@vkontakte/videoplayer-statistics 1.0.24 → 1.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es2015.cjs.js +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 +1 -1
- package/types.d.ts +1 -0
package/es2015.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-statistics v1.0.
|
|
3
|
-
*
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-statistics v1.0.25
|
|
3
|
+
* Wed, 21 Sep 2022 08:17:06 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-25/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.js'));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={},T=!a((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),E=u,S=Function.prototype.call,_=E?S.bind(S):function(){return S.apply(S,arguments)},O={},P={}.propertyIsEnumerable,R=Object.getOwnPropertyDescriptor,x=R&&!P.call({1:2},1);O.f=x?function(t){var e=R(this,t);return!!e&&e.enumerable}:P;var j,k,C=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},I=b,N=I({}.toString),L=I(''.slice),q=function(t){return L(N(t),8,-1)},U=a,B=q,z=Object,D=b(''.split),M=U((function(){return!z('z').propertyIsEnumerable(0)}))?function(t){return'String'==B(t)?D(t,''):z(t)}:z,F=TypeError,$=function(t){if(null==t)throw F('Can\'t call method on '+t);return t},K=M,Q=$,H=w,W=function(t){return'object'==typeof t?null!==t:H(t)},G={},V=G,Y=s,J=w,Z=function(t){return J(t)?t:void 0},X=function(t,e){return arguments.length<2?Z(V[t])||Z(Y[t]):V[t]&&V[t][e]||Y[t]&&Y[t][e]},tt=b({}.isPrototypeOf),et=X('navigator','userAgent')||'',rt=s,nt=et,ot=rt.process,it=rt.Deno,st=ot&&ot.versions||it&&it.version,at=st&&st.v8;at&&(k=(j=at.split('.'))[0]>0&&j[0]<4?1:+(j[0]+j[1])),!k&&nt&&(!(j=nt.match(/Edge\/(\d+)/))||j[1]>=74)&&(j=nt.match(/Chrome\/(\d+)/))&&(k=+j[1]);var ut=k,ct=ut,ht=a,lt=!!Object.getOwnPropertySymbols&&!ht((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&ct&&ct<41})),ft=lt&&!Symbol.sham&&'symbol'==typeof Symbol.iterator,pt=X,dt=w,vt=tt,yt=Object,mt=ft?function(t){return'symbol'==typeof t}:function(t){var e=pt('Symbol');return dt(e)&&vt(e.prototype,yt(t))},gt=String,bt=function(t){try{return gt(t)}catch(t){return'Object'}},wt=w,At=bt,Tt=TypeError,Et=function(t){if(wt(t))return t;throw Tt(At(t)+' is not a function')},St=Et,_t=function(t,e){var r=t[e];return null==r?void 0:St(r)},Ot=_,Pt=w,Rt=W,xt=TypeError,jt={exports:{}},kt=s,Ct=Object.defineProperty,It=function(t,e){try{Ct(kt,t,{value:e,configurable:!0,writable:!0})}catch(r){kt[t]=e}return e},Nt=s['__core-js_shared__']||It('__core-js_shared__',{}),Lt=Nt;(jt.exports=function(t,e){return Lt[t]||(Lt[t]=void 0!==e?e:{})})('versions',[]).push({version:'3.24.1',mode:'pure',copyright:'© 2014-2022 Denis Pushkarev (zloirock.ru)',license:'https://github.com/zloirock/core-js/blob/v3.24.1/LICENSE',source:'https://github.com/zloirock/core-js'});var qt=$,Ut=Object,Bt=function(t){return Ut(qt(t))},zt=b({}.hasOwnProperty),Dt=Object.hasOwn||function(t,e){return zt(Bt(t),e)},Mt=b,Ft=0,$t=Math.random(),Kt=Mt(1..toString),Qt=function(t){return'Symbol('+(void 0===t?'':t)+')_'+Kt(++Ft+$t,36)},Ht=s,Wt=jt.exports,Gt=Dt,Vt=Qt,Yt=lt,Jt=ft,Zt=Wt('wks'),Xt=Ht.Symbol,te=Xt&&Xt.for,ee=Jt?Xt:Xt&&Xt.withoutSetter||Vt,re=function(t){if(!Gt(Zt,t)||!Yt&&'string'!=typeof Zt[t]){var e='Symbol.'+t;Yt&&Gt(Xt,t)?Zt[t]=Xt[t]:Zt[t]=Jt&&te?te(e):ee(e)}return Zt[t]},ne=_,oe=W,ie=mt,se=_t,ae=function(t,e){var r,n;if('string'===e&&Pt(r=t.toString)&&!Rt(n=Ot(r,t)))return n;if(Pt(r=t.valueOf)&&!Rt(n=Ot(r,t)))return n;if('string'!==e&&Pt(r=t.toString)&&!Rt(n=Ot(r,t)))return n;throw xt('Can\'t convert object to primitive value')},ue=TypeError,ce=re('toPrimitive'),he=function(t,e){if(!oe(t)||ie(t))return t;var r,n=se(t,ce);if(n){if(void 0===e&&(e='default'),r=ne(n,t,e),!oe(r)||ie(r))return r;throw ue('Can\'t convert object to primitive value')}return void 0===e&&(e='number'),ae(t,e)},le=mt,fe=function(t){var e=he(t,'string');return le(e)?e:e+''},pe=W,de=s.document,ve=pe(de)&&pe(de.createElement),ye=function(t){return ve?de.createElement(t):{}},me=ye,ge=!T&&!a((function(){return 7!=Object.defineProperty(me('div'),'a',{get:function(){return 7}}).a})),be=T,we=_,Ae=O,Te=C,Ee=function(t){return K(Q(t))},Se=fe,_e=Dt,Oe=ge,Pe=Object.getOwnPropertyDescriptor;A.f=be?Pe:function(t,e){if(t=Ee(t),e=Se(e),Oe)try{return Pe(t,e)}catch(t){}if(_e(t,e))return Te(!we(Ae.f,t,e),t[e])};var Re=a,xe=w,je=/#|\.prototype\./,ke=function(t,e){var r=Ie[Ce(t)];return r==Le||r!=Ne&&(xe(e)?Re(e):!!e)},Ce=ke.normalize=function(t){return String(t).replace(je,'.').toLowerCase()},Ie=ke.data={},Ne=ke.NATIVE='N',Le=ke.POLYFILL='P',qe=ke,Ue=Et,Be=u,ze=b(b.bind),De=function(t,e){return Ue(t),void 0===e?t:Be?ze(t,e):function(){return t.apply(e,arguments)}},Me={},Fe=T&&a((function(){return 42!=Object.defineProperty((function(){}),'prototype',{value:42,writable:!1}).prototype})),$e=W,Ke=String,Qe=TypeError,He=function(t){if($e(t))return t;throw Qe(Ke(t)+' is not an object')},We=T,Ge=ge,Ve=Fe,Ye=He,Je=fe,Ze=TypeError,Xe=Object.defineProperty,tr=Object.getOwnPropertyDescriptor;Me.f=We?Ve?function(t,e,r){if(Ye(t),e=Je(e),Ye(r),'function'==typeof t&&'prototype'===e&&'value'in r&&'writable'in r&&!r.writable){var n=tr(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 Xe(t,e,r)}:Xe:function(t,e,r){if(Ye(t),e=Je(e),Ye(r),Ge)try{return Xe(t,e,r)}catch(t){}if('get'in r||'set'in r)throw Ze('Accessors not supported');return'value'in r&&(t[e]=r.value),t};var er=Me,rr=C,nr=T?function(t,e,r){return er.f(t,e,rr(1,r))}:function(t,e,r){return t[e]=r,t},or=s,ir=p,sr=b,ar=w,ur=A.f,cr=qe,hr=G,lr=De,fr=nr,pr=Dt,dr=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 ir(t,this,arguments)};return e.prototype=t.prototype,e},vr=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?or:f?or[h]:(or[h]||{}).prototype,v=l?hr:hr[h]||fr(hr,h,{})[h],y=v.prototype;for(o in e)r=!cr(l?o:h+(f?'.':'#')+o,t.forced)&&d&&pr(d,o),s=v[o],r&&(a=t.dontCallGetSet?(c=ur(d,o))&&c.value:d[o]),i=r&&a?a:e[o],r&&typeof s==typeof i||(u=t.bind&&r?lr(i,or):t.wrap&&r?dr(i):p&&ar(i)?sr(i):i,(t.sham||i&&i.sham||s&&s.sham)&&fr(u,'sham',!0),fr(v,o,u),p&&(pr(hr,n=h+'Prototype')||fr(hr,n,{}),fr(hr[n],o,i),t.real&&y&&!y[o]&&fr(y,o,i)))},yr='process'==q(s.process),mr=nr,gr=(TypeError,b);Object.setPrototypeOf||'__proto__'in{}&&function(){var t,e=!1,r={};try{(t=gr(Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').set))(r,[]),e=r instanceof Array}catch(t){}}();var br={};br[re('toStringTag')]='z';var wr='[object z]'===String(br),Ar=wr,Tr=w,Er=q,Sr=re('toStringTag'),_r=Object,Or='Arguments'==Er(function(){return arguments}()),Pr=Ar?Er: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=_r(t),Sr))?r:Or?Er(e):'Object'==(n=Er(e))&&Tr(e.callee)?'Arguments':n},Rr=Pr,xr=wr?{}.toString:function(){return'[object '+Rr(this)+']'},jr=wr,kr=Me.f,Cr=nr,Ir=Dt,Nr=xr,Lr=re('toStringTag'),qr=X,Ur=Me,Br=T,zr=re('species'),Dr=tt,Mr=TypeError,Fr=w,$r=Nt,Kr=b(Function.toString);Fr($r.inspectSource)||($r.inspectSource=function(t){return Kr(t)});var Qr=$r.inspectSource,Hr=b,Wr=a,Gr=w,Vr=Pr,Yr=Qr,Jr=function(){},Zr=[],Xr=X('Reflect','construct'),tn=/^\s*(?:class|function)\b/,en=Hr(tn.exec),rn=!tn.exec(Jr),nn=function(t){if(!Gr(t))return!1;try{return Xr(Jr,Zr,t),!0}catch(t){return!1}},on=function(t){if(!Gr(t))return!1;switch(Vr(t)){case'AsyncFunction':case'GeneratorFunction':case'AsyncGeneratorFunction':return!1}try{return rn||!!en(tn,Yr(t))}catch(t){return!0}};on.sham=!0;var sn,an,un,cn,hn=!Xr||Wr((function(){var t;return nn(nn.call)||!nn(Object)||!nn((function(){t=!0}))||t}))?on:nn,ln=bt,fn=TypeError,pn=He,dn=function(t){if(hn(t))return t;throw fn(ln(t)+' is not a constructor')},vn=re('species'),yn=function(t,e){var r,n=pn(t).constructor;return void 0===n||null==(r=pn(n)[vn])?e:dn(r)},mn=X('document','documentElement'),gn=b([].slice),bn=TypeError,wn=/(?:ipad|iphone|ipod).*applewebkit/i.test(et),An=s,Tn=p,En=De,Sn=w,_n=Dt,On=a,Pn=mn,Rn=gn,xn=ye,jn=function(t,e){if(t<e)throw bn('Not enough arguments');return t},kn=wn,Cn=yr,In=An.setImmediate,Nn=An.clearImmediate,Ln=An.process,qn=An.Dispatch,Un=An.Function,Bn=An.MessageChannel,zn=An.String,Dn=0,Mn={};try{sn=An.location}catch(t){}var Fn=function(t){if(_n(Mn,t)){var e=Mn[t];delete Mn[t],e()}},$n=function(t){return function(){Fn(t)}},Kn=function(t){Fn(t.data)},Qn=function(t){An.postMessage(zn(t),sn.protocol+'//'+sn.host)};In&&Nn||(In=function(t){jn(arguments.length,1);var e=Sn(t)?t:Un(t),r=Rn(arguments,1);return Mn[++Dn]=function(){Tn(e,void 0,r)},an(Dn),Dn},Nn=function(t){delete Mn[t]},Cn?an=function(t){Ln.nextTick($n(t))}:qn&&qn.now?an=function(t){qn.now($n(t))}:Bn&&!kn?(cn=(un=new Bn).port2,un.port1.onmessage=Kn,an=En(cn.postMessage,cn)):An.addEventListener&&Sn(An.postMessage)&&!An.importScripts&&sn&&'file:'!==sn.protocol&&!On(Qn)?(an=Qn,An.addEventListener('message',Kn,!1)):an='onreadystatechange'in xn('script')?function(t){Pn.appendChild(xn('script')).onreadystatechange=function(){Pn.removeChild(this),Fn(t)}}:function(t){setTimeout($n(t),0)});var Hn,Wn,Gn,Vn,Yn,Jn,Zn,Xn,to={set:In,clear:Nn},eo=s,ro=/ipad|iphone|ipod/i.test(et)&&void 0!==eo.Pebble,no=/web0s(?!.*chrome)/i.test(et),oo=s,io=De,so=A.f,ao=to.set,uo=wn,co=ro,ho=no,lo=yr,fo=oo.MutationObserver||oo.WebKitMutationObserver,po=oo.document,vo=oo.process,yo=oo.Promise,mo=so(oo,'queueMicrotask'),go=mo&&mo.value;go||(Hn=function(){var t,e;for(lo&&(t=vo.domain)&&t.exit();Wn;){e=Wn.fn,Wn=Wn.next;try{e()}catch(t){throw Wn?Vn():Gn=void 0,t}}Gn=void 0,t&&t.enter()},uo||lo||ho||!fo||!po?!co&&yo&&yo.resolve?((Zn=yo.resolve(void 0)).constructor=yo,Xn=io(Zn.then,Zn),Vn=function(){Xn(Hn)}):lo?Vn=function(){vo.nextTick(Hn)}:(ao=io(ao,oo),Vn=function(){ao(Hn)}):(Yn=!0,Jn=po.createTextNode(''),new fo(Hn).observe(Jn,{characterData:!0}),Vn=function(){Jn.data=Yn=!Yn}));var bo=go||function(t){var e={fn:t,next:void 0};Gn&&(Gn.next=e),Wn||(Wn=e,Vn()),Gn=e},wo=s,Ao=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},To=function(){this.head=null,this.tail=null};To.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 Eo,So,_o,Oo=To,Po=w,Ro=Qr,xo=s.WeakMap,jo=Po(xo)&&/native code/.test(Ro(xo)),ko=jt.exports,Co=Qt,Io=ko('keys'),No=jo,Lo=s,qo=b,Uo=W,Bo=nr,zo=Dt,Do=Nt,Mo=function(t){return Io[t]||(Io[t]=Co(t))},Fo=Lo.TypeError,$o=Lo.WeakMap;if(No||Do.state){var Ko=Do.state||(Do.state=new $o),Qo=qo(Ko.get),Ho=qo(Ko.has),Wo=qo(Ko.set);Eo=function(t,e){if(Ho(Ko,t))throw new Fo('Object already initialized');return e.facade=t,Wo(Ko,t,e),e},So=function(t){return Qo(Ko,t)||{}},_o=function(t){return Ho(Ko,t)}}else{var Go=Mo('state');Eo=function(t,e){if(zo(t,Go))throw new Fo('Object already initialized');return e.facade=t,Bo(t,Go,e),e},So=function(t){return zo(t,Go)?t[Go]:{}},_o=function(t){return zo(t,Go)}}var Vo={set:Eo,get:So,has:_o,enforce:function(t){return _o(t)?So(t):Eo(t,{})},getterFor:function(t){return function(e){var r;if(!Uo(e)||(r=So(e)).type!==t)throw Fo('Incompatible receiver, '+t+' required');return r}}},Yo=s.Promise,Jo='object'==typeof Deno&&Deno&&'object'==typeof Deno.version,Zo=!Jo&&!yr&&'object'==typeof window&&'object'==typeof document,Xo=s,ti=Yo,ei=w,ri=qe,ni=Qr,oi=re,ii=Zo,si=Jo,ai=ut,ui=ti&&ti.prototype,ci=oi('species'),hi=!1,li=ei(Xo.PromiseRejectionEvent),fi={CONSTRUCTOR:ri('Promise',(function(){var t=ni(ti),e=t!==String(ti);if(!e&&66===ai)return!0;if(!ui.catch||!ui.finally)return!0;if(!ai||ai<51||!/native code/.test(t)){var r=new ti((function(t){t(1)})),n=function(t){t((function(){}),(function(){}))};if((r.constructor={})[ci]=n,!(hi=r.then((function(){}))instanceof n))return!0}return!e&&(ii||si)&&!li})),REJECTION_EVENT:li,SUBCLASSING:hi},pi={},di=Et,vi=function(t){var e,r;this.promise=new t((function(t,n){if(void 0!==e||void 0!==r)throw TypeError('Bad Promise constructor');e=t,r=n})),this.resolve=di(e),this.reject=di(r)};pi.f=function(t){return new vi(t)};var yi,mi,gi=vr,bi=yr,wi=s,Ai=_,Ti=function(t,e,r,n){return n&&n.enumerable?t[e]=r:mr(t,e,r),t},Ei=function(t,e,r,n){if(t){var o=r?t:t.prototype;Ir(o,Lr)||kr(o,Lr,{configurable:!0,value:e}),n&&!jr&&Cr(o,'toString',Nr)}},Si=function(t){var e=qr(t),r=Ur.f;Br&&e&&!e[zr]&&r(e,zr,{configurable:!0,get:function(){return this}})},_i=Et,Oi=w,Pi=W,Ri=function(t,e){if(Dr(e,t))return t;throw Mr('Incorrect invocation')},xi=yn,ji=to.set,ki=bo,Ci=function(t,e){var r=wo.console;r&&r.error&&(1==arguments.length?r.error(t):r.error(t,e))},Ii=Ao,Ni=Oo,Li=Vo,qi=Yo,Ui=pi,Bi=fi.CONSTRUCTOR,zi=fi.REJECTION_EVENT,Di=Li.getterFor('Promise'),Mi=Li.set,Fi=qi&&qi.prototype,$i=qi,Ki=Fi,Qi=wi.TypeError,Hi=wi.document,Wi=wi.process,Gi=Ui.f,Vi=Gi,Yi=!!(Hi&&Hi.createEvent&&wi.dispatchEvent),Ji=function(t){var e;return!(!Pi(t)||!Oi(e=t.then))&&e},Zi=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&&ns(e),e.rejection=1),!0===a?r=i:(h&&h.enter(),r=a(i),h&&(h.exit(),o=!0)),r===t.promise?c(Qi('Promise-chain cycle')):(n=Ji(r))?Ai(n,r,u,c):u(r)):c(i)}catch(t){h&&!o&&h.exit(),c(t)}},Xi=function(t,e){t.notified||(t.notified=!0,ki((function(){for(var r,n=t.reactions;r=n.get();)Zi(r,t);t.notified=!1,e&&!t.rejection&&es(t)})))},ts=function(t,e,r){var n,o;Yi?((n=Hi.createEvent('Event')).promise=e,n.reason=r,n.initEvent(t,!1,!0),wi.dispatchEvent(n)):n={promise:e,reason:r},!zi&&(o=wi['on'+t])?o(n):'unhandledrejection'===t&&Ci('Unhandled promise rejection',r)},es=function(t){Ai(ji,wi,(function(){var e,r=t.facade,n=t.value;if(rs(t)&&(e=Ii((function(){bi?Wi.emit('unhandledRejection',n,r):ts('unhandledrejection',r,n)})),t.rejection=bi||rs(t)?2:1,e.error))throw e.value}))},rs=function(t){return 1!==t.rejection&&!t.parent},ns=function(t){Ai(ji,wi,(function(){var e=t.facade;bi?Wi.emit('rejectionHandled',e):ts('rejectionhandled',e,t.value)}))},os=function(t,e,r){return function(n){t(e,n,r)}},is=function(t,e,r){t.done||(t.done=!0,r&&(t=r),t.value=e,t.state=2,Xi(t,!0))},ss=function(t,e,r){if(!t.done){t.done=!0,r&&(t=r);try{if(t.facade===e)throw Qi('Promise can\'t be resolved itself');var n=Ji(e);n?ki((function(){var r={done:!1};try{Ai(n,e,os(ss,r,t),os(is,r,t))}catch(e){is(r,e,t)}})):(t.value=e,t.state=1,Xi(t,!1))}catch(e){is({done:!1},e,t)}}};Bi&&(Ki=($i=function(t){Ri(this,Ki),_i(t),Ai(yi,this);var e=Di(this);try{t(os(ss,e),os(is,e))}catch(t){is(e,t)}}).prototype,(yi=function(t){Mi(this,{type:'Promise',done:!1,notified:!1,parent:!1,reactions:new Ni,rejection:!1,state:0,value:void 0})}).prototype=Ti(Ki,'then',(function(t,e){var r=Di(this),n=Gi(xi(this,$i));return r.parent=!0,n.ok=!Oi(t)||t,n.fail=Oi(e)&&e,n.domain=bi?Wi.domain:void 0,0==r.state?r.reactions.add(n):ki((function(){Zi(n,r)})),n.promise})),mi=function(){var t=new yi,e=Di(t);this.promise=t,this.resolve=os(ss,e),this.reject=os(is,e)},Ui.f=Gi=function(t){return t===$i||undefined===t?new mi(t):Vi(t)}),gi({global:!0,constructor:!0,wrap:!0,forced:Bi},{Promise:$i}),Ei($i,'Promise',!1,!0),Si('Promise');var as={},us=as,cs=re('iterator'),hs=Array.prototype,ls=Math.ceil,fs=Math.floor,ps=Math.trunc||function(t){var e=+t;return(e>0?fs:ls)(e)},ds=function(t){var e=+t;return e!=e||0===e?0:ps(e)},vs=Math.min,ys=function(t){return t>0?vs(ds(t),9007199254740991):0},ms=Pr,gs=_t,bs=as,ws=re('iterator'),As=function(t){if(null!=t)return gs(t,ws)||gs(t,'@@iterator')||bs[ms(t)]},Ts=_,Es=Et,Ss=He,_s=bt,Os=As,Ps=TypeError,Rs=_,xs=He,js=_t,ks=De,Cs=_,Is=He,Ns=bt,Ls=function(t){return void 0!==t&&(us.Array===t||hs[cs]===t)},qs=function(t){return ys(t.length)},Us=tt,Bs=function(t,e){var r=arguments.length<2?Os(t):e;if(Es(r))return Ss(Ts(r,t));throw Ps(_s(t)+' is not iterable')},zs=As,Ds=function(t,e,r){var n,o;xs(t);try{if(!(n=js(t,'return'))){if('throw'===e)throw r;return r}n=Rs(n,t)}catch(t){o=!0,n=t}if('throw'===e)throw r;if(o)throw n;return xs(n),r},Ms=TypeError,Fs=function(t,e){this.stopped=t,this.result=e},$s=Fs.prototype,Ks=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_RECORD),p=!(!r||!r.IS_ITERATOR),d=!(!r||!r.INTERRUPTED),v=ks(e,h),y=function(t){return n&&Ds(n,'normal',t),new Fs(!0,t)},m=function(t){return l?(Is(t),d?v(t[0],t[1],y):v(t[0],t[1])):d?v(t,y):v(t)};if(f)n=t.iterator;else if(p)n=t;else{if(!(o=zs(t)))throw Ms(Ns(t)+' is not iterable');if(Ls(o)){for(i=0,s=qs(t);s>i;i++)if((a=m(t[i]))&&Us($s,a))return a;return new Fs(!1)}n=Bs(t,o)}for(u=f?t.next:n.next;!(c=Cs(u,n)).done;){try{a=m(c.value)}catch(t){Ds(n,'throw',t)}if('object'==typeof a&&a&&Us($s,a))return a}return new Fs(!1)},Qs=re('iterator'),Hs=!1;try{var Ws=0,Gs={next:function(){return{done:!!Ws++}},return:function(){Hs=!0}};Gs[Qs]=function(){return this},Array.from(Gs,(function(){throw 2}))}catch(t){}var Vs=Yo,Ys=fi.CONSTRUCTOR||!function(t,e){if(!e&&!Hs)return!1;var r=!1;try{var n={};n[Qs]=function(){return{next:function(){return{done:r=!0}}}},t(n)}catch(t){}return r}((function(t){Vs.all(t).then(void 0,(function(){}))})),Js=_,Zs=Et,Xs=pi,ta=Ao,ea=Ks;vr({target:'Promise',stat:!0,forced:Ys},{all:function(t){var e=this,r=Xs.f(e),n=r.resolve,o=r.reject,i=ta((function(){var r=Zs(e.resolve),i=[],s=0,a=1;ea(t,(function(t){var u=s++,c=!1;a++,Js(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}});var ra=vr,na=fi.CONSTRUCTOR;Yo&&Yo.prototype,ra({target:'Promise',proto:!0,forced:na,real:!0},{catch:function(t){return this.then(void 0,t)}});var oa=_,ia=Et,sa=pi,aa=Ao,ua=Ks;vr({target:'Promise',stat:!0,forced:Ys},{race:function(t){var e=this,r=sa.f(e),n=r.reject,o=aa((function(){var o=ia(e.resolve);ua(t,(function(t){oa(o,e,t).then(r.resolve,n)}))}));return o.error&&n(o.value),r.promise}});var ca=_,ha=pi;vr({target:'Promise',stat:!0,forced:fi.CONSTRUCTOR},{reject:function(t){var e=ha.f(this);return ca(e.reject,void 0,t),e.promise}});var la=He,fa=W,pa=pi,da=function(t,e){if(la(t),fa(e)&&e.constructor===t)return e;var r=pa.f(t);return(0,r.resolve)(e),r.promise},va=vr,ya=Yo,ma=fi.CONSTRUCTOR,ga=da,ba=X('Promise'),wa=!ma;va({target:'Promise',stat:!0,forced:true},{resolve:function(t){return ga(wa&&this===ba?ya:this,t)}});var Aa=vr,Ta=Yo,Ea=a,Sa=X,_a=w,Oa=yn,Pa=da,Ra=Ta&&Ta.prototype;Aa({target:'Promise',proto:!0,real:!0,forced:!!Ta&&Ea((function(){Ra.finally.call({then:function(){}},(function(){}))}))},{finally:function(t){var e=Oa(this,Sa('Promise')),r=_a(t);return this.then(r?function(r){return Pa(e,t()).then((function(){return r}))}:t,r?function(r){return Pa(e,t()).then((function(){throw r}))}:t)}});var xa=X('Promise','finally');const ja=(()=>{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 ka,Ca,Ia,Na,La,qa,Ua,Ba={get:t=>function(t){const e=ja?ja.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{ja&&ja.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){ja&&ja.removeItem('_one-stat_'+t)}(t)}};exports.ApiEnv=void 0,(ka=exports.ApiEnv||(exports.ApiEnv={})).PROD='prod',ka.VK_ALIAS='vk_alias',ka.VIDEOTEST='videotest',ka.TEST='test',ka.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,(Ia=exports.ScreenDestination||(exports.ScreenDestination={})).CHROMECAST='chromecast',Ia.APPLE_TV='appletv',Ia.PIP='pip',Ia.HEADPHONES='externalHeadphones',Ia.SCREEN='',exports.ContentType=void 0,(Na=exports.ContentType||(exports.ContentType={})).MP4='mp4',Na.DASH='dash',Na.DASH_SEP='dash_sep',Na.ONDEMAND_DASH='ondemand_dash',Na.HLS='hls',Na.ONDEMAND_HLS='ondemand_hls',Na.WEBM='webm',Na.UNKNOWN='unknown',function(t){t.AUTO='auto',t.MANUAL=''}(La||(La={})),exports.ConnectionType=void 0,(qa=exports.ConnectionType||(exports.ConnectionType={})).HTTP1='http1',qa.HTTP2='http2',qa.HTTP3='http3',function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(Ua||(Ua={}));const za={[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]:''},Da={start:1e3,factor:1.5,max:3e5,random:.1};var Ma;!function(t){t[t.PARAM_SESSION_EXPIRED=102]='PARAM_SESSION_EXPIRED',t[t.PARAM_SESSION_KEY=103]='PARAM_SESSION_KEY',t[t.PARAM_SIGNATURE=104]='PARAM_SIGNATURE',t[t.AUTH_LOGIN=401]='AUTH_LOGIN'}(Ma||(Ma={}));class Fa{constructor(e){this.consequentAuthErrors=0,this.authorized$=new t.ValueSubject(!1),this.params=e;const r=Ba.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('')}(),Ba.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 Ma.PARAM_SESSION_EXPIRED:case Ma.PARAM_SESSION_KEY:case Ma.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=yield this._authorizeWithBackoff(),e>0?s(t,e-1):void 0;case Ma.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=xa(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.24',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,Da);return new Promise((t=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout((()=>{xa(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.24'.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=xa(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 Ma.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}))}}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}const Ka=$a({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Qa=Ka?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,Ha=Ka?Qa.fetch:window.fetch;Ka?Qa.Request:window.Request;class Wa{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 Ha(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}),za[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(),Ha(`${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 Ga{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 Wa({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:za[r.apiEnv],apiEnv:r.apiEnv,error$:o});this.api=new Fa({apiTransport:i,refreshAuthToken:r.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:o}),this.logger=new Ga({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()}logInited(){this.log({operation:'init'})}logReady(t){this.log({operation:'player_ready',param:String(t.time)})}logStarted(t){this.log({operation:'play',param:String(Math.round(t.position))})}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)})}logDownloadSpeed(t){this.log({operation:'download_speed',param:String(t.speed)})}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?Ua.YES:!1===this.statContext.connectionReused?Ua.NO:void 0,stat_type:!0===this.statContext.autoplay?La.AUTO:!1===this.statContext.autoplay?La.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}}};
|
|
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.js'));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={},T=!a((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),E=u,S=Function.prototype.call,_=E?S.bind(S):function(){return S.apply(S,arguments)},O={},P={}.propertyIsEnumerable,R=Object.getOwnPropertyDescriptor,x=R&&!P.call({1:2},1);O.f=x?function(t){var e=R(this,t);return!!e&&e.enumerable}:P;var j,k,C=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},I=b,N=I({}.toString),L=I(''.slice),q=function(t){return L(N(t),8,-1)},U=a,B=q,z=Object,D=b(''.split),M=U((function(){return!z('z').propertyIsEnumerable(0)}))?function(t){return'String'==B(t)?D(t,''):z(t)}:z,F=TypeError,$=function(t){if(null==t)throw F('Can\'t call method on '+t);return t},K=M,Q=$,H=w,W=function(t){return'object'==typeof t?null!==t:H(t)},G={},V=G,Y=s,J=w,Z=function(t){return J(t)?t:void 0},X=function(t,e){return arguments.length<2?Z(V[t])||Z(Y[t]):V[t]&&V[t][e]||Y[t]&&Y[t][e]},tt=b({}.isPrototypeOf),et=X('navigator','userAgent')||'',rt=s,nt=et,ot=rt.process,it=rt.Deno,st=ot&&ot.versions||it&&it.version,at=st&&st.v8;at&&(k=(j=at.split('.'))[0]>0&&j[0]<4?1:+(j[0]+j[1])),!k&&nt&&(!(j=nt.match(/Edge\/(\d+)/))||j[1]>=74)&&(j=nt.match(/Chrome\/(\d+)/))&&(k=+j[1]);var ut=k,ct=ut,ht=a,lt=!!Object.getOwnPropertySymbols&&!ht((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&ct&&ct<41})),ft=lt&&!Symbol.sham&&'symbol'==typeof Symbol.iterator,pt=X,dt=w,vt=tt,yt=Object,mt=ft?function(t){return'symbol'==typeof t}:function(t){var e=pt('Symbol');return dt(e)&&vt(e.prototype,yt(t))},gt=String,bt=function(t){try{return gt(t)}catch(t){return'Object'}},wt=w,At=bt,Tt=TypeError,Et=function(t){if(wt(t))return t;throw Tt(At(t)+' is not a function')},St=Et,_t=function(t,e){var r=t[e];return null==r?void 0:St(r)},Ot=_,Pt=w,Rt=W,xt=TypeError,jt={exports:{}},kt=s,Ct=Object.defineProperty,It=function(t,e){try{Ct(kt,t,{value:e,configurable:!0,writable:!0})}catch(r){kt[t]=e}return e},Nt=s['__core-js_shared__']||It('__core-js_shared__',{}),Lt=Nt;(jt.exports=function(t,e){return Lt[t]||(Lt[t]=void 0!==e?e:{})})('versions',[]).push({version:'3.24.1',mode:'pure',copyright:'© 2014-2022 Denis Pushkarev (zloirock.ru)',license:'https://github.com/zloirock/core-js/blob/v3.24.1/LICENSE',source:'https://github.com/zloirock/core-js'});var qt=$,Ut=Object,Bt=function(t){return Ut(qt(t))},zt=b({}.hasOwnProperty),Dt=Object.hasOwn||function(t,e){return zt(Bt(t),e)},Mt=b,Ft=0,$t=Math.random(),Kt=Mt(1..toString),Qt=function(t){return'Symbol('+(void 0===t?'':t)+')_'+Kt(++Ft+$t,36)},Ht=s,Wt=jt.exports,Gt=Dt,Vt=Qt,Yt=lt,Jt=ft,Zt=Wt('wks'),Xt=Ht.Symbol,te=Xt&&Xt.for,ee=Jt?Xt:Xt&&Xt.withoutSetter||Vt,re=function(t){if(!Gt(Zt,t)||!Yt&&'string'!=typeof Zt[t]){var e='Symbol.'+t;Yt&&Gt(Xt,t)?Zt[t]=Xt[t]:Zt[t]=Jt&&te?te(e):ee(e)}return Zt[t]},ne=_,oe=W,ie=mt,se=_t,ae=function(t,e){var r,n;if('string'===e&&Pt(r=t.toString)&&!Rt(n=Ot(r,t)))return n;if(Pt(r=t.valueOf)&&!Rt(n=Ot(r,t)))return n;if('string'!==e&&Pt(r=t.toString)&&!Rt(n=Ot(r,t)))return n;throw xt('Can\'t convert object to primitive value')},ue=TypeError,ce=re('toPrimitive'),he=function(t,e){if(!oe(t)||ie(t))return t;var r,n=se(t,ce);if(n){if(void 0===e&&(e='default'),r=ne(n,t,e),!oe(r)||ie(r))return r;throw ue('Can\'t convert object to primitive value')}return void 0===e&&(e='number'),ae(t,e)},le=mt,fe=function(t){var e=he(t,'string');return le(e)?e:e+''},pe=W,de=s.document,ve=pe(de)&&pe(de.createElement),ye=function(t){return ve?de.createElement(t):{}},me=ye,ge=!T&&!a((function(){return 7!=Object.defineProperty(me('div'),'a',{get:function(){return 7}}).a})),be=T,we=_,Ae=O,Te=C,Ee=function(t){return K(Q(t))},Se=fe,_e=Dt,Oe=ge,Pe=Object.getOwnPropertyDescriptor;A.f=be?Pe:function(t,e){if(t=Ee(t),e=Se(e),Oe)try{return Pe(t,e)}catch(t){}if(_e(t,e))return Te(!we(Ae.f,t,e),t[e])};var Re=a,xe=w,je=/#|\.prototype\./,ke=function(t,e){var r=Ie[Ce(t)];return r==Le||r!=Ne&&(xe(e)?Re(e):!!e)},Ce=ke.normalize=function(t){return String(t).replace(je,'.').toLowerCase()},Ie=ke.data={},Ne=ke.NATIVE='N',Le=ke.POLYFILL='P',qe=ke,Ue=Et,Be=u,ze=b(b.bind),De=function(t,e){return Ue(t),void 0===e?t:Be?ze(t,e):function(){return t.apply(e,arguments)}},Me={},Fe=T&&a((function(){return 42!=Object.defineProperty((function(){}),'prototype',{value:42,writable:!1}).prototype})),$e=W,Ke=String,Qe=TypeError,He=function(t){if($e(t))return t;throw Qe(Ke(t)+' is not an object')},We=T,Ge=ge,Ve=Fe,Ye=He,Je=fe,Ze=TypeError,Xe=Object.defineProperty,tr=Object.getOwnPropertyDescriptor;Me.f=We?Ve?function(t,e,r){if(Ye(t),e=Je(e),Ye(r),'function'==typeof t&&'prototype'===e&&'value'in r&&'writable'in r&&!r.writable){var n=tr(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 Xe(t,e,r)}:Xe:function(t,e,r){if(Ye(t),e=Je(e),Ye(r),Ge)try{return Xe(t,e,r)}catch(t){}if('get'in r||'set'in r)throw Ze('Accessors not supported');return'value'in r&&(t[e]=r.value),t};var er=Me,rr=C,nr=T?function(t,e,r){return er.f(t,e,rr(1,r))}:function(t,e,r){return t[e]=r,t},or=s,ir=p,sr=b,ar=w,ur=A.f,cr=qe,hr=G,lr=De,fr=nr,pr=Dt,dr=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 ir(t,this,arguments)};return e.prototype=t.prototype,e},vr=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?or:f?or[h]:(or[h]||{}).prototype,v=l?hr:hr[h]||fr(hr,h,{})[h],y=v.prototype;for(o in e)r=!cr(l?o:h+(f?'.':'#')+o,t.forced)&&d&&pr(d,o),s=v[o],r&&(a=t.dontCallGetSet?(c=ur(d,o))&&c.value:d[o]),i=r&&a?a:e[o],r&&typeof s==typeof i||(u=t.bind&&r?lr(i,or):t.wrap&&r?dr(i):p&&ar(i)?sr(i):i,(t.sham||i&&i.sham||s&&s.sham)&&fr(u,'sham',!0),fr(v,o,u),p&&(pr(hr,n=h+'Prototype')||fr(hr,n,{}),fr(hr[n],o,i),t.real&&y&&!y[o]&&fr(y,o,i)))},yr='process'==q(s.process),mr=nr,gr=(TypeError,b);Object.setPrototypeOf||'__proto__'in{}&&function(){var t,e=!1,r={};try{(t=gr(Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').set))(r,[]),e=r instanceof Array}catch(t){}}();var br={};br[re('toStringTag')]='z';var wr='[object z]'===String(br),Ar=wr,Tr=w,Er=q,Sr=re('toStringTag'),_r=Object,Or='Arguments'==Er(function(){return arguments}()),Pr=Ar?Er: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=_r(t),Sr))?r:Or?Er(e):'Object'==(n=Er(e))&&Tr(e.callee)?'Arguments':n},Rr=Pr,xr=wr?{}.toString:function(){return'[object '+Rr(this)+']'},jr=wr,kr=Me.f,Cr=nr,Ir=Dt,Nr=xr,Lr=re('toStringTag'),qr=X,Ur=Me,Br=T,zr=re('species'),Dr=tt,Mr=TypeError,Fr=w,$r=Nt,Kr=b(Function.toString);Fr($r.inspectSource)||($r.inspectSource=function(t){return Kr(t)});var Qr=$r.inspectSource,Hr=b,Wr=a,Gr=w,Vr=Pr,Yr=Qr,Jr=function(){},Zr=[],Xr=X('Reflect','construct'),tn=/^\s*(?:class|function)\b/,en=Hr(tn.exec),rn=!tn.exec(Jr),nn=function(t){if(!Gr(t))return!1;try{return Xr(Jr,Zr,t),!0}catch(t){return!1}},on=function(t){if(!Gr(t))return!1;switch(Vr(t)){case'AsyncFunction':case'GeneratorFunction':case'AsyncGeneratorFunction':return!1}try{return rn||!!en(tn,Yr(t))}catch(t){return!0}};on.sham=!0;var sn,an,un,cn,hn=!Xr||Wr((function(){var t;return nn(nn.call)||!nn(Object)||!nn((function(){t=!0}))||t}))?on:nn,ln=bt,fn=TypeError,pn=He,dn=function(t){if(hn(t))return t;throw fn(ln(t)+' is not a constructor')},vn=re('species'),yn=function(t,e){var r,n=pn(t).constructor;return void 0===n||null==(r=pn(n)[vn])?e:dn(r)},mn=X('document','documentElement'),gn=b([].slice),bn=TypeError,wn=/(?:ipad|iphone|ipod).*applewebkit/i.test(et),An=s,Tn=p,En=De,Sn=w,_n=Dt,On=a,Pn=mn,Rn=gn,xn=ye,jn=function(t,e){if(t<e)throw bn('Not enough arguments');return t},kn=wn,Cn=yr,In=An.setImmediate,Nn=An.clearImmediate,Ln=An.process,qn=An.Dispatch,Un=An.Function,Bn=An.MessageChannel,zn=An.String,Dn=0,Mn={};try{sn=An.location}catch(t){}var Fn=function(t){if(_n(Mn,t)){var e=Mn[t];delete Mn[t],e()}},$n=function(t){return function(){Fn(t)}},Kn=function(t){Fn(t.data)},Qn=function(t){An.postMessage(zn(t),sn.protocol+'//'+sn.host)};In&&Nn||(In=function(t){jn(arguments.length,1);var e=Sn(t)?t:Un(t),r=Rn(arguments,1);return Mn[++Dn]=function(){Tn(e,void 0,r)},an(Dn),Dn},Nn=function(t){delete Mn[t]},Cn?an=function(t){Ln.nextTick($n(t))}:qn&&qn.now?an=function(t){qn.now($n(t))}:Bn&&!kn?(cn=(un=new Bn).port2,un.port1.onmessage=Kn,an=En(cn.postMessage,cn)):An.addEventListener&&Sn(An.postMessage)&&!An.importScripts&&sn&&'file:'!==sn.protocol&&!On(Qn)?(an=Qn,An.addEventListener('message',Kn,!1)):an='onreadystatechange'in xn('script')?function(t){Pn.appendChild(xn('script')).onreadystatechange=function(){Pn.removeChild(this),Fn(t)}}:function(t){setTimeout($n(t),0)});var Hn,Wn,Gn,Vn,Yn,Jn,Zn,Xn,to={set:In,clear:Nn},eo=s,ro=/ipad|iphone|ipod/i.test(et)&&void 0!==eo.Pebble,no=/web0s(?!.*chrome)/i.test(et),oo=s,io=De,so=A.f,ao=to.set,uo=wn,co=ro,ho=no,lo=yr,fo=oo.MutationObserver||oo.WebKitMutationObserver,po=oo.document,vo=oo.process,yo=oo.Promise,mo=so(oo,'queueMicrotask'),go=mo&&mo.value;go||(Hn=function(){var t,e;for(lo&&(t=vo.domain)&&t.exit();Wn;){e=Wn.fn,Wn=Wn.next;try{e()}catch(t){throw Wn?Vn():Gn=void 0,t}}Gn=void 0,t&&t.enter()},uo||lo||ho||!fo||!po?!co&&yo&&yo.resolve?((Zn=yo.resolve(void 0)).constructor=yo,Xn=io(Zn.then,Zn),Vn=function(){Xn(Hn)}):lo?Vn=function(){vo.nextTick(Hn)}:(ao=io(ao,oo),Vn=function(){ao(Hn)}):(Yn=!0,Jn=po.createTextNode(''),new fo(Hn).observe(Jn,{characterData:!0}),Vn=function(){Jn.data=Yn=!Yn}));var bo=go||function(t){var e={fn:t,next:void 0};Gn&&(Gn.next=e),Wn||(Wn=e,Vn()),Gn=e},wo=s,Ao=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},To=function(){this.head=null,this.tail=null};To.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 Eo,So,_o,Oo=To,Po=w,Ro=Qr,xo=s.WeakMap,jo=Po(xo)&&/native code/.test(Ro(xo)),ko=jt.exports,Co=Qt,Io=ko('keys'),No=jo,Lo=s,qo=b,Uo=W,Bo=nr,zo=Dt,Do=Nt,Mo=function(t){return Io[t]||(Io[t]=Co(t))},Fo=Lo.TypeError,$o=Lo.WeakMap;if(No||Do.state){var Ko=Do.state||(Do.state=new $o),Qo=qo(Ko.get),Ho=qo(Ko.has),Wo=qo(Ko.set);Eo=function(t,e){if(Ho(Ko,t))throw new Fo('Object already initialized');return e.facade=t,Wo(Ko,t,e),e},So=function(t){return Qo(Ko,t)||{}},_o=function(t){return Ho(Ko,t)}}else{var Go=Mo('state');Eo=function(t,e){if(zo(t,Go))throw new Fo('Object already initialized');return e.facade=t,Bo(t,Go,e),e},So=function(t){return zo(t,Go)?t[Go]:{}},_o=function(t){return zo(t,Go)}}var Vo={set:Eo,get:So,has:_o,enforce:function(t){return _o(t)?So(t):Eo(t,{})},getterFor:function(t){return function(e){var r;if(!Uo(e)||(r=So(e)).type!==t)throw Fo('Incompatible receiver, '+t+' required');return r}}},Yo=s.Promise,Jo='object'==typeof Deno&&Deno&&'object'==typeof Deno.version,Zo=!Jo&&!yr&&'object'==typeof window&&'object'==typeof document,Xo=s,ti=Yo,ei=w,ri=qe,ni=Qr,oi=re,ii=Zo,si=Jo,ai=ut,ui=ti&&ti.prototype,ci=oi('species'),hi=!1,li=ei(Xo.PromiseRejectionEvent),fi={CONSTRUCTOR:ri('Promise',(function(){var t=ni(ti),e=t!==String(ti);if(!e&&66===ai)return!0;if(!ui.catch||!ui.finally)return!0;if(!ai||ai<51||!/native code/.test(t)){var r=new ti((function(t){t(1)})),n=function(t){t((function(){}),(function(){}))};if((r.constructor={})[ci]=n,!(hi=r.then((function(){}))instanceof n))return!0}return!e&&(ii||si)&&!li})),REJECTION_EVENT:li,SUBCLASSING:hi},pi={},di=Et,vi=function(t){var e,r;this.promise=new t((function(t,n){if(void 0!==e||void 0!==r)throw TypeError('Bad Promise constructor');e=t,r=n})),this.resolve=di(e),this.reject=di(r)};pi.f=function(t){return new vi(t)};var yi,mi,gi=vr,bi=yr,wi=s,Ai=_,Ti=function(t,e,r,n){return n&&n.enumerable?t[e]=r:mr(t,e,r),t},Ei=function(t,e,r,n){if(t){var o=r?t:t.prototype;Ir(o,Lr)||kr(o,Lr,{configurable:!0,value:e}),n&&!jr&&Cr(o,'toString',Nr)}},Si=function(t){var e=qr(t),r=Ur.f;Br&&e&&!e[zr]&&r(e,zr,{configurable:!0,get:function(){return this}})},_i=Et,Oi=w,Pi=W,Ri=function(t,e){if(Dr(e,t))return t;throw Mr('Incorrect invocation')},xi=yn,ji=to.set,ki=bo,Ci=function(t,e){var r=wo.console;r&&r.error&&(1==arguments.length?r.error(t):r.error(t,e))},Ii=Ao,Ni=Oo,Li=Vo,qi=Yo,Ui=pi,Bi=fi.CONSTRUCTOR,zi=fi.REJECTION_EVENT,Di=Li.getterFor('Promise'),Mi=Li.set,Fi=qi&&qi.prototype,$i=qi,Ki=Fi,Qi=wi.TypeError,Hi=wi.document,Wi=wi.process,Gi=Ui.f,Vi=Gi,Yi=!!(Hi&&Hi.createEvent&&wi.dispatchEvent),Ji=function(t){var e;return!(!Pi(t)||!Oi(e=t.then))&&e},Zi=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&&ns(e),e.rejection=1),!0===a?r=i:(h&&h.enter(),r=a(i),h&&(h.exit(),o=!0)),r===t.promise?c(Qi('Promise-chain cycle')):(n=Ji(r))?Ai(n,r,u,c):u(r)):c(i)}catch(t){h&&!o&&h.exit(),c(t)}},Xi=function(t,e){t.notified||(t.notified=!0,ki((function(){for(var r,n=t.reactions;r=n.get();)Zi(r,t);t.notified=!1,e&&!t.rejection&&es(t)})))},ts=function(t,e,r){var n,o;Yi?((n=Hi.createEvent('Event')).promise=e,n.reason=r,n.initEvent(t,!1,!0),wi.dispatchEvent(n)):n={promise:e,reason:r},!zi&&(o=wi['on'+t])?o(n):'unhandledrejection'===t&&Ci('Unhandled promise rejection',r)},es=function(t){Ai(ji,wi,(function(){var e,r=t.facade,n=t.value;if(rs(t)&&(e=Ii((function(){bi?Wi.emit('unhandledRejection',n,r):ts('unhandledrejection',r,n)})),t.rejection=bi||rs(t)?2:1,e.error))throw e.value}))},rs=function(t){return 1!==t.rejection&&!t.parent},ns=function(t){Ai(ji,wi,(function(){var e=t.facade;bi?Wi.emit('rejectionHandled',e):ts('rejectionhandled',e,t.value)}))},os=function(t,e,r){return function(n){t(e,n,r)}},is=function(t,e,r){t.done||(t.done=!0,r&&(t=r),t.value=e,t.state=2,Xi(t,!0))},ss=function(t,e,r){if(!t.done){t.done=!0,r&&(t=r);try{if(t.facade===e)throw Qi('Promise can\'t be resolved itself');var n=Ji(e);n?ki((function(){var r={done:!1};try{Ai(n,e,os(ss,r,t),os(is,r,t))}catch(e){is(r,e,t)}})):(t.value=e,t.state=1,Xi(t,!1))}catch(e){is({done:!1},e,t)}}};Bi&&(Ki=($i=function(t){Ri(this,Ki),_i(t),Ai(yi,this);var e=Di(this);try{t(os(ss,e),os(is,e))}catch(t){is(e,t)}}).prototype,(yi=function(t){Mi(this,{type:'Promise',done:!1,notified:!1,parent:!1,reactions:new Ni,rejection:!1,state:0,value:void 0})}).prototype=Ti(Ki,'then',(function(t,e){var r=Di(this),n=Gi(xi(this,$i));return r.parent=!0,n.ok=!Oi(t)||t,n.fail=Oi(e)&&e,n.domain=bi?Wi.domain:void 0,0==r.state?r.reactions.add(n):ki((function(){Zi(n,r)})),n.promise})),mi=function(){var t=new yi,e=Di(t);this.promise=t,this.resolve=os(ss,e),this.reject=os(is,e)},Ui.f=Gi=function(t){return t===$i||undefined===t?new mi(t):Vi(t)}),gi({global:!0,constructor:!0,wrap:!0,forced:Bi},{Promise:$i}),Ei($i,'Promise',!1,!0),Si('Promise');var as={},us=as,cs=re('iterator'),hs=Array.prototype,ls=Math.ceil,fs=Math.floor,ps=Math.trunc||function(t){var e=+t;return(e>0?fs:ls)(e)},ds=function(t){var e=+t;return e!=e||0===e?0:ps(e)},vs=Math.min,ys=function(t){return t>0?vs(ds(t),9007199254740991):0},ms=Pr,gs=_t,bs=as,ws=re('iterator'),As=function(t){if(null!=t)return gs(t,ws)||gs(t,'@@iterator')||bs[ms(t)]},Ts=_,Es=Et,Ss=He,_s=bt,Os=As,Ps=TypeError,Rs=_,xs=He,js=_t,ks=De,Cs=_,Is=He,Ns=bt,Ls=function(t){return void 0!==t&&(us.Array===t||hs[cs]===t)},qs=function(t){return ys(t.length)},Us=tt,Bs=function(t,e){var r=arguments.length<2?Os(t):e;if(Es(r))return Ss(Ts(r,t));throw Ps(_s(t)+' is not iterable')},zs=As,Ds=function(t,e,r){var n,o;xs(t);try{if(!(n=js(t,'return'))){if('throw'===e)throw r;return r}n=Rs(n,t)}catch(t){o=!0,n=t}if('throw'===e)throw r;if(o)throw n;return xs(n),r},Ms=TypeError,Fs=function(t,e){this.stopped=t,this.result=e},$s=Fs.prototype,Ks=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_RECORD),p=!(!r||!r.IS_ITERATOR),d=!(!r||!r.INTERRUPTED),v=ks(e,h),y=function(t){return n&&Ds(n,'normal',t),new Fs(!0,t)},m=function(t){return l?(Is(t),d?v(t[0],t[1],y):v(t[0],t[1])):d?v(t,y):v(t)};if(f)n=t.iterator;else if(p)n=t;else{if(!(o=zs(t)))throw Ms(Ns(t)+' is not iterable');if(Ls(o)){for(i=0,s=qs(t);s>i;i++)if((a=m(t[i]))&&Us($s,a))return a;return new Fs(!1)}n=Bs(t,o)}for(u=f?t.next:n.next;!(c=Cs(u,n)).done;){try{a=m(c.value)}catch(t){Ds(n,'throw',t)}if('object'==typeof a&&a&&Us($s,a))return a}return new Fs(!1)},Qs=re('iterator'),Hs=!1;try{var Ws=0,Gs={next:function(){return{done:!!Ws++}},return:function(){Hs=!0}};Gs[Qs]=function(){return this},Array.from(Gs,(function(){throw 2}))}catch(t){}var Vs=Yo,Ys=fi.CONSTRUCTOR||!function(t,e){if(!e&&!Hs)return!1;var r=!1;try{var n={};n[Qs]=function(){return{next:function(){return{done:r=!0}}}},t(n)}catch(t){}return r}((function(t){Vs.all(t).then(void 0,(function(){}))})),Js=_,Zs=Et,Xs=pi,ta=Ao,ea=Ks;vr({target:'Promise',stat:!0,forced:Ys},{all:function(t){var e=this,r=Xs.f(e),n=r.resolve,o=r.reject,i=ta((function(){var r=Zs(e.resolve),i=[],s=0,a=1;ea(t,(function(t){var u=s++,c=!1;a++,Js(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}});var ra=vr,na=fi.CONSTRUCTOR;Yo&&Yo.prototype,ra({target:'Promise',proto:!0,forced:na,real:!0},{catch:function(t){return this.then(void 0,t)}});var oa=_,ia=Et,sa=pi,aa=Ao,ua=Ks;vr({target:'Promise',stat:!0,forced:Ys},{race:function(t){var e=this,r=sa.f(e),n=r.reject,o=aa((function(){var o=ia(e.resolve);ua(t,(function(t){oa(o,e,t).then(r.resolve,n)}))}));return o.error&&n(o.value),r.promise}});var ca=_,ha=pi;vr({target:'Promise',stat:!0,forced:fi.CONSTRUCTOR},{reject:function(t){var e=ha.f(this);return ca(e.reject,void 0,t),e.promise}});var la=He,fa=W,pa=pi,da=function(t,e){if(la(t),fa(e)&&e.constructor===t)return e;var r=pa.f(t);return(0,r.resolve)(e),r.promise},va=vr,ya=Yo,ma=fi.CONSTRUCTOR,ga=da,ba=X('Promise'),wa=!ma;va({target:'Promise',stat:!0,forced:true},{resolve:function(t){return ga(wa&&this===ba?ya:this,t)}});var Aa=vr,Ta=Yo,Ea=a,Sa=X,_a=w,Oa=yn,Pa=da,Ra=Ta&&Ta.prototype;Aa({target:'Promise',proto:!0,real:!0,forced:!!Ta&&Ea((function(){Ra.finally.call({then:function(){}},(function(){}))}))},{finally:function(t){var e=Oa(this,Sa('Promise')),r=_a(t);return this.then(r?function(r){return Pa(e,t()).then((function(){return r}))}:t,r?function(r){return Pa(e,t()).then((function(){throw r}))}:t)}});var xa=X('Promise','finally');const ja=(()=>{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 ka,Ca,Ia,Na,La,qa,Ua,Ba={get:t=>function(t){const e=ja?ja.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{ja&&ja.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){ja&&ja.removeItem('_one-stat_'+t)}(t)}};exports.ApiEnv=void 0,(ka=exports.ApiEnv||(exports.ApiEnv={})).PROD='prod',ka.VK_ALIAS='vk_alias',ka.VIDEOTEST='videotest',ka.TEST='test',ka.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,(Ia=exports.ScreenDestination||(exports.ScreenDestination={})).CHROMECAST='chromecast',Ia.APPLE_TV='appletv',Ia.PIP='pip',Ia.HEADPHONES='externalHeadphones',Ia.SCREEN='',exports.ContentType=void 0,(Na=exports.ContentType||(exports.ContentType={})).MP4='mp4',Na.DASH='dash',Na.DASH_SEP='dash_sep',Na.ONDEMAND_DASH='ondemand_dash',Na.HLS='hls',Na.ONDEMAND_HLS='ondemand_hls',Na.WEBM='webm',Na.RTMP='rtmp',Na.UNKNOWN='unknown',function(t){t.AUTO='auto',t.MANUAL=''}(La||(La={})),exports.ConnectionType=void 0,(qa=exports.ConnectionType||(exports.ConnectionType={})).HTTP1='http1',qa.HTTP2='http2',qa.HTTP3='http3',function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(Ua||(Ua={}));const za={[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]:''},Da={start:1e3,factor:1.5,max:3e5,random:.1};var Ma;!function(t){t[t.PARAM_SESSION_EXPIRED=102]='PARAM_SESSION_EXPIRED',t[t.PARAM_SESSION_KEY=103]='PARAM_SESSION_KEY',t[t.PARAM_SIGNATURE=104]='PARAM_SIGNATURE',t[t.AUTH_LOGIN=401]='AUTH_LOGIN'}(Ma||(Ma={}));class Fa{constructor(e){this.consequentAuthErrors=0,this.authorized$=new t.ValueSubject(!1),this.params=e;const r=Ba.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('')}(),Ba.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 Ma.PARAM_SESSION_EXPIRED:case Ma.PARAM_SESSION_KEY:case Ma.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=yield this._authorizeWithBackoff(),e>0?s(t,e-1):void 0;case Ma.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=xa(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.25',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,Da);return new Promise((t=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout((()=>{xa(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.25'.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=xa(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 Ma.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}))}}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}const Ka=$a({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Qa=Ka?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,Ha=Ka?Qa.fetch:window.fetch;Ka?Qa.Request:window.Request;class Wa{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 Ha(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}),za[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(),Ha(`${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 Ga{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 Wa({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:za[r.apiEnv],apiEnv:r.apiEnv,error$:o});this.api=new Fa({apiTransport:i,refreshAuthToken:r.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:o}),this.logger=new Ga({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()}logInited(){this.log({operation:'init'})}logReady(t){this.log({operation:'player_ready',param:String(t.time)})}logStarted(t){this.log({operation:'play',param:String(Math.round(t.position))})}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)})}logDownloadSpeed(t){this.log({operation:'download_speed',param:String(t.speed)})}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?Ua.YES:!1===this.statContext.connectionReused?Ua.NO:void 0,stat_type:!0===this.statContext.autoplay?La.AUTO:!1===this.statContext.autoplay?La.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
|
-
*
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-statistics v1.0.25
|
|
3
|
+
* Wed, 21 Sep 2022 08:17:06 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-25/doc/
|
|
5
5
|
*/
|
|
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.js';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}},f=!h((function(){var t=function(){}.bind();return'function'!=typeof t||t.hasOwnProperty('prototype')})),l=f,p=Function.prototype,d=p.apply,v=p.call,m='object'==typeof Reflect&&Reflect.apply||(l?v.bind(d):function(){return v.apply(d,arguments)}),y=f,g=Function.prototype,b=g.bind,w=g.call,_=y&&b.bind(w,w),T=y?function(t){return t&&_(t)}:function(t){return t&&function(){return w.apply(t,arguments)}},O=function(t){return'function'==typeof t},A={},S=!h((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),E=f,P=Function.prototype.call,R=E?P.bind(P):function(){return P.apply(P,arguments)},k={},j={}.propertyIsEnumerable,C=Object.getOwnPropertyDescriptor,x=C&&!j.call({1:2},1);k.f=x?function(t){var e=C(this,t);return!!e&&e.enumerable}:j;var I,N,L=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},U=T,q=U({}.toString),B=U(''.slice),z=function(t){return B(q(t),8,-1)},M=h,D=z,F=Object,$=T(''.split),K=M((function(){return!F('z').propertyIsEnumerable(0)}))?function(t){return'String'==D(t)?$(t,''):F(t)}:F,H=TypeError,Q=function(t){if(null==t)throw H('Can\'t call method on '+t);return t},W=K,G=Q,Y=O,J=function(t){return'object'==typeof t?null!==t:Y(t)},V={},Z=V,X=c,tt=O,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=T({}.isPrototypeOf),ot=rt('navigator','userAgent')||'',it=c,st=ot,at=it.process,ut=it.Deno,ct=at&&at.versions||ut&&ut.version,ht=ct&&ct.v8;ht&&(N=(I=ht.split('.'))[0]>0&&I[0]<4?1:+(I[0]+I[1])),!N&&st&&(!(I=st.match(/Edge\/(\d+)/))||I[1]>=74)&&(I=st.match(/Chrome\/(\d+)/))&&(N=+I[1]);var ft=N,lt=ft,pt=h,dt=!!Object.getOwnPropertySymbols&&!pt((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&<&<<41})),vt=dt&&!Symbol.sham&&'symbol'==typeof Symbol.iterator,mt=rt,yt=O,gt=nt,bt=Object,wt=vt?function(t){return'symbol'==typeof t}:function(t){var e=mt('Symbol');return yt(e)&>(e.prototype,bt(t))},_t=String,Tt=function(t){try{return _t(t)}catch(t){return'Object'}},Ot=O,At=Tt,St=TypeError,Et=function(t){if(Ot(t))return t;throw St(At(t)+' is not a function')},Pt=Et,Rt=function(t,e){var r=t[e];return null==r?void 0:Pt(r)},kt=R,jt=O,Ct=J,xt=TypeError,It={exports:{}},Nt=c,Lt=Object.defineProperty,Ut=function(t,e){try{Lt(Nt,t,{value:e,configurable:!0,writable:!0})}catch(r){Nt[t]=e}return e},qt=c['__core-js_shared__']||Ut('__core-js_shared__',{}),Bt=qt;(It.exports=function(t,e){return Bt[t]||(Bt[t]=void 0!==e?e:{})})('versions',[]).push({version:'3.24.1',mode:'pure',copyright:'© 2014-2022 Denis Pushkarev (zloirock.ru)',license:'https://github.com/zloirock/core-js/blob/v3.24.1/LICENSE',source:'https://github.com/zloirock/core-js'});var zt=Q,Mt=Object,Dt=function(t){return Mt(zt(t))},Ft=T({}.hasOwnProperty),$t=Object.hasOwn||function(t,e){return Ft(Dt(t),e)},Kt=T,Ht=0,Qt=Math.random(),Wt=Kt(1..toString),Gt=function(t){return'Symbol('+(void 0===t?'':t)+')_'+Wt(++Ht+Qt,36)},Yt=c,Jt=It.exports,Vt=$t,Zt=Gt,Xt=dt,te=vt,ee=Jt('wks'),re=Yt.Symbol,ne=re&&re.for,oe=te?re:re&&re.withoutSetter||Zt,ie=function(t){if(!Vt(ee,t)||!Xt&&'string'!=typeof ee[t]){var e='Symbol.'+t;Xt&&Vt(re,t)?ee[t]=re[t]:ee[t]=te&&ne?ne(e):oe(e)}return ee[t]},se=R,ae=J,ue=wt,ce=Rt,he=function(t,e){var r,n;if('string'===e&&jt(r=t.toString)&&!Ct(n=kt(r,t)))return n;if(jt(r=t.valueOf)&&!Ct(n=kt(r,t)))return n;if('string'!==e&&jt(r=t.toString)&&!Ct(n=kt(r,t)))return n;throw xt('Can\'t convert object to primitive value')},fe=TypeError,le=ie('toPrimitive'),pe=function(t,e){if(!ae(t)||ue(t))return t;var r,n=ce(t,le);if(n){if(void 0===e&&(e='default'),r=se(n,t,e),!ae(r)||ue(r))return r;throw fe('Can\'t convert object to primitive value')}return void 0===e&&(e='number'),he(t,e)},de=wt,ve=function(t){var e=pe(t,'string');return de(e)?e:e+''},me=J,ye=c.document,ge=me(ye)&&me(ye.createElement),be=function(t){return ge?ye.createElement(t):{}},we=be,_e=!S&&!h((function(){return 7!=Object.defineProperty(we('div'),'a',{get:function(){return 7}}).a})),Te=S,Oe=R,Ae=k,Se=L,Ee=function(t){return W(G(t))},Pe=ve,Re=$t,ke=_e,je=Object.getOwnPropertyDescriptor;A.f=Te?je:function(t,e){if(t=Ee(t),e=Pe(e),ke)try{return je(t,e)}catch(t){}if(Re(t,e))return Se(!Oe(Ae.f,t,e),t[e])};var Ce=h,xe=O,Ie=/#|\.prototype\./,Ne=function(t,e){var r=Ue[Le(t)];return r==Be||r!=qe&&(xe(e)?Ce(e):!!e)},Le=Ne.normalize=function(t){return String(t).replace(Ie,'.').toLowerCase()},Ue=Ne.data={},qe=Ne.NATIVE='N',Be=Ne.POLYFILL='P',ze=Ne,Me=Et,De=f,Fe=T(T.bind),$e=function(t,e){return Me(t),void 0===e?t:De?Fe(t,e):function(){return t.apply(e,arguments)}},Ke={},He=S&&h((function(){return 42!=Object.defineProperty((function(){}),'prototype',{value:42,writable:!1}).prototype})),Qe=J,We=String,Ge=TypeError,Ye=function(t){if(Qe(t))return t;throw Ge(We(t)+' is not an object')},Je=S,Ve=_e,Ze=He,Xe=Ye,tr=ve,er=TypeError,rr=Object.defineProperty,nr=Object.getOwnPropertyDescriptor;Ke.f=Je?Ze?function(t,e,r){if(Xe(t),e=tr(e),Xe(r),'function'==typeof t&&'prototype'===e&&'value'in r&&'writable'in r&&!r.writable){var n=nr(t,e);n&&n.writable&&(t[e]=r.value,r={configurable:'configurable'in r?r.configurable:n.configurable,enumerable:'enumerable'in r?r.enumerable:n.enumerable,writable:!1})}return rr(t,e,r)}:rr:function(t,e,r){if(Xe(t),e=tr(e),Xe(r),Ve)try{return rr(t,e,r)}catch(t){}if('get'in r||'set'in r)throw er('Accessors not supported');return'value'in r&&(t[e]=r.value),t};var or=Ke,ir=L,sr=S?function(t,e,r){return or.f(t,e,ir(1,r))}:function(t,e,r){return t[e]=r,t},ar=c,ur=m,cr=T,hr=O,fr=A.f,lr=ze,pr=V,dr=$e,vr=sr,mr=$t,yr=function(t){var e=function(r,n,o){if(this instanceof e){switch(arguments.length){case 0:return new t;case 1:return new t(r);case 2:return new t(r,n)}return new t(r,n,o)}return ur(t,this,arguments)};return e.prototype=t.prototype,e},gr=function(t,e){var r,n,o,i,s,a,u,c,h=t.target,f=t.global,l=t.stat,p=t.proto,d=f?ar:l?ar[h]:(ar[h]||{}).prototype,v=f?pr:pr[h]||vr(pr,h,{})[h],m=v.prototype;for(o in e)r=!lr(f?o:h+(l?'.':'#')+o,t.forced)&&d&&mr(d,o),s=v[o],r&&(a=t.dontCallGetSet?(c=fr(d,o))&&c.value:d[o]),i=r&&a?a:e[o],r&&typeof s==typeof i||(u=t.bind&&r?dr(i,ar):t.wrap&&r?yr(i):p&&hr(i)?cr(i):i,(t.sham||i&&i.sham||s&&s.sham)&&vr(u,'sham',!0),vr(v,o,u),p&&(mr(pr,n=h+'Prototype')||vr(pr,n,{}),vr(pr[n],o,i),t.real&&m&&!m[o]&&vr(m,o,i)))},br='process'==z(c.process),wr=sr,_r=(TypeError,T);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[ie('toStringTag')]='z';var Or='[object z]'===String(Tr),Ar=Or,Sr=O,Er=z,Pr=ie('toStringTag'),Rr=Object,kr='Arguments'==Er(function(){return arguments}()),jr=Ar?Er: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=Rr(t),Pr))?r:kr?Er(e):'Object'==(n=Er(e))&&Sr(e.callee)?'Arguments':n},Cr=jr,xr=Or?{}.toString:function(){return'[object '+Cr(this)+']'},Ir=Or,Nr=Ke.f,Lr=sr,Ur=$t,qr=xr,Br=ie('toStringTag'),zr=rt,Mr=Ke,Dr=S,Fr=ie('species'),$r=nt,Kr=TypeError,Hr=O,Qr=qt,Wr=T(Function.toString);Hr(Qr.inspectSource)||(Qr.inspectSource=function(t){return Wr(t)});var Gr=Qr.inspectSource,Yr=T,Jr=h,Vr=O,Zr=jr,Xr=Gr,tn=function(){},en=[],rn=rt('Reflect','construct'),nn=/^\s*(?:class|function)\b/,on=Yr(nn.exec),sn=!nn.exec(tn),an=function(t){if(!Vr(t))return!1;try{return rn(tn,en,t),!0}catch(t){return!1}},un=function(t){if(!Vr(t))return!1;switch(Zr(t)){case'AsyncFunction':case'GeneratorFunction':case'AsyncGeneratorFunction':return!1}try{return sn||!!on(nn,Xr(t))}catch(t){return!0}};un.sham=!0;var cn,hn,fn,ln,pn=!rn||Jr((function(){var t;return an(an.call)||!an(Object)||!an((function(){t=!0}))||t}))?un:an,dn=Tt,vn=TypeError,mn=Ye,yn=function(t){if(pn(t))return t;throw vn(dn(t)+' is not a constructor')},gn=ie('species'),bn=function(t,e){var r,n=mn(t).constructor;return void 0===n||null==(r=mn(n)[gn])?e:yn(r)},wn=rt('document','documentElement'),_n=T([].slice),Tn=TypeError,On=/(?:ipad|iphone|ipod).*applewebkit/i.test(ot),An=c,Sn=m,En=$e,Pn=O,Rn=$t,kn=h,jn=wn,Cn=_n,xn=be,In=function(t,e){if(t<e)throw Tn('Not enough arguments');return t},Nn=On,Ln=br,Un=An.setImmediate,qn=An.clearImmediate,Bn=An.process,zn=An.Dispatch,Mn=An.Function,Dn=An.MessageChannel,Fn=An.String,$n=0,Kn={};try{cn=An.location}catch(t){}var Hn=function(t){if(Rn(Kn,t)){var e=Kn[t];delete Kn[t],e()}},Qn=function(t){return function(){Hn(t)}},Wn=function(t){Hn(t.data)},Gn=function(t){An.postMessage(Fn(t),cn.protocol+'//'+cn.host)};Un&&qn||(Un=function(t){In(arguments.length,1);var e=Pn(t)?t:Mn(t),r=Cn(arguments,1);return Kn[++$n]=function(){Sn(e,void 0,r)},hn($n),$n},qn=function(t){delete Kn[t]},Ln?hn=function(t){Bn.nextTick(Qn(t))}:zn&&zn.now?hn=function(t){zn.now(Qn(t))}:Dn&&!Nn?(ln=(fn=new Dn).port2,fn.port1.onmessage=Wn,hn=En(ln.postMessage,ln)):An.addEventListener&&Pn(An.postMessage)&&!An.importScripts&&cn&&'file:'!==cn.protocol&&!kn(Gn)?(hn=Gn,An.addEventListener('message',Wn,!1)):hn='onreadystatechange'in xn('script')?function(t){jn.appendChild(xn('script')).onreadystatechange=function(){jn.removeChild(this),Hn(t)}}:function(t){setTimeout(Qn(t),0)});var Yn,Jn,Vn,Zn,Xn,to,eo,ro,no={set:Un,clear:qn},oo=c,io=/ipad|iphone|ipod/i.test(ot)&&void 0!==oo.Pebble,so=/web0s(?!.*chrome)/i.test(ot),ao=c,uo=$e,co=A.f,ho=no.set,fo=On,lo=io,po=so,vo=br,mo=ao.MutationObserver||ao.WebKitMutationObserver,yo=ao.document,go=ao.process,bo=ao.Promise,wo=co(ao,'queueMicrotask'),_o=wo&&wo.value;_o||(Yn=function(){var t,e;for(vo&&(t=go.domain)&&t.exit();Jn;){e=Jn.fn,Jn=Jn.next;try{e()}catch(t){throw Jn?Zn():Vn=void 0,t}}Vn=void 0,t&&t.enter()},fo||vo||po||!mo||!yo?!lo&&bo&&bo.resolve?((eo=bo.resolve(void 0)).constructor=bo,ro=uo(eo.then,eo),Zn=function(){ro(Yn)}):vo?Zn=function(){go.nextTick(Yn)}:(ho=uo(ho,ao),Zn=function(){ho(Yn)}):(Xn=!0,to=yo.createTextNode(''),new mo(Yn).observe(to,{characterData:!0}),Zn=function(){to.data=Xn=!Xn}));var To=_o||function(t){var e={fn:t,next:void 0};Vn&&(Vn.next=e),Jn||(Jn=e,Zn()),Vn=e},Oo=c,Ao=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},So=function(){this.head=null,this.tail=null};So.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 Eo,Po,Ro,ko=So,jo=O,Co=Gr,xo=c.WeakMap,Io=jo(xo)&&/native code/.test(Co(xo)),No=It.exports,Lo=Gt,Uo=No('keys'),qo=Io,Bo=c,zo=T,Mo=J,Do=sr,Fo=$t,$o=qt,Ko=function(t){return Uo[t]||(Uo[t]=Lo(t))},Ho=Bo.TypeError,Qo=Bo.WeakMap;if(qo||$o.state){var Wo=$o.state||($o.state=new Qo),Go=zo(Wo.get),Yo=zo(Wo.has),Jo=zo(Wo.set);Eo=function(t,e){if(Yo(Wo,t))throw new Ho('Object already initialized');return e.facade=t,Jo(Wo,t,e),e},Po=function(t){return Go(Wo,t)||{}},Ro=function(t){return Yo(Wo,t)}}else{var Vo=Ko('state');Eo=function(t,e){if(Fo(t,Vo))throw new Ho('Object already initialized');return e.facade=t,Do(t,Vo,e),e},Po=function(t){return Fo(t,Vo)?t[Vo]:{}},Ro=function(t){return Fo(t,Vo)}}var Zo={set:Eo,get:Po,has:Ro,enforce:function(t){return Ro(t)?Po(t):Eo(t,{})},getterFor:function(t){return function(e){var r;if(!Mo(e)||(r=Po(e)).type!==t)throw Ho('Incompatible receiver, '+t+' required');return r}}},Xo=c.Promise,ti='object'==typeof Deno&&Deno&&'object'==typeof Deno.version,ei=!ti&&!br&&'object'==typeof window&&'object'==typeof document,ri=c,ni=Xo,oi=O,ii=ze,si=Gr,ai=ie,ui=ei,ci=ti,hi=ft,fi=ni&&ni.prototype,li=ai('species'),pi=!1,di=oi(ri.PromiseRejectionEvent),vi={CONSTRUCTOR:ii('Promise',(function(){var t=si(ni),e=t!==String(ni);if(!e&&66===hi)return!0;if(!fi.catch||!fi.finally)return!0;if(!hi||hi<51||!/native code/.test(t)){var r=new ni((function(t){t(1)})),n=function(t){t((function(){}),(function(){}))};if((r.constructor={})[li]=n,!(pi=r.then((function(){}))instanceof n))return!0}return!e&&(ui||ci)&&!di})),REJECTION_EVENT:di,SUBCLASSING:pi},mi={},yi=Et,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=yi(e),this.reject=yi(r)};mi.f=function(t){return new gi(t)};var bi,wi,_i=gr,Ti=br,Oi=c,Ai=R,Si=function(t,e,r,n){return n&&n.enumerable?t[e]=r:wr(t,e,r),t},Ei=function(t,e,r,n){if(t){var o=r?t:t.prototype;Ur(o,Br)||Nr(o,Br,{configurable:!0,value:e}),n&&!Ir&&Lr(o,'toString',qr)}},Pi=function(t){var e=zr(t),r=Mr.f;Dr&&e&&!e[Fr]&&r(e,Fr,{configurable:!0,get:function(){return this}})},Ri=Et,ki=O,ji=J,Ci=function(t,e){if($r(e,t))return t;throw Kr('Incorrect invocation')},xi=bn,Ii=no.set,Ni=To,Li=function(t,e){var r=Oo.console;r&&r.error&&(1==arguments.length?r.error(t):r.error(t,e))},Ui=Ao,qi=ko,Bi=Zo,zi=Xo,Mi=mi,Di=vi.CONSTRUCTOR,Fi=vi.REJECTION_EVENT,$i=Bi.getterFor('Promise'),Ki=Bi.set,Hi=zi&&zi.prototype,Qi=zi,Wi=Hi,Gi=Oi.TypeError,Yi=Oi.document,Ji=Oi.process,Vi=Mi.f,Zi=Vi,Xi=!!(Yi&&Yi.createEvent&&Oi.dispatchEvent),ts=function(t){var e;return!(!ji(t)||!ki(e=t.then))&&e},es=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&&ss(e),e.rejection=1),!0===a?r=i:(h&&h.enter(),r=a(i),h&&(h.exit(),o=!0)),r===t.promise?c(Gi('Promise-chain cycle')):(n=ts(r))?Ai(n,r,u,c):u(r)):c(i)}catch(t){h&&!o&&h.exit(),c(t)}},rs=function(t,e){t.notified||(t.notified=!0,Ni((function(){for(var r,n=t.reactions;r=n.get();)es(r,t);t.notified=!1,e&&!t.rejection&&os(t)})))},ns=function(t,e,r){var n,o;Xi?((n=Yi.createEvent('Event')).promise=e,n.reason=r,n.initEvent(t,!1,!0),Oi.dispatchEvent(n)):n={promise:e,reason:r},!Fi&&(o=Oi['on'+t])?o(n):'unhandledrejection'===t&&Li('Unhandled promise rejection',r)},os=function(t){Ai(Ii,Oi,(function(){var e,r=t.facade,n=t.value;if(is(t)&&(e=Ui((function(){Ti?Ji.emit('unhandledRejection',n,r):ns('unhandledrejection',r,n)})),t.rejection=Ti||is(t)?2:1,e.error))throw e.value}))},is=function(t){return 1!==t.rejection&&!t.parent},ss=function(t){Ai(Ii,Oi,(function(){var e=t.facade;Ti?Ji.emit('rejectionHandled',e):ns('rejectionhandled',e,t.value)}))},as=function(t,e,r){return function(n){t(e,n,r)}},us=function(t,e,r){t.done||(t.done=!0,r&&(t=r),t.value=e,t.state=2,rs(t,!0))},cs=function(t,e,r){if(!t.done){t.done=!0,r&&(t=r);try{if(t.facade===e)throw Gi('Promise can\'t be resolved itself');var n=ts(e);n?Ni((function(){var r={done:!1};try{Ai(n,e,as(cs,r,t),as(us,r,t))}catch(e){us(r,e,t)}})):(t.value=e,t.state=1,rs(t,!1))}catch(e){us({done:!1},e,t)}}};Di&&(Wi=(Qi=function(t){Ci(this,Wi),Ri(t),Ai(bi,this);var e=$i(this);try{t(as(cs,e),as(us,e))}catch(t){us(e,t)}}).prototype,(bi=function(t){Ki(this,{type:'Promise',done:!1,notified:!1,parent:!1,reactions:new qi,rejection:!1,state:0,value:void 0})}).prototype=Si(Wi,'then',(function(t,e){var r=$i(this),n=Vi(xi(this,Qi));return r.parent=!0,n.ok=!ki(t)||t,n.fail=ki(e)&&e,n.domain=Ti?Ji.domain:void 0,0==r.state?r.reactions.add(n):Ni((function(){es(n,r)})),n.promise})),wi=function(){var t=new bi,e=$i(t);this.promise=t,this.resolve=as(cs,e),this.reject=as(us,e)},Mi.f=Vi=function(t){return t===Qi||undefined===t?new wi(t):Zi(t)}),_i({global:!0,constructor:!0,wrap:!0,forced:Di},{Promise:Qi}),Ei(Qi,'Promise',!1,!0),Pi('Promise');var hs={},fs=hs,ls=ie('iterator'),ps=Array.prototype,ds=Math.ceil,vs=Math.floor,ms=Math.trunc||function(t){var e=+t;return(e>0?vs:ds)(e)},ys=function(t){var e=+t;return e!=e||0===e?0:ms(e)},gs=Math.min,bs=function(t){return t>0?gs(ys(t),9007199254740991):0},ws=jr,_s=Rt,Ts=hs,Os=ie('iterator'),As=function(t){if(null!=t)return _s(t,Os)||_s(t,'@@iterator')||Ts[ws(t)]},Ss=R,Es=Et,Ps=Ye,Rs=Tt,ks=As,js=TypeError,Cs=R,xs=Ye,Is=Rt,Ns=$e,Ls=R,Us=Ye,qs=Tt,Bs=function(t){return void 0!==t&&(fs.Array===t||ps[ls]===t)},zs=function(t){return bs(t.length)},Ms=nt,Ds=function(t,e){var r=arguments.length<2?ks(t):e;if(Es(r))return Ps(Ss(r,t));throw js(Rs(t)+' is not iterable')},Fs=As,$s=function(t,e,r){var n,o;xs(t);try{if(!(n=Is(t,'return'))){if('throw'===e)throw r;return r}n=Cs(n,t)}catch(t){o=!0,n=t}if('throw'===e)throw r;if(o)throw n;return xs(n),r},Ks=TypeError,Hs=function(t,e){this.stopped=t,this.result=e},Qs=Hs.prototype,Ws=function(t,e,r){var n,o,i,s,a,u,c,h=r&&r.that,f=!(!r||!r.AS_ENTRIES),l=!(!r||!r.IS_RECORD),p=!(!r||!r.IS_ITERATOR),d=!(!r||!r.INTERRUPTED),v=Ns(e,h),m=function(t){return n&&$s(n,'normal',t),new Hs(!0,t)},y=function(t){return f?(Us(t),d?v(t[0],t[1],m):v(t[0],t[1])):d?v(t,m):v(t)};if(l)n=t.iterator;else if(p)n=t;else{if(!(o=Fs(t)))throw Ks(qs(t)+' is not iterable');if(Bs(o)){for(i=0,s=zs(t);s>i;i++)if((a=y(t[i]))&&Ms(Qs,a))return a;return new Hs(!1)}n=Ds(t,o)}for(u=l?t.next:n.next;!(c=Ls(u,n)).done;){try{a=y(c.value)}catch(t){$s(n,'throw',t)}if('object'==typeof a&&a&&Ms(Qs,a))return a}return new Hs(!1)},Gs=ie('iterator'),Ys=!1;try{var Js=0,Vs={next:function(){return{done:!!Js++}},return:function(){Ys=!0}};Vs[Gs]=function(){return this},Array.from(Vs,(function(){throw 2}))}catch(t){}var Zs=Xo,Xs=vi.CONSTRUCTOR||!function(t,e){if(!e&&!Ys)return!1;var r=!1;try{var n={};n[Gs]=function(){return{next:function(){return{done:r=!0}}}},t(n)}catch(t){}return r}((function(t){Zs.all(t).then(void 0,(function(){}))})),ta=R,ea=Et,ra=mi,na=Ao,oa=Ws;gr({target:'Promise',stat:!0,forced:Xs},{all:function(t){var e=this,r=ra.f(e),n=r.resolve,o=r.reject,i=na((function(){var r=ea(e.resolve),i=[],s=0,a=1;oa(t,(function(t){var u=s++,c=!1;a++,ta(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}});var ia=gr,sa=vi.CONSTRUCTOR;Xo&&Xo.prototype,ia({target:'Promise',proto:!0,forced:sa,real:!0},{catch:function(t){return this.then(void 0,t)}});var aa=R,ua=Et,ca=mi,ha=Ao,fa=Ws;gr({target:'Promise',stat:!0,forced:Xs},{race:function(t){var e=this,r=ca.f(e),n=r.reject,o=ha((function(){var o=ua(e.resolve);fa(t,(function(t){aa(o,e,t).then(r.resolve,n)}))}));return o.error&&n(o.value),r.promise}});var la=R,pa=mi;gr({target:'Promise',stat:!0,forced:vi.CONSTRUCTOR},{reject:function(t){var e=pa.f(this);return la(e.reject,void 0,t),e.promise}});var da=Ye,va=J,ma=mi,ya=function(t,e){if(da(t),va(e)&&e.constructor===t)return e;var r=ma.f(t);return(0,r.resolve)(e),r.promise},ga=gr,ba=Xo,wa=vi.CONSTRUCTOR,_a=ya,Ta=rt('Promise'),Oa=!wa;ga({target:'Promise',stat:!0,forced:true},{resolve:function(t){return _a(Oa&&this===Ta?ba:this,t)}});var Aa=gr,Sa=Xo,Ea=h,Pa=rt,Ra=O,ka=bn,ja=ya,Ca=Sa&&Sa.prototype;Aa({target:'Promise',proto:!0,real:!0,forced:!!Sa&&Ea((function(){Ca.finally.call({then:function(){}},(function(){}))}))},{finally:function(t){var e=ka(this,Pa('Promise')),r=Ra(t);return this.then(r?function(r){return ja(e,t()).then((function(){return r}))}:t,r?function(r){return ja(e,t()).then((function(){throw r}))}:t)}});var xa=rt('Promise','finally');const Ia=(()=>{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 Na,La,Ua,qa,Ba,za,Ma,Da={get:t=>function(t){const e=Ia?Ia.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{Ia&&Ia.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){Ia&&Ia.removeItem('_one-stat_'+t)}(t)}};!function(t){t.PROD='prod',t.VK_ALIAS='vk_alias',t.VIDEOTEST='videotest',t.TEST='test',t.AUTO='auto'}(Na||(Na={})),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=''}(Ua||(Ua={})),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',t.UNKNOWN='unknown'}(qa||(qa={})),function(t){t.AUTO='auto',t.MANUAL=''}(Ba||(Ba={})),function(t){t.HTTP1='http1',t.HTTP2='http2',t.HTTP3='http3'}(za||(za={})),function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(Ma||(Ma={}));const Fa={[Na.PROD]:'https://api.ok.ru',[Na.VK_ALIAS]:'https://api.mycdn.me',[Na.VIDEOTEST]:'https://videotestapi.ok.ru/api',[Na.TEST]:'https://apitest.ok.ru',[Na.AUTO]:''},$a={start:1e3,factor:1.5,max:3e5,random:.1};var Ka;!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'}(Ka||(Ka={}));class Ha{constructor(e){this.consequentAuthErrors=0,this.authorized$=new t(!1),this.params=e;const r=Da.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('')}(),Da.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 Ka.PARAM_SESSION_EXPIRED:case Ka.PARAM_SESSION_KEY:case Ka.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=yield this._authorizeWithBackoff(),e>0?i(t,e-1):void 0;case Ka.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=xa(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.24',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,$a);return new Promise((e=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout((()=>{xa(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.24'.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=xa(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 Ka.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}))}}function Qa(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}const Wa=Qa({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Ga=Wa?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(!Qa({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,Ya=Wa?Ga.fetch:window.fetch;Wa?Ga.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!==Na.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const e=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),r=yield Ya(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}),Fa[Na.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(),Ya(`${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 Va{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 Za{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:Fa[e.apiEnv],apiEnv:e.apiEnv,error$:s});this.api=new Ha({apiTransport:a,refreshAuthToken:e.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:s}),this.logger=new Va({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()}logInited(){this.log({operation:'init'})}logReady(t){this.log({operation:'player_ready',param:String(t.time)})}logStarted(t){this.log({operation:'play',param:String(Math.round(t.position))})}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)})}logDownloadSpeed(t){this.log({operation:'download_speed',param:String(t.speed)})}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?Ba.AUTO:!1===this.statContext.autoplay?Ba.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{Na as ApiEnv,za as ConnectionType,qa as ContentType,Za as OneStat,La as Quality,Ua 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.js';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}},f=!h((function(){var t=function(){}.bind();return'function'!=typeof t||t.hasOwnProperty('prototype')})),l=f,p=Function.prototype,d=p.apply,v=p.call,m='object'==typeof Reflect&&Reflect.apply||(l?v.bind(d):function(){return v.apply(d,arguments)}),y=f,g=Function.prototype,b=g.bind,w=g.call,T=y&&b.bind(w,w),_=y?function(t){return t&&T(t)}:function(t){return t&&function(){return w.apply(t,arguments)}},O=function(t){return'function'==typeof t},A={},S=!h((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),P=f,E=Function.prototype.call,R=P?E.bind(E):function(){return E.apply(E,arguments)},k={},j={}.propertyIsEnumerable,C=Object.getOwnPropertyDescriptor,x=C&&!j.call({1:2},1);k.f=x?function(t){var e=C(this,t);return!!e&&e.enumerable}:j;var I,N,L=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},U=_,q=U({}.toString),B=U(''.slice),z=function(t){return B(q(t),8,-1)},M=h,D=z,F=Object,$=_(''.split),K=M((function(){return!F('z').propertyIsEnumerable(0)}))?function(t){return'String'==D(t)?$(t,''):F(t)}:F,H=TypeError,Q=function(t){if(null==t)throw H('Can\'t call method on '+t);return t},W=K,G=Q,Y=O,J=function(t){return'object'==typeof t?null!==t:Y(t)},V={},Z=V,X=c,tt=O,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=_({}.isPrototypeOf),ot=rt('navigator','userAgent')||'',it=c,st=ot,at=it.process,ut=it.Deno,ct=at&&at.versions||ut&&ut.version,ht=ct&&ct.v8;ht&&(N=(I=ht.split('.'))[0]>0&&I[0]<4?1:+(I[0]+I[1])),!N&&st&&(!(I=st.match(/Edge\/(\d+)/))||I[1]>=74)&&(I=st.match(/Chrome\/(\d+)/))&&(N=+I[1]);var ft=N,lt=ft,pt=h,dt=!!Object.getOwnPropertySymbols&&!pt((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&<&<<41})),vt=dt&&!Symbol.sham&&'symbol'==typeof Symbol.iterator,mt=rt,yt=O,gt=nt,bt=Object,wt=vt?function(t){return'symbol'==typeof t}:function(t){var e=mt('Symbol');return yt(e)&>(e.prototype,bt(t))},Tt=String,_t=function(t){try{return Tt(t)}catch(t){return'Object'}},Ot=O,At=_t,St=TypeError,Pt=function(t){if(Ot(t))return t;throw St(At(t)+' is not a function')},Et=Pt,Rt=function(t,e){var r=t[e];return null==r?void 0:Et(r)},kt=R,jt=O,Ct=J,xt=TypeError,It={exports:{}},Nt=c,Lt=Object.defineProperty,Ut=function(t,e){try{Lt(Nt,t,{value:e,configurable:!0,writable:!0})}catch(r){Nt[t]=e}return e},qt=c['__core-js_shared__']||Ut('__core-js_shared__',{}),Bt=qt;(It.exports=function(t,e){return Bt[t]||(Bt[t]=void 0!==e?e:{})})('versions',[]).push({version:'3.24.1',mode:'pure',copyright:'© 2014-2022 Denis Pushkarev (zloirock.ru)',license:'https://github.com/zloirock/core-js/blob/v3.24.1/LICENSE',source:'https://github.com/zloirock/core-js'});var zt=Q,Mt=Object,Dt=function(t){return Mt(zt(t))},Ft=_({}.hasOwnProperty),$t=Object.hasOwn||function(t,e){return Ft(Dt(t),e)},Kt=_,Ht=0,Qt=Math.random(),Wt=Kt(1..toString),Gt=function(t){return'Symbol('+(void 0===t?'':t)+')_'+Wt(++Ht+Qt,36)},Yt=c,Jt=It.exports,Vt=$t,Zt=Gt,Xt=dt,te=vt,ee=Jt('wks'),re=Yt.Symbol,ne=re&&re.for,oe=te?re:re&&re.withoutSetter||Zt,ie=function(t){if(!Vt(ee,t)||!Xt&&'string'!=typeof ee[t]){var e='Symbol.'+t;Xt&&Vt(re,t)?ee[t]=re[t]:ee[t]=te&&ne?ne(e):oe(e)}return ee[t]},se=R,ae=J,ue=wt,ce=Rt,he=function(t,e){var r,n;if('string'===e&&jt(r=t.toString)&&!Ct(n=kt(r,t)))return n;if(jt(r=t.valueOf)&&!Ct(n=kt(r,t)))return n;if('string'!==e&&jt(r=t.toString)&&!Ct(n=kt(r,t)))return n;throw xt('Can\'t convert object to primitive value')},fe=TypeError,le=ie('toPrimitive'),pe=function(t,e){if(!ae(t)||ue(t))return t;var r,n=ce(t,le);if(n){if(void 0===e&&(e='default'),r=se(n,t,e),!ae(r)||ue(r))return r;throw fe('Can\'t convert object to primitive value')}return void 0===e&&(e='number'),he(t,e)},de=wt,ve=function(t){var e=pe(t,'string');return de(e)?e:e+''},me=J,ye=c.document,ge=me(ye)&&me(ye.createElement),be=function(t){return ge?ye.createElement(t):{}},we=be,Te=!S&&!h((function(){return 7!=Object.defineProperty(we('div'),'a',{get:function(){return 7}}).a})),_e=S,Oe=R,Ae=k,Se=L,Pe=function(t){return W(G(t))},Ee=ve,Re=$t,ke=Te,je=Object.getOwnPropertyDescriptor;A.f=_e?je:function(t,e){if(t=Pe(t),e=Ee(e),ke)try{return je(t,e)}catch(t){}if(Re(t,e))return Se(!Oe(Ae.f,t,e),t[e])};var Ce=h,xe=O,Ie=/#|\.prototype\./,Ne=function(t,e){var r=Ue[Le(t)];return r==Be||r!=qe&&(xe(e)?Ce(e):!!e)},Le=Ne.normalize=function(t){return String(t).replace(Ie,'.').toLowerCase()},Ue=Ne.data={},qe=Ne.NATIVE='N',Be=Ne.POLYFILL='P',ze=Ne,Me=Pt,De=f,Fe=_(_.bind),$e=function(t,e){return Me(t),void 0===e?t:De?Fe(t,e):function(){return t.apply(e,arguments)}},Ke={},He=S&&h((function(){return 42!=Object.defineProperty((function(){}),'prototype',{value:42,writable:!1}).prototype})),Qe=J,We=String,Ge=TypeError,Ye=function(t){if(Qe(t))return t;throw Ge(We(t)+' is not an object')},Je=S,Ve=Te,Ze=He,Xe=Ye,tr=ve,er=TypeError,rr=Object.defineProperty,nr=Object.getOwnPropertyDescriptor;Ke.f=Je?Ze?function(t,e,r){if(Xe(t),e=tr(e),Xe(r),'function'==typeof t&&'prototype'===e&&'value'in r&&'writable'in r&&!r.writable){var n=nr(t,e);n&&n.writable&&(t[e]=r.value,r={configurable:'configurable'in r?r.configurable:n.configurable,enumerable:'enumerable'in r?r.enumerable:n.enumerable,writable:!1})}return rr(t,e,r)}:rr:function(t,e,r){if(Xe(t),e=tr(e),Xe(r),Ve)try{return rr(t,e,r)}catch(t){}if('get'in r||'set'in r)throw er('Accessors not supported');return'value'in r&&(t[e]=r.value),t};var or=Ke,ir=L,sr=S?function(t,e,r){return or.f(t,e,ir(1,r))}:function(t,e,r){return t[e]=r,t},ar=c,ur=m,cr=_,hr=O,fr=A.f,lr=ze,pr=V,dr=$e,vr=sr,mr=$t,yr=function(t){var e=function(r,n,o){if(this instanceof e){switch(arguments.length){case 0:return new t;case 1:return new t(r);case 2:return new t(r,n)}return new t(r,n,o)}return ur(t,this,arguments)};return e.prototype=t.prototype,e},gr=function(t,e){var r,n,o,i,s,a,u,c,h=t.target,f=t.global,l=t.stat,p=t.proto,d=f?ar:l?ar[h]:(ar[h]||{}).prototype,v=f?pr:pr[h]||vr(pr,h,{})[h],m=v.prototype;for(o in e)r=!lr(f?o:h+(l?'.':'#')+o,t.forced)&&d&&mr(d,o),s=v[o],r&&(a=t.dontCallGetSet?(c=fr(d,o))&&c.value:d[o]),i=r&&a?a:e[o],r&&typeof s==typeof i||(u=t.bind&&r?dr(i,ar):t.wrap&&r?yr(i):p&&hr(i)?cr(i):i,(t.sham||i&&i.sham||s&&s.sham)&&vr(u,'sham',!0),vr(v,o,u),p&&(mr(pr,n=h+'Prototype')||vr(pr,n,{}),vr(pr[n],o,i),t.real&&m&&!m[o]&&vr(m,o,i)))},br='process'==z(c.process),wr=sr,Tr=(TypeError,_);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[ie('toStringTag')]='z';var Or='[object z]'===String(_r),Ar=Or,Sr=O,Pr=z,Er=ie('toStringTag'),Rr=Object,kr='Arguments'==Pr(function(){return arguments}()),jr=Ar?Pr: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=Rr(t),Er))?r:kr?Pr(e):'Object'==(n=Pr(e))&&Sr(e.callee)?'Arguments':n},Cr=jr,xr=Or?{}.toString:function(){return'[object '+Cr(this)+']'},Ir=Or,Nr=Ke.f,Lr=sr,Ur=$t,qr=xr,Br=ie('toStringTag'),zr=rt,Mr=Ke,Dr=S,Fr=ie('species'),$r=nt,Kr=TypeError,Hr=O,Qr=qt,Wr=_(Function.toString);Hr(Qr.inspectSource)||(Qr.inspectSource=function(t){return Wr(t)});var Gr=Qr.inspectSource,Yr=_,Jr=h,Vr=O,Zr=jr,Xr=Gr,tn=function(){},en=[],rn=rt('Reflect','construct'),nn=/^\s*(?:class|function)\b/,on=Yr(nn.exec),sn=!nn.exec(tn),an=function(t){if(!Vr(t))return!1;try{return rn(tn,en,t),!0}catch(t){return!1}},un=function(t){if(!Vr(t))return!1;switch(Zr(t)){case'AsyncFunction':case'GeneratorFunction':case'AsyncGeneratorFunction':return!1}try{return sn||!!on(nn,Xr(t))}catch(t){return!0}};un.sham=!0;var cn,hn,fn,ln,pn=!rn||Jr((function(){var t;return an(an.call)||!an(Object)||!an((function(){t=!0}))||t}))?un:an,dn=_t,vn=TypeError,mn=Ye,yn=function(t){if(pn(t))return t;throw vn(dn(t)+' is not a constructor')},gn=ie('species'),bn=function(t,e){var r,n=mn(t).constructor;return void 0===n||null==(r=mn(n)[gn])?e:yn(r)},wn=rt('document','documentElement'),Tn=_([].slice),_n=TypeError,On=/(?:ipad|iphone|ipod).*applewebkit/i.test(ot),An=c,Sn=m,Pn=$e,En=O,Rn=$t,kn=h,jn=wn,Cn=Tn,xn=be,In=function(t,e){if(t<e)throw _n('Not enough arguments');return t},Nn=On,Ln=br,Un=An.setImmediate,qn=An.clearImmediate,Bn=An.process,zn=An.Dispatch,Mn=An.Function,Dn=An.MessageChannel,Fn=An.String,$n=0,Kn={};try{cn=An.location}catch(t){}var Hn=function(t){if(Rn(Kn,t)){var e=Kn[t];delete Kn[t],e()}},Qn=function(t){return function(){Hn(t)}},Wn=function(t){Hn(t.data)},Gn=function(t){An.postMessage(Fn(t),cn.protocol+'//'+cn.host)};Un&&qn||(Un=function(t){In(arguments.length,1);var e=En(t)?t:Mn(t),r=Cn(arguments,1);return Kn[++$n]=function(){Sn(e,void 0,r)},hn($n),$n},qn=function(t){delete Kn[t]},Ln?hn=function(t){Bn.nextTick(Qn(t))}:zn&&zn.now?hn=function(t){zn.now(Qn(t))}:Dn&&!Nn?(ln=(fn=new Dn).port2,fn.port1.onmessage=Wn,hn=Pn(ln.postMessage,ln)):An.addEventListener&&En(An.postMessage)&&!An.importScripts&&cn&&'file:'!==cn.protocol&&!kn(Gn)?(hn=Gn,An.addEventListener('message',Wn,!1)):hn='onreadystatechange'in xn('script')?function(t){jn.appendChild(xn('script')).onreadystatechange=function(){jn.removeChild(this),Hn(t)}}:function(t){setTimeout(Qn(t),0)});var Yn,Jn,Vn,Zn,Xn,to,eo,ro,no={set:Un,clear:qn},oo=c,io=/ipad|iphone|ipod/i.test(ot)&&void 0!==oo.Pebble,so=/web0s(?!.*chrome)/i.test(ot),ao=c,uo=$e,co=A.f,ho=no.set,fo=On,lo=io,po=so,vo=br,mo=ao.MutationObserver||ao.WebKitMutationObserver,yo=ao.document,go=ao.process,bo=ao.Promise,wo=co(ao,'queueMicrotask'),To=wo&&wo.value;To||(Yn=function(){var t,e;for(vo&&(t=go.domain)&&t.exit();Jn;){e=Jn.fn,Jn=Jn.next;try{e()}catch(t){throw Jn?Zn():Vn=void 0,t}}Vn=void 0,t&&t.enter()},fo||vo||po||!mo||!yo?!lo&&bo&&bo.resolve?((eo=bo.resolve(void 0)).constructor=bo,ro=uo(eo.then,eo),Zn=function(){ro(Yn)}):vo?Zn=function(){go.nextTick(Yn)}:(ho=uo(ho,ao),Zn=function(){ho(Yn)}):(Xn=!0,to=yo.createTextNode(''),new mo(Yn).observe(to,{characterData:!0}),Zn=function(){to.data=Xn=!Xn}));var _o=To||function(t){var e={fn:t,next:void 0};Vn&&(Vn.next=e),Jn||(Jn=e,Zn()),Vn=e},Oo=c,Ao=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},So=function(){this.head=null,this.tail=null};So.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 Po,Eo,Ro,ko=So,jo=O,Co=Gr,xo=c.WeakMap,Io=jo(xo)&&/native code/.test(Co(xo)),No=It.exports,Lo=Gt,Uo=No('keys'),qo=Io,Bo=c,zo=_,Mo=J,Do=sr,Fo=$t,$o=qt,Ko=function(t){return Uo[t]||(Uo[t]=Lo(t))},Ho=Bo.TypeError,Qo=Bo.WeakMap;if(qo||$o.state){var Wo=$o.state||($o.state=new Qo),Go=zo(Wo.get),Yo=zo(Wo.has),Jo=zo(Wo.set);Po=function(t,e){if(Yo(Wo,t))throw new Ho('Object already initialized');return e.facade=t,Jo(Wo,t,e),e},Eo=function(t){return Go(Wo,t)||{}},Ro=function(t){return Yo(Wo,t)}}else{var Vo=Ko('state');Po=function(t,e){if(Fo(t,Vo))throw new Ho('Object already initialized');return e.facade=t,Do(t,Vo,e),e},Eo=function(t){return Fo(t,Vo)?t[Vo]:{}},Ro=function(t){return Fo(t,Vo)}}var Zo={set:Po,get:Eo,has:Ro,enforce:function(t){return Ro(t)?Eo(t):Po(t,{})},getterFor:function(t){return function(e){var r;if(!Mo(e)||(r=Eo(e)).type!==t)throw Ho('Incompatible receiver, '+t+' required');return r}}},Xo=c.Promise,ti='object'==typeof Deno&&Deno&&'object'==typeof Deno.version,ei=!ti&&!br&&'object'==typeof window&&'object'==typeof document,ri=c,ni=Xo,oi=O,ii=ze,si=Gr,ai=ie,ui=ei,ci=ti,hi=ft,fi=ni&&ni.prototype,li=ai('species'),pi=!1,di=oi(ri.PromiseRejectionEvent),vi={CONSTRUCTOR:ii('Promise',(function(){var t=si(ni),e=t!==String(ni);if(!e&&66===hi)return!0;if(!fi.catch||!fi.finally)return!0;if(!hi||hi<51||!/native code/.test(t)){var r=new ni((function(t){t(1)})),n=function(t){t((function(){}),(function(){}))};if((r.constructor={})[li]=n,!(pi=r.then((function(){}))instanceof n))return!0}return!e&&(ui||ci)&&!di})),REJECTION_EVENT:di,SUBCLASSING:pi},mi={},yi=Pt,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=yi(e),this.reject=yi(r)};mi.f=function(t){return new gi(t)};var bi,wi,Ti=gr,_i=br,Oi=c,Ai=R,Si=function(t,e,r,n){return n&&n.enumerable?t[e]=r:wr(t,e,r),t},Pi=function(t,e,r,n){if(t){var o=r?t:t.prototype;Ur(o,Br)||Nr(o,Br,{configurable:!0,value:e}),n&&!Ir&&Lr(o,'toString',qr)}},Ei=function(t){var e=zr(t),r=Mr.f;Dr&&e&&!e[Fr]&&r(e,Fr,{configurable:!0,get:function(){return this}})},Ri=Pt,ki=O,ji=J,Ci=function(t,e){if($r(e,t))return t;throw Kr('Incorrect invocation')},xi=bn,Ii=no.set,Ni=_o,Li=function(t,e){var r=Oo.console;r&&r.error&&(1==arguments.length?r.error(t):r.error(t,e))},Ui=Ao,qi=ko,Bi=Zo,zi=Xo,Mi=mi,Di=vi.CONSTRUCTOR,Fi=vi.REJECTION_EVENT,$i=Bi.getterFor('Promise'),Ki=Bi.set,Hi=zi&&zi.prototype,Qi=zi,Wi=Hi,Gi=Oi.TypeError,Yi=Oi.document,Ji=Oi.process,Vi=Mi.f,Zi=Vi,Xi=!!(Yi&&Yi.createEvent&&Oi.dispatchEvent),ts=function(t){var e;return!(!ji(t)||!ki(e=t.then))&&e},es=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&&ss(e),e.rejection=1),!0===a?r=i:(h&&h.enter(),r=a(i),h&&(h.exit(),o=!0)),r===t.promise?c(Gi('Promise-chain cycle')):(n=ts(r))?Ai(n,r,u,c):u(r)):c(i)}catch(t){h&&!o&&h.exit(),c(t)}},rs=function(t,e){t.notified||(t.notified=!0,Ni((function(){for(var r,n=t.reactions;r=n.get();)es(r,t);t.notified=!1,e&&!t.rejection&&os(t)})))},ns=function(t,e,r){var n,o;Xi?((n=Yi.createEvent('Event')).promise=e,n.reason=r,n.initEvent(t,!1,!0),Oi.dispatchEvent(n)):n={promise:e,reason:r},!Fi&&(o=Oi['on'+t])?o(n):'unhandledrejection'===t&&Li('Unhandled promise rejection',r)},os=function(t){Ai(Ii,Oi,(function(){var e,r=t.facade,n=t.value;if(is(t)&&(e=Ui((function(){_i?Ji.emit('unhandledRejection',n,r):ns('unhandledrejection',r,n)})),t.rejection=_i||is(t)?2:1,e.error))throw e.value}))},is=function(t){return 1!==t.rejection&&!t.parent},ss=function(t){Ai(Ii,Oi,(function(){var e=t.facade;_i?Ji.emit('rejectionHandled',e):ns('rejectionhandled',e,t.value)}))},as=function(t,e,r){return function(n){t(e,n,r)}},us=function(t,e,r){t.done||(t.done=!0,r&&(t=r),t.value=e,t.state=2,rs(t,!0))},cs=function(t,e,r){if(!t.done){t.done=!0,r&&(t=r);try{if(t.facade===e)throw Gi('Promise can\'t be resolved itself');var n=ts(e);n?Ni((function(){var r={done:!1};try{Ai(n,e,as(cs,r,t),as(us,r,t))}catch(e){us(r,e,t)}})):(t.value=e,t.state=1,rs(t,!1))}catch(e){us({done:!1},e,t)}}};Di&&(Wi=(Qi=function(t){Ci(this,Wi),Ri(t),Ai(bi,this);var e=$i(this);try{t(as(cs,e),as(us,e))}catch(t){us(e,t)}}).prototype,(bi=function(t){Ki(this,{type:'Promise',done:!1,notified:!1,parent:!1,reactions:new qi,rejection:!1,state:0,value:void 0})}).prototype=Si(Wi,'then',(function(t,e){var r=$i(this),n=Vi(xi(this,Qi));return r.parent=!0,n.ok=!ki(t)||t,n.fail=ki(e)&&e,n.domain=_i?Ji.domain:void 0,0==r.state?r.reactions.add(n):Ni((function(){es(n,r)})),n.promise})),wi=function(){var t=new bi,e=$i(t);this.promise=t,this.resolve=as(cs,e),this.reject=as(us,e)},Mi.f=Vi=function(t){return t===Qi||undefined===t?new wi(t):Zi(t)}),Ti({global:!0,constructor:!0,wrap:!0,forced:Di},{Promise:Qi}),Pi(Qi,'Promise',!1,!0),Ei('Promise');var hs={},fs=hs,ls=ie('iterator'),ps=Array.prototype,ds=Math.ceil,vs=Math.floor,ms=Math.trunc||function(t){var e=+t;return(e>0?vs:ds)(e)},ys=function(t){var e=+t;return e!=e||0===e?0:ms(e)},gs=Math.min,bs=function(t){return t>0?gs(ys(t),9007199254740991):0},ws=jr,Ts=Rt,_s=hs,Os=ie('iterator'),As=function(t){if(null!=t)return Ts(t,Os)||Ts(t,'@@iterator')||_s[ws(t)]},Ss=R,Ps=Pt,Es=Ye,Rs=_t,ks=As,js=TypeError,Cs=R,xs=Ye,Is=Rt,Ns=$e,Ls=R,Us=Ye,qs=_t,Bs=function(t){return void 0!==t&&(fs.Array===t||ps[ls]===t)},zs=function(t){return bs(t.length)},Ms=nt,Ds=function(t,e){var r=arguments.length<2?ks(t):e;if(Ps(r))return Es(Ss(r,t));throw js(Rs(t)+' is not iterable')},Fs=As,$s=function(t,e,r){var n,o;xs(t);try{if(!(n=Is(t,'return'))){if('throw'===e)throw r;return r}n=Cs(n,t)}catch(t){o=!0,n=t}if('throw'===e)throw r;if(o)throw n;return xs(n),r},Ks=TypeError,Hs=function(t,e){this.stopped=t,this.result=e},Qs=Hs.prototype,Ws=function(t,e,r){var n,o,i,s,a,u,c,h=r&&r.that,f=!(!r||!r.AS_ENTRIES),l=!(!r||!r.IS_RECORD),p=!(!r||!r.IS_ITERATOR),d=!(!r||!r.INTERRUPTED),v=Ns(e,h),m=function(t){return n&&$s(n,'normal',t),new Hs(!0,t)},y=function(t){return f?(Us(t),d?v(t[0],t[1],m):v(t[0],t[1])):d?v(t,m):v(t)};if(l)n=t.iterator;else if(p)n=t;else{if(!(o=Fs(t)))throw Ks(qs(t)+' is not iterable');if(Bs(o)){for(i=0,s=zs(t);s>i;i++)if((a=y(t[i]))&&Ms(Qs,a))return a;return new Hs(!1)}n=Ds(t,o)}for(u=l?t.next:n.next;!(c=Ls(u,n)).done;){try{a=y(c.value)}catch(t){$s(n,'throw',t)}if('object'==typeof a&&a&&Ms(Qs,a))return a}return new Hs(!1)},Gs=ie('iterator'),Ys=!1;try{var Js=0,Vs={next:function(){return{done:!!Js++}},return:function(){Ys=!0}};Vs[Gs]=function(){return this},Array.from(Vs,(function(){throw 2}))}catch(t){}var Zs=Xo,Xs=vi.CONSTRUCTOR||!function(t,e){if(!e&&!Ys)return!1;var r=!1;try{var n={};n[Gs]=function(){return{next:function(){return{done:r=!0}}}},t(n)}catch(t){}return r}((function(t){Zs.all(t).then(void 0,(function(){}))})),ta=R,ea=Pt,ra=mi,na=Ao,oa=Ws;gr({target:'Promise',stat:!0,forced:Xs},{all:function(t){var e=this,r=ra.f(e),n=r.resolve,o=r.reject,i=na((function(){var r=ea(e.resolve),i=[],s=0,a=1;oa(t,(function(t){var u=s++,c=!1;a++,ta(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}});var ia=gr,sa=vi.CONSTRUCTOR;Xo&&Xo.prototype,ia({target:'Promise',proto:!0,forced:sa,real:!0},{catch:function(t){return this.then(void 0,t)}});var aa=R,ua=Pt,ca=mi,ha=Ao,fa=Ws;gr({target:'Promise',stat:!0,forced:Xs},{race:function(t){var e=this,r=ca.f(e),n=r.reject,o=ha((function(){var o=ua(e.resolve);fa(t,(function(t){aa(o,e,t).then(r.resolve,n)}))}));return o.error&&n(o.value),r.promise}});var la=R,pa=mi;gr({target:'Promise',stat:!0,forced:vi.CONSTRUCTOR},{reject:function(t){var e=pa.f(this);return la(e.reject,void 0,t),e.promise}});var da=Ye,va=J,ma=mi,ya=function(t,e){if(da(t),va(e)&&e.constructor===t)return e;var r=ma.f(t);return(0,r.resolve)(e),r.promise},ga=gr,ba=Xo,wa=vi.CONSTRUCTOR,Ta=ya,_a=rt('Promise'),Oa=!wa;ga({target:'Promise',stat:!0,forced:true},{resolve:function(t){return Ta(Oa&&this===_a?ba:this,t)}});var Aa=gr,Sa=Xo,Pa=h,Ea=rt,Ra=O,ka=bn,ja=ya,Ca=Sa&&Sa.prototype;Aa({target:'Promise',proto:!0,real:!0,forced:!!Sa&&Pa((function(){Ca.finally.call({then:function(){}},(function(){}))}))},{finally:function(t){var e=ka(this,Ea('Promise')),r=Ra(t);return this.then(r?function(r){return ja(e,t()).then((function(){return r}))}:t,r?function(r){return ja(e,t()).then((function(){throw r}))}:t)}});var xa=rt('Promise','finally');const Ia=(()=>{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 Na,La,Ua,qa,Ba,za,Ma,Da={get:t=>function(t){const e=Ia?Ia.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{Ia&&Ia.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){Ia&&Ia.removeItem('_one-stat_'+t)}(t)}};!function(t){t.PROD='prod',t.VK_ALIAS='vk_alias',t.VIDEOTEST='videotest',t.TEST='test',t.AUTO='auto'}(Na||(Na={})),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=''}(Ua||(Ua={})),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',t.RTMP='rtmp',t.UNKNOWN='unknown'}(qa||(qa={})),function(t){t.AUTO='auto',t.MANUAL=''}(Ba||(Ba={})),function(t){t.HTTP1='http1',t.HTTP2='http2',t.HTTP3='http3'}(za||(za={})),function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(Ma||(Ma={}));const Fa={[Na.PROD]:'https://api.ok.ru',[Na.VK_ALIAS]:'https://api.mycdn.me',[Na.VIDEOTEST]:'https://videotestapi.ok.ru/api',[Na.TEST]:'https://apitest.ok.ru',[Na.AUTO]:''},$a={start:1e3,factor:1.5,max:3e5,random:.1};var Ka;!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'}(Ka||(Ka={}));class Ha{constructor(e){this.consequentAuthErrors=0,this.authorized$=new t(!1),this.params=e;const r=Da.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('')}(),Da.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 Ka.PARAM_SESSION_EXPIRED:case Ka.PARAM_SESSION_KEY:case Ka.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=yield this._authorizeWithBackoff(),e>0?i(t,e-1):void 0;case Ka.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=xa(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.25',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,$a);return new Promise((e=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout((()=>{xa(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.25'.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=xa(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 Ka.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}))}}function Qa(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}const Wa=Qa({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Ga=Wa?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(!Qa({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,Ya=Wa?Ga.fetch:window.fetch;Wa?Ga.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!==Na.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const e=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),r=yield Ya(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}),Fa[Na.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(),Ya(`${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 Va{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 Za{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:Fa[e.apiEnv],apiEnv:e.apiEnv,error$:s});this.api=new Ha({apiTransport:a,refreshAuthToken:e.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:s}),this.logger=new Va({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()}logInited(){this.log({operation:'init'})}logReady(t){this.log({operation:'player_ready',param:String(t.time)})}logStarted(t){this.log({operation:'play',param:String(Math.round(t.position))})}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)})}logDownloadSpeed(t){this.log({operation:'download_speed',param:String(t.speed)})}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?Ba.AUTO:!1===this.statContext.autoplay?Ba.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{Na as ApiEnv,za as ConnectionType,qa as ContentType,Za as OneStat,La as Quality,Ua as ScreenDestination};
|
package/es2018.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-statistics v1.0.
|
|
3
|
-
*
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-statistics v1.0.25
|
|
3
|
+
* Wed, 21 Sep 2022 08:17:06 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-25/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 o=e(require('lodash/debounce.js'));const s=(()=>{try{const t=Date.now().toString(),e=window.localStorage;e.setItem(t,t);const o=e.getItem(t)===t;return e.removeItem(t),o?e:null}catch(t){return null}})();var r,i,n,a,h,u,p,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,(r=exports.ApiEnv||(exports.ApiEnv={})).PROD='prod',r.VK_ALIAS='vk_alias',r.VIDEOTEST='videotest',r.TEST='test',r.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',a.UNKNOWN='unknown',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'}(p||(p={}));const d={[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]:''},c={start:1e3,factor:1.5,max:3e5,random:.1};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 o=l.get('uuid');o?this.uuid=String(o):(this.uuid=function(){const t='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),e=new Array(36);let o,s,r=0;for(s=0;s<36;s++)8===s||13===s||18===s||23===s?e[s]='-':14===s?e[s]='4':(r<=2&&(r=33554432+16777216*Math.random()|0),o=15&r,r>>=4,e[s]=t[19===s?3&o|8:o]);return e.join('')}(),l.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),o=this.sessionKey;if(!o)return;this.params.apiTransport.sendBeacon('log.externalLog',e,o)||this.logRequest(t)}async logRequest(t){var e;const o='log.externalLog',s=this.createLogParams(t),r=null!==(e=this.sessionKey)&&void 0!==e?e:await this._authorizeWithBackoff();if(!r)return;const i=async(t,e=this.params.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(o,s,r)}catch(s){if(!s||!('error_code'in s))return void this.params.error$.next({id:'logRequestUnknown',message:`Unknown ${o} error`,thrown:s});const r=null==s?void 0:s.error_code;switch(r){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#${r}`,message:`${o} 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.24',platform:'WEB',items:t.map((t=>({...t,time:0,type:1})))})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const e=t.getExponentialDelay(this.consequentAuthErrors,c);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.24'.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}}function f(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}const y=f({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),A=y?function(t){'function'==typeof t&&(t={fetch:t});const{fetch:e,Request:o=e.Request,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:r=!1}=t;if(!f({fetch:e,Request:o,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:r}))return{fetch:e,Request:i};let i=o;(i&&!i.prototype.hasOwnProperty('signal')||r)&&(i=function(t,e){let s;e&&e.signal&&(s=e.signal,delete e.signal);const r=new o(t,e);return s&&Object.defineProperty(r,'signal',{writable:!1,enumerable:!1,configurable:!0,value:s}),r},i.prototype=o.prototype);const n=e;return{fetch:(t,e)=>{const o=i&&i.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(o){let s;try{s=new DOMException('Aborted','AbortError')}catch(t){s=new Error('Aborted'),s.name='AbortError'}if(o.aborted)return Promise.reject(s);const r=new Promise(((t,e)=>{o.addEventListener('abort',(()=>e(s)),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([r,n(t,e)])}return n(t,e)},Request:i}}({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,_=y?A.fetch:window.fetch;y?A.Request:window.Request;class v{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='),o=await _(e,{method:'GET',mode:'cors',cache:'no-cache'}),s=await o.json(),r=null===(t=null==s?void 0:s.Answer[0])||void 0===t?void 0:t.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}),d[exports.ApiEnv.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(t,e,o){if(!window.Blob||!window.navigator.sendBeacon)return!1;const s=this._prepareQueryParams({method:t,queryParams:e,sessionKey:o}),r=new window.Blob([s.toString()],{type:'application/x-www-form-urlencoded'});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,r)}catch(o){this.params.error$.next({id:'OneStat:ApiTransport:sendBeacon',message:'Unhandled beacon error',thrown:o,data:{method:t,params:e}})}return!1}async sendRequest(t,e,o){const s=Date.now(),r=r=>{r instanceof TypeError&&['Failed to fetch','NetworkError when attempting to fetch resource.'].includes(r.message)?this.params.error$.next({id:'Network',message:'Request failed',thrown:r}):this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:r,data:{method:t,params:e,sessionKey:o,time:Date.now()-s}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),_(`${this.apiBaseUrl}/fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:t,queryParams:e,sessionKey:o})}).then((t=>Number(t.headers.get('content-length'))>0?t.json().then((t=>Object.prototype.hasOwnProperty.call(t,'error_msg')?Promise.reject(t):t),r):void 0),r)}_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,o])=>e.append(t,'string'==typeof o?o:JSON.stringify(o)))),e}}class w{constructor(t){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=o.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,o){var s;this.subscription=new t.Subscription,this.statContext=e,this.config={...null!==(s=o.config)&&void 0!==s?s:{},requestRetryCount:1};const r=new t.Subject;this.experimental={error$:r};const i=new v({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:d[o.apiEnv],apiEnv:o.apiEnv,error$:r});this.api=new g({apiTransport:i,refreshAuthToken:o.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:r}),this.logger=new w({api:this.api,error$:r}),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()}logInited(){this.log({operation:'init'})}logReady(t){this.log({operation:'player_ready',param:String(t.time)})}logStarted(t){this.log({operation:'play',param:String(Math.round(t.position))})}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)})}logDownloadSpeed(t){this.log({operation:'download_speed',param:String(t.speed)})}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 o=Date.now(),s={vid:this.statContext.movieId,quality:this.statContext.quality,dst:this.statContext.destination,ct:this.statContext.contentType,aid:this.statContext.albumId,place:this.statContext.place,cdn_host:this.statContext.cdnHostname,connection_type:this.statContext.connectionType,connection_reused:!0===this.statContext.connectionReused?p.YES:!1===this.statContext.connectionReused?p.NO:void 0,stat_type:!0===this.statContext.autoplay?h.AUTO:!1===this.statContext.autoplay?h.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode};return void 0!==e&&(s.param=e),{operation:t,timestamp:o,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 o=e(require('lodash/debounce.js'));const s=(()=>{try{const t=Date.now().toString(),e=window.localStorage;e.setItem(t,t);const o=e.getItem(t)===t;return e.removeItem(t),o?e:null}catch(t){return null}})();var r,i,n,a,h,u,p,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,(r=exports.ApiEnv||(exports.ApiEnv={})).PROD='prod',r.VK_ALIAS='vk_alias',r.VIDEOTEST='videotest',r.TEST='test',r.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',a.RTMP='rtmp',a.UNKNOWN='unknown',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'}(p||(p={}));const d={[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]:''},c={start:1e3,factor:1.5,max:3e5,random:.1};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 o=l.get('uuid');o?this.uuid=String(o):(this.uuid=function(){const t='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),e=new Array(36);let o,s,r=0;for(s=0;s<36;s++)8===s||13===s||18===s||23===s?e[s]='-':14===s?e[s]='4':(r<=2&&(r=33554432+16777216*Math.random()|0),o=15&r,r>>=4,e[s]=t[19===s?3&o|8:o]);return e.join('')}(),l.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),o=this.sessionKey;if(!o)return;this.params.apiTransport.sendBeacon('log.externalLog',e,o)||this.logRequest(t)}async logRequest(t){var e;const o='log.externalLog',s=this.createLogParams(t),r=null!==(e=this.sessionKey)&&void 0!==e?e:await this._authorizeWithBackoff();if(!r)return;const i=async(t,e=this.params.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(o,s,r)}catch(s){if(!s||!('error_code'in s))return void this.params.error$.next({id:'logRequestUnknown',message:`Unknown ${o} error`,thrown:s});const r=null==s?void 0:s.error_code;switch(r){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#${r}`,message:`${o} 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.25',platform:'WEB',items:t.map((t=>({...t,time:0,type:1})))})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const e=t.getExponentialDelay(this.consequentAuthErrors,c);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.25'.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}}function f(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}const y=f({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),A=y?function(t){'function'==typeof t&&(t={fetch:t});const{fetch:e,Request:o=e.Request,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:r=!1}=t;if(!f({fetch:e,Request:o,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:r}))return{fetch:e,Request:i};let i=o;(i&&!i.prototype.hasOwnProperty('signal')||r)&&(i=function(t,e){let s;e&&e.signal&&(s=e.signal,delete e.signal);const r=new o(t,e);return s&&Object.defineProperty(r,'signal',{writable:!1,enumerable:!1,configurable:!0,value:s}),r},i.prototype=o.prototype);const n=e;return{fetch:(t,e)=>{const o=i&&i.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(o){let s;try{s=new DOMException('Aborted','AbortError')}catch(t){s=new Error('Aborted'),s.name='AbortError'}if(o.aborted)return Promise.reject(s);const r=new Promise(((t,e)=>{o.addEventListener('abort',(()=>e(s)),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([r,n(t,e)])}return n(t,e)},Request:i}}({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,_=y?A.fetch:window.fetch;y?A.Request:window.Request;class v{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='),o=await _(e,{method:'GET',mode:'cors',cache:'no-cache'}),s=await o.json(),r=null===(t=null==s?void 0:s.Answer[0])||void 0===t?void 0:t.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}),d[exports.ApiEnv.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(t,e,o){if(!window.Blob||!window.navigator.sendBeacon)return!1;const s=this._prepareQueryParams({method:t,queryParams:e,sessionKey:o}),r=new window.Blob([s.toString()],{type:'application/x-www-form-urlencoded'});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,r)}catch(o){this.params.error$.next({id:'OneStat:ApiTransport:sendBeacon',message:'Unhandled beacon error',thrown:o,data:{method:t,params:e}})}return!1}async sendRequest(t,e,o){const s=Date.now(),r=r=>{r instanceof TypeError&&['Failed to fetch','NetworkError when attempting to fetch resource.'].includes(r.message)?this.params.error$.next({id:'Network',message:'Request failed',thrown:r}):this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:r,data:{method:t,params:e,sessionKey:o,time:Date.now()-s}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),_(`${this.apiBaseUrl}/fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:t,queryParams:e,sessionKey:o})}).then((t=>Number(t.headers.get('content-length'))>0?t.json().then((t=>Object.prototype.hasOwnProperty.call(t,'error_msg')?Promise.reject(t):t),r):void 0),r)}_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,o])=>e.append(t,'string'==typeof o?o:JSON.stringify(o)))),e}}class w{constructor(t){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=o.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,o){var s;this.subscription=new t.Subscription,this.statContext=e,this.config={...null!==(s=o.config)&&void 0!==s?s:{},requestRetryCount:1};const r=new t.Subject;this.experimental={error$:r};const i=new v({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:d[o.apiEnv],apiEnv:o.apiEnv,error$:r});this.api=new g({apiTransport:i,refreshAuthToken:o.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:r}),this.logger=new w({api:this.api,error$:r}),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()}logInited(){this.log({operation:'init'})}logReady(t){this.log({operation:'player_ready',param:String(t.time)})}logStarted(t){this.log({operation:'play',param:String(Math.round(t.position))})}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)})}logDownloadSpeed(t){this.log({operation:'download_speed',param:String(t.speed)})}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 o=Date.now(),s={vid:this.statContext.movieId,quality:this.statContext.quality,dst:this.statContext.destination,ct:this.statContext.contentType,aid:this.statContext.albumId,place:this.statContext.place,cdn_host:this.statContext.cdnHostname,connection_type:this.statContext.connectionType,connection_reused:!0===this.statContext.connectionReused?p.YES:!1===this.statContext.connectionReused?p.NO:void 0,stat_type:!0===this.statContext.autoplay?h.AUTO:!1===this.statContext.autoplay?h.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode};return void 0!==e&&(s.param=e),{operation:t,timestamp:o,custom:s}}};
|
package/es2018.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-statistics v1.0.
|
|
3
|
-
*
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-statistics v1.0.25
|
|
3
|
+
* Wed, 21 Sep 2022 08:17:06 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-25/doc/
|
|
5
5
|
*/
|
|
6
|
-
import{ValueSubject as t,getExponentialDelay as e,Subscription as s,Subject as o,fromEvent as r}from'@vkontakte/videoplayer-shared/es2018.esm.js';import i from'lodash/debounce.js';const a=(()=>{try{const t=Date.now().toString(),e=window.localStorage;e.setItem(t,t);const s=e.getItem(t)===t;return e.removeItem(t),s?e:null}catch(t){return null}})();var n,h,u,l,d,c,p,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',t.UNKNOWN='unknown'}(l||(l={})),function(t){t.AUTO='auto',t.MANUAL=''}(d||(d={})),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'}(p||(p={}));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:.1};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 s=m.get('uuid');s?this.uuid=String(s):(this.uuid=function(){const t='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),e=new Array(36);let s,o,r=0;for(o=0;o<36;o++)8===o||13===o||18===o||23===o?e[o]='-':14===o?e[o]='4':(r<=2&&(r=33554432+16777216*Math.random()|0),s=15&r,r>>=4,e[o]=t[19===o?3&s|8:s]);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),s=this.sessionKey;if(!s)return;this.params.apiTransport.sendBeacon('log.externalLog',e,s)||this.logRequest(t)}async logRequest(t){var e;const s='log.externalLog',o=this.createLogParams(t),r=null!==(e=this.sessionKey)&&void 0!==e?e:await this._authorizeWithBackoff();if(!r)return;const i=async(t,e=this.params.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(s,o,r)}catch(o){if(!o||!('error_code'in o))return void this.params.error$.next({id:'logRequestUnknown',message:`Unknown ${s} error`,thrown:o});const r=null==o?void 0:o.error_code;switch(r){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#${r}`,message:`${s} error`,data:o})}}};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.24',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.24'.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}}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}const w=_({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),v=w?function(t){'function'==typeof t&&(t={fetch:t});const{fetch:e,Request:s=e.Request,AbortController:o,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:r=!1}=t;if(!_({fetch:e,Request:s,AbortController:o,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:r}))return{fetch:e,Request:i};let i=s;(i&&!i.prototype.hasOwnProperty('signal')||r)&&(i=function(t,e){let o;e&&e.signal&&(o=e.signal,delete e.signal);const r=new s(t,e);return o&&Object.defineProperty(r,'signal',{writable:!1,enumerable:!1,configurable:!0,value:o}),r},i.prototype=s.prototype);const a=e;return{fetch:(t,e)=>{const s=i&&i.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(s){let o;try{o=new DOMException('Aborted','AbortError')}catch(t){o=new Error('Aborted'),o.name='AbortError'}if(s.aborted)return Promise.reject(o);const r=new Promise(((t,e)=>{s.addEventListener('abort',(()=>e(o)),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([r,a(t,e)])}return a(t,e)},Request:i}}({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,T=w?v.fetch:window.fetch;w?v.Request:window.Request;class P{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='),s=await T(e,{method:'GET',mode:'cors',cache:'no-cache'}),o=await s.json(),r=null===(t=null==o?void 0:o.Answer[0])||void 0===t?void 0:t.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,s){if(!window.Blob||!window.navigator.sendBeacon)return!1;const o=this._prepareQueryParams({method:t,queryParams:e,sessionKey:s}),r=new window.Blob([o.toString()],{type:'application/x-www-form-urlencoded'});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,r)}catch(s){this.params.error$.next({id:'OneStat:ApiTransport:sendBeacon',message:'Unhandled beacon error',thrown:s,data:{method:t,params:e}})}return!1}async sendRequest(t,e,s){const o=Date.now(),r=r=>{r instanceof TypeError&&['Failed to fetch','NetworkError when attempting to fetch resource.'].includes(r.message)?this.params.error$.next({id:'Network',message:'Request failed',thrown:r}):this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:r,data:{method:t,params:e,sessionKey:s,time:Date.now()-o}})};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:s})}).then((t=>Number(t.headers.get('content-length'))>0?t.json().then((t=>Object.prototype.hasOwnProperty.call(t,'error_msg')?Promise.reject(t):t),r):void 0),r)}_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,s])=>e.append(t,'string'==typeof s?s:JSON.stringify(s)))),e}}class S{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 E{constructor(t,e){var i;this.subscription=new s,this.statContext=t,this.config={...null!==(i=e.config)&&void 0!==i?i:{},requestRetryCount:1};const a=new o;this.experimental={error$:a};const n=new P({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:g[e.apiEnv],apiEnv:e.apiEnv,error$:a});this.api=new A({apiTransport:n,refreshAuthToken:e.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:a}),this.logger=new S({api:this.api,error$:a}),this.subscription.add(r(window,'beforeunload').subscribe((()=>this.logger.flush(!0))))}updateContext(t){this.statContext={...this.statContext,...t}}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause()}resume(){this.logger.resume()}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}logInited(){this.log({operation:'init'})}logReady(t){this.log({operation:'player_ready',param:String(t.time)})}logStarted(t){this.log({operation:'play',param:String(Math.round(t.position))})}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)})}logDownloadSpeed(t){this.log({operation:'download_speed',param:String(t.speed)})}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 s=Date.now(),o={vid:this.statContext.movieId,quality:this.statContext.quality,dst:this.statContext.destination,ct:this.statContext.contentType,aid:this.statContext.albumId,place:this.statContext.place,cdn_host:this.statContext.cdnHostname,connection_type:this.statContext.connectionType,connection_reused:!0===this.statContext.connectionReused?p.YES:!1===this.statContext.connectionReused?p.NO:void 0,stat_type:!0===this.statContext.autoplay?d.AUTO:!1===this.statContext.autoplay?d.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode};return void 0!==e&&(o.param=e),{operation:t,timestamp:s,custom:o}}}export{n as ApiEnv,c as ConnectionType,l as ContentType,E as OneStat,h as Quality,u as ScreenDestination};
|
|
6
|
+
import{ValueSubject as t,getExponentialDelay as e,Subscription as s,Subject as o,fromEvent as r}from'@vkontakte/videoplayer-shared/es2018.esm.js';import i from'lodash/debounce.js';const a=(()=>{try{const t=Date.now().toString(),e=window.localStorage;e.setItem(t,t);const s=e.getItem(t)===t;return e.removeItem(t),s?e:null}catch(t){return null}})();var n,h,u,l,d,c,p,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',t.RTMP='rtmp',t.UNKNOWN='unknown'}(l||(l={})),function(t){t.AUTO='auto',t.MANUAL=''}(d||(d={})),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'}(p||(p={}));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:.1};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 s=m.get('uuid');s?this.uuid=String(s):(this.uuid=function(){const t='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),e=new Array(36);let s,o,r=0;for(o=0;o<36;o++)8===o||13===o||18===o||23===o?e[o]='-':14===o?e[o]='4':(r<=2&&(r=33554432+16777216*Math.random()|0),s=15&r,r>>=4,e[o]=t[19===o?3&s|8:s]);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),s=this.sessionKey;if(!s)return;this.params.apiTransport.sendBeacon('log.externalLog',e,s)||this.logRequest(t)}async logRequest(t){var e;const s='log.externalLog',o=this.createLogParams(t),r=null!==(e=this.sessionKey)&&void 0!==e?e:await this._authorizeWithBackoff();if(!r)return;const i=async(t,e=this.params.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(s,o,r)}catch(o){if(!o||!('error_code'in o))return void this.params.error$.next({id:'logRequestUnknown',message:`Unknown ${s} error`,thrown:o});const r=null==o?void 0:o.error_code;switch(r){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#${r}`,message:`${s} error`,data:o})}}};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.25',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.25'.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}}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}const w=_({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),v=w?function(t){'function'==typeof t&&(t={fetch:t});const{fetch:e,Request:s=e.Request,AbortController:o,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:r=!1}=t;if(!_({fetch:e,Request:s,AbortController:o,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:r}))return{fetch:e,Request:i};let i=s;(i&&!i.prototype.hasOwnProperty('signal')||r)&&(i=function(t,e){let o;e&&e.signal&&(o=e.signal,delete e.signal);const r=new s(t,e);return o&&Object.defineProperty(r,'signal',{writable:!1,enumerable:!1,configurable:!0,value:o}),r},i.prototype=s.prototype);const a=e;return{fetch:(t,e)=>{const s=i&&i.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(s){let o;try{o=new DOMException('Aborted','AbortError')}catch(t){o=new Error('Aborted'),o.name='AbortError'}if(s.aborted)return Promise.reject(o);const r=new Promise(((t,e)=>{s.addEventListener('abort',(()=>e(o)),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([r,a(t,e)])}return a(t,e)},Request:i}}({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,T=w?v.fetch:window.fetch;w?v.Request:window.Request;class P{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='),s=await T(e,{method:'GET',mode:'cors',cache:'no-cache'}),o=await s.json(),r=null===(t=null==o?void 0:o.Answer[0])||void 0===t?void 0:t.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,s){if(!window.Blob||!window.navigator.sendBeacon)return!1;const o=this._prepareQueryParams({method:t,queryParams:e,sessionKey:s}),r=new window.Blob([o.toString()],{type:'application/x-www-form-urlencoded'});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,r)}catch(s){this.params.error$.next({id:'OneStat:ApiTransport:sendBeacon',message:'Unhandled beacon error',thrown:s,data:{method:t,params:e}})}return!1}async sendRequest(t,e,s){const o=Date.now(),r=r=>{r instanceof TypeError&&['Failed to fetch','NetworkError when attempting to fetch resource.'].includes(r.message)?this.params.error$.next({id:'Network',message:'Request failed',thrown:r}):this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:r,data:{method:t,params:e,sessionKey:s,time:Date.now()-o}})};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:s})}).then((t=>Number(t.headers.get('content-length'))>0?t.json().then((t=>Object.prototype.hasOwnProperty.call(t,'error_msg')?Promise.reject(t):t),r):void 0),r)}_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,s])=>e.append(t,'string'==typeof s?s:JSON.stringify(s)))),e}}class S{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 R{constructor(t,e){var i;this.subscription=new s,this.statContext=t,this.config={...null!==(i=e.config)&&void 0!==i?i:{},requestRetryCount:1};const a=new o;this.experimental={error$:a};const n=new P({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:g[e.apiEnv],apiEnv:e.apiEnv,error$:a});this.api=new A({apiTransport:n,refreshAuthToken:e.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:a}),this.logger=new S({api:this.api,error$:a}),this.subscription.add(r(window,'beforeunload').subscribe((()=>this.logger.flush(!0))))}updateContext(t){this.statContext={...this.statContext,...t}}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause()}resume(){this.logger.resume()}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}logInited(){this.log({operation:'init'})}logReady(t){this.log({operation:'player_ready',param:String(t.time)})}logStarted(t){this.log({operation:'play',param:String(Math.round(t.position))})}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)})}logDownloadSpeed(t){this.log({operation:'download_speed',param:String(t.speed)})}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 s=Date.now(),o={vid:this.statContext.movieId,quality:this.statContext.quality,dst:this.statContext.destination,ct:this.statContext.contentType,aid:this.statContext.albumId,place:this.statContext.place,cdn_host:this.statContext.cdnHostname,connection_type:this.statContext.connectionType,connection_reused:!0===this.statContext.connectionReused?p.YES:!1===this.statContext.connectionReused?p.NO:void 0,stat_type:!0===this.statContext.autoplay?d.AUTO:!1===this.statContext.autoplay?d.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode};return void 0!==e&&(o.param=e),{operation:t,timestamp:s,custom:o}}}export{n as ApiEnv,c as ConnectionType,l as ContentType,R 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
|
-
*
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-statistics v1.0.25
|
|
3
|
+
* Wed, 21 Sep 2022 08:17:06 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-25/doc/
|
|
5
5
|
*/
|
|
6
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var e=require('@vkontakte/videoplayer-shared/esnext.cjs.js');function t(e){return e&&'object'==typeof e&&'default'in e?e:{default:e}}var o=t(require('lodash/debounce.js'));const s=(()=>{try{const e=Date.now().toString(),t=window.localStorage;t.setItem(e,e);const o=t.getItem(e)===e;return t.removeItem(e),o?t:null}catch(e){return null}})();var r,i,a,n,h,u,p,c={get:e=>function(e){const t=s?s.getItem('_one-stat_'+e):null;if(null===t)return null;try{return JSON.parse(t)}catch(e){return null}}(e)||null,set(e,t){!function(e,t){try{s&&s.setItem('_one-stat_'+e,JSON.stringify(t))}catch(e){}}(e,t)},remove(e){!function(e){s&&s.removeItem('_one-stat_'+e)}(e)}};exports.ApiEnv=void 0,(r=exports.ApiEnv||(exports.ApiEnv={})).PROD='prod',r.VK_ALIAS='vk_alias',r.VIDEOTEST='videotest',r.TEST='test',r.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,(a=exports.ScreenDestination||(exports.ScreenDestination={})).CHROMECAST='chromecast',a.APPLE_TV='appletv',a.PIP='pip',a.HEADPHONES='externalHeadphones',a.SCREEN='',exports.ContentType=void 0,(n=exports.ContentType||(exports.ContentType={})).MP4='mp4',n.DASH='dash',n.DASH_SEP='dash_sep',n.ONDEMAND_DASH='ondemand_dash',n.HLS='hls',n.ONDEMAND_HLS='ondemand_hls',n.WEBM='webm',n.UNKNOWN='unknown',function(e){e.AUTO='auto',e.MANUAL=''}(h||(h={})),exports.ConnectionType=void 0,(u=exports.ConnectionType||(exports.ConnectionType={})).HTTP1='http1',u.HTTP2='http2',u.HTTP3='http3',function(e){e[e.YES=1]='YES',e[e.NO=0]='NO'}(p||(p={}));const l={[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:.1};var m;!function(e){e[e.PARAM_SESSION_EXPIRED=102]='PARAM_SESSION_EXPIRED',e[e.PARAM_SESSION_KEY=103]='PARAM_SESSION_KEY',e[e.PARAM_SIGNATURE=104]='PARAM_SIGNATURE',e[e.AUTH_LOGIN=401]='AUTH_LOGIN'}(m||(m={}));class g{params;uuid;authToken;sessionKey;authorizePromise;refreshAuthTokenPromise;consequentAuthErrors=0;authorized$=new e.ValueSubject(!1);backoffTimeoutId;constructor(e){this.params=e;const t=c.get('uuid');t?this.uuid=String(t):(this.uuid=function(){const e='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),t=new Array(36);let o,s,r=0;for(s=0;s<36;s++)8===s||13===s||18===s||23===s?t[s]='-':14===s?t[s]='4':(r<=2&&(r=33554432+16777216*Math.random()|0),o=15&r,r>>=4,t[s]=e[19===s?3&o|8:o]);return t.join('')}(),c.set('uuid',this.uuid))}async authorize(e){return this.authToken=e??await this.refreshAuthToken(),this._authorizeWithBackoff()}logBeacon(e){const t=this.createLogParams(e),o=this.sessionKey;if(!o)return;this.params.apiTransport.sendBeacon('log.externalLog',t,o)||this.logRequest(e)}async logRequest(e){const t='log.externalLog',o=this.createLogParams(e),s=this.sessionKey??await this._authorizeWithBackoff();if(!s)return;const r=async(e,i=this.params.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(t,o,s)}catch(o){if(!o||!('error_code'in o))return void this.params.error$.next({id:'logRequestUnknown',message:`Unknown ${t} error`,thrown:o});const s=o?.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?r(e,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?r(e,i-1):void 0;default:return void this.params.error$.next({id:`LogRequest#${s}`,message:`${t} error`,data:o})}}};return r(e)}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(e){return{collector:'ok.mobile.apps.video',data:JSON.stringify({application:'@vkontakte/videoplayer-statistics:1.0.24',platform:'WEB',items:e.map((e=>({...e,time:0,type:1})))})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const t=e.getExponentialDelay(this.consequentAuthErrors,d);return new Promise((e=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout((()=>{this._authorize().then(e).catch((e=>this.params.error$.next({id:'AuthorizeBackoff',message:'Otherwise unhandle errror in authrization',thrown:e}))).finally((()=>this.backoffTimeoutId=0))}),t))}))}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const e={session_data:{version:2,device_id:this.uuid,client_version:'1.0.24'.split('-')[0],client_type:'SDK_JS'}};return void 0!==this.authToken&&(e.session_data.auth_token=this.authToken,e.session_data.version=3),this.authorizePromise=this.params.apiTransport.sendRequest('auth.anonymLogin',e).then((e=>(e&&e.session_key||this.params.error$.next({id:'AuthorizeFailed',message:'No session key',data:e}),this.sessionKey=e?.session_key??void 0,this.sessionKey))).catch((async e=>{this.sessionKey=void 0;const t=e?.error_code;switch(t){case m.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}t?this.params.error$.next({id:`Authorize#${t}`,message:'authorize error',data:e}):this.params.error$.next({id:'AuthorizeUnknown',message:'authorize error',thrown:e})})).finally((()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(void 0!==this.sessionKey)})),this.authorizePromise}}function f(e){return e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill'),!0):'function'==typeof e.Request&&!e.Request.prototype.hasOwnProperty('signal')||!e.AbortController}const y=f({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),A=y?function(e){'function'==typeof e&&(e={fetch:e});const{fetch:t,Request:o=t.Request,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:r=!1}=e;if(!f({fetch:t,Request:o,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:r}))return{fetch:t,Request:i};let i=o;(i&&!i.prototype.hasOwnProperty('signal')||r)&&(i=function(e,t){let s;t&&t.signal&&(s=t.signal,delete t.signal);const r=new o(e,t);return s&&Object.defineProperty(r,'signal',{writable:!1,enumerable:!1,configurable:!0,value:s}),r},i.prototype=o.prototype);const a=t;return{fetch:(e,t)=>{const o=i&&i.prototype.isPrototypeOf(e)?e.signal:t?t.signal:void 0;if(o){let s;try{s=new DOMException('Aborted','AbortError')}catch(e){s=new Error('Aborted'),s.name='AbortError'}if(o.aborted)return Promise.reject(s);const r=new Promise(((e,t)=>{o.addEventListener('abort',(()=>t(s)),{once:!0})}));return t&&t.signal&&delete t.signal,Promise.race([r,a(e,t)])}return a(e,t)},Request:i}}({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,_=y?A.fetch:window.fetch;y?A.Request:window.Request;class w{apiKey;apiBaseUrl;apiEnv;isApiBaseUrlFetched;params;constructor(e){this.params=e,this.apiKey=e.apiKey,this.apiEnv=e.apiEnv,this.apiBaseUrl=e.apiBaseUrl,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){if(this.apiEnv!==exports.ApiEnv.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const e=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),t=await _(e,{method:'GET',mode:'cors',cache:'no-cache'}),o=(await t.json())?.Answer[0]?.data;if(!o)throw new Error('Wrong DNS response');return o}catch(e){return this.params.error$.next({id:'OneStat:ApiTransport:resolveApiBaseUrl',message:'Unhandled resolve api base url error',thrown:e}),l[exports.ApiEnv.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(e,t,o){if(!window.Blob||!window.navigator.sendBeacon)return!1;const s=this._prepareQueryParams({method:e,queryParams:t,sessionKey:o}),r=new window.Blob([s.toString()],{type:'application/x-www-form-urlencoded'});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,r)}catch(o){this.params.error$.next({id:'OneStat:ApiTransport:sendBeacon',message:'Unhandled beacon error',thrown:o,data:{method:e,params:t}})}return!1}async sendRequest(e,t,o){const s=Date.now(),r=r=>{r instanceof TypeError&&['Failed to fetch','NetworkError when attempting to fetch resource.'].includes(r.message)?this.params.error$.next({id:'Network',message:'Request failed',thrown:r}):this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:r,data:{method:e,params:t,sessionKey:o,time:Date.now()-s}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),_(`${this.apiBaseUrl}/fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:e,queryParams:t,sessionKey:o})}).then((e=>Number(e.headers.get('content-length'))>0?e.json().then((e=>Object.prototype.hasOwnProperty.call(e,'error_msg')?Promise.reject(e):e),r):void 0),r)}_prepareQueryParams(e){const t=new URLSearchParams({format:'JSON',method:e.method,application_key:this.apiKey});return void 0!==e.sessionKey&&t.append('session_key',e.sessionKey),Object.entries(e.queryParams).forEach((([e,o])=>t.append(e,'string'==typeof o?o:JSON.stringify(o)))),t}}class v{api;error$;requestQueue=[];subscription;isPaused=!1;debouncedFlush=o.default((()=>{try{this.flush()}catch(e){this.error$.next({id:'LoggerError',message:String(e)??'Unknown logger error',thrown:e})}}),3e3,{maxWait:15e3});constructor(e){this.api=e.api,this.error$=e.error$,this.subscription=this.api.authorized$.subscribe((e=>{e&&this.debouncedFlush()}))}log(e){this.requestQueue.push(e),this.isPaused||this.debouncedFlush()}flush(e=!1){0!==this.requestQueue.length&&(this.api.authorized$.getValue()?(e?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[]):e||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 e.Subscription;experimental;statContext;constructor(t,o){this.statContext=t,this.config={...o.config??{},requestRetryCount:1};const s=new e.Subject;this.experimental={error$:s};const r=new w({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:l[o.apiEnv],apiEnv:o.apiEnv,error$:s});this.api=new g({apiTransport:r,refreshAuthToken:o.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:s}),this.logger=new v({api:this.api,error$:s}),this.subscription.add(e.fromEvent(window,'beforeunload').subscribe((()=>this.logger.flush(!0))))}updateContext(e){this.statContext={...this.statContext,...e}}authorize(e){return this.api.authorize(e)}pause(){this.logger.pause()}resume(){this.logger.resume()}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}logInited(){this.log({operation:'init'})}logReady(e){this.log({operation:'player_ready',param:String(e.time)})}logStarted(e){this.log({operation:'play',param:String(Math.round(e.position))})}logPlay(){this.log({operation:'play_toggle'})}logPause(e){this.log({operation:'pause',param:String(Math.round(e.position))})}logSeek(){this.log({operation:'seek'})}logFirstBytes(e){this.log({operation:'first_bytes',param:String(e.time)})}logFirstFrame(e){this.log({operation:'first_frame',param:String(e.time)})}logError(e){this.log({operation:'error',param:e.errorType})}logWatchCoverageRecord(e){this.log({operation:'watch_coverage_record',param:`${e.start}-${e.end}`}),this.logger.flush(!0)}logWatchCoverageLive(e){this.log({operation:'watch_coverage_live',param:`${e.start}-${e.end}`}),this.logger.flush(!0)}logEmptyBuffer(e){this.log({operation:'empty_buffer',param:String(e.duration)})}logDownloadSpeed(e){this.log({operation:'download_speed',param:String(e.speed)})}logAdSlotRequest(){this.log({operation:'adv',param:'slot_request'})}logAdStarted(e){this.log({operation:'adv',param:e})}logAdPaused(){this.log({operation:'adv',param:'pause'})}logAdResumed(){this.log({operation:'adv',param:'resume'})}logAdEnded(){this.log({operation:'adv',param:'ended'})}logAdSkipped(){this.log({operation:'adv',param:'skip'})}logAdClicked(){this.log({operation:'adv',param:'click'})}log(e){const t=this.crateLogItem(e);this.logger.log(t)}crateLogItem({operation:e,param:t}){const o=Date.now(),s={vid:this.statContext.movieId,quality:this.statContext.quality,dst:this.statContext.destination,ct:this.statContext.contentType,aid:this.statContext.albumId,place:this.statContext.place,cdn_host:this.statContext.cdnHostname,connection_type:this.statContext.connectionType,connection_reused:!0===this.statContext.connectionReused?p.YES:!1===this.statContext.connectionReused?p.NO:void 0,stat_type:!0===this.statContext.autoplay?h.AUTO:!1===this.statContext.autoplay?h.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode};return void 0!==t&&(s.param=t),{operation:e,timestamp:o,custom:s}}};
|
|
6
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var e=require('@vkontakte/videoplayer-shared/esnext.cjs.js');function t(e){return e&&'object'==typeof e&&'default'in e?e:{default:e}}var o=t(require('lodash/debounce.js'));const s=(()=>{try{const e=Date.now().toString(),t=window.localStorage;t.setItem(e,e);const o=t.getItem(e)===e;return t.removeItem(e),o?t:null}catch(e){return null}})();var r,i,a,n,h,u,p,c={get:e=>function(e){const t=s?s.getItem('_one-stat_'+e):null;if(null===t)return null;try{return JSON.parse(t)}catch(e){return null}}(e)||null,set(e,t){!function(e,t){try{s&&s.setItem('_one-stat_'+e,JSON.stringify(t))}catch(e){}}(e,t)},remove(e){!function(e){s&&s.removeItem('_one-stat_'+e)}(e)}};exports.ApiEnv=void 0,(r=exports.ApiEnv||(exports.ApiEnv={})).PROD='prod',r.VK_ALIAS='vk_alias',r.VIDEOTEST='videotest',r.TEST='test',r.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,(a=exports.ScreenDestination||(exports.ScreenDestination={})).CHROMECAST='chromecast',a.APPLE_TV='appletv',a.PIP='pip',a.HEADPHONES='externalHeadphones',a.SCREEN='',exports.ContentType=void 0,(n=exports.ContentType||(exports.ContentType={})).MP4='mp4',n.DASH='dash',n.DASH_SEP='dash_sep',n.ONDEMAND_DASH='ondemand_dash',n.HLS='hls',n.ONDEMAND_HLS='ondemand_hls',n.WEBM='webm',n.RTMP='rtmp',n.UNKNOWN='unknown',function(e){e.AUTO='auto',e.MANUAL=''}(h||(h={})),exports.ConnectionType=void 0,(u=exports.ConnectionType||(exports.ConnectionType={})).HTTP1='http1',u.HTTP2='http2',u.HTTP3='http3',function(e){e[e.YES=1]='YES',e[e.NO=0]='NO'}(p||(p={}));const l={[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:.1};var m;!function(e){e[e.PARAM_SESSION_EXPIRED=102]='PARAM_SESSION_EXPIRED',e[e.PARAM_SESSION_KEY=103]='PARAM_SESSION_KEY',e[e.PARAM_SIGNATURE=104]='PARAM_SIGNATURE',e[e.AUTH_LOGIN=401]='AUTH_LOGIN'}(m||(m={}));class g{params;uuid;authToken;sessionKey;authorizePromise;refreshAuthTokenPromise;consequentAuthErrors=0;authorized$=new e.ValueSubject(!1);backoffTimeoutId;constructor(e){this.params=e;const t=c.get('uuid');t?this.uuid=String(t):(this.uuid=function(){const e='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),t=new Array(36);let o,s,r=0;for(s=0;s<36;s++)8===s||13===s||18===s||23===s?t[s]='-':14===s?t[s]='4':(r<=2&&(r=33554432+16777216*Math.random()|0),o=15&r,r>>=4,t[s]=e[19===s?3&o|8:o]);return t.join('')}(),c.set('uuid',this.uuid))}async authorize(e){return this.authToken=e??await this.refreshAuthToken(),this._authorizeWithBackoff()}logBeacon(e){const t=this.createLogParams(e),o=this.sessionKey;if(!o)return;this.params.apiTransport.sendBeacon('log.externalLog',t,o)||this.logRequest(e)}async logRequest(e){const t='log.externalLog',o=this.createLogParams(e),s=this.sessionKey??await this._authorizeWithBackoff();if(!s)return;const r=async(e,i=this.params.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(t,o,s)}catch(o){if(!o||!('error_code'in o))return void this.params.error$.next({id:'logRequestUnknown',message:`Unknown ${t} error`,thrown:o});const s=o?.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?r(e,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?r(e,i-1):void 0;default:return void this.params.error$.next({id:`LogRequest#${s}`,message:`${t} error`,data:o})}}};return r(e)}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(e){return{collector:'ok.mobile.apps.video',data:JSON.stringify({application:'@vkontakte/videoplayer-statistics:1.0.25',platform:'WEB',items:e.map((e=>({...e,time:0,type:1})))})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const t=e.getExponentialDelay(this.consequentAuthErrors,d);return new Promise((e=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout((()=>{this._authorize().then(e).catch((e=>this.params.error$.next({id:'AuthorizeBackoff',message:'Otherwise unhandle errror in authrization',thrown:e}))).finally((()=>this.backoffTimeoutId=0))}),t))}))}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const e={session_data:{version:2,device_id:this.uuid,client_version:'1.0.25'.split('-')[0],client_type:'SDK_JS'}};return void 0!==this.authToken&&(e.session_data.auth_token=this.authToken,e.session_data.version=3),this.authorizePromise=this.params.apiTransport.sendRequest('auth.anonymLogin',e).then((e=>(e&&e.session_key||this.params.error$.next({id:'AuthorizeFailed',message:'No session key',data:e}),this.sessionKey=e?.session_key??void 0,this.sessionKey))).catch((async e=>{this.sessionKey=void 0;const t=e?.error_code;switch(t){case m.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}t?this.params.error$.next({id:`Authorize#${t}`,message:'authorize error',data:e}):this.params.error$.next({id:'AuthorizeUnknown',message:'authorize error',thrown:e})})).finally((()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(void 0!==this.sessionKey)})),this.authorizePromise}}function f(e){return e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill'),!0):'function'==typeof e.Request&&!e.Request.prototype.hasOwnProperty('signal')||!e.AbortController}const y=f({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),A=y?function(e){'function'==typeof e&&(e={fetch:e});const{fetch:t,Request:o=t.Request,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:r=!1}=e;if(!f({fetch:t,Request:o,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:r}))return{fetch:t,Request:i};let i=o;(i&&!i.prototype.hasOwnProperty('signal')||r)&&(i=function(e,t){let s;t&&t.signal&&(s=t.signal,delete t.signal);const r=new o(e,t);return s&&Object.defineProperty(r,'signal',{writable:!1,enumerable:!1,configurable:!0,value:s}),r},i.prototype=o.prototype);const a=t;return{fetch:(e,t)=>{const o=i&&i.prototype.isPrototypeOf(e)?e.signal:t?t.signal:void 0;if(o){let s;try{s=new DOMException('Aborted','AbortError')}catch(e){s=new Error('Aborted'),s.name='AbortError'}if(o.aborted)return Promise.reject(s);const r=new Promise(((e,t)=>{o.addEventListener('abort',(()=>t(s)),{once:!0})}));return t&&t.signal&&delete t.signal,Promise.race([r,a(e,t)])}return a(e,t)},Request:i}}({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,_=y?A.fetch:window.fetch;y?A.Request:window.Request;class w{apiKey;apiBaseUrl;apiEnv;isApiBaseUrlFetched;params;constructor(e){this.params=e,this.apiKey=e.apiKey,this.apiEnv=e.apiEnv,this.apiBaseUrl=e.apiBaseUrl,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){if(this.apiEnv!==exports.ApiEnv.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const e=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),t=await _(e,{method:'GET',mode:'cors',cache:'no-cache'}),o=(await t.json())?.Answer[0]?.data;if(!o)throw new Error('Wrong DNS response');return o}catch(e){return this.params.error$.next({id:'OneStat:ApiTransport:resolveApiBaseUrl',message:'Unhandled resolve api base url error',thrown:e}),l[exports.ApiEnv.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(e,t,o){if(!window.Blob||!window.navigator.sendBeacon)return!1;const s=this._prepareQueryParams({method:e,queryParams:t,sessionKey:o}),r=new window.Blob([s.toString()],{type:'application/x-www-form-urlencoded'});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,r)}catch(o){this.params.error$.next({id:'OneStat:ApiTransport:sendBeacon',message:'Unhandled beacon error',thrown:o,data:{method:e,params:t}})}return!1}async sendRequest(e,t,o){const s=Date.now(),r=r=>{r instanceof TypeError&&['Failed to fetch','NetworkError when attempting to fetch resource.'].includes(r.message)?this.params.error$.next({id:'Network',message:'Request failed',thrown:r}):this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:r,data:{method:e,params:t,sessionKey:o,time:Date.now()-s}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),_(`${this.apiBaseUrl}/fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:e,queryParams:t,sessionKey:o})}).then((e=>Number(e.headers.get('content-length'))>0?e.json().then((e=>Object.prototype.hasOwnProperty.call(e,'error_msg')?Promise.reject(e):e),r):void 0),r)}_prepareQueryParams(e){const t=new URLSearchParams({format:'JSON',method:e.method,application_key:this.apiKey});return void 0!==e.sessionKey&&t.append('session_key',e.sessionKey),Object.entries(e.queryParams).forEach((([e,o])=>t.append(e,'string'==typeof o?o:JSON.stringify(o)))),t}}class v{api;error$;requestQueue=[];subscription;isPaused=!1;debouncedFlush=o.default((()=>{try{this.flush()}catch(e){this.error$.next({id:'LoggerError',message:String(e)??'Unknown logger error',thrown:e})}}),3e3,{maxWait:15e3});constructor(e){this.api=e.api,this.error$=e.error$,this.subscription=this.api.authorized$.subscribe((e=>{e&&this.debouncedFlush()}))}log(e){this.requestQueue.push(e),this.isPaused||this.debouncedFlush()}flush(e=!1){0!==this.requestQueue.length&&(this.api.authorized$.getValue()?(e?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[]):e||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 e.Subscription;experimental;statContext;constructor(t,o){this.statContext=t,this.config={...o.config??{},requestRetryCount:1};const s=new e.Subject;this.experimental={error$:s};const r=new w({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:l[o.apiEnv],apiEnv:o.apiEnv,error$:s});this.api=new g({apiTransport:r,refreshAuthToken:o.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:s}),this.logger=new v({api:this.api,error$:s}),this.subscription.add(e.fromEvent(window,'beforeunload').subscribe((()=>this.logger.flush(!0))))}updateContext(e){this.statContext={...this.statContext,...e}}authorize(e){return this.api.authorize(e)}pause(){this.logger.pause()}resume(){this.logger.resume()}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}logInited(){this.log({operation:'init'})}logReady(e){this.log({operation:'player_ready',param:String(e.time)})}logStarted(e){this.log({operation:'play',param:String(Math.round(e.position))})}logPlay(){this.log({operation:'play_toggle'})}logPause(e){this.log({operation:'pause',param:String(Math.round(e.position))})}logSeek(){this.log({operation:'seek'})}logFirstBytes(e){this.log({operation:'first_bytes',param:String(e.time)})}logFirstFrame(e){this.log({operation:'first_frame',param:String(e.time)})}logError(e){this.log({operation:'error',param:e.errorType})}logWatchCoverageRecord(e){this.log({operation:'watch_coverage_record',param:`${e.start}-${e.end}`}),this.logger.flush(!0)}logWatchCoverageLive(e){this.log({operation:'watch_coverage_live',param:`${e.start}-${e.end}`}),this.logger.flush(!0)}logEmptyBuffer(e){this.log({operation:'empty_buffer',param:String(e.duration)})}logDownloadSpeed(e){this.log({operation:'download_speed',param:String(e.speed)})}logAdSlotRequest(){this.log({operation:'adv',param:'slot_request'})}logAdStarted(e){this.log({operation:'adv',param:e})}logAdPaused(){this.log({operation:'adv',param:'pause'})}logAdResumed(){this.log({operation:'adv',param:'resume'})}logAdEnded(){this.log({operation:'adv',param:'ended'})}logAdSkipped(){this.log({operation:'adv',param:'skip'})}logAdClicked(){this.log({operation:'adv',param:'click'})}log(e){const t=this.crateLogItem(e);this.logger.log(t)}crateLogItem({operation:e,param:t}){const o=Date.now(),s={vid:this.statContext.movieId,quality:this.statContext.quality,dst:this.statContext.destination,ct:this.statContext.contentType,aid:this.statContext.albumId,place:this.statContext.place,cdn_host:this.statContext.cdnHostname,connection_type:this.statContext.connectionType,connection_reused:!0===this.statContext.connectionReused?p.YES:!1===this.statContext.connectionReused?p.NO:void 0,stat_type:!0===this.statContext.autoplay?h.AUTO:!1===this.statContext.autoplay?h.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode};return void 0!==t&&(s.param=t),{operation:e,timestamp:o,custom:s}}};
|
package/esnext.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-statistics v1.0.
|
|
3
|
-
*
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-statistics v1.0.25
|
|
3
|
+
* Wed, 21 Sep 2022 08:17:06 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-25/doc/
|
|
5
5
|
*/
|
|
6
|
-
import{ValueSubject as t,getExponentialDelay as e,Subscription as s,Subject as o,fromEvent as r}from'@vkontakte/videoplayer-shared/esnext.esm.js';import i from'lodash/debounce.js';const a=(()=>{try{const t=Date.now().toString(),e=window.localStorage;e.setItem(t,t);const s=e.getItem(t)===t;return e.removeItem(t),s?e:null}catch(t){return null}})();var n,h,u,c,p,l,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',t.UNKNOWN='unknown'}(c||(c={})),function(t){t.AUTO='auto',t.MANUAL=''}(p||(p={})),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'}(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:.1};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 s,o,r=0;for(o=0;o<36;o++)8===o||13===o||18===o||23===o?e[o]='-':14===o?e[o]='4':(r<=2&&(r=33554432+16777216*Math.random()|0),s=15&r,r>>=4,e[o]=t[19===o?3&s|8:s]);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),s=this.sessionKey;if(!s)return;this.params.apiTransport.sendBeacon('log.externalLog',e,s)||this.logRequest(t)}async logRequest(t){const e='log.externalLog',s=this.createLogParams(t),o=this.sessionKey??await this._authorizeWithBackoff();if(!o)return;const r=async(t,i=this.params.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(e,s,o)}catch(s){if(!s||!('error_code'in s))return void this.params.error$.next({id:'logRequestUnknown',message:`Unknown ${e} error`,thrown:s});const o=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(),i>0?r(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?r(t,i-1):void 0;default:return void this.params.error$.next({id:`LogRequest#${o}`,message:`${e} error`,data:s})}}};return r(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.24',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.24'.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}}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}const w=_({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),T=w?function(t){'function'==typeof t&&(t={fetch:t});const{fetch:e,Request:s=e.Request,AbortController:o,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:r=!1}=t;if(!_({fetch:e,Request:s,AbortController:o,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:r}))return{fetch:e,Request:i};let i=s;(i&&!i.prototype.hasOwnProperty('signal')||r)&&(i=function(t,e){let o;e&&e.signal&&(o=e.signal,delete e.signal);const r=new s(t,e);return o&&Object.defineProperty(r,'signal',{writable:!1,enumerable:!1,configurable:!0,value:o}),r},i.prototype=s.prototype);const a=e;return{fetch:(t,e)=>{const s=i&&i.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(s){let o;try{o=new DOMException('Aborted','AbortError')}catch(t){o=new Error('Aborted'),o.name='AbortError'}if(s.aborted)return Promise.reject(o);const r=new Promise(((t,e)=>{s.addEventListener('abort',(()=>e(o)),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([r,a(t,e)])}return a(t,e)},Request:i}}({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,P=w?T.fetch:window.fetch;w?T.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!==n.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const t=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),e=await P(t,{method:'GET',mode:'cors',cache:'no-cache'}),s=(await e.json())?.Answer[0]?.data;if(!s)throw new Error('Wrong DNS response');return s}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,s){if(!window.Blob||!window.navigator.sendBeacon)return!1;const o=this._prepareQueryParams({method:t,queryParams:e,sessionKey:s}),r=new window.Blob([o.toString()],{type:'application/x-www-form-urlencoded'});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,r)}catch(s){this.params.error$.next({id:'OneStat:ApiTransport:sendBeacon',message:'Unhandled beacon error',thrown:s,data:{method:t,params:e}})}return!1}async sendRequest(t,e,s){const o=Date.now(),r=r=>{r instanceof TypeError&&['Failed to fetch','NetworkError when attempting to fetch resource.'].includes(r.message)?this.params.error$.next({id:'Network',message:'Request failed',thrown:r}):this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:r,data:{method:t,params:e,sessionKey:s,time:Date.now()-o}})};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:s})}).then((t=>Number(t.headers.get('content-length'))>0?t.json().then((t=>Object.prototype.hasOwnProperty.call(t,'error_msg')?Promise.reject(t):t),r):void 0),r)}_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,s])=>e.append(t,'string'==typeof s?s:JSON.stringify(s)))),e}}class E{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 v{api;logger;config;subscription=new s;experimental;statContext;constructor(t,e){this.statContext=t,this.config={...e.config??{},requestRetryCount:1};const s=new o;this.experimental={error$:s};const i=new S({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:g[e.apiEnv],apiEnv:e.apiEnv,error$:s});this.api=new A({apiTransport:i,refreshAuthToken:e.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:s}),this.logger=new E({api:this.api,error$:s}),this.subscription.add(r(window,'beforeunload').subscribe((()=>this.logger.flush(!0))))}updateContext(t){this.statContext={...this.statContext,...t}}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause()}resume(){this.logger.resume()}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}logInited(){this.log({operation:'init'})}logReady(t){this.log({operation:'player_ready',param:String(t.time)})}logStarted(t){this.log({operation:'play',param:String(Math.round(t.position))})}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)})}logDownloadSpeed(t){this.log({operation:'download_speed',param:String(t.speed)})}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 s=Date.now(),o={vid:this.statContext.movieId,quality:this.statContext.quality,dst:this.statContext.destination,ct:this.statContext.contentType,aid:this.statContext.albumId,place:this.statContext.place,cdn_host:this.statContext.cdnHostname,connection_type:this.statContext.connectionType,connection_reused:!0===this.statContext.connectionReused?d.YES:!1===this.statContext.connectionReused?d.NO:void 0,stat_type:!0===this.statContext.autoplay?p.AUTO:!1===this.statContext.autoplay?p.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode};return void 0!==e&&(o.param=e),{operation:t,timestamp:s,custom:o}}}export{n as ApiEnv,l as ConnectionType,c as ContentType,v as OneStat,h as Quality,u as ScreenDestination};
|
|
6
|
+
import{ValueSubject as t,getExponentialDelay as e,Subscription as s,Subject as r,fromEvent as o}from'@vkontakte/videoplayer-shared/esnext.esm.js';import i from'lodash/debounce.js';const a=(()=>{try{const t=Date.now().toString(),e=window.localStorage;e.setItem(t,t);const s=e.getItem(t)===t;return e.removeItem(t),s?e:null}catch(t){return null}})();var n,h,u,c,p,l,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',t.RTMP='rtmp',t.UNKNOWN='unknown'}(c||(c={})),function(t){t.AUTO='auto',t.MANUAL=''}(p||(p={})),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'}(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:.1};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 s,r,o=0;for(r=0;r<36;r++)8===r||13===r||18===r||23===r?e[r]='-':14===r?e[r]='4':(o<=2&&(o=33554432+16777216*Math.random()|0),s=15&o,o>>=4,e[r]=t[19===r?3&s|8:s]);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),s=this.sessionKey;if(!s)return;this.params.apiTransport.sendBeacon('log.externalLog',e,s)||this.logRequest(t)}async logRequest(t){const e='log.externalLog',s=this.createLogParams(t),r=this.sessionKey??await this._authorizeWithBackoff();if(!r)return;const o=async(t,i=this.params.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(e,s,r)}catch(s){if(!s||!('error_code'in s))return void this.params.error$.next({id:'logRequestUnknown',message:`Unknown ${e} error`,thrown:s});const r=s?.error_code;switch(r){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#${r}`,message:`${e} error`,data:s})}}};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.25',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.25'.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}}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}const w=_({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),T=w?function(t){'function'==typeof t&&(t={fetch:t});const{fetch:e,Request:s=e.Request,AbortController:r,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o=!1}=t;if(!_({fetch:e,Request:s,AbortController:r,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:e,Request:i};let i=s;(i&&!i.prototype.hasOwnProperty('signal')||o)&&(i=function(t,e){let r;e&&e.signal&&(r=e.signal,delete e.signal);const o=new s(t,e);return r&&Object.defineProperty(o,'signal',{writable:!1,enumerable:!1,configurable:!0,value:r}),o},i.prototype=s.prototype);const a=e;return{fetch:(t,e)=>{const s=i&&i.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(s){let r;try{r=new DOMException('Aborted','AbortError')}catch(t){r=new Error('Aborted'),r.name='AbortError'}if(s.aborted)return Promise.reject(r);const o=new Promise(((t,e)=>{s.addEventListener('abort',(()=>e(r)),{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,P=w?T.fetch:window.fetch;w?T.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!==n.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const t=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),e=await P(t,{method:'GET',mode:'cors',cache:'no-cache'}),s=(await e.json())?.Answer[0]?.data;if(!s)throw new Error('Wrong DNS response');return s}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,s){if(!window.Blob||!window.navigator.sendBeacon)return!1;const r=this._prepareQueryParams({method:t,queryParams:e,sessionKey:s}),o=new window.Blob([r.toString()],{type:'application/x-www-form-urlencoded'});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,o)}catch(s){this.params.error$.next({id:'OneStat:ApiTransport:sendBeacon',message:'Unhandled beacon error',thrown:s,data:{method:t,params:e}})}return!1}async sendRequest(t,e,s){const r=Date.now(),o=o=>{o instanceof TypeError&&['Failed to fetch','NetworkError when attempting to fetch resource.'].includes(o.message)?this.params.error$.next({id:'Network',message:'Request failed',thrown:o}):this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:o,data:{method:t,params:e,sessionKey:s,time:Date.now()-r}})};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:s})}).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,s])=>e.append(t,'string'==typeof s?s:JSON.stringify(s)))),e}}class E{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 R{api;logger;config;subscription=new s;experimental;statContext;constructor(t,e){this.statContext=t,this.config={...e.config??{},requestRetryCount:1};const s=new r;this.experimental={error$:s};const i=new S({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:g[e.apiEnv],apiEnv:e.apiEnv,error$:s});this.api=new A({apiTransport:i,refreshAuthToken:e.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:s}),this.logger=new E({api:this.api,error$:s}),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()}logInited(){this.log({operation:'init'})}logReady(t){this.log({operation:'player_ready',param:String(t.time)})}logStarted(t){this.log({operation:'play',param:String(Math.round(t.position))})}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)})}logDownloadSpeed(t){this.log({operation:'download_speed',param:String(t.speed)})}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 s=Date.now(),r={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?p.AUTO:!1===this.statContext.autoplay?p.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode};return void 0!==e&&(r.param=e),{operation:t,timestamp:s,custom:r}}}export{n as ApiEnv,l as ConnectionType,c as ContentType,R as OneStat,h as Quality,u as ScreenDestination};
|
package/package.json
CHANGED