nsfwapp/backend/web/dist/assets/index-wVqrTYvi.js
2025-12-30 23:52:25 +01:00

268 lines
1.5 MiB
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function sk(s,e){for(var t=0;t<e.length;t++){const i=e[t];if(typeof i!="string"&&!Array.isArray(i)){for(const n in i)if(n!=="default"&&!(n in s)){const r=Object.getOwnPropertyDescriptor(i,n);r&&Object.defineProperty(s,n,r.get?r:{enumerable:!0,get:()=>i[n]})}}}return Object.freeze(Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))i(n);new MutationObserver(n=>{for(const r of n)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function t(n){const r={};return n.integrity&&(r.integrity=n.integrity),n.referrerPolicy&&(r.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?r.credentials="include":n.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(n){if(n.ep)return;n.ep=!0;const r=t(n);fetch(n.href,r)}})();var Dp=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ac(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function nk(s){if(Object.prototype.hasOwnProperty.call(s,"__esModule"))return s;var e=s.default;if(typeof e=="function"){var t=function i(){var n=!1;try{n=this instanceof i}catch{}return n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(s).forEach(function(i){var n=Object.getOwnPropertyDescriptor(s,i);Object.defineProperty(t,i,n.get?n:{enumerable:!0,get:function(){return s[i]}})}),t}var F0={exports:{}},pd={};var mS;function rk(){if(mS)return pd;mS=1;var s=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(i,n,r){var o=null;if(r!==void 0&&(o=""+r),n.key!==void 0&&(o=""+n.key),"key"in n){r={};for(var u in n)u!=="key"&&(r[u]=n[u])}else r=n;return n=r.ref,{$$typeof:s,type:i,key:o,ref:n!==void 0?n:null,props:r}}return pd.Fragment=e,pd.jsx=t,pd.jsxs=t,pd}var gS;function ak(){return gS||(gS=1,F0.exports=rk()),F0.exports}var P=ak(),U0={exports:{}},Tt={};var yS;function ok(){if(yS)return Tt;yS=1;var s=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),n=Symbol.for("react.profiler"),r=Symbol.for("react.consumer"),o=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),m=Symbol.for("react.activity"),g=Symbol.iterator;function v(U){return U===null||typeof U!="object"?null:(U=g&&U[g]||U["@@iterator"],typeof U=="function"?U:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,E={};function w(U,ie,fe){this.props=U,this.context=ie,this.refs=E,this.updater=fe||b}w.prototype.isReactComponent={},w.prototype.setState=function(U,ie){if(typeof U!="object"&&typeof U!="function"&&U!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,U,ie,"setState")},w.prototype.forceUpdate=function(U){this.updater.enqueueForceUpdate(this,U,"forceUpdate")};function I(){}I.prototype=w.prototype;function L(U,ie,fe){this.props=U,this.context=ie,this.refs=E,this.updater=fe||b}var F=L.prototype=new I;F.constructor=L,_(F,w.prototype),F.isPureReactComponent=!0;var $=Array.isArray;function G(){}var B={H:null,A:null,T:null,S:null},V=Object.prototype.hasOwnProperty;function k(U,ie,fe){var xe=fe.ref;return{$$typeof:s,type:U,key:ie,ref:xe!==void 0?xe:null,props:fe}}function R(U,ie){return k(U.type,ie,U.props)}function z(U){return typeof U=="object"&&U!==null&&U.$$typeof===s}function X(U){var ie={"=":"=0",":":"=2"};return"$"+U.replace(/[=:]/g,function(fe){return ie[fe]})}var ee=/\/+/g;function le(U,ie){return typeof U=="object"&&U!==null&&U.key!=null?X(""+U.key):ie.toString(36)}function oe(U){switch(U.status){case"fulfilled":return U.value;case"rejected":throw U.reason;default:switch(typeof U.status=="string"?U.then(G,G):(U.status="pending",U.then(function(ie){U.status==="pending"&&(U.status="fulfilled",U.value=ie)},function(ie){U.status==="pending"&&(U.status="rejected",U.reason=ie)})),U.status){case"fulfilled":return U.value;case"rejected":throw U.reason}}throw U}function Y(U,ie,fe,xe,Ae){var $e=typeof U;($e==="undefined"||$e==="boolean")&&(U=null);var Ee=!1;if(U===null)Ee=!0;else switch($e){case"bigint":case"string":case"number":Ee=!0;break;case"object":switch(U.$$typeof){case s:case e:Ee=!0;break;case f:return Ee=U._init,Y(Ee(U._payload),ie,fe,xe,Ae)}}if(Ee)return Ae=Ae(U),Ee=xe===""?"."+le(U,0):xe,$(Ae)?(fe="",Ee!=null&&(fe=Ee.replace(ee,"$&/")+"/"),Y(Ae,ie,fe,"",function(et){return et})):Ae!=null&&(z(Ae)&&(Ae=R(Ae,fe+(Ae.key==null||U&&U.key===Ae.key?"":(""+Ae.key).replace(ee,"$&/")+"/")+Ee)),ie.push(Ae)),1;Ee=0;var je=xe===""?".":xe+":";if($(U))for(var qe=0;qe<U.length;qe++)xe=U[qe],$e=je+le(xe,qe),Ee+=Y(xe,ie,fe,$e,Ae);else if(qe=v(U),typeof qe=="function")for(U=qe.call(U),qe=0;!(xe=U.next()).done;)xe=xe.value,$e=je+le(xe,qe++),Ee+=Y(xe,ie,fe,$e,Ae);else if($e==="object"){if(typeof U.then=="function")return Y(oe(U),ie,fe,xe,Ae);throw ie=String(U),Error("Objects are not valid as a React child (found: "+(ie==="[object Object]"?"object with keys {"+Object.keys(U).join(", ")+"}":ie)+"). If you meant to render a collection of children, use an array instead.")}return Ee}function Z(U,ie,fe){if(U==null)return U;var xe=[],Ae=0;return Y(U,xe,"","",function($e){return ie.call(fe,$e,Ae++)}),xe}function Q(U){if(U._status===-1){var ie=U._result;ie=ie(),ie.then(function(fe){(U._status===0||U._status===-1)&&(U._status=1,U._result=fe)},function(fe){(U._status===0||U._status===-1)&&(U._status=2,U._result=fe)}),U._status===-1&&(U._status=0,U._result=ie)}if(U._status===1)return U._result.default;throw U._result}var ae=typeof reportError=="function"?reportError:function(U){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var ie=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof U=="object"&&U!==null&&typeof U.message=="string"?String(U.message):String(U),error:U});if(!window.dispatchEvent(ie))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",U);return}console.error(U)},ue={map:Z,forEach:function(U,ie,fe){Z(U,function(){ie.apply(this,arguments)},fe)},count:function(U){var ie=0;return Z(U,function(){ie++}),ie},toArray:function(U){return Z(U,function(ie){return ie})||[]},only:function(U){if(!z(U))throw Error("React.Children.only expected to receive a single React element child.");return U}};return Tt.Activity=m,Tt.Children=ue,Tt.Component=w,Tt.Fragment=t,Tt.Profiler=n,Tt.PureComponent=L,Tt.StrictMode=i,Tt.Suspense=c,Tt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=B,Tt.__COMPILER_RUNTIME={__proto__:null,c:function(U){return B.H.useMemoCache(U)}},Tt.cache=function(U){return function(){return U.apply(null,arguments)}},Tt.cacheSignal=function(){return null},Tt.cloneElement=function(U,ie,fe){if(U==null)throw Error("The argument must be a React element, but you passed "+U+".");var xe=_({},U.props),Ae=U.key;if(ie!=null)for($e in ie.key!==void 0&&(Ae=""+ie.key),ie)!V.call(ie,$e)||$e==="key"||$e==="__self"||$e==="__source"||$e==="ref"&&ie.ref===void 0||(xe[$e]=ie[$e]);var $e=arguments.length-2;if($e===1)xe.children=fe;else if(1<$e){for(var Ee=Array($e),je=0;je<$e;je++)Ee[je]=arguments[je+2];xe.children=Ee}return k(U.type,Ae,xe)},Tt.createContext=function(U){return U={$$typeof:o,_currentValue:U,_currentValue2:U,_threadCount:0,Provider:null,Consumer:null},U.Provider=U,U.Consumer={$$typeof:r,_context:U},U},Tt.createElement=function(U,ie,fe){var xe,Ae={},$e=null;if(ie!=null)for(xe in ie.key!==void 0&&($e=""+ie.key),ie)V.call(ie,xe)&&xe!=="key"&&xe!=="__self"&&xe!=="__source"&&(Ae[xe]=ie[xe]);var Ee=arguments.length-2;if(Ee===1)Ae.children=fe;else if(1<Ee){for(var je=Array(Ee),qe=0;qe<Ee;qe++)je[qe]=arguments[qe+2];Ae.children=je}if(U&&U.defaultProps)for(xe in Ee=U.defaultProps,Ee)Ae[xe]===void 0&&(Ae[xe]=Ee[xe]);return k(U,$e,Ae)},Tt.createRef=function(){return{current:null}},Tt.forwardRef=function(U){return{$$typeof:u,render:U}},Tt.isValidElement=z,Tt.lazy=function(U){return{$$typeof:f,_payload:{_status:-1,_result:U},_init:Q}},Tt.memo=function(U,ie){return{$$typeof:d,type:U,compare:ie===void 0?null:ie}},Tt.startTransition=function(U){var ie=B.T,fe={};B.T=fe;try{var xe=U(),Ae=B.S;Ae!==null&&Ae(fe,xe),typeof xe=="object"&&xe!==null&&typeof xe.then=="function"&&xe.then(G,ae)}catch($e){ae($e)}finally{ie!==null&&fe.types!==null&&(ie.types=fe.types),B.T=ie}},Tt.unstable_useCacheRefresh=function(){return B.H.useCacheRefresh()},Tt.use=function(U){return B.H.use(U)},Tt.useActionState=function(U,ie,fe){return B.H.useActionState(U,ie,fe)},Tt.useCallback=function(U,ie){return B.H.useCallback(U,ie)},Tt.useContext=function(U){return B.H.useContext(U)},Tt.useDebugValue=function(){},Tt.useDeferredValue=function(U,ie){return B.H.useDeferredValue(U,ie)},Tt.useEffect=function(U,ie){return B.H.useEffect(U,ie)},Tt.useEffectEvent=function(U){return B.H.useEffectEvent(U)},Tt.useId=function(){return B.H.useId()},Tt.useImperativeHandle=function(U,ie,fe){return B.H.useImperativeHandle(U,ie,fe)},Tt.useInsertionEffect=function(U,ie){return B.H.useInsertionEffect(U,ie)},Tt.useLayoutEffect=function(U,ie){return B.H.useLayoutEffect(U,ie)},Tt.useMemo=function(U,ie){return B.H.useMemo(U,ie)},Tt.useOptimistic=function(U,ie){return B.H.useOptimistic(U,ie)},Tt.useReducer=function(U,ie,fe){return B.H.useReducer(U,ie,fe)},Tt.useRef=function(U){return B.H.useRef(U)},Tt.useState=function(U){return B.H.useState(U)},Tt.useSyncExternalStore=function(U,ie,fe){return B.H.useSyncExternalStore(U,ie,fe)},Tt.useTransition=function(){return B.H.useTransition()},Tt.version="19.2.3",Tt}var vS;function lm(){return vS||(vS=1,U0.exports=ok()),U0.exports}var j=lm();const yt=ac(j),TS=sk({__proto__:null,default:yt},[j]);var $0={exports:{}},md={},j0={exports:{}},H0={};var bS;function lk(){return bS||(bS=1,(function(s){function e(Y,Z){var Q=Y.length;Y.push(Z);e:for(;0<Q;){var ae=Q-1>>>1,ue=Y[ae];if(0<n(ue,Z))Y[ae]=Z,Y[Q]=ue,Q=ae;else break e}}function t(Y){return Y.length===0?null:Y[0]}function i(Y){if(Y.length===0)return null;var Z=Y[0],Q=Y.pop();if(Q!==Z){Y[0]=Q;e:for(var ae=0,ue=Y.length,U=ue>>>1;ae<U;){var ie=2*(ae+1)-1,fe=Y[ie],xe=ie+1,Ae=Y[xe];if(0>n(fe,Q))xe<ue&&0>n(Ae,fe)?(Y[ae]=Ae,Y[xe]=Q,ae=xe):(Y[ae]=fe,Y[ie]=Q,ae=ie);else if(xe<ue&&0>n(Ae,Q))Y[ae]=Ae,Y[xe]=Q,ae=xe;else break e}}return Z}function n(Y,Z){var Q=Y.sortIndex-Z.sortIndex;return Q!==0?Q:Y.id-Z.id}if(s.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var r=performance;s.unstable_now=function(){return r.now()}}else{var o=Date,u=o.now();s.unstable_now=function(){return o.now()-u}}var c=[],d=[],f=1,m=null,g=3,v=!1,b=!1,_=!1,E=!1,w=typeof setTimeout=="function"?setTimeout:null,I=typeof clearTimeout=="function"?clearTimeout:null,L=typeof setImmediate<"u"?setImmediate:null;function F(Y){for(var Z=t(d);Z!==null;){if(Z.callback===null)i(d);else if(Z.startTime<=Y)i(d),Z.sortIndex=Z.expirationTime,e(c,Z);else break;Z=t(d)}}function $(Y){if(_=!1,F(Y),!b)if(t(c)!==null)b=!0,G||(G=!0,X());else{var Z=t(d);Z!==null&&oe($,Z.startTime-Y)}}var G=!1,B=-1,V=5,k=-1;function R(){return E?!0:!(s.unstable_now()-k<V)}function z(){if(E=!1,G){var Y=s.unstable_now();k=Y;var Z=!0;try{e:{b=!1,_&&(_=!1,I(B),B=-1),v=!0;var Q=g;try{t:{for(F(Y),m=t(c);m!==null&&!(m.expirationTime>Y&&R());){var ae=m.callback;if(typeof ae=="function"){m.callback=null,g=m.priorityLevel;var ue=ae(m.expirationTime<=Y);if(Y=s.unstable_now(),typeof ue=="function"){m.callback=ue,F(Y),Z=!0;break t}m===t(c)&&i(c),F(Y)}else i(c);m=t(c)}if(m!==null)Z=!0;else{var U=t(d);U!==null&&oe($,U.startTime-Y),Z=!1}}break e}finally{m=null,g=Q,v=!1}Z=void 0}}finally{Z?X():G=!1}}}var X;if(typeof L=="function")X=function(){L(z)};else if(typeof MessageChannel<"u"){var ee=new MessageChannel,le=ee.port2;ee.port1.onmessage=z,X=function(){le.postMessage(null)}}else X=function(){w(z,0)};function oe(Y,Z){B=w(function(){Y(s.unstable_now())},Z)}s.unstable_IdlePriority=5,s.unstable_ImmediatePriority=1,s.unstable_LowPriority=4,s.unstable_NormalPriority=3,s.unstable_Profiling=null,s.unstable_UserBlockingPriority=2,s.unstable_cancelCallback=function(Y){Y.callback=null},s.unstable_forceFrameRate=function(Y){0>Y||125<Y?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):V=0<Y?Math.floor(1e3/Y):5},s.unstable_getCurrentPriorityLevel=function(){return g},s.unstable_next=function(Y){switch(g){case 1:case 2:case 3:var Z=3;break;default:Z=g}var Q=g;g=Z;try{return Y()}finally{g=Q}},s.unstable_requestPaint=function(){E=!0},s.unstable_runWithPriority=function(Y,Z){switch(Y){case 1:case 2:case 3:case 4:case 5:break;default:Y=3}var Q=g;g=Y;try{return Z()}finally{g=Q}},s.unstable_scheduleCallback=function(Y,Z,Q){var ae=s.unstable_now();switch(typeof Q=="object"&&Q!==null?(Q=Q.delay,Q=typeof Q=="number"&&0<Q?ae+Q:ae):Q=ae,Y){case 1:var ue=-1;break;case 2:ue=250;break;case 5:ue=1073741823;break;case 4:ue=1e4;break;default:ue=5e3}return ue=Q+ue,Y={id:f++,callback:Z,priorityLevel:Y,startTime:Q,expirationTime:ue,sortIndex:-1},Q>ae?(Y.sortIndex=Q,e(d,Y),t(c)===null&&Y===t(d)&&(_?(I(B),B=-1):_=!0,oe($,Q-ae))):(Y.sortIndex=ue,e(c,Y),b||v||(b=!0,G||(G=!0,X()))),Y},s.unstable_shouldYield=R,s.unstable_wrapCallback=function(Y){var Z=g;return function(){var Q=g;g=Z;try{return Y.apply(this,arguments)}finally{g=Q}}}})(H0)),H0}var _S;function uk(){return _S||(_S=1,j0.exports=lk()),j0.exports}var G0={exports:{}},Ss={};var xS;function ck(){if(xS)return Ss;xS=1;var s=lm();function e(c){var d="https://react.dev/errors/"+c;if(1<arguments.length){d+="?args[]="+encodeURIComponent(arguments[1]);for(var f=2;f<arguments.length;f++)d+="&args[]="+encodeURIComponent(arguments[f])}return"Minified React error #"+c+"; visit "+d+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function t(){}var i={d:{f:t,r:function(){throw Error(e(522))},D:t,C:t,L:t,m:t,X:t,S:t,M:t},p:0,findDOMNode:null},n=Symbol.for("react.portal");function r(c,d,f){var m=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:n,key:m==null?null:""+m,children:c,containerInfo:d,implementation:f}}var o=s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(c,d){if(c==="font")return"";if(typeof d=="string")return d==="use-credentials"?d:""}return Ss.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,Ss.createPortal=function(c,d){var f=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!d||d.nodeType!==1&&d.nodeType!==9&&d.nodeType!==11)throw Error(e(299));return r(c,d,null,f)},Ss.flushSync=function(c){var d=o.T,f=i.p;try{if(o.T=null,i.p=2,c)return c()}finally{o.T=d,i.p=f,i.d.f()}},Ss.preconnect=function(c,d){typeof c=="string"&&(d?(d=d.crossOrigin,d=typeof d=="string"?d==="use-credentials"?d:"":void 0):d=null,i.d.C(c,d))},Ss.prefetchDNS=function(c){typeof c=="string"&&i.d.D(c)},Ss.preinit=function(c,d){if(typeof c=="string"&&d&&typeof d.as=="string"){var f=d.as,m=u(f,d.crossOrigin),g=typeof d.integrity=="string"?d.integrity:void 0,v=typeof d.fetchPriority=="string"?d.fetchPriority:void 0;f==="style"?i.d.S(c,typeof d.precedence=="string"?d.precedence:void 0,{crossOrigin:m,integrity:g,fetchPriority:v}):f==="script"&&i.d.X(c,{crossOrigin:m,integrity:g,fetchPriority:v,nonce:typeof d.nonce=="string"?d.nonce:void 0})}},Ss.preinitModule=function(c,d){if(typeof c=="string")if(typeof d=="object"&&d!==null){if(d.as==null||d.as==="script"){var f=u(d.as,d.crossOrigin);i.d.M(c,{crossOrigin:f,integrity:typeof d.integrity=="string"?d.integrity:void 0,nonce:typeof d.nonce=="string"?d.nonce:void 0})}}else d==null&&i.d.M(c)},Ss.preload=function(c,d){if(typeof c=="string"&&typeof d=="object"&&d!==null&&typeof d.as=="string"){var f=d.as,m=u(f,d.crossOrigin);i.d.L(c,f,{crossOrigin:m,integrity:typeof d.integrity=="string"?d.integrity:void 0,nonce:typeof d.nonce=="string"?d.nonce:void 0,type:typeof d.type=="string"?d.type:void 0,fetchPriority:typeof d.fetchPriority=="string"?d.fetchPriority:void 0,referrerPolicy:typeof d.referrerPolicy=="string"?d.referrerPolicy:void 0,imageSrcSet:typeof d.imageSrcSet=="string"?d.imageSrcSet:void 0,imageSizes:typeof d.imageSizes=="string"?d.imageSizes:void 0,media:typeof d.media=="string"?d.media:void 0})}},Ss.preloadModule=function(c,d){if(typeof c=="string")if(d){var f=u(d.as,d.crossOrigin);i.d.m(c,{as:typeof d.as=="string"&&d.as!=="script"?d.as:void 0,crossOrigin:f,integrity:typeof d.integrity=="string"?d.integrity:void 0})}else i.d.m(c)},Ss.requestFormReset=function(c){i.d.r(c)},Ss.unstable_batchedUpdates=function(c,d){return c(d)},Ss.useFormState=function(c,d,f){return o.H.useFormState(c,d,f)},Ss.useFormStatus=function(){return o.H.useHostTransitionStatus()},Ss.version="19.2.3",Ss}var SS;function z2(){if(SS)return G0.exports;SS=1;function s(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(s)}catch(e){console.error(e)}}return s(),G0.exports=ck(),G0.exports}var ES;function dk(){if(ES)return md;ES=1;var s=uk(),e=lm(),t=z2();function i(a){var l="https://react.dev/errors/"+a;if(1<arguments.length){l+="?args[]="+encodeURIComponent(arguments[1]);for(var h=2;h<arguments.length;h++)l+="&args[]="+encodeURIComponent(arguments[h])}return"Minified React error #"+a+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function r(a){var l=a,h=a;if(a.alternate)for(;l.return;)l=l.return;else{a=l;do l=a,(l.flags&4098)!==0&&(h=l.return),a=l.return;while(a)}return l.tag===3?h:null}function o(a){if(a.tag===13){var l=a.memoizedState;if(l===null&&(a=a.alternate,a!==null&&(l=a.memoizedState)),l!==null)return l.dehydrated}return null}function u(a){if(a.tag===31){var l=a.memoizedState;if(l===null&&(a=a.alternate,a!==null&&(l=a.memoizedState)),l!==null)return l.dehydrated}return null}function c(a){if(r(a)!==a)throw Error(i(188))}function d(a){var l=a.alternate;if(!l){if(l=r(a),l===null)throw Error(i(188));return l!==a?null:a}for(var h=a,p=l;;){var T=h.return;if(T===null)break;var x=T.alternate;if(x===null){if(p=T.return,p!==null){h=p;continue}break}if(T.child===x.child){for(x=T.child;x;){if(x===h)return c(T),a;if(x===p)return c(T),l;x=x.sibling}throw Error(i(188))}if(h.return!==p.return)h=T,p=x;else{for(var M=!1,q=T.child;q;){if(q===h){M=!0,h=T,p=x;break}if(q===p){M=!0,p=T,h=x;break}q=q.sibling}if(!M){for(q=x.child;q;){if(q===h){M=!0,h=x,p=T;break}if(q===p){M=!0,p=x,h=T;break}q=q.sibling}if(!M)throw Error(i(189))}}if(h.alternate!==p)throw Error(i(190))}if(h.tag!==3)throw Error(i(188));return h.stateNode.current===h?a:l}function f(a){var l=a.tag;if(l===5||l===26||l===27||l===6)return a;for(a=a.child;a!==null;){if(l=f(a),l!==null)return l;a=a.sibling}return null}var m=Object.assign,g=Symbol.for("react.element"),v=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),_=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),I=Symbol.for("react.consumer"),L=Symbol.for("react.context"),F=Symbol.for("react.forward_ref"),$=Symbol.for("react.suspense"),G=Symbol.for("react.suspense_list"),B=Symbol.for("react.memo"),V=Symbol.for("react.lazy"),k=Symbol.for("react.activity"),R=Symbol.for("react.memo_cache_sentinel"),z=Symbol.iterator;function X(a){return a===null||typeof a!="object"?null:(a=z&&a[z]||a["@@iterator"],typeof a=="function"?a:null)}var ee=Symbol.for("react.client.reference");function le(a){if(a==null)return null;if(typeof a=="function")return a.$$typeof===ee?null:a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case _:return"Fragment";case w:return"Profiler";case E:return"StrictMode";case $:return"Suspense";case G:return"SuspenseList";case k:return"Activity"}if(typeof a=="object")switch(a.$$typeof){case b:return"Portal";case L:return a.displayName||"Context";case I:return(a._context.displayName||"Context")+".Consumer";case F:var l=a.render;return a=a.displayName,a||(a=l.displayName||l.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case B:return l=a.displayName||null,l!==null?l:le(a.type)||"Memo";case V:l=a._payload,a=a._init;try{return le(a(l))}catch{}}return null}var oe=Array.isArray,Y=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z=t.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q={pending:!1,data:null,method:null,action:null},ae=[],ue=-1;function U(a){return{current:a}}function ie(a){0>ue||(a.current=ae[ue],ae[ue]=null,ue--)}function fe(a,l){ue++,ae[ue]=a.current,a.current=l}var xe=U(null),Ae=U(null),$e=U(null),Ee=U(null);function je(a,l){switch(fe($e,l),fe(Ae,a),fe(xe,null),l.nodeType){case 9:case 11:a=(a=l.documentElement)&&(a=a.namespaceURI)?Fx(a):0;break;default:if(a=l.tagName,l=l.namespaceURI)l=Fx(l),a=Ux(l,a);else switch(a){case"svg":a=1;break;case"math":a=2;break;default:a=0}}ie(xe),fe(xe,a)}function qe(){ie(xe),ie(Ae),ie($e)}function et(a){a.memoizedState!==null&&fe(Ee,a);var l=xe.current,h=Ux(l,a.type);l!==h&&(fe(Ae,a),fe(xe,h))}function rt(a){Ae.current===a&&(ie(xe),ie(Ae)),Ee.current===a&&(ie(Ee),cd._currentValue=Q)}var ht,qt;function xt(a){if(ht===void 0)try{throw Error()}catch(h){var l=h.stack.trim().match(/\n( *(at )?)/);ht=l&&l[1]||"",qt=-1<h.stack.indexOf(`
at`)?" (<anonymous>)":-1<h.stack.indexOf("@")?"@unknown:0:0":""}return`
`+ht+a+qt}var Ri=!1;function Be(a,l){if(!a||Ri)return"";Ri=!0;var h=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var p={DetermineComponentFrameRoot:function(){try{if(l){var Ne=function(){throw Error()};if(Object.defineProperty(Ne.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ne,[])}catch(Ie){var De=Ie}Reflect.construct(a,[],Ne)}else{try{Ne.call()}catch(Ie){De=Ie}a.call(Ne.prototype)}}else{try{throw Error()}catch(Ie){De=Ie}(Ne=a())&&typeof Ne.catch=="function"&&Ne.catch(function(){})}}catch(Ie){if(Ie&&De&&typeof Ie.stack=="string")return[Ie.stack,De.stack]}return[null,null]}};p.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var T=Object.getOwnPropertyDescriptor(p.DetermineComponentFrameRoot,"name");T&&T.configurable&&Object.defineProperty(p.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var x=p.DetermineComponentFrameRoot(),M=x[0],q=x[1];if(M&&q){var ce=M.split(`
`),_e=q.split(`
`);for(T=p=0;p<ce.length&&!ce[p].includes("DetermineComponentFrameRoot");)p++;for(;T<_e.length&&!_e[T].includes("DetermineComponentFrameRoot");)T++;if(p===ce.length||T===_e.length)for(p=ce.length-1,T=_e.length-1;1<=p&&0<=T&&ce[p]!==_e[T];)T--;for(;1<=p&&0<=T;p--,T--)if(ce[p]!==_e[T]){if(p!==1||T!==1)do if(p--,T--,0>T||ce[p]!==_e[T]){var Oe=`
`+ce[p].replace(" at new "," at ");return a.displayName&&Oe.includes("<anonymous>")&&(Oe=Oe.replace("<anonymous>",a.displayName)),Oe}while(1<=p&&0<=T);break}}}finally{Ri=!1,Error.prepareStackTrace=h}return(h=a?a.displayName||a.name:"")?xt(h):""}function Xe(a,l){switch(a.tag){case 26:case 27:case 5:return xt(a.type);case 16:return xt("Lazy");case 13:return a.child!==l&&l!==null?xt("Suspense Fallback"):xt("Suspense");case 19:return xt("SuspenseList");case 0:case 15:return Be(a.type,!1);case 11:return Be(a.type.render,!1);case 1:return Be(a.type,!0);case 31:return xt("Activity");default:return""}}function ft(a){try{var l="",h=null;do l+=Xe(a,h),h=a,a=a.return;while(a);return l}catch(p){return`
Error generating stack: `+p.message+`
`+p.stack}}var At=Object.prototype.hasOwnProperty,we=s.unstable_scheduleCallback,Fe=s.unstable_cancelCallback,Ue=s.unstable_shouldYield,Ke=s.unstable_requestPaint,Ye=s.unstable_now,gt=s.unstable_getCurrentPriorityLevel,Lt=s.unstable_ImmediatePriority,$t=s.unstable_UserBlockingPriority,fi=s.unstable_NormalPriority,pi=s.unstable_LowPriority,ts=s.unstable_IdlePriority,vs=s.log,Et=s.unstable_setDisableYieldValue,de=null,ye=null;function Se(a){if(typeof vs=="function"&&Et(a),ye&&typeof ye.setStrictMode=="function")try{ye.setStrictMode(de,a)}catch{}}var He=Math.clz32?Math.clz32:Oi,it=Math.log,gi=Math.LN2;function Oi(a){return a>>>=0,a===0?32:31-(it(a)/gi|0)|0}var Wi=256,Ht=262144,ws=4194304;function H(a){var l=a&42;if(l!==0)return l;switch(a&-a){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return a&261888;case 262144:case 524288:case 1048576:case 2097152:return a&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return a&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return a}}function K(a,l,h){var p=a.pendingLanes;if(p===0)return 0;var T=0,x=a.suspendedLanes,M=a.pingedLanes;a=a.warmLanes;var q=p&134217727;return q!==0?(p=q&~x,p!==0?T=H(p):(M&=q,M!==0?T=H(M):h||(h=q&~a,h!==0&&(T=H(h))))):(q=p&~x,q!==0?T=H(q):M!==0?T=H(M):h||(h=p&~a,h!==0&&(T=H(h)))),T===0?0:l!==0&&l!==T&&(l&x)===0&&(x=T&-T,h=l&-l,x>=h||x===32&&(h&4194048)!==0)?l:T}function se(a,l){return(a.pendingLanes&~(a.suspendedLanes&~a.pingedLanes)&l)===0}function Ce(a,l){switch(a){case 1:case 2:case 4:case 8:case 64:return l+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ge(){var a=ws;return ws<<=1,(ws&62914560)===0&&(ws=4194304),a}function at(a){for(var l=[],h=0;31>h;h++)l.push(a);return l}function Mt(a,l){a.pendingLanes|=l,l!==268435456&&(a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0)}function xi(a,l,h,p,T,x){var M=a.pendingLanes;a.pendingLanes=h,a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0,a.expiredLanes&=h,a.entangledLanes&=h,a.errorRecoveryDisabledLanes&=h,a.shellSuspendCounter=0;var q=a.entanglements,ce=a.expirationTimes,_e=a.hiddenUpdates;for(h=M&~h;0<h;){var Oe=31-He(h),Ne=1<<Oe;q[Oe]=0,ce[Oe]=-1;var De=_e[Oe];if(De!==null)for(_e[Oe]=null,Oe=0;Oe<De.length;Oe++){var Ie=De[Oe];Ie!==null&&(Ie.lane&=-536870913)}h&=~Ne}p!==0&&Pi(a,p,0),x!==0&&T===0&&a.tag!==0&&(a.suspendedLanes|=x&~(M&~l))}function Pi(a,l,h){a.pendingLanes|=l,a.suspendedLanes&=~l;var p=31-He(l);a.entangledLanes|=l,a.entanglements[p]=a.entanglements[p]|1073741824|h&261930}function ut(a,l){var h=a.entangledLanes|=l;for(a=a.entanglements;h;){var p=31-He(h),T=1<<p;T&l|a[p]&l&&(a[p]|=l),h&=~T}}function Mi(a,l){var h=l&-l;return h=(h&42)!==0?1:Ts(h),(h&(a.suspendedLanes|l))!==0?0:h}function Ts(a){switch(a){case 2:a=1;break;case 8:a=4;break;case 32:a=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:a=128;break;case 268435456:a=134217728;break;default:a=0}return a}function ci(a){return a&=-a,2<a?8<a?(a&134217727)!==0?32:268435456:8:2}function An(){var a=Z.p;return a!==0?a:(a=window.event,a===void 0?32:lS(a.type))}function Ls(a,l){var h=Z.p;try{return Z.p=a,l()}finally{Z.p=h}}var Ni=Math.random().toString(36).slice(2),jt="__reactFiber$"+Ni,Nt="__reactProps$"+Ni,kt="__reactContainer$"+Ni,Cn="__reactEvents$"+Ni,jr="__reactListeners$"+Ni,wl="__reactHandles$"+Ni,hh="__reactResources$"+Ni,an="__reactMarker$"+Ni;function Jt(a){delete a[jt],delete a[Nt],delete a[Cn],delete a[jr],delete a[wl]}function Hr(a){var l=a[jt];if(l)return l;for(var h=a.parentNode;h;){if(l=h[kt]||h[jt]){if(h=l.alternate,l.child!==null||h!==null&&h.child!==null)for(a=zx(a);a!==null;){if(h=a[jt])return h;a=zx(a)}return l}a=h,h=a.parentNode}return null}function Hn(a){if(a=a[jt]||a[kt]){var l=a.tag;if(l===5||l===6||l===13||l===31||l===26||l===27||l===3)return a}return null}function Do(a){var l=a.tag;if(l===5||l===26||l===27||l===6)return a.stateNode;throw Error(i(33))}function xa(a){var l=a[hh];return l||(l=a[hh]={hoistableStyles:new Map,hoistableScripts:new Map}),l}function Gi(a){a[an]=!0}var pc=new Set,Ll={};function Gn(a,l){Gr(a,l),Gr(a+"Capture",l)}function Gr(a,l){for(Ll[a]=l,a=0;a<l.length;a++)pc.add(l[a])}var Vm=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),fh={},wo={};function Il(a){return At.call(wo,a)?!0:At.call(fh,a)?!1:Vm.test(a)?wo[a]=!0:(fh[a]=!0,!1)}function Lo(a,l,h){if(Il(l))if(h===null)a.removeAttribute(l);else{switch(typeof h){case"undefined":case"function":case"symbol":a.removeAttribute(l);return;case"boolean":var p=l.toLowerCase().slice(0,5);if(p!=="data-"&&p!=="aria-"){a.removeAttribute(l);return}}a.setAttribute(l,""+h)}}function nr(a,l,h){if(h===null)a.removeAttribute(l);else{switch(typeof h){case"undefined":case"function":case"symbol":case"boolean":a.removeAttribute(l);return}a.setAttribute(l,""+h)}}function Is(a,l,h,p){if(p===null)a.removeAttribute(h);else{switch(typeof p){case"undefined":case"function":case"symbol":case"boolean":a.removeAttribute(h);return}a.setAttributeNS(l,h,""+p)}}function is(a){switch(typeof a){case"bigint":case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function Sa(a){var l=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function qm(a,l,h){var p=Object.getOwnPropertyDescriptor(a.constructor.prototype,l);if(!a.hasOwnProperty(l)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var T=p.get,x=p.set;return Object.defineProperty(a,l,{configurable:!0,get:function(){return T.call(this)},set:function(M){h=""+M,x.call(this,M)}}),Object.defineProperty(a,l,{enumerable:p.enumerable}),{getValue:function(){return h},setValue:function(M){h=""+M},stopTracking:function(){a._valueTracker=null,delete a[l]}}}}function kl(a){if(!a._valueTracker){var l=Sa(a)?"checked":"value";a._valueTracker=qm(a,l,""+a[l])}}function ph(a){if(!a)return!1;var l=a._valueTracker;if(!l)return!0;var h=l.getValue(),p="";return a&&(p=Sa(a)?a.checked?"true":"false":a.value),a=p,a!==h?(l.setValue(a),!0):!1}function Rl(a){if(a=a||(typeof document<"u"?document:void 0),typeof a>"u")return null;try{return a.activeElement||a.body}catch{return a.body}}var rr=/[\n"\\]/g;function cs(a){return a.replace(rr,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mc(a,l,h,p,T,x,M,q){a.name="",M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"?a.type=M:a.removeAttribute("type"),l!=null?M==="number"?(l===0&&a.value===""||a.value!=l)&&(a.value=""+is(l)):a.value!==""+is(l)&&(a.value=""+is(l)):M!=="submit"&&M!=="reset"||a.removeAttribute("value"),l!=null?Io(a,M,is(l)):h!=null?Io(a,M,is(h)):p!=null&&a.removeAttribute("value"),T==null&&x!=null&&(a.defaultChecked=!!x),T!=null&&(a.checked=T&&typeof T!="function"&&typeof T!="symbol"),q!=null&&typeof q!="function"&&typeof q!="symbol"&&typeof q!="boolean"?a.name=""+is(q):a.removeAttribute("name")}function Ol(a,l,h,p,T,x,M,q){if(x!=null&&typeof x!="function"&&typeof x!="symbol"&&typeof x!="boolean"&&(a.type=x),l!=null||h!=null){if(!(x!=="submit"&&x!=="reset"||l!=null)){kl(a);return}h=h!=null?""+is(h):"",l=l!=null?""+is(l):h,q||l===a.value||(a.value=l),a.defaultValue=l}p=p??T,p=typeof p!="function"&&typeof p!="symbol"&&!!p,a.checked=q?a.checked:!!p,a.defaultChecked=!!p,M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"&&(a.name=M),kl(a)}function Io(a,l,h){l==="number"&&Rl(a.ownerDocument)===a||a.defaultValue===""+h||(a.defaultValue=""+h)}function ss(a,l,h,p){if(a=a.options,l){l={};for(var T=0;T<h.length;T++)l["$"+h[T]]=!0;for(h=0;h<a.length;h++)T=l.hasOwnProperty("$"+a[h].value),a[h].selected!==T&&(a[h].selected=T),T&&p&&(a[h].defaultSelected=!0)}else{for(h=""+is(h),l=null,T=0;T<a.length;T++){if(a[T].value===h){a[T].selected=!0,p&&(a[T].defaultSelected=!0);return}l!==null||a[T].disabled||(l=a[T])}l!==null&&(l.selected=!0)}}function mh(a,l,h){if(l!=null&&(l=""+is(l),l!==a.value&&(a.value=l),h==null)){a.defaultValue!==l&&(a.defaultValue=l);return}a.defaultValue=h!=null?""+is(h):""}function ko(a,l,h,p){if(l==null){if(p!=null){if(h!=null)throw Error(i(92));if(oe(p)){if(1<p.length)throw Error(i(93));p=p[0]}h=p}h==null&&(h=""),l=h}h=is(l),a.defaultValue=h,p=a.textContent,p===h&&p!==""&&p!==null&&(a.value=p),kl(a)}function Dn(a,l){if(l){var h=a.firstChild;if(h&&h===a.lastChild&&h.nodeType===3){h.nodeValue=l;return}}a.textContent=l}var Pl=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Vr(a,l,h){var p=l.indexOf("--")===0;h==null||typeof h=="boolean"||h===""?p?a.setProperty(l,""):l==="float"?a.cssFloat="":a[l]="":p?a.setProperty(l,h):typeof h!="number"||h===0||Pl.has(l)?l==="float"?a.cssFloat=h:a[l]=(""+h).trim():a[l]=h+"px"}function Ml(a,l,h){if(l!=null&&typeof l!="object")throw Error(i(62));if(a=a.style,h!=null){for(var p in h)!h.hasOwnProperty(p)||l!=null&&l.hasOwnProperty(p)||(p.indexOf("--")===0?a.setProperty(p,""):p==="float"?a.cssFloat="":a[p]="");for(var T in l)p=l[T],l.hasOwnProperty(T)&&h[T]!==p&&Vr(a,T,p)}else for(var x in l)l.hasOwnProperty(x)&&Vr(a,x,l[x])}function Nl(a){if(a.indexOf("-")===-1)return!1;switch(a){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var gc=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),zm=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Bl(a){return zm.test(""+a)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":a}function Vn(){}var Ea=null;function Fl(a){return a=a.target||a.srcElement||window,a.correspondingUseElement&&(a=a.correspondingUseElement),a.nodeType===3?a.parentNode:a}var Aa=null,qr=null;function gh(a){var l=Hn(a);if(l&&(a=l.stateNode)){var h=a[Nt]||null;e:switch(a=l.stateNode,l.type){case"input":if(mc(a,h.value,h.defaultValue,h.defaultValue,h.checked,h.defaultChecked,h.type,h.name),l=h.name,h.type==="radio"&&l!=null){for(h=a;h.parentNode;)h=h.parentNode;for(h=h.querySelectorAll('input[name="'+cs(""+l)+'"][type="radio"]'),l=0;l<h.length;l++){var p=h[l];if(p!==a&&p.form===a.form){var T=p[Nt]||null;if(!T)throw Error(i(90));mc(p,T.value,T.defaultValue,T.defaultValue,T.checked,T.defaultChecked,T.type,T.name)}}for(l=0;l<h.length;l++)p=h[l],p.form===a.form&&ph(p)}break e;case"textarea":mh(a,h.value,h.defaultValue);break e;case"select":l=h.value,l!=null&&ss(a,!!h.multiple,l,!1)}}}var Ul=!1;function yh(a,l,h){if(Ul)return a(l,h);Ul=!0;try{var p=a(l);return p}finally{if(Ul=!1,(Aa!==null||qr!==null)&&(yf(),Aa&&(l=Aa,a=qr,qr=Aa=null,gh(l),a)))for(l=0;l<a.length;l++)gh(a[l])}}function ar(a,l){var h=a.stateNode;if(h===null)return null;var p=h[Nt]||null;if(p===null)return null;h=p[l];e:switch(l){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(p=!p.disabled)||(a=a.type,p=!(a==="button"||a==="input"||a==="select"||a==="textarea")),a=!p;break e;default:a=!1}if(a)return null;if(h&&typeof h!="function")throw Error(i(231,l,typeof h));return h}var Us=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),$l=!1;if(Us)try{var Ro={};Object.defineProperty(Ro,"passive",{get:function(){$l=!0}}),window.addEventListener("test",Ro,Ro),window.removeEventListener("test",Ro,Ro)}catch{$l=!1}var or=null,jl=null,Oo=null;function vh(){if(Oo)return Oo;var a,l=jl,h=l.length,p,T="value"in or?or.value:or.textContent,x=T.length;for(a=0;a<h&&l[a]===T[a];a++);var M=h-a;for(p=1;p<=M&&l[h-p]===T[x-p];p++);return Oo=T.slice(a,1<p?1-p:void 0)}function Po(a){var l=a.keyCode;return"charCode"in a?(a=a.charCode,a===0&&l===13&&(a=13)):a=l,a===10&&(a=13),32<=a||a===13?a:0}function Hl(){return!0}function Th(){return!1}function bs(a){function l(h,p,T,x,M){this._reactName=h,this._targetInst=T,this.type=p,this.nativeEvent=x,this.target=M,this.currentTarget=null;for(var q in a)a.hasOwnProperty(q)&&(h=a[q],this[q]=h?h(x):x[q]);return this.isDefaultPrevented=(x.defaultPrevented!=null?x.defaultPrevented:x.returnValue===!1)?Hl:Th,this.isPropagationStopped=Th,this}return m(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var h=this.nativeEvent;h&&(h.preventDefault?h.preventDefault():typeof h.returnValue!="unknown"&&(h.returnValue=!1),this.isDefaultPrevented=Hl)},stopPropagation:function(){var h=this.nativeEvent;h&&(h.stopPropagation?h.stopPropagation():typeof h.cancelBubble!="unknown"&&(h.cancelBubble=!0),this.isPropagationStopped=Hl)},persist:function(){},isPersistent:Hl}),l}var zr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Gl=bs(zr),Mo=m({},zr,{view:0,detail:0}),yc=bs(Mo),vc,Vl,lr,ql=m({},Mo,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Tc,button:0,buttons:0,relatedTarget:function(a){return a.relatedTarget===void 0?a.fromElement===a.srcElement?a.toElement:a.fromElement:a.relatedTarget},movementX:function(a){return"movementX"in a?a.movementX:(a!==lr&&(lr&&a.type==="mousemove"?(vc=a.screenX-lr.screenX,Vl=a.screenY-lr.screenY):Vl=vc=0,lr=a),vc)},movementY:function(a){return"movementY"in a?a.movementY:Vl}}),bh=bs(ql),Km=m({},ql,{dataTransfer:0}),Ym=bs(Km),Wm=m({},Mo,{relatedTarget:0}),Ca=bs(Wm),No=m({},zr,{animationName:0,elapsedTime:0,pseudoElement:0}),Bo=bs(No),zl=m({},zr,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),on=bs(zl),qn=m({},zr,{data:0}),Fo=bs(qn),_h={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Xm={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Qm={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Zm(a){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(a):(a=Qm[a])?!!l[a]:!1}function Tc(){return Zm}var xh=m({},Mo,{key:function(a){if(a.key){var l=_h[a.key]||a.key;if(l!=="Unidentified")return l}return a.type==="keypress"?(a=Po(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?Xm[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Tc,charCode:function(a){return a.type==="keypress"?Po(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?Po(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),Sh=bs(xh),Kl=m({},ql,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Da=bs(Kl),Yl=m({},Mo,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Tc}),Kr=bs(Yl),Jm=m({},zr,{propertyName:0,elapsedTime:0,pseudoElement:0}),Eh=bs(Jm),Ah=m({},ql,{deltaX:function(a){return"deltaX"in a?a.deltaX:"wheelDeltaX"in a?-a.wheelDeltaX:0},deltaY:function(a){return"deltaY"in a?a.deltaY:"wheelDeltaY"in a?-a.wheelDeltaY:"wheelDelta"in a?-a.wheelDelta:0},deltaZ:0,deltaMode:0}),Ch=bs(Ah),eg=m({},zr,{newState:0,oldState:0}),tg=bs(eg),ig=[9,13,27,32],wa=Us&&"CompositionEvent"in window,Uo=null;Us&&"documentMode"in document&&(Uo=document.documentMode);var Dh=Us&&"TextEvent"in window&&!Uo,wh=Us&&(!wa||Uo&&8<Uo&&11>=Uo),Lh=" ",bc=!1;function Wl(a,l){switch(a){case"keyup":return ig.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ih(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var La=!1;function sg(a,l){switch(a){case"compositionend":return Ih(l);case"keypress":return l.which!==32?null:(bc=!0,Lh);case"textInput":return a=l.data,a===Lh&&bc?null:a;default:return null}}function _c(a,l){if(La)return a==="compositionend"||!wa&&Wl(a,l)?(a=vh(),Oo=jl=or=null,La=!1,a):null;switch(a){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1<l.char.length)return l.char;if(l.which)return String.fromCharCode(l.which)}return null;case"compositionend":return wh&&l.locale!=="ko"?null:l.data;default:return null}}var ng={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function xc(a){var l=a&&a.nodeName&&a.nodeName.toLowerCase();return l==="input"?!!ng[a.type]:l==="textarea"}function kh(a,l,h,p){Aa?qr?qr.push(p):qr=[p]:Aa=p,l=Ef(l,"onChange"),0<l.length&&(h=new Gl("onChange","change",null,h,p),a.push({event:h,listeners:l}))}var $o=null,Ia=null;function rg(a){Rx(a,0)}function jo(a){var l=Do(a);if(ph(l))return a}function Sc(a,l){if(a==="change")return l}var Ec=!1;if(Us){var Ac;if(Us){var Cc="oninput"in document;if(!Cc){var Ho=document.createElement("div");Ho.setAttribute("oninput","return;"),Cc=typeof Ho.oninput=="function"}Ac=Cc}else Ac=!1;Ec=Ac&&(!document.documentMode||9<document.documentMode)}function Rh(){$o&&($o.detachEvent("onpropertychange",Oh),Ia=$o=null)}function Oh(a){if(a.propertyName==="value"&&jo(Ia)){var l=[];kh(l,Ia,a,Fl(a)),yh(rg,l)}}function ag(a,l,h){a==="focusin"?(Rh(),$o=l,Ia=h,$o.attachEvent("onpropertychange",Oh)):a==="focusout"&&Rh()}function og(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return jo(Ia)}function Ph(a,l){if(a==="click")return jo(l)}function lg(a,l){if(a==="input"||a==="change")return jo(l)}function Go(a,l){return a===l&&(a!==0||1/a===1/l)||a!==a&&l!==l}var _s=typeof Object.is=="function"?Object.is:Go;function ur(a,l){if(_s(a,l))return!0;if(typeof a!="object"||a===null||typeof l!="object"||l===null)return!1;var h=Object.keys(a),p=Object.keys(l);if(h.length!==p.length)return!1;for(p=0;p<h.length;p++){var T=h[p];if(!At.call(l,T)||!_s(a[T],l[T]))return!1}return!0}function ka(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function yi(a,l){var h=ka(a);a=0;for(var p;h;){if(h.nodeType===3){if(p=a+h.textContent.length,a<=l&&p>=l)return{node:h,offset:l-a};a=p}e:{for(;h;){if(h.nextSibling){h=h.nextSibling;break e}h=h.parentNode}h=void 0}h=ka(h)}}function Yr(a,l){return a&&l?a===l?!0:a&&a.nodeType===3?!1:l&&l.nodeType===3?Yr(a,l.parentNode):"contains"in a?a.contains(l):a.compareDocumentPosition?!!(a.compareDocumentPosition(l)&16):!1:!1}function Xl(a){a=a!=null&&a.ownerDocument!=null&&a.ownerDocument.defaultView!=null?a.ownerDocument.defaultView:window;for(var l=Rl(a.document);l instanceof a.HTMLIFrameElement;){try{var h=typeof l.contentWindow.location.href=="string"}catch{h=!1}if(h)a=l.contentWindow;else break;l=Rl(a.document)}return l}function Dc(a){var l=a&&a.nodeName&&a.nodeName.toLowerCase();return l&&(l==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||l==="textarea"||a.contentEditable==="true")}var ug=Us&&"documentMode"in document&&11>=document.documentMode,Ra=null,wc=null,Oa=null,Ql=!1;function Lc(a,l,h){var p=h.window===h?h.document:h.nodeType===9?h:h.ownerDocument;Ql||Ra==null||Ra!==Rl(p)||(p=Ra,"selectionStart"in p&&Dc(p)?p={start:p.selectionStart,end:p.selectionEnd}:(p=(p.ownerDocument&&p.ownerDocument.defaultView||window).getSelection(),p={anchorNode:p.anchorNode,anchorOffset:p.anchorOffset,focusNode:p.focusNode,focusOffset:p.focusOffset}),Oa&&ur(Oa,p)||(Oa=p,p=Ef(wc,"onSelect"),0<p.length&&(l=new Gl("onSelect","select",null,l,h),a.push({event:l,listeners:p}),l.target=Ra)))}function cr(a,l){var h={};return h[a.toLowerCase()]=l.toLowerCase(),h["Webkit"+a]="webkit"+l,h["Moz"+a]="moz"+l,h}var Wr={animationend:cr("Animation","AnimationEnd"),animationiteration:cr("Animation","AnimationIteration"),animationstart:cr("Animation","AnimationStart"),transitionrun:cr("Transition","TransitionRun"),transitionstart:cr("Transition","TransitionStart"),transitioncancel:cr("Transition","TransitionCancel"),transitionend:cr("Transition","TransitionEnd")},Vo={},Ic={};Us&&(Ic=document.createElement("div").style,"AnimationEvent"in window||(delete Wr.animationend.animation,delete Wr.animationiteration.animation,delete Wr.animationstart.animation),"TransitionEvent"in window||delete Wr.transitionend.transition);function zn(a){if(Vo[a])return Vo[a];if(!Wr[a])return a;var l=Wr[a],h;for(h in l)if(l.hasOwnProperty(h)&&h in Ic)return Vo[a]=l[h];return a}var Mh=zn("animationend"),Pa=zn("animationiteration"),Nh=zn("animationstart"),Bh=zn("transitionrun"),Fh=zn("transitionstart"),cg=zn("transitioncancel"),Uh=zn("transitionend"),kc=new Map,Rc="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");Rc.push("scrollEnd");function ln(a,l){kc.set(a,l),Gn(l,[a])}var Ma=typeof reportError=="function"?reportError:function(a){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var l=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof a=="object"&&a!==null&&typeof a.message=="string"?String(a.message):String(a),error:a});if(!window.dispatchEvent(l))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",a);return}console.error(a)},$s=[],Na=0,Oc=0;function Zl(){for(var a=Na,l=Oc=Na=0;l<a;){var h=$s[l];$s[l++]=null;var p=$s[l];$s[l++]=null;var T=$s[l];$s[l++]=null;var x=$s[l];if($s[l++]=null,p!==null&&T!==null){var M=p.pending;M===null?T.next=T:(T.next=M.next,M.next=T),p.pending=T}x!==0&&$h(h,T,x)}}function Jl(a,l,h,p){$s[Na++]=a,$s[Na++]=l,$s[Na++]=h,$s[Na++]=p,Oc|=p,a.lanes|=p,a=a.alternate,a!==null&&(a.lanes|=p)}function Pc(a,l,h,p){return Jl(a,l,h,p),eu(a)}function Xr(a,l){return Jl(a,null,null,l),eu(a)}function $h(a,l,h){a.lanes|=h;var p=a.alternate;p!==null&&(p.lanes|=h);for(var T=!1,x=a.return;x!==null;)x.childLanes|=h,p=x.alternate,p!==null&&(p.childLanes|=h),x.tag===22&&(a=x.stateNode,a===null||a._visibility&1||(T=!0)),a=x,x=x.return;return a.tag===3?(x=a.stateNode,T&&l!==null&&(T=31-He(h),a=x.hiddenUpdates,p=a[T],p===null?a[T]=[l]:p.push(l),l.lane=h|536870912),x):null}function eu(a){if(50<sd)throw sd=0,l0=null,Error(i(185));for(var l=a.return;l!==null;)a=l,l=a.return;return a.tag===3?a.stateNode:null}var Ba={};function dg(a,l,h,p){this.tag=a,this.key=h,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=p,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Di(a,l,h,p){return new dg(a,l,h,p)}function Mc(a){return a=a.prototype,!(!a||!a.isReactComponent)}function Kn(a,l){var h=a.alternate;return h===null?(h=Di(a.tag,l,a.key,a.mode),h.elementType=a.elementType,h.type=a.type,h.stateNode=a.stateNode,h.alternate=a,a.alternate=h):(h.pendingProps=l,h.type=a.type,h.flags=0,h.subtreeFlags=0,h.deletions=null),h.flags=a.flags&65011712,h.childLanes=a.childLanes,h.lanes=a.lanes,h.child=a.child,h.memoizedProps=a.memoizedProps,h.memoizedState=a.memoizedState,h.updateQueue=a.updateQueue,l=a.dependencies,h.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},h.sibling=a.sibling,h.index=a.index,h.ref=a.ref,h.refCleanup=a.refCleanup,h}function jh(a,l){a.flags&=65011714;var h=a.alternate;return h===null?(a.childLanes=0,a.lanes=l,a.child=null,a.subtreeFlags=0,a.memoizedProps=null,a.memoizedState=null,a.updateQueue=null,a.dependencies=null,a.stateNode=null):(a.childLanes=h.childLanes,a.lanes=h.lanes,a.child=h.child,a.subtreeFlags=0,a.deletions=null,a.memoizedProps=h.memoizedProps,a.memoizedState=h.memoizedState,a.updateQueue=h.updateQueue,a.type=h.type,l=h.dependencies,a.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),a}function Nc(a,l,h,p,T,x){var M=0;if(p=a,typeof a=="function")Mc(a)&&(M=1);else if(typeof a=="string")M=qI(a,h,xe.current)?26:a==="html"||a==="head"||a==="body"?27:5;else e:switch(a){case k:return a=Di(31,h,l,T),a.elementType=k,a.lanes=x,a;case _:return dr(h.children,T,x,l);case E:M=8,T|=24;break;case w:return a=Di(12,h,l,T|2),a.elementType=w,a.lanes=x,a;case $:return a=Di(13,h,l,T),a.elementType=$,a.lanes=x,a;case G:return a=Di(19,h,l,T),a.elementType=G,a.lanes=x,a;default:if(typeof a=="object"&&a!==null)switch(a.$$typeof){case L:M=10;break e;case I:M=9;break e;case F:M=11;break e;case B:M=14;break e;case V:M=16,p=null;break e}M=29,h=Error(i(130,a===null?"null":typeof a,"")),p=null}return l=Di(M,h,l,T),l.elementType=a,l.type=p,l.lanes=x,l}function dr(a,l,h,p){return a=Di(7,a,p,l),a.lanes=h,a}function qo(a,l,h){return a=Di(6,a,null,l),a.lanes=h,a}function Bc(a){var l=Di(18,null,null,0);return l.stateNode=a,l}function Fa(a,l,h){return l=Di(4,a.children!==null?a.children:[],a.key,l),l.lanes=h,l.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation},l}var zo=new WeakMap;function js(a,l){if(typeof a=="object"&&a!==null){var h=zo.get(a);return h!==void 0?h:(l={value:a,source:l,stack:ft(l)},zo.set(a,l),l)}return{value:a,source:l,stack:ft(l)}}var Ua=[],$a=0,tu=null,Ko=0,xs=[],Hs=0,hr=null,un=1,ds="";function Ct(a,l){Ua[$a++]=Ko,Ua[$a++]=tu,tu=a,Ko=l}function fr(a,l,h){xs[Hs++]=un,xs[Hs++]=ds,xs[Hs++]=hr,hr=a;var p=un;a=ds;var T=32-He(p)-1;p&=~(1<<T),h+=1;var x=32-He(l)+T;if(30<x){var M=T-T%5;x=(p&(1<<M)-1).toString(32),p>>=M,T-=M,un=1<<32-He(l)+T|h<<T|p,ds=x+a}else un=1<<x|h<<T|p,ds=a}function Xi(a){a.return!==null&&(Ct(a,1),fr(a,1,0))}function Gs(a){for(;a===tu;)tu=Ua[--$a],Ua[$a]=null,Ko=Ua[--$a],Ua[$a]=null;for(;a===hr;)hr=xs[--Hs],xs[Hs]=null,ds=xs[--Hs],xs[Hs]=null,un=xs[--Hs],xs[Hs]=null}function Hh(a,l){xs[Hs++]=un,xs[Hs++]=ds,xs[Hs++]=hr,un=l.id,ds=l.overflow,hr=a}var Vi=null,ri=null,Rt=!1,pr=null,Vs=!1,Fc=Error(i(519));function mr(a){var l=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw A(js(l,a)),Fc}function Gh(a){var l=a.stateNode,h=a.type,p=a.memoizedProps;switch(l[jt]=a,l[Nt]=p,h){case"dialog":Pt("cancel",l),Pt("close",l);break;case"iframe":case"object":case"embed":Pt("load",l);break;case"video":case"audio":for(h=0;h<rd.length;h++)Pt(rd[h],l);break;case"source":Pt("error",l);break;case"img":case"image":case"link":Pt("error",l),Pt("load",l);break;case"details":Pt("toggle",l);break;case"input":Pt("invalid",l),Ol(l,p.value,p.defaultValue,p.checked,p.defaultChecked,p.type,p.name,!0);break;case"select":Pt("invalid",l);break;case"textarea":Pt("invalid",l),ko(l,p.value,p.defaultValue,p.children)}h=p.children,typeof h!="string"&&typeof h!="number"&&typeof h!="bigint"||l.textContent===""+h||p.suppressHydrationWarning===!0||Nx(l.textContent,h)?(p.popover!=null&&(Pt("beforetoggle",l),Pt("toggle",l)),p.onScroll!=null&&Pt("scroll",l),p.onScrollEnd!=null&&Pt("scrollend",l),p.onClick!=null&&(l.onclick=Vn),l=!0):l=!1,l||mr(a,!0)}function Uc(a){for(Vi=a.return;Vi;)switch(Vi.tag){case 5:case 31:case 13:Vs=!1;return;case 27:case 3:Vs=!0;return;default:Vi=Vi.return}}function y(a){if(a!==Vi)return!1;if(!Rt)return Uc(a),Rt=!0,!1;var l=a.tag,h;if((h=l!==3&&l!==27)&&((h=l===5)&&(h=a.type,h=!(h!=="form"&&h!=="button")||S0(a.type,a.memoizedProps)),h=!h),h&&ri&&mr(a),Uc(a),l===13){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(i(317));ri=qx(a)}else if(l===31){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(i(317));ri=qx(a)}else l===27?(l=ri,Ja(a.type)?(a=w0,w0=null,ri=a):ri=l):ri=Vi?In(a.stateNode.nextSibling):null;return!0}function S(){ri=Vi=null,Rt=!1}function C(){var a=pr;return a!==null&&(Ys===null?Ys=a:Ys.push.apply(Ys,a),pr=null),a}function A(a){pr===null?pr=[a]:pr.push(a)}var D=U(null),O=null,W=null;function J(a,l,h){fe(D,l._currentValue),l._currentValue=h}function te(a){a._currentValue=D.current,ie(D)}function re(a,l,h){for(;a!==null;){var p=a.alternate;if((a.childLanes&l)!==l?(a.childLanes|=l,p!==null&&(p.childLanes|=l)):p!==null&&(p.childLanes&l)!==l&&(p.childLanes|=l),a===h)break;a=a.return}}function pe(a,l,h,p){var T=a.child;for(T!==null&&(T.return=a);T!==null;){var x=T.dependencies;if(x!==null){var M=T.child;x=x.firstContext;e:for(;x!==null;){var q=x;x=T;for(var ce=0;ce<l.length;ce++)if(q.context===l[ce]){x.lanes|=h,q=x.alternate,q!==null&&(q.lanes|=h),re(x.return,h,a),p||(M=null);break e}x=q.next}}else if(T.tag===18){if(M=T.return,M===null)throw Error(i(341));M.lanes|=h,x=M.alternate,x!==null&&(x.lanes|=h),re(M,h,a),M=null}else M=T.child;if(M!==null)M.return=T;else for(M=T;M!==null;){if(M===a){M=null;break}if(T=M.sibling,T!==null){T.return=M.return,M=T;break}M=M.return}T=M}}function Le(a,l,h,p){a=null;for(var T=l,x=!1;T!==null;){if(!x){if((T.flags&524288)!==0)x=!0;else if((T.flags&262144)!==0)break}if(T.tag===10){var M=T.alternate;if(M===null)throw Error(i(387));if(M=M.memoizedProps,M!==null){var q=T.type;_s(T.pendingProps.value,M.value)||(a!==null?a.push(q):a=[q])}}else if(T===Ee.current){if(M=T.alternate,M===null)throw Error(i(387));M.memoizedState.memoizedState!==T.memoizedState.memoizedState&&(a!==null?a.push(cd):a=[cd])}T=T.return}a!==null&&pe(l,a,h,p),l.flags|=262144}function ze(a){for(a=a.firstContext;a!==null;){if(!_s(a.context._currentValue,a.memoizedValue))return!0;a=a.next}return!1}function Re(a){O=a,W=null,a=a.dependencies,a!==null&&(a.firstContext=null)}function Qe(a){return Bi(O,a)}function mt(a,l){return O===null&&Re(a),Bi(a,l)}function Bi(a,l){var h=l._currentValue;if(l={context:l,memoizedValue:h,next:null},W===null){if(a===null)throw Error(i(308));W=l,a.dependencies={lanes:0,firstContext:l},a.flags|=524288}else W=W.next=l;return h}var ks=typeof AbortController<"u"?AbortController:function(){var a=[],l=this.signal={aborted:!1,addEventListener:function(h,p){a.push(p)}};this.abort=function(){l.aborted=!0,a.forEach(function(h){return h()})}},gr=s.unstable_scheduleCallback,Yo=s.unstable_NormalPriority,di={$$typeof:L,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Qr(){return{controller:new ks,data:new Map,refCount:0}}function Yn(a){a.refCount--,a.refCount===0&&gr(Yo,function(){a.controller.abort()})}var yr=null,Yt=0,wn=0,ns=null;function VL(a,l){if(yr===null){var h=yr=[];Yt=0,wn=p0(),ns={status:"pending",value:void 0,then:function(p){h.push(p)}}}return Yt++,l.then(xb,xb),l}function xb(){if(--Yt===0&&yr!==null){ns!==null&&(ns.status="fulfilled");var a=yr;yr=null,wn=0,ns=null;for(var l=0;l<a.length;l++)(0,a[l])()}}function qL(a,l){var h=[],p={status:"pending",value:null,reason:null,then:function(T){h.push(T)}};return a.then(function(){p.status="fulfilled",p.value=l;for(var T=0;T<h.length;T++)(0,h[T])(l)},function(T){for(p.status="rejected",p.reason=T,T=0;T<h.length;T++)(0,h[T])(void 0)}),p}var Sb=Y.S;Y.S=function(a,l){ax=Ye(),typeof l=="object"&&l!==null&&typeof l.then=="function"&&VL(a,l),Sb!==null&&Sb(a,l)};var Wo=U(null);function hg(){var a=Wo.current;return a!==null?a:ai.pooledCache}function Vh(a,l){l===null?fe(Wo,Wo.current):fe(Wo,l.pool)}function Eb(){var a=hg();return a===null?null:{parent:di._currentValue,pool:a}}var iu=Error(i(460)),fg=Error(i(474)),qh=Error(i(542)),zh={then:function(){}};function Ab(a){return a=a.status,a==="fulfilled"||a==="rejected"}function Cb(a,l,h){switch(h=a[h],h===void 0?a.push(l):h!==l&&(l.then(Vn,Vn),l=h),l.status){case"fulfilled":return l.value;case"rejected":throw a=l.reason,wb(a),a;default:if(typeof l.status=="string")l.then(Vn,Vn);else{if(a=ai,a!==null&&100<a.shellSuspendCounter)throw Error(i(482));a=l,a.status="pending",a.then(function(p){if(l.status==="pending"){var T=l;T.status="fulfilled",T.value=p}},function(p){if(l.status==="pending"){var T=l;T.status="rejected",T.reason=p}})}switch(l.status){case"fulfilled":return l.value;case"rejected":throw a=l.reason,wb(a),a}throw Qo=l,iu}}function Xo(a){try{var l=a._init;return l(a._payload)}catch(h){throw h!==null&&typeof h=="object"&&typeof h.then=="function"?(Qo=h,iu):h}}var Qo=null;function Db(){if(Qo===null)throw Error(i(459));var a=Qo;return Qo=null,a}function wb(a){if(a===iu||a===qh)throw Error(i(483))}var su=null,$c=0;function Kh(a){var l=$c;return $c+=1,su===null&&(su=[]),Cb(su,a,l)}function jc(a,l){l=l.props.ref,a.ref=l!==void 0?l:null}function Yh(a,l){throw l.$$typeof===g?Error(i(525)):(a=Object.prototype.toString.call(l),Error(i(31,a==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":a)))}function Lb(a){function l(me,he){if(a){var be=me.deletions;be===null?(me.deletions=[he],me.flags|=16):be.push(he)}}function h(me,he){if(!a)return null;for(;he!==null;)l(me,he),he=he.sibling;return null}function p(me){for(var he=new Map;me!==null;)me.key!==null?he.set(me.key,me):he.set(me.index,me),me=me.sibling;return he}function T(me,he){return me=Kn(me,he),me.index=0,me.sibling=null,me}function x(me,he,be){return me.index=be,a?(be=me.alternate,be!==null?(be=be.index,be<he?(me.flags|=67108866,he):be):(me.flags|=67108866,he)):(me.flags|=1048576,he)}function M(me){return a&&me.alternate===null&&(me.flags|=67108866),me}function q(me,he,be,Me){return he===null||he.tag!==6?(he=qo(be,me.mode,Me),he.return=me,he):(he=T(he,be),he.return=me,he)}function ce(me,he,be,Me){var ot=be.type;return ot===_?Oe(me,he,be.props.children,Me,be.key):he!==null&&(he.elementType===ot||typeof ot=="object"&&ot!==null&&ot.$$typeof===V&&Xo(ot)===he.type)?(he=T(he,be.props),jc(he,be),he.return=me,he):(he=Nc(be.type,be.key,be.props,null,me.mode,Me),jc(he,be),he.return=me,he)}function _e(me,he,be,Me){return he===null||he.tag!==4||he.stateNode.containerInfo!==be.containerInfo||he.stateNode.implementation!==be.implementation?(he=Fa(be,me.mode,Me),he.return=me,he):(he=T(he,be.children||[]),he.return=me,he)}function Oe(me,he,be,Me,ot){return he===null||he.tag!==7?(he=dr(be,me.mode,Me,ot),he.return=me,he):(he=T(he,be),he.return=me,he)}function Ne(me,he,be){if(typeof he=="string"&&he!==""||typeof he=="number"||typeof he=="bigint")return he=qo(""+he,me.mode,be),he.return=me,he;if(typeof he=="object"&&he!==null){switch(he.$$typeof){case v:return be=Nc(he.type,he.key,he.props,null,me.mode,be),jc(be,he),be.return=me,be;case b:return he=Fa(he,me.mode,be),he.return=me,he;case V:return he=Xo(he),Ne(me,he,be)}if(oe(he)||X(he))return he=dr(he,me.mode,be,null),he.return=me,he;if(typeof he.then=="function")return Ne(me,Kh(he),be);if(he.$$typeof===L)return Ne(me,mt(me,he),be);Yh(me,he)}return null}function De(me,he,be,Me){var ot=he!==null?he.key:null;if(typeof be=="string"&&be!==""||typeof be=="number"||typeof be=="bigint")return ot!==null?null:q(me,he,""+be,Me);if(typeof be=="object"&&be!==null){switch(be.$$typeof){case v:return be.key===ot?ce(me,he,be,Me):null;case b:return be.key===ot?_e(me,he,be,Me):null;case V:return be=Xo(be),De(me,he,be,Me)}if(oe(be)||X(be))return ot!==null?null:Oe(me,he,be,Me,null);if(typeof be.then=="function")return De(me,he,Kh(be),Me);if(be.$$typeof===L)return De(me,he,mt(me,be),Me);Yh(me,be)}return null}function Ie(me,he,be,Me,ot){if(typeof Me=="string"&&Me!==""||typeof Me=="number"||typeof Me=="bigint")return me=me.get(be)||null,q(he,me,""+Me,ot);if(typeof Me=="object"&&Me!==null){switch(Me.$$typeof){case v:return me=me.get(Me.key===null?be:Me.key)||null,ce(he,me,Me,ot);case b:return me=me.get(Me.key===null?be:Me.key)||null,_e(he,me,Me,ot);case V:return Me=Xo(Me),Ie(me,he,be,Me,ot)}if(oe(Me)||X(Me))return me=me.get(be)||null,Oe(he,me,Me,ot,null);if(typeof Me.then=="function")return Ie(me,he,be,Kh(Me),ot);if(Me.$$typeof===L)return Ie(me,he,be,mt(he,Me),ot);Yh(he,Me)}return null}function tt(me,he,be,Me){for(var ot=null,Gt=null,st=he,St=he=0,Ft=null;st!==null&&St<be.length;St++){st.index>St?(Ft=st,st=null):Ft=st.sibling;var Vt=De(me,st,be[St],Me);if(Vt===null){st===null&&(st=Ft);break}a&&st&&Vt.alternate===null&&l(me,st),he=x(Vt,he,St),Gt===null?ot=Vt:Gt.sibling=Vt,Gt=Vt,st=Ft}if(St===be.length)return h(me,st),Rt&&Ct(me,St),ot;if(st===null){for(;St<be.length;St++)st=Ne(me,be[St],Me),st!==null&&(he=x(st,he,St),Gt===null?ot=st:Gt.sibling=st,Gt=st);return Rt&&Ct(me,St),ot}for(st=p(st);St<be.length;St++)Ft=Ie(st,me,St,be[St],Me),Ft!==null&&(a&&Ft.alternate!==null&&st.delete(Ft.key===null?St:Ft.key),he=x(Ft,he,St),Gt===null?ot=Ft:Gt.sibling=Ft,Gt=Ft);return a&&st.forEach(function(no){return l(me,no)}),Rt&&Ct(me,St),ot}function ct(me,he,be,Me){if(be==null)throw Error(i(151));for(var ot=null,Gt=null,st=he,St=he=0,Ft=null,Vt=be.next();st!==null&&!Vt.done;St++,Vt=be.next()){st.index>St?(Ft=st,st=null):Ft=st.sibling;var no=De(me,st,Vt.value,Me);if(no===null){st===null&&(st=Ft);break}a&&st&&no.alternate===null&&l(me,st),he=x(no,he,St),Gt===null?ot=no:Gt.sibling=no,Gt=no,st=Ft}if(Vt.done)return h(me,st),Rt&&Ct(me,St),ot;if(st===null){for(;!Vt.done;St++,Vt=be.next())Vt=Ne(me,Vt.value,Me),Vt!==null&&(he=x(Vt,he,St),Gt===null?ot=Vt:Gt.sibling=Vt,Gt=Vt);return Rt&&Ct(me,St),ot}for(st=p(st);!Vt.done;St++,Vt=be.next())Vt=Ie(st,me,St,Vt.value,Me),Vt!==null&&(a&&Vt.alternate!==null&&st.delete(Vt.key===null?St:Vt.key),he=x(Vt,he,St),Gt===null?ot=Vt:Gt.sibling=Vt,Gt=Vt);return a&&st.forEach(function(ik){return l(me,ik)}),Rt&&Ct(me,St),ot}function ii(me,he,be,Me){if(typeof be=="object"&&be!==null&&be.type===_&&be.key===null&&(be=be.props.children),typeof be=="object"&&be!==null){switch(be.$$typeof){case v:e:{for(var ot=be.key;he!==null;){if(he.key===ot){if(ot=be.type,ot===_){if(he.tag===7){h(me,he.sibling),Me=T(he,be.props.children),Me.return=me,me=Me;break e}}else if(he.elementType===ot||typeof ot=="object"&&ot!==null&&ot.$$typeof===V&&Xo(ot)===he.type){h(me,he.sibling),Me=T(he,be.props),jc(Me,be),Me.return=me,me=Me;break e}h(me,he);break}else l(me,he);he=he.sibling}be.type===_?(Me=dr(be.props.children,me.mode,Me,be.key),Me.return=me,me=Me):(Me=Nc(be.type,be.key,be.props,null,me.mode,Me),jc(Me,be),Me.return=me,me=Me)}return M(me);case b:e:{for(ot=be.key;he!==null;){if(he.key===ot)if(he.tag===4&&he.stateNode.containerInfo===be.containerInfo&&he.stateNode.implementation===be.implementation){h(me,he.sibling),Me=T(he,be.children||[]),Me.return=me,me=Me;break e}else{h(me,he);break}else l(me,he);he=he.sibling}Me=Fa(be,me.mode,Me),Me.return=me,me=Me}return M(me);case V:return be=Xo(be),ii(me,he,be,Me)}if(oe(be))return tt(me,he,be,Me);if(X(be)){if(ot=X(be),typeof ot!="function")throw Error(i(150));return be=ot.call(be),ct(me,he,be,Me)}if(typeof be.then=="function")return ii(me,he,Kh(be),Me);if(be.$$typeof===L)return ii(me,he,mt(me,be),Me);Yh(me,be)}return typeof be=="string"&&be!==""||typeof be=="number"||typeof be=="bigint"?(be=""+be,he!==null&&he.tag===6?(h(me,he.sibling),Me=T(he,be),Me.return=me,me=Me):(h(me,he),Me=qo(be,me.mode,Me),Me.return=me,me=Me),M(me)):h(me,he)}return function(me,he,be,Me){try{$c=0;var ot=ii(me,he,be,Me);return su=null,ot}catch(st){if(st===iu||st===qh)throw st;var Gt=Di(29,st,null,me.mode);return Gt.lanes=Me,Gt.return=me,Gt}}}var Zo=Lb(!0),Ib=Lb(!1),ja=!1;function pg(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function mg(a,l){a=a.updateQueue,l.updateQueue===a&&(l.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,callbacks:null})}function Ha(a){return{lane:a,tag:0,payload:null,callback:null,next:null}}function Ga(a,l,h){var p=a.updateQueue;if(p===null)return null;if(p=p.shared,(zt&2)!==0){var T=p.pending;return T===null?l.next=l:(l.next=T.next,T.next=l),p.pending=l,l=eu(a),$h(a,null,h),l}return Jl(a,p,l,h),eu(a)}function Hc(a,l,h){if(l=l.updateQueue,l!==null&&(l=l.shared,(h&4194048)!==0)){var p=l.lanes;p&=a.pendingLanes,h|=p,l.lanes=h,ut(a,h)}}function gg(a,l){var h=a.updateQueue,p=a.alternate;if(p!==null&&(p=p.updateQueue,h===p)){var T=null,x=null;if(h=h.firstBaseUpdate,h!==null){do{var M={lane:h.lane,tag:h.tag,payload:h.payload,callback:null,next:null};x===null?T=x=M:x=x.next=M,h=h.next}while(h!==null);x===null?T=x=l:x=x.next=l}else T=x=l;h={baseState:p.baseState,firstBaseUpdate:T,lastBaseUpdate:x,shared:p.shared,callbacks:p.callbacks},a.updateQueue=h;return}a=h.lastBaseUpdate,a===null?h.firstBaseUpdate=l:a.next=l,h.lastBaseUpdate=l}var yg=!1;function Gc(){if(yg){var a=ns;if(a!==null)throw a}}function Vc(a,l,h,p){yg=!1;var T=a.updateQueue;ja=!1;var x=T.firstBaseUpdate,M=T.lastBaseUpdate,q=T.shared.pending;if(q!==null){T.shared.pending=null;var ce=q,_e=ce.next;ce.next=null,M===null?x=_e:M.next=_e,M=ce;var Oe=a.alternate;Oe!==null&&(Oe=Oe.updateQueue,q=Oe.lastBaseUpdate,q!==M&&(q===null?Oe.firstBaseUpdate=_e:q.next=_e,Oe.lastBaseUpdate=ce))}if(x!==null){var Ne=T.baseState;M=0,Oe=_e=ce=null,q=x;do{var De=q.lane&-536870913,Ie=De!==q.lane;if(Ie?(Bt&De)===De:(p&De)===De){De!==0&&De===wn&&(yg=!0),Oe!==null&&(Oe=Oe.next={lane:0,tag:q.tag,payload:q.payload,callback:null,next:null});e:{var tt=a,ct=q;De=l;var ii=h;switch(ct.tag){case 1:if(tt=ct.payload,typeof tt=="function"){Ne=tt.call(ii,Ne,De);break e}Ne=tt;break e;case 3:tt.flags=tt.flags&-65537|128;case 0:if(tt=ct.payload,De=typeof tt=="function"?tt.call(ii,Ne,De):tt,De==null)break e;Ne=m({},Ne,De);break e;case 2:ja=!0}}De=q.callback,De!==null&&(a.flags|=64,Ie&&(a.flags|=8192),Ie=T.callbacks,Ie===null?T.callbacks=[De]:Ie.push(De))}else Ie={lane:De,tag:q.tag,payload:q.payload,callback:q.callback,next:null},Oe===null?(_e=Oe=Ie,ce=Ne):Oe=Oe.next=Ie,M|=De;if(q=q.next,q===null){if(q=T.shared.pending,q===null)break;Ie=q,q=Ie.next,Ie.next=null,T.lastBaseUpdate=Ie,T.shared.pending=null}}while(!0);Oe===null&&(ce=Ne),T.baseState=ce,T.firstBaseUpdate=_e,T.lastBaseUpdate=Oe,x===null&&(T.shared.lanes=0),Ya|=M,a.lanes=M,a.memoizedState=Ne}}function kb(a,l){if(typeof a!="function")throw Error(i(191,a));a.call(l)}function Rb(a,l){var h=a.callbacks;if(h!==null)for(a.callbacks=null,a=0;a<h.length;a++)kb(h[a],l)}var nu=U(null),Wh=U(0);function Ob(a,l){a=aa,fe(Wh,a),fe(nu,l),aa=a|l.baseLanes}function vg(){fe(Wh,aa),fe(nu,nu.current)}function Tg(){aa=Wh.current,ie(nu),ie(Wh)}var cn=U(null),Ln=null;function Va(a){var l=a.alternate;fe(Fi,Fi.current&1),fe(cn,a),Ln===null&&(l===null||nu.current!==null||l.memoizedState!==null)&&(Ln=a)}function bg(a){fe(Fi,Fi.current),fe(cn,a),Ln===null&&(Ln=a)}function Pb(a){a.tag===22?(fe(Fi,Fi.current),fe(cn,a),Ln===null&&(Ln=a)):qa()}function qa(){fe(Fi,Fi.current),fe(cn,cn.current)}function dn(a){ie(cn),Ln===a&&(Ln=null),ie(Fi)}var Fi=U(0);function Xh(a){for(var l=a;l!==null;){if(l.tag===13){var h=l.memoizedState;if(h!==null&&(h=h.dehydrated,h===null||C0(h)||D0(h)))return l}else if(l.tag===19&&(l.memoizedProps.revealOrder==="forwards"||l.memoizedProps.revealOrder==="backwards"||l.memoizedProps.revealOrder==="unstable_legacy-backwards"||l.memoizedProps.revealOrder==="together")){if((l.flags&128)!==0)return l}else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===a)break;for(;l.sibling===null;){if(l.return===null||l.return===a)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var Zr=0,_t=null,ei=null,qi=null,Qh=!1,ru=!1,Jo=!1,Zh=0,qc=0,au=null,zL=0;function wi(){throw Error(i(321))}function _g(a,l){if(l===null)return!1;for(var h=0;h<l.length&&h<a.length;h++)if(!_s(a[h],l[h]))return!1;return!0}function xg(a,l,h,p,T,x){return Zr=x,_t=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,Y.H=a===null||a.memoizedState===null?y_:Bg,Jo=!1,x=h(p,T),Jo=!1,ru&&(x=Nb(l,h,p,T)),Mb(a),x}function Mb(a){Y.H=Yc;var l=ei!==null&&ei.next!==null;if(Zr=0,qi=ei=_t=null,Qh=!1,qc=0,au=null,l)throw Error(i(300));a===null||zi||(a=a.dependencies,a!==null&&ze(a)&&(zi=!0))}function Nb(a,l,h,p){_t=a;var T=0;do{if(ru&&(au=null),qc=0,ru=!1,25<=T)throw Error(i(301));if(T+=1,qi=ei=null,a.updateQueue!=null){var x=a.updateQueue;x.lastEffect=null,x.events=null,x.stores=null,x.memoCache!=null&&(x.memoCache.index=0)}Y.H=v_,x=l(h,p)}while(ru);return x}function KL(){var a=Y.H,l=a.useState()[0];return l=typeof l.then=="function"?zc(l):l,a=a.useState()[0],(ei!==null?ei.memoizedState:null)!==a&&(_t.flags|=1024),l}function Sg(){var a=Zh!==0;return Zh=0,a}function Eg(a,l,h){l.updateQueue=a.updateQueue,l.flags&=-2053,a.lanes&=~h}function Ag(a){if(Qh){for(a=a.memoizedState;a!==null;){var l=a.queue;l!==null&&(l.pending=null),a=a.next}Qh=!1}Zr=0,qi=ei=_t=null,ru=!1,qc=Zh=0,au=null}function Rs(){var a={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return qi===null?_t.memoizedState=qi=a:qi=qi.next=a,qi}function Ui(){if(ei===null){var a=_t.alternate;a=a!==null?a.memoizedState:null}else a=ei.next;var l=qi===null?_t.memoizedState:qi.next;if(l!==null)qi=l,ei=a;else{if(a===null)throw _t.alternate===null?Error(i(467)):Error(i(310));ei=a,a={memoizedState:ei.memoizedState,baseState:ei.baseState,baseQueue:ei.baseQueue,queue:ei.queue,next:null},qi===null?_t.memoizedState=qi=a:qi=qi.next=a}return qi}function Jh(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function zc(a){var l=qc;return qc+=1,au===null&&(au=[]),a=Cb(au,a,l),l=_t,(qi===null?l.memoizedState:qi.next)===null&&(l=l.alternate,Y.H=l===null||l.memoizedState===null?y_:Bg),a}function ef(a){if(a!==null&&typeof a=="object"){if(typeof a.then=="function")return zc(a);if(a.$$typeof===L)return Qe(a)}throw Error(i(438,String(a)))}function Cg(a){var l=null,h=_t.updateQueue;if(h!==null&&(l=h.memoCache),l==null){var p=_t.alternate;p!==null&&(p=p.updateQueue,p!==null&&(p=p.memoCache,p!=null&&(l={data:p.data.map(function(T){return T.slice()}),index:0})))}if(l==null&&(l={data:[],index:0}),h===null&&(h=Jh(),_t.updateQueue=h),h.memoCache=l,h=l.data[l.index],h===void 0)for(h=l.data[l.index]=Array(a),p=0;p<a;p++)h[p]=R;return l.index++,h}function Jr(a,l){return typeof l=="function"?l(a):l}function tf(a){var l=Ui();return Dg(l,ei,a)}function Dg(a,l,h){var p=a.queue;if(p===null)throw Error(i(311));p.lastRenderedReducer=h;var T=a.baseQueue,x=p.pending;if(x!==null){if(T!==null){var M=T.next;T.next=x.next,x.next=M}l.baseQueue=T=x,p.pending=null}if(x=a.baseState,T===null)a.memoizedState=x;else{l=T.next;var q=M=null,ce=null,_e=l,Oe=!1;do{var Ne=_e.lane&-536870913;if(Ne!==_e.lane?(Bt&Ne)===Ne:(Zr&Ne)===Ne){var De=_e.revertLane;if(De===0)ce!==null&&(ce=ce.next={lane:0,revertLane:0,gesture:null,action:_e.action,hasEagerState:_e.hasEagerState,eagerState:_e.eagerState,next:null}),Ne===wn&&(Oe=!0);else if((Zr&De)===De){_e=_e.next,De===wn&&(Oe=!0);continue}else Ne={lane:0,revertLane:_e.revertLane,gesture:null,action:_e.action,hasEagerState:_e.hasEagerState,eagerState:_e.eagerState,next:null},ce===null?(q=ce=Ne,M=x):ce=ce.next=Ne,_t.lanes|=De,Ya|=De;Ne=_e.action,Jo&&h(x,Ne),x=_e.hasEagerState?_e.eagerState:h(x,Ne)}else De={lane:Ne,revertLane:_e.revertLane,gesture:_e.gesture,action:_e.action,hasEagerState:_e.hasEagerState,eagerState:_e.eagerState,next:null},ce===null?(q=ce=De,M=x):ce=ce.next=De,_t.lanes|=Ne,Ya|=Ne;_e=_e.next}while(_e!==null&&_e!==l);if(ce===null?M=x:ce.next=q,!_s(x,a.memoizedState)&&(zi=!0,Oe&&(h=ns,h!==null)))throw h;a.memoizedState=x,a.baseState=M,a.baseQueue=ce,p.lastRenderedState=x}return T===null&&(p.lanes=0),[a.memoizedState,p.dispatch]}function wg(a){var l=Ui(),h=l.queue;if(h===null)throw Error(i(311));h.lastRenderedReducer=a;var p=h.dispatch,T=h.pending,x=l.memoizedState;if(T!==null){h.pending=null;var M=T=T.next;do x=a(x,M.action),M=M.next;while(M!==T);_s(x,l.memoizedState)||(zi=!0),l.memoizedState=x,l.baseQueue===null&&(l.baseState=x),h.lastRenderedState=x}return[x,p]}function Bb(a,l,h){var p=_t,T=Ui(),x=Rt;if(x){if(h===void 0)throw Error(i(407));h=h()}else h=l();var M=!_s((ei||T).memoizedState,h);if(M&&(T.memoizedState=h,zi=!0),T=T.queue,kg($b.bind(null,p,T,a),[a]),T.getSnapshot!==l||M||qi!==null&&qi.memoizedState.tag&1){if(p.flags|=2048,ou(9,{destroy:void 0},Ub.bind(null,p,T,h,l),null),ai===null)throw Error(i(349));x||(Zr&127)!==0||Fb(p,l,h)}return h}function Fb(a,l,h){a.flags|=16384,a={getSnapshot:l,value:h},l=_t.updateQueue,l===null?(l=Jh(),_t.updateQueue=l,l.stores=[a]):(h=l.stores,h===null?l.stores=[a]:h.push(a))}function Ub(a,l,h,p){l.value=h,l.getSnapshot=p,jb(l)&&Hb(a)}function $b(a,l,h){return h(function(){jb(l)&&Hb(a)})}function jb(a){var l=a.getSnapshot;a=a.value;try{var h=l();return!_s(a,h)}catch{return!0}}function Hb(a){var l=Xr(a,2);l!==null&&Ws(l,a,2)}function Lg(a){var l=Rs();if(typeof a=="function"){var h=a;if(a=h(),Jo){Se(!0);try{h()}finally{Se(!1)}}}return l.memoizedState=l.baseState=a,l.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Jr,lastRenderedState:a},l}function Gb(a,l,h,p){return a.baseState=h,Dg(a,ei,typeof p=="function"?p:Jr)}function YL(a,l,h,p,T){if(rf(a))throw Error(i(485));if(a=l.action,a!==null){var x={payload:T,action:a,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(M){x.listeners.push(M)}};Y.T!==null?h(!0):x.isTransition=!1,p(x),h=l.pending,h===null?(x.next=l.pending=x,Vb(l,x)):(x.next=h.next,l.pending=h.next=x)}}function Vb(a,l){var h=l.action,p=l.payload,T=a.state;if(l.isTransition){var x=Y.T,M={};Y.T=M;try{var q=h(T,p),ce=Y.S;ce!==null&&ce(M,q),qb(a,l,q)}catch(_e){Ig(a,l,_e)}finally{x!==null&&M.types!==null&&(x.types=M.types),Y.T=x}}else try{x=h(T,p),qb(a,l,x)}catch(_e){Ig(a,l,_e)}}function qb(a,l,h){h!==null&&typeof h=="object"&&typeof h.then=="function"?h.then(function(p){zb(a,l,p)},function(p){return Ig(a,l,p)}):zb(a,l,h)}function zb(a,l,h){l.status="fulfilled",l.value=h,Kb(l),a.state=h,l=a.pending,l!==null&&(h=l.next,h===l?a.pending=null:(h=h.next,l.next=h,Vb(a,h)))}function Ig(a,l,h){var p=a.pending;if(a.pending=null,p!==null){p=p.next;do l.status="rejected",l.reason=h,Kb(l),l=l.next;while(l!==p)}a.action=null}function Kb(a){a=a.listeners;for(var l=0;l<a.length;l++)(0,a[l])()}function Yb(a,l){return l}function Wb(a,l){if(Rt){var h=ai.formState;if(h!==null){e:{var p=_t;if(Rt){if(ri){t:{for(var T=ri,x=Vs;T.nodeType!==8;){if(!x){T=null;break t}if(T=In(T.nextSibling),T===null){T=null;break t}}x=T.data,T=x==="F!"||x==="F"?T:null}if(T){ri=In(T.nextSibling),p=T.data==="F!";break e}}mr(p)}p=!1}p&&(l=h[0])}}return h=Rs(),h.memoizedState=h.baseState=l,p={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Yb,lastRenderedState:l},h.queue=p,h=p_.bind(null,_t,p),p.dispatch=h,p=Lg(!1),x=Ng.bind(null,_t,!1,p.queue),p=Rs(),T={state:l,dispatch:null,action:a,pending:null},p.queue=T,h=YL.bind(null,_t,T,x,h),T.dispatch=h,p.memoizedState=a,[l,h,!1]}function Xb(a){var l=Ui();return Qb(l,ei,a)}function Qb(a,l,h){if(l=Dg(a,l,Yb)[0],a=tf(Jr)[0],typeof l=="object"&&l!==null&&typeof l.then=="function")try{var p=zc(l)}catch(M){throw M===iu?qh:M}else p=l;l=Ui();var T=l.queue,x=T.dispatch;return h!==l.memoizedState&&(_t.flags|=2048,ou(9,{destroy:void 0},WL.bind(null,T,h),null)),[p,x,a]}function WL(a,l){a.action=l}function Zb(a){var l=Ui(),h=ei;if(h!==null)return Qb(l,h,a);Ui(),l=l.memoizedState,h=Ui();var p=h.queue.dispatch;return h.memoizedState=a,[l,p,!1]}function ou(a,l,h,p){return a={tag:a,create:h,deps:p,inst:l,next:null},l=_t.updateQueue,l===null&&(l=Jh(),_t.updateQueue=l),h=l.lastEffect,h===null?l.lastEffect=a.next=a:(p=h.next,h.next=a,a.next=p,l.lastEffect=a),a}function Jb(){return Ui().memoizedState}function sf(a,l,h,p){var T=Rs();_t.flags|=a,T.memoizedState=ou(1|l,{destroy:void 0},h,p===void 0?null:p)}function nf(a,l,h,p){var T=Ui();p=p===void 0?null:p;var x=T.memoizedState.inst;ei!==null&&p!==null&&_g(p,ei.memoizedState.deps)?T.memoizedState=ou(l,x,h,p):(_t.flags|=a,T.memoizedState=ou(1|l,x,h,p))}function e_(a,l){sf(8390656,8,a,l)}function kg(a,l){nf(2048,8,a,l)}function XL(a){_t.flags|=4;var l=_t.updateQueue;if(l===null)l=Jh(),_t.updateQueue=l,l.events=[a];else{var h=l.events;h===null?l.events=[a]:h.push(a)}}function t_(a){var l=Ui().memoizedState;return XL({ref:l,nextImpl:a}),function(){if((zt&2)!==0)throw Error(i(440));return l.impl.apply(void 0,arguments)}}function i_(a,l){return nf(4,2,a,l)}function s_(a,l){return nf(4,4,a,l)}function n_(a,l){if(typeof l=="function"){a=a();var h=l(a);return function(){typeof h=="function"?h():l(null)}}if(l!=null)return a=a(),l.current=a,function(){l.current=null}}function r_(a,l,h){h=h!=null?h.concat([a]):null,nf(4,4,n_.bind(null,l,a),h)}function Rg(){}function a_(a,l){var h=Ui();l=l===void 0?null:l;var p=h.memoizedState;return l!==null&&_g(l,p[1])?p[0]:(h.memoizedState=[a,l],a)}function o_(a,l){var h=Ui();l=l===void 0?null:l;var p=h.memoizedState;if(l!==null&&_g(l,p[1]))return p[0];if(p=a(),Jo){Se(!0);try{a()}finally{Se(!1)}}return h.memoizedState=[p,l],p}function Og(a,l,h){return h===void 0||(Zr&1073741824)!==0&&(Bt&261930)===0?a.memoizedState=l:(a.memoizedState=h,a=lx(),_t.lanes|=a,Ya|=a,h)}function l_(a,l,h,p){return _s(h,l)?h:nu.current!==null?(a=Og(a,h,p),_s(a,l)||(zi=!0),a):(Zr&42)===0||(Zr&1073741824)!==0&&(Bt&261930)===0?(zi=!0,a.memoizedState=h):(a=lx(),_t.lanes|=a,Ya|=a,l)}function u_(a,l,h,p,T){var x=Z.p;Z.p=x!==0&&8>x?x:8;var M=Y.T,q={};Y.T=q,Ng(a,!1,l,h);try{var ce=T(),_e=Y.S;if(_e!==null&&_e(q,ce),ce!==null&&typeof ce=="object"&&typeof ce.then=="function"){var Oe=qL(ce,p);Kc(a,l,Oe,pn(a))}else Kc(a,l,p,pn(a))}catch(Ne){Kc(a,l,{then:function(){},status:"rejected",reason:Ne},pn())}finally{Z.p=x,M!==null&&q.types!==null&&(M.types=q.types),Y.T=M}}function QL(){}function Pg(a,l,h,p){if(a.tag!==5)throw Error(i(476));var T=c_(a).queue;u_(a,T,l,Q,h===null?QL:function(){return d_(a),h(p)})}function c_(a){var l=a.memoizedState;if(l!==null)return l;l={memoizedState:Q,baseState:Q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Jr,lastRenderedState:Q},next:null};var h={};return l.next={memoizedState:h,baseState:h,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Jr,lastRenderedState:h},next:null},a.memoizedState=l,a=a.alternate,a!==null&&(a.memoizedState=l),l}function d_(a){var l=c_(a);l.next===null&&(l=a.alternate.memoizedState),Kc(a,l.next.queue,{},pn())}function Mg(){return Qe(cd)}function h_(){return Ui().memoizedState}function f_(){return Ui().memoizedState}function ZL(a){for(var l=a.return;l!==null;){switch(l.tag){case 24:case 3:var h=pn();a=Ha(h);var p=Ga(l,a,h);p!==null&&(Ws(p,l,h),Hc(p,l,h)),l={cache:Qr()},a.payload=l;return}l=l.return}}function JL(a,l,h){var p=pn();h={lane:p,revertLane:0,gesture:null,action:h,hasEagerState:!1,eagerState:null,next:null},rf(a)?m_(l,h):(h=Pc(a,l,h,p),h!==null&&(Ws(h,a,p),g_(h,l,p)))}function p_(a,l,h){var p=pn();Kc(a,l,h,p)}function Kc(a,l,h,p){var T={lane:p,revertLane:0,gesture:null,action:h,hasEagerState:!1,eagerState:null,next:null};if(rf(a))m_(l,T);else{var x=a.alternate;if(a.lanes===0&&(x===null||x.lanes===0)&&(x=l.lastRenderedReducer,x!==null))try{var M=l.lastRenderedState,q=x(M,h);if(T.hasEagerState=!0,T.eagerState=q,_s(q,M))return Jl(a,l,T,0),ai===null&&Zl(),!1}catch{}if(h=Pc(a,l,T,p),h!==null)return Ws(h,a,p),g_(h,l,p),!0}return!1}function Ng(a,l,h,p){if(p={lane:2,revertLane:p0(),gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null},rf(a)){if(l)throw Error(i(479))}else l=Pc(a,h,p,2),l!==null&&Ws(l,a,2)}function rf(a){var l=a.alternate;return a===_t||l!==null&&l===_t}function m_(a,l){ru=Qh=!0;var h=a.pending;h===null?l.next=l:(l.next=h.next,h.next=l),a.pending=l}function g_(a,l,h){if((h&4194048)!==0){var p=l.lanes;p&=a.pendingLanes,h|=p,l.lanes=h,ut(a,h)}}var Yc={readContext:Qe,use:ef,useCallback:wi,useContext:wi,useEffect:wi,useImperativeHandle:wi,useLayoutEffect:wi,useInsertionEffect:wi,useMemo:wi,useReducer:wi,useRef:wi,useState:wi,useDebugValue:wi,useDeferredValue:wi,useTransition:wi,useSyncExternalStore:wi,useId:wi,useHostTransitionStatus:wi,useFormState:wi,useActionState:wi,useOptimistic:wi,useMemoCache:wi,useCacheRefresh:wi};Yc.useEffectEvent=wi;var y_={readContext:Qe,use:ef,useCallback:function(a,l){return Rs().memoizedState=[a,l===void 0?null:l],a},useContext:Qe,useEffect:e_,useImperativeHandle:function(a,l,h){h=h!=null?h.concat([a]):null,sf(4194308,4,n_.bind(null,l,a),h)},useLayoutEffect:function(a,l){return sf(4194308,4,a,l)},useInsertionEffect:function(a,l){sf(4,2,a,l)},useMemo:function(a,l){var h=Rs();l=l===void 0?null:l;var p=a();if(Jo){Se(!0);try{a()}finally{Se(!1)}}return h.memoizedState=[p,l],p},useReducer:function(a,l,h){var p=Rs();if(h!==void 0){var T=h(l);if(Jo){Se(!0);try{h(l)}finally{Se(!1)}}}else T=l;return p.memoizedState=p.baseState=T,a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:T},p.queue=a,a=a.dispatch=JL.bind(null,_t,a),[p.memoizedState,a]},useRef:function(a){var l=Rs();return a={current:a},l.memoizedState=a},useState:function(a){a=Lg(a);var l=a.queue,h=p_.bind(null,_t,l);return l.dispatch=h,[a.memoizedState,h]},useDebugValue:Rg,useDeferredValue:function(a,l){var h=Rs();return Og(h,a,l)},useTransition:function(){var a=Lg(!1);return a=u_.bind(null,_t,a.queue,!0,!1),Rs().memoizedState=a,[!1,a]},useSyncExternalStore:function(a,l,h){var p=_t,T=Rs();if(Rt){if(h===void 0)throw Error(i(407));h=h()}else{if(h=l(),ai===null)throw Error(i(349));(Bt&127)!==0||Fb(p,l,h)}T.memoizedState=h;var x={value:h,getSnapshot:l};return T.queue=x,e_($b.bind(null,p,x,a),[a]),p.flags|=2048,ou(9,{destroy:void 0},Ub.bind(null,p,x,h,l),null),h},useId:function(){var a=Rs(),l=ai.identifierPrefix;if(Rt){var h=ds,p=un;h=(p&~(1<<32-He(p)-1)).toString(32)+h,l="_"+l+"R_"+h,h=Zh++,0<h&&(l+="H"+h.toString(32)),l+="_"}else h=zL++,l="_"+l+"r_"+h.toString(32)+"_";return a.memoizedState=l},useHostTransitionStatus:Mg,useFormState:Wb,useActionState:Wb,useOptimistic:function(a){var l=Rs();l.memoizedState=l.baseState=a;var h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return l.queue=h,l=Ng.bind(null,_t,!0,h),h.dispatch=l,[a,l]},useMemoCache:Cg,useCacheRefresh:function(){return Rs().memoizedState=ZL.bind(null,_t)},useEffectEvent:function(a){var l=Rs(),h={impl:a};return l.memoizedState=h,function(){if((zt&2)!==0)throw Error(i(440));return h.impl.apply(void 0,arguments)}}},Bg={readContext:Qe,use:ef,useCallback:a_,useContext:Qe,useEffect:kg,useImperativeHandle:r_,useInsertionEffect:i_,useLayoutEffect:s_,useMemo:o_,useReducer:tf,useRef:Jb,useState:function(){return tf(Jr)},useDebugValue:Rg,useDeferredValue:function(a,l){var h=Ui();return l_(h,ei.memoizedState,a,l)},useTransition:function(){var a=tf(Jr)[0],l=Ui().memoizedState;return[typeof a=="boolean"?a:zc(a),l]},useSyncExternalStore:Bb,useId:h_,useHostTransitionStatus:Mg,useFormState:Xb,useActionState:Xb,useOptimistic:function(a,l){var h=Ui();return Gb(h,ei,a,l)},useMemoCache:Cg,useCacheRefresh:f_};Bg.useEffectEvent=t_;var v_={readContext:Qe,use:ef,useCallback:a_,useContext:Qe,useEffect:kg,useImperativeHandle:r_,useInsertionEffect:i_,useLayoutEffect:s_,useMemo:o_,useReducer:wg,useRef:Jb,useState:function(){return wg(Jr)},useDebugValue:Rg,useDeferredValue:function(a,l){var h=Ui();return ei===null?Og(h,a,l):l_(h,ei.memoizedState,a,l)},useTransition:function(){var a=wg(Jr)[0],l=Ui().memoizedState;return[typeof a=="boolean"?a:zc(a),l]},useSyncExternalStore:Bb,useId:h_,useHostTransitionStatus:Mg,useFormState:Zb,useActionState:Zb,useOptimistic:function(a,l){var h=Ui();return ei!==null?Gb(h,ei,a,l):(h.baseState=a,[a,h.queue.dispatch])},useMemoCache:Cg,useCacheRefresh:f_};v_.useEffectEvent=t_;function Fg(a,l,h,p){l=a.memoizedState,h=h(p,l),h=h==null?l:m({},l,h),a.memoizedState=h,a.lanes===0&&(a.updateQueue.baseState=h)}var Ug={enqueueSetState:function(a,l,h){a=a._reactInternals;var p=pn(),T=Ha(p);T.payload=l,h!=null&&(T.callback=h),l=Ga(a,T,p),l!==null&&(Ws(l,a,p),Hc(l,a,p))},enqueueReplaceState:function(a,l,h){a=a._reactInternals;var p=pn(),T=Ha(p);T.tag=1,T.payload=l,h!=null&&(T.callback=h),l=Ga(a,T,p),l!==null&&(Ws(l,a,p),Hc(l,a,p))},enqueueForceUpdate:function(a,l){a=a._reactInternals;var h=pn(),p=Ha(h);p.tag=2,l!=null&&(p.callback=l),l=Ga(a,p,h),l!==null&&(Ws(l,a,h),Hc(l,a,h))}};function T_(a,l,h,p,T,x,M){return a=a.stateNode,typeof a.shouldComponentUpdate=="function"?a.shouldComponentUpdate(p,x,M):l.prototype&&l.prototype.isPureReactComponent?!ur(h,p)||!ur(T,x):!0}function b_(a,l,h,p){a=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(h,p),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(h,p),l.state!==a&&Ug.enqueueReplaceState(l,l.state,null)}function el(a,l){var h=l;if("ref"in l){h={};for(var p in l)p!=="ref"&&(h[p]=l[p])}if(a=a.defaultProps){h===l&&(h=m({},h));for(var T in a)h[T]===void 0&&(h[T]=a[T])}return h}function __(a){Ma(a)}function x_(a){console.error(a)}function S_(a){Ma(a)}function af(a,l){try{var h=a.onUncaughtError;h(l.value,{componentStack:l.stack})}catch(p){setTimeout(function(){throw p})}}function E_(a,l,h){try{var p=a.onCaughtError;p(h.value,{componentStack:h.stack,errorBoundary:l.tag===1?l.stateNode:null})}catch(T){setTimeout(function(){throw T})}}function $g(a,l,h){return h=Ha(h),h.tag=3,h.payload={element:null},h.callback=function(){af(a,l)},h}function A_(a){return a=Ha(a),a.tag=3,a}function C_(a,l,h,p){var T=h.type.getDerivedStateFromError;if(typeof T=="function"){var x=p.value;a.payload=function(){return T(x)},a.callback=function(){E_(l,h,p)}}var M=h.stateNode;M!==null&&typeof M.componentDidCatch=="function"&&(a.callback=function(){E_(l,h,p),typeof T!="function"&&(Wa===null?Wa=new Set([this]):Wa.add(this));var q=p.stack;this.componentDidCatch(p.value,{componentStack:q!==null?q:""})})}function eI(a,l,h,p,T){if(h.flags|=32768,p!==null&&typeof p=="object"&&typeof p.then=="function"){if(l=h.alternate,l!==null&&Le(l,h,T,!0),h=cn.current,h!==null){switch(h.tag){case 31:case 13:return Ln===null?vf():h.alternate===null&&Li===0&&(Li=3),h.flags&=-257,h.flags|=65536,h.lanes=T,p===zh?h.flags|=16384:(l=h.updateQueue,l===null?h.updateQueue=new Set([p]):l.add(p),d0(a,p,T)),!1;case 22:return h.flags|=65536,p===zh?h.flags|=16384:(l=h.updateQueue,l===null?(l={transitions:null,markerInstances:null,retryQueue:new Set([p])},h.updateQueue=l):(h=l.retryQueue,h===null?l.retryQueue=new Set([p]):h.add(p)),d0(a,p,T)),!1}throw Error(i(435,h.tag))}return d0(a,p,T),vf(),!1}if(Rt)return l=cn.current,l!==null?((l.flags&65536)===0&&(l.flags|=256),l.flags|=65536,l.lanes=T,p!==Fc&&(a=Error(i(422),{cause:p}),A(js(a,h)))):(p!==Fc&&(l=Error(i(423),{cause:p}),A(js(l,h))),a=a.current.alternate,a.flags|=65536,T&=-T,a.lanes|=T,p=js(p,h),T=$g(a.stateNode,p,T),gg(a,T),Li!==4&&(Li=2)),!1;var x=Error(i(520),{cause:p});if(x=js(x,h),id===null?id=[x]:id.push(x),Li!==4&&(Li=2),l===null)return!0;p=js(p,h),h=l;do{switch(h.tag){case 3:return h.flags|=65536,a=T&-T,h.lanes|=a,a=$g(h.stateNode,p,a),gg(h,a),!1;case 1:if(l=h.type,x=h.stateNode,(h.flags&128)===0&&(typeof l.getDerivedStateFromError=="function"||x!==null&&typeof x.componentDidCatch=="function"&&(Wa===null||!Wa.has(x))))return h.flags|=65536,T&=-T,h.lanes|=T,T=A_(T),C_(T,a,h,p),gg(h,T),!1}h=h.return}while(h!==null);return!1}var jg=Error(i(461)),zi=!1;function hs(a,l,h,p){l.child=a===null?Ib(l,null,h,p):Zo(l,a.child,h,p)}function D_(a,l,h,p,T){h=h.render;var x=l.ref;if("ref"in p){var M={};for(var q in p)q!=="ref"&&(M[q]=p[q])}else M=p;return Re(l),p=xg(a,l,h,M,x,T),q=Sg(),a!==null&&!zi?(Eg(a,l,T),ea(a,l,T)):(Rt&&q&&Xi(l),l.flags|=1,hs(a,l,p,T),l.child)}function w_(a,l,h,p,T){if(a===null){var x=h.type;return typeof x=="function"&&!Mc(x)&&x.defaultProps===void 0&&h.compare===null?(l.tag=15,l.type=x,L_(a,l,x,p,T)):(a=Nc(h.type,null,p,l,l.mode,T),a.ref=l.ref,a.return=l,l.child=a)}if(x=a.child,!Wg(a,T)){var M=x.memoizedProps;if(h=h.compare,h=h!==null?h:ur,h(M,p)&&a.ref===l.ref)return ea(a,l,T)}return l.flags|=1,a=Kn(x,p),a.ref=l.ref,a.return=l,l.child=a}function L_(a,l,h,p,T){if(a!==null){var x=a.memoizedProps;if(ur(x,p)&&a.ref===l.ref)if(zi=!1,l.pendingProps=p=x,Wg(a,T))(a.flags&131072)!==0&&(zi=!0);else return l.lanes=a.lanes,ea(a,l,T)}return Hg(a,l,h,p,T)}function I_(a,l,h,p){var T=p.children,x=a!==null?a.memoizedState:null;if(a===null&&l.stateNode===null&&(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),p.mode==="hidden"){if((l.flags&128)!==0){if(x=x!==null?x.baseLanes|h:h,a!==null){for(p=l.child=a.child,T=0;p!==null;)T=T|p.lanes|p.childLanes,p=p.sibling;p=T&~x}else p=0,l.child=null;return k_(a,l,x,h,p)}if((h&536870912)!==0)l.memoizedState={baseLanes:0,cachePool:null},a!==null&&Vh(l,x!==null?x.cachePool:null),x!==null?Ob(l,x):vg(),Pb(l);else return p=l.lanes=536870912,k_(a,l,x!==null?x.baseLanes|h:h,h,p)}else x!==null?(Vh(l,x.cachePool),Ob(l,x),qa(),l.memoizedState=null):(a!==null&&Vh(l,null),vg(),qa());return hs(a,l,T,h),l.child}function Wc(a,l){return a!==null&&a.tag===22||l.stateNode!==null||(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.sibling}function k_(a,l,h,p,T){var x=hg();return x=x===null?null:{parent:di._currentValue,pool:x},l.memoizedState={baseLanes:h,cachePool:x},a!==null&&Vh(l,null),vg(),Pb(l),a!==null&&Le(a,l,p,!0),l.childLanes=T,null}function of(a,l){return l=uf({mode:l.mode,children:l.children},a.mode),l.ref=a.ref,a.child=l,l.return=a,l}function R_(a,l,h){return Zo(l,a.child,null,h),a=of(l,l.pendingProps),a.flags|=2,dn(l),l.memoizedState=null,a}function tI(a,l,h){var p=l.pendingProps,T=(l.flags&128)!==0;if(l.flags&=-129,a===null){if(Rt){if(p.mode==="hidden")return a=of(l,p),l.lanes=536870912,Wc(null,a);if(bg(l),(a=ri)?(a=Vx(a,Vs),a=a!==null&&a.data==="&"?a:null,a!==null&&(l.memoizedState={dehydrated:a,treeContext:hr!==null?{id:un,overflow:ds}:null,retryLane:536870912,hydrationErrors:null},h=Bc(a),h.return=l,l.child=h,Vi=l,ri=null)):a=null,a===null)throw mr(l);return l.lanes=536870912,null}return of(l,p)}var x=a.memoizedState;if(x!==null){var M=x.dehydrated;if(bg(l),T)if(l.flags&256)l.flags&=-257,l=R_(a,l,h);else if(l.memoizedState!==null)l.child=a.child,l.flags|=128,l=null;else throw Error(i(558));else if(zi||Le(a,l,h,!1),T=(h&a.childLanes)!==0,zi||T){if(p=ai,p!==null&&(M=Mi(p,h),M!==0&&M!==x.retryLane))throw x.retryLane=M,Xr(a,M),Ws(p,a,M),jg;vf(),l=R_(a,l,h)}else a=x.treeContext,ri=In(M.nextSibling),Vi=l,Rt=!0,pr=null,Vs=!1,a!==null&&Hh(l,a),l=of(l,p),l.flags|=4096;return l}return a=Kn(a.child,{mode:p.mode,children:p.children}),a.ref=l.ref,l.child=a,a.return=l,a}function lf(a,l){var h=l.ref;if(h===null)a!==null&&a.ref!==null&&(l.flags|=4194816);else{if(typeof h!="function"&&typeof h!="object")throw Error(i(284));(a===null||a.ref!==h)&&(l.flags|=4194816)}}function Hg(a,l,h,p,T){return Re(l),h=xg(a,l,h,p,void 0,T),p=Sg(),a!==null&&!zi?(Eg(a,l,T),ea(a,l,T)):(Rt&&p&&Xi(l),l.flags|=1,hs(a,l,h,T),l.child)}function O_(a,l,h,p,T,x){return Re(l),l.updateQueue=null,h=Nb(l,p,h,T),Mb(a),p=Sg(),a!==null&&!zi?(Eg(a,l,x),ea(a,l,x)):(Rt&&p&&Xi(l),l.flags|=1,hs(a,l,h,x),l.child)}function P_(a,l,h,p,T){if(Re(l),l.stateNode===null){var x=Ba,M=h.contextType;typeof M=="object"&&M!==null&&(x=Qe(M)),x=new h(p,x),l.memoizedState=x.state!==null&&x.state!==void 0?x.state:null,x.updater=Ug,l.stateNode=x,x._reactInternals=l,x=l.stateNode,x.props=p,x.state=l.memoizedState,x.refs={},pg(l),M=h.contextType,x.context=typeof M=="object"&&M!==null?Qe(M):Ba,x.state=l.memoizedState,M=h.getDerivedStateFromProps,typeof M=="function"&&(Fg(l,h,M,p),x.state=l.memoizedState),typeof h.getDerivedStateFromProps=="function"||typeof x.getSnapshotBeforeUpdate=="function"||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(M=x.state,typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount(),M!==x.state&&Ug.enqueueReplaceState(x,x.state,null),Vc(l,p,x,T),Gc(),x.state=l.memoizedState),typeof x.componentDidMount=="function"&&(l.flags|=4194308),p=!0}else if(a===null){x=l.stateNode;var q=l.memoizedProps,ce=el(h,q);x.props=ce;var _e=x.context,Oe=h.contextType;M=Ba,typeof Oe=="object"&&Oe!==null&&(M=Qe(Oe));var Ne=h.getDerivedStateFromProps;Oe=typeof Ne=="function"||typeof x.getSnapshotBeforeUpdate=="function",q=l.pendingProps!==q,Oe||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(q||_e!==M)&&b_(l,x,p,M),ja=!1;var De=l.memoizedState;x.state=De,Vc(l,p,x,T),Gc(),_e=l.memoizedState,q||De!==_e||ja?(typeof Ne=="function"&&(Fg(l,h,Ne,p),_e=l.memoizedState),(ce=ja||T_(l,h,ce,p,De,_e,M))?(Oe||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount()),typeof x.componentDidMount=="function"&&(l.flags|=4194308)):(typeof x.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=p,l.memoizedState=_e),x.props=p,x.state=_e,x.context=M,p=ce):(typeof x.componentDidMount=="function"&&(l.flags|=4194308),p=!1)}else{x=l.stateNode,mg(a,l),M=l.memoizedProps,Oe=el(h,M),x.props=Oe,Ne=l.pendingProps,De=x.context,_e=h.contextType,ce=Ba,typeof _e=="object"&&_e!==null&&(ce=Qe(_e)),q=h.getDerivedStateFromProps,(_e=typeof q=="function"||typeof x.getSnapshotBeforeUpdate=="function")||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(M!==Ne||De!==ce)&&b_(l,x,p,ce),ja=!1,De=l.memoizedState,x.state=De,Vc(l,p,x,T),Gc();var Ie=l.memoizedState;M!==Ne||De!==Ie||ja||a!==null&&a.dependencies!==null&&ze(a.dependencies)?(typeof q=="function"&&(Fg(l,h,q,p),Ie=l.memoizedState),(Oe=ja||T_(l,h,Oe,p,De,Ie,ce)||a!==null&&a.dependencies!==null&&ze(a.dependencies))?(_e||typeof x.UNSAFE_componentWillUpdate!="function"&&typeof x.componentWillUpdate!="function"||(typeof x.componentWillUpdate=="function"&&x.componentWillUpdate(p,Ie,ce),typeof x.UNSAFE_componentWillUpdate=="function"&&x.UNSAFE_componentWillUpdate(p,Ie,ce)),typeof x.componentDidUpdate=="function"&&(l.flags|=4),typeof x.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof x.componentDidUpdate!="function"||M===a.memoizedProps&&De===a.memoizedState||(l.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||M===a.memoizedProps&&De===a.memoizedState||(l.flags|=1024),l.memoizedProps=p,l.memoizedState=Ie),x.props=p,x.state=Ie,x.context=ce,p=Oe):(typeof x.componentDidUpdate!="function"||M===a.memoizedProps&&De===a.memoizedState||(l.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||M===a.memoizedProps&&De===a.memoizedState||(l.flags|=1024),p=!1)}return x=p,lf(a,l),p=(l.flags&128)!==0,x||p?(x=l.stateNode,h=p&&typeof h.getDerivedStateFromError!="function"?null:x.render(),l.flags|=1,a!==null&&p?(l.child=Zo(l,a.child,null,T),l.child=Zo(l,null,h,T)):hs(a,l,h,T),l.memoizedState=x.state,a=l.child):a=ea(a,l,T),a}function M_(a,l,h,p){return S(),l.flags|=256,hs(a,l,h,p),l.child}var Gg={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Vg(a){return{baseLanes:a,cachePool:Eb()}}function qg(a,l,h){return a=a!==null?a.childLanes&~h:0,l&&(a|=fn),a}function N_(a,l,h){var p=l.pendingProps,T=!1,x=(l.flags&128)!==0,M;if((M=x)||(M=a!==null&&a.memoizedState===null?!1:(Fi.current&2)!==0),M&&(T=!0,l.flags&=-129),M=(l.flags&32)!==0,l.flags&=-33,a===null){if(Rt){if(T?Va(l):qa(),(a=ri)?(a=Vx(a,Vs),a=a!==null&&a.data!=="&"?a:null,a!==null&&(l.memoizedState={dehydrated:a,treeContext:hr!==null?{id:un,overflow:ds}:null,retryLane:536870912,hydrationErrors:null},h=Bc(a),h.return=l,l.child=h,Vi=l,ri=null)):a=null,a===null)throw mr(l);return D0(a)?l.lanes=32:l.lanes=536870912,null}var q=p.children;return p=p.fallback,T?(qa(),T=l.mode,q=uf({mode:"hidden",children:q},T),p=dr(p,T,h,null),q.return=l,p.return=l,q.sibling=p,l.child=q,p=l.child,p.memoizedState=Vg(h),p.childLanes=qg(a,M,h),l.memoizedState=Gg,Wc(null,p)):(Va(l),zg(l,q))}var ce=a.memoizedState;if(ce!==null&&(q=ce.dehydrated,q!==null)){if(x)l.flags&256?(Va(l),l.flags&=-257,l=Kg(a,l,h)):l.memoizedState!==null?(qa(),l.child=a.child,l.flags|=128,l=null):(qa(),q=p.fallback,T=l.mode,p=uf({mode:"visible",children:p.children},T),q=dr(q,T,h,null),q.flags|=2,p.return=l,q.return=l,p.sibling=q,l.child=p,Zo(l,a.child,null,h),p=l.child,p.memoizedState=Vg(h),p.childLanes=qg(a,M,h),l.memoizedState=Gg,l=Wc(null,p));else if(Va(l),D0(q)){if(M=q.nextSibling&&q.nextSibling.dataset,M)var _e=M.dgst;M=_e,p=Error(i(419)),p.stack="",p.digest=M,A({value:p,source:null,stack:null}),l=Kg(a,l,h)}else if(zi||Le(a,l,h,!1),M=(h&a.childLanes)!==0,zi||M){if(M=ai,M!==null&&(p=Mi(M,h),p!==0&&p!==ce.retryLane))throw ce.retryLane=p,Xr(a,p),Ws(M,a,p),jg;C0(q)||vf(),l=Kg(a,l,h)}else C0(q)?(l.flags|=192,l.child=a.child,l=null):(a=ce.treeContext,ri=In(q.nextSibling),Vi=l,Rt=!0,pr=null,Vs=!1,a!==null&&Hh(l,a),l=zg(l,p.children),l.flags|=4096);return l}return T?(qa(),q=p.fallback,T=l.mode,ce=a.child,_e=ce.sibling,p=Kn(ce,{mode:"hidden",children:p.children}),p.subtreeFlags=ce.subtreeFlags&65011712,_e!==null?q=Kn(_e,q):(q=dr(q,T,h,null),q.flags|=2),q.return=l,p.return=l,p.sibling=q,l.child=p,Wc(null,p),p=l.child,q=a.child.memoizedState,q===null?q=Vg(h):(T=q.cachePool,T!==null?(ce=di._currentValue,T=T.parent!==ce?{parent:ce,pool:ce}:T):T=Eb(),q={baseLanes:q.baseLanes|h,cachePool:T}),p.memoizedState=q,p.childLanes=qg(a,M,h),l.memoizedState=Gg,Wc(a.child,p)):(Va(l),h=a.child,a=h.sibling,h=Kn(h,{mode:"visible",children:p.children}),h.return=l,h.sibling=null,a!==null&&(M=l.deletions,M===null?(l.deletions=[a],l.flags|=16):M.push(a)),l.child=h,l.memoizedState=null,h)}function zg(a,l){return l=uf({mode:"visible",children:l},a.mode),l.return=a,a.child=l}function uf(a,l){return a=Di(22,a,null,l),a.lanes=0,a}function Kg(a,l,h){return Zo(l,a.child,null,h),a=zg(l,l.pendingProps.children),a.flags|=2,l.memoizedState=null,a}function B_(a,l,h){a.lanes|=l;var p=a.alternate;p!==null&&(p.lanes|=l),re(a.return,l,h)}function Yg(a,l,h,p,T,x){var M=a.memoizedState;M===null?a.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:p,tail:h,tailMode:T,treeForkCount:x}:(M.isBackwards=l,M.rendering=null,M.renderingStartTime=0,M.last=p,M.tail=h,M.tailMode=T,M.treeForkCount=x)}function F_(a,l,h){var p=l.pendingProps,T=p.revealOrder,x=p.tail;p=p.children;var M=Fi.current,q=(M&2)!==0;if(q?(M=M&1|2,l.flags|=128):M&=1,fe(Fi,M),hs(a,l,p,h),p=Rt?Ko:0,!q&&a!==null&&(a.flags&128)!==0)e:for(a=l.child;a!==null;){if(a.tag===13)a.memoizedState!==null&&B_(a,h,l);else if(a.tag===19)B_(a,h,l);else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===l)break e;for(;a.sibling===null;){if(a.return===null||a.return===l)break e;a=a.return}a.sibling.return=a.return,a=a.sibling}switch(T){case"forwards":for(h=l.child,T=null;h!==null;)a=h.alternate,a!==null&&Xh(a)===null&&(T=h),h=h.sibling;h=T,h===null?(T=l.child,l.child=null):(T=h.sibling,h.sibling=null),Yg(l,!1,T,h,x,p);break;case"backwards":case"unstable_legacy-backwards":for(h=null,T=l.child,l.child=null;T!==null;){if(a=T.alternate,a!==null&&Xh(a)===null){l.child=T;break}a=T.sibling,T.sibling=h,h=T,T=a}Yg(l,!0,h,null,x,p);break;case"together":Yg(l,!1,null,null,void 0,p);break;default:l.memoizedState=null}return l.child}function ea(a,l,h){if(a!==null&&(l.dependencies=a.dependencies),Ya|=l.lanes,(h&l.childLanes)===0)if(a!==null){if(Le(a,l,h,!1),(h&l.childLanes)===0)return null}else return null;if(a!==null&&l.child!==a.child)throw Error(i(153));if(l.child!==null){for(a=l.child,h=Kn(a,a.pendingProps),l.child=h,h.return=l;a.sibling!==null;)a=a.sibling,h=h.sibling=Kn(a,a.pendingProps),h.return=l;h.sibling=null}return l.child}function Wg(a,l){return(a.lanes&l)!==0?!0:(a=a.dependencies,!!(a!==null&&ze(a)))}function iI(a,l,h){switch(l.tag){case 3:je(l,l.stateNode.containerInfo),J(l,di,a.memoizedState.cache),S();break;case 27:case 5:et(l);break;case 4:je(l,l.stateNode.containerInfo);break;case 10:J(l,l.type,l.memoizedProps.value);break;case 31:if(l.memoizedState!==null)return l.flags|=128,bg(l),null;break;case 13:var p=l.memoizedState;if(p!==null)return p.dehydrated!==null?(Va(l),l.flags|=128,null):(h&l.child.childLanes)!==0?N_(a,l,h):(Va(l),a=ea(a,l,h),a!==null?a.sibling:null);Va(l);break;case 19:var T=(a.flags&128)!==0;if(p=(h&l.childLanes)!==0,p||(Le(a,l,h,!1),p=(h&l.childLanes)!==0),T){if(p)return F_(a,l,h);l.flags|=128}if(T=l.memoizedState,T!==null&&(T.rendering=null,T.tail=null,T.lastEffect=null),fe(Fi,Fi.current),p)break;return null;case 22:return l.lanes=0,I_(a,l,h,l.pendingProps);case 24:J(l,di,a.memoizedState.cache)}return ea(a,l,h)}function U_(a,l,h){if(a!==null)if(a.memoizedProps!==l.pendingProps)zi=!0;else{if(!Wg(a,h)&&(l.flags&128)===0)return zi=!1,iI(a,l,h);zi=(a.flags&131072)!==0}else zi=!1,Rt&&(l.flags&1048576)!==0&&fr(l,Ko,l.index);switch(l.lanes=0,l.tag){case 16:e:{var p=l.pendingProps;if(a=Xo(l.elementType),l.type=a,typeof a=="function")Mc(a)?(p=el(a,p),l.tag=1,l=P_(null,l,a,p,h)):(l.tag=0,l=Hg(null,l,a,p,h));else{if(a!=null){var T=a.$$typeof;if(T===F){l.tag=11,l=D_(null,l,a,p,h);break e}else if(T===B){l.tag=14,l=w_(null,l,a,p,h);break e}}throw l=le(a)||a,Error(i(306,l,""))}}return l;case 0:return Hg(a,l,l.type,l.pendingProps,h);case 1:return p=l.type,T=el(p,l.pendingProps),P_(a,l,p,T,h);case 3:e:{if(je(l,l.stateNode.containerInfo),a===null)throw Error(i(387));p=l.pendingProps;var x=l.memoizedState;T=x.element,mg(a,l),Vc(l,p,null,h);var M=l.memoizedState;if(p=M.cache,J(l,di,p),p!==x.cache&&pe(l,[di],h,!0),Gc(),p=M.element,x.isDehydrated)if(x={element:p,isDehydrated:!1,cache:M.cache},l.updateQueue.baseState=x,l.memoizedState=x,l.flags&256){l=M_(a,l,p,h);break e}else if(p!==T){T=js(Error(i(424)),l),A(T),l=M_(a,l,p,h);break e}else for(a=l.stateNode.containerInfo,a.nodeType===9?a=a.body:a=a.nodeName==="HTML"?a.ownerDocument.body:a,ri=In(a.firstChild),Vi=l,Rt=!0,pr=null,Vs=!0,h=Ib(l,null,p,h),l.child=h;h;)h.flags=h.flags&-3|4096,h=h.sibling;else{if(S(),p===T){l=ea(a,l,h);break e}hs(a,l,p,h)}l=l.child}return l;case 26:return lf(a,l),a===null?(h=Xx(l.type,null,l.pendingProps,null))?l.memoizedState=h:Rt||(h=l.type,a=l.pendingProps,p=Af($e.current).createElement(h),p[jt]=l,p[Nt]=a,fs(p,h,a),Gi(p),l.stateNode=p):l.memoizedState=Xx(l.type,a.memoizedProps,l.pendingProps,a.memoizedState),null;case 27:return et(l),a===null&&Rt&&(p=l.stateNode=Kx(l.type,l.pendingProps,$e.current),Vi=l,Vs=!0,T=ri,Ja(l.type)?(w0=T,ri=In(p.firstChild)):ri=T),hs(a,l,l.pendingProps.children,h),lf(a,l),a===null&&(l.flags|=4194304),l.child;case 5:return a===null&&Rt&&((T=p=ri)&&(p=RI(p,l.type,l.pendingProps,Vs),p!==null?(l.stateNode=p,Vi=l,ri=In(p.firstChild),Vs=!1,T=!0):T=!1),T||mr(l)),et(l),T=l.type,x=l.pendingProps,M=a!==null?a.memoizedProps:null,p=x.children,S0(T,x)?p=null:M!==null&&S0(T,M)&&(l.flags|=32),l.memoizedState!==null&&(T=xg(a,l,KL,null,null,h),cd._currentValue=T),lf(a,l),hs(a,l,p,h),l.child;case 6:return a===null&&Rt&&((a=h=ri)&&(h=OI(h,l.pendingProps,Vs),h!==null?(l.stateNode=h,Vi=l,ri=null,a=!0):a=!1),a||mr(l)),null;case 13:return N_(a,l,h);case 4:return je(l,l.stateNode.containerInfo),p=l.pendingProps,a===null?l.child=Zo(l,null,p,h):hs(a,l,p,h),l.child;case 11:return D_(a,l,l.type,l.pendingProps,h);case 7:return hs(a,l,l.pendingProps,h),l.child;case 8:return hs(a,l,l.pendingProps.children,h),l.child;case 12:return hs(a,l,l.pendingProps.children,h),l.child;case 10:return p=l.pendingProps,J(l,l.type,p.value),hs(a,l,p.children,h),l.child;case 9:return T=l.type._context,p=l.pendingProps.children,Re(l),T=Qe(T),p=p(T),l.flags|=1,hs(a,l,p,h),l.child;case 14:return w_(a,l,l.type,l.pendingProps,h);case 15:return L_(a,l,l.type,l.pendingProps,h);case 19:return F_(a,l,h);case 31:return tI(a,l,h);case 22:return I_(a,l,h,l.pendingProps);case 24:return Re(l),p=Qe(di),a===null?(T=hg(),T===null&&(T=ai,x=Qr(),T.pooledCache=x,x.refCount++,x!==null&&(T.pooledCacheLanes|=h),T=x),l.memoizedState={parent:p,cache:T},pg(l),J(l,di,T)):((a.lanes&h)!==0&&(mg(a,l),Vc(l,null,null,h),Gc()),T=a.memoizedState,x=l.memoizedState,T.parent!==p?(T={parent:p,cache:p},l.memoizedState=T,l.lanes===0&&(l.memoizedState=l.updateQueue.baseState=T),J(l,di,p)):(p=x.cache,J(l,di,p),p!==T.cache&&pe(l,[di],h,!0))),hs(a,l,l.pendingProps.children,h),l.child;case 29:throw l.pendingProps}throw Error(i(156,l.tag))}function ta(a){a.flags|=4}function Xg(a,l,h,p,T){if((l=(a.mode&32)!==0)&&(l=!1),l){if(a.flags|=16777216,(T&335544128)===T)if(a.stateNode.complete)a.flags|=8192;else if(hx())a.flags|=8192;else throw Qo=zh,fg}else a.flags&=-16777217}function $_(a,l){if(l.type!=="stylesheet"||(l.state.loading&4)!==0)a.flags&=-16777217;else if(a.flags|=16777216,!tS(l))if(hx())a.flags|=8192;else throw Qo=zh,fg}function cf(a,l){l!==null&&(a.flags|=4),a.flags&16384&&(l=a.tag!==22?Ge():536870912,a.lanes|=l,du|=l)}function Xc(a,l){if(!Rt)switch(a.tailMode){case"hidden":l=a.tail;for(var h=null;l!==null;)l.alternate!==null&&(h=l),l=l.sibling;h===null?a.tail=null:h.sibling=null;break;case"collapsed":h=a.tail;for(var p=null;h!==null;)h.alternate!==null&&(p=h),h=h.sibling;p===null?l||a.tail===null?a.tail=null:a.tail.sibling=null:p.sibling=null}}function mi(a){var l=a.alternate!==null&&a.alternate.child===a.child,h=0,p=0;if(l)for(var T=a.child;T!==null;)h|=T.lanes|T.childLanes,p|=T.subtreeFlags&65011712,p|=T.flags&65011712,T.return=a,T=T.sibling;else for(T=a.child;T!==null;)h|=T.lanes|T.childLanes,p|=T.subtreeFlags,p|=T.flags,T.return=a,T=T.sibling;return a.subtreeFlags|=p,a.childLanes=h,l}function sI(a,l,h){var p=l.pendingProps;switch(Gs(l),l.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return mi(l),null;case 1:return mi(l),null;case 3:return h=l.stateNode,p=null,a!==null&&(p=a.memoizedState.cache),l.memoizedState.cache!==p&&(l.flags|=2048),te(di),qe(),h.pendingContext&&(h.context=h.pendingContext,h.pendingContext=null),(a===null||a.child===null)&&(y(l)?ta(l):a===null||a.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,C())),mi(l),null;case 26:var T=l.type,x=l.memoizedState;return a===null?(ta(l),x!==null?(mi(l),$_(l,x)):(mi(l),Xg(l,T,null,p,h))):x?x!==a.memoizedState?(ta(l),mi(l),$_(l,x)):(mi(l),l.flags&=-16777217):(a=a.memoizedProps,a!==p&&ta(l),mi(l),Xg(l,T,a,p,h)),null;case 27:if(rt(l),h=$e.current,T=l.type,a!==null&&l.stateNode!=null)a.memoizedProps!==p&&ta(l);else{if(!p){if(l.stateNode===null)throw Error(i(166));return mi(l),null}a=xe.current,y(l)?Gh(l):(a=Kx(T,p,h),l.stateNode=a,ta(l))}return mi(l),null;case 5:if(rt(l),T=l.type,a!==null&&l.stateNode!=null)a.memoizedProps!==p&&ta(l);else{if(!p){if(l.stateNode===null)throw Error(i(166));return mi(l),null}if(x=xe.current,y(l))Gh(l);else{var M=Af($e.current);switch(x){case 1:x=M.createElementNS("http://www.w3.org/2000/svg",T);break;case 2:x=M.createElementNS("http://www.w3.org/1998/Math/MathML",T);break;default:switch(T){case"svg":x=M.createElementNS("http://www.w3.org/2000/svg",T);break;case"math":x=M.createElementNS("http://www.w3.org/1998/Math/MathML",T);break;case"script":x=M.createElement("div"),x.innerHTML="<script><\/script>",x=x.removeChild(x.firstChild);break;case"select":x=typeof p.is=="string"?M.createElement("select",{is:p.is}):M.createElement("select"),p.multiple?x.multiple=!0:p.size&&(x.size=p.size);break;default:x=typeof p.is=="string"?M.createElement(T,{is:p.is}):M.createElement(T)}}x[jt]=l,x[Nt]=p;e:for(M=l.child;M!==null;){if(M.tag===5||M.tag===6)x.appendChild(M.stateNode);else if(M.tag!==4&&M.tag!==27&&M.child!==null){M.child.return=M,M=M.child;continue}if(M===l)break e;for(;M.sibling===null;){if(M.return===null||M.return===l)break e;M=M.return}M.sibling.return=M.return,M=M.sibling}l.stateNode=x;e:switch(fs(x,T,p),T){case"button":case"input":case"select":case"textarea":p=!!p.autoFocus;break e;case"img":p=!0;break e;default:p=!1}p&&ta(l)}}return mi(l),Xg(l,l.type,a===null?null:a.memoizedProps,l.pendingProps,h),null;case 6:if(a&&l.stateNode!=null)a.memoizedProps!==p&&ta(l);else{if(typeof p!="string"&&l.stateNode===null)throw Error(i(166));if(a=$e.current,y(l)){if(a=l.stateNode,h=l.memoizedProps,p=null,T=Vi,T!==null)switch(T.tag){case 27:case 5:p=T.memoizedProps}a[jt]=l,a=!!(a.nodeValue===h||p!==null&&p.suppressHydrationWarning===!0||Nx(a.nodeValue,h)),a||mr(l,!0)}else a=Af(a).createTextNode(p),a[jt]=l,l.stateNode=a}return mi(l),null;case 31:if(h=l.memoizedState,a===null||a.memoizedState!==null){if(p=y(l),h!==null){if(a===null){if(!p)throw Error(i(318));if(a=l.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(i(557));a[jt]=l}else S(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;mi(l),a=!1}else h=C(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=h),a=!0;if(!a)return l.flags&256?(dn(l),l):(dn(l),null);if((l.flags&128)!==0)throw Error(i(558))}return mi(l),null;case 13:if(p=l.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(T=y(l),p!==null&&p.dehydrated!==null){if(a===null){if(!T)throw Error(i(318));if(T=l.memoizedState,T=T!==null?T.dehydrated:null,!T)throw Error(i(317));T[jt]=l}else S(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;mi(l),T=!1}else T=C(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=T),T=!0;if(!T)return l.flags&256?(dn(l),l):(dn(l),null)}return dn(l),(l.flags&128)!==0?(l.lanes=h,l):(h=p!==null,a=a!==null&&a.memoizedState!==null,h&&(p=l.child,T=null,p.alternate!==null&&p.alternate.memoizedState!==null&&p.alternate.memoizedState.cachePool!==null&&(T=p.alternate.memoizedState.cachePool.pool),x=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(x=p.memoizedState.cachePool.pool),x!==T&&(p.flags|=2048)),h!==a&&h&&(l.child.flags|=8192),cf(l,l.updateQueue),mi(l),null);case 4:return qe(),a===null&&v0(l.stateNode.containerInfo),mi(l),null;case 10:return te(l.type),mi(l),null;case 19:if(ie(Fi),p=l.memoizedState,p===null)return mi(l),null;if(T=(l.flags&128)!==0,x=p.rendering,x===null)if(T)Xc(p,!1);else{if(Li!==0||a!==null&&(a.flags&128)!==0)for(a=l.child;a!==null;){if(x=Xh(a),x!==null){for(l.flags|=128,Xc(p,!1),a=x.updateQueue,l.updateQueue=a,cf(l,a),l.subtreeFlags=0,a=h,h=l.child;h!==null;)jh(h,a),h=h.sibling;return fe(Fi,Fi.current&1|2),Rt&&Ct(l,p.treeForkCount),l.child}a=a.sibling}p.tail!==null&&Ye()>mf&&(l.flags|=128,T=!0,Xc(p,!1),l.lanes=4194304)}else{if(!T)if(a=Xh(x),a!==null){if(l.flags|=128,T=!0,a=a.updateQueue,l.updateQueue=a,cf(l,a),Xc(p,!0),p.tail===null&&p.tailMode==="hidden"&&!x.alternate&&!Rt)return mi(l),null}else 2*Ye()-p.renderingStartTime>mf&&h!==536870912&&(l.flags|=128,T=!0,Xc(p,!1),l.lanes=4194304);p.isBackwards?(x.sibling=l.child,l.child=x):(a=p.last,a!==null?a.sibling=x:l.child=x,p.last=x)}return p.tail!==null?(a=p.tail,p.rendering=a,p.tail=a.sibling,p.renderingStartTime=Ye(),a.sibling=null,h=Fi.current,fe(Fi,T?h&1|2:h&1),Rt&&Ct(l,p.treeForkCount),a):(mi(l),null);case 22:case 23:return dn(l),Tg(),p=l.memoizedState!==null,a!==null?a.memoizedState!==null!==p&&(l.flags|=8192):p&&(l.flags|=8192),p?(h&536870912)!==0&&(l.flags&128)===0&&(mi(l),l.subtreeFlags&6&&(l.flags|=8192)):mi(l),h=l.updateQueue,h!==null&&cf(l,h.retryQueue),h=null,a!==null&&a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(h=a.memoizedState.cachePool.pool),p=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(p=l.memoizedState.cachePool.pool),p!==h&&(l.flags|=2048),a!==null&&ie(Wo),null;case 24:return h=null,a!==null&&(h=a.memoizedState.cache),l.memoizedState.cache!==h&&(l.flags|=2048),te(di),mi(l),null;case 25:return null;case 30:return null}throw Error(i(156,l.tag))}function nI(a,l){switch(Gs(l),l.tag){case 1:return a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 3:return te(di),qe(),a=l.flags,(a&65536)!==0&&(a&128)===0?(l.flags=a&-65537|128,l):null;case 26:case 27:case 5:return rt(l),null;case 31:if(l.memoizedState!==null){if(dn(l),l.alternate===null)throw Error(i(340));S()}return a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 13:if(dn(l),a=l.memoizedState,a!==null&&a.dehydrated!==null){if(l.alternate===null)throw Error(i(340));S()}return a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 19:return ie(Fi),null;case 4:return qe(),null;case 10:return te(l.type),null;case 22:case 23:return dn(l),Tg(),a!==null&&ie(Wo),a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 24:return te(di),null;case 25:return null;default:return null}}function j_(a,l){switch(Gs(l),l.tag){case 3:te(di),qe();break;case 26:case 27:case 5:rt(l);break;case 4:qe();break;case 31:l.memoizedState!==null&&dn(l);break;case 13:dn(l);break;case 19:ie(Fi);break;case 10:te(l.type);break;case 22:case 23:dn(l),Tg(),a!==null&&ie(Wo);break;case 24:te(di)}}function Qc(a,l){try{var h=l.updateQueue,p=h!==null?h.lastEffect:null;if(p!==null){var T=p.next;h=T;do{if((h.tag&a)===a){p=void 0;var x=h.create,M=h.inst;p=x(),M.destroy=p}h=h.next}while(h!==T)}}catch(q){Xt(l,l.return,q)}}function za(a,l,h){try{var p=l.updateQueue,T=p!==null?p.lastEffect:null;if(T!==null){var x=T.next;p=x;do{if((p.tag&a)===a){var M=p.inst,q=M.destroy;if(q!==void 0){M.destroy=void 0,T=l;var ce=h,_e=q;try{_e()}catch(Oe){Xt(T,ce,Oe)}}}p=p.next}while(p!==x)}}catch(Oe){Xt(l,l.return,Oe)}}function H_(a){var l=a.updateQueue;if(l!==null){var h=a.stateNode;try{Rb(l,h)}catch(p){Xt(a,a.return,p)}}}function G_(a,l,h){h.props=el(a.type,a.memoizedProps),h.state=a.memoizedState;try{h.componentWillUnmount()}catch(p){Xt(a,l,p)}}function Zc(a,l){try{var h=a.ref;if(h!==null){switch(a.tag){case 26:case 27:case 5:var p=a.stateNode;break;case 30:p=a.stateNode;break;default:p=a.stateNode}typeof h=="function"?a.refCleanup=h(p):h.current=p}}catch(T){Xt(a,l,T)}}function vr(a,l){var h=a.ref,p=a.refCleanup;if(h!==null)if(typeof p=="function")try{p()}catch(T){Xt(a,l,T)}finally{a.refCleanup=null,a=a.alternate,a!=null&&(a.refCleanup=null)}else if(typeof h=="function")try{h(null)}catch(T){Xt(a,l,T)}else h.current=null}function V_(a){var l=a.type,h=a.memoizedProps,p=a.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":h.autoFocus&&p.focus();break e;case"img":h.src?p.src=h.src:h.srcSet&&(p.srcset=h.srcSet)}}catch(T){Xt(a,a.return,T)}}function Qg(a,l,h){try{var p=a.stateNode;CI(p,a.type,h,l),p[Nt]=l}catch(T){Xt(a,a.return,T)}}function q_(a){return a.tag===5||a.tag===3||a.tag===26||a.tag===27&&Ja(a.type)||a.tag===4}function Zg(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||q_(a.return))return null;a=a.return}for(a.sibling.return=a.return,a=a.sibling;a.tag!==5&&a.tag!==6&&a.tag!==18;){if(a.tag===27&&Ja(a.type)||a.flags&2||a.child===null||a.tag===4)continue e;a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}function Jg(a,l,h){var p=a.tag;if(p===5||p===6)a=a.stateNode,l?(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h).insertBefore(a,l):(l=h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,l.appendChild(a),h=h._reactRootContainer,h!=null||l.onclick!==null||(l.onclick=Vn));else if(p!==4&&(p===27&&Ja(a.type)&&(h=a.stateNode,l=null),a=a.child,a!==null))for(Jg(a,l,h),a=a.sibling;a!==null;)Jg(a,l,h),a=a.sibling}function df(a,l,h){var p=a.tag;if(p===5||p===6)a=a.stateNode,l?h.insertBefore(a,l):h.appendChild(a);else if(p!==4&&(p===27&&Ja(a.type)&&(h=a.stateNode),a=a.child,a!==null))for(df(a,l,h),a=a.sibling;a!==null;)df(a,l,h),a=a.sibling}function z_(a){var l=a.stateNode,h=a.memoizedProps;try{for(var p=a.type,T=l.attributes;T.length;)l.removeAttributeNode(T[0]);fs(l,p,h),l[jt]=a,l[Nt]=h}catch(x){Xt(a,a.return,x)}}var ia=!1,Ki=!1,e0=!1,K_=typeof WeakSet=="function"?WeakSet:Set,rs=null;function rI(a,l){if(a=a.containerInfo,_0=Rf,a=Xl(a),Dc(a)){if("selectionStart"in a)var h={start:a.selectionStart,end:a.selectionEnd};else e:{h=(h=a.ownerDocument)&&h.defaultView||window;var p=h.getSelection&&h.getSelection();if(p&&p.rangeCount!==0){h=p.anchorNode;var T=p.anchorOffset,x=p.focusNode;p=p.focusOffset;try{h.nodeType,x.nodeType}catch{h=null;break e}var M=0,q=-1,ce=-1,_e=0,Oe=0,Ne=a,De=null;t:for(;;){for(var Ie;Ne!==h||T!==0&&Ne.nodeType!==3||(q=M+T),Ne!==x||p!==0&&Ne.nodeType!==3||(ce=M+p),Ne.nodeType===3&&(M+=Ne.nodeValue.length),(Ie=Ne.firstChild)!==null;)De=Ne,Ne=Ie;for(;;){if(Ne===a)break t;if(De===h&&++_e===T&&(q=M),De===x&&++Oe===p&&(ce=M),(Ie=Ne.nextSibling)!==null)break;Ne=De,De=Ne.parentNode}Ne=Ie}h=q===-1||ce===-1?null:{start:q,end:ce}}else h=null}h=h||{start:0,end:0}}else h=null;for(x0={focusedElem:a,selectionRange:h},Rf=!1,rs=l;rs!==null;)if(l=rs,a=l.child,(l.subtreeFlags&1028)!==0&&a!==null)a.return=l,rs=a;else for(;rs!==null;){switch(l=rs,x=l.alternate,a=l.flags,l.tag){case 0:if((a&4)!==0&&(a=l.updateQueue,a=a!==null?a.events:null,a!==null))for(h=0;h<a.length;h++)T=a[h],T.ref.impl=T.nextImpl;break;case 11:case 15:break;case 1:if((a&1024)!==0&&x!==null){a=void 0,h=l,T=x.memoizedProps,x=x.memoizedState,p=h.stateNode;try{var tt=el(h.type,T);a=p.getSnapshotBeforeUpdate(tt,x),p.__reactInternalSnapshotBeforeUpdate=a}catch(ct){Xt(h,h.return,ct)}}break;case 3:if((a&1024)!==0){if(a=l.stateNode.containerInfo,h=a.nodeType,h===9)A0(a);else if(h===1)switch(a.nodeName){case"HEAD":case"HTML":case"BODY":A0(a);break;default:a.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((a&1024)!==0)throw Error(i(163))}if(a=l.sibling,a!==null){a.return=l.return,rs=a;break}rs=l.return}}function Y_(a,l,h){var p=h.flags;switch(h.tag){case 0:case 11:case 15:na(a,h),p&4&&Qc(5,h);break;case 1:if(na(a,h),p&4)if(a=h.stateNode,l===null)try{a.componentDidMount()}catch(M){Xt(h,h.return,M)}else{var T=el(h.type,l.memoizedProps);l=l.memoizedState;try{a.componentDidUpdate(T,l,a.__reactInternalSnapshotBeforeUpdate)}catch(M){Xt(h,h.return,M)}}p&64&&H_(h),p&512&&Zc(h,h.return);break;case 3:if(na(a,h),p&64&&(a=h.updateQueue,a!==null)){if(l=null,h.child!==null)switch(h.child.tag){case 27:case 5:l=h.child.stateNode;break;case 1:l=h.child.stateNode}try{Rb(a,l)}catch(M){Xt(h,h.return,M)}}break;case 27:l===null&&p&4&&z_(h);case 26:case 5:na(a,h),l===null&&p&4&&V_(h),p&512&&Zc(h,h.return);break;case 12:na(a,h);break;case 31:na(a,h),p&4&&Q_(a,h);break;case 13:na(a,h),p&4&&Z_(a,h),p&64&&(a=h.memoizedState,a!==null&&(a=a.dehydrated,a!==null&&(h=pI.bind(null,h),PI(a,h))));break;case 22:if(p=h.memoizedState!==null||ia,!p){l=l!==null&&l.memoizedState!==null||Ki,T=ia;var x=Ki;ia=p,(Ki=l)&&!x?ra(a,h,(h.subtreeFlags&8772)!==0):na(a,h),ia=T,Ki=x}break;case 30:break;default:na(a,h)}}function W_(a){var l=a.alternate;l!==null&&(a.alternate=null,W_(l)),a.child=null,a.deletions=null,a.sibling=null,a.tag===5&&(l=a.stateNode,l!==null&&Jt(l)),a.stateNode=null,a.return=null,a.dependencies=null,a.memoizedProps=null,a.memoizedState=null,a.pendingProps=null,a.stateNode=null,a.updateQueue=null}var vi=null,qs=!1;function sa(a,l,h){for(h=h.child;h!==null;)X_(a,l,h),h=h.sibling}function X_(a,l,h){if(ye&&typeof ye.onCommitFiberUnmount=="function")try{ye.onCommitFiberUnmount(de,h)}catch{}switch(h.tag){case 26:Ki||vr(h,l),sa(a,l,h),h.memoizedState?h.memoizedState.count--:h.stateNode&&(h=h.stateNode,h.parentNode.removeChild(h));break;case 27:Ki||vr(h,l);var p=vi,T=qs;Ja(h.type)&&(vi=h.stateNode,qs=!1),sa(a,l,h),od(h.stateNode),vi=p,qs=T;break;case 5:Ki||vr(h,l);case 6:if(p=vi,T=qs,vi=null,sa(a,l,h),vi=p,qs=T,vi!==null)if(qs)try{(vi.nodeType===9?vi.body:vi.nodeName==="HTML"?vi.ownerDocument.body:vi).removeChild(h.stateNode)}catch(x){Xt(h,l,x)}else try{vi.removeChild(h.stateNode)}catch(x){Xt(h,l,x)}break;case 18:vi!==null&&(qs?(a=vi,Hx(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,h.stateNode),Tu(a)):Hx(vi,h.stateNode));break;case 4:p=vi,T=qs,vi=h.stateNode.containerInfo,qs=!0,sa(a,l,h),vi=p,qs=T;break;case 0:case 11:case 14:case 15:za(2,h,l),Ki||za(4,h,l),sa(a,l,h);break;case 1:Ki||(vr(h,l),p=h.stateNode,typeof p.componentWillUnmount=="function"&&G_(h,l,p)),sa(a,l,h);break;case 21:sa(a,l,h);break;case 22:Ki=(p=Ki)||h.memoizedState!==null,sa(a,l,h),Ki=p;break;default:sa(a,l,h)}}function Q_(a,l){if(l.memoizedState===null&&(a=l.alternate,a!==null&&(a=a.memoizedState,a!==null))){a=a.dehydrated;try{Tu(a)}catch(h){Xt(l,l.return,h)}}}function Z_(a,l){if(l.memoizedState===null&&(a=l.alternate,a!==null&&(a=a.memoizedState,a!==null&&(a=a.dehydrated,a!==null))))try{Tu(a)}catch(h){Xt(l,l.return,h)}}function aI(a){switch(a.tag){case 31:case 13:case 19:var l=a.stateNode;return l===null&&(l=a.stateNode=new K_),l;case 22:return a=a.stateNode,l=a._retryCache,l===null&&(l=a._retryCache=new K_),l;default:throw Error(i(435,a.tag))}}function hf(a,l){var h=aI(a);l.forEach(function(p){if(!h.has(p)){h.add(p);var T=mI.bind(null,a,p);p.then(T,T)}})}function zs(a,l){var h=l.deletions;if(h!==null)for(var p=0;p<h.length;p++){var T=h[p],x=a,M=l,q=M;e:for(;q!==null;){switch(q.tag){case 27:if(Ja(q.type)){vi=q.stateNode,qs=!1;break e}break;case 5:vi=q.stateNode,qs=!1;break e;case 3:case 4:vi=q.stateNode.containerInfo,qs=!0;break e}q=q.return}if(vi===null)throw Error(i(160));X_(x,M,T),vi=null,qs=!1,x=T.alternate,x!==null&&(x.return=null),T.return=null}if(l.subtreeFlags&13886)for(l=l.child;l!==null;)J_(l,a),l=l.sibling}var Wn=null;function J_(a,l){var h=a.alternate,p=a.flags;switch(a.tag){case 0:case 11:case 14:case 15:zs(l,a),Ks(a),p&4&&(za(3,a,a.return),Qc(3,a),za(5,a,a.return));break;case 1:zs(l,a),Ks(a),p&512&&(Ki||h===null||vr(h,h.return)),p&64&&ia&&(a=a.updateQueue,a!==null&&(p=a.callbacks,p!==null&&(h=a.shared.hiddenCallbacks,a.shared.hiddenCallbacks=h===null?p:h.concat(p))));break;case 26:var T=Wn;if(zs(l,a),Ks(a),p&512&&(Ki||h===null||vr(h,h.return)),p&4){var x=h!==null?h.memoizedState:null;if(p=a.memoizedState,h===null)if(p===null)if(a.stateNode===null){e:{p=a.type,h=a.memoizedProps,T=T.ownerDocument||T;t:switch(p){case"title":x=T.getElementsByTagName("title")[0],(!x||x[an]||x[jt]||x.namespaceURI==="http://www.w3.org/2000/svg"||x.hasAttribute("itemprop"))&&(x=T.createElement(p),T.head.insertBefore(x,T.querySelector("head > title"))),fs(x,p,h),x[jt]=a,Gi(x),p=x;break e;case"link":var M=Jx("link","href",T).get(p+(h.href||""));if(M){for(var q=0;q<M.length;q++)if(x=M[q],x.getAttribute("href")===(h.href==null||h.href===""?null:h.href)&&x.getAttribute("rel")===(h.rel==null?null:h.rel)&&x.getAttribute("title")===(h.title==null?null:h.title)&&x.getAttribute("crossorigin")===(h.crossOrigin==null?null:h.crossOrigin)){M.splice(q,1);break t}}x=T.createElement(p),fs(x,p,h),T.head.appendChild(x);break;case"meta":if(M=Jx("meta","content",T).get(p+(h.content||""))){for(q=0;q<M.length;q++)if(x=M[q],x.getAttribute("content")===(h.content==null?null:""+h.content)&&x.getAttribute("name")===(h.name==null?null:h.name)&&x.getAttribute("property")===(h.property==null?null:h.property)&&x.getAttribute("http-equiv")===(h.httpEquiv==null?null:h.httpEquiv)&&x.getAttribute("charset")===(h.charSet==null?null:h.charSet)){M.splice(q,1);break t}}x=T.createElement(p),fs(x,p,h),T.head.appendChild(x);break;default:throw Error(i(468,p))}x[jt]=a,Gi(x),p=x}a.stateNode=p}else eS(T,a.type,a.stateNode);else a.stateNode=Zx(T,p,a.memoizedProps);else x!==p?(x===null?h.stateNode!==null&&(h=h.stateNode,h.parentNode.removeChild(h)):x.count--,p===null?eS(T,a.type,a.stateNode):Zx(T,p,a.memoizedProps)):p===null&&a.stateNode!==null&&Qg(a,a.memoizedProps,h.memoizedProps)}break;case 27:zs(l,a),Ks(a),p&512&&(Ki||h===null||vr(h,h.return)),h!==null&&p&4&&Qg(a,a.memoizedProps,h.memoizedProps);break;case 5:if(zs(l,a),Ks(a),p&512&&(Ki||h===null||vr(h,h.return)),a.flags&32){T=a.stateNode;try{Dn(T,"")}catch(tt){Xt(a,a.return,tt)}}p&4&&a.stateNode!=null&&(T=a.memoizedProps,Qg(a,T,h!==null?h.memoizedProps:T)),p&1024&&(e0=!0);break;case 6:if(zs(l,a),Ks(a),p&4){if(a.stateNode===null)throw Error(i(162));p=a.memoizedProps,h=a.stateNode;try{h.nodeValue=p}catch(tt){Xt(a,a.return,tt)}}break;case 3:if(wf=null,T=Wn,Wn=Cf(l.containerInfo),zs(l,a),Wn=T,Ks(a),p&4&&h!==null&&h.memoizedState.isDehydrated)try{Tu(l.containerInfo)}catch(tt){Xt(a,a.return,tt)}e0&&(e0=!1,ex(a));break;case 4:p=Wn,Wn=Cf(a.stateNode.containerInfo),zs(l,a),Ks(a),Wn=p;break;case 12:zs(l,a),Ks(a);break;case 31:zs(l,a),Ks(a),p&4&&(p=a.updateQueue,p!==null&&(a.updateQueue=null,hf(a,p)));break;case 13:zs(l,a),Ks(a),a.child.flags&8192&&a.memoizedState!==null!=(h!==null&&h.memoizedState!==null)&&(pf=Ye()),p&4&&(p=a.updateQueue,p!==null&&(a.updateQueue=null,hf(a,p)));break;case 22:T=a.memoizedState!==null;var ce=h!==null&&h.memoizedState!==null,_e=ia,Oe=Ki;if(ia=_e||T,Ki=Oe||ce,zs(l,a),Ki=Oe,ia=_e,Ks(a),p&8192)e:for(l=a.stateNode,l._visibility=T?l._visibility&-2:l._visibility|1,T&&(h===null||ce||ia||Ki||tl(a)),h=null,l=a;;){if(l.tag===5||l.tag===26){if(h===null){ce=h=l;try{if(x=ce.stateNode,T)M=x.style,typeof M.setProperty=="function"?M.setProperty("display","none","important"):M.display="none";else{q=ce.stateNode;var Ne=ce.memoizedProps.style,De=Ne!=null&&Ne.hasOwnProperty("display")?Ne.display:null;q.style.display=De==null||typeof De=="boolean"?"":(""+De).trim()}}catch(tt){Xt(ce,ce.return,tt)}}}else if(l.tag===6){if(h===null){ce=l;try{ce.stateNode.nodeValue=T?"":ce.memoizedProps}catch(tt){Xt(ce,ce.return,tt)}}}else if(l.tag===18){if(h===null){ce=l;try{var Ie=ce.stateNode;T?Gx(Ie,!0):Gx(ce.stateNode,!1)}catch(tt){Xt(ce,ce.return,tt)}}}else if((l.tag!==22&&l.tag!==23||l.memoizedState===null||l===a)&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===a)break e;for(;l.sibling===null;){if(l.return===null||l.return===a)break e;h===l&&(h=null),l=l.return}h===l&&(h=null),l.sibling.return=l.return,l=l.sibling}p&4&&(p=a.updateQueue,p!==null&&(h=p.retryQueue,h!==null&&(p.retryQueue=null,hf(a,h))));break;case 19:zs(l,a),Ks(a),p&4&&(p=a.updateQueue,p!==null&&(a.updateQueue=null,hf(a,p)));break;case 30:break;case 21:break;default:zs(l,a),Ks(a)}}function Ks(a){var l=a.flags;if(l&2){try{for(var h,p=a.return;p!==null;){if(q_(p)){h=p;break}p=p.return}if(h==null)throw Error(i(160));switch(h.tag){case 27:var T=h.stateNode,x=Zg(a);df(a,x,T);break;case 5:var M=h.stateNode;h.flags&32&&(Dn(M,""),h.flags&=-33);var q=Zg(a);df(a,q,M);break;case 3:case 4:var ce=h.stateNode.containerInfo,_e=Zg(a);Jg(a,_e,ce);break;default:throw Error(i(161))}}catch(Oe){Xt(a,a.return,Oe)}a.flags&=-3}l&4096&&(a.flags&=-4097)}function ex(a){if(a.subtreeFlags&1024)for(a=a.child;a!==null;){var l=a;ex(l),l.tag===5&&l.flags&1024&&l.stateNode.reset(),a=a.sibling}}function na(a,l){if(l.subtreeFlags&8772)for(l=l.child;l!==null;)Y_(a,l.alternate,l),l=l.sibling}function tl(a){for(a=a.child;a!==null;){var l=a;switch(l.tag){case 0:case 11:case 14:case 15:za(4,l,l.return),tl(l);break;case 1:vr(l,l.return);var h=l.stateNode;typeof h.componentWillUnmount=="function"&&G_(l,l.return,h),tl(l);break;case 27:od(l.stateNode);case 26:case 5:vr(l,l.return),tl(l);break;case 22:l.memoizedState===null&&tl(l);break;case 30:tl(l);break;default:tl(l)}a=a.sibling}}function ra(a,l,h){for(h=h&&(l.subtreeFlags&8772)!==0,l=l.child;l!==null;){var p=l.alternate,T=a,x=l,M=x.flags;switch(x.tag){case 0:case 11:case 15:ra(T,x,h),Qc(4,x);break;case 1:if(ra(T,x,h),p=x,T=p.stateNode,typeof T.componentDidMount=="function")try{T.componentDidMount()}catch(_e){Xt(p,p.return,_e)}if(p=x,T=p.updateQueue,T!==null){var q=p.stateNode;try{var ce=T.shared.hiddenCallbacks;if(ce!==null)for(T.shared.hiddenCallbacks=null,T=0;T<ce.length;T++)kb(ce[T],q)}catch(_e){Xt(p,p.return,_e)}}h&&M&64&&H_(x),Zc(x,x.return);break;case 27:z_(x);case 26:case 5:ra(T,x,h),h&&p===null&&M&4&&V_(x),Zc(x,x.return);break;case 12:ra(T,x,h);break;case 31:ra(T,x,h),h&&M&4&&Q_(T,x);break;case 13:ra(T,x,h),h&&M&4&&Z_(T,x);break;case 22:x.memoizedState===null&&ra(T,x,h),Zc(x,x.return);break;case 30:break;default:ra(T,x,h)}l=l.sibling}}function t0(a,l){var h=null;a!==null&&a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(h=a.memoizedState.cachePool.pool),a=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(a=l.memoizedState.cachePool.pool),a!==h&&(a!=null&&a.refCount++,h!=null&&Yn(h))}function i0(a,l){a=null,l.alternate!==null&&(a=l.alternate.memoizedState.cache),l=l.memoizedState.cache,l!==a&&(l.refCount++,a!=null&&Yn(a))}function Xn(a,l,h,p){if(l.subtreeFlags&10256)for(l=l.child;l!==null;)tx(a,l,h,p),l=l.sibling}function tx(a,l,h,p){var T=l.flags;switch(l.tag){case 0:case 11:case 15:Xn(a,l,h,p),T&2048&&Qc(9,l);break;case 1:Xn(a,l,h,p);break;case 3:Xn(a,l,h,p),T&2048&&(a=null,l.alternate!==null&&(a=l.alternate.memoizedState.cache),l=l.memoizedState.cache,l!==a&&(l.refCount++,a!=null&&Yn(a)));break;case 12:if(T&2048){Xn(a,l,h,p),a=l.stateNode;try{var x=l.memoizedProps,M=x.id,q=x.onPostCommit;typeof q=="function"&&q(M,l.alternate===null?"mount":"update",a.passiveEffectDuration,-0)}catch(ce){Xt(l,l.return,ce)}}else Xn(a,l,h,p);break;case 31:Xn(a,l,h,p);break;case 13:Xn(a,l,h,p);break;case 23:break;case 22:x=l.stateNode,M=l.alternate,l.memoizedState!==null?x._visibility&2?Xn(a,l,h,p):Jc(a,l):x._visibility&2?Xn(a,l,h,p):(x._visibility|=2,lu(a,l,h,p,(l.subtreeFlags&10256)!==0||!1)),T&2048&&t0(M,l);break;case 24:Xn(a,l,h,p),T&2048&&i0(l.alternate,l);break;default:Xn(a,l,h,p)}}function lu(a,l,h,p,T){for(T=T&&((l.subtreeFlags&10256)!==0||!1),l=l.child;l!==null;){var x=a,M=l,q=h,ce=p,_e=M.flags;switch(M.tag){case 0:case 11:case 15:lu(x,M,q,ce,T),Qc(8,M);break;case 23:break;case 22:var Oe=M.stateNode;M.memoizedState!==null?Oe._visibility&2?lu(x,M,q,ce,T):Jc(x,M):(Oe._visibility|=2,lu(x,M,q,ce,T)),T&&_e&2048&&t0(M.alternate,M);break;case 24:lu(x,M,q,ce,T),T&&_e&2048&&i0(M.alternate,M);break;default:lu(x,M,q,ce,T)}l=l.sibling}}function Jc(a,l){if(l.subtreeFlags&10256)for(l=l.child;l!==null;){var h=a,p=l,T=p.flags;switch(p.tag){case 22:Jc(h,p),T&2048&&t0(p.alternate,p);break;case 24:Jc(h,p),T&2048&&i0(p.alternate,p);break;default:Jc(h,p)}l=l.sibling}}var ed=8192;function uu(a,l,h){if(a.subtreeFlags&ed)for(a=a.child;a!==null;)ix(a,l,h),a=a.sibling}function ix(a,l,h){switch(a.tag){case 26:uu(a,l,h),a.flags&ed&&a.memoizedState!==null&&zI(h,Wn,a.memoizedState,a.memoizedProps);break;case 5:uu(a,l,h);break;case 3:case 4:var p=Wn;Wn=Cf(a.stateNode.containerInfo),uu(a,l,h),Wn=p;break;case 22:a.memoizedState===null&&(p=a.alternate,p!==null&&p.memoizedState!==null?(p=ed,ed=16777216,uu(a,l,h),ed=p):uu(a,l,h));break;default:uu(a,l,h)}}function sx(a){var l=a.alternate;if(l!==null&&(a=l.child,a!==null)){l.child=null;do l=a.sibling,a.sibling=null,a=l;while(a!==null)}}function td(a){var l=a.deletions;if((a.flags&16)!==0){if(l!==null)for(var h=0;h<l.length;h++){var p=l[h];rs=p,rx(p,a)}sx(a)}if(a.subtreeFlags&10256)for(a=a.child;a!==null;)nx(a),a=a.sibling}function nx(a){switch(a.tag){case 0:case 11:case 15:td(a),a.flags&2048&&za(9,a,a.return);break;case 3:td(a);break;case 12:td(a);break;case 22:var l=a.stateNode;a.memoizedState!==null&&l._visibility&2&&(a.return===null||a.return.tag!==13)?(l._visibility&=-3,ff(a)):td(a);break;default:td(a)}}function ff(a){var l=a.deletions;if((a.flags&16)!==0){if(l!==null)for(var h=0;h<l.length;h++){var p=l[h];rs=p,rx(p,a)}sx(a)}for(a=a.child;a!==null;){switch(l=a,l.tag){case 0:case 11:case 15:za(8,l,l.return),ff(l);break;case 22:h=l.stateNode,h._visibility&2&&(h._visibility&=-3,ff(l));break;default:ff(l)}a=a.sibling}}function rx(a,l){for(;rs!==null;){var h=rs;switch(h.tag){case 0:case 11:case 15:za(8,h,l);break;case 23:case 22:if(h.memoizedState!==null&&h.memoizedState.cachePool!==null){var p=h.memoizedState.cachePool.pool;p!=null&&p.refCount++}break;case 24:Yn(h.memoizedState.cache)}if(p=h.child,p!==null)p.return=h,rs=p;else e:for(h=a;rs!==null;){p=rs;var T=p.sibling,x=p.return;if(W_(p),p===h){rs=null;break e}if(T!==null){T.return=x,rs=T;break e}rs=x}}}var oI={getCacheForType:function(a){var l=Qe(di),h=l.data.get(a);return h===void 0&&(h=a(),l.data.set(a,h)),h},cacheSignal:function(){return Qe(di).controller.signal}},lI=typeof WeakMap=="function"?WeakMap:Map,zt=0,ai=null,Ot=null,Bt=0,Wt=0,hn=null,Ka=!1,cu=!1,s0=!1,aa=0,Li=0,Ya=0,il=0,n0=0,fn=0,du=0,id=null,Ys=null,r0=!1,pf=0,ax=0,mf=1/0,gf=null,Wa=null,Qi=0,Xa=null,hu=null,oa=0,a0=0,o0=null,ox=null,sd=0,l0=null;function pn(){return(zt&2)!==0&&Bt!==0?Bt&-Bt:Y.T!==null?p0():An()}function lx(){if(fn===0)if((Bt&536870912)===0||Rt){var a=Ht;Ht<<=1,(Ht&3932160)===0&&(Ht=262144),fn=a}else fn=536870912;return a=cn.current,a!==null&&(a.flags|=32),fn}function Ws(a,l,h){(a===ai&&(Wt===2||Wt===9)||a.cancelPendingCommit!==null)&&(fu(a,0),Qa(a,Bt,fn,!1)),Mt(a,h),((zt&2)===0||a!==ai)&&(a===ai&&((zt&2)===0&&(il|=h),Li===4&&Qa(a,Bt,fn,!1)),Tr(a))}function ux(a,l,h){if((zt&6)!==0)throw Error(i(327));var p=!h&&(l&127)===0&&(l&a.expiredLanes)===0||se(a,l),T=p?dI(a,l):c0(a,l,!0),x=p;do{if(T===0){cu&&!p&&Qa(a,l,0,!1);break}else{if(h=a.current.alternate,x&&!uI(h)){T=c0(a,l,!1),x=!1;continue}if(T===2){if(x=l,a.errorRecoveryDisabledLanes&x)var M=0;else M=a.pendingLanes&-536870913,M=M!==0?M:M&536870912?536870912:0;if(M!==0){l=M;e:{var q=a;T=id;var ce=q.current.memoizedState.isDehydrated;if(ce&&(fu(q,M).flags|=256),M=c0(q,M,!1),M!==2){if(s0&&!ce){q.errorRecoveryDisabledLanes|=x,il|=x,T=4;break e}x=Ys,Ys=T,x!==null&&(Ys===null?Ys=x:Ys.push.apply(Ys,x))}T=M}if(x=!1,T!==2)continue}}if(T===1){fu(a,0),Qa(a,l,0,!0);break}e:{switch(p=a,x=T,x){case 0:case 1:throw Error(i(345));case 4:if((l&4194048)!==l)break;case 6:Qa(p,l,fn,!Ka);break e;case 2:Ys=null;break;case 3:case 5:break;default:throw Error(i(329))}if((l&62914560)===l&&(T=pf+300-Ye(),10<T)){if(Qa(p,l,fn,!Ka),K(p,0,!0)!==0)break e;oa=l,p.timeoutHandle=$x(cx.bind(null,p,h,Ys,gf,r0,l,fn,il,du,Ka,x,"Throttled",-0,0),T);break e}cx(p,h,Ys,gf,r0,l,fn,il,du,Ka,x,null,-0,0)}}break}while(!0);Tr(a)}function cx(a,l,h,p,T,x,M,q,ce,_e,Oe,Ne,De,Ie){if(a.timeoutHandle=-1,Ne=l.subtreeFlags,Ne&8192||(Ne&16785408)===16785408){Ne={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Vn},ix(l,x,Ne);var tt=(x&62914560)===x?pf-Ye():(x&4194048)===x?ax-Ye():0;if(tt=KI(Ne,tt),tt!==null){oa=x,a.cancelPendingCommit=tt(vx.bind(null,a,l,x,h,p,T,M,q,ce,Oe,Ne,null,De,Ie)),Qa(a,x,M,!_e);return}}vx(a,l,x,h,p,T,M,q,ce)}function uI(a){for(var l=a;;){var h=l.tag;if((h===0||h===11||h===15)&&l.flags&16384&&(h=l.updateQueue,h!==null&&(h=h.stores,h!==null)))for(var p=0;p<h.length;p++){var T=h[p],x=T.getSnapshot;T=T.value;try{if(!_s(x(),T))return!1}catch{return!1}}if(h=l.child,l.subtreeFlags&16384&&h!==null)h.return=l,l=h;else{if(l===a)break;for(;l.sibling===null;){if(l.return===null||l.return===a)return!0;l=l.return}l.sibling.return=l.return,l=l.sibling}}return!0}function Qa(a,l,h,p){l&=~n0,l&=~il,a.suspendedLanes|=l,a.pingedLanes&=~l,p&&(a.warmLanes|=l),p=a.expirationTimes;for(var T=l;0<T;){var x=31-He(T),M=1<<x;p[x]=-1,T&=~M}h!==0&&Pi(a,h,l)}function yf(){return(zt&6)===0?(nd(0),!1):!0}function u0(){if(Ot!==null){if(Wt===0)var a=Ot.return;else a=Ot,W=O=null,Ag(a),su=null,$c=0,a=Ot;for(;a!==null;)j_(a.alternate,a),a=a.return;Ot=null}}function fu(a,l){var h=a.timeoutHandle;h!==-1&&(a.timeoutHandle=-1,LI(h)),h=a.cancelPendingCommit,h!==null&&(a.cancelPendingCommit=null,h()),oa=0,u0(),ai=a,Ot=h=Kn(a.current,null),Bt=l,Wt=0,hn=null,Ka=!1,cu=se(a,l),s0=!1,du=fn=n0=il=Ya=Li=0,Ys=id=null,r0=!1,(l&8)!==0&&(l|=l&32);var p=a.entangledLanes;if(p!==0)for(a=a.entanglements,p&=l;0<p;){var T=31-He(p),x=1<<T;l|=a[T],p&=~x}return aa=l,Zl(),h}function dx(a,l){_t=null,Y.H=Yc,l===iu||l===qh?(l=Db(),Wt=3):l===fg?(l=Db(),Wt=4):Wt=l===jg?8:l!==null&&typeof l=="object"&&typeof l.then=="function"?6:1,hn=l,Ot===null&&(Li=1,af(a,js(l,a.current)))}function hx(){var a=cn.current;return a===null?!0:(Bt&4194048)===Bt?Ln===null:(Bt&62914560)===Bt||(Bt&536870912)!==0?a===Ln:!1}function fx(){var a=Y.H;return Y.H=Yc,a===null?Yc:a}function px(){var a=Y.A;return Y.A=oI,a}function vf(){Li=4,Ka||(Bt&4194048)!==Bt&&cn.current!==null||(cu=!0),(Ya&134217727)===0&&(il&134217727)===0||ai===null||Qa(ai,Bt,fn,!1)}function c0(a,l,h){var p=zt;zt|=2;var T=fx(),x=px();(ai!==a||Bt!==l)&&(gf=null,fu(a,l)),l=!1;var M=Li;e:do try{if(Wt!==0&&Ot!==null){var q=Ot,ce=hn;switch(Wt){case 8:u0(),M=6;break e;case 3:case 2:case 9:case 6:cn.current===null&&(l=!0);var _e=Wt;if(Wt=0,hn=null,pu(a,q,ce,_e),h&&cu){M=0;break e}break;default:_e=Wt,Wt=0,hn=null,pu(a,q,ce,_e)}}cI(),M=Li;break}catch(Oe){dx(a,Oe)}while(!0);return l&&a.shellSuspendCounter++,W=O=null,zt=p,Y.H=T,Y.A=x,Ot===null&&(ai=null,Bt=0,Zl()),M}function cI(){for(;Ot!==null;)mx(Ot)}function dI(a,l){var h=zt;zt|=2;var p=fx(),T=px();ai!==a||Bt!==l?(gf=null,mf=Ye()+500,fu(a,l)):cu=se(a,l);e:do try{if(Wt!==0&&Ot!==null){l=Ot;var x=hn;t:switch(Wt){case 1:Wt=0,hn=null,pu(a,l,x,1);break;case 2:case 9:if(Ab(x)){Wt=0,hn=null,gx(l);break}l=function(){Wt!==2&&Wt!==9||ai!==a||(Wt=7),Tr(a)},x.then(l,l);break e;case 3:Wt=7;break e;case 4:Wt=5;break e;case 7:Ab(x)?(Wt=0,hn=null,gx(l)):(Wt=0,hn=null,pu(a,l,x,7));break;case 5:var M=null;switch(Ot.tag){case 26:M=Ot.memoizedState;case 5:case 27:var q=Ot;if(M?tS(M):q.stateNode.complete){Wt=0,hn=null;var ce=q.sibling;if(ce!==null)Ot=ce;else{var _e=q.return;_e!==null?(Ot=_e,Tf(_e)):Ot=null}break t}}Wt=0,hn=null,pu(a,l,x,5);break;case 6:Wt=0,hn=null,pu(a,l,x,6);break;case 8:u0(),Li=6;break e;default:throw Error(i(462))}}hI();break}catch(Oe){dx(a,Oe)}while(!0);return W=O=null,Y.H=p,Y.A=T,zt=h,Ot!==null?0:(ai=null,Bt=0,Zl(),Li)}function hI(){for(;Ot!==null&&!Ue();)mx(Ot)}function mx(a){var l=U_(a.alternate,a,aa);a.memoizedProps=a.pendingProps,l===null?Tf(a):Ot=l}function gx(a){var l=a,h=l.alternate;switch(l.tag){case 15:case 0:l=O_(h,l,l.pendingProps,l.type,void 0,Bt);break;case 11:l=O_(h,l,l.pendingProps,l.type.render,l.ref,Bt);break;case 5:Ag(l);default:j_(h,l),l=Ot=jh(l,aa),l=U_(h,l,aa)}a.memoizedProps=a.pendingProps,l===null?Tf(a):Ot=l}function pu(a,l,h,p){W=O=null,Ag(l),su=null,$c=0;var T=l.return;try{if(eI(a,T,l,h,Bt)){Li=1,af(a,js(h,a.current)),Ot=null;return}}catch(x){if(T!==null)throw Ot=T,x;Li=1,af(a,js(h,a.current)),Ot=null;return}l.flags&32768?(Rt||p===1?a=!0:cu||(Bt&536870912)!==0?a=!1:(Ka=a=!0,(p===2||p===9||p===3||p===6)&&(p=cn.current,p!==null&&p.tag===13&&(p.flags|=16384))),yx(l,a)):Tf(l)}function Tf(a){var l=a;do{if((l.flags&32768)!==0){yx(l,Ka);return}a=l.return;var h=sI(l.alternate,l,aa);if(h!==null){Ot=h;return}if(l=l.sibling,l!==null){Ot=l;return}Ot=l=a}while(l!==null);Li===0&&(Li=5)}function yx(a,l){do{var h=nI(a.alternate,a);if(h!==null){h.flags&=32767,Ot=h;return}if(h=a.return,h!==null&&(h.flags|=32768,h.subtreeFlags=0,h.deletions=null),!l&&(a=a.sibling,a!==null)){Ot=a;return}Ot=a=h}while(a!==null);Li=6,Ot=null}function vx(a,l,h,p,T,x,M,q,ce){a.cancelPendingCommit=null;do bf();while(Qi!==0);if((zt&6)!==0)throw Error(i(327));if(l!==null){if(l===a.current)throw Error(i(177));if(x=l.lanes|l.childLanes,x|=Oc,xi(a,h,x,M,q,ce),a===ai&&(Ot=ai=null,Bt=0),hu=l,Xa=a,oa=h,a0=x,o0=T,ox=p,(l.subtreeFlags&10256)!==0||(l.flags&10256)!==0?(a.callbackNode=null,a.callbackPriority=0,gI(fi,function(){return Sx(),null})):(a.callbackNode=null,a.callbackPriority=0),p=(l.flags&13878)!==0,(l.subtreeFlags&13878)!==0||p){p=Y.T,Y.T=null,T=Z.p,Z.p=2,M=zt,zt|=4;try{rI(a,l,h)}finally{zt=M,Z.p=T,Y.T=p}}Qi=1,Tx(),bx(),_x()}}function Tx(){if(Qi===1){Qi=0;var a=Xa,l=hu,h=(l.flags&13878)!==0;if((l.subtreeFlags&13878)!==0||h){h=Y.T,Y.T=null;var p=Z.p;Z.p=2;var T=zt;zt|=4;try{J_(l,a);var x=x0,M=Xl(a.containerInfo),q=x.focusedElem,ce=x.selectionRange;if(M!==q&&q&&q.ownerDocument&&Yr(q.ownerDocument.documentElement,q)){if(ce!==null&&Dc(q)){var _e=ce.start,Oe=ce.end;if(Oe===void 0&&(Oe=_e),"selectionStart"in q)q.selectionStart=_e,q.selectionEnd=Math.min(Oe,q.value.length);else{var Ne=q.ownerDocument||document,De=Ne&&Ne.defaultView||window;if(De.getSelection){var Ie=De.getSelection(),tt=q.textContent.length,ct=Math.min(ce.start,tt),ii=ce.end===void 0?ct:Math.min(ce.end,tt);!Ie.extend&&ct>ii&&(M=ii,ii=ct,ct=M);var me=yi(q,ct),he=yi(q,ii);if(me&&he&&(Ie.rangeCount!==1||Ie.anchorNode!==me.node||Ie.anchorOffset!==me.offset||Ie.focusNode!==he.node||Ie.focusOffset!==he.offset)){var be=Ne.createRange();be.setStart(me.node,me.offset),Ie.removeAllRanges(),ct>ii?(Ie.addRange(be),Ie.extend(he.node,he.offset)):(be.setEnd(he.node,he.offset),Ie.addRange(be))}}}}for(Ne=[],Ie=q;Ie=Ie.parentNode;)Ie.nodeType===1&&Ne.push({element:Ie,left:Ie.scrollLeft,top:Ie.scrollTop});for(typeof q.focus=="function"&&q.focus(),q=0;q<Ne.length;q++){var Me=Ne[q];Me.element.scrollLeft=Me.left,Me.element.scrollTop=Me.top}}Rf=!!_0,x0=_0=null}finally{zt=T,Z.p=p,Y.T=h}}a.current=l,Qi=2}}function bx(){if(Qi===2){Qi=0;var a=Xa,l=hu,h=(l.flags&8772)!==0;if((l.subtreeFlags&8772)!==0||h){h=Y.T,Y.T=null;var p=Z.p;Z.p=2;var T=zt;zt|=4;try{Y_(a,l.alternate,l)}finally{zt=T,Z.p=p,Y.T=h}}Qi=3}}function _x(){if(Qi===4||Qi===3){Qi=0,Ke();var a=Xa,l=hu,h=oa,p=ox;(l.subtreeFlags&10256)!==0||(l.flags&10256)!==0?Qi=5:(Qi=0,hu=Xa=null,xx(a,a.pendingLanes));var T=a.pendingLanes;if(T===0&&(Wa=null),ci(h),l=l.stateNode,ye&&typeof ye.onCommitFiberRoot=="function")try{ye.onCommitFiberRoot(de,l,void 0,(l.current.flags&128)===128)}catch{}if(p!==null){l=Y.T,T=Z.p,Z.p=2,Y.T=null;try{for(var x=a.onRecoverableError,M=0;M<p.length;M++){var q=p[M];x(q.value,{componentStack:q.stack})}}finally{Y.T=l,Z.p=T}}(oa&3)!==0&&bf(),Tr(a),T=a.pendingLanes,(h&261930)!==0&&(T&42)!==0?a===l0?sd++:(sd=0,l0=a):sd=0,nd(0)}}function xx(a,l){(a.pooledCacheLanes&=l)===0&&(l=a.pooledCache,l!=null&&(a.pooledCache=null,Yn(l)))}function bf(){return Tx(),bx(),_x(),Sx()}function Sx(){if(Qi!==5)return!1;var a=Xa,l=a0;a0=0;var h=ci(oa),p=Y.T,T=Z.p;try{Z.p=32>h?32:h,Y.T=null,h=o0,o0=null;var x=Xa,M=oa;if(Qi=0,hu=Xa=null,oa=0,(zt&6)!==0)throw Error(i(331));var q=zt;if(zt|=4,nx(x.current),tx(x,x.current,M,h),zt=q,nd(0,!1),ye&&typeof ye.onPostCommitFiberRoot=="function")try{ye.onPostCommitFiberRoot(de,x)}catch{}return!0}finally{Z.p=T,Y.T=p,xx(a,l)}}function Ex(a,l,h){l=js(h,l),l=$g(a.stateNode,l,2),a=Ga(a,l,2),a!==null&&(Mt(a,2),Tr(a))}function Xt(a,l,h){if(a.tag===3)Ex(a,a,h);else for(;l!==null;){if(l.tag===3){Ex(l,a,h);break}else if(l.tag===1){var p=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof p.componentDidCatch=="function"&&(Wa===null||!Wa.has(p))){a=js(h,a),h=A_(2),p=Ga(l,h,2),p!==null&&(C_(h,p,l,a),Mt(p,2),Tr(p));break}}l=l.return}}function d0(a,l,h){var p=a.pingCache;if(p===null){p=a.pingCache=new lI;var T=new Set;p.set(l,T)}else T=p.get(l),T===void 0&&(T=new Set,p.set(l,T));T.has(h)||(s0=!0,T.add(h),a=fI.bind(null,a,l,h),l.then(a,a))}function fI(a,l,h){var p=a.pingCache;p!==null&&p.delete(l),a.pingedLanes|=a.suspendedLanes&h,a.warmLanes&=~h,ai===a&&(Bt&h)===h&&(Li===4||Li===3&&(Bt&62914560)===Bt&&300>Ye()-pf?(zt&2)===0&&fu(a,0):n0|=h,du===Bt&&(du=0)),Tr(a)}function Ax(a,l){l===0&&(l=Ge()),a=Xr(a,l),a!==null&&(Mt(a,l),Tr(a))}function pI(a){var l=a.memoizedState,h=0;l!==null&&(h=l.retryLane),Ax(a,h)}function mI(a,l){var h=0;switch(a.tag){case 31:case 13:var p=a.stateNode,T=a.memoizedState;T!==null&&(h=T.retryLane);break;case 19:p=a.stateNode;break;case 22:p=a.stateNode._retryCache;break;default:throw Error(i(314))}p!==null&&p.delete(l),Ax(a,h)}function gI(a,l){return we(a,l)}var _f=null,mu=null,h0=!1,xf=!1,f0=!1,Za=0;function Tr(a){a!==mu&&a.next===null&&(mu===null?_f=mu=a:mu=mu.next=a),xf=!0,h0||(h0=!0,vI())}function nd(a,l){if(!f0&&xf){f0=!0;do for(var h=!1,p=_f;p!==null;){if(a!==0){var T=p.pendingLanes;if(T===0)var x=0;else{var M=p.suspendedLanes,q=p.pingedLanes;x=(1<<31-He(42|a)+1)-1,x&=T&~(M&~q),x=x&201326741?x&201326741|1:x?x|2:0}x!==0&&(h=!0,Lx(p,x))}else x=Bt,x=K(p,p===ai?x:0,p.cancelPendingCommit!==null||p.timeoutHandle!==-1),(x&3)===0||se(p,x)||(h=!0,Lx(p,x));p=p.next}while(h);f0=!1}}function yI(){Cx()}function Cx(){xf=h0=!1;var a=0;Za!==0&&wI()&&(a=Za);for(var l=Ye(),h=null,p=_f;p!==null;){var T=p.next,x=Dx(p,l);x===0?(p.next=null,h===null?_f=T:h.next=T,T===null&&(mu=h)):(h=p,(a!==0||(x&3)!==0)&&(xf=!0)),p=T}Qi!==0&&Qi!==5||nd(a),Za!==0&&(Za=0)}function Dx(a,l){for(var h=a.suspendedLanes,p=a.pingedLanes,T=a.expirationTimes,x=a.pendingLanes&-62914561;0<x;){var M=31-He(x),q=1<<M,ce=T[M];ce===-1?((q&h)===0||(q&p)!==0)&&(T[M]=Ce(q,l)):ce<=l&&(a.expiredLanes|=q),x&=~q}if(l=ai,h=Bt,h=K(a,a===l?h:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),p=a.callbackNode,h===0||a===l&&(Wt===2||Wt===9)||a.cancelPendingCommit!==null)return p!==null&&p!==null&&Fe(p),a.callbackNode=null,a.callbackPriority=0;if((h&3)===0||se(a,h)){if(l=h&-h,l===a.callbackPriority)return l;switch(p!==null&&Fe(p),ci(h)){case 2:case 8:h=$t;break;case 32:h=fi;break;case 268435456:h=ts;break;default:h=fi}return p=wx.bind(null,a),h=we(h,p),a.callbackPriority=l,a.callbackNode=h,l}return p!==null&&p!==null&&Fe(p),a.callbackPriority=2,a.callbackNode=null,2}function wx(a,l){if(Qi!==0&&Qi!==5)return a.callbackNode=null,a.callbackPriority=0,null;var h=a.callbackNode;if(bf()&&a.callbackNode!==h)return null;var p=Bt;return p=K(a,a===ai?p:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),p===0?null:(ux(a,p,l),Dx(a,Ye()),a.callbackNode!=null&&a.callbackNode===h?wx.bind(null,a):null)}function Lx(a,l){if(bf())return null;ux(a,l,!0)}function vI(){II(function(){(zt&6)!==0?we(Lt,yI):Cx()})}function p0(){if(Za===0){var a=wn;a===0&&(a=Wi,Wi<<=1,(Wi&261888)===0&&(Wi=256)),Za=a}return Za}function Ix(a){return a==null||typeof a=="symbol"||typeof a=="boolean"?null:typeof a=="function"?a:Bl(""+a)}function kx(a,l){var h=l.ownerDocument.createElement("input");return h.name=l.name,h.value=l.value,a.id&&h.setAttribute("form",a.id),l.parentNode.insertBefore(h,l),a=new FormData(a),h.parentNode.removeChild(h),a}function TI(a,l,h,p,T){if(l==="submit"&&h&&h.stateNode===T){var x=Ix((T[Nt]||null).action),M=p.submitter;M&&(l=(l=M[Nt]||null)?Ix(l.formAction):M.getAttribute("formAction"),l!==null&&(x=l,M=null));var q=new Gl("action","action",null,p,T);a.push({event:q,listeners:[{instance:null,listener:function(){if(p.defaultPrevented){if(Za!==0){var ce=M?kx(T,M):new FormData(T);Pg(h,{pending:!0,data:ce,method:T.method,action:x},null,ce)}}else typeof x=="function"&&(q.preventDefault(),ce=M?kx(T,M):new FormData(T),Pg(h,{pending:!0,data:ce,method:T.method,action:x},x,ce))},currentTarget:T}]})}}for(var m0=0;m0<Rc.length;m0++){var g0=Rc[m0],bI=g0.toLowerCase(),_I=g0[0].toUpperCase()+g0.slice(1);ln(bI,"on"+_I)}ln(Mh,"onAnimationEnd"),ln(Pa,"onAnimationIteration"),ln(Nh,"onAnimationStart"),ln("dblclick","onDoubleClick"),ln("focusin","onFocus"),ln("focusout","onBlur"),ln(Bh,"onTransitionRun"),ln(Fh,"onTransitionStart"),ln(cg,"onTransitionCancel"),ln(Uh,"onTransitionEnd"),Gr("onMouseEnter",["mouseout","mouseover"]),Gr("onMouseLeave",["mouseout","mouseover"]),Gr("onPointerEnter",["pointerout","pointerover"]),Gr("onPointerLeave",["pointerout","pointerover"]),Gn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Gn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Gn("onBeforeInput",["compositionend","keypress","textInput","paste"]),Gn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Gn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Gn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var rd="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),xI=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(rd));function Rx(a,l){l=(l&4)!==0;for(var h=0;h<a.length;h++){var p=a[h],T=p.event;p=p.listeners;e:{var x=void 0;if(l)for(var M=p.length-1;0<=M;M--){var q=p[M],ce=q.instance,_e=q.currentTarget;if(q=q.listener,ce!==x&&T.isPropagationStopped())break e;x=q,T.currentTarget=_e;try{x(T)}catch(Oe){Ma(Oe)}T.currentTarget=null,x=ce}else for(M=0;M<p.length;M++){if(q=p[M],ce=q.instance,_e=q.currentTarget,q=q.listener,ce!==x&&T.isPropagationStopped())break e;x=q,T.currentTarget=_e;try{x(T)}catch(Oe){Ma(Oe)}T.currentTarget=null,x=ce}}}}function Pt(a,l){var h=l[Cn];h===void 0&&(h=l[Cn]=new Set);var p=a+"__bubble";h.has(p)||(Ox(l,a,2,!1),h.add(p))}function y0(a,l,h){var p=0;l&&(p|=4),Ox(h,a,p,l)}var Sf="_reactListening"+Math.random().toString(36).slice(2);function v0(a){if(!a[Sf]){a[Sf]=!0,pc.forEach(function(h){h!=="selectionchange"&&(xI.has(h)||y0(h,!1,a),y0(h,!0,a))});var l=a.nodeType===9?a:a.ownerDocument;l===null||l[Sf]||(l[Sf]=!0,y0("selectionchange",!1,l))}}function Ox(a,l,h,p){switch(lS(l)){case 2:var T=XI;break;case 8:T=QI;break;default:T=O0}h=T.bind(null,l,h,a),T=void 0,!$l||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(T=!0),p?T!==void 0?a.addEventListener(l,h,{capture:!0,passive:T}):a.addEventListener(l,h,!0):T!==void 0?a.addEventListener(l,h,{passive:T}):a.addEventListener(l,h,!1)}function T0(a,l,h,p,T){var x=p;if((l&1)===0&&(l&2)===0&&p!==null)e:for(;;){if(p===null)return;var M=p.tag;if(M===3||M===4){var q=p.stateNode.containerInfo;if(q===T)break;if(M===4)for(M=p.return;M!==null;){var ce=M.tag;if((ce===3||ce===4)&&M.stateNode.containerInfo===T)return;M=M.return}for(;q!==null;){if(M=Hr(q),M===null)return;if(ce=M.tag,ce===5||ce===6||ce===26||ce===27){p=x=M;continue e}q=q.parentNode}}p=p.return}yh(function(){var _e=x,Oe=Fl(h),Ne=[];e:{var De=kc.get(a);if(De!==void 0){var Ie=Gl,tt=a;switch(a){case"keypress":if(Po(h)===0)break e;case"keydown":case"keyup":Ie=Sh;break;case"focusin":tt="focus",Ie=Ca;break;case"focusout":tt="blur",Ie=Ca;break;case"beforeblur":case"afterblur":Ie=Ca;break;case"click":if(h.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ie=bh;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ie=Ym;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ie=Kr;break;case Mh:case Pa:case Nh:Ie=Bo;break;case Uh:Ie=Eh;break;case"scroll":case"scrollend":Ie=yc;break;case"wheel":Ie=Ch;break;case"copy":case"cut":case"paste":Ie=on;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ie=Da;break;case"toggle":case"beforetoggle":Ie=tg}var ct=(l&4)!==0,ii=!ct&&(a==="scroll"||a==="scrollend"),me=ct?De!==null?De+"Capture":null:De;ct=[];for(var he=_e,be;he!==null;){var Me=he;if(be=Me.stateNode,Me=Me.tag,Me!==5&&Me!==26&&Me!==27||be===null||me===null||(Me=ar(he,me),Me!=null&&ct.push(ad(he,Me,be))),ii)break;he=he.return}0<ct.length&&(De=new Ie(De,tt,null,h,Oe),Ne.push({event:De,listeners:ct}))}}if((l&7)===0){e:{if(De=a==="mouseover"||a==="pointerover",Ie=a==="mouseout"||a==="pointerout",De&&h!==Ea&&(tt=h.relatedTarget||h.fromElement)&&(Hr(tt)||tt[kt]))break e;if((Ie||De)&&(De=Oe.window===Oe?Oe:(De=Oe.ownerDocument)?De.defaultView||De.parentWindow:window,Ie?(tt=h.relatedTarget||h.toElement,Ie=_e,tt=tt?Hr(tt):null,tt!==null&&(ii=r(tt),ct=tt.tag,tt!==ii||ct!==5&&ct!==27&&ct!==6)&&(tt=null)):(Ie=null,tt=_e),Ie!==tt)){if(ct=bh,Me="onMouseLeave",me="onMouseEnter",he="mouse",(a==="pointerout"||a==="pointerover")&&(ct=Da,Me="onPointerLeave",me="onPointerEnter",he="pointer"),ii=Ie==null?De:Do(Ie),be=tt==null?De:Do(tt),De=new ct(Me,he+"leave",Ie,h,Oe),De.target=ii,De.relatedTarget=be,Me=null,Hr(Oe)===_e&&(ct=new ct(me,he+"enter",tt,h,Oe),ct.target=be,ct.relatedTarget=ii,Me=ct),ii=Me,Ie&&tt)t:{for(ct=SI,me=Ie,he=tt,be=0,Me=me;Me;Me=ct(Me))be++;Me=0;for(var ot=he;ot;ot=ct(ot))Me++;for(;0<be-Me;)me=ct(me),be--;for(;0<Me-be;)he=ct(he),Me--;for(;be--;){if(me===he||he!==null&&me===he.alternate){ct=me;break t}me=ct(me),he=ct(he)}ct=null}else ct=null;Ie!==null&&Px(Ne,De,Ie,ct,!1),tt!==null&&ii!==null&&Px(Ne,ii,tt,ct,!0)}}e:{if(De=_e?Do(_e):window,Ie=De.nodeName&&De.nodeName.toLowerCase(),Ie==="select"||Ie==="input"&&De.type==="file")var Gt=Sc;else if(xc(De))if(Ec)Gt=lg;else{Gt=og;var st=ag}else Ie=De.nodeName,!Ie||Ie.toLowerCase()!=="input"||De.type!=="checkbox"&&De.type!=="radio"?_e&&Nl(_e.elementType)&&(Gt=Sc):Gt=Ph;if(Gt&&(Gt=Gt(a,_e))){kh(Ne,Gt,h,Oe);break e}st&&st(a,De,_e),a==="focusout"&&_e&&De.type==="number"&&_e.memoizedProps.value!=null&&Io(De,"number",De.value)}switch(st=_e?Do(_e):window,a){case"focusin":(xc(st)||st.contentEditable==="true")&&(Ra=st,wc=_e,Oa=null);break;case"focusout":Oa=wc=Ra=null;break;case"mousedown":Ql=!0;break;case"contextmenu":case"mouseup":case"dragend":Ql=!1,Lc(Ne,h,Oe);break;case"selectionchange":if(ug)break;case"keydown":case"keyup":Lc(Ne,h,Oe)}var St;if(wa)e:{switch(a){case"compositionstart":var Ft="onCompositionStart";break e;case"compositionend":Ft="onCompositionEnd";break e;case"compositionupdate":Ft="onCompositionUpdate";break e}Ft=void 0}else La?Wl(a,h)&&(Ft="onCompositionEnd"):a==="keydown"&&h.keyCode===229&&(Ft="onCompositionStart");Ft&&(wh&&h.locale!=="ko"&&(La||Ft!=="onCompositionStart"?Ft==="onCompositionEnd"&&La&&(St=vh()):(or=Oe,jl="value"in or?or.value:or.textContent,La=!0)),st=Ef(_e,Ft),0<st.length&&(Ft=new Fo(Ft,a,null,h,Oe),Ne.push({event:Ft,listeners:st}),St?Ft.data=St:(St=Ih(h),St!==null&&(Ft.data=St)))),(St=Dh?sg(a,h):_c(a,h))&&(Ft=Ef(_e,"onBeforeInput"),0<Ft.length&&(st=new Fo("onBeforeInput","beforeinput",null,h,Oe),Ne.push({event:st,listeners:Ft}),st.data=St)),TI(Ne,a,_e,h,Oe)}Rx(Ne,l)})}function ad(a,l,h){return{instance:a,listener:l,currentTarget:h}}function Ef(a,l){for(var h=l+"Capture",p=[];a!==null;){var T=a,x=T.stateNode;if(T=T.tag,T!==5&&T!==26&&T!==27||x===null||(T=ar(a,h),T!=null&&p.unshift(ad(a,T,x)),T=ar(a,l),T!=null&&p.push(ad(a,T,x))),a.tag===3)return p;a=a.return}return[]}function SI(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5&&a.tag!==27);return a||null}function Px(a,l,h,p,T){for(var x=l._reactName,M=[];h!==null&&h!==p;){var q=h,ce=q.alternate,_e=q.stateNode;if(q=q.tag,ce!==null&&ce===p)break;q!==5&&q!==26&&q!==27||_e===null||(ce=_e,T?(_e=ar(h,x),_e!=null&&M.unshift(ad(h,_e,ce))):T||(_e=ar(h,x),_e!=null&&M.push(ad(h,_e,ce)))),h=h.return}M.length!==0&&a.push({event:l,listeners:M})}var EI=/\r\n?/g,AI=/\u0000|\uFFFD/g;function Mx(a){return(typeof a=="string"?a:""+a).replace(EI,`
`).replace(AI,"")}function Nx(a,l){return l=Mx(l),Mx(a)===l}function ti(a,l,h,p,T,x){switch(h){case"children":typeof p=="string"?l==="body"||l==="textarea"&&p===""||Dn(a,p):(typeof p=="number"||typeof p=="bigint")&&l!=="body"&&Dn(a,""+p);break;case"className":nr(a,"class",p);break;case"tabIndex":nr(a,"tabindex",p);break;case"dir":case"role":case"viewBox":case"width":case"height":nr(a,h,p);break;case"style":Ml(a,p,x);break;case"data":if(l!=="object"){nr(a,"data",p);break}case"src":case"href":if(p===""&&(l!=="a"||h!=="href")){a.removeAttribute(h);break}if(p==null||typeof p=="function"||typeof p=="symbol"||typeof p=="boolean"){a.removeAttribute(h);break}p=Bl(""+p),a.setAttribute(h,p);break;case"action":case"formAction":if(typeof p=="function"){a.setAttribute(h,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof x=="function"&&(h==="formAction"?(l!=="input"&&ti(a,l,"name",T.name,T,null),ti(a,l,"formEncType",T.formEncType,T,null),ti(a,l,"formMethod",T.formMethod,T,null),ti(a,l,"formTarget",T.formTarget,T,null)):(ti(a,l,"encType",T.encType,T,null),ti(a,l,"method",T.method,T,null),ti(a,l,"target",T.target,T,null)));if(p==null||typeof p=="symbol"||typeof p=="boolean"){a.removeAttribute(h);break}p=Bl(""+p),a.setAttribute(h,p);break;case"onClick":p!=null&&(a.onclick=Vn);break;case"onScroll":p!=null&&Pt("scroll",a);break;case"onScrollEnd":p!=null&&Pt("scrollend",a);break;case"dangerouslySetInnerHTML":if(p!=null){if(typeof p!="object"||!("__html"in p))throw Error(i(61));if(h=p.__html,h!=null){if(T.children!=null)throw Error(i(60));a.innerHTML=h}}break;case"multiple":a.multiple=p&&typeof p!="function"&&typeof p!="symbol";break;case"muted":a.muted=p&&typeof p!="function"&&typeof p!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(p==null||typeof p=="function"||typeof p=="boolean"||typeof p=="symbol"){a.removeAttribute("xlink:href");break}h=Bl(""+p),a.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",h);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":p!=null&&typeof p!="function"&&typeof p!="symbol"?a.setAttribute(h,""+p):a.removeAttribute(h);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":p&&typeof p!="function"&&typeof p!="symbol"?a.setAttribute(h,""):a.removeAttribute(h);break;case"capture":case"download":p===!0?a.setAttribute(h,""):p!==!1&&p!=null&&typeof p!="function"&&typeof p!="symbol"?a.setAttribute(h,p):a.removeAttribute(h);break;case"cols":case"rows":case"size":case"span":p!=null&&typeof p!="function"&&typeof p!="symbol"&&!isNaN(p)&&1<=p?a.setAttribute(h,p):a.removeAttribute(h);break;case"rowSpan":case"start":p==null||typeof p=="function"||typeof p=="symbol"||isNaN(p)?a.removeAttribute(h):a.setAttribute(h,p);break;case"popover":Pt("beforetoggle",a),Pt("toggle",a),Lo(a,"popover",p);break;case"xlinkActuate":Is(a,"http://www.w3.org/1999/xlink","xlink:actuate",p);break;case"xlinkArcrole":Is(a,"http://www.w3.org/1999/xlink","xlink:arcrole",p);break;case"xlinkRole":Is(a,"http://www.w3.org/1999/xlink","xlink:role",p);break;case"xlinkShow":Is(a,"http://www.w3.org/1999/xlink","xlink:show",p);break;case"xlinkTitle":Is(a,"http://www.w3.org/1999/xlink","xlink:title",p);break;case"xlinkType":Is(a,"http://www.w3.org/1999/xlink","xlink:type",p);break;case"xmlBase":Is(a,"http://www.w3.org/XML/1998/namespace","xml:base",p);break;case"xmlLang":Is(a,"http://www.w3.org/XML/1998/namespace","xml:lang",p);break;case"xmlSpace":Is(a,"http://www.w3.org/XML/1998/namespace","xml:space",p);break;case"is":Lo(a,"is",p);break;case"innerText":case"textContent":break;default:(!(2<h.length)||h[0]!=="o"&&h[0]!=="O"||h[1]!=="n"&&h[1]!=="N")&&(h=gc.get(h)||h,Lo(a,h,p))}}function b0(a,l,h,p,T,x){switch(h){case"style":Ml(a,p,x);break;case"dangerouslySetInnerHTML":if(p!=null){if(typeof p!="object"||!("__html"in p))throw Error(i(61));if(h=p.__html,h!=null){if(T.children!=null)throw Error(i(60));a.innerHTML=h}}break;case"children":typeof p=="string"?Dn(a,p):(typeof p=="number"||typeof p=="bigint")&&Dn(a,""+p);break;case"onScroll":p!=null&&Pt("scroll",a);break;case"onScrollEnd":p!=null&&Pt("scrollend",a);break;case"onClick":p!=null&&(a.onclick=Vn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Ll.hasOwnProperty(h))e:{if(h[0]==="o"&&h[1]==="n"&&(T=h.endsWith("Capture"),l=h.slice(2,T?h.length-7:void 0),x=a[Nt]||null,x=x!=null?x[h]:null,typeof x=="function"&&a.removeEventListener(l,x,T),typeof p=="function")){typeof x!="function"&&x!==null&&(h in a?a[h]=null:a.hasAttribute(h)&&a.removeAttribute(h)),a.addEventListener(l,p,T);break e}h in a?a[h]=p:p===!0?a.setAttribute(h,""):Lo(a,h,p)}}}function fs(a,l,h){switch(l){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Pt("error",a),Pt("load",a);var p=!1,T=!1,x;for(x in h)if(h.hasOwnProperty(x)){var M=h[x];if(M!=null)switch(x){case"src":p=!0;break;case"srcSet":T=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,l));default:ti(a,l,x,M,h,null)}}T&&ti(a,l,"srcSet",h.srcSet,h,null),p&&ti(a,l,"src",h.src,h,null);return;case"input":Pt("invalid",a);var q=x=M=T=null,ce=null,_e=null;for(p in h)if(h.hasOwnProperty(p)){var Oe=h[p];if(Oe!=null)switch(p){case"name":T=Oe;break;case"type":M=Oe;break;case"checked":ce=Oe;break;case"defaultChecked":_e=Oe;break;case"value":x=Oe;break;case"defaultValue":q=Oe;break;case"children":case"dangerouslySetInnerHTML":if(Oe!=null)throw Error(i(137,l));break;default:ti(a,l,p,Oe,h,null)}}Ol(a,x,q,ce,_e,M,T,!1);return;case"select":Pt("invalid",a),p=M=x=null;for(T in h)if(h.hasOwnProperty(T)&&(q=h[T],q!=null))switch(T){case"value":x=q;break;case"defaultValue":M=q;break;case"multiple":p=q;default:ti(a,l,T,q,h,null)}l=x,h=M,a.multiple=!!p,l!=null?ss(a,!!p,l,!1):h!=null&&ss(a,!!p,h,!0);return;case"textarea":Pt("invalid",a),x=T=p=null;for(M in h)if(h.hasOwnProperty(M)&&(q=h[M],q!=null))switch(M){case"value":p=q;break;case"defaultValue":T=q;break;case"children":x=q;break;case"dangerouslySetInnerHTML":if(q!=null)throw Error(i(91));break;default:ti(a,l,M,q,h,null)}ko(a,p,T,x);return;case"option":for(ce in h)h.hasOwnProperty(ce)&&(p=h[ce],p!=null)&&(ce==="selected"?a.selected=p&&typeof p!="function"&&typeof p!="symbol":ti(a,l,ce,p,h,null));return;case"dialog":Pt("beforetoggle",a),Pt("toggle",a),Pt("cancel",a),Pt("close",a);break;case"iframe":case"object":Pt("load",a);break;case"video":case"audio":for(p=0;p<rd.length;p++)Pt(rd[p],a);break;case"image":Pt("error",a),Pt("load",a);break;case"details":Pt("toggle",a);break;case"embed":case"source":case"link":Pt("error",a),Pt("load",a);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(_e in h)if(h.hasOwnProperty(_e)&&(p=h[_e],p!=null))switch(_e){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,l));default:ti(a,l,_e,p,h,null)}return;default:if(Nl(l)){for(Oe in h)h.hasOwnProperty(Oe)&&(p=h[Oe],p!==void 0&&b0(a,l,Oe,p,h,void 0));return}}for(q in h)h.hasOwnProperty(q)&&(p=h[q],p!=null&&ti(a,l,q,p,h,null))}function CI(a,l,h,p){switch(l){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var T=null,x=null,M=null,q=null,ce=null,_e=null,Oe=null;for(Ie in h){var Ne=h[Ie];if(h.hasOwnProperty(Ie)&&Ne!=null)switch(Ie){case"checked":break;case"value":break;case"defaultValue":ce=Ne;default:p.hasOwnProperty(Ie)||ti(a,l,Ie,null,p,Ne)}}for(var De in p){var Ie=p[De];if(Ne=h[De],p.hasOwnProperty(De)&&(Ie!=null||Ne!=null))switch(De){case"type":x=Ie;break;case"name":T=Ie;break;case"checked":_e=Ie;break;case"defaultChecked":Oe=Ie;break;case"value":M=Ie;break;case"defaultValue":q=Ie;break;case"children":case"dangerouslySetInnerHTML":if(Ie!=null)throw Error(i(137,l));break;default:Ie!==Ne&&ti(a,l,De,Ie,p,Ne)}}mc(a,M,q,ce,_e,Oe,x,T);return;case"select":Ie=M=q=De=null;for(x in h)if(ce=h[x],h.hasOwnProperty(x)&&ce!=null)switch(x){case"value":break;case"multiple":Ie=ce;default:p.hasOwnProperty(x)||ti(a,l,x,null,p,ce)}for(T in p)if(x=p[T],ce=h[T],p.hasOwnProperty(T)&&(x!=null||ce!=null))switch(T){case"value":De=x;break;case"defaultValue":q=x;break;case"multiple":M=x;default:x!==ce&&ti(a,l,T,x,p,ce)}l=q,h=M,p=Ie,De!=null?ss(a,!!h,De,!1):!!p!=!!h&&(l!=null?ss(a,!!h,l,!0):ss(a,!!h,h?[]:"",!1));return;case"textarea":Ie=De=null;for(q in h)if(T=h[q],h.hasOwnProperty(q)&&T!=null&&!p.hasOwnProperty(q))switch(q){case"value":break;case"children":break;default:ti(a,l,q,null,p,T)}for(M in p)if(T=p[M],x=h[M],p.hasOwnProperty(M)&&(T!=null||x!=null))switch(M){case"value":De=T;break;case"defaultValue":Ie=T;break;case"children":break;case"dangerouslySetInnerHTML":if(T!=null)throw Error(i(91));break;default:T!==x&&ti(a,l,M,T,p,x)}mh(a,De,Ie);return;case"option":for(var tt in h)De=h[tt],h.hasOwnProperty(tt)&&De!=null&&!p.hasOwnProperty(tt)&&(tt==="selected"?a.selected=!1:ti(a,l,tt,null,p,De));for(ce in p)De=p[ce],Ie=h[ce],p.hasOwnProperty(ce)&&De!==Ie&&(De!=null||Ie!=null)&&(ce==="selected"?a.selected=De&&typeof De!="function"&&typeof De!="symbol":ti(a,l,ce,De,p,Ie));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var ct in h)De=h[ct],h.hasOwnProperty(ct)&&De!=null&&!p.hasOwnProperty(ct)&&ti(a,l,ct,null,p,De);for(_e in p)if(De=p[_e],Ie=h[_e],p.hasOwnProperty(_e)&&De!==Ie&&(De!=null||Ie!=null))switch(_e){case"children":case"dangerouslySetInnerHTML":if(De!=null)throw Error(i(137,l));break;default:ti(a,l,_e,De,p,Ie)}return;default:if(Nl(l)){for(var ii in h)De=h[ii],h.hasOwnProperty(ii)&&De!==void 0&&!p.hasOwnProperty(ii)&&b0(a,l,ii,void 0,p,De);for(Oe in p)De=p[Oe],Ie=h[Oe],!p.hasOwnProperty(Oe)||De===Ie||De===void 0&&Ie===void 0||b0(a,l,Oe,De,p,Ie);return}}for(var me in h)De=h[me],h.hasOwnProperty(me)&&De!=null&&!p.hasOwnProperty(me)&&ti(a,l,me,null,p,De);for(Ne in p)De=p[Ne],Ie=h[Ne],!p.hasOwnProperty(Ne)||De===Ie||De==null&&Ie==null||ti(a,l,Ne,De,p,Ie)}function Bx(a){switch(a){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function DI(){if(typeof performance.getEntriesByType=="function"){for(var a=0,l=0,h=performance.getEntriesByType("resource"),p=0;p<h.length;p++){var T=h[p],x=T.transferSize,M=T.initiatorType,q=T.duration;if(x&&q&&Bx(M)){for(M=0,q=T.responseEnd,p+=1;p<h.length;p++){var ce=h[p],_e=ce.startTime;if(_e>q)break;var Oe=ce.transferSize,Ne=ce.initiatorType;Oe&&Bx(Ne)&&(ce=ce.responseEnd,M+=Oe*(ce<q?1:(q-_e)/(ce-_e)))}if(--p,l+=8*(x+M)/(T.duration/1e3),a++,10<a)break}}if(0<a)return l/a/1e6}return navigator.connection&&(a=navigator.connection.downlink,typeof a=="number")?a:5}var _0=null,x0=null;function Af(a){return a.nodeType===9?a:a.ownerDocument}function Fx(a){switch(a){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Ux(a,l){if(a===0)switch(l){case"svg":return 1;case"math":return 2;default:return 0}return a===1&&l==="foreignObject"?0:a}function S0(a,l){return a==="textarea"||a==="noscript"||typeof l.children=="string"||typeof l.children=="number"||typeof l.children=="bigint"||typeof l.dangerouslySetInnerHTML=="object"&&l.dangerouslySetInnerHTML!==null&&l.dangerouslySetInnerHTML.__html!=null}var E0=null;function wI(){var a=window.event;return a&&a.type==="popstate"?a===E0?!1:(E0=a,!0):(E0=null,!1)}var $x=typeof setTimeout=="function"?setTimeout:void 0,LI=typeof clearTimeout=="function"?clearTimeout:void 0,jx=typeof Promise=="function"?Promise:void 0,II=typeof queueMicrotask=="function"?queueMicrotask:typeof jx<"u"?function(a){return jx.resolve(null).then(a).catch(kI)}:$x;function kI(a){setTimeout(function(){throw a})}function Ja(a){return a==="head"}function Hx(a,l){var h=l,p=0;do{var T=h.nextSibling;if(a.removeChild(h),T&&T.nodeType===8)if(h=T.data,h==="/$"||h==="/&"){if(p===0){a.removeChild(T),Tu(l);return}p--}else if(h==="$"||h==="$?"||h==="$~"||h==="$!"||h==="&")p++;else if(h==="html")od(a.ownerDocument.documentElement);else if(h==="head"){h=a.ownerDocument.head,od(h);for(var x=h.firstChild;x;){var M=x.nextSibling,q=x.nodeName;x[an]||q==="SCRIPT"||q==="STYLE"||q==="LINK"&&x.rel.toLowerCase()==="stylesheet"||h.removeChild(x),x=M}}else h==="body"&&od(a.ownerDocument.body);h=T}while(h);Tu(l)}function Gx(a,l){var h=a;a=0;do{var p=h.nextSibling;if(h.nodeType===1?l?(h._stashedDisplay=h.style.display,h.style.display="none"):(h.style.display=h._stashedDisplay||"",h.getAttribute("style")===""&&h.removeAttribute("style")):h.nodeType===3&&(l?(h._stashedText=h.nodeValue,h.nodeValue=""):h.nodeValue=h._stashedText||""),p&&p.nodeType===8)if(h=p.data,h==="/$"){if(a===0)break;a--}else h!=="$"&&h!=="$?"&&h!=="$~"&&h!=="$!"||a++;h=p}while(h)}function A0(a){var l=a.firstChild;for(l&&l.nodeType===10&&(l=l.nextSibling);l;){var h=l;switch(l=l.nextSibling,h.nodeName){case"HTML":case"HEAD":case"BODY":A0(h),Jt(h);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(h.rel.toLowerCase()==="stylesheet")continue}a.removeChild(h)}}function RI(a,l,h,p){for(;a.nodeType===1;){var T=h;if(a.nodeName.toLowerCase()!==l.toLowerCase()){if(!p&&(a.nodeName!=="INPUT"||a.type!=="hidden"))break}else if(p){if(!a[an])switch(l){case"meta":if(!a.hasAttribute("itemprop"))break;return a;case"link":if(x=a.getAttribute("rel"),x==="stylesheet"&&a.hasAttribute("data-precedence"))break;if(x!==T.rel||a.getAttribute("href")!==(T.href==null||T.href===""?null:T.href)||a.getAttribute("crossorigin")!==(T.crossOrigin==null?null:T.crossOrigin)||a.getAttribute("title")!==(T.title==null?null:T.title))break;return a;case"style":if(a.hasAttribute("data-precedence"))break;return a;case"script":if(x=a.getAttribute("src"),(x!==(T.src==null?null:T.src)||a.getAttribute("type")!==(T.type==null?null:T.type)||a.getAttribute("crossorigin")!==(T.crossOrigin==null?null:T.crossOrigin))&&x&&a.hasAttribute("async")&&!a.hasAttribute("itemprop"))break;return a;default:return a}}else if(l==="input"&&a.type==="hidden"){var x=T.name==null?null:""+T.name;if(T.type==="hidden"&&a.getAttribute("name")===x)return a}else return a;if(a=In(a.nextSibling),a===null)break}return null}function OI(a,l,h){if(l==="")return null;for(;a.nodeType!==3;)if((a.nodeType!==1||a.nodeName!=="INPUT"||a.type!=="hidden")&&!h||(a=In(a.nextSibling),a===null))return null;return a}function Vx(a,l){for(;a.nodeType!==8;)if((a.nodeType!==1||a.nodeName!=="INPUT"||a.type!=="hidden")&&!l||(a=In(a.nextSibling),a===null))return null;return a}function C0(a){return a.data==="$?"||a.data==="$~"}function D0(a){return a.data==="$!"||a.data==="$?"&&a.ownerDocument.readyState!=="loading"}function PI(a,l){var h=a.ownerDocument;if(a.data==="$~")a._reactRetry=l;else if(a.data!=="$?"||h.readyState!=="loading")l();else{var p=function(){l(),h.removeEventListener("DOMContentLoaded",p)};h.addEventListener("DOMContentLoaded",p),a._reactRetry=p}}function In(a){for(;a!=null;a=a.nextSibling){var l=a.nodeType;if(l===1||l===3)break;if(l===8){if(l=a.data,l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"||l==="F!"||l==="F")break;if(l==="/$"||l==="/&")return null}}return a}var w0=null;function qx(a){a=a.nextSibling;for(var l=0;a;){if(a.nodeType===8){var h=a.data;if(h==="/$"||h==="/&"){if(l===0)return In(a.nextSibling);l--}else h!=="$"&&h!=="$!"&&h!=="$?"&&h!=="$~"&&h!=="&"||l++}a=a.nextSibling}return null}function zx(a){a=a.previousSibling;for(var l=0;a;){if(a.nodeType===8){var h=a.data;if(h==="$"||h==="$!"||h==="$?"||h==="$~"||h==="&"){if(l===0)return a;l--}else h!=="/$"&&h!=="/&"||l++}a=a.previousSibling}return null}function Kx(a,l,h){switch(l=Af(h),a){case"html":if(a=l.documentElement,!a)throw Error(i(452));return a;case"head":if(a=l.head,!a)throw Error(i(453));return a;case"body":if(a=l.body,!a)throw Error(i(454));return a;default:throw Error(i(451))}}function od(a){for(var l=a.attributes;l.length;)a.removeAttributeNode(l[0]);Jt(a)}var kn=new Map,Yx=new Set;function Cf(a){return typeof a.getRootNode=="function"?a.getRootNode():a.nodeType===9?a:a.ownerDocument}var la=Z.d;Z.d={f:MI,r:NI,D:BI,C:FI,L:UI,m:$I,X:HI,S:jI,M:GI};function MI(){var a=la.f(),l=yf();return a||l}function NI(a){var l=Hn(a);l!==null&&l.tag===5&&l.type==="form"?d_(l):la.r(a)}var gu=typeof document>"u"?null:document;function Wx(a,l,h){var p=gu;if(p&&typeof l=="string"&&l){var T=cs(l);T='link[rel="'+a+'"][href="'+T+'"]',typeof h=="string"&&(T+='[crossorigin="'+h+'"]'),Yx.has(T)||(Yx.add(T),a={rel:a,crossOrigin:h,href:l},p.querySelector(T)===null&&(l=p.createElement("link"),fs(l,"link",a),Gi(l),p.head.appendChild(l)))}}function BI(a){la.D(a),Wx("dns-prefetch",a,null)}function FI(a,l){la.C(a,l),Wx("preconnect",a,l)}function UI(a,l,h){la.L(a,l,h);var p=gu;if(p&&a&&l){var T='link[rel="preload"][as="'+cs(l)+'"]';l==="image"&&h&&h.imageSrcSet?(T+='[imagesrcset="'+cs(h.imageSrcSet)+'"]',typeof h.imageSizes=="string"&&(T+='[imagesizes="'+cs(h.imageSizes)+'"]')):T+='[href="'+cs(a)+'"]';var x=T;switch(l){case"style":x=yu(a);break;case"script":x=vu(a)}kn.has(x)||(a=m({rel:"preload",href:l==="image"&&h&&h.imageSrcSet?void 0:a,as:l},h),kn.set(x,a),p.querySelector(T)!==null||l==="style"&&p.querySelector(ld(x))||l==="script"&&p.querySelector(ud(x))||(l=p.createElement("link"),fs(l,"link",a),Gi(l),p.head.appendChild(l)))}}function $I(a,l){la.m(a,l);var h=gu;if(h&&a){var p=l&&typeof l.as=="string"?l.as:"script",T='link[rel="modulepreload"][as="'+cs(p)+'"][href="'+cs(a)+'"]',x=T;switch(p){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":x=vu(a)}if(!kn.has(x)&&(a=m({rel:"modulepreload",href:a},l),kn.set(x,a),h.querySelector(T)===null)){switch(p){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(h.querySelector(ud(x)))return}p=h.createElement("link"),fs(p,"link",a),Gi(p),h.head.appendChild(p)}}}function jI(a,l,h){la.S(a,l,h);var p=gu;if(p&&a){var T=xa(p).hoistableStyles,x=yu(a);l=l||"default";var M=T.get(x);if(!M){var q={loading:0,preload:null};if(M=p.querySelector(ld(x)))q.loading=5;else{a=m({rel:"stylesheet",href:a,"data-precedence":l},h),(h=kn.get(x))&&L0(a,h);var ce=M=p.createElement("link");Gi(ce),fs(ce,"link",a),ce._p=new Promise(function(_e,Oe){ce.onload=_e,ce.onerror=Oe}),ce.addEventListener("load",function(){q.loading|=1}),ce.addEventListener("error",function(){q.loading|=2}),q.loading|=4,Df(M,l,p)}M={type:"stylesheet",instance:M,count:1,state:q},T.set(x,M)}}}function HI(a,l){la.X(a,l);var h=gu;if(h&&a){var p=xa(h).hoistableScripts,T=vu(a),x=p.get(T);x||(x=h.querySelector(ud(T)),x||(a=m({src:a,async:!0},l),(l=kn.get(T))&&I0(a,l),x=h.createElement("script"),Gi(x),fs(x,"link",a),h.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},p.set(T,x))}}function GI(a,l){la.M(a,l);var h=gu;if(h&&a){var p=xa(h).hoistableScripts,T=vu(a),x=p.get(T);x||(x=h.querySelector(ud(T)),x||(a=m({src:a,async:!0,type:"module"},l),(l=kn.get(T))&&I0(a,l),x=h.createElement("script"),Gi(x),fs(x,"link",a),h.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},p.set(T,x))}}function Xx(a,l,h,p){var T=(T=$e.current)?Cf(T):null;if(!T)throw Error(i(446));switch(a){case"meta":case"title":return null;case"style":return typeof h.precedence=="string"&&typeof h.href=="string"?(l=yu(h.href),h=xa(T).hoistableStyles,p=h.get(l),p||(p={type:"style",instance:null,count:0,state:null},h.set(l,p)),p):{type:"void",instance:null,count:0,state:null};case"link":if(h.rel==="stylesheet"&&typeof h.href=="string"&&typeof h.precedence=="string"){a=yu(h.href);var x=xa(T).hoistableStyles,M=x.get(a);if(M||(T=T.ownerDocument||T,M={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},x.set(a,M),(x=T.querySelector(ld(a)))&&!x._p&&(M.instance=x,M.state.loading=5),kn.has(a)||(h={rel:"preload",as:"style",href:h.href,crossOrigin:h.crossOrigin,integrity:h.integrity,media:h.media,hrefLang:h.hrefLang,referrerPolicy:h.referrerPolicy},kn.set(a,h),x||VI(T,a,h,M.state))),l&&p===null)throw Error(i(528,""));return M}if(l&&p!==null)throw Error(i(529,""));return null;case"script":return l=h.async,h=h.src,typeof h=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=vu(h),h=xa(T).hoistableScripts,p=h.get(l),p||(p={type:"script",instance:null,count:0,state:null},h.set(l,p)),p):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,a))}}function yu(a){return'href="'+cs(a)+'"'}function ld(a){return'link[rel="stylesheet"]['+a+"]"}function Qx(a){return m({},a,{"data-precedence":a.precedence,precedence:null})}function VI(a,l,h,p){a.querySelector('link[rel="preload"][as="style"]['+l+"]")?p.loading=1:(l=a.createElement("link"),p.preload=l,l.addEventListener("load",function(){return p.loading|=1}),l.addEventListener("error",function(){return p.loading|=2}),fs(l,"link",h),Gi(l),a.head.appendChild(l))}function vu(a){return'[src="'+cs(a)+'"]'}function ud(a){return"script[async]"+a}function Zx(a,l,h){if(l.count++,l.instance===null)switch(l.type){case"style":var p=a.querySelector('style[data-href~="'+cs(h.href)+'"]');if(p)return l.instance=p,Gi(p),p;var T=m({},h,{"data-href":h.href,"data-precedence":h.precedence,href:null,precedence:null});return p=(a.ownerDocument||a).createElement("style"),Gi(p),fs(p,"style",T),Df(p,h.precedence,a),l.instance=p;case"stylesheet":T=yu(h.href);var x=a.querySelector(ld(T));if(x)return l.state.loading|=4,l.instance=x,Gi(x),x;p=Qx(h),(T=kn.get(T))&&L0(p,T),x=(a.ownerDocument||a).createElement("link"),Gi(x);var M=x;return M._p=new Promise(function(q,ce){M.onload=q,M.onerror=ce}),fs(x,"link",p),l.state.loading|=4,Df(x,h.precedence,a),l.instance=x;case"script":return x=vu(h.src),(T=a.querySelector(ud(x)))?(l.instance=T,Gi(T),T):(p=h,(T=kn.get(x))&&(p=m({},h),I0(p,T)),a=a.ownerDocument||a,T=a.createElement("script"),Gi(T),fs(T,"link",p),a.head.appendChild(T),l.instance=T);case"void":return null;default:throw Error(i(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(p=l.instance,l.state.loading|=4,Df(p,h.precedence,a));return l.instance}function Df(a,l,h){for(var p=h.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),T=p.length?p[p.length-1]:null,x=T,M=0;M<p.length;M++){var q=p[M];if(q.dataset.precedence===l)x=q;else if(x!==T)break}x?x.parentNode.insertBefore(a,x.nextSibling):(l=h.nodeType===9?h.head:h,l.insertBefore(a,l.firstChild))}function L0(a,l){a.crossOrigin==null&&(a.crossOrigin=l.crossOrigin),a.referrerPolicy==null&&(a.referrerPolicy=l.referrerPolicy),a.title==null&&(a.title=l.title)}function I0(a,l){a.crossOrigin==null&&(a.crossOrigin=l.crossOrigin),a.referrerPolicy==null&&(a.referrerPolicy=l.referrerPolicy),a.integrity==null&&(a.integrity=l.integrity)}var wf=null;function Jx(a,l,h){if(wf===null){var p=new Map,T=wf=new Map;T.set(h,p)}else T=wf,p=T.get(h),p||(p=new Map,T.set(h,p));if(p.has(a))return p;for(p.set(a,null),h=h.getElementsByTagName(a),T=0;T<h.length;T++){var x=h[T];if(!(x[an]||x[jt]||a==="link"&&x.getAttribute("rel")==="stylesheet")&&x.namespaceURI!=="http://www.w3.org/2000/svg"){var M=x.getAttribute(l)||"";M=a+M;var q=p.get(M);q?q.push(x):p.set(M,[x])}}return p}function eS(a,l,h){a=a.ownerDocument||a,a.head.insertBefore(h,l==="title"?a.querySelector("head > title"):null)}function qI(a,l,h){if(h===1||l.itemProp!=null)return!1;switch(a){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(a=l.disabled,typeof l.precedence=="string"&&a==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function tS(a){return!(a.type==="stylesheet"&&(a.state.loading&3)===0)}function zI(a,l,h,p){if(h.type==="stylesheet"&&(typeof p.media!="string"||matchMedia(p.media).matches!==!1)&&(h.state.loading&4)===0){if(h.instance===null){var T=yu(p.href),x=l.querySelector(ld(T));if(x){l=x._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(a.count++,a=Lf.bind(a),l.then(a,a)),h.state.loading|=4,h.instance=x,Gi(x);return}x=l.ownerDocument||l,p=Qx(p),(T=kn.get(T))&&L0(p,T),x=x.createElement("link"),Gi(x);var M=x;M._p=new Promise(function(q,ce){M.onload=q,M.onerror=ce}),fs(x,"link",p),h.instance=x}a.stylesheets===null&&(a.stylesheets=new Map),a.stylesheets.set(h,l),(l=h.state.preload)&&(h.state.loading&3)===0&&(a.count++,h=Lf.bind(a),l.addEventListener("load",h),l.addEventListener("error",h))}}var k0=0;function KI(a,l){return a.stylesheets&&a.count===0&&kf(a,a.stylesheets),0<a.count||0<a.imgCount?function(h){var p=setTimeout(function(){if(a.stylesheets&&kf(a,a.stylesheets),a.unsuspend){var x=a.unsuspend;a.unsuspend=null,x()}},6e4+l);0<a.imgBytes&&k0===0&&(k0=62500*DI());var T=setTimeout(function(){if(a.waitingForImages=!1,a.count===0&&(a.stylesheets&&kf(a,a.stylesheets),a.unsuspend)){var x=a.unsuspend;a.unsuspend=null,x()}},(a.imgBytes>k0?50:800)+l);return a.unsuspend=h,function(){a.unsuspend=null,clearTimeout(p),clearTimeout(T)}}:null}function Lf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)kf(this,this.stylesheets);else if(this.unsuspend){var a=this.unsuspend;this.unsuspend=null,a()}}}var If=null;function kf(a,l){a.stylesheets=null,a.unsuspend!==null&&(a.count++,If=new Map,l.forEach(YI,a),If=null,Lf.call(a))}function YI(a,l){if(!(l.state.loading&4)){var h=If.get(a);if(h)var p=h.get(null);else{h=new Map,If.set(a,h);for(var T=a.querySelectorAll("link[data-precedence],style[data-precedence]"),x=0;x<T.length;x++){var M=T[x];(M.nodeName==="LINK"||M.getAttribute("media")!=="not all")&&(h.set(M.dataset.precedence,M),p=M)}p&&h.set(null,p)}T=l.instance,M=T.getAttribute("data-precedence"),x=h.get(M)||p,x===p&&h.set(null,T),h.set(M,T),this.count++,p=Lf.bind(this),T.addEventListener("load",p),T.addEventListener("error",p),x?x.parentNode.insertBefore(T,x.nextSibling):(a=a.nodeType===9?a.head:a,a.insertBefore(T,a.firstChild)),l.state.loading|=4}}var cd={$$typeof:L,Provider:null,Consumer:null,_currentValue:Q,_currentValue2:Q,_threadCount:0};function WI(a,l,h,p,T,x,M,q,ce){this.tag=1,this.containerInfo=a,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=at(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=at(0),this.hiddenUpdates=at(null),this.identifierPrefix=p,this.onUncaughtError=T,this.onCaughtError=x,this.onRecoverableError=M,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=ce,this.incompleteTransitions=new Map}function iS(a,l,h,p,T,x,M,q,ce,_e,Oe,Ne){return a=new WI(a,l,h,M,ce,_e,Oe,Ne,q),l=1,x===!0&&(l|=24),x=Di(3,null,null,l),a.current=x,x.stateNode=a,l=Qr(),l.refCount++,a.pooledCache=l,l.refCount++,x.memoizedState={element:p,isDehydrated:h,cache:l},pg(x),a}function sS(a){return a?(a=Ba,a):Ba}function nS(a,l,h,p,T,x){T=sS(T),p.context===null?p.context=T:p.pendingContext=T,p=Ha(l),p.payload={element:h},x=x===void 0?null:x,x!==null&&(p.callback=x),h=Ga(a,p,l),h!==null&&(Ws(h,a,l),Hc(h,a,l))}function rS(a,l){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var h=a.retryLane;a.retryLane=h!==0&&h<l?h:l}}function R0(a,l){rS(a,l),(a=a.alternate)&&rS(a,l)}function aS(a){if(a.tag===13||a.tag===31){var l=Xr(a,67108864);l!==null&&Ws(l,a,67108864),R0(a,67108864)}}function oS(a){if(a.tag===13||a.tag===31){var l=pn();l=Ts(l);var h=Xr(a,l);h!==null&&Ws(h,a,l),R0(a,l)}}var Rf=!0;function XI(a,l,h,p){var T=Y.T;Y.T=null;var x=Z.p;try{Z.p=2,O0(a,l,h,p)}finally{Z.p=x,Y.T=T}}function QI(a,l,h,p){var T=Y.T;Y.T=null;var x=Z.p;try{Z.p=8,O0(a,l,h,p)}finally{Z.p=x,Y.T=T}}function O0(a,l,h,p){if(Rf){var T=P0(p);if(T===null)T0(a,l,p,Of,h),uS(a,p);else if(JI(T,a,l,h,p))p.stopPropagation();else if(uS(a,p),l&4&&-1<ZI.indexOf(a)){for(;T!==null;){var x=Hn(T);if(x!==null)switch(x.tag){case 3:if(x=x.stateNode,x.current.memoizedState.isDehydrated){var M=H(x.pendingLanes);if(M!==0){var q=x;for(q.pendingLanes|=2,q.entangledLanes|=2;M;){var ce=1<<31-He(M);q.entanglements[1]|=ce,M&=~ce}Tr(x),(zt&6)===0&&(mf=Ye()+500,nd(0))}}break;case 31:case 13:q=Xr(x,2),q!==null&&Ws(q,x,2),yf(),R0(x,2)}if(x=P0(p),x===null&&T0(a,l,p,Of,h),x===T)break;T=x}T!==null&&p.stopPropagation()}else T0(a,l,p,null,h)}}function P0(a){return a=Fl(a),M0(a)}var Of=null;function M0(a){if(Of=null,a=Hr(a),a!==null){var l=r(a);if(l===null)a=null;else{var h=l.tag;if(h===13){if(a=o(l),a!==null)return a;a=null}else if(h===31){if(a=u(l),a!==null)return a;a=null}else if(h===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;a=null}else l!==a&&(a=null)}}return Of=a,null}function lS(a){switch(a){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(gt()){case Lt:return 2;case $t:return 8;case fi:case pi:return 32;case ts:return 268435456;default:return 32}default:return 32}}var N0=!1,eo=null,to=null,io=null,dd=new Map,hd=new Map,so=[],ZI="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function uS(a,l){switch(a){case"focusin":case"focusout":eo=null;break;case"dragenter":case"dragleave":to=null;break;case"mouseover":case"mouseout":io=null;break;case"pointerover":case"pointerout":dd.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":hd.delete(l.pointerId)}}function fd(a,l,h,p,T,x){return a===null||a.nativeEvent!==x?(a={blockedOn:l,domEventName:h,eventSystemFlags:p,nativeEvent:x,targetContainers:[T]},l!==null&&(l=Hn(l),l!==null&&aS(l)),a):(a.eventSystemFlags|=p,l=a.targetContainers,T!==null&&l.indexOf(T)===-1&&l.push(T),a)}function JI(a,l,h,p,T){switch(l){case"focusin":return eo=fd(eo,a,l,h,p,T),!0;case"dragenter":return to=fd(to,a,l,h,p,T),!0;case"mouseover":return io=fd(io,a,l,h,p,T),!0;case"pointerover":var x=T.pointerId;return dd.set(x,fd(dd.get(x)||null,a,l,h,p,T)),!0;case"gotpointercapture":return x=T.pointerId,hd.set(x,fd(hd.get(x)||null,a,l,h,p,T)),!0}return!1}function cS(a){var l=Hr(a.target);if(l!==null){var h=r(l);if(h!==null){if(l=h.tag,l===13){if(l=o(h),l!==null){a.blockedOn=l,Ls(a.priority,function(){oS(h)});return}}else if(l===31){if(l=u(h),l!==null){a.blockedOn=l,Ls(a.priority,function(){oS(h)});return}}else if(l===3&&h.stateNode.current.memoizedState.isDehydrated){a.blockedOn=h.tag===3?h.stateNode.containerInfo:null;return}}}a.blockedOn=null}function Pf(a){if(a.blockedOn!==null)return!1;for(var l=a.targetContainers;0<l.length;){var h=P0(a.nativeEvent);if(h===null){h=a.nativeEvent;var p=new h.constructor(h.type,h);Ea=p,h.target.dispatchEvent(p),Ea=null}else return l=Hn(h),l!==null&&aS(l),a.blockedOn=h,!1;l.shift()}return!0}function dS(a,l,h){Pf(a)&&h.delete(l)}function ek(){N0=!1,eo!==null&&Pf(eo)&&(eo=null),to!==null&&Pf(to)&&(to=null),io!==null&&Pf(io)&&(io=null),dd.forEach(dS),hd.forEach(dS)}function Mf(a,l){a.blockedOn===l&&(a.blockedOn=null,N0||(N0=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,ek)))}var Nf=null;function hS(a){Nf!==a&&(Nf=a,s.unstable_scheduleCallback(s.unstable_NormalPriority,function(){Nf===a&&(Nf=null);for(var l=0;l<a.length;l+=3){var h=a[l],p=a[l+1],T=a[l+2];if(typeof p!="function"){if(M0(p||h)===null)continue;break}var x=Hn(h);x!==null&&(a.splice(l,3),l-=3,Pg(x,{pending:!0,data:T,method:h.method,action:p},p,T))}}))}function Tu(a){function l(ce){return Mf(ce,a)}eo!==null&&Mf(eo,a),to!==null&&Mf(to,a),io!==null&&Mf(io,a),dd.forEach(l),hd.forEach(l);for(var h=0;h<so.length;h++){var p=so[h];p.blockedOn===a&&(p.blockedOn=null)}for(;0<so.length&&(h=so[0],h.blockedOn===null);)cS(h),h.blockedOn===null&&so.shift();if(h=(a.ownerDocument||a).$$reactFormReplay,h!=null)for(p=0;p<h.length;p+=3){var T=h[p],x=h[p+1],M=T[Nt]||null;if(typeof x=="function")M||hS(h);else if(M){var q=null;if(x&&x.hasAttribute("formAction")){if(T=x,M=x[Nt]||null)q=M.formAction;else if(M0(T)!==null)continue}else q=M.action;typeof q=="function"?h[p+1]=q:(h.splice(p,3),p-=3),hS(h)}}}function fS(){function a(x){x.canIntercept&&x.info==="react-transition"&&x.intercept({handler:function(){return new Promise(function(M){return T=M})},focusReset:"manual",scroll:"manual"})}function l(){T!==null&&(T(),T=null),p||setTimeout(h,20)}function h(){if(!p&&!navigation.transition){var x=navigation.currentEntry;x&&x.url!=null&&navigation.navigate(x.url,{state:x.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var p=!1,T=null;return navigation.addEventListener("navigate",a),navigation.addEventListener("navigatesuccess",l),navigation.addEventListener("navigateerror",l),setTimeout(h,100),function(){p=!0,navigation.removeEventListener("navigate",a),navigation.removeEventListener("navigatesuccess",l),navigation.removeEventListener("navigateerror",l),T!==null&&(T(),T=null)}}}function B0(a){this._internalRoot=a}Bf.prototype.render=B0.prototype.render=function(a){var l=this._internalRoot;if(l===null)throw Error(i(409));var h=l.current,p=pn();nS(h,p,a,l,null,null)},Bf.prototype.unmount=B0.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var l=a.containerInfo;nS(a.current,2,null,a,null,null),yf(),l[kt]=null}};function Bf(a){this._internalRoot=a}Bf.prototype.unstable_scheduleHydration=function(a){if(a){var l=An();a={blockedOn:null,target:a,priority:l};for(var h=0;h<so.length&&l!==0&&l<so[h].priority;h++);so.splice(h,0,a),h===0&&cS(a)}};var pS=e.version;if(pS!=="19.2.3")throw Error(i(527,pS,"19.2.3"));Z.findDOMNode=function(a){var l=a._reactInternals;if(l===void 0)throw typeof a.render=="function"?Error(i(188)):(a=Object.keys(a).join(","),Error(i(268,a)));return a=d(l),a=a!==null?f(a):null,a=a===null?null:a.stateNode,a};var tk={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:Y,reconcilerVersion:"19.2.3"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Ff=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ff.isDisabled&&Ff.supportsFiber)try{de=Ff.inject(tk),ye=Ff}catch{}}return md.createRoot=function(a,l){if(!n(a))throw Error(i(299));var h=!1,p="",T=__,x=x_,M=S_;return l!=null&&(l.unstable_strictMode===!0&&(h=!0),l.identifierPrefix!==void 0&&(p=l.identifierPrefix),l.onUncaughtError!==void 0&&(T=l.onUncaughtError),l.onCaughtError!==void 0&&(x=l.onCaughtError),l.onRecoverableError!==void 0&&(M=l.onRecoverableError)),l=iS(a,1,!1,null,null,h,p,null,T,x,M,fS),a[kt]=l.current,v0(a),new B0(l)},md.hydrateRoot=function(a,l,h){if(!n(a))throw Error(i(299));var p=!1,T="",x=__,M=x_,q=S_,ce=null;return h!=null&&(h.unstable_strictMode===!0&&(p=!0),h.identifierPrefix!==void 0&&(T=h.identifierPrefix),h.onUncaughtError!==void 0&&(x=h.onUncaughtError),h.onCaughtError!==void 0&&(M=h.onCaughtError),h.onRecoverableError!==void 0&&(q=h.onRecoverableError),h.formState!==void 0&&(ce=h.formState)),l=iS(a,1,!0,l,h??null,p,T,ce,x,M,q,fS),l.context=sS(null),h=l.current,p=pn(),p=Ts(p),T=Ha(p),T.callback=null,Ga(h,T,p),h=p,l.current.lanes=h,Mt(l,h),Tr(l),a[kt]=l.current,v0(a),new Bf(l)},md.version="19.2.3",md}var AS;function hk(){if(AS)return $0.exports;AS=1;function s(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(s)}catch(e){console.error(e)}}return s(),$0.exports=dk(),$0.exports}var fk=hk();function pk(...s){return s.filter(Boolean).join(" ")}const mk="inline-flex items-center justify-center font-semibold focus-visible:outline-2 focus-visible:outline-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",gk={sm:"rounded-sm",md:"rounded-md",full:"rounded-full"},yk={xs:"px-2 py-1 text-xs",sm:"px-2.5 py-1.5 text-sm",md:"px-3 py-2 text-sm",lg:"px-3.5 py-2.5 text-sm"},vk={indigo:{primary:"bg-indigo-600 text-white shadow-xs hover:bg-indigo-500 focus-visible:outline-indigo-600 dark:bg-indigo-500 dark:shadow-none dark:hover:bg-indigo-400 dark:focus-visible:outline-indigo-500",secondary:"bg-white text-gray-900 shadow-xs inset-ring inset-ring-gray-300 hover:bg-gray-50 dark:bg-white/10 dark:text-white dark:shadow-none dark:inset-ring-white/5 dark:hover:bg-white/20",soft:"bg-indigo-50 text-indigo-600 shadow-xs hover:bg-indigo-100 dark:bg-indigo-500/20 dark:text-indigo-400 dark:shadow-none dark:hover:bg-indigo-500/30"},blue:{primary:"bg-blue-600 text-white shadow-xs hover:bg-blue-500 focus-visible:outline-blue-600 dark:bg-blue-500 dark:shadow-none dark:hover:bg-blue-400 dark:focus-visible:outline-blue-500",secondary:"bg-white text-gray-900 shadow-xs inset-ring inset-ring-gray-300 hover:bg-gray-50 dark:bg-white/10 dark:text-white dark:shadow-none dark:inset-ring-white/5 dark:hover:bg-white/20",soft:"bg-blue-50 text-blue-600 shadow-xs hover:bg-blue-100 dark:bg-blue-500/20 dark:text-blue-400 dark:shadow-none dark:hover:bg-blue-500/30"},emerald:{primary:"bg-emerald-600 text-white shadow-xs hover:bg-emerald-500 focus-visible:outline-emerald-600 dark:bg-emerald-500 dark:shadow-none dark:hover:bg-emerald-400 dark:focus-visible:outline-emerald-500",secondary:"bg-white text-gray-900 shadow-xs inset-ring inset-ring-gray-300 hover:bg-gray-50 dark:bg-white/10 dark:text-white dark:shadow-none dark:inset-ring-white/5 dark:hover:bg-white/20",soft:"bg-emerald-50 text-emerald-700 shadow-xs hover:bg-emerald-100 dark:bg-emerald-500/20 dark:text-emerald-400 dark:shadow-none dark:hover:bg-emerald-500/30"},red:{primary:"bg-red-600 text-white shadow-xs hover:bg-red-500 focus-visible:outline-red-600 dark:bg-red-500 dark:shadow-none dark:hover:bg-red-400 dark:focus-visible:outline-red-500",secondary:"bg-white text-gray-900 shadow-xs inset-ring inset-ring-gray-300 hover:bg-gray-50 dark:bg-white/10 dark:text-white dark:shadow-none dark:inset-ring-white/5 dark:hover:bg-white/20",soft:"bg-red-50 text-red-700 shadow-xs hover:bg-red-100 dark:bg-red-500/20 dark:text-red-400 dark:shadow-none dark:hover:bg-red-500/30"},amber:{primary:"bg-amber-500 text-white shadow-xs hover:bg-amber-400 focus-visible:outline-amber-500 dark:bg-amber-500 dark:shadow-none dark:hover:bg-amber-400 dark:focus-visible:outline-amber-500",secondary:"bg-white text-gray-900 shadow-xs inset-ring inset-ring-gray-300 hover:bg-gray-50 dark:bg-white/10 dark:text-white dark:shadow-none dark:inset-ring-white/5 dark:hover:bg-white/20",soft:"bg-amber-50 text-amber-800 shadow-xs hover:bg-amber-100 dark:bg-amber-500/20 dark:text-amber-300 dark:shadow-none dark:hover:bg-amber-500/30"}};function Tk(){return P.jsxs("svg",{viewBox:"0 0 24 24",className:"size-4 animate-spin","aria-hidden":"true",children:[P.jsx("circle",{cx:"12",cy:"12",r:"10",fill:"none",stroke:"currentColor",strokeWidth:"4",opacity:"0.25"}),P.jsx("path",{d:"M22 12a10 10 0 0 1-10 10",fill:"none",stroke:"currentColor",strokeWidth:"4",opacity:"0.9"})]})}function es({children:s,variant:e="primary",color:t="indigo",size:i="md",rounded:n="md",leadingIcon:r,trailingIcon:o,isLoading:u=!1,disabled:c,className:d,type:f="button",...m}){const g=r||o||u?"gap-x-1.5":"";return P.jsxs("button",{type:f,disabled:c||u,className:pk(mk,gk[n],yk[i],vk[t][e],g,d),...m,children:[u?P.jsx("span",{className:"-ml-0.5",children:P.jsx(Tk,{})}):r&&P.jsx("span",{className:"-ml-0.5",children:r}),P.jsx("span",{children:s}),o&&!u&&P.jsx("span",{className:"-mr-0.5",children:o})]})}function K2(s){var e,t,i="";if(typeof s=="string"||typeof s=="number")i+=s;else if(typeof s=="object")if(Array.isArray(s)){var n=s.length;for(e=0;e<n;e++)s[e]&&(t=K2(s[e]))&&(i&&(i+=" "),i+=t)}else for(t in s)s[t]&&(i&&(i+=" "),i+=t);return i}function Ut(){for(var s,e,t=0,i="",n=arguments.length;t<n;t++)(s=arguments[t])&&(e=K2(s))&&(i&&(i+=" "),i+=e);return i}var ih=z2(),bk=Object.defineProperty,_k=(s,e,t)=>e in s?bk(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,V0=(s,e,t)=>(_k(s,typeof e!="symbol"?e+"":e,t),t);let xk=class{constructor(){V0(this,"current",this.detect()),V0(this,"handoffState","pending"),V0(this,"currentId",0)}set(e){this.current!==e&&(this.handoffState="pending",this.currentId=0,this.current=e)}reset(){this.set(this.detect())}nextId(){return++this.currentId}get isServer(){return this.current==="server"}get isClient(){return this.current==="client"}detect(){return typeof window>"u"||typeof document>"u"?"server":"client"}handoff(){this.handoffState==="pending"&&(this.handoffState="complete")}get isHandoffComplete(){return this.handoffState==="complete"}},Pr=new xk;function sh(s){var e;return Pr.isServer?null:s==null?document:(e=s?.ownerDocument)!=null?e:document}function ov(s){var e,t;return Pr.isServer?null:s==null?document:(t=(e=s?.getRootNode)==null?void 0:e.call(s))!=null?t:document}function Y2(s){var e,t;return(t=(e=ov(s))==null?void 0:e.activeElement)!=null?t:null}function Sk(s){return Y2(s)===s}function um(s){typeof queueMicrotask=="function"?queueMicrotask(s):Promise.resolve().then(s).catch(e=>setTimeout(()=>{throw e}))}function _a(){let s=[],e={addEventListener(t,i,n,r){return t.addEventListener(i,n,r),e.add(()=>t.removeEventListener(i,n,r))},requestAnimationFrame(...t){let i=requestAnimationFrame(...t);return e.add(()=>cancelAnimationFrame(i))},nextFrame(...t){return e.requestAnimationFrame(()=>e.requestAnimationFrame(...t))},setTimeout(...t){let i=setTimeout(...t);return e.add(()=>clearTimeout(i))},microTask(...t){let i={current:!0};return um(()=>{i.current&&t[0]()}),e.add(()=>{i.current=!1})},style(t,i,n){let r=t.style.getPropertyValue(i);return Object.assign(t.style,{[i]:n}),this.add(()=>{Object.assign(t.style,{[i]:r})})},group(t){let i=_a();return t(i),this.add(()=>i.dispose())},add(t){return s.includes(t)||s.push(t),()=>{let i=s.indexOf(t);if(i>=0)for(let n of s.splice(i,1))n()}},dispose(){for(let t of s.splice(0))t()}};return e}function cm(){let[s]=j.useState(_a);return j.useEffect(()=>()=>s.dispose(),[s]),s}let sn=(s,e)=>{Pr.isServer?j.useEffect(s,e):j.useLayoutEffect(s,e)};function Dl(s){let e=j.useRef(s);return sn(()=>{e.current=s},[s]),e}let li=function(s){let e=Dl(s);return yt.useCallback((...t)=>e.current(...t),[e])};function nh(s){return j.useMemo(()=>s,Object.values(s))}let Ek=j.createContext(void 0);function Ak(){return j.useContext(Ek)}function lv(...s){return Array.from(new Set(s.flatMap(e=>typeof e=="string"?e.split(" "):[]))).filter(Boolean).join(" ")}function Ta(s,e,...t){if(s in e){let n=e[s];return typeof n=="function"?n(...t):n}let i=new Error(`Tried to handle "${s}" but there is no handler defined. Only defined handlers are: ${Object.keys(e).map(n=>`"${n}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(i,Ta),i}var wp=(s=>(s[s.None=0]="None",s[s.RenderStrategy=1]="RenderStrategy",s[s.Static=2]="Static",s))(wp||{}),vo=(s=>(s[s.Unmount=0]="Unmount",s[s.Hidden=1]="Hidden",s))(vo||{});function Un(){let s=Dk();return j.useCallback(e=>Ck({mergeRefs:s,...e}),[s])}function Ck({ourProps:s,theirProps:e,slot:t,defaultTag:i,features:n,visible:r=!0,name:o,mergeRefs:u}){u=u??wk;let c=W2(e,s);if(r)return Uf(c,t,i,o,u);let d=n??0;if(d&2){let{static:f=!1,...m}=c;if(f)return Uf(m,t,i,o,u)}if(d&1){let{unmount:f=!0,...m}=c;return Ta(f?0:1,{0(){return null},1(){return Uf({...m,hidden:!0,style:{display:"none"}},t,i,o,u)}})}return Uf(c,t,i,o,u)}function Uf(s,e={},t,i,n){let{as:r=t,children:o,refName:u="ref",...c}=q0(s,["unmount","static"]),d=s.ref!==void 0?{[u]:s.ref}:{},f=typeof o=="function"?o(e):o;"className"in c&&c.className&&typeof c.className=="function"&&(c.className=c.className(e)),c["aria-labelledby"]&&c["aria-labelledby"]===c.id&&(c["aria-labelledby"]=void 0);let m={};if(e){let g=!1,v=[];for(let[b,_]of Object.entries(e))typeof _=="boolean"&&(g=!0),_===!0&&v.push(b.replace(/([A-Z])/g,E=>`-${E.toLowerCase()}`));if(g){m["data-headlessui-state"]=v.join(" ");for(let b of v)m[`data-${b}`]=""}}if(kd(r)&&(Object.keys(ul(c)).length>0||Object.keys(ul(m)).length>0))if(!j.isValidElement(f)||Array.isArray(f)&&f.length>1||Ik(f)){if(Object.keys(ul(c)).length>0)throw new Error(['Passing props on "Fragment"!',"",`The current component <${i} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(ul(c)).concat(Object.keys(ul(m))).map(g=>` - ${g}`).join(`
`),"","You can apply a few solutions:",['Add an `as="..."` prop, to ensure that we render an actual element instead of a "Fragment".',"Render a single element as the child so that we can forward the props onto that element."].map(g=>` - ${g}`).join(`
`)].join(`
`))}else{let g=f.props,v=g?.className,b=typeof v=="function"?(...w)=>lv(v(...w),c.className):lv(v,c.className),_=b?{className:b}:{},E=W2(f.props,ul(q0(c,["ref"])));for(let w in m)w in E&&delete m[w];return j.cloneElement(f,Object.assign({},E,m,d,{ref:n(Lk(f),d.ref)},_))}return j.createElement(r,Object.assign({},q0(c,["ref"]),!kd(r)&&d,!kd(r)&&m),f)}function Dk(){let s=j.useRef([]),e=j.useCallback(t=>{for(let i of s.current)i!=null&&(typeof i=="function"?i(t):i.current=t)},[]);return(...t)=>{if(!t.every(i=>i==null))return s.current=t,e}}function wk(...s){return s.every(e=>e==null)?void 0:e=>{for(let t of s)t!=null&&(typeof t=="function"?t(e):t.current=e)}}function W2(...s){if(s.length===0)return{};if(s.length===1)return s[0];let e={},t={};for(let i of s)for(let n in i)n.startsWith("on")&&typeof i[n]=="function"?(t[n]!=null||(t[n]=[]),t[n].push(i[n])):e[n]=i[n];if(e.disabled||e["aria-disabled"])for(let i in t)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(i)&&(t[i]=[n=>{var r;return(r=n?.preventDefault)==null?void 0:r.call(n)}]);for(let i in t)Object.assign(e,{[i](n,...r){let o=t[i];for(let u of o){if((n instanceof Event||n?.nativeEvent instanceof Event)&&n.defaultPrevented)return;u(n,...r)}}});return e}function rn(s){var e;return Object.assign(j.forwardRef(s),{displayName:(e=s.displayName)!=null?e:s.name})}function ul(s){let e=Object.assign({},s);for(let t in e)e[t]===void 0&&delete e[t];return e}function q0(s,e=[]){let t=Object.assign({},s);for(let i of e)i in t&&delete t[i];return t}function Lk(s){return yt.version.split(".")[0]>="19"?s.props.ref:s.ref}function kd(s){return s===j.Fragment||s===Symbol.for("react.fragment")}function Ik(s){return kd(s.type)}let kk="span";var Lp=(s=>(s[s.None=1]="None",s[s.Focusable=2]="Focusable",s[s.Hidden=4]="Hidden",s))(Lp||{});function Rk(s,e){var t;let{features:i=1,...n}=s,r={ref:e,"aria-hidden":(i&2)===2?!0:(t=n["aria-hidden"])!=null?t:void 0,hidden:(i&4)===4?!0:void 0,style:{position:"fixed",top:1,left:1,width:1,height:0,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0",...(i&4)===4&&(i&2)!==2&&{display:"none"}}};return Un()({ourProps:r,theirProps:n,slot:{},defaultTag:kk,name:"Hidden"})}let uv=rn(Rk);function Ok(s){return typeof s!="object"||s===null?!1:"nodeType"in s}function bo(s){return Ok(s)&&"tagName"in s}function Sl(s){return bo(s)&&"accessKey"in s}function To(s){return bo(s)&&"tabIndex"in s}function Pk(s){return bo(s)&&"style"in s}function Mk(s){return Sl(s)&&s.nodeName==="IFRAME"}function Nk(s){return Sl(s)&&s.nodeName==="INPUT"}let X2=Symbol();function Bk(s,e=!0){return Object.assign(s,{[X2]:e})}function $r(...s){let e=j.useRef(s);j.useEffect(()=>{e.current=s},[s]);let t=li(i=>{for(let n of e.current)n!=null&&(typeof n=="function"?n(i):n.current=i)});return s.every(i=>i==null||i?.[X2])?void 0:t}let lT=j.createContext(null);lT.displayName="DescriptionContext";function Q2(){let s=j.useContext(lT);if(s===null){let e=new Error("You used a <Description /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(e,Q2),e}return s}function Fk(){let[s,e]=j.useState([]);return[s.length>0?s.join(" "):void 0,j.useMemo(()=>function(t){let i=li(r=>(e(o=>[...o,r]),()=>e(o=>{let u=o.slice(),c=u.indexOf(r);return c!==-1&&u.splice(c,1),u}))),n=j.useMemo(()=>({register:i,slot:t.slot,name:t.name,props:t.props,value:t.value}),[i,t.slot,t.name,t.props,t.value]);return yt.createElement(lT.Provider,{value:n},t.children)},[e])]}let Uk="p";function $k(s,e){let t=j.useId(),i=Ak(),{id:n=`headlessui-description-${t}`,...r}=s,o=Q2(),u=$r(e);sn(()=>o.register(n),[n,o.register]);let c=nh({...o.slot,disabled:i||!1}),d={ref:u,...o.props,id:n};return Un()({ourProps:d,theirProps:r,slot:c,defaultTag:Uk,name:o.name||"Description"})}let jk=rn($k),Hk=Object.assign(jk,{});var Z2=(s=>(s.Space=" ",s.Enter="Enter",s.Escape="Escape",s.Backspace="Backspace",s.Delete="Delete",s.ArrowLeft="ArrowLeft",s.ArrowUp="ArrowUp",s.ArrowRight="ArrowRight",s.ArrowDown="ArrowDown",s.Home="Home",s.End="End",s.PageUp="PageUp",s.PageDown="PageDown",s.Tab="Tab",s))(Z2||{});let Gk=j.createContext(()=>{});function Vk({value:s,children:e}){return yt.createElement(Gk.Provider,{value:s},e)}let J2=class extends Map{constructor(e){super(),this.factory=e}get(e){let t=super.get(e);return t===void 0&&(t=this.factory(e),this.set(e,t)),t}};var qk=Object.defineProperty,zk=(s,e,t)=>e in s?qk(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Kk=(s,e,t)=>(zk(s,e+"",t),t),eA=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Rn=(s,e,t)=>(eA(s,e,"read from private field"),t?t.call(s):e.get(s)),z0=(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)},CS=(s,e,t,i)=>(eA(s,e,"write to private field"),e.set(s,t),t),Sr,Ed,Ad;let Yk=class{constructor(e){z0(this,Sr,{}),z0(this,Ed,new J2(()=>new Set)),z0(this,Ad,new Set),Kk(this,"disposables",_a()),CS(this,Sr,e),Pr.isServer&&this.disposables.microTask(()=>{this.dispose()})}dispose(){this.disposables.dispose()}get state(){return Rn(this,Sr)}subscribe(e,t){if(Pr.isServer)return()=>{};let i={selector:e,callback:t,current:e(Rn(this,Sr))};return Rn(this,Ad).add(i),this.disposables.add(()=>{Rn(this,Ad).delete(i)})}on(e,t){return Pr.isServer?()=>{}:(Rn(this,Ed).get(e).add(t),this.disposables.add(()=>{Rn(this,Ed).get(e).delete(t)}))}send(e){let t=this.reduce(Rn(this,Sr),e);if(t!==Rn(this,Sr)){CS(this,Sr,t);for(let i of Rn(this,Ad)){let n=i.selector(Rn(this,Sr));tA(i.current,n)||(i.current=n,i.callback(n))}for(let i of Rn(this,Ed).get(e.type))i(Rn(this,Sr),e)}}};Sr=new WeakMap,Ed=new WeakMap,Ad=new WeakMap;function tA(s,e){return Object.is(s,e)?!0:typeof s!="object"||s===null||typeof e!="object"||e===null?!1:Array.isArray(s)&&Array.isArray(e)?s.length!==e.length?!1:K0(s[Symbol.iterator](),e[Symbol.iterator]()):s instanceof Map&&e instanceof Map||s instanceof Set&&e instanceof Set?s.size!==e.size?!1:K0(s.entries(),e.entries()):DS(s)&&DS(e)?K0(Object.entries(s)[Symbol.iterator](),Object.entries(e)[Symbol.iterator]()):!1}function K0(s,e){do{let t=s.next(),i=e.next();if(t.done&&i.done)return!0;if(t.done||i.done||!Object.is(t.value,i.value))return!1}while(!0)}function DS(s){if(Object.prototype.toString.call(s)!=="[object Object]")return!1;let e=Object.getPrototypeOf(s);return e===null||Object.getPrototypeOf(e)===null}var Wk=Object.defineProperty,Xk=(s,e,t)=>e in s?Wk(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,wS=(s,e,t)=>(Xk(s,typeof e!="symbol"?e+"":e,t),t),Qk=(s=>(s[s.Push=0]="Push",s[s.Pop=1]="Pop",s))(Qk||{});let Zk={0(s,e){let t=e.id,i=s.stack,n=s.stack.indexOf(t);if(n!==-1){let r=s.stack.slice();return r.splice(n,1),r.push(t),i=r,{...s,stack:i}}return{...s,stack:[...s.stack,t]}},1(s,e){let t=e.id,i=s.stack.indexOf(t);if(i===-1)return s;let n=s.stack.slice();return n.splice(i,1),{...s,stack:n}}},Jk=class iA extends Yk{constructor(){super(...arguments),wS(this,"actions",{push:e=>this.send({type:0,id:e}),pop:e=>this.send({type:1,id:e})}),wS(this,"selectors",{isTop:(e,t)=>e.stack[e.stack.length-1]===t,inStack:(e,t)=>e.stack.includes(t)})}static new(){return new iA({stack:[]})}reduce(e,t){return Ta(t.type,Zk,e,t)}};const sA=new J2(()=>Jk.new());var Y0={exports:{}},W0={};var LS;function eR(){if(LS)return W0;LS=1;var s=lm();function e(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var t=typeof Object.is=="function"?Object.is:e,i=s.useSyncExternalStore,n=s.useRef,r=s.useEffect,o=s.useMemo,u=s.useDebugValue;return W0.useSyncExternalStoreWithSelector=function(c,d,f,m,g){var v=n(null);if(v.current===null){var b={hasValue:!1,value:null};v.current=b}else b=v.current;v=o(function(){function E($){if(!w){if(w=!0,I=$,$=m($),g!==void 0&&b.hasValue){var G=b.value;if(g(G,$))return L=G}return L=$}if(G=L,t(I,$))return G;var B=m($);return g!==void 0&&g(G,B)?(I=$,G):(I=$,L=B)}var w=!1,I,L,F=f===void 0?null:f;return[function(){return E(d())},F===null?void 0:function(){return E(F())}]},[d,f,m,g]);var _=i(c,v[0],v[1]);return r(function(){b.hasValue=!0,b.value=_},[_]),u(_),_},W0}var IS;function tR(){return IS||(IS=1,Y0.exports=eR()),Y0.exports}var iR=tR();function nA(s,e,t=tA){return iR.useSyncExternalStoreWithSelector(li(i=>s.subscribe(sR,i)),li(()=>s.state),li(()=>s.state),li(e),t)}function sR(s){return s}function rh(s,e){let t=j.useId(),i=sA.get(e),[n,r]=nA(i,j.useCallback(o=>[i.selectors.isTop(o,t),i.selectors.inStack(o,t)],[i,t]));return sn(()=>{if(s)return i.actions.push(t),()=>i.actions.pop(t)},[i,s,t]),s?r?n:!0:!1}let cv=new Map,Rd=new Map;function kS(s){var e;let t=(e=Rd.get(s))!=null?e:0;return Rd.set(s,t+1),t!==0?()=>RS(s):(cv.set(s,{"aria-hidden":s.getAttribute("aria-hidden"),inert:s.inert}),s.setAttribute("aria-hidden","true"),s.inert=!0,()=>RS(s))}function RS(s){var e;let t=(e=Rd.get(s))!=null?e:1;if(t===1?Rd.delete(s):Rd.set(s,t-1),t!==1)return;let i=cv.get(s);i&&(i["aria-hidden"]===null?s.removeAttribute("aria-hidden"):s.setAttribute("aria-hidden",i["aria-hidden"]),s.inert=i.inert,cv.delete(s))}function nR(s,{allowed:e,disallowed:t}={}){let i=rh(s,"inert-others");sn(()=>{var n,r;if(!i)return;let o=_a();for(let c of(n=t?.())!=null?n:[])c&&o.add(kS(c));let u=(r=e?.())!=null?r:[];for(let c of u){if(!c)continue;let d=sh(c);if(!d)continue;let f=c.parentElement;for(;f&&f!==d.body;){for(let m of f.children)u.some(g=>m.contains(g))||o.add(kS(m));f=f.parentElement}}return o.dispose},[i,e,t])}function rR(s,e,t){let i=Dl(n=>{let r=n.getBoundingClientRect();r.x===0&&r.y===0&&r.width===0&&r.height===0&&t()});j.useEffect(()=>{if(!s)return;let n=e===null?null:Sl(e)?e:e.current;if(!n)return;let r=_a();if(typeof ResizeObserver<"u"){let o=new ResizeObserver(()=>i.current(n));o.observe(n),r.add(()=>o.disconnect())}if(typeof IntersectionObserver<"u"){let o=new IntersectionObserver(()=>i.current(n));o.observe(n),r.add(()=>o.disconnect())}return()=>r.dispose()},[e,i,s])}let Ip=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","details>summary","textarea:not([disabled])"].map(s=>`${s}:not([tabindex='-1'])`).join(","),aR=["[data-autofocus]"].map(s=>`${s}:not([tabindex='-1'])`).join(",");var pa=(s=>(s[s.First=1]="First",s[s.Previous=2]="Previous",s[s.Next=4]="Next",s[s.Last=8]="Last",s[s.WrapAround=16]="WrapAround",s[s.NoScroll=32]="NoScroll",s[s.AutoFocus=64]="AutoFocus",s))(pa||{}),dv=(s=>(s[s.Error=0]="Error",s[s.Overflow=1]="Overflow",s[s.Success=2]="Success",s[s.Underflow=3]="Underflow",s))(dv||{}),oR=(s=>(s[s.Previous=-1]="Previous",s[s.Next=1]="Next",s))(oR||{});function lR(s=document.body){return s==null?[]:Array.from(s.querySelectorAll(Ip)).sort((e,t)=>Math.sign((e.tabIndex||Number.MAX_SAFE_INTEGER)-(t.tabIndex||Number.MAX_SAFE_INTEGER)))}function uR(s=document.body){return s==null?[]:Array.from(s.querySelectorAll(aR)).sort((e,t)=>Math.sign((e.tabIndex||Number.MAX_SAFE_INTEGER)-(t.tabIndex||Number.MAX_SAFE_INTEGER)))}var rA=(s=>(s[s.Strict=0]="Strict",s[s.Loose=1]="Loose",s))(rA||{});function cR(s,e=0){var t;return s===((t=sh(s))==null?void 0:t.body)?!1:Ta(e,{0(){return s.matches(Ip)},1(){let i=s;for(;i!==null;){if(i.matches(Ip))return!0;i=i.parentElement}return!1}})}var dR=(s=>(s[s.Keyboard=0]="Keyboard",s[s.Mouse=1]="Mouse",s))(dR||{});typeof window<"u"&&typeof document<"u"&&(document.addEventListener("keydown",s=>{s.metaKey||s.altKey||s.ctrlKey||(document.documentElement.dataset.headlessuiFocusVisible="")},!0),document.addEventListener("click",s=>{s.detail===1?delete document.documentElement.dataset.headlessuiFocusVisible:s.detail===0&&(document.documentElement.dataset.headlessuiFocusVisible="")},!0));function ya(s){s?.focus({preventScroll:!0})}let hR=["textarea","input"].join(",");function fR(s){var e,t;return(t=(e=s?.matches)==null?void 0:e.call(s,hR))!=null?t:!1}function pR(s,e=t=>t){return s.slice().sort((t,i)=>{let n=e(t),r=e(i);if(n===null||r===null)return 0;let o=n.compareDocumentPosition(r);return o&Node.DOCUMENT_POSITION_FOLLOWING?-1:o&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function Od(s,e,{sorted:t=!0,relativeTo:i=null,skipElements:n=[]}={}){let r=Array.isArray(s)?s.length>0?ov(s[0]):document:ov(s),o=Array.isArray(s)?t?pR(s):s:e&64?uR(s):lR(s);n.length>0&&o.length>1&&(o=o.filter(v=>!n.some(b=>b!=null&&"current"in b?b?.current===v:b===v))),i=i??r?.activeElement;let u=(()=>{if(e&5)return 1;if(e&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),c=(()=>{if(e&1)return 0;if(e&2)return Math.max(0,o.indexOf(i))-1;if(e&4)return Math.max(0,o.indexOf(i))+1;if(e&8)return o.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),d=e&32?{preventScroll:!0}:{},f=0,m=o.length,g;do{if(f>=m||f+m<=0)return 0;let v=c+f;if(e&16)v=(v+m)%m;else{if(v<0)return 3;if(v>=m)return 1}g=o[v],g?.focus(d),f+=u}while(g!==Y2(g));return e&6&&fR(g)&&g.select(),2}function aA(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function mR(){return/Android/gi.test(window.navigator.userAgent)}function OS(){return aA()||mR()}function $f(s,e,t,i){let n=Dl(t);j.useEffect(()=>{if(!s)return;function r(o){n.current(o)}return document.addEventListener(e,r,i),()=>document.removeEventListener(e,r,i)},[s,e,i])}function oA(s,e,t,i){let n=Dl(t);j.useEffect(()=>{if(!s)return;function r(o){n.current(o)}return window.addEventListener(e,r,i),()=>window.removeEventListener(e,r,i)},[s,e,i])}const PS=30;function gR(s,e,t){let i=Dl(t),n=j.useCallback(function(u,c){if(u.defaultPrevented)return;let d=c(u);if(d===null||!d.getRootNode().contains(d)||!d.isConnected)return;let f=(function m(g){return typeof g=="function"?m(g()):Array.isArray(g)||g instanceof Set?g:[g]})(e);for(let m of f)if(m!==null&&(m.contains(d)||u.composed&&u.composedPath().includes(m)))return;return!cR(d,rA.Loose)&&d.tabIndex!==-1&&u.preventDefault(),i.current(u,d)},[i,e]),r=j.useRef(null);$f(s,"pointerdown",u=>{var c,d;OS()||(r.current=((d=(c=u.composedPath)==null?void 0:c.call(u))==null?void 0:d[0])||u.target)},!0),$f(s,"pointerup",u=>{if(OS()||!r.current)return;let c=r.current;return r.current=null,n(u,()=>c)},!0);let o=j.useRef({x:0,y:0});$f(s,"touchstart",u=>{o.current.x=u.touches[0].clientX,o.current.y=u.touches[0].clientY},!0),$f(s,"touchend",u=>{let c={x:u.changedTouches[0].clientX,y:u.changedTouches[0].clientY};if(!(Math.abs(c.x-o.current.x)>=PS||Math.abs(c.y-o.current.y)>=PS))return n(u,()=>To(u.target)?u.target:null)},!0),oA(s,"blur",u=>n(u,()=>Mk(window.document.activeElement)?window.document.activeElement:null),!0)}function uT(...s){return j.useMemo(()=>sh(...s),[...s])}function lA(s,e,t,i){let n=Dl(t);j.useEffect(()=>{s=s??window;function r(o){n.current(o)}return s.addEventListener(e,r,i),()=>s.removeEventListener(e,r,i)},[s,e,i])}function yR(s){return j.useSyncExternalStore(s.subscribe,s.getSnapshot,s.getSnapshot)}function vR(s,e){let t=s(),i=new Set;return{getSnapshot(){return t},subscribe(n){return i.add(n),()=>i.delete(n)},dispatch(n,...r){let o=e[n].call(t,...r);o&&(t=o,i.forEach(u=>u()))}}}function TR(){let s;return{before({doc:e}){var t;let i=e.documentElement,n=(t=e.defaultView)!=null?t:window;s=Math.max(0,n.innerWidth-i.clientWidth)},after({doc:e,d:t}){let i=e.documentElement,n=Math.max(0,i.clientWidth-i.offsetWidth),r=Math.max(0,s-n);t.style(i,"paddingRight",`${r}px`)}}}function bR(){return aA()?{before({doc:s,d:e,meta:t}){function i(n){for(let r of t().containers)for(let o of r())if(o.contains(n))return!0;return!1}e.microTask(()=>{var n;if(window.getComputedStyle(s.documentElement).scrollBehavior!=="auto"){let u=_a();u.style(s.documentElement,"scrollBehavior","auto"),e.add(()=>e.microTask(()=>u.dispose()))}let r=(n=window.scrollY)!=null?n:window.pageYOffset,o=null;e.addEventListener(s,"click",u=>{if(To(u.target))try{let c=u.target.closest("a");if(!c)return;let{hash:d}=new URL(c.href),f=s.querySelector(d);To(f)&&!i(f)&&(o=f)}catch{}},!0),e.group(u=>{e.addEventListener(s,"touchstart",c=>{if(u.dispose(),To(c.target)&&Pk(c.target))if(i(c.target)){let d=c.target;for(;d.parentElement&&i(d.parentElement);)d=d.parentElement;u.style(d,"overscrollBehavior","contain")}else u.style(c.target,"touchAction","none")})}),e.addEventListener(s,"touchmove",u=>{if(To(u.target)){if(Nk(u.target))return;if(i(u.target)){let c=u.target;for(;c.parentElement&&c.dataset.headlessuiPortal!==""&&!(c.scrollHeight>c.clientHeight||c.scrollWidth>c.clientWidth);)c=c.parentElement;c.dataset.headlessuiPortal===""&&u.preventDefault()}else u.preventDefault()}},{passive:!1}),e.add(()=>{var u;let c=(u=window.scrollY)!=null?u:window.pageYOffset;r!==c&&window.scrollTo(0,r),o&&o.isConnected&&(o.scrollIntoView({block:"nearest"}),o=null)})})}}:{}}function _R(){return{before({doc:s,d:e}){e.style(s.documentElement,"overflow","hidden")}}}function MS(s){let e={};for(let t of s)Object.assign(e,t(e));return e}let pl=vR(()=>new Map,{PUSH(s,e){var t;let i=(t=this.get(s))!=null?t:{doc:s,count:0,d:_a(),meta:new Set,computedMeta:{}};return i.count++,i.meta.add(e),i.computedMeta=MS(i.meta),this.set(s,i),this},POP(s,e){let t=this.get(s);return t&&(t.count--,t.meta.delete(e),t.computedMeta=MS(t.meta)),this},SCROLL_PREVENT(s){let e={doc:s.doc,d:s.d,meta(){return s.computedMeta}},t=[bR(),TR(),_R()];t.forEach(({before:i})=>i?.(e)),t.forEach(({after:i})=>i?.(e))},SCROLL_ALLOW({d:s}){s.dispose()},TEARDOWN({doc:s}){this.delete(s)}});pl.subscribe(()=>{let s=pl.getSnapshot(),e=new Map;for(let[t]of s)e.set(t,t.documentElement.style.overflow);for(let t of s.values()){let i=e.get(t.doc)==="hidden",n=t.count!==0;(n&&!i||!n&&i)&&pl.dispatch(t.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",t),t.count===0&&pl.dispatch("TEARDOWN",t)}});function xR(s,e,t=()=>({containers:[]})){let i=yR(pl),n=e?i.get(e):void 0,r=n?n.count>0:!1;return sn(()=>{if(!(!e||!s))return pl.dispatch("PUSH",e,t),()=>pl.dispatch("POP",e,t)},[s,e]),r}function SR(s,e,t=()=>[document.body]){let i=rh(s,"scroll-lock");xR(i,e,n=>{var r;return{containers:[...(r=n.containers)!=null?r:[],t]}})}function ER(s=0){let[e,t]=j.useState(s),i=j.useCallback(c=>t(c),[]),n=j.useCallback(c=>t(d=>d|c),[]),r=j.useCallback(c=>(e&c)===c,[e]),o=j.useCallback(c=>t(d=>d&~c),[]),u=j.useCallback(c=>t(d=>d^c),[]);return{flags:e,setFlag:i,addFlag:n,hasFlag:r,removeFlag:o,toggleFlag:u}}var AR={},NS,BS;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((NS=process==null?void 0:AR)==null?void 0:NS.NODE_ENV)==="test"&&typeof((BS=Element?.prototype)==null?void 0:BS.getAnimations)>"u"&&(Element.prototype.getAnimations=function(){return console.warn(["Headless UI has polyfilled `Element.prototype.getAnimations` for your tests.","Please install a proper polyfill e.g. `jsdom-testing-mocks`, to silence these warnings.","","Example usage:","```js","import { mockAnimationsApi } from 'jsdom-testing-mocks'","mockAnimationsApi()","```"].join(`
`)),[]});var CR=(s=>(s[s.None=0]="None",s[s.Closed=1]="Closed",s[s.Enter=2]="Enter",s[s.Leave=4]="Leave",s))(CR||{});function DR(s){let e={};for(let t in s)s[t]===!0&&(e[`data-${t}`]="");return e}function wR(s,e,t,i){let[n,r]=j.useState(t),{hasFlag:o,addFlag:u,removeFlag:c}=ER(s&&n?3:0),d=j.useRef(!1),f=j.useRef(!1),m=cm();return sn(()=>{var g;if(s){if(t&&r(!0),!e){t&&u(3);return}return(g=i?.start)==null||g.call(i,t),LR(e,{inFlight:d,prepare(){f.current?f.current=!1:f.current=d.current,d.current=!0,!f.current&&(t?(u(3),c(4)):(u(4),c(2)))},run(){f.current?t?(c(3),u(4)):(c(4),u(3)):t?c(1):u(1)},done(){var v;f.current&&RR(e)||(d.current=!1,c(7),t||r(!1),(v=i?.end)==null||v.call(i,t))}})}},[s,t,e,m]),s?[n,{closed:o(1),enter:o(2),leave:o(4),transition:o(2)||o(4)}]:[t,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function LR(s,{prepare:e,run:t,done:i,inFlight:n}){let r=_a();return kR(s,{prepare:e,inFlight:n}),r.nextFrame(()=>{t(),r.requestAnimationFrame(()=>{r.add(IR(s,i))})}),r.dispose}function IR(s,e){var t,i;let n=_a();if(!s)return n.dispose;let r=!1;n.add(()=>{r=!0});let o=(i=(t=s.getAnimations)==null?void 0:t.call(s).filter(u=>u instanceof CSSTransition))!=null?i:[];return o.length===0?(e(),n.dispose):(Promise.allSettled(o.map(u=>u.finished)).then(()=>{r||e()}),n.dispose)}function kR(s,{inFlight:e,prepare:t}){if(e!=null&&e.current){t();return}let i=s.style.transition;s.style.transition="none",t(),s.offsetHeight,s.style.transition=i}function RR(s){var e,t;return((t=(e=s.getAnimations)==null?void 0:e.call(s))!=null?t:[]).some(i=>i instanceof CSSTransition&&i.playState!=="finished")}function cT(s,e){let t=j.useRef([]),i=li(s);j.useEffect(()=>{let n=[...t.current];for(let[r,o]of e.entries())if(t.current[r]!==o){let u=i(e,n);return t.current=e,u}},[i,...e])}let dm=j.createContext(null);dm.displayName="OpenClosedContext";var er=(s=>(s[s.Open=1]="Open",s[s.Closed=2]="Closed",s[s.Closing=4]="Closing",s[s.Opening=8]="Opening",s))(er||{});function hm(){return j.useContext(dm)}function OR({value:s,children:e}){return yt.createElement(dm.Provider,{value:s},e)}function PR({children:s}){return yt.createElement(dm.Provider,{value:null},s)}function MR(s){function e(){document.readyState!=="loading"&&(s(),document.removeEventListener("DOMContentLoaded",e))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",e),e())}let yo=[];MR(()=>{function s(e){if(!To(e.target)||e.target===document.body||yo[0]===e.target)return;let t=e.target;t=t.closest(Ip),yo.unshift(t??e.target),yo=yo.filter(i=>i!=null&&i.isConnected),yo.splice(10)}window.addEventListener("click",s,{capture:!0}),window.addEventListener("mousedown",s,{capture:!0}),window.addEventListener("focus",s,{capture:!0}),document.body.addEventListener("click",s,{capture:!0}),document.body.addEventListener("mousedown",s,{capture:!0}),document.body.addEventListener("focus",s,{capture:!0})});function uA(s){let e=li(s),t=j.useRef(!1);j.useEffect(()=>(t.current=!1,()=>{t.current=!0,um(()=>{t.current&&e()})}),[e])}let cA=j.createContext(!1);function NR(){return j.useContext(cA)}function FS(s){return yt.createElement(cA.Provider,{value:s.force},s.children)}function BR(s){let e=NR(),t=j.useContext(hA),[i,n]=j.useState(()=>{var r;if(!e&&t!==null)return(r=t.current)!=null?r:null;if(Pr.isServer)return null;let o=s?.getElementById("headlessui-portal-root");if(o)return o;if(s===null)return null;let u=s.createElement("div");return u.setAttribute("id","headlessui-portal-root"),s.body.appendChild(u)});return j.useEffect(()=>{i!==null&&(s!=null&&s.body.contains(i)||s==null||s.body.appendChild(i))},[i,s]),j.useEffect(()=>{e||t!==null&&n(t.current)},[t,n,e]),i}let dA=j.Fragment,FR=rn(function(s,e){let{ownerDocument:t=null,...i}=s,n=j.useRef(null),r=$r(Bk(g=>{n.current=g}),e),o=uT(n.current),u=t??o,c=BR(u),d=j.useContext(hv),f=cm(),m=Un();return uA(()=>{var g;c&&c.childNodes.length<=0&&((g=c.parentElement)==null||g.removeChild(c))}),c?ih.createPortal(yt.createElement("div",{"data-headlessui-portal":"",ref:g=>{f.dispose(),d&&g&&f.add(d.register(g))}},m({ourProps:{ref:r},theirProps:i,slot:{},defaultTag:dA,name:"Portal"})),c):null});function UR(s,e){let t=$r(e),{enabled:i=!0,ownerDocument:n,...r}=s,o=Un();return i?yt.createElement(FR,{...r,ownerDocument:n,ref:t}):o({ourProps:{ref:t},theirProps:r,slot:{},defaultTag:dA,name:"Portal"})}let $R=j.Fragment,hA=j.createContext(null);function jR(s,e){let{target:t,...i}=s,n={ref:$r(e)},r=Un();return yt.createElement(hA.Provider,{value:t},r({ourProps:n,theirProps:i,defaultTag:$R,name:"Popover.Group"}))}let hv=j.createContext(null);function HR(){let s=j.useContext(hv),e=j.useRef([]),t=li(r=>(e.current.push(r),s&&s.register(r),()=>i(r))),i=li(r=>{let o=e.current.indexOf(r);o!==-1&&e.current.splice(o,1),s&&s.unregister(r)}),n=j.useMemo(()=>({register:t,unregister:i,portals:e}),[t,i,e]);return[e,j.useMemo(()=>function({children:r}){return yt.createElement(hv.Provider,{value:n},r)},[n])]}let GR=rn(UR),fA=rn(jR),VR=Object.assign(GR,{Group:fA});function qR(s,e=typeof document<"u"?document.defaultView:null,t){let i=rh(s,"escape");lA(e,"keydown",n=>{i&&(n.defaultPrevented||n.key===Z2.Escape&&t(n))})}function zR(){var s;let[e]=j.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null),[t,i]=j.useState((s=e?.matches)!=null?s:!1);return sn(()=>{if(!e)return;function n(r){i(r.matches)}return e.addEventListener("change",n),()=>e.removeEventListener("change",n)},[e]),t}function KR({defaultContainers:s=[],portals:e,mainTreeNode:t}={}){let i=li(()=>{var n,r;let o=sh(t),u=[];for(let c of s)c!==null&&(bo(c)?u.push(c):"current"in c&&bo(c.current)&&u.push(c.current));if(e!=null&&e.current)for(let c of e.current)u.push(c);for(let c of(n=o?.querySelectorAll("html > *, body > *"))!=null?n:[])c!==document.body&&c!==document.head&&bo(c)&&c.id!=="headlessui-portal-root"&&(t&&(c.contains(t)||c.contains((r=t?.getRootNode())==null?void 0:r.host))||u.some(d=>c.contains(d))||u.push(c));return u});return{resolveContainers:i,contains:li(n=>i().some(r=>r.contains(n)))}}let pA=j.createContext(null);function US({children:s,node:e}){let[t,i]=j.useState(null),n=mA(e??t);return yt.createElement(pA.Provider,{value:n},s,n===null&&yt.createElement(uv,{features:Lp.Hidden,ref:r=>{var o,u;if(r){for(let c of(u=(o=sh(r))==null?void 0:o.querySelectorAll("html > *, body > *"))!=null?u:[])if(c!==document.body&&c!==document.head&&bo(c)&&c!=null&&c.contains(r)){i(c);break}}}}))}function mA(s=null){var e;return(e=j.useContext(pA))!=null?e:s}function YR(){let s=typeof document>"u";return"useSyncExternalStore"in TS?(e=>e.useSyncExternalStore)(TS)(()=>()=>{},()=>!1,()=>!s):!1}function fm(){let s=YR(),[e,t]=j.useState(Pr.isHandoffComplete);return e&&Pr.isHandoffComplete===!1&&t(!1),j.useEffect(()=>{e!==!0&&t(!0)},[e]),j.useEffect(()=>Pr.handoff(),[]),s?!1:e}function dT(){let s=j.useRef(!1);return sn(()=>(s.current=!0,()=>{s.current=!1}),[]),s}var Cd=(s=>(s[s.Forwards=0]="Forwards",s[s.Backwards=1]="Backwards",s))(Cd||{});function WR(){let s=j.useRef(0);return oA(!0,"keydown",e=>{e.key==="Tab"&&(s.current=e.shiftKey?1:0)},!0),s}function gA(s){if(!s)return new Set;if(typeof s=="function")return new Set(s());let e=new Set;for(let t of s.current)bo(t.current)&&e.add(t.current);return e}let XR="div";var hl=(s=>(s[s.None=0]="None",s[s.InitialFocus=1]="InitialFocus",s[s.TabLock=2]="TabLock",s[s.FocusLock=4]="FocusLock",s[s.RestoreFocus=8]="RestoreFocus",s[s.AutoFocus=16]="AutoFocus",s))(hl||{});function QR(s,e){let t=j.useRef(null),i=$r(t,e),{initialFocus:n,initialFocusFallback:r,containers:o,features:u=15,...c}=s;fm()||(u=0);let d=uT(t.current);tO(u,{ownerDocument:d});let f=iO(u,{ownerDocument:d,container:t,initialFocus:n,initialFocusFallback:r});sO(u,{ownerDocument:d,container:t,containers:o,previousActiveElement:f});let m=WR(),g=li(I=>{if(!Sl(t.current))return;let L=t.current;(F=>F())(()=>{Ta(m.current,{[Cd.Forwards]:()=>{Od(L,pa.First,{skipElements:[I.relatedTarget,r]})},[Cd.Backwards]:()=>{Od(L,pa.Last,{skipElements:[I.relatedTarget,r]})}})})}),v=rh(!!(u&2),"focus-trap#tab-lock"),b=cm(),_=j.useRef(!1),E={ref:i,onKeyDown(I){I.key=="Tab"&&(_.current=!0,b.requestAnimationFrame(()=>{_.current=!1}))},onBlur(I){if(!(u&4))return;let L=gA(o);Sl(t.current)&&L.add(t.current);let F=I.relatedTarget;To(F)&&F.dataset.headlessuiFocusGuard!=="true"&&(yA(L,F)||(_.current?Od(t.current,Ta(m.current,{[Cd.Forwards]:()=>pa.Next,[Cd.Backwards]:()=>pa.Previous})|pa.WrapAround,{relativeTo:I.target}):To(I.target)&&ya(I.target)))}},w=Un();return yt.createElement(yt.Fragment,null,v&&yt.createElement(uv,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:g,features:Lp.Focusable}),w({ourProps:E,theirProps:c,defaultTag:XR,name:"FocusTrap"}),v&&yt.createElement(uv,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:g,features:Lp.Focusable}))}let ZR=rn(QR),JR=Object.assign(ZR,{features:hl});function eO(s=!0){let e=j.useRef(yo.slice());return cT(([t],[i])=>{i===!0&&t===!1&&um(()=>{e.current.splice(0)}),i===!1&&t===!0&&(e.current=yo.slice())},[s,yo,e]),li(()=>{var t;return(t=e.current.find(i=>i!=null&&i.isConnected))!=null?t:null})}function tO(s,{ownerDocument:e}){let t=!!(s&8),i=eO(t);cT(()=>{t||Sk(e?.body)&&ya(i())},[t]),uA(()=>{t&&ya(i())})}function iO(s,{ownerDocument:e,container:t,initialFocus:i,initialFocusFallback:n}){let r=j.useRef(null),o=rh(!!(s&1),"focus-trap#initial-focus"),u=dT();return cT(()=>{if(s===0)return;if(!o){n!=null&&n.current&&ya(n.current);return}let c=t.current;c&&um(()=>{if(!u.current)return;let d=e?.activeElement;if(i!=null&&i.current){if(i?.current===d){r.current=d;return}}else if(c.contains(d)){r.current=d;return}if(i!=null&&i.current)ya(i.current);else{if(s&16){if(Od(c,pa.First|pa.AutoFocus)!==dv.Error)return}else if(Od(c,pa.First)!==dv.Error)return;if(n!=null&&n.current&&(ya(n.current),e?.activeElement===n.current))return;console.warn("There are no focusable elements inside the <FocusTrap />")}r.current=e?.activeElement})},[n,o,s]),r}function sO(s,{ownerDocument:e,container:t,containers:i,previousActiveElement:n}){let r=dT(),o=!!(s&4);lA(e?.defaultView,"focus",u=>{if(!o||!r.current)return;let c=gA(i);Sl(t.current)&&c.add(t.current);let d=n.current;if(!d)return;let f=u.target;Sl(f)?yA(c,f)?(n.current=f,ya(f)):(u.preventDefault(),u.stopPropagation(),ya(d)):ya(n.current)},!0)}function yA(s,e){for(let t of s)if(t.contains(e))return!0;return!1}function vA(s){var e;return!!(s.enter||s.enterFrom||s.enterTo||s.leave||s.leaveFrom||s.leaveTo)||!kd((e=s.as)!=null?e:bA)||yt.Children.count(s.children)===1}let pm=j.createContext(null);pm.displayName="TransitionContext";var nO=(s=>(s.Visible="visible",s.Hidden="hidden",s))(nO||{});function rO(){let s=j.useContext(pm);if(s===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return s}function aO(){let s=j.useContext(mm);if(s===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return s}let mm=j.createContext(null);mm.displayName="NestingContext";function gm(s){return"children"in s?gm(s.children):s.current.filter(({el:e})=>e.current!==null).filter(({state:e})=>e==="visible").length>0}function TA(s,e){let t=Dl(s),i=j.useRef([]),n=dT(),r=cm(),o=li((v,b=vo.Hidden)=>{let _=i.current.findIndex(({el:E})=>E===v);_!==-1&&(Ta(b,{[vo.Unmount](){i.current.splice(_,1)},[vo.Hidden](){i.current[_].state="hidden"}}),r.microTask(()=>{var E;!gm(i)&&n.current&&((E=t.current)==null||E.call(t))}))}),u=li(v=>{let b=i.current.find(({el:_})=>_===v);return b?b.state!=="visible"&&(b.state="visible"):i.current.push({el:v,state:"visible"}),()=>o(v,vo.Unmount)}),c=j.useRef([]),d=j.useRef(Promise.resolve()),f=j.useRef({enter:[],leave:[]}),m=li((v,b,_)=>{c.current.splice(0),e&&(e.chains.current[b]=e.chains.current[b].filter(([E])=>E!==v)),e?.chains.current[b].push([v,new Promise(E=>{c.current.push(E)})]),e?.chains.current[b].push([v,new Promise(E=>{Promise.all(f.current[b].map(([w,I])=>I)).then(()=>E())})]),b==="enter"?d.current=d.current.then(()=>e?.wait.current).then(()=>_(b)):_(b)}),g=li((v,b,_)=>{Promise.all(f.current[b].splice(0).map(([E,w])=>w)).then(()=>{var E;(E=c.current.shift())==null||E()}).then(()=>_(b))});return j.useMemo(()=>({children:i,register:u,unregister:o,onStart:m,onStop:g,wait:d,chains:f}),[u,o,i,m,g,f,d])}let bA=j.Fragment,_A=wp.RenderStrategy;function oO(s,e){var t,i;let{transition:n=!0,beforeEnter:r,afterEnter:o,beforeLeave:u,afterLeave:c,enter:d,enterFrom:f,enterTo:m,entered:g,leave:v,leaveFrom:b,leaveTo:_,...E}=s,[w,I]=j.useState(null),L=j.useRef(null),F=vA(s),$=$r(...F?[L,e,I]:e===null?[]:[e]),G=(t=E.unmount)==null||t?vo.Unmount:vo.Hidden,{show:B,appear:V,initial:k}=rO(),[R,z]=j.useState(B?"visible":"hidden"),X=aO(),{register:ee,unregister:le}=X;sn(()=>ee(L),[ee,L]),sn(()=>{if(G===vo.Hidden&&L.current){if(B&&R!=="visible"){z("visible");return}return Ta(R,{hidden:()=>le(L),visible:()=>ee(L)})}},[R,L,ee,le,B,G]);let oe=fm();sn(()=>{if(F&&oe&&R==="visible"&&L.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[L,R,oe,F]);let Y=k&&!V,Z=V&&B&&k,Q=j.useRef(!1),ae=TA(()=>{Q.current||(z("hidden"),le(L))},X),ue=li(Ee=>{Q.current=!0;let je=Ee?"enter":"leave";ae.onStart(L,je,qe=>{qe==="enter"?r?.():qe==="leave"&&u?.()})}),U=li(Ee=>{let je=Ee?"enter":"leave";Q.current=!1,ae.onStop(L,je,qe=>{qe==="enter"?o?.():qe==="leave"&&c?.()}),je==="leave"&&!gm(ae)&&(z("hidden"),le(L))});j.useEffect(()=>{F&&n||(ue(B),U(B))},[B,F,n]);let ie=!(!n||!F||!oe||Y),[,fe]=wR(ie,w,B,{start:ue,end:U}),xe=ul({ref:$,className:((i=lv(E.className,Z&&d,Z&&f,fe.enter&&d,fe.enter&&fe.closed&&f,fe.enter&&!fe.closed&&m,fe.leave&&v,fe.leave&&!fe.closed&&b,fe.leave&&fe.closed&&_,!fe.transition&&B&&g))==null?void 0:i.trim())||void 0,...DR(fe)}),Ae=0;R==="visible"&&(Ae|=er.Open),R==="hidden"&&(Ae|=er.Closed),B&&R==="hidden"&&(Ae|=er.Opening),!B&&R==="visible"&&(Ae|=er.Closing);let $e=Un();return yt.createElement(mm.Provider,{value:ae},yt.createElement(OR,{value:Ae},$e({ourProps:xe,theirProps:E,defaultTag:bA,features:_A,visible:R==="visible",name:"Transition.Child"})))}function lO(s,e){let{show:t,appear:i=!1,unmount:n=!0,...r}=s,o=j.useRef(null),u=vA(s),c=$r(...u?[o,e]:e===null?[]:[e]);fm();let d=hm();if(t===void 0&&d!==null&&(t=(d&er.Open)===er.Open),t===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[f,m]=j.useState(t?"visible":"hidden"),g=TA(()=>{t||m("hidden")}),[v,b]=j.useState(!0),_=j.useRef([t]);sn(()=>{v!==!1&&_.current[_.current.length-1]!==t&&(_.current.push(t),b(!1))},[_,t]);let E=j.useMemo(()=>({show:t,appear:i,initial:v}),[t,i,v]);sn(()=>{t?m("visible"):!gm(g)&&o.current!==null&&m("hidden")},[t,g]);let w={unmount:n},I=li(()=>{var $;v&&b(!1),($=s.beforeEnter)==null||$.call(s)}),L=li(()=>{var $;v&&b(!1),($=s.beforeLeave)==null||$.call(s)}),F=Un();return yt.createElement(mm.Provider,{value:g},yt.createElement(pm.Provider,{value:E},F({ourProps:{...w,as:j.Fragment,children:yt.createElement(xA,{ref:c,...w,...r,beforeEnter:I,beforeLeave:L})},theirProps:{},defaultTag:j.Fragment,features:_A,visible:f==="visible",name:"Transition"})))}function uO(s,e){let t=j.useContext(pm)!==null,i=hm()!==null;return yt.createElement(yt.Fragment,null,!t&&i?yt.createElement(fv,{ref:e,...s}):yt.createElement(xA,{ref:e,...s}))}let fv=rn(lO),xA=rn(oO),hT=rn(uO),pp=Object.assign(fv,{Child:hT,Root:fv});var cO=(s=>(s[s.Open=0]="Open",s[s.Closed=1]="Closed",s))(cO||{}),dO=(s=>(s[s.SetTitleId=0]="SetTitleId",s))(dO||{});let hO={0(s,e){return s.titleId===e.id?s:{...s,titleId:e.id}}},fT=j.createContext(null);fT.displayName="DialogContext";function ym(s){let e=j.useContext(fT);if(e===null){let t=new Error(`<${s} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,ym),t}return e}function fO(s,e){return Ta(e.type,hO,s,e)}let $S=rn(function(s,e){let t=j.useId(),{id:i=`headlessui-dialog-${t}`,open:n,onClose:r,initialFocus:o,role:u="dialog",autoFocus:c=!0,__demoMode:d=!1,unmount:f=!1,...m}=s,g=j.useRef(!1);u=(function(){return u==="dialog"||u==="alertdialog"?u:(g.current||(g.current=!0,console.warn(`Invalid role [${u}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog")})();let v=hm();n===void 0&&v!==null&&(n=(v&er.Open)===er.Open);let b=j.useRef(null),_=$r(b,e),E=uT(b.current),w=n?0:1,[I,L]=j.useReducer(fO,{titleId:null,descriptionId:null,panelRef:j.createRef()}),F=li(()=>r(!1)),$=li(fe=>L({type:0,id:fe})),G=fm()?w===0:!1,[B,V]=HR(),k={get current(){var fe;return(fe=I.panelRef.current)!=null?fe:b.current}},R=mA(),{resolveContainers:z}=KR({mainTreeNode:R,portals:B,defaultContainers:[k]}),X=v!==null?(v&er.Closing)===er.Closing:!1;nR(d||X?!1:G,{allowed:li(()=>{var fe,xe;return[(xe=(fe=b.current)==null?void 0:fe.closest("[data-headlessui-portal]"))!=null?xe:null]}),disallowed:li(()=>{var fe;return[(fe=R?.closest("body > *:not(#headlessui-portal-root)"))!=null?fe:null]})});let ee=sA.get(null);sn(()=>{if(G)return ee.actions.push(i),()=>ee.actions.pop(i)},[ee,i,G]);let le=nA(ee,j.useCallback(fe=>ee.selectors.isTop(fe,i),[ee,i]));gR(le,z,fe=>{fe.preventDefault(),F()}),qR(le,E?.defaultView,fe=>{fe.preventDefault(),fe.stopPropagation(),document.activeElement&&"blur"in document.activeElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur(),F()}),SR(d||X?!1:G,E,z),rR(G,b,F);let[oe,Y]=Fk(),Z=j.useMemo(()=>[{dialogState:w,close:F,setTitleId:$,unmount:f},I],[w,F,$,f,I]),Q=nh({open:w===0}),ae={ref:_,id:i,role:u,tabIndex:-1,"aria-modal":d?void 0:w===0?!0:void 0,"aria-labelledby":I.titleId,"aria-describedby":oe,unmount:f},ue=!zR(),U=hl.None;G&&!d&&(U|=hl.RestoreFocus,U|=hl.TabLock,c&&(U|=hl.AutoFocus),ue&&(U|=hl.InitialFocus));let ie=Un();return yt.createElement(PR,null,yt.createElement(FS,{force:!0},yt.createElement(VR,null,yt.createElement(fT.Provider,{value:Z},yt.createElement(fA,{target:b},yt.createElement(FS,{force:!1},yt.createElement(Y,{slot:Q},yt.createElement(V,null,yt.createElement(JR,{initialFocus:o,initialFocusFallback:b,containers:z,features:U},yt.createElement(Vk,{value:F},ie({ourProps:ae,theirProps:m,slot:Q,defaultTag:pO,features:mO,visible:w===0,name:"Dialog"})))))))))))}),pO="div",mO=wp.RenderStrategy|wp.Static;function gO(s,e){let{transition:t=!1,open:i,...n}=s,r=hm(),o=s.hasOwnProperty("open")||r!==null,u=s.hasOwnProperty("onClose");if(!o&&!u)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!o)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!u)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if(!r&&typeof s.open!="boolean")throw new Error(`You provided an \`open\` prop to the \`Dialog\`, but the value is not a boolean. Received: ${s.open}`);if(typeof s.onClose!="function")throw new Error(`You provided an \`onClose\` prop to the \`Dialog\`, but the value is not a function. Received: ${s.onClose}`);return(i!==void 0||t)&&!n.static?yt.createElement(US,null,yt.createElement(pp,{show:i,transition:t,unmount:n.unmount},yt.createElement($S,{ref:e,...n}))):yt.createElement(US,null,yt.createElement($S,{ref:e,open:i,...n}))}let yO="div";function vO(s,e){let t=j.useId(),{id:i=`headlessui-dialog-panel-${t}`,transition:n=!1,...r}=s,[{dialogState:o,unmount:u},c]=ym("Dialog.Panel"),d=$r(e,c.panelRef),f=nh({open:o===0}),m=li(E=>{E.stopPropagation()}),g={ref:d,id:i,onClick:m},v=n?hT:j.Fragment,b=n?{unmount:u}:{},_=Un();return yt.createElement(v,{...b},_({ourProps:g,theirProps:r,slot:f,defaultTag:yO,name:"Dialog.Panel"}))}let TO="div";function bO(s,e){let{transition:t=!1,...i}=s,[{dialogState:n,unmount:r}]=ym("Dialog.Backdrop"),o=nh({open:n===0}),u={ref:e,"aria-hidden":!0},c=t?hT:j.Fragment,d=t?{unmount:r}:{},f=Un();return yt.createElement(c,{...d},f({ourProps:u,theirProps:i,slot:o,defaultTag:TO,name:"Dialog.Backdrop"}))}let _O="h2";function xO(s,e){let t=j.useId(),{id:i=`headlessui-dialog-title-${t}`,...n}=s,[{dialogState:r,setTitleId:o}]=ym("Dialog.Title"),u=$r(e);j.useEffect(()=>(o(i),()=>o(null)),[i,o]);let c=nh({open:r===0}),d={ref:u,id:i};return Un()({ourProps:d,theirProps:n,slot:c,defaultTag:_O,name:"Dialog.Title"})}let SO=rn(gO),EO=rn(vO);rn(bO);let AO=rn(xO),Mu=Object.assign(SO,{Panel:EO,Title:AO,Description:Hk});function CO({open:s,onClose:e,onApply:t,initialCookies:i}){const[n,r]=j.useState(""),[o,u]=j.useState(""),[c,d]=j.useState([]),f=j.useRef(!1);j.useEffect(()=>{s&&!f.current&&(r(""),u(""),d(i??[])),f.current=s},[s,i]);function m(){const b=n.trim(),_=o.trim();!b||!_||(d(E=>[...E.filter(I=>I.name!==b),{name:b,value:_}]),r(""),u(""))}function g(b){d(_=>_.filter(E=>E.name!==b))}function v(){t(c),e()}return P.jsxs(Mu,{open:s,onClose:e,className:"relative z-50",children:[P.jsx("div",{className:"fixed inset-0 bg-black/40","aria-hidden":"true"}),P.jsx("div",{className:"fixed inset-0 flex items-center justify-center p-4",children:P.jsxs(Mu.Panel,{className:"w-full max-w-lg rounded-lg bg-white dark:bg-gray-800 p-6 shadow-xl dark:outline dark:-outline-offset-1 dark:outline-white/10",children:[P.jsx(Mu.Title,{className:"text-base font-semibold text-gray-900 dark:text-white",children:"Zusätzliche Cookies"}),P.jsxs("div",{className:"mt-4 grid grid-cols-1 sm:grid-cols-3 gap-2",children:[P.jsx("input",{value:n,onChange:b=>r(b.target.value),placeholder:"Name (z. B. cf_clearance)",className:"col-span-1 rounded-md px-3 py-2 text-sm bg-white text-gray-900 dark:bg-white/10 dark:text-white"}),P.jsx("input",{value:o,onChange:b=>u(b.target.value),placeholder:"Wert",className:"col-span-1 sm:col-span-2 rounded-md px-3 py-2 text-sm bg-white text-gray-900 dark:bg-white/10 dark:text-white"})]}),P.jsx("div",{className:"mt-2",children:P.jsx(es,{size:"sm",variant:"secondary",onClick:m,disabled:!n.trim()||!o.trim(),children:"Hinzufügen"})}),P.jsx("div",{className:"mt-4",children:c.length===0?P.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Noch keine Cookies hinzugefügt."}):P.jsxs("table",{className:"min-w-full text-sm border divide-y dark:divide-white/10",children:[P.jsx("thead",{className:"bg-gray-50 dark:bg-gray-700/50",children:P.jsxs("tr",{children:[P.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Name"}),P.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Wert"}),P.jsx("th",{className:"px-3 py-2"})]})}),P.jsx("tbody",{className:"divide-y dark:divide-white/10",children:c.map(b=>P.jsxs("tr",{children:[P.jsx("td",{className:"px-3 py-2 font-mono",children:b.name}),P.jsx("td",{className:"px-3 py-2 truncate max-w-[240px]",children:b.value}),P.jsx("td",{className:"px-3 py-2 text-right",children:P.jsx("button",{onClick:()=>g(b.name),className:"text-xs text-red-600 hover:underline dark:text-red-400",children:"Entfernen"})})]},b.name))})]})}),P.jsxs("div",{className:"mt-6 flex justify-end gap-2",children:[P.jsx(es,{variant:"secondary",onClick:e,children:"Abbrechen"}),P.jsx(es,{variant:"primary",onClick:v,children:"Übernehmen"})]})]})})]})}function Pn({header:s,footer:e,grayBody:t=!1,grayFooter:i=!1,edgeToEdgeMobile:n=!1,well:r=!1,noBodyPadding:o=!1,className:u,bodyClassName:c,children:d}){const f=r;return P.jsxs("div",{className:Ut("overflow-hidden",n?"sm:rounded-lg":"rounded-lg",f?"bg-gray-50 dark:bg-gray-800 shadow-none":"bg-white shadow-sm dark:bg-gray-800 dark:shadow-none dark:outline dark:-outline-offset-1 dark:outline-white/10",u),children:[s&&P.jsx("div",{className:"shrink-0 px-4 py-5 sm:px-6 border-b border-gray-200 dark:border-white/10",children:s}),P.jsx("div",{className:Ut("min-h-0",o?"p-0":"px-4 py-5 sm:p-6",t&&"bg-gray-50 dark:bg-gray-800",c),children:d}),e&&P.jsx("div",{className:Ut("shrink-0 px-4 py-4 sm:px-6",i&&"bg-gray-50 dark:bg-gray-800/50","border-t border-gray-200 dark:border-white/10"),children:e})]})}function DO({title:s,titleId:e,...t},i){return j.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?j.createElement("title",{id:e},s):null,j.createElement("path",{fillRule:"evenodd",d:"M4.22 6.22a.75.75 0 0 1 1.06 0L8 8.94l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L4.22 7.28a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"}))}const wO=j.forwardRef(DO);function LO({tabs:s,value:e,onChange:t,className:i,ariaLabel:n="Ansicht auswählen",variant:r="underline",hideCountUntilMd:o=!1}){if(!s?.length)return null;const u=s.find(g=>g.id===e)??s[0],c=Ut("col-start-1 row-start-1 w-full appearance-none rounded-md bg-white py-2 pr-8 pl-3 text-base text-gray-900 outline-1 -outline-offset-1 outline-gray-300 focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600 dark:text-gray-100 dark:outline-white/10 dark:*:bg-gray-800 dark:focus:outline-indigo-500",r==="pillsBrand"?"dark:bg-gray-800/50":"dark:bg-white/5"),d=g=>Ut(g?"bg-indigo-100 text-indigo-600 dark:bg-indigo-500/20 dark:text-indigo-400":"bg-gray-100 text-gray-900 dark:bg-white/10 dark:text-gray-300",o?"ml-3 hidden rounded-full px-2.5 py-0.5 text-xs font-medium md:inline-block":"ml-3 rounded-full px-2.5 py-0.5 text-xs font-medium"),f=(g,v)=>v.count===void 0?null:P.jsx("span",{className:d(g),children:v.count}),m=()=>{switch(r){case"underline":case"underlineIcons":return P.jsx("div",{className:"border-b border-gray-200 dark:border-white/10",children:P.jsx("nav",{"aria-label":n,className:"-mb-px flex space-x-8",children:s.map(g=>{const v=g.id===u.id,b=!!g.disabled;return P.jsxs("button",{type:"button",onClick:()=>!b&&t(g.id),disabled:b,"aria-current":v?"page":void 0,className:Ut(v?"border-indigo-500 text-indigo-600 dark:border-indigo-400 dark:text-indigo-400":"border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 dark:text-gray-400 dark:hover:border-white/20 dark:hover:text-gray-200",r==="underlineIcons"?"group inline-flex items-center border-b-2 px-1 py-4 text-sm font-medium":"flex items-center border-b-2 px-1 py-4 text-sm font-medium whitespace-nowrap",b&&"cursor-not-allowed opacity-50 hover:border-transparent hover:text-gray-500 dark:hover:text-gray-400"),children:[r==="underlineIcons"&&g.icon?P.jsx(g.icon,{"aria-hidden":"true",className:Ut(v?"text-indigo-500 dark:text-indigo-400":"text-gray-400 group-hover:text-gray-500 dark:text-gray-500 dark:group-hover:text-gray-400","mr-2 -ml-0.5 size-5")}):null,P.jsx("span",{children:g.label}),f(v,g)]},g.id)})})});case"pills":case"pillsGray":case"pillsBrand":{const g=r==="pills"?"bg-gray-100 text-gray-700 dark:bg-white/10 dark:text-gray-200":r==="pillsGray"?"bg-gray-200 text-gray-800 dark:bg-white/10 dark:text-white":"bg-indigo-100 text-indigo-700 dark:bg-indigo-500/20 dark:text-indigo-300",v=r==="pills"?"text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200":r==="pillsGray"?"text-gray-600 hover:text-gray-800 dark:text-gray-400 dark:hover:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200";return P.jsx("nav",{"aria-label":n,className:"flex space-x-4",children:s.map(b=>{const _=b.id===u.id,E=!!b.disabled;return P.jsxs("button",{type:"button",onClick:()=>!E&&t(b.id),disabled:E,"aria-current":_?"page":void 0,className:Ut(_?g:v,"inline-flex items-center rounded-md px-3 py-2 text-sm font-medium",E&&"cursor-not-allowed opacity-50 hover:text-inherit"),children:[P.jsx("span",{children:b.label}),b.count!==void 0?P.jsx("span",{className:Ut(_?"ml-2 bg-white/70 text-gray-900 dark:bg-white/10 dark:text-white":"ml-2 bg-gray-100 text-gray-900 dark:bg-white/10 dark:text-gray-300","rounded-full px-2 py-0.5 text-xs font-medium"),children:b.count}):null]},b.id)})})}case"fullWidthUnderline":return P.jsx("div",{className:"border-b border-gray-200 dark:border-white/10",children:P.jsx("nav",{"aria-label":n,className:"-mb-px flex",children:s.map(g=>{const v=g.id===u.id,b=!!g.disabled;return P.jsx("button",{type:"button",onClick:()=>!b&&t(g.id),disabled:b,"aria-current":v?"page":void 0,className:Ut(v?"border-indigo-500 text-indigo-600 dark:border-indigo-400 dark:text-indigo-400":"border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 dark:text-gray-400 dark:hover:border-white/20 dark:hover:text-gray-300","flex-1 border-b-2 px-1 py-4 text-center text-sm font-medium",b&&"cursor-not-allowed opacity-50 hover:border-transparent hover:text-gray-500 dark:hover:text-gray-400"),children:g.label},g.id)})})});case"barUnderline":return P.jsx("nav",{"aria-label":n,className:"isolate flex divide-x divide-gray-200 rounded-lg bg-white shadow-sm dark:divide-white/10 dark:bg-gray-800/50 dark:shadow-none dark:outline dark:-outline-offset-1 dark:outline-white/10",children:s.map((g,v)=>{const b=g.id===u.id,_=!!g.disabled;return P.jsxs("button",{type:"button",onClick:()=>!_&&t(g.id),disabled:_,"aria-current":b?"page":void 0,className:Ut(b?"text-gray-900 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-white",v===0?"rounded-l-lg":"",v===s.length-1?"rounded-r-lg":"","group relative min-w-0 flex-1 overflow-hidden px-4 py-4 text-center text-sm font-medium hover:bg-gray-50 focus:z-10 dark:hover:bg-white/5",_&&"cursor-not-allowed opacity-50 hover:bg-transparent hover:text-gray-500 dark:hover:text-gray-400"),children:[P.jsxs("span",{className:"inline-flex items-center justify-center",children:[g.label,g.count!==void 0?P.jsx("span",{className:"ml-2 rounded-full bg-white/70 px-2 py-0.5 text-xs font-medium text-gray-900 dark:bg-white/10 dark:text-white",children:g.count}):null]}),P.jsx("span",{"aria-hidden":"true",className:Ut(b?"bg-indigo-500 dark:bg-indigo-400":"bg-transparent","absolute inset-x-0 bottom-0 h-0.5")})]},g.id)})});case"simple":return P.jsx("nav",{className:"flex border-b border-gray-200 py-4 dark:border-white/10","aria-label":n,children:P.jsx("ul",{role:"list",className:"flex min-w-full flex-none gap-x-8 px-2 text-sm/6 font-semibold text-gray-500 dark:text-gray-400",children:s.map(g=>{const v=g.id===u.id,b=!!g.disabled;return P.jsx("li",{children:P.jsx("button",{type:"button",onClick:()=>!b&&t(g.id),disabled:b,"aria-current":v?"page":void 0,className:Ut(v?"text-indigo-600 dark:text-indigo-400":"hover:text-gray-700 dark:hover:text-white",b&&"cursor-not-allowed opacity-50 hover:text-inherit"),children:g.label})},g.id)})})});default:return null}};return P.jsxs("div",{className:i,children:[P.jsxs("div",{className:"grid grid-cols-1 sm:hidden",children:[P.jsx("select",{value:u.id,onChange:g=>t(g.target.value),"aria-label":n,className:c,children:s.map(g=>P.jsx("option",{value:g.id,children:g.label},g.id))}),P.jsx(wO,{"aria-hidden":"true",className:"pointer-events-none col-start-1 row-start-1 mr-2 size-5 self-center justify-self-end fill-gray-500 dark:fill-gray-400"})]}),P.jsx("div",{className:"hidden sm:block",children:m()})]})}function jS({checked:s,onChange:e,id:t,name:i,disabled:n,required:r,ariaLabel:o,ariaLabelledby:u,ariaDescribedby:c,size:d="default",variant:f="simple",className:m}){const g=b=>{n||e(b.target.checked)},v=Ut("absolute inset-0 size-full appearance-none focus:outline-hidden",n&&"cursor-not-allowed");return d==="short"?P.jsxs("div",{className:Ut("group relative inline-flex h-5 w-10 shrink-0 items-center justify-center rounded-full outline-offset-2 outline-indigo-600 has-focus-visible:outline-2 dark:outline-indigo-500",n&&"opacity-60",m),children:[P.jsx("span",{className:Ut("absolute mx-auto h-4 w-9 rounded-full bg-gray-200 inset-ring inset-ring-gray-900/5 transition-colors duration-200 ease-in-out dark:bg-gray-800/50 dark:inset-ring-white/10",s&&"bg-indigo-600 dark:bg-indigo-500")}),P.jsx("span",{className:Ut("absolute left-0 size-5 rounded-full border border-gray-300 bg-white shadow-xs transition-transform duration-200 ease-in-out dark:shadow-none",s&&"translate-x-5")}),P.jsx("input",{id:t,name:i,type:"checkbox",checked:s,onChange:g,disabled:n,required:r,"aria-label":o,"aria-labelledby":u,"aria-describedby":c,className:v})]}):P.jsxs("div",{className:Ut("group relative inline-flex w-11 shrink-0 rounded-full bg-gray-200 p-0.5 inset-ring inset-ring-gray-900/5 outline-offset-2 outline-indigo-600 transition-colors duration-200 ease-in-out has-focus-visible:outline-2 dark:bg-white/5 dark:inset-ring-white/10 dark:outline-indigo-500",s&&"bg-indigo-600 dark:bg-indigo-500",n&&"opacity-60",m),children:[f==="icon"?P.jsxs("span",{className:Ut("relative size-5 rounded-full bg-white shadow-xs ring-1 ring-gray-900/5 transition-transform duration-200 ease-in-out",s&&"translate-x-5"),children:[P.jsx("span",{"aria-hidden":"true",className:Ut("absolute inset-0 flex size-full items-center justify-center transition-opacity ease-in",s?"opacity-0 duration-100":"opacity-100 duration-200"),children:P.jsx("svg",{fill:"none",viewBox:"0 0 12 12",className:"size-3 text-gray-400 dark:text-gray-600",children:P.jsx("path",{d:"M4 8l2-2m0 0l2-2M6 6L4 4m2 2l2 2",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})})}),P.jsx("span",{"aria-hidden":"true",className:Ut("absolute inset-0 flex size-full items-center justify-center transition-opacity ease-out",s?"opacity-100 duration-200":"opacity-0 duration-100"),children:P.jsx("svg",{fill:"currentColor",viewBox:"0 0 12 12",className:"size-3 text-indigo-600 dark:text-indigo-500",children:P.jsx("path",{d:"M3.707 5.293a1 1 0 00-1.414 1.414l1.414-1.414zM5 8l-.707.707a1 1 0 001.414 0L5 8zm4.707-3.293a1 1 0 00-1.414-1.414l1.414 1.414zm-7.414 2l2 2 1.414-1.414-2-2-1.414 1.414zm3.414 2l4-4-1.414-1.414-4 4 1.414 1.414z"})})})]}):P.jsx("span",{className:Ut("size-5 rounded-full bg-white shadow-xs ring-1 ring-gray-900/5 transition-transform duration-200 ease-in-out",s&&"translate-x-5")}),P.jsx("input",{id:t,name:i,type:"checkbox",checked:s,onChange:g,disabled:n,required:r,"aria-label":o,"aria-labelledby":u,"aria-describedby":c,className:v})]})}function jf({label:s,description:e,labelPosition:t="left",id:i,className:n,...r}){const o=j.useId(),u=i??`sw-${o}`,c=`${u}-label`,d=`${u}-desc`;return t==="right"?P.jsxs("div",{className:Ut("flex items-center justify-between gap-3",n),children:[P.jsx(jS,{...r,id:u,ariaLabelledby:c,ariaDescribedby:e?d:void 0}),P.jsxs("div",{className:"text-sm",children:[P.jsx("label",{id:c,htmlFor:u,className:"font-medium text-gray-900 dark:text-white",children:s})," ",e?P.jsx("span",{id:d,className:"text-gray-500 dark:text-gray-400",children:e}):null]})]}):P.jsxs("div",{className:Ut("flex items-center justify-between",n),children:[P.jsxs("span",{className:"flex grow flex-col",children:[P.jsx("label",{id:c,htmlFor:u,className:"text-sm/6 font-medium text-gray-900 dark:text-white",children:s}),e?P.jsx("span",{id:d,className:"text-sm text-gray-500 dark:text-gray-400",children:e}):null]}),P.jsx(jS,{...r,id:u,ariaLabelledby:c,ariaDescribedby:e?d:void 0})]})}const ro={recordDir:"records",doneDir:"records/done",ffmpegPath:"",autoAddToDownloadList:!0,autoStartAddedDownloads:!0,useChaturbateApi:!1,blurPreviews:!1};function IO(){const[s,e]=j.useState(ro),[t,i]=j.useState(!1),[n,r]=j.useState(null),[o,u]=j.useState(null),[c,d]=j.useState(null);j.useEffect(()=>{let g=!0;return fetch("/api/settings",{cache:"no-store"}).then(async v=>{if(!v.ok)throw new Error(await v.text());return v.json()}).then(v=>{g&&e({recordDir:(v.recordDir||ro.recordDir).toString(),doneDir:(v.doneDir||ro.doneDir).toString(),ffmpegPath:String(v.ffmpegPath??ro.ffmpegPath??""),autoAddToDownloadList:v.autoAddToDownloadList??ro.autoAddToDownloadList,autoStartAddedDownloads:v.autoStartAddedDownloads??ro.autoStartAddedDownloads,useChaturbateApi:v.useChaturbateApi??ro.useChaturbateApi,blurPreviews:v.blurPreviews??ro.blurPreviews})}).catch(()=>{}),()=>{g=!1}},[]);async function f(g){d(null),u(null),r(g);try{window.focus();const v=await fetch(`/api/settings/browse?target=${g}`,{cache:"no-store"});if(v.status===204)return;if(!v.ok){const E=await v.text().catch(()=>"");throw new Error(E||`HTTP ${v.status}`)}const _=((await v.json()).path??"").trim();if(!_)return;e(E=>g==="record"?{...E,recordDir:_}:g==="done"?{...E,doneDir:_}:{...E,ffmpegPath:_})}catch(v){d(v?.message??String(v))}finally{r(null)}}async function m(){d(null),u(null);const g=s.recordDir.trim(),v=s.doneDir.trim(),b=(s.ffmpegPath??"").trim();if(!g||!v){d("Bitte Aufnahme-Ordner und Ziel-Ordner angeben.");return}const _=!!s.autoAddToDownloadList,E=_?!!s.autoStartAddedDownloads:!1,w=!!s.useChaturbateApi,I=!!s.blurPreviews;i(!0);try{const L=await fetch("/api/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({recordDir:g,doneDir:v,ffmpegPath:b,autoAddToDownloadList:_,autoStartAddedDownloads:E,useChaturbateApi:w,blurPreviews:I})});if(!L.ok){const F=await L.text().catch(()=>"");throw new Error(F||`HTTP ${L.status}`)}u("✅ Gespeichert."),window.dispatchEvent(new CustomEvent("recorder-settings-updated"))}catch(L){d(L?.message??String(L))}finally{i(!1)}}return P.jsx(Pn,{header:P.jsxs("div",{className:"flex items-center justify-between gap-4",children:[P.jsx("div",{children:P.jsx("div",{className:"text-base font-semibold text-gray-900 dark:text-white",children:"Einstellungen"})}),P.jsx(es,{variant:"primary",onClick:m,disabled:t,children:"Speichern"})]}),grayBody:!0,children:P.jsxs("div",{className:"space-y-4",children:[c&&P.jsx("div",{className:"rounded-md bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-500/10 dark:text-red-200",children:c}),o&&P.jsx("div",{className:"rounded-md bg-green-50 px-3 py-2 text-sm text-green-700 dark:bg-green-500/10 dark:text-green-200",children:o}),P.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-12 sm:items-center",children:[P.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-200 sm:col-span-3",children:"Aufnahme-Ordner"}),P.jsxs("div",{className:"sm:col-span-9 flex gap-2",children:[P.jsx("input",{value:s.recordDir,onChange:g=>e(v=>({...v,recordDir:g.target.value})),placeholder:"records (oder absolut: C:\\records / /mnt/data/records)",className:`min-w-0 flex-1 rounded-md px-3 py-2 text-sm bg-white text-gray-900
dark:bg-white/10 dark:text-white`}),P.jsx(es,{variant:"secondary",onClick:()=>f("record"),disabled:t||n!==null,children:"Durchsuchen..."})]})]}),P.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-12 sm:items-center",children:[P.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-200 sm:col-span-3",children:"Fertige Downloads nach"}),P.jsxs("div",{className:"sm:col-span-9 flex gap-2",children:[P.jsx("input",{value:s.doneDir,onChange:g=>e(v=>({...v,doneDir:g.target.value})),placeholder:"records/done",className:`min-w-0 flex-1 rounded-md px-3 py-2 text-sm bg-white text-gray-900
dark:bg-white/10 dark:text-white`}),P.jsx(es,{variant:"secondary",onClick:()=>f("done"),disabled:t||n!==null,children:"Durchsuchen..."})]})]}),P.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-12 sm:items-center",children:[P.jsx("label",{className:"text-sm font-medium text-gray-900 dark:text-gray-200 sm:col-span-3",children:"ffmpeg.exe"}),P.jsxs("div",{className:"sm:col-span-9 flex gap-2",children:[P.jsx("input",{value:s.ffmpegPath??"",onChange:g=>e(v=>({...v,ffmpegPath:g.target.value})),placeholder:"Leer = automatisch (FFMPEG_PATH / ffmpeg im PATH)",className:`min-w-0 flex-1 rounded-md px-3 py-2 text-sm bg-white text-gray-900
dark:bg-white/10 dark:text-white`}),P.jsx(es,{variant:"secondary",onClick:()=>f("ffmpeg"),disabled:t||n!==null,children:"Durchsuchen..."})]})]}),P.jsx("div",{className:"mt-2 border-t border-gray-200 pt-4 dark:border-white/10",children:P.jsxs("div",{className:"space-y-3",children:[P.jsx(jf,{checked:!!s.autoAddToDownloadList,onChange:g=>e(v=>({...v,autoAddToDownloadList:g,autoStartAddedDownloads:g?v.autoStartAddedDownloads:!1})),label:"Automatisch zur Downloadliste hinzufügen",description:"Neue Links/Modelle werden automatisch in die Downloadliste übernommen."}),P.jsx(jf,{checked:!!s.autoStartAddedDownloads,onChange:g=>e(v=>({...v,autoStartAddedDownloads:g})),disabled:!s.autoAddToDownloadList,label:"Hinzugefügte Downloads automatisch starten",description:"Wenn ein Download hinzugefügt wurde, startet er direkt (sofern möglich)."}),P.jsx(jf,{checked:!!s.useChaturbateApi,onChange:g=>e(v=>({...v,useChaturbateApi:g})),label:"Chaturbate API",description:"Wenn aktiv, pollt das Backend alle paar Sekunden die Online-Rooms API und cached die aktuell online Models."}),P.jsx(jf,{checked:!!s.blurPreviews,onChange:g=>e(v=>({...v,blurPreviews:g})),label:"Vorschaubilder blurren",description:"Weichzeichnet Vorschaubilder/Teaser (praktisch auf mobilen Geräten oder im öffentlichen Umfeld)."})]})})]})})}function kO({title:s,titleId:e,...t},i){return j.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?j.createElement("title",{id:e},s):null,j.createElement("path",{fillRule:"evenodd",d:"M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"}))}const RO=j.forwardRef(kO);function OO({title:s,titleId:e,...t},i){return j.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?j.createElement("title",{id:e},s):null,j.createElement("path",{fillRule:"evenodd",d:"M11.78 5.22a.75.75 0 0 1 0 1.06L8.06 10l3.72 3.72a.75.75 0 1 1-1.06 1.06l-4.25-4.25a.75.75 0 0 1 0-1.06l4.25-4.25a.75.75 0 0 1 1.06 0Z",clipRule:"evenodd"}))}const PO=j.forwardRef(OO);function MO({title:s,titleId:e,...t},i){return j.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?j.createElement("title",{id:e},s):null,j.createElement("path",{fillRule:"evenodd",d:"M8.22 5.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L11.94 10 8.22 6.28a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"}))}const NO=j.forwardRef(MO);function Xs(...s){return s.filter(Boolean).join(" ")}function HS(s){return s==="center"?"text-center":s==="right"?"text-right":"text-left"}function BO(s){return s==="center"?"justify-center":s==="right"?"justify-end":"justify-start"}function GS(s){return s==null?{isNull:!0,kind:"string",value:""}:s instanceof Date?{isNull:!1,kind:"number",value:s.getTime()}:typeof s=="number"?{isNull:!1,kind:"number",value:s}:typeof s=="boolean"?{isNull:!1,kind:"number",value:s?1:0}:typeof s=="bigint"?{isNull:!1,kind:"number",value:Number(s)}:{isNull:!1,kind:"string",value:String(s).toLocaleLowerCase()}}function vm({columns:s,rows:e,getRowKey:t,title:i,description:n,actions:r,fullWidth:o=!1,card:u=!0,striped:c=!1,stickyHeader:d=!1,compact:f=!1,isLoading:m=!1,emptyLabel:g="Keine Daten vorhanden.",className:v,rowClassName:b,onRowClick:_,onRowContextMenu:E,sort:w,onSortChange:I,defaultSort:L=null}){const F=f?"py-2":"py-4",$=f?"py-3":"py-3.5",G=w!==void 0,[B,V]=j.useState(L),k=G?w:B,R=j.useCallback(X=>{G||V(X),I?.(X)},[G,I]),z=j.useMemo(()=>{if(!k)return e;const X=s.find(oe=>oe.key===k.key);if(!X)return e;const ee=k.direction==="asc"?1:-1,le=e.map((oe,Y)=>({r:oe,i:Y}));return le.sort((oe,Y)=>{let Z=0;if(X.sortFn)Z=X.sortFn(oe.r,Y.r);else{const Q=X.sortValue?X.sortValue(oe.r):oe.r?.[X.key],ae=X.sortValue?X.sortValue(Y.r):Y.r?.[X.key],ue=GS(Q),U=GS(ae);ue.isNull&&!U.isNull?Z=1:!ue.isNull&&U.isNull?Z=-1:ue.kind==="number"&&U.kind==="number"?Z=ue.value<U.value?-1:ue.value>U.value?1:0:Z=String(ue.value).localeCompare(String(U.value),void 0,{numeric:!0})}return Z===0?oe.i-Y.i:Z*ee}),le.map(oe=>oe.r)},[e,s,k]);return P.jsxs("div",{className:Xs(o?"":"px-4 sm:px-6 lg:px-8",v),children:[(i||n||r)&&P.jsxs("div",{className:"sm:flex sm:items-center",children:[P.jsxs("div",{className:"sm:flex-auto",children:[i&&P.jsx("h1",{className:"text-base font-semibold text-gray-900 dark:text-white",children:i}),n&&P.jsx("p",{className:"mt-2 text-sm text-gray-700 dark:text-gray-300",children:n})]}),r&&P.jsx("div",{className:"mt-4 sm:mt-0 sm:ml-16 sm:flex-none",children:r})]}),P.jsx("div",{className:Xs(i||n||r?"mt-8":""),children:P.jsx("div",{className:"flow-root",children:P.jsx("div",{className:"overflow-x-auto",children:P.jsx("div",{className:Xs("inline-block min-w-full py-2 align-middle",o?"":"sm:px-6 lg:px-8"),children:P.jsx("div",{className:Xs(u&&"overflow-hidden shadow-sm outline-1 outline-black/5 sm:rounded-lg dark:shadow-none dark:-outline-offset-1 dark:outline-white/10"),children:P.jsxs("table",{className:"relative min-w-full divide-y divide-gray-200 dark:divide-white/10",children:[P.jsx("thead",{className:Xs(u&&"bg-gray-50/90 dark:bg-gray-800/70",d&&"sticky top-0 z-10 backdrop-blur-sm shadow-sm"),children:P.jsx("tr",{children:s.map(X=>{const ee=!!k&&k.key===X.key,le=ee?k.direction:void 0,oe=X.sortable&&!X.srOnlyHeader?ee?le==="asc"?"ascending":"descending":"none":void 0,Y=()=>{if(!(!X.sortable||X.srOnlyHeader))return R(ee?le==="asc"?{key:X.key,direction:"desc"}:null:{key:X.key,direction:"asc"})};return P.jsx("th",{scope:"col","aria-sort":oe,className:Xs($,"px-3 text-xs font-semibold tracking-wide text-gray-700 dark:text-gray-200 whitespace-nowrap",HS(X.align),X.widthClassName,X.headerClassName),children:X.srOnlyHeader?P.jsx("span",{className:"sr-only",children:X.header}):X.sortable?P.jsxs("button",{type:"button",onClick:Y,className:Xs("group inline-flex w-full items-center gap-2 select-none rounded-md px-1.5 py-1 -my-1 hover:bg-gray-100/70 dark:hover:bg-white/5",BO(X.align)),children:[P.jsx("span",{children:X.header}),P.jsx("span",{className:Xs("flex-none rounded-sm text-gray-400 dark:text-gray-500",ee?"bg-gray-100 text-gray-900 dark:bg-gray-800 dark:text-white":"invisible group-hover:visible group-focus-visible:visible"),children:P.jsx(RO,{"aria-hidden":"true",className:Xs("size-5 transition-transform",ee&&le==="asc"&&"rotate-180")})})]}):X.header},X.key)})})}),P.jsx("tbody",{className:Xs("divide-y divide-gray-200 dark:divide-white/10",u?"bg-white dark:bg-gray-800/50":"bg-white dark:bg-gray-900"),children:m?P.jsx("tr",{children:P.jsx("td",{colSpan:s.length,className:Xs(F,"px-3 text-sm text-gray-500 dark:text-gray-400"),children:"Lädt…"})}):z.length===0?P.jsx("tr",{children:P.jsx("td",{colSpan:s.length,className:Xs(F,"px-3 text-sm text-gray-500 dark:text-gray-400"),children:g})}):z.map((X,ee)=>{const le=t?t(X,ee):String(ee);return P.jsx("tr",{className:Xs(c&&"even:bg-gray-50 dark:even:bg-gray-800/50",_&&"cursor-pointer",_&&"hover:bg-gray-50 dark:hover:bg-white/5 transition-colors",b?.(X,ee)),onClick:()=>_?.(X),onContextMenu:E?oe=>{oe.preventDefault(),E(X,oe)}:void 0,children:s.map(oe=>{const Y=oe.cell?.(X,ee)??oe.accessor?.(X)??X?.[oe.key];return P.jsx("td",{className:Xs(F,"px-3 text-sm whitespace-nowrap",HS(oe.align),oe.className,oe.key===s[0]?.key?"font-medium text-gray-900 dark:text-white":"text-gray-500 dark:text-gray-400"),children:Y},oe.key)})},le)})})]})})})})})})]})}function SA({children:s,content:e}){const t=j.useRef(null),i=j.useRef(null),[n,r]=j.useState(!1),[o,u]=j.useState(null),c=j.useRef(null),d=()=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null)},f=()=>{d(),c.current=window.setTimeout(()=>{r(!1),c.current=null},150)},m=()=>{d(),r(!0)},g=()=>{f()},v=()=>{d(),r(!1)},b=()=>{const E=t.current,w=i.current;if(!E||!w)return;const I=8,L=8,F=E.getBoundingClientRect(),$=w.getBoundingClientRect();let G=F.bottom+I;if(G+$.height>window.innerHeight-L){const k=F.top-$.height-I;k>=L?G=k:G=Math.max(L,window.innerHeight-$.height-L)}let V=F.left;V+$.width>window.innerWidth-L&&(V=window.innerWidth-$.width-L),V=Math.max(L,V),u({left:V,top:G})};j.useLayoutEffect(()=>{if(!n)return;const E=requestAnimationFrame(()=>b());return()=>cancelAnimationFrame(E)},[n]),j.useEffect(()=>{if(!n)return;const E=()=>requestAnimationFrame(()=>b());return window.addEventListener("resize",E),window.addEventListener("scroll",E,!0),()=>{window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[n]),j.useEffect(()=>()=>d(),[]);const _=()=>typeof e=="function"?e(n,{close:v}):e;return P.jsxs(P.Fragment,{children:[P.jsx("div",{ref:t,className:"inline-flex",onMouseEnter:m,onMouseLeave:g,children:s}),n&&ih.createPortal(P.jsx("div",{ref:i,className:"fixed z-50",style:{left:o?.left??-9999,top:o?.top??-9999,visibility:o?"visible":"hidden"},onMouseEnter:m,onMouseLeave:g,children:P.jsx(Pn,{className:"shadow-lg ring-1 ring-black/10 dark:ring-white/10 max-w-[calc(100vw-16px)]",noBodyPadding:!0,children:_()})}),document.body)]})}function X0({job:s,getFileName:e,durationSeconds:t,onDuration:i,animated:n=!1,animatedMode:r="frames",animatedTrigger:o="always",autoTickMs:u=15e3,thumbStepSec:c,thumbSpread:d,thumbSamples:f,clipSeconds:m=1,variant:g="thumb",className:v,showPopover:b=!0,blur:_=!1,inlineVideo:E=!1,inlineNonce:w=0,inlineControls:I=!1,inlineLoop:L=!0}){const F=e(s.output||""),$=_?"blur-md":"",[G,B]=j.useState(!0),[V,k]=j.useState(!0),[R,z]=j.useState(!1),X=j.useRef(null),[ee,le]=j.useState(!1),[oe,Y]=j.useState(0),[Z,Q]=j.useState(!1),ae=E===!0||E==="always"?"always":E==="hover"?"hover":"never",ue=j.useMemo(()=>{if(!F)return"";const Be=F.lastIndexOf(".");return Be>0?F.slice(0,Be):F},[F]),U=j.useMemo(()=>F?`/api/record/video?file=${encodeURIComponent(F)}`:"",[F]),ie=typeof t=="number"&&Number.isFinite(t)&&t>0,fe=g==="fill"?"w-full h-full":"w-20 h-16";j.useEffect(()=>{const Be=X.current;if(!Be)return;const Xe=new IntersectionObserver(ft=>le(!!ft[0]?.isIntersecting),{threshold:.1});return Xe.observe(Be),()=>Xe.disconnect()},[]),j.useEffect(()=>{if(!n||r!=="frames"||!ee||document.hidden)return;const Be=window.setInterval(()=>Y(Xe=>Xe+1),u);return()=>window.clearInterval(Be)},[n,r,ee,u]);const xe=j.useMemo(()=>{if(!n||r!=="frames"||!ie)return null;const Be=t,Xe=Math.max(.25,c??3);if(d){const we=Math.max(4,Math.min(f??16,Math.floor(Be))),Fe=oe%we,Ue=Math.max(.1,Be-Xe),Ke=Math.min(.25,Ue*.02),Ye=Fe/we*Ue+Ke;return Math.min(Be-.05,Math.max(.05,Ye))}const ft=Math.max(Be-.1,Xe),At=oe*Xe%ft;return Math.min(Be-.05,Math.max(.05,At))},[n,r,ie,t,oe,c,d,f]),Ae=j.useMemo(()=>ue?xe==null?`/api/record/preview?id=${encodeURIComponent(ue)}`:`/api/record/preview?id=${encodeURIComponent(ue)}&t=${encodeURIComponent(xe.toFixed(2))}&v=${encodeURIComponent(String(oe))}`:"",[ue,xe,oe]),$e=Be=>{if(z(!0),!i)return;const Xe=Be.currentTarget.duration;Number.isFinite(Xe)&&Xe>0&&i(s,Xe)};if(!U)return P.jsx("div",{className:[fe,"rounded bg-gray-100 dark:bg-white/5"].join(" ")});const Ee=ae!=="never"&&ee&&V&&(ae==="always"||ae==="hover"&&Z),je=j.useMemo(()=>{if(!n)return[];if(r!=="clips")return[];if(!ie)return[];const Be=t,Xe=Math.max(.25,m),ft=Math.max(8,Math.min(f??18,Math.floor(Be))),At=Math.max(.1,Be-Xe),we=Math.min(.25,At*.02),Fe=[];for(let Ue=0;Ue<ft;Ue++){const Ke=Ue/ft*At+we;Fe.push(Math.min(Be-.05,Math.max(.05,Ke)))}return Fe},[n,r,ie,t,f,m]),qe=j.useMemo(()=>je.map(Be=>Be.toFixed(2)).join(","),[je]),et=n&&r==="clips"&&ee&&!document.hidden&&V&&je.length>0&&!Ee&&(o==="always"||Z),rt=ae==="hover"||n&&r==="clips"&&o==="hover",ht=j.useRef(null),qt=j.useRef(0),xt=j.useRef(0);j.useEffect(()=>{const Be=ht.current;if(!Be)return;if(!et){Be.pause();return}if(!je.length)return;qt.current=qt.current%je.length,xt.current=je[qt.current];const Xe=()=>{try{Be.currentTime=xt.current}catch{}const we=Be.play();we&&typeof we.catch=="function"&&we.catch(()=>{})},ft=()=>Xe(),At=()=>{if(je.length&&Be.currentTime-xt.current>=m){qt.current=(qt.current+1)%je.length,xt.current=je[qt.current];try{Be.currentTime=xt.current+.01}catch{}}};return Be.addEventListener("loadedmetadata",ft),Be.addEventListener("timeupdate",At),Be.readyState>=1&&Xe(),()=>{Be.removeEventListener("loadedmetadata",ft),Be.removeEventListener("timeupdate",At),Be.pause()}},[et,qe,m]);const Ri=P.jsxs("div",{ref:X,className:["rounded bg-gray-100 dark:bg-white/5 overflow-hidden relative",fe,v??""].join(" "),onMouseEnter:rt?()=>Q(!0):void 0,onMouseLeave:rt?()=>Q(!1):void 0,onFocus:rt?()=>Q(!0):void 0,onBlur:rt?()=>Q(!1):void 0,children:[Ee?P.jsx("video",{src:U,className:["w-full h-full object-cover bg-black",$,I?"pointer-events-auto":"pointer-events-none"].filter(Boolean).join(" "),muted:!0,playsInline:!0,preload:"metadata",autoPlay:!0,controls:I,loop:L,poster:Ae||void 0,onLoadedMetadata:$e,onError:()=>k(!1)},`inline-${ue}-${w}`):et?P.jsx("video",{ref:ht,src:U,className:["w-full h-full object-cover bg-black pointer-events-none",$].filter(Boolean).join(" "),muted:!0,playsInline:!0,preload:"metadata",poster:Ae||void 0,onLoadedMetadata:$e,onError:()=>k(!1)},`teaser-${ue}-${qe}`):Ae&&G?P.jsx("img",{src:Ae,loading:"lazy",alt:F,className:["w-full h-full object-cover",$].filter(Boolean).join(" "),onError:()=>B(!1)}):P.jsx("div",{className:"w-full h-full bg-black"}),ee&&i&&!ie&&!R&&!Ee&&P.jsx("video",{src:U,preload:"metadata",muted:!0,playsInline:!0,className:"hidden",onLoadedMetadata:$e})]});return b?P.jsx(SA,{content:Be=>Be&&P.jsx("div",{className:"w-[420px]",children:P.jsx("div",{className:"aspect-video",children:P.jsx("video",{src:U,className:["w-full h-full bg-black",$].filter(Boolean).join(" "),muted:!0,playsInline:!0,preload:"metadata",controls:!0,autoPlay:!0,loop:!0,onClick:Xe=>Xe.stopPropagation(),onMouseDown:Xe=>Xe.stopPropagation()})})}),children:Ri}):Ri}function FO({open:s,x:e,y:t,items:i,onClose:n,className:r}){const o=j.useRef(null),[u,c]=j.useState({left:e,top:t});return j.useLayoutEffect(()=>{if(!s)return;const d=o.current;if(!d)return;const f=8,{innerWidth:m,innerHeight:g}=window,v=d.getBoundingClientRect(),b=Math.min(Math.max(e,f),m-v.width-f),_=Math.min(Math.max(t,f),g-v.height-f);c({left:b,top:_})},[s,e,t,i.length]),j.useEffect(()=>{if(!s)return;const d=m=>m.key==="Escape"&&n(),f=()=>n();return window.addEventListener("keydown",d),window.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{window.removeEventListener("keydown",d),window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[s,n]),s?ih.createPortal(P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"fixed inset-0 z-50",onMouseDown:n,onContextMenu:d=>{d.preventDefault(),n()}}),P.jsx("div",{ref:o,className:Ut("fixed z-50 min-w-[220px] overflow-hidden rounded-lg","bg-white dark:bg-gray-800","ring-1 ring-black/10 dark:ring-white/10 shadow-lg",r),style:{left:u.left,top:u.top},role:"menu",onMouseDown:d=>d.stopPropagation(),onContextMenu:d=>d.preventDefault(),children:P.jsx("div",{className:"py-1",children:i.map((d,f)=>P.jsx("button",{type:"button",disabled:d.disabled,onClick:()=>{d.disabled||(d.onClick(),n())},className:Ut("w-full text-left px-3 py-2 text-sm","hover:bg-black/5 dark:hover:bg-white/10","disabled:opacity-50 disabled:cursor-not-allowed",d.danger?"text-red-700 dark:text-red-300":"text-gray-900 dark:text-gray-100"),role:"menuitem",children:d.label},f))})})]}),document.body):null}function UO({job:s,modelName:e,state:t,actions:i}){const c=t.liked;return[{label:"Abspielen",onClick:()=>i.onPlay(s)},{label:"Beobachten",onClick:()=>i.onToggleWatch(s)},{label:c===!0?"Gefällt mir entfernen":"Gefällt mir",onClick:()=>i.onSetLike(s,!0)},{label:c===!1?"Gefällt mir nicht entfernen":"Gefällt mir nicht",onClick:()=>i.onSetLike(s,!1)},{label:"Als Favorit markieren",onClick:()=>i.onToggleFavorite(s)},{label:`Mehr von ${e} anzeigen`,onClick:()=>i.onMoreFromModel(e,s),disabled:!e||e==="—"},{label:"Dateipfad im Explorer öffnen",onClick:()=>i.onRevealInExplorer(s),disabled:!s.output},{label:"Zur Downloadliste hinzufügen",onClick:()=>i.onAddToDownloadList(s)},{label:"Als HOT markieren",onClick:()=>i.onToggleHot(s)},{label:"Behalten",onClick:()=>i.onToggleKeep(s)},{label:"Löschen",onClick:()=>i.onDelete(s),danger:!0,disabled:!1}]}function Q0(...s){return s.filter(Boolean).join(" ")}const $O={sm:{btn:"px-2.5 py-1.5 text-sm",icon:"size-5"},md:{btn:"px-3 py-2 text-sm",icon:"size-5"}};function jO({items:s,value:e,onChange:t,size:i="md",className:n,ariaLabel:r="Optionen"}){const o=$O[i];return P.jsx("span",{className:Q0("isolate inline-flex rounded-md shadow-xs dark:shadow-none",n),role:"group","aria-label":r,children:s.map((u,c)=>{const d=u.id===e,f=c===0,m=c===s.length-1,g=!u.label&&!!u.icon;return P.jsxs("button",{type:"button",disabled:u.disabled,onClick:()=>t(u.id),"aria-pressed":d,className:Q0("relative inline-flex items-center font-semibold focus:z-10",!f&&"-ml-px",f&&"rounded-l-md",m&&"rounded-r-md","bg-white text-gray-900 inset-ring-1 inset-ring-gray-300 hover:bg-gray-50","dark:bg-white/10 dark:text-white dark:inset-ring-gray-700 dark:hover:bg-white/20",d&&"bg-gray-50 dark:bg-white/20","disabled:opacity-50 disabled:cursor-not-allowed",g?"px-2 py-2 text-gray-400 dark:text-gray-300":o.btn),title:typeof u.label=="string"?u.label:u.srLabel,children:[g&&u.srLabel?P.jsx("span",{className:"sr-only",children:u.srLabel}):null,u.icon?P.jsx("span",{className:Q0("shrink-0",g?"":"-ml-0.5 text-gray-400 dark:text-gray-500"),children:u.icon}):null,u.label?P.jsx("span",{className:u.icon?"ml-1.5":"",children:u.label}):null]},u.id)})})}function HO({title:s,titleId:e,...t},i){return j.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?j.createElement("title",{id:e},s):null,j.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 9V4.5M9 9H4.5M9 9 3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5 5.25 5.25"}))}const GO=j.forwardRef(HO);function VO({title:s,titleId:e,...t},i){return j.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?j.createElement("title",{id:e},s):null,j.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 3.75v4.5m0-4.5h4.5m-4.5 0L9 9M3.75 20.25v-4.5m0 4.5h4.5m-4.5 0L9 15M20.25 3.75h-4.5m4.5 0v4.5m0-4.5L15 9m5.25 11.25h-4.5m4.5 0v-4.5m0 4.5L15 15"}))}const qO=j.forwardRef(VO);function zO({title:s,titleId:e,...t},i){return j.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?j.createElement("title",{id:e},s):null,j.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.5 3.75V16.5L12 14.25 7.5 16.5V3.75m9 0H18A2.25 2.25 0 0 1 20.25 6v12A2.25 2.25 0 0 1 18 20.25H6A2.25 2.25 0 0 1 3.75 18V6A2.25 2.25 0 0 1 6 3.75h1.5m9 0h-9"}))}const mp=j.forwardRef(zO);function KO({title:s,titleId:e,...t},i){return j.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?j.createElement("title",{id:e},s):null,j.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6.75a.75.75 0 1 1 0-1.5.75.75 0 0 1 0 1.5ZM12 12.75a.75.75 0 1 1 0-1.5.75.75 0 0 1 0 1.5ZM12 18.75a.75.75 0 1 1 0-1.5.75.75 0 0 1 0 1.5Z"}))}const VS=j.forwardRef(KO);function YO({title:s,titleId:e,...t},i){return j.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?j.createElement("title",{id:e},s):null,j.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.362 5.214A8.252 8.252 0 0 1 12 21 8.25 8.25 0 0 1 6.038 7.047 8.287 8.287 0 0 0 9 9.601a8.983 8.983 0 0 1 3.361-6.867 8.21 8.21 0 0 0 3 2.48Z"}),j.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 18a3.75 3.75 0 0 0 .495-7.468 5.99 5.99 0 0 0-1.925 3.547 5.975 5.975 0 0 1-2.133-1.001A3.75 3.75 0 0 0 12 18Z"}))}const EA=j.forwardRef(YO);function WO({title:s,titleId:e,...t},i){return j.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?j.createElement("title",{id:e},s):null,j.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6.633 10.25c.806 0 1.533-.446 2.031-1.08a9.041 9.041 0 0 1 2.861-2.4c.723-.384 1.35-.956 1.653-1.715a4.498 4.498 0 0 0 .322-1.672V2.75a.75.75 0 0 1 .75-.75 2.25 2.25 0 0 1 2.25 2.25c0 1.152-.26 2.243-.723 3.218-.266.558.107 1.282.725 1.282m0 0h3.126c1.026 0 1.945.694 2.054 1.715.045.422.068.85.068 1.285a11.95 11.95 0 0 1-2.649 7.521c-.388.482-.987.729-1.605.729H13.48c-.483 0-.964-.078-1.423-.23l-3.114-1.04a4.501 4.501 0 0 0-1.423-.23H5.904m10.598-9.75H14.25M5.904 18.5c.083.205.173.405.27.602.197.4-.078.898-.523.898h-.908c-.889 0-1.713-.518-1.972-1.368a12 12 0 0 1-.521-3.507c0-1.553.295-3.036.831-4.398C3.387 9.953 4.167 9.5 5 9.5h1.053c.472 0 .745.556.5.96a8.958 8.958 0 0 0-1.302 4.665c0 1.194.232 2.333.654 3.375Z"}))}const XO=j.forwardRef(WO);function QO({title:s,titleId:e,...t},i){return j.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?j.createElement("title",{id:e},s):null,j.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 8.25c0-2.485-2.099-4.5-4.688-4.5-1.935 0-3.597 1.126-4.312 2.733-.715-1.607-2.377-2.733-4.313-2.733C5.1 3.75 3 5.765 3 8.25c0 7.22 9 12 9 12s9-4.78 9-12Z"}))}const AA=j.forwardRef(QO);function ZO({title:s,titleId:e,...t},i){return j.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?j.createElement("title",{id:e},s):null,j.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 6.878V6a2.25 2.25 0 0 1 2.25-2.25h7.5A2.25 2.25 0 0 1 18 6v.878m-12 0c.235-.083.487-.128.75-.128h10.5c.263 0 .515.045.75.128m-12 0A2.25 2.25 0 0 0 4.5 9v.878m13.5-3A2.25 2.25 0 0 1 19.5 9v.878m0 0a2.246 2.246 0 0 0-.75-.128H5.25c-.263 0-.515.045-.75.128m15 0A2.25 2.25 0 0 1 21 12v6a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 18v-6c0-.98.626-1.813 1.5-2.122"}))}const JO=j.forwardRef(ZO);function eP({title:s,titleId:e,...t},i){return j.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?j.createElement("title",{id:e},s):null,j.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 6A2.25 2.25 0 0 1 6 3.75h2.25A2.25 2.25 0 0 1 10.5 6v2.25a2.25 2.25 0 0 1-2.25 2.25H6a2.25 2.25 0 0 1-2.25-2.25V6ZM3.75 15.75A2.25 2.25 0 0 1 6 13.5h2.25a2.25 2.25 0 0 1 2.25 2.25V18a2.25 2.25 0 0 1-2.25 2.25H6A2.25 2.25 0 0 1 3.75 18v-2.25ZM13.5 6a2.25 2.25 0 0 1 2.25-2.25H18A2.25 2.25 0 0 1 20.25 6v2.25A2.25 2.25 0 0 1 18 10.5h-2.25a2.25 2.25 0 0 1-2.25-2.25V6ZM13.5 15.75a2.25 2.25 0 0 1 2.25-2.25H18a2.25 2.25 0 0 1 2.25 2.25V18A2.25 2.25 0 0 1 18 20.25h-2.25A2.25 2.25 0 0 1 13.5 18v-2.25Z"}))}const tP=j.forwardRef(eP);function iP({title:s,titleId:e,...t},i){return j.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?j.createElement("title",{id:e},s):null,j.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11.48 3.499a.562.562 0 0 1 1.04 0l2.125 5.111a.563.563 0 0 0 .475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 0 0-.182.557l1.285 5.385a.562.562 0 0 1-.84.61l-4.725-2.885a.562.562 0 0 0-.586 0L6.982 20.54a.562.562 0 0 1-.84-.61l1.285-5.386a.562.562 0 0 0-.182-.557l-4.204-3.602a.562.562 0 0 1 .321-.988l5.518-.442a.563.563 0 0 0 .475-.345L11.48 3.5Z"}))}const sP=j.forwardRef(iP);function nP({title:s,titleId:e,...t},i){return j.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?j.createElement("title",{id:e},s):null,j.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.375 19.5h17.25m-17.25 0a1.125 1.125 0 0 1-1.125-1.125M3.375 19.5h7.5c.621 0 1.125-.504 1.125-1.125m-9.75 0V5.625m0 12.75v-1.5c0-.621.504-1.125 1.125-1.125m18.375 2.625V5.625m0 12.75c0 .621-.504 1.125-1.125 1.125m1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125m0 3.75h-7.5A1.125 1.125 0 0 1 12 18.375m9.75-12.75c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125m19.5 0v1.5c0 .621-.504 1.125-1.125 1.125M2.25 5.625v1.5c0 .621.504 1.125 1.125 1.125m0 0h17.25m-17.25 0h7.5c.621 0 1.125.504 1.125 1.125M3.375 8.25c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125m17.25-3.75h-7.5c-.621 0-1.125.504-1.125 1.125m8.625-1.125c.621 0 1.125.504 1.125 1.125v1.5c0 .621-.504 1.125-1.125 1.125m-17.25 0h7.5m-7.5 0c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125M12 10.875v-1.5m0 1.5c0 .621-.504 1.125-1.125 1.125M12 10.875c0 .621.504 1.125 1.125 1.125m-2.25 0c.621 0 1.125.504 1.125 1.125M13.125 12h7.5m-7.5 0c-.621 0-1.125.504-1.125 1.125M20.625 12c.621 0 1.125.504 1.125 1.125v1.5c0 .621-.504 1.125-1.125 1.125m-17.25 0h7.5M12 14.625v-1.5m0 1.5c0 .621-.504 1.125-1.125 1.125M12 14.625c0 .621.504 1.125 1.125 1.125m-2.25 0c.621 0 1.125.504 1.125 1.125m0 1.5v-1.5m0 0c0-.621.504-1.125 1.125-1.125m0 0h7.5"}))}const rP=j.forwardRef(nP);function aP({title:s,titleId:e,...t},i){return j.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?j.createElement("title",{id:e},s):null,j.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0"}))}const Pd=j.forwardRef(aP);function oP({title:s,titleId:e,...t},i){return j.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?j.createElement("title",{id:e},s):null,j.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18 18 6M6 6l12 12"}))}const CA=j.forwardRef(oP);function lP({title:s,titleId:e,...t},i){return j.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?j.createElement("title",{id:e},s):null,j.createElement("path",{d:"m11.645 20.91-.007-.003-.022-.012a15.247 15.247 0 0 1-.383-.218 25.18 25.18 0 0 1-4.244-3.17C4.688 15.36 2.25 12.174 2.25 8.25 2.25 5.322 4.714 3 7.688 3A5.5 5.5 0 0 1 12 5.052 5.5 5.5 0 0 1 16.313 3c2.973 0 5.437 2.322 5.437 5.25 0 3.925-2.438 7.111-4.739 9.256a25.175 25.175 0 0 1-4.244 3.17 15.247 15.247 0 0 1-.383.219l-.022.012-.007.004-.003.001a.752.752 0 0 1-.704 0l-.003-.001Z"}))}const uP=j.forwardRef(lP);function cP({title:s,titleId:e,...t},i){return j.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:i,"aria-labelledby":e},t),s?j.createElement("title",{id:e},s):null,j.createElement("path",{fillRule:"evenodd",d:"M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.006 5.404.434c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.434 2.082-5.005Z",clipRule:"evenodd"}))}const dP=j.forwardRef(cP);function Hf(...s){return s.filter(Boolean).join(" ")}const hP=j.forwardRef(function({children:e,enabled:t=!0,disabled:i=!1,onTap:n,onSwipeLeft:r,onSwipeRight:o,className:u,leftAction:c={label:P.jsxs("span",{className:"inline-flex flex-col items-center gap-1 font-semibold leading-tight",children:[P.jsx(mp,{className:"h-6 w-6","aria-hidden":"true"}),P.jsx("span",{children:"Behalten"})]}),className:"bg-emerald-500/20 text-emerald-800 dark:bg-emerald-500/15 dark:text-emerald-300"},rightAction:d={label:P.jsxs("span",{className:"inline-flex flex-col items-center gap-1 font-semibold leading-tight",children:[P.jsx(Pd,{className:"h-6 w-6","aria-hidden":"true"}),P.jsx("span",{children:"Löschen"})]}),className:"bg-red-500/20 text-red-800 dark:bg-red-500/15 dark:text-red-300"},thresholdPx:f=120,thresholdRatio:m=.35,ignoreFromBottomPx:g=72,ignoreSelector:v="[data-swipe-ignore]",snapMs:b=180,commitMs:_=180},E){const w=j.useRef(null),I=j.useRef({id:null,x:0,y:0,dragging:!1,captured:!1}),[L,F]=j.useState(0),[$,G]=j.useState(null),[B,V]=j.useState(0),k=j.useCallback(()=>{V(b),F(0),G(null),window.setTimeout(()=>V(0),b)},[b]),R=j.useCallback(async(z,X)=>{const le=w.current?.offsetWidth||360;V(_),G(z==="right"?"right":"left"),F(z==="right"?le+40:-(le+40));let oe=!0;if(X)try{oe=z==="right"?await o():await r()}catch{oe=!1}return oe===!1?(V(b),G(null),F(0),window.setTimeout(()=>V(0),b),!1):!0},[_,r,o,b]);return j.useImperativeHandle(E,()=>({swipeLeft:z=>R("left",z?.runAction??!0),swipeRight:z=>R("right",z?.runAction??!0),reset:()=>k()}),[R,k]),P.jsxs("div",{className:Hf("relative overflow-hidden rounded-lg",u),children:[P.jsxs("div",{className:"absolute inset-0 pointer-events-none overflow-hidden rounded-lg",children:[P.jsx("div",{className:Hf("absolute inset-0 transition-opacity duration-200 ease-out",L===0?"opacity-0":"opacity-100",L>0?c.className:d.className)}),P.jsx("div",{className:Hf("absolute inset-0 flex items-center transition-all duration-200 ease-out"),style:{transform:`translateX(${Math.max(-24,Math.min(24,L/8))}px)`,opacity:L===0?0:1,justifyContent:L>0?"flex-start":"flex-end",paddingLeft:L>0?16:0,paddingRight:L>0?0:16},children:L>0?c.label:d.label})]}),P.jsx("div",{ref:w,className:"relative",style:{transform:`translateX(${L}px)`,transition:B?`transform ${B}ms ease`:void 0,touchAction:"pan-y"},onPointerDown:z=>{if(!t||i)return;const X=z.target;if(v&&X?.closest?.(v))return;const le=z.currentTarget.getBoundingClientRect().bottom-z.clientY;g&&le<=g||(I.current={id:z.pointerId,x:z.clientX,y:z.clientY,dragging:!1,captured:!1})},onPointerMove:z=>{if(!t||i||I.current.id!==z.pointerId)return;const X=z.clientX-I.current.x,ee=z.clientY-I.current.y;if(!I.current.dragging){if(Math.abs(ee)>Math.abs(X)&&Math.abs(ee)>8){I.current.id=null;return}if(Math.abs(X)<12)return;I.current.dragging=!0;try{z.currentTarget.setPointerCapture(z.pointerId),I.current.captured=!0}catch{I.current.captured=!1}}V(0),F(X);const oe=w.current?.offsetWidth||360,Y=Math.min(f,oe*m);G(X>Y?"right":X<-Y?"left":null)},onPointerUp:z=>{if(!t||i||I.current.id!==z.pointerId)return;const ee=w.current?.offsetWidth||360,le=Math.min(f,ee*m),oe=I.current.dragging,Y=I.current.captured;if(I.current.id=null,I.current.dragging=!1,I.current.captured=!1,Y)try{z.currentTarget.releasePointerCapture(z.pointerId)}catch{}if(!oe){k(),n?.();return}L>le?R("right",!0):L<-le?R("left",!0):k()},onPointerCancel:z=>{if(!(!t||i)){if(I.current.captured&&I.current.id!=null)try{z.currentTarget.releasePointerCapture(I.current.id)}catch{}I.current={id:null,x:0,y:0,dragging:!1,captured:!1},k()}},children:P.jsxs("div",{className:"relative",children:[P.jsx("div",{className:"relative z-10",children:e}),P.jsx("div",{className:Hf("absolute inset-0 z-20 pointer-events-none transition-opacity duration-150 rounded-lg",$==="right"&&"bg-emerald-500/20 opacity-100",$==="left"&&"bg-red-500/20 opacity-100",$===null&&"opacity-0")})]})})]})}),pv=s=>(s||"").replaceAll("\\","/").trim(),Ms=s=>{const t=pv(s).split("/");return t[t.length-1]||""},$i=s=>Ms(s.output||"")||s.id;function Z0(...s){return s.filter(Boolean).join(" ")}function DA(s){if(!Number.isFinite(s)||s<=0)return"—";const e=Math.floor(s/1e3),t=Math.floor(e/3600),i=Math.floor(e%3600/60),n=e%60;return t>0?`${t}h ${i}m`:i>0?`${i}m ${n}s`:`${n}s`}function J0(s){if(typeof s!="number"||!Number.isFinite(s)||s<=0)return"—";const e=["B","KB","MB","GB","TB"];let t=s,i=0;for(;t>=1024&&i<e.length-1;)t/=1024,i++;const n=i===0||t>=100?0:t>=10?1:2;return`${t.toFixed(n)} ${e[i]}`}function fP(s){const e=Date.parse(String(s.startedAt||"")),t=Date.parse(String(s.endedAt||""));return!Number.isFinite(e)||!Number.isFinite(t)?"—":DA(t-e)}function pP(s){const[e,t]=j.useState(!1);return j.useEffect(()=>{const i=window.matchMedia(s),n=()=>t(i.matches);return n(),i.addEventListener?i.addEventListener("change",n):i.addListener(n),()=>{i.removeEventListener?i.removeEventListener("change",n):i.removeListener(n)}},[s]),e}const gd=s=>{const e=(s??"").match(/\bHTTP\s+(\d{3})\b/i);return e?`HTTP ${e[1]}`:null},wu=s=>s.startsWith("HOT ")?s.slice(4):s,sl=s=>{const e=Ms(s||""),t=wu(e);if(!t)return"—";const i=t.replace(/\.[^.]+$/,""),n=i.match(/^(.*?)_\d{1,2}_\d{1,2}_\d{4}__\d{1,2}-\d{2}-\d{2}$/);if(n?.[1])return n[1];const r=i.lastIndexOf("_");return r>0?i.slice(0,r):i},qS=s=>(s||"").trim().toLowerCase(),yd=s=>{const e=s,t=e.sizeBytes??e.fileSizeBytes??e.bytes??e.size??null;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:null};function mP({jobs:s,doneJobs:e,blurPreviews:t,onOpenPlayer:i,onDeleteJob:n,onToggleHot:r,onToggleFavorite:o,onToggleLike:u}){const[d,f]=j.useState(50),[m,g]=j.useState(null),[v,b]=j.useState(()=>new Set),[_,E]=j.useState(()=>new Set),[w,I]=j.useState(null),L="finishedDownloads_view",F="finishedDownloads_sort",[$,G]=j.useState("completed_desc");j.useEffect(()=>{try{const de=window.localStorage.getItem(F);de&&G(de)}catch{}},[]),j.useEffect(()=>{try{window.localStorage.setItem(F,$)}catch{}},[$]);const[B,V]=j.useState("table"),k=j.useRef(new Map),[R,z]=j.useState({}),X=j.useCallback(async()=>{try{const de=await fetch("/api/models/list",{cache:"no-store"});if(!de.ok)return;const ye=await de.json(),Se={};for(const He of Array.isArray(ye)?ye:[]){const it=qS(String(He?.modelKey??""));if(!it)continue;const gi=Se[it];if(!gi){Se[it]=He;continue}const Oi=Wi=>(Wi.favorite?2:0)+(Wi.liked===!0?1:0);Oi(He)>Oi(gi)&&(Se[it]=He)}z(Se)}catch{}},[]);j.useEffect(()=>{X()},[X]),j.useEffect(()=>{const de=()=>{X()};return window.addEventListener("models-changed",de),()=>window.removeEventListener("models-changed",de)},[X]),j.useEffect(()=>{try{const de=localStorage.getItem(L);V(de==="table"||de==="cards"||de==="gallery"?de:window.matchMedia("(max-width: 639px)").matches?"cards":"table")}catch{V("table")}},[]),j.useEffect(()=>{try{localStorage.setItem(L,B)}catch{}},[B]);const[ee,le]=j.useState({}),[oe,Y]=j.useState(null),Z=j.useCallback(de=>{const Se=document.getElementById(de)?.querySelector("video");if(!Se)return!1;Se.muted=!0,Se.playsInline=!0,Se.setAttribute("playsinline","true");const He=Se.play?.();return He&&typeof He.catch=="function"&&He.catch(()=>{}),!0},[]),Q=j.useCallback(de=>{Y(ye=>ye?.key===de?{key:de,nonce:ye.nonce+1}:{key:de,nonce:1})},[]),ae=j.useCallback(de=>{Y(null),i(de)},[i]),ue=(de,ye)=>{ye.preventDefault(),ye.stopPropagation(),g({x:ye.clientX,y:ye.clientY,job:de})},U=(de,ye,Se)=>{g({x:ye,y:Se,job:de})},ie=j.useCallback((de,ye)=>{E(Se=>{const He=new Set(Se);return ye?He.add(de):He.delete(de),He})},[]),fe=j.useCallback(de=>{b(ye=>{const Se=new Set(ye);return Se.add(de),Se})},[]),[xe,Ae]=j.useState(()=>new Set),$e=j.useCallback((de,ye)=>{Ae(Se=>{const He=new Set(Se);return ye?He.add(de):He.delete(de),He})},[]),[Ee,je]=j.useState(()=>new Set),qe=j.useCallback((de,ye)=>{je(Se=>{const He=new Set(Se);return ye?He.add(de):He.delete(de),He})},[]),et=j.useCallback(de=>{qe(de,!0),window.setTimeout(()=>{fe(de),qe(de,!1)},320)},[fe,qe]),rt=j.useCallback(async(de,ye)=>{window.dispatchEvent(new CustomEvent("player:release",{detail:{file:de}})),ye?.close&&window.dispatchEvent(new CustomEvent("player:close",{detail:{file:de}})),await new Promise(Se=>window.setTimeout(Se,250))},[]),ht=j.useCallback(async de=>{const ye=Ms(de.output||""),Se=$i(de);if(!ye)return window.alert("Kein Dateiname gefunden kann nicht löschen."),!1;if(_.has(Se))return!1;ie(Se,!0);try{if(await rt(ye,{close:!0}),n)return await n(de),et(Se),!0;const He=await fetch(`/api/record/delete?file=${encodeURIComponent(ye)}`,{method:"POST"});if(!He.ok){const it=await He.text().catch(()=>"");throw new Error(it||`HTTP ${He.status}`)}return et(Se),!0}catch(He){return window.alert(`Löschen fehlgeschlagen: ${String(He?.message||He)}`),!1}finally{ie(Se,!1)}},[_,ie,rt,n,et]),qt=j.useCallback(async de=>{const ye=Ms(de.output||""),Se=$i(de);if(!ye)return window.alert("Kein Dateiname gefunden kann nicht behalten."),!1;if(xe.has(Se)||_.has(Se))return!1;$e(Se,!0);try{await rt(ye,{close:!0});const He=await fetch(`/api/record/keep?file=${encodeURIComponent(ye)}`,{method:"POST"});if(!He.ok){const it=await He.text().catch(()=>"");throw new Error(it||`HTTP ${He.status}`)}return et(Se),!0}catch(He){return window.alert(`Behalten fehlgeschlagen: ${String(He?.message||He)}`),!1}finally{$e(Se,!1)}},[xe,_,$e,rt,et]),xt=j.useMemo(()=>{if(!m)return[];const de=m.job,ye=sl(de.output);return UO({job:de,modelName:ye,state:{liked:null},actions:{onPlay:i,onToggleWatch:Se=>console.log("toggle watch",Se.id),onSetLike:(Se,He)=>console.log("set like",Se.id,He),onToggleFavorite:Se=>console.log("toggle favorite",Se.id),onMoreFromModel:Se=>console.log("more from",Se),onRevealInExplorer:Se=>console.log("reveal in explorer",Se.output),onAddToDownloadList:Se=>console.log("add to download list",Se.id),onToggleHot:Se=>console.log("toggle hot",Se.id),onToggleKeep:Se=>console.log("toggle keep",Se.id),onDelete:Se=>{g(null),ht(Se)}}})},[m,ht,i]),Ri=j.useCallback(de=>{const ye=$i(de),Se=typeof de.durationSeconds=="number"&&de.durationSeconds>0?de.durationSeconds:ee[ye];if(typeof Se=="number"&&Number.isFinite(Se)&&Se>0)return Se;const He=Date.parse(String(de.startedAt||"")),it=Date.parse(String(de.endedAt||""));return!Number.isFinite(He)||!Number.isFinite(it)||it<=He?Number.POSITIVE_INFINITY:(it-He)/1e3},[ee]),Be=j.useMemo(()=>{const de=new Map;for(const Se of e)de.set($i(Se),Se);for(const Se of s){const He=$i(Se);de.has(He)&&de.set(He,{...de.get(He),...Se})}const ye=Array.from(de.values()).filter(Se=>v.has($i(Se))?!1:Se.status==="finished"||Se.status==="failed"||Se.status==="stopped");return ye.sort((Se,He)=>pv(He.endedAt||"").localeCompare(pv(Se.endedAt||""))),ye},[s,e,v]),Xe=de=>de.endedAt?new Date(de.endedAt).getTime():0,ft=de=>sl(de.output||"").toLowerCase(),At=de=>{const ye=Ms(de.output||"").toLowerCase();return wu(ye)},we=de=>{const ye=$i(de),Se=typeof de.durationSeconds=="number"&&de.durationSeconds>0?de.durationSeconds:ee[ye];return typeof Se=="number"&&Number.isFinite(Se)&&Se>0?Se:NaN},Fe=de=>{const ye=yd(de);return typeof ye=="number"?ye:NaN},Ue=(de,ye)=>de.localeCompare(ye,void 0,{numeric:!0,sensitivity:"base"}),Ke=(de,ye)=>de-ye,Ye=(de,ye,Se)=>{const He=Number.isFinite(de),it=Number.isFinite(ye);return!He&&!it?0:He?it?Se*Ke(de,ye):-1:1},gt=j.useMemo(()=>{const de=[...Be];return de.sort((ye,Se)=>{switch($){case"completed_asc":return Ke(Xe(ye),Xe(Se))||Ue($i(ye),$i(Se));case"completed_desc":return Ke(Xe(Se),Xe(ye))||Ue($i(ye),$i(Se));case"model_asc":return Ue(ft(ye),ft(Se))||Ke(Xe(Se),Xe(ye));case"model_desc":return Ue(ft(Se),ft(ye))||Ke(Xe(Se),Xe(ye));case"file_asc":return Ue(At(ye),At(Se))||Ke(Xe(Se),Xe(ye));case"file_desc":return Ue(At(Se),At(ye))||Ke(Xe(Se),Xe(ye));case"duration_asc":return Ye(we(ye),we(Se),1)||Ke(Xe(Se),Xe(ye));case"duration_desc":return Ye(we(ye),we(Se),-1)||Ke(Xe(Se),Xe(ye));case"size_asc":return Ye(Fe(ye),Fe(Se),1)||Ke(Xe(Se),Xe(ye));case"size_desc":return Ye(Fe(ye),Fe(Se),-1)||Ke(Xe(Se),Xe(ye));default:return Ke(Xe(Se),Xe(ye))}}),de},[Be,$,ee]);j.useEffect(()=>{f(50)},[Be.length]),j.useEffect(()=>{const de=ye=>{const Se=ye.detail;if(!Se?.file)return;const He=Se.file;Se.phase==="start"?(ie(He,!0),B==="cards"&&k.current.get(He)?.swipeLeft({runAction:!1})):Se.phase==="success"?(ie(He,!1),B==="cards"?window.setTimeout(()=>fe(He),320):et(He)):Se.phase==="error"&&(ie(He,!1),B==="cards"&&k.current.get(He)?.reset())};return window.addEventListener("finished-downloads:delete",de),()=>window.removeEventListener("finished-downloads:delete",de)},[et,ie,fe,B]);const $t=(B==="table"?Be:gt).filter(de=>!v.has($i(de))).slice(0,d),fi=j.useRef(new Set);j.useEffect(()=>{if(!(B==="table"&&w?.key==="runtime"))return;const ye=[];for(const He of Be){const it=Ms(He.output||"");if(!it)continue;const gi=$i(He),Oi=typeof He.durationSeconds=="number"&&He.durationSeconds>0?He.durationSeconds:ee[gi];typeof Oi=="number"&&Oi>0||fi.current.has(it)||(fi.current.add(it),ye.push(it))}if(ye.length===0)return;const Se=new AbortController;return(async()=>{for(let it=0;it<ye.length;it+=25){const gi=ye.slice(it,it+25),Oi=await fetch("/api/record/duration",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({files:gi}),signal:Se.signal});if(!Oi.ok)break;const Wi=await Oi.json();le(Ht=>{const ws={...Ht};for(const H of Wi)H?.file&&typeof H.durationSeconds=="number"&&H.durationSeconds>0&&(ws[H.file]=H.durationSeconds);return ws})}})().catch(()=>{}),()=>Se.abort()},[B,w?.key,Be]);const pi=de=>{const ye=$i(de),Se=typeof de.durationSeconds=="number"&&de.durationSeconds>0?de.durationSeconds:ee[ye];return typeof Se=="number"&&Number.isFinite(Se)&&Se>0?DA(Se*1e3):fP(de)},ts=j.useCallback((de,ye)=>{if(!Number.isFinite(ye)||ye<=0)return;const Se=$i(de);le(He=>{const it=He[Se];return typeof it=="number"&&Math.abs(it-ye)<.5?He:{...He,[Se]:ye}})},[]),vs=[{key:"preview",header:"Vorschau",srOnlyHeader:!0,widthClassName:"w-[140px]",cell:de=>{const ye=$i(de);return P.jsx("div",{className:"py-1",onClick:Se=>Se.stopPropagation(),onMouseDown:Se=>Se.stopPropagation(),onContextMenu:Se=>{Se.preventDefault(),Se.stopPropagation(),ue(de,Se)},children:P.jsx(X0,{job:de,getFileName:Ms,durationSeconds:ee[ye],onDuration:ts,className:"w-28 h-16 rounded-md ring-1 ring-black/5 dark:ring-white/10",showPopover:!1,blur:t})})}},{key:"video",header:"Video",sortable:!0,sortValue:de=>{const ye=Ms(de.output||""),Se=ye.startsWith("HOT "),He=sl(de.output),it=wu(ye);return`${He} ${Se?"HOT":""} ${it}`.trim()},cell:de=>{const ye=Ms(de.output||""),Se=ye.startsWith("HOT "),He=sl(de.output),it=wu(ye);return P.jsxs("div",{className:"min-w-0",children:[P.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[P.jsx("div",{className:"truncate font-medium text-gray-900 dark:text-white",title:He,children:He}),Se?P.jsx("span",{className:"shrink-0 rounded-md bg-amber-500/15 px-1.5 py-0.5 text-[11px] font-semibold text-amber-800 dark:text-amber-300",children:"HOT"}):null]}),P.jsx("div",{className:"truncate text-xs text-gray-500 dark:text-gray-400",title:it,children:it||"—"})]})}},{key:"status",header:"Status",sortable:!0,sortValue:de=>de.status==="finished"?0:de.status==="stopped"?1:de.status==="failed"?2:9,cell:de=>{const ye="inline-flex items-center rounded-full px-2 py-0.5 text-xs font-semibold ring-1 ring-inset";if(de.status==="failed"){const Se=gd(de.error),He=Se?`failed (${Se})`:"failed";return P.jsx("span",{className:`${ye} bg-red-50 text-red-700 ring-red-200 dark:bg-red-500/10 dark:text-red-300 dark:ring-red-500/30`,title:de.error||"",children:He})}return de.status==="finished"?P.jsx("span",{className:`${ye} bg-emerald-50 text-emerald-800 ring-emerald-200 dark:bg-emerald-500/10 dark:text-emerald-300 dark:ring-emerald-500/30`,children:"finished"}):de.status==="stopped"?P.jsx("span",{className:`${ye} bg-amber-50 text-amber-800 ring-amber-200 dark:bg-amber-500/10 dark:text-amber-300 dark:ring-amber-500/30`,children:"stopped"}):P.jsx("span",{className:`${ye} bg-gray-50 text-gray-700 ring-gray-200 dark:bg-white/5 dark:text-gray-300 dark:ring-white/10`,children:de.status})}},{key:"runtime",header:"Dauer",align:"right",sortable:!0,sortValue:de=>Ri(de),cell:de=>P.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:pi(de)})},{key:"size",header:"Größe",align:"right",sortable:!0,sortValue:de=>{const ye=yd(de);return typeof ye=="number"?ye:Number.NEGATIVE_INFINITY},cell:de=>P.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:J0(yd(de))})},{key:"actions",header:"Aktionen",align:"right",srOnlyHeader:!0,cell:de=>{const ye=$i(de),Se=_.has(ye)||xe.has(ye),He="inline-flex items-center justify-center rounded-md p-1.5 hover:bg-gray-100/70 dark:hover:bg-white/5 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 dark:focus-visible:outline-indigo-500";return P.jsxs("div",{className:"flex items-center justify-end gap-1",children:[P.jsx("button",{type:"button",className:He,title:"Behalten (nach keep verschieben)","aria-label":"Behalten",disabled:Se,onClick:it=>{it.preventDefault(),it.stopPropagation(),qt(de)},children:P.jsx(mp,{className:"size-5 text-emerald-600 dark:text-emerald-300"})}),P.jsx("button",{type:"button",className:He,title:"Löschen","aria-label":"Löschen",disabled:Se,onClick:it=>{it.preventDefault(),it.stopPropagation(),ht(de)},children:P.jsx(Pd,{className:"size-5 text-red-600 dark:text-red-300"})}),P.jsx("button",{type:"button",className:He,title:"Mehr Aktionen","aria-label":"Mehr Aktionen",onClick:it=>{it.preventDefault(),it.stopPropagation();const gi=it.currentTarget.getBoundingClientRect();U(de,gi.left,gi.bottom+6)},children:P.jsx(VS,{className:"size-5 text-gray-500 dark:text-gray-300"})})]})}}],Et=pP("(max-width: 639px)");return j.useEffect(()=>{Et||(k.current=new Map)},[Et]),Be.length===0?P.jsx(Pn,{grayBody:!0,children:P.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Keine abgeschlossenen Downloads im Zielordner vorhanden."})}):P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[P.jsx("div",{className:"sm:hidden min-w-0",children:P.jsxs("div",{className:"truncate text-sm font-semibold text-gray-900 dark:text-white",children:["Abgeschlossene Downloads ",P.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["(",Be.length,")"]})]})}),P.jsx("div",{className:"shrink-0",children:P.jsx(jO,{value:B,onChange:de=>V(de),size:"sm",ariaLabel:"Ansicht",items:[{id:"table",icon:P.jsx(rP,{className:"size-5"}),label:P.jsx("span",{className:"hidden sm:inline",children:"Tabelle"}),srLabel:"Tabelle"},{id:"cards",icon:P.jsx(JO,{className:"size-5"}),label:P.jsx("span",{className:"hidden sm:inline",children:"Cards"}),srLabel:"Cards"},{id:"gallery",icon:P.jsx(tP,{className:"size-5"}),label:P.jsx("span",{className:"hidden sm:inline",children:"Galerie"}),srLabel:"Galerie"}]})})]}),B!=="table"&&P.jsxs("div",{className:"ml-2",children:[P.jsx("label",{className:"sr-only",htmlFor:"finished-sort",children:"Sortierung"}),P.jsxs("select",{id:"finished-sort",value:$,onChange:de=>G(de.target.value),className:`h-9 rounded-md border border-gray-200 bg-white px-2 text-sm text-gray-900 shadow-sm
dark:border-white/10 dark:bg-white/5 dark:text-white`,children:[P.jsx("option",{value:"completed_desc",children:"Fertiggestellt am ↓"}),P.jsx("option",{value:"completed_asc",children:"Fertiggestellt am ↑"}),P.jsx("option",{value:"model_asc",children:"Modelname A→Z"}),P.jsx("option",{value:"model_desc",children:"Modelname Z→A"}),P.jsx("option",{value:"file_asc",children:"Dateiname A→Z"}),P.jsx("option",{value:"file_desc",children:"Dateiname Z→A"}),P.jsx("option",{value:"duration_desc",children:"Dauer ↓"}),P.jsx("option",{value:"duration_asc",children:"Dauer ↑"}),P.jsx("option",{value:"size_desc",children:"Größe ↓"}),P.jsx("option",{value:"size_asc",children:"Größe ↑"})]})]}),B==="cards"&&P.jsx("div",{className:"space-y-3",children:$t.map(de=>{const ye=$i(de),Se=oe?.key===ye,He=Se?oe?.nonce??0:0,it=_.has(ye)||xe.has(ye)||Ee.has(ye),gi=sl(de.output),Oi=Ms(de.output||""),Wi=pi(de),Ht=J0(yd(de)),ws=de.status==="failed"?P.jsxs("span",{className:"text-red-700 dark:text-red-300",title:de.error||"",children:["failed",gd(de.error)?` (${gd(de.error)})`:""]}):P.jsx("span",{className:"font-medium",children:de.status}),H=`inline-prev-${encodeURIComponent(ye)}`,K=P.jsx("div",{role:"button",tabIndex:0,className:["transition-all duration-300 ease-in-out",it&&"pointer-events-none",_.has(ye)&&"ring-1 ring-red-300 bg-red-50/60 dark:bg-red-500/10 dark:ring-red-500/30 animate-pulse",xe.has(ye)&&"ring-1 ring-emerald-300 bg-emerald-50/60 dark:bg-emerald-500/10 dark:ring-emerald-500/30 animate-pulse",Ee.has(ye)&&"opacity-0 translate-y-2 scale-[0.98]"].filter(Boolean).join(" "),onClick:Et?void 0:()=>ae(de),onKeyDown:se=>{(se.key==="Enter"||se.key===" ")&&i(de)},onContextMenu:se=>ue(de,se),children:P.jsxs(Pn,{noBodyPadding:!0,className:"overflow-hidden",children:[P.jsxs("div",{id:H,className:"relative aspect-video bg-black/5 dark:bg-white/5",onClick:se=>{se.preventDefault(),se.stopPropagation(),!Et&&Q(ye)},children:[P.jsx(X0,{job:de,getFileName:Ms,durationSeconds:ee[ye],onDuration:ts,className:"w-full h-full",showPopover:!1,blur:t,animated:!0,animatedMode:"clips",animatedTrigger:"always",clipSeconds:1,thumbSamples:18,inlineVideo:Se?"always":!1,inlineNonce:He,inlineControls:Se,inlineLoop:!1}),P.jsx("div",{className:["pointer-events-none absolute inset-x-0 bottom-0 h-20 bg-gradient-to-t from-black/70 to-transparent","transition-opacity duration-150",Se?"opacity-0":"opacity-100"].join(" ")}),P.jsxs("div",{className:["pointer-events-none absolute inset-x-3 bottom-3 flex items-end justify-between gap-3","transition-opacity duration-150",Se?"opacity-0":"opacity-100"].join(" "),children:[P.jsxs("div",{className:"min-w-0",children:[P.jsx("div",{className:"truncate text-sm font-semibold text-white",children:gi}),P.jsx("div",{className:"truncate text-[11px] text-white/80",children:wu(Oi)||"—"})]}),P.jsx("div",{className:"shrink-0 flex items-center gap-2",children:Oi.startsWith("HOT ")?P.jsx("span",{className:"rounded-md bg-amber-500/25 px-2 py-1 text-[11px] font-semibold text-white",children:"HOT"}):null})]}),!Et&&oe?.key===ye&&P.jsx("button",{type:"button",className:"absolute left-2 top-2 z-10 rounded-md bg-black/40 px-2 py-1 text-xs font-semibold text-white backdrop-blur hover:bg-black/60",onClick:se=>{se.preventDefault(),se.stopPropagation(),Y(Ce=>({key:ye,nonce:Ce?.key===ye?Ce.nonce+1:1}))},title:"Von vorne starten","aria-label":"Von vorne starten",children:"↻"}),P.jsx("div",{className:"absolute right-2 top-2 flex items-center gap-2",children:(()=>{const se="inline-flex items-center justify-center rounded-md bg-black/40 p-2 text-white backdrop-blur hover:bg-black/60 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-500",Ce=Ms(de.output||""),Ge=Ce.startsWith("HOT "),at=sl(de.output),Mt=R[qS(at)],xi=!!Mt?.favorite,Pi=Mt?.liked===!0;return P.jsxs(P.Fragment,{children:[!Et&&P.jsxs(P.Fragment,{children:[P.jsx("button",{type:"button",className:se,title:"Behalten (nach keep verschieben)","aria-label":"Behalten",disabled:it,onPointerDown:ut=>ut.stopPropagation(),onClick:ut=>{ut.preventDefault(),ut.stopPropagation(),qt(de)},children:P.jsx(mp,{className:"size-5 text-emerald-300"})}),P.jsx("button",{type:"button",className:se,title:"Löschen","aria-label":"Löschen",disabled:it,onPointerDown:ut=>ut.stopPropagation(),onClick:ut=>{ut.preventDefault(),ut.stopPropagation(),ht(de)},children:P.jsx(Pd,{className:"size-5 text-red-300"})})]}),P.jsx("button",{type:"button",className:se,title:Ge?"HOT entfernen":"Als HOT markieren","aria-label":Ge?"HOT entfernen":"Als HOT markieren",disabled:it||!r,onPointerDown:ut=>ut.stopPropagation(),onClick:async ut=>{ut.preventDefault(),ut.stopPropagation(),rt(Ce,{close:!0}),await new Promise(Mi=>setTimeout(Mi,150)),await r?.(de)},children:P.jsx(EA,{className:Z0("size-5",Ge?"text-amber-300":"text-white/90")})}),P.jsx("button",{type:"button",className:se,title:xi?"Favorit entfernen":"Als Favorit markieren","aria-label":xi?"Favorit entfernen":"Als Favorit markieren",disabled:it||!o,onPointerDown:ut=>ut.stopPropagation(),onClick:async ut=>{ut.preventDefault(),ut.stopPropagation(),await o?.(de)},children:(()=>{const ut=xi?dP:sP;return P.jsx(ut,{className:Z0("size-5",xi?"text-amber-300":"text-white/90")})})()}),P.jsx("button",{type:"button",className:se,title:Pi?"Gefällt mir entfernen":"Als Gefällt mir markieren","aria-label":Pi?"Gefällt mir entfernen":"Als Gefällt mir markieren",disabled:it||!u,onPointerDown:ut=>ut.stopPropagation(),onClick:async ut=>{ut.preventDefault(),ut.stopPropagation(),await u?.(de)},children:(()=>{const ut=Pi?uP:AA;return P.jsx(ut,{className:Z0("size-5",Pi?"text-rose-300":"text-white/90")})})()}),P.jsx("button",{type:"button",className:se,title:"Aktionen","aria-label":"Aktionen",onPointerDown:ut=>ut.stopPropagation(),onClick:ut=>{ut.preventDefault(),ut.stopPropagation();const Mi=ut.currentTarget.getBoundingClientRect();U(de,Mi.left,Mi.bottom+6)},children:P.jsx(VS,{className:"size-5"})})]})})()})]}),P.jsxs("div",{className:"px-4 py-3",children:[P.jsx("div",{className:"flex items-center justify-between gap-3 text-xs text-gray-600 dark:text-gray-300",children:P.jsxs("div",{className:"min-w-0 truncate",children:["Status: ",ws,P.jsx("span",{className:"mx-2 opacity-60",children:"•"}),"Dauer: ",P.jsx("span",{className:"font-medium",children:Wi}),P.jsx("span",{className:"mx-2 opacity-60",children:"•"}),"Größe: ",P.jsx("span",{className:"font-medium",children:Ht})]})}),de.output?P.jsx("div",{className:"mt-1 truncate text-xs text-gray-500 dark:text-gray-400",title:de.output,children:de.output}):null]})]})});return Et?P.jsx(hP,{ref:se=>{se?k.current.set(ye,se):k.current.delete(ye)},enabled:!0,disabled:it,ignoreFromBottomPx:110,onTap:()=>{const se=`inline-prev-${encodeURIComponent(ye)}`;ih.flushSync(()=>Q(ye)),Z(se)||requestAnimationFrame(()=>Z(se))},onSwipeLeft:()=>ht(de),onSwipeRight:()=>qt(de),children:K},ye):P.jsx(j.Fragment,{children:K},ye)})}),B==="table"&&P.jsx(vm,{rows:$t,columns:vs,getRowKey:de=>$i(de),striped:!0,fullWidth:!0,stickyHeader:!0,compact:!0,sort:w,onSortChange:I,onRowClick:i,onRowContextMenu:(de,ye)=>ue(de,ye),rowClassName:de=>{const ye=$i(de);return["transition-all duration-300",(_.has(ye)||Ee.has(ye))&&"bg-red-50/60 dark:bg-red-500/10 pointer-events-none",_.has(ye)&&"animate-pulse",(xe.has(ye)||Ee.has(ye))&&"pointer-events-none",xe.has(ye)&&"bg-emerald-50/60 dark:bg-emerald-500/10 animate-pulse",Ee.has(ye)&&"opacity-0"].filter(Boolean).join(" ")}}),B==="gallery"&&P.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4",children:$t.map(de=>{const ye=$i(de),Se=sl(de.output),He=Ms(de.output||""),it=pi(de),gi=J0(yd(de)),Oi=_.has(ye)||xe.has(ye)||Ee.has(ye),Wi=v.has(ye);return P.jsxs("div",{role:"button",tabIndex:0,className:["group relative overflow-hidden rounded-lg outline-1 outline-black/5 dark:-outline-offset-1 dark:outline-white/10","bg-white dark:bg-gray-900/40","transition-all duration-200","hover:-translate-y-0.5 hover:shadow-md dark:hover:shadow-none","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 dark:focus-visible:outline-indigo-500",Oi&&"pointer-events-none opacity-70",_.has(ye)&&"ring-1 ring-red-300 bg-red-50/60 dark:bg-red-500/10 dark:ring-red-500/30",Ee.has(ye)&&"opacity-0 translate-y-2 scale-[0.98]",Wi&&"hidden"].filter(Boolean).join(" "),onClick:()=>i(de),onKeyDown:Ht=>{(Ht.key==="Enter"||Ht.key===" ")&&i(de)},onContextMenu:Ht=>ue(de,Ht),children:[P.jsxs("div",{className:"group relative aspect-video bg-black/5 dark:bg-white/5",onContextMenu:Ht=>{Ht.preventDefault(),Ht.stopPropagation(),ue(de,Ht)},children:[P.jsx(X0,{job:de,getFileName:Ms,durationSeconds:ee[ye],onDuration:ts,variant:"fill",showPopover:!1,blur:t,animated:!0,animatedMode:"clips",animatedTrigger:"hover",clipSeconds:1,thumbSamples:18}),P.jsx("div",{className:`
pointer-events-none absolute inset-x-0 bottom-0 h-16
bg-gradient-to-t from-black/65 to-transparent
transition-opacity duration-150
group-hover:opacity-0 group-focus-within:opacity-0
`}),P.jsxs("div",{className:`
pointer-events-none absolute inset-x-0 bottom-0 p-2 text-white
transition-opacity duration-150
group-hover:opacity-0 group-focus-within:opacity-0
`,children:[P.jsx("div",{className:"truncate text-xs font-semibold",children:Se}),P.jsxs("div",{className:"mt-0.5 flex items-center justify-between gap-2 text-[11px] opacity-90",children:[P.jsx("span",{className:"truncate",children:wu(He)||"—"}),P.jsxs("div",{className:"shrink-0 flex items-center gap-1.5",children:[P.jsx("span",{className:"rounded bg-black/40 px-1.5 py-0.5 font-medium",children:it}),P.jsx("span",{className:"rounded bg-black/40 px-1.5 py-0.5 font-medium",children:gi})]})]})]}),P.jsx("button",{type:"button",className:["absolute right-12 top-2 z-10 rounded-md px-2 py-1 text-xs font-semibold","bg-black/55 text-white hover:bg-black/70","opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity"].join(" "),"aria-label":"Behalten",title:"Behalten (nach keep verschieben)",disabled:Oi,onClick:Ht=>{Ht.preventDefault(),Ht.stopPropagation(),qt(de)},children:P.jsx(mp,{className:"size-5 text-emerald-600 dark:text-emerald-300"})}),P.jsx("button",{type:"button",className:["absolute right-2 top-2 z-10 rounded-md px-2 py-1 text-xs font-semibold","bg-black/55 text-white hover:bg-black/70","opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity"].join(" "),"aria-label":"Video löschen",title:"Video löschen",onClick:Ht=>{Ht.preventDefault(),Ht.stopPropagation(),ht(de)},children:P.jsx(Pd,{className:"size-5 text-red-600 dark:text-red-300"})}),P.jsx("button",{type:"button",className:["absolute left-2 top-2 z-10 rounded-md px-2 py-1 text-xs font-semibold","bg-black/55 text-white hover:bg-black/70","opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity"].join(" "),"aria-label":"Aktionen",title:"Aktionen",onClick:Ht=>{Ht.preventDefault(),Ht.stopPropagation();const ws=Ht.currentTarget.getBoundingClientRect();U(de,ws.left,ws.bottom+6)},children:"⋯"})]}),P.jsx("div",{className:"px-3 py-2",children:P.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs text-gray-600 dark:text-gray-300",children:[P.jsxs("span",{className:"truncate",children:["Status:"," ",de.status==="failed"?P.jsxs("span",{className:"text-red-700 dark:text-red-300",title:de.error||"",children:["failed",gd(de.error)?` (${gd(de.error)})`:""]}):P.jsx("span",{className:"font-medium",children:de.status})]}),Ms(de.output||"").startsWith("HOT ")?P.jsx("span",{className:"shrink-0 rounded bg-amber-100 px-2 py-0.5 text-[11px] font-semibold text-amber-800 dark:bg-amber-500/15 dark:text-amber-200",children:"HOT"}):null]})})]},ye)})}),P.jsx(FO,{open:!!m,x:m?.x??0,y:m?.y??0,items:xt,onClose:()=>g(null)}),Be.length>d?P.jsx("div",{className:"mt-3 flex justify-center",children:P.jsxs(es,{className:"rounded-md bg-black/5 px-3 py-2 text-sm font-medium hover:bg-black/10 dark:bg-white/10 dark:hover:bg-white/15",onClick:()=>f(de=>Math.min(Be.length,de+50)),children:["Mehr laden (",Math.min(50,Be.length-d)," von ",Be.length-d,")"]})}):null]})}var ey,zS;function Tm(){if(zS)return ey;zS=1;var s;return typeof window<"u"?s=window:typeof Dp<"u"?s=Dp:typeof self<"u"?s=self:s={},ey=s,ey}var gP=Tm();const ne=ac(gP),yP={},vP=Object.freeze(Object.defineProperty({__proto__:null,default:yP},Symbol.toStringTag,{value:"Module"})),TP=nk(vP);var ty,KS;function wA(){if(KS)return ty;KS=1;var s=typeof Dp<"u"?Dp:typeof window<"u"?window:{},e=TP,t;return typeof document<"u"?t=document:(t=s["__GLOBAL_DOCUMENT_CACHE@4"],t||(t=s["__GLOBAL_DOCUMENT_CACHE@4"]=e)),ty=t,ty}var bP=wA();const Ve=ac(bP);var Gf={exports:{}},iy={exports:{}},YS;function _P(){return YS||(YS=1,(function(s){function e(){return s.exports=e=Object.assign?Object.assign.bind():function(t){for(var i=1;i<arguments.length;i++){var n=arguments[i];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},s.exports.__esModule=!0,s.exports.default=s.exports,e.apply(null,arguments)}s.exports=e,s.exports.__esModule=!0,s.exports.default=s.exports})(iy)),iy.exports}var sy,WS;function xP(){if(WS)return sy;WS=1,sy=e;var s=Object.prototype.toString;function e(t){if(!t)return!1;var i=s.call(t);return i==="[object Function]"||typeof t=="function"&&i!=="[object RegExp]"||typeof window<"u"&&(t===window.setTimeout||t===window.alert||t===window.confirm||t===window.prompt)}return sy}var ny,XS;function SP(){if(XS)return ny;XS=1;function s(n,r){var o=typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(o)return(o=o.call(n)).next.bind(o);if(Array.isArray(n)||(o=e(n))||r){o&&(n=o);var u=0;return function(){return u>=n.length?{done:!0}:{done:!1,value:n[u++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function e(n,r){if(n){if(typeof n=="string")return t(n,r);var o=Object.prototype.toString.call(n).slice(8,-1);if(o==="Object"&&n.constructor&&(o=n.constructor.name),o==="Map"||o==="Set")return Array.from(n);if(o==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return t(n,r)}}function t(n,r){(r==null||r>n.length)&&(r=n.length);for(var o=0,u=new Array(r);o<r;o++)u[o]=n[o];return u}var i=(function(){function n(){this.typeToInterceptorsMap_=new Map,this.enabled_=!1}var r=n.prototype;return r.getIsEnabled=function(){return this.enabled_},r.enable=function(){this.enabled_=!0},r.disable=function(){this.enabled_=!1},r.reset=function(){this.typeToInterceptorsMap_=new Map,this.enabled_=!1},r.addInterceptor=function(u,c){this.typeToInterceptorsMap_.has(u)||this.typeToInterceptorsMap_.set(u,new Set);var d=this.typeToInterceptorsMap_.get(u);return d.has(c)?!1:(d.add(c),!0)},r.removeInterceptor=function(u,c){var d=this.typeToInterceptorsMap_.get(u);return d&&d.has(c)?(d.delete(c),!0):!1},r.clearInterceptorsByType=function(u){var c=this.typeToInterceptorsMap_.get(u);return c?(this.typeToInterceptorsMap_.delete(u),this.typeToInterceptorsMap_.set(u,new Set),!0):!1},r.clear=function(){return this.typeToInterceptorsMap_.size?(this.typeToInterceptorsMap_=new Map,!0):!1},r.getForType=function(u){return this.typeToInterceptorsMap_.get(u)||new Set},r.execute=function(u,c){for(var d=this.getForType(u),f=s(d),m;!(m=f()).done;){var g=m.value;try{c=g(c)}catch{}}return c},n})();return ny=i,ny}var ry,QS;function EP(){if(QS)return ry;QS=1;var s=(function(){function t(){this.maxAttempts_=1,this.delayFactor_=.1,this.fuzzFactor_=.1,this.initialDelay_=1e3,this.enabled_=!1}var i=t.prototype;return i.getIsEnabled=function(){return this.enabled_},i.enable=function(){this.enabled_=!0},i.disable=function(){this.enabled_=!1},i.reset=function(){this.maxAttempts_=1,this.delayFactor_=.1,this.fuzzFactor_=.1,this.initialDelay_=1e3,this.enabled_=!1},i.getMaxAttempts=function(){return this.maxAttempts_},i.setMaxAttempts=function(r){this.maxAttempts_=r},i.getDelayFactor=function(){return this.delayFactor_},i.setDelayFactor=function(r){this.delayFactor_=r},i.getFuzzFactor=function(){return this.fuzzFactor_},i.setFuzzFactor=function(r){this.fuzzFactor_=r},i.getInitialDelay=function(){return this.initialDelay_},i.setInitialDelay=function(r){this.initialDelay_=r},i.createRetry=function(r){var o=r===void 0?{}:r,u=o.maxAttempts,c=o.delayFactor,d=o.fuzzFactor,f=o.initialDelay;return new e({maxAttempts:u||this.maxAttempts_,delayFactor:c||this.delayFactor_,fuzzFactor:d||this.fuzzFactor_,initialDelay:f||this.initialDelay_})},t})(),e=(function(){function t(n){this.maxAttempts_=n.maxAttempts,this.delayFactor_=n.delayFactor,this.fuzzFactor_=n.fuzzFactor,this.currentDelay_=n.initialDelay,this.currentAttempt_=1}var i=t.prototype;return i.moveToNextAttempt=function(){this.currentAttempt_++;var r=this.currentDelay_*this.delayFactor_;this.currentDelay_=this.currentDelay_+r},i.shouldRetry=function(){return this.currentAttempt_<this.maxAttempts_},i.getCurrentDelay=function(){return this.currentDelay_},i.getCurrentMinPossibleDelay=function(){return(1-this.fuzzFactor_)*this.currentDelay_},i.getCurrentMaxPossibleDelay=function(){return(1+this.fuzzFactor_)*this.currentDelay_},i.getCurrentFuzzedDelay=function(){var r=this.getCurrentMinPossibleDelay(),o=this.getCurrentMaxPossibleDelay();return r+Math.random()*(o-r)},t})();return ry=s,ry}var ay,ZS;function AP(){if(ZS)return ay;ZS=1;var s=Tm(),e=function(n,r){return r===void 0&&(r=!1),function(o,u,c){if(o){n(o);return}if(u.statusCode>=400&&u.statusCode<=599){var d=c;if(r)if(s.TextDecoder){var f=t(u.headers&&u.headers["content-type"]);try{d=new TextDecoder(f).decode(c)}catch{}}else d=String.fromCharCode.apply(null,new Uint8Array(c));n({cause:d});return}n(null,c)}};function t(i){return i===void 0&&(i=""),i.toLowerCase().split(";").reduce(function(n,r){var o=r.split("="),u=o[0],c=o[1];return u.trim()==="charset"?c.trim():n},"utf-8")}return ay=e,ay}var JS;function CP(){if(JS)return Gf.exports;JS=1;var s=Tm(),e=_P(),t=xP(),i=SP(),n=EP();d.httpHandler=AP(),d.requestInterceptorsStorage=new i,d.responseInterceptorsStorage=new i,d.retryManager=new n;var r=function(b){var _={};return b&&b.trim().split(`
`).forEach(function(E){var w=E.indexOf(":"),I=E.slice(0,w).trim().toLowerCase(),L=E.slice(w+1).trim();typeof _[I]>"u"?_[I]=L:Array.isArray(_[I])?_[I].push(L):_[I]=[_[I],L]}),_};Gf.exports=d,Gf.exports.default=d,d.XMLHttpRequest=s.XMLHttpRequest||g,d.XDomainRequest="withCredentials"in new d.XMLHttpRequest?d.XMLHttpRequest:s.XDomainRequest,o(["get","put","post","patch","head","delete"],function(v){d[v==="delete"?"del":v]=function(b,_,E){return _=c(b,_,E),_.method=v.toUpperCase(),f(_)}});function o(v,b){for(var _=0;_<v.length;_++)b(v[_])}function u(v){for(var b in v)if(v.hasOwnProperty(b))return!1;return!0}function c(v,b,_){var E=v;return t(b)?(_=b,typeof v=="string"&&(E={uri:v})):E=e({},b,{uri:v}),E.callback=_,E}function d(v,b,_){return b=c(v,b,_),f(b)}function f(v){if(typeof v.callback>"u")throw new Error("callback argument missing");if(v.requestType&&d.requestInterceptorsStorage.getIsEnabled()){var b={uri:v.uri||v.url,headers:v.headers||{},body:v.body,metadata:v.metadata||{},retry:v.retry,timeout:v.timeout},_=d.requestInterceptorsStorage.execute(v.requestType,b);v.uri=_.uri,v.headers=_.headers,v.body=_.body,v.metadata=_.metadata,v.retry=_.retry,v.timeout=_.timeout}var E=!1,w=function(Q,ae,ue){E||(E=!0,v.callback(Q,ae,ue))};function I(){G.readyState===4&&!d.responseInterceptorsStorage.getIsEnabled()&&setTimeout($,0)}function L(){var Z=void 0;if(G.response?Z=G.response:Z=G.responseText||m(G),le)try{Z=JSON.parse(Z)}catch{}return Z}function F(Z){if(clearTimeout(oe),clearTimeout(v.retryTimeout),Z instanceof Error||(Z=new Error(""+(Z||"Unknown XMLHttpRequest Error"))),Z.statusCode=0,!V&&d.retryManager.getIsEnabled()&&v.retry&&v.retry.shouldRetry()){v.retryTimeout=setTimeout(function(){v.retry.moveToNextAttempt(),v.xhr=G,f(v)},v.retry.getCurrentFuzzedDelay());return}if(v.requestType&&d.responseInterceptorsStorage.getIsEnabled()){var Q={headers:Y.headers||{},body:Y.body,responseUrl:G.responseURL,responseType:G.responseType},ae=d.responseInterceptorsStorage.execute(v.requestType,Q);Y.body=ae.body,Y.headers=ae.headers}return w(Z,Y)}function $(){if(!V){var Z;clearTimeout(oe),clearTimeout(v.retryTimeout),v.useXDR&&G.status===void 0?Z=200:Z=G.status===1223?204:G.status;var Q=Y,ae=null;if(Z!==0?(Q={body:L(),statusCode:Z,method:R,headers:{},url:k,rawRequest:G},G.getAllResponseHeaders&&(Q.headers=r(G.getAllResponseHeaders()))):ae=new Error("Internal XMLHttpRequest Error"),v.requestType&&d.responseInterceptorsStorage.getIsEnabled()){var ue={headers:Q.headers||{},body:Q.body,responseUrl:G.responseURL,responseType:G.responseType},U=d.responseInterceptorsStorage.execute(v.requestType,ue);Q.body=U.body,Q.headers=U.headers}return w(ae,Q,Q.body)}}var G=v.xhr||null;G||(v.cors||v.useXDR?G=new d.XDomainRequest:G=new d.XMLHttpRequest);var B,V,k=G.url=v.uri||v.url,R=G.method=v.method||"GET",z=v.body||v.data,X=G.headers=v.headers||{},ee=!!v.sync,le=!1,oe,Y={body:void 0,headers:{},statusCode:0,method:R,url:k,rawRequest:G};if("json"in v&&v.json!==!1&&(le=!0,X.accept||X.Accept||(X.Accept="application/json"),R!=="GET"&&R!=="HEAD"&&(X["content-type"]||X["Content-Type"]||(X["Content-Type"]="application/json"),z=JSON.stringify(v.json===!0?z:v.json))),G.onreadystatechange=I,G.onload=$,G.onerror=F,G.onprogress=function(){},G.onabort=function(){V=!0,clearTimeout(v.retryTimeout)},G.ontimeout=F,G.open(R,k,!ee,v.username,v.password),ee||(G.withCredentials=!!v.withCredentials),!ee&&v.timeout>0&&(oe=setTimeout(function(){if(!V){V=!0,G.abort("timeout");var Z=new Error("XMLHttpRequest timeout");Z.code="ETIMEDOUT",F(Z)}},v.timeout)),G.setRequestHeader)for(B in X)X.hasOwnProperty(B)&&G.setRequestHeader(B,X[B]);else if(v.headers&&!u(v.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in v&&(G.responseType=v.responseType),"beforeSend"in v&&typeof v.beforeSend=="function"&&v.beforeSend(G),G.send(z||null),G}function m(v){try{if(v.responseType==="document")return v.responseXML;var b=v.responseXML&&v.responseXML.documentElement.nodeName==="parsererror";if(v.responseType===""&&!b)return v.responseXML}catch{}return null}function g(){}return Gf.exports}var DP=CP();const LA=ac(DP);var oy={exports:{}},ly,eE;function wP(){if(eE)return ly;eE=1;var s=wA(),e=Object.create||(function(){function k(){}return function(R){if(arguments.length!==1)throw new Error("Object.create shim only accepts one parameter.");return k.prototype=R,new k}})();function t(k,R){this.name="ParsingError",this.code=k.code,this.message=R||k.message}t.prototype=e(Error.prototype),t.prototype.constructor=t,t.Errors={BadSignature:{code:0,message:"Malformed WebVTT signature."},BadTimeStamp:{code:1,message:"Malformed time stamp."}};function i(k){function R(X,ee,le,oe){return(X|0)*3600+(ee|0)*60+(le|0)+(oe|0)/1e3}var z=k.match(/^(\d+):(\d{1,2})(:\d{1,2})?\.(\d{3})/);return z?z[3]?R(z[1],z[2],z[3].replace(":",""),z[4]):z[1]>59?R(z[1],z[2],0,z[4]):R(0,z[1],z[2],z[4]):null}function n(){this.values=e(null)}n.prototype={set:function(k,R){!this.get(k)&&R!==""&&(this.values[k]=R)},get:function(k,R,z){return z?this.has(k)?this.values[k]:R[z]:this.has(k)?this.values[k]:R},has:function(k){return k in this.values},alt:function(k,R,z){for(var X=0;X<z.length;++X)if(R===z[X]){this.set(k,R);break}},integer:function(k,R){/^-?\d+$/.test(R)&&this.set(k,parseInt(R,10))},percent:function(k,R){return R.match(/^([\d]{1,3})(\.[\d]*)?%$/)&&(R=parseFloat(R),R>=0&&R<=100)?(this.set(k,R),!0):!1}};function r(k,R,z,X){var ee=X?k.split(X):[k];for(var le in ee)if(typeof ee[le]=="string"){var oe=ee[le].split(z);if(oe.length===2){var Y=oe[0].trim(),Z=oe[1].trim();R(Y,Z)}}}function o(k,R,z){var X=k;function ee(){var Y=i(k);if(Y===null)throw new t(t.Errors.BadTimeStamp,"Malformed timestamp: "+X);return k=k.replace(/^[^\sa-zA-Z-]+/,""),Y}function le(Y,Z){var Q=new n;r(Y,function(ae,ue){switch(ae){case"region":for(var U=z.length-1;U>=0;U--)if(z[U].id===ue){Q.set(ae,z[U].region);break}break;case"vertical":Q.alt(ae,ue,["rl","lr"]);break;case"line":var ie=ue.split(","),fe=ie[0];Q.integer(ae,fe),Q.percent(ae,fe)&&Q.set("snapToLines",!1),Q.alt(ae,fe,["auto"]),ie.length===2&&Q.alt("lineAlign",ie[1],["start","center","end"]);break;case"position":ie=ue.split(","),Q.percent(ae,ie[0]),ie.length===2&&Q.alt("positionAlign",ie[1],["start","center","end"]);break;case"size":Q.percent(ae,ue);break;case"align":Q.alt(ae,ue,["start","center","end","left","right"]);break}},/:/,/\s/),Z.region=Q.get("region",null),Z.vertical=Q.get("vertical","");try{Z.line=Q.get("line","auto")}catch{}Z.lineAlign=Q.get("lineAlign","start"),Z.snapToLines=Q.get("snapToLines",!0),Z.size=Q.get("size",100);try{Z.align=Q.get("align","center")}catch{Z.align=Q.get("align","middle")}try{Z.position=Q.get("position","auto")}catch{Z.position=Q.get("position",{start:0,left:0,center:50,middle:50,end:100,right:100},Z.align)}Z.positionAlign=Q.get("positionAlign",{start:"start",left:"start",center:"center",middle:"center",end:"end",right:"end"},Z.align)}function oe(){k=k.replace(/^\s+/,"")}if(oe(),R.startTime=ee(),oe(),k.substr(0,3)!=="-->")throw new t(t.Errors.BadTimeStamp,"Malformed time stamp (time stamps must be separated by '-->'): "+X);k=k.substr(3),oe(),R.endTime=ee(),oe(),le(k,R)}var u=s.createElement&&s.createElement("textarea"),c={c:"span",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"span",lang:"span"},d={white:"rgba(255,255,255,1)",lime:"rgba(0,255,0,1)",cyan:"rgba(0,255,255,1)",red:"rgba(255,0,0,1)",yellow:"rgba(255,255,0,1)",magenta:"rgba(255,0,255,1)",blue:"rgba(0,0,255,1)",black:"rgba(0,0,0,1)"},f={v:"title",lang:"lang"},m={rt:"ruby"};function g(k,R){function z(){if(!R)return null;function fe(Ae){return R=R.substr(Ae.length),Ae}var xe=R.match(/^([^<]*)(<[^>]*>?)?/);return fe(xe[1]?xe[1]:xe[2])}function X(fe){return u.innerHTML=fe,fe=u.textContent,u.textContent="",fe}function ee(fe,xe){return!m[xe.localName]||m[xe.localName]===fe.localName}function le(fe,xe){var Ae=c[fe];if(!Ae)return null;var $e=k.document.createElement(Ae),Ee=f[fe];return Ee&&xe&&($e[Ee]=xe.trim()),$e}for(var oe=k.document.createElement("div"),Y=oe,Z,Q=[];(Z=z())!==null;){if(Z[0]==="<"){if(Z[1]==="/"){Q.length&&Q[Q.length-1]===Z.substr(2).replace(">","")&&(Q.pop(),Y=Y.parentNode);continue}var ae=i(Z.substr(1,Z.length-2)),ue;if(ae){ue=k.document.createProcessingInstruction("timestamp",ae),Y.appendChild(ue);continue}var U=Z.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);if(!U||(ue=le(U[1],U[3]),!ue)||!ee(Y,ue))continue;if(U[2]){var ie=U[2].split(".");ie.forEach(function(fe){var xe=/^bg_/.test(fe),Ae=xe?fe.slice(3):fe;if(d.hasOwnProperty(Ae)){var $e=xe?"background-color":"color",Ee=d[Ae];ue.style[$e]=Ee}}),ue.className=ie.join(" ")}Q.push(U[1]),Y.appendChild(ue),Y=ue;continue}Y.appendChild(k.document.createTextNode(X(Z)))}return oe}var v=[[1470,1470],[1472,1472],[1475,1475],[1478,1478],[1488,1514],[1520,1524],[1544,1544],[1547,1547],[1549,1549],[1563,1563],[1566,1610],[1645,1647],[1649,1749],[1765,1766],[1774,1775],[1786,1805],[1807,1808],[1810,1839],[1869,1957],[1969,1969],[1984,2026],[2036,2037],[2042,2042],[2048,2069],[2074,2074],[2084,2084],[2088,2088],[2096,2110],[2112,2136],[2142,2142],[2208,2208],[2210,2220],[8207,8207],[64285,64285],[64287,64296],[64298,64310],[64312,64316],[64318,64318],[64320,64321],[64323,64324],[64326,64449],[64467,64829],[64848,64911],[64914,64967],[65008,65020],[65136,65140],[65142,65276],[67584,67589],[67592,67592],[67594,67637],[67639,67640],[67644,67644],[67647,67669],[67671,67679],[67840,67867],[67872,67897],[67903,67903],[67968,68023],[68030,68031],[68096,68096],[68112,68115],[68117,68119],[68121,68147],[68160,68167],[68176,68184],[68192,68223],[68352,68405],[68416,68437],[68440,68466],[68472,68479],[68608,68680],[126464,126467],[126469,126495],[126497,126498],[126500,126500],[126503,126503],[126505,126514],[126516,126519],[126521,126521],[126523,126523],[126530,126530],[126535,126535],[126537,126537],[126539,126539],[126541,126543],[126545,126546],[126548,126548],[126551,126551],[126553,126553],[126555,126555],[126557,126557],[126559,126559],[126561,126562],[126564,126564],[126567,126570],[126572,126578],[126580,126583],[126585,126588],[126590,126590],[126592,126601],[126603,126619],[126625,126627],[126629,126633],[126635,126651],[1114109,1114109]];function b(k){for(var R=0;R<v.length;R++){var z=v[R];if(k>=z[0]&&k<=z[1])return!0}return!1}function _(k){var R=[],z="",X;if(!k||!k.childNodes)return"ltr";function ee(Y,Z){for(var Q=Z.childNodes.length-1;Q>=0;Q--)Y.push(Z.childNodes[Q])}function le(Y){if(!Y||!Y.length)return null;var Z=Y.pop(),Q=Z.textContent||Z.innerText;if(Q){var ae=Q.match(/^.*(\n|\r)/);return ae?(Y.length=0,ae[0]):Q}if(Z.tagName==="ruby")return le(Y);if(Z.childNodes)return ee(Y,Z),le(Y)}for(ee(R,k);z=le(R);)for(var oe=0;oe<z.length;oe++)if(X=z.charCodeAt(oe),b(X))return"rtl";return"ltr"}function E(k){if(typeof k.line=="number"&&(k.snapToLines||k.line>=0&&k.line<=100))return k.line;if(!k.track||!k.track.textTrackList||!k.track.textTrackList.mediaElement)return-1;for(var R=k.track,z=R.textTrackList,X=0,ee=0;ee<z.length&&z[ee]!==R;ee++)z[ee].mode==="showing"&&X++;return++X*-1}function w(){}w.prototype.applyStyles=function(k,R){R=R||this.div;for(var z in k)k.hasOwnProperty(z)&&(R.style[z]=k[z])},w.prototype.formatStyle=function(k,R){return k===0?0:k+R};function I(k,R,z){w.call(this),this.cue=R,this.cueDiv=g(k,R.text);var X={color:"rgba(255, 255, 255, 1)",backgroundColor:"rgba(0, 0, 0, 0.8)",position:"relative",left:0,right:0,top:0,bottom:0,display:"inline",writingMode:R.vertical===""?"horizontal-tb":R.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext"};this.applyStyles(X,this.cueDiv),this.div=k.document.createElement("div"),X={direction:_(this.cueDiv),writingMode:R.vertical===""?"horizontal-tb":R.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext",textAlign:R.align==="middle"?"center":R.align,font:z.font,whiteSpace:"pre-line",position:"absolute"},this.applyStyles(X),this.div.appendChild(this.cueDiv);var ee=0;switch(R.positionAlign){case"start":case"line-left":ee=R.position;break;case"center":ee=R.position-R.size/2;break;case"end":case"line-right":ee=R.position-R.size;break}R.vertical===""?this.applyStyles({left:this.formatStyle(ee,"%"),width:this.formatStyle(R.size,"%")}):this.applyStyles({top:this.formatStyle(ee,"%"),height:this.formatStyle(R.size,"%")}),this.move=function(le){this.applyStyles({top:this.formatStyle(le.top,"px"),bottom:this.formatStyle(le.bottom,"px"),left:this.formatStyle(le.left,"px"),right:this.formatStyle(le.right,"px"),height:this.formatStyle(le.height,"px"),width:this.formatStyle(le.width,"px")})}}I.prototype=e(w.prototype),I.prototype.constructor=I;function L(k){var R,z,X,ee;if(k.div){z=k.div.offsetHeight,X=k.div.offsetWidth,ee=k.div.offsetTop;var le=(le=k.div.childNodes)&&(le=le[0])&&le.getClientRects&&le.getClientRects();k=k.div.getBoundingClientRect(),R=le?Math.max(le[0]&&le[0].height||0,k.height/le.length):0}this.left=k.left,this.right=k.right,this.top=k.top||ee,this.height=k.height||z,this.bottom=k.bottom||ee+(k.height||z),this.width=k.width||X,this.lineHeight=R!==void 0?R:k.lineHeight}L.prototype.move=function(k,R){switch(R=R!==void 0?R:this.lineHeight,k){case"+x":this.left+=R,this.right+=R;break;case"-x":this.left-=R,this.right-=R;break;case"+y":this.top+=R,this.bottom+=R;break;case"-y":this.top-=R,this.bottom-=R;break}},L.prototype.overlaps=function(k){return this.left<k.right&&this.right>k.left&&this.top<k.bottom&&this.bottom>k.top},L.prototype.overlapsAny=function(k){for(var R=0;R<k.length;R++)if(this.overlaps(k[R]))return!0;return!1},L.prototype.within=function(k){return this.top>=k.top&&this.bottom<=k.bottom&&this.left>=k.left&&this.right<=k.right},L.prototype.overlapsOppositeAxis=function(k,R){switch(R){case"+x":return this.left<k.left;case"-x":return this.right>k.right;case"+y":return this.top<k.top;case"-y":return this.bottom>k.bottom}},L.prototype.intersectPercentage=function(k){var R=Math.max(0,Math.min(this.right,k.right)-Math.max(this.left,k.left)),z=Math.max(0,Math.min(this.bottom,k.bottom)-Math.max(this.top,k.top)),X=R*z;return X/(this.height*this.width)},L.prototype.toCSSCompatValues=function(k){return{top:this.top-k.top,bottom:k.bottom-this.bottom,left:this.left-k.left,right:k.right-this.right,height:this.height,width:this.width}},L.getSimpleBoxPosition=function(k){var R=k.div?k.div.offsetHeight:k.tagName?k.offsetHeight:0,z=k.div?k.div.offsetWidth:k.tagName?k.offsetWidth:0,X=k.div?k.div.offsetTop:k.tagName?k.offsetTop:0;k=k.div?k.div.getBoundingClientRect():k.tagName?k.getBoundingClientRect():k;var ee={left:k.left,right:k.right,top:k.top||X,height:k.height||R,bottom:k.bottom||X+(k.height||R),width:k.width||z};return ee};function F(k,R,z,X){function ee(Ae,$e){for(var Ee,je=new L(Ae),qe=1,et=0;et<$e.length;et++){for(;Ae.overlapsOppositeAxis(z,$e[et])||Ae.within(z)&&Ae.overlapsAny(X);)Ae.move($e[et]);if(Ae.within(z))return Ae;var rt=Ae.intersectPercentage(z);qe>rt&&(Ee=new L(Ae),qe=rt),Ae=new L(je)}return Ee||je}var le=new L(R),oe=R.cue,Y=E(oe),Z=[];if(oe.snapToLines){var Q;switch(oe.vertical){case"":Z=["+y","-y"],Q="height";break;case"rl":Z=["+x","-x"],Q="width";break;case"lr":Z=["-x","+x"],Q="width";break}var ae=le.lineHeight,ue=ae*Math.round(Y),U=z[Q]+ae,ie=Z[0];Math.abs(ue)>U&&(ue=ue<0?-1:1,ue*=Math.ceil(U/ae)*ae),Y<0&&(ue+=oe.vertical===""?z.height:z.width,Z=Z.reverse()),le.move(ie,ue)}else{var fe=le.lineHeight/z.height*100;switch(oe.lineAlign){case"center":Y-=fe/2;break;case"end":Y-=fe;break}switch(oe.vertical){case"":R.applyStyles({top:R.formatStyle(Y,"%")});break;case"rl":R.applyStyles({left:R.formatStyle(Y,"%")});break;case"lr":R.applyStyles({right:R.formatStyle(Y,"%")});break}Z=["+y","-x","+x","-y"],le=new L(R)}var xe=ee(le,Z);R.move(xe.toCSSCompatValues(z))}function $(){}$.StringDecoder=function(){return{decode:function(k){if(!k)return"";if(typeof k!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(k))}}},$.convertCueToDOMTree=function(k,R){return!k||!R?null:g(k,R)};var G=.05,B="sans-serif",V="1.5%";return $.processCues=function(k,R,z){if(!k||!R||!z)return null;for(;z.firstChild;)z.removeChild(z.firstChild);var X=k.document.createElement("div");X.style.position="absolute",X.style.left="0",X.style.right="0",X.style.top="0",X.style.bottom="0",X.style.margin=V,z.appendChild(X);function ee(ae){for(var ue=0;ue<ae.length;ue++)if(ae[ue].hasBeenReset||!ae[ue].displayState)return!0;return!1}if(!ee(R)){for(var le=0;le<R.length;le++)X.appendChild(R[le].displayState);return}var oe=[],Y=L.getSimpleBoxPosition(X),Z=Math.round(Y.height*G*100)/100,Q={font:Z+"px "+B};(function(){for(var ae,ue,U=0;U<R.length;U++)ue=R[U],ae=new I(k,ue,Q),X.appendChild(ae.div),F(k,ae,Y,oe),ue.displayState=ae.div,oe.push(L.getSimpleBoxPosition(ae))})()},$.Parser=function(k,R,z){z||(z=R,R={}),R||(R={}),this.window=k,this.vttjs=R,this.state="INITIAL",this.buffer="",this.decoder=z||new TextDecoder("utf8"),this.regionList=[]},$.Parser.prototype={reportOrThrowError:function(k){if(k instanceof t)this.onparsingerror&&this.onparsingerror(k);else throw k},parse:function(k){var R=this;k&&(R.buffer+=R.decoder.decode(k,{stream:!0}));function z(){for(var ae=R.buffer,ue=0;ue<ae.length&&ae[ue]!=="\r"&&ae[ue]!==`
`;)++ue;var U=ae.substr(0,ue);return ae[ue]==="\r"&&++ue,ae[ue]===`
`&&++ue,R.buffer=ae.substr(ue),U}function X(ae){var ue=new n;if(r(ae,function(ie,fe){switch(ie){case"id":ue.set(ie,fe);break;case"width":ue.percent(ie,fe);break;case"lines":ue.integer(ie,fe);break;case"regionanchor":case"viewportanchor":var xe=fe.split(",");if(xe.length!==2)break;var Ae=new n;if(Ae.percent("x",xe[0]),Ae.percent("y",xe[1]),!Ae.has("x")||!Ae.has("y"))break;ue.set(ie+"X",Ae.get("x")),ue.set(ie+"Y",Ae.get("y"));break;case"scroll":ue.alt(ie,fe,["up"]);break}},/=/,/\s/),ue.has("id")){var U=new(R.vttjs.VTTRegion||R.window.VTTRegion);U.width=ue.get("width",100),U.lines=ue.get("lines",3),U.regionAnchorX=ue.get("regionanchorX",0),U.regionAnchorY=ue.get("regionanchorY",100),U.viewportAnchorX=ue.get("viewportanchorX",0),U.viewportAnchorY=ue.get("viewportanchorY",100),U.scroll=ue.get("scroll",""),R.onregion&&R.onregion(U),R.regionList.push({id:ue.get("id"),region:U})}}function ee(ae){var ue=new n;r(ae,function(U,ie){switch(U){case"MPEGT":ue.integer(U+"S",ie);break;case"LOCA":ue.set(U+"L",i(ie));break}},/[^\d]:/,/,/),R.ontimestampmap&&R.ontimestampmap({MPEGTS:ue.get("MPEGTS"),LOCAL:ue.get("LOCAL")})}function le(ae){ae.match(/X-TIMESTAMP-MAP/)?r(ae,function(ue,U){ue==="X-TIMESTAMP-MAP"&&ee(U)},/=/):r(ae,function(ue,U){ue==="Region"&&X(U)},/:/)}try{var oe;if(R.state==="INITIAL"){if(!/\r\n|\n/.test(R.buffer))return this;oe=z();var Y=oe.match(/^WEBVTT([ \t].*)?$/);if(!Y||!Y[0])throw new t(t.Errors.BadSignature);R.state="HEADER"}for(var Z=!1;R.buffer;){if(!/\r\n|\n/.test(R.buffer))return this;switch(Z?Z=!1:oe=z(),R.state){case"HEADER":/:/.test(oe)?le(oe):oe||(R.state="ID");continue;case"NOTE":oe||(R.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(oe)){R.state="NOTE";break}if(!oe)continue;R.cue=new(R.vttjs.VTTCue||R.window.VTTCue)(0,0,"");try{R.cue.align="center"}catch{R.cue.align="middle"}if(R.state="CUE",oe.indexOf("-->")===-1){R.cue.id=oe;continue}case"CUE":try{o(oe,R.cue,R.regionList)}catch(ae){R.reportOrThrowError(ae),R.cue=null,R.state="BADCUE";continue}R.state="CUETEXT";continue;case"CUETEXT":var Q=oe.indexOf("-->")!==-1;if(!oe||Q&&(Z=!0)){R.oncue&&R.oncue(R.cue),R.cue=null,R.state="ID";continue}R.cue.text&&(R.cue.text+=`
`),R.cue.text+=oe.replace(/\u2028/g,`
`).replace(/u2029/g,`
`);continue;case"BADCUE":oe||(R.state="ID");continue}}}catch(ae){R.reportOrThrowError(ae),R.state==="CUETEXT"&&R.cue&&R.oncue&&R.oncue(R.cue),R.cue=null,R.state=R.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},flush:function(){var k=this;try{if(k.buffer+=k.decoder.decode(),(k.cue||k.state==="HEADER")&&(k.buffer+=`
`,k.parse()),k.state==="INITIAL")throw new t(t.Errors.BadSignature)}catch(R){k.reportOrThrowError(R)}return k.onflush&&k.onflush(),this}},ly=$,ly}var uy,tE;function LP(){if(tE)return uy;tE=1;var s="auto",e={"":1,lr:1,rl:1},t={start:1,center:1,end:1,left:1,right:1,auto:1,"line-left":1,"line-right":1};function i(o){if(typeof o!="string")return!1;var u=e[o.toLowerCase()];return u?o.toLowerCase():!1}function n(o){if(typeof o!="string")return!1;var u=t[o.toLowerCase()];return u?o.toLowerCase():!1}function r(o,u,c){this.hasBeenReset=!1;var d="",f=!1,m=o,g=u,v=c,b=null,_="",E=!0,w="auto",I="start",L="auto",F="auto",$=100,G="center";Object.defineProperties(this,{id:{enumerable:!0,get:function(){return d},set:function(B){d=""+B}},pauseOnExit:{enumerable:!0,get:function(){return f},set:function(B){f=!!B}},startTime:{enumerable:!0,get:function(){return m},set:function(B){if(typeof B!="number")throw new TypeError("Start time must be set to a number.");m=B,this.hasBeenReset=!0}},endTime:{enumerable:!0,get:function(){return g},set:function(B){if(typeof B!="number")throw new TypeError("End time must be set to a number.");g=B,this.hasBeenReset=!0}},text:{enumerable:!0,get:function(){return v},set:function(B){v=""+B,this.hasBeenReset=!0}},region:{enumerable:!0,get:function(){return b},set:function(B){b=B,this.hasBeenReset=!0}},vertical:{enumerable:!0,get:function(){return _},set:function(B){var V=i(B);if(V===!1)throw new SyntaxError("Vertical: an invalid or illegal direction string was specified.");_=V,this.hasBeenReset=!0}},snapToLines:{enumerable:!0,get:function(){return E},set:function(B){E=!!B,this.hasBeenReset=!0}},line:{enumerable:!0,get:function(){return w},set:function(B){if(typeof B!="number"&&B!==s)throw new SyntaxError("Line: an invalid number or illegal string was specified.");w=B,this.hasBeenReset=!0}},lineAlign:{enumerable:!0,get:function(){return I},set:function(B){var V=n(B);V?(I=V,this.hasBeenReset=!0):console.warn("lineAlign: an invalid or illegal string was specified.")}},position:{enumerable:!0,get:function(){return L},set:function(B){if(B<0||B>100)throw new Error("Position must be between 0 and 100.");L=B,this.hasBeenReset=!0}},positionAlign:{enumerable:!0,get:function(){return F},set:function(B){var V=n(B);V?(F=V,this.hasBeenReset=!0):console.warn("positionAlign: an invalid or illegal string was specified.")}},size:{enumerable:!0,get:function(){return $},set:function(B){if(B<0||B>100)throw new Error("Size must be between 0 and 100.");$=B,this.hasBeenReset=!0}},align:{enumerable:!0,get:function(){return G},set:function(B){var V=n(B);if(!V)throw new SyntaxError("align: an invalid or illegal alignment string was specified.");G=V,this.hasBeenReset=!0}}}),this.displayState=void 0}return r.prototype.getCueAsHTML=function(){return WebVTT.convertCueToDOMTree(window,this.text)},uy=r,uy}var cy,iE;function IP(){if(iE)return cy;iE=1;var s={"":!0,up:!0};function e(n){if(typeof n!="string")return!1;var r=s[n.toLowerCase()];return r?n.toLowerCase():!1}function t(n){return typeof n=="number"&&n>=0&&n<=100}function i(){var n=100,r=3,o=0,u=100,c=0,d=100,f="";Object.defineProperties(this,{width:{enumerable:!0,get:function(){return n},set:function(m){if(!t(m))throw new Error("Width must be between 0 and 100.");n=m}},lines:{enumerable:!0,get:function(){return r},set:function(m){if(typeof m!="number")throw new TypeError("Lines must be set to a number.");r=m}},regionAnchorY:{enumerable:!0,get:function(){return u},set:function(m){if(!t(m))throw new Error("RegionAnchorX must be between 0 and 100.");u=m}},regionAnchorX:{enumerable:!0,get:function(){return o},set:function(m){if(!t(m))throw new Error("RegionAnchorY must be between 0 and 100.");o=m}},viewportAnchorY:{enumerable:!0,get:function(){return d},set:function(m){if(!t(m))throw new Error("ViewportAnchorY must be between 0 and 100.");d=m}},viewportAnchorX:{enumerable:!0,get:function(){return c},set:function(m){if(!t(m))throw new Error("ViewportAnchorX must be between 0 and 100.");c=m}},scroll:{enumerable:!0,get:function(){return f},set:function(m){var g=e(m);g===!1?console.warn("Scroll: an invalid or illegal string was specified."):f=g}}})}return cy=i,cy}var sE;function kP(){if(sE)return oy.exports;sE=1;var s=Tm(),e=oy.exports={WebVTT:wP(),VTTCue:LP(),VTTRegion:IP()};s.vttjs=e,s.WebVTT=e.WebVTT;var t=e.VTTCue,i=e.VTTRegion,n=s.VTTCue,r=s.VTTRegion;return e.shim=function(){s.VTTCue=t,s.VTTRegion=i},e.restore=function(){s.VTTCue=n,s.VTTRegion=r},s.VTTCue||e.shim(),oy.exports}var RP=kP();const nE=ac(RP);function Hi(){return Hi=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},Hi.apply(null,arguments)}var rE="https://example.com",bm=function(e,t){if(/^[a-z]+:/i.test(t))return t;/^data:/.test(e)&&(e=ne.location&&ne.location.href||"");var i=/^\/\//.test(e),n=!ne.location&&!/\/\//i.test(e);e=new ne.URL(e,ne.location||rE);var r=new URL(t,e);return n?r.href.slice(rE.length):i?r.href.slice(r.protocol.length):r.href},pT=(function(){function s(){this.listeners={}}var e=s.prototype;return e.on=function(i,n){this.listeners[i]||(this.listeners[i]=[]),this.listeners[i].push(n)},e.off=function(i,n){if(!this.listeners[i])return!1;var r=this.listeners[i].indexOf(n);return this.listeners[i]=this.listeners[i].slice(0),this.listeners[i].splice(r,1),r>-1},e.trigger=function(i){var n=this.listeners[i];if(n)if(arguments.length===2)for(var r=n.length,o=0;o<r;++o)n[o].call(this,arguments[1]);else for(var u=Array.prototype.slice.call(arguments,1),c=n.length,d=0;d<c;++d)n[d].apply(this,u)},e.dispose=function(){this.listeners={}},e.pipe=function(i){this.on("data",function(n){i.push(n)})},s})(),OP=function(e){return ne.atob?ne.atob(e):Buffer.from(e,"base64").toString("binary")};function IA(s){for(var e=OP(s),t=new Uint8Array(e.length),i=0;i<e.length;i++)t[i]=e.charCodeAt(i);return t}class PP extends pT{constructor(){super(),this.buffer=""}push(e){let t;for(this.buffer+=e,t=this.buffer.indexOf(`
`);t>-1;t=this.buffer.indexOf(`
`))this.trigger("data",this.buffer.substring(0,t)),this.buffer=this.buffer.substring(t+1)}}const MP=" ",dy=function(s){const e=/([0-9.]*)?@?([0-9.]*)?/.exec(s||""),t={};return e[1]&&(t.length=parseInt(e[1],10)),e[2]&&(t.offset=parseInt(e[2],10)),t},NP=function(){const t="(?:"+"[^=]*"+")=(?:"+'"[^"]*"|[^,]*'+")";return new RegExp("(?:^|,)("+t+")")},Os=function(s){const e={};if(!s)return e;const t=s.split(NP());let i=t.length,n;for(;i--;)t[i]!==""&&(n=/([^=]*)=(.*)/.exec(t[i]).slice(1),n[0]=n[0].replace(/^\s+|\s+$/g,""),n[1]=n[1].replace(/^\s+|\s+$/g,""),n[1]=n[1].replace(/^['"](.*)['"]$/g,"$1"),e[n[0]]=n[1]);return e},aE=s=>{const e=s.split("x"),t={};return e[0]&&(t.width=parseInt(e[0],10)),e[1]&&(t.height=parseInt(e[1],10)),t};class BP extends pT{constructor(){super(),this.customParsers=[],this.tagMappers=[]}push(e){let t,i;if(e=e.trim(),e.length===0)return;if(e[0]!=="#"){this.trigger("data",{type:"uri",uri:e});return}this.tagMappers.reduce((r,o)=>{const u=o(e);return u===e?r:r.concat([u])},[e]).forEach(r=>{for(let o=0;o<this.customParsers.length;o++)if(this.customParsers[o].call(this,r))return;if(r.indexOf("#EXT")!==0){this.trigger("data",{type:"comment",text:r.slice(1)});return}if(r=r.replace("\r",""),t=/^#EXTM3U/.exec(r),t){this.trigger("data",{type:"tag",tagType:"m3u"});return}if(t=/^#EXTINF:([0-9\.]*)?,?(.*)?$/.exec(r),t){i={type:"tag",tagType:"inf"},t[1]&&(i.duration=parseFloat(t[1])),t[2]&&(i.title=t[2]),this.trigger("data",i);return}if(t=/^#EXT-X-TARGETDURATION:([0-9.]*)?/.exec(r),t){i={type:"tag",tagType:"targetduration"},t[1]&&(i.duration=parseInt(t[1],10)),this.trigger("data",i);return}if(t=/^#EXT-X-VERSION:([0-9.]*)?/.exec(r),t){i={type:"tag",tagType:"version"},t[1]&&(i.version=parseInt(t[1],10)),this.trigger("data",i);return}if(t=/^#EXT-X-MEDIA-SEQUENCE:(\-?[0-9.]*)?/.exec(r),t){i={type:"tag",tagType:"media-sequence"},t[1]&&(i.number=parseInt(t[1],10)),this.trigger("data",i);return}if(t=/^#EXT-X-DISCONTINUITY-SEQUENCE:(\-?[0-9.]*)?/.exec(r),t){i={type:"tag",tagType:"discontinuity-sequence"},t[1]&&(i.number=parseInt(t[1],10)),this.trigger("data",i);return}if(t=/^#EXT-X-PLAYLIST-TYPE:(.*)?$/.exec(r),t){i={type:"tag",tagType:"playlist-type"},t[1]&&(i.playlistType=t[1]),this.trigger("data",i);return}if(t=/^#EXT-X-BYTERANGE:(.*)?$/.exec(r),t){i=Hi(dy(t[1]),{type:"tag",tagType:"byterange"}),this.trigger("data",i);return}if(t=/^#EXT-X-ALLOW-CACHE:(YES|NO)?/.exec(r),t){i={type:"tag",tagType:"allow-cache"},t[1]&&(i.allowed=!/NO/.test(t[1])),this.trigger("data",i);return}if(t=/^#EXT-X-MAP:(.*)$/.exec(r),t){if(i={type:"tag",tagType:"map"},t[1]){const o=Os(t[1]);o.URI&&(i.uri=o.URI),o.BYTERANGE&&(i.byterange=dy(o.BYTERANGE))}this.trigger("data",i);return}if(t=/^#EXT-X-STREAM-INF:(.*)$/.exec(r),t){i={type:"tag",tagType:"stream-inf"},t[1]&&(i.attributes=Os(t[1]),i.attributes.RESOLUTION&&(i.attributes.RESOLUTION=aE(i.attributes.RESOLUTION)),i.attributes.BANDWIDTH&&(i.attributes.BANDWIDTH=parseInt(i.attributes.BANDWIDTH,10)),i.attributes["FRAME-RATE"]&&(i.attributes["FRAME-RATE"]=parseFloat(i.attributes["FRAME-RATE"])),i.attributes["PROGRAM-ID"]&&(i.attributes["PROGRAM-ID"]=parseInt(i.attributes["PROGRAM-ID"],10))),this.trigger("data",i);return}if(t=/^#EXT-X-MEDIA:(.*)$/.exec(r),t){i={type:"tag",tagType:"media"},t[1]&&(i.attributes=Os(t[1])),this.trigger("data",i);return}if(t=/^#EXT-X-ENDLIST/.exec(r),t){this.trigger("data",{type:"tag",tagType:"endlist"});return}if(t=/^#EXT-X-DISCONTINUITY/.exec(r),t){this.trigger("data",{type:"tag",tagType:"discontinuity"});return}if(t=/^#EXT-X-PROGRAM-DATE-TIME:(.*)$/.exec(r),t){i={type:"tag",tagType:"program-date-time"},t[1]&&(i.dateTimeString=t[1],i.dateTimeObject=new Date(t[1])),this.trigger("data",i);return}if(t=/^#EXT-X-KEY:(.*)$/.exec(r),t){i={type:"tag",tagType:"key"},t[1]&&(i.attributes=Os(t[1]),i.attributes.IV&&(i.attributes.IV.substring(0,2).toLowerCase()==="0x"&&(i.attributes.IV=i.attributes.IV.substring(2)),i.attributes.IV=i.attributes.IV.match(/.{8}/g),i.attributes.IV[0]=parseInt(i.attributes.IV[0],16),i.attributes.IV[1]=parseInt(i.attributes.IV[1],16),i.attributes.IV[2]=parseInt(i.attributes.IV[2],16),i.attributes.IV[3]=parseInt(i.attributes.IV[3],16),i.attributes.IV=new Uint32Array(i.attributes.IV))),this.trigger("data",i);return}if(t=/^#EXT-X-START:(.*)$/.exec(r),t){i={type:"tag",tagType:"start"},t[1]&&(i.attributes=Os(t[1]),i.attributes["TIME-OFFSET"]=parseFloat(i.attributes["TIME-OFFSET"]),i.attributes.PRECISE=/YES/.test(i.attributes.PRECISE)),this.trigger("data",i);return}if(t=/^#EXT-X-CUE-OUT-CONT:(.*)?$/.exec(r),t){i={type:"tag",tagType:"cue-out-cont"},t[1]?i.data=t[1]:i.data="",this.trigger("data",i);return}if(t=/^#EXT-X-CUE-OUT:(.*)?$/.exec(r),t){i={type:"tag",tagType:"cue-out"},t[1]?i.data=t[1]:i.data="",this.trigger("data",i);return}if(t=/^#EXT-X-CUE-IN:?(.*)?$/.exec(r),t){i={type:"tag",tagType:"cue-in"},t[1]?i.data=t[1]:i.data="",this.trigger("data",i);return}if(t=/^#EXT-X-SKIP:(.*)$/.exec(r),t&&t[1]){i={type:"tag",tagType:"skip"},i.attributes=Os(t[1]),i.attributes.hasOwnProperty("SKIPPED-SEGMENTS")&&(i.attributes["SKIPPED-SEGMENTS"]=parseInt(i.attributes["SKIPPED-SEGMENTS"],10)),i.attributes.hasOwnProperty("RECENTLY-REMOVED-DATERANGES")&&(i.attributes["RECENTLY-REMOVED-DATERANGES"]=i.attributes["RECENTLY-REMOVED-DATERANGES"].split(MP)),this.trigger("data",i);return}if(t=/^#EXT-X-PART:(.*)$/.exec(r),t&&t[1]){i={type:"tag",tagType:"part"},i.attributes=Os(t[1]),["DURATION"].forEach(function(o){i.attributes.hasOwnProperty(o)&&(i.attributes[o]=parseFloat(i.attributes[o]))}),["INDEPENDENT","GAP"].forEach(function(o){i.attributes.hasOwnProperty(o)&&(i.attributes[o]=/YES/.test(i.attributes[o]))}),i.attributes.hasOwnProperty("BYTERANGE")&&(i.attributes.byterange=dy(i.attributes.BYTERANGE)),this.trigger("data",i);return}if(t=/^#EXT-X-SERVER-CONTROL:(.*)$/.exec(r),t&&t[1]){i={type:"tag",tagType:"server-control"},i.attributes=Os(t[1]),["CAN-SKIP-UNTIL","PART-HOLD-BACK","HOLD-BACK"].forEach(function(o){i.attributes.hasOwnProperty(o)&&(i.attributes[o]=parseFloat(i.attributes[o]))}),["CAN-SKIP-DATERANGES","CAN-BLOCK-RELOAD"].forEach(function(o){i.attributes.hasOwnProperty(o)&&(i.attributes[o]=/YES/.test(i.attributes[o]))}),this.trigger("data",i);return}if(t=/^#EXT-X-PART-INF:(.*)$/.exec(r),t&&t[1]){i={type:"tag",tagType:"part-inf"},i.attributes=Os(t[1]),["PART-TARGET"].forEach(function(o){i.attributes.hasOwnProperty(o)&&(i.attributes[o]=parseFloat(i.attributes[o]))}),this.trigger("data",i);return}if(t=/^#EXT-X-PRELOAD-HINT:(.*)$/.exec(r),t&&t[1]){i={type:"tag",tagType:"preload-hint"},i.attributes=Os(t[1]),["BYTERANGE-START","BYTERANGE-LENGTH"].forEach(function(o){if(i.attributes.hasOwnProperty(o)){i.attributes[o]=parseInt(i.attributes[o],10);const u=o==="BYTERANGE-LENGTH"?"length":"offset";i.attributes.byterange=i.attributes.byterange||{},i.attributes.byterange[u]=i.attributes[o],delete i.attributes[o]}}),this.trigger("data",i);return}if(t=/^#EXT-X-RENDITION-REPORT:(.*)$/.exec(r),t&&t[1]){i={type:"tag",tagType:"rendition-report"},i.attributes=Os(t[1]),["LAST-MSN","LAST-PART"].forEach(function(o){i.attributes.hasOwnProperty(o)&&(i.attributes[o]=parseInt(i.attributes[o],10))}),this.trigger("data",i);return}if(t=/^#EXT-X-DATERANGE:(.*)$/.exec(r),t&&t[1]){i={type:"tag",tagType:"daterange"},i.attributes=Os(t[1]),["ID","CLASS"].forEach(function(u){i.attributes.hasOwnProperty(u)&&(i.attributes[u]=String(i.attributes[u]))}),["START-DATE","END-DATE"].forEach(function(u){i.attributes.hasOwnProperty(u)&&(i.attributes[u]=new Date(i.attributes[u]))}),["DURATION","PLANNED-DURATION"].forEach(function(u){i.attributes.hasOwnProperty(u)&&(i.attributes[u]=parseFloat(i.attributes[u]))}),["END-ON-NEXT"].forEach(function(u){i.attributes.hasOwnProperty(u)&&(i.attributes[u]=/YES/i.test(i.attributes[u]))}),["SCTE35-CMD"," SCTE35-OUT","SCTE35-IN"].forEach(function(u){i.attributes.hasOwnProperty(u)&&(i.attributes[u]=i.attributes[u].toString(16))});const o=/^X-([A-Z]+-)+[A-Z]+$/;for(const u in i.attributes){if(!o.test(u))continue;const c=/[0-9A-Fa-f]{6}/g.test(i.attributes[u]),d=/^\d+(\.\d+)?$/.test(i.attributes[u]);i.attributes[u]=c?i.attributes[u].toString(16):d?parseFloat(i.attributes[u]):String(i.attributes[u])}this.trigger("data",i);return}if(t=/^#EXT-X-INDEPENDENT-SEGMENTS/.exec(r),t){this.trigger("data",{type:"tag",tagType:"independent-segments"});return}if(t=/^#EXT-X-I-FRAMES-ONLY/.exec(r),t){this.trigger("data",{type:"tag",tagType:"i-frames-only"});return}if(t=/^#EXT-X-CONTENT-STEERING:(.*)$/.exec(r),t){i={type:"tag",tagType:"content-steering"},i.attributes=Os(t[1]),this.trigger("data",i);return}if(t=/^#EXT-X-I-FRAME-STREAM-INF:(.*)$/.exec(r),t){i={type:"tag",tagType:"i-frame-playlist"},i.attributes=Os(t[1]),i.attributes.URI&&(i.uri=i.attributes.URI),i.attributes.BANDWIDTH&&(i.attributes.BANDWIDTH=parseInt(i.attributes.BANDWIDTH,10)),i.attributes.RESOLUTION&&(i.attributes.RESOLUTION=aE(i.attributes.RESOLUTION)),i.attributes["AVERAGE-BANDWIDTH"]&&(i.attributes["AVERAGE-BANDWIDTH"]=parseInt(i.attributes["AVERAGE-BANDWIDTH"],10)),i.attributes["FRAME-RATE"]&&(i.attributes["FRAME-RATE"]=parseFloat(i.attributes["FRAME-RATE"])),this.trigger("data",i);return}if(t=/^#EXT-X-DEFINE:(.*)$/.exec(r),t){i={type:"tag",tagType:"define"},i.attributes=Os(t[1]),this.trigger("data",i);return}this.trigger("data",{type:"tag",data:r.slice(4)})})}addParser({expression:e,customType:t,dataParser:i,segment:n}){typeof i!="function"&&(i=r=>r),this.customParsers.push(r=>{if(e.exec(r))return this.trigger("data",{type:"custom",data:i(r),customType:t,segment:n}),!0})}addTagMapper({expression:e,map:t}){const i=n=>e.test(n)?t(n):n;this.tagMappers.push(i)}}const FP=s=>s.toLowerCase().replace(/-(\w)/g,e=>e[1].toUpperCase()),ao=function(s){const e={};return Object.keys(s).forEach(function(t){e[FP(t)]=s[t]}),e},hy=function(s){const{serverControl:e,targetDuration:t,partTargetDuration:i}=s;if(!e)return;const n="#EXT-X-SERVER-CONTROL",r="holdBack",o="partHoldBack",u=t&&t*3,c=i&&i*2;t&&!e.hasOwnProperty(r)&&(e[r]=u,this.trigger("info",{message:`${n} defaulting HOLD-BACK to targetDuration * 3 (${u}).`})),u&&e[r]<u&&(this.trigger("warn",{message:`${n} clamping HOLD-BACK (${e[r]}) to targetDuration * 3 (${u})`}),e[r]=u),i&&!e.hasOwnProperty(o)&&(e[o]=i*3,this.trigger("info",{message:`${n} defaulting PART-HOLD-BACK to partTargetDuration * 3 (${e[o]}).`})),i&&e[o]<c&&(this.trigger("warn",{message:`${n} clamping PART-HOLD-BACK (${e[o]}) to partTargetDuration * 2 (${c}).`}),e[o]=c)};class UP extends pT{constructor(e={}){super(),this.lineStream=new PP,this.parseStream=new BP,this.lineStream.pipe(this.parseStream),this.mainDefinitions=e.mainDefinitions||{},this.params=new URL(e.uri,"https://a.com").searchParams,this.lastProgramDateTime=null;const t=this,i=[];let n={},r,o,u=!1;const c=function(){},d={AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},f="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";let m=0;this.manifest={allowCache:!0,discontinuityStarts:[],dateRanges:[],iFramePlaylists:[],segments:[]};let g=0,v=0;const b={};this.on("end",()=>{n.uri||!n.parts&&!n.preloadHints||(!n.map&&r&&(n.map=r),!n.key&&o&&(n.key=o),!n.timeline&&typeof m=="number"&&(n.timeline=m),this.manifest.preloadSegment=n)}),this.parseStream.on("data",function(_){let E,w;if(t.manifest.definitions){for(const I in t.manifest.definitions)if(_.uri&&(_.uri=_.uri.replace(`{$${I}}`,t.manifest.definitions[I])),_.attributes)for(const L in _.attributes)typeof _.attributes[L]=="string"&&(_.attributes[L]=_.attributes[L].replace(`{$${I}}`,t.manifest.definitions[I]))}({tag(){({version(){_.version&&(this.manifest.version=_.version)},"allow-cache"(){this.manifest.allowCache=_.allowed,"allowed"in _||(this.trigger("info",{message:"defaulting allowCache to YES"}),this.manifest.allowCache=!0)},byterange(){const I={};"length"in _&&(n.byterange=I,I.length=_.length,"offset"in _||(_.offset=g)),"offset"in _&&(n.byterange=I,I.offset=_.offset),g=I.offset+I.length},endlist(){this.manifest.endList=!0},inf(){"mediaSequence"in this.manifest||(this.manifest.mediaSequence=0,this.trigger("info",{message:"defaulting media sequence to zero"})),"discontinuitySequence"in this.manifest||(this.manifest.discontinuitySequence=0,this.trigger("info",{message:"defaulting discontinuity sequence to zero"})),_.title&&(n.title=_.title),_.duration>0&&(n.duration=_.duration),_.duration===0&&(n.duration=.01,this.trigger("info",{message:"updating zero segment duration to a small value"})),this.manifest.segments=i},key(){if(!_.attributes){this.trigger("warn",{message:"ignoring key declaration without attribute list"});return}if(_.attributes.METHOD==="NONE"){o=null;return}if(!_.attributes.URI){this.trigger("warn",{message:"ignoring key declaration without URI"});return}if(_.attributes.KEYFORMAT==="com.apple.streamingkeydelivery"){this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.apple.fps.1_0"]={attributes:_.attributes};return}if(_.attributes.KEYFORMAT==="com.microsoft.playready"){this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.microsoft.playready"]={uri:_.attributes.URI};return}if(_.attributes.KEYFORMAT===f){if(["SAMPLE-AES","SAMPLE-AES-CTR","SAMPLE-AES-CENC"].indexOf(_.attributes.METHOD)===-1){this.trigger("warn",{message:"invalid key method provided for Widevine"});return}if(_.attributes.METHOD==="SAMPLE-AES-CENC"&&this.trigger("warn",{message:"SAMPLE-AES-CENC is deprecated, please use SAMPLE-AES-CTR instead"}),_.attributes.URI.substring(0,23)!=="data:text/plain;base64,"){this.trigger("warn",{message:"invalid key URI provided for Widevine"});return}if(!(_.attributes.KEYID&&_.attributes.KEYID.substring(0,2)==="0x")){this.trigger("warn",{message:"invalid key ID provided for Widevine"});return}this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.widevine.alpha"]={attributes:{schemeIdUri:_.attributes.KEYFORMAT,keyId:_.attributes.KEYID.substring(2)},pssh:IA(_.attributes.URI.split(",")[1])};return}_.attributes.METHOD||this.trigger("warn",{message:"defaulting key method to AES-128"}),o={method:_.attributes.METHOD||"AES-128",uri:_.attributes.URI},typeof _.attributes.IV<"u"&&(o.iv=_.attributes.IV)},"media-sequence"(){if(!isFinite(_.number)){this.trigger("warn",{message:"ignoring invalid media sequence: "+_.number});return}this.manifest.mediaSequence=_.number},"discontinuity-sequence"(){if(!isFinite(_.number)){this.trigger("warn",{message:"ignoring invalid discontinuity sequence: "+_.number});return}this.manifest.discontinuitySequence=_.number,m=_.number},"playlist-type"(){if(!/VOD|EVENT/.test(_.playlistType)){this.trigger("warn",{message:"ignoring unknown playlist type: "+_.playlist});return}this.manifest.playlistType=_.playlistType},map(){r={},_.uri&&(r.uri=_.uri),_.byterange&&(r.byterange=_.byterange),o&&(r.key=o)},"stream-inf"(){if(this.manifest.playlists=i,this.manifest.mediaGroups=this.manifest.mediaGroups||d,!_.attributes){this.trigger("warn",{message:"ignoring empty stream-inf attributes"});return}n.attributes||(n.attributes={}),Hi(n.attributes,_.attributes)},media(){if(this.manifest.mediaGroups=this.manifest.mediaGroups||d,!(_.attributes&&_.attributes.TYPE&&_.attributes["GROUP-ID"]&&_.attributes.NAME)){this.trigger("warn",{message:"ignoring incomplete or missing media group"});return}const I=this.manifest.mediaGroups[_.attributes.TYPE];I[_.attributes["GROUP-ID"]]=I[_.attributes["GROUP-ID"]]||{},E=I[_.attributes["GROUP-ID"]],w={default:/yes/i.test(_.attributes.DEFAULT)},w.default?w.autoselect=!0:w.autoselect=/yes/i.test(_.attributes.AUTOSELECT),_.attributes.LANGUAGE&&(w.language=_.attributes.LANGUAGE),_.attributes.URI&&(w.uri=_.attributes.URI),_.attributes["INSTREAM-ID"]&&(w.instreamId=_.attributes["INSTREAM-ID"]),_.attributes.CHARACTERISTICS&&(w.characteristics=_.attributes.CHARACTERISTICS),_.attributes.FORCED&&(w.forced=/yes/i.test(_.attributes.FORCED)),E[_.attributes.NAME]=w},discontinuity(){m+=1,n.discontinuity=!0,this.manifest.discontinuityStarts.push(i.length)},"program-date-time"(){typeof this.manifest.dateTimeString>"u"&&(this.manifest.dateTimeString=_.dateTimeString,this.manifest.dateTimeObject=_.dateTimeObject),n.dateTimeString=_.dateTimeString,n.dateTimeObject=_.dateTimeObject;const{lastProgramDateTime:I}=this;this.lastProgramDateTime=new Date(_.dateTimeString).getTime(),I===null&&this.manifest.segments.reduceRight((L,F)=>(F.programDateTime=L-F.duration*1e3,F.programDateTime),this.lastProgramDateTime)},targetduration(){if(!isFinite(_.duration)||_.duration<0){this.trigger("warn",{message:"ignoring invalid target duration: "+_.duration});return}this.manifest.targetDuration=_.duration,hy.call(this,this.manifest)},start(){if(!_.attributes||isNaN(_.attributes["TIME-OFFSET"])){this.trigger("warn",{message:"ignoring start declaration without appropriate attribute list"});return}this.manifest.start={timeOffset:_.attributes["TIME-OFFSET"],precise:_.attributes.PRECISE}},"cue-out"(){n.cueOut=_.data},"cue-out-cont"(){n.cueOutCont=_.data},"cue-in"(){n.cueIn=_.data},skip(){this.manifest.skip=ao(_.attributes),this.warnOnMissingAttributes_("#EXT-X-SKIP",_.attributes,["SKIPPED-SEGMENTS"])},part(){u=!0;const I=this.manifest.segments.length,L=ao(_.attributes);n.parts=n.parts||[],n.parts.push(L),L.byterange&&(L.byterange.hasOwnProperty("offset")||(L.byterange.offset=v),v=L.byterange.offset+L.byterange.length);const F=n.parts.length-1;this.warnOnMissingAttributes_(`#EXT-X-PART #${F} for segment #${I}`,_.attributes,["URI","DURATION"]),this.manifest.renditionReports&&this.manifest.renditionReports.forEach(($,G)=>{$.hasOwnProperty("lastPart")||this.trigger("warn",{message:`#EXT-X-RENDITION-REPORT #${G} lacks required attribute(s): LAST-PART`})})},"server-control"(){const I=this.manifest.serverControl=ao(_.attributes);I.hasOwnProperty("canBlockReload")||(I.canBlockReload=!1,this.trigger("info",{message:"#EXT-X-SERVER-CONTROL defaulting CAN-BLOCK-RELOAD to false"})),hy.call(this,this.manifest),I.canSkipDateranges&&!I.hasOwnProperty("canSkipUntil")&&this.trigger("warn",{message:"#EXT-X-SERVER-CONTROL lacks required attribute CAN-SKIP-UNTIL which is required when CAN-SKIP-DATERANGES is set"})},"preload-hint"(){const I=this.manifest.segments.length,L=ao(_.attributes),F=L.type&&L.type==="PART";n.preloadHints=n.preloadHints||[],n.preloadHints.push(L),L.byterange&&(L.byterange.hasOwnProperty("offset")||(L.byterange.offset=F?v:0,F&&(v=L.byterange.offset+L.byterange.length)));const $=n.preloadHints.length-1;if(this.warnOnMissingAttributes_(`#EXT-X-PRELOAD-HINT #${$} for segment #${I}`,_.attributes,["TYPE","URI"]),!!L.type)for(let G=0;G<n.preloadHints.length-1;G++){const B=n.preloadHints[G];B.type&&B.type===L.type&&this.trigger("warn",{message:`#EXT-X-PRELOAD-HINT #${$} for segment #${I} has the same TYPE ${L.type} as preload hint #${G}`})}},"rendition-report"(){const I=ao(_.attributes);this.manifest.renditionReports=this.manifest.renditionReports||[],this.manifest.renditionReports.push(I);const L=this.manifest.renditionReports.length-1,F=["LAST-MSN","URI"];u&&F.push("LAST-PART"),this.warnOnMissingAttributes_(`#EXT-X-RENDITION-REPORT #${L}`,_.attributes,F)},"part-inf"(){this.manifest.partInf=ao(_.attributes),this.warnOnMissingAttributes_("#EXT-X-PART-INF",_.attributes,["PART-TARGET"]),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),hy.call(this,this.manifest)},daterange(){this.manifest.dateRanges.push(ao(_.attributes));const I=this.manifest.dateRanges.length-1;this.warnOnMissingAttributes_(`#EXT-X-DATERANGE #${I}`,_.attributes,["ID","START-DATE"]);const L=this.manifest.dateRanges[I];L.endDate&&L.startDate&&new Date(L.endDate)<new Date(L.startDate)&&this.trigger("warn",{message:"EXT-X-DATERANGE END-DATE must be equal to or later than the value of the START-DATE"}),L.duration&&L.duration<0&&this.trigger("warn",{message:"EXT-X-DATERANGE DURATION must not be negative"}),L.plannedDuration&&L.plannedDuration<0&&this.trigger("warn",{message:"EXT-X-DATERANGE PLANNED-DURATION must not be negative"});const F=!!L.endOnNext;if(F&&!L.class&&this.trigger("warn",{message:"EXT-X-DATERANGE with an END-ON-NEXT=YES attribute must have a CLASS attribute"}),F&&(L.duration||L.endDate)&&this.trigger("warn",{message:"EXT-X-DATERANGE with an END-ON-NEXT=YES attribute must not contain DURATION or END-DATE attributes"}),L.duration&&L.endDate){const G=L.startDate.getTime()+L.duration*1e3;this.manifest.dateRanges[I].endDate=new Date(G)}if(!b[L.id])b[L.id]=L;else{for(const G in b[L.id])if(L[G]&&JSON.stringify(b[L.id][G])!==JSON.stringify(L[G])){this.trigger("warn",{message:"EXT-X-DATERANGE tags with the same ID in a playlist must have the same attributes values"});break}const $=this.manifest.dateRanges.findIndex(G=>G.id===L.id);this.manifest.dateRanges[$]=Hi(this.manifest.dateRanges[$],L),b[L.id]=Hi(b[L.id],L),this.manifest.dateRanges.pop()}},"independent-segments"(){this.manifest.independentSegments=!0},"i-frames-only"(){this.manifest.iFramesOnly=!0,this.requiredCompatibilityversion(this.manifest.version,4)},"content-steering"(){this.manifest.contentSteering=ao(_.attributes),this.warnOnMissingAttributes_("#EXT-X-CONTENT-STEERING",_.attributes,["SERVER-URI"])},define(){this.manifest.definitions=this.manifest.definitions||{};const I=(L,F)=>{if(L in this.manifest.definitions){this.trigger("error",{message:`EXT-X-DEFINE: Duplicate name ${L}`});return}this.manifest.definitions[L]=F};if("QUERYPARAM"in _.attributes){if("NAME"in _.attributes||"IMPORT"in _.attributes){this.trigger("error",{message:"EXT-X-DEFINE: Invalid attributes"});return}const L=this.params.get(_.attributes.QUERYPARAM);if(!L){this.trigger("error",{message:`EXT-X-DEFINE: No query param ${_.attributes.QUERYPARAM}`});return}I(_.attributes.QUERYPARAM,decodeURIComponent(L));return}if("NAME"in _.attributes){if("IMPORT"in _.attributes){this.trigger("error",{message:"EXT-X-DEFINE: Invalid attributes"});return}if(!("VALUE"in _.attributes)||typeof _.attributes.VALUE!="string"){this.trigger("error",{message:`EXT-X-DEFINE: No value for ${_.attributes.NAME}`});return}I(_.attributes.NAME,_.attributes.VALUE);return}if("IMPORT"in _.attributes){if(!this.mainDefinitions[_.attributes.IMPORT]){this.trigger("error",{message:`EXT-X-DEFINE: No value ${_.attributes.IMPORT} to import, or IMPORT used on main playlist`});return}I(_.attributes.IMPORT,this.mainDefinitions[_.attributes.IMPORT]);return}this.trigger("error",{message:"EXT-X-DEFINE: No attribute"})},"i-frame-playlist"(){this.manifest.iFramePlaylists.push({attributes:_.attributes,uri:_.uri,timeline:m}),this.warnOnMissingAttributes_("#EXT-X-I-FRAME-STREAM-INF",_.attributes,["BANDWIDTH","URI"])}}[_.tagType]||c).call(t)},uri(){n.uri=_.uri,i.push(n),this.manifest.targetDuration&&!("duration"in n)&&(this.trigger("warn",{message:"defaulting segment duration to the target duration"}),n.duration=this.manifest.targetDuration),o&&(n.key=o),n.timeline=m,r&&(n.map=r),v=0,this.lastProgramDateTime!==null&&(n.programDateTime=this.lastProgramDateTime,this.lastProgramDateTime+=n.duration*1e3),n={}},comment(){},custom(){_.segment?(n.custom=n.custom||{},n.custom[_.customType]=_.data):(this.manifest.custom=this.manifest.custom||{},this.manifest.custom[_.customType]=_.data)}})[_.type].call(t)})}requiredCompatibilityversion(e,t){(e<t||!e)&&this.trigger("warn",{message:`manifest must be at least version ${t}`})}warnOnMissingAttributes_(e,t,i){const n=[];i.forEach(function(r){t.hasOwnProperty(r)||n.push(r)}),n.length&&this.trigger("warn",{message:`${e} lacks required attribute(s): ${n.join(", ")}`})}push(e){this.lineStream.push(e)}end(){this.lineStream.push(`
`),this.manifest.dateRanges.length&&this.lastProgramDateTime===null&&this.trigger("warn",{message:"A playlist with EXT-X-DATERANGE tag must contain atleast one EXT-X-PROGRAM-DATE-TIME tag"}),this.lastProgramDateTime=null,this.trigger("end")}addParser(e){this.parseStream.addParser(e)}addTagMapper(e){this.parseStream.addTagMapper(e)}}var yl={mp4:/^(av0?1|avc0?[1234]|vp0?9|flac|opus|mp3|mp4a|mp4v|stpp.ttml.im1t)/,webm:/^(vp0?[89]|av0?1|opus|vorbis)/,ogg:/^(vp0?[89]|theora|flac|opus|vorbis)/,video:/^(av0?1|avc0?[1234]|vp0?[89]|hvc1|hev1|theora|mp4v)/,audio:/^(mp4a|flac|vorbis|opus|ac-[34]|ec-3|alac|mp3|speex|aac)/,text:/^(stpp.ttml.im1t)/,muxerVideo:/^(avc0?1)/,muxerAudio:/^(mp4a)/,muxerText:/a^/},$P=["video","audio","text"],oE=["Video","Audio","Text"],kA=function(e){return e&&e.replace(/avc1\.(\d+)\.(\d+)/i,function(t,i,n){var r=("00"+Number(i).toString(16)).slice(-2),o=("00"+Number(n).toString(16)).slice(-2);return"avc1."+r+"00"+o})},Ar=function(e){e===void 0&&(e="");var t=e.split(","),i=[];return t.forEach(function(n){n=n.trim();var r;$P.forEach(function(o){var u=yl[o].exec(n.toLowerCase());if(!(!u||u.length<=1)){r=o;var c=n.substring(0,u[1].length),d=n.replace(c,"");i.push({type:c,details:d,mediaType:o})}}),r||i.push({type:n,details:"",mediaType:"unknown"})}),i},jP=function(e,t){if(!e.mediaGroups.AUDIO||!t)return null;var i=e.mediaGroups.AUDIO[t];if(!i)return null;for(var n in i){var r=i[n];if(r.default&&r.playlists)return Ar(r.playlists[0].attributes.CODECS)}return null},RA=function(e){return e===void 0&&(e=""),yl.audio.test(e.trim().toLowerCase())},HP=function(e){return e===void 0&&(e=""),yl.text.test(e.trim().toLowerCase())},Wu=function(e){if(!(!e||typeof e!="string")){var t=e.toLowerCase().split(",").map(function(r){return kA(r.trim())}),i="video";t.length===1&&RA(t[0])?i="audio":t.length===1&&HP(t[0])&&(i="application");var n="mp4";return t.every(function(r){return yl.mp4.test(r)})?n="mp4":t.every(function(r){return yl.webm.test(r)})?n="webm":t.every(function(r){return yl.ogg.test(r)})&&(n="ogg"),i+"/"+n+';codecs="'+e+'"'}},Md=function(e,t){return e===void 0&&(e=""),t===void 0&&(t=!1),ne.MediaSource&&ne.MediaSource.isTypeSupported&&ne.MediaSource.isTypeSupported(Wu(e))||t&&ne.ManagedMediaSource&&ne.ManagedMediaSource.isTypeSupported&&ne.ManagedMediaSource.isTypeSupported(Wu(e))||!1},fy=function(e){return e===void 0&&(e=""),e.toLowerCase().split(",").every(function(t){t=t.trim();for(var i=0;i<oE.length;i++){var n=oE[i];if(yl["muxer"+n].test(t))return!0}return!1})},lE="mp4a.40.2",GP="avc1.4d400d",VP=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i,qP=/^application\/dash\+xml/i,OA=function(e){return VP.test(e)?"hls":qP.test(e)?"dash":e==="application/vnd.videojs.vhs+json"?"vhs-json":null},zP=function(e){return e.toString(2).length},KP=function(e){return Math.ceil(zP(e)/8)},PA=function(e){return ArrayBuffer.isView==="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer},YP=function(e){return PA(e)},lt=function(e){return e instanceof Uint8Array?e:(!Array.isArray(e)&&!YP(e)&&!(e instanceof ArrayBuffer)&&(typeof e!="number"||typeof e=="number"&&e!==e?e=0:e=[e]),new Uint8Array(e&&e.buffer||e,e&&e.byteOffset||0,e&&e.byteLength||0))},ms=ne.BigInt||Number,mv=[ms("0x1"),ms("0x100"),ms("0x10000"),ms("0x1000000"),ms("0x100000000"),ms("0x10000000000"),ms("0x1000000000000"),ms("0x100000000000000"),ms("0x10000000000000000")];(function(){var s=new Uint16Array([65484]),e=new Uint8Array(s.buffer,s.byteOffset,s.byteLength);return e[0]===255?"big":e[0]===204?"little":"unknown"})();var WP=function(e,t){var i=t===void 0?{}:t,n=i.signed,r=n===void 0?!1:n,o=i.le,u=o===void 0?!1:o;e=lt(e);var c=u?"reduce":"reduceRight",d=e[c]?e[c]:Array.prototype[c],f=d.call(e,function(g,v,b){var _=u?b:Math.abs(b+1-e.length);return g+ms(v)*mv[_]},ms(0));if(r){var m=mv[e.length]/ms(2)-ms(1);f=ms(f),f>m&&(f-=m,f-=m,f-=ms(2))}return Number(f)},XP=function(e,t){var i={},n=i.le,r=n===void 0?!1:n;(typeof e!="bigint"&&typeof e!="number"||typeof e=="number"&&e!==e)&&(e=0),e=ms(e);for(var o=KP(e),u=new Uint8Array(new ArrayBuffer(o)),c=0;c<o;c++){var d=r?c:Math.abs(c+1-u.length);u[d]=Number(e/mv[c]&ms(255)),e<0&&(u[d]=Math.abs(~u[d]),u[d]-=c===0?1:2)}return u},MA=function(e,t){if(typeof e!="string"&&e&&typeof e.toString=="function"&&(e=e.toString()),typeof e!="string")return new Uint8Array;t||(e=unescape(encodeURIComponent(e)));for(var i=new Uint8Array(e.length),n=0;n<e.length;n++)i[n]=e.charCodeAt(n);return i},QP=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];if(t=t.filter(function(u){return u&&(u.byteLength||u.length)&&typeof u!="string"}),t.length<=1)return lt(t[0]);var n=t.reduce(function(u,c,d){return u+(c.byteLength||c.length)},0),r=new Uint8Array(n),o=0;return t.forEach(function(u){u=lt(u),r.set(u,o),o+=u.byteLength}),r},Ti=function(e,t,i){var n=i===void 0?{}:i,r=n.offset,o=r===void 0?0:r,u=n.mask,c=u===void 0?[]:u;e=lt(e),t=lt(t);var d=t.every?t.every:Array.prototype.every;return t.length&&e.length-o>=t.length&&d.call(t,function(f,m){var g=c[m]?c[m]&e[o+m]:e[o+m];return f===g})},ZP=function(e,t,i){t.forEach(function(n){for(var r in e.mediaGroups[n])for(var o in e.mediaGroups[n][r]){var u=e.mediaGroups[n][r][o];i(u,n,r,o)}})},vd={},ua={},nl={},uE;function _m(){if(uE)return nl;uE=1;function s(r,o,u){if(u===void 0&&(u=Array.prototype),r&&typeof u.find=="function")return u.find.call(r,o);for(var c=0;c<r.length;c++)if(Object.prototype.hasOwnProperty.call(r,c)){var d=r[c];if(o.call(void 0,d,c,r))return d}}function e(r,o){return o===void 0&&(o=Object),o&&typeof o.freeze=="function"?o.freeze(r):r}function t(r,o){if(r===null||typeof r!="object")throw new TypeError("target is not an object");for(var u in o)Object.prototype.hasOwnProperty.call(o,u)&&(r[u]=o[u]);return r}var i=e({HTML:"text/html",isHTML:function(r){return r===i.HTML},XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),n=e({HTML:"http://www.w3.org/1999/xhtml",isHTML:function(r){return r===n.HTML},SVG:"http://www.w3.org/2000/svg",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"});return nl.assign=t,nl.find=s,nl.freeze=e,nl.MIME_TYPE=i,nl.NAMESPACE=n,nl}var cE;function NA(){if(cE)return ua;cE=1;var s=_m(),e=s.find,t=s.NAMESPACE;function i(H){return H!==""}function n(H){return H?H.split(/[\t\n\f\r ]+/).filter(i):[]}function r(H,K){return H.hasOwnProperty(K)||(H[K]=!0),H}function o(H){if(!H)return[];var K=n(H);return Object.keys(K.reduce(r,{}))}function u(H){return function(K){return H&&H.indexOf(K)!==-1}}function c(H,K){for(var se in H)Object.prototype.hasOwnProperty.call(H,se)&&(K[se]=H[se])}function d(H,K){var se=H.prototype;if(!(se instanceof K)){let Ge=function(){};var Ce=Ge;Ge.prototype=K.prototype,Ge=new Ge,c(se,Ge),H.prototype=se=Ge}se.constructor!=H&&(typeof H!="function"&&console.error("unknown Class:"+H),se.constructor=H)}var f={},m=f.ELEMENT_NODE=1,g=f.ATTRIBUTE_NODE=2,v=f.TEXT_NODE=3,b=f.CDATA_SECTION_NODE=4,_=f.ENTITY_REFERENCE_NODE=5,E=f.ENTITY_NODE=6,w=f.PROCESSING_INSTRUCTION_NODE=7,I=f.COMMENT_NODE=8,L=f.DOCUMENT_NODE=9,F=f.DOCUMENT_TYPE_NODE=10,$=f.DOCUMENT_FRAGMENT_NODE=11,G=f.NOTATION_NODE=12,B={},V={};B.INDEX_SIZE_ERR=(V[1]="Index size error",1),B.DOMSTRING_SIZE_ERR=(V[2]="DOMString size error",2);var k=B.HIERARCHY_REQUEST_ERR=(V[3]="Hierarchy request error",3);B.WRONG_DOCUMENT_ERR=(V[4]="Wrong document",4),B.INVALID_CHARACTER_ERR=(V[5]="Invalid character",5),B.NO_DATA_ALLOWED_ERR=(V[6]="No data allowed",6),B.NO_MODIFICATION_ALLOWED_ERR=(V[7]="No modification allowed",7);var R=B.NOT_FOUND_ERR=(V[8]="Not found",8);B.NOT_SUPPORTED_ERR=(V[9]="Not supported",9);var z=B.INUSE_ATTRIBUTE_ERR=(V[10]="Attribute in use",10);B.INVALID_STATE_ERR=(V[11]="Invalid state",11),B.SYNTAX_ERR=(V[12]="Syntax error",12),B.INVALID_MODIFICATION_ERR=(V[13]="Invalid modification",13),B.NAMESPACE_ERR=(V[14]="Invalid namespace",14),B.INVALID_ACCESS_ERR=(V[15]="Invalid access",15);function X(H,K){if(K instanceof Error)var se=K;else se=this,Error.call(this,V[H]),this.message=V[H],Error.captureStackTrace&&Error.captureStackTrace(this,X);return se.code=H,K&&(this.message=this.message+": "+K),se}X.prototype=Error.prototype,c(B,X);function ee(){}ee.prototype={length:0,item:function(H){return H>=0&&H<this.length?this[H]:null},toString:function(H,K){for(var se=[],Ce=0;Ce<this.length;Ce++)gi(this[Ce],se,H,K);return se.join("")},filter:function(H){return Array.prototype.filter.call(this,H)},indexOf:function(H){return Array.prototype.indexOf.call(this,H)}};function le(H,K){this._node=H,this._refresh=K,oe(this)}function oe(H){var K=H._node._inc||H._node.ownerDocument._inc;if(H._inc!==K){var se=H._refresh(H._node);if(Ht(H,"length",se.length),!H.$$length||se.length<H.$$length)for(var Ce=se.length;Ce in H;Ce++)Object.prototype.hasOwnProperty.call(H,Ce)&&delete H[Ce];c(se,H),H._inc=K}}le.prototype.item=function(H){return oe(this),this[H]||null},d(le,ee);function Y(){}function Z(H,K){for(var se=H.length;se--;)if(H[se]===K)return se}function Q(H,K,se,Ce){if(Ce?K[Z(K,Ce)]=se:K[K.length++]=se,H){se.ownerElement=H;var Ge=H.ownerDocument;Ge&&(Ce&&$e(Ge,H,Ce),Ae(Ge,H,se))}}function ae(H,K,se){var Ce=Z(K,se);if(Ce>=0){for(var Ge=K.length-1;Ce<Ge;)K[Ce]=K[++Ce];if(K.length=Ge,H){var at=H.ownerDocument;at&&($e(at,H,se),se.ownerElement=null)}}else throw new X(R,new Error(H.tagName+"@"+se))}Y.prototype={length:0,item:ee.prototype.item,getNamedItem:function(H){for(var K=this.length;K--;){var se=this[K];if(se.nodeName==H)return se}},setNamedItem:function(H){var K=H.ownerElement;if(K&&K!=this._ownerElement)throw new X(z);var se=this.getNamedItem(H.nodeName);return Q(this._ownerElement,this,H,se),se},setNamedItemNS:function(H){var K=H.ownerElement,se;if(K&&K!=this._ownerElement)throw new X(z);return se=this.getNamedItemNS(H.namespaceURI,H.localName),Q(this._ownerElement,this,H,se),se},removeNamedItem:function(H){var K=this.getNamedItem(H);return ae(this._ownerElement,this,K),K},removeNamedItemNS:function(H,K){var se=this.getNamedItemNS(H,K);return ae(this._ownerElement,this,se),se},getNamedItemNS:function(H,K){for(var se=this.length;se--;){var Ce=this[se];if(Ce.localName==K&&Ce.namespaceURI==H)return Ce}return null}};function ue(){}ue.prototype={hasFeature:function(H,K){return!0},createDocument:function(H,K,se){var Ce=new xe;if(Ce.implementation=this,Ce.childNodes=new ee,Ce.doctype=se||null,se&&Ce.appendChild(se),K){var Ge=Ce.createElementNS(H,K);Ce.appendChild(Ge)}return Ce},createDocumentType:function(H,K,se){var Ce=new fi;return Ce.name=H,Ce.nodeName=H,Ce.publicId=K||"",Ce.systemId=se||"",Ce}};function U(){}U.prototype={firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,attributes:null,parentNode:null,childNodes:null,ownerDocument:null,nodeValue:null,namespaceURI:null,prefix:null,localName:null,insertBefore:function(H,K){return At(this,H,K)},replaceChild:function(H,K){At(this,H,K,ft),K&&this.removeChild(K)},removeChild:function(H){return je(this,H)},appendChild:function(H){return this.insertBefore(H,null)},hasChildNodes:function(){return this.firstChild!=null},cloneNode:function(H){return Wi(this.ownerDocument||this,this,H)},normalize:function(){for(var H=this.firstChild;H;){var K=H.nextSibling;K&&K.nodeType==v&&H.nodeType==v?(this.removeChild(K),H.appendData(K.data)):(H.normalize(),H=K)}},isSupported:function(H,K){return this.ownerDocument.implementation.hasFeature(H,K)},hasAttributes:function(){return this.attributes.length>0},lookupPrefix:function(H){for(var K=this;K;){var se=K._nsMap;if(se){for(var Ce in se)if(Object.prototype.hasOwnProperty.call(se,Ce)&&se[Ce]===H)return Ce}K=K.nodeType==g?K.ownerDocument:K.parentNode}return null},lookupNamespaceURI:function(H){for(var K=this;K;){var se=K._nsMap;if(se&&Object.prototype.hasOwnProperty.call(se,H))return se[H];K=K.nodeType==g?K.ownerDocument:K.parentNode}return null},isDefaultNamespace:function(H){var K=this.lookupPrefix(H);return K==null}};function ie(H){return H=="<"&&"&lt;"||H==">"&&"&gt;"||H=="&"&&"&amp;"||H=='"'&&"&quot;"||"&#"+H.charCodeAt()+";"}c(f,U),c(f,U.prototype);function fe(H,K){if(K(H))return!0;if(H=H.firstChild)do if(fe(H,K))return!0;while(H=H.nextSibling)}function xe(){this.ownerDocument=this}function Ae(H,K,se){H&&H._inc++;var Ce=se.namespaceURI;Ce===t.XMLNS&&(K._nsMap[se.prefix?se.localName:""]=se.value)}function $e(H,K,se,Ce){H&&H._inc++;var Ge=se.namespaceURI;Ge===t.XMLNS&&delete K._nsMap[se.prefix?se.localName:""]}function Ee(H,K,se){if(H&&H._inc){H._inc++;var Ce=K.childNodes;if(se)Ce[Ce.length++]=se;else{for(var Ge=K.firstChild,at=0;Ge;)Ce[at++]=Ge,Ge=Ge.nextSibling;Ce.length=at,delete Ce[Ce.length]}}}function je(H,K){var se=K.previousSibling,Ce=K.nextSibling;return se?se.nextSibling=Ce:H.firstChild=Ce,Ce?Ce.previousSibling=se:H.lastChild=se,K.parentNode=null,K.previousSibling=null,K.nextSibling=null,Ee(H.ownerDocument,H),K}function qe(H){return H&&(H.nodeType===U.DOCUMENT_NODE||H.nodeType===U.DOCUMENT_FRAGMENT_NODE||H.nodeType===U.ELEMENT_NODE)}function et(H){return H&&(ht(H)||qt(H)||rt(H)||H.nodeType===U.DOCUMENT_FRAGMENT_NODE||H.nodeType===U.COMMENT_NODE||H.nodeType===U.PROCESSING_INSTRUCTION_NODE)}function rt(H){return H&&H.nodeType===U.DOCUMENT_TYPE_NODE}function ht(H){return H&&H.nodeType===U.ELEMENT_NODE}function qt(H){return H&&H.nodeType===U.TEXT_NODE}function xt(H,K){var se=H.childNodes||[];if(e(se,ht)||rt(K))return!1;var Ce=e(se,rt);return!(K&&Ce&&se.indexOf(Ce)>se.indexOf(K))}function Ri(H,K){var se=H.childNodes||[];function Ce(at){return ht(at)&&at!==K}if(e(se,Ce))return!1;var Ge=e(se,rt);return!(K&&Ge&&se.indexOf(Ge)>se.indexOf(K))}function Be(H,K,se){if(!qe(H))throw new X(k,"Unexpected parent node type "+H.nodeType);if(se&&se.parentNode!==H)throw new X(R,"child not in parent");if(!et(K)||rt(K)&&H.nodeType!==U.DOCUMENT_NODE)throw new X(k,"Unexpected node type "+K.nodeType+" for parent node type "+H.nodeType)}function Xe(H,K,se){var Ce=H.childNodes||[],Ge=K.childNodes||[];if(K.nodeType===U.DOCUMENT_FRAGMENT_NODE){var at=Ge.filter(ht);if(at.length>1||e(Ge,qt))throw new X(k,"More than one element or text in fragment");if(at.length===1&&!xt(H,se))throw new X(k,"Element in fragment can not be inserted before doctype")}if(ht(K)&&!xt(H,se))throw new X(k,"Only one element can be added and only after doctype");if(rt(K)){if(e(Ce,rt))throw new X(k,"Only one doctype is allowed");var Mt=e(Ce,ht);if(se&&Ce.indexOf(Mt)<Ce.indexOf(se))throw new X(k,"Doctype can only be inserted before an element");if(!se&&Mt)throw new X(k,"Doctype can not be appended since element is present")}}function ft(H,K,se){var Ce=H.childNodes||[],Ge=K.childNodes||[];if(K.nodeType===U.DOCUMENT_FRAGMENT_NODE){var at=Ge.filter(ht);if(at.length>1||e(Ge,qt))throw new X(k,"More than one element or text in fragment");if(at.length===1&&!Ri(H,se))throw new X(k,"Element in fragment can not be inserted before doctype")}if(ht(K)&&!Ri(H,se))throw new X(k,"Only one element can be added and only after doctype");if(rt(K)){let Pi=function(ut){return rt(ut)&&ut!==se};var xi=Pi;if(e(Ce,Pi))throw new X(k,"Only one doctype is allowed");var Mt=e(Ce,ht);if(se&&Ce.indexOf(Mt)<Ce.indexOf(se))throw new X(k,"Doctype can only be inserted before an element")}}function At(H,K,se,Ce){Be(H,K,se),H.nodeType===U.DOCUMENT_NODE&&(Ce||Xe)(H,K,se);var Ge=K.parentNode;if(Ge&&Ge.removeChild(K),K.nodeType===$){var at=K.firstChild;if(at==null)return K;var Mt=K.lastChild}else at=Mt=K;var xi=se?se.previousSibling:H.lastChild;at.previousSibling=xi,Mt.nextSibling=se,xi?xi.nextSibling=at:H.firstChild=at,se==null?H.lastChild=Mt:se.previousSibling=Mt;do{at.parentNode=H;var Pi=H.ownerDocument||H;we(at,Pi)}while(at!==Mt&&(at=at.nextSibling));return Ee(H.ownerDocument||H,H),K.nodeType==$&&(K.firstChild=K.lastChild=null),K}function we(H,K){if(H.ownerDocument!==K){if(H.ownerDocument=K,H.nodeType===m&&H.attributes)for(var se=0;se<H.attributes.length;se++){var Ce=H.attributes.item(se);Ce&&(Ce.ownerDocument=K)}for(var Ge=H.firstChild;Ge;)we(Ge,K),Ge=Ge.nextSibling}}function Fe(H,K){K.parentNode&&K.parentNode.removeChild(K),K.parentNode=H,K.previousSibling=H.lastChild,K.nextSibling=null,K.previousSibling?K.previousSibling.nextSibling=K:H.firstChild=K,H.lastChild=K,Ee(H.ownerDocument,H,K);var se=H.ownerDocument||H;return we(K,se),K}xe.prototype={nodeName:"#document",nodeType:L,doctype:null,documentElement:null,_inc:1,insertBefore:function(H,K){if(H.nodeType==$){for(var se=H.firstChild;se;){var Ce=se.nextSibling;this.insertBefore(se,K),se=Ce}return H}return At(this,H,K),we(H,this),this.documentElement===null&&H.nodeType===m&&(this.documentElement=H),H},removeChild:function(H){return this.documentElement==H&&(this.documentElement=null),je(this,H)},replaceChild:function(H,K){At(this,H,K,ft),we(H,this),K&&this.removeChild(K),ht(H)&&(this.documentElement=H)},importNode:function(H,K){return Oi(this,H,K)},getElementById:function(H){var K=null;return fe(this.documentElement,function(se){if(se.nodeType==m&&se.getAttribute("id")==H)return K=se,!0}),K},getElementsByClassName:function(H){var K=o(H);return new le(this,function(se){var Ce=[];return K.length>0&&fe(se.documentElement,function(Ge){if(Ge!==se&&Ge.nodeType===m){var at=Ge.getAttribute("class");if(at){var Mt=H===at;if(!Mt){var xi=o(at);Mt=K.every(u(xi))}Mt&&Ce.push(Ge)}}}),Ce})},createElement:function(H){var K=new Ue;K.ownerDocument=this,K.nodeName=H,K.tagName=H,K.localName=H,K.childNodes=new ee;var se=K.attributes=new Y;return se._ownerElement=K,K},createDocumentFragment:function(){var H=new Et;return H.ownerDocument=this,H.childNodes=new ee,H},createTextNode:function(H){var K=new gt;return K.ownerDocument=this,K.appendData(H),K},createComment:function(H){var K=new Lt;return K.ownerDocument=this,K.appendData(H),K},createCDATASection:function(H){var K=new $t;return K.ownerDocument=this,K.appendData(H),K},createProcessingInstruction:function(H,K){var se=new de;return se.ownerDocument=this,se.tagName=se.nodeName=se.target=H,se.nodeValue=se.data=K,se},createAttribute:function(H){var K=new Ke;return K.ownerDocument=this,K.name=H,K.nodeName=H,K.localName=H,K.specified=!0,K},createEntityReference:function(H){var K=new vs;return K.ownerDocument=this,K.nodeName=H,K},createElementNS:function(H,K){var se=new Ue,Ce=K.split(":"),Ge=se.attributes=new Y;return se.childNodes=new ee,se.ownerDocument=this,se.nodeName=K,se.tagName=K,se.namespaceURI=H,Ce.length==2?(se.prefix=Ce[0],se.localName=Ce[1]):se.localName=K,Ge._ownerElement=se,se},createAttributeNS:function(H,K){var se=new Ke,Ce=K.split(":");return se.ownerDocument=this,se.nodeName=K,se.name=K,se.namespaceURI=H,se.specified=!0,Ce.length==2?(se.prefix=Ce[0],se.localName=Ce[1]):se.localName=K,se}},d(xe,U);function Ue(){this._nsMap={}}Ue.prototype={nodeType:m,hasAttribute:function(H){return this.getAttributeNode(H)!=null},getAttribute:function(H){var K=this.getAttributeNode(H);return K&&K.value||""},getAttributeNode:function(H){return this.attributes.getNamedItem(H)},setAttribute:function(H,K){var se=this.ownerDocument.createAttribute(H);se.value=se.nodeValue=""+K,this.setAttributeNode(se)},removeAttribute:function(H){var K=this.getAttributeNode(H);K&&this.removeAttributeNode(K)},appendChild:function(H){return H.nodeType===$?this.insertBefore(H,null):Fe(this,H)},setAttributeNode:function(H){return this.attributes.setNamedItem(H)},setAttributeNodeNS:function(H){return this.attributes.setNamedItemNS(H)},removeAttributeNode:function(H){return this.attributes.removeNamedItem(H.nodeName)},removeAttributeNS:function(H,K){var se=this.getAttributeNodeNS(H,K);se&&this.removeAttributeNode(se)},hasAttributeNS:function(H,K){return this.getAttributeNodeNS(H,K)!=null},getAttributeNS:function(H,K){var se=this.getAttributeNodeNS(H,K);return se&&se.value||""},setAttributeNS:function(H,K,se){var Ce=this.ownerDocument.createAttributeNS(H,K);Ce.value=Ce.nodeValue=""+se,this.setAttributeNode(Ce)},getAttributeNodeNS:function(H,K){return this.attributes.getNamedItemNS(H,K)},getElementsByTagName:function(H){return new le(this,function(K){var se=[];return fe(K,function(Ce){Ce!==K&&Ce.nodeType==m&&(H==="*"||Ce.tagName==H)&&se.push(Ce)}),se})},getElementsByTagNameNS:function(H,K){return new le(this,function(se){var Ce=[];return fe(se,function(Ge){Ge!==se&&Ge.nodeType===m&&(H==="*"||Ge.namespaceURI===H)&&(K==="*"||Ge.localName==K)&&Ce.push(Ge)}),Ce})}},xe.prototype.getElementsByTagName=Ue.prototype.getElementsByTagName,xe.prototype.getElementsByTagNameNS=Ue.prototype.getElementsByTagNameNS,d(Ue,U);function Ke(){}Ke.prototype.nodeType=g,d(Ke,U);function Ye(){}Ye.prototype={data:"",substringData:function(H,K){return this.data.substring(H,H+K)},appendData:function(H){H=this.data+H,this.nodeValue=this.data=H,this.length=H.length},insertData:function(H,K){this.replaceData(H,0,K)},appendChild:function(H){throw new Error(V[k])},deleteData:function(H,K){this.replaceData(H,K,"")},replaceData:function(H,K,se){var Ce=this.data.substring(0,H),Ge=this.data.substring(H+K);se=Ce+se+Ge,this.nodeValue=this.data=se,this.length=se.length}},d(Ye,U);function gt(){}gt.prototype={nodeName:"#text",nodeType:v,splitText:function(H){var K=this.data,se=K.substring(H);K=K.substring(0,H),this.data=this.nodeValue=K,this.length=K.length;var Ce=this.ownerDocument.createTextNode(se);return this.parentNode&&this.parentNode.insertBefore(Ce,this.nextSibling),Ce}},d(gt,Ye);function Lt(){}Lt.prototype={nodeName:"#comment",nodeType:I},d(Lt,Ye);function $t(){}$t.prototype={nodeName:"#cdata-section",nodeType:b},d($t,Ye);function fi(){}fi.prototype.nodeType=F,d(fi,U);function pi(){}pi.prototype.nodeType=G,d(pi,U);function ts(){}ts.prototype.nodeType=E,d(ts,U);function vs(){}vs.prototype.nodeType=_,d(vs,U);function Et(){}Et.prototype.nodeName="#document-fragment",Et.prototype.nodeType=$,d(Et,U);function de(){}de.prototype.nodeType=w,d(de,U);function ye(){}ye.prototype.serializeToString=function(H,K,se){return Se.call(H,K,se)},U.prototype.toString=Se;function Se(H,K){var se=[],Ce=this.nodeType==9&&this.documentElement||this,Ge=Ce.prefix,at=Ce.namespaceURI;if(at&&Ge==null){var Ge=Ce.lookupPrefix(at);if(Ge==null)var Mt=[{namespace:at,prefix:null}]}return gi(this,se,H,K,Mt),se.join("")}function He(H,K,se){var Ce=H.prefix||"",Ge=H.namespaceURI;if(!Ge||Ce==="xml"&&Ge===t.XML||Ge===t.XMLNS)return!1;for(var at=se.length;at--;){var Mt=se[at];if(Mt.prefix===Ce)return Mt.namespace!==Ge}return!0}function it(H,K,se){H.push(" ",K,'="',se.replace(/[<>&"\t\n\r]/g,ie),'"')}function gi(H,K,se,Ce,Ge){if(Ge||(Ge=[]),Ce)if(H=Ce(H),H){if(typeof H=="string"){K.push(H);return}}else return;switch(H.nodeType){case m:var at=H.attributes,Mt=at.length,Nt=H.firstChild,xi=H.tagName;se=t.isHTML(H.namespaceURI)||se;var Pi=xi;if(!se&&!H.prefix&&H.namespaceURI){for(var ut,Mi=0;Mi<at.length;Mi++)if(at.item(Mi).name==="xmlns"){ut=at.item(Mi).value;break}if(!ut)for(var Ts=Ge.length-1;Ts>=0;Ts--){var ci=Ge[Ts];if(ci.prefix===""&&ci.namespace===H.namespaceURI){ut=ci.namespace;break}}if(ut!==H.namespaceURI)for(var Ts=Ge.length-1;Ts>=0;Ts--){var ci=Ge[Ts];if(ci.namespace===H.namespaceURI){ci.prefix&&(Pi=ci.prefix+":"+xi);break}}}K.push("<",Pi);for(var An=0;An<Mt;An++){var Ls=at.item(An);Ls.prefix=="xmlns"?Ge.push({prefix:Ls.localName,namespace:Ls.value}):Ls.nodeName=="xmlns"&&Ge.push({prefix:"",namespace:Ls.value})}for(var An=0;An<Mt;An++){var Ls=at.item(An);if(He(Ls,se,Ge)){var Ni=Ls.prefix||"",jt=Ls.namespaceURI;it(K,Ni?"xmlns:"+Ni:"xmlns",jt),Ge.push({prefix:Ni,namespace:jt})}gi(Ls,K,se,Ce,Ge)}if(xi===Pi&&He(H,se,Ge)){var Ni=H.prefix||"",jt=H.namespaceURI;it(K,Ni?"xmlns:"+Ni:"xmlns",jt),Ge.push({prefix:Ni,namespace:jt})}if(Nt||se&&!/^(?:meta|link|img|br|hr|input)$/i.test(xi)){if(K.push(">"),se&&/^script$/i.test(xi))for(;Nt;)Nt.data?K.push(Nt.data):gi(Nt,K,se,Ce,Ge.slice()),Nt=Nt.nextSibling;else for(;Nt;)gi(Nt,K,se,Ce,Ge.slice()),Nt=Nt.nextSibling;K.push("</",Pi,">")}else K.push("/>");return;case L:case $:for(var Nt=H.firstChild;Nt;)gi(Nt,K,se,Ce,Ge.slice()),Nt=Nt.nextSibling;return;case g:return it(K,H.name,H.value);case v:return K.push(H.data.replace(/[<&>]/g,ie));case b:return K.push("<![CDATA[",H.data,"]]>");case I:return K.push("<!--",H.data,"-->");case F:var kt=H.publicId,Cn=H.systemId;if(K.push("<!DOCTYPE ",H.name),kt)K.push(" PUBLIC ",kt),Cn&&Cn!="."&&K.push(" ",Cn),K.push(">");else if(Cn&&Cn!=".")K.push(" SYSTEM ",Cn,">");else{var jr=H.internalSubset;jr&&K.push(" [",jr,"]"),K.push(">")}return;case w:return K.push("<?",H.target," ",H.data,"?>");case _:return K.push("&",H.nodeName,";");default:K.push("??",H.nodeName)}}function Oi(H,K,se){var Ce;switch(K.nodeType){case m:Ce=K.cloneNode(!1),Ce.ownerDocument=H;case $:break;case g:se=!0;break}if(Ce||(Ce=K.cloneNode(!1)),Ce.ownerDocument=H,Ce.parentNode=null,se)for(var Ge=K.firstChild;Ge;)Ce.appendChild(Oi(H,Ge,se)),Ge=Ge.nextSibling;return Ce}function Wi(H,K,se){var Ce=new K.constructor;for(var Ge in K)if(Object.prototype.hasOwnProperty.call(K,Ge)){var at=K[Ge];typeof at!="object"&&at!=Ce[Ge]&&(Ce[Ge]=at)}switch(K.childNodes&&(Ce.childNodes=new ee),Ce.ownerDocument=H,Ce.nodeType){case m:var Mt=K.attributes,xi=Ce.attributes=new Y,Pi=Mt.length;xi._ownerElement=Ce;for(var ut=0;ut<Pi;ut++)Ce.setAttributeNode(Wi(H,Mt.item(ut),!0));break;case g:se=!0}if(se)for(var Mi=K.firstChild;Mi;)Ce.appendChild(Wi(H,Mi,se)),Mi=Mi.nextSibling;return Ce}function Ht(H,K,se){H[K]=se}try{if(Object.defineProperty){let H=function(K){switch(K.nodeType){case m:case $:var se=[];for(K=K.firstChild;K;)K.nodeType!==7&&K.nodeType!==8&&se.push(H(K)),K=K.nextSibling;return se.join("");default:return K.nodeValue}};var ws=H;Object.defineProperty(le.prototype,"length",{get:function(){return oe(this),this.$$length}}),Object.defineProperty(U.prototype,"textContent",{get:function(){return H(this)},set:function(K){switch(this.nodeType){case m:case $:for(;this.firstChild;)this.removeChild(this.firstChild);(K||String(K))&&this.appendChild(this.ownerDocument.createTextNode(K));break;default:this.data=K,this.value=K,this.nodeValue=K}}}),Ht=function(K,se,Ce){K["$$"+se]=Ce}}}catch{}return ua.DocumentType=fi,ua.DOMException=X,ua.DOMImplementation=ue,ua.Element=Ue,ua.Node=U,ua.NodeList=ee,ua.XMLSerializer=ye,ua}var Td={},py={},dE;function JP(){return dE||(dE=1,(function(s){var e=_m().freeze;s.XML_ENTITIES=e({amp:"&",apos:"'",gt:">",lt:"<",quot:'"'}),s.HTML_ENTITIES=e({Aacute:"Á",aacute:"á",Abreve:"Ă",abreve:"ă",ac:"∾",acd:"∿",acE:"∾̳",Acirc:"Â",acirc:"â",acute:"´",Acy:"А",acy:"а",AElig:"Æ",aelig:"æ",af:"",Afr:"𝔄",afr:"𝔞",Agrave:"À",agrave:"à",alefsym:"ℵ",aleph:"ℵ",Alpha:"Α",alpha:"α",Amacr:"Ā",amacr:"ā",amalg:"⨿",AMP:"&",amp:"&",And:"⩓",and:"∧",andand:"⩕",andd:"⩜",andslope:"⩘",andv:"⩚",ang:"∠",ange:"⦤",angle:"∠",angmsd:"∡",angmsdaa:"⦨",angmsdab:"⦩",angmsdac:"⦪",angmsdad:"⦫",angmsdae:"⦬",angmsdaf:"⦭",angmsdag:"⦮",angmsdah:"⦯",angrt:"∟",angrtvb:"⊾",angrtvbd:"⦝",angsph:"∢",angst:"Å",angzarr:"⍼",Aogon:"Ą",aogon:"ą",Aopf:"𝔸",aopf:"𝕒",ap:"≈",apacir:"⩯",apE:"⩰",ape:"≊",apid:"≋",apos:"'",ApplyFunction:"",approx:"≈",approxeq:"≊",Aring:"Å",aring:"å",Ascr:"𝒜",ascr:"𝒶",Assign:"≔",ast:"*",asymp:"≈",asympeq:"≍",Atilde:"Ã",atilde:"ã",Auml:"Ä",auml:"ä",awconint:"∳",awint:"⨑",backcong:"≌",backepsilon:"϶",backprime:"",backsim:"∽",backsimeq:"⋍",Backslash:"",Barv:"⫧",barvee:"⊽",Barwed:"⌆",barwed:"⌅",barwedge:"⌅",bbrk:"⎵",bbrktbrk:"⎶",bcong:"≌",Bcy:"Б",bcy:"б",bdquo:"„",becaus:"∵",Because:"∵",because:"∵",bemptyv:"⦰",bepsi:"϶",bernou:"",Bernoullis:"",Beta:"Β",beta:"β",beth:"ℶ",between:"≬",Bfr:"𝔅",bfr:"𝔟",bigcap:"⋂",bigcirc:"◯",bigcup:"",bigodot:"⨀",bigoplus:"⨁",bigotimes:"⨂",bigsqcup:"⨆",bigstar:"★",bigtriangledown:"▽",bigtriangleup:"△",biguplus:"⨄",bigvee:"",bigwedge:"⋀",bkarow:"⤍",blacklozenge:"⧫",blacksquare:"▪",blacktriangle:"▴",blacktriangledown:"▾",blacktriangleleft:"◂",blacktriangleright:"▸",blank:"␣",blk12:"▒",blk14:"░",blk34:"▓",block:"█",bne:"=⃥",bnequiv:"≡⃥",bNot:"⫭",bnot:"⌐",Bopf:"𝔹",bopf:"𝕓",bot:"⊥",bottom:"⊥",bowtie:"⋈",boxbox:"⧉",boxDL:"╗",boxDl:"╖",boxdL:"╕",boxdl:"┐",boxDR:"╔",boxDr:"╓",boxdR:"╒",boxdr:"┌",boxH:"═",boxh:"─",boxHD:"╦",boxHd:"╤",boxhD:"╥",boxhd:"┬",boxHU:"╩",boxHu:"╧",boxhU:"╨",boxhu:"┴",boxminus:"⊟",boxplus:"⊞",boxtimes:"⊠",boxUL:"╝",boxUl:"╜",boxuL:"╛",boxul:"┘",boxUR:"╚",boxUr:"╙",boxuR:"╘",boxur:"└",boxV:"║",boxv:"│",boxVH:"╬",boxVh:"╫",boxvH:"╪",boxvh:"┼",boxVL:"╣",boxVl:"╢",boxvL:"╡",boxvl:"┤",boxVR:"╠",boxVr:"╟",boxvR:"╞",boxvr:"├",bprime:"",Breve:"˘",breve:"˘",brvbar:"¦",Bscr:"",bscr:"𝒷",bsemi:"⁏",bsim:"∽",bsime:"⋍",bsol:"\\",bsolb:"⧅",bsolhsub:"⟈",bull:"•",bullet:"•",bump:"≎",bumpE:"⪮",bumpe:"≏",Bumpeq:"≎",bumpeq:"≏",Cacute:"Ć",cacute:"ć",Cap:"⋒",cap:"∩",capand:"⩄",capbrcup:"⩉",capcap:"⩋",capcup:"⩇",capdot:"⩀",CapitalDifferentialD:"",caps:"∩︀",caret:"",caron:"ˇ",Cayleys:"",ccaps:"⩍",Ccaron:"Č",ccaron:"č",Ccedil:"Ç",ccedil:"ç",Ccirc:"Ĉ",ccirc:"ĉ",Cconint:"∰",ccups:"⩌",ccupssm:"⩐",Cdot:"Ċ",cdot:"ċ",cedil:"¸",Cedilla:"¸",cemptyv:"⦲",cent:"¢",CenterDot:"·",centerdot:"·",Cfr:"",cfr:"𝔠",CHcy:"Ч",chcy:"ч",check:"✓",checkmark:"✓",Chi:"Χ",chi:"χ",cir:"○",circ:"ˆ",circeq:"≗",circlearrowleft:"↺",circlearrowright:"↻",circledast:"⊛",circledcirc:"⊚",circleddash:"⊝",CircleDot:"⊙",circledR:"®",circledS:"Ⓢ",CircleMinus:"⊖",CirclePlus:"⊕",CircleTimes:"⊗",cirE:"⧃",cire:"≗",cirfnint:"⨐",cirmid:"⫯",cirscir:"⧂",ClockwiseContourIntegral:"∲",CloseCurlyDoubleQuote:"”",CloseCurlyQuote:"",clubs:"♣",clubsuit:"♣",Colon:"∷",colon:":",Colone:"⩴",colone:"≔",coloneq:"≔",comma:",",commat:"@",comp:"∁",compfn:"∘",complement:"∁",complexes:"",cong:"≅",congdot:"⩭",Congruent:"≡",Conint:"∯",conint:"∮",ContourIntegral:"∮",Copf:"",copf:"𝕔",coprod:"∐",Coproduct:"∐",COPY:"©",copy:"©",copysr:"℗",CounterClockwiseContourIntegral:"∳",crarr:"↵",Cross:"",cross:"✗",Cscr:"𝒞",cscr:"𝒸",csub:"⫏",csube:"⫑",csup:"⫐",csupe:"⫒",ctdot:"⋯",cudarrl:"⤸",cudarrr:"⤵",cuepr:"⋞",cuesc:"⋟",cularr:"↶",cularrp:"⤽",Cup:"⋓",cup:"",cupbrcap:"⩈",CupCap:"≍",cupcap:"⩆",cupcup:"⩊",cupdot:"⊍",cupor:"⩅",cups:"",curarr:"↷",curarrm:"⤼",curlyeqprec:"⋞",curlyeqsucc:"⋟",curlyvee:"⋎",curlywedge:"⋏",curren:"¤",curvearrowleft:"↶",curvearrowright:"↷",cuvee:"⋎",cuwed:"⋏",cwconint:"∲",cwint:"∱",cylcty:"⌭",Dagger:"‡",dagger:"†",daleth:"ℸ",Darr:"↡",dArr:"⇓",darr:"↓",dash:"",Dashv:"⫤",dashv:"⊣",dbkarow:"⤏",dblac:"˝",Dcaron:"Ď",dcaron:"ď",Dcy:"Д",dcy:"д",DD:"",dd:"",ddagger:"‡",ddarr:"⇊",DDotrahd:"⤑",ddotseq:"⩷",deg:"°",Del:"∇",Delta:"Δ",delta:"δ",demptyv:"⦱",dfisht:"⥿",Dfr:"𝔇",dfr:"𝔡",dHar:"⥥",dharl:"⇃",dharr:"⇂",DiacriticalAcute:"´",DiacriticalDot:"˙",DiacriticalDoubleAcute:"˝",DiacriticalGrave:"`",DiacriticalTilde:"˜",diam:"⋄",Diamond:"⋄",diamond:"⋄",diamondsuit:"♦",diams:"♦",die:"¨",DifferentialD:"",digamma:"ϝ",disin:"⋲",div:"÷",divide:"÷",divideontimes:"⋇",divonx:"⋇",DJcy:"Ђ",djcy:"ђ",dlcorn:"⌞",dlcrop:"⌍",dollar:"$",Dopf:"𝔻",dopf:"𝕕",Dot:"¨",dot:"˙",DotDot:"⃜",doteq:"≐",doteqdot:"≑",DotEqual:"≐",dotminus:"∸",dotplus:"∔",dotsquare:"⊡",doublebarwedge:"⌆",DoubleContourIntegral:"∯",DoubleDot:"¨",DoubleDownArrow:"⇓",DoubleLeftArrow:"⇐",DoubleLeftRightArrow:"⇔",DoubleLeftTee:"⫤",DoubleLongLeftArrow:"⟸",DoubleLongLeftRightArrow:"⟺",DoubleLongRightArrow:"⟹",DoubleRightArrow:"⇒",DoubleRightTee:"⊨",DoubleUpArrow:"⇑",DoubleUpDownArrow:"⇕",DoubleVerticalBar:"∥",DownArrow:"↓",Downarrow:"⇓",downarrow:"↓",DownArrowBar:"⤓",DownArrowUpArrow:"⇵",DownBreve:"̑",downdownarrows:"⇊",downharpoonleft:"⇃",downharpoonright:"⇂",DownLeftRightVector:"⥐",DownLeftTeeVector:"⥞",DownLeftVector:"↽",DownLeftVectorBar:"⥖",DownRightTeeVector:"⥟",DownRightVector:"⇁",DownRightVectorBar:"⥗",DownTee:"",DownTeeArrow:"↧",drbkarow:"⤐",drcorn:"⌟",drcrop:"⌌",Dscr:"𝒟",dscr:"𝒹",DScy:"Ѕ",dscy:"ѕ",dsol:"⧶",Dstrok:"Đ",dstrok:"đ",dtdot:"⋱",dtri:"▿",dtrif:"▾",duarr:"⇵",duhar:"⥯",dwangle:"⦦",DZcy:"Џ",dzcy:"џ",dzigrarr:"⟿",Eacute:"É",eacute:"é",easter:"⩮",Ecaron:"Ě",ecaron:"ě",ecir:"≖",Ecirc:"Ê",ecirc:"ê",ecolon:"≕",Ecy:"Э",ecy:"э",eDDot:"⩷",Edot:"Ė",eDot:"≑",edot:"ė",ee:"",efDot:"≒",Efr:"𝔈",efr:"𝔢",eg:"⪚",Egrave:"È",egrave:"è",egs:"⪖",egsdot:"⪘",el:"⪙",Element:"∈",elinters:"⏧",ell:"",els:"⪕",elsdot:"⪗",Emacr:"Ē",emacr:"ē",empty:"∅",emptyset:"∅",EmptySmallSquare:"◻",emptyv:"∅",EmptyVerySmallSquare:"▫",emsp:"",emsp13:"",emsp14:"",ENG:"Ŋ",eng:"ŋ",ensp:"",Eogon:"Ę",eogon:"ę",Eopf:"𝔼",eopf:"𝕖",epar:"⋕",eparsl:"⧣",eplus:"⩱",epsi:"ε",Epsilon:"Ε",epsilon:"ε",epsiv:"ϵ",eqcirc:"≖",eqcolon:"≕",eqsim:"≂",eqslantgtr:"⪖",eqslantless:"⪕",Equal:"⩵",equals:"=",EqualTilde:"≂",equest:"≟",Equilibrium:"⇌",equiv:"≡",equivDD:"⩸",eqvparsl:"⧥",erarr:"⥱",erDot:"≓",Escr:"",escr:"",esdot:"≐",Esim:"⩳",esim:"≂",Eta:"Η",eta:"η",ETH:"Ð",eth:"ð",Euml:"Ë",euml:"ë",euro:"€",excl:"!",exist:"∃",Exists:"∃",expectation:"",ExponentialE:"",exponentiale:"",fallingdotseq:"≒",Fcy:"Ф",fcy:"ф",female:"♀",ffilig:"ffi",fflig:"ff",ffllig:"ffl",Ffr:"𝔉",ffr:"𝔣",filig:"fi",FilledSmallSquare:"◼",FilledVerySmallSquare:"▪",fjlig:"fj",flat:"♭",fllig:"fl",fltns:"▱",fnof:"ƒ",Fopf:"𝔽",fopf:"𝕗",ForAll:"∀",forall:"∀",fork:"⋔",forkv:"⫙",Fouriertrf:"",fpartint:"⨍",frac12:"½",frac13:"⅓",frac14:"¼",frac15:"⅕",frac16:"⅙",frac18:"⅛",frac23:"⅔",frac25:"⅖",frac34:"¾",frac35:"⅗",frac38:"⅜",frac45:"⅘",frac56:"⅚",frac58:"⅝",frac78:"⅞",frasl:"",frown:"⌢",Fscr:"",fscr:"𝒻",gacute:"ǵ",Gamma:"Γ",gamma:"γ",Gammad:"Ϝ",gammad:"ϝ",gap:"⪆",Gbreve:"Ğ",gbreve:"ğ",Gcedil:"Ģ",Gcirc:"Ĝ",gcirc:"ĝ",Gcy:"Г",gcy:"г",Gdot:"Ġ",gdot:"ġ",gE:"≧",ge:"≥",gEl:"⪌",gel:"⋛",geq:"≥",geqq:"≧",geqslant:"⩾",ges:"⩾",gescc:"⪩",gesdot:"⪀",gesdoto:"⪂",gesdotol:"⪄",gesl:"⋛︀",gesles:"⪔",Gfr:"𝔊",gfr:"𝔤",Gg:"⋙",gg:"≫",ggg:"⋙",gimel:"ℷ",GJcy:"Ѓ",gjcy:"ѓ",gl:"≷",gla:"⪥",glE:"⪒",glj:"⪤",gnap:"⪊",gnapprox:"⪊",gnE:"≩",gne:"⪈",gneq:"⪈",gneqq:"≩",gnsim:"⋧",Gopf:"𝔾",gopf:"𝕘",grave:"`",GreaterEqual:"≥",GreaterEqualLess:"⋛",GreaterFullEqual:"≧",GreaterGreater:"⪢",GreaterLess:"≷",GreaterSlantEqual:"⩾",GreaterTilde:"≳",Gscr:"𝒢",gscr:"",gsim:"≳",gsime:"⪎",gsiml:"⪐",Gt:"≫",GT:">",gt:">",gtcc:"⪧",gtcir:"⩺",gtdot:"⋗",gtlPar:"⦕",gtquest:"⩼",gtrapprox:"⪆",gtrarr:"⥸",gtrdot:"⋗",gtreqless:"⋛",gtreqqless:"⪌",gtrless:"≷",gtrsim:"≳",gvertneqq:"≩︀",gvnE:"≩︀",Hacek:"ˇ",hairsp:"",half:"½",hamilt:"",HARDcy:"Ъ",hardcy:"ъ",hArr:"⇔",harr:"↔",harrcir:"⥈",harrw:"↭",Hat:"^",hbar:"ℏ",Hcirc:"Ĥ",hcirc:"ĥ",hearts:"♥",heartsuit:"♥",hellip:"…",hercon:"⊹",Hfr:"",hfr:"𝔥",HilbertSpace:"",hksearow:"⤥",hkswarow:"⤦",hoarr:"⇿",homtht:"∻",hookleftarrow:"↩",hookrightarrow:"↪",Hopf:"",hopf:"𝕙",horbar:"―",HorizontalLine:"─",Hscr:"",hscr:"𝒽",hslash:"ℏ",Hstrok:"Ħ",hstrok:"ħ",HumpDownHump:"≎",HumpEqual:"≏",hybull:"",hyphen:"",Iacute:"Í",iacute:"í",ic:"",Icirc:"Î",icirc:"î",Icy:"И",icy:"и",Idot:"İ",IEcy:"Е",iecy:"е",iexcl:"¡",iff:"⇔",Ifr:"",ifr:"𝔦",Igrave:"Ì",igrave:"ì",ii:"",iiiint:"⨌",iiint:"∭",iinfin:"⧜",iiota:"℩",IJlig:"IJ",ijlig:"ij",Im:"",Imacr:"Ī",imacr:"ī",image:"",ImaginaryI:"",imagline:"",imagpart:"",imath:"ı",imof:"⊷",imped:"Ƶ",Implies:"⇒",in:"∈",incare:"℅",infin:"∞",infintie:"⧝",inodot:"ı",Int:"∬",int:"∫",intcal:"⊺",integers:"",Integral:"∫",intercal:"⊺",Intersection:"⋂",intlarhk:"⨗",intprod:"⨼",InvisibleComma:"",InvisibleTimes:"",IOcy:"Ё",iocy:"ё",Iogon:"Į",iogon:"į",Iopf:"𝕀",iopf:"𝕚",Iota:"Ι",iota:"ι",iprod:"⨼",iquest:"¿",Iscr:"",iscr:"𝒾",isin:"∈",isindot:"⋵",isinE:"⋹",isins:"⋴",isinsv:"⋳",isinv:"∈",it:"",Itilde:"Ĩ",itilde:"ĩ",Iukcy:"І",iukcy:"і",Iuml:"Ï",iuml:"ï",Jcirc:"Ĵ",jcirc:"ĵ",Jcy:"Й",jcy:"й",Jfr:"𝔍",jfr:"𝔧",jmath:"ȷ",Jopf:"𝕁",jopf:"𝕛",Jscr:"𝒥",jscr:"𝒿",Jsercy:"Ј",jsercy:"ј",Jukcy:"Є",jukcy:"є",Kappa:"Κ",kappa:"κ",kappav:"ϰ",Kcedil:"Ķ",kcedil:"ķ",Kcy:"К",kcy:"к",Kfr:"𝔎",kfr:"𝔨",kgreen:"ĸ",KHcy:"Х",khcy:"х",KJcy:"Ќ",kjcy:"ќ",Kopf:"𝕂",kopf:"𝕜",Kscr:"𝒦",kscr:"𝓀",lAarr:"⇚",Lacute:"Ĺ",lacute:"ĺ",laemptyv:"⦴",lagran:"",Lambda:"Λ",lambda:"λ",Lang:"⟪",lang:"⟨",langd:"⦑",langle:"⟨",lap:"⪅",Laplacetrf:"",laquo:"«",Larr:"↞",lArr:"⇐",larr:"←",larrb:"⇤",larrbfs:"⤟",larrfs:"⤝",larrhk:"↩",larrlp:"↫",larrpl:"⤹",larrsim:"⥳",larrtl:"↢",lat:"⪫",lAtail:"⤛",latail:"⤙",late:"⪭",lates:"⪭︀",lBarr:"⤎",lbarr:"⤌",lbbrk:"",lbrace:"{",lbrack:"[",lbrke:"⦋",lbrksld:"⦏",lbrkslu:"⦍",Lcaron:"Ľ",lcaron:"ľ",Lcedil:"Ļ",lcedil:"ļ",lceil:"⌈",lcub:"{",Lcy:"Л",lcy:"л",ldca:"⤶",ldquo:"“",ldquor:"„",ldrdhar:"⥧",ldrushar:"⥋",ldsh:"↲",lE:"≦",le:"≤",LeftAngleBracket:"⟨",LeftArrow:"←",Leftarrow:"⇐",leftarrow:"←",LeftArrowBar:"⇤",LeftArrowRightArrow:"⇆",leftarrowtail:"↢",LeftCeiling:"⌈",LeftDoubleBracket:"⟦",LeftDownTeeVector:"⥡",LeftDownVector:"⇃",LeftDownVectorBar:"⥙",LeftFloor:"⌊",leftharpoondown:"↽",leftharpoonup:"↼",leftleftarrows:"⇇",LeftRightArrow:"↔",Leftrightarrow:"⇔",leftrightarrow:"↔",leftrightarrows:"⇆",leftrightharpoons:"⇋",leftrightsquigarrow:"↭",LeftRightVector:"⥎",LeftTee:"⊣",LeftTeeArrow:"↤",LeftTeeVector:"⥚",leftthreetimes:"⋋",LeftTriangle:"⊲",LeftTriangleBar:"⧏",LeftTriangleEqual:"⊴",LeftUpDownVector:"⥑",LeftUpTeeVector:"⥠",LeftUpVector:"↿",LeftUpVectorBar:"⥘",LeftVector:"↼",LeftVectorBar:"⥒",lEg:"⪋",leg:"⋚",leq:"≤",leqq:"≦",leqslant:"⩽",les:"⩽",lescc:"⪨",lesdot:"⩿",lesdoto:"⪁",lesdotor:"⪃",lesg:"⋚︀",lesges:"⪓",lessapprox:"⪅",lessdot:"⋖",lesseqgtr:"⋚",lesseqqgtr:"⪋",LessEqualGreater:"⋚",LessFullEqual:"≦",LessGreater:"≶",lessgtr:"≶",LessLess:"⪡",lesssim:"≲",LessSlantEqual:"⩽",LessTilde:"≲",lfisht:"⥼",lfloor:"⌊",Lfr:"𝔏",lfr:"𝔩",lg:"≶",lgE:"⪑",lHar:"⥢",lhard:"↽",lharu:"↼",lharul:"⥪",lhblk:"▄",LJcy:"Љ",ljcy:"љ",Ll:"⋘",ll:"≪",llarr:"⇇",llcorner:"⌞",Lleftarrow:"⇚",llhard:"⥫",lltri:"◺",Lmidot:"Ŀ",lmidot:"ŀ",lmoust:"⎰",lmoustache:"⎰",lnap:"⪉",lnapprox:"⪉",lnE:"≨",lne:"⪇",lneq:"⪇",lneqq:"≨",lnsim:"⋦",loang:"⟬",loarr:"⇽",lobrk:"⟦",LongLeftArrow:"⟵",Longleftarrow:"⟸",longleftarrow:"⟵",LongLeftRightArrow:"⟷",Longleftrightarrow:"⟺",longleftrightarrow:"⟷",longmapsto:"⟼",LongRightArrow:"⟶",Longrightarrow:"⟹",longrightarrow:"⟶",looparrowleft:"↫",looparrowright:"↬",lopar:"⦅",Lopf:"𝕃",lopf:"𝕝",loplus:"⨭",lotimes:"⨴",lowast:"",lowbar:"_",LowerLeftArrow:"↙",LowerRightArrow:"↘",loz:"◊",lozenge:"◊",lozf:"⧫",lpar:"(",lparlt:"⦓",lrarr:"⇆",lrcorner:"⌟",lrhar:"⇋",lrhard:"⥭",lrm:"",lrtri:"⊿",lsaquo:"",Lscr:"",lscr:"𝓁",Lsh:"↰",lsh:"↰",lsim:"≲",lsime:"⪍",lsimg:"⪏",lsqb:"[",lsquo:"",lsquor:"",Lstrok:"Ł",lstrok:"ł",Lt:"≪",LT:"<",lt:"<",ltcc:"⪦",ltcir:"⩹",ltdot:"⋖",lthree:"⋋",ltimes:"⋉",ltlarr:"⥶",ltquest:"⩻",ltri:"◃",ltrie:"⊴",ltrif:"◂",ltrPar:"⦖",lurdshar:"⥊",luruhar:"⥦",lvertneqq:"≨︀",lvnE:"≨︀",macr:"¯",male:"♂",malt:"✠",maltese:"✠",Map:"⤅",map:"↦",mapsto:"↦",mapstodown:"↧",mapstoleft:"↤",mapstoup:"↥",marker:"▮",mcomma:"⨩",Mcy:"М",mcy:"м",mdash:"—",mDDot:"∺",measuredangle:"∡",MediumSpace:"",Mellintrf:"",Mfr:"𝔐",mfr:"𝔪",mho:"℧",micro:"µ",mid:"",midast:"*",midcir:"⫰",middot:"·",minus:"",minusb:"⊟",minusd:"∸",minusdu:"⨪",MinusPlus:"∓",mlcp:"⫛",mldr:"…",mnplus:"∓",models:"⊧",Mopf:"𝕄",mopf:"𝕞",mp:"∓",Mscr:"",mscr:"𝓂",mstpos:"∾",Mu:"Μ",mu:"μ",multimap:"⊸",mumap:"⊸",nabla:"∇",Nacute:"Ń",nacute:"ń",nang:"∠⃒",nap:"≉",napE:"⩰̸",napid:"≋̸",napos:"ʼn",napprox:"≉",natur:"♮",natural:"♮",naturals:"",nbsp:" ",nbump:"≎̸",nbumpe:"≏̸",ncap:"⩃",Ncaron:"Ň",ncaron:"ň",Ncedil:"Ņ",ncedil:"ņ",ncong:"≇",ncongdot:"⩭̸",ncup:"⩂",Ncy:"Н",ncy:"н",ndash:"",ne:"≠",nearhk:"⤤",neArr:"⇗",nearr:"↗",nearrow:"↗",nedot:"≐̸",NegativeMediumSpace:"",NegativeThickSpace:"",NegativeThinSpace:"",NegativeVeryThinSpace:"",nequiv:"≢",nesear:"⤨",nesim:"≂̸",NestedGreaterGreater:"≫",NestedLessLess:"≪",NewLine:`
`,nexist:"∄",nexists:"∄",Nfr:"𝔑",nfr:"𝔫",ngE:"≧̸",nge:"≱",ngeq:"≱",ngeqq:"≧̸",ngeqslant:"⩾̸",nges:"⩾̸",nGg:"⋙̸",ngsim:"≵",nGt:"≫⃒",ngt:"≯",ngtr:"≯",nGtv:"≫̸",nhArr:"⇎",nharr:"↮",nhpar:"⫲",ni:"∋",nis:"⋼",nisd:"⋺",niv:"∋",NJcy:"Њ",njcy:"њ",nlArr:"⇍",nlarr:"↚",nldr:"‥",nlE:"≦̸",nle:"≰",nLeftarrow:"⇍",nleftarrow:"↚",nLeftrightarrow:"⇎",nleftrightarrow:"↮",nleq:"≰",nleqq:"≦̸",nleqslant:"⩽̸",nles:"⩽̸",nless:"≮",nLl:"⋘̸",nlsim:"≴",nLt:"≪⃒",nlt:"≮",nltri:"⋪",nltrie:"⋬",nLtv:"≪̸",nmid:"∤",NoBreak:"",NonBreakingSpace:" ",Nopf:"",nopf:"𝕟",Not:"⫬",not:"¬",NotCongruent:"≢",NotCupCap:"≭",NotDoubleVerticalBar:"∦",NotElement:"∉",NotEqual:"≠",NotEqualTilde:"≂̸",NotExists:"∄",NotGreater:"≯",NotGreaterEqual:"≱",NotGreaterFullEqual:"≧̸",NotGreaterGreater:"≫̸",NotGreaterLess:"≹",NotGreaterSlantEqual:"⩾̸",NotGreaterTilde:"≵",NotHumpDownHump:"≎̸",NotHumpEqual:"≏̸",notin:"∉",notindot:"⋵̸",notinE:"⋹̸",notinva:"∉",notinvb:"⋷",notinvc:"⋶",NotLeftTriangle:"⋪",NotLeftTriangleBar:"⧏̸",NotLeftTriangleEqual:"⋬",NotLess:"≮",NotLessEqual:"≰",NotLessGreater:"≸",NotLessLess:"≪̸",NotLessSlantEqual:"⩽̸",NotLessTilde:"≴",NotNestedGreaterGreater:"⪢̸",NotNestedLessLess:"⪡̸",notni:"∌",notniva:"∌",notnivb:"⋾",notnivc:"⋽",NotPrecedes:"⊀",NotPrecedesEqual:"⪯̸",NotPrecedesSlantEqual:"⋠",NotReverseElement:"∌",NotRightTriangle:"⋫",NotRightTriangleBar:"⧐̸",NotRightTriangleEqual:"⋭",NotSquareSubset:"⊏̸",NotSquareSubsetEqual:"⋢",NotSquareSuperset:"⊐̸",NotSquareSupersetEqual:"⋣",NotSubset:"⊂⃒",NotSubsetEqual:"⊈",NotSucceeds:"⊁",NotSucceedsEqual:"⪰̸",NotSucceedsSlantEqual:"⋡",NotSucceedsTilde:"≿̸",NotSuperset:"⊃⃒",NotSupersetEqual:"⊉",NotTilde:"≁",NotTildeEqual:"≄",NotTildeFullEqual:"≇",NotTildeTilde:"≉",NotVerticalBar:"∤",npar:"∦",nparallel:"∦",nparsl:"⫽⃥",npart:"∂̸",npolint:"⨔",npr:"⊀",nprcue:"⋠",npre:"⪯̸",nprec:"⊀",npreceq:"⪯̸",nrArr:"⇏",nrarr:"↛",nrarrc:"⤳̸",nrarrw:"↝̸",nRightarrow:"⇏",nrightarrow:"↛",nrtri:"⋫",nrtrie:"⋭",nsc:"⊁",nsccue:"⋡",nsce:"⪰̸",Nscr:"𝒩",nscr:"𝓃",nshortmid:"∤",nshortparallel:"∦",nsim:"≁",nsime:"≄",nsimeq:"≄",nsmid:"∤",nspar:"∦",nsqsube:"⋢",nsqsupe:"⋣",nsub:"⊄",nsubE:"⫅̸",nsube:"⊈",nsubset:"⊂⃒",nsubseteq:"⊈",nsubseteqq:"⫅̸",nsucc:"⊁",nsucceq:"⪰̸",nsup:"⊅",nsupE:"⫆̸",nsupe:"⊉",nsupset:"⊃⃒",nsupseteq:"⊉",nsupseteqq:"⫆̸",ntgl:"≹",Ntilde:"Ñ",ntilde:"ñ",ntlg:"≸",ntriangleleft:"⋪",ntrianglelefteq:"⋬",ntriangleright:"⋫",ntrianglerighteq:"⋭",Nu:"Ν",nu:"ν",num:"#",numero:"№",numsp:"",nvap:"≍⃒",nVDash:"⊯",nVdash:"⊮",nvDash:"⊭",nvdash:"⊬",nvge:"≥⃒",nvgt:">⃒",nvHarr:"⤄",nvinfin:"⧞",nvlArr:"⤂",nvle:"≤⃒",nvlt:"<⃒",nvltrie:"⊴⃒",nvrArr:"⤃",nvrtrie:"⊵⃒",nvsim:"∼⃒",nwarhk:"⤣",nwArr:"⇖",nwarr:"↖",nwarrow:"↖",nwnear:"⤧",Oacute:"Ó",oacute:"ó",oast:"⊛",ocir:"⊚",Ocirc:"Ô",ocirc:"ô",Ocy:"О",ocy:"о",odash:"⊝",Odblac:"Ő",odblac:"ő",odiv:"⨸",odot:"⊙",odsold:"⦼",OElig:"Œ",oelig:"œ",ofcir:"⦿",Ofr:"𝔒",ofr:"𝔬",ogon:"˛",Ograve:"Ò",ograve:"ò",ogt:"⧁",ohbar:"⦵",ohm:"Ω",oint:"∮",olarr:"↺",olcir:"⦾",olcross:"⦻",oline:"‾",olt:"⧀",Omacr:"Ō",omacr:"ō",Omega:"Ω",omega:"ω",Omicron:"Ο",omicron:"ο",omid:"⦶",ominus:"⊖",Oopf:"𝕆",oopf:"𝕠",opar:"⦷",OpenCurlyDoubleQuote:"“",OpenCurlyQuote:"",operp:"⦹",oplus:"⊕",Or:"⩔",or:"",orarr:"↻",ord:"⩝",order:"",orderof:"",ordf:"ª",ordm:"º",origof:"⊶",oror:"⩖",orslope:"⩗",orv:"⩛",oS:"Ⓢ",Oscr:"𝒪",oscr:"",Oslash:"Ø",oslash:"ø",osol:"⊘",Otilde:"Õ",otilde:"õ",Otimes:"⨷",otimes:"⊗",otimesas:"⨶",Ouml:"Ö",ouml:"ö",ovbar:"⌽",OverBar:"‾",OverBrace:"⏞",OverBracket:"⎴",OverParenthesis:"⏜",par:"∥",para:"¶",parallel:"∥",parsim:"⫳",parsl:"⫽",part:"∂",PartialD:"∂",Pcy:"П",pcy:"п",percnt:"%",period:".",permil:"‰",perp:"⊥",pertenk:"‱",Pfr:"𝔓",pfr:"𝔭",Phi:"Φ",phi:"φ",phiv:"ϕ",phmmat:"",phone:"☎",Pi:"Π",pi:"π",pitchfork:"⋔",piv:"ϖ",planck:"ℏ",planckh:"",plankv:"ℏ",plus:"+",plusacir:"⨣",plusb:"⊞",pluscir:"⨢",plusdo:"∔",plusdu:"⨥",pluse:"⩲",PlusMinus:"±",plusmn:"±",plussim:"⨦",plustwo:"⨧",pm:"±",Poincareplane:"",pointint:"⨕",Popf:"",popf:"𝕡",pound:"£",Pr:"⪻",pr:"≺",prap:"⪷",prcue:"≼",prE:"⪳",pre:"⪯",prec:"≺",precapprox:"⪷",preccurlyeq:"≼",Precedes:"≺",PrecedesEqual:"⪯",PrecedesSlantEqual:"≼",PrecedesTilde:"≾",preceq:"⪯",precnapprox:"⪹",precneqq:"⪵",precnsim:"⋨",precsim:"≾",Prime:"″",prime:"",primes:"",prnap:"⪹",prnE:"⪵",prnsim:"⋨",prod:"∏",Product:"∏",profalar:"⌮",profline:"⌒",profsurf:"⌓",prop:"∝",Proportion:"∷",Proportional:"∝",propto:"∝",prsim:"≾",prurel:"⊰",Pscr:"𝒫",pscr:"𝓅",Psi:"Ψ",psi:"ψ",puncsp:"",Qfr:"𝔔",qfr:"𝔮",qint:"⨌",Qopf:"",qopf:"𝕢",qprime:"⁗",Qscr:"𝒬",qscr:"𝓆",quaternions:"",quatint:"⨖",quest:"?",questeq:"≟",QUOT:'"',quot:'"',rAarr:"⇛",race:"∽̱",Racute:"Ŕ",racute:"ŕ",radic:"√",raemptyv:"⦳",Rang:"⟫",rang:"⟩",rangd:"⦒",range:"⦥",rangle:"⟩",raquo:"»",Rarr:"↠",rArr:"⇒",rarr:"→",rarrap:"⥵",rarrb:"⇥",rarrbfs:"⤠",rarrc:"⤳",rarrfs:"⤞",rarrhk:"↪",rarrlp:"↬",rarrpl:"⥅",rarrsim:"⥴",Rarrtl:"⤖",rarrtl:"↣",rarrw:"↝",rAtail:"⤜",ratail:"⤚",ratio:"",rationals:"",RBarr:"⤐",rBarr:"⤏",rbarr:"⤍",rbbrk:"",rbrace:"}",rbrack:"]",rbrke:"⦌",rbrksld:"⦎",rbrkslu:"⦐",Rcaron:"Ř",rcaron:"ř",Rcedil:"Ŗ",rcedil:"ŗ",rceil:"⌉",rcub:"}",Rcy:"Р",rcy:"р",rdca:"⤷",rdldhar:"⥩",rdquo:"”",rdquor:"”",rdsh:"↳",Re:"",real:"",realine:"",realpart:"",reals:"",rect:"▭",REG:"®",reg:"®",ReverseElement:"∋",ReverseEquilibrium:"⇋",ReverseUpEquilibrium:"⥯",rfisht:"⥽",rfloor:"⌋",Rfr:"",rfr:"𝔯",rHar:"⥤",rhard:"⇁",rharu:"⇀",rharul:"⥬",Rho:"Ρ",rho:"ρ",rhov:"ϱ",RightAngleBracket:"⟩",RightArrow:"→",Rightarrow:"⇒",rightarrow:"→",RightArrowBar:"⇥",RightArrowLeftArrow:"⇄",rightarrowtail:"↣",RightCeiling:"⌉",RightDoubleBracket:"⟧",RightDownTeeVector:"⥝",RightDownVector:"⇂",RightDownVectorBar:"⥕",RightFloor:"⌋",rightharpoondown:"⇁",rightharpoonup:"⇀",rightleftarrows:"⇄",rightleftharpoons:"⇌",rightrightarrows:"⇉",rightsquigarrow:"↝",RightTee:"⊢",RightTeeArrow:"↦",RightTeeVector:"⥛",rightthreetimes:"⋌",RightTriangle:"⊳",RightTriangleBar:"⧐",RightTriangleEqual:"⊵",RightUpDownVector:"⥏",RightUpTeeVector:"⥜",RightUpVector:"↾",RightUpVectorBar:"⥔",RightVector:"⇀",RightVectorBar:"⥓",ring:"˚",risingdotseq:"≓",rlarr:"⇄",rlhar:"⇌",rlm:"",rmoust:"⎱",rmoustache:"⎱",rnmid:"⫮",roang:"⟭",roarr:"⇾",robrk:"⟧",ropar:"⦆",Ropf:"",ropf:"𝕣",roplus:"⨮",rotimes:"⨵",RoundImplies:"⥰",rpar:")",rpargt:"⦔",rppolint:"⨒",rrarr:"⇉",Rrightarrow:"⇛",rsaquo:"",Rscr:"",rscr:"𝓇",Rsh:"↱",rsh:"↱",rsqb:"]",rsquo:"",rsquor:"",rthree:"⋌",rtimes:"⋊",rtri:"▹",rtrie:"⊵",rtrif:"▸",rtriltri:"⧎",RuleDelayed:"⧴",ruluhar:"⥨",rx:"℞",Sacute:"Ś",sacute:"ś",sbquo:"",Sc:"⪼",sc:"≻",scap:"⪸",Scaron:"Š",scaron:"š",sccue:"≽",scE:"⪴",sce:"⪰",Scedil:"Ş",scedil:"ş",Scirc:"Ŝ",scirc:"ŝ",scnap:"⪺",scnE:"⪶",scnsim:"⋩",scpolint:"⨓",scsim:"≿",Scy:"С",scy:"с",sdot:"⋅",sdotb:"⊡",sdote:"⩦",searhk:"⤥",seArr:"⇘",searr:"↘",searrow:"↘",sect:"§",semi:";",seswar:"⤩",setminus:"",setmn:"",sext:"✶",Sfr:"𝔖",sfr:"𝔰",sfrown:"⌢",sharp:"♯",SHCHcy:"Щ",shchcy:"щ",SHcy:"Ш",shcy:"ш",ShortDownArrow:"↓",ShortLeftArrow:"←",shortmid:"",shortparallel:"∥",ShortRightArrow:"→",ShortUpArrow:"↑",shy:"­",Sigma:"Σ",sigma:"σ",sigmaf:"ς",sigmav:"ς",sim:"",simdot:"⩪",sime:"≃",simeq:"≃",simg:"⪞",simgE:"⪠",siml:"⪝",simlE:"⪟",simne:"≆",simplus:"⨤",simrarr:"⥲",slarr:"←",SmallCircle:"∘",smallsetminus:"",smashp:"⨳",smeparsl:"⧤",smid:"",smile:"⌣",smt:"⪪",smte:"⪬",smtes:"⪬︀",SOFTcy:"Ь",softcy:"ь",sol:"/",solb:"⧄",solbar:"⌿",Sopf:"𝕊",sopf:"𝕤",spades:"♠",spadesuit:"♠",spar:"∥",sqcap:"⊓",sqcaps:"⊓︀",sqcup:"⊔",sqcups:"⊔︀",Sqrt:"√",sqsub:"⊏",sqsube:"⊑",sqsubset:"⊏",sqsubseteq:"⊑",sqsup:"⊐",sqsupe:"⊒",sqsupset:"⊐",sqsupseteq:"⊒",squ:"□",Square:"□",square:"□",SquareIntersection:"⊓",SquareSubset:"⊏",SquareSubsetEqual:"⊑",SquareSuperset:"⊐",SquareSupersetEqual:"⊒",SquareUnion:"⊔",squarf:"▪",squf:"▪",srarr:"→",Sscr:"𝒮",sscr:"𝓈",ssetmn:"",ssmile:"⌣",sstarf:"⋆",Star:"⋆",star:"☆",starf:"★",straightepsilon:"ϵ",straightphi:"ϕ",strns:"¯",Sub:"⋐",sub:"⊂",subdot:"⪽",subE:"⫅",sube:"⊆",subedot:"⫃",submult:"⫁",subnE:"⫋",subne:"⊊",subplus:"⪿",subrarr:"⥹",Subset:"⋐",subset:"⊂",subseteq:"⊆",subseteqq:"⫅",SubsetEqual:"⊆",subsetneq:"⊊",subsetneqq:"⫋",subsim:"⫇",subsub:"⫕",subsup:"⫓",succ:"≻",succapprox:"⪸",succcurlyeq:"≽",Succeeds:"≻",SucceedsEqual:"⪰",SucceedsSlantEqual:"≽",SucceedsTilde:"≿",succeq:"⪰",succnapprox:"⪺",succneqq:"⪶",succnsim:"⋩",succsim:"≿",SuchThat:"∋",Sum:"∑",sum:"∑",sung:"♪",Sup:"⋑",sup:"⊃",sup1:"¹",sup2:"²",sup3:"³",supdot:"⪾",supdsub:"⫘",supE:"⫆",supe:"⊇",supedot:"⫄",Superset:"⊃",SupersetEqual:"⊇",suphsol:"⟉",suphsub:"⫗",suplarr:"⥻",supmult:"⫂",supnE:"⫌",supne:"⊋",supplus:"⫀",Supset:"⋑",supset:"⊃",supseteq:"⊇",supseteqq:"⫆",supsetneq:"⊋",supsetneqq:"⫌",supsim:"⫈",supsub:"⫔",supsup:"⫖",swarhk:"⤦",swArr:"⇙",swarr:"↙",swarrow:"↙",swnwar:"⤪",szlig:"ß",Tab:" ",target:"⌖",Tau:"Τ",tau:"τ",tbrk:"⎴",Tcaron:"Ť",tcaron:"ť",Tcedil:"Ţ",tcedil:"ţ",Tcy:"Т",tcy:"т",tdot:"⃛",telrec:"⌕",Tfr:"𝔗",tfr:"𝔱",there4:"∴",Therefore:"∴",therefore:"∴",Theta:"Θ",theta:"θ",thetasym:"ϑ",thetav:"ϑ",thickapprox:"≈",thicksim:"",ThickSpace:"",thinsp:"",ThinSpace:"",thkap:"≈",thksim:"",THORN:"Þ",thorn:"þ",Tilde:"",tilde:"˜",TildeEqual:"≃",TildeFullEqual:"≅",TildeTilde:"≈",times:"×",timesb:"⊠",timesbar:"⨱",timesd:"⨰",tint:"∭",toea:"⤨",top:"",topbot:"⌶",topcir:"⫱",Topf:"𝕋",topf:"𝕥",topfork:"⫚",tosa:"⤩",tprime:"‴",TRADE:"™",trade:"™",triangle:"▵",triangledown:"▿",triangleleft:"◃",trianglelefteq:"⊴",triangleq:"≜",triangleright:"▹",trianglerighteq:"⊵",tridot:"◬",trie:"≜",triminus:"⨺",TripleDot:"⃛",triplus:"⨹",trisb:"⧍",tritime:"⨻",trpezium:"⏢",Tscr:"𝒯",tscr:"𝓉",TScy:"Ц",tscy:"ц",TSHcy:"Ћ",tshcy:"ћ",Tstrok:"Ŧ",tstrok:"ŧ",twixt:"≬",twoheadleftarrow:"↞",twoheadrightarrow:"↠",Uacute:"Ú",uacute:"ú",Uarr:"↟",uArr:"⇑",uarr:"↑",Uarrocir:"⥉",Ubrcy:"Ў",ubrcy:"ў",Ubreve:"Ŭ",ubreve:"ŭ",Ucirc:"Û",ucirc:"û",Ucy:"У",ucy:"у",udarr:"⇅",Udblac:"Ű",udblac:"ű",udhar:"⥮",ufisht:"⥾",Ufr:"𝔘",ufr:"𝔲",Ugrave:"Ù",ugrave:"ù",uHar:"⥣",uharl:"↿",uharr:"↾",uhblk:"▀",ulcorn:"⌜",ulcorner:"⌜",ulcrop:"⌏",ultri:"◸",Umacr:"Ū",umacr:"ū",uml:"¨",UnderBar:"_",UnderBrace:"⏟",UnderBracket:"⎵",UnderParenthesis:"⏝",Union:"",UnionPlus:"⊎",Uogon:"Ų",uogon:"ų",Uopf:"𝕌",uopf:"𝕦",UpArrow:"↑",Uparrow:"⇑",uparrow:"↑",UpArrowBar:"⤒",UpArrowDownArrow:"⇅",UpDownArrow:"↕",Updownarrow:"⇕",updownarrow:"↕",UpEquilibrium:"⥮",upharpoonleft:"↿",upharpoonright:"↾",uplus:"⊎",UpperLeftArrow:"↖",UpperRightArrow:"↗",Upsi:"ϒ",upsi:"υ",upsih:"ϒ",Upsilon:"Υ",upsilon:"υ",UpTee:"⊥",UpTeeArrow:"↥",upuparrows:"⇈",urcorn:"⌝",urcorner:"⌝",urcrop:"⌎",Uring:"Ů",uring:"ů",urtri:"◹",Uscr:"𝒰",uscr:"𝓊",utdot:"⋰",Utilde:"Ũ",utilde:"ũ",utri:"▵",utrif:"▴",uuarr:"⇈",Uuml:"Ü",uuml:"ü",uwangle:"⦧",vangrt:"⦜",varepsilon:"ϵ",varkappa:"ϰ",varnothing:"∅",varphi:"ϕ",varpi:"ϖ",varpropto:"∝",vArr:"⇕",varr:"↕",varrho:"ϱ",varsigma:"ς",varsubsetneq:"⊊︀",varsubsetneqq:"⫋︀",varsupsetneq:"⊋︀",varsupsetneqq:"⫌︀",vartheta:"ϑ",vartriangleleft:"⊲",vartriangleright:"⊳",Vbar:"⫫",vBar:"⫨",vBarv:"⫩",Vcy:"В",vcy:"в",VDash:"⊫",Vdash:"⊩",vDash:"⊨",vdash:"⊢",Vdashl:"⫦",Vee:"",vee:"",veebar:"⊻",veeeq:"≚",vellip:"⋮",Verbar:"‖",verbar:"|",Vert:"‖",vert:"|",VerticalBar:"",VerticalLine:"|",VerticalSeparator:"❘",VerticalTilde:"≀",VeryThinSpace:"",Vfr:"𝔙",vfr:"𝔳",vltri:"⊲",vnsub:"⊂⃒",vnsup:"⊃⃒",Vopf:"𝕍",vopf:"𝕧",vprop:"∝",vrtri:"⊳",Vscr:"𝒱",vscr:"𝓋",vsubnE:"⫋︀",vsubne:"⊊︀",vsupnE:"⫌︀",vsupne:"⊋︀",Vvdash:"⊪",vzigzag:"⦚",Wcirc:"Ŵ",wcirc:"ŵ",wedbar:"⩟",Wedge:"⋀",wedge:"∧",wedgeq:"≙",weierp:"℘",Wfr:"𝔚",wfr:"𝔴",Wopf:"𝕎",wopf:"𝕨",wp:"℘",wr:"≀",wreath:"≀",Wscr:"𝒲",wscr:"𝓌",xcap:"⋂",xcirc:"◯",xcup:"",xdtri:"▽",Xfr:"𝔛",xfr:"𝔵",xhArr:"⟺",xharr:"⟷",Xi:"Ξ",xi:"ξ",xlArr:"⟸",xlarr:"⟵",xmap:"⟼",xnis:"⋻",xodot:"⨀",Xopf:"𝕏",xopf:"𝕩",xoplus:"⨁",xotime:"⨂",xrArr:"⟹",xrarr:"⟶",Xscr:"𝒳",xscr:"𝓍",xsqcup:"⨆",xuplus:"⨄",xutri:"△",xvee:"",xwedge:"⋀",Yacute:"Ý",yacute:"ý",YAcy:"Я",yacy:"я",Ycirc:"Ŷ",ycirc:"ŷ",Ycy:"Ы",ycy:"ы",yen:"¥",Yfr:"𝔜",yfr:"𝔶",YIcy:"Ї",yicy:"ї",Yopf:"𝕐",yopf:"𝕪",Yscr:"𝒴",yscr:"𝓎",YUcy:"Ю",yucy:"ю",Yuml:"Ÿ",yuml:"ÿ",Zacute:"Ź",zacute:"ź",Zcaron:"Ž",zcaron:"ž",Zcy:"З",zcy:"з",Zdot:"Ż",zdot:"ż",zeetrf:"",ZeroWidthSpace:"",Zeta:"Ζ",zeta:"ζ",Zfr:"",zfr:"𝔷",ZHcy:"Ж",zhcy:"ж",zigrarr:"⇝",Zopf:"",zopf:"𝕫",Zscr:"𝒵",zscr:"𝓏",zwj:"",zwnj:""}),s.entityMap=s.HTML_ENTITIES})(py)),py}var Vf={},hE;function eM(){if(hE)return Vf;hE=1;var s=_m().NAMESPACE,e=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,t=new RegExp("[\\-\\.0-9"+e.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"),i=new RegExp("^"+e.source+t.source+"*(?::"+e.source+t.source+"*)?$"),n=0,r=1,o=2,u=3,c=4,d=5,f=6,m=7;function g(k,R){this.message=k,this.locator=R,Error.captureStackTrace&&Error.captureStackTrace(this,g)}g.prototype=new Error,g.prototype.name=g.name;function v(){}v.prototype={parse:function(k,R,z){var X=this.domBuilder;X.startDocument(),F(R,R={}),b(k,R,z,X,this.errorHandler),X.endDocument()}};function b(k,R,z,X,ee){function le(Fe){if(Fe>65535){Fe-=65536;var Ue=55296+(Fe>>10),Ke=56320+(Fe&1023);return String.fromCharCode(Ue,Ke)}else return String.fromCharCode(Fe)}function oe(Fe){var Ue=Fe.slice(1,-1);return Object.hasOwnProperty.call(z,Ue)?z[Ue]:Ue.charAt(0)==="#"?le(parseInt(Ue.substr(1).replace("x","0x"))):(ee.error("entity not found:"+Fe),Fe)}function Y(Fe){if(Fe>xe){var Ue=k.substring(xe,Fe).replace(/&#?\w+;/g,oe);U&&Z(xe),X.characters(Ue,0,Fe-xe),xe=Fe}}function Z(Fe,Ue){for(;Fe>=ae&&(Ue=ue.exec(k));)Q=Ue.index,ae=Q+Ue[0].length,U.lineNumber++;U.columnNumber=Fe-Q+1}for(var Q=0,ae=0,ue=/.*(?:\r\n?|\n)|.*$/g,U=X.locator,ie=[{currentNSMap:R}],fe={},xe=0;;){try{var Ae=k.indexOf("<",xe);if(Ae<0){if(!k.substr(xe).match(/^\s*$/)){var $e=X.doc,Ee=$e.createTextNode(k.substr(xe));$e.appendChild(Ee),X.currentElement=Ee}return}switch(Ae>xe&&Y(Ae),k.charAt(Ae+1)){case"/":var Be=k.indexOf(">",Ae+3),je=k.substring(Ae+2,Be).replace(/[ \t\n\r]+$/g,""),qe=ie.pop();Be<0?(je=k.substring(Ae+2).replace(/[\s<].*/,""),ee.error("end tag name: "+je+" is not complete:"+qe.tagName),Be=Ae+1+je.length):je.match(/\s</)&&(je=je.replace(/[\s<].*/,""),ee.error("end tag name: "+je+" maybe not complete"),Be=Ae+1+je.length);var et=qe.localNSMap,rt=qe.tagName==je,ht=rt||qe.tagName&&qe.tagName.toLowerCase()==je.toLowerCase();if(ht){if(X.endElement(qe.uri,qe.localName,je),et)for(var qt in et)Object.prototype.hasOwnProperty.call(et,qt)&&X.endPrefixMapping(qt);rt||ee.fatalError("end tag name: "+je+" is not match the current start tagName:"+qe.tagName)}else ie.push(qe);Be++;break;case"?":U&&Z(Ae),Be=G(k,Ae,X);break;case"!":U&&Z(Ae),Be=$(k,Ae,X,ee);break;default:U&&Z(Ae);var xt=new B,Ri=ie[ie.length-1].currentNSMap,Be=E(k,Ae,xt,Ri,oe,ee),Xe=xt.length;if(!xt.closed&&L(k,Be,xt.tagName,fe)&&(xt.closed=!0,z.nbsp||ee.warning("unclosed xml attribute")),U&&Xe){for(var ft=_(U,{}),At=0;At<Xe;At++){var we=xt[At];Z(we.offset),we.locator=_(U,{})}X.locator=ft,w(xt,X,Ri)&&ie.push(xt),X.locator=U}else w(xt,X,Ri)&&ie.push(xt);s.isHTML(xt.uri)&&!xt.closed?Be=I(k,Be,xt.tagName,oe,X):Be++}}catch(Fe){if(Fe instanceof g)throw Fe;ee.error("element parse error: "+Fe),Be=-1}Be>xe?xe=Be:Y(Math.max(Ae,xe)+1)}}function _(k,R){return R.lineNumber=k.lineNumber,R.columnNumber=k.columnNumber,R}function E(k,R,z,X,ee,le){function oe(U,ie,fe){z.attributeNames.hasOwnProperty(U)&&le.fatalError("Attribute "+U+" redefined"),z.addValue(U,ie.replace(/[\t\n\r]/g," ").replace(/&#?\w+;/g,ee),fe)}for(var Y,Z,Q=++R,ae=n;;){var ue=k.charAt(Q);switch(ue){case"=":if(ae===r)Y=k.slice(R,Q),ae=u;else if(ae===o)ae=u;else throw new Error("attribute equal must after attrName");break;case"'":case'"':if(ae===u||ae===r)if(ae===r&&(le.warning('attribute value must after "="'),Y=k.slice(R,Q)),R=Q+1,Q=k.indexOf(ue,R),Q>0)Z=k.slice(R,Q),oe(Y,Z,R-1),ae=d;else throw new Error("attribute value no end '"+ue+"' match");else if(ae==c)Z=k.slice(R,Q),oe(Y,Z,R),le.warning('attribute "'+Y+'" missed start quot('+ue+")!!"),R=Q+1,ae=d;else throw new Error('attribute value must after "="');break;case"/":switch(ae){case n:z.setTagName(k.slice(R,Q));case d:case f:case m:ae=m,z.closed=!0;case c:case r:break;case o:z.closed=!0;break;default:throw new Error("attribute invalid close char('/')")}break;case"":return le.error("unexpected end of input"),ae==n&&z.setTagName(k.slice(R,Q)),Q;case">":switch(ae){case n:z.setTagName(k.slice(R,Q));case d:case f:case m:break;case c:case r:Z=k.slice(R,Q),Z.slice(-1)==="/"&&(z.closed=!0,Z=Z.slice(0,-1));case o:ae===o&&(Z=Y),ae==c?(le.warning('attribute "'+Z+'" missed quot(")!'),oe(Y,Z,R)):((!s.isHTML(X[""])||!Z.match(/^(?:disabled|checked|selected)$/i))&&le.warning('attribute "'+Z+'" missed value!! "'+Z+'" instead!!'),oe(Z,Z,R));break;case u:throw new Error("attribute value missed!!")}return Q;case"€":ue=" ";default:if(ue<=" ")switch(ae){case n:z.setTagName(k.slice(R,Q)),ae=f;break;case r:Y=k.slice(R,Q),ae=o;break;case c:var Z=k.slice(R,Q);le.warning('attribute "'+Z+'" missed quot(")!!'),oe(Y,Z,R);case d:ae=f;break}else switch(ae){case o:z.tagName,(!s.isHTML(X[""])||!Y.match(/^(?:disabled|checked|selected)$/i))&&le.warning('attribute "'+Y+'" missed value!! "'+Y+'" instead2!!'),oe(Y,Y,R),R=Q,ae=r;break;case d:le.warning('attribute space is required"'+Y+'"!!');case f:ae=r,R=Q;break;case u:ae=c,R=Q;break;case m:throw new Error("elements closed character '/' and '>' must be connected to")}}Q++}}function w(k,R,z){for(var X=k.tagName,ee=null,ue=k.length;ue--;){var le=k[ue],oe=le.qName,Y=le.value,U=oe.indexOf(":");if(U>0)var Z=le.prefix=oe.slice(0,U),Q=oe.slice(U+1),ae=Z==="xmlns"&&Q;else Q=oe,Z=null,ae=oe==="xmlns"&&"";le.localName=Q,ae!==!1&&(ee==null&&(ee={},F(z,z={})),z[ae]=ee[ae]=Y,le.uri=s.XMLNS,R.startPrefixMapping(ae,Y))}for(var ue=k.length;ue--;){le=k[ue];var Z=le.prefix;Z&&(Z==="xml"&&(le.uri=s.XML),Z!=="xmlns"&&(le.uri=z[Z||""]))}var U=X.indexOf(":");U>0?(Z=k.prefix=X.slice(0,U),Q=k.localName=X.slice(U+1)):(Z=null,Q=k.localName=X);var ie=k.uri=z[Z||""];if(R.startElement(ie,Q,X,k),k.closed){if(R.endElement(ie,Q,X),ee)for(Z in ee)Object.prototype.hasOwnProperty.call(ee,Z)&&R.endPrefixMapping(Z)}else return k.currentNSMap=z,k.localNSMap=ee,!0}function I(k,R,z,X,ee){if(/^(?:script|textarea)$/i.test(z)){var le=k.indexOf("</"+z+">",R),oe=k.substring(R+1,le);if(/[&<]/.test(oe))return/^script$/i.test(z)?(ee.characters(oe,0,oe.length),le):(oe=oe.replace(/&#?\w+;/g,X),ee.characters(oe,0,oe.length),le)}return R+1}function L(k,R,z,X){var ee=X[z];return ee==null&&(ee=k.lastIndexOf("</"+z+">"),ee<R&&(ee=k.lastIndexOf("</"+z)),X[z]=ee),ee<R}function F(k,R){for(var z in k)Object.prototype.hasOwnProperty.call(k,z)&&(R[z]=k[z])}function $(k,R,z,X){var ee=k.charAt(R+2);switch(ee){case"-":if(k.charAt(R+3)==="-"){var le=k.indexOf("-->",R+4);return le>R?(z.comment(k,R+4,le-R-4),le+3):(X.error("Unclosed comment"),-1)}else return-1;default:if(k.substr(R+3,6)=="CDATA["){var le=k.indexOf("]]>",R+9);return z.startCDATA(),z.characters(k,R+9,le-R-9),z.endCDATA(),le+3}var oe=V(k,R),Y=oe.length;if(Y>1&&/!doctype/i.test(oe[0][0])){var Z=oe[1][0],Q=!1,ae=!1;Y>3&&(/^public$/i.test(oe[2][0])?(Q=oe[3][0],ae=Y>4&&oe[4][0]):/^system$/i.test(oe[2][0])&&(ae=oe[3][0]));var ue=oe[Y-1];return z.startDTD(Z,Q,ae),z.endDTD(),ue.index+ue[0].length}}return-1}function G(k,R,z){var X=k.indexOf("?>",R);if(X){var ee=k.substring(R,X).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);return ee?(ee[0].length,z.processingInstruction(ee[1],ee[2]),X+2):-1}return-1}function B(){this.attributeNames={}}B.prototype={setTagName:function(k){if(!i.test(k))throw new Error("invalid tagName:"+k);this.tagName=k},addValue:function(k,R,z){if(!i.test(k))throw new Error("invalid attribute:"+k);this.attributeNames[k]=this.length,this[this.length++]={qName:k,value:R,offset:z}},length:0,getLocalName:function(k){return this[k].localName},getLocator:function(k){return this[k].locator},getQName:function(k){return this[k].qName},getURI:function(k){return this[k].uri},getValue:function(k){return this[k].value}};function V(k,R){var z,X=[],ee=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;for(ee.lastIndex=R,ee.exec(k);z=ee.exec(k);)if(X.push(z),z[1])return X}return Vf.XMLReader=v,Vf.ParseError=g,Vf}var fE;function tM(){if(fE)return Td;fE=1;var s=_m(),e=NA(),t=JP(),i=eM(),n=e.DOMImplementation,r=s.NAMESPACE,o=i.ParseError,u=i.XMLReader;function c(E){return E.replace(/\r[\n\u0085]/g,`
`).replace(/[\r\u0085\u2028]/g,`
`)}function d(E){this.options=E||{locator:{}}}d.prototype.parseFromString=function(E,w){var I=this.options,L=new u,F=I.domBuilder||new m,$=I.errorHandler,G=I.locator,B=I.xmlns||{},V=/\/x?html?$/.test(w),k=V?t.HTML_ENTITIES:t.XML_ENTITIES;G&&F.setDocumentLocator(G),L.errorHandler=f($,F,G),L.domBuilder=I.domBuilder||F,V&&(B[""]=r.HTML),B.xml=B.xml||r.XML;var R=I.normalizeLineEndings||c;return E&&typeof E=="string"?L.parse(R(E),B,k):L.errorHandler.error("invalid doc source"),F.doc};function f(E,w,I){if(!E){if(w instanceof m)return w;E=w}var L={},F=E instanceof Function;I=I||{};function $(G){var B=E[G];!B&&F&&(B=E.length==2?function(V){E(G,V)}:E),L[G]=B&&function(V){B("[xmldom "+G+"] "+V+v(I))}||function(){}}return $("warning"),$("error"),$("fatalError"),L}function m(){this.cdata=!1}function g(E,w){w.lineNumber=E.lineNumber,w.columnNumber=E.columnNumber}m.prototype={startDocument:function(){this.doc=new n().createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(E,w,I,L){var F=this.doc,$=F.createElementNS(E,I||w),G=L.length;_(this,$),this.currentElement=$,this.locator&&g(this.locator,$);for(var B=0;B<G;B++){var E=L.getURI(B),V=L.getValue(B),I=L.getQName(B),k=F.createAttributeNS(E,I);this.locator&&g(L.getLocator(B),k),k.value=k.nodeValue=V,$.setAttributeNode(k)}},endElement:function(E,w,I){var L=this.currentElement;L.tagName,this.currentElement=L.parentNode},startPrefixMapping:function(E,w){},endPrefixMapping:function(E){},processingInstruction:function(E,w){var I=this.doc.createProcessingInstruction(E,w);this.locator&&g(this.locator,I),_(this,I)},ignorableWhitespace:function(E,w,I){},characters:function(E,w,I){if(E=b.apply(this,arguments),E){if(this.cdata)var L=this.doc.createCDATASection(E);else var L=this.doc.createTextNode(E);this.currentElement?this.currentElement.appendChild(L):/^\s*$/.test(E)&&this.doc.appendChild(L),this.locator&&g(this.locator,L)}},skippedEntity:function(E){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(E){(this.locator=E)&&(E.lineNumber=0)},comment:function(E,w,I){E=b.apply(this,arguments);var L=this.doc.createComment(E);this.locator&&g(this.locator,L),_(this,L)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(E,w,I){var L=this.doc.implementation;if(L&&L.createDocumentType){var F=L.createDocumentType(E,w,I);this.locator&&g(this.locator,F),_(this,F),this.doc.doctype=F}},warning:function(E){console.warn("[xmldom warning] "+E,v(this.locator))},error:function(E){console.error("[xmldom error] "+E,v(this.locator))},fatalError:function(E){throw new o(E,this.locator)}};function v(E){if(E)return`
@`+(E.systemId||"")+"#[line:"+E.lineNumber+",col:"+E.columnNumber+"]"}function b(E,w,I){return typeof E=="string"?E.substr(w,I):E.length>=w+I||w?new java.lang.String(E,w,I)+"":E}"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(E){m.prototype[E]=function(){return null}});function _(E,w){E.currentElement?E.currentElement.appendChild(w):E.doc.appendChild(w)}return Td.__DOMHandler=m,Td.normalizeLineEndings=c,Td.DOMParser=d,Td}var pE;function iM(){if(pE)return vd;pE=1;var s=NA();return vd.DOMImplementation=s.DOMImplementation,vd.XMLSerializer=s.XMLSerializer,vd.DOMParser=tM().DOMParser,vd}var sM=iM();const mE=s=>!!s&&typeof s=="object",ls=(...s)=>s.reduce((e,t)=>(typeof t!="object"||Object.keys(t).forEach(i=>{Array.isArray(e[i])&&Array.isArray(t[i])?e[i]=e[i].concat(t[i]):mE(e[i])&&mE(t[i])?e[i]=ls(e[i],t[i]):e[i]=t[i]}),e),{}),BA=s=>Object.keys(s).map(e=>s[e]),nM=(s,e)=>{const t=[];for(let i=s;i<e;i++)t.push(i);return t},Xu=s=>s.reduce((e,t)=>e.concat(t),[]),FA=s=>{if(!s.length)return[];const e=[];for(let t=0;t<s.length;t++)e.push(s[t]);return e},rM=(s,e)=>s.reduce((t,i,n)=>(i[e]&&t.push(n),t),[]),aM=(s,e)=>BA(s.reduce((t,i)=>(i.forEach(n=>{t[e(n)]=n}),t),{}));var Qu={INVALID_NUMBER_OF_PERIOD:"INVALID_NUMBER_OF_PERIOD",DASH_EMPTY_MANIFEST:"DASH_EMPTY_MANIFEST",DASH_INVALID_XML:"DASH_INVALID_XML",NO_BASE_URL:"NO_BASE_URL",SEGMENT_TIME_UNSPECIFIED:"SEGMENT_TIME_UNSPECIFIED",UNSUPPORTED_UTC_TIMING_SCHEME:"UNSUPPORTED_UTC_TIMING_SCHEME"};const Vd=({baseUrl:s="",source:e="",range:t="",indexRange:i=""})=>{const n={uri:e,resolvedUri:bm(s||"",e)};if(t||i){const o=(t||i).split("-");let u=ne.BigInt?ne.BigInt(o[0]):parseInt(o[0],10),c=ne.BigInt?ne.BigInt(o[1]):parseInt(o[1],10);u<Number.MAX_SAFE_INTEGER&&typeof u=="bigint"&&(u=Number(u)),c<Number.MAX_SAFE_INTEGER&&typeof c=="bigint"&&(c=Number(c));let d;typeof c=="bigint"||typeof u=="bigint"?d=ne.BigInt(c)-ne.BigInt(u)+ne.BigInt(1):d=c-u+1,typeof d=="bigint"&&d<Number.MAX_SAFE_INTEGER&&(d=Number(d)),n.byterange={length:d,offset:u}}return n},oM=s=>{let e;return typeof s.offset=="bigint"||typeof s.length=="bigint"?e=ne.BigInt(s.offset)+ne.BigInt(s.length)-ne.BigInt(1):e=s.offset+s.length-1,`${s.offset}-${e}`},gE=s=>(s&&typeof s!="number"&&(s=parseInt(s,10)),isNaN(s)?null:s),lM={static(s){const{duration:e,timescale:t=1,sourceDuration:i,periodDuration:n}=s,r=gE(s.endNumber),o=e/t;return typeof r=="number"?{start:0,end:r}:typeof n=="number"?{start:0,end:n/o}:{start:0,end:i/o}},dynamic(s){const{NOW:e,clientOffset:t,availabilityStartTime:i,timescale:n=1,duration:r,periodStart:o=0,minimumUpdatePeriod:u=0,timeShiftBufferDepth:c=1/0}=s,d=gE(s.endNumber),f=(e+t)/1e3,m=i+o,v=f+u-m,b=Math.ceil(v*n/r),_=Math.floor((f-m-c)*n/r),E=Math.floor((f-m)*n/r);return{start:Math.max(0,_),end:typeof d=="number"?d:Math.min(b,E)}}},uM=s=>e=>{const{duration:t,timescale:i=1,periodStart:n,startNumber:r=1}=s;return{number:r+e,duration:t/i,timeline:n,time:e*t}},mT=s=>{const{type:e,duration:t,timescale:i=1,periodDuration:n,sourceDuration:r}=s,{start:o,end:u}=lM[e](s),c=nM(o,u).map(uM(s));if(e==="static"){const d=c.length-1,f=typeof n=="number"?n:r;c[d].duration=f-t/i*d}return c},UA=s=>{const{baseUrl:e,initialization:t={},sourceDuration:i,indexRange:n="",periodStart:r,presentationTime:o,number:u=0,duration:c}=s;if(!e)throw new Error(Qu.NO_BASE_URL);const d=Vd({baseUrl:e,source:t.sourceURL,range:t.range}),f=Vd({baseUrl:e,source:e,indexRange:n});if(f.map=d,c){const m=mT(s);m.length&&(f.duration=m[0].duration,f.timeline=m[0].timeline)}else i&&(f.duration=i,f.timeline=r);return f.presentationTime=o||r,f.number=u,[f]},gT=(s,e,t)=>{const i=s.sidx.map?s.sidx.map:null,n=s.sidx.duration,r=s.timeline||0,o=s.sidx.byterange,u=o.offset+o.length,c=e.timescale,d=e.references.filter(E=>E.referenceType!==1),f=[],m=s.endList?"static":"dynamic",g=s.sidx.timeline;let v=g,b=s.mediaSequence||0,_;typeof e.firstOffset=="bigint"?_=ne.BigInt(u)+e.firstOffset:_=u+e.firstOffset;for(let E=0;E<d.length;E++){const w=e.references[E],I=w.referencedSize,L=w.subsegmentDuration;let F;typeof _=="bigint"?F=_+ne.BigInt(I)-ne.BigInt(1):F=_+I-1;const $=`${_}-${F}`,B=UA({baseUrl:t,timescale:c,timeline:r,periodStart:g,presentationTime:v,number:b,duration:L,sourceDuration:n,indexRange:$,type:m})[0];i&&(B.map=i),f.push(B),typeof _=="bigint"?_+=ne.BigInt(I):_+=I,v+=L/c,b++}return s.segments=f,s},cM=["AUDIO","SUBTITLES"],dM=1/60,$A=s=>aM(s,({timeline:e})=>e).sort((e,t)=>e.timeline>t.timeline?1:-1),hM=(s,e)=>{for(let t=0;t<s.length;t++)if(s[t].attributes.NAME===e)return s[t];return null},yE=s=>{let e=[];return ZP(s,cM,(t,i,n,r)=>{e=e.concat(t.playlists||[])}),e},vE=({playlist:s,mediaSequence:e})=>{s.mediaSequence=e,s.segments.forEach((t,i)=>{t.number=s.mediaSequence+i})},fM=({oldPlaylists:s,newPlaylists:e,timelineStarts:t})=>{e.forEach(i=>{i.discontinuitySequence=t.findIndex(function({timeline:c}){return c===i.timeline});const n=hM(s,i.attributes.NAME);if(!n||i.sidx)return;const r=i.segments[0],o=n.segments.findIndex(function(c){return Math.abs(c.presentationTime-r.presentationTime)<dM});if(o===-1){vE({playlist:i,mediaSequence:n.mediaSequence+n.segments.length}),i.segments[0].discontinuity=!0,i.discontinuityStarts.unshift(0),(!n.segments.length&&i.timeline>n.timeline||n.segments.length&&i.timeline>n.segments[n.segments.length-1].timeline)&&i.discontinuitySequence--;return}n.segments[o].discontinuity&&!r.discontinuity&&(r.discontinuity=!0,i.discontinuityStarts.unshift(0),i.discontinuitySequence--),vE({playlist:i,mediaSequence:n.segments[o].number})})},pM=({oldManifest:s,newManifest:e})=>{const t=s.playlists.concat(yE(s)),i=e.playlists.concat(yE(e));return e.timelineStarts=$A([s.timelineStarts,e.timelineStarts]),fM({oldPlaylists:t,newPlaylists:i,timelineStarts:e.timelineStarts}),e},xm=s=>s&&s.uri+"-"+oM(s.byterange),my=s=>{const e=s.reduce(function(i,n){return i[n.attributes.baseUrl]||(i[n.attributes.baseUrl]=[]),i[n.attributes.baseUrl].push(n),i},{});let t=[];return Object.values(e).forEach(i=>{const n=BA(i.reduce((r,o)=>{const u=o.attributes.id+(o.attributes.lang||"");return r[u]?(o.segments&&(o.segments[0]&&(o.segments[0].discontinuity=!0),r[u].segments.push(...o.segments)),o.attributes.contentProtection&&(r[u].attributes.contentProtection=o.attributes.contentProtection)):(r[u]=o,r[u].attributes.timelineStarts=[]),r[u].attributes.timelineStarts.push({start:o.attributes.periodStart,timeline:o.attributes.periodStart}),r},{}));t=t.concat(n)}),t.map(i=>(i.discontinuityStarts=rM(i.segments||[],"discontinuity"),i))},yT=(s,e)=>{const t=xm(s.sidx),i=t&&e[t]&&e[t].sidx;return i&&gT(s,i,s.sidx.resolvedUri),s},mM=(s,e={})=>{if(!Object.keys(e).length)return s;for(const t in s)s[t]=yT(s[t],e);return s},gM=({attributes:s,segments:e,sidx:t,mediaSequence:i,discontinuitySequence:n,discontinuityStarts:r},o)=>{const u={attributes:{NAME:s.id,BANDWIDTH:s.bandwidth,CODECS:s.codecs,"PROGRAM-ID":1},uri:"",endList:s.type==="static",timeline:s.periodStart,resolvedUri:s.baseUrl||"",targetDuration:s.duration,discontinuitySequence:n,discontinuityStarts:r,timelineStarts:s.timelineStarts,mediaSequence:i,segments:e};return s.contentProtection&&(u.contentProtection=s.contentProtection),s.serviceLocation&&(u.attributes.serviceLocation=s.serviceLocation),t&&(u.sidx=t),o&&(u.attributes.AUDIO="audio",u.attributes.SUBTITLES="subs"),u},yM=({attributes:s,segments:e,mediaSequence:t,discontinuityStarts:i,discontinuitySequence:n})=>{typeof e>"u"&&(e=[{uri:s.baseUrl,timeline:s.periodStart,resolvedUri:s.baseUrl||"",duration:s.sourceDuration,number:0}],s.duration=s.sourceDuration);const r={NAME:s.id,BANDWIDTH:s.bandwidth,"PROGRAM-ID":1};s.codecs&&(r.CODECS=s.codecs);const o={attributes:r,uri:"",endList:s.type==="static",timeline:s.periodStart,resolvedUri:s.baseUrl||"",targetDuration:s.duration,timelineStarts:s.timelineStarts,discontinuityStarts:i,discontinuitySequence:n,mediaSequence:t,segments:e};return s.serviceLocation&&(o.attributes.serviceLocation=s.serviceLocation),o},vM=(s,e={},t=!1)=>{let i;const n=s.reduce((r,o)=>{const u=o.attributes.role&&o.attributes.role.value||"",c=o.attributes.lang||"";let d=o.attributes.label||"main";if(c&&!o.attributes.label){const m=u?` (${u})`:"";d=`${o.attributes.lang}${m}`}r[d]||(r[d]={language:c,autoselect:!0,default:u==="main",playlists:[],uri:""});const f=yT(gM(o,t),e);return r[d].playlists.push(f),typeof i>"u"&&u==="main"&&(i=o,i.default=!0),r},{});if(!i){const r=Object.keys(n)[0];n[r].default=!0}return n},TM=(s,e={})=>s.reduce((t,i)=>{const n=i.attributes.label||i.attributes.lang||"text",r=i.attributes.lang||"und";return t[n]||(t[n]={language:r,default:!1,autoselect:!1,playlists:[],uri:""}),t[n].playlists.push(yT(yM(i),e)),t},{}),bM=s=>s.reduce((e,t)=>(t&&t.forEach(i=>{const{channel:n,language:r}=i;e[r]={autoselect:!1,default:!1,instreamId:n,language:r},i.hasOwnProperty("aspectRatio")&&(e[r].aspectRatio=i.aspectRatio),i.hasOwnProperty("easyReader")&&(e[r].easyReader=i.easyReader),i.hasOwnProperty("3D")&&(e[r]["3D"]=i["3D"])}),e),{}),_M=({attributes:s,segments:e,sidx:t,discontinuityStarts:i})=>{const n={attributes:{NAME:s.id,AUDIO:"audio",SUBTITLES:"subs",RESOLUTION:{width:s.width,height:s.height},CODECS:s.codecs,BANDWIDTH:s.bandwidth,"PROGRAM-ID":1},uri:"",endList:s.type==="static",timeline:s.periodStart,resolvedUri:s.baseUrl||"",targetDuration:s.duration,discontinuityStarts:i,timelineStarts:s.timelineStarts,segments:e};return s.frameRate&&(n.attributes["FRAME-RATE"]=s.frameRate),s.contentProtection&&(n.contentProtection=s.contentProtection),s.serviceLocation&&(n.attributes.serviceLocation=s.serviceLocation),t&&(n.sidx=t),n},xM=({attributes:s})=>s.mimeType==="video/mp4"||s.mimeType==="video/webm"||s.contentType==="video",SM=({attributes:s})=>s.mimeType==="audio/mp4"||s.mimeType==="audio/webm"||s.contentType==="audio",EM=({attributes:s})=>s.mimeType==="text/vtt"||s.contentType==="text",AM=(s,e)=>{s.forEach(t=>{t.mediaSequence=0,t.discontinuitySequence=e.findIndex(function({timeline:i}){return i===t.timeline}),t.segments&&t.segments.forEach((i,n)=>{i.number=n})})},TE=s=>s?Object.keys(s).reduce((e,t)=>{const i=s[t];return e.concat(i.playlists)},[]):[],CM=({dashPlaylists:s,locations:e,contentSteering:t,sidxMapping:i={},previousManifest:n,eventStream:r})=>{if(!s.length)return{};const{sourceDuration:o,type:u,suggestedPresentationDelay:c,minimumUpdatePeriod:d}=s[0].attributes,f=my(s.filter(xM)).map(_M),m=my(s.filter(SM)),g=my(s.filter(EM)),v=s.map(F=>F.attributes.captionServices).filter(Boolean),b={allowCache:!0,discontinuityStarts:[],segments:[],endList:!0,mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:"",duration:o,playlists:mM(f,i)};d>=0&&(b.minimumUpdatePeriod=d*1e3),e&&(b.locations=e),t&&(b.contentSteering=t),u==="dynamic"&&(b.suggestedPresentationDelay=c),r&&r.length>0&&(b.eventStream=r);const _=b.playlists.length===0,E=m.length?vM(m,i,_):null,w=g.length?TM(g,i):null,I=f.concat(TE(E),TE(w)),L=I.map(({timelineStarts:F})=>F);return b.timelineStarts=$A(L),AM(I,b.timelineStarts),E&&(b.mediaGroups.AUDIO.audio=E),w&&(b.mediaGroups.SUBTITLES.subs=w),v.length&&(b.mediaGroups["CLOSED-CAPTIONS"].cc=bM(v)),n?pM({oldManifest:n,newManifest:b}):b},DM=(s,e,t)=>{const{NOW:i,clientOffset:n,availabilityStartTime:r,timescale:o=1,periodStart:u=0,minimumUpdatePeriod:c=0}=s,d=(i+n)/1e3,f=r+u,g=d+c-f;return Math.ceil((g*o-e)/t)},jA=(s,e)=>{const{type:t,minimumUpdatePeriod:i=0,media:n="",sourceDuration:r,timescale:o=1,startNumber:u=1,periodStart:c}=s,d=[];let f=-1;for(let m=0;m<e.length;m++){const g=e[m],v=g.d,b=g.r||0,_=g.t||0;f<0&&(f=_),_&&_>f&&(f=_);let E;if(b<0){const L=m+1;L===e.length?t==="dynamic"&&i>0&&n.indexOf("$Number$")>0?E=DM(s,f,v):E=(r*o-f)/v:E=(e[L].t-f)/v}else E=b+1;const w=u+d.length+E;let I=u+d.length;for(;I<w;)d.push({number:I,duration:v/o,time:f,timeline:c}),f+=v,I++}return d},wM=/\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g,LM=s=>(e,t,i,n)=>{if(e==="$$")return"$";if(typeof s[t]>"u")return e;const r=""+s[t];return t==="RepresentationID"||(i?n=parseInt(n,10):n=1,r.length>=n)?r:`${new Array(n-r.length+1).join("0")}${r}`},bE=(s,e)=>s.replace(wM,LM(e)),IM=(s,e)=>!s.duration&&!e?[{number:s.startNumber||1,duration:s.sourceDuration,time:0,timeline:s.periodStart}]:s.duration?mT(s):jA(s,e),kM=(s,e)=>{const t={RepresentationID:s.id,Bandwidth:s.bandwidth||0},{initialization:i={sourceURL:"",range:""}}=s,n=Vd({baseUrl:s.baseUrl,source:bE(i.sourceURL,t),range:i.range});return IM(s,e).map(o=>{t.Number=o.number,t.Time=o.time;const u=bE(s.media||"",t),c=s.timescale||1,d=s.presentationTimeOffset||0,f=s.periodStart+(o.time-d)/c;return{uri:u,timeline:o.timeline,duration:o.duration,resolvedUri:bm(s.baseUrl||"",u),map:n,number:o.number,presentationTime:f}})},RM=(s,e)=>{const{baseUrl:t,initialization:i={}}=s,n=Vd({baseUrl:t,source:i.sourceURL,range:i.range}),r=Vd({baseUrl:t,source:e.media,range:e.mediaRange});return r.map=n,r},OM=(s,e)=>{const{duration:t,segmentUrls:i=[],periodStart:n}=s;if(!t&&!e||t&&e)throw new Error(Qu.SEGMENT_TIME_UNSPECIFIED);const r=i.map(c=>RM(s,c));let o;return t&&(o=mT(s)),e&&(o=jA(s,e)),o.map((c,d)=>{if(r[d]){const f=r[d],m=s.timescale||1,g=s.presentationTimeOffset||0;return f.timeline=c.timeline,f.duration=c.duration,f.number=c.number,f.presentationTime=n+(c.time-g)/m,f}}).filter(c=>c)},PM=({attributes:s,segmentInfo:e})=>{let t,i;e.template?(i=kM,t=ls(s,e.template)):e.base?(i=UA,t=ls(s,e.base)):e.list&&(i=OM,t=ls(s,e.list));const n={attributes:s};if(!i)return n;const r=i(t,e.segmentTimeline);if(t.duration){const{duration:o,timescale:u=1}=t;t.duration=o/u}else r.length?t.duration=r.reduce((o,u)=>Math.max(o,Math.ceil(u.duration)),0):t.duration=0;return n.attributes=t,n.segments=r,e.base&&t.indexRange&&(n.sidx=r[0],n.segments=[]),n},MM=s=>s.map(PM),bi=(s,e)=>FA(s.childNodes).filter(({tagName:t})=>t===e),ah=s=>s.textContent.trim(),NM=s=>parseFloat(s.split("/").reduce((e,t)=>e/t)),bu=s=>{const u=/P(?:(\d*)Y)?(?:(\d*)M)?(?:(\d*)D)?(?:T(?:(\d*)H)?(?:(\d*)M)?(?:([\d.]*)S)?)?/.exec(s);if(!u)return 0;const[c,d,f,m,g,v]=u.slice(1);return parseFloat(c||0)*31536e3+parseFloat(d||0)*2592e3+parseFloat(f||0)*86400+parseFloat(m||0)*3600+parseFloat(g||0)*60+parseFloat(v||0)},BM=s=>(/^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/.test(s)&&(s+="Z"),Date.parse(s)),_E={mediaPresentationDuration(s){return bu(s)},availabilityStartTime(s){return BM(s)/1e3},minimumUpdatePeriod(s){return bu(s)},suggestedPresentationDelay(s){return bu(s)},type(s){return s},timeShiftBufferDepth(s){return bu(s)},start(s){return bu(s)},width(s){return parseInt(s,10)},height(s){return parseInt(s,10)},bandwidth(s){return parseInt(s,10)},frameRate(s){return NM(s)},startNumber(s){return parseInt(s,10)},timescale(s){return parseInt(s,10)},presentationTimeOffset(s){return parseInt(s,10)},duration(s){const e=parseInt(s,10);return isNaN(e)?bu(s):e},d(s){return parseInt(s,10)},t(s){return parseInt(s,10)},r(s){return parseInt(s,10)},presentationTime(s){return parseInt(s,10)},DEFAULT(s){return s}},Yi=s=>s&&s.attributes?FA(s.attributes).reduce((e,t)=>{const i=_E[t.name]||_E.DEFAULT;return e[t.name]=i(t.value),e},{}):{},FM={"urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b":"org.w3.clearkey","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":"com.widevine.alpha","urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":"com.microsoft.playready","urn:uuid:f239e769-efa3-4850-9c16-a903c6932efb":"com.adobe.primetime","urn:mpeg:dash:mp4protection:2011":"mp4protection"},Sm=(s,e)=>e.length?Xu(s.map(function(t){return e.map(function(i){const n=ah(i),r=bm(t.baseUrl,n),o=ls(Yi(i),{baseUrl:r});return r!==n&&!o.serviceLocation&&t.serviceLocation&&(o.serviceLocation=t.serviceLocation),o})})):s,vT=s=>{const e=bi(s,"SegmentTemplate")[0],t=bi(s,"SegmentList")[0],i=t&&bi(t,"SegmentURL").map(m=>ls({tag:"SegmentURL"},Yi(m))),n=bi(s,"SegmentBase")[0],r=t||e,o=r&&bi(r,"SegmentTimeline")[0],u=t||n||e,c=u&&bi(u,"Initialization")[0],d=e&&Yi(e);d&&c?d.initialization=c&&Yi(c):d&&d.initialization&&(d.initialization={sourceURL:d.initialization});const f={template:d,segmentTimeline:o&&bi(o,"S").map(m=>Yi(m)),list:t&&ls(Yi(t),{segmentUrls:i,initialization:Yi(c)}),base:n&&ls(Yi(n),{initialization:Yi(c)})};return Object.keys(f).forEach(m=>{f[m]||delete f[m]}),f},UM=(s,e,t)=>i=>{const n=bi(i,"BaseURL"),r=Sm(e,n),o=ls(s,Yi(i)),u=vT(i);return r.map(c=>({segmentInfo:ls(t,u),attributes:ls(o,c)}))},$M=s=>s.reduce((e,t)=>{const i=Yi(t);i.schemeIdUri&&(i.schemeIdUri=i.schemeIdUri.toLowerCase());const n=FM[i.schemeIdUri];if(n){e[n]={attributes:i};const r=bi(t,"cenc:pssh")[0];if(r){const o=ah(r);e[n].pssh=o&&IA(o)}}return e},{}),jM=s=>{if(s.schemeIdUri==="urn:scte:dash:cc:cea-608:2015")return(typeof s.value!="string"?[]:s.value.split(";")).map(t=>{let i,n;return n=t,/^CC\d=/.test(t)?[i,n]=t.split("="):/^CC\d$/.test(t)&&(i=t),{channel:i,language:n}});if(s.schemeIdUri==="urn:scte:dash:cc:cea-708:2015")return(typeof s.value!="string"?[]:s.value.split(";")).map(t=>{const i={channel:void 0,language:void 0,aspectRatio:1,easyReader:0,"3D":0};if(/=/.test(t)){const[n,r=""]=t.split("=");i.channel=n,i.language=t,r.split(",").forEach(o=>{const[u,c]=o.split(":");u==="lang"?i.language=c:u==="er"?i.easyReader=Number(c):u==="war"?i.aspectRatio=Number(c):u==="3D"&&(i["3D"]=Number(c))})}else i.language=t;return i.channel&&(i.channel="SERVICE"+i.channel),i})},HM=s=>Xu(bi(s.node,"EventStream").map(e=>{const t=Yi(e),i=t.schemeIdUri;return bi(e,"Event").map(n=>{const r=Yi(n),o=r.presentationTime||0,u=t.timescale||1,c=r.duration||0,d=o/u+s.attributes.start;return{schemeIdUri:i,value:t.value,id:r.id,start:d,end:d+c/u,messageData:ah(n)||r.messageData,contentEncoding:t.contentEncoding,presentationTimeOffset:t.presentationTimeOffset||0}})})),GM=(s,e,t)=>i=>{const n=Yi(i),r=Sm(e,bi(i,"BaseURL")),o=bi(i,"Role")[0],u={role:Yi(o)};let c=ls(s,n,u);const d=bi(i,"Accessibility")[0],f=jM(Yi(d));f&&(c=ls(c,{captionServices:f}));const m=bi(i,"Label")[0];if(m&&m.childNodes.length){const E=m.childNodes[0].nodeValue.trim();c=ls(c,{label:E})}const g=$M(bi(i,"ContentProtection"));Object.keys(g).length&&(c=ls(c,{contentProtection:g}));const v=vT(i),b=bi(i,"Representation"),_=ls(t,v);return Xu(b.map(UM(c,r,_)))},VM=(s,e)=>(t,i)=>{const n=Sm(e,bi(t.node,"BaseURL")),r=ls(s,{periodStart:t.attributes.start});typeof t.attributes.duration=="number"&&(r.periodDuration=t.attributes.duration);const o=bi(t.node,"AdaptationSet"),u=vT(t.node);return Xu(o.map(GM(r,n,u)))},qM=(s,e)=>{if(s.length>1&&e({type:"warn",message:"The MPD manifest should contain no more than one ContentSteering tag"}),!s.length)return null;const t=ls({serverURL:ah(s[0])},Yi(s[0]));return t.queryBeforeStart=t.queryBeforeStart==="true",t},zM=({attributes:s,priorPeriodAttributes:e,mpdType:t})=>typeof s.start=="number"?s.start:e&&typeof e.start=="number"&&typeof e.duration=="number"?e.start+e.duration:!e&&t==="static"?0:null,KM=(s,e={})=>{const{manifestUri:t="",NOW:i=Date.now(),clientOffset:n=0,eventHandler:r=function(){}}=e,o=bi(s,"Period");if(!o.length)throw new Error(Qu.INVALID_NUMBER_OF_PERIOD);const u=bi(s,"Location"),c=Yi(s),d=Sm([{baseUrl:t}],bi(s,"BaseURL")),f=bi(s,"ContentSteering");c.type=c.type||"static",c.sourceDuration=c.mediaPresentationDuration||0,c.NOW=i,c.clientOffset=n,u.length&&(c.locations=u.map(ah));const m=[];return o.forEach((g,v)=>{const b=Yi(g),_=m[v-1];b.start=zM({attributes:b,priorPeriodAttributes:_?_.attributes:null,mpdType:c.type}),m.push({node:g,attributes:b})}),{locations:c.locations,contentSteeringInfo:qM(f,r),representationInfo:Xu(m.map(VM(c,d))),eventStream:Xu(m.map(HM))}},HA=s=>{if(s==="")throw new Error(Qu.DASH_EMPTY_MANIFEST);const e=new sM.DOMParser;let t,i;try{t=e.parseFromString(s,"application/xml"),i=t&&t.documentElement.tagName==="MPD"?t.documentElement:null}catch{}if(!i||i&&i.getElementsByTagName("parsererror").length>0)throw new Error(Qu.DASH_INVALID_XML);return i},YM=s=>{const e=bi(s,"UTCTiming")[0];if(!e)return null;const t=Yi(e);switch(t.schemeIdUri){case"urn:mpeg:dash:utc:http-head:2014":case"urn:mpeg:dash:utc:http-head:2012":t.method="HEAD";break;case"urn:mpeg:dash:utc:http-xsdate:2014":case"urn:mpeg:dash:utc:http-iso:2014":case"urn:mpeg:dash:utc:http-xsdate:2012":case"urn:mpeg:dash:utc:http-iso:2012":t.method="GET";break;case"urn:mpeg:dash:utc:direct:2014":case"urn:mpeg:dash:utc:direct:2012":t.method="DIRECT",t.value=Date.parse(t.value);break;default:throw new Error(Qu.UNSUPPORTED_UTC_TIMING_SCHEME)}return t},WM=(s,e={})=>{const t=KM(HA(s),e),i=MM(t.representationInfo);return CM({dashPlaylists:i,locations:t.locations,contentSteering:t.contentSteeringInfo,sidxMapping:e.sidxMapping,previousManifest:e.previousManifest,eventStream:t.eventStream})},XM=s=>YM(HA(s));var gy,xE;function QM(){if(xE)return gy;xE=1;var s=Math.pow(2,32),e=function(t){var i=new DataView(t.buffer,t.byteOffset,t.byteLength),n;return i.getBigUint64?(n=i.getBigUint64(0),n<Number.MAX_SAFE_INTEGER?Number(n):n):i.getUint32(0)*s+i.getUint32(4)};return gy={getUint64:e,MAX_UINT32:s},gy}var yy,SE;function ZM(){if(SE)return yy;SE=1;var s=QM().getUint64,e=function(t){var i=new DataView(t.buffer,t.byteOffset,t.byteLength),n={version:t[0],flags:new Uint8Array(t.subarray(1,4)),references:[],referenceId:i.getUint32(4),timescale:i.getUint32(8)},r=12;n.version===0?(n.earliestPresentationTime=i.getUint32(r),n.firstOffset=i.getUint32(r+4),r+=8):(n.earliestPresentationTime=s(t.subarray(r)),n.firstOffset=s(t.subarray(r+8)),r+=16),r+=2;var o=i.getUint16(r);for(r+=2;o>0;r+=12,o--)n.references.push({referenceType:(t[r]&128)>>>7,referencedSize:i.getUint32(r)&2147483647,subsegmentDuration:i.getUint32(r+4),startsWithSap:!!(t[r+8]&128),sapType:(t[r+8]&112)>>>4,sapDeltaTime:i.getUint32(r+8)&268435455});return n};return yy=e,yy}var JM=ZM();const eN=ac(JM);var tN=lt([73,68,51]),iN=function(e,t){t===void 0&&(t=0),e=lt(e);var i=e[t+5],n=e[t+6]<<21|e[t+7]<<14|e[t+8]<<7|e[t+9],r=(i&16)>>4;return r?n+20:n+10},Dd=function s(e,t){return t===void 0&&(t=0),e=lt(e),e.length-t<10||!Ti(e,tN,{offset:t})?t:(t+=iN(e,t),s(e,t))},EE=function(e){return typeof e=="string"?MA(e):e},sN=function(e){return Array.isArray(e)?e.map(function(t){return EE(t)}):[EE(e)]},nN=function s(e,t,i){i===void 0&&(i=!1),t=sN(t),e=lt(e);var n=[];if(!t.length)return n;for(var r=0;r<e.length;){var o=(e[r]<<24|e[r+1]<<16|e[r+2]<<8|e[r+3])>>>0,u=e.subarray(r+4,r+8);if(o===0)break;var c=r+o;if(c>e.length){if(i)break;c=e.length}var d=e.subarray(r+8,c);Ti(u,t[0])&&(t.length===1?n.push(d):n.push.apply(n,s(d,t.slice(1),i))),r=c}return n},qf={EBML:lt([26,69,223,163]),DocType:lt([66,130]),Segment:lt([24,83,128,103]),SegmentInfo:lt([21,73,169,102]),Tracks:lt([22,84,174,107]),Track:lt([174]),TrackNumber:lt([215]),DefaultDuration:lt([35,227,131]),TrackEntry:lt([174]),TrackType:lt([131]),FlagDefault:lt([136]),CodecID:lt([134]),CodecPrivate:lt([99,162]),VideoTrack:lt([224]),AudioTrack:lt([225]),Cluster:lt([31,67,182,117]),Timestamp:lt([231]),TimestampScale:lt([42,215,177]),BlockGroup:lt([160]),BlockDuration:lt([155]),Block:lt([161]),SimpleBlock:lt([163])},gv=[128,64,32,16,8,4,2,1],rN=function(e){for(var t=1,i=0;i<gv.length&&!(e&gv[i]);i++)t++;return t},kp=function(e,t,i,n){i===void 0&&(i=!0),n===void 0&&(n=!1);var r=rN(e[t]),o=e.subarray(t,t+r);return i&&(o=Array.prototype.slice.call(e,t,t+r),o[0]^=gv[r-1]),{length:r,value:WP(o,{signed:n}),bytes:o}},AE=function s(e){return typeof e=="string"?e.match(/.{1,2}/g).map(function(t){return s(t)}):typeof e=="number"?XP(e):e},aN=function(e){return Array.isArray(e)?e.map(function(t){return AE(t)}):[AE(e)]},oN=function s(e,t,i){if(i>=t.length)return t.length;var n=kp(t,i,!1);if(Ti(e.bytes,n.bytes))return i;var r=kp(t,i+n.length);return s(e,t,i+r.length+r.value+n.length)},CE=function s(e,t){t=aN(t),e=lt(e);var i=[];if(!t.length)return i;for(var n=0;n<e.length;){var r=kp(e,n,!1),o=kp(e,n+r.length),u=n+r.length+o.length;o.value===127&&(o.value=oN(r,e,u),o.value!==e.length&&(o.value-=u));var c=u+o.value>e.length?e.length:u+o.value,d=e.subarray(u,c);Ti(t[0],r.bytes)&&(t.length===1?i.push(d):i=i.concat(s(d,t.slice(1))));var f=r.length+o.length+d.length;n+=f}return i},lN=lt([0,0,0,1]),uN=lt([0,0,1]),cN=lt([0,0,3]),dN=function(e){for(var t=[],i=1;i<e.length-2;)Ti(e.subarray(i,i+3),cN)&&(t.push(i+2),i++),i++;if(t.length===0)return e;var n=e.length-t.length,r=new Uint8Array(n),o=0;for(i=0;i<n;o++,i++)o===t[0]&&(o++,t.shift()),r[i]=e[o];return r},GA=function(e,t,i,n){e=lt(e),i=[].concat(i);for(var r=0,o,u=0;r<e.length&&(u<n||o);){var c=void 0;if(Ti(e.subarray(r),lN)?c=4:Ti(e.subarray(r),uN)&&(c=3),!c){r++;continue}if(u++,o)return dN(e.subarray(o,r));var d=void 0;t==="h264"?d=e[r+c]&31:t==="h265"&&(d=e[r+c]>>1&63),i.indexOf(d)!==-1&&(o=r+c),r+=c+(t==="h264"?1:2)}return e.subarray(0,0)},hN=function(e,t,i){return GA(e,"h264",t,i)},fN=function(e,t,i){return GA(e,"h265",t,i)},Ps={webm:lt([119,101,98,109]),matroska:lt([109,97,116,114,111,115,107,97]),flac:lt([102,76,97,67]),ogg:lt([79,103,103,83]),ac3:lt([11,119]),riff:lt([82,73,70,70]),avi:lt([65,86,73]),wav:lt([87,65,86,69]),"3gp":lt([102,116,121,112,51,103]),mp4:lt([102,116,121,112]),fmp4:lt([115,116,121,112]),mov:lt([102,116,121,112,113,116]),moov:lt([109,111,111,118]),moof:lt([109,111,111,102])},Zu={aac:function(e){var t=Dd(e);return Ti(e,[255,16],{offset:t,mask:[255,22]})},mp3:function(e){var t=Dd(e);return Ti(e,[255,2],{offset:t,mask:[255,6]})},webm:function(e){var t=CE(e,[qf.EBML,qf.DocType])[0];return Ti(t,Ps.webm)},mkv:function(e){var t=CE(e,[qf.EBML,qf.DocType])[0];return Ti(t,Ps.matroska)},mp4:function(e){if(Zu["3gp"](e)||Zu.mov(e))return!1;if(Ti(e,Ps.mp4,{offset:4})||Ti(e,Ps.fmp4,{offset:4})||Ti(e,Ps.moof,{offset:4})||Ti(e,Ps.moov,{offset:4}))return!0},mov:function(e){return Ti(e,Ps.mov,{offset:4})},"3gp":function(e){return Ti(e,Ps["3gp"],{offset:4})},ac3:function(e){var t=Dd(e);return Ti(e,Ps.ac3,{offset:t})},ts:function(e){if(e.length<189&&e.length>=1)return e[0]===71;for(var t=0;t+188<e.length&&t<188;){if(e[t]===71&&e[t+188]===71)return!0;t+=1}return!1},flac:function(e){var t=Dd(e);return Ti(e,Ps.flac,{offset:t})},ogg:function(e){return Ti(e,Ps.ogg)},avi:function(e){return Ti(e,Ps.riff)&&Ti(e,Ps.avi,{offset:8})},wav:function(e){return Ti(e,Ps.riff)&&Ti(e,Ps.wav,{offset:8})},h264:function(e){return hN(e,7,3).length},h265:function(e){return fN(e,[32,33],3).length}},yv=Object.keys(Zu).filter(function(s){return s!=="ts"&&s!=="h264"&&s!=="h265"}).concat(["ts","h264","h265"]);yv.forEach(function(s){var e=Zu[s];Zu[s]=function(t){return e(lt(t))}});var pN=Zu,TT=function(e){e=lt(e);for(var t=0;t<yv.length;t++){var i=yv[t];if(pN[i](e))return i}return""},mN=function(e){return nN(e,["moof"]).length>0},vy,DE;function gN(){if(DE)return vy;DE=1;var s=9e4,e,t,i,n,r,o,u;return e=function(c){return c*s},t=function(c,d){return c*d},i=function(c){return c/s},n=function(c,d){return c/d},r=function(c,d){return e(n(c,d))},o=function(c,d){return t(i(c),d)},u=function(c,d,f){return i(f?c:c-d)},vy={ONE_SECOND_IN_TS:s,secondsToVideoTs:e,secondsToAudioTs:t,videoTsToSeconds:i,audioTsToSeconds:n,audioTsToVideoTs:r,videoTsToAudioTs:o,metadataTsToSeconds:u},vy}var ml=gN();var vv="8.23.4";const ma={},xo=function(s,e){return ma[s]=ma[s]||[],e&&(ma[s]=ma[s].concat(e)),ma[s]},yN=function(s,e){xo(s,e)},VA=function(s,e){const t=xo(s).indexOf(e);return t<=-1?!1:(ma[s]=ma[s].slice(),ma[s].splice(t,1),!0)},vN=function(s,e){xo(s,[].concat(e).map(t=>{const i=(...n)=>(VA(s,i),t(...n));return i}))},Rp={prefixed:!0},gp=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror","fullscreen"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror","-webkit-full-screen"]],wE=gp[0];let wd;for(let s=0;s<gp.length;s++)if(gp[s][1]in Ve){wd=gp[s];break}if(wd){for(let s=0;s<wd.length;s++)Rp[wE[s]]=wd[s];Rp.prefixed=wd[0]!==wE[0]}let Zs=[];const TN=(s,e,t)=>(i,n,r)=>{const o=e.levels[n],u=new RegExp(`^(${o})$`);let c=s;if(i!=="log"&&r.unshift(i.toUpperCase()+":"),t&&(c=`%c${s}`,r.unshift(t)),r.unshift(c+":"),Zs){Zs.push([].concat(r));const f=Zs.length-1e3;Zs.splice(0,f>0?f:0)}if(!ne.console)return;let d=ne.console[i];!d&&i==="debug"&&(d=ne.console.info||ne.console.log),!(!d||!o||!u.test(i))&&d[Array.isArray(r)?"apply":"call"](ne.console,r)};function Tv(s,e=":",t=""){let i="info",n;function r(...o){n("log",i,o)}return n=TN(s,r,t),r.createLogger=(o,u,c)=>{const d=u!==void 0?u:e,f=c!==void 0?c:t,m=`${s} ${d} ${o}`;return Tv(m,d,f)},r.createNewLogger=(o,u,c)=>Tv(o,u,c),r.levels={all:"debug|log|warn|error",off:"",debug:"debug|log|warn|error",info:"log|warn|error",warn:"warn|error",error:"error",DEFAULT:i},r.level=o=>{if(typeof o=="string"){if(!r.levels.hasOwnProperty(o))throw new Error(`"${o}" in not a valid log level`);i=o}return i},r.history=()=>Zs?[].concat(Zs):[],r.history.filter=o=>(Zs||[]).filter(u=>new RegExp(`.*${o}.*`).test(u[0])),r.history.clear=()=>{Zs&&(Zs.length=0)},r.history.disable=()=>{Zs!==null&&(Zs.length=0,Zs=null)},r.history.enable=()=>{Zs===null&&(Zs=[])},r.error=(...o)=>n("error",i,o),r.warn=(...o)=>n("warn",i,o),r.debug=(...o)=>n("debug",i,o),r}const Dt=Tv("VIDEOJS"),qA=Dt.createLogger,bN=Object.prototype.toString,zA=function(s){return Mr(s)?Object.keys(s):[]};function Nu(s,e){zA(s).forEach(t=>e(s[t],t))}function KA(s,e,t=0){return zA(s).reduce((i,n)=>e(i,s[n],n),t)}function Mr(s){return!!s&&typeof s=="object"}function Ju(s){return Mr(s)&&bN.call(s)==="[object Object]"&&s.constructor===Object}function si(...s){const e={};return s.forEach(t=>{t&&Nu(t,(i,n)=>{if(!Ju(i)){e[n]=i;return}Ju(e[n])||(e[n]={}),e[n]=si(e[n],i)})}),e}function YA(s={}){const e=[];for(const t in s)if(s.hasOwnProperty(t)){const i=s[t];e.push(i)}return e}function Em(s,e,t,i=!0){const n=o=>Object.defineProperty(s,e,{value:o,enumerable:!0,writable:!0}),r={configurable:!0,enumerable:!0,get(){const o=t();return n(o),o}};return i&&(r.set=n),Object.defineProperty(s,e,r)}var _N=Object.freeze({__proto__:null,each:Nu,reduce:KA,isObject:Mr,isPlain:Ju,merge:si,values:YA,defineLazyProperty:Em});let bT=!1,WA=null,ir=!1,XA,QA=!1,Bu=!1,Fu=!1,Nr=!1,_T=null,Am=null;const xN=!!(ne.cast&&ne.cast.framework&&ne.cast.framework.CastReceiverContext);let ZA=null,Op=!1,Cm=!1,Pp=!1,Dm=!1,Mp=!1,Np=!1,Bp=!1;const qd=!!(oc()&&("ontouchstart"in ne||ne.navigator.maxTouchPoints||ne.DocumentTouch&&ne.document instanceof ne.DocumentTouch)),oo=ne.navigator&&ne.navigator.userAgentData;oo&&oo.platform&&oo.brands&&(ir=oo.platform==="Android",Bu=!!oo.brands.find(s=>s.brand==="Microsoft Edge"),Fu=!!oo.brands.find(s=>s.brand==="Chromium"),Nr=!Bu&&Fu,_T=Am=(oo.brands.find(s=>s.brand==="Chromium")||{}).version||null,Cm=oo.platform==="Windows");if(!Fu){const s=ne.navigator&&ne.navigator.userAgent||"";bT=/iPod/i.test(s),WA=(function(){const e=s.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null})(),ir=/Android/i.test(s),XA=(function(){const e=s.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;const t=e[1]&&parseFloat(e[1]),i=e[2]&&parseFloat(e[2]);return t&&i?parseFloat(e[1]+"."+e[2]):t||null})(),QA=/Firefox/i.test(s),Bu=/Edg/i.test(s),Fu=/Chrome/i.test(s)||/CriOS/i.test(s),Nr=!Bu&&Fu,_T=Am=(function(){const e=s.match(/(Chrome|CriOS)\/(\d+)/);return e&&e[2]?parseFloat(e[2]):null})(),ZA=(function(){const e=/MSIE\s(\d+)\.\d/.exec(s);let t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(s)&&/rv:11.0/.test(s)&&(t=11),t})(),Mp=/Tizen/i.test(s),Np=/Web0S/i.test(s),Bp=Mp||Np,Op=/Safari/i.test(s)&&!Nr&&!ir&&!Bu&&!Bp,Cm=/Windows/i.test(s),Pp=/iPad/i.test(s)||Op&&qd&&!/iPhone/i.test(s),Dm=/iPhone/i.test(s)&&!Pp}const As=Dm||Pp||bT,wm=(Op||As)&&!Nr;var JA=Object.freeze({__proto__:null,get IS_IPOD(){return bT},get IOS_VERSION(){return WA},get IS_ANDROID(){return ir},get ANDROID_VERSION(){return XA},get IS_FIREFOX(){return QA},get IS_EDGE(){return Bu},get IS_CHROMIUM(){return Fu},get IS_CHROME(){return Nr},get CHROMIUM_VERSION(){return _T},get CHROME_VERSION(){return Am},IS_CHROMECAST_RECEIVER:xN,get IE_VERSION(){return ZA},get IS_SAFARI(){return Op},get IS_WINDOWS(){return Cm},get IS_IPAD(){return Pp},get IS_IPHONE(){return Dm},get IS_TIZEN(){return Mp},get IS_WEBOS(){return Np},get IS_SMART_TV(){return Bp},TOUCH_ENABLED:qd,IS_IOS:As,IS_ANY_SAFARI:wm});function LE(s){return typeof s=="string"&&!!s.trim()}function SN(s){if(s.indexOf(" ")>=0)throw new Error("class has illegal whitespace characters")}function oc(){return Ve===ne.document}function lc(s){return Mr(s)&&s.nodeType===1}function eC(){try{return ne.parent!==ne.self}catch{return!0}}function tC(s){return function(e,t){if(!LE(e))return Ve[s](null);LE(t)&&(t=Ve.querySelector(t));const i=lc(t)?t:Ve;return i[s]&&i[s](e)}}function dt(s="div",e={},t={},i){const n=Ve.createElement(s);return Object.getOwnPropertyNames(e).forEach(function(r){const o=e[r];r==="textContent"?Co(n,o):(n[r]!==o||r==="tabIndex")&&(n[r]=o)}),Object.getOwnPropertyNames(t).forEach(function(r){n.setAttribute(r,t[r])}),i&&xT(n,i),n}function Co(s,e){return typeof s.textContent>"u"?s.innerText=e:s.textContent=e,s}function bv(s,e){e.firstChild?e.insertBefore(s,e.firstChild):e.appendChild(s)}function Nd(s,e){return SN(e),s.classList.contains(e)}function vl(s,...e){return s.classList.add(...e.reduce((t,i)=>t.concat(i.split(/\s+/)),[])),s}function Lm(s,...e){return s?(s.classList.remove(...e.reduce((t,i)=>t.concat(i.split(/\s+/)),[])),s):(Dt.warn("removeClass was called with an element that doesn't exist"),null)}function iC(s,e,t){return typeof t=="function"&&(t=t(s,e)),typeof t!="boolean"&&(t=void 0),e.split(/\s+/).forEach(i=>s.classList.toggle(i,t)),s}function sC(s,e){Object.getOwnPropertyNames(e).forEach(function(t){const i=e[t];i===null||typeof i>"u"||i===!1?s.removeAttribute(t):s.setAttribute(t,i===!0?"":i)})}function fo(s){const e={},t=["autoplay","controls","playsinline","loop","muted","default","defaultMuted"];if(s&&s.attributes&&s.attributes.length>0){const i=s.attributes;for(let n=i.length-1;n>=0;n--){const r=i[n].name;let o=i[n].value;t.includes(r)&&(o=o!==null),e[r]=o}}return e}function nC(s,e){return s.getAttribute(e)}function ec(s,e,t){s.setAttribute(e,t)}function Im(s,e){s.removeAttribute(e)}function rC(){Ve.body.focus(),Ve.onselectstart=function(){return!1}}function aC(){Ve.onselectstart=function(){return!0}}function tc(s){if(s&&s.getBoundingClientRect&&s.parentNode){const e=s.getBoundingClientRect(),t={};return["bottom","height","left","right","top","width"].forEach(i=>{e[i]!==void 0&&(t[i]=e[i])}),t.height||(t.height=parseFloat(ic(s,"height"))),t.width||(t.width=parseFloat(ic(s,"width"))),t}}function zd(s){if(!s||s&&!s.offsetParent)return{left:0,top:0,width:0,height:0};const e=s.offsetWidth,t=s.offsetHeight;let i=0,n=0;for(;s.offsetParent&&s!==Ve[Rp.fullscreenElement];)i+=s.offsetLeft,n+=s.offsetTop,s=s.offsetParent;return{left:i,top:n,width:e,height:t}}function km(s,e){const t={x:0,y:0};if(As){let f=s;for(;f&&f.nodeName.toLowerCase()!=="html";){const m=ic(f,"transform");if(/^matrix/.test(m)){const g=m.slice(7,-1).split(/,\s/).map(Number);t.x+=g[4],t.y+=g[5]}else if(/^matrix3d/.test(m)){const g=m.slice(9,-1).split(/,\s/).map(Number);t.x+=g[12],t.y+=g[13]}if(f.assignedSlot&&f.assignedSlot.parentElement&&ne.WebKitCSSMatrix){const g=ne.getComputedStyle(f.assignedSlot.parentElement).transform,v=new ne.WebKitCSSMatrix(g);t.x+=v.m41,t.y+=v.m42}f=f.parentNode||f.host}}const i={},n=zd(e.target),r=zd(s),o=r.width,u=r.height;let c=e.offsetY-(r.top-n.top),d=e.offsetX-(r.left-n.left);return e.changedTouches&&(d=e.changedTouches[0].pageX-r.left,c=e.changedTouches[0].pageY+r.top,As&&(d-=t.x,c-=t.y)),i.y=1-Math.max(0,Math.min(1,c/u)),i.x=Math.max(0,Math.min(1,d/o)),i}function oC(s){return Mr(s)&&s.nodeType===3}function Rm(s){for(;s.firstChild;)s.removeChild(s.firstChild);return s}function lC(s){return typeof s=="function"&&(s=s()),(Array.isArray(s)?s:[s]).map(e=>{if(typeof e=="function"&&(e=e()),lc(e)||oC(e))return e;if(typeof e=="string"&&/\S/.test(e))return Ve.createTextNode(e)}).filter(e=>e)}function xT(s,e){return lC(e).forEach(t=>s.appendChild(t)),s}function uC(s,e){return xT(Rm(s),e)}function Kd(s){return s.button===void 0&&s.buttons===void 0||s.button===0&&s.buttons===void 0||s.type==="mouseup"&&s.button===0&&s.buttons===0||s.type==="mousedown"&&s.button===0&&s.buttons===0?!0:!(s.button!==0||s.buttons!==1)}const So=tC("querySelector"),cC=tC("querySelectorAll");function ic(s,e){if(!s||!e)return"";if(typeof ne.getComputedStyle=="function"){let t;try{t=ne.getComputedStyle(s)}catch{return""}return t?t.getPropertyValue(e)||t[e]:""}return""}function dC(s){[...Ve.styleSheets].forEach(e=>{try{const t=[...e.cssRules].map(n=>n.cssText).join(""),i=Ve.createElement("style");i.textContent=t,s.document.head.appendChild(i)}catch{const i=Ve.createElement("link");i.rel="stylesheet",i.type=e.type,i.media=e.media.mediaText,i.href=e.href,s.document.head.appendChild(i)}})}var hC=Object.freeze({__proto__:null,isReal:oc,isEl:lc,isInFrame:eC,createEl:dt,textContent:Co,prependTo:bv,hasClass:Nd,addClass:vl,removeClass:Lm,toggleClass:iC,setAttributes:sC,getAttributes:fo,getAttribute:nC,setAttribute:ec,removeAttribute:Im,blockTextSelection:rC,unblockTextSelection:aC,getBoundingClientRect:tc,findPosition:zd,getPointerPosition:km,isTextNode:oC,emptyEl:Rm,normalizeContent:lC,appendContent:xT,insertContent:uC,isSingleLeftClick:Kd,$:So,$$:cC,computedStyle:ic,copyStyleSheetsToWindow:dC});let fC=!1,_v;const EN=function(){if(_v.options.autoSetup===!1)return;const s=Array.prototype.slice.call(Ve.getElementsByTagName("video")),e=Array.prototype.slice.call(Ve.getElementsByTagName("audio")),t=Array.prototype.slice.call(Ve.getElementsByTagName("video-js")),i=s.concat(e,t);if(i&&i.length>0)for(let n=0,r=i.length;n<r;n++){const o=i[n];if(o&&o.getAttribute)o.player===void 0&&o.getAttribute("data-setup")!==null&&_v(o);else{xv(1);break}}else fC||xv(1)};function xv(s,e){oc()&&(e&&(_v=e),ne.setTimeout(EN,s))}function Sv(){fC=!0,ne.removeEventListener("load",Sv)}oc()&&(Ve.readyState==="complete"?Sv():ne.addEventListener("load",Sv));const pC=function(s){const e=Ve.createElement("style");return e.className=s,e},mC=function(s,e){s.styleSheet?s.styleSheet.cssText=e:s.textContent=e};var Bs=new WeakMap;const AN=3;let CN=AN;function Nn(){return CN++}function IE(s,e){if(!Bs.has(s))return;const t=Bs.get(s);t.handlers[e].length===0&&(delete t.handlers[e],s.removeEventListener?s.removeEventListener(e,t.dispatcher,!1):s.detachEvent&&s.detachEvent("on"+e,t.dispatcher)),Object.getOwnPropertyNames(t.handlers).length<=0&&(delete t.handlers,delete t.dispatcher,delete t.disabled),Object.getOwnPropertyNames(t).length===0&&Bs.delete(s)}function ST(s,e,t,i){t.forEach(function(n){s(e,n,i)})}function Om(s){if(s.fixed_)return s;function e(){return!0}function t(){return!1}if(!s||!s.isPropagationStopped||!s.isImmediatePropagationStopped){const i=s||ne.event;s={};const n=["layerX","layerY","keyLocation","path","webkitMovementX","webkitMovementY","mozPressure","mozInputSource"];for(const r in i)n.includes(r)||r==="returnValue"&&i.preventDefault||(s[r]=i[r]);if(s.target||(s.target=s.srcElement||Ve),s.relatedTarget||(s.relatedTarget=s.fromElement===s.target?s.toElement:s.fromElement),s.preventDefault=function(){i.preventDefault&&i.preventDefault(),s.returnValue=!1,i.returnValue=!1,s.defaultPrevented=!0},s.defaultPrevented=!1,s.stopPropagation=function(){i.stopPropagation&&i.stopPropagation(),s.cancelBubble=!0,i.cancelBubble=!0,s.isPropagationStopped=e},s.isPropagationStopped=t,s.stopImmediatePropagation=function(){i.stopImmediatePropagation&&i.stopImmediatePropagation(),s.isImmediatePropagationStopped=e,s.stopPropagation()},s.isImmediatePropagationStopped=t,s.clientX!==null&&s.clientX!==void 0){const r=Ve.documentElement,o=Ve.body;s.pageX=s.clientX+(r&&r.scrollLeft||o&&o.scrollLeft||0)-(r&&r.clientLeft||o&&o.clientLeft||0),s.pageY=s.clientY+(r&&r.scrollTop||o&&o.scrollTop||0)-(r&&r.clientTop||o&&o.clientTop||0)}s.which=s.charCode||s.keyCode,s.button!==null&&s.button!==void 0&&(s.button=s.button&1?0:s.button&4?1:s.button&2?2:0)}return s.fixed_=!0,s}let zf;const DN=function(){if(typeof zf!="boolean"){zf=!1;try{const s=Object.defineProperty({},"passive",{get(){zf=!0}});ne.addEventListener("test",null,s),ne.removeEventListener("test",null,s)}catch{}}return zf},wN=["touchstart","touchmove"];function Sn(s,e,t){if(Array.isArray(e))return ST(Sn,s,e,t);Bs.has(s)||Bs.set(s,{});const i=Bs.get(s);if(i.handlers||(i.handlers={}),i.handlers[e]||(i.handlers[e]=[]),t.guid||(t.guid=Nn()),i.handlers[e].push(t),i.dispatcher||(i.disabled=!1,i.dispatcher=function(n,r){if(i.disabled)return;n=Om(n);const o=i.handlers[n.type];if(o){const u=o.slice(0);for(let c=0,d=u.length;c<d&&!n.isImmediatePropagationStopped();c++)try{u[c].call(s,n,r)}catch(f){Dt.error(f)}}}),i.handlers[e].length===1)if(s.addEventListener){let n=!1;DN()&&wN.indexOf(e)>-1&&(n={passive:!0}),s.addEventListener(e,i.dispatcher,n)}else s.attachEvent&&s.attachEvent("on"+e,i.dispatcher)}function Cs(s,e,t){if(!Bs.has(s))return;const i=Bs.get(s);if(!i.handlers)return;if(Array.isArray(e))return ST(Cs,s,e,t);const n=function(o,u){i.handlers[u]=[],IE(o,u)};if(e===void 0){for(const o in i.handlers)Object.prototype.hasOwnProperty.call(i.handlers||{},o)&&n(s,o);return}const r=i.handlers[e];if(r){if(!t){n(s,e);return}if(t.guid)for(let o=0;o<r.length;o++)r[o].guid===t.guid&&r.splice(o--,1);IE(s,e)}}function uc(s,e,t){const i=Bs.has(s)?Bs.get(s):{},n=s.parentNode||s.ownerDocument;if(typeof e=="string"?e={type:e,target:s}:e.target||(e.target=s),e=Om(e),i.dispatcher&&i.dispatcher.call(s,e,t),n&&!e.isPropagationStopped()&&e.bubbles===!0)uc.call(null,n,e,t);else if(!n&&!e.defaultPrevented&&e.target&&e.target[e.type]){Bs.has(e.target)||Bs.set(e.target,{});const r=Bs.get(e.target);e.target[e.type]&&(r.disabled=!0,typeof e.target[e.type]=="function"&&e.target[e.type](),r.disabled=!1)}return!e.defaultPrevented}function Pm(s,e,t){if(Array.isArray(e))return ST(Pm,s,e,t);const i=function(){Cs(s,e,i),t.apply(this,arguments)};i.guid=t.guid=t.guid||Nn(),Sn(s,e,i)}function ET(s,e,t){const i=function(){Cs(s,e,i),t.apply(this,arguments)};i.guid=t.guid=t.guid||Nn(),Sn(s,e,i)}var LN=Object.freeze({__proto__:null,fixEvent:Om,on:Sn,off:Cs,trigger:uc,one:Pm,any:ET});const Bn=30,hi=function(s,e,t){e.guid||(e.guid=Nn());const i=e.bind(s);return i.guid=t?t+"_"+e.guid:e.guid,i},Br=function(s,e){let t=ne.performance.now();return function(...n){const r=ne.performance.now();r-t>=e&&(s(...n),t=r)}},gC=function(s,e,t,i=ne){let n;const r=()=>{i.clearTimeout(n),n=null},o=function(){const u=this,c=arguments;let d=function(){n=null,d=null,t||s.apply(u,c)};!n&&t&&s.apply(u,c),i.clearTimeout(n),n=i.setTimeout(d,e)};return o.cancel=r,o};var IN=Object.freeze({__proto__:null,UPDATE_REFRESH_INTERVAL:Bn,bind_:hi,throttle:Br,debounce:gC});let bd;class En{on(e,t){const i=this.addEventListener;this.addEventListener=()=>{},Sn(this,e,t),this.addEventListener=i}off(e,t){Cs(this,e,t)}one(e,t){const i=this.addEventListener;this.addEventListener=()=>{},Pm(this,e,t),this.addEventListener=i}any(e,t){const i=this.addEventListener;this.addEventListener=()=>{},ET(this,e,t),this.addEventListener=i}trigger(e){const t=e.type||e;typeof e=="string"&&(e={type:t}),e=Om(e),this.allowedEvents_[t]&&this["on"+t]&&this["on"+t](e),uc(this,e)}queueTrigger(e){bd||(bd=new Map);const t=e.type||e;let i=bd.get(this);i||(i=new Map,bd.set(this,i));const n=i.get(t);i.delete(t),ne.clearTimeout(n);const r=ne.setTimeout(()=>{i.delete(t),i.size===0&&(i=null,bd.delete(this)),this.trigger(e)},0);i.set(t,r)}}En.prototype.allowedEvents_={};En.prototype.addEventListener=En.prototype.on;En.prototype.removeEventListener=En.prototype.off;En.prototype.dispatchEvent=En.prototype.trigger;const Mm=s=>typeof s.name=="function"?s.name():typeof s.name=="string"?s.name:s.name_?s.name_:s.constructor&&s.constructor.name?s.constructor.name:typeof s,va=s=>s instanceof En||!!s.eventBusEl_&&["on","one","off","trigger"].every(e=>typeof s[e]=="function"),kN=(s,e)=>{va(s)?e():(s.eventedCallbacks||(s.eventedCallbacks=[]),s.eventedCallbacks.push(e))},Ev=s=>typeof s=="string"&&/\S/.test(s)||Array.isArray(s)&&!!s.length,Fp=(s,e,t)=>{if(!s||!s.nodeName&&!va(s))throw new Error(`Invalid target for ${Mm(e)}#${t}; must be a DOM node or evented object.`)},yC=(s,e,t)=>{if(!Ev(s))throw new Error(`Invalid event type for ${Mm(e)}#${t}; must be a non-empty string or array.`)},vC=(s,e,t)=>{if(typeof s!="function")throw new Error(`Invalid listener for ${Mm(e)}#${t}; must be a function.`)},Ty=(s,e,t)=>{const i=e.length<3||e[0]===s||e[0]===s.eventBusEl_;let n,r,o;return i?(n=s.eventBusEl_,e.length>=3&&e.shift(),[r,o]=e):(n=e[0],r=e[1],o=e[2]),Fp(n,s,t),yC(r,s,t),vC(o,s,t),o=hi(s,o),{isTargetingSelf:i,target:n,type:r,listener:o}},rl=(s,e,t,i)=>{Fp(s,s,e),s.nodeName?LN[e](s,t,i):s[e](t,i)},RN={on(...s){const{isTargetingSelf:e,target:t,type:i,listener:n}=Ty(this,s,"on");if(rl(t,"on",i,n),!e){const r=()=>this.off(t,i,n);r.guid=n.guid;const o=()=>this.off("dispose",r);o.guid=n.guid,rl(this,"on","dispose",r),rl(t,"on","dispose",o)}},one(...s){const{isTargetingSelf:e,target:t,type:i,listener:n}=Ty(this,s,"one");if(e)rl(t,"one",i,n);else{const r=(...o)=>{this.off(t,i,r),n.apply(null,o)};r.guid=n.guid,rl(t,"one",i,r)}},any(...s){const{isTargetingSelf:e,target:t,type:i,listener:n}=Ty(this,s,"any");if(e)rl(t,"any",i,n);else{const r=(...o)=>{this.off(t,i,r),n.apply(null,o)};r.guid=n.guid,rl(t,"any",i,r)}},off(s,e,t){if(!s||Ev(s))Cs(this.eventBusEl_,s,e);else{const i=s,n=e;Fp(i,this,"off"),yC(n,this,"off"),vC(t,this,"off"),t=hi(this,t),this.off("dispose",t),i.nodeName?(Cs(i,n,t),Cs(i,"dispose",t)):va(i)&&(i.off(n,t),i.off("dispose",t))}},trigger(s,e){Fp(this.eventBusEl_,this,"trigger");const t=s&&typeof s!="string"?s.type:s;if(!Ev(t))throw new Error(`Invalid event type for ${Mm(this)}#trigger; must be a non-empty string or object with a type key that has a non-empty value.`);return uc(this.eventBusEl_,s,e)}};function AT(s,e={}){const{eventBusKey:t}=e;if(t){if(!s[t].nodeName)throw new Error(`The eventBusKey "${t}" does not refer to an element.`);s.eventBusEl_=s[t]}else s.eventBusEl_=dt("span",{className:"vjs-event-bus"});return Object.assign(s,RN),s.eventedCallbacks&&s.eventedCallbacks.forEach(i=>{i()}),s.on("dispose",()=>{s.off(),[s,s.el_,s.eventBusEl_].forEach(function(i){i&&Bs.has(i)&&Bs.delete(i)}),ne.setTimeout(()=>{s.eventBusEl_=null},0)}),s}const ON={state:{},setState(s){typeof s=="function"&&(s=s());let e;return Nu(s,(t,i)=>{this.state[i]!==t&&(e=e||{},e[i]={from:this.state[i],to:t}),this.state[i]=t}),e&&va(this)&&this.trigger({changes:e,type:"statechanged"}),e}};function TC(s,e){return Object.assign(s,ON),s.state=Object.assign({},s.state,e),typeof s.handleStateChanged=="function"&&va(s)&&s.on("statechanged",s.handleStateChanged),s}const Bd=function(s){return typeof s!="string"?s:s.replace(/./,e=>e.toLowerCase())},ki=function(s){return typeof s!="string"?s:s.replace(/./,e=>e.toUpperCase())},bC=function(s,e){return ki(s)===ki(e)};var PN=Object.freeze({__proto__:null,toLowerCase:Bd,toTitleCase:ki,titleCaseEquals:bC});class ke{constructor(e,t,i){if(!e&&this.play?this.player_=e=this:this.player_=e,this.isDisposed_=!1,this.parentComponent_=null,this.options_=si({},this.options_),t=this.options_=si(this.options_,t),this.id_=t.id||t.el&&t.el.id,!this.id_){const n=e&&e.id&&e.id()||"no_player";this.id_=`${n}_component_${Nn()}`}this.name_=t.name||null,t.el?this.el_=t.el:t.createEl!==!1&&(this.el_=this.createEl()),t.className&&this.el_&&t.className.split(" ").forEach(n=>this.addClass(n)),["on","off","one","any","trigger"].forEach(n=>{this[n]=void 0}),t.evented!==!1&&(AT(this,{eventBusKey:this.el_?"el_":null}),this.handleLanguagechange=this.handleLanguagechange.bind(this),this.on(this.player_,"languagechange",this.handleLanguagechange)),TC(this,this.constructor.defaultState),this.children_=[],this.childIndex_={},this.childNameIndex_={},this.setTimeoutIds_=new Set,this.setIntervalIds_=new Set,this.rafIds_=new Set,this.namedRafs_=new Map,this.clearingTimersOnDispose_=!1,t.initChildren!==!1&&this.initChildren(),this.ready(i),t.reportTouchActivity!==!1&&this.enableTouchActivity()}dispose(e={}){if(!this.isDisposed_){if(this.readyQueue_&&(this.readyQueue_.length=0),this.trigger({type:"dispose",bubbles:!1}),this.isDisposed_=!0,this.children_)for(let t=this.children_.length-1;t>=0;t--)this.children_[t].dispose&&this.children_[t].dispose();this.children_=null,this.childIndex_=null,this.childNameIndex_=null,this.parentComponent_=null,this.el_&&(this.el_.parentNode&&(e.restoreEl?this.el_.parentNode.replaceChild(e.restoreEl,this.el_):this.el_.parentNode.removeChild(this.el_)),this.el_=null),this.player_=null}}isDisposed(){return!!this.isDisposed_}player(){return this.player_}options(e){return e?(this.options_=si(this.options_,e),this.options_):this.options_}el(){return this.el_}createEl(e,t,i){return dt(e,t,i)}localize(e,t,i=e){const n=this.player_.language&&this.player_.language(),r=this.player_.languages&&this.player_.languages(),o=r&&r[n],u=n&&n.split("-")[0],c=r&&r[u];let d=i;return o&&o[e]?d=o[e]:c&&c[e]&&(d=c[e]),t&&(d=d.replace(/\{(\d+)\}/g,function(f,m){const g=t[m-1];let v=g;return typeof g>"u"&&(v=f),v})),d}handleLanguagechange(){}contentEl(){return this.contentEl_||this.el_}id(){return this.id_}name(){return this.name_}children(){return this.children_}getChildById(e){return this.childIndex_[e]}getChild(e){if(e)return this.childNameIndex_[e]}getDescendant(...e){e=e.reduce((i,n)=>i.concat(n),[]);let t=this;for(let i=0;i<e.length;i++)if(t=t.getChild(e[i]),!t||!t.getChild)return;return t}setIcon(e,t=this.el()){if(!this.player_.options_.experimentalSvgIcons)return;const i="http://www.w3.org/2000/svg",n=dt("span",{className:"vjs-icon-placeholder vjs-svg-icon"},{"aria-hidden":"true"}),r=Ve.createElementNS(i,"svg");r.setAttributeNS(null,"viewBox","0 0 512 512");const o=Ve.createElementNS(i,"use");return r.appendChild(o),o.setAttributeNS(null,"href",`#vjs-icon-${e}`),n.appendChild(r),this.iconIsSet_?t.replaceChild(n,t.querySelector(".vjs-icon-placeholder")):t.appendChild(n),this.iconIsSet_=!0,n}addChild(e,t={},i=this.children_.length){let n,r;if(typeof e=="string"){r=ki(e);const o=t.componentClass||r;t.name=r;const u=ke.getComponent(o);if(!u)throw new Error(`Component ${o} does not exist`);if(typeof u!="function")return null;n=new u(this.player_||this,t)}else n=e;if(n.parentComponent_&&n.parentComponent_.removeChild(n),this.children_.splice(i,0,n),n.parentComponent_=this,typeof n.id=="function"&&(this.childIndex_[n.id()]=n),r=r||n.name&&ki(n.name()),r&&(this.childNameIndex_[r]=n,this.childNameIndex_[Bd(r)]=n),typeof n.el=="function"&&n.el()){let o=null;this.children_[i+1]&&(this.children_[i+1].el_?o=this.children_[i+1].el_:lc(this.children_[i+1])&&(o=this.children_[i+1])),this.contentEl().insertBefore(n.el(),o)}return n}removeChild(e){if(typeof e=="string"&&(e=this.getChild(e)),!e||!this.children_)return;let t=!1;for(let n=this.children_.length-1;n>=0;n--)if(this.children_[n]===e){t=!0,this.children_.splice(n,1);break}if(!t)return;e.parentComponent_=null,this.childIndex_[e.id()]=null,this.childNameIndex_[ki(e.name())]=null,this.childNameIndex_[Bd(e.name())]=null;const i=e.el();i&&i.parentNode===this.contentEl()&&this.contentEl().removeChild(e.el())}initChildren(){const e=this.options_.children;if(e){const t=this.options_,i=o=>{const u=o.name;let c=o.opts;if(t[u]!==void 0&&(c=t[u]),c===!1)return;c===!0&&(c={}),c.playerOptions=this.options_.playerOptions;const d=this.addChild(u,c);d&&(this[u]=d)};let n;const r=ke.getComponent("Tech");Array.isArray(e)?n=e:n=Object.keys(e),n.concat(Object.keys(this.options_).filter(function(o){return!n.some(function(u){return typeof u=="string"?o===u:o===u.name})})).map(o=>{let u,c;return typeof o=="string"?(u=o,c=e[u]||this.options_[u]||{}):(u=o.name,c=o),{name:u,opts:c}}).filter(o=>{const u=ke.getComponent(o.opts.componentClass||ki(o.name));return u&&!r.isTech(u)}).forEach(i)}}buildCSSClass(){return""}ready(e,t=!1){if(e){if(!this.isReady_){this.readyQueue_=this.readyQueue_||[],this.readyQueue_.push(e);return}t?e.call(this):this.setTimeout(e,1)}}triggerReady(){this.isReady_=!0,this.setTimeout(function(){const e=this.readyQueue_;this.readyQueue_=[],e&&e.length>0&&e.forEach(function(t){t.call(this)},this),this.trigger("ready")},1)}$(e,t){return So(e,t||this.contentEl())}$$(e,t){return cC(e,t||this.contentEl())}hasClass(e){return Nd(this.el_,e)}addClass(...e){vl(this.el_,...e)}removeClass(...e){Lm(this.el_,...e)}toggleClass(e,t){iC(this.el_,e,t)}show(){this.removeClass("vjs-hidden")}hide(){this.addClass("vjs-hidden")}lockShowing(){this.addClass("vjs-lock-showing")}unlockShowing(){this.removeClass("vjs-lock-showing")}getAttribute(e){return nC(this.el_,e)}setAttribute(e,t){ec(this.el_,e,t)}removeAttribute(e){Im(this.el_,e)}width(e,t){return this.dimension("width",e,t)}height(e,t){return this.dimension("height",e,t)}dimensions(e,t){this.width(e,!0),this.height(t)}dimension(e,t,i){if(t!==void 0){(t===null||t!==t)&&(t=0),(""+t).indexOf("%")!==-1||(""+t).indexOf("px")!==-1?this.el_.style[e]=t:t==="auto"?this.el_.style[e]="":this.el_.style[e]=t+"px",i||this.trigger("componentresize");return}if(!this.el_)return 0;const n=this.el_.style[e],r=n.indexOf("px");return parseInt(r!==-1?n.slice(0,r):this.el_["offset"+ki(e)],10)}currentDimension(e){let t=0;if(e!=="width"&&e!=="height")throw new Error("currentDimension only accepts width or height value");if(t=ic(this.el_,e),t=parseFloat(t),t===0||isNaN(t)){const i=`offset${ki(e)}`;t=this.el_[i]}return t}currentDimensions(){return{width:this.currentDimension("width"),height:this.currentDimension("height")}}currentWidth(){return this.currentDimension("width")}currentHeight(){return this.currentDimension("height")}getPositions(){const e=this.el_.getBoundingClientRect(),t={x:e.x,y:e.y,width:e.width,height:e.height,top:e.top,right:e.right,bottom:e.bottom,left:e.left},i={x:e.left+e.width/2,y:e.top+e.height/2,width:0,height:0,top:e.top+e.height/2,right:e.left+e.width/2,bottom:e.top+e.height/2,left:e.left+e.width/2};return{boundingClientRect:t,center:i}}focus(){this.el_.focus()}blur(){this.el_.blur()}handleKeyDown(e){this.player_&&(e.key!=="Tab"&&!(this.player_.options_.playerOptions.spatialNavigation&&this.player_.options_.playerOptions.spatialNavigation.enabled)&&e.stopPropagation(),this.player_.handleKeyDown(e))}handleKeyPress(e){this.handleKeyDown(e)}emitTapEvents(){let e=0,t=null;const i=10,n=200;let r;this.on("touchstart",function(u){u.touches.length===1&&(t={pageX:u.touches[0].pageX,pageY:u.touches[0].pageY},e=ne.performance.now(),r=!0)}),this.on("touchmove",function(u){if(u.touches.length>1)r=!1;else if(t){const c=u.touches[0].pageX-t.pageX,d=u.touches[0].pageY-t.pageY;Math.sqrt(c*c+d*d)>i&&(r=!1)}});const o=function(){r=!1};this.on("touchleave",o),this.on("touchcancel",o),this.on("touchend",function(u){t=null,r===!0&&ne.performance.now()-e<n&&(u.preventDefault(),this.trigger("tap"))})}enableTouchActivity(){if(!this.player()||!this.player().reportUserActivity)return;const e=hi(this.player(),this.player().reportUserActivity);let t;this.on("touchstart",function(){e(),this.clearInterval(t),t=this.setInterval(e,250)});const i=function(n){e(),this.clearInterval(t)};this.on("touchmove",e),this.on("touchend",i),this.on("touchcancel",i)}setTimeout(e,t){var i;return e=hi(this,e),this.clearTimersOnDispose_(),i=ne.setTimeout(()=>{this.setTimeoutIds_.has(i)&&this.setTimeoutIds_.delete(i),e()},t),this.setTimeoutIds_.add(i),i}clearTimeout(e){return this.setTimeoutIds_.has(e)&&(this.setTimeoutIds_.delete(e),ne.clearTimeout(e)),e}setInterval(e,t){e=hi(this,e),this.clearTimersOnDispose_();const i=ne.setInterval(e,t);return this.setIntervalIds_.add(i),i}clearInterval(e){return this.setIntervalIds_.has(e)&&(this.setIntervalIds_.delete(e),ne.clearInterval(e)),e}requestAnimationFrame(e){this.clearTimersOnDispose_();var t;return e=hi(this,e),t=ne.requestAnimationFrame(()=>{this.rafIds_.has(t)&&this.rafIds_.delete(t),e()}),this.rafIds_.add(t),t}requestNamedAnimationFrame(e,t){this.namedRafs_.has(e)&&this.cancelNamedAnimationFrame(e),this.clearTimersOnDispose_(),t=hi(this,t);const i=this.requestAnimationFrame(()=>{t(),this.namedRafs_.has(e)&&this.namedRafs_.delete(e)});return this.namedRafs_.set(e,i),e}cancelNamedAnimationFrame(e){this.namedRafs_.has(e)&&(this.cancelAnimationFrame(this.namedRafs_.get(e)),this.namedRafs_.delete(e))}cancelAnimationFrame(e){return this.rafIds_.has(e)&&(this.rafIds_.delete(e),ne.cancelAnimationFrame(e)),e}clearTimersOnDispose_(){this.clearingTimersOnDispose_||(this.clearingTimersOnDispose_=!0,this.one("dispose",()=>{[["namedRafs_","cancelNamedAnimationFrame"],["rafIds_","cancelAnimationFrame"],["setTimeoutIds_","clearTimeout"],["setIntervalIds_","clearInterval"]].forEach(([e,t])=>{this[e].forEach((i,n)=>this[t](n))}),this.clearingTimersOnDispose_=!1}))}getIsDisabled(){return!!this.el_.disabled}getIsExpresslyInert(){return this.el_.inert&&!this.el_.ownerDocument.documentElement.inert}getIsFocusable(e){return(e||this.el_).tabIndex>=0&&!(this.getIsDisabled()||this.getIsExpresslyInert())}getIsAvailableToBeFocused(e){function t(r){const o=ne.getComputedStyle(r,null),u=o.getPropertyValue("visibility");return o.getPropertyValue("display")!=="none"&&!["hidden","collapse"].includes(u)}function i(r){return!(!t(r.parentElement)||!t(r)||r.style.opacity==="0"||ne.getComputedStyle(r).height==="0px"||ne.getComputedStyle(r).width==="0px")}function n(r){if(r.offsetWidth+r.offsetHeight+r.getBoundingClientRect().height+r.getBoundingClientRect().width===0)return!1;const o={x:r.getBoundingClientRect().left+r.offsetWidth/2,y:r.getBoundingClientRect().top+r.offsetHeight/2};if(o.x<0||o.x>(Ve.documentElement.clientWidth||ne.innerWidth)||o.y<0||o.y>(Ve.documentElement.clientHeight||ne.innerHeight))return!1;let u=Ve.elementFromPoint(o.x,o.y);for(;u;){if(u===r)return!0;if(u.parentNode)u=u.parentNode;else return!1}}return e||(e=this.el()),!!(n(e)&&i(e)&&(!e.parentElement||e.tabIndex>=0))}static registerComponent(e,t){if(typeof e!="string"||!e)throw new Error(`Illegal component name, "${e}"; must be a non-empty string.`);const i=ke.getComponent("Tech"),n=i&&i.isTech(t),r=ke===t||ke.prototype.isPrototypeOf(t.prototype);if(n||!r){let u;throw n?u="techs must be registered using Tech.registerTech()":u="must be a Component subclass",new Error(`Illegal component, "${e}"; ${u}.`)}e=ki(e),ke.components_||(ke.components_={});const o=ke.getComponent("Player");if(e==="Player"&&o&&o.players){const u=o.players,c=Object.keys(u);if(u&&c.length>0){for(let d=0;d<c.length;d++)if(u[c[d]]!==null)throw new Error("Can not register Player component after player has been created.")}}return ke.components_[e]=t,ke.components_[Bd(e)]=t,t}static getComponent(e){if(!(!e||!ke.components_))return ke.components_[e]}}ke.registerComponent("Component",ke);function MN(s,e,t){if(typeof e!="number"||e<0||e>t)throw new Error(`Failed to execute '${s}' on 'TimeRanges': The index provided (${e}) is non-numeric or out of bounds (0-${t}).`)}function kE(s,e,t,i){return MN(s,i,t.length-1),t[i][e]}function by(s){let e;return s===void 0||s.length===0?e={length:0,start(){throw new Error("This TimeRanges object is empty")},end(){throw new Error("This TimeRanges object is empty")}}:e={length:s.length,start:kE.bind(null,"start",0,s),end:kE.bind(null,"end",1,s)},ne.Symbol&&ne.Symbol.iterator&&(e[ne.Symbol.iterator]=()=>(s||[]).values()),e}function tr(s,e){return Array.isArray(s)?by(s):s===void 0||e===void 0?by():by([[s,e]])}const _C=function(s,e){s=s<0?0:s;let t=Math.floor(s%60),i=Math.floor(s/60%60),n=Math.floor(s/3600);const r=Math.floor(e/60%60),o=Math.floor(e/3600);return(isNaN(s)||s===1/0)&&(n=i=t="-"),n=n>0||o>0?n+":":"",i=((n||r>=10)&&i<10?"0"+i:i)+":",t=t<10?"0"+t:t,n+i+t};let CT=_C;function xC(s){CT=s}function SC(){CT=_C}function El(s,e=s){return CT(s,e)}var NN=Object.freeze({__proto__:null,createTimeRanges:tr,createTimeRange:tr,setFormatTime:xC,resetFormatTime:SC,formatTime:El});function EC(s,e){let t=0,i,n;if(!e)return 0;(!s||!s.length)&&(s=tr(0,0));for(let r=0;r<s.length;r++)i=s.start(r),n=s.end(r),n>e&&(n=e),t+=n-i;return t/e}function Ci(s){if(s instanceof Ci)return s;typeof s=="number"?this.code=s:typeof s=="string"?this.message=s:Mr(s)&&(typeof s.code=="number"&&(this.code=s.code),Object.assign(this,s)),this.message||(this.message=Ci.defaultMessages[this.code]||"")}Ci.prototype.code=0;Ci.prototype.message="";Ci.prototype.status=null;Ci.prototype.metadata=null;Ci.errorTypes=["MEDIA_ERR_CUSTOM","MEDIA_ERR_ABORTED","MEDIA_ERR_NETWORK","MEDIA_ERR_DECODE","MEDIA_ERR_SRC_NOT_SUPPORTED","MEDIA_ERR_ENCRYPTED"];Ci.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail part-way.",3:"The media playback was aborted due to a corruption problem or because the media used features your browser did not support.",4:"The media could not be loaded, either because the server or network failed or because the format is not supported.",5:"The media is encrypted and we do not have the keys to decrypt it."};Ci.MEDIA_ERR_CUSTOM=0;Ci.prototype.MEDIA_ERR_CUSTOM=0;Ci.MEDIA_ERR_ABORTED=1;Ci.prototype.MEDIA_ERR_ABORTED=1;Ci.MEDIA_ERR_NETWORK=2;Ci.prototype.MEDIA_ERR_NETWORK=2;Ci.MEDIA_ERR_DECODE=3;Ci.prototype.MEDIA_ERR_DECODE=3;Ci.MEDIA_ERR_SRC_NOT_SUPPORTED=4;Ci.prototype.MEDIA_ERR_SRC_NOT_SUPPORTED=4;Ci.MEDIA_ERR_ENCRYPTED=5;Ci.prototype.MEDIA_ERR_ENCRYPTED=5;function Fd(s){return s!=null&&typeof s.then=="function"}function wr(s){Fd(s)&&s.then(null,e=>{})}const Av=function(s){return["kind","label","language","id","inBandMetadataTrackDispatchType","mode","src"].reduce((t,i,n)=>(s[i]&&(t[i]=s[i]),t),{cues:s.cues&&Array.prototype.map.call(s.cues,function(t){return{startTime:t.startTime,endTime:t.endTime,text:t.text,id:t.id}})})},BN=function(s){const e=s.$$("track"),t=Array.prototype.map.call(e,n=>n.track);return Array.prototype.map.call(e,function(n){const r=Av(n.track);return n.src&&(r.src=n.src),r}).concat(Array.prototype.filter.call(s.textTracks(),function(n){return t.indexOf(n)===-1}).map(Av))},FN=function(s,e){return s.forEach(function(t){const i=e.addRemoteTextTrack(t).track;!t.src&&t.cues&&t.cues.forEach(n=>i.addCue(n))}),e.textTracks()};var Cv={textTracksToJson:BN,jsonToTextTracks:FN,trackToJson:Av};const _y="vjs-modal-dialog";class cc extends ke{constructor(e,t){super(e,t),this.handleKeyDown_=i=>this.handleKeyDown(i),this.close_=i=>this.close(i),this.opened_=this.hasBeenOpened_=this.hasBeenFilled_=!1,this.closeable(!this.options_.uncloseable),this.content(this.options_.content),this.contentEl_=dt("div",{className:`${_y}-content`},{role:"document"}),this.descEl_=dt("p",{className:`${_y}-description vjs-control-text`,id:this.el().getAttribute("aria-describedby")}),Co(this.descEl_,this.description()),this.el_.appendChild(this.descEl_),this.el_.appendChild(this.contentEl_)}createEl(){return super.createEl("div",{className:this.buildCSSClass(),tabIndex:-1},{"aria-describedby":`${this.id()}_description`,"aria-hidden":"true","aria-label":this.label(),role:"dialog","aria-live":"polite"})}dispose(){this.contentEl_=null,this.descEl_=null,this.previouslyActiveEl_=null,super.dispose()}buildCSSClass(){return`${_y} vjs-hidden ${super.buildCSSClass()}`}label(){return this.localize(this.options_.label||"Modal Window")}description(){let e=this.options_.description||this.localize("This is a modal window.");return this.closeable()&&(e+=" "+this.localize("This modal can be closed by pressing the Escape key or activating the close button.")),e}open(){if(this.opened_){this.options_.fillAlways&&this.fill();return}const e=this.player();this.trigger("beforemodalopen"),this.opened_=!0,(this.options_.fillAlways||!this.hasBeenOpened_&&!this.hasBeenFilled_)&&this.fill(),this.wasPlaying_=!e.paused(),this.options_.pauseOnOpen&&this.wasPlaying_&&e.pause(),this.on("keydown",this.handleKeyDown_),this.hadControls_=e.controls(),e.controls(!1),this.show(),this.conditionalFocus_(),this.el().setAttribute("aria-hidden","false"),this.trigger("modalopen"),this.hasBeenOpened_=!0}opened(e){return typeof e=="boolean"&&this[e?"open":"close"](),this.opened_}close(){if(!this.opened_)return;const e=this.player();this.trigger("beforemodalclose"),this.opened_=!1,this.wasPlaying_&&this.options_.pauseOnOpen&&e.play(),this.off("keydown",this.handleKeyDown_),this.hadControls_&&e.controls(!0),this.hide(),this.el().setAttribute("aria-hidden","true"),this.trigger({type:"modalclose",bubbles:!0}),this.conditionalBlur_(),this.options_.temporary&&this.dispose()}closeable(e){if(typeof e=="boolean"){const t=this.closeable_=!!e;let i=this.getChild("closeButton");if(t&&!i){const n=this.contentEl_;this.contentEl_=this.el_,i=this.addChild("closeButton",{controlText:"Close Modal Dialog"}),this.contentEl_=n,this.on(i,"close",this.close_)}!t&&i&&(this.off(i,"close",this.close_),this.removeChild(i),i.dispose())}return this.closeable_}fill(){this.fillWith(this.content())}fillWith(e){const t=this.contentEl(),i=t.parentNode,n=t.nextSibling;this.trigger("beforemodalfill"),this.hasBeenFilled_=!0,i.removeChild(t),this.empty(),uC(t,e),this.trigger("modalfill"),n?i.insertBefore(t,n):i.appendChild(t);const r=this.getChild("closeButton");r&&i.appendChild(r.el_),this.trigger("aftermodalfill")}empty(){this.trigger("beforemodalempty"),Rm(this.contentEl()),this.trigger("modalempty")}content(e){return typeof e<"u"&&(this.content_=e),this.content_}conditionalFocus_(){const e=Ve.activeElement,t=this.player_.el_;this.previouslyActiveEl_=null,(t.contains(e)||t===e)&&(this.previouslyActiveEl_=e,this.focus())}conditionalBlur_(){this.previouslyActiveEl_&&(this.previouslyActiveEl_.focus(),this.previouslyActiveEl_=null)}handleKeyDown(e){if(this.trigger({type:"modalKeydown",originalEvent:e,target:this,bubbles:!0}),e.stopPropagation(),e.key==="Escape"&&this.closeable()){e.preventDefault(),this.close();return}if(e.key!=="Tab")return;const t=this.focusableEls_(),i=this.el_.querySelector(":focus");let n;for(let r=0;r<t.length;r++)if(i===t[r]){n=r;break}Ve.activeElement===this.el_&&(n=0),e.shiftKey&&n===0?(t[t.length-1].focus(),e.preventDefault()):!e.shiftKey&&n===t.length-1&&(t[0].focus(),e.preventDefault())}focusableEls_(){const e=this.el_.querySelectorAll("*");return Array.prototype.filter.call(e,t=>(t instanceof ne.HTMLAnchorElement||t instanceof ne.HTMLAreaElement)&&t.hasAttribute("href")||(t instanceof ne.HTMLInputElement||t instanceof ne.HTMLSelectElement||t instanceof ne.HTMLTextAreaElement||t instanceof ne.HTMLButtonElement)&&!t.hasAttribute("disabled")||t instanceof ne.HTMLIFrameElement||t instanceof ne.HTMLObjectElement||t instanceof ne.HTMLEmbedElement||t.hasAttribute("tabindex")&&t.getAttribute("tabindex")!==-1||t.hasAttribute("contenteditable"))}}cc.prototype.options_={pauseOnOpen:!0,temporary:!0};ke.registerComponent("ModalDialog",cc);class Al extends En{constructor(e=[]){super(),this.tracks_=[],Object.defineProperty(this,"length",{get(){return this.tracks_.length}});for(let t=0;t<e.length;t++)this.addTrack(e[t])}addTrack(e){const t=this.tracks_.length;""+t in this||Object.defineProperty(this,t,{get(){return this.tracks_[t]}}),this.tracks_.indexOf(e)===-1&&(this.tracks_.push(e),this.trigger({track:e,type:"addtrack",target:this})),e.labelchange_=()=>{this.trigger({track:e,type:"labelchange",target:this})},va(e)&&e.addEventListener("labelchange",e.labelchange_)}removeTrack(e){let t;for(let i=0,n=this.length;i<n;i++)if(this[i]===e){t=this[i],t.off&&t.off(),this.tracks_.splice(i,1);break}t&&this.trigger({track:t,type:"removetrack",target:this})}getTrackById(e){let t=null;for(let i=0,n=this.length;i<n;i++){const r=this[i];if(r.id===e){t=r;break}}return t}}Al.prototype.allowedEvents_={change:"change",addtrack:"addtrack",removetrack:"removetrack",labelchange:"labelchange"};for(const s in Al.prototype.allowedEvents_)Al.prototype["on"+s]=null;const xy=function(s,e){for(let t=0;t<s.length;t++)!Object.keys(s[t]).length||e.id===s[t].id||(s[t].enabled=!1)};class AC extends Al{constructor(e=[]){for(let t=e.length-1;t>=0;t--)if(e[t].enabled){xy(e,e[t]);break}super(e),this.changing_=!1}addTrack(e){e.enabled&&xy(this,e),super.addTrack(e),e.addEventListener&&(e.enabledChange_=()=>{this.changing_||(this.changing_=!0,xy(this,e),this.changing_=!1,this.trigger("change"))},e.addEventListener("enabledchange",e.enabledChange_))}removeTrack(e){super.removeTrack(e),e.removeEventListener&&e.enabledChange_&&(e.removeEventListener("enabledchange",e.enabledChange_),e.enabledChange_=null)}}const Sy=function(s,e){for(let t=0;t<s.length;t++)!Object.keys(s[t]).length||e.id===s[t].id||(s[t].selected=!1)};class CC extends Al{constructor(e=[]){for(let t=e.length-1;t>=0;t--)if(e[t].selected){Sy(e,e[t]);break}super(e),this.changing_=!1,Object.defineProperty(this,"selectedIndex",{get(){for(let t=0;t<this.length;t++)if(this[t].selected)return t;return-1},set(){}})}addTrack(e){e.selected&&Sy(this,e),super.addTrack(e),e.addEventListener&&(e.selectedChange_=()=>{this.changing_||(this.changing_=!0,Sy(this,e),this.changing_=!1,this.trigger("change"))},e.addEventListener("selectedchange",e.selectedChange_))}removeTrack(e){super.removeTrack(e),e.removeEventListener&&e.selectedChange_&&(e.removeEventListener("selectedchange",e.selectedChange_),e.selectedChange_=null)}}class DT extends Al{addTrack(e){super.addTrack(e),this.queueChange_||(this.queueChange_=()=>this.queueTrigger("change")),this.triggerSelectedlanguagechange||(this.triggerSelectedlanguagechange_=()=>this.trigger("selectedlanguagechange")),e.addEventListener("modechange",this.queueChange_),["metadata","chapters"].indexOf(e.kind)===-1&&e.addEventListener("modechange",this.triggerSelectedlanguagechange_)}removeTrack(e){super.removeTrack(e),e.removeEventListener&&(this.queueChange_&&e.removeEventListener("modechange",this.queueChange_),this.selectedlanguagechange_&&e.removeEventListener("modechange",this.triggerSelectedlanguagechange_))}toJSON(){return this.tracks_.map(e=>e.toJSON())}}class UN{constructor(e=[]){this.trackElements_=[],Object.defineProperty(this,"length",{get(){return this.trackElements_.length}});for(let t=0,i=e.length;t<i;t++)this.addTrackElement_(e[t])}addTrackElement_(e){const t=this.trackElements_.length;""+t in this||Object.defineProperty(this,t,{get(){return this.trackElements_[t]}}),this.trackElements_.indexOf(e)===-1&&this.trackElements_.push(e)}getTrackElementByTrack_(e){let t;for(let i=0,n=this.trackElements_.length;i<n;i++)if(e===this.trackElements_[i].track){t=this.trackElements_[i];break}return t}removeTrackElement_(e){for(let t=0,i=this.trackElements_.length;t<i;t++)if(e===this.trackElements_[t]){this.trackElements_[t].track&&typeof this.trackElements_[t].track.off=="function"&&this.trackElements_[t].track.off(),typeof this.trackElements_[t].off=="function"&&this.trackElements_[t].off(),this.trackElements_.splice(t,1);break}}}class Up{constructor(e){Up.prototype.setCues_.call(this,e),Object.defineProperty(this,"length",{get(){return this.length_}})}setCues_(e){const t=this.length||0;let i=0;const n=e.length;this.cues_=e,this.length_=e.length;const r=function(o){""+o in this||Object.defineProperty(this,""+o,{get(){return this.cues_[o]}})};if(t<n)for(i=t;i<n;i++)r.call(this,i)}getCueById(e){let t=null;for(let i=0,n=this.length;i<n;i++){const r=this[i];if(r.id===e){t=r;break}}return t}}const $N={alternative:"alternative",captions:"captions",main:"main",sign:"sign",subtitles:"subtitles",commentary:"commentary"},jN={alternative:"alternative",descriptions:"descriptions",main:"main","main-desc":"main-desc",translation:"translation",commentary:"commentary"},HN={subtitles:"subtitles",captions:"captions",descriptions:"descriptions",chapters:"chapters",metadata:"metadata"},RE={disabled:"disabled",hidden:"hidden",showing:"showing"};class wT extends En{constructor(e={}){super();const t={id:e.id||"vjs_track_"+Nn(),kind:e.kind||"",language:e.language||""};let i=e.label||"";for(const n in t)Object.defineProperty(this,n,{get(){return t[n]},set(){}});Object.defineProperty(this,"label",{get(){return i},set(n){n!==i&&(i=n,this.trigger("labelchange"))}})}}const LT=function(s){return new URL(s,Ve.baseURI)},DC=function(s){return new URL(s,Ve.baseURI).href},IT=function(s){if(typeof s=="string"){const t=s.split("?")[0].replace(/\/+$/,"").match(/\.([^.\/]+)$/);return t?t[1].toLowerCase():""}return""},Nm=function(s,e=ne.location){return LT(s).origin!==e.origin};var GN=Object.freeze({__proto__:null,parseUrl:LT,getAbsoluteURL:DC,getFileExtension:IT,isCrossOrigin:Nm});const OE=function(s,e){const t=new ne.WebVTT.Parser(ne,ne.vttjs,ne.WebVTT.StringDecoder()),i=[];t.oncue=function(n){e.addCue(n)},t.onparsingerror=function(n){i.push(n)},t.onflush=function(){e.trigger({type:"loadeddata",target:e})},t.parse(s),i.length>0&&(ne.console&&ne.console.groupCollapsed&&ne.console.groupCollapsed(`Text Track parsing errors for ${e.src}`),i.forEach(n=>Dt.error(n)),ne.console&&ne.console.groupEnd&&ne.console.groupEnd()),t.flush()},PE=function(s,e){const t={uri:s},i=Nm(s);i&&(t.cors=i);const n=e.tech_.crossOrigin()==="use-credentials";n&&(t.withCredentials=n),LA(t,hi(this,function(r,o,u){if(r)return Dt.error(r,o);e.loaded_=!0,typeof ne.WebVTT!="function"?e.tech_&&e.tech_.any(["vttjsloaded","vttjserror"],c=>{if(c.type==="vttjserror"){Dt.error(`vttjs failed to load, stopping trying to process ${e.src}`);return}return OE(u,e)}):OE(u,e)}))};class oh extends wT{constructor(e={}){if(!e.tech)throw new Error("A tech was not provided.");const t=si(e,{kind:HN[e.kind]||"subtitles",language:e.language||e.srclang||""});let i=RE[t.mode]||"disabled";const n=t.default;(t.kind==="metadata"||t.kind==="chapters")&&(i="hidden"),super(t),this.tech_=t.tech,this.cues_=[],this.activeCues_=[],this.preload_=this.tech_.preloadTextTracks!==!1;const r=new Up(this.cues_),o=new Up(this.activeCues_);let u=!1;this.timeupdateHandler=hi(this,function(d={}){if(!this.tech_.isDisposed()){if(!this.tech_.isReady_){d.type!=="timeupdate"&&(this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler));return}this.activeCues=this.activeCues,u&&(this.trigger("cuechange"),u=!1),d.type!=="timeupdate"&&(this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler))}});const c=()=>{this.stopTracking()};this.tech_.one("dispose",c),i!=="disabled"&&this.startTracking(),Object.defineProperties(this,{default:{get(){return n},set(){}},mode:{get(){return i},set(d){RE[d]&&i!==d&&(i=d,!this.preload_&&i!=="disabled"&&this.cues.length===0&&PE(this.src,this),this.stopTracking(),i!=="disabled"&&this.startTracking(),this.trigger("modechange"))}},cues:{get(){return this.loaded_?r:null},set(){}},activeCues:{get(){if(!this.loaded_)return null;if(this.cues.length===0)return o;const d=this.tech_.currentTime(),f=[];for(let m=0,g=this.cues.length;m<g;m++){const v=this.cues[m];v.startTime<=d&&v.endTime>=d&&f.push(v)}if(u=!1,f.length!==this.activeCues_.length)u=!0;else for(let m=0;m<f.length;m++)this.activeCues_.indexOf(f[m])===-1&&(u=!0);return this.activeCues_=f,o.setCues_(this.activeCues_),o},set(){}}}),t.src?(this.src=t.src,this.preload_||(this.loaded_=!0),(this.preload_||t.kind!=="subtitles"&&t.kind!=="captions")&&PE(this.src,this)):this.loaded_=!0}startTracking(){this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler),this.tech_.on("timeupdate",this.timeupdateHandler)}stopTracking(){this.rvf_&&(this.tech_.cancelVideoFrameCallback(this.rvf_),this.rvf_=void 0),this.tech_.off("timeupdate",this.timeupdateHandler)}addCue(e){let t=e;if(!("getCueAsHTML"in t)){t=new ne.vttjs.VTTCue(e.startTime,e.endTime,e.text);for(const n in e)n in t||(t[n]=e[n]);t.id=e.id,t.originalCue_=e}const i=this.tech_.textTracks();for(let n=0;n<i.length;n++)i[n]!==this&&i[n].removeCue(t);this.cues_.push(t),this.cues.setCues_(this.cues_)}toJSON(){return Cv.trackToJson(this)}removeCue(e){let t=this.cues_.length;for(;t--;){const i=this.cues_[t];if(i===e||i.originalCue_&&i.originalCue_===e){this.cues_.splice(t,1),this.cues.setCues_(this.cues_);break}}}}oh.prototype.allowedEvents_={cuechange:"cuechange"};class wC extends wT{constructor(e={}){const t=si(e,{kind:jN[e.kind]||""});super(t);let i=!1;Object.defineProperty(this,"enabled",{get(){return i},set(n){typeof n!="boolean"||n===i||(i=n,this.trigger("enabledchange"))}}),t.enabled&&(this.enabled=t.enabled),this.loaded_=!0}}class LC extends wT{constructor(e={}){const t=si(e,{kind:$N[e.kind]||""});super(t);let i=!1;Object.defineProperty(this,"selected",{get(){return i},set(n){typeof n!="boolean"||n===i||(i=n,this.trigger("selectedchange"))}}),t.selected&&(this.selected=t.selected)}}class ba extends En{constructor(e={}){super();let t;const i=new oh(e);this.kind=i.kind,this.src=i.src,this.srclang=i.language,this.label=i.label,this.default=i.default,Object.defineProperties(this,{readyState:{get(){return t}},track:{get(){return i}}}),t=ba.NONE,i.addEventListener("loadeddata",()=>{t=ba.LOADED,this.trigger({type:"load",target:this})})}}ba.prototype.allowedEvents_={load:"load"};ba.NONE=0;ba.LOADING=1;ba.LOADED=2;ba.ERROR=3;const Mn={audio:{ListClass:AC,TrackClass:wC,capitalName:"Audio"},video:{ListClass:CC,TrackClass:LC,capitalName:"Video"},text:{ListClass:DT,TrackClass:oh,capitalName:"Text"}};Object.keys(Mn).forEach(function(s){Mn[s].getterName=`${s}Tracks`,Mn[s].privateName=`${s}Tracks_`});const sc={remoteText:{ListClass:DT,TrackClass:oh,capitalName:"RemoteText",getterName:"remoteTextTracks",privateName:"remoteTextTracks_"},remoteTextEl:{ListClass:UN,TrackClass:ba,capitalName:"RemoteTextTrackEls",getterName:"remoteTextTrackEls",privateName:"remoteTextTrackEls_"}},Ns=Object.assign({},Mn,sc);sc.names=Object.keys(sc);Mn.names=Object.keys(Mn);Ns.names=[].concat(sc.names).concat(Mn.names);function VN(s,e,t,i,n={}){const r=s.textTracks();n.kind=e,t&&(n.label=t),i&&(n.language=i),n.tech=s;const o=new Ns.text.TrackClass(n);return r.addTrack(o),o}class bt extends ke{constructor(e={},t=function(){}){e.reportTouchActivity=!1,super(null,e,t),this.onDurationChange_=i=>this.onDurationChange(i),this.trackProgress_=i=>this.trackProgress(i),this.trackCurrentTime_=i=>this.trackCurrentTime(i),this.stopTrackingCurrentTime_=i=>this.stopTrackingCurrentTime(i),this.disposeSourceHandler_=i=>this.disposeSourceHandler(i),this.queuedHanders_=new Set,this.hasStarted_=!1,this.on("playing",function(){this.hasStarted_=!0}),this.on("loadstart",function(){this.hasStarted_=!1}),Ns.names.forEach(i=>{const n=Ns[i];e&&e[n.getterName]&&(this[n.privateName]=e[n.getterName])}),this.featuresProgressEvents||this.manualProgressOn(),this.featuresTimeupdateEvents||this.manualTimeUpdatesOn(),["Text","Audio","Video"].forEach(i=>{e[`native${i}Tracks`]===!1&&(this[`featuresNative${i}Tracks`]=!1)}),e.nativeCaptions===!1||e.nativeTextTracks===!1?this.featuresNativeTextTracks=!1:(e.nativeCaptions===!0||e.nativeTextTracks===!0)&&(this.featuresNativeTextTracks=!0),this.featuresNativeTextTracks||this.emulateTextTracks(),this.preloadTextTracks=e.preloadTextTracks!==!1,this.autoRemoteTextTracks_=new Ns.text.ListClass,this.initTrackListeners(),e.nativeControlsForTouch||this.emitTapEvents(),this.constructor&&(this.name_=this.constructor.name||"Unknown Tech")}triggerSourceset(e){this.isReady_||this.one("ready",()=>this.setTimeout(()=>this.triggerSourceset(e),1)),this.trigger({src:e,type:"sourceset"})}manualProgressOn(){this.on("durationchange",this.onDurationChange_),this.manualProgress=!0,this.one("ready",this.trackProgress_)}manualProgressOff(){this.manualProgress=!1,this.stopTrackingProgress(),this.off("durationchange",this.onDurationChange_)}trackProgress(e){this.stopTrackingProgress(),this.progressInterval=this.setInterval(hi(this,function(){const t=this.bufferedPercent();this.bufferedPercent_!==t&&this.trigger("progress"),this.bufferedPercent_=t,t===1&&this.stopTrackingProgress()}),500)}onDurationChange(e){this.duration_=this.duration()}buffered(){return tr(0,0)}bufferedPercent(){return EC(this.buffered(),this.duration_)}stopTrackingProgress(){this.clearInterval(this.progressInterval)}manualTimeUpdatesOn(){this.manualTimeUpdates=!0,this.on("play",this.trackCurrentTime_),this.on("pause",this.stopTrackingCurrentTime_)}manualTimeUpdatesOff(){this.manualTimeUpdates=!1,this.stopTrackingCurrentTime(),this.off("play",this.trackCurrentTime_),this.off("pause",this.stopTrackingCurrentTime_)}trackCurrentTime(){this.currentTimeInterval&&this.stopTrackingCurrentTime(),this.currentTimeInterval=this.setInterval(function(){this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})},250)}stopTrackingCurrentTime(){this.clearInterval(this.currentTimeInterval),this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}dispose(){this.clearTracks(Mn.names),this.manualProgress&&this.manualProgressOff(),this.manualTimeUpdates&&this.manualTimeUpdatesOff(),super.dispose()}clearTracks(e){e=[].concat(e),e.forEach(t=>{const i=this[`${t}Tracks`]()||[];let n=i.length;for(;n--;){const r=i[n];t==="text"&&this.removeRemoteTextTrack(r),i.removeTrack(r)}})}cleanupAutoTextTracks(){const e=this.autoRemoteTextTracks_||[];let t=e.length;for(;t--;){const i=e[t];this.removeRemoteTextTrack(i)}}reset(){}crossOrigin(){}setCrossOrigin(){}error(e){return e!==void 0&&(this.error_=new Ci(e),this.trigger("error")),this.error_}played(){return this.hasStarted_?tr(0,0):tr()}play(){}setScrubbing(e){}scrubbing(){}setCurrentTime(e){this.manualTimeUpdates&&this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}initTrackListeners(){Mn.names.forEach(e=>{const t=Mn[e],i=()=>{this.trigger(`${e}trackchange`)},n=this[t.getterName]();n.addEventListener("removetrack",i),n.addEventListener("addtrack",i),this.on("dispose",()=>{n.removeEventListener("removetrack",i),n.removeEventListener("addtrack",i)})})}addWebVttScript_(){if(!ne.WebVTT)if(Ve.body.contains(this.el())){if(!this.options_["vtt.js"]&&Ju(nE)&&Object.keys(nE).length>0){this.trigger("vttjsloaded");return}const e=Ve.createElement("script");e.src=this.options_["vtt.js"]||"https://vjs.zencdn.net/vttjs/0.14.1/vtt.min.js",e.onload=()=>{this.trigger("vttjsloaded")},e.onerror=()=>{this.trigger("vttjserror")},this.on("dispose",()=>{e.onload=null,e.onerror=null}),ne.WebVTT=!0,this.el().parentNode.appendChild(e)}else this.ready(this.addWebVttScript_)}emulateTextTracks(){const e=this.textTracks(),t=this.remoteTextTracks(),i=u=>e.addTrack(u.track),n=u=>e.removeTrack(u.track);t.on("addtrack",i),t.on("removetrack",n),this.addWebVttScript_();const r=()=>this.trigger("texttrackchange"),o=()=>{r();for(let u=0;u<e.length;u++){const c=e[u];c.removeEventListener("cuechange",r),c.mode==="showing"&&c.addEventListener("cuechange",r)}};o(),e.addEventListener("change",o),e.addEventListener("addtrack",o),e.addEventListener("removetrack",o),this.on("dispose",function(){t.off("addtrack",i),t.off("removetrack",n),e.removeEventListener("change",o),e.removeEventListener("addtrack",o),e.removeEventListener("removetrack",o);for(let u=0;u<e.length;u++)e[u].removeEventListener("cuechange",r)})}addTextTrack(e,t,i){if(!e)throw new Error("TextTrack kind is required but was not provided");return VN(this,e,t,i)}createRemoteTextTrack(e){const t=si(e,{tech:this});return new sc.remoteTextEl.TrackClass(t)}addRemoteTextTrack(e={},t){const i=this.createRemoteTextTrack(e);return typeof t!="boolean"&&(t=!1),this.remoteTextTrackEls().addTrackElement_(i),this.remoteTextTracks().addTrack(i.track),t===!1&&this.ready(()=>this.autoRemoteTextTracks_.addTrack(i.track)),i}removeRemoteTextTrack(e){const t=this.remoteTextTrackEls().getTrackElementByTrack_(e);this.remoteTextTrackEls().removeTrackElement_(t),this.remoteTextTracks().removeTrack(e),this.autoRemoteTextTracks_.removeTrack(e)}getVideoPlaybackQuality(){return{}}requestPictureInPicture(){return Promise.reject()}disablePictureInPicture(){return!0}setDisablePictureInPicture(){}requestVideoFrameCallback(e){const t=Nn();return!this.isReady_||this.paused()?(this.queuedHanders_.add(t),this.one("playing",()=>{this.queuedHanders_.has(t)&&(this.queuedHanders_.delete(t),e())})):this.requestNamedAnimationFrame(t,e),t}cancelVideoFrameCallback(e){this.queuedHanders_.has(e)?this.queuedHanders_.delete(e):this.cancelNamedAnimationFrame(e)}setPoster(){}playsinline(){}setPlaysinline(){}overrideNativeAudioTracks(e){}overrideNativeVideoTracks(e){}canPlayType(e){return""}static canPlayType(e){return""}static canPlaySource(e,t){return bt.canPlayType(e.type)}static isTech(e){return e.prototype instanceof bt||e instanceof bt||e===bt}static registerTech(e,t){if(bt.techs_||(bt.techs_={}),!bt.isTech(t))throw new Error(`Tech ${e} must be a Tech`);if(!bt.canPlayType)throw new Error("Techs must have a static canPlayType method on them");if(!bt.canPlaySource)throw new Error("Techs must have a static canPlaySource method on them");return e=ki(e),bt.techs_[e]=t,bt.techs_[Bd(e)]=t,e!=="Tech"&&bt.defaultTechOrder_.push(e),t}static getTech(e){if(e){if(bt.techs_&&bt.techs_[e])return bt.techs_[e];if(e=ki(e),ne&&ne.videojs&&ne.videojs[e])return Dt.warn(`The ${e} tech was added to the videojs object when it should be registered using videojs.registerTech(name, tech)`),ne.videojs[e]}}}Ns.names.forEach(function(s){const e=Ns[s];bt.prototype[e.getterName]=function(){return this[e.privateName]=this[e.privateName]||new e.ListClass,this[e.privateName]}});bt.prototype.featuresVolumeControl=!0;bt.prototype.featuresMuteControl=!0;bt.prototype.featuresFullscreenResize=!1;bt.prototype.featuresPlaybackRate=!1;bt.prototype.featuresProgressEvents=!1;bt.prototype.featuresSourceset=!1;bt.prototype.featuresTimeupdateEvents=!1;bt.prototype.featuresNativeTextTracks=!1;bt.prototype.featuresVideoFrameCallback=!1;bt.withSourceHandlers=function(s){s.registerSourceHandler=function(t,i){let n=s.sourceHandlers;n||(n=s.sourceHandlers=[]),i===void 0&&(i=n.length),n.splice(i,0,t)},s.canPlayType=function(t){const i=s.sourceHandlers||[];let n;for(let r=0;r<i.length;r++)if(n=i[r].canPlayType(t),n)return n;return""},s.selectSourceHandler=function(t,i){const n=s.sourceHandlers||[];let r;for(let o=0;o<n.length;o++)if(r=n[o].canHandleSource(t,i),r)return n[o];return null},s.canPlaySource=function(t,i){const n=s.selectSourceHandler(t,i);return n?n.canHandleSource(t,i):""},["seekable","seeking","duration"].forEach(function(t){const i=this[t];typeof i=="function"&&(this[t]=function(){return this.sourceHandler_&&this.sourceHandler_[t]?this.sourceHandler_[t].apply(this.sourceHandler_,arguments):i.apply(this,arguments)})},s.prototype),s.prototype.setSource=function(t){let i=s.selectSourceHandler(t,this.options_);i||(s.nativeSourceHandler?i=s.nativeSourceHandler:Dt.error("No source handler found for the current source.")),this.disposeSourceHandler(),this.off("dispose",this.disposeSourceHandler_),i!==s.nativeSourceHandler&&(this.currentSource_=t),this.sourceHandler_=i.handleSource(t,this,this.options_),this.one("dispose",this.disposeSourceHandler_)},s.prototype.disposeSourceHandler=function(){this.currentSource_&&(this.clearTracks(["audio","video"]),this.currentSource_=null),this.cleanupAutoTextTracks(),this.sourceHandler_&&(this.sourceHandler_.dispose&&this.sourceHandler_.dispose(),this.sourceHandler_=null)}};ke.registerComponent("Tech",bt);bt.registerTech("Tech",bt);bt.defaultTechOrder_=[];const Tl={},$p={},jp={};function qN(s,e){Tl[s]=Tl[s]||[],Tl[s].push(e)}function zN(s,e,t){s.setTimeout(()=>cl(e,Tl[e.type],t,s),1)}function KN(s,e){s.forEach(t=>t.setTech&&t.setTech(e))}function YN(s,e,t){return s.reduceRight(kT(t),e[t]())}function WN(s,e,t,i){return e[t](s.reduce(kT(t),i))}function ME(s,e,t,i=null){const n="call"+ki(t),r=s.reduce(kT(n),i),o=r===jp,u=o?null:e[t](r);return ZN(s,t,u,o),u}const XN={buffered:1,currentTime:1,duration:1,muted:1,played:1,paused:1,seekable:1,volume:1,ended:1},QN={setCurrentTime:1,setMuted:1,setVolume:1},NE={play:1,pause:1};function kT(s){return(e,t)=>e===jp?jp:t[s]?t[s](e):e}function ZN(s,e,t,i){for(let n=s.length-1;n>=0;n--){const r=s[n];r[e]&&r[e](i,t)}}function JN(s){$p.hasOwnProperty(s.id())&&delete $p[s.id()]}function e3(s,e){const t=$p[s.id()];let i=null;if(t==null)return i=e(s),$p[s.id()]=[[e,i]],i;for(let n=0;n<t.length;n++){const[r,o]=t[n];r===e&&(i=o)}return i===null&&(i=e(s),t.push([e,i])),i}function cl(s={},e=[],t,i,n=[],r=!1){const[o,...u]=e;if(typeof o=="string")cl(s,Tl[o],t,i,n,r);else if(o){const c=e3(i,o);if(!c.setSource)return n.push(c),cl(s,u,t,i,n,r);c.setSource(Object.assign({},s),function(d,f){if(d)return cl(s,u,t,i,n,r);n.push(c),cl(f,s.type===f.type?u:Tl[f.type],t,i,n,r)})}else u.length?cl(s,u,t,i,n,r):r?t(s,n):cl(s,Tl["*"],t,i,n,!0)}const t3={opus:"video/ogg",ogv:"video/ogg",mp4:"video/mp4",mov:"video/mp4",m4v:"video/mp4",mkv:"video/x-matroska",m4a:"audio/mp4",mp3:"audio/mpeg",aac:"audio/aac",caf:"audio/x-caf",flac:"audio/flac",oga:"audio/ogg",wav:"audio/wav",m3u8:"application/x-mpegURL",mpd:"application/dash+xml",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",png:"image/png",svg:"image/svg+xml",webp:"image/webp"},Hp=function(s=""){const e=IT(s);return t3[e.toLowerCase()]||""},i3=(s,e)=>{if(!e)return"";if(s.cache_.source.src===e&&s.cache_.source.type)return s.cache_.source.type;const t=s.cache_.sources.filter(n=>n.src===e);if(t.length)return t[0].type;const i=s.$$("source");for(let n=0;n<i.length;n++){const r=i[n];if(r.type&&r.src&&r.src===e)return r.type}return Hp(e)},IC=function(s){if(Array.isArray(s)){let e=[];s.forEach(function(t){t=IC(t),Array.isArray(t)?e=e.concat(t):Mr(t)&&e.push(t)}),s=e}else typeof s=="string"&&s.trim()?s=[BE({src:s})]:Mr(s)&&typeof s.src=="string"&&s.src&&s.src.trim()?s=[BE(s)]:s=[];return s};function BE(s){if(!s.type){const e=Hp(s.src);e&&(s.type=e)}return s}var s3=`<svg xmlns="http://www.w3.org/2000/svg">
<defs>
<symbol viewBox="0 0 48 48" id="vjs-icon-play">
<path d="M16 10v28l22-14z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-pause">
<path d="M12 38h8V10h-8v28zm16-28v28h8V10h-8z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-audio">
<path d="M24 2C14.06 2 6 10.06 6 20v14c0 3.31 2.69 6 6 6h6V24h-8v-4c0-7.73 6.27-14 14-14s14 6.27 14 14v4h-8v16h6c3.31 0 6-2.69 6-6V20c0-9.94-8.06-18-18-18z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-captions">
<path d="M38 8H10c-2.21 0-4 1.79-4 4v24c0 2.21 1.79 4 4 4h28c2.21 0 4-1.79 4-4V12c0-2.21-1.79-4-4-4zM22 22h-3v-1h-4v6h4v-1h3v2a2 2 0 0 1-2 2h-6a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2zm14 0h-3v-1h-4v6h4v-1h3v2a2 2 0 0 1-2 2h-6a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-subtitles">
<path d="M40 8H8c-2.21 0-4 1.79-4 4v24c0 2.21 1.79 4 4 4h32c2.21 0 4-1.79 4-4V12c0-2.21-1.79-4-4-4zM8 24h8v4H8v-4zm20 12H8v-4h20v4zm12 0h-8v-4h8v4zm0-8H20v-4h20v4z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-fullscreen-enter">
<path d="M14 28h-4v10h10v-4h-6v-6zm-4-8h4v-6h6v-4H10v10zm24 14h-6v4h10V28h-4v6zm-6-24v4h6v6h4V10H28z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-fullscreen-exit">
<path d="M10 32h6v6h4V28H10v4zm6-16h-6v4h10V10h-4v6zm12 22h4v-6h6v-4H28v10zm4-22v-6h-4v10h10v-4h-6z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-play-circle">
<path d="M20 33l12-9-12-9v18zm4-29C12.95 4 4 12.95 4 24s8.95 20 20 20 20-8.95 20-20S35.05 4 24 4zm0 36c-8.82 0-16-7.18-16-16S15.18 8 24 8s16 7.18 16 16-7.18 16-16 16z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-volume-mute">
<path d="M33 24c0-3.53-2.04-6.58-5-8.05v4.42l4.91 4.91c.06-.42.09-.85.09-1.28zm5 0c0 1.88-.41 3.65-1.08 5.28l3.03 3.03C41.25 29.82 42 27 42 24c0-8.56-5.99-15.72-14-17.54v4.13c5.78 1.72 10 7.07 10 13.41zM8.55 6L6 8.55 15.45 18H6v12h8l10 10V26.55l8.51 8.51c-1.34 1.03-2.85 1.86-4.51 2.36v4.13a17.94 17.94 0 0 0 7.37-3.62L39.45 42 42 39.45l-18-18L8.55 6zM24 8l-4.18 4.18L24 16.36V8z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-volume-low">
<path d="M14 18v12h8l10 10V8L22 18h-8z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-volume-medium">
<path d="M37 24c0-3.53-2.04-6.58-5-8.05v16.11c2.96-1.48 5-4.53 5-8.06zm-27-6v12h8l10 10V8L18 18h-8z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-volume-high">
<path d="M6 18v12h8l10 10V8L14 18H6zm27 6c0-3.53-2.04-6.58-5-8.05v16.11c2.96-1.48 5-4.53 5-8.06zM28 6.46v4.13c5.78 1.72 10 7.07 10 13.41s-4.22 11.69-10 13.41v4.13c8.01-1.82 14-8.97 14-17.54S36.01 8.28 28 6.46z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-spinner">
<path d="M18.8 21l9.53-16.51C26.94 4.18 25.49 4 24 4c-4.8 0-9.19 1.69-12.64 4.51l7.33 12.69.11-.2zm24.28-3c-1.84-5.85-6.3-10.52-11.99-12.68L23.77 18h19.31zm.52 2H28.62l.58 1 9.53 16.5C41.99 33.94 44 29.21 44 24c0-1.37-.14-2.71-.4-4zm-26.53 4l-7.8-13.5C6.01 14.06 4 18.79 4 24c0 1.37.14 2.71.4 4h14.98l-2.31-4zM4.92 30c1.84 5.85 6.3 10.52 11.99 12.68L24.23 30H4.92zm22.54 0l-7.8 13.51c1.4.31 2.85.49 4.34.49 4.8 0 9.19-1.69 12.64-4.51L29.31 26.8 27.46 30z"></path>
</symbol>
<symbol viewBox="0 0 24 24" id="vjs-icon-hd">
<path d="M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-8 12H9.5v-2h-2v2H6V9h1.5v2.5h2V9H11v6zm2-6h4c.55 0 1 .45 1 1v4c0 .55-.45 1-1 1h-4V9zm1.5 4.5h2v-3h-2v3z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-chapters">
<path d="M6 26h4v-4H6v4zm0 8h4v-4H6v4zm0-16h4v-4H6v4zm8 8h28v-4H14v4zm0 8h28v-4H14v4zm0-20v4h28v-4H14z"></path>
</symbol>
<symbol viewBox="0 0 40 40" id="vjs-icon-downloading">
<path d="M18.208 36.875q-3.208-.292-5.979-1.729-2.771-1.438-4.812-3.729-2.042-2.292-3.188-5.229-1.146-2.938-1.146-6.23 0-6.583 4.334-11.416 4.333-4.834 10.833-5.5v3.166q-5.167.75-8.583 4.646Q6.25 14.75 6.25 19.958q0 5.209 3.396 9.104 3.396 3.896 8.562 4.646zM20 28.417L11.542 20l2.083-2.083 4.917 4.916v-11.25h2.916v11.25l4.875-4.916L28.417 20zm1.792 8.458v-3.167q1.833-.25 3.541-.958 1.709-.708 3.167-1.875l2.333 2.292q-1.958 1.583-4.25 2.541-2.291.959-4.791 1.167zm6.791-27.792q-1.541-1.125-3.25-1.854-1.708-.729-3.541-1.021V3.042q2.5.25 4.77 1.208 2.271.958 4.271 2.5zm4.584 21.584l-2.25-2.25q1.166-1.5 1.854-3.209.687-1.708.937-3.541h3.209q-.292 2.5-1.229 4.791-.938 2.292-2.521 4.209zm.541-12.417q-.291-1.833-.958-3.562-.667-1.73-1.833-3.188l2.375-2.208q1.541 1.916 2.458 4.208.917 2.292 1.167 4.75z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-file-download">
<path d="M10.8 40.55q-1.35 0-2.375-1T7.4 37.15v-7.7h3.4v7.7h26.35v-7.7h3.4v7.7q0 1.4-1 2.4t-2.4 1zM24 32.1L13.9 22.05l2.45-2.45 5.95 5.95V7.15h3.4v18.4l5.95-5.95 2.45 2.45z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-file-download-done">
<path d="M9.8 40.5v-3.45h28.4v3.45zm9.2-9.05L7.4 19.85l2.45-2.35L19 26.65l19.2-19.2 2.4 2.4z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-file-download-off">
<path d="M4.9 4.75L43.25 43.1 41 45.3l-4.75-4.75q-.05.05-.075.025-.025-.025-.075-.025H10.8q-1.35 0-2.375-1T7.4 37.15v-7.7h3.4v7.7h22.05l-7-7-1.85 1.8L13.9 21.9l1.85-1.85L2.7 7zm26.75 14.7l2.45 2.45-3.75 3.8-2.45-2.5zM25.7 7.15V21.1l-3.4-3.45V7.15z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-share">
<path d="M36 32.17c-1.52 0-2.89.59-3.93 1.54L17.82 25.4c.11-.45.18-.92.18-1.4s-.07-.95-.18-1.4l14.1-8.23c1.07 1 2.5 1.62 4.08 1.62 3.31 0 6-2.69 6-6s-2.69-6-6-6-6 2.69-6 6c0 .48.07.95.18 1.4l-14.1 8.23c-1.07-1-2.5-1.62-4.08-1.62-3.31 0-6 2.69-6 6s2.69 6 6 6c1.58 0 3.01-.62 4.08-1.62l14.25 8.31c-.1.42-.16.86-.16 1.31A5.83 5.83 0 1 0 36 32.17z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-cog">
<path d="M38.86 25.95c.08-.64.14-1.29.14-1.95s-.06-1.31-.14-1.95l4.23-3.31c.38-.3.49-.84.24-1.28l-4-6.93c-.25-.43-.77-.61-1.22-.43l-4.98 2.01c-1.03-.79-2.16-1.46-3.38-1.97L29 4.84c-.09-.47-.5-.84-1-.84h-8c-.5 0-.91.37-.99.84l-.75 5.3a14.8 14.8 0 0 0-3.38 1.97L9.9 10.1a1 1 0 0 0-1.22.43l-4 6.93c-.25.43-.14.97.24 1.28l4.22 3.31C9.06 22.69 9 23.34 9 24s.06 1.31.14 1.95l-4.22 3.31c-.38.3-.49.84-.24 1.28l4 6.93c.25.43.77.61 1.22.43l4.98-2.01c1.03.79 2.16 1.46 3.38 1.97l.75 5.3c.08.47.49.84.99.84h8c.5 0 .91-.37.99-.84l.75-5.3a14.8 14.8 0 0 0 3.38-1.97l4.98 2.01a1 1 0 0 0 1.22-.43l4-6.93c.25-.43.14-.97-.24-1.28l-4.22-3.31zM24 31c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-square">
<path d="M36 8H12c-2.21 0-4 1.79-4 4v24c0 2.21 1.79 4 4 4h24c2.21 0 4-1.79 4-4V12c0-2.21-1.79-4-4-4zm0 28H12V12h24v24z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-circle">
<circle cx="24" cy="24" r="20"></circle>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-circle-outline">
<path d="M24 4C12.95 4 4 12.95 4 24s8.95 20 20 20 20-8.95 20-20S35.05 4 24 4zm0 36c-8.82 0-16-7.18-16-16S15.18 8 24 8s16 7.18 16 16-7.18 16-16 16z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-circle-inner-circle">
<path d="M24 4C12.97 4 4 12.97 4 24s8.97 20 20 20 20-8.97 20-20S35.03 4 24 4zm0 36c-8.82 0-16-7.18-16-16S15.18 8 24 8s16 7.18 16 16-7.18 16-16 16zm6-16c0 3.31-2.69 6-6 6s-6-2.69-6-6 2.69-6 6-6 6 2.69 6 6z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-cancel">
<path d="M24 4C12.95 4 4 12.95 4 24s8.95 20 20 20 20-8.95 20-20S35.05 4 24 4zm10 27.17L31.17 34 24 26.83 16.83 34 14 31.17 21.17 24 14 16.83 16.83 14 24 21.17 31.17 14 34 16.83 26.83 24 34 31.17z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-replay">
<path d="M24 10V2L14 12l10 10v-8c6.63 0 12 5.37 12 12s-5.37 12-12 12-12-5.37-12-12H8c0 8.84 7.16 16 16 16s16-7.16 16-16-7.16-16-16-16z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-repeat">
<path d="M14 14h20v6l8-8-8-8v6H10v12h4v-8zm20 20H14v-6l-8 8 8 8v-6h24V26h-4v8z"></path>
</symbol>
<symbol viewBox="0 96 48 48" id="vjs-icon-replay-5">
<path d="M17.689 98l-8.697 8.696 8.697 8.697 2.486-2.485-4.32-4.319h1.302c4.93 0 9.071 1.722 12.424 5.165 3.352 3.443 5.029 7.638 5.029 12.584h3.55c0-2.958-.553-5.73-1.658-8.313-1.104-2.583-2.622-4.841-4.555-6.774-1.932-1.932-4.19-3.45-6.773-4.555-2.584-1.104-5.355-1.657-8.313-1.657H15.5l4.615-4.615zm-8.08 21.659v13.861h11.357v5.008H9.609V143h12.7c.834 0 1.55-.298 2.146-.894.596-.597.895-1.31.895-2.145v-7.781c0-.835-.299-1.55-.895-2.147a2.929 2.929 0 0 0-2.147-.894h-8.227v-5.096H25.35v-4.384z"></path>
</symbol>
<symbol viewBox="0 96 48 48" id="vjs-icon-replay-10">
<path d="M42.315 125.63c0-4.997-1.694-9.235-5.08-12.713-3.388-3.479-7.571-5.218-12.552-5.218h-1.315l4.363 4.363-2.51 2.51-8.787-8.786L25.221 97l2.45 2.45-4.662 4.663h1.375c2.988 0 5.788.557 8.397 1.673 2.61 1.116 4.892 2.65 6.844 4.602 1.953 1.953 3.487 4.234 4.602 6.844 1.116 2.61 1.674 5.41 1.674 8.398zM8.183 142v-19.657H3.176V117.8h9.643V142zm13.63 0c-1.156 0-2.127-.393-2.912-1.178-.778-.778-1.168-1.746-1.168-2.902v-16.04c0-1.156.393-2.127 1.178-2.912.779-.779 1.746-1.168 2.902-1.168h7.696c1.156 0 2.126.392 2.911 1.177.779.78 1.168 1.747 1.168 2.903v16.04c0 1.156-.392 2.127-1.177 2.912-.779.779-1.746 1.168-2.902 1.168zm.556-4.636h6.583v-15.02H22.37z"></path>
</symbol>
<symbol viewBox="0 96 48 48" id="vjs-icon-replay-30">
<path d="M26.047 97l-8.733 8.732 8.733 8.733 2.496-2.494-4.336-4.338h1.307c4.95 0 9.108 1.73 12.474 5.187 3.367 3.458 5.051 7.668 5.051 12.635h3.565c0-2.97-.556-5.751-1.665-8.346-1.109-2.594-2.633-4.862-4.574-6.802-1.94-1.941-4.208-3.466-6.803-4.575-2.594-1.109-5.375-1.664-8.345-1.664H23.85l4.634-4.634zM2.555 117.531v4.688h10.297v5.25H5.873v4.687h6.979v5.156H2.555V142H13.36c1.061 0 1.95-.395 2.668-1.186.718-.79 1.076-1.772 1.076-2.94v-16.218c0-1.168-.358-2.149-1.076-2.94-.717-.79-1.607-1.185-2.668-1.185zm22.482.14c-1.149 0-2.11.39-2.885 1.165-.78.78-1.172 1.744-1.172 2.893v15.943c0 1.149.388 2.11 1.163 2.885.78.78 1.745 1.172 2.894 1.172h7.649c1.148 0 2.11-.388 2.884-1.163.78-.78 1.17-1.745 1.17-2.894v-15.943c0-1.15-.386-2.111-1.16-2.885-.78-.78-1.746-1.172-2.894-1.172zm.553 4.518h6.545v14.93H25.59z"></path>
</symbol>
<symbol viewBox="0 96 48 48" id="vjs-icon-forward-5">
<path d="M29.508 97l-2.431 2.43 4.625 4.625h-1.364c-2.965 0-5.742.554-8.332 1.66-2.589 1.107-4.851 2.629-6.788 4.566-1.937 1.937-3.458 4.2-4.565 6.788-1.107 2.59-1.66 5.367-1.66 8.331h3.557c0-4.957 1.68-9.16 5.04-12.611 3.36-3.45 7.51-5.177 12.451-5.177h1.304l-4.326 4.33 2.49 2.49 8.715-8.716zm-9.783 21.61v13.89h11.382v5.018H19.725V142h12.727a2.93 2.93 0 0 0 2.15-.896 2.93 2.93 0 0 0 .896-2.15v-7.798c0-.837-.299-1.554-.896-2.152a2.93 2.93 0 0 0-2.15-.896h-8.245V123h11.29v-4.392z"></path>
</symbol>
<symbol viewBox="0 96 48 48" id="vjs-icon-forward-10">
<path d="M23.119 97l-2.386 2.383 4.538 4.538h-1.339c-2.908 0-5.633.543-8.173 1.63-2.54 1.085-4.76 2.577-6.66 4.478-1.9 1.9-3.392 4.12-4.478 6.66-1.085 2.54-1.629 5.264-1.629 8.172h3.49c0-4.863 1.648-8.986 4.944-12.372 3.297-3.385 7.368-5.078 12.216-5.078h1.279l-4.245 4.247 2.443 2.442 8.55-8.55zm-9.52 21.45v4.42h4.871V142h4.513v-23.55zm18.136 0c-1.125 0-2.066.377-2.824 1.135-.764.764-1.148 1.709-1.148 2.834v15.612c0 1.124.38 2.066 1.139 2.824.764.764 1.708 1.145 2.833 1.145h7.489c1.125 0 2.066-.378 2.824-1.136.764-.764 1.145-1.709 1.145-2.833v-15.612c0-1.125-.378-2.067-1.136-2.825-.764-.764-1.708-1.145-2.833-1.145zm.54 4.42h6.408v14.617h-6.407z"></path>
</symbol>
<symbol viewBox="0 96 48 48" id="vjs-icon-forward-30">
<path d="M25.549 97l-2.437 2.434 4.634 4.635H26.38c-2.97 0-5.753.555-8.347 1.664-2.594 1.109-4.861 2.633-6.802 4.574-1.94 1.94-3.465 4.207-4.574 6.802-1.109 2.594-1.664 5.377-1.664 8.347h3.565c0-4.967 1.683-9.178 5.05-12.636 3.366-3.458 7.525-5.187 12.475-5.187h1.307l-4.335 4.338 2.495 2.494 8.732-8.732zm-11.553 20.53v4.689h10.297v5.249h-6.978v4.688h6.978v5.156H13.996V142h10.808c1.06 0 1.948-.395 2.666-1.186.718-.79 1.077-1.771 1.077-2.94v-16.217c0-1.169-.36-2.15-1.077-2.94-.718-.79-1.605-1.186-2.666-1.186zm21.174.168c-1.149 0-2.11.389-2.884 1.163-.78.78-1.172 1.745-1.172 2.894v15.942c0 1.15.388 2.11 1.162 2.885.78.78 1.745 1.17 2.894 1.17h7.649c1.149 0 2.11-.386 2.885-1.16.78-.78 1.17-1.746 1.17-2.895v-15.942c0-1.15-.387-2.11-1.161-2.885-.78-.78-1.745-1.172-2.894-1.172zm.552 4.516h6.542v14.931h-6.542z"></path>
</symbol>
<symbol viewBox="0 0 512 512" id="vjs-icon-audio-description">
<g fill-rule="evenodd"><path d="M227.29 381.351V162.993c50.38-1.017 89.108-3.028 117.631 17.126 27.374 19.342 48.734 56.965 44.89 105.325-4.067 51.155-41.335 94.139-89.776 98.475-24.085 2.155-71.972 0-71.972 0s-.84-1.352-.773-2.568m48.755-54.804c31.43 1.26 53.208-16.633 56.495-45.386 4.403-38.51-21.188-63.552-58.041-60.796v103.612c-.036 1.466.575 2.22 1.546 2.57"></path><path d="M383.78 381.328c13.336 3.71 17.387-11.06 23.215-21.408 12.722-22.571 22.294-51.594 22.445-84.774.221-47.594-18.343-82.517-35.6-106.182h-8.51c-.587 3.874 2.226 7.315 3.865 10.276 13.166 23.762 25.367 56.553 25.54 94.194.2 43.176-14.162 79.278-30.955 107.894"></path><path d="M425.154 381.328c13.336 3.71 17.384-11.061 23.215-21.408 12.721-22.571 22.291-51.594 22.445-84.774.221-47.594-18.343-82.517-35.6-106.182h-8.511c-.586 3.874 2.226 7.315 3.866 10.276 13.166 23.762 25.367 56.553 25.54 94.194.2 43.176-14.162 79.278-30.955 107.894"></path><path d="M466.26 381.328c13.337 3.71 17.385-11.061 23.216-21.408 12.722-22.571 22.292-51.594 22.445-84.774.221-47.594-18.343-82.517-35.6-106.182h-8.51c-.587 3.874 2.225 7.315 3.865 10.276 13.166 23.762 25.367 56.553 25.54 94.194.2 43.176-14.162 79.278-30.955 107.894M4.477 383.005H72.58l18.573-28.484 64.169-.135s.065 19.413.065 28.62h48.756V160.307h-58.816c-5.653 9.537-140.85 222.697-140.85 222.697zm152.667-145.282v71.158l-40.453-.27 40.453-70.888z"></path></g>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-next-item">
<path d="M12 36l17-12-17-12v24zm20-24v24h4V12h-4z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-previous-item">
<path d="M12 12h4v24h-4zm7 12l17 12V12z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-shuffle">
<path d="M21.17 18.34L10.83 8 8 10.83l10.34 10.34 2.83-2.83zM29 8l4.09 4.09L8 37.17 10.83 40l25.09-25.09L40 19V8H29zm.66 18.83l-2.83 2.83 6.26 6.26L29 40h11V29l-4.09 4.09-6.25-6.26z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-cast">
<path d="M42 6H6c-2.21 0-4 1.79-4 4v6h4v-6h36v28H28v4h14c2.21 0 4-1.79 4-4V10c0-2.21-1.79-4-4-4zM2 36v6h6c0-3.31-2.69-6-6-6zm0-8v4c5.52 0 10 4.48 10 10h4c0-7.73-6.27-14-14-14zm0-8v4c9.94 0 18 8.06 18 18h4c0-12.15-9.85-22-22-22z"></path>
</symbol>
<symbol viewBox="0 0 48 48" id="vjs-icon-picture-in-picture-enter">
<path d="M38 22H22v11.99h16V22zm8 16V9.96C46 7.76 44.2 6 42 6H6C3.8 6 2 7.76 2 9.96V38c0 2.2 1.8 4 4 4h36c2.2 0 4-1.8 4-4zm-4 .04H6V9.94h36v28.1z"></path>
</symbol>
<symbol viewBox="0 0 22 18" id="vjs-icon-picture-in-picture-exit">
<path d="M18 4H4v10h14V4zm4 12V1.98C22 .88 21.1 0 20 0H2C.9 0 0 .88 0 1.98V16c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2zm-2 .02H2V1.97h18v14.05z"></path>
<path fill="none" d="M-1-3h24v24H-1z"></path>
</symbol>
<symbol viewBox="0 0 1792 1792" id="vjs-icon-facebook">
<path d="M1343 12v264h-157q-86 0-116 36t-30 108v189h293l-39 296h-254v759H734V905H479V609h255V391q0-186 104-288.5T1115 0q147 0 228 12z"></path>
</symbol>
<symbol viewBox="0 0 1792 1792" id="vjs-icon-linkedin">
<path d="M477 625v991H147V625h330zm21-306q1 73-50.5 122T312 490h-2q-82 0-132-49t-50-122q0-74 51.5-122.5T314 148t133 48.5T498 319zm1166 729v568h-329v-530q0-105-40.5-164.5T1168 862q-63 0-105.5 34.5T999 982q-11 30-11 81v553H659q2-399 2-647t-1-296l-1-48h329v144h-2q20-32 41-56t56.5-52 87-43.5T1285 602q171 0 275 113.5t104 332.5z"></path>
</symbol>
<symbol viewBox="0 0 1200 1227" id="vjs-icon-twitter">
<path d="M714.163 519.284L1160.89 0H1055.03L667.137 450.887L357.328 0H0L468.492 681.821L0 1226.37H105.866L515.491 750.218L842.672 1226.37H1200L714.137 519.284H714.163ZM569.165 687.828L521.697 619.934L144.011 79.6944H306.615L611.412 515.685L658.88 583.579L1055.08 1150.3H892.476L569.165 687.854V687.828Z"/>
</symbol>
<symbol viewBox="0 0 1792 1792" id="vjs-icon-tumblr">
<path d="M1328 1329l80 237q-23 35-111 66t-177 32q-104 2-190.5-26T787 1564t-95-106-55.5-120-16.5-118V676H452V461q72-26 129-69.5t91-90 58-102 34-99T779 12q1-5 4.5-8.5T791 0h244v424h333v252h-334v518q0 30 6.5 56t22.5 52.5 49.5 41.5 81.5 14q78-2 134-29z"></path>
</symbol>
<symbol viewBox="0 0 1792 1792" id="vjs-icon-pinterest">
<path d="M1664 896q0 209-103 385.5T1281.5 1561 896 1664q-111 0-218-32 59-93 78-164 9-34 54-211 20 39 73 67.5t114 28.5q121 0 216-68.5t147-188.5 52-270q0-114-59.5-214T1180 449t-255-63q-105 0-196 29t-154.5 77-109 110.5-67 129.5T377 866q0 104 40 183t117 111q30 12 38-20 2-7 8-31t8-30q6-23-11-43-51-61-51-151 0-151 104.5-259.5T904 517q151 0 235.5 82t84.5 213q0 170-68.5 289T980 1220q-61 0-98-43.5T859 1072q8-35 26.5-93.5t30-103T927 800q0-50-27-83t-77-33q-62 0-105 57t-43 142q0 73 25 122l-99 418q-17 70-13 177-206-91-333-281T128 896q0-209 103-385.5T510.5 231 896 128t385.5 103T1561 510.5 1664 896z"></path>
</symbol>
</defs>
</svg>`;const FE=Mp?10009:Np?461:8,_u={codes:{play:415,pause:19,ff:417,rw:412,back:FE},names:{415:"play",19:"pause",417:"ff",412:"rw",[FE]:"back"},isEventKey(s,e){return e=e.toLowerCase(),!!(this.names[s.keyCode]&&this.names[s.keyCode]===e)},getEventName(s){if(this.names[s.keyCode])return this.names[s.keyCode];if(this.codes[s.code]){const e=this.codes[s.code];return this.names[e]}return null}},UE=5;class n3 extends En{constructor(e){super(),this.player_=e,this.focusableComponents=[],this.isListening_=!1,this.isPaused_=!1,this.onKeyDown_=this.onKeyDown_.bind(this),this.lastFocusedComponent_=null}start(){this.isListening_||(this.player_.on("keydown",this.onKeyDown_),this.player_.on("modalKeydown",this.onKeyDown_),this.player_.on("loadedmetadata",()=>{this.focus(this.updateFocusableComponents()[0])}),this.player_.on("modalclose",()=>{this.refocusComponent()}),this.player_.on("focusin",this.handlePlayerFocus_.bind(this)),this.player_.on("focusout",this.handlePlayerBlur_.bind(this)),this.isListening_=!0,this.player_.errorDisplay&&this.player_.errorDisplay.on("aftermodalfill",()=>{this.updateFocusableComponents(),this.focusableComponents.length&&(this.focusableComponents.length>1?this.focusableComponents[1].focus():this.focusableComponents[0].focus())}))}stop(){this.player_.off("keydown",this.onKeyDown_),this.isListening_=!1}onKeyDown_(e){const t=e.originalEvent?e.originalEvent:e;if(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(t.key)){if(this.isPaused_)return;t.preventDefault();const i=t.key.substring(5).toLowerCase();this.move(i)}else if(_u.isEventKey(t,"play")||_u.isEventKey(t,"pause")||_u.isEventKey(t,"ff")||_u.isEventKey(t,"rw")){t.preventDefault();const i=_u.getEventName(t);this.performMediaAction_(i)}else _u.isEventKey(t,"Back")&&e.target&&typeof e.target.closeable=="function"&&e.target.closeable()&&(t.preventDefault(),e.target.close())}performMediaAction_(e){if(this.player_)switch(e){case"play":this.player_.paused()&&this.player_.play();break;case"pause":this.player_.paused()||this.player_.pause();break;case"ff":this.userSeek_(this.player_.currentTime()+UE);break;case"rw":this.userSeek_(this.player_.currentTime()-UE);break}}userSeek_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&this.player_.liveTracker.nextSeekedFromUser(),this.player_.currentTime(e)}pause(){this.isPaused_=!0}resume(){this.isPaused_=!1}handlePlayerBlur_(e){const t=e.relatedTarget;let i=null;const n=this.getCurrentComponent(e.target);t&&(i=!!t.closest(".video-js"),t.classList.contains("vjs-text-track-settings")&&!this.isPaused_&&this.searchForTrackSelect_()),(!e.currentTarget.contains(e.relatedTarget)&&!i||!t)&&(n&&n.name()==="CloseButton"?this.refocusComponent():(this.pause(),n&&n.el()&&(this.lastFocusedComponent_=n)))}handlePlayerFocus_(){this.getCurrentComponent()&&this.getCurrentComponent().getIsFocusable()&&this.resume()}updateFocusableComponents(){const e=this.player_,t=[];function i(n){for(const r of n)r.hasOwnProperty("el_")&&r.getIsFocusable()&&r.getIsAvailableToBeFocused(r.el())&&t.push(r),r.hasOwnProperty("children_")&&r.children_.length>0&&i(r.children_)}return e.children_.forEach(n=>{if(n.hasOwnProperty("el_"))if(n.getIsFocusable&&n.getIsAvailableToBeFocused&&n.getIsFocusable()&&n.getIsAvailableToBeFocused(n.el())){t.push(n);return}else n.hasOwnProperty("children_")&&n.children_.length>0?i(n.children_):n.hasOwnProperty("items")&&n.items.length>0?i(n.items):this.findSuitableDOMChild(n)&&t.push(n);if(n.name_==="ErrorDisplay"&&n.opened_){const r=n.el_.querySelector(".vjs-errors-ok-button-container");r&&r.querySelectorAll("button").forEach((u,c)=>{t.push({name:()=>"ModalButton"+(c+1),el:()=>u,getPositions:()=>{const d=u.getBoundingClientRect(),f={x:d.x,y:d.y,width:d.width,height:d.height,top:d.top,right:d.right,bottom:d.bottom,left:d.left},m={x:d.left+d.width/2,y:d.top+d.height/2,width:0,height:0,top:d.top+d.height/2,right:d.left+d.width/2,bottom:d.top+d.height/2,left:d.left+d.width/2};return{boundingClientRect:f,center:m}},getIsAvailableToBeFocused:()=>!0,getIsFocusable:d=>!0,focus:()=>u.focus()})})}}),this.focusableComponents=t,this.focusableComponents}findSuitableDOMChild(e){function t(i){if(e.getIsFocusable(i)&&e.getIsAvailableToBeFocused(i))return i;for(let n=0;n<i.children.length;n++){const r=i.children[n],o=t(r);if(o)return o}return null}return e.el()?t(e.el()):null}getCurrentComponent(e){this.updateFocusableComponents();const t=e||document.activeElement;if(this.focusableComponents.length){for(const i of this.focusableComponents)if(i.el()===t)return i}}add(e){const t=[...this.focusableComponents];e.hasOwnProperty("el_")&&e.getIsFocusable()&&e.getIsAvailableToBeFocused(e.el())&&t.push(e),this.focusableComponents=t,this.trigger({type:"focusableComponentsChanged",focusableComponents:this.focusableComponents})}remove(e){for(let t=0;t<this.focusableComponents.length;t++)if(this.focusableComponents[t].name()===e.name()){this.focusableComponents.splice(t,1),this.trigger({type:"focusableComponentsChanged",focusableComponents:this.focusableComponents});return}}clear(){this.focusableComponents.length>0&&(this.focusableComponents=[],this.trigger({type:"focusableComponentsChanged",focusableComponents:this.focusableComponents}))}move(e){const t=this.getCurrentComponent();if(!t)return;const i=t.getPositions(),n=this.focusableComponents.filter(o=>o!==t&&this.isInDirection_(i.boundingClientRect,o.getPositions().boundingClientRect,e)),r=this.findBestCandidate_(i.center,n,e);r?this.focus(r):this.trigger({type:"endOfFocusableComponents",direction:e,focusedComponent:t})}findBestCandidate_(e,t,i){let n=1/0,r=null;for(const o of t){const u=o.getPositions().center,c=this.calculateDistance_(e,u,i);c<n&&(n=c,r=o)}return r}isInDirection_(e,t,i){switch(i){case"right":return t.left>=e.right;case"left":return t.right<=e.left;case"down":return t.top>=e.bottom;case"up":return t.bottom<=e.top;default:return!1}}refocusComponent(){if(this.lastFocusedComponent_){this.player_.userActive()||this.player_.userActive(!0),this.updateFocusableComponents();for(let e=0;e<this.focusableComponents.length;e++)if(this.focusableComponents[e].name()===this.lastFocusedComponent_.name()){this.focus(this.focusableComponents[e]);return}}else this.focus(this.updateFocusableComponents()[0])}focus(e){typeof e=="object"&&(e.getIsAvailableToBeFocused(e.el())?e.focus():this.findSuitableDOMChild(e)&&this.findSuitableDOMChild(e).focus())}calculateDistance_(e,t,i){const n=Math.abs(e.x-t.x),r=Math.abs(e.y-t.y);let o;switch(i){case"right":case"left":o=n+r*100;break;case"up":o=r*2+n*.5;break;case"down":o=r*5+n;break;default:o=n+r}return o}searchForTrackSelect_(){const e=this;for(const t of e.updateFocusableComponents())if(t.constructor.name==="TextTrackSelect"){e.focus(t);break}}}class r3 extends ke{constructor(e,t,i){const n=si({createEl:!1},t);if(super(e,n,i),!t.playerOptions.sources||t.playerOptions.sources.length===0)for(let r=0,o=t.playerOptions.techOrder;r<o.length;r++){const u=ki(o[r]);let c=bt.getTech(u);if(u||(c=ke.getComponent(u)),c&&c.isSupported()){e.loadTech_(u);break}}else e.src(t.playerOptions.sources)}}ke.registerComponent("MediaLoader",r3);class Bm extends ke{constructor(e,t){super(e,t),this.options_.controlText&&this.controlText(this.options_.controlText),this.handleMouseOver_=i=>this.handleMouseOver(i),this.handleMouseOut_=i=>this.handleMouseOut(i),this.handleClick_=i=>this.handleClick(i),this.handleKeyDown_=i=>this.handleKeyDown(i),this.emitTapEvents(),this.enable()}createEl(e="div",t={},i={}){t=Object.assign({className:this.buildCSSClass(),tabIndex:0},t),e==="button"&&Dt.error(`Creating a ClickableComponent with an HTML element of ${e} is not supported; use a Button instead.`),i=Object.assign({role:"button"},i),this.tabIndex_=t.tabIndex;const n=dt(e,t,i);return this.player_.options_.experimentalSvgIcons||n.appendChild(dt("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),this.createControlTextEl(n),n}dispose(){this.controlTextEl_=null,super.dispose()}createControlTextEl(e){return this.controlTextEl_=dt("span",{className:"vjs-control-text"},{"aria-live":"polite"}),e&&e.appendChild(this.controlTextEl_),this.controlText(this.controlText_,e),this.controlTextEl_}controlText(e,t=this.el()){if(e===void 0)return this.controlText_||"Need Text";const i=this.localize(e);this.controlText_=e,Co(this.controlTextEl_,i),!this.nonIconControl&&!this.player_.options_.noUITitleAttributes&&t.setAttribute("title",i)}buildCSSClass(){return`vjs-control vjs-button ${super.buildCSSClass()}`}enable(){this.enabled_||(this.enabled_=!0,this.removeClass("vjs-disabled"),this.el_.setAttribute("aria-disabled","false"),typeof this.tabIndex_<"u"&&this.el_.setAttribute("tabIndex",this.tabIndex_),this.on(["tap","click"],this.handleClick_),this.on("keydown",this.handleKeyDown_))}disable(){this.enabled_=!1,this.addClass("vjs-disabled"),this.el_.setAttribute("aria-disabled","true"),typeof this.tabIndex_<"u"&&this.el_.removeAttribute("tabIndex"),this.off("mouseover",this.handleMouseOver_),this.off("mouseout",this.handleMouseOut_),this.off(["tap","click"],this.handleClick_),this.off("keydown",this.handleKeyDown_)}handleLanguagechange(){this.controlText(this.controlText_)}handleClick(e){this.options_.clickHandler&&this.options_.clickHandler.call(this,arguments)}handleKeyDown(e){e.key===" "||e.key==="Enter"?(e.preventDefault(),e.stopPropagation(),this.trigger("click")):super.handleKeyDown(e)}}ke.registerComponent("ClickableComponent",Bm);class Dv extends Bm{constructor(e,t){super(e,t),this.update(),this.update_=i=>this.update(i),e.on("posterchange",this.update_)}dispose(){this.player().off("posterchange",this.update_),super.dispose()}createEl(){return dt("div",{className:"vjs-poster"})}crossOrigin(e){if(typeof e>"u")return this.$("img")?this.$("img").crossOrigin:this.player_.tech_&&this.player_.tech_.isReady_?this.player_.crossOrigin():this.player_.options_.crossOrigin||this.player_.options_.crossorigin||null;if(e!==null&&e!=="anonymous"&&e!=="use-credentials"){this.player_.log.warn(`crossOrigin must be null, "anonymous" or "use-credentials", given "${e}"`);return}this.$("img")&&(this.$("img").crossOrigin=e)}update(e){const t=this.player().poster();this.setSrc(t),t?this.show():this.hide()}setSrc(e){if(!e){this.el_.textContent="";return}this.$("img")||this.el_.appendChild(dt("picture",{className:"vjs-poster",tabIndex:-1},{},dt("img",{loading:"lazy",crossOrigin:this.crossOrigin()},{alt:""}))),this.$("img").src=e}handleClick(e){this.player_.controls()&&(this.player_.tech(!0)&&this.player_.tech(!0).focus(),this.player_.paused()?wr(this.player_.play()):this.player_.pause())}}Dv.prototype.crossorigin=Dv.prototype.crossOrigin;ke.registerComponent("PosterImage",Dv);const On="#222",$E="#ccc",a3={monospace:"monospace",sansSerif:"sans-serif",serif:"serif",monospaceSansSerif:'"Andale Mono", "Lucida Console", monospace',monospaceSerif:'"Courier New", monospace',proportionalSansSerif:"sans-serif",proportionalSerif:"serif",casual:'"Comic Sans MS", Impact, fantasy',script:'"Monotype Corsiva", cursive',smallcaps:'"Andale Mono", "Lucida Console", monospace, sans-serif'};function Ey(s,e){let t;if(s.length===4)t=s[1]+s[1]+s[2]+s[2]+s[3]+s[3];else if(s.length===7)t=s.slice(1);else throw new Error("Invalid color code provided, "+s+"; must be formatted as e.g. #f0e or #f604e2.");return"rgba("+parseInt(t.slice(0,2),16)+","+parseInt(t.slice(2,4),16)+","+parseInt(t.slice(4,6),16)+","+e+")"}function br(s,e,t){try{s.style[e]=t}catch{return}}function jE(s){return s?`${s}px`:""}class o3 extends ke{constructor(e,t,i){super(e,t,i);const n=o=>this.updateDisplay(o),r=o=>{this.updateDisplayOverlay(),this.updateDisplay(o)};e.on("loadstart",o=>this.toggleDisplay(o)),e.on("useractive",n),e.on("userinactive",n),e.on("texttrackchange",n),e.on("loadedmetadata",o=>{this.updateDisplayOverlay(),this.preselectTrack(o)}),e.ready(hi(this,function(){if(e.tech_&&e.tech_.featuresNativeTextTracks){this.hide();return}e.on("fullscreenchange",r),e.on("playerresize",r);const o=ne.screen.orientation||ne,u=ne.screen.orientation?"change":"orientationchange";o.addEventListener(u,r),e.on("dispose",()=>o.removeEventListener(u,r));const c=this.options_.playerOptions.tracks||[];for(let d=0;d<c.length;d++)this.player_.addRemoteTextTrack(c[d],!0);this.preselectTrack()}))}preselectTrack(){const e={captions:1,subtitles:1},t=this.player_.textTracks(),i=this.player_.cache_.selectedLanguage;let n,r,o;for(let u=0;u<t.length;u++){const c=t[u];i&&i.enabled&&i.language&&i.language===c.language&&c.kind in e?c.kind===i.kind?o=c:o||(o=c):i&&!i.enabled?(o=null,n=null,r=null):c.default&&(c.kind==="descriptions"&&!n?n=c:c.kind in e&&!r&&(r=c))}o?o.mode="showing":r?r.mode="showing":n&&(n.mode="showing")}toggleDisplay(){this.player_.tech_&&this.player_.tech_.featuresNativeTextTracks?this.hide():this.show()}createEl(){return super.createEl("div",{className:"vjs-text-track-display"},{translate:"yes","aria-live":"off","aria-atomic":"true"})}clearDisplay(){typeof ne.WebVTT=="function"&&ne.WebVTT.processCues(ne,[],this.el_)}updateDisplay(){const e=this.player_.textTracks(),t=this.options_.allowMultipleShowingTracks;if(this.clearDisplay(),t){const o=[];for(let u=0;u<e.length;++u){const c=e[u];c.mode==="showing"&&o.push(c)}this.updateForTrack(o);return}let i=null,n=null,r=e.length;for(;r--;){const o=e[r];o.mode==="showing"&&(o.kind==="descriptions"?i=o:n=o)}if(n?(this.getAttribute("aria-live")!=="off"&&this.setAttribute("aria-live","off"),this.updateForTrack(n)):i&&(this.getAttribute("aria-live")!=="assertive"&&this.setAttribute("aria-live","assertive"),this.updateForTrack(i)),!ne.CSS.supports("inset","10px")){const o=this.el_,u=o.querySelectorAll(".vjs-text-track-cue"),c=this.player_.controlBar.el_.getBoundingClientRect().height,d=this.player_.el_.getBoundingClientRect().height;o.style="",br(o,"position","relative"),br(o,"height",d-c+"px"),br(o,"top","unset"),Bp?br(o,"bottom",d+"px"):br(o,"bottom","0px"),u.length>0&&u.forEach(f=>{if(f.style.inset){const m=f.style.inset.split(" ");m.length===3&&Object.assign(f.style,{top:m[0],right:m[1],bottom:m[2],left:"unset"})}})}}updateDisplayOverlay(){if(!this.player_.videoHeight()||!ne.CSS.supports("inset-inline: 10px"))return;const e=this.player_.currentWidth(),t=this.player_.currentHeight(),i=e/t,n=this.player_.videoWidth()/this.player_.videoHeight();let r=0,o=0;Math.abs(i-n)>.1&&(i>n?r=Math.round((e-t*n)/2):o=Math.round((t-e/n)/2)),br(this.el_,"insetInline",jE(r)),br(this.el_,"insetBlock",jE(o))}updateDisplayState(e){const t=this.player_.textTrackSettings.getValues(),i=e.activeCues;let n=i.length;for(;n--;){const r=i[n];if(!r)continue;const o=r.displayState;if(t.color&&(o.firstChild.style.color=t.color),t.textOpacity&&br(o.firstChild,"color",Ey(t.color||"#fff",t.textOpacity)),t.backgroundColor&&(o.firstChild.style.backgroundColor=t.backgroundColor),t.backgroundOpacity&&br(o.firstChild,"backgroundColor",Ey(t.backgroundColor||"#000",t.backgroundOpacity)),t.windowColor&&(t.windowOpacity?br(o,"backgroundColor",Ey(t.windowColor,t.windowOpacity)):o.style.backgroundColor=t.windowColor),t.edgeStyle&&(t.edgeStyle==="dropshadow"?o.firstChild.style.textShadow=`2px 2px 3px ${On}, 2px 2px 4px ${On}, 2px 2px 5px ${On}`:t.edgeStyle==="raised"?o.firstChild.style.textShadow=`1px 1px ${On}, 2px 2px ${On}, 3px 3px ${On}`:t.edgeStyle==="depressed"?o.firstChild.style.textShadow=`1px 1px ${$E}, 0 1px ${$E}, -1px -1px ${On}, 0 -1px ${On}`:t.edgeStyle==="uniform"&&(o.firstChild.style.textShadow=`0 0 4px ${On}, 0 0 4px ${On}, 0 0 4px ${On}, 0 0 4px ${On}`)),t.fontPercent&&t.fontPercent!==1){const u=ne.parseFloat(o.style.fontSize);o.style.fontSize=u*t.fontPercent+"px",o.style.height="auto",o.style.top="auto"}t.fontFamily&&t.fontFamily!=="default"&&(t.fontFamily==="small-caps"?o.firstChild.style.fontVariant="small-caps":o.firstChild.style.fontFamily=a3[t.fontFamily])}}updateForTrack(e){if(Array.isArray(e)||(e=[e]),typeof ne.WebVTT!="function"||e.every(i=>!i.activeCues))return;const t=[];for(let i=0;i<e.length;++i){const n=e[i];for(let r=0;r<n.activeCues.length;++r)t.push(n.activeCues[r])}ne.WebVTT.processCues(ne,t,this.el_);for(let i=0;i<e.length;++i){const n=e[i];for(let r=0;r<n.activeCues.length;++r){const o=n.activeCues[r].displayState;vl(o,"vjs-text-track-cue","vjs-text-track-cue-"+(n.language?n.language:i)),n.language&&ec(o,"lang",n.language)}this.player_.textTrackSettings&&this.updateDisplayState(n)}}}ke.registerComponent("TextTrackDisplay",o3);class l3 extends ke{createEl(){const e=this.player_.isAudio(),t=this.localize(e?"Audio Player":"Video Player"),i=dt("span",{className:"vjs-control-text",textContent:this.localize("{1} is loading.",[t])}),n=super.createEl("div",{className:"vjs-loading-spinner",dir:"ltr"});return n.appendChild(i),n}handleLanguagechange(){this.$(".vjs-control-text").textContent=this.localize("{1} is loading.",[this.player_.isAudio()?"Audio Player":"Video Player"])}}ke.registerComponent("LoadingSpinner",l3);class Ds extends Bm{createEl(e,t={},i={}){e="button",t=Object.assign({className:this.buildCSSClass()},t),i=Object.assign({type:"button"},i);const n=dt(e,t,i);return this.player_.options_.experimentalSvgIcons||n.appendChild(dt("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),this.createControlTextEl(n),n}addChild(e,t={}){const i=this.constructor.name;return Dt.warn(`Adding an actionable (user controllable) child to a Button (${i}) is not supported; use a ClickableComponent instead.`),ke.prototype.addChild.call(this,e,t)}enable(){super.enable(),this.el_.removeAttribute("disabled")}disable(){super.disable(),this.el_.setAttribute("disabled","disabled")}handleKeyDown(e){if(e.key===" "||e.key==="Enter"){e.stopPropagation();return}super.handleKeyDown(e)}}ke.registerComponent("Button",Ds);class kC extends Ds{constructor(e,t){super(e,t),this.mouseused_=!1,this.setIcon("play"),this.on("mousedown",i=>this.handleMouseDown(i))}buildCSSClass(){return"vjs-big-play-button"}handleClick(e){const t=this.player_.play();if(e.type==="tap"||this.mouseused_&&"clientX"in e&&"clientY"in e){wr(t),this.player_.tech(!0)&&this.player_.tech(!0).focus();return}const i=this.player_.getChild("controlBar"),n=i&&i.getChild("playToggle");if(!n){this.player_.tech(!0).focus();return}const r=()=>n.focus();Fd(t)?t.then(r,()=>{}):this.setTimeout(r,1)}handleKeyDown(e){this.mouseused_=!1,super.handleKeyDown(e)}handleMouseDown(e){this.mouseused_=!0}}kC.prototype.controlText_="Play Video";ke.registerComponent("BigPlayButton",kC);class u3 extends Ds{constructor(e,t){super(e,t),this.setIcon("cancel"),this.controlText(t&&t.controlText||this.localize("Close"))}buildCSSClass(){return`vjs-close-button ${super.buildCSSClass()}`}handleClick(e){this.trigger({type:"close",bubbles:!1})}handleKeyDown(e){e.key==="Escape"?(e.preventDefault(),e.stopPropagation(),this.trigger("click")):super.handleKeyDown(e)}}ke.registerComponent("CloseButton",u3);class RC extends Ds{constructor(e,t={}){super(e,t),t.replay=t.replay===void 0||t.replay,this.setIcon("play"),this.on(e,"play",i=>this.handlePlay(i)),this.on(e,"pause",i=>this.handlePause(i)),t.replay&&this.on(e,"ended",i=>this.handleEnded(i))}buildCSSClass(){return`vjs-play-control ${super.buildCSSClass()}`}handleClick(e){this.player_.paused()?wr(this.player_.play()):this.player_.pause()}handleSeeked(e){this.removeClass("vjs-ended"),this.player_.paused()?this.handlePause(e):this.handlePlay(e)}handlePlay(e){this.removeClass("vjs-ended","vjs-paused"),this.addClass("vjs-playing"),this.setIcon("pause"),this.controlText("Pause")}handlePause(e){this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.setIcon("play"),this.controlText("Play")}handleEnded(e){this.removeClass("vjs-playing"),this.addClass("vjs-ended"),this.setIcon("replay"),this.controlText("Replay"),this.one(this.player_,"seeked",t=>this.handleSeeked(t))}}RC.prototype.controlText_="Play";ke.registerComponent("PlayToggle",RC);class dc extends ke{constructor(e,t){super(e,t),this.on(e,["timeupdate","ended","seeking"],i=>this.update(i)),this.updateTextNode_()}createEl(){const e=this.buildCSSClass(),t=super.createEl("div",{className:`${e} vjs-time-control vjs-control`}),i=dt("span",{className:"vjs-control-text",textContent:`${this.localize(this.labelText_)} `},{role:"presentation"});return t.appendChild(i),this.contentEl_=dt("span",{className:`${e}-display`},{role:"presentation"}),t.appendChild(this.contentEl_),t}dispose(){this.contentEl_=null,this.textNode_=null,super.dispose()}update(e){!this.player_.options_.enableSmoothSeeking&&e.type==="seeking"||this.updateContent(e)}updateTextNode_(e=0){e=El(e),this.formattedTime_!==e&&(this.formattedTime_=e,this.requestNamedAnimationFrame("TimeDisplay#updateTextNode_",()=>{if(!this.contentEl_)return;let t=this.textNode_;t&&this.contentEl_.firstChild!==t&&(t=null,Dt.warn("TimeDisplay#updateTextnode_: Prevented replacement of text node element since it was no longer a child of this node. Appending a new node instead.")),this.textNode_=Ve.createTextNode(this.formattedTime_),this.textNode_&&(t?this.contentEl_.replaceChild(this.textNode_,t):this.contentEl_.appendChild(this.textNode_))}))}updateContent(e){}}dc.prototype.labelText_="Time";dc.prototype.controlText_="Time";ke.registerComponent("TimeDisplay",dc);class RT extends dc{buildCSSClass(){return"vjs-current-time"}updateContent(e){let t;this.player_.ended()?t=this.player_.duration():e&&e.target&&typeof e.target.pendingSeekTime=="function"?t=e.target.pendingSeekTime():t=this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime(),this.updateTextNode_(t)}}RT.prototype.labelText_="Current Time";RT.prototype.controlText_="Current Time";ke.registerComponent("CurrentTimeDisplay",RT);class OT extends dc{constructor(e,t){super(e,t);const i=n=>this.updateContent(n);this.on(e,"durationchange",i),this.on(e,"loadstart",i),this.on(e,"loadedmetadata",i)}buildCSSClass(){return"vjs-duration"}updateContent(e){const t=this.player_.duration();this.updateTextNode_(t)}}OT.prototype.labelText_="Duration";OT.prototype.controlText_="Duration";ke.registerComponent("DurationDisplay",OT);class c3 extends ke{createEl(){const e=super.createEl("div",{className:"vjs-time-control vjs-time-divider"},{"aria-hidden":!0}),t=super.createEl("div"),i=super.createEl("span",{textContent:"/"});return t.appendChild(i),e.appendChild(t),e}}ke.registerComponent("TimeDivider",c3);class PT extends dc{constructor(e,t){super(e,t),this.on(e,"durationchange",i=>this.updateContent(i))}buildCSSClass(){return"vjs-remaining-time"}createEl(){const e=super.createEl();return this.options_.displayNegative!==!1&&e.insertBefore(dt("span",{},{"aria-hidden":!0},"-"),this.contentEl_),e}updateContent(e){if(typeof this.player_.duration()!="number")return;let t;this.player_.ended()?t=0:this.player_.remainingTimeDisplay?t=this.player_.remainingTimeDisplay():t=this.player_.remainingTime(),this.updateTextNode_(t)}}PT.prototype.labelText_="Remaining Time";PT.prototype.controlText_="Remaining Time";ke.registerComponent("RemainingTimeDisplay",PT);class d3 extends ke{constructor(e,t){super(e,t),this.updateShowing(),this.on(this.player(),"durationchange",i=>this.updateShowing(i))}createEl(){const e=super.createEl("div",{className:"vjs-live-control vjs-control"});return this.contentEl_=dt("div",{className:"vjs-live-display"},{"aria-live":"off"}),this.contentEl_.appendChild(dt("span",{className:"vjs-control-text",textContent:`${this.localize("Stream Type")} `})),this.contentEl_.appendChild(Ve.createTextNode(this.localize("LIVE"))),e.appendChild(this.contentEl_),e}dispose(){this.contentEl_=null,super.dispose()}updateShowing(e){this.player().duration()===1/0?this.show():this.hide()}}ke.registerComponent("LiveDisplay",d3);class OC extends Ds{constructor(e,t){super(e,t),this.updateLiveEdgeStatus(),this.player_.liveTracker&&(this.updateLiveEdgeStatusHandler_=i=>this.updateLiveEdgeStatus(i),this.on(this.player_.liveTracker,"liveedgechange",this.updateLiveEdgeStatusHandler_))}createEl(){const e=super.createEl("button",{className:"vjs-seek-to-live-control vjs-control"});return this.setIcon("circle",e),this.textEl_=dt("span",{className:"vjs-seek-to-live-text",textContent:this.localize("LIVE")},{"aria-hidden":"true"}),e.appendChild(this.textEl_),e}updateLiveEdgeStatus(){!this.player_.liveTracker||this.player_.liveTracker.atLiveEdge()?(this.setAttribute("aria-disabled",!0),this.addClass("vjs-at-live-edge"),this.controlText("Seek to live, currently playing live")):(this.setAttribute("aria-disabled",!1),this.removeClass("vjs-at-live-edge"),this.controlText("Seek to live, currently behind live"))}handleClick(){this.player_.liveTracker.seekToLiveEdge()}dispose(){this.player_.liveTracker&&this.off(this.player_.liveTracker,"liveedgechange",this.updateLiveEdgeStatusHandler_),this.textEl_=null,super.dispose()}}OC.prototype.controlText_="Seek to live, currently playing live";ke.registerComponent("SeekToLive",OC);function lh(s,e,t){return s=Number(s),Math.min(t,Math.max(e,isNaN(s)?e:s))}var h3=Object.freeze({__proto__:null,clamp:lh});class MT extends ke{constructor(e,t){super(e,t),this.handleMouseDown_=i=>this.handleMouseDown(i),this.handleMouseUp_=i=>this.handleMouseUp(i),this.handleKeyDown_=i=>this.handleKeyDown(i),this.handleClick_=i=>this.handleClick(i),this.handleMouseMove_=i=>this.handleMouseMove(i),this.update_=i=>this.update(i),this.bar=this.getChild(this.options_.barName),this.vertical(!!this.options_.vertical),this.enable()}enabled(){return this.enabled_}enable(){this.enabled()||(this.on("mousedown",this.handleMouseDown_),this.on("touchstart",this.handleMouseDown_),this.on("keydown",this.handleKeyDown_),this.on("click",this.handleClick_),this.on(this.player_,"controlsvisible",this.update),this.playerEvent&&this.on(this.player_,this.playerEvent,this.update),this.removeClass("disabled"),this.setAttribute("tabindex",0),this.enabled_=!0)}disable(){if(!this.enabled())return;const e=this.bar.el_.ownerDocument;this.off("mousedown",this.handleMouseDown_),this.off("touchstart",this.handleMouseDown_),this.off("keydown",this.handleKeyDown_),this.off("click",this.handleClick_),this.off(this.player_,"controlsvisible",this.update_),this.off(e,"mousemove",this.handleMouseMove_),this.off(e,"mouseup",this.handleMouseUp_),this.off(e,"touchmove",this.handleMouseMove_),this.off(e,"touchend",this.handleMouseUp_),this.removeAttribute("tabindex"),this.addClass("disabled"),this.playerEvent&&this.off(this.player_,this.playerEvent,this.update),this.enabled_=!1}createEl(e,t={},i={}){return t.className=t.className+" vjs-slider",t=Object.assign({tabIndex:0},t),i=Object.assign({role:"slider","aria-valuenow":0,"aria-valuemin":0,"aria-valuemax":100},i),super.createEl(e,t,i)}handleMouseDown(e){const t=this.bar.el_.ownerDocument;e.type==="mousedown"&&e.preventDefault(),e.type==="touchstart"&&!Nr&&e.preventDefault(),rC(),this.addClass("vjs-sliding"),this.trigger("slideractive"),this.on(t,"mousemove",this.handleMouseMove_),this.on(t,"mouseup",this.handleMouseUp_),this.on(t,"touchmove",this.handleMouseMove_),this.on(t,"touchend",this.handleMouseUp_),this.handleMouseMove(e,!0)}handleMouseMove(e){}handleMouseUp(e){const t=this.bar.el_.ownerDocument;aC(),this.removeClass("vjs-sliding"),this.trigger("sliderinactive"),this.off(t,"mousemove",this.handleMouseMove_),this.off(t,"mouseup",this.handleMouseUp_),this.off(t,"touchmove",this.handleMouseMove_),this.off(t,"touchend",this.handleMouseUp_),this.update()}update(){if(!this.el_||!this.bar)return;const e=this.getProgress();return e===this.progress_||(this.progress_=e,this.requestNamedAnimationFrame("Slider#update",()=>{const t=this.vertical()?"height":"width";this.bar.el().style[t]=(e*100).toFixed(2)+"%"})),e}getProgress(){return Number(lh(this.getPercent(),0,1).toFixed(4))}calculateDistance(e){const t=km(this.el_,e);return this.vertical()?t.y:t.x}handleKeyDown(e){const t=this.options_.playerOptions.spatialNavigation,i=t&&t.enabled,n=t&&t.horizontalSeek;i?n&&e.key==="ArrowLeft"||!n&&e.key==="ArrowDown"?(e.preventDefault(),e.stopPropagation(),this.stepBack()):n&&e.key==="ArrowRight"||!n&&e.key==="ArrowUp"?(e.preventDefault(),e.stopPropagation(),this.stepForward()):(this.pendingSeekTime()&&(this.pendingSeekTime(null),this.userSeek_(this.player_.currentTime())),super.handleKeyDown(e)):e.key==="ArrowLeft"||e.key==="ArrowDown"?(e.preventDefault(),e.stopPropagation(),this.stepBack()):e.key==="ArrowUp"||e.key==="ArrowRight"?(e.preventDefault(),e.stopPropagation(),this.stepForward()):super.handleKeyDown(e)}handleClick(e){e.stopPropagation(),e.preventDefault()}vertical(e){if(e===void 0)return this.vertical_||!1;this.vertical_=!!e,this.vertical_?this.addClass("vjs-slider-vertical"):this.addClass("vjs-slider-horizontal")}}ke.registerComponent("Slider",MT);const Ay=(s,e)=>lh(s/e*100,0,100).toFixed(2)+"%";class f3 extends ke{constructor(e,t){super(e,t),this.partEls_=[],this.on(e,"progress",i=>this.update(i))}createEl(){const e=super.createEl("div",{className:"vjs-load-progress"}),t=dt("span",{className:"vjs-control-text"}),i=dt("span",{textContent:this.localize("Loaded")}),n=Ve.createTextNode(": ");return this.percentageEl_=dt("span",{className:"vjs-control-text-loaded-percentage",textContent:"0%"}),e.appendChild(t),t.appendChild(i),t.appendChild(n),t.appendChild(this.percentageEl_),e}dispose(){this.partEls_=null,this.percentageEl_=null,super.dispose()}update(e){this.requestNamedAnimationFrame("LoadProgressBar#update",()=>{const t=this.player_.liveTracker,i=this.player_.buffered(),n=t&&t.isLive()?t.seekableEnd():this.player_.duration(),r=this.player_.bufferedEnd(),o=this.partEls_,u=Ay(r,n);this.percent_!==u&&(this.el_.style.width=u,Co(this.percentageEl_,u),this.percent_=u);for(let c=0;c<i.length;c++){const d=i.start(c),f=i.end(c);let m=o[c];m||(m=this.el_.appendChild(dt()),o[c]=m),!(m.dataset.start===d&&m.dataset.end===f)&&(m.dataset.start=d,m.dataset.end=f,m.style.left=Ay(d,r),m.style.width=Ay(f-d,r))}for(let c=o.length;c>i.length;c--)this.el_.removeChild(o[c-1]);o.length=i.length})}}ke.registerComponent("LoadProgressBar",f3);class p3 extends ke{constructor(e,t){super(e,t),this.update=Br(hi(this,this.update),Bn)}createEl(){return super.createEl("div",{className:"vjs-time-tooltip"},{"aria-hidden":"true"})}update(e,t,i){const n=zd(this.el_),r=tc(this.player_.el()),o=e.width*t;if(!r||!n)return;let u=e.left-r.left+o,c=e.width-o+(r.right-e.right);c||(c=e.width-o,u=o);let d=n.width/2;u<d?d+=d-u:c<d&&(d=c),d<0?d=0:d>n.width&&(d=n.width),d=Math.round(d),this.el_.style.right=`-${d}px`,this.write(i)}write(e){Co(this.el_,e)}updateTime(e,t,i,n){this.requestNamedAnimationFrame("TimeTooltip#updateTime",()=>{let r;const o=this.player_.duration();if(this.player_.liveTracker&&this.player_.liveTracker.isLive()){const u=this.player_.liveTracker.liveWindow(),c=u-t*u;r=(c<1?"":"-")+El(c,u)}else r=El(i,o);this.update(e,t,r),n&&n()})}}ke.registerComponent("TimeTooltip",p3);class NT extends ke{constructor(e,t){super(e,t),this.setIcon("circle"),this.update=Br(hi(this,this.update),Bn)}createEl(){return super.createEl("div",{className:"vjs-play-progress vjs-slider-bar"},{"aria-hidden":"true"})}update(e,t,i){const n=this.getChild("timeTooltip");if(!n)return;const r=i&&i.target&&typeof i.target.pendingSeekTime=="function"?i.target.pendingSeekTime():this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime();n.updateTime(e,t,r)}}NT.prototype.options_={children:[]};!As&&!ir&&NT.prototype.options_.children.push("timeTooltip");ke.registerComponent("PlayProgressBar",NT);class PC extends ke{constructor(e,t){super(e,t),this.update=Br(hi(this,this.update),Bn)}createEl(){return super.createEl("div",{className:"vjs-mouse-display"})}update(e,t){const i=t*this.player_.duration();this.getChild("timeTooltip").updateTime(e,t,i,()=>{this.el_.style.left=`${e.width*t}px`})}}PC.prototype.options_={children:["timeTooltip"]};ke.registerComponent("MouseTimeDisplay",PC);class Fm extends MT{constructor(e,t){t=si(Fm.prototype.options_,t),t.children=[...t.children];const i=e.options_.disableSeekWhileScrubbingOnMobile&&(As||ir)||e.options_.disableSeekWhileScrubbingOnSTV;(!As&&!ir||i)&&t.children.splice(1,0,"mouseTimeDisplay"),super(e,t),this.shouldDisableSeekWhileScrubbing_=i,this.pendingSeekTime_=null,this.setEventHandlers_()}setEventHandlers_(){this.update_=hi(this,this.update),this.update=Br(this.update_,Bn),this.on(this.player_,["durationchange","timeupdate"],this.update),this.on(this.player_,["ended"],this.update_),this.player_.liveTracker&&this.on(this.player_.liveTracker,"liveedgechange",this.update),this.updateInterval=null,this.enableIntervalHandler_=e=>this.enableInterval_(e),this.disableIntervalHandler_=e=>this.disableInterval_(e),this.on(this.player_,["playing"],this.enableIntervalHandler_),this.on(this.player_,["ended","pause","waiting"],this.disableIntervalHandler_),"hidden"in Ve&&"visibilityState"in Ve&&this.on(Ve,"visibilitychange",this.toggleVisibility_)}toggleVisibility_(e){Ve.visibilityState==="hidden"?(this.cancelNamedAnimationFrame("SeekBar#update"),this.cancelNamedAnimationFrame("Slider#update"),this.disableInterval_(e)):(!this.player_.ended()&&!this.player_.paused()&&this.enableInterval_(),this.update())}enableInterval_(){this.updateInterval||(this.updateInterval=this.setInterval(this.update,Bn))}disableInterval_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&e&&e.type!=="ended"||this.updateInterval&&(this.clearInterval(this.updateInterval),this.updateInterval=null)}createEl(){return super.createEl("div",{className:"vjs-progress-holder"},{"aria-label":this.localize("Progress Bar")})}update(e){if(Ve.visibilityState==="hidden")return;const t=super.update();return this.requestNamedAnimationFrame("SeekBar#update",()=>{const i=this.player_.ended()?this.player_.duration():this.getCurrentTime_(),n=this.player_.liveTracker;let r=this.player_.duration();n&&n.isLive()&&(r=this.player_.liveTracker.liveCurrentTime()),this.percent_!==t&&(this.el_.setAttribute("aria-valuenow",(t*100).toFixed(2)),this.percent_=t),(this.currentTime_!==i||this.duration_!==r)&&(this.el_.setAttribute("aria-valuetext",this.localize("progress bar timing: currentTime={1} duration={2}",[El(i,r),El(r,r)],"{1} of {2}")),this.currentTime_=i,this.duration_=r),this.bar&&this.bar.update(tc(this.el()),this.getProgress(),e)}),t}userSeek_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&this.player_.liveTracker.nextSeekedFromUser(),this.player_.currentTime(e)}getCurrentTime_(){return this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime()}pendingSeekTime(e){if(e!==void 0)if(e!==null){const t=this.player_.duration();this.pendingSeekTime_=Math.max(0,Math.min(e,t))}else this.pendingSeekTime_=null;return this.pendingSeekTime_}getPercent(){if(this.pendingSeekTime()!==null)return this.pendingSeekTime()/this.player_.duration();const e=this.getCurrentTime_();let t;const i=this.player_.liveTracker;return i&&i.isLive()?(t=(e-i.seekableStart())/i.liveWindow(),i.atLiveEdge()&&(t=1)):t=e/this.player_.duration(),t}handleMouseDown(e){Kd(e)&&(e.stopPropagation(),this.videoWasPlaying=!this.player_.paused(),this.shouldDisableSeekWhileScrubbing_||this.player_.pause(),super.handleMouseDown(e))}handleMouseMove(e,t=!1){if(!Kd(e)||isNaN(this.player_.duration()))return;!t&&!this.player_.scrubbing()&&this.player_.scrubbing(!0);let i;const n=this.calculateDistance(e),r=this.player_.liveTracker;if(!r||!r.isLive())i=n*this.player_.duration(),i===this.player_.duration()&&(i=i-.1);else{if(n>=.99){r.seekToLiveEdge();return}const o=r.seekableStart(),u=r.liveCurrentTime();if(i=o+n*r.liveWindow(),i>=u&&(i=u),i<=o&&(i=o+.1),i===1/0)return}this.shouldDisableSeekWhileScrubbing_?this.pendingSeekTime(i):this.userSeek_(i),this.player_.options_.enableSmoothSeeking&&this.update()}enable(){super.enable();const e=this.getChild("mouseTimeDisplay");e&&e.show()}disable(){super.disable();const e=this.getChild("mouseTimeDisplay");e&&e.hide()}handleMouseUp(e){super.handleMouseUp(e),e&&e.stopPropagation(),this.player_.scrubbing(!1),this.pendingSeekTime()!==null&&(this.userSeek_(this.pendingSeekTime()),this.pendingSeekTime(null)),this.player_.trigger({type:"timeupdate",target:this,manuallyTriggered:!0}),this.videoWasPlaying?wr(this.player_.play()):this.update_()}handlePendingSeek_(e){this.player_.paused()||this.player_.pause();const t=this.pendingSeekTime()!==null?this.pendingSeekTime():this.player_.currentTime();this.pendingSeekTime(t+e),this.player_.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}stepForward(){this.shouldDisableSeekWhileScrubbing_?this.handlePendingSeek_(this.options().stepSeconds):this.userSeek_(this.player_.currentTime()+this.options().stepSeconds)}stepBack(){this.shouldDisableSeekWhileScrubbing_?this.handlePendingSeek_(-this.options().stepSeconds):this.userSeek_(this.player_.currentTime()-this.options().stepSeconds)}handleAction(e){this.pendingSeekTime()!==null&&(this.userSeek_(this.pendingSeekTime()),this.pendingSeekTime(null)),this.player_.paused()?this.player_.play():this.player_.pause()}handleKeyDown(e){const t=this.player_.liveTracker;if(e.key===" "||e.key==="Enter")e.preventDefault(),e.stopPropagation(),this.handleAction(e);else if(e.key==="Home")e.preventDefault(),e.stopPropagation(),this.userSeek_(0);else if(e.key==="End")e.preventDefault(),e.stopPropagation(),t&&t.isLive()?this.userSeek_(t.liveCurrentTime()):this.userSeek_(this.player_.duration());else if(/^[0-9]$/.test(e.key)){e.preventDefault(),e.stopPropagation();const i=parseInt(e.key,10)*.1;t&&t.isLive()?this.userSeek_(t.seekableStart()+t.liveWindow()*i):this.userSeek_(this.player_.duration()*i)}else e.key==="PageDown"?(e.preventDefault(),e.stopPropagation(),this.userSeek_(this.player_.currentTime()-this.options().stepSeconds*this.options().pageMultiplier)):e.key==="PageUp"?(e.preventDefault(),e.stopPropagation(),this.userSeek_(this.player_.currentTime()+this.options().stepSeconds*this.options().pageMultiplier)):super.handleKeyDown(e)}dispose(){this.disableInterval_(),this.off(this.player_,["durationchange","timeupdate"],this.update),this.off(this.player_,["ended"],this.update_),this.player_.liveTracker&&this.off(this.player_.liveTracker,"liveedgechange",this.update),this.off(this.player_,["playing"],this.enableIntervalHandler_),this.off(this.player_,["ended","pause","waiting"],this.disableIntervalHandler_),"hidden"in Ve&&"visibilityState"in Ve&&this.off(Ve,"visibilitychange",this.toggleVisibility_),super.dispose()}}Fm.prototype.options_={children:["loadProgressBar","playProgressBar"],barName:"playProgressBar",stepSeconds:5,pageMultiplier:12};ke.registerComponent("SeekBar",Fm);class MC extends ke{constructor(e,t){super(e,t),this.handleMouseMove=Br(hi(this,this.handleMouseMove),Bn),this.throttledHandleMouseSeek=Br(hi(this,this.handleMouseSeek),Bn),this.handleMouseUpHandler_=i=>this.handleMouseUp(i),this.handleMouseDownHandler_=i=>this.handleMouseDown(i),this.enable()}createEl(){return super.createEl("div",{className:"vjs-progress-control vjs-control"})}handleMouseMove(e){const t=this.getChild("seekBar");if(!t)return;const i=t.getChild("playProgressBar"),n=t.getChild("mouseTimeDisplay");if(!i&&!n)return;const r=t.el(),o=zd(r);let u=km(r,e).x;u=lh(u,0,1),n&&n.update(o,u),i&&i.update(o,t.getProgress())}handleMouseSeek(e){const t=this.getChild("seekBar");t&&t.handleMouseMove(e)}enabled(){return this.enabled_}disable(){if(this.children().forEach(e=>e.disable&&e.disable()),!!this.enabled()&&(this.off(["mousedown","touchstart"],this.handleMouseDownHandler_),this.off(this.el_,["mousemove","touchmove"],this.handleMouseMove),this.removeListenersAddedOnMousedownAndTouchstart(),this.addClass("disabled"),this.enabled_=!1,this.player_.scrubbing())){const e=this.getChild("seekBar");this.player_.scrubbing(!1),e.videoWasPlaying&&wr(this.player_.play())}}enable(){this.children().forEach(e=>e.enable&&e.enable()),!this.enabled()&&(this.on(["mousedown","touchstart"],this.handleMouseDownHandler_),this.on(this.el_,["mousemove","touchmove"],this.handleMouseMove),this.removeClass("disabled"),this.enabled_=!0)}removeListenersAddedOnMousedownAndTouchstart(){const e=this.el_.ownerDocument;this.off(e,"mousemove",this.throttledHandleMouseSeek),this.off(e,"touchmove",this.throttledHandleMouseSeek),this.off(e,"mouseup",this.handleMouseUpHandler_),this.off(e,"touchend",this.handleMouseUpHandler_)}handleMouseDown(e){const t=this.el_.ownerDocument,i=this.getChild("seekBar");i&&i.handleMouseDown(e),this.on(t,"mousemove",this.throttledHandleMouseSeek),this.on(t,"touchmove",this.throttledHandleMouseSeek),this.on(t,"mouseup",this.handleMouseUpHandler_),this.on(t,"touchend",this.handleMouseUpHandler_)}handleMouseUp(e){const t=this.getChild("seekBar");t&&t.handleMouseUp(e),this.removeListenersAddedOnMousedownAndTouchstart()}}MC.prototype.options_={children:["seekBar"]};ke.registerComponent("ProgressControl",MC);class NC extends Ds{constructor(e,t){super(e,t),this.setIcon("picture-in-picture-enter"),this.on(e,["enterpictureinpicture","leavepictureinpicture"],i=>this.handlePictureInPictureChange(i)),this.on(e,["disablepictureinpicturechanged","loadedmetadata"],i=>this.handlePictureInPictureEnabledChange(i)),this.on(e,["loadedmetadata","audioonlymodechange","audiopostermodechange"],()=>this.handlePictureInPictureAudioModeChange()),this.disable()}buildCSSClass(){return`vjs-picture-in-picture-control vjs-hidden ${super.buildCSSClass()}`}handlePictureInPictureAudioModeChange(){if(!(this.player_.currentType().substring(0,5)==="audio"||this.player_.audioPosterMode()||this.player_.audioOnlyMode())){this.show();return}this.player_.isInPictureInPicture()&&this.player_.exitPictureInPicture(),this.hide()}handlePictureInPictureEnabledChange(){Ve.pictureInPictureEnabled&&this.player_.disablePictureInPicture()===!1||this.player_.options_.enableDocumentPictureInPicture&&"documentPictureInPicture"in ne?this.enable():this.disable()}handlePictureInPictureChange(e){this.player_.isInPictureInPicture()?(this.setIcon("picture-in-picture-exit"),this.controlText("Exit Picture-in-Picture")):(this.setIcon("picture-in-picture-enter"),this.controlText("Picture-in-Picture")),this.handlePictureInPictureEnabledChange()}handleClick(e){this.player_.isInPictureInPicture()?this.player_.exitPictureInPicture():this.player_.requestPictureInPicture()}show(){typeof Ve.exitPictureInPicture=="function"&&super.show()}}NC.prototype.controlText_="Picture-in-Picture";ke.registerComponent("PictureInPictureToggle",NC);class BC extends Ds{constructor(e,t){super(e,t),this.setIcon("fullscreen-enter"),this.on(e,"fullscreenchange",i=>this.handleFullscreenChange(i)),Ve[e.fsApi_.fullscreenEnabled]===!1&&this.disable()}buildCSSClass(){return`vjs-fullscreen-control ${super.buildCSSClass()}`}handleFullscreenChange(e){this.player_.isFullscreen()?(this.controlText("Exit Fullscreen"),this.setIcon("fullscreen-exit")):(this.controlText("Fullscreen"),this.setIcon("fullscreen-enter"))}handleClick(e){this.player_.isFullscreen()?this.player_.exitFullscreen():this.player_.requestFullscreen()}}BC.prototype.controlText_="Fullscreen";ke.registerComponent("FullscreenToggle",BC);const m3=function(s,e){e.tech_&&!e.tech_.featuresVolumeControl&&s.addClass("vjs-hidden"),s.on(e,"loadstart",function(){e.tech_.featuresVolumeControl?s.removeClass("vjs-hidden"):s.addClass("vjs-hidden")})};class g3 extends ke{createEl(){const e=super.createEl("div",{className:"vjs-volume-level"});return this.setIcon("circle",e),e.appendChild(super.createEl("span",{className:"vjs-control-text"})),e}}ke.registerComponent("VolumeLevel",g3);class y3 extends ke{constructor(e,t){super(e,t),this.update=Br(hi(this,this.update),Bn)}createEl(){return super.createEl("div",{className:"vjs-volume-tooltip"},{"aria-hidden":"true"})}update(e,t,i,n){if(!i){const r=tc(this.el_),o=tc(this.player_.el()),u=e.width*t;if(!o||!r)return;const c=e.left-o.left+u,d=e.width-u+(o.right-e.right);let f=r.width/2;c<f?f+=f-c:d<f&&(f=d),f<0?f=0:f>r.width&&(f=r.width),this.el_.style.right=`-${f}px`}this.write(`${n}%`)}write(e){Co(this.el_,e)}updateVolume(e,t,i,n,r){this.requestNamedAnimationFrame("VolumeLevelTooltip#updateVolume",()=>{this.update(e,t,i,n.toFixed(0)),r&&r()})}}ke.registerComponent("VolumeLevelTooltip",y3);class FC extends ke{constructor(e,t){super(e,t),this.update=Br(hi(this,this.update),Bn)}createEl(){return super.createEl("div",{className:"vjs-mouse-display"})}update(e,t,i){const n=100*t;this.getChild("volumeLevelTooltip").updateVolume(e,t,i,n,()=>{i?this.el_.style.bottom=`${e.height*t}px`:this.el_.style.left=`${e.width*t}px`})}}FC.prototype.options_={children:["volumeLevelTooltip"]};ke.registerComponent("MouseVolumeLevelDisplay",FC);class Um extends MT{constructor(e,t){super(e,t),this.on("slideractive",i=>this.updateLastVolume_(i)),this.on(e,"volumechange",i=>this.updateARIAAttributes(i)),e.ready(()=>this.updateARIAAttributes())}createEl(){return super.createEl("div",{className:"vjs-volume-bar vjs-slider-bar"},{"aria-label":this.localize("Volume Level"),"aria-live":"polite"})}handleMouseDown(e){Kd(e)&&super.handleMouseDown(e)}handleMouseMove(e){const t=this.getChild("mouseVolumeLevelDisplay");if(t){const i=this.el(),n=tc(i),r=this.vertical();let o=km(i,e);o=r?o.y:o.x,o=lh(o,0,1),t.update(n,o,r)}Kd(e)&&(this.checkMuted(),this.player_.volume(this.calculateDistance(e)))}checkMuted(){this.player_.muted()&&this.player_.muted(!1)}getPercent(){return this.player_.muted()?0:this.player_.volume()}stepForward(){this.checkMuted(),this.player_.volume(this.player_.volume()+.1)}stepBack(){this.checkMuted(),this.player_.volume(this.player_.volume()-.1)}updateARIAAttributes(e){const t=this.player_.muted()?0:this.volumeAsPercentage_();this.el_.setAttribute("aria-valuenow",t),this.el_.setAttribute("aria-valuetext",t+"%")}volumeAsPercentage_(){return Math.round(this.player_.volume()*100)}updateLastVolume_(){const e=this.player_.volume();this.one("sliderinactive",()=>{this.player_.volume()===0&&this.player_.lastVolume_(e)})}}Um.prototype.options_={children:["volumeLevel"],barName:"volumeLevel"};!As&&!ir&&Um.prototype.options_.children.splice(0,0,"mouseVolumeLevelDisplay");Um.prototype.playerEvent="volumechange";ke.registerComponent("VolumeBar",Um);class UC extends ke{constructor(e,t={}){t.vertical=t.vertical||!1,(typeof t.volumeBar>"u"||Ju(t.volumeBar))&&(t.volumeBar=t.volumeBar||{},t.volumeBar.vertical=t.vertical),super(e,t),m3(this,e),this.throttledHandleMouseMove=Br(hi(this,this.handleMouseMove),Bn),this.handleMouseUpHandler_=i=>this.handleMouseUp(i),this.on("mousedown",i=>this.handleMouseDown(i)),this.on("touchstart",i=>this.handleMouseDown(i)),this.on("mousemove",i=>this.handleMouseMove(i)),this.on(this.volumeBar,["focus","slideractive"],()=>{this.volumeBar.addClass("vjs-slider-active"),this.addClass("vjs-slider-active"),this.trigger("slideractive")}),this.on(this.volumeBar,["blur","sliderinactive"],()=>{this.volumeBar.removeClass("vjs-slider-active"),this.removeClass("vjs-slider-active"),this.trigger("sliderinactive")})}createEl(){let e="vjs-volume-horizontal";return this.options_.vertical&&(e="vjs-volume-vertical"),super.createEl("div",{className:`vjs-volume-control vjs-control ${e}`})}handleMouseDown(e){const t=this.el_.ownerDocument;this.on(t,"mousemove",this.throttledHandleMouseMove),this.on(t,"touchmove",this.throttledHandleMouseMove),this.on(t,"mouseup",this.handleMouseUpHandler_),this.on(t,"touchend",this.handleMouseUpHandler_)}handleMouseUp(e){const t=this.el_.ownerDocument;this.off(t,"mousemove",this.throttledHandleMouseMove),this.off(t,"touchmove",this.throttledHandleMouseMove),this.off(t,"mouseup",this.handleMouseUpHandler_),this.off(t,"touchend",this.handleMouseUpHandler_)}handleMouseMove(e){this.volumeBar.handleMouseMove(e)}}UC.prototype.options_={children:["volumeBar"]};ke.registerComponent("VolumeControl",UC);const v3=function(s,e){e.tech_&&!e.tech_.featuresMuteControl&&s.addClass("vjs-hidden"),s.on(e,"loadstart",function(){e.tech_.featuresMuteControl?s.removeClass("vjs-hidden"):s.addClass("vjs-hidden")})};class $C extends Ds{constructor(e,t){super(e,t),v3(this,e),this.on(e,["loadstart","volumechange"],i=>this.update(i))}buildCSSClass(){return`vjs-mute-control ${super.buildCSSClass()}`}handleClick(e){const t=this.player_.volume(),i=this.player_.lastVolume_();if(t===0){const n=i<.1?.1:i;this.player_.volume(n),this.player_.muted(!1)}else this.player_.muted(!this.player_.muted())}update(e){this.updateIcon_(),this.updateControlText_()}updateIcon_(){const e=this.player_.volume();let t=3;this.setIcon("volume-high"),As&&this.player_.tech_&&this.player_.tech_.el_&&this.player_.muted(this.player_.tech_.el_.muted),e===0||this.player_.muted()?(this.setIcon("volume-mute"),t=0):e<.33?(this.setIcon("volume-low"),t=1):e<.67&&(this.setIcon("volume-medium"),t=2),Lm(this.el_,[0,1,2,3].reduce((i,n)=>i+`${n?" ":""}vjs-vol-${n}`,"")),vl(this.el_,`vjs-vol-${t}`)}updateControlText_(){const t=this.player_.muted()||this.player_.volume()===0?"Unmute":"Mute";this.controlText()!==t&&this.controlText(t)}}$C.prototype.controlText_="Mute";ke.registerComponent("MuteToggle",$C);class jC extends ke{constructor(e,t={}){typeof t.inline<"u"?t.inline=t.inline:t.inline=!0,(typeof t.volumeControl>"u"||Ju(t.volumeControl))&&(t.volumeControl=t.volumeControl||{},t.volumeControl.vertical=!t.inline),super(e,t),this.handleKeyPressHandler_=i=>this.handleKeyPress(i),this.on(e,["loadstart"],i=>this.volumePanelState_(i)),this.on(this.muteToggle,"keyup",i=>this.handleKeyPress(i)),this.on(this.volumeControl,"keyup",i=>this.handleVolumeControlKeyUp(i)),this.on("keydown",i=>this.handleKeyPress(i)),this.on("mouseover",i=>this.handleMouseOver(i)),this.on("mouseout",i=>this.handleMouseOut(i)),this.on(this.volumeControl,["slideractive"],this.sliderActive_),this.on(this.volumeControl,["sliderinactive"],this.sliderInactive_)}sliderActive_(){this.addClass("vjs-slider-active")}sliderInactive_(){this.removeClass("vjs-slider-active")}volumePanelState_(){this.volumeControl.hasClass("vjs-hidden")&&this.muteToggle.hasClass("vjs-hidden")&&this.addClass("vjs-hidden"),this.volumeControl.hasClass("vjs-hidden")&&!this.muteToggle.hasClass("vjs-hidden")&&this.addClass("vjs-mute-toggle-only")}createEl(){let e="vjs-volume-panel-horizontal";return this.options_.inline||(e="vjs-volume-panel-vertical"),super.createEl("div",{className:`vjs-volume-panel vjs-control ${e}`})}dispose(){this.handleMouseOut(),super.dispose()}handleVolumeControlKeyUp(e){e.key==="Escape"&&this.muteToggle.focus()}handleMouseOver(e){this.addClass("vjs-hover"),Sn(Ve,"keyup",this.handleKeyPressHandler_)}handleMouseOut(e){this.removeClass("vjs-hover"),Cs(Ve,"keyup",this.handleKeyPressHandler_)}handleKeyPress(e){e.key==="Escape"&&this.handleMouseOut()}}jC.prototype.options_={children:["muteToggle","volumeControl"]};ke.registerComponent("VolumePanel",jC);class HC extends Ds{constructor(e,t){super(e,t),this.validOptions=[5,10,30],this.skipTime=this.getSkipForwardTime(),this.skipTime&&this.validOptions.includes(this.skipTime)?(this.setIcon(`forward-${this.skipTime}`),this.controlText(this.localize("Skip forward {1} seconds",[this.skipTime.toLocaleString(e.language())])),this.show()):this.hide()}getSkipForwardTime(){const e=this.options_.playerOptions;return e.controlBar&&e.controlBar.skipButtons&&e.controlBar.skipButtons.forward}buildCSSClass(){return`vjs-skip-forward-${this.getSkipForwardTime()} ${super.buildCSSClass()}`}handleClick(e){if(isNaN(this.player_.duration()))return;const t=this.player_.currentTime(),i=this.player_.liveTracker,n=i&&i.isLive()?i.seekableEnd():this.player_.duration();let r;t+this.skipTime<=n?r=t+this.skipTime:r=n,this.player_.currentTime(r)}handleLanguagechange(){this.controlText(this.localize("Skip forward {1} seconds",[this.skipTime]))}}HC.prototype.controlText_="Skip Forward";ke.registerComponent("SkipForward",HC);class GC extends Ds{constructor(e,t){super(e,t),this.validOptions=[5,10,30],this.skipTime=this.getSkipBackwardTime(),this.skipTime&&this.validOptions.includes(this.skipTime)?(this.setIcon(`replay-${this.skipTime}`),this.controlText(this.localize("Skip backward {1} seconds",[this.skipTime.toLocaleString(e.language())])),this.show()):this.hide()}getSkipBackwardTime(){const e=this.options_.playerOptions;return e.controlBar&&e.controlBar.skipButtons&&e.controlBar.skipButtons.backward}buildCSSClass(){return`vjs-skip-backward-${this.getSkipBackwardTime()} ${super.buildCSSClass()}`}handleClick(e){const t=this.player_.currentTime(),i=this.player_.liveTracker,n=i&&i.isLive()&&i.seekableStart();let r;n&&t-this.skipTime<=n?r=n:t>=this.skipTime?r=t-this.skipTime:r=0,this.player_.currentTime(r)}handleLanguagechange(){this.controlText(this.localize("Skip backward {1} seconds",[this.skipTime]))}}GC.prototype.controlText_="Skip Backward";ke.registerComponent("SkipBackward",GC);class VC extends ke{constructor(e,t){super(e,t),t&&(this.menuButton_=t.menuButton),this.focusedChild_=-1,this.on("keydown",i=>this.handleKeyDown(i)),this.boundHandleBlur_=i=>this.handleBlur(i),this.boundHandleTapClick_=i=>this.handleTapClick(i)}addEventListenerForItem(e){e instanceof ke&&(this.on(e,"blur",this.boundHandleBlur_),this.on(e,["tap","click"],this.boundHandleTapClick_))}removeEventListenerForItem(e){e instanceof ke&&(this.off(e,"blur",this.boundHandleBlur_),this.off(e,["tap","click"],this.boundHandleTapClick_))}removeChild(e){typeof e=="string"&&(e=this.getChild(e)),this.removeEventListenerForItem(e),super.removeChild(e)}addItem(e){const t=this.addChild(e);t&&this.addEventListenerForItem(t)}createEl(){const e=this.options_.contentElType||"ul";this.contentEl_=dt(e,{className:"vjs-menu-content"}),this.contentEl_.setAttribute("role","menu");const t=super.createEl("div",{append:this.contentEl_,className:"vjs-menu"});return t.appendChild(this.contentEl_),Sn(t,"click",function(i){i.preventDefault(),i.stopImmediatePropagation()}),t}dispose(){this.contentEl_=null,this.boundHandleBlur_=null,this.boundHandleTapClick_=null,super.dispose()}handleBlur(e){const t=e.relatedTarget||Ve.activeElement;if(!this.children().some(i=>i.el()===t)){const i=this.menuButton_;i&&i.buttonPressed_&&t!==i.el().firstChild&&i.unpressButton()}}handleTapClick(e){if(this.menuButton_){this.menuButton_.unpressButton();const t=this.children();if(!Array.isArray(t))return;const i=t.filter(n=>n.el()===e.target)[0];if(!i)return;i.name()!=="CaptionSettingsMenuItem"&&this.menuButton_.focus()}}handleKeyDown(e){e.key==="ArrowLeft"||e.key==="ArrowDown"?(e.preventDefault(),e.stopPropagation(),this.stepForward()):(e.key==="ArrowRight"||e.key==="ArrowUp")&&(e.preventDefault(),e.stopPropagation(),this.stepBack())}stepForward(){let e=0;this.focusedChild_!==void 0&&(e=this.focusedChild_+1),this.focus(e)}stepBack(){let e=0;this.focusedChild_!==void 0&&(e=this.focusedChild_-1),this.focus(e)}focus(e=0){const t=this.children().slice();t.length&&t[0].hasClass("vjs-menu-title")&&t.shift(),t.length>0&&(e<0?e=0:e>=t.length&&(e=t.length-1),this.focusedChild_=e,t[e].el_.focus())}}ke.registerComponent("Menu",VC);class BT extends ke{constructor(e,t={}){super(e,t),this.menuButton_=new Ds(e,t),this.menuButton_.controlText(this.controlText_),this.menuButton_.el_.setAttribute("aria-haspopup","true");const i=Ds.prototype.buildCSSClass();this.menuButton_.el_.className=this.buildCSSClass()+" "+i,this.menuButton_.removeClass("vjs-control"),this.addChild(this.menuButton_),this.update(),this.enabled_=!0;const n=r=>this.handleClick(r);this.handleMenuKeyUp_=r=>this.handleMenuKeyUp(r),this.on(this.menuButton_,"tap",n),this.on(this.menuButton_,"click",n),this.on(this.menuButton_,"keydown",r=>this.handleKeyDown(r)),this.on(this.menuButton_,"mouseenter",()=>{this.addClass("vjs-hover"),this.menu.show(),Sn(Ve,"keyup",this.handleMenuKeyUp_)}),this.on("mouseleave",r=>this.handleMouseLeave(r)),this.on("keydown",r=>this.handleSubmenuKeyDown(r))}update(){const e=this.createMenu();this.menu&&(this.menu.dispose(),this.removeChild(this.menu)),this.menu=e,this.addChild(e),this.buttonPressed_=!1,this.menuButton_.el_.setAttribute("aria-expanded","false"),this.items&&this.items.length<=this.hideThreshold_?(this.hide(),this.menu.contentEl_.removeAttribute("role")):(this.show(),this.menu.contentEl_.setAttribute("role","menu"))}createMenu(){const e=new VC(this.player_,{menuButton:this});if(this.hideThreshold_=0,this.options_.title){const t=dt("li",{className:"vjs-menu-title",textContent:ki(this.options_.title),tabIndex:-1}),i=new ke(this.player_,{el:t});e.addItem(i)}if(this.items=this.createItems(),this.items)for(let t=0;t<this.items.length;t++)e.addItem(this.items[t]);return e}createItems(){}createEl(){return super.createEl("div",{className:this.buildWrapperCSSClass()},{})}setIcon(e){super.setIcon(e,this.menuButton_.el_)}buildWrapperCSSClass(){let e="vjs-menu-button";this.options_.inline===!0?e+="-inline":e+="-popup";const t=Ds.prototype.buildCSSClass();return`vjs-menu-button ${e} ${t} ${super.buildCSSClass()}`}buildCSSClass(){let e="vjs-menu-button";return this.options_.inline===!0?e+="-inline":e+="-popup",`vjs-menu-button ${e} ${super.buildCSSClass()}`}controlText(e,t=this.menuButton_.el()){return this.menuButton_.controlText(e,t)}dispose(){this.handleMouseLeave(),super.dispose()}handleClick(e){this.buttonPressed_?this.unpressButton():this.pressButton()}handleMouseLeave(e){this.removeClass("vjs-hover"),Cs(Ve,"keyup",this.handleMenuKeyUp_)}focus(){this.menuButton_.focus()}blur(){this.menuButton_.blur()}handleKeyDown(e){e.key==="Escape"||e.key==="Tab"?(this.buttonPressed_&&this.unpressButton(),!e.key==="Tab"&&(e.preventDefault(),this.menuButton_.focus())):(e.key==="Up"||e.key==="Down"&&!(this.player_.options_.playerOptions.spatialNavigation&&this.player_.options_.playerOptions.spatialNavigation.enabled))&&(this.buttonPressed_||(e.preventDefault(),this.pressButton()))}handleMenuKeyUp(e){(e.key==="Escape"||e.key==="Tab")&&this.removeClass("vjs-hover")}handleSubmenuKeyPress(e){this.handleSubmenuKeyDown(e)}handleSubmenuKeyDown(e){(e.key==="Escape"||e.key==="Tab")&&(this.buttonPressed_&&this.unpressButton(),!e.key==="Tab"&&(e.preventDefault(),this.menuButton_.focus()))}pressButton(){if(this.enabled_){if(this.buttonPressed_=!0,this.menu.show(),this.menu.lockShowing(),this.menuButton_.el_.setAttribute("aria-expanded","true"),As&&eC())return;this.menu.focus()}}unpressButton(){this.enabled_&&(this.buttonPressed_=!1,this.menu.unlockShowing(),this.menu.hide(),this.menuButton_.el_.setAttribute("aria-expanded","false"))}disable(){this.unpressButton(),this.enabled_=!1,this.addClass("vjs-disabled"),this.menuButton_.disable()}enable(){this.enabled_=!0,this.removeClass("vjs-disabled"),this.menuButton_.enable()}}ke.registerComponent("MenuButton",BT);class FT extends BT{constructor(e,t){const i=t.tracks;if(super(e,t),this.items.length<=1&&this.hide(),!i)return;const n=hi(this,this.update);i.addEventListener("removetrack",n),i.addEventListener("addtrack",n),i.addEventListener("labelchange",n),this.player_.on("ready",n),this.player_.on("dispose",function(){i.removeEventListener("removetrack",n),i.removeEventListener("addtrack",n),i.removeEventListener("labelchange",n)})}}ke.registerComponent("TrackButton",FT);class uh extends Bm{constructor(e,t){super(e,t),this.selectable=t.selectable,this.isSelected_=t.selected||!1,this.multiSelectable=t.multiSelectable,this.selected(this.isSelected_),this.selectable?this.multiSelectable?this.el_.setAttribute("role","menuitemcheckbox"):this.el_.setAttribute("role","menuitemradio"):this.el_.setAttribute("role","menuitem")}createEl(e,t,i){this.nonIconControl=!0;const n=super.createEl("li",Object.assign({className:"vjs-menu-item",tabIndex:-1},t),i),r=dt("span",{className:"vjs-menu-item-text",textContent:this.localize(this.options_.label)});return this.player_.options_.experimentalSvgIcons?n.appendChild(r):n.replaceChild(r,n.querySelector(".vjs-icon-placeholder")),n}handleKeyDown(e){["Tab","Escape","ArrowUp","ArrowLeft","ArrowRight","ArrowDown"].includes(e.key)||super.handleKeyDown(e)}handleClick(e){this.selected(!0)}selected(e){this.selectable&&(e?(this.addClass("vjs-selected"),this.el_.setAttribute("aria-checked","true"),this.controlText(", selected"),this.isSelected_=!0):(this.removeClass("vjs-selected"),this.el_.setAttribute("aria-checked","false"),this.controlText(""),this.isSelected_=!1))}}ke.registerComponent("MenuItem",uh);class ch extends uh{constructor(e,t){const i=t.track,n=e.textTracks();t.label=i.label||i.language||"Unknown",t.selected=i.mode==="showing",super(e,t),this.track=i,this.kinds=(t.kinds||[t.kind||this.track.kind]).filter(Boolean);const r=(...u)=>{this.handleTracksChange.apply(this,u)},o=(...u)=>{this.handleSelectedLanguageChange.apply(this,u)};if(e.on(["loadstart","texttrackchange"],r),n.addEventListener("change",r),n.addEventListener("selectedlanguagechange",o),this.on("dispose",function(){e.off(["loadstart","texttrackchange"],r),n.removeEventListener("change",r),n.removeEventListener("selectedlanguagechange",o)}),n.onchange===void 0){let u;this.on(["tap","click"],function(){if(typeof ne.Event!="object")try{u=new ne.Event("change")}catch{}u||(u=Ve.createEvent("Event"),u.initEvent("change",!0,!0)),n.dispatchEvent(u)})}this.handleTracksChange()}handleClick(e){const t=this.track,i=this.player_.textTracks();if(super.handleClick(e),!!i)for(let n=0;n<i.length;n++){const r=i[n];this.kinds.indexOf(r.kind)!==-1&&(r===t?r.mode!=="showing"&&(r.mode="showing"):r.mode!=="disabled"&&(r.mode="disabled"))}}handleTracksChange(e){const t=this.track.mode==="showing";t!==this.isSelected_&&this.selected(t)}handleSelectedLanguageChange(e){if(this.track.mode==="showing"){const t=this.player_.cache_.selectedLanguage;if(t&&t.enabled&&t.language===this.track.language&&t.kind!==this.track.kind)return;this.player_.cache_.selectedLanguage={enabled:!0,language:this.track.language,kind:this.track.kind}}}dispose(){this.track=null,super.dispose()}}ke.registerComponent("TextTrackMenuItem",ch);class qC extends ch{constructor(e,t){t.track={player:e,kind:t.kind,kinds:t.kinds,default:!1,mode:"disabled"},t.kinds||(t.kinds=[t.kind]),t.label?t.track.label=t.label:t.track.label=t.kinds.join(" and ")+" off",t.selectable=!0,t.multiSelectable=!1,super(e,t)}handleTracksChange(e){const t=this.player().textTracks();let i=!0;for(let n=0,r=t.length;n<r;n++){const o=t[n];if(this.options_.kinds.indexOf(o.kind)>-1&&o.mode==="showing"){i=!1;break}}i!==this.isSelected_&&this.selected(i)}handleSelectedLanguageChange(e){const t=this.player().textTracks();let i=!0;for(let n=0,r=t.length;n<r;n++){const o=t[n];if(["captions","descriptions","subtitles"].indexOf(o.kind)>-1&&o.mode==="showing"){i=!1;break}}i&&(this.player_.cache_.selectedLanguage={enabled:!1})}handleLanguagechange(){this.$(".vjs-menu-item-text").textContent=this.player_.localize(this.options_.label),super.handleLanguagechange()}}ke.registerComponent("OffTextTrackMenuItem",qC);class hc extends FT{constructor(e,t={}){t.tracks=e.textTracks(),super(e,t)}createItems(e=[],t=ch){let i;this.label_&&(i=`${this.label_} off`),e.push(new qC(this.player_,{kinds:this.kinds_,kind:this.kind_,label:i})),this.hideThreshold_+=1;const n=this.player_.textTracks();Array.isArray(this.kinds_)||(this.kinds_=[this.kind_]);for(let r=0;r<n.length;r++){const o=n[r];if(this.kinds_.indexOf(o.kind)>-1){const u=new t(this.player_,{track:o,kinds:this.kinds_,kind:this.kind_,selectable:!0,multiSelectable:!1});u.addClass(`vjs-${o.kind}-menu-item`),e.push(u)}}return e}}ke.registerComponent("TextTrackButton",hc);class zC extends uh{constructor(e,t){const i=t.track,n=t.cue,r=e.currentTime();t.selectable=!0,t.multiSelectable=!1,t.label=n.text,t.selected=n.startTime<=r&&r<n.endTime,super(e,t),this.track=i,this.cue=n}handleClick(e){super.handleClick(),this.player_.currentTime(this.cue.startTime)}}ke.registerComponent("ChaptersTrackMenuItem",zC);class UT extends hc{constructor(e,t,i){super(e,t,i),this.setIcon("chapters"),this.selectCurrentItem_=()=>{this.items.forEach(n=>{n.selected(this.track_.activeCues[0]===n.cue)})}}buildCSSClass(){return`vjs-chapters-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-chapters-button ${super.buildWrapperCSSClass()}`}update(e){if(e&&e.track&&e.track.kind!=="chapters")return;const t=this.findChaptersTrack();t!==this.track_?(this.setTrack(t),super.update()):(!this.items||t&&t.cues&&t.cues.length!==this.items.length)&&super.update()}setTrack(e){if(this.track_!==e){if(this.updateHandler_||(this.updateHandler_=this.update.bind(this)),this.track_){const t=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);t&&t.removeEventListener("load",this.updateHandler_),this.track_.removeEventListener("cuechange",this.selectCurrentItem_),this.track_=null}if(this.track_=e,this.track_){this.track_.mode="hidden";const t=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);t&&t.addEventListener("load",this.updateHandler_),this.track_.addEventListener("cuechange",this.selectCurrentItem_)}}}findChaptersTrack(){const e=this.player_.textTracks()||[];for(let t=e.length-1;t>=0;t--){const i=e[t];if(i.kind===this.kind_)return i}}getMenuCaption(){return this.track_&&this.track_.label?this.track_.label:this.localize(ki(this.kind_))}createMenu(){return this.options_.title=this.getMenuCaption(),super.createMenu()}createItems(){const e=[];if(!this.track_)return e;const t=this.track_.cues;if(!t)return e;for(let i=0,n=t.length;i<n;i++){const r=t[i],o=new zC(this.player_,{track:this.track_,cue:r});e.push(o)}return e}}UT.prototype.kind_="chapters";UT.prototype.controlText_="Chapters";ke.registerComponent("ChaptersButton",UT);class $T extends hc{constructor(e,t,i){super(e,t,i),this.setIcon("audio-description");const n=e.textTracks(),r=hi(this,this.handleTracksChange);n.addEventListener("change",r),this.on("dispose",function(){n.removeEventListener("change",r)})}handleTracksChange(e){const t=this.player().textTracks();let i=!1;for(let n=0,r=t.length;n<r;n++){const o=t[n];if(o.kind!==this.kind_&&o.mode==="showing"){i=!0;break}}i?this.disable():this.enable()}buildCSSClass(){return`vjs-descriptions-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-descriptions-button ${super.buildWrapperCSSClass()}`}}$T.prototype.kind_="descriptions";$T.prototype.controlText_="Descriptions";ke.registerComponent("DescriptionsButton",$T);class jT extends hc{constructor(e,t,i){super(e,t,i),this.setIcon("subtitles")}buildCSSClass(){return`vjs-subtitles-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-subtitles-button ${super.buildWrapperCSSClass()}`}}jT.prototype.kind_="subtitles";jT.prototype.controlText_="Subtitles";ke.registerComponent("SubtitlesButton",jT);class HT extends ch{constructor(e,t){t.track={player:e,kind:t.kind,label:t.kind+" settings",selectable:!1,default:!1,mode:"disabled"},t.selectable=!1,t.name="CaptionSettingsMenuItem",super(e,t),this.addClass("vjs-texttrack-settings"),this.controlText(", opens "+t.kind+" settings dialog")}handleClick(e){this.player().getChild("textTrackSettings").open()}handleLanguagechange(){this.$(".vjs-menu-item-text").textContent=this.player_.localize(this.options_.kind+" settings"),super.handleLanguagechange()}}ke.registerComponent("CaptionSettingsMenuItem",HT);class GT extends hc{constructor(e,t,i){super(e,t,i),this.setIcon("captions")}buildCSSClass(){return`vjs-captions-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-captions-button ${super.buildWrapperCSSClass()}`}createItems(){const e=[];return!(this.player().tech_&&this.player().tech_.featuresNativeTextTracks)&&this.player().getChild("textTrackSettings")&&(e.push(new HT(this.player_,{kind:this.kind_})),this.hideThreshold_+=1),super.createItems(e)}}GT.prototype.kind_="captions";GT.prototype.controlText_="Captions";ke.registerComponent("CaptionsButton",GT);class KC extends ch{createEl(e,t,i){const n=super.createEl(e,t,i),r=n.querySelector(".vjs-menu-item-text");return this.options_.track.kind==="captions"&&(this.player_.options_.experimentalSvgIcons?this.setIcon("captions",n):r.appendChild(dt("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),r.appendChild(dt("span",{className:"vjs-control-text",textContent:` ${this.localize("Captions")}`}))),n}}ke.registerComponent("SubsCapsMenuItem",KC);class VT extends hc{constructor(e,t={}){super(e,t),this.label_="subtitles",this.setIcon("subtitles"),["en","en-us","en-ca","fr-ca"].indexOf(this.player_.language_)>-1&&(this.label_="captions",this.setIcon("captions")),this.menuButton_.controlText(ki(this.label_))}buildCSSClass(){return`vjs-subs-caps-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-subs-caps-button ${super.buildWrapperCSSClass()}`}createItems(){let e=[];return!(this.player().tech_&&this.player().tech_.featuresNativeTextTracks)&&this.player().getChild("textTrackSettings")&&(e.push(new HT(this.player_,{kind:this.label_})),this.hideThreshold_+=1),e=super.createItems(e,KC),e}}VT.prototype.kinds_=["captions","subtitles"];VT.prototype.controlText_="Subtitles";ke.registerComponent("SubsCapsButton",VT);class YC extends uh{constructor(e,t){const i=t.track,n=e.audioTracks();t.label=i.label||i.language||"Unknown",t.selected=i.enabled,super(e,t),this.track=i,this.addClass(`vjs-${i.kind}-menu-item`);const r=(...o)=>{this.handleTracksChange.apply(this,o)};n.addEventListener("change",r),this.on("dispose",()=>{n.removeEventListener("change",r)})}createEl(e,t,i){const n=super.createEl(e,t,i),r=n.querySelector(".vjs-menu-item-text");return["main-desc","descriptions"].indexOf(this.options_.track.kind)>=0&&(r.appendChild(dt("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),r.appendChild(dt("span",{className:"vjs-control-text",textContent:" "+this.localize("Descriptions")}))),n}handleClick(e){if(super.handleClick(e),this.track.enabled=!0,this.player_.tech_.featuresNativeAudioTracks){const t=this.player_.audioTracks();for(let i=0;i<t.length;i++){const n=t[i];n!==this.track&&(n.enabled=n===this.track)}}}handleTracksChange(e){this.selected(this.track.enabled)}}ke.registerComponent("AudioTrackMenuItem",YC);class WC extends FT{constructor(e,t={}){t.tracks=e.audioTracks(),super(e,t),this.setIcon("audio")}buildCSSClass(){return`vjs-audio-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-audio-button ${super.buildWrapperCSSClass()}`}createItems(e=[]){this.hideThreshold_=1;const t=this.player_.audioTracks();for(let i=0;i<t.length;i++){const n=t[i];e.push(new YC(this.player_,{track:n,selectable:!0,multiSelectable:!1}))}return e}}WC.prototype.controlText_="Audio Track";ke.registerComponent("AudioTrackButton",WC);class qT extends uh{constructor(e,t){const i=t.rate,n=parseFloat(i,10);t.label=i,t.selected=n===e.playbackRate(),t.selectable=!0,t.multiSelectable=!1,super(e,t),this.label=i,this.rate=n,this.on(e,"ratechange",r=>this.update(r))}handleClick(e){super.handleClick(),this.player().playbackRate(this.rate)}update(e){this.selected(this.player().playbackRate()===this.rate)}}qT.prototype.contentElType="button";ke.registerComponent("PlaybackRateMenuItem",qT);class XC extends BT{constructor(e,t){super(e,t),this.menuButton_.el_.setAttribute("aria-describedby",this.labelElId_),this.updateVisibility(),this.updateLabel(),this.on(e,"loadstart",i=>this.updateVisibility(i)),this.on(e,"ratechange",i=>this.updateLabel(i)),this.on(e,"playbackrateschange",i=>this.handlePlaybackRateschange(i))}createEl(){const e=super.createEl();return this.labelElId_="vjs-playback-rate-value-label-"+this.id_,this.labelEl_=dt("div",{className:"vjs-playback-rate-value",id:this.labelElId_,textContent:"1x"}),e.appendChild(this.labelEl_),e}dispose(){this.labelEl_=null,super.dispose()}buildCSSClass(){return`vjs-playback-rate ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-playback-rate ${super.buildWrapperCSSClass()}`}createItems(){const e=this.playbackRates(),t=[];for(let i=e.length-1;i>=0;i--)t.push(new qT(this.player(),{rate:e[i]+"x"}));return t}handlePlaybackRateschange(e){this.update()}playbackRates(){const e=this.player();return e.playbackRates&&e.playbackRates()||[]}playbackRateSupported(){return this.player().tech_&&this.player().tech_.featuresPlaybackRate&&this.playbackRates()&&this.playbackRates().length>0}updateVisibility(e){this.playbackRateSupported()?this.removeClass("vjs-hidden"):this.addClass("vjs-hidden")}updateLabel(e){this.playbackRateSupported()&&(this.labelEl_.textContent=this.player().playbackRate()+"x")}}XC.prototype.controlText_="Playback Rate";ke.registerComponent("PlaybackRateMenuButton",XC);class QC extends ke{buildCSSClass(){return`vjs-spacer ${super.buildCSSClass()}`}createEl(e="div",t={},i={}){return t.className||(t.className=this.buildCSSClass()),super.createEl(e,t,i)}}ke.registerComponent("Spacer",QC);class T3 extends QC{buildCSSClass(){return`vjs-custom-control-spacer ${super.buildCSSClass()}`}createEl(){return super.createEl("div",{className:this.buildCSSClass(),textContent:" "})}}ke.registerComponent("CustomControlSpacer",T3);class ZC extends ke{createEl(){return super.createEl("div",{className:"vjs-control-bar",dir:"ltr"})}}ZC.prototype.options_={children:["playToggle","skipBackward","skipForward","volumePanel","currentTimeDisplay","timeDivider","durationDisplay","progressControl","liveDisplay","seekToLive","remainingTimeDisplay","customControlSpacer","playbackRateMenuButton","chaptersButton","descriptionsButton","subsCapsButton","audioTrackButton","pictureInPictureToggle","fullscreenToggle"]};ke.registerComponent("ControlBar",ZC);class JC extends cc{constructor(e,t){super(e,t),this.on(e,"error",i=>{this.open(i)})}buildCSSClass(){return`vjs-error-display ${super.buildCSSClass()}`}content(){const e=this.player().error();return e?this.localize(e.message):""}}JC.prototype.options_=Object.assign({},cc.prototype.options_,{pauseOnOpen:!1,fillAlways:!0,temporary:!1,uncloseable:!0});ke.registerComponent("ErrorDisplay",JC);class eD extends ke{constructor(e,t={}){super(e,t),this.el_.setAttribute("aria-labelledby",this.selectLabelledbyIds)}createEl(){return this.selectLabelledbyIds=[this.options_.legendId,this.options_.labelId].join(" ").trim(),dt("select",{id:this.options_.id},{},this.options_.SelectOptions.map(t=>{const i=(this.options_.labelId?this.options_.labelId:`vjs-track-option-${Nn()}`)+"-"+t[1].replace(/\W+/g,""),n=dt("option",{id:i,value:this.localize(t[0]),textContent:this.localize(t[1])});return n.setAttribute("aria-labelledby",`${this.selectLabelledbyIds} ${i}`),n}))}}ke.registerComponent("TextTrackSelect",eD);class bl extends ke{constructor(e,t={}){super(e,t);const i=dt("legend",{textContent:this.localize(this.options_.legendText),id:this.options_.legendId});this.el().appendChild(i);const n=this.options_.selects;for(const r of n){const o=this.options_.selectConfigs[r],u=o.className,c=o.id.replace("%s",this.options_.id_);let d=null;const f=`vjs_select_${Nn()}`;if(this.options_.type==="colors"){d=dt("span",{className:u});const g=dt("label",{id:c,className:"vjs-label",textContent:this.localize(o.label)});g.setAttribute("for",f),d.appendChild(g)}const m=new eD(e,{SelectOptions:o.options,legendId:this.options_.legendId,id:f,labelId:c});this.addChild(m),this.options_.type==="colors"&&(d.appendChild(m.el()),this.el().appendChild(d))}}createEl(){return dt("fieldset",{className:this.options_.className})}}ke.registerComponent("TextTrackFieldset",bl);class tD extends ke{constructor(e,t={}){super(e,t);const i=this.options_.textTrackComponentid,n=new bl(e,{id_:i,legendId:`captions-text-legend-${i}`,legendText:this.localize("Text"),className:"vjs-fg vjs-track-setting",selects:this.options_.fieldSets[0],selectConfigs:this.options_.selectConfigs,type:"colors"});this.addChild(n);const r=new bl(e,{id_:i,legendId:`captions-background-${i}`,legendText:this.localize("Text Background"),className:"vjs-bg vjs-track-setting",selects:this.options_.fieldSets[1],selectConfigs:this.options_.selectConfigs,type:"colors"});this.addChild(r);const o=new bl(e,{id_:i,legendId:`captions-window-${i}`,legendText:this.localize("Caption Area Background"),className:"vjs-window vjs-track-setting",selects:this.options_.fieldSets[2],selectConfigs:this.options_.selectConfigs,type:"colors"});this.addChild(o)}createEl(){return dt("div",{className:"vjs-track-settings-colors"})}}ke.registerComponent("TextTrackSettingsColors",tD);class iD extends ke{constructor(e,t={}){super(e,t);const i=this.options_.textTrackComponentid,n=new bl(e,{id_:i,legendId:`captions-font-size-${i}`,legendText:"Font Size",className:"vjs-font-percent vjs-track-setting",selects:this.options_.fieldSets[0],selectConfigs:this.options_.selectConfigs,type:"font"});this.addChild(n);const r=new bl(e,{id_:i,legendId:`captions-edge-style-${i}`,legendText:this.localize("Text Edge Style"),className:"vjs-edge-style vjs-track-setting",selects:this.options_.fieldSets[1],selectConfigs:this.options_.selectConfigs,type:"font"});this.addChild(r);const o=new bl(e,{id_:i,legendId:`captions-font-family-${i}`,legendText:this.localize("Font Family"),className:"vjs-font-family vjs-track-setting",selects:this.options_.fieldSets[2],selectConfigs:this.options_.selectConfigs,type:"font"});this.addChild(o)}createEl(){return dt("div",{className:"vjs-track-settings-font"})}}ke.registerComponent("TextTrackSettingsFont",iD);class sD extends ke{constructor(e,t={}){super(e,t);const i=new Ds(e,{controlText:this.localize("restore all settings to the default values"),className:"vjs-default-button"});i.el().classList.remove("vjs-control","vjs-button"),i.el().textContent=this.localize("Reset"),this.addChild(i);const n=this.localize("Done"),r=new Ds(e,{controlText:n,className:"vjs-done-button"});r.el().classList.remove("vjs-control","vjs-button"),r.el().textContent=n,this.addChild(r)}createEl(){return dt("div",{className:"vjs-track-settings-controls"})}}ke.registerComponent("TrackSettingsControls",sD);const Cy="vjs-text-track-settings",HE=["#000","Black"],GE=["#00F","Blue"],VE=["#0FF","Cyan"],qE=["#0F0","Green"],zE=["#F0F","Magenta"],KE=["#F00","Red"],YE=["#FFF","White"],WE=["#FF0","Yellow"],Dy=["1","Opaque"],wy=["0.5","Semi-Transparent"],XE=["0","Transparent"],po={backgroundColor:{selector:".vjs-bg-color > select",id:"captions-background-color-%s",label:"Color",options:[HE,YE,KE,qE,GE,WE,zE,VE],className:"vjs-bg-color"},backgroundOpacity:{selector:".vjs-bg-opacity > select",id:"captions-background-opacity-%s",label:"Opacity",options:[Dy,wy,XE],className:"vjs-bg-opacity vjs-opacity"},color:{selector:".vjs-text-color > select",id:"captions-foreground-color-%s",label:"Color",options:[YE,HE,KE,qE,GE,WE,zE,VE],className:"vjs-text-color"},edgeStyle:{selector:".vjs-edge-style > select",id:"",label:"Text Edge Style",options:[["none","None"],["raised","Raised"],["depressed","Depressed"],["uniform","Uniform"],["dropshadow","Drop shadow"]]},fontFamily:{selector:".vjs-font-family > select",id:"",label:"Font Family",options:[["proportionalSansSerif","Proportional Sans-Serif"],["monospaceSansSerif","Monospace Sans-Serif"],["proportionalSerif","Proportional Serif"],["monospaceSerif","Monospace Serif"],["casual","Casual"],["script","Script"],["small-caps","Small Caps"]]},fontPercent:{selector:".vjs-font-percent > select",id:"",label:"Font Size",options:[["0.50","50%"],["0.75","75%"],["1.00","100%"],["1.25","125%"],["1.50","150%"],["1.75","175%"],["2.00","200%"],["3.00","300%"],["4.00","400%"]],default:2,parser:s=>s==="1.00"?null:Number(s)},textOpacity:{selector:".vjs-text-opacity > select",id:"captions-foreground-opacity-%s",label:"Opacity",options:[Dy,wy],className:"vjs-text-opacity vjs-opacity"},windowColor:{selector:".vjs-window-color > select",id:"captions-window-color-%s",label:"Color",className:"vjs-window-color"},windowOpacity:{selector:".vjs-window-opacity > select",id:"captions-window-opacity-%s",label:"Opacity",options:[XE,wy,Dy],className:"vjs-window-opacity vjs-opacity"}};po.windowColor.options=po.backgroundColor.options;function nD(s,e){if(e&&(s=e(s)),s&&s!=="none")return s}function b3(s,e){const t=s.options[s.options.selectedIndex].value;return nD(t,e)}function _3(s,e,t){if(e){for(let i=0;i<s.options.length;i++)if(nD(s.options[i].value,t)===e){s.selectedIndex=i;break}}}class x3 extends cc{constructor(e,t){t.temporary=!1,super(e,t),this.updateDisplay=this.updateDisplay.bind(this),this.fill(),this.hasBeenOpened_=this.hasBeenFilled_=!0,this.renderModalComponents(e),this.endDialog=dt("p",{className:"vjs-control-text",textContent:this.localize("End of dialog window.")}),this.el().appendChild(this.endDialog),this.setDefaults(),t.persistTextTrackSettings===void 0&&(this.options_.persistTextTrackSettings=this.options_.playerOptions.persistTextTrackSettings),this.bindFunctionsToSelectsAndButtons(),this.options_.persistTextTrackSettings&&this.restoreSettings()}renderModalComponents(e){const t=new tD(e,{textTrackComponentid:this.id_,selectConfigs:po,fieldSets:[["color","textOpacity"],["backgroundColor","backgroundOpacity"],["windowColor","windowOpacity"]]});this.addChild(t);const i=new iD(e,{textTrackComponentid:this.id_,selectConfigs:po,fieldSets:[["fontPercent"],["edgeStyle"],["fontFamily"]]});this.addChild(i);const n=new sD(e);this.addChild(n)}bindFunctionsToSelectsAndButtons(){this.on(this.$(".vjs-done-button"),["click","tap"],()=>{this.saveSettings(),this.close()}),this.on(this.$(".vjs-default-button"),["click","tap"],()=>{this.setDefaults(),this.updateDisplay()}),Nu(po,e=>{this.on(this.$(e.selector),"change",this.updateDisplay)})}dispose(){this.endDialog=null,super.dispose()}label(){return this.localize("Caption Settings Dialog")}description(){return this.localize("Beginning of dialog window. Escape will cancel and close the window.")}buildCSSClass(){return super.buildCSSClass()+" vjs-text-track-settings"}getValues(){return KA(po,(e,t,i)=>{const n=b3(this.$(t.selector),t.parser);return n!==void 0&&(e[i]=n),e},{})}setValues(e){Nu(po,(t,i)=>{_3(this.$(t.selector),e[i],t.parser)})}setDefaults(){Nu(po,e=>{const t=e.hasOwnProperty("default")?e.default:0;this.$(e.selector).selectedIndex=t})}restoreSettings(){let e;try{e=JSON.parse(ne.localStorage.getItem(Cy))}catch(t){Dt.warn(t)}e&&this.setValues(e)}saveSettings(){if(!this.options_.persistTextTrackSettings)return;const e=this.getValues();try{Object.keys(e).length?ne.localStorage.setItem(Cy,JSON.stringify(e)):ne.localStorage.removeItem(Cy)}catch(t){Dt.warn(t)}}updateDisplay(){const e=this.player_.getChild("textTrackDisplay");e&&e.updateDisplay()}handleLanguagechange(){this.fill(),this.renderModalComponents(this.player_),this.bindFunctionsToSelectsAndButtons()}}ke.registerComponent("TextTrackSettings",x3);class S3 extends ke{constructor(e,t){let i=t.ResizeObserver||ne.ResizeObserver;t.ResizeObserver===null&&(i=!1);const n=si({createEl:!i,reportTouchActivity:!1},t);super(e,n),this.ResizeObserver=t.ResizeObserver||ne.ResizeObserver,this.loadListener_=null,this.resizeObserver_=null,this.debouncedHandler_=gC(()=>{this.resizeHandler()},100,!1,this),i?(this.resizeObserver_=new this.ResizeObserver(this.debouncedHandler_),this.resizeObserver_.observe(e.el())):(this.loadListener_=()=>{if(!this.el_||!this.el_.contentWindow)return;const r=this.debouncedHandler_;let o=this.unloadListener_=function(){Cs(this,"resize",r),Cs(this,"unload",o),o=null};Sn(this.el_.contentWindow,"unload",o),Sn(this.el_.contentWindow,"resize",r)},this.one("load",this.loadListener_))}createEl(){return super.createEl("iframe",{className:"vjs-resize-manager",tabIndex:-1,title:this.localize("No content")},{"aria-hidden":"true"})}resizeHandler(){!this.player_||!this.player_.trigger||this.player_.trigger("playerresize")}dispose(){this.debouncedHandler_&&this.debouncedHandler_.cancel(),this.resizeObserver_&&(this.player_.el()&&this.resizeObserver_.unobserve(this.player_.el()),this.resizeObserver_.disconnect()),this.loadListener_&&this.off("load",this.loadListener_),this.el_&&this.el_.contentWindow&&this.unloadListener_&&this.unloadListener_.call(this.el_.contentWindow),this.ResizeObserver=null,this.resizeObserver=null,this.debouncedHandler_=null,this.loadListener_=null,super.dispose()}}ke.registerComponent("ResizeManager",S3);const E3={trackingThreshold:20,liveTolerance:15};class A3 extends ke{constructor(e,t){const i=si(E3,t,{createEl:!1});super(e,i),this.trackLiveHandler_=()=>this.trackLive_(),this.handlePlay_=n=>this.handlePlay(n),this.handleFirstTimeupdate_=n=>this.handleFirstTimeupdate(n),this.handleSeeked_=n=>this.handleSeeked(n),this.seekToLiveEdge_=n=>this.seekToLiveEdge(n),this.reset_(),this.on(this.player_,"durationchange",n=>this.handleDurationchange(n)),this.on(this.player_,"canplay",()=>this.toggleTracking())}trackLive_(){const e=this.player_.seekable();if(!e||!e.length)return;const t=Number(ne.performance.now().toFixed(4)),i=this.lastTime_===-1?0:(t-this.lastTime_)/1e3;this.lastTime_=t,this.pastSeekEnd_=this.pastSeekEnd()+i;const n=this.liveCurrentTime(),r=this.player_.currentTime();let o=this.player_.paused()||this.seekedBehindLive_||Math.abs(n-r)>this.options_.liveTolerance;(!this.timeupdateSeen_||n===1/0)&&(o=!1),o!==this.behindLiveEdge_&&(this.behindLiveEdge_=o,this.trigger("liveedgechange"))}handleDurationchange(){this.toggleTracking()}toggleTracking(){this.player_.duration()===1/0&&this.liveWindow()>=this.options_.trackingThreshold?(this.player_.options_.liveui&&this.player_.addClass("vjs-liveui"),this.startTracking()):(this.player_.removeClass("vjs-liveui"),this.stopTracking())}startTracking(){this.isTracking()||(this.timeupdateSeen_||(this.timeupdateSeen_=this.player_.hasStarted()),this.trackingInterval_=this.setInterval(this.trackLiveHandler_,Bn),this.trackLive_(),this.on(this.player_,["play","pause"],this.trackLiveHandler_),this.timeupdateSeen_?this.on(this.player_,"seeked",this.handleSeeked_):(this.one(this.player_,"play",this.handlePlay_),this.one(this.player_,"timeupdate",this.handleFirstTimeupdate_)))}handleFirstTimeupdate(){this.timeupdateSeen_=!0,this.on(this.player_,"seeked",this.handleSeeked_)}handleSeeked(){const e=Math.abs(this.liveCurrentTime()-this.player_.currentTime());this.seekedBehindLive_=this.nextSeekedFromUser_&&e>2,this.nextSeekedFromUser_=!1,this.trackLive_()}handlePlay(){this.one(this.player_,"timeupdate",this.seekToLiveEdge_)}reset_(){this.lastTime_=-1,this.pastSeekEnd_=0,this.lastSeekEnd_=-1,this.behindLiveEdge_=!0,this.timeupdateSeen_=!1,this.seekedBehindLive_=!1,this.nextSeekedFromUser_=!1,this.clearInterval(this.trackingInterval_),this.trackingInterval_=null,this.off(this.player_,["play","pause"],this.trackLiveHandler_),this.off(this.player_,"seeked",this.handleSeeked_),this.off(this.player_,"play",this.handlePlay_),this.off(this.player_,"timeupdate",this.handleFirstTimeupdate_),this.off(this.player_,"timeupdate",this.seekToLiveEdge_)}nextSeekedFromUser(){this.nextSeekedFromUser_=!0}stopTracking(){this.isTracking()&&(this.reset_(),this.trigger("liveedgechange"))}seekableEnd(){const e=this.player_.seekable(),t=[];let i=e?e.length:0;for(;i--;)t.push(e.end(i));return t.length?t.sort()[t.length-1]:1/0}seekableStart(){const e=this.player_.seekable(),t=[];let i=e?e.length:0;for(;i--;)t.push(e.start(i));return t.length?t.sort()[0]:0}liveWindow(){const e=this.liveCurrentTime();return e===1/0?0:e-this.seekableStart()}isLive(){return this.isTracking()}atLiveEdge(){return!this.behindLiveEdge()}liveCurrentTime(){return this.pastSeekEnd()+this.seekableEnd()}pastSeekEnd(){const e=this.seekableEnd();return this.lastSeekEnd_!==-1&&e!==this.lastSeekEnd_&&(this.pastSeekEnd_=0),this.lastSeekEnd_=e,this.pastSeekEnd_}behindLiveEdge(){return this.behindLiveEdge_}isTracking(){return typeof this.trackingInterval_=="number"}seekToLiveEdge(){this.seekedBehindLive_=!1,!this.atLiveEdge()&&(this.nextSeekedFromUser_=!1,this.player_.currentTime(this.liveCurrentTime()))}dispose(){this.stopTracking(),super.dispose()}}ke.registerComponent("LiveTracker",A3);class C3 extends ke{constructor(e,t){super(e,t),this.on("statechanged",i=>this.updateDom_()),this.updateDom_()}createEl(){return this.els={title:dt("div",{className:"vjs-title-bar-title",id:`vjs-title-bar-title-${Nn()}`}),description:dt("div",{className:"vjs-title-bar-description",id:`vjs-title-bar-description-${Nn()}`})},dt("div",{className:"vjs-title-bar"},{},YA(this.els))}updateDom_(){const e=this.player_.tech_,t=e&&e.el_,i={title:"aria-labelledby",description:"aria-describedby"};["title","description"].forEach(n=>{const r=this.state[n],o=this.els[n],u=i[n];Rm(o),r&&Co(o,r),t&&(t.removeAttribute(u),r&&t.setAttribute(u,o.id))}),this.state.title||this.state.description?this.show():this.hide()}update(e){this.setState(e)}dispose(){const e=this.player_.tech_,t=e&&e.el_;t&&(t.removeAttribute("aria-labelledby"),t.removeAttribute("aria-describedby")),super.dispose(),this.els=null}}ke.registerComponent("TitleBar",C3);const D3={initialDisplay:4e3,position:[],takeFocus:!1};class w3 extends Ds{constructor(e,t){t=si(D3,t),super(e,t),this.controlText(t.controlText),this.hide(),this.on(this.player_,["useractive","userinactive"],i=>{this.removeClass("force-display")})}buildCSSClass(){return`vjs-transient-button focus-visible ${this.options_.position.map(e=>`vjs-${e}`).join(" ")}`}createEl(){const e=dt("button",{},{type:"button",class:this.buildCSSClass()},dt("span"));return this.controlTextEl_=e.querySelector("span"),e}show(){super.show(),this.addClass("force-display"),this.options_.takeFocus&&this.el().focus({preventScroll:!0}),this.forceDisplayTimeout=this.player_.setTimeout(()=>{this.removeClass("force-display")},this.options_.initialDisplay)}hide(){this.removeClass("force-display"),super.hide()}dispose(){this.player_.clearTimeout(this.forceDisplayTimeout),super.dispose()}}ke.registerComponent("TransientButton",w3);const wv=s=>{const e=s.el();if(e.hasAttribute("src"))return s.triggerSourceset(e.src),!0;const t=s.$$("source"),i=[];let n="";if(!t.length)return!1;for(let r=0;r<t.length;r++){const o=t[r].src;o&&i.indexOf(o)===-1&&i.push(o)}return i.length?(i.length===1&&(n=i[0]),s.triggerSourceset(n),!0):!1},L3=Object.defineProperty({},"innerHTML",{get(){return this.cloneNode(!0).innerHTML},set(s){const e=Ve.createElement(this.nodeName.toLowerCase());e.innerHTML=s;const t=Ve.createDocumentFragment();for(;e.childNodes.length;)t.appendChild(e.childNodes[0]);return this.innerText="",ne.Element.prototype.appendChild.call(this,t),this.innerHTML}}),rD=(s,e)=>{let t={};for(let i=0;i<s.length&&(t=Object.getOwnPropertyDescriptor(s[i],e),!(t&&t.set&&t.get));i++);return t.enumerable=!0,t.configurable=!0,t},I3=s=>rD([s.el(),ne.HTMLMediaElement.prototype,ne.Element.prototype,L3],"innerHTML"),QE=function(s){const e=s.el();if(e.resetSourceWatch_)return;const t={},i=I3(s),n=r=>(...o)=>{const u=r.apply(e,o);return wv(s),u};["append","appendChild","insertAdjacentHTML"].forEach(r=>{e[r]&&(t[r]=e[r],e[r]=n(t[r]))}),Object.defineProperty(e,"innerHTML",si(i,{set:n(i.set)})),e.resetSourceWatch_=()=>{e.resetSourceWatch_=null,Object.keys(t).forEach(r=>{e[r]=t[r]}),Object.defineProperty(e,"innerHTML",i)},s.one("sourceset",e.resetSourceWatch_)},k3=Object.defineProperty({},"src",{get(){return this.hasAttribute("src")?DC(ne.Element.prototype.getAttribute.call(this,"src")):""},set(s){return ne.Element.prototype.setAttribute.call(this,"src",s),s}}),R3=s=>rD([s.el(),ne.HTMLMediaElement.prototype,k3],"src"),O3=function(s){if(!s.featuresSourceset)return;const e=s.el();if(e.resetSourceset_)return;const t=R3(s),i=e.setAttribute,n=e.load;Object.defineProperty(e,"src",si(t,{set:r=>{const o=t.set.call(e,r);return s.triggerSourceset(e.src),o}})),e.setAttribute=(r,o)=>{const u=i.call(e,r,o);return/src/i.test(r)&&s.triggerSourceset(e.src),u},e.load=()=>{const r=n.call(e);return wv(s)||(s.triggerSourceset(""),QE(s)),r},e.currentSrc?s.triggerSourceset(e.currentSrc):wv(s)||QE(s),e.resetSourceset_=()=>{e.resetSourceset_=null,e.load=n,e.setAttribute=i,Object.defineProperty(e,"src",t),e.resetSourceWatch_&&e.resetSourceWatch_()}};class Ze extends bt{constructor(e,t){super(e,t);const i=e.source;let n=!1;if(this.featuresVideoFrameCallback=this.featuresVideoFrameCallback&&this.el_.tagName==="VIDEO",i&&(this.el_.currentSrc!==i.src||e.tag&&e.tag.initNetworkState_===3)?this.setSource(i):this.handleLateInit_(this.el_),e.enableSourceset&&this.setupSourcesetHandling_(),this.isScrubbing_=!1,this.el_.hasChildNodes()){const r=this.el_.childNodes;let o=r.length;const u=[];for(;o--;){const c=r[o];c.nodeName.toLowerCase()==="track"&&(this.featuresNativeTextTracks?(this.remoteTextTrackEls().addTrackElement_(c),this.remoteTextTracks().addTrack(c.track),this.textTracks().addTrack(c.track),!n&&!this.el_.hasAttribute("crossorigin")&&Nm(c.src)&&(n=!0)):u.push(c))}for(let c=0;c<u.length;c++)this.el_.removeChild(u[c])}this.proxyNativeTracks_(),this.featuresNativeTextTracks&&n&&Dt.warn(`Text Tracks are being loaded from another origin but the crossorigin attribute isn't used.
This may prevent text tracks from loading.`),this.restoreMetadataTracksInIOSNativePlayer_(),(qd||Dm)&&e.nativeControlsForTouch===!0&&this.setControls(!0),this.proxyWebkitFullscreen_(),this.triggerReady()}dispose(){this.el_&&this.el_.resetSourceset_&&this.el_.resetSourceset_(),Ze.disposeMediaElement(this.el_),this.options_=null,super.dispose()}setupSourcesetHandling_(){O3(this)}restoreMetadataTracksInIOSNativePlayer_(){const e=this.textTracks();let t;const i=()=>{t=[];for(let r=0;r<e.length;r++){const o=e[r];o.kind==="metadata"&&t.push({track:o,storedMode:o.mode})}};i(),e.addEventListener("change",i),this.on("dispose",()=>e.removeEventListener("change",i));const n=()=>{for(let r=0;r<t.length;r++){const o=t[r];o.track.mode==="disabled"&&o.track.mode!==o.storedMode&&(o.track.mode=o.storedMode)}e.removeEventListener("change",n)};this.on("webkitbeginfullscreen",()=>{e.removeEventListener("change",i),e.removeEventListener("change",n),e.addEventListener("change",n)}),this.on("webkitendfullscreen",()=>{e.removeEventListener("change",i),e.addEventListener("change",i),e.removeEventListener("change",n)})}overrideNative_(e,t){if(t!==this[`featuresNative${e}Tracks`])return;const i=e.toLowerCase();this[`${i}TracksListeners_`]&&Object.keys(this[`${i}TracksListeners_`]).forEach(n=>{this.el()[`${i}Tracks`].removeEventListener(n,this[`${i}TracksListeners_`][n])}),this[`featuresNative${e}Tracks`]=!t,this[`${i}TracksListeners_`]=null,this.proxyNativeTracksForType_(i)}overrideNativeAudioTracks(e){this.overrideNative_("Audio",e)}overrideNativeVideoTracks(e){this.overrideNative_("Video",e)}proxyNativeTracksForType_(e){const t=Mn[e],i=this.el()[t.getterName],n=this[t.getterName]();if(!this[`featuresNative${t.capitalName}Tracks`]||!i||!i.addEventListener)return;const r={change:u=>{const c={type:"change",target:n,currentTarget:n,srcElement:n};n.trigger(c),e==="text"&&this[sc.remoteText.getterName]().trigger(c)},addtrack(u){n.addTrack(u.track)},removetrack(u){n.removeTrack(u.track)}},o=function(){const u=[];for(let c=0;c<n.length;c++){let d=!1;for(let f=0;f<i.length;f++)if(i[f]===n[c]){d=!0;break}d||u.push(n[c])}for(;u.length;)n.removeTrack(u.shift())};this[t.getterName+"Listeners_"]=r,Object.keys(r).forEach(u=>{const c=r[u];i.addEventListener(u,c),this.on("dispose",d=>i.removeEventListener(u,c))}),this.on("loadstart",o),this.on("dispose",u=>this.off("loadstart",o))}proxyNativeTracks_(){Mn.names.forEach(e=>{this.proxyNativeTracksForType_(e)})}createEl(){let e=this.options_.tag;if(!e||!(this.options_.playerElIngest||this.movingMediaElementInDOM)){if(e){const i=e.cloneNode(!0);e.parentNode&&e.parentNode.insertBefore(i,e),Ze.disposeMediaElement(e),e=i}else{e=Ve.createElement("video");const i=this.options_.tag&&fo(this.options_.tag),n=si({},i);(!qd||this.options_.nativeControlsForTouch!==!0)&&delete n.controls,sC(e,Object.assign(n,{id:this.options_.techId,class:"vjs-tech"}))}e.playerId=this.options_.playerId}typeof this.options_.preload<"u"&&ec(e,"preload",this.options_.preload),this.options_.disablePictureInPicture!==void 0&&(e.disablePictureInPicture=this.options_.disablePictureInPicture);const t=["loop","muted","playsinline","autoplay"];for(let i=0;i<t.length;i++){const n=t[i],r=this.options_[n];typeof r<"u"&&(r?ec(e,n,n):Im(e,n),e[n]=r)}return e}handleLateInit_(e){if(e.networkState===0||e.networkState===3)return;if(e.readyState===0){let i=!1;const n=function(){i=!0};this.on("loadstart",n);const r=function(){i||this.trigger("loadstart")};this.on("loadedmetadata",r),this.ready(function(){this.off("loadstart",n),this.off("loadedmetadata",r),i||this.trigger("loadstart")});return}const t=["loadstart"];t.push("loadedmetadata"),e.readyState>=2&&t.push("loadeddata"),e.readyState>=3&&t.push("canplay"),e.readyState>=4&&t.push("canplaythrough"),this.ready(function(){t.forEach(function(i){this.trigger(i)},this)})}setScrubbing(e){this.isScrubbing_=e}scrubbing(){return this.isScrubbing_}setCurrentTime(e){try{this.isScrubbing_&&this.el_.fastSeek&&wm?this.el_.fastSeek(e):this.el_.currentTime=e}catch(t){Dt(t,"Video is not ready. (Video.js)")}}duration(){if(this.el_.duration===1/0&&ir&&Nr&&this.el_.currentTime===0){const e=()=>{this.el_.currentTime>0&&(this.el_.duration===1/0&&this.trigger("durationchange"),this.off("timeupdate",e))};return this.on("timeupdate",e),NaN}return this.el_.duration||NaN}width(){return this.el_.offsetWidth}height(){return this.el_.offsetHeight}proxyWebkitFullscreen_(){if(!("webkitDisplayingFullscreen"in this.el_))return;const e=function(){this.trigger("fullscreenchange",{isFullscreen:!1}),this.el_.controls&&!this.options_.nativeControlsForTouch&&this.controls()&&(this.el_.controls=!1)},t=function(){"webkitPresentationMode"in this.el_&&this.el_.webkitPresentationMode!=="picture-in-picture"&&(this.one("webkitendfullscreen",e),this.trigger("fullscreenchange",{isFullscreen:!0,nativeIOSFullscreen:!0}))};this.on("webkitbeginfullscreen",t),this.on("dispose",()=>{this.off("webkitbeginfullscreen",t),this.off("webkitendfullscreen",e)})}supportsFullScreen(){return typeof this.el_.webkitEnterFullScreen=="function"}enterFullScreen(){const e=this.el_;if(e.paused&&e.networkState<=e.HAVE_METADATA)wr(this.el_.play()),this.setTimeout(function(){e.pause();try{e.webkitEnterFullScreen()}catch(t){this.trigger("fullscreenerror",t)}},0);else try{e.webkitEnterFullScreen()}catch(t){this.trigger("fullscreenerror",t)}}exitFullScreen(){if(!this.el_.webkitDisplayingFullscreen){this.trigger("fullscreenerror",new Error("The video is not fullscreen"));return}this.el_.webkitExitFullScreen()}requestPictureInPicture(){return this.el_.requestPictureInPicture()}requestVideoFrameCallback(e){return this.featuresVideoFrameCallback&&!this.el_.webkitKeys?this.el_.requestVideoFrameCallback(e):super.requestVideoFrameCallback(e)}cancelVideoFrameCallback(e){this.featuresVideoFrameCallback&&!this.el_.webkitKeys?this.el_.cancelVideoFrameCallback(e):super.cancelVideoFrameCallback(e)}src(e){if(e===void 0)return this.el_.src;this.setSrc(e)}addSourceElement(e,t){if(!e)return Dt.error("Invalid source URL."),!1;const i={src:e};t&&(i.type=t);const n=dt("source",{},i);return this.el_.appendChild(n),!0}removeSourceElement(e){if(!e)return Dt.error("Source URL is required to remove the source element."),!1;const t=this.el_.querySelectorAll("source");for(const i of t)if(i.src===e)return this.el_.removeChild(i),!0;return Dt.warn(`No matching source element found with src: ${e}`),!1}reset(){Ze.resetMediaElement(this.el_)}currentSrc(){return this.currentSource_?this.currentSource_.src:this.el_.currentSrc}setControls(e){this.el_.controls=!!e}addTextTrack(e,t,i){return this.featuresNativeTextTracks?this.el_.addTextTrack(e,t,i):super.addTextTrack(e,t,i)}createRemoteTextTrack(e){if(!this.featuresNativeTextTracks)return super.createRemoteTextTrack(e);const t=Ve.createElement("track");return e.kind&&(t.kind=e.kind),e.label&&(t.label=e.label),(e.language||e.srclang)&&(t.srclang=e.language||e.srclang),e.default&&(t.default=e.default),e.id&&(t.id=e.id),e.src&&(t.src=e.src),t}addRemoteTextTrack(e,t){const i=super.addRemoteTextTrack(e,t);return this.featuresNativeTextTracks&&this.el().appendChild(i),i}removeRemoteTextTrack(e){if(super.removeRemoteTextTrack(e),this.featuresNativeTextTracks){const t=this.$$("track");let i=t.length;for(;i--;)(e===t[i]||e===t[i].track)&&this.el().removeChild(t[i])}}getVideoPlaybackQuality(){if(typeof this.el().getVideoPlaybackQuality=="function")return this.el().getVideoPlaybackQuality();const e={};return typeof this.el().webkitDroppedFrameCount<"u"&&typeof this.el().webkitDecodedFrameCount<"u"&&(e.droppedVideoFrames=this.el().webkitDroppedFrameCount,e.totalVideoFrames=this.el().webkitDecodedFrameCount),ne.performance&&(e.creationTime=ne.performance.now()),e}}Em(Ze,"TEST_VID",function(){if(!oc())return;const s=Ve.createElement("video"),e=Ve.createElement("track");return e.kind="captions",e.srclang="en",e.label="English",s.appendChild(e),s});Ze.isSupported=function(){try{Ze.TEST_VID.volume=.5}catch{return!1}return!!(Ze.TEST_VID&&Ze.TEST_VID.canPlayType)};Ze.canPlayType=function(s){return Ze.TEST_VID.canPlayType(s)};Ze.canPlaySource=function(s,e){return Ze.canPlayType(s.type)};Ze.canControlVolume=function(){try{const s=Ze.TEST_VID.volume;Ze.TEST_VID.volume=s/2+.1;const e=s!==Ze.TEST_VID.volume;return e&&As?(ne.setTimeout(()=>{Ze&&Ze.prototype&&(Ze.prototype.featuresVolumeControl=s!==Ze.TEST_VID.volume)}),!1):e}catch{return!1}};Ze.canMuteVolume=function(){try{const s=Ze.TEST_VID.muted;return Ze.TEST_VID.muted=!s,Ze.TEST_VID.muted?ec(Ze.TEST_VID,"muted","muted"):Im(Ze.TEST_VID,"muted","muted"),s!==Ze.TEST_VID.muted}catch{return!1}};Ze.canControlPlaybackRate=function(){if(ir&&Nr&&Am<58)return!1;try{const s=Ze.TEST_VID.playbackRate;return Ze.TEST_VID.playbackRate=s/2+.1,s!==Ze.TEST_VID.playbackRate}catch{return!1}};Ze.canOverrideAttributes=function(){try{const s=()=>{};Object.defineProperty(Ve.createElement("video"),"src",{get:s,set:s}),Object.defineProperty(Ve.createElement("audio"),"src",{get:s,set:s}),Object.defineProperty(Ve.createElement("video"),"innerHTML",{get:s,set:s}),Object.defineProperty(Ve.createElement("audio"),"innerHTML",{get:s,set:s})}catch{return!1}return!0};Ze.supportsNativeTextTracks=function(){return wm||As&&Nr};Ze.supportsNativeVideoTracks=function(){return!!(Ze.TEST_VID&&Ze.TEST_VID.videoTracks)};Ze.supportsNativeAudioTracks=function(){return!!(Ze.TEST_VID&&Ze.TEST_VID.audioTracks)};Ze.Events=["loadstart","suspend","abort","error","emptied","stalled","loadedmetadata","loadeddata","canplay","canplaythrough","playing","waiting","seeking","seeked","ended","durationchange","timeupdate","progress","play","pause","ratechange","resize","volumechange"];[["featuresMuteControl","canMuteVolume"],["featuresPlaybackRate","canControlPlaybackRate"],["featuresSourceset","canOverrideAttributes"],["featuresNativeTextTracks","supportsNativeTextTracks"],["featuresNativeVideoTracks","supportsNativeVideoTracks"],["featuresNativeAudioTracks","supportsNativeAudioTracks"]].forEach(function([s,e]){Em(Ze.prototype,s,()=>Ze[e](),!0)});Ze.prototype.featuresVolumeControl=Ze.canControlVolume();Ze.prototype.movingMediaElementInDOM=!As;Ze.prototype.featuresFullscreenResize=!0;Ze.prototype.featuresProgressEvents=!0;Ze.prototype.featuresTimeupdateEvents=!0;Ze.prototype.featuresVideoFrameCallback=!!(Ze.TEST_VID&&Ze.TEST_VID.requestVideoFrameCallback);Ze.disposeMediaElement=function(s){if(s){for(s.parentNode&&s.parentNode.removeChild(s);s.hasChildNodes();)s.removeChild(s.firstChild);s.removeAttribute("src"),typeof s.load=="function"&&(function(){try{s.load()}catch{}})()}};Ze.resetMediaElement=function(s){if(!s)return;const e=s.querySelectorAll("source");let t=e.length;for(;t--;)s.removeChild(e[t]);s.removeAttribute("src"),typeof s.load=="function"&&(function(){try{s.load()}catch{}})()};["muted","defaultMuted","autoplay","controls","loop","playsinline"].forEach(function(s){Ze.prototype[s]=function(){return this.el_[s]||this.el_.hasAttribute(s)}});["muted","defaultMuted","autoplay","loop","playsinline"].forEach(function(s){Ze.prototype["set"+ki(s)]=function(e){this.el_[s]=e,e?this.el_.setAttribute(s,s):this.el_.removeAttribute(s)}});["paused","currentTime","buffered","volume","poster","preload","error","seeking","seekable","ended","playbackRate","defaultPlaybackRate","disablePictureInPicture","played","networkState","readyState","videoWidth","videoHeight","crossOrigin"].forEach(function(s){Ze.prototype[s]=function(){return this.el_[s]}});["volume","src","poster","preload","playbackRate","defaultPlaybackRate","disablePictureInPicture","crossOrigin"].forEach(function(s){Ze.prototype["set"+ki(s)]=function(e){this.el_[s]=e}});["pause","load","play"].forEach(function(s){Ze.prototype[s]=function(){return this.el_[s]()}});bt.withSourceHandlers(Ze);Ze.nativeSourceHandler={};Ze.nativeSourceHandler.canPlayType=function(s){try{return Ze.TEST_VID.canPlayType(s)}catch{return""}};Ze.nativeSourceHandler.canHandleSource=function(s,e){if(s.type)return Ze.nativeSourceHandler.canPlayType(s.type);if(s.src){const t=IT(s.src);return Ze.nativeSourceHandler.canPlayType(`video/${t}`)}return""};Ze.nativeSourceHandler.handleSource=function(s,e,t){e.setSrc(s.src)};Ze.nativeSourceHandler.dispose=function(){};Ze.registerSourceHandler(Ze.nativeSourceHandler);bt.registerTech("Html5",Ze);const aD=["progress","abort","suspend","emptied","stalled","loadedmetadata","loadeddata","timeupdate","resize","volumechange","texttrackchange"],Ly={canplay:"CanPlay",canplaythrough:"CanPlayThrough",playing:"Playing",seeked:"Seeked"},Lv=["tiny","xsmall","small","medium","large","xlarge","huge"],yp={};Lv.forEach(s=>{const e=s.charAt(0)==="x"?`x-${s.substring(1)}`:s;yp[s]=`vjs-layout-${e}`});const P3={tiny:210,xsmall:320,small:425,medium:768,large:1440,xlarge:2560,huge:1/0};let _i=class Lu extends ke{constructor(e,t,i){if(e.id=e.id||t.id||`vjs_video_${Nn()}`,t=Object.assign(Lu.getTagSettings(e),t),t.initChildren=!1,t.createEl=!1,t.evented=!1,t.reportTouchActivity=!1,!t.language){const o=e.closest("[lang]");o&&(t.language=o.getAttribute("lang"))}if(super(null,t,i),this.boundDocumentFullscreenChange_=o=>this.documentFullscreenChange_(o),this.boundFullWindowOnEscKey_=o=>this.fullWindowOnEscKey(o),this.boundUpdateStyleEl_=o=>this.updateStyleEl_(o),this.boundApplyInitTime_=o=>this.applyInitTime_(o),this.boundUpdateCurrentBreakpoint_=o=>this.updateCurrentBreakpoint_(o),this.boundHandleTechClick_=o=>this.handleTechClick_(o),this.boundHandleTechDoubleClick_=o=>this.handleTechDoubleClick_(o),this.boundHandleTechTouchStart_=o=>this.handleTechTouchStart_(o),this.boundHandleTechTouchMove_=o=>this.handleTechTouchMove_(o),this.boundHandleTechTouchEnd_=o=>this.handleTechTouchEnd_(o),this.boundHandleTechTap_=o=>this.handleTechTap_(o),this.boundUpdatePlayerHeightOnAudioOnlyMode_=o=>this.updatePlayerHeightOnAudioOnlyMode_(o),this.isFullscreen_=!1,this.log=qA(this.id_),this.fsApi_=Rp,this.isPosterFromTech_=!1,this.queuedCallbacks_=[],this.isReady_=!1,this.hasStarted_=!1,this.userActive_=!1,this.debugEnabled_=!1,this.audioOnlyMode_=!1,this.audioPosterMode_=!1,this.audioOnlyCache_={controlBarHeight:null,playerHeight:null,hiddenChildren:[]},!this.options_||!this.options_.techOrder||!this.options_.techOrder.length)throw new Error("No techOrder specified. Did you overwrite videojs.options instead of just changing the properties you want to override?");if(this.tag=e,this.tagAttributes=e&&fo(e),this.language(this.options_.language),t.languages){const o={};Object.getOwnPropertyNames(t.languages).forEach(function(u){o[u.toLowerCase()]=t.languages[u]}),this.languages_=o}else this.languages_=Lu.prototype.options_.languages;this.resetCache_(),this.poster_=t.poster||"",this.controls_=!!t.controls,e.controls=!1,e.removeAttribute("controls"),this.changingSrc_=!1,this.playCallbacks_=[],this.playTerminatedQueue_=[],e.hasAttribute("autoplay")?this.autoplay(!0):this.autoplay(this.options_.autoplay),t.plugins&&Object.keys(t.plugins).forEach(o=>{if(typeof this[o]!="function")throw new Error(`plugin "${o}" does not exist`)}),this.scrubbing_=!1,this.el_=this.createEl(),AT(this,{eventBusKey:"el_"}),this.fsApi_.requestFullscreen&&(Sn(Ve,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),this.on(this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_)),this.fluid_&&this.on(["playerreset","resize"],this.boundUpdateStyleEl_);const n=si(this.options_);if(t.plugins&&Object.keys(t.plugins).forEach(o=>{this[o](t.plugins[o])}),t.debug&&this.debug(!0),this.options_.playerOptions=n,this.middleware_=[],this.playbackRates(t.playbackRates),t.experimentalSvgIcons){const u=new ne.DOMParser().parseFromString(s3,"image/svg+xml");if(u.querySelector("parsererror"))Dt.warn("Failed to load SVG Icons. Falling back to Font Icons."),this.options_.experimentalSvgIcons=null;else{const d=u.documentElement;d.style.display="none",this.el_.appendChild(d),this.addClass("vjs-svg-icons-enabled")}}this.initChildren(),this.isAudio(e.nodeName.toLowerCase()==="audio"),this.controls()?this.addClass("vjs-controls-enabled"):this.addClass("vjs-controls-disabled"),this.el_.setAttribute("role","region"),this.isAudio()?this.el_.setAttribute("aria-label",this.localize("Audio Player")):this.el_.setAttribute("aria-label",this.localize("Video Player")),this.isAudio()&&this.addClass("vjs-audio"),t.spatialNavigation&&t.spatialNavigation.enabled&&(this.spatialNavigation=new n3(this),this.addClass("vjs-spatial-navigation-enabled")),qd&&this.addClass("vjs-touch-enabled"),As||this.addClass("vjs-workinghover"),Lu.players[this.id_]=this;const r=vv.split(".")[0];this.addClass(`vjs-v${r}`),this.userActive(!0),this.reportUserActivity(),this.one("play",o=>this.listenForUserActivity_(o)),this.on("keydown",o=>this.handleKeyDown(o)),this.on("languagechange",o=>this.handleLanguagechange(o)),this.breakpoints(this.options_.breakpoints),this.responsive(this.options_.responsive),this.on("ready",()=>{this.audioPosterMode(this.options_.audioPosterMode),this.audioOnlyMode(this.options_.audioOnlyMode)})}dispose(){this.trigger("dispose"),this.off("dispose"),Cs(Ve,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),Cs(Ve,"keydown",this.boundFullWindowOnEscKey_),this.styleEl_&&this.styleEl_.parentNode&&(this.styleEl_.parentNode.removeChild(this.styleEl_),this.styleEl_=null),Lu.players[this.id_]=null,this.tag&&this.tag.player&&(this.tag.player=null),this.el_&&this.el_.player&&(this.el_.player=null),this.tech_&&(this.tech_.dispose(),this.isPosterFromTech_=!1,this.poster_=""),this.playerElIngest_&&(this.playerElIngest_=null),this.tag&&(this.tag=null),JN(this),Ns.names.forEach(e=>{const t=Ns[e],i=this[t.getterName]();i&&i.off&&i.off()}),super.dispose({restoreEl:this.options_.restoreEl})}createEl(){let e=this.tag,t,i=this.playerElIngest_=e.parentNode&&e.parentNode.hasAttribute&&e.parentNode.hasAttribute("data-vjs-player");const n=this.tag.tagName.toLowerCase()==="video-js";i?t=this.el_=e.parentNode:n||(t=this.el_=super.createEl("div"));const r=fo(e);if(n){for(t=this.el_=e,e=this.tag=Ve.createElement("video");t.children.length;)e.appendChild(t.firstChild);Nd(t,"video-js")||vl(t,"video-js"),t.appendChild(e),i=this.playerElIngest_=t,Object.keys(t).forEach(c=>{try{e[c]=t[c]}catch{}})}e.setAttribute("tabindex","-1"),r.tabindex="-1",Nr&&Cm&&(e.setAttribute("role","application"),r.role="application"),e.removeAttribute("width"),e.removeAttribute("height"),"width"in r&&delete r.width,"height"in r&&delete r.height,Object.getOwnPropertyNames(r).forEach(function(c){n&&c==="class"||t.setAttribute(c,r[c]),n&&e.setAttribute(c,r[c])}),e.playerId=e.id,e.id+="_html5_api",e.className="vjs-tech",e.player=t.player=this,this.addClass("vjs-paused");const o=["IS_SMART_TV","IS_TIZEN","IS_WEBOS","IS_ANDROID","IS_IPAD","IS_IPHONE","IS_CHROMECAST_RECEIVER"].filter(c=>JA[c]).map(c=>"vjs-device-"+c.substring(3).toLowerCase().replace(/\_/g,"-"));if(this.addClass(...o),ne.VIDEOJS_NO_DYNAMIC_STYLE!==!0){this.styleEl_=pC("vjs-styles-dimensions");const c=So(".vjs-styles-defaults"),d=So("head");d.insertBefore(this.styleEl_,c?c.nextSibling:d.firstChild)}this.fill_=!1,this.fluid_=!1,this.width(this.options_.width),this.height(this.options_.height),this.fill(this.options_.fill),this.fluid(this.options_.fluid),this.aspectRatio(this.options_.aspectRatio),this.crossOrigin(this.options_.crossOrigin||this.options_.crossorigin);const u=e.getElementsByTagName("a");for(let c=0;c<u.length;c++){const d=u.item(c);vl(d,"vjs-hidden"),d.setAttribute("hidden","hidden")}return e.initNetworkState_=e.networkState,e.parentNode&&!i&&e.parentNode.insertBefore(t,e),bv(e,t),this.children_.unshift(e),this.el_.setAttribute("lang",this.language_),this.el_.setAttribute("translate","no"),this.el_=t,t}crossOrigin(e){if(typeof e>"u")return this.techGet_("crossOrigin");if(e!==null&&e!=="anonymous"&&e!=="use-credentials"){Dt.warn(`crossOrigin must be null, "anonymous" or "use-credentials", given "${e}"`);return}this.techCall_("setCrossOrigin",e),this.posterImage&&this.posterImage.crossOrigin(e)}width(e){return this.dimension("width",e)}height(e){return this.dimension("height",e)}dimension(e,t){const i=e+"_";if(t===void 0)return this[i]||0;if(t===""||t==="auto"){this[i]=void 0,this.updateStyleEl_();return}const n=parseFloat(t);if(isNaN(n)){Dt.error(`Improper value "${t}" supplied for for ${e}`);return}this[i]=n,this.updateStyleEl_()}fluid(e){if(e===void 0)return!!this.fluid_;this.fluid_=!!e,va(this)&&this.off(["playerreset","resize"],this.boundUpdateStyleEl_),e?(this.addClass("vjs-fluid"),this.fill(!1),kN(this,()=>{this.on(["playerreset","resize"],this.boundUpdateStyleEl_)})):this.removeClass("vjs-fluid"),this.updateStyleEl_()}fill(e){if(e===void 0)return!!this.fill_;this.fill_=!!e,e?(this.addClass("vjs-fill"),this.fluid(!1)):this.removeClass("vjs-fill")}aspectRatio(e){if(e===void 0)return this.aspectRatio_;if(!/^\d+\:\d+$/.test(e))throw new Error("Improper value supplied for aspect ratio. The format should be width:height, for example 16:9.");this.aspectRatio_=e,this.fluid(!0),this.updateStyleEl_()}updateStyleEl_(){if(ne.VIDEOJS_NO_DYNAMIC_STYLE===!0){const u=typeof this.width_=="number"?this.width_:this.options_.width,c=typeof this.height_=="number"?this.height_:this.options_.height,d=this.tech_&&this.tech_.el();d&&(u>=0&&(d.width=u),c>=0&&(d.height=c));return}let e,t,i,n;this.aspectRatio_!==void 0&&this.aspectRatio_!=="auto"?i=this.aspectRatio_:this.videoWidth()>0?i=this.videoWidth()+":"+this.videoHeight():i="16:9";const r=i.split(":"),o=r[1]/r[0];this.width_!==void 0?e=this.width_:this.height_!==void 0?e=this.height_/o:e=this.videoWidth()||300,this.height_!==void 0?t=this.height_:t=e*o,/^[^a-zA-Z]/.test(this.id())?n="dimensions-"+this.id():n=this.id()+"-dimensions",this.addClass(n),mC(this.styleEl_,`
.${n} {
width: ${e}px;
height: ${t}px;
}
.${n}.vjs-fluid:not(.vjs-audio-only-mode) {
padding-top: ${o*100}%;
}
`)}loadTech_(e,t){this.tech_&&this.unloadTech_();const i=ki(e),n=e.charAt(0).toLowerCase()+e.slice(1);i!=="Html5"&&this.tag&&(bt.getTech("Html5").disposeMediaElement(this.tag),this.tag.player=null,this.tag=null),this.techName_=i,this.isReady_=!1;let r=this.autoplay();(typeof this.autoplay()=="string"||this.autoplay()===!0&&this.options_.normalizeAutoplay)&&(r=!1);const o={source:t,autoplay:r,nativeControlsForTouch:this.options_.nativeControlsForTouch,playerId:this.id(),techId:`${this.id()}_${n}_api`,playsinline:this.options_.playsinline,preload:this.options_.preload,loop:this.options_.loop,disablePictureInPicture:this.options_.disablePictureInPicture,muted:this.options_.muted,poster:this.poster(),language:this.language(),playerElIngest:this.playerElIngest_||!1,"vtt.js":this.options_["vtt.js"],canOverridePoster:!!this.options_.techCanOverridePoster,enableSourceset:this.options_.enableSourceset};Ns.names.forEach(c=>{const d=Ns[c];o[d.getterName]=this[d.privateName]}),Object.assign(o,this.options_[i]),Object.assign(o,this.options_[n]),Object.assign(o,this.options_[e.toLowerCase()]),this.tag&&(o.tag=this.tag),t&&t.src===this.cache_.src&&this.cache_.currentTime>0&&(o.startTime=this.cache_.currentTime);const u=bt.getTech(e);if(!u)throw new Error(`No Tech named '${i}' exists! '${i}' should be registered using videojs.registerTech()'`);this.tech_=new u(o),this.tech_.ready(hi(this,this.handleTechReady_),!0),Cv.jsonToTextTracks(this.textTracksJson_||[],this.tech_),aD.forEach(c=>{this.on(this.tech_,c,d=>this[`handleTech${ki(c)}_`](d))}),Object.keys(Ly).forEach(c=>{this.on(this.tech_,c,d=>{if(this.tech_.playbackRate()===0&&this.tech_.seeking()){this.queuedCallbacks_.push({callback:this[`handleTech${Ly[c]}_`].bind(this),event:d});return}this[`handleTech${Ly[c]}_`](d)})}),this.on(this.tech_,"loadstart",c=>this.handleTechLoadStart_(c)),this.on(this.tech_,"sourceset",c=>this.handleTechSourceset_(c)),this.on(this.tech_,"waiting",c=>this.handleTechWaiting_(c)),this.on(this.tech_,"ended",c=>this.handleTechEnded_(c)),this.on(this.tech_,"seeking",c=>this.handleTechSeeking_(c)),this.on(this.tech_,"play",c=>this.handleTechPlay_(c)),this.on(this.tech_,"pause",c=>this.handleTechPause_(c)),this.on(this.tech_,"durationchange",c=>this.handleTechDurationChange_(c)),this.on(this.tech_,"fullscreenchange",(c,d)=>this.handleTechFullscreenChange_(c,d)),this.on(this.tech_,"fullscreenerror",(c,d)=>this.handleTechFullscreenError_(c,d)),this.on(this.tech_,"enterpictureinpicture",c=>this.handleTechEnterPictureInPicture_(c)),this.on(this.tech_,"leavepictureinpicture",c=>this.handleTechLeavePictureInPicture_(c)),this.on(this.tech_,"error",c=>this.handleTechError_(c)),this.on(this.tech_,"posterchange",c=>this.handleTechPosterChange_(c)),this.on(this.tech_,"textdata",c=>this.handleTechTextData_(c)),this.on(this.tech_,"ratechange",c=>this.handleTechRateChange_(c)),this.on(this.tech_,"loadedmetadata",this.boundUpdateStyleEl_),this.usingNativeControls(this.techGet_("controls")),this.controls()&&!this.usingNativeControls()&&this.addTechControlsListeners_(),this.tech_.el().parentNode!==this.el()&&(i!=="Html5"||!this.tag)&&bv(this.tech_.el(),this.el()),this.tag&&(this.tag.player=null,this.tag=null)}unloadTech_(){Ns.names.forEach(e=>{const t=Ns[e];this[t.privateName]=this[t.getterName]()}),this.textTracksJson_=Cv.textTracksToJson(this.tech_),this.isReady_=!1,this.tech_.dispose(),this.tech_=!1,this.isPosterFromTech_&&(this.poster_="",this.trigger("posterchange")),this.isPosterFromTech_=!1}tech(e){return e===void 0&&Dt.warn(`Using the tech directly can be dangerous. I hope you know what you're doing.
See https://github.com/videojs/video.js/issues/2617 for more info.
`),this.tech_}version(){return{"video.js":vv}}addTechControlsListeners_(){this.removeTechControlsListeners_(),this.on(this.tech_,"click",this.boundHandleTechClick_),this.on(this.tech_,"dblclick",this.boundHandleTechDoubleClick_),this.on(this.tech_,"touchstart",this.boundHandleTechTouchStart_),this.on(this.tech_,"touchmove",this.boundHandleTechTouchMove_),this.on(this.tech_,"touchend",this.boundHandleTechTouchEnd_),this.on(this.tech_,"tap",this.boundHandleTechTap_)}removeTechControlsListeners_(){this.off(this.tech_,"tap",this.boundHandleTechTap_),this.off(this.tech_,"touchstart",this.boundHandleTechTouchStart_),this.off(this.tech_,"touchmove",this.boundHandleTechTouchMove_),this.off(this.tech_,"touchend",this.boundHandleTechTouchEnd_),this.off(this.tech_,"click",this.boundHandleTechClick_),this.off(this.tech_,"dblclick",this.boundHandleTechDoubleClick_)}handleTechReady_(){this.triggerReady(),this.cache_.volume&&this.techCall_("setVolume",this.cache_.volume),this.handleTechPosterChange_(),this.handleTechDurationChange_()}handleTechLoadStart_(){this.removeClass("vjs-ended","vjs-seeking"),this.error(null),this.handleTechDurationChange_(),this.paused()?(this.hasStarted(!1),this.trigger("loadstart")):this.trigger("loadstart"),this.manualAutoplay_(this.autoplay()===!0&&this.options_.normalizeAutoplay?"play":this.autoplay())}manualAutoplay_(e){if(!this.tech_||typeof e!="string")return;const t=()=>{const n=this.muted();this.muted(!0);const r=()=>{this.muted(n)};this.playTerminatedQueue_.push(r);const o=this.play();if(Fd(o))return o.catch(u=>{throw r(),new Error(`Rejection at manualAutoplay. Restoring muted value. ${u||""}`)})};let i;if(e==="any"&&!this.muted()?(i=this.play(),Fd(i)&&(i=i.catch(t))):e==="muted"&&!this.muted()?i=t():i=this.play(),!!Fd(i))return i.then(()=>{this.trigger({type:"autoplay-success",autoplay:e})}).catch(()=>{this.trigger({type:"autoplay-failure",autoplay:e})})}updateSourceCaches_(e=""){let t=e,i="";typeof t!="string"&&(t=e.src,i=e.type),this.cache_.source=this.cache_.source||{},this.cache_.sources=this.cache_.sources||[],t&&!i&&(i=i3(this,t)),this.cache_.source=si({},e,{src:t,type:i});const n=this.cache_.sources.filter(c=>c.src&&c.src===t),r=[],o=this.$$("source"),u=[];for(let c=0;c<o.length;c++){const d=fo(o[c]);r.push(d),d.src&&d.src===t&&u.push(d.src)}u.length&&!n.length?this.cache_.sources=r:n.length||(this.cache_.sources=[this.cache_.source]),this.cache_.src=t}handleTechSourceset_(e){if(!this.changingSrc_){let t=r=>this.updateSourceCaches_(r);const i=this.currentSource().src,n=e.src;i&&!/^blob:/.test(i)&&/^blob:/.test(n)&&(!this.lastSource_||this.lastSource_.tech!==n&&this.lastSource_.player!==i)&&(t=()=>{}),t(n),e.src||this.tech_.any(["sourceset","loadstart"],r=>{if(r.type==="sourceset")return;const o=this.techGet_("currentSrc");this.lastSource_.tech=o,this.updateSourceCaches_(o)})}this.lastSource_={player:this.currentSource().src,tech:e.src},this.trigger({src:e.src,type:"sourceset"})}hasStarted(e){if(e===void 0)return this.hasStarted_;e!==this.hasStarted_&&(this.hasStarted_=e,this.hasStarted_?this.addClass("vjs-has-started"):this.removeClass("vjs-has-started"))}handleTechPlay_(){this.removeClass("vjs-ended","vjs-paused"),this.addClass("vjs-playing"),this.hasStarted(!0),this.trigger("play")}handleTechRateChange_(){this.tech_.playbackRate()>0&&this.cache_.lastPlaybackRate===0&&(this.queuedCallbacks_.forEach(e=>e.callback(e.event)),this.queuedCallbacks_=[]),this.cache_.lastPlaybackRate=this.tech_.playbackRate(),this.trigger("ratechange")}handleTechWaiting_(){this.addClass("vjs-waiting"),this.trigger("waiting");const e=this.currentTime(),t=()=>{e!==this.currentTime()&&(this.removeClass("vjs-waiting"),this.off("timeupdate",t))};this.on("timeupdate",t)}handleTechCanPlay_(){this.removeClass("vjs-waiting"),this.trigger("canplay")}handleTechCanPlayThrough_(){this.removeClass("vjs-waiting"),this.trigger("canplaythrough")}handleTechPlaying_(){this.removeClass("vjs-waiting"),this.trigger("playing")}handleTechSeeking_(){this.addClass("vjs-seeking"),this.trigger("seeking")}handleTechSeeked_(){this.removeClass("vjs-seeking","vjs-ended"),this.trigger("seeked")}handleTechPause_(){this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.trigger("pause")}handleTechEnded_(){this.addClass("vjs-ended"),this.removeClass("vjs-waiting"),this.options_.loop?(this.currentTime(0),this.play()):this.paused()||this.pause(),this.trigger("ended")}handleTechDurationChange_(){this.duration(this.techGet_("duration"))}handleTechClick_(e){this.controls_&&(this.options_===void 0||this.options_.userActions===void 0||this.options_.userActions.click===void 0||this.options_.userActions.click!==!1)&&(this.options_!==void 0&&this.options_.userActions!==void 0&&typeof this.options_.userActions.click=="function"?this.options_.userActions.click.call(this,e):this.paused()?wr(this.play()):this.pause())}handleTechDoubleClick_(e){if(!this.controls_)return;Array.prototype.some.call(this.$$(".vjs-control-bar, .vjs-modal-dialog"),i=>i.contains(e.target))||(this.options_===void 0||this.options_.userActions===void 0||this.options_.userActions.doubleClick===void 0||this.options_.userActions.doubleClick!==!1)&&(this.options_!==void 0&&this.options_.userActions!==void 0&&typeof this.options_.userActions.doubleClick=="function"?this.options_.userActions.doubleClick.call(this,e):this.isInPictureInPicture()&&!Ve.pictureInPictureElement?this.exitPictureInPicture():this.isFullscreen()?this.exitFullscreen():this.requestFullscreen())}handleTechTap_(){this.userActive(!this.userActive())}handleTechTouchStart_(){this.userWasActive=this.userActive()}handleTechTouchMove_(){this.userWasActive&&this.reportUserActivity()}handleTechTouchEnd_(e){e.cancelable&&e.preventDefault()}toggleFullscreenClass_(){this.isFullscreen()?this.addClass("vjs-fullscreen"):this.removeClass("vjs-fullscreen")}documentFullscreenChange_(e){const t=e.target.player;if(t&&t!==this)return;const i=this.el();let n=Ve[this.fsApi_.fullscreenElement]===i;!n&&i.matches&&(n=i.matches(":"+this.fsApi_.fullscreen)),this.isFullscreen(n)}handleTechFullscreenChange_(e,t){t&&(t.nativeIOSFullscreen&&(this.addClass("vjs-ios-native-fs"),this.tech_.one("webkitendfullscreen",()=>{this.removeClass("vjs-ios-native-fs")})),this.isFullscreen(t.isFullscreen))}handleTechFullscreenError_(e,t){this.trigger("fullscreenerror",t)}togglePictureInPictureClass_(){this.isInPictureInPicture()?this.addClass("vjs-picture-in-picture"):this.removeClass("vjs-picture-in-picture")}handleTechEnterPictureInPicture_(e){this.isInPictureInPicture(!0)}handleTechLeavePictureInPicture_(e){this.isInPictureInPicture(!1)}handleTechError_(){const e=this.tech_.error();e&&this.error(e)}handleTechTextData_(){let e=null;arguments.length>1&&(e=arguments[1]),this.trigger("textdata",e)}getCache(){return this.cache_}resetCache_(){this.cache_={currentTime:0,initTime:0,inactivityTimeout:this.options_.inactivityTimeout,duration:NaN,lastVolume:1,lastPlaybackRate:this.defaultPlaybackRate(),media:null,src:"",source:{},sources:[],playbackRates:[],volume:1}}techCall_(e,t){this.ready(function(){if(e in QN)return WN(this.middleware_,this.tech_,e,t);if(e in NE)return ME(this.middleware_,this.tech_,e,t);try{this.tech_&&this.tech_[e](t)}catch(i){throw Dt(i),i}},!0)}techGet_(e){if(!(!this.tech_||!this.tech_.isReady_)){if(e in XN)return YN(this.middleware_,this.tech_,e);if(e in NE)return ME(this.middleware_,this.tech_,e);try{return this.tech_[e]()}catch(t){throw this.tech_[e]===void 0?(Dt(`Video.js: ${e} method not defined for ${this.techName_} playback technology.`,t),t):t.name==="TypeError"?(Dt(`Video.js: ${e} unavailable on ${this.techName_} playback technology element.`,t),this.tech_.isReady_=!1,t):(Dt(t),t)}}}play(){return new Promise(e=>{this.play_(e)})}play_(e=wr){this.playCallbacks_.push(e);const t=!!(!this.changingSrc_&&(this.src()||this.currentSrc())),i=!!(wm||As);if(this.waitToPlay_&&(this.off(["ready","loadstart"],this.waitToPlay_),this.waitToPlay_=null),!this.isReady_||!t){this.waitToPlay_=o=>{this.play_()},this.one(["ready","loadstart"],this.waitToPlay_),!t&&i&&this.load();return}const n=this.techGet_("play");i&&this.hasClass("vjs-ended")&&this.resetProgressBar_(),n===null?this.runPlayTerminatedQueue_():this.runPlayCallbacks_(n)}runPlayTerminatedQueue_(){const e=this.playTerminatedQueue_.slice(0);this.playTerminatedQueue_=[],e.forEach(function(t){t()})}runPlayCallbacks_(e){const t=this.playCallbacks_.slice(0);this.playCallbacks_=[],this.playTerminatedQueue_=[],t.forEach(function(i){i(e)})}pause(){this.techCall_("pause")}paused(){return this.techGet_("paused")!==!1}played(){return this.techGet_("played")||tr(0,0)}scrubbing(e){if(typeof e>"u")return this.scrubbing_;this.scrubbing_=!!e,this.techCall_("setScrubbing",this.scrubbing_),e?this.addClass("vjs-scrubbing"):this.removeClass("vjs-scrubbing")}currentTime(e){if(e===void 0)return this.cache_.currentTime=this.techGet_("currentTime")||0,this.cache_.currentTime;if(e<0&&(e=0),!this.isReady_||this.changingSrc_||!this.tech_||!this.tech_.isReady_){this.cache_.initTime=e,this.off("canplay",this.boundApplyInitTime_),this.one("canplay",this.boundApplyInitTime_);return}this.techCall_("setCurrentTime",e),this.cache_.initTime=0,isFinite(e)&&(this.cache_.currentTime=Number(e))}applyInitTime_(){this.currentTime(this.cache_.initTime)}duration(e){if(e===void 0)return this.cache_.duration!==void 0?this.cache_.duration:NaN;e=parseFloat(e),e<0&&(e=1/0),e!==this.cache_.duration&&(this.cache_.duration=e,e===1/0?this.addClass("vjs-live"):this.removeClass("vjs-live"),isNaN(e)||this.trigger("durationchange"))}remainingTime(){return this.duration()-this.currentTime()}remainingTimeDisplay(){return Math.floor(this.duration())-Math.floor(this.currentTime())}buffered(){let e=this.techGet_("buffered");return(!e||!e.length)&&(e=tr(0,0)),e}seekable(){let e=this.techGet_("seekable");return(!e||!e.length)&&(e=tr(0,0)),e}seeking(){return this.techGet_("seeking")}ended(){return this.techGet_("ended")}networkState(){return this.techGet_("networkState")}readyState(){return this.techGet_("readyState")}bufferedPercent(){return EC(this.buffered(),this.duration())}bufferedEnd(){const e=this.buffered(),t=this.duration();let i=e.end(e.length-1);return i>t&&(i=t),i}volume(e){let t;if(e!==void 0){t=Math.max(0,Math.min(1,e)),this.cache_.volume=t,this.techCall_("setVolume",t),t>0&&this.lastVolume_(t);return}return t=parseFloat(this.techGet_("volume")),isNaN(t)?1:t}muted(e){if(e!==void 0){this.techCall_("setMuted",e);return}return this.techGet_("muted")||!1}defaultMuted(e){return e!==void 0&&this.techCall_("setDefaultMuted",e),this.techGet_("defaultMuted")||!1}lastVolume_(e){if(e!==void 0&&e!==0){this.cache_.lastVolume=e;return}return this.cache_.lastVolume}supportsFullScreen(){return this.techGet_("supportsFullScreen")||!1}isFullscreen(e){if(e!==void 0){const t=this.isFullscreen_;this.isFullscreen_=!!e,this.isFullscreen_!==t&&this.fsApi_.prefixed&&this.trigger("fullscreenchange"),this.toggleFullscreenClass_();return}return this.isFullscreen_}requestFullscreen(e){this.isInPictureInPicture()&&this.exitPictureInPicture();const t=this;return new Promise((i,n)=>{function r(){t.off("fullscreenerror",u),t.off("fullscreenchange",o)}function o(){r(),i()}function u(d,f){r(),n(f)}t.one("fullscreenchange",o),t.one("fullscreenerror",u);const c=t.requestFullscreenHelper_(e);c&&(c.then(r,r),c.then(i,n))})}requestFullscreenHelper_(e){let t;if(this.fsApi_.prefixed||(t=this.options_.fullscreen&&this.options_.fullscreen.options||{},e!==void 0&&(t=e)),this.fsApi_.requestFullscreen){const i=this.el_[this.fsApi_.requestFullscreen](t);return i&&i.then(()=>this.isFullscreen(!0),()=>this.isFullscreen(!1)),i}else this.tech_.supportsFullScreen()&&!this.options_.preferFullWindow?this.techCall_("enterFullScreen"):this.enterFullWindow()}exitFullscreen(){const e=this;return new Promise((t,i)=>{function n(){e.off("fullscreenerror",o),e.off("fullscreenchange",r)}function r(){n(),t()}function o(c,d){n(),i(d)}e.one("fullscreenchange",r),e.one("fullscreenerror",o);const u=e.exitFullscreenHelper_();u&&(u.then(n,n),u.then(t,i))})}exitFullscreenHelper_(){if(this.fsApi_.requestFullscreen){const e=Ve[this.fsApi_.exitFullscreen]();return e&&wr(e.then(()=>this.isFullscreen(!1))),e}else this.tech_.supportsFullScreen()&&!this.options_.preferFullWindow?this.techCall_("exitFullScreen"):this.exitFullWindow()}enterFullWindow(){this.isFullscreen(!0),this.isFullWindow=!0,this.docOrigOverflow=Ve.documentElement.style.overflow,Sn(Ve,"keydown",this.boundFullWindowOnEscKey_),Ve.documentElement.style.overflow="hidden",vl(Ve.body,"vjs-full-window"),this.trigger("enterFullWindow")}fullWindowOnEscKey(e){e.key==="Escape"&&this.isFullscreen()===!0&&(this.isFullWindow?this.exitFullWindow():this.exitFullscreen())}exitFullWindow(){this.isFullscreen(!1),this.isFullWindow=!1,Cs(Ve,"keydown",this.boundFullWindowOnEscKey_),Ve.documentElement.style.overflow=this.docOrigOverflow,Lm(Ve.body,"vjs-full-window"),this.trigger("exitFullWindow")}disablePictureInPicture(e){if(e===void 0)return this.techGet_("disablePictureInPicture");this.techCall_("setDisablePictureInPicture",e),this.options_.disablePictureInPicture=e,this.trigger("disablepictureinpicturechanged")}isInPictureInPicture(e){if(e!==void 0){this.isInPictureInPicture_=!!e,this.togglePictureInPictureClass_();return}return!!this.isInPictureInPicture_}requestPictureInPicture(){if(this.options_.enableDocumentPictureInPicture&&ne.documentPictureInPicture){const e=Ve.createElement(this.el().tagName);return e.classList=this.el().classList,e.classList.add("vjs-pip-container"),this.posterImage&&e.appendChild(this.posterImage.el().cloneNode(!0)),this.titleBar&&e.appendChild(this.titleBar.el().cloneNode(!0)),e.appendChild(dt("p",{className:"vjs-pip-text"},{},this.localize("Playing in picture-in-picture"))),ne.documentPictureInPicture.requestWindow({width:this.videoWidth(),height:this.videoHeight()}).then(t=>(dC(t),this.el_.parentNode.insertBefore(e,this.el_),t.document.body.appendChild(this.el_),t.document.body.classList.add("vjs-pip-window"),this.player_.isInPictureInPicture(!0),this.player_.trigger({type:"enterpictureinpicture",pipWindow:t}),t.addEventListener("pagehide",i=>{const n=i.target.querySelector(".video-js");e.parentNode.replaceChild(n,e),this.player_.isInPictureInPicture(!1),this.player_.trigger("leavepictureinpicture")}),t))}return"pictureInPictureEnabled"in Ve&&this.disablePictureInPicture()===!1?this.techGet_("requestPictureInPicture"):Promise.reject("No PiP mode is available")}exitPictureInPicture(){if(ne.documentPictureInPicture&&ne.documentPictureInPicture.window)return ne.documentPictureInPicture.window.close(),Promise.resolve();if("pictureInPictureEnabled"in Ve)return Ve.exitPictureInPicture()}handleKeyDown(e){const{userActions:t}=this.options_;!t||!t.hotkeys||(n=>{const r=n.tagName.toLowerCase();if(n.isContentEditable)return!0;const o=["button","checkbox","hidden","radio","reset","submit"];return r==="input"?o.indexOf(n.type)===-1:["textarea"].indexOf(r)!==-1})(this.el_.ownerDocument.activeElement)||(typeof t.hotkeys=="function"?t.hotkeys.call(this,e):this.handleHotkeys(e))}handleHotkeys(e){const t=this.options_.userActions?this.options_.userActions.hotkeys:{},{fullscreenKey:i=o=>e.key.toLowerCase()==="f",muteKey:n=o=>e.key.toLowerCase()==="m",playPauseKey:r=o=>e.key.toLowerCase()==="k"||e.key.toLowerCase()===" "}=t;if(i.call(this,e)){e.preventDefault(),e.stopPropagation();const o=ke.getComponent("FullscreenToggle");Ve[this.fsApi_.fullscreenEnabled]!==!1&&o.prototype.handleClick.call(this,e)}else n.call(this,e)?(e.preventDefault(),e.stopPropagation(),ke.getComponent("MuteToggle").prototype.handleClick.call(this,e)):r.call(this,e)&&(e.preventDefault(),e.stopPropagation(),ke.getComponent("PlayToggle").prototype.handleClick.call(this,e))}canPlayType(e){let t;for(let i=0,n=this.options_.techOrder;i<n.length;i++){const r=n[i];let o=bt.getTech(r);if(o||(o=ke.getComponent(r)),!o){Dt.error(`The "${r}" tech is undefined. Skipped browser support check for that tech.`);continue}if(o.isSupported()&&(t=o.canPlayType(e),t))return t}return""}selectSource(e){const t=this.options_.techOrder.map(u=>[u,bt.getTech(u)]).filter(([u,c])=>c?c.isSupported():(Dt.error(`The "${u}" tech is undefined. Skipped browser support check for that tech.`),!1)),i=function(u,c,d){let f;return u.some(m=>c.some(g=>{if(f=d(m,g),f)return!0})),f};let n;const r=u=>(c,d)=>u(d,c),o=([u,c],d)=>{if(c.canPlaySource(d,this.options_[u.toLowerCase()]))return{source:d,tech:u}};return this.options_.sourceOrder?n=i(e,t,r(o)):n=i(t,e,o),n||!1}handleSrc_(e,t){if(typeof e>"u")return this.cache_.src||"";this.resetRetryOnError_&&this.resetRetryOnError_();const i=IC(e);if(!i.length){this.setTimeout(function(){this.error({code:4,message:this.options_.notSupportedMessage})},0);return}if(this.changingSrc_=!0,t||(this.cache_.sources=i),this.updateSourceCaches_(i[0]),zN(this,i[0],(n,r)=>{if(this.middleware_=r,t||(this.cache_.sources=i),this.updateSourceCaches_(n),this.src_(n)){if(i.length>1)return this.handleSrc_(i.slice(1));this.changingSrc_=!1,this.setTimeout(function(){this.error({code:4,message:this.options_.notSupportedMessage})},0),this.triggerReady();return}KN(r,this.tech_)}),i.length>1){const n=()=>{this.error(null),this.handleSrc_(i.slice(1),!0)},r=()=>{this.off("error",n)};this.one("error",n),this.one("playing",r),this.resetRetryOnError_=()=>{this.off("error",n),this.off("playing",r)}}}src(e){return this.handleSrc_(e,!1)}src_(e){const t=this.selectSource([e]);return t?bC(t.tech,this.techName_)?(this.ready(function(){this.tech_.constructor.prototype.hasOwnProperty("setSource")?this.techCall_("setSource",e):this.techCall_("src",e.src),this.changingSrc_=!1},!0),!1):(this.changingSrc_=!0,this.loadTech_(t.tech,t.source),this.tech_.ready(()=>{this.changingSrc_=!1}),!1):!0}addSourceElement(e,t){return this.tech_?this.tech_.addSourceElement(e,t):!1}removeSourceElement(e){return this.tech_?this.tech_.removeSourceElement(e):!1}load(){if(this.tech_&&this.tech_.vhs){this.src(this.currentSource());return}this.techCall_("load")}reset(){if(this.paused())this.doReset_();else{const e=this.play();wr(e.then(()=>this.doReset_()))}}doReset_(){this.tech_&&this.tech_.clearTracks("text"),this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.resetCache_(),this.poster(""),this.loadTech_(this.options_.techOrder[0],null),this.techCall_("reset"),this.resetControlBarUI_(),this.error(null),this.titleBar&&this.titleBar.update({title:void 0,description:void 0}),va(this)&&this.trigger("playerreset")}resetControlBarUI_(){this.resetProgressBar_(),this.resetPlaybackRate_(),this.resetVolumeBar_()}resetProgressBar_(){this.currentTime(0);const{currentTimeDisplay:e,durationDisplay:t,progressControl:i,remainingTimeDisplay:n}=this.controlBar||{},{seekBar:r}=i||{};e&&e.updateContent(),t&&t.updateContent(),n&&n.updateContent(),r&&(r.update(),r.loadProgressBar&&r.loadProgressBar.update())}resetPlaybackRate_(){this.playbackRate(this.defaultPlaybackRate()),this.handleTechRateChange_()}resetVolumeBar_(){this.volume(1),this.trigger("volumechange")}currentSources(){const e=this.currentSource(),t=[];return Object.keys(e).length!==0&&t.push(e),this.cache_.sources||t}currentSource(){return this.cache_.source||{}}currentSrc(){return this.currentSource()&&this.currentSource().src||""}currentType(){return this.currentSource()&&this.currentSource().type||""}preload(e){if(e!==void 0){this.techCall_("setPreload",e),this.options_.preload=e;return}return this.techGet_("preload")}autoplay(e){if(e===void 0)return this.options_.autoplay||!1;let t;typeof e=="string"&&/(any|play|muted)/.test(e)||e===!0&&this.options_.normalizeAutoplay?(this.options_.autoplay=e,this.manualAutoplay_(typeof e=="string"?e:"play"),t=!1):e?this.options_.autoplay=!0:this.options_.autoplay=!1,t=typeof t>"u"?this.options_.autoplay:t,this.tech_&&this.techCall_("setAutoplay",t)}playsinline(e){return e!==void 0&&(this.techCall_("setPlaysinline",e),this.options_.playsinline=e),this.techGet_("playsinline")}loop(e){if(e!==void 0){this.techCall_("setLoop",e),this.options_.loop=e;return}return this.techGet_("loop")}poster(e){if(e===void 0)return this.poster_;e||(e=""),e!==this.poster_&&(this.poster_=e,this.techCall_("setPoster",e),this.isPosterFromTech_=!1,this.trigger("posterchange"))}handleTechPosterChange_(){if((!this.poster_||this.options_.techCanOverridePoster)&&this.tech_&&this.tech_.poster){const e=this.tech_.poster()||"";e!==this.poster_&&(this.poster_=e,this.isPosterFromTech_=!0,this.trigger("posterchange"))}}controls(e){if(e===void 0)return!!this.controls_;e=!!e,this.controls_!==e&&(this.controls_=e,this.usingNativeControls()&&this.techCall_("setControls",e),this.controls_?(this.removeClass("vjs-controls-disabled"),this.addClass("vjs-controls-enabled"),this.trigger("controlsenabled"),this.usingNativeControls()||this.addTechControlsListeners_()):(this.removeClass("vjs-controls-enabled"),this.addClass("vjs-controls-disabled"),this.trigger("controlsdisabled"),this.usingNativeControls()||this.removeTechControlsListeners_()))}usingNativeControls(e){if(e===void 0)return!!this.usingNativeControls_;e=!!e,this.usingNativeControls_!==e&&(this.usingNativeControls_=e,this.usingNativeControls_?(this.addClass("vjs-using-native-controls"),this.trigger("usingnativecontrols")):(this.removeClass("vjs-using-native-controls"),this.trigger("usingcustomcontrols")))}error(e){if(e===void 0)return this.error_||null;if(xo("beforeerror").forEach(t=>{const i=t(this,e);if(!(Mr(i)&&!Array.isArray(i)||typeof i=="string"||typeof i=="number"||i===null)){this.log.error("please return a value that MediaError expects in beforeerror hooks");return}e=i}),this.options_.suppressNotSupportedError&&e&&e.code===4){const t=function(){this.error(e)};this.options_.suppressNotSupportedError=!1,this.any(["click","touchstart"],t),this.one("loadstart",function(){this.off(["click","touchstart"],t)});return}if(e===null){this.error_=null,this.removeClass("vjs-error"),this.errorDisplay&&this.errorDisplay.close();return}this.error_=new Ci(e),this.addClass("vjs-error"),Dt.error(`(CODE:${this.error_.code} ${Ci.errorTypes[this.error_.code]})`,this.error_.message,this.error_),this.trigger("error"),xo("error").forEach(t=>t(this,this.error_))}reportUserActivity(e){this.userActivity_=!0}userActive(e){if(e===void 0)return this.userActive_;if(e=!!e,e!==this.userActive_){if(this.userActive_=e,this.userActive_){this.userActivity_=!0,this.removeClass("vjs-user-inactive"),this.addClass("vjs-user-active"),this.trigger("useractive");return}this.tech_&&this.tech_.one("mousemove",function(t){t.stopPropagation(),t.preventDefault()}),this.userActivity_=!1,this.removeClass("vjs-user-active"),this.addClass("vjs-user-inactive"),this.trigger("userinactive")}}listenForUserActivity_(){let e,t,i;const n=hi(this,this.reportUserActivity),r=function(m){(m.screenX!==t||m.screenY!==i)&&(t=m.screenX,i=m.screenY,n())},o=function(){n(),this.clearInterval(e),e=this.setInterval(n,250)},u=function(m){n(),this.clearInterval(e)};this.on("mousedown",o),this.on("mousemove",r),this.on("mouseup",u),this.on("mouseleave",u);const c=this.getChild("controlBar");c&&!As&&!ir&&(c.on("mouseenter",function(m){this.player().options_.inactivityTimeout!==0&&(this.player().cache_.inactivityTimeout=this.player().options_.inactivityTimeout),this.player().options_.inactivityTimeout=0}),c.on("mouseleave",function(m){this.player().options_.inactivityTimeout=this.player().cache_.inactivityTimeout})),this.on("keydown",n),this.on("keyup",n);let d;const f=function(){if(!this.userActivity_)return;this.userActivity_=!1,this.userActive(!0),this.clearTimeout(d);const m=this.options_.inactivityTimeout;m<=0||(d=this.setTimeout(function(){this.userActivity_||this.userActive(!1)},m))};this.setInterval(f,250)}playbackRate(e){if(e!==void 0){this.techCall_("setPlaybackRate",e);return}return this.tech_&&this.tech_.featuresPlaybackRate?this.cache_.lastPlaybackRate||this.techGet_("playbackRate"):1}defaultPlaybackRate(e){return e!==void 0?this.techCall_("setDefaultPlaybackRate",e):this.tech_&&this.tech_.featuresPlaybackRate?this.techGet_("defaultPlaybackRate"):1}isAudio(e){if(e!==void 0){this.isAudio_=!!e;return}return!!this.isAudio_}updatePlayerHeightOnAudioOnlyMode_(){const e=this.getChild("ControlBar");!e||this.audioOnlyCache_.controlBarHeight===e.currentHeight()||(this.audioOnlyCache_.controlBarHeight=e.currentHeight(),this.height(this.audioOnlyCache_.controlBarHeight))}enableAudioOnlyUI_(){this.addClass("vjs-audio-only-mode");const e=this.children(),t=this.getChild("ControlBar"),i=t&&t.currentHeight();e.forEach(n=>{n!==t&&n.el_&&!n.hasClass("vjs-hidden")&&(n.hide(),this.audioOnlyCache_.hiddenChildren.push(n))}),this.audioOnlyCache_.playerHeight=this.currentHeight(),this.audioOnlyCache_.controlBarHeight=i,this.on("playerresize",this.boundUpdatePlayerHeightOnAudioOnlyMode_),this.height(i),this.trigger("audioonlymodechange")}disableAudioOnlyUI_(){this.removeClass("vjs-audio-only-mode"),this.off("playerresize",this.boundUpdatePlayerHeightOnAudioOnlyMode_),this.audioOnlyCache_.hiddenChildren.forEach(e=>e.show()),this.height(this.audioOnlyCache_.playerHeight),this.trigger("audioonlymodechange")}audioOnlyMode(e){if(typeof e!="boolean"||e===this.audioOnlyMode_)return this.audioOnlyMode_;if(this.audioOnlyMode_=e,e){const t=[];return this.isInPictureInPicture()&&t.push(this.exitPictureInPicture()),this.isFullscreen()&&t.push(this.exitFullscreen()),this.audioPosterMode()&&t.push(this.audioPosterMode(!1)),Promise.all(t).then(()=>this.enableAudioOnlyUI_())}return Promise.resolve().then(()=>this.disableAudioOnlyUI_())}enablePosterModeUI_(){(this.tech_&&this.tech_).hide(),this.addClass("vjs-audio-poster-mode"),this.trigger("audiopostermodechange")}disablePosterModeUI_(){(this.tech_&&this.tech_).show(),this.removeClass("vjs-audio-poster-mode"),this.trigger("audiopostermodechange")}audioPosterMode(e){return typeof e!="boolean"||e===this.audioPosterMode_?this.audioPosterMode_:(this.audioPosterMode_=e,e?this.audioOnlyMode()?this.audioOnlyMode(!1).then(()=>{this.enablePosterModeUI_()}):Promise.resolve().then(()=>{this.enablePosterModeUI_()}):Promise.resolve().then(()=>{this.disablePosterModeUI_()}))}addTextTrack(e,t,i){if(this.tech_)return this.tech_.addTextTrack(e,t,i)}addRemoteTextTrack(e,t){if(this.tech_)return this.tech_.addRemoteTextTrack(e,t)}removeRemoteTextTrack(e={}){let{track:t}=e;if(t||(t=e),this.tech_)return this.tech_.removeRemoteTextTrack(t)}getVideoPlaybackQuality(){return this.techGet_("getVideoPlaybackQuality")}videoWidth(){return this.tech_&&this.tech_.videoWidth&&this.tech_.videoWidth()||0}videoHeight(){return this.tech_&&this.tech_.videoHeight&&this.tech_.videoHeight()||0}language(e){if(e===void 0)return this.language_;this.language_!==String(e).toLowerCase()&&(this.language_=String(e).toLowerCase(),va(this)&&this.trigger("languagechange"))}languages(){return si(Lu.prototype.options_.languages,this.languages_)}toJSON(){const e=si(this.options_),t=e.tracks;e.tracks=[];for(let i=0;i<t.length;i++){let n=t[i];n=si(n),n.player=void 0,e.tracks[i]=n}return e}createModal(e,t){t=t||{},t.content=e||"";const i=new cc(this,t);return this.addChild(i),i.on("dispose",()=>{this.removeChild(i)}),i.open(),i}updateCurrentBreakpoint_(){if(!this.responsive())return;const e=this.currentBreakpoint(),t=this.currentWidth();for(let i=0;i<Lv.length;i++){const n=Lv[i],r=this.breakpoints_[n];if(t<=r){if(e===n)return;e&&this.removeClass(yp[e]),this.addClass(yp[n]),this.breakpoint_=n;break}}}removeCurrentBreakpoint_(){const e=this.currentBreakpointClass();this.breakpoint_="",e&&this.removeClass(e)}breakpoints(e){return e===void 0?Object.assign(this.breakpoints_):(this.breakpoint_="",this.breakpoints_=Object.assign({},P3,e),this.updateCurrentBreakpoint_(),Object.assign(this.breakpoints_))}responsive(e){if(e===void 0)return this.responsive_;e=!!e;const t=this.responsive_;if(e!==t)return this.responsive_=e,e?(this.on("playerresize",this.boundUpdateCurrentBreakpoint_),this.updateCurrentBreakpoint_()):(this.off("playerresize",this.boundUpdateCurrentBreakpoint_),this.removeCurrentBreakpoint_()),e}currentBreakpoint(){return this.breakpoint_}currentBreakpointClass(){return yp[this.breakpoint_]||""}loadMedia(e,t){if(!e||typeof e!="object")return;const i=this.crossOrigin();this.reset(),this.cache_.media=si(e);const{artist:n,artwork:r,description:o,poster:u,src:c,textTracks:d,title:f}=this.cache_.media;!r&&u&&(this.cache_.media.artwork=[{src:u,type:Hp(u)}]),i&&this.crossOrigin(i),c&&this.src(c),u&&this.poster(u),Array.isArray(d)&&d.forEach(m=>this.addRemoteTextTrack(m,!1)),this.titleBar&&this.titleBar.update({title:f,description:o||n||""}),this.ready(t)}getMedia(){if(!this.cache_.media){const e=this.poster(),t=this.currentSources(),i=Array.prototype.map.call(this.remoteTextTracks(),r=>({kind:r.kind,label:r.label,language:r.language,src:r.src})),n={src:t,textTracks:i};return e&&(n.poster=e,n.artwork=[{src:n.poster,type:Hp(n.poster)}]),n}return si(this.cache_.media)}static getTagSettings(e){const t={sources:[],tracks:[]},i=fo(e),n=i["data-setup"];if(Nd(e,"vjs-fill")&&(i.fill=!0),Nd(e,"vjs-fluid")&&(i.fluid=!0),n!==null)try{Object.assign(i,JSON.parse(n||"{}"))}catch(r){Dt.error("data-setup",r)}if(Object.assign(t,i),e.hasChildNodes()){const r=e.childNodes;for(let o=0,u=r.length;o<u;o++){const c=r[o],d=c.nodeName.toLowerCase();d==="source"?t.sources.push(fo(c)):d==="track"&&t.tracks.push(fo(c))}}return t}debug(e){if(e===void 0)return this.debugEnabled_;e?(this.trigger("debugon"),this.previousLogLevel_=this.log.level,this.log.level("debug"),this.debugEnabled_=!0):(this.trigger("debugoff"),this.log.level(this.previousLogLevel_),this.previousLogLevel_=void 0,this.debugEnabled_=!1)}playbackRates(e){if(e===void 0)return this.cache_.playbackRates;Array.isArray(e)&&e.every(t=>typeof t=="number")&&(this.cache_.playbackRates=e,this.trigger("playbackrateschange"))}};_i.prototype.videoTracks=()=>{};_i.prototype.audioTracks=()=>{};_i.prototype.textTracks=()=>{};_i.prototype.remoteTextTracks=()=>{};_i.prototype.remoteTextTrackEls=()=>{};Ns.names.forEach(function(s){const e=Ns[s];_i.prototype[e.getterName]=function(){return this.tech_?this.tech_[e.getterName]():(this[e.privateName]=this[e.privateName]||new e.ListClass,this[e.privateName])}});_i.prototype.crossorigin=_i.prototype.crossOrigin;_i.players={};const _d=ne.navigator;_i.prototype.options_={techOrder:bt.defaultTechOrder_,html5:{},enableSourceset:!0,inactivityTimeout:2e3,playbackRates:[],liveui:!1,children:["mediaLoader","posterImage","titleBar","textTrackDisplay","loadingSpinner","bigPlayButton","liveTracker","controlBar","errorDisplay","textTrackSettings","resizeManager"],language:_d&&(_d.languages&&_d.languages[0]||_d.userLanguage||_d.language)||"en",languages:{},notSupportedMessage:"No compatible source was found for this media.",normalizeAutoplay:!1,fullscreen:{options:{navigationUI:"hide"}},breakpoints:{},responsive:!1,audioOnlyMode:!1,audioPosterMode:!1,spatialNavigation:{enabled:!1,horizontalSeek:!1},enableSmoothSeeking:!1,disableSeekWhileScrubbingOnMobile:!1,disableSeekWhileScrubbingOnSTV:!1};aD.forEach(function(s){_i.prototype[`handleTech${ki(s)}_`]=function(){return this.trigger(s)}});ke.registerComponent("Player",_i);const Gp="plugin",Uu="activePlugins_",ku={},Vp=s=>ku.hasOwnProperty(s),vp=s=>Vp(s)?ku[s]:void 0,oD=(s,e)=>{s[Uu]=s[Uu]||{},s[Uu][e]=!0},qp=(s,e,t)=>{const i=(t?"before":"")+"pluginsetup";s.trigger(i,e),s.trigger(i+":"+e.name,e)},M3=function(s,e){const t=function(){qp(this,{name:s,plugin:e,instance:null},!0);const i=e.apply(this,arguments);return oD(this,s),qp(this,{name:s,plugin:e,instance:i}),i};return Object.keys(e).forEach(function(i){t[i]=e[i]}),t},ZE=(s,e)=>(e.prototype.name=s,function(...t){qp(this,{name:s,plugin:e,instance:null},!0);const i=new e(this,...t);return this[s]=()=>i,qp(this,i.getEventHash()),i});class nn{constructor(e){if(this.constructor===nn)throw new Error("Plugin must be sub-classed; not directly instantiated.");this.player=e,this.log||(this.log=this.player.log.createLogger(this.name)),AT(this),delete this.trigger,TC(this,this.constructor.defaultState),oD(e,this.name),this.dispose=this.dispose.bind(this),e.on("dispose",this.dispose)}version(){return this.constructor.VERSION}getEventHash(e={}){return e.name=this.name,e.plugin=this.constructor,e.instance=this,e}trigger(e,t={}){return uc(this.eventBusEl_,e,this.getEventHash(t))}handleStateChanged(e){}dispose(){const{name:e,player:t}=this;this.trigger("dispose"),this.off(),t.off("dispose",this.dispose),t[Uu][e]=!1,this.player=this.state=null,t[e]=ZE(e,ku[e])}static isBasic(e){const t=typeof e=="string"?vp(e):e;return typeof t=="function"&&!nn.prototype.isPrototypeOf(t.prototype)}static registerPlugin(e,t){if(typeof e!="string")throw new Error(`Illegal plugin name, "${e}", must be a string, was ${typeof e}.`);if(Vp(e))Dt.warn(`A plugin named "${e}" already exists. You may want to avoid re-registering plugins!`);else if(_i.prototype.hasOwnProperty(e))throw new Error(`Illegal plugin name, "${e}", cannot share a name with an existing player method!`);if(typeof t!="function")throw new Error(`Illegal plugin for "${e}", must be a function, was ${typeof t}.`);return ku[e]=t,e!==Gp&&(nn.isBasic(t)?_i.prototype[e]=M3(e,t):_i.prototype[e]=ZE(e,t)),t}static deregisterPlugin(e){if(e===Gp)throw new Error("Cannot de-register base plugin.");Vp(e)&&(delete ku[e],delete _i.prototype[e])}static getPlugins(e=Object.keys(ku)){let t;return e.forEach(i=>{const n=vp(i);n&&(t=t||{},t[i]=n)}),t}static getPluginVersion(e){const t=vp(e);return t&&t.VERSION||""}}nn.getPlugin=vp;nn.BASE_PLUGIN_NAME=Gp;nn.registerPlugin(Gp,nn);_i.prototype.usingPlugin=function(s){return!!this[Uu]&&this[Uu][s]===!0};_i.prototype.hasPlugin=function(s){return!!Vp(s)};function N3(s,e){let t=!1;return function(...i){return t||Dt.warn(s),t=!0,e.apply(this,i)}}function sr(s,e,t,i){return N3(`${e} is deprecated and will be removed in ${s}.0; please use ${t} instead.`,i)}var B3={NetworkBadStatus:"networkbadstatus",NetworkRequestFailed:"networkrequestfailed",NetworkRequestAborted:"networkrequestaborted",NetworkRequestTimeout:"networkrequesttimeout",NetworkBodyParserFailed:"networkbodyparserfailed",StreamingHlsPlaylistParserError:"streaminghlsplaylistparsererror",StreamingDashManifestParserError:"streamingdashmanifestparsererror",StreamingContentSteeringParserError:"streamingcontentsteeringparsererror",StreamingVttParserError:"streamingvttparsererror",StreamingFailedToSelectNextSegment:"streamingfailedtoselectnextsegment",StreamingFailedToDecryptSegment:"streamingfailedtodecryptsegment",StreamingFailedToTransmuxSegment:"streamingfailedtotransmuxsegment",StreamingFailedToAppendSegment:"streamingfailedtoappendsegment",StreamingCodecsChangeError:"streamingcodecschangeerror"};const lD=s=>s.indexOf("#")===0?s.slice(1):s;function Te(s,e,t){let i=Te.getPlayer(s);if(i)return e&&Dt.warn(`Player "${s}" is already initialised. Options will not be applied.`),t&&i.ready(t),i;const n=typeof s=="string"?So("#"+lD(s)):s;if(!lc(n))throw new TypeError("The element or ID supplied is not valid. (videojs)");const o=("getRootNode"in n?n.getRootNode()instanceof ne.ShadowRoot:!1)?n.getRootNode():n.ownerDocument.body;(!n.ownerDocument.defaultView||!o.contains(n))&&Dt.warn("The element supplied is not included in the DOM"),e=e||{},e.restoreEl===!0&&(e.restoreEl=(n.parentNode&&n.parentNode.hasAttribute&&n.parentNode.hasAttribute("data-vjs-player")?n.parentNode:n).cloneNode(!0)),xo("beforesetup").forEach(c=>{const d=c(n,si(e));if(!Mr(d)||Array.isArray(d)){Dt.error("please return an object in beforesetup hooks");return}e=si(e,d)});const u=ke.getComponent("Player");return i=new u(n,e,t),xo("setup").forEach(c=>c(i)),i}Te.hooks_=ma;Te.hooks=xo;Te.hook=yN;Te.hookOnce=vN;Te.removeHook=VA;if(ne.VIDEOJS_NO_DYNAMIC_STYLE!==!0&&oc()){let s=So(".vjs-styles-defaults");if(!s){s=pC("vjs-styles-defaults");const e=So("head");e&&e.insertBefore(s,e.firstChild),mC(s,`
.video-js {
width: 300px;
height: 150px;
}
.vjs-fluid:not(.vjs-audio-only-mode) {
padding-top: 56.25%
}
`)}}xv(1,Te);Te.VERSION=vv;Te.options=_i.prototype.options_;Te.getPlayers=()=>_i.players;Te.getPlayer=s=>{const e=_i.players;let t;if(typeof s=="string"){const i=lD(s),n=e[i];if(n)return n;t=So("#"+i)}else t=s;if(lc(t)){const{player:i,playerId:n}=t;if(i||e[n])return i||e[n]}};Te.getAllPlayers=()=>Object.keys(_i.players).map(s=>_i.players[s]).filter(Boolean);Te.players=_i.players;Te.getComponent=ke.getComponent;Te.registerComponent=(s,e)=>(bt.isTech(e)&&Dt.warn(`The ${s} tech was registered as a component. It should instead be registered using videojs.registerTech(name, tech)`),ke.registerComponent.call(ke,s,e));Te.getTech=bt.getTech;Te.registerTech=bt.registerTech;Te.use=qN;Object.defineProperty(Te,"middleware",{value:{},writeable:!1,enumerable:!0});Object.defineProperty(Te.middleware,"TERMINATOR",{value:jp,writeable:!1,enumerable:!0});Te.browser=JA;Te.obj=_N;Te.mergeOptions=sr(9,"videojs.mergeOptions","videojs.obj.merge",si);Te.defineLazyProperty=sr(9,"videojs.defineLazyProperty","videojs.obj.defineLazyProperty",Em);Te.bind=sr(9,"videojs.bind","native Function.prototype.bind",hi);Te.registerPlugin=nn.registerPlugin;Te.deregisterPlugin=nn.deregisterPlugin;Te.plugin=(s,e)=>(Dt.warn("videojs.plugin() is deprecated; use videojs.registerPlugin() instead"),nn.registerPlugin(s,e));Te.getPlugins=nn.getPlugins;Te.getPlugin=nn.getPlugin;Te.getPluginVersion=nn.getPluginVersion;Te.addLanguage=function(s,e){return s=(""+s).toLowerCase(),Te.options.languages=si(Te.options.languages,{[s]:e}),Te.options.languages[s]};Te.log=Dt;Te.createLogger=qA;Te.time=NN;Te.createTimeRange=sr(9,"videojs.createTimeRange","videojs.time.createTimeRanges",tr);Te.createTimeRanges=sr(9,"videojs.createTimeRanges","videojs.time.createTimeRanges",tr);Te.formatTime=sr(9,"videojs.formatTime","videojs.time.formatTime",El);Te.setFormatTime=sr(9,"videojs.setFormatTime","videojs.time.setFormatTime",xC);Te.resetFormatTime=sr(9,"videojs.resetFormatTime","videojs.time.resetFormatTime",SC);Te.parseUrl=sr(9,"videojs.parseUrl","videojs.url.parseUrl",LT);Te.isCrossOrigin=sr(9,"videojs.isCrossOrigin","videojs.url.isCrossOrigin",Nm);Te.EventTarget=En;Te.any=ET;Te.on=Sn;Te.one=Pm;Te.off=Cs;Te.trigger=uc;Te.xhr=LA;Te.TrackList=Al;Te.TextTrack=oh;Te.TextTrackList=DT;Te.AudioTrack=wC;Te.AudioTrackList=AC;Te.VideoTrack=LC;Te.VideoTrackList=CC;["isEl","isTextNode","createEl","hasClass","addClass","removeClass","toggleClass","setAttributes","getAttributes","emptyEl","appendContent","insertContent"].forEach(s=>{Te[s]=function(){return Dt.warn(`videojs.${s}() is deprecated; use videojs.dom.${s}() instead`),hC[s].apply(null,arguments)}});Te.computedStyle=sr(9,"videojs.computedStyle","videojs.dom.computedStyle",ic);Te.dom=hC;Te.fn=IN;Te.num=h3;Te.str=PN;Te.url=GN;Te.Error=B3;class F3{constructor(e){let t=this;return t.id=e.id,t.label=t.id,t.width=e.width,t.height=e.height,t.bitrate=e.bandwidth,t.frameRate=e.frameRate,t.enabled_=e.enabled,Object.defineProperty(t,"enabled",{get(){return t.enabled_()},set(i){t.enabled_(i)}}),t}}class zp extends Te.EventTarget{constructor(){super();let e=this;return e.levels_=[],e.selectedIndex_=-1,Object.defineProperty(e,"selectedIndex",{get(){return e.selectedIndex_}}),Object.defineProperty(e,"length",{get(){return e.levels_.length}}),e[Symbol.iterator]=()=>e.levels_.values(),e}addQualityLevel(e){let t=this.getQualityLevelById(e.id);if(t)return t;const i=this.levels_.length;return t=new F3(e),""+i in this||Object.defineProperty(this,i,{get(){return this.levels_[i]}}),this.levels_.push(t),this.trigger({qualityLevel:t,type:"addqualitylevel"}),t}removeQualityLevel(e){let t=null;for(let i=0,n=this.length;i<n;i++)if(this[i]===e){t=this.levels_.splice(i,1)[0],this.selectedIndex_===i?this.selectedIndex_=-1:this.selectedIndex_>i&&this.selectedIndex_--;break}return t&&this.trigger({qualityLevel:e,type:"removequalitylevel"}),t}getQualityLevelById(e){for(let t=0,i=this.length;t<i;t++){const n=this[t];if(n.id===e)return n}return null}dispose(){this.selectedIndex_=-1,this.levels_.length=0}}zp.prototype.allowedEvents_={change:"change",addqualitylevel:"addqualitylevel",removequalitylevel:"removequalitylevel"};for(const s in zp.prototype.allowedEvents_)zp.prototype["on"+s]=null;var uD="4.1.0";const U3=function(s,e){const t=s.qualityLevels,i=new zp,n=function(){i.dispose(),s.qualityLevels=t,s.off("dispose",n)};return s.on("dispose",n),s.qualityLevels=()=>i,s.qualityLevels.VERSION=uD,i},cD=function(s){return U3(this,Te.obj.merge({},s))};Te.registerPlugin("qualityLevels",cD);cD.VERSION=uD;const Js=bm,Kp=(s,e)=>e&&e.responseURL&&s!==e.responseURL?e.responseURL:s,$n=s=>Te.log.debug?Te.log.debug.bind(Te,"VHS:",`${s} >`):function(){};function Kt(...s){const e=Te.obj||Te;return(e.merge||e.mergeOptions).apply(e,s)}function us(...s){const e=Te.time||Te;return(e.createTimeRanges||e.createTimeRanges).apply(e,s)}function $3(s){if(s.length===0)return"Buffered Ranges are empty";let e=`Buffered Ranges:
`;for(let t=0;t<s.length;t++){const i=s.start(t),n=s.end(t);e+=`${i} --> ${n}. Duration (${n-i})
`}return e}const Lr=1/30,Ir=Lr*3,dD=function(s,e){const t=[];let i;if(s&&s.length)for(i=0;i<s.length;i++)e(s.start(i),s.end(i))&&t.push([s.start(i),s.end(i)]);return us(t)},Ru=function(s,e){return dD(s,function(t,i){return t-Ir<=e&&i+Ir>=e})},Kf=function(s,e){return dD(s,function(t){return t-Lr>=e})},j3=function(s){if(s.length<2)return us();const e=[];for(let t=1;t<s.length;t++){const i=s.end(t-1),n=s.start(t);e.push([i,n])}return us(e)},H3=function(s,e){let t=null,i=null,n=0;const r=[],o=[];if(!s||!s.length||!e||!e.length)return us();let u=s.length;for(;u--;)r.push({time:s.start(u),type:"start"}),r.push({time:s.end(u),type:"end"});for(u=e.length;u--;)r.push({time:e.start(u),type:"start"}),r.push({time:e.end(u),type:"end"});for(r.sort(function(c,d){return c.time-d.time}),u=0;u<r.length;u++)r[u].type==="start"?(n++,n===2&&(t=r[u].time)):r[u].type==="end"&&(n--,n===1&&(i=r[u].time)),t!==null&&i!==null&&(o.push([t,i]),t=null,i=null);return us(o)},hD=s=>{const e=[];if(!s||!s.length)return"";for(let t=0;t<s.length;t++)e.push(s.start(t)+" => "+s.end(t));return e.join(", ")},G3=function(s,e,t=1){return((s.length?s.end(s.length-1):0)-e)/t},gl=s=>{const e=[];for(let t=0;t<s.length;t++)e.push({start:s.start(t),end:s.end(t)});return e},V3=function(s,e){if(s===e)return!1;if(!s&&e||!e&&s||s.length!==e.length)return!0;for(let t=0;t<s.length;t++)if(s.start(t)!==e.start(t)||s.end(t)!==e.end(t))return!0;return!1},Iy=function(s){if(!(!s||!s.length||!s.end))return s.end(s.length-1)},zT=function(s,e){let t=0;if(!s||!s.length)return t;for(let i=0;i<s.length;i++){const n=s.start(i),r=s.end(i);if(!(e>r)){if(e>n&&e<=r){t+=r-e;continue}t+=r-n}}return t},KT=(s,e)=>{if(!e.preload)return e.duration;let t=0;return(e.parts||[]).forEach(function(i){t+=i.duration}),(e.preloadHints||[]).forEach(function(i){i.type==="PART"&&(t+=s.partTargetDuration)}),t},Iv=s=>(s.segments||[]).reduce((e,t,i)=>(t.parts?t.parts.forEach(function(n,r){e.push({duration:n.duration,segmentIndex:i,partIndex:r,part:n,segment:t})}):e.push({duration:t.duration,segmentIndex:i,partIndex:null,segment:t,part:null}),e),[]),fD=s=>{const e=s.segments&&s.segments.length&&s.segments[s.segments.length-1];return e&&e.parts||[]},pD=({preloadSegment:s})=>{if(!s)return;const{parts:e,preloadHints:t}=s;let i=(t||[]).reduce((n,r)=>n+(r.type==="PART"?1:0),0);return i+=e&&e.length?e.length:0,i},mD=(s,e)=>{if(e.endList)return 0;if(s&&s.suggestedPresentationDelay)return s.suggestedPresentationDelay;const t=fD(e).length>0;return t&&e.serverControl&&e.serverControl.partHoldBack?e.serverControl.partHoldBack:t&&e.partTargetDuration?e.partTargetDuration*3:e.serverControl&&e.serverControl.holdBack?e.serverControl.holdBack:e.targetDuration?e.targetDuration*3:0},q3=function(s,e){let t=0,i=e-s.mediaSequence,n=s.segments[i];if(n){if(typeof n.start<"u")return{result:n.start,precise:!0};if(typeof n.end<"u")return{result:n.end-n.duration,precise:!0}}for(;i--;){if(n=s.segments[i],typeof n.end<"u")return{result:t+n.end,precise:!0};if(t+=KT(s,n),typeof n.start<"u")return{result:t+n.start,precise:!0}}return{result:t,precise:!1}},z3=function(s,e){let t=0,i,n=e-s.mediaSequence;for(;n<s.segments.length;n++){if(i=s.segments[n],typeof i.start<"u")return{result:i.start-t,precise:!0};if(t+=KT(s,i),typeof i.end<"u")return{result:i.end-t,precise:!0}}return{result:-1,precise:!1}},gD=function(s,e,t){if(typeof e>"u"&&(e=s.mediaSequence+s.segments.length),e<s.mediaSequence)return 0;const i=q3(s,e);if(i.precise)return i.result;const n=z3(s,e);return n.precise?n.result:i.result+t},yD=function(s,e,t){if(!s)return 0;if(typeof t!="number"&&(t=0),typeof e>"u"){if(s.totalDuration)return s.totalDuration;if(!s.endList)return ne.Infinity}return gD(s,e,t)},Ud=function({defaultDuration:s,durationList:e,startIndex:t,endIndex:i}){let n=0;if(t>i&&([t,i]=[i,t]),t<0){for(let r=t;r<Math.min(0,i);r++)n+=s;t=0}for(let r=t;r<i;r++)n+=e[r].duration;return n},vD=function(s,e,t,i){if(!s||!s.segments)return null;if(s.endList)return yD(s);if(e===null)return null;e=e||0;let n=gD(s,s.mediaSequence+s.segments.length,e);return t&&(i=typeof i=="number"?i:mD(null,s),n-=i),Math.max(0,n)},K3=function(s,e,t){const n=e||0;let r=vD(s,e,!0,t);return r===null?us():(r<n&&(r=n),us(n,r))},Y3=function({playlist:s,currentTime:e,startingSegmentIndex:t,startingPartIndex:i,startTime:n,exactManifestTimings:r}){let o=e-n;const u=Iv(s);let c=0;for(let d=0;d<u.length;d++){const f=u[d];if(t===f.segmentIndex&&!(typeof i=="number"&&typeof f.partIndex=="number"&&i!==f.partIndex)){c=d;break}}if(o<0){if(c>0)for(let d=c-1;d>=0;d--){const f=u[d];if(o+=f.duration,r){if(o<0)continue}else if(o+Lr<=0)continue;return{partIndex:f.partIndex,segmentIndex:f.segmentIndex,startTime:n-Ud({defaultDuration:s.targetDuration,durationList:u,startIndex:c,endIndex:d})}}return{partIndex:u[0]&&u[0].partIndex||null,segmentIndex:u[0]&&u[0].segmentIndex||0,startTime:e}}if(c<0){for(let d=c;d<0;d++)if(o-=s.targetDuration,o<0)return{partIndex:u[0]&&u[0].partIndex||null,segmentIndex:u[0]&&u[0].segmentIndex||0,startTime:e};c=0}for(let d=c;d<u.length;d++){const f=u[d];o-=f.duration;const m=f.duration>Lr,g=o===0,v=m&&o+Lr>=0;if(!((g||v)&&d!==u.length-1)){if(r){if(o>0)continue}else if(o-Lr>=0)continue;return{partIndex:f.partIndex,segmentIndex:f.segmentIndex,startTime:n+Ud({defaultDuration:s.targetDuration,durationList:u,startIndex:c,endIndex:d})}}}return{segmentIndex:u[u.length-1].segmentIndex,partIndex:u[u.length-1].partIndex,startTime:e}},TD=function(s){return s.excludeUntil&&s.excludeUntil>Date.now()},YT=function(s){return s.excludeUntil&&s.excludeUntil===1/0},$m=function(s){const e=TD(s);return!s.disabled&&!e},W3=function(s){return s.disabled},X3=function(s){for(let e=0;e<s.segments.length;e++)if(s.segments[e].key)return!0;return!1},bD=function(s,e){return e.attributes&&e.attributes[s]},Q3=function(s,e,t,i=0){return bD("BANDWIDTH",t)?(s*t.attributes.BANDWIDTH-i*8)/e:NaN},kv=(s,e)=>{if(s.playlists.length===1)return!0;const t=e.attributes.BANDWIDTH||Number.MAX_VALUE;return s.playlists.filter(i=>$m(i)?(i.attributes.BANDWIDTH||0)<t:!1).length===0},WT=(s,e)=>!s&&!e||!s&&e||s&&!e?!1:!!(s===e||s.id&&e.id&&s.id===e.id||s.resolvedUri&&e.resolvedUri&&s.resolvedUri===e.resolvedUri||s.uri&&e.uri&&s.uri===e.uri),JE=function(s,e){const t=s&&s.mediaGroups&&s.mediaGroups.AUDIO||{};let i=!1;for(const n in t){for(const r in t[n])if(i=e(t[n][r]),i)break;if(i)break}return!!i},dh=s=>{if(!s||!s.playlists||!s.playlists.length)return JE(s,t=>t.playlists&&t.playlists.length||t.uri);for(let e=0;e<s.playlists.length;e++){const t=s.playlists[e],i=t.attributes&&t.attributes.CODECS;if(!(i&&i.split(",").every(r=>RA(r))||JE(s,r=>WT(t,r))))return!1}return!0};var en={liveEdgeDelay:mD,duration:yD,seekable:K3,getMediaInfoForTime:Y3,isEnabled:$m,isDisabled:W3,isExcluded:TD,isIncompatible:YT,playlistEnd:vD,isAes:X3,hasAttribute:bD,estimateSegmentRequestTime:Q3,isLowestEnabledRendition:kv,isAudioOnly:dh,playlistMatch:WT,segmentDurationWithParts:KT};const{log:_D}=Te,$u=(s,e)=>`${s}-${e}`,xD=(s,e,t)=>`placeholder-uri-${s}-${e}-${t}`,Z3=({onwarn:s,oninfo:e,manifestString:t,customTagParsers:i=[],customTagMappers:n=[],llhls:r})=>{const o=new UP;s&&o.on("warn",s),e&&o.on("info",e),i.forEach(d=>o.addParser(d)),n.forEach(d=>o.addTagMapper(d)),o.push(t),o.end();const u=o.manifest;if(r||(["preloadSegment","skip","serverControl","renditionReports","partInf","partTargetDuration"].forEach(function(d){u.hasOwnProperty(d)&&delete u[d]}),u.segments&&u.segments.forEach(function(d){["parts","preloadHints"].forEach(function(f){d.hasOwnProperty(f)&&delete d[f]})})),!u.targetDuration){let d=10;u.segments&&u.segments.length&&(d=u.segments.reduce((f,m)=>Math.max(f,m.duration),0)),s&&s({message:`manifest has no targetDuration defaulting to ${d}`}),u.targetDuration=d}const c=fD(u);if(c.length&&!u.partTargetDuration){const d=c.reduce((f,m)=>Math.max(f,m.duration),0);s&&(s({message:`manifest has no partTargetDuration defaulting to ${d}`}),_D.error("LL-HLS manifest has parts but lacks required #EXT-X-PART-INF:PART-TARGET value. See https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis-09#section-4.4.3.7. Playback is not guaranteed.")),u.partTargetDuration=d}return u},fc=(s,e)=>{s.mediaGroups&&["AUDIO","SUBTITLES"].forEach(t=>{if(s.mediaGroups[t])for(const i in s.mediaGroups[t])for(const n in s.mediaGroups[t][i]){const r=s.mediaGroups[t][i][n];e(r,t,i,n)}})},SD=({playlist:s,uri:e,id:t})=>{s.id=t,s.playlistErrors_=0,e&&(s.uri=e),s.attributes=s.attributes||{}},J3=s=>{let e=s.playlists.length;for(;e--;){const t=s.playlists[e];SD({playlist:t,id:$u(e,t.uri)}),t.resolvedUri=Js(s.uri,t.uri),s.playlists[t.id]=t,s.playlists[t.uri]=t,t.attributes.BANDWIDTH||_D.warn("Invalid playlist STREAM-INF detected. Missing BANDWIDTH attribute.")}},e5=s=>{fc(s,e=>{e.uri&&(e.resolvedUri=Js(s.uri,e.uri))})},t5=(s,e)=>{const t=$u(0,e),i={mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:ne.location.href,resolvedUri:ne.location.href,playlists:[{uri:e,id:t,resolvedUri:e,attributes:{}}]};return i.playlists[t]=i.playlists[0],i.playlists[e]=i.playlists[0],i},ED=(s,e,t=xD)=>{s.uri=e;for(let n=0;n<s.playlists.length;n++)if(!s.playlists[n].uri){const r=`placeholder-uri-${n}`;s.playlists[n].uri=r}const i=dh(s);fc(s,(n,r,o,u)=>{if(!n.playlists||!n.playlists.length){if(i&&r==="AUDIO"&&!n.uri)for(let c=0;c<s.playlists.length;c++){const d=s.playlists[c];if(d.attributes&&d.attributes.AUDIO&&d.attributes.AUDIO===o)return}n.playlists=[Hi({},n)]}n.playlists.forEach(function(c,d){const f=t(r,o,u,c),m=$u(d,f);c.uri?c.resolvedUri=c.resolvedUri||Js(s.uri,c.uri):(c.uri=d===0?f:m,c.resolvedUri=c.uri),c.id=c.id||m,c.attributes=c.attributes||{},s.playlists[c.id]=c,s.playlists[c.uri]=c})}),J3(s),e5(s)};class e1{constructor(){this.offset_=null,this.pendingDateRanges_=new Map,this.processedDateRanges_=new Map}setOffset(e=[]){if(this.offset_!==null||!e.length)return;const[t]=e;t.programDateTime!==void 0&&(this.offset_=t.programDateTime/1e3)}setPendingDateRanges(e=[]){if(!e.length)return;const[t]=e,i=t.startDate.getTime();this.trimProcessedDateRanges_(i),this.pendingDateRanges_=e.reduce((n,r)=>(n.set(r.id,r),n),new Map)}processDateRange(e){this.pendingDateRanges_.delete(e.id),this.processedDateRanges_.set(e.id,e)}getDateRangesToProcess(){if(this.offset_===null)return[];const e={},t=[];this.pendingDateRanges_.forEach((i,n)=>{if(!this.processedDateRanges_.has(n)&&(i.startTime=i.startDate.getTime()/1e3-this.offset_,i.processDateRange=()=>this.processDateRange(i),t.push(i),!!i.class))if(e[i.class]){const r=e[i.class].push(i);i.classListIndex=r-1}else e[i.class]=[i],i.classListIndex=0});for(const i of t){const n=e[i.class]||[];i.endDate?i.endTime=i.endDate.getTime()/1e3-this.offset_:i.endOnNext&&n[i.classListIndex+1]?i.endTime=n[i.classListIndex+1].startTime:i.duration?i.endTime=i.startTime+i.duration:i.plannedDuration?i.endTime=i.startTime+i.plannedDuration:i.endTime=i.startTime}return t}trimProcessedDateRanges_(e){new Map(this.processedDateRanges_).forEach((i,n)=>{i.startDate.getTime()<e&&this.processedDateRanges_.delete(n)})}}const AD=22,_l=({requestType:s,request:e,error:t,parseFailure:i})=>{const n=e.status<200||e.status>299,r=e.status>=400&&e.status<=499,o={uri:e.uri,requestType:s},u=n&&!r||i;if(t&&r)o.error=Hi({},t),o.errorType=Te.Error.NetworkRequestFailed;else if(e.aborted)o.errorType=Te.Error.NetworkRequestAborted;else if(e.timedout)o.errorType=Te.Error.NetworkRequestTimeout;else if(u){const c=i?Te.Error.NetworkBodyParserFailed:Te.Error.NetworkBadStatus;o.errorType=c,o.status=e.status,o.headers=e.headers}return o},i5=$n("CodecUtils"),CD=function(s){const e=s.attributes||{};if(e.CODECS)return Ar(e.CODECS)},DD=(s,e)=>{const t=e.attributes||{};return s&&s.mediaGroups&&s.mediaGroups.AUDIO&&t.AUDIO&&s.mediaGroups.AUDIO[t.AUDIO]},s5=(s,e)=>{if(!DD(s,e))return!0;const t=e.attributes||{},i=s.mediaGroups.AUDIO[t.AUDIO];for(const n in i)if(!i[n].uri&&!i[n].playlists)return!0;return!1},Yd=function(s){const e={};return s.forEach(({mediaType:t,type:i,details:n})=>{e[t]=e[t]||[],e[t].push(kA(`${i}${n}`))}),Object.keys(e).forEach(function(t){if(e[t].length>1){i5(`multiple ${t} codecs found as attributes: ${e[t].join(", ")}. Setting playlist codecs to null so that we wait for mux.js to probe segments for real codecs.`),e[t]=null;return}e[t]=e[t][0]}),e},t1=function(s){let e=0;return s.audio&&e++,s.video&&e++,e},$d=function(s,e){const t=e.attributes||{},i=Yd(CD(e)||[]);if(DD(s,e)&&!i.audio&&!s5(s,e)){const n=Yd(jP(s,t.AUDIO)||[]);n.audio&&(i.audio=n.audio)}return i},{EventTarget:n5}=Te,r5=(s,e)=>{if(e.endList||!e.serverControl)return s;const t={};if(e.serverControl.canBlockReload){const{preloadSegment:i}=e;let n=e.mediaSequence+e.segments.length;if(i){const r=i.parts||[],o=pD(e)-1;o>-1&&o!==r.length-1&&(t._HLS_part=o),(o>-1||r.length)&&n--}t._HLS_msn=n}if(e.serverControl&&e.serverControl.canSkipUntil&&(t._HLS_skip=e.serverControl.canSkipDateranges?"v2":"YES"),Object.keys(t).length){const i=new ne.URL(s);["_HLS_skip","_HLS_msn","_HLS_part"].forEach(function(n){t.hasOwnProperty(n)&&i.searchParams.set(n,t[n])}),s=i.toString()}return s},a5=(s,e)=>{if(!s)return e;const t=Kt(s,e);if(s.preloadHints&&!e.preloadHints&&delete t.preloadHints,s.parts&&!e.parts)delete t.parts;else if(s.parts&&e.parts)for(let i=0;i<e.parts.length;i++)s.parts&&s.parts[i]&&(t.parts[i]=Kt(s.parts[i],e.parts[i]));return!s.skipped&&e.skipped&&(t.skipped=!1),s.preload&&!e.preload&&(t.preload=!1),t},o5=(s,e,t)=>{const i=s.slice(),n=e.slice();t=t||0;const r=[];let o;for(let u=0;u<n.length;u++){const c=i[u+t],d=n[u];c?(o=c.map||o,r.push(a5(c,d))):(o&&!d.map&&(d.map=o),r.push(d))}return r},wD=(s,e)=>{!s.resolvedUri&&s.uri&&(s.resolvedUri=Js(e,s.uri)),s.key&&!s.key.resolvedUri&&(s.key.resolvedUri=Js(e,s.key.uri)),s.map&&!s.map.resolvedUri&&(s.map.resolvedUri=Js(e,s.map.uri)),s.map&&s.map.key&&!s.map.key.resolvedUri&&(s.map.key.resolvedUri=Js(e,s.map.key.uri)),s.parts&&s.parts.length&&s.parts.forEach(t=>{t.resolvedUri||(t.resolvedUri=Js(e,t.uri))}),s.preloadHints&&s.preloadHints.length&&s.preloadHints.forEach(t=>{t.resolvedUri||(t.resolvedUri=Js(e,t.uri))})},LD=function(s){const e=s.segments||[],t=s.preloadSegment;if(t&&t.parts&&t.parts.length){if(t.preloadHints){for(let i=0;i<t.preloadHints.length;i++)if(t.preloadHints[i].type==="MAP")return e}t.duration=s.targetDuration,t.preload=!0,e.push(t)}return e},ID=(s,e)=>s===e||s.segments&&e.segments&&s.segments.length===e.segments.length&&s.endList===e.endList&&s.mediaSequence===e.mediaSequence&&s.preloadSegment===e.preloadSegment,Rv=(s,e,t=ID)=>{const i=Kt(s,{}),n=i.playlists[e.id];if(!n||t(n,e))return null;e.segments=LD(e);const r=Kt(n,e);if(r.preloadSegment&&!e.preloadSegment&&delete r.preloadSegment,n.segments){if(e.skip){e.segments=e.segments||[];for(let o=0;o<e.skip.skippedSegments;o++)e.segments.unshift({skipped:!0})}r.segments=o5(n.segments,e.segments,e.mediaSequence-n.mediaSequence)}r.segments.forEach(o=>{wD(o,r.resolvedUri)});for(let o=0;o<i.playlists.length;o++)i.playlists[o].id===e.id&&(i.playlists[o]=r);return i.playlists[e.id]=r,i.playlists[e.uri]=r,fc(s,(o,u,c,d)=>{if(o.playlists)for(let f=0;f<o.playlists.length;f++)e.id===o.playlists[f].id&&(o.playlists[f]=r)}),i},Ov=(s,e)=>{const t=s.segments||[],i=t[t.length-1],n=i&&i.parts&&i.parts[i.parts.length-1],r=n&&n.duration||i&&i.duration;return e&&r?r*1e3:(s.partTargetDuration||s.targetDuration||10)*500},i1=(s,e,t)=>{if(!s)return;const i=[];return s.forEach(n=>{if(!n.attributes)return;const{BANDWIDTH:r,RESOLUTION:o,CODECS:u}=n.attributes;i.push({id:n.id,bandwidth:r,resolution:o,codecs:u})}),{type:e,isLive:t,renditions:i}};let Ou=class extends n5{constructor(e,t,i={}){if(super(),!e)throw new Error("A non-empty playlist URL or object is required");this.logger_=$n("PlaylistLoader");const{withCredentials:n=!1}=i;this.src=e,this.vhs_=t,this.withCredentials=n,this.addDateRangesToTextTrack_=i.addDateRangesToTextTrack;const r=t.options_;this.customTagParsers=r&&r.customTagParsers||[],this.customTagMappers=r&&r.customTagMappers||[],this.llhls=r&&r.llhls,this.dateRangesStorage_=new e1,this.state="HAVE_NOTHING",this.handleMediaupdatetimeout_=this.handleMediaupdatetimeout_.bind(this),this.on("mediaupdatetimeout",this.handleMediaupdatetimeout_),this.on("loadedplaylist",this.handleLoadedPlaylist_.bind(this))}handleLoadedPlaylist_(){const e=this.media();if(!e)return;this.dateRangesStorage_.setOffset(e.segments),this.dateRangesStorage_.setPendingDateRanges(e.dateRanges);const t=this.dateRangesStorage_.getDateRangesToProcess();!t.length||!this.addDateRangesToTextTrack_||this.addDateRangesToTextTrack_(t)}handleMediaupdatetimeout_(){if(this.state!=="HAVE_METADATA")return;const e=this.media();let t=Js(this.main.uri,e.uri);this.llhls&&(t=r5(t,e)),this.state="HAVE_CURRENT_METADATA",this.request=this.vhs_.xhr({uri:t,withCredentials:this.withCredentials,requestType:"hls-playlist"},(i,n)=>{if(this.request){if(i)return this.playlistRequestError(this.request,this.media(),"HAVE_METADATA");this.haveMetadata({playlistString:this.request.responseText,url:this.media().uri,id:this.media().id})}})}playlistRequestError(e,t,i){const{uri:n,id:r}=t;this.request=null,i&&(this.state=i),this.error={playlist:this.main.playlists[r],status:e.status,message:`HLS playlist request error at URL: ${n}.`,responseText:e.responseText,code:e.status>=500?4:2,metadata:_l({requestType:e.requestType,request:e,error:e.error})},this.trigger("error")}parseManifest_({url:e,manifestString:t}){try{const i=Z3({onwarn:({message:n})=>this.logger_(`m3u8-parser warn for ${e}: ${n}`),oninfo:({message:n})=>this.logger_(`m3u8-parser info for ${e}: ${n}`),manifestString:t,customTagParsers:this.customTagParsers,customTagMappers:this.customTagMappers,llhls:this.llhls});return!i.playlists||!i.playlists.length||this.excludeAudioOnlyVariants(i.playlists),i}catch(i){this.error=i,this.error.metadata={errorType:Te.Error.StreamingHlsPlaylistParserError,error:i}}}excludeAudioOnlyVariants(e){const t=i=>{const n=i.attributes||{},{width:r,height:o}=n.RESOLUTION||{};if(r&&o)return!0;const u=CD(i)||[];return!!Yd(u).video};e.some(t)&&e.forEach(i=>{t(i)||(i.excludeUntil=1/0)})}haveMetadata({playlistString:e,playlistObject:t,url:i,id:n}){this.request=null,this.state="HAVE_METADATA";const r={playlistInfo:{type:"media",uri:i}};this.trigger({type:"playlistparsestart",metadata:r});const o=t||this.parseManifest_({url:i,manifestString:e});o.lastRequest=Date.now(),SD({playlist:o,uri:i,id:n});const u=Rv(this.main,o);this.targetDuration=o.partTargetDuration||o.targetDuration,this.pendingMedia_=null,u?(this.main=u,this.media_=this.main.playlists[n]):this.trigger("playlistunchanged"),this.updateMediaUpdateTimeout_(Ov(this.media(),!!u)),r.parsedPlaylist=i1(this.main.playlists,r.playlistInfo.type,!this.media_.endList),this.trigger({type:"playlistparsecomplete",metadata:r}),this.trigger("loadedplaylist")}dispose(){this.trigger("dispose"),this.stopRequest(),ne.clearTimeout(this.mediaUpdateTimeout),ne.clearTimeout(this.finalRenditionTimeout),this.dateRangesStorage_=new e1,this.off()}stopRequest(){if(this.request){const e=this.request;this.request=null,e.onreadystatechange=null,e.abort()}}media(e,t){if(!e)return this.media_;if(this.state==="HAVE_NOTHING")throw new Error("Cannot switch media playlist from "+this.state);if(typeof e=="string"){if(!this.main.playlists[e])throw new Error("Unknown playlist URI: "+e);e=this.main.playlists[e]}if(ne.clearTimeout(this.finalRenditionTimeout),t){const u=(e.partTargetDuration||e.targetDuration)/2*1e3||5e3;this.finalRenditionTimeout=ne.setTimeout(this.media.bind(this,e,!1),u);return}const i=this.state,n=!this.media_||e.id!==this.media_.id,r=this.main.playlists[e.id];if(r&&r.endList||e.endList&&e.segments.length){this.request&&(this.request.onreadystatechange=null,this.request.abort(),this.request=null),this.state="HAVE_METADATA",this.media_=e,n&&(this.trigger("mediachanging"),i==="HAVE_MAIN_MANIFEST"?this.trigger("loadedmetadata"):this.trigger("mediachange"));return}if(this.updateMediaUpdateTimeout_(Ov(e,!0)),!n)return;if(this.state="SWITCHING_MEDIA",this.request){if(e.resolvedUri===this.request.url)return;this.request.onreadystatechange=null,this.request.abort(),this.request=null}this.media_&&this.trigger("mediachanging"),this.pendingMedia_=e;const o={playlistInfo:{type:"media",uri:e.uri}};this.trigger({type:"playlistrequeststart",metadata:o}),this.request=this.vhs_.xhr({uri:e.resolvedUri,withCredentials:this.withCredentials,requestType:"hls-playlist"},(u,c)=>{if(this.request){if(e.lastRequest=Date.now(),e.resolvedUri=Kp(e.resolvedUri,c),u)return this.playlistRequestError(this.request,e,i);this.trigger({type:"playlistrequestcomplete",metadata:o}),this.haveMetadata({playlistString:c.responseText,url:e.uri,id:e.id}),i==="HAVE_MAIN_MANIFEST"?this.trigger("loadedmetadata"):this.trigger("mediachange")}})}pause(){this.mediaUpdateTimeout&&(ne.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null),this.stopRequest(),this.state==="HAVE_NOTHING"&&(this.started=!1),this.state==="SWITCHING_MEDIA"?this.media_?this.state="HAVE_METADATA":this.state="HAVE_MAIN_MANIFEST":this.state==="HAVE_CURRENT_METADATA"&&(this.state="HAVE_METADATA")}load(e){this.mediaUpdateTimeout&&(ne.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null);const t=this.media();if(e){const i=t?(t.partTargetDuration||t.targetDuration)/2*1e3:5e3;this.mediaUpdateTimeout=ne.setTimeout(()=>{this.mediaUpdateTimeout=null,this.load()},i);return}if(!this.started){this.start();return}t&&!t.endList?this.trigger("mediaupdatetimeout"):this.trigger("loadedplaylist")}updateMediaUpdateTimeout_(e){this.mediaUpdateTimeout&&(ne.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null),!(!this.media()||this.media().endList)&&(this.mediaUpdateTimeout=ne.setTimeout(()=>{this.mediaUpdateTimeout=null,this.trigger("mediaupdatetimeout"),this.updateMediaUpdateTimeout_(e)},e))}start(){if(this.started=!0,typeof this.src=="object"){this.src.uri||(this.src.uri=ne.location.href),this.src.resolvedUri=this.src.uri,setTimeout(()=>{this.setupInitialPlaylist(this.src)},0);return}const e={playlistInfo:{type:"multivariant",uri:this.src}};this.trigger({type:"playlistrequeststart",metadata:e}),this.request=this.vhs_.xhr({uri:this.src,withCredentials:this.withCredentials,requestType:"hls-playlist"},(t,i)=>{if(!this.request)return;if(this.request=null,t)return this.error={status:i.status,message:`HLS playlist request error at URL: ${this.src}.`,responseText:i.responseText,code:2,metadata:_l({requestType:i.requestType,request:i,error:t})},this.state==="HAVE_NOTHING"&&(this.started=!1),this.trigger("error");this.trigger({type:"playlistrequestcomplete",metadata:e}),this.src=Kp(this.src,i),this.trigger({type:"playlistparsestart",metadata:e});const n=this.parseManifest_({manifestString:i.responseText,url:this.src});e.parsedPlaylist=i1(n.playlists,e.playlistInfo.type,!1),this.trigger({type:"playlistparsecomplete",metadata:e}),this.setupInitialPlaylist(n)})}srcUri(){return typeof this.src=="string"?this.src:this.src.uri}setupInitialPlaylist(e){if(this.state="HAVE_MAIN_MANIFEST",e.playlists){this.main=e,ED(this.main,this.srcUri()),e.playlists.forEach(i=>{i.segments=LD(i),i.segments.forEach(n=>{wD(n,i.resolvedUri)})}),this.trigger("loadedplaylist"),this.request||this.media(this.main.playlists[0]);return}const t=this.srcUri()||ne.location.href;this.main=t5(e,t),this.haveMetadata({playlistObject:e,url:t,id:this.main.playlists[0].id}),this.trigger("loadedmetadata")}updateOrDeleteClone(e,t){const i=this.main,n=e.ID;let r=i.playlists.length;for(;r--;){const o=i.playlists[r];if(o.attributes["PATHWAY-ID"]===n){const u=o.resolvedUri,c=o.id;if(t){const d=this.createCloneURI_(o.resolvedUri,e),f=$u(n,d),m=this.createCloneAttributes_(n,o.attributes),g=this.createClonePlaylist_(o,f,e,m);i.playlists[r]=g,i.playlists[f]=g,i.playlists[d]=g}else i.playlists.splice(r,1);delete i.playlists[c],delete i.playlists[u]}}this.updateOrDeleteCloneMedia(e,t)}updateOrDeleteCloneMedia(e,t){const i=this.main,n=e.ID;["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(r=>{if(!(!i.mediaGroups[r]||!i.mediaGroups[r][n])){for(const o in i.mediaGroups[r])if(o===n){for(const u in i.mediaGroups[r][o])i.mediaGroups[r][o][u].playlists.forEach((d,f)=>{const m=i.playlists[d.id],g=m.id,v=m.resolvedUri;delete i.playlists[g],delete i.playlists[v]});delete i.mediaGroups[r][o]}}}),t&&this.createClonedMediaGroups_(e)}addClonePathway(e,t={}){const i=this.main,n=i.playlists.length,r=this.createCloneURI_(t.resolvedUri,e),o=$u(e.ID,r),u=this.createCloneAttributes_(e.ID,t.attributes),c=this.createClonePlaylist_(t,o,e,u);i.playlists[n]=c,i.playlists[o]=c,i.playlists[r]=c,this.createClonedMediaGroups_(e)}createClonedMediaGroups_(e){const t=e.ID,i=e["BASE-ID"],n=this.main;["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(r=>{if(!(!n.mediaGroups[r]||n.mediaGroups[r][t]))for(const o in n.mediaGroups[r]){if(o===i)n.mediaGroups[r][t]={};else continue;for(const u in n.mediaGroups[r][o]){const c=n.mediaGroups[r][o][u];n.mediaGroups[r][t][u]=Hi({},c);const d=n.mediaGroups[r][t][u],f=this.createCloneURI_(c.resolvedUri,e);d.resolvedUri=f,d.uri=f,d.playlists=[],c.playlists.forEach((m,g)=>{const v=n.playlists[m.id],b=xD(r,t,u),_=$u(t,b);if(v&&!n.playlists[_]){const E=this.createClonePlaylist_(v,_,e),w=E.resolvedUri;n.playlists[_]=E,n.playlists[w]=E}d.playlists[g]=this.createClonePlaylist_(m,_,e)})}}})}createClonePlaylist_(e,t,i,n){const r=this.createCloneURI_(e.resolvedUri,i),o={resolvedUri:r,uri:r,id:t};return e.segments&&(o.segments=[]),n&&(o.attributes=n),Kt(e,o)}createCloneURI_(e,t){const i=new URL(e);i.hostname=t["URI-REPLACEMENT"].HOST;const n=t["URI-REPLACEMENT"].PARAMS;for(const r of Object.keys(n))i.searchParams.set(r,n[r]);return i.href}createCloneAttributes_(e,t){const i={"PATHWAY-ID":e};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(n=>{t[n]&&(i[n]=e)}),i}getKeyIdSet(e){const t=new Set;if(!e||!e.contentProtection)return t;for(const i in e.contentProtection)if(e.contentProtection[i]&&e.contentProtection[i].attributes&&e.contentProtection[i].attributes.keyId){const n=e.contentProtection[i].attributes.keyId;t.add(n.toLowerCase())}return t}};const Pv=function(s,e,t,i){const n=s.responseType==="arraybuffer"?s.response:s.responseText;!e&&n&&(s.responseTime=Date.now(),s.roundTripTime=s.responseTime-s.requestTime,s.bytesReceived=n.byteLength||n.length,s.bandwidth||(s.bandwidth=Math.floor(s.bytesReceived/s.roundTripTime*8*1e3))),t.headers&&(s.responseHeaders=t.headers),e&&e.code==="ETIMEDOUT"&&(s.timedout=!0),!e&&!s.aborted&&t.statusCode!==200&&t.statusCode!==206&&t.statusCode!==0&&(e=new Error("XHR Failed with a response of: "+(s&&(n||s.responseText)))),i(e,s)},l5=(s,e)=>{if(!s||!s.size)return;let t=e;return s.forEach(i=>{t=i(t)}),t},u5=(s,e,t,i)=>{!s||!s.size||s.forEach(n=>{n(e,t,i)})},kD=function(){const s=function e(t,i){t=Kt({timeout:45e3},t);const n=e.beforeRequest||Te.Vhs.xhr.beforeRequest,r=e._requestCallbackSet||Te.Vhs.xhr._requestCallbackSet||new Set,o=e._responseCallbackSet||Te.Vhs.xhr._responseCallbackSet;n&&typeof n=="function"&&(Te.log.warn("beforeRequest is deprecated, use onRequest instead."),r.add(n));const u=Te.Vhs.xhr.original===!0?Te.xhr:Te.Vhs.xhr,c=l5(r,t);r.delete(n);const d=u(c||t,function(m,g){return u5(o,d,m,g),Pv(d,m,g,i)}),f=d.abort;return d.abort=function(){return d.aborted=!0,f.apply(d,arguments)},d.uri=t.uri,d.requestType=t.requestType,d.requestTime=Date.now(),d};return s.original=!0,s},c5=function(s){let e;const t=s.offset;return typeof s.offset=="bigint"||typeof s.length=="bigint"?e=ne.BigInt(s.offset)+ne.BigInt(s.length)-ne.BigInt(1):e=s.offset+s.length-1,"bytes="+t+"-"+e},Mv=function(s){const e={};return s.byterange&&(e.Range=c5(s.byterange)),e},d5=function(s,e){return s.start(e)+"-"+s.end(e)},h5=function(s,e){const t=s.toString(16);return"00".substring(0,2-t.length)+t+(e%2?" ":"")},f5=function(s){return s>=32&&s<126?String.fromCharCode(s):"."},RD=function(s){const e={};return Object.keys(s).forEach(t=>{const i=s[t];PA(i)?e[t]={bytes:i.buffer,byteOffset:i.byteOffset,byteLength:i.byteLength}:e[t]=i}),e},Yp=function(s){const e=s.byterange||{length:1/0,offset:0};return[e.length,e.offset,s.resolvedUri].join(",")},OD=function(s){return s.resolvedUri},PD=s=>{const e=Array.prototype.slice.call(s),t=16;let i="",n,r;for(let o=0;o<e.length/t;o++)n=e.slice(o*t,o*t+t).map(h5).join(""),r=e.slice(o*t,o*t+t).map(f5).join(""),i+=n+" "+r+`
`;return i},p5=({bytes:s})=>PD(s),m5=s=>{let e="",t;for(t=0;t<s.length;t++)e+=d5(s,t)+" ";return e};var g5=Object.freeze({__proto__:null,createTransferableMessage:RD,initSegmentId:Yp,segmentKeyId:OD,hexDump:PD,tagDump:p5,textRanges:m5});const MD=.25,y5=(s,e)=>{if(!e.dateTimeObject)return null;const t=e.videoTimingInfo.transmuxerPrependedSeconds,n=e.videoTimingInfo.transmuxedPresentationStart+t,r=s-n;return new Date(e.dateTimeObject.getTime()+r*1e3)},v5=s=>s.transmuxedPresentationEnd-s.transmuxedPresentationStart-s.transmuxerPrependedSeconds,T5=(s,e)=>{let t;try{t=new Date(s)}catch{return null}if(!e||!e.segments||e.segments.length===0)return null;let i=e.segments[0];if(t<new Date(i.dateTimeObject))return null;for(let c=0;c<e.segments.length-1;c++){i=e.segments[c];const d=new Date(e.segments[c+1].dateTimeObject);if(t<d)break}const n=e.segments[e.segments.length-1],r=n.dateTimeObject,o=n.videoTimingInfo?v5(n.videoTimingInfo):n.duration+n.duration*MD,u=new Date(r.getTime()+o*1e3);return t>u?null:(t>new Date(r)&&(i=n),{segment:i,estimatedStart:i.videoTimingInfo?i.videoTimingInfo.transmuxedPresentationStart:en.duration(e,e.mediaSequence+e.segments.indexOf(i)),type:i.videoTimingInfo?"accurate":"estimate"})},b5=(s,e)=>{if(!e||!e.segments||e.segments.length===0)return null;let t=0,i;for(let r=0;r<e.segments.length&&(i=e.segments[r],t=i.videoTimingInfo?i.videoTimingInfo.transmuxedPresentationEnd:t+i.duration,!(s<=t));r++);const n=e.segments[e.segments.length-1];if(n.videoTimingInfo&&n.videoTimingInfo.transmuxedPresentationEnd<s)return null;if(s>t){if(s>t+n.duration*MD)return null;i=n}return{segment:i,estimatedStart:i.videoTimingInfo?i.videoTimingInfo.transmuxedPresentationStart:t-i.duration,type:i.videoTimingInfo?"accurate":"estimate"}},_5=(s,e)=>{let t,i;try{t=new Date(s),i=new Date(e)}catch{}const n=t.getTime();return(i.getTime()-n)/1e3},x5=s=>{if(!s.segments||s.segments.length===0)return!1;for(let e=0;e<s.segments.length;e++)if(!s.segments[e].dateTimeObject)return!1;return!0},S5=({playlist:s,time:e=void 0,callback:t})=>{if(!t)throw new Error("getProgramTime: callback must be provided");if(!s||e===void 0)return t({message:"getProgramTime: playlist and time must be provided"});const i=b5(e,s);if(!i)return t({message:"valid programTime was not found"});if(i.type==="estimate")return t({message:"Accurate programTime could not be determined. Please seek to e.seekTime and try again",seekTime:i.estimatedStart});const n={mediaSeconds:e},r=y5(e,i.segment);return r&&(n.programDateTime=r.toISOString()),t(null,n)},ND=({programTime:s,playlist:e,retryCount:t=2,seekTo:i,pauseAfterSeek:n=!0,tech:r,callback:o})=>{if(!o)throw new Error("seekToProgramTime: callback must be provided");if(typeof s>"u"||!e||!i)return o({message:"seekToProgramTime: programTime, seekTo and playlist must be provided"});if(!e.endList&&!r.hasStarted_)return o({message:"player must be playing a live stream to start buffering"});if(!x5(e))return o({message:"programDateTime tags must be provided in the manifest "+e.resolvedUri});const u=T5(s,e);if(!u)return o({message:`${s} was not found in the stream`});const c=u.segment,d=_5(c.dateTimeObject,s);if(u.type==="estimate"){if(t===0)return o({message:`${s} is not buffered yet. Try again`});i(u.estimatedStart+d),r.one("seeked",()=>{ND({programTime:s,playlist:e,retryCount:t-1,seekTo:i,pauseAfterSeek:n,tech:r,callback:o})});return}const f=c.start+d,m=()=>o(null,r.currentTime());r.one("seeked",m),n&&r.pause(),i(f)},ky=(s,e)=>{if(s.readyState===4)return e()},E5=(s,e,t,i)=>{let n=[],r,o=!1;const u=function(m,g,v,b){return g.abort(),o=!0,t(m,g,v,b)},c=function(m,g){if(o)return;if(m)return m.metadata=_l({requestType:i,request:g,error:m}),u(m,g,"",n);const v=g.responseText.substring(n&&n.byteLength||0,g.responseText.length);if(n=QP(n,MA(v,!0)),r=r||Dd(n),n.length<10||r&&n.length<r+2)return ky(g,()=>u(m,g,"",n));const b=TT(n);return b==="ts"&&n.length<188?ky(g,()=>u(m,g,"",n)):!b&&n.length<376?ky(g,()=>u(m,g,"",n)):u(null,g,b,n)},f=e({uri:s,beforeSend(m){m.overrideMimeType("text/plain; charset=x-user-defined"),m.addEventListener("progress",function({total:g,loaded:v}){return Pv(m,null,{statusCode:m.status},c)})}},function(m,g){return Pv(f,m,g,c)});return f},{EventTarget:A5}=Te,s1=function(s,e){if(!ID(s,e)||s.sidx&&e.sidx&&(s.sidx.offset!==e.sidx.offset||s.sidx.length!==e.sidx.length))return!1;if(!s.sidx&&e.sidx||s.sidx&&!e.sidx||s.segments&&!e.segments||!s.segments&&e.segments)return!1;if(!s.segments&&!e.segments)return!0;for(let t=0;t<s.segments.length;t++){const i=s.segments[t],n=e.segments[t];if(i.uri!==n.uri)return!1;if(!i.byterange&&!n.byterange)continue;const r=i.byterange,o=n.byterange;if(r&&!o||!r&&o||r.offset!==o.offset||r.length!==o.length)return!1}return!0},C5=(s,e,t,i)=>{const n=i.attributes.NAME||t;return`placeholder-uri-${s}-${e}-${n}`},D5=({mainXml:s,srcUrl:e,clientOffset:t,sidxMapping:i,previousManifest:n})=>{const r=WM(s,{manifestUri:e,clientOffset:t,sidxMapping:i,previousManifest:n});return ED(r,e,C5),r},w5=(s,e)=>{fc(s,(t,i,n,r)=>{(!e.mediaGroups[i][n]||!(r in e.mediaGroups[i][n]))&&delete s.mediaGroups[i][n][r]})},L5=(s,e,t)=>{let i=!0,n=Kt(s,{duration:e.duration,minimumUpdatePeriod:e.minimumUpdatePeriod,timelineStarts:e.timelineStarts});for(let r=0;r<e.playlists.length;r++){const o=e.playlists[r];if(o.sidx){const c=xm(o.sidx);t&&t[c]&&t[c].sidx&&gT(o,t[c].sidx,o.sidx.resolvedUri)}const u=Rv(n,o,s1);u&&(n=u,i=!1)}return fc(e,(r,o,u,c)=>{if(r.playlists&&r.playlists.length){const d=r.playlists[0].id,f=Rv(n,r.playlists[0],s1);f&&(n=f,c in n.mediaGroups[o][u]||(n.mediaGroups[o][u][c]=r),n.mediaGroups[o][u][c].playlists[0]=n.playlists[d],i=!1)}}),w5(n,e),e.minimumUpdatePeriod!==s.minimumUpdatePeriod&&(i=!1),i?null:n},I5=(s,e)=>(!s.map&&!e.map||!!(s.map&&e.map&&s.map.byterange.offset===e.map.byterange.offset&&s.map.byterange.length===e.map.byterange.length))&&s.uri===e.uri&&s.byterange.offset===e.byterange.offset&&s.byterange.length===e.byterange.length,n1=(s,e)=>{const t={};for(const i in s){const r=s[i].sidx;if(r){const o=xm(r);if(!e[o])break;const u=e[o].sidxInfo;I5(u,r)&&(t[o]=e[o])}}return t},k5=(s,e)=>{let i=n1(s.playlists,e);return fc(s,(n,r,o,u)=>{if(n.playlists&&n.playlists.length){const c=n.playlists;i=Kt(i,n1(c,e))}}),i};class Nv extends A5{constructor(e,t,i={},n){super(),this.isPaused_=!0,this.mainPlaylistLoader_=n||this,n||(this.isMain_=!0);const{withCredentials:r=!1}=i;if(this.vhs_=t,this.withCredentials=r,this.addMetadataToTextTrack=i.addMetadataToTextTrack,!e)throw new Error("A non-empty playlist URL or object is required");this.on("minimumUpdatePeriod",()=>{this.refreshXml_()}),this.on("mediaupdatetimeout",()=>{this.refreshMedia_(this.media().id)}),this.state="HAVE_NOTHING",this.loadedPlaylists_={},this.logger_=$n("DashPlaylistLoader"),this.isMain_?(this.mainPlaylistLoader_.srcUrl=e,this.mainPlaylistLoader_.sidxMapping_={}):this.childPlaylist_=e}get isPaused(){return this.isPaused_}requestErrored_(e,t,i){if(!this.request)return!0;if(this.request=null,e)return this.error=typeof e=="object"&&!(e instanceof Error)?e:{status:t.status,message:"DASH request error at URL: "+t.uri,response:t.response,code:2,metadata:e.metadata},i&&(this.state=i),this.trigger("error"),!0}addSidxSegments_(e,t,i){const n=e.sidx&&xm(e.sidx);if(!e.sidx||!n||this.mainPlaylistLoader_.sidxMapping_[n]){ne.clearTimeout(this.mediaRequest_),this.mediaRequest_=ne.setTimeout(()=>i(!1),0);return}const r=Kp(e.sidx.resolvedUri),o=(c,d)=>{if(this.requestErrored_(c,d,t))return;const f=this.mainPlaylistLoader_.sidxMapping_,{requestType:m}=d;let g;try{g=eN(lt(d.response).subarray(8))}catch(v){v.metadata=_l({requestType:m,request:d,parseFailure:!0}),this.requestErrored_(v,d,t);return}return f[n]={sidxInfo:e.sidx,sidx:g},gT(e,g,e.sidx.resolvedUri),i(!0)},u="dash-sidx";this.request=E5(r,this.vhs_.xhr,(c,d,f,m)=>{if(c)return o(c,d);if(!f||f!=="mp4"){const b=f||"unknown";return o({status:d.status,message:`Unsupported ${b} container type for sidx segment at URL: ${r}`,response:"",playlist:e,internal:!0,playlistExclusionDuration:1/0,code:2},d)}const{offset:g,length:v}=e.sidx.byterange;if(m.length>=v+g)return o(c,{response:m.subarray(g,g+v),status:d.status,uri:d.uri});this.request=this.vhs_.xhr({uri:r,responseType:"arraybuffer",requestType:"dash-sidx",headers:Mv({byterange:e.sidx.byterange})},o)},u)}dispose(){this.isPaused_=!0,this.trigger("dispose"),this.stopRequest(),this.loadedPlaylists_={},ne.clearTimeout(this.minimumUpdatePeriodTimeout_),ne.clearTimeout(this.mediaRequest_),ne.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null,this.mediaRequest_=null,this.minimumUpdatePeriodTimeout_=null,this.mainPlaylistLoader_.createMupOnMedia_&&(this.off("loadedmetadata",this.mainPlaylistLoader_.createMupOnMedia_),this.mainPlaylistLoader_.createMupOnMedia_=null),this.off()}hasPendingRequest(){return this.request||this.mediaRequest_}stopRequest(){if(this.request){const e=this.request;this.request=null,e.onreadystatechange=null,e.abort()}}media(e){if(!e)return this.media_;if(this.state==="HAVE_NOTHING")throw new Error("Cannot switch media playlist from "+this.state);const t=this.state;if(typeof e=="string"){if(!this.mainPlaylistLoader_.main.playlists[e])throw new Error("Unknown playlist URI: "+e);e=this.mainPlaylistLoader_.main.playlists[e]}const i=!this.media_||e.id!==this.media_.id;if(i&&this.loadedPlaylists_[e.id]&&this.loadedPlaylists_[e.id].endList){this.state="HAVE_METADATA",this.media_=e,i&&(this.trigger("mediachanging"),this.trigger("mediachange"));return}i&&(this.media_&&this.trigger("mediachanging"),this.addSidxSegments_(e,t,n=>{this.haveMetadata({startingState:t,playlist:e})}))}haveMetadata({startingState:e,playlist:t}){this.state="HAVE_METADATA",this.loadedPlaylists_[t.id]=t,ne.clearTimeout(this.mediaRequest_),this.mediaRequest_=null,this.refreshMedia_(t.id),e==="HAVE_MAIN_MANIFEST"?this.trigger("loadedmetadata"):this.trigger("mediachange")}pause(){this.isPaused_=!0,this.mainPlaylistLoader_.createMupOnMedia_&&(this.off("loadedmetadata",this.mainPlaylistLoader_.createMupOnMedia_),this.mainPlaylistLoader_.createMupOnMedia_=null),this.stopRequest(),ne.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null,this.isMain_&&(ne.clearTimeout(this.mainPlaylistLoader_.minimumUpdatePeriodTimeout_),this.mainPlaylistLoader_.minimumUpdatePeriodTimeout_=null),this.state==="HAVE_NOTHING"&&(this.started=!1)}load(e){this.isPaused_=!1,ne.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null;const t=this.media();if(e){const i=t?t.targetDuration/2*1e3:5e3;this.mediaUpdateTimeout=ne.setTimeout(()=>this.load(),i);return}if(!this.started){this.start();return}t&&!t.endList?(this.isMain_&&!this.minimumUpdatePeriodTimeout_&&(this.trigger("minimumUpdatePeriod"),this.updateMinimumUpdatePeriodTimeout_()),this.trigger("mediaupdatetimeout")):this.trigger("loadedplaylist")}start(){if(this.started=!0,!this.isMain_){ne.clearTimeout(this.mediaRequest_),this.mediaRequest_=ne.setTimeout(()=>this.haveMain_(),0);return}this.requestMain_((e,t)=>{this.haveMain_(),!this.hasPendingRequest()&&!this.media_&&this.media(this.mainPlaylistLoader_.main.playlists[0])})}requestMain_(e){const t={manifestInfo:{uri:this.mainPlaylistLoader_.srcUrl}};this.trigger({type:"manifestrequeststart",metadata:t}),this.request=this.vhs_.xhr({uri:this.mainPlaylistLoader_.srcUrl,withCredentials:this.withCredentials,requestType:"dash-manifest"},(i,n)=>{if(i){const{requestType:o}=n;i.metadata=_l({requestType:o,request:n,error:i})}if(this.requestErrored_(i,n)){this.state==="HAVE_NOTHING"&&(this.started=!1);return}this.trigger({type:"manifestrequestcomplete",metadata:t});const r=n.responseText!==this.mainPlaylistLoader_.mainXml_;if(this.mainPlaylistLoader_.mainXml_=n.responseText,n.responseHeaders&&n.responseHeaders.date?this.mainLoaded_=Date.parse(n.responseHeaders.date):this.mainLoaded_=Date.now(),this.mainPlaylistLoader_.srcUrl=Kp(this.mainPlaylistLoader_.srcUrl,n),r){this.handleMain_(),this.syncClientServerClock_(()=>e(n,r));return}return e(n,r)})}syncClientServerClock_(e){const t=XM(this.mainPlaylistLoader_.mainXml_);if(t===null)return this.mainPlaylistLoader_.clientOffset_=this.mainLoaded_-Date.now(),e();if(t.method==="DIRECT")return this.mainPlaylistLoader_.clientOffset_=t.value-Date.now(),e();this.request=this.vhs_.xhr({uri:Js(this.mainPlaylistLoader_.srcUrl,t.value),method:t.method,withCredentials:this.withCredentials,requestType:"dash-clock-sync"},(i,n)=>{if(!this.request)return;if(i){const{requestType:o}=n;return this.error.metadata=_l({requestType:o,request:n,error:i}),this.mainPlaylistLoader_.clientOffset_=this.mainLoaded_-Date.now(),e()}let r;t.method==="HEAD"?!n.responseHeaders||!n.responseHeaders.date?r=this.mainLoaded_:r=Date.parse(n.responseHeaders.date):r=Date.parse(n.responseText),this.mainPlaylistLoader_.clientOffset_=r-Date.now(),e()})}haveMain_(){this.state="HAVE_MAIN_MANIFEST",this.isMain_?this.trigger("loadedplaylist"):this.media_||this.media(this.childPlaylist_)}handleMain_(){ne.clearTimeout(this.mediaRequest_),this.mediaRequest_=null;const e=this.mainPlaylistLoader_.main,t={manifestInfo:{uri:this.mainPlaylistLoader_.srcUrl}};this.trigger({type:"manifestparsestart",metadata:t});let i;try{i=D5({mainXml:this.mainPlaylistLoader_.mainXml_,srcUrl:this.mainPlaylistLoader_.srcUrl,clientOffset:this.mainPlaylistLoader_.clientOffset_,sidxMapping:this.mainPlaylistLoader_.sidxMapping_,previousManifest:e})}catch(r){this.error=r,this.error.metadata={errorType:Te.Error.StreamingDashManifestParserError,error:r},this.trigger("error")}e&&(i=L5(e,i,this.mainPlaylistLoader_.sidxMapping_)),this.mainPlaylistLoader_.main=i||e;const n=this.mainPlaylistLoader_.main.locations&&this.mainPlaylistLoader_.main.locations[0];if(n&&n!==this.mainPlaylistLoader_.srcUrl&&(this.mainPlaylistLoader_.srcUrl=n),(!e||i&&i.minimumUpdatePeriod!==e.minimumUpdatePeriod)&&this.updateMinimumUpdatePeriodTimeout_(),this.addEventStreamToMetadataTrack_(i),i){const{duration:r,endList:o}=i,u=[];i.playlists.forEach(d=>{u.push({id:d.id,bandwidth:d.attributes.BANDWIDTH,resolution:d.attributes.RESOLUTION,codecs:d.attributes.CODECS})});const c={duration:r,isLive:!o,renditions:u};t.parsedManifest=c,this.trigger({type:"manifestparsecomplete",metadata:t})}return!!i}updateMinimumUpdatePeriodTimeout_(){const e=this.mainPlaylistLoader_;e.createMupOnMedia_&&(e.off("loadedmetadata",e.createMupOnMedia_),e.createMupOnMedia_=null),e.minimumUpdatePeriodTimeout_&&(ne.clearTimeout(e.minimumUpdatePeriodTimeout_),e.minimumUpdatePeriodTimeout_=null);let t=e.main&&e.main.minimumUpdatePeriod;if(t===0&&(e.media()?t=e.media().targetDuration*1e3:(e.createMupOnMedia_=e.updateMinimumUpdatePeriodTimeout_,e.one("loadedmetadata",e.createMupOnMedia_))),typeof t!="number"||t<=0){t<0&&this.logger_(`found invalid minimumUpdatePeriod of ${t}, not setting a timeout`);return}this.createMUPTimeout_(t)}createMUPTimeout_(e){const t=this.mainPlaylistLoader_;t.minimumUpdatePeriodTimeout_=ne.setTimeout(()=>{t.minimumUpdatePeriodTimeout_=null,t.trigger("minimumUpdatePeriod"),t.createMUPTimeout_(e)},e)}refreshXml_(){this.requestMain_((e,t)=>{t&&(this.media_&&(this.media_=this.mainPlaylistLoader_.main.playlists[this.media_.id]),this.mainPlaylistLoader_.sidxMapping_=k5(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.sidxMapping_),this.addSidxSegments_(this.media(),this.state,i=>{this.refreshMedia_(this.media().id)}))})}refreshMedia_(e){if(!e)throw new Error("refreshMedia_ must take a media id");this.media_&&this.isMain_&&this.handleMain_();const t=this.mainPlaylistLoader_.main.playlists,i=!this.media_||this.media_!==t[e];if(i?this.media_=t[e]:this.trigger("playlistunchanged"),!this.mediaUpdateTimeout){const n=()=>{this.media().endList||(this.mediaUpdateTimeout=ne.setTimeout(()=>{this.trigger("mediaupdatetimeout"),n()},Ov(this.media(),!!i)))};n()}this.trigger("loadedplaylist")}addEventStreamToMetadataTrack_(e){if(e&&this.mainPlaylistLoader_.main.eventStream){const t=this.mainPlaylistLoader_.main.eventStream.map(i=>({cueTime:i.start,frames:[{data:i.messageData}]}));this.addMetadataToTextTrack("EventStream",t,this.mainPlaylistLoader_.main.duration)}}getKeyIdSet(e){if(e.contentProtection){const t=new Set;for(const i in e.contentProtection){const n=e.contentProtection[i].attributes["cenc:default_KID"];n&&t.add(n.replace(/-/g,"").toLowerCase())}return t}}}var os={GOAL_BUFFER_LENGTH:30,MAX_GOAL_BUFFER_LENGTH:60,BACK_BUFFER_LENGTH:30,GOAL_BUFFER_LENGTH_RATE:1,INITIAL_BANDWIDTH:4194304,BANDWIDTH_VARIANCE:1.2,BUFFER_LOW_WATER_LINE:0,MAX_BUFFER_LOW_WATER_LINE:30,EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:16,BUFFER_LOW_WATER_LINE_RATE:1,BUFFER_HIGH_WATER_LINE:30};const R5=s=>{const e=new Uint8Array(new ArrayBuffer(s.length));for(let t=0;t<s.length;t++)e[t]=s.charCodeAt(t);return e.buffer},BD=function(s){return s.on=s.addEventListener,s.off=s.removeEventListener,s},O5=function(s){try{return URL.createObjectURL(new Blob([s],{type:"application/javascript"}))}catch{const t=new BlobBuilder;return t.append(s),URL.createObjectURL(t.getBlob())}},FD=function(s){return function(){const e=O5(s),t=BD(new Worker(e));t.objURL=e;const i=t.terminate;return t.on=t.addEventListener,t.off=t.removeEventListener,t.terminate=function(){return URL.revokeObjectURL(e),i.call(this)},t}},UD=function(s){return`var browserWorkerPolyFill = ${BD.toString()};
browserWorkerPolyFill(self);
`+s},$D=function(s){return s.toString().replace(/^function.+?{/,"").slice(0,-1)},P5=UD($D(function(){var s=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=function(){this.init=function(){var y={};this.on=function(S,C){y[S]||(y[S]=[]),y[S]=y[S].concat(C)},this.off=function(S,C){var A;return y[S]?(A=y[S].indexOf(C),y[S]=y[S].slice(),y[S].splice(A,1),A>-1):!1},this.trigger=function(S){var C,A,D,O;if(C=y[S],!!C)if(arguments.length===2)for(D=C.length,A=0;A<D;++A)C[A].call(this,arguments[1]);else{for(O=[],A=arguments.length,A=1;A<arguments.length;++A)O.push(arguments[A]);for(D=C.length,A=0;A<D;++A)C[A].apply(this,O)}},this.dispose=function(){y={}}}};e.prototype.pipe=function(y){return this.on("data",function(S){y.push(S)}),this.on("done",function(S){y.flush(S)}),this.on("partialdone",function(S){y.partialFlush(S)}),this.on("endedtimeline",function(S){y.endTimeline(S)}),this.on("reset",function(S){y.reset(S)}),y},e.prototype.push=function(y){this.trigger("data",y)},e.prototype.flush=function(y){this.trigger("done",y)},e.prototype.partialFlush=function(y){this.trigger("partialdone",y)},e.prototype.endTimeline=function(y){this.trigger("endedtimeline",y)},e.prototype.reset=function(y){this.trigger("reset",y)};var t=e,i=Math.pow(2,32),n=function(y){var S=new DataView(y.buffer,y.byteOffset,y.byteLength),C;return S.getBigUint64?(C=S.getBigUint64(0),C<Number.MAX_SAFE_INTEGER?Number(C):C):S.getUint32(0)*i+S.getUint32(4)},r={getUint64:n,MAX_UINT32:i},o=r.MAX_UINT32,u,c,d,f,m,g,v,b,_,E,w,I,L,F,$,G,B,V,k,R,z,X,ee,le,oe,Y,Z,Q,ae,ue,U,ie,fe,xe,Ae,$e;(function(){var y;if(ee={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],pasp:[],sdtp:[],smhd:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],styp:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[]},!(typeof Uint8Array>"u")){for(y in ee)ee.hasOwnProperty(y)&&(ee[y]=[y.charCodeAt(0),y.charCodeAt(1),y.charCodeAt(2),y.charCodeAt(3)]);le=new Uint8Array([105,115,111,109]),Y=new Uint8Array([97,118,99,49]),oe=new Uint8Array([0,0,0,1]),Z=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]),Q=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]),ae={video:Z,audio:Q},ie=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),U=new Uint8Array([0,0,0,0,0,0,0,0]),fe=new Uint8Array([0,0,0,0,0,0,0,0]),xe=fe,Ae=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),$e=fe,ue=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}})(),u=function(y){var S=[],C=0,A,D,O;for(A=1;A<arguments.length;A++)S.push(arguments[A]);for(A=S.length;A--;)C+=S[A].byteLength;for(D=new Uint8Array(C+8),O=new DataView(D.buffer,D.byteOffset,D.byteLength),O.setUint32(0,D.byteLength),D.set(y,4),A=0,C=8;A<S.length;A++)D.set(S[A],C),C+=S[A].byteLength;return D},c=function(){return u(ee.dinf,u(ee.dref,ie))},d=function(y){return u(ee.esds,new Uint8Array([0,0,0,0,3,25,0,0,0,4,17,64,21,0,6,0,0,0,218,192,0,0,218,192,5,2,y.audioobjecttype<<3|y.samplingfrequencyindex>>>1,y.samplingfrequencyindex<<7|y.channelcount<<3,6,1,2]))},f=function(){return u(ee.ftyp,le,oe,le,Y)},G=function(y){return u(ee.hdlr,ae[y])},m=function(y){return u(ee.mdat,y)},$=function(y){var S=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,y.duration>>>24&255,y.duration>>>16&255,y.duration>>>8&255,y.duration&255,85,196,0,0]);return y.samplerate&&(S[12]=y.samplerate>>>24&255,S[13]=y.samplerate>>>16&255,S[14]=y.samplerate>>>8&255,S[15]=y.samplerate&255),u(ee.mdhd,S)},F=function(y){return u(ee.mdia,$(y),G(y.type),v(y))},g=function(y){return u(ee.mfhd,new Uint8Array([0,0,0,0,(y&4278190080)>>24,(y&16711680)>>16,(y&65280)>>8,y&255]))},v=function(y){return u(ee.minf,y.type==="video"?u(ee.vmhd,ue):u(ee.smhd,U),c(),V(y))},b=function(y,S){for(var C=[],A=S.length;A--;)C[A]=R(S[A]);return u.apply(null,[ee.moof,g(y)].concat(C))},_=function(y){for(var S=y.length,C=[];S--;)C[S]=I(y[S]);return u.apply(null,[ee.moov,w(4294967295)].concat(C).concat(E(y)))},E=function(y){for(var S=y.length,C=[];S--;)C[S]=z(y[S]);return u.apply(null,[ee.mvex].concat(C))},w=function(y){var S=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(y&4278190080)>>24,(y&16711680)>>16,(y&65280)>>8,y&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 u(ee.mvhd,S)},B=function(y){var S=y.samples||[],C=new Uint8Array(4+S.length),A,D;for(D=0;D<S.length;D++)A=S[D].flags,C[D+4]=A.dependsOn<<4|A.isDependedOn<<2|A.hasRedundancy;return u(ee.sdtp,C)},V=function(y){return u(ee.stbl,k(y),u(ee.stts,$e),u(ee.stsc,xe),u(ee.stsz,Ae),u(ee.stco,fe))},(function(){var y,S;k=function(C){return u(ee.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),C.type==="video"?y(C):S(C))},y=function(C){var A=C.sps||[],D=C.pps||[],O=[],W=[],J,te;for(J=0;J<A.length;J++)O.push((A[J].byteLength&65280)>>>8),O.push(A[J].byteLength&255),O=O.concat(Array.prototype.slice.call(A[J]));for(J=0;J<D.length;J++)W.push((D[J].byteLength&65280)>>>8),W.push(D[J].byteLength&255),W=W.concat(Array.prototype.slice.call(D[J]));if(te=[ee.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(C.width&65280)>>8,C.width&255,(C.height&65280)>>8,C.height&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,45,104,108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),u(ee.avcC,new Uint8Array([1,C.profileIdc,C.profileCompatibility,C.levelIdc,255].concat([A.length],O,[D.length],W))),u(ee.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]))],C.sarRatio){var re=C.sarRatio[0],pe=C.sarRatio[1];te.push(u(ee.pasp,new Uint8Array([(re&4278190080)>>24,(re&16711680)>>16,(re&65280)>>8,re&255,(pe&4278190080)>>24,(pe&16711680)>>16,(pe&65280)>>8,pe&255])))}return u.apply(null,te)},S=function(C){return u(ee.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(C.channelcount&65280)>>8,C.channelcount&255,(C.samplesize&65280)>>8,C.samplesize&255,0,0,0,0,(C.samplerate&65280)>>8,C.samplerate&255,0,0]),d(C))}})(),L=function(y){var S=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(y.id&4278190080)>>24,(y.id&16711680)>>16,(y.id&65280)>>8,y.id&255,0,0,0,0,(y.duration&4278190080)>>24,(y.duration&16711680)>>16,(y.duration&65280)>>8,y.duration&255,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,(y.width&65280)>>8,y.width&255,0,0,(y.height&65280)>>8,y.height&255,0,0]);return u(ee.tkhd,S)},R=function(y){var S,C,A,D,O,W,J;return S=u(ee.tfhd,new Uint8Array([0,0,0,58,(y.id&4278190080)>>24,(y.id&16711680)>>16,(y.id&65280)>>8,y.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0])),W=Math.floor(y.baseMediaDecodeTime/o),J=Math.floor(y.baseMediaDecodeTime%o),C=u(ee.tfdt,new Uint8Array([1,0,0,0,W>>>24&255,W>>>16&255,W>>>8&255,W&255,J>>>24&255,J>>>16&255,J>>>8&255,J&255])),O=92,y.type==="audio"?(A=X(y,O),u(ee.traf,S,C,A)):(D=B(y),A=X(y,D.length+O),u(ee.traf,S,C,A,D))},I=function(y){return y.duration=y.duration||4294967295,u(ee.trak,L(y),F(y))},z=function(y){var S=new Uint8Array([0,0,0,0,(y.id&4278190080)>>24,(y.id&16711680)>>16,(y.id&65280)>>8,y.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return y.type!=="video"&&(S[S.length-1]=0),u(ee.trex,S)},(function(){var y,S,C;C=function(A,D){var O=0,W=0,J=0,te=0;return A.length&&(A[0].duration!==void 0&&(O=1),A[0].size!==void 0&&(W=2),A[0].flags!==void 0&&(J=4),A[0].compositionTimeOffset!==void 0&&(te=8)),[0,0,O|W|J|te,1,(A.length&4278190080)>>>24,(A.length&16711680)>>>16,(A.length&65280)>>>8,A.length&255,(D&4278190080)>>>24,(D&16711680)>>>16,(D&65280)>>>8,D&255]},S=function(A,D){var O,W,J,te,re,pe;for(te=A.samples||[],D+=20+16*te.length,J=C(te,D),W=new Uint8Array(J.length+te.length*16),W.set(J),O=J.length,pe=0;pe<te.length;pe++)re=te[pe],W[O++]=(re.duration&4278190080)>>>24,W[O++]=(re.duration&16711680)>>>16,W[O++]=(re.duration&65280)>>>8,W[O++]=re.duration&255,W[O++]=(re.size&4278190080)>>>24,W[O++]=(re.size&16711680)>>>16,W[O++]=(re.size&65280)>>>8,W[O++]=re.size&255,W[O++]=re.flags.isLeading<<2|re.flags.dependsOn,W[O++]=re.flags.isDependedOn<<6|re.flags.hasRedundancy<<4|re.flags.paddingValue<<1|re.flags.isNonSyncSample,W[O++]=re.flags.degradationPriority&61440,W[O++]=re.flags.degradationPriority&15,W[O++]=(re.compositionTimeOffset&4278190080)>>>24,W[O++]=(re.compositionTimeOffset&16711680)>>>16,W[O++]=(re.compositionTimeOffset&65280)>>>8,W[O++]=re.compositionTimeOffset&255;return u(ee.trun,W)},y=function(A,D){var O,W,J,te,re,pe;for(te=A.samples||[],D+=20+8*te.length,J=C(te,D),O=new Uint8Array(J.length+te.length*8),O.set(J),W=J.length,pe=0;pe<te.length;pe++)re=te[pe],O[W++]=(re.duration&4278190080)>>>24,O[W++]=(re.duration&16711680)>>>16,O[W++]=(re.duration&65280)>>>8,O[W++]=re.duration&255,O[W++]=(re.size&4278190080)>>>24,O[W++]=(re.size&16711680)>>>16,O[W++]=(re.size&65280)>>>8,O[W++]=re.size&255;return u(ee.trun,O)},X=function(A,D){return A.type==="audio"?y(A,D):S(A,D)}})();var Ee={ftyp:f,mdat:m,moof:b,moov:_,initSegment:function(y){var S=f(),C=_(y),A;return A=new Uint8Array(S.byteLength+C.byteLength),A.set(S),A.set(C,S.byteLength),A}},je=function(y){var S,C,A=[],D=[];for(D.byteLength=0,D.nalCount=0,D.duration=0,A.byteLength=0,S=0;S<y.length;S++)C=y[S],C.nalUnitType==="access_unit_delimiter_rbsp"?(A.length&&(A.duration=C.dts-A.dts,D.byteLength+=A.byteLength,D.nalCount+=A.length,D.duration+=A.duration,D.push(A)),A=[C],A.byteLength=C.data.byteLength,A.pts=C.pts,A.dts=C.dts):(C.nalUnitType==="slice_layer_without_partitioning_rbsp_idr"&&(A.keyFrame=!0),A.duration=C.dts-A.dts,A.byteLength+=C.data.byteLength,A.push(C));return D.length&&(!A.duration||A.duration<=0)&&(A.duration=D[D.length-1].duration),D.byteLength+=A.byteLength,D.nalCount+=A.length,D.duration+=A.duration,D.push(A),D},qe=function(y){var S,C,A=[],D=[];for(A.byteLength=0,A.nalCount=0,A.duration=0,A.pts=y[0].pts,A.dts=y[0].dts,D.byteLength=0,D.nalCount=0,D.duration=0,D.pts=y[0].pts,D.dts=y[0].dts,S=0;S<y.length;S++)C=y[S],C.keyFrame?(A.length&&(D.push(A),D.byteLength+=A.byteLength,D.nalCount+=A.nalCount,D.duration+=A.duration),A=[C],A.nalCount=C.length,A.byteLength=C.byteLength,A.pts=C.pts,A.dts=C.dts,A.duration=C.duration):(A.duration+=C.duration,A.nalCount+=C.length,A.byteLength+=C.byteLength,A.push(C));return D.length&&A.duration<=0&&(A.duration=D[D.length-1].duration),D.byteLength+=A.byteLength,D.nalCount+=A.nalCount,D.duration+=A.duration,D.push(A),D},et=function(y){var S;return!y[0][0].keyFrame&&y.length>1&&(S=y.shift(),y.byteLength-=S.byteLength,y.nalCount-=S.nalCount,y[0][0].dts=S.dts,y[0][0].pts=S.pts,y[0][0].duration+=S.duration),y},rt=function(){return{size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0,isNonSyncSample:1}}},ht=function(y,S){var C=rt();return C.dataOffset=S,C.compositionTimeOffset=y.pts-y.dts,C.duration=y.duration,C.size=4*y.length,C.size+=y.byteLength,y.keyFrame&&(C.flags.dependsOn=2,C.flags.isNonSyncSample=0),C},qt=function(y,S){var C,A,D,O,W,J=S||0,te=[];for(C=0;C<y.length;C++)for(O=y[C],A=0;A<O.length;A++)W=O[A],D=ht(W,J),J+=D.size,te.push(D);return te},xt=function(y){var S,C,A,D,O,W,J=0,te=y.byteLength,re=y.nalCount,pe=te+4*re,Le=new Uint8Array(pe),ze=new DataView(Le.buffer);for(S=0;S<y.length;S++)for(D=y[S],C=0;C<D.length;C++)for(O=D[C],A=0;A<O.length;A++)W=O[A],ze.setUint32(J,W.data.byteLength),J+=4,Le.set(W.data,J),J+=W.data.byteLength;return Le},Ri=function(y,S){var C,A=S||0,D=[];return C=ht(y,A),D.push(C),D},Be=function(y){var S,C,A=0,D=y.byteLength,O=y.length,W=D+4*O,J=new Uint8Array(W),te=new DataView(J.buffer);for(S=0;S<y.length;S++)C=y[S],te.setUint32(A,C.data.byteLength),A+=4,J.set(C.data,A),A+=C.data.byteLength;return J},Xe={groupNalsIntoFrames:je,groupFramesIntoGops:qe,extendFirstKeyFrame:et,generateSampleTable:qt,concatenateNalData:xt,generateSampleTableForFrame:Ri,concatenateNalDataForFrame:Be},ft=[33,16,5,32,164,27],At=[33,65,108,84,1,2,4,8,168,2,4,8,17,191,252],we=function(y){for(var S=[];y--;)S.push(0);return S},Fe=function(y){return Object.keys(y).reduce(function(S,C){return S[C]=new Uint8Array(y[C].reduce(function(A,D){return A.concat(D)},[])),S},{})},Ue,Ke=function(){if(!Ue){var y={96e3:[ft,[227,64],we(154),[56]],88200:[ft,[231],we(170),[56]],64e3:[ft,[248,192],we(240),[56]],48e3:[ft,[255,192],we(268),[55,148,128],we(54),[112]],44100:[ft,[255,192],we(268),[55,163,128],we(84),[112]],32e3:[ft,[255,192],we(268),[55,234],we(226),[112]],24e3:[ft,[255,192],we(268),[55,255,128],we(268),[111,112],we(126),[224]],16e3:[ft,[255,192],we(268),[55,255,128],we(268),[111,255],we(269),[223,108],we(195),[1,192]],12e3:[At,we(268),[3,127,248],we(268),[6,255,240],we(268),[13,255,224],we(268),[27,253,128],we(259),[56]],11025:[At,we(268),[3,127,248],we(268),[6,255,240],we(268),[13,255,224],we(268),[27,255,192],we(268),[55,175,128],we(108),[112]],8e3:[At,we(268),[3,121,16],we(47),[7]]};Ue=Fe(y)}return Ue},Ye=9e4,gt,Lt,$t,fi,pi,ts,vs;gt=function(y){return y*Ye},Lt=function(y,S){return y*S},$t=function(y){return y/Ye},fi=function(y,S){return y/S},pi=function(y,S){return gt(fi(y,S))},ts=function(y,S){return Lt($t(y),S)},vs=function(y,S,C){return $t(C?y:y-S)};var Et={ONE_SECOND_IN_TS:Ye,secondsToVideoTs:gt,secondsToAudioTs:Lt,videoTsToSeconds:$t,audioTsToSeconds:fi,audioTsToVideoTs:pi,videoTsToAudioTs:ts,metadataTsToSeconds:vs},de=Ke,ye=Et,Se=function(y){var S,C,A=0;for(S=0;S<y.length;S++)C=y[S],A+=C.data.byteLength;return A},He=function(y,S,C,A){var D,O=0,W=0,J=0,te=0,re,pe,Le;if(S.length&&(D=ye.audioTsToVideoTs(y.baseMediaDecodeTime,y.samplerate),O=Math.ceil(ye.ONE_SECOND_IN_TS/(y.samplerate/1024)),C&&A&&(W=D-Math.max(C,A),J=Math.floor(W/O),te=J*O),!(J<1||te>ye.ONE_SECOND_IN_TS/2))){for(re=de()[y.samplerate],re||(re=S[0].data),pe=0;pe<J;pe++)Le=S[0],S.splice(0,0,{data:re,dts:Le.dts-O,pts:Le.pts-O});return y.baseMediaDecodeTime-=Math.floor(ye.videoTsToAudioTs(te,y.samplerate)),te}},it=function(y,S,C){return S.minSegmentDts>=C?y:(S.minSegmentDts=1/0,y.filter(function(A){return A.dts>=C?(S.minSegmentDts=Math.min(S.minSegmentDts,A.dts),S.minSegmentPts=S.minSegmentDts,!0):!1}))},gi=function(y){var S,C,A=[];for(S=0;S<y.length;S++)C=y[S],A.push({size:C.data.byteLength,duration:1024});return A},Oi=function(y){var S,C,A=0,D=new Uint8Array(Se(y));for(S=0;S<y.length;S++)C=y[S],D.set(C.data,A),A+=C.data.byteLength;return D},Wi={prefixWithSilence:He,trimAdtsFramesByEarliestDts:it,generateSampleTable:gi,concatenateFrameData:Oi},Ht=Et.ONE_SECOND_IN_TS,ws=function(y,S){typeof S.pts=="number"&&(y.timelineStartInfo.pts===void 0&&(y.timelineStartInfo.pts=S.pts),y.minSegmentPts===void 0?y.minSegmentPts=S.pts:y.minSegmentPts=Math.min(y.minSegmentPts,S.pts),y.maxSegmentPts===void 0?y.maxSegmentPts=S.pts:y.maxSegmentPts=Math.max(y.maxSegmentPts,S.pts)),typeof S.dts=="number"&&(y.timelineStartInfo.dts===void 0&&(y.timelineStartInfo.dts=S.dts),y.minSegmentDts===void 0?y.minSegmentDts=S.dts:y.minSegmentDts=Math.min(y.minSegmentDts,S.dts),y.maxSegmentDts===void 0?y.maxSegmentDts=S.dts:y.maxSegmentDts=Math.max(y.maxSegmentDts,S.dts))},H=function(y){delete y.minSegmentDts,delete y.maxSegmentDts,delete y.minSegmentPts,delete y.maxSegmentPts},K=function(y,S){var C,A,D=y.minSegmentDts;return S||(D-=y.timelineStartInfo.dts),C=y.timelineStartInfo.baseMediaDecodeTime,C+=D,C=Math.max(0,C),y.type==="audio"&&(A=y.samplerate/Ht,C*=A,C=Math.floor(C)),C},se={clearDtsInfo:H,calculateTrackBaseMediaDecodeTime:K,collectDtsInfo:ws},Ce=4,Ge=128,at=function(y){for(var S=0,C={payloadType:-1,payloadSize:0},A=0,D=0;S<y.byteLength&&y[S]!==Ge;){for(;y[S]===255;)A+=255,S++;for(A+=y[S++];y[S]===255;)D+=255,S++;if(D+=y[S++],!C.payload&&A===Ce){var O=String.fromCharCode(y[S+3],y[S+4],y[S+5],y[S+6]);if(O==="GA94"){C.payloadType=A,C.payloadSize=D,C.payload=y.subarray(S,S+D);break}else C.payload=void 0}S+=D,A=0,D=0}return C},Mt=function(y){return y.payload[0]!==181||(y.payload[1]<<8|y.payload[2])!==49||String.fromCharCode(y.payload[3],y.payload[4],y.payload[5],y.payload[6])!=="GA94"||y.payload[7]!==3?null:y.payload.subarray(8,y.payload.length-1)},xi=function(y,S){var C=[],A,D,O,W;if(!(S[0]&64))return C;for(D=S[0]&31,A=0;A<D;A++)O=A*3,W={type:S[O+2]&3,pts:y},S[O+2]&4&&(W.ccData=S[O+3]<<8|S[O+4],C.push(W));return C},Pi=function(y){for(var S=y.byteLength,C=[],A=1,D,O;A<S-2;)y[A]===0&&y[A+1]===0&&y[A+2]===3?(C.push(A+2),A+=2):A++;if(C.length===0)return y;D=S-C.length,O=new Uint8Array(D);var W=0;for(A=0;A<D;W++,A++)W===C[0]&&(W++,C.shift()),O[A]=y[W];return O},ut={parseSei:at,parseUserData:Mt,parseCaptionPackets:xi,discardEmulationPreventionBytes:Pi,USER_DATA_REGISTERED_ITU_T_T35:Ce},Mi=t,Ts=ut,ci=function(y){y=y||{},ci.prototype.init.call(this),this.parse708captions_=typeof y.parse708captions=="boolean"?y.parse708captions:!0,this.captionPackets_=[],this.ccStreams_=[new Jt(0,0),new Jt(0,1),new Jt(1,0),new Jt(1,1)],this.parse708captions_&&(this.cc708Stream_=new kt({captionServices:y.captionServices})),this.reset(),this.ccStreams_.forEach(function(S){S.on("data",this.trigger.bind(this,"data")),S.on("partialdone",this.trigger.bind(this,"partialdone")),S.on("done",this.trigger.bind(this,"done"))},this),this.parse708captions_&&(this.cc708Stream_.on("data",this.trigger.bind(this,"data")),this.cc708Stream_.on("partialdone",this.trigger.bind(this,"partialdone")),this.cc708Stream_.on("done",this.trigger.bind(this,"done")))};ci.prototype=new Mi,ci.prototype.push=function(y){var S,C,A;if(y.nalUnitType==="sei_rbsp"&&(S=Ts.parseSei(y.escapedRBSP),!!S.payload&&S.payloadType===Ts.USER_DATA_REGISTERED_ITU_T_T35&&(C=Ts.parseUserData(S),!!C))){if(y.dts<this.latestDts_){this.ignoreNextEqualDts_=!0;return}else if(y.dts===this.latestDts_&&this.ignoreNextEqualDts_){this.numSameDts_--,this.numSameDts_||(this.ignoreNextEqualDts_=!1);return}A=Ts.parseCaptionPackets(y.pts,C),this.captionPackets_=this.captionPackets_.concat(A),this.latestDts_!==y.dts&&(this.numSameDts_=0),this.numSameDts_++,this.latestDts_=y.dts}},ci.prototype.flushCCStreams=function(y){this.ccStreams_.forEach(function(S){return y==="flush"?S.flush():S.partialFlush()},this)},ci.prototype.flushStream=function(y){if(!this.captionPackets_.length){this.flushCCStreams(y);return}this.captionPackets_.forEach(function(S,C){S.presortIndex=C}),this.captionPackets_.sort(function(S,C){return S.pts===C.pts?S.presortIndex-C.presortIndex:S.pts-C.pts}),this.captionPackets_.forEach(function(S){S.type<2?this.dispatchCea608Packet(S):this.dispatchCea708Packet(S)},this),this.captionPackets_.length=0,this.flushCCStreams(y)},ci.prototype.flush=function(){return this.flushStream("flush")},ci.prototype.partialFlush=function(){return this.flushStream("partialFlush")},ci.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.numSameDts_=0,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach(function(y){y.reset()})},ci.prototype.dispatchCea608Packet=function(y){this.setsTextOrXDSActive(y)?this.activeCea608Channel_[y.type]=null:this.setsChannel1Active(y)?this.activeCea608Channel_[y.type]=0:this.setsChannel2Active(y)&&(this.activeCea608Channel_[y.type]=1),this.activeCea608Channel_[y.type]!==null&&this.ccStreams_[(y.type<<1)+this.activeCea608Channel_[y.type]].push(y)},ci.prototype.setsChannel1Active=function(y){return(y.ccData&30720)===4096},ci.prototype.setsChannel2Active=function(y){return(y.ccData&30720)===6144},ci.prototype.setsTextOrXDSActive=function(y){return(y.ccData&28928)===256||(y.ccData&30974)===4138||(y.ccData&30974)===6186},ci.prototype.dispatchCea708Packet=function(y){this.parse708captions_&&this.cc708Stream_.push(y)};var An={127:9834,4128:32,4129:160,4133:8230,4138:352,4140:338,4144:9608,4145:8216,4146:8217,4147:8220,4148:8221,4149:8226,4153:8482,4154:353,4156:339,4157:8480,4159:376,4214:8539,4215:8540,4216:8541,4217:8542,4218:9168,4219:9124,4220:9123,4221:9135,4222:9126,4223:9121,4256:12600},Ls=function(y){var S=An[y]||y;return y&4096&&y===S?"":String.fromCharCode(S)},Ni=function(y){return 32<=y&&y<=127||160<=y&&y<=255},jt=function(y){this.windowNum=y,this.reset()};jt.prototype.reset=function(){this.clearText(),this.pendingNewLine=!1,this.winAttr={},this.penAttr={},this.penLoc={},this.penColor={},this.visible=0,this.rowLock=0,this.columnLock=0,this.priority=0,this.relativePositioning=0,this.anchorVertical=0,this.anchorHorizontal=0,this.anchorPoint=0,this.rowCount=1,this.virtualRowCount=this.rowCount+1,this.columnCount=41,this.windowStyle=0,this.penStyle=0},jt.prototype.getText=function(){return this.rows.join(`
`)},jt.prototype.clearText=function(){this.rows=[""],this.rowIdx=0},jt.prototype.newLine=function(y){for(this.rows.length>=this.virtualRowCount&&typeof this.beforeRowOverflow=="function"&&this.beforeRowOverflow(y),this.rows.length>0&&(this.rows.push(""),this.rowIdx++);this.rows.length>this.virtualRowCount;)this.rows.shift(),this.rowIdx--},jt.prototype.isEmpty=function(){return this.rows.length===0?!0:this.rows.length===1?this.rows[0]==="":!1},jt.prototype.addText=function(y){this.rows[this.rowIdx]+=y},jt.prototype.backspace=function(){if(!this.isEmpty()){var y=this.rows[this.rowIdx];this.rows[this.rowIdx]=y.substr(0,y.length-1)}};var Nt=function(y,S,C){this.serviceNum=y,this.text="",this.currentWindow=new jt(-1),this.windows=[],this.stream=C,typeof S=="string"&&this.createTextDecoder(S)};Nt.prototype.init=function(y,S){this.startPts=y;for(var C=0;C<8;C++)this.windows[C]=new jt(C),typeof S=="function"&&(this.windows[C].beforeRowOverflow=S)},Nt.prototype.setCurrentWindow=function(y){this.currentWindow=this.windows[y]},Nt.prototype.createTextDecoder=function(y){if(typeof TextDecoder>"u")this.stream.trigger("log",{level:"warn",message:"The `encoding` option is unsupported without TextDecoder support"});else try{this.textDecoder_=new TextDecoder(y)}catch(S){this.stream.trigger("log",{level:"warn",message:"TextDecoder could not be created with "+y+" encoding. "+S})}};var kt=function(y){y=y||{},kt.prototype.init.call(this);var S=this,C=y.captionServices||{},A={},D;Object.keys(C).forEach(O=>{D=C[O],/^SERVICE/.test(O)&&(A[O]=D.encoding)}),this.serviceEncodings=A,this.current708Packet=null,this.services={},this.push=function(O){O.type===3?(S.new708Packet(),S.add708Bytes(O)):(S.current708Packet===null&&S.new708Packet(),S.add708Bytes(O))}};kt.prototype=new Mi,kt.prototype.new708Packet=function(){this.current708Packet!==null&&this.push708Packet(),this.current708Packet={data:[],ptsVals:[]}},kt.prototype.add708Bytes=function(y){var S=y.ccData,C=S>>>8,A=S&255;this.current708Packet.ptsVals.push(y.pts),this.current708Packet.data.push(C),this.current708Packet.data.push(A)},kt.prototype.push708Packet=function(){var y=this.current708Packet,S=y.data,C=null,A=null,D=0,O=S[D++];for(y.seq=O>>6,y.sizeCode=O&63;D<S.length;D++)O=S[D++],C=O>>5,A=O&31,C===7&&A>0&&(O=S[D++],C=O),this.pushServiceBlock(C,D,A),A>0&&(D+=A-1)},kt.prototype.pushServiceBlock=function(y,S,C){var A,D=S,O=this.current708Packet.data,W=this.services[y];for(W||(W=this.initService(y,D));D<S+C&&D<O.length;D++)A=O[D],Ni(A)?D=this.handleText(D,W):A===24?D=this.multiByteCharacter(D,W):A===16?D=this.extendedCommands(D,W):128<=A&&A<=135?D=this.setCurrentWindow(D,W):152<=A&&A<=159?D=this.defineWindow(D,W):A===136?D=this.clearWindows(D,W):A===140?D=this.deleteWindows(D,W):A===137?D=this.displayWindows(D,W):A===138?D=this.hideWindows(D,W):A===139?D=this.toggleWindows(D,W):A===151?D=this.setWindowAttributes(D,W):A===144?D=this.setPenAttributes(D,W):A===145?D=this.setPenColor(D,W):A===146?D=this.setPenLocation(D,W):A===143?W=this.reset(D,W):A===8?W.currentWindow.backspace():A===12?W.currentWindow.clearText():A===13?W.currentWindow.pendingNewLine=!0:A===14?W.currentWindow.clearText():A===141&&D++},kt.prototype.extendedCommands=function(y,S){var C=this.current708Packet.data,A=C[++y];return Ni(A)&&(y=this.handleText(y,S,{isExtended:!0})),y},kt.prototype.getPts=function(y){return this.current708Packet.ptsVals[Math.floor(y/2)]},kt.prototype.initService=function(y,S){var A="SERVICE"+y,C=this,A,D;return A in this.serviceEncodings&&(D=this.serviceEncodings[A]),this.services[y]=new Nt(y,D,C),this.services[y].init(this.getPts(S),function(O){C.flushDisplayed(O,C.services[y])}),this.services[y]},kt.prototype.handleText=function(y,S,C){var A=C&&C.isExtended,D=C&&C.isMultiByte,O=this.current708Packet.data,W=A?4096:0,J=O[y],te=O[y+1],re=S.currentWindow,pe,Le;function ze(Re){return Re.map(Qe=>("0"+(Qe&255).toString(16)).slice(-2)).join("")}if(D?(Le=[J,te],y++):Le=[J],S.textDecoder_&&!A)pe=S.textDecoder_.decode(new Uint8Array(Le));else if(D){const Re=ze(Le);pe=String.fromCharCode(parseInt(Re,16))}else pe=Ls(W|J);return re.pendingNewLine&&!re.isEmpty()&&re.newLine(this.getPts(y)),re.pendingNewLine=!1,re.addText(pe),y},kt.prototype.multiByteCharacter=function(y,S){var C=this.current708Packet.data,A=C[y+1],D=C[y+2];return Ni(A)&&Ni(D)&&(y=this.handleText(++y,S,{isMultiByte:!0})),y},kt.prototype.setCurrentWindow=function(y,S){var C=this.current708Packet.data,A=C[y],D=A&7;return S.setCurrentWindow(D),y},kt.prototype.defineWindow=function(y,S){var C=this.current708Packet.data,A=C[y],D=A&7;S.setCurrentWindow(D);var O=S.currentWindow;return A=C[++y],O.visible=(A&32)>>5,O.rowLock=(A&16)>>4,O.columnLock=(A&8)>>3,O.priority=A&7,A=C[++y],O.relativePositioning=(A&128)>>7,O.anchorVertical=A&127,A=C[++y],O.anchorHorizontal=A,A=C[++y],O.anchorPoint=(A&240)>>4,O.rowCount=A&15,A=C[++y],O.columnCount=A&63,A=C[++y],O.windowStyle=(A&56)>>3,O.penStyle=A&7,O.virtualRowCount=O.rowCount+1,y},kt.prototype.setWindowAttributes=function(y,S){var C=this.current708Packet.data,A=C[y],D=S.currentWindow.winAttr;return A=C[++y],D.fillOpacity=(A&192)>>6,D.fillRed=(A&48)>>4,D.fillGreen=(A&12)>>2,D.fillBlue=A&3,A=C[++y],D.borderType=(A&192)>>6,D.borderRed=(A&48)>>4,D.borderGreen=(A&12)>>2,D.borderBlue=A&3,A=C[++y],D.borderType+=(A&128)>>5,D.wordWrap=(A&64)>>6,D.printDirection=(A&48)>>4,D.scrollDirection=(A&12)>>2,D.justify=A&3,A=C[++y],D.effectSpeed=(A&240)>>4,D.effectDirection=(A&12)>>2,D.displayEffect=A&3,y},kt.prototype.flushDisplayed=function(y,S){for(var C=[],A=0;A<8;A++)S.windows[A].visible&&!S.windows[A].isEmpty()&&C.push(S.windows[A].getText());S.endPts=y,S.text=C.join(`
`),this.pushCaption(S),S.startPts=y},kt.prototype.pushCaption=function(y){y.text!==""&&(this.trigger("data",{startPts:y.startPts,endPts:y.endPts,text:y.text,stream:"cc708_"+y.serviceNum}),y.text="",y.startPts=y.endPts)},kt.prototype.displayWindows=function(y,S){var C=this.current708Packet.data,A=C[++y],D=this.getPts(y);this.flushDisplayed(D,S);for(var O=0;O<8;O++)A&1<<O&&(S.windows[O].visible=1);return y},kt.prototype.hideWindows=function(y,S){var C=this.current708Packet.data,A=C[++y],D=this.getPts(y);this.flushDisplayed(D,S);for(var O=0;O<8;O++)A&1<<O&&(S.windows[O].visible=0);return y},kt.prototype.toggleWindows=function(y,S){var C=this.current708Packet.data,A=C[++y],D=this.getPts(y);this.flushDisplayed(D,S);for(var O=0;O<8;O++)A&1<<O&&(S.windows[O].visible^=1);return y},kt.prototype.clearWindows=function(y,S){var C=this.current708Packet.data,A=C[++y],D=this.getPts(y);this.flushDisplayed(D,S);for(var O=0;O<8;O++)A&1<<O&&S.windows[O].clearText();return y},kt.prototype.deleteWindows=function(y,S){var C=this.current708Packet.data,A=C[++y],D=this.getPts(y);this.flushDisplayed(D,S);for(var O=0;O<8;O++)A&1<<O&&S.windows[O].reset();return y},kt.prototype.setPenAttributes=function(y,S){var C=this.current708Packet.data,A=C[y],D=S.currentWindow.penAttr;return A=C[++y],D.textTag=(A&240)>>4,D.offset=(A&12)>>2,D.penSize=A&3,A=C[++y],D.italics=(A&128)>>7,D.underline=(A&64)>>6,D.edgeType=(A&56)>>3,D.fontStyle=A&7,y},kt.prototype.setPenColor=function(y,S){var C=this.current708Packet.data,A=C[y],D=S.currentWindow.penColor;return A=C[++y],D.fgOpacity=(A&192)>>6,D.fgRed=(A&48)>>4,D.fgGreen=(A&12)>>2,D.fgBlue=A&3,A=C[++y],D.bgOpacity=(A&192)>>6,D.bgRed=(A&48)>>4,D.bgGreen=(A&12)>>2,D.bgBlue=A&3,A=C[++y],D.edgeRed=(A&48)>>4,D.edgeGreen=(A&12)>>2,D.edgeBlue=A&3,y},kt.prototype.setPenLocation=function(y,S){var C=this.current708Packet.data,A=C[y],D=S.currentWindow.penLoc;return S.currentWindow.pendingNewLine=!0,A=C[++y],D.row=A&15,A=C[++y],D.column=A&63,y},kt.prototype.reset=function(y,S){var C=this.getPts(y);return this.flushDisplayed(C,S),this.initService(S.serviceNum,y)};var Cn={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,304:174,305:176,306:189,307:191,308:8482,309:162,310:163,311:9834,312:224,313:160,314:232,315:226,316:234,317:238,318:244,319:251,544:193,545:201,546:211,547:218,548:220,549:252,550:8216,551:161,552:42,553:39,554:8212,555:169,556:8480,557:8226,558:8220,559:8221,560:192,561:194,562:199,563:200,564:202,565:203,566:235,567:206,568:207,569:239,570:212,571:217,572:249,573:219,574:171,575:187,800:195,801:227,802:205,803:204,804:236,805:210,806:242,807:213,808:245,809:123,810:125,811:92,812:94,813:95,814:124,815:126,816:196,817:228,818:214,819:246,820:223,821:165,822:164,823:9474,824:197,825:229,826:216,827:248,828:9484,829:9488,830:9492,831:9496},jr=function(y){return y===null?"":(y=Cn[y]||y,String.fromCharCode(y))},wl=14,hh=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],an=function(){for(var y=[],S=wl+1;S--;)y.push({text:"",indent:0,offset:0});return y},Jt=function(y,S){Jt.prototype.init.call(this),this.field_=y||0,this.dataChannel_=S||0,this.name_="CC"+((this.field_<<1|this.dataChannel_)+1),this.setConstants(),this.reset(),this.push=function(C){var A,D,O,W,J;if(A=C.ccData&32639,A===this.lastControlCode_){this.lastControlCode_=null;return}if((A&61440)===4096?this.lastControlCode_=A:A!==this.PADDING_&&(this.lastControlCode_=null),O=A>>>8,W=A&255,A!==this.PADDING_)if(A===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(A===this.END_OF_CAPTION_)this.mode_="popOn",this.clearFormatting(C.pts),this.flushDisplayed(C.pts),D=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=D,this.startPts_=C.pts;else if(A===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(C.pts);else if(A===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(C.pts);else if(A===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(C.pts);else if(A===this.CARRIAGE_RETURN_)this.clearFormatting(C.pts),this.flushDisplayed(C.pts),this.shiftRowsUp_(),this.startPts_=C.pts;else if(A===this.BACKSPACE_)this.mode_==="popOn"?this.nonDisplayed_[this.row_].text=this.nonDisplayed_[this.row_].text.slice(0,-1):this.displayed_[this.row_].text=this.displayed_[this.row_].text.slice(0,-1);else if(A===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(C.pts),this.displayed_=an();else if(A===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=an();else if(A===this.RESUME_DIRECT_CAPTIONING_)this.mode_!=="paintOn"&&(this.flushDisplayed(C.pts),this.displayed_=an()),this.mode_="paintOn",this.startPts_=C.pts;else if(this.isSpecialCharacter(O,W))O=(O&3)<<8,J=jr(O|W),this[this.mode_](C.pts,J),this.column_++;else if(this.isExtCharacter(O,W))this.mode_==="popOn"?this.nonDisplayed_[this.row_].text=this.nonDisplayed_[this.row_].text.slice(0,-1):this.displayed_[this.row_].text=this.displayed_[this.row_].text.slice(0,-1),O=(O&3)<<8,J=jr(O|W),this[this.mode_](C.pts,J),this.column_++;else if(this.isMidRowCode(O,W))this.clearFormatting(C.pts),this[this.mode_](C.pts," "),this.column_++,(W&14)===14&&this.addFormatting(C.pts,["i"]),(W&1)===1&&this.addFormatting(C.pts,["u"]);else if(this.isOffsetControlCode(O,W)){const re=W&3;this.nonDisplayed_[this.row_].offset=re,this.column_+=re}else if(this.isPAC(O,W)){var te=hh.indexOf(A&7968);if(this.mode_==="rollUp"&&(te-this.rollUpRows_+1<0&&(te=this.rollUpRows_-1),this.setRollUp(C.pts,te)),te!==this.row_&&te>=0&&te<=14&&(this.clearFormatting(C.pts),this.row_=te),W&1&&this.formatting_.indexOf("u")===-1&&this.addFormatting(C.pts,["u"]),(A&16)===16){const re=(A&14)>>1;this.column_=re*4,this.nonDisplayed_[this.row_].indent+=re}this.isColorPAC(W)&&(W&14)===14&&this.addFormatting(C.pts,["i"])}else this.isNormalChar(O)&&(W===0&&(W=null),J=jr(O),J+=jr(W),this[this.mode_](C.pts,J),this.column_+=J.length)}};Jt.prototype=new Mi,Jt.prototype.flushDisplayed=function(y){const S=A=>{this.trigger("log",{level:"warn",message:"Skipping a malformed 608 caption at index "+A+"."})},C=[];this.displayed_.forEach((A,D)=>{if(A&&A.text&&A.text.length){try{A.text=A.text.trim()}catch{S(D)}A.text.length&&C.push({text:A.text,line:D+1,position:10+Math.min(70,A.indent*10)+A.offset*2.5})}else A==null&&S(D)}),C.length&&this.trigger("data",{startPts:this.startPts_,endPts:y,content:C,stream:this.name_})},Jt.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=an(),this.nonDisplayed_=an(),this.lastControlCode_=null,this.column_=0,this.row_=wl,this.rollUpRows_=2,this.formatting_=[]},Jt.prototype.setConstants=function(){this.dataChannel_===0?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):this.dataChannel_===1&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=this.CONTROL_|32,this.END_OF_CAPTION_=this.CONTROL_|47,this.ROLL_UP_2_ROWS_=this.CONTROL_|37,this.ROLL_UP_3_ROWS_=this.CONTROL_|38,this.ROLL_UP_4_ROWS_=this.CONTROL_|39,this.CARRIAGE_RETURN_=this.CONTROL_|45,this.RESUME_DIRECT_CAPTIONING_=this.CONTROL_|41,this.BACKSPACE_=this.CONTROL_|33,this.ERASE_DISPLAYED_MEMORY_=this.CONTROL_|44,this.ERASE_NON_DISPLAYED_MEMORY_=this.CONTROL_|46},Jt.prototype.isSpecialCharacter=function(y,S){return y===this.EXT_&&S>=48&&S<=63},Jt.prototype.isExtCharacter=function(y,S){return(y===this.EXT_+1||y===this.EXT_+2)&&S>=32&&S<=63},Jt.prototype.isMidRowCode=function(y,S){return y===this.EXT_&&S>=32&&S<=47},Jt.prototype.isOffsetControlCode=function(y,S){return y===this.OFFSET_&&S>=33&&S<=35},Jt.prototype.isPAC=function(y,S){return y>=this.BASE_&&y<this.BASE_+8&&S>=64&&S<=127},Jt.prototype.isColorPAC=function(y){return y>=64&&y<=79||y>=96&&y<=127},Jt.prototype.isNormalChar=function(y){return y>=32&&y<=127},Jt.prototype.setRollUp=function(y,S){if(this.mode_!=="rollUp"&&(this.row_=wl,this.mode_="rollUp",this.flushDisplayed(y),this.nonDisplayed_=an(),this.displayed_=an()),S!==void 0&&S!==this.row_)for(var C=0;C<this.rollUpRows_;C++)this.displayed_[S-C]=this.displayed_[this.row_-C],this.displayed_[this.row_-C]={text:"",indent:0,offset:0};S===void 0&&(S=this.row_),this.topRow_=S-this.rollUpRows_+1},Jt.prototype.addFormatting=function(y,S){this.formatting_=this.formatting_.concat(S);var C=S.reduce(function(A,D){return A+"<"+D+">"},"");this[this.mode_](y,C)},Jt.prototype.clearFormatting=function(y){if(this.formatting_.length){var S=this.formatting_.reverse().reduce(function(C,A){return C+"</"+A+">"},"");this.formatting_=[],this[this.mode_](y,S)}},Jt.prototype.popOn=function(y,S){var C=this.nonDisplayed_[this.row_].text;C+=S,this.nonDisplayed_[this.row_].text=C},Jt.prototype.rollUp=function(y,S){var C=this.displayed_[this.row_].text;C+=S,this.displayed_[this.row_].text=C},Jt.prototype.shiftRowsUp_=function(){var y;for(y=0;y<this.topRow_;y++)this.displayed_[y]={text:"",indent:0,offset:0};for(y=this.row_+1;y<wl+1;y++)this.displayed_[y]={text:"",indent:0,offset:0};for(y=this.topRow_;y<this.row_;y++)this.displayed_[y]=this.displayed_[y+1];this.displayed_[this.row_]={text:"",indent:0,offset:0}},Jt.prototype.paintOn=function(y,S){var C=this.displayed_[this.row_].text;C+=S,this.displayed_[this.row_].text=C};var Hr={CaptionStream:ci,Cea608Stream:Jt,Cea708Stream:kt},Hn={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21},Do=t,xa=8589934592,Gi=4294967296,pc="shared",Ll=function(y,S){var C=1;for(y>S&&(C=-1);Math.abs(S-y)>Gi;)y+=C*xa;return y},Gn=function(y){var S,C;Gn.prototype.init.call(this),this.type_=y||pc,this.push=function(A){if(A.type==="metadata"){this.trigger("data",A);return}this.type_!==pc&&A.type!==this.type_||(C===void 0&&(C=A.dts),A.dts=Ll(A.dts,C),A.pts=Ll(A.pts,C),S=A.dts,this.trigger("data",A))},this.flush=function(){C=S,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.discontinuity=function(){C=void 0,S=void 0},this.reset=function(){this.discontinuity(),this.trigger("reset")}};Gn.prototype=new Do;var Gr={TimestampRolloverStream:Gn,handleRollover:Ll},Vm=(y,S,C)=>{if(!y)return-1;for(var A=C;A<y.length;A++)if(y[A]===S)return A;return-1},fh={typedArrayIndexOf:Vm},wo=fh.typedArrayIndexOf,Il={Utf8:3},Lo=function(y,S,C){var A,D="";for(A=S;A<C;A++)D+="%"+("00"+y[A].toString(16)).slice(-2);return D},nr=function(y,S,C){return decodeURIComponent(Lo(y,S,C))},Is=function(y,S,C){return unescape(Lo(y,S,C))},is=function(y){return y[0]<<21|y[1]<<14|y[2]<<7|y[3]},Sa={APIC:function(y){var S=1,C,A,D="-->";y.data[0]===Il.Utf8&&(C=wo(y.data,0,S),!(C<0)&&(y.mimeType=Is(y.data,S,C),S=C+1,y.pictureType=y.data[S],S++,A=wo(y.data,0,S),!(A<0)&&(y.description=nr(y.data,S,A),S=A+1,y.mimeType===D?y.url=Is(y.data,S,y.data.length):y.pictureData=y.data.subarray(S,y.data.length))))},"T*":function(y){y.data[0]===Il.Utf8&&(y.value=nr(y.data,1,y.data.length).replace(/\0*$/,""),y.values=y.value.split("\0"))},TXXX:function(y){var S;y.data[0]===Il.Utf8&&(S=wo(y.data,0,1),S!==-1&&(y.description=nr(y.data,1,S),y.value=nr(y.data,S+1,y.data.length).replace(/\0*$/,""),y.data=y.value))},"W*":function(y){y.url=Is(y.data,0,y.data.length).replace(/\0.*$/,"")},WXXX:function(y){var S;y.data[0]===Il.Utf8&&(S=wo(y.data,0,1),S!==-1&&(y.description=nr(y.data,1,S),y.url=Is(y.data,S+1,y.data.length).replace(/\0.*$/,"")))},PRIV:function(y){var S;for(S=0;S<y.data.length;S++)if(y.data[S]===0){y.owner=Is(y.data,0,S);break}y.privateData=y.data.subarray(S+1),y.data=y.privateData}},qm=function(y){var S,C,A=10,D=0,O=[];if(!(y.length<10||y[0]!==73||y[1]!==68||y[2]!==51)){D=is(y.subarray(6,10)),D+=10;var W=y[5]&64;W&&(A+=4,A+=is(y.subarray(10,14)),D-=is(y.subarray(16,20)));do{if(S=is(y.subarray(A+4,A+8)),S<1)break;C=String.fromCharCode(y[A],y[A+1],y[A+2],y[A+3]);var J={id:C,data:y.subarray(A+10,A+S+10)};J.key=J.id,Sa[J.id]?Sa[J.id](J):J.id[0]==="T"?Sa["T*"](J):J.id[0]==="W"&&Sa["W*"](J),O.push(J),A+=10,A+=S}while(A<D);return O}},kl={parseId3Frames:qm,parseSyncSafeInteger:is,frameParsers:Sa},ph=t,Rl=Hn,rr=kl,cs;cs=function(y){var S={descriptor:y&&y.descriptor},C=0,A=[],D=0,O;if(cs.prototype.init.call(this),this.dispatchType=Rl.METADATA_STREAM_TYPE.toString(16),S.descriptor)for(O=0;O<S.descriptor.length;O++)this.dispatchType+=("00"+S.descriptor[O].toString(16)).slice(-2);this.push=function(W){var J,te,re,pe,Le,ze;if(W.type==="timed-metadata"){if(W.dataAlignmentIndicator&&(D=0,A.length=0),A.length===0&&(W.data.length<10||W.data[0]!==73||W.data[1]!==68||W.data[2]!==51)){this.trigger("log",{level:"warn",message:"Skipping unrecognized metadata packet"});return}if(A.push(W),D+=W.data.byteLength,A.length===1&&(C=rr.parseSyncSafeInteger(W.data.subarray(6,10)),C+=10),!(D<C)){for(J={data:new Uint8Array(C),frames:[],pts:A[0].pts,dts:A[0].dts},Le=0;Le<C;)J.data.set(A[0].data.subarray(0,C-Le),Le),Le+=A[0].data.byteLength,D-=A[0].data.byteLength,A.shift();te=10,J.data[5]&64&&(te+=4,te+=rr.parseSyncSafeInteger(J.data.subarray(10,14)),C-=rr.parseSyncSafeInteger(J.data.subarray(16,20)));do{if(re=rr.parseSyncSafeInteger(J.data.subarray(te+4,te+8)),re<1){this.trigger("log",{level:"warn",message:"Malformed ID3 frame encountered. Skipping remaining metadata parsing."});break}if(ze=String.fromCharCode(J.data[te],J.data[te+1],J.data[te+2],J.data[te+3]),pe={id:ze,data:J.data.subarray(te+10,te+re+10)},pe.key=pe.id,rr.frameParsers[pe.id]?rr.frameParsers[pe.id](pe):pe.id[0]==="T"?rr.frameParsers["T*"](pe):pe.id[0]==="W"&&rr.frameParsers["W*"](pe),pe.owner==="com.apple.streaming.transportStreamTimestamp"){var Re=pe.data,Qe=(Re[3]&1)<<30|Re[4]<<22|Re[5]<<14|Re[6]<<6|Re[7]>>>2;Qe*=4,Qe+=Re[7]&3,pe.timeStamp=Qe,J.pts===void 0&&J.dts===void 0&&(J.pts=pe.timeStamp,J.dts=pe.timeStamp),this.trigger("timestamp",pe)}J.frames.push(pe),te+=10,te+=re}while(te<C);this.trigger("data",J)}}}},cs.prototype=new ph;var mc=cs,Ol=t,Io=Hr,ss=Hn,mh=Gr.TimestampRolloverStream,ko,Dn,Pl,Vr=188,Ml=71;ko=function(){var y=new Uint8Array(Vr),S=0;ko.prototype.init.call(this),this.push=function(C){var A=0,D=Vr,O;for(S?(O=new Uint8Array(C.byteLength+S),O.set(y.subarray(0,S)),O.set(C,S),S=0):O=C;D<O.byteLength;){if(O[A]===Ml&&O[D]===Ml){this.trigger("data",O.subarray(A,D)),A+=Vr,D+=Vr;continue}A++,D++}A<O.byteLength&&(y.set(O.subarray(A),0),S=O.byteLength-A)},this.flush=function(){S===Vr&&y[0]===Ml&&(this.trigger("data",y),S=0),this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.reset=function(){S=0,this.trigger("reset")}},ko.prototype=new Ol,Dn=function(){var y,S,C,A;Dn.prototype.init.call(this),A=this,this.packetsWaitingForPmt=[],this.programMapTable=void 0,y=function(D,O){var W=0;O.payloadUnitStartIndicator&&(W+=D[W]+1),O.type==="pat"?S(D.subarray(W),O):C(D.subarray(W),O)},S=function(D,O){O.section_number=D[7],O.last_section_number=D[8],A.pmtPid=(D[10]&31)<<8|D[11],O.pmtPid=A.pmtPid},C=function(D,O){var W,J,te,re;if(D[5]&1){for(A.programMapTable={video:null,audio:null,"timed-metadata":{}},W=(D[1]&15)<<8|D[2],J=3+W-4,te=(D[10]&15)<<8|D[11],re=12+te;re<J;){var pe=D[re],Le=(D[re+1]&31)<<8|D[re+2];pe===ss.H264_STREAM_TYPE&&A.programMapTable.video===null?A.programMapTable.video=Le:pe===ss.ADTS_STREAM_TYPE&&A.programMapTable.audio===null?A.programMapTable.audio=Le:pe===ss.METADATA_STREAM_TYPE&&(A.programMapTable["timed-metadata"][Le]=pe),re+=((D[re+3]&15)<<8|D[re+4])+5}O.programMapTable=A.programMapTable}},this.push=function(D){var O={},W=4;if(O.payloadUnitStartIndicator=!!(D[1]&64),O.pid=D[1]&31,O.pid<<=8,O.pid|=D[2],(D[3]&48)>>>4>1&&(W+=D[W]+1),O.pid===0)O.type="pat",y(D.subarray(W),O),this.trigger("data",O);else if(O.pid===this.pmtPid)for(O.type="pmt",y(D.subarray(W),O),this.trigger("data",O);this.packetsWaitingForPmt.length;)this.processPes_.apply(this,this.packetsWaitingForPmt.shift());else this.programMapTable===void 0?this.packetsWaitingForPmt.push([D,W,O]):this.processPes_(D,W,O)},this.processPes_=function(D,O,W){W.pid===this.programMapTable.video?W.streamType=ss.H264_STREAM_TYPE:W.pid===this.programMapTable.audio?W.streamType=ss.ADTS_STREAM_TYPE:W.streamType=this.programMapTable["timed-metadata"][W.pid],W.type="pes",W.data=D.subarray(O),this.trigger("data",W)}},Dn.prototype=new Ol,Dn.STREAM_TYPES={h264:27,adts:15},Pl=function(){var y=this,S=!1,C={data:[],size:0},A={data:[],size:0},D={data:[],size:0},O,W=function(te,re){var pe;const Le=te[0]<<16|te[1]<<8|te[2];re.data=new Uint8Array,Le===1&&(re.packetLength=6+(te[4]<<8|te[5]),re.dataAlignmentIndicator=(te[6]&4)!==0,pe=te[7],pe&192&&(re.pts=(te[9]&14)<<27|(te[10]&255)<<20|(te[11]&254)<<12|(te[12]&255)<<5|(te[13]&254)>>>3,re.pts*=4,re.pts+=(te[13]&6)>>>1,re.dts=re.pts,pe&64&&(re.dts=(te[14]&14)<<27|(te[15]&255)<<20|(te[16]&254)<<12|(te[17]&255)<<5|(te[18]&254)>>>3,re.dts*=4,re.dts+=(te[18]&6)>>>1)),re.data=te.subarray(9+te[8]))},J=function(te,re,pe){var Le=new Uint8Array(te.size),ze={type:re},Re=0,Qe=0,mt=!1,Bi;if(!(!te.data.length||te.size<9)){for(ze.trackId=te.data[0].pid,Re=0;Re<te.data.length;Re++)Bi=te.data[Re],Le.set(Bi.data,Qe),Qe+=Bi.data.byteLength;W(Le,ze),mt=re==="video"||ze.packetLength<=te.size,(pe||mt)&&(te.size=0,te.data.length=0),mt&&y.trigger("data",ze)}};Pl.prototype.init.call(this),this.push=function(te){({pat:function(){},pes:function(){var re,pe;switch(te.streamType){case ss.H264_STREAM_TYPE:re=C,pe="video";break;case ss.ADTS_STREAM_TYPE:re=A,pe="audio";break;case ss.METADATA_STREAM_TYPE:re=D,pe="timed-metadata";break;default:return}te.payloadUnitStartIndicator&&J(re,pe,!0),re.data.push(te),re.size+=te.data.byteLength},pmt:function(){var re={type:"metadata",tracks:[]};O=te.programMapTable,O.video!==null&&re.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+O.video,codec:"avc",type:"video"}),O.audio!==null&&re.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+O.audio,codec:"adts",type:"audio"}),S=!0,y.trigger("data",re)}})[te.type]()},this.reset=function(){C.size=0,C.data.length=0,A.size=0,A.data.length=0,this.trigger("reset")},this.flushStreams_=function(){J(C,"video"),J(A,"audio"),J(D,"timed-metadata")},this.flush=function(){if(!S&&O){var te={type:"metadata",tracks:[]};O.video!==null&&te.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+O.video,codec:"avc",type:"video"}),O.audio!==null&&te.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+O.audio,codec:"adts",type:"audio"}),y.trigger("data",te)}S=!1,this.flushStreams_(),this.trigger("done")}},Pl.prototype=new Ol;var Nl={PAT_PID:0,MP2T_PACKET_LENGTH:Vr,TransportPacketStream:ko,TransportParseStream:Dn,ElementaryStream:Pl,TimestampRolloverStream:mh,CaptionStream:Io.CaptionStream,Cea608Stream:Io.Cea608Stream,Cea708Stream:Io.Cea708Stream,MetadataStream:mc};for(var gc in ss)ss.hasOwnProperty(gc)&&(Nl[gc]=ss[gc]);var zm=Nl,Bl=t,Vn=Et.ONE_SECOND_IN_TS,Ea,Fl=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];Ea=function(y){var S,C=0;Ea.prototype.init.call(this),this.skipWarn_=function(A,D){this.trigger("log",{level:"warn",message:`adts skiping bytes ${A} to ${D} in frame ${C} outside syncword`})},this.push=function(A){var D=0,O,W,J,te,re;if(y||(C=0),A.type==="audio"){S&&S.length?(J=S,S=new Uint8Array(J.byteLength+A.data.byteLength),S.set(J),S.set(A.data,J.byteLength)):S=A.data;for(var pe;D+7<S.length;){if(S[D]!==255||(S[D+1]&246)!==240){typeof pe!="number"&&(pe=D),D++;continue}if(typeof pe=="number"&&(this.skipWarn_(pe,D),pe=null),W=(~S[D+1]&1)*2,O=(S[D+3]&3)<<11|S[D+4]<<3|(S[D+5]&224)>>5,te=((S[D+6]&3)+1)*1024,re=te*Vn/Fl[(S[D+2]&60)>>>2],S.byteLength-D<O)break;this.trigger("data",{pts:A.pts+C*re,dts:A.dts+C*re,sampleCount:te,audioobjecttype:(S[D+2]>>>6&3)+1,channelcount:(S[D+2]&1)<<2|(S[D+3]&192)>>>6,samplerate:Fl[(S[D+2]&60)>>>2],samplingfrequencyindex:(S[D+2]&60)>>>2,samplesize:16,data:S.subarray(D+7+W,D+O)}),C++,D+=O}typeof pe=="number"&&(this.skipWarn_(pe,D),pe=null),S=S.subarray(D)}},this.flush=function(){C=0,this.trigger("done")},this.reset=function(){S=void 0,this.trigger("reset")},this.endTimeline=function(){S=void 0,this.trigger("endedtimeline")}},Ea.prototype=new Bl;var Aa=Ea,qr;qr=function(y){var S=y.byteLength,C=0,A=0;this.length=function(){return 8*S},this.bitsAvailable=function(){return 8*S+A},this.loadWord=function(){var D=y.byteLength-S,O=new Uint8Array(4),W=Math.min(4,S);if(W===0)throw new Error("no bytes available");O.set(y.subarray(D,D+W)),C=new DataView(O.buffer).getUint32(0),A=W*8,S-=W},this.skipBits=function(D){var O;A>D?(C<<=D,A-=D):(D-=A,O=Math.floor(D/8),D-=O*8,S-=O,this.loadWord(),C<<=D,A-=D)},this.readBits=function(D){var O=Math.min(A,D),W=C>>>32-O;return A-=O,A>0?C<<=O:S>0&&this.loadWord(),O=D-O,O>0?W<<O|this.readBits(O):W},this.skipLeadingZeros=function(){var D;for(D=0;D<A;++D)if((C&2147483648>>>D)!==0)return C<<=D,A-=D,D;return this.loadWord(),D+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.readUnsignedExpGolomb=function(){var D=this.skipLeadingZeros();return this.readBits(D+1)-1},this.readExpGolomb=function(){var D=this.readUnsignedExpGolomb();return 1&D?1+D>>>1:-1*(D>>>1)},this.readBoolean=function(){return this.readBits(1)===1},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord()};var gh=qr,Ul=t,yh=gh,ar,Us,$l;Us=function(){var y=0,S,C;Us.prototype.init.call(this),this.push=function(A){var D;C?(D=new Uint8Array(C.byteLength+A.data.byteLength),D.set(C),D.set(A.data,C.byteLength),C=D):C=A.data;for(var O=C.byteLength;y<O-3;y++)if(C[y+2]===1){S=y+5;break}for(;S<O;)switch(C[S]){case 0:if(C[S-1]!==0){S+=2;break}else if(C[S-2]!==0){S++;break}y+3!==S-2&&this.trigger("data",C.subarray(y+3,S-2));do S++;while(C[S]!==1&&S<O);y=S-2,S+=3;break;case 1:if(C[S-1]!==0||C[S-2]!==0){S+=3;break}this.trigger("data",C.subarray(y+3,S-2)),y=S-2,S+=3;break;default:S+=3;break}C=C.subarray(y),S-=y,y=0},this.reset=function(){C=null,y=0,this.trigger("reset")},this.flush=function(){C&&C.byteLength>3&&this.trigger("data",C.subarray(y+3)),C=null,y=0,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")}},Us.prototype=new Ul,$l={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},ar=function(){var y=new Us,S,C,A,D,O,W,J;ar.prototype.init.call(this),S=this,this.push=function(te){te.type==="video"&&(C=te.trackId,A=te.pts,D=te.dts,y.push(te))},y.on("data",function(te){var re={trackId:C,pts:A,dts:D,data:te,nalUnitTypeCode:te[0]&31};switch(re.nalUnitTypeCode){case 5:re.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:re.nalUnitType="sei_rbsp",re.escapedRBSP=O(te.subarray(1));break;case 7:re.nalUnitType="seq_parameter_set_rbsp",re.escapedRBSP=O(te.subarray(1)),re.config=W(re.escapedRBSP);break;case 8:re.nalUnitType="pic_parameter_set_rbsp";break;case 9:re.nalUnitType="access_unit_delimiter_rbsp";break}S.trigger("data",re)}),y.on("done",function(){S.trigger("done")}),y.on("partialdone",function(){S.trigger("partialdone")}),y.on("reset",function(){S.trigger("reset")}),y.on("endedtimeline",function(){S.trigger("endedtimeline")}),this.flush=function(){y.flush()},this.partialFlush=function(){y.partialFlush()},this.reset=function(){y.reset()},this.endTimeline=function(){y.endTimeline()},J=function(te,re){var pe=8,Le=8,ze,Re;for(ze=0;ze<te;ze++)Le!==0&&(Re=re.readExpGolomb(),Le=(pe+Re+256)%256),pe=Le===0?pe:Le},O=function(te){for(var re=te.byteLength,pe=[],Le=1,ze,Re;Le<re-2;)te[Le]===0&&te[Le+1]===0&&te[Le+2]===3?(pe.push(Le+2),Le+=2):Le++;if(pe.length===0)return te;ze=re-pe.length,Re=new Uint8Array(ze);var Qe=0;for(Le=0;Le<ze;Qe++,Le++)Qe===pe[0]&&(Qe++,pe.shift()),Re[Le]=te[Qe];return Re},W=function(te){var re=0,pe=0,Le=0,ze=0,Re,Qe,mt,Bi,ks,gr,Yo,di,Qr,Yn,yr,Yt=[1,1],wn,ns;if(Re=new yh(te),Qe=Re.readUnsignedByte(),Bi=Re.readUnsignedByte(),mt=Re.readUnsignedByte(),Re.skipUnsignedExpGolomb(),$l[Qe]&&(ks=Re.readUnsignedExpGolomb(),ks===3&&Re.skipBits(1),Re.skipUnsignedExpGolomb(),Re.skipUnsignedExpGolomb(),Re.skipBits(1),Re.readBoolean()))for(yr=ks!==3?8:12,ns=0;ns<yr;ns++)Re.readBoolean()&&(ns<6?J(16,Re):J(64,Re));if(Re.skipUnsignedExpGolomb(),gr=Re.readUnsignedExpGolomb(),gr===0)Re.readUnsignedExpGolomb();else if(gr===1)for(Re.skipBits(1),Re.skipExpGolomb(),Re.skipExpGolomb(),Yo=Re.readUnsignedExpGolomb(),ns=0;ns<Yo;ns++)Re.skipExpGolomb();if(Re.skipUnsignedExpGolomb(),Re.skipBits(1),di=Re.readUnsignedExpGolomb(),Qr=Re.readUnsignedExpGolomb(),Yn=Re.readBits(1),Yn===0&&Re.skipBits(1),Re.skipBits(1),Re.readBoolean()&&(re=Re.readUnsignedExpGolomb(),pe=Re.readUnsignedExpGolomb(),Le=Re.readUnsignedExpGolomb(),ze=Re.readUnsignedExpGolomb()),Re.readBoolean()&&Re.readBoolean()){switch(wn=Re.readUnsignedByte(),wn){case 1:Yt=[1,1];break;case 2:Yt=[12,11];break;case 3:Yt=[10,11];break;case 4:Yt=[16,11];break;case 5:Yt=[40,33];break;case 6:Yt=[24,11];break;case 7:Yt=[20,11];break;case 8:Yt=[32,11];break;case 9:Yt=[80,33];break;case 10:Yt=[18,11];break;case 11:Yt=[15,11];break;case 12:Yt=[64,33];break;case 13:Yt=[160,99];break;case 14:Yt=[4,3];break;case 15:Yt=[3,2];break;case 16:Yt=[2,1];break;case 255:{Yt=[Re.readUnsignedByte()<<8|Re.readUnsignedByte(),Re.readUnsignedByte()<<8|Re.readUnsignedByte()];break}}Yt&&Yt[0]/Yt[1]}return{profileIdc:Qe,levelIdc:mt,profileCompatibility:Bi,width:(di+1)*16-re*2-pe*2,height:(2-Yn)*(Qr+1)*16-Le*2-ze*2,sarRatio:Yt}}},ar.prototype=new Ul;var Ro={H264Stream:ar},or=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],jl=function(y,S){var C=y[S+6]<<21|y[S+7]<<14|y[S+8]<<7|y[S+9],A=y[S+5],D=(A&16)>>4;return C=C>=0?C:0,D?C+20:C+10},Oo=function(y,S){return y.length-S<10||y[S]!==73||y[S+1]!==68||y[S+2]!==51?S:(S+=jl(y,S),Oo(y,S))},vh=function(y){var S=Oo(y,0);return y.length>=S+2&&(y[S]&255)===255&&(y[S+1]&240)===240&&(y[S+1]&22)===16},Po=function(y){return y[0]<<21|y[1]<<14|y[2]<<7|y[3]},Hl=function(y,S,C){var A,D="";for(A=S;A<C;A++)D+="%"+("00"+y[A].toString(16)).slice(-2);return D},Th=function(y,S,C){return unescape(Hl(y,S,C))},bs=function(y,S){var C=(y[S+5]&224)>>5,A=y[S+4]<<3,D=y[S+3]&6144;return D|A|C},zr=function(y,S){return y[S]===73&&y[S+1]===68&&y[S+2]===51?"timed-metadata":y[S]&!0&&(y[S+1]&240)===240?"audio":null},Gl=function(y){for(var S=0;S+5<y.length;){if(y[S]!==255||(y[S+1]&246)!==240){S++;continue}return or[(y[S+2]&60)>>>2]}return null},Mo=function(y){var S,C,A,D;S=10,y[5]&64&&(S+=4,S+=Po(y.subarray(10,14)));do{if(C=Po(y.subarray(S+4,S+8)),C<1)return null;if(D=String.fromCharCode(y[S],y[S+1],y[S+2],y[S+3]),D==="PRIV"){A=y.subarray(S+10,S+C+10);for(var O=0;O<A.byteLength;O++)if(A[O]===0){var W=Th(A,0,O);if(W==="com.apple.streaming.transportStreamTimestamp"){var J=A.subarray(O+1),te=(J[3]&1)<<30|J[4]<<22|J[5]<<14|J[6]<<6|J[7]>>>2;return te*=4,te+=J[7]&3,te}break}}S+=10,S+=C}while(S<y.byteLength);return null},yc={isLikelyAacData:vh,parseId3TagSize:jl,parseAdtsSize:bs,parseType:zr,parseSampleRate:Gl,parseAacTimestamp:Mo},vc=t,Vl=yc,lr;lr=function(){var y=new Uint8Array,S=0;lr.prototype.init.call(this),this.setTimestamp=function(C){S=C},this.push=function(C){var A=0,D=0,O,W,J,te;for(y.length?(te=y.length,y=new Uint8Array(C.byteLength+te),y.set(y.subarray(0,te)),y.set(C,te)):y=C;y.length-D>=3;){if(y[D]===73&&y[D+1]===68&&y[D+2]===51){if(y.length-D<10||(A=Vl.parseId3TagSize(y,D),D+A>y.length))break;W={type:"timed-metadata",data:y.subarray(D,D+A)},this.trigger("data",W),D+=A;continue}else if((y[D]&255)===255&&(y[D+1]&240)===240){if(y.length-D<7||(A=Vl.parseAdtsSize(y,D),D+A>y.length))break;J={type:"audio",data:y.subarray(D,D+A),pts:S,dts:S},this.trigger("data",J),D+=A;continue}D++}O=y.length-D,O>0?y=y.subarray(D):y=new Uint8Array},this.reset=function(){y=new Uint8Array,this.trigger("reset")},this.endTimeline=function(){y=new Uint8Array,this.trigger("endedtimeline")}},lr.prototype=new vc;var ql=lr,bh=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],Km=bh,Ym=["width","height","profileIdc","levelIdc","profileCompatibility","sarRatio"],Wm=Ym,Ca=t,No=Ee,Bo=Xe,zl=Wi,on=se,qn=zm,Fo=Et,_h=Aa,Xm=Ro.H264Stream,Qm=ql,Zm=yc.isLikelyAacData,Tc=Et.ONE_SECOND_IN_TS,xh=Km,Sh=Wm,Kl,Da,Yl,Kr,Jm=function(y,S){S.stream=y,this.trigger("log",S)},Eh=function(y,S){for(var C=Object.keys(S),A=0;A<C.length;A++){var D=C[A];D==="headOfPipeline"||!S[D].on||S[D].on("log",Jm.bind(y,D))}},Ah=function(y,S){var C;if(y.length!==S.length)return!1;for(C=0;C<y.length;C++)if(y[C]!==S[C])return!1;return!0},Ch=function(y,S,C,A,D,O){var W=C-S,J=A-S,te=D-C;return{start:{dts:y,pts:y+W},end:{dts:y+J,pts:y+te},prependedContentDuration:O,baseMediaDecodeTime:y}};Da=function(y,S){var C=[],A,D=0,O=0,W=1/0;S=S||{},A=S.firstSequenceNumber||0,Da.prototype.init.call(this),this.push=function(J){on.collectDtsInfo(y,J),y&&xh.forEach(function(te){y[te]=J[te]}),C.push(J)},this.setEarliestDts=function(J){D=J},this.setVideoBaseMediaDecodeTime=function(J){W=J},this.setAudioAppendStart=function(J){O=J},this.flush=function(){var J,te,re,pe,Le,ze,Re;if(C.length===0){this.trigger("done","AudioSegmentStream");return}J=zl.trimAdtsFramesByEarliestDts(C,y,D),y.baseMediaDecodeTime=on.calculateTrackBaseMediaDecodeTime(y,S.keepOriginalTimestamps),Re=zl.prefixWithSilence(y,J,O,W),y.samples=zl.generateSampleTable(J),re=No.mdat(zl.concatenateFrameData(J)),C=[],te=No.moof(A,[y]),pe=new Uint8Array(te.byteLength+re.byteLength),A++,pe.set(te),pe.set(re,te.byteLength),on.clearDtsInfo(y),Le=Math.ceil(Tc*1024/y.samplerate),J.length&&(ze=J.length*Le,this.trigger("segmentTimingInfo",Ch(Fo.audioTsToVideoTs(y.baseMediaDecodeTime,y.samplerate),J[0].dts,J[0].pts,J[0].dts+ze,J[0].pts+ze,Re||0)),this.trigger("timingInfo",{start:J[0].pts,end:J[0].pts+ze})),this.trigger("data",{track:y,boxes:pe}),this.trigger("done","AudioSegmentStream")},this.reset=function(){on.clearDtsInfo(y),C=[],this.trigger("reset")}},Da.prototype=new Ca,Kl=function(y,S){var C,A=[],D=[],O,W;S=S||{},C=S.firstSequenceNumber||0,Kl.prototype.init.call(this),delete y.minPTS,this.gopCache_=[],this.push=function(J){on.collectDtsInfo(y,J),J.nalUnitType==="seq_parameter_set_rbsp"&&!O&&(O=J.config,y.sps=[J.data],Sh.forEach(function(te){y[te]=O[te]},this)),J.nalUnitType==="pic_parameter_set_rbsp"&&!W&&(W=J.data,y.pps=[J.data]),A.push(J)},this.flush=function(){for(var J,te,re,pe,Le,ze,Re=0,Qe,mt;A.length&&A[0].nalUnitType!=="access_unit_delimiter_rbsp";)A.shift();if(A.length===0){this.resetStream_(),this.trigger("done","VideoSegmentStream");return}if(J=Bo.groupNalsIntoFrames(A),re=Bo.groupFramesIntoGops(J),re[0][0].keyFrame||(te=this.getGopForFusion_(A[0],y),te?(Re=te.duration,re.unshift(te),re.byteLength+=te.byteLength,re.nalCount+=te.nalCount,re.pts=te.pts,re.dts=te.dts,re.duration+=te.duration):re=Bo.extendFirstKeyFrame(re)),D.length){var Bi;if(S.alignGopsAtEnd?Bi=this.alignGopsAtEnd_(re):Bi=this.alignGopsAtStart_(re),!Bi){this.gopCache_.unshift({gop:re.pop(),pps:y.pps,sps:y.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),A=[],this.resetStream_(),this.trigger("done","VideoSegmentStream");return}on.clearDtsInfo(y),re=Bi}on.collectDtsInfo(y,re),y.samples=Bo.generateSampleTable(re),Le=No.mdat(Bo.concatenateNalData(re)),y.baseMediaDecodeTime=on.calculateTrackBaseMediaDecodeTime(y,S.keepOriginalTimestamps),this.trigger("processedGopsInfo",re.map(function(ks){return{pts:ks.pts,dts:ks.dts,byteLength:ks.byteLength}})),Qe=re[0],mt=re[re.length-1],this.trigger("segmentTimingInfo",Ch(y.baseMediaDecodeTime,Qe.dts,Qe.pts,mt.dts+mt.duration,mt.pts+mt.duration,Re)),this.trigger("timingInfo",{start:re[0].pts,end:re[re.length-1].pts+re[re.length-1].duration}),this.gopCache_.unshift({gop:re.pop(),pps:y.pps,sps:y.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),A=[],this.trigger("baseMediaDecodeTime",y.baseMediaDecodeTime),this.trigger("timelineStartInfo",y.timelineStartInfo),pe=No.moof(C,[y]),ze=new Uint8Array(pe.byteLength+Le.byteLength),C++,ze.set(pe),ze.set(Le,pe.byteLength),this.trigger("data",{track:y,boxes:ze}),this.resetStream_(),this.trigger("done","VideoSegmentStream")},this.reset=function(){this.resetStream_(),A=[],this.gopCache_.length=0,D.length=0,this.trigger("reset")},this.resetStream_=function(){on.clearDtsInfo(y),O=void 0,W=void 0},this.getGopForFusion_=function(J){var te=45e3,re=1/0,pe,Le,ze,Re,Qe;for(Qe=0;Qe<this.gopCache_.length;Qe++)Re=this.gopCache_[Qe],ze=Re.gop,!(!(y.pps&&Ah(y.pps[0],Re.pps[0]))||!(y.sps&&Ah(y.sps[0],Re.sps[0])))&&(ze.dts<y.timelineStartInfo.dts||(pe=J.dts-ze.dts-ze.duration,pe>=-1e4&&pe<=te&&(!Le||re>pe)&&(Le=Re,re=pe)));return Le?Le.gop:null},this.alignGopsAtStart_=function(J){var te,re,pe,Le,ze,Re,Qe,mt;for(ze=J.byteLength,Re=J.nalCount,Qe=J.duration,te=re=0;te<D.length&&re<J.length&&(pe=D[te],Le=J[re],pe.pts!==Le.pts);){if(Le.pts>pe.pts){te++;continue}re++,ze-=Le.byteLength,Re-=Le.nalCount,Qe-=Le.duration}return re===0?J:re===J.length?null:(mt=J.slice(re),mt.byteLength=ze,mt.duration=Qe,mt.nalCount=Re,mt.pts=mt[0].pts,mt.dts=mt[0].dts,mt)},this.alignGopsAtEnd_=function(J){var te,re,pe,Le,ze,Re;for(te=D.length-1,re=J.length-1,ze=null,Re=!1;te>=0&&re>=0;){if(pe=D[te],Le=J[re],pe.pts===Le.pts){Re=!0;break}if(pe.pts>Le.pts){te--;continue}te===D.length-1&&(ze=re),re--}if(!Re&&ze===null)return null;var Qe;if(Re?Qe=re:Qe=ze,Qe===0)return J;var mt=J.slice(Qe),Bi=mt.reduce(function(ks,gr){return ks.byteLength+=gr.byteLength,ks.duration+=gr.duration,ks.nalCount+=gr.nalCount,ks},{byteLength:0,duration:0,nalCount:0});return mt.byteLength=Bi.byteLength,mt.duration=Bi.duration,mt.nalCount=Bi.nalCount,mt.pts=mt[0].pts,mt.dts=mt[0].dts,mt},this.alignGopsWith=function(J){D=J}},Kl.prototype=new Ca,Kr=function(y,S){this.numberOfTracks=0,this.metadataStream=S,y=y||{},typeof y.remux<"u"?this.remuxTracks=!!y.remux:this.remuxTracks=!0,typeof y.keepOriginalTimestamps=="boolean"?this.keepOriginalTimestamps=y.keepOriginalTimestamps:this.keepOriginalTimestamps=!1,this.pendingTracks=[],this.videoTrack=null,this.pendingBoxes=[],this.pendingCaptions=[],this.pendingMetadata=[],this.pendingBytes=0,this.emittedTracks=0,Kr.prototype.init.call(this),this.push=function(C){if(C.content||C.text)return this.pendingCaptions.push(C);if(C.frames)return this.pendingMetadata.push(C);this.pendingTracks.push(C.track),this.pendingBytes+=C.boxes.byteLength,C.track.type==="video"&&(this.videoTrack=C.track,this.pendingBoxes.push(C.boxes)),C.track.type==="audio"&&(this.audioTrack=C.track,this.pendingBoxes.unshift(C.boxes))}},Kr.prototype=new Ca,Kr.prototype.flush=function(y){var S=0,C={captions:[],captionStreams:{},metadata:[],info:{}},A,D,O,W=0,J;if(this.pendingTracks.length<this.numberOfTracks){if(y!=="VideoSegmentStream"&&y!=="AudioSegmentStream")return;if(this.remuxTracks)return;if(this.pendingTracks.length===0){this.emittedTracks++,this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0);return}}if(this.videoTrack?(W=this.videoTrack.timelineStartInfo.pts,Sh.forEach(function(te){C.info[te]=this.videoTrack[te]},this)):this.audioTrack&&(W=this.audioTrack.timelineStartInfo.pts,xh.forEach(function(te){C.info[te]=this.audioTrack[te]},this)),this.videoTrack||this.audioTrack){for(this.pendingTracks.length===1?C.type=this.pendingTracks[0].type:C.type="combined",this.emittedTracks+=this.pendingTracks.length,O=No.initSegment(this.pendingTracks),C.initSegment=new Uint8Array(O.byteLength),C.initSegment.set(O),C.data=new Uint8Array(this.pendingBytes),J=0;J<this.pendingBoxes.length;J++)C.data.set(this.pendingBoxes[J],S),S+=this.pendingBoxes[J].byteLength;for(J=0;J<this.pendingCaptions.length;J++)A=this.pendingCaptions[J],A.startTime=Fo.metadataTsToSeconds(A.startPts,W,this.keepOriginalTimestamps),A.endTime=Fo.metadataTsToSeconds(A.endPts,W,this.keepOriginalTimestamps),C.captionStreams[A.stream]=!0,C.captions.push(A);for(J=0;J<this.pendingMetadata.length;J++)D=this.pendingMetadata[J],D.cueTime=Fo.metadataTsToSeconds(D.pts,W,this.keepOriginalTimestamps),C.metadata.push(D);for(C.metadata.dispatchType=this.metadataStream.dispatchType,this.pendingTracks.length=0,this.videoTrack=null,this.pendingBoxes.length=0,this.pendingCaptions.length=0,this.pendingBytes=0,this.pendingMetadata.length=0,this.trigger("data",C),J=0;J<C.captions.length;J++)A=C.captions[J],this.trigger("caption",A);for(J=0;J<C.metadata.length;J++)D=C.metadata[J],this.trigger("id3Frame",D)}this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0)},Kr.prototype.setRemux=function(y){this.remuxTracks=y},Yl=function(y){var S=this,C=!0,A,D;Yl.prototype.init.call(this),y=y||{},this.baseMediaDecodeTime=y.baseMediaDecodeTime||0,this.transmuxPipeline_={},this.setupAacPipeline=function(){var O={};this.transmuxPipeline_=O,O.type="aac",O.metadataStream=new qn.MetadataStream,O.aacStream=new Qm,O.audioTimestampRolloverStream=new qn.TimestampRolloverStream("audio"),O.timedMetadataTimestampRolloverStream=new qn.TimestampRolloverStream("timed-metadata"),O.adtsStream=new _h,O.coalesceStream=new Kr(y,O.metadataStream),O.headOfPipeline=O.aacStream,O.aacStream.pipe(O.audioTimestampRolloverStream).pipe(O.adtsStream),O.aacStream.pipe(O.timedMetadataTimestampRolloverStream).pipe(O.metadataStream).pipe(O.coalesceStream),O.metadataStream.on("timestamp",function(W){O.aacStream.setTimestamp(W.timeStamp)}),O.aacStream.on("data",function(W){W.type!=="timed-metadata"&&W.type!=="audio"||O.audioSegmentStream||(D=D||{timelineStartInfo:{baseMediaDecodeTime:S.baseMediaDecodeTime},codec:"adts",type:"audio"},O.coalesceStream.numberOfTracks++,O.audioSegmentStream=new Da(D,y),O.audioSegmentStream.on("log",S.getLogTrigger_("audioSegmentStream")),O.audioSegmentStream.on("timingInfo",S.trigger.bind(S,"audioTimingInfo")),O.adtsStream.pipe(O.audioSegmentStream).pipe(O.coalesceStream),S.trigger("trackinfo",{hasAudio:!!D,hasVideo:!!A}))}),O.coalesceStream.on("data",this.trigger.bind(this,"data")),O.coalesceStream.on("done",this.trigger.bind(this,"done")),Eh(this,O)},this.setupTsPipeline=function(){var O={};this.transmuxPipeline_=O,O.type="ts",O.metadataStream=new qn.MetadataStream,O.packetStream=new qn.TransportPacketStream,O.parseStream=new qn.TransportParseStream,O.elementaryStream=new qn.ElementaryStream,O.timestampRolloverStream=new qn.TimestampRolloverStream,O.adtsStream=new _h,O.h264Stream=new Xm,O.captionStream=new qn.CaptionStream(y),O.coalesceStream=new Kr(y,O.metadataStream),O.headOfPipeline=O.packetStream,O.packetStream.pipe(O.parseStream).pipe(O.elementaryStream).pipe(O.timestampRolloverStream),O.timestampRolloverStream.pipe(O.h264Stream),O.timestampRolloverStream.pipe(O.adtsStream),O.timestampRolloverStream.pipe(O.metadataStream).pipe(O.coalesceStream),O.h264Stream.pipe(O.captionStream).pipe(O.coalesceStream),O.elementaryStream.on("data",function(W){var J;if(W.type==="metadata"){for(J=W.tracks.length;J--;)!A&&W.tracks[J].type==="video"?(A=W.tracks[J],A.timelineStartInfo.baseMediaDecodeTime=S.baseMediaDecodeTime):!D&&W.tracks[J].type==="audio"&&(D=W.tracks[J],D.timelineStartInfo.baseMediaDecodeTime=S.baseMediaDecodeTime);A&&!O.videoSegmentStream&&(O.coalesceStream.numberOfTracks++,O.videoSegmentStream=new Kl(A,y),O.videoSegmentStream.on("log",S.getLogTrigger_("videoSegmentStream")),O.videoSegmentStream.on("timelineStartInfo",function(te){D&&!y.keepOriginalTimestamps&&(D.timelineStartInfo=te,O.audioSegmentStream.setEarliestDts(te.dts-S.baseMediaDecodeTime))}),O.videoSegmentStream.on("processedGopsInfo",S.trigger.bind(S,"gopInfo")),O.videoSegmentStream.on("segmentTimingInfo",S.trigger.bind(S,"videoSegmentTimingInfo")),O.videoSegmentStream.on("baseMediaDecodeTime",function(te){D&&O.audioSegmentStream.setVideoBaseMediaDecodeTime(te)}),O.videoSegmentStream.on("timingInfo",S.trigger.bind(S,"videoTimingInfo")),O.h264Stream.pipe(O.videoSegmentStream).pipe(O.coalesceStream)),D&&!O.audioSegmentStream&&(O.coalesceStream.numberOfTracks++,O.audioSegmentStream=new Da(D,y),O.audioSegmentStream.on("log",S.getLogTrigger_("audioSegmentStream")),O.audioSegmentStream.on("timingInfo",S.trigger.bind(S,"audioTimingInfo")),O.audioSegmentStream.on("segmentTimingInfo",S.trigger.bind(S,"audioSegmentTimingInfo")),O.adtsStream.pipe(O.audioSegmentStream).pipe(O.coalesceStream)),S.trigger("trackinfo",{hasAudio:!!D,hasVideo:!!A})}}),O.coalesceStream.on("data",this.trigger.bind(this,"data")),O.coalesceStream.on("id3Frame",function(W){W.dispatchType=O.metadataStream.dispatchType,S.trigger("id3Frame",W)}),O.coalesceStream.on("caption",this.trigger.bind(this,"caption")),O.coalesceStream.on("done",this.trigger.bind(this,"done")),Eh(this,O)},this.setBaseMediaDecodeTime=function(O){var W=this.transmuxPipeline_;y.keepOriginalTimestamps||(this.baseMediaDecodeTime=O),D&&(D.timelineStartInfo.dts=void 0,D.timelineStartInfo.pts=void 0,on.clearDtsInfo(D),W.audioTimestampRolloverStream&&W.audioTimestampRolloverStream.discontinuity()),A&&(W.videoSegmentStream&&(W.videoSegmentStream.gopCache_=[]),A.timelineStartInfo.dts=void 0,A.timelineStartInfo.pts=void 0,on.clearDtsInfo(A),W.captionStream.reset()),W.timestampRolloverStream&&W.timestampRolloverStream.discontinuity()},this.setAudioAppendStart=function(O){D&&this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(O)},this.setRemux=function(O){var W=this.transmuxPipeline_;y.remux=O,W&&W.coalesceStream&&W.coalesceStream.setRemux(O)},this.alignGopsWith=function(O){A&&this.transmuxPipeline_.videoSegmentStream&&this.transmuxPipeline_.videoSegmentStream.alignGopsWith(O)},this.getLogTrigger_=function(O){var W=this;return function(J){J.stream=O,W.trigger("log",J)}},this.push=function(O){if(C){var W=Zm(O);W&&this.transmuxPipeline_.type!=="aac"?this.setupAacPipeline():!W&&this.transmuxPipeline_.type!=="ts"&&this.setupTsPipeline(),C=!1}this.transmuxPipeline_.headOfPipeline.push(O)},this.flush=function(){C=!0,this.transmuxPipeline_.headOfPipeline.flush()},this.endTimeline=function(){this.transmuxPipeline_.headOfPipeline.endTimeline()},this.reset=function(){this.transmuxPipeline_.headOfPipeline&&this.transmuxPipeline_.headOfPipeline.reset()},this.resetCaptions=function(){this.transmuxPipeline_.captionStream&&this.transmuxPipeline_.captionStream.reset()}},Yl.prototype=new Ca;var eg={Transmuxer:Yl},tg=function(y){return y>>>0},ig=function(y){return("00"+y.toString(16)).slice(-2)},wa={toUnsigned:tg,toHexString:ig},Uo=function(y){var S="";return S+=String.fromCharCode(y[0]),S+=String.fromCharCode(y[1]),S+=String.fromCharCode(y[2]),S+=String.fromCharCode(y[3]),S},Dh=Uo,wh=wa.toUnsigned,Lh=Dh,bc=function(y,S){var C=[],A,D,O,W,J;if(!S.length)return null;for(A=0;A<y.byteLength;)D=wh(y[A]<<24|y[A+1]<<16|y[A+2]<<8|y[A+3]),O=Lh(y.subarray(A+4,A+8)),W=D>1?A+D:y.byteLength,O===S[0]&&(S.length===1?C.push(y.subarray(A+8,W)):(J=bc(y.subarray(A+8,W),S.slice(1)),J.length&&(C=C.concat(J)))),A=W;return C},Wl=bc,Ih=wa.toUnsigned,La=r.getUint64,sg=function(y){var S={version:y[0],flags:new Uint8Array(y.subarray(1,4))};return S.version===1?S.baseMediaDecodeTime=La(y.subarray(4)):S.baseMediaDecodeTime=Ih(y[4]<<24|y[5]<<16|y[6]<<8|y[7]),S},_c=sg,ng=function(y){var S=new DataView(y.buffer,y.byteOffset,y.byteLength),C={version:y[0],flags:new Uint8Array(y.subarray(1,4)),trackId:S.getUint32(4)},A=C.flags[2]&1,D=C.flags[2]&2,O=C.flags[2]&8,W=C.flags[2]&16,J=C.flags[2]&32,te=C.flags[0]&65536,re=C.flags[0]&131072,pe;return pe=8,A&&(pe+=4,C.baseDataOffset=S.getUint32(12),pe+=4),D&&(C.sampleDescriptionIndex=S.getUint32(pe),pe+=4),O&&(C.defaultSampleDuration=S.getUint32(pe),pe+=4),W&&(C.defaultSampleSize=S.getUint32(pe),pe+=4),J&&(C.defaultSampleFlags=S.getUint32(pe)),te&&(C.durationIsEmpty=!0),!A&&re&&(C.baseDataOffsetIsMoof=!0),C},xc=ng,kh=function(y){return{isLeading:(y[0]&12)>>>2,dependsOn:y[0]&3,isDependedOn:(y[1]&192)>>>6,hasRedundancy:(y[1]&48)>>>4,paddingValue:(y[1]&14)>>>1,isNonSyncSample:y[1]&1,degradationPriority:y[2]<<8|y[3]}},$o=kh,Ia=$o,rg=function(y){var S={version:y[0],flags:new Uint8Array(y.subarray(1,4)),samples:[]},C=new DataView(y.buffer,y.byteOffset,y.byteLength),A=S.flags[2]&1,D=S.flags[2]&4,O=S.flags[1]&1,W=S.flags[1]&2,J=S.flags[1]&4,te=S.flags[1]&8,re=C.getUint32(4),pe=8,Le;for(A&&(S.dataOffset=C.getInt32(pe),pe+=4),D&&re&&(Le={flags:Ia(y.subarray(pe,pe+4))},pe+=4,O&&(Le.duration=C.getUint32(pe),pe+=4),W&&(Le.size=C.getUint32(pe),pe+=4),te&&(S.version===1?Le.compositionTimeOffset=C.getInt32(pe):Le.compositionTimeOffset=C.getUint32(pe),pe+=4),S.samples.push(Le),re--);re--;)Le={},O&&(Le.duration=C.getUint32(pe),pe+=4),W&&(Le.size=C.getUint32(pe),pe+=4),J&&(Le.flags=Ia(y.subarray(pe,pe+4)),pe+=4),te&&(S.version===1?Le.compositionTimeOffset=C.getInt32(pe):Le.compositionTimeOffset=C.getUint32(pe),pe+=4),S.samples.push(Le);return S},jo=rg,Sc={tfdt:_c,trun:jo},Ec={parseTfdt:Sc.tfdt,parseTrun:Sc.trun},Ac=function(y){for(var S=0,C=String.fromCharCode(y[S]),A="";C!=="\0";)A+=C,S++,C=String.fromCharCode(y[S]);return A+=C,A},Cc={uint8ToCString:Ac},Ho=Cc.uint8ToCString,Rh=r.getUint64,Oh=function(y){var S=4,C=y[0],A,D,O,W,J,te,re,pe;if(C===0){A=Ho(y.subarray(S)),S+=A.length,D=Ho(y.subarray(S)),S+=D.length;var Le=new DataView(y.buffer);O=Le.getUint32(S),S+=4,J=Le.getUint32(S),S+=4,te=Le.getUint32(S),S+=4,re=Le.getUint32(S),S+=4}else if(C===1){var Le=new DataView(y.buffer);O=Le.getUint32(S),S+=4,W=Rh(y.subarray(S)),S+=8,te=Le.getUint32(S),S+=4,re=Le.getUint32(S),S+=4,A=Ho(y.subarray(S)),S+=A.length,D=Ho(y.subarray(S)),S+=D.length}pe=new Uint8Array(y.subarray(S,y.byteLength));var ze={scheme_id_uri:A,value:D,timescale:O||1,presentation_time:W,presentation_time_delta:J,event_duration:te,id:re,message_data:pe};return og(C,ze)?ze:void 0},ag=function(y,S,C,A){return y||y===0?y/S:A+C/S},og=function(y,S){var C=S.scheme_id_uri!=="\0",A=y===0&&Ph(S.presentation_time_delta)&&C,D=y===1&&Ph(S.presentation_time)&&C;return!(y>1)&&A||D},Ph=function(y){return y!==void 0||y!==null},lg={parseEmsgBox:Oh,scaleTime:ag},Go;typeof window<"u"?Go=window:typeof s<"u"?Go=s:typeof self<"u"?Go=self:Go={};var _s=Go,ur=wa.toUnsigned,ka=wa.toHexString,yi=Wl,Yr=Dh,Xl=lg,Dc=xc,ug=jo,Ra=_c,wc=r.getUint64,Oa,Ql,Lc,cr,Wr,Vo,Ic,zn=_s,Mh=kl.parseId3Frames;Oa=function(y){var S={},C=yi(y,["moov","trak"]);return C.reduce(function(A,D){var O,W,J,te,re;return O=yi(D,["tkhd"])[0],!O||(W=O[0],J=W===0?12:20,te=ur(O[J]<<24|O[J+1]<<16|O[J+2]<<8|O[J+3]),re=yi(D,["mdia","mdhd"])[0],!re)?null:(W=re[0],J=W===0?12:20,A[te]=ur(re[J]<<24|re[J+1]<<16|re[J+2]<<8|re[J+3]),A)},S)},Ql=function(y,S){var C;C=yi(S,["moof","traf"]);var A=C.reduce(function(D,O){var W=yi(O,["tfhd"])[0],J=ur(W[4]<<24|W[5]<<16|W[6]<<8|W[7]),te=y[J]||9e4,re=yi(O,["tfdt"])[0],pe=new DataView(re.buffer,re.byteOffset,re.byteLength),Le;re[0]===1?Le=wc(re.subarray(4,12)):Le=pe.getUint32(4);let ze;return typeof Le=="bigint"?ze=Le/zn.BigInt(te):typeof Le=="number"&&!isNaN(Le)&&(ze=Le/te),ze<Number.MAX_SAFE_INTEGER&&(ze=Number(ze)),ze<D&&(D=ze),D},1/0);return typeof A=="bigint"||isFinite(A)?A:0},Lc=function(y,S){var C=yi(S,["moof","traf"]),A=0,D=0,O;if(C&&C.length){var W=yi(C[0],["tfhd"])[0],J=yi(C[0],["trun"])[0],te=yi(C[0],["tfdt"])[0];if(W){var re=Dc(W);O=re.trackId}if(te){var pe=Ra(te);A=pe.baseMediaDecodeTime}if(J){var Le=ug(J);Le.samples&&Le.samples.length&&(D=Le.samples[0].compositionTimeOffset||0)}}var ze=y[O]||9e4;typeof A=="bigint"&&(D=zn.BigInt(D),ze=zn.BigInt(ze));var Re=(A+D)/ze;return typeof Re=="bigint"&&Re<Number.MAX_SAFE_INTEGER&&(Re=Number(Re)),Re},cr=function(y){var S=yi(y,["moov","trak"]),C=[];return S.forEach(function(A){var D=yi(A,["mdia","hdlr"]),O=yi(A,["tkhd"]);D.forEach(function(W,J){var te=Yr(W.subarray(8,12)),re=O[J],pe,Le,ze;te==="vide"&&(pe=new DataView(re.buffer,re.byteOffset,re.byteLength),Le=pe.getUint8(0),ze=Le===0?pe.getUint32(12):pe.getUint32(20),C.push(ze))})}),C},Vo=function(y){var S=y[0],C=S===0?12:20;return ur(y[C]<<24|y[C+1]<<16|y[C+2]<<8|y[C+3])},Wr=function(y){var S=yi(y,["moov","trak"]),C=[];return S.forEach(function(A){var D={},O=yi(A,["tkhd"])[0],W,J;O&&(W=new DataView(O.buffer,O.byteOffset,O.byteLength),J=W.getUint8(0),D.id=J===0?W.getUint32(12):W.getUint32(20));var te=yi(A,["mdia","hdlr"])[0];if(te){var re=Yr(te.subarray(8,12));re==="vide"?D.type="video":re==="soun"?D.type="audio":D.type=re}var pe=yi(A,["mdia","minf","stbl","stsd"])[0];if(pe){var Le=pe.subarray(8);D.codec=Yr(Le.subarray(4,8));var ze=yi(Le,[D.codec])[0],Re,Qe;ze&&(/^[asm]vc[1-9]$/i.test(D.codec)?(Re=ze.subarray(78),Qe=Yr(Re.subarray(4,8)),Qe==="avcC"&&Re.length>11?(D.codec+=".",D.codec+=ka(Re[9]),D.codec+=ka(Re[10]),D.codec+=ka(Re[11])):D.codec="avc1.4d400d"):/^mp4[a,v]$/i.test(D.codec)?(Re=ze.subarray(28),Qe=Yr(Re.subarray(4,8)),Qe==="esds"&&Re.length>20&&Re[19]!==0?(D.codec+="."+ka(Re[19]),D.codec+="."+ka(Re[20]>>>2&63).replace(/^0/,"")):D.codec="mp4a.40.2"):D.codec=D.codec.toLowerCase())}var mt=yi(A,["mdia","mdhd"])[0];mt&&(D.timescale=Vo(mt)),C.push(D)}),C},Ic=function(y,S=0){var C=yi(y,["emsg"]);return C.map(A=>{var D=Xl.parseEmsgBox(new Uint8Array(A)),O=Mh(D.message_data);return{cueTime:Xl.scaleTime(D.presentation_time,D.timescale,D.presentation_time_delta,S),duration:Xl.scaleTime(D.event_duration,D.timescale),frames:O}})};var Pa={findBox:yi,parseType:Yr,timescale:Oa,startTime:Ql,compositionStartTime:Lc,videoTrackIds:cr,tracks:Wr,getTimescaleFromMediaHeader:Vo,getEmsgID3:Ic};const{parseTrun:Nh}=Ec,{findBox:Bh}=Pa;var Fh=_s,cg=function(y){var S=Bh(y,["moof","traf"]),C=Bh(y,["mdat"]),A=[];return C.forEach(function(D,O){var W=S[O];A.push({mdat:D,traf:W})}),A},Uh=function(y,S,C){var A=S,D=C.defaultSampleDuration||0,O=C.defaultSampleSize||0,W=C.trackId,J=[];return y.forEach(function(te){var re=Nh(te),pe=re.samples;pe.forEach(function(Le){Le.duration===void 0&&(Le.duration=D),Le.size===void 0&&(Le.size=O),Le.trackId=W,Le.dts=A,Le.compositionTimeOffset===void 0&&(Le.compositionTimeOffset=0),typeof A=="bigint"?(Le.pts=A+Fh.BigInt(Le.compositionTimeOffset),A+=Fh.BigInt(Le.duration)):(Le.pts=A+Le.compositionTimeOffset,A+=Le.duration)}),J=J.concat(pe)}),J},kc={getMdatTrafPairs:cg,parseSamples:Uh},Rc=ut.discardEmulationPreventionBytes,ln=Hr.CaptionStream,Ma=Wl,$s=_c,Na=xc,{getMdatTrafPairs:Oc,parseSamples:Zl}=kc,Jl=function(y,S){for(var C=y,A=0;A<S.length;A++){var D=S[A];if(C<D.size)return D;C-=D.size}return null},Pc=function(y,S,C){var A=new DataView(y.buffer,y.byteOffset,y.byteLength),D={logs:[],seiNals:[]},O,W,J,te;for(W=0;W+4<y.length;W+=J)if(J=A.getUint32(W),W+=4,!(J<=0))switch(y[W]&31){case 6:var re=y.subarray(W+1,W+1+J),pe=Jl(W,S);if(O={nalUnitType:"sei_rbsp",size:J,data:re,escapedRBSP:Rc(re),trackId:C},pe)O.pts=pe.pts,O.dts=pe.dts,te=pe;else if(te)O.pts=te.pts,O.dts=te.dts;else{D.logs.push({level:"warn",message:"We've encountered a nal unit without data at "+W+" for trackId "+C+". See mux.js#223."});break}D.seiNals.push(O);break}return D},Xr=function(y,S){var C={},A=Oc(y);return A.forEach(function(D){var O=D.mdat,W=D.traf,J=Ma(W,["tfhd"]),te=Na(J[0]),re=te.trackId,pe=Ma(W,["tfdt"]),Le=pe.length>0?$s(pe[0]).baseMediaDecodeTime:0,ze=Ma(W,["trun"]),Re,Qe;S===re&&ze.length>0&&(Re=Zl(ze,Le,te),Qe=Pc(O,Re,re),C[re]||(C[re]={seiNals:[],logs:[]}),C[re].seiNals=C[re].seiNals.concat(Qe.seiNals),C[re].logs=C[re].logs.concat(Qe.logs))}),C},$h=function(y,S,C){var A;if(S===null)return null;A=Xr(y,S);var D=A[S]||{};return{seiNals:D.seiNals,logs:D.logs,timescale:C}},eu=function(){var y=!1,S,C,A,D,O,W;this.isInitialized=function(){return y},this.init=function(J){S=new ln,y=!0,W=J?J.isPartial:!1,S.on("data",function(te){te.startTime=te.startPts/D,te.endTime=te.endPts/D,O.captions.push(te),O.captionStreams[te.stream]=!0}),S.on("log",function(te){O.logs.push(te)})},this.isNewInit=function(J,te){return J&&J.length===0||te&&typeof te=="object"&&Object.keys(te).length===0?!1:A!==J[0]||D!==te[A]},this.parse=function(J,te,re){var pe;if(this.isInitialized()){if(!te||!re)return null;if(this.isNewInit(te,re))A=te[0],D=re[A];else if(A===null||!D)return C.push(J),null}else return null;for(;C.length>0;){var Le=C.shift();this.parse(Le,te,re)}return pe=$h(J,A,D),pe&&pe.logs&&(O.logs=O.logs.concat(pe.logs)),pe===null||!pe.seiNals?O.logs.length?{logs:O.logs,captions:[],captionStreams:[]}:null:(this.pushNals(pe.seiNals),this.flushStream(),O)},this.pushNals=function(J){if(!this.isInitialized()||!J||J.length===0)return null;J.forEach(function(te){S.push(te)})},this.flushStream=function(){if(!this.isInitialized())return null;W?S.partialFlush():S.flush()},this.clearParsedCaptions=function(){O.captions=[],O.captionStreams={},O.logs=[]},this.resetCaptionStream=function(){if(!this.isInitialized())return null;S.reset()},this.clearAllCaptions=function(){this.clearParsedCaptions(),this.resetCaptionStream()},this.reset=function(){C=[],A=null,D=null,O?this.clearParsedCaptions():O={captions:[],captionStreams:{},logs:[]},this.resetCaptionStream()},this.reset()},Ba=eu;const{parseTfdt:dg}=Ec,Di=Wl,{getTimescaleFromMediaHeader:Mc}=Pa,{parseSamples:Kn,getMdatTrafPairs:jh}=kc;var dr=function(){let y=9e4;this.init=function(S){const C=Di(S,["moov","trak","mdia","mdhd"])[0];C&&(y=Mc(C))},this.parseSegment=function(S){const C=[],A=jh(S);let D=0;return A.forEach(function(O){const W=O.mdat,J=O.traf,te=Di(J,["tfdt"])[0],re=Di(J,["tfhd"])[0],pe=Di(J,["trun"]);if(te&&(D=dg(te).baseMediaDecodeTime),pe.length&&re){const Le=Kn(pe,D,re);let ze=0;Le.forEach(function(Re){const Qe="utf-8",mt=new TextDecoder(Qe),Bi=W.slice(ze,ze+Re.size);if(Di(Bi,["vtte"])[0]){ze+=Re.size;return}Di(Bi,["vttc"]).forEach(function(Yo){const di=Di(Yo,["payl"])[0],Qr=Di(Yo,["sttg"])[0],Yn=Re.pts/y,yr=(Re.pts+Re.duration)/y;let Yt,wn;if(di)try{Yt=mt.decode(di)}catch(ns){console.error(ns)}if(Qr)try{wn=mt.decode(Qr)}catch(ns){console.error(ns)}Re.duration&&Yt&&C.push({cueText:Yt,start:Yn,end:yr,settings:wn})}),ze+=Re.size})}}),C}},qo=Hn,Bc=function(y){var S=y[1]&31;return S<<=8,S|=y[2],S},Fa=function(y){return!!(y[1]&64)},zo=function(y){var S=0;return(y[3]&48)>>>4>1&&(S+=y[4]+1),S},js=function(y,S){var C=Bc(y);return C===0?"pat":C===S?"pmt":S?"pes":null},Ua=function(y){var S=Fa(y),C=4+zo(y);return S&&(C+=y[C]+1),(y[C+10]&31)<<8|y[C+11]},$a=function(y){var S={},C=Fa(y),A=4+zo(y);if(C&&(A+=y[A]+1),!!(y[A+5]&1)){var D,O,W;D=(y[A+1]&15)<<8|y[A+2],O=3+D-4,W=(y[A+10]&15)<<8|y[A+11];for(var J=12+W;J<O;){var te=A+J;S[(y[te+1]&31)<<8|y[te+2]]=y[te],J+=((y[te+3]&15)<<8|y[te+4])+5}return S}},tu=function(y,S){var C=Bc(y),A=S[C];switch(A){case qo.H264_STREAM_TYPE:return"video";case qo.ADTS_STREAM_TYPE:return"audio";case qo.METADATA_STREAM_TYPE:return"timed-metadata";default:return null}},Ko=function(y){var S=Fa(y);if(!S)return null;var C=4+zo(y);if(C>=y.byteLength)return null;var A=null,D;return D=y[C+7],D&192&&(A={},A.pts=(y[C+9]&14)<<27|(y[C+10]&255)<<20|(y[C+11]&254)<<12|(y[C+12]&255)<<5|(y[C+13]&254)>>>3,A.pts*=4,A.pts+=(y[C+13]&6)>>>1,A.dts=A.pts,D&64&&(A.dts=(y[C+14]&14)<<27|(y[C+15]&255)<<20|(y[C+16]&254)<<12|(y[C+17]&255)<<5|(y[C+18]&254)>>>3,A.dts*=4,A.dts+=(y[C+18]&6)>>>1)),A},xs=function(y){switch(y){case 5:return"slice_layer_without_partitioning_rbsp_idr";case 6:return"sei_rbsp";case 7:return"seq_parameter_set_rbsp";case 8:return"pic_parameter_set_rbsp";case 9:return"access_unit_delimiter_rbsp";default:return null}},Hs=function(y){for(var S=4+zo(y),C=y.subarray(S),A=0,D=0,O=!1,W;D<C.byteLength-3;D++)if(C[D+2]===1){A=D+5;break}for(;A<C.byteLength;)switch(C[A]){case 0:if(C[A-1]!==0){A+=2;break}else if(C[A-2]!==0){A++;break}D+3!==A-2&&(W=xs(C[D+3]&31),W==="slice_layer_without_partitioning_rbsp_idr"&&(O=!0));do A++;while(C[A]!==1&&A<C.length);D=A-2,A+=3;break;case 1:if(C[A-1]!==0||C[A-2]!==0){A+=3;break}W=xs(C[D+3]&31),W==="slice_layer_without_partitioning_rbsp_idr"&&(O=!0),D=A-2,A+=3;break;default:A+=3;break}return C=C.subarray(D),A-=D,D=0,C&&C.byteLength>3&&(W=xs(C[D+3]&31),W==="slice_layer_without_partitioning_rbsp_idr"&&(O=!0)),O},hr={parseType:js,parsePat:Ua,parsePmt:$a,parsePayloadUnitStartIndicator:Fa,parsePesType:tu,parsePesTime:Ko,videoPacketContainsKeyFrame:Hs},un=Hn,ds=Gr.handleRollover,Ct={};Ct.ts=hr,Ct.aac=yc;var fr=Et.ONE_SECOND_IN_TS,Xi=188,Gs=71,Hh=function(y,S){for(var C=0,A=Xi,D,O;A<y.byteLength;){if(y[C]===Gs&&y[A]===Gs){switch(D=y.subarray(C,A),O=Ct.ts.parseType(D,S.pid),O){case"pat":S.pid=Ct.ts.parsePat(D);break;case"pmt":var W=Ct.ts.parsePmt(D);S.table=S.table||{},Object.keys(W).forEach(function(J){S.table[J]=W[J]});break}C+=Xi,A+=Xi;continue}C++,A++}},Vi=function(y,S,C){for(var A=0,D=Xi,O,W,J,te,re,pe=!1;D<=y.byteLength;){if(y[A]===Gs&&(y[D]===Gs||D===y.byteLength)){if(O=y.subarray(A,D),W=Ct.ts.parseType(O,S.pid),W==="pes"&&(J=Ct.ts.parsePesType(O,S.table),te=Ct.ts.parsePayloadUnitStartIndicator(O),J==="audio"&&te&&(re=Ct.ts.parsePesTime(O),re&&(re.type="audio",C.audio.push(re),pe=!0))),pe)break;A+=Xi,D+=Xi;continue}A++,D++}for(D=y.byteLength,A=D-Xi,pe=!1;A>=0;){if(y[A]===Gs&&(y[D]===Gs||D===y.byteLength)){if(O=y.subarray(A,D),W=Ct.ts.parseType(O,S.pid),W==="pes"&&(J=Ct.ts.parsePesType(O,S.table),te=Ct.ts.parsePayloadUnitStartIndicator(O),J==="audio"&&te&&(re=Ct.ts.parsePesTime(O),re&&(re.type="audio",C.audio.push(re),pe=!0))),pe)break;A-=Xi,D-=Xi;continue}A--,D--}},ri=function(y,S,C){for(var A=0,D=Xi,O,W,J,te,re,pe,Le,ze,Re=!1,Qe={data:[],size:0};D<y.byteLength;){if(y[A]===Gs&&y[D]===Gs){switch(O=y.subarray(A,D),W=Ct.ts.parseType(O,S.pid),W){case"pes":if(J=Ct.ts.parsePesType(O,S.table),te=Ct.ts.parsePayloadUnitStartIndicator(O),J==="video"&&(te&&!Re&&(re=Ct.ts.parsePesTime(O),re&&(re.type="video",C.video.push(re),Re=!0)),!C.firstKeyFrame)){if(te&&Qe.size!==0){for(pe=new Uint8Array(Qe.size),Le=0;Qe.data.length;)ze=Qe.data.shift(),pe.set(ze,Le),Le+=ze.byteLength;if(Ct.ts.videoPacketContainsKeyFrame(pe)){var mt=Ct.ts.parsePesTime(pe);mt?(C.firstKeyFrame=mt,C.firstKeyFrame.type="video"):console.warn("Failed to extract PTS/DTS from PES at first keyframe. This could be an unusual TS segment, or else mux.js did not parse your TS segment correctly. If you know your TS segments do contain PTS/DTS on keyframes please file a bug report! You can try ffprobe to double check for yourself.")}Qe.size=0}Qe.data.push(O),Qe.size+=O.byteLength}break}if(Re&&C.firstKeyFrame)break;A+=Xi,D+=Xi;continue}A++,D++}for(D=y.byteLength,A=D-Xi,Re=!1;A>=0;){if(y[A]===Gs&&y[D]===Gs){if(O=y.subarray(A,D),W=Ct.ts.parseType(O,S.pid),W==="pes"&&(J=Ct.ts.parsePesType(O,S.table),te=Ct.ts.parsePayloadUnitStartIndicator(O),J==="video"&&te&&(re=Ct.ts.parsePesTime(O),re&&(re.type="video",C.video.push(re),Re=!0))),Re)break;A-=Xi,D-=Xi;continue}A--,D--}},Rt=function(y,S){if(y.audio&&y.audio.length){var C=S;(typeof C>"u"||isNaN(C))&&(C=y.audio[0].dts),y.audio.forEach(function(O){O.dts=ds(O.dts,C),O.pts=ds(O.pts,C),O.dtsTime=O.dts/fr,O.ptsTime=O.pts/fr})}if(y.video&&y.video.length){var A=S;if((typeof A>"u"||isNaN(A))&&(A=y.video[0].dts),y.video.forEach(function(O){O.dts=ds(O.dts,A),O.pts=ds(O.pts,A),O.dtsTime=O.dts/fr,O.ptsTime=O.pts/fr}),y.firstKeyFrame){var D=y.firstKeyFrame;D.dts=ds(D.dts,A),D.pts=ds(D.pts,A),D.dtsTime=D.dts/fr,D.ptsTime=D.pts/fr}}},pr=function(y){for(var S=!1,C=0,A=null,D=null,O=0,W=0,J;y.length-W>=3;){var te=Ct.aac.parseType(y,W);switch(te){case"timed-metadata":if(y.length-W<10){S=!0;break}if(O=Ct.aac.parseId3TagSize(y,W),O>y.length){S=!0;break}D===null&&(J=y.subarray(W,W+O),D=Ct.aac.parseAacTimestamp(J)),W+=O;break;case"audio":if(y.length-W<7){S=!0;break}if(O=Ct.aac.parseAdtsSize(y,W),O>y.length){S=!0;break}A===null&&(J=y.subarray(W,W+O),A=Ct.aac.parseSampleRate(J)),C++,W+=O;break;default:W++;break}if(S)return null}if(A===null||D===null)return null;var re=fr/A,pe={audio:[{type:"audio",dts:D,pts:D},{type:"audio",dts:D+C*1024*re,pts:D+C*1024*re}]};return pe},Vs=function(y){var S={pid:null,table:null},C={};Hh(y,S);for(var A in S.table)if(S.table.hasOwnProperty(A)){var D=S.table[A];switch(D){case un.H264_STREAM_TYPE:C.video=[],ri(y,S,C),C.video.length===0&&delete C.video;break;case un.ADTS_STREAM_TYPE:C.audio=[],Vi(y,S,C),C.audio.length===0&&delete C.audio;break}}return C},Fc=function(y,S){var C=Ct.aac.isLikelyAacData(y),A;return C?A=pr(y):A=Vs(y),!A||!A.audio&&!A.video?null:(Rt(A,S),A)},mr={inspect:Fc,parseAudioPes_:Vi};const Gh=function(y,S){S.on("data",function(C){const A=C.initSegment;C.initSegment={data:A.buffer,byteOffset:A.byteOffset,byteLength:A.byteLength};const D=C.data;C.data=D.buffer,y.postMessage({action:"data",segment:C,byteOffset:D.byteOffset,byteLength:D.byteLength},[C.data])}),S.on("done",function(C){y.postMessage({action:"done"})}),S.on("gopInfo",function(C){y.postMessage({action:"gopInfo",gopInfo:C})}),S.on("videoSegmentTimingInfo",function(C){const A={start:{decode:Et.videoTsToSeconds(C.start.dts),presentation:Et.videoTsToSeconds(C.start.pts)},end:{decode:Et.videoTsToSeconds(C.end.dts),presentation:Et.videoTsToSeconds(C.end.pts)},baseMediaDecodeTime:Et.videoTsToSeconds(C.baseMediaDecodeTime)};C.prependedContentDuration&&(A.prependedContentDuration=Et.videoTsToSeconds(C.prependedContentDuration)),y.postMessage({action:"videoSegmentTimingInfo",videoSegmentTimingInfo:A})}),S.on("audioSegmentTimingInfo",function(C){const A={start:{decode:Et.videoTsToSeconds(C.start.dts),presentation:Et.videoTsToSeconds(C.start.pts)},end:{decode:Et.videoTsToSeconds(C.end.dts),presentation:Et.videoTsToSeconds(C.end.pts)},baseMediaDecodeTime:Et.videoTsToSeconds(C.baseMediaDecodeTime)};C.prependedContentDuration&&(A.prependedContentDuration=Et.videoTsToSeconds(C.prependedContentDuration)),y.postMessage({action:"audioSegmentTimingInfo",audioSegmentTimingInfo:A})}),S.on("id3Frame",function(C){y.postMessage({action:"id3Frame",id3Frame:C})}),S.on("caption",function(C){y.postMessage({action:"caption",caption:C})}),S.on("trackinfo",function(C){y.postMessage({action:"trackinfo",trackInfo:C})}),S.on("audioTimingInfo",function(C){y.postMessage({action:"audioTimingInfo",audioTimingInfo:{start:Et.videoTsToSeconds(C.start),end:Et.videoTsToSeconds(C.end)}})}),S.on("videoTimingInfo",function(C){y.postMessage({action:"videoTimingInfo",videoTimingInfo:{start:Et.videoTsToSeconds(C.start),end:Et.videoTsToSeconds(C.end)}})}),S.on("log",function(C){y.postMessage({action:"log",log:C})})};class Uc{constructor(S,C){this.options=C||{},this.self=S,this.init()}init(){this.transmuxer&&this.transmuxer.dispose(),this.transmuxer=new eg.Transmuxer(this.options),Gh(this.self,this.transmuxer)}pushMp4Captions(S){this.captionParser||(this.captionParser=new Ba,this.captionParser.init());const C=new Uint8Array(S.data,S.byteOffset,S.byteLength),A=this.captionParser.parse(C,S.trackIds,S.timescales);this.self.postMessage({action:"mp4Captions",captions:A&&A.captions||[],logs:A&&A.logs||[],data:C.buffer},[C.buffer])}initMp4WebVttParser(S){this.webVttParser||(this.webVttParser=new dr);const C=new Uint8Array(S.data,S.byteOffset,S.byteLength);this.webVttParser.init(C)}getMp4WebVttText(S){this.webVttParser||(this.webVttParser=new dr);const C=new Uint8Array(S.data,S.byteOffset,S.byteLength),A=this.webVttParser.parseSegment(C);this.self.postMessage({action:"getMp4WebVttText",mp4VttCues:A||[],data:C.buffer},[C.buffer])}probeMp4StartTime({timescales:S,data:C}){const A=Pa.startTime(S,C);this.self.postMessage({action:"probeMp4StartTime",startTime:A,data:C},[C.buffer])}probeMp4Tracks({data:S}){const C=Pa.tracks(S);this.self.postMessage({action:"probeMp4Tracks",tracks:C,data:S},[S.buffer])}probeEmsgID3({data:S,offset:C}){const A=Pa.getEmsgID3(S,C);this.self.postMessage({action:"probeEmsgID3",id3Frames:A,emsgData:S},[S.buffer])}probeTs({data:S,baseStartTime:C}){const A=typeof C=="number"&&!isNaN(C)?C*Et.ONE_SECOND_IN_TS:void 0,D=mr.inspect(S,A);let O=null;D&&(O={hasVideo:D.video&&D.video.length===2||!1,hasAudio:D.audio&&D.audio.length===2||!1},O.hasVideo&&(O.videoStart=D.video[0].ptsTime),O.hasAudio&&(O.audioStart=D.audio[0].ptsTime)),this.self.postMessage({action:"probeTs",result:O,data:S},[S.buffer])}clearAllMp4Captions(){this.captionParser&&this.captionParser.clearAllCaptions()}clearParsedMp4Captions(){this.captionParser&&this.captionParser.clearParsedCaptions()}push(S){const C=new Uint8Array(S.data,S.byteOffset,S.byteLength);this.transmuxer.push(C)}reset(){this.transmuxer.reset()}setTimestampOffset(S){const C=S.timestampOffset||0;this.transmuxer.setBaseMediaDecodeTime(Math.round(Et.secondsToVideoTs(C)))}setAudioAppendStart(S){this.transmuxer.setAudioAppendStart(Math.ceil(Et.secondsToVideoTs(S.appendStart)))}setRemux(S){this.transmuxer.setRemux(S.remux)}flush(S){this.transmuxer.flush(),self.postMessage({action:"done",type:"transmuxed"})}endTimeline(){this.transmuxer.endTimeline(),self.postMessage({action:"endedtimeline",type:"transmuxed"})}alignGopsWith(S){this.transmuxer.alignGopsWith(S.gopsToAlignWith.slice())}}self.onmessage=function(y){if(y.data.action==="init"&&y.data.options){this.messageHandlers=new Uc(self,y.data.options);return}this.messageHandlers||(this.messageHandlers=new Uc(self)),y.data&&y.data.action&&y.data.action!=="init"&&this.messageHandlers[y.data.action]&&this.messageHandlers[y.data.action](y.data)}}));var M5=FD(P5);const N5=(s,e,t)=>{const{type:i,initSegment:n,captions:r,captionStreams:o,metadata:u,videoFrameDtsTime:c,videoFramePtsTime:d}=s.data.segment;e.buffer.push({captions:r,captionStreams:o,metadata:u});const f=s.data.segment.boxes||{data:s.data.segment.data},m={type:i,data:new Uint8Array(f.data,f.data.byteOffset,f.data.byteLength),initSegment:new Uint8Array(n.data,n.byteOffset,n.byteLength)};typeof c<"u"&&(m.videoFrameDtsTime=c),typeof d<"u"&&(m.videoFramePtsTime=d),t(m)},B5=({transmuxedData:s,callback:e})=>{s.buffer=[],e(s)},F5=(s,e)=>{e.gopInfo=s.data.gopInfo},jD=s=>{const{transmuxer:e,bytes:t,audioAppendStart:i,gopsToAlignWith:n,remux:r,onData:o,onTrackInfo:u,onAudioTimingInfo:c,onVideoTimingInfo:d,onVideoSegmentTimingInfo:f,onAudioSegmentTimingInfo:m,onId3:g,onCaptions:v,onDone:b,onEndedTimeline:_,onTransmuxerLog:E,isEndOfTimeline:w,segment:I,triggerSegmentEventFn:L}=s,F={buffer:[]};let $=w;const G=V=>{e.currentTransmux===s&&(V.data.action==="data"&&N5(V,F,o),V.data.action==="trackinfo"&&u(V.data.trackInfo),V.data.action==="gopInfo"&&F5(V,F),V.data.action==="audioTimingInfo"&&c(V.data.audioTimingInfo),V.data.action==="videoTimingInfo"&&d(V.data.videoTimingInfo),V.data.action==="videoSegmentTimingInfo"&&f(V.data.videoSegmentTimingInfo),V.data.action==="audioSegmentTimingInfo"&&m(V.data.audioSegmentTimingInfo),V.data.action==="id3Frame"&&g([V.data.id3Frame],V.data.id3Frame.dispatchType),V.data.action==="caption"&&v(V.data.caption),V.data.action==="endedtimeline"&&($=!1,_()),V.data.action==="log"&&E(V.data.log),V.data.type==="transmuxed"&&($||(e.onmessage=null,B5({transmuxedData:F,callback:b}),HD(e))))},B=()=>{const V={message:"Received an error message from the transmuxer worker",metadata:{errorType:Te.Error.StreamingFailedToTransmuxSegment,segmentInfo:fl({segment:I})}};b(null,V)};if(e.onmessage=G,e.onerror=B,i&&e.postMessage({action:"setAudioAppendStart",appendStart:i}),Array.isArray(n)&&e.postMessage({action:"alignGopsWith",gopsToAlignWith:n}),typeof r<"u"&&e.postMessage({action:"setRemux",remux:r}),t.byteLength){const V=t instanceof ArrayBuffer?t:t.buffer,k=t instanceof ArrayBuffer?0:t.byteOffset;L({type:"segmenttransmuxingstart",segment:I}),e.postMessage({action:"push",data:V,byteOffset:k,byteLength:t.byteLength},[V])}w&&e.postMessage({action:"endTimeline"}),e.postMessage({action:"flush"})},HD=s=>{s.currentTransmux=null,s.transmuxQueue.length&&(s.currentTransmux=s.transmuxQueue.shift(),typeof s.currentTransmux=="function"?s.currentTransmux():jD(s.currentTransmux))},r1=(s,e)=>{s.postMessage({action:e}),HD(s)},GD=(s,e)=>{if(!e.currentTransmux){e.currentTransmux=s,r1(e,s);return}e.transmuxQueue.push(r1.bind(null,e,s))},U5=s=>{GD("reset",s)},$5=s=>{GD("endTimeline",s)},VD=s=>{if(!s.transmuxer.currentTransmux){s.transmuxer.currentTransmux=s,jD(s);return}s.transmuxer.transmuxQueue.push(s)},j5=s=>{const e=new M5;e.currentTransmux=null,e.transmuxQueue=[];const t=e.terminate;return e.terminate=()=>(e.currentTransmux=null,e.transmuxQueue.length=0,t.call(e)),e.postMessage({action:"init",options:s}),e};var Ry={reset:U5,endTimeline:$5,transmux:VD,createTransmuxer:j5};const ju=function(s){const e=s.transmuxer,t=s.endAction||s.action,i=s.callback,n=Hi({},s,{endAction:null,transmuxer:null,callback:null}),r=o=>{o.data.action===t&&(e.removeEventListener("message",r),o.data.data&&(o.data.data=new Uint8Array(o.data.data,s.byteOffset||0,s.byteLength||o.data.data.byteLength),s.data&&(s.data=o.data.data)),i(o.data))};if(e.addEventListener("message",r),s.data){const o=s.data instanceof ArrayBuffer;n.byteOffset=o?0:s.data.byteOffset,n.byteLength=s.data.byteLength;const u=[o?s.data:s.data.buffer];e.postMessage(n,u)}else e.postMessage(n)},kr={FAILURE:2,TIMEOUT:-101,ABORTED:-102},qD="wvtt",Bv=s=>{s.forEach(e=>{e.abort()})},H5=s=>({bandwidth:s.bandwidth,bytesReceived:s.bytesReceived||0,roundTripTime:s.roundTripTime||0}),G5=s=>{const e=s.target,i={bandwidth:1/0,bytesReceived:0,roundTripTime:Date.now()-e.requestTime||0};return i.bytesReceived=s.loaded,i.bandwidth=Math.floor(i.bytesReceived/i.roundTripTime*8*1e3),i},XT=(s,e)=>{const{requestType:t}=e,i=_l({requestType:t,request:e,error:s});return e.timedout?{status:e.status,message:"HLS request timed-out at URL: "+e.uri,code:kr.TIMEOUT,xhr:e,metadata:i}:e.aborted?{status:e.status,message:"HLS request aborted at URL: "+e.uri,code:kr.ABORTED,xhr:e,metadata:i}:s?{status:e.status,message:"HLS request errored at URL: "+e.uri,code:kr.FAILURE,xhr:e,metadata:i}:e.responseType==="arraybuffer"&&e.response.byteLength===0?{status:e.status,message:"Empty HLS response at URL: "+e.uri,code:kr.FAILURE,xhr:e,metadata:i}:null},a1=(s,e,t,i)=>(n,r)=>{const o=r.response,u=XT(n,r);if(u)return t(u,s);if(o.byteLength!==16)return t({status:r.status,message:"Invalid HLS key at URL: "+r.uri,code:kr.FAILURE,xhr:r},s);const c=new DataView(o),d=new Uint32Array([c.getUint32(0),c.getUint32(4),c.getUint32(8),c.getUint32(12)]);for(let m=0;m<e.length;m++)e[m].bytes=d;const f={uri:r.uri};return i({type:"segmentkeyloadcomplete",segment:s,keyInfo:f}),t(null,s)},V5=(s,e)=>{e===qD&&s.transmuxer.postMessage({action:"initMp4WebVttParser",data:s.map.bytes})},q5=(s,e,t)=>{e===qD&&ju({action:"getMp4WebVttText",data:s.bytes,transmuxer:s.transmuxer,callback:({data:i,mp4VttCues:n})=>{s.bytes=i,t(null,s,{mp4VttCues:n})}})},zD=(s,e)=>{const t=TT(s.map.bytes);if(t!=="mp4"){const i=s.map.resolvedUri||s.map.uri,n=t||"unknown";return e({internal:!0,message:`Found unsupported ${n} container for initialization segment at URL: ${i}`,code:kr.FAILURE,metadata:{mediaType:n}})}ju({action:"probeMp4Tracks",data:s.map.bytes,transmuxer:s.transmuxer,callback:({tracks:i,data:n})=>(s.map.bytes=n,i.forEach(function(r){s.map.tracks=s.map.tracks||{},!s.map.tracks[r.type]&&(s.map.tracks[r.type]=r,typeof r.id=="number"&&r.timescale&&(s.map.timescales=s.map.timescales||{},s.map.timescales[r.id]=r.timescale),r.type==="text"&&V5(s,r.codec))}),e(null))})},z5=({segment:s,finishProcessingFn:e,triggerSegmentEventFn:t})=>(i,n)=>{const r=XT(i,n);if(r)return e(r,s);const o=new Uint8Array(n.response);if(t({type:"segmentloaded",segment:s}),s.map.key)return s.map.encryptedBytes=o,e(null,s);s.map.bytes=o,zD(s,function(u){if(u)return u.xhr=n,u.status=n.status,e(u,s);e(null,s)})},K5=({segment:s,finishProcessingFn:e,responseType:t,triggerSegmentEventFn:i})=>(n,r)=>{const o=XT(n,r);if(o)return e(o,s);i({type:"segmentloaded",segment:s});const u=t==="arraybuffer"||!r.responseText?r.response:R5(r.responseText.substring(s.lastReachedChar||0));return s.stats=H5(r),s.key?s.encryptedBytes=new Uint8Array(u):s.bytes=new Uint8Array(u),e(null,s)},Y5=({segment:s,bytes:e,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:o,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f,doneFn:m,onTransmuxerLog:g,triggerSegmentEventFn:v})=>{const b=s.map&&s.map.tracks||{},_=!!(b.audio&&b.video);let E=i.bind(null,s,"audio","start");const w=i.bind(null,s,"audio","end");let I=i.bind(null,s,"video","start");const L=i.bind(null,s,"video","end"),F=()=>VD({bytes:e,transmuxer:s.transmuxer,audioAppendStart:s.audioAppendStart,gopsToAlignWith:s.gopsToAlignWith,remux:_,onData:$=>{$.type=$.type==="combined"?"video":$.type,f(s,$)},onTrackInfo:$=>{t&&(_&&($.isMuxed=!0),t(s,$))},onAudioTimingInfo:$=>{E&&typeof $.start<"u"&&(E($.start),E=null),w&&typeof $.end<"u"&&w($.end)},onVideoTimingInfo:$=>{I&&typeof $.start<"u"&&(I($.start),I=null),L&&typeof $.end<"u"&&L($.end)},onVideoSegmentTimingInfo:$=>{const G={pts:{start:$.start.presentation,end:$.end.presentation},dts:{start:$.start.decode,end:$.end.decode}};v({type:"segmenttransmuxingtiminginfoavailable",segment:s,timingInfo:G}),n($)},onAudioSegmentTimingInfo:$=>{const G={pts:{start:$.start.pts,end:$.end.pts},dts:{start:$.start.dts,end:$.end.dts}};v({type:"segmenttransmuxingtiminginfoavailable",segment:s,timingInfo:G}),r($)},onId3:($,G)=>{o(s,$,G)},onCaptions:$=>{u(s,[$])},isEndOfTimeline:c,onEndedTimeline:()=>{d()},onTransmuxerLog:g,onDone:($,G)=>{m&&($.type=$.type==="combined"?"video":$.type,v({type:"segmenttransmuxingcomplete",segment:s}),m(G,s,$))},segment:s,triggerSegmentEventFn:v});ju({action:"probeTs",transmuxer:s.transmuxer,data:e,baseStartTime:s.baseStartTime,callback:$=>{s.bytes=e=$.data;const G=$.result;G&&(t(s,{hasAudio:G.hasAudio,hasVideo:G.hasVideo,isMuxed:_}),t=null),F()}})},KD=({segment:s,bytes:e,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:o,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f,doneFn:m,onTransmuxerLog:g,triggerSegmentEventFn:v})=>{let b=new Uint8Array(e);if(mN(b)){s.isFmp4=!0;const{tracks:_}=s.map;if(_.text&&(!_.audio||!_.video)){f(s,{data:b,type:"text"}),q5(s,_.text.codec,m);return}const w={isFmp4:!0,hasVideo:!!_.video,hasAudio:!!_.audio};_.audio&&_.audio.codec&&_.audio.codec!=="enca"&&(w.audioCodec=_.audio.codec),_.video&&_.video.codec&&_.video.codec!=="encv"&&(w.videoCodec=_.video.codec),_.video&&_.audio&&(w.isMuxed=!0),t(s,w);const I=(L,F)=>{f(s,{data:b,type:w.hasAudio&&!w.isMuxed?"audio":"video"}),F&&F.length&&o(s,F),L&&L.length&&u(s,L),m(null,s,{})};ju({action:"probeMp4StartTime",timescales:s.map.timescales,data:b,transmuxer:s.transmuxer,callback:({data:L,startTime:F})=>{e=L.buffer,s.bytes=b=L,w.hasAudio&&!w.isMuxed&&i(s,"audio","start",F),w.hasVideo&&i(s,"video","start",F),ju({action:"probeEmsgID3",data:b,transmuxer:s.transmuxer,offset:F,callback:({emsgData:$,id3Frames:G})=>{if(e=$.buffer,s.bytes=b=$,!_.video||!$.byteLength||!s.transmuxer){I(void 0,G);return}ju({action:"pushMp4Captions",endAction:"mp4Captions",transmuxer:s.transmuxer,data:b,timescales:s.map.timescales,trackIds:[_.video.id],callback:B=>{e=B.data.buffer,s.bytes=b=B.data,B.logs.forEach(function(V){g(Kt(V,{stream:"mp4CaptionParser"}))}),I(B.captions,G)}})}})}});return}if(!s.transmuxer){m(null,s,{});return}if(typeof s.container>"u"&&(s.container=TT(b)),s.container!=="ts"&&s.container!=="aac"){t(s,{hasAudio:!1,hasVideo:!1}),m(null,s,{});return}Y5({segment:s,bytes:e,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:o,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f,doneFn:m,onTransmuxerLog:g,triggerSegmentEventFn:v})},YD=function({id:s,key:e,encryptedBytes:t,decryptionWorker:i,segment:n,doneFn:r},o){const u=d=>{if(d.data.source===s){i.removeEventListener("message",u);const f=d.data.decrypted;o(new Uint8Array(f.bytes,f.byteOffset,f.byteLength))}};i.onerror=()=>{const d="An error occurred in the decryption worker",f=fl({segment:n}),m={message:d,metadata:{error:new Error(d),errorType:Te.Error.StreamingFailedToDecryptSegment,segmentInfo:f,keyInfo:{uri:n.key.resolvedUri||n.map.key.resolvedUri}}};r(m,n)},i.addEventListener("message",u);let c;e.bytes.slice?c=e.bytes.slice():c=new Uint32Array(Array.prototype.slice.call(e.bytes)),i.postMessage(RD({source:s,encrypted:t,key:c,iv:e.iv}),[t.buffer,c.buffer])},W5=({decryptionWorker:s,segment:e,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:o,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f,doneFn:m,onTransmuxerLog:g,triggerSegmentEventFn:v})=>{v({type:"segmentdecryptionstart"}),YD({id:e.requestId,key:e.key,encryptedBytes:e.encryptedBytes,decryptionWorker:s,segment:e,doneFn:m},b=>{e.bytes=b,v({type:"segmentdecryptioncomplete",segment:e}),KD({segment:e,bytes:e.bytes,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:o,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f,doneFn:m,onTransmuxerLog:g,triggerSegmentEventFn:v})})},X5=({activeXhrs:s,decryptionWorker:e,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:o,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f,doneFn:m,onTransmuxerLog:g,triggerSegmentEventFn:v})=>{let b=0,_=!1;return(E,w)=>{if(!_){if(E)return _=!0,Bv(s),m(E,w);if(b+=1,b===s.length){const I=function(){if(w.encryptedBytes)return W5({decryptionWorker:e,segment:w,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:o,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f,doneFn:m,onTransmuxerLog:g,triggerSegmentEventFn:v});KD({segment:w,bytes:w.bytes,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:o,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f,doneFn:m,onTransmuxerLog:g,triggerSegmentEventFn:v})};if(w.endOfAllRequests=Date.now(),w.map&&w.map.encryptedBytes&&!w.map.bytes)return v({type:"segmentdecryptionstart",segment:w}),YD({decryptionWorker:e,id:w.requestId+"-init",encryptedBytes:w.map.encryptedBytes,key:w.map.key,segment:w,doneFn:m},L=>{w.map.bytes=L,v({type:"segmentdecryptioncomplete",segment:w}),zD(w,F=>{if(F)return Bv(s),m(F,w);I()})});I()}}}},Q5=({loadendState:s,abortFn:e})=>t=>{t.target.aborted&&e&&!s.calledAbortFn&&(e(),s.calledAbortFn=!0)},Z5=({segment:s,progressFn:e,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:o,captionsFn:u,isEndOfTimeline:c,endedTimelineFn:d,dataFn:f})=>m=>{if(!m.target.aborted)return s.stats=Kt(s.stats,G5(m)),!s.stats.firstBytesReceivedAt&&s.stats.bytesReceived&&(s.stats.firstBytesReceivedAt=Date.now()),e(m,s)},J5=({xhr:s,xhrOptions:e,decryptionWorker:t,segment:i,abortFn:n,progressFn:r,trackInfoFn:o,timingInfoFn:u,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:d,id3Fn:f,captionsFn:m,isEndOfTimeline:g,endedTimelineFn:v,dataFn:b,doneFn:_,onTransmuxerLog:E,triggerSegmentEventFn:w})=>{const I=[],L=X5({activeXhrs:I,decryptionWorker:t,trackInfoFn:o,timingInfoFn:u,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:d,id3Fn:f,captionsFn:m,isEndOfTimeline:g,endedTimelineFn:v,dataFn:b,doneFn:_,onTransmuxerLog:E,triggerSegmentEventFn:w});if(i.key&&!i.key.bytes){const V=[i.key];i.map&&!i.map.bytes&&i.map.key&&i.map.key.resolvedUri===i.key.resolvedUri&&V.push(i.map.key);const k=Kt(e,{uri:i.key.resolvedUri,responseType:"arraybuffer",requestType:"segment-key"}),R=a1(i,V,L,w),z={uri:i.key.resolvedUri};w({type:"segmentkeyloadstart",segment:i,keyInfo:z});const X=s(k,R);I.push(X)}if(i.map&&!i.map.bytes){if(i.map.key&&(!i.key||i.key.resolvedUri!==i.map.key.resolvedUri)){const X=Kt(e,{uri:i.map.key.resolvedUri,responseType:"arraybuffer",requestType:"segment-key"}),ee=a1(i,[i.map.key],L,w),le={uri:i.map.key.resolvedUri};w({type:"segmentkeyloadstart",segment:i,keyInfo:le});const oe=s(X,ee);I.push(oe)}const k=Kt(e,{uri:i.map.resolvedUri,responseType:"arraybuffer",headers:Mv(i.map),requestType:"segment-media-initialization"}),R=z5({segment:i,finishProcessingFn:L,triggerSegmentEventFn:w});w({type:"segmentloadstart",segment:i});const z=s(k,R);I.push(z)}const F=Kt(e,{uri:i.part&&i.part.resolvedUri||i.resolvedUri,responseType:"arraybuffer",headers:Mv(i),requestType:"segment"}),$=K5({segment:i,finishProcessingFn:L,responseType:F.responseType,triggerSegmentEventFn:w});w({type:"segmentloadstart",segment:i});const G=s(F,$);G.addEventListener("progress",Z5({segment:i,progressFn:r,trackInfoFn:o,timingInfoFn:u,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:d,id3Fn:f,captionsFn:m,isEndOfTimeline:g,endedTimelineFn:v,dataFn:b})),I.push(G);const B={};return I.forEach(V=>{V.addEventListener("loadend",Q5({loadendState:B,abortFn:n}))}),()=>Bv(I)},Yf=$n("PlaylistSelector"),o1=function(s){if(!s||!s.playlist)return;const e=s.playlist;return JSON.stringify({id:e.id,bandwidth:s.bandwidth,width:s.width,height:s.height,codecs:e.attributes&&e.attributes.CODECS||""})},Hu=function(s,e){if(!s)return"";const t=ne.getComputedStyle(s);return t?t[e]:""},Gu=function(s,e){const t=s.slice();s.sort(function(i,n){const r=e(i,n);return r===0?t.indexOf(i)-t.indexOf(n):r})},QT=function(s,e){let t,i;return s.attributes.BANDWIDTH&&(t=s.attributes.BANDWIDTH),t=t||ne.Number.MAX_VALUE,e.attributes.BANDWIDTH&&(i=e.attributes.BANDWIDTH),i=i||ne.Number.MAX_VALUE,t-i},e4=function(s,e){let t,i;return s.attributes.RESOLUTION&&s.attributes.RESOLUTION.width&&(t=s.attributes.RESOLUTION.width),t=t||ne.Number.MAX_VALUE,e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width&&(i=e.attributes.RESOLUTION.width),i=i||ne.Number.MAX_VALUE,t===i&&s.attributes.BANDWIDTH&&e.attributes.BANDWIDTH?s.attributes.BANDWIDTH-e.attributes.BANDWIDTH:t-i};let WD=function(s){const{main:e,bandwidth:t,playerWidth:i,playerHeight:n,playerObjectFit:r,limitRenditionByPlayerDimensions:o,playlistController:u}=s;if(!e)return;const c={bandwidth:t,width:i,height:n,limitRenditionByPlayerDimensions:o};let d=e.playlists;en.isAudioOnly(e)&&(d=u.getAudioTrackPlaylists_(),c.audioOnly=!0);let f=d.map(B=>{let V;const k=B.attributes&&B.attributes.RESOLUTION&&B.attributes.RESOLUTION.width,R=B.attributes&&B.attributes.RESOLUTION&&B.attributes.RESOLUTION.height;return V=B.attributes&&B.attributes.BANDWIDTH,V=V||ne.Number.MAX_VALUE,{bandwidth:V,width:k,height:R,playlist:B}});Gu(f,(B,V)=>B.bandwidth-V.bandwidth),f=f.filter(B=>!en.isIncompatible(B.playlist));let m=f.filter(B=>en.isEnabled(B.playlist));m.length||(m=f.filter(B=>!en.isDisabled(B.playlist)));const g=m.filter(B=>B.bandwidth*os.BANDWIDTH_VARIANCE<t);let v=g[g.length-1];const b=g.filter(B=>B.bandwidth===v.bandwidth)[0];if(o===!1){const B=b||m[0]||f[0];if(B&&B.playlist){let V="sortedPlaylistReps";return b&&(V="bandwidthBestRep"),m[0]&&(V="enabledPlaylistReps"),Yf(`choosing ${o1(B)} using ${V} with options`,c),B.playlist}return Yf("could not choose a playlist with options",c),null}const _=g.filter(B=>B.width&&B.height);Gu(_,(B,V)=>B.width-V.width);const E=_.filter(B=>B.width===i&&B.height===n);v=E[E.length-1];const w=E.filter(B=>B.bandwidth===v.bandwidth)[0];let I,L,F;w||(I=_.filter(B=>r==="cover"?B.width>i&&B.height>n:B.width>i||B.height>n),L=I.filter(B=>B.width===I[0].width&&B.height===I[0].height),v=L[L.length-1],F=L.filter(B=>B.bandwidth===v.bandwidth)[0]);let $;if(u.leastPixelDiffSelector){const B=_.map(V=>(V.pixelDiff=Math.abs(V.width-i)+Math.abs(V.height-n),V));Gu(B,(V,k)=>V.pixelDiff===k.pixelDiff?k.bandwidth-V.bandwidth:V.pixelDiff-k.pixelDiff),$=B[0]}const G=$||F||w||b||m[0]||f[0];if(G&&G.playlist){let B="sortedPlaylistReps";return $?B="leastPixelDiffRep":F?B="resolutionPlusOneRep":w?B="resolutionBestRep":b?B="bandwidthBestRep":m[0]&&(B="enabledPlaylistReps"),Yf(`choosing ${o1(G)} using ${B} with options`,c),G.playlist}return Yf("could not choose a playlist with options",c),null};const l1=function(){let s=this.useDevicePixelRatio&&ne.devicePixelRatio||1;return isNaN(this.customPixelRatio)||(s=this.customPixelRatio),WD({main:this.playlists.main,bandwidth:this.systemBandwidth,playerWidth:parseInt(Hu(this.tech_.el(),"width"),10)*s,playerHeight:parseInt(Hu(this.tech_.el(),"height"),10)*s,playerObjectFit:this.usePlayerObjectFit?Hu(this.tech_.el(),"objectFit"):"",limitRenditionByPlayerDimensions:this.limitRenditionByPlayerDimensions,playlistController:this.playlistController_})},t4=function(s){let e=-1,t=-1;if(s<0||s>1)throw new Error("Moving average bandwidth decay must be between 0 and 1.");return function(){let i=this.useDevicePixelRatio&&ne.devicePixelRatio||1;return isNaN(this.customPixelRatio)||(i=this.customPixelRatio),e<0&&(e=this.systemBandwidth,t=this.systemBandwidth),this.systemBandwidth>0&&this.systemBandwidth!==t&&(e=s*this.systemBandwidth+(1-s)*e,t=this.systemBandwidth),WD({main:this.playlists.main,bandwidth:e,playerWidth:parseInt(Hu(this.tech_.el(),"width"),10)*i,playerHeight:parseInt(Hu(this.tech_.el(),"height"),10)*i,playerObjectFit:this.usePlayerObjectFit?Hu(this.tech_.el(),"objectFit"):"",limitRenditionByPlayerDimensions:this.limitRenditionByPlayerDimensions,playlistController:this.playlistController_})}},i4=function(s){const{main:e,currentTime:t,bandwidth:i,duration:n,segmentDuration:r,timeUntilRebuffer:o,currentTimeline:u,syncController:c}=s,d=e.playlists.filter(b=>!en.isIncompatible(b));let f=d.filter(en.isEnabled);f.length||(f=d.filter(b=>!en.isDisabled(b)));const g=f.filter(en.hasAttribute.bind(null,"BANDWIDTH")).map(b=>{const E=c.getSyncPoint(b,n,u,t)?1:2,I=en.estimateSegmentRequestTime(r,i,b)*E-o;return{playlist:b,rebufferingImpact:I}}),v=g.filter(b=>b.rebufferingImpact<=0);return Gu(v,(b,_)=>QT(_.playlist,b.playlist)),v.length?v[0]:(Gu(g,(b,_)=>b.rebufferingImpact-_.rebufferingImpact),g[0]||null)},s4=function(){const s=this.playlists.main.playlists.filter(en.isEnabled);return Gu(s,(t,i)=>QT(t,i)),s.filter(t=>!!$d(this.playlists.main,t).video)[0]||null},n4=s=>{let e=0,t;return s.bytes&&(t=new Uint8Array(s.bytes),s.segments.forEach(i=>{t.set(i,e),e+=i.byteLength})),t};function XD(s){try{return new URL(s).pathname.split("/").slice(-2).join("/")}catch{return""}}const r4=function(s,e,t){if(!s[t]){e.trigger({type:"usage",name:"vhs-608"});let i=t;/^cc708_/.test(t)&&(i="SERVICE"+t.split("_")[1]);const n=e.textTracks().getTrackById(i);if(n)s[t]=n;else{const r=e.options_.vhs&&e.options_.vhs.captionServices||{};let o=t,u=t,c=!1;const d=r[i];d&&(o=d.label,u=d.language,c=d.default),s[t]=e.addRemoteTextTrack({kind:"captions",id:i,default:c,label:o,language:u},!1).track}}},a4=function({inbandTextTracks:s,captionArray:e,timestampOffset:t}){if(!e)return;const i=ne.WebKitDataCue||ne.VTTCue;e.forEach(n=>{const r=n.stream;n.content?n.content.forEach(o=>{const u=new i(n.startTime+t,n.endTime+t,o.text);u.line=o.line,u.align="left",u.position=o.position,u.positionAlign="line-left",s[r].addCue(u)}):s[r].addCue(new i(n.startTime+t,n.endTime+t,n.text))})},o4=function(s){Object.defineProperties(s.frame,{id:{get(){return Te.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),s.value.key}},value:{get(){return Te.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),s.value.data}},privateData:{get(){return Te.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),s.value.data}}})},l4=({inbandTextTracks:s,metadataArray:e,timestampOffset:t,videoDuration:i})=>{if(!e)return;const n=ne.WebKitDataCue||ne.VTTCue,r=s.metadataTrack_;if(!r||(e.forEach(f=>{const m=f.cueTime+t;typeof m!="number"||ne.isNaN(m)||m<0||!(m<1/0)||!f.frames||!f.frames.length||f.frames.forEach(g=>{const v=new n(m,m,g.value||g.url||g.data||"");v.frame=g,v.value=g,o4(v),r.addCue(v)})}),!r.cues||!r.cues.length))return;const o=r.cues,u=[];for(let f=0;f<o.length;f++)o[f]&&u.push(o[f]);const c=u.reduce((f,m)=>{const g=f[m.startTime]||[];return g.push(m),f[m.startTime]=g,f},{}),d=Object.keys(c).sort((f,m)=>Number(f)-Number(m));d.forEach((f,m)=>{const g=c[f],v=isFinite(i)?i:f,b=Number(d[m+1])||v;g.forEach(_=>{_.endTime=b})})},u4={id:"ID",class:"CLASS",startDate:"START-DATE",duration:"DURATION",endDate:"END-DATE",endOnNext:"END-ON-NEXT",plannedDuration:"PLANNED-DURATION",scte35Out:"SCTE35-OUT",scte35In:"SCTE35-IN"},c4=new Set(["id","class","startDate","duration","endDate","endOnNext","startTime","endTime","processDateRange"]),d4=({inbandTextTracks:s,dateRanges:e})=>{const t=s.metadataTrack_;if(!t)return;const i=ne.WebKitDataCue||ne.VTTCue;e.forEach(n=>{for(const r of Object.keys(n)){if(c4.has(r))continue;const o=new i(n.startTime,n.endTime,"");o.id=n.id,o.type="com.apple.quicktime.HLS",o.value={key:u4[r],data:n[r]},(r==="scte35Out"||r==="scte35In")&&(o.value.data=new Uint8Array(o.value.data.match(/[\da-f]{2}/gi)).buffer),t.addCue(o)}n.processDateRange()})},u1=(s,e,t)=>{s.metadataTrack_||(s.metadataTrack_=t.addRemoteTextTrack({kind:"metadata",label:"Timed Metadata"},!1).track,Te.browser.IS_ANY_SAFARI||(s.metadataTrack_.inBandMetadataTrackDispatchType=e))},Ld=function(s,e,t){let i,n;if(t&&t.cues)for(i=t.cues.length;i--;)n=t.cues[i],n.startTime>=s&&n.endTime<=e&&t.removeCue(n)},h4=function(s){const e=s.cues;if(!e)return;const t={};for(let i=e.length-1;i>=0;i--){const n=e[i],r=`${n.startTime}-${n.endTime}-${n.text}`;t[r]?s.removeCue(n):t[r]=n}},f4=(s,e,t)=>{if(typeof e>"u"||e===null||!s.length)return[];const i=Math.ceil((e-t+3)*ml.ONE_SECOND_IN_TS);let n;for(n=0;n<s.length&&!(s[n].pts>i);n++);return s.slice(n)},p4=(s,e,t)=>{if(!e.length)return s;if(t)return e.slice();const i=e[0].pts;let n=0;for(n;n<s.length&&!(s[n].pts>=i);n++);return s.slice(0,n).concat(e)},m4=(s,e,t,i)=>{const n=Math.ceil((e-i)*ml.ONE_SECOND_IN_TS),r=Math.ceil((t-i)*ml.ONE_SECOND_IN_TS),o=s.slice();let u=s.length;for(;u--&&!(s[u].pts<=r););if(u===-1)return o;let c=u+1;for(;c--&&!(s[c].pts<=n););return c=Math.max(c,0),o.splice(c,u-c+1),o},g4=function(s,e){if(!s&&!e||!s&&e||s&&!e)return!1;if(s===e)return!0;const t=Object.keys(s).sort(),i=Object.keys(e).sort();if(t.length!==i.length)return!1;for(let n=0;n<t.length;n++){const r=t[n];if(r!==i[n]||s[r]!==e[r])return!1}return!0},y4=function(s,e,t){e=e||[];const i=[];let n=0;for(let r=0;r<e.length;r++){const o=e[r];if(s===o.timeline&&(i.push(r),n+=o.duration,n>t))return r}return i.length===0?0:i[i.length-1]},xd=1,v4=500,c1=s=>typeof s=="number"&&isFinite(s),Wf=1/60,T4=(s,e,t)=>s!=="main"||!e||!t?null:!t.hasAudio&&!t.hasVideo?"Neither audio nor video found in segment.":e.hasVideo&&!t.hasVideo?"Only audio found in segment when we expected video. We can't switch to audio only from a stream that had video. To get rid of this message, please add codec information to the manifest.":!e.hasVideo&&t.hasVideo?"Video found in segment when we expected only audio. We can't switch to a stream with video from an audio only stream. To get rid of this message, please add codec information to the manifest.":null,b4=(s,e,t)=>{let i=e-os.BACK_BUFFER_LENGTH;s.length&&(i=Math.max(i,s.start(0)));const n=e-t;return Math.min(n,i)},xu=s=>{const{startOfSegment:e,duration:t,segment:i,part:n,playlist:{mediaSequence:r,id:o,segments:u=[]},mediaIndex:c,partIndex:d,timeline:f}=s,m=u.length-1;let g="mediaIndex/partIndex increment";s.getMediaInfoForTime?g=`getMediaInfoForTime (${s.getMediaInfoForTime})`:s.isSyncRequest&&(g="getSyncSegmentCandidate (isSyncRequest)"),s.independent&&(g+=` with independent ${s.independent}`);const v=typeof d=="number",b=s.segment.uri?"segment":"pre-segment",_=v?pD({preloadSegment:i})-1:0;return`${b} [${r+c}/${r+m}]`+(v?` part [${d}/${_}]`:"")+` segment start/end [${i.start} => ${i.end}]`+(v?` part start/end [${n.start} => ${n.end}]`:"")+` startOfSegment [${e}] duration [${t}] timeline [${f}] selected by [${g}] playlist [${o}]`},d1=s=>`${s}TimingInfo`,_4=({segmentTimeline:s,currentTimeline:e,startOfSegment:t,buffered:i,overrideCheck:n})=>!n&&s===e?null:s<e?t:i.length?i.end(i.length-1):t,Fv=({timelineChangeController:s,currentTimeline:e,segmentTimeline:t,loaderType:i,audioDisabled:n})=>{if(e===t)return!1;if(i==="audio"){const r=s.lastTimelineChange({type:"main"});return!r||r.to!==t}if(i==="main"&&n){const r=s.pendingTimelineChange({type:"audio"});return!(r&&r.to===t)}return!1},x4=s=>{if(!s)return!1;const e=s.pendingTimelineChange({type:"audio"}),t=s.pendingTimelineChange({type:"main"}),i=e&&t,n=i&&e.to!==t.to;return!!(i&&e.from!==-1&&t.from!==-1&&n)},S4=s=>{const e=s.timelineChangeController_.pendingTimelineChange({type:"audio"}),t=s.timelineChangeController_.pendingTimelineChange({type:"main"});return e&&t&&e.to<t.to},lo=s=>{const e=s.pendingSegment_;if(!e)return;if(Fv({timelineChangeController:s.timelineChangeController_,currentTimeline:s.currentTimeline_,segmentTimeline:e.timeline,loaderType:s.loaderType_,audioDisabled:s.audioDisabled_})&&x4(s.timelineChangeController_)){if(S4(s)){s.timelineChangeController_.trigger("audioTimelineBehind");return}s.timelineChangeController_.trigger("fixBadTimelineChange")}},E4=s=>{let e=0;return["video","audio"].forEach(function(t){const i=s[`${t}TimingInfo`];if(!i)return;const{start:n,end:r}=i;let o;typeof n=="bigint"||typeof r=="bigint"?o=ne.BigInt(r)-ne.BigInt(n):typeof n=="number"&&typeof r=="number"&&(o=r-n),typeof o<"u"&&o>e&&(e=o)}),typeof e=="bigint"&&e<Number.MAX_SAFE_INTEGER&&(e=Number(e)),e},h1=({segmentDuration:s,maxDuration:e})=>s?Math.round(s)>e+Lr:!1,A4=(s,e)=>{if(e!=="hls")return null;const t=E4({audioTimingInfo:s.audioTimingInfo,videoTimingInfo:s.videoTimingInfo});if(!t)return null;const i=s.playlist.targetDuration,n=h1({segmentDuration:t,maxDuration:i*2}),r=h1({segmentDuration:t,maxDuration:i}),o=`Segment with index ${s.mediaIndex} from playlist ${s.playlist.id} has a duration of ${t} when the reported duration is ${s.duration} and the target duration is ${i}. For HLS content, a duration in excess of the target duration may result in playback issues. See the HLS specification section on EXT-X-TARGETDURATION for more details: https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.3.1`;return n||r?{severity:n?"warn":"info",message:o}:null},fl=({type:s,segment:e})=>{if(!e)return;const t=!!(e.key||e.map&&e.map.ke),i=!!(e.map&&!e.map.bytes),n=e.startOfSegment===void 0?e.start:e.startOfSegment;return{type:s||e.type,uri:e.resolvedUri||e.uri,start:n,duration:e.duration,isEncrypted:t,isMediaInitialization:i}};class Uv extends Te.EventTarget{constructor(e,t={}){if(super(),!e)throw new TypeError("Initialization settings are required");if(typeof e.currentTime!="function")throw new TypeError("No currentTime getter specified");if(!e.mediaSource)throw new TypeError("No MediaSource specified");this.bandwidth=e.bandwidth,this.throughput={rate:0,count:0},this.roundTrip=NaN,this.resetStats_(),this.mediaIndex=null,this.partIndex=null,this.hasPlayed_=e.hasPlayed,this.currentTime_=e.currentTime,this.seekable_=e.seekable,this.seeking_=e.seeking,this.duration_=e.duration,this.mediaSource_=e.mediaSource,this.vhs_=e.vhs,this.loaderType_=e.loaderType,this.currentMediaInfo_=void 0,this.startingMediaInfo_=void 0,this.segmentMetadataTrack_=e.segmentMetadataTrack,this.goalBufferLength_=e.goalBufferLength,this.sourceType_=e.sourceType,this.sourceUpdater_=e.sourceUpdater,this.inbandTextTracks_=e.inbandTextTracks,this.state_="INIT",this.timelineChangeController_=e.timelineChangeController,this.shouldSaveSegmentTimingInfo_=!0,this.parse708captions_=e.parse708captions,this.useDtsForTimestampOffset_=e.useDtsForTimestampOffset,this.captionServices_=e.captionServices,this.exactManifestTimings=e.exactManifestTimings,this.addMetadataToTextTrack=e.addMetadataToTextTrack,this.checkBufferTimeout_=null,this.error_=void 0,this.currentTimeline_=-1,this.shouldForceTimestampOffsetAfterResync_=!1,this.pendingSegment_=null,this.xhrOptions_=null,this.pendingSegments_=[],this.audioDisabled_=!1,this.isPendingTimestampOffset_=!1,this.gopBuffer_=[],this.timeMapping_=0,this.safeAppend_=!1,this.appendInitSegment_={audio:!0,video:!0},this.playlistOfLastInitSegment_={audio:null,video:null},this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_={id3:[],caption:[]},this.waitingOnRemove_=!1,this.quotaExceededErrorRetryTimeout_=null,this.activeInitSegmentId_=null,this.initSegments_={},this.cacheEncryptionKeys_=e.cacheEncryptionKeys,this.keyCache_={},this.decrypter_=e.decrypter,this.syncController_=e.syncController,this.syncPoint_={segmentIndex:0,time:0},this.transmuxer_=this.createTransmuxer_(),this.triggerSyncInfoUpdate_=()=>this.trigger("syncinfoupdate"),this.syncController_.on("syncinfoupdate",this.triggerSyncInfoUpdate_),this.mediaSource_.addEventListener("sourceopen",()=>{this.isEndOfStream_()||(this.ended_=!1)}),this.fetchAtBuffer_=!1,this.logger_=$n(`SegmentLoader[${this.loaderType_}]`),Object.defineProperty(this,"state",{get(){return this.state_},set(i){i!==this.state_&&(this.logger_(`${this.state_} -> ${i}`),this.state_=i,this.trigger("statechange"))}}),this.sourceUpdater_.on("ready",()=>{this.hasEnoughInfoToAppend_()?this.processCallQueue_():lo(this)}),this.sourceUpdater_.on("codecschange",i=>{this.trigger(Hi({type:"codecschange"},i))}),this.loaderType_==="main"&&this.timelineChangeController_.on("pendingtimelinechange",()=>{this.hasEnoughInfoToAppend_()?this.processCallQueue_():lo(this)}),this.loaderType_==="audio"&&this.timelineChangeController_.on("timelinechange",i=>{this.trigger(Hi({type:"timelinechange"},i)),this.hasEnoughInfoToLoad_()?this.processLoadQueue_():lo(this),this.hasEnoughInfoToAppend_()?this.processCallQueue_():lo(this)})}get mediaSequenceSync_(){return this.syncController_.getMediaSequenceSync(this.loaderType_)}createTransmuxer_(){return Ry.createTransmuxer({remux:!1,alignGopsAtEnd:this.safeAppend_,keepOriginalTimestamps:!0,parse708captions:this.parse708captions_,captionServices:this.captionServices_})}resetStats_(){this.mediaBytesTransferred=0,this.mediaRequests=0,this.mediaRequestsAborted=0,this.mediaRequestsTimedout=0,this.mediaRequestsErrored=0,this.mediaTransferDuration=0,this.mediaSecondsLoaded=0,this.mediaAppends=0}dispose(){this.trigger("dispose"),this.state="DISPOSED",this.pause(),this.abort_(),this.transmuxer_&&this.transmuxer_.terminate(),this.resetStats_(),this.checkBufferTimeout_&&ne.clearTimeout(this.checkBufferTimeout_),this.syncController_&&this.triggerSyncInfoUpdate_&&this.syncController_.off("syncinfoupdate",this.triggerSyncInfoUpdate_),this.off()}setAudio(e){this.audioDisabled_=!e,e?this.appendInitSegment_.audio=!0:this.sourceUpdater_.removeAudio(0,this.duration_())}abort(){if(this.state!=="WAITING"){this.pendingSegment_&&(this.pendingSegment_=null),this.timelineChangeController_.clearPendingTimelineChange(this.loaderType_);return}this.abort_(),this.state="READY",this.paused()||this.monitorBuffer_()}abort_(){this.pendingSegment_&&this.pendingSegment_.abortRequests&&this.pendingSegment_.abortRequests(),this.pendingSegment_=null,this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_.id3=[],this.metadataQueue_.caption=[],this.timelineChangeController_.clearPendingTimelineChange(this.loaderType_),this.waitingOnRemove_=!1,ne.clearTimeout(this.quotaExceededErrorRetryTimeout_),this.quotaExceededErrorRetryTimeout_=null}checkForAbort_(e){return this.state==="APPENDING"&&!this.pendingSegment_?(this.state="READY",!0):!this.pendingSegment_||this.pendingSegment_.requestId!==e}error(e){return typeof e<"u"&&(this.logger_("error occurred:",e),this.error_=e),this.pendingSegment_=null,this.error_}endOfStream(){this.ended_=!0,this.transmuxer_&&Ry.reset(this.transmuxer_),this.gopBuffer_.length=0,this.pause(),this.trigger("ended")}buffered_(){const e=this.getMediaInfo_();if(!this.sourceUpdater_||!e)return us();if(this.loaderType_==="main"){const{hasAudio:t,hasVideo:i,isMuxed:n}=e;if(i&&t&&!this.audioDisabled_&&!n)return this.sourceUpdater_.buffered();if(i)return this.sourceUpdater_.videoBuffered()}return this.sourceUpdater_.audioBuffered()}initSegmentForMap(e,t=!1){if(!e)return null;const i=Yp(e);let n=this.initSegments_[i];return t&&!n&&e.bytes&&(this.initSegments_[i]=n={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:e.bytes,tracks:e.tracks,timescales:e.timescales}),n||e}segmentKey(e,t=!1){if(!e)return null;const i=OD(e);let n=this.keyCache_[i];this.cacheEncryptionKeys_&&t&&!n&&e.bytes&&(this.keyCache_[i]=n={resolvedUri:e.resolvedUri,bytes:e.bytes});const r={resolvedUri:(n||e).resolvedUri};return n&&(r.bytes=n.bytes),r}couldBeginLoading_(){return this.playlist_&&!this.paused()}load(){if(this.monitorBuffer_(),!!this.playlist_){if(this.state==="INIT"&&this.couldBeginLoading_())return this.init_();!this.couldBeginLoading_()||this.state!=="READY"&&this.state!=="INIT"||(this.state="READY")}}init_(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}playlist(e,t={}){if(!e||this.playlist_&&this.playlist_.endList&&e.endList&&this.playlist_.uri===e.uri)return;const i=this.playlist_,n=this.pendingSegment_;this.playlist_=e,this.xhrOptions_=t,this.state==="INIT"&&(e.syncInfo={mediaSequence:e.mediaSequence,time:0},this.loaderType_==="main"&&this.syncController_.setDateTimeMappingForStart(e));let r=null;if(i&&(i.id?r=i.id:i.uri&&(r=i.uri)),this.logger_(`playlist update [${r} => ${e.id||e.uri}]`),this.mediaSequenceSync_&&(this.mediaSequenceSync_.update(e,this.currentTime_()),this.logger_(`Playlist update:
currentTime: ${this.currentTime_()}
bufferedEnd: ${Iy(this.buffered_())}
`,this.mediaSequenceSync_.diagnostics)),this.trigger("syncinfoupdate"),this.state==="INIT"&&this.couldBeginLoading_())return this.init_();if(!i||i.uri!==e.uri){this.mediaIndex!==null&&(!e.endList&&typeof e.partTargetDuration=="number"?this.resetLoader():this.resyncLoader()),this.currentMediaInfo_=void 0,this.trigger("playlistupdate");return}const o=e.mediaSequence-i.mediaSequence;if(this.logger_(`live window shift [${o}]`),this.mediaIndex!==null)if(this.mediaIndex-=o,this.mediaIndex<0)this.mediaIndex=null,this.partIndex=null;else{const u=this.playlist_.segments[this.mediaIndex];if(this.partIndex&&(!u.parts||!u.parts.length||!u.parts[this.partIndex])){const c=this.mediaIndex;this.logger_(`currently processing part (index ${this.partIndex}) no longer exists.`),this.resetLoader(),this.mediaIndex=c}}n&&(n.mediaIndex-=o,n.mediaIndex<0?(n.mediaIndex=null,n.partIndex=null):(n.mediaIndex>=0&&(n.segment=e.segments[n.mediaIndex]),n.partIndex>=0&&n.segment.parts&&(n.part=n.segment.parts[n.partIndex]))),this.syncController_.saveExpiredSegmentInfo(i,e)}pause(){this.checkBufferTimeout_&&(ne.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=null)}paused(){return this.checkBufferTimeout_===null}resetEverything(e){this.ended_=!1,this.activeInitSegmentId_=null,this.appendInitSegment_={audio:!0,video:!0},this.resetLoader(),this.remove(0,1/0,e),this.transmuxer_&&(this.transmuxer_.postMessage({action:"clearAllMp4Captions"}),this.transmuxer_.postMessage({action:"reset"}))}resetLoader(){this.fetchAtBuffer_=!1,this.mediaSequenceSync_&&this.mediaSequenceSync_.resetAppendedStatus(),this.resyncLoader()}resyncLoader(){this.transmuxer_&&Ry.reset(this.transmuxer_),this.mediaIndex=null,this.partIndex=null,this.syncPoint_=null,this.isPendingTimestampOffset_=!1;const e=this.currentMediaInfo_&&this.currentMediaInfo_.isFmp4;this.sourceType_==="hls"&&!e&&(this.shouldForceTimestampOffsetAfterResync_=!0),this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_.id3=[],this.metadataQueue_.caption=[],this.abort(),this.transmuxer_&&this.transmuxer_.postMessage({action:"clearParsedMp4Captions"})}remove(e,t,i=()=>{},n=!1){if(t===1/0&&(t=this.duration_()),t<=e){this.logger_("skipping remove because end ${end} is <= start ${start}");return}if(!this.sourceUpdater_||!this.getMediaInfo_()){this.logger_("skipping remove because no source updater or starting media info");return}let r=1;const o=()=>{r--,r===0&&i()};(n||!this.audioDisabled_)&&(r++,this.sourceUpdater_.removeAudio(e,t,o)),(n||this.loaderType_==="main")&&(this.gopBuffer_=m4(this.gopBuffer_,e,t,this.timeMapping_),r++,this.sourceUpdater_.removeVideo(e,t,o));for(const u in this.inbandTextTracks_)Ld(e,t,this.inbandTextTracks_[u]);Ld(e,t,this.segmentMetadataTrack_),o()}monitorBuffer_(){this.checkBufferTimeout_&&ne.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=ne.setTimeout(this.monitorBufferTick_.bind(this),1)}monitorBufferTick_(){this.state==="READY"&&this.fillBuffer_(),this.checkBufferTimeout_&&ne.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=ne.setTimeout(this.monitorBufferTick_.bind(this),v4)}fillBuffer_(){if(this.sourceUpdater_.updating())return;const e=this.chooseNextRequest_();if(!e)return;const t={segmentInfo:fl({type:this.loaderType_,segment:e})};this.trigger({type:"segmentselected",metadata:t}),typeof e.timestampOffset=="number"&&(this.isPendingTimestampOffset_=!1,this.timelineChangeController_.pendingTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:e.timeline})),this.loadSegment_(e)}isEndOfStream_(e=this.mediaIndex,t=this.playlist_,i=this.partIndex){if(!t||!this.mediaSource_)return!1;const n=typeof e=="number"&&t.segments[e],r=e+1===t.segments.length,o=!n||!n.parts||i+1===n.parts.length;return t.endList&&this.mediaSource_.readyState==="open"&&r&&o}chooseNextRequest_(){const e=this.buffered_(),t=Iy(e)||0,i=zT(e,this.currentTime_()),n=!this.hasPlayed_()&&i>=1,r=i>=this.goalBufferLength_(),o=this.playlist_.segments;if(!o.length||n||r)return null;this.syncPoint_=this.syncPoint_||this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_(),this.loaderType_);const u={partIndex:null,mediaIndex:null,startOfSegment:null,playlist:this.playlist_,isSyncRequest:!this.syncPoint_};if(u.isSyncRequest)u.mediaIndex=y4(this.currentTimeline_,o,t),this.logger_(`choose next request. Can not find sync point. Fallback to media Index: ${u.mediaIndex}`);else if(this.mediaIndex!==null){const g=o[this.mediaIndex],v=typeof this.partIndex=="number"?this.partIndex:-1;u.startOfSegment=g.end?g.end:t,g.parts&&g.parts[v+1]?(u.mediaIndex=this.mediaIndex,u.partIndex=v+1):u.mediaIndex=this.mediaIndex+1}else{let g,v,b;const _=this.fetchAtBuffer_?t:this.currentTime_();if(this.mediaSequenceSync_&&this.logger_(`chooseNextRequest_ request after Quality Switch:
For TargetTime: ${_}.
CurrentTime: ${this.currentTime_()}
BufferedEnd: ${t}
Fetch At Buffer: ${this.fetchAtBuffer_}
`,this.mediaSequenceSync_.diagnostics),this.mediaSequenceSync_&&this.mediaSequenceSync_.isReliable){const E=this.getSyncInfoFromMediaSequenceSync_(_);if(!E){const w="No sync info found while using media sequence sync";return this.error({message:w,metadata:{errorType:Te.Error.StreamingFailedToSelectNextSegment,error:new Error(w)}}),this.logger_("chooseNextRequest_ - no sync info found using media sequence sync"),null}this.logger_(`chooseNextRequest_ mediaSequence syncInfo (${E.start} --> ${E.end})`),g=E.segmentIndex,v=E.partIndex,b=E.start}else{this.logger_("chooseNextRequest_ - fallback to a regular segment selection algorithm, based on a syncPoint.");const E=en.getMediaInfoForTime({exactManifestTimings:this.exactManifestTimings,playlist:this.playlist_,currentTime:_,startingPartIndex:this.syncPoint_.partIndex,startingSegmentIndex:this.syncPoint_.segmentIndex,startTime:this.syncPoint_.time});g=E.segmentIndex,v=E.partIndex,b=E.startTime}u.getMediaInfoForTime=this.fetchAtBuffer_?`bufferedEnd ${_}`:`currentTime ${_}`,u.mediaIndex=g,u.startOfSegment=b,u.partIndex=v,this.logger_(`choose next request. Playlist switched and we have a sync point. Media Index: ${u.mediaIndex} `)}const c=o[u.mediaIndex];let d=c&&typeof u.partIndex=="number"&&c.parts&&c.parts[u.partIndex];if(!c||typeof u.partIndex=="number"&&!d)return null;typeof u.partIndex!="number"&&c.parts&&(u.partIndex=0,d=c.parts[0]);const f=this.vhs_.playlists&&this.vhs_.playlists.main&&this.vhs_.playlists.main.independentSegments||this.playlist_.independentSegments;if(!i&&d&&!f&&!d.independent)if(u.partIndex===0){const g=o[u.mediaIndex-1],v=g.parts&&g.parts.length&&g.parts[g.parts.length-1];v&&v.independent&&(u.mediaIndex-=1,u.partIndex=g.parts.length-1,u.independent="previous segment")}else c.parts[u.partIndex-1].independent&&(u.partIndex-=1,u.independent="previous part");const m=this.mediaSource_&&this.mediaSource_.readyState==="ended";return u.mediaIndex>=o.length-1&&m&&!this.seeking_()?null:(this.shouldForceTimestampOffsetAfterResync_&&(this.shouldForceTimestampOffsetAfterResync_=!1,u.forceTimestampOffset=!0,this.logger_("choose next request. Force timestamp offset after loader resync")),this.generateSegmentInfo_(u))}getSyncInfoFromMediaSequenceSync_(e){if(!this.mediaSequenceSync_)return null;const t=Math.max(e,this.mediaSequenceSync_.start);e!==t&&this.logger_(`getSyncInfoFromMediaSequenceSync_. Pulled target time from ${e} to ${t}`);const i=this.mediaSequenceSync_.getSyncInfoForTime(t);if(!i)return null;if(!i.isAppended)return i;const n=this.mediaSequenceSync_.getSyncInfoForTime(i.end);return n?(n.isAppended&&this.logger_("getSyncInfoFromMediaSequenceSync_: We encounter unexpected scenario where next media sequence sync info is also appended!"),n):null}generateSegmentInfo_(e){const{independent:t,playlist:i,mediaIndex:n,startOfSegment:r,isSyncRequest:o,partIndex:u,forceTimestampOffset:c,getMediaInfoForTime:d}=e,f=i.segments[n],m=typeof u=="number"&&f.parts[u],g={requestId:"segment-loader-"+Math.random(),uri:m&&m.resolvedUri||f.resolvedUri,mediaIndex:n,partIndex:m?u:null,isSyncRequest:o,startOfSegment:r,playlist:i,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:f.timeline,duration:m&&m.duration||f.duration,segment:f,part:m,byteLength:0,transmuxer:this.transmuxer_,getMediaInfoForTime:d,independent:t},v=typeof c<"u"?c:this.isPendingTimestampOffset_;g.timestampOffset=this.timestampOffsetForSegment_({segmentTimeline:f.timeline,currentTimeline:this.currentTimeline_,startOfSegment:r,buffered:this.buffered_(),overrideCheck:v});const b=Iy(this.sourceUpdater_.audioBuffered());return typeof b=="number"&&(g.audioAppendStart=b-this.sourceUpdater_.audioTimestampOffset()),this.sourceUpdater_.videoBuffered().length&&(g.gopsToAlignWith=f4(this.gopBuffer_,this.currentTime_()-this.sourceUpdater_.videoTimestampOffset(),this.timeMapping_)),g}timestampOffsetForSegment_(e){return _4(e)}earlyAbortWhenNeeded_(e){if(this.vhs_.tech_.paused()||!this.xhrOptions_.timeout||!this.playlist_.attributes.BANDWIDTH||Date.now()-(e.firstBytesReceivedAt||Date.now())<1e3)return;const t=this.currentTime_(),i=e.bandwidth,n=this.pendingSegment_.duration,r=en.estimateSegmentRequestTime(n,i,this.playlist_,e.bytesReceived),o=G3(this.buffered_(),t,this.vhs_.tech_.playbackRate())-1;if(r<=o)return;const u=i4({main:this.vhs_.playlists.main,currentTime:t,bandwidth:i,duration:this.duration_(),segmentDuration:n,timeUntilRebuffer:o,currentTimeline:this.currentTimeline_,syncController:this.syncController_});if(!u)return;const d=r-o-u.rebufferingImpact;let f=.5;o<=Lr&&(f=1),!(!u.playlist||u.playlist.uri===this.playlist_.uri||d<f)&&(this.bandwidth=u.playlist.attributes.BANDWIDTH*os.BANDWIDTH_VARIANCE+1,this.trigger("earlyabort"))}handleAbort_(e){this.logger_(`Aborting ${xu(e)}`),this.mediaRequestsAborted+=1}handleProgress_(e,t){this.earlyAbortWhenNeeded_(t.stats),!this.checkForAbort_(t.requestId)&&this.trigger("progress")}handleTrackInfo_(e,t){const{hasAudio:i,hasVideo:n}=t,r={segmentInfo:fl({type:this.loaderType_,segment:e}),trackInfo:{hasAudio:i,hasVideo:n}};this.trigger({type:"segmenttransmuxingtrackinfoavailable",metadata:r}),this.earlyAbortWhenNeeded_(e.stats),!this.checkForAbort_(e.requestId)&&(this.checkForIllegalMediaSwitch(t)||(t=t||{},g4(this.currentMediaInfo_,t)||(this.appendInitSegment_={audio:!0,video:!0},this.startingMediaInfo_=t,this.currentMediaInfo_=t,this.logger_("trackinfo update",t),this.trigger("trackinfo")),!this.checkForAbort_(e.requestId)&&(this.pendingSegment_.trackInfo=t,this.hasEnoughInfoToAppend_()?this.processCallQueue_():lo(this))))}handleTimingInfo_(e,t,i,n){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;const r=this.pendingSegment_,o=d1(t);r[o]=r[o]||{},r[o][i]=n,this.logger_(`timinginfo: ${t} - ${i} - ${n}`),this.hasEnoughInfoToAppend_()?this.processCallQueue_():lo(this)}handleCaptions_(e,t){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(t.length===0){this.logger_("SegmentLoader received no captions from a caption event");return}if(!this.pendingSegment_.hasAppendedData_){this.metadataQueue_.caption.push(this.handleCaptions_.bind(this,e,t));return}const n=this.sourceUpdater_.videoTimestampOffset()===null?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset(),r={};t.forEach(o=>{r[o.stream]=r[o.stream]||{startTime:1/0,captions:[],endTime:0};const u=r[o.stream];u.startTime=Math.min(u.startTime,o.startTime+n),u.endTime=Math.max(u.endTime,o.endTime+n),u.captions.push(o)}),Object.keys(r).forEach(o=>{const{startTime:u,endTime:c,captions:d}=r[o],f=this.inbandTextTracks_;this.logger_(`adding cues from ${u} -> ${c} for ${o}`),r4(f,this.vhs_.tech_,o),Ld(u,c,f[o]),a4({captionArray:d,inbandTextTracks:f,timestampOffset:n})}),this.transmuxer_&&this.transmuxer_.postMessage({action:"clearParsedMp4Captions"})}handleId3_(e,t,i){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(!this.pendingSegment_.hasAppendedData_){this.metadataQueue_.id3.push(this.handleId3_.bind(this,e,t,i));return}this.addMetadataToTextTrack(i,t,this.duration_())}processMetadataQueue_(){this.metadataQueue_.id3.forEach(e=>e()),this.metadataQueue_.caption.forEach(e=>e()),this.metadataQueue_.id3=[],this.metadataQueue_.caption=[]}processCallQueue_(){const e=this.callQueue_;this.callQueue_=[],e.forEach(t=>t())}processLoadQueue_(){const e=this.loadQueue_;this.loadQueue_=[],e.forEach(t=>t())}hasEnoughInfoToLoad_(){if(this.loaderType_!=="audio")return!0;const e=this.pendingSegment_;return e?this.getCurrentMediaInfo_()?!Fv({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}):!0:!1}getCurrentMediaInfo_(e=this.pendingSegment_){return e&&e.trackInfo||this.currentMediaInfo_}getMediaInfo_(e=this.pendingSegment_){return this.getCurrentMediaInfo_(e)||this.startingMediaInfo_}getPendingSegmentPlaylist(){return this.pendingSegment_?this.pendingSegment_.playlist:null}hasEnoughInfoToAppend_(){if(!this.sourceUpdater_.ready()||this.waitingOnRemove_||this.quotaExceededErrorRetryTimeout_)return!1;const e=this.pendingSegment_,t=this.getCurrentMediaInfo_();if(!e||!t)return!1;const{hasAudio:i,hasVideo:n,isMuxed:r}=t;return!(n&&!e.videoTimingInfo||i&&!this.audioDisabled_&&!r&&!e.audioTimingInfo||Fv({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}))}handleData_(e,t){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(this.callQueue_.length||!this.hasEnoughInfoToAppend_()){lo(this),this.callQueue_.push(this.handleData_.bind(this,e,t));return}const i=this.pendingSegment_;if(this.setTimeMapping_(i.timeline),this.updateMediaSecondsLoaded_(i.part||i.segment),this.mediaSource_.readyState!=="closed"){if(e.map&&(e.map=this.initSegmentForMap(e.map,!0),i.segment.map=e.map),e.key&&this.segmentKey(e.key,!0),i.isFmp4=e.isFmp4,i.timingInfo=i.timingInfo||{},i.isFmp4)this.trigger("fmp4"),i.timingInfo.start=i[d1(t.type)].start;else{const n=this.getCurrentMediaInfo_(),r=this.loaderType_==="main"&&n&&n.hasVideo;let o;r&&(o=i.videoTimingInfo.start),i.timingInfo.start=this.trueSegmentStart_({currentStart:i.timingInfo.start,playlist:i.playlist,mediaIndex:i.mediaIndex,currentVideoTimestampOffset:this.sourceUpdater_.videoTimestampOffset(),useVideoTimingInfo:r,firstVideoFrameTimeForData:o,videoTimingInfo:i.videoTimingInfo,audioTimingInfo:i.audioTimingInfo})}if(this.updateAppendInitSegmentStatus(i,t.type),this.updateSourceBufferTimestampOffset_(i),i.isSyncRequest){this.updateTimingInfoEnd_(i),this.syncController_.saveSegmentTimingInfo({segmentInfo:i,shouldSaveTimelineMapping:this.loaderType_==="main"});const n=this.chooseNextRequest_();if(n.mediaIndex!==i.mediaIndex||n.partIndex!==i.partIndex){this.logger_("sync segment was incorrect, not appending");return}this.logger_("sync segment was correct, appending")}i.hasAppendedData_=!0,this.processMetadataQueue_(),this.appendData_(i,t)}}updateAppendInitSegmentStatus(e,t){this.loaderType_==="main"&&typeof e.timestampOffset=="number"&&!e.changedTimestampOffset&&(this.appendInitSegment_={audio:!0,video:!0}),this.playlistOfLastInitSegment_[t]!==e.playlist&&(this.appendInitSegment_[t]=!0)}getInitSegmentAndUpdateState_({type:e,initSegment:t,map:i,playlist:n}){if(i){const r=Yp(i);if(this.activeInitSegmentId_===r)return null;t=this.initSegmentForMap(i,!0).bytes,this.activeInitSegmentId_=r}return t&&this.appendInitSegment_[e]?(this.playlistOfLastInitSegment_[e]=n,this.appendInitSegment_[e]=!1,this.activeInitSegmentId_=null,t):null}handleQuotaExceededError_({segmentInfo:e,type:t,bytes:i},n){const r=this.sourceUpdater_.audioBuffered(),o=this.sourceUpdater_.videoBuffered();r.length>1&&this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the audio buffer: "+gl(r).join(", ")),o.length>1&&this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the video buffer: "+gl(o).join(", "));const u=r.length?r.start(0):0,c=r.length?r.end(r.length-1):0,d=o.length?o.start(0):0,f=o.length?o.end(o.length-1):0;if(c-u<=xd&&f-d<=xd){this.logger_(`On QUOTA_EXCEEDED_ERR, single segment too large to append to buffer, triggering an error. Appended byte length: ${i.byteLength}, audio buffer: ${gl(r).join(", ")}, video buffer: ${gl(o).join(", ")}, `),this.error({message:"Quota exceeded error with append of a single segment of content",excludeUntil:1/0}),this.trigger("error");return}this.waitingOnRemove_=!0,this.callQueue_.push(this.appendToSourceBuffer_.bind(this,{segmentInfo:e,type:t,bytes:i}));const g=this.currentTime_()-xd;this.logger_(`On QUOTA_EXCEEDED_ERR, removing audio/video from 0 to ${g}`),this.remove(0,g,()=>{this.logger_(`On QUOTA_EXCEEDED_ERR, retrying append in ${xd}s`),this.waitingOnRemove_=!1,this.quotaExceededErrorRetryTimeout_=ne.setTimeout(()=>{this.logger_("On QUOTA_EXCEEDED_ERR, re-processing call queue"),this.quotaExceededErrorRetryTimeout_=null,this.processCallQueue_()},xd*1e3)},!0)}handleAppendError_({segmentInfo:e,type:t,bytes:i},n){if(n){if(n.code===AD){this.handleQuotaExceededError_({segmentInfo:e,type:t,bytes:i});return}this.logger_("Received non QUOTA_EXCEEDED_ERR on append",n),this.error({message:`${t} append of ${i.length}b failed for segment #${e.mediaIndex} in playlist ${e.playlist.id}`,metadata:{errorType:Te.Error.StreamingFailedToAppendSegment}}),this.trigger("appenderror")}}appendToSourceBuffer_({segmentInfo:e,type:t,initSegment:i,data:n,bytes:r}){if(!r){const u=[n];let c=n.byteLength;i&&(u.unshift(i),c+=i.byteLength),r=n4({bytes:c,segments:u})}const o={segmentInfo:fl({type:this.loaderType_,segment:e})};this.trigger({type:"segmentappendstart",metadata:o}),this.sourceUpdater_.appendBuffer({segmentInfo:e,type:t,bytes:r},this.handleAppendError_.bind(this,{segmentInfo:e,type:t,bytes:r}))}handleSegmentTimingInfo_(e,t,i){if(!this.pendingSegment_||t!==this.pendingSegment_.requestId)return;const n=this.pendingSegment_.segment,r=`${e}TimingInfo`;n[r]||(n[r]={}),n[r].transmuxerPrependedSeconds=i.prependedContentDuration||0,n[r].transmuxedPresentationStart=i.start.presentation,n[r].transmuxedDecodeStart=i.start.decode,n[r].transmuxedPresentationEnd=i.end.presentation,n[r].transmuxedDecodeEnd=i.end.decode,n[r].baseMediaDecodeTime=i.baseMediaDecodeTime}appendData_(e,t){const{type:i,data:n}=t;if(!n||!n.byteLength||i==="audio"&&this.audioDisabled_)return;const r=this.getInitSegmentAndUpdateState_({type:i,initSegment:t.initSegment,playlist:e.playlist,map:e.isFmp4?e.segment.map:null});this.appendToSourceBuffer_({segmentInfo:e,type:i,initSegment:r,data:n})}loadSegment_(e){if(this.state="WAITING",this.pendingSegment_=e,this.trimBackBuffer_(e),typeof e.timestampOffset=="number"&&this.transmuxer_&&this.transmuxer_.postMessage({action:"clearAllMp4Captions"}),!this.hasEnoughInfoToLoad_()){lo(this),this.loadQueue_.push(()=>{const t=Hi({},e,{forceTimestampOffset:!0});Hi(e,this.generateSegmentInfo_(t)),this.isPendingTimestampOffset_=!1,this.updateTransmuxerAndRequestSegment_(e)});return}this.updateTransmuxerAndRequestSegment_(e)}updateTransmuxerAndRequestSegment_(e){this.shouldUpdateTransmuxerTimestampOffset_(e.timestampOffset)&&(this.gopBuffer_.length=0,e.gopsToAlignWith=[],this.timeMapping_=0,this.transmuxer_.postMessage({action:"reset"}),this.transmuxer_.postMessage({action:"setTimestampOffset",timestampOffset:e.timestampOffset}));const t=this.createSimplifiedSegmentObj_(e),i=this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex),n=this.mediaIndex!==null,r=e.timeline!==this.currentTimeline_&&e.timeline>0,o=i||n&&r;this.logger_(`Requesting
${XD(e.uri)}
${xu(e)}`),t.map&&!t.map.bytes&&(this.logger_("going to request init segment."),this.appendInitSegment_={video:!0,audio:!0}),e.abortRequests=J5({xhr:this.vhs_.xhr,xhrOptions:this.xhrOptions_,decryptionWorker:this.decrypter_,segment:t,abortFn:this.handleAbort_.bind(this,e),progressFn:this.handleProgress_.bind(this),trackInfoFn:this.handleTrackInfo_.bind(this),timingInfoFn:this.handleTimingInfo_.bind(this),videoSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,"video",e.requestId),audioSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,"audio",e.requestId),captionsFn:this.handleCaptions_.bind(this),isEndOfTimeline:o,endedTimelineFn:()=>{this.logger_("received endedtimeline callback")},id3Fn:this.handleId3_.bind(this),dataFn:this.handleData_.bind(this),doneFn:this.segmentRequestFinished_.bind(this),onTransmuxerLog:({message:u,level:c,stream:d})=>{this.logger_(`${xu(e)} logged from transmuxer stream ${d} as a ${c}: ${u}`)},triggerSegmentEventFn:({type:u,segment:c,keyInfo:d,trackInfo:f,timingInfo:m})=>{const v={segmentInfo:fl({segment:c})};d&&(v.keyInfo=d),f&&(v.trackInfo=f),m&&(v.timingInfo=m),this.trigger({type:u,metadata:v})}})}trimBackBuffer_(e){const t=b4(this.seekable_(),this.currentTime_(),this.playlist_.targetDuration||10);t>0&&this.remove(0,t)}createSimplifiedSegmentObj_(e){const t=e.segment,i=e.part,n=e.segment.key||e.segment.map&&e.segment.map.key,r=e.segment.map&&!e.segment.map.bytes,o={resolvedUri:i?i.resolvedUri:t.resolvedUri,byterange:i?i.byterange:t.byterange,requestId:e.requestId,transmuxer:e.transmuxer,audioAppendStart:e.audioAppendStart,gopsToAlignWith:e.gopsToAlignWith,part:e.part,type:this.loaderType_,start:e.startOfSegment,duration:e.duration,isEncrypted:n,isMediaInitialization:r},u=e.playlist.segments[e.mediaIndex-1];if(u&&u.timeline===t.timeline&&(u.videoTimingInfo?o.baseStartTime=u.videoTimingInfo.transmuxedDecodeEnd:u.audioTimingInfo&&(o.baseStartTime=u.audioTimingInfo.transmuxedDecodeEnd)),t.key){const c=t.key.iv||new Uint32Array([0,0,0,e.mediaIndex+e.playlist.mediaSequence]);o.key=this.segmentKey(t.key),o.key.iv=c}return t.map&&(o.map=this.initSegmentForMap(t.map)),o}saveTransferStats_(e){this.mediaRequests+=1,e&&(this.mediaBytesTransferred+=e.bytesReceived,this.mediaTransferDuration+=e.roundTripTime)}saveBandwidthRelatedStats_(e,t){if(this.pendingSegment_.byteLength=t.bytesReceived,e<Wf){this.logger_(`Ignoring segment's bandwidth because its duration of ${e} is less than the min to record ${Wf}`);return}const i={bandwidthInfo:{from:this.bandwidth,to:t.bandwidth}};this.trigger({type:"bandwidthupdated",metadata:i}),this.bandwidth=t.bandwidth,this.roundTrip=t.roundTripTime}handleTimeout_(){this.mediaRequestsTimedout+=1,this.bandwidth=1,this.roundTrip=NaN,this.trigger("bandwidthupdate"),this.trigger("timeout")}segmentRequestFinished_(e,t,i){if(this.callQueue_.length){this.callQueue_.push(this.segmentRequestFinished_.bind(this,e,t,i));return}if(this.saveTransferStats_(t.stats),!this.pendingSegment_||t.requestId!==this.pendingSegment_.requestId)return;if(e){if(this.pendingSegment_=null,this.state="READY",e.code===kr.ABORTED)return;if(this.pause(),e.code===kr.TIMEOUT){this.handleTimeout_();return}this.mediaRequestsErrored+=1,this.error(e),this.trigger("error");return}const n=this.pendingSegment_;this.saveBandwidthRelatedStats_(n.duration,t.stats),n.endOfAllRequests=t.endOfAllRequests,i.gopInfo&&(this.gopBuffer_=p4(this.gopBuffer_,i.gopInfo,this.safeAppend_)),this.state="APPENDING",this.trigger("appending"),this.waitForAppendsToComplete_(n)}setTimeMapping_(e){const t=this.syncController_.mappingForTimeline(e);t!==null&&(this.timeMapping_=t)}updateMediaSecondsLoaded_(e){typeof e.start=="number"&&typeof e.end=="number"?this.mediaSecondsLoaded+=e.end-e.start:this.mediaSecondsLoaded+=e.duration}shouldUpdateTransmuxerTimestampOffset_(e){return e===null?!1:this.loaderType_==="main"&&e!==this.sourceUpdater_.videoTimestampOffset()||!this.audioDisabled_&&e!==this.sourceUpdater_.audioTimestampOffset()}trueSegmentStart_({currentStart:e,playlist:t,mediaIndex:i,firstVideoFrameTimeForData:n,currentVideoTimestampOffset:r,useVideoTimingInfo:o,videoTimingInfo:u,audioTimingInfo:c}){if(typeof e<"u")return e;if(!o)return c.start;const d=t.segments[i-1];return i===0||!d||typeof d.start>"u"||d.end!==n+r?n:u.start}waitForAppendsToComplete_(e){const t=this.getCurrentMediaInfo_(e);if(!t){this.error({message:"No starting media returned, likely due to an unsupported media format.",playlistExclusionDuration:1/0}),this.trigger("error");return}const{hasAudio:i,hasVideo:n,isMuxed:r}=t,o=this.loaderType_==="main"&&n,u=!this.audioDisabled_&&i&&!r;if(e.waitingOnAppends=0,!e.hasAppendedData_){!e.timingInfo&&typeof e.timestampOffset=="number"&&(this.isPendingTimestampOffset_=!0),e.timingInfo={start:0},e.waitingOnAppends++,this.isPendingTimestampOffset_||(this.updateSourceBufferTimestampOffset_(e),this.processMetadataQueue_()),this.checkAppendsDone_(e);return}o&&e.waitingOnAppends++,u&&e.waitingOnAppends++,o&&this.sourceUpdater_.videoQueueCallback(this.checkAppendsDone_.bind(this,e)),u&&this.sourceUpdater_.audioQueueCallback(this.checkAppendsDone_.bind(this,e))}checkAppendsDone_(e){this.checkForAbort_(e.requestId)||(e.waitingOnAppends--,e.waitingOnAppends===0&&this.handleAppendsDone_())}checkForIllegalMediaSwitch(e){const t=T4(this.loaderType_,this.getCurrentMediaInfo_(),e);return t?(this.error({message:t,playlistExclusionDuration:1/0}),this.trigger("error"),!0):!1}updateSourceBufferTimestampOffset_(e){if(e.timestampOffset===null||typeof e.timingInfo.start!="number"||e.changedTimestampOffset||this.loaderType_!=="main")return;let t=!1;e.timestampOffset-=this.getSegmentStartTimeForTimestampOffsetCalculation_({videoTimingInfo:e.segment.videoTimingInfo,audioTimingInfo:e.segment.audioTimingInfo,timingInfo:e.timingInfo}),e.changedTimestampOffset=!0,e.timestampOffset!==this.sourceUpdater_.videoTimestampOffset()&&(this.sourceUpdater_.videoTimestampOffset(e.timestampOffset),t=!0),e.timestampOffset!==this.sourceUpdater_.audioTimestampOffset()&&(this.sourceUpdater_.audioTimestampOffset(e.timestampOffset),t=!0),t&&this.trigger("timestampoffset")}getSegmentStartTimeForTimestampOffsetCalculation_({videoTimingInfo:e,audioTimingInfo:t,timingInfo:i}){return this.useDtsForTimestampOffset_?e&&typeof e.transmuxedDecodeStart=="number"?e.transmuxedDecodeStart:t&&typeof t.transmuxedDecodeStart=="number"?t.transmuxedDecodeStart:i.start:i.start}updateTimingInfoEnd_(e){e.timingInfo=e.timingInfo||{};const t=this.getMediaInfo_(),n=this.loaderType_==="main"&&t&&t.hasVideo&&e.videoTimingInfo?e.videoTimingInfo:e.audioTimingInfo;n&&(e.timingInfo.end=typeof n.end=="number"?n.end:n.start+e.duration)}handleAppendsDone_(){if(this.pendingSegment_){const c={segmentInfo:fl({type:this.loaderType_,segment:this.pendingSegment_})};this.trigger({type:"appendsdone",metadata:c})}if(!this.pendingSegment_){this.state="READY",this.paused()||this.monitorBuffer_();return}const e=this.pendingSegment_;e.part&&e.part.syncInfo?e.part.syncInfo.markAppended():e.segment.syncInfo&&e.segment.syncInfo.markAppended(),this.updateTimingInfoEnd_(e),this.shouldSaveSegmentTimingInfo_&&this.syncController_.saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:this.loaderType_==="main"});const t=A4(e,this.sourceType_);if(t&&(t.severity==="warn"?Te.log.warn(t.message):this.logger_(t.message)),this.recordThroughput_(e),this.pendingSegment_=null,this.state="READY",e.isSyncRequest&&(this.trigger("syncinfoupdate"),!e.hasAppendedData_)){this.logger_(`Throwing away un-appended sync request ${xu(e)}`);return}this.logger_(`Appended ${xu(e)}`),this.addSegmentMetadataCue_(e),this.fetchAtBuffer_=!0,this.currentTimeline_!==e.timeline&&(this.timelineChangeController_.lastTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:e.timeline}),this.loaderType_==="main"&&!this.audioDisabled_&&this.timelineChangeController_.lastTimelineChange({type:"audio",from:this.currentTimeline_,to:e.timeline})),this.currentTimeline_=e.timeline,this.trigger("syncinfoupdate");const i=e.segment,n=e.part,r=i.end&&this.currentTime_()-i.end>e.playlist.targetDuration*3,o=n&&n.end&&this.currentTime_()-n.end>e.playlist.partTargetDuration*3;if(r||o){this.logger_(`bad ${r?"segment":"part"} ${xu(e)}`),this.resetEverything();return}this.mediaIndex!==null&&this.trigger("bandwidthupdate"),this.trigger("progress"),this.mediaIndex=e.mediaIndex,this.partIndex=e.partIndex,this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex)&&this.endOfStream(),this.trigger("appended"),e.hasAppendedData_&&this.mediaAppends++,this.paused()||this.monitorBuffer_()}recordThroughput_(e){if(e.duration<Wf){this.logger_(`Ignoring segment's throughput because its duration of ${e.duration} is less than the min to record ${Wf}`);return}const t=this.throughput.rate,i=Date.now()-e.endOfAllRequests+1,n=Math.floor(e.byteLength/i*8*1e3);this.throughput.rate+=(n-t)/++this.throughput.count}addSegmentMetadataCue_(e){if(!this.segmentMetadataTrack_)return;const t=e.segment,i=t.start,n=t.end;if(!c1(i)||!c1(n))return;Ld(i,n,this.segmentMetadataTrack_);const r=ne.WebKitDataCue||ne.VTTCue,o={custom:t.custom,dateTimeObject:t.dateTimeObject,dateTimeString:t.dateTimeString,programDateTime:t.programDateTime,bandwidth:e.playlist.attributes.BANDWIDTH,resolution:e.playlist.attributes.RESOLUTION,codecs:e.playlist.attributes.CODECS,byteLength:e.byteLength,uri:e.uri,timeline:e.timeline,playlist:e.playlist.id,start:i,end:n},u=JSON.stringify(o),c=new r(i,n,u);c.value=o,this.segmentMetadataTrack_.addCue(c)}}function ga(){}const QD=function(s){return typeof s!="string"?s:s.replace(/./,e=>e.toUpperCase())},C4=["video","audio"],$v=(s,e)=>{const t=e[`${s}Buffer`];return t&&t.updating||e.queuePending[s]},D4=(s,e)=>{for(let t=0;t<e.length;t++){const i=e[t];if(i.type==="mediaSource")return null;if(i.type===s)return t}return null},Vu=(s,e)=>{if(e.queue.length===0)return;let t=0,i=e.queue[t];if(i.type==="mediaSource"){!e.updating()&&e.mediaSource.readyState!=="closed"&&(e.queue.shift(),i.action(e),i.doneFn&&i.doneFn(),Vu("audio",e),Vu("video",e));return}if(s!=="mediaSource"&&!(!e.ready()||e.mediaSource.readyState==="closed"||$v(s,e))){if(i.type!==s){if(t=D4(s,e.queue),t===null)return;i=e.queue[t]}if(e.queue.splice(t,1),e.queuePending[s]=i,i.action(s,e),!i.doneFn){e.queuePending[s]=null,Vu(s,e);return}}},ZD=(s,e)=>{const t=e[`${s}Buffer`],i=QD(s);t&&(t.removeEventListener("updateend",e[`on${i}UpdateEnd_`]),t.removeEventListener("error",e[`on${i}Error_`]),e.codecs[s]=null,e[`${s}Buffer`]=null)},Cr=(s,e)=>s&&e&&Array.prototype.indexOf.call(s.sourceBuffers,e)!==-1,mn={appendBuffer:(s,e,t)=>(i,n)=>{const r=n[`${i}Buffer`];if(Cr(n.mediaSource,r)){n.logger_(`Appending segment ${e.mediaIndex}'s ${s.length} bytes to ${i}Buffer`);try{r.appendBuffer(s)}catch(o){n.logger_(`Error with code ${o.code} `+(o.code===AD?"(QUOTA_EXCEEDED_ERR) ":"")+`when appending segment ${e.mediaIndex} to ${i}Buffer`),n.queuePending[i]=null,t(o)}}},remove:(s,e)=>(t,i)=>{const n=i[`${t}Buffer`];if(Cr(i.mediaSource,n)){i.logger_(`Removing ${s} to ${e} from ${t}Buffer`);try{n.remove(s,e)}catch{i.logger_(`Remove ${s} to ${e} from ${t}Buffer failed`)}}},timestampOffset:s=>(e,t)=>{const i=t[`${e}Buffer`];Cr(t.mediaSource,i)&&(t.logger_(`Setting ${e}timestampOffset to ${s}`),i.timestampOffset=s)},callback:s=>(e,t)=>{s()},endOfStream:s=>e=>{if(e.mediaSource.readyState==="open"){e.logger_(`Calling mediaSource endOfStream(${s||""})`);try{e.mediaSource.endOfStream(s)}catch(t){Te.log.warn("Failed to call media source endOfStream",t)}}},duration:s=>e=>{e.logger_(`Setting mediaSource duration to ${s}`);try{e.mediaSource.duration=s}catch(t){Te.log.warn("Failed to set media source duration",t)}},abort:()=>(s,e)=>{if(e.mediaSource.readyState!=="open")return;const t=e[`${s}Buffer`];if(Cr(e.mediaSource,t)){e.logger_(`calling abort on ${s}Buffer`);try{t.abort()}catch(i){Te.log.warn(`Failed to abort on ${s}Buffer`,i)}}},addSourceBuffer:(s,e)=>t=>{const i=QD(s),n=Wu(e);t.logger_(`Adding ${s}Buffer with codec ${e} to mediaSource`);const r=t.mediaSource.addSourceBuffer(n);r.addEventListener("updateend",t[`on${i}UpdateEnd_`]),r.addEventListener("error",t[`on${i}Error_`]),t.codecs[s]=e,t[`${s}Buffer`]=r},removeSourceBuffer:s=>e=>{const t=e[`${s}Buffer`];if(ZD(s,e),!!Cr(e.mediaSource,t)){e.logger_(`Removing ${s}Buffer with codec ${e.codecs[s]} from mediaSource`);try{e.mediaSource.removeSourceBuffer(t)}catch(i){Te.log.warn(`Failed to removeSourceBuffer ${s}Buffer`,i)}}},changeType:s=>(e,t)=>{const i=t[`${e}Buffer`],n=Wu(s);if(!Cr(t.mediaSource,i))return;const r=s.substring(0,s.indexOf(".")),o=t.codecs[e];if(o.substring(0,o.indexOf("."))===r)return;const c={codecsChangeInfo:{from:o,to:s}};t.trigger({type:"codecschange",metadata:c}),t.logger_(`changing ${e}Buffer codec from ${o} to ${s}`);try{i.changeType(n),t.codecs[e]=s}catch(d){c.errorType=Te.Error.StreamingCodecsChangeError,c.error=d,d.metadata=c,t.error_=d,t.trigger("error"),Te.log.warn(`Failed to changeType on ${e}Buffer`,d)}}},gn=({type:s,sourceUpdater:e,action:t,doneFn:i,name:n})=>{e.queue.push({type:s,action:t,doneFn:i,name:n}),Vu(s,e)},f1=(s,e)=>t=>{const i=e[`${s}Buffered`](),n=$3(i);if(e.logger_(`received "updateend" event for ${s} Source Buffer: `,n),e.queuePending[s]){const r=e.queuePending[s].doneFn;e.queuePending[s]=null,r&&r(e[`${s}Error_`])}Vu(s,e)};class JD extends Te.EventTarget{constructor(e){super(),this.mediaSource=e,this.sourceopenListener_=()=>Vu("mediaSource",this),this.mediaSource.addEventListener("sourceopen",this.sourceopenListener_),this.logger_=$n("SourceUpdater"),this.audioTimestampOffset_=0,this.videoTimestampOffset_=0,this.queue=[],this.queuePending={audio:null,video:null},this.delayedAudioAppendQueue_=[],this.videoAppendQueued_=!1,this.codecs={},this.onVideoUpdateEnd_=f1("video",this),this.onAudioUpdateEnd_=f1("audio",this),this.onVideoError_=t=>{this.videoError_=t},this.onAudioError_=t=>{this.audioError_=t},this.createdSourceBuffers_=!1,this.initializedEme_=!1,this.triggeredReady_=!1}initializedEme(){this.initializedEme_=!0,this.triggerReady()}hasCreatedSourceBuffers(){return this.createdSourceBuffers_}hasInitializedAnyEme(){return this.initializedEme_}ready(){return this.hasCreatedSourceBuffers()&&this.hasInitializedAnyEme()}createSourceBuffers(e){this.hasCreatedSourceBuffers()||(this.addOrChangeSourceBuffers(e),this.createdSourceBuffers_=!0,this.trigger("createdsourcebuffers"),this.triggerReady())}triggerReady(){this.ready()&&!this.triggeredReady_&&(this.triggeredReady_=!0,this.trigger("ready"))}addSourceBuffer(e,t){gn({type:"mediaSource",sourceUpdater:this,action:mn.addSourceBuffer(e,t),name:"addSourceBuffer"})}abort(e){gn({type:e,sourceUpdater:this,action:mn.abort(e),name:"abort"})}removeSourceBuffer(e){if(!this.canRemoveSourceBuffer()){Te.log.error("removeSourceBuffer is not supported!");return}gn({type:"mediaSource",sourceUpdater:this,action:mn.removeSourceBuffer(e),name:"removeSourceBuffer"})}canRemoveSourceBuffer(){return!Te.browser.IS_FIREFOX&&ne.MediaSource&&ne.MediaSource.prototype&&typeof ne.MediaSource.prototype.removeSourceBuffer=="function"}static canChangeType(){return ne.SourceBuffer&&ne.SourceBuffer.prototype&&typeof ne.SourceBuffer.prototype.changeType=="function"}canChangeType(){return this.constructor.canChangeType()}changeType(e,t){if(!this.canChangeType()){Te.log.error("changeType is not supported!");return}gn({type:e,sourceUpdater:this,action:mn.changeType(t),name:"changeType"})}addOrChangeSourceBuffers(e){if(!e||typeof e!="object"||Object.keys(e).length===0)throw new Error("Cannot addOrChangeSourceBuffers to undefined codecs");Object.keys(e).forEach(t=>{const i=e[t];if(!this.hasCreatedSourceBuffers())return this.addSourceBuffer(t,i);this.canChangeType()&&this.changeType(t,i)})}appendBuffer(e,t){const{segmentInfo:i,type:n,bytes:r}=e;if(this.processedAppend_=!0,n==="audio"&&this.videoBuffer&&!this.videoAppendQueued_){this.delayedAudioAppendQueue_.push([e,t]),this.logger_(`delayed audio append of ${r.length} until video append`);return}const o=t;if(gn({type:n,sourceUpdater:this,action:mn.appendBuffer(r,i||{mediaIndex:-1},o),doneFn:t,name:"appendBuffer"}),n==="video"){if(this.videoAppendQueued_=!0,!this.delayedAudioAppendQueue_.length)return;const u=this.delayedAudioAppendQueue_.slice();this.logger_(`queuing delayed audio ${u.length} appendBuffers`),this.delayedAudioAppendQueue_.length=0,u.forEach(c=>{this.appendBuffer.apply(this,c)})}}audioBuffered(){return Cr(this.mediaSource,this.audioBuffer)&&this.audioBuffer.buffered?this.audioBuffer.buffered:us()}videoBuffered(){return Cr(this.mediaSource,this.videoBuffer)&&this.videoBuffer.buffered?this.videoBuffer.buffered:us()}buffered(){const e=Cr(this.mediaSource,this.videoBuffer)?this.videoBuffer:null,t=Cr(this.mediaSource,this.audioBuffer)?this.audioBuffer:null;return t&&!e?this.audioBuffered():e&&!t?this.videoBuffered():H3(this.audioBuffered(),this.videoBuffered())}setDuration(e,t=ga){gn({type:"mediaSource",sourceUpdater:this,action:mn.duration(e),name:"duration",doneFn:t})}endOfStream(e=null,t=ga){typeof e!="string"&&(e=void 0),gn({type:"mediaSource",sourceUpdater:this,action:mn.endOfStream(e),name:"endOfStream",doneFn:t})}removeAudio(e,t,i=ga){if(!this.audioBuffered().length||this.audioBuffered().end(0)===0){i();return}gn({type:"audio",sourceUpdater:this,action:mn.remove(e,t),doneFn:i,name:"remove"})}removeVideo(e,t,i=ga){if(!this.videoBuffered().length||this.videoBuffered().end(0)===0){i();return}gn({type:"video",sourceUpdater:this,action:mn.remove(e,t),doneFn:i,name:"remove"})}updating(){return!!($v("audio",this)||$v("video",this))}audioTimestampOffset(e){return typeof e<"u"&&this.audioBuffer&&this.audioTimestampOffset_!==e&&(gn({type:"audio",sourceUpdater:this,action:mn.timestampOffset(e),name:"timestampOffset"}),this.audioTimestampOffset_=e),this.audioTimestampOffset_}videoTimestampOffset(e){return typeof e<"u"&&this.videoBuffer&&this.videoTimestampOffset_!==e&&(gn({type:"video",sourceUpdater:this,action:mn.timestampOffset(e),name:"timestampOffset"}),this.videoTimestampOffset_=e),this.videoTimestampOffset_}audioQueueCallback(e){this.audioBuffer&&gn({type:"audio",sourceUpdater:this,action:mn.callback(e),name:"callback"})}videoQueueCallback(e){this.videoBuffer&&gn({type:"video",sourceUpdater:this,action:mn.callback(e),name:"callback"})}dispose(){this.trigger("dispose"),C4.forEach(e=>{this.abort(e),this.canRemoveSourceBuffer()?this.removeSourceBuffer(e):this[`${e}QueueCallback`](()=>ZD(e,this))}),this.videoAppendQueued_=!1,this.delayedAudioAppendQueue_.length=0,this.sourceopenListener_&&this.mediaSource.removeEventListener("sourceopen",this.sourceopenListener_),this.off()}}const p1=s=>decodeURIComponent(escape(String.fromCharCode.apply(null,s))),w4=s=>{const e=new Uint8Array(s);return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")},m1=new Uint8Array(`
`.split("").map(s=>s.charCodeAt(0)));class L4 extends Error{constructor(){super("Trying to parse received VTT cues, but there is no WebVTT. Make sure vtt.js is loaded.")}}class I4 extends Uv{constructor(e,t={}){super(e,t),this.mediaSource_=null,this.subtitlesTrack_=null,this.featuresNativeTextTracks_=e.featuresNativeTextTracks,this.loadVttJs=e.loadVttJs,this.shouldSaveSegmentTimingInfo_=!1}buffered_(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues||!this.subtitlesTrack_.cues.length)return us();const e=this.subtitlesTrack_.cues,t=e[0].startTime,i=e[e.length-1].startTime;return us([[t,i]])}initSegmentForMap(e,t=!1){if(!e)return null;const i=Yp(e);let n=this.initSegments_[i];if(t&&!n&&e.bytes){const r=m1.byteLength+e.bytes.byteLength,o=new Uint8Array(r);o.set(e.bytes),o.set(m1,e.bytes.byteLength),this.initSegments_[i]=n={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:o}}return n||e}couldBeginLoading_(){return this.playlist_&&this.subtitlesTrack_&&!this.paused()}init_(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}track(e){return typeof e>"u"?this.subtitlesTrack_:(this.subtitlesTrack_=e,this.state==="INIT"&&this.couldBeginLoading_()&&this.init_(),this.subtitlesTrack_)}remove(e,t){Ld(e,t,this.subtitlesTrack_)}fillBuffer_(){const e=this.chooseNextRequest_();if(e){if(this.syncController_.timestampOffsetForTimeline(e.timeline)===null){const t=()=>{this.state="READY",this.paused()||this.monitorBuffer_()};this.syncController_.one("timestampoffset",t),this.state="WAITING_ON_TIMELINE";return}this.loadSegment_(e)}}timestampOffsetForSegment_(){return null}chooseNextRequest_(){return this.skipEmptySegments_(super.chooseNextRequest_())}skipEmptySegments_(e){for(;e&&e.segment.empty;){if(e.mediaIndex+1>=e.playlist.segments.length){e=null;break}e=this.generateSegmentInfo_({playlist:e.playlist,mediaIndex:e.mediaIndex+1,startOfSegment:e.startOfSegment+e.duration,isSyncRequest:e.isSyncRequest})}return e}stopForError(e){this.error(e),this.state="READY",this.pause(),this.trigger("error")}segmentRequestFinished_(e,t,i){if(!this.subtitlesTrack_){this.state="READY";return}if(this.saveTransferStats_(t.stats),!this.pendingSegment_){this.state="READY",this.mediaRequestsAborted+=1;return}if(e){e.code===kr.TIMEOUT&&this.handleTimeout_(),e.code===kr.ABORTED?this.mediaRequestsAborted+=1:this.mediaRequestsErrored+=1,this.stopForError(e);return}const n=this.pendingSegment_,r=i.mp4VttCues&&i.mp4VttCues.length;r&&(n.mp4VttCues=i.mp4VttCues),this.saveBandwidthRelatedStats_(n.duration,t.stats),t.key&&this.segmentKey(t.key,!0),this.state="APPENDING",this.trigger("appending");const o=n.segment;if(o.map&&(o.map.bytes=t.map.bytes),n.bytes=t.bytes,typeof ne.WebVTT!="function"&&typeof this.loadVttJs=="function"){this.state="WAITING_ON_VTTJS",this.loadVttJs().then(()=>this.segmentRequestFinished_(e,t,i),()=>this.stopForError({message:"Error loading vtt.js"}));return}o.requested=!0;try{this.parseVTTCues_(n)}catch(u){this.stopForError({message:u.message,metadata:{errorType:Te.Error.StreamingVttParserError,error:u}});return}if(r||this.updateTimeMapping_(n,this.syncController_.timelines[n.timeline],this.playlist_),n.cues.length?n.timingInfo={start:n.cues[0].startTime,end:n.cues[n.cues.length-1].endTime}:n.timingInfo={start:n.startOfSegment,end:n.startOfSegment+n.duration},n.isSyncRequest){this.trigger("syncinfoupdate"),this.pendingSegment_=null,this.state="READY";return}n.byteLength=n.bytes.byteLength,this.mediaSecondsLoaded+=o.duration,n.cues.forEach(u=>{this.subtitlesTrack_.addCue(this.featuresNativeTextTracks_?new ne.VTTCue(u.startTime,u.endTime,u.text):u)}),h4(this.subtitlesTrack_),this.handleAppendsDone_()}handleData_(e,t){const i=e&&e.type==="vtt",n=t&&t.type==="text";i&&n&&super.handleData_(e,t)}updateTimingInfoEnd_(){}parseMp4VttCues_(e){const t=this.sourceUpdater_.videoTimestampOffset()===null?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset();e.mp4VttCues.forEach(i=>{const n=i.start+t,r=i.end+t,o=new ne.VTTCue(n,r,i.cueText);i.settings&&i.settings.split(" ").forEach(u=>{const c=u.split(":"),d=c[0],f=c[1];o[d]=isNaN(f)?f:Number(f)}),e.cues.push(o)})}parseVTTCues_(e){let t,i=!1;if(typeof ne.WebVTT!="function")throw new L4;if(e.cues=[],e.timestampmap={MPEGTS:0,LOCAL:0},e.mp4VttCues){this.parseMp4VttCues_(e);return}typeof ne.TextDecoder=="function"?t=new ne.TextDecoder("utf8"):(t=ne.WebVTT.StringDecoder(),i=!0);const n=new ne.WebVTT.Parser(ne,ne.vttjs,t);if(n.oncue=e.cues.push.bind(e.cues),n.ontimestampmap=o=>{e.timestampmap=o},n.onparsingerror=o=>{Te.log.warn("Error encountered when parsing cues: "+o.message)},e.segment.map){let o=e.segment.map.bytes;i&&(o=p1(o)),n.parse(o)}let r=e.bytes;i&&(r=p1(r)),n.parse(r),n.flush()}updateTimeMapping_(e,t,i){const n=e.segment;if(!t)return;if(!e.cues.length){n.empty=!0;return}const{MPEGTS:r,LOCAL:o}=e.timestampmap,c=r/ml.ONE_SECOND_IN_TS-o+t.mapping;if(e.cues.forEach(d=>{const f=d.endTime-d.startTime,m=this.handleRollover_(d.startTime+c,t.time);d.startTime=Math.max(m,0),d.endTime=Math.max(m+f,0)}),!i.syncInfo){const d=e.cues[0].startTime,f=e.cues[e.cues.length-1].startTime;i.syncInfo={mediaSequence:i.mediaSequence+e.mediaIndex,time:Math.min(d,f-n.duration)}}}handleRollover_(e,t){if(t===null)return e;let i=e*ml.ONE_SECOND_IN_TS;const n=t*ml.ONE_SECOND_IN_TS;let r;for(n<i?r=-8589934592:r=8589934592;Math.abs(i-n)>4294967296;)i+=r;return i/ml.ONE_SECOND_IN_TS}}const k4=function(s,e){const t=s.cues;for(let i=0;i<t.length;i++){const n=t[i];if(e>=n.adStartTime&&e<=n.adEndTime)return n}return null},R4=function(s,e,t=0){if(!s.segments)return;let i=t,n;for(let r=0;r<s.segments.length;r++){const o=s.segments[r];if(n||(n=k4(e,i+o.duration/2)),n){if("cueIn"in o){n.endTime=i,n.adEndTime=i,i+=o.duration,n=null;continue}if(i<n.endTime){i+=o.duration;continue}n.endTime+=o.duration}else if("cueOut"in o&&(n=new ne.VTTCue(i,i+o.duration,o.cueOut),n.adStartTime=i,n.adEndTime=i+parseFloat(o.cueOut),e.addCue(n)),"cueOutCont"in o){const[u,c]=o.cueOutCont.split("/").map(parseFloat);n=new ne.VTTCue(i,i+o.duration,""),n.adStartTime=i-u,n.adEndTime=n.adStartTime+c,e.addCue(n)}i+=o.duration}};class g1{constructor({start:e,end:t,segmentIndex:i,partIndex:n=null,appended:r=!1}){this.start_=e,this.end_=t,this.segmentIndex_=i,this.partIndex_=n,this.appended_=r}isInRange(e){return e>=this.start&&e<this.end}markAppended(){this.appended_=!0}resetAppendedStatus(){this.appended_=!1}get isAppended(){return this.appended_}get start(){return this.start_}get end(){return this.end_}get segmentIndex(){return this.segmentIndex_}get partIndex(){return this.partIndex_}}class O4{constructor(e,t=[]){this.segmentSyncInfo_=e,this.partsSyncInfo_=t}get segmentSyncInfo(){return this.segmentSyncInfo_}get partsSyncInfo(){return this.partsSyncInfo_}get hasPartsSyncInfo(){return this.partsSyncInfo_.length>0}resetAppendStatus(){this.segmentSyncInfo_.resetAppendedStatus(),this.partsSyncInfo_.forEach(e=>e.resetAppendedStatus())}}class ew{constructor(){this.storage_=new Map,this.diagnostics_="",this.isReliable_=!1,this.start_=-1/0,this.end_=1/0}get start(){return this.start_}get end(){return this.end_}get diagnostics(){return this.diagnostics_}get isReliable(){return this.isReliable_}resetAppendedStatus(){this.storage_.forEach(e=>e.resetAppendStatus())}update(e,t){const{mediaSequence:i,segments:n}=e;if(this.isReliable_=this.isReliablePlaylist_(i,n),!!this.isReliable_)return this.updateStorage_(n,i,this.calculateBaseTime_(i,n,t))}getSyncInfoForTime(e){for(const{segmentSyncInfo:t,partsSyncInfo:i}of this.storage_.values())if(i.length){for(const n of i)if(n.isInRange(e))return n}else if(t.isInRange(e))return t;return null}getSyncInfoForMediaSequence(e){return this.storage_.get(e)}updateStorage_(e,t,i){const n=new Map;let r=`
`,o=i,u=t;this.start_=o,e.forEach((c,d)=>{const f=this.storage_.get(u),m=o,g=m+c.duration,v=!!(f&&f.segmentSyncInfo&&f.segmentSyncInfo.isAppended),b=new g1({start:m,end:g,appended:v,segmentIndex:d});c.syncInfo=b;let _=o;const E=(c.parts||[]).map((w,I)=>{const L=_,F=_+w.duration,$=!!(f&&f.partsSyncInfo&&f.partsSyncInfo[I]&&f.partsSyncInfo[I].isAppended),G=new g1({start:L,end:F,appended:$,segmentIndex:d,partIndex:I});return _=F,r+=`Media Sequence: ${u}.${I} | Range: ${L} --> ${F} | Appended: ${$}
`,w.syncInfo=G,G});n.set(u,new O4(b,E)),r+=`${XD(c.resolvedUri)} | Media Sequence: ${u} | Range: ${m} --> ${g} | Appended: ${v}
`,u++,o=g}),this.end_=o,this.storage_=n,this.diagnostics_=r}calculateBaseTime_(e,t,i){if(!this.storage_.size)return 0;if(this.storage_.has(e))return this.storage_.get(e).segmentSyncInfo.start;const n=Math.min(...this.storage_.keys());if(e<n){const r=n-e;let o=this.storage_.get(n).segmentSyncInfo.start;for(let u=0;u<r;u++){const c=t[u];o-=c.duration}return o}return i}isReliablePlaylist_(e,t){return e!=null&&Array.isArray(t)&&t.length}}class y1 extends ew{constructor(e){super(),this.parent_=e}calculateBaseTime_(e,t,i){if(!this.storage_.size){const n=this.parent_.getSyncInfoForMediaSequence(e);return n?n.segmentSyncInfo.start:0}return super.calculateBaseTime_(e,t,i)}}const P4=86400,Oy=[{name:"VOD",run:(s,e,t,i,n)=>t!==1/0?{time:0,segmentIndex:0,partIndex:null}:null},{name:"MediaSequence",run:(s,e,t,i,n,r)=>{const o=s.getMediaSequenceSync(r);if(!o||!o.isReliable)return null;const u=o.getSyncInfoForTime(n);return u?{time:u.start,partIndex:u.partIndex,segmentIndex:u.segmentIndex}:null}},{name:"ProgramDateTime",run:(s,e,t,i,n)=>{if(!Object.keys(s.timelineToDatetimeMappings).length)return null;let r=null,o=null;const u=Iv(e);n=n||0;for(let c=0;c<u.length;c++){const d=e.endList||n===0?c:u.length-(c+1),f=u[d],m=f.segment,g=s.timelineToDatetimeMappings[m.timeline];if(!g||!m.dateTimeObject)continue;let b=m.dateTimeObject.getTime()/1e3+g;if(m.parts&&typeof f.partIndex=="number")for(let E=0;E<f.partIndex;E++)b+=m.parts[E].duration;const _=Math.abs(n-b);if(o!==null&&(_===0||o<_))break;o=_,r={time:b,segmentIndex:f.segmentIndex,partIndex:f.partIndex}}return r}},{name:"Segment",run:(s,e,t,i,n)=>{let r=null,o=null;n=n||0;const u=Iv(e);for(let c=0;c<u.length;c++){const d=e.endList||n===0?c:u.length-(c+1),f=u[d],m=f.segment,g=f.part&&f.part.start||m&&m.start;if(m.timeline===i&&typeof g<"u"){const v=Math.abs(n-g);if(o!==null&&o<v)break;(!r||o===null||o>=v)&&(o=v,r={time:g,segmentIndex:f.segmentIndex,partIndex:f.partIndex})}}return r}},{name:"Discontinuity",run:(s,e,t,i,n)=>{let r=null;if(n=n||0,e.discontinuityStarts&&e.discontinuityStarts.length){let o=null;for(let u=0;u<e.discontinuityStarts.length;u++){const c=e.discontinuityStarts[u],d=e.discontinuitySequence+u+1,f=s.discontinuities[d];if(f){const m=Math.abs(n-f.time);if(o!==null&&o<m)break;(!r||o===null||o>=m)&&(o=m,r={time:f.time,segmentIndex:c,partIndex:null})}}}return r}},{name:"Playlist",run:(s,e,t,i,n)=>e.syncInfo?{time:e.syncInfo.time,segmentIndex:e.syncInfo.mediaSequence-e.mediaSequence,partIndex:null}:null}];class M4 extends Te.EventTarget{constructor(e={}){super(),this.timelines=[],this.discontinuities=[],this.timelineToDatetimeMappings={};const t=new ew,i=new y1(t),n=new y1(t);this.mediaSequenceStorage_={main:t,audio:i,vtt:n},this.logger_=$n("SyncController")}getMediaSequenceSync(e){return this.mediaSequenceStorage_[e]||null}getSyncPoint(e,t,i,n,r){if(t!==1/0)return Oy.find(({name:c})=>c==="VOD").run(this,e,t);const o=this.runStrategies_(e,t,i,n,r);if(!o.length)return null;for(const u of o){const{syncPoint:c,strategy:d}=u,{segmentIndex:f,time:m}=c;if(f<0)continue;const g=e.segments[f],v=m,b=v+g.duration;if(this.logger_(`Strategy: ${d}. Current time: ${n}. selected segment: ${f}. Time: [${v} -> ${b}]}`),n>=v&&n<b)return this.logger_("Found sync point with exact match: ",c),c}return this.selectSyncPoint_(o,{key:"time",value:n})}getExpiredTime(e,t){if(!e||!e.segments)return null;const i=this.runStrategies_(e,t,e.discontinuitySequence,0);if(!i.length)return null;const n=this.selectSyncPoint_(i,{key:"segmentIndex",value:0});return n.segmentIndex>0&&(n.time*=-1),Math.abs(n.time+Ud({defaultDuration:e.targetDuration,durationList:e.segments,startIndex:n.segmentIndex,endIndex:0}))}runStrategies_(e,t,i,n,r){const o=[];for(let u=0;u<Oy.length;u++){const c=Oy[u],d=c.run(this,e,t,i,n,r);d&&(d.strategy=c.name,o.push({strategy:c.name,syncPoint:d}))}return o}selectSyncPoint_(e,t){let i=e[0].syncPoint,n=Math.abs(e[0].syncPoint[t.key]-t.value),r=e[0].strategy;for(let o=1;o<e.length;o++){const u=Math.abs(e[o].syncPoint[t.key]-t.value);u<n&&(n=u,i=e[o].syncPoint,r=e[o].strategy)}return this.logger_(`syncPoint for [${t.key}: ${t.value}] chosen with strategy [${r}]: [time:${i.time}, segmentIndex:${i.segmentIndex}`+(typeof i.partIndex=="number"?`,partIndex:${i.partIndex}`:"")+"]"),i}saveExpiredSegmentInfo(e,t){const i=t.mediaSequence-e.mediaSequence;if(i>P4){Te.log.warn(`Not saving expired segment info. Media sequence gap ${i} is too large.`);return}for(let n=i-1;n>=0;n--){const r=e.segments[n];if(r&&typeof r.start<"u"){t.syncInfo={mediaSequence:e.mediaSequence+n,time:r.start},this.logger_(`playlist refresh sync: [time:${t.syncInfo.time}, mediaSequence: ${t.syncInfo.mediaSequence}]`),this.trigger("syncinfoupdate");break}}}setDateTimeMappingForStart(e){if(this.timelineToDatetimeMappings={},e.segments&&e.segments.length&&e.segments[0].dateTimeObject){const t=e.segments[0],i=t.dateTimeObject.getTime()/1e3;this.timelineToDatetimeMappings[t.timeline]=-i}}saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:t}){const i=this.calculateSegmentTimeMapping_(e,e.timingInfo,t),n=e.segment;i&&(this.saveDiscontinuitySyncInfo_(e),e.playlist.syncInfo||(e.playlist.syncInfo={mediaSequence:e.playlist.mediaSequence+e.mediaIndex,time:n.start}));const r=n.dateTimeObject;n.discontinuity&&t&&r&&(this.timelineToDatetimeMappings[n.timeline]=-(r.getTime()/1e3))}timestampOffsetForTimeline(e){return typeof this.timelines[e]>"u"?null:this.timelines[e].time}mappingForTimeline(e){return typeof this.timelines[e]>"u"?null:this.timelines[e].mapping}calculateSegmentTimeMapping_(e,t,i){const n=e.segment,r=e.part;let o=this.timelines[e.timeline],u,c;if(typeof e.timestampOffset=="number")o={time:e.startOfSegment,mapping:e.startOfSegment-t.start},i&&(this.timelines[e.timeline]=o,this.trigger("timestampoffset"),this.logger_(`time mapping for timeline ${e.timeline}: [time: ${o.time}] [mapping: ${o.mapping}]`)),u=e.startOfSegment,c=t.end+o.mapping;else if(o)u=t.start+o.mapping,c=t.end+o.mapping;else return!1;return r&&(r.start=u,r.end=c),(!n.start||u<n.start)&&(n.start=u),n.end=c,!0}saveDiscontinuitySyncInfo_(e){const t=e.playlist,i=e.segment;if(i.discontinuity)this.discontinuities[i.timeline]={time:i.start,accuracy:0};else if(t.discontinuityStarts&&t.discontinuityStarts.length)for(let n=0;n<t.discontinuityStarts.length;n++){const r=t.discontinuityStarts[n],o=t.discontinuitySequence+n+1,u=r-e.mediaIndex,c=Math.abs(u);if(!this.discontinuities[o]||this.discontinuities[o].accuracy>c){let d;u<0?d=i.start-Ud({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex,endIndex:r}):d=i.end+Ud({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex+1,endIndex:r}),this.discontinuities[o]={time:d,accuracy:c}}}}dispose(){this.trigger("dispose"),this.off()}}class N4 extends Te.EventTarget{constructor(){super(),this.pendingTimelineChanges_={},this.lastTimelineChanges_={}}clearPendingTimelineChange(e){this.pendingTimelineChanges_[e]=null,this.trigger("pendingtimelinechange")}pendingTimelineChange({type:e,from:t,to:i}){return typeof t=="number"&&typeof i=="number"&&(this.pendingTimelineChanges_[e]={type:e,from:t,to:i},this.trigger("pendingtimelinechange")),this.pendingTimelineChanges_[e]}lastTimelineChange({type:e,from:t,to:i}){if(typeof t=="number"&&typeof i=="number"){this.lastTimelineChanges_[e]={type:e,from:t,to:i},delete this.pendingTimelineChanges_[e];const n={timelineChangeInfo:{from:t,to:i}};this.trigger({type:"timelinechange",metadata:n})}return this.lastTimelineChanges_[e]}dispose(){this.trigger("dispose"),this.pendingTimelineChanges_={},this.lastTimelineChanges_={},this.off()}}const B4=UD($D(function(){var s=(function(){function _(){this.listeners={}}var E=_.prototype;return E.on=function(I,L){this.listeners[I]||(this.listeners[I]=[]),this.listeners[I].push(L)},E.off=function(I,L){if(!this.listeners[I])return!1;var F=this.listeners[I].indexOf(L);return this.listeners[I]=this.listeners[I].slice(0),this.listeners[I].splice(F,1),F>-1},E.trigger=function(I){var L=this.listeners[I];if(L)if(arguments.length===2)for(var F=L.length,$=0;$<F;++$)L[$].call(this,arguments[1]);else for(var G=Array.prototype.slice.call(arguments,1),B=L.length,V=0;V<B;++V)L[V].apply(this,G)},E.dispose=function(){this.listeners={}},E.pipe=function(I){this.on("data",function(L){I.push(L)})},_})();function e(_){return _.subarray(0,_.byteLength-_[_.byteLength-1])}const t=function(){const _=[[[],[],[],[],[]],[[],[],[],[],[]]],E=_[0],w=_[1],I=E[4],L=w[4];let F,$,G;const B=[],V=[];let k,R,z,X,ee,le;for(F=0;F<256;F++)V[(B[F]=F<<1^(F>>7)*283)^F]=F;for($=G=0;!I[$];$^=k||1,G=V[G]||1)for(X=G^G<<1^G<<2^G<<3^G<<4,X=X>>8^X&255^99,I[$]=X,L[X]=$,z=B[R=B[k=B[$]]],le=z*16843009^R*65537^k*257^$*16843008,ee=B[X]*257^X*16843008,F=0;F<4;F++)E[F][$]=ee=ee<<24^ee>>>8,w[F][X]=le=le<<24^le>>>8;for(F=0;F<5;F++)E[F]=E[F].slice(0),w[F]=w[F].slice(0);return _};let i=null;class n{constructor(E){i||(i=t()),this._tables=[[i[0][0].slice(),i[0][1].slice(),i[0][2].slice(),i[0][3].slice(),i[0][4].slice()],[i[1][0].slice(),i[1][1].slice(),i[1][2].slice(),i[1][3].slice(),i[1][4].slice()]];let w,I,L;const F=this._tables[0][4],$=this._tables[1],G=E.length;let B=1;if(G!==4&&G!==6&&G!==8)throw new Error("Invalid aes key size");const V=E.slice(0),k=[];for(this._key=[V,k],w=G;w<4*G+28;w++)L=V[w-1],(w%G===0||G===8&&w%G===4)&&(L=F[L>>>24]<<24^F[L>>16&255]<<16^F[L>>8&255]<<8^F[L&255],w%G===0&&(L=L<<8^L>>>24^B<<24,B=B<<1^(B>>7)*283)),V[w]=V[w-G]^L;for(I=0;w;I++,w--)L=V[I&3?w:w-4],w<=4||I<4?k[I]=L:k[I]=$[0][F[L>>>24]]^$[1][F[L>>16&255]]^$[2][F[L>>8&255]]^$[3][F[L&255]]}decrypt(E,w,I,L,F,$){const G=this._key[1];let B=E^G[0],V=L^G[1],k=I^G[2],R=w^G[3],z,X,ee;const le=G.length/4-2;let oe,Y=4;const Z=this._tables[1],Q=Z[0],ae=Z[1],ue=Z[2],U=Z[3],ie=Z[4];for(oe=0;oe<le;oe++)z=Q[B>>>24]^ae[V>>16&255]^ue[k>>8&255]^U[R&255]^G[Y],X=Q[V>>>24]^ae[k>>16&255]^ue[R>>8&255]^U[B&255]^G[Y+1],ee=Q[k>>>24]^ae[R>>16&255]^ue[B>>8&255]^U[V&255]^G[Y+2],R=Q[R>>>24]^ae[B>>16&255]^ue[V>>8&255]^U[k&255]^G[Y+3],Y+=4,B=z,V=X,k=ee;for(oe=0;oe<4;oe++)F[(3&-oe)+$]=ie[B>>>24]<<24^ie[V>>16&255]<<16^ie[k>>8&255]<<8^ie[R&255]^G[Y++],z=B,B=V,V=k,k=R,R=z}}class r extends s{constructor(){super(s),this.jobs=[],this.delay=1,this.timeout_=null}processJob_(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null}push(E){this.jobs.push(E),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))}}const o=function(_){return _<<24|(_&65280)<<8|(_&16711680)>>8|_>>>24},u=function(_,E,w){const I=new Int32Array(_.buffer,_.byteOffset,_.byteLength>>2),L=new n(Array.prototype.slice.call(E)),F=new Uint8Array(_.byteLength),$=new Int32Array(F.buffer);let G,B,V,k,R,z,X,ee,le;for(G=w[0],B=w[1],V=w[2],k=w[3],le=0;le<I.length;le+=4)R=o(I[le]),z=o(I[le+1]),X=o(I[le+2]),ee=o(I[le+3]),L.decrypt(R,z,X,ee,$,le),$[le]=o($[le]^G),$[le+1]=o($[le+1]^B),$[le+2]=o($[le+2]^V),$[le+3]=o($[le+3]^k),G=R,B=z,V=X,k=ee;return F};class c{constructor(E,w,I,L){const F=c.STEP,$=new Int32Array(E.buffer),G=new Uint8Array(E.byteLength);let B=0;for(this.asyncStream_=new r,this.asyncStream_.push(this.decryptChunk_($.subarray(B,B+F),w,I,G)),B=F;B<$.length;B+=F)I=new Uint32Array([o($[B-4]),o($[B-3]),o($[B-2]),o($[B-1])]),this.asyncStream_.push(this.decryptChunk_($.subarray(B,B+F),w,I,G));this.asyncStream_.push(function(){L(null,e(G))})}static get STEP(){return 32e3}decryptChunk_(E,w,I,L){return function(){const F=u(E,w,I);L.set(F,E.byteOffset)}}}var d=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},f;typeof window<"u"?f=window:typeof d<"u"?f=d:typeof self<"u"?f=self:f={};var m=f,g=function(E){return ArrayBuffer.isView==="function"?ArrayBuffer.isView(E):E&&E.buffer instanceof ArrayBuffer},v=m.BigInt||Number;v("0x1"),v("0x100"),v("0x10000"),v("0x1000000"),v("0x100000000"),v("0x10000000000"),v("0x1000000000000"),v("0x100000000000000"),v("0x10000000000000000"),(function(){var _=new Uint16Array([65484]),E=new Uint8Array(_.buffer,_.byteOffset,_.byteLength);return E[0]===255?"big":E[0]===204?"little":"unknown"})();const b=function(_){const E={};return Object.keys(_).forEach(w=>{const I=_[w];g(I)?E[w]={bytes:I.buffer,byteOffset:I.byteOffset,byteLength:I.byteLength}:E[w]=I}),E};self.onmessage=function(_){const E=_.data,w=new Uint8Array(E.encrypted.bytes,E.encrypted.byteOffset,E.encrypted.byteLength),I=new Uint32Array(E.key.bytes,E.key.byteOffset,E.key.byteLength/4),L=new Uint32Array(E.iv.bytes,E.iv.byteOffset,E.iv.byteLength/4);new c(w,I,L,function(F,$){self.postMessage(b({source:E.source,decrypted:$}),[$.buffer])})}}));var F4=FD(B4);const U4=s=>{let e=s.default?"main":"alternative";return s.characteristics&&s.characteristics.indexOf("public.accessibility.describes-video")>=0&&(e="main-desc"),e},tw=(s,e)=>{s.abort(),s.pause(),e&&e.activePlaylistLoader&&(e.activePlaylistLoader.pause(),e.activePlaylistLoader=null)},jv=(s,e)=>{e.activePlaylistLoader=s,s.load()},$4=(s,e)=>()=>{const{segmentLoaders:{[s]:t,main:i},mediaTypes:{[s]:n}}=e,r=n.activeTrack(),o=n.getActiveGroup(),u=n.activePlaylistLoader,c=n.lastGroup_;if(!(o&&c&&o.id===c.id)&&(n.lastGroup_=o,n.lastTrack_=r,tw(t,n),!(!o||o.isMainPlaylist))){if(!o.playlistLoader){u&&i.resetEverything();return}t.resyncLoader(),jv(o.playlistLoader,n)}},j4=(s,e)=>()=>{const{segmentLoaders:{[s]:t},mediaTypes:{[s]:i}}=e;i.lastGroup_=null,t.abort(),t.pause()},H4=(s,e)=>()=>{const{mainPlaylistLoader:t,segmentLoaders:{[s]:i,main:n},mediaTypes:{[s]:r}}=e,o=r.activeTrack(),u=r.getActiveGroup(),c=r.activePlaylistLoader,d=r.lastTrack_;if(!(d&&o&&d.id===o.id)&&(r.lastGroup_=u,r.lastTrack_=o,tw(i,r),!!u)){if(u.isMainPlaylist){if(!o||!d||o.id===d.id)return;const f=e.vhs.playlistController_,m=f.selectPlaylist();if(f.media()===m)return;r.logger_(`track change. Switching main audio from ${d.id} to ${o.id}`),t.pause(),n.resetEverything(),f.fastQualityChange_(m);return}if(s==="AUDIO"){if(!u.playlistLoader){n.setAudio(!0),n.resetEverything();return}i.setAudio(!0),n.setAudio(!1)}if(c===u.playlistLoader){jv(u.playlistLoader,r);return}i.track&&i.track(o),i.resetEverything(),jv(u.playlistLoader,r)}},Wp={AUDIO:(s,e)=>()=>{const{mediaTypes:{[s]:t},excludePlaylist:i}=e,n=t.activeTrack(),r=t.activeGroup(),o=(r.filter(c=>c.default)[0]||r[0]).id,u=t.tracks[o];if(n===u){i({error:{message:"Problem encountered loading the default audio track."}});return}Te.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(const c in t.tracks)t.tracks[c].enabled=t.tracks[c]===u;t.onTrackChanged()},SUBTITLES:(s,e)=>()=>{const{mediaTypes:{[s]:t}}=e;Te.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track.");const i=t.activeTrack();i&&(i.mode="disabled"),t.onTrackChanged()}},v1={AUDIO:(s,e,t)=>{if(!e)return;const{tech:i,requestOptions:n,segmentLoaders:{[s]:r}}=t;e.on("loadedmetadata",()=>{const o=e.media();r.playlist(o,n),(!i.paused()||o.endList&&i.preload()!=="none")&&r.load()}),e.on("loadedplaylist",()=>{r.playlist(e.media(),n),i.paused()||r.load()}),e.on("error",Wp[s](s,t))},SUBTITLES:(s,e,t)=>{const{tech:i,requestOptions:n,segmentLoaders:{[s]:r},mediaTypes:{[s]:o}}=t;e.on("loadedmetadata",()=>{const u=e.media();r.playlist(u,n),r.track(o.activeTrack()),(!i.paused()||u.endList&&i.preload()!=="none")&&r.load()}),e.on("loadedplaylist",()=>{r.playlist(e.media(),n),i.paused()||r.load()}),e.on("error",Wp[s](s,t))}},G4={AUDIO:(s,e)=>{const{vhs:t,sourceType:i,segmentLoaders:{[s]:n},requestOptions:r,main:{mediaGroups:o},mediaTypes:{[s]:{groups:u,tracks:c,logger_:d}},mainPlaylistLoader:f}=e,m=dh(f.main);(!o[s]||Object.keys(o[s]).length===0)&&(o[s]={main:{default:{default:!0}}},m&&(o[s].main.default.playlists=f.main.playlists));for(const g in o[s]){u[g]||(u[g]=[]);for(const v in o[s][g]){let b=o[s][g][v],_;if(m?(d(`AUDIO group '${g}' label '${v}' is a main playlist`),b.isMainPlaylist=!0,_=null):i==="vhs-json"&&b.playlists?_=new Ou(b.playlists[0],t,r):b.resolvedUri?_=new Ou(b.resolvedUri,t,r):b.playlists&&i==="dash"?_=new Nv(b.playlists[0],t,r,f):_=null,b=Kt({id:v,playlistLoader:_},b),v1[s](s,b.playlistLoader,e),u[g].push(b),typeof c[v]>"u"){const E=new Te.AudioTrack({id:v,kind:U4(b),enabled:!1,language:b.language,default:b.default,label:v});c[v]=E}}}n.on("error",Wp[s](s,e))},SUBTITLES:(s,e)=>{const{tech:t,vhs:i,sourceType:n,segmentLoaders:{[s]:r},requestOptions:o,main:{mediaGroups:u},mediaTypes:{[s]:{groups:c,tracks:d}},mainPlaylistLoader:f}=e;for(const m in u[s]){c[m]||(c[m]=[]);for(const g in u[s][m]){if(!i.options_.useForcedSubtitles&&u[s][m][g].forced)continue;let v=u[s][m][g],b;if(n==="hls")b=new Ou(v.resolvedUri,i,o);else if(n==="dash"){if(!v.playlists.filter(E=>E.excludeUntil!==1/0).length)return;b=new Nv(v.playlists[0],i,o,f)}else n==="vhs-json"&&(b=new Ou(v.playlists?v.playlists[0]:v.resolvedUri,i,o));if(v=Kt({id:g,playlistLoader:b},v),v1[s](s,v.playlistLoader,e),c[m].push(v),typeof d[g]>"u"){const _=t.addRemoteTextTrack({id:g,kind:"subtitles",default:v.default&&v.autoselect,language:v.language,label:g},!1).track;d[g]=_}}}r.on("error",Wp[s](s,e))},"CLOSED-CAPTIONS":(s,e)=>{const{tech:t,main:{mediaGroups:i},mediaTypes:{[s]:{groups:n,tracks:r}}}=e;for(const o in i[s]){n[o]||(n[o]=[]);for(const u in i[s][o]){const c=i[s][o][u];if(!/^(?:CC|SERVICE)/.test(c.instreamId))continue;const d=t.options_.vhs&&t.options_.vhs.captionServices||{};let f={label:u,language:c.language,instreamId:c.instreamId,default:c.default&&c.autoselect};if(d[f.instreamId]&&(f=Kt(f,d[f.instreamId])),f.default===void 0&&delete f.default,n[o].push(Kt({id:u},c)),typeof r[u]>"u"){const m=t.addRemoteTextTrack({id:f.instreamId,kind:"captions",default:f.default,language:f.language,label:f.label},!1).track;r[u]=m}}}}},iw=(s,e)=>{for(let t=0;t<s.length;t++)if(WT(e,s[t])||s[t].playlists&&iw(s[t].playlists,e))return!0;return!1},V4=(s,e)=>t=>{const{mainPlaylistLoader:i,mediaTypes:{[s]:{groups:n}}}=e,r=i.media();if(!r)return null;let o=null;r.attributes[s]&&(o=n[r.attributes[s]]);const u=Object.keys(n);if(!o)if(s==="AUDIO"&&u.length>1&&dh(e.main))for(let c=0;c<u.length;c++){const d=n[u[c]];if(iw(d,r)){o=d;break}}else n.main?o=n.main:u.length===1&&(o=n[u[0]]);return typeof t>"u"?o:t===null||!o?null:o.filter(c=>c.id===t.id)[0]||null},q4={AUDIO:(s,e)=>()=>{const{mediaTypes:{[s]:{tracks:t}}}=e;for(const i in t)if(t[i].enabled)return t[i];return null},SUBTITLES:(s,e)=>()=>{const{mediaTypes:{[s]:{tracks:t}}}=e;for(const i in t)if(t[i].mode==="showing"||t[i].mode==="hidden")return t[i];return null}},z4=(s,{mediaTypes:e})=>()=>{const t=e[s].activeTrack();return t?e[s].activeGroup(t):null},K4=s=>{["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(d=>{G4[d](d,s)});const{mediaTypes:e,mainPlaylistLoader:t,tech:i,vhs:n,segmentLoaders:{["AUDIO"]:r,main:o}}=s;["AUDIO","SUBTITLES"].forEach(d=>{e[d].activeGroup=V4(d,s),e[d].activeTrack=q4[d](d,s),e[d].onGroupChanged=$4(d,s),e[d].onGroupChanging=j4(d,s),e[d].onTrackChanged=H4(d,s),e[d].getActiveGroup=z4(d,s)});const u=e.AUDIO.activeGroup();if(u){const d=(u.filter(m=>m.default)[0]||u[0]).id;e.AUDIO.tracks[d].enabled=!0,e.AUDIO.onGroupChanged(),e.AUDIO.onTrackChanged(),e.AUDIO.getActiveGroup().playlistLoader?(o.setAudio(!1),r.setAudio(!0)):o.setAudio(!0)}t.on("mediachange",()=>{["AUDIO","SUBTITLES"].forEach(d=>e[d].onGroupChanged())}),t.on("mediachanging",()=>{["AUDIO","SUBTITLES"].forEach(d=>e[d].onGroupChanging())});const c=()=>{e.AUDIO.onTrackChanged(),i.trigger({type:"usage",name:"vhs-audio-change"})};i.audioTracks().addEventListener("change",c),i.remoteTextTracks().addEventListener("change",e.SUBTITLES.onTrackChanged),n.on("dispose",()=>{i.audioTracks().removeEventListener("change",c),i.remoteTextTracks().removeEventListener("change",e.SUBTITLES.onTrackChanged)}),i.clearTracks("audio");for(const d in e.AUDIO.tracks)i.audioTracks().addTrack(e.AUDIO.tracks[d])},Y4=()=>{const s={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{s[e]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:ga,activeTrack:ga,getActiveGroup:ga,onGroupChanged:ga,onTrackChanged:ga,lastTrack_:null,logger_:$n(`MediaGroups[${e}]`)}}),s};class T1{constructor(){this.priority_=[],this.pathwayClones_=new Map}set version(e){e===1&&(this.version_=e)}set ttl(e){this.ttl_=e||300}set reloadUri(e){e&&(this.reloadUri_=Js(this.reloadUri_,e))}set priority(e){e&&e.length&&(this.priority_=e)}set pathwayClones(e){e&&e.length&&(this.pathwayClones_=new Map(e.map(t=>[t.ID,t])))}get version(){return this.version_}get ttl(){return this.ttl_}get reloadUri(){return this.reloadUri_}get priority(){return this.priority_}get pathwayClones(){return this.pathwayClones_}}let W4=class extends Te.EventTarget{constructor(e,t){super(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=!1,this.availablePathways_=new Set,this.steeringManifest=new T1,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.currentPathwayClones=new Map,this.nextPathwayClones=new Map,this.excludedSteeringManifestURLs=new Set,this.logger_=$n("Content Steering"),this.xhr_=e,this.getBandwidth_=t}assignTagProperties(e,t){this.manifestType_=t.serverUri?"HLS":"DASH";const i=t.serverUri||t.serverURL;if(!i){this.logger_(`steering manifest URL is ${i}, cannot request steering manifest.`),this.trigger("error");return}if(i.startsWith("data:")){this.decodeDataUriManifest_(i.substring(i.indexOf(",")+1));return}this.steeringManifest.reloadUri=Js(e,i),this.defaultPathway=t.pathwayId||t.defaultServiceLocation,this.queryBeforeStart=t.queryBeforeStart,this.proxyServerUrl_=t.proxyServerURL,this.defaultPathway&&!this.queryBeforeStart&&this.trigger("content-steering")}requestSteeringManifest(e){const t=this.steeringManifest.reloadUri;if(!t)return;const i=e?t:this.getRequestURI(t);if(!i){this.logger_("No valid content steering manifest URIs. Stopping content steering."),this.trigger("error"),this.dispose();return}const n={contentSteeringInfo:{uri:i}};this.trigger({type:"contentsteeringloadstart",metadata:n}),this.request_=this.xhr_({uri:i,requestType:"content-steering-manifest"},(r,o)=>{if(r){if(o.status===410){this.logger_(`manifest request 410 ${r}.`),this.logger_(`There will be no more content steering requests to ${i} this session.`),this.excludedSteeringManifestURLs.add(i);return}if(o.status===429){const d=o.responseHeaders["retry-after"];this.logger_(`manifest request 429 ${r}.`),this.logger_(`content steering will retry in ${d} seconds.`),this.startTTLTimeout_(parseInt(d,10));return}this.logger_(`manifest failed to load ${r}.`),this.startTTLTimeout_();return}this.trigger({type:"contentsteeringloadcomplete",metadata:n});let u;try{u=JSON.parse(this.request_.responseText)}catch(d){const f={errorType:Te.Error.StreamingContentSteeringParserError,error:d};this.trigger({type:"error",metadata:f})}this.assignSteeringProperties_(u);const c={contentSteeringInfo:n.contentSteeringInfo,contentSteeringManifest:{version:this.steeringManifest.version,reloadUri:this.steeringManifest.reloadUri,priority:this.steeringManifest.priority}};this.trigger({type:"contentsteeringparsed",metadata:c}),this.startTTLTimeout_()})}setProxyServerUrl_(e){const t=new ne.URL(e),i=new ne.URL(this.proxyServerUrl_);return i.searchParams.set("url",encodeURI(t.toString())),this.setSteeringParams_(i.toString())}decodeDataUriManifest_(e){const t=JSON.parse(ne.atob(e));this.assignSteeringProperties_(t)}setSteeringParams_(e){const t=new ne.URL(e),i=this.getPathway(),n=this.getBandwidth_();if(i){const r=`_${this.manifestType_}_pathway`;t.searchParams.set(r,i)}if(n){const r=`_${this.manifestType_}_throughput`;t.searchParams.set(r,n)}return t.toString()}assignSteeringProperties_(e){if(this.steeringManifest.version=e.VERSION,!this.steeringManifest.version){this.logger_(`manifest version is ${e.VERSION}, which is not supported.`),this.trigger("error");return}this.steeringManifest.ttl=e.TTL,this.steeringManifest.reloadUri=e["RELOAD-URI"],this.steeringManifest.priority=e["PATHWAY-PRIORITY"]||e["SERVICE-LOCATION-PRIORITY"],this.steeringManifest.pathwayClones=e["PATHWAY-CLONES"],this.nextPathwayClones=this.steeringManifest.pathwayClones,this.availablePathways_.size||(this.logger_("There are no available pathways for content steering. Ending content steering."),this.trigger("error"),this.dispose());const i=(n=>{for(const r of n)if(this.availablePathways_.has(r))return r;return[...this.availablePathways_][0]})(this.steeringManifest.priority);this.currentPathway!==i&&(this.currentPathway=i,this.trigger("content-steering"))}getPathway(){return this.currentPathway||this.defaultPathway}getRequestURI(e){if(!e)return null;const t=n=>this.excludedSteeringManifestURLs.has(n);if(this.proxyServerUrl_){const n=this.setProxyServerUrl_(e);if(!t(n))return n}const i=this.setSteeringParams_(e);return t(i)?null:i}startTTLTimeout_(e=this.steeringManifest.ttl){const t=e*1e3;this.ttlTimeout_=ne.setTimeout(()=>{this.requestSteeringManifest()},t)}clearTTLTimeout_(){ne.clearTimeout(this.ttlTimeout_),this.ttlTimeout_=null}abort(){this.request_&&this.request_.abort(),this.request_=null}dispose(){this.off("content-steering"),this.off("error"),this.abort(),this.clearTTLTimeout_(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=null,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.excludedSteeringManifestURLs=new Set,this.availablePathways_=new Set,this.steeringManifest=new T1}addAvailablePathway(e){e&&this.availablePathways_.add(e)}clearAvailablePathways(){this.availablePathways_.clear()}excludePathway(e){return this.availablePathways_.delete(e)}didDASHTagChange(e,t){return!t&&this.steeringManifest.reloadUri||t&&(Js(e,t.serverURL)!==this.steeringManifest.reloadUri||t.defaultServiceLocation!==this.defaultPathway||t.queryBeforeStart!==this.queryBeforeStart||t.proxyServerURL!==this.proxyServerUrl_)}getAvailablePathways(){return this.availablePathways_}};const X4=(s,e)=>{let t=null;return(...i)=>{clearTimeout(t),t=setTimeout(()=>{s.apply(null,i)},e)}},Q4=10;let uo;const Z4=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred","mediaAppends"],J4=function(s){return this.audioSegmentLoader_[s]+this.mainSegmentLoader_[s]},eB=function({currentPlaylist:s,buffered:e,currentTime:t,nextPlaylist:i,bufferLowWaterLine:n,bufferHighWaterLine:r,duration:o,bufferBasedABR:u,log:c}){if(!i)return Te.log.warn("We received no playlist to switch to. Please check your stream."),!1;const d=`allowing switch ${s&&s.id||"null"} -> ${i.id}`;if(!s)return c(`${d} as current playlist is not set`),!0;if(i.id===s.id)return!1;const f=!!Ru(e,t).length;if(!s.endList)return!f&&typeof s.partTargetDuration=="number"?(c(`not ${d} as current playlist is live llhls, but currentTime isn't in buffered.`),!1):(c(`${d} as current playlist is live`),!0);const m=zT(e,t),g=u?os.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:os.MAX_BUFFER_LOW_WATER_LINE;if(o<g)return c(`${d} as duration < max low water line (${o} < ${g})`),!0;const v=i.attributes.BANDWIDTH,b=s.attributes.BANDWIDTH;if(v<b&&(!u||m<r)){let _=`${d} as next bandwidth < current bandwidth (${v} < ${b})`;return u&&(_+=` and forwardBuffer < bufferHighWaterLine (${m} < ${r})`),c(_),!0}if((!u||v>b)&&m>=n){let _=`${d} as forwardBuffer >= bufferLowWaterLine (${m} >= ${n})`;return u&&(_+=` and next bandwidth > current bandwidth (${v} > ${b})`),c(_),!0}return c(`not ${d} as no switching criteria met`),!1};class tB extends Te.EventTarget{constructor(e){super(),this.fastQualityChange_=X4(this.fastQualityChange_.bind(this),100);const{src:t,withCredentials:i,tech:n,bandwidth:r,externVhs:o,useCueTags:u,playlistExclusionDuration:c,enableLowInitialPlaylist:d,sourceType:f,cacheEncryptionKeys:m,bufferBasedABR:g,leastPixelDiffSelector:v,captionServices:b,experimentalUseMMS:_}=e;if(!t)throw new Error("A non-empty playlist URL or JSON manifest string is required");let{maxPlaylistRetries:E}=e;(E===null||typeof E>"u")&&(E=1/0),uo=o,this.bufferBasedABR=!!g,this.leastPixelDiffSelector=!!v,this.withCredentials=i,this.tech_=n,this.vhs_=n.vhs,this.player_=e.player_,this.sourceType_=f,this.useCueTags_=u,this.playlistExclusionDuration=c,this.maxPlaylistRetries=E,this.enableLowInitialPlaylist=d,this.usingManagedMediaSource_=!1,this.useCueTags_&&(this.cueTagsTrack_=this.tech_.addTextTrack("metadata","ad-cues"),this.cueTagsTrack_.inBandMetadataTrackDispatchType=""),this.requestOptions_={withCredentials:i,maxPlaylistRetries:E,timeout:null},this.on("error",this.pauseLoading),this.mediaTypes_=Y4(),_&&ne.ManagedMediaSource?(this.tech_.el_.disableRemotePlayback=!0,this.mediaSource=new ne.ManagedMediaSource,this.usingManagedMediaSource_=!0,Te.log("Using ManagedMediaSource")):ne.MediaSource&&(this.mediaSource=new ne.MediaSource),this.handleDurationChange_=this.handleDurationChange_.bind(this),this.handleSourceOpen_=this.handleSourceOpen_.bind(this),this.handleSourceEnded_=this.handleSourceEnded_.bind(this),this.load=this.load.bind(this),this.pause=this.pause.bind(this),this.mediaSource.addEventListener("durationchange",this.handleDurationChange_),this.mediaSource.addEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.addEventListener("sourceended",this.handleSourceEnded_),this.mediaSource.addEventListener("startstreaming",this.load),this.mediaSource.addEventListener("endstreaming",this.pause),this.seekable_=us(),this.hasPlayed_=!1,this.syncController_=new M4(e),this.segmentMetadataTrack_=n.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,this.segmentMetadataTrack_.mode="hidden",this.decrypter_=new F4,this.sourceUpdater_=new JD(this.mediaSource),this.inbandTextTracks_={},this.timelineChangeController_=new N4,this.keyStatusMap_=new Map;const w={vhs:this.vhs_,parse708captions:e.parse708captions,useDtsForTimestampOffset:e.useDtsForTimestampOffset,captionServices:b,mediaSource:this.mediaSource,currentTime:this.tech_.currentTime.bind(this.tech_),seekable:()=>this.seekable(),seeking:()=>this.tech_.seeking(),duration:()=>this.duration(),hasPlayed:()=>this.hasPlayed_,goalBufferLength:()=>this.goalBufferLength(),bandwidth:r,syncController:this.syncController_,decrypter:this.decrypter_,sourceType:this.sourceType_,inbandTextTracks:this.inbandTextTracks_,cacheEncryptionKeys:m,sourceUpdater:this.sourceUpdater_,timelineChangeController:this.timelineChangeController_,exactManifestTimings:e.exactManifestTimings,addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)};this.mainPlaylistLoader_=this.sourceType_==="dash"?new Nv(t,this.vhs_,Kt(this.requestOptions_,{addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)})):new Ou(t,this.vhs_,Kt(this.requestOptions_,{addDateRangesToTextTrack:this.addDateRangesToTextTrack_.bind(this)})),this.setupMainPlaylistLoaderListeners_(),this.mainSegmentLoader_=new Uv(Kt(w,{segmentMetadataTrack:this.segmentMetadataTrack_,loaderType:"main"}),e),this.audioSegmentLoader_=new Uv(Kt(w,{loaderType:"audio"}),e),this.subtitleSegmentLoader_=new I4(Kt(w,{loaderType:"vtt",featuresNativeTextTracks:this.tech_.featuresNativeTextTracks,loadVttJs:()=>new Promise((F,$)=>{function G(){n.off("vttjserror",B),F()}function B(){n.off("vttjsloaded",G),$()}n.one("vttjsloaded",G),n.one("vttjserror",B),n.addWebVttScript_()})}),e);const I=()=>this.mainSegmentLoader_.bandwidth;this.contentSteeringController_=new W4(this.vhs_.xhr,I),this.setupSegmentLoaderListeners_(),this.bufferBasedABR&&(this.mainPlaylistLoader_.one("loadedplaylist",()=>this.startABRTimer_()),this.tech_.on("pause",()=>this.stopABRTimer_()),this.tech_.on("play",()=>this.startABRTimer_())),Z4.forEach(F=>{this[F+"_"]=J4.bind(this,F)}),this.logger_=$n("pc"),this.triggeredFmp4Usage=!1,this.tech_.preload()==="none"?(this.loadOnPlay_=()=>{this.loadOnPlay_=null,this.mainPlaylistLoader_.load()},this.tech_.one("play",this.loadOnPlay_)):this.mainPlaylistLoader_.load(),this.timeToLoadedData__=-1,this.mainAppendsToLoadedData__=-1,this.audioAppendsToLoadedData__=-1;const L=this.tech_.preload()==="none"?"play":"loadstart";this.tech_.one(L,()=>{const F=Date.now();this.tech_.one("loadeddata",()=>{this.timeToLoadedData__=Date.now()-F,this.mainAppendsToLoadedData__=this.mainSegmentLoader_.mediaAppends,this.audioAppendsToLoadedData__=this.audioSegmentLoader_.mediaAppends})})}mainAppendsToLoadedData_(){return this.mainAppendsToLoadedData__}audioAppendsToLoadedData_(){return this.audioAppendsToLoadedData__}appendsToLoadedData_(){const e=this.mainAppendsToLoadedData_(),t=this.audioAppendsToLoadedData_();return e===-1||t===-1?-1:e+t}timeToLoadedData_(){return this.timeToLoadedData__}checkABR_(e="abr"){const t=this.selectPlaylist();t&&this.shouldSwitchToMedia_(t)&&this.switchMedia_(t,e)}switchMedia_(e,t,i){const n=this.media(),r=n&&(n.id||n.uri),o=e&&(e.id||e.uri);if(r&&r!==o){this.logger_(`switch media ${r} -> ${o} from ${t}`);const u={renditionInfo:{id:o,bandwidth:e.attributes.BANDWIDTH,resolution:e.attributes.RESOLUTION,codecs:e.attributes.CODECS},cause:t};this.trigger({type:"renditionselected",metadata:u}),this.tech_.trigger({type:"usage",name:`vhs-rendition-change-${t}`})}this.mainPlaylistLoader_.media(e,i)}switchMediaForDASHContentSteering_(){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{const t=this.mediaTypes_[e],i=t?t.activeGroup():null,n=this.contentSteeringController_.getPathway();if(i&&n){const o=(i.length?i[0].playlists:i.playlists).filter(u=>u.attributes.serviceLocation===n);o.length&&this.mediaTypes_[e].activePlaylistLoader.media(o[0])}})}startABRTimer_(){this.stopABRTimer_(),this.abrTimer_=ne.setInterval(()=>this.checkABR_(),250)}stopABRTimer_(){this.tech_.scrubbing&&this.tech_.scrubbing()||(ne.clearInterval(this.abrTimer_),this.abrTimer_=null)}getAudioTrackPlaylists_(){const e=this.main(),t=e&&e.playlists||[];if(!e||!e.mediaGroups||!e.mediaGroups.AUDIO)return t;const i=e.mediaGroups.AUDIO,n=Object.keys(i);let r;if(Object.keys(this.mediaTypes_.AUDIO.groups).length)r=this.mediaTypes_.AUDIO.activeTrack();else{const u=i.main||n.length&&i[n[0]];for(const c in u)if(u[c].default){r={label:c};break}}if(!r)return t;const o=[];for(const u in i)if(i[u][r.label]){const c=i[u][r.label];if(c.playlists&&c.playlists.length)o.push.apply(o,c.playlists);else if(c.uri)o.push(c);else if(e.playlists.length)for(let d=0;d<e.playlists.length;d++){const f=e.playlists[d];f.attributes&&f.attributes.AUDIO&&f.attributes.AUDIO===u&&o.push(f)}}return o.length?o:t}setupMainPlaylistLoaderListeners_(){this.mainPlaylistLoader_.on("loadedmetadata",()=>{const t=this.mainPlaylistLoader_.media(),i=t.targetDuration*1.5*1e3;kv(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=i,t.endList&&this.tech_.preload()!=="none"&&(this.mainSegmentLoader_.playlist(t,this.requestOptions_),this.mainSegmentLoader_.load()),K4({sourceType:this.sourceType_,segmentLoaders:{AUDIO:this.audioSegmentLoader_,SUBTITLES:this.subtitleSegmentLoader_,main:this.mainSegmentLoader_},tech:this.tech_,requestOptions:this.requestOptions_,mainPlaylistLoader:this.mainPlaylistLoader_,vhs:this.vhs_,main:this.main(),mediaTypes:this.mediaTypes_,excludePlaylist:this.excludePlaylist.bind(this)}),this.triggerPresenceUsage_(this.main(),t),this.setupFirstPlay(),!this.mediaTypes_.AUDIO.activePlaylistLoader||this.mediaTypes_.AUDIO.activePlaylistLoader.media()?this.trigger("selectedinitialmedia"):this.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",()=>{this.trigger("selectedinitialmedia")})}),this.mainPlaylistLoader_.on("loadedplaylist",()=>{this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_);let t=this.mainPlaylistLoader_.media();if(!t){this.attachContentSteeringListeners_(),this.initContentSteeringController_(),this.excludeUnsupportedVariants_();let i;if(this.enableLowInitialPlaylist&&(i=this.selectInitialPlaylist()),i||(i=this.selectPlaylist()),!i||!this.shouldSwitchToMedia_(i)||(this.initialMedia_=i,this.switchMedia_(this.initialMedia_,"initial"),!(this.sourceType_==="vhs-json"&&this.initialMedia_.segments)))return;t=this.initialMedia_}this.handleUpdatedMediaPlaylist(t)}),this.mainPlaylistLoader_.on("error",()=>{const t=this.mainPlaylistLoader_.error;this.excludePlaylist({playlistToExclude:t.playlist,error:t})}),this.mainPlaylistLoader_.on("mediachanging",()=>{this.mainSegmentLoader_.abort(),this.mainSegmentLoader_.pause()}),this.mainPlaylistLoader_.on("mediachange",()=>{const t=this.mainPlaylistLoader_.media(),i=t.targetDuration*1.5*1e3;kv(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=i,this.sourceType_==="dash"&&this.mainPlaylistLoader_.isPaused&&this.mainPlaylistLoader_.load(),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(t,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_?this.runFastQualitySwitch_():this.mainSegmentLoader_.load(),this.tech_.trigger({type:"mediachange",bubbles:!0})}),this.mainPlaylistLoader_.on("playlistunchanged",()=>{const t=this.mainPlaylistLoader_.media();if(t.lastExcludeReason_==="playlist-unchanged")return;this.stuckAtPlaylistEnd_(t)&&(this.excludePlaylist({error:{message:"Playlist no longer updating.",reason:"playlist-unchanged"}}),this.tech_.trigger("playliststuck"))}),this.mainPlaylistLoader_.on("renditiondisabled",()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-disabled"})}),this.mainPlaylistLoader_.on("renditionenabled",()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-enabled"})}),["manifestrequeststart","manifestrequestcomplete","manifestparsestart","manifestparsecomplete","playlistrequeststart","playlistrequestcomplete","playlistparsestart","playlistparsecomplete","renditiondisabled","renditionenabled"].forEach(t=>{this.mainPlaylistLoader_.on(t,i=>{this.player_.trigger(Hi({},i))})})}handleUpdatedMediaPlaylist(e){this.useCueTags_&&this.updateAdCues_(e),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_&&this.runFastQualitySwitch_(),this.updateDuration(!e.endList),this.tech_.paused()||(this.mainSegmentLoader_.load(),this.audioSegmentLoader_&&this.audioSegmentLoader_.load())}triggerPresenceUsage_(e,t){const i=e.mediaGroups||{};let n=!0;const r=Object.keys(i.AUDIO);for(const o in i.AUDIO)for(const u in i.AUDIO[o])i.AUDIO[o][u].uri||(n=!1);n&&this.tech_.trigger({type:"usage",name:"vhs-demuxed"}),Object.keys(i.SUBTITLES).length&&this.tech_.trigger({type:"usage",name:"vhs-webvtt"}),uo.Playlist.isAes(t)&&this.tech_.trigger({type:"usage",name:"vhs-aes"}),r.length&&Object.keys(i.AUDIO[r[0]]).length>1&&this.tech_.trigger({type:"usage",name:"vhs-alternate-audio"}),this.useCueTags_&&this.tech_.trigger({type:"usage",name:"vhs-playlist-cue-tags"})}shouldSwitchToMedia_(e){const t=this.mainPlaylistLoader_.media()||this.mainPlaylistLoader_.pendingMedia_,i=this.tech_.currentTime(),n=this.bufferLowWaterLine(),r=this.bufferHighWaterLine(),o=this.tech_.buffered();return eB({buffered:o,currentTime:i,currentPlaylist:t,nextPlaylist:e,bufferLowWaterLine:n,bufferHighWaterLine:r,duration:this.duration(),bufferBasedABR:this.bufferBasedABR,log:this.logger_})}setupSegmentLoaderListeners_(){this.mainSegmentLoader_.on("bandwidthupdate",()=>{this.checkABR_("bandwidthupdate"),this.tech_.trigger("bandwidthupdate")}),this.mainSegmentLoader_.on("timeout",()=>{this.bufferBasedABR&&this.mainSegmentLoader_.load()}),this.bufferBasedABR||this.mainSegmentLoader_.on("progress",()=>{this.trigger("progress")}),this.mainSegmentLoader_.on("error",()=>{const i=this.mainSegmentLoader_.error();this.excludePlaylist({playlistToExclude:i.playlist,error:i})}),this.mainSegmentLoader_.on("appenderror",()=>{this.error=this.mainSegmentLoader_.error_,this.trigger("error")}),this.mainSegmentLoader_.on("syncinfoupdate",()=>{this.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("timestampoffset",()=>{this.tech_.trigger({type:"usage",name:"vhs-timestamp-offset"})}),this.audioSegmentLoader_.on("syncinfoupdate",()=>{this.onSyncInfoUpdate_()}),this.audioSegmentLoader_.on("appenderror",()=>{this.error=this.audioSegmentLoader_.error_,this.trigger("error")}),this.mainSegmentLoader_.on("ended",()=>{this.logger_("main segment loader ended"),this.onEndOfStream()}),this.timelineChangeController_.on("audioTimelineBehind",()=>{const i=this.audioSegmentLoader_.pendingSegment_;if(!i||!i.segment||!i.segment.syncInfo)return;const n=i.segment.syncInfo.end+.01;this.tech_.setCurrentTime(n)}),this.timelineChangeController_.on("fixBadTimelineChange",()=>{this.logger_("Fix bad timeline change. Restarting al segment loaders..."),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}),this.mainSegmentLoader_.on("earlyabort",i=>{this.bufferBasedABR||(this.delegateLoaders_("all",["abort"]),this.excludePlaylist({error:{message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},playlistExclusionDuration:Q4}))});const e=()=>{if(!this.sourceUpdater_.hasCreatedSourceBuffers())return this.tryToCreateSourceBuffers_();const i=this.getCodecsOrExclude_();i&&this.sourceUpdater_.addOrChangeSourceBuffers(i)};this.mainSegmentLoader_.on("trackinfo",e),this.audioSegmentLoader_.on("trackinfo",e),this.mainSegmentLoader_.on("fmp4",()=>{this.triggeredFmp4Usage||(this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0)}),this.audioSegmentLoader_.on("fmp4",()=>{this.triggeredFmp4Usage||(this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0)}),this.audioSegmentLoader_.on("ended",()=>{this.logger_("audioSegmentLoader ended"),this.onEndOfStream()}),["segmentselected","segmentloadstart","segmentloaded","segmentkeyloadstart","segmentkeyloadcomplete","segmentdecryptionstart","segmentdecryptioncomplete","segmenttransmuxingstart","segmenttransmuxingcomplete","segmenttransmuxingtrackinfoavailable","segmenttransmuxingtiminginfoavailable","segmentappendstart","appendsdone","bandwidthupdated","timelinechange","codecschange"].forEach(i=>{this.mainSegmentLoader_.on(i,n=>{this.player_.trigger(Hi({},n))}),this.audioSegmentLoader_.on(i,n=>{this.player_.trigger(Hi({},n))}),this.subtitleSegmentLoader_.on(i,n=>{this.player_.trigger(Hi({},n))})})}mediaSecondsLoaded_(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}load(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load()}pause(){this.mainSegmentLoader_.pause(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.pause(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.pause()}fastQualityChange_(e=this.selectPlaylist()){if(e&&e===this.mainPlaylistLoader_.media()){this.logger_("skipping fastQualityChange because new media is same as old");return}this.switchMedia_(e,"fast-quality"),this.waitingForFastQualityPlaylistReceived_=!0}runFastQualitySwitch_(){this.waitingForFastQualityPlaylistReceived_=!1,this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}play(){if(this.setupFirstPlay())return;this.tech_.ended()&&this.tech_.setCurrentTime(0),this.hasPlayed_&&this.load();const e=this.tech_.seekable();if(this.tech_.duration()===1/0&&this.tech_.currentTime()<e.start(0))return this.tech_.setCurrentTime(e.end(e.length-1))}setupFirstPlay(){const e=this.mainPlaylistLoader_.media();if(!e||this.tech_.paused()||this.hasPlayed_)return!1;if(!e.endList||e.start){const t=this.seekable();if(!t.length)return!1;const i=t.end(0);let n=i;if(e.start){const r=e.start.timeOffset;r<0?n=Math.max(i+r,t.start(0)):n=Math.min(i,r)}this.trigger("firstplay"),this.tech_.setCurrentTime(n)}return this.hasPlayed_=!0,this.load(),!0}handleSourceOpen_(){if(this.tryToCreateSourceBuffers_(),this.tech_.autoplay()){const e=this.tech_.play();typeof e<"u"&&typeof e.then=="function"&&e.then(null,t=>{})}this.trigger("sourceopen")}handleSourceEnded_(){if(!this.inbandTextTracks_.metadataTrack_)return;const e=this.inbandTextTracks_.metadataTrack_.cues;if(!e||!e.length)return;const t=this.duration();e[e.length-1].endTime=isNaN(t)||Math.abs(t)===1/0?Number.MAX_VALUE:t}handleDurationChange_(){this.tech_.trigger("durationchange")}onEndOfStream(){let e=this.mainSegmentLoader_.ended_;if(this.mediaTypes_.AUDIO.activePlaylistLoader){const t=this.mainSegmentLoader_.getCurrentMediaInfo_();!t||t.hasVideo?e=e&&this.audioSegmentLoader_.ended_:e=this.audioSegmentLoader_.ended_}e&&(this.stopABRTimer_(),this.sourceUpdater_.endOfStream())}stuckAtPlaylistEnd_(e){if(!this.seekable().length)return!1;const i=this.syncController_.getExpiredTime(e,this.duration());if(i===null)return!1;const n=uo.Playlist.playlistEnd(e,i),r=this.tech_.currentTime(),o=this.tech_.buffered();if(!o.length)return n-r<=Ir;const u=o.end(o.length-1);return u-r<=Ir&&n-u<=Ir}excludePlaylist({playlistToExclude:e=this.mainPlaylistLoader_.media(),error:t={},playlistExclusionDuration:i}){if(e=e||this.mainPlaylistLoader_.media(),i=i||t.playlistExclusionDuration||this.playlistExclusionDuration,!e){this.error=t,this.mediaSource.readyState!=="open"?this.trigger("error"):this.sourceUpdater_.endOfStream("network");return}e.playlistErrors_++;const n=this.mainPlaylistLoader_.main.playlists,r=n.filter($m),o=r.length===1&&r[0]===e;if(n.length===1&&i!==1/0)return Te.log.warn(`Problem encountered with playlist ${e.id}. Trying again since it is the only playlist.`),this.tech_.trigger("retryplaylist"),this.mainPlaylistLoader_.load(o);if(o){if(this.main().contentSteering){const b=this.pathwayAttribute_(e),_=this.contentSteeringController_.steeringManifest.ttl*1e3;this.contentSteeringController_.excludePathway(b),this.excludeThenChangePathway_(),setTimeout(()=>{this.contentSteeringController_.addAvailablePathway(b)},_);return}let v=!1;n.forEach(b=>{if(b===e)return;const _=b.excludeUntil;typeof _<"u"&&_!==1/0&&(v=!0,delete b.excludeUntil)}),v&&(Te.log.warn("Removing other playlists from the exclusion list because the last rendition is about to be excluded."),this.tech_.trigger("retryplaylist"))}let u;e.playlistErrors_>this.maxPlaylistRetries?u=1/0:u=Date.now()+i*1e3,e.excludeUntil=u,t.reason&&(e.lastExcludeReason_=t.reason),this.tech_.trigger("excludeplaylist"),this.tech_.trigger({type:"usage",name:"vhs-rendition-excluded"});const c=this.selectPlaylist();if(!c){this.error="Playback cannot continue. No available working or supported playlists.",this.trigger("error");return}const d=t.internal?this.logger_:Te.log.warn,f=t.message?" "+t.message:"";d(`${t.internal?"Internal problem":"Problem"} encountered with playlist ${e.id}.${f} Switching to playlist ${c.id}.`),c.attributes.AUDIO!==e.attributes.AUDIO&&this.delegateLoaders_("audio",["abort","pause"]),c.attributes.SUBTITLES!==e.attributes.SUBTITLES&&this.delegateLoaders_("subtitle",["abort","pause"]),this.delegateLoaders_("main",["abort","pause"]);const m=c.targetDuration/2*1e3||5*1e3,g=typeof c.lastRequest=="number"&&Date.now()-c.lastRequest<=m;return this.switchMedia_(c,"exclude",o||g)}pauseLoading(){this.delegateLoaders_("all",["abort","pause"]),this.stopABRTimer_()}delegateLoaders_(e,t){const i=[],n=e==="all";(n||e==="main")&&i.push(this.mainPlaylistLoader_);const r=[];(n||e==="audio")&&r.push("AUDIO"),(n||e==="subtitle")&&(r.push("CLOSED-CAPTIONS"),r.push("SUBTITLES")),r.forEach(o=>{const u=this.mediaTypes_[o]&&this.mediaTypes_[o].activePlaylistLoader;u&&i.push(u)}),["main","audio","subtitle"].forEach(o=>{const u=this[`${o}SegmentLoader_`];u&&(e===o||e==="all")&&i.push(u)}),i.forEach(o=>t.forEach(u=>{typeof o[u]=="function"&&o[u]()}))}setCurrentTime(e){const t=Ru(this.tech_.buffered(),e);if(!(this.mainPlaylistLoader_&&this.mainPlaylistLoader_.media())||!this.mainPlaylistLoader_.media().segments)return 0;if(t&&t.length)return e;this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}duration(){if(!this.mainPlaylistLoader_)return 0;const e=this.mainPlaylistLoader_.media();return e?e.endList?this.mediaSource?this.mediaSource.duration:uo.Playlist.duration(e):1/0:0}seekable(){return this.seekable_}getSeekableRange_(e,t){const i=e.media();if(!i)return null;const n=this.syncController_.getMediaSequenceSync(t);if(n&&n.isReliable){const u=n.start,c=n.end;if(!isFinite(u)||!isFinite(c))return null;const d=uo.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,i),f=Math.max(u,c-d);return us([[u,f]])}const r=this.syncController_.getExpiredTime(i,this.duration());if(r===null)return null;const o=uo.Playlist.seekable(i,r,uo.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,i));return o.length?o:null}computeFinalSeekable_(e,t){if(!t)return e;const i=e.start(0),n=e.end(0),r=t.start(0),o=t.end(0);return r>n||i>o?e:us([[Math.max(i,r),Math.min(n,o)]])}onSyncInfoUpdate_(){if(!this.mainPlaylistLoader_)return;const e=this.getSeekableRange_(this.mainPlaylistLoader_,"main");if(!e)return;let t;if(this.mediaTypes_.AUDIO.activePlaylistLoader&&(t=this.getSeekableRange_(this.mediaTypes_.AUDIO.activePlaylistLoader,"audio"),!t))return;const i=this.seekable_;if(this.seekable_=this.computeFinalSeekable_(e,t),!this.seekable_||i&&i.length&&this.seekable_.length&&i.start(0)===this.seekable_.start(0)&&i.end(0)===this.seekable_.end(0))return;this.logger_(`seekable updated [${hD(this.seekable_)}]`);const n={seekableRanges:this.seekable_};this.trigger({type:"seekablerangeschanged",metadata:n}),this.tech_.trigger("seekablechanged")}updateDuration(e){if(this.updateDuration_&&(this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.updateDuration_=null),this.mediaSource.readyState!=="open"){this.updateDuration_=this.updateDuration.bind(this,e),this.mediaSource.addEventListener("sourceopen",this.updateDuration_);return}if(e){const n=this.seekable();if(!n.length)return;(isNaN(this.mediaSource.duration)||this.mediaSource.duration<n.end(n.length-1))&&this.sourceUpdater_.setDuration(n.end(n.length-1));return}const t=this.tech_.buffered();let i=uo.Playlist.duration(this.mainPlaylistLoader_.media());t.length>0&&(i=Math.max(i,t.end(t.length-1))),this.mediaSource.duration!==i&&this.sourceUpdater_.setDuration(i)}dispose(){this.trigger("dispose"),this.decrypter_.terminate(),this.mainPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),this.contentSteeringController_.dispose(),this.keyStatusMap_.clear(),this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_),["AUDIO","SUBTITLES"].forEach(e=>{const t=this.mediaTypes_[e].groups;for(const i in t)t[i].forEach(n=>{n.playlistLoader&&n.playlistLoader.dispose()})}),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose(),this.sourceUpdater_.dispose(),this.timelineChangeController_.dispose(),this.stopABRTimer_(),this.updateDuration_&&this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.mediaSource.removeEventListener("durationchange",this.handleDurationChange_),this.mediaSource.removeEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.removeEventListener("sourceended",this.handleSourceEnded_),this.off()}main(){return this.mainPlaylistLoader_.main}media(){return this.mainPlaylistLoader_.media()||this.initialMedia_}areMediaTypesKnown_(){const e=!!this.mediaTypes_.AUDIO.activePlaylistLoader,t=!!this.mainSegmentLoader_.getCurrentMediaInfo_(),i=e?!!this.audioSegmentLoader_.getCurrentMediaInfo_():!0;return!(!t||!i)}getCodecsOrExclude_(){const e={main:this.mainSegmentLoader_.getCurrentMediaInfo_()||{},audio:this.audioSegmentLoader_.getCurrentMediaInfo_()||{}},t=this.mainSegmentLoader_.getPendingSegmentPlaylist()||this.media();e.video=e.main;const i=$d(this.main(),t),n={},r=!!this.mediaTypes_.AUDIO.activePlaylistLoader;if(e.main.hasVideo&&(n.video=i.video||e.main.videoCodec||GP),e.main.isMuxed&&(n.video+=`,${i.audio||e.main.audioCodec||lE}`),(e.main.hasAudio&&!e.main.isMuxed||e.audio.hasAudio||r)&&(n.audio=i.audio||e.main.audioCodec||e.audio.audioCodec||lE,e.audio.isFmp4=e.main.hasAudio&&!e.main.isMuxed?e.main.isFmp4:e.audio.isFmp4),!n.audio&&!n.video){this.excludePlaylist({playlistToExclude:t,error:{message:"Could not determine codecs for playlist."},playlistExclusionDuration:1/0});return}const o=(d,f)=>d?Md(f,this.usingManagedMediaSource_):fy(f),u={};let c;if(["video","audio"].forEach(function(d){if(n.hasOwnProperty(d)&&!o(e[d].isFmp4,n[d])){const f=e[d].isFmp4?"browser":"muxer";u[f]=u[f]||[],u[f].push(n[d]),d==="audio"&&(c=f)}}),r&&c&&t.attributes.AUDIO){const d=t.attributes.AUDIO;this.main().playlists.forEach(f=>{(f.attributes&&f.attributes.AUDIO)===d&&f!==t&&(f.excludeUntil=1/0)}),this.logger_(`excluding audio group ${d} as ${c} does not support codec(s): "${n.audio}"`)}if(Object.keys(u).length){const d=Object.keys(u).reduce((f,m)=>(f&&(f+=", "),f+=`${m} does not support codec(s): "${u[m].join(",")}"`,f),"")+".";this.excludePlaylist({playlistToExclude:t,error:{internal:!0,message:d},playlistExclusionDuration:1/0});return}if(this.sourceUpdater_.hasCreatedSourceBuffers()&&!this.sourceUpdater_.canChangeType()){const d=[];if(["video","audio"].forEach(f=>{const m=(Ar(this.sourceUpdater_.codecs[f]||"")[0]||{}).type,g=(Ar(n[f]||"")[0]||{}).type;m&&g&&m.toLowerCase()!==g.toLowerCase()&&d.push(`"${this.sourceUpdater_.codecs[f]}" -> "${n[f]}"`)}),d.length){this.excludePlaylist({playlistToExclude:t,error:{message:`Codec switching not supported: ${d.join(", ")}.`,internal:!0},playlistExclusionDuration:1/0});return}}return n}tryToCreateSourceBuffers_(){if(this.mediaSource.readyState!=="open"||this.sourceUpdater_.hasCreatedSourceBuffers()||!this.areMediaTypesKnown_())return;const e=this.getCodecsOrExclude_();if(!e)return;this.sourceUpdater_.createSourceBuffers(e);const t=[e.video,e.audio].filter(Boolean).join(",");this.excludeIncompatibleVariants_(t)}excludeUnsupportedVariants_(){const e=this.main().playlists,t=[];Object.keys(e).forEach(i=>{const n=e[i];if(t.indexOf(n.id)!==-1)return;t.push(n.id);const r=$d(this.main,n),o=[];r.audio&&!fy(r.audio)&&!Md(r.audio,this.usingManagedMediaSource_)&&o.push(`audio codec ${r.audio}`),r.video&&!fy(r.video)&&!Md(r.video,this.usingManagedMediaSource_)&&o.push(`video codec ${r.video}`),r.text&&r.text==="stpp.ttml.im1t"&&o.push(`text codec ${r.text}`),o.length&&(n.excludeUntil=1/0,this.logger_(`excluding ${n.id} for unsupported: ${o.join(", ")}`))})}excludeIncompatibleVariants_(e){const t=[],i=this.main().playlists,n=Yd(Ar(e)),r=t1(n),o=n.video&&Ar(n.video)[0]||null,u=n.audio&&Ar(n.audio)[0]||null;Object.keys(i).forEach(c=>{const d=i[c];if(t.indexOf(d.id)!==-1||d.excludeUntil===1/0)return;t.push(d.id);const f=[],m=$d(this.mainPlaylistLoader_.main,d),g=t1(m);if(!(!m.audio&&!m.video)){if(g!==r&&f.push(`codec count "${g}" !== "${r}"`),!this.sourceUpdater_.canChangeType()){const v=m.video&&Ar(m.video)[0]||null,b=m.audio&&Ar(m.audio)[0]||null;v&&o&&v.type.toLowerCase()!==o.type.toLowerCase()&&f.push(`video codec "${v.type}" !== "${o.type}"`),b&&u&&b.type.toLowerCase()!==u.type.toLowerCase()&&f.push(`audio codec "${b.type}" !== "${u.type}"`)}f.length&&(d.excludeUntil=1/0,this.logger_(`excluding ${d.id}: ${f.join(" && ")}`))}})}updateAdCues_(e){let t=0;const i=this.seekable();i.length&&(t=i.start(0)),R4(e,this.cueTagsTrack_,t)}goalBufferLength(){const e=this.tech_.currentTime(),t=os.GOAL_BUFFER_LENGTH,i=os.GOAL_BUFFER_LENGTH_RATE,n=Math.max(t,os.MAX_GOAL_BUFFER_LENGTH);return Math.min(t+e*i,n)}bufferLowWaterLine(){const e=this.tech_.currentTime(),t=os.BUFFER_LOW_WATER_LINE,i=os.BUFFER_LOW_WATER_LINE_RATE,n=Math.max(t,os.MAX_BUFFER_LOW_WATER_LINE),r=Math.max(t,os.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE);return Math.min(t+e*i,this.bufferBasedABR?r:n)}bufferHighWaterLine(){return os.BUFFER_HIGH_WATER_LINE}addDateRangesToTextTrack_(e){u1(this.inbandTextTracks_,"com.apple.streaming",this.tech_),d4({inbandTextTracks:this.inbandTextTracks_,dateRanges:e})}addMetadataToTextTrack(e,t,i){const n=this.sourceUpdater_.videoBuffer?this.sourceUpdater_.videoTimestampOffset():this.sourceUpdater_.audioTimestampOffset();u1(this.inbandTextTracks_,e,this.tech_),l4({inbandTextTracks:this.inbandTextTracks_,metadataArray:t,timestampOffset:n,videoDuration:i})}pathwayAttribute_(e){return e.attributes["PATHWAY-ID"]||e.attributes.serviceLocation}initContentSteeringController_(){const e=this.main();if(e.contentSteering){for(const t of e.playlists)this.contentSteeringController_.addAvailablePathway(this.pathwayAttribute_(t));if(this.contentSteeringController_.assignTagProperties(e.uri,e.contentSteering),this.contentSteeringController_.queryBeforeStart){this.contentSteeringController_.requestSteeringManifest(!0);return}this.tech_.one("canplay",()=>{this.contentSteeringController_.requestSteeringManifest()})}}resetContentSteeringController_(){this.contentSteeringController_.clearAvailablePathways(),this.contentSteeringController_.dispose(),this.initContentSteeringController_()}attachContentSteeringListeners_(){this.contentSteeringController_.on("content-steering",this.excludeThenChangePathway_.bind(this)),["contentsteeringloadstart","contentsteeringloadcomplete","contentsteeringparsed"].forEach(t=>{this.contentSteeringController_.on(t,i=>{this.trigger(Hi({},i))})}),this.sourceType_==="dash"&&this.mainPlaylistLoader_.on("loadedplaylist",()=>{const t=this.main();(this.contentSteeringController_.didDASHTagChange(t.uri,t.contentSteering)||(()=>{const r=this.contentSteeringController_.getAvailablePathways(),o=[];for(const u of t.playlists){const c=u.attributes.serviceLocation;if(c&&(o.push(c),!r.has(c)))return!0}return!!(!o.length&&r.size)})())&&this.resetContentSteeringController_()})}excludeThenChangePathway_(){const e=this.contentSteeringController_.getPathway();if(!e)return;this.handlePathwayClones_();const i=this.main().playlists,n=new Set;let r=!1;Object.keys(i).forEach(o=>{const u=i[o],c=this.pathwayAttribute_(u),d=c&&e!==c;u.excludeUntil===1/0&&u.lastExcludeReason_==="content-steering"&&!d&&(delete u.excludeUntil,delete u.lastExcludeReason_,r=!0);const m=!u.excludeUntil&&u.excludeUntil!==1/0;!n.has(u.id)&&d&&m&&(n.add(u.id),u.excludeUntil=1/0,u.lastExcludeReason_="content-steering",this.logger_(`excluding ${u.id} for ${u.lastExcludeReason_}`))}),this.contentSteeringController_.manifestType_==="DASH"&&Object.keys(this.mediaTypes_).forEach(o=>{const u=this.mediaTypes_[o];if(u.activePlaylistLoader){const c=u.activePlaylistLoader.media_;c&&c.attributes.serviceLocation!==e&&(r=!0)}}),r&&this.changeSegmentPathway_()}handlePathwayClones_(){const t=this.main().playlists,i=this.contentSteeringController_.currentPathwayClones,n=this.contentSteeringController_.nextPathwayClones;if(i&&i.size||n&&n.size){for(const[o,u]of i.entries())n.get(o)||(this.mainPlaylistLoader_.updateOrDeleteClone(u),this.contentSteeringController_.excludePathway(o));for(const[o,u]of n.entries()){const c=i.get(o);if(!c){t.filter(f=>f.attributes["PATHWAY-ID"]===u["BASE-ID"]).forEach(f=>{this.mainPlaylistLoader_.addClonePathway(u,f)}),this.contentSteeringController_.addAvailablePathway(o);continue}this.equalPathwayClones_(c,u)||(this.mainPlaylistLoader_.updateOrDeleteClone(u,!0),this.contentSteeringController_.addAvailablePathway(o))}this.contentSteeringController_.currentPathwayClones=new Map(JSON.parse(JSON.stringify([...n])))}}equalPathwayClones_(e,t){if(e["BASE-ID"]!==t["BASE-ID"]||e.ID!==t.ID||e["URI-REPLACEMENT"].HOST!==t["URI-REPLACEMENT"].HOST)return!1;const i=e["URI-REPLACEMENT"].PARAMS,n=t["URI-REPLACEMENT"].PARAMS;for(const r in i)if(i[r]!==n[r])return!1;for(const r in n)if(i[r]!==n[r])return!1;return!0}changeSegmentPathway_(){const e=this.selectPlaylist();this.pauseLoading(),this.contentSteeringController_.manifestType_==="DASH"&&this.switchMediaForDASHContentSteering_(),this.switchMedia_(e,"content-steering")}excludeNonUsablePlaylistsByKeyId_(){if(!this.mainPlaylistLoader_||!this.mainPlaylistLoader_.main)return;let e=0;const t="non-usable";this.mainPlaylistLoader_.main.playlists.forEach(i=>{const n=this.mainPlaylistLoader_.getKeyIdSet(i);!n||!n.size||n.forEach(r=>{const o="usable",u=this.keyStatusMap_.has(r)&&this.keyStatusMap_.get(r)===o,c=i.lastExcludeReason_===t&&i.excludeUntil===1/0;u?u&&c&&(delete i.excludeUntil,delete i.lastExcludeReason_,this.logger_(`enabling playlist ${i.id} because key ID ${r} is ${o}`)):(i.excludeUntil!==1/0&&i.lastExcludeReason_!==t&&(i.excludeUntil=1/0,i.lastExcludeReason_=t,this.logger_(`excluding playlist ${i.id} because the key ID ${r} doesn't exist in the keyStatusMap or is not ${o}`)),e++)})}),e>=this.mainPlaylistLoader_.main.playlists.length&&this.mainPlaylistLoader_.main.playlists.forEach(i=>{const n=i&&i.attributes&&i.attributes.RESOLUTION&&i.attributes.RESOLUTION.height<720,r=i.excludeUntil===1/0&&i.lastExcludeReason_===t;n&&r&&(delete i.excludeUntil,Te.log.warn(`enabling non-HD playlist ${i.id} because all playlists were excluded due to ${t} key IDs`))})}addKeyStatus_(e,t){const r=(typeof e=="string"?e:w4(e)).slice(0,32).toLowerCase();this.logger_(`KeyStatus '${t}' with key ID ${r} added to the keyStatusMap`),this.keyStatusMap_.set(r,t)}updatePlaylistByKeyStatus(e,t){this.addKeyStatus_(e,t),this.waitingForFastQualityPlaylistReceived_||this.excludeNonUsableThenChangePlaylist_(),this.mainPlaylistLoader_.off("loadedplaylist",this.excludeNonUsableThenChangePlaylist_.bind(this)),this.mainPlaylistLoader_.on("loadedplaylist",this.excludeNonUsableThenChangePlaylist_.bind(this))}excludeNonUsableThenChangePlaylist_(){this.excludeNonUsablePlaylistsByKeyId_(),this.fastQualityChange_()}}const iB=(s,e,t)=>i=>{const n=s.main.playlists[e],r=YT(n),o=$m(n);if(typeof i>"u")return o;i?delete n.disabled:n.disabled=!0;const u={renditionInfo:{id:e,bandwidth:n.attributes.BANDWIDTH,resolution:n.attributes.RESOLUTION,codecs:n.attributes.CODECS},cause:"fast-quality"};return i!==o&&!r&&(i?(t(n),s.trigger({type:"renditionenabled",metadata:u})):s.trigger({type:"renditiondisabled",metadata:u})),i};class sB{constructor(e,t,i){const{playlistController_:n}=e,r=n.fastQualityChange_.bind(n);if(t.attributes){const o=t.attributes.RESOLUTION;this.width=o&&o.width,this.height=o&&o.height,this.bandwidth=t.attributes.BANDWIDTH,this.frameRate=t.attributes["FRAME-RATE"]}this.codecs=$d(n.main(),t),this.playlist=t,this.id=i,this.enabled=iB(e.playlists,t.id,r)}}const nB=function(s){s.representations=()=>{const e=s.playlistController_.main(),t=dh(e)?s.playlistController_.getAudioTrackPlaylists_():e.playlists;return t?t.filter(i=>!YT(i)).map((i,n)=>new sB(s,i,i.id)):[]}},b1=["seeking","seeked","pause","playing","error"];class rB extends Te.EventTarget{constructor(e){super(),this.playlistController_=e.playlistController,this.tech_=e.tech,this.seekable=e.seekable,this.allowSeeksWithinUnsafeLiveWindow=e.allowSeeksWithinUnsafeLiveWindow,this.liveRangeSafeTimeDelta=e.liveRangeSafeTimeDelta,this.media=e.media,this.playedRanges_=[],this.consecutiveUpdates=0,this.lastRecordedTime=null,this.checkCurrentTimeTimeout_=null,this.logger_=$n("PlaybackWatcher"),this.logger_("initialize");const t=()=>this.monitorCurrentTime_(),i=()=>this.monitorCurrentTime_(),n=()=>this.techWaiting_(),r=()=>this.resetTimeUpdate_(),o=this.playlistController_,u=["main","subtitle","audio"],c={};u.forEach(f=>{c[f]={reset:()=>this.resetSegmentDownloads_(f),updateend:()=>this.checkSegmentDownloads_(f)},o[`${f}SegmentLoader_`].on("appendsdone",c[f].updateend),o[`${f}SegmentLoader_`].on("playlistupdate",c[f].reset),this.tech_.on(["seeked","seeking"],c[f].reset)});const d=f=>{["main","audio"].forEach(m=>{o[`${m}SegmentLoader_`][f]("appended",this.seekingAppendCheck_)})};this.seekingAppendCheck_=()=>{this.fixesBadSeeks_()&&(this.consecutiveUpdates=0,this.lastRecordedTime=this.tech_.currentTime(),d("off"))},this.clearSeekingAppendCheck_=()=>d("off"),this.watchForBadSeeking_=()=>{this.clearSeekingAppendCheck_(),d("on")},this.tech_.on("seeked",this.clearSeekingAppendCheck_),this.tech_.on("seeking",this.watchForBadSeeking_),this.tech_.on("waiting",n),this.tech_.on(b1,r),this.tech_.on("canplay",i),this.tech_.one("play",t),this.dispose=()=>{this.clearSeekingAppendCheck_(),this.logger_("dispose"),this.tech_.off("waiting",n),this.tech_.off(b1,r),this.tech_.off("canplay",i),this.tech_.off("play",t),this.tech_.off("seeking",this.watchForBadSeeking_),this.tech_.off("seeked",this.clearSeekingAppendCheck_),u.forEach(f=>{o[`${f}SegmentLoader_`].off("appendsdone",c[f].updateend),o[`${f}SegmentLoader_`].off("playlistupdate",c[f].reset),this.tech_.off(["seeked","seeking"],c[f].reset)}),this.checkCurrentTimeTimeout_&&ne.clearTimeout(this.checkCurrentTimeTimeout_),this.resetTimeUpdate_()}}monitorCurrentTime_(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&ne.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=ne.setTimeout(this.monitorCurrentTime_.bind(this),250)}resetSegmentDownloads_(e){const t=this.playlistController_[`${e}SegmentLoader_`];this[`${e}StalledDownloads_`]>0&&this.logger_(`resetting possible stalled download count for ${e} loader`),this[`${e}StalledDownloads_`]=0,this[`${e}Buffered_`]=t.buffered_()}checkSegmentDownloads_(e){const t=this.playlistController_,i=t[`${e}SegmentLoader_`],n=i.buffered_(),r=V3(this[`${e}Buffered_`],n);if(this[`${e}Buffered_`]=n,r){const o={bufferedRanges:n};t.trigger({type:"bufferedrangeschanged",metadata:o}),this.resetSegmentDownloads_(e);return}this[`${e}StalledDownloads_`]++,this.logger_(`found #${this[`${e}StalledDownloads_`]} ${e} appends that did not increase buffer (possible stalled download)`,{playlistId:i.playlist_&&i.playlist_.id,buffered:gl(n)}),!(this[`${e}StalledDownloads_`]<10)&&(this.logger_(`${e} loader stalled download exclusion`),this.resetSegmentDownloads_(e),this.tech_.trigger({type:"usage",name:`vhs-${e}-download-exclusion`}),e!=="subtitle"&&t.excludePlaylist({error:{message:`Excessive ${e} segment downloading detected.`},playlistExclusionDuration:1/0}))}checkCurrentTime_(){if(this.tech_.paused()||this.tech_.seeking())return;const e=this.tech_.currentTime(),t=this.tech_.buffered();if(this.lastRecordedTime===e&&(!t.length||e+Ir>=t.end(t.length-1)))return this.techWaiting_();if(this.consecutiveUpdates>=5&&e===this.lastRecordedTime)this.consecutiveUpdates++,this.waiting_();else if(e===this.lastRecordedTime)this.consecutiveUpdates++;else{this.playedRanges_.push(us([this.lastRecordedTime,e]));const i={playedRanges:this.playedRanges_};this.playlistController_.trigger({type:"playedrangeschanged",metadata:i}),this.consecutiveUpdates=0,this.lastRecordedTime=e}}resetTimeUpdate_(){this.consecutiveUpdates=0}fixesBadSeeks_(){if(!this.tech_.seeking())return!1;const t=this.seekable(),i=this.tech_.currentTime(),n=this.afterSeekableWindow_(t,i,this.media(),this.allowSeeksWithinUnsafeLiveWindow);let r;if(n&&(r=t.end(t.length-1)),this.beforeSeekableWindow_(t,i)){const b=t.start(0);r=b+(b===t.end(0)?0:Ir)}if(typeof r<"u")return this.logger_(`Trying to seek outside of seekable at time ${i} with seekable range ${hD(t)}. Seeking to ${r}.`),this.tech_.setCurrentTime(r),!0;const o=this.playlistController_.sourceUpdater_,u=this.tech_.buffered(),c=o.audioBuffer?o.audioBuffered():null,d=o.videoBuffer?o.videoBuffered():null,f=this.media(),m=f.partTargetDuration?f.partTargetDuration:(f.targetDuration-Lr)*2,g=[c,d];for(let b=0;b<g.length;b++){if(!g[b])continue;if(zT(g[b],i)<m)return!1}const v=Kf(u,i);return v.length===0?!1:(r=v.start(0)+Ir,this.logger_(`Buffered region starts (${v.start(0)}) just beyond seek point (${i}). Seeking to ${r}.`),this.tech_.setCurrentTime(r),!0)}waiting_(){if(this.techWaiting_())return;const e=this.tech_.currentTime(),t=this.tech_.buffered(),i=Ru(t,e);if(i.length&&e+3<=i.end(0)){this.resetTimeUpdate_(),this.tech_.setCurrentTime(e),this.logger_(`Stopped at ${e} while inside a buffered region [${i.start(0)} -> ${i.end(0)}]. Attempting to resume playback by seeking to the current time.`),this.tech_.trigger({type:"usage",name:"vhs-unknown-waiting"});return}}techWaiting_(){const e=this.seekable(),t=this.tech_.currentTime();if(this.tech_.seeking())return!0;if(this.beforeSeekableWindow_(e,t)){const u=e.end(e.length-1);return this.logger_(`Fell out of live window at time ${t}. Seeking to live point (seekable end) ${u}`),this.resetTimeUpdate_(),this.tech_.setCurrentTime(u),this.tech_.trigger({type:"usage",name:"vhs-live-resync"}),!0}const i=this.tech_.vhs.playlistController_.sourceUpdater_,n=this.tech_.buffered();if(this.videoUnderflow_({audioBuffered:i.audioBuffered(),videoBuffered:i.videoBuffered(),currentTime:t}))return this.resetTimeUpdate_(),this.tech_.setCurrentTime(t),this.tech_.trigger({type:"usage",name:"vhs-video-underflow"}),!0;const o=Kf(n,t);return o.length>0?(this.logger_(`Stopped at ${t} and seeking to ${o.start(0)}`),this.resetTimeUpdate_(),this.skipTheGap_(t),!0):!1}afterSeekableWindow_(e,t,i,n=!1){if(!e.length)return!1;let r=e.end(e.length-1)+Ir;const o=!i.endList,u=typeof i.partTargetDuration=="number";return o&&(u||n)&&(r=e.end(e.length-1)+i.targetDuration*3),t>r}beforeSeekableWindow_(e,t){return!!(e.length&&e.start(0)>0&&t<e.start(0)-this.liveRangeSafeTimeDelta)}videoUnderflow_({videoBuffered:e,audioBuffered:t,currentTime:i}){if(!e)return;let n;if(e.length&&t.length){const r=Ru(e,i-3),o=Ru(e,i),u=Ru(t,i);u.length&&!o.length&&r.length&&(n={start:r.end(0),end:u.end(0)})}else Kf(e,i).length||(n=this.gapFromVideoUnderflow_(e,i));return n?(this.logger_(`Encountered a gap in video from ${n.start} to ${n.end}. Seeking to current time ${i}`),!0):!1}skipTheGap_(e){const t=this.tech_.buffered(),i=this.tech_.currentTime(),n=Kf(t,i);if(this.resetTimeUpdate_(),n.length===0||i!==e)return;this.logger_("skipTheGap_:","currentTime:",i,"scheduled currentTime:",e,"nextRange start:",n.start(0)),this.tech_.setCurrentTime(n.start(0)+Lr);const r={gapInfo:{from:i,to:n.start(0)}};this.playlistController_.trigger({type:"gapjumped",metadata:r}),this.tech_.trigger({type:"usage",name:"vhs-gap-skip"})}gapFromVideoUnderflow_(e,t){const i=j3(e);for(let n=0;n<i.length;n++){const r=i.start(n),o=i.end(n);if(t-r<4&&t-r>2)return{start:r,end:o}}return null}}const aB={errorInterval:30,getSource(s){const t=this.tech({IWillNotUseThisInPlugins:!0}).currentSource_||this.currentSource();return s(t)}},sw=function(s,e){let t=0,i=0;const n=Kt(aB,e);s.ready(()=>{s.trigger({type:"usage",name:"vhs-error-reload-initialized"})});const r=function(){i&&s.currentTime(i)},o=function(f){f!=null&&(i=s.duration()!==1/0&&s.currentTime()||0,s.one("loadedmetadata",r),s.src(f),s.trigger({type:"usage",name:"vhs-error-reload"}),s.play())},u=function(){if(Date.now()-t<n.errorInterval*1e3){s.trigger({type:"usage",name:"vhs-error-reload-canceled"});return}if(!n.getSource||typeof n.getSource!="function"){Te.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}return t=Date.now(),n.getSource.call(s,o)},c=function(){s.off("loadedmetadata",r),s.off("error",u),s.off("dispose",c)},d=function(f){c(),sw(s,f)};s.on("error",u),s.on("dispose",c),s.reloadSourceOnError=d},oB=function(s){sw(this,s)};var nw="3.17.2",lB="7.1.0",uB="1.3.1",cB="7.2.0",dB="4.0.2";const Ai={PlaylistLoader:Ou,Playlist:en,utils:g5,STANDARD_PLAYLIST_SELECTOR:l1,INITIAL_PLAYLIST_SELECTOR:s4,lastBandwidthSelector:l1,movingAverageBandwidthSelector:t4,comparePlaylistBandwidth:QT,comparePlaylistResolution:e4,xhr:kD()};Object.keys(os).forEach(s=>{Object.defineProperty(Ai,s,{get(){return Te.log.warn(`using Vhs.${s} is UNSAFE be sure you know what you are doing`),os[s]},set(e){if(Te.log.warn(`using Vhs.${s} is UNSAFE be sure you know what you are doing`),typeof e!="number"||e<0){Te.log.warn(`value of Vhs.${s} must be greater than or equal to 0`);return}os[s]=e}})});const rw="videojs-vhs",aw=function(s,e){const t=e.media();let i=-1;for(let n=0;n<s.length;n++)if(s[n].id===t.id){i=n;break}s.selectedIndex_=i,s.trigger({selectedIndex:i,type:"change"})},hB=function(s,e){e.representations().forEach(t=>{s.addQualityLevel(t)}),aw(s,e.playlists)};Ai.canPlaySource=function(){return Te.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};const fB=(s,e,t)=>{if(!s)return s;let i={};e&&e.attributes&&e.attributes.CODECS&&(i=Yd(Ar(e.attributes.CODECS))),t&&t.attributes&&t.attributes.CODECS&&(i.audio=t.attributes.CODECS);const n=Wu(i.video),r=Wu(i.audio),o={};for(const u in s)o[u]={},r&&(o[u].audioContentType=r),n&&(o[u].videoContentType=n),e.contentProtection&&e.contentProtection[u]&&e.contentProtection[u].pssh&&(o[u].pssh=e.contentProtection[u].pssh),typeof s[u]=="string"&&(o[u].url=s[u]);return Kt(s,o)},pB=(s,e)=>s.reduce((t,i)=>{if(!i.contentProtection)return t;const n=e.reduce((r,o)=>{const u=i.contentProtection[o];return u&&u.pssh&&(r[o]={pssh:u.pssh}),r},{});return Object.keys(n).length&&t.push(n),t},[]),mB=({player:s,sourceKeySystems:e,audioMedia:t,mainPlaylists:i})=>{if(!s.eme.initializeMediaKeys)return Promise.resolve();const n=t?i.concat([t]):i,r=pB(n,Object.keys(e)),o=[],u=[];return r.forEach(c=>{u.push(new Promise((d,f)=>{s.tech_.one("keysessioncreated",d)})),o.push(new Promise((d,f)=>{s.eme.initializeMediaKeys({keySystems:c},m=>{if(m){f(m);return}d()})}))}),Promise.race([Promise.all(o),Promise.race(u)])},gB=({player:s,sourceKeySystems:e,media:t,audioMedia:i})=>{const n=fB(e,t,i);return n?(s.currentSource().keySystems=n,n&&!s.eme?(Te.log.warn("DRM encrypted source cannot be decrypted without a DRM plugin"),!1):!0):!1},ow=()=>{if(!ne.localStorage)return null;const s=ne.localStorage.getItem(rw);if(!s)return null;try{return JSON.parse(s)}catch{return null}},yB=s=>{if(!ne.localStorage)return!1;let e=ow();e=e?Kt(e,s):s;try{ne.localStorage.setItem(rw,JSON.stringify(e))}catch{return!1}return e},vB=s=>s.toLowerCase().indexOf("data:application/vnd.videojs.vhs+json,")===0?JSON.parse(s.substring(s.indexOf(",")+1)):s,lw=(s,e)=>{s._requestCallbackSet||(s._requestCallbackSet=new Set),s._requestCallbackSet.add(e)},uw=(s,e)=>{s._responseCallbackSet||(s._responseCallbackSet=new Set),s._responseCallbackSet.add(e)},cw=(s,e)=>{s._requestCallbackSet&&(s._requestCallbackSet.delete(e),s._requestCallbackSet.size||delete s._requestCallbackSet)},dw=(s,e)=>{s._responseCallbackSet&&(s._responseCallbackSet.delete(e),s._responseCallbackSet.size||delete s._responseCallbackSet)};Ai.supportsNativeHls=(function(){if(!Ve||!Ve.createElement)return!1;const s=Ve.createElement("video");return Te.getTech("Html5").isSupported()?["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"].some(function(t){return/maybe|probably/i.test(s.canPlayType(t))}):!1})();Ai.supportsNativeDash=(function(){return!Ve||!Ve.createElement||!Te.getTech("Html5").isSupported()?!1:/maybe|probably/i.test(Ve.createElement("video").canPlayType("application/dash+xml"))})();Ai.supportsTypeNatively=s=>s==="hls"?Ai.supportsNativeHls:s==="dash"?Ai.supportsNativeDash:!1;Ai.isSupported=function(){return Te.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};Ai.xhr.onRequest=function(s){lw(Ai.xhr,s)};Ai.xhr.onResponse=function(s){uw(Ai.xhr,s)};Ai.xhr.offRequest=function(s){cw(Ai.xhr,s)};Ai.xhr.offResponse=function(s){dw(Ai.xhr,s)};const TB=Te.getComponent("Component");class hw extends TB{constructor(e,t,i){if(super(t,i.vhs),typeof i.initialBandwidth=="number"&&(this.options_.bandwidth=i.initialBandwidth),this.logger_=$n("VhsHandler"),t.options_&&t.options_.playerId){const n=Te.getPlayer(t.options_.playerId);this.player_=n}if(this.tech_=t,this.source_=e,this.stats={},this.ignoreNextSeekingEvent_=!1,this.setOptions_(),this.options_.overrideNative&&t.overrideNativeAudioTracks&&t.overrideNativeVideoTracks)t.overrideNativeAudioTracks(!0),t.overrideNativeVideoTracks(!0);else if(this.options_.overrideNative&&(t.featuresNativeVideoTracks||t.featuresNativeAudioTracks))throw new Error("Overriding native VHS requires emulated tracks. See https://git.io/vMpjB");this.on(Ve,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],n=>{const r=Ve.fullscreenElement||Ve.webkitFullscreenElement||Ve.mozFullScreenElement||Ve.msFullscreenElement;r&&r.contains(this.tech_.el())?this.playlistController_.fastQualityChange_():this.playlistController_.checkABR_()}),this.on(this.tech_,"seeking",function(){if(this.ignoreNextSeekingEvent_){this.ignoreNextSeekingEvent_=!1;return}this.setCurrentTime(this.tech_.currentTime())}),this.on(this.tech_,"error",function(){this.tech_.error()&&this.playlistController_&&this.playlistController_.pauseLoading()}),this.on(this.tech_,"play",this.play)}setOptions_(e={}){if(this.options_=Kt(this.options_,e),this.options_.withCredentials=this.options_.withCredentials||!1,this.options_.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions!==!1,this.options_.useDevicePixelRatio=this.options_.useDevicePixelRatio||!1,this.options_.usePlayerObjectFit=this.options_.usePlayerObjectFit||!1,this.options_.useBandwidthFromLocalStorage=typeof this.source_.useBandwidthFromLocalStorage<"u"?this.source_.useBandwidthFromLocalStorage:this.options_.useBandwidthFromLocalStorage||!1,this.options_.useForcedSubtitles=this.options_.useForcedSubtitles||!1,this.options_.useNetworkInformationApi=typeof this.options_.useNetworkInformationApi<"u"?this.options_.useNetworkInformationApi:!0,this.options_.useDtsForTimestampOffset=this.options_.useDtsForTimestampOffset||!1,this.options_.customTagParsers=this.options_.customTagParsers||[],this.options_.customTagMappers=this.options_.customTagMappers||[],this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||!1,this.options_.llhls=this.options_.llhls!==!1,this.options_.bufferBasedABR=this.options_.bufferBasedABR||!1,typeof this.options_.playlistExclusionDuration!="number"&&(this.options_.playlistExclusionDuration=60),typeof this.options_.bandwidth!="number"&&this.options_.useBandwidthFromLocalStorage){const i=ow();i&&i.bandwidth&&(this.options_.bandwidth=i.bandwidth,this.tech_.trigger({type:"usage",name:"vhs-bandwidth-from-local-storage"})),i&&i.throughput&&(this.options_.throughput=i.throughput,this.tech_.trigger({type:"usage",name:"vhs-throughput-from-local-storage"}))}typeof this.options_.bandwidth!="number"&&(this.options_.bandwidth=os.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===os.INITIAL_BANDWIDTH,["withCredentials","useDevicePixelRatio","usePlayerObjectFit","customPixelRatio","limitRenditionByPlayerDimensions","bandwidth","customTagParsers","customTagMappers","cacheEncryptionKeys","playlistSelector","initialPlaylistSelector","bufferBasedABR","liveRangeSafeTimeDelta","llhls","useForcedSubtitles","useNetworkInformationApi","useDtsForTimestampOffset","exactManifestTimings","leastPixelDiffSelector"].forEach(i=>{typeof this.source_[i]<"u"&&(this.options_[i]=this.source_[i])}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions,this.useDevicePixelRatio=this.options_.useDevicePixelRatio,this.usePlayerObjectFit=this.options_.usePlayerObjectFit;const t=this.options_.customPixelRatio;typeof t=="number"&&t>=0&&(this.customPixelRatio=t)}setOptions(e={}){this.setOptions_(e)}src(e,t){if(!e)return;this.setOptions_(),this.options_.src=vB(this.source_.src),this.options_.tech=this.tech_,this.options_.externVhs=Ai,this.options_.sourceType=OA(t),this.options_.seekTo=r=>{this.tech_.setCurrentTime(r)},this.options_.player_=this.player_,this.playlistController_=new tB(this.options_);const i=Kt({liveRangeSafeTimeDelta:Ir},this.options_,{seekable:()=>this.seekable(),media:()=>this.playlistController_.media(),playlistController:this.playlistController_});this.playbackWatcher_=new rB(i),this.attachStreamingEventListeners_(),this.playlistController_.on("error",()=>{const r=Te.players[this.tech_.options_.playerId];let o=this.playlistController_.error;typeof o=="object"&&!o.code?o.code=3:typeof o=="string"&&(o={message:o,code:3}),r.error(o)});const n=this.options_.bufferBasedABR?Ai.movingAverageBandwidthSelector(.55):Ai.STANDARD_PLAYLIST_SELECTOR;this.playlistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):n.bind(this),this.playlistController_.selectInitialPlaylist=Ai.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.playlistController_.mainPlaylistLoader_,this.mediaSource=this.playlistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get(){return this.playlistController_.selectPlaylist},set(r){this.playlistController_.selectPlaylist=r.bind(this)}},throughput:{get(){return this.playlistController_.mainSegmentLoader_.throughput.rate},set(r){this.playlistController_.mainSegmentLoader_.throughput.rate=r,this.playlistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get(){let r=this.playlistController_.mainSegmentLoader_.bandwidth;const o=ne.navigator.connection||ne.navigator.mozConnection||ne.navigator.webkitConnection,u=1e7;if(this.options_.useNetworkInformationApi&&o){const c=o.downlink*1e3*1e3;c>=u&&r>=u?r=Math.max(r,c):r=c}return r},set(r){this.playlistController_.mainSegmentLoader_.bandwidth=r,this.playlistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get(){const r=1/(this.bandwidth||1);let o;return this.throughput>0?o=1/this.throughput:o=0,Math.floor(1/(r+o))},set(){Te.log.error('The "systemBandwidth" property is read-only')}}}),this.options_.bandwidth&&(this.bandwidth=this.options_.bandwidth),this.options_.throughput&&(this.throughput=this.options_.throughput),Object.defineProperties(this.stats,{bandwidth:{get:()=>this.bandwidth||0,enumerable:!0},mediaRequests:{get:()=>this.playlistController_.mediaRequests_()||0,enumerable:!0},mediaRequestsAborted:{get:()=>this.playlistController_.mediaRequestsAborted_()||0,enumerable:!0},mediaRequestsTimedout:{get:()=>this.playlistController_.mediaRequestsTimedout_()||0,enumerable:!0},mediaRequestsErrored:{get:()=>this.playlistController_.mediaRequestsErrored_()||0,enumerable:!0},mediaTransferDuration:{get:()=>this.playlistController_.mediaTransferDuration_()||0,enumerable:!0},mediaBytesTransferred:{get:()=>this.playlistController_.mediaBytesTransferred_()||0,enumerable:!0},mediaSecondsLoaded:{get:()=>this.playlistController_.mediaSecondsLoaded_()||0,enumerable:!0},mediaAppends:{get:()=>this.playlistController_.mediaAppends_()||0,enumerable:!0},mainAppendsToLoadedData:{get:()=>this.playlistController_.mainAppendsToLoadedData_()||0,enumerable:!0},audioAppendsToLoadedData:{get:()=>this.playlistController_.audioAppendsToLoadedData_()||0,enumerable:!0},appendsToLoadedData:{get:()=>this.playlistController_.appendsToLoadedData_()||0,enumerable:!0},timeToLoadedData:{get:()=>this.playlistController_.timeToLoadedData_()||0,enumerable:!0},buffered:{get:()=>gl(this.tech_.buffered()),enumerable:!0},currentTime:{get:()=>this.tech_.currentTime(),enumerable:!0},currentSource:{get:()=>this.tech_.currentSource_,enumerable:!0},currentTech:{get:()=>this.tech_.name_,enumerable:!0},duration:{get:()=>this.tech_.duration(),enumerable:!0},main:{get:()=>this.playlists.main,enumerable:!0},playerDimensions:{get:()=>this.tech_.currentDimensions(),enumerable:!0},seekable:{get:()=>gl(this.tech_.seekable()),enumerable:!0},timestamp:{get:()=>Date.now(),enumerable:!0},videoPlaybackQuality:{get:()=>this.tech_.getVideoPlaybackQuality(),enumerable:!0}}),this.tech_.one("canplay",this.playlistController_.setupFirstPlay.bind(this.playlistController_)),this.tech_.on("bandwidthupdate",()=>{this.options_.useBandwidthFromLocalStorage&&yB({bandwidth:this.bandwidth,throughput:Math.round(this.throughput)})}),this.playlistController_.on("selectedinitialmedia",()=>{nB(this)}),this.playlistController_.sourceUpdater_.on("createdsourcebuffers",()=>{this.setupEme_()}),this.on(this.playlistController_,"progress",function(){this.tech_.trigger("progress")}),this.on(this.playlistController_,"firstplay",function(){this.ignoreNextSeekingEvent_=!0}),this.setupQualityLevels_(),this.tech_.el()&&(this.mediaSourceUrl_=ne.URL.createObjectURL(this.playlistController_.mediaSource),(Te.browser.IS_ANY_SAFARI||Te.browser.IS_IOS)&&this.options_.overrideNative&&this.options_.sourceType==="hls"&&typeof this.tech_.addSourceElement=="function"?(this.tech_.addSourceElement(this.mediaSourceUrl_),this.tech_.addSourceElement(this.source_.src)):this.tech_.src(this.mediaSourceUrl_))}createKeySessions_(){const e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader;this.logger_("waiting for EME key session creation"),mB({player:this.player_,sourceKeySystems:this.source_.keySystems,audioMedia:e&&e.media(),mainPlaylists:this.playlists.main.playlists}).then(()=>{this.logger_("created EME key session"),this.playlistController_.sourceUpdater_.initializedEme()}).catch(t=>{this.logger_("error while creating EME key session",t),this.player_.error({message:"Failed to initialize media keys for EME",code:3})})}handleWaitingForKey_(){this.logger_("waitingforkey fired, attempting to create any new key sessions"),this.createKeySessions_()}setupEme_(){const e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader,t=gB({player:this.player_,sourceKeySystems:this.source_.keySystems,media:this.playlists.media(),audioMedia:e&&e.media()});if(this.player_.tech_.on("keystatuschange",i=>{this.playlistController_.updatePlaylistByKeyStatus(i.keyId,i.status)}),this.handleWaitingForKey_=this.handleWaitingForKey_.bind(this),this.player_.tech_.on("waitingforkey",this.handleWaitingForKey_),!t){this.playlistController_.sourceUpdater_.initializedEme();return}this.createKeySessions_()}setupQualityLevels_(){const e=Te.players[this.tech_.options_.playerId];!e||!e.qualityLevels||this.qualityLevels_||(this.qualityLevels_=e.qualityLevels(),this.playlistController_.on("selectedinitialmedia",()=>{hB(this.qualityLevels_,this)}),this.playlists.on("mediachange",()=>{aw(this.qualityLevels_,this.playlists)}))}static version(){return{"@videojs/http-streaming":nw,"mux.js":lB,"mpd-parser":uB,"m3u8-parser":cB,"aes-decrypter":dB}}version(){return this.constructor.version()}canChangeType(){return JD.canChangeType()}play(){this.playlistController_.play()}setCurrentTime(e){this.playlistController_.setCurrentTime(e)}duration(){return this.playlistController_.duration()}seekable(){return this.playlistController_.seekable()}dispose(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.playlistController_&&this.playlistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),this.tech_&&this.tech_.vhs&&delete this.tech_.vhs,this.mediaSourceUrl_&&ne.URL.revokeObjectURL&&(ne.URL.revokeObjectURL(this.mediaSourceUrl_),this.mediaSourceUrl_=null),this.tech_&&this.tech_.off("waitingforkey",this.handleWaitingForKey_),super.dispose()}convertToProgramTime(e,t){return S5({playlist:this.playlistController_.media(),time:e,callback:t})}seekToProgramTime(e,t,i=!0,n=2){return ND({programTime:e,playlist:this.playlistController_.media(),retryCount:n,pauseAfterSeek:i,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:t})}setupXhrHooks_(){this.xhr.onRequest=e=>{lw(this.xhr,e)},this.xhr.onResponse=e=>{uw(this.xhr,e)},this.xhr.offRequest=e=>{cw(this.xhr,e)},this.xhr.offResponse=e=>{dw(this.xhr,e)},this.player_.trigger("xhr-hooks-ready")}attachStreamingEventListeners_(){const e=["seekablerangeschanged","bufferedrangeschanged","contentsteeringloadstart","contentsteeringloadcomplete","contentsteeringparsed"],t=["gapjumped","playedrangeschanged"];e.forEach(i=>{this.playlistController_.on(i,n=>{this.player_.trigger(Hi({},n))})}),t.forEach(i=>{this.playbackWatcher_.on(i,n=>{this.player_.trigger(Hi({},n))})})}}const Xp={name:"videojs-http-streaming",VERSION:nw,canHandleSource(s,e={}){const t=Kt(Te.options,e);return!t.vhs.experimentalUseMMS&&!Md("avc1.4d400d,mp4a.40.2",!1)?!1:Xp.canPlayType(s.type,t)},handleSource(s,e,t={}){const i=Kt(Te.options,t);return e.vhs=new hw(s,e,i),e.vhs.xhr=kD(),e.vhs.setupXhrHooks_(),e.vhs.src(s.src,s.type),e.vhs},canPlayType(s,e){const t=OA(s);if(!t)return"";const i=Xp.getOverrideNative(e);return!Ai.supportsTypeNatively(t)||i?"maybe":""},getOverrideNative(s={}){const{vhs:e={}}=s,t=!(Te.browser.IS_ANY_SAFARI||Te.browser.IS_IOS),{overrideNative:i=t}=e;return i}},bB=()=>Md("avc1.4d400d,mp4a.40.2",!0);bB()&&Te.getTech("Html5").registerSourceHandler(Xp,0);Te.VhsHandler=hw;Te.VhsSourceHandler=Xp;Te.Vhs=Ai;Te.use||Te.registerComponent("Vhs",Ai);Te.options.vhs=Te.options.vhs||{};(!Te.getPlugin||!Te.getPlugin("reloadSourceOnError"))&&Te.registerPlugin("reloadSourceOnError",oB);const Xf=s=>(s||"").replaceAll("\\","/").split("/").pop()||"";function al(...s){return s.filter(Boolean).join(" ")}function _B({job:s,expanded:e,onClose:t,onToggleExpand:i,className:n,isHot:r=!1,isFavorite:o=!1,isLiked:u=!1,onDelete:c,onToggleHot:d,onToggleFavorite:f,onToggleLike:m}){const g=j.useMemo(()=>Xf(s.output?.trim()||"")||s.id,[s.output,s.id]);j.useEffect(()=>{const Q=ae=>ae.key==="Escape"&&t();return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[t]);const v=j.useMemo(()=>{if(s.status==="running")return{src:`/api/record/preview?id=${encodeURIComponent(s.id)}&file=index_hq.m3u8`,type:"application/x-mpegURL"};const Q=Xf(s.output?.trim()||"");return Q?{src:`/api/record/video?file=${encodeURIComponent(Q)}`,type:"video/mp4"}:{src:`/api/record/video?id=${encodeURIComponent(s.id)}`,type:"video/mp4"}},[s.id,s.output,s.status]),b=j.useRef(null),_=j.useRef(null),E=j.useRef(null),[w,I]=j.useState(!1);j.useEffect(()=>I(!0),[]),j.useLayoutEffect(()=>{if(!w||!b.current||_.current)return;const Q=document.createElement("video");Q.className="video-js vjs-big-play-centered w-full h-full",Q.setAttribute("playsinline","true"),b.current.appendChild(Q),E.current=Q;const ae=Te(Q,{autoplay:!0,muted:!0,controls:!0,preload:"metadata",playsinline:!0,responsive:!0,fluid:!1,fill:!0,controlBar:{skipButtons:{backward:10,forward:10},children:["playToggle","progressControl","currentTimeDisplay","timeDivider","durationDisplay","volumePanel","playbackRateMenuButton","fullscreenToggle"]},playbackRates:[.5,1,1.25,1.5,2]});return _.current=ae,()=>{try{_.current&&(_.current.dispose(),_.current=null)}finally{E.current&&(E.current.remove(),E.current=null)}}},[w]),j.useEffect(()=>{if(!w)return;const Q=_.current;if(!Q||Q.isDisposed?.())return;const ae=Q.currentTime()||0;Q.muted(!0),Q.src({src:v.src,type:v.type});const ue=()=>{const U=Q.play?.();U&&typeof U.catch=="function"&&U.catch(()=>{})};Q.one("loadedmetadata",()=>{Q.isDisposed?.()||(ae>0&&v.type!=="application/x-mpegURL"&&Q.currentTime(ae),ue())}),ue()},[w,v.src,v.type]),j.useEffect(()=>{const Q=_.current;!Q||Q.isDisposed?.()||queueMicrotask(()=>Q.trigger("resize"))},[e]);const L=j.useCallback(()=>{const Q=_.current;if(!(!Q||Q.isDisposed?.())){try{Q.pause(),Q.reset?.()}catch{}try{Q.src({src:"",type:"video/mp4"}),Q.load?.()}catch{}}},[]);j.useEffect(()=>{const Q=ae=>{const U=(ae.detail?.file??"").trim();if(!U)return;const ie=Xf(s.output?.trim()||"");ie&&ie===U&&L()};return window.addEventListener("player:release",Q),()=>window.removeEventListener("player:release",Q)},[s.output,L]),j.useEffect(()=>{const Q=ae=>{const U=(ae.detail?.file??"").trim();if(!U)return;const ie=Xf(s.output?.trim()||"");ie&&ie===U&&(L(),t())};return window.addEventListener("player:close",Q),()=>window.removeEventListener("player:close",Q)},[s.output,L,t]);const F=!e,[$,G]=j.useState(!1),[B,V]=j.useState(!1),[k,R]=j.useState(!1),z=j.useRef(null),X=j.useCallback(()=>{z.current&&window.clearTimeout(z.current),z.current=null,R(!1)},[]),ee=j.useCallback(()=>{R(!0),z.current&&window.clearTimeout(z.current),z.current=window.setTimeout(()=>{R(!1),z.current=null},500)},[]);j.useEffect(()=>{e&&B&&ee()},[e,B,ee]),j.useEffect(()=>()=>{z.current&&window.clearTimeout(z.current)},[]),j.useEffect(()=>{e||R(!1)},[e]),j.useEffect(()=>{const Q=window.matchMedia?.("(hover: hover) and (pointer: fine)"),ae=()=>V(!!Q?.matches);return ae(),Q?.addEventListener?.("change",ae),()=>Q?.removeEventListener?.("change",ae)},[]),j.useEffect(()=>{F||G(!1)},[F]);const le=F&&(B?$:!0);if(!w)return null;const oe="inline-flex items-center justify-center rounded-md bg-black/40 p-2 text-white backdrop-blur hover:bg-black/55 transition focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed",Z=P.jsxs("div",{className:"flex items-center gap-1",children:[P.jsx("button",{type:"button",className:oe,title:r?"HOT entfernen":"Als HOT markieren","aria-label":r?"HOT entfernen":"Als HOT markieren",onClick:async Q=>{Q.stopPropagation(),L(),await new Promise(ue=>setTimeout(ue,150)),await d?.(s),await new Promise(ue=>setTimeout(ue,0));const ae=_.current;if(ae&&!ae.isDisposed?.()){const ue=ae.play?.();ue&&typeof ue.catch=="function"&&ue.catch(()=>{})}},disabled:!d,children:P.jsx(EA,{className:al("h-5 w-5",r?"text-amber-300":"text-white")})}),P.jsx("button",{type:"button",className:oe,title:o?"Favorite entfernen":"Als Favorite markieren","aria-label":o?"Favorite entfernen":"Als Favorite markieren",onClick:Q=>{Q.stopPropagation(),f?.(s)},disabled:!f,children:P.jsx(AA,{className:al("h-5 w-5",o?"text-pink-300":"text-white")})}),P.jsx("button",{type:"button",className:oe,title:u?"Like entfernen":"Like hinzufügen","aria-label":u?"Like entfernen":"Like hinzufügen",onClick:Q=>{Q.stopPropagation(),m?.(s)},disabled:!m,children:P.jsx(XO,{className:al("h-5 w-5",u?"text-indigo-200":"text-white")})}),P.jsx("button",{type:"button",className:"inline-flex items-center justify-center rounded-md bg-red-600/35 p-2 text-white backdrop-blur hover:bg-red-600/55 transition focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed",title:"Löschen","aria-label":"Löschen",onClick:async Q=>{Q.stopPropagation(),L(),t(),await new Promise(ae=>setTimeout(ae,150)),await c?.(s)},disabled:!c,children:P.jsx(Pd,{className:"h-5 w-5"})})]});return ih.createPortal(P.jsxs(P.Fragment,{children:[e&&P.jsx("div",{className:"fixed inset-0 z-40 bg-black/45 backdrop-blur-[1px] transition-opacity",onClick:t,"aria-hidden":"true"}),P.jsx(Pn,{edgeToEdgeMobile:!0,noBodyPadding:!0,className:al("fixed z-50 flex flex-col shadow-2xl ring-1 ring-black/10 dark:ring-white/10",e?"inset-4 sm:inset-6":"left-0 right-0 bottom-0 w-full rounded-none pb-[env(safe-area-inset-bottom)] sm:rounded-lg sm:left-auto sm:right-4 sm:bottom-4 sm:w-[420px]",n??""),bodyClassName:"flex flex-col flex-1 min-h-0 p-0",children:P.jsx("div",{className:e?"flex-1 min-h-0":"aspect-video",children:P.jsxs("div",{className:al("relative w-full h-full",F&&"vjs-mini",B&&"vjs-controls-on-activity",B&&k&&"vjs-controls-active"),onMouseEnter:F?()=>{G(!0),B&&ee()}:e&&B?ee:void 0,onMouseMove:B?ee:void 0,onMouseLeave:()=>{F&&G(!1),B&&X()},onFocusCapture:e&&B?()=>R(!0):void 0,onBlurCapture:e&&B?Q=>{const ae=Q.relatedTarget;(!ae||!Q.currentTarget.contains(ae))&&X()}:void 0,children:[P.jsx("div",{ref:b,className:"absolute inset-0"}),P.jsxs("div",{className:"absolute inset-x-2 top-2 z-20 flex items-start justify-between gap-2",children:[P.jsx("div",{className:"min-w-0",children:P.jsx("div",{className:"player-ui max-w-[70vw] sm:max-w-[320px] truncate rounded-md bg-black/45 px-2.5 py-1.5 text-xs font-semibold text-white backdrop-blur",children:g})}),P.jsxs("div",{className:"flex items-center gap-1",children:[P.jsx("button",{type:"button",className:"inline-flex items-center justify-center rounded-md bg-black/40 p-2 text-white backdrop-blur hover:bg-black/55 transition focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-500",onClick:i,"aria-label":e?"Minimieren":"Maximieren",title:e?"Minimieren":"Maximieren",children:e?P.jsx(GO,{className:"h-5 w-5"}):P.jsx(qO,{className:"h-5 w-5"})}),P.jsx("button",{type:"button",className:"inline-flex items-center justify-center rounded-md bg-black/40 p-2 text-white backdrop-blur hover:bg-black/55 transition focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-500",onClick:t,"aria-label":"Schließen",title:"Schließen",children:P.jsx(CA,{className:"h-5 w-5"})})]})]}),!e&&P.jsxs(P.Fragment,{children:[P.jsx("div",{className:al("player-ui pointer-events-none absolute inset-x-0 bg-gradient-to-t from-black/70 to-transparent","transition-all duration-200 ease-out",le?"bottom-7 h-24":"bottom-0 h-20")}),P.jsxs("div",{className:al("player-ui absolute inset-x-2 z-20 flex items-end justify-between gap-2","transition-all duration-200 ease-out",le?"bottom-7":"bottom-2"),children:[P.jsxs("div",{className:"min-w-0 rounded-md bg-black/45 px-2.5 py-1.5 text-[11px] text-white/90 backdrop-blur",children:[P.jsx("span",{className:"font-semibold text-white",children:s.status}),s.output?P.jsxs("span",{className:"ml-2 opacity-80",children:["• ",s.output]}):null]}),Z]})]})]})})})]}),document.body)}const We=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)},xB=Number.isSafeInteger||function(s){return typeof s=="number"&&Math.abs(s)<=SB},SB=Number.MAX_SAFE_INTEGER||9007199254740991;let nt=(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})({}),ve=(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})({}),N=(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="hlsSubtitleTracksUpdated",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 It={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},Je={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};class Su{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 EB{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_=new Su(e),this.fast_=new Su(t),this.defaultTTFB_=n,this.ttfb_=new Su(e)}update(e,t){const{slow_:i,fast_:n,ttfb_:r}=this;i.halfLife!==e&&(this.slow_=new Su(e,i.getEstimate(),i.getTotalWeight())),n.halfLife!==t&&(this.fast_=new Su(t,n.getEstimate(),n.getTotalWeight())),r.halfLife!==e&&(this.ttfb_=new Su(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 AB(s,e,t){return(e=DB(e))in s?Object.defineProperty(s,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[e]=t,s}function ni(){return ni=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},ni.apply(null,arguments)}function _1(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 Qt(s){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?_1(Object(t),!0).forEach(function(i){AB(s,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):_1(Object(t)).forEach(function(i){Object.defineProperty(s,i,Object.getOwnPropertyDescriptor(t,i))})}return s}function CB(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 DB(s){var e=CB(s,"string");return typeof e=="symbol"?e:e+""}class jn{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=mo,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 mo=function(){},wB={trace:mo,debug:mo,log:mo,warn:mo,info:mo,error:mo};function Hv(){return ni({},wB)}function LB(s,e){const t=self.console[s];return t?t.bind(self.console,`${e?"["+e+"] ":""}[${s}] >`):mo}function x1(s,e,t){return e[s]?e[s].bind(e):LB(s,t)}const Gv=Hv();function IB(s,e,t){const i=Hv();if(typeof console=="object"&&s===!0||typeof s=="object"){const n=["debug","log","info","warn","error"];n.forEach(r=>{i[r]=x1(r,s,t)});try{i.log(`Debug logs enabled for "${e}" in hls.js version 1.6.15`)}catch{return Hv()}n.forEach(r=>{Gv[r]=x1(r,s)})}else ni(Gv,i);return i}const Zt=Gv;function Eo(s=!0){return typeof self>"u"?void 0:(s||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function kB(s){return typeof self<"u"&&s===self.ManagedMediaSource}function fw(s,e){const t=Object.keys(s),i=Object.keys(e),n=t.length,r=i.length;return!n||!r||n===r&&!t.some(o=>i.indexOf(o)===-1)}function xn(s,e=!1){if(typeof TextDecoder<"u"){const d=new TextDecoder("utf-8").decode(s);if(e){const f=d.indexOf("\0");return f!==-1?d.substring(0,f):d}return d.replace(/\0/g,"")}const t=s.length;let i,n,r,o="",u=0;for(;u<t;){if(i=s[u++],i===0&&e)return o;if(i===0||i===3)continue;switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(i);break;case 12:case 13:n=s[u++],o+=String.fromCharCode((i&31)<<6|n&63);break;case 14:n=s[u++],r=s[u++],o+=String.fromCharCode((i&15)<<12|(n&63)<<6|(r&63)<<0);break}}return o}function gs(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 pw(s){return Uint8Array.from(s.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function RB(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Py={exports:{}},S1;function OB(){return S1||(S1=1,(function(s,e){(function(t){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,n=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,o=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,u={buildAbsoluteURL:function(c,d,f){if(f=f||{},c=c.trim(),d=d.trim(),!d){if(!f.alwaysNormalize)return c;var m=u.parseURL(c);if(!m)throw new Error("Error trying to parse base URL.");return m.path=u.normalizePath(m.path),u.buildURLFromParts(m)}var g=u.parseURL(d);if(!g)throw new Error("Error trying to parse relative URL.");if(g.scheme)return f.alwaysNormalize?(g.path=u.normalizePath(g.path),u.buildURLFromParts(g)):d;var v=u.parseURL(c);if(!v)throw new Error("Error trying to parse base URL.");if(!v.netLoc&&v.path&&v.path[0]!=="/"){var b=n.exec(v.path);v.netLoc=b[1],v.path=b[2]}v.netLoc&&!v.path&&(v.path="/");var _={scheme:v.scheme,netLoc:g.netLoc,path:null,params:g.params,query:g.query,fragment:g.fragment};if(!g.netLoc&&(_.netLoc=v.netLoc,g.path[0]!=="/"))if(!g.path)_.path=v.path,g.params||(_.params=v.params,g.query||(_.query=v.query));else{var E=v.path,w=E.substring(0,E.lastIndexOf("/")+1)+g.path;_.path=u.normalizePath(w)}return _.path===null&&(_.path=f.alwaysNormalize?u.normalizePath(g.path):g.path),u.buildURLFromParts(_)},parseURL:function(c){var d=i.exec(c);return d?{scheme:d[1]||"",netLoc:d[2]||"",path:d[3]||"",params:d[4]||"",query:d[5]||"",fragment:d[6]||""}:null},normalizePath:function(c){for(c=c.split("").reverse().join("").replace(r,"");c.length!==(c=c.replace(o,"")).length;);return c.split("").reverse().join("")},buildURLFromParts:function(c){return c.scheme+c.netLoc+c.path+c.params+c.query+c.fragment}};s.exports=u})()})(Py)),Py.exports}var ZT=OB();class JT{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 oi={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class mw{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,MB(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={[oi.AUDIO]:null,[oi.VIDEO]:null,[oi.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 JT),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=ZT.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[oi.AUDIO]=null,e[oi.VIDEO]=null,e[oi.AUDIOVIDEO]=null}}function ji(s){return s.sn!=="initSegment"}class My extends mw{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(We(e)&&We(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=We(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(!We(e)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=e}get ref(){return ji(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,o=!1){const{elementaryStreams:u}=this,c=u[e];if(!c){u[e]={startPTS:t,endPTS:i,startDTS:n,endDTS:r,partial:o};return}c.startPTS=Math.min(c.startPTS,t),c.endPTS=Math.max(c.endPTS,i),c.startDTS=Math.min(c.startDTS,n),c.endDTS=Math.max(c.endDTS,r)}}class PB extends mw{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 o=e.enumeratedString("BYTERANGE");o&&this.setByteRange(o,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 gw(s,e){const t=Object.getPrototypeOf(s);if(t){const i=Object.getOwnPropertyDescriptor(t,e);return i||gw(t,e)}}function MB(s,e){const t=gw(s,e);t&&(t.enumerable=!0,Object.defineProperty(s,e,t))}const E1=Math.pow(2,32)-1,NB=[].push,yw={video:1,audio:2,id3:3,text:4};function Zi(s){return String.fromCharCode.apply(null,s)}function vw(s,e){const t=s[e]<<8|s[e+1];return t<0?65536+t:t}function pt(s,e){const t=Tw(s,e);return t<0?4294967296+t:t}function A1(s,e){let t=pt(s,e);return t*=Math.pow(2,32),t+=pt(s,e+4),t}function Tw(s,e){return s[e]<<24|s[e+1]<<16|s[e+2]<<8|s[e+3]}function BB(s){const e=s.byteLength;for(let t=0;t<e;){const i=pt(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 wt(s,e){const t=[];if(!e.length)return t;const i=s.byteLength;for(let n=0;n<i;){const r=pt(s,n),o=Zi(s.subarray(n+4,n+8)),u=r>1?n+r:i;if(o===e[0])if(e.length===1)t.push(s.subarray(n+8,u));else{const c=wt(s.subarray(n+8,u),e.slice(1));c.length&&NB.apply(t,c)}n=u}return t}function FB(s){const e=[],t=s[0];let i=8;const n=pt(s,i);i+=4;let r=0,o=0;t===0?(r=pt(s,i),o=pt(s,i+4),i+=8):(r=A1(s,i),o=A1(s,i+8),i+=16),i+=2;let u=s.length+o;const c=vw(s,i);i+=2;for(let d=0;d<c;d++){let f=i;const m=pt(s,f);f+=4;const g=m&2147483647;if((m&2147483648)>>>31===1)return Zt.warn("SIDX has hierarchical references (not supported)"),null;const b=pt(s,f);f+=4,e.push({referenceSize:g,subsegmentDuration:b,info:{duration:b/n,start:u,end:u+g-1}}),u+=g,f+=4,i=f}return{earliestPresentationTime:r,timescale:n,version:t,referencesCount:c,references:e}}function bw(s){const e=[],t=wt(s,["moov","trak"]);for(let n=0;n<t.length;n++){const r=t[n],o=wt(r,["tkhd"])[0];if(o){let u=o[0];const c=pt(o,u===0?12:20),d=wt(r,["mdia","mdhd"])[0];if(d){u=d[0];const f=pt(d,u===0?12:20),m=wt(r,["mdia","hdlr"])[0];if(m){const g=Zi(m.subarray(8,12)),v={soun:oi.AUDIO,vide:oi.VIDEO}[g],b=wt(r,["mdia","minf","stbl","stsd"])[0],_=UB(b);v?(e[c]={timescale:f,type:v,stsd:_},e[v]=Qt({timescale:f,id:c},_)):e[c]={timescale:f,type:g,stsd:_}}}}}return wt(s,["moov","mvex","trex"]).forEach(n=>{const r=pt(n,4),o=e[r];o&&(o.default={duration:pt(n,12),flags:pt(n,20)})}),e}function UB(s){const e=s.subarray(8),t=e.subarray(86),i=Zi(e.subarray(4,8));let n=i,r;const o=i==="enca"||i==="encv";if(o){const d=wt(e,[i])[0].subarray(i==="enca"?28:78);wt(d,["sinf"]).forEach(m=>{const g=wt(m,["schm"])[0];if(g){const v=Zi(g.subarray(4,8));if(v==="cbcs"||v==="cenc"){const b=wt(m,["frma"])[0];b&&(n=Zi(b))}}})}const u=n;switch(n){case"avc1":case"avc2":case"avc3":case"avc4":{const c=wt(t,["avcC"])[0];c&&c.length>3&&(n+="."+Zf(c[1])+Zf(c[2])+Zf(c[3]),r=Qf(u==="avc1"?"dva1":"dvav",t));break}case"mp4a":{const c=wt(e,[i])[0],d=wt(c.subarray(28),["esds"])[0];if(d&&d.length>7){let f=4;if(d[f++]!==3)break;f=Ny(d,f),f+=2;const m=d[f++];if(m&128&&(f+=2),m&64&&(f+=d[f++]),d[f++]!==4)break;f=Ny(d,f);const g=d[f++];if(g===64)n+="."+Zf(g);else break;if(f+=12,d[f++]!==5)break;f=Ny(d,f);const v=d[f++];let b=(v&248)>>3;b===31&&(b+=1+((v&7)<<3)+((d[f]&224)>>5)),n+="."+b}break}case"hvc1":case"hev1":{const c=wt(t,["hvcC"])[0];if(c&&c.length>12){const d=c[1],f=["","A","B","C"][d>>6],m=d&31,g=pt(c,2),v=(d&32)>>5?"H":"L",b=c[12],_=c.subarray(6,12);n+="."+f+m,n+="."+$B(g).toString(16).toUpperCase(),n+="."+v+b;let E="";for(let w=_.length;w--;){const I=_[w];(I||E)&&(E="."+I.toString(16).toUpperCase()+E)}n+=E}r=Qf(u=="hev1"?"dvhe":"dvh1",t);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":{n=Qf(n,t)||n;break}case"vp09":{const c=wt(t,["vpcC"])[0];if(c&&c.length>6){const d=c[4],f=c[5],m=c[6]>>4&15;n+="."+Er(d)+"."+Er(f)+"."+Er(m)}break}case"av01":{const c=wt(t,["av1C"])[0];if(c&&c.length>2){const d=c[1]>>>5,f=c[1]&31,m=c[2]>>>7?"H":"M",g=(c[2]&64)>>6,v=(c[2]&32)>>5,b=d===2&&g?v?12:10:g?10:8,_=(c[2]&16)>>4,E=(c[2]&8)>>3,w=(c[2]&4)>>2,I=c[2]&3;n+="."+d+"."+Er(f)+m+"."+Er(b)+"."+_+"."+E+w+I+"."+Er(1)+"."+Er(1)+"."+Er(1)+"."+0,r=Qf("dav1",t)}break}}return{codec:n,encrypted:o,supplemental:r}}function Qf(s,e){const t=wt(e,["dvvC"]),i=t.length?t[0]:wt(e,["dvcC"])[0];if(i){const n=i[2]>>1&127,r=i[2]<<5&32|i[3]>>3&31;return s+"."+Er(n)+"."+Er(r)}}function $B(s){let e=0;for(let t=0;t<32;t++)e|=(s>>t&1)<<31-t;return e>>>0}function Ny(s,e){const t=e+5;for(;s[e++]&128&&e<t;);return e}function Zf(s){return("0"+s.toString(16).toUpperCase()).slice(-2)}function Er(s){return(s<10?"0":"")+s}function jB(s,e){if(!s||!e)return;const t=e.keyId;t&&e.isCommonEncryption&&_w(s,(i,n)=>{const r=i.subarray(8,24);r.some(o=>o!==0)||(Zt.log(`[eme] Patching keyId in 'enc${n?"a":"v"}>sinf>>tenc' box: ${gs(r)} -> ${gs(t)}`),i.set(t,8))})}function HB(s){const e=[];return _w(s,t=>e.push(t.subarray(8,24))),e}function _w(s,e){wt(s,["moov","trak"]).forEach(i=>{const n=wt(i,["mdia","minf","stbl","stsd"])[0];if(!n)return;const r=n.subarray(8);let o=wt(r,["enca"]);const u=o.length>0;u||(o=wt(r,["encv"])),o.forEach(c=>{const d=u?c.subarray(28):c.subarray(78);wt(d,["sinf"]).forEach(m=>{const g=xw(m);g&&e(g,u)})})})}function xw(s){const e=wt(s,["schm"])[0];if(e){const t=Zi(e.subarray(4,8));if(t==="cbcs"||t==="cenc"){const i=wt(s,["schi","tenc"])[0];if(i)return i}}}function GB(s,e,t){const i={},n=wt(s,["moof","traf"]);for(let r=0;r<n.length;r++){const o=n[r],u=wt(o,["tfhd"])[0],c=pt(u,4),d=e[c];if(!d)continue;i[c]||(i[c]={start:NaN,duration:0,sampleCount:0,timescale:d.timescale,type:d.type});const f=i[c],m=wt(o,["tfdt"])[0];if(m){const L=m[0];let F=pt(m,4);L===1&&(F===E1?t.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(F*=E1+1,F+=pt(m,8))),We(F)&&(!We(f.start)||F<f.start)&&(f.start=F)}const g=d.default,v=pt(u,0)|g?.flags;let b=g?.duration||0;v&8&&(v&2?b=pt(u,12):b=pt(u,8));const _=wt(o,["trun"]);let E=f.start||0,w=0,I=b;for(let L=0;L<_.length;L++){const F=_[L],$=pt(F,4),G=f.sampleCount;f.sampleCount+=$;const B=F[3]&1,V=F[3]&4,k=F[2]&1,R=F[2]&2,z=F[2]&4,X=F[2]&8;let ee=8,le=$;for(B&&(ee+=4),V&&$&&(!(F[ee+1]&1)&&f.keyFrameIndex===void 0&&(f.keyFrameIndex=G),ee+=4,k?(I=pt(F,ee),ee+=4):I=b,R&&(ee+=4),X&&(ee+=4),E+=I,w+=I,le--);le--;)k?(I=pt(F,ee),ee+=4):I=b,R&&(ee+=4),z&&(F[ee+1]&1||f.keyFrameIndex===void 0&&(f.keyFrameIndex=f.sampleCount-(le+1),f.keyFrameStart=E),ee+=4),X&&(ee+=4),E+=I,w+=I;!w&&b&&(w+=b*$)}f.duration+=w}if(!Object.keys(i).some(r=>i[r].duration)){let r=1/0,o=0;const u=wt(s,["sidx"]);for(let c=0;c<u.length;c++){const d=FB(u[c]);if(d!=null&&d.references){r=Math.min(r,d.earliestPresentationTime/d.timescale);const f=d.references.reduce((m,g)=>m+g.info.duration||0,0);o=Math.max(o,f+d.earliestPresentationTime/d.timescale)}}o&&We(o)&&Object.keys(i).forEach(c=>{i[c].duration||(i[c].duration=o*i[c].timescale-i[c].start)})}return i}function VB(s){const e={valid:null,remainder:null},t=wt(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 Fn(s,e){const t=new Uint8Array(s.length+e.length);return t.set(s),t.set(e,s.length),t}function C1(s,e){const t=[],i=e.samples,n=e.timescale,r=e.id;let o=!1;return wt(i,["moof"]).map(c=>{const d=c.byteOffset-8;wt(c,["traf"]).map(m=>{const g=wt(m,["tfdt"]).map(v=>{const b=v[0];let _=pt(v,4);return b===1&&(_*=Math.pow(2,32),_+=pt(v,8)),_/n})[0];return g!==void 0&&(s=g),wt(m,["tfhd"]).map(v=>{const b=pt(v,4),_=pt(v,0)&16777215,E=(_&1)!==0,w=(_&2)!==0,I=(_&8)!==0;let L=0;const F=(_&16)!==0;let $=0;const G=(_&32)!==0;let B=8;b===r&&(E&&(B+=8),w&&(B+=4),I&&(L=pt(v,B),B+=4),F&&($=pt(v,B),B+=4),G&&(B+=4),e.type==="video"&&(o=jm(e.codec)),wt(m,["trun"]).map(V=>{const k=V[0],R=pt(V,0)&16777215,z=(R&1)!==0;let X=0;const ee=(R&4)!==0,le=(R&256)!==0;let oe=0;const Y=(R&512)!==0;let Z=0;const Q=(R&1024)!==0,ae=(R&2048)!==0;let ue=0;const U=pt(V,4);let ie=8;z&&(X=pt(V,ie),ie+=4),ee&&(ie+=4);let fe=X+d;for(let xe=0;xe<U;xe++){if(le?(oe=pt(V,ie),ie+=4):oe=L,Y?(Z=pt(V,ie),ie+=4):Z=$,Q&&(ie+=4),ae&&(k===0?ue=pt(V,ie):ue=Tw(V,ie),ie+=4),e.type===oi.VIDEO){let Ae=0;for(;Ae<Z;){const $e=pt(i,fe);if(fe+=4,qB(o,i[fe])){const Ee=i.subarray(fe,fe+$e);eb(Ee,o?2:1,s+ue/n,t)}fe+=$e,Ae+=$e+4}}s+=oe/n}}))})})}),t}function jm(s){if(!s)return!1;const e=s.substring(0,4);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function qB(s,e){if(s){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function eb(s,e,t,i){const n=Sw(s);let r=0;r+=e;let o=0,u=0,c=0;for(;r<n.length;){o=0;do{if(r>=n.length)break;c=n[r++],o+=c}while(c===255);u=0;do{if(r>=n.length)break;c=n[r++],u+=c}while(c===255);const d=n.length-r;let f=r;if(u<d)r+=u;else if(u>d){Zt.error(`Malformed SEI payload. ${u} is too small, only ${d} bytes left to parse.`);break}if(o===4){if(n[f++]===181){const g=vw(n,f);if(f+=2,g===49){const v=pt(n,f);if(f+=4,v===1195456820){const b=n[f++];if(b===3){const _=n[f++],E=31&_,w=64&_,I=w?2+E*3:0,L=new Uint8Array(I);if(w){L[0]=_;for(let F=1;F<I;F++)L[F]=n[f++]}i.push({type:b,payloadType:o,pts:t,bytes:L})}}}}}else if(o===5&&u>16){const m=[];for(let b=0;b<16;b++){const _=n[f++].toString(16);m.push(_.length==1?"0"+_:_),(b===3||b===5||b===7||b===9)&&m.push("-")}const g=u-16,v=new Uint8Array(g);for(let b=0;b<g;b++)v[b]=n[f++];i.push({payloadType:o,pts:t,uuid:m.join(""),userData:xn(v),userDataBytes:v})}}}function Sw(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 o=0;for(i=0;i<n;o++,i++)o===t[0]&&(o++,t.shift()),r[i]=s[o];return r}function zB(s){const e=s[0];let t="",i="",n=0,r=0,o=0,u=0,c=0,d=0;if(e===0){for(;Zi(s.subarray(d,d+1))!=="\0";)t+=Zi(s.subarray(d,d+1)),d+=1;for(t+=Zi(s.subarray(d,d+1)),d+=1;Zi(s.subarray(d,d+1))!=="\0";)i+=Zi(s.subarray(d,d+1)),d+=1;i+=Zi(s.subarray(d,d+1)),d+=1,n=pt(s,12),r=pt(s,16),u=pt(s,20),c=pt(s,24),d=28}else if(e===1){d+=4,n=pt(s,d),d+=4;const m=pt(s,d);d+=4;const g=pt(s,d);for(d+=4,o=2**32*m+g,xB(o)||(o=Number.MAX_SAFE_INTEGER,Zt.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),u=pt(s,d),d+=4,c=pt(s,d),d+=4;Zi(s.subarray(d,d+1))!=="\0";)t+=Zi(s.subarray(d,d+1)),d+=1;for(t+=Zi(s.subarray(d,d+1)),d+=1;Zi(s.subarray(d,d+1))!=="\0";)i+=Zi(s.subarray(d,d+1)),d+=1;i+=Zi(s.subarray(d,d+1)),d+=1}const f=s.subarray(d,s.byteLength);return{schemeIdUri:t,value:i,timeScale:n,presentationTime:o,presentationTimeDelta:r,eventDuration:u,id:c,payload:f}}function KB(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 YB(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 o=new Uint8Array(4);return t.byteLength>0&&new DataView(o.buffer).setUint32(0,t.byteLength,!1),KB([112,115,115,104],new Uint8Array([i,0,0,0]),s,r,n,o,t)}function WB(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=XB(n);e.push(r),i+=r.size}}return e}function XB(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 o=s.buffer,u=gs(new Uint8Array(o,t+12,16));let c=null,d=null,f=0;if(r===0)f=28;else{const g=s.getUint32(28);if(!g||i<32+g*16)return{offset:t,size:e};c=[];for(let v=0;v<g;v++)c.push(new Uint8Array(o,t+32+v*16,16));f=32+g*16}if(!f)return{offset:t,size:e};const m=s.getUint32(f);return e-32<m?{offset:t,size:e}:(d=new Uint8Array(o,t+f+4,m),{version:r,systemId:u,kids:c,data:d,offset:t,size:e})}const Ew=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),nc={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 tb(s,e){const t=nc[e];return!!t&&!!t[s.slice(0,4)]}function Wd(s,e,t=!0){return!s.split(",").some(i=>!ib(i,e,t))}function ib(s,e,t=!0){var i;const n=Eo(t);return(i=n?.isTypeSupported(Xd(s,e)))!=null?i:!1}function Xd(s,e){return`${e}/mp4;codecs=${s}`}function D1(s){if(s){const e=s.substring(0,4);return nc.video[e]}return 2}function Qp(s){const e=Ew();return s.split(",").reduce((t,i)=>{const r=e&&jm(i)?9:nc.video[i];return r?(r*2+t)/(t?3:2):(nc.audio[i]+t)/(t?2:1)},0)}const By={};function QB(s,e=!0){if(By[s])return By[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(ib(t[n],"audio",e))return By[s]=t[n],t[n];if(t[n]==="mp3"&&(i=Eo(e))!=null&&i.isTypeSupported("audio/mpeg"))return""}return s}const ZB=/flac|opus|mp4a\.40\.34/i;function Zp(s,e=!0){return s.replace(ZB,t=>QB(t.toLowerCase(),e))}function JB(s,e){const t=[];if(s){const i=s.split(",");for(let n=0;n<i.length;n++)tb(i[n],"video")||t.push(i[n])}return e&&t.push(e),t.join(",")}function Tp(s,e){if(s&&(s.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(s)!==-1)&&(w1(s,"audio")||w1(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 w1(s,e){return tb(s,e)&&ib(s,e)}function eF(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 tF(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 L1(s){const e=Eo(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 Vv(s){return s.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const iF={supported:!0,powerEfficient:!0,smooth:!0},sF={supported:!1,smooth:!1,powerEfficient:!1},Aw={supported:!0,configurations:[],decodingInfoResults:[iF]};function Cw(s,e){return{supported:!1,configurations:e,decodingInfoResults:[sF],error:s}}function nF(s,e,t,i,n,r){const o=s.videoCodec,u=s.audioCodec?s.audioGroups:null,c=r?.audioCodec,d=r?.channels,f=d?parseInt(d):c?1/0:2;let m=null;if(u!=null&&u.length)try{u.length===1&&u[0]?m=e.groups[u[0]].channels:m=u.reduce((g,v)=>{if(v){const b=e.groups[v];if(!b)throw new Error(`Audio track group ${v} not found`);Object.keys(b.channels).forEach(_=>{g[_]=(g[_]||0)+b.channels[_]})}return g},{2:0})}catch{return!0}return o!==void 0&&(o.split(",").some(g=>jm(g))||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))||!!m&&We(f)&&Object.keys(m).some(g=>parseInt(g)>f)}function Dw(s,e,t,i={}){const n=s.videoCodec;if(!n&&!s.audioCodec||!t)return Promise.resolve(Aw);const r=[],o=rF(s),u=o.length,c=aF(s,e,u>0),d=c.length;for(let f=u||1*d||1;f--;){const m={type:"media-source"};if(u&&(m.video=o[f%u]),d){m.audio=c[f%d];const g=m.audio.bitrate;m.video&&g&&(m.video.bitrate-=g)}r.push(m)}if(n){const f=navigator.userAgent;if(n.split(",").some(m=>jm(m))&&Ew())return Promise.resolve(Cw(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${f})`),r))}return Promise.all(r.map(f=>{const m=lF(f);return i[m]||(i[m]=t.decodingInfo(f))})).then(f=>({supported:!f.some(m=>!m.supported),configurations:r,decodingInfoResults:f})).catch(f=>({supported:!1,configurations:r,decodingInfoResults:[],error:f}))}function rF(s){var e;const t=(e=s.videoCodec)==null?void 0:e.split(","),i=ww(s),n=s.width||640,r=s.height||480,o=s.frameRate||30,u=s.videoRange.toLowerCase();return t?t.map(c=>{const d={contentType:Xd(tF(c),"video"),width:n,height:r,bitrate:i,framerate:o};return u!=="sdr"&&(d.transferFunction=u),d}):[]}function aF(s,e,t){var i;const n=(i=s.audioCodec)==null?void 0:i.split(","),r=ww(s);return n&&s.audioGroups?s.audioGroups.reduce((o,u)=>{var c;const d=u?(c=e.groups[u])==null?void 0:c.tracks:null;return d?d.reduce((f,m)=>{if(m.groupId===u){const g=parseFloat(m.channels||"");n.forEach(v=>{const b={contentType:Xd(v,"audio"),bitrate:t?oF(v,r):r};g&&(b.channels=""+g),f.push(b)})}return f},o):o},[]):[]}function oF(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 ww(s){return Math.ceil(Math.max(s.bitrate*.9,s.averageBitrate)/1e3)*1e3||1}function lF(s){let e="";const{audio:t,video:i}=s;if(i){const n=Vv(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=Vv(t.contentType);e+=`${i?"_":""}${n}_c${t.channels}`}return e}const qv=["NONE","TYPE-0","TYPE-1",null];function uF(s){return qv.indexOf(s)>-1}const Jp=["SDR","PQ","HLG"];function cF(s){return!!s&&Jp.indexOf(s)>-1}var bp={No:"",Yes:"YES",v2:"v2"};function I1(s){const{canSkipUntil:e,canSkipDateRanges:t,age:i}=s,n=i<e/2;return e&&n?t?bp.v2:bp.Yes:bp.No}class k1{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 Qd{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 R1(this._audioGroups,e)}hasSubtitleGroup(e){return R1(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 R1(s,e){return!e||!s?!1:s.indexOf(e)!==-1}function dF(){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 hF(s,e){let t=!1,i=[];if(s&&(t=s!=="SDR",i=[s]),e){i=e.allowedVideoRanges||Jp.slice(0);const n=i.join("")!=="SDR"&&!e.videoCodec;t=e.preferHDR!==void 0?e.preferHDR:n&&dF(),t||(i=["SDR"])}return{preferHDR:t,allowedVideoRanges:i}}const fF=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}},ui=(s,e)=>JSON.stringify(s,fF(e));function pF(s,e,t,i,n){const r=Object.keys(s),o=i?.channels,u=i?.audioCodec,c=n?.videoCodec,d=o&&parseInt(o)===2;let f=!1,m=!1,g=1/0,v=1/0,b=1/0,_=1/0,E=0,w=[];const{preferHDR:I,allowedVideoRanges:L}=hF(e,n);for(let V=r.length;V--;){const k=s[r[V]];f||(f=k.channels[2]>0),g=Math.min(g,k.minHeight),v=Math.min(v,k.minFramerate),b=Math.min(b,k.minBitrate),L.filter(z=>k.videoRanges[z]>0).length>0&&(m=!0)}g=We(g)?g:0,v=We(v)?v:0;const F=Math.max(1080,g),$=Math.max(30,v);b=We(b)?b:t,t=Math.max(b,t),m||(e=void 0);const G=r.length>1;return{codecSet:r.reduce((V,k)=>{const R=s[k];if(k===V)return V;if(w=m?L.filter(z=>R.videoRanges[z]>0):[],G){if(R.minBitrate>t)return _r(k,`min bitrate of ${R.minBitrate} > current estimate of ${t}`),V;if(!R.hasDefaultAudio)return _r(k,"no renditions with default or auto-select sound found"),V;if(u&&k.indexOf(u.substring(0,4))%5!==0)return _r(k,`audio codec preference "${u}" not found`),V;if(o&&!d){if(!R.channels[o])return _r(k,`no renditions with ${o} channel sound found (channels options: ${Object.keys(R.channels)})`),V}else if((!u||d)&&f&&R.channels[2]===0)return _r(k,"no renditions with stereo sound found"),V;if(R.minHeight>F)return _r(k,`min resolution of ${R.minHeight} > maximum of ${F}`),V;if(R.minFramerate>$)return _r(k,`min framerate of ${R.minFramerate} > maximum of ${$}`),V;if(!w.some(z=>R.videoRanges[z]>0))return _r(k,`no variants with VIDEO-RANGE of ${ui(w)} found`),V;if(c&&k.indexOf(c.substring(0,4))%5!==0)return _r(k,`video codec preference "${c}" not found`),V;if(R.maxScore<E)return _r(k,`max score of ${R.maxScore} < selected max of ${E}`),V}return V&&(Qp(k)>=Qp(V)||R.fragmentError>s[V].fragmentError)?V:(_=R.minIndex,E=R.maxScore,k)},void 0),videoRanges:w,preferHDR:I,minFramerate:v,minBitrate:b,minIndex:_}}function _r(s,e){Zt.log(`[abr] start candidates with "${s}" ignored because ${e}`)}function Lw(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 mF(s,e,t,i){return s.slice(t,i+1).reduce((n,r,o)=>{if(!r.codecSet)return n;const u=r.audioGroups;let c=n[r.codecSet];c||(n[r.codecSet]=c={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:o,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!u,fragmentError:0}),c.minBitrate=Math.min(c.minBitrate,r.bitrate);const d=Math.min(r.height,r.width);return c.minHeight=Math.min(c.minHeight,d),c.minFramerate=Math.min(c.minFramerate,r.frameRate),c.minIndex=Math.min(c.minIndex,o),c.maxScore=Math.max(c.maxScore,r.score),c.fragmentError+=r.fragmentError,c.videoRanges[r.videoRange]=(c.videoRanges[r.videoRange]||0)+1,u&&u.forEach(f=>{if(!f)return;const m=e.groups[f];m&&(c.hasDefaultAudio=c.hasDefaultAudio||e.hasDefaultAudio?m.hasDefault:m.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(m.channels).forEach(g=>{c.channels[g]=(c.channels[g]||0)+m.channels[g]}))}),n},{})}function O1(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 Rr(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(xl(s,n,t))return i}return-1}function xl(s,e,t){const{groupId:i,name:n,lang:r,assocLang:o,default:u}=s,c=s.forced;return(i===void 0||e.groupId===i)&&(n===void 0||e.name===n)&&(r===void 0||gF(r,e.lang))&&(r===void 0||e.assocLang===o)&&(u===void 0||e.default===u)&&(c===void 0||e.forced===c)&&(!("characteristics"in s)||yF(s.characteristics||"",e.characteristics))&&(t===void 0||t(s,e))}function gF(s,e="--"){return s.length===e.length?s===e:s.startsWith(e)||e.startsWith(s)}function yF(s,e=""){const t=s.split(","),i=e.split(",");return t.length===i.length&&!t.some(n=>i.indexOf(n)===-1)}function dl(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 vF(s,e,t,i,n){const r=e[i],u=e.reduce((g,v,b)=>{const _=v.uri;return(g[_]||(g[_]=[])).push(b),g},{})[r.uri];u.length>1&&(i=Math.max.apply(Math,u));const c=r.videoRange,d=r.frameRate,f=r.codecSet.substring(0,4),m=P1(e,i,g=>{if(g.videoRange!==c||g.frameRate!==d||g.codecSet.substring(0,4)!==f)return!1;const v=g.audioGroups,b=t.filter(_=>!v||v.indexOf(_.groupId)!==-1);return Rr(s,b,n)>-1});return m>-1?m:P1(e,i,g=>{const v=g.audioGroups,b=t.filter(_=>!v||v.indexOf(_.groupId)!==-1);return Rr(s,b,n)>-1})}function P1(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 em(s,e){var t;return!!s&&s!==((t=e.loadLevelObj)==null?void 0:t.uri)}class TF extends jn{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:o}=this,{autoLevelEnabled:u,media:c}=o;if(!n||!c)return;const d=performance.now(),f=r?r.stats:n.stats,m=r?r.duration:n.duration,g=d-f.loading.start,v=o.minAutoLevel,b=n.level,_=this._nextAutoLevel;if(f.aborted||f.loaded&&f.loaded===f.total||b<=v){this.clearTimer(),this._nextAutoLevel=-1;return}if(!u)return;const E=_>-1&&_!==b,w=!!t||E;if(!w&&(c.paused||!c.playbackRate||!c.readyState))return;const I=o.mainForwardBufferInfo;if(!w&&I===null)return;const L=this.bwEstimator.getEstimateTTFB(),F=Math.abs(c.playbackRate);if(g<=Math.max(L,1e3*(m/(F*2))))return;const $=I?I.len/F:0,G=f.loading.first?f.loading.first-f.loading.start:-1,B=f.loaded&&G>-1,V=this.getBwEstimate(),k=o.levels,R=k[b],z=Math.max(f.loaded,Math.round(m*(n.bitrate||R.averageBitrate)/8));let X=B?g-G:g;X<1&&B&&(X=Math.min(g,f.loaded*8/V));const ee=B?f.loaded*1e3/X:0,le=L/1e3,oe=ee?(z-f.loaded)/ee:z*8/V+le;if(oe<=$)return;const Y=ee?ee*8:V,Z=((i=t?.details||this.hls.latestLevelDetails)==null?void 0:i.live)===!0,Q=this.hls.config.abrBandWidthUpFactor;let ae=Number.POSITIVE_INFINITY,ue;for(ue=b-1;ue>v;ue--){const xe=k[ue].maxBitrate,Ae=!k[ue].details||Z;if(ae=this.getTimeToLoadFrag(le,Y,m*xe,Ae),ae<Math.min($,m+le))break}if(ae>=oe||ae>m*10)return;B?this.bwEstimator.sample(g-Math.min(L,G),f.loaded):this.bwEstimator.sampleTTFB(g);const U=k[ue].maxBitrate;this.getBwEstimate()*Q>U&&this.resetEstimator(U);const ie=this.findBestLevel(U,v,ue,0,$,1,1);ie>-1&&(ue=ie),this.warn(`Fragment ${n.sn}${r?" part "+r.index:""} of level ${b} is loading too slowly;
Fragment duration: ${n.duration.toFixed(3)}
Time to underbuffer: ${$.toFixed(3)} s
Estimated load time for current fragment: ${oe.toFixed(3)} s
Estimated load time for down switch fragment: ${ae.toFixed(3)} s
TTFB estimate: ${G|0} ms
Current BW estimate: ${We(V)?V|0:"Unknown"} bps
New BW estimate: ${this.getBwEstimate()|0} bps
Switching to level ${ue} @ ${U|0} bps`),o.nextLoadLevel=o.nextAutoLevel=ue,this.clearTimer();const fe=()=>{if(this.clearTimer(),this.fragCurrent===n&&this.hls.loadLevel===ue&&ue>0){const xe=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${ue>0?"and switching down":""}
Fragment duration: ${n.duration.toFixed(3)} s
Time to underbuffer: ${xe.toFixed(3)} s`),n.abortRequests(),this.fragCurrent=this.partCurrent=null,ue>v){let Ae=this.findBestLevel(this.hls.levels[v].bitrate,v,ue,0,xe,1,1);Ae===-1&&(Ae=v),this.hls.nextLoadLevel=this.hls.nextAutoLevel=Ae,this.resetEstimator(this.hls.levels[Ae].bitrate)}}};E||oe>ae*2?fe():this.timer=self.setInterval(fe,ae*1e3),o.trigger(N.FRAG_LOAD_EMERGENCY_ABORTED,{frag:n,part:r,stats:f})},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 EB(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(N.MANIFEST_LOADING,this.onManifestLoading,this),e.on(N.FRAG_LOADING,this.onFragLoading,this),e.on(N.FRAG_LOADED,this.onFragLoaded,this),e.on(N.FRAG_BUFFERED,this.onFragBuffered,this),e.on(N.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(N.LEVEL_LOADED,this.onLevelLoaded,this),e.on(N.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(N.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(N.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(N.MANIFEST_LOADING,this.onManifestLoading,this),e.off(N.FRAG_LOADING,this.onFragLoading,this),e.off(N.FRAG_LOADED,this.onFragLoaded,this),e.off(N.FRAG_BUFFERED,this.onFragBuffered,this),e.off(N.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(N.LEVEL_LOADED,this.onLevelLoaded,this),e.off(N.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(N.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(N.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;if(!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 ve.BUFFER_ADD_CODEC_ERROR:case ve.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case ve.FRAG_LOAD_TIMEOUT:{const i=t.frag,{fragCurrent:n,partCurrent:r}=this;if(i&&n&&i.sn===n.sn&&i.level===n.level){const o=performance.now(),u=r?r.stats:i.stats,c=o-u.loading.start,d=u.loading.first?u.loading.first-u.loading.start:-1;if(u.loaded&&d>-1){const m=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(c-Math.min(m,d),u.loaded)}else this.bwEstimator.sampleTTFB(c)}break}}}getTimeToLoadFrag(e,t,i,n){const r=e+i/t,o=n?e+this.lastLevelLoadSec:0;return r+o}onLevelLoaded(e,t){const i=this.hls.config,{loading:n}=t.stats,r=n.end-n.first;We(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===Je.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,o=this.hls.levels[t.level],u=(o.loaded?o.loaded.bytes:0)+n.loaded,c=(o.loaded?o.loaded.duration:0)+r;o.loaded={bytes:u,duration:c},o.realBitrate=Math.round(8*u/c)}if(t.bitrateTest){const r={stats:n,frag:t,part:i,id:t.type};this.onFragBuffered(N.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 o=r.parsing.end-r.loading.start-Math.min(r.loading.first-r.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(o,r.loaded),r.bwEstimate=this.getBwEstimate(),i.bitrateTest?this.bitrateTestDelay=o/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==Je.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 o=this.hls.firstLevel,u=Math.min(Math.max(o,t),e);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${o} clamped to ${u}`),u}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 o=this.hls.levels;if(o.length>Math.max(e,r)&&o[e].loadError<=o[r].loadError)return e}return this._nextAutoLevel=r,this.nextAutoLevelKey=this.getAutoLevelKey(),r}getAutoLevelKey(){return`${this.getBwEstimate()}_${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:o}=i,u=t?t.duration:e?e.duration:0,c=this.getBwEstimate(),d=this.getStarvationDelay();let f=r.abrBandWidthFactor,m=r.abrBandWidthUpFactor;if(d){const E=this.findBestLevel(c,o,n,d,0,f,m);if(E>=0)return this.rebufferNotice=-1,E}let g=u?Math.min(u,r.maxStarvationDelay):r.maxStarvationDelay;if(!d){const E=this.bitrateTestDelay;E&&(g=(u?Math.min(u,r.maxLoadingDelay):r.maxLoadingDelay)-E,this.info(`bitrate test took ${Math.round(1e3*E)}ms, set first fragment max fetchDuration to ${Math.round(1e3*g)} ms`),f=m=1)}const v=this.findBestLevel(c,o,n,d,g,f,m);if(this.rebufferNotice!==v&&(this.rebufferNotice=v,this.info(`${d?"rebuffering expected":"buffer is empty"}, optimal quality level ${v}`)),v>-1)return v;const b=i.levels[o],_=i.loadLevelObj;return _&&b?.bitrate<_.bitrate?o: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,o,u){var c;const d=n+r,f=this.lastLoadedFragLevel,m=f===-1?this.hls.firstLevel:f,{fragCurrent:g,partCurrent:v}=this,{levels:b,allAudioTracks:_,loadLevel:E,config:w}=this.hls;if(b.length===1)return 0;const I=b[m],L=!!((c=this.hls.latestLevelDetails)!=null&&c.live),F=E===-1||f===-1;let $,G="SDR",B=I?.frameRate||0;const{audioPreference:V,videoPreference:k}=w,R=this.audioTracksByGroup||(this.audioTracksByGroup=Lw(_));let z=-1;if(F){if(this.firstSelection!==-1)return this.firstSelection;const Y=this.codecTiers||(this.codecTiers=mF(b,R,t,i)),Z=pF(Y,G,e,V,k),{codecSet:Q,videoRanges:ae,minFramerate:ue,minBitrate:U,minIndex:ie,preferHDR:fe}=Z;z=ie,$=Q,G=fe?ae[ae.length-1]:ae[0],B=ue,e=Math.max(e,U),this.log(`picked start tier ${ui(Z)}`)}else $=I?.codecSet,G=I?.videoRange;const X=v?v.duration:g?g.duration:0,ee=this.bwEstimator.getEstimateTTFB()/1e3,le=[];for(let Y=i;Y>=t;Y--){var oe;const Z=b[Y],Q=Y>m;if(!Z)continue;if(w.useMediaCapabilities&&!Z.supportedResult&&!Z.supportedPromise){const Ae=navigator.mediaCapabilities;typeof Ae?.decodingInfo=="function"&&nF(Z,R,G,B,e,V)?(Z.supportedPromise=Dw(Z,R,Ae,this.supportedCache),Z.supportedPromise.then($e=>{if(!this.hls)return;Z.supportedResult=$e;const Ee=this.hls.levels,je=Ee.indexOf(Z);$e.error?this.warn(`MediaCapabilities decodingInfo error: "${$e.error}" for level ${je} ${ui($e)}`):$e.supported?$e.decodingInfoResults.some(qe=>qe.smooth===!1||qe.powerEfficient===!1)&&this.log(`MediaCapabilities decodingInfo for level ${je} not smooth or powerEfficient: ${ui($e)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${je} ${ui($e)}`),je>-1&&Ee.length>1&&(this.log(`Removing unsupported level ${je}`),this.hls.removeLevel(je),this.hls.loadLevel===-1&&(this.hls.nextLoadLevel=0)))}).catch($e=>{this.warn(`Error handling MediaCapabilities decodingInfo: ${$e}`)})):Z.supportedResult=Aw}if(($&&Z.codecSet!==$||G&&Z.videoRange!==G||Q&&B>Z.frameRate||!Q&&B>0&&B<Z.frameRate||(oe=Z.supportedResult)!=null&&(oe=oe.decodingInfoResults)!=null&&oe.some(Ae=>Ae.smooth===!1))&&(!F||Y!==z)){le.push(Y);continue}const ae=Z.details,ue=(v?ae?.partTarget:ae?.averagetargetduration)||X;let U;Q?U=u*e:U=o*e;const ie=X&&n>=X*2&&r===0?Z.averageBitrate:Z.maxBitrate,fe=this.getTimeToLoadFrag(ee,U,ie*ue,ae===void 0);if(U>=ie&&(Y===f||Z.loadError===0&&Z.fragmentError===0)&&(fe<=ee||!We(fe)||L&&!this.bitrateTestDelay||fe<d)){const Ae=this.forcedAutoLevel;return Y!==E&&(Ae===-1||Ae!==E)&&(le.length&&this.trace(`Skipped level(s) ${le.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${b[le[0]].codecs}" ${b[le[0]].videoRange}; not compatible with "${$}" ${G}`),this.info(`switch candidate:${m}->${Y} adjustedbw(${Math.round(U)})-bitrate=${Math.round(U-ie)} ttfb:${ee.toFixed(1)} avgDuration:${ue.toFixed(1)} maxFetchDuration:${d.toFixed(1)} fetchDuration:${fe.toFixed(1)} firstSelection:${F} codecSet:${Z.codecSet} videoRange:${Z.videoRange} hls.loadLevel:${E}`)),F&&(this.firstSelection=Y),Y}}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 Iw={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 o=e(r);if(o>0)t=n+1;else if(o<0)i=n-1;else return r}return null}};function bF(s,e,t){if(e===null||!Array.isArray(s)||!s.length||!We(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 o=s[r];if(xF(e,t,o))return o}return null}function Cl(s,e,t=0,i=0,n=.005){let r=null;if(s){r=e[1+s.sn-e[0].sn]||null;const u=s.endDTS-t;u>0&&u<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)&&M1(t,i,r)===0||_F(r,s,Math.min(n,i))))return r;const o=Iw.search(e,M1.bind(null,t,i));return o&&(o!==s||!r)?o:r}function _F(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 M1(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 xF(s,e,t){const i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-i>s}function kw(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 Iw.search(i,o=>o.cc<e?1:o.cc>e?-1:(r=o,o.end<=t?1:o.start>t?-1:0)),r||null}return null}function tm(s){switch(s.details){case ve.FRAG_LOAD_TIMEOUT:case ve.KEY_LOAD_TIMEOUT:case ve.LEVEL_LOAD_TIMEOUT:case ve.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Rw(s){return s.details.startsWith("key")}function Ow(s){return Rw(s)&&!!s.frag&&!s.frag.decryptdata}function N1(s,e){const t=tm(e);return s.default[`${t?"timeout":"error"}Retry`]}function sb(s,e){const t=s.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*s.retryDelayMs,s.maxRetryDelayMs)}function B1(s){return Qt(Qt({},s),{errorRetry:null,timeoutRetry:null})}function im(s,e,t,i){if(!s)return!1;const n=i?.code,r=e<s.maxNumRetry&&(SF(n)||!!t);return s.shouldRetry?s.shouldRetry(s,e,t,i,r):r}function SF(s){return zv(s)||!!s&&(s<400||s>499)}function zv(s){return s===0&&navigator.onLine===!1}var ps={DoNothing:0,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,RetryRequest:5},Tn={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,MoveAllAlternatesMatchingKey:4};class EF extends jn{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(N.ERROR,this.onError,this),e.on(N.MANIFEST_LOADING,this.onManifestLoading,this),e.on(N.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(N.ERROR,this.onError,this),e.off(N.ERROR,this.onErrorOut,this),e.off(N.MANIFEST_LOADING,this.onManifestLoading,this),e.off(N.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return e?.type===Je.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(o=>n.indexOf(o.groupId)>=0).some(o=>{var u;return(u=o.details)==null?void 0:u.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 ve.FRAG_LOAD_ERROR:case ve.FRAG_LOAD_TIMEOUT:case ve.KEY_LOAD_ERROR:case ve.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case ve.FRAG_PARSING_ERROR:if((i=t.frag)!=null&&i.gap){t.errorAction=qu();return}case ve.FRAG_GAP:case ve.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=ps.SendAlternateToPenaltyBox;return}case ve.LEVEL_EMPTY_ERROR:case ve.LEVEL_PARSING_ERROR:{var o;const c=t.parent===Je.MAIN?t.level:n.loadLevel;t.details===ve.LEVEL_EMPTY_ERROR&&((o=t.context)!=null&&(o=o.levelDetails)!=null&&o.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,c):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,c))}return;case ve.LEVEL_LOAD_ERROR:case ve.LEVEL_LOAD_TIMEOUT:typeof r?.level=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,r.level));return;case ve.AUDIO_TRACK_LOAD_ERROR:case ve.AUDIO_TRACK_LOAD_TIMEOUT:case ve.SUBTITLE_LOAD_ERROR:case ve.SUBTITLE_TRACK_LOAD_TIMEOUT:if(r){const c=n.loadLevelObj;if(c&&(r.type===It.AUDIO_TRACK&&c.hasAudioGroup(r.groupId)||r.type===It.SUBTITLE_TRACK&&c.hasSubtitleGroup(r.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=ps.SendAlternateToPenaltyBox,t.errorAction.flags=Tn.MoveAllAlternatesMatchingHost;return}}return;case ve.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:t.errorAction={action:ps.SendAlternateToPenaltyBox,flags:Tn.MoveAllAlternatesMatchingHDCP};return;case ve.KEY_SYSTEM_SESSION_UPDATE_FAILED:case ve.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case ve.KEY_SYSTEM_NO_SESSION:t.errorAction={action:ps.SendAlternateToPenaltyBox,flags:Tn.MoveAllAlternatesMatchingKey};return;case ve.BUFFER_ADD_CODEC_ERROR:case ve.REMUX_ALLOC_ERROR:case ve.BUFFER_APPEND_ERROR:if(!t.errorAction){var u;t.errorAction=this.getLevelSwitchAction(t,(u=t.level)!=null?u:n.loadLevel)}return;case ve.INTERNAL_EXCEPTION:case ve.BUFFER_APPENDING_ERROR:case ve.BUFFER_FULL_ERROR:case ve.LEVEL_SWITCH_ERROR:case ve.BUFFER_STALLED_ERROR:case ve.BUFFER_SEEK_OVER_HOLE:case ve.BUFFER_NUDGE_ON_STALL:t.errorAction=qu();return}t.type===nt.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=qu())}getPlaylistRetryOrSwitchAction(e,t){const i=this.hls,n=N1(i.config.playlistLoadPolicy,e),r=this.playlistError++;if(im(n,r,tm(e),e.response))return{action:ps.RetryRequest,flags:Tn.None,retryConfig:n,retryCount:r};const u=this.getLevelSwitchAction(e,t);return n&&(u.retryConfig=n,u.retryCount=r),u}getFragRetryOrSwitchAction(e){const t=this.hls,i=this.getVariantLevelIndex(e.frag),n=t.levels[i],{fragLoadPolicy:r,keyLoadPolicy:o}=t.config,u=N1(Rw(e)?o:r,e),c=t.levels.reduce((f,m)=>f+m.fragmentError,0);if(n&&(e.details!==ve.FRAG_GAP&&n.fragmentError++,!Ow(e)&&im(u,c,tm(e),e.response)))return{action:ps.RetryRequest,flags:Tn.None,retryConfig:u,retryCount:c};const d=this.getLevelSwitchAction(e,i);return u&&(d.retryConfig=u,d.retryCount=c),d}getLevelSwitchAction(e,t){const i=this.hls;t==null&&(t=i.loadLevel);const n=this.hls.levels[t];if(n){var r,o;const d=e.details;n.loadError++,d===ve.BUFFER_APPEND_ERROR&&n.fragmentError++;let f=-1;const{levels:m,loadLevel:g,minAutoLevel:v,maxAutoLevel:b}=i;!i.autoLevelEnabled&&!i.config.preserveManualLevelOnError&&(i.loadLevel=-1);const _=(r=e.frag)==null?void 0:r.type,w=(_===Je.AUDIO&&d===ve.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(d===ve.BUFFER_ADD_CODEC_ERROR||d===ve.BUFFER_APPEND_ERROR))&&m.some(({audioCodec:G})=>n.audioCodec!==G),L=e.sourceBufferName==="video"&&(d===ve.BUFFER_ADD_CODEC_ERROR||d===ve.BUFFER_APPEND_ERROR)&&m.some(({codecSet:G,audioCodec:B})=>n.codecSet!==G&&n.audioCodec===B),{type:F,groupId:$}=(o=e.context)!=null?o:{};for(let G=m.length;G--;){const B=(G+g)%m.length;if(B!==g&&B>=v&&B<=b&&m[B].loadError===0){var u,c;const V=m[B];if(d===ve.FRAG_GAP&&_===Je.MAIN&&e.frag){const k=m[B].details;if(k){const R=Cl(e.frag,k.fragments,e.frag.start);if(R!=null&&R.gap)continue}}else{if(F===It.AUDIO_TRACK&&V.hasAudioGroup($)||F===It.SUBTITLE_TRACK&&V.hasSubtitleGroup($))continue;if(_===Je.AUDIO&&(u=n.audioGroups)!=null&&u.some(k=>V.hasAudioGroup(k))||_===Je.SUBTITLE&&(c=n.subtitleGroups)!=null&&c.some(k=>V.hasSubtitleGroup(k))||w&&n.audioCodec===V.audioCodec||L&&n.codecSet===V.codecSet||!w&&n.codecSet!==V.codecSet)continue}f=B;break}}if(f>-1&&i.loadLevel!==f)return e.levelRetry=!0,this.playlistError=0,{action:ps.SendAlternateToPenaltyBox,flags:Tn.None,nextAutoLevel:f}}return{action:ps.SendAlternateToPenaltyBox,flags:Tn.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var i;switch((i=t.errorAction)==null?void 0:i.action){case ps.DoNothing:break;case ps.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==ve.FRAG_GAP?t.fatal=!0:/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError());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 Tn.None:this.switchLevel(e,r);break;case Tn.MoveAllAlternatesMatchingHDCP:{const c=this.getVariantLevelIndex(e.frag),d=t.levels[c],f=d?.attrs["HDCP-LEVEL"];if(i.hdcpLevel=f,f==="NONE")this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(f){t.maxHdcpLevel=qv[qv.indexOf(f)-1],i.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}}case Tn.MoveAllAlternatesMatchingKey:{const c=e.decryptdata;if(c){const d=this.hls.levels,f=d.length;for(let g=f;g--;)if(this.variantHasKey(d[g],c)){var o,u;this.log(`Banned key found in level ${g} (${d[g].bitrate}bps) or audio group "${(o=d[g].audioGroups)==null?void 0:o.join(",")}" (${(u=e.frag)==null?void 0:u.type} fragment) ${gs(c.keyId||[])}`),d[g].fragmentError++,d[g].loadError++,this.log(`Removing level ${g} with key error (${e.error})`),this.hls.removeLevel(g)}const m=e.frag;if(this.hls.levels.length<f)i.resolved=!0;else if(m&&m.type!==Je.MAIN){const g=m.decryptdata;g&&!c.matches(g)&&(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===ve.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&e.sourceBufferName!=="audiovideo")){const i=Vv(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 qu(s){const e={action:ps.DoNothing,flags:Tn.None};return s&&(e.resolved=!0),e}var Ji={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class AF{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(N.MANIFEST_LOADING,this.onManifestLoading,this),e.on(N.BUFFER_APPENDED,this.onBufferAppended,this),e.on(N.FRAG_BUFFERED,this.onFragBuffered,this),e.on(N.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(N.MANIFEST_LOADING,this.onManifestLoading,this),e.off(N.BUFFER_APPENDED,this.onBufferAppended,this),e.off(N.FRAG_BUFFERED,this.onFragBuffered,this),e.off(N.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 o=r.length;o--;){const u=n[r[o]];if(u?.body.type===t&&(!i||u.buffered)){const c=u.body;if(c.start<=e&&e<=c.end)return c}}return null}detectEvictedFragments(e,t,i,n,r){this.timeRanges&&(this.timeRanges[e]=t);const o=n?.fragment.sn||-1;Object.keys(this.fragments).forEach(u=>{const c=this.fragments[u];if(!c||o>=c.body.sn)return;if(!c.buffered&&(!c.loaded||r)){c.body.type===i&&this.removeFragment(c.body);return}const d=c.range[e];if(d){if(d.time.length===0){this.removeFragment(c.body);return}d.time.some(f=>{const m=!this.isTimeBuffered(f.startPTS,f.endPTS,t);return m&&this.removeFragment(c.body),m})}})}detectPartialFragments(e){const t=this.timeRanges;if(!t||e.frag.sn==="initSegment")return;const i=e.frag,n=Eu(i),r=this.fragments[n];if(!r||r.buffered&&i.gap)return;const o=!i.relurl;Object.keys(t).forEach(u=>{const c=i.elementaryStreams[u];if(!c)return;const d=t[u],f=o||c.partial===!0;r.range[u]=this.getBufferedTimes(i,e.part,f,d)}),r.loaded=null,Object.keys(r.range).length?(this.bufferedEnd(r,i),Jf(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]=F1(i,n=>n.fragment.sn>=e))}fragBuffered(e,t){const i=Eu(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},o=e.start,u=e.end,c=e.minEndPTS||u,d=e.maxStartPTS||o;for(let f=0;f<n.length;f++){const m=n.start(f)-this.bufferPadding,g=n.end(f)+this.bufferPadding;if(d>=m&&c<=g){r.time.push({startPTS:Math.max(o,n.start(f)),endPTS:Math.min(u,n.end(f))});break}else if(o<g&&u>m){const v=Math.max(o,n.start(f)),b=Math.min(u,n.end(f));b>v&&(r.partial=!0,r.time.push({startPTS:v,endPTS:b}))}else if(u<=m)break}return r}getPartialFragment(e){let t=null,i,n,r,o=0;const{bufferPadding:u,fragments:c}=this;return Object.keys(c).forEach(d=>{const f=c[d];f&&Jf(f)&&(n=f.body.start-u,r=f.body.end+u,e>=n&&e<=r&&(i=Math.min(e-n,r-e),o<=i&&(t=f.body,o=i)))}),t}isEndListAppended(e){const t=this.endListFragments[e];return t!==void 0&&(t.buffered||Jf(t))}getState(e){const t=Eu(e),i=this.fragments[t];return i?i.buffered?Jf(i)?Ji.PARTIAL:Ji.OK:Ji.APPENDING:Ji.NOT_LOADED}isTimeBuffered(e,t,i){let n,r;for(let o=0;o<i.length;o++){if(n=i.start(o)-this.bufferPadding,r=i.end(o)+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=Eu(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:o}=t;if(i.sn==="initSegment")return;const u=i.type;if(n){let d=this.activePartLists[u];d||(this.activePartLists[u]=d=[]),d.push(n)}this.timeRanges=r;const c=r[o];this.detectEvictedFragments(o,c,u,n)}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=Eu(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(o=>{const u=this.fragments[o];if(!u)return;const c=u.body;c.type!==i||n&&!c.gap||c.start<t&&c.end>e&&(u.buffered||r)&&this.removeFragment(c)})}removeFragment(e){const t=Eu(e);e.clearElementaryStreamInfo();const i=this.activePartLists[e.type];if(i){const n=e.sn;this.activePartLists[e.type]=F1(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 Jf(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 Eu(s){return`${s.type}_${s.level}_${s.sn}`}function F1(s,e){return s.filter(t=>{const i=e(t);return i||t.clearElementaryStreamInfo(),i})}var Ao={cbc:0,ctr:1};class CF{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 Ao.cbc:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case Ao.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 DF(s){const e=s.byteLength,t=e&&new DataView(s.buffer).getUint8(e-1);return t?s.slice(0,e-t):s}class wF{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],o=i[2],u=i[3],c=this.invSubMix,d=c[0],f=c[1],m=c[2],g=c[3],v=new Uint32Array(256);let b=0,_=0,E=0;for(E=0;E<256;E++)E<128?v[E]=E<<1:v[E]=E<<1^283;for(E=0;E<256;E++){let w=_^_<<1^_<<2^_<<3^_<<4;w=w>>>8^w&255^99,e[b]=w,t[w]=b;const I=v[b],L=v[I],F=v[L];let $=v[w]*257^w*16843008;n[b]=$<<24|$>>>8,r[b]=$<<16|$>>>16,o[b]=$<<8|$>>>24,u[b]=$,$=F*16843009^L*65537^I*257^b*16843008,d[w]=$<<24|$>>>8,f[w]=$<<16|$>>>16,m[w]=$<<8|$>>>24,g[w]=$,b?(b=I^v[v[v[F^I]]],_^=v[v[_]]):b=_=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 o=this.ksRows=(r+6+1)*4;let u,c;const d=this.keySchedule=new Uint32Array(o),f=this.invKeySchedule=new Uint32Array(o),m=this.sBox,g=this.rcon,v=this.invSubMix,b=v[0],_=v[1],E=v[2],w=v[3];let I,L;for(u=0;u<o;u++){if(u<r){I=d[u]=t[u];continue}L=I,u%r===0?(L=L<<8|L>>>24,L=m[L>>>24]<<24|m[L>>>16&255]<<16|m[L>>>8&255]<<8|m[L&255],L^=g[u/r|0]<<24):r>6&&u%r===4&&(L=m[L>>>24]<<24|m[L>>>16&255]<<16|m[L>>>8&255]<<8|m[L&255]),d[u]=I=(d[u-r]^L)>>>0}for(c=0;c<o;c++)u=o-c,c&3?L=d[u]:L=d[u-4],c<4||u<=4?f[c]=L:f[c]=b[m[L>>>24]]^_[m[L>>>16&255]]^E[m[L>>>8&255]]^w[m[L&255]],f[c]=f[c]>>>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,o=this.invSBox,u=this.invSubMix,c=u[0],d=u[1],f=u[2],m=u[3],g=this.uint8ArrayToUint32Array_(i);let v=g[0],b=g[1],_=g[2],E=g[3];const w=new Int32Array(e),I=new Int32Array(w.length);let L,F,$,G,B,V,k,R,z,X,ee,le,oe,Y;const Z=this.networkToHostOrderSwap;for(;t<w.length;){for(z=Z(w[t]),X=Z(w[t+1]),ee=Z(w[t+2]),le=Z(w[t+3]),B=z^r[0],V=le^r[1],k=ee^r[2],R=X^r[3],oe=4,Y=1;Y<n;Y++)L=c[B>>>24]^d[V>>16&255]^f[k>>8&255]^m[R&255]^r[oe],F=c[V>>>24]^d[k>>16&255]^f[R>>8&255]^m[B&255]^r[oe+1],$=c[k>>>24]^d[R>>16&255]^f[B>>8&255]^m[V&255]^r[oe+2],G=c[R>>>24]^d[B>>16&255]^f[V>>8&255]^m[k&255]^r[oe+3],B=L,V=F,k=$,R=G,oe=oe+4;L=o[B>>>24]<<24^o[V>>16&255]<<16^o[k>>8&255]<<8^o[R&255]^r[oe],F=o[V>>>24]<<24^o[k>>16&255]<<16^o[R>>8&255]<<8^o[B&255]^r[oe+1],$=o[k>>>24]<<24^o[R>>16&255]<<16^o[B>>8&255]<<8^o[V&255]^r[oe+2],G=o[R>>>24]<<24^o[B>>16&255]<<16^o[V>>8&255]<<8^o[k&255]^r[oe+3],I[t]=Z(L^v),I[t+1]=Z(G^b),I[t+2]=Z($^_),I[t+3]=Z(F^E),v=z,b=X,_=ee,E=le,t=t+4}return I.buffer}}class LF{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=IF(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}function IF(s){switch(s){case Ao.cbc:return"AES-CBC";case Ao.ctr:return"AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${s}`)}}const kF=16;class nb{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?DF(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,o)=>{const u=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(u,t,i,n);const c=this.flush();c?r(c.buffer):o(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,i,n)}softwareDecrypt(e,t,i,n){const{currentIV:r,currentResult:o,remainderData:u}=this;if(n!==Ao.cbc||t.byteLength!==16)return Zt.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),u&&(e=Fn(u,e),this.remainderData=null);const c=this.getValidChunk(e);if(!c.length)return null;r&&(i=r);let d=this.softwareDecrypter;d||(d=this.softwareDecrypter=new wF),d.expandKey(t);const f=o;return this.currentResult=d.decrypt(c.buffer,0,i),this.currentIV=c.slice(-16).buffer,f||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 LF(this.subtle,t,n)}return this.fastAesKey.expandKey().then(r=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new CF(this.subtle,new Uint8Array(i),n).decrypt(e.buffer,r)):Promise.reject(new Error("web crypto not initialized"))).catch(r=>(Zt.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 o=this.flush();if(o)return o.buffer}throw new Error("WebCrypto"+(r?" and softwareDecrypt":"")+": failed to decrypt data")}getValidChunk(e){let t=e;const i=e.length-e.length%kF;return i!==e.length&&(t=e.slice(0,i),this.remainderData=e.slice(i)),t}logOnce(e){this.logEnabled&&(Zt.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const U1=Math.pow(2,17);class RF{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 ha({type:nt.NETWORK_ERROR,details:ve.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,o=n.loader;return new Promise((u,c)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(b=>b[0]==="GAP")){c(j1(e));return}else e.gap=!1;const d=this.loader=r?new r(n):new o(n),f=$1(e);e.loader=d;const m=B1(n.fragLoadPolicy.default),g={loadPolicy:m,timeout:m.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:U1};e.stats=d.stats;const v={onSuccess:(b,_,E,w)=>{this.resetLoader(e,d);let I=b.data;E.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(I.slice(0,16)),I=I.slice(16)),u({frag:e,part:null,payload:I,networkDetails:w})},onError:(b,_,E,w)=>{this.resetLoader(e,d),c(new ha({type:nt.NETWORK_ERROR,details:ve.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Qt({url:i,data:void 0},b),error:new Error(`HTTP Error ${b.code} ${b.text}`),networkDetails:E,stats:w}))},onAbort:(b,_,E)=>{this.resetLoader(e,d),c(new ha({type:nt.NETWORK_ERROR,details:ve.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:E,stats:b}))},onTimeout:(b,_,E)=>{this.resetLoader(e,d),c(new ha({type:nt.NETWORK_ERROR,details:ve.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${g.timeout}ms`),networkDetails:E,stats:b}))}};t&&(v.onProgress=(b,_,E,w)=>t({frag:e,part:null,payload:E,networkDetails:w})),d.load(f,g,v)})}loadPart(e,t,i){this.abort();const n=this.config,r=n.fLoader,o=n.loader;return new Promise((u,c)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){c(j1(e,t));return}const d=this.loader=r?new r(n):new o(n),f=$1(e,t);e.loader=d;const m=B1(n.fragLoadPolicy.default),g={loadPolicy:m,timeout:m.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:U1};t.stats=d.stats,d.load(f,g,{onSuccess:(v,b,_,E)=>{this.resetLoader(e,d),this.updateStatsFromPart(e,t);const w={frag:e,part:t,payload:v.data,networkDetails:E};i(w),u(w)},onError:(v,b,_,E)=>{this.resetLoader(e,d),c(new ha({type:nt.NETWORK_ERROR,details:ve.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:Qt({url:f.url,data:void 0},v),error:new Error(`HTTP Error ${v.code} ${v.text}`),networkDetails:_,stats:E}))},onAbort:(v,b,_)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,d),c(new ha({type:nt.NETWORK_ERROR,details:ve.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:_,stats:v}))},onTimeout:(v,b,_)=>{this.resetLoader(e,d),c(new ha({type:nt.NETWORK_ERROR,details:ve.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${g.timeout}ms`),networkDetails:_,stats:v}))}})})}updateStatsFromPart(e,t){const i=e.stats,n=t.stats,r=n.total;if(i.loaded+=n.loaded,r){const c=Math.round(e.duration/t.duration),d=Math.min(Math.round(i.loaded/r),c),m=(c-d)*Math.round(i.loaded/d);i.total=i.loaded+m}else i.total=Math.max(i.loaded,i.total);const o=i.loading,u=n.loading;o.start?o.first+=u.first-u.start:(o.start=u.start,o.first=u.first),o.end=u.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function $1(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(We(n)&&We(r)){var o;let u=n,c=r;if(s.sn==="initSegment"&&OF((o=s.decryptdata)==null?void 0:o.method)){const d=r-n;d%16&&(c=r+(16-d%16)),n!==0&&(i.resetIV=!0,u=n-16)}i.rangeStart=u,i.rangeEnd=c}return i}function j1(s,e){const t=new Error(`GAP ${s.gap?"tag":"attribute"} found`),i={type:nt.MEDIA_ERROR,details:ve.FRAG_GAP,fatal:!1,frag:s,error:t,networkDetails:null};return e&&(i.part=e),(e||s).stats.aborted=!0,new ha(i)}function OF(s){return s==="AES-128"||s==="AES-256"}class ha extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class Pw extends jn{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 rb{constructor(e,t,i,n=0,r=-1,o=!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=ep(),this.buffering={audio:ep(),video:ep(),audiovideo:ep()},this.level=e,this.sn=t,this.id=i,this.size=n,this.part=r,this.partial=o}}function ep(){return{start:0,executeStart:0,executeEnd:0,end:0}}const H1={length:0,start:()=>0,end:()=>0};class vt{static isBuffered(e,t){if(e){const i=vt.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=vt.getBuffered(e);return vt.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=vt.bufferedRanges(e);if(n.length)return vt.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((f,m)=>f.start-m.start||m.end-f.end);let n=-1,r=[];if(i)for(let f=0;f<e.length;f++){t>=e[f].start&&t<=e[f].end&&(n=f);const m=r.length;if(m){const g=r[m-1].end;e[f].start-g<i?e[f].end>g&&(r[m-1].end=e[f].end):r.push(e[f])}else r.push(e[f])}else r=e;let o=0,u,c=t,d=t;for(let f=0;f<r.length;f++){const m=r[f].start,g=r[f].end;if(n===-1&&t>=m&&t<=g&&(n=f),t+i>=m&&t<g)c=m,d=g,o=d-t;else if(t+i<m){u=m;break}}return{len:o,start:c||0,end:d||0,nextStart:u,buffered:e,bufferedIndex:n}}static getBuffered(e){try{return e.buffered||H1}catch(t){return Zt.log("failed to get media.buffered",t),H1}}}const Mw=/\{\$([a-zA-Z0-9-_]+)\}/g;function G1(s){return Mw.test(s)}function Kv(s,e){if(s.variableList!==null||s.hasVariableRefs){const t=s.variableList;return e.replace(Mw,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 V1(s,e,t){let i=s.variableList;i||(s.variableList=i={});let n,r;if("QUERYPARAM"in e){n=e.QUERYPARAM;try{const o=new self.URL(t).searchParams;if(o.has(n))r=o.get(n);else throw new Error(`"${n}" does not match any query parameter in URI: "${t}"`)}catch(o){s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${o.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 PF(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 MF=/^(\d+)x(\d+)$/,q1=/(.+?)=(".*?"|.*?)(?:,|$)/g;class Si{constructor(e,t){typeof e=="string"&&(e=Si.parseAttrList(e,t)),ni(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=MF.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(q1.lastIndex=0;(i=q1.exec(e))!==null;){const o=i[1].trim();let u=i[2];const c=u.indexOf('"')===0&&u.lastIndexOf('"')===u.length-1;let d=!1;if(c)u=u.slice(1,-1);else switch(o){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":d=!0}if(t&&(c||d))u=Kv(t,u);else if(!d&&!c)switch(o){case"CLOSED-CAPTIONS":if(u==="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":Zt.warn(`${e}: attribute ${o} is missing quotes`)}n[o]=u}return n}}const NF="com.apple.hls.interstitial";function BF(s){return s!=="ID"&&s!=="CLASS"&&s!=="CUE"&&s!=="START-DATE"&&s!=="DURATION"&&s!=="END-DATE"&&s!=="END-ON-NEXT"}function FF(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"||s==="SCTE35-CMD"}class Nw{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 o in r)if(Object.prototype.hasOwnProperty.call(e,o)&&e[o]!==r[o]){Zt.warn(`DATERANGE tag attribute: "${o}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=o;break}e=ni(new Si({}),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"]);We(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?(Zt.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(We(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===NF}get isValid(){return!!this.id&&!this._badValueForSameId&&We(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 UF=10;class $F{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.driftStartTime=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?We(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||UF}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 sm(s,e){return s.length===e.length?!s.some((t,i)=>t!==e[i]):!1}function z1(s,e){return!s&&!e?!0:!s||!e?!1:sm(s,e)}function zu(s){return s==="AES-128"||s==="AES-256"||s==="AES-256-CTR"}function ab(s){switch(s){case"AES-128":case"AES-256":return Ao.cbc;case"AES-256-CTR":return Ao.ctr;default:throw new Error(`invalid full segment method ${s}`)}}function ob(s){return Uint8Array.from(atob(s),e=>e.charCodeAt(0))}function Yv(s){return Uint8Array.from(unescape(encodeURIComponent(s)),e=>e.charCodeAt(0))}function jF(s){const e=Yv(s).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function Bw(s){const e=function(i,n,r){const o=i[n];i[n]=i[r],i[r]=o};e(s,0,3),e(s,1,2),e(s,4,5),e(s,6,7)}function Fw(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",o=n[1];r?(i.splice(-1,1),t=ob(o)):t=jF(o)}}return t}const nm=typeof self<"u"?self:void 0;var Ei={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},ys={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function _p(s){switch(s){case ys.FAIRPLAY:return Ei.FAIRPLAY;case ys.PLAYREADY:return Ei.PLAYREADY;case ys.WIDEVINE:return Ei.WIDEVINE;case ys.CLEARKEY:return Ei.CLEARKEY}}function Fy(s){switch(s){case Ei.FAIRPLAY:return ys.FAIRPLAY;case Ei.PLAYREADY:return ys.PLAYREADY;case Ei.WIDEVINE:return ys.WIDEVINE;case Ei.CLEARKEY:return ys.CLEARKEY}}function Id(s){const{drmSystems:e,widevineLicenseUrl:t}=s,i=e?[Ei.FAIRPLAY,Ei.WIDEVINE,Ei.PLAYREADY,Ei.CLEARKEY].filter(n=>!!e[n]):[];return!i[Ei.WIDEVINE]&&t&&i.push(Ei.WIDEVINE),i}const Uw=(function(s){return nm!=null&&(s=nm.navigator)!=null&&s.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null})();function HF(s,e,t,i){let n;switch(s){case Ei.FAIRPLAY:n=["cenc","sinf"];break;case Ei.WIDEVINE:case Ei.PLAYREADY:n=["cenc"];break;case Ei.CLEARKEY:n=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${s}`)}return GF(n,e,t,i)}function GF(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}`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:t.map(r=>({contentType:`video/mp4; codecs=${r}`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function VF(s){var e;return!!s&&(s.sessionType==="persistent-license"||!!((e=s.sessionTypes)!=null&&e.some(t=>t==="persistent-license")))}function $w(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),o=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(o){const u=o.childNodes[0]?o.childNodes[0].nodeValue:o.getAttribute("VALUE");if(u){const c=ob(u).subarray(0,16);return Bw(c),c}}return null}let Au={};class _o{static clearKeyUriToKeyIdMap(){Au={}}static setKeyIdForUri(e,t){Au[e]=t}static addKeyIdForUri(e){const t=Object.keys(Au).length%Number.MAX_SAFE_INTEGER,i=new Uint8Array(16);return new DataView(i.buffer,12,4).setUint32(0,t),Au[e]=i,i}constructor(e,t,i,n=[1],r=null,o){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&&!zu(e),o!=null&&o.startsWith("0x")&&(this.keyId=new Uint8Array(pw(o)))}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&sm(e.keyFormatVersions,this.keyFormatVersions)&&z1(e.iv,this.iv)&&z1(e.keyId,this.keyId)}isSupported(){if(this.method){if(zu(this.method)||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case ys.FAIRPLAY:case ys.WIDEVINE:case ys.PLAYREADY:case ys.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(zu(this.method)){let r=this.iv;return r||(typeof e!="number"&&(Zt.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0),r=zF(e)),new _o(this.method,this.uri,"identity",this.keyFormatVersions,r)}if(this.keyId){const r=Au[this.uri];if(r&&!sm(this.keyId,r)&&_o.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}const i=Fw(this.uri);if(i)switch(this.keyFormat){case ys.WIDEVINE:if(this.pssh=i,!this.keyId){const r=WB(i.buffer);if(r.length){var n;const o=r[0];this.keyId=(n=o.kids)!=null&&n.length?o.kids[0]:null}}this.keyId||(this.keyId=K1(t));break;case ys.PLAYREADY:{const r=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=YB(r,null,i),this.keyId=$w(i);break}default:{let r=i.subarray(0,16);if(r.length!==16){const o=new Uint8Array(16);o.set(r,16-r.length),r=o}this.keyId=r;break}}if(!this.keyId||this.keyId.byteLength!==16){let r;r=qF(t),r||(r=K1(t),r||(r=Au[this.uri])),r&&(this.keyId=r,_o.setKeyIdForUri(this.uri,r))}return this}}function qF(s){const e=s?.[ys.WIDEVINE];return e?e.keyId:null}function K1(s){const e=s?.[ys.PLAYREADY];if(e){const t=Fw(e.uri);if(t)return $w(t)}return null}function zF(s){const e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=s>>8*(15-t)&255;return e}const Y1=/#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,W1=/#EXT-X-MEDIA:(.*)/g,KF=/^#EXT(?:INF|-X-TARGETDURATION):/m,Uy=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),YF=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 Or{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 ZT.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return KF.test(e)}static parseMasterPlaylist(e,t){const i=G1(e),n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},r=[];if(Y1.lastIndex=0,!e.startsWith("#EXTM3U"))return n.playlistParsingError=new Error("no EXTM3U delimiter"),n;let o;for(;(o=Y1.exec(e))!=null;)if(o[1]){var u;const d=new Si(o[1],n),f=Kv(n,o[2]),m={attrs:d,bitrate:d.decimalInteger("BANDWIDTH")||d.decimalInteger("AVERAGE-BANDWIDTH"),name:d.NAME,url:Or.resolve(f,t)},g=d.decimalResolution("RESOLUTION");g&&(m.width=g.width,m.height=g.height),Z1(d.CODECS,m);const v=d["SUPPLEMENTAL-CODECS"];v&&(m.supplemental={},Z1(v,m.supplemental)),(u=m.unknownCodecs)!=null&&u.length||r.push(m),n.levels.push(m)}else if(o[3]){const d=o[3],f=o[4];switch(d){case"SESSION-DATA":{const m=new Si(f,n),g=m["DATA-ID"];g&&(n.sessionData===null&&(n.sessionData={}),n.sessionData[g]=m);break}case"SESSION-KEY":{const m=X1(f,t,n);m.encrypted&&m.isSupported()?(n.sessionKeys===null&&(n.sessionKeys=[]),n.sessionKeys.push(m)):Zt.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${f}"`);break}case"DEFINE":{{const m=new Si(f,n);V1(n,m,t)}break}case"CONTENT-STEERING":{const m=new Si(f,n);n.contentSteering={uri:Or.resolve(m["SERVER-URI"],t),pathwayId:m["PATHWAY-ID"]||"."};break}case"START":{n.startTimeOffset=Q1(f);break}}}const c=r.length>0&&r.length<n.levels.length;return n.levels=c?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={},o=i.levels,u={AUDIO:o.map(d=>({id:d.attrs.AUDIO,audioCodec:d.audioCodec})),SUBTITLES:o.map(d=>({id:d.attrs.SUBTITLES,textCodec:d.textCodec})),"CLOSED-CAPTIONS":[]};let c=0;for(W1.lastIndex=0;(n=W1.exec(e))!==null;){const d=new Si(n[1],i),f=d.TYPE;if(f){const m=u[f],g=r[f]||[];r[f]=g;const v=d.LANGUAGE,b=d["ASSOC-LANGUAGE"],_=d.CHANNELS,E=d.CHARACTERISTICS,w=d["INSTREAM-ID"],I={attrs:d,bitrate:0,id:c++,groupId:d["GROUP-ID"]||"",name:d.NAME||v||"",type:f,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:v,url:d.URI?Or.resolve(d.URI,t):""};if(b&&(I.assocLang=b),_&&(I.channels=_),E&&(I.characteristics=E),w&&(I.instreamId=w),m!=null&&m.length){const L=Or.findGroup(m,I.groupId)||m[0];J1(I,L,"audioCodec"),J1(I,L,"textCodec")}g.push(I)}}return r}static parseLevelPlaylist(e,t,i,n,r,o){var u;const c={url:t},d=new $F(t),f=d.fragments,m=[];let g=null,v=0,b=0,_=0,E=0,w=0,I=null,L=new My(n,c),F,$,G,B=-1,V=!1,k=null,R;if(Uy.lastIndex=0,d.m3u8=e,d.hasVariableRefs=G1(e),((u=Uy.exec(e))==null?void 0:u[0])!=="#EXTM3U")return d.playlistParsingError=new Error("Missing format identifier #EXTM3U"),d;for(;(F=Uy.exec(e))!==null;){V&&(V=!1,L=new My(n,c),L.playlistOffset=_,L.setStart(_),L.sn=v,L.cc=E,w&&(L.bitrate=w),L.level=i,g&&(L.initSegment=g,g.rawProgramDateTime&&(L.rawProgramDateTime=g.rawProgramDateTime,g.rawProgramDateTime=null),k&&(L.setByteRange(k),k=null)));const le=F[1];if(le){L.duration=parseFloat(le);const oe=(" "+F[2]).slice(1);L.title=oe||null,L.tagList.push(oe?["INF",le,oe]:["INF",le])}else if(F[3]){if(We(L.duration)){L.playlistOffset=_,L.setStart(_),G&&t2(L,G,d),L.sn=v,L.level=i,L.cc=E,f.push(L);const oe=(" "+F[3]).slice(1);L.relurl=Kv(d,oe),Wv(L,I,m),I=L,_+=L.duration,v++,b=0,V=!0}}else{if(F=F[0].match(YF),!F){Zt.warn("No matches on slow regex match for level playlist!");continue}for($=1;$<F.length&&F[$]===void 0;$++);const oe=(" "+F[$]).slice(1),Y=(" "+F[$+1]).slice(1),Z=F[$+2]?(" "+F[$+2]).slice(1):null;switch(oe){case"BYTERANGE":I?L.setByteRange(Y,I):L.setByteRange(Y);break;case"PROGRAM-DATE-TIME":L.rawProgramDateTime=Y,L.tagList.push(["PROGRAM-DATE-TIME",Y]),B===-1&&(B=f.length);break;case"PLAYLIST-TYPE":d.type&&ca(d,oe,F),d.type=Y.toUpperCase();break;case"MEDIA-SEQUENCE":d.startSN!==0?ca(d,oe,F):f.length>0&&i2(d,oe,F),v=d.startSN=parseInt(Y);break;case"SKIP":{d.skippedSegments&&ca(d,oe,F);const Q=new Si(Y,d),ae=Q.decimalInteger("SKIPPED-SEGMENTS");if(We(ae)){d.skippedSegments+=ae;for(let U=ae;U--;)f.push(null);v+=ae}const ue=Q.enumeratedString("RECENTLY-REMOVED-DATERANGES");ue&&(d.recentlyRemovedDateranges=(d.recentlyRemovedDateranges||[]).concat(ue.split(" ")));break}case"TARGETDURATION":d.targetduration!==0&&ca(d,oe,F),d.targetduration=Math.max(parseInt(Y),1);break;case"VERSION":d.version!==null&&ca(d,oe,F),d.version=parseInt(Y);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":d.live||ca(d,oe,F),d.live=!1;break;case"#":(Y||Z)&&L.tagList.push(Z?[Y,Z]:[Y]);break;case"DISCONTINUITY":E++,L.tagList.push(["DIS"]);break;case"GAP":L.gap=!0,L.tagList.push([oe]);break;case"BITRATE":L.tagList.push([oe,Y]),w=parseInt(Y)*1e3,We(w)?L.bitrate=w:w=0;break;case"DATERANGE":{const Q=new Si(Y,d),ae=new Nw(Q,d.dateRanges[Q.ID],d.dateRangeTagCount);d.dateRangeTagCount++,ae.isValid||d.skippedSegments?d.dateRanges[ae.id]=ae:Zt.warn(`Ignoring invalid DATERANGE tag: "${Y}"`),L.tagList.push(["EXT-X-DATERANGE",Y]);break}case"DEFINE":{{const Q=new Si(Y,d);"IMPORT"in Q?PF(d,Q,o):V1(d,Q,t)}break}case"DISCONTINUITY-SEQUENCE":d.startCC!==0?ca(d,oe,F):f.length>0&&i2(d,oe,F),d.startCC=E=parseInt(Y);break;case"KEY":{const Q=X1(Y,t,d);if(Q.isSupported()){if(Q.method==="NONE"){G=void 0;break}G||(G={});const ae=G[Q.keyFormat];ae!=null&&ae.matches(Q)||(ae&&(G=ni({},G)),G[Q.keyFormat]=Q)}else Zt.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${Y}"`);break}case"START":d.startTimeOffset=Q1(Y);break;case"MAP":{const Q=new Si(Y,d);if(L.duration){const ae=new My(n,c);e2(ae,Q,i,G),g=ae,L.initSegment=g,g.rawProgramDateTime&&!L.rawProgramDateTime&&(L.rawProgramDateTime=g.rawProgramDateTime)}else{const ae=L.byteRangeEndOffset;if(ae){const ue=L.byteRangeStartOffset;k=`${ae-ue}@${ue}`}else k=null;e2(L,Q,i,G),g=L,V=!0}g.cc=E;break}case"SERVER-CONTROL":{R&&ca(d,oe,F),R=new Si(Y),d.canBlockReload=R.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=R.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&R.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=R.optionalFloat("PART-HOLD-BACK",0),d.holdBack=R.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{d.partTarget&&ca(d,oe,F);const Q=new Si(Y);d.partTarget=Q.decimalFloatingPoint("PART-TARGET");break}case"PART":{let Q=d.partList;Q||(Q=d.partList=[]);const ae=b>0?Q[Q.length-1]:void 0,ue=b++,U=new Si(Y,d),ie=new PB(U,L,c,ue,ae);Q.push(ie),L.duration+=ie.duration;break}case"PRELOAD-HINT":{const Q=new Si(Y,d);d.preloadHint=Q;break}case"RENDITION-REPORT":{const Q=new Si(Y,d);d.renditionReports=d.renditionReports||[],d.renditionReports.push(Q);break}default:Zt.warn(`line parsed but not handled: ${F}`);break}}}I&&!I.relurl?(f.pop(),_-=I.duration,d.partList&&(d.fragmentHint=I)):d.partList&&(Wv(L,I,m),L.cc=E,d.fragmentHint=L,G&&t2(L,G,d)),d.targetduration||(d.playlistParsingError=new Error("Missing Target Duration"));const z=f.length,X=f[0],ee=f[z-1];if(_+=d.skippedSegments*d.targetduration,_>0&&z&&ee){d.averagetargetduration=_/z;const le=ee.sn;d.endSN=le!=="initSegment"?le:0,d.live||(ee.endList=!0),B>0&&(XF(f,B),X&&m.unshift(X))}return d.fragmentHint&&(_+=d.fragmentHint.duration),d.totalduration=_,m.length&&d.dateRangeTagCount&&X&&jw(m,d),d.endCC=E,d}}function jw(s,e){let t=s.length;if(!t)if(e.hasProgramDateTime){const u=e.fragments[e.fragments.length-1];s.push(u),t++}else return;const i=s[t-1],n=e.live?1/0:e.totalduration,r=Object.keys(e.dateRanges);for(let u=r.length;u--;){const c=e.dateRanges[r[u]],d=c.startDate.getTime();c.tagAnchor=i.ref;for(let f=t;f--;){var o;if(((o=s[f])==null?void 0:o.sn)<e.startSN)break;const m=WF(e,d,s,f,n);if(m!==-1){c.tagAnchor=e.fragments[m].ref;break}}}}function WF(s,e,t,i,n){const r=t[i];if(r){const u=r.programDateTime;if(e>=u||i===0){var o;const c=(((o=t[i+1])==null?void 0:o.start)||n)-r.start;if(e<=u+c*1e3){const d=t[i].sn-s.startSN;if(d<0)return-1;const f=s.fragments;if(f.length>t.length){const g=(t[i+1]||f[f.length-1]).sn-s.startSN;for(let v=g;v>d;v--){const b=f[v].programDateTime;if(e>=b&&e<b+f[v].duration*1e3)return v}}return d}}}return-1}function X1(s,e,t){var i,n;const r=new Si(s,t),o=(i=r.METHOD)!=null?i:"",u=r.URI,c=r.hexadecimalInteger("IV"),d=r.KEYFORMATVERSIONS,f=(n=r.KEYFORMAT)!=null?n:"identity";u&&r.IV&&!c&&Zt.error(`Invalid IV: ${r.IV}`);const m=u?Or.resolve(u,e):"",g=(d||"1").split("/").map(Number).filter(Number.isFinite);return new _o(o,m,f,g,c,r.KEYID)}function Q1(s){const t=new Si(s).decimalFloatingPoint("TIME-OFFSET");return We(t)?t:null}function Z1(s,e){let t=(s||"").split(/[ ,]+/).filter(i=>i);["video","audio","text"].forEach(i=>{const n=t.filter(r=>tb(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 J1(s,e,t){const i=e[t];i&&(s[t]=i)}function XF(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 Wv(s,e,t){s.rawProgramDateTime?t.push(s):e!=null&&e.programDateTime&&(s.programDateTime=e.endProgramDateTime)}function e2(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 t2(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 ca(s,e,t){s.playlistParsingError=new Error(`#EXT-X-${e} must not appear more than once (${t[0]})`)}function i2(s,e,t){s.playlistParsingError=new Error(`#EXT-X-${e} must appear before the first Media Segment (${t[0]})`)}function $y(s,e){const t=e.startPTS;if(We(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 Hw(s,e,t,i,n,r,o){i-t<=0&&(o.warn("Fragment should have a positive duration",e),i=t+e.duration,r=n+e.duration);let c=t,d=i;const f=e.startPTS,m=e.endPTS;if(We(f)){const w=Math.abs(f-t);s&&w>s.totalduration?o.warn(`media timestamps and playlist times differ by ${w}s for level ${e.level} ${s.url}`):We(e.deltaPTS)?e.deltaPTS=Math.max(w,e.deltaPTS):e.deltaPTS=w,c=Math.max(t,f),t=Math.min(t,f),n=e.startDTS!==void 0?Math.min(n,e.startDTS):n,d=Math.min(i,m),i=Math.max(i,m),r=e.endDTS!==void 0?Math.max(r,e.endDTS):r}const g=t-e.start;e.start!==0&&e.setStart(t),e.setDuration(i-e.start),e.startPTS=t,e.maxStartPTS=c,e.startDTS=n,e.endPTS=i,e.minEndPTS=d,e.endDTS=r;const v=e.sn;if(!s||v<s.startSN||v>s.endSN)return 0;let b;const _=v-s.startSN,E=s.fragments;for(E[_]=e,b=_;b>0;b--)$y(E[b],E[b-1]);for(b=_;b<E.length-1;b++)$y(E[b],E[b+1]);return s.fragmentHint&&$y(E[E.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,g}function QF(s,e,t){if(s===e)return;let i=null;const n=s.fragments;for(let f=n.length-1;f>=0;f--){const m=n[f].initSegment;if(m){i=m;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;let r;e8(s,e,(f,m,g,v)=>{if((!e.startCC||e.skippedSegments)&&m.cc!==f.cc){const b=f.cc-m.cc;for(let _=g;_<v.length;_++)v[_].cc+=b;e.endCC=v[v.length-1].cc}We(f.startPTS)&&We(f.endPTS)&&(m.setStart(m.startPTS=f.startPTS),m.startDTS=f.startDTS,m.maxStartPTS=f.maxStartPTS,m.endPTS=f.endPTS,m.endDTS=f.endDTS,m.minEndPTS=f.minEndPTS,m.setDuration(f.endPTS-f.startPTS),m.duration&&(r=m),e.PTSKnown=e.alignedSliding=!0),f.hasStreams&&(m.elementaryStreams=f.elementaryStreams),m.loader=f.loader,f.hasStats&&(m.stats=f.stats),f.initSegment&&(m.initSegment=f.initSegment,i=f.initSegment)});const o=e.fragments,u=e.fragmentHint?o.concat(e.fragmentHint):o;if(i&&u.forEach(f=>{var m;f&&(!f.initSegment||f.initSegment.relurl===((m=i)==null?void 0:m.relurl))&&(f.initSegment=i)}),e.skippedSegments){if(e.deltaUpdateFailed=o.some(f=>!f),e.deltaUpdateFailed){t.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let f=e.skippedSegments;f--;)o.shift();e.startSN=o[0].sn}else{e.canSkipDateRanges&&(e.dateRanges=ZF(s.dateRanges,e,t));const f=s.fragments.filter(m=>m.rawProgramDateTime);if(s.hasProgramDateTime&&!e.hasProgramDateTime)for(let m=1;m<u.length;m++)u[m].programDateTime===null&&Wv(u[m],u[m-1],f);jw(f,e)}e.endCC=o[o.length-1].cc}if(!e.startCC){var c;const f=qw(s,e.startSN-1);e.startCC=(c=f?.cc)!=null?c:o[0].cc}JF(s.partList,e.partList,(f,m)=>{m.elementaryStreams=f.elementaryStreams,m.stats=f.stats}),r?Hw(e,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS,t):Gw(s,e),o.length&&(e.totalduration=e.edge-o[0].start),e.driftStartTime=s.driftStartTime,e.driftStart=s.driftStart;const d=e.advancedDateTime;if(e.advanced&&d){const f=e.edge;e.driftStart||(e.driftStartTime=d,e.driftStart=f),e.driftEndTime=d,e.driftEnd=f}else e.driftEndTime=s.driftEndTime,e.driftEnd=s.driftEnd,e.advancedDateTime=s.advancedDateTime;e.requestScheduled===-1&&(e.requestScheduled=s.requestScheduled)}function ZF(s,e,t){const{dateRanges:i,recentlyRemovedDateranges:n}=e,r=ni({},s);n&&n.forEach(c=>{delete r[c]});const u=Object.keys(r).length;return u?(Object.keys(i).forEach(c=>{const d=r[c],f=new Nw(i[c].attr,d);f.isValid?(r[c]=f,d||(f.tagOrder+=u)):t.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${ui(i[c].attr)}"`)}),r):i}function JF(s,e,t){if(s&&e){let i=0;for(let n=0,r=s.length;n<=r;n++){const o=s[n],u=e[n+i];o&&u&&o.index===u.index&&o.fragment.sn===u.fragment.sn?t(o,u):i--}}}function e8(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,o=e.startSN-s.startSN,u=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,c=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments;for(let d=n;d<=r;d++){const f=c[o+d];let m=u[d];if(i&&!m&&f&&(m=e.fragments[d]=f),f&&m){t(f,m,d,u);const g=f.relurl,v=m.relurl;if(g&&t8(g,v)){e.playlistParsingError=s2(`media sequence mismatch ${m.sn}:`,s,e,f,m);return}else if(f.cc!==m.cc){e.playlistParsingError=s2(`discontinuity sequence mismatch (${f.cc}!=${m.cc})`,s,e,f,m);return}}}}function s2(s,e,t,i,n){return new Error(`${s} ${n.url}
Playlist starting @${e.startSN}
${e.m3u8}
Playlist starting @${t.startSN}
${t.m3u8}`)}function Gw(s,e,t=!0){const i=e.startSN+e.skippedSegments-s.startSN,n=s.fragments,r=i>=0;let o=0;if(r&&i<n.length)o=n[i].start;else if(r&&e.startSN===s.endSN+1)o=s.fragmentEnd;else if(r&&t)o=s.fragmentStart+i*e.levelTargetDuration;else if(!e.skippedSegments&&e.fragmentStart===0)o=s.fragmentStart;else return;Xv(e,o)}function Xv(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 Vw(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 qw(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 n2(s,e,t){return s?zw(s.partList,e,t):null}function zw(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 Kw(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 t8(s,e){return s!==e&&e?r2(s)!==r2(e):!1}function r2(s){return s.replace(/\?[^?]*$/,"")}function jd(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 i8(s,e){return!!(s&&e.startCC<s.endCC&&e.endCC>s.startCC)}function a2(s,e){const t=s.start+e;s.startPTS=t,s.setStart(t),s.endPTS=t+s.duration}function Yw(s,e){const t=e.fragments;for(let i=0,n=t.length;i<n;i++)a2(t[i],s);e.fragmentHint&&a2(e.fragmentHint,s),e.alignedSliding=!0}function s8(s,e){s&&(Ww(e,s),e.alignedSliding||rm(e,s),!e.alignedSliding&&!e.skippedSegments&&Gw(s,e,!1))}function Ww(s,e){if(!i8(e,s))return;const t=Math.min(e.endCC,s.endCC),i=jd(e.fragments,t),n=jd(s.fragments,t);if(!i||!n)return;Zt.log(`Aligning playlist at start of dicontinuity sequence ${t}`);const r=i.start-n.start;Yw(r,s)}function rm(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 o=Math.min(e.endCC,s.endCC);e.startCC<o&&s.startCC<o&&(n=jd(i,o),r=jd(t,o)),(!n||!r)&&(n=i[Math.floor(i.length/2)],r=jd(t,n.cc)||t[Math.floor(t.length/2)]);const u=n.programDateTime,c=r.programDateTime;if(!u||!c)return;const d=(c-u)/1e3-(r.start-n.start);Yw(d,s)}function Fs(s,e,t){tn(s,e,t),s.addEventListener(e,t)}function tn(s,e,t){s.removeEventListener(e,t)}const n8={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}},Pe={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 lb extends Pw{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=Pe.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:o,fragCurrent:u,media:c,mediaBuffer:d,state:f}=this,m=c?c.currentTime:0,g=vt.bufferInfo(d||c,m,o.maxBufferHole),v=!g.len;if(this.log(`Media seeking to ${We(m)?m.toFixed(3):m}, state: ${f}, ${v?"out of":"in"} buffer`),this.state===Pe.ENDED)this.resetLoadingState();else if(u){const b=o.maxFragLookUpTolerance,_=u.start-b,E=u.start+u.duration+b;if(v||E<g.start||_>g.end){const w=m>E;(m<_||w)&&(w&&u.loader&&(this.log(`Cancelling fragment load for seek (sn: ${u.sn})`),u.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}if(c){this.fragmentTracker.removeFragmentsInRange(m,1/0,this.playlistType,!0);const b=this.lastCurrentTime;if(m>b&&(this.lastCurrentTime=m),!this.loadingParts){const _=Math.max(g.end,m),E=this.shouldLoadParts(this.getLevelDetails(),_);E&&(this.log(`LL-Part loading ON after seeking to ${m.toFixed(2)} with buffer @${_.toFixed(2)}`),this.loadingParts=E)}}this.hls.hasEnoughToStart||(this.log(`Setting ${v?"startPosition":"nextLoadPosition"} to ${m} for seek without enough to start`),this.nextLoadPosition=m,v&&(this.startPosition=m)),v&&this.state===Pe.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 RF(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new nb(e.config)}registerListeners(){const{hls:e}=this;e.on(N.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(N.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(N.MANIFEST_LOADING,this.onManifestLoading,this),e.on(N.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(N.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(N.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(N.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(N.MANIFEST_LOADING,this.onManifestLoading,this),e.off(N.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(N.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===Pe.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=Pe.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=vt.bufferedInfo(r,e.start,0));const o=e.nextStart;if(o&&o>n&&o<t.edge||this.media.currentTime<e.start)return!1;const c=t.partList;if(c!=null&&c.length){const f=c[c.length-1];return vt.isBuffered(this.media,f.start+f.duration/2)}const d=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(d)}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;Fs(i,"seeking",this.onMediaSeeking),Fs(i,"ended",this.onMediaEnded);const n=this.config;this.levels&&n.autoStartLoad&&this.state===Pe.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),tn(n,"seeking",this.onMediaSeeking),tn(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=Pe.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 o=r.frag;if(this.fragContextChanged(o)){this.warn(`${o.type} sn: ${o.sn}${r.part?" part: "+r.part.index:""} of ${this.fragInfo(o,!1,r.part)}) was dropped during download.`),this.fragmentTracker.removeFragment(o);return}o.stats.chunkCount++,this._handleFragmentLoadProgress(r)};this._doFragLoad(e,t,i,n).then(r=>{if(!r)return;const o=this.state,u=r.frag;if(this.fragContextChanged(u)){(o===Pe.FRAG_LOADING||!this.fragCurrent&&o===Pe.PARSING)&&(this.fragmentTracker.removeFragment(u),this.state=Pe.IDLE);return}"payload"in r&&(this.log(`Loaded ${u.type} sn: ${u.sn} of ${this.playlistLabel()} ${u.level}`),this.hls.trigger(N.FRAG_LOADED,r)),this._handleFragmentLoadComplete(r)}).catch(r=>{this.state===Pe.STOPPED||this.state===Pe.ERROR||(this.warn(`Frag error: ${r?.message||r}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:i}=this;if(i.getState(e)===Ji.APPENDING){const r=e.type,o=this.getFwdBufferInfo(this.mediaBuffer,r),u=Math.max(e.duration,o?o.len:this.config.maxBufferLength),c=this.backtrackFragment;((c?e.sn-c.sn:0)===1||this.reduceMaxBufferLength(u,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)===Ji.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(N.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:o}=i,u=r.decryptdata;if(o&&o.byteLength>0&&u!=null&&u.key&&u.iv&&zu(u.method)){const c=self.performance.now();return this.decrypter.decrypt(new Uint8Array(o),u.key.buffer,u.iv.buffer,ab(u.method)).catch(d=>{throw n.trigger(N.ERROR,{type:nt.MEDIA_ERROR,details:ve.FRAG_DECRYPT_ERROR,fatal:!1,error:d,reason:d.message,frag:r}),d}).then(d=>{const f=self.performance.now();return n.trigger(N.FRAG_DECRYPTED,{frag:r,payload:d,stats:{tstart:c,tdecrypt:f}}),i.payload=d,this.completeInitSegmentLoad(i)})}return this.completeInitSegmentLoad(i)}).catch(i=>{this.state===Pe.STOPPED||this.state===Pe.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!==Pe.STOPPED&&(this.state=Pe.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 o=this.media,u=new Error(`Encrypted track with no key in ${this.fragInfo(t)} (media ${o?"attached mediaKeys: "+o.mediaKeys:"detached"})`);return this.warn(u.message),!o||o.mediaKeys?!1:(this.hls.trigger(N.ERROR,{type:nt.KEY_SYSTEM_ERROR,details:ve.KEY_SYSTEM_NO_KEYS,fatal:!1,error:u,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?n8.toString(vt.getBuffered(i)):"(detached)"})`),ji(e)){var n;if(e.type!==Je.SUBTITLE){const o=e.elementaryStreams;if(!Object.keys(o).some(u=>!!o[u])){this.state=Pe.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=Pe.IDLE}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:i,part:n,partsLoaded:r}=e,o=!r||r.length===0||r.some(c=>!c),u=new rb(i.level,i.sn,i.stats.chunkCount+1,0,n?n.index:-1,!o);t.flush(u)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,i=null,n){var r;this.fragCurrent=e;const o=t.details;if(!this.levels||!o)throw new Error(`frag load aborted, missing level${o?"":" detail"}s`);let u=null;if(e.encrypted&&!((r=e.decryptdata)!=null&&r.key)){if(this.log(`Loading key for ${e.sn} of [${o.startSN}-${o.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=Pe.KEY_LOADING,this.fragCurrent=e,u=this.keyLoader.load(e).then(g=>{if(!this.fragContextChanged(g.frag))return this.hls.trigger(N.KEY_LOADED,g),this.state===Pe.KEY_LOADING&&(this.state=Pe.IDLE),g}),this.hls.trigger(N.KEY_LOADING,{frag:e}),this.fragCurrent===null)return this.log("context changed in KEY_LOADING"),Promise.resolve(null)}else e.encrypted||(u=this.keyLoader.loadClear(e,o.encryptedFragments,this.startFragRequested),u&&this.log("[eme] blocking frag load until media-keys acquired"));const c=this.fragPrevious;if(ji(e)&&(!c||e.sn!==c.sn)){const g=this.shouldLoadParts(t.details,e.end);g!==this.loadingParts&&(this.log(`LL-Part loading ${g?"ON":"OFF"} loading sn ${c?.sn}->${e.sn}`),this.loadingParts=g)}if(i=Math.max(e.start,i||0),this.loadingParts&&ji(e)){const g=o.partList;if(g&&n){i>o.fragmentEnd&&o.fragmentHint&&(e=o.fragmentHint);const v=this.getNextPart(g,e,i);if(v>-1){const b=g[v];e=this.fragCurrent=b.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${b.index} (${v}/${g.length-1}) of ${this.fragInfo(e,!1,b)}) cc: ${e.cc} [${o.startSN}-${o.endSN}], target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=b.start+b.duration,this.state=Pe.FRAG_LOADING;let _;return u?_=u.then(E=>!E||this.fragContextChanged(E.frag)?null:this.doFragPartsLoad(e,b,t,n)).catch(E=>this.handleFragLoadError(E)):_=this.doFragPartsLoad(e,b,t,n).catch(E=>this.handleFragLoadError(E)),this.hls.trigger(N.FRAG_LOADING,{frag:e,part:b,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):_}else if(!e.url||this.loadedEndOfParts(g,i))return Promise.resolve(null)}}if(ji(e)&&this.loadingParts){var d;this.log(`LL-Part loading OFF after next part miss @${i.toFixed(2)} Check buffer at sn: ${e.sn} loaded parts: ${(d=o.partList)==null?void 0:d.filter(g=>g.loaded).map(g=>`[${g.start}-${g.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} ${"["+o.startSN+"-"+o.endSN+"]"}, target: ${parseFloat(i.toFixed(3))}`),We(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=Pe.FRAG_LOADING;const f=this.config.progressive&&e.type!==Je.SUBTITLE;let m;return f&&u?m=u.then(g=>!g||this.fragContextChanged(g.frag)?null:this.fragmentLoader.load(e,n)).catch(g=>this.handleFragLoadError(g)):m=Promise.all([this.fragmentLoader.load(e,f?n:void 0),u]).then(([g])=>(!f&&n&&n(g),g)).catch(g=>this.handleFragLoadError(g)),this.hls.trigger(N.FRAG_LOADING,{frag:e,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):m}doFragPartsLoad(e,t,i,n){return new Promise((r,o)=>{var u;const c=[],d=(u=i.details)==null?void 0:u.partList,f=m=>{this.fragmentLoader.loadPart(e,m,n).then(g=>{c[m.index]=g;const v=g.part;this.hls.trigger(N.FRAG_LOADED,g);const b=n2(i.details,e.sn,m.index+1)||zw(d,e.sn,m.index+1);if(b)f(b);else return r({frag:e,part:v,partsLoaded:c})}).catch(o)};f(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;t.frag&&t.details===ve.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===nt.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger(N.ERROR,t)}else this.hls.trigger(N.ERROR,{type:nt.OTHER_ERROR,details:ve.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==Pe.PARSING){!this.fragCurrent&&this.state!==Pe.STOPPED&&this.state!==Pe.ERROR&&(this.state=Pe.IDLE);return}const{frag:i,part:n,level:r}=t,o=self.performance.now();i.stats.parsing.end=o,n&&(n.stats.parsing.end=o);const u=this.getLevelDetails(),d=u&&i.sn>u.endSN||this.shouldLoadParts(u,i.end);d!==this.loadingParts&&(this.log(`LL-Part loading ${d?"ON":"OFF"} after parsing segment ending @${i.end.toFixed(2)}`),this.loadingParts=d),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===Je.SUBTITLE)return!1;const o=r.end+(((i=e.fragmentHint)==null?void 0:i.duration)||0);if(t>=o){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:o}=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 u=t[n],c=u.details,d=o>-1?n2(c,r,o):null,f=d?d.fragment:qw(c,r,i);return f?(i&&i!==f&&(f.stats=i.stats),{frag:f,part:d,level:u}):null}bufferFragmentData(e,t,i,n,r){if(this.state!==Pe.PARSING)return;const{data1:o,data2:u}=e;let c=o;if(u&&(c=Fn(o,u)),!c.length)return;const d=this.initPTS[t.cc],f=d?-d.baseTime/d.timescale:void 0,m={type:e.type,frag:t,part:i,chunkMeta:n,offset:f,parent:t.type,data:c};if(this.hls.trigger(N.BUFFER_APPENDING,m),e.dropped&&e.independent&&!i){if(r)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!vt.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}const i=t.currentTime,n=vt.bufferInfo(t,i,0),r=e.duration,o=Math.min(this.config.maxFragLookUpTolerance*2,r*.25),u=Math.max(Math.min(e.start-o,n.end-o),i+o);e.start-u>o&&this.flushMainBuffer(u,e.start)}getFwdBufferInfo(e,t){var i;const n=this.getLoadPosition();if(!We(n))return null;const o=this.lastCurrentTime>n||(i=this.media)!=null&&i.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,n,t,o)}getFwdBufferInfoAtPos(e,t,i,n){const r=vt.bufferInfo(e,t,n);if(r.len===0&&r.nextStart!==void 0){const o=this.fragmentTracker.getBufferedFrag(t,i);if(o&&(r.nextStart<=o.end||o.gap)){const u=Math.max(Math.min(r.nextStart,o.end)-t,n);return vt.bufferInfo(e,t,u)}}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=Je.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,o=i[0].start,u=r.lowLatencyMode&&!!t.partList;let c=null;if(t.live){const m=r.initialLiveManifestSize;if(n<m)return this.warn(`Not enough fragments to start playback (have: ${n}, need: ${m})`),null;if(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<o){var d;u&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),c=this.getInitialLiveFragment(t);const g=this.hls.startPosition,v=this.hls.liveSyncPosition,b=c?(g!==-1&&g>=o?g:v)||c.start:e;this.log(`Setting startPosition to ${b} to match start frag at live edge. mainStart: ${g} liveSyncPosition: ${v} frag.start: ${(d=c)==null?void 0:d.start}`),this.startPosition=this.nextLoadPosition=b}}else e<=o&&(c=i[0]);if(!c){const m=this.loadingParts?t.partEnd:t.fragmentEnd;c=this.getFragmentAtPosition(e,m,t)}let f=this.filterReplacedPrimary(c,t);if(!f&&c){const m=c.sn-t.startSN;f=this.filterReplacedPrimary(i[m+1]||null,t)}return this.mapToInitFragWhenRequired(f)}isLoopLoading(e,t){const i=this.fragmentTracker.getState(e);return(i===Ji.OK||i===Ji.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,i,n,r){let o=null;if(e.gap&&(o=this.getNextFragment(this.nextLoadPosition,t),o&&!o.gap&&i.nextStart)){const u=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,n,0);if(u!==null&&i.len+u.len>=r){const c=o.sn;return this.loopSn!==c&&(this.log(`buffer full after gaps in "${n}" playlist starting at sn: ${c}`),this.loopSn=c),null}}return this.loopSn=void 0,o}get primaryPrefetch(){if(o2(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(o2(this.config)&&e.type!==Je.SUBTITLE){const i=this.hls.interstitialsManager,n=i?.bufferingItem;if(n){const o=n.event;if(o){if(o.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 o=r.length;o--;){const u=r[o].interstitial;if(u.appendInPlace&&e.start>=u.startTime&&e.end<=u.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,o=!0;for(let u=0,c=e.length;u<c;u++){const d=e[u];if(o=o&&!d.independent,n>-1&&i<d.start)break;const f=d.loaded;f?n=-1:(r||(d.independent||o)&&d.fragment===t)&&(d.fragment!==t&&this.warn(`Need buffer at ${i} but next unloaded part starts at ${d.start}`),n=u),r=f}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=bF(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!n){const r=i.sn+1;if(r>=e.startSN&&r<=e.endSN){const o=t[r-e.startSN];i.cc===o.cc&&(n=o,this.log(`Live playlist, switching playlist, load frag with next SN: ${n.sn}`))}n||(n=kw(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:o,endSN:u}=i;const{fragmentHint:c}=i,{maxFragLookUpTolerance:d}=n,f=i.partList,m=!!(this.loadingParts&&f!=null&&f.length&&c);m&&!this.bitrateTest&&f[f.length-1].fragment.sn===c.sn&&(o=o.concat(c),u=c.sn);let g;if(e<t){var v;const _=e<this.lastCurrentTime||e>t-d||(v=this.media)!=null&&v.paused||!this.startFragRequested?0:d;g=Cl(r,o,e,_)}else g=o[o.length-1];if(g){const b=g.sn-i.startSN,_=this.fragmentTracker.getState(g);if((_===Ji.OK||_===Ji.PARTIAL&&g.gap)&&(r=g),r&&g.sn===r.sn&&(!m||f[0].fragment.sn>g.sn||!i.live)&&g.level===r.level){const w=o[b+1];g.sn<u&&this.fragmentTracker.getState(w)!==Ji.OK?g=w:g=null}}return g}alignPlaylists(e,t,i){const n=e.fragments.length;if(!n)return this.warn("No fragments in live playlist"),0;const r=e.fragmentStart,o=!t,u=e.alignedSliding&&We(r);if(o||!u&&!r){s8(i,e);const c=e.fragmentStart;return this.log(`Live playlist sliding: ${c.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${n}`),c}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,o=r?this.startTimeOffset:e.startTimeOffset;o!==null&&We(o)?(i=t+o,o<0&&(i+=e.edge),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Setting startPosition to ${i} for start time offset ${o} 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&&ji(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!==Pe.FRAG_LOADING_WAITING_RETRY)&&(this.state=Pe.IDLE)}onFragmentOrKeyLoadError(e,t){var i;if(t.chunkMeta&&!t.frag){const w=this.getCurrentContext(t.chunkMeta);w&&(t.frag=w.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 o=t.details===ve.FRAG_GAP;o&&this.fragmentTracker.fragBuffered(n,!0);const u=t.errorAction;if(!u){this.state=Pe.ERROR;return}const{action:c,flags:d,retryCount:f=0,retryConfig:m}=u,g=!!m,v=g&&c===ps.RetryRequest,b=g&&!u.resolved&&d===Tn.MoveAllAlternatesMatchingHost,_=(i=this.hls.latestLevelDetails)==null?void 0:i.live;if(!v&&b&&ji(n)&&!n.endList&&_&&!Ow(t))this.resetFragmentErrors(e),this.treatAsGap(n),u.resolved=!0;else if((v||b)&&f<m.maxNumRetry){var E;const w=zv((E=t.response)==null?void 0:E.code),I=sb(m,f);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+I,this.state=Pe.FRAG_LOADING_WAITING_RETRY,u.resolved=!0,w){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 ${f+1}/${m.maxNumRetry} in ${I}ms`)}else if(m)if(this.resetFragmentErrors(e),f<m.maxNumRetry)!o&&c!==ps.RemoveAlternatePermanently&&(u.resolved=!0);else{this.warn(`${t.details} reached or exceeded max retry (${f})`);return}else c===ps.SendAlternateToPenaltyBox?this.state=Pe.WAITING_LEVEL:this.state=Pe.ERROR;this.tickImmediate()}checkRetryDate(){const e=self.performance.now(),t=this.retryDate,i=t===1/0;(!t||e>=t||i&&!zv(0))&&(i&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=Pe.IDLE)}reduceLengthAndFlushBuffer(e){if(this.state===Pe.PARSING||this.state===Pe.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 o=!r;return o&&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(),o}return!1}resetFragmentErrors(e){e===Je.AUDIO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==Pe.STOPPED&&(this.state=Pe.IDLE)}afterBufferFlushed(e,t,i){if(!e)return;const n=vt.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,n,i),this.state===Pe.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==Pe.STOPPED&&(this.state=Pe.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((c,d)=>{const f=e.elementaryStreams[d];if(f){const m=f.endPTS-f.startPTS;if(m<=0)return this.warn(`Could not parse fragment ${e.sn} ${d} duration reliably (${m})`),c||!1;const g=n?0:Hw(r,e,f.startPTS,f.endPTS,f.startDTS,f.endDTS,this);return this.hls.trigger(N.LEVEL_PTS_UPDATED,{details:r,level:i,drift:g,type:d,frag:e,start:f.startPTS,end:f.endPTS}),!0}return c},!1)){var u;const c=((u=this.transmuxer)==null?void 0:u.error)===null;if((i.fragmentError===0||c&&(i.fragmentError<2||e.endList))&&this.treatAsGap(e,i),c){const d=new Error(`Found no media in fragment ${e.sn} of ${this.playlistLabel()} ${e.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(d.message),this.hls.trigger(N.ERROR,{type:nt.MEDIA_ERROR,details:ve.FRAG_PARSING_ERROR,fatal:!1,error:d,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}}this.state=Pe.PARSED,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)})`),this.hls.trigger(N.FRAG_PARSED,{frag:e,part:t})}playlistLabel(){return this.playlistType===Je.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 o2(s){return!!s.interstitialsController&&s.enableInterstitialPlayback!==!1}class Xw{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=r8(e,t);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}}function r8(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 jy={exports:{}},l2;function a8(){return l2||(l2=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(c,d,f){this.fn=c,this.context=d,this.once=f||!1}function r(c,d,f,m,g){if(typeof f!="function")throw new TypeError("The listener must be a function");var v=new n(f,m||c,g),b=t?t+d:d;return c._events[b]?c._events[b].fn?c._events[b]=[c._events[b],v]:c._events[b].push(v):(c._events[b]=v,c._eventsCount++),c}function o(c,d){--c._eventsCount===0?c._events=new i:delete c._events[d]}function u(){this._events=new i,this._eventsCount=0}u.prototype.eventNames=function(){var d=[],f,m;if(this._eventsCount===0)return d;for(m in f=this._events)e.call(f,m)&&d.push(t?m.slice(1):m);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(f)):d},u.prototype.listeners=function(d){var f=t?t+d:d,m=this._events[f];if(!m)return[];if(m.fn)return[m.fn];for(var g=0,v=m.length,b=new Array(v);g<v;g++)b[g]=m[g].fn;return b},u.prototype.listenerCount=function(d){var f=t?t+d:d,m=this._events[f];return m?m.fn?1:m.length:0},u.prototype.emit=function(d,f,m,g,v,b){var _=t?t+d:d;if(!this._events[_])return!1;var E=this._events[_],w=arguments.length,I,L;if(E.fn){switch(E.once&&this.removeListener(d,E.fn,void 0,!0),w){case 1:return E.fn.call(E.context),!0;case 2:return E.fn.call(E.context,f),!0;case 3:return E.fn.call(E.context,f,m),!0;case 4:return E.fn.call(E.context,f,m,g),!0;case 5:return E.fn.call(E.context,f,m,g,v),!0;case 6:return E.fn.call(E.context,f,m,g,v,b),!0}for(L=1,I=new Array(w-1);L<w;L++)I[L-1]=arguments[L];E.fn.apply(E.context,I)}else{var F=E.length,$;for(L=0;L<F;L++)switch(E[L].once&&this.removeListener(d,E[L].fn,void 0,!0),w){case 1:E[L].fn.call(E[L].context);break;case 2:E[L].fn.call(E[L].context,f);break;case 3:E[L].fn.call(E[L].context,f,m);break;case 4:E[L].fn.call(E[L].context,f,m,g);break;default:if(!I)for($=1,I=new Array(w-1);$<w;$++)I[$-1]=arguments[$];E[L].fn.apply(E[L].context,I)}}return!0},u.prototype.on=function(d,f,m){return r(this,d,f,m,!1)},u.prototype.once=function(d,f,m){return r(this,d,f,m,!0)},u.prototype.removeListener=function(d,f,m,g){var v=t?t+d:d;if(!this._events[v])return this;if(!f)return o(this,v),this;var b=this._events[v];if(b.fn)b.fn===f&&(!g||b.once)&&(!m||b.context===m)&&o(this,v);else{for(var _=0,E=[],w=b.length;_<w;_++)(b[_].fn!==f||g&&!b[_].once||m&&b[_].context!==m)&&E.push(b[_]);E.length?this._events[v]=E.length===1?E[0]:E:o(this,v)}return this},u.prototype.removeAllListeners=function(d){var f;return d?(f=t?t+d:d,this._events[f]&&o(this,f)):(this._events=new i,this._eventsCount=0),this},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=t,u.EventEmitter=u,s.exports=u})(jy)),jy.exports}var o8=a8(),ub=RB(o8);const Zd="1.6.15",rc={};function l8(){return typeof __HLS_WORKER_BUNDLE__=="function"}function u8(){const s=rc[Zd];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 rc[Zd]=n,n}function c8(s){const e=rc[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 rc[s]=n,n}function d8(s){const e=rc[s||Zd];if(e&&e.clientCount--===1){const{worker:i,objectURL:n}=e;delete rc[s||Zd],n&&self.URL.revokeObjectURL(n),i.terminate()}}function Qw(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 cb(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 Hm(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 Jd(s,e){const t=e;let i=0;for(;cb(s,e);){i+=10;const n=Hm(s,e+6);i+=n,Qw(s,e+10)&&(i+=10),e+=i}if(i>0)return s.subarray(t,t+i)}function h8(s,e,t,i){const n=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],r=e[t+2],o=r>>2&15;if(o>12){const v=new Error(`invalid ADTS sampling index:${o}`);s.emit(N.ERROR,N.ERROR,{type:nt.MEDIA_ERROR,details:ve.FRAG_PARSING_ERROR,fatal:!0,error:v,reason:v.message});return}const u=(r>>6&3)+1,c=e[t+3]>>6&3|(r&1)<<2,d="mp4a.40."+u,f=n[o];let m=o;(u===5||u===29)&&(m-=3);const g=[u<<3|(m&14)>>1,(m&1)<<7|c<<3];return Zt.log(`manifest codec:${i}, parsed codec:${d}, channels:${c}, rate:${f} (ADTS object type:${u} sampling index:${o})`),{config:g,samplerate:f,channelCount:c,codec:d,parsedCodec:d,manifestCodec:i}}function Zw(s,e){return s[e]===255&&(s[e+1]&246)===240}function Jw(s,e){return s[e+1]&1?7:9}function db(s,e){return(s[e+3]&3)<<11|s[e+4]<<3|(s[e+5]&224)>>>5}function f8(s,e){return e+5<s.length}function am(s,e){return e+1<s.length&&Zw(s,e)}function p8(s,e){return f8(s,e)&&Zw(s,e)&&db(s,e)<=s.length-e}function m8(s,e){if(am(s,e)){const t=Jw(s,e);if(e+t>=s.length)return!1;const i=db(s,e);if(i<=t)return!1;const n=e+i;return n===s.length||am(s,n)}return!1}function eL(s,e,t,i,n){if(!s.samplerate){const r=h8(e,t,i,n);if(!r)return;ni(s,r)}}function tL(s){return 1024*9e4/s}function g8(s,e){const t=Jw(s,e);if(e+t<=s.length){const i=db(s,e)-t;if(i>0)return{headerLength:t,frameLength:i}}}function iL(s,e,t,i,n){const r=tL(s.samplerate),o=i+n*r,u=g8(e,t);let c;if(u){const{frameLength:m,headerLength:g}=u,v=g+m,b=Math.max(0,t+v-e.length);b?(c=new Uint8Array(v-g),c.set(e.subarray(t+g,e.length),0)):c=e.subarray(t+g,t+v);const _={unit:c,pts:o};return b||s.samples.push(_),{sample:_,length:v,missing:b}}const d=e.length-t;return c=new Uint8Array(d),c.set(e.subarray(t,e.length),0),{sample:{unit:c,pts:o},length:d,missing:-1}}function y8(s,e){return cb(s,e)&&Hm(s,e+6)+10<=s.length-e}function v8(s){return s instanceof ArrayBuffer?s:s.byteOffset==0&&s.byteLength==s.buffer.byteLength?s.buffer:new Uint8Array(s).buffer}function Hy(s,e=0,t=1/0){return T8(s,e,t,Uint8Array)}function T8(s,e,t,i){const n=b8(s);let r=1;"BYTES_PER_ELEMENT"in i&&(r=i.BYTES_PER_ELEMENT);const o=_8(s)?s.byteOffset:0,u=(o+s.byteLength)/r,c=(o+e)/r,d=Math.floor(Math.max(0,Math.min(c,u))),f=Math.floor(Math.min(d+Math.max(t,0),u));return new i(n,d,f-d)}function b8(s){return s instanceof ArrayBuffer?s:s.buffer}function _8(s){return s&&s.buffer instanceof ArrayBuffer&&s.byteLength!==void 0&&s.byteOffset!==void 0}function x8(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=xn(Hy(s.data,1,i)),r=s.data[2+i],o=s.data.subarray(3+i).indexOf(0);if(o===-1)return;const u=xn(Hy(s.data,3+i,o));let c;return n==="-->"?c=xn(Hy(s.data,4+i+o)):c=v8(s.data.subarray(4+i+o)),e.mimeType=n,e.pictureType=r,e.description=u,e.data=c,e}function S8(s){if(s.size<2)return;const e=xn(s.data,!0),t=new Uint8Array(s.data.subarray(e.length+1));return{key:s.type,info:e,data:t.buffer}}function E8(s){if(s.size<2)return;if(s.type==="TXXX"){let t=1;const i=xn(s.data.subarray(t),!0);t+=i.length+1;const n=xn(s.data.subarray(t));return{key:s.type,info:i,data:n}}const e=xn(s.data.subarray(1));return{key:s.type,info:"",data:e}}function A8(s){if(s.type==="WXXX"){if(s.size<2)return;let t=1;const i=xn(s.data.subarray(t),!0);t+=i.length+1;const n=xn(s.data.subarray(t));return{key:s.type,info:i,data:n}}const e=xn(s.data);return{key:s.type,info:"",data:e}}function C8(s){return s.type==="PRIV"?S8(s):s.type[0]==="W"?A8(s):s.type==="APIC"?x8(s):E8(s)}function D8(s){const e=String.fromCharCode(s[0],s[1],s[2],s[3]),t=Hm(s,4),i=10;return{type:e,size:t,data:s.subarray(i,i+t)}}const tp=10,w8=10;function sL(s){let e=0;const t=[];for(;cb(s,e);){const i=Hm(s,e+6);s[e+5]>>6&1&&(e+=tp),e+=tp;const n=e+i;for(;e+w8<n;){const r=D8(s.subarray(e)),o=C8(r);o&&t.push(o),e+=r.size+tp}Qw(s,e)&&(e+=tp)}return t}function nL(s){return s&&s.key==="PRIV"&&s.info==="com.apple.streaming.transportStreamTimestamp"}function L8(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 hb(s){const e=sL(s);for(let t=0;t<e.length;t++){const i=e[t];if(nL(i))return L8(i)}}let _n=(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 Dr(s="",e=9e4){return{type:s,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class fb{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=Fn(this.cachedData,e),this.cachedData=null);let i=Jd(e,0),n=i?i.length:0,r;const o=this._audioTrack,u=this._id3Track,c=i?hb(i):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&We(c))&&(this.basePTS=I8(c,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&u.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:_n.audioId3,duration:Number.POSITIVE_INFINITY});n<d;){if(this.canParse(e,n)){const f=this.appendFrame(o,e,n);f?(this.frameIndex++,this.lastPTS=f.sample.pts,n+=f.length,r=n):n=d}else y8(e,n)?(i=Jd(e,n),u.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:_n.audioId3,duration:Number.POSITIVE_INFINITY}),n+=i.length,r=n):n++;if(n===d&&r!==d){const f=e.slice(r);this.cachedData?this.cachedData=Fn(this.cachedData,f):this.cachedData=f}}return{audioTrack:o,videoTrack:Dr(),id3Track:u,textTrack:Dr()}}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:Dr(),id3Track:this._id3Track,textTrack:Dr()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}const I8=(s,e,t)=>{if(We(s))return s*90;const i=t?t.baseTime*9e4/t.timescale:0;return e*9e4+i};let ip=null;const k8=[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],R8=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],O8=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],P8=[0,1,1,4];function rL(s,e,t,i,n){if(t+24>e.length)return;const r=aL(e,t);if(r&&t+r.frameLength<=e.length){const o=r.samplesPerFrame*9e4/r.sampleRate,u=i+n*o,c={unit:e.subarray(t,t+r.frameLength),pts:u,dts:u};return s.config=[],s.channelCount=r.channelCount,s.samplerate=r.sampleRate,s.samples.push(c),{sample:c,length:r.frameLength,missing:0}}}function aL(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 o=s[e+2]>>1&1,u=s[e+3]>>6,c=t===3?3-i:i===3?3:4,d=k8[c*14+n-1]*1e3,m=R8[(t===3?0:t===2?1:2)*3+r],g=u===3?1:2,v=O8[t][i],b=P8[i],_=v*8*b,E=Math.floor(v*d/m+o)*b;if(ip===null){const L=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);ip=L?parseInt(L[1]):0}return ip&&ip<=87&&i===2&&d>=224e3&&u===0&&(s[e+3]=s[e+3]|128),{sampleRate:m,channelCount:g,frameLength:E,samplesPerFrame:_}}}function pb(s,e){return s[e]===255&&(s[e+1]&224)===224&&(s[e+1]&6)!==0}function oL(s,e){return e+1<s.length&&pb(s,e)}function M8(s,e){return pb(s,e)&&4<=s.length-e}function lL(s,e){if(e+1<s.length&&pb(s,e)){const i=aL(s,e);let n=4;i!=null&&i.frameLength&&(n=i.frameLength);const r=e+n;return r===s.length||oL(s,r)}return!1}class N8 extends fb{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=Jd(e,0);let n=i?.length||0;if(lL(e,n))return!1;for(let r=e.length;n<r;n++)if(m8(e,n))return t.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return p8(e,t)}appendFrame(e,t,i){eL(e,this.observer,t,i,e.manifestCodec);const n=iL(e,t,i,this.basePTS,this.frameIndex);if(n&&n.missing===0)return n}}const uL=(s,e)=>{let t=0,i=5;e+=i;const n=new Uint32Array(1),r=new Uint32Array(1),o=new Uint8Array(1);for(;i>0;){o[0]=s[e];const u=Math.min(i,8),c=8-u;r[0]=4278190080>>>24+c<<c,n[0]=(o[0]&r[0])>>c,t=t?t<<u|n[0]:n[0],e+=1,i-=u}return t};class B8 extends fb{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=cL(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=Jd(e,0);if(!t)return!1;const i=t.length;return e[i]===11&&e[i+1]===119&&hb(t)!==void 0&&uL(e,i)<16}}function cL(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 u=[48e3,44100,32e3][r],c=e[t+4]&63,f=[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][c*3+r]*2;if(t+f>e.length)return-1;const m=e[t+6]>>5;let g=0;m===2?g+=2:(m&1&&m!==1&&(g+=2),m&4&&(g+=2));const v=(e[t+6]<<8|e[t+7])>>12-g&1,_=[2,1,2,3,3,4,4,5][m]+v,E=e[t+5]>>3,w=e[t+5]&7,I=new Uint8Array([r<<6|E<<1|w>>2,(w&3)<<6|m<<3|v<<2|c>>4,c<<4&224]),L=1536/u*9e4,F=i+n*L,$=e.subarray(t,t+f);return s.config=I,s.channelCount=_,s.samplerate=u,s.samples.push({unit:$,pts:F}),f}class F8 extends fb{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=Jd(e,0);let i=t?.length||0;if(t&&e[i]===11&&e[i+1]===119&&hb(t)!==void 0&&uL(e,i)<=16)return!1;for(let n=e.length;i<n;i++)if(lL(e,i))return Zt.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return M8(e,t)}appendFrame(e,t,i){if(this.basePTS!==null)return rL(e,t,i,this.basePTS,this.frameIndex)}}const U8=/\/emsg[-/]ID3/i;class $8{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=Dr("video",1),o=this.audioTrack=Dr("audio",1),u=this.txtTrack=Dr("text",1);if(this.id3Track=Dr("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;const c=bw(e);if(c.video){const{id:d,timescale:f,codec:m,supplemental:g}=c.video;r.id=d,r.timescale=u.timescale=f,r.codec=m,r.supplemental=g}if(c.audio){const{id:d,timescale:f,codec:m}=c.audio;o.id=d,o.timescale=f,o.codec=m}u.id=yw.text,r.sampleDuration=0,r.duration=o.duration=n}resetContiguity(){this.remainderData=null}static probe(e){return BB(e)}demux(e,t){this.timeOffset=t;let i=e;const n=this.videoTrack,r=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=Fn(this.remainderData,e));const u=VB(i);this.remainderData=u.remainder,n.samples=u.valid||new Uint8Array}else n.samples=i;const o=this.extractID3Track(n,t);return r.samples=C1(t,n),{videoTrack:n,audioTrack:this.audioTrack,id3Track:o,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=C1(e,t),{videoTrack:t,audioTrack:Dr(),id3Track:n,textTrack:Dr()}}extractID3Track(e,t){const i=this.id3Track;if(e.samples.length){const n=wt(e.samples,["emsg"]);n&&n.forEach(r=>{const o=zB(r);if(U8.test(o.schemeIdUri)){const u=u2(o,t);let c=o.eventDuration===4294967295?Number.POSITIVE_INFINITY:o.eventDuration/o.timeScale;c<=.001&&(c=Number.POSITIVE_INFINITY);const d=o.payload;i.samples.push({data:d,len:d.byteLength,dts:u,pts:u,type:_n.emsg,duration:c})}else if(this.config.enableEmsgKLVMetadata&&o.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){const u=u2(o,t);i.samples.push({data:o.payload,len:o.payload.byteLength,dts:u,pts:u,type:_n.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 u2(s,e){return We(s.presentationTime)?s.presentationTime/s.timeScale:e+s.presentationTimeDelta/s.timeScale}class j8{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new nb(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,Ao.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),o=r.buffer.slice(r.byteOffset,r.byteOffset+r.length);this.decryptBuffer(o).then(u=>{const c=new Uint8Array(u);n.set(c,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 o=Sw(r.data),u=this.getAvcEncryptedData(o);this.decryptBuffer(u.buffer).then(c=>{r.data=this.getAvcDecryptedUnit(o,c),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 o=r[i];if(!(o.data.length<=48||o.type!==1&&o.type!==5)&&(this.decryptAvcSample(e,t,i,n,o),!this.decrypter.isSync()))return}}}}class dL{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 o=r,u=[];let c=0,d,f,m,g=-1,v=0;for(r===-1&&(g=0,v=this.getNALuType(t,0),r=0,c=1);c<n;){if(d=t[c++],!r){r=d?0:1;continue}if(r===1){r=d?0:2;continue}if(!d)r=3;else if(d===1){if(f=c-r-1,g>=0){const b={data:t.subarray(g,f),type:v};u.push(b)}else{const b=this.getLastNalUnit(e.samples);b&&(o&&c<=4-o&&b.state&&(b.data=b.data.subarray(0,b.data.byteLength-o)),f>0&&(b.data=Fn(b.data,t.subarray(0,f)),b.state=0))}c<n?(m=this.getNALuType(t,c),g=c,v=m,r=0):r=-1}else r=0}if(g>=0&&r>=0){const b={data:t.subarray(g,n),type:v,state:r};u.push(b)}if(u.length===0){const b=this.getLastNalUnit(e.samples);b&&(b.data=Fn(b.data,t))}return e.naluState=r,u}}class Hd{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>e?(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&&Zt.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 H8 extends dL{parsePES(e,t,i,n){const r=this.parseNALu(e,i.data,n);let o=this.VideoSample,u,c=!1;i.data=null,o&&r.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),r.forEach(d=>{var f,m;switch(d.type){case 1:{let _=!1;u=!0;const E=d.data;if(c&&E.length>4){const w=this.readSliceType(E);(w===2||w===4||w===7||w===9)&&(_=!0)}if(_){var g;(g=o)!=null&&g.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null)}o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.frame=!0,o.key=_;break}case 5:u=!0,(f=o)!=null&&f.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.key=!0,o.frame=!0;break;case 6:{u=!0,eb(d.data,1,i.pts,t.samples);break}case 7:{var v,b;u=!0,c=!0;const _=d.data,E=this.readSPS(_);if(!e.sps||e.width!==E.width||e.height!==E.height||((v=e.pixelRatio)==null?void 0:v[0])!==E.pixelRatio[0]||((b=e.pixelRatio)==null?void 0:b[1])!==E.pixelRatio[1]){e.width=E.width,e.height=E.height,e.pixelRatio=E.pixelRatio,e.sps=[_];const w=_.subarray(1,4);let I="avc1.";for(let L=0;L<3;L++){let F=w[L].toString(16);F.length<2&&(F="0"+F),I+=F}e.codec=I}break}case 8:u=!0,e.pps=[d.data];break;case 9:u=!0,e.audFound=!0,(m=o)!=null&&m.frame&&(this.pushAccessUnit(o,e),o=null),o||(o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;case 12:u=!0;break;default:u=!1;break}o&&u&&o.units.push(d)}),n&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}getNALuType(e,t){return e[t]&31}readSliceType(e){const t=new Hd(e);return t.readUByte(),t.readUEG(),t.readUEG()}skipScalingList(e,t){let i=8,n=8,r;for(let o=0;o<e;o++)n!==0&&(r=t.readEG(),n=(i+r+256)%256),i=n===0?i:n}readSPS(e){const t=new Hd(e);let i=0,n=0,r=0,o=0,u,c,d;const f=t.readUByte.bind(t),m=t.readBits.bind(t),g=t.readUEG.bind(t),v=t.readBoolean.bind(t),b=t.skipBits.bind(t),_=t.skipEG.bind(t),E=t.skipUEG.bind(t),w=this.skipScalingList.bind(this);f();const I=f();if(m(5),b(3),f(),E(),I===100||I===110||I===122||I===244||I===44||I===83||I===86||I===118||I===128){const V=g();if(V===3&&b(1),E(),E(),b(1),v())for(c=V!==3?8:12,d=0;d<c;d++)v()&&(d<6?w(16,t):w(64,t))}E();const L=g();if(L===0)g();else if(L===1)for(b(1),_(),_(),u=g(),d=0;d<u;d++)_();E(),b(1);const F=g(),$=g(),G=m(1);G===0&&b(1),b(1),v()&&(i=g(),n=g(),r=g(),o=g());let B=[1,1];if(v()&&v())switch(f()){case 1:B=[1,1];break;case 2:B=[12,11];break;case 3:B=[10,11];break;case 4:B=[16,11];break;case 5:B=[40,33];break;case 6:B=[24,11];break;case 7:B=[20,11];break;case 8:B=[32,11];break;case 9:B=[80,33];break;case 10:B=[18,11];break;case 11:B=[15,11];break;case 12:B=[64,33];break;case 13:B=[160,99];break;case 14:B=[4,3];break;case 15:B=[3,2];break;case 16:B=[2,1];break;case 255:{B=[f()<<8|f(),f()<<8|f()];break}}return{width:Math.ceil((F+1)*16-i*2-n*2),height:(2-G)*($+1)*16-(G?2:4)*(r+o),pixelRatio:B}}}class G8 extends dL{constructor(...e){super(...e),this.initVPS=null}parsePES(e,t,i,n){const r=this.parseNALu(e,i.data,n);let o=this.VideoSample,u,c=!1;i.data=null,o&&r.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),r.forEach(d=>{var f,m;switch(d.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:o||(o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),o.frame=!0,u=!0;break;case 16:case 17:case 18:case 21:if(u=!0,c){var g;(g=o)!=null&&g.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null)}o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.key=!0,o.frame=!0;break;case 19:case 20:u=!0,(f=o)!=null&&f.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.key=!0,o.frame=!0;break;case 39:u=!0,eb(d.data,2,i.pts,t.samples);break;case 32:u=!0,e.vps||(typeof e.params!="object"&&(e.params={}),e.params=ni(e.params,this.readVPS(d.data)),this.initVPS=d.data),e.vps=[d.data];break;case 33:if(u=!0,c=!0,e.vps!==void 0&&e.vps[0]!==this.initVPS&&e.sps!==void 0&&!this.matchSPS(e.sps[0],d.data)&&(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){const v=this.readSPS(d.data);e.width=v.width,e.height=v.height,e.pixelRatio=v.pixelRatio,e.codec=v.codecString,e.sps=[],typeof e.params!="object"&&(e.params={});for(const b in v.params)e.params[b]=v.params[b]}this.pushParameterSet(e.sps,d.data,e.vps),o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.key=!0;break;case 34:if(u=!0,typeof e.params=="object"){if(!e.pps){e.pps=[];const v=this.readPPS(d.data);for(const b in v)e.params[b]=v[b]}this.pushParameterSet(e.pps,d.data,e.vps)}break;case 35:u=!0,e.audFound=!0,(m=o)!=null&&m.frame&&(this.pushAccessUnit(o,e),o=null),o||(o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;default:u=!1;break}o&&u&&o.units.push(d)}),n&&o&&(this.pushAccessUnit(o,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 Hd(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 Hd(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(),o=t.readBits(5),u=t.readUByte(),c=t.readUByte(),d=t.readUByte(),f=t.readUByte(),m=t.readUByte(),g=t.readUByte(),v=t.readUByte(),b=t.readUByte(),_=t.readUByte(),E=t.readUByte(),w=t.readUByte(),I=[],L=[];for(let Be=0;Be<i;Be++)I.push(t.readBoolean()),L.push(t.readBoolean());if(i>0)for(let Be=i;Be<8;Be++)t.readBits(2);for(let Be=0;Be<i;Be++)I[Be]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),L[Be]&&t.readUByte();t.readUEG();const F=t.readUEG();F==3&&t.skipBits(1);const $=t.readUEG(),G=t.readUEG(),B=t.readBoolean();let V=0,k=0,R=0,z=0;B&&(V+=t.readUEG(),k+=t.readUEG(),R+=t.readUEG(),z+=t.readUEG());const X=t.readUEG(),ee=t.readUEG(),le=t.readUEG(),oe=t.readBoolean();for(let Be=oe?0:i;Be<=i;Be++)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 Xe=0;Xe<4;Xe++)for(let ft=0;ft<(Xe===3?2:6);ft++)if(!t.readBoolean())t.readUEG();else{const we=Math.min(64,1<<4+(Xe<<1));Xe>1&&t.readEG();for(let Fe=0;Fe<we;Fe++)t.readEG()}t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());const Q=t.readUEG();let ae=0;for(let Be=0;Be<Q;Be++){let Xe=!1;if(Be!==0&&(Xe=t.readBoolean()),Xe){Be===Q&&t.readUEG(),t.readBoolean(),t.readUEG();let ft=0;for(let At=0;At<=ae;At++){const we=t.readBoolean();let Fe=!1;we||(Fe=t.readBoolean()),(we||Fe)&&ft++}ae=ft}else{const ft=t.readUEG(),At=t.readUEG();ae=ft+At;for(let we=0;we<ft;we++)t.readUEG(),t.readBoolean();for(let we=0;we<At;we++)t.readUEG(),t.readBoolean()}}if(t.readBoolean()){const Be=t.readUEG();for(let Xe=0;Xe<Be;Xe++){for(let ft=0;ft<le+4;ft++)t.readBits(1);t.readBits(1)}}let U=0,ie=1,fe=1,xe=!0,Ae=1,$e=0;t.readBoolean(),t.readBoolean();let Ee=!1;if(t.readBoolean()){if(t.readBoolean()){const Ue=t.readUByte(),Ke=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],Ye=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];Ue>0&&Ue<16?(ie=Ke[Ue-1],fe=Ye[Ue-1]):Ue===255&&(ie=t.readBits(16),fe=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(),Ee=t.readBoolean(),Ee&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG()),t.readBoolean()&&(Ae=t.readBits(32),$e=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean())){const Ye=t.readBoolean(),gt=t.readBoolean();let Lt=!1;(Ye||gt)&&(Lt=t.readBoolean(),Lt&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),Lt&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(let $t=0;$t<=i;$t++){xe=t.readBoolean();const fi=xe||t.readBoolean();let pi=!1;fi?t.readEG():pi=t.readBoolean();const ts=pi?1:t.readUEG()+1;if(Ye)for(let vs=0;vs<ts;vs++)t.readUEG(),t.readUEG(),Lt&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(gt)for(let vs=0;vs<ts;vs++)t.readUEG(),t.readUEG(),Lt&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),U=t.readUEG())}let qe=$,et=G;if(B){let Be=1,Xe=1;F===1?Be=Xe=2:F==2&&(Be=2),qe=$-Be*k-Be*V,et=G-Xe*z-Xe*R}const rt=n?["A","B","C"][n]:"",ht=u<<24|c<<16|d<<8|f;let qt=0;for(let Be=0;Be<32;Be++)qt=(qt|(ht>>Be&1)<<31-Be)>>>0;let xt=qt.toString(16);return o===1&&xt==="2"&&(xt="6"),{codecString:`hvc1.${rt}${o}.${xt}.${r?"H":"L"}${w}.B0`,params:{general_tier_flag:r,general_profile_idc:o,general_profile_space:n,general_profile_compatibility_flags:[u,c,d,f],general_constraint_indicator_flags:[m,g,v,b,_,E],general_level_idc:w,bit_depth:X+8,bit_depth_luma_minus8:X,bit_depth_chroma_minus8:ee,min_spatial_segmentation_idc:U,chroma_format_idc:F,frame_rate:{fixed:xe,fps:$e/Ae}},width:qe,height:et,pixelRatio:[ie,fe]}}readPPS(e){const t=new Hd(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 o=1;return r&&n?o=0:r?o=3:n&&(o=2),{parallelismType:o}}matchSPS(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}const as=188;class go{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=go.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(as*5,t-as)+1,n=0;for(;n<i;){let r=!1,o=-1,u=0;for(let c=n;c<t;c+=as)if(e[c]===71&&(t-c===as||e[c+as]===71)){if(u++,o===-1&&(o=c,o!==0&&(i=Math.min(o+as*99,e.length-as)+1)),r||(r=Qv(e,c)===0),r&&u>1&&(o===0&&u>2||c+as>i))return o}else{if(u)return-1;break}n++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:yw[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=go.createTrack("video"),this._videoTrack.duration=n,this._audioTrack=go.createTrack("audio",n),this._id3Track=go.createTrack("id3"),this._txtTrack=go.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 o=this._videoTrack,u=this._audioTrack,c=this._id3Track,d=this._txtTrack;let f=o.pid,m=o.pesData,g=u.pid,v=c.pid,b=u.pesData,_=c.pesData,E=null,w=this.pmtParsed,I=this._pmtId,L=e.length;if(this.remainderData&&(e=Fn(this.remainderData,e),L=e.length,this.remainderData=null),L<as&&!n)return this.remainderData=e,{audioTrack:u,videoTrack:o,id3Track:c,textTrack:d};const F=Math.max(0,go.syncOffset(e));L-=(L-F)%as,L<e.byteLength&&!n&&(this.remainderData=new Uint8Array(e.buffer,L,e.buffer.byteLength-L));let $=0;for(let B=F;B<L;B+=as)if(e[B]===71){const V=!!(e[B+1]&64),k=Qv(e,B),R=(e[B+3]&48)>>4;let z;if(R>1){if(z=B+5+e[B+4],z===B+as)continue}else z=B+4;switch(k){case f:V&&(m&&(r=Cu(m,this.logger))&&(this.readyVideoParser(o.segmentCodec),this.videoParser!==null&&this.videoParser.parsePES(o,d,r,!1)),m={data:[],size:0}),m&&(m.data.push(e.subarray(z,B+as)),m.size+=B+as-z);break;case g:if(V){if(b&&(r=Cu(b,this.logger)))switch(u.segmentCodec){case"aac":this.parseAACPES(u,r);break;case"mp3":this.parseMPEGPES(u,r);break;case"ac3":this.parseAC3PES(u,r);break}b={data:[],size:0}}b&&(b.data.push(e.subarray(z,B+as)),b.size+=B+as-z);break;case v:V&&(_&&(r=Cu(_,this.logger))&&this.parseID3PES(c,r),_={data:[],size:0}),_&&(_.data.push(e.subarray(z,B+as)),_.size+=B+as-z);break;case 0:V&&(z+=e[z]+1),I=this._pmtId=V8(e,z);break;case I:{V&&(z+=e[z]+1);const X=q8(e,z,this.typeSupported,i,this.observer,this.logger);f=X.videoPid,f>0&&(o.pid=f,o.segmentCodec=X.segmentVideoCodec),g=X.audioPid,g>0&&(u.pid=g,u.segmentCodec=X.segmentAudioCodec),v=X.id3Pid,v>0&&(c.pid=v),E!==null&&!w&&(this.logger.warn(`MPEG-TS PMT found at ${B} after unknown PID '${E}'. Backtracking to sync byte @${F} to parse all TS packets.`),E=null,B=F-188),w=this.pmtParsed=!0;break}case 17:case 8191:break;default:E=k;break}}else $++;$>0&&Zv(this.observer,new Error(`Found ${$} TS packet/s that do not start with 0x47`),void 0,this.logger),o.pesData=m,u.pesData=b,c.pesData=_;const G={audioTrack:u,videoTrack:o,id3Track:c,textTrack:d};return n&&this.extractRemainingSamples(G),G}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,o=i.pesData,u=t.pesData,c=n.pesData;let d;if(o&&(d=Cu(o,this.logger))?(this.readyVideoParser(i.segmentCodec),this.videoParser!==null&&(this.videoParser.parsePES(i,r,d,!0),i.pesData=null)):i.pesData=o,u&&(d=Cu(u,this.logger))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,d);break;case"mp3":this.parseMPEGPES(t,d);break;case"ac3":this.parseAC3PES(t,d);break}t.pesData=null}else u!=null&&u.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=u;c&&(d=Cu(c,this.logger))?(this.parseID3PES(n,d),n.pesData=null):n.pesData=c}demuxSampleAes(e,t,i){const n=this.demux(e,i,!0,!this.config.progressive),r=this.sampleAes=new j8(this.observer,this.config,t);return this.decrypt(n,r)}readyVideoParser(e){this.videoParser===null&&(e==="avc"?this.videoParser=new H8:e==="hevc"&&(this.videoParser=new G8))}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 m=n.missing,g=n.sample.unit.byteLength;if(m===-1)r=Fn(n.sample.unit,r);else{const v=g-m;n.sample.unit.set(r.subarray(0,m),v),e.samples.push(n.sample),i=n.missing}}let o,u;for(o=i,u=r.length;o<u-1&&!am(r,o);o++);if(o!==i){let m;const g=o<u-1;if(g?m=`AAC PES did not start with ADTS header,offset:${o}`:m="No ADTS header found in AAC PES",Zv(this.observer,new Error(m),g,this.logger),!g)return}eL(e,this.observer,r,o,this.audioCodec);let c;if(t.pts!==void 0)c=t.pts;else if(n){const m=tL(e.samplerate);c=n.sample.pts+m}else{this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}let d=0,f;for(;o<u;)if(f=iL(e,r,o,c,d),o+=f.length,f.missing){this.aacOverFlow=f;break}else for(d++;o<u-1&&!am(r,o);o++);}parseMPEGPES(e,t){const i=t.data,n=i.length;let r=0,o=0;const u=t.pts;if(u===void 0){this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;o<n;)if(oL(i,o)){const c=rL(e,i,o,u,r);if(c)o+=c.length,r++;else break}else o++}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 o=0,u=0,c;for(;u<r&&(c=cL(e,i,u,n,o++))>0;)u+=c}}parseID3PES(e,t){if(t.pts===void 0){this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const i=ni({},t,{type:this._videoTrack?_n.emsg:_n.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}}function Qv(s,e){return((s[e+1]&31)<<8)+s[e+2]}function V8(s,e){return(s[e+10]&31)<<8|s[e+11]}function q8(s,e,t,i,n,r){const o={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},u=(s[e+1]&15)<<8|s[e+2],c=e+3+u-4,d=(s[e+10]&15)<<8|s[e+11];for(e+=12+d;e<c;){const f=Qv(s,e),m=(s[e+3]&15)<<8|s[e+4];switch(s[e]){case 207:if(!i){Gy("ADTS AAC",r);break}case 15:o.audioPid===-1&&(o.audioPid=f);break;case 21:o.id3Pid===-1&&(o.id3Pid=f);break;case 219:if(!i){Gy("H.264",r);break}case 27:o.videoPid===-1&&(o.videoPid=f);break;case 3:case 4:!t.mpeg&&!t.mp3?r.log("MPEG audio found, not supported in this browser"):o.audioPid===-1&&(o.audioPid=f,o.segmentAudioCodec="mp3");break;case 193:if(!i){Gy("AC-3",r);break}case 129:t.ac3?o.audioPid===-1&&(o.audioPid=f,o.segmentAudioCodec="ac3"):r.log("AC-3 audio found, not supported in this browser");break;case 6:if(o.audioPid===-1&&m>0){let g=e+5,v=m;for(;v>2;){s[g]===106&&(t.ac3!==!0?r.log("AC-3 audio found, not supported in this browser for now"):(o.audioPid=f,o.segmentAudioCodec="ac3"));const _=s[g+1]+2;g+=_,v-=_}}break;case 194:case 135:return Zv(n,new Error("Unsupported EC-3 in M2TS found"),void 0,r),o;case 36:o.videoPid===-1&&(o.videoPid=f,o.segmentVideoCodec="hevc",r.log("HEVC in M2TS found"));break}e+=m+5}return o}function Zv(s,e,t,i){i.warn(`parsing error: ${e.message}`),s.emit(N.ERROR,N.ERROR,{type:nt.MEDIA_ERROR,details:ve.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:e,reason:e.message})}function Gy(s,e){e.log(`${s} with AES-128-CBC encryption found in unencrypted stream`)}function Cu(s,e){let t=0,i,n,r,o,u;const c=s.data;if(!s||s.size===0)return null;for(;c[0].length<19&&c.length>1;)c[0]=Fn(c[0],c[1]),c.splice(1,1);if(i=c[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 f=i[7];f&192&&(o=(i[9]&14)*536870912+(i[10]&255)*4194304+(i[11]&254)*16384+(i[12]&255)*128+(i[13]&254)/2,f&64?(u=(i[14]&14)*536870912+(i[15]&255)*4194304+(i[16]&254)*16384+(i[17]&255)*128+(i[18]&254)/2,o-u>60*9e4&&(e.warn(`${Math.round((o-u)/9e4)}s delta between PTS and DTS, align them`),o=u)):u=o),r=i[8];let m=r+9;if(s.size<=m)return null;s.size-=m;const g=new Uint8Array(s.size);for(let v=0,b=c.length;v<b;v++){i=c[v];let _=i.byteLength;if(m)if(m>_){m-=_;continue}else i=i.subarray(m),_-=m,m=0;g.set(i,t),t+=_}return n&&(n-=r+3),{data:g,pts:o,dts:u,len:n}}return null}class z8{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 co=Math.pow(2,32)-1;class ge{static init(){ge.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 ge.types)ge.types.hasOwnProperty(e)&&(ge.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]);ge.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 Uint8Array([0,0,0,0,0,0,0,0]);ge.STTS=ge.STSC=ge.STCO=r,ge.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),ge.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),ge.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),ge.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const o=new Uint8Array([105,115,111,109]),u=new Uint8Array([97,118,99,49]),c=new Uint8Array([0,0,0,1]);ge.FTYP=ge.box(ge.types.ftyp,o,c,o,u),ge.DINF=ge.box(ge.types.dinf,ge.box(ge.types.dref,n))}static box(e,...t){let i=8,n=t.length;const r=n;for(;n--;)i+=t[n].byteLength;const o=new Uint8Array(i);for(o[0]=i>>24&255,o[1]=i>>16&255,o[2]=i>>8&255,o[3]=i&255,o.set(e,4),n=0,i=8;n<r;n++)o.set(t[n],i),i+=t[n].byteLength;return o}static hdlr(e){return ge.box(ge.types.hdlr,ge.HDLR_TYPES[e])}static mdat(e){return ge.box(ge.types.mdat,e)}static mdhd(e,t){t*=e;const i=Math.floor(t/(co+1)),n=Math.floor(t%(co+1));return ge.box(ge.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 ge.box(ge.types.mdia,ge.mdhd(e.timescale||0,e.duration||0),ge.hdlr(e.type),ge.minf(e))}static mfhd(e){return ge.box(ge.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"?ge.box(ge.types.minf,ge.box(ge.types.smhd,ge.SMHD),ge.DINF,ge.stbl(e)):ge.box(ge.types.minf,ge.box(ge.types.vmhd,ge.VMHD),ge.DINF,ge.stbl(e))}static moof(e,t,i){return ge.box(ge.types.moof,ge.mfhd(e),ge.traf(i,t))}static moov(e){let t=e.length;const i=[];for(;t--;)i[t]=ge.trak(e[t]);return ge.box.apply(null,[ge.types.moov,ge.mvhd(e[0].timescale||0,e[0].duration||0)].concat(i).concat(ge.mvex(e)))}static mvex(e){let t=e.length;const i=[];for(;t--;)i[t]=ge.trex(e[t]);return ge.box.apply(null,[ge.types.mvex,...i])}static mvhd(e,t){t*=e;const i=Math.floor(t/(co+1)),n=Math.floor(t%(co+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 ge.box(ge.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 ge.box(ge.types.sdtp,i)}static stbl(e){return ge.box(ge.types.stbl,ge.stsd(e),ge.box(ge.types.stts,ge.STTS),ge.box(ge.types.stsc,ge.STSC),ge.box(ge.types.stsz,ge.STSZ),ge.box(ge.types.stco,ge.STCO))}static avc1(e){let t=[],i=[],n,r,o;for(n=0;n<e.sps.length;n++)r=e.sps[n],o=r.byteLength,t.push(o>>>8&255),t.push(o&255),t=t.concat(Array.prototype.slice.call(r));for(n=0;n<e.pps.length;n++)r=e.pps[n],o=r.byteLength,i.push(o>>>8&255),i.push(o&255),i=i.concat(Array.prototype.slice.call(r));const u=ge.box(ge.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(i))),c=e.width,d=e.height,f=e.pixelRatio[0],m=e.pixelRatio[1];return ge.box(ge.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,c>>8&255,c&255,d>>8&255,d&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]),u,ge.box(ge.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),ge.box(ge.types.pasp,new Uint8Array([f>>24,f>>16&255,f>>8&255,f&255,m>>24,m>>16&255,m>>8&255,m&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 ge.box(ge.types.mp4a,ge.audioStsd(e),ge.box(ge.types.esds,ge.esds(e)))}static mp3(e){return ge.box(ge.types[".mp3"],ge.audioStsd(e))}static ac3(e){return ge.box(ge.types["ac-3"],ge.audioStsd(e),ge.box(ge.types.dac3,e.config))}static stsd(e){const{segmentCodec:t}=e;if(e.type==="audio"){if(t==="aac")return ge.box(ge.types.stsd,ge.STSD,ge.mp4a(e));if(t==="ac3"&&e.config)return ge.box(ge.types.stsd,ge.STSD,ge.ac3(e));if(t==="mp3"&&e.codec==="mp3")return ge.box(ge.types.stsd,ge.STSD,ge.mp3(e))}else if(e.pps&&e.sps){if(t==="avc")return ge.box(ge.types.stsd,ge.STSD,ge.avc1(e));if(t==="hevc"&&e.vps)return ge.box(ge.types.stsd,ge.STSD,ge.hvc1(e))}else 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,o=Math.floor(i/(co+1)),u=Math.floor(i%(co+1));return ge.box(ge.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,o>>24,o>>16&255,o>>8&255,o&255,u>>24,u>>16&255,u>>8&255,u&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=ge.sdtp(e),n=e.id,r=Math.floor(t/(co+1)),o=Math.floor(t%(co+1));return ge.box(ge.types.traf,ge.box(ge.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255])),ge.box(ge.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,r&255,o>>24,o>>16&255,o>>8&255,o&255])),ge.trun(e,i.length+16+20+8+16+8+8),i)}static trak(e){return e.duration=e.duration||4294967295,ge.box(ge.types.trak,ge.tkhd(e),ge.mdia(e))}static trex(e){const t=e.id;return ge.box(ge.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,o=new Uint8Array(r);let u,c,d,f,m,g;for(t+=8+r,o.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),u=0;u<n;u++)c=i[u],d=c.duration,f=c.size,m=c.flags,g=c.cts,o.set([d>>>24&255,d>>>16&255,d>>>8&255,d&255,f>>>24&255,f>>>16&255,f>>>8&255,f&255,m.isLeading<<2|m.dependsOn,m.isDependedOn<<6|m.hasRedundancy<<4|m.paddingValue<<1|m.isNonSync,m.degradPrio&61440,m.degradPrio&15,g>>>24&255,g>>>16&255,g>>>8&255,g&255],12+16*u);return ge.box(ge.types.trun,o)}static initSegment(e){ge.types||ge.init();const t=ge.moov(e);return Fn(ge.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 o=r.length;for(let b=0;b<i.length;b+=1){o+=3;for(let _=0;_<i[b].length;_+=1)o+=2+i[b][_].length}const u=new Uint8Array(o);u.set(r,0),o=r.length;const c=i.length-1;for(let b=0;b<i.length;b+=1){u.set(new Uint8Array([32+b|(b===c?128:0),0,i[b].length]),o),o+=3;for(let _=0;_<i[b].length;_+=1)u.set(new Uint8Array([i[b][_].length>>8,i[b][_].length&255]),o),o+=2,u.set(i[b][_],o),o+=i[b][_].length}const d=ge.box(ge.types.hvcC,u),f=e.width,m=e.height,g=e.pixelRatio[0],v=e.pixelRatio[1];return ge.box(ge.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,f>>8&255,f&255,m>>8&255,m&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]),d,ge.box(ge.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),ge.box(ge.types.pasp,new Uint8Array([g>>24,g>>16&255,g>>8&255,g&255,v>>24,v>>16&255,v>>8&255,v&255])))}}ge.types=void 0;ge.HDLR_TYPES=void 0;ge.STTS=void 0;ge.STSC=void 0;ge.STCO=void 0;ge.STSZ=void 0;ge.VMHD=void 0;ge.SMHD=void 0;ge.STSD=void 0;ge.FTYP=void 0;ge.DINF=void 0;const hL=9e4;function mb(s,e,t=1,i=!1){const n=s*e*t;return i?Math.round(n):n}function K8(s,e,t=1,i=!1){return mb(s,e,1/t,i)}function Sd(s,e=!1){return mb(s,1e3,1/hL,e)}function Y8(s,e=1){return mb(s,hL,1/e)}function c2(s){const{baseTime:e,timescale:t,trackId:i}=s;return`${e/t} (${e}/${t}) trackId: ${i}`}const W8=10*1e3,X8=1024,Q8=1152,Z8=1536;let Du=null,Vy=null;function d2(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 xp extends jn{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,Du===null){const o=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Du=o?parseInt(o[1]):0}if(Vy===null){const r=navigator.userAgent.match(/Safari\/(\d+)/i);Vy=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&&c2(t)} > ${e&&c2(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,o)=>{let u=o.pts,c=u-r;return c<-4294967296&&(t=!0,u=bn(u,i),c=u-r),c>0?r:u},i);return t&&this.debug("PTS rollover detected"),n}remux(e,t,i,n,r,o,u,c){let d,f,m,g,v,b,_=r,E=r;const w=e.pid>-1,I=t.pid>-1,L=t.samples.length,F=e.samples.length>0,$=u&&L>0||L>1;if((!w||F)&&(!I||$)||this.ISGenerated||u){if(this.ISGenerated){var B,V,k,R;const le=this.videoTrackConfig;(le&&(t.width!==le.width||t.height!==le.height||((B=t.pixelRatio)==null?void 0:B[0])!==((V=le.pixelRatio)==null?void 0:V[0])||((k=t.pixelRatio)==null?void 0:k[1])!==((R=le.pixelRatio)==null?void 0:R[1]))||!le&&$||this.nextAudioTs===null&&F)&&this.resetInitSegment()}this.ISGenerated||(m=this.generateIS(e,t,r,o));const z=this.isVideoContiguous;let X=-1,ee;if($&&(X=J8(t.samples),!z&&this.config.forceKeyFrameOnDiscontinuity))if(b=!0,X>0){this.warn(`Dropped ${X} out of ${L} video samples due to a missing keyframe`);const le=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(X),t.dropped+=X,E+=(t.samples[0].pts-le)/t.inputTimeScale,ee=E}else X===-1&&(this.warn(`No keyframe found out of ${L} video samples`),b=!1);if(this.ISGenerated){if(F&&$){const le=this.getVideoStartPts(t.samples),Y=(bn(e.samples[0].pts,le)-le)/t.inputTimeScale;_+=Math.max(0,Y),E+=Math.max(0,-Y)}if(F){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),m=this.generateIS(e,t,r,o)),f=this.remuxAudio(e,_,this.isAudioContiguous,o,I||$||c===Je.AUDIO?E:void 0),$){const le=f?f.endPTS-f.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),m=this.generateIS(e,t,r,o)),d=this.remuxVideo(t,E,z,le)}}else $&&(d=this.remuxVideo(t,E,z,0));d&&(d.firstKeyFrame=X,d.independent=X!==-1,d.firstKeyFramePTS=ee)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(v=fL(i,r,this._initPTS,this._initDTS)),n.samples.length&&(g=pL(n,r,this._initPTS))),{audio:f,video:d,initSegment:m,independent:b,text:g,id3:v}}computeInitPts(e,t,i,n){const r=Math.round(i*t);let o=bn(e,r);if(o<r+t)for(this.log(`Adjusting PTS for rollover in timeline near ${(r-o)/t} ${n}`);o<r+t;)o+=8589934592;return o-r}generateIS(e,t,i,n){const r=e.samples,o=t.samples,u=this.typeSupported,c={},d=this._initPTS;let f=!d||n,m="audio/mp4",g,v,b,_=-1;if(f&&(g=v=1/0),e.config&&r.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":u.mpeg?(m="audio/mpeg",e.codec=""):u.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}c.audio={id:"audio",container:m,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&u.mpeg?new Uint8Array(0):ge.initSegment([e]),metadata:{channelCount:e.channelCount}},f&&(_=e.id,b=e.inputTimeScale,!d||b!==d.timescale?g=v=this.computeInitPts(r[0].pts,b,i,"audio"):f=!1)}if(t.sps&&t.pps&&o.length){if(t.timescale=t.inputTimeScale,c.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:ge.initSegment([t]),metadata:{width:t.width,height:t.height}},f)if(_=t.id,b=t.inputTimeScale,!d||b!==d.timescale){const E=this.getVideoStartPts(o),w=bn(o[0].dts,E),I=this.computeInitPts(w,b,i,"video"),L=this.computeInitPts(E,b,i,"video");v=Math.min(v,I),g=Math.min(g,L)}else f=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(c).length)return this.ISGenerated=!0,f?(d&&this.warn(`Timestamps at playlist time: ${n?"":"~"}${i} ${g/b} != initPTS: ${d.baseTime/d.timescale} (${d.baseTime}/${d.timescale}) trackId: ${d.trackId}`),this.log(`Found initPTS at playlist time: ${i} offset: ${g/b} (${g}/${b}) trackId: ${_}`),this._initPTS={baseTime:g,timescale:b,trackId:_},this._initDTS={baseTime:v,timescale:b,trackId:_}):g=b=void 0,{tracks:c,initPTS:g,timescale:b,trackId:_}}remuxVideo(e,t,i,n){const r=e.inputTimeScale,o=e.samples,u=[],c=o.length,d=this._initPTS,f=d.baseTime*r/d.timescale;let m=this.nextVideoTs,g=8,v=this.videoSampleDuration,b,_,E=Number.POSITIVE_INFINITY,w=Number.NEGATIVE_INFINITY,I=!1;if(!i||m===null){const U=f+t*r,ie=o[0].pts-bn(o[0].dts,o[0].pts);Du&&m!==null&&Math.abs(U-ie-(m+f))<15e3?i=!0:m=U-ie-f}const L=m+f;for(let U=0;U<c;U++){const ie=o[U];ie.pts=bn(ie.pts,L),ie.dts=bn(ie.dts,L),ie.dts<o[U>0?U-1:U].dts&&(I=!0)}I&&o.sort(function(U,ie){const fe=U.dts-ie.dts,xe=U.pts-ie.pts;return fe||xe}),b=o[0].dts,_=o[o.length-1].dts;const F=_-b,$=F?Math.round(F/(c-1)):v||e.inputTimeScale/30;if(i){const U=b-L,ie=U>$,fe=U<-1;if((ie||fe)&&(ie?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Sd(U,!0)} ms (${U}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Sd(-U,!0)} ms (${U}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!fe||L>=o[0].pts||Du)){b=L;const xe=o[0].pts-U;if(ie)o[0].dts=b,o[0].pts=xe;else{let Ae=!0;for(let $e=0;$e<o.length&&!(o[$e].dts>xe&&Ae);$e++){const Ee=o[$e].pts;if(o[$e].dts-=U,o[$e].pts-=U,$e<o.length-1){const je=o[$e+1].pts,qe=o[$e].pts,et=je<=qe,rt=je<=Ee;Ae=et==rt}}}this.log(`Video: Initial PTS/DTS adjusted: ${Sd(xe,!0)}/${Sd(b,!0)}, delta: ${Sd(U,!0)} ms`)}}b=Math.max(0,b);let G=0,B=0,V=b;for(let U=0;U<c;U++){const ie=o[U],fe=ie.units,xe=fe.length;let Ae=0;for(let $e=0;$e<xe;$e++)Ae+=fe[$e].data.length;B+=Ae,G+=xe,ie.length=Ae,ie.dts<V?(ie.dts=V,V+=$/4|0||1):V=ie.dts,E=Math.min(ie.pts,E),w=Math.max(ie.pts,w)}_=o[c-1].dts;const k=B+4*G+8;let R;try{R=new Uint8Array(k)}catch(U){this.observer.emit(N.ERROR,N.ERROR,{type:nt.MUX_ERROR,details:ve.REMUX_ALLOC_ERROR,fatal:!1,error:U,bytes:k,reason:`fail allocating video mdat ${k}`});return}const z=new DataView(R.buffer);z.setUint32(0,k),R.set(ge.types.mdat,4);let X=!1,ee=Number.POSITIVE_INFINITY,le=Number.POSITIVE_INFINITY,oe=Number.NEGATIVE_INFINITY,Y=Number.NEGATIVE_INFINITY;for(let U=0;U<c;U++){const ie=o[U],fe=ie.units;let xe=0;for(let Ee=0,je=fe.length;Ee<je;Ee++){const qe=fe[Ee],et=qe.data,rt=qe.data.byteLength;z.setUint32(g,rt),g+=4,R.set(et,g),g+=rt,xe+=4+rt}let Ae;if(U<c-1)v=o[U+1].dts-ie.dts,Ae=o[U+1].pts-ie.pts;else{const Ee=this.config,je=U>0?ie.dts-o[U-1].dts:$;if(Ae=U>0?ie.pts-o[U-1].pts:$,Ee.stretchShortVideoTrack&&this.nextAudioTs!==null){const qe=Math.floor(Ee.maxBufferHole*r),et=(n?E+n*r:this.nextAudioTs+f)-ie.pts;et>qe?(v=et-je,v<0?v=je:X=!0,this.log(`It is approximately ${et/90} ms to the next segment; using duration ${v/90} ms for the last video frame.`)):v=je}else v=je}const $e=Math.round(ie.pts-ie.dts);ee=Math.min(ee,v),oe=Math.max(oe,v),le=Math.min(le,Ae),Y=Math.max(Y,Ae),u.push(d2(ie.key,v,xe,$e))}if(u.length){if(Du){if(Du<70){const U=u[0].flags;U.dependsOn=2,U.isNonSync=0}}else if(Vy&&Y-le<oe-ee&&$/oe<.025&&u[0].cts===0){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let U=b;for(let ie=0,fe=u.length;ie<fe;ie++){const xe=U+u[ie].duration,Ae=U+u[ie].cts;if(ie<fe-1){const $e=xe+u[ie+1].cts;u[ie].duration=$e-Ae}else u[ie].duration=ie?u[ie-1].duration:$;u[ie].cts=0,U=xe}}}v=X||!v?$:v;const Z=_+v;this.nextVideoTs=m=Z-f,this.videoSampleDuration=v,this.isVideoContiguous=!0;const ue={data1:ge.moof(e.sequenceNumber++,b,ni(e,{samples:u})),data2:R,startPTS:(E-f)/r,endPTS:(w+v-f)/r,startDTS:(b-f)/r,endDTS:m/r,type:"video",hasAudio:!1,hasVideo:!0,nb:u.length,dropped:e.dropped};return e.samples=[],e.dropped=0,ue}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return Q8;case"ac3":return Z8;default:return X8}}remuxAudio(e,t,i,n,r){const o=e.inputTimeScale,u=e.samplerate?e.samplerate:o,c=o/u,d=this.getSamplesPerFrame(e),f=d*c,m=this._initPTS,g=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,v=[],b=r!==void 0;let _=e.samples,E=g?0:8,w=this.nextAudioTs||-1;const I=m.baseTime*o/m.timescale,L=I+t*o;if(this.isAudioContiguous=i=i||_.length&&w>0&&(n&&Math.abs(L-(w+I))<9e3||Math.abs(bn(_[0].pts,L)-(w+I))<20*f),_.forEach(function(Y){Y.pts=bn(Y.pts,L)}),!i||w<0){const Y=_.length;if(_=_.filter(Z=>Z.pts>=0),Y!==_.length&&this.warn(`Removed ${_.length-Y} of ${Y} samples (initPTS ${I} / ${o})`),!_.length)return;r===0?w=0:n&&!b?w=Math.max(0,L-I):w=_[0].pts-I}if(e.segmentCodec==="aac"){const Y=this.config.maxAudioFramesDrift;for(let Z=0,Q=w+I;Z<_.length;Z++){const ae=_[Z],ue=ae.pts,U=ue-Q,ie=Math.abs(1e3*U/o);if(U<=-Y*f&&b)Z===0&&(this.warn(`Audio frame @ ${(ue/o).toFixed(3)}s overlaps marker by ${Math.round(1e3*U/o)} ms.`),this.nextAudioTs=w=ue-I,Q=ue);else if(U>=Y*f&&ie<W8&&b){let fe=Math.round(U/f);for(Q=ue-fe*f;Q<0&&fe&&f;)fe--,Q+=f;Z===0&&(this.nextAudioTs=w=Q-I),this.warn(`Injecting ${fe} audio frames @ ${((Q-I)/o).toFixed(3)}s due to ${Math.round(1e3*U/o)} ms gap.`);for(let xe=0;xe<fe;xe++){let Ae=z8.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);Ae||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),Ae=ae.unit.subarray()),_.splice(Z,0,{unit:Ae,pts:Q}),Q+=f,Z++}}ae.pts=Q,Q+=f}}let F=null,$=null,G,B=0,V=_.length;for(;V--;)B+=_[V].unit.byteLength;for(let Y=0,Z=_.length;Y<Z;Y++){const Q=_[Y],ae=Q.unit;let ue=Q.pts;if($!==null){const ie=v[Y-1];ie.duration=Math.round((ue-$)/c)}else if(i&&e.segmentCodec==="aac"&&(ue=w+I),F=ue,B>0){B+=E;try{G=new Uint8Array(B)}catch(ie){this.observer.emit(N.ERROR,N.ERROR,{type:nt.MUX_ERROR,details:ve.REMUX_ALLOC_ERROR,fatal:!1,error:ie,bytes:B,reason:`fail allocating audio mdat ${B}`});return}g||(new DataView(G.buffer).setUint32(0,B),G.set(ge.types.mdat,4))}else return;G.set(ae,E);const U=ae.byteLength;E+=U,v.push(d2(!0,d,U,0)),$=ue}const k=v.length;if(!k)return;const R=v[v.length-1];w=$-I,this.nextAudioTs=w+c*R.duration;const z=g?new Uint8Array(0):ge.moof(e.sequenceNumber++,F/c,ni({},e,{samples:v}));e.samples=[];const X=(F-I)/o,ee=this.nextAudioTs/o,oe={data1:z,data2:G,startPTS:X,endPTS:ee,startDTS:X,endDTS:ee,type:"audio",hasAudio:!0,hasVideo:!1,nb:k};return this.isAudioContiguous=!0,oe}}function bn(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 J8(s){for(let e=0;e<s.length;e++)if(s[e].key)return e;return-1}function fL(s,e,t,i){const n=s.samples.length;if(!n)return;const r=s.inputTimeScale;for(let u=0;u<n;u++){const c=s.samples[u];c.pts=bn(c.pts-t.baseTime*r/t.timescale,e*r)/r,c.dts=bn(c.dts-i.baseTime*r/i.timescale,e*r)/r}const o=s.samples;return s.samples=[],{samples:o}}function pL(s,e,t){const i=s.samples.length;if(!i)return;const n=s.inputTimeScale;for(let o=0;o<i;o++){const u=s.samples[o];u.pts=bn(u.pts-t.baseTime*n/t.timescale,e*n)/n}s.samples.sort((o,u)=>o.pts-u.pts);const r=s.samples;return s.samples=[],{samples:r}}class eU extends jn{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:o}=this.initData=bw(e);if(t)jB(e,t);else{const c=r||o;c!=null&&c.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${c.codec}")!`)}r&&(i=h2(r,oi.AUDIO,this)),o&&(n=h2(o,oi.VIDEO,this));const u={};r&&o?u.audiovideo={container:"video/mp4",codec:i+","+n,supplemental:o.supplemental,encrypted:o.encrypted,initSegment:e,id:"main"}:r?u.audio={container:"audio/mp4",codec:i,encrypted:r.encrypted,initSegment:e,id:"audio"}:o?u.video={container:"video/mp4",codec:n,supplemental:o.supplemental,encrypted:o.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=u}remux(e,t,i,n,r,o){var u,c;let{initPTS:d,lastEndTime:f}=this;const m={audio:void 0,video:void 0,text:n,id3:i,initSegment:void 0};We(f)||(f=this.lastEndTime=r||0);const g=t.samples;if(!g.length)return m;const v={initPTS:void 0,timescale:void 0,trackId:void 0};let b=this.initData;if((u=b)!=null&&u.length||(this.generateInitSegment(g),b=this.initData),!((c=b)!=null&&c.length))return this.warn("Failed to generate initSegment."),m;this.emitInitSegment&&(v.tracks=this.initTracks,this.emitInitSegment=!1);const _=GB(g,b,this),E=b.audio?_[b.audio.id]:null,w=b.video?_[b.video.id]:null,I=sp(w,1/0),L=sp(E,1/0),F=sp(w,0,!0),$=sp(E,0,!0);let G=r,B=0;const V=E&&(!w||!d&&L<I||d&&d.trackId===b.audio.id),k=V?E:w;if(k){const Q=k.timescale,ae=k.start-r*Q,ue=V?b.audio.id:b.video.id;G=k.start/Q,B=V?$-L:F-I,(o||!d)&&(tU(d,G,r,B)||Q!==d.timescale)&&(d&&this.warn(`Timestamps at playlist time: ${o?"":"~"}${r} ${ae/Q} != initPTS: ${d.baseTime/d.timescale} (${d.baseTime}/${d.timescale}) trackId: ${d.trackId}`),this.log(`Found initPTS at playlist time: ${r} offset: ${G-r} (${ae}/${Q}) trackId: ${ue}`),d=null,v.initPTS=ae,v.timescale=Q,v.trackId=ue)}else this.warn(`No audio or video samples found for initPTS at playlist time: ${r}`);d?(v.initPTS=d.baseTime,v.timescale=d.timescale,v.trackId=d.trackId):((!v.timescale||v.trackId===void 0||v.initPTS===void 0)&&(this.warn("Could not set initPTS"),v.initPTS=G,v.timescale=1,v.trackId=-1),this.initPTS=d={baseTime:v.initPTS,timescale:v.timescale,trackId:v.trackId});const R=G-d.baseTime/d.timescale,z=R+B;B>0?this.lastEndTime=z:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const X=!!b.audio,ee=!!b.video;let le="";X&&(le+="audio"),ee&&(le+="video");const oe=(b.audio?b.audio.encrypted:!1)||(b.video?b.video.encrypted:!1),Y={data1:g,startPTS:R,startDTS:R,endPTS:z,endDTS:z,type:le,hasAudio:X,hasVideo:ee,nb:1,dropped:0,encrypted:oe};m.audio=X&&!ee?Y:void 0,m.video=ee?Y:void 0;const Z=w?.sampleCount;if(Z){const Q=w.keyFrameIndex,ae=Q!==-1;Y.nb=Z,Y.dropped=Q===0||this.isVideoContiguous?0:ae?Q:Z,Y.independent=ae,Y.firstKeyFrame=Q,ae&&w.keyFrameStart&&(Y.firstKeyFramePTS=(w.keyFrameStart-d.baseTime)/d.timescale),this.isVideoContiguous||(m.independent=ae),this.isVideoContiguous||(this.isVideoContiguous=ae),Y.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${Q}/${Z} dropped: ${Y.dropped} start: ${Y.firstKeyFramePTS||"NA"}`)}return m.initSegment=v,m.id3=fL(i,r,d,d),n.samples.length&&(m.text=pL(n,r,d)),m}}function sp(s,e,t=!1){return s?.start!==void 0?(s.start+(t?s.duration:0))/s.timescale:e}function tU(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 h2(s,e,t){const i=s.codec;return i&&i.length>4?i:e===oi.AUDIO?i==="ec-3"||i==="ac-3"||i==="alac"?i:i==="fLaC"||i==="Opus"?Zp(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 fa;try{fa=self.performance.now.bind(self.performance)}catch{fa=Date.now}const Sp=[{demux:$8,remux:eU},{demux:go,remux:xp},{demux:N8,remux:xp},{demux:F8,remux:xp}];Sp.splice(2,0,{demux:B8,remux:xp});class f2{constructor(e,t,i,n,r,o){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=o}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,i,n){const r=i.transmuxing;r.executeStart=fa();let o=new Uint8Array(e);const{currentTransmuxState:u,transmuxConfig:c}=this;n&&(this.currentTransmuxState=n);const{contiguous:d,discontinuity:f,trackSwitch:m,accurateTimeOffset:g,timeOffset:v,initSegmentChange:b}=n||u,{audioCodec:_,videoCodec:E,defaultInitPts:w,duration:I,initSegmentData:L}=c,F=iU(o,t);if(F&&zu(F.method)){const V=this.getDecrypter(),k=ab(F.method);if(V.isSync()){let R=V.softwareDecrypt(o,F.key.buffer,F.iv.buffer,k);if(i.part>-1){const X=V.flush();R=X&&X.buffer}if(!R)return r.executeEnd=fa(),qy(i);o=new Uint8Array(R)}else return this.asyncResult=!0,this.decryptionPromise=V.webCryptoDecrypt(o,F.key.buffer,F.iv.buffer,k).then(R=>{const z=this.push(R,null,i);return this.decryptionPromise=null,z}),this.decryptionPromise}const $=this.needsProbing(f,m);if($){const V=this.configureTransmuxer(o);if(V)return this.logger.warn(`[transmuxer] ${V.message}`),this.observer.emit(N.ERROR,N.ERROR,{type:nt.MEDIA_ERROR,details:ve.FRAG_PARSING_ERROR,fatal:!1,error:V,reason:V.message}),r.executeEnd=fa(),qy(i)}(f||m||b||$)&&this.resetInitSegment(L,_,E,I,t),(f||b||$)&&this.resetInitialTimestamp(w),d||this.resetContiguity();const G=this.transmux(o,F,v,g,i);this.asyncResult=eh(G);const B=this.currentTransmuxState;return B.contiguous=!0,B.discontinuity=!1,B.trackSwitch=!1,r.executeEnd=fa(),G}flush(e){const t=e.transmuxing;t.executeStart=fa();const{decrypter:i,currentTransmuxState:n,decryptionPromise:r}=this;if(r)return this.asyncResult=!0,r.then(()=>this.flush(e));const o=[],{timeOffset:u}=n;if(i){const m=i.flush();m&&o.push(this.push(m.buffer,null,e))}const{demuxer:c,remuxer:d}=this;if(!c||!d){t.executeEnd=fa();const m=[qy(e)];return this.asyncResult?Promise.resolve(m):m}const f=c.flush(u);return eh(f)?(this.asyncResult=!0,f.then(m=>(this.flushRemux(o,m,e),o))):(this.flushRemux(o,f,e),this.asyncResult?Promise.resolve(o):o)}flushRemux(e,t,i){const{audioTrack:n,videoTrack:r,id3Track:o,textTrack:u}=t,{accurateTimeOffset:c,timeOffset:d}=this.currentTransmuxState;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${i.sn}${i.part>-1?" part: "+i.part:""} of ${this.id===Je.MAIN?"level":"track"} ${i.level}`);const f=this.remuxer.remux(n,r,o,u,d,c,!0,this.id);e.push({remuxResult:f,chunkMeta:i}),i.transmuxing.executeEnd=fa()}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:o,remuxer:u}=this;!o||!u||(o.resetInitSegment(e,t,i,n),u.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 o;return t&&t.method==="SAMPLE-AES"?o=this.transmuxSampleAes(e,t,i,n,r):o=this.transmuxUnencrypted(e,i,n,r),o}transmuxUnencrypted(e,t,i,n){const{audioTrack:r,videoTrack:o,id3Track:u,textTrack:c}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(r,o,u,c,t,i,!1,this.id),chunkMeta:n}}transmuxSampleAes(e,t,i,n,r){return this.demuxer.demuxSampleAes(e,t,i).then(o=>({remuxResult:this.remuxer.remux(o.audioTrack,o.videoTrack,o.id3Track,o.textTrack,i,n,!1,this.id),chunkMeta:r}))}configureTransmuxer(e){const{config:t,observer:i,typeSupported:n}=this;let r;for(let m=0,g=Sp.length;m<g;m++){var o;if((o=Sp[m].demux)!=null&&o.probe(e,this.logger)){r=Sp[m];break}}if(!r)return new Error("Failed to find demuxer by probing fragment data");const u=this.demuxer,c=this.remuxer,d=r.remux,f=r.demux;(!c||!(c instanceof d))&&(this.remuxer=new d(i,t,n,this.logger)),(!u||!(u instanceof f))&&(this.demuxer=new f(i,t,n,this.logger),this.probe=f.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new nb(this.config)),e}}function iU(s,e){let t=null;return s.byteLength>0&&e?.key!=null&&e.iv!==null&&e.method!=null&&(t=e),t}const qy=s=>({remuxResult:{},chunkMeta:s});function eh(s){return"then"in s&&s.then instanceof Function}class sU{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 nU{constructor(e,t,i,n,r,o){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=o}}let p2=0;class mL{constructor(e,t,i,n){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=p2++,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=c=>{const d=c.data,f=this.hls;if(!(!f||!(d!=null&&d.event)||d.instanceNo!==this.instanceNo))switch(d.event){case"init":{var m;const g=(m=this.workerContext)==null?void 0:m.objectURL;g&&self.URL.revokeObjectURL(g);break}case"transmuxComplete":{this.handleTransmuxComplete(d.data);break}case"flush":{this.onFlush(d.data);break}case"workerLog":{f.logger[d.data.logType]&&f.logger[d.data.logType](d.data.message);break}default:{d.data=d.data||{},d.data.frag=this.frag,d.data.part=this.part,d.data.id=this.id,f.trigger(d.event,d.data);break}}},this.onWorkerError=c=>{if(!this.hls)return;const d=new Error(`${c.message} (${c.filename}:${c.lineno})`);this.hls.config.enableWorker=!1,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(N.ERROR,{type:nt.OTHER_ERROR,details:ve.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:d})};const r=e.config;this.hls=e,this.id=t,this.useWorker=!!r.enableWorker,this.onTransmuxComplete=i,this.onFlush=n;const o=(c,d)=>{d=d||{},d.frag=this.frag||void 0,c===N.ERROR&&(d=d,d.parent=this.id,d.part=this.part,this.error=d.error),this.hls.trigger(c,d)};this.observer=new ub,this.observer.on(N.FRAG_DECRYPTED,o),this.observer.on(N.ERROR,o);const u=L1(r.preferManagedMediaSource);if(this.useWorker&&typeof Worker<"u"){const c=this.hls.logger;if(r.workerPath||l8()){try{r.workerPath?(c.log(`loading Web Worker ${r.workerPath} for "${t}"`),this.workerContext=c8(r.workerPath)):(c.log(`injecting Web Worker for "${t}"`),this.workerContext=u8());const{worker:f}=this.workerContext;f.addEventListener("message",this.onWorkerMessage),f.addEventListener("error",this.onWorkerError),f.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:u,id:t,config:ui(r)})}catch(f){c.warn(`Error setting up "${t}" Web Worker, fallback to inline`,f),this.terminateWorker(),this.error=null,this.transmuxer=new f2(this.observer,u,r,"",t,e.logger)}return}}this.transmuxer=new f2(this.observer,u,r,"",t,e.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){const e=this.instanceNo;this.instanceNo=p2++;const t=this.hls.config,i=L1(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:i,id:this.id,config:ui(t)})}}terminateWorker(){if(this.workerContext){const{worker:e}=this.workerContext;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),d8(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,o,u,c,d,f){var m,g;d.transmuxing.start=self.performance.now();const{instanceNo:v,transmuxer:b}=this,_=o?o.start:r.start,E=r.decryptdata,w=this.frag,I=!(w&&r.cc===w.cc),L=!(w&&d.level===w.level),F=w?d.sn-w.sn:-1,$=this.part?d.part-this.part.index:-1,G=F===0&&d.id>1&&d.id===w?.stats.chunkCount,B=!L&&(F===1||F===0&&($===1||G&&$<=0)),V=self.performance.now();(L||F||r.stats.parsing.start===0)&&(r.stats.parsing.start=V),o&&($||!B)&&(o.stats.parsing.start=V);const k=!(w&&((m=r.initSegment)==null?void 0:m.url)===((g=w.initSegment)==null?void 0:g.url)),R=new nU(I,B,c,L,_,k);if(!B||I||k){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${r.type} sn: ${d.sn}${d.part>-1?" part: "+d.part:""} ${this.id===Je.MAIN?"level":"track"}: ${d.level} id: ${d.id}
discontinuity: ${I}
trackSwitch: ${L}
contiguous: ${B}
accurateTimeOffset: ${c}
timeOffset: ${_}
initSegmentChange: ${k}`);const z=new sU(i,n,t,u,f);this.configureTransmuxer(z)}if(this.frag=r,this.part=o,this.workerContext)this.workerContext.worker.postMessage({instanceNo:v,cmd:"demux",data:e,decryptdata:E,chunkMeta:d,state:R},e instanceof ArrayBuffer?[e]:[]);else if(b){const z=b.push(e,E,d,R);eh(z)?z.then(X=>{this.handleTransmuxComplete(X)}).catch(X=>{this.transmuxerError(X,d,"transmuxer-interface push error")}):this.handleTransmuxComplete(z)}}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);eh(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(N.ERROR,{type:nt.MEDIA_ERROR,details:ve.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 m2=100;class rU extends lb{constructor(e,t,i){super(e,t,i,"audio-stream-controller",Je.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(N.LEVEL_LOADED,this.onLevelLoaded,this),e.on(N.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(N.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(N.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(N.BUFFER_RESET,this.onBufferReset,this),e.on(N.BUFFER_CREATED,this.onBufferCreated,this),e.on(N.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(N.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(N.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(N.FRAG_LOADING,this.onFragLoading,this),e.on(N.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){const{hls:e}=this;e&&(super.unregisterListeners(),e.off(N.LEVEL_LOADED,this.onLevelLoaded,this),e.off(N.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(N.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(N.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(N.BUFFER_RESET,this.onBufferReset,this),e.off(N.BUFFER_CREATED,this.onBufferCreated,this),e.off(N.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(N.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(N.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(N.FRAG_LOADING,this.onFragLoading,this),e.off(N.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(e,{frag:t,id:i,initPTS:n,timescale:r,trackId:o}){if(i===Je.MAIN){const u=t.cc,c=this.fragCurrent;if(this.initPTS[u]={baseTime:n,timescale:r,trackId:o},this.log(`InitPTS for cc: ${u} found from main: ${n/r} (${n}/${r}) trackId: ${o}`),this.mainAnchor=t,this.state===Pe.WAITING_INIT_PTS){const d=this.waitingData;(!d&&!this.loadingParts||d&&d.frag.cc!==u)&&this.syncWithAnchor(t,d?.frag)}else!this.hls.hasEnoughToStart&&c&&c.cc!==u?(c.abortRequests(),this.syncWithAnchor(t,c)):this.state===Pe.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,o=this.getLevelDetails(),u=this.getLoadPosition(),c=kw(o,r,u);c&&(this.log(`Syncing with main frag at ${c.start} cc ${c.cc}`),this.startFragRequested=!1,this.nextLoadPosition=c.start,this.resetLoadingState(),this.state===Pe.IDLE&&this.doTickIdle())}startLoad(e,t){if(!this.levels){this.startPosition=e,this.state=Pe.STOPPED;return}const i=this.lastCurrentTime;this.stopLoad(),this.setInterval(m2),i>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i,this.state=Pe.IDLE):this.state=Pe.WAITING_TRACK,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}doTick(){switch(this.state){case Pe.IDLE:this.doTickIdle();break;case Pe.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=Pe.WAITING_INIT_PTS}break}case Pe.FRAG_LOADING_WAITING_RETRY:{this.checkRetryDate();break}case Pe.WAITING_INIT_PTS:{const e=this.waitingData;if(e){const{frag:t,part:i,cache:n,complete:r}=e,o=this.mainAnchor;if(this.initPTS[t.cc]!==void 0){this.waitingData=null,this.state=Pe.FRAG_LOADING;const u=n.flush().buffer,c={frag:t,part:i,payload:u,networkDetails:null};this._handleFragmentLoadProgress(c),r&&super._handleFragmentLoadComplete(c)}else o&&o.cc!==e.frag.cc&&this.syncWithAnchor(o,e.frag)}else this.state=Pe.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,o=t.config;if(!this.buffering||!n&&!this.primaryPrefetch&&(this.startFragRequested||!o.startFragPrefetch)||!(i!=null&&i[r]))return;const u=i[r],c=u.details;if(!c||this.waitForLive(u)||this.waitForCdnTuneIn(c)){this.state=Pe.WAITING_TRACK,this.startFragRequested=!1;return}const d=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&d&&(this.bufferFlushed=!1,this.afterBufferFlushed(d,oi.AUDIO,Je.AUDIO));const f=this.getFwdBufferInfo(d,Je.AUDIO);if(f===null)return;if(!this.switchingTrack&&this._streamEnded(f,c)){t.trigger(N.BUFFER_EOS,{type:"audio"}),this.state=Pe.ENDED;return}const m=f.len,g=t.maxBufferLength,v=c.fragments,b=v[0].start,_=this.getLoadPosition(),E=this.flushing?_:f.end;if(this.switchingTrack&&n){const L=_;c.PTSKnown&&L<b&&(f.end>b||f.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),n.currentTime=b+.05)}if(m>=g&&!this.switchingTrack&&E<v[v.length-1].start)return;let w=this.getNextFragment(E,c);if(w&&this.isLoopLoading(w,E)&&(w=this.getNextFragmentLoopLoading(w,c,f,Je.MAIN,g)),!w){this.bufferFlushed=!0;return}let I=((e=this.mainFragLoading)==null?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&I&&ji(w)&&!w.endList&&(!c.live||!this.loadingParts&&E<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(I)===Ji.OK&&(this.mainFragLoading=I=null),I&&ji(I))){if(w.start>I.end){const F=this.fragmentTracker.getFragAtPos(E,Je.MAIN);F&&F.end>I.end&&(I=F,this.mainFragLoading={frag:F,targetBufferTime:null})}if(w.start>I.end)return}this.loadFragment(w,u,E)}onMediaDetaching(e,t){this.bufferFlushed=this.flushing=!1,super.onMediaDetaching(e,t)}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(i=>new Qd(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!==Pe.STOPPED&&(this.setInterval(m2),this.state=Pe.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(N.AUDIO_TRACK_LOADED,i))}onAudioTrackLoaded(e,t){var i;const{levels:n}=this,{details:r,id:o,groupId:u,track:c}=t;if(!n){this.warn(`Audio tracks reset while loading track ${o} "${c.name}" of "${u}"`);return}const d=this.mainDetails;if(!d||r.endCC>d.endCC||d.expired){this.cachedTrackLoadedData=t,this.state!==Pe.STOPPED&&(this.state=Pe.WAITING_TRACK);return}this.cachedTrackLoadedData=null,this.log(`Audio track ${o} "${c.name}" of "${u}" loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""},duration:${r.totalduration}`);const f=n[o];let m=0;if(r.live||(i=f.details)!=null&&i.live){if(this.checkLiveUpdate(r),r.deltaUpdateFailed)return;if(f.details){var g;m=this.alignPlaylists(r,f.details,(g=this.levelLastLoaded)==null?void 0:g.details)}r.alignedSliding||(Ww(r,d),r.alignedSliding||rm(r,d),m=r.fragmentStart)}f.details=r,this.levelLastLoaded=f,this.startFragRequested||this.setStartPosition(d,m),this.hls.trigger(N.AUDIO_TRACK_UPDATED,{details:r,id:o,groupId:t.groupId}),this.state===Pe.WAITING_TRACK&&!this.waitForCdnTuneIn(r)&&(this.state=Pe.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;const i=e.frag,{part:n,payload:r}=e,{config:o,trackId:u,levels:c}=this;if(!c){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 d=c[u];if(!d){this.warn("Audio track is undefined on fragment load progress");return}const f=d.details;if(!f){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start);return}const m=o.defaultAudioCodec||d.audioCodec||"mp4a.40.2";let g=this.transmuxer;g||(g=this.transmuxer=new mL(this.hls,Je.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const v=this.initPTS[i.cc],b=(t=i.initSegment)==null?void 0:t.data;if(v!==void 0){const E=n?n.index:-1,w=E!==-1,I=new rb(i.level,i.sn,i.stats.chunkCount,r.byteLength,E,w);g.push(r,b,m,"",i,n,f.totalduration,!1,I,v)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${f.startSN} ,${f.endSN}],track ${u}`);const{cache:_}=this.waitingData=this.waitingData||{frag:i,part:n,cache:new Xw,complete:!1};_.push(new Uint8Array(r)),this.state!==Pe.STOPPED&&(this.state=Pe.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===Je.MAIN&&ji(t.frag)&&(this.mainFragLoading=t,this.state===Pe.IDLE&&this.tick())}onFragBuffered(e,t){const{frag:i,part:n}=t;if(i.type!==Je.AUDIO){!this.audioOnly&&i.type===Je.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(ji(i)){this.fragPrevious=i;const r=this.switchingTrack;r&&(this.bufferedTrack=r,this.switchingTrack=null,this.hls.trigger(N.AUDIO_TRACK_SWITCHED,Qt({},r)))}this.fragBufferedComplete(i,n),this.media&&this.tick()}onError(e,t){var i;if(t.fatal){this.state=Pe.ERROR;return}switch(t.details){case ve.FRAG_GAP:case ve.FRAG_PARSING_ERROR:case ve.FRAG_DECRYPT_ERROR:case ve.FRAG_LOAD_ERROR:case ve.FRAG_LOAD_TIMEOUT:case ve.KEY_LOAD_ERROR:case ve.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Je.AUDIO,t);break;case ve.AUDIO_TRACK_LOAD_ERROR:case ve.AUDIO_TRACK_LOAD_TIMEOUT:case ve.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===Pe.WAITING_TRACK&&((i=t.context)==null?void 0:i.type)===It.AUDIO_TRACK&&(this.state=Pe.IDLE);break;case ve.BUFFER_ADD_CODEC_ERROR:case ve.BUFFER_APPEND_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case ve.BUFFER_FULL_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case ve.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==oi.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==oi.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===Pe.ENDED&&(this.state=Pe.IDLE);const i=this.mediaBuffer||this.media;i&&(this.afterBufferFlushed(i,t,Je.AUDIO),this.tick())}}_handleTransmuxComplete(e){var t;const i="audio",{hls:n}=this,{remuxResult:r,chunkMeta:o}=e,u=this.getCurrentContext(o);if(!u){this.resetWhenMissingContext(o);return}const{frag:c,part:d,level:f}=u,{details:m}=f,{audio:g,text:v,id3:b,initSegment:_}=r;if(this.fragContextChanged(c)||!m){this.fragmentTracker.removeFragment(c);return}if(this.state=Pe.PARSING,this.switchingTrack&&g&&this.completeAudioSwitch(this.switchingTrack),_!=null&&_.tracks){const E=c.initSegment||c;if(this.unhandledEncryptionError(_,c))return;this._bufferInitSegment(f,_.tracks,E,o),n.trigger(N.FRAG_PARSING_INIT_SEGMENT,{frag:E,id:i,tracks:_.tracks})}if(g){const{startPTS:E,endPTS:w,startDTS:I,endDTS:L}=g;d&&(d.elementaryStreams[oi.AUDIO]={startPTS:E,endPTS:w,startDTS:I,endDTS:L}),c.setElementaryStreamInfo(oi.AUDIO,E,w,I,L),this.bufferFragmentData(g,c,d,o)}if(b!=null&&(t=b.samples)!=null&&t.length){const E=ni({id:i,frag:c,details:m},b);n.trigger(N.FRAG_PARSING_METADATA,E)}if(v){const E=ni({id:i,frag:c,details:m},v);n.trigger(N.FRAG_PARSING_USERDATA,E)}}_bufferInitSegment(e,t,i,n){if(this.state!==Pe.PARSING||(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio))return;const r=t.audio;r.id=Je.AUDIO;const o=e.audioCodec;this.log(`Init audio buffer, container:${r.container}, codecs[level/parsed]=[${o}/${r.codec}]`),o&&o.split(",").length===1&&(r.levelCodec=o),this.hls.trigger(N.BUFFER_CODECS,t);const u=r.initSegment;if(u!=null&&u.byteLength){const c={type:"audio",frag:i,part:null,chunkMeta:n,parent:i.type,data:u};this.hls.trigger(N.BUFFER_APPENDING,c)}this.tickImmediate()}loadFragment(e,t,i){const n=this.fragmentTracker.getState(e);if(this.switchingTrack||n===Ji.NOT_LOADED||n===Ji.PARTIAL){var r;if(!ji(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=Pe.WAITING_INIT_PTS;const o=this.mainDetails;o&&o.fragmentStart!==t.details.fragmentStart&&rm(t.details,o)}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:o,channels:u}=this.bufferedTrack;xl({name:t,lang:i,assocLang:n,characteristics:r,audioCodec:o,channels:u},e,dl)||(em(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(N.AUDIO_TRACK_SWITCHED,Qt({},e))}}class gb extends jn{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 o=0;o<n.length;o++){const u=n[o];let c;try{c=new self.URL(u.URI,t.url).href}catch(d){this.warn(`Could not construct new URL for Rendition Report: ${d}`),c=u.URI||""}if(c===e){r=o;break}else c===e.substring(0,c.length)&&(r=o)}if(r!==-1){const o=n[r],u=parseInt(o["LAST-MSN"])||t.lastPartSn;let c=parseInt(o["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){const f=Math.min(t.age-t.partTarget,t.targetduration);c>=0&&f>t.partTarget&&(c+=1)}const d=i&&I1(i);return new k1(u,c>=0?c:void 0,d)}}}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,o=self.performance.now(),u=r.loading.first?Math.max(0,o-r.loading.first):0;n.advancedDateTime=Date.now()-u;const c=this.hls.config.timelineOffset;if(c!==n.appliedTimelineOffset){const f=Math.max(c||0,0);n.appliedTimelineOffset=f,n.fragments.forEach(m=>{m.setStart(m.playlistOffset+f)})}if(n.live||i!=null&&i.live){const f="levelInfo"in t?t.levelInfo:t.track;if(n.reloaded(i),i&&n.fragments.length>0){QF(i,n,this);const I=n.playlistParsingError;if(I){this.warn(I);const L=this.hls;if(!L.config.ignorePlaylistParsingErrors){var d;const{networkDetails:F}=t;L.trigger(N.ERROR,{type:nt.NETWORK_ERROR,details:ve.LEVEL_PARSING_ERROR,fatal:!1,url:n.url,error:I,reason:I.message,level:t.level||void 0,parent:(d=n.fragments[0])==null?void 0:d.type,networkDetails:F,stats:r});return}n.playlistParsingError=null}}n.requestScheduled===-1&&(n.requestScheduled=r.loading.start);const m=this.hls.mainForwardBufferInfo,g=m?m.end-m.len:0,v=(n.edge-g)*1e3,b=Vw(n,v);if(n.requestScheduled+b<o?n.requestScheduled=o:n.requestScheduled+=b,this.log(`live playlist ${e} ${n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED"}`),!this.canLoad||!n.live)return;let _,E,w;if(n.canBlockReload&&n.endSN&&n.advanced){const I=this.hls.config.lowLatencyMode,L=n.lastPartSn,F=n.endSN,$=n.lastPartIndex,G=$!==-1,B=L===F;G?B?(E=F+1,w=I?0:$):(E=L,w=I?$+1:n.maxPartIndex):E=F+1;const V=n.age,k=V+n.ageHeader;let R=Math.min(k-n.partTarget,n.targetduration*1.5);if(R>0){if(k>n.targetduration*3)this.log(`Playlist last advanced ${V.toFixed(2)}s ago. Omitting segment and part directives.`),E=void 0,w=void 0;else if(i!=null&&i.tuneInGoal&&k-n.partTarget>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${R} with playlist age: ${n.age}`),R=0;else{const z=Math.floor(R/n.targetduration);if(E+=z,w!==void 0){const X=Math.round(R%n.targetduration/n.partTarget);w+=X}this.log(`CDN Tune-in age: ${n.ageHeader}s last advanced ${V.toFixed(2)}s goal: ${R} skip sn ${z} to part ${w}`)}n.tuneInGoal=R}if(_=this.getDeliveryDirectives(n,t.deliveryDirectives,E,w),I||!B){n.requestScheduled=o,this.loadingPlaylist(f,_);return}}else(n.canBlockReload||n.canSkipUntil)&&(_=this.getDeliveryDirectives(n,t.deliveryDirectives,E,w));_&&E!==void 0&&n.canBlockReload&&(n.requestScheduled=r.loading.first+Math.max(b-u*2,b/2)),this.scheduleLoading(f,_,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(),o=n.requestScheduled;if(r>=o){this.loadingPlaylist(e,t);return}const u=o-r;this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(u)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),u)}getDeliveryDirectives(e,t,i,n){let r=I1(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,n=t.part,r=bp.No),new k1(i,n,r)}checkRetry(e){const t=e.details,i=tm(e),n=e.errorAction,{action:r,retryCount:o=0,retryConfig:u}=n||{},c=!!n&&!!u&&(r===ps.RetryRequest||!n.resolved&&r===ps.SendAlternateToPenaltyBox);if(c){var d;if(o>=u.maxNumRetry)return!1;if(i&&(d=e.context)!=null&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${o+1}/${u.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const f=sb(u,o);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),f),this.warn(`Retrying playlist loading ${o+1}/${u.maxNumRetry} after "${t}" in ${f}ms`)}e.levelRetry=!0,n.resolved=!0}return c}}function gL(s,e){if(s.length!==e.length)return!1;for(let t=0;t<s.length;t++)if(!th(s[t].attrs,e[t].attrs))return!1;return!0}function th(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 Jv(s,e){return e.label.toLowerCase()===s.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(s.lang||"").toLowerCase())}class aU extends gb{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(N.MANIFEST_LOADING,this.onManifestLoading,this),e.on(N.MANIFEST_PARSED,this.onManifestParsed,this),e.on(N.LEVEL_LOADING,this.onLevelLoading,this),e.on(N.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(N.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(N.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(N.MANIFEST_LOADING,this.onManifestLoading,this),e.off(N.MANIFEST_PARSED,this.onManifestParsed,this),e.off(N.LEVEL_LOADING,this.onLevelLoading,this),e.off(N.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(N.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(N.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,o=this.tracksInGroup[i];if(!o||o.groupId!==n){this.warn(`Audio track with id:${i} and group:${n} not found in active group ${o?.groupId}`);return}const u=o.details;o.details=t.details,this.log(`Audio track ${i} "${o.name}" lang:${o.lang} group:${n} loaded [${r.startSN}-${r.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,u)}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.audioGroups||null,n=this.groupIds;let r=this.currentTrack;if(!i||n?.length!==i?.length||i!=null&&i.some(u=>n?.indexOf(u)===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;const u=this.tracks.filter(g=>!i||i.indexOf(g.groupId)!==-1);if(u.length)this.selectDefaultTrack&&!u.some(g=>g.default)&&(this.selectDefaultTrack=!1),u.forEach((g,v)=>{g.id=v});else if(!r&&!this.tracksInGroup.length)return;this.tracksInGroup=u;const c=this.hls.config.audioPreference;if(!r&&c){const g=Rr(c,u,dl);if(g>-1)r=u[g];else{const v=Rr(c,this.tracks);r=this.tracks[v]}}let d=this.findTrackId(r);d===-1&&r&&(d=this.findTrackId(null));const f={audioTracks:u};this.log(`Updating audio tracks, ${u.length} track(s) found in group(s): ${i?.join(",")}`),this.hls.trigger(N.AUDIO_TRACKS_UPDATED,f);const m=this.trackId;if(d!==-1&&m===-1)this.setAudioTrack(d);else if(u.length&&m===-1){var o;const g=new Error(`No audio track selected for current audio group-ID(s): ${(o=this.groupIds)==null?void 0:o.join(",")} track count: ${u.length}`);this.warn(g.message),this.hls.trigger(N.ERROR,{type:nt.MEDIA_ERROR,details:ve.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:g})}}}onError(e,t){t.fatal||!t.context||t.context.type===It.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;if(this.selectDefaultTrack=!1,i.length){const n=this.currentTrack;if(n&&xl(e,n,dl))return n;const r=Rr(e,this.tracksInGroup,dl);if(r>-1){const o=this.tracksInGroup[r];return this.setAudioTrack(r),o}else if(n){let o=t.loadLevel;o===-1&&(o=t.firstAutoLevel);const u=vF(e,t.levels,i,o,dl);if(u===-1)return null;t.nextLoadLevel=u}if(e.channels||e.audioCodec){const o=Rr(e,i);if(o>-1)return i[o]}}}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(N.AUDIO_TRACK_SWITCHING,Qt({},n)),r))return;const o=this.switchParams(n.url,i?.details,n.details);this.loadPlaylist(o)}findTrackId(e){const t=this.tracksInGroup;for(let i=0;i<t.length;i++){const n=t[i];if(!(this.selectDefaultTrack&&!n.default)&&(!e||xl(e,n,dl)))return i}if(e){const{name:i,lang:n,assocLang:r,characteristics:o,audioCodec:u,channels:c}=e;for(let d=0;d<t.length;d++){const f=t[d];if(xl({name:i,lang:n,assocLang:r,characteristics:o,audioCodec:u,channels:c},f,dl))return d}for(let d=0;d<t.length;d++){const f=t[d];if(th(e.attrs,f.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return d}for(let d=0;d<t.length;d++){const f=t[d];if(th(e.attrs,f.attrs,["LANGUAGE"]))return d}}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;this.shouldLoadPlaylist(t)&&em(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),o=e.details,u=o?.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:""}${u&&o.live?" age "+u.toFixed(1)+(o.type&&" "+o.type||""):""} ${r}`),this.hls.trigger(N.AUDIO_TRACK_LOADING,{url:r,id:i,groupId:n,deliveryDirectives:t||null,track:e})}}class oU{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 o=(i=this.tracks[e])==null?void 0:i.buffer;o!=null&&o.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>":`
${this.list("video")}
${this.list("audio")}
${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 g2=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,yL="HlsJsTrackRemovedError";class lU extends Error{constructor(e){super(e),this.name=yL}}class uU extends jn{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(N.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=kB(Eo(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(N.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(N.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(N.MANIFEST_LOADING,this.onManifestLoading,this),e.on(N.MANIFEST_PARSED,this.onManifestParsed,this),e.on(N.BUFFER_RESET,this.onBufferReset,this),e.on(N.BUFFER_APPENDING,this.onBufferAppending,this),e.on(N.BUFFER_CODECS,this.onBufferCodecs,this),e.on(N.BUFFER_EOS,this.onBufferEos,this),e.on(N.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(N.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(N.FRAG_PARSED,this.onFragParsed,this),e.on(N.FRAG_CHANGED,this.onFragChanged,this),e.on(N.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(N.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(N.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(N.MANIFEST_LOADING,this.onManifestLoading,this),e.off(N.MANIFEST_PARSED,this.onManifestParsed,this),e.off(N.BUFFER_RESET,this.onBufferReset,this),e.off(N.BUFFER_APPENDING,this.onBufferAppending,this),e.off(N.BUFFER_CODECS,this.onBufferCodecs,this),e.off(N.BUFFER_EOS,this.onBufferEos,this),e.off(N.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(N.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(N.FRAG_PARSED,this.onFragParsed,this),e.off(N.FRAG_CHANGED,this.onFragChanged,this),e.off(N.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 o=this.isQueued();(r||o)&&this.warn(`Transfering MediaSource with${o?" operations in queue":""}${r?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy()}const n=this.transferData;return!this.sourceBufferCount&&n&&n.mediaSource===t?ni(i,n.tracks):this.sourceBuffers.forEach(r=>{const[o]=r;o&&(i[o]=ni({},this.tracks[o]),this.removeBuffer(o)),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=Eo(this.appendSource);if(n){const r=!!t.mediaSource;(r||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);const o=this.mediaSource=t.mediaSource||new n;if(this.assignMediaSource(o),r)this._objectUrl=i.src,this.attachTransferred();else{const u=this._objectUrl=self.URL.createObjectURL(o);if(this.appendSource)try{i.removeAttribute("src");const c=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||c&&o instanceof c,y2(i),cU(i,u),i.load()}catch{i.src=u}else i.src=u}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,o=r?r.length:0,u=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(n&&r&&o){if(!this.tracksReady){this.hls.config.startFragPrefetch=!0,this.log("attachTransferred: waiting for SourceBuffer track info");return}if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})
required tracks: ${ui(i,(c,d)=>c==="initSegment"?void 0:d)};
transfer tracks: ${ui(n,(c,d)=>c==="initSegment"?void 0:d)}}`),!fw(n,i)){t.mediaSource=null,t.tracks=void 0;const c=e.currentTime,d=this.details,f=Math.max(c,d?.fragments[0].start||0);if(f-c>1){this.log(`attachTransferred: waiting for playback to reach new tracks start time ${c} -> ${f}`);return}this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(n)}"->"${Object.keys(i)}") start time: ${f} currentTime: ${c}`),this.onMediaDetaching(N.MEDIA_DETACHING,{}),this.onMediaAttaching(N.MEDIA_ATTACHING,t),e.currentTime=f;return}this.transferData=void 0,r.forEach(c=>{const d=c,f=n[d];if(f){const m=f.buffer;if(m){const g=this.fragmentTracker,v=f.id;if(g.hasFragments(v)||g.hasParts(v)){const E=vt.getBuffered(m);g.detectEvictedFragments(d,E,v,null,!0)}const b=zy(d),_=[d,m];this.sourceBuffers[b]=_,m.updating&&this.operationQueue&&this.operationQueue.prependBlocker(d),this.trackSourceBuffer(d,f)}}}),u(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),u()}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:o}=this;if(r){if(this.log(`media source ${i?"transferring":"detaching"}`),i)this.sourceBuffers.forEach(([u])=>{u&&this.removeBuffer(u)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){const u=r.readyState==="open";try{const c=r.sourceBuffers;for(let d=c.length;d--;)u&&c[d].abort(),r.removeSourceBuffer(c[d]);u&&r.endOfStream()}catch(c){this.warn(`onMediaDetaching: ${c.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||(o&&self.URL.revokeObjectURL(o),this.mediaSrc===o?(n.removeAttribute("src"),this.appendSource&&y2(n),n.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(N.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[zy(e)]=[null,null];const t=this.tracks[e];t&&(t.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new oU(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 o="audiovideo"in t&&(n.audio||n.video)||n.audiovideo&&("audio"in t||"video"in t),u=!o&&this.sourceBufferCount&&this.media&&r.some(c=>!n[c]);if(o||u){this.warn(`Unsupported transition between "${Object.keys(n)}" and "${r}" SourceBuffers`);return}r.forEach(c=>{var d,f;const m=t[c],{id:g,codec:v,levelCodec:b,container:_,metadata:E,supplemental:w}=m;let I=n[c];const L=(d=this.transferData)==null||(d=d.tracks)==null?void 0:d[c],F=L!=null&&L.buffer?L:I,$=F?.pendingCodec||F?.codec,G=F?.levelCodec;I||(I=n[c]={buffer:void 0,listeners:[],codec:v,supplemental:w,container:_,levelCodec:b,metadata:E,id:g});const B=Tp($,G),V=B?.replace(g2,"$1");let k=Tp(v,b);const R=(f=k)==null?void 0:f.replace(g2,"$1");k&&B&&V!==R&&(c.slice(0,5)==="audio"&&(k=Zp(k,this.appendSource)),this.log(`switching codec ${$} to ${k}`),k!==(I.pendingCodec||I.codec)&&(I.pendingCodec=k),I.container=_,this.appendChangeType(c,_,k))}),(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 o=this.tracks[e];if(o){const u=o.buffer;u!=null&&u.changeType&&(this.log(`changing ${e} sourceBuffer type to ${n}`),u.changeType(n),o.codec=i,o.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:o=>{this.warn(`Failed to change ${e} SourceBuffer type`,o)}};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,Je.MAIN))==null?void 0:t.gap)===!0)return;const o={label:"block-audio",execute:()=>{var u;const c=this.tracks.video;(this.lastVideoAppendEnd>n||c!=null&&c.buffer&&vt.isBuffered(c.buffer,n)||((u=this.fragmentTracker.getAppendedFrag(n,Je.MAIN))==null?void 0:u.gap)===!0)&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"))},onStart:()=>{},onComplete:()=>{},onError:u=>{this.warn("Error executing block-audio operation",u)}};this.blockedAudioAppend={op:o,frag:e},this.append(o,"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:o,frag:u,part:c,chunkMeta:d,offset:f}=t,m=d.buffering[r],{sn:g,cc:v}=u,b=self.performance.now();m.start=b;const _=u.stats.buffering,E=c?c.stats.buffering:null;_.start===0&&(_.start=b),E&&E.start===0&&(E.start=b);const w=i.audio;let I=!1;r==="audio"&&w?.container==="audio/mpeg"&&(I=!this.lastMpegAudioChunk||d.id===1||this.lastMpegAudioChunk.sn!==d.sn,this.lastMpegAudioChunk=d);const L=i.video,F=L?.buffer;if(F&&g!=="initSegment"){const B=c||u,V=this.blockedAudioAppend;if(r==="audio"&&o!=="main"&&!this.blockedAudioAppend&&!(L.ending||L.ended)){const R=B.start+B.duration*.05,z=F.buffered,X=this.currentOp("video");!z.length&&!X?this.blockAudio(B):!X&&!vt.isBuffered(F,R)&&this.lastVideoAppendEnd<R&&this.blockAudio(B)}else if(r==="video"){const k=B.end;if(V){const R=V.frag.start;(k>R||k<this.lastVideoAppendEnd||vt.isBuffered(F,R))&&this.unblockAudio()}this.lastVideoAppendEnd=k}}const $=(c||u).start,G={label:`append-${r}`,execute:()=>{var B;m.executeStart=self.performance.now();const V=(B=this.tracks[r])==null?void 0:B.buffer;V&&(I?this.updateTimestampOffset(V,$,.1,r,g,v):f!==void 0&&We(f)&&this.updateTimestampOffset(V,f,1e-6,r,g,v)),this.appendExecutor(n,r)},onStart:()=>{},onComplete:()=>{const B=self.performance.now();m.executeEnd=m.end=B,_.first===0&&(_.first=B),E&&E.first===0&&(E.first=B);const V={};this.sourceBuffers.forEach(([k,R])=>{k&&(V[k]=vt.getBuffered(R))}),this.appendErrors[r]=0,r==="audio"||r==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(N.BUFFER_APPENDED,{type:r,frag:u,part:c,chunkMeta:d,parent:u.type,timeRanges:V})},onError:B=>{var V;const k={type:nt.MEDIA_ERROR,parent:u.type,details:ve.BUFFER_APPEND_ERROR,sourceBufferName:r,frag:u,part:c,chunkMeta:d,error:B,err:B,fatal:!1},R=(V=this.media)==null?void 0:V.error;if(B.code===DOMException.QUOTA_EXCEEDED_ERR||B.name=="QuotaExceededError"||"quota"in B)k.details=ve.BUFFER_FULL_ERROR;else if(B.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!R)k.errorAction=qu(!0);else if(B.name===yL&&this.sourceBufferCount===0)k.errorAction=qu(!0);else{const z=++this.appendErrors[r];this.warn(`Failed ${z}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${r}" sourceBuffer (${R||"no media error"})`),(z>=this.hls.config.appendErrorMaxRetry||R)&&(k.fatal=!0)}this.hls.trigger(N.ERROR,k)}};this.log(`queuing "${r}" append sn: ${g}${c?" p: "+c.index:""} of ${u.type===Je.MAIN?"level":"track"} ${u.level} cc: ${v}`),this.append(G,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(N.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(([o])=>{o&&this.append(this.getFlushOp(o,n,r),o)})}onFragParsed(e,t){const{frag:i,part:n}=t,r=[],o=n?n.elementaryStreams:i.elementaryStreams;o[oi.AUDIOVIDEO]?r.push("audiovideo"):(o[oi.AUDIO]&&r.push("audio"),o[oi.VIDEO]&&r.push("video"));const u=()=>{const c=self.performance.now();i.stats.buffering.end=c,n&&(n.stats.buffering.end=c);const d=n?n.stats:i.stats;this.hls.trigger(N.FRAG_BUFFERED,{frag:i,part:n,stats:d,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(u,r).catch(c=>{this.warn(`Fragment buffered callback ${c}`),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(([o])=>{if(o){const u=this.tracks[o];(!t.type||t.type===o)&&(u.ending=!0,u.ended||(u.ended=!0,this.log(`${o} buffer reached EOS`)))}});const n=((i=this.overrides)==null?void 0:i.endOfStream)!==!1;this.sourceBufferCount>0&&!this.sourceBuffers.some(([o])=>{var u;return o&&!((u=this.tracks[o])!=null&&u.ended)})?n?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();const{mediaSource:o}=this;if(!o||o.readyState!=="open"){o&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${o.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),o.endOfStream(),this.hls.trigger(N.BUFFERED_TO_END,void 0)})):(this.tracksEnded(),this.hls.trigger(N.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===ve.BUFFER_APPEND_ERROR&&t.frag){var i;const n=(i=t.errorAction)==null?void 0:i.nextAutoLevel;We(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,o=t.levelTargetDuration,u=t.live&&n.liveBackBufferLength!==null?n.liveBackBufferLength:n.backBufferLength;if(We(u)&&u>=0){const d=Math.max(u,o),f=Math.floor(r/o)*o-d;this.flushBackBuffer(r,o,f)}const c=n.frontBufferFlushThreshold;if(We(c)&&c>0){const d=Math.max(n.maxBufferLength,c),f=Math.max(d,o),m=Math.floor(r/o)*o+f;this.flushFrontBuffer(r,o,m)}}flushBackBuffer(e,t,i){this.sourceBuffers.forEach(([n,r])=>{if(r){const u=vt.getBuffered(r);if(u.length>0&&i>u.start(0)){var o;this.hls.trigger(N.BACK_BUFFER_REACHED,{bufferEnd:i});const c=this.tracks[n];if((o=this.details)!=null&&o.live)this.hls.trigger(N.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(c!=null&&c.ended){this.log(`Cannot flush ${n} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(N.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:n})}}})}flushFrontBuffer(e,t,i){this.sourceBuffers.forEach(([n,r])=>{if(r){const o=vt.getBuffered(r),u=o.length;if(u<2)return;const c=o.start(u-1),d=o.end(u-1);if(i>c||e>=c&&e<=d)return;this.hls.trigger(N.BUFFER_FLUSHING,{startOffset:c,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 d=Math.max(0,t.fragmentStart),f=Math.max(d,n);return{duration:1/0,start:d,end:f}}return{duration:1/0}}const r=(e=this.overrides)==null?void 0:e.duration;if(r)return We(r)?{duration:r}:null;const o=this.media.duration,u=We(i.duration)?i.duration:0;return n>u&&n>o||!We(o)?{duration:n}:null}updateMediaSource({duration:e,start:t,end:i}){const n=this.mediaSource;!this.media||!n||n.readyState!=="open"||(n.duration!==e&&(We(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}) ${ui(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(N.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(N.ERROR,{type:nt.MEDIA_ERROR,details:ve.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 o=r,u=e[o];if(this.isPending(u)){const c=this.getTrackCodec(u,o),d=`${u.container};codecs=${c}`;u.codec=c,this.log(`creating sourceBuffer(${d})${this.currentOp(o)?" Queued":""} ${ui(u)}`);try{const f=i.addSourceBuffer(d),m=zy(o),g=[o,f];t[m]=g,u.buffer=f}catch(f){var n;this.error(`error while trying to add sourceBuffer: ${f.message}`),this.shiftAndExecuteNext(o),(n=this.operationQueue)==null||n.removeBlockers(),delete this.tracks[o],this.hls.trigger(N.ERROR,{type:nt.MEDIA_ERROR,details:ve.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:f,sourceBufferName:o,mimeType:d,parent:u.id});return}this.trackSourceBuffer(o,u)}}this.bufferCreated()}getTrackCodec(e,t){const i=e.supplemental;let n=e.codec;i&&(t==="video"||t==="audiovideo")&&Wd(i,"video")&&(n=JB(n,i));const r=Tp(n,e.levelCodec);return r?t.slice(0,5)==="audio"?Zp(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,o)=>{const u=o.removedRanges;u!=null&&u.length&&this.hls.trigger(N.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(N.ERROR,{type:nt.MEDIA_ERROR,details:ve.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:n,fatal:!1});const r=this.currentOp(e);r&&r.onError(n)}updateTimestampOffset(e,t,i,n,r,o){const u=t-e.timestampOffset;Math.abs(u)>=i&&(this.log(`Updating ${n} SourceBuffer timestampOffset to ${t} (sn: ${r} cc: ${o})`),e.timestampOffset=t)}removeExecutor(e,t,i){const{media:n,mediaSource:r}=this,o=this.tracks[e],u=o?.buffer;if(!n||!r||!u){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),this.shiftAndExecuteNext(e);return}const c=We(n.duration)?n.duration:1/0,d=We(r.duration)?r.duration:1/0,f=Math.max(0,t),m=Math.min(i,c,d);m>f&&(!o.ending||o.ended)?(o.ended=!1,this.log(`Removing [${f},${m}] from the ${e} SourceBuffer`),u.remove(f,m)):this.shiftAndExecuteNext(e)}appendExecutor(e,t){const i=this.tracks[t],n=i?.buffer;if(!n)throw new lU(`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}`),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(o=>this.appendBlocker(o));return t.length>1&&this.blockedAudioAppend&&this.unblockAudio(),Promise.all(n).then(o=>{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 o=i.bind(this,e);n.listeners.push({event:t,listener:o}),r.addEventListener(t,o)}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 y2(s){const e=s.querySelectorAll("source");[].slice.call(e).forEach(t=>{s.removeChild(t)})}function cU(s,e){const t=self.document.createElement("source");t.type="video/mp4",t.src=e,s.appendChild(t)}function zy(s){return s==="audio"?1:0}class yb{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(N.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(N.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(N.MANIFEST_PARSED,this.onManifestParsed,this),e.on(N.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(N.BUFFER_CODECS,this.onBufferCodecs,this),e.on(N.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(N.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(N.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(N.MANIFEST_PARSED,this.onManifestParsed,this),e.off(N.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(N.BUFFER_CODECS,this.onBufferCodecs,this),e.off(N.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&&We(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,yb.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=(u,c)=>c?u.width!==c.width||u.height!==c.height:!0;let r=e.length-1;const o=Math.max(t,i);for(let u=0;u<e.length;u+=1){const c=e[u];if((c.width>=o||c.height>=o)&&n(c,e[u+1])){r=u;break}}return r}}const dU={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},Qs=dU,hU={HLS:"h"},fU=hU;class Fr{constructor(e,t){Array.isArray(e)&&(e=e.map(i=>i instanceof Fr?i:new Fr(i))),this.value=e,this.params=t}}const pU="Dict";function mU(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 gU(s,e,t,i){return new Error(`failed to ${s} "${mU(e)}" as ${t}`,{cause:i})}function Ur(s,e,t){return gU("serialize",s,e,t)}class vL{constructor(e){this.description=e}}const v2="Bare Item",yU="Boolean";function vU(s){if(typeof s!="boolean")throw Ur(s,yU);return s?"?1":"?0"}function TU(s){return btoa(String.fromCharCode(...s))}const bU="Byte Sequence";function _U(s){if(ArrayBuffer.isView(s)===!1)throw Ur(s,bU);return`:${TU(s)}:`}const xU="Integer";function SU(s){return s<-999999999999999||999999999999999<s}function TL(s){if(SU(s))throw Ur(s,xU);return s.toString()}function EU(s){return`@${TL(s.getTime()/1e3)}`}function bL(s,e){if(s<0)return-bL(-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 AU="Decimal";function CU(s){const e=bL(s,3);if(Math.floor(Math.abs(e)).toString().length>12)throw Ur(s,AU);const t=e.toString();return t.includes(".")?t:`${t}.0`}const DU="String",wU=/[\x00-\x1f\x7f]+/;function LU(s){if(wU.test(s))throw Ur(s,DU);return`"${s.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function IU(s){return s.description||s.toString().slice(7,-1)}const kU="Token";function T2(s){const e=IU(s);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw Ur(e,kU);return e}function eT(s){switch(typeof s){case"number":if(!We(s))throw Ur(s,v2);return Number.isInteger(s)?TL(s):CU(s);case"string":return LU(s);case"symbol":return T2(s);case"boolean":return vU(s);case"object":if(s instanceof Date)return EU(s);if(s instanceof Uint8Array)return _U(s);if(s instanceof vL)return T2(s);default:throw Ur(s,v2)}}const RU="Key";function tT(s){if(/^[a-z*][a-z0-9\-_.*]*$/.test(s)===!1)throw Ur(s,RU);return s}function vb(s){return s==null?"":Object.entries(s).map(([e,t])=>t===!0?`;${tT(e)}`:`;${tT(e)}=${eT(t)}`).join("")}function _L(s){return s instanceof Fr?`${eT(s.value)}${vb(s.params)}`:eT(s)}function OU(s){return`(${s.value.map(_L).join(" ")})${vb(s.params)}`}function PU(s,e={whitespace:!0}){if(typeof s!="object"||s==null)throw Ur(s,pU);const t=s instanceof Map?s.entries():Object.entries(s),i=e?.whitespace?" ":"";return Array.from(t).map(([n,r])=>{r instanceof Fr||(r=new Fr(r));let o=tT(n);return r.value===!0?o+=vb(r.params):(o+="=",Array.isArray(r.value)?o+=OU(r):o+=_L(r)),o}).join(`,${i}`)}function xL(s,e){return PU(s,e)}const xr="CMCD-Object",Ii="CMCD-Request",ol="CMCD-Session",ho="CMCD-Status",MU={br:xr,ab:xr,d:xr,ot:xr,tb:xr,tpb:xr,lb:xr,tab:xr,lab:xr,url:xr,pb:Ii,bl:Ii,tbl:Ii,dl:Ii,ltc:Ii,mtp:Ii,nor:Ii,nrr:Ii,rc:Ii,sn:Ii,sta:Ii,su:Ii,ttfb:Ii,ttfbb:Ii,ttlb:Ii,cmsdd:Ii,cmsds:Ii,smrt:Ii,df:Ii,cs:Ii,ts:Ii,cid:ol,pr:ol,sf:ol,sid:ol,st:ol,v:ol,msd:ol,bs:ho,bsd:ho,cdn:ho,rtp:ho,bg:ho,pt:ho,ec:ho,e:ho},NU={REQUEST:Ii};function BU(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 FU(s,e){const t={};if(!s)return t;const i=Object.keys(s),n=e?BU(e):{};return i.reduce((r,o)=>{var u;const c=MU[o]||n[o]||NU.REQUEST,d=(u=r[c])!==null&&u!==void 0?u:r[c]={};return d[o]=s[o],r},t)}function UU(s){return["ot","sf","st","e","sta"].includes(s)}function $U(s){return typeof s=="number"?We(s):s!=null&&s!==""&&s!==!1}const SL="event";function jU(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 Ep=s=>Math.round(s),iT=(s,e)=>Array.isArray(s)?s.map(t=>iT(t,e)):s instanceof Fr&&typeof s.value=="string"?new Fr(iT(s.value,e),s.params):(e.baseUrl&&(s=jU(s,e.baseUrl)),e.version===1?encodeURIComponent(s):s),np=s=>Ep(s/100)*100,HU=(s,e)=>{let t=s;return e.version>=2&&(s instanceof Fr&&typeof s.value=="string"?t=new Fr([s]):typeof s=="string"&&(t=[s])),iT(t,e)},GU={br:Ep,d:Ep,bl:np,dl:np,mtp:np,nor:HU,rtp:np,tb:Ep},EL="request",AL="response",Tb=["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"],VU=["e"],qU=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function Gm(s){return qU.test(s)}function zU(s){return Tb.includes(s)||VU.includes(s)||Gm(s)}const CL=["d","dl","nor","ot","rtp","su"];function KU(s){return Tb.includes(s)||CL.includes(s)||Gm(s)}const YU=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];function WU(s){return Tb.includes(s)||CL.includes(s)||YU.includes(s)||Gm(s)}const XU=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function QU(s){return XU.includes(s)||Gm(s)}const ZU={[AL]:WU,[SL]:zU,[EL]:KU};function DL(s,e={}){const t={};if(s==null||typeof s!="object")return t;const i=e.version||s.v||1,n=e.reportingMode||EL,r=i===1?QU:ZU[n];let o=Object.keys(s).filter(r);const u=e.filter;typeof u=="function"&&(o=o.filter(u));const c=n===AL||n===SL;c&&!o.includes("ts")&&o.push("ts"),i>1&&!o.includes("v")&&o.push("v");const d=ni({},GU,e.formatters),f={version:i,reportingMode:n,baseUrl:e.baseUrl};return o.sort().forEach(m=>{let g=s[m];const v=d[m];if(typeof v=="function"&&(g=v(g,f)),m==="v"){if(i===1)return;g=i}m=="pr"&&g===1||(c&&m==="ts"&&!We(g)&&(g=Date.now()),$U(g)&&(UU(m)&&typeof g=="string"&&(g=new vL(g)),t[m]=g))}),t}function JU(s,e={}){const t={};if(!s)return t;const i=DL(s,e),n=FU(i,e?.customHeaderMap);return Object.entries(n).reduce((r,[o,u])=>{const c=xL(u,{whitespace:!1});return c&&(r[o]=c),r},t)}function e6(s,e,t){return ni(s,JU(e,t))}const t6="CMCD";function i6(s,e={}){return s?xL(DL(s,e),{whitespace:!1}):""}function s6(s,e={}){if(!s)return"";const t=i6(s,e);return encodeURIComponent(t)}function n6(s,e={}){if(!s)return"";const t=s6(s,e);return`${t6}=${t}`}const b2=/CMCD=[^&#]+/;function r6(s,e,t){const i=n6(e,t);if(!i)return s;if(b2.test(s))return s.replace(b2,i);const n=s.includes("?")?"&":"?";return`${s}${n}${i}`}class a6{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:Qs.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:o}=n,u=this.hls.levels[r.level],c=this.getObjectType(r),d={d:(o||r).duration*1e3,ot:c};(c===Qs.VIDEO||c===Qs.AUDIO||c==Qs.MUXED)&&(d.br=u.bitrate/1e3,d.tb=this.getTopBandwidth(c)/1e3,d.bl=this.getBufferLength(c));const f=o?this.getNextPart(o):this.getNextFrag(r);f!=null&&f.url&&f.url!==r.url&&(d.nor=f.url),this.apply(n,d)}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;e.on(N.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(N.MEDIA_DETACHED,this.onMediaDetached,this),e.on(N.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(N.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(N.MEDIA_DETACHED,this.onMediaDetached,this),e.off(N.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:fU.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){ni(t,this.createData());const i=t.ot===Qs.INIT||t.ot===Qs.VIDEO||t.ot===Qs.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((o,u)=>(n.includes(u)&&(o[u]=t[u]),o),{}));const r={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),e6(e.headers,t,r)):e.url=r6(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:o}=n;for(let u=r.length-1;u>=0;u--){const c=r[u];if(c.index===i&&c.fragment.sn===o)return r[u+1]}}}getObjectType(e){const{type:t}=e;if(t==="subtitle")return Qs.TIMED_TEXT;if(e.sn==="initSegment")return Qs.INIT;if(t==="audio")return Qs.AUDIO;if(t==="main")return this.hls.audioTracks.length?Qs.VIDEO:Qs.MUXED}getTopBandwidth(e){let t=0,i;const n=this.hls;if(e===Qs.AUDIO)i=n.audioTracks;else{const r=n.maxAutoLevel,o=r>-1?r+1:n.levels.length;i=n.levels.slice(0,o)}return i.forEach(r=>{r.bitrate>t&&(t=r.bitrate)}),t>0?t:NaN}getBufferLength(e){const t=this.media,i=e===Qs.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!t?NaN:vt.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,o,u){t(r),this.loader.load(r,o,u)}}}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,o,u){t(r),this.loader.load(r,o,u)}}}}const o6=3e5;class l6 extends jn{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(N.MANIFEST_LOADING,this.onManifestLoading,this),e.on(N.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(N.MANIFEST_PARSED,this.onManifestParsed,this),e.on(N.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(N.MANIFEST_LOADING,this.onManifestLoading,this),e.off(N.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(N.MANIFEST_PARSED,this.onManifestParsed,this),e.off(N.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)}startLoad(){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===ps.SendAlternateToPenaltyBox&&i.flags===Tn.MoveAllAlternatesMatchingHost){const n=this.levels;let r=this._pathwayPriority,o=this.pathwayId;if(t.context){const{groupId:u,pathwayId:c,type:d}=t.context;u&&n?o=this.getPathwayForGroupId(u,d,o):c&&(o=c)}o in this.penalizedPathways||(this.penalizedPathways[o]=performance.now()),!r&&n&&(r=this.pathways()),r&&r.length>1&&(this.updatePathwayPriority(r),i.resolved=this.pathwayId!==o),t.details===ve.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: ${o} levels: ${n&&n.length} priorities: ${ui(r)} penalized: ${ui(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();Object.keys(i).forEach(r=>{n-i[r]>o6&&delete i[r]});for(let r=0;r<e.length;r++){const o=e[r];if(o in i)continue;if(o===this.pathwayId)return;const u=this.hls.nextLoadLevel,c=this.hls.levels[u];if(t=this.getLevelsForPathway(o),t.length>0){this.log(`Setting Pathway to "${o}"`),this.pathwayId=o,Kw(t),this.hls.trigger(N.LEVELS_UPDATED,{levels:t});const d=this.hls.levels[u];c&&d&&this.levels&&(d.attrs["STABLE-VARIANT-ID"]!==c.attrs["STABLE-VARIANT-ID"]&&d.bitrate!==c.bitrate&&this.log(`Unstable Pathways change from bitrate ${c.bitrate} to ${d.bitrate}`),this.hls.nextLoadLevel=u);break}}}getPathwayForGroupId(e,t,i){const n=this.getLevelsForPathway(i).concat(this.levels||[]);for(let r=0;r<n.length;r++)if(t===It.AUDIO_TRACK&&n[r].hasAudioGroup(e)||t===It.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:o,"BASE-ID":u,"URI-REPLACEMENT":c}=r;if(t.some(f=>f.pathwayId===o))return;const d=this.getLevelsForPathway(u).map(f=>{const m=new Si(f.attrs);m["PATHWAY-ID"]=o;const g=m.AUDIO&&`${m.AUDIO}_clone_${o}`,v=m.SUBTITLES&&`${m.SUBTITLES}_clone_${o}`;g&&(i[m.AUDIO]=g,m.AUDIO=g),v&&(n[m.SUBTITLES]=v,m.SUBTITLES=v);const b=wL(f.uri,m["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",c),_=new Qd({attrs:m,audioCodec:f.audioCodec,bitrate:f.bitrate,height:f.height,name:f.name,url:b,videoCodec:f.videoCodec,width:f.width});if(f.audioGroups)for(let E=1;E<f.audioGroups.length;E++)_.addGroupId("audio",`${f.audioGroups[E]}_clone_${o}`);if(f.subtitleGroups)for(let E=1;E<f.subtitleGroups.length;E++)_.addGroupId("text",`${f.subtitleGroups[E]}_clone_${o}`);return _});t.push(...d),_2(this.audioTracks,i,c,o),_2(this.subtitleTracks,n,c,o)})}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 f=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;n.searchParams.set("_HLS_pathway",this.pathwayId),n.searchParams.set("_HLS_throughput",""+f)}const r={responseType:"json",url:n.href},o=t.steeringManifestLoadPolicy.default,u=o.errorRetry||o.timeoutRetry||{},c={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:u.maxNumRetry||0,retryDelay:u.retryDelayMs||0,maxRetryDelay:u.maxRetryDelayMs||0},d={onSuccess:(f,m,g,v)=>{this.log(`Loaded steering manifest: "${n}"`);const b=f.data;if(b?.VERSION!==1){this.log(`Steering VERSION ${b.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=b.TTL;const{"RELOAD-URI":_,"PATHWAY-CLONES":E,"PATHWAY-PRIORITY":w}=b;if(_)try{this.uri=new self.URL(_,n).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${_}`);return}this.scheduleRefresh(this.uri||g.url),E&&this.clonePathways(E);const I={steeringManifest:b,url:n.toString()};this.hls.trigger(N.STEERING_MANIFEST_LOADED,I),w&&this.updatePathwayPriority(w)},onError:(f,m,g,v)=>{if(this.log(`Error loading steering manifest: ${f.code} ${f.text} (${m.url})`),this.stopLoad(),f.code===410){this.enabled=!1,this.log(`Steering manifest ${m.url} no longer available`);return}let b=this.timeToLoad*1e3;if(f.code===429){const _=this.loader;if(typeof _?.getResponseHeader=="function"){const E=_.getResponseHeader("Retry-After");E&&(b=parseFloat(E)*1e3)}this.log(`Steering manifest ${m.url} rate limited`);return}this.scheduleRefresh(this.uri||m.url,b)},onTimeout:(f,m,g)=>{this.log(`Timeout loading steering manifest (${m.url})`),this.scheduleRefresh(this.uri||m.url)}};this.log(`Requesting steering manifest: ${n}`),this.loader.load(r,c,d)}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 _2(s,e,t,i){s&&Object.keys(e).forEach(n=>{const r=s.filter(o=>o.groupId===n).map(o=>{const u=ni({},o);return u.details=void 0,u.attrs=new Si(u.attrs),u.url=u.attrs.URI=wL(o.url,o.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),u.groupId=u.attrs["GROUP-ID"]=e[n],u.attrs["PATHWAY-ID"]=i,u});s.push(...r)})}function wL(s,e,t,i){const{HOST:n,PARAMS:r,[t]:o}=i;let u;e&&(u=o?.[e],u&&(s=u));const c=new self.URL(s);return n&&!u&&(c.host=n),r&&Object.keys(r).sort().forEach(d=>{d&&c.searchParams.set(d,r[d])}),c.href}class Ku extends jn{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=Ku.CDMCleanupPromise?[Ku.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 o=Object.keys(this.keySystemAccessPromises);o.length||(o=Id(this.config));const u=o.map(Fy).filter(c=>!!c);this.keyFormatPromise=this.getKeyFormatPromise(u)}this.keyFormatPromise.then(o=>{const u=_p(o);if(i!=="sinf"||u!==Ei.FAIRPLAY){this.log(`Ignoring "${t.type}" event with init data type: "${i}" for selected key-system ${u}`);return}let c;try{const v=Zi(new Uint8Array(n)),b=ob(JSON.parse(v).sinf),_=xw(b);if(!_)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");c=new Uint8Array(_.subarray(8,24))}catch(v){this.warn(`${r} Failed to parse sinf: ${v}`);return}const d=gs(c),{keyIdToKeySessionPromise:f,mediaKeySessions:m}=this;let g=f[d];for(let v=0;v<m.length;v++){const b=m[v],_=b.decryptdata;if(!_.keyId)continue;const E=gs(_.keyId);if(sm(c,_.keyId)||_.uri.replace(/-/g,"").indexOf(d)!==-1){if(g=f[E],!g)continue;if(_.pssh)break;delete f[E],_.pssh=new Uint8Array(n),_.keyId=c,g=f[d]=g.then(()=>this.generateRequestWithPreferredKeySession(b,i,n,"encrypted-event-key-match")),g.catch(w=>this.handleError(w));break}}g||this.handleError(new Error(`Key ID ${d} not encountered in playlist. Key-system sessions ${m.length}.`))}).catch(o=>this.handleError(o))}},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}registerListeners(){this.hls.on(N.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(N.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(N.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(N.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on(N.DESTROYING,this.onDestroying,this)}unregisterListeners(){this.hls.off(N.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(N.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(N.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(N.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off(N.DESTROYING,this.onDestroying,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:i}=this.config,n=t?.[e];if(n)return n.licenseUrl;if(e===Ei.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=(o,u,c)=>!!o&&c.indexOf(o)===u,n=t.map(o=>o.audioCodec).filter(i),r=t.map(o=>o.videoCodec).filter(i);return n.length+r.length===0&&r.push("avc1.42e01e"),new Promise((o,u)=>{const c=d=>{const f=d.shift();this.getMediaKeysPromise(f,n,r).then(m=>o({keySystem:f,mediaKeys:m})).catch(m=>{d.length?c(d):m instanceof yn?u(m):u(new yn({type:nt.KEY_SYSTEM_ERROR,details:ve.KEY_SYSTEM_NO_ACCESS,error:m,fatal:!0},m.message))})};c(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:i}=this.config;if(typeof i!="function"){let n=`Configured requestMediaKeySystemAccess is not a function ${i}`;return Uw===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=HF(e,t,i,this.config.drmSystemOptions||{});let o=this.keySystemAccessPromises[e],u=(n=o)==null?void 0:n.keySystemAccess;if(!u){this.log(`Requesting encrypted media "${e}" key-system access with config: ${ui(r)}`),u=this.requestMediaKeySystemAccess(e,r);const c=o=this.keySystemAccessPromises[e]={keySystemAccess:u};return u.catch(d=>{this.log(`Failed to obtain access to key-system "${e}": ${d}`)}),u.then(d=>{this.log(`Access for key-system "${d.keySystem}" obtained`);const f=this.fetchServerCertificate(e);this.log(`Create media-keys for "${e}"`);const m=c.mediaKeys=d.createMediaKeys().then(g=>(this.log(`Media-keys created for "${e}"`),c.hasMediaKeys=!0,f.then(v=>v?this.setMediaKeysServerCertificate(g,e,v):g)));return m.catch(g=>{this.error(`Failed to create media-keys for "${e}"}: ${g}`)}),m})}return u.then(()=>o.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: ${gs(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=rp(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 ${gs(e.decryptdata.keyId||[])}
} (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})=>Fy(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=Fy(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=Id(this.config),i=e.map(_p).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=u6(e,t[i]);if(n)return n}}loadKey(e){const t=e.keyInfo.decryptdata,i=rp(t),n=this.bannedKeyIds[i];if(n||this.getKeyStatus(t)==="internal-error"){const u=x2(n||"internal-error",t);return this.handleError(u,e.frag),Promise.reject(u)}const r=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${r}`);const o=this.keyIdToKeySessionPromise[i];if(!o){const u=this.getKeySystemForKeyPromise(t).then(({keySystem:c,mediaKeys:d})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${r}`),this.attemptSetMediaKeys(c,d).then(()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:c,mediaKeys:d,decryptdata:t}))))).then(c=>{const d="cenc",f=t.pssh?t.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(c,d,f,"playlist-key")});return u.catch(c=>this.handleError(c,e.frag)),this.keyIdToKeySessionPromise[i]=u,u}return o.catch(u=>{if(u instanceof yn){const c=Qt({},u.data);this.getKeyStatus(t)==="internal-error"&&(c.decryptdata=t);const d=new yn(c,u.message);this.handleError(d,e.frag)}}),o}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e,t){if(this.hls)if(e instanceof yn){t&&(e.data.frag=t);const i=e.data.decryptdata;this.error(`${e.message}${i?` (${gs(i.keyId||[])})`:""}`),this.hls.trigger(N.ERROR,e.data)}else this.error(e.message),this.hls.trigger(N.ERROR,{type:nt.KEY_SYSTEM_ERROR,details:ve.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}getKeySystemForKeyPromise(e){const t=rp(e),i=this.keyIdToKeySessionPromise[t];if(!i){const n=_p(e.keyFormat),r=n?[n]:Id(this.config);return this.attemptKeySystemAccess(r)}return i}getKeySystemSelectionPromise(e){if(e.length||(e=Id(this.config)),e.length===0)throw new yn({type:nt.KEY_SYSTEM_ERROR,details:ve.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${ui({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,o)=>{this.mediaResolved=()=>{if(this.mediaResolved=void 0,!this.media)return o(new Error("Attempted to set mediaKeys without media element attached"));this.mediaKeys=t,this.media.setMediaKeys(t).then(r).catch(o)}}));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 o=(r=this.config.drmSystems)==null||(r=r[e.keySystem])==null?void 0:r.generateRequest;if(o)try{const b=o.call(this.hls,t,i,e);if(!b)throw new Error("Invalid response from configured generateRequest filter");t=b.initDataType,i=b.initData?b.initData:null,e.decryptdata.pssh=i?new Uint8Array(i):null}catch(b){if(this.warn(b.message),this.hls&&this.hls.config.debug)throw b}if(i===null)return this.log(`Skipping key-session request for "${n}" (no initData)`),Promise.resolve(e);const u=rp(e.decryptdata),c=e.decryptdata.uri;this.log(`Generating key-session request for "${n}" keyId: ${u} URI: ${c} (init data type: ${t} length: ${i.byteLength})`);const d=new ub,f=e._onmessage=b=>{const _=e.mediaKeysSession;if(!_){d.emit("error",new Error("invalid state"));return}const{messageType:E,message:w}=b;this.log(`"${E}" message event for session "${_.sessionId}" message size: ${w.byteLength}`),E==="license-request"||E==="license-renewal"?this.renewLicense(e,w).catch(I=>{d.eventNames().length?d.emit("error",I):this.handleError(I)}):E==="license-release"?e.keySystem===Ei.FAIRPLAY&&this.updateKeySession(e,Yv("acknowledged")).then(()=>this.removeSession(e)).catch(I=>this.handleError(I)):this.warn(`unhandled media key message type "${E}"`)},m=(b,_)=>{_.keyStatus=b;let E;b.startsWith("usable")?d.emit("resolved"):b==="internal-error"||b==="output-restricted"||b==="output-downscaled"?E=x2(b,_.decryptdata):b==="expired"?E=new Error(`key expired (keyId: ${u})`):b==="released"?E=new Error("key released"):b==="status-pending"||this.warn(`unhandled key status change "${b}" (keyId: ${u})`),E&&(d.eventNames().length?d.emit("error",E):this.handleError(E))},g=e._onkeystatuseschange=b=>{if(!e.mediaKeysSession){d.emit("error",new Error("invalid state"));return}const E=this.getKeyStatuses(e);if(!Object.keys(E).some(F=>E[F]!=="status-pending"))return;if(E[u]==="expired"){this.log(`Expired key ${ui(E)} in key-session "${e.mediaKeysSession.sessionId}"`),this.renewKeySession(e);return}let I=E[u];if(I)m(I,e);else{var L;e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(L=e.keyStatusTimeouts)[u]||(L[u]=self.setTimeout(()=>{if(!e.mediaKeysSession||!this.mediaKeys)return;const $=this.getKeyStatus(e.decryptdata);if($&&$!=="status-pending")return this.log(`No status for keyId ${u} in key-session "${e.mediaKeysSession.sessionId}". Using session key-status ${$} from other session.`),m($,e);this.log(`key status for ${u} in key-session "${e.mediaKeysSession.sessionId}" timed out after 1000ms`),I="internal-error",m(I,e)},1e3)),this.log(`No status for keyId ${u} (${ui(E)}).`)}};Fs(e.mediaKeysSession,"message",f),Fs(e.mediaKeysSession,"keystatuseschange",g);const v=new Promise((b,_)=>{d.on("error",_),d.on("resolved",b)});return e.mediaKeysSession.generateRequest(t,i).then(()=>{this.log(`Request generated for key-session "${e.mediaKeysSession.sessionId}" keyId: ${u} URI: ${c}`)}).catch(b=>{throw new yn({type:nt.KEY_SYSTEM_ERROR,details:ve.KEY_SYSTEM_NO_SESSION,error:b,decryptdata:e.decryptdata,fatal:!1},`Error generating key-session request: ${b}`)}).then(()=>v).catch(b=>(d.removeAllListeners(),this.removeSession(e).then(()=>{throw b}))).then(()=>(d.removeAllListeners(),e))}getKeyStatuses(e){const t={};return e.mediaKeysSession.keyStatuses.forEach((i,n)=>{if(typeof n=="string"&&typeof i=="object"){const u=n;n=i,i=u}const r="buffer"in n?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n);if(e.keySystem===Ei.PLAYREADY&&r.length===16){const u=gs(r);t[u]=i,Bw(r)}const o=gs(r);i==="internal-error"&&(this.bannedKeyIds[o]=i),this.log(`key status change "${i}" for keyStatuses keyId: ${o} key-session "${e.mediaKeysSession.sessionId}"`),t[o]=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((o,u)=>{const c={responseType:"arraybuffer",url:r},d=t.certLoadPolicy.default,f={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},m={onSuccess:(g,v,b,_)=>{o(g.data)},onError:(g,v,b,_)=>{u(new yn({type:nt.KEY_SYSTEM_ERROR,details:ve.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:b,response:Qt({url:c.url,data:void 0},g)},`"${e}" certificate request failed (${r}). Status: ${g.code} (${g.text})`))},onTimeout:(g,v,b)=>{u(new yn({type:nt.KEY_SYSTEM_ERROR,details:ve.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:b,response:{url:c.url,data:void 0}},`"${e}" certificate request timed out (${r})`))},onAbort:(g,v,b)=>{u(new Error("aborted"))}};n.load(c,f,m)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,i){return new Promise((n,r)=>{e.setServerCertificate(i).then(o=>{this.log(`setServerCertificate ${o?"success":"not supported by CDM"} (${i.byteLength}) on "${t}"`),n(e)}).catch(o=>{r(new yn({type:nt.KEY_SYSTEM_ERROR,details:ve.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:o,fatal:!0},o.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(i=>this.updateKeySession(e,new Uint8Array(i)).catch(n=>{throw new yn({type:nt.KEY_SYSTEM_ERROR,details:ve.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 f;for(let m=0,g=r.length;m<g;m++){var o,u;f=r[m];const v=(o=f.querySelector("name"))==null?void 0:o.textContent,b=(u=f.querySelector("value"))==null?void 0:u.textContent;v&&b&&e.setRequestHeader(v,b)}}const c=n.querySelector("Challenge"),d=c?.textContent;if(!d)throw new Error("Cannot find <Challenge> in key message");return Yv(atob(d))}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(o=>{if(!i.decryptdata)throw o;return e.open("POST",t,!0),r.call(this.hls,e,t,i,n)}).then(o=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:o||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 o=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${o}`);const u=new XMLHttpRequest;u.responseType="arraybuffer",u.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return r(new Error("invalid state"));if(u.readyState===4)if(u.status===200){this._requestLicenseFailureCount=0;let c=u.response;this.log(`License received ${c instanceof ArrayBuffer?c.byteLength:c}`);const d=this.config.licenseResponseCallback;if(d)try{c=d.call(this.hls,u,o,e)}catch(f){this.error(f)}n(c)}else{const c=i.errorRetry,d=c?c.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>d||u.status>=400&&u.status<500)r(new yn({type:nt.KEY_SYSTEM_ERROR,details:ve.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:e.decryptdata,fatal:!0,networkDetails:u,response:{url:o,data:void 0,code:u.status,text:u.statusText}},`License Request XHR failed (${o}). Status: ${u.status} (${u.statusText})`));else{const f=d-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${f} attempts left`),this.requestLicense(e,t).then(n,r)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=u,this.setupLicenseXHR(u,o,e,t).then(({xhr:c,licenseChallenge:d})=>{e.keySystem==Ei.PLAYREADY&&(d=this.unpackPlayReadyKeyMessage(c,d)),c.send(d)}).catch(r)})}onDestroying(){this.unregisterListeners(),this._clear()}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const i=t.media;this.media=i,Fs(i,"encrypted",this.onMediaEncrypted),Fs(i,"waitingforkey",this.onWaitingForKey);const n=this.mediaResolved;n?n():this.mediaKeys=i.mediaKeys}onMediaDetached(){const e=this.media;e&&(tn(e,"encrypted",this.onMediaEncrypted),tn(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,_o.clearKeyUriToKeyIdMap();const r=n.length;Ku.CDMCleanupPromise=Promise.all(n.map(o=>this.removeSession(o)).concat((i==null||(e=i.setMediaKeys(null))==null?void 0:e.catch(o=>{this.log(`Could not clear media keys: ${o}`),this.hls&&this.hls.trigger(N.ERROR,{type:nt.OTHER_ERROR,details:ve.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error(`Could not clear media keys: ${o}`)})}))||Promise.resolve())).catch(o=>{this.log(`Could not close sessions and clear media keys: ${o}`),this.hls&&this.hls.trigger(N.ERROR,{type:nt.OTHER_ERROR,details:ve.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${o}`)})}).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: ${gs(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:o}=e;o&&Object.keys(o).forEach(d=>self.clearTimeout(o[d]));const{drmSystemOptions:u}=this.config;return(VF(u)?new Promise((d,f)=>{self.setTimeout(()=>f(new Error("MediaKeySession.remove() timeout")),8e3),t.remove().then(d).catch(f)}):Promise.resolve()).catch(d=>{this.log(`Could not remove session: ${d}`),this.hls&&this.hls.trigger(N.ERROR,{type:nt.OTHER_ERROR,details:ve.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error(`Could not remove session: ${d}`)})}).then(()=>t.close()).catch(d=>{this.log(`Could not close session: ${d}`),this.hls&&this.hls.trigger(N.ERROR,{type:nt.OTHER_ERROR,details:ve.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${d}`)})})}return Promise.resolve()}}Ku.CDMCleanupPromise=void 0;function rp(s){if(!s)throw new Error("Could not read keyId of undefined decryptdata");if(s.keyId===null)throw new Error("keyId is null");return gs(s.keyId)}function u6(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 yn 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 x2(s,e){const t=s==="output-restricted",i=t?ve.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:ve.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new yn({type:nt.KEY_SYSTEM_ERROR,details:i,fatal:!1,decryptdata:e},t?"HDCP level output restricted":`key status changed to "${s}"`)}class c6{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(N.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(N.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off(N.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(N.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,o=i-this.lastDroppedFrames,u=t-this.lastDecodedFrames,c=1e3*o/r,d=this.hls;if(d.trigger(N.FPS_DROP,{currentDropped:o,currentDecoded:u,totalDroppedFrames:i}),c>0&&o>d.config.fpsDroppedMonitoringThreshold*u){let f=d.currentLevel;d.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+f),f>0&&(d.autoLevelCapping===-1||d.autoLevelCapping>=f)&&(f=f-1,d.trigger(N.FPS_DROP_LEVEL_CAPPING,{level:f,droppedLevel:d.currentLevel}),d.autoLevelCapping=f,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 LL(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 IL(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){Zt.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){Zt.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${n}`)}}t==="disabled"&&(s.mode=t)}function Pu(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 sT(s,e,t,i){const n=s.mode;if(n==="disabled"&&(s.mode="hidden"),s.cues&&s.cues.length>0){const r=h6(s.cues,e,t);for(let o=0;o<r.length;o++)(!i||i(r[o]))&&s.removeCue(r[o])}n==="disabled"&&(s.mode=n)}function d6(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 h6(s,e,t){const i=[],n=d6(s,e);if(n>-1)for(let r=n,o=s.length;r<o;r++){const u=s[r];if(u.startTime>=e&&u.endTime<=t)i.push(u);else if(u.startTime>t)return i}return i}function Ap(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 f6 extends gb{constructor(e){super(e,"subtitle-track-controller"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null;const i=Ap(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];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(N.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(N.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(N.MANIFEST_LOADING,this.onManifestLoading,this),e.on(N.MANIFEST_PARSED,this.onManifestParsed,this),e.on(N.LEVEL_LOADING,this.onLevelLoading,this),e.on(N.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(N.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(N.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(N.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(N.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(N.MANIFEST_LOADING,this.onManifestLoading,this),e.off(N.MANIFEST_PARSED,this.onManifestParsed,this),e.off(N.LEVEL_LOADING,this.onLevelLoading,this),e.off(N.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(N.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(N.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;Ap(i.textTracks).forEach(o=>{Pu(o)})}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,o=this.tracksInGroup[i];if(!o||o.groupId!==n){this.warn(`Subtitle track with id:${i} and group:${n} not found in active group ${o?.groupId}`);return}const u=o.details;o.details=t.details,this.log(`Subtitle track ${i} "${o.name}" lang:${o.lang} group:${n} loaded [${r.startSN}-${r.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,u)}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(o=>n?.indexOf(o)===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;const o=this.tracks.filter(f=>!i||i.indexOf(f.groupId)!==-1);if(o.length)this.selectDefaultTrack&&!o.some(f=>f.default)&&(this.selectDefaultTrack=!1),o.forEach((f,m)=>{f.id=m});else if(!r&&!this.tracksInGroup.length)return;this.tracksInGroup=o;const u=this.hls.config.subtitlePreference;if(!r&&u){this.selectDefaultTrack=!1;const f=Rr(u,o);if(f>-1)r=o[f];else{const m=Rr(u,this.tracks);r=this.tracks[m]}}let c=this.findTrackId(r);c===-1&&r&&(c=this.findTrackId(null));const d={subtitleTracks:o};this.log(`Updating subtitle tracks, ${o.length} track(s) found in "${i?.join(",")}" group-id`),this.hls.trigger(N.SUBTITLE_TRACKS_UPDATED,d),c!==-1&&this.trackId===-1&&this.setSubtitleTrack(c)}}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||xl(r,e)))return n}if(e){for(let n=0;n<t.length;n++){const r=t[n];if(th(e.attrs,r.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return n}for(let n=0;n<t.length;n++){const r=t[n];if(th(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(Jv(n,e))return i}}return-1}onError(e,t){t.fatal||!t.context||t.context.type===It.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&&xl(e,i))return i;const n=Rr(e,this.tracksInGroup);if(n>-1){const r=this.tracksInGroup[n];return this.setSubtitleTrack(n),r}else{if(i)return null;{const r=Rr(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),o=e.details,u=o?.age;this.log(`Loading subtitle ${i} "${e.name}" lang:${e.lang} group:${n}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${u&&o.live?" age "+u.toFixed(1)+(o.type&&" "+o.type||""):""} ${r}`),this.hls.trigger(N.SUBTITLE_TRACK_LOADING,{url:r,id:i,groupId:n,deliveryDirectives:t||null,track:e})}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=Ap(e.textTracks),i=this.currentTrack;let n;if(i&&(n=t.filter(r=>Jv(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||!We(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(N.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:o,groupId:u="",name:c,type:d,url:f}=n;this.hls.trigger(N.SUBTITLE_TRACK_SWITCH,{id:o,groupId:u,name:c,type:d,url:f});const m=this.switchParams(n.url,i?.details,n.details);this.loadPlaylist(m)}}function p6(){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 Gd(s){let e=5381,t=s.length;for(;t;)e=e*33^s.charCodeAt(--t);return(e>>>0).toString()}const Yu=.025;let om=(function(s){return s[s.Point=0]="Point",s[s.Range=1]="Range",s})({});function m6(s,e,t){return`${s.identifier}-${t+1}-${Gd(e)}`}class g6{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 Ky(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=Ky(t,e);return t-i<.1}return!1}get resumptionOffset(){const e=this.resumeOffset,t=We(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 Ky(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)<Yu))}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"?om.Range:om.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 y6(this)}}function Ky(s,e){return s-e.start<e.duration/2&&!(Math.abs(s-(e.start+e.duration))<Yu)?e.start:e.start+e.duration}function kL(s,e,t){const i=new self.URL(s,t);return i.protocol!=="data:"&&i.searchParams.set("_HLS_primary_id",e),i}function Yy(s,e){for(;(t=s.assetList[++e])!=null&&t.error;)var t;return e}function y6(s){return`["${s.identifier}" ${s.cue.pre?"<pre>":s.cue.post?"<post>":""}${s.timelineStart.toFixed(2)}-${s.resumeTime.toFixed(2)}]`}function Iu(s){const e=s.timelineStart,t=s.duration||0;return`["${s.identifier}" ${e.toFixed(2)}-${(e+t).toFixed(2)}]`}class v6{constructor(e,t,i,n){this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(N.PLAYOUT_LIMIT_REACHED,{})};const r=this.hls=new e(t);this.interstitial=i,this.assetItem=n;const o=()=>{this.hasDetails=!0};r.once(N.LEVEL_LOADED,o),r.once(N.AUDIO_TRACK_LOADED,o),r.once(N.SUBTITLE_TRACK_LOADED,o),r.on(N.MEDIA_ATTACHING,(u,{media:c})=>{this.removeMediaListeners(),this.mediaAttached=c,this.interstitial.playoutLimit&&(c.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&r.on(N.BUFFER_APPENDED,()=>{const f=this.bufferedEnd;this.reachedPlayout(f)&&(this._bufferedEosTime=f,r.trigger(N.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=kL(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=vt.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=vt.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: ${Iu(this.assetItem)} ${(e=this.hls)==null?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}const S2=.033;class T6 extends jn{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={},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 o=i[r];if(!o.error){const u=o.timelineStart;if(t===u||t>u&&(t<u+(o.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,o=this.parseDateRanges(n,{url:i.url},t),u=Object.keys(n),c=r?r.filter(d=>!u.includes(d.identifier)):[];o.length&&o.sort((d,f)=>{const m=d.cue.pre,g=d.cue.post,v=f.cue.pre,b=f.cue.post;if(m&&!v)return-1;if(v&&!m||g&&!b)return 1;if(b&&!g)return-1;if(!m&&!v&&!g&&!b){const _=d.startTime,E=f.startTime;if(_!==E)return _-E}return d.dateRange.tagOrder-f.dateRange.tagOrder}),this.events=o,c.forEach(d=>{this.removeEvent(d)}),this.updateSchedule(e,c)}updateSchedule(e,t=[],i=!1){const n=this.events||[];if(n.length||t.length||this.length<2){const r=this.items,o=this.parseSchedule(n,e);(i||t.length||r?.length!==o.length||o.some((c,d)=>Math.abs(c.playout.start-r[d].playout.start)>.005||Math.abs(c.playout.end-r[d].playout.end)>.005))&&(this.items=o,this.onScheduleUpdate(t,r))}}parseDateRanges(e,t,i){const n=[],r=Object.keys(e);for(let o=0;o<r.length;o++){const u=r[o],c=e[u];if(c.isInterstitial){let d=this.eventMap[u];d?d.setDateRange(c):(d=new g6(c,t),this.eventMap[u]=d,i===!1&&(d.appendInPlace=i)),n.push(d)}}return n}parseSchedule(e,t){const i=[],n=t.main.details,r=n.live?1/0:n.edge;let o=0;if(e=e.filter(c=>!c.error&&!(c.cue.once&&c.hasPlayed)),e.length){this.resolveOffsets(e,t);let c=0,d=0;if(e.forEach((f,m)=>{const g=f.cue.pre,v=f.cue.post,b=e[m-1]||null,_=f.appendInPlace,E=v?r:f.startOffset,w=f.duration,I=f.timelineOccupancy===om.Range?w:0,L=f.resumptionOffset,F=b?.startTime===E,$=E+f.cumulativeDuration;let G=_?$+w:E+L;if(g||!v&&E<=0){const V=d;d+=I,f.timelineStart=$;const k=o;o+=w,i.push({event:f,start:$,end:G,playout:{start:k,end:o},integrated:{start:V,end:d}})}else if(E<=r){if(!F){const R=E-c;if(R>S2){const z=c,X=d;d+=R;const ee=o;o+=R;const le={previousEvent:e[m-1]||null,nextEvent:f,start:z,end:z+R,playout:{start:ee,end:o},integrated:{start:X,end:d}};i.push(le)}else R>0&&b&&(b.cumulativeDuration+=R,i[i.length-1].end=E)}v&&(G=$),f.timelineStart=$;const V=d;d+=I;const k=o;o+=w,i.push({event:f,start:$,end:G,playout:{start:k,end:o},integrated:{start:V,end:d}})}else return;const B=f.resumeTime;v||B>r?c=r:c=B}),c<r){var u;const f=c,m=d,g=r-c;d+=g;const v=o;o+=g,i.push({previousEvent:((u=i[i.length-1])==null?void 0:u.event)||null,nextEvent:null,start:c,end:f+g,playout:{start:v,end:o},integrated:{start:m,end:d}})}this.setDurations(r,o,d)}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,o=-1;e.forEach((u,c)=>{const d=u.cue.pre,f=u.cue.post,m=d?0:f?n:u.startTime;this.updateAssetDurations(u),o===m?u.cumulativeDuration=r:(r=0,o=m),!f&&u.snapOptions.in&&(u.resumeAnchor=Cl(null,i.fragments,u.startOffset+u.resumptionOffset,0,0)||void 0),u.appendInPlace&&!u.appendInPlaceStarted&&(this.primaryCanResumeInPlaceAt(u,t)||(u.appendInPlace=!1)),!u.appendInPlace&&c+1<e.length&&e[c+1].startTime-e[c].resumeTime<S2&&(e[c+1].appendInPlace=!1,e[c+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${u}`));const v=We(u.resumeOffset)?u.resumeOffset:u.duration;r+=v})}primaryCanResumeInPlaceAt(e,t){const i=e.resumeTime,n=e.startTime+e.resumptionOffset;return Math.abs(i-n)>Yu?(this.log(`"${e.identifier}" resumption ${i} not aligned with estimated timeline end ${n}`),!1):!Object.keys(t).some(o=>{const u=t[o].details,c=u.edge;if(i>=c)return this.log(`"${e.identifier}" resumption ${i} past ${o} playlist end ${c}`),!1;const d=Cl(null,u.fragments,i);if(!d)return this.log(`"${e.identifier}" resumption ${i} does not align with any fragments in ${o} playlist (${u.fragStart}-${u.fragmentEnd})`),!0;const f=o==="audio"?.175:0;return Math.abs(d.start-i)<Yu+f||Math.abs(d.end-i)<Yu+f?!1:(this.log(`"${e.identifier}" resumption ${i} not aligned with ${o} fragment bounds (${d.start}-${d.end} sn: ${d.sn} cc: ${d.cc})`),!0)})}updateAssetDurations(e){if(!e.assetListLoaded)return;const t=e.timelineStart;let i=0,n=!1,r=!1;for(let o=0;o<e.assetList.length;o++){const u=e.assetList[o],c=t+i;u.startOffset=i,u.timelineStart=c,n||(n=u.duration===null),r||(r=!!u.error);const d=u.error?0:u.duration||0;i+=d}n&&!r?e.duration=Math.max(i,e.duration):e.duration=i}removeEvent(e){e.reset(),delete this.eventMap[e.identifier]}}function Qn(s){return`[${s.event?'"'+s.event.identifier+'"':"primary"}: ${s.start.toFixed(2)}-${s.end.toFixed(2)}]`}class b6{constructor(e){this.hls=void 0,this.hls=e}destroy(){this.hls=null}loadAssetList(e,t){const i=e.assetListUrl;let n;try{n=kL(i,this.hls.sessionId,e.baseUrl)}catch(g){const v=this.assignAssetListError(e,ve.ASSET_LIST_LOAD_ERROR,g,i);this.hls.trigger(N.ERROR,v);return}t&&n.protocol!=="data:"&&n.searchParams.set("_HLS_start_offset",""+t);const r=this.hls.config,o=r.loader,u=new o(r),c={responseType:"json",url:n.href},d=r.interstitialAssetListLoadPolicy.default,f={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},m={onSuccess:(g,v,b,_)=>{const E=g.data,w=E?.ASSETS;if(!Array.isArray(w)){const I=this.assignAssetListError(e,ve.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),b.url,v,_);this.hls.trigger(N.ERROR,I);return}e.assetListResponse=E,this.hls.trigger(N.ASSET_LIST_LOADED,{event:e,assetListResponse:E,networkDetails:_})},onError:(g,v,b,_)=>{const E=this.assignAssetListError(e,ve.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${g.code} ${g.text} (${v.url})`),v.url,_,b);this.hls.trigger(N.ERROR,E)},onTimeout:(g,v,b)=>{const _=this.assignAssetListError(e,ve.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${v.url})`),v.url,g,b);this.hls.trigger(N.ERROR,_)}};return u.load(c,f,m),this.hls.trigger(N.ASSET_LIST_LOADING,{event:e}),u}assignAssetListError(e,t,i,n,r,o){return e.error=i,{type:nt.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:n,error:i,networkDetails:o,stats:r}}}function E2(s){var e;s==null||(e=s.play())==null||e.catch(()=>{})}function ap(s,e){return`[${s}] Advancing timeline position to ${e}`}class _6 extends jn{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 o=n<=-.01;this.timelinePos=i,this.bufferedPos=i;const u=this.playingItem;if(!u){this.checkBuffer();return}if(o&&this.schedule.resetErrorsInRange(i,i-n)&&this.updateSchedule(!0),this.checkBuffer(),o&&i<u.start||i>=u.end){var c;const v=this.findItemIndex(u);let b=this.schedule.findItemIndexAtTime(i);if(b===-1&&(b=v+(o?-1:1),this.log(`seeked ${o?"back ":""}to position not covered by schedule ${i} (resolving from ${v} to ${b})`)),!this.isInterstitial(u)&&(c=this.media)!=null&&c.paused&&(this.shouldPlay=!1),!o&&b>v){const _=this.schedule.findJumpRestrictedIndex(v+1,b);if(_>v){this.setSchedulePosition(_);return}}this.setSchedulePosition(b);return}const d=this.playingAsset;if(!d){if(this.playingLastItem&&this.isInterstitial(u)){const v=u.event.assetList[0];v&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(i,v))}return}const f=d.timelineStart,m=d.duration||0;if(o&&i<f||i>=f+m){var g;(g=u.event)!=null&&g.appendInPlace&&(this.clearAssetPlayers(u.event,u),this.flushFrontBuffer(i)),this.setScheduleToAssetAtTime(i,d)}},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 u=this.findItemIndex(n);this.setSchedulePosition(u+1)}const r=this.playingAsset;if(!r)return;const o=r.timelineStart+(r.duration||0);i>=o&&this.setScheduleToAssetAtTime(i,r)},this.onScheduleUpdate=(i,n)=>{const r=this.schedule;if(!r)return;const o=this.playingItem,u=r.events||[],c=r.items||[],d=r.durations,f=i.map(_=>_.identifier),m=!!(u.length||f.length);(m||n)&&this.log(`INTERSTITIALS_UPDATED (${u.length}): ${u}
Schedule: ${c.map(_=>Qn(_))} pos: ${this.timelinePos}`),f.length&&this.log(`Removed events ${f}`);let g=null,v=null;o&&(g=this.updateItem(o,this.timelinePos),this.itemsMatch(o,g)?this.playingItem=g:this.waitingItem=this.endedItem=null),this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);const b=this.bufferingItem;if(b&&(v=this.updateItem(b,this.bufferedPos),this.itemsMatch(b,v)?this.bufferingItem=v:b.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(b.event,null))),i.forEach(_=>{_.assetList.forEach(E=>{this.clearAssetPlayer(E.identifier,null)})}),this.playerQueue.forEach(_=>{if(_.interstitial.appendInPlace){const E=_.assetItem.timelineStart,w=_.timelineOffset-E;if(w)try{_.timelineOffset=E}catch(I){Math.abs(w)>Yu&&this.warn(`${I} ("${_.assetId}" ${_.timelineOffset}->${E})`)}}}),m||n){if(this.hls.trigger(N.INTERSTITIALS_UPDATED,{events:u.slice(0),schedule:c.slice(0),durations:d,removedIds:f}),this.isInterstitial(o)&&f.includes(o.event.identifier)){this.warn(`Interstitial "${o.event.identifier}" removed while playing`),this.primaryFallback(o.event);return}o&&this.trimInPlace(g,o),b&&v!==g&&this.trimInPlace(v,b),this.checkBuffer()}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new b6(e),this.schedule=new T6(this.onScheduleUpdate,e.logger),this.registerListeners()}registerListeners(){const e=this.hls;e&&(e.on(N.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(N.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(N.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(N.MANIFEST_LOADING,this.onManifestLoading,this),e.on(N.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(N.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(N.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(N.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(N.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(N.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(N.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(N.BUFFER_APPENDED,this.onBufferAppended,this),e.on(N.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(N.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(N.MEDIA_ENDED,this.onMediaEnded,this),e.on(N.ERROR,this.onError,this),e.on(N.DESTROYING,this.onDestroying,this))}unregisterListeners(){const e=this.hls;e&&(e.off(N.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(N.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(N.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(N.MANIFEST_LOADING,this.onManifestLoading,this),e.off(N.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(N.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(N.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(N.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(N.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(N.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(N.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(N.BUFFER_CODECS,this.onBufferCodecs,this),e.off(N.BUFFER_APPENDED,this.onBufferAppended,this),e.off(N.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(N.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(N.MEDIA_ENDED,this.onMediaEnded,this),e.off(N.ERROR,this.onError,this),e.off(N.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){tn(e,"play",this.onPlay),tn(e,"pause",this.onPause),tn(e,"seeking",this.onSeeking),tn(e,"timeupdate",this.onTimeupdate)}onMediaAttaching(e,t){const i=this.media=t.media;Fs(i,"seeking",this.onSeeking),Fs(i,"timeupdate",this.onTimeupdate),Fs(i,"play",this.onPlay),Fs(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=m=>m&&e.getAssetPlayer(m.identifier),n=(m,g,v,b,_)=>{if(m){let E=m[g].start;const w=m.event;if(w){if(g==="playout"||w.timelineOccupancy!==om.Point){const I=i(v);I?.interstitial===w&&(E+=I.assetItem.startOffset+I[_])}}else{const I=b==="bufferedPos"?o():e[b];E+=I-m.start}return E}return 0},r=(m,g)=>{var v;if(m!==0&&g!=="primary"&&(v=e.schedule)!=null&&v.length){var b;const _=e.schedule.findItemIndexAtTime(m),E=(b=e.schedule.items)==null?void 0:b[_];if(E){const w=E[g].start-E.start;return m+w}}return m},o=()=>{const m=e.bufferedPos;return m===Number.MAX_VALUE?u("primary"):Math.max(m,0)},u=m=>{var g,v;return(g=e.primaryDetails)!=null&&g.live?e.primaryDetails.edge:((v=e.schedule)==null?void 0:v.durations[m])||0},c=(m,g)=>{var v,b;const _=e.effectivePlayingItem;if(_!=null&&(v=_.event)!=null&&v.restrictions.skip||!e.schedule)return;e.log(`seek to ${m} "${g}"`);const E=e.effectivePlayingItem,w=e.schedule.findItemIndexAtTime(m,g),I=(b=e.schedule.items)==null?void 0:b[w],L=e.getBufferingPlayer(),F=L?.interstitial,$=F?.appendInPlace,G=E&&e.itemsMatch(E,I);if(E&&($||G)){const B=i(e.playingAsset),V=B?.media||e.primaryMedia;if(V){const k=g==="primary"?V.currentTime:n(E,g,e.playingAsset,"timelinePos","currentTime"),R=m-k,z=($?k:V.currentTime)+R;if(z>=0&&(!B||$||z<=B.duration)){V.currentTime=z;return}}}if(I){let B=m;if(g!=="primary"){const k=I[g].start,R=m-k;B=I.start+R}const V=!e.isInterstitial(I);if((!e.isInterstitial(E)||E.event.appendInPlace)&&(V||I.event.appendInPlace)){const k=e.media||($?L?.media:null);k&&(k.currentTime=B)}else if(E){const k=e.findItemIndex(E);if(w>k){const z=e.schedule.findJumpRestrictedIndex(k+1,w);if(z>k){e.setSchedulePosition(z);return}}let R=0;if(V)e.timelinePos=B,e.checkBuffer();else{const z=I.event.assetList,X=m-(I[g]||I).start;for(let ee=z.length;ee--;){const le=z[ee];if(le.duration&&X>=le.startOffset&&X<le.startOffset+le.duration){R=ee;break}}}e.setSchedulePosition(w,R)}}},d=()=>{const m=e.effectivePlayingItem;if(e.isInterstitial(m))return m;const g=t();return e.isInterstitial(g)?g:null},f={get bufferedEnd(){const m=t(),g=e.bufferingItem;if(g&&g===m){var v;return n(g,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-g.playout.start||((v=e.bufferingAsset)==null?void 0:v.startOffset)||0}return 0},get currentTime(){const m=d(),g=e.effectivePlayingItem;return g&&g===m?n(g,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-g.playout.start:0},set currentTime(m){const g=d(),v=e.effectivePlayingItem;v&&v===g&&c(m+v.playout.start,"playout")},get duration(){const m=d();return m?m.playout.end-m.playout.start:0},get assetPlayers(){var m;const g=(m=d())==null?void 0:m.event.assetList;return g?g.map(v=>e.getAssetPlayer(v.identifier)):[]},get playingIndex(){var m;const g=(m=d())==null?void 0:m.event;return g&&e.effectivePlayingAsset?g.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return d()}};return this.manager={get events(){var m;return((m=e.schedule)==null||(m=m.events)==null?void 0:m.slice(0))||[]},get schedule(){var m;return((m=e.schedule)==null||(m=m.items)==null?void 0:m.slice(0))||[]},get interstitialPlayer(){return d()?f:null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return t()},get bufferingIndex(){const m=t();return e.findItemIndex(m)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){const m=e.effectivePlayingItem;return e.findItemIndex(m)},primary:{get bufferedEnd(){return o()},get currentTime(){const m=e.timelinePos;return m>0?m:0},set currentTime(m){c(m,"primary")},get duration(){return u("primary")},get seekableStart(){var m;return((m=e.primaryDetails)==null?void 0:m.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(m){c(m,"integrated")},get duration(){return u("integrated")},get seekableStart(){var m;return r(((m=e.primaryDetails)==null?void 0:m.fragmentStart)||0,"integrated")}},skip:()=>{const m=e.effectivePlayingItem,g=m?.event;if(g&&!g.restrictions.skip){const v=e.findItemIndex(m);if(g.appendInPlace){const b=m.playout.start+m.event.duration;c(b+.001,"playout")}else e.advanceAfterAssetEnded(g,v,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||!We(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} ${ui(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 o=this.hls,u=e!==o,c=u&&e.interstitial.appendInPlace,d=(i=this.detachedData)==null?void 0:i.mediaSource;let f;if(o.media)c&&(r=o.transferMedia(),this.detachedData=r),f="Primary";else if(d){const b=this.getBufferingPlayer();b?(r=b.transferMedia(),f=`${b}`):f="detached MediaSource"}else f="detached media";if(!r){if(d)r=this.detachedData,this.log(`using detachedData: MediaSource ${ui(r)}`);else if(!this.detachedData||o.media===t){const b=this.playerQueue;b.length>1&&b.forEach(_=>{if(u&&_.interstitial.appendInPlace!==c){const E=_.interstitial;this.clearInterstitial(_.interstitial,null),E.appendInPlace=!1,E.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${E}`)}}),this.hls.detachMedia(),this.detachedData={media:t}}}const m=r&&"mediaSource"in r&&((n=r.mediaSource)==null?void 0:n.readyState)!=="closed",g=m&&r?r:t;this.log(`${m?"transfering MediaSource":"attaching media"} to ${u?e:"Primary"} from ${f} (media.currentTime: ${t.currentTime})`);const v=this.schedule;if(g===r&&v){const b=u&&e.assetId===v.assetIdAtEnd;g.overrides={duration:v.duration,endOfStream:!u||b,cueRemoval:!u}}e.attachMedia(g)}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(ap("checkStart",r)),this.timelinePos=r,t.length&&t[0].cue.pre){const o=e.findEventIndex(t[0].identifier);this.setSchedulePosition(o)}else if(r>=0||!this.primaryLive){const o=this.timelinePos=r>0?r:0,u=e.findItemIndexAtTime(o);this.setSchedulePosition(u)}}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=Yy(i,n);if(!i.isAssetPastPlayoutLimit(r))this.bufferedToEvent(e,r);else if(this.schedule){var o;const u=(o=this.schedule.items)==null?void 0:o[this.findItemIndex(e)+1];u&&this.bufferedToItem(u)}}advanceAfterAssetEnded(e,t,i){const n=Yy(e,i);if(e.isAssetPastPlayoutLimit(n)){if(this.schedule){const r=this.schedule.items;if(r){const o=t+1,u=r.length;if(o>=u){this.setSchedulePosition(-1);return}const c=e.resumeTime;this.timelinePos<c&&(this.log(ap("advanceAfterAssetEnded",c)),this.timelinePos=c,e.appendInPlace&&this.advanceInPlace(c),this.checkBuffer(this.bufferedPos<c)),this.setSchedulePosition(o)}}}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 o=i.findEventIndex(n),u=i.findAssetIndex(r,e);this.advanceAfterAssetEnded(r,o,u-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&&Qn(r)}) pos: ${this.timelinePos}`);const o=this.waitingItem||this.playingItem,u=this.playingLastItem;if(this.isInterstitial(o)){const f=o.event,m=this.playingAsset,g=m?.identifier,v=g?this.getAssetPlayer(g):null;if(v&&g&&(!this.eventItemsMatch(o,r)||t!==void 0&&g!==f.assetList[t].identifier)){var c;const b=f.findAssetIndex(m);if(this.log(`INTERSTITIAL_ASSET_ENDED ${b+1}/${f.assetList.length} ${Iu(m)}`),this.endedAsset=m,this.playingAsset=null,this.hls.trigger(N.INTERSTITIAL_ASSET_ENDED,{asset:m,assetListIndex:b,event:f,schedule:n.slice(0),scheduleIndex:e,player:v}),o!==this.playingItem){this.itemsMatch(o,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(f,this.findItemIndex(this.playingItem),b);return}this.retreiveMediaSource(g,r),v.media&&!((c=this.detachedData)!=null&&c.mediaSource)&&v.detachMedia()}if(!this.eventItemsMatch(o,r)&&(this.endedItem=o,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${f} ${Qn(o)}`),f.hasPlayed=!0,this.hls.trigger(N.INTERSTITIAL_ENDED,{event:f,schedule:n.slice(0),scheduleIndex:e}),f.cue.once)){var d;this.updateSchedule();const b=(d=this.schedule)==null?void 0:d.items;if(r&&b){const _=this.findItemIndex(r);this.advanceSchedule(_,b,t,o,u)}return}}this.advanceSchedule(e,n,t,o,u)}advanceSchedule(e,t,i,n,r){const o=this.schedule;if(!o)return;const u=t[e]||null,c=this.primaryMedia,d=this.playerQueue;if(d.length&&d.forEach(f=>{const m=f.interstitial,g=o.findEventIndex(m.identifier);(g<e||g>e+1)&&this.clearInterstitial(m,u)}),this.isInterstitial(u)){this.timelinePos=Math.min(Math.max(this.timelinePos,u.start),u.end);const f=u.event;if(i===void 0){i=o.findAssetIndex(f,this.timelinePos);const b=Yy(f,i-1);if(f.isAssetPastPlayoutLimit(b)||f.appendInPlace&&this.timelinePos===u.end){this.advanceAfterAssetEnded(f,e,i);return}i=b}const m=this.waitingItem;this.assetsBuffered(u,c)||this.setBufferingItem(u);let g=this.preloadAssets(f,i);if(this.eventItemsMatch(u,m||n)||(this.waitingItem=u,this.log(`INTERSTITIAL_STARTED ${Qn(u)} ${f.appendInPlace?"append in place":""}`),this.hls.trigger(N.INTERSTITIAL_STARTED,{event:f,schedule:t.slice(0),scheduleIndex:e})),!f.assetListLoaded){this.log(`Waiting for ASSET-LIST to complete loading ${f}`);return}if(f.assetListLoader&&(f.assetListLoader.destroy(),f.assetListLoader=void 0),!c){this.log(`Waiting for attachMedia to start Interstitial ${f}`);return}this.waitingItem=this.endedItem=null,this.playingItem=u;const v=f.assetList[i];if(!v){this.advanceAfterAssetEnded(f,e,i||0);return}if(g||(g=this.getAssetPlayer(v.identifier)),g===null||g.destroyed){const b=f.assetList.length;this.warn(`asset ${i+1}/${b} player destroyed ${f}`),g=this.createAssetPlayer(f,v,i),g.loadSource()}if(!this.eventItemsMatch(u,this.bufferingItem)&&f.appendInPlace&&this.isAssetBuffered(v))return;this.startAssetPlayer(g,i,t,e,c),this.shouldPlay&&E2(g.media)}else u?(this.resumePrimary(u,e,n),this.shouldPlay&&E2(this.hls.media)):r&&this.isInterstitial(n)&&(this.endedItem=null,this.playingItem=n,n.event.appendInPlace||this.attachPrimary(o.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 ${Qn(e)}`),!((n=this.detachedData)!=null&&n.mediaSource)){let u=this.timelinePos;(u<e.start||u>=e.end)&&(u=this.getPrimaryResumption(e,t),this.log(ap("resumePrimary",u)),this.timelinePos=u),this.attachPrimary(u,e)}if(!i)return;const o=(r=this.schedule)==null?void 0:r.items;o&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${Qn(e)}`),this.hls.trigger(N.INTERSTITIALS_PRIMARY_RESUMED,{schedule:o.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:vt.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(ap("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(N.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(N.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=Qt(Qt({},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=Qt(Qt({},this.altSelection),{},{audio:i});return}const r=Qt(Qt({},n),{},{audio:i});this.mediaSelection=r}onSubtitleTrackUpdated(e,t){const i=this.hls.subtitleTracks[t.id],n=this.mediaSelection;if(!n){this.altSelection=Qt(Qt({},this.altSelection),{},{subtitles:i});return}const r=Qt(Qt({},n),{},{subtitles:i});this.mediaSelection=r}onAudioTrackSwitching(e,t){const i=O1(t);this.playerQueue.forEach(({hls:n})=>n&&(n.setAudioOption(t)||n.setAudioOption(i)))}onSubtitleTrackSwitch(e,t){const i=O1(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 o=this.schedule.findEventIndex(r.identifier),u=(i=this.schedule.items)==null?void 0:i[o];this.isInterstitial(u)&&this.eventItemsMatch(u,this.bufferingItem)&&this.bufferedToItem(u,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,o)=>{e.event.isAssetPastPlayoutLimit(o)&&this.clearAssetPlayer(r.identifier,null)});const i=e.end+.25,n=vt.bufferInfo(this.primaryMedia,i,0);(n.end>i||(n.nextStart||0)>i)&&(this.log(`trim buffered interstitial ${Qn(e)} (was ${Qn(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=vt.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 o=this.playingItem,u=this.findItemIndex(o);let c=n.findItemIndexAtTime(e);if(this.bufferedPos<e){var d;const f=this.findItemIndex(r),m=Math.min(f+1,t.length-1),g=t[m];if((c===-1&&r&&e>=r.end||(d=g.event)!=null&&d.appendInPlace&&e+.01>=g.start)&&(c=m),this.isInterstitial(r)){const v=r.event;if(m-u>1&&v.appendInPlace===!1||v.assetList.length===0&&v.assetListLoader)return}if(this.bufferedPos=e,c>f&&c>u)this.bufferedToItem(g);else{const v=this.primaryDetails;this.primaryLive&&v&&e>v.edge-v.targetduration&&g.start<v.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(g)&&this.preloadAssets(g.event,0)}}else i&&o&&!this.itemsMatch(o,r)&&(c===u?this.bufferedToItem(o):c===u+1&&this.bufferedToItem(t[c]))}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 o=this.isInterstitial(e),u=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));const c=u?u.remaining:t?t.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${Qn(e)}`+(t?` (${c.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(o){const d=i.findAssetIndex(e.event,this.bufferedPos);e.event.assetList.forEach((f,m)=>{const g=this.getAssetPlayer(f.identifier);g&&(m===d&&g.loadSource(),g.resumeBuffering())})}else this.hls.resumeBuffering(),this.playerQueue.forEach(d=>d.pauseBuffering());this.hls.trigger(N.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 o=this.preloadAssets(i,t);if(o!=null&&o.interstitial.appendInPlace){const u=this.primaryMedia;u&&this.bufferAssetPlayer(o,u)}}}preloadAssets(e,t){const i=e.assetUrl,n=e.assetList.length,r=n===0&&!e.assetListLoader,o=e.cue.once;if(r){const c=e.timelineStart;if(e.appendInPlace){var u;const g=this.playingItem;!this.isInterstitial(g)&&(g==null||(u=g.nextEvent)==null?void 0:u.identifier)===e.identifier&&this.flushFrontBuffer(c+.25)}let d,f=0;if(!this.playingItem&&this.primaryLive&&(f=this.hls.startPosition,f===-1&&(f=this.hls.liveSyncPosition||0)),f&&!(e.cue.pre||e.cue.post)){const g=f-c;g>0&&(d=Math.round(g*1e3)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${i?1:n} ${e}${d?` live-start: ${f} start-offset: ${d}`:""}`),i)return this.createAsset(e,0,0,c,e.duration,i);const m=this.assetListLoader.loadAssetList(e,d);m&&(e.assetListLoader=m)}else if(!o&&n){for(let d=t;d<n;d++){const f=e.assetList[d],m=this.getAssetPlayerQueueIndex(f.identifier);(m===-1||this.playerQueue[m].destroyed)&&!f.error&&this.createAssetPlayer(e,f,d)}const c=e.assetList[t];if(c){const d=this.getAssetPlayer(c.identifier);return d&&d.loadSource(),d}}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(N.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,o){const u={parentIdentifier:e.identifier,identifier:m6(e,o,t),duration:r,startOffset:i,timelineStart:n,uri:o};return this.createAssetPlayer(e,u,t)}createAssetPlayer(e,t,i){const n=this.hls,r=n.userConfig;let o=r.videoPreference;const u=n.loadLevelObj||n.levels[n.currentLevel];(o||u)&&(o=ni({},o),u.videoCodec&&(o.videoCodec=u.videoCodec),u.videoRange&&(o.allowedVideoRanges=[u.videoRange]));const c=n.audioTracks[n.audioTrack],d=n.subtitleTracks[n.subtitleTrack];let f=0;if(this.primaryLive||e.appendInPlace){const F=this.timelinePos-t.timelineStart;if(F>1){const $=t.duration;$&&F<$&&(f=F)}}const m=t.identifier,g=Qt(Qt({},r),{},{maxMaxBufferLength:Math.min(180,n.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:n.sessionId,assetPlayerId:m,abrEwmaDefaultEstimate:n.bandwidthEstimate,interstitialsController:void 0,startPosition:f,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:o,audioPreference:c||r.audioPreference,subtitlePreference:d||r.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(g.timelineOffset=t.timelineStart));const v=g.cmcd;v!=null&&v.sessionId&&v.contentId&&(g.cmcd=ni({},v,{contentId:Gd(t.uri)})),this.getAssetPlayer(m)&&this.warn(`Duplicate date range identifier ${e} and asset ${m}`);const b=new v6(this.HlsPlayerClass,g,e,t);this.playerQueue.push(b),e.assetList[i]=t;let _=!0;const E=F=>{if(F.live){var $;const V=new Error(`Interstitials MUST be VOD assets ${e}`),k={fatal:!0,type:nt.OTHER_ERROR,details:ve.INTERSTITIAL_ASSET_ITEM_ERROR,error:V},R=(($=this.schedule)==null?void 0:$.findEventIndex(e.identifier))||-1;this.handleAssetItemError(k,e,R,i,V.message);return}const G=F.edge-F.fragmentStart,B=t.duration;(_||B===null||G>B)&&(_=!1,this.log(`Interstitial asset "${m}" duration change ${B} > ${G}`),t.duration=G,this.updateSchedule())};b.on(N.LEVEL_UPDATED,(F,{details:$})=>E($)),b.on(N.LEVEL_PTS_UPDATED,(F,{details:$})=>E($)),b.on(N.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());const w=(F,$)=>{const G=this.getAssetPlayer(m);if(G&&$.tracks){G.off(N.BUFFER_CODECS,w),G.tracks=$.tracks;const B=this.primaryMedia;this.bufferingAsset===G.assetItem&&B&&!G.media&&this.bufferAssetPlayer(G,B)}};b.on(N.BUFFER_CODECS,w);const I=()=>{var F;const $=this.getAssetPlayer(m);if(this.log(`buffered to end of asset ${$}`),!$||!this.schedule)return;const G=this.schedule.findEventIndex(e.identifier),B=(F=this.schedule.items)==null?void 0:F[G];this.isInterstitial(B)&&this.advanceAssetBuffering(B,t)};b.on(N.BUFFERED_TO_END,I);const L=F=>()=>{if(!this.getAssetPlayer(m)||!this.schedule)return;this.shouldPlay=!0;const G=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,G,F)};return b.once(N.MEDIA_ENDED,L(i)),b.once(N.PLAYOUT_LIMIT_REACHED,L(1/0)),b.on(N.ERROR,(F,$)=>{if(!this.schedule)return;const G=this.getAssetPlayer(m);if($.details===ve.BUFFER_STALLED_ERROR){if(G!=null&&G.appendInPlace){this.handleInPlaceStall(e);return}this.onTimeupdate(),this.checkBuffer(!0);return}this.handleAssetItemError($,e,this.schedule.findEventIndex(e.identifier),i,`Asset player error ${$.error} ${e}`)}),b.on(N.DESTROYING,()=>{if(!this.getAssetPlayer(m)||!this.schedule)return;const $=new Error(`Asset player destroyed unexpectedly ${m}`),G={fatal:!0,type:nt.OTHER_ERROR,details:ve.INTERSTITIAL_ASSET_ITEM_ERROR,error:$};this.handleAssetItemError(G,e,this.schedule.findEventIndex(e.identifier),i,$.message)}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${Iu(t)}`),this.hls.trigger(N.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:i,event:e,player:b}),b}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&&Qn(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:o,assetItem:u,assetId:c}=e,d=o.assetList.length,f=this.playingAsset;this.endedAsset=null,this.playingAsset=u,(!f||f.identifier!==c)&&(f&&(this.clearAssetPlayer(f.identifier,i[n]),delete f.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${d} ${Iu(u)}`),this.hls.trigger(N.INTERSTITIAL_ASSET_STARTED,{asset:u,assetListIndex:t,event:o,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:o}=e,u=this.schedule.findEventIndex(r.identifier),c=(i=this.schedule.items)==null?void 0:i[u];if(!c)return;e.loadSource(),this.setBufferingItem(c),this.bufferingAsset=o;const d=this.getBufferingPlayer();if(d===e)return;const f=r.appendInPlace;if(f&&d?.interstitial.appendInPlace===!1)return;const m=d?.tracks||((n=this.detachedData)==null?void 0:n.tracks)||this.requiredTracks;if(f&&o!==this.playingAsset){if(!e.tracks){this.log(`Waiting for track info before buffering ${e}`);return}if(m&&!fw(m,e.tracks)){const g=new Error(`Asset ${Iu(o)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(m)}')`),v={fatal:!0,type:nt.OTHER_ERROR,details:ve.INTERSTITIAL_ASSET_ITEM_ERROR,error:g},b=r.findAssetIndex(o);this.handleAssetItemError(v,r,u,b,g.message);return}}this.transferMediaTo(e,t)}handleInPlaceStall(e){const t=this.schedule,i=this.primaryMedia;if(!t||!i)return;const n=i.currentTime,r=t.findAssetIndex(e,n),o=e.assetList[r];if(o){const u=this.getAssetPlayer(o.identifier);if(u){const c=u.currentTime||n-o.timelineStart,d=u.duration-c;if(this.warn(`Stalled at ${c} of ${c+d} in ${u} ${e} (media.currentTime: ${n})`),c&&(d/i.playbackRate<.5||u.bufferedInPlaceToEnd(i))&&u.hls){const f=t.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,f,r)}}}}advanceInPlace(e){const t=this.primaryMedia;t&&t.currentTime<e&&(t.currentTime=e)}handleAssetItemError(e,t,i,n,r){if(e.details===ve.BUFFER_STALLED_ERROR)return;const o=t.assetList[n]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${o&&Iu(o)} ${e.error}`),!this.schedule)return;const u=o?.identifier||"",c=this.getAssetPlayerQueueIndex(u),d=this.playerQueue[c]||null,f=this.schedule.items,m=ni({},e,{fatal:!1,errorAction:qu(!0),asset:o,assetListIndex:n,event:t,schedule:f,scheduleIndex:i,player:d});if(this.hls.trigger(N.INTERSTITIAL_ASSET_ERROR,m),!e.fatal)return;const g=this.playingAsset,v=this.bufferingAsset,b=new Error(r);if(o&&(this.clearAssetPlayer(u,null),o.error=b),!t.assetList.some(_=>!_.error))t.error=b;else for(let _=n;_<t.assetList.length;_++)this.resetAssetPlayer(t.assetList[_].identifier);this.updateSchedule(!0),t.error?this.primaryFallback(t):g&&g.identifier===u?this.advanceAfterAssetEnded(t,i,n):v&&v.identifier===u&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,v)}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: ${Qn(i)} error: ${e.error}`),n===-1&&(n=this.hls.startPosition);const o=this.updateItem(i,n);this.itemsMatch(i,o)&&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,o=r.identifier,u=t.assetListResponse.ASSETS;if(!((i=this.schedule)!=null&&i.hasEvent(o)))return;const c=r.timelineStart,d=r.duration;let f=0;u.forEach((_,E)=>{const w=parseFloat(_.DURATION);this.createAsset(r,E,f,c+f,w,_.URI),f+=w}),r.duration=f,this.log(`Loaded asset-list with duration: ${f} (was: ${d}) ${r}`);const m=this.waitingItem,g=m?.event.identifier===o;this.updateSchedule();const v=(n=this.bufferingItem)==null?void 0:n.event;if(g){var b;const _=this.schedule.findEventIndex(o),E=(b=this.schedule.items)==null?void 0:b[_];if(E){if(!this.playingItem&&this.timelinePos>E.end&&this.schedule.findItemIndexAtTime(this.timelinePos)!==_){r.error=new Error(`Interstitial ${u.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(E)}this.setSchedulePosition(_)}else if(v?.identifier===o){const _=r.assetList[0];if(_){const E=this.getAssetPlayer(_.identifier);if(v.appendInPlace){const w=this.primaryMedia;E&&w&&this.bufferAssetPlayer(E,w)}else E&&E.loadSource()}}}onError(e,t){if(this.schedule)switch(t.details){case ve.ASSET_LIST_PARSING_ERROR:case ve.ASSET_LIST_LOAD_ERROR:case ve.ASSET_LIST_LOAD_TIMEOUT:{const i=t.interstitial;i&&(this.updateSchedule(!0),this.primaryFallback(i));break}case ve.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 A2=500;class x6 extends lb{constructor(e,t,i){super(e,t,i,"subtitle-stream-controller",Je.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(N.LEVEL_LOADED,this.onLevelLoaded,this),e.on(N.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(N.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(N.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(N.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(N.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(N.LEVEL_LOADED,this.onLevelLoaded,this),e.off(N.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(N.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(N.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(N.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(N.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(e,t){this.stopLoad(),this.state=Pe.IDLE,this.setInterval(A2),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)||(ji(i)&&(this.fragPrevious=i),this.state=Pe.IDLE),!n)return;const r=this.tracksBuffered[this.currentTrackId];if(!r)return;let o;const u=i.start;for(let d=0;d<r.length;d++)if(u>=r[d].start&&u<=r[d].end){o=r[d];break}const c=i.start+i.duration;o?o.end=c:(o={start:u,end:c},r.push(o)),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(o=>{for(let u=0;u<o.length;){if(o[u].end<=r){o.shift();continue}else if(o[u].start<r)o[u].start=r;else break;u++}}),this.fragmentTracker.removeFragmentsInRange(i,r,Je.SUBTITLE)}}onError(e,t){const i=t.frag;i?.type===Je.SUBTITLE&&(t.details===ve.FRAG_GAP&&this.fragmentTracker.fragBuffered(i,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==Pe.STOPPED&&(this.state=Pe.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&gL(this.levels,t)){this.levels=t.map(i=>new Qd(i));return}this.tracksBuffered=[],this.levels=t.map(i=>{const n=new Qd(i);return this.tracksBuffered[n.id]=[],n}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Je.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!==Pe.STOPPED&&this.setInterval(A2)}onSubtitleTrackLoaded(e,t){var i;const{currentTrackId:n,levels:r}=this,{details:o,id:u}=t;if(!r){this.warn(`Subtitle tracks were reset while loading level ${u}`);return}const c=r[u];if(u>=r.length||!c)return;this.log(`Subtitle track ${u} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""},duration:${o.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let d=0;if(o.live||(i=c.details)!=null&&i.live){if(o.deltaUpdateFailed)return;const m=this.mainDetails;if(!m){this.startFragRequested=!1;return}const g=m.fragments[0];if(!c.details)o.hasProgramDateTime&&m.hasProgramDateTime?(rm(o,m),d=o.fragmentStart):g&&(d=g.start,Xv(o,d));else{var f;d=this.alignPlaylists(o,c.details,(f=this.levelLastLoaded)==null?void 0:f.details),d===0&&g&&(d=g.start,Xv(o,d))}m&&!this.startFragRequested&&this.setStartPosition(m,d)}c.details=o,this.levelLastLoaded=c,u===n&&(this.hls.trigger(N.SUBTITLE_TRACK_UPDATED,{details:o,id:u,groupId:t.groupId}),this.tick(),o.live&&!this.fragCurrent&&this.media&&this.state===Pe.IDLE&&(Cl(null,o.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),c.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&&zu(n.method)){const o=performance.now();this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer,ab(n.method)).catch(u=>{throw r.trigger(N.ERROR,{type:nt.MEDIA_ERROR,details:ve.FRAG_DECRYPT_ERROR,fatal:!1,error:u,reason:u.message,frag:t}),u}).then(u=>{const c=performance.now();r.trigger(N.FRAG_DECRYPTED,{frag:t,payload:u,stats:{tstart:o,tdecrypt:c}})}).catch(u=>{this.warn(`${u.name}: ${u.message}`),this.state=Pe.IDLE})}}doTick(){if(!this.media){this.state=Pe.IDLE;return}if(this.state===Pe.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(),o=vt.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],r,n.maxBufferHole),{end:u,len:c}=o,d=i.details,f=this.hls.maxBufferLength+d.levelTargetDuration;if(c>f)return;const m=d.fragments,g=m.length,v=d.edge;let b=null;const _=this.fragPrevious;if(u<v){const I=n.maxFragLookUpTolerance,L=u>v-I?0:I;b=Cl(_,m,Math.max(m[0].start,u),L),!b&&_&&_.start<m[0].start&&(b=m[0])}else b=m[g-1];if(b=this.filterReplacedPrimary(b,i.details),!b)return;const E=b.sn-d.startSN,w=m[E-1];if(w&&w.cc===b.cc&&this.fragmentTracker.getState(w)===Ji.NOT_LOADED&&(b=w),this.fragmentTracker.getState(b)===Ji.NOT_LOADED){const I=this.mapToInitFragWhenRequired(b);I&&this.loadFragment(I,i,u)}}}loadFragment(e,t,i){ji(e)?super.loadFragment(e,t,i):this._loadInitSegment(e,t)}get mediaBufferTimeRanges(){return new S6(this.tracksBuffered[this.currentTrackId]||[])}}class S6{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 E6={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},RL=s=>String.fromCharCode(E6[s]||s),Zn=15,da=100,A6={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},C6={17:2,18:4,21:6,22:8,23:10,19:13,20:15},D6={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},w6={25:2,26:4,29:6,30:8,31:10,27:13,28:15},L6=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class I6{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const i=typeof t=="function"?t():t;Zt.log(`${this.time} [${e}] ${i}`)}}}const ll=function(e){const t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t};class OL{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 k6{constructor(){this.uchar=" ",this.penState=new OL}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 R6{constructor(e){this.chars=[],this.pos=0,this.currPenState=new OL,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<da;t++)this.chars.push(new k6);this.logger=e}equals(e){for(let t=0;t<da;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<da;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<da;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>da&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=da)}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=RL(e);if(this.pos>=da){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<da;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<da;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 Wy{constructor(e){this.rows=[],this.currRow=Zn-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<Zn;t++)this.rows.push(new R6(e));this.logger=e}reset(){for(let e=0;e<Zn;e++)this.rows[e].clear();this.currRow=Zn-1}equals(e){let t=!0;for(let i=0;i<Zn;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}copy(e){for(let t=0;t<Zn;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<Zn;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 = "+ui(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let u=0;u<Zn;u++)this.rows[u].clear();const r=this.currRow+1-this.nrRollUpRows,o=this.lastOutputScreen;if(o){const u=o.rows[r].cueStartTime,c=this.logger.time;if(u!==null&&c!==null&&u<c)for(let d=0;d<this.nrRollUpRows;d++)this.rows[t-this.nrRollUpRows+d+1].copy(o.rows[r+d])}}this.currRow=t;const i=this.rows[this.currRow];if(e.indent!==null){const r=e.indent,o=Math.max(r-1,0);i.setCursor(e.indent),e.color=i.chars[o].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 = "+ui(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<Zn;r++){const o=this.rows[r].getTextString();o&&(n=r+1,e?t.push("Row "+n+": '"+o+"'"):t.push(o.trim()))}return t.length>0&&(e?i="["+t.join(" | ")+"]":i=t.join(`
`)),i}getTextAndFormat(){return this.rows}}class C2{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 Wy(i),this.nonDisplayedMemory=new Wy(i),this.lastOutputScreen=new Wy(i),this.currRollUpRow=this.displayedMemory.rows[Zn-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[Zn-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: "+ui(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 D2{constructor(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=P6(),this.logger=void 0;const n=this.logger=new I6;this.channels=[null,new C2(e,t,n),new C2(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 o=!1,u=null;if(n===0&&r===0)continue;this.logger.log(3,()=>"["+ll([t[i],t[i+1]])+"] -> ("+ll([n,r])+")");const c=this.cmdHistory;if(n>=16&&n<=31){if(O6(n,r,c)){op(null,null,c),this.logger.log(3,()=>"Repeated command ("+ll([n,r])+") is dropped");continue}op(n,r,this.cmdHistory),o=this.parseCmd(n,r),o||(o=this.parseMidrow(n,r)),o||(o=this.parsePAC(n,r)),o||(o=this.parseBackgroundAttributes(n,r))}else op(null,null,c);if(!o&&(u=this.parseChars(n,r),u)){const f=this.currentChannel;f&&f>0?this.channels[f].insertChars(u):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!o&&!u&&this.logger.log(2,()=>"Couldn't parse cleaned data "+ll([n,r])+" orig: "+ll([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,o=this.channels[r];return e===20||e===21||e===28||e===29?t===32?o.ccRCL():t===33?o.ccBS():t===34?o.ccAOF():t===35?o.ccAON():t===36?o.ccDER():t===37?o.ccRU(2):t===38?o.ccRU(3):t===39?o.ccRU(4):t===40?o.ccFON():t===41?o.ccRDC():t===42?o.ccTR():t===43?o.ccRTD():t===44?o.ccEDM():t===45?o.ccCR():t===46?o.ccENM():t===47&&o.ccEOC():o.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 ("+ll([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 o=e<=23?1:2;t>=64&&t<=95?i=o===1?A6[e]:D6[e]:i=o===1?C6[e]:w6[e];const u=this.channels[o];return u?(u.setPAC(this.interpretPAC(i,t)),this.currentChannel=o,!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 o;r===17?o=t+80:r===18?o=t+112:o=t+144,this.logger.log(2,()=>"Special char '"+RL(o)+"' in channel "+i),n=[o]}else e>=32&&e<=127&&(n=t===0?[e]:[e,t]);return n&&this.logger.log(3,()=>"Char codes = "+ll(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 o={};e===16||e===24?(r=Math.floor((t-32)/2),o.background=L6[r],t%2===1&&(o.background=o.background+"_semi")):t===45?o.background="transparent":(o.foreground="black",t===47&&(o.underline=!0));const u=e<=23?1:2;return this.channels[u].setBkgData(o),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}op(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 op(s,e,t){t.a=s,t.b=e}function O6(s,e,t){return t.a===s&&t.b===e}function P6(){return{a:null,b:null}}var bb=(function(){if(nm!=null&&nm.VTTCue)return self.VTTCue;const s=["","lr","rl"],e=["start","middle","end","left","right"];function t(u,c){if(typeof c!="string"||!Array.isArray(u))return!1;const d=c.toLowerCase();return~u.indexOf(d)?d:!1}function i(u){return t(s,u)}function n(u){return t(e,u)}function r(u,...c){let d=1;for(;d<arguments.length;d++){const f=arguments[d];for(const m in f)u[m]=f[m]}return u}function o(u,c,d){const f=this,m={enumerable:!0};f.hasBeenReset=!1;let g="",v=!1,b=u,_=c,E=d,w=null,I="",L=!0,F="auto",$="start",G=50,B="middle",V=50,k="middle";Object.defineProperty(f,"id",r({},m,{get:function(){return g},set:function(R){g=""+R}})),Object.defineProperty(f,"pauseOnExit",r({},m,{get:function(){return v},set:function(R){v=!!R}})),Object.defineProperty(f,"startTime",r({},m,{get:function(){return b},set:function(R){if(typeof R!="number")throw new TypeError("Start time must be set to a number.");b=R,this.hasBeenReset=!0}})),Object.defineProperty(f,"endTime",r({},m,{get:function(){return _},set:function(R){if(typeof R!="number")throw new TypeError("End time must be set to a number.");_=R,this.hasBeenReset=!0}})),Object.defineProperty(f,"text",r({},m,{get:function(){return E},set:function(R){E=""+R,this.hasBeenReset=!0}})),Object.defineProperty(f,"region",r({},m,{get:function(){return w},set:function(R){w=R,this.hasBeenReset=!0}})),Object.defineProperty(f,"vertical",r({},m,{get:function(){return I},set:function(R){const z=i(R);if(z===!1)throw new SyntaxError("An invalid or illegal string was specified.");I=z,this.hasBeenReset=!0}})),Object.defineProperty(f,"snapToLines",r({},m,{get:function(){return L},set:function(R){L=!!R,this.hasBeenReset=!0}})),Object.defineProperty(f,"line",r({},m,{get:function(){return F},set:function(R){if(typeof R!="number"&&R!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");F=R,this.hasBeenReset=!0}})),Object.defineProperty(f,"lineAlign",r({},m,{get:function(){return $},set:function(R){const z=n(R);if(!z)throw new SyntaxError("An invalid or illegal string was specified.");$=z,this.hasBeenReset=!0}})),Object.defineProperty(f,"position",r({},m,{get:function(){return G},set:function(R){if(R<0||R>100)throw new Error("Position must be between 0 and 100.");G=R,this.hasBeenReset=!0}})),Object.defineProperty(f,"positionAlign",r({},m,{get:function(){return B},set:function(R){const z=n(R);if(!z)throw new SyntaxError("An invalid or illegal string was specified.");B=z,this.hasBeenReset=!0}})),Object.defineProperty(f,"size",r({},m,{get:function(){return V},set:function(R){if(R<0||R>100)throw new Error("Size must be between 0 and 100.");V=R,this.hasBeenReset=!0}})),Object.defineProperty(f,"align",r({},m,{get:function(){return k},set:function(R){const z=n(R);if(!z)throw new SyntaxError("An invalid or illegal string was specified.");k=z,this.hasBeenReset=!0}})),f.displayState=void 0}return o.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},o})();class M6{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function PL(s){function e(i,n,r,o){return(i|0)*3600+(n|0)*60+(r|0)+parseFloat(o||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 N6{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 ML(s,e,t,i){const n=i?s.split(i):[s];for(const r in n){if(typeof n[r]!="string")continue;const o=n[r].split(t);if(o.length!==2)continue;const u=o[0],c=o[1];e(u,c)}}const nT=new bb(0,0,""),lp=nT.align==="middle"?"middle":"center";function B6(s,e,t){const i=s;function n(){const u=PL(s);if(u===null)throw new Error("Malformed timestamp: "+i);return s=s.replace(/^[^\sa-zA-Z-]+/,""),u}function r(u,c){const d=new N6;ML(u,function(g,v){let b;switch(g){case"region":for(let _=t.length-1;_>=0;_--)if(t[_].id===v){d.set(g,t[_].region);break}break;case"vertical":d.alt(g,v,["rl","lr"]);break;case"line":b=v.split(","),d.integer(g,b[0]),d.percent(g,b[0])&&d.set("snapToLines",!1),d.alt(g,b[0],["auto"]),b.length===2&&d.alt("lineAlign",b[1],["start",lp,"end"]);break;case"position":b=v.split(","),d.percent(g,b[0]),b.length===2&&d.alt("positionAlign",b[1],["start",lp,"end","line-left","line-right","auto"]);break;case"size":d.percent(g,v);break;case"align":d.alt(g,v,["start",lp,"end","left","right"]);break}},/:/,/\s/),c.region=d.get("region",null),c.vertical=d.get("vertical","");let f=d.get("line","auto");f==="auto"&&nT.line===-1&&(f=-1),c.line=f,c.lineAlign=d.get("lineAlign","start"),c.snapToLines=d.get("snapToLines",!0),c.size=d.get("size",100),c.align=d.get("align",lp);let m=d.get("position","auto");m==="auto"&&nT.position===50&&(m=c.align==="start"||c.align==="left"?0:c.align==="end"||c.align==="right"?100:50),c.position=m}function o(){s=s.replace(/^\s+/,"")}if(o(),e.startTime=n(),o(),s.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);s=s.slice(3),o(),e.endTime=n(),o(),r(s,e)}function NL(s){return s.replace(/<br(?: \/)?>/gi,`
`)}class F6{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new M6,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,o=0;for(r=NL(r);o<r.length&&r[o]!=="\r"&&r[o]!==`
`;)++o;const u=r.slice(0,o);return r[o]==="\r"&&++o,r[o]===`
`&&++o,t.buffer=r.slice(o),u}function n(r){ML(r,function(o,u){},/:/)}try{let r="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;r=i();const u=r.match(/^()?WEBVTT([ \t].*)?$/);if(!(u!=null&&u[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let o=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(o?o=!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 bb(0,0,""),t.state="CUE",r.indexOf("-->")===-1){t.cue.id=r;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{B6(r,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const u=r.indexOf("-->")!==-1;if(!r||u&&(o=!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+=`
`),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+=`
`,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 U6=/\r\n|\n\r|\n|\r/g,Xy=function(e,t,i=0){return e.slice(i,i+t.length)===t},$6=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(!We(t)||!We(i)||!We(n)||!We(r))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=60*1e3*n,t+=3600*1e3*r,t};function _b(s,e,t){return Gd(s.toString())+Gd(e.toString())+Gd(t)}const j6=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(;(o=r)!=null&&o.new;){var o;e.ccOffset+=n.start-r.start,n.new=!1,n=r,r=e[n.prevCC]}e.presentationOffset=i};function H6(s,e,t,i,n,r,o){const u=new F6,c=xn(new Uint8Array(s)).trim().replace(U6,`
`).split(`
`),d=[],f=e?Y8(e.baseTime,e.timescale):0;let m="00:00.000",g=0,v=0,b,_=!0;u.oncue=function(E){const w=t[i];let I=t.ccOffset;const L=(g-f)/9e4;if(w!=null&&w.new&&(v!==void 0?I=t.ccOffset=w.start:j6(t,i,L)),L){if(!e){b=new Error("Missing initPTS for VTT MPEGTS");return}I=L-t.presentationOffset}const F=E.endTime-E.startTime,$=bn((E.startTime+I-v)*9e4,n*9e4)/9e4;E.startTime=Math.max($,0),E.endTime=Math.max($+F,0);const G=E.text.trim();E.text=decodeURIComponent(encodeURIComponent(G)),E.id||(E.id=_b(E.startTime,E.endTime,G)),E.endTime>0&&d.push(E)},u.onparsingerror=function(E){b=E},u.onflush=function(){if(b){o(b);return}r(d)},c.forEach(E=>{if(_)if(Xy(E,"X-TIMESTAMP-MAP=")){_=!1,E.slice(16).split(",").forEach(w=>{Xy(w,"LOCAL:")?m=w.slice(6):Xy(w,"MPEGTS:")&&(g=parseInt(w.slice(7)))});try{v=$6(m)/1e3}catch(w){b=w}return}else E===""&&(_=!1);u.parse(E+`
`)}),u.flush()}const Qy="stpp.ttml.im1t",BL=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,FL=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,G6={left:"start",center:"center",right:"end",start:"start",end:"end"};function w2(s,e,t,i){const n=wt(new Uint8Array(s),["mdat"]);if(n.length===0){i(new Error("Could not parse IMSC1 mdat"));return}const r=n.map(u=>xn(u)),o=K8(e.baseTime,1,e.timescale);try{r.forEach(u=>t(V6(u,o)))}catch(u){i(u)}}function V6(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},o=Object.keys(r).reduce((m,g)=>(m[g]=n.getAttribute(`ttp:${g}`)||r[g],m),{}),u=n.getAttribute("xml:space")!=="preserve",c=L2(Zy(n,"styling","style")),d=L2(Zy(n,"layout","region")),f=Zy(n,"body","[begin]");return[].map.call(f,m=>{const g=UL(m,u);if(!g||!m.hasAttribute("begin"))return null;const v=ev(m.getAttribute("begin"),o),b=ev(m.getAttribute("dur"),o);let _=ev(m.getAttribute("end"),o);if(v===null)throw I2(m);if(_===null){if(b===null)throw I2(m);_=v+b}const E=new bb(v-e,_-e,g);E.id=_b(E.startTime,E.endTime,E.text);const w=d[m.getAttribute("region")],I=c[m.getAttribute("style")],L=q6(w,I,c),{textAlign:F}=L;if(F){const $=G6[F];$&&(E.lineAlign=$),E.align=F}return ni(E,L),E}).filter(m=>m!==null)}function Zy(s,e,t){const i=s.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(t)):[]}function L2(s){return s.reduce((e,t)=>{const i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function UL(s,e){return[].slice.call(s.childNodes).reduce((t,i,n)=>{var r;return i.nodeName==="br"&&n?t+`
`:(r=i.childNodes)!=null&&r.length?UL(i,e):e?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent},"")}function q6(s,e,t){const i="http://www.w3.org/ns/ttml#styling";let n=null;const r=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],o=s!=null&&s.hasAttribute("style")?s.getAttribute("style"):null;return o&&t.hasOwnProperty(o)&&(n=t[o]),r.reduce((u,c)=>{const d=Jy(e,i,c)||Jy(s,i,c)||Jy(n,i,c);return d&&(u[c]=d),u},{})}function Jy(s,e,t){return s&&s.hasAttributeNS(e,t)?s.getAttributeNS(e,t):null}function I2(s){return new Error(`Could not parse ttml timestamp ${s}`)}function ev(s,e){if(!s)return null;let t=PL(s);return t===null&&(BL.test(s)?t=z6(s,e):FL.test(s)&&(t=K6(s,e))),t}function z6(s,e){const t=BL.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 K6(s,e){const t=FL.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 up{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 Y6{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=R2(),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}},e.on(N.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(N.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(N.MANIFEST_LOADING,this.onManifestLoading,this),e.on(N.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(N.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(N.FRAG_LOADING,this.onFragLoading,this),e.on(N.FRAG_LOADED,this.onFragLoaded,this),e.on(N.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(N.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(N.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(N.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(N.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(N.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(N.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(N.MANIFEST_LOADING,this.onManifestLoading,this),e.off(N.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(N.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(N.FRAG_LOADING,this.onFragLoading,this),e.off(N.FRAG_LOADED,this.onFragLoaded,this),e.off(N.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(N.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(N.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(N.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(N.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const e=new up(this,"textTrack1"),t=new up(this,"textTrack2"),i=new up(this,"textTrack3"),n=new up(this,"textTrack4");this.cea608Parser1=new D2(1,e,t),this.cea608Parser2=new D2(3,i,n)}addCues(e,t,i,n,r){let o=!1;for(let u=r.length;u--;){const c=r[u],d=W6(c[0],c[1],t,i);if(d>=0&&(c[0]=Math.min(c[0],t),c[1]=Math.max(c[1],i),o=!0,d/(i-t)>.5))return}if(o||r.push([t,i]),this.config.renderTextTracksNatively){const u=this.captionsTracks[e];this.Cues.newCue(u,t,i,n)}else{const u=this.Cues.newCue(null,t,i,n);this.hls.trigger(N.CUES_PARSED,{type:"captions",cues:u,track:e})}}onInitPtsFound(e,{frag:t,id:i,initPTS:n,timescale:r,trackId:o}){const{unparsedVttFrags:u}=this;i===Je.MAIN&&(this.initPTS[t.cc]={baseTime:n,timescale:r,trackId:o}),u.length&&(this.unparsedVttFrags=[],u.forEach(c=>{this.initPTS[c.frag.cc]?this.onFragLoaded(N.FRAG_LOADED,c):this.hls.trigger(N.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:c.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(k2(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:o}=t[e],u=this.getExistingTrack(r,o);if(u)i[e]=u,Pu(i[e]),LL(i[e],n);else{const c=this.createTextTrack("captions",r,o);c&&(c[e]=!0,i[e]=c)}}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(N.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=>{Pu(n[r]),delete n[r]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=R2(),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++)Pu(t[i])}onSubtitleTracksUpdated(e,t){const i=t.subtitleTracks||[],n=i.some(r=>r.textCodec===Qy);if(this.config.enableWebVTT||n&&this.config.enableIMSC1){if(gL(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){const o=this.media,u=o?Ap(o.textTracks):null;if(this.tracks.forEach((c,d)=>{let f;if(u){let m=null;for(let g=0;g<u.length;g++)if(u[g]&&k2(u[g],c)){m=u[g],u[g]=null;break}m&&(f=m)}if(f)Pu(f);else{const m=$L(c);f=this.createTextTrack(m,c.name,c.lang),f&&(f.mode="disabled")}f&&this.textTracks.push(f)}),u!=null&&u.length){const c=u.filter(d=>d!==null).map(d=>d.label);c.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${c.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const o=this.tracks.map(u=>({label:u.name,kind:u.type.toLowerCase(),default:u.default,subtitleTrack:u}));this.hls.trigger(N.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:o})}}}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]}`,o=this.captionsProperties[r];o&&(o.label=i.name,i.lang&&(o.languageCode=i.lang),o.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===Je.MAIN){var i,n;const{cea608Parser1:r,cea608Parser2:o,lastSn:u}=this,{cc:c,sn:d}=t.frag,f=(i=(n=t.part)==null?void 0:n.index)!=null?i:-1;r&&o&&(d!==u+1||d===u&&f!==this.lastPartIndex+1||c!==this.lastCc)&&(r.reset(),o.reset()),this.lastCc=c,this.lastSn=d,this.lastPartIndex=f}}onFragLoaded(e,t){const{frag:i,payload:n}=t;if(i.type===Je.SUBTITLE)if(n.byteLength){const r=i.decryptdata,o="stats"in t;if(r==null||!r.encrypted||o){const u=this.tracks[i.level],c=this.vttCCs;c[i.cc]||(c[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),u&&u.textCodec===Qy?this._parseIMSC1(i,n):this._parseVTTs(t)}}else this.hls.trigger(N.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const i=this.hls;w2(t,this.initPTS[e.cc],n=>{this._appendCues(n,e.level),i.trigger(N.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},n=>{i.logger.log(`Failed to parse IMSC1: ${n}`),i.trigger(N.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:n})})}_parseVTTs(e){var t;const{frag:i,payload:n}=e,{initPTS:r,unparsedVttFrags:o}=this,u=r.length-1;if(!r[i.cc]&&u===-1){o.push(e);return}const c=this.hls,d=(t=i.initSegment)!=null&&t.data?Fn(i.initSegment.data,new Uint8Array(n)).buffer:n;H6(d,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,f=>{this._appendCues(f,i.level),c.trigger(N.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},f=>{const m=f.message==="Missing initPTS for VTT MPEGTS";m?o.push(e):this._fallbackToIMSC1(i,n),c.logger.log(`Failed to parse VTT cue: ${f}`),!(m&&u>i.cc)&&c.trigger(N.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:f})})}_fallbackToIMSC1(e,t){const i=this.tracks[e.level];i.textCodec||w2(t,this.initPTS[e.cc],()=>{i.textCodec=Qy,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=>IL(n,r))}else{const n=this.tracks[t];if(!n)return;const r=n.default?"default":"subtitles"+t;i.trigger(N.CUES_PARSED,{type:"subtitles",cues:e,track:r})}}onFragDecrypted(e,t){const{frag:i}=t;i.type===Je.SUBTITLE&&this.onFragLoaded(N.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===Je.MAIN&&this.closedCaptionsForLevel(i)==="NONE"))for(let r=0;r<n.length;r++){const o=n[r].bytes;if(o){this.cea608Parser1||this.initCea608Parsers();const u=this.extractCea608Data(o);this.cea608Parser1.addData(n[r].pts,u[0]),this.cea608Parser2.addData(n[r].pts,u[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:i,endOffsetSubtitles:n,type:r}){const{media:o}=this;if(!(!o||o.currentTime<i)){if(!r||r==="video"){const{captionsTracks:u}=this;Object.keys(u).forEach(c=>sT(u[c],t,i))}if(this.config.renderTextTracksNatively&&t===0&&n!==void 0){const{textTracks:u}=this;Object.keys(u).forEach(c=>sT(u[c],t,n))}}}extractCea608Data(e){const t=[[],[]],i=e[0]&31;let n=2;for(let r=0;r<i;r++){const o=e[n++],u=127&e[n++],c=127&e[n++];if(u===0&&c===0)continue;if((4&o)!==0){const f=3&o;(f===0||f===1)&&(t[f].push(u),t[f].push(c))}}return t}}function $L(s){return s.characteristics&&/transcribes-spoken-dialog/gi.test(s.characteristics)&&/describes-music-and-sound/gi.test(s.characteristics)?"captions":"subtitles"}function k2(s,e){return!!s&&s.kind===$L(e)&&Jv(e,s)}function W6(s,e,t,i){return Math.min(e,i)-Math.max(s,t)}function R2(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}const X6=/\s/,Q6={newCue(s,e,t,i){const n=[];let r,o,u,c,d;const f=self.VTTCue||self.TextTrackCue;for(let g=0;g<i.rows.length;g++)if(r=i.rows[g],u=!0,c=0,d="",!r.isEmpty()){var m;for(let _=0;_<r.chars.length;_++)X6.test(r.chars[_].uchar)&&u?c++:(d+=r.chars[_].uchar,u=!1);r.cueStartTime=e,e===t&&(t+=1e-4),c>=16?c--:c++;const v=NL(d.trim()),b=_b(e,t,v);s!=null&&(m=s.cues)!=null&&m.getCueById(b)||(o=new f(e,t,v),o.id=b,o.line=g+1,o.align="left",o.position=10+Math.min(80,Math.floor(c*8/32)*10),n.push(o))}return s&&n.length&&(n.sort((g,v)=>g.line==="auto"||v.line==="auto"?0:g.line>8&&v.line>8?v.line-g.line:g.line-v.line),n.forEach(g=>IL(s,g))),n}};function Z6(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const J6=/(\d+)-(\d+)\/(\d+)/;class O2{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||s$,this.controller=new self.AbortController,this.stats=new JT}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=e$(e,this.controller.signal),o=e.responseType==="arraybuffer",u=o?"byteLength":"length",{maxTimeToFirstByteMs:c,maxLoadTimeMs:d}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,r),self.clearTimeout(this.requestTimeout),t.timeout=c&&We(c)?c:d,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(n,e,this.response))},t.timeout),(eh(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(m=>{var g;this.response=this.loader=m;const v=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=d,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(n,e,this.response))},d-(v-n.loading.start)),!m.ok){const{status:_,statusText:E}=m;throw new n$(E||"fetch, bad network response",_,m)}n.loading.first=v,n.total=i$(m.headers)||n.total;const b=(g=this.callbacks)==null?void 0:g.onProgress;return b&&We(t.highWaterMark)?this.loadProgressively(m,n,e,t.highWaterMark,b):o?m.arrayBuffer():e.responseType==="json"?m.json():m.text()}).then(m=>{var g,v;const b=this.response;if(!b)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);const _=m[u];_&&(n.loaded=n.total=_);const E={url:b.url,data:m,code:b.status},w=(g=this.callbacks)==null?void 0:g.onProgress;w&&!We(t.highWaterMark)&&w(n,e,m,b),(v=this.callbacks)==null||v.onSuccess(E,n,e,b)}).catch(m=>{var g;if(self.clearTimeout(this.requestTimeout),n.aborted)return;const v=m&&m.code||0,b=m?m.message:null;(g=this.callbacks)==null||g.onError({code:v,text:b},e,m?m.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 o=new Xw,u=e.body.getReader(),c=()=>u.read().then(d=>{if(d.done)return o.dataLength&&r(t,i,o.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));const f=d.value,m=f.length;return t.loaded+=m,m<n||o.dataLength?(o.push(f),o.dataLength>=n&&r(t,i,o.flush().buffer,e)):r(t,i,f.buffer,e),c()}).catch(()=>Promise.reject());return c()}}function e$(s,e){const t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(ni({},s.headers))};return s.rangeEnd&&t.headers.set("Range","bytes="+s.rangeStart+"-"+String(s.rangeEnd-1)),t}function t$(s){const e=J6.exec(s);if(e)return parseInt(e[2])-parseInt(e[1])+1}function i$(s){const e=s.get("Content-Range");if(e){const i=t$(e);if(We(i))return i}const t=s.get("Content-Length");if(t)return parseInt(t)}function s$(s,e){return new self.Request(s.url,e)}class n$ extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i}}const r$=/^age:\s*[\d.]+\s*$/im;class jL{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 JT,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(o=>{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(o=>{var u;(u=this.callbacks)==null||u.onError({code:i.status,text:o.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:o}=i.loadPolicy;if(n)for(const u in n)e.setRequestHeader(u,n[u]);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&&We(r)?r:o,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 d=t.status,f=t.responseType==="text"?t.responseText:null;if(d>=200&&d<300){const b=f??t.response;if(b!=null){var o,u;i.loading.end=Math.max(self.performance.now(),i.loading.first);const _=t.responseType==="arraybuffer"?b.byteLength:b.length;i.loaded=i.total=_,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first);const E=(o=this.callbacks)==null?void 0:o.onProgress;E&&E(i,e,b,t);const w={url:t.responseURL,data:b,code:d};(u=this.callbacks)==null||u.onSuccess(w,i,e,t);return}}const m=r.loadPolicy.errorRetry,g=i.retry,v={url:e.url,data:void 0,code:d};if(im(m,g,!1,v))this.retry(m);else{var c;Zt.error(`${d} while loading ${e.url}`),(c=this.callbacks)==null||c.onError({code:d,text:t.statusText},e,t,i)}}}loadtimeout(){if(!this.config)return;const e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(im(e,t,!0))this.retry(e);else{var i;Zt.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=sb(e,i.retry),i.retry++,Zt.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&&r$.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 a$={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},o$=Qt(Qt({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:jL,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:TF,bufferController:uU,capLevelController:yb,errorController:EF,fpsController:c6,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:Uw,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:a$},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},l$()),{},{subtitleStreamController:x6,subtitleTrackController:f6,timelineController:Y6,audioStreamController:rU,audioTrackController:aU,emeController:Ku,cmcdController:a6,contentSteeringController:l6,interstitialsController:_6});function l$(){return{cueHandler:Q6,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 u$(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=rT(s),n=["manifest","level","frag"],r=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return n.forEach(o=>{const u=`${o==="level"?"playlist":o}LoadPolicy`,c=e[u]===void 0,d=[];r.forEach(f=>{const m=`${o}Loading${f}`,g=e[m];if(g!==void 0&&c){d.push(m);const v=i[u].default;switch(e[u]={default:v},f){case"TimeOut":v.maxLoadTimeMs=g,v.maxTimeToFirstByteMs=g;break;case"MaxRetry":v.errorRetry.maxNumRetry=g,v.timeoutRetry.maxNumRetry=g;break;case"RetryDelay":v.errorRetry.retryDelayMs=g,v.timeoutRetry.retryDelayMs=g;break;case"MaxRetryTimeout":v.errorRetry.maxRetryDelayMs=g,v.timeoutRetry.maxRetryDelayMs=g;break}}}),d.length&&t.warn(`hls.js config: "${d.join('", "')}" setting(s) are deprecated, use "${u}": ${ui(e[u])}`)}),Qt(Qt({},i),e)}function rT(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(rT):Object.keys(s).reduce((e,t)=>(e[t]=rT(s[t]),e),{}):s}function c$(s,e){const t=s.loader;t!==O2&&t!==jL?(e.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=!1):Z6()&&(s.loader=O2,s.progressive=!0,s.enableSoftwareAES=!0,e.log("[config]: Progressive streaming enabled, using FetchLoader"))}const Cp=2,d$=.1,h$=.05,f$=100;class p$ extends Pw{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(N.MEDIA_ENDED,{stalled:!1})}},this.hls=e,this.fragmentTracker=t,this.registerListeners()}registerListeners(){const{hls:e}=this;e&&(e.on(N.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(N.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(N.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(N.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(N.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(N.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(f$),this.mediaSource=t.mediaSource;const i=this.media=t.media;Fs(i,"playing",this.onMediaPlaying),Fs(i,"waiting",this.onMediaWaiting),Fs(i,"ended",this.onMediaEnded)}onMediaDetaching(e,t){this.clearInterval();const{media:i}=this;i&&(tn(i,"playing",this.onMediaPlaying),tn(i,"waiting",this.onMediaWaiting),tn(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 o=this.media;if(!o)return;const{seeking:u}=o,c=this.seeking&&!u,d=!this.seeking&&u,f=o.paused&&!u||o.ended||o.playbackRate===0;if(this.seeking=u,e!==t){t&&(this.ended=0),this.moved=!0,u||(this.nudgeRetry=0,r.nudgeOnVideoHole&&!f&&e>t&&this.nudgeOnVideoHole(e,t)),this.waiting===0&&this.stallResolved(e);return}if(d||c){c&&this.stallResolved(e);return}if(f){this.nudgeRetry=0,this.stallResolved(e),!this.ended&&o.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(N.MEDIA_ENDED,{stalled:!1}));return}if(!vt.getBuffered(o).length){this.nudgeRetry=0;return}const m=vt.bufferInfo(o,e,0),g=m.nextStart||0,v=this.fragmentTracker;if(u&&v&&this.hls){const G=P2(this.hls.inFlightFragments,e),B=m.len>Cp,V=!g||G||g-e>Cp&&!v.getPartialFragment(e);if(B||V)return;this.moved=!1}const b=(n=this.hls)==null?void 0:n.latestLevelDetails;if(!this.moved&&this.stalled!==null&&v){if(!(m.len>0)&&!g)return;const B=Math.max(g,m.start||0)-e,k=!!(b!=null&&b.live)?b.targetduration*2:Cp,R=cp(e,v);if(B>0&&(B<=k||R)){o.paused||this._trySkipBufferHole(R);return}}const _=r.detectStallWithCurrentTimeMs,E=self.performance.now(),w=this.waiting;let I=this.stalled;if(I===null)if(w>0&&E-w<_)I=this.stalled=w;else{this.stalled=E;return}const L=E-I;if(!u&&(L>=_||w)&&this.hls){var F;if(((F=this.mediaSource)==null?void 0:F.readyState)==="ended"&&!(b!=null&&b.live)&&Math.abs(e-(b?.edge||0))<1){if(this.ended)return;this.ended=e||1,this.hls.trigger(N.MEDIA_ENDED,{stalled:!0});return}if(this._reportStall(m),!this.media||!this.hls)return}const $=vt.bufferInfo(o,e,r.maxBufferHole);this._tryFixBufferStall($,L,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(N.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=vt.bufferedInfo(vt.timeRangesToArray(this.buffered.audio),e,0);if(r.len>1&&t>=r.start){const o=vt.timeRangesToArray(n),u=vt.bufferedInfo(o,t,0).bufferedIndex;if(u>-1&&u<o.length-1){const c=vt.bufferedInfo(o,e,0).bufferedIndex,d=o[u].end,f=o[u+1].start;if((c===-1||c>u)&&f-d<1&&e-d<2){const m=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${d} -> ${f} buffered index: ${c}`);this.warn(m.message),this.media.currentTime+=1e-6;let g=cp(e,this.fragmentTracker);g&&"fragment"in g?g=g.fragment:g||(g=void 0);const v=vt.bufferInfo(this.media,e,0);this.hls.trigger(N.ERROR,{type:nt.MEDIA_ERROR,details:ve.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:m,reason:m.message,frag:g,buffer:v.len,bufferInfo:v})}}}}}_tryFixBufferStall(e,t,i){var n,r;const{fragmentTracker:o,media:u}=this,c=(n=this.hls)==null?void 0:n.config;if(!u||!o||!c)return;const d=(r=this.hls)==null?void 0:r.latestLevelDetails,f=cp(i,o);if((f||d!=null&&d.live&&i<d.fragmentStart)&&(this._trySkipBufferHole(f)||!this.media))return;const m=e.buffered,g=this.adjacentTraversal(e,i);(m&&m.length>1&&e.len>c.maxBufferHole||e.nextStart&&(e.nextStart-i<c.maxBufferHole||g))&&(t>c.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,Je.MAIN),o=i.getFragAtPos(n,Je.MAIN);if(r&&o)return o.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 o=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${ui(e)})`);this.warn(o.message),t.trigger(N.ERROR,{type:nt.MEDIA_ERROR,details:ve.BUFFER_STALLED_ERROR,fatal:!1,error:o,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 o=n.currentTime,u=vt.bufferInfo(n,o,0),c=o<u.start?u.start:u.nextStart;if(c&&this.hls){const f=u.len<=r.maxBufferHole,m=u.len>0&&u.len<1&&n.readyState<3,g=c-o;if(g>0&&(f||m)){if(g>r.maxBufferHole){let b=!1;if(o===0){const _=i.getAppendedFrag(0,Je.MAIN);_&&c<_.end&&(b=!0)}if(!b&&e){var d;if(!((d=this.hls.loadLevelObj)!=null&&d.details)||P2(this.hls.inFlightFragments,c))return 0;let E=!1,w=e.end;for(;w<c;){const I=cp(w,i);if(I)w+=I.duration;else{E=!0;break}}if(E)return 0}}const v=Math.max(c+h$,o+d$);if(this.warn(`skipping hole, adjusting currentTime from ${o} to ${v}`),this.moved=!0,n.currentTime=v,!(e!=null&&e.gap)){const b=new Error(`fragment loaded with buffer holes, seeking from ${o} to ${v}`),_={type:nt.MEDIA_ERROR,details:ve.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:b,reason:b.message,buffer:u.len,bufferInfo:u};e&&("fragment"in e?_.part=e:_.frag=e),this.hls.trigger(N.ERROR,_)}return v}}return 0}_tryNudgeBuffer(e){const{hls:t,media:i,nudgeRetry:n}=this,r=t?.config;if(!i||!r)return 0;const o=i.currentTime;if(this.nudgeRetry++,n<r.nudgeMaxRetry){const u=o+(n+1)*r.nudgeOffset,c=new Error(`Nudging 'currentTime' from ${o} to ${u}`);this.warn(c.message),i.currentTime=u,t.trigger(N.ERROR,{type:nt.MEDIA_ERROR,details:ve.BUFFER_NUDGE_ON_STALL,error:c,fatal:!1,buffer:e.len,bufferInfo:e})}else{const u=new Error(`Playhead still not moving while enough data buffered @${o} after ${r.nudgeMaxRetry} nudges`);this.error(u.message),t.trigger(N.ERROR,{type:nt.MEDIA_ERROR,details:ve.BUFFER_STALLED_ERROR,error:u,fatal:!0,buffer:e.len,bufferInfo:e})}}}function P2(s,e){const t=M2(s.main);if(t&&t.start<=e)return t;const i=M2(s.audio);return i&&i.start<=e?i:null}function M2(s){if(!s)return null;switch(s.state){case Pe.IDLE:case Pe.STOPPED:case Pe.ENDED:case Pe.ERROR:return null}return s.frag}function cp(s,e){return e.getAppendedFrag(s,Je.MAIN)||e.getPartialFragment(s)}const m$=.25;function aT(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function tv(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,ui(n?Qt({type:n},i):i))}return r}const dp=(()=>{const s=aT();try{s&&new s(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();class g${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(N.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(N.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(N.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(N.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(N.MANIFEST_LOADING,this.onManifestLoading,this),e.on(N.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(N.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(N.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(N.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(N.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(N.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(N.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(N.MANIFEST_LOADING,this.onManifestLoading,this),e.off(N.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(N.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(N.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(N.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&&Pu(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 LL(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 o=aT();if(o)for(let u=0;u<r.length;u++){const c=r[u].type;if(c===_n.emsg&&!i||!n)continue;const d=sL(r[u].data),f=r[u].pts;let m=f+r[u].duration;m>dp&&(m=dp),m-f<=0&&(m=f+m$);for(let v=0;v<d.length;v++){const b=d[v];if(!nL(b)){this.updateId3CueEnds(f,c);const _=tv(o,f,m,b,c);_&&this.id3Track.addCue(_)}}}}updateId3CueEnds(e,t){var i;const n=(i=this.id3Track)==null?void 0:i.cues;if(n)for(let r=n.length;r--;){const o=n[r];o.type===t&&o.startTime<e&&o.endTime===dp&&(o.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:i,type:n}){const{id3Track:r,hls:o}=this;if(!o)return;const{config:{enableEmsgMetadataCues:u,enableID3MetadataCues:c}}=o;if(r&&(u||c)){let d;n==="audio"?d=f=>f.type===_n.audioId3&&c:n==="video"?d=f=>f.type===_n.emsg&&u:d=f=>f.type===_n.audioId3&&c||f.type===_n.emsg&&u,sT(r,t,i,d)}}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:o}=this.hls.config;if(!r)return;const u=aT();if(i&&n&&!o){const{fragmentStart:_,fragmentEnd:E}=e;let w=this.assetCue;w?(w.startTime=_,w.endTime=E):u&&(w=this.assetCue=tv(u,_,E,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),w&&(w.id=i,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(w),w.addEventListener("enter",this.onEventCueEnter)))}if(!e.hasProgramDateTime)return;const{id3Track:c}=this,{dateRanges:d}=e,f=Object.keys(d);let m=this.dateRangeCuesAppended;if(c&&t){var g;if((g=c.cues)!=null&&g.length){const _=Object.keys(m).filter(E=>!f.includes(E));for(let E=_.length;E--;){var v;const w=_[E],I=(v=m[w])==null?void 0:v.cues;delete m[w],I&&Object.keys(I).forEach(L=>{const F=I[L];if(F){F.removeEventListener("enter",this.onEventCueEnter);try{c.removeCue(F)}catch{}}})}}else m=this.dateRangeCuesAppended={}}const b=e.fragments[e.fragments.length-1];if(!(f.length===0||!We(b?.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let _=0;_<f.length;_++){const E=f[_],w=d[E],I=w.startTime,L=m[E],F=L?.cues||{};let $=L?.durationKnown||!1,G=dp;const{duration:B,endDate:V}=w;if(V&&B!==null)G=I+B,$=!0;else if(w.endOnNext&&!$){const R=f.reduce((z,X)=>{if(X!==w.id){const ee=d[X];if(ee.class===w.class&&ee.startDate>w.startDate&&(!z||w.startDate<z.startDate))return ee}return z},null);R&&(G=R.startTime,$=!0)}const k=Object.keys(w.attr);for(let R=0;R<k.length;R++){const z=k[R];if(!BF(z))continue;const X=F[z];if(X)$&&!(L!=null&&L.durationKnown)?X.endTime=G:Math.abs(X.startTime-I)>.01&&(X.startTime=I,X.endTime=G);else if(u){let ee=w.attr[z];FF(z)&&(ee=pw(ee));const oe=tv(u,I,G,{key:z,data:ee},_n.dateRange);oe&&(oe.id=E,this.id3Track.addCue(oe),F[z]=oe,o&&(z==="X-ASSET-LIST"||z==="X-ASSET-URL")&&oe.addEventListener("enter",this.onEventCueEnter))}}m[E]={cues:F,dateRange:w,durationKnown:$}}}}}class y${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:o}=this.config;if(!r||o===1||!i.live)return;const u=this.targetLatency;if(u===null)return;const c=n-u,d=Math.min(this.maxLatency,u+i.targetduration);if(c<d&&c>.05&&this.forwardBufferLength>1){const m=Math.min(2,Math.max(1,o)),g=Math.round(2/(1+Math.exp(-.75*c-this.edgeStalled))*20)/20,v=Math.min(m,Math.max(1,g));this.changeMediaPlaybackRate(t,v)}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:o,lowLatencyMode:u}=this.config,c=this.hls.userConfig;let d=u&&i||t;(this._targetLatencyUpdated||c.liveSyncDuration||c.liveSyncDurationCount||d===0)&&(d=r!==void 0?r:o*n);const f=n;return d+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,f)}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,o=n-i.totalduration,u=n-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(o,r),u)}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(N.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(N.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(N.MANIFEST_LOADING,this.onManifestLoading,this),e.on(N.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(N.ERROR,this.onError,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(N.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(N.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(N.MANIFEST_LOADING,this.onManifestLoading,this),e.off(N.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(N.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===ve.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 v$ extends gb{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(N.MANIFEST_LOADING,this.onManifestLoading,this),e.on(N.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(N.LEVEL_LOADED,this.onLevelLoaded,this),e.on(N.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(N.FRAG_BUFFERED,this.onFragBuffered,this),e.on(N.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(N.MANIFEST_LOADING,this.onManifestLoading,this),e.off(N.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(N.LEVEL_LOADED,this.onLevelLoaded,this),e.off(N.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(N.FRAG_BUFFERED,this.onFragBuffered,this),e.off(N.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={},o={};let u=!1,c=!1,d=!1;t.levels.forEach(f=>{const m=f.attrs;let{audioCodec:g,videoCodec:v}=f;g&&(f.audioCodec=g=Zp(g,i)||void 0),v&&(v=f.videoCodec=eF(v));const{width:b,height:_,unknownCodecs:E}=f,w=E?.length||0;if(u||(u=!!(b&&_)),c||(c=!!v),d||(d=!!g),w||g&&!this.isAudioSupported(g)||v&&!this.isVideoSupported(v)){this.log(`Some or all CODECS not supported "${m.CODECS}"`);return}const{CODECS:I,"FRAME-RATE":L,"HDCP-LEVEL":F,"PATHWAY-ID":$,RESOLUTION:G,"VIDEO-RANGE":B}=m,k=`${`${$||"."}-`}${f.bitrate}-${G}-${L}-${I}-${B}-${F}`;if(r[k])if(r[k].uri!==f.url&&!f.attrs["PATHWAY-ID"]){const R=o[k]+=1;f.attrs["PATHWAY-ID"]=new Array(R+1).join(".");const z=this.createLevel(f);r[k]=z,n.push(z)}else r[k].addGroupId("audio",m.AUDIO),r[k].addGroupId("text",m.SUBTITLES);else{const R=this.createLevel(f);r[k]=R,o[k]=1,n.push(R)}}),this.filterAndSortMediaOptions(n,t,u,c,d)}createLevel(e){const t=new Qd(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=Cw(n,[])}return t}isAudioSupported(e){return Wd(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return Wd(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,i,n,r){var o;let u=[],c=[],d=e;const f=((o=t.stats)==null?void 0:o.parsing)||{};if((i||n)&&r&&(d=d.filter(({videoCodec:I,videoRange:L,width:F,height:$})=>(!!I||!!(F&&$))&&cF(L))),d.length===0){Promise.resolve().then(()=>{if(this.hls){let I="no level with compatible codecs found in manifest",L=I;t.levels.length&&(L=`one or more CODECS in variant not supported: ${ui(t.levels.map($=>$.attrs.CODECS).filter(($,G,B)=>B.indexOf($)===G))}`,this.warn(L),I+=` (${L})`);const F=new Error(I);this.hls.trigger(N.ERROR,{type:nt.MEDIA_ERROR,details:ve.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:F,reason:L})}}),f.end=performance.now();return}t.audioTracks&&(u=t.audioTracks.filter(I=>!I.audioCodec||this.isAudioSupported(I.audioCodec)),N2(u)),t.subtitles&&(c=t.subtitles,N2(c));const m=d.slice(0);d.sort((I,L)=>{if(I.attrs["HDCP-LEVEL"]!==L.attrs["HDCP-LEVEL"])return(I.attrs["HDCP-LEVEL"]||"")>(L.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&I.height!==L.height)return I.height-L.height;if(I.frameRate!==L.frameRate)return I.frameRate-L.frameRate;if(I.videoRange!==L.videoRange)return Jp.indexOf(I.videoRange)-Jp.indexOf(L.videoRange);if(I.videoCodec!==L.videoCodec){const F=D1(I.videoCodec),$=D1(L.videoCodec);if(F!==$)return $-F}if(I.uri===L.uri&&I.codecSet!==L.codecSet){const F=Qp(I.codecSet),$=Qp(L.codecSet);if(F!==$)return $-F}return I.averageBitrate!==L.averageBitrate?I.averageBitrate-L.averageBitrate:0});let g=m[0];if(this.steering&&(d=this.steering.filterParsedLevels(d),d.length!==m.length)){for(let I=0;I<m.length;I++)if(m[I].pathwayId===d[0].pathwayId){g=m[I];break}}this._levels=d;for(let I=0;I<d.length;I++)if(d[I]===g){var v;this._firstLevel=I;const L=g.bitrate,F=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${d.length} level(s) found, first bitrate: ${L}`),((v=this.hls.userConfig)==null?void 0:v.abrEwmaDefaultEstimate)===void 0){const $=Math.min(L,this.hls.config.abrEwmaDefaultEstimateMax);$>F&&F===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=$)}break}const b=r&&!n,_=this.hls.config,E=!!(_.audioStreamController&&_.audioTrackController),w={levels:d,audioTracks:u,subtitleTracks:c,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:r,video:n,altAudio:E&&!b&&u.some(I=>!!I.url)};f.end=performance.now(),this.hls.trigger(N.MANIFEST_PARSED,w)}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 f=new Error("invalid level idx"),m=e<0;if(this.hls.trigger(N.ERROR,{type:nt.OTHER_ERROR,details:ve.LEVEL_SWITCH_ERROR,level:e,fatal:m,error:f,reason:f.message}),m)return;e=Math.min(e,t.length-1)}const i=this.currentLevelIndex,n=this.currentLevel,r=n?n.attrs["PATHWAY-ID"]:void 0,o=t[e],u=o.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=o,i===e&&n&&r===u)return;this.log(`Switching to level ${e} (${o.height?o.height+"p ":""}${o.videoRange?o.videoRange+" ":""}${o.codecSet?o.codecSet+" ":""}@${o.bitrate})${u?" with Pathway "+u:""} from level ${i}${r?" with Pathway "+r:""}`);const c={level:e,attrs:o.attrs,details:o.details,bitrate:o.bitrate,averageBitrate:o.averageBitrate,maxBitrate:o.maxBitrate,realBitrate:o.realBitrate,width:o.width,height:o.height,codecSet:o.codecSet,audioCodec:o.audioCodec,videoCodec:o.videoCodec,audioGroups:o.audioGroups,subtitleGroups:o.subtitleGroups,loaded:o.loaded,loadError:o.loadError,fragmentError:o.fragmentError,name:o.name,id:o.id,uri:o.uri,url:o.url,urlId:0,audioGroupIds:o.audioGroupIds,textGroupIds:o.textGroupIds};this.hls.trigger(N.LEVEL_SWITCHING,c);const d=o.details;if(!d||d.live){const f=this.switchParams(o.uri,n?.details,d);this.loadPlaylist(f)}}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===It.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===Je.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,o=t.levelInfo;if(!o){var u;this.warn(`Invalid level index ${n}`),(u=t.deliveryDirectives)!=null&&u.skip&&(r.deltaUpdateFailed=!0);return}if(o===this.currentLevel||t.withoutMultiVariant){o.fragmentError===0&&(o.loadError=0);let c=o.details;c===t.details&&c.advanced&&(c=void 0),this.playlistLoaded(n,t,c)}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"],o=e.details,u=o?.age;this.log(`Loading level index ${n}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${r?" Pathway "+r:""}${u&&o.live?" age "+u.toFixed(1)+(o.type&&" "+o.type||""):""} ${i}`),this.hls.trigger(N.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,o)=>o!==e?!0:(this.steering&&this.steering.removeLevel(r),r===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,r.details&&r.details.fragments.forEach(u=>u.level=-1)),!1));Kw(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(N.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(N.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}function N2(s){const e={};s.forEach(t=>{const i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++})}function HL(){return self.SourceBuffer||self.WebKitSourceBuffer}function GL(){if(!Eo())return!1;const e=HL();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function T$(){if(!GL())return!1;const s=Eo();return typeof s?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>s.isTypeSupported(Xd(e,"video")))||["mp4a.40.2","fLaC"].some(e=>s.isTypeSupported(Xd(e,"audio"))))}function b$(){var s;const e=HL();return typeof(e==null||(s=e.prototype)==null?void 0:s.changeType)=="function"}const _$=100;class x$ extends lb{constructor(e,t,i){super(e,t,i,"stream-controller",Je.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||!We(r)||(this.log(`Media seeked to ${r.toFixed(3)}`),!this.getBufferedFrag(r)))return;const o=this.getFwdBufferInfoAtPos(n,r,Je.MAIN,0);if(o===null||o.len===0){this.warn(`Main forward buffer length at ${r} on "seeked" event ${o?o.len:"empty"})`);return}this.tick()},this.registerListeners()}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(N.MANIFEST_PARSED,this.onManifestParsed,this),e.on(N.LEVEL_LOADING,this.onLevelLoading,this),e.on(N.LEVEL_LOADED,this.onLevelLoaded,this),e.on(N.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(N.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(N.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(N.BUFFER_CREATED,this.onBufferCreated,this),e.on(N.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(N.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(N.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(N.MANIFEST_PARSED,this.onManifestParsed,this),e.off(N.LEVEL_LOADED,this.onLevelLoaded,this),e.off(N.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(N.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(N.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(N.BUFFER_CREATED,this.onBufferCreated,this),e.off(N.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(N.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(N.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying()}startLoad(e,t){if(this.levels){const{lastCurrentTime:i,hls:n}=this;if(this.stopLoad(),this.setInterval(_$),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=Pe.IDLE,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=Pe.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case Pe.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=Pe.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=Pe.IDLE;break}break}case Pe.FRAG_LOADING_WAITING_RETRY:this.checkRetryDate();break}this.state===Pe.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 o=i[r],u=this.getMainFwdBufferInfo();if(u===null)return;const c=this.getLevelDetails();if(c&&this._streamEnded(u,c)){const _={};this.altAudio===2&&(_.type="video"),this.hls.trigger(N.BUFFER_EOS,_),this.state=Pe.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 d=o.details;if(!d||this.state===Pe.WAITING_LEVEL||this.waitForLive(o)){this.level=r,this.state=Pe.WAITING_LEVEL,this.startFragRequested=!1;return}const f=u.len,m=this.getMaxBufferLength(o.maxBitrate);if(f>=m)return;this.backtrackFragment&&this.backtrackFragment.start>u.end&&(this.backtrackFragment=null);const g=this.backtrackFragment?this.backtrackFragment.start:u.end;let v=this.getNextFragment(g,d);if(this.couldBacktrack&&!this.fragPrevious&&v&&ji(v)&&this.fragmentTracker.getState(v)!==Ji.OK){var b;const E=((b=this.backtrackFragment)!=null?b:v).sn-d.startSN,w=d.fragments[E-1];w&&v.cc===w.cc&&(v=w,this.fragmentTracker.removeFragment(w))}else this.backtrackFragment&&u.len&&(this.backtrackFragment=null);if(v&&this.isLoopLoading(v,g)){if(!v.gap){const E=this.audioOnly&&!this.altAudio?oi.AUDIO:oi.VIDEO,w=(E===oi.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;w&&this.afterBufferFlushed(w,E,Je.MAIN)}v=this.getNextFragmentLoopLoading(v,d,u,Je.MAIN,m)}v&&(v.initSegment&&!v.initSegment.data&&!this.bitrateTest&&(v=v.initSegment),this.loadFragment(v,o,g))}loadFragment(e,t,i){const n=this.fragmentTracker.getState(e);n===Ji.NOT_LOADED||n===Ji.PARTIAL?ji(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,Je.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 u=this.getMainFwdBufferInfo();if(!u||u.len<r.targetduration*2)return}if(!t.paused&&e){const u=this.hls.nextLoadLevel,c=e[u],d=this.fragLastKbps;d&&this.fragCurrent?i=this.fragCurrent.duration*c.maxBitrate/(1e3*d)+1:i=0}else i=0;const o=this.getBufferedFrag(t.currentTime+i);if(o){const u=this.followingBufferedFrag(o);if(u){this.abortCurrentFrag();const c=u.maxStartPTS?u.maxStartPTS:u.start,d=u.duration,f=Math.max(o.end,c+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,d*(this.couldBacktrack?.5:.125)),d*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(f,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 Pe.KEY_LOADING:case Pe.FRAG_LOADING:case Pe.FRAG_LOADING_WAITING_RETRY:case Pe.PARSING:case Pe.PARSED:this.state=Pe.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;Fs(i,"playing",this.onMediaPlaying),Fs(i,"seeked",this.onMediaSeeked)}onMediaDetaching(e,t){const{media:i}=this;i&&(tn(i,"playing",this.onMediaPlaying),tn(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(N.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 o=t.levels[r].audioCodec;o&&(i=i||o.indexOf("mp4a.40.2")!==-1,n=n||o.indexOf("mp4a.40.5")!==-1)}this.audioCodecSwitch=i&&n&&!b$(),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!==Pe.IDLE)return;const n=t.levelInfo;(!n.details||n.details.live&&(this.levelLastLoaded!==n||n.details.expired)||this.waitForCdnTuneIn(n.details))&&(this.state=Pe.WAITING_LEVEL)}onLevelLoaded(e,t){var i;const{levels:n,startFragRequested:r}=this,o=t.level,u=t.details,c=u.totalduration;if(!n){this.warn(`Levels were reset while loading level ${o}`);return}this.log(`Level ${o} loaded [${u.startSN},${u.endSN}]${u.lastPartSn?`[part-${u.lastPartSn}-${u.lastPartIndex}]`:""}, cc [${u.startCC}, ${u.endCC}] duration:${c}`);const d=t.levelInfo,f=this.fragCurrent;f&&(this.state===Pe.FRAG_LOADING||this.state===Pe.FRAG_LOADING_WAITING_RETRY)&&f.level!==t.level&&f.loader&&this.abortCurrentFrag();let m=0;if(u.live||(i=d.details)!=null&&i.live){var g;if(this.checkLiveUpdate(u),u.deltaUpdateFailed)return;m=this.alignPlaylists(u,d.details,(g=this.levelLastLoaded)==null?void 0:g.details)}if(d.details=u,this.levelLastLoaded=d,r||this.setStartPosition(u,m),this.hls.trigger(N.LEVEL_UPDATED,{details:u,level:o}),this.state===Pe.WAITING_LEVEL){if(this.waitForCdnTuneIn(u))return;this.state=Pe.IDLE}r&&u.live&&this.synchronizeToLiveEdge(u),this.tick()}synchronizeToLiveEdge(e){const{config:t,media:i}=this;if(!i)return;const n=this.hls.liveSyncPosition,r=this.getLoadPosition(),o=e.fragmentStart,u=e.edge,c=r>=o-t.maxFragLookUpTolerance&&r<=u;if(n!==null&&i.duration>n&&(r<n||!c)){const f=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!c&&i.readyState<4||r<u-f)&&(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: ${u}, reset currentTime to : ${n.toFixed(3)}`),this.config.liveSyncMode==="buffered"){var d;const m=vt.bufferInfo(i,n,0);if(!((d=m.buffered)!=null&&d.length)){i.currentTime=n;return}if(m.start<=r){i.currentTime=n;return}const{nextStart:v}=vt.bufferedInfo(m.buffered,r,0);v&&(i.currentTime=v)}else i.currentTime=n}}_handleFragmentLoadProgress(e){var t;const i=e.frag,{part:n,payload:r}=e,{levels:o}=this;if(!o){this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const u=o[i.level];if(!u){this.warn(`Level ${i.level} not found on progress`);return}const c=u.details;if(!c){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}const d=u.videoCodec,f=c.PTSKnown||!c.live,m=(t=i.initSegment)==null?void 0:t.data,g=this._getAudioCodec(u),v=this.transmuxer=this.transmuxer||new mL(this.hls,Je.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),b=n?n.index:-1,_=b!==-1,E=new rb(i.level,i.sn,i.stats.chunkCount,r.byteLength,b,_),w=this.initPTS[i.cc];v.push(r,m,g,d,i,n,c.totalduration,f,E,w)}onAudioTrackSwitching(e,t){const i=this.hls,n=this.altAudio!==0;if(em(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 o=this.fragCurrent;o&&(this.log("Switching to main audio track, cancel main fragment load"),o.abortRequests(),this.fragmentTracker.removeFragment(o)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(n){this.altAudio=0,this.fragmentTracker.removeAllFragments(),i.once(N.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(N.AUDIO_TRACK_SWITCHED,t)}),i.trigger(N.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}i.trigger(N.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const i=em(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,o=!1;for(const u in i){const c=i[u];if(c.id==="main"){if(r=u,n=c,u==="video"){const d=i[u];d&&(this.videoBuffer=d.buffer)}}else o=!0}o&&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===Je.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===Pe.PARSED&&(this.state=Pe.IDLE);return}const u=n?n.stats:i.stats;this.fragLastKbps=Math.round(8*u.total/(u.buffering.end-u.loading.first)),ji(i)&&(this.fragPrevious=i),this.fragBufferedComplete(i,n)}const o=this.media;o&&(!this._hasEnoughToStart&&vt.getBuffered(o).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),r&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var i;if(t.fatal){this.state=Pe.ERROR;return}switch(t.details){case ve.FRAG_GAP:case ve.FRAG_PARSING_ERROR:case ve.FRAG_DECRYPT_ERROR:case ve.FRAG_LOAD_ERROR:case ve.FRAG_LOAD_TIMEOUT:case ve.KEY_LOAD_ERROR:case ve.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Je.MAIN,t);break;case ve.LEVEL_LOAD_ERROR:case ve.LEVEL_LOAD_TIMEOUT:case ve.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===Pe.WAITING_LEVEL&&((i=t.context)==null?void 0:i.type)===It.LEVEL&&(this.state=Pe.IDLE);break;case ve.BUFFER_ADD_CODEC_ERROR:case ve.BUFFER_APPEND_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case ve.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 ve.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onFragLoadEmergencyAborted(){this.state=Pe.IDLE,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==oi.AUDIO||!this.altAudio){const i=(t===oi.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;i&&(this.afterBufferFlushed(i,t,Je.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(),o=vt.getBuffered(e),u=o.length?o.start(0):0,c=u-i,d=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||c>0&&(c<d||this.loadingParts&&c<2*(r?.partTarget||0)))&&(this.log(`adjusting start position by ${c} to match buffer start`),i+=c,this.startPosition=i),t<i&&(this.log(`seek to target start position ${i} from current time ${t} buffer start ${u}`),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=Pe.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const o=r.stats;o.parsing.start=o.parsing.end=o.buffering.start=o.buffering.end=self.performance.now(),n.trigger(N.FRAG_LOADED,i),r.bitrateTest=!1}).catch(i=>{this.state===Pe.STOPPED||this.state===Pe.ERROR||(this.warn(i),this.resetFragmentLoading(e))})}_handleTransmuxComplete(e){const t=this.playlistType,{hls:i}=this,{remuxResult:n,chunkMeta:r}=e,o=this.getCurrentContext(r);if(!o){this.resetWhenMissingContext(r);return}const{frag:u,part:c,level:d}=o,{video:f,text:m,id3:g,initSegment:v}=n,{details:b}=d,_=this.altAudio?void 0:n.audio;if(this.fragContextChanged(u)){this.fragmentTracker.removeFragment(u);return}if(this.state=Pe.PARSING,v){const E=v.tracks;if(E){const F=u.initSegment||u;if(this.unhandledEncryptionError(v,u))return;this._bufferInitSegment(d,E,F,r),i.trigger(N.FRAG_PARSING_INIT_SEGMENT,{frag:F,id:t,tracks:E})}const w=v.initPTS,I=v.timescale,L=this.initPTS[u.cc];if(We(w)&&(!L||L.baseTime!==w||L.timescale!==I)){const F=v.trackId;this.initPTS[u.cc]={baseTime:w,timescale:I,trackId:F},i.trigger(N.INIT_PTS_FOUND,{frag:u,id:t,initPTS:w,timescale:I,trackId:F})}}if(f&&b){_&&f.type==="audiovideo"&&this.logMuxedErr(u);const E=b.fragments[u.sn-1-b.startSN],w=u.sn===b.startSN,I=!E||u.cc>E.cc;if(n.independent!==!1){const{startPTS:L,endPTS:F,startDTS:$,endDTS:G}=f;if(c)c.elementaryStreams[f.type]={startPTS:L,endPTS:F,startDTS:$,endDTS:G};else if(f.firstKeyFrame&&f.independent&&r.id===1&&!I&&(this.couldBacktrack=!0),f.dropped&&f.independent){const B=this.getMainFwdBufferInfo(),V=(B?B.end:this.getLoadPosition())+this.config.maxBufferHole,k=f.firstKeyFramePTS?f.firstKeyFramePTS:L;if(!w&&V<k-this.config.maxBufferHole&&!I){this.backtrack(u);return}else I&&(u.gap=!0);u.setElementaryStreamInfo(f.type,u.start,F,u.start,G,!0)}else w&&L-(b.appliedTimelineOffset||0)>Cp&&(u.gap=!0);u.setElementaryStreamInfo(f.type,L,F,$,G),this.backtrackFragment&&(this.backtrackFragment=u),this.bufferFragmentData(f,u,c,r,w||I)}else if(w||I)u.gap=!0;else{this.backtrack(u);return}}if(_){const{startPTS:E,endPTS:w,startDTS:I,endDTS:L}=_;c&&(c.elementaryStreams[oi.AUDIO]={startPTS:E,endPTS:w,startDTS:I,endDTS:L}),u.setElementaryStreamInfo(oi.AUDIO,E,w,I,L),this.bufferFragmentData(_,u,c,r)}if(b&&g!=null&&g.samples.length){const E={id:t,frag:u,details:b,samples:g.samples};i.trigger(N.FRAG_PARSING_METADATA,E)}if(b&&m){const E={id:t,frag:u,details:b,samples:m.samples};i.trigger(N.FRAG_PARSING_USERDATA,E)}}logMuxedErr(e){this.warn(`${ji(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}_bufferInitSegment(e,t,i,n){if(this.state!==Pe.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(i));const{audio:r,video:o,audiovideo:u}=t;if(r){const d=e.audioCodec;let f=Tp(r.codec,d);f==="mp4a"&&(f="mp4a.40.5");const m=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){f&&(f.indexOf("mp4a.40.5")!==-1?f="mp4a.40.2":f="mp4a.40.5");const g=r.metadata;g&&"channelCount"in g&&(g.channelCount||1)!==1&&m.indexOf("firefox")===-1&&(f="mp4a.40.5")}f&&f.indexOf("mp4a.40.5")!==-1&&m.indexOf("android")!==-1&&r.container!=="audio/mpeg"&&(f="mp4a.40.2",this.log(`Android: force audio codec to ${f}`)),d&&d!==f&&this.log(`Swapping manifest audio codec "${d}" for "${f}"`),r.levelCodec=f,r.id=Je.MAIN,this.log(`Init audio buffer, container:${r.container}, codecs[selected/level/parsed]=[${f||""}/${d||""}/${r.codec}]`),delete t.audiovideo}if(o){o.levelCodec=e.videoCodec,o.id=Je.MAIN;const d=o.codec;if(d?.length===4)switch(d){case"hvc1":case"hev1":o.codec="hvc1.1.6.L120.90";break;case"av01":o.codec="av01.0.04M.08";break;case"avc1":o.codec="avc1.42e01e";break}this.log(`Init video buffer, container:${o.container}, codecs[level/parsed]=[${e.videoCodec||""}/${d}]${o.codec!==d?" parsed-corrected="+o.codec:""}${o.supplemental?" supplemental="+o.supplemental:""}`),delete t.audiovideo}u&&(this.log(`Init audiovideo buffer, container:${u.container}, codecs[level/parsed]=[${e.codecs}/${u.codec}]`),delete t.video,delete t.audio);const c=Object.keys(t);if(c.length){if(this.hls.trigger(N.BUFFER_CODECS,t),!this.hls)return;c.forEach(d=>{const m=t[d].initSegment;m!=null&&m.byteLength&&this.hls.trigger(N.BUFFER_APPENDING,{type:d,data:m,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,Je.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=Pe.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const i=e.currentTime;if(vt.isBuffered(e,i)?t=this.getAppendedFrag(i):vt.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(N.FRAG_CHANGED,{frag:t}),(!n||n.level!==r)&&this.hls.trigger(N.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 We(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;const t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;if(We(t)){const i=this.getLevelDetails(),n=this.currentFrag||(i?Cl(null,i.fragments,t):null);if(n){const r=n.programDateTime;if(r!==null){const o=r+(t-n.start)*1e3;return new Date(o)}}}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 S$ extends jn{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=ve.KEY_LOAD_ERROR,i,n,r){return new ha({type:nt.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 o=t[n];if(e.cc<=o.cc&&(!ji(e)||!ji(o)||e.sn<o.sn)||!i&&n==r-1)return this.emeController.selectKeySystemFormat(o).then(u=>{if(!this.emeController)return;o.setKeyFormat(u);const c=_p(u);if(c)return this.emeController.getKeySystemAccess([c])})}if(this.config.requireKeySystemAccessOnStart){const n=Id(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 d=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,ve.KEY_LOAD_ERROR,d))}const o=r.uri;if(!o)return Promise.reject(this.createKeyLoadError(e,ve.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${o}"`)));const u=iv(r);let c=this.keyIdToKeyInfo[u];if((i=c)!=null&&i.decryptdata.key)return r.key=c.decryptdata.key,Promise.resolve({frag:e,keyInfo:c});if(this.emeController&&(n=c)!=null&&n.keyLoadPromise)switch(this.emeController.getKeyStatus(c.decryptdata)){case"usable":case"usable-in-future":return c.keyLoadPromise.then(f=>{const{keyInfo:m}=f;return r.key=m.decryptdata.key,{frag:e,keyInfo:m}})}switch(this.log(`${this.keyIdToKeyInfo[u]?"Rel":"L"}oading${r.keyId?" keyId: "+gs(r.keyId):""} URI: ${r.uri} from ${e.type} ${e.level}`),c=this.keyIdToKeyInfo[u]={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(c,e):this.loadKeyEME(c,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(c,e);default:return Promise.reject(this.createKeyLoadError(e,ve.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 o=HB(t.initSegment.data);if(o.length){let u=o[0];u.some(c=>c!==0)?(this.log(`Using keyId found in init segment ${gs(u)}`),_o.setKeyIdForUri(e.decryptdata.uri,u)):(u=_o.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${gs(u)}`)),e.decryptdata.keyId=u}}if(!e.decryptdata.keyId&&!ji(t))return Promise.resolve(i);const r=this.emeController.loadKey(i);return(e.keyLoadPromise=r.then(o=>(e.mediaKeySessionContext=o,i))).catch(o=>{throw e.keyLoadPromise=null,"data"in o&&(o.data.frag=t),o})}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((o,u)=>{const c={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},d=i.keyLoadPolicy.default,f={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},m={onSuccess:(g,v,b,_)=>{const{frag:E,keyInfo:w}=b,I=iv(w.decryptdata);if(!E.decryptdata||w!==this.keyIdToKeyInfo[I])return u(this.createKeyLoadError(E,ve.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),_));w.decryptdata.key=E.decryptdata.key=new Uint8Array(g.data),E.keyLoader=null,w.loader=null,o({frag:E,keyInfo:w})},onError:(g,v,b,_)=>{this.resetLoader(v),u(this.createKeyLoadError(t,ve.KEY_LOAD_ERROR,new Error(`HTTP Error ${g.code} loading key ${g.text}`),b,Qt({url:c.url,data:void 0},g)))},onTimeout:(g,v,b)=>{this.resetLoader(v),u(this.createKeyLoadError(t,ve.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),b))},onAbort:(g,v,b)=>{this.resetLoader(v),u(this.createKeyLoadError(t,ve.INTERNAL_ABORTED,new Error("key loading aborted"),b))}};r.load(c,f,m)})}resetLoader(e){const{frag:t,keyInfo:i,url:n}=e,r=i.loader;t.keyLoader===r&&(t.keyLoader=null,i.loader=null);const o=iv(i.decryptdata)||n;delete this.keyIdToKeyInfo[o],r&&r.destroy()}}function iv(s){if(s.keyFormat!==ys.FAIRPLAY){const e=s.keyId;if(e)return gs(e)}return s.uri}function B2(s){const{type:e}=s;switch(e){case It.AUDIO_TRACK:return Je.AUDIO;case It.SUBTITLE_TRACK:return Je.SUBTITLE;default:return Je.MAIN}}function sv(s,e){let t=s.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}class E${constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(N.MANIFEST_LOADING,this.onManifestLoading,this),e.on(N.LEVEL_LOADING,this.onLevelLoading,this),e.on(N.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(N.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(N.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:e}=this;e.off(N.MANIFEST_LOADING,this.onManifestLoading,this),e.off(N.LEVEL_LOADING,this.onLevelLoading,this),e.off(N.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(N.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(N.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(e){const t=this.hls.config,i=t.pLoader,n=t.loader,r=i||n,o=new r(t);return this.loaders[e.type]=o,o}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:It.MANIFEST,url:i,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(e,t){const{id:i,level:n,pathwayId:r,url:o,deliveryDirectives:u,levelInfo:c}=t;this.load({id:i,level:n,pathwayId:r,responseType:"text",type:It.LEVEL,url:o,deliveryDirectives:u,levelOrTrack:c})}onAudioTrackLoading(e,t){const{id:i,groupId:n,url:r,deliveryDirectives:o,track:u}=t;this.load({id:i,groupId:n,level:null,responseType:"text",type:It.AUDIO_TRACK,url:r,deliveryDirectives:o,levelOrTrack:u})}onSubtitleTrackLoading(e,t){const{id:i,groupId:n,url:r,deliveryDirectives:o,track:u}=t;this.load({id:i,groupId:n,level:null,responseType:"text",type:It.SUBTITLE_TRACK,url:r,deliveryDirectives:o,levelOrTrack:u})}onLevelsUpdated(e,t){const i=this.loaders[It.LEVEL];if(i){const n=i.context;n&&!t.levels.some(r=>r===n.levelOrTrack)&&(i.abort(),delete this.loaders[It.LEVEL])}}load(e){var t;const i=this.hls.config;let n=this.getInternalLoader(e);if(n){const d=this.hls.logger,f=n.context;if(f&&f.levelOrTrack===e.levelOrTrack&&(f.url===e.url||f.deliveryDirectives&&!e.deliveryDirectives)){f.url===e.url?d.log(`[playlist-loader]: ignore ${e.url} ongoing request`):d.log(`[playlist-loader]: ignore ${e.url} in favor of ${f.url}`);return}d.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),n.abort()}let r;if(e.type===It.MANIFEST?r=i.manifestLoadPolicy.default:r=ni({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),n=this.createInternalLoader(e),We((t=e.deliveryDirectives)==null?void 0:t.part)){let d;if(e.type===It.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===It.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===It.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){const f=d.partTarget,m=d.targetduration;if(f&&m){const g=Math.max(f*3,m*.8)*1e3;r=ni({},r,{maxTimeToFirstByteMs:Math.min(g,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(g,r.maxTimeToFirstByteMs)})}}}const o=r.errorRetry||r.timeoutRetry||{},u={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},c={onSuccess:(d,f,m,g)=>{const v=this.getInternalLoader(m);this.resetInternalLoader(m.type);const b=d.data;f.parsing.start=performance.now(),Or.isMediaPlaylist(b)||m.type!==It.MANIFEST?this.handleTrackOrLevelPlaylist(d,f,m,g||null,v):this.handleMasterPlaylist(d,f,m,g)},onError:(d,f,m,g)=>{this.handleNetworkError(f,m,!1,d,g)},onTimeout:(d,f,m)=>{this.handleNetworkError(f,m,!0,void 0,d)}};n.load(e,u,c)}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,o=e.data,u=sv(e,i),c=Or.parseMasterPlaylist(o,u);if(c.playlistParsingError){t.parsing.end=performance.now(),this.handleManifestParsingError(e,i,c.playlistParsingError,n,t);return}const{contentSteering:d,levels:f,sessionData:m,sessionKeys:g,startTimeOffset:v,variableList:b}=c;this.variableList=b,f.forEach(I=>{const{unknownCodecs:L}=I;if(L){const{preferManagedMediaSource:F}=this.hls.config;let{audioCodec:$,videoCodec:G}=I;for(let B=L.length;B--;){const V=L[B];Wd(V,"audio",F)?(I.audioCodec=$=$?`${$},${V}`:V,nc.audio[$.substring(0,4)]=2,L.splice(B,1)):Wd(V,"video",F)&&(I.videoCodec=G=G?`${G},${V}`:V,nc.video[G.substring(0,4)]=2,L.splice(B,1))}}});const{AUDIO:_=[],SUBTITLES:E,"CLOSED-CAPTIONS":w}=Or.parseMasterPlaylistMedia(o,u,c);_.length&&!_.some(L=>!L.url)&&f[0].audioCodec&&!f[0].attrs.AUDIO&&(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),_.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Si({}),bitrate:0,url:""})),r.trigger(N.MANIFEST_LOADED,{levels:f,audioTracks:_,subtitles:E,captions:w,contentSteering:d,url:u,stats:t,networkDetails:n,sessionData:m,sessionKeys:g,startTimeOffset:v,variableList:b})}handleTrackOrLevelPlaylist(e,t,i,n,r){const o=this.hls,{id:u,level:c,type:d}=i,f=sv(e,i),m=We(c)?c:We(u)?u:0,g=B2(i),v=Or.parseLevelPlaylist(e.data,f,m,g,0,this.variableList);if(d===It.MANIFEST){const b={attrs:new Si({}),bitrate:0,details:v,name:"",url:f};v.requestScheduled=t.loading.start+Vw(v,0),o.trigger(N.MANIFEST_LOADED,{levels:[b],audioTracks:[],url:f,stats:t,networkDetails:n,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),i.levelDetails=v,this.handlePlaylistLoaded(v,e,t,i,n,r)}handleManifestParsingError(e,t,i,n,r){this.hls.trigger(N.ERROR,{type:nt.NETWORK_ERROR,details:ve.MANIFEST_PARSING_ERROR,fatal:t.type===It.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 o=`A network ${i?"timeout":"error"+(n?" (status "+n.code+")":"")} occurred while loading ${e.type}`;e.type===It.LEVEL?o+=`: ${e.level} id: ${e.id}`:(e.type===It.AUDIO_TRACK||e.type===It.SUBTITLE_TRACK)&&(o+=` id: ${e.id} group-id: "${e.groupId}"`);const u=new Error(o);this.hls.logger.warn(`[playlist-loader]: ${o}`);let c=ve.UNKNOWN,d=!1;const f=this.getInternalLoader(e);switch(e.type){case It.MANIFEST:c=i?ve.MANIFEST_LOAD_TIMEOUT:ve.MANIFEST_LOAD_ERROR,d=!0;break;case It.LEVEL:c=i?ve.LEVEL_LOAD_TIMEOUT:ve.LEVEL_LOAD_ERROR,d=!1;break;case It.AUDIO_TRACK:c=i?ve.AUDIO_TRACK_LOAD_TIMEOUT:ve.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case It.SUBTITLE_TRACK:c=i?ve.SUBTITLE_TRACK_LOAD_TIMEOUT:ve.SUBTITLE_LOAD_ERROR,d=!1;break}f&&this.resetInternalLoader(e.type);const m={type:nt.NETWORK_ERROR,details:c,fatal:d,url:e.url,loader:f,context:e,error:u,networkDetails:t,stats:r};if(n){const g=t?.url||e.url;m.response=Qt({url:g,data:void 0},n)}this.hls.trigger(N.ERROR,m)}handlePlaylistLoaded(e,t,i,n,r,o){const u=this.hls,{type:c,level:d,levelOrTrack:f,id:m,groupId:g,deliveryDirectives:v}=n,b=sv(t,n),_=B2(n);let E=typeof n.level=="number"&&_===Je.MAIN?d:void 0;const w=e.playlistParsingError;if(w){if(this.hls.logger.warn(`${w} ${e.url}`),!u.config.ignorePlaylistParsingErrors){u.trigger(N.ERROR,{type:nt.NETWORK_ERROR,details:ve.LEVEL_PARSING_ERROR,fatal:!1,url:b,error:w,reason:w.message,response:t,context:n,level:E,parent:_,networkDetails:r,stats:i});return}e.playlistParsingError=null}if(!e.fragments.length){const I=e.playlistParsingError=new Error("No Segments found in Playlist");u.trigger(N.ERROR,{type:nt.NETWORK_ERROR,details:ve.LEVEL_EMPTY_ERROR,fatal:!1,url:b,error:I,reason:I.message,response:t,context:n,level:E,parent:_,networkDetails:r,stats:i});return}switch(e.live&&o&&(o.getCacheAge&&(e.ageHeader=o.getCacheAge()||0),(!o.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),c){case It.MANIFEST:case It.LEVEL:if(E){if(!f)E=0;else if(f!==u.levels[E]){const I=u.levels.indexOf(f);I>-1&&(E=I)}}u.trigger(N.LEVEL_LOADED,{details:e,levelInfo:f||u.levels[0],level:E||0,id:m||0,stats:i,networkDetails:r,deliveryDirectives:v,withoutMultiVariant:c===It.MANIFEST});break;case It.AUDIO_TRACK:u.trigger(N.AUDIO_TRACK_LOADED,{details:e,track:f,id:m||0,groupId:g||"",stats:i,networkDetails:r,deliveryDirectives:v});break;case It.SUBTITLE_TRACK:u.trigger(N.SUBTITLE_TRACK_LOADED,{details:e,track:f,id:m||0,groupId:g||"",stats:i,networkDetails:r,deliveryDirectives:v});break}}}class Jn{static get version(){return Zd}static isMSESupported(){return GL()}static isSupported(){return T$()}static getMediaSource(){return Eo()}static get Events(){return N}static get MetadataSchema(){return _n}static get ErrorTypes(){return nt}static get ErrorDetails(){return ve}static get DefaultConfig(){return Jn.defaultConfig?Jn.defaultConfig:o$}static set DefaultConfig(e){Jn.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 ub,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=IB(e.debug||!1,"Hls instance",e.assetPlayerId),i=this.config=u$(Jn.DefaultConfig,e,t);this.userConfig=e,i.progressive&&c$(i,t);const{abrController:n,bufferController:r,capLevelController:o,errorController:u,fpsController:c}=i,d=new u(this),f=this.abrController=new n(this),m=new AF(this),g=i.interstitialsController,v=g?this.interstitialsController=new g(this,Jn):null,b=this.bufferController=new r(this,m),_=this.capLevelController=new o(this),E=new c(this),w=new E$(this),I=i.contentSteeringController,L=I?new I(this):null,F=this.levelController=new v$(this,L),$=new g$(this),G=new S$(this.config,this.logger),B=this.streamController=new x$(this,m,G),V=this.gapController=new p$(this,m);_.setStreamController(B),E.setStreamController(B);const k=[w,F,B];v&&k.splice(1,0,v),L&&k.splice(1,0,L),this.networkControllers=k;const R=[f,b,V,_,E,$,m];this.audioTrackController=this.createController(i.audioTrackController,k);const z=i.audioStreamController;z&&k.push(this.audioStreamController=new z(this,m,G)),this.subtitleTrackController=this.createController(i.subtitleTrackController,k);const X=i.subtitleStreamController;X&&k.push(this.subtititleStreamController=new X(this,m,G)),this.createController(i.timelineController,R),G.emeController=this.emeController=this.createController(i.emeController,R),this.cmcdController=this.createController(i.cmcdController,R),this.latencyController=this.createController(y$,R),this.coreComponents=R,k.push(d);const ee=d.onErrorOut;typeof ee=="function"&&this.on(N.ERROR,ee,d),this.on(N.MANIFEST_LOADED,w.onManifestLoaded,w)}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===N.ERROR;this.trigger(N.ERROR,{type:nt.OTHER_ERROR,details:ve.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(N.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(N.ERROR,{type:nt.OTHER_ERROR,details:ve.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(N.MEDIA_ATTACHING,n)}detachMedia(){this.logger.log("detachMedia"),this.trigger(N.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;const e=this.bufferController.transferMedia();return this.trigger(N.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();const t=this.media,i=this._url,n=this._url=ZT.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(N.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={[Je.MAIN]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[Je.AUDIO]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[Je.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=p6()),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){uF(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 o=e[r].attrs["HDCP-LEVEL"];if(o&&o<=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}setSubtitleOption(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=Lw(t);return Dw(e,i,navigator.mediaCapabilities)}}Jn.defaultConfig=void 0;function A$({src:s,muted:e,className:t}){const i=j.useRef(null),[n,r]=j.useState(!1);return j.useEffect(()=>{let o=!1,u=null;const c=i.current;if(!c)return;r(!1),c.muted=e;async function d(){const m=Date.now();for(;!o&&Date.now()-m<2e4;){try{const g=await fetch(s,{cache:"no-store"});if(g.status!==204){if(g.ok)return!0}}catch{}await new Promise(g=>setTimeout(g,400))}return!1}async function f(m){if(!await d()||o){o||r(!0);return}if(m.canPlayType("application/vnd.apple.mpegurl")){m.src=s,m.play().catch(()=>{});return}if(!Jn.isSupported()){r(!0);return}u=new Jn({lowLatencyMode:!0,liveSyncDurationCount:2,maxBufferLength:4}),u.on(Jn.Events.ERROR,(v,b)=>{b.fatal&&r(!0)}),u.loadSource(s),u.attachMedia(m),u.on(Jn.Events.MANIFEST_PARSED,()=>{m.play().catch(()=>{})})}return f(c),()=>{o=!0,u?.destroy()}},[s,e]),n?P.jsx("div",{className:"text-xs text-gray-400 italic",children:""}):P.jsx("video",{ref:i,className:t,playsInline:!0,autoPlay:!0,muted:e,onClick:()=>{const o=i.current;o&&(o.muted=!1,o.play().catch(()=>{}))}})}function F2({jobId:s,thumbTick:e,autoTickMs:t=3e4,blur:i=!1}){const n=i?"blur-md":"",[r,o]=j.useState(0),[u,c]=j.useState(!1),d=j.useRef(null),[f,m]=j.useState(!1);j.useEffect(()=>{if(typeof e=="number"||!f||document.hidden)return;const _=window.setInterval(()=>{o(E=>E+1)},t);return()=>window.clearInterval(_)},[e,t,f]),j.useEffect(()=>{const _=d.current;if(!_)return;const E=new IntersectionObserver(w=>{const I=w[0];m(!!I?.isIntersecting)},{root:null,threshold:.1});return E.observe(_),()=>E.disconnect()},[]);const g=typeof e=="number"?e:r;j.useEffect(()=>{c(!1)},[g]);const v=j.useMemo(()=>`/api/record/preview?id=${encodeURIComponent(s)}&v=${g}`,[s,g]),b=j.useMemo(()=>`/api/record/preview?id=${encodeURIComponent(s)}&file=index_hq.m3u8`,[s]);return P.jsx(SA,{content:(_,{close:E})=>_&&P.jsx("div",{className:"w-[420px] max-w-[calc(100vw-1.5rem)]",children:P.jsxs("div",{className:"relative aspect-video overflow-hidden rounded-lg bg-black",children:[P.jsx(A$,{src:b,muted:!1,className:["w-full h-full relative z-0",n].filter(Boolean).join(" ")}),P.jsxs("div",{className:"absolute left-2 top-2 inline-flex items-center gap-1.5 rounded-full bg-red-600/90 px-2 py-1 text-[11px] font-semibold text-white shadow-sm",children:[P.jsx("span",{className:"inline-block size-1.5 rounded-full bg-white animate-pulse"}),"Live"]}),P.jsx("button",{type:"button",className:"absolute right-2 top-2 z-20 inline-flex items-center justify-center rounded-md bg-black/45 p-1.5 text-white hover:bg-black/65 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white/70","aria-label":"Live-Vorschau schließen",title:"Vorschau schließen",onClick:w=>{w.preventDefault(),w.stopPropagation(),E()},children:P.jsx(CA,{className:"h-4 w-4"})})]})}),children:P.jsx("div",{ref:d,className:"w-20 h-16 rounded bg-gray-100 dark:bg-white/5 overflow-hidden flex items-center justify-center",children:u?P.jsx("div",{className:"text-[10px] text-gray-500 dark:text-gray-400 px-1 text-center",children:"keine Vorschau"}):P.jsx("img",{src:v,loading:"lazy",alt:"",className:["w-full h-full object-cover",n].filter(Boolean).join(" "),onError:()=>c(!0),onLoad:()=>c(!1)})})})}function C$({models:s}){const e=j.useMemo(()=>[{key:"model",header:"Model",cell:t=>P.jsx("span",{className:"truncate font-medium text-gray-900 dark:text-white",title:t.modelKey,children:t.modelKey})},{key:"status",header:"Status",cell:t=>P.jsx("span",{className:"font-medium",children:t.currentShow||"unknown"})},{key:"open",header:"Öffnen",srOnlyHeader:!0,align:"right",cell:t=>P.jsx("a",{href:t.url,target:"_blank",rel:"noreferrer",className:"text-indigo-600 dark:text-indigo-400 hover:underline",onClick:i=>i.stopPropagation(),children:"Öffnen"})}],[]);return s.length===0?null:P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"sm:hidden space-y-2",children:s.map(t=>P.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md bg-white/60 dark:bg-white/5 px-3 py-2",children:[P.jsxs("div",{className:"min-w-0",children:[P.jsx("div",{className:"truncate text-sm font-medium text-gray-900 dark:text-white",children:t.modelKey}),P.jsxs("div",{className:"truncate text-xs text-gray-600 dark:text-gray-300",children:["Status: ",P.jsx("span",{className:"font-medium",children:t.currentShow||"unknown"})]})]}),P.jsx("a",{href:t.url,target:"_blank",rel:"noreferrer",className:"shrink-0 text-xs text-indigo-600 dark:text-indigo-400 hover:underline",children:"Öffnen"})]},t.id))}),P.jsx("div",{className:"hidden sm:block",children:P.jsx(vm,{rows:s,columns:e,getRowKey:t=>t.id,striped:!0,fullWidth:!0})})]})}const oT=s=>(s||"").replaceAll("\\","/").trim().split("/").pop()||"",U2=s=>{const e=oT(s||"");if(!e)return"—";const t=e.replace(/\.[^.]+$/,""),i=t.match(/^(.*?)_\d{1,2}_\d{1,2}_\d{4}__\d{1,2}-\d{2}-\d{2}$/);if(i?.[1])return i[1];const n=t.lastIndexOf("_");return n>0?t.slice(0,n):t},D$=s=>{if(!Number.isFinite(s)||s<=0)return"—";const e=Math.floor(s/1e3),t=Math.floor(e/3600),i=Math.floor(e%3600/60),n=e%60;return t>0?`${t}h ${i}m`:i>0?`${i}m ${n}s`:`${n}s`},$2=s=>{const e=Date.parse(String(s.startedAt||""));if(!Number.isFinite(e))return"—";const t=s.endedAt?Date.parse(String(s.endedAt)):Date.now();return Number.isFinite(t)?D$(t-e):"—"};function w$({jobs:s,pending:e=[],onOpenPlayer:t,onStopJob:i,blurPreviews:n}){const r=j.useMemo(()=>[{key:"preview",header:"Vorschau",cell:o=>P.jsx(F2,{jobId:o.id,blur:n})},{key:"model",header:"Modelname",cell:o=>{const u=U2(o.output);return P.jsx("span",{className:"truncate",title:u,children:u})}},{key:"sourceUrl",header:"Source",cell:o=>P.jsx("a",{href:o.sourceUrl,target:"_blank",rel:"noreferrer",className:"text-indigo-600 dark:text-indigo-400 hover:underline",onClick:u=>u.stopPropagation(),children:o.sourceUrl})},{key:"output",header:"Datei",cell:o=>oT(o.output||"")},{key:"status",header:"Status"},{key:"runtime",header:"Dauer",cell:o=>$2(o)},{key:"actions",header:"Aktion",srOnlyHeader:!0,align:"right",cell:o=>P.jsx(es,{size:"md",variant:"primary",onClick:u=>{u.stopPropagation(),i(o.id)},children:"Stop"})}],[i]);return s.length===0&&e.length===0?P.jsx(Pn,{grayBody:!0,children:P.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Keine laufenden Downloads."})}):P.jsxs(P.Fragment,{children:[e.length>0&&P.jsx(Pn,{grayBody:!0,header:P.jsxs("div",{className:"flex items-center justify-between gap-3",children:[P.jsxs("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:["Online (wartend Download startet nur bei ",P.jsx("span",{className:"font-semibold",children:"public"}),")"]}),P.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300",children:e.length})]}),children:P.jsx(C$,{models:e})}),s.length===0&&e.length>0&&P.jsx(Pn,{grayBody:!0,children:P.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Kein aktiver Download wartet auf public."})}),s.length>0&&P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"sm:hidden space-y-3",children:s.map(o=>{const u=U2(o.output),c=oT(o.output||""),d=$2(o);return P.jsx("div",{role:"button",tabIndex:0,className:"cursor-pointer",onClick:()=>t(o),onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&t(o)},children:P.jsx(Pn,{header:P.jsxs("div",{className:"flex items-start justify-between gap-3",children:[P.jsxs("div",{className:"min-w-0",children:[P.jsx("div",{className:"truncate text-sm font-medium text-gray-900 dark:text-white",children:u}),P.jsx("div",{className:"truncate text-xs text-gray-600 dark:text-gray-300",children:c||"—"})]}),P.jsx(es,{size:"sm",variant:"primary",onClick:f=>{f.stopPropagation(),i(o.id)},children:"Stop"})]}),children:P.jsxs("div",{className:"flex gap-3",children:[P.jsx("div",{className:"shrink-0",onClick:f=>f.stopPropagation(),children:P.jsx(F2,{jobId:o.id,blur:n})}),P.jsxs("div",{className:"min-w-0 flex-1",children:[P.jsxs("div",{className:"text-xs text-gray-600 dark:text-gray-300",children:["Status: ",P.jsx("span",{className:"font-medium",children:o.status}),P.jsx("span",{className:"mx-2 opacity-60",children:"•"}),"Dauer: ",P.jsx("span",{className:"font-medium",children:d})]}),o.sourceUrl?P.jsx("a",{href:o.sourceUrl,target:"_blank",rel:"noreferrer",className:"mt-1 block truncate text-xs text-indigo-600 dark:text-indigo-400 hover:underline",onClick:f=>f.stopPropagation(),children:o.sourceUrl}):null]})]})})},o.id)})}),P.jsx("div",{className:"hidden sm:block",children:P.jsx(vm,{rows:s,columns:r,getRowKey:o=>o.id,striped:!0,fullWidth:!0,onRowClick:t})})]})]})}function L$({open:s,onClose:e,title:t,children:i,footer:n,icon:r}){return P.jsx(pp,{show:s,as:j.Fragment,children:P.jsxs(Mu,{as:"div",className:"relative z-50",onClose:e,children:[P.jsx(pp.Child,{as:j.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:P.jsx("div",{className:"fixed inset-0 bg-gray-500/75 dark:bg-gray-900/50"})}),P.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center px-4 py-6 sm:p-0",children:P.jsx(pp.Child,{as:j.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",enterTo:"opacity-100 translate-y-0 sm:scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 translate-y-0 sm:scale-100",leaveTo:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",children:P.jsxs(Mu.Panel,{className:"relative w-full max-w-lg transform overflow-hidden rounded-lg bg-white p-6 text-left shadow-xl transition-all dark:bg-gray-800 dark:outline dark:-outline-offset-1 dark:outline-white/10",children:[r&&P.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-green-100 dark:bg-green-500/10",children:r}),t&&P.jsx(Mu.Title,{className:"text-base font-semibold text-gray-900 dark:text-white",children:t}),P.jsx("div",{className:"mt-2 text-sm text-gray-700 dark:text-gray-300",children:i}),n&&P.jsx("div",{className:"mt-6 flex justify-end gap-3",children:n})]})})})]})})}function j2(s,e,t){return Math.max(e,Math.min(t,s))}function nv(s,e){const t=[];for(let i=s;i<=e;i++)t.push(i);return t}function I$(s,e,t,i){if(s<=1)return[1];const n=1,r=s,o=nv(n,Math.min(t,r)),u=nv(Math.max(r-t+1,t+1),r),c=Math.max(Math.min(e-i,r-t-i*2-1),t+1),d=Math.min(Math.max(e+i,t+i*2+2),r-t),f=[];f.push(...o),c>t+1?f.push("ellipsis"):t+1<r-t&&f.push(t+1),f.push(...nv(c,d)),d<r-t?f.push("ellipsis"):r-t>t&&f.push(r-t),f.push(...u);const m=new Set;return f.filter(g=>{const v=String(g);return m.has(v)?!1:(m.add(v),!0)})}function k$({active:s,disabled:e,rounded:t,onClick:i,children:n,title:r}){const o=t==="l"?"rounded-l-md":t==="r"?"rounded-r-md":"";return P.jsx("button",{type:"button",disabled:e,onClick:e?void 0:i,title:r,className:Ut("relative inline-flex items-center px-4 py-2 text-sm font-semibold focus:z-20 focus:outline-offset-0",o,e?"opacity-50 cursor-not-allowed":"cursor-pointer",s?"z-10 bg-indigo-600 text-white focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 dark:bg-indigo-500 dark:focus-visible:outline-indigo-500":"text-gray-900 inset-ring inset-ring-gray-300 hover:bg-gray-50 dark:text-gray-200 dark:inset-ring-gray-700 dark:hover:bg-white/5"),"aria-current":s?"page":void 0,children:n})}function R$({page:s,pageSize:e,totalItems:t,onPageChange:i,siblingCount:n=1,boundaryCount:r=1,showSummary:o=!0,className:u,ariaLabel:c="Pagination",prevLabel:d="Previous",nextLabel:f="Next"}){const m=Math.max(1,Math.ceil((t||0)/Math.max(1,e||1))),g=j2(s||1,1,m);if(m<=1)return null;const v=t===0?0:(g-1)*e+1,b=Math.min(g*e,t),_=I$(m,g,r,n),E=w=>i(j2(w,1,m));return P.jsxs("div",{className:Ut("flex items-center justify-between border-t border-gray-200 bg-white px-4 py-3 sm:px-6 dark:border-white/10 dark:bg-transparent",u),children:[P.jsxs("div",{className:"flex flex-1 justify-between sm:hidden",children:[P.jsx("button",{type:"button",onClick:()=>E(g-1),disabled:g<=1,className:"relative inline-flex items-center rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed dark:border-white/10 dark:bg-white/5 dark:text-gray-200 dark:hover:bg-white/10",children:d}),P.jsx("button",{type:"button",onClick:()=>E(g+1),disabled:g>=m,className:"relative ml-3 inline-flex items-center rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed dark:border-white/10 dark:bg-white/5 dark:text-gray-200 dark:hover:bg-white/10",children:f})]}),P.jsxs("div",{className:"hidden sm:flex sm:flex-1 sm:items-center sm:justify-between",children:[P.jsx("div",{children:o?P.jsxs("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:["Showing ",P.jsx("span",{className:"font-medium",children:v})," to"," ",P.jsx("span",{className:"font-medium",children:b})," of"," ",P.jsx("span",{className:"font-medium",children:t})," results"]}):null}),P.jsx("div",{children:P.jsxs("nav",{"aria-label":c,className:"isolate inline-flex -space-x-px rounded-md shadow-xs dark:shadow-none",children:[P.jsxs("button",{type:"button",onClick:()=>E(g-1),disabled:g<=1,className:"relative inline-flex items-center rounded-l-md px-2 py-2 text-gray-400 inset-ring inset-ring-gray-300 hover:bg-gray-50 focus:z-20 focus:outline-offset-0 disabled:opacity-50 disabled:cursor-not-allowed dark:inset-ring-gray-700 dark:hover:bg-white/5",children:[P.jsx("span",{className:"sr-only",children:d}),P.jsx(PO,{"aria-hidden":"true",className:"size-5"})]}),_.map((w,I)=>w==="ellipsis"?P.jsx("span",{className:"relative inline-flex items-center px-4 py-2 text-sm font-semibold text-gray-700 inset-ring inset-ring-gray-300 dark:text-gray-400 dark:inset-ring-gray-700",children:"…"},`e-${I}`):P.jsx(k$,{active:w===g,onClick:()=>E(w),rounded:"none",children:w},w)),P.jsxs("button",{type:"button",onClick:()=>E(g+1),disabled:g>=m,className:"relative inline-flex items-center rounded-r-md px-2 py-2 text-gray-400 inset-ring inset-ring-gray-300 hover:bg-gray-50 focus:z-20 focus:outline-offset-0 disabled:opacity-50 disabled:cursor-not-allowed dark:inset-ring-gray-700 dark:hover:bg-white/5",children:[P.jsx("span",{className:"sr-only",children:f}),P.jsx(NO,{"aria-hidden":"true",className:"size-5"})]})]})})]})]})}async function hp(s,e){const t=await fetch(s,e);if(!t.ok){const i=await t.text().catch(()=>"");throw new Error(i||`HTTP ${t.status}`)}return t.json()}const H2=(s,e)=>P.jsx("span",{className:Ut("inline-flex items-center rounded-md px-2 py-0.5 text-xs","bg-indigo-50 text-indigo-700 dark:bg-indigo-500/10 dark:text-indigo-200"),children:e});function O$(s){let e=(s??"").trim();if(!e)return null;/^https?:\/\//i.test(e)||(e=`https://${e}`);try{const t=new URL(e);return t.protocol!=="http:"&&t.protocol!=="https:"?null:t.toString()}catch{return null}}function P$(s){if(!s)return[];const e=s.split(",").map(i=>i.trim()).filter(Boolean),t=Array.from(new Set(e));return t.sort((i,n)=>i.localeCompare(n,void 0,{sensitivity:"base"})),t}function G2({children:s,title:e}){return P.jsx("span",{title:e,className:"inline-flex max-w-[11rem] items-center truncate rounded-md bg-sky-50 px-2 py-0.5 text-xs text-sky-700 dark:bg-sky-500/10 dark:text-sky-200",children:s})}function V2({title:s,active:e,hiddenUntilHover:t,onClick:i,icon:n}){return P.jsx("span",{className:Ut(t&&!e?"opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto transition-opacity":"opacity-100"),children:P.jsx(es,{variant:e?"soft":"secondary",size:"xs",className:Ut("px-2 py-1 leading-none",e?"":"bg-transparent shadow-none hover:bg-gray-50 dark:hover:bg-white/10"),title:s,onClick:i,children:P.jsx("span",{className:"text-base leading-none",children:n})})})}function M$(){const[s,e]=j.useState([]),[t,i]=j.useState(!1),[n,r]=j.useState(null),[o,u]=j.useState(""),[c,d]=j.useState(1),f=10,[m,g]=j.useState(""),[v,b]=j.useState(null),[_,E]=j.useState(null),[w,I]=j.useState(!1),[L,F]=j.useState(!1),[$,G]=j.useState(null),[B,V]=j.useState(null),[k,R]=j.useState("favorite"),[z,X]=j.useState(!1),[ee,le]=j.useState(null);async function oe(){if($){X(!0),V(null),r(null);try{const Ee=new FormData;Ee.append("file",$),Ee.append("kind",k);const je=await fetch("/api/models/import",{method:"POST",body:Ee});if(!je.ok)throw new Error(await je.text());const qe=await je.json();V(`✅ Import: ${qe.inserted} neu, ${qe.updated} aktualisiert, ${qe.skipped} übersprungen`),F(!1),G(null),await Z()}catch(Ee){le(Ee?.message??String(Ee))}finally{X(!1)}}}const Y=()=>{le(null),V(null),G(null),R("favorite"),F(!0)},Z=j.useCallback(async()=>{i(!0),r(null);try{const Ee=await hp("/api/models/list");e(Array.isArray(Ee)?Ee:[])}catch(Ee){r(Ee?.message??String(Ee))}finally{i(!1)}},[]);j.useEffect(()=>{Z()},[Z]),j.useEffect(()=>{const Ee=()=>{Z()};return window.addEventListener("models-changed",Ee),()=>window.removeEventListener("models-changed",Ee)},[Z]),j.useEffect(()=>{const Ee=m.trim();if(!Ee){b(null),E(null);return}const je=O$(Ee);if(!je){b(null),E("Bitte nur gültige http(s) URLs einfügen (keine Modelnamen).");return}const qe=window.setTimeout(async()=>{try{const et=await hp("/api/models/parse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:je})});if(!et?.isUrl){b(null),E("Bitte nur URLs einfügen (keine Modelnamen).");return}b(et),E(null)}catch(et){b(null),E(et?.message??String(et))}},300);return()=>window.clearTimeout(qe)},[m]);const Q=j.useMemo(()=>s.map(Ee=>({m:Ee,hay:`${Ee.modelKey} ${Ee.host??""} ${Ee.input??""} ${Ee.tags??""}`.toLowerCase()})),[s]),ae=j.useDeferredValue(o),ue=j.useMemo(()=>{const Ee=ae.trim().toLowerCase();return Ee?Q.filter(je=>je.hay.includes(Ee)).map(je=>je.m):s},[s,Q,ae]);j.useEffect(()=>{d(1)},[o]);const U=ue.length,ie=j.useMemo(()=>Math.max(1,Math.ceil(U/f)),[U,f]);j.useEffect(()=>{c>ie&&d(ie)},[c,ie]);const fe=j.useMemo(()=>{const Ee=(c-1)*f;return ue.slice(Ee,Ee+f)},[ue,c,f]),xe=async()=>{if(v){if(!v.isUrl){E("Bitte nur URLs einfügen (keine Modelnamen).");return}I(!0),r(null);try{const Ee=await hp("/api/models/upsert",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(v)});e(je=>{const qe=je.filter(et=>et.id!==Ee.id);return[Ee,...qe]}),g(""),b(null)}catch(Ee){r(Ee?.message??String(Ee))}finally{I(!1)}}},Ae=async(Ee,je)=>{r(null);try{const qe=await hp("/api/models/flags",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:Ee,...je})});e(et=>{const rt=et.findIndex(qt=>qt.id===qe.id);if(rt===-1)return et;const ht=et.slice();return ht[rt]=qe,ht})}catch(qe){r(qe?.message??String(qe))}},$e=j.useMemo(()=>[{key:"statusAll",header:"Status",align:"center",cell:Ee=>{const je=Ee.liked===!0,qe=Ee.favorite===!0,et=Ee.watching===!0,rt=!et&&!qe&&!je;return P.jsxs("div",{className:"group flex items-center justify-center gap-1",children:[P.jsx("span",{className:Ut(rt&&!et?"opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto transition-opacity":"opacity-100"),children:P.jsx(es,{variant:et?"soft":"secondary",size:"xs",className:Ut("px-2 py-1 leading-none",!et&&"bg-transparent shadow-none hover:bg-gray-50 dark:hover:bg-white/10"),title:et?"Nicht mehr beobachten":"Beobachten",onClick:ht=>{ht.stopPropagation(),Ae(Ee.id,{watching:!et})},children:P.jsx("span",{className:Ut("text-base leading-none",et?"text-indigo-600 dark:text-indigo-400":"text-gray-400 dark:text-gray-500"),children:"👁"})})}),P.jsx(V2,{title:qe?"Favorit entfernen":"Als Favorit markieren",active:qe,hiddenUntilHover:rt,onClick:ht=>{ht.stopPropagation(),qe?Ae(Ee.id,{favorite:!1}):Ae(Ee.id,{favorite:!0,clearLiked:!0})},icon:P.jsx("span",{className:qe?"text-amber-500":"text-gray-400 dark:text-gray-500",children:"★"})}),P.jsx(V2,{title:je?"Gefällt mir entfernen":"Gefällt mir",active:je,hiddenUntilHover:rt,onClick:ht=>{ht.stopPropagation(),je?Ae(Ee.id,{clearLiked:!0}):Ae(Ee.id,{liked:!0,favorite:!1})},icon:P.jsx("span",{className:je?"text-rose-500":"text-gray-400 dark:text-gray-500",children:"♥"})})]})}},{key:"model",header:"Model",cell:Ee=>P.jsxs("div",{className:"min-w-0",children:[P.jsx("div",{className:"font-medium truncate",children:Ee.modelKey}),P.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:Ee.host??"—"})]})},{key:"url",header:"URL",cell:Ee=>P.jsx("a",{href:Ee.input,target:"_blank",rel:"noreferrer",className:"text-indigo-600 dark:text-indigo-400 hover:underline truncate block max-w-[520px]",onClick:je=>je.stopPropagation(),title:Ee.input,children:Ee.input})},{key:"tags",header:"Tags",cell:Ee=>{const je=P$(Ee.tags),qe=je.slice(0,6),et=je.length-qe.length,rt=je.join(", ");return P.jsxs("div",{className:"flex flex-wrap gap-2",title:rt||void 0,children:[Ee.hot?H2(!0,"🔥 HOT"):null,Ee.keep?H2(!0,"📌 Behalten"):null,qe.map(ht=>P.jsx(G2,{title:ht,children:ht},ht)),et>0?P.jsxs(G2,{title:rt,children:["+",et]}):null,!Ee.hot&&!Ee.keep&&je.length===0?P.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:"—"}):null]})}}],[]);return P.jsxs("div",{className:"space-y-4",children:[P.jsx(Pn,{header:P.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Model hinzufügen"}),grayBody:!0,children:P.jsxs("div",{className:"grid gap-2",children:[P.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[P.jsx("input",{value:m,onChange:Ee=>g(Ee.target.value),placeholder:"https://…",className:"flex-1 rounded-md px-3 py-2 text-sm bg-white text-gray-900 dark:bg-white/10 dark:text-white"}),P.jsx(es,{className:"px-3 py-2 text-sm",onClick:xe,disabled:!v||w,title:v?"In Models speichern":"Bitte gültige URL einfügen",children:"Hinzufügen"}),P.jsx(es,{className:"px-3 py-2 text-sm",onClick:Z,disabled:t,children:"Aktualisieren"})]}),_?P.jsx("div",{className:"text-xs text-red-600 dark:text-red-300",children:_}):v?P.jsxs("div",{className:"text-xs text-gray-600 dark:text-gray-300",children:["Gefunden: ",P.jsx("span",{className:"font-medium",children:v.modelKey}),v.host?P.jsxs("span",{className:"opacity-70",children:[" • ",v.host]}):null]}):null,n?P.jsx("div",{className:"text-xs text-red-600 dark:text-red-300",children:n}):null]})}),P.jsxs(Pn,{header:P.jsxs("div",{className:"flex items-center justify-between gap-2",children:[P.jsxs("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:["Models (",ue.length,")"]}),P.jsxs("div",{className:"flex items-center gap-2",children:[P.jsx(es,{variant:"secondary",size:"sm",onClick:Y,children:"Importieren"}),P.jsx("input",{value:o,onChange:Ee=>u(Ee.target.value),placeholder:"Suchen…",className:"w-[220px] rounded-md px-3 py-2 text-sm bg-white text-gray-900 dark:bg-white/10 dark:text-white"})]})]}),noBodyPadding:!0,children:[P.jsx(vm,{rows:fe,columns:$e,getRowKey:Ee=>Ee.id,striped:!0,compact:!0,fullWidth:!0,stickyHeader:!0,onRowClick:Ee=>Ee.input&&window.open(Ee.input,"_blank","noreferrer")}),P.jsx(R$,{page:c,pageSize:f,totalItems:U,onPageChange:d})]}),P.jsx(L$,{open:L,onClose:()=>!z&&F(!1),title:"Models importieren",footer:P.jsxs(P.Fragment,{children:[P.jsx(es,{variant:"secondary",onClick:()=>F(!1),disabled:z,children:"Abbrechen"}),P.jsx(es,{variant:"primary",onClick:oe,isLoading:z,disabled:!$||z,children:"Import starten"})]}),children:P.jsxs("div",{className:"space-y-3",children:[P.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Wähle eine CSV-Datei zum Import aus."}),P.jsxs("div",{className:"space-y-2",children:[P.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Import-Typ"}),P.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:gap-4",children:[P.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-gray-700 dark:text-gray-300",children:[P.jsx("input",{type:"radio",name:"import-kind",value:"favorite",checked:k==="favorite",onChange:()=>R("favorite"),disabled:z}),"Favoriten (★)"]}),P.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-gray-700 dark:text-gray-300",children:[P.jsx("input",{type:"radio",name:"import-kind",value:"liked",checked:k==="liked",onChange:()=>R("liked"),disabled:z}),"Gefällt mir (♥)"]})]})]}),P.jsx("input",{type:"file",accept:".csv,text/csv",onChange:Ee=>{const je=Ee.target.files?.[0]??null;le(null),G(je)},className:"block w-full text-sm text-gray-700 file:mr-4 file:rounded-md file:border-0 file:bg-gray-100 file:px-3 file:py-2 file:text-sm file:font-semibold file:text-gray-900 hover:file:bg-gray-200 dark:text-gray-200 dark:file:bg-white/10 dark:file:text-white dark:hover:file:bg-white/20"}),$?P.jsxs("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:["Ausgewählt: ",P.jsx("span",{className:"font-medium",children:$.name})]}):null,ee?P.jsx("div",{className:"text-xs text-red-600 dark:text-red-300",children:ee}):null,B?P.jsx("div",{className:"rounded-md bg-green-50 px-3 py-2 text-xs text-green-700 dark:bg-green-500/10 dark:text-green-200",children:B}):null]})})]})}const rv="record_cookies";function fp(s){return Object.fromEntries(Object.entries(s??{}).map(([t,i])=>[t.trim().toLowerCase(),String(i??"").trim()]).filter(([t,i])=>t.length>0&&i.length>0))}async function Es(s,e){const t=await fetch(s,e);if(!t.ok){const i=await t.text().catch(()=>"");throw new Error(i||`HTTP ${t.status}`)}return t.json()}const N$={recordDir:"records",doneDir:"records/done",ffmpegPath:"",autoAddToDownloadList:!1,autoStartAddedDownloads:!1,useChaturbateApi:!1,blurPreviews:!1};function q2(s){const e=(s??"").trim();if(!e)return null;for(const t of e.split(/\s+/g))if(/^https?:\/\//i.test(t))try{return new URL(t).toString()}catch{}return null}const vn=s=>(s||"").replaceAll("\\","/").split("/").pop()||"";function av(s,e){const i=(s||"").replaceAll("\\","/").split("/");return i[i.length-1]=e,i.join("/")}function B$(s){return s.startsWith("HOT ")?s.slice(4):s}const F$=/^(.*?)_\d{1,2}_\d{1,2}_\d{4}__\d{1,2}-\d{2}-\d{2}/;function U$(s){const t=B$(vn(s)).replace(/\.[^.]+$/,""),i=t.match(F$);if(i?.[1]?.trim())return i[1].trim();const n=t.lastIndexOf("_");return n>0?t.slice(0,n):t||null}function $$(){const[s,e]=j.useState(""),[,t]=j.useState(null),[,i]=j.useState(null),[n,r]=j.useState([]),[o,u]=j.useState([]),[c,d]=j.useState(0),[f,m]=j.useState(0),[g,v]=j.useState(null),b=j.useRef(null),[,_]=j.useState(null),[E,w]=j.useState(!1),[I,L]=j.useState(!1),[F,$]=j.useState({}),[G,B]=j.useState(!1),[V,k]=j.useState("running"),[R,z]=j.useState(null),[X,ee]=j.useState(!1),[le,oe]=j.useState(N$),Y=!!le.autoAddToDownloadList,Z=!!le.autoStartAddedDownloads,Q=j.useRef(!1),ae=j.useRef({}),ue=j.useRef([]);j.useEffect(()=>{Q.current=E},[E]),j.useEffect(()=>{ae.current=F},[F]),j.useEffect(()=>{ue.current=n},[n]);const U=j.useRef(null),ie=j.useRef("");j.useEffect(()=>{let we=!1;const Fe=async()=>{try{const Ye=await Es("/api/settings",{cache:"no-store"});!we&&Ye&&oe(gt=>({...gt,...Ye}))}catch{}},Ue=()=>{Fe()},Ke=()=>{Fe()};return window.addEventListener("recorder-settings-updated",Ue),window.addEventListener("focus",Ke),document.addEventListener("visibilitychange",Ke),Fe(),()=>{we=!0,window.removeEventListener("recorder-settings-updated",Ue),window.removeEventListener("focus",Ke),document.removeEventListener("visibilitychange",Ke)}},[]),j.useEffect(()=>{let we=!1;const Fe=async()=>{try{const Ke=await Es("/api/models/meta",{cache:"no-store"}),Ye=Number(Ke?.count??0);!we&&Number.isFinite(Ye)&&m(Ye)}catch{}};Fe();const Ue=window.setInterval(Fe,document.hidden?6e4:3e4);return()=>{we=!0,window.clearInterval(Ue)}},[]);const fe=j.useMemo(()=>Object.entries(F).map(([we,Fe])=>({name:we,value:Fe})),[F]),xe=we=>{z(we),ee(!1)},Ae=n.filter(we=>we.status==="running"),$e=[{id:"running",label:"Laufende Downloads",count:Ae.length},{id:"finished",label:"Abgeschlossene Downloads",count:c},{id:"models",label:"Models",count:f},{id:"settings",label:"Einstellungen"}],Ee=j.useMemo(()=>s.trim().length>0&&!E,[s,E]);j.useEffect(()=>{let we=!1;return(async()=>{try{const Ue=await Es("/api/cookies",{cache:"no-store"}),Ke=fp(Ue?.cookies);if(we||$(Ke),Object.keys(Ke).length===0){const Ye=localStorage.getItem(rv);if(Ye)try{const gt=JSON.parse(Ye),Lt=fp(gt);Object.keys(Lt).length>0&&(we||$(Lt),await Es("/api/cookies",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cookies:Lt})}))}catch{}}}catch{const Ue=localStorage.getItem(rv);if(Ue)try{const Ke=JSON.parse(Ue);we||$(fp(Ke))}catch{}}finally{we||B(!0)}})(),()=>{we=!0}},[]),j.useEffect(()=>{G&&localStorage.setItem(rv,JSON.stringify(F))},[F,G]),j.useEffect(()=>{let we=!1,Fe;const Ue=async()=>{try{const Ye=await fetch("/api/record/done/meta",{cache:"no-store"});if(!Ye.ok)return;const gt=await Ye.json();we||d(gt.count??0)}catch{}finally{if(!we){const Ye=document.hidden?6e4:3e4;Fe=window.setTimeout(Ue,Ye)}}},Ke=()=>{document.hidden||Ue()};return document.addEventListener("visibilitychange",Ke),Ue(),()=>{we=!0,Fe&&window.clearTimeout(Fe),document.removeEventListener("visibilitychange",Ke)}},[]),j.useEffect(()=>{if(s.trim()===""){t(null),i(null);return}const we=setTimeout(async()=>{try{const Fe=await Es("/api/models/parse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:s.trim()})});t(Fe),i(null)}catch(Fe){t(null),i(Fe?.message??String(Fe))}},300);return()=>clearTimeout(we)},[s]),j.useEffect(()=>{let we=!1;const Fe=async()=>{try{const Ke=await Es("/api/record/list");we||r(Array.isArray(Ke)?Ke:[])}catch{}};Fe();const Ue=setInterval(Fe,1e3);return()=>{we=!0,clearInterval(Ue)}},[]),j.useEffect(()=>{if(V!=="finished")return;let we=!1,Fe=!1;const Ue=async()=>{if(!(we||Fe)){Fe=!0;try{const $t=await Es("/api/record/done",{cache:"no-store"});we||u(Array.isArray($t)?$t:[])}catch{we||u([])}finally{Fe=!1}}};Ue();const Ye=document.hidden?6e4:2e4,gt=window.setInterval(Ue,Ye),Lt=()=>{document.hidden||Ue()};return document.addEventListener("visibilitychange",Lt),()=>{we=!0,window.clearInterval(gt),document.removeEventListener("visibilitychange",Lt)}},[V]);function je(we){try{return new URL(we).hostname.includes("chaturbate.com")}catch{return!1}}function qe(we,Fe){const Ue=Object.fromEntries(Object.entries(we).map(([Ke,Ye])=>[Ke.trim().toLowerCase(),Ye]));for(const Ke of Fe){const Ye=Ue[Ke.toLowerCase()];if(Ye)return Ye}}function et(we){const Fe=qe(we,["cf_clearance"]),Ue=qe(we,["sessionid","session_id","sessionid","sessionId"]);return!!(Fe&&Ue)}const rt=j.useCallback(async(we,Fe)=>{const Ue=we.trim();if(!Ue||Q.current)return!1;const Ke=!!Fe?.silent;Ke||_(null);const Ye=ae.current;if(je(Ue)&&!et(Ye))return Ke||_('Für Chaturbate müssen die Cookies "cf_clearance" und "sessionId" gesetzt sein.'),!1;if(ue.current.some(Lt=>Lt.status==="running"&&String(Lt.sourceUrl||"")===Ue))return!0;w(!0),Q.current=!0;try{const Lt=Object.entries(Ye).map(([fi,pi])=>`${fi}=${pi}`).join("; "),$t=await Es("/api/record",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:Ue,cookie:Lt})});return r(fi=>[$t,...fi]),ue.current=[$t,...ue.current],!0}catch(Lt){return Ke||_(Lt?.message??String(Lt)),!1}finally{w(!1),Q.current=!1}},[]);async function ht(we){const Fe=we.sourceUrl??we.SourceURL??"",Ue=q2(Fe);if(Ue){const pi=await Es("/api/models/parse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:Ue})});return await Es("/api/models/upsert",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(pi)})}const Ke=U$(we.output||"");if(!Ke)return null;const Ye=Date.now(),gt=b.current;if(!gt||Ye-gt.ts>3e4){const pi=await Es("/api/models/list",{cache:"no-store"});b.current={ts:Ye,list:Array.isArray(pi)?pi:[]}}const Lt=b.current?.list??[],$t=Ke.toLowerCase(),fi=Lt.filter(pi=>(pi.modelKey||"").toLowerCase()===$t);return fi.length===0?null:fi.sort((pi,ts)=>+!!ts.favorite-+!!pi.favorite)[0]}j.useEffect(()=>{let we=!1;if(!R){v(null);return}return(async()=>{try{const Fe=await ht(R);we||v(Fe)}catch{we||v(null)}})(),()=>{we=!0}},[R]);async function qt(){return rt(s)}const xt=j.useCallback(async we=>{const Fe=vn(we.output||"");if(Fe){window.dispatchEvent(new CustomEvent("finished-downloads:delete",{detail:{file:Fe,phase:"start"}}));try{await Es(`/api/record/delete?file=${encodeURIComponent(Fe)}`,{method:"POST"}),window.dispatchEvent(new CustomEvent("finished-downloads:delete",{detail:{file:Fe,phase:"success"}})),window.setTimeout(()=>{u(Ue=>Ue.filter(Ke=>vn(Ke.output||"")!==Fe)),r(Ue=>Ue.filter(Ke=>vn(Ke.output||"")!==Fe)),z(Ue=>Ue&&vn(Ue.output||"")===Fe?null:Ue)},320)}catch(Ue){throw window.dispatchEvent(new CustomEvent("finished-downloads:delete",{detail:{file:Fe,phase:"error"}})),Ue}}},[]),Ri=j.useCallback(async we=>{const Fe=vn(we.output||"");if(!Fe)return;const Ue=await Es(`/api/record/toggle-hot?file=${encodeURIComponent(Fe)}`,{method:"POST"}),Ke=av(we.output||"",Ue.newFile);z(Ye=>Ye&&{...Ye,output:Ke}),u(Ye=>Ye.map(gt=>vn(gt.output||"")===Fe?{...gt,output:av(gt.output||"",Ue.newFile)}:gt)),r(Ye=>Ye.map(gt=>vn(gt.output||"")===Fe?{...gt,output:av(gt.output||"",Ue.newFile)}:gt))},[]);async function Be(we){return Es("/api/models/flags",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(we)})}const Xe=j.useCallback(async we=>{const Fe=vn(we.output||""),Ue=!!(R&&vn(R.output||"")===Fe);let Ke=Ue?g:null;if(Ke||(Ke=await ht(we)),!Ke)return;const Ye=!Ke.favorite,gt=await Be({id:Ke.id,favorite:Ye,...Ye?{clearLiked:!0}:{}});Ue&&v(gt),window.dispatchEvent(new Event("models-changed"))},[R,g]),ft=j.useCallback(async we=>{const Fe=vn(we.output||""),Ue=!!(R&&vn(R.output||"")===Fe);let Ke=Ue?g:null;if(Ke||(Ke=await ht(we)),!Ke)return;const gt=Ke.liked===!0?await Be({id:Ke.id,clearLiked:!0}):await Be({id:Ke.id,liked:!0,favorite:!1});Ue&&v(gt),window.dispatchEvent(new Event("models-changed"))},[R,g]);j.useEffect(()=>{if(!Y&&!Z||!navigator.clipboard?.readText)return;let we=!1,Fe=!1,Ue=null;const Ke=async()=>{if(!(we||Fe)){Fe=!0;try{const Lt=await navigator.clipboard.readText(),$t=q2(Lt);if(!$t||$t===ie.current)return;ie.current=$t,Y&&e($t),Z&&(Q.current?U.current=$t:(U.current=null,await rt($t)))}catch{}finally{Fe=!1}}},Ye=Lt=>{we||(Ue=window.setTimeout(async()=>{await Ke(),Ye(document.hidden?5e3:1500)},Lt))},gt=()=>{Ke()};return window.addEventListener("focus",gt),document.addEventListener("visibilitychange",gt),Ye(0),()=>{we=!0,Ue&&window.clearTimeout(Ue),window.removeEventListener("focus",gt),document.removeEventListener("visibilitychange",gt)}},[Y,Z,rt]),j.useEffect(()=>{if(E||!Z)return;const we=U.current;we&&(U.current=null,rt(we))},[E,Z,rt]);async function At(we){try{await Es(`/api/record/stop?id=${encodeURIComponent(we)}`,{method:"POST"})}catch{}}return P.jsxs("div",{className:"mx-auto py-4 max-w-7xl sm:px-6 lg:px-8 space-y-6",children:[P.jsxs(Pn,{header:P.jsxs("div",{className:"flex items-start justify-between gap-4",children:[P.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-white",children:"Recorder"}),P.jsxs("div",{className:"flex gap-2",children:[P.jsx(es,{variant:"secondary",onClick:()=>L(!0),children:"Cookies"}),P.jsx(es,{variant:"primary",onClick:qt,disabled:!Ee,children:"Start"})]})]}),children:[P.jsx("label",{className:"block text-sm font-medium text-gray-900 dark:text-gray-200",children:"Source URL"}),P.jsx("input",{value:s,onChange:we=>e(we.target.value),placeholder:"https://…",className:"mt-1 block w-full rounded-md px-3 py-2 text-sm bg-white text-gray-900 dark:bg-white/10 dark:text-white"}),je(s)&&!et(F)&&P.jsxs("div",{className:"mt-2 text-xs text-amber-600 dark:text-amber-400",children:["⚠️ Für Chaturbate werden die Cookies ",P.jsx("code",{children:"cf_clearance"})," und"," ",P.jsx("code",{children:"sessionId"})," benötigt."]})]}),P.jsx(LO,{tabs:$e,value:V,onChange:k,ariaLabel:"Tabs",variant:"pillsBrand"}),V==="running"&&P.jsx(w$,{jobs:Ae,onOpenPlayer:xe,onStopJob:At,blurPreviews:!!le.blurPreviews}),V==="finished"&&P.jsx(mP,{jobs:n,doneJobs:o,onOpenPlayer:xe,onDeleteJob:xt,onToggleHot:Ri,onToggleFavorite:Xe,onToggleLike:ft,blurPreviews:!!le.blurPreviews}),V==="models"&&P.jsx(M$,{}),V==="settings"&&P.jsx(IO,{}),P.jsx(CO,{open:I,onClose:()=>L(!1),initialCookies:fe,onApply:we=>{const Fe=fp(Object.fromEntries(we.map(Ue=>[Ue.name,Ue.value])));$(Fe),Es("/api/cookies",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cookies:Fe})}).catch(()=>{})}}),R&&P.jsx(_B,{job:R,expanded:X,onToggleExpand:()=>ee(we=>!we),onClose:()=>z(null),isHot:vn(R.output||"").startsWith("HOT "),isFavorite:!!g?.favorite,isLiked:g?.liked===!0,onDelete:xt,onToggleHot:Ri,onToggleFavorite:Xe,onToggleLike:ft})]})}fk.createRoot(document.getElementById("root")).render(P.jsx(j.StrictMode,{children:P.jsx($$,{})}));