@vkontakte/videoplayer-core 2.0.181-beta.0 → 2.0.181-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es2015.esm.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @vkontakte/videoplayer-core v2.0.181-beta.0
3
- * Wed, 28 Oct 2026 20:44:16 GMT
2
+ * @vkontakte/videoplayer-core v2.0.181-beta.1
3
+ * Mon, 02 Nov 2026 13:10:41 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/2-0-181/doc/
5
5
  */
6
- import{objectEntries as ce}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as le}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as ue}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as de,assertNonNullable as fe,isNonNullable as pe,ValueSubject as me,Subject as he,Subscription as ge,merge as _e,observableFrom as ve,fromEvent as ye,map as be,tap as xe,filterChanged as Se,isNullable as Ce,ErrorCategory as we}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as Oe,combine as ke,debounce as Ae,ErrorCategory as je,filter as Me,filterChanged as Ne,isNonNullable as Pe,isNullable as Fe,map as Ie,Subscription as Le,ValueSubject as Re}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as ze,assertNonNullable as Be,ErrorCategory as Ve,getHighestQuality as He,isNonNullable as Ue}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as We}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as Ge}from"@vkontakte/videoplayer-shared/es2015";import{createTimers as tt,TimerModule as nt}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as it}from"@vkontakte/videoplayer-shared/es2015";import{isBrowserWindow as at,ValueSubject as ot}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as st}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as ct,isNullable as lt}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as N}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as dt,isBrowserWindow as ft}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as ht,isBrowserWindow as gt}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as bt,isBrowserWindow as xt}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as Ft,isBrowserWindow as It}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as Wt,ErrorCategory as Gt,filter as Kt,Subject as qt,Subscription as Jt,tap as Yt,ValueSubject as Xt,fromEvent as Zt,getWindow as Qt}from"@vkontakte/videoplayer-shared/es2015";import{ValueSubject as nn,Subject as rn,map as an,Subscription as on,combine as sn,filterChanged as cn,assertNonNullable as ln}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as dn}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as fn}from"@vkontakte/videoplayer-shared/es2015";import{objectFromEntries as pn}from"@vkontakte/videoplayer-shared/es2015";import{promiseFinally as mn}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as hn,Subject as gn,merge as _n}from"@vkontakte/videoplayer-shared/es2015";import"@vkontakte/videoplayer-shared/es2015";import{assertNever as bn,debounce as xn,ErrorCategory as Sn,fromEvent as Cn,map as wn,merge as Tn,observableFrom as En,Subject as Dn,Subscription as On,timeout as kn}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Fn}from"@vkontakte/videoplayer-shared/es2015";import{clearVideoElement as In,fromEvent as Ln,getWindow as Rn,Subscription as zn}from"@vkontakte/videoplayer-shared/es2015";import{clearVideoElement as Bn}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as tr}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as nr,map as rr,Subject as ir,Subscription as ar,ErrorCategory as or}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as sr,isNullable as cr,Subscription as lr}from"@vkontakte/videoplayer-shared/es2015";import{fromEvent as F,map as xr,merge as Sr,filterChanged as Cr,isNonNullable as wr,Subject as Tr,filter as Er,mapTo as Dr,combine as Or,once as kr,shareReplay as I,throttle as Ar,ErrorCategory as jr,ErrorOrigin as Mr,ValueSubject as Nr,Subscription as Pr}from"@vkontakte/videoplayer-shared/es2015";import{VideoQuality as Br}from"@vkontakte/videoplayer-shared/es2015";import{assertNotEmptyArray as Hr,getWindow as Ur,isInvariantQuality as Wr,ValueSubject as Gr}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as Kr}from"@vkontakte/videoplayer-shared/es2015";import{objectFromEntries as qr}from"@vkontakte/videoplayer-shared/es2015";import{now as Yr}from"@vkontakte/videoplayer-shared/es2015";import{flattenObject as Zr,isInvariantQuality as Qr,isLowerOrEqual as $r,isNonNullable as ei,now as ti}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as ni}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as ri}from"@vkontakte/videoplayer-shared/es2015";import{isLowerOrEqual as ii,isNonNullable as ai,isNullable as oi}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as Si,isNonNullable as Ci,isNullable as wi}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as Ti}from"@vkontakte/videoplayer-shared/es2015";import{Subscription as Ei}from"@vkontakte/videoplayer-shared/es2015";import{Subscription as ki}from"@vkontakte/videoplayer-shared/es2015";import{isHigher as Vi,isInvariantQuality as Hi,isNonNullable as Ui}from"@vkontakte/videoplayer-shared/es2015";import{isHigherOrEqual as Gi,isLowerOrEqual as Ki,isNonNullable as qi,videoSizeToQuality as Ji}from"@vkontakte/videoplayer-shared/es2015";import{isHigherOrEqual as Xi,isNullable as Zi}from"@vkontakte/videoplayer-shared/es2015";import{isHigher as Qi,isLower as $i,isNonNullable as ea,isNullable as ta,videoHeightToQuality as na}from"@vkontakte/videoplayer-shared/es2015";import{isHigherOrEqual as ca,isNonNullable as la,isNullable as ua,now as da}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as pa}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as ma}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as _a,isLowerOrEqual as va,isNonNullable as ya,isNullable as ba}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as Sa}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as wa,now as Ta}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as ja,assertNonNullable as Ma,combine as Na,debounce as Pa,ErrorCategory as Fa,filter as Ia,filterChanged as La,isNonNullable as Ra,map as za,merge as Ba,observableFrom as Va,once as Ha,Subscription as Ua,ValueSubject as Wa,videoQualityToHeight as Ga,videoSizeToQuality as Ka}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as qa}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as Xa,isNullable as Za,assertNonNullable as Qa}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as $a}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as eo,assertNonNullable as to,now as no}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as po}from"@vkontakte/videoplayer-shared/es2015";import{Subject as ho}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as go}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as vo}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as yo}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as Oo}from"@vkontakte/videoplayer-shared/es2015";import{debounce as ko,filter as Ao,fromEvent as jo,interval as Mo,isHigher as No,isInvariantQuality as Po,isLower as Fo,merge as Io,Subject as Lo,Subscription as Ro}from"@vkontakte/videoplayer-shared/es2015";import{map as Vo,Observable as Ho}from"@vkontakte/videoplayer-shared/es2015";import{fromEvent as Uo}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Ko}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as qo}from"@vkontakte/videoplayer-shared/es2015";import{filter as gs,filterChanged as _s,isNonNullable as vs}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as ys,assertNonNullable as bs,debounce as xs,ErrorCategory as Ss,filter as Cs,filterChanged as ws,fromEvent as Ts,isNonNullable as Es,isNullable as Ds,map as Os,mapTo as ks,merge as As,observableFrom as js,once as Ms,Subscription as Ns,throttle as Ps}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as Fs}from"@vkontakte/videoplayer-shared/es2015";import{videoSizeToQuality as Is}from"@vkontakte/videoplayer-shared/es2015";import{isNullable as Ws,now as Gs,once as Ks,Subscription as qs,ValueSubject as Js,safeStorage as Ys,filterChanged as Xs}from"@vkontakte/videoplayer-shared/es2015";import{combine as ac,map as oc,observeElementSize as sc,Subscription as cc,ValueSubject as lc,noop as uc}from"@vkontakte/videoplayer-shared/es2015";import{filter as fc,map as pc,once as mc}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as gc}from"@vkontakte/videoplayer-shared/es2015";import{filterChanged as _c,isNonNullable as vc,isNullable as yc,now as bc,once as xc,Subscription as Sc,ValueSubject as Cc}from"@vkontakte/videoplayer-shared/es2015";import{isInvariantQuality as Tc,isNonNullable as Ec,isNullable as Dc,Subscription as Oc,ValueSubject as kc}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as Ac}from"@vkontakte/videoplayer-shared/es2015";import{arrayFlatMap as Bc}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as Vc}from"@vkontakte/videoplayer-shared/es2015";import{stringTrimStart as Hc}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as Uc}from"@vkontakte/videoplayer-shared/es2015";import{abortable as Gc,assertNonNullable as Kc,ErrorCategory as qc,ErrorOrigin as Jc,filter as Yc,filterChanged as Xc,flattenObject as Zc,fromEvent as Qc,getTraceSubscriptionMethod as $c,getWindow as el,interval as tl,isNonNullable as z,isNullable as nl,map as rl,merge as il,nowInt as al,Subject as ol,Subscription as sl,SubscriptionRemovable as cl,ValueSubject as B}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as ll}from"@vkontakte/videoplayer-shared/es2015";import{fetchPolyfilled as ul}from"@vkontakte/videoplayer-shared/es2015";import{promiseFinally as dl}from"@vkontakte/videoplayer-shared/es2015";import{abortable as ml,assertNever as hl,devNull as gl,ErrorCategory as _l,flattenObject as vl,fromEvent as yl,getWindow as bl,isNonNullable as xl,isNullable as Sl,merge as Cl,now as wl,Subject as Tl,Subscription as El,suppressAbort as Dl,ValueSubject as Ol,VideoQuality as kl,isAbortError as Al}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as Ml,ErrorOrigin as Nl,isNullable as Pl,parseUnsignedInt as Fl}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as Vl,isNullable as Hl,getWindow as Ul}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as ou,isNonNullable as su}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as _u}from"@vkontakte/videoplayer-shared/es2015";import{stringReplaceAll as bu}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as xu}from"@vkontakte/videoplayer-shared/es2015";import{stringPadStart as Su}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as Cu}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as wu}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Tu}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Eu}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as Ou,isNullable as ku}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Au}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as Lu}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as Ru}from"@vkontakte/videoplayer-shared/es2015";import{requestIdleCallbackPolyfilled as zu}from"@vkontakte/videoplayer-shared/es2015";import{abortable as Bu,assertNonNullable as Vu,ErrorCategory as Hu,ErrorOrigin as Uu,flattenObject as V,fromEvent as Wu,getExponentialDelay as Gu,getWindow as Ku,isAbortError as qu,isHigher as Ju,isNonNullable as H,isNullable as U,once as Yu,Subject as Xu,Subscription as Zu,ValueSubject as Qu,videoQualityToHeight as $u,VideoQuality as ed}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as td}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as ad}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Id}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as Ld,isNonNullable as Rd,isNullable as zd}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as Bd}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as Zd}from"@vkontakte/videoplayer-shared/es2015";import{videoSizeToQuality as Qd}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as df,getWindow as ff,isNonNullable as pf,isNullable as mf,now as hf,isAbortError as gf}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as vf,getWindow as yf,isAbortError as bf,isNullable as xf,now as Sf}from"@vkontakte/videoplayer-shared/es2015";import{arrayFlatMap as wf}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as Tf,ErrorCategory as Ef,isNullable as Df,ValueSubject as Of}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as jf,fromEvent as Mf,isNullable as Nf,Subject as Pf,Subscription as Ff,ValueSubject as If}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as Lf,ErrorCategory as Rf,Subject as zf}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as Kf}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as qf,isHigher as Jf,isLower as Yf,isLowerOrEqual as Xf,VideoQuality as Zf}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as up,combine as dp,ErrorCategory as fp,filter as pp,filterChanged as mp,fromEvent as hp,isNonNullable as gp,map as _p,merge as vp}from"@vkontakte/videoplayer-shared/es2015";import{combine as xp,merge as Sp,filter as Cp,filterChanged as wp,isNullable as Tp,map as Ep,ValueSubject as Dp,isNonNullable as Op}from"@vkontakte/videoplayer-shared/es2015";import{isNullable as Ip,ValueSubject as Lp}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as Up,combine as Wp,ErrorCategory as Gp,filter as Kp,filterChanged as qp,fromEvent as Jp,interval as Yp,isNonNullable as Xp,isNullable as Zp,map as Qp,now as $p,throttle as em}from"@vkontakte/videoplayer-shared/es2015";import{isNullable as nm,ValueSubject as rm}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as sm,assertNonNullable as cm,combine as lm,debounce as um,ErrorCategory as dm,filter as fm,filterChanged as pm,fromEvent as mm,isNonNullable as hm,isNullable as gm,map as _m,merge as vm,observableFrom as ym,once as bm,Subscription as xm,throttle as Sm}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as Cm}from"@vkontakte/videoplayer-shared/es2015";import{arrayFlatMap as wm}from"@vkontakte/videoplayer-shared/es2015";import{abortable as Dm,assertNonNullable as Om,combine as km,ErrorCategory as Am,ErrorOrigin as jm,filter as Mm,filterChanged as Nm,flattenObject as Pm,fromEvent as Fm,getTraceSubscriptionMethod as Im,interval as Lm,isNonNullable as Rm,isNullable as zm,map as Bm,merge as Vm,now as Hm,Subject as Um,Subscription as Wm,SubscriptionRemovable as Gm,tap as Km,throttle as qm,ValueSubject as W}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as Jm}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Ym}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as Xm}from"@vkontakte/videoplayer-shared/es2015";import{arrayFlatMap as Zm}from"@vkontakte/videoplayer-shared/es2015";import{cancelIdleCallbackPolyfilled as Qm}from"@vkontakte/videoplayer-shared/es2015";import{requestIdleCallbackPolyfilled as $m}from"@vkontakte/videoplayer-shared/es2015";import{promiseFinally as eh}from"@vkontakte/videoplayer-shared/es2015";import{promiseAllSettled as th}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as nh,ErrorCategory as rh,Subject as ih}from"@vkontakte/videoplayer-shared/es2015";import{abortable as uh,assertNonNullable as dh,ErrorCategory as fh,ErrorOrigin as ph,flattenObject as mh,fromEvent as hh,getExponentialDelay as gh,getWindow as _h,isHigher as vh,isNonNullable as yh,isNullable as G,now as bh,once as xh,Subject as Sh,Subscription as Ch,ValueSubject as wh,videoQualityToHeight as Th,VideoQuality as Eh,isAbortError as Dh}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as kh}from"@vkontakte/videoplayer-shared/es2015";import{fetchPolyfilled as Ah}from"@vkontakte/videoplayer-shared/es2015";import{promiseFinally as jh}from"@vkontakte/videoplayer-shared/es2015";import{abortable as Mh,assertNever as Nh,devNull as Ph,fromEvent as Fh,merge as Ih,now as Lh,Subject as Rh,ValueSubject as zh,VideoQuality as Bh,flattenObject as Vh,ErrorCategory as Hh,SubscriptionRemovable as Uh,getWindow as Wh,isNonNullable as Gh,isNullable as Kh,suppressAbort as qh}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as Jh,ErrorOrigin as Yh,isNullable as Xh,parseUnsignedInt as Zh}from"@vkontakte/videoplayer-shared/es2015";import{isNullable as ig,ValueSubject as ag}from"@vkontakte/videoplayer-shared/es2015";import{combine as fg,merge as pg,filter as mg,filterChanged as hg,isNullable as gg,map as _g,ValueSubject as vg,isNonNullable as yg}from"@vkontakte/videoplayer-shared/es2015";import{fetchPolyfilled as xg}from"@vkontakte/videoplayer-shared/es2015";import{fetchPolyfilled as Sg}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as Tg,combine as Eg,debounce as Dg,ErrorCategory as Og,filter as kg,filterChanged as Ag,isNonNullable as jg,isNullable as Mg,map as Ng,merge as Pg,observableFrom as Fg,Subscription as Ig,ValueSubject as Lg,VideoQuality as Rg}from"@vkontakte/videoplayer-shared/es2015";import{objectFromEntries as zg}from"@vkontakte/videoplayer-shared/es2015";import{fetchPolyfilled as Bg}from"@vkontakte/videoplayer-shared/es2015";import{videoSizeToQuality as Vg,getExponentialDelay as Hg}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as Zg}from"@vkontakte/videoplayer-shared/es2015";import{fetchPolyfilled as Qg}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as $g,Subscription as e_,throttle as t_,ValueSubject as n_,Subject as r_,ErrorCategory as i_}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as s_,debounce as c_,ErrorCategory as l_,fromEvent as u_,isInvariantQuality as d_,isNonNullable as f_,isNullable as p_,map as m_,merge as h_,observableFrom as g_,Subscription as __,ValueSubject as v_,VideoQuality as y_}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as x_}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as S_}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as C_}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as w_,assertNonNullable as T_,debounce as E_,ErrorCategory as D_,isHigherOrEqual as O_,isLowerOrEqual as k_,isNonNullable as A_,merge as j_,observableFrom as M_,Subscription as N_,map as P_}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as I_,debounce as L_,merge as R_,observableFrom as z_,Subscription as B_,map as V_,ValueSubject as H_,ErrorCategory as U_,VideoQuality as W_}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as G_}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as $_,assertNonNullable as ev,ErrorCategory as tv,ErrorOrigin as nv,filter as rv,isNonNullable as iv,isNullable as av,map as ov,merge as sv,once as cv,Subject as K,Subscription as lv,ValueSubject as q,flattenObject as uv,devNull as dv,getWindow as fv}from"@vkontakte/videoplayer-shared/es2015";import{Observable as pv,map as mv,Subscription as hv,Subject as gv,now as _v,combine as vv}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as bv}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as xv,Subscription as Sv,combine as Cv,filter as wv,once as Tv}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as Ev}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as kv}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as Av,Subject as jv,Subscription as Mv,merge as Nv,isNonNullable as Pv}from"@vkontakte/videoplayer-shared/es2015";import{ErrorOrigin as Fv,flattenObject as Iv,isNullable as Lv}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as Bv}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as Hv,ErrorOrigin as Uv}from"@vkontakte/videoplayer-shared/es2015";import{ErrorOrigin as Gv,flattenObject as Kv}from"@vkontakte/videoplayer-shared/es2015";import{filterChanged as Jv,flattenObject as Yv,fromEvent as Xv,getWindow as Zv,isNonNullable as Qv,merge as $v,now as ey,Subject as ty,Subscription as ny,ErrorOrigin as ry}from"@vkontakte/videoplayer-shared/es2015";import{ErrorOrigin as oy}from"@vkontakte/videoplayer-shared/es2015";import{isNullable as cy,isNonNullable as ly,getWindow as uy}from"@vkontakte/videoplayer-shared/es2015";import{isNullable as my,isNonNullable as hy,Subscription as gy}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as by}from"@vkontakte/videoplayer-shared/es2015";import{objectFromEntries as xy}from"@vkontakte/videoplayer-shared/es2015";import{fromEvent as Sy,once as Cy,combine as wy,Subscription as Ty,ValueSubject as Ey,map as Dy,filter as Oy,isNonNullable as ky,isNullable as Ay,now as J,safeStorage as jy,getWindow as My}from"@vkontakte/videoplayer-shared/es2015";import{fillWithDefault as Uy,VideoQuality as Wy}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as qy,combine as Jy,devNull as Yy,ErrorCategory as Xy,filter as Y,filterChanged as X,flattenObject as Zy,fromEvent as Qy,getPlayerId as $y,getTimersDiagnostics as eb,getTraceSubscriptionMethod as tb,getWindow as nb,InternalsExposure as rb,isHigher as ib,isInvariantQuality as ab,isNonNullable as ob,isNullable as sb,Logger as cb,map as Z,mapTo as lb,merge as ub,now as db,once as Q,retainTimers as fb,Subject as $,Subscription as pb,tap as mb,throttle as hb,TracerFactory as gb,ValueSubject as _b,combineLatest as vb}from"@vkontakte/videoplayer-shared/es2015";import{merge as yb,map as bb,filter as xb,isNonNullable as Sb}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as wb}from"@vkontakte/videoplayer-shared/es2015";import{requestIdleCallbackPolyfilled as Eb}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as Db}from"@vkontakte/videoplayer-shared/es2015";import{cancelIdleCallbackPolyfilled as Ob}from"@vkontakte/videoplayer-shared/es2015";import{devNull as kb,getWindow as Ab}from"@vkontakte/videoplayer-shared/es2015";import{filter as Lb,mapTo as Rb,merge as zb,once as Bb,Subscription as Vb}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Gb}from"@vkontakte/videoplayer-shared/es2015";import{nowInt as Kb,Subscription as qb,ValueSubject as Jb}from"@vkontakte/videoplayer-shared/es2015";import{filter as Yb,ValueSubject as Xb}from"@vkontakte/videoplayer-shared/es2015";import{ValueSubject as ax}from"@vkontakte/videoplayer-shared/es2015";import{filter as sx,ValueSubject as cx}from"@vkontakte/videoplayer-shared/es2015";import{VideoQuality as lx}from"@vkontakte/videoplayer-shared/es2015";import{ValueSubject as Ex}from"@vkontakte/videoplayer-shared/es2015";import{calculateTotalViewTime as Ox,merge as kx,ValueSubject as Ax}from"@vkontakte/videoplayer-shared/es2015";import{Subscription as Lx,Observable as Rx,Subject as zx,ValueSubject as Bx,VideoQuality as Vx}from"@vkontakte/videoplayer-shared/es2015";var _oxcMod2xiscv=function(){function e(t){"@babel/helpers - typeof";return e=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},e(t)}var t=e;function n(e,n){if(t(e)!=`object`||!e)return e;var r=e[Symbol._oxc_toPrimitive];if(r!==void 0){var i=r.call(e,n||`default`);if(t(i)!=`object`)return i;throw TypeError(`@@_oxc_toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(e)}var t=e,r=n;function i(e){var n=r(e,`string`);return t(n)==`symbol`?n:n+``}var a=i;function o(e,t,n){return(t=a(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=o;function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function l(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?c(Object(n),!0).forEach(function(t){s(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function u(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function d(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){u(a,r,i,o,s,`next`,e)}function s(e){u(a,r,i,o,s,`throw`,e)}o(void 0)})}}function f(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}var p=f;function m(e,t){if(e==null)return{};var n,r,i=p(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function h(e,t){this.v=e,this.k=t}var g=h;function _(e){return new g(e,0)}var g=h;function v(e){return function(){return new y(e.apply(this,arguments))}}function y(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof g;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`?`return`:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(a.done?`return`:`normal`,n)},function(e){r(`throw`,e)})}catch(e){i(`throw`,e)}}function i(e,i){switch(e){case`return`:t.resolve({value:i,done:!0});break;case`throw`:t.reject(i);break;default:t.resolve({value:i,done:!1})}(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}y.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},y.prototype.next=function(e){return this._invoke(`next`,e)},y.prototype.throw=function(e){return this._invoke(`throw`,e)},y.prototype.return=function(e){return this._invoke(`return`,e)};const b=[`name`],x=[`url`],S=[`url`],C=[`downloadingItems`],ee=[`data`],w=[`container`];var T=l,E=d,D=m,te=_,O=v,k=`2.0.181-beta.0`,A;(e=>{e.STOPPED=`stopped`,e.READY=`ready`,e.PLAYING=`playing`,e.PAUSED=`paused`})(A||={});var ne;(e=>{e.MPEG=`MPEG`,e.DASH=`DASH`,e.DASH_SEP=`DASH_SEP`,e.DASH_SEP_VK=`DASH_SEP`,e.DASH_WEBM=`DASH_WEBM`,e.DASH_WEBM_AV1=`DASH_WEBM_AV1`,e.DASH_STREAMS=`DASH_STREAMS`,e.DASH_WEBM_VK=`DASH_WEBM`,e.DASH_ONDEMAND=`DASH_ONDEMAND`,e.DASH_ONDEMAND_VK=`DASH_ONDEMAND`,e.DASH_LIVE=`DASH_LIVE`,e.DASH_LIVE_CMAF=`DASH_LIVE_CMAF`,e.DASH_LIVE_WEBM=`DASH_LIVE_WEBM`,e.HLS=`HLS`,e.HLS_ONDEMAND=`HLS_ONDEMAND`,e.HLS_JS=`HLS`,e.HLS_FMP4=`HLS_FMP4`,e.HLS_LIVE=`HLS_LIVE`,e.HLS_LIVE_CMAF=`HLS_LIVE_CMAF`,e.WEB_RTC_LIVE=`WEB_RTC_LIVE`})(ne||={});var re;(e=>{e.AV1=`av1`,e.VP9=`vp9`,e.AVC1=`avc1`,e.HEV1=`hev1`})(re||={});var ie;(e=>{e.NOT_AVAILABLE=`NOT_AVAILABLE`,e.AVAILABLE=`AVAILABLE`,e.CONNECTING=`CONNECTING`,e.CONNECTED=`CONNECTED`})(ie||={});var ae;(e=>{e.HTTP1=`http1`,e.HTTP2=`http2`,e.QUIC=`quic`})(ae||={});var oe;(e=>{e.NONE=`none`,e.INLINE=`inline`,e.FULLSCREEN=`fullscreen`,e.SECOND_SCREEN=`second_screen`,e.PIP=`pip`,e.INVISIBLE=`invisible`})(oe||={});var se;(e=>{e.TRAFFIC_SAVING=`traffic_saving`,e.HIGH_QUALITY=`high_quality`,e.UNKNOWN=`unknown`})(se||={});var Te=e=>new Promise((t,n)=>{let r=document.createElement(`script`);r.setAttribute(`src`,e),r.onload=()=>t(),r.onerror=e=>n(e),document.body.appendChild(r)});class Ee{constructor(e){this.connection$=new me(void 0),this.castState$=new me(`NOT_AVAILABLE`),this.errorEvent$=new he,this.contentId=void 0,this.realCastState$=new me(`NOT_AVAILABLE`),this.subscription=new ge,this.log=void 0,this.params=void 0,this.isDestroyed=!1,this.params=e,this.log=this.params.dependencies.logger.createComponentLog(`ChromecastInitializer`);let t=`chrome`in window;if(this.log({message:`[constructor] receiverApplicationId: ${this.params.receiverApplicationId}, isDisabled: ${this.params.isDisabled}, isSupported: ${t}`}),e.isDisabled||!t)return;let n=pe(window.chrome?.cast),r=!!window.__onGCastApiAvailable;n?this.initializeCastApi():(window.__onGCastApiAvailable=e=>{delete window.__onGCastApiAvailable,e&&!this.isDestroyed&&this.initializeCastApi()},r||Te(`https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1`).catch(()=>this.errorEvent$.next({id:`ChromecastLoading`,category:we.NETWORK,message:`Script loading failed!`})))}connect(){cast.framework.CastContext.getInstance()?.requestSession()}disconnect(){var e;(e=cast.framework.CastContext.getInstance())==null||(e=e.getCurrentSession())==null||e.endSession(!0)}stopMedia(){return new Promise((e,t)=>{var n;(n=cast.framework.CastContext.getInstance())==null||(n=n.getCurrentSession())==null||(n=n.getMediaSession())==null||n.stop(new chrome.cast.media.StopRequest,e,t)})}toggleConnection(){pe(this.connection$.getValue())?this.disconnect():this.connect()}setVolume(e){let t=this.connection$.getValue();Ce(t)||(t.remotePlayer.volumeLevel=e,t.remotePlayerController.setVolumeLevel())}setMuted(e){let t=this.connection$.getValue();Ce(t)||e!==t.remotePlayer.isMuted&&t.remotePlayerController.muteOrUnmute()}destroy(){this.isDestroyed=!0,this.subscription.unsubscribe()}initListeners(){let e=new cast.framework.RemotePlayer,t=new cast.framework.RemotePlayerController(e),n=cast.framework.CastContext.getInstance();this.subscription.add(ye(n,cast.framework.CastContextEventType.SESSION_STATE_CHANGED).subscribe(e=>{switch(e.sessionState){case cast.framework.SessionState.SESSION_STARTED:case cast.framework.SessionState.SESSION_STARTING:case cast.framework.SessionState.SESSION_RESUMED:var t;this.contentId=(t=n.getCurrentSession())==null||(t=t.getMediaSession())==null||(t=t.media)==null?void 0:t.contentId;break;case cast.framework.SessionState.NO_SESSION:case cast.framework.SessionState.SESSION_ENDING:case cast.framework.SessionState.SESSION_ENDED:case cast.framework.SessionState.SESSION_START_FAILED:this.contentId=void 0;break;default:return de(e.sessionState)}})).add(_e(ye(n,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe(xe(e=>{this.log({message:`[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: ${JSON.stringify(e)}`})}),be(e=>e.castState)),ve([n.getCastState()])).pipe(Se(),be(De),xe(e=>{this.log({message:`realCastState$: ${e}`})})).subscribe(this.realCastState$)).add(this.realCastState$.subscribe(r=>{let i=r===`CONNECTED`,a=pe(this.connection$.getValue());if(i&&!a){var o;let r=n.getCurrentSession();fe(r);let i=r.getCastDevice(),a=(o=r.getMediaSession())==null||(o=o.media)==null?void 0:o.contentId;(Ce(a)||a===this.contentId)&&(this.log({message:`connection created`}),this.connection$.next({remotePlayer:e,remotePlayerController:t,session:r,castDevice:i}))}else!i&&a&&(this.log({message:`connection destroyed`}),this.connection$.next(void 0));this.castState$.next(r===`CONNECTED`?pe(this.connection$.getValue())?`CONNECTED`:`AVAILABLE`:r)}))}initializeCastApi(){let e,t,n;try{e=cast.framework.CastContext.getInstance(),t=chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,n=chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}catch{return}try{e.setOptions({receiverApplicationId:this.params.receiverApplicationId??t,autoJoinPolicy:n}),this.initListeners()}catch(e){this.errorEvent$.next({id:`ChromecastInitializer`,category:we.EXTERNAL_API,message:`[initializeCastApi] failed`,thrown:e})}}}var De=e=>{switch(e){case cast.framework.CastState.NO_DEVICES_AVAILABLE:return`NOT_AVAILABLE`;case cast.framework.CastState.NOT_CONNECTED:return`AVAILABLE`;case cast.framework.CastState.CONNECTING:return`CONNECTING`;case cast.framework.CastState.CONNECTED:return`CONNECTED`;default:return de(e)}};var Ke=`_offset_p`,qe=e=>{if(We(e,Ke))return!0;try{return new URL(e).searchParams.has(`offset_p`)}catch{return!1}},Je=(e,t=0,n=0)=>{switch(n){case 0:return e.replace(Ke,t===0?``:`_`+t.toFixed(0));case 1:{if(t===0)return e;let n=new URL(e);return n.searchParams.append(`playback_shift`,t.toFixed(0)),n.toString()}case 2:{let n=new URL(e);return!n.searchParams.get(`offset_p`)&&t===0?e:(n.searchParams.set(`offset_p`,t.toFixed(0)),n.toString())}default:Ge(n)}return e},Ye=(e,t)=>{switch(t){case 0:return NaN;case 1:{let t=new URL(e);return Number(t.searchParams.get(`playback_shift`))}case 2:{let t=new URL(e);return Number(t.searchParams.get(`offset_p`)??0)}default:Ge(t)}},Xe=e=>{let{source:t,format:n,meta:r,output:i}=e,a,o,s;switch(n){case`MPEG`:{let e=t[n];Be(e);let r=He(Object.keys(e));Be(r);let i=e[r];Be(i),a=i,o=`video/mp4`,s=Ze();break}case`HLS`:case`HLS_FMP4`:case`HLS_ONDEMAND`:{let e=t[n];Be(e),a=e.url,o=`application/x-mpegurl`,s=Ze();break}case`DASH_SEP`:case`DASH_ONDEMAND`:case`DASH_WEBM`:case`DASH_WEBM_AV1`:case`DASH_STREAMS`:{let e=t[n];Be(e),a=e.url,o=`application/dash+xml`,s=Ze();break}case`DASH_LIVE_CMAF`:{let e=t[n];Be(e),a=e.url,o=`application/dash+xml`,s=Qe();break}case`HLS_LIVE`:case`HLS_LIVE_CMAF`:{let e=t[n];Be(e),a=Je(e.url),o=`application/x-mpegurl`,s=Qe();break}case`DASH_LIVE`:case`WEB_RTC_LIVE`:{let e=`Unsupported format for Chromecast`,t=Error(e);throw i.error$.next({id:`ChromecastProvider.createMediaInfo()`,category:Ve.VIDEO_PIPELINE,message:e,thrown:t}),t}case`DASH`:case`DASH_LIVE_WEBM`:throw Error(`${n} is no longer supported`);default:return ze(n)}let c=$e(r.videoId??a,o);c.contentUrl=a,c.streamType=s,c.metadata=et();let{title:l,subtitle:u}=r;return Ue(l)&&(c.metadata.title=l),Ue(u)&&(c.metadata.subtitle=u),c};function Ze(){var e;return((e=chrome.cast)==null||(e=e.media)==null||(e=e.StreamType)==null?void 0:e.BUFFERED)??`BUFFERED`}function Qe(){var e;return((e=chrome.cast)==null||(e=e.media)==null||(e=e.StreamType)==null?void 0:e.LIVE)??`LIVE`}function $e(e,t){var n;return!((n=chrome.cast)==null||(n=n.media)==null)&&n.MediaInfo?new chrome.cast.media.MediaInfo(e,t):{contentId:e,contentType:t,metadata:{title:``,subtitle:``},streamType:Ze()}}function et(){var e;return!((e=chrome.cast)==null||(e=e.media)==null)&&e.GenericMediaMetadata?new chrome.cast.media.GenericMediaMetadata:{images:[],metadataType:0,releaseDate:``,subtitle:``,title:``,releaseYear:1970,type:0}}var j=(e,t,n=!1)=>{let r=e.getTransition();(n||!r||r.to===t)&&e.setState(t)};var M=tt(nt.CORE);class rt{constructor(e){this.params=void 0,this.interval=0,this.startVideoPosition=void 0,this.startTs=void 0,this.params=e}start(e=0){M.clearInterval(this.interval),this.startVideoPosition=e,this.startTs=Date.now(),this.interval=M.setInterval(()=>{let e=(Date.now()-this.startTs)/1e3,t=this.startVideoPosition+e;this.params.output.position$.next(t)},1e3)}pause(){M.clearInterval(this.interval)}destroy(){M.clearInterval(this.interval)}}class ut{constructor(){this._current=void 0,this._current_version=void 0,this._chromeVersion=void 0,this._firefoxVersion=void 0,this._safariVersion=void 0,this._operaVersion=void 0,this._edgeVersion=void 0,this._yandexVersion=void 0,this._isMiuiBrowser=!1}get current(){return this._current}get isChrome(){return this.current===`Chrome`}get isChromiumBased(){return st([`Chrome`,`Chromium`,`Opera`,`Yandex`,`Edge`,`SamsungBrowser`],this.current)}get isFirefox(){return this.current===`Firefox`}get isSafari(){return this.current===`Safari`}get isOpera(){return this.current===`Opera`}get isEdge(){return this.current===`Edge`}get isYandex(){return this.current===`Yandex`}get isSamsungBrowser(){return this.current===`SamsungBrowser`}get currentVersion(){return this._current_version}get chromeVersion(){return this._chromeVersion}get firefoxVersion(){return this._firefoxVersion}get safariVersion(){return this._safariVersion}get operaVersion(){return this._operaVersion}get edgeVersion(){return this._edgeVersion}get yandexVersion(){return this._yandexVersion}get isMiuiBrowser(){return this._isMiuiBrowser}detect(){let{userAgent:e}=navigator;try{let t=/yabrowser/i.test(e)?`Yandex`:void 0,n=/samsungbrowser/i.test(e)?`SamsungBrowser`:void 0,r=/chrome|crios/i.test(e)?`Chrome`:void 0,i=/chromium/i.test(e)?`Chromium`:void 0,a=/firefox|fxios/i.test(e)?`Firefox`:void 0,o=/smart-tv;.*tizen/i.test(e)?`Chrome`:void 0,s=/webkit|safari|khtml/i.test(e)?`Safari`:void 0,c=/opr\//i.test(e)?`Opera`:void 0,l=/edg/i.test(e)?`Edge`:void 0;this._isMiuiBrowser=/(XiaoMi)|(MiuiBrowser)/i.test(e),this._current=t||n||a||c||l||r||i||o||s||`Rest`}catch(e){console.error(e)}this.isChrome&&this.detectChromeVersion(),this.isFirefox&&this.detectFirefoxVersion(),this.isSafari&&this.detectSafariVersion(),this.isOpera&&this.detectOperaVersion(),this.isEdge&&this.detectEdgeVersion(),this.isYandex&&this.detectYandexVersion()}detectVersion(e){try{let{userAgent:t}=ct().navigator,n=t.match(e);if(!n)return;let r=n[1],i=parseInt(r,10);if(!isNaN(i))return this._current_version=i,i}catch(e){console.error(e)}}detectChromeVersion(){this._chromeVersion=this.detectVersion(/Chrome\/(\d+\.\d+)/),lt(this._chromeVersion)&&(this._chromeVersion=this.detectVersion(/(\d+\.\d+\.\d+\.\d+)\/\d+\.\d+ TV/))}detectFirefoxVersion(){this._firefoxVersion=this.detectVersion(/Firefox\/(\d+\.\d+)/)}detectSafariVersion(){this._safariVersion=this.detectVersion(/Version\/(\d+)/)}detectOperaVersion(){this._operaVersion=this.detectVersion(/OPR\/(\d+\.\d+)/)}detectEdgeVersion(){this._edgeVersion=this.detectVersion(/Edg\/(\d+\.\d+)/)}detectYandexVersion(){this._yandexVersion=this.detectVersion(/YaBrowser\/(\d+\.\d+\.\d+)/)}}var pt=()=>{var e;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(navigator.appVersion??navigator.userAgent)||((e=navigator)==null||(e=e.userAgentData)==null?void 0:e.mobile)};class mt{constructor(e){this._displayChecker=void 0,this._isMobile=void 0,this._isSmartTV=!1,this._current=void 0,this._iosVersion=void 0,this._highEntropyValues={},this._os={name:`Unknown`,version:`Unknown`,full:`Unknown`},this._details={vendor:`Unknown`,model:`Unknown`},this._hardware={},this._gpuDetection=void 0,this._displayChecker=e}get current(){return this._current}get os(){return this._os}get details(){return this._details}get isSmartTV(){return this._isSmartTV}get hardware(){return this._hardware}get highEntropyValues(){return this._highEntropyValues}get isIOS(){return this._highEntropyValues.platform===`iOS`||N(this.os.name.toLowerCase(),`ios`)||N([`iPhone`,`iPad`,`iPod`],this.current)}get isIPadOS(){let e=this.current===`Mac`&&this._displayChecker.isTouch;return this.current===`iPad`||e}get isMac(){return this._highEntropyValues.platform===`macOS`||N(this.os.name.toLowerCase(),`mac`)||this.current===`Mac`}get isApple(){return this.isIOS||this.isMac}get isIphoneOrOldIpad(){if(!this.isApple||!this._displayChecker.isTouch)return!1;let e=this.current===`iPad`||this._displayChecker.width>700,t=this._iosVersion;return!e||e&&!!t&&t<16}get isAndroid(){return this._highEntropyValues.platform===`Android`||N(this.os.name.toLowerCase(),`android`)||this.current===`Android`}get isWindows(){return N(this.os.name.toLowerCase(),`windows`)}get isLinux(){return N(this.os.name.toLowerCase(),`linux`)&&!this.isAndroid}get isMobile(){return this._highEntropyValues.mobile||this._isMobile}get isTablet(){if(this.isIPadOS||this._highEntropyValues.formFactors!=null&&N(this._highEntropyValues.formFactors,`Tablet`))return!0;if(!this.isAndroid)return!1;let e=dt();if(!ft(e))return!1;let t=e.navigator;return t?t.userAgentData?.mobile===!1?!0:this._displayChecker.isTouch&&!/\bMobile\b/i.test(t.userAgent):!1}get iOSVersion(){return this._iosVersion}detect(){let e=dt();if(!ft(e))return;let{userAgent:t}=e.navigator;try{this._isMobile=pt()}catch(e){console.error(`DeviceChecker: calling isMobile error - `,e)}this.detectDevice(t),this.detectOS(t),this.detectDeviceDetails(t),this.detectHardware(e),this.detectHighEntropyValues(),this.isIOS&&this.detectIOSVersion(),this.detectSmartTv()}detectHardware(e){let t=e.navigator;try{this._hardware={cpuCores:t.hardwareConcurrency,memoryGb:t.deviceMemory}}catch(e){console.error(`DeviceChecker: detectHardware error - `,e)}}detectGpu(){return this._gpuDetection??=this.requestGpuInfo(),this._gpuDetection}requestGpuInfo(){var e=this;return E(function*(){let t=dt();if(ft(t))try{var n,r;let i=yield t.navigator.gpu?.requestAdapter();e._hardware=T(T({},e._hardware),{},{gpuVendor:(i==null||(n=i.info)==null?void 0:n.vendor)||void 0,gpuArchitecture:(i==null||(r=i.info)==null?void 0:r.architecture)||void 0})}catch(e){console.error(`DeviceChecker: detectGpu error - `,e)}})()}detectHighEntropyValues(){var e=this;return E(function*(){let t=dt();if(!ft(t))return;let{userAgentData:n}=t.navigator;if(n?.getHighEntropyValues){let t=yield n.getHighEntropyValues([`architecture`,`bitness`,`brands`,`mobile`,`platform`,`formFactors`,`model`,`platformVersion`,`wow64`]);e._highEntropyValues=t,t.platform&&(e._os.name=e.normalizeOSName(t.platform),t.platformVersion&&(e._os.version=e.normalizeOSVersion(t.platformVersion),e._os.full=`${e._os.name} ${e._os.version}`)),t.model&&(e._details.model=t.model)}})()}detectSmartTv(){try{this._isSmartTV=!1;let e=dt();if(!ft(e))return;let{userAgent:t}=e.navigator;this._isSmartTV=/smart[\w\-_ ]*tv/i.test(t)||/samsung/i.test(t)&&/tizen/i.test(t)}catch(e){console.error(`DeviceChecker: Smart TV detection error - `,e)}}detectDevice(e){try{let t=/android/i.test(e)?`Android`:void 0,n=/iphone/i.test(e)?`iPhone`:void 0,r=/ipad/i.test(e)?`iPad`:void 0,i=/ipod/i.test(e)?`iPod`:void 0,a=/mac/i.test(e)?`Mac`:void 0,o=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(e)?`RestMobile`:void 0;this._current=t||n||r||i||o||a||`Desktop`}catch(e){console.error(`DeviceChecker: device detection error - `,e)}}detectOS(e){try{for(let[t,n]of[[/(windows nt) (6\.[23]); arm/i,[`Windows RT`]],[/(windows nt) (6\.3); arm/i,[`Windows RT 8.1`]],[/(windows (?:phone|mobile|iot))(?: os)?[/ ]?([\d.]+)/i,[`Windows Mobile`,2]],[/(windows)[/ ](xp|vista|7|8(\.1)?|10|11|2000|me)/i,[1,1]],[/windows nt ?([\d.]+)/i,[`Windows`,1]],[/(windows)[/ ](95|98|me|2000|xp|vista|7|8|8\.1|10|11)/i,[1,2]],[/(iphone os|cpu iphone os) ([\d_.]+)/i,[`iOS`,2]],[/(ipad os|cpu os) ([\d_.]+)/i,[`iPadOS`,2]],[/(ipod os|cpu ipod os) ([\d_.]+)/i,[`iOS`,2]],[/(?:ios|os) ([\d_.]+) like mac os x/i,[`iOS`,1]],[/cfnetwork\/.+darwin/i,[`iOS`]],[/(mac os x) ?([\d_.]+)/i,[`macOS`,2]],[/(macintosh|mac os)/i,[`macOS`]],[/(android) ([\d.]+)/i,[1,2]],[/(harmonyos)[/ ]?([\d.]*)/i,[`HarmonyOS`,2]],[/\b(ubuntu|debian|fedora|centos|arch|linux)(?:[-/ ]([\w.]+))?/i,[1,2]],[/(cros)\D*([\d.]+)/i,[`Chrome OS`,2]],[/(freebsd|openbsd|netbsd|dragonfly)[/ ]?([\w.]*)/i,[1,2]],[/(sunos|solaris)?([\d.]*)/i,[`Solaris`,2]],[/(aix)?([\d.]*)/i,[`AIX`,2]]]){let r=e.match(t);if(r){let t=n.length>0,i=n.length>1,a=`Unknown`,o=`Unknown`;if(t){let e=n[0];typeof e==`number`?e<r.length&&r[e]!==void 0&&(a=r[e]):a=e}if(i){let e=n[1];typeof e==`number`?e<r.length&&r[e]!==void 0&&(o=r[e]):e!==void 0&&(o=e)}else r[2]===void 0?r[1]!==void 0&&t&&typeof n[0]==`string`&&(o=r[1]):o=r[2];a=this.normalizeOSName(a),o=this.normalizeOSVersion(o,a),a===`iOS`&&/ipad/i.test(e)?a=`iPadOS`:a===`iPadOS`&&/ip(hone|od)/i.test(e)&&(a=`iOS`),this._os={name:a,version:o||`Unknown`,full:o&&o!==`Unknown`?`${a} ${o}`:a};break}}}catch(e){console.error(`DeviceChecker: OS detection error - `,e)}}normalizeOSName(e){if(!e)return`Unknown`;let t=e.toLowerCase();return N(t,`windows`)?`Windows`:N(t,`mac os`)||N(t,`macintosh`)?`macOS`:N(t,`iphone`)||N(t,`ios`)?`iOS`:N(t,`ipados`)?`iPadOS`:N(t,`android`)?`Android`:N(t,`harmonyos`)?`HarmonyOS`:N(t,`linux`)?`Linux`:N(t,`cros`)?`Chrome OS`:N(t,`freebsd`)?`FreeBSD`:N(t,`openbsd`)?`OpenBSD`:N(t,`solaris`)||N(t,`sunos`)?`Solaris`:N(t,`aix`)?`AIX`:e}normalizeOSVersion(e,t){if(!e)return`Unknown`;if(e!==`Unknown`&&(e=e.replace(/_/g,`.`),t===`Windows`)){let t=parseFloat(e);if(!isNaN(t)){if(t>=11)return`11`;if(t>=10)return`10`;if(t===6.3)return`8.1`;if(t===6.2)return`8`;if(t===6.1)return`7`;if(t===6)return`Vista`;if(t===5.1||t===5.2)return`XP`;if(t===5)return`2000`;if(t===4)return`NT 4.0`}}return e}detectDeviceDetails(e){try{for(let[t,n]of[[/(iphone)/i,[`Apple`,`iPhone`]],[/(ipad)/i,[`Apple`,`iPad`]],[/(ipod)/i,[`Apple`,`iPod`]],[/(macintosh)/i,[`Apple`,`Macintosh`]],[/(windows[\w\-_ ]*phone)/i,[`Microsoft`,0]],[/(windows nt|win64|win32|wow64)/i,[`Microsoft`,`PC`]],[/\b(sch-i[89]0\d|shw-m380s|sm-[ptxs]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i,[`Samsung`,1]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?\d+a?|galaxy nexus)/i,[`Samsung`,1]],[/samsung[- ]((?!sm-[lr]|browser)[-\w]+)/i,[`Samsung`,1]],[/sec-(sgh\w+)/i,[`Samsung`,1]],[/smart-tv.+(samsung)/i,[`Samsung`,`Smart TV`]],[/(samsung).*tizen/i,[`Samsung`,`Smart TV`]],[/(pixel (?:c|tablet|[0-9a-z ]+))/i,[`Google`,1]],[/(pixelbook(?: go)?)/i,[`Google`,1]],[/nexus [0-9]/i,[`Google`,0]],[/(redmi[-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(mi[\w\-_ ]+)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(poco[\w ]+)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(hm[-_ ]?note?[\w ]*)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(?:xiao)?mi[\w\-_ ]+pad/i,[`Xiaomi`,0]],[/(?:huawei|honor) ?([-\w ]+)[;)]/i,[`Huawei`,1]],[/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][\dc][adnt]?)\b(?!.+d\/s)/i,[`Huawei`,1]],[/\b((?:ag[rs][2356]?k?|bah[234]?|bg[2o]|bt[kv]|cmr|cpn|db[ry]2?|jdn2|got|kob2?k?|mon|pce|scm|sht?|[tw]gr|vrd)-[ad]?[lw][0125][09]b?)/i,[`Huawei`,1]],[/(?:one)?(?:plus)? ?([a\d0]\d\d\d?)(?: b|\))/i,[`OnePlus`,1]],[/droid.+; (cph2[3-6]\d[13579]|((?:gm|hd)19|(?:ac|be|in|kb)20|(?:d[en]|eb|le|mt)21|ne22)[0-2]\d)(?: bui|\))/i,[`OnePlus`,1]],[/(oneplus)[-_ ]?([-\w]*)/i,[`OnePlus`,2]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i,[`Realme`,1]],[/(realme)[-_ ]?([-\w]*)/i,[`Realme`,2]],[/; (\w+) bui.+ oppo/i,[`OPPO`,1]],[/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i,[`OPPO`,1]],[/\b(opd2(\d{3}a?))(?: bui|\))/i,[`OPPO`,1]],[/(oppo)[-_ ]?([-\w]*)/i,[`OPPO`,2]],[/; vivo (\w+)(?: bui|\))/i,[`Vivo`,1]],[/\b(v[12]\d{3}\w?[at])(?: bui|;)/i,[`Vivo`,1]],[/(vivo)[-_ ]?([-\w]*)/i,[`Vivo`,2]],[/\bmot(?:orola)?[- ]([\w\s]+)(\)| bui)/i,[`Motorola`,1]],[/((?:moto(?! 360)[-\w() ]+|xt\d{3,4}[cgkosw+]?[-\d]*|nexus 6)(?= bui|\)))/i,[`Motorola`,1]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b/i,[`Motorola`,0]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i,[`Motorola`,0]],[/droid.+; ([a-z]?\d[0-2]{2}[a-z]{2}|[c-g]\d{4}|so[-gl]\w+|xq-[a-z]{2}\d\d)(?= bui|\))/i,[`Sony`,1]],[/sony tablet [ps]/i,[`Sony`,`Xperia Tablet`]],[/\b(?:sony)?sgp\w+(?: bui|\))/i,[`Sony`,0]],[/(sony)[-_ ]?([-\w]*)/i,[`Sony`,2]],[/\blg[-e;/ ]+(?!.*(?:browser|netcast|android tv|watch|webos))(\w+)/i,[`LG`,1]],[/\blg-?([\d\w]+) bui/i,[`LG`,1]],[/(lm(?:-?f100[nv]?|-[\w.]+)(?= bui|\))|nexus [45])/i,[`LG`,1]],[/((?=lg)?[vl]k-?\d{3}) bui/i,[`LG`,0]],[/(lg)[-_ ]?([-\w]*)/i,[`LG`,2]],[/(?:maemo|nokia).*(n900|lumia \d+|rm-\d+)/i,[`Nokia`,1]],[/nokia[-_ ]?(([-\w. ]*?))(?: bui|\)|;|\/)/i,[`Nokia`,1]],[/(nokia) (t[12][01])/i,[`Nokia`,2]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i,[`ASUS`,1]],[/(?:asus[-_ ])?(zenfone[\w\-_ ]*)/i,[`ASUS`,1]],[/(rog[\w\-_ ]*)/i,[`ASUS`,1]],[/(asus)[-_ ]?([-\w]*)/i,[`ASUS`,2]],[/lenovo[-_ ]?([-\w ]+?)(?: bui|\)|\/)/i,[`Lenovo`,1]],[/(ideatab[-\w ]+|602lv|d-42a|a101lv|a2109a|a3500-hv|s[56]000|pb-6505[my]|tb-?x?\d{3,4}(?:f[cu]|xu|[av])|yt\d?-[jx]?\d+[lfmx])(?: bui|;|\)|\/)/i,[`Lenovo`,1]],[/(thinkpad[\w\-_ ]*)/i,[`Lenovo`,0]],[/(kf[a-z]{2}[a-z]*)(?: bui|\))/i,[`Amazon`,1]],[/(alexa)webm/i,[`Amazon`,`Echo`]],[/(fire[\w\-_ ]*)/i,[`Amazon`,0]],[/(amazon)[-_ ]?([-\w]*)/i,[`Amazon`,2]],[/(?:blackberry|\(bb10;) (\w+)/i,[`BlackBerry`,1]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,[`BlackBerry`,1]],[/(playbook);[-\w),; ]+(rim)/i,[`BlackBerry`,1]],[/(microsoft); (lumia[\w ]+)/i,[`Microsoft`,2]],[/(surface duo)/i,[`Microsoft`,`Surface Duo`]],[/(surface[\w\-_ ]*)/i,[`Microsoft`,0]],[/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,[`ZTE`,2]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,[`HTC`,2]],[/(alcatel|tcl)[-_ ]?([-\w]*)/i,[1,2]],[/(meizu)[-_ ]?([-\w]*)/i,[`Meizu`,2]],[/(tecno)[-_ ]?([-\w]*)/i,[`Tecno`,2]],[/(infinix)[-_ ]?([-\w]*)/i,[`Infinix`,2]],[/(micromax)[-_ ]?([-\w]*)/i,[`Micromax`,2]],[/(lava)[-_ ]?([-\w]*)/i,[`Lava`,2]],[/(panasonic)[-_ ]?([-\w]*)/i,[`Panasonic`,2]],[/(sharp)\/?([-\w]*)/i,[`Sharp`,2]],[/(benq)[-_ ]?([-\w]*)/i,[`BenQ`,2]],[/(palm)[-_ ]?([-\w]*)/i,[`Palm`,2]],[/(vertu)[-_ ]?([-\w]*)/i,[`Vertu`,2]],[/(gionee)[-_ ]?([-\w]*)/i,[`Gionee`,2]],[/(doogee)[-_ ]?([-\w]*)/i,[`Doogee`,2]],[/(ulefone)[-_ ]?([-\w]*)/i,[`Ulefone`,2]],[/(blackview)[-_ ]?([-\w]*)/i,[`Blackview`,2]],[/(cubot)[-_ ]?([-\w]*)/i,[`Cubot`,2]],[/(umidigi)[-_ ]?([-\w]*)/i,[`UMIDIGI`,2]],[/(oukitel)[-_ ]?([-\w]*)/i,[`Oukitel`,2]],[/(fairphone)[-_ ]?([-\w]*)/i,[`Fairphone`,2]],[/(cat)[-_ ]?([-\w]*)/i,[`Cat`,2]],[/(energy)[-_ ]?([-\w]*)/i,[`Energizer`,2]],[/(land rover)[-_ ]?([-\w]*)/i,[`Land Rover`,2]],[/(shield[\w\-_ ]*)/i,[`Nvidia`,0]],[/(crkey)/i,[`Google`,`Chromecast`]],[/(roku)[\dx]*/i,[`Roku`,0]],[/(apple)[-_ ]?tv/i,[`Apple`,`TV`]],[/(amazon)[-_ ]?tv/i,[`Amazon`,`Fire TV`]],[/(google)[-_ ]?tv/i,[`Google`,`TV`]],[/(smart[\w\-_ ]*tv)/i,[0,`Smart TV`]],[/(playstation[\w\-_ ]*)/i,[`Sony`,0]],[/(nintendo[\w\-_ ]*)/i,[`Nintendo`,0]],[/(xbox[\w\-_ ]*)/i,[`Microsoft`,0]],[/(googlebot)/i,[`Google`,`Bot`]],[/(bingbot)/i,[`Microsoft`,`Bing Bot`]],[/(yandexbot)/i,[`Yandex`,`Bot`]],[/(slackbot)/i,[`Slack`,`Bot`]],[/(twitterbot)/i,[`Twitter`,`Bot`]],[/(facebookbot)/i,[`Facebook`,`Bot`]],[/(linkedinbot)/i,[`LinkedIn`,`Bot`]],[/(tesla)[-_ ]?([-\w]*)/i,[`Tesla`,2]],[/(raspberry[\w\-_ ]*)/i,[`Raspberry Pi`,0]]]){let r=e.match(t);if(r){let e=n[0],t=n[1],i=typeof e==`number`?r[e]===void 0?`Unknown`:this.normalizeVendorName(r[e]):this.normalizeVendorName(e),a=`Unknown`;typeof t==`number`?a=r[t]===void 0?`Unknown`:r[t]:t===void 0?r[1]===void 0?r[0]!==void 0&&(a=r[0]):a=r[1]:a=t,a=this.normalizeModelName(a,i),this.details.vendor=i,this.details.model=a;break}}}catch(e){console.error(`DeviceChecker: device details detection error - `,e)}}normalizeVendorName(e){return e?{apple:`Apple`,samsung:`Samsung`,google:`Google`,xiaomi:`Xiaomi`,huawei:`Huawei`,oneplus:`OnePlus`,oppo:`OPPO`,vivo:`Vivo`,realme:`Realme`,motorola:`Motorola`,sony:`Sony`,lg:`LG`,nokia:`Nokia`,asus:`ASUS`,lenovo:`Lenovo`,amazon:`Amazon`,blackberry:`BlackBerry`,microsoft:`Microsoft`,zte:`ZTE`,htc:`HTC`,alcatel:`Alcatel`,tcl:`TCL`,meizu:`Meizu`,tecno:`Tecno`,infinix:`Infinix`,micromax:`Micromax`,lava:`Lava`,panasonic:`Panasonic`,sharp:`Sharp`,benq:`BenQ`,palm:`Palm`,honor:`Honor`,nvidia:`NVIDIA`,roku:`Roku`}[e.toLowerCase()]||e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():`Unknown`}normalizeModelName(e,t){if(!e||e===`Unknown`)return e;if(e===`0`)return`Unknown`;let n=e.replace(/^build\//i,``).replace(/\s+bui$/i,``).replace(/\)$/,``).replace(/[;,)]/g,``).replace(/\s*\(.*?\)\s*/g,``).trim(),r=t.toLowerCase();return N(r,`samsung`)?n=n.replace(/^(sm-|gt-|sgh-|sch-)/i,``):N(r,`xiaomi`)?n=n.replace(/^(mi[\s\-_]*|redmi[\s\-_]*)/i,``):N(r,`oneplus`)?n=n.replace(/^oneplus[\s\-_]*/i,``):N(r,`google`)&&(n=n.replace(/^(pixel[\s\-_]*|nexus[\s\-_]*)/i,``)),n=n.replace(/_/g,` `).replace(/-/g,` `).replace(/\s+/g,` `).trim(),n?(n.length>0&&/^[a-z]/.test(n)&&(n=n.charAt(0).toUpperCase()+n.slice(1)),n):`Unknown`}detectIOSVersion(){try{let e=dt();if(!ft(e))return;if(this._highEntropyValues.platformVersion){let e=this._highEntropyValues.platformVersion.split(`.`).slice(0,2).join(`.`);this._iosVersion=parseFloat(e);return}if(this._os.version!==`Unknown`){let e=this._os.version.split(`.`),t=e.length>=2?`${e[0]}.${e[1]}`:e[0];this._iosVersion=parseFloat(t);return}let t=e.navigator.userAgent.match(/OS (\d+(_\d+)?)/i);t?.[1]&&(this._iosVersion=parseFloat(t[1].replace(/_/g,`.`)))}catch(e){console.error(`DeviceChecker: iOS version detection error - `,e)}}}var _t=[`rec2020`,`p3`,`srgb`],vt=[`standalone`,`minimal-ui`,`fullscreen`,`window-controls-overlay`,`picture-in-picture`];class yt{constructor(){this._maxTouchPoints=void 0,this._height=void 0,this._width=void 0,this._isHdr=void 0,this._pixelRatio=void 0,this._screenHeight=void 0,this._screenWidth=void 0,this._colorDepth=void 0,this._colorGamut=void 0,this._displayMode=`browser`,this._isStandalone=!1}get isTouch(){return typeof this._maxTouchPoints==`number`?this._maxTouchPoints>1:`ontouchstart`in ht()}get maxTouchPoints(){return this._maxTouchPoints}get height(){return this._height}get width(){return this._width}get screenHeight(){return this._screenHeight}get screenWidth(){return this._screenWidth}get pixelRatio(){return this._pixelRatio}get isHDR(){return this._isHdr}get colorDepth(){return this._colorDepth}get colorGamut(){return this._colorGamut}get displayMode(){return this._displayMode}get isStandalone(){return this._isStandalone}detect(){let e=ht();if(!gt(e))return;let{navigator:t,screen:n}=e,{maxTouchPoints:r}=t;try{this._maxTouchPoints=r??0,this._isHdr=!!e.matchMedia(`(dynamic-range: high)`)?.matches,this._colorDepth=n.colorDepth,this._colorGamut=this.detectColorGamut(e)}catch(e){console.error(e)}try{this._pixelRatio=e.devicePixelRatio||1,this._height=n.height,this._width=n.width,this._height=n.height,this._screenHeight=this._height*this._pixelRatio,this._screenWidth=this._width*this._pixelRatio}catch(e){console.error(e)}try{this._displayMode=this.detectDisplayMode(e);let n=t.standalone===!0;this._isStandalone=n||this._displayMode!==`browser`}catch(e){console.error(e)}}detectColorGamut(e){return _t.find(t=>{var n;return(n=e.matchMedia)==null||(n=n.call(e,`(color-gamut: ${t})`))==null?void 0:n.matches})}detectDisplayMode(e){return vt.find(t=>{var n;return(n=e.matchMedia)==null||(n=n.call(e,`(display-mode: ${t})`))==null?void 0:n.matches})??`browser`}}var St=()=>window.ManagedMediaSource||window.MediaSource,Ct=()=>{var e;return!!(window.ManagedMediaSource&&!((e=window.ManagedSourceBuffer)==null||(e=e.prototype)==null)&&e.appendBuffer)},wt=()=>{var e;return!!(window.MediaSource&&!((e=window.SourceBuffer)==null||(e=e.prototype)==null)&&e.appendBuffer)},Tt=()=>window.ManagedMediaSource?new ManagedMediaSource:new MediaSource,Et=bt().document?.createElement(`video`),Dt=`video/mp4; codecs="avc1.42000a,mp4a.40.2"`,Ot=`video/mp4; codecs="hev1.1.6.L93.B0"`,kt=`video/webm; codecs="vp09.00.10.08"`,At=`video/webm; codecs="av01.0.00M.08"`,jt=`audio/mp4; codecs="mp4a.40.2"`,Mt=`audio/webm; codecs="opus"`,Nt;(function(){var e=E(function*(){let e=bt();if(!xt(e)||!(`mediaCapabilities`in e.navigator))return;let t={type:`media-source`,video:{contentType:`video/webm`,width:1280,height:720,bitrate:1e6,framerate:30}},[n,r]=yield Promise.all([e.navigator.mediaCapabilities.decodingInfo(T(T({},t),{},{video:T(T({},t.video),{},{contentType:At})})),e.navigator.mediaCapabilities.decodingInfo(T(T({},t),{},{video:T(T({},t.video),{},{contentType:kt})}))]);Nt={DASH_WEBM_AV1:n,DASH_WEBM:r}});return function(){return e.apply(this,arguments)}})()().catch(e=>{console.log(Et),console.error(e)});class Pt{constructor(e,t){this._video=void 0,this._deviceChecker=void 0,this._browserChecker=void 0,this._protocols=void 0,this._containers=void 0,this._codecs=void 0,this._nativeHlsSupported=void 0,this._deviceChecker=e,this._browserChecker=t}get protocols(){return this._protocols}get containers(){return this._containers}get codecs(){return this._codecs}get webmDecodingInfo(){return Nt}get supportedCodecs(){return Object.keys(this._codecs).filter(e=>this._codecs[e])}get nativeHlsSupported(){return this._nativeHlsSupported}detect(){let e=bt();if(!xt(e))return;let t=e.document;this._video=t.createElement(`video`);try{var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_;this._protocols={mms:Ct(),mse:wt(),hls:!!((n=this._video).canPlayType?.call(n,`application/x-mpegurl`)||(r=this._video).canPlayType?.call(r,`vnd.apple.mpegURL`)),webrtc:!!e.RTCPeerConnection,ws:!!e.WebSocket},this._containers={mp4:!!(i=this._video).canPlayType?.call(i,`video/mp4`),webm:!!(a=this._video).canPlayType?.call(a,`video/webm`),cmaf:!0};let t=!!(!((o=St())==null||(s=o.isTypeSupported)==null)&&s.call(o,Dt)),v=!!(!((c=St())==null||(l=c.isTypeSupported)==null)&&l.call(c,Ot)),y=!!(!((u=St())==null||(d=u.isTypeSupported)==null)&&d.call(u,jt));this._codecs={h264:t,h265:v,vp9:!!(!((f=St())==null||(p=f.isTypeSupported)==null)&&p.call(f,kt)),av1:!!(!((m=St())==null||(h=m.isTypeSupported)==null)&&h.call(m,At)),aac:y,opus:!!(!((g=St())==null||(_=g.isTypeSupported)==null)&&_.call(g,Mt)),mpeg:(t||v)&&y},this._nativeHlsSupported=this._protocols.hls&&this._containers.mp4}catch(e){console.error(e)}try{this.destroyVideoElement()}catch(e){console.error(`Error destroying video element:`,e)}}destroyVideoElement(){if(!this._video)return;if(this._video.pause(),this._video.currentTime=0,this._video.removeAttribute(`src`),this._video.src=``,this._video.load(),this._video.remove){this._video.remove(),this._video=null;return}this._video.parentNode&&this._video.parentNode.removeChild(this._video);let e=this._video.cloneNode(!1);this._video.parentNode?.replaceChild(e,this._video),this._video=null}}var Lt=`audio/mpeg`;class Rt{constructor(){this._audio=void 0,this._containers=void 0,this._codecs=void 0}supportMp3(){return this._codecs.mp3&&this._containers.mpeg}detect(){let e=Ft();if(!It(e))return;let t=e.document;this._audio=t.createElement(`audio`);try{var n,r,i;this._containers={mpeg:!!(n=this._audio).canPlayType?.call(n,Lt)},this._codecs={mp3:!!(!((r=St())==null||(i=r.isTypeSupported)==null)&&i.call(r,Lt))}}catch(e){console.error(e)}try{this.destroyAudioElement()}catch(e){console.error(`Error destroying audio element:`,e)}}destroyAudioElement(){if(!this._audio)return;if(this._audio.pause(),this._audio.currentTime=0,this._audio.removeAttribute(`src`),this._audio.src=``,this._audio.load(),this._audio.remove){this._audio.remove(),this._audio=null;return}this._audio.parentNode&&this._audio.parentNode.removeChild(this._audio);let e=this._audio.cloneNode(!1);this._audio.parentNode?.replaceChild(e,this._audio),this._audio=null}}class zt{constructor(){this.isInited$=new ot(!1),this._displayChecker=void 0,this._deviceChecker=void 0,this._browserChecker=void 0,this._videoChecker=void 0,this._audioChecker=void 0,this._displayChecker=new yt,this._deviceChecker=new mt(this._displayChecker),this._browserChecker=new ut,this._videoChecker=new Pt(this._deviceChecker,this._browserChecker),this._audioChecker=new Rt,this.detect()}get display(){return this._displayChecker}get device(){return this._deviceChecker}get browser(){return this._browserChecker}get video(){return this._videoChecker}get audio(){return this._audioChecker}detect(){var e=this;return E(function*(){at()&&(e._displayChecker.detect(),e._deviceChecker.detect(),e._browserChecker.detect(),e._videoChecker.detect(),e._audioChecker.detect(),e.isInited$.next(!0))})()}}var P=new zt,Bt=(e,t=!1)=>{let{containers:n,protocols:r,codecs:i,nativeHlsSupported:a}=P.video,{isMobile:o}=P.device,s=P.device.isMac&&P.browser.isSafari,c=t&&!o&&!s,l=(i.h264||i.h265)&&i.aac,u=r.mse||r.mms;return e.filter(e=>{switch(e){case`DASH_SEP`:return u&&n.mp4&&l;case`DASH_WEBM`:return u&&n.webm&&i.vp9&&i.opus;case`DASH_WEBM_AV1`:return u&&n.webm&&i.av1&&i.opus;case`DASH_STREAMS`:return u&&(n.mp4&&l||n.webm&&(i.vp9||i.av1)&&(i.opus||i.aac));case`DASH_LIVE`:return u&&n.mp4&&l;case`DASH_LIVE_CMAF`:return u&&n.mp4&&l&&n.cmaf;case`DASH_ONDEMAND`:return u&&n.mp4&&l;case`HLS`:case`HLS_ONDEMAND`:case`HLS_FMP4`:case`HLS_LIVE`:case`HLS_LIVE_CMAF`:return a&&!c;case`MPEG`:return n.mp4;case`DASH`:case`DASH_LIVE_WEBM`:return!1;case`WEB_RTC_LIVE`:return r.webrtc&&r.ws&&i.h264&&(n.mp4||n.webm);default:return it(e)}})},Vt=e=>{switch(e){case`MPEG`:case`DASH`:case`DASH_SEP`:case`DASH_ONDEMAND`:case`DASH_WEBM`:case`DASH_WEBM_AV1`:case`DASH_STREAMS`:case`HLS`:case`HLS_FMP4`:case`HLS_ONDEMAND`:return!1;case`DASH_LIVE`:case`DASH_LIVE_CMAF`:case`HLS_LIVE`:case`HLS_LIVE_CMAF`:case`DASH_LIVE_WEBM`:case`WEB_RTC_LIVE`:return!0;default:return it(e)}},Ht=(e,t=!1)=>Bt(Object.keys(e).filter(e=>!Vt(e)),t).length>0;class Ut{constructor(e){this.subscription=new Le,this.log=void 0,this.params=void 0,this.sessionId$=new Re(null),this.mediaSessionId$=new Re(null),this.contentId$=new Re(null),this.progressTicker=void 0,this.isMobile=pt(),this.mobileVolumeState={muted:!1,volume:0},this.media=null,this.lastRequestedVolume=null,this.syncMediaState=e=>{if(Fe(e))return;this.media=e,this.mediaSessionId$.next(e.mediaSessionId??null);let t=e.media?.contentId;t&&this.contentId$.next(t),this.syncPlaybackState(e);let n=e.media?.duration;Pe(n)&&this.params.output.duration$.next(Math.max(0,n));let r=e.currentTime;if(Pe(r)){this.params.desiredState.seekState.getState().state===`applying`&&this.params.output.seekedEvent$.next(),this.params.output.position$.next(r);let t=this.params.output.isLive$.getValue();e.playerState===`PLAYING`&&!t?this.progressTicker.start(r):this.progressTicker.pause()}},this.params=e,this.progressTicker=new rt(e),this.log=this.params.dependencies.logger.createComponentLog(`ChromecastPresentationApiProvider`),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(Vt(e.format)),this.subscribe()}subscribe(){let e=e=>{this.params.output.error$.next({category:je.WTF,id:`ChromecastPresentationApiProvider`,message:e?.message??`Unknown error`,thrown:e})};this.subscription.add(this.params.chromecastConnector.message$.pipe(Me(e=>!!e)).subscribe(e=>{this.handleMessage(e)},e)),this.subscription.add(this.sessionId$.pipe(Me(Pe),Ne(),Ae(0)).subscribe(()=>{this.loadMedia()},e));let t=this.contentId$.pipe(Ne(),Ie(Boolean));this.subscription.add(ke({seekState:this.params.desiredState.seekState.stateChangeEnded$,mediaLoaded:t}).pipe(Me(({mediaLoaded:e})=>e)).subscribe(()=>{let e=this.params.desiredState.seekState.getState();e.state===`requested`&&this.seek(e.position/1e3)},e));let n=ke({playbackState:this.params.desiredState.playbackState.stateChangeStarted$,mediaLoaded:t});this.subscription.add(n.pipe(Me(({mediaLoaded:e})=>e),Ae(0)).subscribe(()=>{this.syncPlayback()},e)),this.subscription.add(n.pipe(Me(({mediaLoaded:e,playbackState:{from:t,to:n}})=>!e&&t===`stopped`&&n===`playing`)).subscribe(()=>{this.loadMedia()},e)),this.subscription.add(ke({volumeState:this.params.desiredState.volume.stateChangeStarted$.pipe(Ae(30)),mediaLoaded:t}).pipe(Me(({mediaLoaded:e})=>e)).subscribe(({volumeState:e})=>{let{muted:t,volume:n}=e.to;this.setVolume(n,t)},e))}handleMessage(e){switch(e.type){case`new_session`:case`update_session`:{var t;this.sessionId$.next(e.message.sessionId);let n=(t=e.message)==null||(t=t.media)==null?void 0:t[0];this.syncMediaState(n);let r=e.message?.receiver.volume;this.syncVolumeState(r)}break;case`v2_message`:switch(e.message?.type){case`MEDIA_STATUS`:{var n;let t=(n=e.message)==null||(n=n.status)==null?void 0:n[0];this.syncMediaState(t);break}}break}}loadMedia(){let e=Xe(this.params),t=this.media?.currentTime,n=this.params.desiredState.seekState.getState(),r=t??(n.state===`none`?0:n.position/1e3),i=this.params.desiredState.playbackState.getState()===`playing`;this.params.chromecastConnector.sendV2Message({type:`LOAD`,requestId:0,media:e,autoplay:i,currentTime:r,customData:null,activeTrackIds:null}),this.params.output.willSeekEvent$.next()}stop(){this.params.chromecastConnector.stopMedia()}play(){let e=this.mediaSessionId$.getValue();Oe(e,`play on null mediaSessionId`),this.params.chromecastConnector.sendV2Message({type:`PLAY`,mediaSessionId:e,customData:null})}pause(){let e=this.mediaSessionId$.getValue();Oe(e,`pause on null mediaSessionId`),this.params.chromecastConnector.sendV2Message({type:`PAUSE`,mediaSessionId:e,customData:null})}seek(e){let t=this.mediaSessionId$.getValue();Oe(t,`seek on null mediaSessionId`),this.params.chromecastConnector.sendV2Message({type:`SEEK`,currentTime:e,mediaSessionId:t}),this.params.output.willSeekEvent$.next()}setVolume(e,t){let n=e,r=`[setVolume] volume: ${e}, muted: ${t}`;this.isMobile&&(n=this.mobileVolumeState.volume,r+=`, mobile next volume: ${n}`),this.log({message:r}),this.lastRequestedVolume={volume:n,muted:t},this.params.chromecastConnector.sendV2Message({type:`SET_VOLUME`,requestId:0,volume:{level:t?0:n,muted:t?!0:null}})}syncPlaybackState({playerState:e,idleReason:t}){let n=this.params.output.isBuffering$.getValue(),r=e===`BUFFERING`;switch(n!==r&&this.params.output.isBuffering$.next(r),e){case`PAUSED`:j(this.params.desiredState.playbackState,`paused`);break;case`PLAYING`:j(this.params.desiredState.playbackState,`playing`);break;case`IDLE`:t===`FINISHED`?(this.params.output.endedEvent$.next(),j(this.params.desiredState.playbackState,`stopped`),this.contentId$.next(null)):j(this.params.desiredState.playbackState,`ready`);break;case`BUFFERING`:break}}syncPlayback(){let e=this.params.desiredState.playbackState.getState();switch(this.log({message:`[syncPlayback] ${e}`}),e){case`ready`:break;case`playing`:this.play();break;case`paused`:this.pause();break;case`stopped`:this.stop();break}}syncVolumeState(e){if(Fe(e))return;let{level:t,muted:n}=e,r={muted:n??!1,volume:t??0};this.lastRequestedVolume&&=(n&&(r.volume=this.lastRequestedVolume.volume),this.lastRequestedVolume.muted&&!t&&!n&&(r.volume=this.lastRequestedVolume.volume,r.muted=!0),null);let i=`[syncVolumeState] volume: ${r.volume}, muted: ${r.muted}`;this.isMobile&&(this.mobileVolumeState.volume=r.volume,this.mobileVolumeState.muted=r.muted,r.volume=this.params.output.volume$.getValue().volume,i+=`, volume passed to state machine: ${r.volume}`),this.log({message:i}),this.params.output.volume$.next(r)}destroy(){this.progressTicker.destroy(),this.subscription.unsubscribe()}}var $t=e=>({castDevice:{friendlyName:e},remotePlayer:{},remotePlayerController:{},session:{}}),en=()=>String(Date.now())+String(Math.floor(Math.random()*1e5));class tn{constructor(e){this.params=void 0,this.clientId=void 0,this.capabilities=[`WEB`],this.presentationRequest$=new Xt(null),this.log=void 0,this.sessionId$=new Xt(null),this.broadcastChannel=new BroadcastChannel(`vk_player_chromecast_events`),this.subscription=new Jt,this.subscriptionEvents=new Jt,this.isDestroyed=!1,this.sequenceNumber=0,this.presentationAvailable$=new Xt(!1),this.presentationConnection$=new Xt(null),this.message$=new Xt(null),this.friendlyName$=new Xt(null),this.errorEvent$=new qt,this.clientId=this.getClientId(),this.params=e,this.log=e.logger.createComponentLog(`ChromecastPresentationApiConnector`),this.log({message:`constructor`}),this.safeReinitPresentation(),this.subscribe()}destroy(){this.log({message:`destroy`}),this.subscription.unsubscribe(),this.subscriptionEvents.unsubscribe(),this.broadcastChannel.close(),this.isDestroyed=!0}disconnect(e=!0){this.log({message:`disconnect`}),e&&this.stopMedia(),this.presentationRequest$.next(null);let t=this.presentationConnection$.getValue();t&&t.close(),this.presentationConnection$.next(null),this.friendlyName$.next(null),this.resetSequenceNumber(),this.resetSubscriptionEvents()}stopMedia(){this.log({message:`stopMedia`}),this.sendV2Message({type:`STOP`})}reinitPresentation(e=!0){let t=this.createCastUrl(),n=new PresentationRequest(t);this.presentationRequest$.next(n),this.log({message:`PresentationRequest created`}),n.getAvailability().then(e=>{let t=()=>{this.log({message:`PresentationRequest presentation availability: ${e.value}`}),this.presentationAvailable$.next(e.value)};this.subscriptionEvents.add(Zt(e,`change`).subscribe(()=>{t()})),t()}).catch(()=>{this.presentationAvailable$.next(!0)}),Qt().navigator.presentation.defaultRequest=n,e&&n.reconnect(`auto-join`).then(e=>{this.log({message:`PresentationRequest reconnect success`}),this.handleConnection(e)}).catch(()=>{this.log({message:`PresentationRequest reconnect failed`})})}safeReinitPresentation(e){try{this.reinitPresentation(e)}catch(e){this.errorEvent$.next({category:Gt.WTF,id:`ChromecastPresentationApiConnector`,message:e?.message??`reinitPresentation error`,thrown:e})}}connect(){var e=this;return E(function*(){e.log({message:`connect`});try{e.presentationRequest$.getValue()||(e.log({message:`reinitPresentation`}),e.reinitPresentation(!1));let t=e.presentationRequest$.getValue();Wt(t,`connect with null presentationRequest`);let n=yield t.start();e.handleConnection(n)}catch(t){switch(t?.name){case`AbortError`:case`NotAllowedError`:break;default:e.errorEvent$.next({category:Gt.WTF,id:`ChromecastPresentationApiConnector`,message:t?.message??`connect error`,thrown:t});break}}})()}subscribe(){this.subscription.add(Zt(this.broadcastChannel,`message`).subscribe(e=>{this.log({message:`broadcast connection data: ${e.data}`}),e.data===`connection`&&this.disconnect(!1)})),this.subscription.add(this.presentationAvailable$.subscribe(e=>{this.log({message:`presentationAvailable$: ${e}`})})),this.subscription.add(this.presentationConnection$.pipe(Yt(e=>{this.log({message:`presentationConnection$: ${!!e}`})}),Kt(e=>!!e)).subscribe(e=>{let t=Zt(e,`message`).subscribe(e=>{let t=JSON.parse(e.data);t.clientId===this.clientId&&(this.log({message:`[onmessage] ${e.data}`}),this.handleMessage(t),this.message$.next(t))}),n=Zt(e,`connect`).subscribe(()=>{this.send(`client_connect`)}),r=Zt(e,`close`).subscribe(e=>{switch(e.reason){case`error`:this.errorEvent$.next({category:Gt.WTF,id:`ChromecastPresentationApiConnector`,message:`Session error`,thrown:e});break;case`closed`:break}});this.subscriptionEvents.add(t),this.subscriptionEvents.add(n),this.subscriptionEvents.add(r)}))}send(e){switch(e){case`client_connect`:{let e={type:`client_connect`,message:this.clientId,sequenceNumber:-1,timeoutMillis:0,clientId:this.clientId};this.safeSend(JSON.stringify(e));break}}}sendV2Message(e){let t=this.sessionId$.getValue();if(t){let n={type:`v2_message`,sequenceNumber:this.getSequenceNumber(),timeoutMillis:0,clientId:this.clientId,message:T(T({},e),{},{sessionId:t})};this.safeSend(JSON.stringify(n))}}safeSend(e){try{this.log({message:`[send] ${e}`});let t=this.presentationConnection$.getValue();t?.state===`connected`&&t?.send(e)}catch(t){this.errorEvent$.next({category:Gt.WTF,id:`ChromecastPresentationApiConnector`,message:`PresentationConnection send error`,data:{message:e},thrown:t})}}handleMessage(e){switch(e.type){case`new_session`:case`update_session`:this.sessionId$.next(e.message.sessionId),this.friendlyName$.next(e.message.receiver.friendlyName||`Chromecast Device`);break;case`receiver_action`:e.message?.action===`stop`&&this.disconnect();break}}createCastUrl(){return`cast:${this.params.appId}?clientId=${this.clientId}&autoJoinPolicy=tab_and_origin_scoped&defaultActionPolicy=create_session&launchTimeout=60000&supportedAppTypes=${this.capabilities}&appParams=%7B%22launchCheckerParams%22%3A%7B%7D%7D`}getSequenceNumber(){let e=this.sequenceNumber;return this.sequenceNumber=(this.sequenceNumber+1)%(2**53-1),e}resetSequenceNumber(){this.sequenceNumber=0}getClientId(){let e=`__vk_player_chromecast_id`;return Qt()[e]=Qt()[e]||en()}resetSubscriptionEvents(){this.subscriptionEvents.unsubscribe(),this.subscriptionEvents=new Jt}handleConnection(e){this.log({message:`connection available`}),this.isDestroyed?(this.log({message:`connected on already destroyed component`}),e.close()):(this.broadcastChannel.postMessage(`connection`),this.presentationConnection$.next(e))}}class un{static isSupported(){return`chrome`in window&&`presentation`in navigator&&`BroadcastChannel`in window}constructor(e){this.subscription=new on,this.log=void 0,this.contentId=void 0,this.connection$=new nn(void 0),this.castState$=new nn(`NOT_AVAILABLE`),this.errorEvent$=new rn,this.chromecastConnector=void 0;let t=un.isSupported();this.log=e.dependencies.logger.createComponentLog(`ChromecastPresentationApiInitializer`),this.log({message:`[constructor] receiverApplicationId: ${e.receiverApplicationId}, isDisabled: ${e.isDisabled}, isSupported: ${t}`}),!(!t||e.isDisabled||!e.receiverApplicationId)&&(this.chromecastConnector=new tn({appId:e.receiverApplicationId,logger:e.dependencies.logger}),this.subscribe())}subscribe(){ln(this.chromecastConnector,`subscribe with null chromecastConnector`),this.subscription.add(this.chromecastConnector.errorEvent$.subscribe(this.errorEvent$));let e=sn({connection:this.chromecastConnector.presentationConnection$,available:this.chromecastConnector.presentationAvailable$,friendlyName:this.chromecastConnector.friendlyName$.pipe(cn())});this.subscription.add(e.pipe(an(({connection:e,friendlyName:t})=>!!(e&&t)),cn()).subscribe(e=>{let t=this.chromecastConnector?.friendlyName$.getValue()??``;this.connection$.next(e?$t(t):void 0)})).add(e.subscribe(({available:e,connection:t})=>{e?t?this.castState$.next(`CONNECTED`):this.castState$.next(`AVAILABLE`):this.castState$.next(`NOT_AVAILABLE`)}))}connect(){this.log({message:`connect`}),this.chromecastConnector?.connect()}disconnect(){this.log({message:`disconnect`}),this.chromecastConnector?.disconnect()}stopMedia(){var e=this;return E(function*(){e.log({message:`stopMedia`}),e.chromecastConnector?.stopMedia()})()}toggleConnection(){let e=!!this.chromecastConnector?.presentationConnection$.getValue();this.log({message:`toggleConnection: isConnected - ${e}`}),e?this.disconnect():this.connect()}setVolume(e){}setMuted(e){}destroy(){this.log({message:`destroy`}),this.chromecastConnector?.destroy(),this.subscription.unsubscribe()}}var vn=(e,t)=>e===t;class yn{constructor(e,t=vn){this.comparator=void 0,this.state=void 0,this.prevState=void 0,this.transition=void 0,this.transitionStarted$=new gn,this.transitionEnded$=new gn,this.transitionUpdated$=new gn,this.forceChanged$=new gn,this.stateChangeStarted$=_n(this.transitionStarted$,this.transitionUpdated$),this.stateChangeEnded$=_n(this.transitionEnded$,this.forceChanged$),this.comparator=t,this.state=e,this.prevState=void 0}setState(e){let t=this.transition,n=this.state;this.transition=void 0,this.prevState=n,this.state=e,t?this.comparator(t.to,e)?this.transitionEnded$.next(t):this.forceChanged$.next({from:t.from,to:e,canceledTransition:t}):this.forceChanged$.next({from:n,to:e,canceledTransition:t})}startTransitionTo(e){let t=this.transition,n=this.state;this.comparator(n,e)||hn(t)&&this.comparator(t.to,e)||(this.prevState=n,this.state=e,t?(this.transition={from:t.from,to:e,canceledTransition:t},this.transitionUpdated$.next(this.transition)):(this.transition={from:n,to:e},this.transitionStarted$.next(this.transition)))}getTransition(){return this.transition}getState(){return this.state}getPrevState(){return this.prevState}}var An=5,jn=5,Mn=500,Nn=7e3;class Pn{constructor(e){this.subscription=new On,this.loadMediaTimeoutSubscription=new On,this.videoState=new yn(`stopped`),this.params=void 0,this.log=void 0,this.syncPlayback=()=>{let e=this.videoState.getState(),t=this.videoState.getTransition(),n=this.params.desiredState.playbackState.getState(),r=this.params.desiredState.playbackState.getTransition(),i=this.params.desiredState.seekState.getState();if(this.log({message:`[syncPlayback] videoState: ${e}; videoTransition: ${JSON.stringify(t)}; desiredPlaybackState: ${n}; desiredPlaybackStateTransition: ${this.params.desiredState.playbackState.getTransition()}; seekState: ${JSON.stringify(i)};`}),n===`stopped`){e!==`stopped`&&(this.videoState.startTransitionTo(`stopped`),this.stop());return}if(!t){if(r?.to!==`paused`&&i.state===`requested`&&e!==`stopped`){this.seek(i.position/1e3);return}switch(n){case`ready`:switch(e){case`playing`:case`paused`:case`ready`:break;case`stopped`:this.videoState.startTransitionTo(`ready`),this.prepare();break;default:bn(e)}break;case`playing`:switch(e){case`playing`:break;case`paused`:this.videoState.startTransitionTo(`playing`),this.params.connection.remotePlayerController.playOrPause();break;case`ready`:this.videoState.startTransitionTo(`playing`),this.params.connection.remotePlayerController.playOrPause();break;case`stopped`:this.videoState.startTransitionTo(`ready`),this.prepare();break;default:bn(e)}break;case`paused`:switch(e){case`playing`:this.videoState.startTransitionTo(`paused`),this.params.connection.remotePlayerController.playOrPause();break;case`paused`:break;case`ready`:this.videoState.startTransitionTo(`paused`),this.videoState.setState(`paused`);break;case`stopped`:this.videoState.startTransitionTo(`ready`),this.prepare();break;default:bn(e)}break;default:bn(n)}}},this.params=e,this.log=this.params.dependencies.logger.createComponentLog(`ChromecastProvider`),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(Vt(e.format)),this.params.output.isAudioAvailable$.next(!0),this.handleRemoteVolumeChange({volume:this.params.connection.remotePlayer.volumeLevel,muted:this.params.connection.remotePlayer.isMuted});let t=this.params.connection.session.getMediaSession();t&&this.restoreSession(t),this.subscribe()}destroy(){this.log({message:`[destroy]`}),this.subscription.unsubscribe()}subscribe(){this.subscription.add(this.loadMediaTimeoutSubscription);let e=new On;this.subscription.add(e),this.subscription.add(Tn(this.videoState.stateChangeStarted$.pipe(wn(e=>`stateChangeStarted$ ${JSON.stringify(e)}`)),this.videoState.stateChangeEnded$.pipe(wn(e=>`stateChangeEnded$ ${JSON.stringify(e)}`))).subscribe(e=>this.log({message:`[videoState] ${e}`})));let t=(e,t)=>this.subscription.add(e.subscribe(t));if(this.params.output.isLive$.getValue())this.params.output.position$.next(0),this.params.output.duration$.next(0);else{let t=new Dn;e.add(t.pipe(xn(Mn)).subscribe(()=>{this.params.output.seekedEvent$.next()}));let n=NaN;e.add(Cn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED).subscribe(e=>{this.logRemoteEvent(e);let r=e.value;this.params.output.position$.next(r),(this.params.desiredState.seekState.getState().state===`applying`||Math.abs(r-n)>An)&&t.next(r),n=r})),e.add(Cn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.DURATION_CHANGED).subscribe(e=>{this.logRemoteEvent(e),this.params.output.duration$.next(e.value)}))}t(Cn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED),t=>{this.logRemoteEvent(t),t.value?this.handleRemoteReady():(this.handleRemoteStop(),e.unsubscribe())}),t(Cn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),e=>{this.logRemoteEvent(e),e.value?this.handleRemotePause():this.handleRemotePlay()}),t(Cn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED),e=>{this.logRemoteEvent(e);let{remotePlayer:t}=this.params.connection,n=e.value,r=this.params.output.isBuffering$.getValue(),i=n===chrome.cast.media.PlayerState.BUFFERING;switch(r!==i&&this.params.output.isBuffering$.next(i),n){case chrome.cast.media.PlayerState.IDLE:!this.params.output.isLive$.getValue()&&t.duration-t.currentTime<jn&&this.params.output.endedEvent$.next(),this.handleRemoteStop(),j(this.params.desiredState.playbackState,`stopped`);break;case chrome.cast.media.PlayerState.PAUSED:this.handleRemotePause();break;case chrome.cast.media.PlayerState.PLAYING:this.handleRemotePlay();break;case chrome.cast.media.PlayerState.BUFFERING:break;default:bn(n)}}),t(Cn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED),e=>{this.logRemoteEvent(e),this.handleRemoteVolumeChange({volume:e.value})}),t(Cn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),e=>{this.logRemoteEvent(e),this.handleRemoteVolumeChange({muted:e.value})}),t(Tn(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,En([`init`])).pipe(xn(0)),this.syncPlayback)}restoreSession(e){this.log({message:`restoreSession`});let{remotePlayer:t}=this.params.connection;if(e.playerState!==chrome.cast.media.PlayerState.IDLE){t.isPaused?(this.videoState.setState(`paused`),j(this.params.desiredState.playbackState,`paused`)):(this.videoState.setState(`playing`),j(this.params.desiredState.playbackState,`playing`));let e=this.params.output.isLive$.getValue();this.params.output.duration$.next(e?0:t.duration),this.params.output.position$.next(e?0:t.currentTime),this.params.desiredState.seekState.setState({state:`none`})}}prepare(){let e=this.params.format;this.log({message:`[prepare] format: ${e}`});let t=Xe(this.params),n=this.createLoadRequest(t);this.loadMedia(n)}handleRemotePause(){let e=this.videoState.getState();(this.videoState.getTransition()?.to===`paused`||e===`playing`)&&(this.videoState.setState(`paused`),j(this.params.desiredState.playbackState,`paused`))}handleRemotePlay(){let e=this.videoState.getState();(this.videoState.getTransition()?.to===`playing`||e===`paused`)&&(this.videoState.setState(`playing`),j(this.params.desiredState.playbackState,`playing`))}handleRemoteReady(){this.videoState.getTransition()?.to===`ready`&&this.videoState.setState(`ready`),this.params.desiredState.playbackState.getTransition()?.to===`ready`&&j(this.params.desiredState.playbackState,`ready`)}handleRemoteStop(){this.videoState.getState()!==`stopped`&&this.videoState.setState(`stopped`)}handleRemoteVolumeChange(e){let t=this.params.output.volume$.getValue(),n={volume:e.volume??t.volume,muted:e.muted??t.muted};(n.volume!==t.volume||n.muted!==n.muted)&&this.params.output.volume$.next(n)}seek(e){this.params.output.willSeekEvent$.next();let{remotePlayer:t,remotePlayerController:n}=this.params.connection;t.currentTime=e,n.seek()}stop(){let{remotePlayerController:e}=this.params.connection;e.stop()}createLoadRequest(e){let t=new chrome.cast.media.LoadRequest(e);t.autoplay=!1;let n=this.params.desiredState.seekState.getState();return n.state===`applying`||n.state===`requested`?t.currentTime=this.params.output.isLive$.getValue()?0:n.position/1e3:t.currentTime=0,t}loadMedia(e){let t=this.params.connection.session.loadMedia(e),n=new Promise((e,t)=>{this.loadMediaTimeoutSubscription.add(kn(Nn).subscribe(()=>t(`timeout(${Nn})`)))});mn(Promise.race([t,n]).then(()=>{this.log({message:`[loadMedia] completed, format: ${this.params.format}`}),this.params.desiredState.seekState.getState().state===`applying`&&this.params.output.seekedEvent$.next(),this.handleRemoteReady()},e=>{let t=`[prepare] loadMedia failed, format: ${this.params.format}, reason: ${e}`;this.log({message:t}),this.params.output.error$.next({id:`ChromecastProvider.loadMedia`,category:Sn.VIDEO_PIPELINE,message:t,thrown:e})}),()=>{this.loadMediaTimeoutSubscription.unsubscribe()})}logRemoteEvent(e){this.log({message:`[remoteEvent] ${JSON.stringify(e)}`})}}var Vn=e=>{try{e.pause(),e.playbackRate=0,Bn(e),e.remove()}catch(e){console.error(e)}},Hn=`__spvc`;class Un{constructor(){this.attribute=`data-pool-reused`}get(e){return e.hasAttribute(this.attribute)}set(e,t){e.toggleAttribute(this.attribute,t)}delete(e){e.removeAttribute(this.attribute)}}var Wn=Rn(),Gn=Wn.WeakMap?new Wn.WeakMap:new Un,Kn=Wn.WeakMap?new Wn.WeakMap:new Map,qn=(e,t=20)=>{let n=0;return Ln(e,`ratechange`).subscribe(r=>{n++,n>=t&&(e.currentTime=e.currentTime,n=0)})};function Jn(e){e.style.position=`fixed`,e.style.left=`100%`,e.setAttribute(`data-role`,`screen`),Rn().document.body.appendChild(e)}function Yn(e,t){e.style.position=``,e.style.left=``,t.appendChild(e)}var Xn=(e,{audioVideoSyncRate:t,disableYandexPiP:n,reuseOwnVideoElement:r,reuseOwnVideoElementOnBackgroundTabOnly:i})=>{let a,o=e.querySelector(`video`),s=!!o,c=Rn().document.querySelector(`body > video[data-role=screen]`)||void 0;r&&!i?Wn[Hn]=c:(c?.remove(),delete Wn[Hn]),o?(a=o,In(a)):c&&c===Wn[Hn]?(a=c,Yn(a,e)):(a=Rn().document.createElement(`video`),e.appendChild(a),r&&!i&&(Wn[Hn]=a)),Gn.set(a,s);let l=new zn;return l.add(qn(a,t)),Kn.set(a,l),a.setAttribute(`crossorigin`,`anonymous`),a.setAttribute(`playsinline`,`playsinline`),n&&a.setAttribute(`x-yandex-pip`,`false`),a.controls=!1,a.setAttribute(`poster`,`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=`),a},Zn=e=>(e.setAttribute(`crossorigin`,`anonymous`),e.controls=!1,e),Qn=(e,t)=>{if(e instanceof HTMLAudioElement){$n(e,t);return}if(e instanceof HTMLVideoElement){er(e,t);return}};function $n(e,{clearAudioElementOnDispose:t}){if(t){In(e);return}Vn(e)}function er(e,{reuseOwnVideoElement:t,reuseOwnVideoElementOnBackgroundTabOnly:n}){Kn.get(e)?.unsubscribe(),Kn.delete(e);let r=Gn.get(e);Gn.delete(e),In(e),t&&!n&&!r&&Jn(e)}var ur=(e,t,n,{equal:r=(e,t)=>e===t,changed$:i,onError:a}={})=>{let o=e.getState(),s=t(),c=cr(i),l=new lr;return i&&l.add(i.subscribe(t=>{r(t,e.getState())&&e.setState(t)},a)),r(s,o)||(n(o),c&&e.setState(o)),l.add(e.stateChangeStarted$.subscribe(t=>{n(t.to),c&&e.setState(t.to)},a)),l},dr=(e,t,n)=>ur(t,()=>e.loop,t=>{sr(t)&&(e.loop=t)},{onError:n}),fr=(e,t,n,r,i)=>ur(t,()=>({muted:e.muted,volume:e.volume}),t=>{i?.skipVideoElVolumeSync$.getValue()||sr(t)&&(e.muted=t.muted,e.volume=t.volume)},{equal:(e,t)=>e===t||e?.muted===t?.muted&&e?.volume===t?.volume,changed$:n,onError:r}),pr=(e,t,n,r)=>ur(t,()=>e.playbackRate,t=>{sr(t)&&(e.playbackRate=t)},{changed$:n,onError:r}),mr=ur;class hr{constructor(){this.available$=new ir,this.error$=new ir,this.subscription=new ar,this.externalTracks=new Map,this.internalTracks=new Map,this.emittedIds=void 0}connect(e,t){let n=e=>{this.error$.next({id:`TextTracksManager`,category:or.WTF,message:`Generic TextTrackManager error`,thrown:e})};this.subscription.add(this.available$.subscribe(t.availableTextTracks$)),this.subscription.add(this.error$.subscribe(t.error$)),this.emitAvailable(),this.subscription.add(mr(e.internalTextTracks,()=>Array.from(this.internalTracks.values()),e=>{nr(e)&&this.setInternal(e)},{equal:(e,t)=>nr(e)&&nr(t)&&e.length===t.length&&e.every(({id:e},n)=>e===t[n].id),changed$:this.available$.pipe(rr(e=>e.filter(({type:e})=>e===`internal`))),onError:n})),this.subscription.add(mr(e.externalTextTracks,()=>Array.from(this.externalTracks.values()),e=>{nr(e)&&this.setExternal(e)},{equal:(e,t)=>nr(e)&&nr(t)&&e.length===t.length&&e.every(({id:e},n)=>e===t[n].id),changed$:this.available$.pipe(rr(e=>e.filter(({type:e})=>e===`external`))),onError:n}))}setExternal(e){this.internalTracks.clear();for(let t of Array.from(this.externalTracks.keys()))e.some(e=>e.id===t)||this.externalTracks.delete(t);for(let t of e)this.externalTracks.has(t.id)||this.externalTracks.set(t.id,t);this.emitAvailable()}setInternal(e){let t=Array.from(this.externalTracks.values());for(let t of Array.from(this.internalTracks.keys()))e.some(e=>e.id===t)||this.internalTracks.delete(t);for(let n of e){let e=t.some(({language:e,isAuto:t})=>e===n.language&&t===n.isAuto);!this.internalTracks.has(n.id)&&!e&&this.internalTracks.set(n.id,n)}this.emitAvailable()}destroy(){this.subscription.unsubscribe(),this.externalTracks.clear(),this.internalTracks.clear()}emitAvailable(){let e=[...this.externalTracks.values(),...this.internalTracks.values()],t=e.map(({id:e})=>e),{emittedIds:n}=this;n&&n.length===t.length&&n.every((e,n)=>e===t[n])||(this.emittedIds=t,this.available$.next(e.map(e=>T(T({},e),{},{isAuto:e.isAuto??tr(e.id,`auto`)}))))}}var gr=hr;class _r{constructor(){this.pausedTime=0,this.streamOffset=0,this.pauseTimestamp=0}getTotalPausedTime(){return this.pausedTime+this.getCurrentPausedTime()}getCurrentPausedTime(){return this.pauseTimestamp>0?Date.now()-this.pauseTimestamp:0}getStreamOffset(){return this.streamOffset}getTotalOffset(){return this.getTotalPausedTime()+this.streamOffset}pause(){this.pauseTimestamp===0&&(this.pauseTimestamp=Date.now())}resume(){this.pauseTimestamp>0&&(this.pausedTime+=this.getCurrentPausedTime(),this.pauseTimestamp=0)}resetTo(e,t=!1){this.streamOffset=e,this.pauseTimestamp=0,this.pausedTime=0,t&&this.pause()}}var vr=e=>{let t=e;for(;!(t instanceof Document)&&!(t instanceof ShadowRoot)&&t!==null;)t=t?.parentNode;return t??void 0},yr=e=>{let t=vr(e);return!!(t&&t.fullscreenElement&&t.fullscreenElement===e)},br=e=>{let t=vr(e);return!!(t&&t.pictureInPictureElement&&t.pictureInPictureElement===e)};var Fr=3,Ir=(e,t,n=Fr)=>{let r=0,i=0;for(let a=0;a<e.length;a++){let o=e.start(a),s=e.end(a);if(o<=t&&t<=s){if(r=o,i=s,!n)return{from:r,to:i};for(let t=a-1;t>=0;t--)e.end(t)+n>=r&&(r=e.start(t));for(let t=a+1;t<e.length;t++)e.start(t)-n<=i&&(i=e.end(t))}}return{from:r,to:i}},Lr=e=>{let t=0;for(let n=0;n<e.length;n++)t+=e.end(n)-e.start(n);return t},Rr=e=>{let t=0;for(let n=0;n<e.length;n++)t+=e.end(n)-e.start(n);return t*1e3},zr=e=>{let t=t=>F(e,t).pipe(Dr(void 0),I(1)),n=new Pr,r=()=>n.unsubscribe(),i=Sr(F(e,`progress`),F(e,`timeupdate`)),a=i.pipe(xr(()=>Ir(e.buffered,e.currentTime)),I(1)),o=i.pipe(xr(()=>Rr(e.buffered)),I(1)),s=i.pipe(xr(()=>e.buffered.length),I(1)),c=P.browser.isSafari?Or({play:t(`play`).pipe(kr()),playing:t(`playing`)}).pipe(Dr(void 0),I(1)):t(`playing`),l=F(e,`volumechange`).pipe(xr(()=>({muted:e.muted,volume:e.volume})),I(1)),u=F(e,`ratechange`).pipe(xr(()=>e.playbackRate),I(1)),d=F(e,`error`).pipe(Er(()=>!!(e.error||e.played.length)),xr(()=>{let t=e.error;return{id:t?`MediaError#${t.code}`:`HtmlVideoError`,category:jr.VIDEO_PIPELINE,message:t?t.message:`Error event from HTML video element`,thrown:e.error??void 0,origin:Mr.MediaError,data:t?{code:t.code}:void 0}}),I(1)),f=F(e,`timeupdate`).pipe(xr(()=>e.currentTime),I(1)),p=Sr(F(e,`loadedmetadata`),F(e,`timeupdate`),F(e,`pause`),F(e,`seeked`),F(e,`ended`)).pipe(xr(()=>Lr(e.played)),Cr(),I(1)),m=[`waiting`,`seeking`,`seeked`,`timeupdate`],h=new Tr,g=.3,_;n.add(Sr(...m.map(t=>F(e,t))).subscribe(t=>{let n=e.currentTime;e.loop&&wr(_)&&wr(n)&&_>=e.duration-g&&n<=g&&h.next(_),_=n}));let v=t(`pause`).pipe(Er(()=>!e.error&&_!==e.duration),I(1)),y=F(e,`enterpictureinpicture`).pipe(I(1)),b=F(e,`leavepictureinpicture`).pipe(I(1)),x=new Nr(br(e));n.add(y.subscribe(()=>x.next(!0))),n.add(b.subscribe(()=>x.next(!1)));let S=new Nr(yr(e)),C=F(e,`fullscreenchange`).pipe(I(1));n.add(C.pipe(xr(()=>yr(e))).subscribe(S));let ee=F(e,`timeupdate`).pipe(xr(t=>e.duration-e.currentTime<.1),Cr(),I(1)),w=Sr(ee.pipe(Er(t=>!e.loop&&t)),F(e,`ended`)).pipe(Ar(1e3),Dr(void 0),I(1)),T=Sr(...[`waiting`,`pause`,`canplay`,`play`,`canplaythrough`,`playing`,`seeking`,`seeked`,`ended`].map(t=>F(e,t)),ee.pipe(xr(e=>({type:e?`ended`:`unknown`})))).pipe(xr(t=>P.browser.isFirefox&&t.type===`ended`?e.readyState<2:e.readyState<3),Cr(),I(1));return{playing$:c,pause$:v,canplay$:t(`canplay`),ended$:w,looped$:h,error$:d,seeked$:t(`seeked`),seeking$:t(`seeking`),progress$:t(`progress`),loadStart$:t(`loadstart`),loadedMetadata$:t(`loadedmetadata`),loadedData$:t(`loadeddata`),timeUpdate$:f,durationChange$:F(e,`durationchange`).pipe(xr(()=>e.duration),I(1)),playedTime$:p,isBuffering$:T,currentBuffer$:a,totalBufferDuration$:o,bufferRangeCount$:s,volumeState$:l,playbackRateState$:u,inPiP$:x,inFullscreen$:S,enterPip$:y,leavePip$:b,destroy:r}};var Vr=e=>{switch(e){case`mobile`:return Br.Q_144P;case`lowest`:return Br.Q_240P;case`low`:return Br.Q_360P;case`sd`:case`medium`:return Br.Q_480P;case`hd`:case`high`:return Br.Q_720P;case`fullhd`:case`full`:return Br.Q_1080P;case`quadhd`:case`quad`:return Br.Q_1440P;case`ultrahd`:case`ultra`:return Br.Q_2160P}};var Jr=e=>`audioTracksAsc`in e;class Xr{constructor(){this.last=void 0,this.history={}}recordSelection(e){this.history[e.id]=Yr()}recordSwitch(e){this.last=e}clear(){this.last=void 0,this.history={}}}var si=(e,t)=>(e??0)/(t>0?t:1),ci=e=>`quality`in e,li=e=>(t,n)=>e*(Number(t.bitrate)-Number(n.bitrate)),ui=e=>(t,n)=>e*(ii(t.quality,n.quality)?-1:1),di=e=>(t,n)=>ci(t)&&ci(n)?ui(e)(t,n):li(e)(t,n),fi=(e,t)=>di(1)(e,t)<0,pi=(e,t)=>Math.log(t)/Math.log(e),mi=(e,t,n)=>(t-n)*2**(-10*e)+n,hi=(e,t,n,r)=>{if(oi(e))return n[0];let i=n.filter(t=>ai(t.bitrate)&&ai(e.bitrate)?e.bitrate/t.bitrate>r:!0),a=ni(n,Math.round(n.length*t.indexOf(e)/(t.length+1)))??ni(n,-1);return a&&ri(i,a)?a:i.length?ni(i,-1):ni(n,0)},gi=(e,t)=>{if(oi(t)||oi(e))return;let n=e.get(t.id);if(!n?.length)return;let r=(n[n.length-1].time.to-n[0].time.from)/1e3;if(r<=0)return;let i=n.reduce((e,t)=>e+(t.size??1/0),0)*8/1024/r;return isFinite(i)?i:void 0},_i=(e,t)=>ai(e)&&ai(t)&&t>0&&e>0&&e<=t*2,vi=e=>{let{name:t}=e;return`
6
+ import{objectEntries as ce}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as le}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as ue}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as de,assertNonNullable as fe,isNonNullable as pe,ValueSubject as me,Subject as he,Subscription as ge,merge as _e,observableFrom as ve,fromEvent as ye,map as be,tap as xe,filterChanged as Se,isNullable as Ce,ErrorCategory as we}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as Oe,combine as ke,debounce as Ae,ErrorCategory as je,filter as Me,filterChanged as Ne,isNonNullable as Pe,isNullable as Fe,map as Ie,Subscription as Le,ValueSubject as Re}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as ze,assertNonNullable as Be,ErrorCategory as Ve,getHighestQuality as He,isNonNullable as Ue}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as We}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as Ge}from"@vkontakte/videoplayer-shared/es2015";import{createTimers as tt,TimerModule as nt}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as it}from"@vkontakte/videoplayer-shared/es2015";import{isBrowserWindow as at,ValueSubject as ot}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as st}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as ct,isNullable as lt}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as N}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as dt,isBrowserWindow as ft}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as ht,isBrowserWindow as gt}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as bt,isBrowserWindow as xt}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as Ft,isBrowserWindow as It}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as Wt,ErrorCategory as Gt,filter as Kt,Subject as qt,Subscription as Jt,tap as Yt,ValueSubject as Xt,fromEvent as Zt,getWindow as Qt}from"@vkontakte/videoplayer-shared/es2015";import{ValueSubject as nn,Subject as rn,map as an,Subscription as on,combine as sn,filterChanged as cn,assertNonNullable as ln}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as dn}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as fn}from"@vkontakte/videoplayer-shared/es2015";import{objectFromEntries as pn}from"@vkontakte/videoplayer-shared/es2015";import{promiseFinally as mn}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as hn,Subject as gn,merge as _n}from"@vkontakte/videoplayer-shared/es2015";import"@vkontakte/videoplayer-shared/es2015";import{assertNever as bn,debounce as xn,ErrorCategory as Sn,fromEvent as Cn,map as wn,merge as Tn,observableFrom as En,Subject as Dn,Subscription as On,timeout as kn}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Fn}from"@vkontakte/videoplayer-shared/es2015";import{clearVideoElement as In,fromEvent as Ln,getWindow as Rn,Subscription as zn}from"@vkontakte/videoplayer-shared/es2015";import{clearVideoElement as Bn}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as tr}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as nr,map as rr,Subject as ir,Subscription as ar,ErrorCategory as or}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as sr,isNullable as cr,Subscription as lr}from"@vkontakte/videoplayer-shared/es2015";import{fromEvent as F,map as xr,merge as Sr,filterChanged as Cr,isNonNullable as wr,Subject as Tr,filter as Er,mapTo as Dr,combine as Or,once as kr,shareReplay as I,throttle as Ar,ErrorCategory as jr,ErrorOrigin as Mr,ValueSubject as Nr,Subscription as Pr}from"@vkontakte/videoplayer-shared/es2015";import{VideoQuality as Br}from"@vkontakte/videoplayer-shared/es2015";import{assertNotEmptyArray as Hr,getWindow as Ur,isInvariantQuality as Wr,ValueSubject as Gr}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as Kr}from"@vkontakte/videoplayer-shared/es2015";import{objectFromEntries as qr}from"@vkontakte/videoplayer-shared/es2015";import{now as Yr}from"@vkontakte/videoplayer-shared/es2015";import{flattenObject as Zr,isInvariantQuality as Qr,isLowerOrEqual as $r,isNonNullable as ei,now as ti}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as ni}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as ri}from"@vkontakte/videoplayer-shared/es2015";import{isLowerOrEqual as ii,isNonNullable as ai,isNullable as oi}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as Si,isNonNullable as Ci,isNullable as wi}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as Ti}from"@vkontakte/videoplayer-shared/es2015";import{Subscription as Ei}from"@vkontakte/videoplayer-shared/es2015";import{Subscription as ki}from"@vkontakte/videoplayer-shared/es2015";import{isHigher as Vi,isInvariantQuality as Hi,isNonNullable as Ui}from"@vkontakte/videoplayer-shared/es2015";import{isHigherOrEqual as Gi,isLowerOrEqual as Ki,isNonNullable as qi,videoSizeToQuality as Ji}from"@vkontakte/videoplayer-shared/es2015";import{isHigherOrEqual as Xi,isNullable as Zi}from"@vkontakte/videoplayer-shared/es2015";import{isHigher as Qi,isLower as $i,isNonNullable as ea,isNullable as ta,videoHeightToQuality as na}from"@vkontakte/videoplayer-shared/es2015";import{isHigherOrEqual as ca,isNonNullable as la,isNullable as ua,now as da}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as pa}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as ma}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as _a,isLowerOrEqual as va,isNonNullable as ya,isNullable as ba}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as Sa}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as wa,now as Ta}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as ja,assertNonNullable as Ma,combine as Na,debounce as Pa,ErrorCategory as Fa,filter as Ia,filterChanged as La,isNonNullable as Ra,map as za,merge as Ba,observableFrom as Va,once as Ha,Subscription as Ua,ValueSubject as Wa,videoQualityToHeight as Ga,videoSizeToQuality as Ka}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as qa}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as Xa,isNullable as Za,assertNonNullable as Qa}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as $a}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as eo,assertNonNullable as to,now as no}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as po}from"@vkontakte/videoplayer-shared/es2015";import{Subject as ho}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as go}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as vo}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as yo}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as Oo}from"@vkontakte/videoplayer-shared/es2015";import{debounce as ko,filter as Ao,fromEvent as jo,interval as Mo,isHigher as No,isInvariantQuality as Po,isLower as Fo,merge as Io,Subject as Lo,Subscription as Ro}from"@vkontakte/videoplayer-shared/es2015";import{map as Vo,Observable as Ho}from"@vkontakte/videoplayer-shared/es2015";import{fromEvent as Uo}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Ko}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as qo}from"@vkontakte/videoplayer-shared/es2015";import{filter as gs,filterChanged as _s,isNonNullable as vs}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as ys,assertNonNullable as bs,debounce as xs,ErrorCategory as Ss,filter as Cs,filterChanged as ws,fromEvent as Ts,isNonNullable as Es,isNullable as Ds,map as Os,mapTo as ks,merge as As,observableFrom as js,once as Ms,Subscription as Ns,throttle as Ps}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as Fs}from"@vkontakte/videoplayer-shared/es2015";import{videoSizeToQuality as Is}from"@vkontakte/videoplayer-shared/es2015";import{isNullable as Ws,now as Gs,once as Ks,Subscription as qs,ValueSubject as Js,safeStorage as Ys,filterChanged as Xs}from"@vkontakte/videoplayer-shared/es2015";import{combine as ac,map as oc,observeElementSize as sc,Subscription as cc,ValueSubject as lc,noop as uc}from"@vkontakte/videoplayer-shared/es2015";import{filter as fc,map as pc,once as mc}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as gc}from"@vkontakte/videoplayer-shared/es2015";import{filterChanged as _c,isNonNullable as vc,isNullable as yc,now as bc,once as xc,Subscription as Sc,ValueSubject as Cc}from"@vkontakte/videoplayer-shared/es2015";import{isInvariantQuality as Tc,isNonNullable as Ec,isNullable as Dc,Subscription as Oc,ValueSubject as kc}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as Ac}from"@vkontakte/videoplayer-shared/es2015";import{arrayFlatMap as Bc}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as Vc}from"@vkontakte/videoplayer-shared/es2015";import{stringTrimStart as Hc}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as Uc}from"@vkontakte/videoplayer-shared/es2015";import{abortable as Gc,assertNonNullable as Kc,ErrorCategory as qc,ErrorOrigin as Jc,filter as Yc,filterChanged as Xc,flattenObject as Zc,fromEvent as Qc,getTraceSubscriptionMethod as $c,getWindow as el,interval as tl,isNonNullable as z,isNullable as nl,map as rl,merge as il,nowInt as al,Subject as ol,Subscription as sl,SubscriptionRemovable as cl,ValueSubject as B}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as ll}from"@vkontakte/videoplayer-shared/es2015";import{fetchPolyfilled as ul}from"@vkontakte/videoplayer-shared/es2015";import{promiseFinally as dl}from"@vkontakte/videoplayer-shared/es2015";import{abortable as ml,assertNever as hl,devNull as gl,ErrorCategory as _l,flattenObject as vl,fromEvent as yl,getWindow as bl,isNonNullable as xl,isNullable as Sl,merge as Cl,now as wl,Subject as Tl,Subscription as El,suppressAbort as Dl,ValueSubject as Ol,VideoQuality as kl,isAbortError as Al}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as Ml,ErrorOrigin as Nl,isNullable as Pl,parseUnsignedInt as Fl}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as Vl,isNullable as Hl,getWindow as Ul}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as ou,isNonNullable as su}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as _u}from"@vkontakte/videoplayer-shared/es2015";import{stringReplaceAll as bu}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as xu}from"@vkontakte/videoplayer-shared/es2015";import{stringPadStart as Su}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as Cu}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as wu}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Tu}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Eu}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as Ou,isNullable as ku}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Au}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as Lu}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as Ru}from"@vkontakte/videoplayer-shared/es2015";import{requestIdleCallbackPolyfilled as zu}from"@vkontakte/videoplayer-shared/es2015";import{abortable as Bu,assertNonNullable as Vu,ErrorCategory as Hu,ErrorOrigin as Uu,flattenObject as V,fromEvent as Wu,getExponentialDelay as Gu,getWindow as Ku,isAbortError as qu,isHigher as Ju,isNonNullable as H,isNullable as U,once as Yu,Subject as Xu,Subscription as Zu,ValueSubject as Qu,videoQualityToHeight as $u,VideoQuality as ed}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as td}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as ad}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Id}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as Ld,isNonNullable as Rd,isNullable as zd}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as Bd}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as Zd}from"@vkontakte/videoplayer-shared/es2015";import{videoSizeToQuality as Qd}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as df,getWindow as ff,isNonNullable as pf,isNullable as mf,now as hf,isAbortError as gf}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as vf,getWindow as yf,isAbortError as bf,isNullable as xf,now as Sf}from"@vkontakte/videoplayer-shared/es2015";import{arrayFlatMap as wf}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as Tf,ErrorCategory as Ef,isNullable as Df,ValueSubject as Of}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as jf,fromEvent as Mf,isNullable as Nf,Subject as Pf,Subscription as Ff,ValueSubject as If}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as Lf,ErrorCategory as Rf,Subject as zf}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as Kf}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as qf,isHigher as Jf,isLower as Yf,isLowerOrEqual as Xf,VideoQuality as Zf}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as up,combine as dp,ErrorCategory as fp,filter as pp,filterChanged as mp,fromEvent as hp,isNonNullable as gp,map as _p,merge as vp}from"@vkontakte/videoplayer-shared/es2015";import{combine as xp,merge as Sp,filter as Cp,filterChanged as wp,isNullable as Tp,map as Ep,ValueSubject as Dp,isNonNullable as Op}from"@vkontakte/videoplayer-shared/es2015";import{isNullable as Ip,ValueSubject as Lp}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as Up,combine as Wp,ErrorCategory as Gp,filter as Kp,filterChanged as qp,fromEvent as Jp,interval as Yp,isNonNullable as Xp,isNullable as Zp,map as Qp,now as $p,throttle as em}from"@vkontakte/videoplayer-shared/es2015";import{isNullable as nm,ValueSubject as rm}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as sm,assertNonNullable as cm,combine as lm,debounce as um,ErrorCategory as dm,filter as fm,filterChanged as pm,fromEvent as mm,isNonNullable as hm,isNullable as gm,map as _m,merge as vm,observableFrom as ym,once as bm,Subscription as xm,throttle as Sm}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as Cm}from"@vkontakte/videoplayer-shared/es2015";import{arrayFlatMap as wm}from"@vkontakte/videoplayer-shared/es2015";import{abortable as Dm,assertNonNullable as Om,combine as km,ErrorCategory as Am,ErrorOrigin as jm,filter as Mm,filterChanged as Nm,flattenObject as Pm,fromEvent as Fm,getTraceSubscriptionMethod as Im,interval as Lm,isNonNullable as Rm,isNullable as zm,map as Bm,merge as Vm,now as Hm,Subject as Um,Subscription as Wm,SubscriptionRemovable as Gm,tap as Km,throttle as qm,ValueSubject as W}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as Jm}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Ym}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as Xm}from"@vkontakte/videoplayer-shared/es2015";import{arrayFlatMap as Zm}from"@vkontakte/videoplayer-shared/es2015";import{cancelIdleCallbackPolyfilled as Qm}from"@vkontakte/videoplayer-shared/es2015";import{requestIdleCallbackPolyfilled as $m}from"@vkontakte/videoplayer-shared/es2015";import{promiseFinally as eh}from"@vkontakte/videoplayer-shared/es2015";import{promiseAllSettled as th}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as nh,ErrorCategory as rh,Subject as ih}from"@vkontakte/videoplayer-shared/es2015";import{abortable as uh,assertNonNullable as dh,ErrorCategory as fh,ErrorOrigin as ph,flattenObject as mh,fromEvent as hh,getExponentialDelay as gh,getWindow as _h,isHigher as vh,isNonNullable as yh,isNullable as G,now as bh,once as xh,Subject as Sh,Subscription as Ch,ValueSubject as wh,videoQualityToHeight as Th,VideoQuality as Eh,isAbortError as Dh}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as kh}from"@vkontakte/videoplayer-shared/es2015";import{fetchPolyfilled as Ah}from"@vkontakte/videoplayer-shared/es2015";import{promiseFinally as jh}from"@vkontakte/videoplayer-shared/es2015";import{abortable as Mh,assertNever as Nh,devNull as Ph,fromEvent as Fh,merge as Ih,now as Lh,Subject as Rh,ValueSubject as zh,VideoQuality as Bh,flattenObject as Vh,ErrorCategory as Hh,SubscriptionRemovable as Uh,getWindow as Wh,isNonNullable as Gh,isNullable as Kh,suppressAbort as qh}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as Jh,ErrorOrigin as Yh,isNullable as Xh,parseUnsignedInt as Zh}from"@vkontakte/videoplayer-shared/es2015";import{isNullable as ig,ValueSubject as ag}from"@vkontakte/videoplayer-shared/es2015";import{combine as fg,merge as pg,filter as mg,filterChanged as hg,isNullable as gg,map as _g,ValueSubject as vg,isNonNullable as yg}from"@vkontakte/videoplayer-shared/es2015";import{fetchPolyfilled as xg}from"@vkontakte/videoplayer-shared/es2015";import{fetchPolyfilled as Sg}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as Tg,combine as Eg,debounce as Dg,ErrorCategory as Og,filter as kg,filterChanged as Ag,isNonNullable as jg,isNullable as Mg,map as Ng,merge as Pg,observableFrom as Fg,Subscription as Ig,ValueSubject as Lg,VideoQuality as Rg}from"@vkontakte/videoplayer-shared/es2015";import{objectFromEntries as zg}from"@vkontakte/videoplayer-shared/es2015";import{fetchPolyfilled as Bg}from"@vkontakte/videoplayer-shared/es2015";import{videoSizeToQuality as Vg,getExponentialDelay as Hg}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as Zg}from"@vkontakte/videoplayer-shared/es2015";import{fetchPolyfilled as Qg}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as $g,Subscription as e_,throttle as t_,ValueSubject as n_,Subject as r_,ErrorCategory as i_}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as s_,debounce as c_,ErrorCategory as l_,fromEvent as u_,isInvariantQuality as d_,isNonNullable as f_,isNullable as p_,map as m_,merge as h_,observableFrom as g_,Subscription as __,ValueSubject as v_,VideoQuality as y_}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as x_}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as S_}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as C_}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as w_,assertNonNullable as T_,debounce as E_,ErrorCategory as D_,isHigherOrEqual as O_,isLowerOrEqual as k_,isNonNullable as A_,merge as j_,observableFrom as M_,Subscription as N_,map as P_}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as I_,debounce as L_,merge as R_,observableFrom as z_,Subscription as B_,map as V_,ValueSubject as H_,ErrorCategory as U_,VideoQuality as W_}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as G_}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as $_,assertNonNullable as ev,ErrorCategory as tv,ErrorOrigin as nv,filter as rv,isNonNullable as iv,isNullable as av,map as ov,merge as sv,once as cv,Subject as K,Subscription as lv,ValueSubject as q,flattenObject as uv,devNull as dv,getWindow as fv}from"@vkontakte/videoplayer-shared/es2015";import{Observable as pv,map as mv,Subscription as hv,Subject as gv,now as _v,combine as vv}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as bv}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as xv,Subscription as Sv,combine as Cv,filter as wv,once as Tv}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as Ev}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as kv}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as Av,Subject as jv,Subscription as Mv,merge as Nv,isNonNullable as Pv}from"@vkontakte/videoplayer-shared/es2015";import{ErrorOrigin as Fv,flattenObject as Iv,isNullable as Lv}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as Bv}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as Hv,ErrorOrigin as Uv}from"@vkontakte/videoplayer-shared/es2015";import{ErrorOrigin as Gv,flattenObject as Kv}from"@vkontakte/videoplayer-shared/es2015";import{filterChanged as Jv,flattenObject as Yv,fromEvent as Xv,getWindow as Zv,isNonNullable as Qv,merge as $v,now as ey,Subject as ty,Subscription as ny,ErrorOrigin as ry}from"@vkontakte/videoplayer-shared/es2015";import{ErrorOrigin as oy}from"@vkontakte/videoplayer-shared/es2015";import{isNullable as cy,isNonNullable as ly,getWindow as uy}from"@vkontakte/videoplayer-shared/es2015";import{isNullable as my,isNonNullable as hy,Subscription as gy}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as by}from"@vkontakte/videoplayer-shared/es2015";import{objectFromEntries as xy}from"@vkontakte/videoplayer-shared/es2015";import{fromEvent as Sy,once as Cy,combine as wy,Subscription as Ty,ValueSubject as Ey,map as Dy,filter as Oy,isNonNullable as ky,isNullable as Ay,now as J,safeStorage as jy,getWindow as My}from"@vkontakte/videoplayer-shared/es2015";import{fillWithDefault as Uy,VideoQuality as Wy}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as qy,combine as Jy,devNull as Yy,ErrorCategory as Xy,filter as Y,filterChanged as X,flattenObject as Zy,fromEvent as Qy,getPlayerId as $y,getTimersDiagnostics as eb,getTraceSubscriptionMethod as tb,getWindow as nb,InternalsExposure as rb,isHigher as ib,isInvariantQuality as ab,isNonNullable as ob,isNullable as sb,Logger as cb,map as Z,mapTo as lb,merge as ub,now as db,once as Q,retainTimers as fb,Subject as $,Subscription as pb,tap as mb,throttle as hb,TracerFactory as gb,ValueSubject as _b,combineLatest as vb}from"@vkontakte/videoplayer-shared/es2015";import{merge as yb,map as bb,filter as xb,isNonNullable as Sb}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as wb}from"@vkontakte/videoplayer-shared/es2015";import{requestIdleCallbackPolyfilled as Eb}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as Db}from"@vkontakte/videoplayer-shared/es2015";import{cancelIdleCallbackPolyfilled as Ob}from"@vkontakte/videoplayer-shared/es2015";import{devNull as kb,getWindow as Ab}from"@vkontakte/videoplayer-shared/es2015";import{filter as Lb,mapTo as Rb,merge as zb,once as Bb,Subscription as Vb}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Gb}from"@vkontakte/videoplayer-shared/es2015";import{nowInt as Kb,Subscription as qb,ValueSubject as Jb}from"@vkontakte/videoplayer-shared/es2015";import{filter as Yb,ValueSubject as Xb}from"@vkontakte/videoplayer-shared/es2015";import{ValueSubject as ax}from"@vkontakte/videoplayer-shared/es2015";import{filter as sx,ValueSubject as cx}from"@vkontakte/videoplayer-shared/es2015";import{VideoQuality as lx}from"@vkontakte/videoplayer-shared/es2015";import{ValueSubject as Ex}from"@vkontakte/videoplayer-shared/es2015";import{calculateTotalViewTime as Ox,merge as kx,ValueSubject as Ax}from"@vkontakte/videoplayer-shared/es2015";import{Subscription as Lx,Observable as Rx,Subject as zx,ValueSubject as Bx,VideoQuality as Vx}from"@vkontakte/videoplayer-shared/es2015";var _oxcMod1uc4ua=function(){function e(t){"@babel/helpers - typeof";return e=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},e(t)}var t=e;function n(e,n){if(t(e)!=`object`||!e)return e;var r=e[Symbol._oxc_toPrimitive];if(r!==void 0){var i=r.call(e,n||`default`);if(t(i)!=`object`)return i;throw TypeError(`@@_oxc_toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(e)}var t=e,r=n;function i(e){var n=r(e,`string`);return t(n)==`symbol`?n:n+``}var a=i;function o(e,t,n){return(t=a(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=o;function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function l(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?c(Object(n),!0).forEach(function(t){s(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function u(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function d(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){u(a,r,i,o,s,`next`,e)}function s(e){u(a,r,i,o,s,`throw`,e)}o(void 0)})}}function f(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}var p=f;function m(e,t){if(e==null)return{};var n,r,i=p(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function h(e,t){this.v=e,this.k=t}var g=h;function _(e){return new g(e,0)}var g=h;function v(e){return function(){return new y(e.apply(this,arguments))}}function y(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof g;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`?`return`:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(a.done?`return`:`normal`,n)},function(e){r(`throw`,e)})}catch(e){i(`throw`,e)}}function i(e,i){switch(e){case`return`:t.resolve({value:i,done:!0});break;case`throw`:t.reject(i);break;default:t.resolve({value:i,done:!1})}(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}y.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},y.prototype.next=function(e){return this._invoke(`next`,e)},y.prototype.throw=function(e){return this._invoke(`throw`,e)},y.prototype.return=function(e){return this._invoke(`return`,e)};const b=[`name`],x=[`url`],S=[`url`],C=[`downloadingItems`],ee=[`data`],w=[`container`];var T=l,E=d,D=m,te=_,O=v,k=`2.0.181-beta.1`,A;(e=>{e.STOPPED=`stopped`,e.READY=`ready`,e.PLAYING=`playing`,e.PAUSED=`paused`})(A||={});var ne;(e=>{e.MPEG=`MPEG`,e.DASH=`DASH`,e.DASH_SEP=`DASH_SEP`,e.DASH_SEP_VK=`DASH_SEP`,e.DASH_WEBM=`DASH_WEBM`,e.DASH_WEBM_AV1=`DASH_WEBM_AV1`,e.DASH_STREAMS=`DASH_STREAMS`,e.DASH_WEBM_VK=`DASH_WEBM`,e.DASH_ONDEMAND=`DASH_ONDEMAND`,e.DASH_ONDEMAND_VK=`DASH_ONDEMAND`,e.DASH_LIVE=`DASH_LIVE`,e.DASH_LIVE_CMAF=`DASH_LIVE_CMAF`,e.DASH_LIVE_WEBM=`DASH_LIVE_WEBM`,e.HLS=`HLS`,e.HLS_ONDEMAND=`HLS_ONDEMAND`,e.HLS_JS=`HLS`,e.HLS_FMP4=`HLS_FMP4`,e.HLS_LIVE=`HLS_LIVE`,e.HLS_LIVE_CMAF=`HLS_LIVE_CMAF`,e.WEB_RTC_LIVE=`WEB_RTC_LIVE`})(ne||={});var re;(e=>{e.AV1=`av1`,e.VP9=`vp9`,e.AVC1=`avc1`,e.HEV1=`hev1`})(re||={});var ie;(e=>{e.NOT_AVAILABLE=`NOT_AVAILABLE`,e.AVAILABLE=`AVAILABLE`,e.CONNECTING=`CONNECTING`,e.CONNECTED=`CONNECTED`})(ie||={});var ae;(e=>{e.HTTP1=`http1`,e.HTTP2=`http2`,e.QUIC=`quic`})(ae||={});var oe;(e=>{e.NONE=`none`,e.INLINE=`inline`,e.FULLSCREEN=`fullscreen`,e.SECOND_SCREEN=`second_screen`,e.PIP=`pip`,e.INVISIBLE=`invisible`})(oe||={});var se;(e=>{e.TRAFFIC_SAVING=`traffic_saving`,e.HIGH_QUALITY=`high_quality`,e.UNKNOWN=`unknown`})(se||={});var Te=e=>new Promise((t,n)=>{let r=document.createElement(`script`);r.setAttribute(`src`,e),r.onload=()=>t(),r.onerror=e=>n(e),document.body.appendChild(r)});class Ee{constructor(e){this.connection$=new me(void 0),this.castState$=new me(`NOT_AVAILABLE`),this.errorEvent$=new he,this.contentId=void 0,this.realCastState$=new me(`NOT_AVAILABLE`),this.subscription=new ge,this.log=void 0,this.params=void 0,this.isDestroyed=!1,this.params=e,this.log=this.params.dependencies.logger.createComponentLog(`ChromecastInitializer`);let t=`chrome`in window;if(this.log({message:`[constructor] receiverApplicationId: ${this.params.receiverApplicationId}, isDisabled: ${this.params.isDisabled}, isSupported: ${t}`}),e.isDisabled||!t)return;let n=pe(window.chrome?.cast),r=!!window.__onGCastApiAvailable;n?this.initializeCastApi():(window.__onGCastApiAvailable=e=>{delete window.__onGCastApiAvailable,e&&!this.isDestroyed&&this.initializeCastApi()},r||Te(`https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1`).catch(()=>this.errorEvent$.next({id:`ChromecastLoading`,category:we.NETWORK,message:`Script loading failed!`})))}connect(){cast.framework.CastContext.getInstance()?.requestSession()}disconnect(){var e;(e=cast.framework.CastContext.getInstance())==null||(e=e.getCurrentSession())==null||e.endSession(!0)}stopMedia(){return new Promise((e,t)=>{var n;(n=cast.framework.CastContext.getInstance())==null||(n=n.getCurrentSession())==null||(n=n.getMediaSession())==null||n.stop(new chrome.cast.media.StopRequest,e,t)})}toggleConnection(){pe(this.connection$.getValue())?this.disconnect():this.connect()}setVolume(e){let t=this.connection$.getValue();Ce(t)||(t.remotePlayer.volumeLevel=e,t.remotePlayerController.setVolumeLevel())}setMuted(e){let t=this.connection$.getValue();Ce(t)||e!==t.remotePlayer.isMuted&&t.remotePlayerController.muteOrUnmute()}destroy(){this.isDestroyed=!0,this.subscription.unsubscribe()}initListeners(){let e=new cast.framework.RemotePlayer,t=new cast.framework.RemotePlayerController(e),n=cast.framework.CastContext.getInstance();this.subscription.add(ye(n,cast.framework.CastContextEventType.SESSION_STATE_CHANGED).subscribe(e=>{switch(e.sessionState){case cast.framework.SessionState.SESSION_STARTED:case cast.framework.SessionState.SESSION_STARTING:case cast.framework.SessionState.SESSION_RESUMED:var t;this.contentId=(t=n.getCurrentSession())==null||(t=t.getMediaSession())==null||(t=t.media)==null?void 0:t.contentId;break;case cast.framework.SessionState.NO_SESSION:case cast.framework.SessionState.SESSION_ENDING:case cast.framework.SessionState.SESSION_ENDED:case cast.framework.SessionState.SESSION_START_FAILED:this.contentId=void 0;break;default:return de(e.sessionState)}})).add(_e(ye(n,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe(xe(e=>{this.log({message:`[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: ${JSON.stringify(e)}`})}),be(e=>e.castState)),ve([n.getCastState()])).pipe(Se(),be(De),xe(e=>{this.log({message:`realCastState$: ${e}`})})).subscribe(this.realCastState$)).add(this.realCastState$.subscribe(r=>{let i=r===`CONNECTED`,a=pe(this.connection$.getValue());if(i&&!a){var o;let r=n.getCurrentSession();fe(r);let i=r.getCastDevice(),a=(o=r.getMediaSession())==null||(o=o.media)==null?void 0:o.contentId;(Ce(a)||a===this.contentId)&&(this.log({message:`connection created`}),this.connection$.next({remotePlayer:e,remotePlayerController:t,session:r,castDevice:i}))}else!i&&a&&(this.log({message:`connection destroyed`}),this.connection$.next(void 0));this.castState$.next(r===`CONNECTED`?pe(this.connection$.getValue())?`CONNECTED`:`AVAILABLE`:r)}))}initializeCastApi(){let e,t,n;try{e=cast.framework.CastContext.getInstance(),t=chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,n=chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}catch{return}try{e.setOptions({receiverApplicationId:this.params.receiverApplicationId??t,autoJoinPolicy:n}),this.initListeners()}catch(e){this.errorEvent$.next({id:`ChromecastInitializer`,category:we.EXTERNAL_API,message:`[initializeCastApi] failed`,thrown:e})}}}var De=e=>{switch(e){case cast.framework.CastState.NO_DEVICES_AVAILABLE:return`NOT_AVAILABLE`;case cast.framework.CastState.NOT_CONNECTED:return`AVAILABLE`;case cast.framework.CastState.CONNECTING:return`CONNECTING`;case cast.framework.CastState.CONNECTED:return`CONNECTED`;default:return de(e)}};var Ke=`_offset_p`,qe=e=>{if(We(e,Ke))return!0;try{return new URL(e).searchParams.has(`offset_p`)}catch{return!1}},Je=(e,t=0,n=0)=>{switch(n){case 0:return e.replace(Ke,t===0?``:`_`+t.toFixed(0));case 1:{if(t===0)return e;let n=new URL(e);return n.searchParams.append(`playback_shift`,t.toFixed(0)),n.toString()}case 2:{let n=new URL(e);return!n.searchParams.get(`offset_p`)&&t===0?e:(n.searchParams.set(`offset_p`,t.toFixed(0)),n.toString())}default:Ge(n)}return e},Ye=(e,t)=>{switch(t){case 0:return NaN;case 1:{let t=new URL(e);return Number(t.searchParams.get(`playback_shift`))}case 2:{let t=new URL(e);return Number(t.searchParams.get(`offset_p`)??0)}default:Ge(t)}},Xe=e=>{let{source:t,format:n,meta:r,output:i}=e,a,o,s;switch(n){case`MPEG`:{let e=t[n];Be(e);let r=He(Object.keys(e));Be(r);let i=e[r];Be(i),a=i,o=`video/mp4`,s=Ze();break}case`HLS`:case`HLS_FMP4`:case`HLS_ONDEMAND`:{let e=t[n];Be(e),a=e.url,o=`application/x-mpegurl`,s=Ze();break}case`DASH_SEP`:case`DASH_ONDEMAND`:case`DASH_WEBM`:case`DASH_WEBM_AV1`:case`DASH_STREAMS`:{let e=t[n];Be(e),a=e.url,o=`application/dash+xml`,s=Ze();break}case`DASH_LIVE_CMAF`:{let e=t[n];Be(e),a=e.url,o=`application/dash+xml`,s=Qe();break}case`HLS_LIVE`:case`HLS_LIVE_CMAF`:{let e=t[n];Be(e),a=Je(e.url),o=`application/x-mpegurl`,s=Qe();break}case`DASH_LIVE`:case`WEB_RTC_LIVE`:{let e=`Unsupported format for Chromecast`,t=Error(e);throw i.error$.next({id:`ChromecastProvider.createMediaInfo()`,category:Ve.VIDEO_PIPELINE,message:e,thrown:t}),t}case`DASH`:case`DASH_LIVE_WEBM`:throw Error(`${n} is no longer supported`);default:return ze(n)}let c=$e(r.videoId??a,o);c.contentUrl=a,c.streamType=s,c.metadata=et();let{title:l,subtitle:u}=r;return Ue(l)&&(c.metadata.title=l),Ue(u)&&(c.metadata.subtitle=u),c};function Ze(){var e;return((e=chrome.cast)==null||(e=e.media)==null||(e=e.StreamType)==null?void 0:e.BUFFERED)??`BUFFERED`}function Qe(){var e;return((e=chrome.cast)==null||(e=e.media)==null||(e=e.StreamType)==null?void 0:e.LIVE)??`LIVE`}function $e(e,t){var n;return!((n=chrome.cast)==null||(n=n.media)==null)&&n.MediaInfo?new chrome.cast.media.MediaInfo(e,t):{contentId:e,contentType:t,metadata:{title:``,subtitle:``},streamType:Ze()}}function et(){var e;return!((e=chrome.cast)==null||(e=e.media)==null)&&e.GenericMediaMetadata?new chrome.cast.media.GenericMediaMetadata:{images:[],metadataType:0,releaseDate:``,subtitle:``,title:``,releaseYear:1970,type:0}}var j=(e,t,n=!1)=>{let r=e.getTransition();(n||!r||r.to===t)&&e.setState(t)};var M=tt(nt.CORE);class rt{constructor(e){this.params=void 0,this.interval=0,this.startVideoPosition=void 0,this.startTs=void 0,this.params=e}start(e=0){M.clearInterval(this.interval),this.startVideoPosition=e,this.startTs=Date.now(),this.interval=M.setInterval(()=>{let e=(Date.now()-this.startTs)/1e3,t=this.startVideoPosition+e;this.params.output.position$.next(t)},1e3)}pause(){M.clearInterval(this.interval)}destroy(){M.clearInterval(this.interval)}}class ut{constructor(){this._current=void 0,this._current_version=void 0,this._chromeVersion=void 0,this._firefoxVersion=void 0,this._safariVersion=void 0,this._operaVersion=void 0,this._edgeVersion=void 0,this._yandexVersion=void 0,this._isMiuiBrowser=!1}get current(){return this._current}get isChrome(){return this.current===`Chrome`}get isChromiumBased(){return st([`Chrome`,`Chromium`,`Opera`,`Yandex`,`Edge`,`SamsungBrowser`],this.current)}get isFirefox(){return this.current===`Firefox`}get isSafari(){return this.current===`Safari`}get isOpera(){return this.current===`Opera`}get isEdge(){return this.current===`Edge`}get isYandex(){return this.current===`Yandex`}get isSamsungBrowser(){return this.current===`SamsungBrowser`}get currentVersion(){return this._current_version}get chromeVersion(){return this._chromeVersion}get firefoxVersion(){return this._firefoxVersion}get safariVersion(){return this._safariVersion}get operaVersion(){return this._operaVersion}get edgeVersion(){return this._edgeVersion}get yandexVersion(){return this._yandexVersion}get isMiuiBrowser(){return this._isMiuiBrowser}detect(){let{userAgent:e}=navigator;try{let t=/yabrowser/i.test(e)?`Yandex`:void 0,n=/samsungbrowser/i.test(e)?`SamsungBrowser`:void 0,r=/chrome|crios/i.test(e)?`Chrome`:void 0,i=/chromium/i.test(e)?`Chromium`:void 0,a=/firefox|fxios/i.test(e)?`Firefox`:void 0,o=/smart-tv;.*tizen/i.test(e)?`Chrome`:void 0,s=/webkit|safari|khtml/i.test(e)?`Safari`:void 0,c=/opr\//i.test(e)?`Opera`:void 0,l=/edg/i.test(e)?`Edge`:void 0;this._isMiuiBrowser=/(XiaoMi)|(MiuiBrowser)/i.test(e),this._current=t||n||a||c||l||r||i||o||s||`Rest`}catch(e){console.error(e)}this.isChrome&&this.detectChromeVersion(),this.isFirefox&&this.detectFirefoxVersion(),this.isSafari&&this.detectSafariVersion(),this.isOpera&&this.detectOperaVersion(),this.isEdge&&this.detectEdgeVersion(),this.isYandex&&this.detectYandexVersion()}detectVersion(e){try{let{userAgent:t}=ct().navigator,n=t.match(e);if(!n)return;let r=n[1],i=parseInt(r,10);if(!isNaN(i))return this._current_version=i,i}catch(e){console.error(e)}}detectChromeVersion(){this._chromeVersion=this.detectVersion(/Chrome\/(\d+\.\d+)/),lt(this._chromeVersion)&&(this._chromeVersion=this.detectVersion(/(\d+\.\d+\.\d+\.\d+)\/\d+\.\d+ TV/))}detectFirefoxVersion(){this._firefoxVersion=this.detectVersion(/Firefox\/(\d+\.\d+)/)}detectSafariVersion(){this._safariVersion=this.detectVersion(/Version\/(\d+)/)}detectOperaVersion(){this._operaVersion=this.detectVersion(/OPR\/(\d+\.\d+)/)}detectEdgeVersion(){this._edgeVersion=this.detectVersion(/Edg\/(\d+\.\d+)/)}detectYandexVersion(){this._yandexVersion=this.detectVersion(/YaBrowser\/(\d+\.\d+\.\d+)/)}}var pt=()=>{var e;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(navigator.appVersion??navigator.userAgent)||((e=navigator)==null||(e=e.userAgentData)==null?void 0:e.mobile)};class mt{constructor(e){this._displayChecker=void 0,this._isMobile=void 0,this._isSmartTV=!1,this._current=void 0,this._iosVersion=void 0,this._highEntropyValues={},this._os={name:`Unknown`,version:`Unknown`,full:`Unknown`},this._details={vendor:`Unknown`,model:`Unknown`},this._hardware={},this._gpuDetection=void 0,this._displayChecker=e}get current(){return this._current}get os(){return this._os}get details(){return this._details}get isSmartTV(){return this._isSmartTV}get hardware(){return this._hardware}get highEntropyValues(){return this._highEntropyValues}get isIOS(){return this._highEntropyValues.platform===`iOS`||N(this.os.name.toLowerCase(),`ios`)||N([`iPhone`,`iPad`,`iPod`],this.current)}get isIPadOS(){let e=this.current===`Mac`&&this._displayChecker.isTouch;return this.current===`iPad`||e}get isMac(){return this._highEntropyValues.platform===`macOS`||N(this.os.name.toLowerCase(),`mac`)||this.current===`Mac`}get isApple(){return this.isIOS||this.isMac}get isIphoneOrOldIpad(){if(!this.isApple||!this._displayChecker.isTouch)return!1;let e=this.current===`iPad`||this._displayChecker.width>700,t=this._iosVersion;return!e||e&&!!t&&t<16}get isAndroid(){return this._highEntropyValues.platform===`Android`||N(this.os.name.toLowerCase(),`android`)||this.current===`Android`}get isWindows(){return N(this.os.name.toLowerCase(),`windows`)}get isLinux(){return N(this.os.name.toLowerCase(),`linux`)&&!this.isAndroid}get isMobile(){return this._highEntropyValues.mobile||this._isMobile}get isTablet(){if(this.isIPadOS||this._highEntropyValues.formFactors!=null&&N(this._highEntropyValues.formFactors,`Tablet`))return!0;if(!this.isAndroid)return!1;let e=dt();if(!ft(e))return!1;let t=e.navigator;return t?t.userAgentData?.mobile===!1?!0:this._displayChecker.isTouch&&!/\bMobile\b/i.test(t.userAgent):!1}get iOSVersion(){return this._iosVersion}detect(){let e=dt();if(!ft(e))return;let{userAgent:t}=e.navigator;try{this._isMobile=pt()}catch(e){console.error(`DeviceChecker: calling isMobile error - `,e)}this.detectDevice(t),this.detectOS(t),this.detectDeviceDetails(t),this.detectHardware(e),this.detectHighEntropyValues(),this.isIOS&&this.detectIOSVersion(),this.detectSmartTv()}detectHardware(e){let t=e.navigator;try{this._hardware={cpuCores:t.hardwareConcurrency,memoryGb:t.deviceMemory}}catch(e){console.error(`DeviceChecker: detectHardware error - `,e)}}detectGpu(){return this._gpuDetection??=this.requestGpuInfo(),this._gpuDetection}requestGpuInfo(){var e=this;return E(function*(){let t=dt();if(ft(t))try{var n,r;let i=yield t.navigator.gpu?.requestAdapter();e._hardware=T(T({},e._hardware),{},{gpuVendor:(i==null||(n=i.info)==null?void 0:n.vendor)||void 0,gpuArchitecture:(i==null||(r=i.info)==null?void 0:r.architecture)||void 0})}catch(e){console.error(`DeviceChecker: detectGpu error - `,e)}})()}detectHighEntropyValues(){var e=this;return E(function*(){let t=dt();if(!ft(t))return;let{userAgentData:n}=t.navigator;if(n?.getHighEntropyValues){let t=yield n.getHighEntropyValues([`architecture`,`bitness`,`brands`,`mobile`,`platform`,`formFactors`,`model`,`platformVersion`,`wow64`]);e._highEntropyValues=t,t.platform&&(e._os.name=e.normalizeOSName(t.platform),t.platformVersion&&(e._os.version=e.normalizeOSVersion(t.platformVersion),e._os.full=`${e._os.name} ${e._os.version}`)),t.model&&(e._details.model=t.model)}})()}detectSmartTv(){try{this._isSmartTV=!1;let e=dt();if(!ft(e))return;let{userAgent:t}=e.navigator;this._isSmartTV=/smart[\w\-_ ]*tv/i.test(t)||/samsung/i.test(t)&&/tizen/i.test(t)}catch(e){console.error(`DeviceChecker: Smart TV detection error - `,e)}}detectDevice(e){try{let t=/android/i.test(e)?`Android`:void 0,n=/iphone/i.test(e)?`iPhone`:void 0,r=/ipad/i.test(e)?`iPad`:void 0,i=/ipod/i.test(e)?`iPod`:void 0,a=/mac/i.test(e)?`Mac`:void 0,o=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(e)?`RestMobile`:void 0;this._current=t||n||r||i||o||a||`Desktop`}catch(e){console.error(`DeviceChecker: device detection error - `,e)}}detectOS(e){try{for(let[t,n]of[[/(windows nt) (6\.[23]); arm/i,[`Windows RT`]],[/(windows nt) (6\.3); arm/i,[`Windows RT 8.1`]],[/(windows (?:phone|mobile|iot))(?: os)?[/ ]?([\d.]+)/i,[`Windows Mobile`,2]],[/(windows)[/ ](xp|vista|7|8(\.1)?|10|11|2000|me)/i,[1,1]],[/windows nt ?([\d.]+)/i,[`Windows`,1]],[/(windows)[/ ](95|98|me|2000|xp|vista|7|8|8\.1|10|11)/i,[1,2]],[/(iphone os|cpu iphone os) ([\d_.]+)/i,[`iOS`,2]],[/(ipad os|cpu os) ([\d_.]+)/i,[`iPadOS`,2]],[/(ipod os|cpu ipod os) ([\d_.]+)/i,[`iOS`,2]],[/(?:ios|os) ([\d_.]+) like mac os x/i,[`iOS`,1]],[/cfnetwork\/.+darwin/i,[`iOS`]],[/(mac os x) ?([\d_.]+)/i,[`macOS`,2]],[/(macintosh|mac os)/i,[`macOS`]],[/(android) ([\d.]+)/i,[1,2]],[/(harmonyos)[/ ]?([\d.]*)/i,[`HarmonyOS`,2]],[/\b(ubuntu|debian|fedora|centos|arch|linux)(?:[-/ ]([\w.]+))?/i,[1,2]],[/(cros)\D*([\d.]+)/i,[`Chrome OS`,2]],[/(freebsd|openbsd|netbsd|dragonfly)[/ ]?([\w.]*)/i,[1,2]],[/(sunos|solaris)?([\d.]*)/i,[`Solaris`,2]],[/(aix)?([\d.]*)/i,[`AIX`,2]]]){let r=e.match(t);if(r){let t=n.length>0,i=n.length>1,a=`Unknown`,o=`Unknown`;if(t){let e=n[0];typeof e==`number`?e<r.length&&r[e]!==void 0&&(a=r[e]):a=e}if(i){let e=n[1];typeof e==`number`?e<r.length&&r[e]!==void 0&&(o=r[e]):e!==void 0&&(o=e)}else r[2]===void 0?r[1]!==void 0&&t&&typeof n[0]==`string`&&(o=r[1]):o=r[2];a=this.normalizeOSName(a),o=this.normalizeOSVersion(o,a),a===`iOS`&&/ipad/i.test(e)?a=`iPadOS`:a===`iPadOS`&&/ip(hone|od)/i.test(e)&&(a=`iOS`),this._os={name:a,version:o||`Unknown`,full:o&&o!==`Unknown`?`${a} ${o}`:a};break}}}catch(e){console.error(`DeviceChecker: OS detection error - `,e)}}normalizeOSName(e){if(!e)return`Unknown`;let t=e.toLowerCase();return N(t,`windows`)?`Windows`:N(t,`mac os`)||N(t,`macintosh`)?`macOS`:N(t,`iphone`)||N(t,`ios`)?`iOS`:N(t,`ipados`)?`iPadOS`:N(t,`android`)?`Android`:N(t,`harmonyos`)?`HarmonyOS`:N(t,`linux`)?`Linux`:N(t,`cros`)?`Chrome OS`:N(t,`freebsd`)?`FreeBSD`:N(t,`openbsd`)?`OpenBSD`:N(t,`solaris`)||N(t,`sunos`)?`Solaris`:N(t,`aix`)?`AIX`:e}normalizeOSVersion(e,t){if(!e)return`Unknown`;if(e!==`Unknown`&&(e=e.replace(/_/g,`.`),t===`Windows`)){let t=parseFloat(e);if(!isNaN(t)){if(t>=11)return`11`;if(t>=10)return`10`;if(t===6.3)return`8.1`;if(t===6.2)return`8`;if(t===6.1)return`7`;if(t===6)return`Vista`;if(t===5.1||t===5.2)return`XP`;if(t===5)return`2000`;if(t===4)return`NT 4.0`}}return e}detectDeviceDetails(e){try{for(let[t,n]of[[/(iphone)/i,[`Apple`,`iPhone`]],[/(ipad)/i,[`Apple`,`iPad`]],[/(ipod)/i,[`Apple`,`iPod`]],[/(macintosh)/i,[`Apple`,`Macintosh`]],[/(windows[\w\-_ ]*phone)/i,[`Microsoft`,0]],[/(windows nt|win64|win32|wow64)/i,[`Microsoft`,`PC`]],[/\b(sch-i[89]0\d|shw-m380s|sm-[ptxs]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i,[`Samsung`,1]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?\d+a?|galaxy nexus)/i,[`Samsung`,1]],[/samsung[- ]((?!sm-[lr]|browser)[-\w]+)/i,[`Samsung`,1]],[/sec-(sgh\w+)/i,[`Samsung`,1]],[/smart-tv.+(samsung)/i,[`Samsung`,`Smart TV`]],[/(samsung).*tizen/i,[`Samsung`,`Smart TV`]],[/(pixel (?:c|tablet|[0-9a-z ]+))/i,[`Google`,1]],[/(pixelbook(?: go)?)/i,[`Google`,1]],[/nexus [0-9]/i,[`Google`,0]],[/(redmi[-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(mi[\w\-_ ]+)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(poco[\w ]+)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(hm[-_ ]?note?[\w ]*)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(?:xiao)?mi[\w\-_ ]+pad/i,[`Xiaomi`,0]],[/(?:huawei|honor) ?([-\w ]+)[;)]/i,[`Huawei`,1]],[/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][\dc][adnt]?)\b(?!.+d\/s)/i,[`Huawei`,1]],[/\b((?:ag[rs][2356]?k?|bah[234]?|bg[2o]|bt[kv]|cmr|cpn|db[ry]2?|jdn2|got|kob2?k?|mon|pce|scm|sht?|[tw]gr|vrd)-[ad]?[lw][0125][09]b?)/i,[`Huawei`,1]],[/(?:one)?(?:plus)? ?([a\d0]\d\d\d?)(?: b|\))/i,[`OnePlus`,1]],[/droid.+; (cph2[3-6]\d[13579]|((?:gm|hd)19|(?:ac|be|in|kb)20|(?:d[en]|eb|le|mt)21|ne22)[0-2]\d)(?: bui|\))/i,[`OnePlus`,1]],[/(oneplus)[-_ ]?([-\w]*)/i,[`OnePlus`,2]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i,[`Realme`,1]],[/(realme)[-_ ]?([-\w]*)/i,[`Realme`,2]],[/; (\w+) bui.+ oppo/i,[`OPPO`,1]],[/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i,[`OPPO`,1]],[/\b(opd2(\d{3}a?))(?: bui|\))/i,[`OPPO`,1]],[/(oppo)[-_ ]?([-\w]*)/i,[`OPPO`,2]],[/; vivo (\w+)(?: bui|\))/i,[`Vivo`,1]],[/\b(v[12]\d{3}\w?[at])(?: bui|;)/i,[`Vivo`,1]],[/(vivo)[-_ ]?([-\w]*)/i,[`Vivo`,2]],[/\bmot(?:orola)?[- ]([\w\s]+)(\)| bui)/i,[`Motorola`,1]],[/((?:moto(?! 360)[-\w() ]+|xt\d{3,4}[cgkosw+]?[-\d]*|nexus 6)(?= bui|\)))/i,[`Motorola`,1]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b/i,[`Motorola`,0]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i,[`Motorola`,0]],[/droid.+; ([a-z]?\d[0-2]{2}[a-z]{2}|[c-g]\d{4}|so[-gl]\w+|xq-[a-z]{2}\d\d)(?= bui|\))/i,[`Sony`,1]],[/sony tablet [ps]/i,[`Sony`,`Xperia Tablet`]],[/\b(?:sony)?sgp\w+(?: bui|\))/i,[`Sony`,0]],[/(sony)[-_ ]?([-\w]*)/i,[`Sony`,2]],[/\blg[-e;/ ]+(?!.*(?:browser|netcast|android tv|watch|webos))(\w+)/i,[`LG`,1]],[/\blg-?([\d\w]+) bui/i,[`LG`,1]],[/(lm(?:-?f100[nv]?|-[\w.]+)(?= bui|\))|nexus [45])/i,[`LG`,1]],[/((?=lg)?[vl]k-?\d{3}) bui/i,[`LG`,0]],[/(lg)[-_ ]?([-\w]*)/i,[`LG`,2]],[/(?:maemo|nokia).*(n900|lumia \d+|rm-\d+)/i,[`Nokia`,1]],[/nokia[-_ ]?(([-\w. ]*?))(?: bui|\)|;|\/)/i,[`Nokia`,1]],[/(nokia) (t[12][01])/i,[`Nokia`,2]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i,[`ASUS`,1]],[/(?:asus[-_ ])?(zenfone[\w\-_ ]*)/i,[`ASUS`,1]],[/(rog[\w\-_ ]*)/i,[`ASUS`,1]],[/(asus)[-_ ]?([-\w]*)/i,[`ASUS`,2]],[/lenovo[-_ ]?([-\w ]+?)(?: bui|\)|\/)/i,[`Lenovo`,1]],[/(ideatab[-\w ]+|602lv|d-42a|a101lv|a2109a|a3500-hv|s[56]000|pb-6505[my]|tb-?x?\d{3,4}(?:f[cu]|xu|[av])|yt\d?-[jx]?\d+[lfmx])(?: bui|;|\)|\/)/i,[`Lenovo`,1]],[/(thinkpad[\w\-_ ]*)/i,[`Lenovo`,0]],[/(kf[a-z]{2}[a-z]*)(?: bui|\))/i,[`Amazon`,1]],[/(alexa)webm/i,[`Amazon`,`Echo`]],[/(fire[\w\-_ ]*)/i,[`Amazon`,0]],[/(amazon)[-_ ]?([-\w]*)/i,[`Amazon`,2]],[/(?:blackberry|\(bb10;) (\w+)/i,[`BlackBerry`,1]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,[`BlackBerry`,1]],[/(playbook);[-\w),; ]+(rim)/i,[`BlackBerry`,1]],[/(microsoft); (lumia[\w ]+)/i,[`Microsoft`,2]],[/(surface duo)/i,[`Microsoft`,`Surface Duo`]],[/(surface[\w\-_ ]*)/i,[`Microsoft`,0]],[/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,[`ZTE`,2]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,[`HTC`,2]],[/(alcatel|tcl)[-_ ]?([-\w]*)/i,[1,2]],[/(meizu)[-_ ]?([-\w]*)/i,[`Meizu`,2]],[/(tecno)[-_ ]?([-\w]*)/i,[`Tecno`,2]],[/(infinix)[-_ ]?([-\w]*)/i,[`Infinix`,2]],[/(micromax)[-_ ]?([-\w]*)/i,[`Micromax`,2]],[/(lava)[-_ ]?([-\w]*)/i,[`Lava`,2]],[/(panasonic)[-_ ]?([-\w]*)/i,[`Panasonic`,2]],[/(sharp)\/?([-\w]*)/i,[`Sharp`,2]],[/(benq)[-_ ]?([-\w]*)/i,[`BenQ`,2]],[/(palm)[-_ ]?([-\w]*)/i,[`Palm`,2]],[/(vertu)[-_ ]?([-\w]*)/i,[`Vertu`,2]],[/(gionee)[-_ ]?([-\w]*)/i,[`Gionee`,2]],[/(doogee)[-_ ]?([-\w]*)/i,[`Doogee`,2]],[/(ulefone)[-_ ]?([-\w]*)/i,[`Ulefone`,2]],[/(blackview)[-_ ]?([-\w]*)/i,[`Blackview`,2]],[/(cubot)[-_ ]?([-\w]*)/i,[`Cubot`,2]],[/(umidigi)[-_ ]?([-\w]*)/i,[`UMIDIGI`,2]],[/(oukitel)[-_ ]?([-\w]*)/i,[`Oukitel`,2]],[/(fairphone)[-_ ]?([-\w]*)/i,[`Fairphone`,2]],[/(cat)[-_ ]?([-\w]*)/i,[`Cat`,2]],[/(energy)[-_ ]?([-\w]*)/i,[`Energizer`,2]],[/(land rover)[-_ ]?([-\w]*)/i,[`Land Rover`,2]],[/(shield[\w\-_ ]*)/i,[`Nvidia`,0]],[/(crkey)/i,[`Google`,`Chromecast`]],[/(roku)[\dx]*/i,[`Roku`,0]],[/(apple)[-_ ]?tv/i,[`Apple`,`TV`]],[/(amazon)[-_ ]?tv/i,[`Amazon`,`Fire TV`]],[/(google)[-_ ]?tv/i,[`Google`,`TV`]],[/(smart[\w\-_ ]*tv)/i,[0,`Smart TV`]],[/(playstation[\w\-_ ]*)/i,[`Sony`,0]],[/(nintendo[\w\-_ ]*)/i,[`Nintendo`,0]],[/(xbox[\w\-_ ]*)/i,[`Microsoft`,0]],[/(googlebot)/i,[`Google`,`Bot`]],[/(bingbot)/i,[`Microsoft`,`Bing Bot`]],[/(yandexbot)/i,[`Yandex`,`Bot`]],[/(slackbot)/i,[`Slack`,`Bot`]],[/(twitterbot)/i,[`Twitter`,`Bot`]],[/(facebookbot)/i,[`Facebook`,`Bot`]],[/(linkedinbot)/i,[`LinkedIn`,`Bot`]],[/(tesla)[-_ ]?([-\w]*)/i,[`Tesla`,2]],[/(raspberry[\w\-_ ]*)/i,[`Raspberry Pi`,0]]]){let r=e.match(t);if(r){let e=n[0],t=n[1],i=typeof e==`number`?r[e]===void 0?`Unknown`:this.normalizeVendorName(r[e]):this.normalizeVendorName(e),a=`Unknown`;typeof t==`number`?a=r[t]===void 0?`Unknown`:r[t]:t===void 0?r[1]===void 0?r[0]!==void 0&&(a=r[0]):a=r[1]:a=t,a=this.normalizeModelName(a,i),this.details.vendor=i,this.details.model=a;break}}}catch(e){console.error(`DeviceChecker: device details detection error - `,e)}}normalizeVendorName(e){return e?{apple:`Apple`,samsung:`Samsung`,google:`Google`,xiaomi:`Xiaomi`,huawei:`Huawei`,oneplus:`OnePlus`,oppo:`OPPO`,vivo:`Vivo`,realme:`Realme`,motorola:`Motorola`,sony:`Sony`,lg:`LG`,nokia:`Nokia`,asus:`ASUS`,lenovo:`Lenovo`,amazon:`Amazon`,blackberry:`BlackBerry`,microsoft:`Microsoft`,zte:`ZTE`,htc:`HTC`,alcatel:`Alcatel`,tcl:`TCL`,meizu:`Meizu`,tecno:`Tecno`,infinix:`Infinix`,micromax:`Micromax`,lava:`Lava`,panasonic:`Panasonic`,sharp:`Sharp`,benq:`BenQ`,palm:`Palm`,honor:`Honor`,nvidia:`NVIDIA`,roku:`Roku`}[e.toLowerCase()]||e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():`Unknown`}normalizeModelName(e,t){if(!e||e===`Unknown`)return e;if(e===`0`)return`Unknown`;let n=e.replace(/^build\//i,``).replace(/\s+bui$/i,``).replace(/\)$/,``).replace(/[;,)]/g,``).replace(/\s*\(.*?\)\s*/g,``).trim(),r=t.toLowerCase();return N(r,`samsung`)?n=n.replace(/^(sm-|gt-|sgh-|sch-)/i,``):N(r,`xiaomi`)?n=n.replace(/^(mi[\s\-_]*|redmi[\s\-_]*)/i,``):N(r,`oneplus`)?n=n.replace(/^oneplus[\s\-_]*/i,``):N(r,`google`)&&(n=n.replace(/^(pixel[\s\-_]*|nexus[\s\-_]*)/i,``)),n=n.replace(/_/g,` `).replace(/-/g,` `).replace(/\s+/g,` `).trim(),n?(n.length>0&&/^[a-z]/.test(n)&&(n=n.charAt(0).toUpperCase()+n.slice(1)),n):`Unknown`}detectIOSVersion(){try{let e=dt();if(!ft(e))return;if(this._highEntropyValues.platformVersion){let e=this._highEntropyValues.platformVersion.split(`.`).slice(0,2).join(`.`);this._iosVersion=parseFloat(e);return}if(this._os.version!==`Unknown`){let e=this._os.version.split(`.`),t=e.length>=2?`${e[0]}.${e[1]}`:e[0];this._iosVersion=parseFloat(t);return}let t=e.navigator.userAgent.match(/OS (\d+(_\d+)?)/i);t?.[1]&&(this._iosVersion=parseFloat(t[1].replace(/_/g,`.`)))}catch(e){console.error(`DeviceChecker: iOS version detection error - `,e)}}}var _t=[`rec2020`,`p3`,`srgb`],vt=[`standalone`,`minimal-ui`,`fullscreen`,`window-controls-overlay`,`picture-in-picture`];class yt{constructor(){this._maxTouchPoints=void 0,this._height=void 0,this._width=void 0,this._isHdr=void 0,this._pixelRatio=void 0,this._screenHeight=void 0,this._screenWidth=void 0,this._colorDepth=void 0,this._colorGamut=void 0,this._displayMode=`browser`,this._isStandalone=!1}get isTouch(){return typeof this._maxTouchPoints==`number`?this._maxTouchPoints>1:`ontouchstart`in ht()}get maxTouchPoints(){return this._maxTouchPoints}get height(){return this._height}get width(){return this._width}get screenHeight(){return this._screenHeight}get screenWidth(){return this._screenWidth}get pixelRatio(){return this._pixelRatio}get isHDR(){return this._isHdr}get colorDepth(){return this._colorDepth}get colorGamut(){return this._colorGamut}get displayMode(){return this._displayMode}get isStandalone(){return this._isStandalone}detect(){let e=ht();if(!gt(e))return;let{navigator:t,screen:n}=e,{maxTouchPoints:r}=t;try{this._maxTouchPoints=r??0,this._isHdr=!!e.matchMedia(`(dynamic-range: high)`)?.matches,this._colorDepth=n.colorDepth,this._colorGamut=this.detectColorGamut(e)}catch(e){console.error(e)}try{this._pixelRatio=e.devicePixelRatio||1,this._height=n.height,this._width=n.width,this._height=n.height,this._screenHeight=this._height*this._pixelRatio,this._screenWidth=this._width*this._pixelRatio}catch(e){console.error(e)}try{this._displayMode=this.detectDisplayMode(e);let n=t.standalone===!0;this._isStandalone=n||this._displayMode!==`browser`}catch(e){console.error(e)}}detectColorGamut(e){return _t.find(t=>{var n;return(n=e.matchMedia)==null||(n=n.call(e,`(color-gamut: ${t})`))==null?void 0:n.matches})}detectDisplayMode(e){return vt.find(t=>{var n;return(n=e.matchMedia)==null||(n=n.call(e,`(display-mode: ${t})`))==null?void 0:n.matches})??`browser`}}var St=()=>window.ManagedMediaSource||window.MediaSource,Ct=()=>{var e;return!!(window.ManagedMediaSource&&!((e=window.ManagedSourceBuffer)==null||(e=e.prototype)==null)&&e.appendBuffer)},wt=()=>{var e;return!!(window.MediaSource&&!((e=window.SourceBuffer)==null||(e=e.prototype)==null)&&e.appendBuffer)},Tt=()=>window.ManagedMediaSource?new ManagedMediaSource:new MediaSource,Et=bt().document?.createElement(`video`),Dt=`video/mp4; codecs="avc1.42000a,mp4a.40.2"`,Ot=`video/mp4; codecs="hev1.1.6.L93.B0"`,kt=`video/webm; codecs="vp09.00.10.08"`,At=`video/webm; codecs="av01.0.00M.08"`,jt=`audio/mp4; codecs="mp4a.40.2"`,Mt=`audio/webm; codecs="opus"`,Nt;(function(){var e=E(function*(){let e=bt();if(!xt(e)||!(`mediaCapabilities`in e.navigator))return;let t={type:`media-source`,video:{contentType:`video/webm`,width:1280,height:720,bitrate:1e6,framerate:30}},[n,r]=yield Promise.all([e.navigator.mediaCapabilities.decodingInfo(T(T({},t),{},{video:T(T({},t.video),{},{contentType:At})})),e.navigator.mediaCapabilities.decodingInfo(T(T({},t),{},{video:T(T({},t.video),{},{contentType:kt})}))]);Nt={DASH_WEBM_AV1:n,DASH_WEBM:r}});return function(){return e.apply(this,arguments)}})()().catch(e=>{console.log(Et),console.error(e)});class Pt{constructor(e,t){this._video=void 0,this._deviceChecker=void 0,this._browserChecker=void 0,this._protocols=void 0,this._containers=void 0,this._codecs=void 0,this._nativeHlsSupported=void 0,this._deviceChecker=e,this._browserChecker=t}get protocols(){return this._protocols}get containers(){return this._containers}get codecs(){return this._codecs}get webmDecodingInfo(){return Nt}get supportedCodecs(){return Object.keys(this._codecs).filter(e=>this._codecs[e])}get nativeHlsSupported(){return this._nativeHlsSupported}detect(){let e=bt();if(!xt(e))return;let t=e.document;this._video=t.createElement(`video`);try{var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_;this._protocols={mms:Ct(),mse:wt(),hls:!!((n=this._video).canPlayType?.call(n,`application/x-mpegurl`)||(r=this._video).canPlayType?.call(r,`vnd.apple.mpegURL`)),webrtc:!!e.RTCPeerConnection,ws:!!e.WebSocket},this._containers={mp4:!!(i=this._video).canPlayType?.call(i,`video/mp4`),webm:!!(a=this._video).canPlayType?.call(a,`video/webm`),cmaf:!0};let t=!!(!((o=St())==null||(s=o.isTypeSupported)==null)&&s.call(o,Dt)),v=!!(!((c=St())==null||(l=c.isTypeSupported)==null)&&l.call(c,Ot)),y=!!(!((u=St())==null||(d=u.isTypeSupported)==null)&&d.call(u,jt));this._codecs={h264:t,h265:v,vp9:!!(!((f=St())==null||(p=f.isTypeSupported)==null)&&p.call(f,kt)),av1:!!(!((m=St())==null||(h=m.isTypeSupported)==null)&&h.call(m,At)),aac:y,opus:!!(!((g=St())==null||(_=g.isTypeSupported)==null)&&_.call(g,Mt)),mpeg:(t||v)&&y},this._nativeHlsSupported=this._protocols.hls&&this._containers.mp4}catch(e){console.error(e)}try{this.destroyVideoElement()}catch(e){console.error(`Error destroying video element:`,e)}}destroyVideoElement(){if(!this._video)return;if(this._video.pause(),this._video.currentTime=0,this._video.removeAttribute(`src`),this._video.src=``,this._video.load(),this._video.remove){this._video.remove(),this._video=null;return}this._video.parentNode&&this._video.parentNode.removeChild(this._video);let e=this._video.cloneNode(!1);this._video.parentNode?.replaceChild(e,this._video),this._video=null}}var Lt=`audio/mpeg`;class Rt{constructor(){this._audio=void 0,this._containers=void 0,this._codecs=void 0}supportMp3(){return this._codecs.mp3&&this._containers.mpeg}detect(){let e=Ft();if(!It(e))return;let t=e.document;this._audio=t.createElement(`audio`);try{var n,r,i;this._containers={mpeg:!!(n=this._audio).canPlayType?.call(n,Lt)},this._codecs={mp3:!!(!((r=St())==null||(i=r.isTypeSupported)==null)&&i.call(r,Lt))}}catch(e){console.error(e)}try{this.destroyAudioElement()}catch(e){console.error(`Error destroying audio element:`,e)}}destroyAudioElement(){if(!this._audio)return;if(this._audio.pause(),this._audio.currentTime=0,this._audio.removeAttribute(`src`),this._audio.src=``,this._audio.load(),this._audio.remove){this._audio.remove(),this._audio=null;return}this._audio.parentNode&&this._audio.parentNode.removeChild(this._audio);let e=this._audio.cloneNode(!1);this._audio.parentNode?.replaceChild(e,this._audio),this._audio=null}}class zt{constructor(){this.isInited$=new ot(!1),this._displayChecker=void 0,this._deviceChecker=void 0,this._browserChecker=void 0,this._videoChecker=void 0,this._audioChecker=void 0,this._displayChecker=new yt,this._deviceChecker=new mt(this._displayChecker),this._browserChecker=new ut,this._videoChecker=new Pt(this._deviceChecker,this._browserChecker),this._audioChecker=new Rt,this.detect()}get display(){return this._displayChecker}get device(){return this._deviceChecker}get browser(){return this._browserChecker}get video(){return this._videoChecker}get audio(){return this._audioChecker}detect(){var e=this;return E(function*(){at()&&(e._displayChecker.detect(),e._deviceChecker.detect(),e._browserChecker.detect(),e._videoChecker.detect(),e._audioChecker.detect(),e.isInited$.next(!0))})()}}var P=new zt,Bt=(e,t=!1)=>{let{containers:n,protocols:r,codecs:i,nativeHlsSupported:a}=P.video,{isMobile:o}=P.device,s=P.device.isMac&&P.browser.isSafari,c=t&&!o&&!s,l=(i.h264||i.h265)&&i.aac,u=r.mse||r.mms;return e.filter(e=>{switch(e){case`DASH_SEP`:return u&&n.mp4&&l;case`DASH_WEBM`:return u&&n.webm&&i.vp9&&i.opus;case`DASH_WEBM_AV1`:return u&&n.webm&&i.av1&&i.opus;case`DASH_STREAMS`:return u&&(n.mp4&&l||n.webm&&(i.vp9||i.av1)&&(i.opus||i.aac));case`DASH_LIVE`:return u&&n.mp4&&l;case`DASH_LIVE_CMAF`:return u&&n.mp4&&l&&n.cmaf;case`DASH_ONDEMAND`:return u&&n.mp4&&l;case`HLS`:case`HLS_ONDEMAND`:case`HLS_FMP4`:case`HLS_LIVE`:case`HLS_LIVE_CMAF`:return a&&!c;case`MPEG`:return n.mp4;case`DASH`:case`DASH_LIVE_WEBM`:return!1;case`WEB_RTC_LIVE`:return r.webrtc&&r.ws&&i.h264&&(n.mp4||n.webm);default:return it(e)}})},Vt=e=>{switch(e){case`MPEG`:case`DASH`:case`DASH_SEP`:case`DASH_ONDEMAND`:case`DASH_WEBM`:case`DASH_WEBM_AV1`:case`DASH_STREAMS`:case`HLS`:case`HLS_FMP4`:case`HLS_ONDEMAND`:return!1;case`DASH_LIVE`:case`DASH_LIVE_CMAF`:case`HLS_LIVE`:case`HLS_LIVE_CMAF`:case`DASH_LIVE_WEBM`:case`WEB_RTC_LIVE`:return!0;default:return it(e)}},Ht=(e,t=!1)=>Bt(Object.keys(e).filter(e=>!Vt(e)),t).length>0;class Ut{constructor(e){this.subscription=new Le,this.log=void 0,this.params=void 0,this.sessionId$=new Re(null),this.mediaSessionId$=new Re(null),this.contentId$=new Re(null),this.progressTicker=void 0,this.isMobile=pt(),this.mobileVolumeState={muted:!1,volume:0},this.media=null,this.lastRequestedVolume=null,this.syncMediaState=e=>{if(Fe(e))return;this.media=e,this.mediaSessionId$.next(e.mediaSessionId??null);let t=e.media?.contentId;t&&this.contentId$.next(t),this.syncPlaybackState(e);let n=e.media?.duration;Pe(n)&&this.params.output.duration$.next(Math.max(0,n));let r=e.currentTime;if(Pe(r)){this.params.desiredState.seekState.getState().state===`applying`&&this.params.output.seekedEvent$.next(),this.params.output.position$.next(r);let t=this.params.output.isLive$.getValue();e.playerState===`PLAYING`&&!t?this.progressTicker.start(r):this.progressTicker.pause()}},this.params=e,this.progressTicker=new rt(e),this.log=this.params.dependencies.logger.createComponentLog(`ChromecastPresentationApiProvider`),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(Vt(e.format)),this.subscribe()}subscribe(){let e=e=>{this.params.output.error$.next({category:je.WTF,id:`ChromecastPresentationApiProvider`,message:e?.message??`Unknown error`,thrown:e})};this.subscription.add(this.params.chromecastConnector.message$.pipe(Me(e=>!!e)).subscribe(e=>{this.handleMessage(e)},e)),this.subscription.add(this.sessionId$.pipe(Me(Pe),Ne(),Ae(0)).subscribe(()=>{this.loadMedia()},e));let t=this.contentId$.pipe(Ne(),Ie(Boolean));this.subscription.add(ke({seekState:this.params.desiredState.seekState.stateChangeEnded$,mediaLoaded:t}).pipe(Me(({mediaLoaded:e})=>e)).subscribe(()=>{let e=this.params.desiredState.seekState.getState();e.state===`requested`&&this.seek(e.position/1e3)},e));let n=ke({playbackState:this.params.desiredState.playbackState.stateChangeStarted$,mediaLoaded:t});this.subscription.add(n.pipe(Me(({mediaLoaded:e})=>e),Ae(0)).subscribe(()=>{this.syncPlayback()},e)),this.subscription.add(n.pipe(Me(({mediaLoaded:e,playbackState:{from:t,to:n}})=>!e&&t===`stopped`&&n===`playing`)).subscribe(()=>{this.loadMedia()},e)),this.subscription.add(ke({volumeState:this.params.desiredState.volume.stateChangeStarted$.pipe(Ae(30)),mediaLoaded:t}).pipe(Me(({mediaLoaded:e})=>e)).subscribe(({volumeState:e})=>{let{muted:t,volume:n}=e.to;this.setVolume(n,t)},e))}handleMessage(e){switch(e.type){case`new_session`:case`update_session`:{var t;this.sessionId$.next(e.message.sessionId);let n=(t=e.message)==null||(t=t.media)==null?void 0:t[0];this.syncMediaState(n);let r=e.message?.receiver.volume;this.syncVolumeState(r)}break;case`v2_message`:switch(e.message?.type){case`MEDIA_STATUS`:{var n;let t=(n=e.message)==null||(n=n.status)==null?void 0:n[0];this.syncMediaState(t);break}}break}}loadMedia(){let e=Xe(this.params),t=this.media?.currentTime,n=this.params.desiredState.seekState.getState(),r=t??(n.state===`none`?0:n.position/1e3),i=this.params.desiredState.playbackState.getState()===`playing`;this.params.chromecastConnector.sendV2Message({type:`LOAD`,requestId:0,media:e,autoplay:i,currentTime:r,customData:null,activeTrackIds:null}),this.params.output.willSeekEvent$.next()}stop(){this.params.chromecastConnector.stopMedia()}play(){let e=this.mediaSessionId$.getValue();Oe(e,`play on null mediaSessionId`),this.params.chromecastConnector.sendV2Message({type:`PLAY`,mediaSessionId:e,customData:null})}pause(){let e=this.mediaSessionId$.getValue();Oe(e,`pause on null mediaSessionId`),this.params.chromecastConnector.sendV2Message({type:`PAUSE`,mediaSessionId:e,customData:null})}seek(e){let t=this.mediaSessionId$.getValue();Oe(t,`seek on null mediaSessionId`),this.params.chromecastConnector.sendV2Message({type:`SEEK`,currentTime:e,mediaSessionId:t}),this.params.output.willSeekEvent$.next()}setVolume(e,t){let n=e,r=`[setVolume] volume: ${e}, muted: ${t}`;this.isMobile&&(n=this.mobileVolumeState.volume,r+=`, mobile next volume: ${n}`),this.log({message:r}),this.lastRequestedVolume={volume:n,muted:t},this.params.chromecastConnector.sendV2Message({type:`SET_VOLUME`,requestId:0,volume:{level:t?0:n,muted:t?!0:null}})}syncPlaybackState({playerState:e,idleReason:t}){let n=this.params.output.isBuffering$.getValue(),r=e===`BUFFERING`;switch(n!==r&&this.params.output.isBuffering$.next(r),e){case`PAUSED`:j(this.params.desiredState.playbackState,`paused`);break;case`PLAYING`:j(this.params.desiredState.playbackState,`playing`);break;case`IDLE`:t===`FINISHED`?(this.params.output.endedEvent$.next(),j(this.params.desiredState.playbackState,`stopped`),this.contentId$.next(null)):j(this.params.desiredState.playbackState,`ready`);break;case`BUFFERING`:break}}syncPlayback(){let e=this.params.desiredState.playbackState.getState();switch(this.log({message:`[syncPlayback] ${e}`}),e){case`ready`:break;case`playing`:this.play();break;case`paused`:this.pause();break;case`stopped`:this.stop();break}}syncVolumeState(e){if(Fe(e))return;let{level:t,muted:n}=e,r={muted:n??!1,volume:t??0};this.lastRequestedVolume&&=(n&&(r.volume=this.lastRequestedVolume.volume),this.lastRequestedVolume.muted&&!t&&!n&&(r.volume=this.lastRequestedVolume.volume,r.muted=!0),null);let i=`[syncVolumeState] volume: ${r.volume}, muted: ${r.muted}`;this.isMobile&&(this.mobileVolumeState.volume=r.volume,this.mobileVolumeState.muted=r.muted,r.volume=this.params.output.volume$.getValue().volume,i+=`, volume passed to state machine: ${r.volume}`),this.log({message:i}),this.params.output.volume$.next(r)}destroy(){this.progressTicker.destroy(),this.subscription.unsubscribe()}}var $t=e=>({castDevice:{friendlyName:e},remotePlayer:{},remotePlayerController:{},session:{}}),en=()=>String(Date.now())+String(Math.floor(Math.random()*1e5));class tn{constructor(e){this.params=void 0,this.clientId=void 0,this.capabilities=[`WEB`],this.presentationRequest$=new Xt(null),this.log=void 0,this.sessionId$=new Xt(null),this.broadcastChannel=new BroadcastChannel(`vk_player_chromecast_events`),this.subscription=new Jt,this.subscriptionEvents=new Jt,this.isDestroyed=!1,this.sequenceNumber=0,this.presentationAvailable$=new Xt(!1),this.presentationConnection$=new Xt(null),this.message$=new Xt(null),this.friendlyName$=new Xt(null),this.errorEvent$=new qt,this.clientId=this.getClientId(),this.params=e,this.log=e.logger.createComponentLog(`ChromecastPresentationApiConnector`),this.log({message:`constructor`}),this.safeReinitPresentation(),this.subscribe()}destroy(){this.log({message:`destroy`}),this.subscription.unsubscribe(),this.subscriptionEvents.unsubscribe(),this.broadcastChannel.close(),this.isDestroyed=!0}disconnect(e=!0){this.log({message:`disconnect`}),e&&this.stopMedia(),this.presentationRequest$.next(null);let t=this.presentationConnection$.getValue();t&&t.close(),this.presentationConnection$.next(null),this.friendlyName$.next(null),this.resetSequenceNumber(),this.resetSubscriptionEvents()}stopMedia(){this.log({message:`stopMedia`}),this.sendV2Message({type:`STOP`})}reinitPresentation(e=!0){let t=this.createCastUrl(),n=new PresentationRequest(t);this.presentationRequest$.next(n),this.log({message:`PresentationRequest created`}),n.getAvailability().then(e=>{let t=()=>{this.log({message:`PresentationRequest presentation availability: ${e.value}`}),this.presentationAvailable$.next(e.value)};this.subscriptionEvents.add(Zt(e,`change`).subscribe(()=>{t()})),t()}).catch(()=>{this.presentationAvailable$.next(!0)}),Qt().navigator.presentation.defaultRequest=n,e&&n.reconnect(`auto-join`).then(e=>{this.log({message:`PresentationRequest reconnect success`}),this.handleConnection(e)}).catch(()=>{this.log({message:`PresentationRequest reconnect failed`})})}safeReinitPresentation(e){try{this.reinitPresentation(e)}catch(e){this.errorEvent$.next({category:Gt.WTF,id:`ChromecastPresentationApiConnector`,message:e?.message??`reinitPresentation error`,thrown:e})}}connect(){var e=this;return E(function*(){e.log({message:`connect`});try{e.presentationRequest$.getValue()||(e.log({message:`reinitPresentation`}),e.reinitPresentation(!1));let t=e.presentationRequest$.getValue();Wt(t,`connect with null presentationRequest`);let n=yield t.start();e.handleConnection(n)}catch(t){switch(t?.name){case`AbortError`:case`NotAllowedError`:break;default:e.errorEvent$.next({category:Gt.WTF,id:`ChromecastPresentationApiConnector`,message:t?.message??`connect error`,thrown:t});break}}})()}subscribe(){this.subscription.add(Zt(this.broadcastChannel,`message`).subscribe(e=>{this.log({message:`broadcast connection data: ${e.data}`}),e.data===`connection`&&this.disconnect(!1)})),this.subscription.add(this.presentationAvailable$.subscribe(e=>{this.log({message:`presentationAvailable$: ${e}`})})),this.subscription.add(this.presentationConnection$.pipe(Yt(e=>{this.log({message:`presentationConnection$: ${!!e}`})}),Kt(e=>!!e)).subscribe(e=>{let t=Zt(e,`message`).subscribe(e=>{let t=JSON.parse(e.data);t.clientId===this.clientId&&(this.log({message:`[onmessage] ${e.data}`}),this.handleMessage(t),this.message$.next(t))}),n=Zt(e,`connect`).subscribe(()=>{this.send(`client_connect`)}),r=Zt(e,`close`).subscribe(e=>{switch(e.reason){case`error`:this.errorEvent$.next({category:Gt.WTF,id:`ChromecastPresentationApiConnector`,message:`Session error`,thrown:e});break;case`closed`:break}});this.subscriptionEvents.add(t),this.subscriptionEvents.add(n),this.subscriptionEvents.add(r)}))}send(e){switch(e){case`client_connect`:{let e={type:`client_connect`,message:this.clientId,sequenceNumber:-1,timeoutMillis:0,clientId:this.clientId};this.safeSend(JSON.stringify(e));break}}}sendV2Message(e){let t=this.sessionId$.getValue();if(t){let n={type:`v2_message`,sequenceNumber:this.getSequenceNumber(),timeoutMillis:0,clientId:this.clientId,message:T(T({},e),{},{sessionId:t})};this.safeSend(JSON.stringify(n))}}safeSend(e){try{this.log({message:`[send] ${e}`});let t=this.presentationConnection$.getValue();t?.state===`connected`&&t?.send(e)}catch(t){this.errorEvent$.next({category:Gt.WTF,id:`ChromecastPresentationApiConnector`,message:`PresentationConnection send error`,data:{message:e},thrown:t})}}handleMessage(e){switch(e.type){case`new_session`:case`update_session`:this.sessionId$.next(e.message.sessionId),this.friendlyName$.next(e.message.receiver.friendlyName||`Chromecast Device`);break;case`receiver_action`:e.message?.action===`stop`&&this.disconnect();break}}createCastUrl(){return`cast:${this.params.appId}?clientId=${this.clientId}&autoJoinPolicy=tab_and_origin_scoped&defaultActionPolicy=create_session&launchTimeout=60000&supportedAppTypes=${this.capabilities}&appParams=%7B%22launchCheckerParams%22%3A%7B%7D%7D`}getSequenceNumber(){let e=this.sequenceNumber;return this.sequenceNumber=(this.sequenceNumber+1)%(2**53-1),e}resetSequenceNumber(){this.sequenceNumber=0}getClientId(){let e=`__vk_player_chromecast_id`;return Qt()[e]=Qt()[e]||en()}resetSubscriptionEvents(){this.subscriptionEvents.unsubscribe(),this.subscriptionEvents=new Jt}handleConnection(e){this.log({message:`connection available`}),this.isDestroyed?(this.log({message:`connected on already destroyed component`}),e.close()):(this.broadcastChannel.postMessage(`connection`),this.presentationConnection$.next(e))}}class un{static isSupported(){return`chrome`in window&&`presentation`in navigator&&`BroadcastChannel`in window}constructor(e){this.subscription=new on,this.log=void 0,this.contentId=void 0,this.connection$=new nn(void 0),this.castState$=new nn(`NOT_AVAILABLE`),this.errorEvent$=new rn,this.chromecastConnector=void 0;let t=un.isSupported();this.log=e.dependencies.logger.createComponentLog(`ChromecastPresentationApiInitializer`),this.log({message:`[constructor] receiverApplicationId: ${e.receiverApplicationId}, isDisabled: ${e.isDisabled}, isSupported: ${t}`}),!(!t||e.isDisabled||!e.receiverApplicationId)&&(this.chromecastConnector=new tn({appId:e.receiverApplicationId,logger:e.dependencies.logger}),this.subscribe())}subscribe(){ln(this.chromecastConnector,`subscribe with null chromecastConnector`),this.subscription.add(this.chromecastConnector.errorEvent$.subscribe(this.errorEvent$));let e=sn({connection:this.chromecastConnector.presentationConnection$,available:this.chromecastConnector.presentationAvailable$,friendlyName:this.chromecastConnector.friendlyName$.pipe(cn())});this.subscription.add(e.pipe(an(({connection:e,friendlyName:t})=>!!(e&&t)),cn()).subscribe(e=>{let t=this.chromecastConnector?.friendlyName$.getValue()??``;this.connection$.next(e?$t(t):void 0)})).add(e.subscribe(({available:e,connection:t})=>{e?t?this.castState$.next(`CONNECTED`):this.castState$.next(`AVAILABLE`):this.castState$.next(`NOT_AVAILABLE`)}))}connect(){this.log({message:`connect`}),this.chromecastConnector?.connect()}disconnect(){this.log({message:`disconnect`}),this.chromecastConnector?.disconnect()}stopMedia(){var e=this;return E(function*(){e.log({message:`stopMedia`}),e.chromecastConnector?.stopMedia()})()}toggleConnection(){let e=!!this.chromecastConnector?.presentationConnection$.getValue();this.log({message:`toggleConnection: isConnected - ${e}`}),e?this.disconnect():this.connect()}setVolume(e){}setMuted(e){}destroy(){this.log({message:`destroy`}),this.chromecastConnector?.destroy(),this.subscription.unsubscribe()}}var vn=(e,t)=>e===t;class yn{constructor(e,t=vn){this.comparator=void 0,this.state=void 0,this.prevState=void 0,this.transition=void 0,this.transitionStarted$=new gn,this.transitionEnded$=new gn,this.transitionUpdated$=new gn,this.forceChanged$=new gn,this.stateChangeStarted$=_n(this.transitionStarted$,this.transitionUpdated$),this.stateChangeEnded$=_n(this.transitionEnded$,this.forceChanged$),this.comparator=t,this.state=e,this.prevState=void 0}setState(e){let t=this.transition,n=this.state;this.transition=void 0,this.prevState=n,this.state=e,t?this.comparator(t.to,e)?this.transitionEnded$.next(t):this.forceChanged$.next({from:t.from,to:e,canceledTransition:t}):this.forceChanged$.next({from:n,to:e,canceledTransition:t})}startTransitionTo(e){let t=this.transition,n=this.state;this.comparator(n,e)||hn(t)&&this.comparator(t.to,e)||(this.prevState=n,this.state=e,t?(this.transition={from:t.from,to:e,canceledTransition:t},this.transitionUpdated$.next(this.transition)):(this.transition={from:n,to:e},this.transitionStarted$.next(this.transition)))}getTransition(){return this.transition}getState(){return this.state}getPrevState(){return this.prevState}}var An=5,jn=5,Mn=500,Nn=7e3;class Pn{constructor(e){this.subscription=new On,this.loadMediaTimeoutSubscription=new On,this.videoState=new yn(`stopped`),this.params=void 0,this.log=void 0,this.syncPlayback=()=>{let e=this.videoState.getState(),t=this.videoState.getTransition(),n=this.params.desiredState.playbackState.getState(),r=this.params.desiredState.playbackState.getTransition(),i=this.params.desiredState.seekState.getState();if(this.log({message:`[syncPlayback] videoState: ${e}; videoTransition: ${JSON.stringify(t)}; desiredPlaybackState: ${n}; desiredPlaybackStateTransition: ${this.params.desiredState.playbackState.getTransition()}; seekState: ${JSON.stringify(i)};`}),n===`stopped`){e!==`stopped`&&(this.videoState.startTransitionTo(`stopped`),this.stop());return}if(!t){if(r?.to!==`paused`&&i.state===`requested`&&e!==`stopped`){this.seek(i.position/1e3);return}switch(n){case`ready`:switch(e){case`playing`:case`paused`:case`ready`:break;case`stopped`:this.videoState.startTransitionTo(`ready`),this.prepare();break;default:bn(e)}break;case`playing`:switch(e){case`playing`:break;case`paused`:this.videoState.startTransitionTo(`playing`),this.params.connection.remotePlayerController.playOrPause();break;case`ready`:this.videoState.startTransitionTo(`playing`),this.params.connection.remotePlayerController.playOrPause();break;case`stopped`:this.videoState.startTransitionTo(`ready`),this.prepare();break;default:bn(e)}break;case`paused`:switch(e){case`playing`:this.videoState.startTransitionTo(`paused`),this.params.connection.remotePlayerController.playOrPause();break;case`paused`:break;case`ready`:this.videoState.startTransitionTo(`paused`),this.videoState.setState(`paused`);break;case`stopped`:this.videoState.startTransitionTo(`ready`),this.prepare();break;default:bn(e)}break;default:bn(n)}}},this.params=e,this.log=this.params.dependencies.logger.createComponentLog(`ChromecastProvider`),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(Vt(e.format)),this.params.output.isAudioAvailable$.next(!0),this.handleRemoteVolumeChange({volume:this.params.connection.remotePlayer.volumeLevel,muted:this.params.connection.remotePlayer.isMuted});let t=this.params.connection.session.getMediaSession();t&&this.restoreSession(t),this.subscribe()}destroy(){this.log({message:`[destroy]`}),this.subscription.unsubscribe()}subscribe(){this.subscription.add(this.loadMediaTimeoutSubscription);let e=new On;this.subscription.add(e),this.subscription.add(Tn(this.videoState.stateChangeStarted$.pipe(wn(e=>`stateChangeStarted$ ${JSON.stringify(e)}`)),this.videoState.stateChangeEnded$.pipe(wn(e=>`stateChangeEnded$ ${JSON.stringify(e)}`))).subscribe(e=>this.log({message:`[videoState] ${e}`})));let t=(e,t)=>this.subscription.add(e.subscribe(t));if(this.params.output.isLive$.getValue())this.params.output.position$.next(0),this.params.output.duration$.next(0);else{let t=new Dn;e.add(t.pipe(xn(Mn)).subscribe(()=>{this.params.output.seekedEvent$.next()}));let n=NaN;e.add(Cn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED).subscribe(e=>{this.logRemoteEvent(e);let r=e.value;this.params.output.position$.next(r),(this.params.desiredState.seekState.getState().state===`applying`||Math.abs(r-n)>An)&&t.next(r),n=r})),e.add(Cn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.DURATION_CHANGED).subscribe(e=>{this.logRemoteEvent(e),this.params.output.duration$.next(e.value)}))}t(Cn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED),t=>{this.logRemoteEvent(t),t.value?this.handleRemoteReady():(this.handleRemoteStop(),e.unsubscribe())}),t(Cn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),e=>{this.logRemoteEvent(e),e.value?this.handleRemotePause():this.handleRemotePlay()}),t(Cn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED),e=>{this.logRemoteEvent(e);let{remotePlayer:t}=this.params.connection,n=e.value,r=this.params.output.isBuffering$.getValue(),i=n===chrome.cast.media.PlayerState.BUFFERING;switch(r!==i&&this.params.output.isBuffering$.next(i),n){case chrome.cast.media.PlayerState.IDLE:!this.params.output.isLive$.getValue()&&t.duration-t.currentTime<jn&&this.params.output.endedEvent$.next(),this.handleRemoteStop(),j(this.params.desiredState.playbackState,`stopped`);break;case chrome.cast.media.PlayerState.PAUSED:this.handleRemotePause();break;case chrome.cast.media.PlayerState.PLAYING:this.handleRemotePlay();break;case chrome.cast.media.PlayerState.BUFFERING:break;default:bn(n)}}),t(Cn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED),e=>{this.logRemoteEvent(e),this.handleRemoteVolumeChange({volume:e.value})}),t(Cn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),e=>{this.logRemoteEvent(e),this.handleRemoteVolumeChange({muted:e.value})}),t(Tn(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,En([`init`])).pipe(xn(0)),this.syncPlayback)}restoreSession(e){this.log({message:`restoreSession`});let{remotePlayer:t}=this.params.connection;if(e.playerState!==chrome.cast.media.PlayerState.IDLE){t.isPaused?(this.videoState.setState(`paused`),j(this.params.desiredState.playbackState,`paused`)):(this.videoState.setState(`playing`),j(this.params.desiredState.playbackState,`playing`));let e=this.params.output.isLive$.getValue();this.params.output.duration$.next(e?0:t.duration),this.params.output.position$.next(e?0:t.currentTime),this.params.desiredState.seekState.setState({state:`none`})}}prepare(){let e=this.params.format;this.log({message:`[prepare] format: ${e}`});let t=Xe(this.params),n=this.createLoadRequest(t);this.loadMedia(n)}handleRemotePause(){let e=this.videoState.getState();(this.videoState.getTransition()?.to===`paused`||e===`playing`)&&(this.videoState.setState(`paused`),j(this.params.desiredState.playbackState,`paused`))}handleRemotePlay(){let e=this.videoState.getState();(this.videoState.getTransition()?.to===`playing`||e===`paused`)&&(this.videoState.setState(`playing`),j(this.params.desiredState.playbackState,`playing`))}handleRemoteReady(){this.videoState.getTransition()?.to===`ready`&&this.videoState.setState(`ready`),this.params.desiredState.playbackState.getTransition()?.to===`ready`&&j(this.params.desiredState.playbackState,`ready`)}handleRemoteStop(){this.videoState.getState()!==`stopped`&&this.videoState.setState(`stopped`)}handleRemoteVolumeChange(e){let t=this.params.output.volume$.getValue(),n={volume:e.volume??t.volume,muted:e.muted??t.muted};(n.volume!==t.volume||n.muted!==n.muted)&&this.params.output.volume$.next(n)}seek(e){this.params.output.willSeekEvent$.next();let{remotePlayer:t,remotePlayerController:n}=this.params.connection;t.currentTime=e,n.seek()}stop(){let{remotePlayerController:e}=this.params.connection;e.stop()}createLoadRequest(e){let t=new chrome.cast.media.LoadRequest(e);t.autoplay=!1;let n=this.params.desiredState.seekState.getState();return n.state===`applying`||n.state===`requested`?t.currentTime=this.params.output.isLive$.getValue()?0:n.position/1e3:t.currentTime=0,t}loadMedia(e){let t=this.params.connection.session.loadMedia(e),n=new Promise((e,t)=>{this.loadMediaTimeoutSubscription.add(kn(Nn).subscribe(()=>t(`timeout(${Nn})`)))});mn(Promise.race([t,n]).then(()=>{this.log({message:`[loadMedia] completed, format: ${this.params.format}`}),this.params.desiredState.seekState.getState().state===`applying`&&this.params.output.seekedEvent$.next(),this.handleRemoteReady()},e=>{let t=`[prepare] loadMedia failed, format: ${this.params.format}, reason: ${e}`;this.log({message:t}),this.params.output.error$.next({id:`ChromecastProvider.loadMedia`,category:Sn.VIDEO_PIPELINE,message:t,thrown:e})}),()=>{this.loadMediaTimeoutSubscription.unsubscribe()})}logRemoteEvent(e){this.log({message:`[remoteEvent] ${JSON.stringify(e)}`})}}var Vn=e=>{try{e.pause(),e.playbackRate=0,Bn(e),e.remove()}catch(e){console.error(e)}},Hn=`__spvc`;class Un{constructor(){this.attribute=`data-pool-reused`}get(e){return e.hasAttribute(this.attribute)}set(e,t){e.toggleAttribute(this.attribute,t)}delete(e){e.removeAttribute(this.attribute)}}var Wn=Rn(),Gn=Wn.WeakMap?new Wn.WeakMap:new Un,Kn=Wn.WeakMap?new Wn.WeakMap:new Map,qn=(e,t=20)=>{let n=0;return Ln(e,`ratechange`).subscribe(r=>{n++,n>=t&&(e.currentTime=e.currentTime,n=0)})};function Jn(e){e.style.position=`fixed`,e.style.left=`100%`,e.setAttribute(`data-role`,`screen`),Rn().document.body.appendChild(e)}function Yn(e,t){e.style.position=``,e.style.left=``,t.appendChild(e)}var Xn=(e,{audioVideoSyncRate:t,disableYandexPiP:n,reuseOwnVideoElement:r,reuseOwnVideoElementOnBackgroundTabOnly:i})=>{let a,o=e.querySelector(`video`),s=!!o,c=Rn().document.querySelector(`body > video[data-role=screen]`)||void 0;r&&!i?Wn[Hn]=c:(c?.remove(),delete Wn[Hn]),o?(a=o,In(a)):c&&c===Wn[Hn]?(a=c,Yn(a,e)):(a=Rn().document.createElement(`video`),e.appendChild(a),r&&!i&&(Wn[Hn]=a)),Gn.set(a,s);let l=new zn;return l.add(qn(a,t)),Kn.set(a,l),a.setAttribute(`crossorigin`,`anonymous`),a.setAttribute(`playsinline`,`playsinline`),n&&a.setAttribute(`x-yandex-pip`,`false`),a.controls=!1,a.setAttribute(`poster`,`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=`),a},Zn=e=>(e.setAttribute(`crossorigin`,`anonymous`),e.controls=!1,e),Qn=(e,t)=>{if(e instanceof HTMLAudioElement){$n(e,t);return}if(e instanceof HTMLVideoElement){er(e,t);return}};function $n(e,{clearAudioElementOnDispose:t}){if(t){In(e);return}Vn(e)}function er(e,{reuseOwnVideoElement:t,reuseOwnVideoElementOnBackgroundTabOnly:n}){Kn.get(e)?.unsubscribe(),Kn.delete(e);let r=Gn.get(e);Gn.delete(e),In(e),t&&!n&&!r&&Jn(e)}var ur=(e,t,n,{equal:r=(e,t)=>e===t,changed$:i,onError:a}={})=>{let o=e.getState(),s=t(),c=cr(i),l=new lr;return i&&l.add(i.subscribe(t=>{r(t,e.getState())&&e.setState(t)},a)),r(s,o)||(n(o),c&&e.setState(o)),l.add(e.stateChangeStarted$.subscribe(t=>{n(t.to),c&&e.setState(t.to)},a)),l},dr=(e,t,n)=>ur(t,()=>e.loop,t=>{sr(t)&&(e.loop=t)},{onError:n}),fr=(e,t,n,r,i)=>ur(t,()=>({muted:e.muted,volume:e.volume}),t=>{i?.skipVideoElVolumeSync$.getValue()||sr(t)&&(e.muted=t.muted,e.volume=t.volume)},{equal:(e,t)=>e===t||e?.muted===t?.muted&&e?.volume===t?.volume,changed$:n,onError:r}),pr=(e,t,n,r)=>ur(t,()=>e.playbackRate,t=>{sr(t)&&(e.playbackRate=t)},{changed$:n,onError:r}),mr=ur;class hr{constructor(){this.available$=new ir,this.error$=new ir,this.subscription=new ar,this.externalTracks=new Map,this.internalTracks=new Map,this.emittedIds=void 0}connect(e,t){let n=e=>{this.error$.next({id:`TextTracksManager`,category:or.WTF,message:`Generic TextTrackManager error`,thrown:e})};this.subscription.add(this.available$.subscribe(t.availableTextTracks$)),this.subscription.add(this.error$.subscribe(t.error$)),this.emitAvailable(),this.subscription.add(mr(e.internalTextTracks,()=>Array.from(this.internalTracks.values()),e=>{nr(e)&&this.setInternal(e)},{equal:(e,t)=>nr(e)&&nr(t)&&e.length===t.length&&e.every(({id:e},n)=>e===t[n].id),changed$:this.available$.pipe(rr(e=>e.filter(({type:e})=>e===`internal`))),onError:n})),this.subscription.add(mr(e.externalTextTracks,()=>Array.from(this.externalTracks.values()),e=>{nr(e)&&this.setExternal(e)},{equal:(e,t)=>nr(e)&&nr(t)&&e.length===t.length&&e.every(({id:e},n)=>e===t[n].id),changed$:this.available$.pipe(rr(e=>e.filter(({type:e})=>e===`external`))),onError:n}))}setExternal(e){this.internalTracks.clear();for(let t of Array.from(this.externalTracks.keys()))e.some(e=>e.id===t)||this.externalTracks.delete(t);for(let t of e)this.externalTracks.has(t.id)||this.externalTracks.set(t.id,t);this.emitAvailable()}setInternal(e){let t=Array.from(this.externalTracks.values());for(let t of Array.from(this.internalTracks.keys()))e.some(e=>e.id===t)||this.internalTracks.delete(t);for(let n of e){let e=t.some(({language:e,isAuto:t})=>e===n.language&&t===n.isAuto);!this.internalTracks.has(n.id)&&!e&&this.internalTracks.set(n.id,n)}this.emitAvailable()}destroy(){this.subscription.unsubscribe(),this.externalTracks.clear(),this.internalTracks.clear()}emitAvailable(){let e=[...this.externalTracks.values(),...this.internalTracks.values()],t=e.map(({id:e})=>e),{emittedIds:n}=this;n&&n.length===t.length&&n.every((e,n)=>e===t[n])||(this.emittedIds=t,this.available$.next(e.map(e=>T(T({},e),{},{isAuto:e.isAuto??tr(e.id,`auto`)}))))}}var gr=hr;class _r{constructor(){this.pausedTime=0,this.streamOffset=0,this.pauseTimestamp=0}getTotalPausedTime(){return this.pausedTime+this.getCurrentPausedTime()}getCurrentPausedTime(){return this.pauseTimestamp>0?Date.now()-this.pauseTimestamp:0}getStreamOffset(){return this.streamOffset}getTotalOffset(){return this.getTotalPausedTime()+this.streamOffset}pause(){this.pauseTimestamp===0&&(this.pauseTimestamp=Date.now())}resume(){this.pauseTimestamp>0&&(this.pausedTime+=this.getCurrentPausedTime(),this.pauseTimestamp=0)}resetTo(e,t=!1){this.streamOffset=e,this.pauseTimestamp=0,this.pausedTime=0,t&&this.pause()}}var vr=e=>{let t=e;for(;!(t instanceof Document)&&!(t instanceof ShadowRoot)&&t!==null;)t=t?.parentNode;return t??void 0},yr=e=>{let t=vr(e);return!!(t&&t.fullscreenElement&&t.fullscreenElement===e)},br=e=>{let t=vr(e);return!!(t&&t.pictureInPictureElement&&t.pictureInPictureElement===e)};var Fr=3,Ir=(e,t,n=Fr)=>{let r=0,i=0;for(let a=0;a<e.length;a++){let o=e.start(a),s=e.end(a);if(o<=t&&t<=s){if(r=o,i=s,!n)return{from:r,to:i};for(let t=a-1;t>=0;t--)e.end(t)+n>=r&&(r=e.start(t));for(let t=a+1;t<e.length;t++)e.start(t)-n<=i&&(i=e.end(t))}}return{from:r,to:i}},Lr=e=>{let t=0;for(let n=0;n<e.length;n++)t+=e.end(n)-e.start(n);return t},Rr=e=>{let t=0;for(let n=0;n<e.length;n++)t+=e.end(n)-e.start(n);return t*1e3},zr=e=>{let t=t=>F(e,t).pipe(Dr(void 0),I(1)),n=new Pr,r=()=>n.unsubscribe(),i=Sr(F(e,`progress`),F(e,`timeupdate`)),a=i.pipe(xr(()=>Ir(e.buffered,e.currentTime)),I(1)),o=i.pipe(xr(()=>Rr(e.buffered)),I(1)),s=i.pipe(xr(()=>e.buffered.length),I(1)),c=P.browser.isSafari?Or({play:t(`play`).pipe(kr()),playing:t(`playing`)}).pipe(Dr(void 0),I(1)):t(`playing`),l=F(e,`volumechange`).pipe(xr(()=>({muted:e.muted,volume:e.volume})),I(1)),u=F(e,`ratechange`).pipe(xr(()=>e.playbackRate),I(1)),d=F(e,`error`).pipe(Er(()=>!!(e.error||e.played.length)),xr(()=>{let t=e.error;return{id:t?`MediaError#${t.code}`:`HtmlVideoError`,category:jr.VIDEO_PIPELINE,message:t?t.message:`Error event from HTML video element`,thrown:e.error??void 0,origin:Mr.MediaError,data:t?{code:t.code}:void 0}}),I(1)),f=F(e,`timeupdate`).pipe(xr(()=>e.currentTime),I(1)),p=Sr(F(e,`loadedmetadata`),F(e,`timeupdate`),F(e,`pause`),F(e,`seeked`),F(e,`ended`)).pipe(xr(()=>Lr(e.played)),Cr(),I(1)),m=[`waiting`,`seeking`,`seeked`,`timeupdate`],h=new Tr,g=.3,_;n.add(Sr(...m.map(t=>F(e,t))).subscribe(t=>{let n=e.currentTime;e.loop&&wr(_)&&wr(n)&&_>=e.duration-g&&n<=g&&h.next(_),_=n}));let v=t(`pause`).pipe(Er(()=>!e.error&&_!==e.duration),I(1)),y=F(e,`enterpictureinpicture`).pipe(I(1)),b=F(e,`leavepictureinpicture`).pipe(I(1)),x=new Nr(br(e));n.add(y.subscribe(()=>x.next(!0))),n.add(b.subscribe(()=>x.next(!1)));let S=new Nr(yr(e)),C=F(e,`fullscreenchange`).pipe(I(1));n.add(C.pipe(xr(()=>yr(e))).subscribe(S));let ee=F(e,`timeupdate`).pipe(xr(t=>e.duration-e.currentTime<.1),Cr(),I(1)),w=Sr(ee.pipe(Er(t=>!e.loop&&t)),F(e,`ended`)).pipe(Ar(1e3),Dr(void 0),I(1)),T=Sr(...[`waiting`,`pause`,`canplay`,`play`,`canplaythrough`,`playing`,`seeking`,`seeked`,`ended`].map(t=>F(e,t)),ee.pipe(xr(e=>({type:e?`ended`:`unknown`})))).pipe(xr(t=>P.browser.isFirefox&&t.type===`ended`?e.readyState<2:e.readyState<3),Cr(),I(1));return{playing$:c,pause$:v,canplay$:t(`canplay`),ended$:w,looped$:h,error$:d,seeked$:t(`seeked`),seeking$:t(`seeking`),progress$:t(`progress`),loadStart$:t(`loadstart`),loadedMetadata$:t(`loadedmetadata`),loadedData$:t(`loadeddata`),timeUpdate$:f,durationChange$:F(e,`durationchange`).pipe(xr(()=>e.duration),I(1)),playedTime$:p,isBuffering$:T,currentBuffer$:a,totalBufferDuration$:o,bufferRangeCount$:s,volumeState$:l,playbackRateState$:u,inPiP$:x,inFullscreen$:S,enterPip$:y,leavePip$:b,destroy:r}};var Vr=e=>{switch(e){case`mobile`:return Br.Q_144P;case`lowest`:return Br.Q_240P;case`low`:return Br.Q_360P;case`sd`:case`medium`:return Br.Q_480P;case`hd`:case`high`:return Br.Q_720P;case`fullhd`:case`full`:return Br.Q_1080P;case`quadhd`:case`quad`:return Br.Q_1440P;case`ultrahd`:case`ultra`:return Br.Q_2160P}};var Jr=e=>`audioTracksAsc`in e;class Xr{constructor(){this.last=void 0,this.history={}}recordSelection(e){this.history[e.id]=Yr()}recordSwitch(e){this.last=e}clear(){this.last=void 0,this.history={}}}var si=(e,t)=>(e??0)/(t>0?t:1),ci=e=>`quality`in e,li=e=>(t,n)=>e*(Number(t.bitrate)-Number(n.bitrate)),ui=e=>(t,n)=>e*(ii(t.quality,n.quality)?-1:1),di=e=>(t,n)=>ci(t)&&ci(n)?ui(e)(t,n):li(e)(t,n),fi=(e,t)=>di(1)(e,t)<0,pi=(e,t)=>Math.log(t)/Math.log(e),mi=(e,t,n)=>(t-n)*2**(-10*e)+n,hi=(e,t,n,r)=>{if(oi(e))return n[0];let i=n.filter(t=>ai(t.bitrate)&&ai(e.bitrate)?e.bitrate/t.bitrate>r:!0),a=ni(n,Math.round(n.length*t.indexOf(e)/(t.length+1)))??ni(n,-1);return a&&ri(i,a)?a:i.length?ni(i,-1):ni(n,0)},gi=(e,t)=>{if(oi(t)||oi(e))return;let n=e.get(t.id);if(!n?.length)return;let r=(n[n.length-1].time.to-n[0].time.from)/1e3;if(r<=0)return;let i=n.reduce((e,t)=>e+(t.size??1/0),0)*8/1024/r;return isFinite(i)?i:void 0},_i=(e,t)=>ai(e)&&ai(t)&&t>0&&e>0&&e<=t*2,vi=e=>{let{name:t}=e;return`
7
7
  ${t}
8
8
  ${Kr(D(e,b)).map(([e,t])=>` ${e}: ${t}`).join(`
9
9
  `)}
@@ -37,4 +37,4 @@ ${Kr(D(e,b)).map(([e,t])=>` ${e}: ${t}`).join(`
37
37
  `,e.map(({time:e,data:t,stack:n})=>`${e}: ${JSON.stringify(t)}${n?`
38
38
  `+n:``}`).join(`
39
39
  `),`
40
- ===== DASH_LIVE DEBUG END ====`),n){let t=e.reduce((e,{time:t,data:n,stack:r})=>{let i=fn(n).map(([e,t])=>`${e}:${t}`).join(`,`);return e+=`${t}: ${i}${r?`: ${r}`:``};`,e},``);dv.push(`core`,{key:`vp_dash_live_debug`,strings:[t]})}};return e.add(this.providerError$.subscribe(e=>{e.id.startsWith(`ProviderHangup`)&&(R({m:`final.0`,e:e.id}),t())})).add(this.noAvailableProvidersError$.subscribe(()=>{R({m:`final.1`}),t()})),e.add(this.mayday.recommendation$.subscribe(({error:e,recommendation:t})=>{let n=this.current$.getValue().destination??`SCREEN`;if(this.handleMaydayRecommendation(t,n),t.action!==`wait`){let t={error:e,currentDestination:n};e.traceAsLog?this.tracer.log(`providerInfo`,uv(t)):this.tracer.error(`providerError`,uv(t))}})),e.add(this.providerError$.subscribe(e=>{let t=this.current$.getValue(),{destination:n}=t;n===`CHROMECAST`?(this.destroyProvider(),this.params.dependencies.chromecastInitializer.stopMedia().then(()=>this.switchToNextProvider(`CHROMECAST`),()=>this.params.dependencies.chromecastInitializer.disconnect())):(this.applyErrorSideEffects(e,t.type),this.mayday.handleError(e))})),e}}var Ny=`vk_uvp_throughput`,Py=`vk_uvp_rtt`,Fy=`one_video_throughput`,Iy=`one_video_rtt`,Ly=()=>{let{navigator:e}=My();if(e)return e.connection},Ry=()=>{let e=Ly()?.downlink;if(ky(e)&&e!==10)return e*1e3},zy=()=>{let e=Ly()?.rtt;if(ky(e)&&e!==3e3)return e},By=(e,t,n)=>{let r=n*8;return r/(r/e+t)};class Vy{constructor(e,t=new Ey(void 0),n){this.throughput=void 0,this.rtt=void 0,this.subscription=new Ty,this.wiring=new Ty,this.throughputVarianceProxy$=new Ey(0),this.currentHost=void 0,this.hasThroughputSamples=!1,this.hasRttSamples=!1,this.storageReadDone=!1,this.tuningConfig=void 0,this.logger=void 0,this.initialThroughputSource=void 0,this.initialRttSource=void 0,this.concurrentDownloads=new Map,this.throughput$=void 0,this.rtt$=void 0,this.rttAdjustedThroughput$=void 0,this.tuningConfig=e,this.logger=n;let r=Vy.resolveInitialThroughput(e),i=Vy.resolveInitialRtt(e);if(n?.({message:`initial state: throughput ${r.value} Kbps (${r.source}), RTT ${i.value} ms (${i.source})`}),this.throughput$=new Ey(r.value),this.rtt$=new Ey(i.value),this.initialThroughputSource=r.source,this.initialRttSource=i.source,this.rttAdjustedThroughput$=new Ey(By(r.value,i.value,e.rttPenaltyRequestSize)),this.throughput=Hp.getSmoothedValue(r.value,-1,e),this.rtt=Hp.getSmoothedValue(i.value,1,e),e.useBrowserEstimation){let e=()=>{if(!this.hasThroughputSamples){let e=Ry();e&&(this.throughput.next(e),this.initialThroughputSource=`browser estimation (downlink)`)}if(!this.hasRttSamples){let e=zy();ky(e)&&(this.rtt.next(e),this.initialRttSource=`browser estimation (rtt)`)}},t=Ly();t&&`onchange`in t&&this.subscription.add(Sy(t,`change`).subscribe(e)),e()}e.cdnCache.enabled&&this.subscription.add(t.subscribe(e=>{ky(e)&&e!==this.currentHost&&(this.currentHost=e,this.tryAdopt())})),this.wireSmoothed()}static readLegacyNumber(e){let t=jy.get(e);if(Ay(t))return;let n=parseInt(t,10);return isNaN(n)?void 0:n}static resolveInitialThroughput(e){let t=e.useBrowserEstimation?Ry():void 0;if(!e.cdnCache.enabled){let e=Vy.readLegacyNumber(Fy);if(e)return{value:e,source:`legacy key one_video_throughput`}}return t?{value:t,source:`browser estimation (downlink)`}:{value:e.initialThroughput,source:`initialThroughput default`}}static resolveInitialRtt(e){let t=e.useBrowserEstimation?zy():void 0;if(!e.cdnCache.enabled){let e=Vy.readLegacyNumber(Iy);if(e!==void 0)return{value:e,source:`legacy key one_video_rtt`}}return t===void 0?{value:0,source:`no data`}:{value:t,source:`browser estimation (rtt)`}}tryAdopt(){if(this.storageReadDone)return;if(this.storageReadDone=!0,this.hasThroughputSamples){this.logger?.call(this,{message:`cache read skipped: throughput samples already flowing — live measurements win`});return}if(Ay(this.currentHost)){this.logger?.call(this,{message:`cache read skipped: delivery host not yet known`});return}let e=Vy.readHostRecord(Ny,this.currentHost,this.tuningConfig),t=Vy.readHostRecord(Py,this.currentHost,this.tuningConfig);if(e.value===void 0&&t.value===void 0){this.logger?.call(this,{message:`host ${this.currentHost}: no valid record (${e.missReason}) — cold start with throughput ${Math.round(this.throughput.smoothed$.getValue())} Kbps, RTT ${Math.round(this.rtt.smoothed$.getValue())} ms`});return}let n=[],r=[];e.value===void 0?r.push(`throughput ${Math.round(this.throughput.smoothed$.getValue())} Kbps (${this.initialThroughputSource})`):n.push(`throughput ${e.value} Kbps`),t.value===void 0?r.push(`RTT ${Math.round(this.rtt.smoothed$.getValue())} ms (${this.initialRttSource})`):n.push(`RTT ${t.value} ms`);let i=`warm start from cache record (${n.join(`, `)})`;this.logger?.call(this,{message:`host ${this.currentHost}: ${r.length?`${i}, ${r.join(`, `)}`:i}`}),this.recreateSmoothed(e.value??this.throughput.smoothed$.getValue(),t.value??this.rtt.smoothed$.getValue())}recreateSmoothed(e,t){this.throughput=Hp.getSmoothedValue(e,-1,this.tuningConfig),this.rtt=Hp.getSmoothedValue(t,1,this.tuningConfig),this.wireSmoothed(),this.rttAdjustedThroughput$.next(By(e,t,this.tuningConfig.rttPenaltyRequestSize))}wireSmoothed(){this.wiring.unsubscribe();let e=new Ty;this.subscription.add(e),this.wiring=e,e.add(this.throughput.smoothed$.subscribe(e=>{this.writeStored(Ny,Fy,e)})),e.add(this.rtt.smoothed$.subscribe(e=>{this.writeStored(Py,Iy,e)})),e.add(this.throughput.debounced$.pipe(Dy(e=>Math.round(e))).subscribe(this.throughput$)),e.add(this.rtt.debounced$.subscribe(this.rtt$)),e.add(wy({throughput:this.throughput.smoothed$,rtt:this.rtt.smoothed$}).pipe(Dy(({throughput:e,rtt:t})=>By(e,t,this.tuningConfig.rttPenaltyRequestSize)),Oy(e=>{let t=this.rttAdjustedThroughput$.getValue()||0;return Math.abs(e-t)/t>=this.tuningConfig.changeThreshold})).subscribe(this.rttAdjustedThroughput$)),e.add(this.throughput.varianceCoefficient$.subscribe(this.throughputVarianceProxy$))}destroy(){this.concurrentDownloads.clear(),this.subscription.unsubscribe()}trackXHR(e){let t=0,n=J(),r=new Ty;switch(this.subscription.add(r),this.concurrentDownloads.set(e,J()),e.readyState){case 4:break;case 3:case 2:r.add(Sy(e,`progress`).pipe(Cy()).subscribe(e=>{t=e.loaded,n=J()}));break;case 1:case 0:r.add(Sy(e,`loadstart`).subscribe(()=>{t=0,n=J()}));break}r.add(Sy(e,`loadend`).subscribe(i=>{if(e.status===200){let e=i.loaded,r=J(),a=e-t,o=r-n;this.addRawSpeed(a,o,1)}this.concurrentDownloads.delete(e),r.unsubscribe()}))}trackStream(e,t=!1){var n=this;let r=e.getReader();if(!r){e.cancel(`Could not get reader`);return}let i=0,a=J(),o=0,s=J(),c=t=>{this.concurrentDownloads.delete(e),r.releaseLock(),e.cancel(`Throughput Estimator error: ${t}`).catch(()=>{})},l=function(){var u=E(function*({done:u,value:d}){if(u){if(!t){let e=n.tuningConfig.measureFastSamples?n.countActiveDownloads(a):1;n.addRawSpeed(i,J()-a,e)}n.concurrentDownloads.delete(e)}else if(d){if(n.tuningConfig.measureFastSamples&&n.concurrentDownloads.set(e,J()),t){let e=J();if(e-s>n.tuningConfig.lowLatency.continuesByteSequenceInterval||e-a>n.tuningConfig.lowLatency.maxLastEvaluationTimeout){let e=s-a;e&&n.addRawSpeed(o,e,1,t),o=d.byteLength,a=J()}else o+=d.byteLength;s=J()}else if(i+=d.byteLength,o+=d.byteLength,o>=n.tuningConfig.streamMinSampleSize&&J()-s>=n.tuningConfig.streamMinSampleTime){let e=n.tuningConfig.measureFastSamples?n.countActiveDownloads(s):n.concurrentDownloads.size;n.addRawSpeed(o,J()-s,e),o=0,s=J()}yield r?.read().then(l,c)}});return function(e){return u.apply(this,arguments)}}();this.concurrentDownloads.set(e,J()),r?.read().then(l,c)}addRawSpeed(e,t,n=1,r=!1){if(this.sanityCheck(e,t,r)){let i=e*8/t*n;if(this.isFastSample(t,r)&&i<this.throughput.smoothed$.getValue())return;this.markSample(),this.throughput.next(i)}}countActiveDownloads(e){let t=0;return this.concurrentDownloads.forEach(n=>{n>=e&&t++}),Math.max(t,1)}isFastSample(e,t){return this.tuningConfig.measureFastSamples&&!t&&e<=this.tuningConfig.cacheThresholdSize}addRawThroughput(e){this.markSample(),this.throughput.next(e)}addRawRtt(e){this.hasRttSamples=!0,this.rtt.next(e)}markSample(){this.hasThroughputSamples=!0,this.tryAdopt()}sanityCheck(e,t,n=!1){let r=e*8/t;return!(!r||!isFinite(r)||r>this.tuningConfig.maxSampleRate||r<30||n&&e<1e4||!n&&e<10*1024&&(!this.tuningConfig.measureNonSegmentRequests||t<this.tuningConfig.smallSampleMinDuration+this.rtt$.getValue())||!n&&!this.tuningConfig.measureFastSamples&&t<=this.tuningConfig.cacheThresholdSize)}get throughputVariance$(){return this.throughputVarianceProxy$}static readHostRecord(e,t,n){let r=jy.get(e);if(Ay(r))return{missReason:`key ${e} missing`};try{let i=JSON.parse(r);if(Ay(i)||typeof i!=`object`)return{missReason:`key ${e} is not a JSON object`};let a=i.hosts?.[t];return!a||typeof a.value!=`number`||typeof a.timestamp!=`number`?{missReason:`no record for host ${t} in ${e}`}:Vy.validateStored(a,n)}catch{return{missReason:`key ${e} contains corrupt JSON`}}}writeStored(e,t,n){if(!this.tuningConfig.cdnCache.enabled){jy.set(t,n.toFixed(0));return}let r=e===Ny?this.hasThroughputSamples:this.hasRttSamples;if(!this.storageReadDone||!r||Ay(this.currentHost))return;let i={},a=jy.get(e);if(ky(a))try{let e=JSON.parse(a);ky(e)&&typeof e==`object`&&(i=xy(by(e.hosts??{}).filter(([,e])=>ky(e)&&typeof e==`object`&&typeof e.value==`number`&&typeof e.timestamp==`number`)))}catch{}i[this.currentHost]={value:Math.round(n),timestamp:Date.now(),networkType:Ly()?.effectiveType};let o=by(i).filter(([e])=>e!==this.currentHost).sort(([,e],[,t])=>t.timestamp-e.timestamp),s=Math.max(1,this.tuningConfig.cdnCache.hostsLimit);for(;o.length+1>s;){let[e]=o.pop();delete i[e]}jy.set(e,JSON.stringify({hosts:i}))}static validateStored(e,t){if(!t.cdnCache.enabled)return{value:e.value};let n=Date.now()-e.timestamp;if(n>t.cdnCache.ttlMs)return{missReason:`record older than TTL (${Math.round(n/6e4)} min)`};let r=Ly()?.effectiveType;return ky(r)&&ky(e.networkType)&&r!==e.networkType?{missReason:`record written with networkType=${e.networkType}, current ${r}`}:{value:e.value}}}var Hy=Vy;var Gy={mayday:{playingUnstableThresholdMs:3e3,heuristics:[],hangupGraceDecayFactor:.5,hangupGraceMinTimeoutMs:0,deferAudibleHangupOnHiddenTab:!1},allowPlayerReuse:!1,useWorkerTimers:[],throughputEstimator:{type:`EmaAndMa`,emaAlphaSlow:.2,emaAlphaFast:.7,emaAlpha:.45,basisTrendChangeCount:10,changeThreshold:.05,useBrowserEstimation:!0,initialThroughput:5e3,measureNonSegmentRequests:!1,rttPenaltyRequestSize:1*1024*1024,streamMinSampleSize:10*1024,streamMinSampleTime:300,smallSampleMinDuration:100,maxSampleRate:1e6,cacheThresholdSize:20,cacheHitTtfbMaxMs:10,measureFastSamples:!1,deviationDepth:20,deviationFactor:.5,lowLatency:{continuesByteSequenceInterval:50,maxLastEvaluationTimeout:300},cdnCache:{enabled:!1,ttlMs:144e5,hostsLimit:10}},autoTrackSelection:{maxBitrateFactorAtEmptyBuffer:4,bitrateFactorAtEmptyBuffer:2.8,minBitrateFactorAtEmptyBuffer:1.5,bitrateAudioFactorAtEmptyBuffer:10,maxBitrateFactorAtFullBuffer:3,bitrateFactorAtFullBuffer:2,minBitrateFactorAtFullBuffer:1,bitrateAudioFactorAtFullBuffer:7,minVideoAudioRatio:5,minAvailableThroughputAudioRatio:5,usePixelRatio:!0,pixelRatioMultiplier:void 0,pixelRatioLogBase:3,pixelRatioLogCoefficients:[1,0,1],limitByContainer:!0,maxContainerSizeFactor:2,containerSizeFactor:1.3,minContainerSizeFactor:1,lazyQualitySwitch:!0,minBufferToSwitchUp:.4,considerPlaybackRate:!1,trackCooldownIncreaseQuality:15e3,trackCooldownDecreaseQuality:3e3,backgroundVideoQualityLimit:Wy.Q_4320P,activeVideoAreaThreshold:.1,highQualityLimit:Wy.Q_720P,trafficSavingLimit:Wy.Q_480P,lowQualityTelemetryLimit:Wy.Q_240P},stallsManager:{enabled:!1,ignoreDynamicAbrForShortVideo:!1,stallDurationNoDataBeforeQualityDecrease:500,stallCountBeforeQualityDecrease:3,resetQualityRestrictionTimeout:1e4,ignoreStallsOnSeek:!0,stallsMetricsHistoryLength:20,maxPossibleStallDuration:3e4,minTvtToBeCounted:120,maxTvtToBeCounted:10800,significantTvt:600,targetStallsDurationPerTvt:1,deviationStallsDurationPerTvt:.5,criticalStallsDurationPerTvt:6,abrAdjustingSpeed:.1,emaAlpha:.6,useTotalStallsDurationPerTvt:!0,useAverageStallsDurationPerTvt:!0,useEmaStallsDurationPerTvt:!0,ignoreStallsOnPause:!1},droppedFramesChecker:{enabled:!1,percentLimit:.1,checkTime:1e3,countLimit:3,tickCountAfterQualityChange:5,qualityUpWaitingTime:5e3,minQualityBanLimit:Wy.Q_480P},dash:{forwardBufferTarget:6e4,forwardBufferTargetAuto:6e4,forwardBufferTargetManual:5*6e4,forwardBufferTargetPreload:5e3,audioBufferAheadOfVideoMs:1e4,seekBiasInTheEnd:2e3,maxSegmentDurationLeftToSelectNextSegment:3e3,minSafeBufferThreshold:.5,bufferPruningSafeZone:1e3,segmentRequestSize:1*1024*1024,maxVirtualBufferSize:250*1024*1024,virtualBufferPruneSize:100*1024*1024,representationSwitchForwardBufferGap:6e4,crashOnStallTimeout:25e3,crashOnStallTWithoutDataTimeout:5e3,restoreBufferBeforeCrashTimeout:1e3,enableSubSegmentBufferFeeding:!0,bufferEmptinessTolerance:100,virtualBufferEmptinessTolerance:100,useBufferQueueVerification:!1,useVirtualBufferImplicitSeek:!1,bufferQueueVerificationMinPosition:2e3,useNewRepresentationSwitch:!1,useDelayedRepresentationSwitch:!1,useSmartRepresentationSwitch:!1,brokenSegmentAppendDetection:!1,brokenSegmentAppendTolerance:100,useFetchPriorityHints:!0,enableBaseUrlSupport:!0,maxSegmentRetryCount:5,sourceOpenTimeout:1e3,vktvAbrThrottle:0,timeupdateEventTickThrottle:300,fetcherBufferOptimisation:!0,usePersistentGaps:!1,abrThrottle:0,useVideoElementWaitingCurrentTimeReassign:!0,stallWatchdogInterval:100,liveUpdateInterval:1e3,liveStallReinitInterval:3e3,ignoreNetworkErrorsOnLoadInit:!1,bufferTolerance:100,useBufferQueueSegmentEndSelection:!1,useBufferGapWatchdog:!1,useNativeBufferGapWatchdog:!1,useZeroAudioBufferLengthWhenAudioManagerExists:!1,jumpToFirstNativeBufferFrame:!1,minNativeBufferSize:5e3,removeTimeShiftFromSegment:500,tickMaintainInterval:100,minSafeBufferToPlay:0,useBufferHoldingOnlyOnStall:!0,useAbrPhases:!1,abrVideoRules:[`fits_container_rule`,`throughput_rule`,`buffer_rule`,`stalls_rule`,`upper_limit_rule`,`lower_limit_rule`],abrAudioRules:[`throughput_rule`,`min_audio_for_video_rule`],useFailoverHostsOnAllProviderCrash:!1,saveData3gQualityLimit:Wy.Q_240P,saveData2gQualityLimit:Wy.Q_144P,useConnectionDataUpperLimit:!1,abandon:{minElapsedMs:1500,bufferSafetyFactor:.8,minLoadedFraction:.15,minBufferToActivateMs:500},bola:{bufferTargetMs:3e4,minBufferMs:1e4,minBufferPerBitrateLevelMs:2e3,placeholderBufferDecay:.99,fallbackSegmentDurationMs:4e3,finiteThresholdMs:6e4,adaptiveBufferTargetK:.5,adaptiveBufferTargetMaxMs:6e4,trimDetectThresholdMs:1e4,antiCascadeDownshift:!0},insufficientBuffer:{thresholdMs:500,gracePeriodAfterPlaybackResetMs:1e3,budgetFactor:.5,fallbackSegmentDurationMs:6e3},videoStreamRepresentaionsFilter:[],filterOnDemandQualityList:!1,dashMaxTvVideoQuality:!1,checkRepresentationCanPlayType:!1,preloadFirstSegment:!1,maxQualityForFirstSegmentPreload:Wy.Q_480P,tracerResumeOnUnexpectedStall:!1,tracerResumeOnLowQuality:!1,recoverStuckSegmentLoading:!1,skipReloadOfFullyBufferedPartiallyEjectedSegments:!1,deferRemoveUntilAbortCompletes:!1},dashCmafLive:{externalStopControl:!1,keepSilentStallWatchdogWhenNotActive:!1,maxActiveLiveOffset:1e4,normalizedTargetMinBufferSize:6e4,normalizedLiveMinBufferSize:5e3,normalizedActualBufferOffset:1e4,offsetCalculationError:3e3,maxLiveDuration:7200,catchupLiveForMutedInactiveTab:!0,lowLatency:{maxTargetOffset:3e3,maxTargetOffsetDeviation:250,playbackCatchupSpeedup:.05,isActiveOnDefault:!1,bufferEstimator:{emaAlpha:.45,changeThreshold:.05,deviationDepth:20,deviationFactor:.5,extremumInterval:5}}},live:{minBuffer:3e3,minBufferSegments:3,lowLatencyMinBuffer:1e3,lowLatencyMinBufferSegments:1,isLiveCatchUpMode:!1,lowLatencyActiveLiveDelay:3e3,activeLiveDelay:5e3,maxPausedTime:5e3,catchupLiveForMutedInactiveTab:!1,disableLiveSeekWithoutOffsetMarker:!1},downloadBackoff:{bufferThreshold:100,start:100,factor:2,max:3*1e3,random:.1},enableWakeLock:!0,enableTelemetryAtStart:!1,userHappinessTriggers:[],forceFormat:void 0,formatsToAvoid:[],disableChromecast:!1,chromecastReceiverId:`07A4434E`,chromecastPresentationApi:!1,useWebmBigRequest:!1,webmCodec:`vp9`,androidPreferredFormat:`dash`,iosPreferredFormat:`hls`,preferCMAF:!1,preferWebRTC:!1,preferMultiStream:!1,preferHDR:!1,bigRequestMinInitSize:50*1024,bigRequestMinDataSize:1*1024*1024,stripRangeHeader:!0,flushShortLoopedBuffers:!0,insufficientBufferRuleMargin:1e4,seekNearDurationBias:1,dashSeekInSegmentDurationThreshold:180*1e3,dashSeekInSegmentAlwaysSeekDelta:1e4,useDelayedPlaybackHangupWithData:!1,playbackHangupNoDataThreshold:5e3,hangupTimeoutMs:5e3,endGapTolerance:300,stallIgnoreThreshold:33,stallHandlingStrategy:`exclude-threshold`,stallIgnoreOnPause:!1,gapWatchdogInterval:50,requestQuick:!1,useHlsJs:!1,disableHlsOnDesktop:!1,useNewSwitchTo:!1,alwaysAbortPreviousSwitch:!1,useDashProviderVirtual:!1,useDashProviderVirtualMobile:!1,useDashLiveProviderVirtual:!1,useDashLiveProviderVirtualMobile:!1,useSafariEndlessRequestBugfix:!0,useSafariOptimisticPositionForLiveEdgeBugfix:!1,isAudioDisabled:!1,autoplayOnlyInActiveTab:!0,autoplayOnlyIfVisible:!0,dynamicImportTimeout:5e3,maxPlaybackTransitionInterval:2e4,providerErrorLimit:3,manifestRetryInterval:300,manifestRetryMaxInterval:1e4,manifestRetryMaxCount:10,audioVideoSyncRate:20,webrtc:{connectionRetryMaxNumber:3},useVolumeMultiplier:!1,ignoreAudioRendererError:!1,useEnableSubtitlesParam:!1,useHlsLiveNewTextManager:!1,exposeInternalsToGlobal:!1,hlsLiveNewTextManagerDownloadThreshold:4e3,disableYandexPiP:!1,asyncResolveClientChecker:!1,changePlaybackStateToPausedWhenEnded:!1,suppressExceptionsInObservables:!0,devNullLogEnabled:!1,collectingDecodingInfoEnabled:!1,sendDashLiveDebug:!1,logDashLiveDebug:!1,reuseOwnVideoElement:!1,reuseOwnVideoElementOnBackgroundTabOnly:!1,handleExtendedNetworkErrorsSet:!1,useDurationFromSegments:!0,ignoreForcePlayResultWhenProviderChanged:!1,hls:{filterOnDemandQualityList:!1},disableSubtitles:!1,audioOnly:!1,clearAudioElementOnDispose:!0,readyOnLoadedMetadata:!1,segmentCache:{mode:`none`,maxTotalSizeBytes:500*1024*1024,evictionThreshold:.9,evictionTargetPercent:.7,evictionBatchMaxBytes:150*1024*1024,quotaExceededEvictPercent:.5,ttlMs:1440*60*1e3,initTtlMs:10080*60*1e3,clearOnErrorStrategy:`once`}},Ky=e=>Uy(e,Gy);var Cb=({seekState:e,position$:t})=>yb(e.stateChangeEnded$.pipe(bb(({to:e})=>e.state===`none`?void 0:(e.position??NaN)/1e3),xb(Sb)),t.pipe(xb(()=>e.getState().state===`none`)));var Tb=e=>{let t=typeof e.container==`string`?document.getElementById(e.container):e.container;return wb(t,`Wrong container or containerId {${e.container}}`),t};var jb=()=>{let e=`mediaCapabilities`in Ab().navigator?Mb:Nb,t=Eb(E(function*(){let t=yield Promise.all(Db(Pb).map(function(){var t=E(function*([t,n]){return{codec:t,supported:yield e(n)}});return function(e){return t.apply(this,arguments)}}())),n=[P.browser.current,...t.map(e=>JSON.stringify(e))].slice(0,16);return kb.push(`core`,{key:`videoplayer_decoding_info`,strings:n}),t}));return()=>Ob(t)},Mb=function(){var e=E(function*(e){if(!e)return Promise.resolve({supported:!1});let t={[`channels`in e?`audio`:`video`]:e};return yield Ab().navigator.mediaCapabilities.decodingInfo(T({type:`media-source`},t))});return function(t){return e.apply(this,arguments)}}(),Nb=e=>{if(!e)return Promise.resolve({supported:!1});let t=Ab().document,n=`channels`in e?t.createElement(`audio`):t.createElement(`video`);return Promise.resolve({supported:n.canPlayType(e?.contentType??``)===`probably`})},Pb={H264:{contentType:`video/mp4; codecs="avc1.4D400C"`,width:720,height:720,bitrate:2886,framerate:30},H265:{contentType:`video/mp4; codecs="hvc1.1.6.L123.B0"`,width:720,height:720,bitrate:2886,framerate:30},VP8:{contentType:`video/webm; codecs="vp8"`,width:720,height:720,bitrate:2886,framerate:30},VP9:{contentType:`video/webm; codecs="vp09.00.10.08"`,width:720,height:720,bitrate:2886,framerate:30},AV1:{contentType:`video/mp4; codecs="av01.0.01M.08"`,width:720,height:720,bitrate:2886,framerate:30},OPUS:{contentType:`audio/ogg; codecs="opus"`,channels:`2`,bitrate:128e3},AAC_LC:{contentType:`audio/mp4; codecs="mp4a.40.2"`,channels:`2`,bitrate:128e3},AC3:{contentType:`audio/mp4; codecs="ac-3"`,channels:`6`,bitrate:128e3},EAC3:{contentType:`audio/mp4; codecs="ec-3"`,channels:`6`,bitrate:128e3},AAC_HE_V1:{contentType:`audio/mp4; codecs="mp4a.40.5"`,channels:`2`,bitrate:128e3},AAC_HE_V2:{contentType:`audio/mp4; codecs="mp4a.40.29"`,channels:`2`,bitrate:128e3},AAC_xHE:{contentType:`audio/mp4; codecs="mp4a.40.42"`,channels:`2`,bitrate:128e3}},Fb={playbackState$:void 0,position$:0,duration$:1/0,playedTime$:0,muted$:!1,volume$:1,availableVideoStreams$:[],currentVideoStream$:void 0,availableVideoTracks$:[],availableQualities$:[],availableQualitiesFps$:{},currentQuality$:void 0,isAutoQualityEnabled$:!0,autoQualityLimitingAvailable$:!1,autoQualityLimits$:{},predefinedQualityLimitType$:`unknown`,availableAudioStreams$:[],currentAudioStream$:void 0,availableAudioTracks$:[],isAudioAvailable$:!0,currentPlaybackRate$:1,currentVirtualVideoBuffer$:{start:0,end:0},currentVideoBuffer$:{start:0,end:0},currentVirtualAudioBuffer$:{start:0,end:0},currentAudioBuffer$:{start:0,end:0},totalBufferDuration$:0,currentNativeVideoBuffer$:{start:0,end:0},currentNativeAudioBuffer$:{start:0,end:0},isBuffering$:!0,isStalled$:!1,stallStartTime$:0,isEnded$:!1,isLooped$:!1,isLive$:void 0,isLiveEnded$:null,canPlayLiveTailBuffer$:!1,canChangePlaybackSpeed$:void 0,atLiveEdge$:void 0,atLiveDurationEdge$:void 0,liveTime$:void 0,liveBufferTime$:void 0,liveLatency$:void 0,currentFormat$:void 0,availableTextTracks$:[],currentTextTrack$:void 0,throughputEstimation$:void 0,rttEstimation$:void 0,videoBitrate$:void 0,hostname$:void 0,httpConnectionType$:void 0,httpConnectionReused$:void 0,httpConnectionMetrics$:void 0,httpDownloadMetrics$:void 0,surface$:`none`,chromecastState$:`NOT_AVAILABLE`,chromecastDeviceName$:void 0,intrinsicVideoSize$:void 0,availableSources$:void 0,currentVideoSegmentLength$:0,currentAudioSegmentLength$:0,debugData$:{volume:0,muted:!1}},Ib={audioStream:void 0,autoVideoTrackLimits:{},autoVideoTrackSwitching:!0,currentTextTrack:void 0,externalTextTracks:[],internalTextTracks:[],isLooped:!1,isLowLatency:!1,playbackRate:1,playbackState:`stopped`,seekState:{state:`none`},videoTrack:void 0,videoStream:void 0,volume:{volume:1,muted:!1}};var Hb=new Set([`has_fatal_error`,`slow_first_frame`,`high_stall_ratio`,`low_quality`]),Ub=e=>typeof e==`string`&&Hb.has(e),Wb=e=>Array.isArray(e)?[...new Set(e.filter(Ub))]:[];var Zb=30,Qb=1.5,$b=3,ex=2e3,tx=1300,nx=.8,rx=.2,ix=(e,t,n,r,i,a,o)=>{let s=new Xb(!1),c=!1,l=!1,u=!1,d=0,f,p=()=>{if(f!==void 0){let e=Math.trunc(Math.max(0,o()-f));l&&(d+=e),f=void 0}},m=()=>{p();let e=n.getValue();e>Zb&&d/e>a&&s.next(!0)},h=()=>{l=!0,f!==void 0&&(f=o())};return i.add(e.stallStartTime$.subscribe(e=>{e>0?f=e:p()})).add(t.firstBytes$.subscribe(()=>{c=!0})).add(e.currentVideoBuffer$.subscribe(e=>{!l&&c&&e&&e.end-e.start>0&&h()})).add(t.firstFrame$.subscribe(()=>{!l&&c&&h()})).add(t.willSeek$.subscribe(()=>{u=!0,p()})).add(t.seeked$.subscribe(()=>{!u&&f!==void 0&&l&&p(),u=!1})).add(t.willStop$.subscribe(()=>{l&&p()})).add(r.pipe(Yb(Boolean)).subscribe(m)).add(p),s};var ox=(e,t)=>{let n=new ax(!1);return t.add(e.fatalError$.subscribe(()=>{n.getValue()||n.next(!0)})),n};var ux={[lx.Q_144P]:0,[lx.Q_240P]:1,[lx.Q_360P]:2,[lx.Q_480P]:3,[lx.Q_720P]:4,[lx.Q_1080P]:5,[lx.Q_1440P]:6,[lx.Q_2160P]:7,[lx.Q_4320P]:8},dx=[281,452,967,2300,2551,4483,8965],fx=[196.4,357.7,595.6,1108,2100,7850,16770],px=[245,424,641,1140,2048,3935,7469],mx=e=>{if(!e||!Number.isFinite(e.width)||!Number.isFinite(e.height)||e.width<=0||e.height<=0)return;let{width:t,height:n}=e;if(t<=256&&n<=144)return 0;if(t<=426&&n<=240)return 1;if(t<=640&&n<=360)return 2;if(t<=853&&n<=480)return 3;if(t<=1280&&n<=720)return 4;if(t<=1920&&n<=1080)return 5;if(t<=2560&&n<=1440)return 6;if(t<=3840&&n<=2160)return 7},hx=(e,t)=>e===void 0||!Number.isFinite(e)||e<0?7:(t===`DASH_WEBM`||t===`DASH_LIVE_WEBM`?fx:t===`DASH_WEBM_AV1`?px:dx).reduce((t,n)=>e>=n?t+1:t,0),gx=e=>e?ux[e]:void 0,_x=e=>{let t=e.reduce((e,t)=>Math.max(e,gx(t)??-1),-1);return t<0?void 0:t},vx=(e,t)=>{if(e===`invisible`)return 0;if(t)return 3;switch(e){case`fullscreen`:case`second_screen`:return 5;case`pip`:return 1;default:return 3}},yx=(e,t)=>{if(e!==`inline`)return vx(e,!1);switch(t){case`mvk`:return 3;case`smart_tv`:return 5;case`web2`:return 4}},bx=(e,t,n)=>{let r=_x(n);return r===void 0?void 0:Math.min(vx(e,t),r)},xx=(e,t,n)=>{let r=yx(e,n.platform),i=mx(n.viewportSize);e!==`invisible`&&i!==void 0&&(r=i);let a=_x(t);return a===void 0?void 0:Math.min(Math.min(r,a),hx(n.throughputKbps,n.format))},Sx=(e,t,n,r)=>{if(r<=0)return;let i=Math.max(0,n-(t??n)),a=i===0?0:2**(i-1);e.requiredQualityTotalSeconds+=r,e.qualityScoreFineSeconds+=a*r},Cx=e=>{if(!(e.requiredQualityTotalSeconds<=0))return e.qualityScoreFineSeconds/e.requiredQualityTotalSeconds},wx=(e,t,n)=>{if(!(e.totalSeconds<=0||t.totalSeconds<=0||e.totalSeconds!==t.totalSeconds))return e.rankSeconds*t.totalSeconds-t.rankSeconds*(e.totalSeconds-e.unknownSeconds)>=-n*e.totalSeconds*t.totalSeconds},Tx=(e,t,n,r,i,a,o)=>{let s=new cx(!1),c={requiredQualityTotalSeconds:0,qualityScoreFineSeconds:0},l={totalSeconds:0,rankSeconds:0,unknownSeconds:0},u={totalSeconds:0,rankSeconds:0},d=e.currentQuality$.getValue(),f=e.isAutoQualityEnabled$.getValue(),p=!1,m=e.surface$.getValue(),h=e.isLive$.getValue()??!1,g=e.availableQualities$.getValue(),_=e.currentFormat$.getValue(),v=e.throughputEstimation$.getValue(),y,b,x=n.getValue(),S=e=>{if(e<=0||p)return;if(!f){p=!0;return}let t=gx(d);l.totalSeconds+=e,t===void 0?l.unknownSeconds+=e:l.rankSeconds+=t*e;let n=bx(m,h,g);if(n!==void 0&&(u.totalSeconds+=e,u.rankSeconds+=n*e),!h){let n=xx(m,g,{viewportSize:y,throughputKbps:v,format:_,platform:o});n!==void 0&&Sx(c,t,n,e)}},C=()=>{let e=n.getValue();S(e-x),x=e};return i.add(e.currentQuality$.subscribe(e=>{C(),d=e})).add(e.isAutoQualityEnabled$.subscribe(e=>{C(),f=e})).add(e.surface$.subscribe(e=>{C(),m=e})).add(e.isLive$.subscribe(e=>{C(),h=e??!1})).add(e.availableQualities$.subscribe(e=>{C(),g=e})).add(e.currentFormat$.subscribe(e=>{C(),_=e})).add(e.throughputEstimation$.subscribe(e=>{C(),v=e})).add(t.element$.subscribe(e=>{C(),b?.disconnect(),b=void 0,y=void 0,e&&typeof ResizeObserver<`u`&&(b=new ResizeObserver(t=>{let n=t.find(({target:t})=>t===e);if(!n)return;let{width:r,height:i}=n.contentRect,a=r>0&&i>0?{width:r,height:i}:void 0;(y?.width!==a?.width||y?.height!==a?.height)&&(C(),y=a)}),b.observe(e))})).add(n.subscribe(C)).add(r.pipe(sx(Boolean)).subscribe(()=>{if(C(),!(!(n.getValue()>Zb)||p||s.getValue())){if(c.requiredQualityTotalSeconds>0){let e=Cx(c),t=e===void 0?void 0:1-e;t!==void 0&&t<a.minQualityScore&&s.next(!0);return}wx(l,u,a.allowedDeficitRank)===!1&&s.next(!0)}})).add(()=>b?.disconnect()),s};var Dx=(e,t,n)=>{let r=new Ex(!1);return t.add(e.firstFrame$.subscribe(e=>{e>n&&!r.getValue()&&r.next(!0)})),r};var jx=(e,t,n,r)=>{let i=new Ax(0),a=new Ax(0);return n.add(i.subscribe(e=>{a.next(e/1e3)})),n.add(Ox({info:e,events:t},r).subscribe(r=>{n.add(kx(t.started$,t.playing$,t.paused$,t.willSeek$,t.ended$,t.willDestruct$,e.currentPlaybackRate$,e.position$).subscribe(()=>i.next(r())))})),a};class Mx{constructor(e,t,n,r,i,a){this.subscription=new qb,this.sessionFinalized$=new Jb(!1),this.lowQuality$=void 0,this.highStallRatio$=void 0,this.hasFatalError$=void 0,this.slowFirstFrame$=void 0;let o=r.some(e=>e===`low_quality`||e===`high_stall_ratio`)?jx(e,t,this.subscription,Kb):new Jb(0);this.lowQuality$=Gb(r,`low_quality`)?Tx(e,n,o,this.sessionFinalized$,this.subscription,i,a):new Jb(!1),this.highStallRatio$=Gb(r,`high_stall_ratio`)?ix(e,t,o,this.sessionFinalized$,this.subscription,i.maxStallRatio,Kb):new Jb(!1),this.hasFatalError$=Gb(r,`has_fatal_error`)?ox(t,this.subscription):new Jb(!1),this.slowFirstFrame$=Gb(r,`slow_first_frame`)?Dx(t,this.subscription,i.maxFirstFrameTimeMs):new Jb(!1)}destroy(){this.finalizeSession(),this.subscription.unsubscribe()}finalizeSession(){this.sessionFinalized$.getValue()||this.sessionFinalized$.next(!0)}}var Nx=e=>({maxFirstFrameTimeMs:e?tx:ex,maxStallRatio:e?$b:Qb,minQualityScore:nx,allowedDeficitRank:rx}),Px=(e,t)=>t?`smart_tv`:e?`mvk`:`web2`;class Fx{constructor(e,t,n,r,i){this.subscription=new Vb,this.observer=void 0;let a=Wb(i);if(a.length===0)return;let o=P.device.isMobile&&!P.device.isTablet;this.observer=new Mx(e,t,n,a,Nx(o),Px(o,P.device.isSmartTV));let s={has_fatal_error:this.observer.hasFatalError$,slow_first_frame:this.observer.slowFirstFrame$,high_stall_ratio:this.observer.highStallRatio$,low_quality:this.observer.lowQuality$},c=zb(...a.map(e=>s[e].pipe(Lb(Boolean),Rb(e))));this.subscription.add(c.subscribe(e=>{r.setSpanAttributes({[e]:!0})})).add(c.pipe(Bb()).subscribe(()=>r.resume()))}destroy(){this.observer?.destroy(),this.subscription.unsubscribe()}}class Ix{constructor(e={},t=gb.createRootTracer(`fake`),n){this.subscription=new pb,this.persistentSubscription=new pb,this.domContainer=null,this.providerContainer=void 0,this.chromecastInitializer=void 0,this.logger=new cb,this.tracer=void 0,this.abrLogger=this.logger.createComponentLog(`ABR`),this.config=void 0,this.tuning=void 0,this.throughputEstimator=void 0,this.internalsExposure=null,this.isPlaybackStarted=!1,this.suppressWillStop=!1,this.initedAt=void 0,this.hasLiveOffsetByPaused=new _b(!1),this.hasLiveOffsetByPausedTimer=0,this.playerInitRequest=0,this.playerInited=new _b(!1),this.explicitInitialQuality=void 0,this.wasSetStartedQuality=!1,this.desiredState=ce(Ib).reduce((e,[t,n])=>(e[t]=new yn(n),e),{}),this.info=ce(Fb).reduce((e,[t,n])=>(e[t]=new _b(n),e),{}),this.userHappinessController=void 0,this.events={inited$:new $,ready$:new $,started$:new $,playing$:new $,paused$:new $,stopped$:new $,willReady$:new $,willStart$:new $,willResume$:new $,willPause$:new $,willStop$:new $,willDestruct$:new $,watchCoverageRecord$:new $,watchCoverageLive$:new $,managedError$:new $,fatalError$:new $,fetcherRecoverableError$:new $,ended$:new $,looped$:new $,seeked$:new $,willSeek$:new $,autoplaySoundProhibited$:new $,manifestRequested$:new $,firstBytesManifest$:new $,manifestReceived$:new $,firstBytesRequested$:new $,firstBytesReceived$:new $,firstBytes$:new $,loadedMetadata$:new $,firstFrame$:new $,canplay$:new $,log$:new $,fetcherError$:new $,severeStallOccured$:new $},this.experimental={element$:new _b(void 0),enableDebugTelemetry$:new _b(!1),dumpTelemetry:Np,getCurrentTime$:new _b(null),skipVideoElVolumeSync$:new _b(!1)},this.devNullLog=void 0,this.collectDecodingInfoDestroyCb=void 0,this.releaseTimers=void 0,this.doInit=e=>{let{container:t}=e,n=D(e,w);this.tracer.log(`initVideo`,Zy(n),!0),this.domContainer=Tb(e),this.chromecastInitializer.contentId=e.meta?.videoId,this.providerContainer=new yy({sources:e.sources,meta:e.meta??{},failoverHosts:e.failoverHosts??[],container:this.domContainer,desiredState:this.desiredState,dependencies:{throughputEstimator:this.throughputEstimator,chromecastInitializer:this.chromecastInitializer,tracer:this.tracer,logger:this.logger,abrLogger:this.abrLogger},tuning:this.tuning,volumeMultiplier:e.volumeMultiplier,panelSize:e.panelSize,skipVideoElVolumeSync$:this.experimental.skipVideoElVolumeSync$,handleNetworkRecoverableErrorAsProviderError:e.handleNetworkRecoverableErrorAsProviderError}),this.initProviderContainerSubscription(this.providerContainer),this.initStartingVideoTrack(this.providerContainer),this.providerContainer.init(),this.setLiveLowLatency(this.tuning.dashCmafLive.lowLatency.isActiveOnDefault),this.initDebugTelemetry(),this.initWakeLock(),this.playerInited.next(!0),this.devNullLog&&this.tuning.devNullLogEnabled?(Yy.subscribe(`core`,this.devNullLog),this.tuning.collectingDecodingInfoEnabled&&(this.collectDecodingInfoDestroyCb=jb())):Yy.destroy(`core`)},this.initLogs(),this.tuning=Ky(e),this.tracer=t,this.userHappinessController=this.createUserHappinessController(),this.releaseTimers=fb(this.tuning.useWorkerTimers),this.tuning.suppressExceptionsInObservables&&(le(this.info).forEach(e=>e.setSuppressErrors(!0)),le(this.events).forEach(e=>e.setSuppressErrors(!0)));let r={receiverApplicationId:this.tuning.chromecastReceiverId,isDisabled:this.tuning.disableChromecast,dependencies:{logger:this.logger}};if(this.chromecastInitializer=this.tuning.chromecastPresentationApi?new un(r):new Ee(r),this.throughputEstimator=new Hy(this.tuning.throughputEstimator,this.info.hostname$,this.logger.createComponentLog(`ThroughputEstimator`)),e.exposeInternalsToGlobal&&(this.internalsExposure=new rb(`core`,$y(n?.playerId)),this.internalsExposure.expose({player:this,getTimersDiagnostics:eb})),this.initChromecastSubscription(),this.initDesiredStateSubscriptions(),this.initDebugDataSubscriptions(),this.devNullLog=n?.onDevNullLog,Yy.create(`core`),Proxy&&Reflect)return new Proxy(this,{get:(e,t,n)=>{let r=Reflect.get(e,t,n);return typeof r==`function`?(...n)=>{try{return r.apply(e,n)}catch(e){let r=n.map(e=>JSON.stringify(e,(e,t)=>{let n=typeof t;return ue([`number`,`string`,`boolean`],n)?t:t===null?null:`<${n}>`})),i=`Player.${String(t)}`,a=`Exception calling ${i} (${r.join(`, `)})`;throw this.events.fatalError$.next({id:i,category:Xy.WTF,message:a,thrown:e}),e}}:r}})}resetDesiredState(){let e=(e,t)=>{e.setState(t)};Object.keys(this.desiredState).forEach(t=>{e(this.desiredState[t],Ib[t])})}createUserHappinessController(){return new Fx(this.info,this.events,this.experimental,this.tracer,this.tuning.userHappinessTriggers)}reset(){this.subscription.unsubscribe(),this.providerContainer?.destroy(),this.providerContainer=void 0,this.userHappinessController.destroy(),M.clearTimeout(this.hasLiveOffsetByPausedTimer),this.collectDecodingInfoDestroyCb?.call(this),this.playerInited.next(!1),this.resetDesiredState();let e=(e,t)=>{e.next(t)},t=[`muted$`,`volume$`];Object.keys(this.info).forEach(n=>{ue(t,n)?e(this.info[n],this.info[n].getValue()):e(this.info[n],Fb[n])}),this.userHappinessController=this.createUserHappinessController()}initAudio(e){return this.initVideo(T(T({},e),{},{container:e.audioElement??document.createElement(`audio`)}))}initVideo(e){let t=nb();this.config=e,this.internalsExposure?.expose({config:e,logger:this.logger,tuning:this.tuning}),this.setMuted(e.isMuted??this.tuning.isAudioDisabled);let n=()=>{this.tuning.autoplayOnlyIfVisible&&t.requestAnimationFrame?this.playerInitRequest=t.requestAnimationFrame(()=>this.doInit(e)):this.doInit(e)},r=()=>{this.tuning.asyncResolveClientChecker?P.isInited$.pipe(Y(e=>!!e),Q()).subscribe(()=>{console.log(`Core SDK async start`),n()}):n()};return this.isNotActiveTabCase()?(this.tracer.log(`request play from hidden tab`),Qy(t.document,`visibilitychange`).pipe(Q()).subscribe(r)):r(),this}destroy(e){let t=nb();this.tracer.log(`destroy`),M.clearTimeout(this.hasLiveOffsetByPausedTimer),this.playerInitRequest&&t.cancelAnimationFrame(this.playerInitRequest),this.events.willDestruct$.next(),this.suppressWillStop=e?.reportStop===!1,this.stop(),this.providerContainer?.destroy(),this.userHappinessController.destroy(),this.throughputEstimator.destroy(),this.chromecastInitializer.destroy(),this.subscription.unsubscribe(),this.persistentSubscription.unsubscribe(),this.tracer.end(),this.internalsExposure?.destroy(),Yy.destroy(`core`),this.collectDecodingInfoDestroyCb?.call(this),this.releaseTimers()}waitInit(e){this.playerInited.getValue()?e():this.subscription.add(this.playerInited.pipe(Y(e=>!!e),Q()).subscribe(e))}prepare(){return this.waitInit(()=>{let e=this.desiredState.playbackState;this.tracer.log(`prepare`,{currentPlayBackState:e.getState()}),e.getState()===`stopped`&&e.startTransitionTo(`ready`)}),this}play(){return this.waitInit(()=>{let e=this.desiredState.playbackState;this.tracer.log(`play`,{currentPlayBackState:e.getState()}),e.getState()!==`playing`&&e.startTransitionTo(`playing`)}),this}pause(){return this.waitInit(()=>{let e=this.desiredState.playbackState;this.tracer.log(`pause`,{currentPlayBackState:e.getState()}),e.getState()!==`paused`&&e.startTransitionTo(`paused`)}),this}stop(){return this.waitInit(()=>{let e=this.desiredState.playbackState;this.tracer.log(`stop`,{currentPlayBackState:e.getState()}),e.getState()!==`stopped`&&(e.startTransitionTo(`stopped`),this.tuning.allowPlayerReuse&&this.reset())}),this}seekTime(e,t=!0){return this.waitInit(()=>{let n=this.info.duration$.getValue(),r=this.info.isLive$.getValue(),i=e;e>=n&&!r&&(i=n-this.tuning.seekNearDurationBias),i<0&&!r&&(i=0),this.tracer.log(`seekTime`,{duration:n,isLive:r,time:e,calculatedTime:i,forcePrecise:t}),Number.isFinite(i)&&(this.events.willSeek$.next({from:this.getExactTime(),to:i}),this.desiredState.seekState.setState({state:`requested`,position:i*1e3,forcePrecise:t}))}),this}seekPercent(e){return this.waitInit(()=>{let t=this.info.duration$.getValue();this.tracer.log(`seekPercent`,{percent:e,duration:t}),isFinite(t)&&this.seekTime(Math.abs(t)*e,!1)}),this}setVolume(e,t,n=!1){return this.waitInit(()=>{this.experimental.skipVideoElVolumeSync$.next(n);let r=this.desiredState.volume,i=r.getTransition()?.to.muted??this.info.muted$.getValue(),a=t??(this.tuning.isAudioDisabled||i);this.tracer.log(`setVolume`,{volume:e,isAudioDisabled:this.tuning.isAudioDisabled,chromecastState:this.chromecastInitializer.castState$.getValue(),muted:a}),this.chromecastInitializer.castState$.getValue()===`CONNECTED`&&!(this.chromecastInitializer instanceof un)?this.chromecastInitializer.setVolume(e):r.startTransitionTo({volume:e,muted:a})}),this}setMuted(e,t=!1,n=!1){return this.waitInit(()=>{this.experimental.skipVideoElVolumeSync$.next(n);let r=this.desiredState.volume,i=this.tuning.isAudioDisabled&&!t||e,a=r.getTransition()?.to.volume??this.info.volume$.getValue();this.tracer.log(`setMuted`,{isMuted:e,nextMuted:i,volume:a,isAudioDisabled:this.tuning.isAudioDisabled,chromecastState:this.chromecastInitializer.castState$.getValue()}),this.chromecastInitializer.castState$.getValue()===`CONNECTED`&&!(this.chromecastInitializer instanceof un)?this.chromecastInitializer.setMuted(i):r.startTransitionTo({volume:a,muted:i})}),this}setVideoStream(e){return this.waitInit(()=>{this.desiredState.videoStream.startTransitionTo(e)}),this}setAudioStream(e){return this.waitInit(()=>{this.desiredState.audioStream.startTransitionTo(e)}),this}setQuality(e){return this.waitInit(()=>{qy(this.providerContainer);let t=this.providerContainer.providerOutput.availableVideoTracks$.getValue();this.tracer.log(`setQuality`,{isDelayed:t.length===0,quality:e}),this.desiredState.videoTrack.getState()===void 0&&this.desiredState.videoTrack.getPrevState()===void 0&&t.length===0?this.wasSetStartedQuality?this.providerContainer.providerOutput.availableVideoTracks$.pipe(Y(e=>e.length>0),Q()).subscribe(t=>{this.setVideoTrackIdByQuality(t,e)}):this.explicitInitialQuality=e:t.length>0&&this.setVideoTrackIdByQuality(t,e)}),this}setAutoQuality(e){return this.waitInit(()=>{this.tracer.log(`setAutoQuality`,{enable:e}),this.desiredState.autoVideoTrackSwitching.startTransitionTo(e)}),this}setAutoQualityLimits(e){return this.waitInit(()=>{this.tracer.log(`setAutoQualityLimits`,Zy(e)),this.desiredState.autoVideoTrackLimits.startTransitionTo(e)}),this}setPredefinedQualityLimits(e){return this.waitInit(()=>{if(this.info.predefinedQualityLimitType$.getValue()===e)return this;let{highQualityLimit:t,trafficSavingLimit:n}=this.tuning.autoTrackSelection,r;switch(e){case`high_quality`:r={min:t,max:void 0};break;case`traffic_saving`:r={max:n,min:void 0};break;default:r={max:void 0,min:void 0}}this.setAutoQualityLimits(r)}),this}setPlaybackRate(e){return this.waitInit(()=>{this.tracer.log(`setPlaybackRate`,{playbackRate:e}),this.desiredState.playbackRate.startTransitionTo(e)}),this}setExternalTextTracks(e){return this.waitInit(()=>{e.length&&this.tracer.log(`setExternalTextTracks`,Zy(e)),this.desiredState.externalTextTracks.startTransitionTo(e.map(e=>T({type:`external`},e)))}),this}selectTextTrack(e){return this.waitInit(()=>{this.tracer.log(`selectTextTrack`,{textTrackId:e}),this.desiredState.currentTextTrack.setState(e)}),this}setLiveLowLatency(e){let t=this.info.isLive$.getValue(),n=this.desiredState.isLowLatency.getState();return!t||n===e?this:(this.tracer.log(`live switch to low latency `+e),this.desiredState.isLowLatency.setState(e),this.seekTime(0))}setLooped(e){return this.waitInit(()=>{this.tracer.log(`setLooped`,{isLooped:e}),this.desiredState.isLooped.startTransitionTo(e)}),this}toggleChromecast(){this.tracer.log(`toggleChromecast`),this.chromecastInitializer.toggleConnection()}getExactTime(){if(!this.providerContainer)return 0;let e=this.providerContainer.providerOutput.element$.getValue();if(sb(e))return this.info.position$.getValue();let t=this.desiredState.seekState.getState(),n=t.state===`none`?void 0:t.position;return ob(n)?n/1e3:e.currentTime}getExactLiveTime(){if(!this.providerContainer)return 0;let e=this.desiredState.seekState.getState(),t=e.state===`none`?void 0:e.position;return(ob(t)?t:this.info.liveTime$.getValue()??0)/1e3}getAllLogs(){return this.logger.getAllLogs()}getDebugData(){return this.info.debugData$.getValue()}buildDebugData([e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v]){let y={version:k,volume:Math.round(_*100),muted:v,provider:e,cdn:t,videoSize:n?`${n.width}x${n.height}`:void 0,speed:l,bitrate:u,liveLatency:d,currentVideoSegmentLength:f,currentAudioSegmentLength:p,videoCodec:m?.codec,audioCodec:h?.codec,hdr:m?.hdr,audioLanguage:h?.language,position:g};return r&&a&&(s&&c?(y.videoBuffer=r.end-c,y.nativeVideoBuffer=a.end-c):(y.videoBuffer=Math.max(r.end-g,0),y.nativeVideoBuffer=Math.max(a.end-g,0))),i&&(y.audioBuffer=Math.max(i.end-g,0),o&&(y.nativeAudioBuffer=Math.max(o.end-g,0))),y}setIntrinsicVideoSize(...e){let t={width:e.reduce((e,{width:t})=>e||t||0,0),height:e.reduce((e,{height:t})=>e||t||0,0)};t.width&&t.height&&this.info.intrinsicVideoSize$.next({width:t.width,height:t.height})}initDebugDataSubscriptions(){this.subscription.add(vb([this.info.currentFormat$,this.info.hostname$,this.info.intrinsicVideoSize$,this.info.currentVirtualVideoBuffer$,this.info.currentVirtualAudioBuffer$,this.info.currentNativeVideoBuffer$,this.info.currentNativeAudioBuffer$,this.info.isLive$,this.info.liveBufferTime$,this.info.throughputEstimation$,this.info.videoBitrate$,this.info.liveLatency$,this.info.currentVideoSegmentLength$,this.info.currentAudioSegmentLength$,this.info.currentVideoStream$,this.info.currentAudioStream$,this.info.position$,this.info.volume$,this.info.muted$]).pipe(Z(e=>this.buildDebugData(e))).subscribe(this.info.debugData$))}initDesiredStateSubscriptions(){this.persistentSubscription.add(ub(this.desiredState.playbackState.stateChangeStarted$,this.desiredState.playbackState.forceChanged$).pipe(Z(e=>e.to)).subscribe(this.info.playbackState$)).add(this.desiredState.isLooped.stateChangeEnded$.pipe(Z(e=>e.to)).subscribe(this.info.isLooped$)).add(this.desiredState.currentTextTrack.stateChangeEnded$.pipe(Z(e=>e.to)).subscribe(this.info.currentTextTrack$)).add(this.desiredState.playbackRate.stateChangeEnded$.pipe(Z(e=>e.to)).subscribe(this.info.currentPlaybackRate$)).add(this.desiredState.autoVideoTrackSwitching.stateChangeEnded$.pipe(Z(e=>e.to)).subscribe(this.info.isAutoQualityEnabled$)).add(this.desiredState.autoVideoTrackLimits.stateChangeEnded$.pipe(Z(e=>e.to)).subscribe(e=>{this.info.autoQualityLimits$.next(e);let{highQualityLimit:t,trafficSavingLimit:n}=this.tuning.autoTrackSelection;this.info.predefinedQualityLimitType$.next(ra(e,t,n))})).add(ub(this.desiredState.playbackState.stateChangeStarted$,this.desiredState.playbackState.forceChanged$).pipe(Y(({from:e})=>e===`stopped`)).subscribe(()=>{this.initedAt=db(),this.events.inited$.next()})).add(this.desiredState.playbackState.stateChangeEnded$.subscribe(e=>{switch(e.to){case`ready`:this.events.ready$.next();break;case`playing`:this.isPlaybackStarted||this.events.started$.next(),this.isPlaybackStarted=!0,this.events.playing$.next();break;case`paused`:this.events.paused$.next();break;case`stopped`:this.events.stopped$.next()}})).add(this.desiredState.playbackState.stateChangeStarted$.subscribe(e=>{switch(e.to){case`ready`:this.events.willReady$.next();break;case`paused`:this.events.willPause$.next();break;case`playing`:this.isPlaybackStarted?this.events.willResume$.next():this.events.willStart$.next();break;case`stopped`:this.suppressWillStop||this.events.willStop$.next();break;default:}}))}initProviderContainerSubscription(e){this.subscription.add(e.providerOutput.willSeekEvent$.subscribe(()=>{let e=this.desiredState.seekState.getState();this.tracer.log(`willSeekEvent`,Zy(e)),e.state===`requested`?this.desiredState.seekState.setState(T(T({},e),{},{state:`applying`})):this.events.managedError$.next({id:`WillSeekIn${e.state}`,category:Xy.WTF,message:`Received unexpeceted willSeek$`})})).add(e.providerOutput.soundProhibitedEvent$.pipe(Q()).subscribe(this.events.autoplaySoundProhibited$)).add(e.providerOutput.severeStallOccurred$.subscribe(this.events.severeStallOccured$)).add(e.providerOutput.seekedEvent$.subscribe(()=>{let e=this.desiredState.seekState.getState();this.tracer.log(`seekedEvent`,Zy(e)),e.state===`applying`&&(this.desiredState.seekState.setState({state:`none`}),this.events.seeked$.next())})).add(e.current$.pipe(Z(e=>e.type)).subscribe(this.info.currentFormat$)).add(e.current$.pipe(Z(e=>e.destination),X()).subscribe(()=>this.isPlaybackStarted=!1)).add(e.providerOutput.availableVideoStreams$.subscribe(this.info.availableVideoStreams$)).add(e.providerOutput.availableVideoTracks$.subscribe(this.info.availableVideoTracks$)).add(Jy({availableVideoTracks:e.providerOutput.availableVideoTracks$,currentVideoStream:e.providerOutput.currentVideoStream$}).pipe(Z(({availableVideoTracks:e,currentVideoStream:t})=>e.filter(e=>t?t.id===e.streamId:!0).map(({quality:e})=>e).sort((e,t)=>ab(e)?1:ab(t)?-1:ib(t,e)?1:-1))).subscribe(this.info.availableQualities$)).add(e.providerOutput.availableVideoTracks$.subscribe(e=>{let t={};for(let n of e)n.fps&&(t[n.quality]=n.fps);this.info.availableQualitiesFps$.next(t)})).add(e.providerOutput.availableAudioStreams$.subscribe(this.info.availableAudioStreams$)).add(e.providerOutput.currentVideoStream$.subscribe(this.info.currentVideoStream$)).add(e.providerOutput.currentAudioStream$.subscribe(this.info.currentAudioStream$)).add(e.providerOutput.availableAudioTracks$.subscribe(this.info.availableAudioTracks$)).add(e.providerOutput.isAudioAvailable$.pipe(X()).subscribe(this.info.isAudioAvailable$)).add(e.providerOutput.currentVideoTrack$.pipe(Y(e=>ob(e))).subscribe(e=>{this.info.currentQuality$.next(e?.quality),this.info.videoBitrate$.next(e?.bitrate)})).add(e.providerOutput.currentVideoSegmentLength$.pipe(X((e,t)=>Math.round(e)===Math.round(t))).subscribe(this.info.currentVideoSegmentLength$)).add(e.providerOutput.currentAudioSegmentLength$.pipe(X((e,t)=>Math.round(e)===Math.round(t))).subscribe(this.info.currentAudioSegmentLength$)).add(e.providerOutput.hostname$.pipe(X()).subscribe(this.info.hostname$)).add(e.providerOutput.httpConnectionType$.pipe(X()).subscribe(this.info.httpConnectionType$)).add(e.providerOutput.httpConnectionReused$.pipe(X()).subscribe(this.info.httpConnectionReused$)).add(e.providerOutput.httpConnectionMetrics$.pipe(X()).subscribe(this.info.httpConnectionMetrics$)).add(e.providerOutput.httpDownloadMetrics$.pipe(X()).subscribe(this.info.httpDownloadMetrics$)).add(e.providerOutput.availableTextTracks$.subscribe(this.info.availableTextTracks$)).add(e.providerOutput.autoVideoTrackLimitingAvailable$.subscribe(this.info.autoQualityLimitingAvailable$)).add(e.providerOutput.autoVideoTrackLimits$.subscribe(e=>{this.desiredState.autoVideoTrackLimits.setState(e??{})})).add(e.providerOutput.currentVirtualVideoBuffer$.pipe(Z(e=>e?{start:e.from,end:e.to}:{start:0,end:0})).subscribe(this.info.currentVirtualVideoBuffer$)).add(e.providerOutput.currentVirtualVideoBuffer$.pipe(Z(e=>e?{start:e.from,end:e.to}:{start:0,end:0})).subscribe(this.info.currentVideoBuffer$)).add(e.providerOutput.currentVirtualAudioBuffer$.pipe(Z(e=>e?{start:e.from,end:e.to}:{start:0,end:0})).subscribe(this.info.currentVirtualAudioBuffer$)).add(e.providerOutput.currentVirtualAudioBuffer$.pipe(Z(e=>e?{start:e.from,end:e.to}:{start:0,end:0})).subscribe(this.info.currentAudioBuffer$)).add(e.providerOutput.currentNativeVideoBuffer$.pipe(Z(e=>e?{start:e.from,end:e.to}:{start:0,end:0})).subscribe(this.info.currentNativeVideoBuffer$)).add(e.providerOutput.currentNativeAudioBuffer$.pipe(Z(e=>e?{start:e.from,end:e.to}:{start:0,end:0})).subscribe(this.info.currentNativeAudioBuffer$)).add(e.providerOutput.totalBufferDuration$.subscribe(this.info.totalBufferDuration$)).add(e.providerOutput.duration$.subscribe(this.info.duration$)).add(e.providerOutput.playedTime$.subscribe(this.info.playedTime$)).add(e.providerOutput.isBuffering$.subscribe(this.info.isBuffering$)).add(e.providerOutput.isLive$.subscribe(this.info.isLive$)).add(e.providerOutput.isLiveEnded$.pipe(mb(e=>e&&this.stop())).subscribe(this.info.isLiveEnded$)).add(e.providerOutput.canPlayLiveTailBuffer$.subscribe(this.info.canPlayLiveTailBuffer$)).add(e.providerOutput.canChangePlaybackSpeed$.subscribe(this.info.canChangePlaybackSpeed$)).add(e.providerOutput.liveTime$.pipe(X()).subscribe(this.info.liveTime$)).add(e.providerOutput.liveBufferTime$.subscribe(this.info.liveBufferTime$)).add(e.providerOutput.liveLatency$.subscribe(this.info.liveLatency$)).add(Jy({hasLiveOffsetByPaused:ub(this.desiredState.playbackState.stateChangeStarted$,this.desiredState.playbackState.forceChanged$).pipe(Z(e=>e.to),X(),Z(e=>e===`paused`)),isLowLatency:e.providerOutput.isLowLatency$}).subscribe(({hasLiveOffsetByPaused:e,isLowLatency:t})=>{if(M.clearTimeout(this.hasLiveOffsetByPausedTimer),e){this.hasLiveOffsetByPausedTimer=M.setTimeout(()=>{this.hasLiveOffsetByPaused.next(!0)},this.getActiveLiveDelay(t));return}this.hasLiveOffsetByPaused.next(!1)})).add(Jy({atLiveEdge:Jy({isLive:e.providerOutput.isLive$,isLowLatency:e.providerOutput.isLowLatency$,position:Cb({seekState:this.desiredState.seekState,position$:e.providerOutput.position$})}).pipe(Z(({isLive:e,position:t,isLowLatency:n})=>{let r=this.getActiveLiveDelay(n);return e&&Math.abs(t)<r/1e3}),X(),mb(e=>e&&this.setPlaybackRate(1))),hasPausedTimeoutCase:this.hasLiveOffsetByPaused}).pipe(Z(({atLiveEdge:e,hasPausedTimeoutCase:t})=>e&&!t)).subscribe(this.info.atLiveEdge$)).add(Jy({isLive:e.providerOutput.isLive$,position:P.browser.isSafari&&this.tuning.useSafariOptimisticPositionForLiveEdgeBugfix?Cb({seekState:this.desiredState.seekState,position$:e.providerOutput.position$}):e.providerOutput.position$,duration:e.providerOutput.duration$}).pipe(Z(({isLive:e,position:t,duration:n})=>e&&(Math.abs(n)-Math.abs(t))*1e3<this.tuning.live.activeLiveDelay),X(),mb(e=>e&&this.setPlaybackRate(1))).subscribe(this.info.atLiveDurationEdge$)).add(e.providerOutput.volume$.pipe(Z(e=>e.muted),X()).subscribe(this.info.muted$)).add(e.providerOutput.volume$.pipe(Z(e=>e.volume),X()).subscribe(this.info.volume$)).add(Cb({seekState:this.desiredState.seekState,position$:e.providerOutput.position$}).subscribe(this.info.position$)).add(e.providerOutput.seekedEvent$.subscribe(()=>{this.info.isEnded$.getValue()&&this.tuning.changePlaybackStateToPausedWhenEnded&&this.play()})).add(ub(e.providerOutput.endedEvent$.pipe(lb(!0)),e.providerOutput.seekedEvent$.pipe(lb(!1))).pipe(X()).subscribe(this.info.isEnded$)).add(e.providerOutput.endedEvent$.subscribe(this.events.ended$)).add(e.providerOutput.loopedEvent$.subscribe(this.events.looped$)).add(e.providerError$.subscribe(this.events.managedError$)).add(e.providerOutput.updateDurationError$.subscribe(this.events.managedError$)).add(e.providerOutput.fetcherRecoverableError$.subscribe(this.events.fetcherRecoverableError$)).add(e.providerOutput.fetcherError$.pipe(Y(e=>e.category===Xy.FATAL)).subscribe(this.events.fatalError$)).add(e.volumeMultiplierError$.subscribe(this.events.managedError$)).add(e.noAvailableProvidersError$.pipe(Z(({forced:e,input:t,supported:n})=>{let r,i;return e?(r=`NoForcedFormat`,i=`${e} was forced but failed or not available`):n.length?(r=`NoFormats`,i=`All formats failed`):t.length?(r=`NoSupportedFormats`,i=`No supported formats`):(r=`NoInputFormats`,i=`No formats supplied`),qy(r),{id:r,category:Xy.VIDEO_PIPELINE,message:i}})).subscribe(this.events.fatalError$)).add(e.providerOutput.element$.subscribe(this.experimental.element$)).add(e.providerOutput.getCurrentTime$.subscribe(this.experimental.getCurrentTime$)).add(e.providerOutput.manifestRequested$.pipe(Q()).subscribe(this.events.manifestRequested$)).add(e.providerOutput.firstBytesManifest$.pipe(Q()).subscribe(this.events.firstBytesManifest$)).add(e.providerOutput.manifestReceived$.pipe(Q()).subscribe(this.events.manifestReceived$)).add(e.providerOutput.firstBytesRequested$.pipe(Q()).subscribe(this.events.firstBytesRequested$)).add(e.providerOutput.firstBytesReceived$.pipe(Q()).subscribe(this.events.firstBytesReceived$)).add(e.providerOutput.firstBytesEvent$.pipe(Q(),Z(e=>e??db()-this.initedAt)).subscribe(this.events.firstBytes$)).add(e.providerOutput.loadedMetadataEvent$.subscribe(this.events.loadedMetadata$)).add(e.providerOutput.firstFrameEvent$.pipe(Q(),Z(()=>db()-this.initedAt)).subscribe(this.events.firstFrame$)).add(e.providerOutput.canplay$.pipe(Q(),Z(()=>db()-this.initedAt)).subscribe(this.events.canplay$)).add(this.throughputEstimator.throughput$.subscribe(this.info.throughputEstimation$)).add(this.throughputEstimator.rtt$.subscribe(this.info.rttEstimation$)).add(e.providerOutput.availableSources$.subscribe(this.info.availableSources$));let t=new _b(!1);this.subscription.add(e.providerOutput.seekedEvent$.subscribe(()=>t.next(!1))).add(e.providerOutput.willSeekEvent$.subscribe(()=>t.next(!0)));let n=new _b(!0),r=new pb;this.subscription.add(r).add(e.current$.subscribe(()=>{n.next(!0),r.unsubscribe(),r.add(this.desiredState.playbackState.stateChangeEnded$.pipe(Y(({to:e})=>e===`playing`),Q()).subscribe(()=>n.next(!1)))}));let i=new _b(!1);this.subscription.add(this.desiredState.playbackState.stateChangeEnded$.subscribe(({to:e})=>i.next(e===`paused`)));let a=0,o=0,s=ub(e.providerOutput.isBuffering$,t,n,i).pipe(Z(()=>{let r=e.providerOutput.isBuffering$.getValue(),a=t.getValue()||n.getValue()||this.tuning.stallIgnoreOnPause&&i.getValue();return r&&!a}),X());this.subscription.add(s.subscribe(e=>{let{stallIgnoreThreshold:t,stallHandlingStrategy:n}=this.tuning;e?(o=db(),n===`verbose`&&this.info.stallStartTime$.next(o),a=M.setTimeout(()=>{this.info.isStalled$.next(!0),o&&this.info.stallStartTime$.next(n===`exclude-threshold`?db():o)},t)):(M.clearTimeout(a),this.info.isStalled$.next(!1),o=0,this.info.stallStartTime$.next(0))})),this.subscription.add(ub(e.providerOutput.canplay$,e.providerOutput.firstFrameEvent$,e.providerOutput.firstBytesEvent$).subscribe(()=>{let t=e.providerOutput.element$.getValue();this.setIntrinsicVideoSize({width:t?.videoWidth,height:t?.videoHeight})})).add(e.providerOutput.currentVideoTrack$.subscribe(t=>{var n,r;let i=e.providerOutput.element$.getValue();this.setIntrinsicVideoSize({width:t==null||(n=t.size)==null?void 0:n.width,height:t==null||(r=t.size)==null?void 0:r.height},{width:i?.videoWidth,height:i?.videoHeight})})),this.subscription.add(ub(e.providerOutput.inPiP$,e.providerOutput.inFullscreen$,e.providerOutput.element$,e.providerOutput.elementVisible$,this.chromecastInitializer.castState$).subscribe(()=>{let t=e.providerOutput.inPiP$.getValue(),n=e.providerOutput.inFullscreen$.getValue(),r=e.providerOutput.element$.getValue(),i=e.providerOutput.elementVisible$.getValue(),a=this.chromecastInitializer.castState$.getValue(),o;o=a===`CONNECTED`?`second_screen`:r?i?t?`pip`:n?`fullscreen`:`inline`:`invisible`:`none`,this.info.surface$.getValue()!==o&&this.info.surface$.next(o)}))}initChromecastSubscription(){this.subscription.add(this.chromecastInitializer.castState$.subscribe(this.info.chromecastState$)),this.subscription.add(this.chromecastInitializer.connection$.pipe(Z(e=>e?.castDevice.friendlyName)).subscribe(this.info.chromecastDeviceName$)),this.subscription.add(this.chromecastInitializer.errorEvent$.subscribe(this.events.managedError$))}initStartingVideoTrack(e){let t=new pb;this.subscription.add(t),this.subscription.add(e.current$.pipe(X((e,t)=>e.provider===t.provider)).subscribe(()=>{t.unsubscribe(),t.add(e.providerOutput.availableVideoTracks$.pipe(Y(e=>e.length>0),Q()).subscribe(e=>{this.setStartingVideoTrack(e)}))}))}setStartingVideoTrack(e){let t;this.wasSetStartedQuality=!0;let n=this.explicitInitialQuality??this.info.currentQuality$.getValue();n&&(t=e.find(({quality:e,tvDisabled:t})=>e===n&&!t),t||this.setAutoQuality(!0)),!t&&(t=ka({videoTracks:e,tuning:this.tuning,abrLogger:this.abrLogger,tracer:this.tracer,container:this.domContainer?.getBoundingClientRect()??null,panelSize:this.config.panelSize??null,estimatedThroughput:this.throughputEstimator.throughput$.getValue(),limits:this.desiredState.autoVideoTrackLimits.getState(),playbackRate:this.info.currentPlaybackRate$.getValue(),forwardBufferHealth:0})),this.desiredState.videoTrack.startTransitionTo(t),this.info.currentQuality$.next(t.quality),this.info.videoBitrate$.next(t.bitrate)}initLogs(){this.persistentSubscription.add(ub(this.desiredState.videoTrack.stateChangeStarted$.pipe(Z(e=>({transition:e,entity:`quality`,type:`start`}))),this.desiredState.videoTrack.stateChangeEnded$.pipe(Z(e=>({transition:e,entity:`quality`,type:`end`}))),this.desiredState.autoVideoTrackSwitching.stateChangeStarted$.pipe(Z(e=>({transition:e,entity:`autoQualityEnabled`,type:`start`}))),this.desiredState.autoVideoTrackSwitching.stateChangeEnded$.pipe(Z(e=>({transition:e,entity:`autoQualityEnabled`,type:`end`}))),this.desiredState.seekState.stateChangeStarted$.pipe(Z(e=>({transition:e,entity:`seekState`,type:`start`}))),this.desiredState.seekState.stateChangeEnded$.pipe(Z(e=>({transition:e,entity:`seekState`,type:`end`}))),this.desiredState.playbackState.stateChangeStarted$.pipe(Z(e=>({transition:e,entity:`playbackState`,type:`start`}))),this.desiredState.playbackState.stateChangeEnded$.pipe(Z(e=>({transition:e,entity:`playbackState`,type:`end`})))).pipe(Z(e=>({component:`desiredState`,message:`[${e.entity} change] ${e.type}: ${JSON.stringify(e.transition)}`}))).subscribe(this.logger.log)),this.persistentSubscription.add(this.logger.log$.subscribe(this.events.log$))}initDebugTelemetry(){let e=this.providerContainer?.providerOutput;qy(this.providerContainer),qy(e),Mp(),this.experimental.enableDebugTelemetry$.next(this.tuning.enableTelemetryAtStart),[this.experimental.enableDebugTelemetry$.subscribe(e=>jp(e)),this.providerContainer.current$.subscribe(({type:e})=>Pp(`provider`,e)),e.duration$.subscribe(e=>Pp(`duration`,e)),e.availableVideoTracks$.pipe(Y(e=>!!e.length),Q()).subscribe(e=>Pp(`tracks`,e)),this.events.fatalError$.subscribe(new Fp(`fatalError`)),this.events.managedError$.subscribe(new Fp(`managedError`)),e.position$.subscribe(new Fp(`position`)),e.currentVideoTrack$.pipe(Z(e=>e?.quality)).subscribe(new Fp(`quality`)),this.info.currentVirtualVideoBuffer$.subscribe(new Fp(`buffer`)),e.isBuffering$.subscribe(new Fp(`isBuffering`))].forEach(e=>this.subscription.add(e)),Pp(`codecs`,P.video.supportedCodecs)}initTracerSubscription(){let e=tb(this.tracer.log.bind(this.tracer)),t=tb(this.tracer.error.bind(this.tracer));this.subscription.add(this.info.playbackState$.subscribe(e(`playbackState`))).add(this.info.isLooped$.subscribe(e(`isLooped`))).add(this.info.currentPlaybackRate$.pipe(X()).subscribe(e(`currentPlaybackRate`))).add(this.info.isAutoQualityEnabled$.subscribe(e(`isAutoQualityEnabled`))).add(this.info.autoQualityLimits$.subscribe(e(`autoQualityLimits`))).add(this.info.currentFormat$.subscribe(e(`currentFormat`))).add(this.info.availableQualities$.subscribe(e(`availableQualities`))).add(this.info.availableQualitiesFps$.subscribe(e(`availableQualitiesFps`))).add(this.info.availableAudioTracks$.subscribe(e(`availableAudioTracks`))).add(this.info.isAudioAvailable$.subscribe(e(`isAudioAvailable`))).add(Jy({currentQuality:this.info.currentQuality$,videoBitrate:this.info.videoBitrate$}).pipe(Y(({currentQuality:e,videoBitrate:t})=>!!e&&!!t),X((e,t)=>e.currentQuality===t.currentQuality)).subscribe(e(`currentVideoTrack`))).add(this.info.currentVideoSegmentLength$.pipe(Y(e=>e>0),X()).subscribe(e(`currentVideoSegmentLength`))).add(this.info.currentAudioSegmentLength$.pipe(Y(e=>e>0),X()).subscribe(e(`currentAudioSegmentLength`))).add(this.info.hostname$.subscribe(e(`hostname`))).add(this.info.currentTextTrack$.pipe(X()).subscribe(e(`currentTextTrack`))).add(this.info.availableTextTracks$.subscribe(e(`availableTextTracks`))).add(this.info.autoQualityLimitingAvailable$.subscribe(e(`autoQualityLimitingAvailable`))).add(Jy({currentBuffer:this.info.currentVirtualVideoBuffer$.pipe(Y(e=>e.end>0),X((e,t)=>e.end===t.end&&e.start===t.start)),position:this.info.position$.pipe(X())}).pipe(hb(1e3)).subscribe(e(`currentBufferAndPosition`))).add(this.info.duration$.pipe(X()).subscribe(e(`duration`))).add(this.info.isBuffering$.subscribe(e(`isBuffering`))).add(this.info.isLive$.pipe(X()).subscribe(e(`isLive`))).add(this.info.canChangePlaybackSpeed$.pipe(X()).subscribe(e(`canChangePlaybackSpeed`))).add(Jy({liveTime:this.info.liveTime$,liveBufferTime:this.info.liveBufferTime$,position:this.info.position$}).pipe(Y(({liveTime:e,liveBufferTime:t})=>!!e&&!!t),hb(1e3)).subscribe(e(`liveBufferAndPosition`))).add(this.info.atLiveEdge$.pipe(X(),Y(e=>e===!0)).subscribe(e(`atLiveEdge`))).add(this.info.atLiveDurationEdge$.pipe(X(),Y(e=>e===!0)).subscribe(e(`atLiveDurationEdge`))).add(this.info.muted$.pipe(X()).subscribe(e(`muted`))).add(this.info.volume$.pipe(X()).subscribe(e(`volume`))).add(this.info.isEnded$.pipe(X(),Y(e=>e===!0)).subscribe(e(`isEnded`))).add(this.info.availableSources$.subscribe(e(`availableSources`))).add(Jy({throughputEstimation:this.info.throughputEstimation$,rtt:this.info.rttEstimation$}).pipe(Y(({throughputEstimation:e,rtt:t})=>!!e&&!!t),hb(3e3)).subscribe(e(`throughputEstimation`))).add(this.info.isStalled$.subscribe(e(`isStalled`))).add(this.info.surface$.subscribe(e(`surface`))).add(this.events.ended$.subscribe(e(`ended`))).add(this.events.looped$.subscribe(e(`looped`))).add(this.events.managedError$.subscribe(t(`managedError`))).add(this.events.fatalError$.subscribe(t(`fatalError`))).add(this.events.firstBytes$.subscribe(e(`firstBytes`))).add(this.events.firstFrame$.subscribe(e(`firstFrame`))).add(this.events.canplay$.subscribe(e(`canplay`)))}initWakeLock(){var e=this;let t=nb();if(!t.navigator.wakeLock||!this.tuning.enableWakeLock)return;let n,r=()=>{n?.release(),n=void 0},i=function(){var t=E(function*(){r(),n=yield window.navigator.wakeLock.request(`screen`).catch(t=>{t instanceof DOMException&&t.name===`NotAllowedError`||e.events.managedError$.next({id:`WakeLock`,category:Xy.DOM,message:String(t)})})});return function(){return t.apply(this,arguments)}}();this.subscription.add(ub(Qy(t.document,`visibilitychange`),Qy(t.document,`fullscreenchange`),this.desiredState.playbackState.stateChangeEnded$).subscribe(()=>{let e=t.document.visibilityState===`visible`,a=this.desiredState.playbackState.getState()===`playing`,o=!!n&&!n?.released;e&&a?o||i():r()})).add(this.events.willDestruct$.subscribe(r))}setVideoTrackIdByQuality(e,t){let n=e.find(e=>e.quality===t);this.tracer.log(`setVideoTrackIdByQuality`,Zy({quality:t,availableTracks:Zy(e),track:Zy(n),isAutoQuality:!n})),n?n.tvDisabled?(this.setAutoQuality(!0),this.events.managedError$.next({id:`SetQualityTrackTvDisabled`,category:Xy.WTF,message:`Set quality was called on track with tvDisabled flag`})):this.desiredState.videoTrack.startTransitionTo(n):this.setAutoQuality(!0)}getActiveLiveDelay(e=!1){return e?this.tuning.live.lowLatencyActiveLiveDelay:this.tuning.live.activeLiveDelay}isNotActiveTabCase(){return nb().document.hidden&&this.tuning.autoplayOnlyInActiveTab&&!Wo()}}var Hx=`@vkontakte/videoplayer-core@${k}`;;return{ie,ae,Rx,A,Ix,se,Hx,zx,Lx,oe,k,Bx,re,ne,Vx,Jo,Ht,P,pt};}();var{ie:_oxcMod2xiscv_ie,ae:_oxcMod2xiscv_ae,Rx:_oxcMod2xiscv_Rx,A:_oxcMod2xiscv_A,Ix:_oxcMod2xiscv_Ix,se:_oxcMod2xiscv_se,Hx:_oxcMod2xiscv_Hx,zx:_oxcMod2xiscv_zx,Lx:_oxcMod2xiscv_Lx,oe:_oxcMod2xiscv_oe,k:_oxcMod2xiscv_k,Bx:_oxcMod2xiscv_Bx,re:_oxcMod2xiscv_re,ne:_oxcMod2xiscv_ne,Vx:_oxcMod2xiscv_Vx,Jo:_oxcMod2xiscv_Jo,Ht:_oxcMod2xiscv_Ht,P:_oxcMod2xiscv_P,pt:_oxcMod2xiscv_pt}=_oxcMod2xiscv;export{_oxcMod2xiscv_ie as ChromecastState,_oxcMod2xiscv_ae as HttpConnectionType,_oxcMod2xiscv_Rx as Observable,_oxcMod2xiscv_A as PlaybackState,_oxcMod2xiscv_Ix as Player,_oxcMod2xiscv_se as PredefinedQualityLimits,_oxcMod2xiscv_Hx as SDK_VERSION,_oxcMod2xiscv_zx as Subject,_oxcMod2xiscv_Lx as Subscription,_oxcMod2xiscv_oe as Surface,_oxcMod2xiscv_k as VERSION,_oxcMod2xiscv_Bx as ValueSubject,_oxcMod2xiscv_re as VideoCodecName,_oxcMod2xiscv_ne as VideoFormat,_oxcMod2xiscv_Vx as VideoQuality,_oxcMod2xiscv_Jo as WebmCodecStrategy,_oxcMod2xiscv_Ht as areValidLiveRecordSources,_oxcMod2xiscv_P as clientChecker,_oxcMod2xiscv_pt as isMobile};
40
+ ===== DASH_LIVE DEBUG END ====`),n){let t=e.reduce((e,{time:t,data:n,stack:r})=>{let i=fn(n).map(([e,t])=>`${e}:${t}`).join(`,`);return e+=`${t}: ${i}${r?`: ${r}`:``};`,e},``);dv.push(`core`,{key:`vp_dash_live_debug`,strings:[t]})}};return e.add(this.providerError$.subscribe(e=>{e.id.startsWith(`ProviderHangup`)&&(R({m:`final.0`,e:e.id}),t())})).add(this.noAvailableProvidersError$.subscribe(()=>{R({m:`final.1`}),t()})),e.add(this.mayday.recommendation$.subscribe(({error:e,recommendation:t})=>{let n=this.current$.getValue().destination??`SCREEN`;if(this.handleMaydayRecommendation(t,n),t.action!==`wait`){let t={error:e,currentDestination:n};e.traceAsLog?this.tracer.log(`providerInfo`,uv(t)):this.tracer.error(`providerError`,uv(t))}})),e.add(this.providerError$.subscribe(e=>{let t=this.current$.getValue(),{destination:n}=t;n===`CHROMECAST`?(this.destroyProvider(),this.params.dependencies.chromecastInitializer.stopMedia().then(()=>this.switchToNextProvider(`CHROMECAST`),()=>this.params.dependencies.chromecastInitializer.disconnect())):(this.applyErrorSideEffects(e,t.type),this.mayday.handleError(e))})),e}}var Ny=`vk_uvp_throughput`,Py=`vk_uvp_rtt`,Fy=`one_video_throughput`,Iy=`one_video_rtt`,Ly=()=>{let{navigator:e}=My();if(e)return e.connection},Ry=()=>{let e=Ly()?.downlink;if(ky(e)&&e!==10)return e*1e3},zy=()=>{let e=Ly()?.rtt;if(ky(e)&&e!==3e3)return e},By=(e,t,n)=>{let r=n*8;return r/(r/e+t)};class Vy{constructor(e,t=new Ey(void 0),n){this.throughput=void 0,this.rtt=void 0,this.subscription=new Ty,this.wiring=new Ty,this.throughputVarianceProxy$=new Ey(0),this.currentHost=void 0,this.hasThroughputSamples=!1,this.hasRttSamples=!1,this.storageReadDone=!1,this.tuningConfig=void 0,this.logger=void 0,this.initialThroughputSource=void 0,this.initialRttSource=void 0,this.concurrentDownloads=new Map,this.throughput$=void 0,this.rtt$=void 0,this.rttAdjustedThroughput$=void 0,this.tuningConfig=e,this.logger=n;let r=Vy.resolveInitialThroughput(e),i=Vy.resolveInitialRtt(e);if(n?.({message:`initial state: throughput ${r.value} Kbps (${r.source}), RTT ${i.value} ms (${i.source})`}),this.throughput$=new Ey(r.value),this.rtt$=new Ey(i.value),this.initialThroughputSource=r.source,this.initialRttSource=i.source,this.rttAdjustedThroughput$=new Ey(By(r.value,i.value,e.rttPenaltyRequestSize)),this.throughput=Hp.getSmoothedValue(r.value,-1,e),this.rtt=Hp.getSmoothedValue(i.value,1,e),e.useBrowserEstimation){let e=()=>{if(!this.hasThroughputSamples){let e=Ry();e&&(this.throughput.next(e),this.initialThroughputSource=`browser estimation (downlink)`)}if(!this.hasRttSamples){let e=zy();ky(e)&&(this.rtt.next(e),this.initialRttSource=`browser estimation (rtt)`)}},t=Ly();t&&`onchange`in t&&this.subscription.add(Sy(t,`change`).subscribe(e)),e()}e.cdnCache.enabled&&this.subscription.add(t.subscribe(e=>{ky(e)&&e!==this.currentHost&&(this.currentHost=e,this.tryAdopt())})),this.wireSmoothed()}static readLegacyNumber(e){let t=jy.get(e);if(Ay(t))return;let n=parseInt(t,10);return isNaN(n)?void 0:n}static resolveInitialThroughput(e){let t=e.useBrowserEstimation?Ry():void 0;if(!e.cdnCache.enabled){let e=Vy.readLegacyNumber(Fy);if(e)return{value:e,source:`legacy key one_video_throughput`}}return t?{value:t,source:`browser estimation (downlink)`}:{value:e.initialThroughput,source:`initialThroughput default`}}static resolveInitialRtt(e){let t=e.useBrowserEstimation?zy():void 0;if(!e.cdnCache.enabled){let e=Vy.readLegacyNumber(Iy);if(e!==void 0)return{value:e,source:`legacy key one_video_rtt`}}return t===void 0?{value:0,source:`no data`}:{value:t,source:`browser estimation (rtt)`}}tryAdopt(){if(this.storageReadDone)return;if(this.storageReadDone=!0,this.hasThroughputSamples){this.logger?.call(this,{message:`cache read skipped: throughput samples already flowing — live measurements win`});return}if(Ay(this.currentHost)){this.logger?.call(this,{message:`cache read skipped: delivery host not yet known`});return}let e=Vy.readHostRecord(Ny,this.currentHost,this.tuningConfig),t=Vy.readHostRecord(Py,this.currentHost,this.tuningConfig);if(e.value===void 0&&t.value===void 0){this.logger?.call(this,{message:`host ${this.currentHost}: no valid record (${e.missReason}) — cold start with throughput ${Math.round(this.throughput.smoothed$.getValue())} Kbps, RTT ${Math.round(this.rtt.smoothed$.getValue())} ms`});return}let n=[],r=[];e.value===void 0?r.push(`throughput ${Math.round(this.throughput.smoothed$.getValue())} Kbps (${this.initialThroughputSource})`):n.push(`throughput ${e.value} Kbps`),t.value===void 0?r.push(`RTT ${Math.round(this.rtt.smoothed$.getValue())} ms (${this.initialRttSource})`):n.push(`RTT ${t.value} ms`);let i=`warm start from cache record (${n.join(`, `)})`;this.logger?.call(this,{message:`host ${this.currentHost}: ${r.length?`${i}, ${r.join(`, `)}`:i}`}),this.recreateSmoothed(e.value??this.throughput.smoothed$.getValue(),t.value??this.rtt.smoothed$.getValue())}recreateSmoothed(e,t){this.throughput=Hp.getSmoothedValue(e,-1,this.tuningConfig),this.rtt=Hp.getSmoothedValue(t,1,this.tuningConfig),this.wireSmoothed(),this.rttAdjustedThroughput$.next(By(e,t,this.tuningConfig.rttPenaltyRequestSize))}wireSmoothed(){this.wiring.unsubscribe();let e=new Ty;this.subscription.add(e),this.wiring=e,e.add(this.throughput.smoothed$.subscribe(e=>{this.writeStored(Ny,Fy,e)})),e.add(this.rtt.smoothed$.subscribe(e=>{this.writeStored(Py,Iy,e)})),e.add(this.throughput.debounced$.pipe(Dy(e=>Math.round(e))).subscribe(this.throughput$)),e.add(this.rtt.debounced$.subscribe(this.rtt$)),e.add(wy({throughput:this.throughput.smoothed$,rtt:this.rtt.smoothed$}).pipe(Dy(({throughput:e,rtt:t})=>By(e,t,this.tuningConfig.rttPenaltyRequestSize)),Oy(e=>{let t=this.rttAdjustedThroughput$.getValue()||0;return Math.abs(e-t)/t>=this.tuningConfig.changeThreshold})).subscribe(this.rttAdjustedThroughput$)),e.add(this.throughput.varianceCoefficient$.subscribe(this.throughputVarianceProxy$))}destroy(){this.concurrentDownloads.clear(),this.subscription.unsubscribe()}trackXHR(e){let t=0,n=J(),r=new Ty;switch(this.subscription.add(r),this.concurrentDownloads.set(e,J()),e.readyState){case 4:break;case 3:case 2:r.add(Sy(e,`progress`).pipe(Cy()).subscribe(e=>{t=e.loaded,n=J()}));break;case 1:case 0:r.add(Sy(e,`loadstart`).subscribe(()=>{t=0,n=J()}));break}r.add(Sy(e,`loadend`).subscribe(i=>{if(e.status===200){let e=i.loaded,r=J(),a=e-t,o=r-n;this.addRawSpeed(a,o,1)}this.concurrentDownloads.delete(e),r.unsubscribe()}))}trackStream(e,t=!1){var n=this;let r=e.getReader();if(!r){e.cancel(`Could not get reader`);return}let i=0,a=J(),o=0,s=J(),c=t=>{this.concurrentDownloads.delete(e),r.releaseLock(),e.cancel(`Throughput Estimator error: ${t}`).catch(()=>{})},l=function(){var u=E(function*({done:u,value:d}){if(u){if(!t){let e=n.tuningConfig.measureFastSamples?n.countActiveDownloads(a):1;n.addRawSpeed(i,J()-a,e)}n.concurrentDownloads.delete(e)}else if(d){if(n.tuningConfig.measureFastSamples&&n.concurrentDownloads.set(e,J()),t){let e=J();if(e-s>n.tuningConfig.lowLatency.continuesByteSequenceInterval||e-a>n.tuningConfig.lowLatency.maxLastEvaluationTimeout){let e=s-a;e&&n.addRawSpeed(o,e,1,t),o=d.byteLength,a=J()}else o+=d.byteLength;s=J()}else if(i+=d.byteLength,o+=d.byteLength,o>=n.tuningConfig.streamMinSampleSize&&J()-s>=n.tuningConfig.streamMinSampleTime){let e=n.tuningConfig.measureFastSamples?n.countActiveDownloads(s):n.concurrentDownloads.size;n.addRawSpeed(o,J()-s,e),o=0,s=J()}yield r?.read().then(l,c)}});return function(e){return u.apply(this,arguments)}}();this.concurrentDownloads.set(e,J()),r?.read().then(l,c)}addRawSpeed(e,t,n=1,r=!1){if(this.sanityCheck(e,t,r)){let i=e*8/t*n;if(this.isFastSample(t,r)&&i<this.throughput.smoothed$.getValue())return;this.markSample(),this.throughput.next(i)}}countActiveDownloads(e){let t=0;return this.concurrentDownloads.forEach(n=>{n>=e&&t++}),Math.max(t,1)}isFastSample(e,t){return this.tuningConfig.measureFastSamples&&!t&&e<=this.tuningConfig.cacheThresholdSize}addRawThroughput(e){this.markSample(),this.throughput.next(e)}addRawRtt(e){this.hasRttSamples=!0,this.rtt.next(e)}markSample(){this.hasThroughputSamples=!0,this.tryAdopt()}sanityCheck(e,t,n=!1){let r=e*8/t;return!(!r||!isFinite(r)||r>this.tuningConfig.maxSampleRate||r<30||n&&e<1e4||!n&&e<10*1024&&(!this.tuningConfig.measureNonSegmentRequests||t<this.tuningConfig.smallSampleMinDuration+this.rtt$.getValue())||!n&&!this.tuningConfig.measureFastSamples&&t<=this.tuningConfig.cacheThresholdSize)}get throughputVariance$(){return this.throughputVarianceProxy$}static readHostRecord(e,t,n){let r=jy.get(e);if(Ay(r))return{missReason:`key ${e} missing`};try{let i=JSON.parse(r);if(Ay(i)||typeof i!=`object`)return{missReason:`key ${e} is not a JSON object`};let a=i.hosts?.[t];return!a||typeof a.value!=`number`||typeof a.timestamp!=`number`?{missReason:`no record for host ${t} in ${e}`}:Vy.validateStored(a,n)}catch{return{missReason:`key ${e} contains corrupt JSON`}}}writeStored(e,t,n){if(!this.tuningConfig.cdnCache.enabled){jy.set(t,n.toFixed(0));return}let r=e===Ny?this.hasThroughputSamples:this.hasRttSamples;if(!this.storageReadDone||!r||Ay(this.currentHost))return;let i={},a=jy.get(e);if(ky(a))try{let e=JSON.parse(a);ky(e)&&typeof e==`object`&&(i=xy(by(e.hosts??{}).filter(([,e])=>ky(e)&&typeof e==`object`&&typeof e.value==`number`&&typeof e.timestamp==`number`)))}catch{}i[this.currentHost]={value:Math.round(n),timestamp:Date.now(),networkType:Ly()?.effectiveType};let o=by(i).filter(([e])=>e!==this.currentHost).sort(([,e],[,t])=>t.timestamp-e.timestamp),s=Math.max(1,this.tuningConfig.cdnCache.hostsLimit);for(;o.length+1>s;){let[e]=o.pop();delete i[e]}jy.set(e,JSON.stringify({hosts:i}))}static validateStored(e,t){if(!t.cdnCache.enabled)return{value:e.value};let n=Date.now()-e.timestamp;if(n>t.cdnCache.ttlMs)return{missReason:`record older than TTL (${Math.round(n/6e4)} min)`};let r=Ly()?.effectiveType;return ky(r)&&ky(e.networkType)&&r!==e.networkType?{missReason:`record written with networkType=${e.networkType}, current ${r}`}:{value:e.value}}}var Hy=Vy;var Gy={mayday:{playingUnstableThresholdMs:3e3,heuristics:[],hangupGraceDecayFactor:.5,hangupGraceMinTimeoutMs:0,deferAudibleHangupOnHiddenTab:!1},allowPlayerReuse:!1,useWorkerTimers:[],throughputEstimator:{type:`EmaAndMa`,emaAlphaSlow:.2,emaAlphaFast:.7,emaAlpha:.45,basisTrendChangeCount:10,changeThreshold:.05,useBrowserEstimation:!0,initialThroughput:5e3,measureNonSegmentRequests:!1,rttPenaltyRequestSize:1*1024*1024,streamMinSampleSize:10*1024,streamMinSampleTime:300,smallSampleMinDuration:100,maxSampleRate:1e6,cacheThresholdSize:20,cacheHitTtfbMaxMs:10,measureFastSamples:!1,deviationDepth:20,deviationFactor:.5,lowLatency:{continuesByteSequenceInterval:50,maxLastEvaluationTimeout:300},cdnCache:{enabled:!1,ttlMs:144e5,hostsLimit:10}},autoTrackSelection:{maxBitrateFactorAtEmptyBuffer:4,bitrateFactorAtEmptyBuffer:2.8,minBitrateFactorAtEmptyBuffer:1.5,bitrateAudioFactorAtEmptyBuffer:10,maxBitrateFactorAtFullBuffer:3,bitrateFactorAtFullBuffer:2,minBitrateFactorAtFullBuffer:1,bitrateAudioFactorAtFullBuffer:7,minVideoAudioRatio:5,minAvailableThroughputAudioRatio:5,usePixelRatio:!0,pixelRatioMultiplier:void 0,pixelRatioLogBase:3,pixelRatioLogCoefficients:[1,0,1],limitByContainer:!0,maxContainerSizeFactor:2,containerSizeFactor:1.3,minContainerSizeFactor:1,lazyQualitySwitch:!0,minBufferToSwitchUp:.4,considerPlaybackRate:!1,trackCooldownIncreaseQuality:15e3,trackCooldownDecreaseQuality:3e3,backgroundVideoQualityLimit:Wy.Q_4320P,activeVideoAreaThreshold:.1,highQualityLimit:Wy.Q_720P,trafficSavingLimit:Wy.Q_480P,lowQualityTelemetryLimit:Wy.Q_240P},stallsManager:{enabled:!1,ignoreDynamicAbrForShortVideo:!1,stallDurationNoDataBeforeQualityDecrease:500,stallCountBeforeQualityDecrease:3,resetQualityRestrictionTimeout:1e4,ignoreStallsOnSeek:!0,stallsMetricsHistoryLength:20,maxPossibleStallDuration:3e4,minTvtToBeCounted:120,maxTvtToBeCounted:10800,significantTvt:600,targetStallsDurationPerTvt:1,deviationStallsDurationPerTvt:.5,criticalStallsDurationPerTvt:6,abrAdjustingSpeed:.1,emaAlpha:.6,useTotalStallsDurationPerTvt:!0,useAverageStallsDurationPerTvt:!0,useEmaStallsDurationPerTvt:!0,ignoreStallsOnPause:!1},droppedFramesChecker:{enabled:!1,percentLimit:.1,checkTime:1e3,countLimit:3,tickCountAfterQualityChange:5,qualityUpWaitingTime:5e3,minQualityBanLimit:Wy.Q_480P},dash:{forwardBufferTarget:6e4,forwardBufferTargetAuto:6e4,forwardBufferTargetManual:5*6e4,forwardBufferTargetPreload:5e3,audioBufferAheadOfVideoMs:1e4,seekBiasInTheEnd:2e3,maxSegmentDurationLeftToSelectNextSegment:3e3,minSafeBufferThreshold:.5,bufferPruningSafeZone:1e3,segmentRequestSize:1*1024*1024,maxVirtualBufferSize:250*1024*1024,virtualBufferPruneSize:100*1024*1024,representationSwitchForwardBufferGap:6e4,crashOnStallTimeout:25e3,crashOnStallTWithoutDataTimeout:5e3,restoreBufferBeforeCrashTimeout:1e3,enableSubSegmentBufferFeeding:!0,bufferEmptinessTolerance:100,virtualBufferEmptinessTolerance:100,useBufferQueueVerification:!1,useVirtualBufferImplicitSeek:!1,bufferQueueVerificationMinPosition:2e3,useNewRepresentationSwitch:!1,useDelayedRepresentationSwitch:!1,useSmartRepresentationSwitch:!1,brokenSegmentAppendDetection:!1,brokenSegmentAppendTolerance:100,useFetchPriorityHints:!0,enableBaseUrlSupport:!0,maxSegmentRetryCount:5,sourceOpenTimeout:1e3,vktvAbrThrottle:0,timeupdateEventTickThrottle:300,fetcherBufferOptimisation:!0,usePersistentGaps:!1,abrThrottle:0,useVideoElementWaitingCurrentTimeReassign:!0,stallWatchdogInterval:100,liveUpdateInterval:1e3,liveStallReinitInterval:3e3,ignoreNetworkErrorsOnLoadInit:!1,bufferTolerance:100,useBufferQueueSegmentEndSelection:!1,useBufferGapWatchdog:!1,useNativeBufferGapWatchdog:!1,useZeroAudioBufferLengthWhenAudioManagerExists:!1,jumpToFirstNativeBufferFrame:!1,minNativeBufferSize:5e3,removeTimeShiftFromSegment:500,tickMaintainInterval:100,minSafeBufferToPlay:0,useBufferHoldingOnlyOnStall:!0,useAbrPhases:!1,abrVideoRules:[`fits_container_rule`,`throughput_rule`,`buffer_rule`,`stalls_rule`,`upper_limit_rule`,`lower_limit_rule`],abrAudioRules:[`throughput_rule`,`min_audio_for_video_rule`],useFailoverHostsOnAllProviderCrash:!1,saveData3gQualityLimit:Wy.Q_240P,saveData2gQualityLimit:Wy.Q_144P,useConnectionDataUpperLimit:!1,abandon:{minElapsedMs:1500,bufferSafetyFactor:.8,minLoadedFraction:.15,minBufferToActivateMs:500},bola:{bufferTargetMs:3e4,minBufferMs:1e4,minBufferPerBitrateLevelMs:2e3,placeholderBufferDecay:.99,fallbackSegmentDurationMs:4e3,finiteThresholdMs:6e4,adaptiveBufferTargetK:.5,adaptiveBufferTargetMaxMs:6e4,trimDetectThresholdMs:1e4,antiCascadeDownshift:!0},insufficientBuffer:{thresholdMs:500,gracePeriodAfterPlaybackResetMs:1e3,budgetFactor:.5,fallbackSegmentDurationMs:6e3},videoStreamRepresentaionsFilter:[],filterOnDemandQualityList:!1,dashMaxTvVideoQuality:!1,checkRepresentationCanPlayType:!1,preloadFirstSegment:!1,maxQualityForFirstSegmentPreload:Wy.Q_480P,tracerResumeOnUnexpectedStall:!1,tracerResumeOnLowQuality:!1,recoverStuckSegmentLoading:!1,skipReloadOfFullyBufferedPartiallyEjectedSegments:!1,deferRemoveUntilAbortCompletes:!1},dashCmafLive:{externalStopControl:!1,keepSilentStallWatchdogWhenNotActive:!1,maxActiveLiveOffset:1e4,normalizedTargetMinBufferSize:6e4,normalizedLiveMinBufferSize:5e3,normalizedActualBufferOffset:1e4,offsetCalculationError:3e3,maxLiveDuration:7200,catchupLiveForMutedInactiveTab:!0,lowLatency:{maxTargetOffset:3e3,maxTargetOffsetDeviation:250,playbackCatchupSpeedup:.05,isActiveOnDefault:!1,bufferEstimator:{emaAlpha:.45,changeThreshold:.05,deviationDepth:20,deviationFactor:.5,extremumInterval:5}}},live:{minBuffer:3e3,minBufferSegments:3,lowLatencyMinBuffer:1e3,lowLatencyMinBufferSegments:1,isLiveCatchUpMode:!1,lowLatencyActiveLiveDelay:3e3,activeLiveDelay:5e3,maxPausedTime:5e3,catchupLiveForMutedInactiveTab:!1,disableLiveSeekWithoutOffsetMarker:!1},downloadBackoff:{bufferThreshold:100,start:100,factor:2,max:3*1e3,random:.1},enableWakeLock:!0,enableTelemetryAtStart:!1,userHappinessTriggers:[],forceFormat:void 0,formatsToAvoid:[],disableChromecast:!1,chromecastReceiverId:`07A4434E`,chromecastPresentationApi:!1,useWebmBigRequest:!1,webmCodec:`vp9`,androidPreferredFormat:`dash`,iosPreferredFormat:`hls`,preferCMAF:!1,preferWebRTC:!1,preferMultiStream:!1,preferHDR:!1,bigRequestMinInitSize:50*1024,bigRequestMinDataSize:1*1024*1024,stripRangeHeader:!0,flushShortLoopedBuffers:!0,insufficientBufferRuleMargin:1e4,seekNearDurationBias:1,dashSeekInSegmentDurationThreshold:180*1e3,dashSeekInSegmentAlwaysSeekDelta:1e4,useDelayedPlaybackHangupWithData:!1,playbackHangupNoDataThreshold:5e3,hangupTimeoutMs:5e3,endGapTolerance:300,stallIgnoreThreshold:33,stallHandlingStrategy:`exclude-threshold`,stallIgnoreOnPause:!1,gapWatchdogInterval:50,requestQuick:!1,useHlsJs:!1,disableHlsOnDesktop:!1,useNewSwitchTo:!1,alwaysAbortPreviousSwitch:!1,useDashProviderVirtual:!1,useDashProviderVirtualMobile:!1,useDashLiveProviderVirtual:!1,useDashLiveProviderVirtualMobile:!1,useSafariEndlessRequestBugfix:!0,useSafariOptimisticPositionForLiveEdgeBugfix:!1,isAudioDisabled:!1,autoplayOnlyInActiveTab:!0,autoplayOnlyIfVisible:!0,dynamicImportTimeout:5e3,maxPlaybackTransitionInterval:2e4,providerErrorLimit:3,manifestRetryInterval:300,manifestRetryMaxInterval:1e4,manifestRetryMaxCount:10,audioVideoSyncRate:20,webrtc:{connectionRetryMaxNumber:3},useVolumeMultiplier:!1,ignoreAudioRendererError:!1,useEnableSubtitlesParam:!1,useHlsLiveNewTextManager:!1,exposeInternalsToGlobal:!1,hlsLiveNewTextManagerDownloadThreshold:4e3,disableYandexPiP:!1,asyncResolveClientChecker:!1,changePlaybackStateToPausedWhenEnded:!1,suppressExceptionsInObservables:!0,devNullLogEnabled:!1,collectingDecodingInfoEnabled:!1,sendDashLiveDebug:!1,logDashLiveDebug:!1,reuseOwnVideoElement:!1,reuseOwnVideoElementOnBackgroundTabOnly:!1,handleExtendedNetworkErrorsSet:!1,useDurationFromSegments:!0,ignoreForcePlayResultWhenProviderChanged:!1,hls:{filterOnDemandQualityList:!1},disableSubtitles:!1,audioOnly:!1,clearAudioElementOnDispose:!0,readyOnLoadedMetadata:!1,segmentCache:{mode:`none`,maxTotalSizeBytes:500*1024*1024,evictionThreshold:.9,evictionTargetPercent:.7,evictionBatchMaxBytes:150*1024*1024,quotaExceededEvictPercent:.5,ttlMs:1440*60*1e3,initTtlMs:10080*60*1e3,clearOnErrorStrategy:`once`}},Ky=e=>Uy(e,Gy);var Cb=({seekState:e,position$:t})=>yb(e.stateChangeEnded$.pipe(bb(({to:e})=>e.state===`none`?void 0:(e.position??NaN)/1e3),xb(Sb)),t.pipe(xb(()=>e.getState().state===`none`)));var Tb=e=>{let t=typeof e.container==`string`?document.getElementById(e.container):e.container;return wb(t,`Wrong container or containerId {${e.container}}`),t};var jb=()=>{let e=`mediaCapabilities`in Ab().navigator?Mb:Nb,t=Eb(E(function*(){let t=yield Promise.all(Db(Pb).map(function(){var t=E(function*([t,n]){return{codec:t,supported:yield e(n)}});return function(e){return t.apply(this,arguments)}}())),n=[P.browser.current,...t.map(e=>JSON.stringify(e))].slice(0,16);return kb.push(`core`,{key:`videoplayer_decoding_info`,strings:n}),t}));return()=>Ob(t)},Mb=function(){var e=E(function*(e){if(!e)return Promise.resolve({supported:!1});let t={[`channels`in e?`audio`:`video`]:e};return yield Ab().navigator.mediaCapabilities.decodingInfo(T({type:`media-source`},t))});return function(t){return e.apply(this,arguments)}}(),Nb=e=>{if(!e)return Promise.resolve({supported:!1});let t=Ab().document,n=`channels`in e?t.createElement(`audio`):t.createElement(`video`);return Promise.resolve({supported:n.canPlayType(e?.contentType??``)===`probably`})},Pb={H264:{contentType:`video/mp4; codecs="avc1.4D400C"`,width:720,height:720,bitrate:2886,framerate:30},H265:{contentType:`video/mp4; codecs="hvc1.1.6.L123.B0"`,width:720,height:720,bitrate:2886,framerate:30},VP8:{contentType:`video/webm; codecs="vp8"`,width:720,height:720,bitrate:2886,framerate:30},VP9:{contentType:`video/webm; codecs="vp09.00.10.08"`,width:720,height:720,bitrate:2886,framerate:30},AV1:{contentType:`video/mp4; codecs="av01.0.01M.08"`,width:720,height:720,bitrate:2886,framerate:30},OPUS:{contentType:`audio/ogg; codecs="opus"`,channels:`2`,bitrate:128e3},AAC_LC:{contentType:`audio/mp4; codecs="mp4a.40.2"`,channels:`2`,bitrate:128e3},AC3:{contentType:`audio/mp4; codecs="ac-3"`,channels:`6`,bitrate:128e3},EAC3:{contentType:`audio/mp4; codecs="ec-3"`,channels:`6`,bitrate:128e3},AAC_HE_V1:{contentType:`audio/mp4; codecs="mp4a.40.5"`,channels:`2`,bitrate:128e3},AAC_HE_V2:{contentType:`audio/mp4; codecs="mp4a.40.29"`,channels:`2`,bitrate:128e3},AAC_xHE:{contentType:`audio/mp4; codecs="mp4a.40.42"`,channels:`2`,bitrate:128e3}},Fb={playbackState$:void 0,position$:0,duration$:1/0,playedTime$:0,muted$:!1,volume$:1,availableVideoStreams$:[],currentVideoStream$:void 0,availableVideoTracks$:[],availableQualities$:[],availableQualitiesFps$:{},currentQuality$:void 0,isAutoQualityEnabled$:!0,autoQualityLimitingAvailable$:!1,autoQualityLimits$:{},predefinedQualityLimitType$:`unknown`,availableAudioStreams$:[],currentAudioStream$:void 0,availableAudioTracks$:[],isAudioAvailable$:!0,currentPlaybackRate$:1,currentVirtualVideoBuffer$:{start:0,end:0},currentVideoBuffer$:{start:0,end:0},currentVirtualAudioBuffer$:{start:0,end:0},currentAudioBuffer$:{start:0,end:0},totalBufferDuration$:0,currentNativeVideoBuffer$:{start:0,end:0},currentNativeAudioBuffer$:{start:0,end:0},isBuffering$:!0,isStalled$:!1,stallStartTime$:0,isEnded$:!1,isLooped$:!1,isLive$:void 0,isLiveEnded$:null,canPlayLiveTailBuffer$:!1,canChangePlaybackSpeed$:void 0,atLiveEdge$:void 0,atLiveDurationEdge$:void 0,liveTime$:void 0,liveBufferTime$:void 0,liveLatency$:void 0,currentFormat$:void 0,availableTextTracks$:[],currentTextTrack$:void 0,throughputEstimation$:void 0,rttEstimation$:void 0,videoBitrate$:void 0,hostname$:void 0,httpConnectionType$:void 0,httpConnectionReused$:void 0,httpConnectionMetrics$:void 0,httpDownloadMetrics$:void 0,surface$:`none`,chromecastState$:`NOT_AVAILABLE`,chromecastDeviceName$:void 0,intrinsicVideoSize$:void 0,availableSources$:void 0,currentVideoSegmentLength$:0,currentAudioSegmentLength$:0,debugData$:{volume:0,muted:!1}},Ib={audioStream:void 0,autoVideoTrackLimits:{},autoVideoTrackSwitching:!0,currentTextTrack:void 0,externalTextTracks:[],internalTextTracks:[],isLooped:!1,isLowLatency:!1,playbackRate:1,playbackState:`stopped`,seekState:{state:`none`},videoTrack:void 0,videoStream:void 0,volume:{volume:1,muted:!1}};var Hb=new Set([`has_fatal_error`,`slow_first_frame`,`high_stall_ratio`,`low_quality`]),Ub=e=>typeof e==`string`&&Hb.has(e),Wb=e=>Array.isArray(e)?[...new Set(e.filter(Ub))]:[];var Zb=30,Qb=1.5,$b=3,ex=2e3,tx=1300,nx=.8,rx=.2,ix=(e,t,n,r,i,a,o)=>{let s=new Xb(!1),c=!1,l=!1,u=!1,d=0,f,p=()=>{if(f!==void 0){let e=Math.trunc(Math.max(0,o()-f));l&&(d+=e),f=void 0}},m=()=>{p();let e=n.getValue();e>Zb&&d/e>a&&s.next(!0)},h=()=>{l=!0,f!==void 0&&(f=o())};return i.add(e.stallStartTime$.subscribe(e=>{e>0?f=e:p()})).add(t.firstBytes$.subscribe(()=>{c=!0})).add(e.currentVideoBuffer$.subscribe(e=>{!l&&c&&e&&e.end-e.start>0&&h()})).add(t.firstFrame$.subscribe(()=>{!l&&c&&h()})).add(t.willSeek$.subscribe(()=>{u=!0,p()})).add(t.seeked$.subscribe(()=>{!u&&f!==void 0&&l&&p(),u=!1})).add(t.willStop$.subscribe(()=>{l&&p()})).add(r.pipe(Yb(Boolean)).subscribe(m)).add(p),s};var ox=(e,t)=>{let n=new ax(!1);return t.add(e.fatalError$.subscribe(()=>{n.getValue()||n.next(!0)})),n};var ux={[lx.Q_144P]:0,[lx.Q_240P]:1,[lx.Q_360P]:2,[lx.Q_480P]:3,[lx.Q_720P]:4,[lx.Q_1080P]:5,[lx.Q_1440P]:6,[lx.Q_2160P]:7,[lx.Q_4320P]:8},dx=[281,452,967,2300,2551,4483,8965],fx=[196.4,357.7,595.6,1108,2100,7850,16770],px=[245,424,641,1140,2048,3935,7469],mx=e=>{if(!e||!Number.isFinite(e.width)||!Number.isFinite(e.height)||e.width<=0||e.height<=0)return;let{width:t,height:n}=e;if(t<=256&&n<=144)return 0;if(t<=426&&n<=240)return 1;if(t<=640&&n<=360)return 2;if(t<=853&&n<=480)return 3;if(t<=1280&&n<=720)return 4;if(t<=1920&&n<=1080)return 5;if(t<=2560&&n<=1440)return 6;if(t<=3840&&n<=2160)return 7},hx=(e,t)=>e===void 0||!Number.isFinite(e)||e<0?7:(t===`DASH_WEBM`||t===`DASH_LIVE_WEBM`?fx:t===`DASH_WEBM_AV1`?px:dx).reduce((t,n)=>e>=n?t+1:t,0),gx=e=>e?ux[e]:void 0,_x=e=>{let t=e.reduce((e,t)=>Math.max(e,gx(t)??-1),-1);return t<0?void 0:t},vx=(e,t)=>{if(e===`invisible`)return 0;if(t)return 3;switch(e){case`fullscreen`:case`second_screen`:return 5;case`pip`:return 1;default:return 3}},yx=(e,t)=>{if(e!==`inline`)return vx(e,!1);switch(t){case`mvk`:return 3;case`smart_tv`:return 5;case`web2`:return 4}},bx=(e,t,n)=>{let r=_x(n);return r===void 0?void 0:Math.min(vx(e,t),r)},xx=(e,t,n)=>{let r=yx(e,n.platform),i=mx(n.viewportSize);e!==`invisible`&&i!==void 0&&(r=i);let a=_x(t);return a===void 0?void 0:Math.min(Math.min(r,a),hx(n.throughputKbps,n.format))},Sx=(e,t,n,r)=>{if(r<=0)return;let i=Math.max(0,n-(t??n)),a=i===0?0:2**(i-1);e.requiredQualityTotalSeconds+=r,e.qualityScoreFineSeconds+=a*r},Cx=e=>{if(!(e.requiredQualityTotalSeconds<=0))return e.qualityScoreFineSeconds/e.requiredQualityTotalSeconds},wx=(e,t,n)=>{if(!(e.totalSeconds<=0||t.totalSeconds<=0||e.totalSeconds!==t.totalSeconds))return e.rankSeconds*t.totalSeconds-t.rankSeconds*(e.totalSeconds-e.unknownSeconds)>=-n*e.totalSeconds*t.totalSeconds},Tx=(e,t,n,r,i,a,o)=>{let s=new cx(!1),c={requiredQualityTotalSeconds:0,qualityScoreFineSeconds:0},l={totalSeconds:0,rankSeconds:0,unknownSeconds:0},u={totalSeconds:0,rankSeconds:0},d=e.currentQuality$.getValue(),f=e.isAutoQualityEnabled$.getValue(),p=!1,m=e.surface$.getValue(),h=e.isLive$.getValue()??!1,g=e.availableQualities$.getValue(),_=e.currentFormat$.getValue(),v=e.throughputEstimation$.getValue(),y,b,x=n.getValue(),S=e=>{if(e<=0||p)return;if(!f){p=!0;return}let t=gx(d);l.totalSeconds+=e,t===void 0?l.unknownSeconds+=e:l.rankSeconds+=t*e;let n=bx(m,h,g);if(n!==void 0&&(u.totalSeconds+=e,u.rankSeconds+=n*e),!h){let n=xx(m,g,{viewportSize:y,throughputKbps:v,format:_,platform:o});n!==void 0&&Sx(c,t,n,e)}},C=()=>{let e=n.getValue();S(e-x),x=e};return i.add(e.currentQuality$.subscribe(e=>{C(),d=e})).add(e.isAutoQualityEnabled$.subscribe(e=>{C(),f=e})).add(e.surface$.subscribe(e=>{C(),m=e})).add(e.isLive$.subscribe(e=>{C(),h=e??!1})).add(e.availableQualities$.subscribe(e=>{C(),g=e})).add(e.currentFormat$.subscribe(e=>{C(),_=e})).add(e.throughputEstimation$.subscribe(e=>{C(),v=e})).add(t.element$.subscribe(e=>{C(),b?.disconnect(),b=void 0,y=void 0,e&&typeof ResizeObserver<`u`&&(b=new ResizeObserver(t=>{let n=t.find(({target:t})=>t===e);if(!n)return;let{width:r,height:i}=n.contentRect,a=r>0&&i>0?{width:r,height:i}:void 0;(y?.width!==a?.width||y?.height!==a?.height)&&(C(),y=a)}),b.observe(e))})).add(n.subscribe(C)).add(r.pipe(sx(Boolean)).subscribe(()=>{if(C(),!(!(n.getValue()>Zb)||p||s.getValue())){if(c.requiredQualityTotalSeconds>0){let e=Cx(c),t=e===void 0?void 0:1-e;t!==void 0&&t<a.minQualityScore&&s.next(!0);return}wx(l,u,a.allowedDeficitRank)===!1&&s.next(!0)}})).add(()=>b?.disconnect()),s};var Dx=(e,t,n)=>{let r=new Ex(!1);return t.add(e.firstFrame$.subscribe(e=>{e>n&&!r.getValue()&&r.next(!0)})),r};var jx=(e,t,n,r)=>{let i=new Ax(0),a=new Ax(0);return n.add(i.subscribe(e=>{a.next(e/1e3)})),n.add(Ox({info:e,events:t},r).subscribe(r=>{n.add(kx(t.started$,t.playing$,t.paused$,t.willSeek$,t.ended$,t.willDestruct$,e.currentPlaybackRate$,e.position$).subscribe(()=>i.next(r())))})),a};class Mx{constructor(e,t,n,r,i,a){this.subscription=new qb,this.sessionFinalized$=new Jb(!1),this.lowQuality$=void 0,this.highStallRatio$=void 0,this.hasFatalError$=void 0,this.slowFirstFrame$=void 0;let o=r.some(e=>e===`low_quality`||e===`high_stall_ratio`)?jx(e,t,this.subscription,Kb):new Jb(0);this.lowQuality$=Gb(r,`low_quality`)?Tx(e,n,o,this.sessionFinalized$,this.subscription,i,a):new Jb(!1),this.highStallRatio$=Gb(r,`high_stall_ratio`)?ix(e,t,o,this.sessionFinalized$,this.subscription,i.maxStallRatio,Kb):new Jb(!1),this.hasFatalError$=Gb(r,`has_fatal_error`)?ox(t,this.subscription):new Jb(!1),this.slowFirstFrame$=Gb(r,`slow_first_frame`)?Dx(t,this.subscription,i.maxFirstFrameTimeMs):new Jb(!1)}destroy(){this.finalizeSession(),this.subscription.unsubscribe()}finalizeSession(){this.sessionFinalized$.getValue()||this.sessionFinalized$.next(!0)}}var Nx=e=>({maxFirstFrameTimeMs:e?tx:ex,maxStallRatio:e?$b:Qb,minQualityScore:nx,allowedDeficitRank:rx}),Px=(e,t)=>t?`smart_tv`:e?`mvk`:`web2`;class Fx{constructor(e,t,n,r,i){this.subscription=new Vb,this.observer=void 0;let a=Wb(i);if(a.length===0)return;let o=P.device.isMobile&&!P.device.isTablet;this.observer=new Mx(e,t,n,a,Nx(o),Px(o,P.device.isSmartTV));let s={has_fatal_error:this.observer.hasFatalError$,slow_first_frame:this.observer.slowFirstFrame$,high_stall_ratio:this.observer.highStallRatio$,low_quality:this.observer.lowQuality$},c=zb(...a.map(e=>s[e].pipe(Lb(Boolean),Rb(e))));this.subscription.add(c.subscribe(e=>{r.setSpanAttributes({[e]:!0})})).add(c.pipe(Bb()).subscribe(()=>r.resume()))}destroy(){this.observer?.destroy(),this.subscription.unsubscribe()}}class Ix{constructor(e={},t=gb.createRootTracer(`fake`),n){this.subscription=new pb,this.persistentSubscription=new pb,this.domContainer=null,this.providerContainer=void 0,this.chromecastInitializer=void 0,this.logger=new cb,this.tracer=void 0,this.abrLogger=this.logger.createComponentLog(`ABR`),this.config=void 0,this.tuning=void 0,this.throughputEstimator=void 0,this.internalsExposure=null,this.isPlaybackStarted=!1,this.suppressWillStop=!1,this.initedAt=void 0,this.hasLiveOffsetByPaused=new _b(!1),this.hasLiveOffsetByPausedTimer=0,this.playerInitRequest=0,this.playerInited=new _b(!1),this.explicitInitialQuality=void 0,this.wasSetStartedQuality=!1,this.desiredState=ce(Ib).reduce((e,[t,n])=>(e[t]=new yn(n),e),{}),this.info=ce(Fb).reduce((e,[t,n])=>(e[t]=new _b(n),e),{}),this.userHappinessController=void 0,this.events={inited$:new $,ready$:new $,started$:new $,playing$:new $,paused$:new $,stopped$:new $,willReady$:new $,willStart$:new $,willResume$:new $,willPause$:new $,willStop$:new $,willDestruct$:new $,watchCoverageRecord$:new $,watchCoverageLive$:new $,managedError$:new $,fatalError$:new $,fetcherRecoverableError$:new $,ended$:new $,looped$:new $,seeked$:new $,willSeek$:new $,autoplaySoundProhibited$:new $,manifestRequested$:new $,firstBytesManifest$:new $,manifestReceived$:new $,firstBytesRequested$:new $,firstBytesReceived$:new $,firstBytes$:new $,loadedMetadata$:new $,firstFrame$:new $,canplay$:new $,log$:new $,fetcherError$:new $,severeStallOccured$:new $},this.experimental={element$:new _b(void 0),enableDebugTelemetry$:new _b(!1),dumpTelemetry:Np,getCurrentTime$:new _b(null),skipVideoElVolumeSync$:new _b(!1)},this.devNullLog=void 0,this.collectDecodingInfoDestroyCb=void 0,this.releaseTimers=void 0,this.doInit=e=>{let{container:t}=e,n=D(e,w);this.tracer.log(`initVideo`,Zy(n),!0),this.domContainer=Tb(e),this.chromecastInitializer.contentId=e.meta?.videoId,this.providerContainer=new yy({sources:e.sources,meta:e.meta??{},failoverHosts:e.failoverHosts??[],container:this.domContainer,desiredState:this.desiredState,dependencies:{throughputEstimator:this.throughputEstimator,chromecastInitializer:this.chromecastInitializer,tracer:this.tracer,logger:this.logger,abrLogger:this.abrLogger},tuning:this.tuning,volumeMultiplier:e.volumeMultiplier,panelSize:e.panelSize,skipVideoElVolumeSync$:this.experimental.skipVideoElVolumeSync$,handleNetworkRecoverableErrorAsProviderError:e.handleNetworkRecoverableErrorAsProviderError}),this.initProviderContainerSubscription(this.providerContainer),this.initStartingVideoTrack(this.providerContainer),this.providerContainer.init(),this.setLiveLowLatency(this.tuning.dashCmafLive.lowLatency.isActiveOnDefault),this.initDebugTelemetry(),this.initWakeLock(),this.playerInited.next(!0),this.devNullLog&&this.tuning.devNullLogEnabled?(Yy.subscribe(`core`,this.devNullLog),this.tuning.collectingDecodingInfoEnabled&&(this.collectDecodingInfoDestroyCb=jb())):Yy.destroy(`core`)},this.initLogs(),this.tuning=Ky(e),this.tracer=t,this.userHappinessController=this.createUserHappinessController(),this.releaseTimers=fb(this.tuning.useWorkerTimers),this.tuning.suppressExceptionsInObservables&&(le(this.info).forEach(e=>e.setSuppressErrors(!0)),le(this.events).forEach(e=>e.setSuppressErrors(!0)));let r={receiverApplicationId:this.tuning.chromecastReceiverId,isDisabled:this.tuning.disableChromecast,dependencies:{logger:this.logger}};if(this.chromecastInitializer=this.tuning.chromecastPresentationApi?new un(r):new Ee(r),this.throughputEstimator=new Hy(this.tuning.throughputEstimator,this.info.hostname$,this.logger.createComponentLog(`ThroughputEstimator`)),e.exposeInternalsToGlobal&&(this.internalsExposure=new rb(`core`,$y(n?.playerId)),this.internalsExposure.expose({player:this,getTimersDiagnostics:eb})),this.initChromecastSubscription(),this.initDesiredStateSubscriptions(),this.initDebugDataSubscriptions(),this.devNullLog=n?.onDevNullLog,Yy.create(`core`),Proxy&&Reflect)return new Proxy(this,{get:(e,t,n)=>{let r=Reflect.get(e,t,n);return typeof r==`function`?(...n)=>{try{return r.apply(e,n)}catch(e){let r=n.map(e=>JSON.stringify(e,(e,t)=>{let n=typeof t;return ue([`number`,`string`,`boolean`],n)?t:t===null?null:`<${n}>`})),i=`Player.${String(t)}`,a=`Exception calling ${i} (${r.join(`, `)})`;throw this.events.fatalError$.next({id:i,category:Xy.WTF,message:a,thrown:e}),e}}:r}})}resetDesiredState(){let e=(e,t)=>{e.setState(t)};Object.keys(this.desiredState).forEach(t=>{e(this.desiredState[t],Ib[t])})}createUserHappinessController(){return new Fx(this.info,this.events,this.experimental,this.tracer,this.tuning.userHappinessTriggers)}reset(){this.subscription.unsubscribe(),this.providerContainer?.destroy(),this.providerContainer=void 0,this.userHappinessController.destroy(),M.clearTimeout(this.hasLiveOffsetByPausedTimer),this.collectDecodingInfoDestroyCb?.call(this),this.playerInited.next(!1),this.resetDesiredState();let e=(e,t)=>{e.next(t)},t=[`muted$`,`volume$`];Object.keys(this.info).forEach(n=>{ue(t,n)?e(this.info[n],this.info[n].getValue()):e(this.info[n],Fb[n])}),this.userHappinessController=this.createUserHappinessController()}initAudio(e){return this.initVideo(T(T({},e),{},{container:e.audioElement??document.createElement(`audio`)}))}initVideo(e){let t=nb();this.config=e,this.internalsExposure?.expose({config:e,logger:this.logger,tuning:this.tuning}),this.setMuted(e.isMuted??this.tuning.isAudioDisabled);let n=()=>{this.tuning.autoplayOnlyIfVisible&&t.requestAnimationFrame?this.playerInitRequest=t.requestAnimationFrame(()=>this.doInit(e)):this.doInit(e)},r=()=>{this.tuning.asyncResolveClientChecker?P.isInited$.pipe(Y(e=>!!e),Q()).subscribe(()=>{console.log(`Core SDK async start`),n()}):n()};return this.isNotActiveTabCase()?(this.tracer.log(`request play from hidden tab`),Qy(t.document,`visibilitychange`).pipe(Q()).subscribe(r)):r(),this}destroy(e){let t=nb();this.tracer.log(`destroy`),M.clearTimeout(this.hasLiveOffsetByPausedTimer),this.playerInitRequest&&t.cancelAnimationFrame(this.playerInitRequest),this.events.willDestruct$.next(),this.suppressWillStop=e?.reportStop===!1,this.stop(),this.providerContainer?.destroy(),this.userHappinessController.destroy(),this.throughputEstimator.destroy(),this.chromecastInitializer.destroy(),this.subscription.unsubscribe(),this.persistentSubscription.unsubscribe(),this.tracer.end(),this.internalsExposure?.destroy(),Yy.destroy(`core`),this.collectDecodingInfoDestroyCb?.call(this),this.releaseTimers()}waitInit(e){this.playerInited.getValue()?e():this.subscription.add(this.playerInited.pipe(Y(e=>!!e),Q()).subscribe(e))}prepare(){return this.waitInit(()=>{let e=this.desiredState.playbackState;this.tracer.log(`prepare`,{currentPlayBackState:e.getState()}),e.getState()===`stopped`&&e.startTransitionTo(`ready`)}),this}play(){return this.waitInit(()=>{let e=this.desiredState.playbackState;this.tracer.log(`play`,{currentPlayBackState:e.getState()}),e.getState()!==`playing`&&e.startTransitionTo(`playing`)}),this}pause(){return this.waitInit(()=>{let e=this.desiredState.playbackState;this.tracer.log(`pause`,{currentPlayBackState:e.getState()}),e.getState()!==`paused`&&e.startTransitionTo(`paused`)}),this}stop(){return this.waitInit(()=>{let e=this.desiredState.playbackState;this.tracer.log(`stop`,{currentPlayBackState:e.getState()}),e.getState()!==`stopped`&&(e.startTransitionTo(`stopped`),this.tuning.allowPlayerReuse&&this.reset())}),this}seekTime(e,t=!0){return this.waitInit(()=>{let n=this.info.duration$.getValue(),r=this.info.isLive$.getValue(),i=e;e>=n&&!r&&(i=n-this.tuning.seekNearDurationBias),i<0&&!r&&(i=0),this.tracer.log(`seekTime`,{duration:n,isLive:r,time:e,calculatedTime:i,forcePrecise:t}),Number.isFinite(i)&&(this.events.willSeek$.next({from:this.getExactTime(),to:i}),this.desiredState.seekState.setState({state:`requested`,position:i*1e3,forcePrecise:t}))}),this}seekPercent(e){return this.waitInit(()=>{let t=this.info.duration$.getValue();this.tracer.log(`seekPercent`,{percent:e,duration:t}),isFinite(t)&&this.seekTime(Math.abs(t)*e,!1)}),this}setVolume(e,t,n=!1){return this.waitInit(()=>{this.experimental.skipVideoElVolumeSync$.next(n);let r=this.desiredState.volume,i=r.getTransition()?.to.muted??this.info.muted$.getValue(),a=t??(this.tuning.isAudioDisabled||i);this.tracer.log(`setVolume`,{volume:e,isAudioDisabled:this.tuning.isAudioDisabled,chromecastState:this.chromecastInitializer.castState$.getValue(),muted:a}),this.chromecastInitializer.castState$.getValue()===`CONNECTED`&&!(this.chromecastInitializer instanceof un)?this.chromecastInitializer.setVolume(e):r.startTransitionTo({volume:e,muted:a})}),this}setMuted(e,t=!1,n=!1){return this.waitInit(()=>{this.experimental.skipVideoElVolumeSync$.next(n);let r=this.desiredState.volume,i=this.tuning.isAudioDisabled&&!t||e,a=r.getTransition()?.to.volume??this.info.volume$.getValue();this.tracer.log(`setMuted`,{isMuted:e,nextMuted:i,volume:a,isAudioDisabled:this.tuning.isAudioDisabled,chromecastState:this.chromecastInitializer.castState$.getValue()}),this.chromecastInitializer.castState$.getValue()===`CONNECTED`&&!(this.chromecastInitializer instanceof un)?this.chromecastInitializer.setMuted(i):r.startTransitionTo({volume:a,muted:i})}),this}setVideoStream(e){return this.waitInit(()=>{this.desiredState.videoStream.startTransitionTo(e)}),this}setAudioStream(e){return this.waitInit(()=>{this.desiredState.audioStream.startTransitionTo(e)}),this}setQuality(e){return this.waitInit(()=>{qy(this.providerContainer);let t=this.providerContainer.providerOutput.availableVideoTracks$.getValue();this.tracer.log(`setQuality`,{isDelayed:t.length===0,quality:e}),this.desiredState.videoTrack.getState()===void 0&&this.desiredState.videoTrack.getPrevState()===void 0&&t.length===0?this.wasSetStartedQuality?this.providerContainer.providerOutput.availableVideoTracks$.pipe(Y(e=>e.length>0),Q()).subscribe(t=>{this.setVideoTrackIdByQuality(t,e)}):this.explicitInitialQuality=e:t.length>0&&this.setVideoTrackIdByQuality(t,e)}),this}setAutoQuality(e){return this.waitInit(()=>{this.tracer.log(`setAutoQuality`,{enable:e}),this.desiredState.autoVideoTrackSwitching.startTransitionTo(e)}),this}setAutoQualityLimits(e){return this.waitInit(()=>{this.tracer.log(`setAutoQualityLimits`,Zy(e)),this.desiredState.autoVideoTrackLimits.startTransitionTo(e)}),this}setPredefinedQualityLimits(e){return this.waitInit(()=>{if(this.info.predefinedQualityLimitType$.getValue()===e)return this;let{highQualityLimit:t,trafficSavingLimit:n}=this.tuning.autoTrackSelection,r;switch(e){case`high_quality`:r={min:t,max:void 0};break;case`traffic_saving`:r={max:n,min:void 0};break;default:r={max:void 0,min:void 0}}this.setAutoQualityLimits(r)}),this}setPlaybackRate(e){return this.waitInit(()=>{this.tracer.log(`setPlaybackRate`,{playbackRate:e}),this.desiredState.playbackRate.startTransitionTo(e)}),this}setExternalTextTracks(e){return this.waitInit(()=>{e.length&&this.tracer.log(`setExternalTextTracks`,Zy(e)),this.desiredState.externalTextTracks.startTransitionTo(e.map(e=>T({type:`external`},e)))}),this}selectTextTrack(e){return this.waitInit(()=>{this.tracer.log(`selectTextTrack`,{textTrackId:e}),this.desiredState.currentTextTrack.setState(e)}),this}setLiveLowLatency(e){let t=this.info.isLive$.getValue(),n=this.desiredState.isLowLatency.getState();return!t||n===e?this:(this.tracer.log(`live switch to low latency `+e),this.desiredState.isLowLatency.setState(e),this.seekTime(0))}setLooped(e){return this.waitInit(()=>{this.tracer.log(`setLooped`,{isLooped:e}),this.desiredState.isLooped.startTransitionTo(e)}),this}toggleChromecast(){this.tracer.log(`toggleChromecast`),this.chromecastInitializer.toggleConnection()}getExactTime(){if(!this.providerContainer)return 0;let e=this.providerContainer.providerOutput.element$.getValue();if(sb(e))return this.info.position$.getValue();let t=this.desiredState.seekState.getState(),n=t.state===`none`?void 0:t.position;return ob(n)?n/1e3:e.currentTime}getExactLiveTime(){if(!this.providerContainer)return 0;let e=this.desiredState.seekState.getState(),t=e.state===`none`?void 0:e.position;return(ob(t)?t:this.info.liveTime$.getValue()??0)/1e3}getAllLogs(){return this.logger.getAllLogs()}getDebugData(){return this.info.debugData$.getValue()}buildDebugData([e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v]){let y={version:k,volume:Math.round(_*100),muted:v,provider:e,cdn:t,videoSize:n?`${n.width}x${n.height}`:void 0,speed:l,bitrate:u,liveLatency:d,currentVideoSegmentLength:f,currentAudioSegmentLength:p,videoCodec:m?.codec,audioCodec:h?.codec,hdr:m?.hdr,audioLanguage:h?.language,position:g};return r&&a&&(s&&c?(y.videoBuffer=r.end-c,y.nativeVideoBuffer=a.end-c):(y.videoBuffer=Math.max(r.end-g,0),y.nativeVideoBuffer=Math.max(a.end-g,0))),i&&(y.audioBuffer=Math.max(i.end-g,0),o&&(y.nativeAudioBuffer=Math.max(o.end-g,0))),y}setIntrinsicVideoSize(...e){let t={width:e.reduce((e,{width:t})=>e||t||0,0),height:e.reduce((e,{height:t})=>e||t||0,0)};t.width&&t.height&&this.info.intrinsicVideoSize$.next({width:t.width,height:t.height})}initDebugDataSubscriptions(){this.subscription.add(vb([this.info.currentFormat$,this.info.hostname$,this.info.intrinsicVideoSize$,this.info.currentVirtualVideoBuffer$,this.info.currentVirtualAudioBuffer$,this.info.currentNativeVideoBuffer$,this.info.currentNativeAudioBuffer$,this.info.isLive$,this.info.liveBufferTime$,this.info.throughputEstimation$,this.info.videoBitrate$,this.info.liveLatency$,this.info.currentVideoSegmentLength$,this.info.currentAudioSegmentLength$,this.info.currentVideoStream$,this.info.currentAudioStream$,this.info.position$,this.info.volume$,this.info.muted$]).pipe(Z(e=>this.buildDebugData(e))).subscribe(this.info.debugData$))}initDesiredStateSubscriptions(){this.persistentSubscription.add(ub(this.desiredState.playbackState.stateChangeStarted$,this.desiredState.playbackState.forceChanged$).pipe(Z(e=>e.to)).subscribe(this.info.playbackState$)).add(this.desiredState.isLooped.stateChangeEnded$.pipe(Z(e=>e.to)).subscribe(this.info.isLooped$)).add(this.desiredState.currentTextTrack.stateChangeEnded$.pipe(Z(e=>e.to)).subscribe(this.info.currentTextTrack$)).add(this.desiredState.playbackRate.stateChangeEnded$.pipe(Z(e=>e.to)).subscribe(this.info.currentPlaybackRate$)).add(this.desiredState.autoVideoTrackSwitching.stateChangeEnded$.pipe(Z(e=>e.to)).subscribe(this.info.isAutoQualityEnabled$)).add(this.desiredState.autoVideoTrackLimits.stateChangeEnded$.pipe(Z(e=>e.to)).subscribe(e=>{this.info.autoQualityLimits$.next(e);let{highQualityLimit:t,trafficSavingLimit:n}=this.tuning.autoTrackSelection;this.info.predefinedQualityLimitType$.next(ra(e,t,n))})).add(ub(this.desiredState.playbackState.stateChangeStarted$,this.desiredState.playbackState.forceChanged$).pipe(Y(({from:e})=>e===`stopped`)).subscribe(()=>{this.initedAt=db(),this.events.inited$.next()})).add(this.desiredState.playbackState.stateChangeEnded$.subscribe(e=>{switch(e.to){case`ready`:this.events.ready$.next();break;case`playing`:this.isPlaybackStarted||this.events.started$.next(),this.isPlaybackStarted=!0,this.events.playing$.next();break;case`paused`:this.events.paused$.next();break;case`stopped`:this.events.stopped$.next()}})).add(this.desiredState.playbackState.stateChangeStarted$.subscribe(e=>{switch(e.to){case`ready`:this.events.willReady$.next();break;case`paused`:this.events.willPause$.next();break;case`playing`:this.isPlaybackStarted?this.events.willResume$.next():this.events.willStart$.next();break;case`stopped`:this.suppressWillStop||this.events.willStop$.next();break;default:}}))}initProviderContainerSubscription(e){this.subscription.add(e.providerOutput.willSeekEvent$.subscribe(()=>{let e=this.desiredState.seekState.getState();this.tracer.log(`willSeekEvent`,Zy(e)),e.state===`requested`?this.desiredState.seekState.setState(T(T({},e),{},{state:`applying`})):this.events.managedError$.next({id:`WillSeekIn${e.state}`,category:Xy.WTF,message:`Received unexpeceted willSeek$`})})).add(e.providerOutput.soundProhibitedEvent$.pipe(Q()).subscribe(this.events.autoplaySoundProhibited$)).add(e.providerOutput.severeStallOccurred$.subscribe(this.events.severeStallOccured$)).add(e.providerOutput.seekedEvent$.subscribe(()=>{let e=this.desiredState.seekState.getState();this.tracer.log(`seekedEvent`,Zy(e)),e.state===`applying`&&(this.desiredState.seekState.setState({state:`none`}),this.events.seeked$.next())})).add(e.current$.pipe(Z(e=>e.type)).subscribe(this.info.currentFormat$)).add(e.current$.pipe(Z(e=>e.destination),X()).subscribe(()=>this.isPlaybackStarted=!1)).add(e.providerOutput.availableVideoStreams$.subscribe(this.info.availableVideoStreams$)).add(e.providerOutput.availableVideoTracks$.subscribe(this.info.availableVideoTracks$)).add(Jy({availableVideoTracks:e.providerOutput.availableVideoTracks$,currentVideoStream:e.providerOutput.currentVideoStream$}).pipe(Z(({availableVideoTracks:e,currentVideoStream:t})=>e.filter(e=>t?t.id===e.streamId:!0).map(({quality:e})=>e).sort((e,t)=>ab(e)?1:ab(t)?-1:ib(t,e)?1:-1))).subscribe(this.info.availableQualities$)).add(e.providerOutput.availableVideoTracks$.subscribe(e=>{let t={};for(let n of e)n.fps&&(t[n.quality]=n.fps);this.info.availableQualitiesFps$.next(t)})).add(e.providerOutput.availableAudioStreams$.subscribe(this.info.availableAudioStreams$)).add(e.providerOutput.currentVideoStream$.subscribe(this.info.currentVideoStream$)).add(e.providerOutput.currentAudioStream$.subscribe(this.info.currentAudioStream$)).add(e.providerOutput.availableAudioTracks$.subscribe(this.info.availableAudioTracks$)).add(e.providerOutput.isAudioAvailable$.pipe(X()).subscribe(this.info.isAudioAvailable$)).add(e.providerOutput.currentVideoTrack$.pipe(Y(e=>ob(e))).subscribe(e=>{this.info.currentQuality$.next(e?.quality),this.info.videoBitrate$.next(e?.bitrate)})).add(e.providerOutput.currentVideoSegmentLength$.pipe(X((e,t)=>Math.round(e)===Math.round(t))).subscribe(this.info.currentVideoSegmentLength$)).add(e.providerOutput.currentAudioSegmentLength$.pipe(X((e,t)=>Math.round(e)===Math.round(t))).subscribe(this.info.currentAudioSegmentLength$)).add(e.providerOutput.hostname$.pipe(X()).subscribe(this.info.hostname$)).add(e.providerOutput.httpConnectionType$.pipe(X()).subscribe(this.info.httpConnectionType$)).add(e.providerOutput.httpConnectionReused$.pipe(X()).subscribe(this.info.httpConnectionReused$)).add(e.providerOutput.httpConnectionMetrics$.pipe(X()).subscribe(this.info.httpConnectionMetrics$)).add(e.providerOutput.httpDownloadMetrics$.pipe(X()).subscribe(this.info.httpDownloadMetrics$)).add(e.providerOutput.availableTextTracks$.subscribe(this.info.availableTextTracks$)).add(e.providerOutput.autoVideoTrackLimitingAvailable$.subscribe(this.info.autoQualityLimitingAvailable$)).add(e.providerOutput.autoVideoTrackLimits$.subscribe(e=>{this.desiredState.autoVideoTrackLimits.setState(e??{})})).add(e.providerOutput.currentVirtualVideoBuffer$.pipe(Z(e=>e?{start:e.from,end:e.to}:{start:0,end:0})).subscribe(this.info.currentVirtualVideoBuffer$)).add(e.providerOutput.currentVirtualVideoBuffer$.pipe(Z(e=>e?{start:e.from,end:e.to}:{start:0,end:0})).subscribe(this.info.currentVideoBuffer$)).add(e.providerOutput.currentVirtualAudioBuffer$.pipe(Z(e=>e?{start:e.from,end:e.to}:{start:0,end:0})).subscribe(this.info.currentVirtualAudioBuffer$)).add(e.providerOutput.currentVirtualAudioBuffer$.pipe(Z(e=>e?{start:e.from,end:e.to}:{start:0,end:0})).subscribe(this.info.currentAudioBuffer$)).add(e.providerOutput.currentNativeVideoBuffer$.pipe(Z(e=>e?{start:e.from,end:e.to}:{start:0,end:0})).subscribe(this.info.currentNativeVideoBuffer$)).add(e.providerOutput.currentNativeAudioBuffer$.pipe(Z(e=>e?{start:e.from,end:e.to}:{start:0,end:0})).subscribe(this.info.currentNativeAudioBuffer$)).add(e.providerOutput.totalBufferDuration$.subscribe(this.info.totalBufferDuration$)).add(e.providerOutput.duration$.subscribe(this.info.duration$)).add(e.providerOutput.playedTime$.subscribe(this.info.playedTime$)).add(e.providerOutput.isBuffering$.subscribe(this.info.isBuffering$)).add(e.providerOutput.isLive$.subscribe(this.info.isLive$)).add(e.providerOutput.isLiveEnded$.pipe(mb(e=>e&&this.stop())).subscribe(this.info.isLiveEnded$)).add(e.providerOutput.canPlayLiveTailBuffer$.subscribe(this.info.canPlayLiveTailBuffer$)).add(e.providerOutput.canChangePlaybackSpeed$.subscribe(this.info.canChangePlaybackSpeed$)).add(e.providerOutput.liveTime$.pipe(X()).subscribe(this.info.liveTime$)).add(e.providerOutput.liveBufferTime$.subscribe(this.info.liveBufferTime$)).add(e.providerOutput.liveLatency$.subscribe(this.info.liveLatency$)).add(Jy({hasLiveOffsetByPaused:ub(this.desiredState.playbackState.stateChangeStarted$,this.desiredState.playbackState.forceChanged$).pipe(Z(e=>e.to),X(),Z(e=>e===`paused`)),isLowLatency:e.providerOutput.isLowLatency$}).subscribe(({hasLiveOffsetByPaused:e,isLowLatency:t})=>{if(M.clearTimeout(this.hasLiveOffsetByPausedTimer),e){this.hasLiveOffsetByPausedTimer=M.setTimeout(()=>{this.hasLiveOffsetByPaused.next(!0)},this.getActiveLiveDelay(t));return}this.hasLiveOffsetByPaused.next(!1)})).add(Jy({atLiveEdge:Jy({isLive:e.providerOutput.isLive$,isLowLatency:e.providerOutput.isLowLatency$,position:Cb({seekState:this.desiredState.seekState,position$:e.providerOutput.position$})}).pipe(Z(({isLive:e,position:t,isLowLatency:n})=>{let r=this.getActiveLiveDelay(n);return e&&Math.abs(t)<r/1e3}),X(),mb(e=>e&&this.setPlaybackRate(1))),hasPausedTimeoutCase:this.hasLiveOffsetByPaused}).pipe(Z(({atLiveEdge:e,hasPausedTimeoutCase:t})=>e&&!t)).subscribe(this.info.atLiveEdge$)).add(Jy({isLive:e.providerOutput.isLive$,position:P.browser.isSafari&&this.tuning.useSafariOptimisticPositionForLiveEdgeBugfix?Cb({seekState:this.desiredState.seekState,position$:e.providerOutput.position$}):e.providerOutput.position$,duration:e.providerOutput.duration$}).pipe(Z(({isLive:e,position:t,duration:n})=>e&&(Math.abs(n)-Math.abs(t))*1e3<this.tuning.live.activeLiveDelay),X(),mb(e=>e&&this.setPlaybackRate(1))).subscribe(this.info.atLiveDurationEdge$)).add(e.providerOutput.volume$.pipe(Z(e=>e.muted),X()).subscribe(this.info.muted$)).add(e.providerOutput.volume$.pipe(Z(e=>e.volume),X()).subscribe(this.info.volume$)).add(Cb({seekState:this.desiredState.seekState,position$:e.providerOutput.position$}).subscribe(this.info.position$)).add(e.providerOutput.seekedEvent$.subscribe(()=>{this.info.isEnded$.getValue()&&this.tuning.changePlaybackStateToPausedWhenEnded&&this.play()})).add(ub(e.providerOutput.endedEvent$.pipe(lb(!0)),e.providerOutput.seekedEvent$.pipe(lb(!1))).pipe(X()).subscribe(this.info.isEnded$)).add(e.providerOutput.endedEvent$.subscribe(this.events.ended$)).add(e.providerOutput.loopedEvent$.subscribe(this.events.looped$)).add(e.providerError$.subscribe(this.events.managedError$)).add(e.providerOutput.updateDurationError$.subscribe(this.events.managedError$)).add(e.providerOutput.fetcherRecoverableError$.subscribe(this.events.fetcherRecoverableError$)).add(e.providerOutput.fetcherError$.pipe(Y(e=>e.category===Xy.FATAL)).subscribe(this.events.fatalError$)).add(e.volumeMultiplierError$.subscribe(this.events.managedError$)).add(e.noAvailableProvidersError$.pipe(Z(({forced:e,input:t,supported:n})=>{let r,i;return e?(r=`NoForcedFormat`,i=`${e} was forced but failed or not available`):n.length?(r=`NoFormats`,i=`All formats failed`):t.length?(r=`NoSupportedFormats`,i=`No supported formats`):(r=`NoInputFormats`,i=`No formats supplied`),qy(r),{id:r,category:Xy.VIDEO_PIPELINE,message:i}})).subscribe(this.events.fatalError$)).add(e.providerOutput.element$.subscribe(this.experimental.element$)).add(e.providerOutput.getCurrentTime$.subscribe(this.experimental.getCurrentTime$)).add(e.providerOutput.manifestRequested$.pipe(Q()).subscribe(this.events.manifestRequested$)).add(e.providerOutput.firstBytesManifest$.pipe(Q()).subscribe(this.events.firstBytesManifest$)).add(e.providerOutput.manifestReceived$.pipe(Q()).subscribe(this.events.manifestReceived$)).add(e.providerOutput.firstBytesRequested$.pipe(Q()).subscribe(this.events.firstBytesRequested$)).add(e.providerOutput.firstBytesReceived$.pipe(Q()).subscribe(this.events.firstBytesReceived$)).add(e.providerOutput.firstBytesEvent$.pipe(Q(),Z(e=>e??db()-this.initedAt)).subscribe(this.events.firstBytes$)).add(e.providerOutput.loadedMetadataEvent$.subscribe(this.events.loadedMetadata$)).add(e.providerOutput.firstFrameEvent$.pipe(Q(),Z(()=>db()-this.initedAt)).subscribe(this.events.firstFrame$)).add(e.providerOutput.canplay$.pipe(Q(),Z(()=>db()-this.initedAt)).subscribe(this.events.canplay$)).add(this.throughputEstimator.throughput$.subscribe(this.info.throughputEstimation$)).add(this.throughputEstimator.rtt$.subscribe(this.info.rttEstimation$)).add(e.providerOutput.availableSources$.subscribe(this.info.availableSources$));let t=new _b(!1);this.subscription.add(e.providerOutput.seekedEvent$.subscribe(()=>t.next(!1))).add(e.providerOutput.willSeekEvent$.subscribe(()=>t.next(!0)));let n=new _b(!0),r=new pb;this.subscription.add(r).add(e.current$.subscribe(()=>{n.next(!0),r.unsubscribe(),r.add(this.desiredState.playbackState.stateChangeEnded$.pipe(Y(({to:e})=>e===`playing`),Q()).subscribe(()=>n.next(!1)))}));let i=new _b(!1);this.subscription.add(this.desiredState.playbackState.stateChangeEnded$.subscribe(({to:e})=>i.next(e===`paused`)));let a=0,o=0,s=ub(e.providerOutput.isBuffering$,t,n,i).pipe(Z(()=>{let r=e.providerOutput.isBuffering$.getValue(),a=t.getValue()||n.getValue()||this.tuning.stallIgnoreOnPause&&i.getValue();return r&&!a}),X());this.subscription.add(s.subscribe(e=>{let{stallIgnoreThreshold:t,stallHandlingStrategy:n}=this.tuning;e?(o=db(),n===`verbose`&&this.info.stallStartTime$.next(o),a=M.setTimeout(()=>{this.info.isStalled$.next(!0),o&&this.info.stallStartTime$.next(n===`exclude-threshold`?db():o)},t)):(M.clearTimeout(a),this.info.isStalled$.next(!1),o=0,this.info.stallStartTime$.next(0))})),this.subscription.add(ub(e.providerOutput.canplay$,e.providerOutput.firstFrameEvent$,e.providerOutput.firstBytesEvent$).subscribe(()=>{let t=e.providerOutput.element$.getValue();this.setIntrinsicVideoSize({width:t?.videoWidth,height:t?.videoHeight})})).add(e.providerOutput.currentVideoTrack$.subscribe(t=>{var n,r;let i=e.providerOutput.element$.getValue();this.setIntrinsicVideoSize({width:t==null||(n=t.size)==null?void 0:n.width,height:t==null||(r=t.size)==null?void 0:r.height},{width:i?.videoWidth,height:i?.videoHeight})})),this.subscription.add(ub(e.providerOutput.inPiP$,e.providerOutput.inFullscreen$,e.providerOutput.element$,e.providerOutput.elementVisible$,this.chromecastInitializer.castState$).subscribe(()=>{let t=e.providerOutput.inPiP$.getValue(),n=e.providerOutput.inFullscreen$.getValue(),r=e.providerOutput.element$.getValue(),i=e.providerOutput.elementVisible$.getValue(),a=this.chromecastInitializer.castState$.getValue(),o;o=a===`CONNECTED`?`second_screen`:r?i?t?`pip`:n?`fullscreen`:`inline`:`invisible`:`none`,this.info.surface$.getValue()!==o&&this.info.surface$.next(o)}))}initChromecastSubscription(){this.subscription.add(this.chromecastInitializer.castState$.subscribe(this.info.chromecastState$)),this.subscription.add(this.chromecastInitializer.connection$.pipe(Z(e=>e?.castDevice.friendlyName)).subscribe(this.info.chromecastDeviceName$)),this.subscription.add(this.chromecastInitializer.errorEvent$.subscribe(this.events.managedError$))}initStartingVideoTrack(e){let t=new pb;this.subscription.add(t),this.subscription.add(e.current$.pipe(X((e,t)=>e.provider===t.provider)).subscribe(()=>{t.unsubscribe(),t.add(e.providerOutput.availableVideoTracks$.pipe(Y(e=>e.length>0),Q()).subscribe(e=>{this.setStartingVideoTrack(e)}))}))}setStartingVideoTrack(e){let t;this.wasSetStartedQuality=!0;let n=this.explicitInitialQuality??this.info.currentQuality$.getValue();n&&(t=e.find(({quality:e,tvDisabled:t})=>e===n&&!t),t||this.setAutoQuality(!0)),!t&&(t=ka({videoTracks:e,tuning:this.tuning,abrLogger:this.abrLogger,tracer:this.tracer,container:this.domContainer?.getBoundingClientRect()??null,panelSize:this.config.panelSize??null,estimatedThroughput:this.throughputEstimator.throughput$.getValue(),limits:this.desiredState.autoVideoTrackLimits.getState(),playbackRate:this.info.currentPlaybackRate$.getValue(),forwardBufferHealth:0})),this.desiredState.videoTrack.startTransitionTo(t),this.info.currentQuality$.next(t.quality),this.info.videoBitrate$.next(t.bitrate)}initLogs(){this.persistentSubscription.add(ub(this.desiredState.videoTrack.stateChangeStarted$.pipe(Z(e=>({transition:e,entity:`quality`,type:`start`}))),this.desiredState.videoTrack.stateChangeEnded$.pipe(Z(e=>({transition:e,entity:`quality`,type:`end`}))),this.desiredState.autoVideoTrackSwitching.stateChangeStarted$.pipe(Z(e=>({transition:e,entity:`autoQualityEnabled`,type:`start`}))),this.desiredState.autoVideoTrackSwitching.stateChangeEnded$.pipe(Z(e=>({transition:e,entity:`autoQualityEnabled`,type:`end`}))),this.desiredState.seekState.stateChangeStarted$.pipe(Z(e=>({transition:e,entity:`seekState`,type:`start`}))),this.desiredState.seekState.stateChangeEnded$.pipe(Z(e=>({transition:e,entity:`seekState`,type:`end`}))),this.desiredState.playbackState.stateChangeStarted$.pipe(Z(e=>({transition:e,entity:`playbackState`,type:`start`}))),this.desiredState.playbackState.stateChangeEnded$.pipe(Z(e=>({transition:e,entity:`playbackState`,type:`end`})))).pipe(Z(e=>({component:`desiredState`,message:`[${e.entity} change] ${e.type}: ${JSON.stringify(e.transition)}`}))).subscribe(this.logger.log)),this.persistentSubscription.add(this.logger.log$.subscribe(this.events.log$))}initDebugTelemetry(){let e=this.providerContainer?.providerOutput;qy(this.providerContainer),qy(e),Mp(),this.experimental.enableDebugTelemetry$.next(this.tuning.enableTelemetryAtStart),[this.experimental.enableDebugTelemetry$.subscribe(e=>jp(e)),this.providerContainer.current$.subscribe(({type:e})=>Pp(`provider`,e)),e.duration$.subscribe(e=>Pp(`duration`,e)),e.availableVideoTracks$.pipe(Y(e=>!!e.length),Q()).subscribe(e=>Pp(`tracks`,e)),this.events.fatalError$.subscribe(new Fp(`fatalError`)),this.events.managedError$.subscribe(new Fp(`managedError`)),e.position$.subscribe(new Fp(`position`)),e.currentVideoTrack$.pipe(Z(e=>e?.quality)).subscribe(new Fp(`quality`)),this.info.currentVirtualVideoBuffer$.subscribe(new Fp(`buffer`)),e.isBuffering$.subscribe(new Fp(`isBuffering`))].forEach(e=>this.subscription.add(e)),Pp(`codecs`,P.video.supportedCodecs)}initTracerSubscription(){let e=tb(this.tracer.log.bind(this.tracer)),t=tb(this.tracer.error.bind(this.tracer));this.subscription.add(this.info.playbackState$.subscribe(e(`playbackState`))).add(this.info.isLooped$.subscribe(e(`isLooped`))).add(this.info.currentPlaybackRate$.pipe(X()).subscribe(e(`currentPlaybackRate`))).add(this.info.isAutoQualityEnabled$.subscribe(e(`isAutoQualityEnabled`))).add(this.info.autoQualityLimits$.subscribe(e(`autoQualityLimits`))).add(this.info.currentFormat$.subscribe(e(`currentFormat`))).add(this.info.availableQualities$.subscribe(e(`availableQualities`))).add(this.info.availableQualitiesFps$.subscribe(e(`availableQualitiesFps`))).add(this.info.availableAudioTracks$.subscribe(e(`availableAudioTracks`))).add(this.info.isAudioAvailable$.subscribe(e(`isAudioAvailable`))).add(Jy({currentQuality:this.info.currentQuality$,videoBitrate:this.info.videoBitrate$}).pipe(Y(({currentQuality:e,videoBitrate:t})=>!!e&&!!t),X((e,t)=>e.currentQuality===t.currentQuality)).subscribe(e(`currentVideoTrack`))).add(this.info.currentVideoSegmentLength$.pipe(Y(e=>e>0),X()).subscribe(e(`currentVideoSegmentLength`))).add(this.info.currentAudioSegmentLength$.pipe(Y(e=>e>0),X()).subscribe(e(`currentAudioSegmentLength`))).add(this.info.hostname$.subscribe(e(`hostname`))).add(this.info.currentTextTrack$.pipe(X()).subscribe(e(`currentTextTrack`))).add(this.info.availableTextTracks$.subscribe(e(`availableTextTracks`))).add(this.info.autoQualityLimitingAvailable$.subscribe(e(`autoQualityLimitingAvailable`))).add(Jy({currentBuffer:this.info.currentVirtualVideoBuffer$.pipe(Y(e=>e.end>0),X((e,t)=>e.end===t.end&&e.start===t.start)),position:this.info.position$.pipe(X())}).pipe(hb(1e3)).subscribe(e(`currentBufferAndPosition`))).add(this.info.duration$.pipe(X()).subscribe(e(`duration`))).add(this.info.isBuffering$.subscribe(e(`isBuffering`))).add(this.info.isLive$.pipe(X()).subscribe(e(`isLive`))).add(this.info.canChangePlaybackSpeed$.pipe(X()).subscribe(e(`canChangePlaybackSpeed`))).add(Jy({liveTime:this.info.liveTime$,liveBufferTime:this.info.liveBufferTime$,position:this.info.position$}).pipe(Y(({liveTime:e,liveBufferTime:t})=>!!e&&!!t),hb(1e3)).subscribe(e(`liveBufferAndPosition`))).add(this.info.atLiveEdge$.pipe(X(),Y(e=>e===!0)).subscribe(e(`atLiveEdge`))).add(this.info.atLiveDurationEdge$.pipe(X(),Y(e=>e===!0)).subscribe(e(`atLiveDurationEdge`))).add(this.info.muted$.pipe(X()).subscribe(e(`muted`))).add(this.info.volume$.pipe(X()).subscribe(e(`volume`))).add(this.info.isEnded$.pipe(X(),Y(e=>e===!0)).subscribe(e(`isEnded`))).add(this.info.availableSources$.subscribe(e(`availableSources`))).add(Jy({throughputEstimation:this.info.throughputEstimation$,rtt:this.info.rttEstimation$}).pipe(Y(({throughputEstimation:e,rtt:t})=>!!e&&!!t),hb(3e3)).subscribe(e(`throughputEstimation`))).add(this.info.isStalled$.subscribe(e(`isStalled`))).add(this.info.surface$.subscribe(e(`surface`))).add(this.events.ended$.subscribe(e(`ended`))).add(this.events.looped$.subscribe(e(`looped`))).add(this.events.managedError$.subscribe(t(`managedError`))).add(this.events.fatalError$.subscribe(t(`fatalError`))).add(this.events.firstBytes$.subscribe(e(`firstBytes`))).add(this.events.firstFrame$.subscribe(e(`firstFrame`))).add(this.events.canplay$.subscribe(e(`canplay`)))}initWakeLock(){var e=this;let t=nb();if(!t.navigator.wakeLock||!this.tuning.enableWakeLock)return;let n,r=()=>{n?.release(),n=void 0},i=function(){var t=E(function*(){r(),n=yield window.navigator.wakeLock.request(`screen`).catch(t=>{t instanceof DOMException&&t.name===`NotAllowedError`||e.events.managedError$.next({id:`WakeLock`,category:Xy.DOM,message:String(t)})})});return function(){return t.apply(this,arguments)}}();this.subscription.add(ub(Qy(t.document,`visibilitychange`),Qy(t.document,`fullscreenchange`),this.desiredState.playbackState.stateChangeEnded$).subscribe(()=>{let e=t.document.visibilityState===`visible`,a=this.desiredState.playbackState.getState()===`playing`,o=!!n&&!n?.released;e&&a?o||i():r()})).add(this.events.willDestruct$.subscribe(r))}setVideoTrackIdByQuality(e,t){let n=e.find(e=>e.quality===t);this.tracer.log(`setVideoTrackIdByQuality`,Zy({quality:t,availableTracks:Zy(e),track:Zy(n),isAutoQuality:!n})),n?n.tvDisabled?(this.setAutoQuality(!0),this.events.managedError$.next({id:`SetQualityTrackTvDisabled`,category:Xy.WTF,message:`Set quality was called on track with tvDisabled flag`})):this.desiredState.videoTrack.startTransitionTo(n):this.setAutoQuality(!0)}getActiveLiveDelay(e=!1){return e?this.tuning.live.lowLatencyActiveLiveDelay:this.tuning.live.activeLiveDelay}isNotActiveTabCase(){return nb().document.hidden&&this.tuning.autoplayOnlyInActiveTab&&!Wo()}}var Hx=`@vkontakte/videoplayer-core@${k}`;;return{ie,ae,Rx,A,Ix,se,Hx,zx,Lx,oe,k,Bx,re,ne,Vx,Jo,Ht,P,pt};}();var{ie:_oxcMod1uc4ua_ie,ae:_oxcMod1uc4ua_ae,Rx:_oxcMod1uc4ua_Rx,A:_oxcMod1uc4ua_A,Ix:_oxcMod1uc4ua_Ix,se:_oxcMod1uc4ua_se,Hx:_oxcMod1uc4ua_Hx,zx:_oxcMod1uc4ua_zx,Lx:_oxcMod1uc4ua_Lx,oe:_oxcMod1uc4ua_oe,k:_oxcMod1uc4ua_k,Bx:_oxcMod1uc4ua_Bx,re:_oxcMod1uc4ua_re,ne:_oxcMod1uc4ua_ne,Vx:_oxcMod1uc4ua_Vx,Jo:_oxcMod1uc4ua_Jo,Ht:_oxcMod1uc4ua_Ht,P:_oxcMod1uc4ua_P,pt:_oxcMod1uc4ua_pt}=_oxcMod1uc4ua;export{_oxcMod1uc4ua_ie as ChromecastState,_oxcMod1uc4ua_ae as HttpConnectionType,_oxcMod1uc4ua_Rx as Observable,_oxcMod1uc4ua_A as PlaybackState,_oxcMod1uc4ua_Ix as Player,_oxcMod1uc4ua_se as PredefinedQualityLimits,_oxcMod1uc4ua_Hx as SDK_VERSION,_oxcMod1uc4ua_zx as Subject,_oxcMod1uc4ua_Lx as Subscription,_oxcMod1uc4ua_oe as Surface,_oxcMod1uc4ua_k as VERSION,_oxcMod1uc4ua_Bx as ValueSubject,_oxcMod1uc4ua_re as VideoCodecName,_oxcMod1uc4ua_ne as VideoFormat,_oxcMod1uc4ua_Vx as VideoQuality,_oxcMod1uc4ua_Jo as WebmCodecStrategy,_oxcMod1uc4ua_Ht as areValidLiveRecordSources,_oxcMod1uc4ua_P as clientChecker,_oxcMod1uc4ua_pt as isMobile};