@vkontakte/videoplayer-statistics 1.0.19 → 1.0.20
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/Api.d.ts +1 -0
- package/OneStat.d.ts +1 -0
- package/es2015.cjs.js +4 -4
- package/es2015.esm.js +4 -4
- package/es2018.cjs.js +4 -4
- package/es2018.esm.js +4 -4
- package/esnext.cjs.js +4 -4
- package/esnext.esm.js +4 -4
- package/package.json +2 -2
- package/types.d.ts +3 -0
package/Api.d.ts
CHANGED
package/OneStat.d.ts
CHANGED
package/es2015.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-statistics v1.0.
|
|
3
|
-
* Tue,
|
|
4
|
-
* https://st.mycdn.me/static/playersdk/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-statistics v1.0.20
|
|
3
|
+
* Tue, 09 Aug 2022 12:30:38 GMT
|
|
4
|
+
* https://st.mycdn.me/static/playersdk/1-0-20/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,h=Function.prototype,l=h.apply,f=h.call,p='object'==typeof Reflect&&Reflect.apply||(c?f.bind(l):function(){return f.apply(l,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,T=Function.prototype.call,_=S?T.bind(T):function(){return T.apply(T,arguments)},O={},P={}.propertyIsEnumerable,x=Object.getOwnPropertyDescriptor,j=x&&!P.call({1:2},1);O.f=j?function(t){var e=x(this,t);return!!e&&e.enumerable}:P;var k,R,L=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},C=b,I=C({}.toString),q=C(''.slice),N=function(t){return q(I(t),8,-1)},U=b,z=a,B=N,M=s.Object,F=U(''.split),$=z((function(){return!M('z').propertyIsEnumerable(0)}))?function(t){return'String'==B(t)?F(t,''):M(t)}:M,D=s.TypeError,K=function(t){if(null==t)throw D('Can\'t call method on '+t);return t},Q=$,H=K,W=w,G=function(t){return'object'==typeof t?null!==t:W(t)},Y={},V=Y,J=s,Z=w,X=function(t){return Z(t)?t:void 0},tt=function(t,e){return arguments.length<2?X(V[t])||X(J[t]):V[t]&&V[t][e]||J[t]&&J[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&&(R=(k=ut.split('.'))[0]>0&&k[0]<4?1:+(k[0]+k[1])),!R&&ot&&(!(k=ot.match(/Edge\/(\d+)/))||k[1]>=74)&&(k=ot.match(/Chrome\/(\d+)/))&&(R=+k[1]);var ct=R,ht=ct,lt=a,ft=!!Object.getOwnPropertySymbols&&!lt((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&ht&&ht<41})),pt=ft&&!Symbol.sham&&'symbol'==typeof Symbol.iterator,dt=tt,vt=w,yt=et,mt=pt,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,Tt=s.TypeError,_t=function(t){if(Et(t))return t;throw Tt(St(t)+' is not a function')},Ot=_t,Pt=function(t,e){var r=t[e];return null==r?void 0:Ot(r)},xt=_,jt=w,kt=G,Rt=s.TypeError,Lt={exports:{}},Ct=s,It=Object.defineProperty,qt=function(t,e){try{It(Ct,t,{value:e,configurable:!0,writable:!0})}catch(r){Ct[t]=e}return e},Nt=s['__core-js_shared__']||qt('__core-js_shared__',{}),Ut=Nt;(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 zt=K,Bt=s.Object,Mt=function(t){return Bt(zt(t))},Ft=b({}.hasOwnProperty),$t=Object.hasOwn||function(t,e){return Ft(Mt(t),e)},Dt=b,Kt=0,Qt=Math.random(),Ht=Dt(1..toString),Wt=function(t){return'Symbol('+(void 0===t?'':t)+')_'+Ht(++Kt+Qt,36)},Gt=s,Yt=Lt.exports,Vt=$t,Jt=Wt,Zt=ft,Xt=pt,te=Yt('wks'),ee=Gt.Symbol,re=ee&&ee.for,ne=Xt?ee:ee&&ee.withoutSetter||Jt,oe=function(t){if(!Vt(te,t)||!Zt&&'string'!=typeof te[t]){var e='Symbol.'+t;Zt&&Vt(ee,t)?te[t]=ee[t]:te[t]=Xt&&re?re(e):ne(e)}return te[t]},ie=_,se=G,ae=bt,ue=Pt,ce=function(t,e){var r,n;if('string'===e&&jt(r=t.toString)&&!kt(n=xt(r,t)))return n;if(jt(r=t.valueOf)&&!kt(n=xt(r,t)))return n;if('string'!==e&&jt(r=t.toString)&&!kt(n=xt(r,t)))return n;throw Rt('Can\'t convert object to primitive value')},he=oe,le=s.TypeError,fe=he('toPrimitive'),pe=function(t,e){if(!se(t)||ae(t))return t;var r,n=ue(t,fe);if(n){if(void 0===e&&(e='default'),r=ie(n,t,e),!se(r)||ae(r))return r;throw le('Can\'t convert object to primitive value')}return void 0===e&&(e='number'),ce(t,e)},de=bt,ve=function(t){var e=pe(t,'string');return de(e)?e:e+''},ye=G,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=_,Te=O,_e=L,Oe=function(t){return Q(H(t))},Pe=ve,xe=$t,je=Ae,ke=Object.getOwnPropertyDescriptor;A.f=Ee?ke:function(t,e){if(t=Oe(t),e=Pe(e),je)try{return ke(t,e)}catch(t){}if(xe(t,e))return _e(!Se(Te.f,t,e),t[e])};var Re=a,Le=w,Ce=/#|\.prototype\./,Ie=function(t,e){var r=Ne[qe(t)];return r==ze||r!=Ue&&(Le(e)?Re(e):!!e)},qe=Ie.normalize=function(t){return String(t).replace(Ce,'.').toLowerCase()},Ne=Ie.data={},Ue=Ie.NATIVE='N',ze=Ie.POLYFILL='P',Be=Ie,Me=_t,Fe=u,$e=b(b.bind),De=function(t,e){return Me(t),void 0===e?t:Fe?$e(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,We=G,Ge=He.String,Ye=He.TypeError,Ve=function(t){if(We(t))return t;throw Ye(Ge(t)+' is not an object')},Je=E,Ze=Ae,Xe=Qe,tr=Ve,er=ve,rr=s.TypeError,nr=Object.defineProperty,or=Object.getOwnPropertyDescriptor;Ke.f=Je?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=p,hr=b,lr=w,fr=A.f,pr=Be,dr=Y,vr=De,yr=ar,mr=$t,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,h=t.target,l=t.global,f=t.stat,p=t.proto,d=l?ur:f?ur[h]:(ur[h]||{}).prototype,v=l?dr:dr[h]||yr(dr,h,{})[h],y=v.prototype;for(o in e)r=!pr(l?o:h+(f?'.':'#')+o,t.forced)&&d&&mr(d,o),s=v[o],r&&(a=t.noTargetGet?(c=fr(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):p&&lr(i)?hr(i):i,(t.sham||i&&i.sham||s&&s.sham)&&yr(u,'sham',!0),yr(v,o,u),p&&(mr(dr,n=h+'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,Tr=(Sr.String,Sr.TypeError,b);Object.setPrototypeOf||'__proto__'in{}&&function(){var t,e=!1,r={};try{(t=Tr(Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').set))(r,[]),e=r instanceof Array}catch(t){}}();var _r={};_r[oe('toStringTag')]='z';var Or='[object z]'===String(_r),Pr=s,xr=Or,jr=w,kr=N,Rr=oe('toStringTag'),Lr=Pr.Object,Cr='Arguments'==kr(function(){return arguments}()),Ir=xr?kr: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),Rr))?r:Cr?kr(e):'Object'==(n=kr(e))&&jr(e.callee)?'Arguments':n},qr=Ir,Nr=Or?{}.toString:function(){return'[object '+qr(this)+']'},Ur=Or,zr=Ke.f,Br=ar,Mr=$t,Fr=Nr,$r=oe('toStringTag'),Dr=tt,Kr=Ke,Qr=E,Hr=oe('species'),Wr=et,Gr=s.TypeError,Yr=w,Vr=Nt,Jr=b(Function.toString);Yr(Vr.inspectSource)||(Vr.inspectSource=function(t){return Jr(t)});var Zr=Vr.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,hn=Pt,ln=Xr,fn=oe('iterator'),pn=function(t){if(null!=t)return hn(t,fn)||hn(t,'@@iterator')||ln[cn(t)]},dn=_,vn=_t,yn=Ve,mn=At,gn=pn,bn=s.TypeError,wn=_,An=Ve,En=Pt,Sn=De,Tn=_,_n=Ve,On=At,Pn=function(t){return void 0!==t&&(tn.Array===t||rn[en]===t)},xn=function(t){return un(t.length)},jn=et,kn=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')},Rn=pn,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},qn=In.prototype,Nn=oe('iterator'),Un=!1;try{var zn=0,Bn={next:function(){return{done:!!zn++}},return:function(){Un=!0}};Bn[Nn]=function(){return this},Array.from(Bn,(function(){throw 2}))}catch(t){}var Mn=b,Fn=a,$n=w,Dn=Ir,Kn=Zr,Qn=function(){},Hn=[],Wn=tt('Reflect','construct'),Gn=/^\s*(?:class|function)\b/,Yn=Mn(Gn.exec),Vn=!Gn.exec(Qn),Jn=function(t){if(!$n(t))return!1;try{return Wn(Qn,Hn,t),!0}catch(t){return!1}},Zn=function(t){if(!$n(t))return!1;switch(Dn(t)){case'AsyncFunction':case'GeneratorFunction':case'AsyncGeneratorFunction':return!1}try{return Vn||!!Yn(Gn,Kn(t))}catch(t){return!0}};Zn.sham=!0;var Xn,to,eo,ro,no=!Wn||Fn((function(){var t;return Jn(Jn.call)||!Jn(Object)||!Jn((function(){t=!0}))||t}))?Zn:Jn,oo=At,io=s.TypeError,so=Ve,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)},ho=tt('document','documentElement'),lo=b([].slice),fo=s.TypeError,po=/(?:ipad|iphone|ipod).*applewebkit/i.test(rt),vo='process'==N(s.process),yo=s,mo=p,go=De,bo=w,wo=$t,Ao=a,Eo=ho,So=lo,To=be,_o=function(t,e){if(t<e)throw fo('Not enough arguments');return t},Oo=po,Po=vo,xo=yo.setImmediate,jo=yo.clearImmediate,ko=yo.process,Ro=yo.Dispatch,Lo=yo.Function,Co=yo.MessageChannel,Io=yo.String,qo=0,No={};try{Xn=yo.location}catch(t){}var Uo=function(t){if(wo(No,t)){var e=No[t];delete No[t],e()}},zo=function(t){return function(){Uo(t)}},Bo=function(t){Uo(t.data)},Mo=function(t){yo.postMessage(Io(t),Xn.protocol+'//'+Xn.host)};xo&&jo||(xo=function(t){_o(arguments.length,1);var e=bo(t)?t:Lo(t),r=So(arguments,1);return No[++qo]=function(){mo(e,void 0,r)},to(qo),qo},jo=function(t){delete No[t]},Po?to=function(t){ko.nextTick(zo(t))}:Ro&&Ro.now?to=function(t){Ro.now(zo(t))}:Co&&!Oo?(ro=(eo=new Co).port2,eo.port1.onmessage=Bo,to=go(ro.postMessage,ro)):yo.addEventListener&&bo(yo.postMessage)&&!yo.importScripts&&Xn&&'file:'!==Xn.protocol&&!Ao(Mo)?(to=Mo,yo.addEventListener('message',Bo,!1)):to='onreadystatechange'in To('script')?function(t){Eo.appendChild(To('script')).onreadystatechange=function(){Eo.removeChild(this),Uo(t)}}:function(t){setTimeout(zo(t),0)});var Fo,$o,Do,Ko,Qo,Ho,Wo,Go,Yo={set:xo,clear:jo},Vo=s,Jo=/ipad|iphone|ipod/i.test(rt)&&void 0!==Vo.Pebble,Zo=/web0s(?!.*chrome)/i.test(rt),Xo=s,ti=De,ei=A.f,ri=Yo.set,ni=po,oi=Jo,ii=Zo,si=vo,ai=Xo.MutationObserver||Xo.WebKitMutationObserver,ui=Xo.document,ci=Xo.process,hi=Xo.Promise,li=ei(Xo,'queueMicrotask'),fi=li&&li.value;fi||(Fo=function(){var t,e;for(si&&(t=ci.domain)&&t.exit();$o;){e=$o.fn,$o=$o.next;try{e()}catch(t){throw $o?Ko():Do=void 0,t}}Do=void 0,t&&t.enter()},ni||si||ii||!ai||!ui?!oi&&hi&&hi.resolve?((Wo=hi.resolve(void 0)).constructor=hi,Go=ti(Wo.then,Wo),Ko=function(){Go(Fo)}):si?Ko=function(){ci.nextTick(Fo)}:(ri=ti(ri,Xo),Ko=function(){ri(Fo)}):(Qo=!0,Ho=ui.createTextNode(''),new ai(Fo).observe(Ho,{characterData:!0}),Ko=function(){Ho.data=Qo=!Qo}));var pi=fi||function(t){var e={fn:t,next:void 0};Do&&(Do.next=e),$o||($o=e,Ko()),Do=e},di={},vi=_t,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=Ve,gi=G,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,Ti,_i,Oi=Ei,Pi=w,xi=Zr,ji=s.WeakMap,ki=Pi(ji)&&/native code/.test(xi(ji)),Ri=Lt.exports,Li=Wt,Ci=Ri('keys'),Ii=ki,qi=s,Ni=b,Ui=G,zi=ar,Bi=$t,Mi=Nt,Fi=function(t){return Ci[t]||(Ci[t]=Li(t))},$i={},Di=qi.TypeError,Ki=qi.WeakMap;if(Ii||Mi.state){var Qi=Mi.state||(Mi.state=new Ki),Hi=Ni(Qi.get),Wi=Ni(Qi.has),Gi=Ni(Qi.set);Si=function(t,e){if(Wi(Qi,t))throw new Di('Object already initialized');return e.facade=t,Gi(Qi,t,e),e},Ti=function(t){return Hi(Qi,t)||{}},_i=function(t){return Wi(Qi,t)}}else{var Yi=Fi('state');$i[Yi]=!0,Si=function(t,e){if(Bi(t,Yi))throw new Di('Object already initialized');return e.facade=t,zi(t,Yi,e),e},Ti=function(t){return Bi(t,Yi)?t[Yi]:{}},_i=function(t){return Bi(t,Yi)}}var Vi,Ji,Zi,Xi='object'==typeof window,ts=br,es=s,rs=tt,ns=_,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;Mr(o,$r)||zr(o,$r,{configurable:!0,value:e}),n&&!Ur&&Br(o,'toString',Fr)}},as=function(t){var e=Dr(t),r=Kr.f;Qr&&e&&!e[Hr]&&r(e,Hr,{configurable:!0,get:function(){return this}})},us=_t,cs=w,hs=G,ls=function(t,e){if(Wr(e,t))return t;throw Gr('Incorrect invocation')},fs=Zr,ps=function(t,e,r){var n,o,i,s,a,u,c,h=r&&r.that,l=!(!r||!r.AS_ENTRIES),f=!(!r||!r.IS_ITERATOR),p=!(!r||!r.INTERRUPTED),d=Sn(e,h),v=function(t){return n&&Ln(n,'normal',t),new In(!0,t)},y=function(t){return l?(_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=Rn(t)))throw Cn(On(t)+' is not iterable');if(Pn(o)){for(i=0,s=xn(t);s>i;i++)if((a=y(t[i]))&&jn(qn,a))return a;return new In(!1)}n=kn(t,o)}for(u=n.next;!(c=Tn(u,n)).done;){try{a=y(c.value)}catch(t){Ln(n,'throw',t)}if('object'==typeof a&&a&&jn(qn,a))return a}return new In(!1)},ds=function(t,e){if(!e&&!Un)return!1;var r=!1;try{var n={};n[Nn]=function(){return{next:function(){return{done:r=!0}}}},t(n)}catch(t){}return r},vs=co,ys=Yo.set,ms=pi,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=Oi,Ss={set:Si,get:Ti,has:_i,enforce:function(t){return _i(t)?Ti(t):Si(t,{})},getterFor:function(t){return function(e){var r;if(!Ui(e)||(r=Ti(e)).type!==t)throw Di('Incompatible receiver, '+t+' required');return r}}},Ts=Be,_s=Xi,Os=vo,Ps=ct,xs=oe('species'),js='Promise',ks=Ss.getterFor(js),Rs=Ss.set,Ls=Ss.getterFor(js),Cs=os&&os.prototype,Is=os,qs=Cs,Ns=es.TypeError,Us=es.document,zs=es.process,Bs=ws.f,Ms=Bs,Fs=!!(Us&&Us.createEvent&&es.dispatchEvent),$s=cs(es.PromiseRejectionEvent),Ds=Ts(js,(function(){var t=fs(Is),e=t!==String(Is);if(!e&&66===Ps)return!0;if(!qs.finally)return!0;if(Ps>=51&&/native code/.test(t))return!1;var r=new Is((function(t){t(1)})),n=function(t){t((function(){}),(function(){}))};return(r.constructor={})[xs]=n,!(r.then((function(){}))instanceof n)||!e&&_s&&!$s})),Ks=Ds||!ds((function(t){Is.all(t).catch((function(){}))})),Qs=function(t){var e;return!(!hs(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,h=t.domain;try{a?(s||(2===e.rejection&&Js(e),e.rejection=1),!0===a?r=i:(h&&h.enter(),r=a(i),h&&(h.exit(),o=!0)),r===t.promise?c(Ns('Promise-chain cycle')):(n=Qs(r))?ns(n,r,u,c):u(r)):c(i)}catch(t){h&&!o&&h.exit(),c(t)}},Ws=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)})))},Gs=function(t,e,r){var n,o;Fs?((n=Us.createEvent('Event')).promise=e,n.reason=r,n.initEvent(t,!1,!0),es.dispatchEvent(n)):n={promise:e,reason:r},!$s&&(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(Vs(t)&&(e=As((function(){Os?zs.emit('unhandledRejection',n,r):Gs('unhandledrejection',r,n)})),t.rejection=Os||Vs(t)?2:1,e.error))throw e.value}))},Vs=function(t){return 1!==t.rejection&&!t.parent},Js=function(t){ns(ys,es,(function(){var e=t.facade;Os?zs.emit('rejectionHandled',e):Gs('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,Ws(t,!0))},ta=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=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,Ws(t,!1))}catch(e){Xs({done:!1},e,t)}}};Ds&&(qs=(Is=function(t){ls(this,qs),us(t),ns(Vi,this);var e=ks(this);try{t(Zs(ta,e),Zs(Xs,e))}catch(t){Xs(e,t)}}).prototype,(Vi=function(t){Rs(this,{type:js,done:!1,notified:!1,parent:!1,reactions:new Es,rejection:!1,state:0,value:void 0})}).prototype=is(qs,{then:function(t,e){var r=Ls(this),n=Bs(vs(this,Is));return r.parent=!0,n.ok=!cs(t)||t,n.fail=cs(e)&&e,n.domain=Os?zs.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)}}),Ji=function(){var t=new Vi,e=ks(t);this.promise=t,this.resolve=Zs(ta,e),this.reject=Zs(Xs,e)},ws.f=Bs=function(t){return t===Is||t===Zi?new Ji(t):Ms(t)}),ts({global:!0,wrap:!0,forced:Ds},{Promise:Is}),ss(Is,js,!1,!0),as(js),Zi=rs(js),ts({target:js,stat:!0,forced:Ds},{reject:function(t){var e=Bs(this);return ns(e.reject,void 0,t),e.promise}}),ts({target:js,stat:!0,forced:true},{resolve:function(t){return gs(this===Zi?Is:this,t)}}),ts({target:js,stat:!0,forced:Ks},{all:function(t){var e=this,r=Bs(e),n=r.resolve,o=r.reject,i=As((function(){var r=us(e.resolve),i=[],s=0,a=1;ps(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=Bs(e),n=r.reject,o=As((function(){var o=us(e.resolve);ps(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,ha,la,fa,pa,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,(ha=exports.ScreenDestination||(exports.ScreenDestination={})).CHROMECAST='chromecast',ha.APPLE_TV='appletv',ha.PIP='pip',ha.HEADPHONES='externalHeadphones',ha.SCREEN='',exports.ContentType=void 0,(la=exports.ContentType||(exports.ContentType={})).MP4='mp4',la.DASH='dash',la.HLS='hls',la.WEBM='webm',function(t){t.AUTO='auto',t.MANUAL=''}(fa||(fa={})),exports.ConnectionType=void 0,(pa=exports.ConnectionType||(exports.ConnectionType={})).HTTP1='http1',pa.HTTP2='http2',pa.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]:''},ma=1e3,ga=1.5,ba=3e5,wa=1e3;var Aa;!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'}(Aa||(Aa={}));class Ea{constructor(e){this.consequentAuthErrors=0,this.authorized$=new t.ValueSubject(!1),this.params=e;const r=va.get('uuid');r?this.uuid=String(r):(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._authorizeWithBackoff()}))}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._authorizeWithBackoff();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 Aa.PARAM_SESSION_EXPIRED:case Aa.PARAM_SESSION_KEY:case Aa.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=yield this._authorizeWithBackoff(),e>0?s(t,e-1):void 0;case Aa.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=yield this.refreshAuthToken(),this.sessionKey=yield this._authorizeWithBackoff(),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)}))}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}refreshAuthToken(){return n(this,void 0,void 0,(function*(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=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.19',platform:'WEB',items:t.map((t=>Object.assign(Object.assign({},t),{time:0,type:1})))})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const t=Math.min(Math.round(ma*Math.pow(ga,this.consequentAuthErrors-1)+Math.random()*wa),ba);return new Promise((e=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout((()=>{sa(this._authorize().then(e).catch((t=>this.params.error$.next({id:'AuthorizeBackoff',message:'Otherwise unhandle errror in authrization',thrown:t}))),(()=>this.backoffTimeoutId=0))}),t))}))}_authorize(){return n(this,void 0,void 0,(function*(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const t={session_data:{version:2,device_id:this.uuid,client_version:'1.0.19'.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=sa(this.params.apiTransport.sendRequest('auth.anonymLogin',t).then((t=>{var e;return t&&t.session_key||this.params.error$.next({id:'AuthorizeFailed',message:'No session key',data:t}),this.sessionKey=null!==(e=null==t?void 0:t.session_key)&&void 0!==e?e:void 0,this.sessionKey})).catch((t=>n(this,void 0,void 0,(function*(){this.sessionKey=void 0;const e=null==t?void 0:t.error_code;switch(e){case Aa.AUTH_LOGIN:return this.authToken=yield this.refreshAuthToken(),this._authorizeWithBackoff()}e?this.params.error$.next({id:`Authorize#${e}`,message:'authorize error',data:t}):this.params.error$.next({id:'AuthorizeUnknown',message:'authorize error',thrown:t})})))),(()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(void 0!==this.sessionKey)})),this.authorizePromise}))}}class Sa{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 Ta extends Sa{constructor(){super(),this.listeners||Sa.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 Ta,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',Ta.prototype[Symbol.toStringTag]='AbortSignal');const Oa=_a({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Pa=Oa?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(!_a({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,xa=Oa?Pa.fetch:window.fetch;Oa?Pa.Request:window.Request;class ja{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 xa(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(),xa(`${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 ka{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$,this.subscription=this.api.authorized$.subscribe((t=>{t&&this.debouncedFlush()}))}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(this.api.authorized$.getValue()?(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[]):t||this.api.authorize(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe()}}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 ja({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:ya[r.apiEnv],apiEnv:r.apiEnv,error$:o});this.api=new Ea({apiTransport:i,refreshAuthToken:r.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:o}),this.logger=new ka({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(),this.api.destroy(),this.logger.destroy()}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?fa.AUTO:!1===this.statContext.autoplay?fa.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,h=Function.prototype,l=h.apply,f=h.call,p='object'==typeof Reflect&&Reflect.apply||(c?f.bind(l):function(){return f.apply(l,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,T=S?_.bind(_):function(){return _.apply(_,arguments)},O={},P={}.propertyIsEnumerable,x=Object.getOwnPropertyDescriptor,j=x&&!P.call({1:2},1);O.f=j?function(t){var e=x(this,t);return!!e&&e.enumerable}:P;var k,R,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,z=a,B=q,F=s.Object,M=U(''.split),D=z((function(){return!F('z').propertyIsEnumerable(0)}))?function(t){return'String'==B(t)?M(t,''):F(t)}:F,$=s.TypeError,K=function(t){if(null==t)throw $('Can\'t call method on '+t);return t},Q=D,H=K,W=w,G=function(t){return'object'==typeof t?null!==t:W(t)},Y={},V=Y,J=s,Z=w,X=function(t){return Z(t)?t:void 0},tt=function(t,e){return arguments.length<2?X(V[t])||X(J[t]):V[t]&&V[t][e]||J[t]&&J[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&&(R=(k=ut.split('.'))[0]>0&&k[0]<4?1:+(k[0]+k[1])),!R&&ot&&(!(k=ot.match(/Edge\/(\d+)/))||k[1]>=74)&&(k=ot.match(/Chrome\/(\d+)/))&&(R=+k[1]);var ct=R,ht=ct,lt=a,ft=!!Object.getOwnPropertySymbols&&!lt((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&ht&&ht<41})),pt=ft&&!Symbol.sham&&'symbol'==typeof Symbol.iterator,dt=tt,vt=w,yt=et,mt=pt,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,Tt=function(t){if(Et(t))return t;throw _t(St(t)+' is not a function')},Ot=Tt,Pt=function(t,e){var r=t[e];return null==r?void 0:Ot(r)},xt=T,jt=w,kt=G,Rt=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 zt=K,Bt=s.Object,Ft=function(t){return Bt(zt(t))},Mt=b({}.hasOwnProperty),Dt=Object.hasOwn||function(t,e){return Mt(Ft(t),e)},$t=b,Kt=0,Qt=Math.random(),Ht=$t(1..toString),Wt=function(t){return'Symbol('+(void 0===t?'':t)+')_'+Ht(++Kt+Qt,36)},Gt=s,Yt=Lt.exports,Vt=Dt,Jt=Wt,Zt=ft,Xt=pt,te=Yt('wks'),ee=Gt.Symbol,re=ee&&ee.for,ne=Xt?ee:ee&&ee.withoutSetter||Jt,oe=function(t){if(!Vt(te,t)||!Zt&&'string'!=typeof te[t]){var e='Symbol.'+t;Zt&&Vt(ee,t)?te[t]=ee[t]:te[t]=Xt&&re?re(e):ne(e)}return te[t]},ie=T,se=G,ae=bt,ue=Pt,ce=function(t,e){var r,n;if('string'===e&&jt(r=t.toString)&&!kt(n=xt(r,t)))return n;if(jt(r=t.valueOf)&&!kt(n=xt(r,t)))return n;if('string'!==e&&jt(r=t.toString)&&!kt(n=xt(r,t)))return n;throw Rt('Can\'t convert object to primitive value')},he=oe,le=s.TypeError,fe=he('toPrimitive'),pe=function(t,e){if(!se(t)||ae(t))return t;var r,n=ue(t,fe);if(n){if(void 0===e&&(e='default'),r=ie(n,t,e),!se(r)||ae(r))return r;throw le('Can\'t convert object to primitive value')}return void 0===e&&(e='number'),ce(t,e)},de=bt,ve=function(t){var e=pe(t,'string');return de(e)?e:e+''},ye=G,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=T,_e=O,Te=L,Oe=function(t){return Q(H(t))},Pe=ve,xe=Dt,je=Ae,ke=Object.getOwnPropertyDescriptor;A.f=Ee?ke:function(t,e){if(t=Oe(t),e=Pe(e),je)try{return ke(t,e)}catch(t){}if(xe(t,e))return Te(!Se(_e.f,t,e),t[e])};var Re=a,Le=w,Ce=/#|\.prototype\./,Ie=function(t,e){var r=qe[Ne(t)];return r==ze||r!=Ue&&(Le(e)?Re(e):!!e)},Ne=Ie.normalize=function(t){return String(t).replace(Ce,'.').toLowerCase()},qe=Ie.data={},Ue=Ie.NATIVE='N',ze=Ie.POLYFILL='P',Be=Ie,Fe=Tt,Me=u,De=b(b.bind),$e=function(t,e){return Fe(t),void 0===e?t:Me?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,We=G,Ge=He.String,Ye=He.TypeError,Ve=function(t){if(We(t))return t;throw Ye(Ge(t)+' is not an object')},Je=E,Ze=Ae,Xe=Qe,tr=Ve,er=ve,rr=s.TypeError,nr=Object.defineProperty,or=Object.getOwnPropertyDescriptor;Ke.f=Je?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=p,hr=b,lr=w,fr=A.f,pr=Be,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,h=t.target,l=t.global,f=t.stat,p=t.proto,d=l?ur:f?ur[h]:(ur[h]||{}).prototype,v=l?dr:dr[h]||yr(dr,h,{})[h],y=v.prototype;for(o in e)r=!pr(l?o:h+(f?'.':'#')+o,t.forced)&&d&&mr(d,o),s=v[o],r&&(a=t.noTargetGet?(c=fr(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):p&&lr(i)?hr(i):i,(t.sham||i&&i.sham||s&&s.sham)&&yr(u,'sham',!0),yr(v,o,u),p&&(mr(dr,n=h+'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 Tr={};Tr[oe('toStringTag')]='z';var Or='[object z]'===String(Tr),Pr=s,xr=Or,jr=w,kr=q,Rr=oe('toStringTag'),Lr=Pr.Object,Cr='Arguments'==kr(function(){return arguments}()),Ir=xr?kr: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),Rr))?r:Cr?kr(e):'Object'==(n=kr(e))&&jr(e.callee)?'Arguments':n},Nr=Ir,qr=Or?{}.toString:function(){return'[object '+Nr(this)+']'},Ur=Or,zr=Ke.f,Br=ar,Fr=Dt,Mr=qr,Dr=oe('toStringTag'),$r=tt,Kr=Ke,Qr=E,Hr=oe('species'),Wr=et,Gr=s.TypeError,Yr=w,Vr=qt,Jr=b(Function.toString);Yr(Vr.inspectSource)||(Vr.inspectSource=function(t){return Jr(t)});var Zr=Vr.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,hn=Pt,ln=Xr,fn=oe('iterator'),pn=function(t){if(null!=t)return hn(t,fn)||hn(t,'@@iterator')||ln[cn(t)]},dn=T,vn=Tt,yn=Ve,mn=At,gn=pn,bn=s.TypeError,wn=T,An=Ve,En=Pt,Sn=$e,_n=T,Tn=Ve,On=At,Pn=function(t){return void 0!==t&&(tn.Array===t||rn[en]===t)},xn=function(t){return un(t.length)},jn=et,kn=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')},Rn=pn,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 zn=0,Bn={next:function(){return{done:!!zn++}},return:function(){Un=!0}};Bn[qn]=function(){return this},Array.from(Bn,(function(){throw 2}))}catch(t){}var Fn=b,Mn=a,Dn=w,$n=Ir,Kn=Zr,Qn=function(){},Hn=[],Wn=tt('Reflect','construct'),Gn=/^\s*(?:class|function)\b/,Yn=Fn(Gn.exec),Vn=!Gn.exec(Qn),Jn=function(t){if(!Dn(t))return!1;try{return Wn(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 Vn||!!Yn(Gn,Kn(t))}catch(t){return!0}};Zn.sham=!0;var Xn,to,eo,ro,no=!Wn||Mn((function(){var t;return Jn(Jn.call)||!Jn(Object)||!Jn((function(){t=!0}))||t}))?Zn:Jn,oo=At,io=s.TypeError,so=Ve,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)},ho=tt('document','documentElement'),lo=b([].slice),fo=s.TypeError,po=/(?:ipad|iphone|ipod).*applewebkit/i.test(rt),vo='process'==q(s.process),yo=s,mo=p,go=$e,bo=w,wo=Dt,Ao=a,Eo=ho,So=lo,_o=be,To=function(t,e){if(t<e)throw fo('Not enough arguments');return t},Oo=po,Po=vo,xo=yo.setImmediate,jo=yo.clearImmediate,ko=yo.process,Ro=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()}},zo=function(t){return function(){Uo(t)}},Bo=function(t){Uo(t.data)},Fo=function(t){yo.postMessage(Io(t),Xn.protocol+'//'+Xn.host)};xo&&jo||(xo=function(t){To(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},jo=function(t){delete qo[t]},Po?to=function(t){ko.nextTick(zo(t))}:Ro&&Ro.now?to=function(t){Ro.now(zo(t))}:Co&&!Oo?(ro=(eo=new Co).port2,eo.port1.onmessage=Bo,to=go(ro.postMessage,ro)):yo.addEventListener&&bo(yo.postMessage)&&!yo.importScripts&&Xn&&'file:'!==Xn.protocol&&!Ao(Fo)?(to=Fo,yo.addEventListener('message',Bo,!1)):to='onreadystatechange'in _o('script')?function(t){Eo.appendChild(_o('script')).onreadystatechange=function(){Eo.removeChild(this),Uo(t)}}:function(t){setTimeout(zo(t),0)});var Mo,Do,$o,Ko,Qo,Ho,Wo,Go,Yo={set:xo,clear:jo},Vo=s,Jo=/ipad|iphone|ipod/i.test(rt)&&void 0!==Vo.Pebble,Zo=/web0s(?!.*chrome)/i.test(rt),Xo=s,ti=$e,ei=A.f,ri=Yo.set,ni=po,oi=Jo,ii=Zo,si=vo,ai=Xo.MutationObserver||Xo.WebKitMutationObserver,ui=Xo.document,ci=Xo.process,hi=Xo.Promise,li=ei(Xo,'queueMicrotask'),fi=li&&li.value;fi||(Mo=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&&hi&&hi.resolve?((Wo=hi.resolve(void 0)).constructor=hi,Go=ti(Wo.then,Wo),Ko=function(){Go(Mo)}):si?Ko=function(){ci.nextTick(Mo)}:(ri=ti(ri,Xo),Ko=function(){ri(Mo)}):(Qo=!0,Ho=ui.createTextNode(''),new ai(Mo).observe(Ho,{characterData:!0}),Ko=function(){Ho.data=Qo=!Qo}));var pi=fi||function(t){var e={fn:t,next:void 0};$o&&($o.next=e),Do||(Do=e,Ko()),$o=e},di={},vi=Tt,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=Ve,gi=G,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,Ti,Oi=Ei,Pi=w,xi=Zr,ji=s.WeakMap,ki=Pi(ji)&&/native code/.test(xi(ji)),Ri=Lt.exports,Li=Wt,Ci=Ri('keys'),Ii=ki,Ni=s,qi=b,Ui=G,zi=ar,Bi=Dt,Fi=qt,Mi=function(t){return Ci[t]||(Ci[t]=Li(t))},Di={},$i=Ni.TypeError,Ki=Ni.WeakMap;if(Ii||Fi.state){var Qi=Fi.state||(Fi.state=new Ki),Hi=qi(Qi.get),Wi=qi(Qi.has),Gi=qi(Qi.set);Si=function(t,e){if(Wi(Qi,t))throw new $i('Object already initialized');return e.facade=t,Gi(Qi,t,e),e},_i=function(t){return Hi(Qi,t)||{}},Ti=function(t){return Wi(Qi,t)}}else{var Yi=Mi('state');Di[Yi]=!0,Si=function(t,e){if(Bi(t,Yi))throw new $i('Object already initialized');return e.facade=t,zi(t,Yi,e),e},_i=function(t){return Bi(t,Yi)?t[Yi]:{}},Ti=function(t){return Bi(t,Yi)}}var Vi,Ji,Zi,Xi='object'==typeof window,ts=br,es=s,rs=tt,ns=T,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;Fr(o,Dr)||zr(o,Dr,{configurable:!0,value:e}),n&&!Ur&&Br(o,'toString',Mr)}},as=function(t){var e=$r(t),r=Kr.f;Qr&&e&&!e[Hr]&&r(e,Hr,{configurable:!0,get:function(){return this}})},us=Tt,cs=w,hs=G,ls=function(t,e){if(Wr(e,t))return t;throw Gr('Incorrect invocation')},fs=Zr,ps=function(t,e,r){var n,o,i,s,a,u,c,h=r&&r.that,l=!(!r||!r.AS_ENTRIES),f=!(!r||!r.IS_ITERATOR),p=!(!r||!r.INTERRUPTED),d=Sn(e,h),v=function(t){return n&&Ln(n,'normal',t),new In(!0,t)},y=function(t){return l?(Tn(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=Rn(t)))throw Cn(On(t)+' is not iterable');if(Pn(o)){for(i=0,s=xn(t);s>i;i++)if((a=y(t[i]))&&jn(Nn,a))return a;return new In(!1)}n=kn(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&&jn(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=pi,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=Oi,Ss={set:Si,get:_i,has:Ti,enforce:function(t){return Ti(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=Be,Ts=Xi,Os=vo,Ps=ct,xs=oe('species'),js='Promise',ks=Ss.getterFor(js),Rs=Ss.set,Ls=Ss.getterFor(js),Cs=os&&os.prototype,Is=os,Ns=Cs,qs=es.TypeError,Us=es.document,zs=es.process,Bs=ws.f,Fs=Bs,Ms=!!(Us&&Us.createEvent&&es.dispatchEvent),Ds=cs(es.PromiseRejectionEvent),$s=_s(js,(function(){var t=fs(Is),e=t!==String(Is);if(!e&&66===Ps)return!0;if(!Ns.finally)return!0;if(Ps>=51&&/native code/.test(t))return!1;var r=new Is((function(t){t(1)})),n=function(t){t((function(){}),(function(){}))};return(r.constructor={})[xs]=n,!(r.then((function(){}))instanceof n)||!e&&Ts&&!Ds})),Ks=$s||!ds((function(t){Is.all(t).catch((function(){}))})),Qs=function(t){var e;return!(!hs(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,h=t.domain;try{a?(s||(2===e.rejection&&Js(e),e.rejection=1),!0===a?r=i:(h&&h.enter(),r=a(i),h&&(h.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){h&&!o&&h.exit(),c(t)}},Ws=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)})))},Gs=function(t,e,r){var n,o;Ms?((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(Vs(t)&&(e=As((function(){Os?zs.emit('unhandledRejection',n,r):Gs('unhandledrejection',r,n)})),t.rejection=Os||Vs(t)?2:1,e.error))throw e.value}))},Vs=function(t){return 1!==t.rejection&&!t.parent},Js=function(t){ns(ys,es,(function(){var e=t.facade;Os?zs.emit('rejectionHandled',e):Gs('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,Ws(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,Ws(t,!1))}catch(e){Xs({done:!1},e,t)}}};$s&&(Ns=(Is=function(t){ls(this,Ns),us(t),ns(Vi,this);var e=ks(this);try{t(Zs(ta,e),Zs(Xs,e))}catch(t){Xs(e,t)}}).prototype,(Vi=function(t){Rs(this,{type:js,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=Bs(vs(this,Is));return r.parent=!0,n.ok=!cs(t)||t,n.fail=cs(e)&&e,n.domain=Os?zs.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)}}),Ji=function(){var t=new Vi,e=ks(t);this.promise=t,this.resolve=Zs(ta,e),this.reject=Zs(Xs,e)},ws.f=Bs=function(t){return t===Is||t===Zi?new Ji(t):Fs(t)}),ts({global:!0,wrap:!0,forced:$s},{Promise:Is}),ss(Is,js,!1,!0),as(js),Zi=rs(js),ts({target:js,stat:!0,forced:$s},{reject:function(t){var e=Bs(this);return ns(e.reject,void 0,t),e.promise}}),ts({target:js,stat:!0,forced:true},{resolve:function(t){return gs(this===Zi?Is:this,t)}}),ts({target:js,stat:!0,forced:Ks},{all:function(t){var e=this,r=Bs(e),n=r.resolve,o=r.reject,i=As((function(){var r=us(e.resolve),i=[],s=0,a=1;ps(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=Bs(e),n=r.reject,o=As((function(){var o=us(e.resolve);ps(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,ha,la,fa,pa,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,(ha=exports.ScreenDestination||(exports.ScreenDestination={})).CHROMECAST='chromecast',ha.APPLE_TV='appletv',ha.PIP='pip',ha.HEADPHONES='externalHeadphones',ha.SCREEN='',exports.ContentType=void 0,(la=exports.ContentType||(exports.ContentType={})).MP4='mp4',la.DASH='dash',la.DASH_SEP='dash_sep',la.ONDEMAND_DASH='ondemand_dash',la.HLS='hls',la.ONDEMAND_HLS='ondemand_hls',la.WEBM='webm',function(t){t.AUTO='auto',t.MANUAL=''}(fa||(fa={})),exports.ConnectionType=void 0,(pa=exports.ConnectionType||(exports.ConnectionType={})).HTTP1='http1',pa.HTTP2='http2',pa.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]:''},ma={start:1e3,factor:1.5,max:3e5,random:1e3};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(e){this.consequentAuthErrors=0,this.authorized$=new t.ValueSubject(!1),this.params=e;const r=va.get('uuid');r?this.uuid=String(r):(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._authorizeWithBackoff()}))}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._authorizeWithBackoff();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 ga.PARAM_SESSION_EXPIRED:case ga.PARAM_SESSION_KEY:case ga.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=yield this._authorizeWithBackoff(),e>0?s(t,e-1):void 0;case ga.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=yield this.refreshAuthToken(),this.sessionKey=yield this._authorizeWithBackoff(),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)}))}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}refreshAuthToken(){return n(this,void 0,void 0,(function*(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=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.20',platform:'WEB',items:t.map((t=>Object.assign(Object.assign({},t),{time:0,type:1})))})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const e=t.getExponentialDelay(this.consequentAuthErrors,ma);return new Promise((t=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout((()=>{sa(this._authorize().then(t).catch((t=>this.params.error$.next({id:'AuthorizeBackoff',message:'Otherwise unhandle errror in authrization',thrown:t}))),(()=>this.backoffTimeoutId=0))}),e))}))}_authorize(){return n(this,void 0,void 0,(function*(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const t={session_data:{version:2,device_id:this.uuid,client_version:'1.0.20'.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=sa(this.params.apiTransport.sendRequest('auth.anonymLogin',t).then((t=>{var e;return t&&t.session_key||this.params.error$.next({id:'AuthorizeFailed',message:'No session key',data:t}),this.sessionKey=null!==(e=null==t?void 0:t.session_key)&&void 0!==e?e:void 0,this.sessionKey})).catch((t=>n(this,void 0,void 0,(function*(){this.sessionKey=void 0;const e=null==t?void 0:t.error_code;switch(e){case ga.AUTH_LOGIN:return this.authToken=yield this.refreshAuthToken(),this._authorizeWithBackoff()}e?this.params.error$.next({id:`Authorize#${e}`,message:'authorize error',data:t}):this.params.error$.next({id:'AuthorizeUnknown',message:'authorize error',thrown:t})})))),(()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(void 0!==this.sessionKey)})),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,Ta=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 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 Ta(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(),Ta(`${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$,this.subscription=this.api.authorized$.subscribe((t=>{t&&this.debouncedFlush()}))}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(this.api.authorized$.getValue()?(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[]):t||this.api.authorize(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe()}}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 ba({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(),this.api.destroy(),this.logger.destroy()}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?fa.AUTO:!1===this.statContext.autoplay?fa.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode};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.
|
|
3
|
-
* Tue,
|
|
4
|
-
* https://st.mycdn.me/static/playersdk/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-statistics v1.0.20
|
|
3
|
+
* Tue, 09 Aug 2022 12:30:38 GMT
|
|
4
|
+
* https://st.mycdn.me/static/playersdk/1-0-20/doc/
|
|
5
5
|
*/
|
|
6
|
-
import{ValueSubject as t,Subscription as e,Subject as r,fromEvent as n}from'@vkontakte/videoplayer-shared/es2015.esm.js';import o from'lodash/debounce';function i(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 s='undefined'!=typeof globalThis?globalThis:'undefined'!=typeof window?window:'undefined'!=typeof global?global:'undefined'!=typeof self?self:{},a=function(t){return t&&t.Math==Math&&t},u=a('object'==typeof globalThis&&globalThis)||a('object'==typeof window&&window)||a('object'==typeof self&&self)||a('object'==typeof s&&s)||function(){return this}()||Function('return this')(),c=function(t){try{return!!t()}catch(t){return!0}},h=!c((function(){var t=function(){}.bind();return'function'!=typeof t||t.hasOwnProperty('prototype')})),l=h,f=Function.prototype,p=f.apply,d=f.call,v='object'==typeof Reflect&&Reflect.apply||(l?d.bind(p):function(){return d.apply(p,arguments)}),y=h,m=Function.prototype,g=m.bind,b=m.call,w=y&&g.bind(b,b),A=y?function(t){return t&&w(t)}:function(t){return t&&function(){return b.apply(t,arguments)}},E=function(t){return'function'==typeof t},S={},_=!c((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),T=h,P=Function.prototype.call,O=T?P.bind(P):function(){return P.apply(P,arguments)},j={},k={}.propertyIsEnumerable,R=Object.getOwnPropertyDescriptor,x=R&&!k.call({1:2},1);j.f=x?function(t){var e=R(this,t);return!!e&&e.enumerable}:k;var L,I,C=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},N=A,q=N({}.toString),U=N(''.slice),z=function(t){return U(q(t),8,-1)},B=A,M=c,F=z,$=u.Object,K=B(''.split),D=M((function(){return!$('z').propertyIsEnumerable(0)}))?function(t){return'String'==F(t)?K(t,''):$(t)}:$,Q=u.TypeError,H=function(t){if(null==t)throw Q('Can\'t call method on '+t);return t},W=D,G=H,Y=E,J=function(t){return'object'==typeof t?null!==t:Y(t)},V={},Z=V,X=u,tt=E,et=function(t){return tt(t)?t:void 0},rt=function(t,e){return arguments.length<2?et(Z[t])||et(X[t]):Z[t]&&Z[t][e]||X[t]&&X[t][e]},nt=A({}.isPrototypeOf),ot=rt('navigator','userAgent')||'',it=u,st=ot,at=it.process,ut=it.Deno,ct=at&&at.versions||ut&&ut.version,ht=ct&&ct.v8;ht&&(I=(L=ht.split('.'))[0]>0&&L[0]<4?1:+(L[0]+L[1])),!I&&st&&(!(L=st.match(/Edge\/(\d+)/))||L[1]>=74)&&(L=st.match(/Chrome\/(\d+)/))&&(I=+L[1]);var lt=I,ft=lt,pt=c,dt=!!Object.getOwnPropertySymbols&&!pt((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&ft&&ft<41})),vt=dt&&!Symbol.sham&&'symbol'==typeof Symbol.iterator,yt=rt,mt=E,gt=nt,bt=vt,wt=u.Object,At=bt?function(t){return'symbol'==typeof t}:function(t){var e=yt('Symbol');return mt(e)&>(e.prototype,wt(t))},Et=u.String,St=function(t){try{return Et(t)}catch(t){return'Object'}},_t=E,Tt=St,Pt=u.TypeError,Ot=function(t){if(_t(t))return t;throw Pt(Tt(t)+' is not a function')},jt=Ot,kt=function(t,e){var r=t[e];return null==r?void 0:jt(r)},Rt=O,xt=E,Lt=J,It=u.TypeError,Ct={exports:{}},Nt=u,qt=Object.defineProperty,Ut=function(t,e){try{qt(Nt,t,{value:e,configurable:!0,writable:!0})}catch(r){Nt[t]=e}return e},zt=u['__core-js_shared__']||Ut('__core-js_shared__',{}),Bt=zt;(Ct.exports=function(t,e){return Bt[t]||(Bt[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 Mt=H,Ft=u.Object,$t=function(t){return Ft(Mt(t))},Kt=A({}.hasOwnProperty),Dt=Object.hasOwn||function(t,e){return Kt($t(t),e)},Qt=A,Ht=0,Wt=Math.random(),Gt=Qt(1..toString),Yt=function(t){return'Symbol('+(void 0===t?'':t)+')_'+Gt(++Ht+Wt,36)},Jt=u,Vt=Ct.exports,Zt=Dt,Xt=Yt,te=dt,ee=vt,re=Vt('wks'),ne=Jt.Symbol,oe=ne&&ne.for,ie=ee?ne:ne&&ne.withoutSetter||Xt,se=function(t){if(!Zt(re,t)||!te&&'string'!=typeof re[t]){var e='Symbol.'+t;te&&Zt(ne,t)?re[t]=ne[t]:re[t]=ee&&oe?oe(e):ie(e)}return re[t]},ae=O,ue=J,ce=At,he=kt,le=function(t,e){var r,n;if('string'===e&&xt(r=t.toString)&&!Lt(n=Rt(r,t)))return n;if(xt(r=t.valueOf)&&!Lt(n=Rt(r,t)))return n;if('string'!==e&&xt(r=t.toString)&&!Lt(n=Rt(r,t)))return n;throw It('Can\'t convert object to primitive value')},fe=se,pe=u.TypeError,de=fe('toPrimitive'),ve=function(t,e){if(!ue(t)||ce(t))return t;var r,n=he(t,de);if(n){if(void 0===e&&(e='default'),r=ae(n,t,e),!ue(r)||ce(r))return r;throw pe('Can\'t convert object to primitive value')}return void 0===e&&(e='number'),le(t,e)},ye=At,me=function(t){var e=ve(t,'string');return ye(e)?e:e+''},ge=J,be=u.document,we=ge(be)&&ge(be.createElement),Ae=function(t){return we?be.createElement(t):{}},Ee=Ae,Se=!_&&!c((function(){return 7!=Object.defineProperty(Ee('div'),'a',{get:function(){return 7}}).a})),_e=_,Te=O,Pe=j,Oe=C,je=function(t){return W(G(t))},ke=me,Re=Dt,xe=Se,Le=Object.getOwnPropertyDescriptor;S.f=_e?Le:function(t,e){if(t=je(t),e=ke(e),xe)try{return Le(t,e)}catch(t){}if(Re(t,e))return Oe(!Te(Pe.f,t,e),t[e])};var Ie=c,Ce=E,Ne=/#|\.prototype\./,qe=function(t,e){var r=ze[Ue(t)];return r==Me||r!=Be&&(Ce(e)?Ie(e):!!e)},Ue=qe.normalize=function(t){return String(t).replace(Ne,'.').toLowerCase()},ze=qe.data={},Be=qe.NATIVE='N',Me=qe.POLYFILL='P',Fe=qe,$e=Ot,Ke=h,De=A(A.bind),Qe=function(t,e){return $e(t),void 0===e?t:Ke?De(t,e):function(){return t.apply(e,arguments)}},He={},We=_&&c((function(){return 42!=Object.defineProperty((function(){}),'prototype',{value:42,writable:!1}).prototype})),Ge=u,Ye=J,Je=Ge.String,Ve=Ge.TypeError,Ze=function(t){if(Ye(t))return t;throw Ve(Je(t)+' is not an object')},Xe=_,tr=Se,er=We,rr=Ze,nr=me,or=u.TypeError,ir=Object.defineProperty,sr=Object.getOwnPropertyDescriptor;He.f=Xe?er?function(t,e,r){if(rr(t),e=nr(e),rr(r),'function'==typeof t&&'prototype'===e&&'value'in r&&'writable'in r&&!r.writable){var n=sr(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 ir(t,e,r)}:ir:function(t,e,r){if(rr(t),e=nr(e),rr(r),tr)try{return ir(t,e,r)}catch(t){}if('get'in r||'set'in r)throw or('Accessors not supported');return'value'in r&&(t[e]=r.value),t};var ar=He,ur=C,cr=_?function(t,e,r){return ar.f(t,e,ur(1,r))}:function(t,e,r){return t[e]=r,t},hr=u,lr=v,fr=A,pr=E,dr=S.f,vr=Fe,yr=V,mr=Qe,gr=cr,br=Dt,wr=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},Ar=function(t,e){var r,n,o,i,s,a,u,c,h=t.target,l=t.global,f=t.stat,p=t.proto,d=l?hr:f?hr[h]:(hr[h]||{}).prototype,v=l?yr:yr[h]||gr(yr,h,{})[h],y=v.prototype;for(o in e)r=!vr(l?o:h+(f?'.':'#')+o,t.forced)&&d&&br(d,o),s=v[o],r&&(a=t.noTargetGet?(c=dr(d,o))&&c.value:d[o]),i=r&&a?a:e[o],r&&typeof s==typeof i||(u=t.bind&&r?mr(i,hr):t.wrap&&r?wr(i):p&&pr(i)?fr(i):i,(t.sham||i&&i.sham||s&&s.sham)&&gr(u,'sham',!0),gr(v,o,u),p&&(br(yr,n=h+'Prototype')||gr(yr,n,{}),gr(yr[n],o,i),t.real&&y&&!y[o]&&gr(y,o,i)))},Er=u.Promise,Sr=cr,_r=function(t,e,r,n){n&&n.enumerable?t[e]=r:Sr(t,e,r)},Tr=u,Pr=(Tr.String,Tr.TypeError,A);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[se('toStringTag')]='z';var jr='[object z]'===String(Or),kr=u,Rr=jr,xr=E,Lr=z,Ir=se('toStringTag'),Cr=kr.Object,Nr='Arguments'==Lr(function(){return arguments}()),qr=Rr?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),Ir))?r:Nr?Lr(e):'Object'==(n=Lr(e))&&xr(e.callee)?'Arguments':n},Ur=qr,zr=jr?{}.toString:function(){return'[object '+Ur(this)+']'},Br=jr,Mr=He.f,Fr=cr,$r=Dt,Kr=zr,Dr=se('toStringTag'),Qr=rt,Hr=He,Wr=_,Gr=se('species'),Yr=nt,Jr=u.TypeError,Vr=E,Zr=zt,Xr=A(Function.toString);Vr(Zr.inspectSource)||(Zr.inspectSource=function(t){return Xr(t)});var tn=Zr.inspectSource,en={},rn=en,nn=se('iterator'),on=Array.prototype,sn=Math.ceil,an=Math.floor,un=function(t){var e=+t;return e!=e||0===e?0:(e>0?an:sn)(e)},cn=Math.min,hn=function(t){return t>0?cn(un(t),9007199254740991):0},ln=qr,fn=kt,pn=en,dn=se('iterator'),vn=function(t){if(null!=t)return fn(t,dn)||fn(t,'@@iterator')||pn[ln(t)]},yn=O,mn=Ot,gn=Ze,bn=St,wn=vn,An=u.TypeError,En=O,Sn=Ze,_n=kt,Tn=Qe,Pn=O,On=Ze,jn=St,kn=function(t){return void 0!==t&&(rn.Array===t||on[nn]===t)},Rn=function(t){return hn(t.length)},xn=nt,Ln=function(t,e){var r=arguments.length<2?wn(t):e;if(mn(r))return gn(yn(r,t));throw An(bn(t)+' is not iterable')},In=vn,Cn=function(t,e,r){var n,o;Sn(t);try{if(!(n=_n(t,'return'))){if('throw'===e)throw r;return r}n=En(n,t)}catch(t){o=!0,n=t}if('throw'===e)throw r;if(o)throw n;return Sn(n),r},Nn=u.TypeError,qn=function(t,e){this.stopped=t,this.result=e},Un=qn.prototype,zn=se('iterator'),Bn=!1;try{var Mn=0,Fn={next:function(){return{done:!!Mn++}},return:function(){Bn=!0}};Fn[zn]=function(){return this},Array.from(Fn,(function(){throw 2}))}catch(t){}var $n=A,Kn=c,Dn=E,Qn=qr,Hn=tn,Wn=function(){},Gn=[],Yn=rt('Reflect','construct'),Jn=/^\s*(?:class|function)\b/,Vn=$n(Jn.exec),Zn=!Jn.exec(Wn),Xn=function(t){if(!Dn(t))return!1;try{return Yn(Wn,Gn,t),!0}catch(t){return!1}},to=function(t){if(!Dn(t))return!1;switch(Qn(t)){case'AsyncFunction':case'GeneratorFunction':case'AsyncGeneratorFunction':return!1}try{return Zn||!!Vn(Jn,Hn(t))}catch(t){return!0}};to.sham=!0;var eo,ro,no,oo,io=!Yn||Kn((function(){var t;return Xn(Xn.call)||!Xn(Object)||!Xn((function(){t=!0}))||t}))?to:Xn,so=St,ao=u.TypeError,uo=Ze,co=function(t){if(io(t))return t;throw ao(so(t)+' is not a constructor')},ho=se('species'),lo=function(t,e){var r,n=uo(t).constructor;return void 0===n||null==(r=uo(n)[ho])?e:co(r)},fo=rt('document','documentElement'),po=A([].slice),vo=u.TypeError,yo=/(?:ipad|iphone|ipod).*applewebkit/i.test(ot),mo='process'==z(u.process),go=u,bo=v,wo=Qe,Ao=E,Eo=Dt,So=c,_o=fo,To=po,Po=Ae,Oo=function(t,e){if(t<e)throw vo('Not enough arguments');return t},jo=yo,ko=mo,Ro=go.setImmediate,xo=go.clearImmediate,Lo=go.process,Io=go.Dispatch,Co=go.Function,No=go.MessageChannel,qo=go.String,Uo=0,zo={};try{eo=go.location}catch(t){}var Bo=function(t){if(Eo(zo,t)){var e=zo[t];delete zo[t],e()}},Mo=function(t){return function(){Bo(t)}},Fo=function(t){Bo(t.data)},$o=function(t){go.postMessage(qo(t),eo.protocol+'//'+eo.host)};Ro&&xo||(Ro=function(t){Oo(arguments.length,1);var e=Ao(t)?t:Co(t),r=To(arguments,1);return zo[++Uo]=function(){bo(e,void 0,r)},ro(Uo),Uo},xo=function(t){delete zo[t]},ko?ro=function(t){Lo.nextTick(Mo(t))}:Io&&Io.now?ro=function(t){Io.now(Mo(t))}:No&&!jo?(oo=(no=new No).port2,no.port1.onmessage=Fo,ro=wo(oo.postMessage,oo)):go.addEventListener&&Ao(go.postMessage)&&!go.importScripts&&eo&&'file:'!==eo.protocol&&!So($o)?(ro=$o,go.addEventListener('message',Fo,!1)):ro='onreadystatechange'in Po('script')?function(t){_o.appendChild(Po('script')).onreadystatechange=function(){_o.removeChild(this),Bo(t)}}:function(t){setTimeout(Mo(t),0)});var Ko,Do,Qo,Ho,Wo,Go,Yo,Jo,Vo={set:Ro,clear:xo},Zo=u,Xo=/ipad|iphone|ipod/i.test(ot)&&void 0!==Zo.Pebble,ti=/web0s(?!.*chrome)/i.test(ot),ei=u,ri=Qe,ni=S.f,oi=Vo.set,ii=yo,si=Xo,ai=ti,ui=mo,ci=ei.MutationObserver||ei.WebKitMutationObserver,hi=ei.document,li=ei.process,fi=ei.Promise,pi=ni(ei,'queueMicrotask'),di=pi&&pi.value;di||(Ko=function(){var t,e;for(ui&&(t=li.domain)&&t.exit();Do;){e=Do.fn,Do=Do.next;try{e()}catch(t){throw Do?Ho():Qo=void 0,t}}Qo=void 0,t&&t.enter()},ii||ui||ai||!ci||!hi?!si&&fi&&fi.resolve?((Yo=fi.resolve(void 0)).constructor=fi,Jo=ri(Yo.then,Yo),Ho=function(){Jo(Ko)}):ui?Ho=function(){li.nextTick(Ko)}:(oi=ri(oi,ei),Ho=function(){oi(Ko)}):(Wo=!0,Go=hi.createTextNode(''),new ci(Ko).observe(Go,{characterData:!0}),Ho=function(){Go.data=Wo=!Wo}));var vi=di||function(t){var e={fn:t,next:void 0};Qo&&(Qo.next=e),Do||(Do=e,Ho()),Qo=e},yi={},mi=Ot,gi=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=mi(e),this.reject=mi(r)};yi.f=function(t){return new gi(t)};var bi=Ze,wi=J,Ai=yi,Ei=function(t,e){if(bi(t),wi(e)&&e.constructor===t)return e;var r=Ai.f(t);return(0,r.resolve)(e),r.promise},Si=u,_i=function(){this.head=null,this.tail=null};_i.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 Ti,Pi,Oi,ji=_i,ki=E,Ri=tn,xi=u.WeakMap,Li=ki(xi)&&/native code/.test(Ri(xi)),Ii=Ct.exports,Ci=Yt,Ni=Ii('keys'),qi=Li,Ui=u,zi=A,Bi=J,Mi=cr,Fi=Dt,$i=zt,Ki=function(t){return Ni[t]||(Ni[t]=Ci(t))},Di={},Qi=Ui.TypeError,Hi=Ui.WeakMap;if(qi||$i.state){var Wi=$i.state||($i.state=new Hi),Gi=zi(Wi.get),Yi=zi(Wi.has),Ji=zi(Wi.set);Ti=function(t,e){if(Yi(Wi,t))throw new Qi('Object already initialized');return e.facade=t,Ji(Wi,t,e),e},Pi=function(t){return Gi(Wi,t)||{}},Oi=function(t){return Yi(Wi,t)}}else{var Vi=Ki('state');Di[Vi]=!0,Ti=function(t,e){if(Fi(t,Vi))throw new Qi('Object already initialized');return e.facade=t,Mi(t,Vi,e),e},Pi=function(t){return Fi(t,Vi)?t[Vi]:{}},Oi=function(t){return Fi(t,Vi)}}var Zi,Xi,ts,es='object'==typeof window,rs=Ar,ns=u,os=rt,is=O,ss=Er,as=function(t,e,r){for(var n in e)r&&r.unsafe&&t[n]?t[n]=e[n]:_r(t,n,e[n],r);return t},us=function(t,e,r,n){if(t){var o=r?t:t.prototype;$r(o,Dr)||Mr(o,Dr,{configurable:!0,value:e}),n&&!Br&&Fr(o,'toString',Kr)}},cs=function(t){var e=Qr(t),r=Hr.f;Wr&&e&&!e[Gr]&&r(e,Gr,{configurable:!0,get:function(){return this}})},hs=Ot,ls=E,fs=J,ps=function(t,e){if(Yr(e,t))return t;throw Jr('Incorrect invocation')},ds=tn,vs=function(t,e,r){var n,o,i,s,a,u,c,h=r&&r.that,l=!(!r||!r.AS_ENTRIES),f=!(!r||!r.IS_ITERATOR),p=!(!r||!r.INTERRUPTED),d=Tn(e,h),v=function(t){return n&&Cn(n,'normal',t),new qn(!0,t)},y=function(t){return l?(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=In(t)))throw Nn(jn(t)+' is not iterable');if(kn(o)){for(i=0,s=Rn(t);s>i;i++)if((a=y(t[i]))&&xn(Un,a))return a;return new qn(!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&&xn(Un,a))return a}return new qn(!1)},ys=function(t,e){if(!e&&!Bn)return!1;var r=!1;try{var n={};n[zn]=function(){return{next:function(){return{done:r=!0}}}},t(n)}catch(t){}return r},ms=lo,gs=Vo.set,bs=vi,ws=Ei,As=function(t,e){var r=Si.console;r&&r.error&&(1==arguments.length?r.error(t):r.error(t,e))},Es=yi,Ss=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},_s=ji,Ts={set:Ti,get:Pi,has:Oi,enforce:function(t){return Oi(t)?Pi(t):Ti(t,{})},getterFor:function(t){return function(e){var r;if(!Bi(e)||(r=Pi(e)).type!==t)throw Qi('Incompatible receiver, '+t+' required');return r}}},Ps=Fe,Os=es,js=mo,ks=lt,Rs=se('species'),xs='Promise',Ls=Ts.getterFor(xs),Is=Ts.set,Cs=Ts.getterFor(xs),Ns=ss&&ss.prototype,qs=ss,Us=Ns,zs=ns.TypeError,Bs=ns.document,Ms=ns.process,Fs=Es.f,$s=Fs,Ks=!!(Bs&&Bs.createEvent&&ns.dispatchEvent),Ds=ls(ns.PromiseRejectionEvent),Qs=Ps(xs,(function(){var t=ds(qs),e=t!==String(qs);if(!e&&66===ks)return!0;if(!Us.finally)return!0;if(ks>=51&&/native code/.test(t))return!1;var r=new qs((function(t){t(1)})),n=function(t){t((function(){}),(function(){}))};return(r.constructor={})[Rs]=n,!(r.then((function(){}))instanceof n)||!e&&Os&&!Ds})),Hs=Qs||!ys((function(t){qs.all(t).catch((function(){}))})),Ws=function(t){var e;return!(!fs(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,h=t.domain;try{a?(s||(2===e.rejection&&Xs(e),e.rejection=1),!0===a?r=i:(h&&h.enter(),r=a(i),h&&(h.exit(),o=!0)),r===t.promise?c(zs('Promise-chain cycle')):(n=Ws(r))?is(n,r,u,c):u(r)):c(i)}catch(t){h&&!o&&h.exit(),c(t)}},Ys=function(t,e){t.notified||(t.notified=!0,bs((function(){for(var r,n=t.reactions;r=n.get();)Gs(r,t);t.notified=!1,e&&!t.rejection&&Vs(t)})))},Js=function(t,e,r){var n,o;Ks?((n=Bs.createEvent('Event')).promise=e,n.reason=r,n.initEvent(t,!1,!0),ns.dispatchEvent(n)):n={promise:e,reason:r},!Ds&&(o=ns['on'+t])?o(n):'unhandledrejection'===t&&As('Unhandled promise rejection',r)},Vs=function(t){is(gs,ns,(function(){var e,r=t.facade,n=t.value;if(Zs(t)&&(e=Ss((function(){js?Ms.emit('unhandledRejection',n,r):Js('unhandledrejection',r,n)})),t.rejection=js||Zs(t)?2:1,e.error))throw e.value}))},Zs=function(t){return 1!==t.rejection&&!t.parent},Xs=function(t){is(gs,ns,(function(){var e=t.facade;js?Ms.emit('rejectionHandled',e):Js('rejectionhandled',e,t.value)}))},ta=function(t,e,r){return function(n){t(e,n,r)}},ea=function(t,e,r){t.done||(t.done=!0,r&&(t=r),t.value=e,t.state=2,Ys(t,!0))},ra=function(t,e,r){if(!t.done){t.done=!0,r&&(t=r);try{if(t.facade===e)throw zs('Promise can\'t be resolved itself');var n=Ws(e);n?bs((function(){var r={done:!1};try{is(n,e,ta(ra,r,t),ta(ea,r,t))}catch(e){ea(r,e,t)}})):(t.value=e,t.state=1,Ys(t,!1))}catch(e){ea({done:!1},e,t)}}};Qs&&(Us=(qs=function(t){ps(this,Us),hs(t),is(Zi,this);var e=Ls(this);try{t(ta(ra,e),ta(ea,e))}catch(t){ea(e,t)}}).prototype,(Zi=function(t){Is(this,{type:xs,done:!1,notified:!1,parent:!1,reactions:new _s,rejection:!1,state:0,value:void 0})}).prototype=as(Us,{then:function(t,e){var r=Cs(this),n=Fs(ms(this,qs));return r.parent=!0,n.ok=!ls(t)||t,n.fail=ls(e)&&e,n.domain=js?Ms.domain:void 0,0==r.state?r.reactions.add(n):bs((function(){Gs(n,r)})),n.promise},catch:function(t){return this.then(void 0,t)}}),Xi=function(){var t=new Zi,e=Ls(t);this.promise=t,this.resolve=ta(ra,e),this.reject=ta(ea,e)},Es.f=Fs=function(t){return t===qs||t===ts?new Xi(t):$s(t)}),rs({global:!0,wrap:!0,forced:Qs},{Promise:qs}),us(qs,xs,!1,!0),cs(xs),ts=os(xs),rs({target:xs,stat:!0,forced:Qs},{reject:function(t){var e=Fs(this);return is(e.reject,void 0,t),e.promise}}),rs({target:xs,stat:!0,forced:true},{resolve:function(t){return ws(this===ts?qs:this,t)}}),rs({target:xs,stat:!0,forced:Hs},{all:function(t){var e=this,r=Fs(e),n=r.resolve,o=r.reject,i=Ss((function(){var r=hs(e.resolve),i=[],s=0,a=1;vs(t,(function(t){var u=s++,c=!1;a++,is(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=Ss((function(){var o=hs(e.resolve);vs(t,(function(t){is(o,e,t).then(r.resolve,n)}))}));return o.error&&n(o.value),r.promise}});var na=Er,oa=rt,ia=E,sa=lo,aa=Ei;Ar({target:'Promise',proto:!0,real:!0,forced:!!na&&c((function(){na.prototype.finally.call({then:function(){}},(function(){}))}))},{finally:function(t){var e=sa(this,oa('Promise')),r=ia(t);return this.then(r?function(r){return aa(e,t()).then((function(){return r}))}:t,r?function(r){return aa(e,t()).then((function(){throw r}))}:t)}});var ua=rt('Promise','finally');const ca=(()=>{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 ha,la,fa,pa,da,va,ya,ma={get:t=>function(t){const e=ca?ca.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{ca&&ca.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){ca&&ca.removeItem('_one-stat_'+t)}(t)}};!function(t){t.PROD='prod',t.VK_ALIAS='vk_alias',t.VIDEOTEST='videotest',t.TEST='test',t.AUTO='auto'}(ha||(ha={})),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=''}(fa||(fa={})),function(t){t.MP4='mp4',t.DASH='dash',t.HLS='hls',t.WEBM='webm'}(pa||(pa={})),function(t){t.AUTO='auto',t.MANUAL=''}(da||(da={})),function(t){t.HTTP1='http1',t.HTTP2='http2',t.HTTP3='http3'}(va||(va={})),function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(ya||(ya={}));const ga={[ha.PROD]:'https://api.ok.ru',[ha.VK_ALIAS]:'https://api.mycdn.me',[ha.VIDEOTEST]:'https://videotestapi.ok.ru/api',[ha.TEST]:'https://apitest.ok.ru',[ha.AUTO]:''},ba=1e3,wa=1.5,Aa=3e5,Ea=1e3;var Sa;!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'}(Sa||(Sa={}));class _a{constructor(e){this.consequentAuthErrors=0,this.authorized$=new t(!1),this.params=e;const r=ma.get('uuid');r?this.uuid=String(r):(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('')}(),ma.set('uuid',this.uuid))}authorize(t){return i(this,void 0,void 0,(function*(){return this.authToken=null!=t?t:yield this.refreshAuthToken(),this._authorizeWithBackoff()}))}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 i(this,void 0,void 0,(function*(){const r='log.externalLog',n=this.createLogParams(t),o=null!==(e=this.sessionKey)&&void 0!==e?e:yield this._authorizeWithBackoff();if(!o)return;const s=(t,e=this.params.requestRetryCount)=>i(this,void 0,void 0,(function*(){try{return yield this.params.apiTransport.sendRequest(r,n,o)}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 Sa.PARAM_SESSION_EXPIRED:case Sa.PARAM_SESSION_KEY:case Sa.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=yield this._authorizeWithBackoff(),e>0?s(t,e-1):void 0;case Sa.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=yield this.refreshAuthToken(),this.sessionKey=yield this._authorizeWithBackoff(),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)}))}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}refreshAuthToken(){return i(this,void 0,void 0,(function*(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=ua(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.19',platform:'WEB',items:t.map((t=>Object.assign(Object.assign({},t),{time:0,type:1})))})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const t=Math.min(Math.round(ba*Math.pow(wa,this.consequentAuthErrors-1)+Math.random()*Ea),Aa);return new Promise((e=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout((()=>{ua(this._authorize().then(e).catch((t=>this.params.error$.next({id:'AuthorizeBackoff',message:'Otherwise unhandle errror in authrization',thrown:t}))),(()=>this.backoffTimeoutId=0))}),t))}))}_authorize(){return i(this,void 0,void 0,(function*(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const t={session_data:{version:2,device_id:this.uuid,client_version:'1.0.19'.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=ua(this.params.apiTransport.sendRequest('auth.anonymLogin',t).then((t=>{var e;return t&&t.session_key||this.params.error$.next({id:'AuthorizeFailed',message:'No session key',data:t}),this.sessionKey=null!==(e=null==t?void 0:t.session_key)&&void 0!==e?e:void 0,this.sessionKey})).catch((t=>i(this,void 0,void 0,(function*(){this.sessionKey=void 0;const e=null==t?void 0:t.error_code;switch(e){case Sa.AUTH_LOGIN:return this.authToken=yield this.refreshAuthToken(),this._authorizeWithBackoff()}e?this.params.error$.next({id:`Authorize#${e}`,message:'authorize error',data:t}):this.params.error$.next({id:'AuthorizeUnknown',message:'authorize error',thrown:t})})))),(()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(void 0!==this.sessionKey)})),this.authorizePromise}))}}class Ta{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 Pa extends Ta{constructor(){super(),this.listeners||Ta.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 Oa(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 Pa,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',Pa.prototype[Symbol.toStringTag]='AbortSignal');const ja=Oa({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),ka=ja?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(!Oa({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,Ra=ja?ka.fetch:window.fetch;ja?ka.Request:window.Request;class xa{constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiEnv=t.apiEnv,this.apiBaseUrl=t.apiBaseUrl,this.isApiBaseUrlFetched=!1}resolveApiBaseUrl(){var t;return i(this,void 0,void 0,(function*(){if(this.apiEnv!==ha.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const e=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),r=yield Ra(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}),ga[ha.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 i(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(),Ra(`${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 La{constructor(t){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=o((()=>{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$,this.subscription=this.api.authorized$.subscribe((t=>{t&&this.debouncedFlush()}))}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(this.api.authorized$.getValue()?(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[]):t||this.api.authorize(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe()}}class Ia{constructor(t,o){var i;this.subscription=new e,this.statContext=t,this.config=Object.assign(Object.assign({},null!==(i=o.config)&&void 0!==i?i:{}),{requestRetryCount:1});const s=new r;this.experimental={error$:s};const a=new xa({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:ga[o.apiEnv],apiEnv:o.apiEnv,error$:s});this.api=new _a({apiTransport:a,refreshAuthToken:o.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:s}),this.logger=new La({api:this.api,error$:s}),this.subscription.add(n(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(),this.api.destroy(),this.logger.destroy()}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?ya.YES:!1===this.statContext.connectionReused?ya.NO:void 0,stat_type:!0===this.statContext.autoplay?da.AUTO:!1===this.statContext.autoplay?da.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{ha as ApiEnv,va as ConnectionType,pa as ContentType,Ia as OneStat,la as Quality,fa as ScreenDestination};
|
|
6
|
+
import{ValueSubject as t,getExponentialDelay as e,Subscription as r,Subject as n,fromEvent as o}from'@vkontakte/videoplayer-shared/es2015.esm.js';import i from'lodash/debounce';function s(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 a='undefined'!=typeof globalThis?globalThis:'undefined'!=typeof window?window:'undefined'!=typeof global?global:'undefined'!=typeof self?self:{},u=function(t){return t&&t.Math==Math&&t},c=u('object'==typeof globalThis&&globalThis)||u('object'==typeof window&&window)||u('object'==typeof self&&self)||u('object'==typeof a&&a)||function(){return this}()||Function('return this')(),h=function(t){try{return!!t()}catch(t){return!0}},l=!h((function(){var t=function(){}.bind();return'function'!=typeof t||t.hasOwnProperty('prototype')})),f=l,p=Function.prototype,d=p.apply,v=p.call,y='object'==typeof Reflect&&Reflect.apply||(f?v.bind(d):function(){return v.apply(d,arguments)}),m=l,g=Function.prototype,b=g.bind,w=g.call,A=m&&b.bind(w,w),E=m?function(t){return t&&A(t)}:function(t){return t&&function(){return w.apply(t,arguments)}},_=function(t){return'function'==typeof t},S={},O=!h((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),P=l,T=Function.prototype.call,k=P?T.bind(T):function(){return T.apply(T,arguments)},j={},R={}.propertyIsEnumerable,x=Object.getOwnPropertyDescriptor,L=x&&!R.call({1:2},1);j.f=L?function(t){var e=x(this,t);return!!e&&e.enumerable}:R;var I,C,N=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},q=E,U=q({}.toString),z=q(''.slice),B=function(t){return z(U(t),8,-1)},F=E,M=h,$=B,D=c.Object,K=F(''.split),H=M((function(){return!D('z').propertyIsEnumerable(0)}))?function(t){return'String'==$(t)?K(t,''):D(t)}:D,Q=c.TypeError,W=function(t){if(null==t)throw Q('Can\'t call method on '+t);return t},G=H,Y=W,J=_,V=function(t){return'object'==typeof t?null!==t:J(t)},Z={},X=Z,tt=c,et=_,rt=function(t){return et(t)?t:void 0},nt=function(t,e){return arguments.length<2?rt(X[t])||rt(tt[t]):X[t]&&X[t][e]||tt[t]&&tt[t][e]},ot=E({}.isPrototypeOf),it=nt('navigator','userAgent')||'',st=c,at=it,ut=st.process,ct=st.Deno,ht=ut&&ut.versions||ct&&ct.version,lt=ht&&ht.v8;lt&&(C=(I=lt.split('.'))[0]>0&&I[0]<4?1:+(I[0]+I[1])),!C&&at&&(!(I=at.match(/Edge\/(\d+)/))||I[1]>=74)&&(I=at.match(/Chrome\/(\d+)/))&&(C=+I[1]);var ft=C,pt=ft,dt=h,vt=!!Object.getOwnPropertySymbols&&!dt((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&pt&&pt<41})),yt=vt&&!Symbol.sham&&'symbol'==typeof Symbol.iterator,mt=nt,gt=_,bt=ot,wt=yt,At=c.Object,Et=wt?function(t){return'symbol'==typeof t}:function(t){var e=mt('Symbol');return gt(e)&&bt(e.prototype,At(t))},_t=c.String,St=function(t){try{return _t(t)}catch(t){return'Object'}},Ot=_,Pt=St,Tt=c.TypeError,kt=function(t){if(Ot(t))return t;throw Tt(Pt(t)+' is not a function')},jt=kt,Rt=function(t,e){var r=t[e];return null==r?void 0:jt(r)},xt=k,Lt=_,It=V,Ct=c.TypeError,Nt={exports:{}},qt=c,Ut=Object.defineProperty,zt=function(t,e){try{Ut(qt,t,{value:e,configurable:!0,writable:!0})}catch(r){qt[t]=e}return e},Bt=c['__core-js_shared__']||zt('__core-js_shared__',{}),Ft=Bt;(Nt.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 Mt=W,$t=c.Object,Dt=function(t){return $t(Mt(t))},Kt=E({}.hasOwnProperty),Ht=Object.hasOwn||function(t,e){return Kt(Dt(t),e)},Qt=E,Wt=0,Gt=Math.random(),Yt=Qt(1..toString),Jt=function(t){return'Symbol('+(void 0===t?'':t)+')_'+Yt(++Wt+Gt,36)},Vt=c,Zt=Nt.exports,Xt=Ht,te=Jt,ee=vt,re=yt,ne=Zt('wks'),oe=Vt.Symbol,ie=oe&&oe.for,se=re?oe:oe&&oe.withoutSetter||te,ae=function(t){if(!Xt(ne,t)||!ee&&'string'!=typeof ne[t]){var e='Symbol.'+t;ee&&Xt(oe,t)?ne[t]=oe[t]:ne[t]=re&&ie?ie(e):se(e)}return ne[t]},ue=k,ce=V,he=Et,le=Rt,fe=function(t,e){var r,n;if('string'===e&&Lt(r=t.toString)&&!It(n=xt(r,t)))return n;if(Lt(r=t.valueOf)&&!It(n=xt(r,t)))return n;if('string'!==e&&Lt(r=t.toString)&&!It(n=xt(r,t)))return n;throw Ct('Can\'t convert object to primitive value')},pe=ae,de=c.TypeError,ve=pe('toPrimitive'),ye=function(t,e){if(!ce(t)||he(t))return t;var r,n=le(t,ve);if(n){if(void 0===e&&(e='default'),r=ue(n,t,e),!ce(r)||he(r))return r;throw de('Can\'t convert object to primitive value')}return void 0===e&&(e='number'),fe(t,e)},me=Et,ge=function(t){var e=ye(t,'string');return me(e)?e:e+''},be=V,we=c.document,Ae=be(we)&&be(we.createElement),Ee=function(t){return Ae?we.createElement(t):{}},_e=Ee,Se=!O&&!h((function(){return 7!=Object.defineProperty(_e('div'),'a',{get:function(){return 7}}).a})),Oe=O,Pe=k,Te=j,ke=N,je=function(t){return G(Y(t))},Re=ge,xe=Ht,Le=Se,Ie=Object.getOwnPropertyDescriptor;S.f=Oe?Ie:function(t,e){if(t=je(t),e=Re(e),Le)try{return Ie(t,e)}catch(t){}if(xe(t,e))return ke(!Pe(Te.f,t,e),t[e])};var Ce=h,Ne=_,qe=/#|\.prototype\./,Ue=function(t,e){var r=Be[ze(t)];return r==Me||r!=Fe&&(Ne(e)?Ce(e):!!e)},ze=Ue.normalize=function(t){return String(t).replace(qe,'.').toLowerCase()},Be=Ue.data={},Fe=Ue.NATIVE='N',Me=Ue.POLYFILL='P',$e=Ue,De=kt,Ke=l,He=E(E.bind),Qe=function(t,e){return De(t),void 0===e?t:Ke?He(t,e):function(){return t.apply(e,arguments)}},We={},Ge=O&&h((function(){return 42!=Object.defineProperty((function(){}),'prototype',{value:42,writable:!1}).prototype})),Ye=c,Je=V,Ve=Ye.String,Ze=Ye.TypeError,Xe=function(t){if(Je(t))return t;throw Ze(Ve(t)+' is not an object')},tr=O,er=Se,rr=Ge,nr=Xe,or=ge,ir=c.TypeError,sr=Object.defineProperty,ar=Object.getOwnPropertyDescriptor;We.f=tr?rr?function(t,e,r){if(nr(t),e=or(e),nr(r),'function'==typeof t&&'prototype'===e&&'value'in r&&'writable'in r&&!r.writable){var n=ar(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 sr(t,e,r)}:sr:function(t,e,r){if(nr(t),e=or(e),nr(r),er)try{return sr(t,e,r)}catch(t){}if('get'in r||'set'in r)throw ir('Accessors not supported');return'value'in r&&(t[e]=r.value),t};var ur=We,cr=N,hr=O?function(t,e,r){return ur.f(t,e,cr(1,r))}:function(t,e,r){return t[e]=r,t},lr=c,fr=y,pr=E,dr=_,vr=S.f,yr=$e,mr=Z,gr=Qe,br=hr,wr=Ht,Ar=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 fr(t,this,arguments)};return e.prototype=t.prototype,e},Er=function(t,e){var r,n,o,i,s,a,u,c,h=t.target,l=t.global,f=t.stat,p=t.proto,d=l?lr:f?lr[h]:(lr[h]||{}).prototype,v=l?mr:mr[h]||br(mr,h,{})[h],y=v.prototype;for(o in e)r=!yr(l?o:h+(f?'.':'#')+o,t.forced)&&d&&wr(d,o),s=v[o],r&&(a=t.noTargetGet?(c=vr(d,o))&&c.value:d[o]),i=r&&a?a:e[o],r&&typeof s==typeof i||(u=t.bind&&r?gr(i,lr):t.wrap&&r?Ar(i):p&&dr(i)?pr(i):i,(t.sham||i&&i.sham||s&&s.sham)&&br(u,'sham',!0),br(v,o,u),p&&(wr(mr,n=h+'Prototype')||br(mr,n,{}),br(mr[n],o,i),t.real&&y&&!y[o]&&br(y,o,i)))},_r=c.Promise,Sr=hr,Or=function(t,e,r,n){n&&n.enumerable?t[e]=r:Sr(t,e,r)},Pr=c,Tr=(Pr.String,Pr.TypeError,E);Object.setPrototypeOf||'__proto__'in{}&&function(){var t,e=!1,r={};try{(t=Tr(Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').set))(r,[]),e=r instanceof Array}catch(t){}}();var kr={};kr[ae('toStringTag')]='z';var jr='[object z]'===String(kr),Rr=c,xr=jr,Lr=_,Ir=B,Cr=ae('toStringTag'),Nr=Rr.Object,qr='Arguments'==Ir(function(){return arguments}()),Ur=xr?Ir: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=Nr(t),Cr))?r:qr?Ir(e):'Object'==(n=Ir(e))&&Lr(e.callee)?'Arguments':n},zr=Ur,Br=jr?{}.toString:function(){return'[object '+zr(this)+']'},Fr=jr,Mr=We.f,$r=hr,Dr=Ht,Kr=Br,Hr=ae('toStringTag'),Qr=nt,Wr=We,Gr=O,Yr=ae('species'),Jr=ot,Vr=c.TypeError,Zr=_,Xr=Bt,tn=E(Function.toString);Zr(Xr.inspectSource)||(Xr.inspectSource=function(t){return tn(t)});var en=Xr.inspectSource,rn={},nn=rn,on=ae('iterator'),sn=Array.prototype,an=Math.ceil,un=Math.floor,cn=function(t){var e=+t;return e!=e||0===e?0:(e>0?un:an)(e)},hn=Math.min,ln=function(t){return t>0?hn(cn(t),9007199254740991):0},fn=Ur,pn=Rt,dn=rn,vn=ae('iterator'),yn=function(t){if(null!=t)return pn(t,vn)||pn(t,'@@iterator')||dn[fn(t)]},mn=k,gn=kt,bn=Xe,wn=St,An=yn,En=c.TypeError,_n=k,Sn=Xe,On=Rt,Pn=Qe,Tn=k,kn=Xe,jn=St,Rn=function(t){return void 0!==t&&(nn.Array===t||sn[on]===t)},xn=function(t){return ln(t.length)},Ln=ot,In=function(t,e){var r=arguments.length<2?An(t):e;if(gn(r))return bn(mn(r,t));throw En(wn(t)+' is not iterable')},Cn=yn,Nn=function(t,e,r){var n,o;Sn(t);try{if(!(n=On(t,'return'))){if('throw'===e)throw r;return r}n=_n(n,t)}catch(t){o=!0,n=t}if('throw'===e)throw r;if(o)throw n;return Sn(n),r},qn=c.TypeError,Un=function(t,e){this.stopped=t,this.result=e},zn=Un.prototype,Bn=ae('iterator'),Fn=!1;try{var Mn=0,$n={next:function(){return{done:!!Mn++}},return:function(){Fn=!0}};$n[Bn]=function(){return this},Array.from($n,(function(){throw 2}))}catch(t){}var Dn=E,Kn=h,Hn=_,Qn=Ur,Wn=en,Gn=function(){},Yn=[],Jn=nt('Reflect','construct'),Vn=/^\s*(?:class|function)\b/,Zn=Dn(Vn.exec),Xn=!Vn.exec(Gn),to=function(t){if(!Hn(t))return!1;try{return Jn(Gn,Yn,t),!0}catch(t){return!1}},eo=function(t){if(!Hn(t))return!1;switch(Qn(t)){case'AsyncFunction':case'GeneratorFunction':case'AsyncGeneratorFunction':return!1}try{return Xn||!!Zn(Vn,Wn(t))}catch(t){return!0}};eo.sham=!0;var ro,no,oo,io,so=!Jn||Kn((function(){var t;return to(to.call)||!to(Object)||!to((function(){t=!0}))||t}))?eo:to,ao=St,uo=c.TypeError,co=Xe,ho=function(t){if(so(t))return t;throw uo(ao(t)+' is not a constructor')},lo=ae('species'),fo=function(t,e){var r,n=co(t).constructor;return void 0===n||null==(r=co(n)[lo])?e:ho(r)},po=nt('document','documentElement'),vo=E([].slice),yo=c.TypeError,mo=/(?:ipad|iphone|ipod).*applewebkit/i.test(it),go='process'==B(c.process),bo=c,wo=y,Ao=Qe,Eo=_,_o=Ht,So=h,Oo=po,Po=vo,To=Ee,ko=function(t,e){if(t<e)throw yo('Not enough arguments');return t},jo=mo,Ro=go,xo=bo.setImmediate,Lo=bo.clearImmediate,Io=bo.process,Co=bo.Dispatch,No=bo.Function,qo=bo.MessageChannel,Uo=bo.String,zo=0,Bo={};try{ro=bo.location}catch(t){}var Fo=function(t){if(_o(Bo,t)){var e=Bo[t];delete Bo[t],e()}},Mo=function(t){return function(){Fo(t)}},$o=function(t){Fo(t.data)},Do=function(t){bo.postMessage(Uo(t),ro.protocol+'//'+ro.host)};xo&&Lo||(xo=function(t){ko(arguments.length,1);var e=Eo(t)?t:No(t),r=Po(arguments,1);return Bo[++zo]=function(){wo(e,void 0,r)},no(zo),zo},Lo=function(t){delete Bo[t]},Ro?no=function(t){Io.nextTick(Mo(t))}:Co&&Co.now?no=function(t){Co.now(Mo(t))}:qo&&!jo?(io=(oo=new qo).port2,oo.port1.onmessage=$o,no=Ao(io.postMessage,io)):bo.addEventListener&&Eo(bo.postMessage)&&!bo.importScripts&&ro&&'file:'!==ro.protocol&&!So(Do)?(no=Do,bo.addEventListener('message',$o,!1)):no='onreadystatechange'in To('script')?function(t){Oo.appendChild(To('script')).onreadystatechange=function(){Oo.removeChild(this),Fo(t)}}:function(t){setTimeout(Mo(t),0)});var Ko,Ho,Qo,Wo,Go,Yo,Jo,Vo,Zo={set:xo,clear:Lo},Xo=c,ti=/ipad|iphone|ipod/i.test(it)&&void 0!==Xo.Pebble,ei=/web0s(?!.*chrome)/i.test(it),ri=c,ni=Qe,oi=S.f,ii=Zo.set,si=mo,ai=ti,ui=ei,ci=go,hi=ri.MutationObserver||ri.WebKitMutationObserver,li=ri.document,fi=ri.process,pi=ri.Promise,di=oi(ri,'queueMicrotask'),vi=di&&di.value;vi||(Ko=function(){var t,e;for(ci&&(t=fi.domain)&&t.exit();Ho;){e=Ho.fn,Ho=Ho.next;try{e()}catch(t){throw Ho?Wo():Qo=void 0,t}}Qo=void 0,t&&t.enter()},si||ci||ui||!hi||!li?!ai&&pi&&pi.resolve?((Jo=pi.resolve(void 0)).constructor=pi,Vo=ni(Jo.then,Jo),Wo=function(){Vo(Ko)}):ci?Wo=function(){fi.nextTick(Ko)}:(ii=ni(ii,ri),Wo=function(){ii(Ko)}):(Go=!0,Yo=li.createTextNode(''),new hi(Ko).observe(Yo,{characterData:!0}),Wo=function(){Yo.data=Go=!Go}));var yi=vi||function(t){var e={fn:t,next:void 0};Qo&&(Qo.next=e),Ho||(Ho=e,Wo()),Qo=e},mi={},gi=kt,bi=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=gi(e),this.reject=gi(r)};mi.f=function(t){return new bi(t)};var wi=Xe,Ai=V,Ei=mi,_i=function(t,e){if(wi(t),Ai(e)&&e.constructor===t)return e;var r=Ei.f(t);return(0,r.resolve)(e),r.promise},Si=c,Oi=function(){this.head=null,this.tail=null};Oi.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 Pi,Ti,ki,ji=Oi,Ri=_,xi=en,Li=c.WeakMap,Ii=Ri(Li)&&/native code/.test(xi(Li)),Ci=Nt.exports,Ni=Jt,qi=Ci('keys'),Ui=Ii,zi=c,Bi=E,Fi=V,Mi=hr,$i=Ht,Di=Bt,Ki=function(t){return qi[t]||(qi[t]=Ni(t))},Hi={},Qi=zi.TypeError,Wi=zi.WeakMap;if(Ui||Di.state){var Gi=Di.state||(Di.state=new Wi),Yi=Bi(Gi.get),Ji=Bi(Gi.has),Vi=Bi(Gi.set);Pi=function(t,e){if(Ji(Gi,t))throw new Qi('Object already initialized');return e.facade=t,Vi(Gi,t,e),e},Ti=function(t){return Yi(Gi,t)||{}},ki=function(t){return Ji(Gi,t)}}else{var Zi=Ki('state');Hi[Zi]=!0,Pi=function(t,e){if($i(t,Zi))throw new Qi('Object already initialized');return e.facade=t,Mi(t,Zi,e),e},Ti=function(t){return $i(t,Zi)?t[Zi]:{}},ki=function(t){return $i(t,Zi)}}var Xi,ts,es,rs='object'==typeof window,ns=Er,os=c,is=nt,ss=k,as=_r,us=function(t,e,r){for(var n in e)r&&r.unsafe&&t[n]?t[n]=e[n]:Or(t,n,e[n],r);return t},cs=function(t,e,r,n){if(t){var o=r?t:t.prototype;Dr(o,Hr)||Mr(o,Hr,{configurable:!0,value:e}),n&&!Fr&&$r(o,'toString',Kr)}},hs=function(t){var e=Qr(t),r=Wr.f;Gr&&e&&!e[Yr]&&r(e,Yr,{configurable:!0,get:function(){return this}})},ls=kt,fs=_,ps=V,ds=function(t,e){if(Jr(e,t))return t;throw Vr('Incorrect invocation')},vs=en,ys=function(t,e,r){var n,o,i,s,a,u,c,h=r&&r.that,l=!(!r||!r.AS_ENTRIES),f=!(!r||!r.IS_ITERATOR),p=!(!r||!r.INTERRUPTED),d=Pn(e,h),v=function(t){return n&&Nn(n,'normal',t),new Un(!0,t)},y=function(t){return l?(kn(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=Cn(t)))throw qn(jn(t)+' is not iterable');if(Rn(o)){for(i=0,s=xn(t);s>i;i++)if((a=y(t[i]))&&Ln(zn,a))return a;return new Un(!1)}n=In(t,o)}for(u=n.next;!(c=Tn(u,n)).done;){try{a=y(c.value)}catch(t){Nn(n,'throw',t)}if('object'==typeof a&&a&&Ln(zn,a))return a}return new Un(!1)},ms=function(t,e){if(!e&&!Fn)return!1;var r=!1;try{var n={};n[Bn]=function(){return{next:function(){return{done:r=!0}}}},t(n)}catch(t){}return r},gs=fo,bs=Zo.set,ws=yi,As=_i,Es=function(t,e){var r=Si.console;r&&r.error&&(1==arguments.length?r.error(t):r.error(t,e))},_s=mi,Ss=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},Os=ji,Ps={set:Pi,get:Ti,has:ki,enforce:function(t){return ki(t)?Ti(t):Pi(t,{})},getterFor:function(t){return function(e){var r;if(!Fi(e)||(r=Ti(e)).type!==t)throw Qi('Incompatible receiver, '+t+' required');return r}}},Ts=$e,ks=rs,js=go,Rs=ft,xs=ae('species'),Ls='Promise',Is=Ps.getterFor(Ls),Cs=Ps.set,Ns=Ps.getterFor(Ls),qs=as&&as.prototype,Us=as,zs=qs,Bs=os.TypeError,Fs=os.document,Ms=os.process,$s=_s.f,Ds=$s,Ks=!!(Fs&&Fs.createEvent&&os.dispatchEvent),Hs=fs(os.PromiseRejectionEvent),Qs=Ts(Ls,(function(){var t=vs(Us),e=t!==String(Us);if(!e&&66===Rs)return!0;if(!zs.finally)return!0;if(Rs>=51&&/native code/.test(t))return!1;var r=new Us((function(t){t(1)})),n=function(t){t((function(){}),(function(){}))};return(r.constructor={})[xs]=n,!(r.then((function(){}))instanceof n)||!e&&ks&&!Hs})),Ws=Qs||!ms((function(t){Us.all(t).catch((function(){}))})),Gs=function(t){var e;return!(!ps(t)||!fs(e=t.then))&&e},Ys=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,h=t.domain;try{a?(s||(2===e.rejection&&ta(e),e.rejection=1),!0===a?r=i:(h&&h.enter(),r=a(i),h&&(h.exit(),o=!0)),r===t.promise?c(Bs('Promise-chain cycle')):(n=Gs(r))?ss(n,r,u,c):u(r)):c(i)}catch(t){h&&!o&&h.exit(),c(t)}},Js=function(t,e){t.notified||(t.notified=!0,ws((function(){for(var r,n=t.reactions;r=n.get();)Ys(r,t);t.notified=!1,e&&!t.rejection&&Zs(t)})))},Vs=function(t,e,r){var n,o;Ks?((n=Fs.createEvent('Event')).promise=e,n.reason=r,n.initEvent(t,!1,!0),os.dispatchEvent(n)):n={promise:e,reason:r},!Hs&&(o=os['on'+t])?o(n):'unhandledrejection'===t&&Es('Unhandled promise rejection',r)},Zs=function(t){ss(bs,os,(function(){var e,r=t.facade,n=t.value;if(Xs(t)&&(e=Ss((function(){js?Ms.emit('unhandledRejection',n,r):Vs('unhandledrejection',r,n)})),t.rejection=js||Xs(t)?2:1,e.error))throw e.value}))},Xs=function(t){return 1!==t.rejection&&!t.parent},ta=function(t){ss(bs,os,(function(){var e=t.facade;js?Ms.emit('rejectionHandled',e):Vs('rejectionhandled',e,t.value)}))},ea=function(t,e,r){return function(n){t(e,n,r)}},ra=function(t,e,r){t.done||(t.done=!0,r&&(t=r),t.value=e,t.state=2,Js(t,!0))},na=function(t,e,r){if(!t.done){t.done=!0,r&&(t=r);try{if(t.facade===e)throw Bs('Promise can\'t be resolved itself');var n=Gs(e);n?ws((function(){var r={done:!1};try{ss(n,e,ea(na,r,t),ea(ra,r,t))}catch(e){ra(r,e,t)}})):(t.value=e,t.state=1,Js(t,!1))}catch(e){ra({done:!1},e,t)}}};Qs&&(zs=(Us=function(t){ds(this,zs),ls(t),ss(Xi,this);var e=Is(this);try{t(ea(na,e),ea(ra,e))}catch(t){ra(e,t)}}).prototype,(Xi=function(t){Cs(this,{type:Ls,done:!1,notified:!1,parent:!1,reactions:new Os,rejection:!1,state:0,value:void 0})}).prototype=us(zs,{then:function(t,e){var r=Ns(this),n=$s(gs(this,Us));return r.parent=!0,n.ok=!fs(t)||t,n.fail=fs(e)&&e,n.domain=js?Ms.domain:void 0,0==r.state?r.reactions.add(n):ws((function(){Ys(n,r)})),n.promise},catch:function(t){return this.then(void 0,t)}}),ts=function(){var t=new Xi,e=Is(t);this.promise=t,this.resolve=ea(na,e),this.reject=ea(ra,e)},_s.f=$s=function(t){return t===Us||t===es?new ts(t):Ds(t)}),ns({global:!0,wrap:!0,forced:Qs},{Promise:Us}),cs(Us,Ls,!1,!0),hs(Ls),es=is(Ls),ns({target:Ls,stat:!0,forced:Qs},{reject:function(t){var e=$s(this);return ss(e.reject,void 0,t),e.promise}}),ns({target:Ls,stat:!0,forced:true},{resolve:function(t){return As(this===es?Us:this,t)}}),ns({target:Ls,stat:!0,forced:Ws},{all:function(t){var e=this,r=$s(e),n=r.resolve,o=r.reject,i=Ss((function(){var r=ls(e.resolve),i=[],s=0,a=1;ys(t,(function(t){var u=s++,c=!1;a++,ss(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=$s(e),n=r.reject,o=Ss((function(){var o=ls(e.resolve);ys(t,(function(t){ss(o,e,t).then(r.resolve,n)}))}));return o.error&&n(o.value),r.promise}});var oa=_r,ia=nt,sa=_,aa=fo,ua=_i;Er({target:'Promise',proto:!0,real:!0,forced:!!oa&&h((function(){oa.prototype.finally.call({then:function(){}},(function(){}))}))},{finally:function(t){var e=aa(this,ia('Promise')),r=sa(t);return this.then(r?function(r){return ua(e,t()).then((function(){return r}))}:t,r?function(r){return ua(e,t()).then((function(){throw r}))}:t)}});var ca=nt('Promise','finally');const ha=(()=>{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 la,fa,pa,da,va,ya,ma,ga={get:t=>function(t){const e=ha?ha.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{ha&&ha.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){ha&&ha.removeItem('_one-stat_'+t)}(t)}};!function(t){t.PROD='prod',t.VK_ALIAS='vk_alias',t.VIDEOTEST='videotest',t.TEST='test',t.AUTO='auto'}(la||(la={})),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'}(fa||(fa={})),function(t){t.CHROMECAST='chromecast',t.APPLE_TV='appletv',t.PIP='pip',t.HEADPHONES='externalHeadphones',t.SCREEN=''}(pa||(pa={})),function(t){t.MP4='mp4',t.DASH='dash',t.DASH_SEP='dash_sep',t.ONDEMAND_DASH='ondemand_dash',t.HLS='hls',t.ONDEMAND_HLS='ondemand_hls',t.WEBM='webm'}(da||(da={})),function(t){t.AUTO='auto',t.MANUAL=''}(va||(va={})),function(t){t.HTTP1='http1',t.HTTP2='http2',t.HTTP3='http3'}(ya||(ya={})),function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(ma||(ma={}));const ba={[la.PROD]:'https://api.ok.ru',[la.VK_ALIAS]:'https://api.mycdn.me',[la.VIDEOTEST]:'https://videotestapi.ok.ru/api',[la.TEST]:'https://apitest.ok.ru',[la.AUTO]:''},wa={start:1e3,factor:1.5,max:3e5,random:1e3};var Aa;!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'}(Aa||(Aa={}));class Ea{constructor(e){this.consequentAuthErrors=0,this.authorized$=new t(!1),this.params=e;const r=ga.get('uuid');r?this.uuid=String(r):(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('')}(),ga.set('uuid',this.uuid))}authorize(t){return s(this,void 0,void 0,(function*(){return this.authToken=null!=t?t:yield this.refreshAuthToken(),this._authorizeWithBackoff()}))}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 s(this,void 0,void 0,(function*(){const r='log.externalLog',n=this.createLogParams(t),o=null!==(e=this.sessionKey)&&void 0!==e?e:yield this._authorizeWithBackoff();if(!o)return;const i=(t,e=this.params.requestRetryCount)=>s(this,void 0,void 0,(function*(){try{return yield this.params.apiTransport.sendRequest(r,n,o)}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 Aa.PARAM_SESSION_EXPIRED:case Aa.PARAM_SESSION_KEY:case Aa.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=yield this._authorizeWithBackoff(),e>0?i(t,e-1):void 0;case Aa.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=yield this.refreshAuthToken(),this.sessionKey=yield this._authorizeWithBackoff(),e>0?i(t,e-1):void 0;default:return void this.params.error$.next({id:`LogRequest#${o}`,message:`${r} error`,data:n})}}}));return i(t)}))}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}refreshAuthToken(){return s(this,void 0,void 0,(function*(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=ca(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.20',platform:'WEB',items:t.map((t=>Object.assign(Object.assign({},t),{time:0,type:1})))})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const t=e(this.consequentAuthErrors,wa);return new Promise((e=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout((()=>{ca(this._authorize().then(e).catch((t=>this.params.error$.next({id:'AuthorizeBackoff',message:'Otherwise unhandle errror in authrization',thrown:t}))),(()=>this.backoffTimeoutId=0))}),t))}))}_authorize(){return s(this,void 0,void 0,(function*(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const t={session_data:{version:2,device_id:this.uuid,client_version:'1.0.20'.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=ca(this.params.apiTransport.sendRequest('auth.anonymLogin',t).then((t=>{var e;return t&&t.session_key||this.params.error$.next({id:'AuthorizeFailed',message:'No session key',data:t}),this.sessionKey=null!==(e=null==t?void 0:t.session_key)&&void 0!==e?e:void 0,this.sessionKey})).catch((t=>s(this,void 0,void 0,(function*(){this.sessionKey=void 0;const e=null==t?void 0:t.error_code;switch(e){case Aa.AUTH_LOGIN:return this.authToken=yield this.refreshAuthToken(),this._authorizeWithBackoff()}e?this.params.error$.next({id:`Authorize#${e}`,message:'authorize error',data:t}):this.params.error$.next({id:'AuthorizeUnknown',message:'authorize error',thrown:t})})))),(()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(void 0!==this.sessionKey)})),this.authorizePromise}))}}class _a{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 Sa extends _a{constructor(){super(),this.listeners||_a.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 Oa(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 Sa,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',Sa.prototype[Symbol.toStringTag]='AbortSignal');const Pa=Oa({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Ta=Pa?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(!Oa({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,ka=Pa?Ta.fetch:window.fetch;Pa?Ta.Request:window.Request;class ja{constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiEnv=t.apiEnv,this.apiBaseUrl=t.apiBaseUrl,this.isApiBaseUrlFetched=!1}resolveApiBaseUrl(){var t;return s(this,void 0,void 0,(function*(){if(this.apiEnv!==la.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const e=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),r=yield ka(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}),ba[la.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 s(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(),ka(`${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 Ra{constructor(t){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=i((()=>{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$,this.subscription=this.api.authorized$.subscribe((t=>{t&&this.debouncedFlush()}))}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(this.api.authorized$.getValue()?(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[]):t||this.api.authorize(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe()}}class xa{constructor(t,e){var i;this.subscription=new r,this.statContext=t,this.config=Object.assign(Object.assign({},null!==(i=e.config)&&void 0!==i?i:{}),{requestRetryCount:1});const s=new n;this.experimental={error$:s};const a=new ja({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:ba[e.apiEnv],apiEnv:e.apiEnv,error$:s});this.api=new Ea({apiTransport:a,refreshAuthToken:e.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:s}),this.logger=new Ra({api:this.api,error$:s}),this.subscription.add(o(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(),this.api.destroy(),this.logger.destroy()}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?ma.YES:!1===this.statContext.connectionReused?ma.NO:void 0,stat_type:!0===this.statContext.autoplay?va.AUTO:!1===this.statContext.autoplay?va.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode};return void 0!==e&&(n.param=e),{operation:t,timestamp:r,custom:n}}}export{la as ApiEnv,ya as ConnectionType,da as ContentType,xa as OneStat,fa as Quality,pa as ScreenDestination};
|
package/es2018.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-statistics v1.0.
|
|
3
|
-
* Tue,
|
|
4
|
-
* https://st.mycdn.me/static/playersdk/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-statistics v1.0.20
|
|
3
|
+
* Tue, 09 Aug 2022 12:30:38 GMT
|
|
4
|
+
* https://st.mycdn.me/static/playersdk/1-0-20/doc/
|
|
5
5
|
*/
|
|
6
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var t=require('@vkontakte/videoplayer-shared/es2018.cjs.js');function e(t){return t&&'object'==typeof t&&'default'in t?t:{default:t}}var r=e(require('lodash/debounce'));const s=(()=>{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 o,i,n,a,h,u,l,c={get:t=>function(t){const e=s?s.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{s&&s.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){s&&s.removeItem('_one-stat_'+t)}(t)}};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(t){t.AUTO='auto',t.MANUAL=''}(h||(h={})),exports.ConnectionType=void 0,(u=exports.ConnectionType||(exports.ConnectionType={})).HTTP1='http1',u.HTTP2='http2',u.HTTP3='http3',function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(l||(l={}));const p={[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]:''},d=1e3,m=1.5,g=3e5,f=1e3;var y;!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'}(y||(y={}));class v{constructor(e){this.consequentAuthErrors=0,this.authorized$=new t.ValueSubject(!1),this.params=e;const r=c.get('uuid');r?this.uuid=String(r):(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('')}(),c.set('uuid',this.uuid))}async authorize(t){return this.authToken=null!=t?t:await this.refreshAuthToken(),this._authorizeWithBackoff()}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._authorizeWithBackoff();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 y.PARAM_SESSION_EXPIRED:case y.PARAM_SESSION_KEY:case y.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=await this._authorizeWithBackoff(),e>0?i(t,e-1):void 0;case y.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorizeWithBackoff(),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)}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}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.19',platform:'WEB',items:t.map((t=>({...t,time:0,type:1})))})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const t=Math.min(Math.round(d*m**(this.consequentAuthErrors-1)+Math.random()*f),g);return new Promise((e=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout((()=>{this._authorize().then(e).catch((t=>this.params.error$.next({id:'AuthorizeBackoff',message:'Otherwise unhandle errror in authrization',thrown:t}))).finally((()=>this.backoffTimeoutId=0))}),t))}))}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const t={session_data:{version:2,device_id:this.uuid,client_version:'1.0.19'.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('auth.anonymLogin',t).then((t=>{var e;return t&&t.session_key||this.params.error$.next({id:'AuthorizeFailed',message:'No session key',data:t}),this.sessionKey=null!==(e=null==t?void 0:t.session_key)&&void 0!==e?e:void 0,this.sessionKey})).catch((async t=>{this.sessionKey=void 0;const e=null==t?void 0:t.error_code;switch(e){case y.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}e?this.params.error$.next({id:`Authorize#${e}`,message:'authorize error',data:t}):this.params.error$.next({id:'AuthorizeUnknown',message:'authorize error',thrown:t})})).finally((()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(void 0!==this.sessionKey)})),this.authorizePromise}}class A{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 b extends A{constructor(){super(),this.listeners||A.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 w(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 b,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',b.prototype[Symbol.toStringTag]='AbortSignal');const _=w({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),E=_?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(!w({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,T=_?E.fetch:window.fetch;_?E.Request:window.Request;class S{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!==exports.ApiEnv.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const e=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),r=await T(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}),p[exports.ApiEnv.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(),T(`${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=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$,this.subscription=this.api.authorized$.subscribe((t=>{t&&this.debouncedFlush()}))}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(this.api.authorized$.getValue()?(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[]):t||this.api.authorize(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe()}}exports.OneStat=class{constructor(e,r){var s;this.subscription=new t.Subscription,this.statContext=e,this.config={...null!==(s=r.config)&&void 0!==s?s:{},requestRetryCount:1};const o=new t.Subject;this.experimental={error$:o};const i=new S({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:p[r.apiEnv],apiEnv:r.apiEnv,error$:o});this.api=new v({apiTransport:i,refreshAuthToken:r.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:o}),this.logger=new P({api:this.api,error$:o}),this.subscription.add(t.fromEvent(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(),this.api.destroy(),this.logger.destroy()}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?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!==e&&(s.param=e),{operation:t,timestamp:r,custom:s}}};
|
|
6
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var t=require('@vkontakte/videoplayer-shared/es2018.cjs.js');function e(t){return t&&'object'==typeof t&&'default'in t?t:{default:t}}var r=e(require('lodash/debounce'));const s=(()=>{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 o,i,n,a,h,u,l,c={get:t=>function(t){const e=s?s.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{s&&s.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){s&&s.removeItem('_one-stat_'+t)}(t)}};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.DASH_SEP='dash_sep',a.ONDEMAND_DASH='ondemand_dash',a.HLS='hls',a.ONDEMAND_HLS='ondemand_hls',a.WEBM='webm',function(t){t.AUTO='auto',t.MANUAL=''}(h||(h={})),exports.ConnectionType=void 0,(u=exports.ConnectionType||(exports.ConnectionType={})).HTTP1='http1',u.HTTP2='http2',u.HTTP3='http3',function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(l||(l={}));const p={[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]:''},d={start:1e3,factor:1.5,max:3e5,random:1e3};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(e){this.consequentAuthErrors=0,this.authorized$=new t.ValueSubject(!1),this.params=e;const r=c.get('uuid');r?this.uuid=String(r):(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('')}(),c.set('uuid',this.uuid))}async authorize(t){return this.authToken=null!=t?t:await this.refreshAuthToken(),this._authorizeWithBackoff()}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._authorizeWithBackoff();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.authorized$.next(!1),this.sessionKey=await this._authorizeWithBackoff(),e>0?i(t,e-1):void 0;case m.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorizeWithBackoff(),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)}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}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.20',platform:'WEB',items:t.map((t=>({...t,time:0,type:1})))})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const e=t.getExponentialDelay(this.consequentAuthErrors,d);return new Promise((t=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout((()=>{this._authorize().then(t).catch((t=>this.params.error$.next({id:'AuthorizeBackoff',message:'Otherwise unhandle errror in authrization',thrown:t}))).finally((()=>this.backoffTimeoutId=0))}),e))}))}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const t={session_data:{version:2,device_id:this.uuid,client_version:'1.0.20'.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('auth.anonymLogin',t).then((t=>{var e;return t&&t.session_key||this.params.error$.next({id:'AuthorizeFailed',message:'No session key',data:t}),this.sessionKey=null!==(e=null==t?void 0:t.session_key)&&void 0!==e?e:void 0,this.sessionKey})).catch((async t=>{this.sessionKey=void 0;const e=null==t?void 0:t.error_code;switch(e){case m.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}e?this.params.error$.next({id:`Authorize#${e}`,message:'authorize error',data:t}):this.params.error$.next({id:'AuthorizeUnknown',message:'authorize error',thrown:t})})).finally((()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(void 0!==this.sessionKey)})),this.authorizePromise}}class f{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 y extends f{constructor(){super(),this.listeners||f.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 v(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 y,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',y.prototype[Symbol.toStringTag]='AbortSignal');const A=v({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),b=A?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(!v({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,w=A?b.fetch:window.fetch;A?b.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!==exports.ApiEnv.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const e=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),r=await w(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}),p[exports.ApiEnv.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(),w(`${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 E{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$,this.subscription=this.api.authorized$.subscribe((t=>{t&&this.debouncedFlush()}))}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(this.api.authorized$.getValue()?(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[]):t||this.api.authorize(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe()}}exports.OneStat=class{constructor(e,r){var s;this.subscription=new t.Subscription,this.statContext=e,this.config={...null!==(s=r.config)&&void 0!==s?s:{},requestRetryCount:1};const o=new t.Subject;this.experimental={error$:o};const i=new _({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:p[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 E({api:this.api,error$:o}),this.subscription.add(t.fromEvent(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(),this.api.destroy(),this.logger.destroy()}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?h.AUTO:!1===this.statContext.autoplay?h.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode};return void 0!==e&&(s.param=e),{operation:t,timestamp:r,custom:s}}};
|
package/es2018.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-statistics v1.0.
|
|
3
|
-
* Tue,
|
|
4
|
-
* https://st.mycdn.me/static/playersdk/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-statistics v1.0.20
|
|
3
|
+
* Tue, 09 Aug 2022 12:30:38 GMT
|
|
4
|
+
* https://st.mycdn.me/static/playersdk/1-0-20/doc/
|
|
5
5
|
*/
|
|
6
|
-
import{ValueSubject as t,Subscription as e,Subject as r,fromEvent as s}from'@vkontakte/videoplayer-shared/es2018.esm.js';import o from'lodash/debounce';const i=(()=>{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 n,a,h,u,l,c,d,p={get:t=>function(t){const e=i?i.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{i&&i.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){i&&i.removeItem('_one-stat_'+t)}(t)}};!function(t){t.PROD='prod',t.VK_ALIAS='vk_alias',t.VIDEOTEST='videotest',t.TEST='test',t.AUTO='auto'}(n||(n={})),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'}(a||(a={})),function(t){t.CHROMECAST='chromecast',t.APPLE_TV='appletv',t.PIP='pip',t.HEADPHONES='externalHeadphones',t.SCREEN=''}(h||(h={})),function(t){t.MP4='mp4',t.DASH='dash',t.HLS='hls',t.WEBM='webm'}(u||(u={})),function(t){t.AUTO='auto',t.MANUAL=''}(l||(l={})),function(t){t.HTTP1='http1',t.HTTP2='http2',t.HTTP3='http3'}(c||(c={})),function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(d||(d={}));const m={[n.PROD]:'https://api.ok.ru',[n.VK_ALIAS]:'https://api.mycdn.me',[n.VIDEOTEST]:'https://videotestapi.ok.ru/api',[n.TEST]:'https://apitest.ok.ru',[n.AUTO]:''},g=1e3,f=1.5,y=3e5,A=1e3;var v;!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'}(v||(v={}));class b{constructor(e){this.consequentAuthErrors=0,this.authorized$=new t(!1),this.params=e;const r=p.get('uuid');r?this.uuid=String(r):(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._authorizeWithBackoff()}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._authorizeWithBackoff();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 v.PARAM_SESSION_EXPIRED:case v.PARAM_SESSION_KEY:case v.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=await this._authorizeWithBackoff(),e>0?i(t,e-1):void 0;case v.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorizeWithBackoff(),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)}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}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.19',platform:'WEB',items:t.map((t=>({...t,time:0,type:1})))})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const t=Math.min(Math.round(g*f**(this.consequentAuthErrors-1)+Math.random()*A),y);return new Promise((e=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout((()=>{this._authorize().then(e).catch((t=>this.params.error$.next({id:'AuthorizeBackoff',message:'Otherwise unhandle errror in authrization',thrown:t}))).finally((()=>this.backoffTimeoutId=0))}),t))}))}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const t={session_data:{version:2,device_id:this.uuid,client_version:'1.0.19'.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('auth.anonymLogin',t).then((t=>{var e;return t&&t.session_key||this.params.error$.next({id:'AuthorizeFailed',message:'No session key',data:t}),this.sessionKey=null!==(e=null==t?void 0:t.session_key)&&void 0!==e?e:void 0,this.sessionKey})).catch((async t=>{this.sessionKey=void 0;const e=null==t?void 0:t.error_code;switch(e){case v.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}e?this.params.error$.next({id:`Authorize#${e}`,message:'authorize error',data:t}):this.params.error$.next({id:'AuthorizeUnknown',message:'authorize error',thrown:t})})).finally((()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(void 0!==this.sessionKey)})),this.authorizePromise}}class w{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 _ extends w{constructor(){super(),this.listeners||w.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 E(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 _,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',_.prototype[Symbol.toStringTag]='AbortSignal');const T=E({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),P=T?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(!E({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,S=T?P.fetch:window.fetch;T?P.Request:window.Request;class R{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!==n.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const e=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),r=await S(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}),m[n.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(),S(`${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 O{constructor(t){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=o((()=>{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$,this.subscription=this.api.authorized$.subscribe((t=>{t&&this.debouncedFlush()}))}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(this.api.authorized$.getValue()?(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[]):t||this.api.authorize(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe()}}class k{constructor(t,o){var i;this.subscription=new e,this.statContext=t,this.config={...null!==(i=o.config)&&void 0!==i?i:{},requestRetryCount:1};const n=new r;this.experimental={error$:n};const a=new R({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:m[o.apiEnv],apiEnv:o.apiEnv,error$:n});this.api=new b({apiTransport:a,refreshAuthToken:o.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:n}),this.logger=new O({api:this.api,error$:n}),this.subscription.add(s(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(),this.api.destroy(),this.logger.destroy()}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?d.YES:!1===this.statContext.connectionReused?d.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{n as ApiEnv,c as ConnectionType,u as ContentType,k as OneStat,a as Quality,h as ScreenDestination};
|
|
6
|
+
import{ValueSubject as t,getExponentialDelay as e,Subscription as r,Subject as s,fromEvent as o}from'@vkontakte/videoplayer-shared/es2018.esm.js';import i from'lodash/debounce';const n=(()=>{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 a,h,u,l,c,d,p,m={get:t=>function(t){const e=n?n.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{n&&n.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){n&&n.removeItem('_one-stat_'+t)}(t)}};!function(t){t.PROD='prod',t.VK_ALIAS='vk_alias',t.VIDEOTEST='videotest',t.TEST='test',t.AUTO='auto'}(a||(a={})),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'}(h||(h={})),function(t){t.CHROMECAST='chromecast',t.APPLE_TV='appletv',t.PIP='pip',t.HEADPHONES='externalHeadphones',t.SCREEN=''}(u||(u={})),function(t){t.MP4='mp4',t.DASH='dash',t.DASH_SEP='dash_sep',t.ONDEMAND_DASH='ondemand_dash',t.HLS='hls',t.ONDEMAND_HLS='ondemand_hls',t.WEBM='webm'}(l||(l={})),function(t){t.AUTO='auto',t.MANUAL=''}(c||(c={})),function(t){t.HTTP1='http1',t.HTTP2='http2',t.HTTP3='http3'}(d||(d={})),function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(p||(p={}));const g={[a.PROD]:'https://api.ok.ru',[a.VK_ALIAS]:'https://api.mycdn.me',[a.VIDEOTEST]:'https://videotestapi.ok.ru/api',[a.TEST]:'https://apitest.ok.ru',[a.AUTO]:''},f={start:1e3,factor:1.5,max:3e5,random:1e3};var y;!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'}(y||(y={}));class A{constructor(e){this.consequentAuthErrors=0,this.authorized$=new t(!1),this.params=e;const r=m.get('uuid');r?this.uuid=String(r):(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('')}(),m.set('uuid',this.uuid))}async authorize(t){return this.authToken=null!=t?t:await this.refreshAuthToken(),this._authorizeWithBackoff()}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._authorizeWithBackoff();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 y.PARAM_SESSION_EXPIRED:case y.PARAM_SESSION_KEY:case y.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=await this._authorizeWithBackoff(),e>0?i(t,e-1):void 0;case y.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorizeWithBackoff(),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)}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}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.20',platform:'WEB',items:t.map((t=>({...t,time:0,type:1})))})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const t=e(this.consequentAuthErrors,f);return new Promise((e=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout((()=>{this._authorize().then(e).catch((t=>this.params.error$.next({id:'AuthorizeBackoff',message:'Otherwise unhandle errror in authrization',thrown:t}))).finally((()=>this.backoffTimeoutId=0))}),t))}))}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const t={session_data:{version:2,device_id:this.uuid,client_version:'1.0.20'.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('auth.anonymLogin',t).then((t=>{var e;return t&&t.session_key||this.params.error$.next({id:'AuthorizeFailed',message:'No session key',data:t}),this.sessionKey=null!==(e=null==t?void 0:t.session_key)&&void 0!==e?e:void 0,this.sessionKey})).catch((async t=>{this.sessionKey=void 0;const e=null==t?void 0:t.error_code;switch(e){case y.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}e?this.params.error$.next({id:`Authorize#${e}`,message:'authorize error',data:t}):this.params.error$.next({id:'AuthorizeUnknown',message:'authorize error',thrown:t})})).finally((()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(void 0!==this.sessionKey)})),this.authorizePromise}}class v{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 b extends v{constructor(){super(),this.listeners||v.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 w(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 b,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',b.prototype[Symbol.toStringTag]='AbortSignal');const _=w({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),E=_?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(!w({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,P=_?E.fetch:window.fetch;_?E.Request:window.Request;class S{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!==a.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const e=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),r=await P(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}),g[a.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(),P(`${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 T{constructor(t){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=i((()=>{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$,this.subscription=this.api.authorized$.subscribe((t=>{t&&this.debouncedFlush()}))}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(this.api.authorized$.getValue()?(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[]):t||this.api.authorize(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe()}}class O{constructor(t,e){var i;this.subscription=new r,this.statContext=t,this.config={...null!==(i=e.config)&&void 0!==i?i:{},requestRetryCount:1};const n=new s;this.experimental={error$:n};const a=new S({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:g[e.apiEnv],apiEnv:e.apiEnv,error$:n});this.api=new A({apiTransport:a,refreshAuthToken:e.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:n}),this.logger=new T({api:this.api,error$:n}),this.subscription.add(o(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(),this.api.destroy(),this.logger.destroy()}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?p.YES:!1===this.statContext.connectionReused?p.NO:void 0,stat_type:!0===this.statContext.autoplay?c.AUTO:!1===this.statContext.autoplay?c.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode};return void 0!==e&&(s.param=e),{operation:t,timestamp:r,custom:s}}}export{a as ApiEnv,d as ConnectionType,l as ContentType,O as OneStat,h as Quality,u as ScreenDestination};
|
package/esnext.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-statistics v1.0.
|
|
3
|
-
* Tue,
|
|
4
|
-
* https://st.mycdn.me/static/playersdk/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-statistics v1.0.20
|
|
3
|
+
* Tue, 09 Aug 2022 12:30:38 GMT
|
|
4
|
+
* https://st.mycdn.me/static/playersdk/1-0-20/doc/
|
|
5
5
|
*/
|
|
6
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var t=require('@vkontakte/videoplayer-shared/esnext.cjs.js');function e(t){return t&&'object'==typeof t&&'default'in t?t:{default:t}}var r=e(require('lodash/debounce'));const s=(()=>{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 o,i,n,a,h,u,c,l={get:t=>function(t){const e=s?s.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{s&&s.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){s&&s.removeItem('_one-stat_'+t)}(t)}};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(t){t.AUTO='auto',t.MANUAL=''}(h||(h={})),exports.ConnectionType=void 0,(u=exports.ConnectionType||(exports.ConnectionType={})).HTTP1='http1',u.HTTP2='http2',u.HTTP3='http3',function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(c||(c={}));const p={[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]:''},d=1e3,m=1.5,g=3e5,f=1e3;var y;!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'}(y||(y={}));class A{params;uuid;authToken;sessionKey;authorizePromise;refreshAuthTokenPromise;consequentAuthErrors=0;authorized$=new t.ValueSubject(!1);backoffTimeoutId;constructor(t){this.params=t;const e=l.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('')}(),l.set('uuid',this.uuid))}async authorize(t){return this.authToken=t??await this.refreshAuthToken(),this._authorizeWithBackoff()}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){const e='log.externalLog',r=this.createLogParams(t),s=this.sessionKey??await this._authorizeWithBackoff();if(!s)return;const o=async(t,i=this.params.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(e,r,s)}catch(r){if(!r||!('error_code'in r))return void this.params.error$.next({id:'logRequestUnknown',message:`Unknown ${e} error`,thrown:r});const s=r?.error_code;switch(s){case y.PARAM_SESSION_EXPIRED:case y.PARAM_SESSION_KEY:case y.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=await this._authorizeWithBackoff(),i>0?o(t,i-1):void 0;case y.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorizeWithBackoff(),i>0?o(t,i-1):void 0;default:return void this.params.error$.next({id:`LogRequest#${s}`,message:`${e} error`,data:r})}}};return o(t)}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}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.19',platform:'WEB',items:t.map((t=>({...t,time:0,type:1})))})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const t=Math.min(Math.round(d*m**(this.consequentAuthErrors-1)+Math.random()*f),g);return new Promise((e=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout((()=>{this._authorize().then(e).catch((t=>this.params.error$.next({id:'AuthorizeBackoff',message:'Otherwise unhandle errror in authrization',thrown:t}))).finally((()=>this.backoffTimeoutId=0))}),t))}))}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const t={session_data:{version:2,device_id:this.uuid,client_version:'1.0.19'.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('auth.anonymLogin',t).then((t=>(t&&t.session_key||this.params.error$.next({id:'AuthorizeFailed',message:'No session key',data:t}),this.sessionKey=t?.session_key??void 0,this.sessionKey))).catch((async t=>{this.sessionKey=void 0;const e=t?.error_code;switch(e){case y.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}e?this.params.error$.next({id:`Authorize#${e}`,message:'authorize error',data:t}):this.params.error$.next({id:'AuthorizeUnknown',message:'authorize error',thrown:t})})).finally((()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(void 0!==this.sessionKey)})),this.authorizePromise}}class b{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 v extends b{constructor(){super(),this.listeners||b.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 w(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 v,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',v.prototype[Symbol.toStringTag]='AbortSignal');const _=w({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),E=_?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(!w({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,T=_?E.fetch:window.fetch;_?E.Request:window.Request;class S{apiKey;apiBaseUrl;apiEnv;isApiBaseUrlFetched;params;constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiEnv=t.apiEnv,this.apiBaseUrl=t.apiBaseUrl,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){if(this.apiEnv!==exports.ApiEnv.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const t=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),e=await T(t,{method:'GET',mode:'cors',cache:'no-cache'}),r=(await e.json())?.Answer[0]?.data;if(!r)throw new Error('Wrong DNS response');return r}catch(t){return this.params.error$.next({id:'OneStat:ApiTransport:resolveApiBaseUrl',message:'Unhandled resolve api base url error',thrown:t}),p[exports.ApiEnv.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(),T(`${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{api;error$;requestQueue=[];subscription;isPaused=!1;debouncedFlush=r.default((()=>{try{this.flush()}catch(t){this.error$.next({id:'LoggerError',message:String(t)??'Unknown logger error',thrown:t})}}),3e3,{maxWait:15e3});constructor(t){this.api=t.api,this.error$=t.error$,this.subscription=this.api.authorized$.subscribe((t=>{t&&this.debouncedFlush()}))}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(this.api.authorized$.getValue()?(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[]):t||this.api.authorize(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe()}}exports.OneStat=class{api;logger;config;subscription=new t.Subscription;experimental;statContext;constructor(e,r){this.statContext=e,this.config={...r.config??{},requestRetryCount:1};const s=new t.Subject;this.experimental={error$:s};const o=new S({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:p[r.apiEnv],apiEnv:r.apiEnv,error$:s});this.api=new A({apiTransport:o,refreshAuthToken:r.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:s}),this.logger=new P({api:this.api,error$:s}),this.subscription.add(t.fromEvent(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(),this.api.destroy(),this.logger.destroy()}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?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!==e&&(s.param=e),{operation:t,timestamp:r,custom:s}}};
|
|
6
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var t=require('@vkontakte/videoplayer-shared/esnext.cjs.js');function e(t){return t&&'object'==typeof t&&'default'in t?t:{default:t}}var r=e(require('lodash/debounce'));const s=(()=>{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 o,i,n,a,h,u,c,l={get:t=>function(t){const e=s?s.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{s&&s.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){s&&s.removeItem('_one-stat_'+t)}(t)}};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.DASH_SEP='dash_sep',a.ONDEMAND_DASH='ondemand_dash',a.HLS='hls',a.ONDEMAND_HLS='ondemand_hls',a.WEBM='webm',function(t){t.AUTO='auto',t.MANUAL=''}(h||(h={})),exports.ConnectionType=void 0,(u=exports.ConnectionType||(exports.ConnectionType={})).HTTP1='http1',u.HTTP2='http2',u.HTTP3='http3',function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(c||(c={}));const p={[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]:''},d={start:1e3,factor:1.5,max:3e5,random:1e3};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{params;uuid;authToken;sessionKey;authorizePromise;refreshAuthTokenPromise;consequentAuthErrors=0;authorized$=new t.ValueSubject(!1);backoffTimeoutId;constructor(t){this.params=t;const e=l.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('')}(),l.set('uuid',this.uuid))}async authorize(t){return this.authToken=t??await this.refreshAuthToken(),this._authorizeWithBackoff()}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){const e='log.externalLog',r=this.createLogParams(t),s=this.sessionKey??await this._authorizeWithBackoff();if(!s)return;const o=async(t,i=this.params.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(e,r,s)}catch(r){if(!r||!('error_code'in r))return void this.params.error$.next({id:'logRequestUnknown',message:`Unknown ${e} 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.authorized$.next(!1),this.sessionKey=await this._authorizeWithBackoff(),i>0?o(t,i-1):void 0;case m.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorizeWithBackoff(),i>0?o(t,i-1):void 0;default:return void this.params.error$.next({id:`LogRequest#${s}`,message:`${e} error`,data:r})}}};return o(t)}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}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.20',platform:'WEB',items:t.map((t=>({...t,time:0,type:1})))})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const e=t.getExponentialDelay(this.consequentAuthErrors,d);return new Promise((t=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout((()=>{this._authorize().then(t).catch((t=>this.params.error$.next({id:'AuthorizeBackoff',message:'Otherwise unhandle errror in authrization',thrown:t}))).finally((()=>this.backoffTimeoutId=0))}),e))}))}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const t={session_data:{version:2,device_id:this.uuid,client_version:'1.0.20'.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('auth.anonymLogin',t).then((t=>(t&&t.session_key||this.params.error$.next({id:'AuthorizeFailed',message:'No session key',data:t}),this.sessionKey=t?.session_key??void 0,this.sessionKey))).catch((async t=>{this.sessionKey=void 0;const e=t?.error_code;switch(e){case m.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}e?this.params.error$.next({id:`Authorize#${e}`,message:'authorize error',data:t}):this.params.error$.next({id:'AuthorizeUnknown',message:'authorize error',thrown:t})})).finally((()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(void 0!==this.sessionKey)})),this.authorizePromise}}class f{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 y extends f{constructor(){super(),this.listeners||f.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 y,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',y.prototype[Symbol.toStringTag]='AbortSignal');const b=A({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),v=b?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,w=b?v.fetch:window.fetch;b?v.Request:window.Request;class _{apiKey;apiBaseUrl;apiEnv;isApiBaseUrlFetched;params;constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiEnv=t.apiEnv,this.apiBaseUrl=t.apiBaseUrl,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){if(this.apiEnv!==exports.ApiEnv.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const t=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),e=await w(t,{method:'GET',mode:'cors',cache:'no-cache'}),r=(await e.json())?.Answer[0]?.data;if(!r)throw new Error('Wrong DNS response');return r}catch(t){return this.params.error$.next({id:'OneStat:ApiTransport:resolveApiBaseUrl',message:'Unhandled resolve api base url error',thrown:t}),p[exports.ApiEnv.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(),w(`${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 E{api;error$;requestQueue=[];subscription;isPaused=!1;debouncedFlush=r.default((()=>{try{this.flush()}catch(t){this.error$.next({id:'LoggerError',message:String(t)??'Unknown logger error',thrown:t})}}),3e3,{maxWait:15e3});constructor(t){this.api=t.api,this.error$=t.error$,this.subscription=this.api.authorized$.subscribe((t=>{t&&this.debouncedFlush()}))}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(this.api.authorized$.getValue()?(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[]):t||this.api.authorize(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe()}}exports.OneStat=class{api;logger;config;subscription=new t.Subscription;experimental;statContext;constructor(e,r){this.statContext=e,this.config={...r.config??{},requestRetryCount:1};const s=new t.Subject;this.experimental={error$:s};const o=new _({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:p[r.apiEnv],apiEnv:r.apiEnv,error$:s});this.api=new g({apiTransport:o,refreshAuthToken:r.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:s}),this.logger=new E({api:this.api,error$:s}),this.subscription.add(t.fromEvent(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(),this.api.destroy(),this.logger.destroy()}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?h.AUTO:!1===this.statContext.autoplay?h.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode};return void 0!==e&&(s.param=e),{operation:t,timestamp:r,custom:s}}};
|
package/esnext.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-statistics v1.0.
|
|
3
|
-
* Tue,
|
|
4
|
-
* https://st.mycdn.me/static/playersdk/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-statistics v1.0.20
|
|
3
|
+
* Tue, 09 Aug 2022 12:30:38 GMT
|
|
4
|
+
* https://st.mycdn.me/static/playersdk/1-0-20/doc/
|
|
5
5
|
*/
|
|
6
|
-
import{ValueSubject as t,Subscription as e,Subject as r,fromEvent as s}from'@vkontakte/videoplayer-shared/esnext.esm.js';import o from'lodash/debounce';const i=(()=>{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 n,a,h,u,c,l,p,d={get:t=>function(t){const e=i?i.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{i&&i.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){i&&i.removeItem('_one-stat_'+t)}(t)}};!function(t){t.PROD='prod',t.VK_ALIAS='vk_alias',t.VIDEOTEST='videotest',t.TEST='test',t.AUTO='auto'}(n||(n={})),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'}(a||(a={})),function(t){t.CHROMECAST='chromecast',t.APPLE_TV='appletv',t.PIP='pip',t.HEADPHONES='externalHeadphones',t.SCREEN=''}(h||(h={})),function(t){t.MP4='mp4',t.DASH='dash',t.HLS='hls',t.WEBM='webm'}(u||(u={})),function(t){t.AUTO='auto',t.MANUAL=''}(c||(c={})),function(t){t.HTTP1='http1',t.HTTP2='http2',t.HTTP3='http3'}(l||(l={})),function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(p||(p={}));const m={[n.PROD]:'https://api.ok.ru',[n.VK_ALIAS]:'https://api.mycdn.me',[n.VIDEOTEST]:'https://videotestapi.ok.ru/api',[n.TEST]:'https://apitest.ok.ru',[n.AUTO]:''},g=1e3,f=1.5,y=3e5,A=1e3;var b;!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'}(b||(b={}));class w{params;uuid;authToken;sessionKey;authorizePromise;refreshAuthTokenPromise;consequentAuthErrors=0;authorized$=new t(!1);backoffTimeoutId;constructor(t){this.params=t;const e=d.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('')}(),d.set('uuid',this.uuid))}async authorize(t){return this.authToken=t??await this.refreshAuthToken(),this._authorizeWithBackoff()}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){const e='log.externalLog',r=this.createLogParams(t),s=this.sessionKey??await this._authorizeWithBackoff();if(!s)return;const o=async(t,i=this.params.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(e,r,s)}catch(r){if(!r||!('error_code'in r))return void this.params.error$.next({id:'logRequestUnknown',message:`Unknown ${e} error`,thrown:r});const s=r?.error_code;switch(s){case b.PARAM_SESSION_EXPIRED:case b.PARAM_SESSION_KEY:case b.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=await this._authorizeWithBackoff(),i>0?o(t,i-1):void 0;case b.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorizeWithBackoff(),i>0?o(t,i-1):void 0;default:return void this.params.error$.next({id:`LogRequest#${s}`,message:`${e} error`,data:r})}}};return o(t)}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}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.19',platform:'WEB',items:t.map((t=>({...t,time:0,type:1})))})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const t=Math.min(Math.round(g*f**(this.consequentAuthErrors-1)+Math.random()*A),y);return new Promise((e=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout((()=>{this._authorize().then(e).catch((t=>this.params.error$.next({id:'AuthorizeBackoff',message:'Otherwise unhandle errror in authrization',thrown:t}))).finally((()=>this.backoffTimeoutId=0))}),t))}))}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const t={session_data:{version:2,device_id:this.uuid,client_version:'1.0.19'.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('auth.anonymLogin',t).then((t=>(t&&t.session_key||this.params.error$.next({id:'AuthorizeFailed',message:'No session key',data:t}),this.sessionKey=t?.session_key??void 0,this.sessionKey))).catch((async t=>{this.sessionKey=void 0;const e=t?.error_code;switch(e){case b.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}e?this.params.error$.next({id:`Authorize#${e}`,message:'authorize error',data:t}):this.params.error$.next({id:'AuthorizeUnknown',message:'authorize error',thrown:t})})).finally((()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(void 0!==this.sessionKey)})),this.authorizePromise}}class _{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 v extends _{constructor(){super(),this.listeners||_.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 T(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 v,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',v.prototype[Symbol.toStringTag]='AbortSignal');const E=T({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),P=E?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(!T({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,S=E?P.fetch:window.fetch;E?P.Request:window.Request;class k{apiKey;apiBaseUrl;apiEnv;isApiBaseUrlFetched;params;constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiEnv=t.apiEnv,this.apiBaseUrl=t.apiBaseUrl,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){if(this.apiEnv!==n.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const t=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),e=await S(t,{method:'GET',mode:'cors',cache:'no-cache'}),r=(await e.json())?.Answer[0]?.data;if(!r)throw new Error('Wrong DNS response');return r}catch(t){return this.params.error$.next({id:'OneStat:ApiTransport:resolveApiBaseUrl',message:'Unhandled resolve api base url error',thrown:t}),m[n.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(),S(`${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 R{api;error$;requestQueue=[];subscription;isPaused=!1;debouncedFlush=o((()=>{try{this.flush()}catch(t){this.error$.next({id:'LoggerError',message:String(t)??'Unknown logger error',thrown:t})}}),3e3,{maxWait:15e3});constructor(t){this.api=t.api,this.error$=t.error$,this.subscription=this.api.authorized$.subscribe((t=>{t&&this.debouncedFlush()}))}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(this.api.authorized$.getValue()?(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[]):t||this.api.authorize(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe()}}class O{api;logger;config;subscription=new e;experimental;statContext;constructor(t,e){this.statContext=t,this.config={...e.config??{},requestRetryCount:1};const o=new r;this.experimental={error$:o};const i=new k({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:m[e.apiEnv],apiEnv:e.apiEnv,error$:o});this.api=new w({apiTransport:i,refreshAuthToken:e.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:o}),this.logger=new R({api:this.api,error$:o}),this.subscription.add(s(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(),this.api.destroy(),this.logger.destroy()}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?p.YES:!1===this.statContext.connectionReused?p.NO:void 0,stat_type:!0===this.statContext.autoplay?c.AUTO:!1===this.statContext.autoplay?c.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{n as ApiEnv,l as ConnectionType,u as ContentType,O as OneStat,a as Quality,h as ScreenDestination};
|
|
6
|
+
import{ValueSubject as t,getExponentialDelay as e,Subscription as r,Subject as s,fromEvent as o}from'@vkontakte/videoplayer-shared/esnext.esm.js';import i from'lodash/debounce';const a=(()=>{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 n,h,u,c,l,p,d,m={get:t=>function(t){const e=a?a.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{a&&a.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){a&&a.removeItem('_one-stat_'+t)}(t)}};!function(t){t.PROD='prod',t.VK_ALIAS='vk_alias',t.VIDEOTEST='videotest',t.TEST='test',t.AUTO='auto'}(n||(n={})),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'}(h||(h={})),function(t){t.CHROMECAST='chromecast',t.APPLE_TV='appletv',t.PIP='pip',t.HEADPHONES='externalHeadphones',t.SCREEN=''}(u||(u={})),function(t){t.MP4='mp4',t.DASH='dash',t.DASH_SEP='dash_sep',t.ONDEMAND_DASH='ondemand_dash',t.HLS='hls',t.ONDEMAND_HLS='ondemand_hls',t.WEBM='webm'}(c||(c={})),function(t){t.AUTO='auto',t.MANUAL=''}(l||(l={})),function(t){t.HTTP1='http1',t.HTTP2='http2',t.HTTP3='http3'}(p||(p={})),function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(d||(d={}));const g={[n.PROD]:'https://api.ok.ru',[n.VK_ALIAS]:'https://api.mycdn.me',[n.VIDEOTEST]:'https://videotestapi.ok.ru/api',[n.TEST]:'https://apitest.ok.ru',[n.AUTO]:''},f={start:1e3,factor:1.5,max:3e5,random:1e3};var y;!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'}(y||(y={}));class A{params;uuid;authToken;sessionKey;authorizePromise;refreshAuthTokenPromise;consequentAuthErrors=0;authorized$=new t(!1);backoffTimeoutId;constructor(t){this.params=t;const e=m.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('')}(),m.set('uuid',this.uuid))}async authorize(t){return this.authToken=t??await this.refreshAuthToken(),this._authorizeWithBackoff()}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){const e='log.externalLog',r=this.createLogParams(t),s=this.sessionKey??await this._authorizeWithBackoff();if(!s)return;const o=async(t,i=this.params.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(e,r,s)}catch(r){if(!r||!('error_code'in r))return void this.params.error$.next({id:'logRequestUnknown',message:`Unknown ${e} error`,thrown:r});const s=r?.error_code;switch(s){case y.PARAM_SESSION_EXPIRED:case y.PARAM_SESSION_KEY:case y.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=await this._authorizeWithBackoff(),i>0?o(t,i-1):void 0;case y.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorizeWithBackoff(),i>0?o(t,i-1):void 0;default:return void this.params.error$.next({id:`LogRequest#${s}`,message:`${e} error`,data:r})}}};return o(t)}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}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.20',platform:'WEB',items:t.map((t=>({...t,time:0,type:1})))})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const t=e(this.consequentAuthErrors,f);return new Promise((e=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout((()=>{this._authorize().then(e).catch((t=>this.params.error$.next({id:'AuthorizeBackoff',message:'Otherwise unhandle errror in authrization',thrown:t}))).finally((()=>this.backoffTimeoutId=0))}),t))}))}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const t={session_data:{version:2,device_id:this.uuid,client_version:'1.0.20'.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('auth.anonymLogin',t).then((t=>(t&&t.session_key||this.params.error$.next({id:'AuthorizeFailed',message:'No session key',data:t}),this.sessionKey=t?.session_key??void 0,this.sessionKey))).catch((async t=>{this.sessionKey=void 0;const e=t?.error_code;switch(e){case y.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}e?this.params.error$.next({id:`Authorize#${e}`,message:'authorize error',data:t}):this.params.error$.next({id:'AuthorizeUnknown',message:'authorize error',thrown:t})})).finally((()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(void 0!==this.sessionKey)})),this.authorizePromise}}class b{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 w extends b{constructor(){super(),this.listeners||b.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 _(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 w,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',w.prototype[Symbol.toStringTag]='AbortSignal');const v=_({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),E=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(!_({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 a=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,a(t,e)])}return a(t,e)},Request:i}}({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,T=v?E.fetch:window.fetch;v?E.Request:window.Request;class P{apiKey;apiBaseUrl;apiEnv;isApiBaseUrlFetched;params;constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiEnv=t.apiEnv,this.apiBaseUrl=t.apiBaseUrl,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){if(this.apiEnv!==n.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const t=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),e=await T(t,{method:'GET',mode:'cors',cache:'no-cache'}),r=(await e.json())?.Answer[0]?.data;if(!r)throw new Error('Wrong DNS response');return r}catch(t){return this.params.error$.next({id:'OneStat:ApiTransport:resolveApiBaseUrl',message:'Unhandled resolve api base url error',thrown:t}),g[n.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(),T(`${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 S{api;error$;requestQueue=[];subscription;isPaused=!1;debouncedFlush=i((()=>{try{this.flush()}catch(t){this.error$.next({id:'LoggerError',message:String(t)??'Unknown logger error',thrown:t})}}),3e3,{maxWait:15e3});constructor(t){this.api=t.api,this.error$=t.error$,this.subscription=this.api.authorized$.subscribe((t=>{t&&this.debouncedFlush()}))}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(this.api.authorized$.getValue()?(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[]):t||this.api.authorize(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe()}}class k{api;logger;config;subscription=new r;experimental;statContext;constructor(t,e){this.statContext=t,this.config={...e.config??{},requestRetryCount:1};const r=new s;this.experimental={error$:r};const i=new P({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:g[e.apiEnv],apiEnv:e.apiEnv,error$:r});this.api=new A({apiTransport:i,refreshAuthToken:e.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:r}),this.logger=new S({api:this.api,error$:r}),this.subscription.add(o(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(),this.api.destroy(),this.logger.destroy()}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?d.YES:!1===this.statContext.connectionReused?d.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,track_code:this.statContext.trackCode};return void 0!==e&&(s.param=e),{operation:t,timestamp:r,custom:s}}}export{n as ApiEnv,p as ConnectionType,c as ContentType,k as OneStat,h as Quality,u as ScreenDestination};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vkontakte/videoplayer-statistics",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.20",
|
|
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.
|
|
17
|
+
"@vkontakte/videoplayer-shared": "^1.0.14",
|
|
18
18
|
"lodash": "4.17.21"
|
|
19
19
|
}
|
|
20
20
|
}
|
package/types.d.ts
CHANGED
|
@@ -27,7 +27,10 @@ export declare enum ScreenDestination {
|
|
|
27
27
|
export declare enum ContentType {
|
|
28
28
|
MP4 = "mp4",
|
|
29
29
|
DASH = "dash",
|
|
30
|
+
DASH_SEP = "dash_sep",
|
|
31
|
+
ONDEMAND_DASH = "ondemand_dash",
|
|
30
32
|
HLS = "hls",
|
|
33
|
+
ONDEMAND_HLS = "ondemand_hls",
|
|
31
34
|
WEBM = "webm"
|
|
32
35
|
}
|
|
33
36
|
export declare enum StatType {
|