@vkontakte/videoplayer-statistics 1.0.34 → 1.0.35-dev.f578f79.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.
package/es2015.cjs.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @vkontakte/videoplayer-statistics v1.0.34
3
- * Mon, 17 Apr 2023 11:31:09 GMT
4
- * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-34/doc/
2
+ * @vkontakte/videoplayer-statistics v1.0.35-dev.f578f79.0
3
+ * Wed, 10 May 2023 11:40:54 GMT
4
+ * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-35/doc/
5
5
  */
6
- "use strict";var h=require("@vkontakte/videoplayer-shared/es2015.cjs.js"),f=require("@vkontakte/videoplayer-core/es2015.cjs.js"),ho=require("lodash/debounce.js");function w(e,r,t,n){function o(a){return a instanceof t?a:new t(function(i){i(a)})}return new(t||(t=Promise))(function(a,i){function v(c){try{s(n.next(c))}catch(l){i(l)}}function u(c){try{s(n.throw(c))}catch(l){i(l)}}function s(c){c.done?a(c.value):o(c.value).then(v,u)}s((n=n.apply(e,r||[])).next())})}var Hr=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},ue=function(e){return e&&e.Math==Math&&e},g=ue(typeof globalThis=="object"&&globalThis)||ue(typeof window=="object"&&window)||ue(typeof self=="object"&&self)||ue(typeof Hr=="object"&&Hr)||function(){return this}()||Function("return this")(),T=function(e){try{return!!e()}catch(r){return!0}},po=T,Ae=!po(function(){var e=function(){}.bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),yo=Ae,Xt=Function.prototype,qr=Xt.apply,Kr=Xt.call,Zt=typeof Reflect=="object"&&Reflect.apply||(yo?Kr.bind(qr):function(){return Kr.apply(qr,arguments)}),en=Ae,rn=Function.prototype,dr=rn.call,go=en&&rn.bind.bind(dr,dr),O=en?go:function(e){return function(){return dr.apply(e,arguments)}},tn=O,$o=tn({}.toString),bo=tn("".slice),Ne=function(e){return bo($o(e),8,-1)},mo=Ne,Eo=O,nn=function(e){if(mo(e)==="Function")return Eo(e)},hr=typeof document=="object"&&document.all,So=typeof hr=="undefined"&&hr!==void 0,on={all:hr,IS_HTMLDDA:So},an=on,To=an.all,y=an.IS_HTMLDDA?function(e){return typeof e=="function"||e===To}:function(e){return typeof e=="function"},Ir={},Oo=T,J=!Oo(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),_o=Ae,le=Function.prototype.call,_=_o?le.bind(le):function(){return le.apply(le,arguments)},sn={},cn={}.propertyIsEnumerable,un=Object.getOwnPropertyDescriptor,Po=un&&!cn.call({1:2},1);sn.f=Po?function(r){var t=un(this,r);return!!t&&t.enumerable}:cn;var ln=function(e,r){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:r}},Io=O,wo=T,Ro=Ne,xe=Object,Co=Io("".split),Ao=wo(function(){return!xe("z").propertyIsEnumerable(0)})?function(e){return Ro(e)=="String"?Co(e,""):xe(e)}:xe,De=function(e){return e==null},No=De,Do=TypeError,vn=function(e){if(No(e))throw Do("Can't call method on "+e);return e},jo=Ao,Lo=vn,Mo=function(e){return jo(Lo(e))},Qr=y,fn=on,Uo=fn.all,M=fn.IS_HTMLDDA?function(e){return typeof e=="object"?e!==null:Qr(e)||e===Uo}:function(e){return typeof e=="object"?e!==null:Qr(e)},dn={},Ve=dn,He=g,ko=y,Wr=function(e){return ko(e)?e:void 0},C=function(e,r){return arguments.length<2?Wr(Ve[e])||Wr(He[e]):Ve[e]&&Ve[e][r]||He[e]&&He[e][r]},Bo=O,wr=Bo({}.isPrototypeOf),je=typeof navigator!="undefined"&&String(navigator.userAgent)||"",hn=g,qe=je,Gr=hn.process,zr=hn.Deno,Yr=Gr&&Gr.versions||zr&&zr.version,Jr=Yr&&Yr.v8,E,Se;Jr&&(E=Jr.split("."),Se=E[0]>0&&E[0]<4?1:+(E[0]+E[1]));!Se&&qe&&(E=qe.match(/Edge\/(\d+)/),(!E||E[1]>=74)&&(E=qe.match(/Chrome\/(\d+)/),E&&(Se=+E[1])));var pn=Se,Xr=pn,Fo=T,yn=!!Object.getOwnPropertySymbols&&!Fo(function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&Xr&&Xr<41}),xo=yn,gn=xo&&!Symbol.sham&&typeof Symbol.iterator=="symbol",Vo=C,Ho=y,qo=wr,Ko=gn,Qo=Object,$n=Ko?function(e){return typeof e=="symbol"}:function(e){var r=Vo("Symbol");return Ho(r)&&qo(r.prototype,Qo(e))},Wo=String,Le=function(e){try{return Wo(e)}catch(r){return"Object"}},Go=y,zo=Le,Yo=TypeError,U=function(e){if(Go(e))return e;throw Yo(zo(e)+" is not a function")},Jo=U,Xo=De,Rr=function(e,r){var t=e[r];return Xo(t)?void 0:Jo(t)},Ke=_,Qe=y,We=M,Zo=TypeError,ea=function(e,r){var t,n;if(r==="string"&&Qe(t=e.toString)&&!We(n=Ke(t,e))||Qe(t=e.valueOf)&&!We(n=Ke(t,e))||r!=="string"&&Qe(t=e.toString)&&!We(n=Ke(t,e)))return n;throw Zo("Can't convert object to primitive value")},Te={},ra={get exports(){return Te},set exports(e){Te=e}},ie=!0,Zr=g,ta=Object.defineProperty,na=function(e,r){try{ta(Zr,e,{value:r,configurable:!0,writable:!0})}catch(t){Zr[e]=r}return r},oa=g,aa=na,et="__core-js_shared__",ia=oa[et]||aa(et,{}),Cr=ia,rt=Cr;(ra.exports=function(e,r){return rt[e]||(rt[e]=r!==void 0?r:{})})("versions",[]).push({version:"3.27.2",mode:"pure",copyright:"\xA9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.27.2/LICENSE",source:"https://github.com/zloirock/core-js"});var sa=vn,ca=Object,ua=function(e){return ca(sa(e))},la=O,va=ua,fa=la({}.hasOwnProperty),X=Object.hasOwn||function(r,t){return fa(va(r),t)},da=O,ha=0,pa=Math.random(),ya=da(1 .toString),bn=function(e){return"Symbol("+(e===void 0?"":e)+")_"+ya(++ha+pa,36)},ga=g,$a=Te,tt=X,ba=bn,ma=yn,Ea=gn,Q=ga.Symbol,Ge=$a("wks"),Sa=Ea?Q.for||Q:Q&&Q.withoutSetter||ba,P=function(e){return tt(Ge,e)||(Ge[e]=ma&&tt(Q,e)?Q[e]:Sa("Symbol."+e)),Ge[e]},Ta=_,nt=M,ot=$n,Oa=Rr,_a=ea,Pa=P,Ia=TypeError,wa=Pa("toPrimitive"),Ra=function(e,r){if(!nt(e)||ot(e))return e;var t=Oa(e,wa),n;if(t){if(r===void 0&&(r="default"),n=Ta(t,e,r),!nt(n)||ot(n))return n;throw Ia("Can't convert object to primitive value")}return r===void 0&&(r="number"),_a(e,r)},Ca=Ra,Aa=$n,mn=function(e){var r=Ca(e,"string");return Aa(r)?r:r+""},Na=g,at=M,pr=Na.document,Da=at(pr)&&at(pr.createElement),En=function(e){return Da?pr.createElement(e):{}},ja=J,La=T,Ma=En,Sn=!ja&&!La(function(){return Object.defineProperty(Ma("div"),"a",{get:function(){return 7}}).a!=7}),Ua=J,ka=_,Ba=sn,Fa=ln,xa=Mo,Va=mn,Ha=X,qa=Sn,it=Object.getOwnPropertyDescriptor;Ir.f=Ua?it:function(r,t){if(r=xa(r),t=Va(t),qa)try{return it(r,t)}catch(n){}if(Ha(r,t))return Fa(!ka(Ba.f,r,t),r[t])};var Ka=T,Qa=y,Wa=/#|\.prototype\./,se=function(e,r){var t=za[Ga(e)];return t==Ja?!0:t==Ya?!1:Qa(r)?Ka(r):!!r},Ga=se.normalize=function(e){return String(e).replace(Wa,".").toLowerCase()},za=se.data={},Ya=se.NATIVE="N",Ja=se.POLYFILL="P",Tn=se,st=nn,Xa=U,Za=Ae,ei=st(st.bind),Me=function(e,r){return Xa(e),r===void 0?e:Za?ei(e,r):function(){return e.apply(r,arguments)}},Ue={},ri=J,ti=T,ni=ri&&ti(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),oi=M,ai=String,ii=TypeError,k=function(e){if(oi(e))return e;throw ii(ai(e)+" is not an object")},si=J,ci=Sn,ui=ni,ve=k,ct=mn,li=TypeError,ze=Object.defineProperty,vi=Object.getOwnPropertyDescriptor,Ye="enumerable",Je="configurable",Xe="writable";Ue.f=si?ui?function(r,t,n){if(ve(r),t=ct(t),ve(n),typeof r=="function"&&t==="prototype"&&"value"in n&&Xe in n&&!n[Xe]){var o=vi(r,t);o&&o[Xe]&&(r[t]=n.value,n={configurable:Je in n?n[Je]:o[Je],enumerable:Ye in n?n[Ye]:o[Ye],writable:!1})}return ze(r,t,n)}:ze:function(r,t,n){if(ve(r),t=ct(t),ve(n),ci)try{return ze(r,t,n)}catch(o){}if("get"in n||"set"in n)throw li("Accessors not supported");return"value"in n&&(r[t]=n.value),r};var fi=J,di=Ue,hi=ln,ke=fi?function(e,r,t){return di.f(e,r,hi(1,t))}:function(e,r,t){return e[r]=t,e},fe=g,pi=Zt,yi=nn,gi=y,$i=Ir.f,bi=Tn,x=dn,mi=Me,V=ke,ut=X,Ei=function(e){var r=function(t,n,o){if(this instanceof r){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,n)}return new e(t,n,o)}return pi(e,this,arguments)};return r.prototype=e.prototype,r},B=function(e,r){var t=e.target,n=e.global,o=e.stat,a=e.proto,i=n?fe:o?fe[t]:(fe[t]||{}).prototype,v=n?x:x[t]||V(x,t,{})[t],u=v.prototype,s,c,l,p,d,m,A,I,F;for(p in r)s=bi(n?p:t+(o?".":"#")+p,e.forced),c=!s&&i&&ut(i,p),m=v[p],c&&(e.dontCallGetSet?(F=$i(i,p),A=F&&F.value):A=i[p]),d=c&&A?A:r[p],!(c&&typeof m==typeof d)&&(e.bind&&c?I=mi(d,fe):e.wrap&&c?I=Ei(d):a&&gi(d)?I=yi(d):I=d,(e.sham||d&&d.sham||m&&m.sham)&&V(I,"sham",!0),V(v,p,I),a&&(l=t+"Prototype",ut(x,l)||V(x,l,{}),V(x[l],p,d),e.real&&u&&(s||!u[p])&&V(u,p,d)))},Si=Ne,Be=typeof process!="undefined"&&Si(process)=="process",Ti=ke,Ar=function(e,r,t,n){return n&&n.enumerable?e[r]=t:Ti(e,r,t),e},Oi=y,_i=String,Pi=TypeError,Ii=function(e){if(typeof e=="object"||Oi(e))return e;throw Pi("Can't set "+_i(e)+" as a prototype")},wi=O,Ri=k,Ci=Ii,Ai=Object.setPrototypeOf||("__proto__"in{}?function(){var e=!1,r={},t;try{t=wi(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set),t(r,[]),e=r instanceof Array}catch(n){}return function(o,a){return Ri(o),Ci(a),e?t(o,a):o.__proto__=a,o}}():void 0),Ni=P,Di=Ni("toStringTag"),On={};On[Di]="z";var Nr=String(On)==="[object z]",ji=Nr,Li=y,be=Ne,Mi=P,Ui=Mi("toStringTag"),ki=Object,Bi=be(function(){return arguments}())=="Arguments",Fi=function(e,r){try{return e[r]}catch(t){}},Dr=ji?be:function(e){var r,t,n;return e===void 0?"Undefined":e===null?"Null":typeof(t=Fi(r=ki(e),Ui))=="string"?t:Bi?be(r):(n=be(r))=="Object"&&Li(r.callee)?"Arguments":n},xi=Nr,Vi=Dr,Hi=xi?{}.toString:function(){return"[object "+Vi(this)+"]"},qi=Nr,Ki=Ue.f,Qi=ke,Wi=X,Gi=Hi,zi=P,lt=zi("toStringTag"),Yi=function(e,r,t,n){if(e){var o=t?e:e.prototype;Wi(o,lt)||Ki(o,lt,{configurable:!0,value:r}),n&&!qi&&Qi(o,"toString",Gi)}},Ji=C,Xi=Ue,Zi=P,es=J,vt=Zi("species"),rs=function(e){var r=Ji(e),t=Xi.f;es&&r&&!r[vt]&&t(r,vt,{configurable:!0,get:function(){return this}})},ts=wr,ns=TypeError,os=function(e,r){if(ts(r,e))return e;throw ns("Incorrect invocation")},as=O,is=y,yr=Cr,ss=as(Function.toString);is(yr.inspectSource)||(yr.inspectSource=function(e){return ss(e)});var _n=yr.inspectSource,cs=O,us=T,Pn=y,ls=Dr,vs=C,fs=_n,In=function(){},ds=[],wn=vs("Reflect","construct"),jr=/^\s*(?:class|function)\b/,hs=cs(jr.exec),ps=!jr.exec(In),re=function(r){if(!Pn(r))return!1;try{return wn(In,ds,r),!0}catch(t){return!1}},Rn=function(r){if(!Pn(r))return!1;switch(ls(r)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return ps||!!hs(jr,fs(r))}catch(t){return!0}};Rn.sham=!0;var ys=!wn||us(function(){var e;return re(re.call)||!re(Object)||!re(function(){e=!0})||e})?Rn:re,gs=ys,$s=Le,bs=TypeError,ms=function(e){if(gs(e))return e;throw bs($s(e)+" is not a constructor")},ft=k,Es=ms,Ss=De,Ts=P,Os=Ts("species"),Cn=function(e,r){var t=ft(e).constructor,n;return t===void 0||Ss(n=ft(t)[Os])?r:Es(n)},_s=C,Ps=_s("document","documentElement"),Is=O,ws=Is([].slice),Rs=TypeError,Cs=function(e,r){if(e<r)throw Rs("Not enough arguments");return e},As=je,An=/(?:ipad|iphone|ipod).*applewebkit/i.test(As),$=g,Ns=Zt,Ds=Me,dt=y,js=X,Nn=T,ht=Ps,Ls=ws,pt=En,Ms=Cs,Us=An,ks=Be,gr=$.setImmediate,$r=$.clearImmediate,Bs=$.process,Ze=$.Dispatch,Fs=$.Function,yt=$.MessageChannel,xs=$.String,er=0,te={},gt="onreadystatechange",oe,N,rr,tr;Nn(function(){oe=$.location});var Lr=function(e){if(js(te,e)){var r=te[e];delete te[e],r()}},nr=function(e){return function(){Lr(e)}},$t=function(e){Lr(e.data)},bt=function(e){$.postMessage(xs(e),oe.protocol+"//"+oe.host)};(!gr||!$r)&&(gr=function(r){Ms(arguments.length,1);var t=dt(r)?r:Fs(r),n=Ls(arguments,1);return te[++er]=function(){Ns(t,void 0,n)},N(er),er},$r=function(r){delete te[r]},ks?N=function(e){Bs.nextTick(nr(e))}:Ze&&Ze.now?N=function(e){Ze.now(nr(e))}:yt&&!Us?(rr=new yt,tr=rr.port2,rr.port1.onmessage=$t,N=Ds(tr.postMessage,tr)):$.addEventListener&&dt($.postMessage)&&!$.importScripts&&oe&&oe.protocol!=="file:"&&!Nn(bt)?(N=bt,$.addEventListener("message",$t,!1)):gt in pt("script")?N=function(e){ht.appendChild(pt("script"))[gt]=function(){ht.removeChild(this),Lr(e)}}:N=function(e){setTimeout(nr(e),0)});var Dn={set:gr,clear:$r},jn=function(){this.head=null,this.tail=null};jn.prototype={add:function(e){var r={item:e,next:null},t=this.tail;t?t.next=r:this.head=r,this.tail=r},get:function(){var e=this.head;if(e){var r=this.head=e.next;return r===null&&(this.tail=null),e.item}}};var Ln=jn,Vs=je,Hs=/ipad|iphone|ipod/i.test(Vs)&&typeof Pebble!="undefined",qs=je,Ks=/web0s(?!.*chrome)/i.test(qs),L=g,mt=Me,Qs=Ir.f,or=Dn.set,Ws=Ln,Gs=An,zs=Hs,Ys=Ks,ar=Be,Et=L.MutationObserver||L.WebKitMutationObserver,St=L.document,Tt=L.process,de=L.Promise,Ot=Qs(L,"queueMicrotask"),br=Ot&&Ot.value,H,ir,sr,he,_t;if(!br){var pe=new Ws,ye=function(){var e,r;for(ar&&(e=Tt.domain)&&e.exit();r=pe.get();)try{r()}catch(t){throw pe.head&&H(),t}e&&e.enter()};!Gs&&!ar&&!Ys&&Et&&St?(ir=!0,sr=St.createTextNode(""),new Et(ye).observe(sr,{characterData:!0}),H=function(){sr.data=ir=!ir}):!zs&&de&&de.resolve?(he=de.resolve(void 0),he.constructor=de,_t=mt(he.then,he),H=function(){_t(ye)}):ar?H=function(){Tt.nextTick(ye)}:(or=mt(or,L),H=function(){or(ye)}),br=function(e){pe.head||H(),pe.add(e)}}var Js=br,Xs=function(e,r){try{arguments.length==1?console.error(e):console.error(e,r)}catch(t){}},Mr=function(e){try{return{error:!1,value:e()}}catch(r){return{error:!0,value:r}}},Zs=g,ec=y,Pt=Zs.WeakMap,rc=ec(Pt)&&/native code/.test(String(Pt)),tc=Te,nc=bn,It=tc("keys"),oc=function(e){return It[e]||(It[e]=nc(e))},ac={},ic=rc,Mn=g,sc=M,cc=ke,cr=X,ur=Cr,uc=oc,lc=ac,wt="Object already initialized",mr=Mn.TypeError,vc=Mn.WeakMap,Oe,ae,_e,fc=function(e){return _e(e)?ae(e):Oe(e,{})},dc=function(e){return function(r){var t;if(!sc(r)||(t=ae(r)).type!==e)throw mr("Incompatible receiver, "+e+" required");return t}};if(ic||ur.state){var S=ur.state||(ur.state=new vc);S.get=S.get,S.has=S.has,S.set=S.set,Oe=function(e,r){if(S.has(e))throw mr(wt);return r.facade=e,S.set(e,r),r},ae=function(e){return S.get(e)||{}},_e=function(e){return S.has(e)}}else{var q=uc("state");lc[q]=!0,Oe=function(e,r){if(cr(e,q))throw mr(wt);return r.facade=e,cc(e,q,r),r},ae=function(e){return cr(e,q)?e[q]:{}},_e=function(e){return cr(e,q)}}var hc={set:Oe,get:ae,has:_e,enforce:fc,getterFor:dc},pc=g,Z=pc.Promise,Un=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",yc=Un,gc=Be,$c=!yc&&!gc&&typeof window=="object"&&typeof document=="object",bc=g,ne=Z,mc=y,Ec=Tn,Sc=_n,Tc=P,Oc=$c,_c=Un,Pc=ie,lr=pn,Rt=ne&&ne.prototype,Ic=Tc("species"),Er=!1,kn=mc(bc.PromiseRejectionEvent),wc=Ec("Promise",function(){var e=Sc(ne),r=e!==String(ne);if(!r&&lr===66||Pc&&!(Rt.catch&&Rt.finally))return!0;if(!lr||lr<51||!/native code/.test(e)){var t=new ne(function(a){a(1)}),n=function(a){a(function(){},function(){})},o=t.constructor={};if(o[Ic]=n,Er=t.then(function(){})instanceof n,!Er)return!0}return!r&&(Oc||_c)&&!kn}),ce={CONSTRUCTOR:wc,REJECTION_EVENT:kn,SUBCLASSING:Er},ee={},Ct=U,Rc=TypeError,Cc=function(e){var r,t;this.promise=new e(function(n,o){if(r!==void 0||t!==void 0)throw Rc("Bad Promise constructor");r=n,t=o}),this.resolve=Ct(r),this.reject=Ct(t)};ee.f=function(e){return new Cc(e)};var Ac=B,Nc=ie,Pe=Be,R=g,z=_,At=Ar,Nt=Ai,Dc=Yi,jc=rs,Lc=U,me=y,Mc=M,Uc=os,kc=Cn,Bn=Dn.set,Ur=Js,Bc=Xs,Fc=Mr,xc=Ln,Fn=hc,Ie=Z,kr=ce,xn=ee,Fe="Promise",Vn=kr.CONSTRUCTOR,Vc=kr.REJECTION_EVENT,Hc=kr.SUBCLASSING,vr=Fn.getterFor(Fe),qc=Fn.set,K=Ie&&Ie.prototype,D=Ie,ge=K,Hn=R.TypeError,Sr=R.document,Br=R.process,Tr=xn.f,Kc=Tr,Qc=!!(Sr&&Sr.createEvent&&R.dispatchEvent),qn="unhandledrejection",Wc="rejectionhandled",Dt=0,Kn=1,Gc=2,Fr=1,Qn=2,$e,jt,zc,Lt,Wn=function(e){var r;return Mc(e)&&me(r=e.then)?r:!1},Gn=function(e,r){var t=r.value,n=r.state==Kn,o=n?e.ok:e.fail,a=e.resolve,i=e.reject,v=e.domain,u,s,c;try{o?(n||(r.rejection===Qn&&Jc(r),r.rejection=Fr),o===!0?u=t:(v&&v.enter(),u=o(t),v&&(v.exit(),c=!0)),u===e.promise?i(Hn("Promise-chain cycle")):(s=Wn(u))?z(s,u,a,i):a(u)):i(t)}catch(l){v&&!c&&v.exit(),i(l)}},zn=function(e,r){e.notified||(e.notified=!0,Ur(function(){for(var t=e.reactions,n;n=t.get();)Gn(n,e);e.notified=!1,r&&!e.rejection&&Yc(e)}))},Yn=function(e,r,t){var n,o;Qc?(n=Sr.createEvent("Event"),n.promise=r,n.reason=t,n.initEvent(e,!1,!0),R.dispatchEvent(n)):n={promise:r,reason:t},!Vc&&(o=R["on"+e])?o(n):e===qn&&Bc("Unhandled promise rejection",t)},Yc=function(e){z(Bn,R,function(){var r=e.facade,t=e.value,n=Mt(e),o;if(n&&(o=Fc(function(){Pe?Br.emit("unhandledRejection",t,r):Yn(qn,r,t)}),e.rejection=Pe||Mt(e)?Qn:Fr,o.error))throw o.value})},Mt=function(e){return e.rejection!==Fr&&!e.parent},Jc=function(e){z(Bn,R,function(){var r=e.facade;Pe?Br.emit("rejectionHandled",r):Yn(Wc,r,e.value)})},W=function(e,r,t){return function(n){e(r,n,t)}},G=function(e,r,t){e.done||(e.done=!0,t&&(e=t),e.value=r,e.state=Gc,zn(e,!0))},Or=function(e,r,t){if(!e.done){e.done=!0,t&&(e=t);try{if(e.facade===r)throw Hn("Promise can't be resolved itself");var n=Wn(r);n?Ur(function(){var o={done:!1};try{z(n,r,W(Or,o,e),W(G,o,e))}catch(a){G(o,a,e)}}):(e.value=r,e.state=Kn,zn(e,!1))}catch(o){G({done:!1},o,e)}}};if(Vn&&(D=function(r){Uc(this,ge),Lc(r),z($e,this);var t=vr(this);try{r(W(Or,t),W(G,t))}catch(n){G(t,n)}},ge=D.prototype,$e=function(r){qc(this,{type:Fe,done:!1,notified:!1,parent:!1,reactions:new xc,rejection:!1,state:Dt,value:void 0})},$e.prototype=At(ge,"then",function(r,t){var n=vr(this),o=Tr(kc(this,D));return n.parent=!0,o.ok=me(r)?r:!0,o.fail=me(t)&&t,o.domain=Pe?Br.domain:void 0,n.state==Dt?n.reactions.add(o):Ur(function(){Gn(o,n)}),o.promise}),jt=function(){var e=new $e,r=vr(e);this.promise=e,this.resolve=W(Or,r),this.reject=W(G,r)},xn.f=Tr=function(e){return e===D||e===zc?new jt(e):Kc(e)},!Nc&&me(Ie)&&K!==Object.prototype)){Lt=K.then,Hc||At(K,"then",function(r,t){var n=this;return new D(function(o,a){z(Lt,n,o,a)}).then(r,t)},{unsafe:!0});try{delete K.constructor}catch(e){}Nt&&Nt(K,ge)}Ac({global:!0,constructor:!0,wrap:!0,forced:Vn},{Promise:D});Dc(D,Fe,!1,!0);jc(Fe);var Jn={},Xc=P,Zc=Jn,eu=Xc("iterator"),ru=Array.prototype,tu=function(e){return e!==void 0&&(Zc.Array===e||ru[eu]===e)},nu=Math.ceil,ou=Math.floor,au=Math.trunc||function(r){var t=+r;return(t>0?ou:nu)(t)},iu=au,su=function(e){var r=+e;return r!==r||r===0?0:iu(r)},cu=su,uu=Math.min,lu=function(e){return e>0?uu(cu(e),9007199254740991):0},vu=lu,fu=function(e){return vu(e.length)},du=Dr,Ut=Rr,hu=De,pu=Jn,yu=P,gu=yu("iterator"),Xn=function(e){if(!hu(e))return Ut(e,gu)||Ut(e,"@@iterator")||pu[du(e)]},$u=_,bu=U,mu=k,Eu=Le,Su=Xn,Tu=TypeError,Ou=function(e,r){var t=arguments.length<2?Su(e):r;if(bu(t))return mu($u(t,e));throw Tu(Eu(e)+" is not iterable")},_u=_,kt=k,Pu=Rr,Iu=function(e,r,t){var n,o;kt(e);try{if(n=Pu(e,"return"),!n){if(r==="throw")throw t;return t}n=_u(n,e)}catch(a){o=!0,n=a}if(r==="throw")throw t;if(o)throw n;return kt(n),t},wu=Me,Ru=_,Cu=k,Au=Le,Nu=tu,Du=fu,Bt=wr,ju=Ou,Lu=Xn,Ft=Iu,Mu=TypeError,Ee=function(e,r){this.stopped=e,this.result=r},xt=Ee.prototype,Zn=function(e,r,t){var n=t&&t.that,o=!!(t&&t.AS_ENTRIES),a=!!(t&&t.IS_RECORD),i=!!(t&&t.IS_ITERATOR),v=!!(t&&t.INTERRUPTED),u=wu(r,n),s,c,l,p,d,m,A,I=function(b){return s&&Ft(s,"normal",b),new Ee(!0,b)},F=function(b){return o?(Cu(b),v?u(b[0],b[1],I):u(b[0],b[1])):v?u(b,I):u(b)};if(a)s=e.iterator;else if(i)s=e;else{if(c=Lu(e),!c)throw Mu(Au(e)+" is not iterable");if(Nu(c)){for(l=0,p=Du(e);p>l;l++)if(d=F(e[l]),d&&Bt(xt,d))return d;return new Ee(!1)}s=ju(e,c)}for(m=a?e.next:s.next;!(A=Ru(m,s)).done;){try{d=F(A.value)}catch(b){Ft(s,"throw",b)}if(typeof d=="object"&&d&&Bt(xt,d))return d}return new Ee(!1)},Uu=P,eo=Uu("iterator"),ro=!1;try{var ku=0,Vt={next:function(){return{done:!!ku++}},return:function(){ro=!0}};Vt[eo]=function(){return this},Array.from(Vt,function(){throw 2})}catch(e){}var Bu=function(e,r){if(!r&&!ro)return!1;var t=!1;try{var n={};n[eo]=function(){return{next:function(){return{done:t=!0}}}},e(n)}catch(o){}return t},Fu=Z,xu=Bu,Vu=ce.CONSTRUCTOR,to=Vu||!xu(function(e){Fu.all(e).then(void 0,function(){})}),Hu=B,qu=_,Ku=U,Qu=ee,Wu=Mr,Gu=Zn,zu=to;Hu({target:"Promise",stat:!0,forced:zu},{all:function(r){var t=this,n=Qu.f(t),o=n.resolve,a=n.reject,i=Wu(function(){var v=Ku(t.resolve),u=[],s=0,c=1;Gu(r,function(l){var p=s++,d=!1;c++,qu(v,t,l).then(function(m){d||(d=!0,u[p]=m,--c||o(u))},a)}),--c||o(u)});return i.error&&a(i.value),n.promise}});var Yu=B,Ju=ie,Xu=ce.CONSTRUCTOR,_r=Z,Zu=C,el=y,rl=Ar,Ht=_r&&_r.prototype;Yu({target:"Promise",proto:!0,forced:Xu,real:!0},{catch:function(e){return this.then(void 0,e)}});if(!Ju&&el(_r)){var qt=Zu("Promise").prototype.catch;Ht.catch!==qt&&rl(Ht,"catch",qt,{unsafe:!0})}var tl=B,nl=_,ol=U,al=ee,il=Mr,sl=Zn,cl=to;tl({target:"Promise",stat:!0,forced:cl},{race:function(r){var t=this,n=al.f(t),o=n.reject,a=il(function(){var i=ol(t.resolve);sl(r,function(v){nl(i,t,v).then(n.resolve,o)})});return a.error&&o(a.value),n.promise}});var ul=B,ll=_,vl=ee,fl=ce.CONSTRUCTOR;ul({target:"Promise",stat:!0,forced:fl},{reject:function(r){var t=vl.f(this);return ll(t.reject,void 0,r),t.promise}});var dl=k,hl=M,pl=ee,no=function(e,r){if(dl(e),hl(r)&&r.constructor===e)return r;var t=pl.f(e),n=t.resolve;return n(r),t.promise},yl=B,gl=C,oo=ie,$l=Z,ao=ce.CONSTRUCTOR,bl=no,ml=gl("Promise"),El=oo&&!ao;yl({target:"Promise",stat:!0,forced:oo||ao},{resolve:function(r){return bl(El&&this===ml?$l:this,r)}});var Sl=B,Tl=ie,we=Z,Ol=T,io=C,so=y,_l=Cn,Kt=no,Pl=Ar,Pr=we&&we.prototype,Il=!!we&&Ol(function(){Pr.finally.call({then:function(){}},function(){})});Sl({target:"Promise",proto:!0,real:!0,forced:Il},{finally:function(e){var r=_l(this,io("Promise")),t=so(e);return this.then(t?function(n){return Kt(r,e()).then(function(){return n})}:e,t?function(n){return Kt(r,e()).then(function(){throw n})}:e)}});if(!Tl&&so(we)){var Qt=io("Promise").prototype.finally;Pr.finally!==Qt&&Pl(Pr,"finally",Qt,{unsafe:!0})}var wl=C,Rl=wl,Cl=Rl,Al=Cl("Promise","finally"),Nl=Al,Dl=Nl,jl=Dl,Ll=jl,fr=Ll;const xr="_one-stat_",Y=(()=>{try{const e=Date.now().toString(),r=window.localStorage;r.setItem(e,e);const t=r.getItem(e)===e;return r.removeItem(e),t?r:null}catch(e){return null}})();function Ml(e){const r=Y?Y.getItem(xr+e):null;if(r===null)return null;try{return JSON.parse(r)}catch(t){return null}}function Ul(e,r){try{Y&&Y.setItem(xr+e,JSON.stringify(r))}catch(t){}}function kl(e){Y&&Y.removeItem(xr+e)}var Wt={get(e){return Ml(e)||null},set(e,r){Ul(e,r)},remove(e){kl(e)}};function Bl(){const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),r=new Array(36);let t=0,n,o;for(o=0;o<36;o++)o===8||o===13||o===18||o===23?r[o]="-":o===14?r[o]="4":(t<=2&&(t=33554432+Math.random()*16777216|0),n=t&15,t=t>>4,r[o]=e[o===19?n&3|8:n]);return r.join("")}exports.ApiEnv=void 0;(function(e){e.PROD="prod",e.VK_ALIAS="vk_alias",e.VIDEOTEST="videotest",e.TEST="test",e.AUTO="auto"})(exports.ApiEnv||(exports.ApiEnv={}));exports.Quality=void 0;(function(e){e.Q144P="144",e.Q240P="240",e.Q360P="360",e.Q480P="480",e.Q720P="720",e.Q1080P="1080",e.Q1440P="1440",e.Q2160P="2160",e.Q4320P="4320",e.UNKNOWN="unknown"})(exports.Quality||(exports.Quality={}));exports.ScreenDestination=void 0;(function(e){e.CHROMECAST="chromecast",e.APPLE_TV="appletv",e.PIP="pip",e.HEADPHONES="externalHeadphones",e.SCREEN=""})(exports.ScreenDestination||(exports.ScreenDestination={}));exports.ContentType=void 0;(function(e){e.MP4="mp4",e.DASH="dash",e.DASH_SEP="dash_sep",e.ONDEMAND_DASH="ondemand_dash",e.HLS="hls",e.ONDEMAND_HLS="ondemand_hls",e.WEBM="webm",e.RTMP="rtmp",e.UNKNOWN="unknown"})(exports.ContentType||(exports.ContentType={}));var Re;(function(e){e.AUTO="auto",e.MANUAL=""})(Re||(Re={}));exports.ConnectionType=void 0;(function(e){e.HTTP1="http1",e.HTTP2="http2",e.HTTP3="http3"})(exports.ConnectionType||(exports.ConnectionType={}));var Ce;(function(e){e[e.YES=1]="YES",e[e.NO=0]="NO"})(Ce||(Ce={}));const Gt="1.0.34",Fl="es2015.cjs.js",xl="CIOPGQJGDIHBABABA",co={[exports.ApiEnv.PROD]:"https://api.ok.ru",[exports.ApiEnv.VK_ALIAS]:"https://api.mycdn.me",[exports.ApiEnv.VIDEOTEST]:"https://videotestapi.ok.ru/api",[exports.ApiEnv.TEST]:"https://apitest.ok.ru",[exports.ApiEnv.AUTO]:""},Vl={start:1e3,factor:1.5,max:5*60*1e3,random:.1};var j;(function(e){e[e.PARAM_SESSION_EXPIRED=102]="PARAM_SESSION_EXPIRED",e[e.PARAM_SESSION_KEY=103]="PARAM_SESSION_KEY",e[e.PARAM_SIGNATURE=104]="PARAM_SIGNATURE",e[e.AUTH_LOGIN=401]="AUTH_LOGIN"})(j||(j={}));class Hl{constructor(r){this.consequentAuthErrors=0,this.authorized$=new h.ValueSubject(!1),this.params=r;const t=Wt.get("uuid");t?this.uuid=String(t):(this.uuid=Bl(),Wt.set("uuid",this.uuid))}authorize(r){return w(this,void 0,void 0,function*(){return this.authToken=r!=null?r:yield this.refreshAuthToken(),this._authorizeWithBackoff()})}logBeacon(r){const t="log.externalLog",n=this.createLogParams(r),o=this.sessionKey;if(!o)return;this.params.apiTransport.sendBeacon(t,n,o)||this.logRequest(r)}logRequest(r){var t;return w(this,void 0,void 0,function*(){const n="log.externalLog",o=this.createLogParams(r),a=(t=this.sessionKey)!==null&&t!==void 0?t:yield this._authorizeWithBackoff();if(!a)return;const i=(v,u=this.params.requestRetryCount)=>w(this,void 0,void 0,function*(){try{return yield this.params.apiTransport.sendRequest(n,o,a)}catch(s){if(!s||!("error_code"in s)){this.params.error$.next({id:"logRequestUnknown",category:h.ErrorCategory.NETWORK,message:`Unknown ${n} error`,thrown:s});return}const c=s==null?void 0:s.error_code;switch(c){case j.PARAM_SESSION_EXPIRED:case j.PARAM_SESSION_KEY:case j.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=yield this._authorizeWithBackoff(),u>0?i(v,u-1):void 0;case j.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=yield this.refreshAuthToken(),this.sessionKey=yield this._authorizeWithBackoff(),u>0?i(v,u-1):void 0;default:{this.params.error$.next({id:`LogRequest#${c}`,category:h.ErrorCategory.EXTERNAL_API,message:`${n} error`,data:s});return}}}});return i(r)})}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}refreshAuthToken(){return w(this,void 0,void 0,function*(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=fr(this.params.refreshAuthToken(),()=>{this.refreshAuthTokenPromise=void 0})),this.refreshAuthTokenPromise})}createLogParams(r){return{collector:"ok.mobile.apps.video",data:JSON.stringify({application:`${Fl}:${Gt}`,platform:"WEB",items:r.map(t=>Object.assign(Object.assign({},t),{time:0,type:1}))})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const r=h.getExponentialDelay(this.consequentAuthErrors,Vl);return new Promise(t=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout(()=>{fr(this._authorize().then(t).catch(n=>this.params.error$.next({id:"AuthorizeBackoff",category:h.ErrorCategory.NETWORK,message:"Otherwise unhandle errror in authrization",thrown:n})),()=>this.backoffTimeoutId=0)},r))})}_authorize(){return w(this,void 0,void 0,function*(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const r="auth.anonymLogin",t={session_data:{version:2,device_id:this.uuid,client_version:Gt.split("-")[0],client_type:"SDK_JS"}};return this.authToken!==void 0&&(t.session_data.auth_token=this.authToken,t.session_data.version=3),this.authorizePromise=fr(this.params.apiTransport.sendRequest(r,t).then(n=>{var o;return(!n||!n.session_key)&&this.params.error$.next({id:"AuthorizeFailed",category:h.ErrorCategory.EXTERNAL_API,message:"No session key",data:n}),this.sessionKey=(o=n==null?void 0:n.session_key)!==null&&o!==void 0?o:void 0,this.sessionKey}).catch(n=>w(this,void 0,void 0,function*(){this.sessionKey=void 0;const o=n==null?void 0:n.error_code;switch(o){case j.AUTH_LOGIN:return this.authToken=yield this.refreshAuthToken(),this._authorizeWithBackoff()}o?this.params.error$.next({id:`Authorize#${o}`,category:h.ErrorCategory.EXTERNAL_API,message:"authorize error",data:n}):this.params.error$.next({id:"AuthorizeUnknown",category:h.ErrorCategory.NETWORK,message:"authorize error",thrown:n})})),()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise})}}class zt{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(r,t,n){r in this.listeners||(this.listeners[r]=[]),this.listeners[r].push({callback:t,options:n})}removeEventListener(r,t){if(!(r in this.listeners))return;const n=this.listeners[r];for(let o=0,a=n.length;o<a;o++)if(n[o].callback===t){n.splice(o,1);return}}dispatchEvent(r){if(!(r.type in this.listeners))return;const n=this.listeners[r.type].slice();for(let o=0,a=n.length;o<a;o++){const i=n[o];try{i.callback.call(this,r)}catch(v){Promise.resolve().then(()=>{throw v})}i.options&&i.options.once&&this.removeEventListener(r.type,i.callback)}return!r.defaultPrevented}}class uo extends zt{constructor(){super(),this.listeners||zt.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(r){r.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,r)),super.dispatchEvent(r)}}class ql{constructor(){Object.defineProperty(this,"signal",{value:new uo,writable:!0,configurable:!0})}abort(r){let t;try{t=new Event("abort")}catch(o){typeof document!="undefined"?document.createEvent?(t=document.createEvent("Event"),t.initEvent("abort",!1,!1)):(t=document.createEventObject(),t.type="abort"):t={type:"abort",bubbles:!1,cancelable:!1}}let n=r;if(n===void 0)if(typeof document=="undefined")n=new Error("This operation was aborted"),n.name="AbortError";else try{n=new DOMException("signal is aborted without reason")}catch(o){n=new Error("This operation was aborted"),n.name="AbortError"}this.signal.reason=n,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}}typeof Symbol!="undefined"&&Symbol.toStringTag&&(ql.prototype[Symbol.toStringTag]="AbortController",uo.prototype[Symbol.toStringTag]="AbortSignal");function lo(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 Kl(e){typeof e=="function"&&(e={fetch:e});const{fetch:r,Request:t=r.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o=!1}=e;if(!lo({fetch:r,Request:t,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:r,Request:a};let a=t;(a&&!a.prototype.hasOwnProperty("signal")||o)&&(a=function(s,c){let l;c&&c.signal&&(l=c.signal,delete c.signal);const p=new t(s,c);return l&&Object.defineProperty(p,"signal",{writable:!1,enumerable:!1,configurable:!0,value:l}),p},a.prototype=t.prototype);const i=r;return{fetch:(u,s)=>{const c=a&&a.prototype.isPrototypeOf(u)?u.signal:s?s.signal:void 0;if(c){let l;try{l=new DOMException("Aborted","AbortError")}catch(d){l=new Error("Aborted"),l.name="AbortError"}if(c.aborted)return Promise.reject(l);const p=new Promise((d,m)=>{c.addEventListener("abort",()=>m(l),{once:!0})});return s&&s.signal&&delete s.signal,Promise.race([p,i(u,s)])}return i(u,s)},Request:a}}const Vr=lo({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),vo=Vr?Kl({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Yt=Vr?vo.fetch:window.fetch;Vr?vo.Request:window.Request;class Ql{constructor(r){this.params=r,this.apiKey=r.apiKey,this.apiEnv=r.apiEnv,this.apiBaseUrl=r.apiBaseUrl,this.timeSynchronisation=r.timeSynchronisation,this.isApiBaseUrlFetched=!1}resolveApiBaseUrl(){var r;return w(this,void 0,void 0,function*(){if(this.apiEnv!==exports.ApiEnv.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const t=atob("aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ="),o=yield(yield Yt(t,{method:"GET",mode:"cors",cache:"no-cache"})).json(),a=(r=o==null?void 0:o.Answer[0])===null||r===void 0?void 0:r.data;if(!a)throw new Error("Wrong DNS response");return a}catch(t){return this.params.error$.next({id:"OneStat:ApiTransport:resolveApiBaseUrl",category:h.ErrorCategory.NETWORK,message:"Unhandled resolve api base url error",thrown:t}),co[exports.ApiEnv.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}})}sendBeacon(r,t,n){if(!window.Blob||!window.navigator.sendBeacon)return!1;const o=this._prepareQueryParams({method:r,queryParams:t,sessionKey:n}),a=new window.Blob([o.toString()],{type:"application/x-www-form-urlencoded"});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,a)}catch(i){this.params.error$.next({id:"OneStat:ApiTransport:sendBeacon",category:h.ErrorCategory.NETWORK,message:"Unhandled beacon error",thrown:i,data:{method:r,params:t}})}return!1}sendRequest(r,t,n){return w(this,void 0,void 0,function*(){const o=h.now(),a=i=>{if(i instanceof TypeError&&["Failed to fetch","NetworkError when attempting to fetch resource."].includes(i.message)){this.params.error$.next({id:"Network",category:h.ErrorCategory.NETWORK,message:"Request failed",thrown:i});return}this.params.error$.next({id:"OneStat:ApiTransport:sendRequest",category:h.ErrorCategory.NETWORK,message:"Unhandled request error",thrown:i,data:{method:r,params:t,sessionKey:n,time:h.now()-o}})};return this.apiBaseUrl=yield this.resolveApiBaseUrl(),Yt(`${this.apiBaseUrl}/fb.do`,{method:"post",headers:{"Content-type":"application/x-www-form-urlencoded"},body:this._prepareQueryParams({method:r,queryParams:t,sessionKey:n})}).then(i=>{var v;const u=Number(i.headers.get("content-length"))===0,s=new Date((v=i.headers.get("date"))!==null&&v!==void 0?v:"").getTime(),c=h.now()-o;if(isFinite(s)&&this.timeSynchronisation.addServerTime(s,c),!u)return i.json().then(l=>Object.prototype.hasOwnProperty.call(l,"error_msg")?Promise.reject(l):l,a)},a)})}_prepareQueryParams(r){const t=new URLSearchParams({format:"JSON",method:r.method,application_key:this.apiKey});return r.sessionKey!==void 0&&t.append("session_key",r.sessionKey),Object.entries(r.queryParams).forEach(([n,o])=>t.append(n,typeof o=="string"?o:JSON.stringify(o))),t}}const fo=3e3,Wl=fo*5;class Gl{constructor(r){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=ho(()=>{var t;try{this.flush()}catch(n){this.error$.next({id:"LoggerError",category:h.ErrorCategory.WTF,message:(t=String(n))!==null&&t!==void 0?t:"Unknown logger error",thrown:n})}},fo,{maxWait:Wl}),this.api=r.api,this.error$=r.error$,this.subscription=this.api.authorized$.subscribe(t=>{t&&this.debouncedFlush()})}log(r){this.requestQueue.push(r),this.isPaused||this.debouncedFlush()}flush(r=!1){this.requestQueue.length!==0&&(this.api.authorized$.getValue()?(r?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[]):this.api.authorize(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe()}}class zl{constructor(r){this.offset=void 0,this.offset=r}getOffset(){var r;return(r=this.offset)!==null&&r!==void 0?r:0}setOffset(r){this.offset=r}now(){var r;return Date.now()+((r=this.offset)!==null&&r!==void 0?r:0)}date(r=new Date){var t;return r.setTime(r.getTime()+((t=this.offset)!==null&&t!==void 0?t:0)),r}addServerTime(r,t){const n=Date.now(),o=r-n-t/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)}}const Jt=()=>Math.floor(Math.random()*Math.pow(2,32)).toString(36).padStart(8,"0"),Yl=e=>e&&{[f.VideoQuality.INVARIANT]:exports.Quality.UNKNOWN,[f.VideoQuality.Q_144P]:exports.Quality.Q144P,[f.VideoQuality.Q_240P]:exports.Quality.Q240P,[f.VideoQuality.Q_360P]:exports.Quality.Q360P,[f.VideoQuality.Q_480P]:exports.Quality.Q480P,[f.VideoQuality.Q_720P]:exports.Quality.Q720P,[f.VideoQuality.Q_1080P]:exports.Quality.Q1080P,[f.VideoQuality.Q_1440P]:exports.Quality.Q1440P,[f.VideoQuality.Q_2160P]:exports.Quality.Q2160P,[f.VideoQuality.Q_4320P]:exports.Quality.Q4320P}[e],Jl=e=>e&&{[f.HttpConnectionType.HTTP1]:exports.ConnectionType.HTTP1,[f.HttpConnectionType.HTTP2]:exports.ConnectionType.HTTP2,[f.HttpConnectionType.QUIC]:exports.ConnectionType.HTTP3}[e],Xl=e=>{if(e!==void 0)switch(e){case f.VideoFormat.MPEG:return exports.ContentType.MP4;case f.VideoFormat.DASH:case f.VideoFormat.DASH_LIVE:case f.VideoFormat.DASH_LIVE_CMAF:return exports.ContentType.DASH;case f.VideoFormat.DASH_SEP:return exports.ContentType.DASH_SEP;case f.VideoFormat.DASH_ONDEMAND:return exports.ContentType.ONDEMAND_DASH;case f.VideoFormat.DASH_WEBM:case f.VideoFormat.DASH_LIVE_WEBM:return exports.ContentType.WEBM;case f.VideoFormat.HLS:case f.VideoFormat.HLS_LIVE:case f.VideoFormat.HLS_LIVE_CMAF:return exports.ContentType.HLS;case f.VideoFormat.HLS_ONDEMAND:return exports.ContentType.ONDEMAND_HLS;case f.VideoFormat.WEB_RTC_LIVE:return exports.ContentType.RTMP;default:return h.assertNever(e)}};class Zl{constructor(r,t){var n;this.subscription=new h.Subscription,this.timeSynchronisation=new zl,this.vsid=Jt(),this.fieldBlacklist=[],this.statContext=r,this.config=Object.assign(Object.assign({},(n=t.config)!==null&&n!==void 0?n:{}),{requestRetryCount:1});const o=new h.Subject;this.experimental={error$:o};const a=new Ql({apiKey:xl,apiBaseUrl:co[t.apiEnv],apiEnv:t.apiEnv,error$:o,timeSynchronisation:this.timeSynchronisation});this.api=new Hl({apiTransport:a,refreshAuthToken:t.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:o}),this.logger=new Gl({api:this.api,error$:o}),this.subscription.add(h.fromEvent(window,"beforeunload").subscribe(()=>this.logger.flush(!0)))}updateContext(r){this.statContext=Object.assign(Object.assign({},this.statContext),r)}attachTo(r){let t;return new h.Subscription().add(r.events.started$.subscribe(()=>{this.logStarted({position:r.info.position$.getValue()})})).add(r.events.looped$.subscribe(()=>{this.resetViewSession(),this.logStarted({position:r.info.position$.getValue()})})).add(r.events.seeked$.subscribe(()=>{this.logSeek()})).add(r.events.willPause$.subscribe(()=>{this.logPause({position:r.info.position$.getValue()})})).add(r.events.willResume$.subscribe(()=>{this.logPlay()})).add(r.events.managedError$.subscribe(({id:n})=>{this.logError({errorType:n})})).add(r.events.fatalError$.subscribe(({id:n})=>{this.logError({errorType:n})})).add(r.events.inited$.subscribe(()=>{this.logInited()})).add(r.events.canplay$.subscribe(n=>{this.logReady({time:n})})).add(r.events.firstBytes$.subscribe(n=>{this.logFirstBytes({time:n})})).add(r.events.firstFrame$.subscribe(n=>{this.logFirstFrame({time:n})})).add(r.events.watchCoverageRecord$.subscribe(n=>{this.logWatchCoverageRecord(n)})).add(r.events.watchCoverageLive$.subscribe(n=>{this.logWatchCoverageLive(n)})).add(r.info.isStalled$.subscribe(n=>{n?t=h.now():(h.isNonNullable(t)&&this.logEmptyBuffer({duration:h.now()-t}),t=void 0)})).add(r.events.ended$.subscribe(()=>{const n=r.info.throughputEstimation$.getValue();h.isNonNullable(n)&&this.logDownloadSpeed({speed:n/8})})).add(r.info.hostname$.subscribe(n=>{this.updateContext({cdnHostname:n})})).add(r.info.httpConnectionType$.subscribe(n=>{this.updateContext({connectionType:Jl(n)})})).add(r.info.httpConnectionReused$.subscribe(n=>{this.updateContext({connectionReused:n})})).add(r.info.currentQuality$.subscribe(n=>{this.updateContext({quality:Yl(n)})})).add(r.info.currentFormat$.subscribe(n=>{this.updateContext({contentType:Xl(n)})})).add(r.info.chromecastState$.subscribe(n=>{this.updateContext({destination:n===f.ChromecastState.CONNECTED?exports.ScreenDestination.CHROMECAST:exports.ScreenDestination.SCREEN})}))}authorize(r){return this.api.authorize(r)}pause(){this.logger.pause()}resume(){this.logger.resume()}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}resetViewSession(){this.vsid=Jt()}setFieldBlacklist(r=[]){this.fieldBlacklist=r}logInited(){this.log({operation:"init"})}logReady(r){this.log({operation:"player_ready",param:String(r.time)})}logStarted(r){this.log({operation:"play",param:String(Math.round(r.position))})}logPlay(){this.log({operation:"play_toggle"})}logPause(r){this.log({operation:"pause",param:String(Math.round(r.position))})}logSeek(){this.log({operation:"seek"})}logFirstBytes(r){this.log({operation:"first_bytes",param:String(r.time)})}logFirstFrame(r){this.log({operation:"first_frame",param:String(r.time)})}logError(r){this.log({operation:"error",param:r.errorType})}logWatchCoverageRecord(r){this.log({operation:"watch_coverage_record",param:`${r.start}-${r.end}`}),this.logger.flush(!0)}logWatchCoverageLive(r){const t=r.start+this.timeSynchronisation.getOffset(),n=r.end+this.timeSynchronisation.getOffset();this.log({operation:"watch_coverage_live",param:`${t}-${n}`}),this.logger.flush(!0)}logEmptyBuffer(r){this.log({operation:"empty_buffer",param:String(r.duration)})}logDownloadSpeed(r){this.log({operation:"download_speed",param:String(r.speed)})}logAdSlotRequest(){this.log({operation:"adv",param:"slot_request"})}logAdStarted(r){this.log({operation:"adv",param:r})}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"})}log(r){const t=this.createLogItem(r);this.logger.log(t)}createLogItem({operation:r,param:t}){const n=this.timeSynchronisation.now(),o={vsid:this.vsid,vid:this.statContext.movieId,quality:this.statContext.quality,dst:this.statContext.destination,ct:this.statContext.contentType,aid:this.statContext.albumId,place:this.statContext.place,cdn_host:this.statContext.cdnHostname,connection_type:this.statContext.connectionType,connection_reused:this.statContext.connectionReused===!0?Ce.YES:this.statContext.connectionReused===!1?Ce.NO:void 0,stat_type:this.statContext.autoplay===!0?Re.AUTO:this.statContext.autoplay===!1?Re.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode};t!==void 0&&(o.param=t);for(const a of this.fieldBlacklist)delete o[a];return{operation:r,timestamp:n,custom:o}}}exports.OneStat=Zl;
6
+ "use strict";var s=require("@vkontakte/videoplayer-shared/es2015.cjs.js"),yo=require("lodash/debounce.js"),p=require("@vkontakte/videoplayer-core/es2015.cjs.js");function I(e,r,t,n){function o(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function v(i){try{u(n.next(i))}catch(l){c(l)}}function f(i){try{u(n.throw(i))}catch(l){c(l)}}function u(i){i.done?a(i.value):o(i.value).then(v,f)}u((n=n.apply(e,r||[])).next())})}var Hr=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},fe=function(e){return e&&e.Math==Math&&e},g=fe(typeof globalThis=="object"&&globalThis)||fe(typeof window=="object"&&window)||fe(typeof self=="object"&&self)||fe(typeof Hr=="object"&&Hr)||function(){return this}()||Function("return this")(),T=function(e){try{return!!e()}catch(r){return!0}},bo=T,Ne=!bo(function(){var e=function(){}.bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),go=Ne,en=Function.prototype,Kr=en.apply,Wr=en.call,rn=typeof Reflect=="object"&&Reflect.apply||(go?Wr.bind(Kr):function(){return Wr.apply(Kr,arguments)}),tn=Ne,nn=Function.prototype,pr=nn.call,$o=tn&&nn.bind.bind(pr,pr),_=tn?$o:function(e){return function(){return pr.apply(e,arguments)}},on=_,mo=on({}.toString),Eo=on("".slice),De=function(e){return Eo(mo(e),8,-1)},So=De,To=_,an=function(e){if(So(e)==="Function")return To(e)},yr=typeof document=="object"&&document.all,_o=typeof yr=="undefined"&&yr!==void 0,sn={all:yr,IS_HTMLDDA:_o},cn=sn,Oo=cn.all,y=cn.IS_HTMLDDA?function(e){return typeof e=="function"||e===Oo}:function(e){return typeof e=="function"},Ir={},Po=T,Z=!Po(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),wo=Ne,ve=Function.prototype.call,O=wo?ve.bind(ve):function(){return ve.apply(ve,arguments)},un={},ln={}.propertyIsEnumerable,fn=Object.getOwnPropertyDescriptor,Co=fn&&!ln.call({1:2},1);un.f=Co?function(r){var t=fn(this,r);return!!t&&t.enumerable}:ln;var vn=function(e,r){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:r}},Io=_,Ro=T,Ao=De,Ve=Object,No=Io("".split),Do=Ro(function(){return!Ve("z").propertyIsEnumerable(0)})?function(e){return Ao(e)=="String"?No(e,""):Ve(e)}:Ve,Le=function(e){return e==null},Lo=Le,jo=TypeError,dn=function(e){if(Lo(e))throw jo("Can't call method on "+e);return e},xo=Do,Uo=dn,ko=function(e){return xo(Uo(e))},Qr=y,hn=sn,Mo=hn.all,k=hn.IS_HTMLDDA?function(e){return typeof e=="object"?e!==null:Qr(e)||e===Mo}:function(e){return typeof e=="object"?e!==null:Qr(e)},pn={},qe=pn,He=g,Bo=y,Gr=function(e){return Bo(e)?e:void 0},A=function(e,r){return arguments.length<2?Gr(qe[e])||Gr(He[e]):qe[e]&&qe[e][r]||He[e]&&He[e][r]},Fo=_,Rr=Fo({}.isPrototypeOf),je=typeof navigator!="undefined"&&String(navigator.userAgent)||"",yn=g,Ke=je,zr=yn.process,Yr=yn.Deno,Jr=zr&&zr.versions||Yr&&Yr.version,Xr=Jr&&Jr.v8,E,_e;Xr&&(E=Xr.split("."),_e=E[0]>0&&E[0]<4?1:+(E[0]+E[1]));!_e&&Ke&&(E=Ke.match(/Edge\/(\d+)/),(!E||E[1]>=74)&&(E=Ke.match(/Chrome\/(\d+)/),E&&(_e=+E[1])));var bn=_e,Zr=bn,Vo=T,gn=!!Object.getOwnPropertySymbols&&!Vo(function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&Zr&&Zr<41}),qo=gn,$n=qo&&!Symbol.sham&&typeof Symbol.iterator=="symbol",Ho=A,Ko=y,Wo=Rr,Qo=$n,Go=Object,mn=Qo?function(e){return typeof e=="symbol"}:function(e){var r=Ho("Symbol");return Ko(r)&&Wo(r.prototype,Go(e))},zo=String,xe=function(e){try{return zo(e)}catch(r){return"Object"}},Yo=y,Jo=xe,Xo=TypeError,M=function(e){if(Yo(e))return e;throw Xo(Jo(e)+" is not a function")},Zo=M,ei=Le,Ar=function(e,r){var t=e[r];return ei(t)?void 0:Zo(t)},We=O,Qe=y,Ge=k,ri=TypeError,ti=function(e,r){var t,n;if(r==="string"&&Qe(t=e.toString)&&!Ge(n=We(t,e))||Qe(t=e.valueOf)&&!Ge(n=We(t,e))||r!=="string"&&Qe(t=e.toString)&&!Ge(n=We(t,e)))return n;throw ri("Can't convert object to primitive value")},Oe={},ni={get exports(){return Oe},set exports(e){Oe=e}},ce=!0,et=g,oi=Object.defineProperty,ii=function(e,r){try{oi(et,e,{value:r,configurable:!0,writable:!0})}catch(t){et[e]=r}return r},ai=g,si=ii,rt="__core-js_shared__",ci=ai[rt]||si(rt,{}),Nr=ci,tt=Nr;(ni.exports=function(e,r){return tt[e]||(tt[e]=r!==void 0?r:{})})("versions",[]).push({version:"3.27.2",mode:"pure",copyright:"\xA9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.27.2/LICENSE",source:"https://github.com/zloirock/core-js"});var ui=dn,li=Object,fi=function(e){return li(ui(e))},vi=_,di=fi,hi=vi({}.hasOwnProperty),ee=Object.hasOwn||function(r,t){return hi(di(r),t)},pi=_,yi=0,bi=Math.random(),gi=pi(1 .toString),En=function(e){return"Symbol("+(e===void 0?"":e)+")_"+gi(++yi+bi,36)},$i=g,mi=Oe,nt=ee,Ei=En,Si=gn,Ti=$n,G=$i.Symbol,ze=mi("wks"),_i=Ti?G.for||G:G&&G.withoutSetter||Ei,P=function(e){return nt(ze,e)||(ze[e]=Si&&nt(G,e)?G[e]:_i("Symbol."+e)),ze[e]},Oi=O,ot=k,it=mn,Pi=Ar,wi=ti,Ci=P,Ii=TypeError,Ri=Ci("toPrimitive"),Ai=function(e,r){if(!ot(e)||it(e))return e;var t=Pi(e,Ri),n;if(t){if(r===void 0&&(r="default"),n=Oi(t,e,r),!ot(n)||it(n))return n;throw Ii("Can't convert object to primitive value")}return r===void 0&&(r="number"),wi(e,r)},Ni=Ai,Di=mn,Sn=function(e){var r=Ni(e,"string");return Di(r)?r:r+""},Li=g,at=k,br=Li.document,ji=at(br)&&at(br.createElement),Tn=function(e){return ji?br.createElement(e):{}},xi=Z,Ui=T,ki=Tn,_n=!xi&&!Ui(function(){return Object.defineProperty(ki("div"),"a",{get:function(){return 7}}).a!=7}),Mi=Z,Bi=O,Fi=un,Vi=vn,qi=ko,Hi=Sn,Ki=ee,Wi=_n,st=Object.getOwnPropertyDescriptor;Ir.f=Mi?st:function(r,t){if(r=qi(r),t=Hi(t),Wi)try{return st(r,t)}catch(n){}if(Ki(r,t))return Vi(!Bi(Fi.f,r,t),r[t])};var Qi=T,Gi=y,zi=/#|\.prototype\./,ue=function(e,r){var t=Ji[Yi(e)];return t==Zi?!0:t==Xi?!1:Gi(r)?Qi(r):!!r},Yi=ue.normalize=function(e){return String(e).replace(zi,".").toLowerCase()},Ji=ue.data={},Xi=ue.NATIVE="N",Zi=ue.POLYFILL="P",On=ue,ct=an,ea=M,ra=Ne,ta=ct(ct.bind),Ue=function(e,r){return ea(e),r===void 0?e:ra?ta(e,r):function(){return e.apply(r,arguments)}},ke={},na=Z,oa=T,ia=na&&oa(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),aa=k,sa=String,ca=TypeError,B=function(e){if(aa(e))return e;throw ca(sa(e)+" is not an object")},ua=Z,la=_n,fa=ia,de=B,ut=Sn,va=TypeError,Ye=Object.defineProperty,da=Object.getOwnPropertyDescriptor,Je="enumerable",Xe="configurable",Ze="writable";ke.f=ua?fa?function(r,t,n){if(de(r),t=ut(t),de(n),typeof r=="function"&&t==="prototype"&&"value"in n&&Ze in n&&!n[Ze]){var o=da(r,t);o&&o[Ze]&&(r[t]=n.value,n={configurable:Xe in n?n[Xe]:o[Xe],enumerable:Je in n?n[Je]:o[Je],writable:!1})}return Ye(r,t,n)}:Ye:function(r,t,n){if(de(r),t=ut(t),de(n),la)try{return Ye(r,t,n)}catch(o){}if("get"in n||"set"in n)throw va("Accessors not supported");return"value"in n&&(r[t]=n.value),r};var ha=Z,pa=ke,ya=vn,Me=ha?function(e,r,t){return pa.f(e,r,ya(1,t))}:function(e,r,t){return e[r]=t,e},he=g,ba=rn,ga=an,$a=y,ma=Ir.f,Ea=On,q=pn,Sa=Ue,H=Me,lt=ee,Ta=function(e){var r=function(t,n,o){if(this instanceof r){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,n)}return new e(t,n,o)}return ba(e,this,arguments)};return r.prototype=e.prototype,r},F=function(e,r){var t=e.target,n=e.global,o=e.stat,a=e.proto,c=n?he:o?he[t]:(he[t]||{}).prototype,v=n?q:q[t]||H(q,t,{})[t],f=v.prototype,u,i,l,d,h,b,N,w,V;for(d in r)u=Ea(n?d:t+(o?".":"#")+d,e.forced),i=!u&&c&&lt(c,d),b=v[d],i&&(e.dontCallGetSet?(V=ma(c,d),N=V&&V.value):N=c[d]),h=i&&N?N:r[d],!(i&&typeof b==typeof h)&&(e.bind&&i?w=Sa(h,he):e.wrap&&i?w=Ta(h):a&&$a(h)?w=ga(h):w=h,(e.sham||h&&h.sham||b&&b.sham)&&H(w,"sham",!0),H(v,d,w),a&&(l=t+"Prototype",lt(q,l)||H(q,l,{}),H(q[l],d,h),e.real&&f&&(u||!f[d])&&H(f,d,h)))},_a=De,Be=typeof process!="undefined"&&_a(process)=="process",Oa=Me,Dr=function(e,r,t,n){return n&&n.enumerable?e[r]=t:Oa(e,r,t),e},Pa=y,wa=String,Ca=TypeError,Ia=function(e){if(typeof e=="object"||Pa(e))return e;throw Ca("Can't set "+wa(e)+" as a prototype")},Ra=_,Aa=B,Na=Ia,Da=Object.setPrototypeOf||("__proto__"in{}?function(){var e=!1,r={},t;try{t=Ra(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set),t(r,[]),e=r instanceof Array}catch(n){}return function(o,a){return Aa(o),Na(a),e?t(o,a):o.__proto__=a,o}}():void 0),La=P,ja=La("toStringTag"),Pn={};Pn[ja]="z";var Lr=String(Pn)==="[object z]",xa=Lr,Ua=y,Ee=De,ka=P,Ma=ka("toStringTag"),Ba=Object,Fa=Ee(function(){return arguments}())=="Arguments",Va=function(e,r){try{return e[r]}catch(t){}},jr=xa?Ee:function(e){var r,t,n;return e===void 0?"Undefined":e===null?"Null":typeof(t=Va(r=Ba(e),Ma))=="string"?t:Fa?Ee(r):(n=Ee(r))=="Object"&&Ua(r.callee)?"Arguments":n},qa=Lr,Ha=jr,Ka=qa?{}.toString:function(){return"[object "+Ha(this)+"]"},Wa=Lr,Qa=ke.f,Ga=Me,za=ee,Ya=Ka,Ja=P,ft=Ja("toStringTag"),Xa=function(e,r,t,n){if(e){var o=t?e:e.prototype;za(o,ft)||Qa(o,ft,{configurable:!0,value:r}),n&&!Wa&&Ga(o,"toString",Ya)}},Za=A,es=ke,rs=P,ts=Z,vt=rs("species"),ns=function(e){var r=Za(e),t=es.f;ts&&r&&!r[vt]&&t(r,vt,{configurable:!0,get:function(){return this}})},os=Rr,is=TypeError,as=function(e,r){if(os(r,e))return e;throw is("Incorrect invocation")},ss=_,cs=y,gr=Nr,us=ss(Function.toString);cs(gr.inspectSource)||(gr.inspectSource=function(e){return us(e)});var wn=gr.inspectSource,ls=_,fs=T,Cn=y,vs=jr,ds=A,hs=wn,In=function(){},ps=[],Rn=ds("Reflect","construct"),xr=/^\s*(?:class|function)\b/,ys=ls(xr.exec),bs=!xr.exec(In),ne=function(r){if(!Cn(r))return!1;try{return Rn(In,ps,r),!0}catch(t){return!1}},An=function(r){if(!Cn(r))return!1;switch(vs(r)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return bs||!!ys(xr,hs(r))}catch(t){return!0}};An.sham=!0;var gs=!Rn||fs(function(){var e;return ne(ne.call)||!ne(Object)||!ne(function(){e=!0})||e})?An:ne,$s=gs,ms=xe,Es=TypeError,Ss=function(e){if($s(e))return e;throw Es(ms(e)+" is not a constructor")},dt=B,Ts=Ss,_s=Le,Os=P,Ps=Os("species"),Nn=function(e,r){var t=dt(e).constructor,n;return t===void 0||_s(n=dt(t)[Ps])?r:Ts(n)},ws=A,Cs=ws("document","documentElement"),Is=_,Rs=Is([].slice),As=TypeError,Ns=function(e,r){if(e<r)throw As("Not enough arguments");return e},Ds=je,Dn=/(?:ipad|iphone|ipod).*applewebkit/i.test(Ds),$=g,Ls=rn,js=Ue,ht=y,xs=ee,Ln=T,pt=Cs,Us=Rs,yt=Tn,ks=Ns,Ms=Dn,Bs=Be,$r=$.setImmediate,mr=$.clearImmediate,Fs=$.process,er=$.Dispatch,Vs=$.Function,bt=$.MessageChannel,qs=$.String,rr=0,oe={},gt="onreadystatechange",ae,D,tr,nr;Ln(function(){ae=$.location});var Ur=function(e){if(xs(oe,e)){var r=oe[e];delete oe[e],r()}},or=function(e){return function(){Ur(e)}},$t=function(e){Ur(e.data)},mt=function(e){$.postMessage(qs(e),ae.protocol+"//"+ae.host)};(!$r||!mr)&&($r=function(r){ks(arguments.length,1);var t=ht(r)?r:Vs(r),n=Us(arguments,1);return oe[++rr]=function(){Ls(t,void 0,n)},D(rr),rr},mr=function(r){delete oe[r]},Bs?D=function(e){Fs.nextTick(or(e))}:er&&er.now?D=function(e){er.now(or(e))}:bt&&!Ms?(tr=new bt,nr=tr.port2,tr.port1.onmessage=$t,D=js(nr.postMessage,nr)):$.addEventListener&&ht($.postMessage)&&!$.importScripts&&ae&&ae.protocol!=="file:"&&!Ln(mt)?(D=mt,$.addEventListener("message",$t,!1)):gt in yt("script")?D=function(e){pt.appendChild(yt("script"))[gt]=function(){pt.removeChild(this),Ur(e)}}:D=function(e){setTimeout(or(e),0)});var jn={set:$r,clear:mr},xn=function(){this.head=null,this.tail=null};xn.prototype={add:function(e){var r={item:e,next:null},t=this.tail;t?t.next=r:this.head=r,this.tail=r},get:function(){var e=this.head;if(e){var r=this.head=e.next;return r===null&&(this.tail=null),e.item}}};var Un=xn,Hs=je,Ks=/ipad|iphone|ipod/i.test(Hs)&&typeof Pebble!="undefined",Ws=je,Qs=/web0s(?!.*chrome)/i.test(Ws),U=g,Et=Ue,Gs=Ir.f,ir=jn.set,zs=Un,Ys=Dn,Js=Ks,Xs=Qs,ar=Be,St=U.MutationObserver||U.WebKitMutationObserver,Tt=U.document,_t=U.process,pe=U.Promise,Ot=Gs(U,"queueMicrotask"),Er=Ot&&Ot.value,K,sr,cr,ye,Pt;if(!Er){var be=new zs,ge=function(){var e,r;for(ar&&(e=_t.domain)&&e.exit();r=be.get();)try{r()}catch(t){throw be.head&&K(),t}e&&e.enter()};!Ys&&!ar&&!Xs&&St&&Tt?(sr=!0,cr=Tt.createTextNode(""),new St(ge).observe(cr,{characterData:!0}),K=function(){cr.data=sr=!sr}):!Js&&pe&&pe.resolve?(ye=pe.resolve(void 0),ye.constructor=pe,Pt=Et(ye.then,ye),K=function(){Pt(ge)}):ar?K=function(){_t.nextTick(ge)}:(ir=Et(ir,U),K=function(){ir(ge)}),Er=function(e){be.head||K(),be.add(e)}}var Zs=Er,ec=function(e,r){try{arguments.length==1?console.error(e):console.error(e,r)}catch(t){}},kr=function(e){try{return{error:!1,value:e()}}catch(r){return{error:!0,value:r}}},rc=g,tc=y,wt=rc.WeakMap,nc=tc(wt)&&/native code/.test(String(wt)),oc=Oe,ic=En,Ct=oc("keys"),ac=function(e){return Ct[e]||(Ct[e]=ic(e))},sc={},cc=nc,kn=g,uc=k,lc=Me,ur=ee,lr=Nr,fc=ac,vc=sc,It="Object already initialized",Sr=kn.TypeError,dc=kn.WeakMap,Pe,se,we,hc=function(e){return we(e)?se(e):Pe(e,{})},pc=function(e){return function(r){var t;if(!uc(r)||(t=se(r)).type!==e)throw Sr("Incompatible receiver, "+e+" required");return t}};if(cc||lr.state){var S=lr.state||(lr.state=new dc);S.get=S.get,S.has=S.has,S.set=S.set,Pe=function(e,r){if(S.has(e))throw Sr(It);return r.facade=e,S.set(e,r),r},se=function(e){return S.get(e)||{}},we=function(e){return S.has(e)}}else{var W=fc("state");vc[W]=!0,Pe=function(e,r){if(ur(e,W))throw Sr(It);return r.facade=e,lc(e,W,r),r},se=function(e){return ur(e,W)?e[W]:{}},we=function(e){return ur(e,W)}}var yc={set:Pe,get:se,has:we,enforce:hc,getterFor:pc},bc=g,re=bc.Promise,Mn=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",gc=Mn,$c=Be,mc=!gc&&!$c&&typeof window=="object"&&typeof document=="object",Ec=g,ie=re,Sc=y,Tc=On,_c=wn,Oc=P,Pc=mc,wc=Mn,Cc=ce,fr=bn,Rt=ie&&ie.prototype,Ic=Oc("species"),Tr=!1,Bn=Sc(Ec.PromiseRejectionEvent),Rc=Tc("Promise",function(){var e=_c(ie),r=e!==String(ie);if(!r&&fr===66||Cc&&!(Rt.catch&&Rt.finally))return!0;if(!fr||fr<51||!/native code/.test(e)){var t=new ie(function(a){a(1)}),n=function(a){a(function(){},function(){})},o=t.constructor={};if(o[Ic]=n,Tr=t.then(function(){})instanceof n,!Tr)return!0}return!r&&(Pc||wc)&&!Bn}),le={CONSTRUCTOR:Rc,REJECTION_EVENT:Bn,SUBCLASSING:Tr},te={},At=M,Ac=TypeError,Nc=function(e){var r,t;this.promise=new e(function(n,o){if(r!==void 0||t!==void 0)throw Ac("Bad Promise constructor");r=n,t=o}),this.resolve=At(r),this.reject=At(t)};te.f=function(e){return new Nc(e)};var Dc=F,Lc=ce,Ce=Be,R=g,X=O,Nt=Dr,Dt=Da,jc=Xa,xc=ns,Uc=M,Se=y,kc=k,Mc=as,Bc=Nn,Fn=jn.set,Mr=Zs,Fc=ec,Vc=kr,qc=Un,Vn=yc,Ie=re,Br=le,qn=te,Fe="Promise",Hn=Br.CONSTRUCTOR,Hc=Br.REJECTION_EVENT,Kc=Br.SUBCLASSING,vr=Vn.getterFor(Fe),Wc=Vn.set,Q=Ie&&Ie.prototype,L=Ie,$e=Q,Kn=R.TypeError,_r=R.document,Fr=R.process,Or=qn.f,Qc=Or,Gc=!!(_r&&_r.createEvent&&R.dispatchEvent),Wn="unhandledrejection",zc="rejectionhandled",Lt=0,Qn=1,Yc=2,Vr=1,Gn=2,me,jt,Jc,xt,zn=function(e){var r;return kc(e)&&Se(r=e.then)?r:!1},Yn=function(e,r){var t=r.value,n=r.state==Qn,o=n?e.ok:e.fail,a=e.resolve,c=e.reject,v=e.domain,f,u,i;try{o?(n||(r.rejection===Gn&&Zc(r),r.rejection=Vr),o===!0?f=t:(v&&v.enter(),f=o(t),v&&(v.exit(),i=!0)),f===e.promise?c(Kn("Promise-chain cycle")):(u=zn(f))?X(u,f,a,c):a(f)):c(t)}catch(l){v&&!i&&v.exit(),c(l)}},Jn=function(e,r){e.notified||(e.notified=!0,Mr(function(){for(var t=e.reactions,n;n=t.get();)Yn(n,e);e.notified=!1,r&&!e.rejection&&Xc(e)}))},Xn=function(e,r,t){var n,o;Gc?(n=_r.createEvent("Event"),n.promise=r,n.reason=t,n.initEvent(e,!1,!0),R.dispatchEvent(n)):n={promise:r,reason:t},!Hc&&(o=R["on"+e])?o(n):e===Wn&&Fc("Unhandled promise rejection",t)},Xc=function(e){X(Fn,R,function(){var r=e.facade,t=e.value,n=Ut(e),o;if(n&&(o=Vc(function(){Ce?Fr.emit("unhandledRejection",t,r):Xn(Wn,r,t)}),e.rejection=Ce||Ut(e)?Gn:Vr,o.error))throw o.value})},Ut=function(e){return e.rejection!==Vr&&!e.parent},Zc=function(e){X(Fn,R,function(){var r=e.facade;Ce?Fr.emit("rejectionHandled",r):Xn(zc,r,e.value)})},z=function(e,r,t){return function(n){e(r,n,t)}},J=function(e,r,t){e.done||(e.done=!0,t&&(e=t),e.value=r,e.state=Yc,Jn(e,!0))},Pr=function(e,r,t){if(!e.done){e.done=!0,t&&(e=t);try{if(e.facade===r)throw Kn("Promise can't be resolved itself");var n=zn(r);n?Mr(function(){var o={done:!1};try{X(n,r,z(Pr,o,e),z(J,o,e))}catch(a){J(o,a,e)}}):(e.value=r,e.state=Qn,Jn(e,!1))}catch(o){J({done:!1},o,e)}}};if(Hn&&(L=function(r){Mc(this,$e),Uc(r),X(me,this);var t=vr(this);try{r(z(Pr,t),z(J,t))}catch(n){J(t,n)}},$e=L.prototype,me=function(r){Wc(this,{type:Fe,done:!1,notified:!1,parent:!1,reactions:new qc,rejection:!1,state:Lt,value:void 0})},me.prototype=Nt($e,"then",function(r,t){var n=vr(this),o=Or(Bc(this,L));return n.parent=!0,o.ok=Se(r)?r:!0,o.fail=Se(t)&&t,o.domain=Ce?Fr.domain:void 0,n.state==Lt?n.reactions.add(o):Mr(function(){Yn(o,n)}),o.promise}),jt=function(){var e=new me,r=vr(e);this.promise=e,this.resolve=z(Pr,r),this.reject=z(J,r)},qn.f=Or=function(e){return e===L||e===Jc?new jt(e):Qc(e)},!Lc&&Se(Ie)&&Q!==Object.prototype)){xt=Q.then,Kc||Nt(Q,"then",function(r,t){var n=this;return new L(function(o,a){X(xt,n,o,a)}).then(r,t)},{unsafe:!0});try{delete Q.constructor}catch(e){}Dt&&Dt(Q,$e)}Dc({global:!0,constructor:!0,wrap:!0,forced:Hn},{Promise:L});jc(L,Fe,!1,!0);xc(Fe);var Zn={},eu=P,ru=Zn,tu=eu("iterator"),nu=Array.prototype,ou=function(e){return e!==void 0&&(ru.Array===e||nu[tu]===e)},iu=Math.ceil,au=Math.floor,su=Math.trunc||function(r){var t=+r;return(t>0?au:iu)(t)},cu=su,uu=function(e){var r=+e;return r!==r||r===0?0:cu(r)},lu=uu,fu=Math.min,vu=function(e){return e>0?fu(lu(e),9007199254740991):0},du=vu,hu=function(e){return du(e.length)},pu=jr,kt=Ar,yu=Le,bu=Zn,gu=P,$u=gu("iterator"),eo=function(e){if(!yu(e))return kt(e,$u)||kt(e,"@@iterator")||bu[pu(e)]},mu=O,Eu=M,Su=B,Tu=xe,_u=eo,Ou=TypeError,Pu=function(e,r){var t=arguments.length<2?_u(e):r;if(Eu(t))return Su(mu(t,e));throw Ou(Tu(e)+" is not iterable")},wu=O,Mt=B,Cu=Ar,Iu=function(e,r,t){var n,o;Mt(e);try{if(n=Cu(e,"return"),!n){if(r==="throw")throw t;return t}n=wu(n,e)}catch(a){o=!0,n=a}if(r==="throw")throw t;if(o)throw n;return Mt(n),t},Ru=Ue,Au=O,Nu=B,Du=xe,Lu=ou,ju=hu,Bt=Rr,xu=Pu,Uu=eo,Ft=Iu,ku=TypeError,Te=function(e,r){this.stopped=e,this.result=r},Vt=Te.prototype,ro=function(e,r,t){var n=t&&t.that,o=!!(t&&t.AS_ENTRIES),a=!!(t&&t.IS_RECORD),c=!!(t&&t.IS_ITERATOR),v=!!(t&&t.INTERRUPTED),f=Ru(r,n),u,i,l,d,h,b,N,w=function(m){return u&&Ft(u,"normal",m),new Te(!0,m)},V=function(m){return o?(Nu(m),v?f(m[0],m[1],w):f(m[0],m[1])):v?f(m,w):f(m)};if(a)u=e.iterator;else if(c)u=e;else{if(i=Uu(e),!i)throw ku(Du(e)+" is not iterable");if(Lu(i)){for(l=0,d=ju(e);d>l;l++)if(h=V(e[l]),h&&Bt(Vt,h))return h;return new Te(!1)}u=xu(e,i)}for(b=a?e.next:u.next;!(N=Au(b,u)).done;){try{h=V(N.value)}catch(m){Ft(u,"throw",m)}if(typeof h=="object"&&h&&Bt(Vt,h))return h}return new Te(!1)},Mu=P,to=Mu("iterator"),no=!1;try{var Bu=0,qt={next:function(){return{done:!!Bu++}},return:function(){no=!0}};qt[to]=function(){return this},Array.from(qt,function(){throw 2})}catch(e){}var Fu=function(e,r){if(!r&&!no)return!1;var t=!1;try{var n={};n[to]=function(){return{next:function(){return{done:t=!0}}}},e(n)}catch(o){}return t},Vu=re,qu=Fu,Hu=le.CONSTRUCTOR,oo=Hu||!qu(function(e){Vu.all(e).then(void 0,function(){})}),Ku=F,Wu=O,Qu=M,Gu=te,zu=kr,Yu=ro,Ju=oo;Ku({target:"Promise",stat:!0,forced:Ju},{all:function(r){var t=this,n=Gu.f(t),o=n.resolve,a=n.reject,c=zu(function(){var v=Qu(t.resolve),f=[],u=0,i=1;Yu(r,function(l){var d=u++,h=!1;i++,Wu(v,t,l).then(function(b){h||(h=!0,f[d]=b,--i||o(f))},a)}),--i||o(f)});return c.error&&a(c.value),n.promise}});var Xu=F,Zu=ce,el=le.CONSTRUCTOR,wr=re,rl=A,tl=y,nl=Dr,Ht=wr&&wr.prototype;Xu({target:"Promise",proto:!0,forced:el,real:!0},{catch:function(e){return this.then(void 0,e)}});if(!Zu&&tl(wr)){var Kt=rl("Promise").prototype.catch;Ht.catch!==Kt&&nl(Ht,"catch",Kt,{unsafe:!0})}var ol=F,il=O,al=M,sl=te,cl=kr,ul=ro,ll=oo;ol({target:"Promise",stat:!0,forced:ll},{race:function(r){var t=this,n=sl.f(t),o=n.reject,a=cl(function(){var c=al(t.resolve);ul(r,function(v){il(c,t,v).then(n.resolve,o)})});return a.error&&o(a.value),n.promise}});var fl=F,vl=O,dl=te,hl=le.CONSTRUCTOR;fl({target:"Promise",stat:!0,forced:hl},{reject:function(r){var t=dl.f(this);return vl(t.reject,void 0,r),t.promise}});var pl=B,yl=k,bl=te,io=function(e,r){if(pl(e),yl(r)&&r.constructor===e)return r;var t=bl.f(e),n=t.resolve;return n(r),t.promise},gl=F,$l=A,ao=ce,ml=re,so=le.CONSTRUCTOR,El=io,Sl=$l("Promise"),Tl=ao&&!so;gl({target:"Promise",stat:!0,forced:ao||so},{resolve:function(r){return El(Tl&&this===Sl?ml:this,r)}});var _l=F,Ol=ce,Re=re,Pl=T,co=A,uo=y,wl=Nn,Wt=io,Cl=Dr,Cr=Re&&Re.prototype,Il=!!Re&&Pl(function(){Cr.finally.call({then:function(){}},function(){})});_l({target:"Promise",proto:!0,real:!0,forced:Il},{finally:function(e){var r=wl(this,co("Promise")),t=uo(e);return this.then(t?function(n){return Wt(r,e()).then(function(){return n})}:e,t?function(n){return Wt(r,e()).then(function(){throw n})}:e)}});if(!Ol&&uo(Re)){var Qt=co("Promise").prototype.finally;Cr.finally!==Qt&&Cl(Cr,"finally",Qt,{unsafe:!0})}var Rl=A,Al=Rl,Nl=Al,Dl=Nl("Promise","finally"),Ll=Dl,jl=Ll,xl=jl,Ul=xl,dr=Ul;function kl(){const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),r=new Array(36);let t=0,n,o;for(o=0;o<36;o++)o===8||o===13||o===18||o===23?r[o]="-":o===14?r[o]="4":(t<=2&&(t=33554432+Math.random()*16777216|0),n=t&15,t=t>>4,r[o]=e[o===19?n&3|8:n]);return r.join("")}exports.ApiEnv=void 0;(function(e){e.PROD="prod",e.VK_ALIAS="vk_alias",e.VIDEOTEST="videotest",e.TEST="test",e.AUTO="auto"})(exports.ApiEnv||(exports.ApiEnv={}));exports.Quality=void 0;(function(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"})(exports.Quality||(exports.Quality={}));exports.ContentType=void 0;(function(e){e.MP4="mp4",e.DASH="dash",e.DASH_SEP="dash_sep",e.ONDEMAND_DASH="ondemand_dash",e.HLS="hls",e.ONDEMAND_HLS="ondemand_hls",e.WEBM="webm",e.ONDEMAND_DASH_LIVE="ondemand_dash_live",e.ONDEMAND_HLS_LIVE="ondemand_hls_live",e.WEBRTC="webrtc",e.UNKNOWN="unknown",e.RTMP="rtmp"})(exports.ContentType||(exports.ContentType={}));var Ae;(function(e){e.AUTO="auto",e.MANUAL=""})(Ae||(Ae={}));exports.ConnectionType=void 0;(function(e){e.HTTP1="http1",e.HTTP2="http2",e.HTTP3="http3"})(exports.ConnectionType||(exports.ConnectionType={}));var C;(function(e){e[e.YES=1]="YES",e[e.NO=0]="NO"})(C||(C={}));var Y;(function(e){e.EXCELLENT="excellent",e.GOOD="good",e.POOR="poor"})(Y||(Y={}));var x;(function(e){e.PIP="pip",e.FULLSCREEN="fullscreen",e.EXTERNAL="external",e.PREFETCH="prefetch"})(x||(x={}));exports.SeekAction=void 0;(function(e){e.SLIDER="slider",e.DOUBLE_TAP="double_tap",e.TIME_CODE="time_code",e.EPISODE="episode",e.REWIND="rewind",e.LIVE="live",e.UNKNOWN="unknown"})(exports.SeekAction||(exports.SeekAction={}));const Gt="1.0.35-dev.f578f79.0",Ml="es2015.cjs.js",Bl="CIOPGQJGDIHBABABA",lo={[exports.ApiEnv.PROD]:"https://api.ok.ru",[exports.ApiEnv.VK_ALIAS]:"https://api.mycdn.me",[exports.ApiEnv.VIDEOTEST]:"https://videotestapi.ok.ru/api",[exports.ApiEnv.TEST]:"https://apitest.ok.ru",[exports.ApiEnv.AUTO]:""},Fl="_one-stat_",zt=`${Fl}uuid`,Vl={start:1e3,factor:1.5,max:5*60*1e3,random:.1};var j;(function(e){e[e.PARAM_SESSION_EXPIRED=102]="PARAM_SESSION_EXPIRED",e[e.PARAM_SESSION_KEY=103]="PARAM_SESSION_KEY",e[e.PARAM_SIGNATURE=104]="PARAM_SIGNATURE",e[e.AUTH_LOGIN=401]="AUTH_LOGIN"})(j||(j={}));class ql{constructor(r){this.consequentAuthErrors=0,this.authorized$=new s.ValueSubject(!1),this.params=r;const t=s.safeStorage.get(zt);t?this.uuid=String(t):(this.uuid=kl(),s.safeStorage.set(zt,this.uuid))}authorize(r){return I(this,void 0,void 0,function*(){return this.authToken=r!=null?r:yield this.refreshAuthToken(),this._authorizeWithBackoff()})}logBeacon(r){const t="log.externalLog",n=this.createLogParams(r),o=this.sessionKey;if(!o)return;this.params.apiTransport.sendBeacon(t,n,o)||this.logRequest(r)}logRequest(r){var t;return I(this,void 0,void 0,function*(){const n="log.externalLog",o=this.createLogParams(r),a=(t=this.sessionKey)!==null&&t!==void 0?t:yield this._authorizeWithBackoff();if(!a)return;const c=(v,f=this.params.requestRetryCount)=>I(this,void 0,void 0,function*(){try{return yield this.params.apiTransport.sendRequest(n,o,a)}catch(u){if(!u||!("error_code"in u)){this.params.error$.next({id:"logRequestUnknown",category:s.ErrorCategory.NETWORK,message:`Unknown ${n} error`,thrown:u});return}const i=u==null?void 0:u.error_code;switch(i){case j.PARAM_SESSION_EXPIRED:case j.PARAM_SESSION_KEY:case j.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=yield this._authorizeWithBackoff(),f>0?c(v,f-1):void 0;case j.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=yield this.refreshAuthToken(),this.sessionKey=yield this._authorizeWithBackoff(),f>0?c(v,f-1):void 0;default:{this.params.error$.next({id:`LogRequest#${i}`,category:s.ErrorCategory.EXTERNAL_API,message:`${n} error`,data:u});return}}}});return c(r)})}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}refreshAuthToken(){return I(this,void 0,void 0,function*(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=dr(this.params.refreshAuthToken(),()=>{this.refreshAuthTokenPromise=void 0})),this.refreshAuthTokenPromise})}createLogParams(r){return{collector:"ok.mobile.apps.video",data:JSON.stringify({application:`${Ml}:${Gt}`,platform:this.params.mobile?"M_WEB":"WEB",items:r})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const r=s.getExponentialDelay(this.consequentAuthErrors,Vl);return new Promise(t=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout(()=>{dr(this._authorize().then(t).catch(n=>this.params.error$.next({id:"AuthorizeBackoff",category:s.ErrorCategory.NETWORK,message:"Otherwise unhandled error in authorization",thrown:n})),()=>this.backoffTimeoutId=0)},r))})}_authorize(){return I(this,void 0,void 0,function*(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const r="auth.anonymLogin",t={session_data:{version:2,device_id:this.uuid,client_version:Gt.split("-")[0],client_type:"SDK_JS"}};return this.authToken!==void 0&&(t.session_data.auth_token=this.authToken,t.session_data.version=3),this.authorizePromise=dr(this.params.apiTransport.sendRequest(r,t).then(n=>{var o;return(!n||!n.session_key)&&this.params.error$.next({id:"AuthorizeFailed",category:s.ErrorCategory.EXTERNAL_API,message:"No session key",data:n}),this.sessionKey=(o=n==null?void 0:n.session_key)!==null&&o!==void 0?o:void 0,this.sessionKey}).catch(n=>I(this,void 0,void 0,function*(){this.sessionKey=void 0;const o=n==null?void 0:n.error_code;switch(o){case j.AUTH_LOGIN:return this.authToken=yield this.refreshAuthToken(),this._authorizeWithBackoff()}o?this.params.error$.next({id:`Authorize#${o}`,category:s.ErrorCategory.EXTERNAL_API,message:"authorize error",data:n}):this.params.error$.next({id:"AuthorizeUnknown",category:s.ErrorCategory.NETWORK,message:"authorize error",thrown:n})})),()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise})}}class Yt{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(r,t,n){r in this.listeners||(this.listeners[r]=[]),this.listeners[r].push({callback:t,options:n})}removeEventListener(r,t){if(!(r in this.listeners))return;const n=this.listeners[r];for(let o=0,a=n.length;o<a;o++)if(n[o].callback===t){n.splice(o,1);return}}dispatchEvent(r){if(!(r.type in this.listeners))return;const n=this.listeners[r.type].slice();for(let o=0,a=n.length;o<a;o++){const c=n[o];try{c.callback.call(this,r)}catch(v){Promise.resolve().then(()=>{throw v})}c.options&&c.options.once&&this.removeEventListener(r.type,c.callback)}return!r.defaultPrevented}}class fo extends Yt{constructor(){super(),this.listeners||Yt.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(r){r.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,r)),super.dispatchEvent(r)}}class Hl{constructor(){Object.defineProperty(this,"signal",{value:new fo,writable:!0,configurable:!0})}abort(r){let t;try{t=new Event("abort")}catch(o){typeof document!="undefined"?document.createEvent?(t=document.createEvent("Event"),t.initEvent("abort",!1,!1)):(t=document.createEventObject(),t.type="abort"):t={type:"abort",bubbles:!1,cancelable:!1}}let n=r;if(n===void 0)if(typeof document=="undefined")n=new Error("This operation was aborted"),n.name="AbortError";else try{n=new DOMException("signal is aborted without reason")}catch(o){n=new Error("This operation was aborted"),n.name="AbortError"}this.signal.reason=n,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}}typeof Symbol!="undefined"&&Symbol.toStringTag&&(Hl.prototype[Symbol.toStringTag]="AbortController",fo.prototype[Symbol.toStringTag]="AbortSignal");function vo(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 Kl(e){typeof e=="function"&&(e={fetch:e});const{fetch:r,Request:t=r.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o=!1}=e;if(!vo({fetch:r,Request:t,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:r,Request:a};let a=t;(a&&!a.prototype.hasOwnProperty("signal")||o)&&(a=function(u,i){let l;i&&i.signal&&(l=i.signal,delete i.signal);const d=new t(u,i);return l&&Object.defineProperty(d,"signal",{writable:!1,enumerable:!1,configurable:!0,value:l}),d},a.prototype=t.prototype);const c=r;return{fetch:(f,u)=>{const i=a&&a.prototype.isPrototypeOf(f)?f.signal:u?u.signal:void 0;if(i){let l;try{l=new DOMException("Aborted","AbortError")}catch(h){l=new Error("Aborted"),l.name="AbortError"}if(i.aborted)return Promise.reject(l);const d=new Promise((h,b)=>{i.addEventListener("abort",()=>b(l),{once:!0})});return u&&u.signal&&delete u.signal,Promise.race([d,c(f,u)])}return c(f,u)},Request:a}}const qr=vo({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),ho=qr?Kl({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Jt=qr?ho.fetch:window.fetch;qr?ho.Request:window.Request;class Wl{constructor(r){this.params=r,this.apiKey=r.apiKey,this.apiEnv=r.apiEnv,this.apiBaseUrl=r.apiBaseUrl,this.timeSynchronisation=r.timeSynchronisation,this.isApiBaseUrlFetched=!1}resolveApiBaseUrl(){var r;return I(this,void 0,void 0,function*(){if(this.apiEnv!==exports.ApiEnv.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const t=atob("aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ="),o=yield(yield Jt(t,{method:"GET",mode:"cors",cache:"no-cache"})).json(),a=(r=o==null?void 0:o.Answer[0])===null||r===void 0?void 0:r.data;if(!a)throw new Error("Wrong DNS response");return a}catch(t){return this.params.error$.next({id:"OneStat:ApiTransport:resolveApiBaseUrl",category:s.ErrorCategory.NETWORK,message:"Unhandled resolve api base url error",thrown:t}),lo[exports.ApiEnv.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}})}sendBeacon(r,t,n){if(!window.Blob||!window.navigator.sendBeacon)return!1;const o=this._prepareQueryParams({method:r,queryParams:t,sessionKey:n}),a=new window.Blob([o.toString()],{type:"application/x-www-form-urlencoded"});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,a)}catch(c){this.params.error$.next({id:"OneStat:ApiTransport:sendBeacon",category:s.ErrorCategory.NETWORK,message:"Unhandled beacon error",thrown:c,data:{method:r,params:t}})}return!1}sendRequest(r,t,n){return I(this,void 0,void 0,function*(){const o=s.now(),a=c=>{if(c instanceof TypeError&&["Failed to fetch","NetworkError when attempting to fetch resource."].includes(c.message)){this.params.error$.next({id:"Network",category:s.ErrorCategory.NETWORK,message:"Request failed",thrown:c});return}this.params.error$.next({id:"OneStat:ApiTransport:sendRequest",category:s.ErrorCategory.NETWORK,message:"Unhandled request error",thrown:c,data:{method:r,params:t,sessionKey:n,time:s.now()-o}})};return this.apiBaseUrl=yield this.resolveApiBaseUrl(),Jt(`${this.apiBaseUrl}/fb.do`,{method:"post",headers:{"Content-type":"application/x-www-form-urlencoded"},body:this._prepareQueryParams({method:r,queryParams:t,sessionKey:n})}).then(c=>{var v;const f=Number(c.headers.get("content-length"))===0,u=new Date((v=c.headers.get("date"))!==null&&v!==void 0?v:"").getTime(),i=s.now()-o;if(isFinite(u)&&this.timeSynchronisation.addServerTime(u,i),!f)return c.json().then(l=>Object.prototype.hasOwnProperty.call(l,"error_msg")?Promise.reject(l):l,a)},a)})}_prepareQueryParams(r){const t=new URLSearchParams({format:"JSON",method:r.method,application_key:this.apiKey});return r.sessionKey!==void 0&&t.append("session_key",r.sessionKey),Object.entries(r.queryParams).forEach(([n,o])=>t.append(n,typeof o=="string"?o:JSON.stringify(o))),t}}const po=3e3,Ql=po*5;class Gl{constructor(r){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=yo(()=>{var t;try{this.flush()}catch(n){this.error$.next({id:"LoggerError",category:s.ErrorCategory.WTF,message:(t=String(n))!==null&&t!==void 0?t:"Unknown logger error",thrown:n})}},po,{maxWait:Ql}),this.api=r.api,this.error$=r.error$,this.subscription=this.api.authorized$.subscribe(t=>{t&&this.debouncedFlush()})}log(r){console.log(r.operation,r.custom.param,r),this.requestQueue.push(r),this.isPaused||this.debouncedFlush()}flush(r=!1){this.requestQueue.length!==0&&(this.api.authorized$.getValue()?(console.log("Sending",this.requestQueue.length,"events",this.requestQueue),r?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[]):this.api.authorize(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe()}}const zl=()=>{let e,r;try{e=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?e=!0:(e=!1,console.error(n))}try{window.location.ancestorOrigins&&(r=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!r&&document.referrer&&(r=document.referrer)}catch(n){console.error(n)}const t=r?new URL(r).hostname:void 0;return{isEmbed:e,host:t}},Yl=e=>e&&{[p.VideoQuality.INVARIANT]:exports.Quality.UNKNOWN,[p.VideoQuality.Q_144P]:exports.Quality.Q144P,[p.VideoQuality.Q_240P]:exports.Quality.Q240P,[p.VideoQuality.Q_360P]:exports.Quality.Q360P,[p.VideoQuality.Q_480P]:exports.Quality.Q480P,[p.VideoQuality.Q_720P]:exports.Quality.Q720P,[p.VideoQuality.Q_1080P]:exports.Quality.Q1080P,[p.VideoQuality.Q_1440P]:exports.Quality.Q1440P,[p.VideoQuality.Q_2160P]:exports.Quality.Q2160P,[p.VideoQuality.Q_4320P]:exports.Quality.UNKNOWN}[e],Xt=e=>e&&{[p.HttpConnectionType.HTTP1]:exports.ConnectionType.HTTP1,[p.HttpConnectionType.HTTP2]:exports.ConnectionType.HTTP2,[p.HttpConnectionType.QUIC]:exports.ConnectionType.HTTP3}[e],Jl=e=>{if(e!==void 0)switch(e){case p.VideoFormat.MPEG:return exports.ContentType.MP4;case p.VideoFormat.DASH:case p.VideoFormat.DASH_LIVE:return exports.ContentType.DASH;case p.VideoFormat.DASH_SEP:return exports.ContentType.DASH_SEP;case p.VideoFormat.DASH_ONDEMAND:return exports.ContentType.ONDEMAND_DASH;case p.VideoFormat.DASH_WEBM:case p.VideoFormat.DASH_LIVE_WEBM:return exports.ContentType.WEBM;case p.VideoFormat.DASH_LIVE_CMAF:return exports.ContentType.ONDEMAND_DASH_LIVE;case p.VideoFormat.HLS:case p.VideoFormat.HLS_LIVE:return exports.ContentType.HLS;case p.VideoFormat.HLS_ONDEMAND:return exports.ContentType.ONDEMAND_HLS;case p.VideoFormat.HLS_LIVE_CMAF:return exports.ContentType.ONDEMAND_HLS_LIVE;case p.VideoFormat.WEB_RTC_LIVE:return exports.ContentType.WEBRTC;default:return s.assertNever(e)}},hr=e=>{if(e!==void 0)switch(e){case p.Surface.NONE:case p.Surface.INLINE:return;case p.Surface.FULLSCREEN:return x.FULLSCREEN;case p.Surface.SECOND_SCREEN:return x.EXTERNAL;case p.Surface.PIP:return x.PIP;default:return s.assertNever(e)}},Xl=e=>{switch(e){case"slow-2g":return Y.POOR;case"2g":return Y.POOR;case"3g":return Y.GOOD;case"4g":return Y.EXCELLENT}};class Zl{constructor(r){this.offset=void 0,this.offset=r}getOffset(){var r;return(r=this.offset)!==null&&r!==void 0?r:0}setOffset(r){this.offset=r}now(){var r;return Date.now()+((r=this.offset)!==null&&r!==void 0?r:0)}date(r=new Date){var t;return r.setTime(r.getTime()+((t=this.offset)!==null&&t!==void 0?t:0)),r}addServerTime(r,t){const n=Date.now(),o=r-n-t/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)}}const Zt=()=>Math.floor(Math.random()*Math.pow(2,32)).toString(36).padStart(8,"0"),ef=e=>new s.Observable(r=>{const t=new s.Subscription,n=s.merge(s.fromEvent(window,"beforeunload"),e.events.willDestruct$),o=new s.ValueSubject(void 0);let a;e.info.isLive$.pipe(s.filterChanged()).subscribe(h=>{a&&(a.unsubscribe(),o.next(void 0)),h?a=e.info.liveTime$.pipe(s.map(b=>b&&b/1e3)).subscribe(o):a=e.info.position$.subscribe(o),t.add(a)});const{playing$:c,paused$:v}=e.events,f=e.events.willSeek$.pipe(s.filter(()=>e.info.playbackState$.getValue()===p.PlaybackState.PLAYING)),u=e.events.seeked$.pipe(s.filter(()=>e.info.playbackState$.getValue()===p.PlaybackState.PLAYING)),i=s.merge(c,u),l=s.merge(v,f,n,e.events.looped$);let d;return t.add(i.subscribe(()=>d=o.getValue())),t.add(l.subscribe(()=>{const h=o.getValue();s.isNullable(d)||d===h||s.isNullable(h)||(r.next({from:d,to:h}),d=void 0)})),t});class rf{constructor(r,t){var n,o;this.subscription=new s.Subscription,this.timeSynchronisation=new Zl,this.vsid=Zt(),this.seekAction$=new s.ValueSubject(exports.SeekAction.UNKNOWN),this.statContext=r,this.config=Object.assign(Object.assign({},(n=t.config)!==null&&n!==void 0?n:{}),{requestRetryCount:1});const a=new s.Subject;this.experimental={error$:a};const c=new Wl({apiKey:Bl,apiBaseUrl:lo[t.apiEnv],apiEnv:t.apiEnv,error$:a,timeSynchronisation:this.timeSynchronisation});this.api=new ql({apiTransport:c,refreshAuthToken:t.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,mobile:(o=this.statContext.mobile)!==null&&o!==void 0?o:!1,error$:a}),this.logger=new Gl({api:this.api,error$:a});const{isEmbed:v,host:f}=zl();this.isEmbed=v,this.embedParent=f,this.subscribe()}updateContext(r){this.statContext=Object.assign(Object.assign({},this.statContext),r)}attachTo(r){const t=new s.Subscription,n=(i,l)=>t.add(i.subscribe(l));n(r.events.willStart$,()=>{this.logActionPlay({position:r.info.position$.getValue()})}),n(r.events.looped$,()=>{this.resetViewSession(),this.logActionPlay({position:r.info.position$.getValue()})}),n(r.events.seeked$,()=>{this.logSeek({action:this.seekAction$.getValue(),time:r.info.position$.getValue()}),this.seekAction$.next(exports.SeekAction.UNKNOWN)}),n(r.events.paused$,()=>{this.logPause({position:r.info.position$.getValue()})}),n(r.events.willResume$,()=>{this.logPlay()}),n(r.events.started$,()=>{this.statContext.clip&&(this.logWatchCoverageRecord({start:0,end:0}),this.logger.flush())}),n(ef(r),i=>{const l=r.info.isLive$.getValue(),d={start:i.from,end:i.to};l?this.logWatchCoverageLive(d):this.logWatchCoverageRecord(d)});let o;n(r.info.isStalled$,i=>{i?o=s.now():(s.isNonNullable(o)&&this.logEmptyBuffer({duration:s.now()-o}),o=void 0)});let a=!1;t.add(r.events.fatalError$.pipe(s.once()).subscribe(()=>a=!0)),n(r.events.willStop$,()=>{if(r.info.isStalled$.getValue()){const l=s.isNonNullable(o)?s.now()-o:void 0;this.logCloseAtEmptyBuffer({duration:l!=null?l:0}),o=void 0}else a||this.logActionStop();this.logger.flush()}),n(r.events.managedError$,({id:i})=>{this.logError({fatal:!1,errorType:i})}),n(r.events.fatalError$,({id:i})=>{this.logError({fatal:!0,errorType:i})});let c,v,f=!1;n(r.events.firstBytes$,i=>{c=s.now(),this.logFirstBytes({time:i})}),n(r.events.willStart$,()=>v=s.now()),n(r.info.currentBuffer$,i=>{!f&&i&&i.end-i.start>0&&s.isNonNullable(c)&&(this.logPlayerReady({duration:s.now()-c}),f=!0)}),n(r.events.firstFrame$,()=>{s.isNonNullable(c)&&!f&&(this.logPlayerReady({duration:s.now()-c}),f=!0),s.isNonNullable(v)&&this.logFirstFrame({time:s.now()-v})}),n(r.info.atLiveEdge$,i=>this.updateContext({liveEdge:i})),n(s.combine({muted:r.info.muted$,volume:r.info.volume$}),({muted:i,volume:l})=>this.updateContext({audible:!i&&l>0})),n(r.info.currentQuality$,i=>this.updateContext({quality:Yl(i)})),n(r.info.isAutoQualityEnabled$,i=>this.updateContext({autoQuality:i})),n(r.info.currentFormat$,i=>this.updateContext({contentType:Jl(i)}));let u;return n(r.info.hostname$,i=>{this.updateContext({cdnHostname:i,failover:u!==void 0&&u!==i}),u=i}),n(r.info.throughputEstimation$,i=>this.updateContext({downloadSpeed:i})),n(r.info.httpConnectionType$,i=>{this.statContext.firstConnectionType||this.updateContext({firstConnectionType:Xt(i)}),this.updateContext({connectionType:Xt(i)})}),n(r.info.httpConnectionReused$,i=>{s.isNullable(this.statContext.firstConnectionReused)&&this.updateContext({firstConnectionReused:i}),this.updateContext({connectionReused:i})}),n(r.info.surface$,i=>this.updateContext({mode:hr(i)})),n(s.combine({current:r.info.currentTextTrack$,available:r.info.availableTextTracks$}),({current:i,available:l})=>{const d=l.find(({id:h})=>h===i);this.updateContext({subtitles:d==null?void 0:d.language})}),this.player=r,this.uiEvents&&this.attachToUi(this.uiEvents),this.subscription.add(t),t}attachToUi(r){this.uiEvents=r;const t=new s.Subscription;return this.player&&(t.add(r.actionRewind$.subscribe(()=>{this.player&&(this.resetViewSession(),this.logActionPlay({position:this.player.info.position$.getValue()}))})),t.add(r.actionSeek$.subscribe(this.seekAction$)),t.add(r.inPiP$.subscribe(n=>{var o;const a=n?x.PIP:hr((o=this.player)===null||o===void 0?void 0:o.info.surface$.getValue());this.updateContext({mode:a})})),t.add(r.inFullscreen$.subscribe(n=>{var o;const a=n?x.FULLSCREEN:hr((o=this.player)===null||o===void 0?void 0:o.info.surface$.getValue());this.updateContext({mode:a})})),this.subscription.add(t)),t}attachToAds(r){const t=new s.Subscription;return t.add(r.slotRequested$.subscribe(()=>this.logAdSlotRequest())).add(r.started$.subscribe(n=>this.logAdStarted(n))).add(r.paused$.subscribe(()=>this.logAdPaused())).add(r.resumed$.subscribe(()=>this.logAdResumed())).add(r.ended$.subscribe(()=>this.logAdEnded())).add(r.skipped$.subscribe(()=>this.logAdSkipped())).add(r.clicked$.subscribe(()=>this.logAdClicked())),this.subscription.add(t),t}authorize(r){return this.api.authorize(r)}pause(){this.logger.pause()}resume(){this.logger.resume()}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}resetViewSession(){this.vsid=Zt()}setFieldBlacklist(){}logInited(){}logReady(r){this.log({operation:"player_ready",param:String(r.time)})}logStarted(...r){this.logActionPlay(...r)}logPlay(){this.log({operation:"play_toggle"})}logPause(r){this.log({operation:"pause",param:String(Math.round(r.position))})}logSeek(r){this.log({operation:"seek",param:r.action,time:r.time})}logFirstBytes(r){this.log({operation:"first_bytes",param:String(r.time)})}logFirstFrame(r){this.log({operation:"first_frame",param:String(r.time)})}logError(r){this.log({operation:"content_error",param:`${r.fatal?"fatal":"recoverable"}_${r.errorType}`})}logWatchCoverageRecord(r){this.log({operation:"watch_coverage_record",param:`${r.start}-${r.end}`})}logWatchCoverageLive(r){const t=r.start+this.timeSynchronisation.getOffset(),n=r.end+this.timeSynchronisation.getOffset();this.log({operation:"watch_coverage_live",param:`${t}-${n}`})}logEmptyBuffer(r){this.log({operation:"empty_buffer",param:String(r.duration)})}logDownloadSpeed(){}logAdSlotRequest(){this.log({operation:"adv",param:"slot_request"})}logAdStarted(r){this.log({operation:"adv",param:r})}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"})}subscribe(){this.subscription.add(s.fromEvent(window,"beforeunload").subscribe(()=>this.logger.flush(!0)));const r=window.navigator.connection;r&&"onchange"in r&&"effectiveType"in r&&this.subscription.add(s.merge(s.fromEvent(r,"change"),s.observableFrom(["init"])).subscribe(()=>this.updateContext({network:Xl(r.effectiveType)})))}logPlayerReady(r){this.log({operation:"player_ready",param:String(Math.round(r.duration))})}logActionPlay(r){this.log({operation:"action_play",param:String(Math.round(r.position))})}logCloseAtEmptyBuffer(r){this.log({operation:"close_at_empty_buffer",param:String(Math.round(r.duration))})}logActionStop(){this.log({operation:"action_stop"})}log(r){const t=this.createLogItem(r);this.logger.log(t)}createLogItem({operation:r,param:t,time:n}){const o=this.timeSynchronisation.now(),a=r==="empty_buffer"||r==="close_at_empty_buffer"?this.statContext.connectionType:this.statContext.firstConnectionType,c=this.statContext.firstConnectionReused,v={vsid:this.vsid,vid:this.statContext.movieId,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?Ae.AUTO:this.statContext.autoplay===!1?Ae.MANUAL:void 0,param:t,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode,connection_type:a,connection_reused:c===!0?C.YES:c===!1?C.NO:void 0,cached_data:this.statContext.cached===!0?C.YES:this.statContext.cached===!1?C.NO:void 0,live:this.statContext.liveEdge?C.YES:void 0,muted:this.statContext.audible===!1?C.YES:void 0,mode:this.statContext.mode,subtitles:this.statContext.subtitles,download_speed:this.statContext.downloadSpeed,manual_quality:this.statContext.autoQuality?void 0:C.YES,ref_domain:this.embedParent,aid:this.statContext.albumId,vk_playlist_id:this.statContext.vkPlaylistId};return{operation:r,type:1,time:n,network:this.statContext.network,timestamp:o,custom:v}}}exports.OneStat=rf;
package/es2015.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @vkontakte/videoplayer-statistics v1.0.34
3
- * Mon, 17 Apr 2023 11:31:09 GMT
4
- * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-34/doc/
2
+ * @vkontakte/videoplayer-statistics v1.0.35-dev.f578f79.0
3
+ * Wed, 10 May 2023 11:40:54 GMT
4
+ * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-35/doc/
5
5
  */
6
- import{ValueSubject as Oo,getExponentialDelay as _o,ErrorCategory as E,now as ie,assertNever as Po,Subscription as Jr,Subject as Io,fromEvent as wo,isNonNullable as Xr}from"@vkontakte/videoplayer-shared/es2015.esm.js";import{VideoQuality as T,HttpConnectionType as ze,VideoFormat as y,ChromecastState as Ro}from"@vkontakte/videoplayer-core/es2015.esm.js";import Ao from"lodash/debounce.js";function N(e,r,t,n){function o(a){return a instanceof t?a:new t(function(i){i(a)})}return new(t||(t=Promise))(function(a,i){function v(c){try{s(n.next(c))}catch(l){i(l)}}function u(c){try{s(n.throw(c))}catch(l){i(l)}}function s(c){c.done?a(c.value):o(c.value).then(v,u)}s((n=n.apply(e,r||[])).next())})}var Zr=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},pe=function(e){return e&&e.Math==Math&&e},p=pe(typeof globalThis=="object"&&globalThis)||pe(typeof window=="object"&&window)||pe(typeof self=="object"&&self)||pe(typeof Zr=="object"&&Zr)||function(){return this}()||Function("return this")(),P=function(e){try{return!!e()}catch(r){return!0}},Co=P,ke=!Co(function(){var e=function(){}.bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),No=ke,un=Function.prototype,et=un.apply,rt=un.call,ln=typeof Reflect=="object"&&Reflect.apply||(No?rt.bind(et):function(){return rt.apply(et,arguments)}),vn=ke,fn=Function.prototype,Er=fn.call,Do=vn&&fn.bind.bind(Er,Er),I=vn?Do:function(e){return function(){return Er.apply(e,arguments)}},hn=I,jo=hn({}.toString),Lo=hn("".slice),Be=function(e){return Lo(jo(e),8,-1)},Mo=Be,Uo=I,dn=function(e){if(Mo(e)==="Function")return Uo(e)},Sr=typeof document=="object"&&document.all,ko=typeof Sr=="undefined"&&Sr!==void 0,pn={all:Sr,IS_HTMLDDA:ko},yn=pn,Bo=yn.all,d=yn.IS_HTMLDDA?function(e){return typeof e=="function"||e===Bo}:function(e){return typeof e=="function"},Lr={},xo=P,re=!xo(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),Fo=ke,ye=Function.prototype.call,w=Fo?ye.bind(ye):function(){return ye.apply(ye,arguments)},gn={},$n={}.propertyIsEnumerable,bn=Object.getOwnPropertyDescriptor,Ho=bn&&!$n.call({1:2},1);gn.f=Ho?function(r){var t=bn(this,r);return!!t&&t.enumerable}:$n;var mn=function(e,r){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:r}},Ko=I,qo=P,Vo=Be,Qe=Object,Wo=Ko("".split),Go=qo(function(){return!Qe("z").propertyIsEnumerable(0)})?function(e){return Vo(e)=="String"?Wo(e,""):Qe(e)}:Qe,xe=function(e){return e==null},zo=xe,Qo=TypeError,En=function(e){if(zo(e))throw Qo("Can't call method on "+e);return e},Yo=Go,Jo=En,Xo=function(e){return Yo(Jo(e))},tt=d,Sn=pn,Zo=Sn.all,x=Sn.IS_HTMLDDA?function(e){return typeof e=="object"?e!==null:tt(e)||e===Zo}:function(e){return typeof e=="object"?e!==null:tt(e)},Tn={},Ye=Tn,Je=p,ea=d,nt=function(e){return ea(e)?e:void 0},j=function(e,r){return arguments.length<2?nt(Ye[e])||nt(Je[e]):Ye[e]&&Ye[e][r]||Je[e]&&Je[e][r]},ra=I,Mr=ra({}.isPrototypeOf),Fe=typeof navigator!="undefined"&&String(navigator.userAgent)||"",On=p,Xe=Fe,ot=On.process,at=On.Deno,it=ot&&ot.versions||at&&at.version,st=it&&it.v8,S,we;st&&(S=st.split("."),we=S[0]>0&&S[0]<4?1:+(S[0]+S[1]));!we&&Xe&&(S=Xe.match(/Edge\/(\d+)/),(!S||S[1]>=74)&&(S=Xe.match(/Chrome\/(\d+)/),S&&(we=+S[1])));var _n=we,ct=_n,ta=P,Pn=!!Object.getOwnPropertySymbols&&!ta(function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&ct&&ct<41}),na=Pn,In=na&&!Symbol.sham&&typeof Symbol.iterator=="symbol",oa=j,aa=d,ia=Mr,sa=In,ca=Object,wn=sa?function(e){return typeof e=="symbol"}:function(e){var r=oa("Symbol");return aa(r)&&ia(r.prototype,ca(e))},ua=String,He=function(e){try{return ua(e)}catch(r){return"Object"}},la=d,va=He,fa=TypeError,F=function(e){if(la(e))return e;throw fa(va(e)+" is not a function")},ha=F,da=xe,Ur=function(e,r){var t=e[r];return da(t)?void 0:ha(t)},Ze=w,er=d,rr=x,pa=TypeError,ya=function(e,r){var t,n;if(r==="string"&&er(t=e.toString)&&!rr(n=Ze(t,e))||er(t=e.valueOf)&&!rr(n=Ze(t,e))||r!=="string"&&er(t=e.toString)&&!rr(n=Ze(t,e)))return n;throw pa("Can't convert object to primitive value")},Re={},ga={get exports(){return Re},set exports(e){Re=e}},fe=!0,ut=p,$a=Object.defineProperty,ba=function(e,r){try{$a(ut,e,{value:r,configurable:!0,writable:!0})}catch(t){ut[e]=r}return r},ma=p,Ea=ba,lt="__core-js_shared__",Sa=ma[lt]||Ea(lt,{}),kr=Sa,vt=kr;(ga.exports=function(e,r){return vt[e]||(vt[e]=r!==void 0?r:{})})("versions",[]).push({version:"3.27.2",mode:"pure",copyright:"\xA9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.27.2/LICENSE",source:"https://github.com/zloirock/core-js"});var Ta=En,Oa=Object,_a=function(e){return Oa(Ta(e))},Pa=I,Ia=_a,wa=Pa({}.hasOwnProperty),te=Object.hasOwn||function(r,t){return wa(Ia(r),t)},Ra=I,Aa=0,Ca=Math.random(),Na=Ra(1 .toString),Rn=function(e){return"Symbol("+(e===void 0?"":e)+")_"+Na(++Aa+Ca,36)},Da=p,ja=Re,ft=te,La=Rn,Ma=Pn,Ua=In,Y=Da.Symbol,tr=ja("wks"),ka=Ua?Y.for||Y:Y&&Y.withoutSetter||La,R=function(e){return ft(tr,e)||(tr[e]=Ma&&ft(Y,e)?Y[e]:ka("Symbol."+e)),tr[e]},Ba=w,ht=x,dt=wn,xa=Ur,Fa=ya,Ha=R,Ka=TypeError,qa=Ha("toPrimitive"),Va=function(e,r){if(!ht(e)||dt(e))return e;var t=xa(e,qa),n;if(t){if(r===void 0&&(r="default"),n=Ba(t,e,r),!ht(n)||dt(n))return n;throw Ka("Can't convert object to primitive value")}return r===void 0&&(r="number"),Fa(e,r)},Wa=Va,Ga=wn,An=function(e){var r=Wa(e,"string");return Ga(r)?r:r+""},za=p,pt=x,Tr=za.document,Qa=pt(Tr)&&pt(Tr.createElement),Cn=function(e){return Qa?Tr.createElement(e):{}},Ya=re,Ja=P,Xa=Cn,Nn=!Ya&&!Ja(function(){return Object.defineProperty(Xa("div"),"a",{get:function(){return 7}}).a!=7}),Za=re,ei=w,ri=gn,ti=mn,ni=Xo,oi=An,ai=te,ii=Nn,yt=Object.getOwnPropertyDescriptor;Lr.f=Za?yt:function(r,t){if(r=ni(r),t=oi(t),ii)try{return yt(r,t)}catch(n){}if(ai(r,t))return ti(!ei(ri.f,r,t),r[t])};var si=P,ci=d,ui=/#|\.prototype\./,he=function(e,r){var t=vi[li(e)];return t==hi?!0:t==fi?!1:ci(r)?si(r):!!r},li=he.normalize=function(e){return String(e).replace(ui,".").toLowerCase()},vi=he.data={},fi=he.NATIVE="N",hi=he.POLYFILL="P",Dn=he,gt=dn,di=F,pi=ke,yi=gt(gt.bind),Ke=function(e,r){return di(e),r===void 0?e:pi?yi(e,r):function(){return e.apply(r,arguments)}},qe={},gi=re,$i=P,bi=gi&&$i(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),mi=x,Ei=String,Si=TypeError,H=function(e){if(mi(e))return e;throw Si(Ei(e)+" is not an object")},Ti=re,Oi=Nn,_i=bi,ge=H,$t=An,Pi=TypeError,nr=Object.defineProperty,Ii=Object.getOwnPropertyDescriptor,or="enumerable",ar="configurable",ir="writable";qe.f=Ti?_i?function(r,t,n){if(ge(r),t=$t(t),ge(n),typeof r=="function"&&t==="prototype"&&"value"in n&&ir in n&&!n[ir]){var o=Ii(r,t);o&&o[ir]&&(r[t]=n.value,n={configurable:ar in n?n[ar]:o[ar],enumerable:or in n?n[or]:o[or],writable:!1})}return nr(r,t,n)}:nr:function(r,t,n){if(ge(r),t=$t(t),ge(n),Oi)try{return nr(r,t,n)}catch(o){}if("get"in n||"set"in n)throw Pi("Accessors not supported");return"value"in n&&(r[t]=n.value),r};var wi=re,Ri=qe,Ai=mn,Ve=wi?function(e,r,t){return Ri.f(e,r,Ai(1,t))}:function(e,r,t){return e[r]=t,e},$e=p,Ci=ln,Ni=dn,Di=d,ji=Lr.f,Li=Dn,V=Tn,Mi=Ke,W=Ve,bt=te,Ui=function(e){var r=function(t,n,o){if(this instanceof r){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,n)}return new e(t,n,o)}return Ci(e,this,arguments)};return r.prototype=e.prototype,r},K=function(e,r){var t=e.target,n=e.global,o=e.stat,a=e.proto,i=n?$e:o?$e[t]:($e[t]||{}).prototype,v=n?V:V[t]||W(V,t,{})[t],u=v.prototype,s,c,l,h,f,m,L,A,q;for(h in r)s=Li(n?h:t+(o?".":"#")+h,e.forced),c=!s&&i&&bt(i,h),m=v[h],c&&(e.dontCallGetSet?(q=ji(i,h),L=q&&q.value):L=i[h]),f=c&&L?L:r[h],!(c&&typeof m==typeof f)&&(e.bind&&c?A=Mi(f,$e):e.wrap&&c?A=Ui(f):a&&Di(f)?A=Ni(f):A=f,(e.sham||f&&f.sham||m&&m.sham)&&W(A,"sham",!0),W(v,h,A),a&&(l=t+"Prototype",bt(V,l)||W(V,l,{}),W(V[l],h,f),e.real&&u&&(s||!u[h])&&W(u,h,f)))},ki=Be,We=typeof process!="undefined"&&ki(process)=="process",Bi=Ve,Br=function(e,r,t,n){return n&&n.enumerable?e[r]=t:Bi(e,r,t),e},xi=d,Fi=String,Hi=TypeError,Ki=function(e){if(typeof e=="object"||xi(e))return e;throw Hi("Can't set "+Fi(e)+" as a prototype")},qi=I,Vi=H,Wi=Ki,Gi=Object.setPrototypeOf||("__proto__"in{}?function(){var e=!1,r={},t;try{t=qi(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set),t(r,[]),e=r instanceof Array}catch(n){}return function(o,a){return Vi(o),Wi(a),e?t(o,a):o.__proto__=a,o}}():void 0),zi=R,Qi=zi("toStringTag"),jn={};jn[Qi]="z";var xr=String(jn)==="[object z]",Yi=xr,Ji=d,_e=Be,Xi=R,Zi=Xi("toStringTag"),es=Object,rs=_e(function(){return arguments}())=="Arguments",ts=function(e,r){try{return e[r]}catch(t){}},Fr=Yi?_e:function(e){var r,t,n;return e===void 0?"Undefined":e===null?"Null":typeof(t=ts(r=es(e),Zi))=="string"?t:rs?_e(r):(n=_e(r))=="Object"&&Ji(r.callee)?"Arguments":n},ns=xr,os=Fr,as=ns?{}.toString:function(){return"[object "+os(this)+"]"},is=xr,ss=qe.f,cs=Ve,us=te,ls=as,vs=R,mt=vs("toStringTag"),fs=function(e,r,t,n){if(e){var o=t?e:e.prototype;us(o,mt)||ss(o,mt,{configurable:!0,value:r}),n&&!is&&cs(o,"toString",ls)}},hs=j,ds=qe,ps=R,ys=re,Et=ps("species"),gs=function(e){var r=hs(e),t=ds.f;ys&&r&&!r[Et]&&t(r,Et,{configurable:!0,get:function(){return this}})},$s=Mr,bs=TypeError,ms=function(e,r){if($s(r,e))return e;throw bs("Incorrect invocation")},Es=I,Ss=d,Or=kr,Ts=Es(Function.toString);Ss(Or.inspectSource)||(Or.inspectSource=function(e){return Ts(e)});var Ln=Or.inspectSource,Os=I,_s=P,Mn=d,Ps=Fr,Is=j,ws=Ln,Un=function(){},Rs=[],kn=Is("Reflect","construct"),Hr=/^\s*(?:class|function)\b/,As=Os(Hr.exec),Cs=!Hr.exec(Un),ae=function(r){if(!Mn(r))return!1;try{return kn(Un,Rs,r),!0}catch(t){return!1}},Bn=function(r){if(!Mn(r))return!1;switch(Ps(r)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Cs||!!As(Hr,ws(r))}catch(t){return!0}};Bn.sham=!0;var Ns=!kn||_s(function(){var e;return ae(ae.call)||!ae(Object)||!ae(function(){e=!0})||e})?Bn:ae,Ds=Ns,js=He,Ls=TypeError,Ms=function(e){if(Ds(e))return e;throw Ls(js(e)+" is not a constructor")},St=H,Us=Ms,ks=xe,Bs=R,xs=Bs("species"),xn=function(e,r){var t=St(e).constructor,n;return t===void 0||ks(n=St(t)[xs])?r:Us(n)},Fs=j,Hs=Fs("document","documentElement"),Ks=I,qs=Ks([].slice),Vs=TypeError,Ws=function(e,r){if(e<r)throw Vs("Not enough arguments");return e},Gs=Fe,Fn=/(?:ipad|iphone|ipod).*applewebkit/i.test(Gs),g=p,zs=ln,Qs=Ke,Tt=d,Ys=te,Hn=P,Ot=Hs,Js=qs,_t=Cn,Xs=Ws,Zs=Fn,ec=We,_r=g.setImmediate,Pr=g.clearImmediate,rc=g.process,sr=g.Dispatch,tc=g.Function,Pt=g.MessageChannel,nc=g.String,cr=0,se={},It="onreadystatechange",le,M,ur,lr;Hn(function(){le=g.location});var Kr=function(e){if(Ys(se,e)){var r=se[e];delete se[e],r()}},vr=function(e){return function(){Kr(e)}},wt=function(e){Kr(e.data)},Rt=function(e){g.postMessage(nc(e),le.protocol+"//"+le.host)};(!_r||!Pr)&&(_r=function(r){Xs(arguments.length,1);var t=Tt(r)?r:tc(r),n=Js(arguments,1);return se[++cr]=function(){zs(t,void 0,n)},M(cr),cr},Pr=function(r){delete se[r]},ec?M=function(e){rc.nextTick(vr(e))}:sr&&sr.now?M=function(e){sr.now(vr(e))}:Pt&&!Zs?(ur=new Pt,lr=ur.port2,ur.port1.onmessage=wt,M=Qs(lr.postMessage,lr)):g.addEventListener&&Tt(g.postMessage)&&!g.importScripts&&le&&le.protocol!=="file:"&&!Hn(Rt)?(M=Rt,g.addEventListener("message",wt,!1)):It in _t("script")?M=function(e){Ot.appendChild(_t("script"))[It]=function(){Ot.removeChild(this),Kr(e)}}:M=function(e){setTimeout(vr(e),0)});var Kn={set:_r,clear:Pr},qn=function(){this.head=null,this.tail=null};qn.prototype={add:function(e){var r={item:e,next:null},t=this.tail;t?t.next=r:this.head=r,this.tail=r},get:function(){var e=this.head;if(e){var r=this.head=e.next;return r===null&&(this.tail=null),e.item}}};var Vn=qn,oc=Fe,ac=/ipad|iphone|ipod/i.test(oc)&&typeof Pebble!="undefined",ic=Fe,sc=/web0s(?!.*chrome)/i.test(ic),B=p,At=Ke,cc=Lr.f,fr=Kn.set,uc=Vn,lc=Fn,vc=ac,fc=sc,hr=We,Ct=B.MutationObserver||B.WebKitMutationObserver,Nt=B.document,Dt=B.process,be=B.Promise,jt=cc(B,"queueMicrotask"),Ir=jt&&jt.value,G,dr,pr,me,Lt;if(!Ir){var Ee=new uc,Se=function(){var e,r;for(hr&&(e=Dt.domain)&&e.exit();r=Ee.get();)try{r()}catch(t){throw Ee.head&&G(),t}e&&e.enter()};!lc&&!hr&&!fc&&Ct&&Nt?(dr=!0,pr=Nt.createTextNode(""),new Ct(Se).observe(pr,{characterData:!0}),G=function(){pr.data=dr=!dr}):!vc&&be&&be.resolve?(me=be.resolve(void 0),me.constructor=be,Lt=At(me.then,me),G=function(){Lt(Se)}):hr?G=function(){Dt.nextTick(Se)}:(fr=At(fr,B),G=function(){fr(Se)}),Ir=function(e){Ee.head||G(),Ee.add(e)}}var hc=Ir,dc=function(e,r){try{arguments.length==1?console.error(e):console.error(e,r)}catch(t){}},qr=function(e){try{return{error:!1,value:e()}}catch(r){return{error:!0,value:r}}},pc=p,yc=d,Mt=pc.WeakMap,gc=yc(Mt)&&/native code/.test(String(Mt)),$c=Re,bc=Rn,Ut=$c("keys"),mc=function(e){return Ut[e]||(Ut[e]=bc(e))},Ec={},Sc=gc,Wn=p,Tc=x,Oc=Ve,yr=te,gr=kr,_c=mc,Pc=Ec,kt="Object already initialized",wr=Wn.TypeError,Ic=Wn.WeakMap,Ae,ve,Ce,wc=function(e){return Ce(e)?ve(e):Ae(e,{})},Rc=function(e){return function(r){var t;if(!Tc(r)||(t=ve(r)).type!==e)throw wr("Incompatible receiver, "+e+" required");return t}};if(Sc||gr.state){var O=gr.state||(gr.state=new Ic);O.get=O.get,O.has=O.has,O.set=O.set,Ae=function(e,r){if(O.has(e))throw wr(kt);return r.facade=e,O.set(e,r),r},ve=function(e){return O.get(e)||{}},Ce=function(e){return O.has(e)}}else{var z=_c("state");Pc[z]=!0,Ae=function(e,r){if(yr(e,z))throw wr(kt);return r.facade=e,Oc(e,z,r),r},ve=function(e){return yr(e,z)?e[z]:{}},Ce=function(e){return yr(e,z)}}var Ac={set:Ae,get:ve,has:Ce,enforce:wc,getterFor:Rc},Cc=p,ne=Cc.Promise,Gn=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",Nc=Gn,Dc=We,jc=!Nc&&!Dc&&typeof window=="object"&&typeof document=="object",Lc=p,ce=ne,Mc=d,Uc=Dn,kc=Ln,Bc=R,xc=jc,Fc=Gn,Hc=fe,$r=_n,Bt=ce&&ce.prototype,Kc=Bc("species"),Rr=!1,zn=Mc(Lc.PromiseRejectionEvent),qc=Uc("Promise",function(){var e=kc(ce),r=e!==String(ce);if(!r&&$r===66||Hc&&!(Bt.catch&&Bt.finally))return!0;if(!$r||$r<51||!/native code/.test(e)){var t=new ce(function(a){a(1)}),n=function(a){a(function(){},function(){})},o=t.constructor={};if(o[Kc]=n,Rr=t.then(function(){})instanceof n,!Rr)return!0}return!r&&(xc||Fc)&&!zn}),de={CONSTRUCTOR:qc,REJECTION_EVENT:zn,SUBCLASSING:Rr},oe={},xt=F,Vc=TypeError,Wc=function(e){var r,t;this.promise=new e(function(n,o){if(r!==void 0||t!==void 0)throw Vc("Bad Promise constructor");r=n,t=o}),this.resolve=xt(r),this.reject=xt(t)};oe.f=function(e){return new Wc(e)};var Gc=K,zc=fe,Ne=We,D=p,Z=w,Ft=Br,Ht=Gi,Qc=fs,Yc=gs,Jc=F,Pe=d,Xc=x,Zc=ms,eu=xn,Qn=Kn.set,Vr=hc,ru=dc,tu=qr,nu=Vn,Yn=Ac,De=ne,Wr=de,Jn=oe,Ge="Promise",Xn=Wr.CONSTRUCTOR,ou=Wr.REJECTION_EVENT,au=Wr.SUBCLASSING,br=Yn.getterFor(Ge),iu=Yn.set,Q=De&&De.prototype,U=De,Te=Q,Zn=D.TypeError,Ar=D.document,Gr=D.process,Cr=Jn.f,su=Cr,cu=!!(Ar&&Ar.createEvent&&D.dispatchEvent),eo="unhandledrejection",uu="rejectionhandled",Kt=0,ro=1,lu=2,zr=1,to=2,Oe,qt,vu,Vt,no=function(e){var r;return Xc(e)&&Pe(r=e.then)?r:!1},oo=function(e,r){var t=r.value,n=r.state==ro,o=n?e.ok:e.fail,a=e.resolve,i=e.reject,v=e.domain,u,s,c;try{o?(n||(r.rejection===to&&hu(r),r.rejection=zr),o===!0?u=t:(v&&v.enter(),u=o(t),v&&(v.exit(),c=!0)),u===e.promise?i(Zn("Promise-chain cycle")):(s=no(u))?Z(s,u,a,i):a(u)):i(t)}catch(l){v&&!c&&v.exit(),i(l)}},ao=function(e,r){e.notified||(e.notified=!0,Vr(function(){for(var t=e.reactions,n;n=t.get();)oo(n,e);e.notified=!1,r&&!e.rejection&&fu(e)}))},io=function(e,r,t){var n,o;cu?(n=Ar.createEvent("Event"),n.promise=r,n.reason=t,n.initEvent(e,!1,!0),D.dispatchEvent(n)):n={promise:r,reason:t},!ou&&(o=D["on"+e])?o(n):e===eo&&ru("Unhandled promise rejection",t)},fu=function(e){Z(Qn,D,function(){var r=e.facade,t=e.value,n=Wt(e),o;if(n&&(o=tu(function(){Ne?Gr.emit("unhandledRejection",t,r):io(eo,r,t)}),e.rejection=Ne||Wt(e)?to:zr,o.error))throw o.value})},Wt=function(e){return e.rejection!==zr&&!e.parent},hu=function(e){Z(Qn,D,function(){var r=e.facade;Ne?Gr.emit("rejectionHandled",r):io(uu,r,e.value)})},J=function(e,r,t){return function(n){e(r,n,t)}},X=function(e,r,t){e.done||(e.done=!0,t&&(e=t),e.value=r,e.state=lu,ao(e,!0))},Nr=function(e,r,t){if(!e.done){e.done=!0,t&&(e=t);try{if(e.facade===r)throw Zn("Promise can't be resolved itself");var n=no(r);n?Vr(function(){var o={done:!1};try{Z(n,r,J(Nr,o,e),J(X,o,e))}catch(a){X(o,a,e)}}):(e.value=r,e.state=ro,ao(e,!1))}catch(o){X({done:!1},o,e)}}};if(Xn&&(U=function(r){Zc(this,Te),Jc(r),Z(Oe,this);var t=br(this);try{r(J(Nr,t),J(X,t))}catch(n){X(t,n)}},Te=U.prototype,Oe=function(r){iu(this,{type:Ge,done:!1,notified:!1,parent:!1,reactions:new nu,rejection:!1,state:Kt,value:void 0})},Oe.prototype=Ft(Te,"then",function(r,t){var n=br(this),o=Cr(eu(this,U));return n.parent=!0,o.ok=Pe(r)?r:!0,o.fail=Pe(t)&&t,o.domain=Ne?Gr.domain:void 0,n.state==Kt?n.reactions.add(o):Vr(function(){oo(o,n)}),o.promise}),qt=function(){var e=new Oe,r=br(e);this.promise=e,this.resolve=J(Nr,r),this.reject=J(X,r)},Jn.f=Cr=function(e){return e===U||e===vu?new qt(e):su(e)},!zc&&Pe(De)&&Q!==Object.prototype)){Vt=Q.then,au||Ft(Q,"then",function(r,t){var n=this;return new U(function(o,a){Z(Vt,n,o,a)}).then(r,t)},{unsafe:!0});try{delete Q.constructor}catch(e){}Ht&&Ht(Q,Te)}Gc({global:!0,constructor:!0,wrap:!0,forced:Xn},{Promise:U});Qc(U,Ge,!1,!0);Yc(Ge);var so={},du=R,pu=so,yu=du("iterator"),gu=Array.prototype,$u=function(e){return e!==void 0&&(pu.Array===e||gu[yu]===e)},bu=Math.ceil,mu=Math.floor,Eu=Math.trunc||function(r){var t=+r;return(t>0?mu:bu)(t)},Su=Eu,Tu=function(e){var r=+e;return r!==r||r===0?0:Su(r)},Ou=Tu,_u=Math.min,Pu=function(e){return e>0?_u(Ou(e),9007199254740991):0},Iu=Pu,wu=function(e){return Iu(e.length)},Ru=Fr,Gt=Ur,Au=xe,Cu=so,Nu=R,Du=Nu("iterator"),co=function(e){if(!Au(e))return Gt(e,Du)||Gt(e,"@@iterator")||Cu[Ru(e)]},ju=w,Lu=F,Mu=H,Uu=He,ku=co,Bu=TypeError,xu=function(e,r){var t=arguments.length<2?ku(e):r;if(Lu(t))return Mu(ju(t,e));throw Bu(Uu(e)+" is not iterable")},Fu=w,zt=H,Hu=Ur,Ku=function(e,r,t){var n,o;zt(e);try{if(n=Hu(e,"return"),!n){if(r==="throw")throw t;return t}n=Fu(n,e)}catch(a){o=!0,n=a}if(r==="throw")throw t;if(o)throw n;return zt(n),t},qu=Ke,Vu=w,Wu=H,Gu=He,zu=$u,Qu=wu,Qt=Mr,Yu=xu,Ju=co,Yt=Ku,Xu=TypeError,Ie=function(e,r){this.stopped=e,this.result=r},Jt=Ie.prototype,uo=function(e,r,t){var n=t&&t.that,o=!!(t&&t.AS_ENTRIES),a=!!(t&&t.IS_RECORD),i=!!(t&&t.IS_ITERATOR),v=!!(t&&t.INTERRUPTED),u=qu(r,n),s,c,l,h,f,m,L,A=function($){return s&&Yt(s,"normal",$),new Ie(!0,$)},q=function($){return o?(Wu($),v?u($[0],$[1],A):u($[0],$[1])):v?u($,A):u($)};if(a)s=e.iterator;else if(i)s=e;else{if(c=Ju(e),!c)throw Xu(Gu(e)+" is not iterable");if(zu(c)){for(l=0,h=Qu(e);h>l;l++)if(f=q(e[l]),f&&Qt(Jt,f))return f;return new Ie(!1)}s=Yu(e,c)}for(m=a?e.next:s.next;!(L=Vu(m,s)).done;){try{f=q(L.value)}catch($){Yt(s,"throw",$)}if(typeof f=="object"&&f&&Qt(Jt,f))return f}return new Ie(!1)},Zu=R,lo=Zu("iterator"),vo=!1;try{var el=0,Xt={next:function(){return{done:!!el++}},return:function(){vo=!0}};Xt[lo]=function(){return this},Array.from(Xt,function(){throw 2})}catch(e){}var rl=function(e,r){if(!r&&!vo)return!1;var t=!1;try{var n={};n[lo]=function(){return{next:function(){return{done:t=!0}}}},e(n)}catch(o){}return t},tl=ne,nl=rl,ol=de.CONSTRUCTOR,fo=ol||!nl(function(e){tl.all(e).then(void 0,function(){})}),al=K,il=w,sl=F,cl=oe,ul=qr,ll=uo,vl=fo;al({target:"Promise",stat:!0,forced:vl},{all:function(r){var t=this,n=cl.f(t),o=n.resolve,a=n.reject,i=ul(function(){var v=sl(t.resolve),u=[],s=0,c=1;ll(r,function(l){var h=s++,f=!1;c++,il(v,t,l).then(function(m){f||(f=!0,u[h]=m,--c||o(u))},a)}),--c||o(u)});return i.error&&a(i.value),n.promise}});var fl=K,hl=fe,dl=de.CONSTRUCTOR,Dr=ne,pl=j,yl=d,gl=Br,Zt=Dr&&Dr.prototype;fl({target:"Promise",proto:!0,forced:dl,real:!0},{catch:function(e){return this.then(void 0,e)}});if(!hl&&yl(Dr)){var en=pl("Promise").prototype.catch;Zt.catch!==en&&gl(Zt,"catch",en,{unsafe:!0})}var $l=K,bl=w,ml=F,El=oe,Sl=qr,Tl=uo,Ol=fo;$l({target:"Promise",stat:!0,forced:Ol},{race:function(r){var t=this,n=El.f(t),o=n.reject,a=Sl(function(){var i=ml(t.resolve);Tl(r,function(v){bl(i,t,v).then(n.resolve,o)})});return a.error&&o(a.value),n.promise}});var _l=K,Pl=w,Il=oe,wl=de.CONSTRUCTOR;_l({target:"Promise",stat:!0,forced:wl},{reject:function(r){var t=Il.f(this);return Pl(t.reject,void 0,r),t.promise}});var Rl=H,Al=x,Cl=oe,ho=function(e,r){if(Rl(e),Al(r)&&r.constructor===e)return r;var t=Cl.f(e),n=t.resolve;return n(r),t.promise},Nl=K,Dl=j,po=fe,jl=ne,yo=de.CONSTRUCTOR,Ll=ho,Ml=Dl("Promise"),Ul=po&&!yo;Nl({target:"Promise",stat:!0,forced:po||yo},{resolve:function(r){return Ll(Ul&&this===Ml?jl:this,r)}});var kl=K,Bl=fe,je=ne,xl=P,go=j,$o=d,Fl=xn,rn=ho,Hl=Br,jr=je&&je.prototype,Kl=!!je&&xl(function(){jr.finally.call({then:function(){}},function(){})});kl({target:"Promise",proto:!0,real:!0,forced:Kl},{finally:function(e){var r=Fl(this,go("Promise")),t=$o(e);return this.then(t?function(n){return rn(r,e()).then(function(){return n})}:e,t?function(n){return rn(r,e()).then(function(){throw n})}:e)}});if(!Bl&&$o(je)){var tn=go("Promise").prototype.finally;jr.finally!==tn&&Hl(jr,"finally",tn,{unsafe:!0})}var ql=j,Vl=ql,Wl=Vl,Gl=Wl("Promise","finally"),zl=Gl,Ql=zl,Yl=Ql,Jl=Yl,mr=Jl;const Qr="_one-stat_",ee=(()=>{try{const e=Date.now().toString(),r=window.localStorage;r.setItem(e,e);const t=r.getItem(e)===e;return r.removeItem(e),t?r:null}catch(e){return null}})();function Xl(e){const r=ee?ee.getItem(Qr+e):null;if(r===null)return null;try{return JSON.parse(r)}catch(t){return null}}function Zl(e,r){try{ee&&ee.setItem(Qr+e,JSON.stringify(r))}catch(t){}}function ev(e){ee&&ee.removeItem(Qr+e)}var nn={get(e){return Xl(e)||null},set(e,r){Zl(e,r)},remove(e){ev(e)}};function rv(){const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),r=new Array(36);let t=0,n,o;for(o=0;o<36;o++)o===8||o===13||o===18||o===23?r[o]="-":o===14?r[o]="4":(t<=2&&(t=33554432+Math.random()*16777216|0),n=t&15,t=t>>4,r[o]=e[o===19?n&3|8:n]);return r.join("")}var C;(function(e){e.PROD="prod",e.VK_ALIAS="vk_alias",e.VIDEOTEST="videotest",e.TEST="test",e.AUTO="auto"})(C||(C={}));var b;(function(e){e.Q144P="144",e.Q240P="240",e.Q360P="360",e.Q480P="480",e.Q720P="720",e.Q1080P="1080",e.Q1440P="1440",e.Q2160P="2160",e.Q4320P="4320",e.UNKNOWN="unknown"})(b||(b={}));var Le;(function(e){e.CHROMECAST="chromecast",e.APPLE_TV="appletv",e.PIP="pip",e.HEADPHONES="externalHeadphones",e.SCREEN=""})(Le||(Le={}));var _;(function(e){e.MP4="mp4",e.DASH="dash",e.DASH_SEP="dash_sep",e.ONDEMAND_DASH="ondemand_dash",e.HLS="hls",e.ONDEMAND_HLS="ondemand_hls",e.WEBM="webm",e.RTMP="rtmp",e.UNKNOWN="unknown"})(_||(_={}));var Me;(function(e){e.AUTO="auto",e.MANUAL=""})(Me||(Me={}));var ue;(function(e){e.HTTP1="http1",e.HTTP2="http2",e.HTTP3="http3"})(ue||(ue={}));var Ue;(function(e){e[e.YES=1]="YES",e[e.NO=0]="NO"})(Ue||(Ue={}));const on="1.0.34",tv="es2015.esm.js",nv="CIOPGQJGDIHBABABA",bo={[C.PROD]:"https://api.ok.ru",[C.VK_ALIAS]:"https://api.mycdn.me",[C.VIDEOTEST]:"https://videotestapi.ok.ru/api",[C.TEST]:"https://apitest.ok.ru",[C.AUTO]:""},ov={start:1e3,factor:1.5,max:5*60*1e3,random:.1};var k;(function(e){e[e.PARAM_SESSION_EXPIRED=102]="PARAM_SESSION_EXPIRED",e[e.PARAM_SESSION_KEY=103]="PARAM_SESSION_KEY",e[e.PARAM_SIGNATURE=104]="PARAM_SIGNATURE",e[e.AUTH_LOGIN=401]="AUTH_LOGIN"})(k||(k={}));class av{constructor(r){this.consequentAuthErrors=0,this.authorized$=new Oo(!1),this.params=r;const t=nn.get("uuid");t?this.uuid=String(t):(this.uuid=rv(),nn.set("uuid",this.uuid))}authorize(r){return N(this,void 0,void 0,function*(){return this.authToken=r!=null?r:yield this.refreshAuthToken(),this._authorizeWithBackoff()})}logBeacon(r){const t="log.externalLog",n=this.createLogParams(r),o=this.sessionKey;if(!o)return;this.params.apiTransport.sendBeacon(t,n,o)||this.logRequest(r)}logRequest(r){var t;return N(this,void 0,void 0,function*(){const n="log.externalLog",o=this.createLogParams(r),a=(t=this.sessionKey)!==null&&t!==void 0?t:yield this._authorizeWithBackoff();if(!a)return;const i=(v,u=this.params.requestRetryCount)=>N(this,void 0,void 0,function*(){try{return yield this.params.apiTransport.sendRequest(n,o,a)}catch(s){if(!s||!("error_code"in s)){this.params.error$.next({id:"logRequestUnknown",category:E.NETWORK,message:`Unknown ${n} error`,thrown:s});return}const c=s==null?void 0:s.error_code;switch(c){case k.PARAM_SESSION_EXPIRED:case k.PARAM_SESSION_KEY:case k.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=yield this._authorizeWithBackoff(),u>0?i(v,u-1):void 0;case k.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=yield this.refreshAuthToken(),this.sessionKey=yield this._authorizeWithBackoff(),u>0?i(v,u-1):void 0;default:{this.params.error$.next({id:`LogRequest#${c}`,category:E.EXTERNAL_API,message:`${n} error`,data:s});return}}}});return i(r)})}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}refreshAuthToken(){return N(this,void 0,void 0,function*(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=mr(this.params.refreshAuthToken(),()=>{this.refreshAuthTokenPromise=void 0})),this.refreshAuthTokenPromise})}createLogParams(r){return{collector:"ok.mobile.apps.video",data:JSON.stringify({application:`${tv}:${on}`,platform:"WEB",items:r.map(t=>Object.assign(Object.assign({},t),{time:0,type:1}))})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const r=_o(this.consequentAuthErrors,ov);return new Promise(t=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout(()=>{mr(this._authorize().then(t).catch(n=>this.params.error$.next({id:"AuthorizeBackoff",category:E.NETWORK,message:"Otherwise unhandle errror in authrization",thrown:n})),()=>this.backoffTimeoutId=0)},r))})}_authorize(){return N(this,void 0,void 0,function*(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const r="auth.anonymLogin",t={session_data:{version:2,device_id:this.uuid,client_version:on.split("-")[0],client_type:"SDK_JS"}};return this.authToken!==void 0&&(t.session_data.auth_token=this.authToken,t.session_data.version=3),this.authorizePromise=mr(this.params.apiTransport.sendRequest(r,t).then(n=>{var o;return(!n||!n.session_key)&&this.params.error$.next({id:"AuthorizeFailed",category:E.EXTERNAL_API,message:"No session key",data:n}),this.sessionKey=(o=n==null?void 0:n.session_key)!==null&&o!==void 0?o:void 0,this.sessionKey}).catch(n=>N(this,void 0,void 0,function*(){this.sessionKey=void 0;const o=n==null?void 0:n.error_code;switch(o){case k.AUTH_LOGIN:return this.authToken=yield this.refreshAuthToken(),this._authorizeWithBackoff()}o?this.params.error$.next({id:`Authorize#${o}`,category:E.EXTERNAL_API,message:"authorize error",data:n}):this.params.error$.next({id:"AuthorizeUnknown",category:E.NETWORK,message:"authorize error",thrown:n})})),()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise})}}class an{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(r,t,n){r in this.listeners||(this.listeners[r]=[]),this.listeners[r].push({callback:t,options:n})}removeEventListener(r,t){if(!(r in this.listeners))return;const n=this.listeners[r];for(let o=0,a=n.length;o<a;o++)if(n[o].callback===t){n.splice(o,1);return}}dispatchEvent(r){if(!(r.type in this.listeners))return;const n=this.listeners[r.type].slice();for(let o=0,a=n.length;o<a;o++){const i=n[o];try{i.callback.call(this,r)}catch(v){Promise.resolve().then(()=>{throw v})}i.options&&i.options.once&&this.removeEventListener(r.type,i.callback)}return!r.defaultPrevented}}class mo extends an{constructor(){super(),this.listeners||an.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(r){r.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,r)),super.dispatchEvent(r)}}class iv{constructor(){Object.defineProperty(this,"signal",{value:new mo,writable:!0,configurable:!0})}abort(r){let t;try{t=new Event("abort")}catch(o){typeof document!="undefined"?document.createEvent?(t=document.createEvent("Event"),t.initEvent("abort",!1,!1)):(t=document.createEventObject(),t.type="abort"):t={type:"abort",bubbles:!1,cancelable:!1}}let n=r;if(n===void 0)if(typeof document=="undefined")n=new Error("This operation was aborted"),n.name="AbortError";else try{n=new DOMException("signal is aborted without reason")}catch(o){n=new Error("This operation was aborted"),n.name="AbortError"}this.signal.reason=n,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}}typeof Symbol!="undefined"&&Symbol.toStringTag&&(iv.prototype[Symbol.toStringTag]="AbortController",mo.prototype[Symbol.toStringTag]="AbortSignal");function Eo(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 sv(e){typeof e=="function"&&(e={fetch:e});const{fetch:r,Request:t=r.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o=!1}=e;if(!Eo({fetch:r,Request:t,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:r,Request:a};let a=t;(a&&!a.prototype.hasOwnProperty("signal")||o)&&(a=function(s,c){let l;c&&c.signal&&(l=c.signal,delete c.signal);const h=new t(s,c);return l&&Object.defineProperty(h,"signal",{writable:!1,enumerable:!1,configurable:!0,value:l}),h},a.prototype=t.prototype);const i=r;return{fetch:(u,s)=>{const c=a&&a.prototype.isPrototypeOf(u)?u.signal:s?s.signal:void 0;if(c){let l;try{l=new DOMException("Aborted","AbortError")}catch(f){l=new Error("Aborted"),l.name="AbortError"}if(c.aborted)return Promise.reject(l);const h=new Promise((f,m)=>{c.addEventListener("abort",()=>m(l),{once:!0})});return s&&s.signal&&delete s.signal,Promise.race([h,i(u,s)])}return i(u,s)},Request:a}}const Yr=Eo({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),So=Yr?sv({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,sn=Yr?So.fetch:window.fetch;Yr?So.Request:window.Request;class cv{constructor(r){this.params=r,this.apiKey=r.apiKey,this.apiEnv=r.apiEnv,this.apiBaseUrl=r.apiBaseUrl,this.timeSynchronisation=r.timeSynchronisation,this.isApiBaseUrlFetched=!1}resolveApiBaseUrl(){var r;return N(this,void 0,void 0,function*(){if(this.apiEnv!==C.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const t=atob("aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ="),o=yield(yield sn(t,{method:"GET",mode:"cors",cache:"no-cache"})).json(),a=(r=o==null?void 0:o.Answer[0])===null||r===void 0?void 0:r.data;if(!a)throw new Error("Wrong DNS response");return a}catch(t){return this.params.error$.next({id:"OneStat:ApiTransport:resolveApiBaseUrl",category:E.NETWORK,message:"Unhandled resolve api base url error",thrown:t}),bo[C.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}})}sendBeacon(r,t,n){if(!window.Blob||!window.navigator.sendBeacon)return!1;const o=this._prepareQueryParams({method:r,queryParams:t,sessionKey:n}),a=new window.Blob([o.toString()],{type:"application/x-www-form-urlencoded"});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,a)}catch(i){this.params.error$.next({id:"OneStat:ApiTransport:sendBeacon",category:E.NETWORK,message:"Unhandled beacon error",thrown:i,data:{method:r,params:t}})}return!1}sendRequest(r,t,n){return N(this,void 0,void 0,function*(){const o=ie(),a=i=>{if(i instanceof TypeError&&["Failed to fetch","NetworkError when attempting to fetch resource."].includes(i.message)){this.params.error$.next({id:"Network",category:E.NETWORK,message:"Request failed",thrown:i});return}this.params.error$.next({id:"OneStat:ApiTransport:sendRequest",category:E.NETWORK,message:"Unhandled request error",thrown:i,data:{method:r,params:t,sessionKey:n,time:ie()-o}})};return this.apiBaseUrl=yield this.resolveApiBaseUrl(),sn(`${this.apiBaseUrl}/fb.do`,{method:"post",headers:{"Content-type":"application/x-www-form-urlencoded"},body:this._prepareQueryParams({method:r,queryParams:t,sessionKey:n})}).then(i=>{var v;const u=Number(i.headers.get("content-length"))===0,s=new Date((v=i.headers.get("date"))!==null&&v!==void 0?v:"").getTime(),c=ie()-o;if(isFinite(s)&&this.timeSynchronisation.addServerTime(s,c),!u)return i.json().then(l=>Object.prototype.hasOwnProperty.call(l,"error_msg")?Promise.reject(l):l,a)},a)})}_prepareQueryParams(r){const t=new URLSearchParams({format:"JSON",method:r.method,application_key:this.apiKey});return r.sessionKey!==void 0&&t.append("session_key",r.sessionKey),Object.entries(r.queryParams).forEach(([n,o])=>t.append(n,typeof o=="string"?o:JSON.stringify(o))),t}}const To=3e3,uv=To*5;class lv{constructor(r){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=Ao(()=>{var t;try{this.flush()}catch(n){this.error$.next({id:"LoggerError",category:E.WTF,message:(t=String(n))!==null&&t!==void 0?t:"Unknown logger error",thrown:n})}},To,{maxWait:uv}),this.api=r.api,this.error$=r.error$,this.subscription=this.api.authorized$.subscribe(t=>{t&&this.debouncedFlush()})}log(r){this.requestQueue.push(r),this.isPaused||this.debouncedFlush()}flush(r=!1){this.requestQueue.length!==0&&(this.api.authorized$.getValue()?(r?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[]):this.api.authorize(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe()}}class vv{constructor(r){this.offset=void 0,this.offset=r}getOffset(){var r;return(r=this.offset)!==null&&r!==void 0?r:0}setOffset(r){this.offset=r}now(){var r;return Date.now()+((r=this.offset)!==null&&r!==void 0?r:0)}date(r=new Date){var t;return r.setTime(r.getTime()+((t=this.offset)!==null&&t!==void 0?t:0)),r}addServerTime(r,t){const n=Date.now(),o=r-n-t/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)}}const cn=()=>Math.floor(Math.random()*Math.pow(2,32)).toString(36).padStart(8,"0"),fv=e=>e&&{[T.INVARIANT]:b.UNKNOWN,[T.Q_144P]:b.Q144P,[T.Q_240P]:b.Q240P,[T.Q_360P]:b.Q360P,[T.Q_480P]:b.Q480P,[T.Q_720P]:b.Q720P,[T.Q_1080P]:b.Q1080P,[T.Q_1440P]:b.Q1440P,[T.Q_2160P]:b.Q2160P,[T.Q_4320P]:b.Q4320P}[e],hv=e=>e&&{[ze.HTTP1]:ue.HTTP1,[ze.HTTP2]:ue.HTTP2,[ze.QUIC]:ue.HTTP3}[e],dv=e=>{if(e!==void 0)switch(e){case y.MPEG:return _.MP4;case y.DASH:case y.DASH_LIVE:case y.DASH_LIVE_CMAF:return _.DASH;case y.DASH_SEP:return _.DASH_SEP;case y.DASH_ONDEMAND:return _.ONDEMAND_DASH;case y.DASH_WEBM:case y.DASH_LIVE_WEBM:return _.WEBM;case y.HLS:case y.HLS_LIVE:case y.HLS_LIVE_CMAF:return _.HLS;case y.HLS_ONDEMAND:return _.ONDEMAND_HLS;case y.WEB_RTC_LIVE:return _.RTMP;default:return Po(e)}};class $v{constructor(r,t){var n;this.subscription=new Jr,this.timeSynchronisation=new vv,this.vsid=cn(),this.fieldBlacklist=[],this.statContext=r,this.config=Object.assign(Object.assign({},(n=t.config)!==null&&n!==void 0?n:{}),{requestRetryCount:1});const o=new Io;this.experimental={error$:o};const a=new cv({apiKey:nv,apiBaseUrl:bo[t.apiEnv],apiEnv:t.apiEnv,error$:o,timeSynchronisation:this.timeSynchronisation});this.api=new av({apiTransport:a,refreshAuthToken:t.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:o}),this.logger=new lv({api:this.api,error$:o}),this.subscription.add(wo(window,"beforeunload").subscribe(()=>this.logger.flush(!0)))}updateContext(r){this.statContext=Object.assign(Object.assign({},this.statContext),r)}attachTo(r){let t;return new Jr().add(r.events.started$.subscribe(()=>{this.logStarted({position:r.info.position$.getValue()})})).add(r.events.looped$.subscribe(()=>{this.resetViewSession(),this.logStarted({position:r.info.position$.getValue()})})).add(r.events.seeked$.subscribe(()=>{this.logSeek()})).add(r.events.willPause$.subscribe(()=>{this.logPause({position:r.info.position$.getValue()})})).add(r.events.willResume$.subscribe(()=>{this.logPlay()})).add(r.events.managedError$.subscribe(({id:n})=>{this.logError({errorType:n})})).add(r.events.fatalError$.subscribe(({id:n})=>{this.logError({errorType:n})})).add(r.events.inited$.subscribe(()=>{this.logInited()})).add(r.events.canplay$.subscribe(n=>{this.logReady({time:n})})).add(r.events.firstBytes$.subscribe(n=>{this.logFirstBytes({time:n})})).add(r.events.firstFrame$.subscribe(n=>{this.logFirstFrame({time:n})})).add(r.events.watchCoverageRecord$.subscribe(n=>{this.logWatchCoverageRecord(n)})).add(r.events.watchCoverageLive$.subscribe(n=>{this.logWatchCoverageLive(n)})).add(r.info.isStalled$.subscribe(n=>{n?t=ie():(Xr(t)&&this.logEmptyBuffer({duration:ie()-t}),t=void 0)})).add(r.events.ended$.subscribe(()=>{const n=r.info.throughputEstimation$.getValue();Xr(n)&&this.logDownloadSpeed({speed:n/8})})).add(r.info.hostname$.subscribe(n=>{this.updateContext({cdnHostname:n})})).add(r.info.httpConnectionType$.subscribe(n=>{this.updateContext({connectionType:hv(n)})})).add(r.info.httpConnectionReused$.subscribe(n=>{this.updateContext({connectionReused:n})})).add(r.info.currentQuality$.subscribe(n=>{this.updateContext({quality:fv(n)})})).add(r.info.currentFormat$.subscribe(n=>{this.updateContext({contentType:dv(n)})})).add(r.info.chromecastState$.subscribe(n=>{this.updateContext({destination:n===Ro.CONNECTED?Le.CHROMECAST:Le.SCREEN})}))}authorize(r){return this.api.authorize(r)}pause(){this.logger.pause()}resume(){this.logger.resume()}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}resetViewSession(){this.vsid=cn()}setFieldBlacklist(r=[]){this.fieldBlacklist=r}logInited(){this.log({operation:"init"})}logReady(r){this.log({operation:"player_ready",param:String(r.time)})}logStarted(r){this.log({operation:"play",param:String(Math.round(r.position))})}logPlay(){this.log({operation:"play_toggle"})}logPause(r){this.log({operation:"pause",param:String(Math.round(r.position))})}logSeek(){this.log({operation:"seek"})}logFirstBytes(r){this.log({operation:"first_bytes",param:String(r.time)})}logFirstFrame(r){this.log({operation:"first_frame",param:String(r.time)})}logError(r){this.log({operation:"error",param:r.errorType})}logWatchCoverageRecord(r){this.log({operation:"watch_coverage_record",param:`${r.start}-${r.end}`}),this.logger.flush(!0)}logWatchCoverageLive(r){const t=r.start+this.timeSynchronisation.getOffset(),n=r.end+this.timeSynchronisation.getOffset();this.log({operation:"watch_coverage_live",param:`${t}-${n}`}),this.logger.flush(!0)}logEmptyBuffer(r){this.log({operation:"empty_buffer",param:String(r.duration)})}logDownloadSpeed(r){this.log({operation:"download_speed",param:String(r.speed)})}logAdSlotRequest(){this.log({operation:"adv",param:"slot_request"})}logAdStarted(r){this.log({operation:"adv",param:r})}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"})}log(r){const t=this.createLogItem(r);this.logger.log(t)}createLogItem({operation:r,param:t}){const n=this.timeSynchronisation.now(),o={vsid:this.vsid,vid:this.statContext.movieId,quality:this.statContext.quality,dst:this.statContext.destination,ct:this.statContext.contentType,aid:this.statContext.albumId,place:this.statContext.place,cdn_host:this.statContext.cdnHostname,connection_type:this.statContext.connectionType,connection_reused:this.statContext.connectionReused===!0?Ue.YES:this.statContext.connectionReused===!1?Ue.NO:void 0,stat_type:this.statContext.autoplay===!0?Me.AUTO:this.statContext.autoplay===!1?Me.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode};t!==void 0&&(o.param=t);for(const a of this.fieldBlacklist)delete o[a];return{operation:r,timestamp:n,custom:o}}}export{C as ApiEnv,ue as ConnectionType,_ as ContentType,$v as OneStat,b as Quality,Le as ScreenDestination};
6
+ import{ValueSubject as Hr,safeStorage as at,getExponentialDelay as xo,ErrorCategory as T,now as S,assertNever as mn,Observable as Uo,Subscription as fe,merge as Ae,fromEvent as wr,filterChanged as Mo,map as ko,filter as it,isNullable as Ir,Subject as Bo,once as Fo,combine as st,observableFrom as Vo,isNonNullable as ce}from"@vkontakte/videoplayer-shared/es2015.esm.js";import Ho from"lodash/debounce.js";import{Surface as ue,VideoQuality as O,HttpConnectionType as Ze,VideoFormat as $,PlaybackState as ct}from"@vkontakte/videoplayer-core/es2015.esm.js";function L(e,r,t,n){function o(i){return i instanceof t?i:new t(function(s){s(i)})}return new(t||(t=Promise))(function(i,s){function f(a){try{c(n.next(a))}catch(u){s(u)}}function l(a){try{c(n.throw(a))}catch(u){s(u)}}function c(a){a.done?i(a.value):o(a.value).then(f,l)}c((n=n.apply(e,r||[])).next())})}var ut=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},me=function(e){return e&&e.Math==Math&&e},y=me(typeof globalThis=="object"&&globalThis)||me(typeof window=="object"&&window)||me(typeof self=="object"&&self)||me(typeof ut=="object"&&ut)||function(){return this}()||Function("return this")(),w=function(e){try{return!!e()}catch(r){return!0}},Ko=w,He=!Ko(function(){var e=function(){}.bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),qo=He,En=Function.prototype,lt=En.apply,ft=En.call,Sn=typeof Reflect=="object"&&Reflect.apply||(qo?ft.bind(lt):function(){return ft.apply(lt,arguments)}),Tn=He,_n=Function.prototype,Rr=_n.call,Wo=Tn&&_n.bind.bind(Rr,Rr),I=Tn?Wo:function(e){return function(){return Rr.apply(e,arguments)}},On=I,Go=On({}.toString),zo=On("".slice),Ke=function(e){return zo(Go(e),8,-1)},Qo=Ke,Yo=I,Pn=function(e){if(Qo(e)==="Function")return Yo(e)},Ar=typeof document=="object"&&document.all,Jo=typeof Ar=="undefined"&&Ar!==void 0,wn={all:Ar,IS_HTMLDDA:Jo},In=wn,Xo=In.all,h=In.IS_HTMLDDA?function(e){return typeof e=="function"||e===Xo}:function(e){return typeof e=="function"},Kr={},Zo=w,oe=!Zo(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),ea=He,Ee=Function.prototype.call,R=ea?Ee.bind(Ee):function(){return Ee.apply(Ee,arguments)},Rn={},An={}.propertyIsEnumerable,Cn=Object.getOwnPropertyDescriptor,ra=Cn&&!An.call({1:2},1);Rn.f=ra?function(r){var t=Cn(this,r);return!!t&&t.enumerable}:An;var Nn=function(e,r){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:r}},ta=I,na=w,oa=Ke,er=Object,aa=ta("".split),ia=na(function(){return!er("z").propertyIsEnumerable(0)})?function(e){return oa(e)=="String"?aa(e,""):er(e)}:er,qe=function(e){return e==null},sa=qe,ca=TypeError,Dn=function(e){if(sa(e))throw ca("Can't call method on "+e);return e},ua=ia,la=Dn,fa=function(e){return ua(la(e))},vt=h,Ln=wn,va=Ln.all,H=Ln.IS_HTMLDDA?function(e){return typeof e=="object"?e!==null:vt(e)||e===va}:function(e){return typeof e=="object"?e!==null:vt(e)},jn={},rr=jn,tr=y,da=h,dt=function(e){return da(e)?e:void 0},x=function(e,r){return arguments.length<2?dt(rr[e])||dt(tr[e]):rr[e]&&rr[e][r]||tr[e]&&tr[e][r]},ha=I,qr=ha({}.isPrototypeOf),We=typeof navigator!="undefined"&&String(navigator.userAgent)||"",xn=y,nr=We,ht=xn.process,pt=xn.Deno,yt=ht&&ht.versions||pt&&pt.version,$t=yt&&yt.v8,_,Le;$t&&(_=$t.split("."),Le=_[0]>0&&_[0]<4?1:+(_[0]+_[1]));!Le&&nr&&(_=nr.match(/Edge\/(\d+)/),(!_||_[1]>=74)&&(_=nr.match(/Chrome\/(\d+)/),_&&(Le=+_[1])));var Un=Le,bt=Un,pa=w,Mn=!!Object.getOwnPropertySymbols&&!pa(function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&bt&&bt<41}),ya=Mn,kn=ya&&!Symbol.sham&&typeof Symbol.iterator=="symbol",$a=x,ba=h,ga=qr,ma=kn,Ea=Object,Bn=ma?function(e){return typeof e=="symbol"}:function(e){var r=$a("Symbol");return ba(r)&&ga(r.prototype,Ea(e))},Sa=String,Ge=function(e){try{return Sa(e)}catch(r){return"Object"}},Ta=h,_a=Ge,Oa=TypeError,K=function(e){if(Ta(e))return e;throw Oa(_a(e)+" is not a function")},Pa=K,wa=qe,Wr=function(e,r){var t=e[r];return wa(t)?void 0:Pa(t)},or=R,ar=h,ir=H,Ia=TypeError,Ra=function(e,r){var t,n;if(r==="string"&&ar(t=e.toString)&&!ir(n=or(t,e))||ar(t=e.valueOf)&&!ir(n=or(t,e))||r!=="string"&&ar(t=e.toString)&&!ir(n=or(t,e)))return n;throw Ia("Can't convert object to primitive value")},je={},Aa={get exports(){return je},set exports(e){je=e}},$e=!0,gt=y,Ca=Object.defineProperty,Na=function(e,r){try{Ca(gt,e,{value:r,configurable:!0,writable:!0})}catch(t){gt[e]=r}return r},Da=y,La=Na,mt="__core-js_shared__",ja=Da[mt]||La(mt,{}),Gr=ja,Et=Gr;(Aa.exports=function(e,r){return Et[e]||(Et[e]=r!==void 0?r:{})})("versions",[]).push({version:"3.27.2",mode:"pure",copyright:"\xA9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.27.2/LICENSE",source:"https://github.com/zloirock/core-js"});var xa=Dn,Ua=Object,Ma=function(e){return Ua(xa(e))},ka=I,Ba=Ma,Fa=ka({}.hasOwnProperty),ae=Object.hasOwn||function(r,t){return Fa(Ba(r),t)},Va=I,Ha=0,Ka=Math.random(),qa=Va(1 .toString),Fn=function(e){return"Symbol("+(e===void 0?"":e)+")_"+qa(++Ha+Ka,36)},Wa=y,Ga=je,St=ae,za=Fn,Qa=Mn,Ya=kn,Z=Wa.Symbol,sr=Ga("wks"),Ja=Ya?Z.for||Z:Z&&Z.withoutSetter||za,A=function(e){return St(sr,e)||(sr[e]=Qa&&St(Z,e)?Z[e]:Ja("Symbol."+e)),sr[e]},Xa=R,Tt=H,_t=Bn,Za=Wr,ei=Ra,ri=A,ti=TypeError,ni=ri("toPrimitive"),oi=function(e,r){if(!Tt(e)||_t(e))return e;var t=Za(e,ni),n;if(t){if(r===void 0&&(r="default"),n=Xa(t,e,r),!Tt(n)||_t(n))return n;throw ti("Can't convert object to primitive value")}return r===void 0&&(r="number"),ei(e,r)},ai=oi,ii=Bn,Vn=function(e){var r=ai(e,"string");return ii(r)?r:r+""},si=y,Ot=H,Cr=si.document,ci=Ot(Cr)&&Ot(Cr.createElement),Hn=function(e){return ci?Cr.createElement(e):{}},ui=oe,li=w,fi=Hn,Kn=!ui&&!li(function(){return Object.defineProperty(fi("div"),"a",{get:function(){return 7}}).a!=7}),vi=oe,di=R,hi=Rn,pi=Nn,yi=fa,$i=Vn,bi=ae,gi=Kn,Pt=Object.getOwnPropertyDescriptor;Kr.f=vi?Pt:function(r,t){if(r=yi(r),t=$i(t),gi)try{return Pt(r,t)}catch(n){}if(bi(r,t))return pi(!di(hi.f,r,t),r[t])};var mi=w,Ei=h,Si=/#|\.prototype\./,be=function(e,r){var t=_i[Ti(e)];return t==Pi?!0:t==Oi?!1:Ei(r)?mi(r):!!r},Ti=be.normalize=function(e){return String(e).replace(Si,".").toLowerCase()},_i=be.data={},Oi=be.NATIVE="N",Pi=be.POLYFILL="P",qn=be,wt=Pn,wi=K,Ii=He,Ri=wt(wt.bind),ze=function(e,r){return wi(e),r===void 0?e:Ii?Ri(e,r):function(){return e.apply(r,arguments)}},Qe={},Ai=oe,Ci=w,Ni=Ai&&Ci(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),Di=H,Li=String,ji=TypeError,q=function(e){if(Di(e))return e;throw ji(Li(e)+" is not an object")},xi=oe,Ui=Kn,Mi=Ni,Se=q,It=Vn,ki=TypeError,cr=Object.defineProperty,Bi=Object.getOwnPropertyDescriptor,ur="enumerable",lr="configurable",fr="writable";Qe.f=xi?Mi?function(r,t,n){if(Se(r),t=It(t),Se(n),typeof r=="function"&&t==="prototype"&&"value"in n&&fr in n&&!n[fr]){var o=Bi(r,t);o&&o[fr]&&(r[t]=n.value,n={configurable:lr in n?n[lr]:o[lr],enumerable:ur in n?n[ur]:o[ur],writable:!1})}return cr(r,t,n)}:cr:function(r,t,n){if(Se(r),t=It(t),Se(n),Ui)try{return cr(r,t,n)}catch(o){}if("get"in n||"set"in n)throw ki("Accessors not supported");return"value"in n&&(r[t]=n.value),r};var Fi=oe,Vi=Qe,Hi=Nn,Ye=Fi?function(e,r,t){return Vi.f(e,r,Hi(1,t))}:function(e,r,t){return e[r]=t,e},Te=y,Ki=Sn,qi=Pn,Wi=h,Gi=Kr.f,zi=qn,z=jn,Qi=ze,Q=Ye,Rt=ae,Yi=function(e){var r=function(t,n,o){if(this instanceof r){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,n)}return new e(t,n,o)}return Ki(e,this,arguments)};return r.prototype=e.prototype,r},W=function(e,r){var t=e.target,n=e.global,o=e.stat,i=e.proto,s=n?Te:o?Te[t]:(Te[t]||{}).prototype,f=n?z:z[t]||Q(z,t,{})[t],l=f.prototype,c,a,u,v,d,p,U,C,G;for(v in r)c=zi(n?v:t+(o?".":"#")+v,e.forced),a=!c&&s&&Rt(s,v),p=f[v],a&&(e.dontCallGetSet?(G=Gi(s,v),U=G&&G.value):U=s[v]),d=a&&U?U:r[v],!(a&&typeof p==typeof d)&&(e.bind&&a?C=Qi(d,Te):e.wrap&&a?C=Yi(d):i&&Wi(d)?C=qi(d):C=d,(e.sham||d&&d.sham||p&&p.sham)&&Q(C,"sham",!0),Q(f,v,C),i&&(u=t+"Prototype",Rt(z,u)||Q(z,u,{}),Q(z[u],v,d),e.real&&l&&(c||!l[v])&&Q(l,v,d)))},Ji=Ke,Je=typeof process!="undefined"&&Ji(process)=="process",Xi=Ye,zr=function(e,r,t,n){return n&&n.enumerable?e[r]=t:Xi(e,r,t),e},Zi=h,es=String,rs=TypeError,ts=function(e){if(typeof e=="object"||Zi(e))return e;throw rs("Can't set "+es(e)+" as a prototype")},ns=I,os=q,as=ts,is=Object.setPrototypeOf||("__proto__"in{}?function(){var e=!1,r={},t;try{t=ns(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set),t(r,[]),e=r instanceof Array}catch(n){}return function(o,i){return os(o),as(i),e?t(o,i):o.__proto__=i,o}}():void 0),ss=A,cs=ss("toStringTag"),Wn={};Wn[cs]="z";var Qr=String(Wn)==="[object z]",us=Qr,ls=h,Ce=Ke,fs=A,vs=fs("toStringTag"),ds=Object,hs=Ce(function(){return arguments}())=="Arguments",ps=function(e,r){try{return e[r]}catch(t){}},Yr=us?Ce:function(e){var r,t,n;return e===void 0?"Undefined":e===null?"Null":typeof(t=ps(r=ds(e),vs))=="string"?t:hs?Ce(r):(n=Ce(r))=="Object"&&ls(r.callee)?"Arguments":n},ys=Qr,$s=Yr,bs=ys?{}.toString:function(){return"[object "+$s(this)+"]"},gs=Qr,ms=Qe.f,Es=Ye,Ss=ae,Ts=bs,_s=A,At=_s("toStringTag"),Os=function(e,r,t,n){if(e){var o=t?e:e.prototype;Ss(o,At)||ms(o,At,{configurable:!0,value:r}),n&&!gs&&Es(o,"toString",Ts)}},Ps=x,ws=Qe,Is=A,Rs=oe,Ct=Is("species"),As=function(e){var r=Ps(e),t=ws.f;Rs&&r&&!r[Ct]&&t(r,Ct,{configurable:!0,get:function(){return this}})},Cs=qr,Ns=TypeError,Ds=function(e,r){if(Cs(r,e))return e;throw Ns("Incorrect invocation")},Ls=I,js=h,Nr=Gr,xs=Ls(Function.toString);js(Nr.inspectSource)||(Nr.inspectSource=function(e){return xs(e)});var Gn=Nr.inspectSource,Us=I,Ms=w,zn=h,ks=Yr,Bs=x,Fs=Gn,Qn=function(){},Vs=[],Yn=Bs("Reflect","construct"),Jr=/^\s*(?:class|function)\b/,Hs=Us(Jr.exec),Ks=!Jr.exec(Qn),le=function(r){if(!zn(r))return!1;try{return Yn(Qn,Vs,r),!0}catch(t){return!1}},Jn=function(r){if(!zn(r))return!1;switch(ks(r)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Ks||!!Hs(Jr,Fs(r))}catch(t){return!0}};Jn.sham=!0;var qs=!Yn||Ms(function(){var e;return le(le.call)||!le(Object)||!le(function(){e=!0})||e})?Jn:le,Ws=qs,Gs=Ge,zs=TypeError,Qs=function(e){if(Ws(e))return e;throw zs(Gs(e)+" is not a constructor")},Nt=q,Ys=Qs,Js=qe,Xs=A,Zs=Xs("species"),Xn=function(e,r){var t=Nt(e).constructor,n;return t===void 0||Js(n=Nt(t)[Zs])?r:Ys(n)},ec=x,rc=ec("document","documentElement"),tc=I,nc=tc([].slice),oc=TypeError,ac=function(e,r){if(e<r)throw oc("Not enough arguments");return e},ic=We,Zn=/(?:ipad|iphone|ipod).*applewebkit/i.test(ic),b=y,sc=Sn,cc=ze,Dt=h,uc=ae,eo=w,Lt=rc,lc=nc,jt=Hn,fc=ac,vc=Zn,dc=Je,Dr=b.setImmediate,Lr=b.clearImmediate,hc=b.process,vr=b.Dispatch,pc=b.Function,xt=b.MessageChannel,yc=b.String,dr=0,ve={},Ut="onreadystatechange",pe,M,hr,pr;eo(function(){pe=b.location});var Xr=function(e){if(uc(ve,e)){var r=ve[e];delete ve[e],r()}},yr=function(e){return function(){Xr(e)}},Mt=function(e){Xr(e.data)},kt=function(e){b.postMessage(yc(e),pe.protocol+"//"+pe.host)};(!Dr||!Lr)&&(Dr=function(r){fc(arguments.length,1);var t=Dt(r)?r:pc(r),n=lc(arguments,1);return ve[++dr]=function(){sc(t,void 0,n)},M(dr),dr},Lr=function(r){delete ve[r]},dc?M=function(e){hc.nextTick(yr(e))}:vr&&vr.now?M=function(e){vr.now(yr(e))}:xt&&!vc?(hr=new xt,pr=hr.port2,hr.port1.onmessage=Mt,M=cc(pr.postMessage,pr)):b.addEventListener&&Dt(b.postMessage)&&!b.importScripts&&pe&&pe.protocol!=="file:"&&!eo(kt)?(M=kt,b.addEventListener("message",Mt,!1)):Ut in jt("script")?M=function(e){Lt.appendChild(jt("script"))[Ut]=function(){Lt.removeChild(this),Xr(e)}}:M=function(e){setTimeout(yr(e),0)});var ro={set:Dr,clear:Lr},to=function(){this.head=null,this.tail=null};to.prototype={add:function(e){var r={item:e,next:null},t=this.tail;t?t.next=r:this.head=r,this.tail=r},get:function(){var e=this.head;if(e){var r=this.head=e.next;return r===null&&(this.tail=null),e.item}}};var no=to,$c=We,bc=/ipad|iphone|ipod/i.test($c)&&typeof Pebble!="undefined",gc=We,mc=/web0s(?!.*chrome)/i.test(gc),V=y,Bt=ze,Ec=Kr.f,$r=ro.set,Sc=no,Tc=Zn,_c=bc,Oc=mc,br=Je,Ft=V.MutationObserver||V.WebKitMutationObserver,Vt=V.document,Ht=V.process,_e=V.Promise,Kt=Ec(V,"queueMicrotask"),jr=Kt&&Kt.value,Y,gr,mr,Oe,qt;if(!jr){var Pe=new Sc,we=function(){var e,r;for(br&&(e=Ht.domain)&&e.exit();r=Pe.get();)try{r()}catch(t){throw Pe.head&&Y(),t}e&&e.enter()};!Tc&&!br&&!Oc&&Ft&&Vt?(gr=!0,mr=Vt.createTextNode(""),new Ft(we).observe(mr,{characterData:!0}),Y=function(){mr.data=gr=!gr}):!_c&&_e&&_e.resolve?(Oe=_e.resolve(void 0),Oe.constructor=_e,qt=Bt(Oe.then,Oe),Y=function(){qt(we)}):br?Y=function(){Ht.nextTick(we)}:($r=Bt($r,V),Y=function(){$r(we)}),jr=function(e){Pe.head||Y(),Pe.add(e)}}var Pc=jr,wc=function(e,r){try{arguments.length==1?console.error(e):console.error(e,r)}catch(t){}},Zr=function(e){try{return{error:!1,value:e()}}catch(r){return{error:!0,value:r}}},Ic=y,Rc=h,Wt=Ic.WeakMap,Ac=Rc(Wt)&&/native code/.test(String(Wt)),Cc=je,Nc=Fn,Gt=Cc("keys"),Dc=function(e){return Gt[e]||(Gt[e]=Nc(e))},Lc={},jc=Ac,oo=y,xc=H,Uc=Ye,Er=ae,Sr=Gr,Mc=Dc,kc=Lc,zt="Object already initialized",xr=oo.TypeError,Bc=oo.WeakMap,xe,ye,Ue,Fc=function(e){return Ue(e)?ye(e):xe(e,{})},Vc=function(e){return function(r){var t;if(!xc(r)||(t=ye(r)).type!==e)throw xr("Incompatible receiver, "+e+" required");return t}};if(jc||Sr.state){var P=Sr.state||(Sr.state=new Bc);P.get=P.get,P.has=P.has,P.set=P.set,xe=function(e,r){if(P.has(e))throw xr(zt);return r.facade=e,P.set(e,r),r},ye=function(e){return P.get(e)||{}},Ue=function(e){return P.has(e)}}else{var J=Mc("state");kc[J]=!0,xe=function(e,r){if(Er(e,J))throw xr(zt);return r.facade=e,Uc(e,J,r),r},ye=function(e){return Er(e,J)?e[J]:{}},Ue=function(e){return Er(e,J)}}var Hc={set:xe,get:ye,has:Ue,enforce:Fc,getterFor:Vc},Kc=y,ie=Kc.Promise,ao=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",qc=ao,Wc=Je,Gc=!qc&&!Wc&&typeof window=="object"&&typeof document=="object",zc=y,de=ie,Qc=h,Yc=qn,Jc=Gn,Xc=A,Zc=Gc,eu=ao,ru=$e,Tr=Un,Qt=de&&de.prototype,tu=Xc("species"),Ur=!1,io=Qc(zc.PromiseRejectionEvent),nu=Yc("Promise",function(){var e=Jc(de),r=e!==String(de);if(!r&&Tr===66||ru&&!(Qt.catch&&Qt.finally))return!0;if(!Tr||Tr<51||!/native code/.test(e)){var t=new de(function(i){i(1)}),n=function(i){i(function(){},function(){})},o=t.constructor={};if(o[tu]=n,Ur=t.then(function(){})instanceof n,!Ur)return!0}return!r&&(Zc||eu)&&!io}),ge={CONSTRUCTOR:nu,REJECTION_EVENT:io,SUBCLASSING:Ur},se={},Yt=K,ou=TypeError,au=function(e){var r,t;this.promise=new e(function(n,o){if(r!==void 0||t!==void 0)throw ou("Bad Promise constructor");r=n,t=o}),this.resolve=Yt(r),this.reject=Yt(t)};se.f=function(e){return new au(e)};var iu=W,su=$e,Me=Je,j=y,ne=R,Jt=zr,Xt=is,cu=Os,uu=As,lu=K,Ne=h,fu=H,vu=Ds,du=Xn,so=ro.set,et=Pc,hu=wc,pu=Zr,yu=no,co=Hc,ke=ie,rt=ge,uo=se,Xe="Promise",lo=rt.CONSTRUCTOR,$u=rt.REJECTION_EVENT,bu=rt.SUBCLASSING,_r=co.getterFor(Xe),gu=co.set,X=ke&&ke.prototype,k=ke,Ie=X,fo=j.TypeError,Mr=j.document,tt=j.process,kr=uo.f,mu=kr,Eu=!!(Mr&&Mr.createEvent&&j.dispatchEvent),vo="unhandledrejection",Su="rejectionhandled",Zt=0,ho=1,Tu=2,nt=1,po=2,Re,en,_u,rn,yo=function(e){var r;return fu(e)&&Ne(r=e.then)?r:!1},$o=function(e,r){var t=r.value,n=r.state==ho,o=n?e.ok:e.fail,i=e.resolve,s=e.reject,f=e.domain,l,c,a;try{o?(n||(r.rejection===po&&Pu(r),r.rejection=nt),o===!0?l=t:(f&&f.enter(),l=o(t),f&&(f.exit(),a=!0)),l===e.promise?s(fo("Promise-chain cycle")):(c=yo(l))?ne(c,l,i,s):i(l)):s(t)}catch(u){f&&!a&&f.exit(),s(u)}},bo=function(e,r){e.notified||(e.notified=!0,et(function(){for(var t=e.reactions,n;n=t.get();)$o(n,e);e.notified=!1,r&&!e.rejection&&Ou(e)}))},go=function(e,r,t){var n,o;Eu?(n=Mr.createEvent("Event"),n.promise=r,n.reason=t,n.initEvent(e,!1,!0),j.dispatchEvent(n)):n={promise:r,reason:t},!$u&&(o=j["on"+e])?o(n):e===vo&&hu("Unhandled promise rejection",t)},Ou=function(e){ne(so,j,function(){var r=e.facade,t=e.value,n=tn(e),o;if(n&&(o=pu(function(){Me?tt.emit("unhandledRejection",t,r):go(vo,r,t)}),e.rejection=Me||tn(e)?po:nt,o.error))throw o.value})},tn=function(e){return e.rejection!==nt&&!e.parent},Pu=function(e){ne(so,j,function(){var r=e.facade;Me?tt.emit("rejectionHandled",r):go(Su,r,e.value)})},ee=function(e,r,t){return function(n){e(r,n,t)}},te=function(e,r,t){e.done||(e.done=!0,t&&(e=t),e.value=r,e.state=Tu,bo(e,!0))},Br=function(e,r,t){if(!e.done){e.done=!0,t&&(e=t);try{if(e.facade===r)throw fo("Promise can't be resolved itself");var n=yo(r);n?et(function(){var o={done:!1};try{ne(n,r,ee(Br,o,e),ee(te,o,e))}catch(i){te(o,i,e)}}):(e.value=r,e.state=ho,bo(e,!1))}catch(o){te({done:!1},o,e)}}};if(lo&&(k=function(r){vu(this,Ie),lu(r),ne(Re,this);var t=_r(this);try{r(ee(Br,t),ee(te,t))}catch(n){te(t,n)}},Ie=k.prototype,Re=function(r){gu(this,{type:Xe,done:!1,notified:!1,parent:!1,reactions:new yu,rejection:!1,state:Zt,value:void 0})},Re.prototype=Jt(Ie,"then",function(r,t){var n=_r(this),o=kr(du(this,k));return n.parent=!0,o.ok=Ne(r)?r:!0,o.fail=Ne(t)&&t,o.domain=Me?tt.domain:void 0,n.state==Zt?n.reactions.add(o):et(function(){$o(o,n)}),o.promise}),en=function(){var e=new Re,r=_r(e);this.promise=e,this.resolve=ee(Br,r),this.reject=ee(te,r)},uo.f=kr=function(e){return e===k||e===_u?new en(e):mu(e)},!su&&Ne(ke)&&X!==Object.prototype)){rn=X.then,bu||Jt(X,"then",function(r,t){var n=this;return new k(function(o,i){ne(rn,n,o,i)}).then(r,t)},{unsafe:!0});try{delete X.constructor}catch(e){}Xt&&Xt(X,Ie)}iu({global:!0,constructor:!0,wrap:!0,forced:lo},{Promise:k});cu(k,Xe,!1,!0);uu(Xe);var mo={},wu=A,Iu=mo,Ru=wu("iterator"),Au=Array.prototype,Cu=function(e){return e!==void 0&&(Iu.Array===e||Au[Ru]===e)},Nu=Math.ceil,Du=Math.floor,Lu=Math.trunc||function(r){var t=+r;return(t>0?Du:Nu)(t)},ju=Lu,xu=function(e){var r=+e;return r!==r||r===0?0:ju(r)},Uu=xu,Mu=Math.min,ku=function(e){return e>0?Mu(Uu(e),9007199254740991):0},Bu=ku,Fu=function(e){return Bu(e.length)},Vu=Yr,nn=Wr,Hu=qe,Ku=mo,qu=A,Wu=qu("iterator"),Eo=function(e){if(!Hu(e))return nn(e,Wu)||nn(e,"@@iterator")||Ku[Vu(e)]},Gu=R,zu=K,Qu=q,Yu=Ge,Ju=Eo,Xu=TypeError,Zu=function(e,r){var t=arguments.length<2?Ju(e):r;if(zu(t))return Qu(Gu(t,e));throw Xu(Yu(e)+" is not iterable")},el=R,on=q,rl=Wr,tl=function(e,r,t){var n,o;on(e);try{if(n=rl(e,"return"),!n){if(r==="throw")throw t;return t}n=el(n,e)}catch(i){o=!0,n=i}if(r==="throw")throw t;if(o)throw n;return on(n),t},nl=ze,ol=R,al=q,il=Ge,sl=Cu,cl=Fu,an=qr,ul=Zu,ll=Eo,sn=tl,fl=TypeError,De=function(e,r){this.stopped=e,this.result=r},cn=De.prototype,So=function(e,r,t){var n=t&&t.that,o=!!(t&&t.AS_ENTRIES),i=!!(t&&t.IS_RECORD),s=!!(t&&t.IS_ITERATOR),f=!!(t&&t.INTERRUPTED),l=nl(r,n),c,a,u,v,d,p,U,C=function(g){return c&&sn(c,"normal",g),new De(!0,g)},G=function(g){return o?(al(g),f?l(g[0],g[1],C):l(g[0],g[1])):f?l(g,C):l(g)};if(i)c=e.iterator;else if(s)c=e;else{if(a=ll(e),!a)throw fl(il(e)+" is not iterable");if(sl(a)){for(u=0,v=cl(e);v>u;u++)if(d=G(e[u]),d&&an(cn,d))return d;return new De(!1)}c=ul(e,a)}for(p=i?e.next:c.next;!(U=ol(p,c)).done;){try{d=G(U.value)}catch(g){sn(c,"throw",g)}if(typeof d=="object"&&d&&an(cn,d))return d}return new De(!1)},vl=A,To=vl("iterator"),_o=!1;try{var dl=0,un={next:function(){return{done:!!dl++}},return:function(){_o=!0}};un[To]=function(){return this},Array.from(un,function(){throw 2})}catch(e){}var hl=function(e,r){if(!r&&!_o)return!1;var t=!1;try{var n={};n[To]=function(){return{next:function(){return{done:t=!0}}}},e(n)}catch(o){}return t},pl=ie,yl=hl,$l=ge.CONSTRUCTOR,Oo=$l||!yl(function(e){pl.all(e).then(void 0,function(){})}),bl=W,gl=R,ml=K,El=se,Sl=Zr,Tl=So,_l=Oo;bl({target:"Promise",stat:!0,forced:_l},{all:function(r){var t=this,n=El.f(t),o=n.resolve,i=n.reject,s=Sl(function(){var f=ml(t.resolve),l=[],c=0,a=1;Tl(r,function(u){var v=c++,d=!1;a++,gl(f,t,u).then(function(p){d||(d=!0,l[v]=p,--a||o(l))},i)}),--a||o(l)});return s.error&&i(s.value),n.promise}});var Ol=W,Pl=$e,wl=ge.CONSTRUCTOR,Fr=ie,Il=x,Rl=h,Al=zr,ln=Fr&&Fr.prototype;Ol({target:"Promise",proto:!0,forced:wl,real:!0},{catch:function(e){return this.then(void 0,e)}});if(!Pl&&Rl(Fr)){var fn=Il("Promise").prototype.catch;ln.catch!==fn&&Al(ln,"catch",fn,{unsafe:!0})}var Cl=W,Nl=R,Dl=K,Ll=se,jl=Zr,xl=So,Ul=Oo;Cl({target:"Promise",stat:!0,forced:Ul},{race:function(r){var t=this,n=Ll.f(t),o=n.reject,i=jl(function(){var s=Dl(t.resolve);xl(r,function(f){Nl(s,t,f).then(n.resolve,o)})});return i.error&&o(i.value),n.promise}});var Ml=W,kl=R,Bl=se,Fl=ge.CONSTRUCTOR;Ml({target:"Promise",stat:!0,forced:Fl},{reject:function(r){var t=Bl.f(this);return kl(t.reject,void 0,r),t.promise}});var Vl=q,Hl=H,Kl=se,Po=function(e,r){if(Vl(e),Hl(r)&&r.constructor===e)return r;var t=Kl.f(e),n=t.resolve;return n(r),t.promise},ql=W,Wl=x,wo=$e,Gl=ie,Io=ge.CONSTRUCTOR,zl=Po,Ql=Wl("Promise"),Yl=wo&&!Io;ql({target:"Promise",stat:!0,forced:wo||Io},{resolve:function(r){return zl(Yl&&this===Ql?Gl:this,r)}});var Jl=W,Xl=$e,Be=ie,Zl=w,Ro=x,Ao=h,ef=Xn,vn=Po,rf=zr,Vr=Be&&Be.prototype,tf=!!Be&&Zl(function(){Vr.finally.call({then:function(){}},function(){})});Jl({target:"Promise",proto:!0,real:!0,forced:tf},{finally:function(e){var r=ef(this,Ro("Promise")),t=Ao(e);return this.then(t?function(n){return vn(r,e()).then(function(){return n})}:e,t?function(n){return vn(r,e()).then(function(){throw n})}:e)}});if(!Xl&&Ao(Be)){var dn=Ro("Promise").prototype.finally;Vr.finally!==dn&&rf(Vr,"finally",dn,{unsafe:!0})}var nf=x,of=nf,af=of,sf=af("Promise","finally"),cf=sf,uf=cf,lf=uf,ff=lf,Or=ff;function vf(){const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),r=new Array(36);let t=0,n,o;for(o=0;o<36;o++)o===8||o===13||o===18||o===23?r[o]="-":o===14?r[o]="4":(t<=2&&(t=33554432+Math.random()*16777216|0),n=t&15,t=t>>4,r[o]=e[o===19?n&3|8:n]);return r.join("")}var D;(function(e){e.PROD="prod",e.VK_ALIAS="vk_alias",e.VIDEOTEST="videotest",e.TEST="test",e.AUTO="auto"})(D||(D={}));var m;(function(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"})(m||(m={}));var E;(function(e){e.MP4="mp4",e.DASH="dash",e.DASH_SEP="dash_sep",e.ONDEMAND_DASH="ondemand_dash",e.HLS="hls",e.ONDEMAND_HLS="ondemand_hls",e.WEBM="webm",e.ONDEMAND_DASH_LIVE="ondemand_dash_live",e.ONDEMAND_HLS_LIVE="ondemand_hls_live",e.WEBRTC="webrtc",e.UNKNOWN="unknown",e.RTMP="rtmp"})(E||(E={}));var Fe;(function(e){e.AUTO="auto",e.MANUAL=""})(Fe||(Fe={}));var he;(function(e){e.HTTP1="http1",e.HTTP2="http2",e.HTTP3="http3"})(he||(he={}));var N;(function(e){e[e.YES=1]="YES",e[e.NO=0]="NO"})(N||(N={}));var re;(function(e){e.EXCELLENT="excellent",e.GOOD="good",e.POOR="poor"})(re||(re={}));var F;(function(e){e.PIP="pip",e.FULLSCREEN="fullscreen",e.EXTERNAL="external",e.PREFETCH="prefetch"})(F||(F={}));var Ve;(function(e){e.SLIDER="slider",e.DOUBLE_TAP="double_tap",e.TIME_CODE="time_code",e.EPISODE="episode",e.REWIND="rewind",e.LIVE="live",e.UNKNOWN="unknown"})(Ve||(Ve={}));const hn="1.0.35-dev.f578f79.0",df="es2015.esm.js",hf="CIOPGQJGDIHBABABA",Co={[D.PROD]:"https://api.ok.ru",[D.VK_ALIAS]:"https://api.mycdn.me",[D.VIDEOTEST]:"https://videotestapi.ok.ru/api",[D.TEST]:"https://apitest.ok.ru",[D.AUTO]:""},pf="_one-stat_",pn=`${pf}uuid`,yf={start:1e3,factor:1.5,max:5*60*1e3,random:.1};var B;(function(e){e[e.PARAM_SESSION_EXPIRED=102]="PARAM_SESSION_EXPIRED",e[e.PARAM_SESSION_KEY=103]="PARAM_SESSION_KEY",e[e.PARAM_SIGNATURE=104]="PARAM_SIGNATURE",e[e.AUTH_LOGIN=401]="AUTH_LOGIN"})(B||(B={}));class $f{constructor(r){this.consequentAuthErrors=0,this.authorized$=new Hr(!1),this.params=r;const t=at.get(pn);t?this.uuid=String(t):(this.uuid=vf(),at.set(pn,this.uuid))}authorize(r){return L(this,void 0,void 0,function*(){return this.authToken=r!=null?r:yield this.refreshAuthToken(),this._authorizeWithBackoff()})}logBeacon(r){const t="log.externalLog",n=this.createLogParams(r),o=this.sessionKey;if(!o)return;this.params.apiTransport.sendBeacon(t,n,o)||this.logRequest(r)}logRequest(r){var t;return L(this,void 0,void 0,function*(){const n="log.externalLog",o=this.createLogParams(r),i=(t=this.sessionKey)!==null&&t!==void 0?t:yield this._authorizeWithBackoff();if(!i)return;const s=(f,l=this.params.requestRetryCount)=>L(this,void 0,void 0,function*(){try{return yield this.params.apiTransport.sendRequest(n,o,i)}catch(c){if(!c||!("error_code"in c)){this.params.error$.next({id:"logRequestUnknown",category:T.NETWORK,message:`Unknown ${n} error`,thrown:c});return}const a=c==null?void 0:c.error_code;switch(a){case B.PARAM_SESSION_EXPIRED:case B.PARAM_SESSION_KEY:case B.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=yield this._authorizeWithBackoff(),l>0?s(f,l-1):void 0;case B.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=yield this.refreshAuthToken(),this.sessionKey=yield this._authorizeWithBackoff(),l>0?s(f,l-1):void 0;default:{this.params.error$.next({id:`LogRequest#${a}`,category:T.EXTERNAL_API,message:`${n} error`,data:c});return}}}});return s(r)})}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}refreshAuthToken(){return L(this,void 0,void 0,function*(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=Or(this.params.refreshAuthToken(),()=>{this.refreshAuthTokenPromise=void 0})),this.refreshAuthTokenPromise})}createLogParams(r){return{collector:"ok.mobile.apps.video",data:JSON.stringify({application:`${df}:${hn}`,platform:this.params.mobile?"M_WEB":"WEB",items:r})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const r=xo(this.consequentAuthErrors,yf);return new Promise(t=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout(()=>{Or(this._authorize().then(t).catch(n=>this.params.error$.next({id:"AuthorizeBackoff",category:T.NETWORK,message:"Otherwise unhandled error in authorization",thrown:n})),()=>this.backoffTimeoutId=0)},r))})}_authorize(){return L(this,void 0,void 0,function*(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const r="auth.anonymLogin",t={session_data:{version:2,device_id:this.uuid,client_version:hn.split("-")[0],client_type:"SDK_JS"}};return this.authToken!==void 0&&(t.session_data.auth_token=this.authToken,t.session_data.version=3),this.authorizePromise=Or(this.params.apiTransport.sendRequest(r,t).then(n=>{var o;return(!n||!n.session_key)&&this.params.error$.next({id:"AuthorizeFailed",category:T.EXTERNAL_API,message:"No session key",data:n}),this.sessionKey=(o=n==null?void 0:n.session_key)!==null&&o!==void 0?o:void 0,this.sessionKey}).catch(n=>L(this,void 0,void 0,function*(){this.sessionKey=void 0;const o=n==null?void 0:n.error_code;switch(o){case B.AUTH_LOGIN:return this.authToken=yield this.refreshAuthToken(),this._authorizeWithBackoff()}o?this.params.error$.next({id:`Authorize#${o}`,category:T.EXTERNAL_API,message:"authorize error",data:n}):this.params.error$.next({id:"AuthorizeUnknown",category:T.NETWORK,message:"authorize error",thrown:n})})),()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise})}}class yn{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(r,t,n){r in this.listeners||(this.listeners[r]=[]),this.listeners[r].push({callback:t,options:n})}removeEventListener(r,t){if(!(r in this.listeners))return;const n=this.listeners[r];for(let o=0,i=n.length;o<i;o++)if(n[o].callback===t){n.splice(o,1);return}}dispatchEvent(r){if(!(r.type in this.listeners))return;const n=this.listeners[r.type].slice();for(let o=0,i=n.length;o<i;o++){const s=n[o];try{s.callback.call(this,r)}catch(f){Promise.resolve().then(()=>{throw f})}s.options&&s.options.once&&this.removeEventListener(r.type,s.callback)}return!r.defaultPrevented}}class No extends yn{constructor(){super(),this.listeners||yn.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(r){r.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,r)),super.dispatchEvent(r)}}class bf{constructor(){Object.defineProperty(this,"signal",{value:new No,writable:!0,configurable:!0})}abort(r){let t;try{t=new Event("abort")}catch(o){typeof document!="undefined"?document.createEvent?(t=document.createEvent("Event"),t.initEvent("abort",!1,!1)):(t=document.createEventObject(),t.type="abort"):t={type:"abort",bubbles:!1,cancelable:!1}}let n=r;if(n===void 0)if(typeof document=="undefined")n=new Error("This operation was aborted"),n.name="AbortError";else try{n=new DOMException("signal is aborted without reason")}catch(o){n=new Error("This operation was aborted"),n.name="AbortError"}this.signal.reason=n,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}}typeof Symbol!="undefined"&&Symbol.toStringTag&&(bf.prototype[Symbol.toStringTag]="AbortController",No.prototype[Symbol.toStringTag]="AbortSignal");function Do(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 gf(e){typeof e=="function"&&(e={fetch:e});const{fetch:r,Request:t=r.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o=!1}=e;if(!Do({fetch:r,Request:t,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:r,Request:i};let i=t;(i&&!i.prototype.hasOwnProperty("signal")||o)&&(i=function(c,a){let u;a&&a.signal&&(u=a.signal,delete a.signal);const v=new t(c,a);return u&&Object.defineProperty(v,"signal",{writable:!1,enumerable:!1,configurable:!0,value:u}),v},i.prototype=t.prototype);const s=r;return{fetch:(l,c)=>{const a=i&&i.prototype.isPrototypeOf(l)?l.signal:c?c.signal:void 0;if(a){let u;try{u=new DOMException("Aborted","AbortError")}catch(d){u=new Error("Aborted"),u.name="AbortError"}if(a.aborted)return Promise.reject(u);const v=new Promise((d,p)=>{a.addEventListener("abort",()=>p(u),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([v,s(l,c)])}return s(l,c)},Request:i}}const ot=Do({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Lo=ot?gf({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,$n=ot?Lo.fetch:window.fetch;ot?Lo.Request:window.Request;class mf{constructor(r){this.params=r,this.apiKey=r.apiKey,this.apiEnv=r.apiEnv,this.apiBaseUrl=r.apiBaseUrl,this.timeSynchronisation=r.timeSynchronisation,this.isApiBaseUrlFetched=!1}resolveApiBaseUrl(){var r;return L(this,void 0,void 0,function*(){if(this.apiEnv!==D.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const t=atob("aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ="),o=yield(yield $n(t,{method:"GET",mode:"cors",cache:"no-cache"})).json(),i=(r=o==null?void 0:o.Answer[0])===null||r===void 0?void 0:r.data;if(!i)throw new Error("Wrong DNS response");return i}catch(t){return this.params.error$.next({id:"OneStat:ApiTransport:resolveApiBaseUrl",category:T.NETWORK,message:"Unhandled resolve api base url error",thrown:t}),Co[D.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}})}sendBeacon(r,t,n){if(!window.Blob||!window.navigator.sendBeacon)return!1;const o=this._prepareQueryParams({method:r,queryParams:t,sessionKey:n}),i=new window.Blob([o.toString()],{type:"application/x-www-form-urlencoded"});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,i)}catch(s){this.params.error$.next({id:"OneStat:ApiTransport:sendBeacon",category:T.NETWORK,message:"Unhandled beacon error",thrown:s,data:{method:r,params:t}})}return!1}sendRequest(r,t,n){return L(this,void 0,void 0,function*(){const o=S(),i=s=>{if(s instanceof TypeError&&["Failed to fetch","NetworkError when attempting to fetch resource."].includes(s.message)){this.params.error$.next({id:"Network",category:T.NETWORK,message:"Request failed",thrown:s});return}this.params.error$.next({id:"OneStat:ApiTransport:sendRequest",category:T.NETWORK,message:"Unhandled request error",thrown:s,data:{method:r,params:t,sessionKey:n,time:S()-o}})};return this.apiBaseUrl=yield this.resolveApiBaseUrl(),$n(`${this.apiBaseUrl}/fb.do`,{method:"post",headers:{"Content-type":"application/x-www-form-urlencoded"},body:this._prepareQueryParams({method:r,queryParams:t,sessionKey:n})}).then(s=>{var f;const l=Number(s.headers.get("content-length"))===0,c=new Date((f=s.headers.get("date"))!==null&&f!==void 0?f:"").getTime(),a=S()-o;if(isFinite(c)&&this.timeSynchronisation.addServerTime(c,a),!l)return s.json().then(u=>Object.prototype.hasOwnProperty.call(u,"error_msg")?Promise.reject(u):u,i)},i)})}_prepareQueryParams(r){const t=new URLSearchParams({format:"JSON",method:r.method,application_key:this.apiKey});return r.sessionKey!==void 0&&t.append("session_key",r.sessionKey),Object.entries(r.queryParams).forEach(([n,o])=>t.append(n,typeof o=="string"?o:JSON.stringify(o))),t}}const jo=3e3,Ef=jo*5;class Sf{constructor(r){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=Ho(()=>{var t;try{this.flush()}catch(n){this.error$.next({id:"LoggerError",category:T.WTF,message:(t=String(n))!==null&&t!==void 0?t:"Unknown logger error",thrown:n})}},jo,{maxWait:Ef}),this.api=r.api,this.error$=r.error$,this.subscription=this.api.authorized$.subscribe(t=>{t&&this.debouncedFlush()})}log(r){console.log(r.operation,r.custom.param,r),this.requestQueue.push(r),this.isPaused||this.debouncedFlush()}flush(r=!1){this.requestQueue.length!==0&&(this.api.authorized$.getValue()?(console.log("Sending",this.requestQueue.length,"events",this.requestQueue),r?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[]):this.api.authorize(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe()}}const Tf=()=>{let e,r;try{e=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?e=!0:(e=!1,console.error(n))}try{window.location.ancestorOrigins&&(r=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!r&&document.referrer&&(r=document.referrer)}catch(n){console.error(n)}const t=r?new URL(r).hostname:void 0;return{isEmbed:e,host:t}},_f=e=>e&&{[O.INVARIANT]:m.UNKNOWN,[O.Q_144P]:m.Q144P,[O.Q_240P]:m.Q240P,[O.Q_360P]:m.Q360P,[O.Q_480P]:m.Q480P,[O.Q_720P]:m.Q720P,[O.Q_1080P]:m.Q1080P,[O.Q_1440P]:m.Q1440P,[O.Q_2160P]:m.Q2160P,[O.Q_4320P]:m.UNKNOWN}[e],bn=e=>e&&{[Ze.HTTP1]:he.HTTP1,[Ze.HTTP2]:he.HTTP2,[Ze.QUIC]:he.HTTP3}[e],Of=e=>{if(e!==void 0)switch(e){case $.MPEG:return E.MP4;case $.DASH:case $.DASH_LIVE:return E.DASH;case $.DASH_SEP:return E.DASH_SEP;case $.DASH_ONDEMAND:return E.ONDEMAND_DASH;case $.DASH_WEBM:case $.DASH_LIVE_WEBM:return E.WEBM;case $.DASH_LIVE_CMAF:return E.ONDEMAND_DASH_LIVE;case $.HLS:case $.HLS_LIVE:return E.HLS;case $.HLS_ONDEMAND:return E.ONDEMAND_HLS;case $.HLS_LIVE_CMAF:return E.ONDEMAND_HLS_LIVE;case $.WEB_RTC_LIVE:return E.WEBRTC;default:return mn(e)}},Pr=e=>{if(e!==void 0)switch(e){case ue.NONE:case ue.INLINE:return;case ue.FULLSCREEN:return F.FULLSCREEN;case ue.SECOND_SCREEN:return F.EXTERNAL;case ue.PIP:return F.PIP;default:return mn(e)}},Pf=e=>{switch(e){case"slow-2g":return re.POOR;case"2g":return re.POOR;case"3g":return re.GOOD;case"4g":return re.EXCELLENT}};class wf{constructor(r){this.offset=void 0,this.offset=r}getOffset(){var r;return(r=this.offset)!==null&&r!==void 0?r:0}setOffset(r){this.offset=r}now(){var r;return Date.now()+((r=this.offset)!==null&&r!==void 0?r:0)}date(r=new Date){var t;return r.setTime(r.getTime()+((t=this.offset)!==null&&t!==void 0?t:0)),r}addServerTime(r,t){const n=Date.now(),o=r-n-t/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)}}const gn=()=>Math.floor(Math.random()*Math.pow(2,32)).toString(36).padStart(8,"0"),If=e=>new Uo(r=>{const t=new fe,n=Ae(wr(window,"beforeunload"),e.events.willDestruct$),o=new Hr(void 0);let i;e.info.isLive$.pipe(Mo()).subscribe(d=>{i&&(i.unsubscribe(),o.next(void 0)),d?i=e.info.liveTime$.pipe(ko(p=>p&&p/1e3)).subscribe(o):i=e.info.position$.subscribe(o),t.add(i)});const{playing$:s,paused$:f}=e.events,l=e.events.willSeek$.pipe(it(()=>e.info.playbackState$.getValue()===ct.PLAYING)),c=e.events.seeked$.pipe(it(()=>e.info.playbackState$.getValue()===ct.PLAYING)),a=Ae(s,c),u=Ae(f,l,n,e.events.looped$);let v;return t.add(a.subscribe(()=>v=o.getValue())),t.add(u.subscribe(()=>{const d=o.getValue();Ir(v)||v===d||Ir(d)||(r.next({from:v,to:d}),v=void 0)})),t});class Nf{constructor(r,t){var n,o;this.subscription=new fe,this.timeSynchronisation=new wf,this.vsid=gn(),this.seekAction$=new Hr(Ve.UNKNOWN),this.statContext=r,this.config=Object.assign(Object.assign({},(n=t.config)!==null&&n!==void 0?n:{}),{requestRetryCount:1});const i=new Bo;this.experimental={error$:i};const s=new mf({apiKey:hf,apiBaseUrl:Co[t.apiEnv],apiEnv:t.apiEnv,error$:i,timeSynchronisation:this.timeSynchronisation});this.api=new $f({apiTransport:s,refreshAuthToken:t.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,mobile:(o=this.statContext.mobile)!==null&&o!==void 0?o:!1,error$:i}),this.logger=new Sf({api:this.api,error$:i});const{isEmbed:f,host:l}=Tf();this.isEmbed=f,this.embedParent=l,this.subscribe()}updateContext(r){this.statContext=Object.assign(Object.assign({},this.statContext),r)}attachTo(r){const t=new fe,n=(a,u)=>t.add(a.subscribe(u));n(r.events.willStart$,()=>{this.logActionPlay({position:r.info.position$.getValue()})}),n(r.events.looped$,()=>{this.resetViewSession(),this.logActionPlay({position:r.info.position$.getValue()})}),n(r.events.seeked$,()=>{this.logSeek({action:this.seekAction$.getValue(),time:r.info.position$.getValue()}),this.seekAction$.next(Ve.UNKNOWN)}),n(r.events.paused$,()=>{this.logPause({position:r.info.position$.getValue()})}),n(r.events.willResume$,()=>{this.logPlay()}),n(r.events.started$,()=>{this.statContext.clip&&(this.logWatchCoverageRecord({start:0,end:0}),this.logger.flush())}),n(If(r),a=>{const u=r.info.isLive$.getValue(),v={start:a.from,end:a.to};u?this.logWatchCoverageLive(v):this.logWatchCoverageRecord(v)});let o;n(r.info.isStalled$,a=>{a?o=S():(ce(o)&&this.logEmptyBuffer({duration:S()-o}),o=void 0)});let i=!1;t.add(r.events.fatalError$.pipe(Fo()).subscribe(()=>i=!0)),n(r.events.willStop$,()=>{if(r.info.isStalled$.getValue()){const u=ce(o)?S()-o:void 0;this.logCloseAtEmptyBuffer({duration:u!=null?u:0}),o=void 0}else i||this.logActionStop();this.logger.flush()}),n(r.events.managedError$,({id:a})=>{this.logError({fatal:!1,errorType:a})}),n(r.events.fatalError$,({id:a})=>{this.logError({fatal:!0,errorType:a})});let s,f,l=!1;n(r.events.firstBytes$,a=>{s=S(),this.logFirstBytes({time:a})}),n(r.events.willStart$,()=>f=S()),n(r.info.currentBuffer$,a=>{!l&&a&&a.end-a.start>0&&ce(s)&&(this.logPlayerReady({duration:S()-s}),l=!0)}),n(r.events.firstFrame$,()=>{ce(s)&&!l&&(this.logPlayerReady({duration:S()-s}),l=!0),ce(f)&&this.logFirstFrame({time:S()-f})}),n(r.info.atLiveEdge$,a=>this.updateContext({liveEdge:a})),n(st({muted:r.info.muted$,volume:r.info.volume$}),({muted:a,volume:u})=>this.updateContext({audible:!a&&u>0})),n(r.info.currentQuality$,a=>this.updateContext({quality:_f(a)})),n(r.info.isAutoQualityEnabled$,a=>this.updateContext({autoQuality:a})),n(r.info.currentFormat$,a=>this.updateContext({contentType:Of(a)}));let c;return n(r.info.hostname$,a=>{this.updateContext({cdnHostname:a,failover:c!==void 0&&c!==a}),c=a}),n(r.info.throughputEstimation$,a=>this.updateContext({downloadSpeed:a})),n(r.info.httpConnectionType$,a=>{this.statContext.firstConnectionType||this.updateContext({firstConnectionType:bn(a)}),this.updateContext({connectionType:bn(a)})}),n(r.info.httpConnectionReused$,a=>{Ir(this.statContext.firstConnectionReused)&&this.updateContext({firstConnectionReused:a}),this.updateContext({connectionReused:a})}),n(r.info.surface$,a=>this.updateContext({mode:Pr(a)})),n(st({current:r.info.currentTextTrack$,available:r.info.availableTextTracks$}),({current:a,available:u})=>{const v=u.find(({id:d})=>d===a);this.updateContext({subtitles:v==null?void 0:v.language})}),this.player=r,this.uiEvents&&this.attachToUi(this.uiEvents),this.subscription.add(t),t}attachToUi(r){this.uiEvents=r;const t=new fe;return this.player&&(t.add(r.actionRewind$.subscribe(()=>{this.player&&(this.resetViewSession(),this.logActionPlay({position:this.player.info.position$.getValue()}))})),t.add(r.actionSeek$.subscribe(this.seekAction$)),t.add(r.inPiP$.subscribe(n=>{var o;const i=n?F.PIP:Pr((o=this.player)===null||o===void 0?void 0:o.info.surface$.getValue());this.updateContext({mode:i})})),t.add(r.inFullscreen$.subscribe(n=>{var o;const i=n?F.FULLSCREEN:Pr((o=this.player)===null||o===void 0?void 0:o.info.surface$.getValue());this.updateContext({mode:i})})),this.subscription.add(t)),t}attachToAds(r){const t=new fe;return t.add(r.slotRequested$.subscribe(()=>this.logAdSlotRequest())).add(r.started$.subscribe(n=>this.logAdStarted(n))).add(r.paused$.subscribe(()=>this.logAdPaused())).add(r.resumed$.subscribe(()=>this.logAdResumed())).add(r.ended$.subscribe(()=>this.logAdEnded())).add(r.skipped$.subscribe(()=>this.logAdSkipped())).add(r.clicked$.subscribe(()=>this.logAdClicked())),this.subscription.add(t),t}authorize(r){return this.api.authorize(r)}pause(){this.logger.pause()}resume(){this.logger.resume()}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}resetViewSession(){this.vsid=gn()}setFieldBlacklist(){}logInited(){}logReady(r){this.log({operation:"player_ready",param:String(r.time)})}logStarted(...r){this.logActionPlay(...r)}logPlay(){this.log({operation:"play_toggle"})}logPause(r){this.log({operation:"pause",param:String(Math.round(r.position))})}logSeek(r){this.log({operation:"seek",param:r.action,time:r.time})}logFirstBytes(r){this.log({operation:"first_bytes",param:String(r.time)})}logFirstFrame(r){this.log({operation:"first_frame",param:String(r.time)})}logError(r){this.log({operation:"content_error",param:`${r.fatal?"fatal":"recoverable"}_${r.errorType}`})}logWatchCoverageRecord(r){this.log({operation:"watch_coverage_record",param:`${r.start}-${r.end}`})}logWatchCoverageLive(r){const t=r.start+this.timeSynchronisation.getOffset(),n=r.end+this.timeSynchronisation.getOffset();this.log({operation:"watch_coverage_live",param:`${t}-${n}`})}logEmptyBuffer(r){this.log({operation:"empty_buffer",param:String(r.duration)})}logDownloadSpeed(){}logAdSlotRequest(){this.log({operation:"adv",param:"slot_request"})}logAdStarted(r){this.log({operation:"adv",param:r})}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"})}subscribe(){this.subscription.add(wr(window,"beforeunload").subscribe(()=>this.logger.flush(!0)));const r=window.navigator.connection;r&&"onchange"in r&&"effectiveType"in r&&this.subscription.add(Ae(wr(r,"change"),Vo(["init"])).subscribe(()=>this.updateContext({network:Pf(r.effectiveType)})))}logPlayerReady(r){this.log({operation:"player_ready",param:String(Math.round(r.duration))})}logActionPlay(r){this.log({operation:"action_play",param:String(Math.round(r.position))})}logCloseAtEmptyBuffer(r){this.log({operation:"close_at_empty_buffer",param:String(Math.round(r.duration))})}logActionStop(){this.log({operation:"action_stop"})}log(r){const t=this.createLogItem(r);this.logger.log(t)}createLogItem({operation:r,param:t,time:n}){const o=this.timeSynchronisation.now(),i=r==="empty_buffer"||r==="close_at_empty_buffer"?this.statContext.connectionType:this.statContext.firstConnectionType,s=this.statContext.firstConnectionReused,f={vsid:this.vsid,vid:this.statContext.movieId,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?Fe.AUTO:this.statContext.autoplay===!1?Fe.MANUAL:void 0,param:t,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode,connection_type:i,connection_reused:s===!0?N.YES:s===!1?N.NO:void 0,cached_data:this.statContext.cached===!0?N.YES:this.statContext.cached===!1?N.NO:void 0,live:this.statContext.liveEdge?N.YES:void 0,muted:this.statContext.audible===!1?N.YES:void 0,mode:this.statContext.mode,subtitles:this.statContext.subtitles,download_speed:this.statContext.downloadSpeed,manual_quality:this.statContext.autoQuality?void 0:N.YES,ref_domain:this.embedParent,aid:this.statContext.albumId,vk_playlist_id:this.statContext.vkPlaylistId};return{operation:r,type:1,time:n,network:this.statContext.network,timestamp:o,custom:f}}}export{D as ApiEnv,he as ConnectionType,E as ContentType,Nf as OneStat,m as Quality,Ve as SeekAction};