@vkontakte/videoplayer-statistics 1.0.17 → 1.0.18

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/OneStat.d.ts CHANGED
@@ -20,6 +20,10 @@ export interface IOneStat {
20
20
  * Снимает паузу отправки событий
21
21
  */
22
22
  resume(): void;
23
+ /**
24
+ * Деструктор класса
25
+ */
26
+ destroy(): void;
23
27
  /**
24
28
  * Первый старт видео. Отправляется 1 раз, когда пользователь начал смотреть ролик (накручивает статистику ролику)
25
29
  *
@@ -144,6 +148,7 @@ export declare class OneStat implements IOneStat {
144
148
  private api;
145
149
  private logger;
146
150
  private config;
151
+ private subscription;
147
152
  experimental: {
148
153
  error$: IObservable<IError>;
149
154
  };
@@ -153,6 +158,7 @@ export declare class OneStat implements IOneStat {
153
158
  authorize(authToken?: string): Promise<unknown>;
154
159
  pause(): void;
155
160
  resume(): void;
161
+ destroy(): void;
156
162
  logStarted(): void;
157
163
  logPlay(): void;
158
164
  logPause(payload: IPausePayload): void;
package/es2015.cjs.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @vkontakte/videoplayer-statistics v1.0.17
3
- * Tue, 28 Jun 2022 15:51:43 GMT
4
- * https://st.mycdn.me/static/playersdk/1-0-17/doc/
2
+ * @vkontakte/videoplayer-statistics v1.0.18
3
+ * Thu, 14 Jul 2022 10:36:11 GMT
4
+ * https://st.mycdn.me/static/playersdk/1-0-18/doc/
5
5
  */
6
- 'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var t=require('@vkontakte/videoplayer-shared/es2015.cjs.js');function e(t){return t&&'object'==typeof t&&'default'in t?t:{default:t}}var r=e(require('lodash/debounce'));function n(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))}var o='undefined'!=typeof globalThis?globalThis:'undefined'!=typeof window?window:'undefined'!=typeof global?global:'undefined'!=typeof self?self:{},i=function(t){return t&&t.Math==Math&&t},s=i('object'==typeof globalThis&&globalThis)||i('object'==typeof window&&window)||i('object'==typeof self&&self)||i('object'==typeof o&&o)||function(){return this}()||Function('return this')(),a=function(t){try{return!!t()}catch(t){return!0}},u=!a((function(){var t=function(){}.bind();return'function'!=typeof t||t.hasOwnProperty('prototype')})),c=u,l=Function.prototype,h=l.apply,p=l.call,f='object'==typeof Reflect&&Reflect.apply||(c?p.bind(h):function(){return p.apply(h,arguments)}),d=u,v=Function.prototype,y=v.bind,m=v.call,g=d&&y.bind(m,m),b=d?function(t){return t&&g(t)}:function(t){return t&&function(){return m.apply(t,arguments)}},w=function(t){return'function'==typeof t},A={},E=!a((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),S=u,_=Function.prototype.call,O=S?_.bind(_):function(){return _.apply(_,arguments)},P={},T={}.propertyIsEnumerable,j=Object.getOwnPropertyDescriptor,x=j&&!T.call({1:2},1);P.f=x?function(t){var e=j(this,t);return!!e&&e.enumerable}:T;var R,k,L=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},C=b,I=C({}.toString),N=C(''.slice),q=function(t){return N(I(t),8,-1)},U=b,F=a,M=q,B=s.Object,z=U(''.split),D=F((function(){return!B('z').propertyIsEnumerable(0)}))?function(t){return'String'==M(t)?z(t,''):B(t)}:B,$=s.TypeError,K=function(t){if(null==t)throw $('Can\'t call method on '+t);return t},Q=D,H=K,G=w,W=function(t){return'object'==typeof t?null!==t:G(t)},Y={},J=Y,V=s,Z=w,X=function(t){return Z(t)?t:void 0},tt=function(t,e){return arguments.length<2?X(J[t])||X(V[t]):J[t]&&J[t][e]||V[t]&&V[t][e]},et=b({}.isPrototypeOf),rt=tt('navigator','userAgent')||'',nt=s,ot=rt,it=nt.process,st=nt.Deno,at=it&&it.versions||st&&st.version,ut=at&&at.v8;ut&&(k=(R=ut.split('.'))[0]>0&&R[0]<4?1:+(R[0]+R[1])),!k&&ot&&(!(R=ot.match(/Edge\/(\d+)/))||R[1]>=74)&&(R=ot.match(/Chrome\/(\d+)/))&&(k=+R[1]);var ct=k,lt=ct,ht=a,pt=!!Object.getOwnPropertySymbols&&!ht((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&lt&&lt<41})),ft=pt&&!Symbol.sham&&'symbol'==typeof Symbol.iterator,dt=tt,vt=w,yt=et,mt=ft,gt=s.Object,bt=mt?function(t){return'symbol'==typeof t}:function(t){var e=dt('Symbol');return vt(e)&&yt(e.prototype,gt(t))},wt=s.String,At=function(t){try{return wt(t)}catch(t){return'Object'}},Et=w,St=At,_t=s.TypeError,Ot=function(t){if(Et(t))return t;throw _t(St(t)+' is not a function')},Pt=Ot,Tt=function(t,e){var r=t[e];return null==r?void 0:Pt(r)},jt=O,xt=w,Rt=W,kt=s.TypeError,Lt={exports:{}},Ct=s,It=Object.defineProperty,Nt=function(t,e){try{It(Ct,t,{value:e,configurable:!0,writable:!0})}catch(r){Ct[t]=e}return e},qt=s['__core-js_shared__']||Nt('__core-js_shared__',{}),Ut=qt;(Lt.exports=function(t,e){return Ut[t]||(Ut[t]=void 0!==e?e:{})})('versions',[]).push({version:'3.21.1',mode:'pure',copyright:'© 2014-2022 Denis Pushkarev (zloirock.ru)',license:'https://github.com/zloirock/core-js/blob/v3.21.1/LICENSE',source:'https://github.com/zloirock/core-js'});var Ft=K,Mt=s.Object,Bt=function(t){return Mt(Ft(t))},zt=b({}.hasOwnProperty),Dt=Object.hasOwn||function(t,e){return zt(Bt(t),e)},$t=b,Kt=0,Qt=Math.random(),Ht=$t(1..toString),Gt=function(t){return'Symbol('+(void 0===t?'':t)+')_'+Ht(++Kt+Qt,36)},Wt=s,Yt=Lt.exports,Jt=Dt,Vt=Gt,Zt=pt,Xt=ft,te=Yt('wks'),ee=Wt.Symbol,re=ee&&ee.for,ne=Xt?ee:ee&&ee.withoutSetter||Vt,oe=function(t){if(!Jt(te,t)||!Zt&&'string'!=typeof te[t]){var e='Symbol.'+t;Zt&&Jt(ee,t)?te[t]=ee[t]:te[t]=Xt&&re?re(e):ne(e)}return te[t]},ie=O,se=W,ae=bt,ue=Tt,ce=function(t,e){var r,n;if('string'===e&&xt(r=t.toString)&&!Rt(n=jt(r,t)))return n;if(xt(r=t.valueOf)&&!Rt(n=jt(r,t)))return n;if('string'!==e&&xt(r=t.toString)&&!Rt(n=jt(r,t)))return n;throw kt('Can\'t convert object to primitive value')},le=oe,he=s.TypeError,pe=le('toPrimitive'),fe=function(t,e){if(!se(t)||ae(t))return t;var r,n=ue(t,pe);if(n){if(void 0===e&&(e='default'),r=ie(n,t,e),!se(r)||ae(r))return r;throw he('Can\'t convert object to primitive value')}return void 0===e&&(e='number'),ce(t,e)},de=bt,ve=function(t){var e=fe(t,'string');return de(e)?e:e+''},ye=W,me=s.document,ge=ye(me)&&ye(me.createElement),be=function(t){return ge?me.createElement(t):{}},we=be,Ae=!E&&!a((function(){return 7!=Object.defineProperty(we('div'),'a',{get:function(){return 7}}).a})),Ee=E,Se=O,_e=P,Oe=L,Pe=function(t){return Q(H(t))},Te=ve,je=Dt,xe=Ae,Re=Object.getOwnPropertyDescriptor;A.f=Ee?Re:function(t,e){if(t=Pe(t),e=Te(e),xe)try{return Re(t,e)}catch(t){}if(je(t,e))return Oe(!Se(_e.f,t,e),t[e])};var ke=a,Le=w,Ce=/#|\.prototype\./,Ie=function(t,e){var r=qe[Ne(t)];return r==Fe||r!=Ue&&(Le(e)?ke(e):!!e)},Ne=Ie.normalize=function(t){return String(t).replace(Ce,'.').toLowerCase()},qe=Ie.data={},Ue=Ie.NATIVE='N',Fe=Ie.POLYFILL='P',Me=Ie,Be=Ot,ze=u,De=b(b.bind),$e=function(t,e){return Be(t),void 0===e?t:ze?De(t,e):function(){return t.apply(e,arguments)}},Ke={},Qe=E&&a((function(){return 42!=Object.defineProperty((function(){}),'prototype',{value:42,writable:!1}).prototype})),He=s,Ge=W,We=He.String,Ye=He.TypeError,Je=function(t){if(Ge(t))return t;throw Ye(We(t)+' is not an object')},Ve=E,Ze=Ae,Xe=Qe,tr=Je,er=ve,rr=s.TypeError,nr=Object.defineProperty,or=Object.getOwnPropertyDescriptor;Ke.f=Ve?Xe?function(t,e,r){if(tr(t),e=er(e),tr(r),'function'==typeof t&&'prototype'===e&&'value'in r&&'writable'in r&&!r.writable){var n=or(t,e);n&&n.writable&&(t[e]=r.value,r={configurable:'configurable'in r?r.configurable:n.configurable,enumerable:'enumerable'in r?r.enumerable:n.enumerable,writable:!1})}return nr(t,e,r)}:nr:function(t,e,r){if(tr(t),e=er(e),tr(r),Ze)try{return nr(t,e,r)}catch(t){}if('get'in r||'set'in r)throw rr('Accessors not supported');return'value'in r&&(t[e]=r.value),t};var ir=Ke,sr=L,ar=E?function(t,e,r){return ir.f(t,e,sr(1,r))}:function(t,e,r){return t[e]=r,t},ur=s,cr=f,lr=b,hr=w,pr=A.f,fr=Me,dr=Y,vr=$e,yr=ar,mr=Dt,gr=function(t){var e=function(r,n,o){if(this instanceof e){switch(arguments.length){case 0:return new t;case 1:return new t(r);case 2:return new t(r,n)}return new t(r,n,o)}return cr(t,this,arguments)};return e.prototype=t.prototype,e},br=function(t,e){var r,n,o,i,s,a,u,c,l=t.target,h=t.global,p=t.stat,f=t.proto,d=h?ur:p?ur[l]:(ur[l]||{}).prototype,v=h?dr:dr[l]||yr(dr,l,{})[l],y=v.prototype;for(o in e)r=!fr(h?o:l+(p?'.':'#')+o,t.forced)&&d&&mr(d,o),s=v[o],r&&(a=t.noTargetGet?(c=pr(d,o))&&c.value:d[o]),i=r&&a?a:e[o],r&&typeof s==typeof i||(u=t.bind&&r?vr(i,ur):t.wrap&&r?gr(i):f&&hr(i)?lr(i):i,(t.sham||i&&i.sham||s&&s.sham)&&yr(u,'sham',!0),yr(v,o,u),f&&(mr(dr,n=l+'Prototype')||yr(dr,n,{}),yr(dr[n],o,i),t.real&&y&&!y[o]&&yr(y,o,i)))},wr=s.Promise,Ar=ar,Er=function(t,e,r,n){n&&n.enumerable?t[e]=r:Ar(t,e,r)},Sr=s,_r=(Sr.String,Sr.TypeError,b);Object.setPrototypeOf||'__proto__'in{}&&function(){var t,e=!1,r={};try{(t=_r(Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').set))(r,[]),e=r instanceof Array}catch(t){}}();var Or={};Or[oe('toStringTag')]='z';var Pr='[object z]'===String(Or),Tr=s,jr=Pr,xr=w,Rr=q,kr=oe('toStringTag'),Lr=Tr.Object,Cr='Arguments'==Rr(function(){return arguments}()),Ir=jr?Rr:function(t){var e,r,n;return void 0===t?'Undefined':null===t?'Null':'string'==typeof(r=function(t,e){try{return t[e]}catch(t){}}(e=Lr(t),kr))?r:Cr?Rr(e):'Object'==(n=Rr(e))&&xr(e.callee)?'Arguments':n},Nr=Ir,qr=Pr?{}.toString:function(){return'[object '+Nr(this)+']'},Ur=Pr,Fr=Ke.f,Mr=ar,Br=Dt,zr=qr,Dr=oe('toStringTag'),$r=tt,Kr=Ke,Qr=E,Hr=oe('species'),Gr=et,Wr=s.TypeError,Yr=w,Jr=qt,Vr=b(Function.toString);Yr(Jr.inspectSource)||(Jr.inspectSource=function(t){return Vr(t)});var Zr=Jr.inspectSource,Xr={},tn=Xr,en=oe('iterator'),rn=Array.prototype,nn=Math.ceil,on=Math.floor,sn=function(t){var e=+t;return e!=e||0===e?0:(e>0?on:nn)(e)},an=Math.min,un=function(t){return t>0?an(sn(t),9007199254740991):0},cn=Ir,ln=Tt,hn=Xr,pn=oe('iterator'),fn=function(t){if(null!=t)return ln(t,pn)||ln(t,'@@iterator')||hn[cn(t)]},dn=O,vn=Ot,yn=Je,mn=At,gn=fn,bn=s.TypeError,wn=O,An=Je,En=Tt,Sn=$e,_n=O,On=Je,Pn=At,Tn=function(t){return void 0!==t&&(tn.Array===t||rn[en]===t)},jn=function(t){return un(t.length)},xn=et,Rn=function(t,e){var r=arguments.length<2?gn(t):e;if(vn(r))return yn(dn(r,t));throw bn(mn(t)+' is not iterable')},kn=fn,Ln=function(t,e,r){var n,o;An(t);try{if(!(n=En(t,'return'))){if('throw'===e)throw r;return r}n=wn(n,t)}catch(t){o=!0,n=t}if('throw'===e)throw r;if(o)throw n;return An(n),r},Cn=s.TypeError,In=function(t,e){this.stopped=t,this.result=e},Nn=In.prototype,qn=oe('iterator'),Un=!1;try{var Fn=0,Mn={next:function(){return{done:!!Fn++}},return:function(){Un=!0}};Mn[qn]=function(){return this},Array.from(Mn,(function(){throw 2}))}catch(t){}var Bn=b,zn=a,Dn=w,$n=Ir,Kn=Zr,Qn=function(){},Hn=[],Gn=tt('Reflect','construct'),Wn=/^\s*(?:class|function)\b/,Yn=Bn(Wn.exec),Jn=!Wn.exec(Qn),Vn=function(t){if(!Dn(t))return!1;try{return Gn(Qn,Hn,t),!0}catch(t){return!1}},Zn=function(t){if(!Dn(t))return!1;switch($n(t)){case'AsyncFunction':case'GeneratorFunction':case'AsyncGeneratorFunction':return!1}try{return Jn||!!Yn(Wn,Kn(t))}catch(t){return!0}};Zn.sham=!0;var Xn,to,eo,ro,no=!Gn||zn((function(){var t;return Vn(Vn.call)||!Vn(Object)||!Vn((function(){t=!0}))||t}))?Zn:Vn,oo=At,io=s.TypeError,so=Je,ao=function(t){if(no(t))return t;throw io(oo(t)+' is not a constructor')},uo=oe('species'),co=function(t,e){var r,n=so(t).constructor;return void 0===n||null==(r=so(n)[uo])?e:ao(r)},lo=tt('document','documentElement'),ho=b([].slice),po=s.TypeError,fo=/(?:ipad|iphone|ipod).*applewebkit/i.test(rt),vo='process'==q(s.process),yo=s,mo=f,go=$e,bo=w,wo=Dt,Ao=a,Eo=lo,So=ho,_o=be,Oo=function(t,e){if(t<e)throw po('Not enough arguments');return t},Po=fo,To=vo,jo=yo.setImmediate,xo=yo.clearImmediate,Ro=yo.process,ko=yo.Dispatch,Lo=yo.Function,Co=yo.MessageChannel,Io=yo.String,No=0,qo={};try{Xn=yo.location}catch(t){}var Uo=function(t){if(wo(qo,t)){var e=qo[t];delete qo[t],e()}},Fo=function(t){return function(){Uo(t)}},Mo=function(t){Uo(t.data)},Bo=function(t){yo.postMessage(Io(t),Xn.protocol+'//'+Xn.host)};jo&&xo||(jo=function(t){Oo(arguments.length,1);var e=bo(t)?t:Lo(t),r=So(arguments,1);return qo[++No]=function(){mo(e,void 0,r)},to(No),No},xo=function(t){delete qo[t]},To?to=function(t){Ro.nextTick(Fo(t))}:ko&&ko.now?to=function(t){ko.now(Fo(t))}:Co&&!Po?(ro=(eo=new Co).port2,eo.port1.onmessage=Mo,to=go(ro.postMessage,ro)):yo.addEventListener&&bo(yo.postMessage)&&!yo.importScripts&&Xn&&'file:'!==Xn.protocol&&!Ao(Bo)?(to=Bo,yo.addEventListener('message',Mo,!1)):to='onreadystatechange'in _o('script')?function(t){Eo.appendChild(_o('script')).onreadystatechange=function(){Eo.removeChild(this),Uo(t)}}:function(t){setTimeout(Fo(t),0)});var zo,Do,$o,Ko,Qo,Ho,Go,Wo,Yo={set:jo,clear:xo},Jo=s,Vo=/ipad|iphone|ipod/i.test(rt)&&void 0!==Jo.Pebble,Zo=/web0s(?!.*chrome)/i.test(rt),Xo=s,ti=$e,ei=A.f,ri=Yo.set,ni=fo,oi=Vo,ii=Zo,si=vo,ai=Xo.MutationObserver||Xo.WebKitMutationObserver,ui=Xo.document,ci=Xo.process,li=Xo.Promise,hi=ei(Xo,'queueMicrotask'),pi=hi&&hi.value;pi||(zo=function(){var t,e;for(si&&(t=ci.domain)&&t.exit();Do;){e=Do.fn,Do=Do.next;try{e()}catch(t){throw Do?Ko():$o=void 0,t}}$o=void 0,t&&t.enter()},ni||si||ii||!ai||!ui?!oi&&li&&li.resolve?((Go=li.resolve(void 0)).constructor=li,Wo=ti(Go.then,Go),Ko=function(){Wo(zo)}):si?Ko=function(){ci.nextTick(zo)}:(ri=ti(ri,Xo),Ko=function(){ri(zo)}):(Qo=!0,Ho=ui.createTextNode(''),new ai(zo).observe(Ho,{characterData:!0}),Ko=function(){Ho.data=Qo=!Qo}));var fi=pi||function(t){var e={fn:t,next:void 0};$o&&($o.next=e),Do||(Do=e,Ko()),$o=e},di={},vi=Ot,yi=function(t){var e,r;this.promise=new t((function(t,n){if(void 0!==e||void 0!==r)throw TypeError('Bad Promise constructor');e=t,r=n})),this.resolve=vi(e),this.reject=vi(r)};di.f=function(t){return new yi(t)};var mi=Je,gi=W,bi=di,wi=function(t,e){if(mi(t),gi(e)&&e.constructor===t)return e;var r=bi.f(t);return(0,r.resolve)(e),r.promise},Ai=s,Ei=function(){this.head=null,this.tail=null};Ei.prototype={add:function(t){var e={item:t,next:null};this.head?this.tail.next=e:this.head=e,this.tail=e},get:function(){var t=this.head;if(t)return this.head=t.next,this.tail===t&&(this.tail=null),t.item}};var Si,_i,Oi,Pi=Ei,Ti=w,ji=Zr,xi=s.WeakMap,Ri=Ti(xi)&&/native code/.test(ji(xi)),ki=Lt.exports,Li=Gt,Ci=ki('keys'),Ii=Ri,Ni=s,qi=b,Ui=W,Fi=ar,Mi=Dt,Bi=qt,zi=function(t){return Ci[t]||(Ci[t]=Li(t))},Di={},$i=Ni.TypeError,Ki=Ni.WeakMap;if(Ii||Bi.state){var Qi=Bi.state||(Bi.state=new Ki),Hi=qi(Qi.get),Gi=qi(Qi.has),Wi=qi(Qi.set);Si=function(t,e){if(Gi(Qi,t))throw new $i('Object already initialized');return e.facade=t,Wi(Qi,t,e),e},_i=function(t){return Hi(Qi,t)||{}},Oi=function(t){return Gi(Qi,t)}}else{var Yi=zi('state');Di[Yi]=!0,Si=function(t,e){if(Mi(t,Yi))throw new $i('Object already initialized');return e.facade=t,Fi(t,Yi,e),e},_i=function(t){return Mi(t,Yi)?t[Yi]:{}},Oi=function(t){return Mi(t,Yi)}}var Ji,Vi,Zi,Xi='object'==typeof window,ts=br,es=s,rs=tt,ns=O,os=wr,is=function(t,e,r){for(var n in e)r&&r.unsafe&&t[n]?t[n]=e[n]:Er(t,n,e[n],r);return t},ss=function(t,e,r,n){if(t){var o=r?t:t.prototype;Br(o,Dr)||Fr(o,Dr,{configurable:!0,value:e}),n&&!Ur&&Mr(o,'toString',zr)}},as=function(t){var e=$r(t),r=Kr.f;Qr&&e&&!e[Hr]&&r(e,Hr,{configurable:!0,get:function(){return this}})},us=Ot,cs=w,ls=W,hs=function(t,e){if(Gr(e,t))return t;throw Wr('Incorrect invocation')},ps=Zr,fs=function(t,e,r){var n,o,i,s,a,u,c,l=r&&r.that,h=!(!r||!r.AS_ENTRIES),p=!(!r||!r.IS_ITERATOR),f=!(!r||!r.INTERRUPTED),d=Sn(e,l),v=function(t){return n&&Ln(n,'normal',t),new In(!0,t)},y=function(t){return h?(On(t),f?d(t[0],t[1],v):d(t[0],t[1])):f?d(t,v):d(t)};if(p)n=t;else{if(!(o=kn(t)))throw Cn(Pn(t)+' is not iterable');if(Tn(o)){for(i=0,s=jn(t);s>i;i++)if((a=y(t[i]))&&xn(Nn,a))return a;return new In(!1)}n=Rn(t,o)}for(u=n.next;!(c=_n(u,n)).done;){try{a=y(c.value)}catch(t){Ln(n,'throw',t)}if('object'==typeof a&&a&&xn(Nn,a))return a}return new In(!1)},ds=function(t,e){if(!e&&!Un)return!1;var r=!1;try{var n={};n[qn]=function(){return{next:function(){return{done:r=!0}}}},t(n)}catch(t){}return r},vs=co,ys=Yo.set,ms=fi,gs=wi,bs=function(t,e){var r=Ai.console;r&&r.error&&(1==arguments.length?r.error(t):r.error(t,e))},ws=di,As=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},Es=Pi,Ss={set:Si,get:_i,has:Oi,enforce:function(t){return Oi(t)?_i(t):Si(t,{})},getterFor:function(t){return function(e){var r;if(!Ui(e)||(r=_i(e)).type!==t)throw $i('Incompatible receiver, '+t+' required');return r}}},_s=Me,Os=Xi,Ps=vo,Ts=ct,js=oe('species'),xs='Promise',Rs=Ss.getterFor(xs),ks=Ss.set,Ls=Ss.getterFor(xs),Cs=os&&os.prototype,Is=os,Ns=Cs,qs=es.TypeError,Us=es.document,Fs=es.process,Ms=ws.f,Bs=Ms,zs=!!(Us&&Us.createEvent&&es.dispatchEvent),Ds=cs(es.PromiseRejectionEvent),$s=_s(xs,(function(){var t=ps(Is),e=t!==String(Is);if(!e&&66===Ts)return!0;if(!Ns.finally)return!0;if(Ts>=51&&/native code/.test(t))return!1;var r=new Is((function(t){t(1)})),n=function(t){t((function(){}),(function(){}))};return(r.constructor={})[js]=n,!(r.then((function(){}))instanceof n)||!e&&Os&&!Ds})),Ks=$s||!ds((function(t){Is.all(t).catch((function(){}))})),Qs=function(t){var e;return!(!ls(t)||!cs(e=t.then))&&e},Hs=function(t,e){var r,n,o,i=e.value,s=1==e.state,a=s?t.ok:t.fail,u=t.resolve,c=t.reject,l=t.domain;try{a?(s||(2===e.rejection&&Vs(e),e.rejection=1),!0===a?r=i:(l&&l.enter(),r=a(i),l&&(l.exit(),o=!0)),r===t.promise?c(qs('Promise-chain cycle')):(n=Qs(r))?ns(n,r,u,c):u(r)):c(i)}catch(t){l&&!o&&l.exit(),c(t)}},Gs=function(t,e){t.notified||(t.notified=!0,ms((function(){for(var r,n=t.reactions;r=n.get();)Hs(r,t);t.notified=!1,e&&!t.rejection&&Ys(t)})))},Ws=function(t,e,r){var n,o;zs?((n=Us.createEvent('Event')).promise=e,n.reason=r,n.initEvent(t,!1,!0),es.dispatchEvent(n)):n={promise:e,reason:r},!Ds&&(o=es['on'+t])?o(n):'unhandledrejection'===t&&bs('Unhandled promise rejection',r)},Ys=function(t){ns(ys,es,(function(){var e,r=t.facade,n=t.value;if(Js(t)&&(e=As((function(){Ps?Fs.emit('unhandledRejection',n,r):Ws('unhandledrejection',r,n)})),t.rejection=Ps||Js(t)?2:1,e.error))throw e.value}))},Js=function(t){return 1!==t.rejection&&!t.parent},Vs=function(t){ns(ys,es,(function(){var e=t.facade;Ps?Fs.emit('rejectionHandled',e):Ws('rejectionhandled',e,t.value)}))},Zs=function(t,e,r){return function(n){t(e,n,r)}},Xs=function(t,e,r){t.done||(t.done=!0,r&&(t=r),t.value=e,t.state=2,Gs(t,!0))},ta=function(t,e,r){if(!t.done){t.done=!0,r&&(t=r);try{if(t.facade===e)throw qs('Promise can\'t be resolved itself');var n=Qs(e);n?ms((function(){var r={done:!1};try{ns(n,e,Zs(ta,r,t),Zs(Xs,r,t))}catch(e){Xs(r,e,t)}})):(t.value=e,t.state=1,Gs(t,!1))}catch(e){Xs({done:!1},e,t)}}};$s&&(Ns=(Is=function(t){hs(this,Ns),us(t),ns(Ji,this);var e=Rs(this);try{t(Zs(ta,e),Zs(Xs,e))}catch(t){Xs(e,t)}}).prototype,(Ji=function(t){ks(this,{type:xs,done:!1,notified:!1,parent:!1,reactions:new Es,rejection:!1,state:0,value:void 0})}).prototype=is(Ns,{then:function(t,e){var r=Ls(this),n=Ms(vs(this,Is));return r.parent=!0,n.ok=!cs(t)||t,n.fail=cs(e)&&e,n.domain=Ps?Fs.domain:void 0,0==r.state?r.reactions.add(n):ms((function(){Hs(n,r)})),n.promise},catch:function(t){return this.then(void 0,t)}}),Vi=function(){var t=new Ji,e=Rs(t);this.promise=t,this.resolve=Zs(ta,e),this.reject=Zs(Xs,e)},ws.f=Ms=function(t){return t===Is||t===Zi?new Vi(t):Bs(t)}),ts({global:!0,wrap:!0,forced:$s},{Promise:Is}),ss(Is,xs,!1,!0),as(xs),Zi=rs(xs),ts({target:xs,stat:!0,forced:$s},{reject:function(t){var e=Ms(this);return ns(e.reject,void 0,t),e.promise}}),ts({target:xs,stat:!0,forced:true},{resolve:function(t){return gs(this===Zi?Is:this,t)}}),ts({target:xs,stat:!0,forced:Ks},{all:function(t){var e=this,r=Ms(e),n=r.resolve,o=r.reject,i=As((function(){var r=us(e.resolve),i=[],s=0,a=1;fs(t,(function(t){var u=s++,c=!1;a++,ns(r,e,t).then((function(t){c||(c=!0,i[u]=t,--a||n(i))}),o)})),--a||n(i)}));return i.error&&o(i.value),r.promise},race:function(t){var e=this,r=Ms(e),n=r.reject,o=As((function(){var o=us(e.resolve);fs(t,(function(t){ns(o,e,t).then(r.resolve,n)}))}));return o.error&&n(o.value),r.promise}});var ea=wr,ra=tt,na=w,oa=co,ia=wi;br({target:'Promise',proto:!0,real:!0,forced:!!ea&&a((function(){ea.prototype.finally.call({then:function(){}},(function(){}))}))},{finally:function(t){var e=oa(this,ra('Promise')),r=na(t);return this.then(r?function(r){return ia(e,t()).then((function(){return r}))}:t,r?function(r){return ia(e,t()).then((function(){throw r}))}:t)}});var sa=tt('Promise','finally');const aa=(()=>{try{const t=Date.now().toString(),e=window.localStorage;e.setItem(t,t);const r=e.getItem(t)===t;return e.removeItem(t),r?e:null}catch(t){return null}})();var ua,ca,la,ha,pa,fa,da,va={get:t=>function(t){const e=aa?aa.getItem('_one-stat_'+t):null;if(null===e)return null;try{return JSON.parse(e)}catch(t){return null}}(t)||null,set(t,e){!function(t,e){try{aa&&aa.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){aa&&aa.removeItem('_one-stat_'+t)}(t)}};exports.ApiEnv=void 0,(ua=exports.ApiEnv||(exports.ApiEnv={})).PROD='prod',ua.VK_ALIAS='vk_alias',ua.VIDEOTEST='videotest',ua.TEST='test',ua.AUTO='auto',exports.Quality=void 0,(ca=exports.Quality||(exports.Quality={})).Q144P='144',ca.Q240P='240',ca.Q360P='360',ca.Q480P='480',ca.Q720P='720',ca.Q1080P='1080',ca.Q1440P='1440',ca.Q2160P='2160',ca.Q4320P='4320',ca.UNKNOWN='unknown',exports.ScreenDestination=void 0,(la=exports.ScreenDestination||(exports.ScreenDestination={})).CHROMECAST='chromecast',la.APPLE_TV='appletv',la.PIP='pip',la.HEADPHONES='externalHeadphones',la.SCREEN='',exports.ContentType=void 0,(ha=exports.ContentType||(exports.ContentType={})).MP4='mp4',ha.DASH='dash',ha.HLS='hls',ha.WEBM='webm',function(t){t.AUTO='auto',t.MANUAL=''}(pa||(pa={})),exports.ConnectionType=void 0,(fa=exports.ConnectionType||(exports.ConnectionType={})).HTTP1='http1',fa.HTTP2='http2',fa.HTTP3='http3',function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(da||(da={}));const ya={[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]:''};var ma;!function(t){t[t.PARAM_SESSION_EXPIRED=102]='PARAM_SESSION_EXPIRED',t[t.PARAM_SESSION_KEY=103]='PARAM_SESSION_KEY',t[t.PARAM_SIGNATURE=104]='PARAM_SIGNATURE',t[t.AUTH_LOGIN=401]='AUTH_LOGIN'}(ma||(ma={}));class ga{constructor(t){this.params=t;const e=va.get('uuid');e?this.uuid=String(e):(this.uuid=function(){const t='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),e=new Array(36);let r,n,o=0;for(n=0;n<36;n++)8===n||13===n||18===n||23===n?e[n]='-':14===n?e[n]='4':(o<=2&&(o=33554432+16777216*Math.random()|0),r=15&o,o>>=4,e[n]=t[19===n?3&r|8:r]);return e.join('')}(),va.set('uuid',this.uuid))}authorize(t){return n(this,void 0,void 0,(function*(){return this.authToken=null!=t?t:yield this.refreshAuthToken(),this._authorize()}))}logBeacon(t){const e=this.createLogParams(t),r=this.sessionKey;void 0!==r&&this.params.apiTransport.sendBeacon('log.externalLog',e,r)||this.logRequest(t)}logRequest(t){var e;return n(this,void 0,void 0,(function*(){const r='log.externalLog',o=this.createLogParams(t),i=null!==(e=this.sessionKey)&&void 0!==e?e:yield this._authorize(),s=(t,e=this.params.requestRetryCount)=>n(this,void 0,void 0,(function*(){try{return yield this.params.apiTransport.sendRequest(r,o,i)}catch(n){if(!n||!('error_code'in n))return void this.params.error$.next({id:'logRequestUnknown',message:`Unknown ${r} error`,thrown:n});const o=null==n?void 0:n.error_code;switch(o){case ma.PARAM_SESSION_EXPIRED:case ma.PARAM_SESSION_KEY:case ma.PARAM_SIGNATURE:return this.sessionKey=yield this._authorize(),e>0?s(t,e-1):void 0;case ma.AUTH_LOGIN:return this.authToken=yield this.refreshAuthToken(),this.sessionKey=yield this._authorize(0),e>0?s(t,e-1):void 0;default:return void this.params.error$.next({id:`LogRequest#${o}`,message:`${r} error`,data:n})}}}));return s(t)}))}refreshAuthToken(){return n(this,void 0,void 0,(function*(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=sa(this.params.refreshAuthToken(),(()=>{this.refreshAuthTokenPromise=void 0}))),this.refreshAuthTokenPromise}))}createLogParams(t){return{collector:'ok.mobile.apps.video',data:JSON.stringify({application:'@vkontakte/videoplayer-statistics:1.0.17',platform:'WEB',items:t.map((t=>Object.assign(Object.assign({},t),{time:0,type:1})))})}}_authorize(t=this.params.requestRetryCount){return n(this,void 0,void 0,(function*(){try{return yield this._authorizeRequest()}catch(e){const r=null==e?void 0:e.error_code;switch(r){case ma.AUTH_LOGIN:if(this.authToken=yield this.refreshAuthToken(),t>0)return this._authorize(t-1)}r?this.params.error$.next({id:`Authorize#${r}`,message:'authorize error',data:e}):this.params.error$.next({id:'AuthorizeUnknown',message:'authorize error',thrown:e})}}))}_authorizeRequest(){return n(this,void 0,void 0,(function*(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0;const t='auth.anonymLogin',e={session_data:{version:2,device_id:this.uuid,client_version:'1.0.17'.split('-')[0],client_type:'SDK_JS'}};return void 0!==this.authToken&&(e.session_data.auth_token=this.authToken,e.session_data.version=3),this.authorizePromise=sa(this.params.apiTransport.sendRequest(t,e).then((r=>{if(r){if(r.session_key)return this.sessionKey=r.session_key,this.sessionKey;this.params.error$.next({id:'AuthorizeNoSessionKey',message:`No session key in ${t} response`,data:r})}else this.params.error$.next({id:'AuthorizeEmptyResponse',message:`Empty response for ${t}`,data:e})})).catch((t=>{throw this.sessionKey=void 0,t})),(()=>{this.authorizePromise=void 0})),this.authorizePromise}))}}class ba{constructor(){Object.defineProperty(this,'listeners',{value:{},writable:!0,configurable:!0})}addEventListener(t,e,r){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push({callback:e,options:r})}removeEventListener(t,e){if(!(t in this.listeners))return;const r=this.listeners[t];for(let t=0,n=r.length;t<n;t++)if(r[t].callback===e)return void r.splice(t,1)}dispatchEvent(t){if(!(t.type in this.listeners))return;const e=this.listeners[t.type].slice();for(let r=0,n=e.length;r<n;r++){const n=e[r];try{n.callback.call(this,t)}catch(t){Promise.resolve().then((()=>{throw t}))}n.options&&n.options.once&&this.removeEventListener(t.type,n.callback)}return!t.defaultPrevented}}class wa extends ba{constructor(){super(),this.listeners||ba.call(this),Object.defineProperty(this,'aborted',{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,'onabort',{value:null,writable:!0,configurable:!0})}toString(){return'[object AbortSignal]'}dispatchEvent(t){'abort'===t.type&&(this.aborted=!0,'function'==typeof this.onabort&&this.onabort.call(this,t)),super.dispatchEvent(t)}}function Aa(t){return t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill'),!0):'function'==typeof t.Request&&!t.Request.prototype.hasOwnProperty('signal')||!t.AbortController}'undefined'!=typeof Symbol&&Symbol.toStringTag&&(class{constructor(){Object.defineProperty(this,'signal',{value:new wa,writable:!0,configurable:!0})}abort(){let t;try{t=new Event('abort')}catch(e){'undefined'!=typeof document?document.createEvent?(t=document.createEvent('Event'),t.initEvent('abort',!1,!1)):(t=document.createEventObject(),t.type='abort'):t={type:'abort',bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(t)}toString(){return'[object AbortController]'}}.prototype[Symbol.toStringTag]='AbortController',wa.prototype[Symbol.toStringTag]='AbortSignal');const Ea=Aa({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Sa=Ea?function(t){'function'==typeof t&&(t={fetch:t});const{fetch:e,Request:r=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o=!1}=t;if(!Aa({fetch:e,Request:r,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:e,Request:i};let i=r;(i&&!i.prototype.hasOwnProperty('signal')||o)&&(i=function(t,e){let n;e&&e.signal&&(n=e.signal,delete e.signal);const o=new r(t,e);return n&&Object.defineProperty(o,'signal',{writable:!1,enumerable:!1,configurable:!0,value:n}),o},i.prototype=r.prototype);const s=e;return{fetch:(t,e)=>{const r=i&&i.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(r){let n;try{n=new DOMException('Aborted','AbortError')}catch(t){n=new Error('Aborted'),n.name='AbortError'}if(r.aborted)return Promise.reject(n);const o=new Promise(((t,e)=>{r.addEventListener('abort',(()=>e(n)),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([o,s(t,e)])}return s(t,e)},Request:i}}({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,_a=Ea?Sa.fetch:window.fetch;Ea?Sa.Request:window.Request;class Oa{constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiEnv=t.apiEnv,this.apiBaseUrl=t.apiBaseUrl,this.isApiBaseUrlFetched=!1}resolveApiBaseUrl(){var t;return n(this,void 0,void 0,(function*(){if(this.apiEnv!==exports.ApiEnv.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const e=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),r=yield _a(e,{method:'GET',mode:'cors',cache:'no-cache'}),n=yield r.json(),o=null===(t=null==n?void 0:n.Answer[0])||void 0===t?void 0:t.data;if(!o)throw new Error('Wrong DNS response');return o}catch(t){return this.params.error$.next({id:'OneStat:ApiTransport:resolveApiBaseUrl',message:'Unhandled resolve api base url error',thrown:t}),ya[exports.ApiEnv.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}))}sendBeacon(t,e,r){if(!window.Blob||!window.navigator.sendBeacon)return!1;const n=this._prepareQueryParams({method:t,queryParams:e,sessionKey:r}),o=new window.Blob([n.toString()],{type:'application/x-www-form-urlencoded'});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,o)}catch(r){this.params.error$.next({id:'OneStat:ApiTransport:sendBeacon',message:'Unhandled beacon error',thrown:r,data:{method:t,params:e}})}return!1}sendRequest(t,e,r){return n(this,void 0,void 0,(function*(){const n=Date.now(),o=o=>{o instanceof TypeError&&['Failed to fetch','NetworkError when attempting to fetch resource.'].includes(o.message)?this.params.error$.next({id:'Network',message:'Request failed',thrown:o}):this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:o,data:{method:t,params:e,sessionKey:r,time:Date.now()-n}})};return this.apiBaseUrl=yield this.resolveApiBaseUrl(),_a(`${this.apiBaseUrl}/fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:t,queryParams:e,sessionKey:r})}).then((t=>Number(t.headers.get('content-length'))>0?t.json().then((t=>Object.prototype.hasOwnProperty.call(t,'error_msg')?Promise.reject(t):t),o):void 0),o)}))}_prepareQueryParams(t){const e=new URLSearchParams({format:'JSON',method:t.method,application_key:this.apiKey});return void 0!==t.sessionKey&&e.append('session_key',t.sessionKey),Object.entries(t.queryParams).forEach((([t,r])=>e.append(t,'string'==typeof r?r:JSON.stringify(r)))),e}}class Pa{constructor(t){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=r.default((()=>{var t;try{this.flush()}catch(e){this.error$.next({id:'LoggerError',message:null!==(t=String(e))&&void 0!==t?t:'Unknown logger error',thrown:e})}}),3e3,{maxWait:15e3}),this.api=t.api,this.error$=t.error$}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[],this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}}exports.OneStat=class{constructor(e,r){var n;this.statContext=e,this.config=Object.assign(Object.assign({},null!==(n=r.config)&&void 0!==n?n:{}),{requestRetryCount:1});const o=new t.Subject;this.experimental={error$:o};const i=new Oa({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:ya[r.apiEnv],apiEnv:r.apiEnv,error$:o});this.api=new ga({apiTransport:i,refreshAuthToken:r.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:o}),this.logger=new Pa({api:this.api,error$:o}),window.addEventListener('beforeunload',(()=>this.logger.flush(!0)))}updateContext(t){this.statContext=Object.assign(Object.assign({},this.statContext),t)}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause()}resume(){this.logger.resume()}logStarted(){this.log({operation:'play'})}logPlay(){this.log({operation:'play_toggle'})}logPause(t){this.log({operation:'pause',param:String(Math.round(t.position))})}logSeek(){this.log({operation:'seek'})}logFirstBytes(t){this.log({operation:'first_bytes',param:String(t.time)})}logFirstFrame(t){this.log({operation:'first_frame',param:String(t.time)})}logError(t){this.log({operation:'error',param:t.errorType})}logWatchCoverageRecord(t){this.log({operation:'watch_coverage_record',param:`${t.start}-${t.end}`}),this.logger.flush(!0)}logWatchCoverageLive(t){this.log({operation:'watch_coverage_live',param:`${t.start}-${t.end}`}),this.logger.flush(!0)}logEmptyBuffer(t){this.log({operation:'empty_buffer',param:String(t.duration)})}logAdSlotRequest(){this.log({operation:'adv',param:'slot_request'})}logAdStarted(t){this.log({operation:'adv',param:t})}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(t){const e=this.crateLogItem(t);this.logger.log(e)}crateLogItem({operation:t,param:e}){const r=Date.now(),n={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:!0===this.statContext.connectionReused?da.YES:!1===this.statContext.connectionReused?da.NO:void 0,stat_type:!0===this.statContext.autoplay?pa.AUTO:!1===this.statContext.autoplay?pa.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId};return void 0!==e&&(n.param=e),{operation:t,timestamp:r,custom:n}}};
6
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var t=require('@vkontakte/videoplayer-shared/es2015.cjs.js');function e(t){return t&&'object'==typeof t&&'default'in t?t:{default:t}}var r=e(require('lodash/debounce'));function n(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))}var o='undefined'!=typeof globalThis?globalThis:'undefined'!=typeof window?window:'undefined'!=typeof global?global:'undefined'!=typeof self?self:{},i=function(t){return t&&t.Math==Math&&t},s=i('object'==typeof globalThis&&globalThis)||i('object'==typeof window&&window)||i('object'==typeof self&&self)||i('object'==typeof o&&o)||function(){return this}()||Function('return this')(),a=function(t){try{return!!t()}catch(t){return!0}},u=!a((function(){var t=function(){}.bind();return'function'!=typeof t||t.hasOwnProperty('prototype')})),c=u,l=Function.prototype,h=l.apply,p=l.call,f='object'==typeof Reflect&&Reflect.apply||(c?p.bind(h):function(){return p.apply(h,arguments)}),d=u,v=Function.prototype,y=v.bind,m=v.call,g=d&&y.bind(m,m),b=d?function(t){return t&&g(t)}:function(t){return t&&function(){return m.apply(t,arguments)}},w=function(t){return'function'==typeof t},A={},E=!a((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),S=u,_=Function.prototype.call,O=S?_.bind(_):function(){return _.apply(_,arguments)},P={},T={}.propertyIsEnumerable,j=Object.getOwnPropertyDescriptor,x=j&&!T.call({1:2},1);P.f=x?function(t){var e=j(this,t);return!!e&&e.enumerable}:T;var R,k,L=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},C=b,I=C({}.toString),N=C(''.slice),q=function(t){return N(I(t),8,-1)},U=b,F=a,M=q,B=s.Object,z=U(''.split),D=F((function(){return!B('z').propertyIsEnumerable(0)}))?function(t){return'String'==M(t)?z(t,''):B(t)}:B,$=s.TypeError,K=function(t){if(null==t)throw $('Can\'t call method on '+t);return t},Q=D,H=K,G=w,W=function(t){return'object'==typeof t?null!==t:G(t)},Y={},J=Y,V=s,Z=w,X=function(t){return Z(t)?t:void 0},tt=function(t,e){return arguments.length<2?X(J[t])||X(V[t]):J[t]&&J[t][e]||V[t]&&V[t][e]},et=b({}.isPrototypeOf),rt=tt('navigator','userAgent')||'',nt=s,ot=rt,it=nt.process,st=nt.Deno,at=it&&it.versions||st&&st.version,ut=at&&at.v8;ut&&(k=(R=ut.split('.'))[0]>0&&R[0]<4?1:+(R[0]+R[1])),!k&&ot&&(!(R=ot.match(/Edge\/(\d+)/))||R[1]>=74)&&(R=ot.match(/Chrome\/(\d+)/))&&(k=+R[1]);var ct=k,lt=ct,ht=a,pt=!!Object.getOwnPropertySymbols&&!ht((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&lt&&lt<41})),ft=pt&&!Symbol.sham&&'symbol'==typeof Symbol.iterator,dt=tt,vt=w,yt=et,mt=ft,gt=s.Object,bt=mt?function(t){return'symbol'==typeof t}:function(t){var e=dt('Symbol');return vt(e)&&yt(e.prototype,gt(t))},wt=s.String,At=function(t){try{return wt(t)}catch(t){return'Object'}},Et=w,St=At,_t=s.TypeError,Ot=function(t){if(Et(t))return t;throw _t(St(t)+' is not a function')},Pt=Ot,Tt=function(t,e){var r=t[e];return null==r?void 0:Pt(r)},jt=O,xt=w,Rt=W,kt=s.TypeError,Lt={exports:{}},Ct=s,It=Object.defineProperty,Nt=function(t,e){try{It(Ct,t,{value:e,configurable:!0,writable:!0})}catch(r){Ct[t]=e}return e},qt=s['__core-js_shared__']||Nt('__core-js_shared__',{}),Ut=qt;(Lt.exports=function(t,e){return Ut[t]||(Ut[t]=void 0!==e?e:{})})('versions',[]).push({version:'3.21.1',mode:'pure',copyright:'© 2014-2022 Denis Pushkarev (zloirock.ru)',license:'https://github.com/zloirock/core-js/blob/v3.21.1/LICENSE',source:'https://github.com/zloirock/core-js'});var Ft=K,Mt=s.Object,Bt=function(t){return Mt(Ft(t))},zt=b({}.hasOwnProperty),Dt=Object.hasOwn||function(t,e){return zt(Bt(t),e)},$t=b,Kt=0,Qt=Math.random(),Ht=$t(1..toString),Gt=function(t){return'Symbol('+(void 0===t?'':t)+')_'+Ht(++Kt+Qt,36)},Wt=s,Yt=Lt.exports,Jt=Dt,Vt=Gt,Zt=pt,Xt=ft,te=Yt('wks'),ee=Wt.Symbol,re=ee&&ee.for,ne=Xt?ee:ee&&ee.withoutSetter||Vt,oe=function(t){if(!Jt(te,t)||!Zt&&'string'!=typeof te[t]){var e='Symbol.'+t;Zt&&Jt(ee,t)?te[t]=ee[t]:te[t]=Xt&&re?re(e):ne(e)}return te[t]},ie=O,se=W,ae=bt,ue=Tt,ce=function(t,e){var r,n;if('string'===e&&xt(r=t.toString)&&!Rt(n=jt(r,t)))return n;if(xt(r=t.valueOf)&&!Rt(n=jt(r,t)))return n;if('string'!==e&&xt(r=t.toString)&&!Rt(n=jt(r,t)))return n;throw kt('Can\'t convert object to primitive value')},le=oe,he=s.TypeError,pe=le('toPrimitive'),fe=function(t,e){if(!se(t)||ae(t))return t;var r,n=ue(t,pe);if(n){if(void 0===e&&(e='default'),r=ie(n,t,e),!se(r)||ae(r))return r;throw he('Can\'t convert object to primitive value')}return void 0===e&&(e='number'),ce(t,e)},de=bt,ve=function(t){var e=fe(t,'string');return de(e)?e:e+''},ye=W,me=s.document,ge=ye(me)&&ye(me.createElement),be=function(t){return ge?me.createElement(t):{}},we=be,Ae=!E&&!a((function(){return 7!=Object.defineProperty(we('div'),'a',{get:function(){return 7}}).a})),Ee=E,Se=O,_e=P,Oe=L,Pe=function(t){return Q(H(t))},Te=ve,je=Dt,xe=Ae,Re=Object.getOwnPropertyDescriptor;A.f=Ee?Re:function(t,e){if(t=Pe(t),e=Te(e),xe)try{return Re(t,e)}catch(t){}if(je(t,e))return Oe(!Se(_e.f,t,e),t[e])};var ke=a,Le=w,Ce=/#|\.prototype\./,Ie=function(t,e){var r=qe[Ne(t)];return r==Fe||r!=Ue&&(Le(e)?ke(e):!!e)},Ne=Ie.normalize=function(t){return String(t).replace(Ce,'.').toLowerCase()},qe=Ie.data={},Ue=Ie.NATIVE='N',Fe=Ie.POLYFILL='P',Me=Ie,Be=Ot,ze=u,De=b(b.bind),$e=function(t,e){return Be(t),void 0===e?t:ze?De(t,e):function(){return t.apply(e,arguments)}},Ke={},Qe=E&&a((function(){return 42!=Object.defineProperty((function(){}),'prototype',{value:42,writable:!1}).prototype})),He=s,Ge=W,We=He.String,Ye=He.TypeError,Je=function(t){if(Ge(t))return t;throw Ye(We(t)+' is not an object')},Ve=E,Ze=Ae,Xe=Qe,tr=Je,er=ve,rr=s.TypeError,nr=Object.defineProperty,or=Object.getOwnPropertyDescriptor;Ke.f=Ve?Xe?function(t,e,r){if(tr(t),e=er(e),tr(r),'function'==typeof t&&'prototype'===e&&'value'in r&&'writable'in r&&!r.writable){var n=or(t,e);n&&n.writable&&(t[e]=r.value,r={configurable:'configurable'in r?r.configurable:n.configurable,enumerable:'enumerable'in r?r.enumerable:n.enumerable,writable:!1})}return nr(t,e,r)}:nr:function(t,e,r){if(tr(t),e=er(e),tr(r),Ze)try{return nr(t,e,r)}catch(t){}if('get'in r||'set'in r)throw rr('Accessors not supported');return'value'in r&&(t[e]=r.value),t};var ir=Ke,sr=L,ar=E?function(t,e,r){return ir.f(t,e,sr(1,r))}:function(t,e,r){return t[e]=r,t},ur=s,cr=f,lr=b,hr=w,pr=A.f,fr=Me,dr=Y,vr=$e,yr=ar,mr=Dt,gr=function(t){var e=function(r,n,o){if(this instanceof e){switch(arguments.length){case 0:return new t;case 1:return new t(r);case 2:return new t(r,n)}return new t(r,n,o)}return cr(t,this,arguments)};return e.prototype=t.prototype,e},br=function(t,e){var r,n,o,i,s,a,u,c,l=t.target,h=t.global,p=t.stat,f=t.proto,d=h?ur:p?ur[l]:(ur[l]||{}).prototype,v=h?dr:dr[l]||yr(dr,l,{})[l],y=v.prototype;for(o in e)r=!fr(h?o:l+(p?'.':'#')+o,t.forced)&&d&&mr(d,o),s=v[o],r&&(a=t.noTargetGet?(c=pr(d,o))&&c.value:d[o]),i=r&&a?a:e[o],r&&typeof s==typeof i||(u=t.bind&&r?vr(i,ur):t.wrap&&r?gr(i):f&&hr(i)?lr(i):i,(t.sham||i&&i.sham||s&&s.sham)&&yr(u,'sham',!0),yr(v,o,u),f&&(mr(dr,n=l+'Prototype')||yr(dr,n,{}),yr(dr[n],o,i),t.real&&y&&!y[o]&&yr(y,o,i)))},wr=s.Promise,Ar=ar,Er=function(t,e,r,n){n&&n.enumerable?t[e]=r:Ar(t,e,r)},Sr=s,_r=(Sr.String,Sr.TypeError,b);Object.setPrototypeOf||'__proto__'in{}&&function(){var t,e=!1,r={};try{(t=_r(Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').set))(r,[]),e=r instanceof Array}catch(t){}}();var Or={};Or[oe('toStringTag')]='z';var Pr='[object z]'===String(Or),Tr=s,jr=Pr,xr=w,Rr=q,kr=oe('toStringTag'),Lr=Tr.Object,Cr='Arguments'==Rr(function(){return arguments}()),Ir=jr?Rr:function(t){var e,r,n;return void 0===t?'Undefined':null===t?'Null':'string'==typeof(r=function(t,e){try{return t[e]}catch(t){}}(e=Lr(t),kr))?r:Cr?Rr(e):'Object'==(n=Rr(e))&&xr(e.callee)?'Arguments':n},Nr=Ir,qr=Pr?{}.toString:function(){return'[object '+Nr(this)+']'},Ur=Pr,Fr=Ke.f,Mr=ar,Br=Dt,zr=qr,Dr=oe('toStringTag'),$r=tt,Kr=Ke,Qr=E,Hr=oe('species'),Gr=et,Wr=s.TypeError,Yr=w,Jr=qt,Vr=b(Function.toString);Yr(Jr.inspectSource)||(Jr.inspectSource=function(t){return Vr(t)});var Zr=Jr.inspectSource,Xr={},tn=Xr,en=oe('iterator'),rn=Array.prototype,nn=Math.ceil,on=Math.floor,sn=function(t){var e=+t;return e!=e||0===e?0:(e>0?on:nn)(e)},an=Math.min,un=function(t){return t>0?an(sn(t),9007199254740991):0},cn=Ir,ln=Tt,hn=Xr,pn=oe('iterator'),fn=function(t){if(null!=t)return ln(t,pn)||ln(t,'@@iterator')||hn[cn(t)]},dn=O,vn=Ot,yn=Je,mn=At,gn=fn,bn=s.TypeError,wn=O,An=Je,En=Tt,Sn=$e,_n=O,On=Je,Pn=At,Tn=function(t){return void 0!==t&&(tn.Array===t||rn[en]===t)},jn=function(t){return un(t.length)},xn=et,Rn=function(t,e){var r=arguments.length<2?gn(t):e;if(vn(r))return yn(dn(r,t));throw bn(mn(t)+' is not iterable')},kn=fn,Ln=function(t,e,r){var n,o;An(t);try{if(!(n=En(t,'return'))){if('throw'===e)throw r;return r}n=wn(n,t)}catch(t){o=!0,n=t}if('throw'===e)throw r;if(o)throw n;return An(n),r},Cn=s.TypeError,In=function(t,e){this.stopped=t,this.result=e},Nn=In.prototype,qn=oe('iterator'),Un=!1;try{var Fn=0,Mn={next:function(){return{done:!!Fn++}},return:function(){Un=!0}};Mn[qn]=function(){return this},Array.from(Mn,(function(){throw 2}))}catch(t){}var Bn=b,zn=a,Dn=w,$n=Ir,Kn=Zr,Qn=function(){},Hn=[],Gn=tt('Reflect','construct'),Wn=/^\s*(?:class|function)\b/,Yn=Bn(Wn.exec),Jn=!Wn.exec(Qn),Vn=function(t){if(!Dn(t))return!1;try{return Gn(Qn,Hn,t),!0}catch(t){return!1}},Zn=function(t){if(!Dn(t))return!1;switch($n(t)){case'AsyncFunction':case'GeneratorFunction':case'AsyncGeneratorFunction':return!1}try{return Jn||!!Yn(Wn,Kn(t))}catch(t){return!0}};Zn.sham=!0;var Xn,to,eo,ro,no=!Gn||zn((function(){var t;return Vn(Vn.call)||!Vn(Object)||!Vn((function(){t=!0}))||t}))?Zn:Vn,oo=At,io=s.TypeError,so=Je,ao=function(t){if(no(t))return t;throw io(oo(t)+' is not a constructor')},uo=oe('species'),co=function(t,e){var r,n=so(t).constructor;return void 0===n||null==(r=so(n)[uo])?e:ao(r)},lo=tt('document','documentElement'),ho=b([].slice),po=s.TypeError,fo=/(?:ipad|iphone|ipod).*applewebkit/i.test(rt),vo='process'==q(s.process),yo=s,mo=f,go=$e,bo=w,wo=Dt,Ao=a,Eo=lo,So=ho,_o=be,Oo=function(t,e){if(t<e)throw po('Not enough arguments');return t},Po=fo,To=vo,jo=yo.setImmediate,xo=yo.clearImmediate,Ro=yo.process,ko=yo.Dispatch,Lo=yo.Function,Co=yo.MessageChannel,Io=yo.String,No=0,qo={};try{Xn=yo.location}catch(t){}var Uo=function(t){if(wo(qo,t)){var e=qo[t];delete qo[t],e()}},Fo=function(t){return function(){Uo(t)}},Mo=function(t){Uo(t.data)},Bo=function(t){yo.postMessage(Io(t),Xn.protocol+'//'+Xn.host)};jo&&xo||(jo=function(t){Oo(arguments.length,1);var e=bo(t)?t:Lo(t),r=So(arguments,1);return qo[++No]=function(){mo(e,void 0,r)},to(No),No},xo=function(t){delete qo[t]},To?to=function(t){Ro.nextTick(Fo(t))}:ko&&ko.now?to=function(t){ko.now(Fo(t))}:Co&&!Po?(ro=(eo=new Co).port2,eo.port1.onmessage=Mo,to=go(ro.postMessage,ro)):yo.addEventListener&&bo(yo.postMessage)&&!yo.importScripts&&Xn&&'file:'!==Xn.protocol&&!Ao(Bo)?(to=Bo,yo.addEventListener('message',Mo,!1)):to='onreadystatechange'in _o('script')?function(t){Eo.appendChild(_o('script')).onreadystatechange=function(){Eo.removeChild(this),Uo(t)}}:function(t){setTimeout(Fo(t),0)});var zo,Do,$o,Ko,Qo,Ho,Go,Wo,Yo={set:jo,clear:xo},Jo=s,Vo=/ipad|iphone|ipod/i.test(rt)&&void 0!==Jo.Pebble,Zo=/web0s(?!.*chrome)/i.test(rt),Xo=s,ti=$e,ei=A.f,ri=Yo.set,ni=fo,oi=Vo,ii=Zo,si=vo,ai=Xo.MutationObserver||Xo.WebKitMutationObserver,ui=Xo.document,ci=Xo.process,li=Xo.Promise,hi=ei(Xo,'queueMicrotask'),pi=hi&&hi.value;pi||(zo=function(){var t,e;for(si&&(t=ci.domain)&&t.exit();Do;){e=Do.fn,Do=Do.next;try{e()}catch(t){throw Do?Ko():$o=void 0,t}}$o=void 0,t&&t.enter()},ni||si||ii||!ai||!ui?!oi&&li&&li.resolve?((Go=li.resolve(void 0)).constructor=li,Wo=ti(Go.then,Go),Ko=function(){Wo(zo)}):si?Ko=function(){ci.nextTick(zo)}:(ri=ti(ri,Xo),Ko=function(){ri(zo)}):(Qo=!0,Ho=ui.createTextNode(''),new ai(zo).observe(Ho,{characterData:!0}),Ko=function(){Ho.data=Qo=!Qo}));var fi=pi||function(t){var e={fn:t,next:void 0};$o&&($o.next=e),Do||(Do=e,Ko()),$o=e},di={},vi=Ot,yi=function(t){var e,r;this.promise=new t((function(t,n){if(void 0!==e||void 0!==r)throw TypeError('Bad Promise constructor');e=t,r=n})),this.resolve=vi(e),this.reject=vi(r)};di.f=function(t){return new yi(t)};var mi=Je,gi=W,bi=di,wi=function(t,e){if(mi(t),gi(e)&&e.constructor===t)return e;var r=bi.f(t);return(0,r.resolve)(e),r.promise},Ai=s,Ei=function(){this.head=null,this.tail=null};Ei.prototype={add:function(t){var e={item:t,next:null};this.head?this.tail.next=e:this.head=e,this.tail=e},get:function(){var t=this.head;if(t)return this.head=t.next,this.tail===t&&(this.tail=null),t.item}};var Si,_i,Oi,Pi=Ei,Ti=w,ji=Zr,xi=s.WeakMap,Ri=Ti(xi)&&/native code/.test(ji(xi)),ki=Lt.exports,Li=Gt,Ci=ki('keys'),Ii=Ri,Ni=s,qi=b,Ui=W,Fi=ar,Mi=Dt,Bi=qt,zi=function(t){return Ci[t]||(Ci[t]=Li(t))},Di={},$i=Ni.TypeError,Ki=Ni.WeakMap;if(Ii||Bi.state){var Qi=Bi.state||(Bi.state=new Ki),Hi=qi(Qi.get),Gi=qi(Qi.has),Wi=qi(Qi.set);Si=function(t,e){if(Gi(Qi,t))throw new $i('Object already initialized');return e.facade=t,Wi(Qi,t,e),e},_i=function(t){return Hi(Qi,t)||{}},Oi=function(t){return Gi(Qi,t)}}else{var Yi=zi('state');Di[Yi]=!0,Si=function(t,e){if(Mi(t,Yi))throw new $i('Object already initialized');return e.facade=t,Fi(t,Yi,e),e},_i=function(t){return Mi(t,Yi)?t[Yi]:{}},Oi=function(t){return Mi(t,Yi)}}var Ji,Vi,Zi,Xi='object'==typeof window,ts=br,es=s,rs=tt,ns=O,os=wr,is=function(t,e,r){for(var n in e)r&&r.unsafe&&t[n]?t[n]=e[n]:Er(t,n,e[n],r);return t},ss=function(t,e,r,n){if(t){var o=r?t:t.prototype;Br(o,Dr)||Fr(o,Dr,{configurable:!0,value:e}),n&&!Ur&&Mr(o,'toString',zr)}},as=function(t){var e=$r(t),r=Kr.f;Qr&&e&&!e[Hr]&&r(e,Hr,{configurable:!0,get:function(){return this}})},us=Ot,cs=w,ls=W,hs=function(t,e){if(Gr(e,t))return t;throw Wr('Incorrect invocation')},ps=Zr,fs=function(t,e,r){var n,o,i,s,a,u,c,l=r&&r.that,h=!(!r||!r.AS_ENTRIES),p=!(!r||!r.IS_ITERATOR),f=!(!r||!r.INTERRUPTED),d=Sn(e,l),v=function(t){return n&&Ln(n,'normal',t),new In(!0,t)},y=function(t){return h?(On(t),f?d(t[0],t[1],v):d(t[0],t[1])):f?d(t,v):d(t)};if(p)n=t;else{if(!(o=kn(t)))throw Cn(Pn(t)+' is not iterable');if(Tn(o)){for(i=0,s=jn(t);s>i;i++)if((a=y(t[i]))&&xn(Nn,a))return a;return new In(!1)}n=Rn(t,o)}for(u=n.next;!(c=_n(u,n)).done;){try{a=y(c.value)}catch(t){Ln(n,'throw',t)}if('object'==typeof a&&a&&xn(Nn,a))return a}return new In(!1)},ds=function(t,e){if(!e&&!Un)return!1;var r=!1;try{var n={};n[qn]=function(){return{next:function(){return{done:r=!0}}}},t(n)}catch(t){}return r},vs=co,ys=Yo.set,ms=fi,gs=wi,bs=function(t,e){var r=Ai.console;r&&r.error&&(1==arguments.length?r.error(t):r.error(t,e))},ws=di,As=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},Es=Pi,Ss={set:Si,get:_i,has:Oi,enforce:function(t){return Oi(t)?_i(t):Si(t,{})},getterFor:function(t){return function(e){var r;if(!Ui(e)||(r=_i(e)).type!==t)throw $i('Incompatible receiver, '+t+' required');return r}}},_s=Me,Os=Xi,Ps=vo,Ts=ct,js=oe('species'),xs='Promise',Rs=Ss.getterFor(xs),ks=Ss.set,Ls=Ss.getterFor(xs),Cs=os&&os.prototype,Is=os,Ns=Cs,qs=es.TypeError,Us=es.document,Fs=es.process,Ms=ws.f,Bs=Ms,zs=!!(Us&&Us.createEvent&&es.dispatchEvent),Ds=cs(es.PromiseRejectionEvent),$s=_s(xs,(function(){var t=ps(Is),e=t!==String(Is);if(!e&&66===Ts)return!0;if(!Ns.finally)return!0;if(Ts>=51&&/native code/.test(t))return!1;var r=new Is((function(t){t(1)})),n=function(t){t((function(){}),(function(){}))};return(r.constructor={})[js]=n,!(r.then((function(){}))instanceof n)||!e&&Os&&!Ds})),Ks=$s||!ds((function(t){Is.all(t).catch((function(){}))})),Qs=function(t){var e;return!(!ls(t)||!cs(e=t.then))&&e},Hs=function(t,e){var r,n,o,i=e.value,s=1==e.state,a=s?t.ok:t.fail,u=t.resolve,c=t.reject,l=t.domain;try{a?(s||(2===e.rejection&&Vs(e),e.rejection=1),!0===a?r=i:(l&&l.enter(),r=a(i),l&&(l.exit(),o=!0)),r===t.promise?c(qs('Promise-chain cycle')):(n=Qs(r))?ns(n,r,u,c):u(r)):c(i)}catch(t){l&&!o&&l.exit(),c(t)}},Gs=function(t,e){t.notified||(t.notified=!0,ms((function(){for(var r,n=t.reactions;r=n.get();)Hs(r,t);t.notified=!1,e&&!t.rejection&&Ys(t)})))},Ws=function(t,e,r){var n,o;zs?((n=Us.createEvent('Event')).promise=e,n.reason=r,n.initEvent(t,!1,!0),es.dispatchEvent(n)):n={promise:e,reason:r},!Ds&&(o=es['on'+t])?o(n):'unhandledrejection'===t&&bs('Unhandled promise rejection',r)},Ys=function(t){ns(ys,es,(function(){var e,r=t.facade,n=t.value;if(Js(t)&&(e=As((function(){Ps?Fs.emit('unhandledRejection',n,r):Ws('unhandledrejection',r,n)})),t.rejection=Ps||Js(t)?2:1,e.error))throw e.value}))},Js=function(t){return 1!==t.rejection&&!t.parent},Vs=function(t){ns(ys,es,(function(){var e=t.facade;Ps?Fs.emit('rejectionHandled',e):Ws('rejectionhandled',e,t.value)}))},Zs=function(t,e,r){return function(n){t(e,n,r)}},Xs=function(t,e,r){t.done||(t.done=!0,r&&(t=r),t.value=e,t.state=2,Gs(t,!0))},ta=function(t,e,r){if(!t.done){t.done=!0,r&&(t=r);try{if(t.facade===e)throw qs('Promise can\'t be resolved itself');var n=Qs(e);n?ms((function(){var r={done:!1};try{ns(n,e,Zs(ta,r,t),Zs(Xs,r,t))}catch(e){Xs(r,e,t)}})):(t.value=e,t.state=1,Gs(t,!1))}catch(e){Xs({done:!1},e,t)}}};$s&&(Ns=(Is=function(t){hs(this,Ns),us(t),ns(Ji,this);var e=Rs(this);try{t(Zs(ta,e),Zs(Xs,e))}catch(t){Xs(e,t)}}).prototype,(Ji=function(t){ks(this,{type:xs,done:!1,notified:!1,parent:!1,reactions:new Es,rejection:!1,state:0,value:void 0})}).prototype=is(Ns,{then:function(t,e){var r=Ls(this),n=Ms(vs(this,Is));return r.parent=!0,n.ok=!cs(t)||t,n.fail=cs(e)&&e,n.domain=Ps?Fs.domain:void 0,0==r.state?r.reactions.add(n):ms((function(){Hs(n,r)})),n.promise},catch:function(t){return this.then(void 0,t)}}),Vi=function(){var t=new Ji,e=Rs(t);this.promise=t,this.resolve=Zs(ta,e),this.reject=Zs(Xs,e)},ws.f=Ms=function(t){return t===Is||t===Zi?new Vi(t):Bs(t)}),ts({global:!0,wrap:!0,forced:$s},{Promise:Is}),ss(Is,xs,!1,!0),as(xs),Zi=rs(xs),ts({target:xs,stat:!0,forced:$s},{reject:function(t){var e=Ms(this);return ns(e.reject,void 0,t),e.promise}}),ts({target:xs,stat:!0,forced:true},{resolve:function(t){return gs(this===Zi?Is:this,t)}}),ts({target:xs,stat:!0,forced:Ks},{all:function(t){var e=this,r=Ms(e),n=r.resolve,o=r.reject,i=As((function(){var r=us(e.resolve),i=[],s=0,a=1;fs(t,(function(t){var u=s++,c=!1;a++,ns(r,e,t).then((function(t){c||(c=!0,i[u]=t,--a||n(i))}),o)})),--a||n(i)}));return i.error&&o(i.value),r.promise},race:function(t){var e=this,r=Ms(e),n=r.reject,o=As((function(){var o=us(e.resolve);fs(t,(function(t){ns(o,e,t).then(r.resolve,n)}))}));return o.error&&n(o.value),r.promise}});var ea=wr,ra=tt,na=w,oa=co,ia=wi;br({target:'Promise',proto:!0,real:!0,forced:!!ea&&a((function(){ea.prototype.finally.call({then:function(){}},(function(){}))}))},{finally:function(t){var e=oa(this,ra('Promise')),r=na(t);return this.then(r?function(r){return ia(e,t()).then((function(){return r}))}:t,r?function(r){return ia(e,t()).then((function(){throw r}))}:t)}});var sa=tt('Promise','finally');const aa=(()=>{try{const t=Date.now().toString(),e=window.localStorage;e.setItem(t,t);const r=e.getItem(t)===t;return e.removeItem(t),r?e:null}catch(t){return null}})();var ua,ca,la,ha,pa,fa,da,va={get:t=>function(t){const e=aa?aa.getItem('_one-stat_'+t):null;if(null===e)return null;try{return JSON.parse(e)}catch(t){return null}}(t)||null,set(t,e){!function(t,e){try{aa&&aa.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){aa&&aa.removeItem('_one-stat_'+t)}(t)}};exports.ApiEnv=void 0,(ua=exports.ApiEnv||(exports.ApiEnv={})).PROD='prod',ua.VK_ALIAS='vk_alias',ua.VIDEOTEST='videotest',ua.TEST='test',ua.AUTO='auto',exports.Quality=void 0,(ca=exports.Quality||(exports.Quality={})).Q144P='144',ca.Q240P='240',ca.Q360P='360',ca.Q480P='480',ca.Q720P='720',ca.Q1080P='1080',ca.Q1440P='1440',ca.Q2160P='2160',ca.Q4320P='4320',ca.UNKNOWN='unknown',exports.ScreenDestination=void 0,(la=exports.ScreenDestination||(exports.ScreenDestination={})).CHROMECAST='chromecast',la.APPLE_TV='appletv',la.PIP='pip',la.HEADPHONES='externalHeadphones',la.SCREEN='',exports.ContentType=void 0,(ha=exports.ContentType||(exports.ContentType={})).MP4='mp4',ha.DASH='dash',ha.HLS='hls',ha.WEBM='webm',function(t){t.AUTO='auto',t.MANUAL=''}(pa||(pa={})),exports.ConnectionType=void 0,(fa=exports.ConnectionType||(exports.ConnectionType={})).HTTP1='http1',fa.HTTP2='http2',fa.HTTP3='http3',function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(da||(da={}));const ya={[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]:''};var ma;!function(t){t[t.PARAM_SESSION_EXPIRED=102]='PARAM_SESSION_EXPIRED',t[t.PARAM_SESSION_KEY=103]='PARAM_SESSION_KEY',t[t.PARAM_SIGNATURE=104]='PARAM_SIGNATURE',t[t.AUTH_LOGIN=401]='AUTH_LOGIN'}(ma||(ma={}));class ga{constructor(t){this.params=t;const e=va.get('uuid');e?this.uuid=String(e):(this.uuid=function(){const t='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),e=new Array(36);let r,n,o=0;for(n=0;n<36;n++)8===n||13===n||18===n||23===n?e[n]='-':14===n?e[n]='4':(o<=2&&(o=33554432+16777216*Math.random()|0),r=15&o,o>>=4,e[n]=t[19===n?3&r|8:r]);return e.join('')}(),va.set('uuid',this.uuid))}authorize(t){return n(this,void 0,void 0,(function*(){return this.authToken=null!=t?t:yield this.refreshAuthToken(),this._authorize()}))}logBeacon(t){const e=this.createLogParams(t),r=this.sessionKey;if(!r)return;this.params.apiTransport.sendBeacon('log.externalLog',e,r)||this.logRequest(t)}logRequest(t){var e;return n(this,void 0,void 0,(function*(){const r='log.externalLog',o=this.createLogParams(t),i=null!==(e=this.sessionKey)&&void 0!==e?e:yield this._authorize();if(!i)return;const s=(t,e=this.params.requestRetryCount)=>n(this,void 0,void 0,(function*(){try{return yield this.params.apiTransport.sendRequest(r,o,i)}catch(n){if(!n||!('error_code'in n))return void this.params.error$.next({id:'logRequestUnknown',message:`Unknown ${r} error`,thrown:n});const o=null==n?void 0:n.error_code;switch(o){case ma.PARAM_SESSION_EXPIRED:case ma.PARAM_SESSION_KEY:case ma.PARAM_SIGNATURE:return this.sessionKey=yield this._authorize(),e>0?s(t,e-1):void 0;case ma.AUTH_LOGIN:return this.authToken=yield this.refreshAuthToken(),this.sessionKey=yield this._authorize(0),e>0?s(t,e-1):void 0;default:return void this.params.error$.next({id:`LogRequest#${o}`,message:`${r} error`,data:n})}}}));return s(t)}))}refreshAuthToken(){return n(this,void 0,void 0,(function*(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=sa(this.params.refreshAuthToken(),(()=>{this.refreshAuthTokenPromise=void 0}))),this.refreshAuthTokenPromise}))}createLogParams(t){return{collector:'ok.mobile.apps.video',data:JSON.stringify({application:'@vkontakte/videoplayer-statistics:1.0.18',platform:'WEB',items:t.map((t=>Object.assign(Object.assign({},t),{time:0,type:1})))})}}_authorize(t=this.params.requestRetryCount){return n(this,void 0,void 0,(function*(){try{return yield this._authorizeRequest()}catch(e){const r=null==e?void 0:e.error_code;switch(r){case ma.AUTH_LOGIN:if(this.authToken=yield this.refreshAuthToken(),t>0)return this._authorize(t-1)}r?this.params.error$.next({id:`Authorize#${r}`,message:'authorize error',data:e}):this.params.error$.next({id:'AuthorizeUnknown',message:'authorize error',thrown:e})}}))}_authorizeRequest(){return n(this,void 0,void 0,(function*(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0;const t='auth.anonymLogin',e={session_data:{version:2,device_id:this.uuid,client_version:'1.0.18'.split('-')[0],client_type:'SDK_JS'}};return void 0!==this.authToken&&(e.session_data.auth_token=this.authToken,e.session_data.version=3),this.authorizePromise=sa(this.params.apiTransport.sendRequest(t,e).then((r=>{if(r){if(r.session_key)return this.sessionKey=r.session_key,this.sessionKey;this.params.error$.next({id:'AuthorizeNoSessionKey',message:`No session key in ${t} response`,data:r})}else this.params.error$.next({id:'AuthorizeEmptyResponse',message:`Empty response for ${t}`,data:e})})).catch((t=>{throw this.sessionKey=void 0,t})),(()=>{this.authorizePromise=void 0})),this.authorizePromise}))}}class ba{constructor(){Object.defineProperty(this,'listeners',{value:{},writable:!0,configurable:!0})}addEventListener(t,e,r){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push({callback:e,options:r})}removeEventListener(t,e){if(!(t in this.listeners))return;const r=this.listeners[t];for(let t=0,n=r.length;t<n;t++)if(r[t].callback===e)return void r.splice(t,1)}dispatchEvent(t){if(!(t.type in this.listeners))return;const e=this.listeners[t.type].slice();for(let r=0,n=e.length;r<n;r++){const n=e[r];try{n.callback.call(this,t)}catch(t){Promise.resolve().then((()=>{throw t}))}n.options&&n.options.once&&this.removeEventListener(t.type,n.callback)}return!t.defaultPrevented}}class wa extends ba{constructor(){super(),this.listeners||ba.call(this),Object.defineProperty(this,'aborted',{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,'onabort',{value:null,writable:!0,configurable:!0})}toString(){return'[object AbortSignal]'}dispatchEvent(t){'abort'===t.type&&(this.aborted=!0,'function'==typeof this.onabort&&this.onabort.call(this,t)),super.dispatchEvent(t)}}function Aa(t){return t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill'),!0):'function'==typeof t.Request&&!t.Request.prototype.hasOwnProperty('signal')||!t.AbortController}'undefined'!=typeof Symbol&&Symbol.toStringTag&&(class{constructor(){Object.defineProperty(this,'signal',{value:new wa,writable:!0,configurable:!0})}abort(){let t;try{t=new Event('abort')}catch(e){'undefined'!=typeof document?document.createEvent?(t=document.createEvent('Event'),t.initEvent('abort',!1,!1)):(t=document.createEventObject(),t.type='abort'):t={type:'abort',bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(t)}toString(){return'[object AbortController]'}}.prototype[Symbol.toStringTag]='AbortController',wa.prototype[Symbol.toStringTag]='AbortSignal');const Ea=Aa({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Sa=Ea?function(t){'function'==typeof t&&(t={fetch:t});const{fetch:e,Request:r=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o=!1}=t;if(!Aa({fetch:e,Request:r,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:e,Request:i};let i=r;(i&&!i.prototype.hasOwnProperty('signal')||o)&&(i=function(t,e){let n;e&&e.signal&&(n=e.signal,delete e.signal);const o=new r(t,e);return n&&Object.defineProperty(o,'signal',{writable:!1,enumerable:!1,configurable:!0,value:n}),o},i.prototype=r.prototype);const s=e;return{fetch:(t,e)=>{const r=i&&i.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(r){let n;try{n=new DOMException('Aborted','AbortError')}catch(t){n=new Error('Aborted'),n.name='AbortError'}if(r.aborted)return Promise.reject(n);const o=new Promise(((t,e)=>{r.addEventListener('abort',(()=>e(n)),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([o,s(t,e)])}return s(t,e)},Request:i}}({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,_a=Ea?Sa.fetch:window.fetch;Ea?Sa.Request:window.Request;class Oa{constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiEnv=t.apiEnv,this.apiBaseUrl=t.apiBaseUrl,this.isApiBaseUrlFetched=!1}resolveApiBaseUrl(){var t;return n(this,void 0,void 0,(function*(){if(this.apiEnv!==exports.ApiEnv.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const e=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),r=yield _a(e,{method:'GET',mode:'cors',cache:'no-cache'}),n=yield r.json(),o=null===(t=null==n?void 0:n.Answer[0])||void 0===t?void 0:t.data;if(!o)throw new Error('Wrong DNS response');return o}catch(t){return this.params.error$.next({id:'OneStat:ApiTransport:resolveApiBaseUrl',message:'Unhandled resolve api base url error',thrown:t}),ya[exports.ApiEnv.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}))}sendBeacon(t,e,r){if(!window.Blob||!window.navigator.sendBeacon)return!1;const n=this._prepareQueryParams({method:t,queryParams:e,sessionKey:r}),o=new window.Blob([n.toString()],{type:'application/x-www-form-urlencoded'});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,o)}catch(r){this.params.error$.next({id:'OneStat:ApiTransport:sendBeacon',message:'Unhandled beacon error',thrown:r,data:{method:t,params:e}})}return!1}sendRequest(t,e,r){return n(this,void 0,void 0,(function*(){const n=Date.now(),o=o=>{o instanceof TypeError&&['Failed to fetch','NetworkError when attempting to fetch resource.'].includes(o.message)?this.params.error$.next({id:'Network',message:'Request failed',thrown:o}):this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:o,data:{method:t,params:e,sessionKey:r,time:Date.now()-n}})};return this.apiBaseUrl=yield this.resolveApiBaseUrl(),_a(`${this.apiBaseUrl}/fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:t,queryParams:e,sessionKey:r})}).then((t=>Number(t.headers.get('content-length'))>0?t.json().then((t=>Object.prototype.hasOwnProperty.call(t,'error_msg')?Promise.reject(t):t),o):void 0),o)}))}_prepareQueryParams(t){const e=new URLSearchParams({format:'JSON',method:t.method,application_key:this.apiKey});return void 0!==t.sessionKey&&e.append('session_key',t.sessionKey),Object.entries(t.queryParams).forEach((([t,r])=>e.append(t,'string'==typeof r?r:JSON.stringify(r)))),e}}class Pa{constructor(t){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=r.default((()=>{var t;try{this.flush()}catch(e){this.error$.next({id:'LoggerError',message:null!==(t=String(e))&&void 0!==t?t:'Unknown logger error',thrown:e})}}),3e3,{maxWait:15e3}),this.api=t.api,this.error$=t.error$}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[],this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}}exports.OneStat=class{constructor(e,r){var n;this.subscription=new t.Subscription,this.statContext=e,this.config=Object.assign(Object.assign({},null!==(n=r.config)&&void 0!==n?n:{}),{requestRetryCount:1});const o=new t.Subject;this.experimental={error$:o};const i=new Oa({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:ya[r.apiEnv],apiEnv:r.apiEnv,error$:o});this.api=new ga({apiTransport:i,refreshAuthToken:r.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:o}),this.logger=new Pa({api:this.api,error$:o}),this.subscription.add(t.fromEvent(window,'beforeunload').subscribe((()=>this.logger.flush(!0))))}updateContext(t){this.statContext=Object.assign(Object.assign({},this.statContext),t)}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause()}resume(){this.logger.resume()}destroy(){this.logger.flush(),this.subscription.unsubscribe()}logStarted(){this.log({operation:'play'})}logPlay(){this.log({operation:'play_toggle'})}logPause(t){this.log({operation:'pause',param:String(Math.round(t.position))})}logSeek(){this.log({operation:'seek'})}logFirstBytes(t){this.log({operation:'first_bytes',param:String(t.time)})}logFirstFrame(t){this.log({operation:'first_frame',param:String(t.time)})}logError(t){this.log({operation:'error',param:t.errorType})}logWatchCoverageRecord(t){this.log({operation:'watch_coverage_record',param:`${t.start}-${t.end}`}),this.logger.flush(!0)}logWatchCoverageLive(t){this.log({operation:'watch_coverage_live',param:`${t.start}-${t.end}`}),this.logger.flush(!0)}logEmptyBuffer(t){this.log({operation:'empty_buffer',param:String(t.duration)})}logAdSlotRequest(){this.log({operation:'adv',param:'slot_request'})}logAdStarted(t){this.log({operation:'adv',param:t})}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(t){const e=this.crateLogItem(t);this.logger.log(e)}crateLogItem({operation:t,param:e}){const r=Date.now(),n={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:!0===this.statContext.connectionReused?da.YES:!1===this.statContext.connectionReused?da.NO:void 0,stat_type:!0===this.statContext.autoplay?pa.AUTO:!1===this.statContext.autoplay?pa.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId};return void 0!==e&&(n.param=e),{operation:t,timestamp:r,custom:n}}};
package/es2015.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @vkontakte/videoplayer-statistics v1.0.17
3
- * Tue, 28 Jun 2022 15:51:43 GMT
4
- * https://st.mycdn.me/static/playersdk/1-0-17/doc/
2
+ * @vkontakte/videoplayer-statistics v1.0.18
3
+ * Thu, 14 Jul 2022 10:36:11 GMT
4
+ * https://st.mycdn.me/static/playersdk/1-0-18/doc/
5
5
  */
6
- import{Subject as t}from'@vkontakte/videoplayer-shared/es2015.esm.js';import e from'lodash/debounce';function r(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))}var n='undefined'!=typeof globalThis?globalThis:'undefined'!=typeof window?window:'undefined'!=typeof global?global:'undefined'!=typeof self?self:{},o=function(t){return t&&t.Math==Math&&t},i=o('object'==typeof globalThis&&globalThis)||o('object'==typeof window&&window)||o('object'==typeof self&&self)||o('object'==typeof n&&n)||function(){return this}()||Function('return this')(),s=function(t){try{return!!t()}catch(t){return!0}},a=!s((function(){var t=function(){}.bind();return'function'!=typeof t||t.hasOwnProperty('prototype')})),u=a,c=Function.prototype,l=c.apply,h=c.call,f='object'==typeof Reflect&&Reflect.apply||(u?h.bind(l):function(){return h.apply(l,arguments)}),p=a,d=Function.prototype,v=d.bind,y=d.call,m=p&&v.bind(y,y),g=p?function(t){return t&&m(t)}:function(t){return t&&function(){return y.apply(t,arguments)}},b=function(t){return'function'==typeof t},w={},A=!s((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),E=a,S=Function.prototype.call,_=E?S.bind(S):function(){return S.apply(S,arguments)},P={},O={}.propertyIsEnumerable,T=Object.getOwnPropertyDescriptor,R=T&&!O.call({1:2},1);P.f=R?function(t){var e=T(this,t);return!!e&&e.enumerable}:O;var j,k,L=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},x=g,C=x({}.toString),I=x(''.slice),N=function(t){return I(C(t),8,-1)},q=g,U=s,F=N,B=i.Object,M=q(''.split),z=U((function(){return!B('z').propertyIsEnumerable(0)}))?function(t){return'String'==F(t)?M(t,''):B(t)}:B,$=i.TypeError,K=function(t){if(null==t)throw $('Can\'t call method on '+t);return t},D=z,Q=K,H=b,G=function(t){return'object'==typeof t?null!==t:H(t)},W={},Y=W,J=i,V=b,Z=function(t){return V(t)?t:void 0},X=function(t,e){return arguments.length<2?Z(Y[t])||Z(J[t]):Y[t]&&Y[t][e]||J[t]&&J[t][e]},tt=g({}.isPrototypeOf),et=X('navigator','userAgent')||'',rt=i,nt=et,ot=rt.process,it=rt.Deno,st=ot&&ot.versions||it&&it.version,at=st&&st.v8;at&&(k=(j=at.split('.'))[0]>0&&j[0]<4?1:+(j[0]+j[1])),!k&&nt&&(!(j=nt.match(/Edge\/(\d+)/))||j[1]>=74)&&(j=nt.match(/Chrome\/(\d+)/))&&(k=+j[1]);var ut=k,ct=ut,lt=s,ht=!!Object.getOwnPropertySymbols&&!lt((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&ct&&ct<41})),ft=ht&&!Symbol.sham&&'symbol'==typeof Symbol.iterator,pt=X,dt=b,vt=tt,yt=ft,mt=i.Object,gt=yt?function(t){return'symbol'==typeof t}:function(t){var e=pt('Symbol');return dt(e)&&vt(e.prototype,mt(t))},bt=i.String,wt=function(t){try{return bt(t)}catch(t){return'Object'}},At=b,Et=wt,St=i.TypeError,_t=function(t){if(At(t))return t;throw St(Et(t)+' is not a function')},Pt=_t,Ot=function(t,e){var r=t[e];return null==r?void 0:Pt(r)},Tt=_,Rt=b,jt=G,kt=i.TypeError,Lt={exports:{}},xt=i,Ct=Object.defineProperty,It=function(t,e){try{Ct(xt,t,{value:e,configurable:!0,writable:!0})}catch(r){xt[t]=e}return e},Nt=i['__core-js_shared__']||It('__core-js_shared__',{}),qt=Nt;(Lt.exports=function(t,e){return qt[t]||(qt[t]=void 0!==e?e:{})})('versions',[]).push({version:'3.21.1',mode:'pure',copyright:'© 2014-2022 Denis Pushkarev (zloirock.ru)',license:'https://github.com/zloirock/core-js/blob/v3.21.1/LICENSE',source:'https://github.com/zloirock/core-js'});var Ut=K,Ft=i.Object,Bt=function(t){return Ft(Ut(t))},Mt=g({}.hasOwnProperty),zt=Object.hasOwn||function(t,e){return Mt(Bt(t),e)},$t=g,Kt=0,Dt=Math.random(),Qt=$t(1..toString),Ht=function(t){return'Symbol('+(void 0===t?'':t)+')_'+Qt(++Kt+Dt,36)},Gt=i,Wt=Lt.exports,Yt=zt,Jt=Ht,Vt=ht,Zt=ft,Xt=Wt('wks'),te=Gt.Symbol,ee=te&&te.for,re=Zt?te:te&&te.withoutSetter||Jt,ne=function(t){if(!Yt(Xt,t)||!Vt&&'string'!=typeof Xt[t]){var e='Symbol.'+t;Vt&&Yt(te,t)?Xt[t]=te[t]:Xt[t]=Zt&&ee?ee(e):re(e)}return Xt[t]},oe=_,ie=G,se=gt,ae=Ot,ue=function(t,e){var r,n;if('string'===e&&Rt(r=t.toString)&&!jt(n=Tt(r,t)))return n;if(Rt(r=t.valueOf)&&!jt(n=Tt(r,t)))return n;if('string'!==e&&Rt(r=t.toString)&&!jt(n=Tt(r,t)))return n;throw kt('Can\'t convert object to primitive value')},ce=ne,le=i.TypeError,he=ce('toPrimitive'),fe=function(t,e){if(!ie(t)||se(t))return t;var r,n=ae(t,he);if(n){if(void 0===e&&(e='default'),r=oe(n,t,e),!ie(r)||se(r))return r;throw le('Can\'t convert object to primitive value')}return void 0===e&&(e='number'),ue(t,e)},pe=gt,de=function(t){var e=fe(t,'string');return pe(e)?e:e+''},ve=G,ye=i.document,me=ve(ye)&&ve(ye.createElement),ge=function(t){return me?ye.createElement(t):{}},be=ge,we=!A&&!s((function(){return 7!=Object.defineProperty(be('div'),'a',{get:function(){return 7}}).a})),Ae=A,Ee=_,Se=P,_e=L,Pe=function(t){return D(Q(t))},Oe=de,Te=zt,Re=we,je=Object.getOwnPropertyDescriptor;w.f=Ae?je:function(t,e){if(t=Pe(t),e=Oe(e),Re)try{return je(t,e)}catch(t){}if(Te(t,e))return _e(!Ee(Se.f,t,e),t[e])};var ke=s,Le=b,xe=/#|\.prototype\./,Ce=function(t,e){var r=Ne[Ie(t)];return r==Ue||r!=qe&&(Le(e)?ke(e):!!e)},Ie=Ce.normalize=function(t){return String(t).replace(xe,'.').toLowerCase()},Ne=Ce.data={},qe=Ce.NATIVE='N',Ue=Ce.POLYFILL='P',Fe=Ce,Be=_t,Me=a,ze=g(g.bind),$e=function(t,e){return Be(t),void 0===e?t:Me?ze(t,e):function(){return t.apply(e,arguments)}},Ke={},De=A&&s((function(){return 42!=Object.defineProperty((function(){}),'prototype',{value:42,writable:!1}).prototype})),Qe=i,He=G,Ge=Qe.String,We=Qe.TypeError,Ye=function(t){if(He(t))return t;throw We(Ge(t)+' is not an object')},Je=A,Ve=we,Ze=De,Xe=Ye,tr=de,er=i.TypeError,rr=Object.defineProperty,nr=Object.getOwnPropertyDescriptor;Ke.f=Je?Ze?function(t,e,r){if(Xe(t),e=tr(e),Xe(r),'function'==typeof t&&'prototype'===e&&'value'in r&&'writable'in r&&!r.writable){var n=nr(t,e);n&&n.writable&&(t[e]=r.value,r={configurable:'configurable'in r?r.configurable:n.configurable,enumerable:'enumerable'in r?r.enumerable:n.enumerable,writable:!1})}return rr(t,e,r)}:rr:function(t,e,r){if(Xe(t),e=tr(e),Xe(r),Ve)try{return rr(t,e,r)}catch(t){}if('get'in r||'set'in r)throw er('Accessors not supported');return'value'in r&&(t[e]=r.value),t};var or=Ke,ir=L,sr=A?function(t,e,r){return or.f(t,e,ir(1,r))}:function(t,e,r){return t[e]=r,t},ar=i,ur=f,cr=g,lr=b,hr=w.f,fr=Fe,pr=W,dr=$e,vr=sr,yr=zt,mr=function(t){var e=function(r,n,o){if(this instanceof e){switch(arguments.length){case 0:return new t;case 1:return new t(r);case 2:return new t(r,n)}return new t(r,n,o)}return ur(t,this,arguments)};return e.prototype=t.prototype,e},gr=function(t,e){var r,n,o,i,s,a,u,c,l=t.target,h=t.global,f=t.stat,p=t.proto,d=h?ar:f?ar[l]:(ar[l]||{}).prototype,v=h?pr:pr[l]||vr(pr,l,{})[l],y=v.prototype;for(o in e)r=!fr(h?o:l+(f?'.':'#')+o,t.forced)&&d&&yr(d,o),s=v[o],r&&(a=t.noTargetGet?(c=hr(d,o))&&c.value:d[o]),i=r&&a?a:e[o],r&&typeof s==typeof i||(u=t.bind&&r?dr(i,ar):t.wrap&&r?mr(i):p&&lr(i)?cr(i):i,(t.sham||i&&i.sham||s&&s.sham)&&vr(u,'sham',!0),vr(v,o,u),p&&(yr(pr,n=l+'Prototype')||vr(pr,n,{}),vr(pr[n],o,i),t.real&&y&&!y[o]&&vr(y,o,i)))},br=i.Promise,wr=sr,Ar=function(t,e,r,n){n&&n.enumerable?t[e]=r:wr(t,e,r)},Er=i,Sr=(Er.String,Er.TypeError,g);Object.setPrototypeOf||'__proto__'in{}&&function(){var t,e=!1,r={};try{(t=Sr(Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').set))(r,[]),e=r instanceof Array}catch(t){}}();var _r={};_r[ne('toStringTag')]='z';var Pr='[object z]'===String(_r),Or=i,Tr=Pr,Rr=b,jr=N,kr=ne('toStringTag'),Lr=Or.Object,xr='Arguments'==jr(function(){return arguments}()),Cr=Tr?jr:function(t){var e,r,n;return void 0===t?'Undefined':null===t?'Null':'string'==typeof(r=function(t,e){try{return t[e]}catch(t){}}(e=Lr(t),kr))?r:xr?jr(e):'Object'==(n=jr(e))&&Rr(e.callee)?'Arguments':n},Ir=Cr,Nr=Pr?{}.toString:function(){return'[object '+Ir(this)+']'},qr=Pr,Ur=Ke.f,Fr=sr,Br=zt,Mr=Nr,zr=ne('toStringTag'),$r=X,Kr=Ke,Dr=A,Qr=ne('species'),Hr=tt,Gr=i.TypeError,Wr=b,Yr=Nt,Jr=g(Function.toString);Wr(Yr.inspectSource)||(Yr.inspectSource=function(t){return Jr(t)});var Vr=Yr.inspectSource,Zr={},Xr=Zr,tn=ne('iterator'),en=Array.prototype,rn=Math.ceil,nn=Math.floor,on=function(t){var e=+t;return e!=e||0===e?0:(e>0?nn:rn)(e)},sn=Math.min,an=function(t){return t>0?sn(on(t),9007199254740991):0},un=Cr,cn=Ot,ln=Zr,hn=ne('iterator'),fn=function(t){if(null!=t)return cn(t,hn)||cn(t,'@@iterator')||ln[un(t)]},pn=_,dn=_t,vn=Ye,yn=wt,mn=fn,gn=i.TypeError,bn=_,wn=Ye,An=Ot,En=$e,Sn=_,_n=Ye,Pn=wt,On=function(t){return void 0!==t&&(Xr.Array===t||en[tn]===t)},Tn=function(t){return an(t.length)},Rn=tt,jn=function(t,e){var r=arguments.length<2?mn(t):e;if(dn(r))return vn(pn(r,t));throw gn(yn(t)+' is not iterable')},kn=fn,Ln=function(t,e,r){var n,o;wn(t);try{if(!(n=An(t,'return'))){if('throw'===e)throw r;return r}n=bn(n,t)}catch(t){o=!0,n=t}if('throw'===e)throw r;if(o)throw n;return wn(n),r},xn=i.TypeError,Cn=function(t,e){this.stopped=t,this.result=e},In=Cn.prototype,Nn=ne('iterator'),qn=!1;try{var Un=0,Fn={next:function(){return{done:!!Un++}},return:function(){qn=!0}};Fn[Nn]=function(){return this},Array.from(Fn,(function(){throw 2}))}catch(t){}var Bn=g,Mn=s,zn=b,$n=Cr,Kn=Vr,Dn=function(){},Qn=[],Hn=X('Reflect','construct'),Gn=/^\s*(?:class|function)\b/,Wn=Bn(Gn.exec),Yn=!Gn.exec(Dn),Jn=function(t){if(!zn(t))return!1;try{return Hn(Dn,Qn,t),!0}catch(t){return!1}},Vn=function(t){if(!zn(t))return!1;switch($n(t)){case'AsyncFunction':case'GeneratorFunction':case'AsyncGeneratorFunction':return!1}try{return Yn||!!Wn(Gn,Kn(t))}catch(t){return!0}};Vn.sham=!0;var Zn,Xn,to,eo,ro=!Hn||Mn((function(){var t;return Jn(Jn.call)||!Jn(Object)||!Jn((function(){t=!0}))||t}))?Vn:Jn,no=wt,oo=i.TypeError,io=Ye,so=function(t){if(ro(t))return t;throw oo(no(t)+' is not a constructor')},ao=ne('species'),uo=function(t,e){var r,n=io(t).constructor;return void 0===n||null==(r=io(n)[ao])?e:so(r)},co=X('document','documentElement'),lo=g([].slice),ho=i.TypeError,fo=/(?:ipad|iphone|ipod).*applewebkit/i.test(et),po='process'==N(i.process),vo=i,yo=f,mo=$e,go=b,bo=zt,wo=s,Ao=co,Eo=lo,So=ge,_o=function(t,e){if(t<e)throw ho('Not enough arguments');return t},Po=fo,Oo=po,To=vo.setImmediate,Ro=vo.clearImmediate,jo=vo.process,ko=vo.Dispatch,Lo=vo.Function,xo=vo.MessageChannel,Co=vo.String,Io=0,No={};try{Zn=vo.location}catch(t){}var qo=function(t){if(bo(No,t)){var e=No[t];delete No[t],e()}},Uo=function(t){return function(){qo(t)}},Fo=function(t){qo(t.data)},Bo=function(t){vo.postMessage(Co(t),Zn.protocol+'//'+Zn.host)};To&&Ro||(To=function(t){_o(arguments.length,1);var e=go(t)?t:Lo(t),r=Eo(arguments,1);return No[++Io]=function(){yo(e,void 0,r)},Xn(Io),Io},Ro=function(t){delete No[t]},Oo?Xn=function(t){jo.nextTick(Uo(t))}:ko&&ko.now?Xn=function(t){ko.now(Uo(t))}:xo&&!Po?(eo=(to=new xo).port2,to.port1.onmessage=Fo,Xn=mo(eo.postMessage,eo)):vo.addEventListener&&go(vo.postMessage)&&!vo.importScripts&&Zn&&'file:'!==Zn.protocol&&!wo(Bo)?(Xn=Bo,vo.addEventListener('message',Fo,!1)):Xn='onreadystatechange'in So('script')?function(t){Ao.appendChild(So('script')).onreadystatechange=function(){Ao.removeChild(this),qo(t)}}:function(t){setTimeout(Uo(t),0)});var Mo,zo,$o,Ko,Do,Qo,Ho,Go,Wo={set:To,clear:Ro},Yo=i,Jo=/ipad|iphone|ipod/i.test(et)&&void 0!==Yo.Pebble,Vo=/web0s(?!.*chrome)/i.test(et),Zo=i,Xo=$e,ti=w.f,ei=Wo.set,ri=fo,ni=Jo,oi=Vo,ii=po,si=Zo.MutationObserver||Zo.WebKitMutationObserver,ai=Zo.document,ui=Zo.process,ci=Zo.Promise,li=ti(Zo,'queueMicrotask'),hi=li&&li.value;hi||(Mo=function(){var t,e;for(ii&&(t=ui.domain)&&t.exit();zo;){e=zo.fn,zo=zo.next;try{e()}catch(t){throw zo?Ko():$o=void 0,t}}$o=void 0,t&&t.enter()},ri||ii||oi||!si||!ai?!ni&&ci&&ci.resolve?((Ho=ci.resolve(void 0)).constructor=ci,Go=Xo(Ho.then,Ho),Ko=function(){Go(Mo)}):ii?Ko=function(){ui.nextTick(Mo)}:(ei=Xo(ei,Zo),Ko=function(){ei(Mo)}):(Do=!0,Qo=ai.createTextNode(''),new si(Mo).observe(Qo,{characterData:!0}),Ko=function(){Qo.data=Do=!Do}));var fi=hi||function(t){var e={fn:t,next:void 0};$o&&($o.next=e),zo||(zo=e,Ko()),$o=e},pi={},di=_t,vi=function(t){var e,r;this.promise=new t((function(t,n){if(void 0!==e||void 0!==r)throw TypeError('Bad Promise constructor');e=t,r=n})),this.resolve=di(e),this.reject=di(r)};pi.f=function(t){return new vi(t)};var yi=Ye,mi=G,gi=pi,bi=function(t,e){if(yi(t),mi(e)&&e.constructor===t)return e;var r=gi.f(t);return(0,r.resolve)(e),r.promise},wi=i,Ai=function(){this.head=null,this.tail=null};Ai.prototype={add:function(t){var e={item:t,next:null};this.head?this.tail.next=e:this.head=e,this.tail=e},get:function(){var t=this.head;if(t)return this.head=t.next,this.tail===t&&(this.tail=null),t.item}};var Ei,Si,_i,Pi=Ai,Oi=b,Ti=Vr,Ri=i.WeakMap,ji=Oi(Ri)&&/native code/.test(Ti(Ri)),ki=Lt.exports,Li=Ht,xi=ki('keys'),Ci=ji,Ii=i,Ni=g,qi=G,Ui=sr,Fi=zt,Bi=Nt,Mi=function(t){return xi[t]||(xi[t]=Li(t))},zi={},$i=Ii.TypeError,Ki=Ii.WeakMap;if(Ci||Bi.state){var Di=Bi.state||(Bi.state=new Ki),Qi=Ni(Di.get),Hi=Ni(Di.has),Gi=Ni(Di.set);Ei=function(t,e){if(Hi(Di,t))throw new $i('Object already initialized');return e.facade=t,Gi(Di,t,e),e},Si=function(t){return Qi(Di,t)||{}},_i=function(t){return Hi(Di,t)}}else{var Wi=Mi('state');zi[Wi]=!0,Ei=function(t,e){if(Fi(t,Wi))throw new $i('Object already initialized');return e.facade=t,Ui(t,Wi,e),e},Si=function(t){return Fi(t,Wi)?t[Wi]:{}},_i=function(t){return Fi(t,Wi)}}var Yi,Ji,Vi,Zi='object'==typeof window,Xi=gr,ts=i,es=X,rs=_,ns=br,os=function(t,e,r){for(var n in e)r&&r.unsafe&&t[n]?t[n]=e[n]:Ar(t,n,e[n],r);return t},is=function(t,e,r,n){if(t){var o=r?t:t.prototype;Br(o,zr)||Ur(o,zr,{configurable:!0,value:e}),n&&!qr&&Fr(o,'toString',Mr)}},ss=function(t){var e=$r(t),r=Kr.f;Dr&&e&&!e[Qr]&&r(e,Qr,{configurable:!0,get:function(){return this}})},as=_t,us=b,cs=G,ls=function(t,e){if(Hr(e,t))return t;throw Gr('Incorrect invocation')},hs=Vr,fs=function(t,e,r){var n,o,i,s,a,u,c,l=r&&r.that,h=!(!r||!r.AS_ENTRIES),f=!(!r||!r.IS_ITERATOR),p=!(!r||!r.INTERRUPTED),d=En(e,l),v=function(t){return n&&Ln(n,'normal',t),new Cn(!0,t)},y=function(t){return h?(_n(t),p?d(t[0],t[1],v):d(t[0],t[1])):p?d(t,v):d(t)};if(f)n=t;else{if(!(o=kn(t)))throw xn(Pn(t)+' is not iterable');if(On(o)){for(i=0,s=Tn(t);s>i;i++)if((a=y(t[i]))&&Rn(In,a))return a;return new Cn(!1)}n=jn(t,o)}for(u=n.next;!(c=Sn(u,n)).done;){try{a=y(c.value)}catch(t){Ln(n,'throw',t)}if('object'==typeof a&&a&&Rn(In,a))return a}return new Cn(!1)},ps=function(t,e){if(!e&&!qn)return!1;var r=!1;try{var n={};n[Nn]=function(){return{next:function(){return{done:r=!0}}}},t(n)}catch(t){}return r},ds=uo,vs=Wo.set,ys=fi,ms=bi,gs=function(t,e){var r=wi.console;r&&r.error&&(1==arguments.length?r.error(t):r.error(t,e))},bs=pi,ws=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},As=Pi,Es={set:Ei,get:Si,has:_i,enforce:function(t){return _i(t)?Si(t):Ei(t,{})},getterFor:function(t){return function(e){var r;if(!qi(e)||(r=Si(e)).type!==t)throw $i('Incompatible receiver, '+t+' required');return r}}},Ss=Fe,_s=Zi,Ps=po,Os=ut,Ts=ne('species'),Rs='Promise',js=Es.getterFor(Rs),ks=Es.set,Ls=Es.getterFor(Rs),xs=ns&&ns.prototype,Cs=ns,Is=xs,Ns=ts.TypeError,qs=ts.document,Us=ts.process,Fs=bs.f,Bs=Fs,Ms=!!(qs&&qs.createEvent&&ts.dispatchEvent),zs=us(ts.PromiseRejectionEvent),$s=Ss(Rs,(function(){var t=hs(Cs),e=t!==String(Cs);if(!e&&66===Os)return!0;if(!Is.finally)return!0;if(Os>=51&&/native code/.test(t))return!1;var r=new Cs((function(t){t(1)})),n=function(t){t((function(){}),(function(){}))};return(r.constructor={})[Ts]=n,!(r.then((function(){}))instanceof n)||!e&&_s&&!zs})),Ks=$s||!ps((function(t){Cs.all(t).catch((function(){}))})),Ds=function(t){var e;return!(!cs(t)||!us(e=t.then))&&e},Qs=function(t,e){var r,n,o,i=e.value,s=1==e.state,a=s?t.ok:t.fail,u=t.resolve,c=t.reject,l=t.domain;try{a?(s||(2===e.rejection&&Js(e),e.rejection=1),!0===a?r=i:(l&&l.enter(),r=a(i),l&&(l.exit(),o=!0)),r===t.promise?c(Ns('Promise-chain cycle')):(n=Ds(r))?rs(n,r,u,c):u(r)):c(i)}catch(t){l&&!o&&l.exit(),c(t)}},Hs=function(t,e){t.notified||(t.notified=!0,ys((function(){for(var r,n=t.reactions;r=n.get();)Qs(r,t);t.notified=!1,e&&!t.rejection&&Ws(t)})))},Gs=function(t,e,r){var n,o;Ms?((n=qs.createEvent('Event')).promise=e,n.reason=r,n.initEvent(t,!1,!0),ts.dispatchEvent(n)):n={promise:e,reason:r},!zs&&(o=ts['on'+t])?o(n):'unhandledrejection'===t&&gs('Unhandled promise rejection',r)},Ws=function(t){rs(vs,ts,(function(){var e,r=t.facade,n=t.value;if(Ys(t)&&(e=ws((function(){Ps?Us.emit('unhandledRejection',n,r):Gs('unhandledrejection',r,n)})),t.rejection=Ps||Ys(t)?2:1,e.error))throw e.value}))},Ys=function(t){return 1!==t.rejection&&!t.parent},Js=function(t){rs(vs,ts,(function(){var e=t.facade;Ps?Us.emit('rejectionHandled',e):Gs('rejectionhandled',e,t.value)}))},Vs=function(t,e,r){return function(n){t(e,n,r)}},Zs=function(t,e,r){t.done||(t.done=!0,r&&(t=r),t.value=e,t.state=2,Hs(t,!0))},Xs=function(t,e,r){if(!t.done){t.done=!0,r&&(t=r);try{if(t.facade===e)throw Ns('Promise can\'t be resolved itself');var n=Ds(e);n?ys((function(){var r={done:!1};try{rs(n,e,Vs(Xs,r,t),Vs(Zs,r,t))}catch(e){Zs(r,e,t)}})):(t.value=e,t.state=1,Hs(t,!1))}catch(e){Zs({done:!1},e,t)}}};$s&&(Is=(Cs=function(t){ls(this,Is),as(t),rs(Yi,this);var e=js(this);try{t(Vs(Xs,e),Vs(Zs,e))}catch(t){Zs(e,t)}}).prototype,(Yi=function(t){ks(this,{type:Rs,done:!1,notified:!1,parent:!1,reactions:new As,rejection:!1,state:0,value:void 0})}).prototype=os(Is,{then:function(t,e){var r=Ls(this),n=Fs(ds(this,Cs));return r.parent=!0,n.ok=!us(t)||t,n.fail=us(e)&&e,n.domain=Ps?Us.domain:void 0,0==r.state?r.reactions.add(n):ys((function(){Qs(n,r)})),n.promise},catch:function(t){return this.then(void 0,t)}}),Ji=function(){var t=new Yi,e=js(t);this.promise=t,this.resolve=Vs(Xs,e),this.reject=Vs(Zs,e)},bs.f=Fs=function(t){return t===Cs||t===Vi?new Ji(t):Bs(t)}),Xi({global:!0,wrap:!0,forced:$s},{Promise:Cs}),is(Cs,Rs,!1,!0),ss(Rs),Vi=es(Rs),Xi({target:Rs,stat:!0,forced:$s},{reject:function(t){var e=Fs(this);return rs(e.reject,void 0,t),e.promise}}),Xi({target:Rs,stat:!0,forced:true},{resolve:function(t){return ms(this===Vi?Cs:this,t)}}),Xi({target:Rs,stat:!0,forced:Ks},{all:function(t){var e=this,r=Fs(e),n=r.resolve,o=r.reject,i=ws((function(){var r=as(e.resolve),i=[],s=0,a=1;fs(t,(function(t){var u=s++,c=!1;a++,rs(r,e,t).then((function(t){c||(c=!0,i[u]=t,--a||n(i))}),o)})),--a||n(i)}));return i.error&&o(i.value),r.promise},race:function(t){var e=this,r=Fs(e),n=r.reject,o=ws((function(){var o=as(e.resolve);fs(t,(function(t){rs(o,e,t).then(r.resolve,n)}))}));return o.error&&n(o.value),r.promise}});var ta=br,ea=X,ra=b,na=uo,oa=bi;gr({target:'Promise',proto:!0,real:!0,forced:!!ta&&s((function(){ta.prototype.finally.call({then:function(){}},(function(){}))}))},{finally:function(t){var e=na(this,ea('Promise')),r=ra(t);return this.then(r?function(r){return oa(e,t()).then((function(){return r}))}:t,r?function(r){return oa(e,t()).then((function(){throw r}))}:t)}});var ia=X('Promise','finally');const sa=(()=>{try{const t=Date.now().toString(),e=window.localStorage;e.setItem(t,t);const r=e.getItem(t)===t;return e.removeItem(t),r?e:null}catch(t){return null}})();var aa,ua,ca,la,ha,fa,pa,da={get:t=>function(t){const e=sa?sa.getItem('_one-stat_'+t):null;if(null===e)return null;try{return JSON.parse(e)}catch(t){return null}}(t)||null,set(t,e){!function(t,e){try{sa&&sa.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){sa&&sa.removeItem('_one-stat_'+t)}(t)}};!function(t){t.PROD='prod',t.VK_ALIAS='vk_alias',t.VIDEOTEST='videotest',t.TEST='test',t.AUTO='auto'}(aa||(aa={})),function(t){t.Q144P='144',t.Q240P='240',t.Q360P='360',t.Q480P='480',t.Q720P='720',t.Q1080P='1080',t.Q1440P='1440',t.Q2160P='2160',t.Q4320P='4320',t.UNKNOWN='unknown'}(ua||(ua={})),function(t){t.CHROMECAST='chromecast',t.APPLE_TV='appletv',t.PIP='pip',t.HEADPHONES='externalHeadphones',t.SCREEN=''}(ca||(ca={})),function(t){t.MP4='mp4',t.DASH='dash',t.HLS='hls',t.WEBM='webm'}(la||(la={})),function(t){t.AUTO='auto',t.MANUAL=''}(ha||(ha={})),function(t){t.HTTP1='http1',t.HTTP2='http2',t.HTTP3='http3'}(fa||(fa={})),function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(pa||(pa={}));const va={[aa.PROD]:'https://api.ok.ru',[aa.VK_ALIAS]:'https://api.mycdn.me',[aa.VIDEOTEST]:'https://videotestapi.ok.ru/api',[aa.TEST]:'https://apitest.ok.ru',[aa.AUTO]:''};var ya;!function(t){t[t.PARAM_SESSION_EXPIRED=102]='PARAM_SESSION_EXPIRED',t[t.PARAM_SESSION_KEY=103]='PARAM_SESSION_KEY',t[t.PARAM_SIGNATURE=104]='PARAM_SIGNATURE',t[t.AUTH_LOGIN=401]='AUTH_LOGIN'}(ya||(ya={}));class ma{constructor(t){this.params=t;const e=da.get('uuid');e?this.uuid=String(e):(this.uuid=function(){const t='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),e=new Array(36);let r,n,o=0;for(n=0;n<36;n++)8===n||13===n||18===n||23===n?e[n]='-':14===n?e[n]='4':(o<=2&&(o=33554432+16777216*Math.random()|0),r=15&o,o>>=4,e[n]=t[19===n?3&r|8:r]);return e.join('')}(),da.set('uuid',this.uuid))}authorize(t){return r(this,void 0,void 0,(function*(){return this.authToken=null!=t?t:yield this.refreshAuthToken(),this._authorize()}))}logBeacon(t){const e=this.createLogParams(t),r=this.sessionKey;void 0!==r&&this.params.apiTransport.sendBeacon('log.externalLog',e,r)||this.logRequest(t)}logRequest(t){var e;return r(this,void 0,void 0,(function*(){const n='log.externalLog',o=this.createLogParams(t),i=null!==(e=this.sessionKey)&&void 0!==e?e:yield this._authorize(),s=(t,e=this.params.requestRetryCount)=>r(this,void 0,void 0,(function*(){try{return yield this.params.apiTransport.sendRequest(n,o,i)}catch(r){if(!r||!('error_code'in r))return void this.params.error$.next({id:'logRequestUnknown',message:`Unknown ${n} error`,thrown:r});const o=null==r?void 0:r.error_code;switch(o){case ya.PARAM_SESSION_EXPIRED:case ya.PARAM_SESSION_KEY:case ya.PARAM_SIGNATURE:return this.sessionKey=yield this._authorize(),e>0?s(t,e-1):void 0;case ya.AUTH_LOGIN:return this.authToken=yield this.refreshAuthToken(),this.sessionKey=yield this._authorize(0),e>0?s(t,e-1):void 0;default:return void this.params.error$.next({id:`LogRequest#${o}`,message:`${n} error`,data:r})}}}));return s(t)}))}refreshAuthToken(){return r(this,void 0,void 0,(function*(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=ia(this.params.refreshAuthToken(),(()=>{this.refreshAuthTokenPromise=void 0}))),this.refreshAuthTokenPromise}))}createLogParams(t){return{collector:'ok.mobile.apps.video',data:JSON.stringify({application:'@vkontakte/videoplayer-statistics:1.0.17',platform:'WEB',items:t.map((t=>Object.assign(Object.assign({},t),{time:0,type:1})))})}}_authorize(t=this.params.requestRetryCount){return r(this,void 0,void 0,(function*(){try{return yield this._authorizeRequest()}catch(e){const r=null==e?void 0:e.error_code;switch(r){case ya.AUTH_LOGIN:if(this.authToken=yield this.refreshAuthToken(),t>0)return this._authorize(t-1)}r?this.params.error$.next({id:`Authorize#${r}`,message:'authorize error',data:e}):this.params.error$.next({id:'AuthorizeUnknown',message:'authorize error',thrown:e})}}))}_authorizeRequest(){return r(this,void 0,void 0,(function*(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0;const t='auth.anonymLogin',e={session_data:{version:2,device_id:this.uuid,client_version:'1.0.17'.split('-')[0],client_type:'SDK_JS'}};return void 0!==this.authToken&&(e.session_data.auth_token=this.authToken,e.session_data.version=3),this.authorizePromise=ia(this.params.apiTransport.sendRequest(t,e).then((r=>{if(r){if(r.session_key)return this.sessionKey=r.session_key,this.sessionKey;this.params.error$.next({id:'AuthorizeNoSessionKey',message:`No session key in ${t} response`,data:r})}else this.params.error$.next({id:'AuthorizeEmptyResponse',message:`Empty response for ${t}`,data:e})})).catch((t=>{throw this.sessionKey=void 0,t})),(()=>{this.authorizePromise=void 0})),this.authorizePromise}))}}class ga{constructor(){Object.defineProperty(this,'listeners',{value:{},writable:!0,configurable:!0})}addEventListener(t,e,r){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push({callback:e,options:r})}removeEventListener(t,e){if(!(t in this.listeners))return;const r=this.listeners[t];for(let t=0,n=r.length;t<n;t++)if(r[t].callback===e)return void r.splice(t,1)}dispatchEvent(t){if(!(t.type in this.listeners))return;const e=this.listeners[t.type].slice();for(let r=0,n=e.length;r<n;r++){const n=e[r];try{n.callback.call(this,t)}catch(t){Promise.resolve().then((()=>{throw t}))}n.options&&n.options.once&&this.removeEventListener(t.type,n.callback)}return!t.defaultPrevented}}class ba extends ga{constructor(){super(),this.listeners||ga.call(this),Object.defineProperty(this,'aborted',{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,'onabort',{value:null,writable:!0,configurable:!0})}toString(){return'[object AbortSignal]'}dispatchEvent(t){'abort'===t.type&&(this.aborted=!0,'function'==typeof this.onabort&&this.onabort.call(this,t)),super.dispatchEvent(t)}}function wa(t){return t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill'),!0):'function'==typeof t.Request&&!t.Request.prototype.hasOwnProperty('signal')||!t.AbortController}'undefined'!=typeof Symbol&&Symbol.toStringTag&&(class{constructor(){Object.defineProperty(this,'signal',{value:new ba,writable:!0,configurable:!0})}abort(){let t;try{t=new Event('abort')}catch(e){'undefined'!=typeof document?document.createEvent?(t=document.createEvent('Event'),t.initEvent('abort',!1,!1)):(t=document.createEventObject(),t.type='abort'):t={type:'abort',bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(t)}toString(){return'[object AbortController]'}}.prototype[Symbol.toStringTag]='AbortController',ba.prototype[Symbol.toStringTag]='AbortSignal');const Aa=wa({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Ea=Aa?function(t){'function'==typeof t&&(t={fetch:t});const{fetch:e,Request:r=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o=!1}=t;if(!wa({fetch:e,Request:r,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:e,Request:i};let i=r;(i&&!i.prototype.hasOwnProperty('signal')||o)&&(i=function(t,e){let n;e&&e.signal&&(n=e.signal,delete e.signal);const o=new r(t,e);return n&&Object.defineProperty(o,'signal',{writable:!1,enumerable:!1,configurable:!0,value:n}),o},i.prototype=r.prototype);const s=e;return{fetch:(t,e)=>{const r=i&&i.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(r){let n;try{n=new DOMException('Aborted','AbortError')}catch(t){n=new Error('Aborted'),n.name='AbortError'}if(r.aborted)return Promise.reject(n);const o=new Promise(((t,e)=>{r.addEventListener('abort',(()=>e(n)),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([o,s(t,e)])}return s(t,e)},Request:i}}({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Sa=Aa?Ea.fetch:window.fetch;Aa?Ea.Request:window.Request;class _a{constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiEnv=t.apiEnv,this.apiBaseUrl=t.apiBaseUrl,this.isApiBaseUrlFetched=!1}resolveApiBaseUrl(){var t;return r(this,void 0,void 0,(function*(){if(this.apiEnv!==aa.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const e=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),r=yield Sa(e,{method:'GET',mode:'cors',cache:'no-cache'}),n=yield r.json(),o=null===(t=null==n?void 0:n.Answer[0])||void 0===t?void 0:t.data;if(!o)throw new Error('Wrong DNS response');return o}catch(t){return this.params.error$.next({id:'OneStat:ApiTransport:resolveApiBaseUrl',message:'Unhandled resolve api base url error',thrown:t}),va[aa.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}))}sendBeacon(t,e,r){if(!window.Blob||!window.navigator.sendBeacon)return!1;const n=this._prepareQueryParams({method:t,queryParams:e,sessionKey:r}),o=new window.Blob([n.toString()],{type:'application/x-www-form-urlencoded'});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,o)}catch(r){this.params.error$.next({id:'OneStat:ApiTransport:sendBeacon',message:'Unhandled beacon error',thrown:r,data:{method:t,params:e}})}return!1}sendRequest(t,e,n){return r(this,void 0,void 0,(function*(){const r=Date.now(),o=o=>{o instanceof TypeError&&['Failed to fetch','NetworkError when attempting to fetch resource.'].includes(o.message)?this.params.error$.next({id:'Network',message:'Request failed',thrown:o}):this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:o,data:{method:t,params:e,sessionKey:n,time:Date.now()-r}})};return this.apiBaseUrl=yield this.resolveApiBaseUrl(),Sa(`${this.apiBaseUrl}/fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:t,queryParams:e,sessionKey:n})}).then((t=>Number(t.headers.get('content-length'))>0?t.json().then((t=>Object.prototype.hasOwnProperty.call(t,'error_msg')?Promise.reject(t):t),o):void 0),o)}))}_prepareQueryParams(t){const e=new URLSearchParams({format:'JSON',method:t.method,application_key:this.apiKey});return void 0!==t.sessionKey&&e.append('session_key',t.sessionKey),Object.entries(t.queryParams).forEach((([t,r])=>e.append(t,'string'==typeof r?r:JSON.stringify(r)))),e}}class Pa{constructor(t){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=e((()=>{var t;try{this.flush()}catch(e){this.error$.next({id:'LoggerError',message:null!==(t=String(e))&&void 0!==t?t:'Unknown logger error',thrown:e})}}),3e3,{maxWait:15e3}),this.api=t.api,this.error$=t.error$}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[],this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}}class Oa{constructor(e,r){var n;this.statContext=e,this.config=Object.assign(Object.assign({},null!==(n=r.config)&&void 0!==n?n:{}),{requestRetryCount:1});const o=new t;this.experimental={error$:o};const i=new _a({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:va[r.apiEnv],apiEnv:r.apiEnv,error$:o});this.api=new ma({apiTransport:i,refreshAuthToken:r.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:o}),this.logger=new Pa({api:this.api,error$:o}),window.addEventListener('beforeunload',(()=>this.logger.flush(!0)))}updateContext(t){this.statContext=Object.assign(Object.assign({},this.statContext),t)}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause()}resume(){this.logger.resume()}logStarted(){this.log({operation:'play'})}logPlay(){this.log({operation:'play_toggle'})}logPause(t){this.log({operation:'pause',param:String(Math.round(t.position))})}logSeek(){this.log({operation:'seek'})}logFirstBytes(t){this.log({operation:'first_bytes',param:String(t.time)})}logFirstFrame(t){this.log({operation:'first_frame',param:String(t.time)})}logError(t){this.log({operation:'error',param:t.errorType})}logWatchCoverageRecord(t){this.log({operation:'watch_coverage_record',param:`${t.start}-${t.end}`}),this.logger.flush(!0)}logWatchCoverageLive(t){this.log({operation:'watch_coverage_live',param:`${t.start}-${t.end}`}),this.logger.flush(!0)}logEmptyBuffer(t){this.log({operation:'empty_buffer',param:String(t.duration)})}logAdSlotRequest(){this.log({operation:'adv',param:'slot_request'})}logAdStarted(t){this.log({operation:'adv',param:t})}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(t){const e=this.crateLogItem(t);this.logger.log(e)}crateLogItem({operation:t,param:e}){const r=Date.now(),n={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:!0===this.statContext.connectionReused?pa.YES:!1===this.statContext.connectionReused?pa.NO:void 0,stat_type:!0===this.statContext.autoplay?ha.AUTO:!1===this.statContext.autoplay?ha.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId};return void 0!==e&&(n.param=e),{operation:t,timestamp:r,custom:n}}}export{aa as ApiEnv,fa as ConnectionType,la as ContentType,Oa as OneStat,ua as Quality,ca as ScreenDestination};
6
+ import{Subscription as t,Subject as e,fromEvent as r}from'@vkontakte/videoplayer-shared/es2015.esm.js';import n from'lodash/debounce';function o(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))}var i='undefined'!=typeof globalThis?globalThis:'undefined'!=typeof window?window:'undefined'!=typeof global?global:'undefined'!=typeof self?self:{},s=function(t){return t&&t.Math==Math&&t},a=s('object'==typeof globalThis&&globalThis)||s('object'==typeof window&&window)||s('object'==typeof self&&self)||s('object'==typeof i&&i)||function(){return this}()||Function('return this')(),u=function(t){try{return!!t()}catch(t){return!0}},c=!u((function(){var t=function(){}.bind();return'function'!=typeof t||t.hasOwnProperty('prototype')})),l=c,h=Function.prototype,f=h.apply,p=h.call,d='object'==typeof Reflect&&Reflect.apply||(l?p.bind(f):function(){return p.apply(f,arguments)}),v=c,y=Function.prototype,m=y.bind,g=y.call,b=v&&m.bind(g,g),w=v?function(t){return t&&b(t)}:function(t){return t&&function(){return g.apply(t,arguments)}},A=function(t){return'function'==typeof t},E={},S=!u((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),_=c,P=Function.prototype.call,O=_?P.bind(P):function(){return P.apply(P,arguments)},T={},R={}.propertyIsEnumerable,j=Object.getOwnPropertyDescriptor,k=j&&!R.call({1:2},1);T.f=k?function(t){var e=j(this,t);return!!e&&e.enumerable}:R;var L,x,C=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},I=w,N=I({}.toString),q=I(''.slice),U=function(t){return q(N(t),8,-1)},F=w,B=u,M=U,z=a.Object,$=F(''.split),K=B((function(){return!z('z').propertyIsEnumerable(0)}))?function(t){return'String'==M(t)?$(t,''):z(t)}:z,D=a.TypeError,Q=function(t){if(null==t)throw D('Can\'t call method on '+t);return t},H=K,G=Q,W=A,Y=function(t){return'object'==typeof t?null!==t:W(t)},J={},V=J,Z=a,X=A,tt=function(t){return X(t)?t:void 0},et=function(t,e){return arguments.length<2?tt(V[t])||tt(Z[t]):V[t]&&V[t][e]||Z[t]&&Z[t][e]},rt=w({}.isPrototypeOf),nt=et('navigator','userAgent')||'',ot=a,it=nt,st=ot.process,at=ot.Deno,ut=st&&st.versions||at&&at.version,ct=ut&&ut.v8;ct&&(x=(L=ct.split('.'))[0]>0&&L[0]<4?1:+(L[0]+L[1])),!x&&it&&(!(L=it.match(/Edge\/(\d+)/))||L[1]>=74)&&(L=it.match(/Chrome\/(\d+)/))&&(x=+L[1]);var lt=x,ht=lt,ft=u,pt=!!Object.getOwnPropertySymbols&&!ft((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&ht&&ht<41})),dt=pt&&!Symbol.sham&&'symbol'==typeof Symbol.iterator,vt=et,yt=A,mt=rt,gt=dt,bt=a.Object,wt=gt?function(t){return'symbol'==typeof t}:function(t){var e=vt('Symbol');return yt(e)&&mt(e.prototype,bt(t))},At=a.String,Et=function(t){try{return At(t)}catch(t){return'Object'}},St=A,_t=Et,Pt=a.TypeError,Ot=function(t){if(St(t))return t;throw Pt(_t(t)+' is not a function')},Tt=Ot,Rt=function(t,e){var r=t[e];return null==r?void 0:Tt(r)},jt=O,kt=A,Lt=Y,xt=a.TypeError,Ct={exports:{}},It=a,Nt=Object.defineProperty,qt=function(t,e){try{Nt(It,t,{value:e,configurable:!0,writable:!0})}catch(r){It[t]=e}return e},Ut=a['__core-js_shared__']||qt('__core-js_shared__',{}),Ft=Ut;(Ct.exports=function(t,e){return Ft[t]||(Ft[t]=void 0!==e?e:{})})('versions',[]).push({version:'3.21.1',mode:'pure',copyright:'© 2014-2022 Denis Pushkarev (zloirock.ru)',license:'https://github.com/zloirock/core-js/blob/v3.21.1/LICENSE',source:'https://github.com/zloirock/core-js'});var Bt=Q,Mt=a.Object,zt=function(t){return Mt(Bt(t))},$t=w({}.hasOwnProperty),Kt=Object.hasOwn||function(t,e){return $t(zt(t),e)},Dt=w,Qt=0,Ht=Math.random(),Gt=Dt(1..toString),Wt=function(t){return'Symbol('+(void 0===t?'':t)+')_'+Gt(++Qt+Ht,36)},Yt=a,Jt=Ct.exports,Vt=Kt,Zt=Wt,Xt=pt,te=dt,ee=Jt('wks'),re=Yt.Symbol,ne=re&&re.for,oe=te?re:re&&re.withoutSetter||Zt,ie=function(t){if(!Vt(ee,t)||!Xt&&'string'!=typeof ee[t]){var e='Symbol.'+t;Xt&&Vt(re,t)?ee[t]=re[t]:ee[t]=te&&ne?ne(e):oe(e)}return ee[t]},se=O,ae=Y,ue=wt,ce=Rt,le=function(t,e){var r,n;if('string'===e&&kt(r=t.toString)&&!Lt(n=jt(r,t)))return n;if(kt(r=t.valueOf)&&!Lt(n=jt(r,t)))return n;if('string'!==e&&kt(r=t.toString)&&!Lt(n=jt(r,t)))return n;throw xt('Can\'t convert object to primitive value')},he=ie,fe=a.TypeError,pe=he('toPrimitive'),de=function(t,e){if(!ae(t)||ue(t))return t;var r,n=ce(t,pe);if(n){if(void 0===e&&(e='default'),r=se(n,t,e),!ae(r)||ue(r))return r;throw fe('Can\'t convert object to primitive value')}return void 0===e&&(e='number'),le(t,e)},ve=wt,ye=function(t){var e=de(t,'string');return ve(e)?e:e+''},me=Y,ge=a.document,be=me(ge)&&me(ge.createElement),we=function(t){return be?ge.createElement(t):{}},Ae=we,Ee=!S&&!u((function(){return 7!=Object.defineProperty(Ae('div'),'a',{get:function(){return 7}}).a})),Se=S,_e=O,Pe=T,Oe=C,Te=function(t){return H(G(t))},Re=ye,je=Kt,ke=Ee,Le=Object.getOwnPropertyDescriptor;E.f=Se?Le:function(t,e){if(t=Te(t),e=Re(e),ke)try{return Le(t,e)}catch(t){}if(je(t,e))return Oe(!_e(Pe.f,t,e),t[e])};var xe=u,Ce=A,Ie=/#|\.prototype\./,Ne=function(t,e){var r=Ue[qe(t)];return r==Be||r!=Fe&&(Ce(e)?xe(e):!!e)},qe=Ne.normalize=function(t){return String(t).replace(Ie,'.').toLowerCase()},Ue=Ne.data={},Fe=Ne.NATIVE='N',Be=Ne.POLYFILL='P',Me=Ne,ze=Ot,$e=c,Ke=w(w.bind),De=function(t,e){return ze(t),void 0===e?t:$e?Ke(t,e):function(){return t.apply(e,arguments)}},Qe={},He=S&&u((function(){return 42!=Object.defineProperty((function(){}),'prototype',{value:42,writable:!1}).prototype})),Ge=a,We=Y,Ye=Ge.String,Je=Ge.TypeError,Ve=function(t){if(We(t))return t;throw Je(Ye(t)+' is not an object')},Ze=S,Xe=Ee,tr=He,er=Ve,rr=ye,nr=a.TypeError,or=Object.defineProperty,ir=Object.getOwnPropertyDescriptor;Qe.f=Ze?tr?function(t,e,r){if(er(t),e=rr(e),er(r),'function'==typeof t&&'prototype'===e&&'value'in r&&'writable'in r&&!r.writable){var n=ir(t,e);n&&n.writable&&(t[e]=r.value,r={configurable:'configurable'in r?r.configurable:n.configurable,enumerable:'enumerable'in r?r.enumerable:n.enumerable,writable:!1})}return or(t,e,r)}:or:function(t,e,r){if(er(t),e=rr(e),er(r),Xe)try{return or(t,e,r)}catch(t){}if('get'in r||'set'in r)throw nr('Accessors not supported');return'value'in r&&(t[e]=r.value),t};var sr=Qe,ar=C,ur=S?function(t,e,r){return sr.f(t,e,ar(1,r))}:function(t,e,r){return t[e]=r,t},cr=a,lr=d,hr=w,fr=A,pr=E.f,dr=Me,vr=J,yr=De,mr=ur,gr=Kt,br=function(t){var e=function(r,n,o){if(this instanceof e){switch(arguments.length){case 0:return new t;case 1:return new t(r);case 2:return new t(r,n)}return new t(r,n,o)}return lr(t,this,arguments)};return e.prototype=t.prototype,e},wr=function(t,e){var r,n,o,i,s,a,u,c,l=t.target,h=t.global,f=t.stat,p=t.proto,d=h?cr:f?cr[l]:(cr[l]||{}).prototype,v=h?vr:vr[l]||mr(vr,l,{})[l],y=v.prototype;for(o in e)r=!dr(h?o:l+(f?'.':'#')+o,t.forced)&&d&&gr(d,o),s=v[o],r&&(a=t.noTargetGet?(c=pr(d,o))&&c.value:d[o]),i=r&&a?a:e[o],r&&typeof s==typeof i||(u=t.bind&&r?yr(i,cr):t.wrap&&r?br(i):p&&fr(i)?hr(i):i,(t.sham||i&&i.sham||s&&s.sham)&&mr(u,'sham',!0),mr(v,o,u),p&&(gr(vr,n=l+'Prototype')||mr(vr,n,{}),mr(vr[n],o,i),t.real&&y&&!y[o]&&mr(y,o,i)))},Ar=a.Promise,Er=ur,Sr=function(t,e,r,n){n&&n.enumerable?t[e]=r:Er(t,e,r)},_r=a,Pr=(_r.String,_r.TypeError,w);Object.setPrototypeOf||'__proto__'in{}&&function(){var t,e=!1,r={};try{(t=Pr(Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').set))(r,[]),e=r instanceof Array}catch(t){}}();var Or={};Or[ie('toStringTag')]='z';var Tr='[object z]'===String(Or),Rr=a,jr=Tr,kr=A,Lr=U,xr=ie('toStringTag'),Cr=Rr.Object,Ir='Arguments'==Lr(function(){return arguments}()),Nr=jr?Lr:function(t){var e,r,n;return void 0===t?'Undefined':null===t?'Null':'string'==typeof(r=function(t,e){try{return t[e]}catch(t){}}(e=Cr(t),xr))?r:Ir?Lr(e):'Object'==(n=Lr(e))&&kr(e.callee)?'Arguments':n},qr=Nr,Ur=Tr?{}.toString:function(){return'[object '+qr(this)+']'},Fr=Tr,Br=Qe.f,Mr=ur,zr=Kt,$r=Ur,Kr=ie('toStringTag'),Dr=et,Qr=Qe,Hr=S,Gr=ie('species'),Wr=rt,Yr=a.TypeError,Jr=A,Vr=Ut,Zr=w(Function.toString);Jr(Vr.inspectSource)||(Vr.inspectSource=function(t){return Zr(t)});var Xr=Vr.inspectSource,tn={},en=tn,rn=ie('iterator'),nn=Array.prototype,on=Math.ceil,sn=Math.floor,an=function(t){var e=+t;return e!=e||0===e?0:(e>0?sn:on)(e)},un=Math.min,cn=function(t){return t>0?un(an(t),9007199254740991):0},ln=Nr,hn=Rt,fn=tn,pn=ie('iterator'),dn=function(t){if(null!=t)return hn(t,pn)||hn(t,'@@iterator')||fn[ln(t)]},vn=O,yn=Ot,mn=Ve,gn=Et,bn=dn,wn=a.TypeError,An=O,En=Ve,Sn=Rt,_n=De,Pn=O,On=Ve,Tn=Et,Rn=function(t){return void 0!==t&&(en.Array===t||nn[rn]===t)},jn=function(t){return cn(t.length)},kn=rt,Ln=function(t,e){var r=arguments.length<2?bn(t):e;if(yn(r))return mn(vn(r,t));throw wn(gn(t)+' is not iterable')},xn=dn,Cn=function(t,e,r){var n,o;En(t);try{if(!(n=Sn(t,'return'))){if('throw'===e)throw r;return r}n=An(n,t)}catch(t){o=!0,n=t}if('throw'===e)throw r;if(o)throw n;return En(n),r},In=a.TypeError,Nn=function(t,e){this.stopped=t,this.result=e},qn=Nn.prototype,Un=ie('iterator'),Fn=!1;try{var Bn=0,Mn={next:function(){return{done:!!Bn++}},return:function(){Fn=!0}};Mn[Un]=function(){return this},Array.from(Mn,(function(){throw 2}))}catch(t){}var zn=w,$n=u,Kn=A,Dn=Nr,Qn=Xr,Hn=function(){},Gn=[],Wn=et('Reflect','construct'),Yn=/^\s*(?:class|function)\b/,Jn=zn(Yn.exec),Vn=!Yn.exec(Hn),Zn=function(t){if(!Kn(t))return!1;try{return Wn(Hn,Gn,t),!0}catch(t){return!1}},Xn=function(t){if(!Kn(t))return!1;switch(Dn(t)){case'AsyncFunction':case'GeneratorFunction':case'AsyncGeneratorFunction':return!1}try{return Vn||!!Jn(Yn,Qn(t))}catch(t){return!0}};Xn.sham=!0;var to,eo,ro,no,oo=!Wn||$n((function(){var t;return Zn(Zn.call)||!Zn(Object)||!Zn((function(){t=!0}))||t}))?Xn:Zn,io=Et,so=a.TypeError,ao=Ve,uo=function(t){if(oo(t))return t;throw so(io(t)+' is not a constructor')},co=ie('species'),lo=function(t,e){var r,n=ao(t).constructor;return void 0===n||null==(r=ao(n)[co])?e:uo(r)},ho=et('document','documentElement'),fo=w([].slice),po=a.TypeError,vo=/(?:ipad|iphone|ipod).*applewebkit/i.test(nt),yo='process'==U(a.process),mo=a,go=d,bo=De,wo=A,Ao=Kt,Eo=u,So=ho,_o=fo,Po=we,Oo=function(t,e){if(t<e)throw po('Not enough arguments');return t},To=vo,Ro=yo,jo=mo.setImmediate,ko=mo.clearImmediate,Lo=mo.process,xo=mo.Dispatch,Co=mo.Function,Io=mo.MessageChannel,No=mo.String,qo=0,Uo={};try{to=mo.location}catch(t){}var Fo=function(t){if(Ao(Uo,t)){var e=Uo[t];delete Uo[t],e()}},Bo=function(t){return function(){Fo(t)}},Mo=function(t){Fo(t.data)},zo=function(t){mo.postMessage(No(t),to.protocol+'//'+to.host)};jo&&ko||(jo=function(t){Oo(arguments.length,1);var e=wo(t)?t:Co(t),r=_o(arguments,1);return Uo[++qo]=function(){go(e,void 0,r)},eo(qo),qo},ko=function(t){delete Uo[t]},Ro?eo=function(t){Lo.nextTick(Bo(t))}:xo&&xo.now?eo=function(t){xo.now(Bo(t))}:Io&&!To?(no=(ro=new Io).port2,ro.port1.onmessage=Mo,eo=bo(no.postMessage,no)):mo.addEventListener&&wo(mo.postMessage)&&!mo.importScripts&&to&&'file:'!==to.protocol&&!Eo(zo)?(eo=zo,mo.addEventListener('message',Mo,!1)):eo='onreadystatechange'in Po('script')?function(t){So.appendChild(Po('script')).onreadystatechange=function(){So.removeChild(this),Fo(t)}}:function(t){setTimeout(Bo(t),0)});var $o,Ko,Do,Qo,Ho,Go,Wo,Yo,Jo={set:jo,clear:ko},Vo=a,Zo=/ipad|iphone|ipod/i.test(nt)&&void 0!==Vo.Pebble,Xo=/web0s(?!.*chrome)/i.test(nt),ti=a,ei=De,ri=E.f,ni=Jo.set,oi=vo,ii=Zo,si=Xo,ai=yo,ui=ti.MutationObserver||ti.WebKitMutationObserver,ci=ti.document,li=ti.process,hi=ti.Promise,fi=ri(ti,'queueMicrotask'),pi=fi&&fi.value;pi||($o=function(){var t,e;for(ai&&(t=li.domain)&&t.exit();Ko;){e=Ko.fn,Ko=Ko.next;try{e()}catch(t){throw Ko?Qo():Do=void 0,t}}Do=void 0,t&&t.enter()},oi||ai||si||!ui||!ci?!ii&&hi&&hi.resolve?((Wo=hi.resolve(void 0)).constructor=hi,Yo=ei(Wo.then,Wo),Qo=function(){Yo($o)}):ai?Qo=function(){li.nextTick($o)}:(ni=ei(ni,ti),Qo=function(){ni($o)}):(Ho=!0,Go=ci.createTextNode(''),new ui($o).observe(Go,{characterData:!0}),Qo=function(){Go.data=Ho=!Ho}));var di=pi||function(t){var e={fn:t,next:void 0};Do&&(Do.next=e),Ko||(Ko=e,Qo()),Do=e},vi={},yi=Ot,mi=function(t){var e,r;this.promise=new t((function(t,n){if(void 0!==e||void 0!==r)throw TypeError('Bad Promise constructor');e=t,r=n})),this.resolve=yi(e),this.reject=yi(r)};vi.f=function(t){return new mi(t)};var gi=Ve,bi=Y,wi=vi,Ai=function(t,e){if(gi(t),bi(e)&&e.constructor===t)return e;var r=wi.f(t);return(0,r.resolve)(e),r.promise},Ei=a,Si=function(){this.head=null,this.tail=null};Si.prototype={add:function(t){var e={item:t,next:null};this.head?this.tail.next=e:this.head=e,this.tail=e},get:function(){var t=this.head;if(t)return this.head=t.next,this.tail===t&&(this.tail=null),t.item}};var _i,Pi,Oi,Ti=Si,Ri=A,ji=Xr,ki=a.WeakMap,Li=Ri(ki)&&/native code/.test(ji(ki)),xi=Ct.exports,Ci=Wt,Ii=xi('keys'),Ni=Li,qi=a,Ui=w,Fi=Y,Bi=ur,Mi=Kt,zi=Ut,$i=function(t){return Ii[t]||(Ii[t]=Ci(t))},Ki={},Di=qi.TypeError,Qi=qi.WeakMap;if(Ni||zi.state){var Hi=zi.state||(zi.state=new Qi),Gi=Ui(Hi.get),Wi=Ui(Hi.has),Yi=Ui(Hi.set);_i=function(t,e){if(Wi(Hi,t))throw new Di('Object already initialized');return e.facade=t,Yi(Hi,t,e),e},Pi=function(t){return Gi(Hi,t)||{}},Oi=function(t){return Wi(Hi,t)}}else{var Ji=$i('state');Ki[Ji]=!0,_i=function(t,e){if(Mi(t,Ji))throw new Di('Object already initialized');return e.facade=t,Bi(t,Ji,e),e},Pi=function(t){return Mi(t,Ji)?t[Ji]:{}},Oi=function(t){return Mi(t,Ji)}}var Vi,Zi,Xi,ts='object'==typeof window,es=wr,rs=a,ns=et,os=O,is=Ar,ss=function(t,e,r){for(var n in e)r&&r.unsafe&&t[n]?t[n]=e[n]:Sr(t,n,e[n],r);return t},as=function(t,e,r,n){if(t){var o=r?t:t.prototype;zr(o,Kr)||Br(o,Kr,{configurable:!0,value:e}),n&&!Fr&&Mr(o,'toString',$r)}},us=function(t){var e=Dr(t),r=Qr.f;Hr&&e&&!e[Gr]&&r(e,Gr,{configurable:!0,get:function(){return this}})},cs=Ot,ls=A,hs=Y,fs=function(t,e){if(Wr(e,t))return t;throw Yr('Incorrect invocation')},ps=Xr,ds=function(t,e,r){var n,o,i,s,a,u,c,l=r&&r.that,h=!(!r||!r.AS_ENTRIES),f=!(!r||!r.IS_ITERATOR),p=!(!r||!r.INTERRUPTED),d=_n(e,l),v=function(t){return n&&Cn(n,'normal',t),new Nn(!0,t)},y=function(t){return h?(On(t),p?d(t[0],t[1],v):d(t[0],t[1])):p?d(t,v):d(t)};if(f)n=t;else{if(!(o=xn(t)))throw In(Tn(t)+' is not iterable');if(Rn(o)){for(i=0,s=jn(t);s>i;i++)if((a=y(t[i]))&&kn(qn,a))return a;return new Nn(!1)}n=Ln(t,o)}for(u=n.next;!(c=Pn(u,n)).done;){try{a=y(c.value)}catch(t){Cn(n,'throw',t)}if('object'==typeof a&&a&&kn(qn,a))return a}return new Nn(!1)},vs=function(t,e){if(!e&&!Fn)return!1;var r=!1;try{var n={};n[Un]=function(){return{next:function(){return{done:r=!0}}}},t(n)}catch(t){}return r},ys=lo,ms=Jo.set,gs=di,bs=Ai,ws=function(t,e){var r=Ei.console;r&&r.error&&(1==arguments.length?r.error(t):r.error(t,e))},As=vi,Es=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},Ss=Ti,_s={set:_i,get:Pi,has:Oi,enforce:function(t){return Oi(t)?Pi(t):_i(t,{})},getterFor:function(t){return function(e){var r;if(!Fi(e)||(r=Pi(e)).type!==t)throw Di('Incompatible receiver, '+t+' required');return r}}},Ps=Me,Os=ts,Ts=yo,Rs=lt,js=ie('species'),ks='Promise',Ls=_s.getterFor(ks),xs=_s.set,Cs=_s.getterFor(ks),Is=is&&is.prototype,Ns=is,qs=Is,Us=rs.TypeError,Fs=rs.document,Bs=rs.process,Ms=As.f,zs=Ms,$s=!!(Fs&&Fs.createEvent&&rs.dispatchEvent),Ks=ls(rs.PromiseRejectionEvent),Ds=Ps(ks,(function(){var t=ps(Ns),e=t!==String(Ns);if(!e&&66===Rs)return!0;if(!qs.finally)return!0;if(Rs>=51&&/native code/.test(t))return!1;var r=new Ns((function(t){t(1)})),n=function(t){t((function(){}),(function(){}))};return(r.constructor={})[js]=n,!(r.then((function(){}))instanceof n)||!e&&Os&&!Ks})),Qs=Ds||!vs((function(t){Ns.all(t).catch((function(){}))})),Hs=function(t){var e;return!(!hs(t)||!ls(e=t.then))&&e},Gs=function(t,e){var r,n,o,i=e.value,s=1==e.state,a=s?t.ok:t.fail,u=t.resolve,c=t.reject,l=t.domain;try{a?(s||(2===e.rejection&&Zs(e),e.rejection=1),!0===a?r=i:(l&&l.enter(),r=a(i),l&&(l.exit(),o=!0)),r===t.promise?c(Us('Promise-chain cycle')):(n=Hs(r))?os(n,r,u,c):u(r)):c(i)}catch(t){l&&!o&&l.exit(),c(t)}},Ws=function(t,e){t.notified||(t.notified=!0,gs((function(){for(var r,n=t.reactions;r=n.get();)Gs(r,t);t.notified=!1,e&&!t.rejection&&Js(t)})))},Ys=function(t,e,r){var n,o;$s?((n=Fs.createEvent('Event')).promise=e,n.reason=r,n.initEvent(t,!1,!0),rs.dispatchEvent(n)):n={promise:e,reason:r},!Ks&&(o=rs['on'+t])?o(n):'unhandledrejection'===t&&ws('Unhandled promise rejection',r)},Js=function(t){os(ms,rs,(function(){var e,r=t.facade,n=t.value;if(Vs(t)&&(e=Es((function(){Ts?Bs.emit('unhandledRejection',n,r):Ys('unhandledrejection',r,n)})),t.rejection=Ts||Vs(t)?2:1,e.error))throw e.value}))},Vs=function(t){return 1!==t.rejection&&!t.parent},Zs=function(t){os(ms,rs,(function(){var e=t.facade;Ts?Bs.emit('rejectionHandled',e):Ys('rejectionhandled',e,t.value)}))},Xs=function(t,e,r){return function(n){t(e,n,r)}},ta=function(t,e,r){t.done||(t.done=!0,r&&(t=r),t.value=e,t.state=2,Ws(t,!0))},ea=function(t,e,r){if(!t.done){t.done=!0,r&&(t=r);try{if(t.facade===e)throw Us('Promise can\'t be resolved itself');var n=Hs(e);n?gs((function(){var r={done:!1};try{os(n,e,Xs(ea,r,t),Xs(ta,r,t))}catch(e){ta(r,e,t)}})):(t.value=e,t.state=1,Ws(t,!1))}catch(e){ta({done:!1},e,t)}}};Ds&&(qs=(Ns=function(t){fs(this,qs),cs(t),os(Vi,this);var e=Ls(this);try{t(Xs(ea,e),Xs(ta,e))}catch(t){ta(e,t)}}).prototype,(Vi=function(t){xs(this,{type:ks,done:!1,notified:!1,parent:!1,reactions:new Ss,rejection:!1,state:0,value:void 0})}).prototype=ss(qs,{then:function(t,e){var r=Cs(this),n=Ms(ys(this,Ns));return r.parent=!0,n.ok=!ls(t)||t,n.fail=ls(e)&&e,n.domain=Ts?Bs.domain:void 0,0==r.state?r.reactions.add(n):gs((function(){Gs(n,r)})),n.promise},catch:function(t){return this.then(void 0,t)}}),Zi=function(){var t=new Vi,e=Ls(t);this.promise=t,this.resolve=Xs(ea,e),this.reject=Xs(ta,e)},As.f=Ms=function(t){return t===Ns||t===Xi?new Zi(t):zs(t)}),es({global:!0,wrap:!0,forced:Ds},{Promise:Ns}),as(Ns,ks,!1,!0),us(ks),Xi=ns(ks),es({target:ks,stat:!0,forced:Ds},{reject:function(t){var e=Ms(this);return os(e.reject,void 0,t),e.promise}}),es({target:ks,stat:!0,forced:true},{resolve:function(t){return bs(this===Xi?Ns:this,t)}}),es({target:ks,stat:!0,forced:Qs},{all:function(t){var e=this,r=Ms(e),n=r.resolve,o=r.reject,i=Es((function(){var r=cs(e.resolve),i=[],s=0,a=1;ds(t,(function(t){var u=s++,c=!1;a++,os(r,e,t).then((function(t){c||(c=!0,i[u]=t,--a||n(i))}),o)})),--a||n(i)}));return i.error&&o(i.value),r.promise},race:function(t){var e=this,r=Ms(e),n=r.reject,o=Es((function(){var o=cs(e.resolve);ds(t,(function(t){os(o,e,t).then(r.resolve,n)}))}));return o.error&&n(o.value),r.promise}});var ra=Ar,na=et,oa=A,ia=lo,sa=Ai;wr({target:'Promise',proto:!0,real:!0,forced:!!ra&&u((function(){ra.prototype.finally.call({then:function(){}},(function(){}))}))},{finally:function(t){var e=ia(this,na('Promise')),r=oa(t);return this.then(r?function(r){return sa(e,t()).then((function(){return r}))}:t,r?function(r){return sa(e,t()).then((function(){throw r}))}:t)}});var aa=et('Promise','finally');const ua=(()=>{try{const t=Date.now().toString(),e=window.localStorage;e.setItem(t,t);const r=e.getItem(t)===t;return e.removeItem(t),r?e:null}catch(t){return null}})();var ca,la,ha,fa,pa,da,va,ya={get:t=>function(t){const e=ua?ua.getItem('_one-stat_'+t):null;if(null===e)return null;try{return JSON.parse(e)}catch(t){return null}}(t)||null,set(t,e){!function(t,e){try{ua&&ua.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){ua&&ua.removeItem('_one-stat_'+t)}(t)}};!function(t){t.PROD='prod',t.VK_ALIAS='vk_alias',t.VIDEOTEST='videotest',t.TEST='test',t.AUTO='auto'}(ca||(ca={})),function(t){t.Q144P='144',t.Q240P='240',t.Q360P='360',t.Q480P='480',t.Q720P='720',t.Q1080P='1080',t.Q1440P='1440',t.Q2160P='2160',t.Q4320P='4320',t.UNKNOWN='unknown'}(la||(la={})),function(t){t.CHROMECAST='chromecast',t.APPLE_TV='appletv',t.PIP='pip',t.HEADPHONES='externalHeadphones',t.SCREEN=''}(ha||(ha={})),function(t){t.MP4='mp4',t.DASH='dash',t.HLS='hls',t.WEBM='webm'}(fa||(fa={})),function(t){t.AUTO='auto',t.MANUAL=''}(pa||(pa={})),function(t){t.HTTP1='http1',t.HTTP2='http2',t.HTTP3='http3'}(da||(da={})),function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(va||(va={}));const ma={[ca.PROD]:'https://api.ok.ru',[ca.VK_ALIAS]:'https://api.mycdn.me',[ca.VIDEOTEST]:'https://videotestapi.ok.ru/api',[ca.TEST]:'https://apitest.ok.ru',[ca.AUTO]:''};var ga;!function(t){t[t.PARAM_SESSION_EXPIRED=102]='PARAM_SESSION_EXPIRED',t[t.PARAM_SESSION_KEY=103]='PARAM_SESSION_KEY',t[t.PARAM_SIGNATURE=104]='PARAM_SIGNATURE',t[t.AUTH_LOGIN=401]='AUTH_LOGIN'}(ga||(ga={}));class ba{constructor(t){this.params=t;const e=ya.get('uuid');e?this.uuid=String(e):(this.uuid=function(){const t='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),e=new Array(36);let r,n,o=0;for(n=0;n<36;n++)8===n||13===n||18===n||23===n?e[n]='-':14===n?e[n]='4':(o<=2&&(o=33554432+16777216*Math.random()|0),r=15&o,o>>=4,e[n]=t[19===n?3&r|8:r]);return e.join('')}(),ya.set('uuid',this.uuid))}authorize(t){return o(this,void 0,void 0,(function*(){return this.authToken=null!=t?t:yield this.refreshAuthToken(),this._authorize()}))}logBeacon(t){const e=this.createLogParams(t),r=this.sessionKey;if(!r)return;this.params.apiTransport.sendBeacon('log.externalLog',e,r)||this.logRequest(t)}logRequest(t){var e;return o(this,void 0,void 0,(function*(){const r='log.externalLog',n=this.createLogParams(t),i=null!==(e=this.sessionKey)&&void 0!==e?e:yield this._authorize();if(!i)return;const s=(t,e=this.params.requestRetryCount)=>o(this,void 0,void 0,(function*(){try{return yield this.params.apiTransport.sendRequest(r,n,i)}catch(n){if(!n||!('error_code'in n))return void this.params.error$.next({id:'logRequestUnknown',message:`Unknown ${r} error`,thrown:n});const o=null==n?void 0:n.error_code;switch(o){case ga.PARAM_SESSION_EXPIRED:case ga.PARAM_SESSION_KEY:case ga.PARAM_SIGNATURE:return this.sessionKey=yield this._authorize(),e>0?s(t,e-1):void 0;case ga.AUTH_LOGIN:return this.authToken=yield this.refreshAuthToken(),this.sessionKey=yield this._authorize(0),e>0?s(t,e-1):void 0;default:return void this.params.error$.next({id:`LogRequest#${o}`,message:`${r} error`,data:n})}}}));return s(t)}))}refreshAuthToken(){return o(this,void 0,void 0,(function*(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=aa(this.params.refreshAuthToken(),(()=>{this.refreshAuthTokenPromise=void 0}))),this.refreshAuthTokenPromise}))}createLogParams(t){return{collector:'ok.mobile.apps.video',data:JSON.stringify({application:'@vkontakte/videoplayer-statistics:1.0.18',platform:'WEB',items:t.map((t=>Object.assign(Object.assign({},t),{time:0,type:1})))})}}_authorize(t=this.params.requestRetryCount){return o(this,void 0,void 0,(function*(){try{return yield this._authorizeRequest()}catch(e){const r=null==e?void 0:e.error_code;switch(r){case ga.AUTH_LOGIN:if(this.authToken=yield this.refreshAuthToken(),t>0)return this._authorize(t-1)}r?this.params.error$.next({id:`Authorize#${r}`,message:'authorize error',data:e}):this.params.error$.next({id:'AuthorizeUnknown',message:'authorize error',thrown:e})}}))}_authorizeRequest(){return o(this,void 0,void 0,(function*(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0;const t='auth.anonymLogin',e={session_data:{version:2,device_id:this.uuid,client_version:'1.0.18'.split('-')[0],client_type:'SDK_JS'}};return void 0!==this.authToken&&(e.session_data.auth_token=this.authToken,e.session_data.version=3),this.authorizePromise=aa(this.params.apiTransport.sendRequest(t,e).then((r=>{if(r){if(r.session_key)return this.sessionKey=r.session_key,this.sessionKey;this.params.error$.next({id:'AuthorizeNoSessionKey',message:`No session key in ${t} response`,data:r})}else this.params.error$.next({id:'AuthorizeEmptyResponse',message:`Empty response for ${t}`,data:e})})).catch((t=>{throw this.sessionKey=void 0,t})),(()=>{this.authorizePromise=void 0})),this.authorizePromise}))}}class wa{constructor(){Object.defineProperty(this,'listeners',{value:{},writable:!0,configurable:!0})}addEventListener(t,e,r){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push({callback:e,options:r})}removeEventListener(t,e){if(!(t in this.listeners))return;const r=this.listeners[t];for(let t=0,n=r.length;t<n;t++)if(r[t].callback===e)return void r.splice(t,1)}dispatchEvent(t){if(!(t.type in this.listeners))return;const e=this.listeners[t.type].slice();for(let r=0,n=e.length;r<n;r++){const n=e[r];try{n.callback.call(this,t)}catch(t){Promise.resolve().then((()=>{throw t}))}n.options&&n.options.once&&this.removeEventListener(t.type,n.callback)}return!t.defaultPrevented}}class Aa extends wa{constructor(){super(),this.listeners||wa.call(this),Object.defineProperty(this,'aborted',{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,'onabort',{value:null,writable:!0,configurable:!0})}toString(){return'[object AbortSignal]'}dispatchEvent(t){'abort'===t.type&&(this.aborted=!0,'function'==typeof this.onabort&&this.onabort.call(this,t)),super.dispatchEvent(t)}}function Ea(t){return t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill'),!0):'function'==typeof t.Request&&!t.Request.prototype.hasOwnProperty('signal')||!t.AbortController}'undefined'!=typeof Symbol&&Symbol.toStringTag&&(class{constructor(){Object.defineProperty(this,'signal',{value:new Aa,writable:!0,configurable:!0})}abort(){let t;try{t=new Event('abort')}catch(e){'undefined'!=typeof document?document.createEvent?(t=document.createEvent('Event'),t.initEvent('abort',!1,!1)):(t=document.createEventObject(),t.type='abort'):t={type:'abort',bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(t)}toString(){return'[object AbortController]'}}.prototype[Symbol.toStringTag]='AbortController',Aa.prototype[Symbol.toStringTag]='AbortSignal');const Sa=Ea({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),_a=Sa?function(t){'function'==typeof t&&(t={fetch:t});const{fetch:e,Request:r=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o=!1}=t;if(!Ea({fetch:e,Request:r,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:e,Request:i};let i=r;(i&&!i.prototype.hasOwnProperty('signal')||o)&&(i=function(t,e){let n;e&&e.signal&&(n=e.signal,delete e.signal);const o=new r(t,e);return n&&Object.defineProperty(o,'signal',{writable:!1,enumerable:!1,configurable:!0,value:n}),o},i.prototype=r.prototype);const s=e;return{fetch:(t,e)=>{const r=i&&i.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(r){let n;try{n=new DOMException('Aborted','AbortError')}catch(t){n=new Error('Aborted'),n.name='AbortError'}if(r.aborted)return Promise.reject(n);const o=new Promise(((t,e)=>{r.addEventListener('abort',(()=>e(n)),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([o,s(t,e)])}return s(t,e)},Request:i}}({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Pa=Sa?_a.fetch:window.fetch;Sa?_a.Request:window.Request;class Oa{constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiEnv=t.apiEnv,this.apiBaseUrl=t.apiBaseUrl,this.isApiBaseUrlFetched=!1}resolveApiBaseUrl(){var t;return o(this,void 0,void 0,(function*(){if(this.apiEnv!==ca.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const e=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),r=yield Pa(e,{method:'GET',mode:'cors',cache:'no-cache'}),n=yield r.json(),o=null===(t=null==n?void 0:n.Answer[0])||void 0===t?void 0:t.data;if(!o)throw new Error('Wrong DNS response');return o}catch(t){return this.params.error$.next({id:'OneStat:ApiTransport:resolveApiBaseUrl',message:'Unhandled resolve api base url error',thrown:t}),ma[ca.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}))}sendBeacon(t,e,r){if(!window.Blob||!window.navigator.sendBeacon)return!1;const n=this._prepareQueryParams({method:t,queryParams:e,sessionKey:r}),o=new window.Blob([n.toString()],{type:'application/x-www-form-urlencoded'});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,o)}catch(r){this.params.error$.next({id:'OneStat:ApiTransport:sendBeacon',message:'Unhandled beacon error',thrown:r,data:{method:t,params:e}})}return!1}sendRequest(t,e,r){return o(this,void 0,void 0,(function*(){const n=Date.now(),o=o=>{o instanceof TypeError&&['Failed to fetch','NetworkError when attempting to fetch resource.'].includes(o.message)?this.params.error$.next({id:'Network',message:'Request failed',thrown:o}):this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:o,data:{method:t,params:e,sessionKey:r,time:Date.now()-n}})};return this.apiBaseUrl=yield this.resolveApiBaseUrl(),Pa(`${this.apiBaseUrl}/fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:t,queryParams:e,sessionKey:r})}).then((t=>Number(t.headers.get('content-length'))>0?t.json().then((t=>Object.prototype.hasOwnProperty.call(t,'error_msg')?Promise.reject(t):t),o):void 0),o)}))}_prepareQueryParams(t){const e=new URLSearchParams({format:'JSON',method:t.method,application_key:this.apiKey});return void 0!==t.sessionKey&&e.append('session_key',t.sessionKey),Object.entries(t.queryParams).forEach((([t,r])=>e.append(t,'string'==typeof r?r:JSON.stringify(r)))),e}}class Ta{constructor(t){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=n((()=>{var t;try{this.flush()}catch(e){this.error$.next({id:'LoggerError',message:null!==(t=String(e))&&void 0!==t?t:'Unknown logger error',thrown:e})}}),3e3,{maxWait:15e3}),this.api=t.api,this.error$=t.error$}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[],this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}}class Ra{constructor(n,o){var i;this.subscription=new t,this.statContext=n,this.config=Object.assign(Object.assign({},null!==(i=o.config)&&void 0!==i?i:{}),{requestRetryCount:1});const s=new e;this.experimental={error$:s};const a=new Oa({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:ma[o.apiEnv],apiEnv:o.apiEnv,error$:s});this.api=new ba({apiTransport:a,refreshAuthToken:o.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:s}),this.logger=new Ta({api:this.api,error$:s}),this.subscription.add(r(window,'beforeunload').subscribe((()=>this.logger.flush(!0))))}updateContext(t){this.statContext=Object.assign(Object.assign({},this.statContext),t)}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause()}resume(){this.logger.resume()}destroy(){this.logger.flush(),this.subscription.unsubscribe()}logStarted(){this.log({operation:'play'})}logPlay(){this.log({operation:'play_toggle'})}logPause(t){this.log({operation:'pause',param:String(Math.round(t.position))})}logSeek(){this.log({operation:'seek'})}logFirstBytes(t){this.log({operation:'first_bytes',param:String(t.time)})}logFirstFrame(t){this.log({operation:'first_frame',param:String(t.time)})}logError(t){this.log({operation:'error',param:t.errorType})}logWatchCoverageRecord(t){this.log({operation:'watch_coverage_record',param:`${t.start}-${t.end}`}),this.logger.flush(!0)}logWatchCoverageLive(t){this.log({operation:'watch_coverage_live',param:`${t.start}-${t.end}`}),this.logger.flush(!0)}logEmptyBuffer(t){this.log({operation:'empty_buffer',param:String(t.duration)})}logAdSlotRequest(){this.log({operation:'adv',param:'slot_request'})}logAdStarted(t){this.log({operation:'adv',param:t})}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(t){const e=this.crateLogItem(t);this.logger.log(e)}crateLogItem({operation:t,param:e}){const r=Date.now(),n={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:!0===this.statContext.connectionReused?va.YES:!1===this.statContext.connectionReused?va.NO:void 0,stat_type:!0===this.statContext.autoplay?pa.AUTO:!1===this.statContext.autoplay?pa.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId};return void 0!==e&&(n.param=e),{operation:t,timestamp:r,custom:n}}}export{ca as ApiEnv,da as ConnectionType,fa as ContentType,Ra as OneStat,la as Quality,ha as ScreenDestination};
package/es2018.cjs.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @vkontakte/videoplayer-statistics v1.0.17
3
- * Tue, 28 Jun 2022 15:51:43 GMT
4
- * https://st.mycdn.me/static/playersdk/1-0-17/doc/
2
+ * @vkontakte/videoplayer-statistics v1.0.18
3
+ * Thu, 14 Jul 2022 10:36:11 GMT
4
+ * https://st.mycdn.me/static/playersdk/1-0-18/doc/
5
5
  */
6
- 'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var e=require('@vkontakte/videoplayer-shared/es2018.cjs.js');function t(e){return e&&'object'==typeof e&&'default'in e?e:{default:e}}var r=t(require('lodash/debounce'));const o=(()=>{try{const e=Date.now().toString(),t=window.localStorage;t.setItem(e,e);const r=t.getItem(e)===e;return t.removeItem(e),r?t:null}catch(e){return null}})();var s,i,n,a,h,l,u,p={get:e=>function(e){const t=o?o.getItem('_one-stat_'+e):null;if(null===t)return null;try{return JSON.parse(t)}catch(e){return null}}(e)||null,set(e,t){!function(e,t){try{o&&o.setItem('_one-stat_'+e,JSON.stringify(t))}catch(e){}}(e,t)},remove(e){!function(e){o&&o.removeItem('_one-stat_'+e)}(e)}};exports.ApiEnv=void 0,(s=exports.ApiEnv||(exports.ApiEnv={})).PROD='prod',s.VK_ALIAS='vk_alias',s.VIDEOTEST='videotest',s.TEST='test',s.AUTO='auto',exports.Quality=void 0,(i=exports.Quality||(exports.Quality={})).Q144P='144',i.Q240P='240',i.Q360P='360',i.Q480P='480',i.Q720P='720',i.Q1080P='1080',i.Q1440P='1440',i.Q2160P='2160',i.Q4320P='4320',i.UNKNOWN='unknown',exports.ScreenDestination=void 0,(n=exports.ScreenDestination||(exports.ScreenDestination={})).CHROMECAST='chromecast',n.APPLE_TV='appletv',n.PIP='pip',n.HEADPHONES='externalHeadphones',n.SCREEN='',exports.ContentType=void 0,(a=exports.ContentType||(exports.ContentType={})).MP4='mp4',a.DASH='dash',a.HLS='hls',a.WEBM='webm',function(e){e.AUTO='auto',e.MANUAL=''}(h||(h={})),exports.ConnectionType=void 0,(l=exports.ConnectionType||(exports.ConnectionType={})).HTTP1='http1',l.HTTP2='http2',l.HTTP3='http3',function(e){e[e.YES=1]='YES',e[e.NO=0]='NO'}(u||(u={}));const c={[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]:''};var d;!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'}(d||(d={}));class g{constructor(e){this.params=e;const t=p.get('uuid');t?this.uuid=String(t):(this.uuid=function(){const e='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),t=new Array(36);let r,o,s=0;for(o=0;o<36;o++)8===o||13===o||18===o||23===o?t[o]='-':14===o?t[o]='4':(s<=2&&(s=33554432+16777216*Math.random()|0),r=15&s,s>>=4,t[o]=e[19===o?3&r|8:r]);return t.join('')}(),p.set('uuid',this.uuid))}async authorize(e){return this.authToken=null!=e?e:await this.refreshAuthToken(),this._authorize()}logBeacon(e){const t=this.createLogParams(e),r=this.sessionKey;void 0!==r&&this.params.apiTransport.sendBeacon('log.externalLog',t,r)||this.logRequest(e)}async logRequest(e){var t;const r='log.externalLog',o=this.createLogParams(e),s=null!==(t=this.sessionKey)&&void 0!==t?t:await this._authorize(),i=async(e,t=this.params.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(r,o,s)}catch(o){if(!o||!('error_code'in o))return void this.params.error$.next({id:'logRequestUnknown',message:`Unknown ${r} error`,thrown:o});const s=null==o?void 0:o.error_code;switch(s){case d.PARAM_SESSION_EXPIRED:case d.PARAM_SESSION_KEY:case d.PARAM_SIGNATURE:return this.sessionKey=await this._authorize(),t>0?i(e,t-1):void 0;case d.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorize(0),t>0?i(e,t-1):void 0;default:return void this.params.error$.next({id:`LogRequest#${s}`,message:`${r} error`,data:o})}}};return i(e)}async refreshAuthToken(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=this.params.refreshAuthToken().finally((()=>{this.refreshAuthTokenPromise=void 0}))),this.refreshAuthTokenPromise}createLogParams(e){return{collector:'ok.mobile.apps.video',data:JSON.stringify({application:'@vkontakte/videoplayer-statistics:1.0.17',platform:'WEB',items:e.map((e=>({...e,time:0,type:1})))})}}async _authorize(e=this.params.requestRetryCount){try{return await this._authorizeRequest()}catch(t){const r=null==t?void 0:t.error_code;switch(r){case d.AUTH_LOGIN:if(this.authToken=await this.refreshAuthToken(),e>0)return this._authorize(e-1)}r?this.params.error$.next({id:`Authorize#${r}`,message:'authorize error',data:t}):this.params.error$.next({id:'AuthorizeUnknown',message:'authorize error',thrown:t})}}async _authorizeRequest(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0;const e='auth.anonymLogin',t={session_data:{version:2,device_id:this.uuid,client_version:'1.0.17'.split('-')[0],client_type:'SDK_JS'}};return void 0!==this.authToken&&(t.session_data.auth_token=this.authToken,t.session_data.version=3),this.authorizePromise=this.params.apiTransport.sendRequest(e,t).then((r=>{if(r){if(r.session_key)return this.sessionKey=r.session_key,this.sessionKey;this.params.error$.next({id:'AuthorizeNoSessionKey',message:`No session key in ${e} response`,data:r})}else this.params.error$.next({id:'AuthorizeEmptyResponse',message:`Empty response for ${e}`,data:t})})).catch((e=>{throw this.sessionKey=void 0,e})).finally((()=>{this.authorizePromise=void 0})),this.authorizePromise}}class m{constructor(){Object.defineProperty(this,'listeners',{value:{},writable:!0,configurable:!0})}addEventListener(e,t,r){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:r})}removeEventListener(e,t){if(!(e in this.listeners))return;const r=this.listeners[e];for(let e=0,o=r.length;e<o;e++)if(r[e].callback===t)return void r.splice(e,1)}dispatchEvent(e){if(!(e.type in this.listeners))return;const t=this.listeners[e.type].slice();for(let r=0,o=t.length;r<o;r++){const o=t[r];try{o.callback.call(this,e)}catch(e){Promise.resolve().then((()=>{throw e}))}o.options&&o.options.once&&this.removeEventListener(e.type,o.callback)}return!e.defaultPrevented}}class y extends m{constructor(){super(),this.listeners||m.call(this),Object.defineProperty(this,'aborted',{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,'onabort',{value:null,writable:!0,configurable:!0})}toString(){return'[object AbortSignal]'}dispatchEvent(e){'abort'===e.type&&(this.aborted=!0,'function'==typeof this.onabort&&this.onabort.call(this,e)),super.dispatchEvent(e)}}function v(e){return e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill'),!0):'function'==typeof e.Request&&!e.Request.prototype.hasOwnProperty('signal')||!e.AbortController}'undefined'!=typeof Symbol&&Symbol.toStringTag&&(class{constructor(){Object.defineProperty(this,'signal',{value:new y,writable:!0,configurable:!0})}abort(){let e;try{e=new Event('abort')}catch(t){'undefined'!=typeof document?document.createEvent?(e=document.createEvent('Event'),e.initEvent('abort',!1,!1)):(e=document.createEventObject(),e.type='abort'):e={type:'abort',bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(e)}toString(){return'[object AbortController]'}}.prototype[Symbol.toStringTag]='AbortController',y.prototype[Symbol.toStringTag]='AbortSignal');const f=v({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),A=f?function(e){'function'==typeof e&&(e={fetch:e});const{fetch:t,Request:r=t.Request,AbortController:o,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:s=!1}=e;if(!v({fetch:t,Request:r,AbortController:o,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:s}))return{fetch:t,Request:i};let i=r;(i&&!i.prototype.hasOwnProperty('signal')||s)&&(i=function(e,t){let o;t&&t.signal&&(o=t.signal,delete t.signal);const s=new r(e,t);return o&&Object.defineProperty(s,'signal',{writable:!1,enumerable:!1,configurable:!0,value:o}),s},i.prototype=r.prototype);const n=t;return{fetch:(e,t)=>{const r=i&&i.prototype.isPrototypeOf(e)?e.signal:t?t.signal:void 0;if(r){let o;try{o=new DOMException('Aborted','AbortError')}catch(e){o=new Error('Aborted'),o.name='AbortError'}if(r.aborted)return Promise.reject(o);const s=new Promise(((e,t)=>{r.addEventListener('abort',(()=>t(o)),{once:!0})}));return t&&t.signal&&delete t.signal,Promise.race([s,n(e,t)])}return n(e,t)},Request:i}}({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,w=f?A.fetch:window.fetch;f?A.Request:window.Request;class _{constructor(e){this.params=e,this.apiKey=e.apiKey,this.apiEnv=e.apiEnv,this.apiBaseUrl=e.apiBaseUrl,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){var e;if(this.apiEnv!==exports.ApiEnv.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const t=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),r=await w(t,{method:'GET',mode:'cors',cache:'no-cache'}),o=await r.json(),s=null===(e=null==o?void 0:o.Answer[0])||void 0===e?void 0:e.data;if(!s)throw new Error('Wrong DNS response');return s}catch(e){return this.params.error$.next({id:'OneStat:ApiTransport:resolveApiBaseUrl',message:'Unhandled resolve api base url error',thrown:e}),c[exports.ApiEnv.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(e,t,r){if(!window.Blob||!window.navigator.sendBeacon)return!1;const o=this._prepareQueryParams({method:e,queryParams:t,sessionKey:r}),s=new window.Blob([o.toString()],{type:'application/x-www-form-urlencoded'});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,s)}catch(r){this.params.error$.next({id:'OneStat:ApiTransport:sendBeacon',message:'Unhandled beacon error',thrown:r,data:{method:e,params:t}})}return!1}async sendRequest(e,t,r){const o=Date.now(),s=s=>{s instanceof TypeError&&['Failed to fetch','NetworkError when attempting to fetch resource.'].includes(s.message)?this.params.error$.next({id:'Network',message:'Request failed',thrown:s}):this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:s,data:{method:e,params:t,sessionKey:r,time:Date.now()-o}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),w(`${this.apiBaseUrl}/fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:e,queryParams:t,sessionKey:r})}).then((e=>Number(e.headers.get('content-length'))>0?e.json().then((e=>Object.prototype.hasOwnProperty.call(e,'error_msg')?Promise.reject(e):e),s):void 0),s)}_prepareQueryParams(e){const t=new URLSearchParams({format:'JSON',method:e.method,application_key:this.apiKey});return void 0!==e.sessionKey&&t.append('session_key',e.sessionKey),Object.entries(e.queryParams).forEach((([e,r])=>t.append(e,'string'==typeof r?r:JSON.stringify(r)))),t}}class b{constructor(e){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=r.default((()=>{var e;try{this.flush()}catch(t){this.error$.next({id:'LoggerError',message:null!==(e=String(t))&&void 0!==e?e:'Unknown logger error',thrown:t})}}),3e3,{maxWait:15e3}),this.api=e.api,this.error$=e.error$}log(e){this.requestQueue.push(e),this.isPaused||this.debouncedFlush()}flush(e=!1){0!==this.requestQueue.length&&(e?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[],this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}}exports.OneStat=class{constructor(t,r){var o;this.statContext=t,this.config={...null!==(o=r.config)&&void 0!==o?o:{},requestRetryCount:1};const s=new e.Subject;this.experimental={error$:s};const i=new _({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:c[r.apiEnv],apiEnv:r.apiEnv,error$:s});this.api=new g({apiTransport:i,refreshAuthToken:r.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:s}),this.logger=new b({api:this.api,error$:s}),window.addEventListener('beforeunload',(()=>this.logger.flush(!0)))}updateContext(e){this.statContext={...this.statContext,...e}}authorize(e){return this.api.authorize(e)}pause(){this.logger.pause()}resume(){this.logger.resume()}logStarted(){this.log({operation:'play'})}logPlay(){this.log({operation:'play_toggle'})}logPause(e){this.log({operation:'pause',param:String(Math.round(e.position))})}logSeek(){this.log({operation:'seek'})}logFirstBytes(e){this.log({operation:'first_bytes',param:String(e.time)})}logFirstFrame(e){this.log({operation:'first_frame',param:String(e.time)})}logError(e){this.log({operation:'error',param:e.errorType})}logWatchCoverageRecord(e){this.log({operation:'watch_coverage_record',param:`${e.start}-${e.end}`}),this.logger.flush(!0)}logWatchCoverageLive(e){this.log({operation:'watch_coverage_live',param:`${e.start}-${e.end}`}),this.logger.flush(!0)}logEmptyBuffer(e){this.log({operation:'empty_buffer',param:String(e.duration)})}logAdSlotRequest(){this.log({operation:'adv',param:'slot_request'})}logAdStarted(e){this.log({operation:'adv',param:e})}logAdPaused(){this.log({operation:'adv',param:'pause'})}logAdResumed(){this.log({operation:'adv',param:'resume'})}logAdEnded(){this.log({operation:'adv',param:'ended'})}logAdSkipped(){this.log({operation:'adv',param:'skip'})}logAdClicked(){this.log({operation:'adv',param:'click'})}log(e){const t=this.crateLogItem(e);this.logger.log(t)}crateLogItem({operation:e,param:t}){const r=Date.now(),o={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:!0===this.statContext.connectionReused?u.YES:!1===this.statContext.connectionReused?u.NO:void 0,stat_type:!0===this.statContext.autoplay?h.AUTO:!1===this.statContext.autoplay?h.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId};return void 0!==t&&(o.param=t),{operation:e,timestamp:r,custom:o}}};
6
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var e=require('@vkontakte/videoplayer-shared/es2018.cjs.js');function t(e){return e&&'object'==typeof e&&'default'in e?e:{default:e}}var r=t(require('lodash/debounce'));const s=(()=>{try{const e=Date.now().toString(),t=window.localStorage;t.setItem(e,e);const r=t.getItem(e)===e;return t.removeItem(e),r?t:null}catch(e){return null}})();var o,i,n,a,h,l,u,p={get:e=>function(e){const t=s?s.getItem('_one-stat_'+e):null;if(null===t)return null;try{return JSON.parse(t)}catch(e){return null}}(e)||null,set(e,t){!function(e,t){try{s&&s.setItem('_one-stat_'+e,JSON.stringify(t))}catch(e){}}(e,t)},remove(e){!function(e){s&&s.removeItem('_one-stat_'+e)}(e)}};exports.ApiEnv=void 0,(o=exports.ApiEnv||(exports.ApiEnv={})).PROD='prod',o.VK_ALIAS='vk_alias',o.VIDEOTEST='videotest',o.TEST='test',o.AUTO='auto',exports.Quality=void 0,(i=exports.Quality||(exports.Quality={})).Q144P='144',i.Q240P='240',i.Q360P='360',i.Q480P='480',i.Q720P='720',i.Q1080P='1080',i.Q1440P='1440',i.Q2160P='2160',i.Q4320P='4320',i.UNKNOWN='unknown',exports.ScreenDestination=void 0,(n=exports.ScreenDestination||(exports.ScreenDestination={})).CHROMECAST='chromecast',n.APPLE_TV='appletv',n.PIP='pip',n.HEADPHONES='externalHeadphones',n.SCREEN='',exports.ContentType=void 0,(a=exports.ContentType||(exports.ContentType={})).MP4='mp4',a.DASH='dash',a.HLS='hls',a.WEBM='webm',function(e){e.AUTO='auto',e.MANUAL=''}(h||(h={})),exports.ConnectionType=void 0,(l=exports.ConnectionType||(exports.ConnectionType={})).HTTP1='http1',l.HTTP2='http2',l.HTTP3='http3',function(e){e[e.YES=1]='YES',e[e.NO=0]='NO'}(u||(u={}));const c={[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]:''};var d;!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'}(d||(d={}));class g{constructor(e){this.params=e;const t=p.get('uuid');t?this.uuid=String(t):(this.uuid=function(){const e='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),t=new Array(36);let r,s,o=0;for(s=0;s<36;s++)8===s||13===s||18===s||23===s?t[s]='-':14===s?t[s]='4':(o<=2&&(o=33554432+16777216*Math.random()|0),r=15&o,o>>=4,t[s]=e[19===s?3&r|8:r]);return t.join('')}(),p.set('uuid',this.uuid))}async authorize(e){return this.authToken=null!=e?e:await this.refreshAuthToken(),this._authorize()}logBeacon(e){const t=this.createLogParams(e),r=this.sessionKey;if(!r)return;this.params.apiTransport.sendBeacon('log.externalLog',t,r)||this.logRequest(e)}async logRequest(e){var t;const r='log.externalLog',s=this.createLogParams(e),o=null!==(t=this.sessionKey)&&void 0!==t?t:await this._authorize();if(!o)return;const i=async(e,t=this.params.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(r,s,o)}catch(s){if(!s||!('error_code'in s))return void this.params.error$.next({id:'logRequestUnknown',message:`Unknown ${r} error`,thrown:s});const o=null==s?void 0:s.error_code;switch(o){case d.PARAM_SESSION_EXPIRED:case d.PARAM_SESSION_KEY:case d.PARAM_SIGNATURE:return this.sessionKey=await this._authorize(),t>0?i(e,t-1):void 0;case d.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorize(0),t>0?i(e,t-1):void 0;default:return void this.params.error$.next({id:`LogRequest#${o}`,message:`${r} error`,data:s})}}};return i(e)}async refreshAuthToken(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=this.params.refreshAuthToken().finally((()=>{this.refreshAuthTokenPromise=void 0}))),this.refreshAuthTokenPromise}createLogParams(e){return{collector:'ok.mobile.apps.video',data:JSON.stringify({application:'@vkontakte/videoplayer-statistics:1.0.18',platform:'WEB',items:e.map((e=>({...e,time:0,type:1})))})}}async _authorize(e=this.params.requestRetryCount){try{return await this._authorizeRequest()}catch(t){const r=null==t?void 0:t.error_code;switch(r){case d.AUTH_LOGIN:if(this.authToken=await this.refreshAuthToken(),e>0)return this._authorize(e-1)}r?this.params.error$.next({id:`Authorize#${r}`,message:'authorize error',data:t}):this.params.error$.next({id:'AuthorizeUnknown',message:'authorize error',thrown:t})}}async _authorizeRequest(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0;const e='auth.anonymLogin',t={session_data:{version:2,device_id:this.uuid,client_version:'1.0.18'.split('-')[0],client_type:'SDK_JS'}};return void 0!==this.authToken&&(t.session_data.auth_token=this.authToken,t.session_data.version=3),this.authorizePromise=this.params.apiTransport.sendRequest(e,t).then((r=>{if(r){if(r.session_key)return this.sessionKey=r.session_key,this.sessionKey;this.params.error$.next({id:'AuthorizeNoSessionKey',message:`No session key in ${e} response`,data:r})}else this.params.error$.next({id:'AuthorizeEmptyResponse',message:`Empty response for ${e}`,data:t})})).catch((e=>{throw this.sessionKey=void 0,e})).finally((()=>{this.authorizePromise=void 0})),this.authorizePromise}}class m{constructor(){Object.defineProperty(this,'listeners',{value:{},writable:!0,configurable:!0})}addEventListener(e,t,r){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:r})}removeEventListener(e,t){if(!(e in this.listeners))return;const r=this.listeners[e];for(let e=0,s=r.length;e<s;e++)if(r[e].callback===t)return void r.splice(e,1)}dispatchEvent(e){if(!(e.type in this.listeners))return;const t=this.listeners[e.type].slice();for(let r=0,s=t.length;r<s;r++){const s=t[r];try{s.callback.call(this,e)}catch(e){Promise.resolve().then((()=>{throw e}))}s.options&&s.options.once&&this.removeEventListener(e.type,s.callback)}return!e.defaultPrevented}}class y extends m{constructor(){super(),this.listeners||m.call(this),Object.defineProperty(this,'aborted',{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,'onabort',{value:null,writable:!0,configurable:!0})}toString(){return'[object AbortSignal]'}dispatchEvent(e){'abort'===e.type&&(this.aborted=!0,'function'==typeof this.onabort&&this.onabort.call(this,e)),super.dispatchEvent(e)}}function f(e){return e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill'),!0):'function'==typeof e.Request&&!e.Request.prototype.hasOwnProperty('signal')||!e.AbortController}'undefined'!=typeof Symbol&&Symbol.toStringTag&&(class{constructor(){Object.defineProperty(this,'signal',{value:new y,writable:!0,configurable:!0})}abort(){let e;try{e=new Event('abort')}catch(t){'undefined'!=typeof document?document.createEvent?(e=document.createEvent('Event'),e.initEvent('abort',!1,!1)):(e=document.createEventObject(),e.type='abort'):e={type:'abort',bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(e)}toString(){return'[object AbortController]'}}.prototype[Symbol.toStringTag]='AbortController',y.prototype[Symbol.toStringTag]='AbortSignal');const v=f({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),A=v?function(e){'function'==typeof e&&(e={fetch:e});const{fetch:t,Request:r=t.Request,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o=!1}=e;if(!f({fetch:t,Request:r,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:t,Request:i};let i=r;(i&&!i.prototype.hasOwnProperty('signal')||o)&&(i=function(e,t){let s;t&&t.signal&&(s=t.signal,delete t.signal);const o=new r(e,t);return s&&Object.defineProperty(o,'signal',{writable:!1,enumerable:!1,configurable:!0,value:s}),o},i.prototype=r.prototype);const n=t;return{fetch:(e,t)=>{const r=i&&i.prototype.isPrototypeOf(e)?e.signal:t?t.signal:void 0;if(r){let s;try{s=new DOMException('Aborted','AbortError')}catch(e){s=new Error('Aborted'),s.name='AbortError'}if(r.aborted)return Promise.reject(s);const o=new Promise(((e,t)=>{r.addEventListener('abort',(()=>t(s)),{once:!0})}));return t&&t.signal&&delete t.signal,Promise.race([o,n(e,t)])}return n(e,t)},Request:i}}({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,b=v?A.fetch:window.fetch;v?A.Request:window.Request;class w{constructor(e){this.params=e,this.apiKey=e.apiKey,this.apiEnv=e.apiEnv,this.apiBaseUrl=e.apiBaseUrl,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){var e;if(this.apiEnv!==exports.ApiEnv.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const t=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),r=await b(t,{method:'GET',mode:'cors',cache:'no-cache'}),s=await r.json(),o=null===(e=null==s?void 0:s.Answer[0])||void 0===e?void 0:e.data;if(!o)throw new Error('Wrong DNS response');return o}catch(e){return this.params.error$.next({id:'OneStat:ApiTransport:resolveApiBaseUrl',message:'Unhandled resolve api base url error',thrown:e}),c[exports.ApiEnv.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(e,t,r){if(!window.Blob||!window.navigator.sendBeacon)return!1;const s=this._prepareQueryParams({method:e,queryParams:t,sessionKey:r}),o=new window.Blob([s.toString()],{type:'application/x-www-form-urlencoded'});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,o)}catch(r){this.params.error$.next({id:'OneStat:ApiTransport:sendBeacon',message:'Unhandled beacon error',thrown:r,data:{method:e,params:t}})}return!1}async sendRequest(e,t,r){const s=Date.now(),o=o=>{o instanceof TypeError&&['Failed to fetch','NetworkError when attempting to fetch resource.'].includes(o.message)?this.params.error$.next({id:'Network',message:'Request failed',thrown:o}):this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:o,data:{method:e,params:t,sessionKey:r,time:Date.now()-s}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),b(`${this.apiBaseUrl}/fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:e,queryParams:t,sessionKey:r})}).then((e=>Number(e.headers.get('content-length'))>0?e.json().then((e=>Object.prototype.hasOwnProperty.call(e,'error_msg')?Promise.reject(e):e),o):void 0),o)}_prepareQueryParams(e){const t=new URLSearchParams({format:'JSON',method:e.method,application_key:this.apiKey});return void 0!==e.sessionKey&&t.append('session_key',e.sessionKey),Object.entries(e.queryParams).forEach((([e,r])=>t.append(e,'string'==typeof r?r:JSON.stringify(r)))),t}}class _{constructor(e){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=r.default((()=>{var e;try{this.flush()}catch(t){this.error$.next({id:'LoggerError',message:null!==(e=String(t))&&void 0!==e?e:'Unknown logger error',thrown:t})}}),3e3,{maxWait:15e3}),this.api=e.api,this.error$=e.error$}log(e){this.requestQueue.push(e),this.isPaused||this.debouncedFlush()}flush(e=!1){0!==this.requestQueue.length&&(e?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[],this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}}exports.OneStat=class{constructor(t,r){var s;this.subscription=new e.Subscription,this.statContext=t,this.config={...null!==(s=r.config)&&void 0!==s?s:{},requestRetryCount:1};const o=new e.Subject;this.experimental={error$:o};const i=new w({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:c[r.apiEnv],apiEnv:r.apiEnv,error$:o});this.api=new g({apiTransport:i,refreshAuthToken:r.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:o}),this.logger=new _({api:this.api,error$:o}),this.subscription.add(e.fromEvent(window,'beforeunload').subscribe((()=>this.logger.flush(!0))))}updateContext(e){this.statContext={...this.statContext,...e}}authorize(e){return this.api.authorize(e)}pause(){this.logger.pause()}resume(){this.logger.resume()}destroy(){this.logger.flush(),this.subscription.unsubscribe()}logStarted(){this.log({operation:'play'})}logPlay(){this.log({operation:'play_toggle'})}logPause(e){this.log({operation:'pause',param:String(Math.round(e.position))})}logSeek(){this.log({operation:'seek'})}logFirstBytes(e){this.log({operation:'first_bytes',param:String(e.time)})}logFirstFrame(e){this.log({operation:'first_frame',param:String(e.time)})}logError(e){this.log({operation:'error',param:e.errorType})}logWatchCoverageRecord(e){this.log({operation:'watch_coverage_record',param:`${e.start}-${e.end}`}),this.logger.flush(!0)}logWatchCoverageLive(e){this.log({operation:'watch_coverage_live',param:`${e.start}-${e.end}`}),this.logger.flush(!0)}logEmptyBuffer(e){this.log({operation:'empty_buffer',param:String(e.duration)})}logAdSlotRequest(){this.log({operation:'adv',param:'slot_request'})}logAdStarted(e){this.log({operation:'adv',param:e})}logAdPaused(){this.log({operation:'adv',param:'pause'})}logAdResumed(){this.log({operation:'adv',param:'resume'})}logAdEnded(){this.log({operation:'adv',param:'ended'})}logAdSkipped(){this.log({operation:'adv',param:'skip'})}logAdClicked(){this.log({operation:'adv',param:'click'})}log(e){const t=this.crateLogItem(e);this.logger.log(t)}crateLogItem({operation:e,param:t}){const r=Date.now(),s={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:!0===this.statContext.connectionReused?u.YES:!1===this.statContext.connectionReused?u.NO:void 0,stat_type:!0===this.statContext.autoplay?h.AUTO:!1===this.statContext.autoplay?h.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId};return void 0!==t&&(s.param=t),{operation:e,timestamp:r,custom:s}}};
package/es2018.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @vkontakte/videoplayer-statistics v1.0.17
3
- * Tue, 28 Jun 2022 15:51:43 GMT
4
- * https://st.mycdn.me/static/playersdk/1-0-17/doc/
2
+ * @vkontakte/videoplayer-statistics v1.0.18
3
+ * Thu, 14 Jul 2022 10:36:11 GMT
4
+ * https://st.mycdn.me/static/playersdk/1-0-18/doc/
5
5
  */
6
- import{Subject as t}from'@vkontakte/videoplayer-shared/es2018.esm.js';import e from'lodash/debounce';const r=(()=>{try{const t=Date.now().toString(),e=window.localStorage;e.setItem(t,t);const r=e.getItem(t)===t;return e.removeItem(t),r?e:null}catch(t){return null}})();var s,o,i,n,a,h,l,u={get:t=>function(t){const e=r?r.getItem('_one-stat_'+t):null;if(null===e)return null;try{return JSON.parse(e)}catch(t){return null}}(t)||null,set(t,e){!function(t,e){try{r&&r.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){r&&r.removeItem('_one-stat_'+t)}(t)}};!function(t){t.PROD='prod',t.VK_ALIAS='vk_alias',t.VIDEOTEST='videotest',t.TEST='test',t.AUTO='auto'}(s||(s={})),function(t){t.Q144P='144',t.Q240P='240',t.Q360P='360',t.Q480P='480',t.Q720P='720',t.Q1080P='1080',t.Q1440P='1440',t.Q2160P='2160',t.Q4320P='4320',t.UNKNOWN='unknown'}(o||(o={})),function(t){t.CHROMECAST='chromecast',t.APPLE_TV='appletv',t.PIP='pip',t.HEADPHONES='externalHeadphones',t.SCREEN=''}(i||(i={})),function(t){t.MP4='mp4',t.DASH='dash',t.HLS='hls',t.WEBM='webm'}(n||(n={})),function(t){t.AUTO='auto',t.MANUAL=''}(a||(a={})),function(t){t.HTTP1='http1',t.HTTP2='http2',t.HTTP3='http3'}(h||(h={})),function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(l||(l={}));const c={[s.PROD]:'https://api.ok.ru',[s.VK_ALIAS]:'https://api.mycdn.me',[s.VIDEOTEST]:'https://videotestapi.ok.ru/api',[s.TEST]:'https://apitest.ok.ru',[s.AUTO]:''};var p;!function(t){t[t.PARAM_SESSION_EXPIRED=102]='PARAM_SESSION_EXPIRED',t[t.PARAM_SESSION_KEY=103]='PARAM_SESSION_KEY',t[t.PARAM_SIGNATURE=104]='PARAM_SIGNATURE',t[t.AUTH_LOGIN=401]='AUTH_LOGIN'}(p||(p={}));class d{constructor(t){this.params=t;const e=u.get('uuid');e?this.uuid=String(e):(this.uuid=function(){const t='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),e=new Array(36);let r,s,o=0;for(s=0;s<36;s++)8===s||13===s||18===s||23===s?e[s]='-':14===s?e[s]='4':(o<=2&&(o=33554432+16777216*Math.random()|0),r=15&o,o>>=4,e[s]=t[19===s?3&r|8:r]);return e.join('')}(),u.set('uuid',this.uuid))}async authorize(t){return this.authToken=null!=t?t:await this.refreshAuthToken(),this._authorize()}logBeacon(t){const e=this.createLogParams(t),r=this.sessionKey;void 0!==r&&this.params.apiTransport.sendBeacon('log.externalLog',e,r)||this.logRequest(t)}async logRequest(t){var e;const r='log.externalLog',s=this.createLogParams(t),o=null!==(e=this.sessionKey)&&void 0!==e?e:await this._authorize(),i=async(t,e=this.params.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(r,s,o)}catch(s){if(!s||!('error_code'in s))return void this.params.error$.next({id:'logRequestUnknown',message:`Unknown ${r} error`,thrown:s});const o=null==s?void 0:s.error_code;switch(o){case p.PARAM_SESSION_EXPIRED:case p.PARAM_SESSION_KEY:case p.PARAM_SIGNATURE:return this.sessionKey=await this._authorize(),e>0?i(t,e-1):void 0;case p.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorize(0),e>0?i(t,e-1):void 0;default:return void this.params.error$.next({id:`LogRequest#${o}`,message:`${r} error`,data:s})}}};return i(t)}async refreshAuthToken(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=this.params.refreshAuthToken().finally((()=>{this.refreshAuthTokenPromise=void 0}))),this.refreshAuthTokenPromise}createLogParams(t){return{collector:'ok.mobile.apps.video',data:JSON.stringify({application:'@vkontakte/videoplayer-statistics:1.0.17',platform:'WEB',items:t.map((t=>({...t,time:0,type:1})))})}}async _authorize(t=this.params.requestRetryCount){try{return await this._authorizeRequest()}catch(e){const r=null==e?void 0:e.error_code;switch(r){case p.AUTH_LOGIN:if(this.authToken=await this.refreshAuthToken(),t>0)return this._authorize(t-1)}r?this.params.error$.next({id:`Authorize#${r}`,message:'authorize error',data:e}):this.params.error$.next({id:'AuthorizeUnknown',message:'authorize error',thrown:e})}}async _authorizeRequest(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0;const t='auth.anonymLogin',e={session_data:{version:2,device_id:this.uuid,client_version:'1.0.17'.split('-')[0],client_type:'SDK_JS'}};return void 0!==this.authToken&&(e.session_data.auth_token=this.authToken,e.session_data.version=3),this.authorizePromise=this.params.apiTransport.sendRequest(t,e).then((r=>{if(r){if(r.session_key)return this.sessionKey=r.session_key,this.sessionKey;this.params.error$.next({id:'AuthorizeNoSessionKey',message:`No session key in ${t} response`,data:r})}else this.params.error$.next({id:'AuthorizeEmptyResponse',message:`Empty response for ${t}`,data:e})})).catch((t=>{throw this.sessionKey=void 0,t})).finally((()=>{this.authorizePromise=void 0})),this.authorizePromise}}class m{constructor(){Object.defineProperty(this,'listeners',{value:{},writable:!0,configurable:!0})}addEventListener(t,e,r){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push({callback:e,options:r})}removeEventListener(t,e){if(!(t in this.listeners))return;const r=this.listeners[t];for(let t=0,s=r.length;t<s;t++)if(r[t].callback===e)return void r.splice(t,1)}dispatchEvent(t){if(!(t.type in this.listeners))return;const e=this.listeners[t.type].slice();for(let r=0,s=e.length;r<s;r++){const s=e[r];try{s.callback.call(this,t)}catch(t){Promise.resolve().then((()=>{throw t}))}s.options&&s.options.once&&this.removeEventListener(t.type,s.callback)}return!t.defaultPrevented}}class g extends m{constructor(){super(),this.listeners||m.call(this),Object.defineProperty(this,'aborted',{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,'onabort',{value:null,writable:!0,configurable:!0})}toString(){return'[object AbortSignal]'}dispatchEvent(t){'abort'===t.type&&(this.aborted=!0,'function'==typeof this.onabort&&this.onabort.call(this,t)),super.dispatchEvent(t)}}function y(t){return t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill'),!0):'function'==typeof t.Request&&!t.Request.prototype.hasOwnProperty('signal')||!t.AbortController}'undefined'!=typeof Symbol&&Symbol.toStringTag&&(class{constructor(){Object.defineProperty(this,'signal',{value:new g,writable:!0,configurable:!0})}abort(){let t;try{t=new Event('abort')}catch(e){'undefined'!=typeof document?document.createEvent?(t=document.createEvent('Event'),t.initEvent('abort',!1,!1)):(t=document.createEventObject(),t.type='abort'):t={type:'abort',bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(t)}toString(){return'[object AbortController]'}}.prototype[Symbol.toStringTag]='AbortController',g.prototype[Symbol.toStringTag]='AbortSignal');const f=y({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),A=f?function(t){'function'==typeof t&&(t={fetch:t});const{fetch:e,Request:r=e.Request,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o=!1}=t;if(!y({fetch:e,Request:r,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:e,Request:i};let i=r;(i&&!i.prototype.hasOwnProperty('signal')||o)&&(i=function(t,e){let s;e&&e.signal&&(s=e.signal,delete e.signal);const o=new r(t,e);return s&&Object.defineProperty(o,'signal',{writable:!1,enumerable:!1,configurable:!0,value:s}),o},i.prototype=r.prototype);const n=e;return{fetch:(t,e)=>{const r=i&&i.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(r){let s;try{s=new DOMException('Aborted','AbortError')}catch(t){s=new Error('Aborted'),s.name='AbortError'}if(r.aborted)return Promise.reject(s);const o=new Promise(((t,e)=>{r.addEventListener('abort',(()=>e(s)),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([o,n(t,e)])}return n(t,e)},Request:i}}({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,v=f?A.fetch:window.fetch;f?A.Request:window.Request;class w{constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiEnv=t.apiEnv,this.apiBaseUrl=t.apiBaseUrl,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){var t;if(this.apiEnv!==s.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const e=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),r=await v(e,{method:'GET',mode:'cors',cache:'no-cache'}),s=await r.json(),o=null===(t=null==s?void 0:s.Answer[0])||void 0===t?void 0:t.data;if(!o)throw new Error('Wrong DNS response');return o}catch(t){return this.params.error$.next({id:'OneStat:ApiTransport:resolveApiBaseUrl',message:'Unhandled resolve api base url error',thrown:t}),c[s.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(t,e,r){if(!window.Blob||!window.navigator.sendBeacon)return!1;const s=this._prepareQueryParams({method:t,queryParams:e,sessionKey:r}),o=new window.Blob([s.toString()],{type:'application/x-www-form-urlencoded'});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,o)}catch(r){this.params.error$.next({id:'OneStat:ApiTransport:sendBeacon',message:'Unhandled beacon error',thrown:r,data:{method:t,params:e}})}return!1}async sendRequest(t,e,r){const s=Date.now(),o=o=>{o instanceof TypeError&&['Failed to fetch','NetworkError when attempting to fetch resource.'].includes(o.message)?this.params.error$.next({id:'Network',message:'Request failed',thrown:o}):this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:o,data:{method:t,params:e,sessionKey:r,time:Date.now()-s}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),v(`${this.apiBaseUrl}/fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:t,queryParams:e,sessionKey:r})}).then((t=>Number(t.headers.get('content-length'))>0?t.json().then((t=>Object.prototype.hasOwnProperty.call(t,'error_msg')?Promise.reject(t):t),o):void 0),o)}_prepareQueryParams(t){const e=new URLSearchParams({format:'JSON',method:t.method,application_key:this.apiKey});return void 0!==t.sessionKey&&e.append('session_key',t.sessionKey),Object.entries(t.queryParams).forEach((([t,r])=>e.append(t,'string'==typeof r?r:JSON.stringify(r)))),e}}class _{constructor(t){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=e((()=>{var t;try{this.flush()}catch(e){this.error$.next({id:'LoggerError',message:null!==(t=String(e))&&void 0!==t?t:'Unknown logger error',thrown:e})}}),3e3,{maxWait:15e3}),this.api=t.api,this.error$=t.error$}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[],this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}}class b{constructor(e,r){var s;this.statContext=e,this.config={...null!==(s=r.config)&&void 0!==s?s:{},requestRetryCount:1};const o=new t;this.experimental={error$:o};const i=new w({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:c[r.apiEnv],apiEnv:r.apiEnv,error$:o});this.api=new d({apiTransport:i,refreshAuthToken:r.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:o}),this.logger=new _({api:this.api,error$:o}),window.addEventListener('beforeunload',(()=>this.logger.flush(!0)))}updateContext(t){this.statContext={...this.statContext,...t}}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause()}resume(){this.logger.resume()}logStarted(){this.log({operation:'play'})}logPlay(){this.log({operation:'play_toggle'})}logPause(t){this.log({operation:'pause',param:String(Math.round(t.position))})}logSeek(){this.log({operation:'seek'})}logFirstBytes(t){this.log({operation:'first_bytes',param:String(t.time)})}logFirstFrame(t){this.log({operation:'first_frame',param:String(t.time)})}logError(t){this.log({operation:'error',param:t.errorType})}logWatchCoverageRecord(t){this.log({operation:'watch_coverage_record',param:`${t.start}-${t.end}`}),this.logger.flush(!0)}logWatchCoverageLive(t){this.log({operation:'watch_coverage_live',param:`${t.start}-${t.end}`}),this.logger.flush(!0)}logEmptyBuffer(t){this.log({operation:'empty_buffer',param:String(t.duration)})}logAdSlotRequest(){this.log({operation:'adv',param:'slot_request'})}logAdStarted(t){this.log({operation:'adv',param:t})}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(t){const e=this.crateLogItem(t);this.logger.log(e)}crateLogItem({operation:t,param:e}){const r=Date.now(),s={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:!0===this.statContext.connectionReused?l.YES:!1===this.statContext.connectionReused?l.NO:void 0,stat_type:!0===this.statContext.autoplay?a.AUTO:!1===this.statContext.autoplay?a.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId};return void 0!==e&&(s.param=e),{operation:t,timestamp:r,custom:s}}}export{s as ApiEnv,h as ConnectionType,n as ContentType,b as OneStat,o as Quality,i as ScreenDestination};
6
+ import{Subscription as t,Subject as e,fromEvent as r}from'@vkontakte/videoplayer-shared/es2018.esm.js';import s from'lodash/debounce';const o=(()=>{try{const t=Date.now().toString(),e=window.localStorage;e.setItem(t,t);const r=e.getItem(t)===t;return e.removeItem(t),r?e:null}catch(t){return null}})();var i,n,a,h,l,u,c,p={get:t=>function(t){const e=o?o.getItem('_one-stat_'+t):null;if(null===e)return null;try{return JSON.parse(e)}catch(t){return null}}(t)||null,set(t,e){!function(t,e){try{o&&o.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){o&&o.removeItem('_one-stat_'+t)}(t)}};!function(t){t.PROD='prod',t.VK_ALIAS='vk_alias',t.VIDEOTEST='videotest',t.TEST='test',t.AUTO='auto'}(i||(i={})),function(t){t.Q144P='144',t.Q240P='240',t.Q360P='360',t.Q480P='480',t.Q720P='720',t.Q1080P='1080',t.Q1440P='1440',t.Q2160P='2160',t.Q4320P='4320',t.UNKNOWN='unknown'}(n||(n={})),function(t){t.CHROMECAST='chromecast',t.APPLE_TV='appletv',t.PIP='pip',t.HEADPHONES='externalHeadphones',t.SCREEN=''}(a||(a={})),function(t){t.MP4='mp4',t.DASH='dash',t.HLS='hls',t.WEBM='webm'}(h||(h={})),function(t){t.AUTO='auto',t.MANUAL=''}(l||(l={})),function(t){t.HTTP1='http1',t.HTTP2='http2',t.HTTP3='http3'}(u||(u={})),function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(c||(c={}));const d={[i.PROD]:'https://api.ok.ru',[i.VK_ALIAS]:'https://api.mycdn.me',[i.VIDEOTEST]:'https://videotestapi.ok.ru/api',[i.TEST]:'https://apitest.ok.ru',[i.AUTO]:''};var m;!function(t){t[t.PARAM_SESSION_EXPIRED=102]='PARAM_SESSION_EXPIRED',t[t.PARAM_SESSION_KEY=103]='PARAM_SESSION_KEY',t[t.PARAM_SIGNATURE=104]='PARAM_SIGNATURE',t[t.AUTH_LOGIN=401]='AUTH_LOGIN'}(m||(m={}));class g{constructor(t){this.params=t;const e=p.get('uuid');e?this.uuid=String(e):(this.uuid=function(){const t='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),e=new Array(36);let r,s,o=0;for(s=0;s<36;s++)8===s||13===s||18===s||23===s?e[s]='-':14===s?e[s]='4':(o<=2&&(o=33554432+16777216*Math.random()|0),r=15&o,o>>=4,e[s]=t[19===s?3&r|8:r]);return e.join('')}(),p.set('uuid',this.uuid))}async authorize(t){return this.authToken=null!=t?t:await this.refreshAuthToken(),this._authorize()}logBeacon(t){const e=this.createLogParams(t),r=this.sessionKey;if(!r)return;this.params.apiTransport.sendBeacon('log.externalLog',e,r)||this.logRequest(t)}async logRequest(t){var e;const r='log.externalLog',s=this.createLogParams(t),o=null!==(e=this.sessionKey)&&void 0!==e?e:await this._authorize();if(!o)return;const i=async(t,e=this.params.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(r,s,o)}catch(s){if(!s||!('error_code'in s))return void this.params.error$.next({id:'logRequestUnknown',message:`Unknown ${r} error`,thrown:s});const o=null==s?void 0:s.error_code;switch(o){case m.PARAM_SESSION_EXPIRED:case m.PARAM_SESSION_KEY:case m.PARAM_SIGNATURE:return this.sessionKey=await this._authorize(),e>0?i(t,e-1):void 0;case m.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorize(0),e>0?i(t,e-1):void 0;default:return void this.params.error$.next({id:`LogRequest#${o}`,message:`${r} error`,data:s})}}};return i(t)}async refreshAuthToken(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=this.params.refreshAuthToken().finally((()=>{this.refreshAuthTokenPromise=void 0}))),this.refreshAuthTokenPromise}createLogParams(t){return{collector:'ok.mobile.apps.video',data:JSON.stringify({application:'@vkontakte/videoplayer-statistics:1.0.18',platform:'WEB',items:t.map((t=>({...t,time:0,type:1})))})}}async _authorize(t=this.params.requestRetryCount){try{return await this._authorizeRequest()}catch(e){const r=null==e?void 0:e.error_code;switch(r){case m.AUTH_LOGIN:if(this.authToken=await this.refreshAuthToken(),t>0)return this._authorize(t-1)}r?this.params.error$.next({id:`Authorize#${r}`,message:'authorize error',data:e}):this.params.error$.next({id:'AuthorizeUnknown',message:'authorize error',thrown:e})}}async _authorizeRequest(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0;const t='auth.anonymLogin',e={session_data:{version:2,device_id:this.uuid,client_version:'1.0.18'.split('-')[0],client_type:'SDK_JS'}};return void 0!==this.authToken&&(e.session_data.auth_token=this.authToken,e.session_data.version=3),this.authorizePromise=this.params.apiTransport.sendRequest(t,e).then((r=>{if(r){if(r.session_key)return this.sessionKey=r.session_key,this.sessionKey;this.params.error$.next({id:'AuthorizeNoSessionKey',message:`No session key in ${t} response`,data:r})}else this.params.error$.next({id:'AuthorizeEmptyResponse',message:`Empty response for ${t}`,data:e})})).catch((t=>{throw this.sessionKey=void 0,t})).finally((()=>{this.authorizePromise=void 0})),this.authorizePromise}}class y{constructor(){Object.defineProperty(this,'listeners',{value:{},writable:!0,configurable:!0})}addEventListener(t,e,r){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push({callback:e,options:r})}removeEventListener(t,e){if(!(t in this.listeners))return;const r=this.listeners[t];for(let t=0,s=r.length;t<s;t++)if(r[t].callback===e)return void r.splice(t,1)}dispatchEvent(t){if(!(t.type in this.listeners))return;const e=this.listeners[t.type].slice();for(let r=0,s=e.length;r<s;r++){const s=e[r];try{s.callback.call(this,t)}catch(t){Promise.resolve().then((()=>{throw t}))}s.options&&s.options.once&&this.removeEventListener(t.type,s.callback)}return!t.defaultPrevented}}class f extends y{constructor(){super(),this.listeners||y.call(this),Object.defineProperty(this,'aborted',{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,'onabort',{value:null,writable:!0,configurable:!0})}toString(){return'[object AbortSignal]'}dispatchEvent(t){'abort'===t.type&&(this.aborted=!0,'function'==typeof this.onabort&&this.onabort.call(this,t)),super.dispatchEvent(t)}}function A(t){return t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill'),!0):'function'==typeof t.Request&&!t.Request.prototype.hasOwnProperty('signal')||!t.AbortController}'undefined'!=typeof Symbol&&Symbol.toStringTag&&(class{constructor(){Object.defineProperty(this,'signal',{value:new f,writable:!0,configurable:!0})}abort(){let t;try{t=new Event('abort')}catch(e){'undefined'!=typeof document?document.createEvent?(t=document.createEvent('Event'),t.initEvent('abort',!1,!1)):(t=document.createEventObject(),t.type='abort'):t={type:'abort',bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(t)}toString(){return'[object AbortController]'}}.prototype[Symbol.toStringTag]='AbortController',f.prototype[Symbol.toStringTag]='AbortSignal');const v=A({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),w=v?function(t){'function'==typeof t&&(t={fetch:t});const{fetch:e,Request:r=e.Request,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o=!1}=t;if(!A({fetch:e,Request:r,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:e,Request:i};let i=r;(i&&!i.prototype.hasOwnProperty('signal')||o)&&(i=function(t,e){let s;e&&e.signal&&(s=e.signal,delete e.signal);const o=new r(t,e);return s&&Object.defineProperty(o,'signal',{writable:!1,enumerable:!1,configurable:!0,value:s}),o},i.prototype=r.prototype);const n=e;return{fetch:(t,e)=>{const r=i&&i.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(r){let s;try{s=new DOMException('Aborted','AbortError')}catch(t){s=new Error('Aborted'),s.name='AbortError'}if(r.aborted)return Promise.reject(s);const o=new Promise(((t,e)=>{r.addEventListener('abort',(()=>e(s)),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([o,n(t,e)])}return n(t,e)},Request:i}}({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,b=v?w.fetch:window.fetch;v?w.Request:window.Request;class _{constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiEnv=t.apiEnv,this.apiBaseUrl=t.apiBaseUrl,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){var t;if(this.apiEnv!==i.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const e=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),r=await b(e,{method:'GET',mode:'cors',cache:'no-cache'}),s=await r.json(),o=null===(t=null==s?void 0:s.Answer[0])||void 0===t?void 0:t.data;if(!o)throw new Error('Wrong DNS response');return o}catch(t){return this.params.error$.next({id:'OneStat:ApiTransport:resolveApiBaseUrl',message:'Unhandled resolve api base url error',thrown:t}),d[i.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(t,e,r){if(!window.Blob||!window.navigator.sendBeacon)return!1;const s=this._prepareQueryParams({method:t,queryParams:e,sessionKey:r}),o=new window.Blob([s.toString()],{type:'application/x-www-form-urlencoded'});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,o)}catch(r){this.params.error$.next({id:'OneStat:ApiTransport:sendBeacon',message:'Unhandled beacon error',thrown:r,data:{method:t,params:e}})}return!1}async sendRequest(t,e,r){const s=Date.now(),o=o=>{o instanceof TypeError&&['Failed to fetch','NetworkError when attempting to fetch resource.'].includes(o.message)?this.params.error$.next({id:'Network',message:'Request failed',thrown:o}):this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:o,data:{method:t,params:e,sessionKey:r,time:Date.now()-s}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),b(`${this.apiBaseUrl}/fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:t,queryParams:e,sessionKey:r})}).then((t=>Number(t.headers.get('content-length'))>0?t.json().then((t=>Object.prototype.hasOwnProperty.call(t,'error_msg')?Promise.reject(t):t),o):void 0),o)}_prepareQueryParams(t){const e=new URLSearchParams({format:'JSON',method:t.method,application_key:this.apiKey});return void 0!==t.sessionKey&&e.append('session_key',t.sessionKey),Object.entries(t.queryParams).forEach((([t,r])=>e.append(t,'string'==typeof r?r:JSON.stringify(r)))),e}}class P{constructor(t){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=s((()=>{var t;try{this.flush()}catch(e){this.error$.next({id:'LoggerError',message:null!==(t=String(e))&&void 0!==t?t:'Unknown logger error',thrown:e})}}),3e3,{maxWait:15e3}),this.api=t.api,this.error$=t.error$}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[],this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}}class E{constructor(s,o){var i;this.subscription=new t,this.statContext=s,this.config={...null!==(i=o.config)&&void 0!==i?i:{},requestRetryCount:1};const n=new e;this.experimental={error$:n};const a=new _({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:d[o.apiEnv],apiEnv:o.apiEnv,error$:n});this.api=new g({apiTransport:a,refreshAuthToken:o.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:n}),this.logger=new P({api:this.api,error$:n}),this.subscription.add(r(window,'beforeunload').subscribe((()=>this.logger.flush(!0))))}updateContext(t){this.statContext={...this.statContext,...t}}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause()}resume(){this.logger.resume()}destroy(){this.logger.flush(),this.subscription.unsubscribe()}logStarted(){this.log({operation:'play'})}logPlay(){this.log({operation:'play_toggle'})}logPause(t){this.log({operation:'pause',param:String(Math.round(t.position))})}logSeek(){this.log({operation:'seek'})}logFirstBytes(t){this.log({operation:'first_bytes',param:String(t.time)})}logFirstFrame(t){this.log({operation:'first_frame',param:String(t.time)})}logError(t){this.log({operation:'error',param:t.errorType})}logWatchCoverageRecord(t){this.log({operation:'watch_coverage_record',param:`${t.start}-${t.end}`}),this.logger.flush(!0)}logWatchCoverageLive(t){this.log({operation:'watch_coverage_live',param:`${t.start}-${t.end}`}),this.logger.flush(!0)}logEmptyBuffer(t){this.log({operation:'empty_buffer',param:String(t.duration)})}logAdSlotRequest(){this.log({operation:'adv',param:'slot_request'})}logAdStarted(t){this.log({operation:'adv',param:t})}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(t){const e=this.crateLogItem(t);this.logger.log(e)}crateLogItem({operation:t,param:e}){const r=Date.now(),s={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:!0===this.statContext.connectionReused?c.YES:!1===this.statContext.connectionReused?c.NO:void 0,stat_type:!0===this.statContext.autoplay?l.AUTO:!1===this.statContext.autoplay?l.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId};return void 0!==e&&(s.param=e),{operation:t,timestamp:r,custom:s}}}export{i as ApiEnv,u as ConnectionType,h as ContentType,E as OneStat,n as Quality,a as ScreenDestination};
package/esnext.cjs.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @vkontakte/videoplayer-statistics v1.0.17
3
- * Tue, 28 Jun 2022 15:51:43 GMT
4
- * https://st.mycdn.me/static/playersdk/1-0-17/doc/
2
+ * @vkontakte/videoplayer-statistics v1.0.18
3
+ * Thu, 14 Jul 2022 10:36:11 GMT
4
+ * https://st.mycdn.me/static/playersdk/1-0-18/doc/
5
5
  */
6
- 'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var e=require('@vkontakte/videoplayer-shared/esnext.cjs.js');function t(e){return e&&'object'==typeof e&&'default'in e?e:{default:e}}var r=t(require('lodash/debounce'));const s=(()=>{try{const e=Date.now().toString(),t=window.localStorage;t.setItem(e,e);const r=t.getItem(e)===e;return t.removeItem(e),r?t:null}catch(e){return null}})();var o,i,n,a,h,p,u,l={get:e=>function(e){const t=s?s.getItem('_one-stat_'+e):null;if(null===t)return null;try{return JSON.parse(t)}catch(e){return null}}(e)||null,set(e,t){!function(e,t){try{s&&s.setItem('_one-stat_'+e,JSON.stringify(t))}catch(e){}}(e,t)},remove(e){!function(e){s&&s.removeItem('_one-stat_'+e)}(e)}};exports.ApiEnv=void 0,(o=exports.ApiEnv||(exports.ApiEnv={})).PROD='prod',o.VK_ALIAS='vk_alias',o.VIDEOTEST='videotest',o.TEST='test',o.AUTO='auto',exports.Quality=void 0,(i=exports.Quality||(exports.Quality={})).Q144P='144',i.Q240P='240',i.Q360P='360',i.Q480P='480',i.Q720P='720',i.Q1080P='1080',i.Q1440P='1440',i.Q2160P='2160',i.Q4320P='4320',i.UNKNOWN='unknown',exports.ScreenDestination=void 0,(n=exports.ScreenDestination||(exports.ScreenDestination={})).CHROMECAST='chromecast',n.APPLE_TV='appletv',n.PIP='pip',n.HEADPHONES='externalHeadphones',n.SCREEN='',exports.ContentType=void 0,(a=exports.ContentType||(exports.ContentType={})).MP4='mp4',a.DASH='dash',a.HLS='hls',a.WEBM='webm',function(e){e.AUTO='auto',e.MANUAL=''}(h||(h={})),exports.ConnectionType=void 0,(p=exports.ConnectionType||(exports.ConnectionType={})).HTTP1='http1',p.HTTP2='http2',p.HTTP3='http3',function(e){e[e.YES=1]='YES',e[e.NO=0]='NO'}(u||(u={}));const c={[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]:''};var d;!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'}(d||(d={}));class m{params;uuid;authToken;sessionKey;authorizePromise;refreshAuthTokenPromise;constructor(e){this.params=e;const t=l.get('uuid');t?this.uuid=String(t):(this.uuid=function(){const e='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),t=new Array(36);let r,s,o=0;for(s=0;s<36;s++)8===s||13===s||18===s||23===s?t[s]='-':14===s?t[s]='4':(o<=2&&(o=33554432+16777216*Math.random()|0),r=15&o,o>>=4,t[s]=e[19===s?3&r|8:r]);return t.join('')}(),l.set('uuid',this.uuid))}async authorize(e){return this.authToken=e??await this.refreshAuthToken(),this._authorize()}logBeacon(e){const t=this.createLogParams(e),r=this.sessionKey;void 0!==r&&this.params.apiTransport.sendBeacon('log.externalLog',t,r)||this.logRequest(e)}async logRequest(e){const t='log.externalLog',r=this.createLogParams(e),s=this.sessionKey??await this._authorize(),o=async(e,i=this.params.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(t,r,s)}catch(r){if(!r||!('error_code'in r))return void this.params.error$.next({id:'logRequestUnknown',message:`Unknown ${t} error`,thrown:r});const s=r?.error_code;switch(s){case d.PARAM_SESSION_EXPIRED:case d.PARAM_SESSION_KEY:case d.PARAM_SIGNATURE:return this.sessionKey=await this._authorize(),i>0?o(e,i-1):void 0;case d.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorize(0),i>0?o(e,i-1):void 0;default:return void this.params.error$.next({id:`LogRequest#${s}`,message:`${t} error`,data:r})}}};return o(e)}async refreshAuthToken(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=this.params.refreshAuthToken().finally((()=>{this.refreshAuthTokenPromise=void 0}))),this.refreshAuthTokenPromise}createLogParams(e){return{collector:'ok.mobile.apps.video',data:JSON.stringify({application:'@vkontakte/videoplayer-statistics:1.0.17',platform:'WEB',items:e.map((e=>({...e,time:0,type:1})))})}}async _authorize(e=this.params.requestRetryCount){try{return await this._authorizeRequest()}catch(t){const r=t?.error_code;switch(r){case d.AUTH_LOGIN:if(this.authToken=await this.refreshAuthToken(),e>0)return this._authorize(e-1)}r?this.params.error$.next({id:`Authorize#${r}`,message:'authorize error',data:t}):this.params.error$.next({id:'AuthorizeUnknown',message:'authorize error',thrown:t})}}async _authorizeRequest(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0;const e='auth.anonymLogin',t={session_data:{version:2,device_id:this.uuid,client_version:'1.0.17'.split('-')[0],client_type:'SDK_JS'}};return void 0!==this.authToken&&(t.session_data.auth_token=this.authToken,t.session_data.version=3),this.authorizePromise=this.params.apiTransport.sendRequest(e,t).then((r=>{if(r){if(r.session_key)return this.sessionKey=r.session_key,this.sessionKey;this.params.error$.next({id:'AuthorizeNoSessionKey',message:`No session key in ${e} response`,data:r})}else this.params.error$.next({id:'AuthorizeEmptyResponse',message:`Empty response for ${e}`,data:t})})).catch((e=>{throw this.sessionKey=void 0,e})).finally((()=>{this.authorizePromise=void 0})),this.authorizePromise}}class g{constructor(){Object.defineProperty(this,'listeners',{value:{},writable:!0,configurable:!0})}addEventListener(e,t,r){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:r})}removeEventListener(e,t){if(!(e in this.listeners))return;const r=this.listeners[e];for(let e=0,s=r.length;e<s;e++)if(r[e].callback===t)return void r.splice(e,1)}dispatchEvent(e){if(!(e.type in this.listeners))return;const t=this.listeners[e.type].slice();for(let r=0,s=t.length;r<s;r++){const s=t[r];try{s.callback.call(this,e)}catch(e){Promise.resolve().then((()=>{throw e}))}s.options&&s.options.once&&this.removeEventListener(e.type,s.callback)}return!e.defaultPrevented}}class y extends g{constructor(){super(),this.listeners||g.call(this),Object.defineProperty(this,'aborted',{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,'onabort',{value:null,writable:!0,configurable:!0})}toString(){return'[object AbortSignal]'}dispatchEvent(e){'abort'===e.type&&(this.aborted=!0,'function'==typeof this.onabort&&this.onabort.call(this,e)),super.dispatchEvent(e)}}function f(e){return e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill'),!0):'function'==typeof e.Request&&!e.Request.prototype.hasOwnProperty('signal')||!e.AbortController}'undefined'!=typeof Symbol&&Symbol.toStringTag&&(class{constructor(){Object.defineProperty(this,'signal',{value:new y,writable:!0,configurable:!0})}abort(){let e;try{e=new Event('abort')}catch(t){'undefined'!=typeof document?document.createEvent?(e=document.createEvent('Event'),e.initEvent('abort',!1,!1)):(e=document.createEventObject(),e.type='abort'):e={type:'abort',bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(e)}toString(){return'[object AbortController]'}}.prototype[Symbol.toStringTag]='AbortController',y.prototype[Symbol.toStringTag]='AbortSignal');const A=f({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),v=A?function(e){'function'==typeof e&&(e={fetch:e});const{fetch:t,Request:r=t.Request,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o=!1}=e;if(!f({fetch:t,Request:r,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:t,Request:i};let i=r;(i&&!i.prototype.hasOwnProperty('signal')||o)&&(i=function(e,t){let s;t&&t.signal&&(s=t.signal,delete t.signal);const o=new r(e,t);return s&&Object.defineProperty(o,'signal',{writable:!1,enumerable:!1,configurable:!0,value:s}),o},i.prototype=r.prototype);const n=t;return{fetch:(e,t)=>{const r=i&&i.prototype.isPrototypeOf(e)?e.signal:t?t.signal:void 0;if(r){let s;try{s=new DOMException('Aborted','AbortError')}catch(e){s=new Error('Aborted'),s.name='AbortError'}if(r.aborted)return Promise.reject(s);const o=new Promise(((e,t)=>{r.addEventListener('abort',(()=>t(s)),{once:!0})}));return t&&t.signal&&delete t.signal,Promise.race([o,n(e,t)])}return n(e,t)},Request:i}}({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,w=A?v.fetch:window.fetch;A?v.Request:window.Request;class _{apiKey;apiBaseUrl;apiEnv;isApiBaseUrlFetched;params;constructor(e){this.params=e,this.apiKey=e.apiKey,this.apiEnv=e.apiEnv,this.apiBaseUrl=e.apiBaseUrl,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){if(this.apiEnv!==exports.ApiEnv.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const e=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),t=await w(e,{method:'GET',mode:'cors',cache:'no-cache'}),r=(await t.json())?.Answer[0]?.data;if(!r)throw new Error('Wrong DNS response');return r}catch(e){return this.params.error$.next({id:'OneStat:ApiTransport:resolveApiBaseUrl',message:'Unhandled resolve api base url error',thrown:e}),c[exports.ApiEnv.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(e,t,r){if(!window.Blob||!window.navigator.sendBeacon)return!1;const s=this._prepareQueryParams({method:e,queryParams:t,sessionKey:r}),o=new window.Blob([s.toString()],{type:'application/x-www-form-urlencoded'});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,o)}catch(r){this.params.error$.next({id:'OneStat:ApiTransport:sendBeacon',message:'Unhandled beacon error',thrown:r,data:{method:e,params:t}})}return!1}async sendRequest(e,t,r){const s=Date.now(),o=o=>{o instanceof TypeError&&['Failed to fetch','NetworkError when attempting to fetch resource.'].includes(o.message)?this.params.error$.next({id:'Network',message:'Request failed',thrown:o}):this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:o,data:{method:e,params:t,sessionKey:r,time:Date.now()-s}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),w(`${this.apiBaseUrl}/fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:e,queryParams:t,sessionKey:r})}).then((e=>Number(e.headers.get('content-length'))>0?e.json().then((e=>Object.prototype.hasOwnProperty.call(e,'error_msg')?Promise.reject(e):e),o):void 0),o)}_prepareQueryParams(e){const t=new URLSearchParams({format:'JSON',method:e.method,application_key:this.apiKey});return void 0!==e.sessionKey&&t.append('session_key',e.sessionKey),Object.entries(e.queryParams).forEach((([e,r])=>t.append(e,'string'==typeof r?r:JSON.stringify(r)))),t}}class b{api;error$;requestQueue=[];isPaused=!1;debouncedFlush=r.default((()=>{try{this.flush()}catch(e){this.error$.next({id:'LoggerError',message:String(e)??'Unknown logger error',thrown:e})}}),3e3,{maxWait:15e3});constructor(e){this.api=e.api,this.error$=e.error$}log(e){this.requestQueue.push(e),this.isPaused||this.debouncedFlush()}flush(e=!1){0!==this.requestQueue.length&&(e?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[],this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}}exports.OneStat=class{api;logger;config;experimental;statContext;constructor(t,r){this.statContext=t,this.config={...r.config??{},requestRetryCount:1};const s=new e.Subject;this.experimental={error$:s};const o=new _({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:c[r.apiEnv],apiEnv:r.apiEnv,error$:s});this.api=new m({apiTransport:o,refreshAuthToken:r.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:s}),this.logger=new b({api:this.api,error$:s}),window.addEventListener('beforeunload',(()=>this.logger.flush(!0)))}updateContext(e){this.statContext={...this.statContext,...e}}authorize(e){return this.api.authorize(e)}pause(){this.logger.pause()}resume(){this.logger.resume()}logStarted(){this.log({operation:'play'})}logPlay(){this.log({operation:'play_toggle'})}logPause(e){this.log({operation:'pause',param:String(Math.round(e.position))})}logSeek(){this.log({operation:'seek'})}logFirstBytes(e){this.log({operation:'first_bytes',param:String(e.time)})}logFirstFrame(e){this.log({operation:'first_frame',param:String(e.time)})}logError(e){this.log({operation:'error',param:e.errorType})}logWatchCoverageRecord(e){this.log({operation:'watch_coverage_record',param:`${e.start}-${e.end}`}),this.logger.flush(!0)}logWatchCoverageLive(e){this.log({operation:'watch_coverage_live',param:`${e.start}-${e.end}`}),this.logger.flush(!0)}logEmptyBuffer(e){this.log({operation:'empty_buffer',param:String(e.duration)})}logAdSlotRequest(){this.log({operation:'adv',param:'slot_request'})}logAdStarted(e){this.log({operation:'adv',param:e})}logAdPaused(){this.log({operation:'adv',param:'pause'})}logAdResumed(){this.log({operation:'adv',param:'resume'})}logAdEnded(){this.log({operation:'adv',param:'ended'})}logAdSkipped(){this.log({operation:'adv',param:'skip'})}logAdClicked(){this.log({operation:'adv',param:'click'})}log(e){const t=this.crateLogItem(e);this.logger.log(t)}crateLogItem({operation:e,param:t}){const r=Date.now(),s={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:!0===this.statContext.connectionReused?u.YES:!1===this.statContext.connectionReused?u.NO:void 0,stat_type:!0===this.statContext.autoplay?h.AUTO:!1===this.statContext.autoplay?h.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId};return void 0!==t&&(s.param=t),{operation:e,timestamp:r,custom:s}}};
6
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var e=require('@vkontakte/videoplayer-shared/esnext.cjs.js');function t(e){return e&&'object'==typeof e&&'default'in e?e:{default:e}}var r=t(require('lodash/debounce'));const s=(()=>{try{const e=Date.now().toString(),t=window.localStorage;t.setItem(e,e);const r=t.getItem(e)===e;return t.removeItem(e),r?t:null}catch(e){return null}})();var o,i,n,a,h,u,p,l={get:e=>function(e){const t=s?s.getItem('_one-stat_'+e):null;if(null===t)return null;try{return JSON.parse(t)}catch(e){return null}}(e)||null,set(e,t){!function(e,t){try{s&&s.setItem('_one-stat_'+e,JSON.stringify(t))}catch(e){}}(e,t)},remove(e){!function(e){s&&s.removeItem('_one-stat_'+e)}(e)}};exports.ApiEnv=void 0,(o=exports.ApiEnv||(exports.ApiEnv={})).PROD='prod',o.VK_ALIAS='vk_alias',o.VIDEOTEST='videotest',o.TEST='test',o.AUTO='auto',exports.Quality=void 0,(i=exports.Quality||(exports.Quality={})).Q144P='144',i.Q240P='240',i.Q360P='360',i.Q480P='480',i.Q720P='720',i.Q1080P='1080',i.Q1440P='1440',i.Q2160P='2160',i.Q4320P='4320',i.UNKNOWN='unknown',exports.ScreenDestination=void 0,(n=exports.ScreenDestination||(exports.ScreenDestination={})).CHROMECAST='chromecast',n.APPLE_TV='appletv',n.PIP='pip',n.HEADPHONES='externalHeadphones',n.SCREEN='',exports.ContentType=void 0,(a=exports.ContentType||(exports.ContentType={})).MP4='mp4',a.DASH='dash',a.HLS='hls',a.WEBM='webm',function(e){e.AUTO='auto',e.MANUAL=''}(h||(h={})),exports.ConnectionType=void 0,(u=exports.ConnectionType||(exports.ConnectionType={})).HTTP1='http1',u.HTTP2='http2',u.HTTP3='http3',function(e){e[e.YES=1]='YES',e[e.NO=0]='NO'}(p||(p={}));const c={[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]:''};var d;!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'}(d||(d={}));class m{params;uuid;authToken;sessionKey;authorizePromise;refreshAuthTokenPromise;constructor(e){this.params=e;const t=l.get('uuid');t?this.uuid=String(t):(this.uuid=function(){const e='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),t=new Array(36);let r,s,o=0;for(s=0;s<36;s++)8===s||13===s||18===s||23===s?t[s]='-':14===s?t[s]='4':(o<=2&&(o=33554432+16777216*Math.random()|0),r=15&o,o>>=4,t[s]=e[19===s?3&r|8:r]);return t.join('')}(),l.set('uuid',this.uuid))}async authorize(e){return this.authToken=e??await this.refreshAuthToken(),this._authorize()}logBeacon(e){const t=this.createLogParams(e),r=this.sessionKey;if(!r)return;this.params.apiTransport.sendBeacon('log.externalLog',t,r)||this.logRequest(e)}async logRequest(e){const t='log.externalLog',r=this.createLogParams(e),s=this.sessionKey??await this._authorize();if(!s)return;const o=async(e,i=this.params.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(t,r,s)}catch(r){if(!r||!('error_code'in r))return void this.params.error$.next({id:'logRequestUnknown',message:`Unknown ${t} error`,thrown:r});const s=r?.error_code;switch(s){case d.PARAM_SESSION_EXPIRED:case d.PARAM_SESSION_KEY:case d.PARAM_SIGNATURE:return this.sessionKey=await this._authorize(),i>0?o(e,i-1):void 0;case d.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorize(0),i>0?o(e,i-1):void 0;default:return void this.params.error$.next({id:`LogRequest#${s}`,message:`${t} error`,data:r})}}};return o(e)}async refreshAuthToken(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=this.params.refreshAuthToken().finally((()=>{this.refreshAuthTokenPromise=void 0}))),this.refreshAuthTokenPromise}createLogParams(e){return{collector:'ok.mobile.apps.video',data:JSON.stringify({application:'@vkontakte/videoplayer-statistics:1.0.18',platform:'WEB',items:e.map((e=>({...e,time:0,type:1})))})}}async _authorize(e=this.params.requestRetryCount){try{return await this._authorizeRequest()}catch(t){const r=t?.error_code;switch(r){case d.AUTH_LOGIN:if(this.authToken=await this.refreshAuthToken(),e>0)return this._authorize(e-1)}r?this.params.error$.next({id:`Authorize#${r}`,message:'authorize error',data:t}):this.params.error$.next({id:'AuthorizeUnknown',message:'authorize error',thrown:t})}}async _authorizeRequest(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0;const e='auth.anonymLogin',t={session_data:{version:2,device_id:this.uuid,client_version:'1.0.18'.split('-')[0],client_type:'SDK_JS'}};return void 0!==this.authToken&&(t.session_data.auth_token=this.authToken,t.session_data.version=3),this.authorizePromise=this.params.apiTransport.sendRequest(e,t).then((r=>{if(r){if(r.session_key)return this.sessionKey=r.session_key,this.sessionKey;this.params.error$.next({id:'AuthorizeNoSessionKey',message:`No session key in ${e} response`,data:r})}else this.params.error$.next({id:'AuthorizeEmptyResponse',message:`Empty response for ${e}`,data:t})})).catch((e=>{throw this.sessionKey=void 0,e})).finally((()=>{this.authorizePromise=void 0})),this.authorizePromise}}class g{constructor(){Object.defineProperty(this,'listeners',{value:{},writable:!0,configurable:!0})}addEventListener(e,t,r){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:r})}removeEventListener(e,t){if(!(e in this.listeners))return;const r=this.listeners[e];for(let e=0,s=r.length;e<s;e++)if(r[e].callback===t)return void r.splice(e,1)}dispatchEvent(e){if(!(e.type in this.listeners))return;const t=this.listeners[e.type].slice();for(let r=0,s=t.length;r<s;r++){const s=t[r];try{s.callback.call(this,e)}catch(e){Promise.resolve().then((()=>{throw e}))}s.options&&s.options.once&&this.removeEventListener(e.type,s.callback)}return!e.defaultPrevented}}class y extends g{constructor(){super(),this.listeners||g.call(this),Object.defineProperty(this,'aborted',{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,'onabort',{value:null,writable:!0,configurable:!0})}toString(){return'[object AbortSignal]'}dispatchEvent(e){'abort'===e.type&&(this.aborted=!0,'function'==typeof this.onabort&&this.onabort.call(this,e)),super.dispatchEvent(e)}}function f(e){return e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill'),!0):'function'==typeof e.Request&&!e.Request.prototype.hasOwnProperty('signal')||!e.AbortController}'undefined'!=typeof Symbol&&Symbol.toStringTag&&(class{constructor(){Object.defineProperty(this,'signal',{value:new y,writable:!0,configurable:!0})}abort(){let e;try{e=new Event('abort')}catch(t){'undefined'!=typeof document?document.createEvent?(e=document.createEvent('Event'),e.initEvent('abort',!1,!1)):(e=document.createEventObject(),e.type='abort'):e={type:'abort',bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(e)}toString(){return'[object AbortController]'}}.prototype[Symbol.toStringTag]='AbortController',y.prototype[Symbol.toStringTag]='AbortSignal');const A=f({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),v=A?function(e){'function'==typeof e&&(e={fetch:e});const{fetch:t,Request:r=t.Request,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o=!1}=e;if(!f({fetch:t,Request:r,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:t,Request:i};let i=r;(i&&!i.prototype.hasOwnProperty('signal')||o)&&(i=function(e,t){let s;t&&t.signal&&(s=t.signal,delete t.signal);const o=new r(e,t);return s&&Object.defineProperty(o,'signal',{writable:!1,enumerable:!1,configurable:!0,value:s}),o},i.prototype=r.prototype);const n=t;return{fetch:(e,t)=>{const r=i&&i.prototype.isPrototypeOf(e)?e.signal:t?t.signal:void 0;if(r){let s;try{s=new DOMException('Aborted','AbortError')}catch(e){s=new Error('Aborted'),s.name='AbortError'}if(r.aborted)return Promise.reject(s);const o=new Promise(((e,t)=>{r.addEventListener('abort',(()=>t(s)),{once:!0})}));return t&&t.signal&&delete t.signal,Promise.race([o,n(e,t)])}return n(e,t)},Request:i}}({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,b=A?v.fetch:window.fetch;A?v.Request:window.Request;class w{apiKey;apiBaseUrl;apiEnv;isApiBaseUrlFetched;params;constructor(e){this.params=e,this.apiKey=e.apiKey,this.apiEnv=e.apiEnv,this.apiBaseUrl=e.apiBaseUrl,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){if(this.apiEnv!==exports.ApiEnv.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const e=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),t=await b(e,{method:'GET',mode:'cors',cache:'no-cache'}),r=(await t.json())?.Answer[0]?.data;if(!r)throw new Error('Wrong DNS response');return r}catch(e){return this.params.error$.next({id:'OneStat:ApiTransport:resolveApiBaseUrl',message:'Unhandled resolve api base url error',thrown:e}),c[exports.ApiEnv.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(e,t,r){if(!window.Blob||!window.navigator.sendBeacon)return!1;const s=this._prepareQueryParams({method:e,queryParams:t,sessionKey:r}),o=new window.Blob([s.toString()],{type:'application/x-www-form-urlencoded'});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,o)}catch(r){this.params.error$.next({id:'OneStat:ApiTransport:sendBeacon',message:'Unhandled beacon error',thrown:r,data:{method:e,params:t}})}return!1}async sendRequest(e,t,r){const s=Date.now(),o=o=>{o instanceof TypeError&&['Failed to fetch','NetworkError when attempting to fetch resource.'].includes(o.message)?this.params.error$.next({id:'Network',message:'Request failed',thrown:o}):this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:o,data:{method:e,params:t,sessionKey:r,time:Date.now()-s}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),b(`${this.apiBaseUrl}/fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:e,queryParams:t,sessionKey:r})}).then((e=>Number(e.headers.get('content-length'))>0?e.json().then((e=>Object.prototype.hasOwnProperty.call(e,'error_msg')?Promise.reject(e):e),o):void 0),o)}_prepareQueryParams(e){const t=new URLSearchParams({format:'JSON',method:e.method,application_key:this.apiKey});return void 0!==e.sessionKey&&t.append('session_key',e.sessionKey),Object.entries(e.queryParams).forEach((([e,r])=>t.append(e,'string'==typeof r?r:JSON.stringify(r)))),t}}class _{api;error$;requestQueue=[];isPaused=!1;debouncedFlush=r.default((()=>{try{this.flush()}catch(e){this.error$.next({id:'LoggerError',message:String(e)??'Unknown logger error',thrown:e})}}),3e3,{maxWait:15e3});constructor(e){this.api=e.api,this.error$=e.error$}log(e){this.requestQueue.push(e),this.isPaused||this.debouncedFlush()}flush(e=!1){0!==this.requestQueue.length&&(e?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[],this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}}exports.OneStat=class{api;logger;config;subscription=new e.Subscription;experimental;statContext;constructor(t,r){this.statContext=t,this.config={...r.config??{},requestRetryCount:1};const s=new e.Subject;this.experimental={error$:s};const o=new w({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:c[r.apiEnv],apiEnv:r.apiEnv,error$:s});this.api=new m({apiTransport:o,refreshAuthToken:r.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:s}),this.logger=new _({api:this.api,error$:s}),this.subscription.add(e.fromEvent(window,'beforeunload').subscribe((()=>this.logger.flush(!0))))}updateContext(e){this.statContext={...this.statContext,...e}}authorize(e){return this.api.authorize(e)}pause(){this.logger.pause()}resume(){this.logger.resume()}destroy(){this.logger.flush(),this.subscription.unsubscribe()}logStarted(){this.log({operation:'play'})}logPlay(){this.log({operation:'play_toggle'})}logPause(e){this.log({operation:'pause',param:String(Math.round(e.position))})}logSeek(){this.log({operation:'seek'})}logFirstBytes(e){this.log({operation:'first_bytes',param:String(e.time)})}logFirstFrame(e){this.log({operation:'first_frame',param:String(e.time)})}logError(e){this.log({operation:'error',param:e.errorType})}logWatchCoverageRecord(e){this.log({operation:'watch_coverage_record',param:`${e.start}-${e.end}`}),this.logger.flush(!0)}logWatchCoverageLive(e){this.log({operation:'watch_coverage_live',param:`${e.start}-${e.end}`}),this.logger.flush(!0)}logEmptyBuffer(e){this.log({operation:'empty_buffer',param:String(e.duration)})}logAdSlotRequest(){this.log({operation:'adv',param:'slot_request'})}logAdStarted(e){this.log({operation:'adv',param:e})}logAdPaused(){this.log({operation:'adv',param:'pause'})}logAdResumed(){this.log({operation:'adv',param:'resume'})}logAdEnded(){this.log({operation:'adv',param:'ended'})}logAdSkipped(){this.log({operation:'adv',param:'skip'})}logAdClicked(){this.log({operation:'adv',param:'click'})}log(e){const t=this.crateLogItem(e);this.logger.log(t)}crateLogItem({operation:e,param:t}){const r=Date.now(),s={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:!0===this.statContext.connectionReused?p.YES:!1===this.statContext.connectionReused?p.NO:void 0,stat_type:!0===this.statContext.autoplay?h.AUTO:!1===this.statContext.autoplay?h.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId};return void 0!==t&&(s.param=t),{operation:e,timestamp:r,custom:s}}};
package/esnext.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @vkontakte/videoplayer-statistics v1.0.17
3
- * Tue, 28 Jun 2022 15:51:43 GMT
4
- * https://st.mycdn.me/static/playersdk/1-0-17/doc/
2
+ * @vkontakte/videoplayer-statistics v1.0.18
3
+ * Thu, 14 Jul 2022 10:36:11 GMT
4
+ * https://st.mycdn.me/static/playersdk/1-0-18/doc/
5
5
  */
6
- import{Subject as e}from'@vkontakte/videoplayer-shared/esnext.esm.js';import t from'lodash/debounce';const r=(()=>{try{const e=Date.now().toString(),t=window.localStorage;t.setItem(e,e);const r=t.getItem(e)===e;return t.removeItem(e),r?t:null}catch(e){return null}})();var s,o,i,a,n,h,l,u={get:e=>function(e){const t=r?r.getItem('_one-stat_'+e):null;if(null===t)return null;try{return JSON.parse(t)}catch(e){return null}}(e)||null,set(e,t){!function(e,t){try{r&&r.setItem('_one-stat_'+e,JSON.stringify(t))}catch(e){}}(e,t)},remove(e){!function(e){r&&r.removeItem('_one-stat_'+e)}(e)}};!function(e){e.PROD='prod',e.VK_ALIAS='vk_alias',e.VIDEOTEST='videotest',e.TEST='test',e.AUTO='auto'}(s||(s={})),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'}(o||(o={})),function(e){e.CHROMECAST='chromecast',e.APPLE_TV='appletv',e.PIP='pip',e.HEADPHONES='externalHeadphones',e.SCREEN=''}(i||(i={})),function(e){e.MP4='mp4',e.DASH='dash',e.HLS='hls',e.WEBM='webm'}(a||(a={})),function(e){e.AUTO='auto',e.MANUAL=''}(n||(n={})),function(e){e.HTTP1='http1',e.HTTP2='http2',e.HTTP3='http3'}(h||(h={})),function(e){e[e.YES=1]='YES',e[e.NO=0]='NO'}(l||(l={}));const c={[s.PROD]:'https://api.ok.ru',[s.VK_ALIAS]:'https://api.mycdn.me',[s.VIDEOTEST]:'https://videotestapi.ok.ru/api',[s.TEST]:'https://apitest.ok.ru',[s.AUTO]:''};var p;!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'}(p||(p={}));class d{params;uuid;authToken;sessionKey;authorizePromise;refreshAuthTokenPromise;constructor(e){this.params=e;const t=u.get('uuid');t?this.uuid=String(t):(this.uuid=function(){const e='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),t=new Array(36);let r,s,o=0;for(s=0;s<36;s++)8===s||13===s||18===s||23===s?t[s]='-':14===s?t[s]='4':(o<=2&&(o=33554432+16777216*Math.random()|0),r=15&o,o>>=4,t[s]=e[19===s?3&r|8:r]);return t.join('')}(),u.set('uuid',this.uuid))}async authorize(e){return this.authToken=e??await this.refreshAuthToken(),this._authorize()}logBeacon(e){const t=this.createLogParams(e),r=this.sessionKey;void 0!==r&&this.params.apiTransport.sendBeacon('log.externalLog',t,r)||this.logRequest(e)}async logRequest(e){const t='log.externalLog',r=this.createLogParams(e),s=this.sessionKey??await this._authorize(),o=async(e,i=this.params.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(t,r,s)}catch(r){if(!r||!('error_code'in r))return void this.params.error$.next({id:'logRequestUnknown',message:`Unknown ${t} error`,thrown:r});const s=r?.error_code;switch(s){case p.PARAM_SESSION_EXPIRED:case p.PARAM_SESSION_KEY:case p.PARAM_SIGNATURE:return this.sessionKey=await this._authorize(),i>0?o(e,i-1):void 0;case p.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorize(0),i>0?o(e,i-1):void 0;default:return void this.params.error$.next({id:`LogRequest#${s}`,message:`${t} error`,data:r})}}};return o(e)}async refreshAuthToken(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=this.params.refreshAuthToken().finally((()=>{this.refreshAuthTokenPromise=void 0}))),this.refreshAuthTokenPromise}createLogParams(e){return{collector:'ok.mobile.apps.video',data:JSON.stringify({application:'@vkontakte/videoplayer-statistics:1.0.17',platform:'WEB',items:e.map((e=>({...e,time:0,type:1})))})}}async _authorize(e=this.params.requestRetryCount){try{return await this._authorizeRequest()}catch(t){const r=t?.error_code;switch(r){case p.AUTH_LOGIN:if(this.authToken=await this.refreshAuthToken(),e>0)return this._authorize(e-1)}r?this.params.error$.next({id:`Authorize#${r}`,message:'authorize error',data:t}):this.params.error$.next({id:'AuthorizeUnknown',message:'authorize error',thrown:t})}}async _authorizeRequest(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0;const e='auth.anonymLogin',t={session_data:{version:2,device_id:this.uuid,client_version:'1.0.17'.split('-')[0],client_type:'SDK_JS'}};return void 0!==this.authToken&&(t.session_data.auth_token=this.authToken,t.session_data.version=3),this.authorizePromise=this.params.apiTransport.sendRequest(e,t).then((r=>{if(r){if(r.session_key)return this.sessionKey=r.session_key,this.sessionKey;this.params.error$.next({id:'AuthorizeNoSessionKey',message:`No session key in ${e} response`,data:r})}else this.params.error$.next({id:'AuthorizeEmptyResponse',message:`Empty response for ${e}`,data:t})})).catch((e=>{throw this.sessionKey=void 0,e})).finally((()=>{this.authorizePromise=void 0})),this.authorizePromise}}class m{constructor(){Object.defineProperty(this,'listeners',{value:{},writable:!0,configurable:!0})}addEventListener(e,t,r){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:r})}removeEventListener(e,t){if(!(e in this.listeners))return;const r=this.listeners[e];for(let e=0,s=r.length;e<s;e++)if(r[e].callback===t)return void r.splice(e,1)}dispatchEvent(e){if(!(e.type in this.listeners))return;const t=this.listeners[e.type].slice();for(let r=0,s=t.length;r<s;r++){const s=t[r];try{s.callback.call(this,e)}catch(e){Promise.resolve().then((()=>{throw e}))}s.options&&s.options.once&&this.removeEventListener(e.type,s.callback)}return!e.defaultPrevented}}class g extends m{constructor(){super(),this.listeners||m.call(this),Object.defineProperty(this,'aborted',{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,'onabort',{value:null,writable:!0,configurable:!0})}toString(){return'[object AbortSignal]'}dispatchEvent(e){'abort'===e.type&&(this.aborted=!0,'function'==typeof this.onabort&&this.onabort.call(this,e)),super.dispatchEvent(e)}}function y(e){return e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill'),!0):'function'==typeof e.Request&&!e.Request.prototype.hasOwnProperty('signal')||!e.AbortController}'undefined'!=typeof Symbol&&Symbol.toStringTag&&(class{constructor(){Object.defineProperty(this,'signal',{value:new g,writable:!0,configurable:!0})}abort(){let e;try{e=new Event('abort')}catch(t){'undefined'!=typeof document?document.createEvent?(e=document.createEvent('Event'),e.initEvent('abort',!1,!1)):(e=document.createEventObject(),e.type='abort'):e={type:'abort',bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(e)}toString(){return'[object AbortController]'}}.prototype[Symbol.toStringTag]='AbortController',g.prototype[Symbol.toStringTag]='AbortSignal');const f=y({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),A=f?function(e){'function'==typeof e&&(e={fetch:e});const{fetch:t,Request:r=t.Request,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o=!1}=e;if(!y({fetch:t,Request:r,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:t,Request:i};let i=r;(i&&!i.prototype.hasOwnProperty('signal')||o)&&(i=function(e,t){let s;t&&t.signal&&(s=t.signal,delete t.signal);const o=new r(e,t);return s&&Object.defineProperty(o,'signal',{writable:!1,enumerable:!1,configurable:!0,value:s}),o},i.prototype=r.prototype);const a=t;return{fetch:(e,t)=>{const r=i&&i.prototype.isPrototypeOf(e)?e.signal:t?t.signal:void 0;if(r){let s;try{s=new DOMException('Aborted','AbortError')}catch(e){s=new Error('Aborted'),s.name='AbortError'}if(r.aborted)return Promise.reject(s);const o=new Promise(((e,t)=>{r.addEventListener('abort',(()=>t(s)),{once:!0})}));return t&&t.signal&&delete t.signal,Promise.race([o,a(e,t)])}return a(e,t)},Request:i}}({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,w=f?A.fetch:window.fetch;f?A.Request:window.Request;class v{apiKey;apiBaseUrl;apiEnv;isApiBaseUrlFetched;params;constructor(e){this.params=e,this.apiKey=e.apiKey,this.apiEnv=e.apiEnv,this.apiBaseUrl=e.apiBaseUrl,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){if(this.apiEnv!==s.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const e=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),t=await w(e,{method:'GET',mode:'cors',cache:'no-cache'}),r=(await t.json())?.Answer[0]?.data;if(!r)throw new Error('Wrong DNS response');return r}catch(e){return this.params.error$.next({id:'OneStat:ApiTransport:resolveApiBaseUrl',message:'Unhandled resolve api base url error',thrown:e}),c[s.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(e,t,r){if(!window.Blob||!window.navigator.sendBeacon)return!1;const s=this._prepareQueryParams({method:e,queryParams:t,sessionKey:r}),o=new window.Blob([s.toString()],{type:'application/x-www-form-urlencoded'});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,o)}catch(r){this.params.error$.next({id:'OneStat:ApiTransport:sendBeacon',message:'Unhandled beacon error',thrown:r,data:{method:e,params:t}})}return!1}async sendRequest(e,t,r){const s=Date.now(),o=o=>{o instanceof TypeError&&['Failed to fetch','NetworkError when attempting to fetch resource.'].includes(o.message)?this.params.error$.next({id:'Network',message:'Request failed',thrown:o}):this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:o,data:{method:e,params:t,sessionKey:r,time:Date.now()-s}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),w(`${this.apiBaseUrl}/fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:e,queryParams:t,sessionKey:r})}).then((e=>Number(e.headers.get('content-length'))>0?e.json().then((e=>Object.prototype.hasOwnProperty.call(e,'error_msg')?Promise.reject(e):e),o):void 0),o)}_prepareQueryParams(e){const t=new URLSearchParams({format:'JSON',method:e.method,application_key:this.apiKey});return void 0!==e.sessionKey&&t.append('session_key',e.sessionKey),Object.entries(e.queryParams).forEach((([e,r])=>t.append(e,'string'==typeof r?r:JSON.stringify(r)))),t}}class _{api;error$;requestQueue=[];isPaused=!1;debouncedFlush=t((()=>{try{this.flush()}catch(e){this.error$.next({id:'LoggerError',message:String(e)??'Unknown logger error',thrown:e})}}),3e3,{maxWait:15e3});constructor(e){this.api=e.api,this.error$=e.error$}log(e){this.requestQueue.push(e),this.isPaused||this.debouncedFlush()}flush(e=!1){0!==this.requestQueue.length&&(e?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[],this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}}class b{api;logger;config;experimental;statContext;constructor(t,r){this.statContext=t,this.config={...r.config??{},requestRetryCount:1};const s=new e;this.experimental={error$:s};const o=new v({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:c[r.apiEnv],apiEnv:r.apiEnv,error$:s});this.api=new d({apiTransport:o,refreshAuthToken:r.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:s}),this.logger=new _({api:this.api,error$:s}),window.addEventListener('beforeunload',(()=>this.logger.flush(!0)))}updateContext(e){this.statContext={...this.statContext,...e}}authorize(e){return this.api.authorize(e)}pause(){this.logger.pause()}resume(){this.logger.resume()}logStarted(){this.log({operation:'play'})}logPlay(){this.log({operation:'play_toggle'})}logPause(e){this.log({operation:'pause',param:String(Math.round(e.position))})}logSeek(){this.log({operation:'seek'})}logFirstBytes(e){this.log({operation:'first_bytes',param:String(e.time)})}logFirstFrame(e){this.log({operation:'first_frame',param:String(e.time)})}logError(e){this.log({operation:'error',param:e.errorType})}logWatchCoverageRecord(e){this.log({operation:'watch_coverage_record',param:`${e.start}-${e.end}`}),this.logger.flush(!0)}logWatchCoverageLive(e){this.log({operation:'watch_coverage_live',param:`${e.start}-${e.end}`}),this.logger.flush(!0)}logEmptyBuffer(e){this.log({operation:'empty_buffer',param:String(e.duration)})}logAdSlotRequest(){this.log({operation:'adv',param:'slot_request'})}logAdStarted(e){this.log({operation:'adv',param:e})}logAdPaused(){this.log({operation:'adv',param:'pause'})}logAdResumed(){this.log({operation:'adv',param:'resume'})}logAdEnded(){this.log({operation:'adv',param:'ended'})}logAdSkipped(){this.log({operation:'adv',param:'skip'})}logAdClicked(){this.log({operation:'adv',param:'click'})}log(e){const t=this.crateLogItem(e);this.logger.log(t)}crateLogItem({operation:e,param:t}){const r=Date.now(),s={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:!0===this.statContext.connectionReused?l.YES:!1===this.statContext.connectionReused?l.NO:void 0,stat_type:!0===this.statContext.autoplay?n.AUTO:!1===this.statContext.autoplay?n.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId};return void 0!==t&&(s.param=t),{operation:e,timestamp:r,custom:s}}}export{s as ApiEnv,h as ConnectionType,a as ContentType,b as OneStat,o as Quality,i as ScreenDestination};
6
+ import{Subscription as e,Subject as t,fromEvent as r}from'@vkontakte/videoplayer-shared/esnext.esm.js';import s from'lodash/debounce';const o=(()=>{try{const e=Date.now().toString(),t=window.localStorage;t.setItem(e,e);const r=t.getItem(e)===e;return t.removeItem(e),r?t:null}catch(e){return null}})();var i,n,a,h,u,l,c,p={get:e=>function(e){const t=o?o.getItem('_one-stat_'+e):null;if(null===t)return null;try{return JSON.parse(t)}catch(e){return null}}(e)||null,set(e,t){!function(e,t){try{o&&o.setItem('_one-stat_'+e,JSON.stringify(t))}catch(e){}}(e,t)},remove(e){!function(e){o&&o.removeItem('_one-stat_'+e)}(e)}};!function(e){e.PROD='prod',e.VK_ALIAS='vk_alias',e.VIDEOTEST='videotest',e.TEST='test',e.AUTO='auto'}(i||(i={})),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'}(n||(n={})),function(e){e.CHROMECAST='chromecast',e.APPLE_TV='appletv',e.PIP='pip',e.HEADPHONES='externalHeadphones',e.SCREEN=''}(a||(a={})),function(e){e.MP4='mp4',e.DASH='dash',e.HLS='hls',e.WEBM='webm'}(h||(h={})),function(e){e.AUTO='auto',e.MANUAL=''}(u||(u={})),function(e){e.HTTP1='http1',e.HTTP2='http2',e.HTTP3='http3'}(l||(l={})),function(e){e[e.YES=1]='YES',e[e.NO=0]='NO'}(c||(c={}));const d={[i.PROD]:'https://api.ok.ru',[i.VK_ALIAS]:'https://api.mycdn.me',[i.VIDEOTEST]:'https://videotestapi.ok.ru/api',[i.TEST]:'https://apitest.ok.ru',[i.AUTO]:''};var m;!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'}(m||(m={}));class g{params;uuid;authToken;sessionKey;authorizePromise;refreshAuthTokenPromise;constructor(e){this.params=e;const t=p.get('uuid');t?this.uuid=String(t):(this.uuid=function(){const e='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),t=new Array(36);let r,s,o=0;for(s=0;s<36;s++)8===s||13===s||18===s||23===s?t[s]='-':14===s?t[s]='4':(o<=2&&(o=33554432+16777216*Math.random()|0),r=15&o,o>>=4,t[s]=e[19===s?3&r|8:r]);return t.join('')}(),p.set('uuid',this.uuid))}async authorize(e){return this.authToken=e??await this.refreshAuthToken(),this._authorize()}logBeacon(e){const t=this.createLogParams(e),r=this.sessionKey;if(!r)return;this.params.apiTransport.sendBeacon('log.externalLog',t,r)||this.logRequest(e)}async logRequest(e){const t='log.externalLog',r=this.createLogParams(e),s=this.sessionKey??await this._authorize();if(!s)return;const o=async(e,i=this.params.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(t,r,s)}catch(r){if(!r||!('error_code'in r))return void this.params.error$.next({id:'logRequestUnknown',message:`Unknown ${t} error`,thrown:r});const s=r?.error_code;switch(s){case m.PARAM_SESSION_EXPIRED:case m.PARAM_SESSION_KEY:case m.PARAM_SIGNATURE:return this.sessionKey=await this._authorize(),i>0?o(e,i-1):void 0;case m.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorize(0),i>0?o(e,i-1):void 0;default:return void this.params.error$.next({id:`LogRequest#${s}`,message:`${t} error`,data:r})}}};return o(e)}async refreshAuthToken(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=this.params.refreshAuthToken().finally((()=>{this.refreshAuthTokenPromise=void 0}))),this.refreshAuthTokenPromise}createLogParams(e){return{collector:'ok.mobile.apps.video',data:JSON.stringify({application:'@vkontakte/videoplayer-statistics:1.0.18',platform:'WEB',items:e.map((e=>({...e,time:0,type:1})))})}}async _authorize(e=this.params.requestRetryCount){try{return await this._authorizeRequest()}catch(t){const r=t?.error_code;switch(r){case m.AUTH_LOGIN:if(this.authToken=await this.refreshAuthToken(),e>0)return this._authorize(e-1)}r?this.params.error$.next({id:`Authorize#${r}`,message:'authorize error',data:t}):this.params.error$.next({id:'AuthorizeUnknown',message:'authorize error',thrown:t})}}async _authorizeRequest(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0;const e='auth.anonymLogin',t={session_data:{version:2,device_id:this.uuid,client_version:'1.0.18'.split('-')[0],client_type:'SDK_JS'}};return void 0!==this.authToken&&(t.session_data.auth_token=this.authToken,t.session_data.version=3),this.authorizePromise=this.params.apiTransport.sendRequest(e,t).then((r=>{if(r){if(r.session_key)return this.sessionKey=r.session_key,this.sessionKey;this.params.error$.next({id:'AuthorizeNoSessionKey',message:`No session key in ${e} response`,data:r})}else this.params.error$.next({id:'AuthorizeEmptyResponse',message:`Empty response for ${e}`,data:t})})).catch((e=>{throw this.sessionKey=void 0,e})).finally((()=>{this.authorizePromise=void 0})),this.authorizePromise}}class y{constructor(){Object.defineProperty(this,'listeners',{value:{},writable:!0,configurable:!0})}addEventListener(e,t,r){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:r})}removeEventListener(e,t){if(!(e in this.listeners))return;const r=this.listeners[e];for(let e=0,s=r.length;e<s;e++)if(r[e].callback===t)return void r.splice(e,1)}dispatchEvent(e){if(!(e.type in this.listeners))return;const t=this.listeners[e.type].slice();for(let r=0,s=t.length;r<s;r++){const s=t[r];try{s.callback.call(this,e)}catch(e){Promise.resolve().then((()=>{throw e}))}s.options&&s.options.once&&this.removeEventListener(e.type,s.callback)}return!e.defaultPrevented}}class f extends y{constructor(){super(),this.listeners||y.call(this),Object.defineProperty(this,'aborted',{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,'onabort',{value:null,writable:!0,configurable:!0})}toString(){return'[object AbortSignal]'}dispatchEvent(e){'abort'===e.type&&(this.aborted=!0,'function'==typeof this.onabort&&this.onabort.call(this,e)),super.dispatchEvent(e)}}function A(e){return e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill'),!0):'function'==typeof e.Request&&!e.Request.prototype.hasOwnProperty('signal')||!e.AbortController}'undefined'!=typeof Symbol&&Symbol.toStringTag&&(class{constructor(){Object.defineProperty(this,'signal',{value:new f,writable:!0,configurable:!0})}abort(){let e;try{e=new Event('abort')}catch(t){'undefined'!=typeof document?document.createEvent?(e=document.createEvent('Event'),e.initEvent('abort',!1,!1)):(e=document.createEventObject(),e.type='abort'):e={type:'abort',bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(e)}toString(){return'[object AbortController]'}}.prototype[Symbol.toStringTag]='AbortController',f.prototype[Symbol.toStringTag]='AbortSignal');const w=A({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),b=w?function(e){'function'==typeof e&&(e={fetch:e});const{fetch:t,Request:r=t.Request,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o=!1}=e;if(!A({fetch:t,Request:r,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:t,Request:i};let i=r;(i&&!i.prototype.hasOwnProperty('signal')||o)&&(i=function(e,t){let s;t&&t.signal&&(s=t.signal,delete t.signal);const o=new r(e,t);return s&&Object.defineProperty(o,'signal',{writable:!1,enumerable:!1,configurable:!0,value:s}),o},i.prototype=r.prototype);const n=t;return{fetch:(e,t)=>{const r=i&&i.prototype.isPrototypeOf(e)?e.signal:t?t.signal:void 0;if(r){let s;try{s=new DOMException('Aborted','AbortError')}catch(e){s=new Error('Aborted'),s.name='AbortError'}if(r.aborted)return Promise.reject(s);const o=new Promise(((e,t)=>{r.addEventListener('abort',(()=>t(s)),{once:!0})}));return t&&t.signal&&delete t.signal,Promise.race([o,n(e,t)])}return n(e,t)},Request:i}}({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,_=w?b.fetch:window.fetch;w?b.Request:window.Request;class v{apiKey;apiBaseUrl;apiEnv;isApiBaseUrlFetched;params;constructor(e){this.params=e,this.apiKey=e.apiKey,this.apiEnv=e.apiEnv,this.apiBaseUrl=e.apiBaseUrl,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){if(this.apiEnv!==i.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const e=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),t=await _(e,{method:'GET',mode:'cors',cache:'no-cache'}),r=(await t.json())?.Answer[0]?.data;if(!r)throw new Error('Wrong DNS response');return r}catch(e){return this.params.error$.next({id:'OneStat:ApiTransport:resolveApiBaseUrl',message:'Unhandled resolve api base url error',thrown:e}),d[i.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(e,t,r){if(!window.Blob||!window.navigator.sendBeacon)return!1;const s=this._prepareQueryParams({method:e,queryParams:t,sessionKey:r}),o=new window.Blob([s.toString()],{type:'application/x-www-form-urlencoded'});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,o)}catch(r){this.params.error$.next({id:'OneStat:ApiTransport:sendBeacon',message:'Unhandled beacon error',thrown:r,data:{method:e,params:t}})}return!1}async sendRequest(e,t,r){const s=Date.now(),o=o=>{o instanceof TypeError&&['Failed to fetch','NetworkError when attempting to fetch resource.'].includes(o.message)?this.params.error$.next({id:'Network',message:'Request failed',thrown:o}):this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:o,data:{method:e,params:t,sessionKey:r,time:Date.now()-s}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),_(`${this.apiBaseUrl}/fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:e,queryParams:t,sessionKey:r})}).then((e=>Number(e.headers.get('content-length'))>0?e.json().then((e=>Object.prototype.hasOwnProperty.call(e,'error_msg')?Promise.reject(e):e),o):void 0),o)}_prepareQueryParams(e){const t=new URLSearchParams({format:'JSON',method:e.method,application_key:this.apiKey});return void 0!==e.sessionKey&&t.append('session_key',e.sessionKey),Object.entries(e.queryParams).forEach((([e,r])=>t.append(e,'string'==typeof r?r:JSON.stringify(r)))),t}}class P{api;error$;requestQueue=[];isPaused=!1;debouncedFlush=s((()=>{try{this.flush()}catch(e){this.error$.next({id:'LoggerError',message:String(e)??'Unknown logger error',thrown:e})}}),3e3,{maxWait:15e3});constructor(e){this.api=e.api,this.error$=e.error$}log(e){this.requestQueue.push(e),this.isPaused||this.debouncedFlush()}flush(e=!1){0!==this.requestQueue.length&&(e?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[],this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}}class E{api;logger;config;subscription=new e;experimental;statContext;constructor(e,s){this.statContext=e,this.config={...s.config??{},requestRetryCount:1};const o=new t;this.experimental={error$:o};const i=new v({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:d[s.apiEnv],apiEnv:s.apiEnv,error$:o});this.api=new g({apiTransport:i,refreshAuthToken:s.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:o}),this.logger=new P({api:this.api,error$:o}),this.subscription.add(r(window,'beforeunload').subscribe((()=>this.logger.flush(!0))))}updateContext(e){this.statContext={...this.statContext,...e}}authorize(e){return this.api.authorize(e)}pause(){this.logger.pause()}resume(){this.logger.resume()}destroy(){this.logger.flush(),this.subscription.unsubscribe()}logStarted(){this.log({operation:'play'})}logPlay(){this.log({operation:'play_toggle'})}logPause(e){this.log({operation:'pause',param:String(Math.round(e.position))})}logSeek(){this.log({operation:'seek'})}logFirstBytes(e){this.log({operation:'first_bytes',param:String(e.time)})}logFirstFrame(e){this.log({operation:'first_frame',param:String(e.time)})}logError(e){this.log({operation:'error',param:e.errorType})}logWatchCoverageRecord(e){this.log({operation:'watch_coverage_record',param:`${e.start}-${e.end}`}),this.logger.flush(!0)}logWatchCoverageLive(e){this.log({operation:'watch_coverage_live',param:`${e.start}-${e.end}`}),this.logger.flush(!0)}logEmptyBuffer(e){this.log({operation:'empty_buffer',param:String(e.duration)})}logAdSlotRequest(){this.log({operation:'adv',param:'slot_request'})}logAdStarted(e){this.log({operation:'adv',param:e})}logAdPaused(){this.log({operation:'adv',param:'pause'})}logAdResumed(){this.log({operation:'adv',param:'resume'})}logAdEnded(){this.log({operation:'adv',param:'ended'})}logAdSkipped(){this.log({operation:'adv',param:'skip'})}logAdClicked(){this.log({operation:'adv',param:'click'})}log(e){const t=this.crateLogItem(e);this.logger.log(t)}crateLogItem({operation:e,param:t}){const r=Date.now(),s={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:!0===this.statContext.connectionReused?c.YES:!1===this.statContext.connectionReused?c.NO:void 0,stat_type:!0===this.statContext.autoplay?u.AUTO:!1===this.statContext.autoplay?u.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId};return void 0!==t&&(s.param=t),{operation:e,timestamp:r,custom:s}}}export{i as ApiEnv,l as ConnectionType,h as ContentType,E as OneStat,n as Quality,a as ScreenDestination};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vkontakte/videoplayer-statistics",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "author": "vk.com",
5
5
  "description": "Statistics library for vk.com videoplayer",
6
6
  "homepage": "https://vk.com",
@@ -14,7 +14,7 @@
14
14
  "**/*.d.ts"
15
15
  ],
16
16
  "dependencies": {
17
- "@vkontakte/videoplayer-shared": "^1.0.12",
17
+ "@vkontakte/videoplayer-shared": "^1.0.13",
18
18
  "lodash": "4.17.21"
19
19
  }
20
20
  }