@vkontakte/videoplayer-statistics 1.0.103-dev.55dfadaf.0 → 1.0.103-dev.baccd7d5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es2015.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
- * @vkontakte/videoplayer-statistics v1.0.103-dev.55dfadaf.0
3
- * Wed, 25 Mar 2026 07:47:33 GMT
2
+ * @vkontakte/videoplayer-statistics v1.0.103-dev.baccd7d5.0
3
+ * Thu, 26 Mar 2026 07:38:58 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-103/doc/
5
5
  */
6
- import e from"@oxc-project/runtime/helpers/defineProperty";import t from"@oxc-project/runtime/helpers/objectSpread2";import n from"@oxc-project/runtime/helpers/asyncToGenerator";var r=Object.create,i=Object.getPrototypeOf,a=Object.defineProperty,o=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty;function c(e){return this[e]}var l,u,d=(e,t,n)=>{var d=typeof e==`object`&&!!e;if(d){var f=t?l??=new WeakMap:u??=new WeakMap,p=f.get(e);if(p)return p}n=e==null?{}:r(i(e));let m=t||!e||!e.__esModule?a(n,`default`,{value:e,enumerable:!0}):n;for(let t of o(e))s.call(m,t)||a(m,t,{get:c.bind(e,t),enumerable:!0});return d&&f.set(e,m),m},f=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),p=e=>e;function m(e,t){this[e]=p.bind(null,t)}var h=(e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0,configurable:!0,set:m.bind(t,n)})},g=f((e,t)=>{var n=function(e){return e&&e.Math===Math&&e};t.exports=n(typeof globalThis==`object`&&globalThis)||n(typeof window==`object`&&window)||n(typeof self==`object`&&self)||n(typeof global==`object`&&global)||n(typeof e==`object`&&e)||function(){return this}()||Function(`return this`)()}),_=f((e,t)=>{t.exports=function(e){try{return!!e()}catch{return!0}}}),v=f((e,t)=>{t.exports=!_()(function(){var e=function(){}.bind();return typeof e!=`function`||e.hasOwnProperty(`prototype`)})}),y=f((e,t)=>{var n=v(),r=Function.prototype,i=r.apply,a=r.call;t.exports=typeof Reflect==`object`&&Reflect.apply||(n?a.bind(i):function(){return a.apply(i,arguments)})}),b=f((e,t)=>{var n=v(),r=Function.prototype,i=r.call,a=n&&r.bind.bind(i,i);t.exports=n?a:function(e){return function(){return i.apply(e,arguments)}}}),x=f((e,t)=>{var n=b(),r=n({}.toString),i=n(``.slice);t.exports=function(e){return i(r(e),8,-1)}}),S=f((e,t)=>{var n=x(),r=b();t.exports=function(e){if(n(e)===`Function`)return r(e)}}),C=f((e,t)=>{var n=typeof document==`object`&&document.all;t.exports=n===void 0&&n!==void 0?function(e){return typeof e==`function`||e===n}:function(e){return typeof e==`function`}}),w=f((e,t)=>{t.exports=!_()(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})}),T=f((e,t)=>{var n=v(),r=Function.prototype.call;t.exports=n?r.bind(r):function(){return r.apply(r,arguments)}}),E=f(e=>{var t={}.propertyIsEnumerable,n=Object.getOwnPropertyDescriptor;e.f=n&&!t.call({1:2},1)?function(e){var t=n(this,e);return!!t&&t.enumerable}:t}),D=f((e,t)=>{t.exports=function(e,t){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:t}}}),O=f((e,t)=>{var n=b(),r=_(),i=x(),a=Object,o=n(``.split);t.exports=r(function(){return!a(`z`).propertyIsEnumerable(0)})?function(e){return i(e)===`String`?o(e,``):a(e)}:a}),k=f((e,t)=>{t.exports=function(e){return e==null}}),A=f((e,t)=>{var n=k(),r=TypeError;t.exports=function(e){if(n(e))throw new r(`Can't call method on `+e);return e}}),j=f((e,t)=>{var n=O(),r=A();t.exports=function(e){return n(r(e))}}),M=f((e,t)=>{var n=C();t.exports=function(e){return typeof e==`object`?e!==null:n(e)}}),N=f((e,t)=>{t.exports={}}),P=f((e,t)=>{var n=N(),r=g(),i=C(),a=function(e){return i(e)?e:void 0};t.exports=function(e,t){return arguments.length<2?a(n[e])||a(r[e]):n[e]&&n[e][t]||r[e]&&r[e][t]}}),F=f((e,t)=>{t.exports=b()({}.isPrototypeOf)}),I=f((e,t)=>{var n=g().navigator,r=n&&n.userAgent;t.exports=r?String(r):``}),ee=f((e,t)=>{var n=g(),r=I(),i=n.process,a=n.Deno,o=i&&i.versions||a&&a.version,s=o&&o.v8,c,l;s&&(c=s.split(`.`),l=c[0]>0&&c[0]<4?1:+(c[0]+c[1])),!l&&r&&(c=r.match(/Edge\/(\d+)/),(!c||c[1]>=74)&&(c=r.match(/Chrome\/(\d+)/),c&&(l=+c[1]))),t.exports=l}),te=f((e,t)=>{var n=ee(),r=_(),i=g().String;t.exports=!!Object.getOwnPropertySymbols&&!r(function(){var e=Symbol(`symbol detection`);return!i(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&n&&n<41})}),ne=f((e,t)=>{t.exports=te()&&!Symbol.sham&&typeof Symbol.iterator==`symbol`}),re=f((e,t)=>{var n=P(),r=C(),i=F(),a=ne(),o=Object;t.exports=a?function(e){return typeof e==`symbol`}:function(e){var t=n(`Symbol`);return r(t)&&i(t.prototype,o(e))}}),ie=f((e,t)=>{var n=String;t.exports=function(e){try{return n(e)}catch{return`Object`}}}),ae=f((e,t)=>{var n=C(),r=ie(),i=TypeError;t.exports=function(e){if(n(e))return e;throw new i(r(e)+` is not a function`)}}),oe=f((e,t)=>{var n=ae(),r=k();t.exports=function(e,t){var i=e[t];return r(i)?void 0:n(i)}}),se=f((e,t)=>{var n=T(),r=C(),i=M(),a=TypeError;t.exports=function(e,t){var o,s;if(t===`string`&&r(o=e.toString)&&!i(s=n(o,e))||r(o=e.valueOf)&&!i(s=n(o,e))||t!==`string`&&r(o=e.toString)&&!i(s=n(o,e)))return s;throw new a(`Can't convert object to primitive value`)}}),L=f((e,t)=>{t.exports=!0}),ce=f((e,t)=>{var n=g(),r=Object.defineProperty;t.exports=function(e,t){try{r(n,e,{value:t,configurable:!0,writable:!0})}catch{n[e]=t}return t}}),le=f((e,t)=>{var n=L(),r=g(),i=ce(),a=`__core-js_shared__`,o=t.exports=r[a]||i(a,{});(o.versions||=[]).push({version:`3.43.0`,mode:n?`pure`:`global`,copyright:`© 2014-2025 Denis Pushkarev (zloirock.ru)`,license:`https://github.com/zloirock/core-js/blob/v3.43.0/LICENSE`,source:`https://github.com/zloirock/core-js`})}),ue=f((e,t)=>{var n=le();t.exports=function(e,t){return n[e]||(n[e]=t||{})}}),de=f((e,t)=>{var n=A(),r=Object;t.exports=function(e){return r(n(e))}}),R=f((e,t)=>{var n=b(),r=de(),i=n({}.hasOwnProperty);t.exports=Object.hasOwn||function(e,t){return i(r(e),t)}}),fe=f((e,t)=>{var n=b(),r=0,i=Math.random(),a=n(1.1.toString);t.exports=function(e){return`Symbol(`+(e===void 0?``:e)+`)_`+a(++r+i,36)}}),z=f((e,t)=>{var n=g(),r=ue(),i=R(),a=fe(),o=te(),s=ne(),c=n.Symbol,l=r(`wks`),u=s?c.for||c:c&&c.withoutSetter||a;t.exports=function(e){return i(l,e)||(l[e]=o&&i(c,e)?c[e]:u(`Symbol.`+e)),l[e]}}),pe=f((e,t)=>{var n=T(),r=M(),i=re(),a=oe(),o=se(),s=z(),c=TypeError,l=s(`toPrimitive`);t.exports=function(e,t){if(!r(e)||i(e))return e;var s=a(e,l),u;if(s){if(t===void 0&&(t=`default`),u=n(s,e,t),!r(u)||i(u))return u;throw new c(`Can't convert object to primitive value`)}return t===void 0&&(t=`number`),o(e,t)}}),me=f((e,t)=>{var n=pe(),r=re();t.exports=function(e){var t=n(e,`string`);return r(t)?t:t+``}}),he=f((e,t)=>{var n=g(),r=M(),i=n.document,a=r(i)&&r(i.createElement);t.exports=function(e){return a?i.createElement(e):{}}}),ge=f((e,t)=>{var n=w(),r=_(),i=he();t.exports=!n&&!r(function(){return Object.defineProperty(i(`div`),`a`,{get:function(){return 7}}).a!==7})}),_e=f(e=>{var t=w(),n=T(),r=E(),i=D(),a=j(),o=me(),s=R(),c=ge(),l=Object.getOwnPropertyDescriptor;e.f=t?l:function(e,t){if(e=a(e),t=o(t),c)try{return l(e,t)}catch{}if(s(e,t))return i(!n(r.f,e,t),e[t])}}),ve=f((e,t)=>{var n=_(),r=C(),i=/#|\.prototype\./,a=function(e,t){var i=s[o(e)];return i===l?!0:i===c?!1:r(t)?n(t):!!t},o=a.normalize=function(e){return String(e).replace(i,`.`).toLowerCase()},s=a.data={},c=a.NATIVE=`N`,l=a.POLYFILL=`P`;t.exports=a}),ye=f((e,t)=>{var n=S(),r=ae(),i=v(),a=n(n.bind);t.exports=function(e,t){return r(e),t===void 0?e:i?a(e,t):function(){return e.apply(t,arguments)}}}),be=f((e,t)=>{var n=w(),r=_();t.exports=n&&r(function(){return Object.defineProperty(function(){},`prototype`,{value:42,writable:!1}).prototype!==42})}),B=f((e,t)=>{var n=M(),r=String,i=TypeError;t.exports=function(e){if(n(e))return e;throw new i(r(e)+` is not an object`)}}),V=f(e=>{var t=w(),n=ge(),r=be(),i=B(),a=me(),o=TypeError,s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=`enumerable`,u=`configurable`,d=`writable`;e.f=t?r?function(e,t,n){if(i(e),t=a(t),i(n),typeof e==`function`&&t===`prototype`&&`value`in n&&d in n&&!n[d]){var r=c(e,t);r&&r[d]&&(e[t]=n.value,n={configurable:u in n?n[u]:r[u],enumerable:l in n?n[l]:r[l],writable:!1})}return s(e,t,n)}:s:function(e,t,r){if(i(e),t=a(t),i(r),n)try{return s(e,t,r)}catch{}if(`get`in r||`set`in r)throw new o(`Accessors not supported`);return`value`in r&&(e[t]=r.value),e}}),xe=f((e,t)=>{var n=w(),r=V(),i=D();t.exports=n?function(e,t,n){return r.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}}),H=f((e,t)=>{var n=g(),r=y(),i=S(),a=C(),o=_e().f,s=ve(),c=N(),l=ye(),u=xe(),d=R();le();var f=function(e){var t=function(n,i,a){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(n);case 2:return new e(n,i)}return new e(n,i,a)}return r(e,this,arguments)};return t.prototype=e.prototype,t};t.exports=function(e,t){var r=e.target,p=e.global,m=e.stat,h=e.proto,g=p?n:m?n[r]:n[r]&&n[r].prototype,_=p?c:c[r]||u(c,r,{})[r],v=_.prototype,y,b,x,S,C,w,T,E,D;for(S in t)y=s(p?S:r+(m?`.`:`#`)+S,e.forced),b=!y&&g&&d(g,S),w=_[S],b&&(e.dontCallGetSet?(D=o(g,S),T=D&&D.value):T=g[S]),C=b&&T?T:t[S],!(!y&&!h&&typeof w==typeof C)&&(E=e.bind&&b?l(C,n):e.wrap&&b?f(C):h&&a(C)?i(C):C,(e.sham||C&&C.sham||w&&w.sham)&&u(E,`sham`,!0),u(_,S,E),h&&(x=r+`Prototype`,d(c,x)||u(c,x,{}),u(c[x],S,C),e.real&&v&&(y||!v[S])&&u(v,S,C)))}}),Se=f((e,t)=>{var n=Math.ceil,r=Math.floor;t.exports=Math.trunc||function(e){var t=+e;return(t>0?r:n)(t)}}),U=f((e,t)=>{var n=Se();t.exports=function(e){var t=+e;return t!==t||t===0?0:n(t)}}),Ce=f((e,t)=>{var n=U(),r=Math.max,i=Math.min;t.exports=function(e,t){var a=n(e);return a<0?r(a+t,0):i(a,t)}}),we=f((e,t)=>{var n=U(),r=Math.min;t.exports=function(e){var t=n(e);return t>0?r(t,9007199254740991):0}}),Te=f((e,t)=>{var n=we();t.exports=function(e){return n(e.length)}}),Ee=f((e,t)=>{var n=j(),r=Ce(),i=Te(),a=function(e){return function(t,a,o){var s=n(t),c=i(s);if(c===0)return!e&&-1;var l=r(o,c),u;if(e&&a!==a){for(;c>l;)if(u=s[l++],u!==u)return!0}else for(;c>l;l++)if((e||l in s)&&s[l]===a)return e||l||0;return!e&&-1}};t.exports={includes:a(!0),indexOf:a(!1)}}),De=f((e,t)=>{t.exports=function(){}}),Oe=f(()=>{var e=H(),t=Ee().includes,n=_(),r=De();e({target:`Array`,proto:!0,forced:n(function(){return![,].includes()})},{includes:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),r(`includes`)}),ke=f((e,t)=>{t.exports=P()}),Ae=f((e,t)=>{Oe(),t.exports=ke()(`Array`,`includes`)}),je=f((e,t)=>{t.exports=Ae()}),Me=f((e,t)=>{t.exports=je()}),Ne=f((e,t)=>{var n=z()(`toStringTag`),r={};r[n]=`z`,t.exports=String(r)===`[object z]`}),Pe=f((e,t)=>{var n=Ne(),r=C(),i=x(),a=z()(`toStringTag`),o=Object,s=i(function(){return arguments}())===`Arguments`,c=function(e,t){try{return e[t]}catch{}};t.exports=n?i:function(e){var t,n,l;return e===void 0?`Undefined`:e===null?`Null`:typeof(n=c(t=o(e),a))==`string`?n:s?i(t):(l=i(t))===`Object`&&r(t.callee)?`Arguments`:l}}),Fe=f((e,t)=>{var n=Pe(),r=String;t.exports=function(e){if(n(e)===`Symbol`)throw TypeError(`Cannot convert a Symbol value to a string`);return r(e)}}),Ie=f((e,t)=>{var n=U(),r=Fe(),i=A(),a=RangeError;t.exports=function(e){var t=r(i(this)),o=``,s=n(e);if(s<0||s===1/0)throw new a(`Wrong number of repetitions`);for(;s>0;(s>>>=1)&&(t+=t))s&1&&(o+=t);return o}}),Le=f((e,t)=>{var n=b(),r=we(),i=Fe(),a=Ie(),o=A(),s=n(a),c=n(``.slice),l=Math.ceil,u=function(e){return function(t,n,a){var u=i(o(t)),d=r(n),f=u.length,p=a===void 0?` `:i(a),m,h;return d<=f||p===``?u:(m=d-f,h=s(p,l(m/p.length)),h.length>m&&(h=c(h,0,m)),e?u+h:h+u)}};t.exports={start:u(!1),end:u(!0)}}),Re=f((e,t)=>{var n=I();t.exports=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(n)}),ze=f(()=>{var e=H(),t=Le().start;e({target:`String`,proto:!0,forced:Re()},{padStart:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})}),Be=f((e,t)=>{ze(),t.exports=ke()(`String`,`padStart`)}),Ve=f((e,t)=>{t.exports=Be()}),He=f((e,t)=>{t.exports=Ve()}),Ue=f((e,t)=>{var n=g(),r=I(),i=x(),a=function(e){return r.slice(0,e.length)===e};t.exports=function(){return a(`Bun/`)?`BUN`:a(`Cloudflare-Workers`)?`CLOUDFLARE`:a(`Deno/`)?`DENO`:a(`Node.js/`)?`NODE`:n.Bun&&typeof Bun.version==`string`?`BUN`:n.Deno&&typeof Deno.version==`object`?`DENO`:i(n.process)===`process`?`NODE`:n.window&&n.document?`BROWSER`:`REST`}()}),We=f((e,t)=>{t.exports=Ue()===`NODE`}),Ge=f((e,t)=>{var n=xe();t.exports=function(e,t,r,i){return i&&i.enumerable?e[t]=r:n(e,t,r),e}}),Ke=f((e,t)=>{var n=b(),r=ae();t.exports=function(e,t,i){try{return n(r(Object.getOwnPropertyDescriptor(e,t)[i]))}catch{}}}),qe=f((e,t)=>{var n=M();t.exports=function(e){return n(e)||e===null}}),Je=f((e,t)=>{var n=qe(),r=String,i=TypeError;t.exports=function(e){if(n(e))return e;throw new i(`Can't set `+r(e)+` as a prototype`)}}),Ye=f((e,t)=>{var n=Ke(),r=M(),i=A(),a=Je();t.exports=Object.setPrototypeOf||(`__proto__`in{}?function(){var e=!1,t={},o;try{o=n(Object.prototype,`__proto__`,`set`),o(t,[]),e=t instanceof Array}catch{}return function(t,n){return i(t),a(n),r(t)&&(e?o(t,n):t.__proto__=n),t}}():void 0)}),Xe=f((e,t)=>{var n=Ne(),r=Pe();t.exports=n?{}.toString:function(){return`[object `+r(this)+`]`}}),Ze=f((e,t)=>{var n=Ne(),r=V().f,i=xe(),a=R(),o=Xe(),s=z()(`toStringTag`);t.exports=function(e,t,c,l){var u=c?e:e&&e.prototype;u&&(a(u,s)||r(u,s,{configurable:!0,value:t}),l&&!n&&i(u,`toString`,o))}}),Qe=f((e,t)=>{var n=V();t.exports=function(e,t,r){return n.f(e,t,r)}}),$e=f((e,t)=>{var n=P(),r=Qe(),i=z(),a=w(),o=i(`species`);t.exports=function(e){var t=n(e);a&&t&&!t[o]&&r(t,o,{configurable:!0,get:function(){return this}})}}),et=f((e,t)=>{var n=F(),r=TypeError;t.exports=function(e,t){if(n(t,e))return e;throw new r(`Incorrect invocation`)}}),tt=f((e,t)=>{var n=b(),r=C(),i=le(),a=n(Function.toString);r(i.inspectSource)||(i.inspectSource=function(e){return a(e)}),t.exports=i.inspectSource}),nt=f((e,t)=>{var n=b(),r=_(),i=C(),a=Pe(),o=P(),s=tt(),c=function(){},l=o(`Reflect`,`construct`),u=/^\s*(?:class|function)\b/,d=n(u.exec),f=!u.test(c),p=function(e){if(!i(e))return!1;try{return l(c,[],e),!0}catch{return!1}},m=function(e){if(!i(e))return!1;switch(a(e)){case`AsyncFunction`:case`GeneratorFunction`:case`AsyncGeneratorFunction`:return!1}try{return f||!!d(u,s(e))}catch{return!0}};m.sham=!0,t.exports=!l||r(function(){var e;return p(p.call)||!p(Object)||!p(function(){e=!0})||e})?m:p}),rt=f((e,t)=>{var n=nt(),r=ie(),i=TypeError;t.exports=function(e){if(n(e))return e;throw new i(r(e)+` is not a constructor`)}}),it=f((e,t)=>{var n=B(),r=rt(),i=k(),a=z()(`species`);t.exports=function(e,t){var o=n(e).constructor,s;return o===void 0||i(s=n(o)[a])?t:r(s)}}),at=f((e,t)=>{t.exports=P()(`document`,`documentElement`)}),ot=f((e,t)=>{t.exports=b()([].slice)}),st=f((e,t)=>{var n=TypeError;t.exports=function(e,t){if(e<t)throw new n(`Not enough arguments`);return e}}),ct=f((e,t)=>{var n=I();t.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(n)}),lt=f((e,t)=>{var n=g(),r=y(),i=ye(),a=C(),o=R(),s=_(),c=at(),l=ot(),u=he(),d=st(),f=ct(),p=We(),m=n.setImmediate,h=n.clearImmediate,v=n.process,b=n.Dispatch,x=n.Function,S=n.MessageChannel,w=n.String,T=0,E={},D=`onreadystatechange`,O,k,A,j;s(function(){O=n.location});var M=function(e){if(o(E,e)){var t=E[e];delete E[e],t()}},N=function(e){return function(){M(e)}},P=function(e){M(e.data)},F=function(e){n.postMessage(w(e),O.protocol+`//`+O.host)};(!m||!h)&&(m=function(e){d(arguments.length,1);var t=a(e)?e:x(e),n=l(arguments,1);return E[++T]=function(){r(t,void 0,n)},k(T),T},h=function(e){delete E[e]},p?k=function(e){v.nextTick(N(e))}:b&&b.now?k=function(e){b.now(N(e))}:S&&!f?(A=new S,j=A.port2,A.port1.onmessage=P,k=i(j.postMessage,j)):n.addEventListener&&a(n.postMessage)&&!n.importScripts&&O&&O.protocol!==`file:`&&!s(F)?(k=F,n.addEventListener(`message`,P,!1)):k=D in u(`script`)?function(e){c.appendChild(u(`script`))[D]=function(){c.removeChild(this),M(e)}}:function(e){setTimeout(N(e),0)}),t.exports={set:m,clear:h}}),ut=f((e,t)=>{var n=g(),r=w(),i=Object.getOwnPropertyDescriptor;t.exports=function(e){if(!r)return n[e];var t=i(n,e);return t&&t.value}}),dt=f((e,t)=>{var n=function(){this.head=null,this.tail=null};n.prototype={add:function(e){var t={item:e,next:null},n=this.tail;n?n.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return(this.head=e.next)===null&&(this.tail=null),e.item}},t.exports=n}),ft=f((e,t)=>{var n=I();t.exports=/ipad|iphone|ipod/i.test(n)&&typeof Pebble<`u`}),pt=f((e,t)=>{var n=I();t.exports=/web0s(?!.*chrome)/i.test(n)}),mt=f((e,t)=>{var n=g(),r=ut(),i=ye(),a=lt().set,o=dt(),s=ct(),c=ft(),l=pt(),u=We(),d=n.MutationObserver||n.WebKitMutationObserver,f=n.document,p=n.process,m=n.Promise,h=r(`queueMicrotask`),_,v,y,b,x;h||=(S=new o,C=function(){var e,t;for(u&&(e=p.domain)&&e.exit();t=S.get();)try{t()}catch(e){throw S.head&&_(),e}e&&e.enter()},!s&&!u&&!l&&d&&f?(v=!0,y=f.createTextNode(``),new d(C).observe(y,{characterData:!0}),_=function(){y.data=v=!v}):!c&&m&&m.resolve?(b=m.resolve(void 0),b.constructor=m,x=i(b.then,b),_=function(){x(C)}):u?_=function(){p.nextTick(C)}:(a=i(a,n),_=function(){a(C)}),function(e){S.head||_(),S.add(e)});var S,C;t.exports=h}),ht=f((e,t)=>{t.exports=function(e,t){try{arguments.length===1?console.error(e):console.error(e,t)}catch{}}}),gt=f((e,t)=>{t.exports=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}}}),_t=f((e,t)=>{var n=g(),r=C(),i=n.WeakMap;t.exports=r(i)&&/native code/.test(String(i))}),vt=f((e,t)=>{var n=ue(),r=fe(),i=n(`keys`);t.exports=function(e){return i[e]||(i[e]=r(e))}}),yt=f((e,t)=>{t.exports={}}),bt=f((e,t)=>{var n=_t(),r=g(),i=M(),a=xe(),o=R(),s=le(),c=vt(),l=yt(),u=`Object already initialized`,d=r.TypeError,f=r.WeakMap,p,m,h,_=function(e){return h(e)?m(e):p(e,{})},v=function(e){return function(t){var n;if(!i(t)||(n=m(t)).type!==e)throw new d(`Incompatible receiver, `+e+` required`);return n}};n||s.state?(y=s.state||=new f,y.get=y.get,y.has=y.has,y.set=y.set,p=function(e,t){if(y.has(e))throw new d(u);return t.facade=e,y.set(e,t),t},m=function(e){return y.get(e)||{}},h=function(e){return y.has(e)}):(b=c(`state`),l[b]=!0,p=function(e,t){if(o(e,b))throw new d(u);return t.facade=e,a(e,b,t),t},m=function(e){return o(e,b)?e[b]:{}},h=function(e){return o(e,b)});var y,b;t.exports={set:p,get:m,has:h,enforce:_,getterFor:v}}),xt=f((e,t)=>{t.exports=g().Promise}),St=f((e,t)=>{var n=g(),r=xt(),i=C(),a=ve(),o=tt(),s=z(),c=Ue(),l=L(),u=ee(),d=r&&r.prototype,f=s(`species`),p=!1,m=i(n.PromiseRejectionEvent);t.exports={CONSTRUCTOR:a(`Promise`,function(){var e=o(r),t=e!==String(r);if(!t&&u===66||l&&!(d.catch&&d.finally))return!0;if(!u||u<51||!/native code/.test(e)){var n=new r(function(e){e(1)}),i=function(e){e(function(){},function(){})},a=n.constructor={};if(a[f]=i,p=n.then(function(){})instanceof i,!p)return!0}return!t&&(c===`BROWSER`||c===`DENO`)&&!m}),REJECTION_EVENT:m,SUBCLASSING:p}}),Ct=f((e,t)=>{var n=ae(),r=TypeError,i=function(e){var t,i;this.promise=new e(function(e,n){if(t!==void 0||i!==void 0)throw new r(`Bad Promise constructor`);t=e,i=n}),this.resolve=n(t),this.reject=n(i)};e.f=function(e){return new i(e)}}),wt=f(()=>{var e=H(),t=L(),n=We(),r=g(),i=N(),a=T(),o=Ge(),s=Ye(),c=Ze(),l=$e(),u=ae(),d=C(),f=M(),p=et(),m=it(),h=lt().set,_=mt(),v=ht(),y=gt(),b=dt(),x=bt(),S=xt(),w=St(),E=Ct(),D=`Promise`,O=w.CONSTRUCTOR,k=w.REJECTION_EVENT,A=w.SUBCLASSING,j=x.getterFor(D),P=x.set,F=S&&S.prototype,I=S,ee=F,te=r.TypeError,ne=r.document,re=r.process,ie=E.f,oe=ie,se=!!(ne&&ne.createEvent&&r.dispatchEvent),ce=`unhandledrejection`,le=`rejectionhandled`,ue=0,de=1,R=2,fe=1,z=2,pe,me,he,ge,_e=function(e){var t;return f(e)&&d(t=e.then)?t:!1},ve=function(e,t){var n=t.value,r=t.state===de,i=r?e.ok:e.fail,o=e.resolve,s=e.reject,c=e.domain,l,u,d;try{i?(r||(t.rejection===z&&xe(t),t.rejection=fe),i===!0?l=n:(c&&c.enter(),l=i(n),c&&(c.exit(),d=!0)),l===e.promise?s(new te(`Promise-chain cycle`)):(u=_e(l))?a(u,l,o,s):o(l)):s(n)}catch(e){c&&!d&&c.exit(),s(e)}},ye=function(e,t){e.notified||(e.notified=!0,_(function(){for(var n=e.reactions,r;r=n.get();)ve(r,e);e.notified=!1,t&&!e.rejection&&B(e)}))},be=function(e,t,n){var i,a;se?(i=ne.createEvent(`Event`),i.promise=t,i.reason=n,i.initEvent(e,!1,!0),r.dispatchEvent(i)):i={promise:t,reason:n},!k&&(a=r[`on`+e])?a(i):e===ce&&v(`Unhandled promise rejection`,n)},B=function(e){a(h,r,function(){var t=e.facade,r=e.value,i=V(e),a;if(i&&(a=y(function(){n?re.emit(`unhandledRejection`,r,t):be(ce,t,r)}),e.rejection=n||V(e)?z:fe,a.error))throw a.value})},V=function(e){return e.rejection!==fe&&!e.parent},xe=function(e){a(h,r,function(){var t=e.facade;n?re.emit(`rejectionHandled`,t):be(le,t,e.value)})},Se=function(e,t,n){return function(r){e(t,r,n)}},U=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=R,ye(e,!0))},Ce=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw new te(`Promise can't be resolved itself`);var r=_e(t);r?_(function(){var n={done:!1};try{a(r,t,Se(Ce,n,e),Se(U,n,e))}catch(t){U(n,t,e)}}):(e.value=t,e.state=de,ye(e,!1))}catch(t){U({done:!1},t,e)}}};if(O&&(I=function(e){p(this,ee),u(e),a(pe,this);var t=j(this);try{e(Se(Ce,t),Se(U,t))}catch(e){U(t,e)}},ee=I.prototype,pe=function(e){P(this,{type:D,done:!1,notified:!1,parent:!1,reactions:new b,rejection:!1,state:ue,value:null})},pe.prototype=o(ee,`then`,function(e,t){var r=j(this),i=ie(m(this,I));return r.parent=!0,i.ok=d(e)?e:!0,i.fail=d(t)&&t,i.domain=n?re.domain:void 0,r.state===ue?r.reactions.add(i):_(function(){ve(i,r)}),i.promise}),me=function(){var e=new pe,t=j(e);this.promise=e,this.resolve=Se(Ce,t),this.reject=Se(U,t)},E.f=ie=function(e){return e===I||e===he?new me(e):oe(e)},!t&&d(S)&&F!==Object.prototype)){ge=F.then,A||o(F,`then`,function(e,t){var n=this;return new I(function(e,t){a(ge,n,e,t)}).then(e,t)},{unsafe:!0});try{delete F.constructor}catch{}s&&s(F,ee)}e({global:!0,constructor:!0,wrap:!0,forced:O},{Promise:I}),he=i.Promise,c(I,D,!1,!0),l(D)}),Tt=f((e,t)=>{t.exports={}}),Et=f((e,t)=>{var n=z(),r=Tt(),i=n(`iterator`),a=Array.prototype;t.exports=function(e){return e!==void 0&&(r.Array===e||a[i]===e)}}),Dt=f((e,t)=>{var n=Pe(),r=oe(),i=k(),a=Tt(),o=z()(`iterator`);t.exports=function(e){if(!i(e))return r(e,o)||r(e,`@@iterator`)||a[n(e)]}}),Ot=f((e,t)=>{var n=T(),r=ae(),i=B(),a=ie(),o=Dt(),s=TypeError;t.exports=function(e,t){var c=arguments.length<2?o(e):t;if(r(c))return i(n(c,e));throw new s(a(e)+` is not iterable`)}}),kt=f((e,t)=>{var n=T(),r=B(),i=oe();t.exports=function(e,t,a){var o,s;r(e);try{if(o=i(e,`return`),!o){if(t===`throw`)throw a;return a}o=n(o,e)}catch(e){s=!0,o=e}if(t===`throw`)throw a;if(s)throw o;return r(o),a}}),At=f((e,t)=>{var n=ye(),r=T(),i=B(),a=ie(),o=Et(),s=Te(),c=F(),l=Ot(),u=Dt(),d=kt(),f=TypeError,p=function(e,t){this.stopped=e,this.result=t},m=p.prototype;t.exports=function(e,t,h){var g=h&&h.that,_=!!(h&&h.AS_ENTRIES),v=!!(h&&h.IS_RECORD),y=!!(h&&h.IS_ITERATOR),b=!!(h&&h.INTERRUPTED),x=n(t,g),S,C,w,T,E,D,O,k=function(e){return S&&d(S,`normal`),new p(!0,e)},A=function(e){return _?(i(e),b?x(e[0],e[1],k):x(e[0],e[1])):b?x(e,k):x(e)};if(v)S=e.iterator;else if(y)S=e;else{if(C=u(e),!C)throw new f(a(e)+` is not iterable`);if(o(C)){for(w=0,T=s(e);T>w;w++)if(E=A(e[w]),E&&c(m,E))return E;return new p(!1)}S=l(e,C)}for(D=v?e.next:S.next;!(O=r(D,S)).done;){try{E=A(O.value)}catch(e){d(S,`throw`,e)}if(typeof E==`object`&&E&&c(m,E))return E}return new p(!1)}}),jt=f((e,t)=>{var n=z()(`iterator`),r=!1;try{i=0,a={next:function(){return{done:!!i++}},return:function(){r=!0}},a[n]=function(){return this},Array.from(a,function(){throw 2})}catch{}var i,a;t.exports=function(e,t){try{if(!t&&!r)return!1}catch{return!1}var i=!1;try{var a={};a[n]=function(){return{next:function(){return{done:i=!0}}}},e(a)}catch{}return i}}),Mt=f((e,t)=>{var n=xt(),r=jt();t.exports=St().CONSTRUCTOR||!r(function(e){n.all(e).then(void 0,function(){})})}),Nt=f(()=>{var e=H(),t=T(),n=ae(),r=Ct(),i=gt(),a=At();e({target:`Promise`,stat:!0,forced:Mt()},{all:function(e){var o=this,s=r.f(o),c=s.resolve,l=s.reject,u=i(function(){var r=n(o.resolve),i=[],s=0,u=1;a(e,function(e){var n=s++,a=!1;u++,t(r,o,e).then(function(e){a||(a=!0,i[n]=e,--u||c(i))},l)}),--u||c(i)});return u.error&&l(u.value),s.promise}})}),Pt=f(()=>{var e=H(),t=L(),n=St().CONSTRUCTOR,r=xt(),i=P(),a=C(),o=Ge(),s=r&&r.prototype;e({target:`Promise`,proto:!0,forced:n,real:!0},{catch:function(e){return this.then(void 0,e)}}),!t&&a(r)&&(c=i(`Promise`).prototype.catch,s.catch!==c&&o(s,`catch`,c,{unsafe:!0}));var c}),Ft=f(()=>{var e=H(),t=T(),n=ae(),r=Ct(),i=gt(),a=At();e({target:`Promise`,stat:!0,forced:Mt()},{race:function(e){var o=this,s=r.f(o),c=s.reject,l=i(function(){var r=n(o.resolve);a(e,function(e){t(r,o,e).then(s.resolve,c)})});return l.error&&c(l.value),s.promise}})}),It=f(()=>{var e=H(),t=Ct(),n=St().CONSTRUCTOR;e({target:`Promise`,stat:!0,forced:n},{reject:function(e){var n=t.f(this),r=n.reject;return r(e),n.promise}})}),Lt=f((e,t)=>{var n=B(),r=M(),i=Ct();t.exports=function(e,t){if(n(e),r(t)&&t.constructor===e)return t;var a=i.f(e),o=a.resolve;return o(t),a.promise}}),Rt=f(()=>{var e=H(),t=P(),n=L(),r=xt(),i=St().CONSTRUCTOR,a=Lt(),o=t(`Promise`),s=n&&!i;e({target:`Promise`,stat:!0,forced:n||i},{resolve:function(e){return a(s&&this===o?r:this,e)}})}),zt=f(()=>{wt(),Nt(),Pt(),Ft(),It(),Rt()}),Bt=f(()=>{var e=H(),t=L(),n=xt(),r=_(),i=P(),a=C(),o=it(),s=Lt(),c=Ge(),l=n&&n.prototype;e({target:`Promise`,proto:!0,real:!0,forced:!!n&&r(function(){l.finally.call({then:function(){}},function(){})})},{finally:function(e){var t=o(this,i(`Promise`)),n=a(e);return this.then(n?function(n){return s(t,e()).then(function(){return n})}:e,n?function(n){return s(t,e()).then(function(){throw n})}:e)}}),!t&&a(n)&&(u=i(`Promise`).prototype.finally,l.finally!==u&&c(l,`finally`,u,{unsafe:!0}));var u}),Vt=f((e,t)=>{zt(),Bt(),t.exports=ke()(`Promise`,`finally`)}),Ht=f((e,t)=>{t.exports=Vt()}),Ut=f((e,t)=>{t.exports=Ht()}),Wt=f((e,t)=>{t.exports=!_()(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})}),Gt=f((e,t)=>{var n=R(),r=C(),i=de(),a=vt(),o=Wt(),s=a(`IE_PROTO`),c=Object,l=c.prototype;t.exports=o?c.getPrototypeOf:function(e){var t=i(e);if(n(t,s))return t[s];var a=t.constructor;return r(a)&&t instanceof a?a.prototype:t instanceof c?l:null}}),Kt=f((e,t)=>{var n=b(),r=R(),i=j(),a=Ee().indexOf,o=yt(),s=n([].push);t.exports=function(e,t){var n=i(e),c=0,l=[],u;for(u in n)!r(o,u)&&r(n,u)&&s(l,u);for(;t.length>c;)r(n,u=t[c++])&&(~a(l,u)||s(l,u));return l}}),qt=f((e,t)=>{t.exports=[`constructor`,`hasOwnProperty`,`isPrototypeOf`,`propertyIsEnumerable`,`toLocaleString`,`toString`,`valueOf`]}),Jt=f((e,t)=>{var n=Kt(),r=qt();t.exports=Object.keys||function(e){return n(e,r)}}),Yt=f((e,t)=>{var n=w(),r=_(),i=b(),a=Gt(),o=Jt(),s=j(),c=E().f,l=i(c),u=i([].push),d=n&&r(function(){var e=Object.create(null);return e[2]=2,!l(e,2)}),f=function(e){return function(t){for(var r=s(t),i=o(r),c=d&&a(r)===null,f=i.length,p=0,m=[],h;f>p;)h=i[p++],(!n||(c?h in r:l(r,h)))&&u(m,e?[h,r[h]]:r[h]);return m}};t.exports={entries:f(!0),values:f(!1)}}),Xt=f(()=>{var e=H(),t=Yt().entries;e({target:`Object`,stat:!0},{entries:function(e){return t(e)}})}),Zt=f((e,t)=>{Xt(),t.exports=N().Object.entries}),Qt=f((e,t)=>{t.exports=Zt()}),$t=f((e,t)=>{t.exports=Qt()}),en=f((e,t)=>{var n=w(),r=R(),i=Function.prototype,a=n&&Object.getOwnPropertyDescriptor,o=r(i,`name`);t.exports={EXISTS:o,PROPER:o&&function(){}.name===`something`,CONFIGURABLE:o&&(!n||n&&a(i,`name`).configurable)}}),tn=f(e=>{var t=w(),n=be(),r=V(),i=B(),a=j(),o=Jt();e.f=t&&!n?Object.defineProperties:function(e,t){i(e);for(var n=a(t),s=o(t),c=s.length,l=0,u;c>l;)r.f(e,u=s[l++],n[u]);return e}}),nn=f((e,t)=>{var n=B(),r=tn(),i=qt(),a=yt(),o=at(),s=he(),c=vt(),l=`>`,u=`<`,d=`prototype`,f=`script`,p=c(`IE_PROTO`),m=function(){},h=function(e){return u+f+l+e+u+`/`+f+l},g=function(e){e.write(h(``)),e.close();var t=e.parentWindow.Object;return e=null,t},_=function(){var e=s(`iframe`),t=`java`+f+`:`,n;return e.style.display=`none`,o.appendChild(e),e.src=String(t),n=e.contentWindow.document,n.open(),n.write(h(`document.F=Object`)),n.close(),n.F},v,y=function(){try{v=new ActiveXObject(`htmlfile`)}catch{}y=typeof document<`u`?document.domain&&v?g(v):_():g(v);for(var e=i.length;e--;)delete y[d][i[e]];return y()};a[p]=!0,t.exports=Object.create||function(e,t){var i;return e===null?i=y():(m[d]=n(e),i=new m,m[d]=null,i[p]=e),t===void 0?i:r.f(i,t)}}),rn=f((e,t)=>{var n=_(),r=C(),i=M(),a=nn(),o=Gt(),s=Ge(),c=z(),l=L(),u=c(`iterator`),d=!1,f,p,m;[].keys&&(m=[].keys(),`next`in m?(p=o(o(m)),p!==Object.prototype&&(f=p)):d=!0),!i(f)||n(function(){var e={};return f[u].call(e)!==e})?f={}:l&&(f=a(f)),r(f[u])||s(f,u,function(){return this}),t.exports={IteratorPrototype:f,BUGGY_SAFARI_ITERATORS:d}}),an=f((e,t)=>{var n=rn().IteratorPrototype,r=nn(),i=D(),a=Ze(),o=Tt(),s=function(){return this};t.exports=function(e,t,c,l){var u=t+` Iterator`;return e.prototype=r(n,{next:i(+!l,c)}),a(e,u,!1,!0),o[u]=s,e}}),on=f((e,t)=>{var n=H(),r=T(),i=L(),a=en(),o=C(),s=an(),c=Gt(),l=Ye(),u=Ze(),d=xe(),f=Ge(),p=z(),m=Tt(),h=rn(),g=a.PROPER,_=a.CONFIGURABLE,v=h.IteratorPrototype,y=h.BUGGY_SAFARI_ITERATORS,b=p(`iterator`),x=`keys`,S=`values`,w=`entries`,E=function(){return this};t.exports=function(e,t,a,p,h,C,T){s(a,t,p);var D=function(e){if(e===h&&M)return M;if(!y&&e&&e in A)return A[e];switch(e){case x:return function(){return new a(this,e)};case S:return function(){return new a(this,e)};case w:return function(){return new a(this,e)}}return function(){return new a(this)}},O=t+` Iterator`,k=!1,A=e.prototype,j=A[b]||A[`@@iterator`]||h&&A[h],M=!y&&j||D(h),N=t===`Array`&&A.entries||j,P,F,I;if(N&&(P=c(N.call(new e)),P!==Object.prototype&&P.next&&(!i&&c(P)!==v&&(l?l(P,v):o(P[b])||f(P,b,E)),u(P,O,!0,!0),i&&(m[O]=E))),g&&h===S&&j&&j.name!==S&&(!i&&_?d(A,`name`,S):(k=!0,M=function(){return r(j,this)})),h)if(F={values:D(S),keys:C?M:D(x),entries:D(w)},T)for(I in F)(y||k||!(I in A))&&f(A,I,F[I]);else n({target:t,proto:!0,forced:y||k},F);return(!i||T)&&A[b]!==M&&f(A,b,M,{name:h}),m[t]=M,F}}),sn=f((e,t)=>{t.exports=function(e,t){return{value:e,done:t}}}),cn=f((e,t)=>{var n=j(),r=De(),i=Tt(),a=bt(),o=V().f,s=on(),c=sn(),l=L(),u=w(),d=`Array Iterator`,f=a.set,p=a.getterFor(d);t.exports=s(Array,`Array`,function(e,t){f(this,{type:d,target:n(e),index:0,kind:t})},function(){var e=p(this),t=e.target,n=e.index++;if(!t||n>=t.length)return e.target=null,c(void 0,!0);switch(e.kind){case`keys`:return c(n,!1);case`values`:return c(t[n],!1)}return c([n,t[n]],!1)},`values`);var m=i.Arguments=i.Array;if(r(`keys`),r(`values`),r(`entries`),!l&&u&&m.name!==`values`)try{o(m,`name`,{value:`values`})}catch{}}),ln=f((e,t)=>{var n=w(),r=V(),i=D();t.exports=function(e,t,a){n?r.f(e,t,i(0,a)):e[t]=a}}),un=f(()=>{var e=H(),t=At(),n=ln();e({target:`Object`,stat:!0},{fromEntries:function(e){var r={};return t(e,function(e,t){n(r,e,t)},{AS_ENTRIES:!0}),r}})}),dn=f((e,t)=>{cn(),un(),t.exports=N().Object.fromEntries}),fn=f((e,t)=>{t.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}}),pn=f(()=>{cn();var e=fn(),t=g(),n=Ze(),r=Tt();for(i in e)n(t[i],i),r[i]=r.Array;var i}),mn=f((e,t)=>{var n=dn();pn(),t.exports=n}),hn=f((e,t)=>{t.exports=mn()}),gn=f(()=>{var e=H(),t=Yt().values;e({target:`Object`,stat:!0},{values:function(e){return t(e)}})}),_n=f((e,t)=>{gn(),t.exports=N().Object.values}),vn=f((e,t)=>{t.exports=_n()}),yn=f((e,t)=>{t.exports=vn()}),bn=d(Me(),1),xn=(e,...t)=>typeof e==`string`?e.includes(...t):bn.default(e,...t),Sn=(e,t,n)=>{if(typeof e.canParse==`function`)return e.canParse(t,n);try{return new e(t,n),!0}catch{return!1}},Cn;(e=>{e.PROD=`prod`,e.VK_ALIAS=`vk_alias`,e.VIDEOTEST=`videotest`,e.TEST=`test`,e.OKCDN=`okcdn`,e.AUTO=`auto`})(Cn||={});var wn;(e=>{e.Q144P=`mobile`,e.Q240P=`lowest`,e.Q360P=`low`,e.Q480P=`medium`,e.Q720P=`high`,e.Q1080P=`fullhd`,e.Q1440P=`quadhd`,e.Q2160P=`ultrahd`,e.UNKNOWN=`unknown`})(wn||={});var Tn;(e=>{e.MP4=`mp4`,e.DASH=`dash`,e.DASH_SEP=`dash_sep`,e.ONDEMAND_DASH=`ondemand_dash`,e.HLS=`hls`,e.HLS_FMP4=`hls_fmp4`,e.ONDEMAND_HLS=`ondemand_hls`,e.WEBM=`webm`,e.AV1=`av1`,e.ONDEMAND_DASH_LIVE=`ondemand_dash_live`,e.ONDEMAND_HLS_LIVE=`ondemand_hls_live`,e.WEBRTC=`webrtc`,e.UNKNOWN=`unknown`,e.RTMP=`rtmp`})(Tn||={});var En;(e=>{e.HTTP1=`http1`,e.HTTP2=`http2`,e.HTTP3=`http3`})(En||={});var Dn;(e=>{e.SLIDER=`slider`,e.RICH=`rich`,e.DOUBLE_TAP=`double_tap`,e.TIME_CODE=`time_code`,e.EPISODE=`episode`,e.REWIND=`rewind`,e.LIVE=`live`,e.UNKNOWN=`unknown`})(Dn||={});var On;(e=>{e.GRAPH_SHOW=`iGraphShow`,e.GRAPH_HIDE=`iGraphHide`,e.NEXT_AREA=`iNextChapterArea`,e.NEXT_BUTTON=`iNextChapterBtn`,e.WATCH_AGAIN=`iWatchAgainBtn`})(On||={});var kn={action_play:`ap`,action_play_interactive:`api`,first_bytes:`fb`,player_ready:`pr`,first_frame:`ff`,seek:`sk`,watch_coverage_record:`wr`,watch_coverage_live:`wl`,empty_buffer:`eb`,action_stop:`as`,close_at_empty_buffer:`cb`,content_error:`er`,player_interface_click:`pc`,next_movie:`nm`,track_switch:`ts`,failover:`fo`,quality:`qt`},An={vsid:`si`,isid:`is`,vid:`vi`,place:`pl`,quality:`qt`,cdn_host:`ch`,stat_type:`st`,param:`pm`,vk_app_id:`va`,track_code:`tc`,connection_type:`cnt`,connection_reused:`cr`,cached_data:`cd`,live:`lv`,muted:`mu`,mode:`mo`,subtitles:`sb`,failover:`fo`,download_speed:`ds`,manual_quality:`mq`,ref_domain:`rd`,direct_url:`du`},jn={unknown:`un`,mobile:`m`,lowest:`ls`,low:`l`,medium:`md`,high:`h`,fullhd:`f`,quadhd:`q`,ultrahd:`u`},Mn={pip:`pi`,fullscreen:`fs`,external:`ex`,prefetch:`pr`,airplay:`ap`,chromecast:`cc`,invisible:`iv`,minimal:`minimal`};import{fillWithDefault as Nn}from"@vkontakte/videoplayer-shared/es2015";var Pn=`CIOPGQJGDIHBABABA`,Fn={prod:`https://api.ok.ru`,vk_alias:`https://api.mycdn.me`,videotest:`https://videotestapi.ok.ru/api`,test:`https://apitest.ok.ru`,okcdn:`https://api.okcdn.ru`,auto:``},In={apiEnv:`vk_alias`,apiKey:Pn,apiBaseUrl:null,requestRetryCount:1,useVsid64:!1,firstFlushTime:5e3,flushDebounceTime:1e4,flushMaxWait:6e4,storageExpiration:2160*60*1e3,watchCoverageInterval:15e3,disabledOperations:[`quality`],disabledCustomFields:[],shorten:!0,maxLoops:100,embedUrlParams:[],useBeacon:!0,synchronizeTime:!0,debugLog:!1,clearStorageAtUnload:!0,useVKComIsMobileLogic:!1,backoff:{start:1e3,factor:1.5,max:300*1e3,random:.1},useKeepalive:!1,watchCoverageTimeoutFix:!1},Ln=e=>Nn(e,In);function Rn(){let e=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`.split(``),t=Array(36),n=0,r,i;for(i=0;i<36;i++)i===8||i===13||i===18||i===23?t[i]=`-`:i===14?t[i]=`4`:(n<=2&&(n=33554432+Math.random()*16777216|0),r=n&15,n>>=4,t[i]=e[i===19?r&3|8:r]);return t.join(``)}import{assertNonNullable as zn,combine as Bn,fromEvent as Vn,isNonNullable as Hn,isNullable as Un,merge as Wn,now as W,observableFrom as Gn,once as Kn,safeStorage as qn,Subject as Jn,Subscription as Yn,ValueSubject as Xn}from"@vkontakte/videoplayer-shared/es2015";import{Logger as Zn,detectEmbed as Qn}from"@vkontakte/videoplayer-shared/es2015";var $n=d(He(),1),er=()=>$n.default(Math.floor(Math.random()*2**32).toString(36),13,`0`),tr=()=>$n.default(Math.floor(Math.random()*2**64).toString(36),13,`0`);class nr{static getVSID(){return nr.vsid}static generateVSID(e){return nr.vsid=e?tr():er(),nr.vsid}}e(nr,`vsid`,void 0);var rr=d(Ut(),1),ir=d($t(),1),ar=d(hn(),1),or=e=>{let{operation:n,custom:r}=e,i=ar.default(ir.default(r).map(([e,t])=>{let n=An[e]??e,r=t;return t&&(e===`mode`?r=Mn[t]??t:e===`quality`&&(r=jn[t]??t)),[n,r]}));return t(t({},e),{},{operation:kn[n]??n,custom:i})},sr=`1.0.103-dev.55dfadaf.0`;import{ValueSubject as cr,getExponentialDelay as lr,ErrorCategory as ur}from"@vkontakte/videoplayer-shared/es2015";var dr=/Mobile|mini|Fennec|Android|iP(ad|od|hone)|opera (mini|mobi)/i;class fr{constructor(t){e(this,`params`,void 0),e(this,`authToken`,void 0),e(this,`sessionKey`,void 0),e(this,`authorizePromise`,void 0),e(this,`refreshAuthTokenPromise`,void 0),e(this,`consequentAuthErrors`,0),e(this,`authorized$`,new cr(!1)),e(this,`backoffTimeoutId`,void 0),this.params=t}authorize(e){var t=this;return n(function*(){return t.authToken=e??(yield t.refreshAuthToken()),t._authorizeWithBackoff()})()}logBeacon(e){let t=this.createLogParams(e),n=this.sessionKey;n&&(this.params.apiTransport.sendBeacon(`log.externalLog`,t,n)||this.logRequest(e).catch(()=>{}))}logRequest(e){var t=this;return n(function*(){let r=`log.externalLog`,i=t.createLogParams(e),a=t.sessionKey??(yield t._authorizeWithBackoff());if(!a)return;let o=function(){var e=n(function*(e,n=t.params.config.requestRetryCount){try{return yield t.params.apiTransport.sendRequest(r,i,a)}catch(i){if(!i||!(`error_code`in i)){t.params.error$.next({id:`logRequestUnknown`,category:ur.NETWORK,message:`Unknown ${r} error`,thrown:i});return}let a=i?.error_code;switch(a){case 102:case 103:case 104:return t.authorized$.next(!1),t.sessionKey=yield t._authorizeWithBackoff(),n>0?o(e,n-1):void 0;case 401:return t.authorized$.next(!1),t.authToken=yield t.refreshAuthToken(),t.sessionKey=yield t._authorizeWithBackoff(),n>0?o(e,n-1):void 0;default:t.params.error$.next({id:`LogRequest#${a}`,category:ur.EXTERNAL_API,message:`${r} error`,data:i});return}}});return function(t){return e.apply(this,arguments)}}();return o(e)})()}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}refreshAuthToken(){var e=this;return n(function*(){if(e.params.refreshAuthToken)return e.refreshAuthTokenPromise||=rr.default(e.params.refreshAuthToken(),()=>{e.refreshAuthTokenPromise=void 0}),e.refreshAuthTokenPromise})()}createLogParams(e){let t=`WEB`,n=!1,r=`@vkontakte/videoplayer-statistics:${sr}`;if(this.params.config.useVKComIsMobileLogic){let{appVersion:e}=window.navigator;n=dr.test(e)}else this.params.mobile&&(n=!0);return n&&(t=`M_WEB`),this.params.vktvVersion&&(t=`SMART_TV`,r=this.params.vktvVersion),{collector:`ok.mobile.apps.video`,data:JSON.stringify({application:r,platform:t,items:this.params.config.shorten?e.map(or):e})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();let e=lr(this.consequentAuthErrors,this.params.config.backoff);return new Promise(t=>{this.backoffTimeoutId||=window.setTimeout(()=>{rr.default(this._authorize().then(t).catch(e=>this.params.error$.next({id:`AuthorizeBackoff`,category:ur.NETWORK,message:`Otherwise unhandled error in authorization`,thrown:e})),()=>this.backoffTimeoutId=0)},e)})}_authorize(){var e=this;return n(function*(){if(e.authorizePromise)return e.authorizePromise;e.sessionKey=void 0,e.authorized$.next(!1);let t={session_data:{version:2,device_id:e.params.deviceId,client_version:sr.split(`-`)[0],client_type:`SDK_JS`}};return e.authToken!==void 0&&(t.session_data.auth_token=e.authToken,t.session_data.version=3),e.authorizePromise=rr.default(e.params.apiTransport.sendRequest(`auth.anonymLogin`,t).then(t=>((!t||!t.session_key)&&e.params.error$.next({id:`AuthorizeFailed`,category:ur.EXTERNAL_API,message:`No session key`,data:t}),e.sessionKey=t?.session_key??void 0,e.sessionKey)).catch(function(){var t=n(function*(t){e.sessionKey=void 0;let n=t?.error_code;switch(n){case 401:return e.authToken=yield e.refreshAuthToken(),e._authorizeWithBackoff()}n?e.params.error$.next({id:`Authorize#${n}`,category:ur.EXTERNAL_API,message:`authorize error`,data:t}):e.params.error$.next({id:`AuthorizeUnknown`,category:ur.NETWORK,message:`authorize error`,thrown:t})});return function(e){return t.apply(this,arguments)}}()),()=>{e.authorizePromise=void 0,e.consequentAuthErrors=e.sessionKey?0:e.consequentAuthErrors+1,e.authorized$.next(e.sessionKey!==void 0)}),e.authorizePromise})()}}var{NativeAbortSignal:pr,NativeAbortController:mr}=function(e){return{NativeAbortSignal:e.AbortSignal,NativeAbortController:e.AbortController}}(typeof self<`u`?self:global);function hr(e){let t;try{t=new Event(`abort`)}catch{typeof document<`u`?document.createEvent?(t=document.createEvent(`Event`),t.initEvent(`abort`,!1,!1)):(t=document.createEventObject(),t.type=`abort`):t={type:`abort`,bubbles:!1,cancelable:!1}}return t.reason=e,t}function gr(e){if(e===void 0)if(typeof document>`u`)e=Error(`This operation was aborted`),e.name=`AbortError`;else try{e=new DOMException(`signal is aborted without reason`),Object.defineProperty(e,`name`,{value:`AbortError`})}catch{e=Error(`This operation was aborted`),e.name=`AbortError`}return e}class _r{constructor(){Object.defineProperty(this,`listeners`,{value:{},writable:!0,configurable:!0})}addEventListener(e,t,n){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:n})}removeEventListener(e,t){if(!(e in this.listeners))return;let n=this.listeners[e];for(let e=0,r=n.length;e<r;e++)if(n[e].callback===t){n.splice(e,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let t=this.listeners[e.type].slice();for(let n=0,r=t.length;n<r;n++){let r=t[n];try{r.callback.call(this,e)}catch(e){Promise.resolve().then(()=>{throw e})}r.options&&r.options.once&&this.removeEventListener(e.type,r.callback)}return!e.defaultPrevented}}class vr extends _r{constructor(){super(),this.listeners||_r.call(this),Object.defineProperty(this,`aborted`,{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,`onabort`,{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,`reason`,{value:void 0,writable:!0,configurable:!0})}toString(){return`[object AbortSignal]`}dispatchEvent(e){e.type===`abort`&&(this.aborted=!0,typeof this.onabort==`function`&&this.onabort.call(this,e)),super.dispatchEvent(e)}throwIfAborted(){let{aborted:e,reason:t=`Aborted`}=this;if(e)throw t}static timeout(e){let t=new yr;return setTimeout(()=>t.abort(new DOMException(`This signal is timeout in ${e}ms`,`TimeoutError`)),e),t.signal}static any(e){let t=new yr;function n(){t.abort(this.reason),r()}function r(){for(let t of e)t.removeEventListener(`abort`,n)}for(let r of e)if(r.aborted){t.abort(r.reason);break}else r.addEventListener(`abort`,n);return t.signal}}class yr{constructor(){Object.defineProperty(this,`signal`,{value:new vr,writable:!0,configurable:!0})}abort(e){let t=gr(e),n=hr(t);this.signal.reason=t,this.signal.dispatchEvent(n)}toString(){return`[object AbortController]`}}typeof Symbol<`u`&&Symbol.toStringTag&&(yr.prototype[Symbol.toStringTag]=`AbortController`,vr.prototype[Symbol.toStringTag]=`AbortSignal`);function br(e){return e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log(`__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill`),!0):typeof e.Request==`function`&&!e.Request.prototype.hasOwnProperty(`signal`)||!e.AbortController}function xr(e){typeof e==`function`&&(e={fetch:e});let{fetch:t,Request:n=t.Request,AbortController:r,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i=!1}=e;if(!br({fetch:t,Request:n,AbortController:r,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i}))return{fetch:t,Request:a};let a=n;(a&&!a.prototype.hasOwnProperty(`signal`)||i)&&(a=function(e,t){let r;t&&t.signal&&(r=t.signal,delete t.signal);let i=new n(e,t);return r&&Object.defineProperty(i,`signal`,{writable:!1,enumerable:!1,configurable:!0,value:r}),i},a.prototype=n.prototype);let o=t;return{fetch:(e,t)=>{let n=a&&a.prototype.isPrototypeOf(e)?e.signal:t?t.signal:void 0;if(n){let r;try{r=new DOMException(`Aborted`,`AbortError`)}catch{r=Error(`Aborted`),r.name=`AbortError`}if(n.aborted)return Promise.reject(r);let i=new Promise((e,t)=>{n.addEventListener(`abort`,()=>t(r),{once:!0})});return t&&t.signal&&delete t.signal,Promise.race([i,o(e,t)])}return o(e,t)},Request:a}}var G=typeof globalThis==`object`&&globalThis||typeof window==`object`&&window,Sr=`fetch`in G&&br({fetch:G.fetch,Request:G.Request,AbortController:G.AbortController}),Cr=Sr?xr({fetch:G.fetch,Request:G.Request,AbortController:G.AbortController}):void 0,wr=Sr?Cr.fetch:G.fetch;Sr?Cr.Request:G.Request,Sr||G.AbortController,Sr||G.AbortSignal;var Tr=d(Me(),1),Er=d($t(),1);import{ErrorCategory as Dr,now as Or}from"@vkontakte/videoplayer-shared/es2015";class kr{constructor(t){e(this,`apiKey`,void 0),e(this,`apiBaseUrl`,void 0),e(this,`apiEnv`,void 0),e(this,`timeSynchronisation`,void 0),e(this,`isApiBaseUrlFetched`,void 0),e(this,`params`,void 0),this.params=t,this.apiKey=t.config.apiKey,this.apiEnv=t.config.apiEnv,this.apiBaseUrl=t.config.apiBaseUrl??Fn[this.apiEnv],this.timeSynchronisation=t.timeSynchronisation,this.isApiBaseUrlFetched=!1}resolveApiBaseUrl(){var e=this;return n(function*(){if(e.apiEnv!==`auto`||e.isApiBaseUrlFetched)return e.apiBaseUrl;try{var t;let e=yield(yield wr(atob(`aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ=`),{method:`GET`,mode:`cors`,cache:`no-cache`})).json(),n=e==null||(t=e.Answer[0])==null?void 0:t.data;if(!n)throw Error(`Wrong DNS response`);return n}catch(t){return e.params.error$.next({id:`OneStat:ApiTransport:resolveApiBaseUrl`,category:Dr.NETWORK,message:`Unhandled resolve api base url error`,thrown:t}),Fn.vk_alias}finally{e.isApiBaseUrlFetched=!0}})()}sendBeacon(e,t,n){if(!window.Blob||!window.navigator.sendBeacon)return!1;let r=this._prepareQueryParams({method:e,queryParams:t,sessionKey:n}),i=new window.Blob([r.toString()],{type:`application/x-www-form-urlencoded`});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,i)}catch(n){this.params.error$.next({id:`OneStat:ApiTransport:sendBeacon`,category:Dr.NETWORK,message:`Unhandled beacon error`,thrown:n,data:{method:e,params:t}})}return!1}sendRequest(e,t,r){var i=this;return n(function*(){let n=Or(),a=a=>{if(a instanceof TypeError&&Tr.default([`Failed to fetch`,`NetworkError when attempting to fetch resource.`],a.message)){i.params.error$.next({id:`Network`,category:Dr.NETWORK,message:`Request failed`,thrown:a});return}i.params.error$.next({id:`OneStat:ApiTransport:sendRequest`,category:Dr.NETWORK,message:`Unhandled request error`,thrown:a,data:{method:e,params:t,sessionKey:r,time:Or()-n}})};i.apiBaseUrl=yield i.resolveApiBaseUrl();let o={method:`post`,headers:{"Content-type":`application/x-www-form-urlencoded`},body:i._prepareQueryParams({method:e,queryParams:t,sessionKey:r})};return i.params.config.useKeepalive&&(o.keepalive=!0),wr(`${i.apiBaseUrl}/fb.do`,o).then(e=>{let t=Number(e.headers.get(`content-length`))===0,r=new Date(e.headers.get(`date`)??``).getTime(),o=Or()-n;if(isFinite(r)&&i.timeSynchronisation?.addServerTime(r,o),!t)return e.json().then(e=>Object.prototype.hasOwnProperty.call(e,`error_msg`)?Promise.reject(e):e,a)},a)})()}_prepareQueryParams(e){let t=new URLSearchParams({format:`JSON`,method:e.method,application_key:this.apiKey});return e.sessionKey!==void 0&&t.append(`session_key`,e.sessionKey),Er.default(e.queryParams).forEach(([e,n])=>t.append(e,typeof n==`string`?n:JSON.stringify(n))),t}}var Ar=d(Me(),1),jr=d($t(),1);import{ErrorCategory as Mr,now as Nr,safeStorage as Pr,debounceFn as Fr}from"@vkontakte/videoplayer-shared/es2015";var Ir=`onestat_events`,Lr=e=>t=>t.timestamp+e>=Nr();class Rr{constructor(t){e(this,`params`,void 0),e(this,`api`,void 0),e(this,`error$`,void 0),e(this,`subscription`,void 0),e(this,`userSalt`,void 0),e(this,`unsaltedStorage`,[]),e(this,`lastVsid`,void 0),e(this,`isPaused`,!1),e(this,`firstFlush`,void 0),e(this,`debouncedFlush`,void 0),e(this,`loggerDebugLog`,void 0),e(this,`isUrgent`,e=>{let{operation:t}=e;return Ar.default([`action_play`,`watch_coverage_record`,`watch_coverage_live`],t)}),this.params=t,this.api=t.api,this.error$=t.error$,this.userSalt=t.userSalt,this.loggerDebugLog=t.debugLogger.createComponentLog(`stat logger`),this.firstFlush=Fr(()=>this.safeFlush(),this.params.config.firstFlushTime,{maxWait:this.params.config.firstFlushTime});let n=Pr.isPersistent()?this.params.config.flushMaxWait:0;this.debouncedFlush=Fr(()=>this.safeFlush(),this.params.config.flushDebounceTime,{maxWait:n}),this.subscription=this.api.authorized$.subscribe(e=>{e&&this.debouncedFlush()}),this.housekeepStorage()}safeFlush(){try{this.flush()}catch(e){this.error$.next({id:`LoggerError`,category:Mr.WTF,message:e?String(e):`Unknown logger error`,thrown:e})}}readFromStorage(){let e=Pr.get(Ir);try{return e?JSON.parse(e):{}}catch{}return{}}addToStorage(e){if(!this.userSalt){this.unsaltedStorage.push(e);return}let n=this.readFromStorage(),r=(n[this.userSalt]??[]).filter(Lr(this.params.config.storageExpiration));Pr.set(Ir,JSON.stringify(t(t({},n),{},{[this.userSalt]:[...r,e]})))}getFromStorage(){return this.userSalt?(this.readFromStorage()[this.userSalt]??[]).filter(Lr(this.params.config.storageExpiration)):this.unsaltedStorage}markStorageSent(){if(!this.userSalt){this.unsaltedStorage=[];return}let e=this.readFromStorage();delete e[this.userSalt],Pr.set(Ir,JSON.stringify(e))}housekeepStorage(){let e=this.readFromStorage();for(let[t,n]of jr.default(e)){let r=n.filter(Lr(this.params.config.storageExpiration));r.length?e[t]=r:delete e[t],this.loggerDebugLog({message:`${n.length} retrieved from storage, ${r.length} of them actual`})}Pr.set(Ir,JSON.stringify(e))}log(e){this.addToStorage(e),!this.isPaused&&(this.isUrgent(e)?this.flush():this.lastVsid===e.custom.vsid?this.debouncedFlush():this.firstFlush(),this.lastVsid=e.custom.vsid)}flush({wantBeacon:e,clearStorage:t}={wantBeacon:!1,clearStorage:!0}){let n=this.getFromStorage();n.length!==0&&(this.api.authorized$.getValue()?(e&&this.params.config.useBeacon?(this.loggerDebugLog({message:`Flushing ${n.length} events through beacon`}),this.api.logBeacon(n)):(this.loggerDebugLog({message:`Flushing ${n.length} events`}),this.api.logRequest(n)),t&&this.markStorageSent()):this.api.authorize(),this.firstFlush.cancel(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe(),this.firstFlush.cancel(),this.debouncedFlush.cancel()}}import{HttpConnectionType as zr,Surface as Br,VideoFormat as K,VideoQuality as q}from"@vkontakte/videoplayer-core/es2015";import{assertNever as Vr}from"@vkontakte/videoplayer-shared/es2015";var Hr=e=>e&&{[q.INVARIANT]:`unknown`,[q.Q_144P]:`mobile`,[q.Q_240P]:`lowest`,[q.Q_360P]:`low`,[q.Q_480P]:`medium`,[q.Q_576P]:`unknown`,[q.Q_720P]:`high`,[q.Q_1080P]:`fullhd`,[q.Q_1440P]:`quadhd`,[q.Q_2160P]:`ultrahd`,[q.Q_4320P]:`unknown`}[e],Ur=e=>e&&{[zr.HTTP1]:`http1`,[zr.HTTP2]:`http2`,[zr.QUIC]:`http3`}[e],Wr=e=>{if(e!==void 0)switch(e){case K.MPEG:return`mp4`;case K.DASH:case K.DASH_LIVE:case K.DASH_STREAMS:return`dash`;case K.DASH_SEP:return`dash_sep`;case K.DASH_ONDEMAND:return`ondemand_dash`;case K.DASH_WEBM:case K.DASH_LIVE_WEBM:return`webm`;case K.DASH_WEBM_AV1:return`av1`;case K.DASH_LIVE_CMAF:return`ondemand_dash_live`;case K.HLS:case K.HLS_LIVE:return`hls`;case K.HLS_FMP4:return`hls_fmp4`;case K.HLS_ONDEMAND:return`ondemand_hls`;case K.HLS_LIVE_CMAF:return`ondemand_hls_live`;case K.WEB_RTC_LIVE:return`webrtc`;default:return Vr(e)}},Gr=(e,t)=>{if(t)return`minimal`;switch(e){case void 0:case Br.NONE:case Br.INLINE:return;case Br.FULLSCREEN:return`fullscreen`;case Br.SECOND_SCREEN:return`chromecast`;case Br.PIP:return`pip`;case Br.INVISIBLE:return`invisible`;default:return Vr(e)}},Kr=e=>{switch(e){case`slow-2g`:return`poor`;case`2g`:return`poor`;case`3g`:return`good`;case`4g`:return`excellent`}};class qr{constructor(t){e(this,`offset`,void 0),this.offset=t}getOffset(){return this.offset??0}setOffset(e){this.offset=e}now(){return Date.now()+(this.offset??0)}date(e=new Date){return e.setTime(e.getTime()+(this.offset??0)),e}addServerTime(e,t){let n=e-Date.now()-t/2;if(Math.abs(n)<1e3){this.offset=0;return}if(this.offset===void 0)this.offset=Math.round(n);else{let e=.2;this.offset=Math.round(e*n+(1-e)*this.offset)}}}import{PlaybackState as Jr}from"@vkontakte/videoplayer-core/es2015";import{filter as Yr,filterChanged as Xr,fromEvent as Zr,isNullable as Qr,map as $r,merge as ei,Observable as ti,Subject as ni,Subscription as ri,ValueSubject as ii}from"@vkontakte/videoplayer-shared/es2015";var ai=(e,t)=>new ti(n=>{let r=new ri,i=ei(Zr(window,`beforeunload`),e.events.willDestruct$),a=new ii(void 0),o;r.add(e.info.isLive$.pipe(Xr()).subscribe(t=>{o&&(o.unsubscribe(),a.next(void 0)),o=t?e.info.liveTime$.pipe($r(e=>e&&e/1e3)).subscribe(a):e.info.position$.subscribe(a),r.add(o)}));let{playing$:s,paused$:c}=e.events,l=e.events.willSeek$.pipe(Yr(()=>e.info.playbackState$.getValue()===Jr.PLAYING)),u=e.events.seeked$.pipe(Yr(()=>e.info.playbackState$.getValue()===Jr.PLAYING)),d=!1,f=new ni;r.add(l.subscribe(()=>{d||f.next(),d=!0})),r.add(u.subscribe(()=>d=!1));let p=new ni,m=new ni,h=ei(s,u,p),g=ei(c,f,i,e.events.looped$,m),_,v=()=>_=a.getValue(),y=()=>{let e=a.getValue();Qr(_)||_===e||Qr(e)||(n.next({from:_,to:e}),_=void 0)},b=()=>{m.next(),p.next()};if(r.add(h.subscribe(v)),r.add(g.subscribe(y)),t.forceInterval&&isFinite(t.forceInterval))if(t.watchCoverageTimeoutFix){let e,n=()=>{e!==void 0&&(window.clearTimeout(e),e=void 0)};r.add(h.subscribe(()=>{n(),e=window.setTimeout(b,t.forceInterval)})),r.add(g.subscribe(()=>n())),r.add(()=>n())}else{let e=0;r.add(h.subscribe(()=>e=window.setTimeout(b,t.forceInterval))),r.add(g.subscribe(()=>window.clearTimeout(e)))}return r});import{Surface as J}from"@vkontakte/videoplayer-core/es2015";import{debounce as oi,filterChanged as si,Subject as ci}from"@vkontakte/videoplayer-shared/es2015";var li=(e,t,n)=>{let r=new ci,i=r.pipe(oi(0),si()),a=!1,o=!1,s=!1;return t(e.inPiP$,e=>{a=e,r.next(e?J.PIP:o?J.FULLSCREEN:s?J.INLINE:void 0)}),t(e.inFullscreen$,e=>{o=e,r.next(e?J.FULLSCREEN:a?J.PIP:s?J.INLINE:void 0)}),n&&t(n.info.surface$,e=>{switch(e){case J.SECOND_SCREEN:case J.NONE:case J.INLINE:!o&&!a&&(e===J.INLINE&&(s=!0),r.next(e));break}}),{surface$:i}},ui=`_one-stat_deviceId`,di=()=>{let e=new Yn;return{subscription:e,subscribe:(t,n)=>{t&&e.add(t.subscribe(n))}}};class fi{get vsid$(){return new Xn(nr.getVSID())}constructor(t,n){e(this,`api`,void 0),e(this,`logger`,void 0),e(this,`config`,void 0),e(this,`subscription`,new Yn),e(this,`beforeunloadSubscription`,void 0),e(this,`timeSynchronisation`,void 0),e(this,`debugLogger`,new Zn),e(this,`oneStatDebugLog`,this.debugLogger.createComponentLog(`onestat`)),e(this,`loopCounter`,0),e(this,`disabled`,!1),e(this,`experimental`,void 0),e(this,`isid$`,new Xn(void 0)),e(this,`zenUid$`,new Xn(void 0)),e(this,`statContext`,void 0),e(this,`isEmbed`,void 0),e(this,`embedParent`,void 0),e(this,`uiEvents`,void 0),e(this,`player`,void 0),e(this,`seekAction$`,new Xn(`unknown`)),e(this,`deviceId`,void 0),this.statContext=t,this.config=Ln(n.config??{}),Hn(n.apiEnv)&&(this.config.apiEnv=n.apiEnv),this.config.synchronizeTime&&(this.timeSynchronisation=new qr);let r=new Jn;this.experimental={error$:r};let i=qn.get(ui);this.statContext.deviceId?this.deviceId=this.statContext.deviceId:i?this.deviceId=i:(this.deviceId=Rn(),qn.set(ui,this.deviceId)),this.resetViewSession(),n.useIsid&&this.isid$.next(n.isid??tr()),this.zenUid$.next(n.zenUid);let a=new kr({config:this.config,error$:r,timeSynchronisation:this.timeSynchronisation});this.api=new fr({config:this.config,apiTransport:a,refreshAuthToken:n.refreshAuthToken,mobile:this.statContext.mobile??!1,deviceId:this.deviceId,error$:r,vktvVersion:n.vktvVersion}),this.logger=new Rr({config:this.config,debugLogger:this.debugLogger,api:this.api,error$:r,userSalt:n.userSalt});let{isEmbed:o,topOrigin:s}=Qn();this.isEmbed=o,this.embedParent=s?new URL(s).hostname:void 0,this.subscribe()}updateContext(e){this.statContext=t(t({},this.statContext),e)}attachTo(e){let t=new Yn,n=(e,n)=>t.add(e.subscribe(n));n(e.events.willStart$,()=>{let t=e.info.position$.getValue();this.logActionPlay({position:t}),this.statContext.projectId&&this.logActionPlayInteractive()}),n(e.events.looped$,()=>{this.resetViewSession(),++this.loopCounter>this.config.maxLoops&&(this.disabled=!0),this.logActionPlay({position:e.info.position$.getValue()})}),n(e.events.seeked$,()=>{let t=this.seekAction$.getValue();this.logSeek({action:t===`rich`?`slider`:t,time:e.info.position$.getValue()}),this.seekAction$.next(`unknown`)}),n(e.events.paused$,()=>{this.logPause({position:e.info.position$.getValue()})}),n(e.events.willResume$,()=>{this.logPlay()}),n(e.events.started$,()=>{this.statContext.clip&&this.logWatchCoverageRecord({start:0,end:0})}),n(e.events.playing$,()=>{this.logPlaying()}),n(ai(e,{forceInterval:this.config.watchCoverageInterval,watchCoverageTimeoutFix:this.config.watchCoverageTimeoutFix}),t=>{let n=e.info.isLive$.getValue(),r=e.info.atLiveEdge$.getValue(),i={start:parseFloat(t.from.toFixed(3)),end:parseFloat(t.to.toFixed(3))};if(r){let t=e.info.liveLatency$.getValue()??0,n=e.info.currentBuffer$.getValue()?.end??0,r=e.info.liveBufferTime$.getValue()??0,a=Math.round((t-(n-r))*1e3),o=Math.round(t*1e3);a&&o&&(i.latency=a,i.bufferLatency=o)}n?this.logWatchCoverageLive(i):this.logWatchCoverageRecord(i)});let r;n(e.info.isStalled$,e=>{e?r=W():(Hn(r)&&this.logEmptyBuffer({duration:W()-r}),r=void 0)});let i=!1;t.add(e.events.fatalError$.pipe(Kn()).subscribe(()=>i=!0)),n(e.events.willStop$,()=>{if(e.info.isStalled$.getValue()){let e=Hn(r)?W()-r:void 0;this.logCloseAtEmptyBuffer({duration:e??0}),r=void 0}else i||this.logActionStop()}),n(e.events.managedError$,({id:e})=>{this.logError({fatal:!1,errorType:e})}),n(e.events.fatalError$,({id:e})=>{this.logError({fatal:!0,errorType:e})});let a,o,s=!1;n(e.events.firstBytes$,e=>{a=W(),this.logFirstBytes({time:e})}),n(e.events.willStart$,()=>o=W()),n(e.info.currentBuffer$,e=>{!s&&e&&e.end-e.start>0&&Hn(a)&&(this.logPlayerReady({duration:W()-a}),s=!0)}),n(e.events.firstFrame$,()=>{Hn(a)&&!s&&(this.logPlayerReady({duration:W()-a}),s=!0),Hn(o)&&this.logFirstFrame({time:W()-o})});let c;n(e.info.currentVideoStream$,e=>{e&&(c&&e.id!==c&&this.logTrackSwitch(e),c=e.id)});let l;n(e.info.currentAudioStream$,e=>{e&&(l&&e.id!==l&&this.logTrackSwitch(e),l=e.id)}),n(e.info.atLiveEdge$,e=>this.updateContext({liveEdge:e})),n(Bn({muted:e.info.muted$,volume:e.info.volume$}),({muted:e,volume:t})=>this.updateContext({audible:!e&&t>0})),n(e.info.currentQuality$,e=>{let t=Hr(e);this.updateContext({quality:t}),t&&this.logQuality(t)}),n(e.info.isAutoQualityEnabled$,e=>this.updateContext({autoQuality:e})),n(e.info.currentFormat$,e=>this.updateContext({contentType:Wr(e)})),n(e.info.currentPlaybackRate$,e=>this.updateContext({rate:e})),n(e.info.is3DVideo$,e=>this.updateContext({is3d:e}));let u;return n(e.info.hostname$,e=>{let t=u!==void 0&&u!==e;this.updateContext({cdnHostname:e,failover:t}),t&&this.logFailover(e),u=e}),n(e.info.throughputEstimation$,e=>this.updateContext({downloadSpeed:e})),n(e.info.httpConnectionType$,e=>{this.statContext.firstConnectionType||this.updateContext({firstConnectionType:Ur(e)}),this.updateContext({connectionType:Ur(e)})}),n(e.info.httpConnectionReused$,e=>{Un(this.statContext.firstConnectionReused)&&this.updateContext({firstConnectionReused:e}),this.updateContext({connectionReused:e})}),n(e.info.surface$,e=>{this.uiEvents||this.updateContext({mode:Gr(e,this.statContext.isPreviewPlayerView)})}),n(Bn({current:e.info.currentTextTrack$,available:e.info.availableTextTracks$}),({current:e,available:t})=>{let n=t.find(({id:t})=>t===e),r=n&&(n.isAuto?`${n.language}_auto`:n.language);this.updateContext({subtitles:r?.split(`.`)[0]})}),this.player=e,this.uiEvents&&this.attachToUi(this.uiEvents),this.resubscribeBeforeunload(),this.subscription.add(t),t}attachToUi(e){this.uiEvents=e;let{subscription:t,subscribe:n}=di();if(!this.player)return t;n(e.actionRewind$,()=>{this.player&&(this.resetViewSession(),this.logActionPlay({position:this.player.info.position$.getValue()}))}),n(e.actionSeek$,this.seekAction$);let{surface$:r}=li(this.uiEvents,n,this.player);return n(r,e=>{this.updateContext({mode:Gr(e,this.statContext.isPreviewPlayerView)})}),n(e.actionSetSubtitle$,e=>this.updateContext({subtitles:e?.split(`.`)[0]})),n(e.nextMovie$,e=>this.logNextMovie(e)),this.resubscribeBeforeunload(),this.subscription.add(t),t}attachToAds(e){let{subscription:t,subscribe:n}=di();return n(e.slotRequested$,()=>this.logAdSlotRequest()),n(e.started$,e=>this.logAdStarted(e)),n(e.paused$,()=>this.logAdPaused()),n(e.resumed$,()=>this.logAdResumed()),n(e.ended$,()=>this.logAdEnded()),n(e.skipped$,()=>this.logAdSkipped()),n(e.clicked$,()=>this.logAdClicked()),n(e.error$,e=>this.logError({errorType:e,fatal:!1})),this.resubscribeBeforeunload(),this.subscription.add(t),t}attachToInteractive(e){let{subscription:t,subscribe:n}=di();return n(e.click$,e=>this.logInterfaceClick(e)),n(e.nextMovie$,e=>this.logNextMovie(e)),this.resubscribeBeforeunload(),this.subscription.add(t),t}authorize(e){return this.api.authorize(e)}pause(){this.logger.pause(),this.oneStatDebugLog({message:`paused`})}resume(){this.logger.resume(),this.oneStatDebugLog({message:`resumed`})}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}resetViewSession(){this.oneStatDebugLog({message:`VSID reset`}),nr.generateVSID(this.config.useVsid64)}getDeviceId(){return this.deviceId}setFieldBlacklist(){}logInited(){}logReady(e){this.log({operation:`player_ready`,param:String(e.time)})}logStarted(...e){this.logActionPlay(...e)}logPlay(){this.log({operation:`play_toggle`})}logPlaying(){this.log({operation:`playing`})}logPause(e){this.log({operation:`pause`,param:String(Math.round(e.position))})}logSeek(e){this.log({operation:`seek`,param:e.action,time:e.time})}logFirstBytes(e){this.log({operation:`first_bytes`,param:String(e.time)})}logFirstFrame(e){this.log({operation:`first_frame`,param:String(e.time)})}logError(e){this.log({operation:`content_error`,param:`${e.fatal?`fatal`:`recoverable`}_${e.errorType}`})}logWatchCoverageRecord(e){this.log({operation:`watch_coverage_record`,param:`${e.start}-${e.end}`},{in_history:this.statContext.inHistory?1:void 0})}logWatchCoverageLive(e){let t=this.timeSynchronisation?.getOffset()??0,n=e.start+t,r=e.end+t;this.log({operation:`watch_coverage_live`,param:`${n}-${r}`},{in_history:this.statContext.inHistory?1:void 0,latency:e.latency,buffer_latency:e.bufferLatency})}logEmptyBuffer(e){this.log({operation:`empty_buffer`,param:String(e.duration)})}logDownloadSpeed(){}logAdSlotRequest(){this.log({operation:`adv`,param:`slot_request`})}logAdStarted(e){this.log({operation:`adv`,param:e})}logAdPaused(){this.log({operation:`adv`,param:`pause`})}logAdResumed(){this.log({operation:`adv`,param:`resume`})}logAdEnded(){this.log({operation:`adv`,param:`ended`})}logAdSkipped(){this.log({operation:`adv`,param:`skip`})}logAdClicked(){this.log({operation:`adv`,param:`click`})}logInterfaceClick(e){this.log({operation:`player_interface_click`,param:e})}logNextMovie(e){this.log({operation:`next_movie`,param:String(e)})}subscribe(){this.resubscribeBeforeunload();let e=window.navigator.connection;e&&`onchange`in e&&`effectiveType`in e&&this.subscription.add(Wn(Vn(e,`change`),Gn([`init`])).subscribe(()=>this.updateContext({network:Kr(e.effectiveType)}))),this.config.debugLog&&this.debugLogger.log$.subscribe(e=>{console.debug(`%c stat `,`background:#fa6470;`,`component: ${e.component}.`,e.message)})}resubscribeBeforeunload(){this.beforeunloadSubscription?.unsubscribe(),this.beforeunloadSubscription=Vn(window,`beforeunload`).subscribe(()=>this.logger.flush({wantBeacon:!0,clearStorage:this.config.clearStorageAtUnload})),this.subscription.add(this.beforeunloadSubscription)}logPlayerReady(e){this.log({operation:`player_ready`,param:String(Math.round(e.duration))})}logActionPlay(e){this.log({operation:`action_play`,param:String(Math.round(e.position))})}logActionPlayInteractive(){this.statContext.projectId&&this.log({operation:`action_play_interactive`,param:String(this.statContext.movieId)},{vid:this.statContext.projectId})}logFailover(e){this.log({operation:`failover`,param:e})}logCloseAtEmptyBuffer(e){this.log({operation:`close_at_empty_buffer`,param:String(Math.round(e.duration))})}logActionStop(){this.log({operation:`action_stop`})}logTrackSwitch(e){this.log({operation:`track_switch`,param:e.id})}logQuality(e){this.log({operation:`quality`,param:e})}log(e,t={}){if(this.disabled){this.oneStatDebugLog({message:`operation ${e.operation} but statistics is disabled`});return}if(xn(this.config.disabledOperations,e.operation)){this.oneStatDebugLog({message:`operation ${e.operation} but it is disabled`});return}this.oneStatDebugLog({message:`operation ${e.operation} ${e.param}`});let n=this.createLogItem(e,t);this.logger.log(n)}createLogItem({operation:e,param:n,time:r},i={}){let a=this.timeSynchronisation?.now()??W(),o=this.vsid$.getValue();zn(o);let s=this.isid$.getValue(),c=e===`empty_buffer`||e===`close_at_empty_buffer`?this.statContext.connectionType:this.statContext.firstConnectionType,l=this.statContext.firstConnectionReused,u,d;if(this.isEmbed||this.statContext.place===`embed`){u=this.embedParent;let e=[...new URLSearchParams(location.search).entries()].filter(([e,t])=>xn(this.config.embedUrlParams,e));d=new URLSearchParams(e).toString()}else if(this.statContext.place===`direct`){let e=this.statContext.refDomain||document.referrer;u=e&&Sn(URL,e)?new URL(e).hostname:e,d=location.href.substring(0,1024)}let f=t({vsid:o,isid:s,vid:this.statContext.movieId,uid:this.zenUid$.getValue(),ct:this.statContext.contentType,place:this.isEmbed?`embed`:this.statContext.place,quality:this.statContext.quality,cdn_host:this.statContext.cdnHostname,stat_type:this.statContext.autoplay===!0?`auto`:this.statContext.autoplay===!1?``:void 0,param:n,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode,connection_type:c,connection_reused:l===!0?1:l===!1?0:void 0,cached_data:this.statContext.cached===!0?1:this.statContext.cached===!1?0:void 0,live:this.statContext.liveEdge?1:void 0,muted:this.statContext.audible===!1?1:void 0,mode:this.statContext.mode,subtitles:this.statContext.subtitles,download_speed:this.statContext.downloadSpeed,manual_quality:this.statContext.autoQuality?void 0:1,ref_domain:u,direct_url:d,rate:this.statContext.rate===1||Un(this.statContext.rate)?void 0:this.statContext.rate.toFixed(2),view_360:this.statContext.is3d?1:void 0,aid:this.statContext.albumId,vk_playlist_id:this.statContext.vkPlaylistId},i);for(let e of this.config.disabledCustomFields)delete f[e];return{operation:e,type:1,time:r,network:this.statContext.network,timestamp:a,custom:f}}}var pi={};h(pi,{VERSION:()=>sr,ThinOneStat:()=>Ka,ActionSeekType:()=>Pi});var mi=d(yn(),1),hi=d(Me(),1);import{assertNonNullable as gi,detectEmbed as _i,fromEvent as vi,Logger as yi,merge as bi,combine as xi,filter as Y,filterChanged as Si,once as Ci,skip as wi,debounce as Ti,safeStorage as Ei,getWindow as Di,Subject as Oi,Subscription as ki,ValueSubject as Ai,ErrorCategory as ji}from"@vkontakte/videoplayer-shared/es2015";import{clientChecker as X}from"@vkontakte/videoplayer-core/es2015";import{fillWithDefault as Mi}from"@vkontakte/videoplayer-shared/es2015";var Ni;(e=>{e.AUTO=`auto`,e.AUTO_POOR=`auto_poor`,e.AUTO_RICH=`auto_rich`})(Ni||={});var Pi;(e=>{e.SLIDER=`slider`,e.RICH=`rich`,e.DOUBLE_TAP=`double_tap`,e.TIME_CODE=`time_code`,e.EPISODE=`episode`,e.REWIND=`rewind`,e.LIVE=`live`,e.UNKNOWN=`unknown`})(Pi||={});var Fi=`CIOPGQJGDIHBABABA`,Ii={prod:`https://api.ok.ru`,vk_alias:`https://api.mycdn.me`,videotest:`https://videotestapi.ok.ru/api`,test:`https://apitest.ok.ru`,okcdn:`https://api.okcdn.ru`,auto:``},Li={apiKey:Fi,apiEnv:`okcdn`,apiBaseUrl:null,requestRetryCount:1,useVsid64:!1,firstFlushTime:5e3,flushDebounceTime:1e4,flushMaxWait:6e4,storageExpiration:2160*60*1e3,watchCoverageHeartbeatInterval:3e4,disabledEvents:[],disabledParams:[],synchronizeTime:!0,useBeacon:!1,alwaysSendDesktop:!1,watchedNDefaultTargetDuration:1e3,telemetryInterval:3e4,downloadBytesMaxTime:3e4},Ri=e=>Mi(e,Li),zi=d(Ut(),1);import{getExponentialDelay as Bi,ErrorCategory as Vi,ValueSubject as Hi}from"@vkontakte/videoplayer-shared/es2015";class Ui{constructor(t){e(this,`authorized$`,void 0),e(this,`params`,void 0),e(this,`authToken`,void 0),e(this,`sessionKey`,void 0),e(this,`authorizePromise`,void 0),e(this,`refreshAuthTokenPromise`,void 0),e(this,`consequentAuthErrors`,void 0),e(this,`backoffTimeoutId`,void 0),this.params=t,this.authorized$=new Hi(!1),this.consequentAuthErrors=0}authorize(e){var t=this;return n(function*(){return t.authToken=e??(yield t.refreshAuthToken()),t.authorizeWithBackoff()})()}logBeacon(e){let t=this.createLogParams(e),n=this.sessionKey;n&&(this.params.apiTransport.sendBeacon(`log.logUvStat`,t,n)||this.logRequest(e).catch(()=>{}))}logRequest(e){var t=this;return n(function*(){let r=`log.logUvStat`,i=t.createLogParams(e),a={},o=t.sessionKey??(yield t.authorizeWithBackoff());if(!o)return;let s=function(){var e=n(function*(e,n=t.params.config.requestRetryCount){try{return yield t.params.apiTransport.sendRequest(r,i,o,a)}catch(i){if(!i||!(`error_code`in i)){t.params.error$.next({id:`logRequestUnknown`,category:Vi.NETWORK,message:`Unknown ${r} error`,thrown:i});return}let a=i?.error_code;switch(a){case 102:case 103:case 104:return t.authorized$.next(!1),t.sessionKey=yield t.authorizeWithBackoff(),n>0?s(e,n-1):void 0;case 401:return t.authorized$.next(!1),t.authToken=yield t.refreshAuthToken(),t.sessionKey=yield t.authorizeWithBackoff(),n>0?s(e,n-1):void 0;default:t.params.error$.next({id:`LogRequest#${a}`,category:Vi.EXTERNAL_API,message:`${r} error`,data:i});return}}});return function(t){return e.apply(this,arguments)}}();return s(e)})()}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}refreshAuthToken(){var e=this;return n(function*(){if(e.params.refreshAuthToken)return e.refreshAuthTokenPromise||=zi.default(e.params.refreshAuthToken(),()=>{e.refreshAuthTokenPromise=void 0}),e.refreshAuthTokenPromise})()}createLogParams(e){return{collector:`ok.mobile.apps.video`,uv_stat_data:JSON.stringify({application:`@vkontakte/videoplayer-statistics:${sr}`,platform:e[0].platform,product:e[0].product,events:e})}}authorizeWithBackoff(){var e=this;if(!this.consequentAuthErrors)return this.doAuthorize();let t=Bi(this.consequentAuthErrors);return new Promise(r=>{this.backoffTimeoutId||=window.setTimeout(n(function*(){try{r(yield e.doAuthorize())}catch(t){e.params.error$.next({id:`AuthorizeBackoff`,category:Vi.NETWORK,message:`Otherwise unhandled error in authorization`,thrown:t})}finally{e.backoffTimeoutId=0}}),t)})}doAuthorize(){var e=this;if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);let t={session_data:{version:2,device_id:this.params.deviceId,client_version:sr.split(`-`)[0],client_type:`SDK_JS`}};return this.authToken!==void 0&&(t.session_data.auth_token=this.authToken,t.session_data.version=3),this.authorizePromise=zi.default(this.params.apiTransport.sendRequest(`auth.anonymLogin`,t).then(e=>((!e||!e.session_key)&&this.params.error$.next({id:`AuthorizeFailed`,category:Vi.EXTERNAL_API,message:`No session key`,data:e}),this.sessionKey=e?.session_key??void 0,this.sessionKey)).catch(function(){var t=n(function*(t){e.sessionKey=void 0;let n=t?.error_code;switch(n){case 401:return e.authToken=yield e.refreshAuthToken(),e.authorizeWithBackoff()}n?e.params.error$.next({id:`Authorize#${n}`,category:Vi.EXTERNAL_API,message:`authorize error`,data:t}):e.params.error$.next({id:`AuthorizeUnknown`,category:Vi.NETWORK,message:`authorize error`,thrown:t})});return function(e){return t.apply(this,arguments)}}()),()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise}}var Wi=d(Me(),1),Gi=d($t(),1);import{now as Ki,ErrorCategory as qi}from"@vkontakte/videoplayer-shared/es2015";class Ji{constructor(t){e(this,`params`,void 0),e(this,`apiKey`,void 0),e(this,`apiBaseUrl`,void 0),e(this,`apiEnv`,void 0),e(this,`isApiBaseUrlFetched`,void 0),e(this,`timeSynchronisation`,void 0),this.params=t,this.apiKey=t.config.apiKey,this.apiEnv=t.config.apiEnv,this.apiBaseUrl=t.config.apiBaseUrl??Ii[this.apiEnv],this.timeSynchronisation=t.timeSynchronisation,this.isApiBaseUrlFetched=!1}sendBeacon(e,t,n){if(!window.Blob||!window.navigator.sendBeacon)return!1;let r=this.prepareQueryParams({method:e,queryParams:t,sessionKey:n}),i=new window.Blob([r.toString()],{type:`application/x-www-form-urlencoded`});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,i)}catch(n){this.params.error$.next({id:`OneStat:ApiTransport:sendBeacon`,category:qi.NETWORK,message:`Unhandled beacon error`,thrown:n,data:{method:e,params:t}})}return!1}sendRequest(e,r,i,a){var o=this;return n(function*(){let n=Ki(),s=t=>{if(t instanceof TypeError&&Wi.default([`Failed to fetch`,`NetworkError when attempting to fetch resource.`],t.message)){o.params.error$.next({id:`Network`,category:qi.NETWORK,message:`Request failed`,thrown:t});return}o.params.error$.next({id:`ThinOneStat:ApiTransport:sendRequest`,category:qi.NETWORK,message:`Unhandled request error`,thrown:t,data:{method:e,params:r,sessionKey:i,time:Ki()-n}})};return o.apiBaseUrl=yield o.resolveApiBaseUrl(),wr(`${o.apiBaseUrl}/fb.do`,{method:`post`,headers:t({"Content-type":`application/x-www-form-urlencoded`},a),body:o.prepareQueryParams({method:e,queryParams:r,sessionKey:i})}).then(e=>{let t=Number(e.headers.get(`content-length`))===0,r=new Date(e.headers.get(`date`)??``).getTime(),i=Ki()-n;if(isFinite(r)&&o.timeSynchronisation?.addServerTime(r,i),!t)return e.json().then(e=>Object.prototype.hasOwnProperty.call(e,`error_msg`)?Promise.reject(e):e,s)},s)})()}resolveApiBaseUrl(){var e=this;return n(function*(){if(e.apiEnv!==`auto`||e.isApiBaseUrlFetched)return e.apiBaseUrl;try{var t;let e=yield(yield wr(atob(`aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ=`),{method:`GET`,mode:`cors`,cache:`no-cache`})).json(),n=e==null||(t=e.Answer[0])==null?void 0:t.data;if(!n)throw Error(`Wrong DNS response`);return n}catch(t){return e.params.error$.next({id:`ThinOneStat:ApiTransport:resolveApiBaseUrl`,category:qi.NETWORK,message:`Unhandled resolve api base url error`,thrown:t}),Ii.vk_alias}finally{e.isApiBaseUrlFetched=!0}})()}prepareQueryParams(e){let t=new URLSearchParams({format:`JSON`,method:e.method,application_key:this.apiKey});return e.sessionKey!==void 0&&t.append(`session_key`,e.sessionKey),Gi.default(e.queryParams).forEach(([e,n])=>t.append(e,typeof n==`string`?n:JSON.stringify(n))),t}}var Yi=d(Me(),1),Xi=d($t(),1);import{ErrorCategory as Zi,now as Qi,safeStorage as $i,debounceFn as ea}from"@vkontakte/videoplayer-shared/es2015";var ta=`thinonestat_events`,na=e=>t=>t.client_time+e>=Qi();class ra{constructor(t){e(this,`params`,void 0),e(this,`api`,void 0),e(this,`error$`,void 0),e(this,`subscription`,void 0),e(this,`userSalt`,void 0),e(this,`unsaltedStorage`,[]),e(this,`lastVsid`,void 0),e(this,`isPaused`,!1),e(this,`firstFlush`,void 0),e(this,`debouncedFlush`,void 0),e(this,`loggerDebugLog`,void 0),e(this,`isUrgent`,e=>{let{event_name:t}=e;return Yi.default([`watch_coverage`,`watch_coverage_live`,`watched_n`,`playback_started`],t)}),this.params=t,this.api=t.api,this.error$=t.error$,this.userSalt=t.userSalt,this.loggerDebugLog=t.debugLogger.createComponentLog(`stat logger`),this.firstFlush=ea(()=>this.safeFlush(),this.params.config.firstFlushTime,{maxWait:this.params.config.firstFlushTime});let n=$i.isPersistent()?this.params.config.flushMaxWait:0;this.debouncedFlush=ea(()=>this.safeFlush(),this.params.config.flushDebounceTime,{maxWait:n}),this.subscription=this.api.authorized$.subscribe(e=>{e&&this.debouncedFlush()}),this.housekeepStorage()}safeFlush(){try{this.flush()}catch(e){this.error$.next({id:`LoggerError`,category:Zi.WTF,message:String(e)||`Unknown logger error`,thrown:e})}}readFromStorage(){let e=$i.get(ta);try{return e?JSON.parse(e):{}}catch{}return{}}addToStorage(e){if(!this.userSalt){this.unsaltedStorage.push(e);return}let n=this.readFromStorage(),r=(n[this.userSalt]??[]).filter(na(this.params.config.storageExpiration));$i.set(ta,JSON.stringify(t(t({},n),{},{[this.userSalt]:[...r,e]})))}getFromStorage(){return this.userSalt?(this.readFromStorage()[this.userSalt]??[]).filter(na(this.params.config.storageExpiration)):this.unsaltedStorage}markStorageSent(){if(!this.userSalt){this.unsaltedStorage=[];return}let e=this.readFromStorage();delete e[this.userSalt],$i.set(ta,JSON.stringify(e))}housekeepStorage(){let e=this.readFromStorage();for(let[t,n]of Xi.default(e)){let r=n.filter(na(this.params.config.storageExpiration));r.length?e[t]=r:delete e[t],this.loggerDebugLog({message:`${n.length} retrieved from storage, ${r.length} of them actual`})}$i.set(ta,JSON.stringify(e))}log(e){this.addToStorage(e),!this.isPaused&&(this.isUrgent(e)?this.flush():this.lastVsid===e.vsid?this.debouncedFlush():this.firstFlush(),this.lastVsid=e.vsid)}flush({wantBeacon:e,clearStorage:t}={wantBeacon:!1,clearStorage:!0}){let n=this.getFromStorage();n.length!==0&&(this.api.authorized$.getValue()?(e&&this.params.config.useBeacon?(this.loggerDebugLog({message:`Flushing ${n.length} events through beacon`}),this.api.logBeacon(n)):(this.loggerDebugLog({message:`Flushing ${n.length} events`}),this.api.logRequest(n)),t&&this.markStorageSent()):this.api.authorize(),this.firstFlush.cancel(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe(),this.firstFlush.cancel(),this.debouncedFlush.cancel()}}function ia(){let e=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`.split(``),t=Array(36),n=0,r,i;for(i=0;i<36;i++)i===8||i===13||i===18||i===23?t[i]=`-`:i===14?t[i]=`4`:(n<=2&&(n=33554432+Math.random()*16777216|0),r=n&15,n>>=4,t[i]=e[i===19?r&3|8:r]);return t.join(``)}class aa{constructor(t){e(this,`offset`,void 0),this.offset=t}getOffset(){return this.offset??0}setOffset(e){this.offset=e}now(){return Date.now()+(this.offset??0)}date(e=new Date){return e.setTime(e.getTime()+(this.offset??0)),e}addServerTime(e,t){let n=e-Date.now()-t/2;if(Math.abs(n)<1e3){this.offset=0;return}if(this.offset===void 0)this.offset=Math.round(n);else{let e=.2;this.offset=Math.round(e*n+(1-e)*this.offset)}}}import{PlaybackState as oa}from"@vkontakte/videoplayer-core/es2015";import{Observable as sa,Subscription as ca,ValueSubject as la,Subject as ua,fromEvent as da,isNullable as fa,merge as pa,filter as ma,filterChanged as ha,getWindow as ga}from"@vkontakte/videoplayer-shared/es2015";var _a=(e,t,n)=>new sa(r=>{let i=new ca,a=new la(void 0),o;i.add(e.info.isLive$.pipe(ha()).subscribe(t=>{o&&(o.unsubscribe(),a.next(void 0)),o=t?e.info.liveTime$.pipe(ha()).subscribe(a):e.info.position$.subscribe(a),i.add(o)}));let{playing$:s,paused$:c,ended$:l,looped$:u}=e.events,d=e.events.willSeek$.pipe(ma(()=>e.info.playbackState$.getValue()===oa.PLAYING)),f=e.events.seeked$.pipe(ma(()=>e.info.playbackState$.getValue()===oa.PLAYING)),p=!1,m=new ua;i.add(d.subscribe(()=>{p||m.next(),p=!0})).add(f.subscribe(()=>p=!1));let h=pa(da(ga(),`beforeunload`),e.events.willDestruct$),g,_=()=>g=a.getValue(),v=()=>{let e=a.getValue();fa(g)||fa(e)||g===e||(r.next({from:g,to:e}),g=void 0)},y=new ua,b=new ua,x=pa(s,f,y),S=pa(c,m,h,l,u,b),C=t.started$&&t.ended$?pa(x,t.ended$):x,w=t.started$&&t.ended$?pa(S,t.started$):S;if(i.add(C.subscribe(_)).add(w.subscribe(v)),n.heartbeatInterval&&isFinite(n.heartbeatInterval)){let e=[],t=()=>{b.next(),y.next()};i.add(C.subscribe(()=>{let r=ga().setTimeout(t,n.heartbeatInterval);e.push(r)})).add(w.subscribe(()=>{e.forEach(e=>{ga().clearTimeout(e)}),e=[]}))}return i});import{Subscription as va}from"@vkontakte/videoplayer-core/es2015";import{Observable as ya,merge as ba}from"@vkontakte/videoplayer-shared/es2015";var xa=(e,t)=>new ya(n=>{let r=new va;return r.add(ba(e.info.position$,e.info.liveTime$).subscribe(()=>{let e=t.getTotalViewTime();e>=t.targetDuration&&(n.next({target_duration:t.targetDuration,current_tvt:e}),r.unsubscribe())})),r});import{Subscription as Sa}from"@vkontakte/videoplayer-core/es2015";import{Observable as Ca,filter as wa,getWindow as Ta}from"@vkontakte/videoplayer-shared/es2015";var Ea=(e,{maxTimeWindow:t})=>new Ca(n=>{let r=new Sa,i={maxBytesThreshold:100*1024*1024,minBytesThreshold:100*1024,maxTimeWindow:t,minTimeWindow:2e3},a={bytes:0,startTime:0,lastEmitTime:0,timeoutId:0},o=()=>{a.timeoutId&&=(Ta().clearTimeout(a.timeoutId),null)},s=()=>{a.bytes=0,a.startTime=0,a.lastEmitTime=0,o()},c=e=>{if(a.bytes<i.minBytesThreshold||e-a.lastEmitTime<i.minTimeWindow&&a.lastEmitTime>0)return!1;let t=(a.startTime>0?e-a.startTime:0)>=i.maxTimeWindow,n=a.bytes>=i.maxBytesThreshold;return t||n},l=(e=!1)=>{let t=Date.now();if(!e&&!c(t))return;o();let r=a.startTime>0?t-a.startTime:Math.max(i.minTimeWindow,1),l=a.bytes/(r/1e3);n.next({download_bytes:Math.round(a.bytes),download_speed:Math.round(l)}),a.lastEmitTime=t,s()},u=()=>{if(o(),a.startTime>0&&a.bytes>=i.minBytesThreshold){let e=Date.now()-a.startTime,t=i.maxTimeWindow-e;t>100?a.timeoutId=Ta().setTimeout(()=>{a.timeoutId=null,l()},t):t>0&&l()}};return r.add(e.info.httpDownloadMetrics$.pipe(wa(e=>e!==void 0)).subscribe(e=>{let t=Date.now();a.startTime===0&&(a.startTime=t),a.bytes+=e.bytes,c(t)?l():u()})),r.add(()=>{if(o(),a.bytes>0){let e=Date.now(),t=a.startTime>0?e-a.startTime:i.minTimeWindow,r=a.bytes/(t/1e3);n.next({download_bytes:Math.round(a.bytes),download_speed:Math.round(r)})}s()}),r});import{Observable as Da,Subscription as Oa,merge as ka}from"@vkontakte/videoplayer-shared/es2015";var Aa=e=>new Da(t=>{let n=new Oa,r=0,i=1,a=0,o=!1,s=!1,c=()=>{if(!o)return;let e=Date.now();a+=(e-r)*i,r=e},l=()=>{(!o||s)&&(r=Date.now(),o=!0,s=!1)},u=()=>{o&&=(c(),!1)},d=()=>{o&&(c(),o=!1,s=!0)},f=e=>{o&&c(),i=e,r=Date.now()},{started$:p,playing$:m,paused$:h,willSeek$:g,ended$:_,willDestruct$:v}=e.events,{currentPlaybackRate$:y}=e.info;return n.add(g.subscribe(d)).add(ka(p,m).subscribe(l)).add(ka(h,_,v).subscribe(u)).add(y.subscribe(f)),t.next(()=>{let e=a;return o&&(e+=(Date.now()-r)*i),e}),n});import{Observable as ja,Subscription as Ma,merge as Na}from"@vkontakte/videoplayer-shared/es2015";var Pa=(e,t)=>new ja(n=>{let r=new Ma,i=0;return r.add(Na(e.info.position$,e.info.liveTime$).subscribe(()=>{let e=t.getTotalViewTime();e>i&&Math.floor(e/t.interval)>Math.floor(i/t.interval)&&(i=e,n.next())})),r});import{assertNever as Fa}from"@vkontakte/videoplayer-shared/es2015";import{HttpConnectionType as Ia,Surface as La,VideoFormat as Z,VideoQuality as Q}from"@vkontakte/videoplayer-core/es2015";var Ra=e=>e&&{[Ia.HTTP1]:`http1`,[Ia.HTTP2]:`http2`,[Ia.QUIC]:`http3`}[e],za=e=>{if(e!==void 0)switch(e){case Z.MPEG:return`MP4`;case Z.DASH:case Z.DASH_LIVE:return`DASH`;case Z.DASH_SEP:return`DASH_SEP`;case Z.DASH_ONDEMAND:return`ONDEMAND_DASH`;case Z.HLS_ONDEMAND:return`ONDEMAND_HLS`;case Z.HLS:case Z.HLS_LIVE:return`HLS`;case Z.HLS_FMP4:return`HLS_FMP4`;case Z.DASH_WEBM:case Z.DASH_LIVE_WEBM:return`WEBM`;case Z.DASH_LIVE_CMAF:return`ONDEMAND_DASH_LIVE`;case Z.HLS_LIVE_CMAF:return`ONDEMAND_HLS_LIVE`;case Z.WEB_RTC_LIVE:return`WEBRTC`;case Z.DASH_WEBM_AV1:return`AV1`;case Z.DASH_STREAMS:return`MULTI_DASH`;default:return Fa(e)}},$=e=>{if(e!==void 0)switch(e){case Q.Q_144P:return`144p`;case Q.Q_240P:return`240p`;case Q.Q_360P:return`360p`;case Q.Q_480P:return`480p`;case Q.Q_720P:return`720p`;case Q.Q_1080P:return`1080p`;case Q.Q_1440P:return`1440p`;case Q.Q_2160P:return`2160p`;case Q.INVARIANT:case Q.Q_576P:case Q.Q_4320P:return`UNKNOWN`;default:return Fa(e)}},Ba=e=>{if(e!==void 0)switch(e){case`MP4`:case`ONDEMAND_DASH`:case`ONDEMAND_DASH_LIVE`:case`ONDEMAND_HLS`:case`ONDEMAND_HLS_LIVE`:case`MULTI_DASH`:case`WEBM`:case`AV1`:return`vod`;case`DASH`:case`HLS`:case`HLS_FMP4`:case`WEBRTC`:return`live`;default:return}},Va=(e,t,n)=>{if(e&&t)switch(e){case Z.MPEG:return n&&t[e]&&t[e][n];default:return t[e]?.url}},Ha=(e,t=!1)=>{if(t)return`minimal`;switch(e){case void 0:case La.NONE:return;case La.INLINE:return`inline`;case La.FULLSCREEN:return`fullscreen`;case La.SECOND_SCREEN:return`chromecast`;case La.PIP:return`pip_external`}},Ua=e=>{switch(e){case void 0:return;case La.INVISIBLE:return`background`;default:return`foreground`}},Wa=`_thin-one-stat_deviceId`,Ga=()=>{let e=new ki;return{subscription:e,subscribe:(t,n)=>{t&&e.add(t.subscribe(n))}}};class Ka{get vsid$(){return new Ai(nr.getVSID())}constructor(t,n){e(this,`api`,void 0),e(this,`logger`,void 0),e(this,`config`,void 0),e(this,`subscription`,void 0),e(this,`beforeunloadSubscription`,void 0),e(this,`timeSynchronisation`,void 0),e(this,`statContext`,void 0),e(this,`deviceId`,void 0),e(this,`targetDuration`,void 0),e(this,`debugLogger`,new yi),e(this,`thinOneStatDebugLog`,this.debugLogger.createComponentLog(`ThinOneStat`)),e(this,`eventNumber`,1),e(this,`isStarted`,void 0),e(this,`wasPaused`,void 0),e(this,`isLive`,void 0),e(this,`position`,void 0),e(this,`cdnHostname`,void 0),e(this,`isEmbed`,void 0),e(this,`embedHostname`,void 0),e(this,`connectionType`,void 0),e(this,`connectionReused`,void 0),e(this,`player`,void 0),e(this,`playerSize`,{width:0,height:0}),e(this,`currentSubtitle`,void 0),e(this,`userQuality`,void 0),e(this,`downloadQuality`,void 0),e(this,`downloadSpeed`,void 0),e(this,`networkType`,void 0),e(this,`uiEvents`,void 0),e(this,`seekAction$`,new Ai(`unknown`)),e(this,`isid$`,new Ai(void 0)),e(this,`getTotalViewTime`,()=>0),this.statContext=t,this.config=Ri(n.config??{}),this.subscription=new ki,this.config.synchronizeTime&&(this.timeSynchronisation=new aa);let r=new Oi,i=Ei.get(Wa);this.statContext.deviceId?this.deviceId=this.statContext.deviceId:i?this.deviceId=i:(this.deviceId=ia(),Ei.set(Wa,this.deviceId)),this.statContext.targetDuration?this.targetDuration=this.statContext.targetDuration:this.targetDuration=this.config.watchedNDefaultTargetDuration,this.resetViewSession(),n.useIsid&&this.isid$.next(n.isid??tr());let a=new Ji({error$:r,config:this.config,timeSynchronisation:this.timeSynchronisation});this.api=new Ui({config:this.config,apiTransport:a,error$:r,deviceId:this.deviceId,refreshAuthToken:n.refreshAuthToken}),this.logger=new ra({config:this.config,debugLogger:this.debugLogger,api:this.api,error$:r,userSalt:n.userSalt});let{isEmbed:o,topOrigin:s}=_i();this.isEmbed=o,this.embedHostname=s?new URL(s).hostname:void 0}authorize(e){return this.api.authorize(e)}updateContext(e){this.statContext=t(t({},this.statContext),e)}attachTo(e,n){let r=new ki,i=(e,t)=>r.add(e.subscribe(t));i(Aa(e),e=>{this.getTotalViewTime=e}),i(e.info.isLive$,e=>this.isLive=e),i(e.info.hostname$.pipe(Y(e=>e!==void 0)),e=>{this.cdnHostname=e});let a;i(xi({hostname:e.info.hostname$,connectionType:e.info.httpConnectionType$,connectionReused:e.info.httpConnectionReused$}).pipe(Y(({hostname:e})=>e!==void 0),Y(({connectionType:e})=>e!==void 0),Y(({connectionReused:e})=>e!==void 0)),({hostname:t,connectionType:n,connectionReused:r})=>{if(a!==void 0&&a!==t){let i={cdn_host:t,connection_type:Ra(n),connection_reused:r,content_type:za(e.info.currentFormat$.getValue())};this.logFailover(i)}this.cdnHostname=a=t}),i(e.info.httpConnectionType$,e=>{this.connectionType=Ra(e)}),i(e.info.httpConnectionReused$,e=>{this.connectionReused=e}),i(_a(e,n,{heartbeatInterval:this.config.watchCoverageHeartbeatInterval}),n=>{let r={watch_interval:`${Math.round(n.from*1e3)}-${Math.round(n.to*1e3)}`,in_history:!!this.statContext.inHistory,content_type:za(e.info.currentFormat$.getValue()),playback_quality:$(e.info.currentQuality$.getValue()),recom_info:this.statContext.recomInfo};if(!e.info.isLive$.getValue())this.logWatchCoverage(r);else{let n=e.info.atLiveEdge$.getValue();this.logWatchCoverageLive(t(t({},r),{},{live:!!n}))}}),i(Pa(e,{interval:this.statContext.telemetryInterval??this.config.telemetryInterval,getTotalViewTime:this.getTotalViewTime}),()=>{this.logTelemetry(this.collectTelemetryData())}),i(xa(e,{targetDuration:this.targetDuration,getTotalViewTime:this.getTotalViewTime}),e=>{this.logWatchedN(e)}),i(e.events.willReady$,()=>{if(this.statContext.preload){let t=e.info.currentFormat$.getValue(),n=e.info.availableSources$.getValue(),r=e.info.currentBuffer$.getValue(),i=e.info.currentQuality$.getValue(),a={target_buffer_time:this.calcBufferTime(r),playback_url:Va(t,n,i),playback_quality:$(i)};this.logPreloadStarted(a)}}),i(xi({manifestRequested$:e.events.manifestRequested$,connectionType:e.info.httpConnectionType$,connectionReused:e.info.httpConnectionReused$}).pipe(Y(({connectionType:e})=>e!==void 0),Y(({connectionReused:e})=>e!==void 0),Ci()),()=>{let t={playback_url:Va(e.info.currentFormat$.getValue(),e.info.availableSources$.getValue(),e.info.currentQuality$.getValue()),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused};this.logManifestRequest(t)}),i(xi({firstBytesManifest:e.events.firstBytesManifest$,connectionType:e.info.httpConnectionType$,connectionReused:e.info.httpConnectionReused$}).pipe(Y(({connectionType:e})=>e!==void 0),Y(({connectionReused:e})=>e!==void 0),Ci()),()=>{let t={playback_url:Va(e.info.currentFormat$.getValue(),e.info.availableSources$.getValue(),e.info.currentQuality$.getValue()),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused};this.logFirstByteManifest(t)}),i(e.events.manifestReceived$,()=>{let t={playback_url:Va(e.info.currentFormat$.getValue(),e.info.availableSources$.getValue(),e.info.currentQuality$.getValue()),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused};this.logManifestReceived(t)}),i(e.events.firstBytesRequested$,()=>{let t={playback_url:Va(e.info.currentFormat$.getValue(),e.info.availableSources$.getValue(),e.info.currentQuality$.getValue()),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused};this.logFirstMediaRequest(t)}),i(e.events.firstBytesReceived$,()=>{let t={playback_url:Va(e.info.currentFormat$.getValue(),e.info.availableSources$.getValue(),e.info.currentQuality$.getValue()),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused};this.logFirstByteMedia(t)}),i(bi(e.events.willStart$,e.events.looped$),t=>{t&&this.resetViewSession();let n={isid:this.isid$.getValue(),stream_profile:Ba(za(e.info.currentFormat$.getValue())),dpi:this.statContext.dpi??96*X.display.pixelRatio,web_layout:this.statContext.isMobile||X.device.isMobile?`mobile`:`desktop`,preloaded:this.statContext.preload,navigation:this.statContext.navigation,recom_info:this.statContext.recomInfo};this.isEmbed&&(n.iframe_host=this.embedHostname??`unknown`),this.logStartSession(n)}),i(e.events.started$,()=>{this.isStarted=!0;let t=e.info.currentBuffer$.getValue(),n=e.info.currentQuality$.getValue(),r=e.info.isAutoQualityEnabled$.getValue(),i=e.info.muted$.getValue(),a=e.info.volume$.getValue(),o=e.info.surface$.getValue(),s=e.info.availableTextTracks$.getValue(),c=e.info.currentTextTrack$.getValue(),l=e.info.currentAudioStream$.getValue(),u=e.info.currentPlaybackRate$.getValue(),d={playback_quality:$(n),user_quality:r?`auto`:$(n),player_width:this.statContext.playerSize?.width??this.playerSize.width,player_height:this.statContext.playerSize?.height??this.playerSize.height,muted:i,sound_volume:Math.round(a*100),buffer_time:this.calcBufferTime(t),mode:Ha(o,this.statContext.isPreviewPlayerView),visibility:Ua(o),subtitles_enabled:c?!!c:this.currentSubtitle?.enabled,auto_subtitles:s.find(({id:e})=>e===c)?.isAuto??this.currentSubtitle?.auto,audio_track_lang:l?.language,playback_rate:u,recom_info:this.statContext.recomInfo};this.logPlaybackStarted(d)}),i(e.events.willStart$,()=>{this.logPlay()}),i(e.events.playing$,()=>{let t=e.info.currentBuffer$.getValue(),n={buffer_time:this.calcBufferTime(t)};this.logPlaying(n),this.wasPaused&&this.logResume()}),i(e.events.paused$,()=>{this.wasPaused=!0,this.logPause()}),i(e.events.willStop$,()=>{this.isStarted=!1,this.logStop()}),i(bi(e.events.fetcherRecoverableError$,e.events.fatalError$),()=>{this.statContext.preload&&this.logPreloadError()});let o=e=>{switch(e){case ji.NETWORK:return`network`;case ji.VIDEO_PIPELINE:return`video_pipeline`;case ji.EXTERNAL_API:return`external_api`;case ji.PARSER:return`parser`;case ji.DOM:return`dom`;default:return`wtf`}},s=e=>ji.FATAL===e?`critical`:`informative`;i(e.events.fetcherRecoverableError$,({id:t,category:n,data:r,message:i,httpCode:a,UVBackendErrorCode:c})=>{let l={error_severity:s(n),error_category:o(n),player_error_code:t,player_error_trace:r,http_error_code:a,uv_backend_error_code_subcode:c,error_message:i,content_type:za(e.info.currentFormat$.getValue())};this.logError(l),s(n)===`critical`&&this.logCannotPlay()}),i(e.events.managedError$,({id:t,category:n,data:r,message:i})=>{let a={error_severity:s(n),error_category:o(n),player_error_code:t,player_error_trace:r,error_message:i,content_type:za(e.info.currentFormat$.getValue())};this.logError(a)}),i(e.events.fatalError$,({id:t,category:n,data:r,message:i})=>{let a={error_severity:`critical`,error_category:o(n),player_error_code:t,player_error_trace:r,error_message:i,content_type:za(e.info.currentFormat$.getValue())};this.logError(a),this.logCannotPlay()}),i(xi({connectionType:e.info.httpConnectionType$,connectionReused:e.info.httpConnectionReused$,connectionMetrics:e.info.httpConnectionMetrics$}).pipe(Y(({connectionReused:e})=>e!==void 0),Y(({connectionMetrics:e})=>e!==void 0),Si((e,t)=>e.connectionType===t.connectionType)),({connectionMetrics:t})=>{let n=e.info.currentFormat$.getValue(),r=e.info.availableSources$.getValue(),i=e.info.currentQuality$.getValue(),a=e.info.rttEstimation$.getValue();this.networkType=this.statContext.networkType??t?.networkType;let o={playback_url:Va(n,r,i),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused,rtt:a?Math.round(a):void 0,network_type:this.networkType,dns_resolve_time:t?.dnsResolveTime,tcp_handshake_time:t?.tcpHandshakeTime,tls_handshake_time:t?.tlsHandshakeTime};this.logConnectionEstablished(o)}),i(Ea(e,{maxTimeWindow:this.config.downloadBytesMaxTime}),e=>{this.downloadSpeed=e.download_speed,this.logDownloadBytes(e)}),i(e.events.firstFrame$,()=>{this.logFirstVideoFrameDecoded()}),i(e.events.willSeek$,()=>{let e={seek_type:this.seekAction$.getValue()};this.isStarted&&this.logSeeking(e)}),i(e.events.seeked$,()=>{let e={seek_type:this.seekAction$.getValue()};this.isStarted&&this.logSeeked(e),this.seekAction$.next(`unknown`)}),i(e.info.isStalled$,t=>{let n=e.info.currentBuffer$.getValue(),r=this.calcBufferTime(n);t&&r&&r>0&&this.logBufferStarvation({buffer_time:r})}),i(e.info.currentBuffer$.pipe(Y(e=>!!this.calcBufferTime(e)),Ci()),e=>{let t=this.calcBufferTime(e);if(this.statContext.preload){let e={buffer_time:t};this.logPreloadEnded(e)}this.logReady({buffer_time:t})});let c;i(xi({videoStream:e.info.currentVideoStream$,audioStream:e.info.currentAudioStream$,quality:e.info.currentQuality$}).pipe(Y(({videoStream:e,audioStream:t})=>e!==void 0&&t!==void 0),Y(({quality:e})=>e!==void 0)),({videoStream:t,audioStream:n,quality:r})=>{if(c!==r){if(this.userQuality=e.info.isAutoQualityEnabled$.getValue()?`auto`:$(r),this.downloadQuality=$(r),this.isStarted){let e=t?.codec,r=n?.codec,i={user_quality:this.userQuality,playback_quality:$(c),download_quality:this.downloadQuality,codec_info:this.genCodecInfo(e,r)};this.logQualityChanged(i)}c=r}});let l,u;return i(e.info.surface$,e=>{let t=Ha(e,this.statContext.isPreviewPlayerView);t&&!this.uiEvents&&this.isStarted&&this.logModeChanged({mode:t}),u=Ua(e),l!==u&&(this.isStarted&&this.logVisibilityChanged({visibility:u}),l=Ua(e))}),i(xi({muted:e.info.muted$,volume:e.info.volume$}).pipe(Ti(300)),({muted:e,volume:t})=>{if(this.isStarted){let n={muted:e,sound_volume:Math.round(t*100)};this.logSoundChanged(n)}}),i(e.info.currentFormat$.pipe(Y(e=>e!==void 0),wi(1)),e=>{let t={content_type:za(e),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused};this.logContentTypeChange(t)}),i(e.info.currentAudioStream$.pipe(Y(e=>e!==void 0),wi(1)),e=>{let t={audio_track_lang:e.language,codec_info:e.codec};this.logAudioTrackSwitched(t)}),i(e.info.currentVideoStream$.pipe(Y(e=>e!==void 0),wi(1)),e=>{let t={hdr:e.hdr,codec_info:e.codec};this.logVideoTrackSwitched(t)}),this.player=e,this.resubscribeBeforeunload(),this.subscription.add(r),r}attachToUi(e){this.uiEvents=e;let{subscribe:n,subscription:r}=Ga();n(e.actionSeek$,this.seekAction$),n(e.playerSize$,({width:e,height:t})=>{e&&t&&(this.playerSize={width:e,height:t},this.isStarted&&this.logViewPortChanged({player_width:e,player_height:t}))}),n(e.isLoaderVisible$,e=>{e&&this.isStarted&&this.logShowLoader()}),n(e.actionSubtitlesSwitched$,e=>{if(this.currentSubtitle=t({},e),this.isStarted){let t={subtitles_enabled:e.enabled,subtitles_track_lang:e.lang,auto_subtitles:e.auto};this.logSubtitlesSwitched(t)}});let{surface$:i}=li(this.uiEvents,n,this.player);return n(i,e=>{this.isStarted&&this.logModeChanged({mode:Ha(e)})}),n(e.actionQuality$,e=>{var t,n,r;let i=e=>hi.default(mi.default(Ni),e),a=(t=this.player)==null||(t=t.info.currentVideoStream$.getValue())==null?void 0:t.codec,o=(n=this.player)==null||(n=n.info.currentAudioStream$.getValue())==null?void 0:n.codec,s={user_quality:i(e)?`auto`:$(e),playback_quality:$(this.player?.info.currentQuality$.getValue()),download_quality:i(e)?$((r=this.player)==null||(r=r.info.currentQuality$)==null?void 0:r.getValue()):$(e),codec_info:this.genCodecInfo(a,o)};this.logQualityChangeRequested(s)}),this.resubscribeBeforeunload(),this.subscription.add(r),r}attachToAds(e){let{subscription:t,subscribe:n}=Ga();return n(e.init$,e=>{let t={slot:e};this.logAdvConfiguration(t)}),n(e.slotRequested$,e=>{let t={adv_section:e};this.logAdvRequest(t)}),n(e.started$,e=>{let t={adv_section:e};this.logAdvBreakStarted(t)}),n(e.ended$,({section:e,ordIds:t})=>{let n={adv_section:e,erids:t.join(`,`)};this.logAdvBreakEnded(n)}),n(e.error$,e=>{let t={error_message:e};this.logAdvError(t)}),this.resubscribeBeforeunload(),this.subscription.add(t),t}getDeviceId(){return this.deviceId}resetViewSession(){this.thinOneStatDebugLog({message:`VSID reset`}),nr.generateVSID(this.config.useVsid64),this.eventNumber=0}destroy(){this.api.destroy()}calcBufferTime(e){return e?Math.round((e.end??0)-(e.start??0))*1e3:void 0}genCodecInfo(e,t){return e&&t?`${e},${t}`:void 0}getLatencyInfo(){let e=this.player?.info.atLiveEdge$.getValue(),t={client_time:Date.now(),live:e};return JSON.stringify(t)}collectTelemetryData(){if(!this.player)return{};let e=this.player.info.currentBuffer$.getValue(),t=this.player.experimental.element$.getValue(),n=0,r=0;t&&(n=t.getVideoPlaybackQuality().droppedVideoFrames,r=t.getVideoPlaybackQuality().totalVideoFrames);let i=za(this.player.info.currentFormat$.getValue()),a=this.player.info.currentVideoStream$.getValue()?.codec,o=this.player.info.currentAudioStream$.getValue()?.codec,s=this.player.info.videoBitrate$.getValue(),c=this.player.info.rttEstimation$.getValue();return{buffer_time:this.calcBufferTime(e),dropped_frames_count:n,rendered_frames_count:r,content_type:i,user_quality:this.userQuality,playback_quality:$(this.player.info.currentQuality$.getValue()),download_quality:this.downloadQuality,codec_info:this.genCodecInfo(a,o),bandwidth_from_manifest:s,cdn_host:this.cdnHostname,download_speed:this.downloadSpeed,network_type:this.networkType,rtt:c?Math.round(c):void 0,latency:this.getLatencyInfo()}}createRequiredParams(e){let t=this.vsid$.getValue();gi(t);let n=this.eventNumber++,r=((this.isLive?this.player?.info.liveTime$.getValue():this.player?.info.position$.getValue())??0)*1e3,i={vsid:t,uv_movie_id:this.statContext.movieId,event_name:e,client_time:Date.now(),application:this.statContext.application??`@vkontakte/videoplayer-statistics:${sr}`,platform:this.statContext.platform??`web:${this.statContext.isMobile||X.device.isMobile?`mobile`:`desktop`}`,product:this.statContext.product,event_number:n,playback_position:Math.round(r),current_tvt:this.getTotalViewTime(),cdn_host:this.cdnHostname};for(let e of this.config.disabledParams)delete i[e];return i}createRequiredFatParams(){let e={stats_version:`2.1.1`,browser:this.statContext.browser??X.browser.current,browser_version:this.statContext.browserVersion??String(X.browser.currentVersion),os:this.statContext.os??X.device.os.name,os_version:this.statContext.osVersion??X.device.os.version,device_type:this.statContext.deviceType??(this.statContext.isMobile||X.device.isMobile?`mobile`:`desktop`),device_manufacturer:this.statContext.deviceManufacturer??X.device.details.vendor,device_model:this.statContext.deviceModel??X.device.details.model,navigation:this.statContext.navigation};for(let t of this.config.disabledParams)delete e[t];return e}log(e,n,r=!1){if(xn(this.config.disabledEvents,e))return;let i=this.createRequiredParams(e),a={};r&&(a=this.createRequiredFatParams()),this.logger.log(t(t(t({},i),a),n))}logWatchCoverage(e){this.log(`watch_coverage`,e,!0)}logWatchCoverageLive(e){this.log(`watch_coverage_live`,e,!0)}logWatchedN(e){this.log(`watched_n`,e,!0)}logStartSession(e){this.log(`start_session`,e,!0)}logPreloadStarted(e){this.log(`preload_started`,e)}logPreloadEnded(e){this.log(`preload_ended`,e)}logPreloadError(){this.log(`preload_error`)}logPlaybackStarted(e){this.log(`playback_started`,e,!0)}logPlay(){this.log(`play`)}logManifestRequest(e){this.log(`manifest_request`,e)}logFirstByteManifest(e){this.log(`first_byte_manifest`,e)}logFirstMediaRequest(e){this.log(`first_media_request`,e)}logFirstByteMedia(e){this.log(`first_byte_media`,e)}logManifestReceived(e){this.log(`manifest_received`,e)}logConnectionEstablished(e){this.log(`connection_established`,e)}logFirstVideoFrameDecoded(){this.log(`first_video_frame_decoded`)}logReady(e){this.log(`ready`,e)}logPlaying(e){this.log(`playing`,e)}logPause(){this.log(`pause`)}logResume(){this.log(`resume`)}logSeeking(e){this.log(`seeking`,e)}logSeeked(e){this.log(`seeked`,e)}logStop(){this.log(`stop`)}logBufferStarvation(e){this.log(`buffer_starvation`,e)}logShowLoader(){this.log(`show_loader`)}logQualityChangeRequested(e){this.log(`quality_change_requested`,e)}logQualityChanged(e){this.log(`quality_changed`,e)}logCdnHostChanged(e){this.log(`cdn_host_changed`,e)}logViewPortChanged(e){this.log(`view_port_changed`,e)}logModeChanged(e){this.log(`mode_changed`,e)}logVisibilityChanged(e){this.log(`visibility_changed`,e)}logAudioTrackSwitched(e){this.log(`audio_track_switched`,e)}logVideoTrackSwitched(e){this.log(`video_track_switched`,e)}logSubtitlesSwitched(e){this.log(`subtitles_switched`,e)}logSoundChanged(e){this.log(`sound_changed`,e)}logFailover(e){this.log(`failover`,e)}logContentTypeChange(e){this.log(`content_type_change`,e)}logError(e){this.log(`error`,e,!0)}logCannotPlay(){this.log(`cannot_play`,{},!0)}logDownloadBytes(e){this.log(`download_bytes`,e)}logTelemetry(e){this.log(`telemetry`,e)}logAdvConfiguration(e){this.log(`adv_configuration`,e)}logAdvRequest(e){this.log(`adv_request`,e)}logAdvBreakStarted(e){this.log(`adv_break_started`,e)}logAdvBreakEnded(e){this.log(`adv_break_ended`,e)}logAdvError(e){this.log(`adv_error`,e)}resubscribeBeforeunload(){this.beforeunloadSubscription?.unsubscribe(),this.beforeunloadSubscription=vi(Di(),`beforeunload`).subscribe(()=>{}),this.subscription.add(this.beforeunloadSubscription)}}var qa=(e,t={})=>{let n=t.timeout||1,r=performance.now();return G.setTimeout(()=>{e({get didTimeout(){return t.timeout?!1:performance.now()-r-1>n},timeRemaining(){return Math.max(0,1+(performance.now()-r))}})},1)},Ja=e=>G.clearTimeout(e),Ya=e=>typeof e==`function`&&e?.toString().endsWith(`{ [native code] }`),Xa=!Ya(G.requestIdleCallback)||!Ya(G.cancelIdleCallback),Za=Xa?qa:G.requestIdleCallback,Qa=Xa?Ja:G.cancelIdleCallback;import{PlaybackState as $a,Subscription as eo}from"@vkontakte/videoplayer-core/es2015";import{Logger as to}from"@vkontakte/videoplayer-shared/es2015";class no{constructor(){e(this,`startTime`,null),e(this,`stopTime`,null),e(this,`accumulatedTime`,0)}get time(){return Math.floor(this.timeMs/1e3)}get timeMs(){return this.startTime===null?0:(this.stopTime??this.now())-this.startTime-this.accumulatedTime}get isRunning(){return this.startTime!==null&&this.stopTime===null}start(){this.isRunning||(this.stopTime===null?this.startTime=this.now():(this.accumulatedTime+=this.now()-this.stopTime,this.stopTime=null))}stop(){this.isRunning&&(this.stopTime=this.now())}reset(){this.startTime=null,this.stopTime=null,this.accumulatedTime=0}now(){return Date.now()}}var ro=()=>window.Image?new Image:document.createElement(`img`);class io{constructor(t){e(this,`params`,void 0),e(this,`position`,0),e(this,`started`,!1),e(this,`isActiveLive`,void 0),e(this,`heartbeatPixels`,[]),e(this,`heartbeatLastTimeSent`,{}),e(this,`heartbeatInterval`,void 0),e(this,`heartbeatFirstTimeoutId`,void 0),e(this,`idleCallbackIds`,[]),e(this,`log`,void 0),e(this,`stopwatch`,new no),e(this,`subscription`,new eo),this.params=t,this.log=new to().createComponentLog(`MediascopePixel`)}attachTo(e){this.subscription.add(e.info.playbackState$.subscribe(e=>this.onPlaybackState(e))).add(e.info.position$.subscribe(e=>this.onPosition(e))).add(e.info.atLiveEdge$.subscribe(e=>this.isActiveLive=e)),this.subscription.add(e.events.willSeek$.subscribe(()=>this.onWillSeek())).add(e.events.seeked$.subscribe(()=>this.onSeeked())).add(e.events.ended$.subscribe(()=>this.onEnded()))}destroy(){this.stopwatch.reset(),this.subscription.unsubscribe(),window.clearTimeout(this.heartbeatFirstTimeoutId),this.idleCallbackIds.forEach(e=>Qa(e)),this.send(`stop`)}onPlaybackState(e){e===$a.PLAYING?this.started?this.play():this.start():e===$a.PAUSED&&this.pause()}start(){this.started=!0,this.stopwatch.start(),this.send(`start`),this.heartbeatPixels=this.prepareHeartbeatPixels(),this.heartbeatInterval=this.heartbeatPixels[0]?.interval;let e=this.heartbeatPixels[0]?.url,t=this.heartbeatPixels[0]?.delay;if(t!==void 0&&e)try{this.heartbeatFirstTimeoutId=window.setTimeout(()=>{this.sendHeartbeat(e)},t*1e3)}catch(e){this.log({message:e.message})}}play(){this.stopwatch.start(),this.send(`resume`)}pause(){this.stopwatch.stop(),this.send(`pause`)}onPosition(e){if(this.position=e,this.heartbeatInterval&&this.stopwatch.time!==0&&this.stopwatch.time%this.heartbeatInterval===0)for(let[e,{url:t}]of this.heartbeatPixels.entries())this.heartbeatLastTimeSent[e]!==this.stopwatch.time&&(this.heartbeatLastTimeSent[e]=this.stopwatch.time,this.sendHeartbeat(t))}onWillSeek(){this.started&&this.send(`stop`)}onSeeked(){this.started&&this.send(`start`)}onEnded(){this.stopwatch.stop(),this.send(`stop`)}validatePixels(e,t){return e?.filter(e=>e.event===t.event&&t.keys.every(t=>!!e[t]))}getFrameTimestamp(){let e;if(this.isActiveLive){let t=Math.floor(Math.random()*25)+5;e=Date.now()/1e3-t}else e=this.position||0;return Math.floor(e)}getUTC(){return Math.floor(Date.now()/1e3)}prepareUrl(e){return e.replace(`{@fts_fake_sec}`,String(this.getFrameTimestamp())).replace(`{@utc_sec}`,String(this.getUTC())).split(`&`).filter(e=>!/={@[a-zA-Z_]+}/.test(e)).join(`&`)}preparePixels(e){return this.validatePixels(this.params.pixels,{event:e,keys:[`url`]})}prepareHeartbeatPixels(){return this.validatePixels(this.params.pixels,{event:`heartbeat`,keys:[`url`,`interval`]})}call(e){try{this.idleCallbackIds.push(Za(()=>ro().src=this.prepareUrl(e)))}catch(e){this.log({message:e.message})}}send(e){let t=this.preparePixels(e);for(let{url:e}of t)this.call(e)}sendHeartbeat(e){this.call(e)}}export{sr as VERSION,pi as ThinOneStat,Dn as SeekAction,wn as Quality,fi as OneStat,io as MediascopePixel,On as InteractiveInterfaceClick,Tn as ContentType,En as ConnectionType,Cn as ApiEnv};
6
+ import e from"@oxc-project/runtime/helpers/defineProperty";import t from"@oxc-project/runtime/helpers/objectSpread2";import n from"@oxc-project/runtime/helpers/asyncToGenerator";var r=Object.defineProperty,i=e=>e;function a(e,t){this[e]=i.bind(null,t)}var o=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0,configurable:!0,set:a.bind(t,n)})};import{arrayIncludes as s}from"@vkontakte/videoplayer-shared/es2015";import{urlCanParsePolyfilled as c}from"@vkontakte/videoplayer-shared/es2015";var l;(e=>{e.PROD=`prod`,e.VK_ALIAS=`vk_alias`,e.VIDEOTEST=`videotest`,e.TEST=`test`,e.OKCDN=`okcdn`,e.AUTO=`auto`})(l||={});var u;(e=>{e.Q144P=`mobile`,e.Q240P=`lowest`,e.Q360P=`low`,e.Q480P=`medium`,e.Q720P=`high`,e.Q1080P=`fullhd`,e.Q1440P=`quadhd`,e.Q2160P=`ultrahd`,e.UNKNOWN=`unknown`})(u||={});var d;(e=>{e.MP4=`mp4`,e.DASH=`dash`,e.DASH_SEP=`dash_sep`,e.ONDEMAND_DASH=`ondemand_dash`,e.HLS=`hls`,e.HLS_FMP4=`hls_fmp4`,e.ONDEMAND_HLS=`ondemand_hls`,e.WEBM=`webm`,e.AV1=`av1`,e.ONDEMAND_DASH_LIVE=`ondemand_dash_live`,e.ONDEMAND_HLS_LIVE=`ondemand_hls_live`,e.WEBRTC=`webrtc`,e.UNKNOWN=`unknown`,e.RTMP=`rtmp`})(d||={});var f;(e=>{e.HTTP1=`http1`,e.HTTP2=`http2`,e.HTTP3=`http3`})(f||={});var p;(e=>{e.SLIDER=`slider`,e.RICH=`rich`,e.DOUBLE_TAP=`double_tap`,e.TIME_CODE=`time_code`,e.EPISODE=`episode`,e.REWIND=`rewind`,e.LIVE=`live`,e.UNKNOWN=`unknown`})(p||={});var m;(e=>{e.GRAPH_SHOW=`iGraphShow`,e.GRAPH_HIDE=`iGraphHide`,e.NEXT_AREA=`iNextChapterArea`,e.NEXT_BUTTON=`iNextChapterBtn`,e.WATCH_AGAIN=`iWatchAgainBtn`})(m||={});var h={action_play:`ap`,action_play_interactive:`api`,first_bytes:`fb`,player_ready:`pr`,first_frame:`ff`,seek:`sk`,watch_coverage_record:`wr`,watch_coverage_live:`wl`,empty_buffer:`eb`,action_stop:`as`,close_at_empty_buffer:`cb`,content_error:`er`,player_interface_click:`pc`,next_movie:`nm`,track_switch:`ts`,failover:`fo`,quality:`qt`},g={vsid:`si`,isid:`is`,vid:`vi`,place:`pl`,quality:`qt`,cdn_host:`ch`,stat_type:`st`,param:`pm`,vk_app_id:`va`,track_code:`tc`,connection_type:`cnt`,connection_reused:`cr`,cached_data:`cd`,live:`lv`,muted:`mu`,mode:`mo`,subtitles:`sb`,failover:`fo`,download_speed:`ds`,manual_quality:`mq`,ref_domain:`rd`,direct_url:`du`},_={unknown:`un`,mobile:`m`,lowest:`ls`,low:`l`,medium:`md`,high:`h`,fullhd:`f`,quadhd:`q`,ultrahd:`u`},v={pip:`pi`,fullscreen:`fs`,external:`ex`,prefetch:`pr`,airplay:`ap`,chromecast:`cc`,invisible:`iv`,minimal:`minimal`};import{fillWithDefault as y}from"@vkontakte/videoplayer-shared/es2015";var b=`CIOPGQJGDIHBABABA`,x={prod:`https://api.ok.ru`,vk_alias:`https://api.mycdn.me`,videotest:`https://videotestapi.ok.ru/api`,test:`https://apitest.ok.ru`,okcdn:`https://api.okcdn.ru`,auto:``},ee={apiEnv:`vk_alias`,apiKey:b,apiBaseUrl:null,requestRetryCount:1,useVsid64:!1,firstFlushTime:5e3,flushDebounceTime:1e4,flushMaxWait:6e4,storageExpiration:2160*60*1e3,watchCoverageInterval:15e3,disabledOperations:[`quality`],disabledCustomFields:[],shorten:!0,maxLoops:100,embedUrlParams:[],useBeacon:!0,synchronizeTime:!0,debugLog:!1,clearStorageAtUnload:!0,useVKComIsMobileLogic:!1,backoff:{start:1e3,factor:1.5,max:300*1e3,random:.1},useKeepalive:!1,watchCoverageTimeoutFix:!1},te=e=>y(e,ee);function ne(){let e=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`.split(``),t=Array(36),n=0,r,i;for(i=0;i<36;i++)i===8||i===13||i===18||i===23?t[i]=`-`:i===14?t[i]=`4`:(n<=2&&(n=33554432+Math.random()*16777216|0),r=n&15,n>>=4,t[i]=e[i===19?r&3|8:r]);return t.join(``)}import{assertNonNullable as re,combine as ie,fromEvent as ae,isNonNullable as S,isNullable as oe,merge as se,now as C,observableFrom as ce,once as le,safeStorage as ue,Subject as de,Subscription as fe,ValueSubject as w}from"@vkontakte/videoplayer-shared/es2015";import{Logger as pe,detectEmbed as me}from"@vkontakte/videoplayer-shared/es2015";import{stringPadStart as he}from"@vkontakte/videoplayer-shared/es2015";var ge=()=>he(Math.floor(Math.random()*2**32).toString(36),13,`0`),_e=()=>he(Math.floor(Math.random()*2**64).toString(36),13,`0`);class T{static getVSID(){return T.vsid}static generateVSID(e){return T.vsid=e?_e():ge(),T.vsid}}e(T,`vsid`,void 0);import{promiseFinally as E}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as ve}from"@vkontakte/videoplayer-shared/es2015";import{objectFromEntries as ye}from"@vkontakte/videoplayer-shared/es2015";var be=e=>{let{operation:n,custom:r}=e,i=ye(ve(r).map(([e,t])=>{let n=g[e]??e,r=t;return t&&(e===`mode`?r=v[t]??t:e===`quality`&&(r=_[t]??t)),[n,r]}));return t(t({},e),{},{operation:h[n]??n,custom:i})},D=`1.0.103-dev.baccd7d5.0`;import{ValueSubject as xe,getExponentialDelay as Se,ErrorCategory as O}from"@vkontakte/videoplayer-shared/es2015";var Ce=/Mobile|mini|Fennec|Android|iP(ad|od|hone)|opera (mini|mobi)/i;class we{constructor(t){e(this,`params`,void 0),e(this,`authToken`,void 0),e(this,`sessionKey`,void 0),e(this,`authorizePromise`,void 0),e(this,`refreshAuthTokenPromise`,void 0),e(this,`consequentAuthErrors`,0),e(this,`authorized$`,new xe(!1)),e(this,`backoffTimeoutId`,void 0),this.params=t}authorize(e){var t=this;return n(function*(){return t.authToken=e??(yield t.refreshAuthToken()),t._authorizeWithBackoff()})()}logBeacon(e){let t=this.createLogParams(e),n=this.sessionKey;n&&(this.params.apiTransport.sendBeacon(`log.externalLog`,t,n)||this.logRequest(e).catch(()=>{}))}logRequest(e){var t=this;return n(function*(){let r=`log.externalLog`,i=t.createLogParams(e),a=t.sessionKey??(yield t._authorizeWithBackoff());if(!a)return;let o=function(){var e=n(function*(e,n=t.params.config.requestRetryCount){try{return yield t.params.apiTransport.sendRequest(r,i,a)}catch(i){if(!i||!(`error_code`in i)){t.params.error$.next({id:`logRequestUnknown`,category:O.NETWORK,message:`Unknown ${r} error`,thrown:i});return}let a=i?.error_code;switch(a){case 102:case 103:case 104:return t.authorized$.next(!1),t.sessionKey=yield t._authorizeWithBackoff(),n>0?o(e,n-1):void 0;case 401:return t.authorized$.next(!1),t.authToken=yield t.refreshAuthToken(),t.sessionKey=yield t._authorizeWithBackoff(),n>0?o(e,n-1):void 0;default:t.params.error$.next({id:`LogRequest#${a}`,category:O.EXTERNAL_API,message:`${r} error`,data:i});return}}});return function(t){return e.apply(this,arguments)}}();return o(e)})()}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}refreshAuthToken(){var e=this;return n(function*(){if(e.params.refreshAuthToken)return e.refreshAuthTokenPromise||=E(e.params.refreshAuthToken(),()=>{e.refreshAuthTokenPromise=void 0}),e.refreshAuthTokenPromise})()}createLogParams(e){let t=`WEB`,n=!1,r=`@vkontakte/videoplayer-statistics:${D}`;if(this.params.config.useVKComIsMobileLogic){let{appVersion:e}=window.navigator;n=Ce.test(e)}else this.params.mobile&&(n=!0);return n&&(t=`M_WEB`),this.params.vktvVersion&&(t=`SMART_TV`,r=this.params.vktvVersion),{collector:`ok.mobile.apps.video`,data:JSON.stringify({application:r,platform:t,items:this.params.config.shorten?e.map(be):e})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();let e=Se(this.consequentAuthErrors,this.params.config.backoff);return new Promise(t=>{this.backoffTimeoutId||=window.setTimeout(()=>{E(this._authorize().then(t).catch(e=>this.params.error$.next({id:`AuthorizeBackoff`,category:O.NETWORK,message:`Otherwise unhandled error in authorization`,thrown:e})),()=>this.backoffTimeoutId=0)},e)})}_authorize(){var e=this;return n(function*(){if(e.authorizePromise)return e.authorizePromise;e.sessionKey=void 0,e.authorized$.next(!1);let t={session_data:{version:2,device_id:e.params.deviceId,client_version:D.split(`-`)[0],client_type:`SDK_JS`}};return e.authToken!==void 0&&(t.session_data.auth_token=e.authToken,t.session_data.version=3),e.authorizePromise=E(e.params.apiTransport.sendRequest(`auth.anonymLogin`,t).then(t=>((!t||!t.session_key)&&e.params.error$.next({id:`AuthorizeFailed`,category:O.EXTERNAL_API,message:`No session key`,data:t}),e.sessionKey=t?.session_key??void 0,e.sessionKey)).catch(function(){var t=n(function*(t){e.sessionKey=void 0;let n=t?.error_code;switch(n){case 401:return e.authToken=yield e.refreshAuthToken(),e._authorizeWithBackoff()}n?e.params.error$.next({id:`Authorize#${n}`,category:O.EXTERNAL_API,message:`authorize error`,data:t}):e.params.error$.next({id:`AuthorizeUnknown`,category:O.NETWORK,message:`authorize error`,thrown:t})});return function(e){return t.apply(this,arguments)}}()),()=>{e.authorizePromise=void 0,e.consequentAuthErrors=e.sessionKey?0:e.consequentAuthErrors+1,e.authorized$.next(e.sessionKey!==void 0)}),e.authorizePromise})()}}import{fetchPolyfilled as Te}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Ee}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as De}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as k,now as Oe}from"@vkontakte/videoplayer-shared/es2015";class ke{constructor(t){e(this,`apiKey`,void 0),e(this,`apiBaseUrl`,void 0),e(this,`apiEnv`,void 0),e(this,`timeSynchronisation`,void 0),e(this,`isApiBaseUrlFetched`,void 0),e(this,`params`,void 0),this.params=t,this.apiKey=t.config.apiKey,this.apiEnv=t.config.apiEnv,this.apiBaseUrl=t.config.apiBaseUrl??x[this.apiEnv],this.timeSynchronisation=t.timeSynchronisation,this.isApiBaseUrlFetched=!1}resolveApiBaseUrl(){var e=this;return n(function*(){if(e.apiEnv!==`auto`||e.isApiBaseUrlFetched)return e.apiBaseUrl;try{var t;let e=yield(yield Te(atob(`aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ=`),{method:`GET`,mode:`cors`,cache:`no-cache`})).json(),n=e==null||(t=e.Answer[0])==null?void 0:t.data;if(!n)throw Error(`Wrong DNS response`);return n}catch(t){return e.params.error$.next({id:`OneStat:ApiTransport:resolveApiBaseUrl`,category:k.NETWORK,message:`Unhandled resolve api base url error`,thrown:t}),x.vk_alias}finally{e.isApiBaseUrlFetched=!0}})()}sendBeacon(e,t,n){if(!window.Blob||!window.navigator.sendBeacon)return!1;let r=this._prepareQueryParams({method:e,queryParams:t,sessionKey:n}),i=new window.Blob([r.toString()],{type:`application/x-www-form-urlencoded`});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,i)}catch(n){this.params.error$.next({id:`OneStat:ApiTransport:sendBeacon`,category:k.NETWORK,message:`Unhandled beacon error`,thrown:n,data:{method:e,params:t}})}return!1}sendRequest(e,t,r){var i=this;return n(function*(){let n=Oe(),a=a=>{if(a instanceof TypeError&&Ee([`Failed to fetch`,`NetworkError when attempting to fetch resource.`],a.message)){i.params.error$.next({id:`Network`,category:k.NETWORK,message:`Request failed`,thrown:a});return}i.params.error$.next({id:`OneStat:ApiTransport:sendRequest`,category:k.NETWORK,message:`Unhandled request error`,thrown:a,data:{method:e,params:t,sessionKey:r,time:Oe()-n}})};i.apiBaseUrl=yield i.resolveApiBaseUrl();let o={method:`post`,headers:{"Content-type":`application/x-www-form-urlencoded`},body:i._prepareQueryParams({method:e,queryParams:t,sessionKey:r})};return i.params.config.useKeepalive&&(o.keepalive=!0),Te(`${i.apiBaseUrl}/fb.do`,o).then(e=>{let t=Number(e.headers.get(`content-length`))===0,r=new Date(e.headers.get(`date`)??``).getTime(),o=Oe()-n;if(isFinite(r)&&i.timeSynchronisation?.addServerTime(r,o),!t)return e.json().then(e=>Object.prototype.hasOwnProperty.call(e,`error_msg`)?Promise.reject(e):e,a)},a)})()}_prepareQueryParams(e){let t=new URLSearchParams({format:`JSON`,method:e.method,application_key:this.apiKey});return e.sessionKey!==void 0&&t.append(`session_key`,e.sessionKey),De(e.queryParams).forEach(([e,n])=>t.append(e,typeof n==`string`?n:JSON.stringify(n))),t}}import{arrayIncludes as Ae}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as je}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as Me,now as Ne,safeStorage as A,debounceFn as Pe}from"@vkontakte/videoplayer-shared/es2015";var j=`onestat_events`,Fe=e=>t=>t.timestamp+e>=Ne();class Ie{constructor(t){e(this,`params`,void 0),e(this,`api`,void 0),e(this,`error$`,void 0),e(this,`subscription`,void 0),e(this,`userSalt`,void 0),e(this,`unsaltedStorage`,[]),e(this,`lastVsid`,void 0),e(this,`isPaused`,!1),e(this,`firstFlush`,void 0),e(this,`debouncedFlush`,void 0),e(this,`loggerDebugLog`,void 0),e(this,`isUrgent`,e=>{let{operation:t}=e;return Ae([`action_play`,`watch_coverage_record`,`watch_coverage_live`],t)}),this.params=t,this.api=t.api,this.error$=t.error$,this.userSalt=t.userSalt,this.loggerDebugLog=t.debugLogger.createComponentLog(`stat logger`),this.firstFlush=Pe(()=>this.safeFlush(),this.params.config.firstFlushTime,{maxWait:this.params.config.firstFlushTime});let n=A.isPersistent()?this.params.config.flushMaxWait:0;this.debouncedFlush=Pe(()=>this.safeFlush(),this.params.config.flushDebounceTime,{maxWait:n}),this.subscription=this.api.authorized$.subscribe(e=>{e&&this.debouncedFlush()}),this.housekeepStorage()}safeFlush(){try{this.flush()}catch(e){this.error$.next({id:`LoggerError`,category:Me.WTF,message:e?String(e):`Unknown logger error`,thrown:e})}}readFromStorage(){let e=A.get(j);try{return e?JSON.parse(e):{}}catch{}return{}}addToStorage(e){if(!this.userSalt){this.unsaltedStorage.push(e);return}let n=this.readFromStorage(),r=(n[this.userSalt]??[]).filter(Fe(this.params.config.storageExpiration));A.set(j,JSON.stringify(t(t({},n),{},{[this.userSalt]:[...r,e]})))}getFromStorage(){return this.userSalt?(this.readFromStorage()[this.userSalt]??[]).filter(Fe(this.params.config.storageExpiration)):this.unsaltedStorage}markStorageSent(){if(!this.userSalt){this.unsaltedStorage=[];return}let e=this.readFromStorage();delete e[this.userSalt],A.set(j,JSON.stringify(e))}housekeepStorage(){let e=this.readFromStorage();for(let[t,n]of je(e)){let r=n.filter(Fe(this.params.config.storageExpiration));r.length?e[t]=r:delete e[t],this.loggerDebugLog({message:`${n.length} retrieved from storage, ${r.length} of them actual`})}A.set(j,JSON.stringify(e))}log(e){this.addToStorage(e),!this.isPaused&&(this.isUrgent(e)?this.flush():this.lastVsid===e.custom.vsid?this.debouncedFlush():this.firstFlush(),this.lastVsid=e.custom.vsid)}flush({wantBeacon:e,clearStorage:t}={wantBeacon:!1,clearStorage:!0}){let n=this.getFromStorage();n.length!==0&&(this.api.authorized$.getValue()?(e&&this.params.config.useBeacon?(this.loggerDebugLog({message:`Flushing ${n.length} events through beacon`}),this.api.logBeacon(n)):(this.loggerDebugLog({message:`Flushing ${n.length} events`}),this.api.logRequest(n)),t&&this.markStorageSent()):this.api.authorize(),this.firstFlush.cancel(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe(),this.firstFlush.cancel(),this.debouncedFlush.cancel()}}import{HttpConnectionType as M,Surface as N,VideoFormat as P,VideoQuality as F}from"@vkontakte/videoplayer-core/es2015";import{assertNever as Le}from"@vkontakte/videoplayer-shared/es2015";var Re=e=>e&&{[F.INVARIANT]:`unknown`,[F.Q_144P]:`mobile`,[F.Q_240P]:`lowest`,[F.Q_360P]:`low`,[F.Q_480P]:`medium`,[F.Q_576P]:`unknown`,[F.Q_720P]:`high`,[F.Q_1080P]:`fullhd`,[F.Q_1440P]:`quadhd`,[F.Q_2160P]:`ultrahd`,[F.Q_4320P]:`unknown`}[e],ze=e=>e&&{[M.HTTP1]:`http1`,[M.HTTP2]:`http2`,[M.QUIC]:`http3`}[e],Be=e=>{if(e!==void 0)switch(e){case P.MPEG:return`mp4`;case P.DASH:case P.DASH_LIVE:case P.DASH_STREAMS:return`dash`;case P.DASH_SEP:return`dash_sep`;case P.DASH_ONDEMAND:return`ondemand_dash`;case P.DASH_WEBM:case P.DASH_LIVE_WEBM:return`webm`;case P.DASH_WEBM_AV1:return`av1`;case P.DASH_LIVE_CMAF:return`ondemand_dash_live`;case P.HLS:case P.HLS_LIVE:return`hls`;case P.HLS_FMP4:return`hls_fmp4`;case P.HLS_ONDEMAND:return`ondemand_hls`;case P.HLS_LIVE_CMAF:return`ondemand_hls_live`;case P.WEB_RTC_LIVE:return`webrtc`;default:return Le(e)}},Ve=(e,t)=>{if(t)return`minimal`;switch(e){case void 0:case N.NONE:case N.INLINE:return;case N.FULLSCREEN:return`fullscreen`;case N.SECOND_SCREEN:return`chromecast`;case N.PIP:return`pip`;case N.INVISIBLE:return`invisible`;default:return Le(e)}},He=e=>{switch(e){case`slow-2g`:return`poor`;case`2g`:return`poor`;case`3g`:return`good`;case`4g`:return`excellent`}};class Ue{constructor(t){e(this,`offset`,void 0),this.offset=t}getOffset(){return this.offset??0}setOffset(e){this.offset=e}now(){return Date.now()+(this.offset??0)}date(e=new Date){return e.setTime(e.getTime()+(this.offset??0)),e}addServerTime(e,t){let n=e-Date.now()-t/2;if(Math.abs(n)<1e3){this.offset=0;return}if(this.offset===void 0)this.offset=Math.round(n);else{let e=.2;this.offset=Math.round(e*n+(1-e)*this.offset)}}}import{PlaybackState as We}from"@vkontakte/videoplayer-core/es2015";import{filter as Ge,filterChanged as Ke,fromEvent as qe,isNullable as Je,map as Ye,merge as Xe,Observable as Ze,Subject as Qe,Subscription as $e,ValueSubject as et}from"@vkontakte/videoplayer-shared/es2015";var tt=(e,t)=>new Ze(n=>{let r=new $e,i=Xe(qe(window,`beforeunload`),e.events.willDestruct$),a=new et(void 0),o;r.add(e.info.isLive$.pipe(Ke()).subscribe(t=>{o&&(o.unsubscribe(),a.next(void 0)),o=t?e.info.liveTime$.pipe(Ye(e=>e&&e/1e3)).subscribe(a):e.info.position$.subscribe(a),r.add(o)}));let{playing$:s,paused$:c}=e.events,l=e.events.willSeek$.pipe(Ge(()=>e.info.playbackState$.getValue()===We.PLAYING)),u=e.events.seeked$.pipe(Ge(()=>e.info.playbackState$.getValue()===We.PLAYING)),d=!1,f=new Qe;r.add(l.subscribe(()=>{d||f.next(),d=!0})),r.add(u.subscribe(()=>d=!1));let p=new Qe,m=new Qe,h=Xe(s,u,p),g=Xe(c,f,i,e.events.looped$,m),_,v=()=>_=a.getValue(),y=()=>{let e=a.getValue();Je(_)||_===e||Je(e)||(n.next({from:_,to:e}),_=void 0)},b=()=>{m.next(),p.next()};if(r.add(h.subscribe(v)),r.add(g.subscribe(y)),t.forceInterval&&isFinite(t.forceInterval))if(t.watchCoverageTimeoutFix){let e,n=()=>{e!==void 0&&(window.clearTimeout(e),e=void 0)};r.add(h.subscribe(()=>{n(),e=window.setTimeout(b,t.forceInterval)})),r.add(g.subscribe(()=>n())),r.add(()=>n())}else{let e=0;r.add(h.subscribe(()=>e=window.setTimeout(b,t.forceInterval))),r.add(g.subscribe(()=>window.clearTimeout(e)))}return r});import{Surface as I}from"@vkontakte/videoplayer-core/es2015";import{debounce as nt,filterChanged as rt,Subject as it}from"@vkontakte/videoplayer-shared/es2015";var at=(e,t,n)=>{let r=new it,i=r.pipe(nt(0),rt()),a=!1,o=!1,s=!1;return t(e.inPiP$,e=>{a=e,r.next(e?I.PIP:o?I.FULLSCREEN:s?I.INLINE:void 0)}),t(e.inFullscreen$,e=>{o=e,r.next(e?I.FULLSCREEN:a?I.PIP:s?I.INLINE:void 0)}),n&&t(n.info.surface$,e=>{switch(e){case I.SECOND_SCREEN:case I.NONE:case I.INLINE:!o&&!a&&(e===I.INLINE&&(s=!0),r.next(e));break}}),{surface$:i}},ot=`_one-stat_deviceId`,st=()=>{let e=new fe;return{subscription:e,subscribe:(t,n)=>{t&&e.add(t.subscribe(n))}}};class ct{get vsid$(){return new w(T.getVSID())}constructor(t,n){e(this,`api`,void 0),e(this,`logger`,void 0),e(this,`config`,void 0),e(this,`subscription`,new fe),e(this,`beforeunloadSubscription`,void 0),e(this,`timeSynchronisation`,void 0),e(this,`debugLogger`,new pe),e(this,`oneStatDebugLog`,this.debugLogger.createComponentLog(`onestat`)),e(this,`loopCounter`,0),e(this,`disabled`,!1),e(this,`experimental`,void 0),e(this,`isid$`,new w(void 0)),e(this,`zenUid$`,new w(void 0)),e(this,`statContext`,void 0),e(this,`isEmbed`,void 0),e(this,`embedParent`,void 0),e(this,`uiEvents`,void 0),e(this,`player`,void 0),e(this,`seekAction$`,new w(`unknown`)),e(this,`deviceId`,void 0),this.statContext=t,this.config=te(n.config??{}),S(n.apiEnv)&&(this.config.apiEnv=n.apiEnv),this.config.synchronizeTime&&(this.timeSynchronisation=new Ue);let r=new de;this.experimental={error$:r};let i=ue.get(ot);this.statContext.deviceId?this.deviceId=this.statContext.deviceId:i?this.deviceId=i:(this.deviceId=ne(),ue.set(ot,this.deviceId)),this.resetViewSession(),n.useIsid&&this.isid$.next(n.isid??_e()),this.zenUid$.next(n.zenUid);let a=new ke({config:this.config,error$:r,timeSynchronisation:this.timeSynchronisation});this.api=new we({config:this.config,apiTransport:a,refreshAuthToken:n.refreshAuthToken,mobile:this.statContext.mobile??!1,deviceId:this.deviceId,error$:r,vktvVersion:n.vktvVersion}),this.logger=new Ie({config:this.config,debugLogger:this.debugLogger,api:this.api,error$:r,userSalt:n.userSalt});let{isEmbed:o,topOrigin:s}=me();this.isEmbed=o,this.embedParent=s?new URL(s).hostname:void 0,this.subscribe()}updateContext(e){this.statContext=t(t({},this.statContext),e)}attachTo(e){let t=new fe,n=(e,n)=>t.add(e.subscribe(n));n(e.events.willStart$,()=>{let t=e.info.position$.getValue();this.logActionPlay({position:t}),this.statContext.projectId&&this.logActionPlayInteractive()}),n(e.events.looped$,()=>{this.resetViewSession(),++this.loopCounter>this.config.maxLoops&&(this.disabled=!0),this.logActionPlay({position:e.info.position$.getValue()})}),n(e.events.seeked$,()=>{let t=this.seekAction$.getValue();this.logSeek({action:t===`rich`?`slider`:t,time:e.info.position$.getValue()}),this.seekAction$.next(`unknown`)}),n(e.events.paused$,()=>{this.logPause({position:e.info.position$.getValue()})}),n(e.events.willResume$,()=>{this.logPlay()}),n(e.events.started$,()=>{this.statContext.clip&&this.logWatchCoverageRecord({start:0,end:0})}),n(e.events.playing$,()=>{this.logPlaying()}),n(tt(e,{forceInterval:this.config.watchCoverageInterval,watchCoverageTimeoutFix:this.config.watchCoverageTimeoutFix}),t=>{let n=e.info.isLive$.getValue(),r=e.info.atLiveEdge$.getValue(),i={start:parseFloat(t.from.toFixed(3)),end:parseFloat(t.to.toFixed(3))};if(r){let t=e.info.liveLatency$.getValue()??0,n=e.info.currentBuffer$.getValue()?.end??0,r=e.info.liveBufferTime$.getValue()??0,a=Math.round((t-(n-r))*1e3),o=Math.round(t*1e3);a&&o&&(i.latency=a,i.bufferLatency=o)}n?this.logWatchCoverageLive(i):this.logWatchCoverageRecord(i)});let r;n(e.info.isStalled$,e=>{e?r=C():(S(r)&&this.logEmptyBuffer({duration:C()-r}),r=void 0)});let i=!1;t.add(e.events.fatalError$.pipe(le()).subscribe(()=>i=!0)),n(e.events.willStop$,()=>{if(e.info.isStalled$.getValue()){let e=S(r)?C()-r:void 0;this.logCloseAtEmptyBuffer({duration:e??0}),r=void 0}else i||this.logActionStop()}),n(e.events.managedError$,({id:e})=>{this.logError({fatal:!1,errorType:e})}),n(e.events.fatalError$,({id:e})=>{this.logError({fatal:!0,errorType:e})});let a,o,s=!1;n(e.events.firstBytes$,e=>{a=C(),this.logFirstBytes({time:e})}),n(e.events.willStart$,()=>o=C()),n(e.info.currentBuffer$,e=>{!s&&e&&e.end-e.start>0&&S(a)&&(this.logPlayerReady({duration:C()-a}),s=!0)}),n(e.events.firstFrame$,()=>{S(a)&&!s&&(this.logPlayerReady({duration:C()-a}),s=!0),S(o)&&this.logFirstFrame({time:C()-o})});let c;n(e.info.currentVideoStream$,e=>{e&&(c&&e.id!==c&&this.logTrackSwitch(e),c=e.id)});let l;n(e.info.currentAudioStream$,e=>{e&&(l&&e.id!==l&&this.logTrackSwitch(e),l=e.id)}),n(e.info.atLiveEdge$,e=>this.updateContext({liveEdge:e})),n(ie({muted:e.info.muted$,volume:e.info.volume$}),({muted:e,volume:t})=>this.updateContext({audible:!e&&t>0})),n(e.info.currentQuality$,e=>{let t=Re(e);this.updateContext({quality:t}),t&&this.logQuality(t)}),n(e.info.isAutoQualityEnabled$,e=>this.updateContext({autoQuality:e})),n(e.info.currentFormat$,e=>this.updateContext({contentType:Be(e)})),n(e.info.currentPlaybackRate$,e=>this.updateContext({rate:e})),n(e.info.is3DVideo$,e=>this.updateContext({is3d:e}));let u;return n(e.info.hostname$,e=>{let t=u!==void 0&&u!==e;this.updateContext({cdnHostname:e,failover:t}),t&&this.logFailover(e),u=e}),n(e.info.throughputEstimation$,e=>this.updateContext({downloadSpeed:e})),n(e.info.httpConnectionType$,e=>{this.statContext.firstConnectionType||this.updateContext({firstConnectionType:ze(e)}),this.updateContext({connectionType:ze(e)})}),n(e.info.httpConnectionReused$,e=>{oe(this.statContext.firstConnectionReused)&&this.updateContext({firstConnectionReused:e}),this.updateContext({connectionReused:e})}),n(e.info.surface$,e=>{this.uiEvents||this.updateContext({mode:Ve(e,this.statContext.isPreviewPlayerView)})}),n(ie({current:e.info.currentTextTrack$,available:e.info.availableTextTracks$}),({current:e,available:t})=>{let n=t.find(({id:t})=>t===e),r=n&&(n.isAuto?`${n.language}_auto`:n.language);this.updateContext({subtitles:r?.split(`.`)[0]})}),this.player=e,this.uiEvents&&this.attachToUi(this.uiEvents),this.resubscribeBeforeunload(),this.subscription.add(t),t}attachToUi(e){this.uiEvents=e;let{subscription:t,subscribe:n}=st();if(!this.player)return t;n(e.actionRewind$,()=>{this.player&&(this.resetViewSession(),this.logActionPlay({position:this.player.info.position$.getValue()}))}),n(e.actionSeek$,this.seekAction$);let{surface$:r}=at(this.uiEvents,n,this.player);return n(r,e=>{this.updateContext({mode:Ve(e,this.statContext.isPreviewPlayerView)})}),n(e.actionSetSubtitle$,e=>this.updateContext({subtitles:e?.split(`.`)[0]})),n(e.nextMovie$,e=>this.logNextMovie(e)),this.resubscribeBeforeunload(),this.subscription.add(t),t}attachToAds(e){let{subscription:t,subscribe:n}=st();return n(e.slotRequested$,()=>this.logAdSlotRequest()),n(e.started$,e=>this.logAdStarted(e)),n(e.paused$,()=>this.logAdPaused()),n(e.resumed$,()=>this.logAdResumed()),n(e.ended$,()=>this.logAdEnded()),n(e.skipped$,()=>this.logAdSkipped()),n(e.clicked$,()=>this.logAdClicked()),n(e.error$,e=>this.logError({errorType:e,fatal:!1})),this.resubscribeBeforeunload(),this.subscription.add(t),t}attachToInteractive(e){let{subscription:t,subscribe:n}=st();return n(e.click$,e=>this.logInterfaceClick(e)),n(e.nextMovie$,e=>this.logNextMovie(e)),this.resubscribeBeforeunload(),this.subscription.add(t),t}authorize(e){return this.api.authorize(e)}pause(){this.logger.pause(),this.oneStatDebugLog({message:`paused`})}resume(){this.logger.resume(),this.oneStatDebugLog({message:`resumed`})}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}resetViewSession(){this.oneStatDebugLog({message:`VSID reset`}),T.generateVSID(this.config.useVsid64)}getDeviceId(){return this.deviceId}setFieldBlacklist(){}logInited(){}logReady(e){this.log({operation:`player_ready`,param:String(e.time)})}logStarted(...e){this.logActionPlay(...e)}logPlay(){this.log({operation:`play_toggle`})}logPlaying(){this.log({operation:`playing`})}logPause(e){this.log({operation:`pause`,param:String(Math.round(e.position))})}logSeek(e){this.log({operation:`seek`,param:e.action,time:e.time})}logFirstBytes(e){this.log({operation:`first_bytes`,param:String(e.time)})}logFirstFrame(e){this.log({operation:`first_frame`,param:String(e.time)})}logError(e){this.log({operation:`content_error`,param:`${e.fatal?`fatal`:`recoverable`}_${e.errorType}`})}logWatchCoverageRecord(e){this.log({operation:`watch_coverage_record`,param:`${e.start}-${e.end}`},{in_history:this.statContext.inHistory?1:void 0})}logWatchCoverageLive(e){let t=this.timeSynchronisation?.getOffset()??0,n=e.start+t,r=e.end+t;this.log({operation:`watch_coverage_live`,param:`${n}-${r}`},{in_history:this.statContext.inHistory?1:void 0,latency:e.latency,buffer_latency:e.bufferLatency})}logEmptyBuffer(e){this.log({operation:`empty_buffer`,param:String(e.duration)})}logDownloadSpeed(){}logAdSlotRequest(){this.log({operation:`adv`,param:`slot_request`})}logAdStarted(e){this.log({operation:`adv`,param:e})}logAdPaused(){this.log({operation:`adv`,param:`pause`})}logAdResumed(){this.log({operation:`adv`,param:`resume`})}logAdEnded(){this.log({operation:`adv`,param:`ended`})}logAdSkipped(){this.log({operation:`adv`,param:`skip`})}logAdClicked(){this.log({operation:`adv`,param:`click`})}logInterfaceClick(e){this.log({operation:`player_interface_click`,param:e})}logNextMovie(e){this.log({operation:`next_movie`,param:String(e)})}subscribe(){this.resubscribeBeforeunload();let e=window.navigator.connection;e&&`onchange`in e&&`effectiveType`in e&&this.subscription.add(se(ae(e,`change`),ce([`init`])).subscribe(()=>this.updateContext({network:He(e.effectiveType)}))),this.config.debugLog&&this.debugLogger.log$.subscribe(e=>{console.debug(`%c stat `,`background:#fa6470;`,`component: ${e.component}.`,e.message)})}resubscribeBeforeunload(){this.beforeunloadSubscription?.unsubscribe(),this.beforeunloadSubscription=ae(window,`beforeunload`).subscribe(()=>this.logger.flush({wantBeacon:!0,clearStorage:this.config.clearStorageAtUnload})),this.subscription.add(this.beforeunloadSubscription)}logPlayerReady(e){this.log({operation:`player_ready`,param:String(Math.round(e.duration))})}logActionPlay(e){this.log({operation:`action_play`,param:String(Math.round(e.position))})}logActionPlayInteractive(){this.statContext.projectId&&this.log({operation:`action_play_interactive`,param:String(this.statContext.movieId)},{vid:this.statContext.projectId})}logFailover(e){this.log({operation:`failover`,param:e})}logCloseAtEmptyBuffer(e){this.log({operation:`close_at_empty_buffer`,param:String(Math.round(e.duration))})}logActionStop(){this.log({operation:`action_stop`})}logTrackSwitch(e){this.log({operation:`track_switch`,param:e.id})}logQuality(e){this.log({operation:`quality`,param:e})}log(e,t={}){if(this.disabled){this.oneStatDebugLog({message:`operation ${e.operation} but statistics is disabled`});return}if(s(this.config.disabledOperations,e.operation)){this.oneStatDebugLog({message:`operation ${e.operation} but it is disabled`});return}this.oneStatDebugLog({message:`operation ${e.operation} ${e.param}`});let n=this.createLogItem(e,t);this.logger.log(n)}createLogItem({operation:e,param:n,time:r},i={}){let a=this.timeSynchronisation?.now()??C(),o=this.vsid$.getValue();re(o);let l=this.isid$.getValue(),u=e===`empty_buffer`||e===`close_at_empty_buffer`?this.statContext.connectionType:this.statContext.firstConnectionType,d=this.statContext.firstConnectionReused,f,p;if(this.isEmbed||this.statContext.place===`embed`){f=this.embedParent;let e=[...new URLSearchParams(location.search).entries()].filter(([e,t])=>s(this.config.embedUrlParams,e));p=new URLSearchParams(e).toString()}else if(this.statContext.place===`direct`){let e=this.statContext.refDomain||document.referrer;f=e&&c(URL,e)?new URL(e).hostname:e,p=location.href.substring(0,1024)}let m=t({vsid:o,isid:l,vid:this.statContext.movieId,uid:this.zenUid$.getValue(),ct:this.statContext.contentType,place:this.isEmbed?`embed`:this.statContext.place,quality:this.statContext.quality,cdn_host:this.statContext.cdnHostname,stat_type:this.statContext.autoplay===!0?`auto`:this.statContext.autoplay===!1?``:void 0,param:n,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode,connection_type:u,connection_reused:d===!0?1:d===!1?0:void 0,cached_data:this.statContext.cached===!0?1:this.statContext.cached===!1?0:void 0,live:this.statContext.liveEdge?1:void 0,muted:this.statContext.audible===!1?1:void 0,mode:this.statContext.mode,subtitles:this.statContext.subtitles,download_speed:this.statContext.downloadSpeed,manual_quality:this.statContext.autoQuality?void 0:1,ref_domain:f,direct_url:p,rate:this.statContext.rate===1||oe(this.statContext.rate)?void 0:this.statContext.rate.toFixed(2),view_360:this.statContext.is3d?1:void 0,aid:this.statContext.albumId,vk_playlist_id:this.statContext.vkPlaylistId},i);for(let e of this.config.disabledCustomFields)delete m[e];return{operation:e,type:1,time:r,network:this.statContext.network,timestamp:a,custom:m}}}var lt={};o(lt,{VERSION:()=>D,ThinOneStat:()=>Mn,ActionSeekType:()=>Dt});import{objectValues as ut}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as dt}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as ft,detectEmbed as pt,fromEvent as mt,Logger as ht,merge as gt,combine as L,filter as R,filterChanged as _t,once as vt,skip as yt,debounce as bt,safeStorage as xt,getWindow as St,Subject as Ct,Subscription as wt,ValueSubject as z,ErrorCategory as B}from"@vkontakte/videoplayer-shared/es2015";import{clientChecker as V}from"@vkontakte/videoplayer-core/es2015";import{fillWithDefault as Tt}from"@vkontakte/videoplayer-shared/es2015";var Et;(e=>{e.AUTO=`auto`,e.AUTO_POOR=`auto_poor`,e.AUTO_RICH=`auto_rich`})(Et||={});var Dt;(e=>{e.SLIDER=`slider`,e.RICH=`rich`,e.DOUBLE_TAP=`double_tap`,e.TIME_CODE=`time_code`,e.EPISODE=`episode`,e.REWIND=`rewind`,e.LIVE=`live`,e.UNKNOWN=`unknown`})(Dt||={});var Ot=`CIOPGQJGDIHBABABA`,kt={prod:`https://api.ok.ru`,vk_alias:`https://api.mycdn.me`,videotest:`https://videotestapi.ok.ru/api`,test:`https://apitest.ok.ru`,okcdn:`https://api.okcdn.ru`,auto:``},At={apiKey:Ot,apiEnv:`okcdn`,apiBaseUrl:null,requestRetryCount:1,useVsid64:!1,firstFlushTime:5e3,flushDebounceTime:1e4,flushMaxWait:6e4,storageExpiration:2160*60*1e3,watchCoverageHeartbeatInterval:3e4,disabledEvents:[],disabledParams:[],synchronizeTime:!0,useBeacon:!1,alwaysSendDesktop:!1,watchedNDefaultTargetDuration:1e3,telemetryInterval:3e4,downloadBytesMaxTime:3e4},jt=e=>Tt(e,At);import{promiseFinally as Mt}from"@vkontakte/videoplayer-shared/es2015";import{getExponentialDelay as Nt,ErrorCategory as H,ValueSubject as Pt}from"@vkontakte/videoplayer-shared/es2015";class Ft{constructor(t){e(this,`authorized$`,void 0),e(this,`params`,void 0),e(this,`authToken`,void 0),e(this,`sessionKey`,void 0),e(this,`authorizePromise`,void 0),e(this,`refreshAuthTokenPromise`,void 0),e(this,`consequentAuthErrors`,void 0),e(this,`backoffTimeoutId`,void 0),this.params=t,this.authorized$=new Pt(!1),this.consequentAuthErrors=0}authorize(e){var t=this;return n(function*(){return t.authToken=e??(yield t.refreshAuthToken()),t.authorizeWithBackoff()})()}logBeacon(e){let t=this.createLogParams(e),n=this.sessionKey;n&&(this.params.apiTransport.sendBeacon(`log.logUvStat`,t,n)||this.logRequest(e).catch(()=>{}))}logRequest(e){var t=this;return n(function*(){let r=`log.logUvStat`,i=t.createLogParams(e),a={},o=t.sessionKey??(yield t.authorizeWithBackoff());if(!o)return;let s=function(){var e=n(function*(e,n=t.params.config.requestRetryCount){try{return yield t.params.apiTransport.sendRequest(r,i,o,a)}catch(i){if(!i||!(`error_code`in i)){t.params.error$.next({id:`logRequestUnknown`,category:H.NETWORK,message:`Unknown ${r} error`,thrown:i});return}let a=i?.error_code;switch(a){case 102:case 103:case 104:return t.authorized$.next(!1),t.sessionKey=yield t.authorizeWithBackoff(),n>0?s(e,n-1):void 0;case 401:return t.authorized$.next(!1),t.authToken=yield t.refreshAuthToken(),t.sessionKey=yield t.authorizeWithBackoff(),n>0?s(e,n-1):void 0;default:t.params.error$.next({id:`LogRequest#${a}`,category:H.EXTERNAL_API,message:`${r} error`,data:i});return}}});return function(t){return e.apply(this,arguments)}}();return s(e)})()}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}refreshAuthToken(){var e=this;return n(function*(){if(e.params.refreshAuthToken)return e.refreshAuthTokenPromise||=Mt(e.params.refreshAuthToken(),()=>{e.refreshAuthTokenPromise=void 0}),e.refreshAuthTokenPromise})()}createLogParams(e){return{collector:`ok.mobile.apps.video`,uv_stat_data:JSON.stringify({application:`@vkontakte/videoplayer-statistics:${D}`,platform:e[0].platform,product:e[0].product,events:e})}}authorizeWithBackoff(){var e=this;if(!this.consequentAuthErrors)return this.doAuthorize();let t=Nt(this.consequentAuthErrors);return new Promise(r=>{this.backoffTimeoutId||=window.setTimeout(n(function*(){try{r(yield e.doAuthorize())}catch(t){e.params.error$.next({id:`AuthorizeBackoff`,category:H.NETWORK,message:`Otherwise unhandled error in authorization`,thrown:t})}finally{e.backoffTimeoutId=0}}),t)})}doAuthorize(){var e=this;if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);let t={session_data:{version:2,device_id:this.params.deviceId,client_version:D.split(`-`)[0],client_type:`SDK_JS`}};return this.authToken!==void 0&&(t.session_data.auth_token=this.authToken,t.session_data.version=3),this.authorizePromise=Mt(this.params.apiTransport.sendRequest(`auth.anonymLogin`,t).then(e=>((!e||!e.session_key)&&this.params.error$.next({id:`AuthorizeFailed`,category:H.EXTERNAL_API,message:`No session key`,data:e}),this.sessionKey=e?.session_key??void 0,this.sessionKey)).catch(function(){var t=n(function*(t){e.sessionKey=void 0;let n=t?.error_code;switch(n){case 401:return e.authToken=yield e.refreshAuthToken(),e.authorizeWithBackoff()}n?e.params.error$.next({id:`Authorize#${n}`,category:H.EXTERNAL_API,message:`authorize error`,data:t}):e.params.error$.next({id:`AuthorizeUnknown`,category:H.NETWORK,message:`authorize error`,thrown:t})});return function(e){return t.apply(this,arguments)}}()),()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise}}import{arrayIncludes as It}from"@vkontakte/videoplayer-shared/es2015";import{fetchPolyfilled as Lt}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as Rt}from"@vkontakte/videoplayer-shared/es2015";import{now as zt,ErrorCategory as U}from"@vkontakte/videoplayer-shared/es2015";class Bt{constructor(t){e(this,`params`,void 0),e(this,`apiKey`,void 0),e(this,`apiBaseUrl`,void 0),e(this,`apiEnv`,void 0),e(this,`isApiBaseUrlFetched`,void 0),e(this,`timeSynchronisation`,void 0),this.params=t,this.apiKey=t.config.apiKey,this.apiEnv=t.config.apiEnv,this.apiBaseUrl=t.config.apiBaseUrl??kt[this.apiEnv],this.timeSynchronisation=t.timeSynchronisation,this.isApiBaseUrlFetched=!1}sendBeacon(e,t,n){if(!window.Blob||!window.navigator.sendBeacon)return!1;let r=this.prepareQueryParams({method:e,queryParams:t,sessionKey:n}),i=new window.Blob([r.toString()],{type:`application/x-www-form-urlencoded`});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,i)}catch(n){this.params.error$.next({id:`OneStat:ApiTransport:sendBeacon`,category:U.NETWORK,message:`Unhandled beacon error`,thrown:n,data:{method:e,params:t}})}return!1}sendRequest(e,r,i,a){var o=this;return n(function*(){let n=zt(),s=t=>{if(t instanceof TypeError&&It([`Failed to fetch`,`NetworkError when attempting to fetch resource.`],t.message)){o.params.error$.next({id:`Network`,category:U.NETWORK,message:`Request failed`,thrown:t});return}o.params.error$.next({id:`ThinOneStat:ApiTransport:sendRequest`,category:U.NETWORK,message:`Unhandled request error`,thrown:t,data:{method:e,params:r,sessionKey:i,time:zt()-n}})};return o.apiBaseUrl=yield o.resolveApiBaseUrl(),Lt(`${o.apiBaseUrl}/fb.do`,{method:`post`,headers:t({"Content-type":`application/x-www-form-urlencoded`},a),body:o.prepareQueryParams({method:e,queryParams:r,sessionKey:i})}).then(e=>{let t=Number(e.headers.get(`content-length`))===0,r=new Date(e.headers.get(`date`)??``).getTime(),i=zt()-n;if(isFinite(r)&&o.timeSynchronisation?.addServerTime(r,i),!t)return e.json().then(e=>Object.prototype.hasOwnProperty.call(e,`error_msg`)?Promise.reject(e):e,s)},s)})()}resolveApiBaseUrl(){var e=this;return n(function*(){if(e.apiEnv!==`auto`||e.isApiBaseUrlFetched)return e.apiBaseUrl;try{var t;let e=yield(yield Lt(atob(`aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ=`),{method:`GET`,mode:`cors`,cache:`no-cache`})).json(),n=e==null||(t=e.Answer[0])==null?void 0:t.data;if(!n)throw Error(`Wrong DNS response`);return n}catch(t){return e.params.error$.next({id:`ThinOneStat:ApiTransport:resolveApiBaseUrl`,category:U.NETWORK,message:`Unhandled resolve api base url error`,thrown:t}),kt.vk_alias}finally{e.isApiBaseUrlFetched=!0}})()}prepareQueryParams(e){let t=new URLSearchParams({format:`JSON`,method:e.method,application_key:this.apiKey});return e.sessionKey!==void 0&&t.append(`session_key`,e.sessionKey),Rt(e.queryParams).forEach(([e,n])=>t.append(e,typeof n==`string`?n:JSON.stringify(n))),t}}import{arrayIncludes as Vt}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as Ht}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as Ut,now as Wt,safeStorage as W,debounceFn as Gt}from"@vkontakte/videoplayer-shared/es2015";var G=`thinonestat_events`,Kt=e=>t=>t.client_time+e>=Wt();class qt{constructor(t){e(this,`params`,void 0),e(this,`api`,void 0),e(this,`error$`,void 0),e(this,`subscription`,void 0),e(this,`userSalt`,void 0),e(this,`unsaltedStorage`,[]),e(this,`lastVsid`,void 0),e(this,`isPaused`,!1),e(this,`firstFlush`,void 0),e(this,`debouncedFlush`,void 0),e(this,`loggerDebugLog`,void 0),e(this,`isUrgent`,e=>{let{event_name:t}=e;return Vt([`watch_coverage`,`watch_coverage_live`,`watched_n`,`playback_started`],t)}),this.params=t,this.api=t.api,this.error$=t.error$,this.userSalt=t.userSalt,this.loggerDebugLog=t.debugLogger.createComponentLog(`stat logger`),this.firstFlush=Gt(()=>this.safeFlush(),this.params.config.firstFlushTime,{maxWait:this.params.config.firstFlushTime});let n=W.isPersistent()?this.params.config.flushMaxWait:0;this.debouncedFlush=Gt(()=>this.safeFlush(),this.params.config.flushDebounceTime,{maxWait:n}),this.subscription=this.api.authorized$.subscribe(e=>{e&&this.debouncedFlush()}),this.housekeepStorage()}safeFlush(){try{this.flush()}catch(e){this.error$.next({id:`LoggerError`,category:Ut.WTF,message:String(e)||`Unknown logger error`,thrown:e})}}readFromStorage(){let e=W.get(G);try{return e?JSON.parse(e):{}}catch{}return{}}addToStorage(e){if(!this.userSalt){this.unsaltedStorage.push(e);return}let n=this.readFromStorage(),r=(n[this.userSalt]??[]).filter(Kt(this.params.config.storageExpiration));W.set(G,JSON.stringify(t(t({},n),{},{[this.userSalt]:[...r,e]})))}getFromStorage(){return this.userSalt?(this.readFromStorage()[this.userSalt]??[]).filter(Kt(this.params.config.storageExpiration)):this.unsaltedStorage}markStorageSent(){if(!this.userSalt){this.unsaltedStorage=[];return}let e=this.readFromStorage();delete e[this.userSalt],W.set(G,JSON.stringify(e))}housekeepStorage(){let e=this.readFromStorage();for(let[t,n]of Ht(e)){let r=n.filter(Kt(this.params.config.storageExpiration));r.length?e[t]=r:delete e[t],this.loggerDebugLog({message:`${n.length} retrieved from storage, ${r.length} of them actual`})}W.set(G,JSON.stringify(e))}log(e){this.addToStorage(e),!this.isPaused&&(this.isUrgent(e)?this.flush():this.lastVsid===e.vsid?this.debouncedFlush():this.firstFlush(),this.lastVsid=e.vsid)}flush({wantBeacon:e,clearStorage:t}={wantBeacon:!1,clearStorage:!0}){let n=this.getFromStorage();n.length!==0&&(this.api.authorized$.getValue()?(e&&this.params.config.useBeacon?(this.loggerDebugLog({message:`Flushing ${n.length} events through beacon`}),this.api.logBeacon(n)):(this.loggerDebugLog({message:`Flushing ${n.length} events`}),this.api.logRequest(n)),t&&this.markStorageSent()):this.api.authorize(),this.firstFlush.cancel(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe(),this.firstFlush.cancel(),this.debouncedFlush.cancel()}}function Jt(){let e=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`.split(``),t=Array(36),n=0,r,i;for(i=0;i<36;i++)i===8||i===13||i===18||i===23?t[i]=`-`:i===14?t[i]=`4`:(n<=2&&(n=33554432+Math.random()*16777216|0),r=n&15,n>>=4,t[i]=e[i===19?r&3|8:r]);return t.join(``)}class Yt{constructor(t){e(this,`offset`,void 0),this.offset=t}getOffset(){return this.offset??0}setOffset(e){this.offset=e}now(){return Date.now()+(this.offset??0)}date(e=new Date){return e.setTime(e.getTime()+(this.offset??0)),e}addServerTime(e,t){let n=e-Date.now()-t/2;if(Math.abs(n)<1e3){this.offset=0;return}if(this.offset===void 0)this.offset=Math.round(n);else{let e=.2;this.offset=Math.round(e*n+(1-e)*this.offset)}}}import{PlaybackState as Xt}from"@vkontakte/videoplayer-core/es2015";import{Observable as Zt,Subscription as Qt,ValueSubject as $t,Subject as en,fromEvent as tn,isNullable as nn,merge as K,filter as rn,filterChanged as an,getWindow as on}from"@vkontakte/videoplayer-shared/es2015";var sn=(e,t,n)=>new Zt(r=>{let i=new Qt,a=new $t(void 0),o;i.add(e.info.isLive$.pipe(an()).subscribe(t=>{o&&(o.unsubscribe(),a.next(void 0)),o=t?e.info.liveTime$.pipe(an()).subscribe(a):e.info.position$.subscribe(a),i.add(o)}));let{playing$:s,paused$:c,ended$:l,looped$:u}=e.events,d=e.events.willSeek$.pipe(rn(()=>e.info.playbackState$.getValue()===Xt.PLAYING)),f=e.events.seeked$.pipe(rn(()=>e.info.playbackState$.getValue()===Xt.PLAYING)),p=!1,m=new en;i.add(d.subscribe(()=>{p||m.next(),p=!0})).add(f.subscribe(()=>p=!1));let h=K(tn(on(),`beforeunload`),e.events.willDestruct$),g,_=()=>g=a.getValue(),v=()=>{let e=a.getValue();nn(g)||nn(e)||g===e||(r.next({from:g,to:e}),g=void 0)},y=new en,b=new en,x=K(s,f,y),ee=K(c,m,h,l,u,b),te=t.started$&&t.ended$?K(x,t.ended$):x,ne=t.started$&&t.ended$?K(ee,t.started$):ee;if(i.add(te.subscribe(_)).add(ne.subscribe(v)),n.heartbeatInterval&&isFinite(n.heartbeatInterval)){let e=[],t=()=>{b.next(),y.next()};i.add(te.subscribe(()=>{let r=on().setTimeout(t,n.heartbeatInterval);e.push(r)})).add(ne.subscribe(()=>{e.forEach(e=>{on().clearTimeout(e)}),e=[]}))}return i});import{Subscription as cn}from"@vkontakte/videoplayer-core/es2015";import{Observable as ln,merge as un}from"@vkontakte/videoplayer-shared/es2015";var dn=(e,t)=>new ln(n=>{let r=new cn;return r.add(un(e.info.position$,e.info.liveTime$).subscribe(()=>{let e=t.getTotalViewTime();e>=t.targetDuration&&(n.next({target_duration:t.targetDuration,current_tvt:e}),r.unsubscribe())})),r});import{Subscription as fn}from"@vkontakte/videoplayer-core/es2015";import{Observable as pn,filter as mn,getWindow as hn}from"@vkontakte/videoplayer-shared/es2015";var gn=(e,{maxTimeWindow:t})=>new pn(n=>{let r=new fn,i={maxBytesThreshold:100*1024*1024,minBytesThreshold:100*1024,maxTimeWindow:t,minTimeWindow:2e3},a={bytes:0,startTime:0,lastEmitTime:0,timeoutId:0},o=()=>{a.timeoutId&&=(hn().clearTimeout(a.timeoutId),null)},s=()=>{a.bytes=0,a.startTime=0,a.lastEmitTime=0,o()},c=e=>{if(a.bytes<i.minBytesThreshold||e-a.lastEmitTime<i.minTimeWindow&&a.lastEmitTime>0)return!1;let t=(a.startTime>0?e-a.startTime:0)>=i.maxTimeWindow,n=a.bytes>=i.maxBytesThreshold;return t||n},l=(e=!1)=>{let t=Date.now();if(!e&&!c(t))return;o();let r=a.startTime>0?t-a.startTime:Math.max(i.minTimeWindow,1),l=a.bytes/(r/1e3);n.next({download_bytes:Math.round(a.bytes),download_speed:Math.round(l)}),a.lastEmitTime=t,s()},u=()=>{if(o(),a.startTime>0&&a.bytes>=i.minBytesThreshold){let e=Date.now()-a.startTime,t=i.maxTimeWindow-e;t>100?a.timeoutId=hn().setTimeout(()=>{a.timeoutId=null,l()},t):t>0&&l()}};return r.add(e.info.httpDownloadMetrics$.pipe(mn(e=>e!==void 0)).subscribe(e=>{let t=Date.now();a.startTime===0&&(a.startTime=t),a.bytes+=e.bytes,c(t)?l():u()})),r.add(()=>{if(o(),a.bytes>0){let e=Date.now(),t=a.startTime>0?e-a.startTime:i.minTimeWindow,r=a.bytes/(t/1e3);n.next({download_bytes:Math.round(a.bytes),download_speed:Math.round(r)})}s()}),r});import{Observable as _n,Subscription as vn,merge as yn}from"@vkontakte/videoplayer-shared/es2015";var bn=e=>new _n(t=>{let n=new vn,r=0,i=1,a=0,o=!1,s=!1,c=()=>{if(!o)return;let e=Date.now();a+=(e-r)*i,r=e},l=()=>{(!o||s)&&(r=Date.now(),o=!0,s=!1)},u=()=>{o&&=(c(),!1)},d=()=>{o&&(c(),o=!1,s=!0)},f=e=>{o&&c(),i=e,r=Date.now()},{started$:p,playing$:m,paused$:h,willSeek$:g,ended$:_,willDestruct$:v}=e.events,{currentPlaybackRate$:y}=e.info;return n.add(g.subscribe(d)).add(yn(p,m).subscribe(l)).add(yn(h,_,v).subscribe(u)).add(y.subscribe(f)),t.next(()=>{let e=a;return o&&(e+=(Date.now()-r)*i),e}),n});import{Observable as xn,Subscription as Sn,merge as Cn}from"@vkontakte/videoplayer-shared/es2015";var wn=(e,t)=>new xn(n=>{let r=new Sn,i=0;return r.add(Cn(e.info.position$,e.info.liveTime$).subscribe(()=>{let e=t.getTotalViewTime();e>i&&Math.floor(e/t.interval)>Math.floor(i/t.interval)&&(i=e,n.next())})),r});import{assertNever as Tn}from"@vkontakte/videoplayer-shared/es2015";import{HttpConnectionType as q,Surface as J,VideoFormat as Y,VideoQuality as X}from"@vkontakte/videoplayer-core/es2015";var En=e=>e&&{[q.HTTP1]:`http1`,[q.HTTP2]:`http2`,[q.QUIC]:`http3`}[e],Z=e=>{if(e!==void 0)switch(e){case Y.MPEG:return`MP4`;case Y.DASH:case Y.DASH_LIVE:return`DASH`;case Y.DASH_SEP:return`DASH_SEP`;case Y.DASH_ONDEMAND:return`ONDEMAND_DASH`;case Y.HLS_ONDEMAND:return`ONDEMAND_HLS`;case Y.HLS:case Y.HLS_LIVE:return`HLS`;case Y.HLS_FMP4:return`HLS_FMP4`;case Y.DASH_WEBM:case Y.DASH_LIVE_WEBM:return`WEBM`;case Y.DASH_LIVE_CMAF:return`ONDEMAND_DASH_LIVE`;case Y.HLS_LIVE_CMAF:return`ONDEMAND_HLS_LIVE`;case Y.WEB_RTC_LIVE:return`WEBRTC`;case Y.DASH_WEBM_AV1:return`AV1`;case Y.DASH_STREAMS:return`MULTI_DASH`;default:return Tn(e)}},Q=e=>{if(e!==void 0)switch(e){case X.Q_144P:return`144p`;case X.Q_240P:return`240p`;case X.Q_360P:return`360p`;case X.Q_480P:return`480p`;case X.Q_720P:return`720p`;case X.Q_1080P:return`1080p`;case X.Q_1440P:return`1440p`;case X.Q_2160P:return`2160p`;case X.INVARIANT:case X.Q_576P:case X.Q_4320P:return`UNKNOWN`;default:return Tn(e)}},Dn=e=>{if(e!==void 0)switch(e){case`MP4`:case`ONDEMAND_DASH`:case`ONDEMAND_DASH_LIVE`:case`ONDEMAND_HLS`:case`ONDEMAND_HLS_LIVE`:case`MULTI_DASH`:case`WEBM`:case`AV1`:return`vod`;case`DASH`:case`HLS`:case`HLS_FMP4`:case`WEBRTC`:return`live`;default:return}},$=(e,t,n)=>{if(e&&t)switch(e){case Y.MPEG:return n&&t[e]&&t[e][n];default:return t[e]?.url}},On=(e,t=!1)=>{if(t)return`minimal`;switch(e){case void 0:case J.NONE:return;case J.INLINE:return`inline`;case J.FULLSCREEN:return`fullscreen`;case J.SECOND_SCREEN:return`chromecast`;case J.PIP:return`pip_external`}},kn=e=>{switch(e){case void 0:return;case J.INVISIBLE:return`background`;default:return`foreground`}},An=`_thin-one-stat_deviceId`,jn=()=>{let e=new wt;return{subscription:e,subscribe:(t,n)=>{t&&e.add(t.subscribe(n))}}};class Mn{get vsid$(){return new z(T.getVSID())}constructor(t,n){e(this,`api`,void 0),e(this,`logger`,void 0),e(this,`config`,void 0),e(this,`subscription`,void 0),e(this,`beforeunloadSubscription`,void 0),e(this,`timeSynchronisation`,void 0),e(this,`statContext`,void 0),e(this,`deviceId`,void 0),e(this,`targetDuration`,void 0),e(this,`debugLogger`,new ht),e(this,`thinOneStatDebugLog`,this.debugLogger.createComponentLog(`ThinOneStat`)),e(this,`eventNumber`,1),e(this,`isStarted`,void 0),e(this,`wasPaused`,void 0),e(this,`isLive`,void 0),e(this,`position`,void 0),e(this,`cdnHostname`,void 0),e(this,`isEmbed`,void 0),e(this,`embedHostname`,void 0),e(this,`connectionType`,void 0),e(this,`connectionReused`,void 0),e(this,`player`,void 0),e(this,`playerSize`,{width:0,height:0}),e(this,`currentSubtitle`,void 0),e(this,`userQuality`,void 0),e(this,`downloadQuality`,void 0),e(this,`downloadSpeed`,void 0),e(this,`networkType`,void 0),e(this,`uiEvents`,void 0),e(this,`seekAction$`,new z(`unknown`)),e(this,`isid$`,new z(void 0)),e(this,`getTotalViewTime`,()=>0),this.statContext=t,this.config=jt(n.config??{}),this.subscription=new wt,this.config.synchronizeTime&&(this.timeSynchronisation=new Yt);let r=new Ct,i=xt.get(An);this.statContext.deviceId?this.deviceId=this.statContext.deviceId:i?this.deviceId=i:(this.deviceId=Jt(),xt.set(An,this.deviceId)),this.statContext.targetDuration?this.targetDuration=this.statContext.targetDuration:this.targetDuration=this.config.watchedNDefaultTargetDuration,this.resetViewSession(),n.useIsid&&this.isid$.next(n.isid??_e());let a=new Bt({error$:r,config:this.config,timeSynchronisation:this.timeSynchronisation});this.api=new Ft({config:this.config,apiTransport:a,error$:r,deviceId:this.deviceId,refreshAuthToken:n.refreshAuthToken}),this.logger=new qt({config:this.config,debugLogger:this.debugLogger,api:this.api,error$:r,userSalt:n.userSalt});let{isEmbed:o,topOrigin:s}=pt();this.isEmbed=o,this.embedHostname=s?new URL(s).hostname:void 0}authorize(e){return this.api.authorize(e)}updateContext(e){this.statContext=t(t({},this.statContext),e)}attachTo(e,n){let r=new wt,i=(e,t)=>r.add(e.subscribe(t));i(bn(e),e=>{this.getTotalViewTime=e}),i(e.info.isLive$,e=>this.isLive=e),i(e.info.hostname$.pipe(R(e=>e!==void 0)),e=>{this.cdnHostname=e});let a;i(L({hostname:e.info.hostname$,connectionType:e.info.httpConnectionType$,connectionReused:e.info.httpConnectionReused$}).pipe(R(({hostname:e})=>e!==void 0),R(({connectionType:e})=>e!==void 0),R(({connectionReused:e})=>e!==void 0)),({hostname:t,connectionType:n,connectionReused:r})=>{if(a!==void 0&&a!==t){let i={cdn_host:t,connection_type:En(n),connection_reused:r,content_type:Z(e.info.currentFormat$.getValue())};this.logFailover(i)}this.cdnHostname=a=t}),i(e.info.httpConnectionType$,e=>{this.connectionType=En(e)}),i(e.info.httpConnectionReused$,e=>{this.connectionReused=e}),i(sn(e,n,{heartbeatInterval:this.config.watchCoverageHeartbeatInterval}),n=>{let r={watch_interval:`${Math.round(n.from*1e3)}-${Math.round(n.to*1e3)}`,in_history:!!this.statContext.inHistory,content_type:Z(e.info.currentFormat$.getValue()),playback_quality:Q(e.info.currentQuality$.getValue()),recom_info:this.statContext.recomInfo};if(!e.info.isLive$.getValue())this.logWatchCoverage(r);else{let n=e.info.atLiveEdge$.getValue();this.logWatchCoverageLive(t(t({},r),{},{live:!!n}))}}),i(wn(e,{interval:this.statContext.telemetryInterval??this.config.telemetryInterval,getTotalViewTime:this.getTotalViewTime}),()=>{this.logTelemetry(this.collectTelemetryData())}),i(dn(e,{targetDuration:this.targetDuration,getTotalViewTime:this.getTotalViewTime}),e=>{this.logWatchedN(e)}),i(e.events.willReady$,()=>{if(this.statContext.preload){let t=e.info.currentFormat$.getValue(),n=e.info.availableSources$.getValue(),r=e.info.currentBuffer$.getValue(),i=e.info.currentQuality$.getValue(),a={target_buffer_time:this.calcBufferTime(r),playback_url:$(t,n,i),playback_quality:Q(i)};this.logPreloadStarted(a)}}),i(L({manifestRequested$:e.events.manifestRequested$,connectionType:e.info.httpConnectionType$,connectionReused:e.info.httpConnectionReused$}).pipe(R(({connectionType:e})=>e!==void 0),R(({connectionReused:e})=>e!==void 0),vt()),()=>{let t={playback_url:$(e.info.currentFormat$.getValue(),e.info.availableSources$.getValue(),e.info.currentQuality$.getValue()),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused};this.logManifestRequest(t)}),i(L({firstBytesManifest:e.events.firstBytesManifest$,connectionType:e.info.httpConnectionType$,connectionReused:e.info.httpConnectionReused$}).pipe(R(({connectionType:e})=>e!==void 0),R(({connectionReused:e})=>e!==void 0),vt()),()=>{let t={playback_url:$(e.info.currentFormat$.getValue(),e.info.availableSources$.getValue(),e.info.currentQuality$.getValue()),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused};this.logFirstByteManifest(t)}),i(e.events.manifestReceived$,()=>{let t={playback_url:$(e.info.currentFormat$.getValue(),e.info.availableSources$.getValue(),e.info.currentQuality$.getValue()),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused};this.logManifestReceived(t)}),i(e.events.firstBytesRequested$,()=>{let t={playback_url:$(e.info.currentFormat$.getValue(),e.info.availableSources$.getValue(),e.info.currentQuality$.getValue()),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused};this.logFirstMediaRequest(t)}),i(e.events.firstBytesReceived$,()=>{let t={playback_url:$(e.info.currentFormat$.getValue(),e.info.availableSources$.getValue(),e.info.currentQuality$.getValue()),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused};this.logFirstByteMedia(t)}),i(gt(e.events.willStart$,e.events.looped$),t=>{t&&this.resetViewSession();let n={isid:this.isid$.getValue(),stream_profile:Dn(Z(e.info.currentFormat$.getValue())),dpi:this.statContext.dpi??96*V.display.pixelRatio,web_layout:this.statContext.isMobile||V.device.isMobile?`mobile`:`desktop`,preloaded:this.statContext.preload,navigation:this.statContext.navigation,recom_info:this.statContext.recomInfo};this.isEmbed&&(n.iframe_host=this.embedHostname??`unknown`),this.logStartSession(n)}),i(e.events.started$,()=>{this.isStarted=!0;let t=e.info.currentBuffer$.getValue(),n=e.info.currentQuality$.getValue(),r=e.info.isAutoQualityEnabled$.getValue(),i=e.info.muted$.getValue(),a=e.info.volume$.getValue(),o=e.info.surface$.getValue(),s=e.info.availableTextTracks$.getValue(),c=e.info.currentTextTrack$.getValue(),l=e.info.currentAudioStream$.getValue(),u=e.info.currentPlaybackRate$.getValue(),d={playback_quality:Q(n),user_quality:r?`auto`:Q(n),player_width:this.statContext.playerSize?.width??this.playerSize.width,player_height:this.statContext.playerSize?.height??this.playerSize.height,muted:i,sound_volume:Math.round(a*100),buffer_time:this.calcBufferTime(t),mode:On(o,this.statContext.isPreviewPlayerView),visibility:kn(o),subtitles_enabled:c?!!c:this.currentSubtitle?.enabled,auto_subtitles:s.find(({id:e})=>e===c)?.isAuto??this.currentSubtitle?.auto,audio_track_lang:l?.language,playback_rate:u,recom_info:this.statContext.recomInfo};this.logPlaybackStarted(d)}),i(e.events.willStart$,()=>{this.logPlay()}),i(e.events.playing$,()=>{let t=e.info.currentBuffer$.getValue(),n={buffer_time:this.calcBufferTime(t)};this.logPlaying(n),this.wasPaused&&this.logResume()}),i(e.events.paused$,()=>{this.wasPaused=!0,this.logPause()}),i(e.events.willStop$,()=>{this.isStarted=!1,this.logStop()}),i(gt(e.events.fetcherRecoverableError$,e.events.fatalError$),()=>{this.statContext.preload&&this.logPreloadError()});let o=e=>{switch(e){case B.NETWORK:return`network`;case B.VIDEO_PIPELINE:return`video_pipeline`;case B.EXTERNAL_API:return`external_api`;case B.PARSER:return`parser`;case B.DOM:return`dom`;default:return`wtf`}},s=e=>B.FATAL===e?`critical`:`informative`;i(e.events.fetcherRecoverableError$,({id:t,category:n,data:r,message:i,httpCode:a,UVBackendErrorCode:c})=>{let l={error_severity:s(n),error_category:o(n),player_error_code:t,player_error_trace:r,http_error_code:a,uv_backend_error_code_subcode:c,error_message:i,content_type:Z(e.info.currentFormat$.getValue())};this.logError(l),s(n)===`critical`&&this.logCannotPlay()}),i(e.events.managedError$,({id:t,category:n,data:r,message:i})=>{let a={error_severity:s(n),error_category:o(n),player_error_code:t,player_error_trace:r,error_message:i,content_type:Z(e.info.currentFormat$.getValue())};this.logError(a)}),i(e.events.fatalError$,({id:t,category:n,data:r,message:i})=>{let a={error_severity:`critical`,error_category:o(n),player_error_code:t,player_error_trace:r,error_message:i,content_type:Z(e.info.currentFormat$.getValue())};this.logError(a),this.logCannotPlay()}),i(L({connectionType:e.info.httpConnectionType$,connectionReused:e.info.httpConnectionReused$,connectionMetrics:e.info.httpConnectionMetrics$}).pipe(R(({connectionReused:e})=>e!==void 0),R(({connectionMetrics:e})=>e!==void 0),_t((e,t)=>e.connectionType===t.connectionType)),({connectionMetrics:t})=>{let n=e.info.currentFormat$.getValue(),r=e.info.availableSources$.getValue(),i=e.info.currentQuality$.getValue(),a=e.info.rttEstimation$.getValue();this.networkType=this.statContext.networkType??t?.networkType;let o={playback_url:$(n,r,i),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused,rtt:a?Math.round(a):void 0,network_type:this.networkType,dns_resolve_time:t?.dnsResolveTime,tcp_handshake_time:t?.tcpHandshakeTime,tls_handshake_time:t?.tlsHandshakeTime};this.logConnectionEstablished(o)}),i(gn(e,{maxTimeWindow:this.config.downloadBytesMaxTime}),e=>{this.downloadSpeed=e.download_speed,this.logDownloadBytes(e)}),i(e.events.firstFrame$,()=>{this.logFirstVideoFrameDecoded()}),i(e.events.willSeek$,()=>{let e={seek_type:this.seekAction$.getValue()};this.isStarted&&this.logSeeking(e)}),i(e.events.seeked$,()=>{let e={seek_type:this.seekAction$.getValue()};this.isStarted&&this.logSeeked(e),this.seekAction$.next(`unknown`)}),i(e.info.isStalled$,t=>{let n=e.info.currentBuffer$.getValue(),r=this.calcBufferTime(n);t&&r&&r>0&&this.logBufferStarvation({buffer_time:r})}),i(e.info.currentBuffer$.pipe(R(e=>!!this.calcBufferTime(e)),vt()),e=>{let t=this.calcBufferTime(e);if(this.statContext.preload){let e={buffer_time:t};this.logPreloadEnded(e)}this.logReady({buffer_time:t})});let c;i(L({videoStream:e.info.currentVideoStream$,audioStream:e.info.currentAudioStream$,quality:e.info.currentQuality$}).pipe(R(({videoStream:e,audioStream:t})=>e!==void 0&&t!==void 0),R(({quality:e})=>e!==void 0)),({videoStream:t,audioStream:n,quality:r})=>{if(c!==r){if(this.userQuality=e.info.isAutoQualityEnabled$.getValue()?`auto`:Q(r),this.downloadQuality=Q(r),this.isStarted){let e=t?.codec,r=n?.codec,i={user_quality:this.userQuality,playback_quality:Q(c),download_quality:this.downloadQuality,codec_info:this.genCodecInfo(e,r)};this.logQualityChanged(i)}c=r}});let l,u;return i(e.info.surface$,e=>{let t=On(e,this.statContext.isPreviewPlayerView);t&&!this.uiEvents&&this.isStarted&&this.logModeChanged({mode:t}),u=kn(e),l!==u&&(this.isStarted&&this.logVisibilityChanged({visibility:u}),l=kn(e))}),i(L({muted:e.info.muted$,volume:e.info.volume$}).pipe(bt(300)),({muted:e,volume:t})=>{if(this.isStarted){let n={muted:e,sound_volume:Math.round(t*100)};this.logSoundChanged(n)}}),i(e.info.currentFormat$.pipe(R(e=>e!==void 0),yt(1)),e=>{let t={content_type:Z(e),cdn_host:this.cdnHostname,connection_type:this.connectionType,connection_reused:this.connectionReused};this.logContentTypeChange(t)}),i(e.info.currentAudioStream$.pipe(R(e=>e!==void 0),yt(1)),e=>{let t={audio_track_lang:e.language,codec_info:e.codec};this.logAudioTrackSwitched(t)}),i(e.info.currentVideoStream$.pipe(R(e=>e!==void 0),yt(1)),e=>{let t={hdr:e.hdr,codec_info:e.codec};this.logVideoTrackSwitched(t)}),this.player=e,this.resubscribeBeforeunload(),this.subscription.add(r),r}attachToUi(e){this.uiEvents=e;let{subscribe:n,subscription:r}=jn();n(e.actionSeek$,this.seekAction$),n(e.playerSize$,({width:e,height:t})=>{e&&t&&(this.playerSize={width:e,height:t},this.isStarted&&this.logViewPortChanged({player_width:e,player_height:t}))}),n(e.isLoaderVisible$,e=>{e&&this.isStarted&&this.logShowLoader()}),n(e.actionSubtitlesSwitched$,e=>{if(this.currentSubtitle=t({},e),this.isStarted){let t={subtitles_enabled:e.enabled,subtitles_track_lang:e.lang,auto_subtitles:e.auto};this.logSubtitlesSwitched(t)}});let{surface$:i}=at(this.uiEvents,n,this.player);return n(i,e=>{this.isStarted&&this.logModeChanged({mode:On(e)})}),n(e.actionQuality$,e=>{var t,n,r;let i=e=>dt(ut(Et),e),a=(t=this.player)==null||(t=t.info.currentVideoStream$.getValue())==null?void 0:t.codec,o=(n=this.player)==null||(n=n.info.currentAudioStream$.getValue())==null?void 0:n.codec,s={user_quality:i(e)?`auto`:Q(e),playback_quality:Q(this.player?.info.currentQuality$.getValue()),download_quality:i(e)?Q((r=this.player)==null||(r=r.info.currentQuality$)==null?void 0:r.getValue()):Q(e),codec_info:this.genCodecInfo(a,o)};this.logQualityChangeRequested(s)}),this.resubscribeBeforeunload(),this.subscription.add(r),r}attachToAds(e){let{subscription:t,subscribe:n}=jn();return n(e.init$,e=>{let t={slot:e};this.logAdvConfiguration(t)}),n(e.slotRequested$,e=>{let t={adv_section:e};this.logAdvRequest(t)}),n(e.started$,e=>{let t={adv_section:e};this.logAdvBreakStarted(t)}),n(e.ended$,({section:e,ordIds:t})=>{let n={adv_section:e,erids:t.join(`,`)};this.logAdvBreakEnded(n)}),n(e.error$,e=>{let t={error_message:e};this.logAdvError(t)}),this.resubscribeBeforeunload(),this.subscription.add(t),t}getDeviceId(){return this.deviceId}resetViewSession(){this.thinOneStatDebugLog({message:`VSID reset`}),T.generateVSID(this.config.useVsid64),this.eventNumber=0}destroy(){this.api.destroy()}calcBufferTime(e){return e?Math.round((e.end??0)-(e.start??0))*1e3:void 0}genCodecInfo(e,t){return e&&t?`${e},${t}`:void 0}getLatencyInfo(){let e=this.player?.info.atLiveEdge$.getValue(),t={client_time:Date.now(),live:e};return JSON.stringify(t)}collectTelemetryData(){if(!this.player)return{};let e=this.player.info.currentBuffer$.getValue(),t=this.player.experimental.element$.getValue(),n=0,r=0;t&&(n=t.getVideoPlaybackQuality().droppedVideoFrames,r=t.getVideoPlaybackQuality().totalVideoFrames);let i=Z(this.player.info.currentFormat$.getValue()),a=this.player.info.currentVideoStream$.getValue()?.codec,o=this.player.info.currentAudioStream$.getValue()?.codec,s=this.player.info.videoBitrate$.getValue(),c=this.player.info.rttEstimation$.getValue();return{buffer_time:this.calcBufferTime(e),dropped_frames_count:n,rendered_frames_count:r,content_type:i,user_quality:this.userQuality,playback_quality:Q(this.player.info.currentQuality$.getValue()),download_quality:this.downloadQuality,codec_info:this.genCodecInfo(a,o),bandwidth_from_manifest:s,cdn_host:this.cdnHostname,download_speed:this.downloadSpeed,network_type:this.networkType,rtt:c?Math.round(c):void 0,latency:this.getLatencyInfo()}}createRequiredParams(e){let t=this.vsid$.getValue();ft(t);let n=this.eventNumber++,r=((this.isLive?this.player?.info.liveTime$.getValue():this.player?.info.position$.getValue())??0)*1e3,i={vsid:t,uv_movie_id:this.statContext.movieId,event_name:e,client_time:Date.now(),application:this.statContext.application??`@vkontakte/videoplayer-statistics:${D}`,platform:this.statContext.platform??`web:${this.statContext.isMobile||V.device.isMobile?`mobile`:`desktop`}`,product:this.statContext.product,event_number:n,playback_position:Math.round(r),current_tvt:this.getTotalViewTime(),cdn_host:this.cdnHostname};for(let e of this.config.disabledParams)delete i[e];return i}createRequiredFatParams(){let e={stats_version:`2.1.1`,browser:this.statContext.browser??V.browser.current,browser_version:this.statContext.browserVersion??String(V.browser.currentVersion),os:this.statContext.os??V.device.os.name,os_version:this.statContext.osVersion??V.device.os.version,device_type:this.statContext.deviceType??(this.statContext.isMobile||V.device.isMobile?`mobile`:`desktop`),device_manufacturer:this.statContext.deviceManufacturer??V.device.details.vendor,device_model:this.statContext.deviceModel??V.device.details.model,navigation:this.statContext.navigation};for(let t of this.config.disabledParams)delete e[t];return e}log(e,n,r=!1){if(dt(this.config.disabledEvents,e))return;let i=this.createRequiredParams(e),a={};r&&(a=this.createRequiredFatParams()),this.logger.log(t(t(t({},i),a),n))}logWatchCoverage(e){this.log(`watch_coverage`,e,!0)}logWatchCoverageLive(e){this.log(`watch_coverage_live`,e,!0)}logWatchedN(e){this.log(`watched_n`,e,!0)}logStartSession(e){this.log(`start_session`,e,!0)}logPreloadStarted(e){this.log(`preload_started`,e)}logPreloadEnded(e){this.log(`preload_ended`,e)}logPreloadError(){this.log(`preload_error`)}logPlaybackStarted(e){this.log(`playback_started`,e,!0)}logPlay(){this.log(`play`)}logManifestRequest(e){this.log(`manifest_request`,e)}logFirstByteManifest(e){this.log(`first_byte_manifest`,e)}logFirstMediaRequest(e){this.log(`first_media_request`,e)}logFirstByteMedia(e){this.log(`first_byte_media`,e)}logManifestReceived(e){this.log(`manifest_received`,e)}logConnectionEstablished(e){this.log(`connection_established`,e)}logFirstVideoFrameDecoded(){this.log(`first_video_frame_decoded`)}logReady(e){this.log(`ready`,e)}logPlaying(e){this.log(`playing`,e)}logPause(){this.log(`pause`)}logResume(){this.log(`resume`)}logSeeking(e){this.log(`seeking`,e)}logSeeked(e){this.log(`seeked`,e)}logStop(){this.log(`stop`)}logBufferStarvation(e){this.log(`buffer_starvation`,e)}logShowLoader(){this.log(`show_loader`)}logQualityChangeRequested(e){this.log(`quality_change_requested`,e)}logQualityChanged(e){this.log(`quality_changed`,e)}logCdnHostChanged(e){this.log(`cdn_host_changed`,e)}logViewPortChanged(e){this.log(`view_port_changed`,e)}logModeChanged(e){this.log(`mode_changed`,e)}logVisibilityChanged(e){this.log(`visibility_changed`,e)}logAudioTrackSwitched(e){this.log(`audio_track_switched`,e)}logVideoTrackSwitched(e){this.log(`video_track_switched`,e)}logSubtitlesSwitched(e){this.log(`subtitles_switched`,e)}logSoundChanged(e){this.log(`sound_changed`,e)}logFailover(e){this.log(`failover`,e)}logContentTypeChange(e){this.log(`content_type_change`,e)}logError(e){this.log(`error`,e,!0)}logCannotPlay(){this.log(`cannot_play`,{},!0)}logDownloadBytes(e){this.log(`download_bytes`,e)}logTelemetry(e){this.log(`telemetry`,e)}logAdvConfiguration(e){this.log(`adv_configuration`,e)}logAdvRequest(e){this.log(`adv_request`,e)}logAdvBreakStarted(e){this.log(`adv_break_started`,e)}logAdvBreakEnded(e){this.log(`adv_break_ended`,e)}logAdvError(e){this.log(`adv_error`,e)}resubscribeBeforeunload(){this.beforeunloadSubscription?.unsubscribe(),this.beforeunloadSubscription=mt(St(),`beforeunload`).subscribe(()=>{}),this.subscription.add(this.beforeunloadSubscription)}}import{cancelIdleCallbackPolyfilled as Nn}from"@vkontakte/videoplayer-shared/es2015";import{requestIdleCallbackPolyfilled as Pn}from"@vkontakte/videoplayer-shared/es2015";import{PlaybackState as Fn,Subscription as In}from"@vkontakte/videoplayer-core/es2015";import{Logger as Ln}from"@vkontakte/videoplayer-shared/es2015";class Rn{constructor(){e(this,`startTime`,null),e(this,`stopTime`,null),e(this,`accumulatedTime`,0)}get time(){return Math.floor(this.timeMs/1e3)}get timeMs(){return this.startTime===null?0:(this.stopTime??this.now())-this.startTime-this.accumulatedTime}get isRunning(){return this.startTime!==null&&this.stopTime===null}start(){this.isRunning||(this.stopTime===null?this.startTime=this.now():(this.accumulatedTime+=this.now()-this.stopTime,this.stopTime=null))}stop(){this.isRunning&&(this.stopTime=this.now())}reset(){this.startTime=null,this.stopTime=null,this.accumulatedTime=0}now(){return Date.now()}}var zn=()=>window.Image?new Image:document.createElement(`img`);class Bn{constructor(t){e(this,`params`,void 0),e(this,`position`,0),e(this,`started`,!1),e(this,`isActiveLive`,void 0),e(this,`heartbeatPixels`,[]),e(this,`heartbeatLastTimeSent`,{}),e(this,`heartbeatInterval`,void 0),e(this,`heartbeatFirstTimeoutId`,void 0),e(this,`idleCallbackIds`,[]),e(this,`log`,void 0),e(this,`stopwatch`,new Rn),e(this,`subscription`,new In),this.params=t,this.log=new Ln().createComponentLog(`MediascopePixel`)}attachTo(e){this.subscription.add(e.info.playbackState$.subscribe(e=>this.onPlaybackState(e))).add(e.info.position$.subscribe(e=>this.onPosition(e))).add(e.info.atLiveEdge$.subscribe(e=>this.isActiveLive=e)),this.subscription.add(e.events.willSeek$.subscribe(()=>this.onWillSeek())).add(e.events.seeked$.subscribe(()=>this.onSeeked())).add(e.events.ended$.subscribe(()=>this.onEnded()))}destroy(){this.stopwatch.reset(),this.subscription.unsubscribe(),window.clearTimeout(this.heartbeatFirstTimeoutId),this.idleCallbackIds.forEach(e=>Nn(e)),this.send(`stop`)}onPlaybackState(e){e===Fn.PLAYING?this.started?this.play():this.start():e===Fn.PAUSED&&this.pause()}start(){this.started=!0,this.stopwatch.start(),this.send(`start`),this.heartbeatPixels=this.prepareHeartbeatPixels(),this.heartbeatInterval=this.heartbeatPixels[0]?.interval;let e=this.heartbeatPixels[0]?.url,t=this.heartbeatPixels[0]?.delay;if(t!==void 0&&e)try{this.heartbeatFirstTimeoutId=window.setTimeout(()=>{this.sendHeartbeat(e)},t*1e3)}catch(e){this.log({message:e.message})}}play(){this.stopwatch.start(),this.send(`resume`)}pause(){this.stopwatch.stop(),this.send(`pause`)}onPosition(e){if(this.position=e,this.heartbeatInterval&&this.stopwatch.time!==0&&this.stopwatch.time%this.heartbeatInterval===0)for(let[e,{url:t}]of this.heartbeatPixels.entries())this.heartbeatLastTimeSent[e]!==this.stopwatch.time&&(this.heartbeatLastTimeSent[e]=this.stopwatch.time,this.sendHeartbeat(t))}onWillSeek(){this.started&&this.send(`stop`)}onSeeked(){this.started&&this.send(`start`)}onEnded(){this.stopwatch.stop(),this.send(`stop`)}validatePixels(e,t){return e?.filter(e=>e.event===t.event&&t.keys.every(t=>!!e[t]))}getFrameTimestamp(){let e;if(this.isActiveLive){let t=Math.floor(Math.random()*25)+5;e=Date.now()/1e3-t}else e=this.position||0;return Math.floor(e)}getUTC(){return Math.floor(Date.now()/1e3)}prepareUrl(e){return e.replace(`{@fts_fake_sec}`,String(this.getFrameTimestamp())).replace(`{@utc_sec}`,String(this.getUTC())).split(`&`).filter(e=>!/={@[a-zA-Z_]+}/.test(e)).join(`&`)}preparePixels(e){return this.validatePixels(this.params.pixels,{event:e,keys:[`url`]})}prepareHeartbeatPixels(){return this.validatePixels(this.params.pixels,{event:`heartbeat`,keys:[`url`,`interval`]})}call(e){try{this.idleCallbackIds.push(Pn(()=>zn().src=this.prepareUrl(e)))}catch(e){this.log({message:e.message})}}send(e){let t=this.preparePixels(e);for(let{url:e}of t)this.call(e)}sendHeartbeat(e){this.call(e)}}export{D as VERSION,lt as ThinOneStat,p as SeekAction,u as Quality,ct as OneStat,Bn as MediascopePixel,m as InteractiveInterfaceClick,d as ContentType,f as ConnectionType,l as ApiEnv};
7
7
  //# sourceMappingURL=es2015.esm.js.map