@vkontakte/videoplayer-statistics 1.0.100-dev.04f0bb5f.0 → 1.0.100-dev.319d6ebf.0

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.
Files changed (46) hide show
  1. package/es2018.cjs +3 -3
  2. package/es2018.esm.js +3 -3
  3. package/es2024.cjs +3 -3
  4. package/es2024.esm.js +3 -3
  5. package/esnext.cjs +3 -3
  6. package/esnext.esm.js +3 -3
  7. package/evergreen.esm.js +3 -3
  8. package/package.json +3 -3
  9. package/types/ShareVSID.d.ts +3 -3
  10. package/types/index.d.ts +6 -5
  11. package/types/mediascopePixel/MediascopePixel.d.ts +36 -36
  12. package/types/mediascopePixel/Stopwatch.d.ts +10 -10
  13. package/types/mediascopePixel/types.d.ts +5 -5
  14. package/types/oneStat/Api.d.ts +35 -34
  15. package/types/oneStat/ApiTransport.d.ts +19 -19
  16. package/types/oneStat/Logger.d.ts +35 -35
  17. package/types/oneStat/OneStat.d.ts +309 -307
  18. package/types/oneStat/config.d.ts +32 -32
  19. package/types/oneStat/env.d.ts +3 -3
  20. package/types/oneStat/index.d.ts +9 -6
  21. package/types/oneStat/types.d.ts +43 -43
  22. package/types/oneStat/uiEvents.d.ts +19 -19
  23. package/types/oneStat/utils/mappers.d.ts +2 -2
  24. package/types/oneStat/utils/shorten.d.ts +1 -1
  25. package/types/oneStat/utils/timeSynchronisation.d.ts +8 -8
  26. package/types/oneStat/utils/watchCoverage.d.ts +4 -4
  27. package/types/oneStat/values.d.ts +63 -64
  28. package/types/shared/useModeController.d.ts +6 -5
  29. package/types/thinOneStat/Api.d.ts +32 -32
  30. package/types/thinOneStat/ApiTransport.d.ts +19 -19
  31. package/types/thinOneStat/Logger.d.ts +35 -35
  32. package/types/thinOneStat/ThinOneStat.d.ts +271 -271
  33. package/types/thinOneStat/config.d.ts +21 -20
  34. package/types/thinOneStat/env.d.ts +3 -3
  35. package/types/thinOneStat/events.d.ts +21 -21
  36. package/types/thinOneStat/index.d.ts +6 -4
  37. package/types/thinOneStat/types.d.ts +24 -24
  38. package/types/thinOneStat/utils/calculateTotalViewTime.d.ts +2 -2
  39. package/types/thinOneStat/utils/downloadBytes.d.ts +4 -4
  40. package/types/thinOneStat/utils/mappers.d.ts +3 -2
  41. package/types/thinOneStat/utils/timeSynchronisation.d.ts +8 -8
  42. package/types/thinOneStat/utils/watchCoverage.d.ts +4 -4
  43. package/types/thinOneStat/utils/watchedN.d.ts +5 -5
  44. package/types/thinOneStat/values.d.ts +67 -67
  45. package/es2015.cjs +0 -6
  46. package/es2015.esm.js +0 -6
package/es2018.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @vkontakte/videoplayer-statistics v1.0.100-dev.04f0bb5f.0
3
- * Tue, 24 Feb 2026 12:54:15 GMT
2
+ * @vkontakte/videoplayer-statistics v1.0.100-dev.319d6ebf.0
3
+ * Wed, 04 Mar 2026 10:24:59 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-100/doc/
5
5
  */
6
- var Pf=Object.create;var _r=Object.defineProperty;var Tf=Object.getOwnPropertyDescriptor;var Ef=Object.getOwnPropertyNames;var wf=Object.getPrototypeOf,xf=Object.prototype.hasOwnProperty;var u=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Af=(t,e)=>{for(var r in e)_r(t,r,{get:e[r],enumerable:!0})},Of=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ef(e))!xf.call(t,o)&&o!==r&&_r(t,o,{get:()=>e[o],enumerable:!(i=Tf(e,o))||i.enumerable});return t};var E=(t,e,r)=>(r=t!=null?Pf(wf(t)):{},Of(e||!t||!t.__esModule?_r(r,"default",{value:t,enumerable:!0}):r,t));var _=u((Sr,Jo)=>{"use strict";var Be=function(t){return t&&t.Math===Math&&t};Jo.exports=Be(typeof globalThis=="object"&&globalThis)||Be(typeof window=="object"&&window)||Be(typeof self=="object"&&self)||Be(typeof global=="object"&&global)||Be(typeof Sr=="object"&&Sr)||function(){return this}()||Function("return this")()});var A=u((k_,Xo)=>{"use strict";Xo.exports=function(t){try{return!!t()}catch(e){return!0}}});var Ue=u((L_,Zo)=>{"use strict";var Cf=A();Zo.exports=!Cf(function(){var t=function(){}.bind();return typeof t!="function"||t.hasOwnProperty("prototype")})});var Pr=u((N_,on)=>{"use strict";var qf=Ue(),rn=Function.prototype,en=rn.apply,tn=rn.call;on.exports=typeof Reflect=="object"&&Reflect.apply||(qf?tn.bind(en):function(){return tn.apply(en,arguments)})});var O=u(($_,sn)=>{"use strict";var nn=Ue(),an=Function.prototype,Tr=an.call,Rf=nn&&an.bind.bind(Tr,Tr);sn.exports=nn?Rf:function(t){return function(){return Tr.apply(t,arguments)}}});var je=u((D_,cn)=>{"use strict";var un=O(),kf=un({}.toString),Lf=un("".slice);cn.exports=function(t){return Lf(kf(t),8,-1)}});var Er=u((M_,ln)=>{"use strict";var Nf=je(),$f=O();ln.exports=function(t){if(Nf(t)==="Function")return $f(t)}});var S=u((V_,dn)=>{"use strict";var wr=typeof document=="object"&&document.all;dn.exports=typeof wr=="undefined"&&wr!==void 0?function(t){return typeof t=="function"||t===wr}:function(t){return typeof t=="function"}});var R=u((F_,fn)=>{"use strict";var Df=A();fn.exports=!Df(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var M=u((B_,pn)=>{"use strict";var Mf=Ue(),yt=Function.prototype.call;pn.exports=Mf?yt.bind(yt):function(){return yt.apply(yt,arguments)}});var xr=u(gn=>{"use strict";var hn={}.propertyIsEnumerable,vn=Object.getOwnPropertyDescriptor,Vf=vn&&!hn.call({1:2},1);gn.f=Vf?function(e){var r=vn(this,e);return!!r&&r.enumerable}:hn});var He=u((j_,mn)=>{"use strict";mn.exports=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}});var yn=u((H_,bn)=>{"use strict";var Ff=O(),Bf=A(),Uf=je(),Ar=Object,jf=Ff("".split);bn.exports=Bf(function(){return!Ar("z").propertyIsEnumerable(0)})?function(t){return Uf(t)==="String"?jf(t,""):Ar(t)}:Ar});var We=u((W_,In)=>{"use strict";In.exports=function(t){return t==null}});var be=u((K_,_n)=>{"use strict";var Hf=We(),Wf=TypeError;_n.exports=function(t){if(Hf(t))throw new Wf("Can't call method on "+t);return t}});var ae=u((Q_,Sn)=>{"use strict";var Kf=yn(),Qf=be();Sn.exports=function(t){return Kf(Qf(t))}});var V=u((G_,Pn)=>{"use strict";var Gf=S();Pn.exports=function(t){return typeof t=="object"?t!==null:Gf(t)}});var se=u((z_,Tn)=>{"use strict";Tn.exports={}});var Y=u((Y_,wn)=>{"use strict";var Or=se(),Cr=_(),zf=S(),En=function(t){return zf(t)?t:void 0};wn.exports=function(t,e){return arguments.length<2?En(Or[t])||En(Cr[t]):Or[t]&&Or[t][e]||Cr[t]&&Cr[t][e]}});var It=u((J_,xn)=>{"use strict";var Yf=O();xn.exports=Yf({}.isPrototypeOf)});var ue=u((X_,Cn)=>{"use strict";var Jf=_(),An=Jf.navigator,On=An&&An.userAgent;Cn.exports=On?String(On):""});var Rr=u((Z_,$n)=>{"use strict";var Nn=_(),qr=ue(),qn=Nn.process,Rn=Nn.Deno,kn=qn&&qn.versions||Rn&&Rn.version,Ln=kn&&kn.v8,F,_t;Ln&&(F=Ln.split("."),_t=F[0]>0&&F[0]<4?1:+(F[0]+F[1]));!_t&&qr&&(F=qr.match(/Edge\/(\d+)/),(!F||F[1]>=74)&&(F=qr.match(/Chrome\/(\d+)/),F&&(_t=+F[1])));$n.exports=_t});var kr=u((eS,Mn)=>{"use strict";var Dn=Rr(),Xf=A(),Zf=_(),ep=Zf.String;Mn.exports=!!Object.getOwnPropertySymbols&&!Xf(function(){var t=Symbol("symbol detection");return!ep(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&Dn&&Dn<41})});var Lr=u((tS,Vn)=>{"use strict";var tp=kr();Vn.exports=tp&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Nr=u((rS,Fn)=>{"use strict";var rp=Y(),ip=S(),op=It(),np=Lr(),ap=Object;Fn.exports=np?function(t){return typeof t=="symbol"}:function(t){var e=rp("Symbol");return ip(e)&&op(e.prototype,ap(t))}});var Ke=u((iS,Bn)=>{"use strict";var sp=String;Bn.exports=function(t){try{return sp(t)}catch(e){return"Object"}}});var J=u((oS,Un)=>{"use strict";var up=S(),cp=Ke(),lp=TypeError;Un.exports=function(t){if(up(t))return t;throw new lp(cp(t)+" is not a function")}});var St=u((nS,jn)=>{"use strict";var dp=J(),fp=We();jn.exports=function(t,e){var r=t[e];return fp(r)?void 0:dp(r)}});var Wn=u((aS,Hn)=>{"use strict";var $r=M(),Dr=S(),Mr=V(),pp=TypeError;Hn.exports=function(t,e){var r,i;if(e==="string"&&Dr(r=t.toString)&&!Mr(i=$r(r,t))||Dr(r=t.valueOf)&&!Mr(i=$r(r,t))||e!=="string"&&Dr(r=t.toString)&&!Mr(i=$r(r,t)))return i;throw new pp("Can't convert object to primitive value")}});var K=u((sS,Kn)=>{"use strict";Kn.exports=!0});var zn=u((uS,Gn)=>{"use strict";var Qn=_(),hp=Object.defineProperty;Gn.exports=function(t,e){try{hp(Qn,t,{value:e,configurable:!0,writable:!0})}catch(r){Qn[t]=e}return e}});var Qe=u((cS,Xn)=>{"use strict";var vp=K(),gp=_(),mp=zn(),Yn="__core-js_shared__",Jn=Xn.exports=gp[Yn]||mp(Yn,{});(Jn.versions||(Jn.versions=[])).push({version:"3.43.0",mode:vp?"pure":"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.43.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var Vr=u((lS,ea)=>{"use strict";var Zn=Qe();ea.exports=function(t,e){return Zn[t]||(Zn[t]=e||{})}});var Fr=u((dS,ta)=>{"use strict";var bp=be(),yp=Object;ta.exports=function(t){return yp(bp(t))}});var Q=u((fS,ra)=>{"use strict";var Ip=O(),_p=Fr(),Sp=Ip({}.hasOwnProperty);ra.exports=Object.hasOwn||function(e,r){return Sp(_p(e),r)}});var Br=u((pS,ia)=>{"use strict";var Pp=O(),Tp=0,Ep=Math.random(),wp=Pp(1.1.toString);ia.exports=function(t){return"Symbol("+(t===void 0?"":t)+")_"+wp(++Tp+Ep,36)}});var k=u((hS,na)=>{"use strict";var xp=_(),Ap=Vr(),oa=Q(),Op=Br(),Cp=kr(),qp=Lr(),ye=xp.Symbol,Ur=Ap("wks"),Rp=qp?ye.for||ye:ye&&ye.withoutSetter||Op;na.exports=function(t){return oa(Ur,t)||(Ur[t]=Cp&&oa(ye,t)?ye[t]:Rp("Symbol."+t)),Ur[t]}});var ca=u((vS,ua)=>{"use strict";var kp=M(),aa=V(),sa=Nr(),Lp=St(),Np=Wn(),$p=k(),Dp=TypeError,Mp=$p("toPrimitive");ua.exports=function(t,e){if(!aa(t)||sa(t))return t;var r=Lp(t,Mp),i;if(r){if(e===void 0&&(e="default"),i=kp(r,t,e),!aa(i)||sa(i))return i;throw new Dp("Can't convert object to primitive value")}return e===void 0&&(e="number"),Np(t,e)}});var jr=u((gS,la)=>{"use strict";var Vp=ca(),Fp=Nr();la.exports=function(t){var e=Vp(t,"string");return Fp(e)?e:e+""}});var Pt=u((mS,fa)=>{"use strict";var Bp=_(),da=V(),Hr=Bp.document,Up=da(Hr)&&da(Hr.createElement);fa.exports=function(t){return Up?Hr.createElement(t):{}}});var Wr=u((bS,pa)=>{"use strict";var jp=R(),Hp=A(),Wp=Pt();pa.exports=!jp&&!Hp(function(){return Object.defineProperty(Wp("div"),"a",{get:function(){return 7}}).a!==7})});var ga=u(va=>{"use strict";var Kp=R(),Qp=M(),Gp=xr(),zp=He(),Yp=ae(),Jp=jr(),Xp=Q(),Zp=Wr(),ha=Object.getOwnPropertyDescriptor;va.f=Kp?ha:function(e,r){if(e=Yp(e),r=Jp(r),Zp)try{return ha(e,r)}catch(i){}if(Xp(e,r))return zp(!Qp(Gp.f,e,r),e[r])}});var Kr=u((IS,ma)=>{"use strict";var eh=A(),th=S(),rh=/#|\.prototype\./,Ge=function(t,e){var r=oh[ih(t)];return r===ah?!0:r===nh?!1:th(e)?eh(e):!!e},ih=Ge.normalize=function(t){return String(t).replace(rh,".").toLowerCase()},oh=Ge.data={},nh=Ge.NATIVE="N",ah=Ge.POLYFILL="P";ma.exports=Ge});var ze=u((_S,ya)=>{"use strict";var ba=Er(),sh=J(),uh=Ue(),ch=ba(ba.bind);ya.exports=function(t,e){return sh(t),e===void 0?t:uh?ch(t,e):function(){return t.apply(e,arguments)}}});var Qr=u((SS,Ia)=>{"use strict";var lh=R(),dh=A();Ia.exports=lh&&dh(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var X=u((PS,_a)=>{"use strict";var fh=V(),ph=String,hh=TypeError;_a.exports=function(t){if(fh(t))return t;throw new hh(ph(t)+" is not an object")}});var ce=u(Pa=>{"use strict";var vh=R(),gh=Wr(),mh=Qr(),Tt=X(),Sa=jr(),bh=TypeError,Gr=Object.defineProperty,yh=Object.getOwnPropertyDescriptor,zr="enumerable",Yr="configurable",Jr="writable";Pa.f=vh?mh?function(e,r,i){if(Tt(e),r=Sa(r),Tt(i),typeof e=="function"&&r==="prototype"&&"value"in i&&Jr in i&&!i[Jr]){var o=yh(e,r);o&&o[Jr]&&(e[r]=i.value,i={configurable:Yr in i?i[Yr]:o[Yr],enumerable:zr in i?i[zr]:o[zr],writable:!1})}return Gr(e,r,i)}:Gr:function(e,r,i){if(Tt(e),r=Sa(r),Tt(i),gh)try{return Gr(e,r,i)}catch(o){}if("get"in i||"set"in i)throw new bh("Accessors not supported");return"value"in i&&(e[r]=i.value),e}});var Ie=u((ES,Ta)=>{"use strict";var Ih=R(),_h=ce(),Sh=He();Ta.exports=Ih?function(t,e,r){return _h.f(t,e,Sh(1,r))}:function(t,e,r){return t[e]=r,t}});var C=u((wS,wa)=>{"use strict";var Ye=_(),Ph=Pr(),Th=Er(),Eh=S(),wh=ga().f,xh=Kr(),_e=se(),Ah=ze(),Se=Ie(),Ea=Q();Qe();var Oh=function(t){var e=function(r,i,o){if(this instanceof e){switch(arguments.length){case 0:return new t;case 1:return new t(r);case 2:return new t(r,i)}return new t(r,i,o)}return Ph(t,this,arguments)};return e.prototype=t.prototype,e};wa.exports=function(t,e){var r=t.target,i=t.global,o=t.stat,n=t.proto,c=i?Ye:o?Ye[r]:Ye[r]&&Ye[r].prototype,f=i?_e:_e[r]||Se(_e,r,{})[r],d=f.prototype,p,v,a,s,l,h,g,m,b;for(s in e)p=xh(i?s:r+(o?".":"#")+s,t.forced),v=!p&&c&&Ea(c,s),h=f[s],v&&(t.dontCallGetSet?(b=wh(c,s),g=b&&b.value):g=c[s]),l=v&&g?g:e[s],!(!p&&!n&&typeof h==typeof l)&&(t.bind&&v?m=Ah(l,Ye):t.wrap&&v?m=Oh(l):n&&Eh(l)?m=Th(l):m=l,(t.sham||l&&l.sham||h&&h.sham)&&Se(m,"sham",!0),Se(f,s,m),n&&(a=r+"Prototype",Ea(_e,a)||Se(_e,a,{}),Se(_e[a],s,l),t.real&&d&&(p||!d[s])&&Se(d,s,l)))}});var Aa=u((xS,xa)=>{"use strict";var Ch=Math.ceil,qh=Math.floor;xa.exports=Math.trunc||function(e){var r=+e;return(r>0?qh:Ch)(r)}});var Et=u((AS,Oa)=>{"use strict";var Rh=Aa();Oa.exports=function(t){var e=+t;return e!==e||e===0?0:Rh(e)}});var qa=u((OS,Ca)=>{"use strict";var kh=Et(),Lh=Math.max,Nh=Math.min;Ca.exports=function(t,e){var r=kh(t);return r<0?Lh(r+e,0):Nh(r,e)}});var Xr=u((CS,Ra)=>{"use strict";var $h=Et(),Dh=Math.min;Ra.exports=function(t){var e=$h(t);return e>0?Dh(e,9007199254740991):0}});var Zr=u((qS,ka)=>{"use strict";var Mh=Xr();ka.exports=function(t){return Mh(t.length)}});var ei=u((RS,Na)=>{"use strict";var Vh=ae(),Fh=qa(),Bh=Zr(),La=function(t){return function(e,r,i){var o=Vh(e),n=Bh(o);if(n===0)return!t&&-1;var c=Fh(i,n),f;if(t&&r!==r){for(;n>c;)if(f=o[c++],f!==f)return!0}else for(;n>c;c++)if((t||c in o)&&o[c]===r)return t||c||0;return!t&&-1}};Na.exports={includes:La(!0),indexOf:La(!1)}});var ti=u((kS,$a)=>{"use strict";$a.exports=function(){}});var Da=u(()=>{"use strict";var Uh=C(),jh=ei().includes,Hh=A(),Wh=ti(),Kh=Hh(function(){return!Array(1).includes()});Uh({target:"Array",proto:!0,forced:Kh},{includes:function(e){return jh(this,e,arguments.length>1?arguments[1]:void 0)}});Wh("includes")});var wt=u(($S,Ma)=>{"use strict";var Qh=Y();Ma.exports=Qh});var Fa=u((DS,Va)=>{"use strict";Da();var Gh=wt();Va.exports=Gh("Array","includes")});var Ua=u((MS,Ba)=>{"use strict";var zh=Fa();Ba.exports=zh});var le=u((VS,ja)=>{"use strict";var Yh=Ua();ja.exports=Yh});var xt=u((JS,Za)=>{"use strict";var ev=k(),tv=ev("toStringTag"),Xa={};Xa[tv]="z";Za.exports=String(Xa)==="[object z]"});var Xe=u((XS,es)=>{"use strict";var rv=xt(),iv=S(),At=je(),ov=k(),nv=ov("toStringTag"),av=Object,sv=At(function(){return arguments}())==="Arguments",uv=function(t,e){try{return t[e]}catch(r){}};es.exports=rv?At:function(t){var e,r,i;return t===void 0?"Undefined":t===null?"Null":typeof(r=uv(e=av(t),nv))=="string"?r:sv?At(e):(i=At(e))==="Object"&&iv(e.callee)?"Arguments":i}});var ui=u((ZS,ts)=>{"use strict";var cv=Xe(),lv=String;ts.exports=function(t){if(cv(t)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return lv(t)}});var is=u((eP,rs)=>{"use strict";var dv=Et(),fv=ui(),pv=be(),hv=RangeError;rs.exports=function(e){var r=fv(pv(this)),i="",o=dv(e);if(o<0||o===1/0)throw new hv("Wrong number of repetitions");for(;o>0;(o>>>=1)&&(r+=r))o&1&&(i+=r);return i}});var us=u((tP,ss)=>{"use strict";var as=O(),vv=Xr(),os=ui(),gv=is(),mv=be(),bv=as(gv),yv=as("".slice),Iv=Math.ceil,ns=function(t){return function(e,r,i){var o=os(mv(e)),n=vv(r),c=o.length,f=i===void 0?" ":os(i),d,p;return n<=c||f===""?o:(d=n-c,p=bv(f,Iv(d/f.length)),p.length>d&&(p=yv(p,0,d)),t?o+p:p+o)}};ss.exports={start:ns(!1),end:ns(!0)}});var ls=u((rP,cs)=>{"use strict";var _v=ue();cs.exports=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(_v)});var ds=u(()=>{"use strict";var Sv=C(),Pv=us().start,Tv=ls();Sv({target:"String",proto:!0,forced:Tv},{padStart:function(e){return Pv(this,e,arguments.length>1?arguments[1]:void 0)}})});var ps=u((nP,fs)=>{"use strict";ds();var Ev=wt();fs.exports=Ev("String","padStart")});var vs=u((aP,hs)=>{"use strict";var wv=ps();hs.exports=wv});var ms=u((sP,gs)=>{"use strict";var xv=vs();gs.exports=xv});var bs=u(()=>{"use strict"});var li=u((dP,ys)=>{"use strict";var et=_(),Ov=ue(),Cv=je(),Ot=function(t){return Ov.slice(0,t.length)===t};ys.exports=function(){return Ot("Bun/")?"BUN":Ot("Cloudflare-Workers")?"CLOUDFLARE":Ot("Deno/")?"DENO":Ot("Node.js/")?"NODE":et.Bun&&typeof Bun.version=="string"?"BUN":et.Deno&&typeof Deno.version=="object"?"DENO":Cv(et.process)==="process"?"NODE":et.window&&et.document?"BROWSER":"REST"}()});var Ct=u((fP,Is)=>{"use strict";var qv=li();Is.exports=qv==="NODE"});var Pe=u((pP,_s)=>{"use strict";var Rv=Ie();_s.exports=function(t,e,r,i){return i&&i.enumerable?t[e]=r:Rv(t,e,r),t}});var Ps=u((hP,Ss)=>{"use strict";var kv=O(),Lv=J();Ss.exports=function(t,e,r){try{return kv(Lv(Object.getOwnPropertyDescriptor(t,e)[r]))}catch(i){}}});var Es=u((vP,Ts)=>{"use strict";var Nv=V();Ts.exports=function(t){return Nv(t)||t===null}});var xs=u((gP,ws)=>{"use strict";var $v=Es(),Dv=String,Mv=TypeError;ws.exports=function(t){if($v(t))return t;throw new Mv("Can't set "+Dv(t)+" as a prototype")}});var di=u((mP,As)=>{"use strict";var Vv=Ps(),Fv=V(),Bv=be(),Uv=xs();As.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var t=!1,e={},r;try{r=Vv(Object.prototype,"__proto__","set"),r(e,[]),t=e instanceof Array}catch(i){}return function(o,n){return Bv(o),Uv(n),Fv(o)&&(t?r(o,n):o.__proto__=n),o}}():void 0)});var Cs=u((bP,Os)=>{"use strict";var jv=xt(),Hv=Xe();Os.exports=jv?{}.toString:function(){return"[object "+Hv(this)+"]"}});var tt=u((yP,Rs)=>{"use strict";var Wv=xt(),Kv=ce().f,Qv=Ie(),Gv=Q(),zv=Cs(),Yv=k(),qs=Yv("toStringTag");Rs.exports=function(t,e,r,i){var o=r?t:t&&t.prototype;o&&(Gv(o,qs)||Kv(o,qs,{configurable:!0,value:e}),i&&!Wv&&Qv(o,"toString",zv))}});var Ls=u((IP,ks)=>{"use strict";var Jv=ce();ks.exports=function(t,e,r){return Jv.f(t,e,r)}});var Ds=u((_P,$s)=>{"use strict";var Xv=Y(),Zv=Ls(),eg=k(),tg=R(),Ns=eg("species");$s.exports=function(t){var e=Xv(t);tg&&e&&!e[Ns]&&Zv(e,Ns,{configurable:!0,get:function(){return this}})}});var Vs=u((SP,Ms)=>{"use strict";var rg=It(),ig=TypeError;Ms.exports=function(t,e){if(rg(e,t))return t;throw new ig("Incorrect invocation")}});var pi=u((PP,Fs)=>{"use strict";var og=O(),ng=S(),fi=Qe(),ag=og(Function.toString);ng(fi.inspectSource)||(fi.inspectSource=function(t){return ag(t)});Fs.exports=fi.inspectSource});var Ks=u((TP,Ws)=>{"use strict";var sg=O(),ug=A(),Bs=S(),cg=Xe(),lg=Y(),dg=pi(),Us=function(){},js=lg("Reflect","construct"),hi=/^\s*(?:class|function)\b/,fg=sg(hi.exec),pg=!hi.test(Us),rt=function(e){if(!Bs(e))return!1;try{return js(Us,[],e),!0}catch(r){return!1}},Hs=function(e){if(!Bs(e))return!1;switch(cg(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return pg||!!fg(hi,dg(e))}catch(r){return!0}};Hs.sham=!0;Ws.exports=!js||ug(function(){var t;return rt(rt.call)||!rt(Object)||!rt(function(){t=!0})||t})?Hs:rt});var Gs=u((EP,Qs)=>{"use strict";var hg=Ks(),vg=Ke(),gg=TypeError;Qs.exports=function(t){if(hg(t))return t;throw new gg(vg(t)+" is not a constructor")}});var vi=u((wP,Ys)=>{"use strict";var zs=X(),mg=Gs(),bg=We(),yg=k(),Ig=yg("species");Ys.exports=function(t,e){var r=zs(t).constructor,i;return r===void 0||bg(i=zs(r)[Ig])?e:mg(i)}});var gi=u((xP,Js)=>{"use strict";var _g=Y();Js.exports=_g("document","documentElement")});var Zs=u((AP,Xs)=>{"use strict";var Sg=O();Xs.exports=Sg([].slice)});var tu=u((OP,eu)=>{"use strict";var Pg=TypeError;eu.exports=function(t,e){if(t<e)throw new Pg("Not enough arguments");return t}});var mi=u((CP,ru)=>{"use strict";var Tg=ue();ru.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(Tg)});var wi=u((qP,du)=>{"use strict";var L=_(),Eg=Pr(),wg=ze(),iu=S(),xg=Q(),lu=A(),ou=gi(),Ag=Zs(),nu=Pt(),Og=tu(),Cg=mi(),qg=Ct(),Pi=L.setImmediate,Ti=L.clearImmediate,Rg=L.process,bi=L.Dispatch,kg=L.Function,au=L.MessageChannel,Lg=L.String,yi=0,it={},su="onreadystatechange",ot,de,Ii,_i;lu(function(){ot=L.location});var Ei=function(t){if(xg(it,t)){var e=it[t];delete it[t],e()}},Si=function(t){return function(){Ei(t)}},uu=function(t){Ei(t.data)},cu=function(t){L.postMessage(Lg(t),ot.protocol+"//"+ot.host)};(!Pi||!Ti)&&(Pi=function(e){Og(arguments.length,1);var r=iu(e)?e:kg(e),i=Ag(arguments,1);return it[++yi]=function(){Eg(r,void 0,i)},de(yi),yi},Ti=function(e){delete it[e]},qg?de=function(t){Rg.nextTick(Si(t))}:bi&&bi.now?de=function(t){bi.now(Si(t))}:au&&!Cg?(Ii=new au,_i=Ii.port2,Ii.port1.onmessage=uu,de=wg(_i.postMessage,_i)):L.addEventListener&&iu(L.postMessage)&&!L.importScripts&&ot&&ot.protocol!=="file:"&&!lu(cu)?(de=cu,L.addEventListener("message",uu,!1)):su in nu("script")?de=function(t){ou.appendChild(nu("script"))[su]=function(){ou.removeChild(this),Ei(t)}}:de=function(t){setTimeout(Si(t),0)});du.exports={set:Pi,clear:Ti}});var hu=u((RP,pu)=>{"use strict";var fu=_(),Ng=R(),$g=Object.getOwnPropertyDescriptor;pu.exports=function(t){if(!Ng)return fu[t];var e=$g(fu,t);return e&&e.value}});var xi=u((kP,gu)=>{"use strict";var vu=function(){this.head=null,this.tail=null};vu.prototype={add:function(t){var e={item:t,next:null},r=this.tail;r?r.next=e:this.head=e,this.tail=e},get:function(){var t=this.head;if(t){var e=this.head=t.next;return e===null&&(this.tail=null),t.item}}};gu.exports=vu});var bu=u((LP,mu)=>{"use strict";var Dg=ue();mu.exports=/ipad|iphone|ipod/i.test(Dg)&&typeof Pebble!="undefined"});var Iu=u((NP,yu)=>{"use strict";var Mg=ue();yu.exports=/web0s(?!.*chrome)/i.test(Mg)});var xu=u(($P,wu)=>{"use strict";var Ee=_(),Vg=hu(),_u=ze(),Ai=wi().set,Fg=xi(),Bg=mi(),Ug=bu(),jg=Iu(),Oi=Ct(),Su=Ee.MutationObserver||Ee.WebKitMutationObserver,Pu=Ee.document,Tu=Ee.process,qt=Ee.Promise,Ri=Vg("queueMicrotask"),Te,Ci,qi,Rt,Eu;Ri||(nt=new Fg,at=function(){var t,e;for(Oi&&(t=Tu.domain)&&t.exit();e=nt.get();)try{e()}catch(r){throw nt.head&&Te(),r}t&&t.enter()},!Bg&&!Oi&&!jg&&Su&&Pu?(Ci=!0,qi=Pu.createTextNode(""),new Su(at).observe(qi,{characterData:!0}),Te=function(){qi.data=Ci=!Ci}):!Ug&&qt&&qt.resolve?(Rt=qt.resolve(void 0),Rt.constructor=qt,Eu=_u(Rt.then,Rt),Te=function(){Eu(at)}):Oi?Te=function(){Tu.nextTick(at)}:(Ai=_u(Ai,Ee),Te=function(){Ai(at)}),Ri=function(t){nt.head||Te(),nt.add(t)});var nt,at;wu.exports=Ri});var Ou=u((DP,Au)=>{"use strict";Au.exports=function(t,e){try{arguments.length===1?console.error(t):console.error(t,e)}catch(r){}}});var kt=u((MP,Cu)=>{"use strict";Cu.exports=function(t){try{return{error:!1,value:t()}}catch(e){return{error:!0,value:e}}}});var ku=u((VP,Ru)=>{"use strict";var Hg=_(),Wg=S(),qu=Hg.WeakMap;Ru.exports=Wg(qu)&&/native code/.test(String(qu))});var Lt=u((FP,Nu)=>{"use strict";var Kg=Vr(),Qg=Br(),Lu=Kg("keys");Nu.exports=function(t){return Lu[t]||(Lu[t]=Qg(t))}});var Nt=u((BP,$u)=>{"use strict";$u.exports={}});var $i=u((UP,Vu)=>{"use strict";var Gg=ku(),Mu=_(),zg=V(),Yg=Ie(),ki=Q(),Li=Qe(),Jg=Lt(),Xg=Nt(),Du="Object already initialized",Ni=Mu.TypeError,Zg=Mu.WeakMap,$t,st,Dt,em=function(t){return Dt(t)?st(t):$t(t,{})},tm=function(t){return function(e){var r;if(!zg(e)||(r=st(e)).type!==t)throw new Ni("Incompatible receiver, "+t+" required");return r}};Gg||Li.state?(B=Li.state||(Li.state=new Zg),B.get=B.get,B.has=B.has,B.set=B.set,$t=function(t,e){if(B.has(t))throw new Ni(Du);return e.facade=t,B.set(t,e),e},st=function(t){return B.get(t)||{}},Dt=function(t){return B.has(t)}):(fe=Jg("state"),Xg[fe]=!0,$t=function(t,e){if(ki(t,fe))throw new Ni(Du);return e.facade=t,Yg(t,fe,e),e},st=function(t){return ki(t,fe)?t[fe]:{}},Dt=function(t){return ki(t,fe)});var B,fe;Vu.exports={set:$t,get:st,has:Dt,enforce:em,getterFor:tm}});var pe=u((jP,Fu)=>{"use strict";var rm=_();Fu.exports=rm.Promise});var we=u((HP,Hu)=>{"use strict";var im=_(),ut=pe(),om=S(),nm=Kr(),am=pi(),sm=k(),Bu=li(),um=K(),Di=Rr(),Uu=ut&&ut.prototype,cm=sm("species"),Mi=!1,ju=om(im.PromiseRejectionEvent),lm=nm("Promise",function(){var t=am(ut),e=t!==String(ut);if(!e&&Di===66||um&&!(Uu.catch&&Uu.finally))return!0;if(!Di||Di<51||!/native code/.test(t)){var r=new ut(function(n){n(1)}),i=function(n){n(function(){},function(){})},o=r.constructor={};if(o[cm]=i,Mi=r.then(function(){})instanceof i,!Mi)return!0}return!e&&(Bu==="BROWSER"||Bu==="DENO")&&!ju});Hu.exports={CONSTRUCTOR:lm,REJECTION_EVENT:ju,SUBCLASSING:Mi}});var xe=u((WP,Ku)=>{"use strict";var Wu=J(),dm=TypeError,fm=function(t){var e,r;this.promise=new t(function(i,o){if(e!==void 0||r!==void 0)throw new dm("Bad Promise constructor");e=i,r=o}),this.resolve=Wu(e),this.reject=Wu(r)};Ku.exports.f=function(t){return new fm(t)}});var fc=u(()=>{"use strict";var pm=C(),hm=K(),Bt=Ct(),oe=_(),vm=se(),qe=M(),Qu=Pe(),Gu=di(),gm=tt(),mm=Ds(),bm=J(),Ft=S(),ym=V(),Im=Vs(),_m=vi(),Zu=wi().set,ji=xu(),Sm=Ou(),Pm=kt(),Tm=xi(),ec=$i(),Ut=pe(),Hi=we(),tc=xe(),jt="Promise",rc=Hi.CONSTRUCTOR,Em=Hi.REJECTION_EVENT,wm=Hi.SUBCLASSING,Vi=ec.getterFor(jt),xm=ec.set,Ae=Ut&&Ut.prototype,he=Ut,Mt=Ae,ic=oe.TypeError,Fi=oe.document,Wi=oe.process,Bi=tc.f,Am=Bi,Om=!!(Fi&&Fi.createEvent&&oe.dispatchEvent),oc="unhandledrejection",Cm="rejectionhandled",zu=0,nc=1,qm=2,Ki=1,ac=2,Vt,Yu,sc,Ju,uc=function(t){var e;return ym(t)&&Ft(e=t.then)?e:!1},cc=function(t,e){var r=e.value,i=e.state===nc,o=i?t.ok:t.fail,n=t.resolve,c=t.reject,f=t.domain,d,p,v;try{o?(i||(e.rejection===ac&&km(e),e.rejection=Ki),o===!0?d=r:(f&&f.enter(),d=o(r),f&&(f.exit(),v=!0)),d===t.promise?c(new ic("Promise-chain cycle")):(p=uc(d))?qe(p,d,n,c):n(d)):c(r)}catch(a){f&&!v&&f.exit(),c(a)}},lc=function(t,e){t.notified||(t.notified=!0,ji(function(){for(var r=t.reactions,i;i=r.get();)cc(i,t);t.notified=!1,e&&!t.rejection&&Rm(t)}))},dc=function(t,e,r){var i,o;Om?(i=Fi.createEvent("Event"),i.promise=e,i.reason=r,i.initEvent(t,!1,!0),oe.dispatchEvent(i)):i={promise:e,reason:r},!Em&&(o=oe["on"+t])?o(i):t===oc&&Sm("Unhandled promise rejection",r)},Rm=function(t){qe(Zu,oe,function(){var e=t.facade,r=t.value,i=Xu(t),o;if(i&&(o=Pm(function(){Bt?Wi.emit("unhandledRejection",r,e):dc(oc,e,r)}),t.rejection=Bt||Xu(t)?ac:Ki,o.error))throw o.value})},Xu=function(t){return t.rejection!==Ki&&!t.parent},km=function(t){qe(Zu,oe,function(){var e=t.facade;Bt?Wi.emit("rejectionHandled",e):dc(Cm,e,t.value)})},Oe=function(t,e,r){return function(i){t(e,i,r)}},Ce=function(t,e,r){t.done||(t.done=!0,r&&(t=r),t.value=e,t.state=qm,lc(t,!0))},Ui=function(t,e,r){if(!t.done){t.done=!0,r&&(t=r);try{if(t.facade===e)throw new ic("Promise can't be resolved itself");var i=uc(e);i?ji(function(){var o={done:!1};try{qe(i,e,Oe(Ui,o,t),Oe(Ce,o,t))}catch(n){Ce(o,n,t)}}):(t.value=e,t.state=nc,lc(t,!1))}catch(o){Ce({done:!1},o,t)}}};if(rc&&(he=function(e){Im(this,Mt),bm(e),qe(Vt,this);var r=Vi(this);try{e(Oe(Ui,r),Oe(Ce,r))}catch(i){Ce(r,i)}},Mt=he.prototype,Vt=function(e){xm(this,{type:jt,done:!1,notified:!1,parent:!1,reactions:new Tm,rejection:!1,state:zu,value:null})},Vt.prototype=Qu(Mt,"then",function(e,r){var i=Vi(this),o=Bi(_m(this,he));return i.parent=!0,o.ok=Ft(e)?e:!0,o.fail=Ft(r)&&r,o.domain=Bt?Wi.domain:void 0,i.state===zu?i.reactions.add(o):ji(function(){cc(o,i)}),o.promise}),Yu=function(){var t=new Vt,e=Vi(t);this.promise=t,this.resolve=Oe(Ui,e),this.reject=Oe(Ce,e)},tc.f=Bi=function(t){return t===he||t===sc?new Yu(t):Am(t)},!hm&&Ft(Ut)&&Ae!==Object.prototype)){Ju=Ae.then,wm||Qu(Ae,"then",function(e,r){var i=this;return new he(function(o,n){qe(Ju,i,o,n)}).then(e,r)},{unsafe:!0});try{delete Ae.constructor}catch(t){}Gu&&Gu(Ae,Mt)}pm({global:!0,constructor:!0,wrap:!0,forced:rc},{Promise:he});sc=vm.Promise;gm(he,jt,!1,!0);mm(jt)});var ve=u((GP,pc)=>{"use strict";pc.exports={}});var vc=u((zP,hc)=>{"use strict";var Lm=k(),Nm=ve(),$m=Lm("iterator"),Dm=Array.prototype;hc.exports=function(t){return t!==void 0&&(Nm.Array===t||Dm[$m]===t)}});var Qi=u((YP,mc)=>{"use strict";var Mm=Xe(),gc=St(),Vm=We(),Fm=ve(),Bm=k(),Um=Bm("iterator");mc.exports=function(t){if(!Vm(t))return gc(t,Um)||gc(t,"@@iterator")||Fm[Mm(t)]}});var yc=u((JP,bc)=>{"use strict";var jm=M(),Hm=J(),Wm=X(),Km=Ke(),Qm=Qi(),Gm=TypeError;bc.exports=function(t,e){var r=arguments.length<2?Qm(t):e;if(Hm(r))return Wm(jm(r,t));throw new Gm(Km(t)+" is not iterable")}});var Sc=u((XP,_c)=>{"use strict";var zm=M(),Ic=X(),Ym=St();_c.exports=function(t,e,r){var i,o;Ic(t);try{if(i=Ym(t,"return"),!i){if(e==="throw")throw r;return r}i=zm(i,t)}catch(n){o=!0,i=n}if(e==="throw")throw r;if(o)throw i;return Ic(i),r}});var Wt=u((ZP,wc)=>{"use strict";var Jm=ze(),Xm=M(),Zm=X(),eb=Ke(),tb=vc(),rb=Zr(),Pc=It(),ib=yc(),ob=Qi(),Tc=Sc(),nb=TypeError,Ht=function(t,e){this.stopped=t,this.result=e},Ec=Ht.prototype;wc.exports=function(t,e,r){var i=r&&r.that,o=!!(r&&r.AS_ENTRIES),n=!!(r&&r.IS_RECORD),c=!!(r&&r.IS_ITERATOR),f=!!(r&&r.INTERRUPTED),d=Jm(e,i),p,v,a,s,l,h,g,m=function(I){return p&&Tc(p,"normal"),new Ht(!0,I)},b=function(I){return o?(Zm(I),f?d(I[0],I[1],m):d(I[0],I[1])):f?d(I,m):d(I)};if(n)p=t.iterator;else if(c)p=t;else{if(v=ob(t),!v)throw new nb(eb(t)+" is not iterable");if(tb(v)){for(a=0,s=rb(t);s>a;a++)if(l=b(t[a]),l&&Pc(Ec,l))return l;return new Ht(!1)}p=ib(t,v)}for(h=n?t.next:p.next;!(g=Xm(h,p)).done;){try{l=b(g.value)}catch(I){Tc(p,"throw",I)}if(typeof l=="object"&&l&&Pc(Ec,l))return l}return new Ht(!1)}});var qc=u((eT,Cc)=>{"use strict";var ab=k(),Ac=ab("iterator"),Oc=!1;try{xc=0,Gi={next:function(){return{done:!!xc++}},return:function(){Oc=!0}},Gi[Ac]=function(){return this},Array.from(Gi,function(){throw 2})}catch(t){}var xc,Gi;Cc.exports=function(t,e){try{if(!e&&!Oc)return!1}catch(o){return!1}var r=!1;try{var i={};i[Ac]=function(){return{next:function(){return{done:r=!0}}}},t(i)}catch(o){}return r}});var zi=u((tT,Rc)=>{"use strict";var sb=pe(),ub=qc(),cb=we().CONSTRUCTOR;Rc.exports=cb||!ub(function(t){sb.all(t).then(void 0,function(){})})});var kc=u(()=>{"use strict";var lb=C(),db=M(),fb=J(),pb=xe(),hb=kt(),vb=Wt(),gb=zi();lb({target:"Promise",stat:!0,forced:gb},{all:function(e){var r=this,i=pb.f(r),o=i.resolve,n=i.reject,c=hb(function(){var f=fb(r.resolve),d=[],p=0,v=1;vb(e,function(a){var s=p++,l=!1;v++,db(f,r,a).then(function(h){l||(l=!0,d[s]=h,--v||o(d))},n)}),--v||o(d)});return c.error&&n(c.value),i.promise}})});var Nc=u(()=>{"use strict";var mb=C(),bb=K(),yb=we().CONSTRUCTOR,Ji=pe(),Ib=Y(),_b=S(),Sb=Pe(),Lc=Ji&&Ji.prototype;mb({target:"Promise",proto:!0,forced:yb,real:!0},{catch:function(t){return this.then(void 0,t)}});!bb&&_b(Ji)&&(Yi=Ib("Promise").prototype.catch,Lc.catch!==Yi&&Sb(Lc,"catch",Yi,{unsafe:!0}));var Yi});var $c=u(()=>{"use strict";var Pb=C(),Tb=M(),Eb=J(),wb=xe(),xb=kt(),Ab=Wt(),Ob=zi();Pb({target:"Promise",stat:!0,forced:Ob},{race:function(e){var r=this,i=wb.f(r),o=i.reject,n=xb(function(){var c=Eb(r.resolve);Ab(e,function(f){Tb(c,r,f).then(i.resolve,o)})});return n.error&&o(n.value),i.promise}})});var Dc=u(()=>{"use strict";var Cb=C(),qb=xe(),Rb=we().CONSTRUCTOR;Cb({target:"Promise",stat:!0,forced:Rb},{reject:function(e){var r=qb.f(this),i=r.reject;return i(e),r.promise}})});var Xi=u((lT,Mc)=>{"use strict";var kb=X(),Lb=V(),Nb=xe();Mc.exports=function(t,e){if(kb(t),Lb(e)&&e.constructor===t)return e;var r=Nb.f(t),i=r.resolve;return i(e),r.promise}});var Bc=u(()=>{"use strict";var $b=C(),Db=Y(),Vc=K(),Mb=pe(),Fc=we().CONSTRUCTOR,Vb=Xi(),Fb=Db("Promise"),Bb=Vc&&!Fc;$b({target:"Promise",stat:!0,forced:Vc||Fc},{resolve:function(e){return Vb(Bb&&this===Fb?Mb:this,e)}})});var Uc=u(()=>{"use strict";fc();kc();Nc();$c();Dc();Bc()});var Kc=u(()=>{"use strict";var Ub=C(),jb=K(),Kt=pe(),Hb=A(),Hc=Y(),Wc=S(),Wb=vi(),jc=Xi(),Kb=Pe(),eo=Kt&&Kt.prototype,Qb=!!Kt&&Hb(function(){eo.finally.call({then:function(){}},function(){})});Ub({target:"Promise",proto:!0,real:!0,forced:Qb},{finally:function(t){var e=Wb(this,Hc("Promise")),r=Wc(t);return this.then(r?function(i){return jc(e,t()).then(function(){return i})}:t,r?function(i){return jc(e,t()).then(function(){throw i})}:t)}});!jb&&Wc(Kt)&&(Zi=Hc("Promise").prototype.finally,eo.finally!==Zi&&Kb(eo,"finally",Zi,{unsafe:!0}));var Zi});var Gc=u((mT,Qc)=>{"use strict";bs();Uc();Kc();var Gb=wt();Qc.exports=Gb("Promise","finally")});var Yc=u((bT,zc)=>{"use strict";var zb=Gc();zc.exports=zb});var to=u((yT,Jc)=>{"use strict";var Yb=Yc();Jc.exports=Yb});var Zc=u((IT,Xc)=>{"use strict";var Jb=A();Xc.exports=!Jb(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})});var Qt=u((_T,tl)=>{"use strict";var Xb=Q(),Zb=S(),ey=Fr(),ty=Lt(),ry=Zc(),el=ty("IE_PROTO"),ro=Object,iy=ro.prototype;tl.exports=ry?ro.getPrototypeOf:function(t){var e=ey(t);if(Xb(e,el))return e[el];var r=e.constructor;return Zb(r)&&e instanceof r?r.prototype:e instanceof ro?iy:null}});var ol=u((ST,il)=>{"use strict";var oy=O(),io=Q(),ny=ae(),ay=ei().indexOf,sy=Nt(),rl=oy([].push);il.exports=function(t,e){var r=ny(t),i=0,o=[],n;for(n in r)!io(sy,n)&&io(r,n)&&rl(o,n);for(;e.length>i;)io(r,n=e[i++])&&(~ay(o,n)||rl(o,n));return o}});var oo=u((PT,nl)=>{"use strict";nl.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var no=u((TT,al)=>{"use strict";var uy=ol(),cy=oo();al.exports=Object.keys||function(e){return uy(e,cy)}});var ao=u((ET,dl)=>{"use strict";var ul=R(),ly=A(),cl=O(),dy=Qt(),fy=no(),py=ae(),hy=xr().f,ll=cl(hy),vy=cl([].push),gy=ul&&ly(function(){var t=Object.create(null);return t[2]=2,!ll(t,2)}),sl=function(t){return function(e){for(var r=py(e),i=fy(r),o=gy&&dy(r)===null,n=i.length,c=0,f=[],d;n>c;)d=i[c++],(!ul||(o?d in r:ll(r,d)))&&vy(f,t?[d,r[d]]:r[d]);return f}};dl.exports={entries:sl(!0),values:sl(!1)}});var fl=u(()=>{"use strict";var my=C(),by=ao().entries;my({target:"Object",stat:!0},{entries:function(e){return by(e)}})});var hl=u((AT,pl)=>{"use strict";fl();var yy=se();pl.exports=yy.Object.entries});var gl=u((OT,vl)=>{"use strict";var Iy=hl();vl.exports=Iy});var Re=u((CT,ml)=>{"use strict";var _y=gl();ml.exports=_y});var Il=u((qT,yl)=>{"use strict";var so=R(),Sy=Q(),bl=Function.prototype,Py=so&&Object.getOwnPropertyDescriptor,uo=Sy(bl,"name"),Ty=uo&&function(){}.name==="something",Ey=uo&&(!so||so&&Py(bl,"name").configurable);yl.exports={EXISTS:uo,PROPER:Ty,CONFIGURABLE:Ey}});var Sl=u(_l=>{"use strict";var wy=R(),xy=Qr(),Ay=ce(),Oy=X(),Cy=ae(),qy=no();_l.f=wy&&!xy?Object.defineProperties:function(e,r){Oy(e);for(var i=Cy(r),o=qy(r),n=o.length,c=0,f;n>c;)Ay.f(e,f=o[c++],i[f]);return e}});var po=u((kT,Ol)=>{"use strict";var Ry=X(),ky=Sl(),Pl=oo(),Ly=Nt(),Ny=gi(),$y=Pt(),Dy=Lt(),Tl=">",El="<",lo="prototype",fo="script",xl=Dy("IE_PROTO"),co=function(){},Al=function(t){return El+fo+Tl+t+El+"/"+fo+Tl},wl=function(t){t.write(Al("")),t.close();var e=t.parentWindow.Object;return t=null,e},My=function(){var t=$y("iframe"),e="java"+fo+":",r;return t.style.display="none",Ny.appendChild(t),t.src=String(e),r=t.contentWindow.document,r.open(),r.write(Al("document.F=Object")),r.close(),r.F},Gt,zt=function(){try{Gt=new ActiveXObject("htmlfile")}catch(e){}zt=typeof document!="undefined"?document.domain&&Gt?wl(Gt):My():wl(Gt);for(var t=Pl.length;t--;)delete zt[lo][Pl[t]];return zt()};Ly[xl]=!0;Ol.exports=Object.create||function(e,r){var i;return e!==null?(co[lo]=Ry(e),i=new co,co[lo]=null,i[xl]=e):i=zt(),r===void 0?i:ky.f(i,r)}});var mo=u((LT,Rl)=>{"use strict";var Vy=A(),Fy=S(),By=V(),Uy=po(),Cl=Qt(),jy=Pe(),Hy=k(),Wy=K(),go=Hy("iterator"),ql=!1,Z,ho,vo;[].keys&&(vo=[].keys(),"next"in vo?(ho=Cl(Cl(vo)),ho!==Object.prototype&&(Z=ho)):ql=!0);var Ky=!By(Z)||Vy(function(){var t={};return Z[go].call(t)!==t});Ky?Z={}:Wy&&(Z=Uy(Z));Fy(Z[go])||jy(Z,go,function(){return this});Rl.exports={IteratorPrototype:Z,BUGGY_SAFARI_ITERATORS:ql}});var Ll=u((NT,kl)=>{"use strict";var Qy=mo().IteratorPrototype,Gy=po(),zy=He(),Yy=tt(),Jy=ve(),Xy=function(){return this};kl.exports=function(t,e,r,i){var o=e+" Iterator";return t.prototype=Gy(Qy,{next:zy(+!i,r)}),Yy(t,o,!1,!0),Jy[o]=Xy,t}});var Wl=u(($T,Hl)=>{"use strict";var Zy=C(),eI=M(),Yt=K(),Ul=Il(),tI=S(),rI=Ll(),Nl=Qt(),$l=di(),iI=tt(),oI=Ie(),bo=Pe(),nI=k(),Dl=ve(),jl=mo(),aI=Ul.PROPER,sI=Ul.CONFIGURABLE,Ml=jl.IteratorPrototype,Jt=jl.BUGGY_SAFARI_ITERATORS,ct=nI("iterator"),Vl="keys",lt="values",Fl="entries",Bl=function(){return this};Hl.exports=function(t,e,r,i,o,n,c){rI(r,e,i);var f=function(b){if(b===o&&s)return s;if(!Jt&&b&&b in v)return v[b];switch(b){case Vl:return function(){return new r(this,b)};case lt:return function(){return new r(this,b)};case Fl:return function(){return new r(this,b)}}return function(){return new r(this)}},d=e+" Iterator",p=!1,v=t.prototype,a=v[ct]||v["@@iterator"]||o&&v[o],s=!Jt&&a||f(o),l=e==="Array"&&v.entries||a,h,g,m;if(l&&(h=Nl(l.call(new t)),h!==Object.prototype&&h.next&&(!Yt&&Nl(h)!==Ml&&($l?$l(h,Ml):tI(h[ct])||bo(h,ct,Bl)),iI(h,d,!0,!0),Yt&&(Dl[d]=Bl))),aI&&o===lt&&a&&a.name!==lt&&(!Yt&&sI?oI(v,"name",lt):(p=!0,s=function(){return eI(a,this)})),o)if(g={values:f(lt),keys:n?s:f(Vl),entries:f(Fl)},c)for(m in g)(Jt||p||!(m in v))&&bo(v,m,g[m]);else Zy({target:e,proto:!0,forced:Jt||p},g);return(!Yt||c)&&v[ct]!==s&&bo(v,ct,s,{name:o}),Dl[e]=s,g}});var Ql=u((DT,Kl)=>{"use strict";Kl.exports=function(t,e){return{value:t,done:e}}});var Io=u((MT,Xl)=>{"use strict";var uI=ae(),yo=ti(),Gl=ve(),Yl=$i(),cI=ce().f,lI=Wl(),Xt=Ql(),dI=K(),fI=R(),Jl="Array Iterator",pI=Yl.set,hI=Yl.getterFor(Jl);Xl.exports=lI(Array,"Array",function(t,e){pI(this,{type:Jl,target:uI(t),index:0,kind:e})},function(){var t=hI(this),e=t.target,r=t.index++;if(!e||r>=e.length)return t.target=null,Xt(void 0,!0);switch(t.kind){case"keys":return Xt(r,!1);case"values":return Xt(e[r],!1)}return Xt([r,e[r]],!1)},"values");var zl=Gl.Arguments=Gl.Array;yo("keys");yo("values");yo("entries");if(!dI&&fI&&zl.name!=="values")try{cI(zl,"name",{value:"values"})}catch(t){}});var ed=u((VT,Zl)=>{"use strict";var vI=R(),gI=ce(),mI=He();Zl.exports=function(t,e,r){vI?gI.f(t,e,mI(0,r)):t[e]=r}});var td=u(()=>{"use strict";var bI=C(),yI=Wt(),II=ed();bI({target:"Object",stat:!0},{fromEntries:function(e){var r={};return yI(e,function(i,o){II(r,i,o)},{AS_ENTRIES:!0}),r}})});var id=u((UT,rd)=>{"use strict";Io();td();var _I=se();rd.exports=_I.Object.fromEntries});var nd=u((jT,od)=>{"use strict";od.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}});var sd=u(()=>{"use strict";Io();var SI=nd(),PI=_(),TI=tt(),ad=ve();for(Zt in SI)TI(PI[Zt],Zt),ad[Zt]=ad.Array;var Zt});var cd=u((KT,ud)=>{"use strict";var EI=id();sd();ud.exports=EI});var dd=u((QT,ld)=>{"use strict";var wI=cd();ld.exports=wI});var $d=u(()=>{"use strict";var YI=C(),JI=ao().values;YI({target:"Object",stat:!0},{values:function(e){return JI(e)}})});var Md=u((tx,Dd)=>{"use strict";$d();var XI=se();Dd.exports=XI.Object.values});var Fd=u((rx,Vd)=>{"use strict";var ZI=Md();Vd.exports=ZI});var Ud=u((ix,Bd)=>{"use strict";var e_=Fd();Bd.exports=e_});var Co=E(le(),1);var Jh=(t,e,r)=>{if(typeof t.canParse=="function")return t.canParse(e,r);try{return new t(e,r),!0}catch(i){return!1}},Ha=Jh;var Je=(c=>(c.PROD="prod",c.VK_ALIAS="vk_alias",c.VIDEOTEST="videotest",c.TEST="test",c.OKCDN="okcdn",c.AUTO="auto",c))(Je||{}),ri=(p=>(p.Q144P="mobile",p.Q240P="lowest",p.Q360P="low",p.Q480P="medium",p.Q720P="high",p.Q1080P="fullhd",p.Q1440P="quadhd",p.Q2160P="ultrahd",p.UNKNOWN="unknown",p))(ri||{}),ii=(h=>(h.MP4="mp4",h.DASH="dash",h.DASH_SEP="dash_sep",h.ONDEMAND_DASH="ondemand_dash",h.HLS="hls",h.HLS_FMP4="hls_fmp4",h.ONDEMAND_HLS="ondemand_hls",h.WEBM="webm",h.AV1="av1",h.ONDEMAND_DASH_LIVE="ondemand_dash_live",h.ONDEMAND_HLS_LIVE="ondemand_hls_live",h.WEBRTC="webrtc",h.UNKNOWN="unknown",h.RTMP="rtmp",h))(ii||{});var oi=(i=>(i.HTTP1="http1",i.HTTP2="http2",i.HTTP3="http3",i))(oi||{});var ni=(d=>(d.SLIDER="slider",d.RICH="rich",d.DOUBLE_TAP="double_tap",d.TIME_CODE="time_code",d.EPISODE="episode",d.REWIND="rewind",d.LIVE="live",d.UNKNOWN="unknown",d))(ni||{}),Wa=(n=>(n.GRAPH_SHOW="iGraphShow",n.GRAPH_HIDE="iGraphHide",n.NEXT_AREA="iNextChapterArea",n.NEXT_BUTTON="iNextChapterBtn",n.WATCH_AGAIN="iWatchAgainBtn",n))(Wa||{}),Ka={action_play:"ap",action_play_interactive:"api",first_bytes:"fb",player_ready:"pr",first_frame:"ff",seek:"sk",watch_coverage_record:"wr",watch_coverage_live:"wl",empty_buffer:"eb",action_stop:"as",close_at_empty_buffer:"cb",content_error:"er",player_interface_click:"pc",next_movie:"nm",track_switch:"ts",failover:"fo",quality:"qt"},Qa={vsid:"si",isid:"is",vid:"vi",place:"pl",quality:"qt",cdn_host:"ch",stat_type:"st",param:"pm",vk_app_id:"va",track_code:"tc",connection_type:"cnt",connection_reused:"cr",cached_data:"cd",live:"lv",muted:"mu",mode:"mo",subtitles:"sb",failover:"fo",download_speed:"ds",manual_quality:"mq",ref_domain:"rd",direct_url:"du"},Ga={unknown:"un",mobile:"m",lowest:"ls",low:"l",medium:"md",high:"h",fullhd:"f",quadhd:"q",ultrahd:"u"},za={pip:"pi",fullscreen:"fs",external:"ex",prefetch:"pr",airplay:"ap",chromecast:"cc",invisible:"iv",minimal:"minimal"};import{fillWithDefault as Xh}from"@vkontakte/videoplayer-shared/es2018";var Ya="CIOPGQJGDIHBABABA",ai={prod:"https://api.ok.ru",vk_alias:"https://api.mycdn.me",videotest:"https://videotestapi.ok.ru/api",test:"https://apitest.ok.ru",okcdn:"https://api.okcdn.ru",auto:""};var Zh={apiEnv:"vk_alias",apiKey:Ya,apiBaseUrl:null,requestRetryCount:1,useVsid64:!1,firstFlushTime:5e3,flushDebounceTime:1e4,flushMaxWait:6e4,storageExpiration:36*60*60*1e3,watchCoverageInterval:15e3,disabledOperations:["quality"],disabledCustomFields:[],shorten:!0,maxLoops:100,embedUrlParams:[],useBeacon:!0,synchronizeTime:!0,debugLog:!1,clearStorageAtUnload:!0,useVKComIsMobileLogic:!1,backoff:{start:1e3,factor:1.5,max:5*60*1e3,random:.1},useKeepalive:!1,watchCoverageTimeoutFix:!1},Ja=t=>Xh(t,Zh);function si(){let t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),e=new Array(36),r=0,i,o;for(o=0;o<36;o++)o===8||o===13||o===18||o===23?e[o]="-":o===14?e[o]="4":(r<=2&&(r=33554432+Math.random()*16777216|0),i=r&15,r=r>>4,e[o]=t[o===19?i&3|8:i]);return e.join("")}import{assertNonNullable as UI,combine as qd,fromEvent as Rd,isNonNullable as De,isNullable as kd,merge as jI,now as ee,observableFrom as HI,once as WI,safeStorage as Ld,Subject as KI,Subscription as qo,ValueSubject as ur}from"@vkontakte/videoplayer-shared/es2018";import{Logger as QI,detectEmbed as GI}from"@vkontakte/videoplayer-shared/es2018";var ci=E(ms(),1),Av=()=>(0,ci.default)(Math.floor(Math.random()*2**32).toString(36),13,"0"),Ze=()=>(0,ci.default)(Math.floor(Math.random()*2**64).toString(36),13,"0"),ie=class t{static getVSID(){return t.vsid}static generateVSID(e){return t.vsid=e?Ze():Av(),t.vsid}};var er=E(to(),1);var fd=E(Re(),1),pd=E(dd(),1);var hd=t=>{var o;let{operation:e,custom:r}=t,i=(0,pd.default)((0,fd.default)(r).map(([n,c])=>{var p,v,a;let f=(p=Qa[n])!=null?p:n,d=c;return c&&(n==="mode"?d=(v=za[c])!=null?v:c:n==="quality"&&(d=(a=Ga[c])!=null?a:c)),[f,d]}));return{...t,operation:(o=Ka[e])!=null?o:e,custom:i}};var D="1.0.100-dev.04f0bb5f.0";import{ValueSubject as xI,getExponentialDelay as AI,ErrorCategory as ke}from"@vkontakte/videoplayer-shared/es2018";var OI=/Mobile|mini|Fennec|Android|iP(ad|od|hone)|opera (mini|mobi)/i,dt=class{constructor(e){this.consequentAuthErrors=0;this.authorized$=new xI(!1);this.params=e}async authorize(e){return this.authToken=e!=null?e:await this.refreshAuthToken(),this._authorizeWithBackoff()}logBeacon(e){let r="log.externalLog",i=this.createLogParams(e),o=this.sessionKey;if(!o)return;this.params.apiTransport.sendBeacon(r,i,o)||this.logRequest(e).catch(()=>{})}async logRequest(e){var c;let r="log.externalLog",i=this.createLogParams(e),o=(c=this.sessionKey)!=null?c:await this._authorizeWithBackoff();if(!o)return;let n=async(f,d=this.params.config.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(r,i,o)}catch(p){if(!p||!("error_code"in p)){this.params.error$.next({id:"logRequestUnknown",category:ke.NETWORK,message:`Unknown ${r} error`,thrown:p});return}let v=p==null?void 0:p.error_code;switch(v){case 102:case 103:case 104:return this.authorized$.next(!1),this.sessionKey=await this._authorizeWithBackoff(),d>0?n(f,d-1):void 0;case 401:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorizeWithBackoff(),d>0?n(f,d-1):void 0;default:{this.params.error$.next({id:`LogRequest#${v}`,category:ke.EXTERNAL_API,message:`${r} error`,data:p});return}}}};return n(e)}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}async refreshAuthToken(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=(0,er.default)(this.params.refreshAuthToken(),()=>{this.refreshAuthTokenPromise=void 0})),this.refreshAuthTokenPromise}createLogParams(e){let r="WEB",i=!1,o=`@vkontakte/videoplayer-statistics:${D}`;if(this.params.config.useVKComIsMobileLogic){let{appVersion:n}=window.navigator;i=OI.test(n)}else this.params.mobile&&(i=!0);return i&&(r="M_WEB"),this.params.vktvVersion&&(r="SMART_TV",o=this.params.vktvVersion),{collector:"ok.mobile.apps.video",data:JSON.stringify({application:o,platform:r,items:this.params.config.shorten?e.map(hd):e})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();let e=AI(this.consequentAuthErrors,this.params.config.backoff);return new Promise(r=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout(()=>{(0,er.default)(this._authorize().then(r).catch(i=>this.params.error$.next({id:"AuthorizeBackoff",category:ke.NETWORK,message:"Otherwise unhandled error in authorization",thrown:i})),()=>this.backoffTimeoutId=0)},e))})}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);let e="auth.anonymLogin",r={session_data:{version:2,device_id:this.params.deviceId,client_version:D.split("-")[0],client_type:"SDK_JS"}};return this.authToken!==void 0&&(r.session_data.auth_token=this.authToken,r.session_data.version=3),this.authorizePromise=(0,er.default)(this.params.apiTransport.sendRequest(e,r).then(i=>{var o;return(!i||!i.session_key)&&this.params.error$.next({id:"AuthorizeFailed",category:ke.EXTERNAL_API,message:"No session key",data:i}),this.sessionKey=(o=i==null?void 0:i.session_key)!=null?o:void 0,this.sessionKey}).catch(async i=>{this.sessionKey=void 0;let o=i==null?void 0:i.error_code;switch(o){case 401:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}o?this.params.error$.next({id:`Authorize#${o}`,category:ke.EXTERNAL_API,message:"authorize error",data:i}):this.params.error$.next({id:"AuthorizeUnknown",category:ke.NETWORK,message:"authorize error",thrown:i})}),()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise}};var{NativeAbortSignal:aE,NativeAbortController:sE}=function(t){return{NativeAbortSignal:t.AbortSignal,NativeAbortController:t.AbortController}}(typeof self!="undefined"?self:global);function vd(t){let e;try{e=new Event("abort")}catch(r){typeof document!="undefined"?document.createEvent?(e=document.createEvent("Event"),e.initEvent("abort",!1,!1)):(e=document.createEventObject(),e.type="abort"):e={type:"abort",bubbles:!1,cancelable:!1}}return e.reason=t,e}function gd(t){if(t===void 0)if(typeof document=="undefined")t=new Error("This operation was aborted"),t.name="AbortError";else try{t=new DOMException("signal is aborted without reason"),Object.defineProperty(t,"name",{value:"AbortError"})}catch(e){t=new Error("This operation was aborted"),t.name="AbortError"}return t}var tr=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,r,i){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:r,options:i})}removeEventListener(e,r){if(!(e in this.listeners))return;let i=this.listeners[e];for(let o=0,n=i.length;o<n;o++)if(i[o].callback===r){i.splice(o,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let i=this.listeners[e.type].slice();for(let o=0,n=i.length;o<n;o++){let c=i[o];try{c.callback.call(this,e)}catch(f){Promise.resolve().then(()=>{throw f})}c.options&&c.options.once&&this.removeEventListener(e.type,c.callback)}return!e.defaultPrevented}},Le=class extends tr{constructor(){super(),this.listeners||tr.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,e)),super.dispatchEvent(e)}throwIfAborted(){let{aborted:e,reason:r="Aborted"}=this;if(e)throw r}static timeout(e){let r=new ge;return setTimeout(()=>r.abort(new DOMException(`This signal is timeout in ${e}ms`,"TimeoutError")),e),r.signal}static any(e){let r=new ge;function i(){r.abort(this.reason),o()}function o(){for(let n of e)n.removeEventListener("abort",i)}for(let n of e)if(n.aborted){r.abort(n.reason);break}else n.addEventListener("abort",i);return r.signal}},ge=class{constructor(){Object.defineProperty(this,"signal",{value:new Le,writable:!0,configurable:!0})}abort(e){let r=gd(e),i=vd(r);this.signal.reason=r,this.signal.dispatchEvent(i)}toString(){return"[object AbortController]"}};typeof Symbol!="undefined"&&Symbol.toStringTag&&(ge.prototype[Symbol.toStringTag]="AbortController",Le.prototype[Symbol.toStringTag]="AbortSignal");function rr(t){return t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof t.Request=="function"&&!t.Request.prototype.hasOwnProperty("signal")||!t.AbortController}function _o(t){typeof t=="function"&&(t={fetch:t});let{fetch:e,Request:r=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o=!1}=t;if(!rr({fetch:e,Request:r,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:e,Request:n};let n=r;(n&&!n.prototype.hasOwnProperty("signal")||o)&&(n=function(p,v){let a;v&&v.signal&&(a=v.signal,delete v.signal);let s=new r(p,v);return a&&Object.defineProperty(s,"signal",{writable:!1,enumerable:!1,configurable:!0,value:a}),s},n.prototype=r.prototype);let c=e;return{fetch:(d,p)=>{let v=n&&n.prototype.isPrototypeOf(d)?d.signal:p?p.signal:void 0;if(v){let a;try{a=new DOMException("Aborted","AbortError")}catch(l){a=new Error("Aborted"),a.name="AbortError"}if(v.aborted)return Promise.reject(a);let s=new Promise((l,h)=>{v.addEventListener("abort",()=>h(a),{once:!0})});return p&&p.signal&&delete p.signal,Promise.race([s,c(d,p)])}return c(d,p)},Request:n}}var P=typeof globalThis=="object"&&globalThis||typeof window=="object"&&window;var CI=()=>"fetch"in P,ft=CI()&&rr({fetch:P.fetch,Request:P.Request,AbortController:P.AbortController}),md=ft?_o({fetch:P.fetch,Request:P.Request,AbortController:P.AbortController}):void 0,Ne=ft?md.fetch:P.fetch,yE=ft?md.Request:P.Request,IE=ft?ge:P.AbortController,_E=ft?Le:P.AbortSignal;var bd=E(le(),1),yd=E(Re(),1);import{ErrorCategory as ir,now as So}from"@vkontakte/videoplayer-shared/es2018";var pt=class{constructor(e){var r;this.params=e,this.apiKey=e.config.apiKey,this.apiEnv=e.config.apiEnv,this.apiBaseUrl=(r=e.config.apiBaseUrl)!=null?r:ai[this.apiEnv],this.timeSynchronisation=e.timeSynchronisation,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){var e;if(this.apiEnv!=="auto"||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{let r=atob("aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ="),o=await(await Ne(r,{method:"GET",mode:"cors",cache:"no-cache"})).json(),n=(e=o==null?void 0:o.Answer[0])==null?void 0:e.data;if(!n)throw new Error("Wrong DNS response");return n}catch(r){return this.params.error$.next({id:"OneStat:ApiTransport:resolveApiBaseUrl",category:ir.NETWORK,message:"Unhandled resolve api base url error",thrown:r}),ai.vk_alias}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(e,r,i){if(!window.Blob||!window.navigator.sendBeacon)return!1;let o=this._prepareQueryParams({method:e,queryParams:r,sessionKey:i}),n=new window.Blob([o.toString()],{type:"application/x-www-form-urlencoded"});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,n)}catch(c){this.params.error$.next({id:"OneStat:ApiTransport:sendBeacon",category:ir.NETWORK,message:"Unhandled beacon error",thrown:c,data:{method:e,params:r}})}return!1}async sendRequest(e,r,i){let o=So(),n=f=>{if(f instanceof TypeError&&(0,bd.default)(["Failed to fetch","NetworkError when attempting to fetch resource."],f.message)){this.params.error$.next({id:"Network",category:ir.NETWORK,message:"Request failed",thrown:f});return}this.params.error$.next({id:"OneStat:ApiTransport:sendRequest",category:ir.NETWORK,message:"Unhandled request error",thrown:f,data:{method:e,params:r,sessionKey:i,time:So()-o}})};this.apiBaseUrl=await this.resolveApiBaseUrl();let c={method:"post",headers:{"Content-type":"application/x-www-form-urlencoded"},body:this._prepareQueryParams({method:e,queryParams:r,sessionKey:i})};return this.params.config.useKeepalive&&(c.keepalive=!0),Ne(`${this.apiBaseUrl}/fb.do`,c).then(f=>{var a,s;let d=Number(f.headers.get("content-length"))===0,p=new Date((a=f.headers.get("date"))!=null?a:"").getTime(),v=So()-o;if(isFinite(p)&&((s=this.timeSynchronisation)==null||s.addServerTime(p,v)),!d)return f.json().then(l=>Object.prototype.hasOwnProperty.call(l,"error_msg")?Promise.reject(l):l,n)},n)}_prepareQueryParams(e){let r=new URLSearchParams({format:"JSON",method:e.method,application_key:this.apiKey});return e.sessionKey!==void 0&&r.append("session_key",e.sessionKey),(0,yd.default)(e.queryParams).forEach(([i,o])=>r.append(i,typeof o=="string"?o:JSON.stringify(o))),r}};var _d=E(le(),1),Sd=E(Re(),1);import{ErrorCategory as qI,now as RI,safeStorage as ht,debounceFn as Id}from"@vkontakte/videoplayer-shared/es2018";var or="onestat_events",Po=t=>e=>e.timestamp+t>=RI(),nr=class{constructor(e){this.unsaltedStorage=[];this.isPaused=!1;this.isUrgent=e=>{let{operation:r}=e;return(0,_d.default)(["action_play","watch_coverage_record","watch_coverage_live"],r)};this.params=e,this.api=e.api,this.error$=e.error$,this.userSalt=e.userSalt,this.loggerDebugLog=e.debugLogger.createComponentLog("stat logger"),this.firstFlush=Id(()=>this.safeFlush(),this.params.config.firstFlushTime,{maxWait:this.params.config.firstFlushTime});let r=ht.isPersistent()?this.params.config.flushMaxWait:0;this.debouncedFlush=Id(()=>this.safeFlush(),this.params.config.flushDebounceTime,{maxWait:r}),this.subscription=this.api.authorized$.subscribe(i=>{i&&this.debouncedFlush()}),this.housekeepStorage()}safeFlush(){try{this.flush()}catch(e){this.error$.next({id:"LoggerError",category:qI.WTF,message:e?String(e):"Unknown logger error",thrown:e})}}readFromStorage(){let e=ht.get(or);try{return e?JSON.parse(e):{}}catch(r){}return{}}addToStorage(e){var n;if(!this.userSalt){this.unsaltedStorage.push(e);return}let r=this.readFromStorage(),o=((n=r[this.userSalt])!=null?n:[]).filter(Po(this.params.config.storageExpiration));ht.set(or,JSON.stringify({...r,[this.userSalt]:[...o,e]}))}getFromStorage(){var i;return this.userSalt?((i=this.readFromStorage()[this.userSalt])!=null?i:[]).filter(Po(this.params.config.storageExpiration)):this.unsaltedStorage}markStorageSent(){if(!this.userSalt){this.unsaltedStorage=[];return}let e=this.readFromStorage();delete e[this.userSalt],ht.set(or,JSON.stringify(e))}housekeepStorage(){let e=this.readFromStorage();for(let[r,i]of(0,Sd.default)(e)){let o=i.filter(Po(this.params.config.storageExpiration));o.length?e[r]=o:delete e[r],this.loggerDebugLog({message:`${i.length} retrieved from storage, ${o.length} of them actual`})}ht.set(or,JSON.stringify(e))}log(e){this.addToStorage(e),!this.isPaused&&(this.isUrgent(e)?this.flush():this.lastVsid!==e.custom.vsid?this.firstFlush():this.debouncedFlush(),this.lastVsid=e.custom.vsid)}flush({wantBeacon:e,clearStorage:r}={wantBeacon:!1,clearStorage:!0}){let i=this.getFromStorage();i.length!==0&&(this.api.authorized$.getValue()?(e&&this.params.config.useBeacon?(this.loggerDebugLog({message:`Flushing ${i.length} events through beacon`}),this.api.logBeacon(i)):(this.loggerDebugLog({message:`Flushing ${i.length} events`}),this.api.logRequest(i)),r&&this.markStorageSent()):this.api.authorize(),this.firstFlush.cancel(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe(),this.firstFlush.cancel(),this.debouncedFlush.cancel()}};import{HttpConnectionType as To,Surface as $e,VideoFormat as w,VideoQuality as U}from"@vkontakte/videoplayer-core/es2018";import{assertNever as Pd}from"@vkontakte/videoplayer-shared/es2018";var Td=t=>t&&{[U.INVARIANT]:"unknown",[U.Q_144P]:"mobile",[U.Q_240P]:"lowest",[U.Q_360P]:"low",[U.Q_480P]:"medium",[U.Q_576P]:"unknown",[U.Q_720P]:"high",[U.Q_1080P]:"fullhd",[U.Q_1440P]:"quadhd",[U.Q_2160P]:"ultrahd",[U.Q_4320P]:"unknown"}[t],Eo=t=>t&&{[To.HTTP1]:"http1",[To.HTTP2]:"http2",[To.QUIC]:"http3"}[t],Ed=t=>{if(t!==void 0)switch(t){case w.MPEG:return"mp4";case w.DASH:case w.DASH_LIVE:case w.DASH_STREAMS:return"dash";case w.DASH_SEP:return"dash_sep";case w.DASH_ONDEMAND:return"ondemand_dash";case w.DASH_WEBM:case w.DASH_LIVE_WEBM:return"webm";case w.DASH_WEBM_AV1:return"av1";case w.DASH_LIVE_CMAF:return"ondemand_dash_live";case w.HLS:case w.HLS_LIVE:return"hls";case w.HLS_FMP4:return"hls_fmp4";case w.HLS_ONDEMAND:return"ondemand_hls";case w.HLS_LIVE_CMAF:return"ondemand_hls_live";case w.WEB_RTC_LIVE:return"webrtc";default:return Pd(t)}},wo=(t,e)=>{if(e)return"minimal";switch(t){case void 0:case $e.NONE:case $e.INLINE:return;case $e.FULLSCREEN:return"fullscreen";case $e.SECOND_SCREEN:return"chromecast";case $e.PIP:return"pip";case $e.INVISIBLE:return"invisible";default:return Pd(t)}},wd=t=>{switch(t){case"slow-2g":return"poor";case"2g":return"poor";case"3g":return"good";case"4g":return"excellent"}};var ar=class{constructor(e){this.offset=void 0;this.offset=e}getOffset(){var e;return(e=this.offset)!=null?e:0}setOffset(e){this.offset=e}now(){var e;return Date.now()+((e=this.offset)!=null?e:0)}date(e=new Date){var r;return e.setTime(e.getTime()+((r=this.offset)!=null?r:0)),e}addServerTime(e,r){let i=Date.now(),o=e-i-r/2;if(Math.abs(o)<1e3){this.offset=0;return}this.offset===void 0?this.offset=Math.round(o):this.offset=Math.round(.2*o+(1-.2)*this.offset)}};import{PlaybackState as xd}from"@vkontakte/videoplayer-core/es2018";import{filter as Ad,filterChanged as kI,fromEvent as LI,isNullable as Od,map as NI,merge as xo,Observable as $I,Subject as Ao,Subscription as DI,ValueSubject as MI}from"@vkontakte/videoplayer-shared/es2018";var Cd=(t,e)=>new $I(r=>{let i=new DI,o=xo(LI(window,"beforeunload"),t.events.willDestruct$),n=new MI(void 0),c;i.add(t.info.isLive$.pipe(kI()).subscribe(y=>{c&&(c.unsubscribe(),n.next(void 0)),y?c=t.info.liveTime$.pipe(NI(x=>x&&x/1e3)).subscribe(n):c=t.info.position$.subscribe(n),i.add(c)}));let{playing$:f,paused$:d}=t.events,p=t.events.willSeek$.pipe(Ad(()=>t.info.playbackState$.getValue()===xd.PLAYING)),v=t.events.seeked$.pipe(Ad(()=>t.info.playbackState$.getValue()===xd.PLAYING)),a=!1,s=new Ao;i.add(p.subscribe(()=>{a||s.next(),a=!0})),i.add(v.subscribe(()=>a=!1));let l=new Ao,h=new Ao,g=xo(f,v,l),m=xo(d,s,o,t.events.looped$,h),b,I=()=>b=n.getValue(),q=()=>{let y=n.getValue();Od(b)||b===y||Od(y)||(r.next({from:b,to:y}),b=void 0)},N=()=>{h.next(),l.next()};if(i.add(g.subscribe(I)),i.add(m.subscribe(q)),e.forceInterval&&isFinite(e.forceInterval))if(e.watchCoverageTimeoutFix){let y,x=()=>{y!==void 0&&(window.clearTimeout(y),y=void 0)};i.add(g.subscribe(()=>{x(),y=window.setTimeout(N,e.forceInterval)})),i.add(m.subscribe(()=>x())),i.add(()=>x())}else{let y=0;i.add(g.subscribe(()=>y=window.setTimeout(N,e.forceInterval))),i.add(m.subscribe(()=>window.clearTimeout(y)))}return i});import{Surface as G}from"@vkontakte/videoplayer-core/es2018";import{debounce as VI,filterChanged as FI,Subject as BI}from"@vkontakte/videoplayer-shared/es2018";var sr=(t,e,r)=>{let i=new BI,o=i.pipe(VI(0),FI()),n=!1,c=!1,f=!1;return e(t.inPiP$,d=>{n=d,i.next(d?G.PIP:c?G.FULLSCREEN:f?G.INLINE:void 0)}),e(t.inFullscreen$,d=>{c=d,i.next(d?G.FULLSCREEN:n?G.PIP:f?G.INLINE:void 0)}),r&&e(r.info.surface$,d=>{switch(d){case G.SECOND_SCREEN:case G.NONE:case G.INLINE:{!c&&!n&&(d===G.INLINE&&(f=!0),i.next(d));break}}}),{surface$:o}};var zI="_one-stat_",Nd=`${zI}deviceId`,Oo=()=>{let t=new qo;return{subscription:t,subscribe:(e,r)=>{e&&t.add(e.subscribe(r))}}},Ro=class{constructor(e,r){this.subscription=new qo;this.debugLogger=new QI;this.oneStatDebugLog=this.debugLogger.createComponentLog("onestat");this.loopCounter=0;this.disabled=!1;this.isid$=new ur(void 0);this.zenUid$=new ur(void 0);this.seekAction$=new ur("unknown");var d,p,v;this.statContext=e,this.config=Ja((d=r.config)!=null?d:{}),De(r.apiEnv)&&(this.config.apiEnv=r.apiEnv),this.config.synchronizeTime&&(this.timeSynchronisation=new ar);let i=new KI;this.experimental={error$:i};let o=Ld.get(Nd);this.statContext.deviceId?this.deviceId=this.statContext.deviceId:o?this.deviceId=o:(this.deviceId=si(),Ld.set(Nd,this.deviceId)),this.resetViewSession(),r.useIsid&&this.isid$.next((p=r.isid)!=null?p:Ze()),this.zenUid$.next(r.zenUid);let n=new pt({config:this.config,error$:i,timeSynchronisation:this.timeSynchronisation});this.api=new dt({config:this.config,apiTransport:n,refreshAuthToken:r.refreshAuthToken,mobile:(v=this.statContext.mobile)!=null?v:!1,deviceId:this.deviceId,error$:i,vktvVersion:r.vktvVersion}),this.logger=new nr({config:this.config,debugLogger:this.debugLogger,api:this.api,error$:i,userSalt:r.userSalt});let{isEmbed:c,topOrigin:f}=GI();this.isEmbed=c,this.embedParent=f?new URL(f).hostname:void 0,this.subscribe()}get vsid$(){return new ur(ie.getVSID())}updateContext(e){this.statContext={...this.statContext,...e}}attachTo(e){let r=new qo,i=(s,l)=>r.add(s.subscribe(l));i(e.events.willStart$,()=>{let s=e.info.position$.getValue();this.logActionPlay({position:s}),this.statContext.projectId&&this.logActionPlayInteractive()}),i(e.events.looped$,()=>{this.resetViewSession(),++this.loopCounter>this.config.maxLoops&&(this.disabled=!0),this.logActionPlay({position:e.info.position$.getValue()})}),i(e.events.seeked$,()=>{let s=this.seekAction$.getValue();this.logSeek({action:s==="rich"?"slider":s,time:e.info.position$.getValue()}),this.seekAction$.next("unknown")}),i(e.events.paused$,()=>{this.logPause({position:e.info.position$.getValue()})}),i(e.events.willResume$,()=>{this.logPlay()}),i(e.events.started$,()=>{this.statContext.clip&&this.logWatchCoverageRecord({start:0,end:0})}),i(e.events.playing$,()=>{this.logPlaying()}),i(Cd(e,{forceInterval:this.config.watchCoverageInterval,watchCoverageTimeoutFix:this.config.watchCoverageTimeoutFix}),s=>{var m,b,I,q;let l=e.info.isLive$.getValue(),h=e.info.atLiveEdge$.getValue(),g={start:parseFloat(s.from.toFixed(3)),end:parseFloat(s.to.toFixed(3))};if(h){let N=(m=e.info.liveLatency$.getValue())!=null?m:0,y=(I=(b=e.info.currentBuffer$.getValue())==null?void 0:b.end)!=null?I:0,x=(q=e.info.liveBufferTime$.getValue())!=null?q:0,te=Math.round((N-(y-x))*1e3),re=Math.round(N*1e3);te&&re&&(g.latency=te,g.bufferLatency=re)}l?this.logWatchCoverageLive(g):this.logWatchCoverageRecord(g)});let o;i(e.info.isStalled$,s=>{s?o=ee():(De(o)&&this.logEmptyBuffer({duration:ee()-o}),o=void 0)});let n=!1;r.add(e.events.fatalError$.pipe(WI()).subscribe(()=>n=!0)),i(e.events.willStop$,()=>{if(e.info.isStalled$.getValue()){let l=De(o)?ee()-o:void 0;this.logCloseAtEmptyBuffer({duration:l!=null?l:0}),o=void 0}else n||this.logActionStop()}),i(e.events.managedError$,({id:s})=>{this.logError({fatal:!1,errorType:s})}),i(e.events.fatalError$,({id:s})=>{this.logError({fatal:!0,errorType:s})});let c,f,d=!1;i(e.events.firstBytes$,s=>{c=ee(),this.logFirstBytes({time:s})}),i(e.events.willStart$,()=>f=ee()),i(e.info.currentBuffer$,s=>{!d&&s&&s.end-s.start>0&&De(c)&&(this.logPlayerReady({duration:ee()-c}),d=!0)}),i(e.events.firstFrame$,()=>{De(c)&&!d&&(this.logPlayerReady({duration:ee()-c}),d=!0),De(f)&&this.logFirstFrame({time:ee()-f})});let p;i(e.info.currentVideoStream$,s=>{s&&(p&&s.id!==p&&this.logTrackSwitch(s),p=s.id)});let v;i(e.info.currentAudioStream$,s=>{s&&(v&&s.id!==v&&this.logTrackSwitch(s),v=s.id)}),i(e.info.atLiveEdge$,s=>this.updateContext({liveEdge:s})),i(qd({muted:e.info.muted$,volume:e.info.volume$}),({muted:s,volume:l})=>this.updateContext({audible:!s&&l>0})),i(e.info.currentQuality$,s=>{let l=Td(s);this.updateContext({quality:l}),l&&this.logQuality(l)}),i(e.info.isAutoQualityEnabled$,s=>this.updateContext({autoQuality:s})),i(e.info.currentFormat$,s=>this.updateContext({contentType:Ed(s)})),i(e.info.currentPlaybackRate$,s=>this.updateContext({rate:s})),i(e.info.is3DVideo$,s=>this.updateContext({is3d:s}));let a;return i(e.info.hostname$,s=>{let l=a!==void 0&&a!==s;this.updateContext({cdnHostname:s,failover:l}),l&&this.logFailover(s),a=s}),i(e.info.throughputEstimation$,s=>this.updateContext({downloadSpeed:s})),i(e.info.httpConnectionType$,s=>{this.statContext.firstConnectionType||this.updateContext({firstConnectionType:Eo(s)}),this.updateContext({connectionType:Eo(s)})}),i(e.info.httpConnectionReused$,s=>{kd(this.statContext.firstConnectionReused)&&this.updateContext({firstConnectionReused:s}),this.updateContext({connectionReused:s})}),i(e.info.surface$,s=>{this.uiEvents||this.updateContext({mode:wo(s,this.statContext.isPreviewPlayerView)})}),i(qd({current:e.info.currentTextTrack$,available:e.info.availableTextTracks$}),({current:s,available:l})=>{let h=l.find(({id:m})=>m===s),g=h&&(h.isAuto?`${h.language}_auto`:h.language);this.updateContext({subtitles:g==null?void 0:g.split(".")[0]})}),this.player=e,this.uiEvents&&this.attachToUi(this.uiEvents),this.resubscribeBeforeunload(),this.subscription.add(r),r}attachToUi(e){this.uiEvents=e;let{subscription:r,subscribe:i}=Oo();if(!this.player)return r;i(e.actionRewind$,()=>{this.player&&(this.resetViewSession(),this.logActionPlay({position:this.player.info.position$.getValue()}))}),i(e.actionSeek$,this.seekAction$);let{surface$:o}=sr(this.uiEvents,i,this.player);return i(o,n=>{this.updateContext({mode:wo(n,this.statContext.isPreviewPlayerView)})}),i(e.actionSetSubtitle$,n=>this.updateContext({subtitles:n==null?void 0:n.split(".")[0]})),i(e.nextMovie$,n=>this.logNextMovie(n)),this.resubscribeBeforeunload(),this.subscription.add(r),r}attachToAds(e){let{subscription:r,subscribe:i}=Oo();return i(e.slotRequested$,()=>this.logAdSlotRequest()),i(e.started$,o=>this.logAdStarted(o)),i(e.paused$,()=>this.logAdPaused()),i(e.resumed$,()=>this.logAdResumed()),i(e.ended$,()=>this.logAdEnded()),i(e.skipped$,()=>this.logAdSkipped()),i(e.clicked$,()=>this.logAdClicked()),i(e.error$,o=>this.logError({errorType:o,fatal:!1})),this.resubscribeBeforeunload(),this.subscription.add(r),r}attachToInteractive(e){let{subscription:r,subscribe:i}=Oo();return i(e.click$,o=>this.logInterfaceClick(o)),i(e.nextMovie$,o=>this.logNextMovie(o)),this.resubscribeBeforeunload(),this.subscription.add(r),r}authorize(e){return this.api.authorize(e)}pause(){this.logger.pause(),this.oneStatDebugLog({message:"paused"})}resume(){this.logger.resume(),this.oneStatDebugLog({message:"resumed"})}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}resetViewSession(){this.oneStatDebugLog({message:"VSID reset"}),ie.generateVSID(this.config.useVsid64)}getDeviceId(){return this.deviceId}setFieldBlacklist(){}logInited(){}logReady(e){this.log({operation:"player_ready",param:String(e.time)})}logStarted(...e){this.logActionPlay(...e)}logPlay(){this.log({operation:"play_toggle"})}logPlaying(){this.log({operation:"playing"})}logPause(e){this.log({operation:"pause",param:String(Math.round(e.position))})}logSeek(e){this.log({operation:"seek",param:e.action,time:e.time})}logFirstBytes(e){this.log({operation:"first_bytes",param:String(e.time)})}logFirstFrame(e){this.log({operation:"first_frame",param:String(e.time)})}logError(e){this.log({operation:"content_error",param:`${e.fatal?"fatal":"recoverable"}_${e.errorType}`})}logWatchCoverageRecord(e){this.log({operation:"watch_coverage_record",param:`${e.start}-${e.end}`},{in_history:this.statContext.inHistory?1:void 0})}logWatchCoverageLive(e){var n,c;let r=(c=(n=this.timeSynchronisation)==null?void 0:n.getOffset())!=null?c:0,i=e.start+r,o=e.end+r;this.log({operation:"watch_coverage_live",param:`${i}-${o}`},{in_history:this.statContext.inHistory?1:void 0,latency:e.latency,buffer_latency:e.bufferLatency})}logEmptyBuffer(e){this.log({operation:"empty_buffer",param:String(e.duration)})}logDownloadSpeed(){}logAdSlotRequest(){this.log({operation:"adv",param:"slot_request"})}logAdStarted(e){this.log({operation:"adv",param:e})}logAdPaused(){this.log({operation:"adv",param:"pause"})}logAdResumed(){this.log({operation:"adv",param:"resume"})}logAdEnded(){this.log({operation:"adv",param:"ended"})}logAdSkipped(){this.log({operation:"adv",param:"skip"})}logAdClicked(){this.log({operation:"adv",param:"click"})}logInterfaceClick(e){this.log({operation:"player_interface_click",param:e})}logNextMovie(e){this.log({operation:"next_movie",param:String(e)})}subscribe(){this.resubscribeBeforeunload();let e=window.navigator.connection;e&&"onchange"in e&&"effectiveType"in e&&this.subscription.add(jI(Rd(e,"change"),HI(["init"])).subscribe(()=>this.updateContext({network:wd(e.effectiveType)}))),this.config.debugLog&&this.debugLogger.log$.subscribe(r=>{console.debug("%c stat ","background:#fa6470;",`component: ${r.component}.`,r.message)})}resubscribeBeforeunload(){var e;(e=this.beforeunloadSubscription)==null||e.unsubscribe(),this.beforeunloadSubscription=Rd(window,"beforeunload").subscribe(()=>this.logger.flush({wantBeacon:!0,clearStorage:this.config.clearStorageAtUnload})),this.subscription.add(this.beforeunloadSubscription)}logPlayerReady(e){this.log({operation:"player_ready",param:String(Math.round(e.duration))})}logActionPlay(e){this.log({operation:"action_play",param:String(Math.round(e.position))})}logActionPlayInteractive(){this.statContext.projectId&&this.log({operation:"action_play_interactive",param:String(this.statContext.movieId)},{vid:this.statContext.projectId})}logFailover(e){this.log({operation:"failover",param:e})}logCloseAtEmptyBuffer(e){this.log({operation:"close_at_empty_buffer",param:String(Math.round(e.duration))})}logActionStop(){this.log({operation:"action_stop"})}logTrackSwitch(e){this.log({operation:"track_switch",param:e.id})}logQuality(e){this.log({operation:"quality",param:e})}log(e,r={}){if(this.disabled){this.oneStatDebugLog({message:`operation ${e.operation} but statistics is disabled`});return}if((0,Co.default)(this.config.disabledOperations,e.operation)){this.oneStatDebugLog({message:`operation ${e.operation} but it is disabled`});return}this.oneStatDebugLog({message:`operation ${e.operation} ${e.param}`});let i=this.createLogItem(e,r);this.logger.log(i)}createLogItem({operation:e,param:r,time:i},o={}){var l,h;let n=(h=(l=this.timeSynchronisation)==null?void 0:l.now())!=null?h:ee(),c=this.vsid$.getValue();UI(c);let f=this.isid$.getValue(),d=e==="empty_buffer"||e==="close_at_empty_buffer"?this.statContext.connectionType:this.statContext.firstConnectionType,p=this.statContext.firstConnectionReused,v,a;if(this.isEmbed||this.statContext.place==="embed"){v=this.embedParent;let g=[...new URLSearchParams(location.search).entries()].filter(([m,b])=>(0,Co.default)(this.config.embedUrlParams,m));a=new URLSearchParams(g).toString()}else if(this.statContext.place==="direct"){let g=this.statContext.refDomain||document.referrer;g&&Ha(URL,g)?v=new URL(g).hostname:v=g,a=location.href.substring(0,1024)}let s={vsid:c,isid:f,vid:this.statContext.movieId,uid:this.zenUid$.getValue(),ct:this.statContext.contentType,place:this.isEmbed?"embed":this.statContext.place,quality:this.statContext.quality,cdn_host:this.statContext.cdnHostname,stat_type:this.statContext.autoplay===!0?"auto":this.statContext.autoplay===!1?"":void 0,param:r,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode,connection_type:d,connection_reused:p===!0?1:p===!1?0:void 0,cached_data:this.statContext.cached===!0?1:this.statContext.cached===!1?0:void 0,live:this.statContext.liveEdge?1:void 0,muted:this.statContext.audible===!1?1:void 0,mode:this.statContext.mode,subtitles:this.statContext.subtitles,download_speed:this.statContext.downloadSpeed,manual_quality:this.statContext.autoQuality?void 0:1,ref_domain:v,direct_url:a,rate:this.statContext.rate===1||kd(this.statContext.rate)?void 0:this.statContext.rate.toFixed(2),view_360:this.statContext.is3d?1:void 0,aid:this.statContext.albumId,vk_playlist_id:this.statContext.vkPlaylistId,...o};for(let g of this.config.disabledCustomFields)delete s[g];return{operation:e,type:1,time:i,network:this.statContext.network,timestamp:n,custom:s}}};var Qo={};Af(Qo,{ActionSeekType:()=>cr,ThinOneStat:()=>yr,VERSION:()=>D});var hf=E(Ud(),1),Wo=E(le(),1);import{assertNonNullable as y_,detectEmbed as I_,fromEvent as __,Logger as S_,merge as lf,combine as br,filter as W,filterChanged as P_,once as T_,skip as jo,safeStorage as df,getWindow as E_,Subject as w_,Subscription as Ko,ValueSubject as Ho,ErrorCategory as Fe}from"@vkontakte/videoplayer-shared/es2018";import{clientChecker as z}from"@vkontakte/videoplayer-core/es2018";import{fillWithDefault as t_}from"@vkontakte/videoplayer-shared/es2018";var ko=(i=>(i.AUTO="auto",i.AUTO_POOR="auto_poor",i.AUTO_RICH="auto_rich",i))(ko||{});var cr=(d=>(d.SLIDER="slider",d.RICH="rich",d.DOUBLE_TAP="double_tap",d.TIME_CODE="time_code",d.EPISODE="episode",d.REWIND="rewind",d.LIVE="live",d.UNKNOWN="unknown",d))(cr||{});var Hd="CIOPGQJGDIHBABABA",Lo={prod:"https://api.ok.ru",vk_alias:"https://api.mycdn.me",videotest:"https://videotestapi.ok.ru/api",test:"https://apitest.ok.ru",okcdn:"https://api.okcdn.ru",auto:""};var r_={apiKey:Hd,apiEnv:"okcdn",apiBaseUrl:null,requestRetryCount:1,useVsid64:!1,firstFlushTime:5e3,flushDebounceTime:1e4,flushMaxWait:6e4,storageExpiration:36*60*60*1e3,watchCoverageHeartbeatInterval:3e4,disabledEvents:[],disabledParams:[],synchronizeTime:!0,useBeacon:!1,alwaysSendDesktop:!1,watchedNDefaultTargetDuration:1e3,downloadBytesMaxTime:3e4},Wd=t=>t_(t,r_);var No=E(to(),1);import{getExponentialDelay as i_,ErrorCategory as Me,ValueSubject as o_}from"@vkontakte/videoplayer-shared/es2018";var lr=class{constructor(e){this.params=e,this.authorized$=new o_(!1),this.consequentAuthErrors=0}async authorize(e){return this.authToken=e!=null?e:await this.refreshAuthToken(),this.authorizeWithBackoff()}logBeacon(e){let r="log.logUvStat",i=this.createLogParams(e),o=this.sessionKey;if(!o)return;this.params.apiTransport.sendBeacon(r,i,o)||this.logRequest(e).catch(()=>{})}async logRequest(e){var f;let r="log.logUvStat",i=this.createLogParams(e),o={},n=(f=this.sessionKey)!=null?f:await this.authorizeWithBackoff();if(!n)return;let c=async(d,p=this.params.config.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(r,i,n,o)}catch(v){if(!v||!("error_code"in v)){this.params.error$.next({id:"logRequestUnknown",category:Me.NETWORK,message:`Unknown ${r} error`,thrown:v});return}let a=v==null?void 0:v.error_code;switch(a){case 102:case 103:case 104:return this.authorized$.next(!1),this.sessionKey=await this.authorizeWithBackoff(),p>0?c(d,p-1):void 0;case 401:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this.authorizeWithBackoff(),p>0?c(d,p-1):void 0;default:{this.params.error$.next({id:`LogRequest#${a}`,category:Me.EXTERNAL_API,message:`${r} error`,data:v});return}}}};return c(e)}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}async refreshAuthToken(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=(0,No.default)(this.params.refreshAuthToken(),()=>{this.refreshAuthTokenPromise=void 0})),this.refreshAuthTokenPromise}createLogParams(e){return{collector:"ok.mobile.apps.video",uv_stat_data:JSON.stringify({application:`@vkontakte/videoplayer-statistics:${D}`,platform:e[0].platform,product:e[0].product,events:e})}}authorizeWithBackoff(){if(!this.consequentAuthErrors)return this.doAuthorize();let e=i_(this.consequentAuthErrors);return new Promise(r=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout(async()=>{try{let i=await this.doAuthorize();r(i)}catch(i){this.params.error$.next({id:"AuthorizeBackoff",category:Me.NETWORK,message:"Otherwise unhandled error in authorization",thrown:i})}finally{this.backoffTimeoutId=0}},e))})}doAuthorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);let e="auth.anonymLogin",r={session_data:{version:2,device_id:this.params.deviceId,client_version:D.split("-")[0],client_type:"SDK_JS"}};return this.authToken!==void 0&&(r.session_data.auth_token=this.authToken,r.session_data.version=3),this.authorizePromise=(0,No.default)(this.params.apiTransport.sendRequest(e,r).then(i=>{var o;return(!i||!i.session_key)&&this.params.error$.next({id:"AuthorizeFailed",category:Me.EXTERNAL_API,message:"No session key",data:i}),this.sessionKey=(o=i==null?void 0:i.session_key)!=null?o:void 0,this.sessionKey}).catch(async i=>{this.sessionKey=void 0;let o=i==null?void 0:i.error_code;switch(o){case 401:return this.authToken=await this.refreshAuthToken(),this.authorizeWithBackoff()}o?this.params.error$.next({id:`Authorize#${o}`,category:Me.EXTERNAL_API,message:"authorize error",data:i}):this.params.error$.next({id:"AuthorizeUnknown",category:Me.NETWORK,message:"authorize error",thrown:i})}),()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise}};var Kd=E(le(),1);var Qd=E(Re(),1);import{now as $o,ErrorCategory as dr}from"@vkontakte/videoplayer-shared/es2018";var fr=class{constructor(e){var r;this.params=e,this.apiKey=e.config.apiKey,this.apiEnv=e.config.apiEnv,this.apiBaseUrl=(r=e.config.apiBaseUrl)!=null?r:Lo[this.apiEnv],this.timeSynchronisation=e.timeSynchronisation,this.isApiBaseUrlFetched=!1}sendBeacon(e,r,i){if(!window.Blob||!window.navigator.sendBeacon)return!1;let o=this.prepareQueryParams({method:e,queryParams:r,sessionKey:i}),n=new window.Blob([o.toString()],{type:"application/x-www-form-urlencoded"});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,n)}catch(c){this.params.error$.next({id:"OneStat:ApiTransport:sendBeacon",category:dr.NETWORK,message:"Unhandled beacon error",thrown:c,data:{method:e,params:r}})}return!1}async sendRequest(e,r,i,o){let n=$o(),c=f=>{if(f instanceof TypeError&&(0,Kd.default)(["Failed to fetch","NetworkError when attempting to fetch resource."],f.message)){this.params.error$.next({id:"Network",category:dr.NETWORK,message:"Request failed",thrown:f});return}this.params.error$.next({id:"ThinOneStat:ApiTransport:sendRequest",category:dr.NETWORK,message:"Unhandled request error",thrown:f,data:{method:e,params:r,sessionKey:i,time:$o()-n}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),Ne(`${this.apiBaseUrl}/fb.do`,{method:"post",headers:{"Content-type":"application/x-www-form-urlencoded",...o},body:this.prepareQueryParams({method:e,queryParams:r,sessionKey:i})}).then(f=>{var a,s;let d=Number(f.headers.get("content-length"))===0,p=new Date((a=f.headers.get("date"))!=null?a:"").getTime(),v=$o()-n;if(isFinite(p)&&((s=this.timeSynchronisation)==null||s.addServerTime(p,v)),!d)return f.json().then(l=>Object.prototype.hasOwnProperty.call(l,"error_msg")?Promise.reject(l):l,c)},c)}async resolveApiBaseUrl(){var e;if(this.apiEnv!=="auto"||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{let r=atob("aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ="),o=await(await Ne(r,{method:"GET",mode:"cors",cache:"no-cache"})).json(),n=(e=o==null?void 0:o.Answer[0])==null?void 0:e.data;if(!n)throw new Error("Wrong DNS response");return n}catch(r){return this.params.error$.next({id:"ThinOneStat:ApiTransport:resolveApiBaseUrl",category:dr.NETWORK,message:"Unhandled resolve api base url error",thrown:r}),Lo.vk_alias}finally{this.isApiBaseUrlFetched=!0}}prepareQueryParams(e){let r=new URLSearchParams({format:"JSON",method:e.method,application_key:this.apiKey});return e.sessionKey!==void 0&&r.append("session_key",e.sessionKey),(0,Qd.default)(e.queryParams).forEach(([i,o])=>r.append(i,typeof o=="string"?o:JSON.stringify(o))),r}};var zd=E(le(),1),Yd=E(Re(),1);import{ErrorCategory as n_,now as a_,safeStorage as vt,debounceFn as Gd}from"@vkontakte/videoplayer-shared/es2018";var pr="thinonestat_events",Do=t=>e=>e.client_time+t>=a_(),hr=class{constructor(e){this.unsaltedStorage=[];this.isPaused=!1;this.isUrgent=e=>{let{event_name:r}=e;return(0,zd.default)(["watch_coverage","watch_coverage_live","watched_n","playback_started"],r)};this.params=e,this.api=e.api,this.error$=e.error$,this.userSalt=e.userSalt,this.loggerDebugLog=e.debugLogger.createComponentLog("stat logger"),this.firstFlush=Gd(()=>this.safeFlush(),this.params.config.firstFlushTime,{maxWait:this.params.config.firstFlushTime});let r=vt.isPersistent()?this.params.config.flushMaxWait:0;this.debouncedFlush=Gd(()=>this.safeFlush(),this.params.config.flushDebounceTime,{maxWait:r}),this.subscription=this.api.authorized$.subscribe(i=>{i&&this.debouncedFlush()}),this.housekeepStorage()}safeFlush(){try{this.flush()}catch(e){this.error$.next({id:"LoggerError",category:n_.WTF,message:String(e)||"Unknown logger error",thrown:e})}}readFromStorage(){let e=vt.get(pr);try{return e?JSON.parse(e):{}}catch(r){}return{}}addToStorage(e){var n;if(!this.userSalt){this.unsaltedStorage.push(e);return}let r=this.readFromStorage(),o=((n=r[this.userSalt])!=null?n:[]).filter(Do(this.params.config.storageExpiration));vt.set(pr,JSON.stringify({...r,[this.userSalt]:[...o,e]}))}getFromStorage(){var i;return this.userSalt?((i=this.readFromStorage()[this.userSalt])!=null?i:[]).filter(Do(this.params.config.storageExpiration)):this.unsaltedStorage}markStorageSent(){if(!this.userSalt){this.unsaltedStorage=[];return}let e=this.readFromStorage();delete e[this.userSalt],vt.set(pr,JSON.stringify(e))}housekeepStorage(){let e=this.readFromStorage();for(let[r,i]of(0,Yd.default)(e)){let o=i.filter(Do(this.params.config.storageExpiration));o.length?e[r]=o:delete e[r],this.loggerDebugLog({message:`${i.length} retrieved from storage, ${o.length} of them actual`})}vt.set(pr,JSON.stringify(e))}log(e){this.addToStorage(e),!this.isPaused&&(this.isUrgent(e)?this.flush():this.lastVsid!==e.vsid?this.firstFlush():this.debouncedFlush(),this.lastVsid=e.vsid)}flush({wantBeacon:e,clearStorage:r}={wantBeacon:!1,clearStorage:!0}){let i=this.getFromStorage();i.length!==0&&(this.api.authorized$.getValue()?(e&&this.params.config.useBeacon?(this.loggerDebugLog({message:`Flushing ${i.length} events through beacon`}),this.api.logBeacon(i)):(this.loggerDebugLog({message:`Flushing ${i.length} events`}),this.api.logRequest(i)),r&&this.markStorageSent()):this.api.authorize(),this.firstFlush.cancel(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe(),this.firstFlush.cancel(),this.debouncedFlush.cancel()}};function Mo(){let t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),e=new Array(36),r=0,i,o;for(o=0;o<36;o++)o===8||o===13||o===18||o===23?e[o]="-":o===14?e[o]="4":(r<=2&&(r=33554432+Math.random()*16777216|0),i=r&15,r=r>>4,e[o]=t[o===19?i&3|8:i]);return e.join("")}var vr=class{constructor(e){this.offset=void 0;this.offset=e}getOffset(){var e;return(e=this.offset)!=null?e:0}setOffset(e){this.offset=e}now(){var e;return Date.now()+((e=this.offset)!=null?e:0)}date(e=new Date){var r;return e.setTime(e.getTime()+((r=this.offset)!=null?r:0)),e}addServerTime(e,r){let i=Date.now(),o=e-i-r/2;if(Math.abs(o)<1e3){this.offset=0;return}this.offset===void 0?this.offset=Math.round(o):this.offset=Math.round(.2*o+(1-.2)*this.offset)}};import{PlaybackState as Jd}from"@vkontakte/videoplayer-core/es2018";import{Observable as s_,Subscription as u_,ValueSubject as c_,Subject as Vo,fromEvent as l_,isNullable as Xd,merge as gt,filter as Zd,filterChanged as ef,getWindow as Fo}from"@vkontakte/videoplayer-shared/es2018";var tf=(t,e,r)=>new s_(i=>{let o=new u_,n=new c_(void 0),c;o.add(t.info.isLive$.pipe(ef()).subscribe($=>{c&&(c.unsubscribe(),n.next(void 0)),$?c=t.info.liveTime$.pipe(ef()).subscribe(n):c=t.info.position$.subscribe(n),o.add(c)}));let{playing$:f,paused$:d,ended$:p,looped$:v}=t.events,a=t.events.willSeek$.pipe(Zd(()=>t.info.playbackState$.getValue()===Jd.PLAYING)),s=t.events.seeked$.pipe(Zd(()=>t.info.playbackState$.getValue()===Jd.PLAYING)),l=!1,h=new Vo;o.add(a.subscribe(()=>{l||h.next(),l=!0})).add(s.subscribe(()=>l=!1));let g=gt(l_(Fo(),"beforeunload"),t.events.willDestruct$),m,b=()=>m=n.getValue(),I=()=>{let $=n.getValue();Xd(m)||Xd($)||m===$||(i.next({from:m,to:$}),m=void 0)},q=new Vo,N=new Vo,y=gt(f,s,q),x=gt(d,h,g,p,v,N),te=e.started$&&e.ended$?gt(y,e.ended$):y,re=e.started$&&e.ended$?gt(x,e.started$):x;if(o.add(te.subscribe(b)).add(re.subscribe(I)),r.heartbeatInterval&&isFinite(r.heartbeatInterval)){let $=[],bt=()=>{N.next(),q.next()};o.add(te.subscribe(()=>{let me=Fo().setTimeout(bt,r.heartbeatInterval);$.push(me)})).add(re.subscribe(()=>{$.forEach(me=>{Fo().clearTimeout(me)}),$=[]}))}return o});import{Subscription as d_}from"@vkontakte/videoplayer-core/es2018";import{Observable as f_,merge as p_}from"@vkontakte/videoplayer-shared/es2018";var rf=(t,e)=>new f_(r=>{let i=new d_;return i.add(p_(t.info.position$,t.info.liveTime$).subscribe(()=>{let o=e.getTotalViewTime();o>=e.targetDuration&&(r.next({target_duration:e.targetDuration,current_tvt:o}),i.unsubscribe())})),i});import{Subscription as h_}from"@vkontakte/videoplayer-core/es2018";import{Observable as v_,filter as g_,getWindow as of}from"@vkontakte/videoplayer-shared/es2018";var nf=(t,{maxTimeWindow:e})=>new v_(r=>{let i=new h_,o={maxBytesThreshold:100*1024*1024,minBytesThreshold:100*1024,maxTimeWindow:e,minTimeWindow:2e3},n={bytes:0,startTime:0,lastEmitTime:0,timeoutId:0},c=()=>{n.timeoutId&&(of().clearTimeout(n.timeoutId),n.timeoutId=null)},f=()=>{n.bytes=0,n.startTime=0,n.lastEmitTime=0,c()},d=a=>{if(n.bytes<o.minBytesThreshold||a-n.lastEmitTime<o.minTimeWindow&&n.lastEmitTime>0)return!1;let h=(n.startTime>0?a-n.startTime:0)>=o.maxTimeWindow,g=n.bytes>=o.maxBytesThreshold;return h||g},p=(a=!1)=>{let s=Date.now();if(!a&&!d(s))return;c();let l=n.startTime>0?s-n.startTime:Math.max(o.minTimeWindow,1),h=n.bytes/(l/1e3);r.next({download_bytes:Math.round(n.bytes),download_speed:Math.round(h)}),n.lastEmitTime=s,f()},v=()=>{if(c(),n.startTime>0&&n.bytes>=o.minBytesThreshold){let s=Date.now()-n.startTime,l=o.maxTimeWindow-s;l>100?n.timeoutId=of().setTimeout(()=>{n.timeoutId=null,p()},l):l>0&&p()}};return i.add(t.info.httpDownloadMetrics$.pipe(g_(a=>a!==void 0)).subscribe(a=>{let s=Date.now();n.startTime===0&&(n.startTime=s),n.bytes+=a.bytes,d(s)?p():v()})),i.add(()=>{if(c(),n.bytes>0){let a=Date.now(),s=n.startTime>0?a-n.startTime:o.minTimeWindow,l=n.bytes/(s/1e3);r.next({download_bytes:Math.round(n.bytes),download_speed:Math.round(l)})}f()}),i});import{Observable as m_,Subscription as b_,merge as af}from"@vkontakte/videoplayer-shared/es2018";var sf=t=>new m_(e=>{let r=new b_,i=0,o=1,n=0,c=!1,f=!1,d=()=>{if(!c)return;let y=Date.now();n+=(y-i)*o,i=y},p=()=>{(!c||f)&&(i=Date.now(),c=!0,f=!1)},v=()=>{c&&(d(),c=!1)},a=()=>{c&&(d(),c=!1,f=!0)},s=y=>{c&&d(),o=y,i=Date.now()},{started$:l,playing$:h,paused$:g,willSeek$:m,ended$:b,willDestruct$:I}=t.events,{currentPlaybackRate$:q}=t.info;r.add(m.subscribe(a)).add(af(l,h).subscribe(p)).add(af(g,b,I).subscribe(v)).add(q.subscribe(s));let N=()=>{let y=n;return c&&(y+=(Date.now()-i)*o),y};return e.next(N),r});import{assertNever as uf}from"@vkontakte/videoplayer-shared/es2018";import{HttpConnectionType as Bo,Surface as Ve,VideoFormat as T,VideoQuality as j}from"@vkontakte/videoplayer-core/es2018";var Uo=t=>t&&{[Bo.HTTP1]:"http1",[Bo.HTTP2]:"http2",[Bo.QUIC]:"http3"}[t],mt=t=>{if(t!==void 0)switch(t){case T.MPEG:return"MP4";case T.DASH:case T.DASH_LIVE:return"DASH";case T.DASH_SEP:return"DASH_SEP";case T.DASH_ONDEMAND:return"ONDEMAND_DASH";case T.HLS_ONDEMAND:return"ONDEMAND_HLS";case T.HLS:case T.HLS_LIVE:return"HLS";case T.HLS_FMP4:return"HLS_FMP4";case T.DASH_WEBM:case T.DASH_LIVE_WEBM:return"WEBM";case T.DASH_LIVE_CMAF:return"ONDEMAND_DASH_LIVE";case T.HLS_LIVE_CMAF:return"ONDEMAND_HLS_LIVE";case T.WEB_RTC_LIVE:return"WEBRTC";case T.DASH_WEBM_AV1:return"AV1";case T.DASH_STREAMS:return"MULTI_DASH";default:return uf(t)}},H=t=>{if(t!==void 0)switch(t){case j.Q_144P:return"144p";case j.Q_240P:return"240p";case j.Q_360P:return"360p";case j.Q_480P:return"480p";case j.Q_720P:return"720p";case j.Q_1080P:return"1080p";case j.Q_1440P:return"1440p";case j.Q_2160P:return"2160p";case j.INVARIANT:case j.Q_576P:case j.Q_4320P:return"UNKNOWN";default:return uf(t)}},cf=t=>{if(t!==void 0)switch(t){case"MP4":case"ONDEMAND_DASH":case"ONDEMAND_DASH_LIVE":case"ONDEMAND_HLS":case"ONDEMAND_HLS_LIVE":case"MULTI_DASH":case"WEBM":case"AV1":return"vod";case"DASH":case"HLS":case"HLS_FMP4":case"WEBRTC":return"live";default:return}},ne=(t,e,r)=>{var i;if(t&&e)switch(t){case T.MPEG:return r&&e[t]&&e[t][r];default:return(i=e[t])==null?void 0:i.url}},gr=(t,e=!1)=>{if(e)return"minimal";switch(t){case void 0:case Ve.NONE:return;case Ve.INLINE:return"inline";case Ve.FULLSCREEN:return"fullscreen";case Ve.SECOND_SCREEN:return"chromecast";case Ve.PIP:return"pip_external"}},mr=t=>{switch(t){case void 0:return;case Ve.INVISIBLE:return"background";default:return"foreground"}};var x_="_thin-one-stat_",ff=`${x_}deviceId`,pf=()=>{let t=new Ko;return{subscription:t,subscribe:(e,r)=>{e&&t.add(e.subscribe(r))}}},yr=class{constructor(e,r){this.debugLogger=new S_;this.thinOneStatDebugLog=this.debugLogger.createComponentLog("ThinOneStat");this.eventNumber=1;this.playerSize={width:0,height:0};this.seekAction$=new Ho("unknown");this.isid$=new Ho(void 0);this.getTotalViewTime=()=>0;var d,p;this.statContext=e,this.config=Wd((d=r.config)!=null?d:{}),this.subscription=new Ko,this.config.synchronizeTime&&(this.timeSynchronisation=new vr);let i=new w_,o=df.get(ff);this.statContext.deviceId?this.deviceId=this.statContext.deviceId:o?this.deviceId=o:(this.deviceId=Mo(),df.set(ff,this.deviceId)),this.statContext.targetDuration?this.targetDuration=this.statContext.targetDuration:this.targetDuration=this.config.watchedNDefaultTargetDuration,this.resetViewSession(),r.useIsid&&this.isid$.next((p=r.isid)!=null?p:Ze());let n=new fr({error$:i,config:this.config,timeSynchronisation:this.timeSynchronisation});this.api=new lr({config:this.config,apiTransport:n,error$:i,deviceId:this.deviceId,refreshAuthToken:r.refreshAuthToken}),this.logger=new hr({config:this.config,debugLogger:this.debugLogger,api:this.api,error$:i,userSalt:r.userSalt});let{isEmbed:c,topOrigin:f}=I_();this.isEmbed=c,this.embedHostname=f?new URL(f).hostname:void 0}get vsid$(){return new Ho(ie.getVSID())}authorize(e){return this.api.authorize(e)}updateContext(e){this.statContext={...this.statContext,...e}}attachTo(e,r){let i=new Ko,o=(a,s)=>i.add(a.subscribe(s));o(sf(e),a=>{this.getTotalViewTime=a}),o(e.info.isLive$,a=>this.isLive=a);let n;o(br({hostname:e.info.hostname$,connectionType:e.info.httpConnectionType$,connectionReused:e.info.httpConnectionReused$}).pipe(W(({hostname:a})=>a!==void 0),W(({connectionType:a})=>a!==void 0),W(({connectionReused:a})=>a!==void 0)),({hostname:a,connectionType:s,connectionReused:l})=>{if(n!==void 0&&n!==a){let g={cdn_host:a,connection_type:Uo(s),connection_reused:l,content_type:mt(e.info.currentFormat$.getValue())};this.logFailover(g)}this.cdnHostname=n=a}),o(e.info.httpConnectionType$,a=>{this.connectionType=Uo(a)}),o(e.info.httpConnectionReused$,a=>{this.connectionReused=a}),o(tf(e,r,{heartbeatInterval:this.config.watchCoverageHeartbeatInterval}),a=>{let s=Math.round(a.from*1e3),l=Math.round(a.to*1e3),h={watch_interval:`${s}-${l}`,in_history:!!this.statContext.inHistory,content_type:mt(e.info.currentFormat$.getValue()),playback_quality:H(e.info.currentQuality$.getValue()),recom_info:this.statContext.recomInfo};if(!e.info.isLive$.getValue())this.logWatchCoverage(h);else{let m=e.info.atLiveEdge$.getValue();this.logWatchCoverageLive({...h,live:!!m})}}),o(rf(e,{targetDuration:this.targetDuration,getTotalViewTime:this.getTotalViewTime}),a=>{this.logWatchedN(a)}),o(e.events.willReady$,()=>{if(this.statContext.preload){let a=e.info.currentFormat$.getValue(),s=e.info.availableSources$.getValue(),l=e.info.currentBuffer$.getValue(),h=e.info.currentQuality$.getValue(),g={target_buffer_time:this.calcBufferTime(l),playback_url:ne(a,s,h),playback_quality:H(h)};this.logPreloadStarted(g)}}),o(e.events.manifestRequested$,()=>{let a=e.info.currentFormat$.getValue(),s=e.info.availableSources$.getValue(),l=e.info.currentQuality$.getValue(),h={playback_url:ne(a,s,l),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused};this.logManifestRequest(h)}),o(e.events.firstBytesManifest$,()=>{let a=e.info.currentFormat$.getValue(),s=e.info.availableSources$.getValue(),l=e.info.currentQuality$.getValue(),h={playback_url:ne(a,s,l),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused};this.logFirstByteManifest(h)}),o(e.events.manifestReceived$,()=>{let a=e.info.currentFormat$.getValue(),s=e.info.availableSources$.getValue(),l=e.info.currentQuality$.getValue(),h={playback_url:ne(a,s,l),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused};this.logManifestReceived(h)}),o(e.events.firstBytesRequested$,()=>{let a=e.info.currentFormat$.getValue(),s=e.info.availableSources$.getValue(),l=e.info.currentQuality$.getValue(),h={playback_url:ne(a,s,l),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused};this.logFirstMediaRequest(h)}),o(e.events.firstBytesReceived$,()=>{let a=e.info.currentFormat$.getValue(),s=e.info.availableSources$.getValue(),l=e.info.currentQuality$.getValue(),h={playback_url:ne(a,s,l),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused};this.logFirstByteMedia(h)}),o(lf(e.events.willStart$,e.events.looped$),a=>{var h,g;a&&this.resetViewSession();let l={isid:this.isid$.getValue(),stream_profile:cf(mt(e.info.currentFormat$.getValue())),dpi:(h=this.statContext.dpi)!=null?h:96*z.display.pixelRatio,web_layout:this.statContext.isMobile||z.device.isMobile?"mobile":"desktop",preloaded:this.statContext.preload,navigation:this.statContext.navigation,recom_info:this.statContext.recomInfo};this.isEmbed&&(l.iframe_host=(g=this.embedHostname)!=null?g:"unknown"),this.logStartSession(l)}),o(e.events.started$,()=>{var x,te,re,$,bt,me,zo,Yo;this.isStarted=!0;let a=e.info.currentBuffer$.getValue(),s=e.info.currentQuality$.getValue(),l=e.info.isAutoQualityEnabled$.getValue(),h=e.info.muted$.getValue(),g=e.info.volume$.getValue(),m=e.info.surface$.getValue(),b=e.info.availableTextTracks$.getValue(),I=e.info.currentTextTrack$.getValue(),q=e.info.currentAudioStream$.getValue(),N=e.info.currentPlaybackRate$.getValue(),y={playback_quality:H(s),user_quality:l?"auto":H(s),player_width:(te=(x=this.statContext.playerSize)==null?void 0:x.width)!=null?te:this.playerSize.width,player_height:($=(re=this.statContext.playerSize)==null?void 0:re.height)!=null?$:this.playerSize.height,muted:h,sound_volume:Math.round(g*100),buffer_time:this.calcBufferTime(a),mode:gr(m,this.statContext.isPreviewPlayerView),visibility:mr(m),subtitles_enabled:I?!!I:(bt=this.currentSubtitle)==null?void 0:bt.enabled,auto_subtitles:(Yo=(me=b.find(({id:Sf})=>Sf===I))==null?void 0:me.isAuto)!=null?Yo:(zo=this.currentSubtitle)==null?void 0:zo.auto,audio_track_lang:q==null?void 0:q.language,playback_rate:N,recom_info:this.statContext.recomInfo};this.logPlaybackStarted(y)}),o(e.events.willStart$,()=>{this.logPlay()}),o(e.events.playing$,()=>{let a=e.info.currentBuffer$.getValue(),s={buffer_time:this.calcBufferTime(a)};this.logPlaying(s),this.wasPaused&&this.logResume()}),o(e.events.paused$,()=>{this.wasPaused=!0,this.logPause()}),o(e.events.willStop$,()=>{this.logStop()}),o(lf(e.events.fetcherRecoverableError$,e.events.fatalError$),()=>{this.statContext.preload&&this.logPreloadError()});let c=a=>{switch(a){case Fe.NETWORK:return"network";case Fe.VIDEO_PIPELINE:return"video_pipeline";case Fe.EXTERNAL_API:return"external_api";case Fe.PARSER:return"parser";case Fe.DOM:return"dom";default:return"wtf"}},f=a=>Fe.FATAL===a?"critical":"informative";o(e.events.fetcherRecoverableError$,({id:a,category:s,data:l,message:h,httpCode:g,UVBackendErrorCode:m})=>{let b={error_severity:f(s),error_category:c(s),player_error_code:a,player_error_trace:l,http_error_code:g,uv_backend_error_code_subcode:m,error_message:h};this.logError(b),f(s)==="critical"&&this.logCannotPlay()}),o(e.events.managedError$,({id:a,category:s,data:l,message:h})=>{let g={error_severity:f(s),error_category:c(s),player_error_code:a,player_error_trace:l,error_message:h};this.logError(g)}),o(e.events.fatalError$,({id:a,category:s,data:l,message:h})=>{let g={error_severity:"critical",error_category:c(s),player_error_code:a,player_error_trace:l,error_message:h};this.logError(g),this.logCannotPlay()}),o(br({connectionType:e.info.httpConnectionType$,connectionReused:e.info.httpConnectionReused$,connectionMetrics:e.info.httpConnectionMetrics$}).pipe(W(({connectionReused:a})=>a!==void 0),W(({connectionMetrics:a})=>a!==void 0),P_((a,s)=>a.connectionType===s.connectionType)),({connectionMetrics:a})=>{var b;let s=e.info.currentFormat$.getValue(),l=e.info.availableSources$.getValue(),h=e.info.currentQuality$.getValue(),g=e.info.rttEstimation$.getValue(),m={playback_url:ne(s,l,h),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused,rtt:g?Math.round(g):void 0,network_type:(b=this.statContext.networkType)!=null?b:a==null?void 0:a.networkType,dns_resolve_time:a==null?void 0:a.dnsResolveTime,tcp_handshake_time:a==null?void 0:a.tcpHandshakeTime,tls_handshake_time:a==null?void 0:a.tlsHandshakeTime};this.logConnectionEstablished(m)}),o(nf(e,{maxTimeWindow:this.config.downloadBytesMaxTime}),a=>{this.logDownloadBytes(a)}),o(e.events.firstFrame$,()=>{this.logFirstVideoFrameDecoded()}),o(e.events.willSeek$,()=>{let a={seek_type:this.seekAction$.getValue()};this.isStarted&&this.logSeeking(a)}),o(e.events.seeked$,()=>{let a={seek_type:this.seekAction$.getValue()};this.isStarted&&this.logSeeked(a),this.seekAction$.next("unknown")}),o(e.info.isStalled$,a=>{let s=e.info.currentBuffer$.getValue(),l=this.calcBufferTime(s);a&&l&&l>0&&this.logBufferStarvation({buffer_time:l})}),o(e.info.currentBuffer$.pipe(W(a=>!!this.calcBufferTime(a)),T_()),a=>{let s=this.calcBufferTime(a);if(this.statContext.preload){let l={buffer_time:s};this.logPreloadEnded(l)}this.logReady({buffer_time:s})});let d;o(br({videoStream:e.info.currentVideoStream$,audioStream:e.info.currentAudioStream$,quality:e.info.currentQuality$}).pipe(W(({videoStream:a,audioStream:s})=>a!==void 0&&s!==void 0),W(({quality:a})=>a!==void 0)),({videoStream:a,audioStream:s,quality:l})=>{if(d!==l){let h=e.info.isAutoQualityEnabled$.getValue(),g=a==null?void 0:a.codec,m=s==null?void 0:s.codec,b={user_quality:h?"auto":H(l),playback_quality:H(d),download_quality:H(l),codec_info:g&&m?`${g},${m}`:void 0};d=l,this.logQualityChanged(b)}});let p,v;return o(e.info.surface$,a=>{let s=gr(a,this.statContext.isPreviewPlayerView);s&&!this.uiEvents&&this.isStarted&&this.logModeChanged({mode:s}),v=mr(a),p!==v&&this.isStarted&&(p=mr(a),this.logVisibilityChanged({visibility:v}))}),o(br({muted:e.info.muted$,volume:e.info.volume$}),({muted:a,volume:s})=>{if(this.isStarted){let l={muted:a,sound_volume:Math.round(s*100)};this.logSoundChanged(l)}}),o(e.info.currentFormat$.pipe(W(a=>a!==void 0),jo(1)),a=>{let s={content_type:mt(a),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused};this.logContentTypeChange(s)}),o(e.info.currentAudioStream$.pipe(W(a=>a!==void 0),jo(1)),a=>{let s={audio_track_lang:a.language,codec_info:a.codec};this.logAudioTrackSwitched(s)}),o(e.info.currentVideoStream$.pipe(W(a=>a!==void 0),jo(1)),a=>{let s={hdr:a.hdr,codec_info:a.codec};this.logVideoTrackSwitched(s)}),this.player=e,this.resubscribeBeforeunload(),this.subscription.add(i),i}attachToUi(e){this.uiEvents=e;let{subscribe:r,subscription:i}=pf();r(e.actionSeek$,this.seekAction$),r(e.playerSize$,({width:n,height:c})=>{n&&c&&(this.playerSize={width:n,height:c},this.isStarted&&this.logViewPortChanged({player_width:n,player_height:c}))}),r(e.isLoaderVisible$,n=>{n&&this.isStarted&&this.logShowLoader()}),r(e.actionSubtitlesSwitched$,n=>{if(this.currentSubtitle={...n},this.isStarted){let c={subtitles_enabled:n.enabled,subtitles_track_lang:n.lang,auto_subtitles:n.auto};this.logSubtitlesSwitched(c)}});let{surface$:o}=sr(this.uiEvents,r,this.player);return r(o,n=>{this.isStarted&&this.logModeChanged({mode:gr(n)})}),r(e.actionQuality$,n=>{var v,a,s,l,h,g;let c=m=>(0,Wo.default)((0,hf.default)(ko),m),f=(a=(v=this.player)==null?void 0:v.info.currentVideoStream$.getValue())==null?void 0:a.codec,d=(l=(s=this.player)==null?void 0:s.info.currentAudioStream$.getValue())==null?void 0:l.codec,p={user_quality:c(n)?"auto":H(n),playback_quality:H((h=this.player)==null?void 0:h.info.currentQuality$.getValue()),download_quality:H((g=this.player)==null?void 0:g.info.currentQuality$.getValue()),codec_info:f&&d?`${f},${d}`:void 0};this.logQualityChangeRequested(p)}),this.resubscribeBeforeunload(),this.subscription.add(i),i}attachToAds(e){let{subscription:r,subscribe:i}=pf();return i(e.init$,o=>{let n={slot:o};this.logAdvConfiguration(n)}),i(e.slotRequested$,()=>{this.logAdvRequest()}),i(e.started$,o=>{let n={adv_section:o};this.logAdvBreakStarted(n)}),i(e.ended$,o=>{let n={adv_section:o};this.logAdvBreakEnded(n)}),i(e.error$,o=>{let n={error_message:o};this.logAdvError(n)}),this.resubscribeBeforeunload(),this.subscription.add(r),r}getDeviceId(){return this.deviceId}resetViewSession(){this.thinOneStatDebugLog({message:"VSID reset"}),ie.generateVSID(this.config.useVsid64),this.eventNumber=0}destroy(){this.api.destroy()}calcBufferTime(e){var r,i;return e?Math.round(((r=e.end)!=null?r:0)-((i=e.start)!=null?i:0))*1e3:void 0}createRequiredParams(e){var c,f,d,p,v;let r=this.vsid$.getValue();y_(r);let i=this.eventNumber++,o=((d=this.isLive?(c=this.player)==null?void 0:c.info.liveTime$.getValue():(f=this.player)==null?void 0:f.info.position$.getValue())!=null?d:0)*1e3,n={vsid:r,uv_movie_id:this.statContext.movieId,event_name:e,client_time:Date.now(),application:(p=this.statContext.application)!=null?p:`@vkontakte/videoplayer-statistics:${D}`,platform:(v=this.statContext.platform)!=null?v:`web:${this.statContext.isMobile||z.device.isMobile?"mobile":"desktop"}`,product:this.statContext.product,event_number:i,playback_position:o,current_tvt:this.getTotalViewTime(),cdn_host:this.cdnHostname};for(let a of this.config.disabledParams)delete n[a];return n}createRequiredFatParams(){var r,i,o,n,c,f,d;let e={stats_version:"2.1.1",browser:(r=this.statContext.browser)!=null?r:z.browser.current,browser_version:(i=this.statContext.browserVersion)!=null?i:String(z.browser.currentVersion),os:(o=this.statContext.os)!=null?o:z.device.os.name,os_version:(n=this.statContext.osVersion)!=null?n:z.device.os.version,device_type:(c=this.statContext.deviceType)!=null?c:this.statContext.isMobile||z.device.isMobile?"mobile":"desktop",device_manufacturer:(f=this.statContext.deviceManufacturer)!=null?f:z.device.details.vendor,device_model:(d=this.statContext.deviceModel)!=null?d:z.device.details.model,navigation:this.statContext.navigation};for(let p of this.config.disabledParams)delete e[p];return e}log(e,r,i=!1){if((0,Wo.default)(this.config.disabledEvents,e))return;let o=this.createRequiredParams(e),n={};i&&(n=this.createRequiredFatParams()),this.logger.log({...o,...n,...r})}logWatchCoverage(e){this.log("watch_coverage",e,!0)}logWatchCoverageLive(e){this.log("watch_coverage_live",e,!0)}logWatchedN(e){this.log("watched_n",e,!0)}logStartSession(e){this.log("start_session",e,!0)}logPreloadStarted(e){this.log("preload_started",e)}logPreloadEnded(e){this.log("preload_ended",e)}logPreloadError(){this.log("preload_error")}logPlaybackStarted(e){this.log("playback_started",e,!0)}logPlay(){this.log("play")}logManifestRequest(e){this.log("manifest_request",e)}logFirstByteManifest(e){this.log("first_byte_manifest",e)}logFirstMediaRequest(e){this.log("first_media_request",e)}logFirstByteMedia(e){this.log("first_byte_media",e)}logManifestReceived(e){this.log("manifest_received",e)}logConnectionEstablished(e){this.log("connection_established",e)}logFirstVideoFrameDecoded(){this.log("first_video_frame_decoded")}logReady(e){this.log("ready",e)}logPlaying(e){this.log("playing",e)}logPause(){this.log("pause")}logResume(){this.log("resume")}logSeeking(e){this.log("seeking",e)}logSeeked(e){this.log("seeked",e)}logStop(){this.log("stop")}logBufferStarvation(e){this.log("buffer_starvation",e)}logShowLoader(){this.log("show_loader")}logQualityChangeRequested(e){this.log("quality_change_requested",e)}logQualityChanged(e){this.log("quality_changed",e)}logCdnHostChanged(e){this.log("cdn_host_changed",e)}logViewPortChanged(e){this.log("view_port_changed",e)}logModeChanged(e){this.log("mode_changed",e)}logVisibilityChanged(e){this.log("visibility_changed",e)}logAudioTrackSwitched(e){this.log("audio_track_switched",e)}logVideoTrackSwitched(e){this.log("video_track_switched",e)}logSubtitlesSwitched(e){this.log("subtitles_switched",e)}logSoundChanged(e){this.log("sound_changed",e)}logFailover(e){this.log("failover",e)}logContentTypeChange(e){this.log("content_type_change",e)}logError(e){this.log("error",e,!0)}logCannotPlay(){this.log("cannot_play",{},!0)}logDownloadBytes(e){this.log("download_bytes",e)}logAdvConfiguration(e){this.log("adv_configuration",e)}logAdvRequest(){this.log("adv_request")}logAdvBreakStarted(e){this.log("adv_break_started",e)}logAdvBreakEnded(e){this.log("adv_break_ended",e)}logAdvError(e){this.log("adv_error",e)}resubscribeBeforeunload(){var e;(e=this.beforeunloadSubscription)==null||e.unsubscribe(),this.beforeunloadSubscription=__(E_(),"beforeunload").subscribe(()=>{}),this.subscription.add(this.beforeunloadSubscription)}};var vf={};var A_=(t,e={})=>{let i=e.timeout||1,o=performance.now();return P.setTimeout(()=>{t({get didTimeout(){return e.timeout?!1:performance.now()-o-1>i},timeRemaining(){return Math.max(0,1+(performance.now()-o))}})},1)},O_=t=>P.clearTimeout(t),gf=t=>typeof t=="function"&&(t==null?void 0:t.toString().endsWith("{ [native code] }")),mf=!gf(P.requestIdleCallback)||!gf(P.cancelIdleCallback),bf=mf?A_:P.requestIdleCallback,yf=mf?O_:P.cancelIdleCallback;import{PlaybackState as _f,Subscription as C_}from"@vkontakte/videoplayer-core/es2018";import{Logger as q_}from"@vkontakte/videoplayer-shared/es2018";var Ir=class{constructor(){this.startTime=null;this.stopTime=null;this.accumulatedTime=0}get time(){return Math.floor(this.timeMs/1e3)}get timeMs(){var r;return this.startTime===null?0:((r=this.stopTime)!=null?r:this.now())-this.startTime-this.accumulatedTime}get isRunning(){return this.startTime!==null&&this.stopTime===null}start(){this.isRunning||(this.stopTime!==null?(this.accumulatedTime+=this.now()-this.stopTime,this.stopTime=null):this.startTime=this.now())}stop(){this.isRunning&&(this.stopTime=this.now())}reset(){this.startTime=null,this.stopTime=null,this.accumulatedTime=0}now(){return Date.now()}};var If=()=>window.Image?new Image:document.createElement("img");var Go=class{constructor(e){this.position=0;this.started=!1;this.heartbeatPixels=[];this.heartbeatLastTimeSent={};this.idleCallbackIds=[];this.stopwatch=new Ir;this.subscription=new C_;this.params=e;let r=new q_;this.log=r.createComponentLog("MediascopePixel")}attachTo(e){this.subscription.add(e.info.playbackState$.subscribe(r=>this.onPlaybackState(r))).add(e.info.position$.subscribe(r=>this.onPosition(r))).add(e.info.atLiveEdge$.subscribe(r=>this.isActiveLive=r)),this.subscription.add(e.events.willSeek$.subscribe(()=>this.onWillSeek())).add(e.events.seeked$.subscribe(()=>this.onSeeked())).add(e.events.ended$.subscribe(()=>this.onEnded()))}destroy(){this.stopwatch.reset(),this.subscription.unsubscribe(),window.clearTimeout(this.heartbeatFirstTimeoutId),this.idleCallbackIds.forEach(e=>yf(e)),this.send("stop")}onPlaybackState(e){e===_f.PLAYING?this.started?this.play():this.start():e===_f.PAUSED&&this.pause()}start(){var i,o,n;this.started=!0,this.stopwatch.start(),this.send("start"),this.heartbeatPixels=this.prepareHeartbeatPixels(),this.heartbeatInterval=(i=this.heartbeatPixels[0])==null?void 0:i.interval;let e=(o=this.heartbeatPixels[0])==null?void 0:o.url,r=(n=this.heartbeatPixels[0])==null?void 0:n.delay;if(r!==void 0&&e)try{this.heartbeatFirstTimeoutId=window.setTimeout(()=>{this.sendHeartbeat(e)},r*1e3)}catch(c){this.log({message:c.message})}}play(){this.stopwatch.start(),this.send("resume")}pause(){this.stopwatch.stop(),this.send("pause")}onPosition(e){if(this.position=e,this.heartbeatInterval&&this.stopwatch.time!==0&&this.stopwatch.time%this.heartbeatInterval===0)for(let[r,{url:i}]of this.heartbeatPixels.entries())this.heartbeatLastTimeSent[r]!==this.stopwatch.time&&(this.heartbeatLastTimeSent[r]=this.stopwatch.time,this.sendHeartbeat(i))}onWillSeek(){this.started&&this.send("stop")}onSeeked(){this.started&&this.send("start")}onEnded(){this.stopwatch.stop(),this.send("stop")}validatePixels(e,r){return e==null?void 0:e.filter(i=>i.event===r.event&&r.keys.every(o=>!!i[o]))}getFrameTimestamp(){let e;if(this.isActiveLive){let r=Math.floor(Math.random()*25)+5;e=Date.now()/1e3-r}else e=this.position||0;return Math.floor(e)}getUTC(){return Math.floor(Date.now()/1e3)}prepareUrl(e){return e.replace("{@fts_fake_sec}",String(this.getFrameTimestamp())).replace("{@utc_sec}",String(this.getUTC())).split("&").filter(r=>!/={@[a-zA-Z_]+}/.test(r)).join("&")}preparePixels(e){return this.validatePixels(this.params.pixels,{event:e,keys:["url"]})}prepareHeartbeatPixels(){return this.validatePixels(this.params.pixels,{event:"heartbeat",keys:["url","interval"]})}call(e){try{this.idleCallbackIds.push(bf(()=>If().src=this.prepareUrl(e)))}catch(r){this.log({message:r.message})}}send(e){let r=this.preparePixels(e);for(let{url:i}of r)this.call(i)}sendHeartbeat(e){this.call(e)}};export{Je as ApiEnv,oi as ConnectionType,ii as ContentType,Wa as InteractiveInterfaceClick,Go as MediascopePixel,vf as MediascopePixelTypes,Ro as OneStat,ri as Quality,ni as SeekAction,Qo as ThinOneStat,D as VERSION};
6
+ import e from"@oxc-project/runtime/helpers/defineProperty";var t=Object.create,n=Object.getPrototypeOf,r=Object.defineProperty,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty;function o(e){return this[e]}var s,c,l=(e,l,u)=>{var d=typeof e==`object`&&!!e;if(d){var f=l?s??=new WeakMap:c??=new WeakMap,p=f.get(e);if(p)return p}u=e==null?{}:t(n(e));let m=l||!e||!e.__esModule?r(u,`default`,{value:e,enumerable:!0}):u;for(let t of i(e))a.call(m,t)||r(m,t,{get:o.bind(e,t),enumerable:!0});return d&&f.set(e,m),m},u=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),d=e=>e;function f(e,t){this[e]=d.bind(null,t)}var p=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0,configurable:!0,set:f.bind(t,n)})},m=u((e,t)=>{var n=function(e){return e&&e.Math===Math&&e};t.exports=n(typeof globalThis==`object`&&globalThis)||n(typeof window==`object`&&window)||n(typeof self==`object`&&self)||n(typeof global==`object`&&global)||n(typeof e==`object`&&e)||function(){return this}()||Function(`return this`)()}),h=u((e,t)=>{t.exports=function(e){try{return!!e()}catch{return!0}}}),g=u((e,t)=>{t.exports=!h()(function(){var e=function(){}.bind();return typeof e!=`function`||e.hasOwnProperty(`prototype`)})}),_=u((e,t)=>{var n=g(),r=Function.prototype,i=r.apply,a=r.call;t.exports=typeof Reflect==`object`&&Reflect.apply||(n?a.bind(i):function(){return a.apply(i,arguments)})}),v=u((e,t)=>{var n=g(),r=Function.prototype,i=r.call,a=n&&r.bind.bind(i,i);t.exports=n?a:function(e){return function(){return i.apply(e,arguments)}}}),y=u((e,t)=>{var n=v(),r=n({}.toString),i=n(``.slice);t.exports=function(e){return i(r(e),8,-1)}}),b=u((e,t)=>{var n=y(),r=v();t.exports=function(e){if(n(e)===`Function`)return r(e)}}),x=u((e,t)=>{var n=typeof document==`object`&&document.all;t.exports=n===void 0&&n!==void 0?function(e){return typeof e==`function`||e===n}:function(e){return typeof e==`function`}}),S=u((e,t)=>{t.exports=!h()(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})}),C=u((e,t)=>{var n=g(),r=Function.prototype.call;t.exports=n?r.bind(r):function(){return r.apply(r,arguments)}}),w=u(e=>{var t={}.propertyIsEnumerable,n=Object.getOwnPropertyDescriptor;e.f=n&&!t.call({1:2},1)?function(e){var t=n(this,e);return!!t&&t.enumerable}:t}),T=u((e,t)=>{t.exports=function(e,t){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:t}}}),E=u((e,t)=>{var n=v(),r=h(),i=y(),a=Object,o=n(``.split);t.exports=r(function(){return!a(`z`).propertyIsEnumerable(0)})?function(e){return i(e)===`String`?o(e,``):a(e)}:a}),D=u((e,t)=>{t.exports=function(e){return e==null}}),O=u((e,t)=>{var n=D(),r=TypeError;t.exports=function(e){if(n(e))throw new r(`Can't call method on `+e);return e}}),k=u((e,t)=>{var n=E(),r=O();t.exports=function(e){return n(r(e))}}),A=u((e,t)=>{var n=x();t.exports=function(e){return typeof e==`object`?e!==null:n(e)}}),j=u((e,t)=>{t.exports={}}),M=u((e,t)=>{var n=j(),r=m(),i=x(),a=function(e){return i(e)?e:void 0};t.exports=function(e,t){return arguments.length<2?a(n[e])||a(r[e]):n[e]&&n[e][t]||r[e]&&r[e][t]}}),N=u((e,t)=>{t.exports=v()({}.isPrototypeOf)}),P=u((e,t)=>{var n=m().navigator,r=n&&n.userAgent;t.exports=r?String(r):``}),F=u((e,t)=>{var n=m(),r=P(),i=n.process,a=n.Deno,o=i&&i.versions||a&&a.version,s=o&&o.v8,c,l;s&&(c=s.split(`.`),l=c[0]>0&&c[0]<4?1:+(c[0]+c[1])),!l&&r&&(c=r.match(/Edge\/(\d+)/),(!c||c[1]>=74)&&(c=r.match(/Chrome\/(\d+)/),c&&(l=+c[1]))),t.exports=l}),I=u((e,t)=>{var n=F(),r=h(),i=m().String;t.exports=!!Object.getOwnPropertySymbols&&!r(function(){var e=Symbol(`symbol detection`);return!i(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&n&&n<41})}),ee=u((e,t)=>{t.exports=I()&&!Symbol.sham&&typeof Symbol.iterator==`symbol`}),te=u((e,t)=>{var n=M(),r=x(),i=N(),a=ee(),o=Object;t.exports=a?function(e){return typeof e==`symbol`}:function(e){var t=n(`Symbol`);return r(t)&&i(t.prototype,o(e))}}),ne=u((e,t)=>{var n=String;t.exports=function(e){try{return n(e)}catch{return`Object`}}}),L=u((e,t)=>{var n=x(),r=ne(),i=TypeError;t.exports=function(e){if(n(e))return e;throw new i(r(e)+` is not a function`)}}),re=u((e,t)=>{var n=L(),r=D();t.exports=function(e,t){var i=e[t];return r(i)?void 0:n(i)}}),ie=u((e,t)=>{var n=C(),r=x(),i=A(),a=TypeError;t.exports=function(e,t){var o,s;if(t===`string`&&r(o=e.toString)&&!i(s=n(o,e))||r(o=e.valueOf)&&!i(s=n(o,e))||t!==`string`&&r(o=e.toString)&&!i(s=n(o,e)))return s;throw new a(`Can't convert object to primitive value`)}}),R=u((e,t)=>{t.exports=!0}),ae=u((e,t)=>{var n=m(),r=Object.defineProperty;t.exports=function(e,t){try{r(n,e,{value:t,configurable:!0,writable:!0})}catch{n[e]=t}return t}}),oe=u((e,t)=>{var n=R(),r=m(),i=ae(),a=`__core-js_shared__`,o=t.exports=r[a]||i(a,{});(o.versions||=[]).push({version:`3.43.0`,mode:n?`pure`:`global`,copyright:`© 2014-2025 Denis Pushkarev (zloirock.ru)`,license:`https://github.com/zloirock/core-js/blob/v3.43.0/LICENSE`,source:`https://github.com/zloirock/core-js`})}),se=u((e,t)=>{var n=oe();t.exports=function(e,t){return n[e]||(n[e]=t||{})}}),ce=u((e,t)=>{var n=O(),r=Object;t.exports=function(e){return r(n(e))}}),z=u((e,t)=>{var n=v(),r=ce(),i=n({}.hasOwnProperty);t.exports=Object.hasOwn||function(e,t){return i(r(e),t)}}),le=u((e,t)=>{var n=v(),r=0,i=Math.random(),a=n(1.1.toString);t.exports=function(e){return`Symbol(`+(e===void 0?``:e)+`)_`+a(++r+i,36)}}),B=u((e,t)=>{var n=m(),r=se(),i=z(),a=le(),o=I(),s=ee(),c=n.Symbol,l=r(`wks`),u=s?c.for||c:c&&c.withoutSetter||a;t.exports=function(e){return i(l,e)||(l[e]=o&&i(c,e)?c[e]:u(`Symbol.`+e)),l[e]}}),ue=u((e,t)=>{var n=C(),r=A(),i=te(),a=re(),o=ie(),s=B(),c=TypeError,l=s(`toPrimitive`);t.exports=function(e,t){if(!r(e)||i(e))return e;var s=a(e,l),u;if(s){if(t===void 0&&(t=`default`),u=n(s,e,t),!r(u)||i(u))return u;throw new c(`Can't convert object to primitive value`)}return t===void 0&&(t=`number`),o(e,t)}}),de=u((e,t)=>{var n=ue(),r=te();t.exports=function(e){var t=n(e,`string`);return r(t)?t:t+``}}),fe=u((e,t)=>{var n=m(),r=A(),i=n.document,a=r(i)&&r(i.createElement);t.exports=function(e){return a?i.createElement(e):{}}}),pe=u((e,t)=>{var n=S(),r=h(),i=fe();t.exports=!n&&!r(function(){return Object.defineProperty(i(`div`),`a`,{get:function(){return 7}}).a!==7})}),me=u(e=>{var t=S(),n=C(),r=w(),i=T(),a=k(),o=de(),s=z(),c=pe(),l=Object.getOwnPropertyDescriptor;e.f=t?l:function(e,t){if(e=a(e),t=o(t),c)try{return l(e,t)}catch{}if(s(e,t))return i(!n(r.f,e,t),e[t])}}),he=u((e,t)=>{var n=h(),r=x(),i=/#|\.prototype\./,a=function(e,t){var i=s[o(e)];return i===l?!0:i===c?!1:r(t)?n(t):!!t},o=a.normalize=function(e){return String(e).replace(i,`.`).toLowerCase()},s=a.data={},c=a.NATIVE=`N`,l=a.POLYFILL=`P`;t.exports=a}),ge=u((e,t)=>{var n=b(),r=L(),i=g(),a=n(n.bind);t.exports=function(e,t){return r(e),t===void 0?e:i?a(e,t):function(){return e.apply(t,arguments)}}}),_e=u((e,t)=>{var n=S(),r=h();t.exports=n&&r(function(){return Object.defineProperty(function(){},`prototype`,{value:42,writable:!1}).prototype!==42})}),V=u((e,t)=>{var n=A(),r=String,i=TypeError;t.exports=function(e){if(n(e))return e;throw new i(r(e)+` is not an object`)}}),ve=u(e=>{var t=S(),n=pe(),r=_e(),i=V(),a=de(),o=TypeError,s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=`enumerable`,u=`configurable`,d=`writable`;e.f=t?r?function(e,t,n){if(i(e),t=a(t),i(n),typeof e==`function`&&t===`prototype`&&`value`in n&&d in n&&!n[d]){var r=c(e,t);r&&r[d]&&(e[t]=n.value,n={configurable:u in n?n[u]:r[u],enumerable:l in n?n[l]:r[l],writable:!1})}return s(e,t,n)}:s:function(e,t,r){if(i(e),t=a(t),i(r),n)try{return s(e,t,r)}catch{}if(`get`in r||`set`in r)throw new o(`Accessors not supported`);return`value`in r&&(e[t]=r.value),e}}),ye=u((e,t)=>{var n=S(),r=ve(),i=T();t.exports=n?function(e,t,n){return r.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}}),H=u((e,t)=>{var n=m(),r=_(),i=b(),a=x(),o=me().f,s=he(),c=j(),l=ge(),u=ye(),d=z();oe();var f=function(e){var t=function(n,i,a){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(n);case 2:return new e(n,i)}return new e(n,i,a)}return r(e,this,arguments)};return t.prototype=e.prototype,t};t.exports=function(e,t){var r=e.target,p=e.global,m=e.stat,h=e.proto,g=p?n:m?n[r]:n[r]&&n[r].prototype,_=p?c:c[r]||u(c,r,{})[r],v=_.prototype,y,b,x,S,C,w,T,E,D;for(S in t)y=s(p?S:r+(m?`.`:`#`)+S,e.forced),b=!y&&g&&d(g,S),w=_[S],b&&(e.dontCallGetSet?(D=o(g,S),T=D&&D.value):T=g[S]),C=b&&T?T:t[S],!(!y&&!h&&typeof w==typeof C)&&(E=e.bind&&b?l(C,n):e.wrap&&b?f(C):h&&a(C)?i(C):C,(e.sham||C&&C.sham||w&&w.sham)&&u(E,`sham`,!0),u(_,S,E),h&&(x=r+`Prototype`,d(c,x)||u(c,x,{}),u(c[x],S,C),e.real&&v&&(y||!v[S])&&u(v,S,C)))}}),be=u((e,t)=>{var n=Math.ceil,r=Math.floor;t.exports=Math.trunc||function(e){var t=+e;return(t>0?r:n)(t)}}),xe=u((e,t)=>{var n=be();t.exports=function(e){var t=+e;return t!==t||t===0?0:n(t)}}),Se=u((e,t)=>{var n=xe(),r=Math.max,i=Math.min;t.exports=function(e,t){var a=n(e);return a<0?r(a+t,0):i(a,t)}}),U=u((e,t)=>{var n=xe(),r=Math.min;t.exports=function(e){var t=n(e);return t>0?r(t,9007199254740991):0}}),Ce=u((e,t)=>{var n=U();t.exports=function(e){return n(e.length)}}),we=u((e,t)=>{var n=k(),r=Se(),i=Ce(),a=function(e){return function(t,a,o){var s=n(t),c=i(s);if(c===0)return!e&&-1;var l=r(o,c),u;if(e&&a!==a){for(;c>l;)if(u=s[l++],u!==u)return!0}else for(;c>l;l++)if((e||l in s)&&s[l]===a)return e||l||0;return!e&&-1}};t.exports={includes:a(!0),indexOf:a(!1)}}),Te=u((e,t)=>{t.exports=function(){}}),Ee=u(()=>{var e=H(),t=we().includes,n=h(),r=Te();e({target:`Array`,proto:!0,forced:n(function(){return![,].includes()})},{includes:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),r(`includes`)}),De=u((e,t)=>{t.exports=M()}),Oe=u((e,t)=>{Ee(),t.exports=De()(`Array`,`includes`)}),ke=u((e,t)=>{t.exports=Oe()}),Ae=u((e,t)=>{t.exports=ke()}),je=u((e,t)=>{var n=B()(`toStringTag`),r={};r[n]=`z`,t.exports=String(r)===`[object z]`}),Me=u((e,t)=>{var n=je(),r=x(),i=y(),a=B()(`toStringTag`),o=Object,s=i(function(){return arguments}())===`Arguments`,c=function(e,t){try{return e[t]}catch{}};t.exports=n?i:function(e){var t,n,l;return e===void 0?`Undefined`:e===null?`Null`:typeof(n=c(t=o(e),a))==`string`?n:s?i(t):(l=i(t))===`Object`&&r(t.callee)?`Arguments`:l}}),Ne=u((e,t)=>{var n=Me(),r=String;t.exports=function(e){if(n(e)===`Symbol`)throw TypeError(`Cannot convert a Symbol value to a string`);return r(e)}}),Pe=u((e,t)=>{var n=xe(),r=Ne(),i=O(),a=RangeError;t.exports=function(e){var t=r(i(this)),o=``,s=n(e);if(s<0||s===1/0)throw new a(`Wrong number of repetitions`);for(;s>0;(s>>>=1)&&(t+=t))s&1&&(o+=t);return o}}),Fe=u((e,t)=>{var n=v(),r=U(),i=Ne(),a=Pe(),o=O(),s=n(a),c=n(``.slice),l=Math.ceil,u=function(e){return function(t,n,a){var u=i(o(t)),d=r(n),f=u.length,p=a===void 0?` `:i(a),m,h;return d<=f||p===``?u:(m=d-f,h=s(p,l(m/p.length)),h.length>m&&(h=c(h,0,m)),e?u+h:h+u)}};t.exports={start:u(!1),end:u(!0)}}),Ie=u((e,t)=>{var n=P();t.exports=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(n)}),Le=u(()=>{var e=H(),t=Fe().start;e({target:`String`,proto:!0,forced:Ie()},{padStart:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})}),Re=u((e,t)=>{Le(),t.exports=De()(`String`,`padStart`)}),ze=u((e,t)=>{t.exports=Re()}),Be=u((e,t)=>{t.exports=ze()}),Ve=u((e,t)=>{var n=m(),r=P(),i=y(),a=function(e){return r.slice(0,e.length)===e};t.exports=function(){return a(`Bun/`)?`BUN`:a(`Cloudflare-Workers`)?`CLOUDFLARE`:a(`Deno/`)?`DENO`:a(`Node.js/`)?`NODE`:n.Bun&&typeof Bun.version==`string`?`BUN`:n.Deno&&typeof Deno.version==`object`?`DENO`:i(n.process)===`process`?`NODE`:n.window&&n.document?`BROWSER`:`REST`}()}),He=u((e,t)=>{t.exports=Ve()===`NODE`}),Ue=u((e,t)=>{var n=ye();t.exports=function(e,t,r,i){return i&&i.enumerable?e[t]=r:n(e,t,r),e}}),We=u((e,t)=>{var n=v(),r=L();t.exports=function(e,t,i){try{return n(r(Object.getOwnPropertyDescriptor(e,t)[i]))}catch{}}}),Ge=u((e,t)=>{var n=A();t.exports=function(e){return n(e)||e===null}}),Ke=u((e,t)=>{var n=Ge(),r=String,i=TypeError;t.exports=function(e){if(n(e))return e;throw new i(`Can't set `+r(e)+` as a prototype`)}}),qe=u((e,t)=>{var n=We(),r=A(),i=O(),a=Ke();t.exports=Object.setPrototypeOf||(`__proto__`in{}?function(){var e=!1,t={},o;try{o=n(Object.prototype,`__proto__`,`set`),o(t,[]),e=t instanceof Array}catch{}return function(t,n){return i(t),a(n),r(t)&&(e?o(t,n):t.__proto__=n),t}}():void 0)}),Je=u((e,t)=>{var n=je(),r=Me();t.exports=n?{}.toString:function(){return`[object `+r(this)+`]`}}),Ye=u((e,t)=>{var n=je(),r=ve().f,i=ye(),a=z(),o=Je(),s=B()(`toStringTag`);t.exports=function(e,t,c,l){var u=c?e:e&&e.prototype;u&&(a(u,s)||r(u,s,{configurable:!0,value:t}),l&&!n&&i(u,`toString`,o))}}),Xe=u((e,t)=>{var n=ve();t.exports=function(e,t,r){return n.f(e,t,r)}}),Ze=u((e,t)=>{var n=M(),r=Xe(),i=B(),a=S(),o=i(`species`);t.exports=function(e){var t=n(e);a&&t&&!t[o]&&r(t,o,{configurable:!0,get:function(){return this}})}}),Qe=u((e,t)=>{var n=N(),r=TypeError;t.exports=function(e,t){if(n(t,e))return e;throw new r(`Incorrect invocation`)}}),$e=u((e,t)=>{var n=v(),r=x(),i=oe(),a=n(Function.toString);r(i.inspectSource)||(i.inspectSource=function(e){return a(e)}),t.exports=i.inspectSource}),et=u((e,t)=>{var n=v(),r=h(),i=x(),a=Me(),o=M(),s=$e(),c=function(){},l=o(`Reflect`,`construct`),u=/^\s*(?:class|function)\b/,d=n(u.exec),f=!u.test(c),p=function(e){if(!i(e))return!1;try{return l(c,[],e),!0}catch{return!1}},m=function(e){if(!i(e))return!1;switch(a(e)){case`AsyncFunction`:case`GeneratorFunction`:case`AsyncGeneratorFunction`:return!1}try{return f||!!d(u,s(e))}catch{return!0}};m.sham=!0,t.exports=!l||r(function(){var e;return p(p.call)||!p(Object)||!p(function(){e=!0})||e})?m:p}),tt=u((e,t)=>{var n=et(),r=ne(),i=TypeError;t.exports=function(e){if(n(e))return e;throw new i(r(e)+` is not a constructor`)}}),nt=u((e,t)=>{var n=V(),r=tt(),i=D(),a=B()(`species`);t.exports=function(e,t){var o=n(e).constructor,s;return o===void 0||i(s=n(o)[a])?t:r(s)}}),rt=u((e,t)=>{t.exports=M()(`document`,`documentElement`)}),it=u((e,t)=>{t.exports=v()([].slice)}),at=u((e,t)=>{var n=TypeError;t.exports=function(e,t){if(e<t)throw new n(`Not enough arguments`);return e}}),ot=u((e,t)=>{var n=P();t.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(n)}),st=u((e,t)=>{var n=m(),r=_(),i=ge(),a=x(),o=z(),s=h(),c=rt(),l=it(),u=fe(),d=at(),f=ot(),p=He(),g=n.setImmediate,v=n.clearImmediate,y=n.process,b=n.Dispatch,S=n.Function,C=n.MessageChannel,w=n.String,T=0,E={},D=`onreadystatechange`,O,k,A,j;s(function(){O=n.location});var M=function(e){if(o(E,e)){var t=E[e];delete E[e],t()}},N=function(e){return function(){M(e)}},P=function(e){M(e.data)},F=function(e){n.postMessage(w(e),O.protocol+`//`+O.host)};(!g||!v)&&(g=function(e){d(arguments.length,1);var t=a(e)?e:S(e),n=l(arguments,1);return E[++T]=function(){r(t,void 0,n)},k(T),T},v=function(e){delete E[e]},p?k=function(e){y.nextTick(N(e))}:b&&b.now?k=function(e){b.now(N(e))}:C&&!f?(A=new C,j=A.port2,A.port1.onmessage=P,k=i(j.postMessage,j)):n.addEventListener&&a(n.postMessage)&&!n.importScripts&&O&&O.protocol!==`file:`&&!s(F)?(k=F,n.addEventListener(`message`,P,!1)):k=D in u(`script`)?function(e){c.appendChild(u(`script`))[D]=function(){c.removeChild(this),M(e)}}:function(e){setTimeout(N(e),0)}),t.exports={set:g,clear:v}}),ct=u((e,t)=>{var n=m(),r=S(),i=Object.getOwnPropertyDescriptor;t.exports=function(e){if(!r)return n[e];var t=i(n,e);return t&&t.value}}),lt=u((e,t)=>{var n=function(){this.head=null,this.tail=null};n.prototype={add:function(e){var t={item:e,next:null},n=this.tail;n?n.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return(this.head=e.next)===null&&(this.tail=null),e.item}},t.exports=n}),ut=u((e,t)=>{var n=P();t.exports=/ipad|iphone|ipod/i.test(n)&&typeof Pebble<`u`}),dt=u((e,t)=>{var n=P();t.exports=/web0s(?!.*chrome)/i.test(n)}),ft=u((e,t)=>{var n=m(),r=ct(),i=ge(),a=st().set,o=lt(),s=ot(),c=ut(),l=dt(),u=He(),d=n.MutationObserver||n.WebKitMutationObserver,f=n.document,p=n.process,h=n.Promise,g=r(`queueMicrotask`),_,v,y,b,x;g||=(S=new o,C=function(){var e,t;for(u&&(e=p.domain)&&e.exit();t=S.get();)try{t()}catch(e){throw S.head&&_(),e}e&&e.enter()},!s&&!u&&!l&&d&&f?(v=!0,y=f.createTextNode(``),new d(C).observe(y,{characterData:!0}),_=function(){y.data=v=!v}):!c&&h&&h.resolve?(b=h.resolve(void 0),b.constructor=h,x=i(b.then,b),_=function(){x(C)}):u?_=function(){p.nextTick(C)}:(a=i(a,n),_=function(){a(C)}),function(e){S.head||_(),S.add(e)});var S,C;t.exports=g}),pt=u((e,t)=>{t.exports=function(e,t){try{arguments.length===1?console.error(e):console.error(e,t)}catch{}}}),mt=u((e,t)=>{t.exports=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}}}),ht=u((e,t)=>{var n=m(),r=x(),i=n.WeakMap;t.exports=r(i)&&/native code/.test(String(i))}),gt=u((e,t)=>{var n=se(),r=le(),i=n(`keys`);t.exports=function(e){return i[e]||(i[e]=r(e))}}),_t=u((e,t)=>{t.exports={}}),vt=u((e,t)=>{var n=ht(),r=m(),i=A(),a=ye(),o=z(),s=oe(),c=gt(),l=_t(),u=`Object already initialized`,d=r.TypeError,f=r.WeakMap,p,h,g,_=function(e){return g(e)?h(e):p(e,{})},v=function(e){return function(t){var n;if(!i(t)||(n=h(t)).type!==e)throw new d(`Incompatible receiver, `+e+` required`);return n}};n||s.state?(y=s.state||=new f,y.get=y.get,y.has=y.has,y.set=y.set,p=function(e,t){if(y.has(e))throw new d(u);return t.facade=e,y.set(e,t),t},h=function(e){return y.get(e)||{}},g=function(e){return y.has(e)}):(b=c(`state`),l[b]=!0,p=function(e,t){if(o(e,b))throw new d(u);return t.facade=e,a(e,b,t),t},h=function(e){return o(e,b)?e[b]:{}},g=function(e){return o(e,b)});var y,b;t.exports={set:p,get:h,has:g,enforce:_,getterFor:v}}),yt=u((e,t)=>{t.exports=m().Promise}),bt=u((e,t)=>{var n=m(),r=yt(),i=x(),a=he(),o=$e(),s=B(),c=Ve(),l=R(),u=F(),d=r&&r.prototype,f=s(`species`),p=!1,h=i(n.PromiseRejectionEvent);t.exports={CONSTRUCTOR:a(`Promise`,function(){var e=o(r),t=e!==String(r);if(!t&&u===66||l&&!(d.catch&&d.finally))return!0;if(!u||u<51||!/native code/.test(e)){var n=new r(function(e){e(1)}),i=function(e){e(function(){},function(){})},a=n.constructor={};if(a[f]=i,p=n.then(function(){})instanceof i,!p)return!0}return!t&&(c===`BROWSER`||c===`DENO`)&&!h}),REJECTION_EVENT:h,SUBCLASSING:p}}),xt=u((e,t)=>{var n=L(),r=TypeError,i=function(e){var t,i;this.promise=new e(function(e,n){if(t!==void 0||i!==void 0)throw new r(`Bad Promise constructor`);t=e,i=n}),this.resolve=n(t),this.reject=n(i)};e.f=function(e){return new i(e)}}),St=u(()=>{var e=H(),t=R(),n=He(),r=m(),i=j(),a=C(),o=Ue(),s=qe(),c=Ye(),l=Ze(),u=L(),d=x(),f=A(),p=Qe(),h=nt(),g=st().set,_=ft(),v=pt(),y=mt(),b=lt(),S=vt(),w=yt(),T=bt(),E=xt(),D=`Promise`,O=T.CONSTRUCTOR,k=T.REJECTION_EVENT,M=T.SUBCLASSING,N=S.getterFor(D),P=S.set,F=w&&w.prototype,I=w,ee=F,te=r.TypeError,ne=r.document,re=r.process,ie=E.f,ae=ie,oe=!!(ne&&ne.createEvent&&r.dispatchEvent),se=`unhandledrejection`,ce=`rejectionhandled`,z=0,le=1,B=2,ue=1,de=2,fe,pe,me,he,ge=function(e){var t;return f(e)&&d(t=e.then)?t:!1},_e=function(e,t){var n=t.value,r=t.state===le,i=r?e.ok:e.fail,o=e.resolve,s=e.reject,c=e.domain,l,u,d;try{i?(r||(t.rejection===de&&xe(t),t.rejection=ue),i===!0?l=n:(c&&c.enter(),l=i(n),c&&(c.exit(),d=!0)),l===e.promise?s(new te(`Promise-chain cycle`)):(u=ge(l))?a(u,l,o,s):o(l)):s(n)}catch(e){c&&!d&&c.exit(),s(e)}},V=function(e,t){e.notified||(e.notified=!0,_(function(){for(var n=e.reactions,r;r=n.get();)_e(r,e);e.notified=!1,t&&!e.rejection&&ye(e)}))},ve=function(e,t,n){var i,a;oe?(i=ne.createEvent(`Event`),i.promise=t,i.reason=n,i.initEvent(e,!1,!0),r.dispatchEvent(i)):i={promise:t,reason:n},!k&&(a=r[`on`+e])?a(i):e===se&&v(`Unhandled promise rejection`,n)},ye=function(e){a(g,r,function(){var t=e.facade,r=e.value,i=be(e),a;if(i&&(a=y(function(){n?re.emit(`unhandledRejection`,r,t):ve(se,t,r)}),e.rejection=n||be(e)?de:ue,a.error))throw a.value})},be=function(e){return e.rejection!==ue&&!e.parent},xe=function(e){a(g,r,function(){var t=e.facade;n?re.emit(`rejectionHandled`,t):ve(ce,t,e.value)})},Se=function(e,t,n){return function(r){e(t,r,n)}},U=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=B,V(e,!0))},Ce=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw new te(`Promise can't be resolved itself`);var r=ge(t);r?_(function(){var n={done:!1};try{a(r,t,Se(Ce,n,e),Se(U,n,e))}catch(t){U(n,t,e)}}):(e.value=t,e.state=le,V(e,!1))}catch(t){U({done:!1},t,e)}}};if(O&&(I=function(e){p(this,ee),u(e),a(fe,this);var t=N(this);try{e(Se(Ce,t),Se(U,t))}catch(e){U(t,e)}},ee=I.prototype,fe=function(e){P(this,{type:D,done:!1,notified:!1,parent:!1,reactions:new b,rejection:!1,state:z,value:null})},fe.prototype=o(ee,`then`,function(e,t){var r=N(this),i=ie(h(this,I));return r.parent=!0,i.ok=d(e)?e:!0,i.fail=d(t)&&t,i.domain=n?re.domain:void 0,r.state===z?r.reactions.add(i):_(function(){_e(i,r)}),i.promise}),pe=function(){var e=new fe,t=N(e);this.promise=e,this.resolve=Se(Ce,t),this.reject=Se(U,t)},E.f=ie=function(e){return e===I||e===me?new pe(e):ae(e)},!t&&d(w)&&F!==Object.prototype)){he=F.then,M||o(F,`then`,function(e,t){var n=this;return new I(function(e,t){a(he,n,e,t)}).then(e,t)},{unsafe:!0});try{delete F.constructor}catch{}s&&s(F,ee)}e({global:!0,constructor:!0,wrap:!0,forced:O},{Promise:I}),me=i.Promise,c(I,D,!1,!0),l(D)}),Ct=u((e,t)=>{t.exports={}}),wt=u((e,t)=>{var n=B(),r=Ct(),i=n(`iterator`),a=Array.prototype;t.exports=function(e){return e!==void 0&&(r.Array===e||a[i]===e)}}),Tt=u((e,t)=>{var n=Me(),r=re(),i=D(),a=Ct(),o=B()(`iterator`);t.exports=function(e){if(!i(e))return r(e,o)||r(e,`@@iterator`)||a[n(e)]}}),Et=u((e,t)=>{var n=C(),r=L(),i=V(),a=ne(),o=Tt(),s=TypeError;t.exports=function(e,t){var c=arguments.length<2?o(e):t;if(r(c))return i(n(c,e));throw new s(a(e)+` is not iterable`)}}),Dt=u((e,t)=>{var n=C(),r=V(),i=re();t.exports=function(e,t,a){var o,s;r(e);try{if(o=i(e,`return`),!o){if(t===`throw`)throw a;return a}o=n(o,e)}catch(e){s=!0,o=e}if(t===`throw`)throw a;if(s)throw o;return r(o),a}}),Ot=u((e,t)=>{var n=ge(),r=C(),i=V(),a=ne(),o=wt(),s=Ce(),c=N(),l=Et(),u=Tt(),d=Dt(),f=TypeError,p=function(e,t){this.stopped=e,this.result=t},m=p.prototype;t.exports=function(e,t,h){var g=h&&h.that,_=!!(h&&h.AS_ENTRIES),v=!!(h&&h.IS_RECORD),y=!!(h&&h.IS_ITERATOR),b=!!(h&&h.INTERRUPTED),x=n(t,g),S,C,w,T,E,D,O,k=function(e){return S&&d(S,`normal`),new p(!0,e)},A=function(e){return _?(i(e),b?x(e[0],e[1],k):x(e[0],e[1])):b?x(e,k):x(e)};if(v)S=e.iterator;else if(y)S=e;else{if(C=u(e),!C)throw new f(a(e)+` is not iterable`);if(o(C)){for(w=0,T=s(e);T>w;w++)if(E=A(e[w]),E&&c(m,E))return E;return new p(!1)}S=l(e,C)}for(D=v?e.next:S.next;!(O=r(D,S)).done;){try{E=A(O.value)}catch(e){d(S,`throw`,e)}if(typeof E==`object`&&E&&c(m,E))return E}return new p(!1)}}),kt=u((e,t)=>{var n=B()(`iterator`),r=!1;try{i=0,a={next:function(){return{done:!!i++}},return:function(){r=!0}},a[n]=function(){return this},Array.from(a,function(){throw 2})}catch{}var i,a;t.exports=function(e,t){try{if(!t&&!r)return!1}catch{return!1}var i=!1;try{var a={};a[n]=function(){return{next:function(){return{done:i=!0}}}},e(a)}catch{}return i}}),At=u((e,t)=>{var n=yt(),r=kt();t.exports=bt().CONSTRUCTOR||!r(function(e){n.all(e).then(void 0,function(){})})}),jt=u(()=>{var e=H(),t=C(),n=L(),r=xt(),i=mt(),a=Ot();e({target:`Promise`,stat:!0,forced:At()},{all:function(e){var o=this,s=r.f(o),c=s.resolve,l=s.reject,u=i(function(){var r=n(o.resolve),i=[],s=0,u=1;a(e,function(e){var n=s++,a=!1;u++,t(r,o,e).then(function(e){a||(a=!0,i[n]=e,--u||c(i))},l)}),--u||c(i)});return u.error&&l(u.value),s.promise}})}),Mt=u(()=>{var e=H(),t=R(),n=bt().CONSTRUCTOR,r=yt(),i=M(),a=x(),o=Ue(),s=r&&r.prototype;e({target:`Promise`,proto:!0,forced:n,real:!0},{catch:function(e){return this.then(void 0,e)}}),!t&&a(r)&&(c=i(`Promise`).prototype.catch,s.catch!==c&&o(s,`catch`,c,{unsafe:!0}));var c}),Nt=u(()=>{var e=H(),t=C(),n=L(),r=xt(),i=mt(),a=Ot();e({target:`Promise`,stat:!0,forced:At()},{race:function(e){var o=this,s=r.f(o),c=s.reject,l=i(function(){var r=n(o.resolve);a(e,function(e){t(r,o,e).then(s.resolve,c)})});return l.error&&c(l.value),s.promise}})}),Pt=u(()=>{var e=H(),t=xt(),n=bt().CONSTRUCTOR;e({target:`Promise`,stat:!0,forced:n},{reject:function(e){var n=t.f(this),r=n.reject;return r(e),n.promise}})}),Ft=u((e,t)=>{var n=V(),r=A(),i=xt();t.exports=function(e,t){if(n(e),r(t)&&t.constructor===e)return t;var a=i.f(e),o=a.resolve;return o(t),a.promise}}),It=u(()=>{var e=H(),t=M(),n=R(),r=yt(),i=bt().CONSTRUCTOR,a=Ft(),o=t(`Promise`),s=n&&!i;e({target:`Promise`,stat:!0,forced:n||i},{resolve:function(e){return a(s&&this===o?r:this,e)}})}),Lt=u(()=>{St(),jt(),Mt(),Nt(),Pt(),It()}),Rt=u(()=>{var e=H(),t=R(),n=yt(),r=h(),i=M(),a=x(),o=nt(),s=Ft(),c=Ue(),l=n&&n.prototype;e({target:`Promise`,proto:!0,real:!0,forced:!!n&&r(function(){l.finally.call({then:function(){}},function(){})})},{finally:function(e){var t=o(this,i(`Promise`)),n=a(e);return this.then(n?function(n){return s(t,e()).then(function(){return n})}:e,n?function(n){return s(t,e()).then(function(){throw n})}:e)}}),!t&&a(n)&&(u=i(`Promise`).prototype.finally,l.finally!==u&&c(l,`finally`,u,{unsafe:!0}));var u}),zt=u((e,t)=>{Lt(),Rt(),t.exports=De()(`Promise`,`finally`)}),Bt=u((e,t)=>{t.exports=zt()}),Vt=u((e,t)=>{t.exports=Bt()}),Ht=u((e,t)=>{t.exports=!h()(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})}),Ut=u((e,t)=>{var n=z(),r=x(),i=ce(),a=gt(),o=Ht(),s=a(`IE_PROTO`),c=Object,l=c.prototype;t.exports=o?c.getPrototypeOf:function(e){var t=i(e);if(n(t,s))return t[s];var a=t.constructor;return r(a)&&t instanceof a?a.prototype:t instanceof c?l:null}}),Wt=u((e,t)=>{var n=v(),r=z(),i=k(),a=we().indexOf,o=_t(),s=n([].push);t.exports=function(e,t){var n=i(e),c=0,l=[],u;for(u in n)!r(o,u)&&r(n,u)&&s(l,u);for(;t.length>c;)r(n,u=t[c++])&&(~a(l,u)||s(l,u));return l}}),Gt=u((e,t)=>{t.exports=[`constructor`,`hasOwnProperty`,`isPrototypeOf`,`propertyIsEnumerable`,`toLocaleString`,`toString`,`valueOf`]}),Kt=u((e,t)=>{var n=Wt(),r=Gt();t.exports=Object.keys||function(e){return n(e,r)}}),qt=u((e,t)=>{var n=S(),r=h(),i=v(),a=Ut(),o=Kt(),s=k(),c=w().f,l=i(c),u=i([].push),d=n&&r(function(){var e=Object.create(null);return e[2]=2,!l(e,2)}),f=function(e){return function(t){for(var r=s(t),i=o(r),c=d&&a(r)===null,f=i.length,p=0,m=[],h;f>p;)h=i[p++],(!n||(c?h in r:l(r,h)))&&u(m,e?[h,r[h]]:r[h]);return m}};t.exports={entries:f(!0),values:f(!1)}}),Jt=u(()=>{var e=H(),t=qt().entries;e({target:`Object`,stat:!0},{entries:function(e){return t(e)}})}),Yt=u((e,t)=>{Jt(),t.exports=j().Object.entries}),Xt=u((e,t)=>{t.exports=Yt()}),Zt=u((e,t)=>{t.exports=Xt()}),Qt=u((e,t)=>{var n=S(),r=z(),i=Function.prototype,a=n&&Object.getOwnPropertyDescriptor,o=r(i,`name`);t.exports={EXISTS:o,PROPER:o&&function(){}.name===`something`,CONFIGURABLE:o&&(!n||n&&a(i,`name`).configurable)}}),$t=u(e=>{var t=S(),n=_e(),r=ve(),i=V(),a=k(),o=Kt();e.f=t&&!n?Object.defineProperties:function(e,t){i(e);for(var n=a(t),s=o(t),c=s.length,l=0,u;c>l;)r.f(e,u=s[l++],n[u]);return e}}),en=u((e,t)=>{var n=V(),r=$t(),i=Gt(),a=_t(),o=rt(),s=fe(),c=gt(),l=`>`,u=`<`,d=`prototype`,f=`script`,p=c(`IE_PROTO`),m=function(){},h=function(e){return u+f+l+e+u+`/`+f+l},g=function(e){e.write(h(``)),e.close();var t=e.parentWindow.Object;return e=null,t},_=function(){var e=s(`iframe`),t=`java`+f+`:`,n;return e.style.display=`none`,o.appendChild(e),e.src=String(t),n=e.contentWindow.document,n.open(),n.write(h(`document.F=Object`)),n.close(),n.F},v,y=function(){try{v=new ActiveXObject(`htmlfile`)}catch{}y=typeof document<`u`?document.domain&&v?g(v):_():g(v);for(var e=i.length;e--;)delete y[d][i[e]];return y()};a[p]=!0,t.exports=Object.create||function(e,t){var i;return e===null?i=y():(m[d]=n(e),i=new m,m[d]=null,i[p]=e),t===void 0?i:r.f(i,t)}}),tn=u((e,t)=>{var n=h(),r=x(),i=A(),a=en(),o=Ut(),s=Ue(),c=B(),l=R(),u=c(`iterator`),d=!1,f,p,m;[].keys&&(m=[].keys(),`next`in m?(p=o(o(m)),p!==Object.prototype&&(f=p)):d=!0),!i(f)||n(function(){var e={};return f[u].call(e)!==e})?f={}:l&&(f=a(f)),r(f[u])||s(f,u,function(){return this}),t.exports={IteratorPrototype:f,BUGGY_SAFARI_ITERATORS:d}}),nn=u((e,t)=>{var n=tn().IteratorPrototype,r=en(),i=T(),a=Ye(),o=Ct(),s=function(){return this};t.exports=function(e,t,c,l){var u=t+` Iterator`;return e.prototype=r(n,{next:i(+!l,c)}),a(e,u,!1,!0),o[u]=s,e}}),rn=u((e,t)=>{var n=H(),r=C(),i=R(),a=Qt(),o=x(),s=nn(),c=Ut(),l=qe(),u=Ye(),d=ye(),f=Ue(),p=B(),m=Ct(),h=tn(),g=a.PROPER,_=a.CONFIGURABLE,v=h.IteratorPrototype,y=h.BUGGY_SAFARI_ITERATORS,b=p(`iterator`),S=`keys`,w=`values`,T=`entries`,E=function(){return this};t.exports=function(e,t,a,p,h,x,C){s(a,t,p);var D=function(e){if(e===h&&M)return M;if(!y&&e&&e in A)return A[e];switch(e){case S:return function(){return new a(this,e)};case w:return function(){return new a(this,e)};case T:return function(){return new a(this,e)}}return function(){return new a(this)}},O=t+` Iterator`,k=!1,A=e.prototype,j=A[b]||A[`@@iterator`]||h&&A[h],M=!y&&j||D(h),N=t===`Array`&&A.entries||j,P,F,I;if(N&&(P=c(N.call(new e)),P!==Object.prototype&&P.next&&(!i&&c(P)!==v&&(l?l(P,v):o(P[b])||f(P,b,E)),u(P,O,!0,!0),i&&(m[O]=E))),g&&h===w&&j&&j.name!==w&&(!i&&_?d(A,`name`,w):(k=!0,M=function(){return r(j,this)})),h)if(F={values:D(w),keys:x?M:D(S),entries:D(T)},C)for(I in F)(y||k||!(I in A))&&f(A,I,F[I]);else n({target:t,proto:!0,forced:y||k},F);return(!i||C)&&A[b]!==M&&f(A,b,M,{name:h}),m[t]=M,F}}),an=u((e,t)=>{t.exports=function(e,t){return{value:e,done:t}}}),on=u((e,t)=>{var n=k(),r=Te(),i=Ct(),a=vt(),o=ve().f,s=rn(),c=an(),l=R(),u=S(),d=`Array Iterator`,f=a.set,p=a.getterFor(d);t.exports=s(Array,`Array`,function(e,t){f(this,{type:d,target:n(e),index:0,kind:t})},function(){var e=p(this),t=e.target,n=e.index++;if(!t||n>=t.length)return e.target=null,c(void 0,!0);switch(e.kind){case`keys`:return c(n,!1);case`values`:return c(t[n],!1)}return c([n,t[n]],!1)},`values`);var m=i.Arguments=i.Array;if(r(`keys`),r(`values`),r(`entries`),!l&&u&&m.name!==`values`)try{o(m,`name`,{value:`values`})}catch{}}),sn=u((e,t)=>{var n=S(),r=ve(),i=T();t.exports=function(e,t,a){n?r.f(e,t,i(0,a)):e[t]=a}}),cn=u(()=>{var e=H(),t=Ot(),n=sn();e({target:`Object`,stat:!0},{fromEntries:function(e){var r={};return t(e,function(e,t){n(r,e,t)},{AS_ENTRIES:!0}),r}})}),ln=u((e,t)=>{on(),cn(),t.exports=j().Object.fromEntries}),un=u((e,t)=>{t.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}}),dn=u(()=>{on();var e=un(),t=m(),n=Ye(),r=Ct();for(i in e)n(t[i],i),r[i]=r.Array;var i}),fn=u((e,t)=>{var n=ln();dn(),t.exports=n}),pn=u((e,t)=>{t.exports=fn()}),mn=u(()=>{var e=H(),t=qt().values;e({target:`Object`,stat:!0},{values:function(e){return t(e)}})}),hn=u((e,t)=>{mn(),t.exports=j().Object.values}),gn=u((e,t)=>{t.exports=hn()}),_n=u((e,t)=>{t.exports=gn()}),vn=l(Ae(),1),yn=(e,...t)=>typeof e==`string`?e.includes(...t):vn.default(e,...t),bn=(e,t,n)=>{if(typeof e.canParse==`function`)return e.canParse(t,n);try{return new e(t,n),!0}catch{return!1}},xn;(e=>{e.PROD=`prod`,e.VK_ALIAS=`vk_alias`,e.VIDEOTEST=`videotest`,e.TEST=`test`,e.OKCDN=`okcdn`,e.AUTO=`auto`})(xn||={});var Sn;(e=>{e.Q144P=`mobile`,e.Q240P=`lowest`,e.Q360P=`low`,e.Q480P=`medium`,e.Q720P=`high`,e.Q1080P=`fullhd`,e.Q1440P=`quadhd`,e.Q2160P=`ultrahd`,e.UNKNOWN=`unknown`})(Sn||={});var Cn;(e=>{e.MP4=`mp4`,e.DASH=`dash`,e.DASH_SEP=`dash_sep`,e.ONDEMAND_DASH=`ondemand_dash`,e.HLS=`hls`,e.HLS_FMP4=`hls_fmp4`,e.ONDEMAND_HLS=`ondemand_hls`,e.WEBM=`webm`,e.AV1=`av1`,e.ONDEMAND_DASH_LIVE=`ondemand_dash_live`,e.ONDEMAND_HLS_LIVE=`ondemand_hls_live`,e.WEBRTC=`webrtc`,e.UNKNOWN=`unknown`,e.RTMP=`rtmp`})(Cn||={});var wn;(e=>{e.HTTP1=`http1`,e.HTTP2=`http2`,e.HTTP3=`http3`})(wn||={});var Tn;(e=>{e.SLIDER=`slider`,e.RICH=`rich`,e.DOUBLE_TAP=`double_tap`,e.TIME_CODE=`time_code`,e.EPISODE=`episode`,e.REWIND=`rewind`,e.LIVE=`live`,e.UNKNOWN=`unknown`})(Tn||={});var En;(e=>{e.GRAPH_SHOW=`iGraphShow`,e.GRAPH_HIDE=`iGraphHide`,e.NEXT_AREA=`iNextChapterArea`,e.NEXT_BUTTON=`iNextChapterBtn`,e.WATCH_AGAIN=`iWatchAgainBtn`})(En||={});var Dn={action_play:`ap`,action_play_interactive:`api`,first_bytes:`fb`,player_ready:`pr`,first_frame:`ff`,seek:`sk`,watch_coverage_record:`wr`,watch_coverage_live:`wl`,empty_buffer:`eb`,action_stop:`as`,close_at_empty_buffer:`cb`,content_error:`er`,player_interface_click:`pc`,next_movie:`nm`,track_switch:`ts`,failover:`fo`,quality:`qt`},On={vsid:`si`,isid:`is`,vid:`vi`,place:`pl`,quality:`qt`,cdn_host:`ch`,stat_type:`st`,param:`pm`,vk_app_id:`va`,track_code:`tc`,connection_type:`cnt`,connection_reused:`cr`,cached_data:`cd`,live:`lv`,muted:`mu`,mode:`mo`,subtitles:`sb`,failover:`fo`,download_speed:`ds`,manual_quality:`mq`,ref_domain:`rd`,direct_url:`du`},kn={unknown:`un`,mobile:`m`,lowest:`ls`,low:`l`,medium:`md`,high:`h`,fullhd:`f`,quadhd:`q`,ultrahd:`u`},An={pip:`pi`,fullscreen:`fs`,external:`ex`,prefetch:`pr`,airplay:`ap`,chromecast:`cc`,invisible:`iv`,minimal:`minimal`};import{fillWithDefault as jn}from"@vkontakte/videoplayer-shared/es2018";var Mn=`CIOPGQJGDIHBABABA`,Nn={prod:`https://api.ok.ru`,vk_alias:`https://api.mycdn.me`,videotest:`https://videotestapi.ok.ru/api`,test:`https://apitest.ok.ru`,okcdn:`https://api.okcdn.ru`,auto:``},Pn={apiEnv:`vk_alias`,apiKey:Mn,apiBaseUrl:null,requestRetryCount:1,useVsid64:!1,firstFlushTime:5e3,flushDebounceTime:1e4,flushMaxWait:6e4,storageExpiration:2160*60*1e3,watchCoverageInterval:15e3,disabledOperations:[`quality`],disabledCustomFields:[],shorten:!0,maxLoops:100,embedUrlParams:[],useBeacon:!0,synchronizeTime:!0,debugLog:!1,clearStorageAtUnload:!0,useVKComIsMobileLogic:!1,backoff:{start:1e3,factor:1.5,max:300*1e3,random:.1},useKeepalive:!1,watchCoverageTimeoutFix:!1},Fn=e=>jn(e,Pn);function In(){let e=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`.split(``),t=Array(36),n=0,r,i;for(i=0;i<36;i++)i===8||i===13||i===18||i===23?t[i]=`-`:i===14?t[i]=`4`:(n<=2&&(n=33554432+Math.random()*16777216|0),r=n&15,n>>=4,t[i]=e[i===19?r&3|8:r]);return t.join(``)}import{assertNonNullable as Ln,combine as Rn,fromEvent as zn,isNonNullable as Bn,isNullable as Vn,merge as Hn,now as W,observableFrom as Un,once as Wn,safeStorage as Gn,Subject as Kn,Subscription as qn,ValueSubject as Jn}from"@vkontakte/videoplayer-shared/es2018";import{Logger as Yn,detectEmbed as Xn}from"@vkontakte/videoplayer-shared/es2018";var Zn=l(Be(),1),Qn=()=>Zn.default(Math.floor(Math.random()*2**32).toString(36),13,`0`),$n=()=>Zn.default(Math.floor(Math.random()*2**64).toString(36),13,`0`);class er{static getVSID(){return er.vsid}static generateVSID(e){return er.vsid=e?$n():Qn(),er.vsid}}e(er,`vsid`,void 0);var tr=l(Vt(),1),nr=l(Zt(),1),rr=l(pn(),1),ir=e=>{let{operation:t,custom:n}=e,r=rr.default(nr.default(n).map(([e,t])=>{let n=On[e]??e,r=t;return t&&(e===`mode`?r=An[t]??t:e===`quality`&&(r=kn[t]??t)),[n,r]}));return{...e,operation:Dn[t]??t,custom:r}},ar=`1.0.100-dev.319d6ebf.0`;import{ValueSubject as or,getExponentialDelay as sr,ErrorCategory as cr}from"@vkontakte/videoplayer-shared/es2018";var lr=/Mobile|mini|Fennec|Android|iP(ad|od|hone)|opera (mini|mobi)/i;class ur{constructor(t){e(this,`params`,void 0),e(this,`authToken`,void 0),e(this,`sessionKey`,void 0),e(this,`authorizePromise`,void 0),e(this,`refreshAuthTokenPromise`,void 0),e(this,`consequentAuthErrors`,0),e(this,`authorized$`,new or(!1)),e(this,`backoffTimeoutId`,void 0),this.params=t}async authorize(e){return this.authToken=e??await this.refreshAuthToken(),this._authorizeWithBackoff()}logBeacon(e){let t=this.createLogParams(e),n=this.sessionKey;n&&(this.params.apiTransport.sendBeacon(`log.externalLog`,t,n)||this.logRequest(e).catch(()=>{}))}async logRequest(e){let t=`log.externalLog`,n=this.createLogParams(e),r=this.sessionKey??await this._authorizeWithBackoff();if(!r)return;let i=async(e,a=this.params.config.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(t,n,r)}catch(n){if(!n||!(`error_code`in n)){this.params.error$.next({id:`logRequestUnknown`,category:cr.NETWORK,message:`Unknown ${t} error`,thrown:n});return}let r=n?.error_code;switch(r){case 102:case 103:case 104:return this.authorized$.next(!1),this.sessionKey=await this._authorizeWithBackoff(),a>0?i(e,a-1):void 0;case 401:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorizeWithBackoff(),a>0?i(e,a-1):void 0;default:this.params.error$.next({id:`LogRequest#${r}`,category:cr.EXTERNAL_API,message:`${t} error`,data:n});return}}};return i(e)}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}async refreshAuthToken(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||=tr.default(this.params.refreshAuthToken(),()=>{this.refreshAuthTokenPromise=void 0}),this.refreshAuthTokenPromise}createLogParams(e){let t=`WEB`,n=!1,r=`@vkontakte/videoplayer-statistics:${ar}`;if(this.params.config.useVKComIsMobileLogic){let{appVersion:e}=window.navigator;n=lr.test(e)}else this.params.mobile&&(n=!0);return n&&(t=`M_WEB`),this.params.vktvVersion&&(t=`SMART_TV`,r=this.params.vktvVersion),{collector:`ok.mobile.apps.video`,data:JSON.stringify({application:r,platform:t,items:this.params.config.shorten?e.map(ir):e})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();let e=sr(this.consequentAuthErrors,this.params.config.backoff);return new Promise(t=>{this.backoffTimeoutId||=window.setTimeout(()=>{tr.default(this._authorize().then(t).catch(e=>this.params.error$.next({id:`AuthorizeBackoff`,category:cr.NETWORK,message:`Otherwise unhandled error in authorization`,thrown:e})),()=>this.backoffTimeoutId=0)},e)})}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);let e={session_data:{version:2,device_id:this.params.deviceId,client_version:ar.split(`-`)[0],client_type:`SDK_JS`}};return this.authToken!==void 0&&(e.session_data.auth_token=this.authToken,e.session_data.version=3),this.authorizePromise=tr.default(this.params.apiTransport.sendRequest(`auth.anonymLogin`,e).then(e=>((!e||!e.session_key)&&this.params.error$.next({id:`AuthorizeFailed`,category:cr.EXTERNAL_API,message:`No session key`,data:e}),this.sessionKey=e?.session_key??void 0,this.sessionKey)).catch(async e=>{this.sessionKey=void 0;let t=e?.error_code;switch(t){case 401:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}t?this.params.error$.next({id:`Authorize#${t}`,category:cr.EXTERNAL_API,message:`authorize error`,data:e}):this.params.error$.next({id:`AuthorizeUnknown`,category:cr.NETWORK,message:`authorize error`,thrown:e})}),()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise}}var{NativeAbortSignal:dr,NativeAbortController:fr}=function(e){return{NativeAbortSignal:e.AbortSignal,NativeAbortController:e.AbortController}}(typeof self<`u`?self:global);function pr(e){let t;try{t=new Event(`abort`)}catch{typeof document<`u`?document.createEvent?(t=document.createEvent(`Event`),t.initEvent(`abort`,!1,!1)):(t=document.createEventObject(),t.type=`abort`):t={type:`abort`,bubbles:!1,cancelable:!1}}return t.reason=e,t}function mr(e){if(e===void 0)if(typeof document>`u`)e=Error(`This operation was aborted`),e.name=`AbortError`;else try{e=new DOMException(`signal is aborted without reason`),Object.defineProperty(e,`name`,{value:`AbortError`})}catch{e=Error(`This operation was aborted`),e.name=`AbortError`}return e}class hr{constructor(){Object.defineProperty(this,`listeners`,{value:{},writable:!0,configurable:!0})}addEventListener(e,t,n){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:n})}removeEventListener(e,t){if(!(e in this.listeners))return;let n=this.listeners[e];for(let e=0,r=n.length;e<r;e++)if(n[e].callback===t){n.splice(e,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let t=this.listeners[e.type].slice();for(let n=0,r=t.length;n<r;n++){let r=t[n];try{r.callback.call(this,e)}catch(e){Promise.resolve().then(()=>{throw e})}r.options&&r.options.once&&this.removeEventListener(e.type,r.callback)}return!e.defaultPrevented}}class gr extends hr{constructor(){super(),this.listeners||hr.call(this),Object.defineProperty(this,`aborted`,{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,`onabort`,{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,`reason`,{value:void 0,writable:!0,configurable:!0})}toString(){return`[object AbortSignal]`}dispatchEvent(e){e.type===`abort`&&(this.aborted=!0,typeof this.onabort==`function`&&this.onabort.call(this,e)),super.dispatchEvent(e)}throwIfAborted(){let{aborted:e,reason:t=`Aborted`}=this;if(e)throw t}static timeout(e){let t=new _r;return setTimeout(()=>t.abort(new DOMException(`This signal is timeout in ${e}ms`,`TimeoutError`)),e),t.signal}static any(e){let t=new _r;function n(){t.abort(this.reason),r()}function r(){for(let t of e)t.removeEventListener(`abort`,n)}for(let r of e)if(r.aborted){t.abort(r.reason);break}else r.addEventListener(`abort`,n);return t.signal}}class _r{constructor(){Object.defineProperty(this,`signal`,{value:new gr,writable:!0,configurable:!0})}abort(e){let t=mr(e),n=pr(t);this.signal.reason=t,this.signal.dispatchEvent(n)}toString(){return`[object AbortController]`}}typeof Symbol<`u`&&Symbol.toStringTag&&(_r.prototype[Symbol.toStringTag]=`AbortController`,gr.prototype[Symbol.toStringTag]=`AbortSignal`);function vr(e){return e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log(`__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill`),!0):typeof e.Request==`function`&&!e.Request.prototype.hasOwnProperty(`signal`)||!e.AbortController}function yr(e){typeof e==`function`&&(e={fetch:e});let{fetch:t,Request:n=t.Request,AbortController:r,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i=!1}=e;if(!vr({fetch:t,Request:n,AbortController:r,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i}))return{fetch:t,Request:a};let a=n;(a&&!a.prototype.hasOwnProperty(`signal`)||i)&&(a=function(e,t){let r;t&&t.signal&&(r=t.signal,delete t.signal);let i=new n(e,t);return r&&Object.defineProperty(i,`signal`,{writable:!1,enumerable:!1,configurable:!0,value:r}),i},a.prototype=n.prototype);let o=t;return{fetch:(e,t)=>{let n=a&&a.prototype.isPrototypeOf(e)?e.signal:t?t.signal:void 0;if(n){let r;try{r=new DOMException(`Aborted`,`AbortError`)}catch{r=Error(`Aborted`),r.name=`AbortError`}if(n.aborted)return Promise.reject(r);let i=new Promise((e,t)=>{n.addEventListener(`abort`,()=>t(r),{once:!0})});return t&&t.signal&&delete t.signal,Promise.race([i,o(e,t)])}return o(e,t)},Request:a}}var G=typeof globalThis==`object`&&globalThis||typeof window==`object`&&window,br=`fetch`in G&&vr({fetch:G.fetch,Request:G.Request,AbortController:G.AbortController}),xr=br?yr({fetch:G.fetch,Request:G.Request,AbortController:G.AbortController}):void 0,Sr=br?xr.fetch:G.fetch;br?xr.Request:G.Request,br||G.AbortController,br||G.AbortSignal;var Cr=l(Ae(),1),wr=l(Zt(),1);import{ErrorCategory as Tr,now as Er}from"@vkontakte/videoplayer-shared/es2018";class Dr{constructor(t){e(this,`apiKey`,void 0),e(this,`apiBaseUrl`,void 0),e(this,`apiEnv`,void 0),e(this,`timeSynchronisation`,void 0),e(this,`isApiBaseUrlFetched`,void 0),e(this,`params`,void 0),this.params=t,this.apiKey=t.config.apiKey,this.apiEnv=t.config.apiEnv,this.apiBaseUrl=t.config.apiBaseUrl??Nn[this.apiEnv],this.timeSynchronisation=t.timeSynchronisation,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){if(this.apiEnv!==`auto`||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{var e;let t=await(await Sr(atob(`aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ=`),{method:`GET`,mode:`cors`,cache:`no-cache`})).json(),n=t==null||(e=t.Answer[0])==null?void 0:e.data;if(!n)throw Error(`Wrong DNS response`);return n}catch(e){return this.params.error$.next({id:`OneStat:ApiTransport:resolveApiBaseUrl`,category:Tr.NETWORK,message:`Unhandled resolve api base url error`,thrown:e}),Nn.vk_alias}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(e,t,n){if(!window.Blob||!window.navigator.sendBeacon)return!1;let r=this._prepareQueryParams({method:e,queryParams:t,sessionKey:n}),i=new window.Blob([r.toString()],{type:`application/x-www-form-urlencoded`});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,i)}catch(n){this.params.error$.next({id:`OneStat:ApiTransport:sendBeacon`,category:Tr.NETWORK,message:`Unhandled beacon error`,thrown:n,data:{method:e,params:t}})}return!1}async sendRequest(e,t,n){let r=Er(),i=i=>{if(i instanceof TypeError&&Cr.default([`Failed to fetch`,`NetworkError when attempting to fetch resource.`],i.message)){this.params.error$.next({id:`Network`,category:Tr.NETWORK,message:`Request failed`,thrown:i});return}this.params.error$.next({id:`OneStat:ApiTransport:sendRequest`,category:Tr.NETWORK,message:`Unhandled request error`,thrown:i,data:{method:e,params:t,sessionKey:n,time:Er()-r}})};this.apiBaseUrl=await this.resolveApiBaseUrl();let a={method:`post`,headers:{"Content-type":`application/x-www-form-urlencoded`},body:this._prepareQueryParams({method:e,queryParams:t,sessionKey:n})};return this.params.config.useKeepalive&&(a.keepalive=!0),Sr(`${this.apiBaseUrl}/fb.do`,a).then(e=>{let t=Number(e.headers.get(`content-length`))===0,n=new Date(e.headers.get(`date`)??``).getTime(),a=Er()-r;if(isFinite(n)&&this.timeSynchronisation?.addServerTime(n,a),!t)return e.json().then(e=>Object.prototype.hasOwnProperty.call(e,`error_msg`)?Promise.reject(e):e,i)},i)}_prepareQueryParams(e){let t=new URLSearchParams({format:`JSON`,method:e.method,application_key:this.apiKey});return e.sessionKey!==void 0&&t.append(`session_key`,e.sessionKey),wr.default(e.queryParams).forEach(([e,n])=>t.append(e,typeof n==`string`?n:JSON.stringify(n))),t}}var Or=l(Ae(),1),kr=l(Zt(),1);import{ErrorCategory as Ar,now as jr,safeStorage as Mr,debounceFn as Nr}from"@vkontakte/videoplayer-shared/es2018";var Pr=`onestat_events`,Fr=e=>t=>t.timestamp+e>=jr();class Ir{constructor(t){e(this,`params`,void 0),e(this,`api`,void 0),e(this,`error$`,void 0),e(this,`subscription`,void 0),e(this,`userSalt`,void 0),e(this,`unsaltedStorage`,[]),e(this,`lastVsid`,void 0),e(this,`isPaused`,!1),e(this,`firstFlush`,void 0),e(this,`debouncedFlush`,void 0),e(this,`loggerDebugLog`,void 0),e(this,`isUrgent`,e=>{let{operation:t}=e;return Or.default([`action_play`,`watch_coverage_record`,`watch_coverage_live`],t)}),this.params=t,this.api=t.api,this.error$=t.error$,this.userSalt=t.userSalt,this.loggerDebugLog=t.debugLogger.createComponentLog(`stat logger`),this.firstFlush=Nr(()=>this.safeFlush(),this.params.config.firstFlushTime,{maxWait:this.params.config.firstFlushTime});let n=Mr.isPersistent()?this.params.config.flushMaxWait:0;this.debouncedFlush=Nr(()=>this.safeFlush(),this.params.config.flushDebounceTime,{maxWait:n}),this.subscription=this.api.authorized$.subscribe(e=>{e&&this.debouncedFlush()}),this.housekeepStorage()}safeFlush(){try{this.flush()}catch(e){this.error$.next({id:`LoggerError`,category:Ar.WTF,message:e?String(e):`Unknown logger error`,thrown:e})}}readFromStorage(){let e=Mr.get(Pr);try{return e?JSON.parse(e):{}}catch{}return{}}addToStorage(e){if(!this.userSalt){this.unsaltedStorage.push(e);return}let t=this.readFromStorage(),n=(t[this.userSalt]??[]).filter(Fr(this.params.config.storageExpiration));Mr.set(Pr,JSON.stringify({...t,[this.userSalt]:[...n,e]}))}getFromStorage(){return this.userSalt?(this.readFromStorage()[this.userSalt]??[]).filter(Fr(this.params.config.storageExpiration)):this.unsaltedStorage}markStorageSent(){if(!this.userSalt){this.unsaltedStorage=[];return}let e=this.readFromStorage();delete e[this.userSalt],Mr.set(Pr,JSON.stringify(e))}housekeepStorage(){let e=this.readFromStorage();for(let[t,n]of kr.default(e)){let r=n.filter(Fr(this.params.config.storageExpiration));r.length?e[t]=r:delete e[t],this.loggerDebugLog({message:`${n.length} retrieved from storage, ${r.length} of them actual`})}Mr.set(Pr,JSON.stringify(e))}log(e){this.addToStorage(e),!this.isPaused&&(this.isUrgent(e)?this.flush():this.lastVsid===e.custom.vsid?this.debouncedFlush():this.firstFlush(),this.lastVsid=e.custom.vsid)}flush({wantBeacon:e,clearStorage:t}={wantBeacon:!1,clearStorage:!0}){let n=this.getFromStorage();n.length!==0&&(this.api.authorized$.getValue()?(e&&this.params.config.useBeacon?(this.loggerDebugLog({message:`Flushing ${n.length} events through beacon`}),this.api.logBeacon(n)):(this.loggerDebugLog({message:`Flushing ${n.length} events`}),this.api.logRequest(n)),t&&this.markStorageSent()):this.api.authorize(),this.firstFlush.cancel(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe(),this.firstFlush.cancel(),this.debouncedFlush.cancel()}}import{HttpConnectionType as Lr,Surface as Rr,VideoFormat as K,VideoQuality as q}from"@vkontakte/videoplayer-core/es2018";import{assertNever as zr}from"@vkontakte/videoplayer-shared/es2018";var Br=e=>e&&{[q.INVARIANT]:`unknown`,[q.Q_144P]:`mobile`,[q.Q_240P]:`lowest`,[q.Q_360P]:`low`,[q.Q_480P]:`medium`,[q.Q_576P]:`unknown`,[q.Q_720P]:`high`,[q.Q_1080P]:`fullhd`,[q.Q_1440P]:`quadhd`,[q.Q_2160P]:`ultrahd`,[q.Q_4320P]:`unknown`}[e],Vr=e=>e&&{[Lr.HTTP1]:`http1`,[Lr.HTTP2]:`http2`,[Lr.QUIC]:`http3`}[e],Hr=e=>{if(e!==void 0)switch(e){case K.MPEG:return`mp4`;case K.DASH:case K.DASH_LIVE:case K.DASH_STREAMS:return`dash`;case K.DASH_SEP:return`dash_sep`;case K.DASH_ONDEMAND:return`ondemand_dash`;case K.DASH_WEBM:case K.DASH_LIVE_WEBM:return`webm`;case K.DASH_WEBM_AV1:return`av1`;case K.DASH_LIVE_CMAF:return`ondemand_dash_live`;case K.HLS:case K.HLS_LIVE:return`hls`;case K.HLS_FMP4:return`hls_fmp4`;case K.HLS_ONDEMAND:return`ondemand_hls`;case K.HLS_LIVE_CMAF:return`ondemand_hls_live`;case K.WEB_RTC_LIVE:return`webrtc`;default:return zr(e)}},Ur=(e,t)=>{if(t)return`minimal`;switch(e){case void 0:case Rr.NONE:case Rr.INLINE:return;case Rr.FULLSCREEN:return`fullscreen`;case Rr.SECOND_SCREEN:return`chromecast`;case Rr.PIP:return`pip`;case Rr.INVISIBLE:return`invisible`;default:return zr(e)}},Wr=e=>{switch(e){case`slow-2g`:return`poor`;case`2g`:return`poor`;case`3g`:return`good`;case`4g`:return`excellent`}};class Gr{constructor(t){e(this,`offset`,void 0),this.offset=t}getOffset(){return this.offset??0}setOffset(e){this.offset=e}now(){return Date.now()+(this.offset??0)}date(e=new Date){return e.setTime(e.getTime()+(this.offset??0)),e}addServerTime(e,t){let n=e-Date.now()-t/2;if(Math.abs(n)<1e3){this.offset=0;return}if(this.offset===void 0)this.offset=Math.round(n);else{let e=.2;this.offset=Math.round(e*n+(1-e)*this.offset)}}}import{PlaybackState as Kr}from"@vkontakte/videoplayer-core/es2018";import{filter as qr,filterChanged as Jr,fromEvent as Yr,isNullable as Xr,map as Zr,merge as Qr,Observable as $r,Subject as ei,Subscription as ti,ValueSubject as ni}from"@vkontakte/videoplayer-shared/es2018";var ri=(e,t)=>new $r(n=>{let r=new ti,i=Qr(Yr(window,`beforeunload`),e.events.willDestruct$),a=new ni(void 0),o;r.add(e.info.isLive$.pipe(Jr()).subscribe(t=>{o&&(o.unsubscribe(),a.next(void 0)),o=t?e.info.liveTime$.pipe(Zr(e=>e&&e/1e3)).subscribe(a):e.info.position$.subscribe(a),r.add(o)}));let{playing$:s,paused$:c}=e.events,l=e.events.willSeek$.pipe(qr(()=>e.info.playbackState$.getValue()===Kr.PLAYING)),u=e.events.seeked$.pipe(qr(()=>e.info.playbackState$.getValue()===Kr.PLAYING)),d=!1,f=new ei;r.add(l.subscribe(()=>{d||f.next(),d=!0})),r.add(u.subscribe(()=>d=!1));let p=new ei,m=new ei,h=Qr(s,u,p),g=Qr(c,f,i,e.events.looped$,m),_,v=()=>_=a.getValue(),y=()=>{let e=a.getValue();Xr(_)||_===e||Xr(e)||(n.next({from:_,to:e}),_=void 0)},b=()=>{m.next(),p.next()};if(r.add(h.subscribe(v)),r.add(g.subscribe(y)),t.forceInterval&&isFinite(t.forceInterval))if(t.watchCoverageTimeoutFix){let e,n=()=>{e!==void 0&&(window.clearTimeout(e),e=void 0)};r.add(h.subscribe(()=>{n(),e=window.setTimeout(b,t.forceInterval)})),r.add(g.subscribe(()=>n())),r.add(()=>n())}else{let e=0;r.add(h.subscribe(()=>e=window.setTimeout(b,t.forceInterval))),r.add(g.subscribe(()=>window.clearTimeout(e)))}return r});import{Surface as J}from"@vkontakte/videoplayer-core/es2018";import{debounce as ii,filterChanged as ai,Subject as oi}from"@vkontakte/videoplayer-shared/es2018";var si=(e,t,n)=>{let r=new oi,i=r.pipe(ii(0),ai()),a=!1,o=!1,s=!1;return t(e.inPiP$,e=>{a=e,r.next(e?J.PIP:o?J.FULLSCREEN:s?J.INLINE:void 0)}),t(e.inFullscreen$,e=>{o=e,r.next(e?J.FULLSCREEN:a?J.PIP:s?J.INLINE:void 0)}),n&&t(n.info.surface$,e=>{switch(e){case J.SECOND_SCREEN:case J.NONE:case J.INLINE:!o&&!a&&(e===J.INLINE&&(s=!0),r.next(e));break}}),{surface$:i}},ci=`_one-stat_deviceId`,li=()=>{let e=new qn;return{subscription:e,subscribe:(t,n)=>{t&&e.add(t.subscribe(n))}}};class ui{get vsid$(){return new Jn(er.getVSID())}constructor(t,n){e(this,`api`,void 0),e(this,`logger`,void 0),e(this,`config`,void 0),e(this,`subscription`,new qn),e(this,`beforeunloadSubscription`,void 0),e(this,`timeSynchronisation`,void 0),e(this,`debugLogger`,new Yn),e(this,`oneStatDebugLog`,this.debugLogger.createComponentLog(`onestat`)),e(this,`loopCounter`,0),e(this,`disabled`,!1),e(this,`experimental`,void 0),e(this,`isid$`,new Jn(void 0)),e(this,`zenUid$`,new Jn(void 0)),e(this,`statContext`,void 0),e(this,`isEmbed`,void 0),e(this,`embedParent`,void 0),e(this,`uiEvents`,void 0),e(this,`player`,void 0),e(this,`seekAction$`,new Jn(`unknown`)),e(this,`deviceId`,void 0),this.statContext=t,this.config=Fn(n.config??{}),Bn(n.apiEnv)&&(this.config.apiEnv=n.apiEnv),this.config.synchronizeTime&&(this.timeSynchronisation=new Gr);let r=new Kn;this.experimental={error$:r};let i=Gn.get(ci);this.statContext.deviceId?this.deviceId=this.statContext.deviceId:i?this.deviceId=i:(this.deviceId=In(),Gn.set(ci,this.deviceId)),this.resetViewSession(),n.useIsid&&this.isid$.next(n.isid??$n()),this.zenUid$.next(n.zenUid);let a=new Dr({config:this.config,error$:r,timeSynchronisation:this.timeSynchronisation});this.api=new ur({config:this.config,apiTransport:a,refreshAuthToken:n.refreshAuthToken,mobile:this.statContext.mobile??!1,deviceId:this.deviceId,error$:r,vktvVersion:n.vktvVersion}),this.logger=new Ir({config:this.config,debugLogger:this.debugLogger,api:this.api,error$:r,userSalt:n.userSalt});let{isEmbed:o,topOrigin:s}=Xn();this.isEmbed=o,this.embedParent=s?new URL(s).hostname:void 0,this.subscribe()}updateContext(e){this.statContext={...this.statContext,...e}}attachTo(e){let t=new qn,n=(e,n)=>t.add(e.subscribe(n));n(e.events.willStart$,()=>{let t=e.info.position$.getValue();this.logActionPlay({position:t}),this.statContext.projectId&&this.logActionPlayInteractive()}),n(e.events.looped$,()=>{this.resetViewSession(),++this.loopCounter>this.config.maxLoops&&(this.disabled=!0),this.logActionPlay({position:e.info.position$.getValue()})}),n(e.events.seeked$,()=>{let t=this.seekAction$.getValue();this.logSeek({action:t===`rich`?`slider`:t,time:e.info.position$.getValue()}),this.seekAction$.next(`unknown`)}),n(e.events.paused$,()=>{this.logPause({position:e.info.position$.getValue()})}),n(e.events.willResume$,()=>{this.logPlay()}),n(e.events.started$,()=>{this.statContext.clip&&this.logWatchCoverageRecord({start:0,end:0})}),n(e.events.playing$,()=>{this.logPlaying()}),n(ri(e,{forceInterval:this.config.watchCoverageInterval,watchCoverageTimeoutFix:this.config.watchCoverageTimeoutFix}),t=>{let n=e.info.isLive$.getValue(),r=e.info.atLiveEdge$.getValue(),i={start:parseFloat(t.from.toFixed(3)),end:parseFloat(t.to.toFixed(3))};if(r){let t=e.info.liveLatency$.getValue()??0,n=e.info.currentBuffer$.getValue()?.end??0,r=e.info.liveBufferTime$.getValue()??0,a=Math.round((t-(n-r))*1e3),o=Math.round(t*1e3);a&&o&&(i.latency=a,i.bufferLatency=o)}n?this.logWatchCoverageLive(i):this.logWatchCoverageRecord(i)});let r;n(e.info.isStalled$,e=>{e?r=W():(Bn(r)&&this.logEmptyBuffer({duration:W()-r}),r=void 0)});let i=!1;t.add(e.events.fatalError$.pipe(Wn()).subscribe(()=>i=!0)),n(e.events.willStop$,()=>{if(e.info.isStalled$.getValue()){let e=Bn(r)?W()-r:void 0;this.logCloseAtEmptyBuffer({duration:e??0}),r=void 0}else i||this.logActionStop()}),n(e.events.managedError$,({id:e})=>{this.logError({fatal:!1,errorType:e})}),n(e.events.fatalError$,({id:e})=>{this.logError({fatal:!0,errorType:e})});let a,o,s=!1;n(e.events.firstBytes$,e=>{a=W(),this.logFirstBytes({time:e})}),n(e.events.willStart$,()=>o=W()),n(e.info.currentBuffer$,e=>{!s&&e&&e.end-e.start>0&&Bn(a)&&(this.logPlayerReady({duration:W()-a}),s=!0)}),n(e.events.firstFrame$,()=>{Bn(a)&&!s&&(this.logPlayerReady({duration:W()-a}),s=!0),Bn(o)&&this.logFirstFrame({time:W()-o})});let c;n(e.info.currentVideoStream$,e=>{e&&(c&&e.id!==c&&this.logTrackSwitch(e),c=e.id)});let l;n(e.info.currentAudioStream$,e=>{e&&(l&&e.id!==l&&this.logTrackSwitch(e),l=e.id)}),n(e.info.atLiveEdge$,e=>this.updateContext({liveEdge:e})),n(Rn({muted:e.info.muted$,volume:e.info.volume$}),({muted:e,volume:t})=>this.updateContext({audible:!e&&t>0})),n(e.info.currentQuality$,e=>{let t=Br(e);this.updateContext({quality:t}),t&&this.logQuality(t)}),n(e.info.isAutoQualityEnabled$,e=>this.updateContext({autoQuality:e})),n(e.info.currentFormat$,e=>this.updateContext({contentType:Hr(e)})),n(e.info.currentPlaybackRate$,e=>this.updateContext({rate:e})),n(e.info.is3DVideo$,e=>this.updateContext({is3d:e}));let u;return n(e.info.hostname$,e=>{let t=u!==void 0&&u!==e;this.updateContext({cdnHostname:e,failover:t}),t&&this.logFailover(e),u=e}),n(e.info.throughputEstimation$,e=>this.updateContext({downloadSpeed:e})),n(e.info.httpConnectionType$,e=>{this.statContext.firstConnectionType||this.updateContext({firstConnectionType:Vr(e)}),this.updateContext({connectionType:Vr(e)})}),n(e.info.httpConnectionReused$,e=>{Vn(this.statContext.firstConnectionReused)&&this.updateContext({firstConnectionReused:e}),this.updateContext({connectionReused:e})}),n(e.info.surface$,e=>{this.uiEvents||this.updateContext({mode:Ur(e,this.statContext.isPreviewPlayerView)})}),n(Rn({current:e.info.currentTextTrack$,available:e.info.availableTextTracks$}),({current:e,available:t})=>{let n=t.find(({id:t})=>t===e),r=n&&(n.isAuto?`${n.language}_auto`:n.language);this.updateContext({subtitles:r?.split(`.`)[0]})}),this.player=e,this.uiEvents&&this.attachToUi(this.uiEvents),this.resubscribeBeforeunload(),this.subscription.add(t),t}attachToUi(e){this.uiEvents=e;let{subscription:t,subscribe:n}=li();if(!this.player)return t;n(e.actionRewind$,()=>{this.player&&(this.resetViewSession(),this.logActionPlay({position:this.player.info.position$.getValue()}))}),n(e.actionSeek$,this.seekAction$);let{surface$:r}=si(this.uiEvents,n,this.player);return n(r,e=>{this.updateContext({mode:Ur(e,this.statContext.isPreviewPlayerView)})}),n(e.actionSetSubtitle$,e=>this.updateContext({subtitles:e?.split(`.`)[0]})),n(e.nextMovie$,e=>this.logNextMovie(e)),this.resubscribeBeforeunload(),this.subscription.add(t),t}attachToAds(e){let{subscription:t,subscribe:n}=li();return n(e.slotRequested$,()=>this.logAdSlotRequest()),n(e.started$,e=>this.logAdStarted(e)),n(e.paused$,()=>this.logAdPaused()),n(e.resumed$,()=>this.logAdResumed()),n(e.ended$,()=>this.logAdEnded()),n(e.skipped$,()=>this.logAdSkipped()),n(e.clicked$,()=>this.logAdClicked()),n(e.error$,e=>this.logError({errorType:e,fatal:!1})),this.resubscribeBeforeunload(),this.subscription.add(t),t}attachToInteractive(e){let{subscription:t,subscribe:n}=li();return n(e.click$,e=>this.logInterfaceClick(e)),n(e.nextMovie$,e=>this.logNextMovie(e)),this.resubscribeBeforeunload(),this.subscription.add(t),t}authorize(e){return this.api.authorize(e)}pause(){this.logger.pause(),this.oneStatDebugLog({message:`paused`})}resume(){this.logger.resume(),this.oneStatDebugLog({message:`resumed`})}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}resetViewSession(){this.oneStatDebugLog({message:`VSID reset`}),er.generateVSID(this.config.useVsid64)}getDeviceId(){return this.deviceId}setFieldBlacklist(){}logInited(){}logReady(e){this.log({operation:`player_ready`,param:String(e.time)})}logStarted(...e){this.logActionPlay(...e)}logPlay(){this.log({operation:`play_toggle`})}logPlaying(){this.log({operation:`playing`})}logPause(e){this.log({operation:`pause`,param:String(Math.round(e.position))})}logSeek(e){this.log({operation:`seek`,param:e.action,time:e.time})}logFirstBytes(e){this.log({operation:`first_bytes`,param:String(e.time)})}logFirstFrame(e){this.log({operation:`first_frame`,param:String(e.time)})}logError(e){this.log({operation:`content_error`,param:`${e.fatal?`fatal`:`recoverable`}_${e.errorType}`})}logWatchCoverageRecord(e){this.log({operation:`watch_coverage_record`,param:`${e.start}-${e.end}`},{in_history:this.statContext.inHistory?1:void 0})}logWatchCoverageLive(e){let t=this.timeSynchronisation?.getOffset()??0,n=e.start+t,r=e.end+t;this.log({operation:`watch_coverage_live`,param:`${n}-${r}`},{in_history:this.statContext.inHistory?1:void 0,latency:e.latency,buffer_latency:e.bufferLatency})}logEmptyBuffer(e){this.log({operation:`empty_buffer`,param:String(e.duration)})}logDownloadSpeed(){}logAdSlotRequest(){this.log({operation:`adv`,param:`slot_request`})}logAdStarted(e){this.log({operation:`adv`,param:e})}logAdPaused(){this.log({operation:`adv`,param:`pause`})}logAdResumed(){this.log({operation:`adv`,param:`resume`})}logAdEnded(){this.log({operation:`adv`,param:`ended`})}logAdSkipped(){this.log({operation:`adv`,param:`skip`})}logAdClicked(){this.log({operation:`adv`,param:`click`})}logInterfaceClick(e){this.log({operation:`player_interface_click`,param:e})}logNextMovie(e){this.log({operation:`next_movie`,param:String(e)})}subscribe(){this.resubscribeBeforeunload();let e=window.navigator.connection;e&&`onchange`in e&&`effectiveType`in e&&this.subscription.add(Hn(zn(e,`change`),Un([`init`])).subscribe(()=>this.updateContext({network:Wr(e.effectiveType)}))),this.config.debugLog&&this.debugLogger.log$.subscribe(e=>{console.debug(`%c stat `,`background:#fa6470;`,`component: ${e.component}.`,e.message)})}resubscribeBeforeunload(){this.beforeunloadSubscription?.unsubscribe(),this.beforeunloadSubscription=zn(window,`beforeunload`).subscribe(()=>this.logger.flush({wantBeacon:!0,clearStorage:this.config.clearStorageAtUnload})),this.subscription.add(this.beforeunloadSubscription)}logPlayerReady(e){this.log({operation:`player_ready`,param:String(Math.round(e.duration))})}logActionPlay(e){this.log({operation:`action_play`,param:String(Math.round(e.position))})}logActionPlayInteractive(){this.statContext.projectId&&this.log({operation:`action_play_interactive`,param:String(this.statContext.movieId)},{vid:this.statContext.projectId})}logFailover(e){this.log({operation:`failover`,param:e})}logCloseAtEmptyBuffer(e){this.log({operation:`close_at_empty_buffer`,param:String(Math.round(e.duration))})}logActionStop(){this.log({operation:`action_stop`})}logTrackSwitch(e){this.log({operation:`track_switch`,param:e.id})}logQuality(e){this.log({operation:`quality`,param:e})}log(e,t={}){if(this.disabled){this.oneStatDebugLog({message:`operation ${e.operation} but statistics is disabled`});return}if(yn(this.config.disabledOperations,e.operation)){this.oneStatDebugLog({message:`operation ${e.operation} but it is disabled`});return}this.oneStatDebugLog({message:`operation ${e.operation} ${e.param}`});let n=this.createLogItem(e,t);this.logger.log(n)}createLogItem({operation:e,param:t,time:n},r={}){let i=this.timeSynchronisation?.now()??W(),a=this.vsid$.getValue();Ln(a);let o=this.isid$.getValue(),s=e===`empty_buffer`||e===`close_at_empty_buffer`?this.statContext.connectionType:this.statContext.firstConnectionType,c=this.statContext.firstConnectionReused,l,u;if(this.isEmbed||this.statContext.place===`embed`){l=this.embedParent;let e=[...new URLSearchParams(location.search).entries()].filter(([e,t])=>yn(this.config.embedUrlParams,e));u=new URLSearchParams(e).toString()}else if(this.statContext.place===`direct`){let e=this.statContext.refDomain||document.referrer;l=e&&bn(URL,e)?new URL(e).hostname:e,u=location.href.substring(0,1024)}let d={vsid:a,isid:o,vid:this.statContext.movieId,uid:this.zenUid$.getValue(),ct:this.statContext.contentType,place:this.isEmbed?`embed`:this.statContext.place,quality:this.statContext.quality,cdn_host:this.statContext.cdnHostname,stat_type:this.statContext.autoplay===!0?`auto`:this.statContext.autoplay===!1?``:void 0,param:t,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode,connection_type:s,connection_reused:c===!0?1:c===!1?0:void 0,cached_data:this.statContext.cached===!0?1:this.statContext.cached===!1?0:void 0,live:this.statContext.liveEdge?1:void 0,muted:this.statContext.audible===!1?1:void 0,mode:this.statContext.mode,subtitles:this.statContext.subtitles,download_speed:this.statContext.downloadSpeed,manual_quality:this.statContext.autoQuality?void 0:1,ref_domain:l,direct_url:u,rate:this.statContext.rate===1||Vn(this.statContext.rate)?void 0:this.statContext.rate.toFixed(2),view_360:this.statContext.is3d?1:void 0,aid:this.statContext.albumId,vk_playlist_id:this.statContext.vkPlaylistId,...r};for(let e of this.config.disabledCustomFields)delete d[e];return{operation:e,type:1,time:n,network:this.statContext.network,timestamp:i,custom:d}}}var di={};p(di,{VERSION:()=>ar,ThinOneStat:()=>za,ActionSeekType:()=>ji});var fi=l(_n(),1),pi=l(Ae(),1);import{assertNonNullable as mi,detectEmbed as hi,fromEvent as gi,Logger as _i,merge as vi,combine as yi,filter as Y,filterChanged as bi,once as xi,skip as Si,safeStorage as Ci,getWindow as wi,Subject as Ti,Subscription as Ei,ValueSubject as Di,ErrorCategory as Oi}from"@vkontakte/videoplayer-shared/es2018";import{clientChecker as X}from"@vkontakte/videoplayer-core/es2018";import{fillWithDefault as ki}from"@vkontakte/videoplayer-shared/es2018";var Ai;(e=>{e.AUTO=`auto`,e.AUTO_POOR=`auto_poor`,e.AUTO_RICH=`auto_rich`})(Ai||={});var ji;(e=>{e.SLIDER=`slider`,e.RICH=`rich`,e.DOUBLE_TAP=`double_tap`,e.TIME_CODE=`time_code`,e.EPISODE=`episode`,e.REWIND=`rewind`,e.LIVE=`live`,e.UNKNOWN=`unknown`})(ji||={});var Mi=`CIOPGQJGDIHBABABA`,Ni={prod:`https://api.ok.ru`,vk_alias:`https://api.mycdn.me`,videotest:`https://videotestapi.ok.ru/api`,test:`https://apitest.ok.ru`,okcdn:`https://api.okcdn.ru`,auto:``},Pi={apiKey:Mi,apiEnv:`okcdn`,apiBaseUrl:null,requestRetryCount:1,useVsid64:!1,firstFlushTime:5e3,flushDebounceTime:1e4,flushMaxWait:6e4,storageExpiration:2160*60*1e3,watchCoverageHeartbeatInterval:3e4,disabledEvents:[],disabledParams:[],synchronizeTime:!0,useBeacon:!1,alwaysSendDesktop:!1,watchedNDefaultTargetDuration:1e3,downloadBytesMaxTime:3e4},Fi=e=>ki(e,Pi),Ii=l(Vt(),1);import{getExponentialDelay as Li,ErrorCategory as Ri,ValueSubject as zi}from"@vkontakte/videoplayer-shared/es2018";class Bi{constructor(t){e(this,`authorized$`,void 0),e(this,`params`,void 0),e(this,`authToken`,void 0),e(this,`sessionKey`,void 0),e(this,`authorizePromise`,void 0),e(this,`refreshAuthTokenPromise`,void 0),e(this,`consequentAuthErrors`,void 0),e(this,`backoffTimeoutId`,void 0),this.params=t,this.authorized$=new zi(!1),this.consequentAuthErrors=0}async authorize(e){return this.authToken=e??await this.refreshAuthToken(),this.authorizeWithBackoff()}logBeacon(e){let t=this.createLogParams(e),n=this.sessionKey;n&&(this.params.apiTransport.sendBeacon(`log.logUvStat`,t,n)||this.logRequest(e).catch(()=>{}))}async logRequest(e){let t=`log.logUvStat`,n=this.createLogParams(e),r={},i=this.sessionKey??await this.authorizeWithBackoff();if(!i)return;let a=async(e,o=this.params.config.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(t,n,i,r)}catch(n){if(!n||!(`error_code`in n)){this.params.error$.next({id:`logRequestUnknown`,category:Ri.NETWORK,message:`Unknown ${t} error`,thrown:n});return}let r=n?.error_code;switch(r){case 102:case 103:case 104:return this.authorized$.next(!1),this.sessionKey=await this.authorizeWithBackoff(),o>0?a(e,o-1):void 0;case 401:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this.authorizeWithBackoff(),o>0?a(e,o-1):void 0;default:this.params.error$.next({id:`LogRequest#${r}`,category:Ri.EXTERNAL_API,message:`${t} error`,data:n});return}}};return a(e)}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}async refreshAuthToken(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||=Ii.default(this.params.refreshAuthToken(),()=>{this.refreshAuthTokenPromise=void 0}),this.refreshAuthTokenPromise}createLogParams(e){return{collector:`ok.mobile.apps.video`,uv_stat_data:JSON.stringify({application:`@vkontakte/videoplayer-statistics:${ar}`,platform:e[0].platform,product:e[0].product,events:e})}}authorizeWithBackoff(){if(!this.consequentAuthErrors)return this.doAuthorize();let e=Li(this.consequentAuthErrors);return new Promise(t=>{this.backoffTimeoutId||=window.setTimeout(async()=>{try{t(await this.doAuthorize())}catch(e){this.params.error$.next({id:`AuthorizeBackoff`,category:Ri.NETWORK,message:`Otherwise unhandled error in authorization`,thrown:e})}finally{this.backoffTimeoutId=0}},e)})}doAuthorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);let e={session_data:{version:2,device_id:this.params.deviceId,client_version:ar.split(`-`)[0],client_type:`SDK_JS`}};return this.authToken!==void 0&&(e.session_data.auth_token=this.authToken,e.session_data.version=3),this.authorizePromise=Ii.default(this.params.apiTransport.sendRequest(`auth.anonymLogin`,e).then(e=>((!e||!e.session_key)&&this.params.error$.next({id:`AuthorizeFailed`,category:Ri.EXTERNAL_API,message:`No session key`,data:e}),this.sessionKey=e?.session_key??void 0,this.sessionKey)).catch(async e=>{this.sessionKey=void 0;let t=e?.error_code;switch(t){case 401:return this.authToken=await this.refreshAuthToken(),this.authorizeWithBackoff()}t?this.params.error$.next({id:`Authorize#${t}`,category:Ri.EXTERNAL_API,message:`authorize error`,data:e}):this.params.error$.next({id:`AuthorizeUnknown`,category:Ri.NETWORK,message:`authorize error`,thrown:e})}),()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise}}var Vi=l(Ae(),1),Hi=l(Zt(),1);import{now as Ui,ErrorCategory as Wi}from"@vkontakte/videoplayer-shared/es2018";class Gi{constructor(t){e(this,`params`,void 0),e(this,`apiKey`,void 0),e(this,`apiBaseUrl`,void 0),e(this,`apiEnv`,void 0),e(this,`isApiBaseUrlFetched`,void 0),e(this,`timeSynchronisation`,void 0),this.params=t,this.apiKey=t.config.apiKey,this.apiEnv=t.config.apiEnv,this.apiBaseUrl=t.config.apiBaseUrl??Ni[this.apiEnv],this.timeSynchronisation=t.timeSynchronisation,this.isApiBaseUrlFetched=!1}sendBeacon(e,t,n){if(!window.Blob||!window.navigator.sendBeacon)return!1;let r=this.prepareQueryParams({method:e,queryParams:t,sessionKey:n}),i=new window.Blob([r.toString()],{type:`application/x-www-form-urlencoded`});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,i)}catch(n){this.params.error$.next({id:`OneStat:ApiTransport:sendBeacon`,category:Wi.NETWORK,message:`Unhandled beacon error`,thrown:n,data:{method:e,params:t}})}return!1}async sendRequest(e,t,n,r){let i=Ui(),a=r=>{if(r instanceof TypeError&&Vi.default([`Failed to fetch`,`NetworkError when attempting to fetch resource.`],r.message)){this.params.error$.next({id:`Network`,category:Wi.NETWORK,message:`Request failed`,thrown:r});return}this.params.error$.next({id:`ThinOneStat:ApiTransport:sendRequest`,category:Wi.NETWORK,message:`Unhandled request error`,thrown:r,data:{method:e,params:t,sessionKey:n,time:Ui()-i}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),Sr(`${this.apiBaseUrl}/fb.do`,{method:`post`,headers:{"Content-type":`application/x-www-form-urlencoded`,...r},body:this.prepareQueryParams({method:e,queryParams:t,sessionKey:n})}).then(e=>{let t=Number(e.headers.get(`content-length`))===0,n=new Date(e.headers.get(`date`)??``).getTime(),r=Ui()-i;if(isFinite(n)&&this.timeSynchronisation?.addServerTime(n,r),!t)return e.json().then(e=>Object.prototype.hasOwnProperty.call(e,`error_msg`)?Promise.reject(e):e,a)},a)}async resolveApiBaseUrl(){if(this.apiEnv!==`auto`||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{var e;let t=await(await Sr(atob(`aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ=`),{method:`GET`,mode:`cors`,cache:`no-cache`})).json(),n=t==null||(e=t.Answer[0])==null?void 0:e.data;if(!n)throw Error(`Wrong DNS response`);return n}catch(e){return this.params.error$.next({id:`ThinOneStat:ApiTransport:resolveApiBaseUrl`,category:Wi.NETWORK,message:`Unhandled resolve api base url error`,thrown:e}),Ni.vk_alias}finally{this.isApiBaseUrlFetched=!0}}prepareQueryParams(e){let t=new URLSearchParams({format:`JSON`,method:e.method,application_key:this.apiKey});return e.sessionKey!==void 0&&t.append(`session_key`,e.sessionKey),Hi.default(e.queryParams).forEach(([e,n])=>t.append(e,typeof n==`string`?n:JSON.stringify(n))),t}}var Ki=l(Ae(),1),qi=l(Zt(),1);import{ErrorCategory as Ji,now as Yi,safeStorage as Xi,debounceFn as Zi}from"@vkontakte/videoplayer-shared/es2018";var Qi=`thinonestat_events`,$i=e=>t=>t.client_time+e>=Yi();class ea{constructor(t){e(this,`params`,void 0),e(this,`api`,void 0),e(this,`error$`,void 0),e(this,`subscription`,void 0),e(this,`userSalt`,void 0),e(this,`unsaltedStorage`,[]),e(this,`lastVsid`,void 0),e(this,`isPaused`,!1),e(this,`firstFlush`,void 0),e(this,`debouncedFlush`,void 0),e(this,`loggerDebugLog`,void 0),e(this,`isUrgent`,e=>{let{event_name:t}=e;return Ki.default([`watch_coverage`,`watch_coverage_live`,`watched_n`,`playback_started`],t)}),this.params=t,this.api=t.api,this.error$=t.error$,this.userSalt=t.userSalt,this.loggerDebugLog=t.debugLogger.createComponentLog(`stat logger`),this.firstFlush=Zi(()=>this.safeFlush(),this.params.config.firstFlushTime,{maxWait:this.params.config.firstFlushTime});let n=Xi.isPersistent()?this.params.config.flushMaxWait:0;this.debouncedFlush=Zi(()=>this.safeFlush(),this.params.config.flushDebounceTime,{maxWait:n}),this.subscription=this.api.authorized$.subscribe(e=>{e&&this.debouncedFlush()}),this.housekeepStorage()}safeFlush(){try{this.flush()}catch(e){this.error$.next({id:`LoggerError`,category:Ji.WTF,message:String(e)||`Unknown logger error`,thrown:e})}}readFromStorage(){let e=Xi.get(Qi);try{return e?JSON.parse(e):{}}catch{}return{}}addToStorage(e){if(!this.userSalt){this.unsaltedStorage.push(e);return}let t=this.readFromStorage(),n=(t[this.userSalt]??[]).filter($i(this.params.config.storageExpiration));Xi.set(Qi,JSON.stringify({...t,[this.userSalt]:[...n,e]}))}getFromStorage(){return this.userSalt?(this.readFromStorage()[this.userSalt]??[]).filter($i(this.params.config.storageExpiration)):this.unsaltedStorage}markStorageSent(){if(!this.userSalt){this.unsaltedStorage=[];return}let e=this.readFromStorage();delete e[this.userSalt],Xi.set(Qi,JSON.stringify(e))}housekeepStorage(){let e=this.readFromStorage();for(let[t,n]of qi.default(e)){let r=n.filter($i(this.params.config.storageExpiration));r.length?e[t]=r:delete e[t],this.loggerDebugLog({message:`${n.length} retrieved from storage, ${r.length} of them actual`})}Xi.set(Qi,JSON.stringify(e))}log(e){this.addToStorage(e),!this.isPaused&&(this.isUrgent(e)?this.flush():this.lastVsid===e.vsid?this.debouncedFlush():this.firstFlush(),this.lastVsid=e.vsid)}flush({wantBeacon:e,clearStorage:t}={wantBeacon:!1,clearStorage:!0}){let n=this.getFromStorage();n.length!==0&&(this.api.authorized$.getValue()?(e&&this.params.config.useBeacon?(this.loggerDebugLog({message:`Flushing ${n.length} events through beacon`}),this.api.logBeacon(n)):(this.loggerDebugLog({message:`Flushing ${n.length} events`}),this.api.logRequest(n)),t&&this.markStorageSent()):this.api.authorize(),this.firstFlush.cancel(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe(),this.firstFlush.cancel(),this.debouncedFlush.cancel()}}function ta(){let e=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`.split(``),t=Array(36),n=0,r,i;for(i=0;i<36;i++)i===8||i===13||i===18||i===23?t[i]=`-`:i===14?t[i]=`4`:(n<=2&&(n=33554432+Math.random()*16777216|0),r=n&15,n>>=4,t[i]=e[i===19?r&3|8:r]);return t.join(``)}class na{constructor(t){e(this,`offset`,void 0),this.offset=t}getOffset(){return this.offset??0}setOffset(e){this.offset=e}now(){return Date.now()+(this.offset??0)}date(e=new Date){return e.setTime(e.getTime()+(this.offset??0)),e}addServerTime(e,t){let n=e-Date.now()-t/2;if(Math.abs(n)<1e3){this.offset=0;return}if(this.offset===void 0)this.offset=Math.round(n);else{let e=.2;this.offset=Math.round(e*n+(1-e)*this.offset)}}}import{PlaybackState as ra}from"@vkontakte/videoplayer-core/es2018";import{Observable as ia,Subscription as aa,ValueSubject as oa,Subject as sa,fromEvent as ca,isNullable as la,merge as ua,filter as da,filterChanged as fa,getWindow as pa}from"@vkontakte/videoplayer-shared/es2018";var ma=(e,t,n)=>new ia(r=>{let i=new aa,a=new oa(void 0),o;i.add(e.info.isLive$.pipe(fa()).subscribe(t=>{o&&(o.unsubscribe(),a.next(void 0)),o=t?e.info.liveTime$.pipe(fa()).subscribe(a):e.info.position$.subscribe(a),i.add(o)}));let{playing$:s,paused$:c,ended$:l,looped$:u}=e.events,d=e.events.willSeek$.pipe(da(()=>e.info.playbackState$.getValue()===ra.PLAYING)),f=e.events.seeked$.pipe(da(()=>e.info.playbackState$.getValue()===ra.PLAYING)),p=!1,m=new sa;i.add(d.subscribe(()=>{p||m.next(),p=!0})).add(f.subscribe(()=>p=!1));let h=ua(ca(pa(),`beforeunload`),e.events.willDestruct$),g,_=()=>g=a.getValue(),v=()=>{let e=a.getValue();la(g)||la(e)||g===e||(r.next({from:g,to:e}),g=void 0)},y=new sa,b=new sa,x=ua(s,f,y),S=ua(c,m,h,l,u,b),C=t.started$&&t.ended$?ua(x,t.ended$):x,w=t.started$&&t.ended$?ua(S,t.started$):S;if(i.add(C.subscribe(_)).add(w.subscribe(v)),n.heartbeatInterval&&isFinite(n.heartbeatInterval)){let e=[],t=()=>{b.next(),y.next()};i.add(C.subscribe(()=>{let r=pa().setTimeout(t,n.heartbeatInterval);e.push(r)})).add(w.subscribe(()=>{e.forEach(e=>{pa().clearTimeout(e)}),e=[]}))}return i});import{Subscription as ha}from"@vkontakte/videoplayer-core/es2018";import{Observable as ga,merge as _a}from"@vkontakte/videoplayer-shared/es2018";var va=(e,t)=>new ga(n=>{let r=new ha;return r.add(_a(e.info.position$,e.info.liveTime$).subscribe(()=>{let e=t.getTotalViewTime();e>=t.targetDuration&&(n.next({target_duration:t.targetDuration,current_tvt:e}),r.unsubscribe())})),r});import{Subscription as ya}from"@vkontakte/videoplayer-core/es2018";import{Observable as ba,filter as xa,getWindow as Sa}from"@vkontakte/videoplayer-shared/es2018";var Ca=(e,{maxTimeWindow:t})=>new ba(n=>{let r=new ya,i={maxBytesThreshold:100*1024*1024,minBytesThreshold:100*1024,maxTimeWindow:t,minTimeWindow:2e3},a={bytes:0,startTime:0,lastEmitTime:0,timeoutId:0},o=()=>{a.timeoutId&&=(Sa().clearTimeout(a.timeoutId),null)},s=()=>{a.bytes=0,a.startTime=0,a.lastEmitTime=0,o()},c=e=>{if(a.bytes<i.minBytesThreshold||e-a.lastEmitTime<i.minTimeWindow&&a.lastEmitTime>0)return!1;let t=(a.startTime>0?e-a.startTime:0)>=i.maxTimeWindow,n=a.bytes>=i.maxBytesThreshold;return t||n},l=(e=!1)=>{let t=Date.now();if(!e&&!c(t))return;o();let r=a.startTime>0?t-a.startTime:Math.max(i.minTimeWindow,1),l=a.bytes/(r/1e3);n.next({download_bytes:Math.round(a.bytes),download_speed:Math.round(l)}),a.lastEmitTime=t,s()},u=()=>{if(o(),a.startTime>0&&a.bytes>=i.minBytesThreshold){let e=Date.now()-a.startTime,t=i.maxTimeWindow-e;t>100?a.timeoutId=Sa().setTimeout(()=>{a.timeoutId=null,l()},t):t>0&&l()}};return r.add(e.info.httpDownloadMetrics$.pipe(xa(e=>e!==void 0)).subscribe(e=>{let t=Date.now();a.startTime===0&&(a.startTime=t),a.bytes+=e.bytes,c(t)?l():u()})),r.add(()=>{if(o(),a.bytes>0){let e=Date.now(),t=a.startTime>0?e-a.startTime:i.minTimeWindow,r=a.bytes/(t/1e3);n.next({download_bytes:Math.round(a.bytes),download_speed:Math.round(r)})}s()}),r});import{Observable as wa,Subscription as Ta,merge as Ea}from"@vkontakte/videoplayer-shared/es2018";var Da=e=>new wa(t=>{let n=new Ta,r=0,i=1,a=0,o=!1,s=!1,c=()=>{if(!o)return;let e=Date.now();a+=(e-r)*i,r=e},l=()=>{(!o||s)&&(r=Date.now(),o=!0,s=!1)},u=()=>{o&&=(c(),!1)},d=()=>{o&&(c(),o=!1,s=!0)},f=e=>{o&&c(),i=e,r=Date.now()},{started$:p,playing$:m,paused$:h,willSeek$:g,ended$:_,willDestruct$:v}=e.events,{currentPlaybackRate$:y}=e.info;return n.add(g.subscribe(d)).add(Ea(p,m).subscribe(l)).add(Ea(h,_,v).subscribe(u)).add(y.subscribe(f)),t.next(()=>{let e=a;return o&&(e+=(Date.now()-r)*i),e}),n});import{assertNever as Oa}from"@vkontakte/videoplayer-shared/es2018";import{HttpConnectionType as ka,Surface as Aa,VideoFormat as Z,VideoQuality as Q}from"@vkontakte/videoplayer-core/es2018";var ja=e=>e&&{[ka.HTTP1]:`http1`,[ka.HTTP2]:`http2`,[ka.QUIC]:`http3`}[e],Ma=e=>{if(e!==void 0)switch(e){case Z.MPEG:return`MP4`;case Z.DASH:case Z.DASH_LIVE:return`DASH`;case Z.DASH_SEP:return`DASH_SEP`;case Z.DASH_ONDEMAND:return`ONDEMAND_DASH`;case Z.HLS_ONDEMAND:return`ONDEMAND_HLS`;case Z.HLS:case Z.HLS_LIVE:return`HLS`;case Z.HLS_FMP4:return`HLS_FMP4`;case Z.DASH_WEBM:case Z.DASH_LIVE_WEBM:return`WEBM`;case Z.DASH_LIVE_CMAF:return`ONDEMAND_DASH_LIVE`;case Z.HLS_LIVE_CMAF:return`ONDEMAND_HLS_LIVE`;case Z.WEB_RTC_LIVE:return`WEBRTC`;case Z.DASH_WEBM_AV1:return`AV1`;case Z.DASH_STREAMS:return`MULTI_DASH`;default:return Oa(e)}},$=e=>{if(e!==void 0)switch(e){case Q.Q_144P:return`144p`;case Q.Q_240P:return`240p`;case Q.Q_360P:return`360p`;case Q.Q_480P:return`480p`;case Q.Q_720P:return`720p`;case Q.Q_1080P:return`1080p`;case Q.Q_1440P:return`1440p`;case Q.Q_2160P:return`2160p`;case Q.INVARIANT:case Q.Q_576P:case Q.Q_4320P:return`UNKNOWN`;default:return Oa(e)}},Na=e=>{if(e!==void 0)switch(e){case`MP4`:case`ONDEMAND_DASH`:case`ONDEMAND_DASH_LIVE`:case`ONDEMAND_HLS`:case`ONDEMAND_HLS_LIVE`:case`MULTI_DASH`:case`WEBM`:case`AV1`:return`vod`;case`DASH`:case`HLS`:case`HLS_FMP4`:case`WEBRTC`:return`live`;default:return}},Pa=(e,t,n)=>{if(e&&t)switch(e){case Z.MPEG:return n&&t[e]&&t[e][n];default:return t[e]?.url}},Fa=(e,t=!1)=>{if(t)return`minimal`;switch(e){case void 0:case Aa.NONE:return;case Aa.INLINE:return`inline`;case Aa.FULLSCREEN:return`fullscreen`;case Aa.SECOND_SCREEN:return`chromecast`;case Aa.PIP:return`pip_external`}},Ia=e=>{switch(e){case void 0:return;case Aa.INVISIBLE:return`background`;default:return`foreground`}},La=`_thin-one-stat_deviceId`,Ra=()=>{let e=new Ei;return{subscription:e,subscribe:(t,n)=>{t&&e.add(t.subscribe(n))}}};class za{get vsid$(){return new Di(er.getVSID())}constructor(t,n){e(this,`api`,void 0),e(this,`logger`,void 0),e(this,`config`,void 0),e(this,`subscription`,void 0),e(this,`beforeunloadSubscription`,void 0),e(this,`timeSynchronisation`,void 0),e(this,`statContext`,void 0),e(this,`deviceId`,void 0),e(this,`targetDuration`,void 0),e(this,`debugLogger`,new _i),e(this,`thinOneStatDebugLog`,this.debugLogger.createComponentLog(`ThinOneStat`)),e(this,`eventNumber`,1),e(this,`isStarted`,void 0),e(this,`wasPaused`,void 0),e(this,`isLive`,void 0),e(this,`position`,void 0),e(this,`cdnHostname`,void 0),e(this,`isEmbed`,void 0),e(this,`embedHostname`,void 0),e(this,`connectionType`,void 0),e(this,`connectionReused`,void 0),e(this,`player`,void 0),e(this,`playerSize`,{width:0,height:0}),e(this,`currentSubtitle`,void 0),e(this,`uiEvents`,void 0),e(this,`seekAction$`,new Di(`unknown`)),e(this,`isid$`,new Di(void 0)),e(this,`getTotalViewTime`,()=>0),this.statContext=t,this.config=Fi(n.config??{}),this.subscription=new Ei,this.config.synchronizeTime&&(this.timeSynchronisation=new na);let r=new Ti,i=Ci.get(La);this.statContext.deviceId?this.deviceId=this.statContext.deviceId:i?this.deviceId=i:(this.deviceId=ta(),Ci.set(La,this.deviceId)),this.statContext.targetDuration?this.targetDuration=this.statContext.targetDuration:this.targetDuration=this.config.watchedNDefaultTargetDuration,this.resetViewSession(),n.useIsid&&this.isid$.next(n.isid??$n());let a=new Gi({error$:r,config:this.config,timeSynchronisation:this.timeSynchronisation});this.api=new Bi({config:this.config,apiTransport:a,error$:r,deviceId:this.deviceId,refreshAuthToken:n.refreshAuthToken}),this.logger=new ea({config:this.config,debugLogger:this.debugLogger,api:this.api,error$:r,userSalt:n.userSalt});let{isEmbed:o,topOrigin:s}=hi();this.isEmbed=o,this.embedHostname=s?new URL(s).hostname:void 0}authorize(e){return this.api.authorize(e)}updateContext(e){this.statContext={...this.statContext,...e}}attachTo(e,t){let n=new Ei,r=(e,t)=>n.add(e.subscribe(t));r(Da(e),e=>{this.getTotalViewTime=e}),r(e.info.isLive$,e=>this.isLive=e);let i;r(yi({hostname:e.info.hostname$,connectionType:e.info.httpConnectionType$,connectionReused:e.info.httpConnectionReused$}).pipe(Y(({hostname:e})=>e!==void 0),Y(({connectionType:e})=>e!==void 0),Y(({connectionReused:e})=>e!==void 0)),({hostname:t,connectionType:n,connectionReused:r})=>{if(i!==void 0&&i!==t){let i={cdn_host:t,connection_type:ja(n),connection_reused:r,content_type:Ma(e.info.currentFormat$.getValue())};this.logFailover(i)}this.cdnHostname=i=t}),r(e.info.httpConnectionType$,e=>{this.connectionType=ja(e)}),r(e.info.httpConnectionReused$,e=>{this.connectionReused=e}),r(ma(e,t,{heartbeatInterval:this.config.watchCoverageHeartbeatInterval}),t=>{let n={watch_interval:`${Math.round(t.from*1e3)}-${Math.round(t.to*1e3)}`,in_history:!!this.statContext.inHistory,content_type:Ma(e.info.currentFormat$.getValue()),playback_quality:$(e.info.currentQuality$.getValue()),recom_info:this.statContext.recomInfo};if(!e.info.isLive$.getValue())this.logWatchCoverage(n);else{let t=e.info.atLiveEdge$.getValue();this.logWatchCoverageLive({...n,live:!!t})}}),r(va(e,{targetDuration:this.targetDuration,getTotalViewTime:this.getTotalViewTime}),e=>{this.logWatchedN(e)}),r(e.events.willReady$,()=>{if(this.statContext.preload){let t=e.info.currentFormat$.getValue(),n=e.info.availableSources$.getValue(),r=e.info.currentBuffer$.getValue(),i=e.info.currentQuality$.getValue(),a={target_buffer_time:this.calcBufferTime(r),playback_url:Pa(t,n,i),playback_quality:$(i)};this.logPreloadStarted(a)}}),r(e.events.manifestRequested$,()=>{let t={playback_url:Pa(e.info.currentFormat$.getValue(),e.info.availableSources$.getValue(),e.info.currentQuality$.getValue()),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused};this.logManifestRequest(t)}),r(e.events.firstBytesManifest$,()=>{let t={playback_url:Pa(e.info.currentFormat$.getValue(),e.info.availableSources$.getValue(),e.info.currentQuality$.getValue()),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused};this.logFirstByteManifest(t)}),r(e.events.manifestReceived$,()=>{let t={playback_url:Pa(e.info.currentFormat$.getValue(),e.info.availableSources$.getValue(),e.info.currentQuality$.getValue()),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused};this.logManifestReceived(t)}),r(e.events.firstBytesRequested$,()=>{let t={playback_url:Pa(e.info.currentFormat$.getValue(),e.info.availableSources$.getValue(),e.info.currentQuality$.getValue()),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused};this.logFirstMediaRequest(t)}),r(e.events.firstBytesReceived$,()=>{let t={playback_url:Pa(e.info.currentFormat$.getValue(),e.info.availableSources$.getValue(),e.info.currentQuality$.getValue()),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused};this.logFirstByteMedia(t)}),r(vi(e.events.willStart$,e.events.looped$),t=>{t&&this.resetViewSession();let n={isid:this.isid$.getValue(),stream_profile:Na(Ma(e.info.currentFormat$.getValue())),dpi:this.statContext.dpi??96*X.display.pixelRatio,web_layout:this.statContext.isMobile||X.device.isMobile?`mobile`:`desktop`,preloaded:this.statContext.preload,navigation:this.statContext.navigation,recom_info:this.statContext.recomInfo};this.isEmbed&&(n.iframe_host=this.embedHostname??`unknown`),this.logStartSession(n)}),r(e.events.started$,()=>{this.isStarted=!0;let t=e.info.currentBuffer$.getValue(),n=e.info.currentQuality$.getValue(),r=e.info.isAutoQualityEnabled$.getValue(),i=e.info.muted$.getValue(),a=e.info.volume$.getValue(),o=e.info.surface$.getValue(),s=e.info.availableTextTracks$.getValue(),c=e.info.currentTextTrack$.getValue(),l=e.info.currentAudioStream$.getValue(),u=e.info.currentPlaybackRate$.getValue(),d={playback_quality:$(n),user_quality:r?`auto`:$(n),player_width:this.statContext.playerSize?.width??this.playerSize.width,player_height:this.statContext.playerSize?.height??this.playerSize.height,muted:i,sound_volume:Math.round(a*100),buffer_time:this.calcBufferTime(t),mode:Fa(o,this.statContext.isPreviewPlayerView),visibility:Ia(o),subtitles_enabled:c?!!c:this.currentSubtitle?.enabled,auto_subtitles:s.find(({id:e})=>e===c)?.isAuto??this.currentSubtitle?.auto,audio_track_lang:l?.language,playback_rate:u,recom_info:this.statContext.recomInfo};this.logPlaybackStarted(d)}),r(e.events.willStart$,()=>{this.logPlay()}),r(e.events.playing$,()=>{let t=e.info.currentBuffer$.getValue(),n={buffer_time:this.calcBufferTime(t)};this.logPlaying(n),this.wasPaused&&this.logResume()}),r(e.events.paused$,()=>{this.wasPaused=!0,this.logPause()}),r(e.events.willStop$,()=>{this.logStop()}),r(vi(e.events.fetcherRecoverableError$,e.events.fatalError$),()=>{this.statContext.preload&&this.logPreloadError()});let a=e=>{switch(e){case Oi.NETWORK:return`network`;case Oi.VIDEO_PIPELINE:return`video_pipeline`;case Oi.EXTERNAL_API:return`external_api`;case Oi.PARSER:return`parser`;case Oi.DOM:return`dom`;default:return`wtf`}},o=e=>Oi.FATAL===e?`critical`:`informative`;r(e.events.fetcherRecoverableError$,({id:e,category:t,data:n,message:r,httpCode:i,UVBackendErrorCode:s})=>{let c={error_severity:o(t),error_category:a(t),player_error_code:e,player_error_trace:n,http_error_code:i,uv_backend_error_code_subcode:s,error_message:r};this.logError(c),o(t)===`critical`&&this.logCannotPlay()}),r(e.events.managedError$,({id:e,category:t,data:n,message:r})=>{let i={error_severity:o(t),error_category:a(t),player_error_code:e,player_error_trace:n,error_message:r};this.logError(i)}),r(e.events.fatalError$,({id:e,category:t,data:n,message:r})=>{let i={error_severity:`critical`,error_category:a(t),player_error_code:e,player_error_trace:n,error_message:r};this.logError(i),this.logCannotPlay()}),r(yi({connectionType:e.info.httpConnectionType$,connectionReused:e.info.httpConnectionReused$,connectionMetrics:e.info.httpConnectionMetrics$}).pipe(Y(({connectionReused:e})=>e!==void 0),Y(({connectionMetrics:e})=>e!==void 0),bi((e,t)=>e.connectionType===t.connectionType)),({connectionMetrics:t})=>{let n=e.info.currentFormat$.getValue(),r=e.info.availableSources$.getValue(),i=e.info.currentQuality$.getValue(),a=e.info.rttEstimation$.getValue(),o={playback_url:Pa(n,r,i),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused,rtt:a?Math.round(a):void 0,network_type:this.statContext.networkType??t?.networkType,dns_resolve_time:t?.dnsResolveTime,tcp_handshake_time:t?.tcpHandshakeTime,tls_handshake_time:t?.tlsHandshakeTime};this.logConnectionEstablished(o)}),r(Ca(e,{maxTimeWindow:this.config.downloadBytesMaxTime}),e=>{this.logDownloadBytes(e)}),r(e.events.firstFrame$,()=>{this.logFirstVideoFrameDecoded()}),r(e.events.willSeek$,()=>{let e={seek_type:this.seekAction$.getValue()};this.isStarted&&this.logSeeking(e)}),r(e.events.seeked$,()=>{let e={seek_type:this.seekAction$.getValue()};this.isStarted&&this.logSeeked(e),this.seekAction$.next(`unknown`)}),r(e.info.isStalled$,t=>{let n=e.info.currentBuffer$.getValue(),r=this.calcBufferTime(n);t&&r&&r>0&&this.logBufferStarvation({buffer_time:r})}),r(e.info.currentBuffer$.pipe(Y(e=>!!this.calcBufferTime(e)),xi()),e=>{let t=this.calcBufferTime(e);if(this.statContext.preload){let e={buffer_time:t};this.logPreloadEnded(e)}this.logReady({buffer_time:t})});let s;r(yi({videoStream:e.info.currentVideoStream$,audioStream:e.info.currentAudioStream$,quality:e.info.currentQuality$}).pipe(Y(({videoStream:e,audioStream:t})=>e!==void 0&&t!==void 0),Y(({quality:e})=>e!==void 0)),({videoStream:t,audioStream:n,quality:r})=>{if(s!==r){let i=e.info.isAutoQualityEnabled$.getValue(),a=t?.codec,o=n?.codec,c={user_quality:i?`auto`:$(r),playback_quality:$(s),download_quality:$(r),codec_info:a&&o?`${a},${o}`:void 0};s=r,this.logQualityChanged(c)}});let c,l;return r(e.info.surface$,e=>{let t=Fa(e,this.statContext.isPreviewPlayerView);t&&!this.uiEvents&&this.isStarted&&this.logModeChanged({mode:t}),l=Ia(e),c!==l&&this.isStarted&&(c=Ia(e),this.logVisibilityChanged({visibility:l}))}),r(yi({muted:e.info.muted$,volume:e.info.volume$}),({muted:e,volume:t})=>{if(this.isStarted){let n={muted:e,sound_volume:Math.round(t*100)};this.logSoundChanged(n)}}),r(e.info.currentFormat$.pipe(Y(e=>e!==void 0),Si(1)),e=>{let t={content_type:Ma(e),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused};this.logContentTypeChange(t)}),r(e.info.currentAudioStream$.pipe(Y(e=>e!==void 0),Si(1)),e=>{let t={audio_track_lang:e.language,codec_info:e.codec};this.logAudioTrackSwitched(t)}),r(e.info.currentVideoStream$.pipe(Y(e=>e!==void 0),Si(1)),e=>{let t={hdr:e.hdr,codec_info:e.codec};this.logVideoTrackSwitched(t)}),this.player=e,this.resubscribeBeforeunload(),this.subscription.add(n),n}attachToUi(e){this.uiEvents=e;let{subscribe:t,subscription:n}=Ra();t(e.actionSeek$,this.seekAction$),t(e.playerSize$,({width:e,height:t})=>{e&&t&&(this.playerSize={width:e,height:t},this.isStarted&&this.logViewPortChanged({player_width:e,player_height:t}))}),t(e.isLoaderVisible$,e=>{e&&this.isStarted&&this.logShowLoader()}),t(e.actionSubtitlesSwitched$,e=>{if(this.currentSubtitle={...e},this.isStarted){let t={subtitles_enabled:e.enabled,subtitles_track_lang:e.lang,auto_subtitles:e.auto};this.logSubtitlesSwitched(t)}});let{surface$:r}=si(this.uiEvents,t,this.player);return t(r,e=>{this.isStarted&&this.logModeChanged({mode:Fa(e)})}),t(e.actionQuality$,e=>{var t,n;let r=e=>pi.default(fi.default(Ai),e),i=(t=this.player)==null||(t=t.info.currentVideoStream$.getValue())==null?void 0:t.codec,a=(n=this.player)==null||(n=n.info.currentAudioStream$.getValue())==null?void 0:n.codec,o={user_quality:r(e)?`auto`:$(e),playback_quality:$(this.player?.info.currentQuality$.getValue()),download_quality:$(this.player?.info.currentQuality$.getValue()),codec_info:i&&a?`${i},${a}`:void 0};this.logQualityChangeRequested(o)}),this.resubscribeBeforeunload(),this.subscription.add(n),n}attachToAds(e){let{subscription:t,subscribe:n}=Ra();return n(e.init$,e=>{let t={slot:e};this.logAdvConfiguration(t)}),n(e.slotRequested$,()=>{this.logAdvRequest()}),n(e.started$,e=>{let t={adv_section:e};this.logAdvBreakStarted(t)}),n(e.ended$,e=>{let t={adv_section:e};this.logAdvBreakEnded(t)}),n(e.error$,e=>{let t={error_message:e};this.logAdvError(t)}),this.resubscribeBeforeunload(),this.subscription.add(t),t}getDeviceId(){return this.deviceId}resetViewSession(){this.thinOneStatDebugLog({message:`VSID reset`}),er.generateVSID(this.config.useVsid64),this.eventNumber=0}destroy(){this.api.destroy()}calcBufferTime(e){return e?Math.round((e.end??0)-(e.start??0))*1e3:void 0}createRequiredParams(e){let t=this.vsid$.getValue();mi(t);let n=this.eventNumber++,r=((this.isLive?this.player?.info.liveTime$.getValue():this.player?.info.position$.getValue())??0)*1e3,i={vsid:t,uv_movie_id:this.statContext.movieId,event_name:e,client_time:Date.now(),application:this.statContext.application??`@vkontakte/videoplayer-statistics:${ar}`,platform:this.statContext.platform??`web:${this.statContext.isMobile||X.device.isMobile?`mobile`:`desktop`}`,product:this.statContext.product,event_number:n,playback_position:r,current_tvt:this.getTotalViewTime(),cdn_host:this.cdnHostname};for(let e of this.config.disabledParams)delete i[e];return i}createRequiredFatParams(){let e={stats_version:`2.1.1`,browser:this.statContext.browser??X.browser.current,browser_version:this.statContext.browserVersion??String(X.browser.currentVersion),os:this.statContext.os??X.device.os.name,os_version:this.statContext.osVersion??X.device.os.version,device_type:this.statContext.deviceType??(this.statContext.isMobile||X.device.isMobile?`mobile`:`desktop`),device_manufacturer:this.statContext.deviceManufacturer??X.device.details.vendor,device_model:this.statContext.deviceModel??X.device.details.model,navigation:this.statContext.navigation};for(let t of this.config.disabledParams)delete e[t];return e}log(e,t,n=!1){if(yn(this.config.disabledEvents,e))return;let r=this.createRequiredParams(e),i={};n&&(i=this.createRequiredFatParams()),this.logger.log({...r,...i,...t})}logWatchCoverage(e){this.log(`watch_coverage`,e,!0)}logWatchCoverageLive(e){this.log(`watch_coverage_live`,e,!0)}logWatchedN(e){this.log(`watched_n`,e,!0)}logStartSession(e){this.log(`start_session`,e,!0)}logPreloadStarted(e){this.log(`preload_started`,e)}logPreloadEnded(e){this.log(`preload_ended`,e)}logPreloadError(){this.log(`preload_error`)}logPlaybackStarted(e){this.log(`playback_started`,e,!0)}logPlay(){this.log(`play`)}logManifestRequest(e){this.log(`manifest_request`,e)}logFirstByteManifest(e){this.log(`first_byte_manifest`,e)}logFirstMediaRequest(e){this.log(`first_media_request`,e)}logFirstByteMedia(e){this.log(`first_byte_media`,e)}logManifestReceived(e){this.log(`manifest_received`,e)}logConnectionEstablished(e){this.log(`connection_established`,e)}logFirstVideoFrameDecoded(){this.log(`first_video_frame_decoded`)}logReady(e){this.log(`ready`,e)}logPlaying(e){this.log(`playing`,e)}logPause(){this.log(`pause`)}logResume(){this.log(`resume`)}logSeeking(e){this.log(`seeking`,e)}logSeeked(e){this.log(`seeked`,e)}logStop(){this.log(`stop`)}logBufferStarvation(e){this.log(`buffer_starvation`,e)}logShowLoader(){this.log(`show_loader`)}logQualityChangeRequested(e){this.log(`quality_change_requested`,e)}logQualityChanged(e){this.log(`quality_changed`,e)}logCdnHostChanged(e){this.log(`cdn_host_changed`,e)}logViewPortChanged(e){this.log(`view_port_changed`,e)}logModeChanged(e){this.log(`mode_changed`,e)}logVisibilityChanged(e){this.log(`visibility_changed`,e)}logAudioTrackSwitched(e){this.log(`audio_track_switched`,e)}logVideoTrackSwitched(e){this.log(`video_track_switched`,e)}logSubtitlesSwitched(e){this.log(`subtitles_switched`,e)}logSoundChanged(e){this.log(`sound_changed`,e)}logFailover(e){this.log(`failover`,e)}logContentTypeChange(e){this.log(`content_type_change`,e)}logError(e){this.log(`error`,e,!0)}logCannotPlay(){this.log(`cannot_play`,{},!0)}logDownloadBytes(e){this.log(`download_bytes`,e)}logAdvConfiguration(e){this.log(`adv_configuration`,e)}logAdvRequest(){this.log(`adv_request`)}logAdvBreakStarted(e){this.log(`adv_break_started`,e)}logAdvBreakEnded(e){this.log(`adv_break_ended`,e)}logAdvError(e){this.log(`adv_error`,e)}resubscribeBeforeunload(){this.beforeunloadSubscription?.unsubscribe(),this.beforeunloadSubscription=gi(wi(),`beforeunload`).subscribe(()=>{}),this.subscription.add(this.beforeunloadSubscription)}}var Ba=(e,t={})=>{let n=t.timeout||1,r=performance.now();return G.setTimeout(()=>{e({get didTimeout(){return t.timeout?!1:performance.now()-r-1>n},timeRemaining(){return Math.max(0,1+(performance.now()-r))}})},1)},Va=e=>G.clearTimeout(e),Ha=e=>typeof e==`function`&&e?.toString().endsWith(`{ [native code] }`),Ua=!Ha(G.requestIdleCallback)||!Ha(G.cancelIdleCallback),Wa=Ua?Ba:G.requestIdleCallback,Ga=Ua?Va:G.cancelIdleCallback;import{PlaybackState as Ka,Subscription as qa}from"@vkontakte/videoplayer-core/es2018";import{Logger as Ja}from"@vkontakte/videoplayer-shared/es2018";class Ya{constructor(){e(this,`startTime`,null),e(this,`stopTime`,null),e(this,`accumulatedTime`,0)}get time(){return Math.floor(this.timeMs/1e3)}get timeMs(){return this.startTime===null?0:(this.stopTime??this.now())-this.startTime-this.accumulatedTime}get isRunning(){return this.startTime!==null&&this.stopTime===null}start(){this.isRunning||(this.stopTime===null?this.startTime=this.now():(this.accumulatedTime+=this.now()-this.stopTime,this.stopTime=null))}stop(){this.isRunning&&(this.stopTime=this.now())}reset(){this.startTime=null,this.stopTime=null,this.accumulatedTime=0}now(){return Date.now()}}var Xa=()=>window.Image?new Image:document.createElement(`img`);class Za{constructor(t){e(this,`params`,void 0),e(this,`position`,0),e(this,`started`,!1),e(this,`isActiveLive`,void 0),e(this,`heartbeatPixels`,[]),e(this,`heartbeatLastTimeSent`,{}),e(this,`heartbeatInterval`,void 0),e(this,`heartbeatFirstTimeoutId`,void 0),e(this,`idleCallbackIds`,[]),e(this,`log`,void 0),e(this,`stopwatch`,new Ya),e(this,`subscription`,new qa),this.params=t,this.log=new Ja().createComponentLog(`MediascopePixel`)}attachTo(e){this.subscription.add(e.info.playbackState$.subscribe(e=>this.onPlaybackState(e))).add(e.info.position$.subscribe(e=>this.onPosition(e))).add(e.info.atLiveEdge$.subscribe(e=>this.isActiveLive=e)),this.subscription.add(e.events.willSeek$.subscribe(()=>this.onWillSeek())).add(e.events.seeked$.subscribe(()=>this.onSeeked())).add(e.events.ended$.subscribe(()=>this.onEnded()))}destroy(){this.stopwatch.reset(),this.subscription.unsubscribe(),window.clearTimeout(this.heartbeatFirstTimeoutId),this.idleCallbackIds.forEach(e=>Ga(e)),this.send(`stop`)}onPlaybackState(e){e===Ka.PLAYING?this.started?this.play():this.start():e===Ka.PAUSED&&this.pause()}start(){this.started=!0,this.stopwatch.start(),this.send(`start`),this.heartbeatPixels=this.prepareHeartbeatPixels(),this.heartbeatInterval=this.heartbeatPixels[0]?.interval;let e=this.heartbeatPixels[0]?.url,t=this.heartbeatPixels[0]?.delay;if(t!==void 0&&e)try{this.heartbeatFirstTimeoutId=window.setTimeout(()=>{this.sendHeartbeat(e)},t*1e3)}catch(e){this.log({message:e.message})}}play(){this.stopwatch.start(),this.send(`resume`)}pause(){this.stopwatch.stop(),this.send(`pause`)}onPosition(e){if(this.position=e,this.heartbeatInterval&&this.stopwatch.time!==0&&this.stopwatch.time%this.heartbeatInterval===0)for(let[e,{url:t}]of this.heartbeatPixels.entries())this.heartbeatLastTimeSent[e]!==this.stopwatch.time&&(this.heartbeatLastTimeSent[e]=this.stopwatch.time,this.sendHeartbeat(t))}onWillSeek(){this.started&&this.send(`stop`)}onSeeked(){this.started&&this.send(`start`)}onEnded(){this.stopwatch.stop(),this.send(`stop`)}validatePixels(e,t){return e?.filter(e=>e.event===t.event&&t.keys.every(t=>!!e[t]))}getFrameTimestamp(){let e;if(this.isActiveLive){let t=Math.floor(Math.random()*25)+5;e=Date.now()/1e3-t}else e=this.position||0;return Math.floor(e)}getUTC(){return Math.floor(Date.now()/1e3)}prepareUrl(e){return e.replace(`{@fts_fake_sec}`,String(this.getFrameTimestamp())).replace(`{@utc_sec}`,String(this.getUTC())).split(`&`).filter(e=>!/={@[a-zA-Z_]+}/.test(e)).join(`&`)}preparePixels(e){return this.validatePixels(this.params.pixels,{event:e,keys:[`url`]})}prepareHeartbeatPixels(){return this.validatePixels(this.params.pixels,{event:`heartbeat`,keys:[`url`,`interval`]})}call(e){try{this.idleCallbackIds.push(Wa(()=>Xa().src=this.prepareUrl(e)))}catch(e){this.log({message:e.message})}}send(e){let t=this.preparePixels(e);for(let{url:e}of t)this.call(e)}sendHeartbeat(e){this.call(e)}}export{ar as VERSION,di as ThinOneStat,Tn as SeekAction,Sn as Quality,ui as OneStat,Za as MediascopePixel,En as InteractiveInterfaceClick,Cn as ContentType,wn as ConnectionType,xn as ApiEnv};