@vkontakte/videoplayer-core 2.0.156 → 2.0.157-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es2015.cjs +4 -4
- package/es2015.esm.js +4 -4
- package/es2018.cjs +4 -4
- package/es2018.esm.js +4 -4
- package/es2024.cjs +4 -4
- package/es2024.esm.js +4 -4
- package/esnext.cjs +4 -4
- package/esnext.esm.js +4 -4
- package/evergreen.esm.js +4 -4
- package/package.json +2 -2
package/es2015.esm.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-core v2.0.
|
|
3
|
-
*
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/2-0-
|
|
2
|
+
* @vkontakte/videoplayer-core v2.0.157-beta.0
|
|
3
|
+
* Thu, 26 Mar 2026 09:56:25 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/2-0-157/doc/
|
|
5
5
|
*/
|
|
6
6
|
const e=[`url`],t=[`url`],n=[`downloadingItems`],r=[`container`];import i from"@oxc-project/runtime/helpers/defineProperty";import a from"@oxc-project/runtime/helpers/asyncToGenerator";import o from"@oxc-project/runtime/helpers/objectSpread2";import s from"@oxc-project/runtime/helpers/awaitAsyncGenerator";import c from"@oxc-project/runtime/helpers/wrapAsyncGenerator";import l from"@oxc-project/runtime/helpers/objectWithoutProperties";var u=Object.create,d=Object.getPrototypeOf,f=Object.defineProperty,p=Object.getOwnPropertyNames,m=Object.prototype.hasOwnProperty;function h(e){return this[e]}var g,_,v=(e,t,n)=>{var r=typeof e==`object`&&!!e;if(r){var i=t?g??=new WeakMap:_??=new WeakMap,a=i.get(e);if(a)return a}n=e==null?{}:u(d(e));let o=t||!e||!e.__esModule?f(n,`default`,{value:e,enumerable:!0}):n;for(let t of p(e))m.call(o,t)||f(o,t,{get:h.bind(e,t),enumerable:!0});return r&&i.set(e,o),o},y=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),b=y((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`)()}),x=y((e,t)=>{t.exports=function(e){try{return!!e()}catch{return!0}}}),S=y((e,t)=>{t.exports=!x()(function(){var e=function(){}.bind();return typeof e!=`function`||e.hasOwnProperty(`prototype`)})}),C=y((e,t)=>{var n=S(),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)})}),w=y((e,t)=>{var n=S(),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)}}}),T=y((e,t)=>{var n=w(),r=n({}.toString),i=n(``.slice);t.exports=function(e){return i(r(e),8,-1)}}),E=y((e,t)=>{var n=T(),r=w();t.exports=function(e){if(n(e)===`Function`)return r(e)}}),D=y((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`}}),O=y((e,t)=>{t.exports=!x()(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})}),k=y((e,t)=>{var n=S(),r=Function.prototype.call;t.exports=n?r.bind(r):function(){return r.apply(r,arguments)}}),A=y(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}),ee=y((e,t)=>{t.exports=function(e,t){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:t}}}),te=y((e,t)=>{var n=w(),r=x(),i=T(),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}),ne=y((e,t)=>{t.exports=function(e){return e==null}}),j=y((e,t)=>{var n=ne(),r=TypeError;t.exports=function(e){if(n(e))throw new r(`Can't call method on `+e);return e}}),re=y((e,t)=>{var n=te(),r=j();t.exports=function(e){return n(r(e))}}),ie=y((e,t)=>{var n=D();t.exports=function(e){return typeof e==`object`?e!==null:n(e)}}),ae=y((e,t)=>{t.exports={}}),oe=y((e,t)=>{var n=ae(),r=b(),i=D(),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]}}),se=y((e,t)=>{t.exports=w()({}.isPrototypeOf)}),ce=y((e,t)=>{var n=b().navigator,r=n&&n.userAgent;t.exports=r?String(r):``}),le=y((e,t)=>{var n=b(),r=ce(),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}),ue=y((e,t)=>{var n=le(),r=x(),i=b().String;t.exports=!!Object.getOwnPropertySymbols&&!r(function(){var e=Symbol(`symbol detection`);return!i(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&n&&n<41})}),de=y((e,t)=>{t.exports=ue()&&!Symbol.sham&&typeof Symbol.iterator==`symbol`}),fe=y((e,t)=>{var n=oe(),r=D(),i=se(),a=de(),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))}}),pe=y((e,t)=>{var n=String;t.exports=function(e){try{return n(e)}catch{return`Object`}}}),me=y((e,t)=>{var n=D(),r=pe(),i=TypeError;t.exports=function(e){if(n(e))return e;throw new i(r(e)+` is not a function`)}}),he=y((e,t)=>{var n=me(),r=ne();t.exports=function(e,t){var i=e[t];return r(i)?void 0:n(i)}}),ge=y((e,t)=>{var n=k(),r=D(),i=ie(),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`)}}),_e=y((e,t)=>{t.exports=!0}),ve=y((e,t)=>{var n=b(),r=Object.defineProperty;t.exports=function(e,t){try{r(n,e,{value:t,configurable:!0,writable:!0})}catch{n[e]=t}return t}}),ye=y((e,t)=>{var n=_e(),r=b(),i=ve(),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`})}),be=y((e,t)=>{var n=ye();t.exports=function(e,t){return n[e]||(n[e]=t||{})}}),xe=y((e,t)=>{var n=j(),r=Object;t.exports=function(e){return r(n(e))}}),Se=y((e,t)=>{var n=w(),r=xe(),i=n({}.hasOwnProperty);t.exports=Object.hasOwn||function(e,t){return i(r(e),t)}}),Ce=y((e,t)=>{var n=w(),r=0,i=Math.random(),a=n(1.1.toString);t.exports=function(e){return`Symbol(`+(e===void 0?``:e)+`)_`+a(++r+i,36)}}),M=y((e,t)=>{var n=b(),r=be(),i=Se(),a=Ce(),o=ue(),s=de(),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]}}),we=y((e,t)=>{var n=k(),r=ie(),i=fe(),a=he(),o=ge(),s=M(),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)}}),Te=y((e,t)=>{var n=we(),r=fe();t.exports=function(e){var t=n(e,`string`);return r(t)?t:t+``}}),Ee=y((e,t)=>{var n=b(),r=ie(),i=n.document,a=r(i)&&r(i.createElement);t.exports=function(e){return a?i.createElement(e):{}}}),De=y((e,t)=>{var n=O(),r=x(),i=Ee();t.exports=!n&&!r(function(){return Object.defineProperty(i(`div`),`a`,{get:function(){return 7}}).a!==7})}),Oe=y(e=>{var t=O(),n=k(),r=A(),i=ee(),a=re(),o=Te(),s=Se(),c=De(),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])}}),ke=y((e,t)=>{var n=x(),r=D(),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}),Ae=y((e,t)=>{var n=E(),r=me(),i=S(),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)}}}),je=y((e,t)=>{var n=O(),r=x();t.exports=n&&r(function(){return Object.defineProperty(function(){},`prototype`,{value:42,writable:!1}).prototype!==42})}),Me=y((e,t)=>{var n=ie(),r=String,i=TypeError;t.exports=function(e){if(n(e))return e;throw new i(r(e)+` is not an object`)}}),Ne=y(e=>{var t=O(),n=De(),r=je(),i=Me(),a=Te(),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}}),Pe=y((e,t)=>{var n=O(),r=Ne(),i=ee();t.exports=n?function(e,t,n){return r.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}}),N=y((e,t)=>{var n=b(),r=C(),i=E(),a=D(),o=Oe().f,s=ke(),c=ae(),l=Ae(),u=Pe(),d=Se();ye();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)))}}),Fe=y((e,t)=>{var n=be(),r=Ce(),i=n(`keys`);t.exports=function(e){return i[e]||(i[e]=r(e))}}),Ie=y((e,t)=>{t.exports=!x()(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})}),Le=y((e,t)=>{var n=Se(),r=D(),i=xe(),a=Fe(),o=Ie(),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}}),Re=y((e,t)=>{var n=Math.ceil,r=Math.floor;t.exports=Math.trunc||function(e){var t=+e;return(t>0?r:n)(t)}}),ze=y((e,t)=>{var n=Re();t.exports=function(e){var t=+e;return t!==t||t===0?0:n(t)}}),Be=y((e,t)=>{var n=ze(),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)}}),Ve=y((e,t)=>{var n=ze(),r=Math.min;t.exports=function(e){var t=n(e);return t>0?r(t,9007199254740991):0}}),He=y((e,t)=>{var n=Ve();t.exports=function(e){return n(e.length)}}),Ue=y((e,t)=>{var n=re(),r=Be(),i=He(),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)}}),We=y((e,t)=>{t.exports={}}),Ge=y((e,t)=>{var n=w(),r=Se(),i=re(),a=Ue().indexOf,o=We(),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}}),Ke=y((e,t)=>{t.exports=[`constructor`,`hasOwnProperty`,`isPrototypeOf`,`propertyIsEnumerable`,`toLocaleString`,`toString`,`valueOf`]}),qe=y((e,t)=>{var n=Ge(),r=Ke();t.exports=Object.keys||function(e){return n(e,r)}}),Je=y((e,t)=>{var n=O(),r=x(),i=w(),a=Le(),o=qe(),s=re(),c=A().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)}}),Ye=y(()=>{var e=N(),t=Je().values;e({target:`Object`,stat:!0},{values:function(e){return t(e)}})}),Xe=y((e,t)=>{Ye(),t.exports=ae().Object.values}),Ze=y((e,t)=>{t.exports=Xe()}),Qe=y((e,t)=>{t.exports=Ze()}),$e=y((e,t)=>{t.exports=function(){}}),et=y(()=>{var e=N(),t=Ue().includes,n=x(),r=$e();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`)}),tt=y((e,t)=>{t.exports=oe()}),nt=y((e,t)=>{et(),t.exports=tt()(`Array`,`includes`)}),rt=y((e,t)=>{t.exports=nt()}),it=y((e,t)=>{t.exports=rt()}),at=y(()=>{var e=N(),t=Je().entries;e({target:`Object`,stat:!0},{entries:function(e){return t(e)}})}),ot=y((e,t)=>{at(),t.exports=ae().Object.entries}),st=y((e,t)=>{t.exports=ot()}),ct=y((e,t)=>{t.exports=st()}),lt=y((e,t)=>{t.exports={}}),ut=y((e,t)=>{var n=b(),r=D(),i=n.WeakMap;t.exports=r(i)&&/native code/.test(String(i))}),dt=y((e,t)=>{var n=ut(),r=b(),i=ie(),a=Pe(),o=Se(),s=ye(),c=Fe(),l=We(),u=`Object already initialized`,d=r.TypeError,f=r.WeakMap,p,m,h,g=function(e){return h(e)?m(e):p(e,{})},_=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?(v=s.state||=new f,v.get=v.get,v.has=v.has,v.set=v.set,p=function(e,t){if(v.has(e))throw new d(u);return t.facade=e,v.set(e,t),t},m=function(e){return v.get(e)||{}},h=function(e){return v.has(e)}):(y=c(`state`),l[y]=!0,p=function(e,t){if(o(e,y))throw new d(u);return t.facade=e,a(e,y,t),t},m=function(e){return o(e,y)?e[y]:{}},h=function(e){return o(e,y)});var v,y;t.exports={set:p,get:m,has:h,enforce:g,getterFor:_}}),ft=y((e,t)=>{var n=O(),r=Se(),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)}}),pt=y(e=>{var t=O(),n=je(),r=Ne(),i=Me(),a=re(),o=qe();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}}),mt=y((e,t)=>{t.exports=oe()(`document`,`documentElement`)}),ht=y((e,t)=>{var n=Me(),r=pt(),i=Ke(),a=We(),o=mt(),s=Ee(),c=Fe(),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)}}),gt=y((e,t)=>{var n=Pe();t.exports=function(e,t,r,i){return i&&i.enumerable?e[t]=r:n(e,t,r),e}}),_t=y((e,t)=>{var n=x(),r=D(),i=ie(),a=ht(),o=Le(),s=gt(),c=M(),l=_e(),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}}),vt=y((e,t)=>{var n=M()(`toStringTag`),r={};r[n]=`z`,t.exports=String(r)===`[object z]`}),yt=y((e,t)=>{var n=vt(),r=D(),i=T(),a=M()(`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}}),bt=y((e,t)=>{var n=vt(),r=yt();t.exports=n?{}.toString:function(){return`[object `+r(this)+`]`}}),xt=y((e,t)=>{var n=vt(),r=Ne().f,i=Pe(),a=Se(),o=bt(),s=M()(`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))}}),St=y((e,t)=>{var n=_t().IteratorPrototype,r=ht(),i=ee(),a=xt(),o=lt(),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}}),Ct=y((e,t)=>{var n=w(),r=me();t.exports=function(e,t,i){try{return n(r(Object.getOwnPropertyDescriptor(e,t)[i]))}catch{}}}),wt=y((e,t)=>{var n=ie();t.exports=function(e){return n(e)||e===null}}),Tt=y((e,t)=>{var n=wt(),r=String,i=TypeError;t.exports=function(e){if(n(e))return e;throw new i(`Can't set `+r(e)+` as a prototype`)}}),Et=y((e,t)=>{var n=Ct(),r=ie(),i=j(),a=Tt();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)}),Dt=y((e,t)=>{var n=N(),r=k(),i=_e(),a=ft(),o=D(),s=St(),c=Le(),l=Et(),u=xt(),d=Pe(),f=gt(),p=M(),m=lt(),h=_t(),g=a.PROPER,_=a.CONFIGURABLE,v=h.IteratorPrototype,y=h.BUGGY_SAFARI_ITERATORS,b=p(`iterator`),x=`keys`,S=`values`,C=`entries`,w=function(){return this};t.exports=function(e,t,a,p,h,T,E){s(a,t,p);var D=function(e){if(e===h&&te)return te;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 C:return function(){return new a(this,e)}}return function(){return new a(this)}},O=t+` Iterator`,k=!1,A=e.prototype,ee=A[b]||A[`@@iterator`]||h&&A[h],te=!y&&ee||D(h),ne=t===`Array`&&A.entries||ee,j,re,ie;if(ne&&(j=c(ne.call(new e)),j!==Object.prototype&&j.next&&(!i&&c(j)!==v&&(l?l(j,v):o(j[b])||f(j,b,w)),u(j,O,!0,!0),i&&(m[O]=w))),g&&h===S&&ee&&ee.name!==S&&(!i&&_?d(A,`name`,S):(k=!0,te=function(){return r(ee,this)})),h)if(re={values:D(S),keys:T?te:D(x),entries:D(C)},E)for(ie in re)(y||k||!(ie in A))&&f(A,ie,re[ie]);else n({target:t,proto:!0,forced:y||k},re);return(!i||E)&&A[b]!==te&&f(A,b,te,{name:h}),m[t]=te,re}}),Ot=y((e,t)=>{t.exports=function(e,t){return{value:e,done:t}}}),kt=y((e,t)=>{var n=re(),r=$e(),i=lt(),a=dt(),o=Ne().f,s=Dt(),c=Ot(),l=_e(),u=O(),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{}}),At=y((e,t)=>{var n=M(),r=lt(),i=n(`iterator`),a=Array.prototype;t.exports=function(e){return e!==void 0&&(r.Array===e||a[i]===e)}}),jt=y((e,t)=>{var n=yt(),r=he(),i=ne(),a=lt(),o=M()(`iterator`);t.exports=function(e){if(!i(e))return r(e,o)||r(e,`@@iterator`)||a[n(e)]}}),Mt=y((e,t)=>{var n=k(),r=me(),i=Me(),a=pe(),o=jt(),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`)}}),Nt=y((e,t)=>{var n=k(),r=Me(),i=he();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}}),Pt=y((e,t)=>{var n=Ae(),r=k(),i=Me(),a=pe(),o=At(),s=He(),c=se(),l=Mt(),u=jt(),d=Nt(),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)}}),Ft=y((e,t)=>{var n=O(),r=Ne(),i=ee();t.exports=function(e,t,a){n?r.f(e,t,i(0,a)):e[t]=a}}),It=y(()=>{var e=N(),t=Pt(),n=Ft();e({target:`Object`,stat:!0},{fromEntries:function(e){var r={};return t(e,function(e,t){n(r,e,t)},{AS_ENTRIES:!0}),r}})}),Lt=y((e,t)=>{kt(),It(),t.exports=ae().Object.fromEntries}),Rt=y((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}}),zt=y(()=>{kt();var e=Rt(),t=b(),n=xt(),r=lt();for(i in e)n(t[i],i),r[i]=r.Array;var i}),Bt=y((e,t)=>{var n=Lt();zt(),t.exports=n}),Vt=y((e,t)=>{t.exports=Bt()}),Ht=y((e,t)=>{var n=b(),r=ce(),i=T(),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`}()}),Ut=y((e,t)=>{t.exports=Ht()===`NODE`}),Wt=y((e,t)=>{var n=Ne();t.exports=function(e,t,r){return n.f(e,t,r)}}),Gt=y((e,t)=>{var n=oe(),r=Wt(),i=M(),a=O(),o=i(`species`);t.exports=function(e){var t=n(e);a&&t&&!t[o]&&r(t,o,{configurable:!0,get:function(){return this}})}}),Kt=y((e,t)=>{var n=se(),r=TypeError;t.exports=function(e,t){if(n(t,e))return e;throw new r(`Incorrect invocation`)}}),qt=y((e,t)=>{var n=w(),r=D(),i=ye(),a=n(Function.toString);r(i.inspectSource)||(i.inspectSource=function(e){return a(e)}),t.exports=i.inspectSource}),Jt=y((e,t)=>{var n=w(),r=x(),i=D(),a=yt(),o=oe(),s=qt(),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}),Yt=y((e,t)=>{var n=Jt(),r=pe(),i=TypeError;t.exports=function(e){if(n(e))return e;throw new i(r(e)+` is not a constructor`)}}),Xt=y((e,t)=>{var n=Me(),r=Yt(),i=ne(),a=M()(`species`);t.exports=function(e,t){var o=n(e).constructor,s;return o===void 0||i(s=n(o)[a])?t:r(s)}}),Zt=y((e,t)=>{t.exports=w()([].slice)}),Qt=y((e,t)=>{var n=TypeError;t.exports=function(e,t){if(e<t)throw new n(`Not enough arguments`);return e}}),$t=y((e,t)=>{var n=ce();t.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(n)}),en=y((e,t)=>{var n=b(),r=C(),i=Ae(),a=D(),o=Se(),s=x(),c=mt(),l=Zt(),u=Ee(),d=Qt(),f=$t(),p=Ut(),m=n.setImmediate,h=n.clearImmediate,g=n.process,_=n.Dispatch,v=n.Function,y=n.MessageChannel,S=n.String,w=0,T={},E=`onreadystatechange`,O,k,A,ee;s(function(){O=n.location});var te=function(e){if(o(T,e)){var t=T[e];delete T[e],t()}},ne=function(e){return function(){te(e)}},j=function(e){te(e.data)},re=function(e){n.postMessage(S(e),O.protocol+`//`+O.host)};(!m||!h)&&(m=function(e){d(arguments.length,1);var t=a(e)?e:v(e),n=l(arguments,1);return T[++w]=function(){r(t,void 0,n)},k(w),w},h=function(e){delete T[e]},p?k=function(e){g.nextTick(ne(e))}:_&&_.now?k=function(e){_.now(ne(e))}:y&&!f?(A=new y,ee=A.port2,A.port1.onmessage=j,k=i(ee.postMessage,ee)):n.addEventListener&&a(n.postMessage)&&!n.importScripts&&O&&O.protocol!==`file:`&&!s(re)?(k=re,n.addEventListener(`message`,j,!1)):k=E in u(`script`)?function(e){c.appendChild(u(`script`))[E]=function(){c.removeChild(this),te(e)}}:function(e){setTimeout(ne(e),0)}),t.exports={set:m,clear:h}}),tn=y((e,t)=>{var n=b(),r=O(),i=Object.getOwnPropertyDescriptor;t.exports=function(e){if(!r)return n[e];var t=i(n,e);return t&&t.value}}),nn=y((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}),rn=y((e,t)=>{var n=ce();t.exports=/ipad|iphone|ipod/i.test(n)&&typeof Pebble<`u`}),an=y((e,t)=>{var n=ce();t.exports=/web0s(?!.*chrome)/i.test(n)}),on=y((e,t)=>{var n=b(),r=tn(),i=Ae(),a=en().set,o=nn(),s=$t(),c=rn(),l=an(),u=Ut(),d=n.MutationObserver||n.WebKitMutationObserver,f=n.document,p=n.process,m=n.Promise,h=r(`queueMicrotask`),g,_,v,y,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&&g(),e}e&&e.enter()},!s&&!u&&!l&&d&&f?(_=!0,v=f.createTextNode(``),new d(C).observe(v,{characterData:!0}),g=function(){v.data=_=!_}):!c&&m&&m.resolve?(y=m.resolve(void 0),y.constructor=m,x=i(y.then,y),g=function(){x(C)}):u?g=function(){p.nextTick(C)}:(a=i(a,n),g=function(){a(C)}),function(e){S.head||g(),S.add(e)});var S,C;t.exports=h}),sn=y((e,t)=>{t.exports=function(e,t){try{arguments.length===1?console.error(e):console.error(e,t)}catch{}}}),cn=y((e,t)=>{t.exports=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}}}),ln=y((e,t)=>{t.exports=b().Promise}),un=y((e,t)=>{var n=b(),r=ln(),i=D(),a=ke(),o=qt(),s=M(),c=Ht(),l=_e(),u=le(),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}}),dn=y((e,t)=>{var n=me(),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)}}),fn=y(()=>{var e=N(),t=_e(),n=Ut(),r=b(),i=ae(),a=k(),o=gt(),s=Et(),c=xt(),l=Gt(),u=me(),d=D(),f=ie(),p=Kt(),m=Xt(),h=en().set,g=on(),_=sn(),v=cn(),y=nn(),x=dt(),S=ln(),C=un(),w=dn(),T=`Promise`,E=C.CONSTRUCTOR,O=C.REJECTION_EVENT,A=C.SUBCLASSING,ee=x.getterFor(T),te=x.set,ne=S&&S.prototype,j=S,re=ne,oe=r.TypeError,se=r.document,ce=r.process,le=w.f,ue=le,de=!!(se&&se.createEvent&&r.dispatchEvent),fe=`unhandledrejection`,pe=`rejectionhandled`,he=0,ge=1,ve=2,ye=1,be=2,xe,Se,Ce,M,we=function(e){var t;return f(e)&&d(t=e.then)?t:!1},Te=function(e,t){var n=t.value,r=t.state===ge,i=r?e.ok:e.fail,o=e.resolve,s=e.reject,c=e.domain,l,u,d;try{i?(r||(t.rejection===be&&Ae(t),t.rejection=ye),i===!0?l=n:(c&&c.enter(),l=i(n),c&&(c.exit(),d=!0)),l===e.promise?s(new oe(`Promise-chain cycle`)):(u=we(l))?a(u,l,o,s):o(l)):s(n)}catch(e){c&&!d&&c.exit(),s(e)}},Ee=function(e,t){e.notified||(e.notified=!0,g(function(){for(var n=e.reactions,r;r=n.get();)Te(r,e);e.notified=!1,t&&!e.rejection&&Oe(e)}))},De=function(e,t,n){var i,a;de?(i=se.createEvent(`Event`),i.promise=t,i.reason=n,i.initEvent(e,!1,!0),r.dispatchEvent(i)):i={promise:t,reason:n},!O&&(a=r[`on`+e])?a(i):e===fe&&_(`Unhandled promise rejection`,n)},Oe=function(e){a(h,r,function(){var t=e.facade,r=e.value,i=ke(e),a;if(i&&(a=v(function(){n?ce.emit(`unhandledRejection`,r,t):De(fe,t,r)}),e.rejection=n||ke(e)?be:ye,a.error))throw a.value})},ke=function(e){return e.rejection!==ye&&!e.parent},Ae=function(e){a(h,r,function(){var t=e.facade;n?ce.emit(`rejectionHandled`,t):De(pe,t,e.value)})},je=function(e,t,n){return function(r){e(t,r,n)}},Me=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=ve,Ee(e,!0))},Ne=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw new oe(`Promise can't be resolved itself`);var r=we(t);r?g(function(){var n={done:!1};try{a(r,t,je(Ne,n,e),je(Me,n,e))}catch(t){Me(n,t,e)}}):(e.value=t,e.state=ge,Ee(e,!1))}catch(t){Me({done:!1},t,e)}}};if(E&&(j=function(e){p(this,re),u(e),a(xe,this);var t=ee(this);try{e(je(Ne,t),je(Me,t))}catch(e){Me(t,e)}},re=j.prototype,xe=function(e){te(this,{type:T,done:!1,notified:!1,parent:!1,reactions:new y,rejection:!1,state:he,value:null})},xe.prototype=o(re,`then`,function(e,t){var r=ee(this),i=le(m(this,j));return r.parent=!0,i.ok=d(e)?e:!0,i.fail=d(t)&&t,i.domain=n?ce.domain:void 0,r.state===he?r.reactions.add(i):g(function(){Te(i,r)}),i.promise}),Se=function(){var e=new xe,t=ee(e);this.promise=e,this.resolve=je(Ne,t),this.reject=je(Me,t)},w.f=le=function(e){return e===j||e===Ce?new Se(e):ue(e)},!t&&d(S)&&ne!==Object.prototype)){M=ne.then,A||o(ne,`then`,function(e,t){var n=this;return new j(function(e,t){a(M,n,e,t)}).then(e,t)},{unsafe:!0});try{delete ne.constructor}catch{}s&&s(ne,re)}e({global:!0,constructor:!0,wrap:!0,forced:E},{Promise:j}),Ce=i.Promise,c(j,T,!1,!0),l(T)}),pn=y((e,t)=>{var n=M()(`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}}),mn=y((e,t)=>{var n=ln(),r=pn();t.exports=un().CONSTRUCTOR||!r(function(e){n.all(e).then(void 0,function(){})})}),hn=y(()=>{var e=N(),t=k(),n=me(),r=dn(),i=cn(),a=Pt();e({target:`Promise`,stat:!0,forced:mn()},{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}})}),gn=y(()=>{var e=N(),t=_e(),n=un().CONSTRUCTOR,r=ln(),i=oe(),a=D(),o=gt(),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}),_n=y(()=>{var e=N(),t=k(),n=me(),r=dn(),i=cn(),a=Pt();e({target:`Promise`,stat:!0,forced:mn()},{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}})}),vn=y(()=>{var e=N(),t=dn(),n=un().CONSTRUCTOR;e({target:`Promise`,stat:!0,forced:n},{reject:function(e){var n=t.f(this),r=n.reject;return r(e),n.promise}})}),yn=y((e,t)=>{var n=Me(),r=ie(),i=dn();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}}),bn=y(()=>{var e=N(),t=oe(),n=_e(),r=ln(),i=un().CONSTRUCTOR,a=yn(),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)}})}),xn=y(()=>{fn(),hn(),gn(),_n(),vn(),bn()}),Sn=y(()=>{var e=N(),t=_e(),n=ln(),r=x(),i=oe(),a=D(),o=Xt(),s=yn(),c=gt(),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}),Cn=y((e,t)=>{xn(),Sn(),t.exports=tt()(`Promise`,`finally`)}),wn=y((e,t)=>{t.exports=Cn()}),Tn=y((e,t)=>{t.exports=wn()}),En=y(()=>{var e=N(),t=xe(),n=He(),r=ze(),i=$e();e({target:`Array`,proto:!0},{at:function(e){var i=t(this),a=n(i),o=r(e),s=o>=0?o:a+o;return s<0||s>=a?void 0:i[s]}}),i(`at`)}),Dn=y((e,t)=>{En(),t.exports=tt()(`Array`,`at`)}),On=y((e,t)=>{t.exports=Dn()}),kn=y((e,t)=>{t.exports=On()}),An=y((e,t)=>{var n=yt(),r=String;t.exports=function(e){if(n(e)===`Symbol`)throw TypeError(`Cannot convert a Symbol value to a string`);return r(e)}}),jn=y(()=>{var e=N(),t=w(),n=j(),r=ze(),i=An(),a=x(),o=t(``.charAt);e({target:`String`,proto:!0,forced:a(function(){return`𠮷`.at(-2)!==`\ud842`})},{at:function(e){var t=i(n(this)),a=t.length,s=r(e),c=s>=0?s:a+s;return c<0||c>=a?void 0:o(t,c)}})}),Mn=y((e,t)=>{jn(),t.exports=tt()(`String`,`at`)}),Nn=y((e,t)=>{t.exports=Mn()}),Pn=y((e,t)=>{t.exports=Nn()}),Fn=y((e,t)=>{var n=T();t.exports=Array.isArray||function(e){return n(e)===`Array`}}),In=y((e,t)=>{var n=TypeError,r=9007199254740991;t.exports=function(e){if(e>r)throw n(`Maximum allowed index exceeded`);return e}}),Ln=y((e,t)=>{var n=Fn(),r=He(),i=In(),a=Ae(),o=function(e,t,s,c,l,u,d,f){for(var p=l,m=0,h=d?a(d,f):!1,g,_;m<c;)m in s&&(g=h?h(s[m],m,t):s[m],u>0&&n(g)?(_=r(g),p=o(e,t,g,_,p,u-1)-1):(i(p+1),e[p]=g),p++),m++;return p};t.exports=o}),Rn=y((e,t)=>{var n=Fn(),r=Jt(),i=ie(),a=M()(`species`),o=Array;t.exports=function(e){var t;return n(e)&&(t=e.constructor,r(t)&&(t===o||n(t.prototype))?t=void 0:i(t)&&(t=t[a],t===null&&(t=void 0))),t===void 0?o:t}}),zn=y((e,t)=>{var n=Rn();t.exports=function(e,t){return new(n(e))(t===0?0:t)}}),Bn=y(()=>{var e=N(),t=Ln(),n=me(),r=xe(),i=He(),a=zn();e({target:`Array`,proto:!0},{flatMap:function(e){var o=r(this),s=i(o),c;return n(e),c=a(o,0),c.length=t(c,o,o,s,0,1,e,arguments.length>1?arguments[1]:void 0),c}})}),Vn=y(()=>{$e()(`flatMap`)}),Hn=y((e,t)=>{Bn(),Vn(),t.exports=tt()(`Array`,`flatMap`)}),Un=y((e,t)=>{t.exports=Hn()}),Wn=y((e,t)=>{t.exports=Un()}),Gn=y((e,t)=>{t.exports=`
|
|
7
|
-
\v\f\r \xA0 \u2028\u2029`}),Kn=y((e,t)=>{var n=w(),r=j(),i=An(),a=Gn(),o=n(``.replace),s=RegExp(`^[`+a+`]+`),c=RegExp(`(^|[^`+a+`])[`+a+`]+$`),l=function(e){return function(t){var n=i(r(t));return e&1&&(n=o(n,s,``)),e&2&&(n=o(n,c,`$1`)),n}};t.exports={start:l(1),end:l(2),trim:l(3)}}),qn=y((e,t)=>{var n=ft().PROPER,r=x(),i=Gn(),a=`
`;t.exports=function(e){return r(function(){return!!i[e]()||a[e]()!==a||n&&i[e].name!==e})}}),Jn=y((e,t)=>{var n=Kn().start;t.exports=qn()(`trimStart`)?function(){return n(this)}:``.trimStart}),Yn=y(()=>{var e=N(),t=Jn();e({target:`String`,proto:!0,name:`trimStart`,forced:``.trimLeft!==t},{trimLeft:t})}),Xn=y(()=>{Yn();var e=N(),t=Jn();e({target:`String`,proto:!0,name:`trimStart`,forced:``.trimStart!==t},{trimStart:t})}),Zn=y((e,t)=>{Xn(),t.exports=tt()(`String`,`trimLeft`)}),Qn=y((e,t)=>{t.exports=Zn()}),$n=y((e,t)=>{t.exports=Qn()}),er=y((e,t)=>{var n=ie(),r=T(),i=M()(`match`);t.exports=function(e){var t;return n(e)&&((t=e[i])===void 0?r(e)===`RegExp`:!!t)}}),tr=y((e,t)=>{var n=b(),r=x(),i=n.RegExp;t.exports={correct:!r(function(){var e=!0;try{i(`.`,`d`)}catch{e=!1}var t={},n=``,r=e?`dgimsy`:`gimsy`,a=function(e,r){Object.defineProperty(t,e,{get:function(){return n+=r,!0}})},o={dotAll:`s`,global:`g`,ignoreCase:`i`,multiline:`m`,sticky:`y`};for(var s in e&&(o.hasIndices=`d`),o)a(s,o[s]);return Object.getOwnPropertyDescriptor(i.prototype,`flags`).get.call(t)!==r||n!==r})}}),nr=y((e,t)=>{var n=Me();t.exports=function(){var e=n(this),t=``;return e.hasIndices&&(t+=`d`),e.global&&(t+=`g`),e.ignoreCase&&(t+=`i`),e.multiline&&(t+=`m`),e.dotAll&&(t+=`s`),e.unicode&&(t+=`u`),e.unicodeSets&&(t+=`v`),e.sticky&&(t+=`y`),t}}),rr=y((e,t)=>{var n=k(),r=Se(),i=se(),a=tr(),o=nr(),s=RegExp.prototype;t.exports=a.correct?function(e){return e.flags}:function(e){return!a.correct&&i(s,e)&&!r(e,`flags`)?n(o,e):e.flags}}),ir=y((e,t)=>{var n=w(),r=xe(),i=Math.floor,a=n(``.charAt),o=n(``.replace),s=n(``.slice),c=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,l=/\$([$&'`]|\d{1,2})/g;t.exports=function(e,t,n,u,d,f){var p=n+e.length,m=u.length,h=l;return d!==void 0&&(d=r(d),h=c),o(f,h,function(r,o){var c;switch(a(o,0)){case`$`:return`$`;case`&`:return e;case"`":return s(t,0,n);case`'`:return s(t,p);case`<`:c=d[s(o,1,-1)];break;default:var l=+o;if(l===0)return r;if(l>m){var f=i(l/10);return f===0?r:f<=m?u[f-1]===void 0?a(o,1):u[f-1]+a(o,1):r}c=u[l-1]}return c===void 0?``:c})}}),ar=y(()=>{var e=N(),t=k(),n=w(),r=j(),i=D(),a=ie(),o=er(),s=An(),c=he(),l=rr(),u=ir(),d=M(),f=_e(),p=d(`replace`),m=TypeError,h=n(``.indexOf),g=n(``.replace),_=n(``.slice),v=Math.max;e({target:`String`,proto:!0},{replaceAll:function(e,n){var d=r(this),y,b,x,S,C,w,T,E,D,O,k=0,A=``;if(a(e)){if(y=o(e),y&&(b=s(r(l(e))),!~h(b,`g`)))throw new m("`.replaceAll` does not allow non-global regexes");if(x=c(e,p),x)return t(x,e,d,n);if(f&&y)return g(s(d),e,n)}for(S=s(d),C=s(e),w=i(n),w||(n=s(n)),T=C.length,E=v(1,T),D=h(S,C);D!==-1;)O=w?s(n(C,D,S)):u(C,S,D,[],void 0,n),A+=_(S,k,D)+O,k=D+T,D=D+E>S.length?-1:h(S,C,D+E);return k<S.length&&(A+=_(S,k)),A}})}),or=y((e,t)=>{ar(),t.exports=tt()(`String`,`replaceAll`)}),sr=y((e,t)=>{t.exports=or()}),cr=y((e,t)=>{t.exports=sr()}),lr=y((e,t)=>{var n=ze(),r=An(),i=j(),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}}),ur=y((e,t)=>{var n=w(),r=Ve(),i=An(),a=lr(),o=j(),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)}}),dr=y((e,t)=>{var n=ce();t.exports=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(n)}),fr=y(()=>{var e=N(),t=ur().start;e({target:`String`,proto:!0,forced:dr()},{padStart:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})}),pr=y((e,t)=>{fr(),t.exports=tt()(`String`,`padStart`)}),mr=y((e,t)=>{t.exports=pr()}),hr=y((e,t)=>{t.exports=mr()}),gr=`2.0.156`,_r;(e=>{e.STOPPED=`stopped`,e.READY=`ready`,e.PLAYING=`playing`,e.PAUSED=`paused`})(_r||={});var vr;(e=>{e.MPEG=`MPEG`,e.DASH=`DASH`,e.DASH_SEP=`DASH_SEP`,e.DASH_SEP_VK=`DASH_SEP`,e.DASH_WEBM=`DASH_WEBM`,e.DASH_WEBM_AV1=`DASH_WEBM_AV1`,e.DASH_STREAMS=`DASH_STREAMS`,e.DASH_WEBM_VK=`DASH_WEBM`,e.DASH_ONDEMAND=`DASH_ONDEMAND`,e.DASH_ONDEMAND_VK=`DASH_ONDEMAND`,e.DASH_LIVE=`DASH_LIVE`,e.DASH_LIVE_CMAF=`DASH_LIVE_CMAF`,e.DASH_LIVE_WEBM=`DASH_LIVE_WEBM`,e.HLS=`HLS`,e.HLS_ONDEMAND=`HLS_ONDEMAND`,e.HLS_JS=`HLS`,e.HLS_FMP4=`HLS_FMP4`,e.HLS_LIVE=`HLS_LIVE`,e.HLS_LIVE_CMAF=`HLS_LIVE_CMAF`,e.WEB_RTC_LIVE=`WEB_RTC_LIVE`})(vr||={});var yr;(e=>{e.AV1=`av1`,e.VP9=`vp9`,e.AVC1=`avc1`,e.HEV1=`hev1`})(yr||={});var br;(e=>{e.NOT_AVAILABLE=`NOT_AVAILABLE`,e.AVAILABLE=`AVAILABLE`,e.CONNECTING=`CONNECTING`,e.CONNECTED=`CONNECTED`})(br||={});var xr;(e=>{e.HTTP1=`http1`,e.HTTP2=`http2`,e.QUIC=`quic`})(xr||={});var Sr;(e=>{e.NONE=`none`,e.INLINE=`inline`,e.FULLSCREEN=`fullscreen`,e.SECOND_SCREEN=`second_screen`,e.PIP=`pip`,e.INVISIBLE=`invisible`})(Sr||={});var Cr;(e=>{e.TRAFFIC_SAVING=`traffic_saving`,e.HIGH_QUALITY=`high_quality`,e.UNKNOWN=`unknown`})(Cr||={});var wr=v(Qe(),1),Tr=v(it(),1);import{assertNever as Er,assertNonNullable as Dr,isNonNullable as Or,ValueSubject as kr,Subject as Ar,Subscription as jr,merge as Mr,observableFrom as Nr,fromEvent as Pr,map as Fr,tap as Ir,filterChanged as Lr,isNullable as Rr,ErrorCategory as zr}from"@vkontakte/videoplayer-shared/es2015";var Br=e=>new Promise((t,n)=>{let r=document.createElement(`script`);r.setAttribute(`src`,e),r.onload=()=>t(),r.onerror=e=>n(e),document.body.appendChild(r)});class Vr{constructor(e){i(this,`connection$`,new kr(void 0)),i(this,`castState$`,new kr(`NOT_AVAILABLE`)),i(this,`errorEvent$`,new Ar),i(this,`contentId`,void 0),i(this,`realCastState$`,new kr(`NOT_AVAILABLE`)),i(this,`subscription`,new jr),i(this,`log`,void 0),i(this,`params`,void 0),i(this,`isDestroyed`,!1),this.params=e,this.log=this.params.dependencies.logger.createComponentLog(`ChromecastInitializer`);let t=`chrome`in window;if(this.log({message:`[constructor] receiverApplicationId: ${this.params.receiverApplicationId}, isDisabled: ${this.params.isDisabled}, isSupported: ${t}`}),e.isDisabled||!t)return;let n=Or(window.chrome?.cast),r=!!window.__onGCastApiAvailable;n?this.initializeCastApi():(window.__onGCastApiAvailable=e=>{delete window.__onGCastApiAvailable,e&&!this.isDestroyed&&this.initializeCastApi()},r||Br(`https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1`).catch(()=>this.errorEvent$.next({id:`ChromecastLoading`,category:zr.NETWORK,message:`Script loading failed!`})))}connect(){cast.framework.CastContext.getInstance()?.requestSession()}disconnect(){var e;(e=cast.framework.CastContext.getInstance())==null||(e=e.getCurrentSession())==null||e.endSession(!0)}stopMedia(){return new Promise((e,t)=>{var n;(n=cast.framework.CastContext.getInstance())==null||(n=n.getCurrentSession())==null||(n=n.getMediaSession())==null||n.stop(new chrome.cast.media.StopRequest,e,t)})}toggleConnection(){Or(this.connection$.getValue())?this.disconnect():this.connect()}setVolume(e){let t=this.connection$.getValue();Rr(t)||(t.remotePlayer.volumeLevel=e,t.remotePlayerController.setVolumeLevel())}setMuted(e){let t=this.connection$.getValue();Rr(t)||e!==t.remotePlayer.isMuted&&t.remotePlayerController.muteOrUnmute()}destroy(){this.isDestroyed=!0,this.subscription.unsubscribe()}initListeners(){let e=new cast.framework.RemotePlayer,t=new cast.framework.RemotePlayerController(e),n=cast.framework.CastContext.getInstance();this.subscription.add(Pr(n,cast.framework.CastContextEventType.SESSION_STATE_CHANGED).subscribe(e=>{switch(e.sessionState){case cast.framework.SessionState.SESSION_STARTED:case cast.framework.SessionState.SESSION_STARTING:case cast.framework.SessionState.SESSION_RESUMED:var t;this.contentId=(t=n.getCurrentSession())==null||(t=t.getMediaSession())==null||(t=t.media)==null?void 0:t.contentId;break;case cast.framework.SessionState.NO_SESSION:case cast.framework.SessionState.SESSION_ENDING:case cast.framework.SessionState.SESSION_ENDED:case cast.framework.SessionState.SESSION_START_FAILED:this.contentId=void 0;break;default:return Er(e.sessionState)}})).add(Mr(Pr(n,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe(Ir(e=>{this.log({message:`[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: ${JSON.stringify(e)}`})}),Fr(e=>e.castState)),Nr([n.getCastState()])).pipe(Lr(),Fr(Hr),Ir(e=>{this.log({message:`realCastState$: ${e}`})})).subscribe(this.realCastState$)).add(this.realCastState$.subscribe(r=>{let i=r===`CONNECTED`,a=Or(this.connection$.getValue());if(i&&!a){var o;let r=n.getCurrentSession();Dr(r);let i=r.getCastDevice(),a=(o=r.getMediaSession())==null||(o=o.media)==null?void 0:o.contentId;(Rr(a)||a===this.contentId)&&(this.log({message:`connection created`}),this.connection$.next({remotePlayer:e,remotePlayerController:t,session:r,castDevice:i}))}else !i&&a&&(this.log({message:`connection destroyed`}),this.connection$.next(void 0));this.castState$.next(r===`CONNECTED`?Or(this.connection$.getValue())?`CONNECTED`:`AVAILABLE`:r)}))}initializeCastApi(){let e,t,n;try{e=cast.framework.CastContext.getInstance(),t=chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,n=chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}catch{return}try{e.setOptions({receiverApplicationId:this.params.receiverApplicationId??t,autoJoinPolicy:n}),this.initListeners()}catch(e){this.errorEvent$.next({id:`ChromecastInitializer`,category:zr.EXTERNAL_API,message:`[initializeCastApi] failed`,thrown:e})}}}var Hr=e=>{switch(e){case cast.framework.CastState.NO_DEVICES_AVAILABLE:return`NOT_AVAILABLE`;case cast.framework.CastState.NOT_CONNECTED:return`AVAILABLE`;case cast.framework.CastState.CONNECTING:return`CONNECTING`;case cast.framework.CastState.CONNECTED:return`CONNECTED`;default:return Er(e)}};import{assertNonNullable as Ur,combine as Wr,debounce as Gr,ErrorCategory as Kr,filter as qr,filterChanged as Jr,isNonNullable as Yr,isNullable as Xr,map as Zr,Subscription as Qr,ValueSubject as $r}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as ei,assertNonNullable as ti,ErrorCategory as ni,getHighestQuality as ri,isNonNullable as ii}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as ai}from"@vkontakte/videoplayer-shared/es2015";var oi=(e,t=0,n=0)=>{switch(n){case 0:return e.replace(`_offset_p`,t===0?``:`_`+t.toFixed(0));case 1:{if(t===0)return e;let n=new URL(e);return n.searchParams.append(`playback_shift`,t.toFixed(0)),n.toString()}case 2:{let n=new URL(e);return!n.searchParams.get(`offset_p`)&&t===0?e:(n.searchParams.set(`offset_p`,t.toFixed(0)),n.toString())}default:ai(n)}return e},si=(e,t)=>{switch(t){case 0:return NaN;case 1:{let t=new URL(e);return Number(t.searchParams.get(`playback_shift`))}case 2:{let t=new URL(e);return Number(t.searchParams.get(`offset_p`)??0)}default:ai(t)}},ci=e=>{let{source:t,format:n,meta:r,output:i}=e,a,o,s;switch(n){case`MPEG`:{let e=t[n];ti(e);let r=ri(Object.keys(e));ti(r);let i=e[r];ti(i),a=i,o=`video/mp4`,s=li();break}case`HLS`:case`HLS_FMP4`:case`HLS_ONDEMAND`:{let e=t[n];ti(e),a=e.url,o=`application/x-mpegurl`,s=li();break}case`DASH_SEP`:case`DASH_ONDEMAND`:case`DASH_WEBM`:case`DASH_WEBM_AV1`:case`DASH_STREAMS`:{let e=t[n];ti(e),a=e.url,o=`application/dash+xml`,s=li();break}case`DASH_LIVE_CMAF`:{let e=t[n];ti(e),a=e.url,o=`application/dash+xml`,s=ui();break}case`HLS_LIVE`:case`HLS_LIVE_CMAF`:{let e=t[n];ti(e),a=oi(e.url),o=`application/x-mpegurl`,s=ui();break}case`DASH_LIVE`:case`WEB_RTC_LIVE`:{let e=`Unsupported format for Chromecast`,t=Error(e);throw i.error$.next({id:`ChromecastProvider.createMediaInfo()`,category:ni.VIDEO_PIPELINE,message:e,thrown:t}),t}case`DASH`:case`DASH_LIVE_WEBM`:throw Error(`${n} is no longer supported`);default:return ei(n)}let c=di(r.videoId??a,o);c.contentUrl=a,c.streamType=s,c.metadata=fi();let{title:l,subtitle:u}=r;return ii(l)&&(c.metadata.title=l),ii(u)&&(c.metadata.subtitle=u),c};function li(){var e;return((e=chrome.cast)==null||(e=e.media)==null||(e=e.StreamType)==null?void 0:e.BUFFERED)??`BUFFERED`}function ui(){var e;return((e=chrome.cast)==null||(e=e.media)==null||(e=e.StreamType)==null?void 0:e.LIVE)??`LIVE`}function di(e,t){var n;return!((n=chrome.cast)==null||(n=n.media)==null)&&n.MediaInfo?new chrome.cast.media.MediaInfo(e,t):{contentId:e,contentType:t,metadata:{title:``,subtitle:``},streamType:li()}}function fi(){var e;return!((e=chrome.cast)==null||(e=e.media)==null)&&e.GenericMediaMetadata?new chrome.cast.media.GenericMediaMetadata:{images:[],metadataType:0,releaseDate:``,subtitle:``,title:``,releaseYear:1970,type:0}}var P=(e,t,n=!1)=>{let r=e.getTransition();(n||!r||r.to===t)&&e.setState(t)};class pi{constructor(e){i(this,`params`,void 0),i(this,`interval`,0),i(this,`startVideoPosition`,void 0),i(this,`startTs`,void 0),this.params=e}start(e=0){clearInterval(this.interval),this.startVideoPosition=e,this.startTs=Date.now(),this.interval=window.setInterval(()=>{let e=(Date.now()-this.startTs)/1e3,t=this.startVideoPosition+e;this.params.output.position$.next(t)},1e3)}pause(){clearInterval(this.interval)}destroy(){clearInterval(this.interval)}}import{assertNever as mi}from"@vkontakte/videoplayer-shared/es2015";import{isBrowserWindow as hi,ValueSubject as gi}from"@vkontakte/videoplayer-shared/es2015";var _i=v(it(),1);import{getWindow as vi}from"@vkontakte/videoplayer-shared/es2015";class yi{constructor(){i(this,`_current`,void 0),i(this,`_current_version`,void 0),i(this,`_chromeVersion`,void 0),i(this,`_firefoxVersion`,void 0),i(this,`_safariVersion`,void 0),i(this,`_operaVersion`,void 0),i(this,`_edgeVersion`,void 0),i(this,`_yandexVersion`,void 0),i(this,`_isMiuiBrowser`,!1)}get current(){return this._current}get isChrome(){return this.current===`Chrome`}get isChromiumBased(){return _i.default([`Chrome`,`Chromium`,`Opera`,`Yandex`,`Edge`,`SamsungBrowser`],this.current)}get isFirefox(){return this.current===`Firefox`}get isSafari(){return this.current===`Safari`}get isOpera(){return this.current===`Opera`}get isEdge(){return this.current===`Edge`}get isYandex(){return this.current===`Yandex`}get isSamsungBrowser(){return this.current===`SamsungBrowser`}get currentVersion(){return this._current_version}get chromeVersion(){return this._chromeVersion}get firefoxVersion(){return this._firefoxVersion}get safariVersion(){return this._safariVersion}get operaVersion(){return this._operaVersion}get edgeVersion(){return this._edgeVersion}get yandexVersion(){return this._yandexVersion}get isMiuiBrowser(){return this._isMiuiBrowser}detect(){let{userAgent:e}=navigator;try{let t=/yabrowser/i.test(e)?`Yandex`:void 0,n=/samsungbrowser/i.test(e)?`SamsungBrowser`:void 0,r=/chrome|crios/i.test(e)?`Chrome`:void 0,i=/chromium/i.test(e)?`Chromium`:void 0,a=/firefox|fxios/i.test(e)?`Firefox`:void 0,o=/webkit|safari|khtml/i.test(e)?`Safari`:void 0,s=/opr\//i.test(e)?`Opera`:void 0,c=/edg/i.test(e)?`Edge`:void 0;this._isMiuiBrowser=/(XiaoMi)|(MiuiBrowser)/i.test(e),this._current=t||n||a||s||c||r||i||o||`Rest`}catch(e){console.error(e)}this.isChrome&&this.detectChromeVersion(),this.isFirefox&&this.detectFirefoxVersion(),this.isSafari&&this.detectSafariVersion(),this.isOpera&&this.detectOperaVersion(),this.isEdge&&this.detectEdgeVersion(),this.isYandex&&this.detectYandexVersion()}detectVersion(e){try{let{userAgent:t}=vi().navigator,n=t.match(e);if(!n)return;let r=n[1],i=parseInt(r,10);if(!isNaN(i))return this._current_version=i,i}catch(e){console.error(e)}}detectChromeVersion(){this._chromeVersion=this.detectVersion(/Chrome\/(\d+\.\d+)/)}detectFirefoxVersion(){this._firefoxVersion=this.detectVersion(/Firefox\/(\d+\.\d+)/)}detectSafariVersion(){this._safariVersion=this.detectVersion(/Version\/(\d+)/)}detectOperaVersion(){this._operaVersion=this.detectVersion(/OPR\/(\d+\.\d+)/)}detectEdgeVersion(){this._edgeVersion=this.detectVersion(/Edg\/(\d+\.\d+)/)}detectYandexVersion(){this._yandexVersion=this.detectVersion(/YaBrowser\/(\d+\.\d+\.\d+)/)}}var bi=v(it(),1);import{getWindow as xi,isBrowserWindow as Si}from"@vkontakte/videoplayer-shared/es2015";var Ci=()=>{var e;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(navigator.appVersion??navigator.userAgent)||((e=navigator)==null||(e=e.userAgentData)==null?void 0:e.mobile)};class wi{constructor(e){i(this,`_displayChecker`,void 0),i(this,`_isMobile`,void 0),i(this,`_current`,void 0),i(this,`_iosVersion`,void 0),i(this,`_highEntropyValues`,{}),i(this,`_os`,{name:`Unknown`,version:`Unknown`,full:`Unknown`}),i(this,`_details`,{vendor:`Unknown`,model:`Unknown`}),this._displayChecker=e}get current(){return this._current}get os(){return this._os}get details(){return this._details}get isIOS(){return this._highEntropyValues.platform===`iOS`||this.os.name.toLowerCase().includes(`ios`)||bi.default([`iPhone`,`iPad`,`iPod`],this.current)}get isMac(){return this._highEntropyValues.platform===`macOS`||this.os.name.toLowerCase().includes(`mac`)||this.current===`Mac`}get isApple(){return this.isIOS||this.isMac}get isIphoneOrOldIpad(){if(!this.isApple||!this._displayChecker.isTouch)return!1;let e=this.current===`iPad`||this._displayChecker.width>700,t=this._iosVersion;return!e||e&&!!t&&t<16}get isAndroid(){return this._highEntropyValues.platform===`Android`||this.os.name.toLowerCase().includes(`android`)||this.current===`Android`}get isWindows(){return this.os.name.toLowerCase().includes(`windows`)}get isLinux(){return this.os.name.toLowerCase().includes(`linux`)&&!this.isAndroid}get isMobile(){return this._highEntropyValues.mobile||this._isMobile}get iOSVersion(){return this._iosVersion}detect(){let e=xi();if(!Si(e))return;let{userAgent:t}=e.navigator;try{this._isMobile=Ci()}catch(e){console.error(`DeviceChecker: calling isMobile error - `,e)}this.detectDevice(t),this.detectOS(t),this.detectDeviceDetails(t),this.detectHighEntropyValues(),this.isIOS&&this.detectIOSVersion()}detectHighEntropyValues(){var e=this;return a(function*(){let t=xi();if(!Si(t))return;let{userAgentData:n}=t.navigator;if(n?.getHighEntropyValues){let t=yield n.getHighEntropyValues([`architecture`,`bitness`,`brands`,`mobile`,`platform`,`formFactor`,`model`,`platformVersion`,`wow64`]);e._highEntropyValues=t,t.platform&&(e._os.name=e.normalizeOSName(t.platform),t.platformVersion&&(e._os.version=e.normalizeOSVersion(t.platformVersion),e._os.full=`${e._os.name} ${e._os.version}`)),t.model&&(e._details.model=t.model)}})()}detectDevice(e){try{let t=/android/i.test(e)?`Android`:void 0,n=/iphone/i.test(e)?`iPhone`:void 0,r=/ipad/i.test(e)?`iPad`:void 0,i=/ipod/i.test(e)?`iPod`:void 0,a=/mac/i.test(e)?`Mac`:void 0,o=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(e)?`RestMobile`:void 0;this._current=t||n||r||i||o||a||`Desktop`}catch(e){console.error(`DeviceChecker: device detection error - `,e)}}detectOS(e){try{for(let[t,n]of[[/(windows nt) (6\.[23]); arm/i,[`Windows RT`]],[/(windows nt) (6\.3); arm/i,[`Windows RT 8.1`]],[/(windows (?:phone|mobile|iot))(?: os)?[/ ]?([\d.]+)/i,[`Windows Mobile`,2]],[/(windows)[/ ](xp|vista|7|8(\.1)?|10|11|2000|me)/i,[1,1]],[/windows nt ?([\d.]+)/i,[`Windows`,1]],[/(windows)[/ ](95|98|me|2000|xp|vista|7|8|8\.1|10|11)/i,[1,2]],[/(iphone os|cpu iphone os) ([\d_.]+)/i,[`iOS`,2]],[/(ipad os|cpu os) ([\d_.]+)/i,[`iPadOS`,2]],[/(ipod os|cpu ipod os) ([\d_.]+)/i,[`iOS`,2]],[/(?:ios|os) ([\d_.]+) like mac os x/i,[`iOS`,1]],[/cfnetwork\/.+darwin/i,[`iOS`]],[/(mac os x) ?([\d_.]+)/i,[`macOS`,2]],[/(macintosh|mac os)/i,[`macOS`]],[/(android) ([\d.]+)/i,[1,2]],[/(harmonyos)[/ ]?([\d.]*)/i,[`HarmonyOS`,2]],[/\b(ubuntu|debian|fedora|centos|arch|linux)(?:[-/ ]([\w.]+))?/i,[1,2]],[/(cros)\D*([\d.]+)/i,[`Chrome OS`,2]],[/(freebsd|openbsd|netbsd|dragonfly)[/ ]?([\w.]*)/i,[1,2]],[/(sunos|solaris)?([\d.]*)/i,[`Solaris`,2]],[/(aix)?([\d.]*)/i,[`AIX`,2]]]){let r=e.match(t);if(r){let t=n.length>0,i=n.length>1,a=`Unknown`,o=`Unknown`;if(t){let e=n[0];typeof e==`number`?e<r.length&&r[e]!==void 0&&(a=r[e]):a=e}if(i){let e=n[1];typeof e==`number`?e<r.length&&r[e]!==void 0&&(o=r[e]):e!==void 0&&(o=e)}else r[2]===void 0?r[1]!==void 0&&t&&typeof n[0]==`string`&&(o=r[1]):o=r[2];a=this.normalizeOSName(a),o=this.normalizeOSVersion(o,a),a===`iOS`&&/ipad/i.test(e)?a=`iPadOS`:a===`iPadOS`&&/ip(hone|od)/i.test(e)&&(a=`iOS`),this._os={name:a,version:o||`Unknown`,full:o&&o!==`Unknown`?`${a} ${o}`:a};break}}}catch(e){console.error(`DeviceChecker: OS detection error - `,e)}}normalizeOSName(e){if(!e)return`Unknown`;let t=e.toLowerCase();return t.includes(`windows`)?`Windows`:t.includes(`mac os`)||t.includes(`macintosh`)?`macOS`:t.includes(`iphone`)||t.includes(`ios`)?`iOS`:t.includes(`ipados`)?`iPadOS`:t.includes(`android`)?`Android`:t.includes(`harmonyos`)?`HarmonyOS`:t.includes(`linux`)?`Linux`:t.includes(`cros`)?`Chrome OS`:t.includes(`freebsd`)?`FreeBSD`:t.includes(`openbsd`)?`OpenBSD`:t.includes(`solaris`)||t.includes(`sunos`)?`Solaris`:t.includes(`aix`)?`AIX`:e}normalizeOSVersion(e,t){if(!e)return`Unknown`;if(e!==`Unknown`&&(e=e.replace(/_/g,`.`),t===`Windows`)){let t=parseFloat(e);if(!isNaN(t)){if(t>=11)return`11`;if(t>=10)return`10`;if(t===6.3)return`8.1`;if(t===6.2)return`8`;if(t===6.1)return`7`;if(t===6)return`Vista`;if(t===5.1||t===5.2)return`XP`;if(t===5)return`2000`;if(t===4)return`NT 4.0`}}return e}detectDeviceDetails(e){try{for(let[t,n]of[[/(iphone)/i,[`Apple`,`iPhone`]],[/(ipad)/i,[`Apple`,`iPad`]],[/(ipod)/i,[`Apple`,`iPod`]],[/(macintosh)/i,[`Apple`,`Macintosh`]],[/(windows[\w\-_ ]*phone)/i,[`Microsoft`,0]],[/(windows nt|win64|win32|wow64)/i,[`Microsoft`,`PC`]],[/\b(sch-i[89]0\d|shw-m380s|sm-[ptxs]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i,[`Samsung`,1]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?\d+a?|galaxy nexus)/i,[`Samsung`,1]],[/samsung[- ]((?!sm-[lr]|browser)[-\w]+)/i,[`Samsung`,1]],[/sec-(sgh\w+)/i,[`Samsung`,1]],[/smart-tv.+(samsung)/i,[`Samsung`,`Smart TV`]],[/(samsung).*tizen/i,[`Samsung`,`Smart TV`]],[/(pixel (?:c|tablet|[0-9a-z ]+))/i,[`Google`,1]],[/(pixelbook(?: go)?)/i,[`Google`,1]],[/nexus [0-9]/i,[`Google`,0]],[/(redmi[-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(mi[\w\-_ ]+)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(poco[\w ]+)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(hm[-_ ]?note?[\w ]*)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(?:xiao)?mi[\w\-_ ]+pad/i,[`Xiaomi`,0]],[/(?:huawei|honor) ?([-\w ]+)[;)]/i,[`Huawei`,1]],[/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][\dc][adnt]?)\b(?!.+d\/s)/i,[`Huawei`,1]],[/\b((?:ag[rs][2356]?k?|bah[234]?|bg[2o]|bt[kv]|cmr|cpn|db[ry]2?|jdn2|got|kob2?k?|mon|pce|scm|sht?|[tw]gr|vrd)-[ad]?[lw][0125][09]b?)/i,[`Huawei`,1]],[/(?:one)?(?:plus)? ?([a\d0]\d\d\d?)(?: b|\))/i,[`OnePlus`,1]],[/droid.+; (cph2[3-6]\d[13579]|((?:gm|hd)19|(?:ac|be|in|kb)20|(?:d[en]|eb|le|mt)21|ne22)[0-2]\d)(?: bui|\))/i,[`OnePlus`,1]],[/(oneplus)[-_ ]?([-\w]*)/i,[`OnePlus`,2]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i,[`Realme`,1]],[/(realme)[-_ ]?([-\w]*)/i,[`Realme`,2]],[/; (\w+) bui.+ oppo/i,[`OPPO`,1]],[/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i,[`OPPO`,1]],[/\b(opd2(\d{3}a?))(?: bui|\))/i,[`OPPO`,1]],[/(oppo)[-_ ]?([-\w]*)/i,[`OPPO`,2]],[/; vivo (\w+)(?: bui|\))/i,[`Vivo`,1]],[/\b(v[12]\d{3}\w?[at])(?: bui|;)/i,[`Vivo`,1]],[/(vivo)[-_ ]?([-\w]*)/i,[`Vivo`,2]],[/\bmot(?:orola)?[- ]([\w\s]+)(\)| bui)/i,[`Motorola`,1]],[/((?:moto(?! 360)[-\w() ]+|xt\d{3,4}[cgkosw+]?[-\d]*|nexus 6)(?= bui|\)))/i,[`Motorola`,1]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b/i,[`Motorola`,0]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i,[`Motorola`,0]],[/droid.+; ([a-z]?\d[0-2]{2}[a-z]{2}|[c-g]\d{4}|so[-gl]\w+|xq-[a-z]{2}\d\d)(?= bui|\))/i,[`Sony`,1]],[/sony tablet [ps]/i,[`Sony`,`Xperia Tablet`]],[/\b(?:sony)?sgp\w+(?: bui|\))/i,[`Sony`,0]],[/(sony)[-_ ]?([-\w]*)/i,[`Sony`,2]],[/\blg[-e;/ ]+(?!.*(?:browser|netcast|android tv|watch|webos))(\w+)/i,[`LG`,1]],[/\blg-?([\d\w]+) bui/i,[`LG`,1]],[/(lm(?:-?f100[nv]?|-[\w.]+)(?= bui|\))|nexus [45])/i,[`LG`,1]],[/((?=lg)?[vl]k-?\d{3}) bui/i,[`LG`,0]],[/(lg)[-_ ]?([-\w]*)/i,[`LG`,2]],[/(?:maemo|nokia).*(n900|lumia \d+|rm-\d+)/i,[`Nokia`,1]],[/nokia[-_ ]?(([-\w. ]*?))(?: bui|\)|;|\/)/i,[`Nokia`,1]],[/(nokia) (t[12][01])/i,[`Nokia`,2]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i,[`ASUS`,1]],[/(?:asus[-_ ])?(zenfone[\w\-_ ]*)/i,[`ASUS`,1]],[/(rog[\w\-_ ]*)/i,[`ASUS`,1]],[/(asus)[-_ ]?([-\w]*)/i,[`ASUS`,2]],[/lenovo[-_ ]?([-\w ]+?)(?: bui|\)|\/)/i,[`Lenovo`,1]],[/(ideatab[-\w ]+|602lv|d-42a|a101lv|a2109a|a3500-hv|s[56]000|pb-6505[my]|tb-?x?\d{3,4}(?:f[cu]|xu|[av])|yt\d?-[jx]?\d+[lfmx])(?: bui|;|\)|\/)/i,[`Lenovo`,1]],[/(thinkpad[\w\-_ ]*)/i,[`Lenovo`,0]],[/(kf[a-z]{2}[a-z]*)(?: bui|\))/i,[`Amazon`,1]],[/(alexa)webm/i,[`Amazon`,`Echo`]],[/(fire[\w\-_ ]*)/i,[`Amazon`,0]],[/(amazon)[-_ ]?([-\w]*)/i,[`Amazon`,2]],[/(?:blackberry|\(bb10;) (\w+)/i,[`BlackBerry`,1]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,[`BlackBerry`,1]],[/(playbook);[-\w),; ]+(rim)/i,[`BlackBerry`,1]],[/(microsoft); (lumia[\w ]+)/i,[`Microsoft`,2]],[/(surface duo)/i,[`Microsoft`,`Surface Duo`]],[/(surface[\w\-_ ]*)/i,[`Microsoft`,0]],[/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,[`ZTE`,2]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,[`HTC`,2]],[/(alcatel|tcl)[-_ ]?([-\w]*)/i,[1,2]],[/(meizu)[-_ ]?([-\w]*)/i,[`Meizu`,2]],[/(tecno)[-_ ]?([-\w]*)/i,[`Tecno`,2]],[/(infinix)[-_ ]?([-\w]*)/i,[`Infinix`,2]],[/(micromax)[-_ ]?([-\w]*)/i,[`Micromax`,2]],[/(lava)[-_ ]?([-\w]*)/i,[`Lava`,2]],[/(panasonic)[-_ ]?([-\w]*)/i,[`Panasonic`,2]],[/(sharp)\/?([-\w]*)/i,[`Sharp`,2]],[/(benq)[-_ ]?([-\w]*)/i,[`BenQ`,2]],[/(palm)[-_ ]?([-\w]*)/i,[`Palm`,2]],[/(vertu)[-_ ]?([-\w]*)/i,[`Vertu`,2]],[/(gionee)[-_ ]?([-\w]*)/i,[`Gionee`,2]],[/(doogee)[-_ ]?([-\w]*)/i,[`Doogee`,2]],[/(ulefone)[-_ ]?([-\w]*)/i,[`Ulefone`,2]],[/(blackview)[-_ ]?([-\w]*)/i,[`Blackview`,2]],[/(cubot)[-_ ]?([-\w]*)/i,[`Cubot`,2]],[/(umidigi)[-_ ]?([-\w]*)/i,[`UMIDIGI`,2]],[/(oukitel)[-_ ]?([-\w]*)/i,[`Oukitel`,2]],[/(fairphone)[-_ ]?([-\w]*)/i,[`Fairphone`,2]],[/(cat)[-_ ]?([-\w]*)/i,[`Cat`,2]],[/(energy)[-_ ]?([-\w]*)/i,[`Energizer`,2]],[/(land rover)[-_ ]?([-\w]*)/i,[`Land Rover`,2]],[/(shield[\w\-_ ]*)/i,[`Nvidia`,0]],[/(crkey)/i,[`Google`,`Chromecast`]],[/(roku)[\dx]*/i,[`Roku`,0]],[/(apple)[-_ ]?tv/i,[`Apple`,`TV`]],[/(amazon)[-_ ]?tv/i,[`Amazon`,`Fire TV`]],[/(google)[-_ ]?tv/i,[`Google`,`TV`]],[/(smart[\w\-_ ]*tv)/i,[0,`Smart TV`]],[/(playstation[\w\-_ ]*)/i,[`Sony`,0]],[/(nintendo[\w\-_ ]*)/i,[`Nintendo`,0]],[/(xbox[\w\-_ ]*)/i,[`Microsoft`,0]],[/(googlebot)/i,[`Google`,`Bot`]],[/(bingbot)/i,[`Microsoft`,`Bing Bot`]],[/(yandexbot)/i,[`Yandex`,`Bot`]],[/(slackbot)/i,[`Slack`,`Bot`]],[/(twitterbot)/i,[`Twitter`,`Bot`]],[/(facebookbot)/i,[`Facebook`,`Bot`]],[/(linkedinbot)/i,[`LinkedIn`,`Bot`]],[/(tesla)[-_ ]?([-\w]*)/i,[`Tesla`,2]],[/(raspberry[\w\-_ ]*)/i,[`Raspberry Pi`,0]]]){let r=e.match(t);if(r){let e=n[0],t=n[1],i=typeof e==`number`?r[e]===void 0?`Unknown`:this.normalizeVendorName(r[e]):this.normalizeVendorName(e),a=`Unknown`;typeof t==`number`?a=r[t]===void 0?`Unknown`:r[t]:t===void 0?r[1]===void 0?r[0]!==void 0&&(a=r[0]):a=r[1]:a=t,a=this.normalizeModelName(a,i),this.details.vendor=i,this.details.model=a;break}}}catch(e){console.error(`DeviceChecker: device details detection error - `,e)}}normalizeVendorName(e){return e?{apple:`Apple`,samsung:`Samsung`,google:`Google`,xiaomi:`Xiaomi`,huawei:`Huawei`,oneplus:`OnePlus`,oppo:`OPPO`,vivo:`Vivo`,realme:`Realme`,motorola:`Motorola`,sony:`Sony`,lg:`LG`,nokia:`Nokia`,asus:`ASUS`,lenovo:`Lenovo`,amazon:`Amazon`,blackberry:`BlackBerry`,microsoft:`Microsoft`,zte:`ZTE`,htc:`HTC`,alcatel:`Alcatel`,tcl:`TCL`,meizu:`Meizu`,tecno:`Tecno`,infinix:`Infinix`,micromax:`Micromax`,lava:`Lava`,panasonic:`Panasonic`,sharp:`Sharp`,benq:`BenQ`,palm:`Palm`,honor:`Honor`,nvidia:`NVIDIA`,roku:`Roku`}[e.toLowerCase()]||e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():`Unknown`}normalizeModelName(e,t){if(!e||e===`Unknown`)return e;if(e===`0`)return`Unknown`;let n=e.replace(/^build\//i,``).replace(/\s+bui$/i,``).replace(/\)$/,``).replace(/[;,)]/g,``).replace(/\s*\(.*?\)\s*/g,``).trim(),r=t.toLowerCase();return r.includes(`samsung`)?n=n.replace(/^(sm-|gt-|sgh-|sch-)/i,``):r.includes(`xiaomi`)?n=n.replace(/^(mi[\s\-_]*|redmi[\s\-_]*)/i,``):r.includes(`oneplus`)?n=n.replace(/^oneplus[\s\-_]*/i,``):r.includes(`google`)&&(n=n.replace(/^(pixel[\s\-_]*|nexus[\s\-_]*)/i,``)),n=n.replace(/_/g,` `).replace(/-/g,` `).replace(/\s+/g,` `).trim(),n?(n.length>0&&/^[a-z]/.test(n)&&(n=n.charAt(0).toUpperCase()+n.slice(1)),n):`Unknown`}detectIOSVersion(){try{let e=xi();if(!Si(e))return;if(this._highEntropyValues.platformVersion){let e=this._highEntropyValues.platformVersion.split(`.`).slice(0,2).join(`.`);this._iosVersion=parseFloat(e);return}if(this._os.version!==`Unknown`){let e=this._os.version.split(`.`),t=e.length>=2?`${e[0]}.${e[1]}`:e[0];this._iosVersion=parseFloat(t);return}let t=e.navigator.userAgent.match(/OS (\d+(_\d+)?)/i);t?.[1]&&(this._iosVersion=parseFloat(t[1].replace(/_/g,`.`)))}catch(e){console.error(`DeviceChecker: iOS version detection error - `,e)}}}import{getWindow as Ti,isBrowserWindow as Ei}from"@vkontakte/videoplayer-shared/es2015";class Di{constructor(){i(this,`_maxTouchPoints`,void 0),i(this,`_height`,void 0),i(this,`_width`,void 0),i(this,`_isHdr`,void 0),i(this,`_pixelRatio`,void 0),i(this,`_screenHeight`,void 0),i(this,`_screenWidth`,void 0),i(this,`_colorDepth`,void 0)}get isTouch(){return typeof this._maxTouchPoints==`number`?this._maxTouchPoints>1:`ontouchstart`in Ti()}get maxTouchPoints(){return this._maxTouchPoints}get height(){return this._height}get width(){return this._width}get screenHeight(){return this._screenHeight}get screenWidth(){return this._screenWidth}get pixelRatio(){return this._pixelRatio}get isHDR(){return this._isHdr}get colorDepth(){return this._colorDepth}detect(){let e=Ti();if(!Ei(e))return;let{navigator:t,screen:n}=e,{maxTouchPoints:r}=t;try{this._maxTouchPoints=r??0,this._isHdr=!!e.matchMedia(`(dynamic-range: high)`)?.matches,this._colorDepth=n.colorDepth}catch(e){console.error(e)}try{this._pixelRatio=e.devicePixelRatio||1,this._height=n.height,this._width=n.width,this._height=n.height,this._screenHeight=this._height*this._pixelRatio,this._screenWidth=this._width*this._pixelRatio}catch(e){console.error(e)}}}import{getWindow as Oi,isBrowserWindow as ki}from"@vkontakte/videoplayer-shared/es2015";var Ai=()=>window.ManagedMediaSource||window.MediaSource,ji=()=>{var e;return!!(window.ManagedMediaSource&&!((e=window.ManagedSourceBuffer)==null||(e=e.prototype)==null)&&e.appendBuffer)},Mi=()=>{var e;return!!(window.MediaSource&&!((e=window.SourceBuffer)==null||(e=e.prototype)==null)&&e.appendBuffer)},Ni=()=>window.ManagedMediaSource?new ManagedMediaSource:new MediaSource,Pi=Oi().document?.createElement(`video`),Fi=`video/mp4; codecs="avc1.42000a,mp4a.40.2"`,Ii=`video/mp4; codecs="hev1.1.6.L93.B0"`,Li=`video/webm; codecs="vp09.00.10.08"`,Ri=`video/webm; codecs="av01.0.00M.08"`,zi=`audio/mp4; codecs="mp4a.40.2"`,Bi=`audio/webm; codecs="opus"`,Vi;(function(){var e=a(function*(){let e=Oi();if(!ki(e)||!(`mediaCapabilities`in e.navigator))return;let t={type:`media-source`,video:{contentType:`video/webm`,width:1280,height:720,bitrate:1e6,framerate:30}},[n,r]=yield Promise.all([e.navigator.mediaCapabilities.decodingInfo(o(o({},t),{},{video:o(o({},t.video),{},{contentType:Ri})})),e.navigator.mediaCapabilities.decodingInfo(o(o({},t),{},{video:o(o({},t.video),{},{contentType:Li})}))]);Vi={DASH_WEBM_AV1:n,DASH_WEBM:r}});return function(){return e.apply(this,arguments)}})()().catch(e=>{console.log(Pi),console.error(e)});class Hi{constructor(e,t){i(this,`_video`,void 0),i(this,`_deviceChecker`,void 0),i(this,`_browserChecker`,void 0),i(this,`_protocols`,void 0),i(this,`_containers`,void 0),i(this,`_codecs`,void 0),i(this,`_nativeHlsSupported`,void 0),this._deviceChecker=e,this._browserChecker=t}get protocols(){return this._protocols}get containers(){return this._containers}get codecs(){return this._codecs}get webmDecodingInfo(){return Vi}get supportedCodecs(){return Object.keys(this._codecs).filter(e=>this._codecs[e])}get nativeHlsSupported(){return this._nativeHlsSupported}detect(){let e=Oi();if(ki(e)){this._video=e.document.createElement(`video`);try{var t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g;this._protocols={mms:ji(),mse:Mi(),hls:!!((t=this._video).canPlayType?.call(t,`application/x-mpegurl`)||(n=this._video).canPlayType?.call(n,`vnd.apple.mpegURL`)),webrtc:!!e.RTCPeerConnection,ws:!!e.WebSocket},this._containers={mp4:!!(r=this._video).canPlayType?.call(r,`video/mp4`),webm:!!(i=this._video).canPlayType?.call(i,`video/webm`),cmaf:!0};let _=!!(!((a=Ai())==null||(o=a.isTypeSupported)==null)&&o.call(a,Fi)),v=!!(!((s=Ai())==null||(c=s.isTypeSupported)==null)&&c.call(s,Ii)),y=!!(!((l=Ai())==null||(u=l.isTypeSupported)==null)&&u.call(l,zi));this._codecs={h264:_,h265:v,vp9:!!(!((d=Ai())==null||(f=d.isTypeSupported)==null)&&f.call(d,Li)),av1:!!(!((p=Ai())==null||(m=p.isTypeSupported)==null)&&m.call(p,Ri)),aac:y,opus:!!(!((h=Ai())==null||(g=h.isTypeSupported)==null)&&g.call(h,Bi)),mpeg:(_||v)&&y},this._nativeHlsSupported=this._protocols.hls&&this._containers.mp4}catch(e){console.error(e)}try{this.destroyVideoElement()}catch(e){console.error(`Error destroying video element:`,e)}}}destroyVideoElement(){if(!this._video)return;if(this._video.pause(),this._video.currentTime=0,this._video.removeAttribute(`src`),this._video.src=``,this._video.load(),this._video.remove){this._video.remove(),this._video=null;return}this._video.parentNode&&this._video.parentNode.removeChild(this._video);let e=this._video.cloneNode(!1);this._video.parentNode?.replaceChild(e,this._video),this._video=null}}import{getWindow as Ui,isBrowserWindow as Wi}from"@vkontakte/videoplayer-shared/es2015";var Gi=`audio/mpeg`;class Ki{constructor(){i(this,`_audio`,void 0),i(this,`_containers`,void 0),i(this,`_codecs`,void 0)}supportMp3(){return this._codecs.mp3&&this._containers.mpeg}detect(){let e=Ui();if(Wi(e)){this._audio=e.document.createElement(`audio`);try{var t,n,r;this._containers={mpeg:!!(t=this._audio).canPlayType?.call(t,Gi)},this._codecs={mp3:!!(!((n=Ai())==null||(r=n.isTypeSupported)==null)&&r.call(n,Gi))}}catch(e){console.error(e)}try{this.destroyAudioElement()}catch(e){console.error(`Error destroying audio element:`,e)}}}destroyAudioElement(){if(!this._audio)return;if(this._audio.pause(),this._audio.currentTime=0,this._audio.removeAttribute(`src`),this._audio.src=``,this._audio.load(),this._audio.remove){this._audio.remove(),this._audio=null;return}this._audio.parentNode&&this._audio.parentNode.removeChild(this._audio);let e=this._audio.cloneNode(!1);this._audio.parentNode?.replaceChild(e,this._audio),this._audio=null}}class qi{constructor(){i(this,`isInited$`,new gi(!1)),i(this,`_displayChecker`,void 0),i(this,`_deviceChecker`,void 0),i(this,`_browserChecker`,void 0),i(this,`_videoChecker`,void 0),i(this,`_audioChecker`,void 0),this._displayChecker=new Di,this._deviceChecker=new wi(this._displayChecker),this._browserChecker=new yi,this._videoChecker=new Hi(this._deviceChecker,this._browserChecker),this._audioChecker=new Ki,this.detect()}get display(){return this._displayChecker}get device(){return this._deviceChecker}get browser(){return this._browserChecker}get video(){return this._videoChecker}get audio(){return this._audioChecker}detect(){var e=this;return a(function*(){hi()&&(e._displayChecker.detect(),e._deviceChecker.detect(),e._browserChecker.detect(),e._videoChecker.detect(),e._audioChecker.detect(),e.isInited$.next(!0))})()}}var F=new qi,Ji=e=>{let{containers:t,protocols:n,codecs:r,nativeHlsSupported:i}=F.video,a=(r.h264||r.h265)&&r.aac,o=n.mse||n.mms;return e.filter(e=>{switch(e){case`DASH_SEP`:return o&&t.mp4&&a;case`DASH_WEBM`:return o&&t.webm&&r.vp9&&r.opus;case`DASH_WEBM_AV1`:return o&&t.webm&&r.av1&&r.opus;case`DASH_STREAMS`:return o&&(t.mp4&&a||t.webm&&(r.vp9||r.av1)&&(r.opus||r.aac));case`DASH_LIVE`:return o&&t.mp4&&a;case`DASH_LIVE_CMAF`:return o&&t.mp4&&a&&t.cmaf;case`DASH_ONDEMAND`:return o&&t.mp4&&a;case`HLS`:case`HLS_ONDEMAND`:case`HLS_FMP4`:case`HLS_LIVE`:case`HLS_LIVE_CMAF`:return i;case`MPEG`:return t.mp4;case`DASH`:case`DASH_LIVE_WEBM`:return!1;case`WEB_RTC_LIVE`:return n.webrtc&&n.ws&&r.h264&&(t.mp4||t.webm);default:return mi(e)}})},Yi=e=>{switch(e){case`MPEG`:case`DASH`:case`DASH_SEP`:case`DASH_ONDEMAND`:case`DASH_WEBM`:case`DASH_WEBM_AV1`:case`DASH_STREAMS`:case`HLS`:case`HLS_FMP4`:case`HLS_ONDEMAND`:return!1;case`DASH_LIVE`:case`DASH_LIVE_CMAF`:case`HLS_LIVE`:case`HLS_LIVE_CMAF`:case`DASH_LIVE_WEBM`:case`WEB_RTC_LIVE`:return!0;default:return mi(e)}},Xi=e=>Ji(Object.keys(e).filter(e=>!Yi(e))).length>0;class Zi{constructor(e){i(this,`subscription`,new Qr),i(this,`log`,void 0),i(this,`params`,void 0),i(this,`sessionId$`,new $r(null)),i(this,`mediaSessionId$`,new $r(null)),i(this,`contentId$`,new $r(null)),i(this,`progressTicker`,void 0),i(this,`isMobile`,Ci()),i(this,`mobileVolumeState`,{muted:!1,volume:0}),i(this,`media`,null),i(this,`lastRequestedVolume`,null),i(this,`syncMediaState`,e=>{if(Xr(e))return;this.media=e,this.mediaSessionId$.next(e.mediaSessionId??null);let t=e.media?.contentId;t&&this.contentId$.next(t),this.syncPlaybackState(e);let n=e.media?.duration;Yr(n)&&this.params.output.duration$.next(Math.max(0,n));let r=e.currentTime;if(Yr(r)){this.params.desiredState.seekState.getState().state===`applying`&&this.params.output.seekedEvent$.next(),this.params.output.position$.next(r);let t=this.params.output.isLive$.getValue();e.playerState===`PLAYING`&&!t?this.progressTicker.start(r):this.progressTicker.pause()}}),this.params=e,this.progressTicker=new pi(e),this.log=this.params.dependencies.logger.createComponentLog(`ChromecastPresentationApiProvider`),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(Yi(e.format)),this.subscribe()}subscribe(){let e=e=>{this.params.output.error$.next({category:Kr.WTF,id:`ChromecastPresentationApiProvider`,message:e?.message??`Unknown error`,thrown:e})};this.subscription.add(this.params.chromecastConnector.message$.pipe(qr(e=>!!e)).subscribe(e=>{this.handleMessage(e)},e)),this.subscription.add(this.sessionId$.pipe(qr(Yr),Jr(),Gr(0)).subscribe(()=>{this.loadMedia()},e));let t=this.contentId$.pipe(Jr(),Zr(Boolean));this.subscription.add(Wr({seekState:this.params.desiredState.seekState.stateChangeEnded$,mediaLoaded:t}).pipe(qr(({mediaLoaded:e})=>e)).subscribe(()=>{let e=this.params.desiredState.seekState.getState();e.state===`requested`&&this.seek(e.position/1e3)},e));let n=Wr({playbackState:this.params.desiredState.playbackState.stateChangeStarted$,mediaLoaded:t});this.subscription.add(n.pipe(qr(({mediaLoaded:e})=>e),Gr(0)).subscribe(()=>{this.syncPlayback()},e)),this.subscription.add(n.pipe(qr(({mediaLoaded:e,playbackState:{from:t,to:n}})=>!e&&t===`stopped`&&n===`playing`)).subscribe(()=>{this.loadMedia()},e)),this.subscription.add(Wr({volumeState:this.params.desiredState.volume.stateChangeStarted$.pipe(Gr(30)),mediaLoaded:t}).pipe(qr(({mediaLoaded:e})=>e)).subscribe(({volumeState:e})=>{let{muted:t,volume:n}=e.to;this.setVolume(n,t)},e))}handleMessage(e){switch(e.type){case`new_session`:case`update_session`:{var t;this.sessionId$.next(e.message.sessionId);let n=(t=e.message)==null||(t=t.media)==null?void 0:t[0];this.syncMediaState(n);let r=e.message?.receiver.volume;this.syncVolumeState(r)}break;case`v2_message`:switch(e.message?.type){case`MEDIA_STATUS`:{var n;let t=(n=e.message)==null||(n=n.status)==null?void 0:n[0];this.syncMediaState(t);break}}break}}loadMedia(){let e=ci(this.params),t=this.media?.currentTime,n=this.params.desiredState.seekState.getState(),r=t??(n.state===`none`?0:n.position/1e3),i=this.params.desiredState.playbackState.getState()===`playing`;this.params.chromecastConnector.sendV2Message({type:`LOAD`,requestId:0,media:e,autoplay:i,currentTime:r,customData:null,activeTrackIds:null}),this.params.output.willSeekEvent$.next()}stop(){this.params.chromecastConnector.stopMedia()}play(){let e=this.mediaSessionId$.getValue();Ur(e,`play on null mediaSessionId`),this.params.chromecastConnector.sendV2Message({type:`PLAY`,mediaSessionId:e,customData:null})}pause(){let e=this.mediaSessionId$.getValue();Ur(e,`pause on null mediaSessionId`),this.params.chromecastConnector.sendV2Message({type:`PAUSE`,mediaSessionId:e,customData:null})}seek(e){let t=this.mediaSessionId$.getValue();Ur(t,`seek on null mediaSessionId`),this.params.chromecastConnector.sendV2Message({type:`SEEK`,currentTime:e,mediaSessionId:t}),this.params.output.willSeekEvent$.next()}setVolume(e,t){let n=e,r=`[setVolume] volume: ${e}, muted: ${t}`;this.isMobile&&(n=this.mobileVolumeState.volume,r+=`, mobile next volume: ${n}`),this.log({message:r}),this.lastRequestedVolume={volume:n,muted:t},this.params.chromecastConnector.sendV2Message({type:`SET_VOLUME`,requestId:0,volume:{level:t?0:n,muted:t?!0:null}})}syncPlaybackState({playerState:e,idleReason:t}){let n=this.params.output.isBuffering$.getValue(),r=e===`BUFFERING`;switch(n!==r&&this.params.output.isBuffering$.next(r),e){case`PAUSED`:P(this.params.desiredState.playbackState,`paused`);break;case`PLAYING`:P(this.params.desiredState.playbackState,`playing`);break;case`IDLE`:t===`FINISHED`?(this.params.output.endedEvent$.next(),P(this.params.desiredState.playbackState,`stopped`),this.contentId$.next(null)):P(this.params.desiredState.playbackState,`ready`);break;case`BUFFERING`:break}}syncPlayback(){let e=this.params.desiredState.playbackState.getState();switch(this.log({message:`[syncPlayback] ${e}`}),e){case`ready`:break;case`playing`:this.play();break;case`paused`:this.pause();break;case`stopped`:this.stop();break}}syncVolumeState(e){if(Xr(e))return;let{level:t,muted:n}=e,r={muted:n??!1,volume:t??0};this.lastRequestedVolume&&=(n&&(r.volume=this.lastRequestedVolume.volume),this.lastRequestedVolume.muted&&!t&&!n&&(r.volume=this.lastRequestedVolume.volume,r.muted=!0),null);let i=`[syncVolumeState] volume: ${r.volume}, muted: ${r.muted}`;this.isMobile&&(this.mobileVolumeState.volume=r.volume,this.mobileVolumeState.muted=r.muted,r.volume=this.params.output.volume$.getValue().volume,i+=`, volume passed to state machine: ${r.volume}`),this.log({message:i}),this.params.output.volume$.next(r)}destroy(){this.progressTicker.destroy(),this.subscription.unsubscribe()}}import{assertNonNullable as Qi,ErrorCategory as $i,filter as ea,Subject as ta,Subscription as na,tap as ra,ValueSubject as ia,fromEvent as aa,getWindow as oa}from"@vkontakte/videoplayer-shared/es2015";var sa=e=>({castDevice:{friendlyName:e},remotePlayer:{},remotePlayerController:{},session:{}}),ca=()=>String(Date.now())+String(Math.floor(Math.random()*1e5));class la{constructor(e){i(this,`params`,void 0),i(this,`clientId`,void 0),i(this,`capabilities`,[`WEB`]),i(this,`presentationRequest$`,new ia(null)),i(this,`log`,void 0),i(this,`sessionId$`,new ia(null)),i(this,`broadcastChannel`,new BroadcastChannel(`vk_player_chromecast_events`)),i(this,`subscription`,new na),i(this,`subscriptionEvents`,new na),i(this,`isDestroyed`,!1),i(this,`sequenceNumber`,0),i(this,`presentationAvailable$`,new ia(!1)),i(this,`presentationConnection$`,new ia(null)),i(this,`message$`,new ia(null)),i(this,`friendlyName$`,new ia(null)),i(this,`errorEvent$`,new ta),this.clientId=this.getClientId(),this.params=e,this.log=e.logger.createComponentLog(`ChromecastPresentationApiConnector`),this.log({message:`constructor`}),this.safeReinitPresentation(),this.subscribe()}destroy(){this.log({message:`destroy`}),this.subscription.unsubscribe(),this.subscriptionEvents.unsubscribe(),this.broadcastChannel.close(),this.isDestroyed=!0}disconnect(e=!0){this.log({message:`disconnect`}),e&&this.stopMedia(),this.presentationRequest$.next(null);let t=this.presentationConnection$.getValue();t&&t.close(),this.presentationConnection$.next(null),this.friendlyName$.next(null),this.resetSequenceNumber(),this.resetSubscriptionEvents()}stopMedia(){this.log({message:`stopMedia`}),this.sendV2Message({type:`STOP`})}reinitPresentation(e=!0){let t=this.createCastUrl(),n=new PresentationRequest(t);this.presentationRequest$.next(n),this.log({message:`PresentationRequest created`}),n.getAvailability().then(e=>{let t=()=>{this.log({message:`PresentationRequest presentation availability: ${e.value}`}),this.presentationAvailable$.next(e.value)};this.subscriptionEvents.add(aa(e,`change`).subscribe(()=>{t()})),t()}).catch(()=>{this.presentationAvailable$.next(!0)}),oa().navigator.presentation.defaultRequest=n,e&&n.reconnect(`auto-join`).then(e=>{this.log({message:`PresentationRequest reconnect success`}),this.handleConnection(e)}).catch(()=>{this.log({message:`PresentationRequest reconnect failed`})})}safeReinitPresentation(e){try{this.reinitPresentation(e)}catch(e){this.errorEvent$.next({category:$i.WTF,id:`ChromecastPresentationApiConnector`,message:e?.message??`reinitPresentation error`,thrown:e})}}connect(){var e=this;return a(function*(){e.log({message:`connect`});try{e.presentationRequest$.getValue()||(e.log({message:`reinitPresentation`}),e.reinitPresentation(!1));let t=e.presentationRequest$.getValue();Qi(t,`connect with null presentationRequest`);let n=yield t.start();e.handleConnection(n)}catch(t){switch(t?.name){case`AbortError`:case`NotAllowedError`:break;default:e.errorEvent$.next({category:$i.WTF,id:`ChromecastPresentationApiConnector`,message:t?.message??`connect error`,thrown:t});break}}})()}subscribe(){this.subscription.add(aa(this.broadcastChannel,`message`).subscribe(e=>{this.log({message:`broadcast connection data: ${e.data}`}),e.data===`connection`&&this.disconnect(!1)})),this.subscription.add(this.presentationAvailable$.subscribe(e=>{this.log({message:`presentationAvailable$: ${e}`})})),this.subscription.add(this.presentationConnection$.pipe(ra(e=>{this.log({message:`presentationConnection$: ${!!e}`})}),ea(e=>!!e)).subscribe(e=>{let t=aa(e,`message`).subscribe(e=>{let t=JSON.parse(e.data);t.clientId===this.clientId&&(this.log({message:`[onmessage] ${e.data}`}),this.handleMessage(t),this.message$.next(t))}),n=aa(e,`connect`).subscribe(()=>{this.send(`client_connect`)}),r=aa(e,`close`).subscribe(e=>{switch(e.reason){case`error`:this.errorEvent$.next({category:$i.WTF,id:`ChromecastPresentationApiConnector`,message:`Session error`,thrown:e});break;case`closed`:break}});this.subscriptionEvents.add(t),this.subscriptionEvents.add(n),this.subscriptionEvents.add(r)}))}send(e){switch(e){case`client_connect`:{let e={type:`client_connect`,message:this.clientId,sequenceNumber:-1,timeoutMillis:0,clientId:this.clientId};this.safeSend(JSON.stringify(e));break}}}sendV2Message(e){let t=this.sessionId$.getValue();if(t){let n={type:`v2_message`,sequenceNumber:this.getSequenceNumber(),timeoutMillis:0,clientId:this.clientId,message:o(o({},e),{},{sessionId:t})};this.safeSend(JSON.stringify(n))}}safeSend(e){try{this.log({message:`[send] ${e}`});let t=this.presentationConnection$.getValue();t?.state===`connected`&&t?.send(e)}catch(t){this.errorEvent$.next({category:$i.WTF,id:`ChromecastPresentationApiConnector`,message:`PresentationConnection send error`,data:{message:e},thrown:t})}}handleMessage(e){switch(e.type){case`new_session`:case`update_session`:this.sessionId$.next(e.message.sessionId),this.friendlyName$.next(e.message.receiver.friendlyName||`Chromecast Device`);break;case`receiver_action`:e.message?.action===`stop`&&this.disconnect();break}}createCastUrl(){return`cast:${this.params.appId}?clientId=${this.clientId}&autoJoinPolicy=tab_and_origin_scoped&defaultActionPolicy=create_session&launchTimeout=60000&supportedAppTypes=${this.capabilities}&appParams=%7B%22launchCheckerParams%22%3A%7B%7D%7D`}getSequenceNumber(){let e=this.sequenceNumber;return this.sequenceNumber=(this.sequenceNumber+1)%(2**53-1),e}resetSequenceNumber(){this.sequenceNumber=0}getClientId(){let e=`__vk_player_chromecast_id`;return oa()[e]=oa()[e]||ca()}resetSubscriptionEvents(){this.subscriptionEvents.unsubscribe(),this.subscriptionEvents=new na}handleConnection(e){this.log({message:`connection available`}),this.isDestroyed?(this.log({message:`connected on already destroyed component`}),e.close()):(this.broadcastChannel.postMessage(`connection`),this.presentationConnection$.next(e))}}import{ValueSubject as ua,Subject as da,map as fa,Subscription as pa,combine as ma,filterChanged as ha,assertNonNullable as ga}from"@vkontakte/videoplayer-shared/es2015";class _a{static isSupported(){return`chrome`in window&&`presentation`in navigator&&`BroadcastChannel`in window}constructor(e){i(this,`subscription`,new pa),i(this,`log`,void 0),i(this,`contentId`,void 0),i(this,`connection$`,new ua(void 0)),i(this,`castState$`,new ua(`NOT_AVAILABLE`)),i(this,`errorEvent$`,new da),i(this,`chromecastConnector`,void 0);let t=_a.isSupported();this.log=e.dependencies.logger.createComponentLog(`ChromecastPresentationApiInitializer`),this.log({message:`[constructor] receiverApplicationId: ${e.receiverApplicationId}, isDisabled: ${e.isDisabled}, isSupported: ${t}`}),!(!t||e.isDisabled||!e.receiverApplicationId)&&(this.chromecastConnector=new la({appId:e.receiverApplicationId,logger:e.dependencies.logger}),this.subscribe())}subscribe(){ga(this.chromecastConnector,`subscribe with null chromecastConnector`),this.subscription.add(this.chromecastConnector.errorEvent$.subscribe(this.errorEvent$));let e=ma({connection:this.chromecastConnector.presentationConnection$,available:this.chromecastConnector.presentationAvailable$,friendlyName:this.chromecastConnector.friendlyName$.pipe(ha())});this.subscription.add(e.pipe(fa(({connection:e,friendlyName:t})=>!!(e&&t)),ha()).subscribe(e=>{let t=this.chromecastConnector?.friendlyName$.getValue()??``;this.connection$.next(e?sa(t):void 0)})).add(e.subscribe(({available:e,connection:t})=>{e?t?this.castState$.next(`CONNECTED`):this.castState$.next(`AVAILABLE`):this.castState$.next(`NOT_AVAILABLE`)}))}connect(){this.log({message:`connect`}),this.chromecastConnector?.connect()}disconnect(){this.log({message:`disconnect`}),this.chromecastConnector?.disconnect()}stopMedia(){var e=this;return a(function*(){e.log({message:`stopMedia`}),e.chromecastConnector?.stopMedia()})()}toggleConnection(){let e=!!this.chromecastConnector?.presentationConnection$.getValue();this.log({message:`toggleConnection: isConnected - ${e}`}),e?this.disconnect():this.connect()}setVolume(e){}setMuted(e){}destroy(){this.log({message:`destroy`}),this.chromecastConnector?.destroy(),this.subscription.unsubscribe()}}var va=v(it(),1),ya=(e,...t)=>typeof e==`string`?e.includes(...t):va.default(e,...t),ba=v(ct(),1),xa=v(Vt(),1),Sa=v(Tn(),1);import{isNonNullable as Ca,Subject as wa,merge as Ta}from"@vkontakte/videoplayer-shared/es2015";class I{constructor(e){i(this,`state`,void 0),i(this,`prevState`,void 0),i(this,`transition`,void 0),i(this,`transitionStarted$`,new wa),i(this,`transitionEnded$`,new wa),i(this,`transitionUpdated$`,new wa),i(this,`forceChanged$`,new wa),i(this,`stateChangeStarted$`,Ta(this.transitionStarted$,this.transitionUpdated$)),i(this,`stateChangeEnded$`,Ta(this.transitionEnded$,this.forceChanged$)),this.state=e,this.prevState=void 0}setState(e){let t=this.transition,n=this.state;this.transition=void 0,this.prevState=n,this.state=e,t?t.to===e?this.transitionEnded$.next(t):this.forceChanged$.next({from:t.from,to:e,canceledTransition:t}):this.forceChanged$.next({from:n,to:e,canceledTransition:t})}startTransitionTo(e){let t=this.transition,n=this.state;n===e||Ca(t)&&t.to===e||(this.prevState=n,this.state=e,t?(this.transition={from:t.from,to:e,canceledTransition:t},this.transitionUpdated$.next(this.transition)):(this.transition={from:n,to:e},this.transitionStarted$.next(this.transition)))}getTransition(){return this.transition}getState(){return this.state}getPrevState(){return this.prevState}}import{assertNever as Ea,debounce as Da,ErrorCategory as Oa,fromEvent as ka,map as Aa,merge as ja,observableFrom as Ma,Subject as Na,Subscription as Pa,timeout as Fa}from"@vkontakte/videoplayer-shared/es2015";var Ia=5,La=5,Ra=500,za=7e3;class Ba{constructor(e){i(this,`subscription`,new Pa),i(this,`loadMediaTimeoutSubscription`,new Pa),i(this,`videoState`,new I(`stopped`)),i(this,`params`,void 0),i(this,`log`,void 0),i(this,`syncPlayback`,()=>{let e=this.videoState.getState(),t=this.videoState.getTransition(),n=this.params.desiredState.playbackState.getState(),r=this.params.desiredState.playbackState.getTransition(),i=this.params.desiredState.seekState.getState();if(this.log({message:`[syncPlayback] videoState: ${e}; videoTransition: ${JSON.stringify(t)}; desiredPlaybackState: ${n}; desiredPlaybackStateTransition: ${this.params.desiredState.playbackState.getTransition()}; seekState: ${JSON.stringify(i)};`}),n===`stopped`){e!==`stopped`&&(this.videoState.startTransitionTo(`stopped`),this.stop());return}if(!t){if(r?.to!==`paused`&&i.state===`requested`&&e!==`stopped`){this.seek(i.position/1e3);return}switch(n){case`ready`:switch(e){case`playing`:case`paused`:case`ready`:break;case`stopped`:this.videoState.startTransitionTo(`ready`),this.prepare();break;default:Ea(e)}break;case`playing`:switch(e){case`playing`:break;case`paused`:this.videoState.startTransitionTo(`playing`),this.params.connection.remotePlayerController.playOrPause();break;case`ready`:this.videoState.startTransitionTo(`playing`),this.params.connection.remotePlayerController.playOrPause();break;case`stopped`:this.videoState.startTransitionTo(`ready`),this.prepare();break;default:Ea(e)}break;case`paused`:switch(e){case`playing`:this.videoState.startTransitionTo(`paused`),this.params.connection.remotePlayerController.playOrPause();break;case`paused`:break;case`ready`:this.videoState.startTransitionTo(`paused`),this.videoState.setState(`paused`);break;case`stopped`:this.videoState.startTransitionTo(`ready`),this.prepare();break;default:Ea(e)}break;default:Ea(n)}}}),this.params=e,this.log=this.params.dependencies.logger.createComponentLog(`ChromecastProvider`),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(Yi(e.format)),this.params.output.isAudioAvailable$.next(!0),this.handleRemoteVolumeChange({volume:this.params.connection.remotePlayer.volumeLevel,muted:this.params.connection.remotePlayer.isMuted});let t=this.params.connection.session.getMediaSession();t&&this.restoreSession(t),this.subscribe()}destroy(){this.log({message:`[destroy]`}),this.subscription.unsubscribe()}subscribe(){this.subscription.add(this.loadMediaTimeoutSubscription);let e=new Pa;this.subscription.add(e),this.subscription.add(ja(this.videoState.stateChangeStarted$.pipe(Aa(e=>`stateChangeStarted$ ${JSON.stringify(e)}`)),this.videoState.stateChangeEnded$.pipe(Aa(e=>`stateChangeEnded$ ${JSON.stringify(e)}`))).subscribe(e=>this.log({message:`[videoState] ${e}`})));let t=(e,t)=>this.subscription.add(e.subscribe(t));if(this.params.output.isLive$.getValue())this.params.output.position$.next(0),this.params.output.duration$.next(0);else{let t=new Na;e.add(t.pipe(Da(Ra)).subscribe(()=>{this.params.output.seekedEvent$.next()}));let n=NaN;e.add(ka(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED).subscribe(e=>{this.logRemoteEvent(e);let r=e.value;this.params.output.position$.next(r),(this.params.desiredState.seekState.getState().state===`applying`||Math.abs(r-n)>Ia)&&t.next(r),n=r})),e.add(ka(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.DURATION_CHANGED).subscribe(e=>{this.logRemoteEvent(e),this.params.output.duration$.next(e.value)}))}t(ka(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED),t=>{this.logRemoteEvent(t),t.value?this.handleRemoteReady():(this.handleRemoteStop(),e.unsubscribe())}),t(ka(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),e=>{this.logRemoteEvent(e),e.value?this.handleRemotePause():this.handleRemotePlay()}),t(ka(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED),e=>{this.logRemoteEvent(e);let{remotePlayer:t}=this.params.connection,n=e.value,r=this.params.output.isBuffering$.getValue(),i=n===chrome.cast.media.PlayerState.BUFFERING;switch(r!==i&&this.params.output.isBuffering$.next(i),n){case chrome.cast.media.PlayerState.IDLE:!this.params.output.isLive$.getValue()&&t.duration-t.currentTime<La&&this.params.output.endedEvent$.next(),this.handleRemoteStop(),P(this.params.desiredState.playbackState,`stopped`);break;case chrome.cast.media.PlayerState.PAUSED:this.handleRemotePause();break;case chrome.cast.media.PlayerState.PLAYING:this.handleRemotePlay();break;case chrome.cast.media.PlayerState.BUFFERING:break;default:Ea(n)}}),t(ka(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED),e=>{this.logRemoteEvent(e),this.handleRemoteVolumeChange({volume:e.value})}),t(ka(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),e=>{this.logRemoteEvent(e),this.handleRemoteVolumeChange({muted:e.value})}),t(ja(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,Ma([`init`])).pipe(Da(0)),this.syncPlayback)}restoreSession(e){this.log({message:`restoreSession`});let{remotePlayer:t}=this.params.connection;if(e.playerState!==chrome.cast.media.PlayerState.IDLE){t.isPaused?(this.videoState.setState(`paused`),P(this.params.desiredState.playbackState,`paused`)):(this.videoState.setState(`playing`),P(this.params.desiredState.playbackState,`playing`));let e=this.params.output.isLive$.getValue();this.params.output.duration$.next(e?0:t.duration),this.params.output.position$.next(e?0:t.currentTime),this.params.desiredState.seekState.setState({state:`none`})}}prepare(){let e=this.params.format;this.log({message:`[prepare] format: ${e}`});let t=ci(this.params),n=this.createLoadRequest(t);this.loadMedia(n)}handleRemotePause(){let e=this.videoState.getState();(this.videoState.getTransition()?.to===`paused`||e===`playing`)&&(this.videoState.setState(`paused`),P(this.params.desiredState.playbackState,`paused`))}handleRemotePlay(){let e=this.videoState.getState();(this.videoState.getTransition()?.to===`playing`||e===`paused`)&&(this.videoState.setState(`playing`),P(this.params.desiredState.playbackState,`playing`))}handleRemoteReady(){this.videoState.getTransition()?.to===`ready`&&this.videoState.setState(`ready`),this.params.desiredState.playbackState.getTransition()?.to===`ready`&&P(this.params.desiredState.playbackState,`ready`)}handleRemoteStop(){this.videoState.getState()!==`stopped`&&this.videoState.setState(`stopped`)}handleRemoteVolumeChange(e){let t=this.params.output.volume$.getValue(),n={volume:e.volume??t.volume,muted:e.muted??t.muted};(n.volume!==t.volume||n.muted!==n.muted)&&this.params.output.volume$.next(n)}seek(e){this.params.output.willSeekEvent$.next();let{remotePlayer:t,remotePlayerController:n}=this.params.connection;t.currentTime=e,n.seek()}stop(){let{remotePlayerController:e}=this.params.connection;e.stop()}createLoadRequest(e){let t=new chrome.cast.media.LoadRequest(e);t.autoplay=!1;let n=this.params.desiredState.seekState.getState();return n.state===`applying`||n.state===`requested`?t.currentTime=this.params.output.isLive$.getValue()?0:n.position/1e3:t.currentTime=0,t}loadMedia(e){let t=this.params.connection.session.loadMedia(e),n=new Promise((e,t)=>{this.loadMediaTimeoutSubscription.add(Fa(za).subscribe(()=>t(`timeout(${za})`)))});Sa.default(Promise.race([t,n]).then(()=>{this.log({message:`[loadMedia] completed, format: ${this.params.format}`}),this.params.desiredState.seekState.getState().state===`applying`&&this.params.output.seekedEvent$.next(),this.handleRemoteReady()},e=>{let t=`[prepare] loadMedia failed, format: ${this.params.format}, reason: ${e}`;this.log({message:t}),this.params.output.error$.next({id:`ChromecastProvider.loadMedia`,category:Oa.VIDEO_PIPELINE,message:t,thrown:e})}),()=>{this.loadMediaTimeoutSubscription.unsubscribe()})}logRemoteEvent(e){this.log({message:`[remoteEvent] ${JSON.stringify(e)}`})}}var Va=v(it(),1);import{clearVideoElement as Ha,getWindow as Ua}from"@vkontakte/videoplayer-shared/es2015";import{clearVideoElement as Wa}from"@vkontakte/videoplayer-shared/es2015";var Ga=(e,t)=>{try{e.pause(),e.playbackRate=0,Wa(e,t),e.remove()}catch(e){console.error(e)}};import{fromEvent as Ka,Subscription as qa}from"@vkontakte/videoplayer-shared/es2015";var Ja=`__spvc`;class Ya{constructor(){i(this,`attribute`,`data-pool-reused`)}get(e){return e.hasAttribute(this.attribute)}set(e,t){e.toggleAttribute(this.attribute,t)}delete(e){e.removeAttribute(this.attribute)}}var Xa=Ua(),Za=Xa.WeakMap?new Xa.WeakMap:new Ya,Qa=Xa.WeakMap?new Xa.WeakMap:new Map,$a=(e,t=20)=>{let n=0;return Ka(e,`ratechange`).subscribe(r=>{n++,n>=t&&(e.currentTime=e.currentTime,n=0)})};function eo(e){e.style.position=`fixed`,e.style.left=`100%`,e.setAttribute(`data-role`,`screen`),Ua().document.body.appendChild(e)}function to(e,t){e.style.position=``,e.style.left=``,t.appendChild(e)}var no=(e,{audioVideoSyncRate:t,disableYandexPiP:n,clearVideoElementInnerHTML:r,reuseOwnVideoElement:i})=>{let a,o=e.querySelector(`video`),s=!!o,c=Ua().document.querySelector(`body > video[data-role=screen]`)||void 0;i?Xa[Ja]=c:(c?.remove(),delete Xa[Ja]),o?(a=o,Ha(a,r)):c&&c===Xa[Ja]?(a=c,to(a,e)):(a=Ua().document.createElement(`video`),e.appendChild(a),i&&(Xa[Ja]=a)),Za.set(a,s);let l=new qa;return l.add($a(a,t)),Qa.set(a,l),a.setAttribute(`crossorigin`,`anonymous`),a.setAttribute(`playsinline`,`playsinline`),n&&a.setAttribute(`x-yandex-pip`,`false`),a.controls=!1,a.setAttribute(`poster`,`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=`),a},ro=(e,{keepVideoElement:t,clearVideoElementInnerHTML:n,reuseOwnVideoElement:r})=>{Qa.get(e)?.unsubscribe(),Qa.delete(e);let i=Za.get(e);Za.delete(e),i||t?Ha(e,n):r?(Ha(e,n),eo(e)):Ga(e,n)},io=v(Qe(),1);import{assertNonNullable as ao,isNonNullable as oo,isNullable as so,fromEvent as co,merge as lo,observableFrom as uo,filterChanged as fo,map as po,Subject as mo,Subscription as ho,ValueSubject as go,ErrorCategory as _o}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as vo,isNullable as yo,Subscription as bo}from"@vkontakte/videoplayer-shared/es2015";var xo=(e,t,n,{equal:r=(e,t)=>e===t,changed$:i,onError:a}={})=>{let o=e.getState(),s=t(),c=yo(i),l=new bo;return i&&l.add(i.subscribe(t=>{r(t,e.getState())&&e.setState(t)},a)),r(s,o)||(n(o),c&&e.setState(o)),l.add(e.stateChangeStarted$.subscribe(t=>{n(t.to),c&&e.setState(t.to)},a)),l},So=(e,t,n)=>xo(t,()=>e.loop,t=>{vo(t)&&(e.loop=t)},{onError:n}),Co=(e,t,n,r,i)=>xo(t,()=>({muted:e.muted,volume:e.volume}),t=>{i?.skipVideoElVolumeSync$.getValue()||vo(t)&&(e.muted=t.muted,e.volume=t.volume)},{equal:(e,t)=>e===t||e?.muted===t?.muted&&e?.volume===t?.volume,changed$:n,onError:r}),wo=(e,t,n,r)=>xo(t,()=>e.playbackRate,t=>{vo(t)&&(e.playbackRate=t)},{changed$:n,onError:r}),To=xo,Eo=e=>[`__`,e.language,e.label].join(`|`),Do=(e,t)=>{if(e.id===t)return!0;let[n,r,i]=t.split(`|`);return e.language===r&&e.label===i};class Oo{constructor(e){i(this,`available$`,new mo),i(this,`current$`,new go(void 0)),i(this,`error$`,new mo),i(this,`video`,void 0),i(this,`cueSettings`,void 0),i(this,`subscription`,new ho),i(this,`externalTracks`,new Map),i(this,`internalTracks`,new Map),i(this,`baseURL`,void 0),this.baseURL=e}connect(e,t,n){this.video=e,this.cueSettings=t.textTrackCuesSettings,this.subscribe();let r=e=>{this.error$.next({id:`TextTracksManager`,category:_o.WTF,message:`Generic HtmlVideoTextTrackManager error`,thrown:e})};this.subscription.add(this.available$.subscribe(n.availableTextTracks$)),this.subscription.add(this.current$.subscribe(n.currentTextTrack$)),this.subscription.add(this.error$.subscribe(n.error$)),this.subscription.add(To(t.internalTextTracks,()=>io.default(this.internalTracks),e=>{oo(e)&&this.setInternal(e)},{equal:(e,t)=>oo(e)&&oo(t)&&e.length===t.length&&e.every(({id:e},n)=>e===t[n].id),changed$:this.available$.pipe(po(e=>e.filter(({type:e})=>e===`internal`))),onError:r})),this.subscription.add(To(t.externalTextTracks,()=>io.default(this.externalTracks),e=>{oo(e)&&this.setExternal(e)},{equal:(e,t)=>oo(e)&&oo(t)&&e.length===t.length&&e.every(({id:e},n)=>e===t[n].id),changed$:this.available$.pipe(po(e=>e.filter(({type:e})=>e===`external`))),onError:r})),this.subscription.add(To(t.currentTextTrack,()=>{if(this.video)return;let e=this.htmlTextTracksAsArray().find(({mode:e})=>e===`showing`);return e&&this.htmlTextTrackToITextTrack(e).id},e=>this.select(e),{changed$:this.current$,onError:r})),this.subscription.add(To(t.textTrackCuesSettings,()=>({}),()=>{if(this.video)for(let e of this.htmlTextTracksAsArray())this.applyCueSettings(e.cues),this.applyCueSettings(e.activeCues)}))}subscribe(){ao(this.video);let{textTracks:e}=this.video;this.subscription.add(co(e,`addtrack`).subscribe(()=>{let e=this.current$.getValue();e&&this.select(e)})),this.subscription.add(lo(co(e,`addtrack`),co(e,`removetrack`),uo([`init`])).pipe(po(()=>this.htmlTextTracksAsArray().map(e=>this.htmlTextTrackToITextTrack(e))),fo((e,t)=>e.length===t.length&&e.every(({id:e},n)=>e===t[n].id))).subscribe(this.available$)),this.subscription.add(lo(co(e,`change`),uo([`init`])).pipe(po(()=>this.htmlTextTracksAsArray().find(({mode:e})=>e===`showing`)),po(e=>e&&this.htmlTextTrackToITextTrack(e).id),fo()).subscribe(this.current$));let t=e=>this.applyCueSettings(e.target?.activeCues??null);this.subscription.add(co(e,`addtrack`).subscribe(e=>{e.track?.addEventListener(`cuechange`,t);let n=e=>{let t=e.target?.cues??null;t&&t.length&&(this.applyCueSettings(e.target?.cues??null),e.target?.removeEventListener(`cuechange`,n))};e.track?.addEventListener(`cuechange`,n)})),this.subscription.add(co(e,`removetrack`).subscribe(e=>{e.track?.removeEventListener(`cuechange`,t)}))}applyCueSettings(e){if(!e||!e.length)return;let t=this.cueSettings.getState();for(let n of Array.from(e)){let e=n;oo(t.align)&&(e.align=t.align),oo(t.position)&&(e.position=t.position),oo(t.size)&&(e.size=t.size),oo(t.line)&&(e.line=t.line)}}htmlTextTracksAsArray(e=!1){ao(this.video);let t=[...this.video.textTracks];return e?t:t.filter(Oo.isHealthyTrack)}htmlTextTrackToITextTrack(e){let{language:t,label:n}=e,r=e.id?e.id:Eo(e),i=this.externalTracks.has(r),a=(i?this.externalTracks.get(r)?.isAuto:this.internalTracks.get(r)?.isAuto)??r.includes(`auto`);return i?{id:r,type:`external`,isAuto:a,language:t,label:n,url:this.externalTracks.get(r)?.url}:{id:r,type:`internal`,isAuto:a,language:t,label:n,url:this.internalTracks.get(r)?.url}}static isHealthyTrack(e){return!(e.kind===`metadata`||e.groupId||e.id===``&&e.label===``&&e.language===``)}setExternal(e){this.internalTracks.size>0&&Array.from(this.internalTracks).forEach(([,e])=>this.detach(e)),e.filter(({id:e})=>!this.externalTracks.has(e)).forEach(e=>this.attach(e)),Array.from(this.externalTracks).filter(([t])=>!e.find(e=>e.id===t)).forEach(([,e])=>this.detach(e))}setInternal(e){let t=[...this.externalTracks];e.filter(({id:e,language:n,isAuto:r})=>!this.internalTracks.has(e)&&!t.some(([,e])=>e.language===n&&e.isAuto===r)).forEach(e=>this.attach(e)),Array.from(this.internalTracks).filter(([t])=>!e.find(e=>e.id===t)).forEach(([,e])=>this.detach(e))}select(e){ao(this.video);for(let e of this.htmlTextTracksAsArray(!0))e.mode=`showing`;for(let t of this.htmlTextTracksAsArray(!0))(so(e)||!Do(t,e))&&(t.mode=`disabled`)}destroy(){if(this.subscription.unsubscribe(),this.video)for(let e of Array.from(this.video.getElementsByTagName(`track`))){let t=e.getAttribute(`id`);t&&this.externalTracks.has(t)&&this.video.removeChild(e)}this.externalTracks.clear()}attach(e){ao(this.video);let t=document.createElement(`track`);this.baseURL?t.setAttribute(`src`,new URL(e.url,this.baseURL).toString()):t.setAttribute(`src`,e.url),t.setAttribute(`id`,e.id),e.label&&t.setAttribute(`label`,e.label),e.language&&t.setAttribute(`srclang`,e.language),e.type===`external`?this.externalTracks.set(e.id,e):e.type===`internal`&&this.internalTracks.set(e.id,e),this.video.appendChild(t)}detach(e){ao(this.video);let t=Array.prototype.find.call(this.video.getElementsByTagName(`track`),t=>t.getAttribute(`id`)===e.id);t&&this.video.removeChild(t),e.type===`external`?this.externalTracks.delete(e.id):e.type===`internal`&&this.internalTracks.delete(e.id)}}var ko=Oo;class Ao{constructor(){i(this,`pausedTime`,0),i(this,`streamOffset`,0),i(this,`pauseTimestamp`,0)}getTotalPausedTime(){return this.pausedTime+this.getCurrentPausedTime()}getCurrentPausedTime(){return this.pauseTimestamp>0?Date.now()-this.pauseTimestamp:0}getStreamOffset(){return this.streamOffset}getTotalOffset(){return this.getTotalPausedTime()+this.streamOffset}pause(){this.pauseTimestamp===0&&(this.pauseTimestamp=Date.now())}resume(){this.pauseTimestamp>0&&(this.pausedTime+=this.getCurrentPausedTime(),this.pauseTimestamp=0)}resetTo(e,t=!1){this.streamOffset=e,this.pauseTimestamp=0,this.pausedTime=0,t&&this.pause()}}var jo=e=>{let t=e;for(;!(t instanceof Document)&&!(t instanceof ShadowRoot)&&t!==null;)t=t?.parentNode;return t??void 0},Mo=e=>{let t=jo(e);return!!(t&&t.fullscreenElement&&t.fullscreenElement===e)},No=e=>{let t=jo(e);return!!(t&&t.pictureInPictureElement&&t.pictureInPictureElement===e)};import{fromEvent as Po,map as Fo,merge as Io,filterChanged as Lo,isNonNullable as Ro,Subject as zo,filter as Bo,mapTo as Vo,combine as Ho,once as Uo,shareReplay as Wo,throttle as Go,ErrorCategory as Ko,ValueSubject as qo,Subscription as Jo}from"@vkontakte/videoplayer-shared/es2015";var Yo=3,Xo=(e,t,n=Yo)=>{let r=0,i=0;for(let a=0;a<e.length;a++){let o=e.start(a),s=e.end(a);if(o<=t&&t<=s){if(r=o,i=s,!n)return{from:r,to:i};for(let t=a-1;t>=0;t--)e.end(t)+n>=r&&(r=e.start(t));for(let t=a+1;t<e.length;t++)e.start(t)-n<=i&&(i=e.end(t))}}return{from:r,to:i}},Zo=e=>{let t=t=>Po(e,t).pipe(Vo(void 0),Wo(1)),n=new Jo,r=()=>n.unsubscribe(),i=Io(Po(e,`progress`),Po(e,`timeupdate`)).pipe(Fo(()=>Xo(e.buffered,e.currentTime)),Wo(1)),a=F.browser.isSafari?Ho({play:t(`play`).pipe(Uo()),playing:t(`playing`)}).pipe(Vo(void 0),Wo(1)):t(`playing`),o=Po(e,`volumechange`).pipe(Fo(()=>({muted:e.muted,volume:e.volume})),Wo(1)),s=Po(e,`ratechange`).pipe(Fo(()=>e.playbackRate),Wo(1)),c=Po(e,`error`).pipe(Bo(()=>!!(e.error||e.played.length)),Fo(()=>{let t=e.error;return{id:t?`MediaError#${t.code}`:`HtmlVideoError`,category:Ko.VIDEO_PIPELINE,message:t?t.message:`Error event from HTML video element`,thrown:e.error??void 0}}),Wo(1)),l=Po(e,`timeupdate`).pipe(Fo(()=>e.currentTime),Wo(1)),u=[`waiting`,`seeking`,`seeked`,`timeupdate`],d=new zo,f=.3,p;n.add(Io(...u.map(t=>Po(e,t))).subscribe(t=>{let n=e.currentTime;e.loop&&Ro(p)&&Ro(n)&&p>=e.duration-f&&n<=f&&d.next(p),p=n}));let m=t(`pause`).pipe(Bo(()=>!e.error&&p!==e.duration),Wo(1)),h=Po(e,`enterpictureinpicture`).pipe(Wo(1)),g=Po(e,`leavepictureinpicture`).pipe(Wo(1)),_=new qo(No(e));n.add(h.subscribe(()=>_.next(!0))),n.add(g.subscribe(()=>_.next(!1)));let v=new qo(Mo(e)),y=Po(e,`fullscreenchange`).pipe(Wo(1));n.add(y.pipe(Fo(()=>Mo(e))).subscribe(v));let b=Po(e,`timeupdate`).pipe(Fo(t=>e.duration-e.currentTime<.1),Lo(),Wo(1)),x=Io(b.pipe(Bo(t=>!e.loop&&t)),Po(e,`ended`)).pipe(Go(1e3),Vo(void 0),Wo(1)),S=Io(...[`waiting`,`pause`,`canplay`,`play`,`canplaythrough`,`playing`,`seeking`,`seeked`,`ended`].map(t=>Po(e,t)),b.pipe(Fo(e=>({type:e?`ended`:`unknown`})))).pipe(Fo(t=>F.browser.isFirefox&&t.type===`ended`?e.readyState<2:e.readyState<3),Lo(),Wo(1));return{playing$:a,pause$:m,canplay$:t(`canplay`),ended$:x,looped$:d,error$:c,seeked$:t(`seeked`),seeking$:t(`seeking`),progress$:t(`progress`),loadStart$:t(`loadstart`),loadedMetadata$:t(`loadedmetadata`),loadedData$:t(`loadeddata`),timeUpdate$:l,durationChange$:Po(e,`durationchange`).pipe(Fo(()=>e.duration),Wo(1)),isBuffering$:S,currentBuffer$:i,volumeState$:o,playbackRateState$:s,inPiP$:_,inFullscreen$:v,enterPip$:h,leavePip$:g,destroy:r}};import{VideoQuality as Qo}from"@vkontakte/videoplayer-shared/es2015";var $o=e=>{switch(e){case`mobile`:return Qo.Q_144P;case`lowest`:return Qo.Q_240P;case`low`:return Qo.Q_360P;case`sd`:case`medium`:return Qo.Q_480P;case`hd`:case`high`:return Qo.Q_720P;case`fullhd`:case`full`:return Qo.Q_1080P;case`quadhd`:case`quad`:return Qo.Q_1440P;case`ultrahd`:case`ultra`:return Qo.Q_2160P}},es=v(kn(),1),ts=v(it(),1),ns=v(ct(),1);import{isNonNullable as L,isNullable as rs,now as is,isHigher as as,isHigherOrEqual as os,isInvariantQuality as ss,isLowerOrEqual as cs,videoSizeToQuality as ls,assertNotEmptyArray as us,assertNonNullable as ds}from"@vkontakte/videoplayer-shared/es2015";var fs=!1,ps={},ms=e=>{fs=e},hs=()=>{ps={}},gs=e=>{e(ps)},_s=(e,t)=>{fs&&(ps.meta=ps.meta??{},ps.meta[e]=t)};class vs{constructor(e){i(this,`name`,void 0),this.name=e}next(e){if(!fs)return;ps.series=ps.series??{};let t=ps.series[this.name]??[];t.push([Date.now(),e]),ps.series[this.name]=t}}import{isHigher as ys,isLower as bs,isNonNullable as xs,isNullable as Ss,videoHeightToQuality as Cs}from"@vkontakte/videoplayer-shared/es2015";function ws(e,t,n){return!e.max&&e.min===t?`high_quality`:!e.min&&e.max===n?`traffic_saving`:`unknown`}function Ts(e,t,n){return Ss(e)||xs(e.min)&&xs(e.max)&&bs(e.max,e.min)||xs(e.min)&&xs(t)&&ys(e.min,t)||xs(e.max)&&xs(n)&&bs(e.max,n)}function Es({limits:e,highestAvailableHeight:t,lowestAvailableHeight:n}){return Ts({max:e?.max?Cs(e.max):void 0,min:e?.min?Cs(e.min):void 0},t?Cs(t):void 0,n?Cs(n):void 0)}var Ds=new vs(`best_bitrate`),Os=(e,t,n)=>(t-n)*2**(-10*e)+n,ks=e=>(t,n)=>e*(Number(t.bitrate)-Number(n.bitrate));class As{constructor(){i(this,`last`,void 0),i(this,`history`,{})}recordSelection(e){this.history[e.id]=is()}recordSwitch(e){this.last=e}clear(){this.last=void 0,this.history={}}}var js=`Assertion "ABR Tracks is empty array" failed`,Ms=new WeakMap,Ns=new WeakMap,Ps=new WeakMap,Fs=(e,t,n,r)=>{let i=[...t].sort(ks(1)),a=[...n].sort(ks(1)),o=a.filter(t=>L(t.bitrate)&&L(e.bitrate)?e.bitrate/t.bitrate>r:!0),s=es.default(a,Math.round(a.length*i.indexOf(e)/(i.length+1)))??es.default(a,-1);return s&&ts.default(o,s)?s:o.length?es.default(o,-1):es.default(a,0)},Is=(e,t,n,r)=>{let i=Ms.get(t);i||(i=[...t].sort(ks(1)),Ms.set(t,i));let a=Ms.get(n);a||(a=[...n].sort(ks(1)),Ms.set(n,a));let o=Ps.get(e);o||(o=a.filter(t=>L(t.bitrate)&&L(e.bitrate)?e.bitrate/t.bitrate>r:!0),Ps.set(e,o));let s=es.default(a,Math.round(a.length*i.indexOf(e)/(i.length+1)))??es.default(a,-1);return s&&ts.default(o,s)?s:o.length?es.default(o,-1):es.default(a,0)},Ls=e=>`quality`in e,Rs=(e,t,n,r)=>{var i;let a=L(r==null||(i=r.last)==null?void 0:i.bitrate)&&L(n?.bitrate)&&r.last.bitrate<n.bitrate?e.trackCooldownIncreaseQuality:e.trackCooldownDecreaseQuality,o=n&&r&&r.history[n.id]&&is()-r.history[n.id]<=a&&(!r.last||n.id!==r.last.id);if(n?.id&&r&&!o&&r.recordSelection(n),o&&r?.last){let e=r.last;return r?.recordSwitch(e),t({message:`
|
|
7
|
+
\v\f\r \xA0 \u2028\u2029`}),Kn=y((e,t)=>{var n=w(),r=j(),i=An(),a=Gn(),o=n(``.replace),s=RegExp(`^[`+a+`]+`),c=RegExp(`(^|[^`+a+`])[`+a+`]+$`),l=function(e){return function(t){var n=i(r(t));return e&1&&(n=o(n,s,``)),e&2&&(n=o(n,c,`$1`)),n}};t.exports={start:l(1),end:l(2),trim:l(3)}}),qn=y((e,t)=>{var n=ft().PROPER,r=x(),i=Gn(),a=`
`;t.exports=function(e){return r(function(){return!!i[e]()||a[e]()!==a||n&&i[e].name!==e})}}),Jn=y((e,t)=>{var n=Kn().start;t.exports=qn()(`trimStart`)?function(){return n(this)}:``.trimStart}),Yn=y(()=>{var e=N(),t=Jn();e({target:`String`,proto:!0,name:`trimStart`,forced:``.trimLeft!==t},{trimLeft:t})}),Xn=y(()=>{Yn();var e=N(),t=Jn();e({target:`String`,proto:!0,name:`trimStart`,forced:``.trimStart!==t},{trimStart:t})}),Zn=y((e,t)=>{Xn(),t.exports=tt()(`String`,`trimLeft`)}),Qn=y((e,t)=>{t.exports=Zn()}),$n=y((e,t)=>{t.exports=Qn()}),er=y((e,t)=>{var n=ie(),r=T(),i=M()(`match`);t.exports=function(e){var t;return n(e)&&((t=e[i])===void 0?r(e)===`RegExp`:!!t)}}),tr=y((e,t)=>{var n=b(),r=x(),i=n.RegExp;t.exports={correct:!r(function(){var e=!0;try{i(`.`,`d`)}catch{e=!1}var t={},n=``,r=e?`dgimsy`:`gimsy`,a=function(e,r){Object.defineProperty(t,e,{get:function(){return n+=r,!0}})},o={dotAll:`s`,global:`g`,ignoreCase:`i`,multiline:`m`,sticky:`y`};for(var s in e&&(o.hasIndices=`d`),o)a(s,o[s]);return Object.getOwnPropertyDescriptor(i.prototype,`flags`).get.call(t)!==r||n!==r})}}),nr=y((e,t)=>{var n=Me();t.exports=function(){var e=n(this),t=``;return e.hasIndices&&(t+=`d`),e.global&&(t+=`g`),e.ignoreCase&&(t+=`i`),e.multiline&&(t+=`m`),e.dotAll&&(t+=`s`),e.unicode&&(t+=`u`),e.unicodeSets&&(t+=`v`),e.sticky&&(t+=`y`),t}}),rr=y((e,t)=>{var n=k(),r=Se(),i=se(),a=tr(),o=nr(),s=RegExp.prototype;t.exports=a.correct?function(e){return e.flags}:function(e){return!a.correct&&i(s,e)&&!r(e,`flags`)?n(o,e):e.flags}}),ir=y((e,t)=>{var n=w(),r=xe(),i=Math.floor,a=n(``.charAt),o=n(``.replace),s=n(``.slice),c=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,l=/\$([$&'`]|\d{1,2})/g;t.exports=function(e,t,n,u,d,f){var p=n+e.length,m=u.length,h=l;return d!==void 0&&(d=r(d),h=c),o(f,h,function(r,o){var c;switch(a(o,0)){case`$`:return`$`;case`&`:return e;case"`":return s(t,0,n);case`'`:return s(t,p);case`<`:c=d[s(o,1,-1)];break;default:var l=+o;if(l===0)return r;if(l>m){var f=i(l/10);return f===0?r:f<=m?u[f-1]===void 0?a(o,1):u[f-1]+a(o,1):r}c=u[l-1]}return c===void 0?``:c})}}),ar=y(()=>{var e=N(),t=k(),n=w(),r=j(),i=D(),a=ie(),o=er(),s=An(),c=he(),l=rr(),u=ir(),d=M(),f=_e(),p=d(`replace`),m=TypeError,h=n(``.indexOf),g=n(``.replace),_=n(``.slice),v=Math.max;e({target:`String`,proto:!0},{replaceAll:function(e,n){var d=r(this),y,b,x,S,C,w,T,E,D,O,k=0,A=``;if(a(e)){if(y=o(e),y&&(b=s(r(l(e))),!~h(b,`g`)))throw new m("`.replaceAll` does not allow non-global regexes");if(x=c(e,p),x)return t(x,e,d,n);if(f&&y)return g(s(d),e,n)}for(S=s(d),C=s(e),w=i(n),w||(n=s(n)),T=C.length,E=v(1,T),D=h(S,C);D!==-1;)O=w?s(n(C,D,S)):u(C,S,D,[],void 0,n),A+=_(S,k,D)+O,k=D+T,D=D+E>S.length?-1:h(S,C,D+E);return k<S.length&&(A+=_(S,k)),A}})}),or=y((e,t)=>{ar(),t.exports=tt()(`String`,`replaceAll`)}),sr=y((e,t)=>{t.exports=or()}),cr=y((e,t)=>{t.exports=sr()}),lr=y((e,t)=>{var n=ze(),r=An(),i=j(),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}}),ur=y((e,t)=>{var n=w(),r=Ve(),i=An(),a=lr(),o=j(),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)}}),dr=y((e,t)=>{var n=ce();t.exports=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(n)}),fr=y(()=>{var e=N(),t=ur().start;e({target:`String`,proto:!0,forced:dr()},{padStart:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})}),pr=y((e,t)=>{fr(),t.exports=tt()(`String`,`padStart`)}),mr=y((e,t)=>{t.exports=pr()}),hr=y((e,t)=>{t.exports=mr()}),gr=`2.0.157-beta.0`,_r;(e=>{e.STOPPED=`stopped`,e.READY=`ready`,e.PLAYING=`playing`,e.PAUSED=`paused`})(_r||={});var vr;(e=>{e.MPEG=`MPEG`,e.DASH=`DASH`,e.DASH_SEP=`DASH_SEP`,e.DASH_SEP_VK=`DASH_SEP`,e.DASH_WEBM=`DASH_WEBM`,e.DASH_WEBM_AV1=`DASH_WEBM_AV1`,e.DASH_STREAMS=`DASH_STREAMS`,e.DASH_WEBM_VK=`DASH_WEBM`,e.DASH_ONDEMAND=`DASH_ONDEMAND`,e.DASH_ONDEMAND_VK=`DASH_ONDEMAND`,e.DASH_LIVE=`DASH_LIVE`,e.DASH_LIVE_CMAF=`DASH_LIVE_CMAF`,e.DASH_LIVE_WEBM=`DASH_LIVE_WEBM`,e.HLS=`HLS`,e.HLS_ONDEMAND=`HLS_ONDEMAND`,e.HLS_JS=`HLS`,e.HLS_FMP4=`HLS_FMP4`,e.HLS_LIVE=`HLS_LIVE`,e.HLS_LIVE_CMAF=`HLS_LIVE_CMAF`,e.WEB_RTC_LIVE=`WEB_RTC_LIVE`})(vr||={});var yr;(e=>{e.AV1=`av1`,e.VP9=`vp9`,e.AVC1=`avc1`,e.HEV1=`hev1`})(yr||={});var br;(e=>{e.NOT_AVAILABLE=`NOT_AVAILABLE`,e.AVAILABLE=`AVAILABLE`,e.CONNECTING=`CONNECTING`,e.CONNECTED=`CONNECTED`})(br||={});var xr;(e=>{e.HTTP1=`http1`,e.HTTP2=`http2`,e.QUIC=`quic`})(xr||={});var Sr;(e=>{e.NONE=`none`,e.INLINE=`inline`,e.FULLSCREEN=`fullscreen`,e.SECOND_SCREEN=`second_screen`,e.PIP=`pip`,e.INVISIBLE=`invisible`})(Sr||={});var Cr;(e=>{e.TRAFFIC_SAVING=`traffic_saving`,e.HIGH_QUALITY=`high_quality`,e.UNKNOWN=`unknown`})(Cr||={});var wr=v(Qe(),1),Tr=v(it(),1);import{assertNever as Er,assertNonNullable as Dr,isNonNullable as Or,ValueSubject as kr,Subject as Ar,Subscription as jr,merge as Mr,observableFrom as Nr,fromEvent as Pr,map as Fr,tap as Ir,filterChanged as Lr,isNullable as Rr,ErrorCategory as zr}from"@vkontakte/videoplayer-shared/es2015";var Br=e=>new Promise((t,n)=>{let r=document.createElement(`script`);r.setAttribute(`src`,e),r.onload=()=>t(),r.onerror=e=>n(e),document.body.appendChild(r)});class Vr{constructor(e){i(this,`connection$`,new kr(void 0)),i(this,`castState$`,new kr(`NOT_AVAILABLE`)),i(this,`errorEvent$`,new Ar),i(this,`contentId`,void 0),i(this,`realCastState$`,new kr(`NOT_AVAILABLE`)),i(this,`subscription`,new jr),i(this,`log`,void 0),i(this,`params`,void 0),i(this,`isDestroyed`,!1),this.params=e,this.log=this.params.dependencies.logger.createComponentLog(`ChromecastInitializer`);let t=`chrome`in window;if(this.log({message:`[constructor] receiverApplicationId: ${this.params.receiverApplicationId}, isDisabled: ${this.params.isDisabled}, isSupported: ${t}`}),e.isDisabled||!t)return;let n=Or(window.chrome?.cast),r=!!window.__onGCastApiAvailable;n?this.initializeCastApi():(window.__onGCastApiAvailable=e=>{delete window.__onGCastApiAvailable,e&&!this.isDestroyed&&this.initializeCastApi()},r||Br(`https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1`).catch(()=>this.errorEvent$.next({id:`ChromecastLoading`,category:zr.NETWORK,message:`Script loading failed!`})))}connect(){cast.framework.CastContext.getInstance()?.requestSession()}disconnect(){var e;(e=cast.framework.CastContext.getInstance())==null||(e=e.getCurrentSession())==null||e.endSession(!0)}stopMedia(){return new Promise((e,t)=>{var n;(n=cast.framework.CastContext.getInstance())==null||(n=n.getCurrentSession())==null||(n=n.getMediaSession())==null||n.stop(new chrome.cast.media.StopRequest,e,t)})}toggleConnection(){Or(this.connection$.getValue())?this.disconnect():this.connect()}setVolume(e){let t=this.connection$.getValue();Rr(t)||(t.remotePlayer.volumeLevel=e,t.remotePlayerController.setVolumeLevel())}setMuted(e){let t=this.connection$.getValue();Rr(t)||e!==t.remotePlayer.isMuted&&t.remotePlayerController.muteOrUnmute()}destroy(){this.isDestroyed=!0,this.subscription.unsubscribe()}initListeners(){let e=new cast.framework.RemotePlayer,t=new cast.framework.RemotePlayerController(e),n=cast.framework.CastContext.getInstance();this.subscription.add(Pr(n,cast.framework.CastContextEventType.SESSION_STATE_CHANGED).subscribe(e=>{switch(e.sessionState){case cast.framework.SessionState.SESSION_STARTED:case cast.framework.SessionState.SESSION_STARTING:case cast.framework.SessionState.SESSION_RESUMED:var t;this.contentId=(t=n.getCurrentSession())==null||(t=t.getMediaSession())==null||(t=t.media)==null?void 0:t.contentId;break;case cast.framework.SessionState.NO_SESSION:case cast.framework.SessionState.SESSION_ENDING:case cast.framework.SessionState.SESSION_ENDED:case cast.framework.SessionState.SESSION_START_FAILED:this.contentId=void 0;break;default:return Er(e.sessionState)}})).add(Mr(Pr(n,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe(Ir(e=>{this.log({message:`[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: ${JSON.stringify(e)}`})}),Fr(e=>e.castState)),Nr([n.getCastState()])).pipe(Lr(),Fr(Hr),Ir(e=>{this.log({message:`realCastState$: ${e}`})})).subscribe(this.realCastState$)).add(this.realCastState$.subscribe(r=>{let i=r===`CONNECTED`,a=Or(this.connection$.getValue());if(i&&!a){var o;let r=n.getCurrentSession();Dr(r);let i=r.getCastDevice(),a=(o=r.getMediaSession())==null||(o=o.media)==null?void 0:o.contentId;(Rr(a)||a===this.contentId)&&(this.log({message:`connection created`}),this.connection$.next({remotePlayer:e,remotePlayerController:t,session:r,castDevice:i}))}else !i&&a&&(this.log({message:`connection destroyed`}),this.connection$.next(void 0));this.castState$.next(r===`CONNECTED`?Or(this.connection$.getValue())?`CONNECTED`:`AVAILABLE`:r)}))}initializeCastApi(){let e,t,n;try{e=cast.framework.CastContext.getInstance(),t=chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,n=chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}catch{return}try{e.setOptions({receiverApplicationId:this.params.receiverApplicationId??t,autoJoinPolicy:n}),this.initListeners()}catch(e){this.errorEvent$.next({id:`ChromecastInitializer`,category:zr.EXTERNAL_API,message:`[initializeCastApi] failed`,thrown:e})}}}var Hr=e=>{switch(e){case cast.framework.CastState.NO_DEVICES_AVAILABLE:return`NOT_AVAILABLE`;case cast.framework.CastState.NOT_CONNECTED:return`AVAILABLE`;case cast.framework.CastState.CONNECTING:return`CONNECTING`;case cast.framework.CastState.CONNECTED:return`CONNECTED`;default:return Er(e)}};import{assertNonNullable as Ur,combine as Wr,debounce as Gr,ErrorCategory as Kr,filter as qr,filterChanged as Jr,isNonNullable as Yr,isNullable as Xr,map as Zr,Subscription as Qr,ValueSubject as $r}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as ei,assertNonNullable as ti,ErrorCategory as ni,getHighestQuality as ri,isNonNullable as ii}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as ai}from"@vkontakte/videoplayer-shared/es2015";var oi=(e,t=0,n=0)=>{switch(n){case 0:return e.replace(`_offset_p`,t===0?``:`_`+t.toFixed(0));case 1:{if(t===0)return e;let n=new URL(e);return n.searchParams.append(`playback_shift`,t.toFixed(0)),n.toString()}case 2:{let n=new URL(e);return!n.searchParams.get(`offset_p`)&&t===0?e:(n.searchParams.set(`offset_p`,t.toFixed(0)),n.toString())}default:ai(n)}return e},si=(e,t)=>{switch(t){case 0:return NaN;case 1:{let t=new URL(e);return Number(t.searchParams.get(`playback_shift`))}case 2:{let t=new URL(e);return Number(t.searchParams.get(`offset_p`)??0)}default:ai(t)}},ci=e=>{let{source:t,format:n,meta:r,output:i}=e,a,o,s;switch(n){case`MPEG`:{let e=t[n];ti(e);let r=ri(Object.keys(e));ti(r);let i=e[r];ti(i),a=i,o=`video/mp4`,s=li();break}case`HLS`:case`HLS_FMP4`:case`HLS_ONDEMAND`:{let e=t[n];ti(e),a=e.url,o=`application/x-mpegurl`,s=li();break}case`DASH_SEP`:case`DASH_ONDEMAND`:case`DASH_WEBM`:case`DASH_WEBM_AV1`:case`DASH_STREAMS`:{let e=t[n];ti(e),a=e.url,o=`application/dash+xml`,s=li();break}case`DASH_LIVE_CMAF`:{let e=t[n];ti(e),a=e.url,o=`application/dash+xml`,s=ui();break}case`HLS_LIVE`:case`HLS_LIVE_CMAF`:{let e=t[n];ti(e),a=oi(e.url),o=`application/x-mpegurl`,s=ui();break}case`DASH_LIVE`:case`WEB_RTC_LIVE`:{let e=`Unsupported format for Chromecast`,t=Error(e);throw i.error$.next({id:`ChromecastProvider.createMediaInfo()`,category:ni.VIDEO_PIPELINE,message:e,thrown:t}),t}case`DASH`:case`DASH_LIVE_WEBM`:throw Error(`${n} is no longer supported`);default:return ei(n)}let c=di(r.videoId??a,o);c.contentUrl=a,c.streamType=s,c.metadata=fi();let{title:l,subtitle:u}=r;return ii(l)&&(c.metadata.title=l),ii(u)&&(c.metadata.subtitle=u),c};function li(){var e;return((e=chrome.cast)==null||(e=e.media)==null||(e=e.StreamType)==null?void 0:e.BUFFERED)??`BUFFERED`}function ui(){var e;return((e=chrome.cast)==null||(e=e.media)==null||(e=e.StreamType)==null?void 0:e.LIVE)??`LIVE`}function di(e,t){var n;return!((n=chrome.cast)==null||(n=n.media)==null)&&n.MediaInfo?new chrome.cast.media.MediaInfo(e,t):{contentId:e,contentType:t,metadata:{title:``,subtitle:``},streamType:li()}}function fi(){var e;return!((e=chrome.cast)==null||(e=e.media)==null)&&e.GenericMediaMetadata?new chrome.cast.media.GenericMediaMetadata:{images:[],metadataType:0,releaseDate:``,subtitle:``,title:``,releaseYear:1970,type:0}}var P=(e,t,n=!1)=>{let r=e.getTransition();(n||!r||r.to===t)&&e.setState(t)};class pi{constructor(e){i(this,`params`,void 0),i(this,`interval`,0),i(this,`startVideoPosition`,void 0),i(this,`startTs`,void 0),this.params=e}start(e=0){clearInterval(this.interval),this.startVideoPosition=e,this.startTs=Date.now(),this.interval=window.setInterval(()=>{let e=(Date.now()-this.startTs)/1e3,t=this.startVideoPosition+e;this.params.output.position$.next(t)},1e3)}pause(){clearInterval(this.interval)}destroy(){clearInterval(this.interval)}}import{assertNever as mi}from"@vkontakte/videoplayer-shared/es2015";import{isBrowserWindow as hi,ValueSubject as gi}from"@vkontakte/videoplayer-shared/es2015";var _i=v(it(),1);import{getWindow as vi}from"@vkontakte/videoplayer-shared/es2015";class yi{constructor(){i(this,`_current`,void 0),i(this,`_current_version`,void 0),i(this,`_chromeVersion`,void 0),i(this,`_firefoxVersion`,void 0),i(this,`_safariVersion`,void 0),i(this,`_operaVersion`,void 0),i(this,`_edgeVersion`,void 0),i(this,`_yandexVersion`,void 0),i(this,`_isMiuiBrowser`,!1)}get current(){return this._current}get isChrome(){return this.current===`Chrome`}get isChromiumBased(){return _i.default([`Chrome`,`Chromium`,`Opera`,`Yandex`,`Edge`,`SamsungBrowser`],this.current)}get isFirefox(){return this.current===`Firefox`}get isSafari(){return this.current===`Safari`}get isOpera(){return this.current===`Opera`}get isEdge(){return this.current===`Edge`}get isYandex(){return this.current===`Yandex`}get isSamsungBrowser(){return this.current===`SamsungBrowser`}get currentVersion(){return this._current_version}get chromeVersion(){return this._chromeVersion}get firefoxVersion(){return this._firefoxVersion}get safariVersion(){return this._safariVersion}get operaVersion(){return this._operaVersion}get edgeVersion(){return this._edgeVersion}get yandexVersion(){return this._yandexVersion}get isMiuiBrowser(){return this._isMiuiBrowser}detect(){let{userAgent:e}=navigator;try{let t=/yabrowser/i.test(e)?`Yandex`:void 0,n=/samsungbrowser/i.test(e)?`SamsungBrowser`:void 0,r=/chrome|crios/i.test(e)?`Chrome`:void 0,i=/chromium/i.test(e)?`Chromium`:void 0,a=/firefox|fxios/i.test(e)?`Firefox`:void 0,o=/webkit|safari|khtml/i.test(e)?`Safari`:void 0,s=/opr\//i.test(e)?`Opera`:void 0,c=/edg/i.test(e)?`Edge`:void 0;this._isMiuiBrowser=/(XiaoMi)|(MiuiBrowser)/i.test(e),this._current=t||n||a||s||c||r||i||o||`Rest`}catch(e){console.error(e)}this.isChrome&&this.detectChromeVersion(),this.isFirefox&&this.detectFirefoxVersion(),this.isSafari&&this.detectSafariVersion(),this.isOpera&&this.detectOperaVersion(),this.isEdge&&this.detectEdgeVersion(),this.isYandex&&this.detectYandexVersion()}detectVersion(e){try{let{userAgent:t}=vi().navigator,n=t.match(e);if(!n)return;let r=n[1],i=parseInt(r,10);if(!isNaN(i))return this._current_version=i,i}catch(e){console.error(e)}}detectChromeVersion(){this._chromeVersion=this.detectVersion(/Chrome\/(\d+\.\d+)/)}detectFirefoxVersion(){this._firefoxVersion=this.detectVersion(/Firefox\/(\d+\.\d+)/)}detectSafariVersion(){this._safariVersion=this.detectVersion(/Version\/(\d+)/)}detectOperaVersion(){this._operaVersion=this.detectVersion(/OPR\/(\d+\.\d+)/)}detectEdgeVersion(){this._edgeVersion=this.detectVersion(/Edg\/(\d+\.\d+)/)}detectYandexVersion(){this._yandexVersion=this.detectVersion(/YaBrowser\/(\d+\.\d+\.\d+)/)}}var bi=v(it(),1);import{getWindow as xi,isBrowserWindow as Si}from"@vkontakte/videoplayer-shared/es2015";var Ci=()=>{var e;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(navigator.appVersion??navigator.userAgent)||((e=navigator)==null||(e=e.userAgentData)==null?void 0:e.mobile)};class wi{constructor(e){i(this,`_displayChecker`,void 0),i(this,`_isMobile`,void 0),i(this,`_current`,void 0),i(this,`_iosVersion`,void 0),i(this,`_highEntropyValues`,{}),i(this,`_os`,{name:`Unknown`,version:`Unknown`,full:`Unknown`}),i(this,`_details`,{vendor:`Unknown`,model:`Unknown`}),this._displayChecker=e}get current(){return this._current}get os(){return this._os}get details(){return this._details}get isIOS(){return this._highEntropyValues.platform===`iOS`||this.os.name.toLowerCase().includes(`ios`)||bi.default([`iPhone`,`iPad`,`iPod`],this.current)}get isMac(){return this._highEntropyValues.platform===`macOS`||this.os.name.toLowerCase().includes(`mac`)||this.current===`Mac`}get isApple(){return this.isIOS||this.isMac}get isIphoneOrOldIpad(){if(!this.isApple||!this._displayChecker.isTouch)return!1;let e=this.current===`iPad`||this._displayChecker.width>700,t=this._iosVersion;return!e||e&&!!t&&t<16}get isAndroid(){return this._highEntropyValues.platform===`Android`||this.os.name.toLowerCase().includes(`android`)||this.current===`Android`}get isWindows(){return this.os.name.toLowerCase().includes(`windows`)}get isLinux(){return this.os.name.toLowerCase().includes(`linux`)&&!this.isAndroid}get isMobile(){return this._highEntropyValues.mobile||this._isMobile}get iOSVersion(){return this._iosVersion}detect(){let e=xi();if(!Si(e))return;let{userAgent:t}=e.navigator;try{this._isMobile=Ci()}catch(e){console.error(`DeviceChecker: calling isMobile error - `,e)}this.detectDevice(t),this.detectOS(t),this.detectDeviceDetails(t),this.detectHighEntropyValues(),this.isIOS&&this.detectIOSVersion()}detectHighEntropyValues(){var e=this;return a(function*(){let t=xi();if(!Si(t))return;let{userAgentData:n}=t.navigator;if(n?.getHighEntropyValues){let t=yield n.getHighEntropyValues([`architecture`,`bitness`,`brands`,`mobile`,`platform`,`formFactor`,`model`,`platformVersion`,`wow64`]);e._highEntropyValues=t,t.platform&&(e._os.name=e.normalizeOSName(t.platform),t.platformVersion&&(e._os.version=e.normalizeOSVersion(t.platformVersion),e._os.full=`${e._os.name} ${e._os.version}`)),t.model&&(e._details.model=t.model)}})()}detectDevice(e){try{let t=/android/i.test(e)?`Android`:void 0,n=/iphone/i.test(e)?`iPhone`:void 0,r=/ipad/i.test(e)?`iPad`:void 0,i=/ipod/i.test(e)?`iPod`:void 0,a=/mac/i.test(e)?`Mac`:void 0,o=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(e)?`RestMobile`:void 0;this._current=t||n||r||i||o||a||`Desktop`}catch(e){console.error(`DeviceChecker: device detection error - `,e)}}detectOS(e){try{for(let[t,n]of[[/(windows nt) (6\.[23]); arm/i,[`Windows RT`]],[/(windows nt) (6\.3); arm/i,[`Windows RT 8.1`]],[/(windows (?:phone|mobile|iot))(?: os)?[/ ]?([\d.]+)/i,[`Windows Mobile`,2]],[/(windows)[/ ](xp|vista|7|8(\.1)?|10|11|2000|me)/i,[1,1]],[/windows nt ?([\d.]+)/i,[`Windows`,1]],[/(windows)[/ ](95|98|me|2000|xp|vista|7|8|8\.1|10|11)/i,[1,2]],[/(iphone os|cpu iphone os) ([\d_.]+)/i,[`iOS`,2]],[/(ipad os|cpu os) ([\d_.]+)/i,[`iPadOS`,2]],[/(ipod os|cpu ipod os) ([\d_.]+)/i,[`iOS`,2]],[/(?:ios|os) ([\d_.]+) like mac os x/i,[`iOS`,1]],[/cfnetwork\/.+darwin/i,[`iOS`]],[/(mac os x) ?([\d_.]+)/i,[`macOS`,2]],[/(macintosh|mac os)/i,[`macOS`]],[/(android) ([\d.]+)/i,[1,2]],[/(harmonyos)[/ ]?([\d.]*)/i,[`HarmonyOS`,2]],[/\b(ubuntu|debian|fedora|centos|arch|linux)(?:[-/ ]([\w.]+))?/i,[1,2]],[/(cros)\D*([\d.]+)/i,[`Chrome OS`,2]],[/(freebsd|openbsd|netbsd|dragonfly)[/ ]?([\w.]*)/i,[1,2]],[/(sunos|solaris)?([\d.]*)/i,[`Solaris`,2]],[/(aix)?([\d.]*)/i,[`AIX`,2]]]){let r=e.match(t);if(r){let t=n.length>0,i=n.length>1,a=`Unknown`,o=`Unknown`;if(t){let e=n[0];typeof e==`number`?e<r.length&&r[e]!==void 0&&(a=r[e]):a=e}if(i){let e=n[1];typeof e==`number`?e<r.length&&r[e]!==void 0&&(o=r[e]):e!==void 0&&(o=e)}else r[2]===void 0?r[1]!==void 0&&t&&typeof n[0]==`string`&&(o=r[1]):o=r[2];a=this.normalizeOSName(a),o=this.normalizeOSVersion(o,a),a===`iOS`&&/ipad/i.test(e)?a=`iPadOS`:a===`iPadOS`&&/ip(hone|od)/i.test(e)&&(a=`iOS`),this._os={name:a,version:o||`Unknown`,full:o&&o!==`Unknown`?`${a} ${o}`:a};break}}}catch(e){console.error(`DeviceChecker: OS detection error - `,e)}}normalizeOSName(e){if(!e)return`Unknown`;let t=e.toLowerCase();return t.includes(`windows`)?`Windows`:t.includes(`mac os`)||t.includes(`macintosh`)?`macOS`:t.includes(`iphone`)||t.includes(`ios`)?`iOS`:t.includes(`ipados`)?`iPadOS`:t.includes(`android`)?`Android`:t.includes(`harmonyos`)?`HarmonyOS`:t.includes(`linux`)?`Linux`:t.includes(`cros`)?`Chrome OS`:t.includes(`freebsd`)?`FreeBSD`:t.includes(`openbsd`)?`OpenBSD`:t.includes(`solaris`)||t.includes(`sunos`)?`Solaris`:t.includes(`aix`)?`AIX`:e}normalizeOSVersion(e,t){if(!e)return`Unknown`;if(e!==`Unknown`&&(e=e.replace(/_/g,`.`),t===`Windows`)){let t=parseFloat(e);if(!isNaN(t)){if(t>=11)return`11`;if(t>=10)return`10`;if(t===6.3)return`8.1`;if(t===6.2)return`8`;if(t===6.1)return`7`;if(t===6)return`Vista`;if(t===5.1||t===5.2)return`XP`;if(t===5)return`2000`;if(t===4)return`NT 4.0`}}return e}detectDeviceDetails(e){try{for(let[t,n]of[[/(iphone)/i,[`Apple`,`iPhone`]],[/(ipad)/i,[`Apple`,`iPad`]],[/(ipod)/i,[`Apple`,`iPod`]],[/(macintosh)/i,[`Apple`,`Macintosh`]],[/(windows[\w\-_ ]*phone)/i,[`Microsoft`,0]],[/(windows nt|win64|win32|wow64)/i,[`Microsoft`,`PC`]],[/\b(sch-i[89]0\d|shw-m380s|sm-[ptxs]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i,[`Samsung`,1]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?\d+a?|galaxy nexus)/i,[`Samsung`,1]],[/samsung[- ]((?!sm-[lr]|browser)[-\w]+)/i,[`Samsung`,1]],[/sec-(sgh\w+)/i,[`Samsung`,1]],[/smart-tv.+(samsung)/i,[`Samsung`,`Smart TV`]],[/(samsung).*tizen/i,[`Samsung`,`Smart TV`]],[/(pixel (?:c|tablet|[0-9a-z ]+))/i,[`Google`,1]],[/(pixelbook(?: go)?)/i,[`Google`,1]],[/nexus [0-9]/i,[`Google`,0]],[/(redmi[-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(mi[\w\-_ ]+)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(poco[\w ]+)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(hm[-_ ]?note?[\w ]*)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(?:xiao)?mi[\w\-_ ]+pad/i,[`Xiaomi`,0]],[/(?:huawei|honor) ?([-\w ]+)[;)]/i,[`Huawei`,1]],[/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][\dc][adnt]?)\b(?!.+d\/s)/i,[`Huawei`,1]],[/\b((?:ag[rs][2356]?k?|bah[234]?|bg[2o]|bt[kv]|cmr|cpn|db[ry]2?|jdn2|got|kob2?k?|mon|pce|scm|sht?|[tw]gr|vrd)-[ad]?[lw][0125][09]b?)/i,[`Huawei`,1]],[/(?:one)?(?:plus)? ?([a\d0]\d\d\d?)(?: b|\))/i,[`OnePlus`,1]],[/droid.+; (cph2[3-6]\d[13579]|((?:gm|hd)19|(?:ac|be|in|kb)20|(?:d[en]|eb|le|mt)21|ne22)[0-2]\d)(?: bui|\))/i,[`OnePlus`,1]],[/(oneplus)[-_ ]?([-\w]*)/i,[`OnePlus`,2]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i,[`Realme`,1]],[/(realme)[-_ ]?([-\w]*)/i,[`Realme`,2]],[/; (\w+) bui.+ oppo/i,[`OPPO`,1]],[/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i,[`OPPO`,1]],[/\b(opd2(\d{3}a?))(?: bui|\))/i,[`OPPO`,1]],[/(oppo)[-_ ]?([-\w]*)/i,[`OPPO`,2]],[/; vivo (\w+)(?: bui|\))/i,[`Vivo`,1]],[/\b(v[12]\d{3}\w?[at])(?: bui|;)/i,[`Vivo`,1]],[/(vivo)[-_ ]?([-\w]*)/i,[`Vivo`,2]],[/\bmot(?:orola)?[- ]([\w\s]+)(\)| bui)/i,[`Motorola`,1]],[/((?:moto(?! 360)[-\w() ]+|xt\d{3,4}[cgkosw+]?[-\d]*|nexus 6)(?= bui|\)))/i,[`Motorola`,1]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b/i,[`Motorola`,0]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i,[`Motorola`,0]],[/droid.+; ([a-z]?\d[0-2]{2}[a-z]{2}|[c-g]\d{4}|so[-gl]\w+|xq-[a-z]{2}\d\d)(?= bui|\))/i,[`Sony`,1]],[/sony tablet [ps]/i,[`Sony`,`Xperia Tablet`]],[/\b(?:sony)?sgp\w+(?: bui|\))/i,[`Sony`,0]],[/(sony)[-_ ]?([-\w]*)/i,[`Sony`,2]],[/\blg[-e;/ ]+(?!.*(?:browser|netcast|android tv|watch|webos))(\w+)/i,[`LG`,1]],[/\blg-?([\d\w]+) bui/i,[`LG`,1]],[/(lm(?:-?f100[nv]?|-[\w.]+)(?= bui|\))|nexus [45])/i,[`LG`,1]],[/((?=lg)?[vl]k-?\d{3}) bui/i,[`LG`,0]],[/(lg)[-_ ]?([-\w]*)/i,[`LG`,2]],[/(?:maemo|nokia).*(n900|lumia \d+|rm-\d+)/i,[`Nokia`,1]],[/nokia[-_ ]?(([-\w. ]*?))(?: bui|\)|;|\/)/i,[`Nokia`,1]],[/(nokia) (t[12][01])/i,[`Nokia`,2]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i,[`ASUS`,1]],[/(?:asus[-_ ])?(zenfone[\w\-_ ]*)/i,[`ASUS`,1]],[/(rog[\w\-_ ]*)/i,[`ASUS`,1]],[/(asus)[-_ ]?([-\w]*)/i,[`ASUS`,2]],[/lenovo[-_ ]?([-\w ]+?)(?: bui|\)|\/)/i,[`Lenovo`,1]],[/(ideatab[-\w ]+|602lv|d-42a|a101lv|a2109a|a3500-hv|s[56]000|pb-6505[my]|tb-?x?\d{3,4}(?:f[cu]|xu|[av])|yt\d?-[jx]?\d+[lfmx])(?: bui|;|\)|\/)/i,[`Lenovo`,1]],[/(thinkpad[\w\-_ ]*)/i,[`Lenovo`,0]],[/(kf[a-z]{2}[a-z]*)(?: bui|\))/i,[`Amazon`,1]],[/(alexa)webm/i,[`Amazon`,`Echo`]],[/(fire[\w\-_ ]*)/i,[`Amazon`,0]],[/(amazon)[-_ ]?([-\w]*)/i,[`Amazon`,2]],[/(?:blackberry|\(bb10;) (\w+)/i,[`BlackBerry`,1]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,[`BlackBerry`,1]],[/(playbook);[-\w),; ]+(rim)/i,[`BlackBerry`,1]],[/(microsoft); (lumia[\w ]+)/i,[`Microsoft`,2]],[/(surface duo)/i,[`Microsoft`,`Surface Duo`]],[/(surface[\w\-_ ]*)/i,[`Microsoft`,0]],[/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,[`ZTE`,2]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,[`HTC`,2]],[/(alcatel|tcl)[-_ ]?([-\w]*)/i,[1,2]],[/(meizu)[-_ ]?([-\w]*)/i,[`Meizu`,2]],[/(tecno)[-_ ]?([-\w]*)/i,[`Tecno`,2]],[/(infinix)[-_ ]?([-\w]*)/i,[`Infinix`,2]],[/(micromax)[-_ ]?([-\w]*)/i,[`Micromax`,2]],[/(lava)[-_ ]?([-\w]*)/i,[`Lava`,2]],[/(panasonic)[-_ ]?([-\w]*)/i,[`Panasonic`,2]],[/(sharp)\/?([-\w]*)/i,[`Sharp`,2]],[/(benq)[-_ ]?([-\w]*)/i,[`BenQ`,2]],[/(palm)[-_ ]?([-\w]*)/i,[`Palm`,2]],[/(vertu)[-_ ]?([-\w]*)/i,[`Vertu`,2]],[/(gionee)[-_ ]?([-\w]*)/i,[`Gionee`,2]],[/(doogee)[-_ ]?([-\w]*)/i,[`Doogee`,2]],[/(ulefone)[-_ ]?([-\w]*)/i,[`Ulefone`,2]],[/(blackview)[-_ ]?([-\w]*)/i,[`Blackview`,2]],[/(cubot)[-_ ]?([-\w]*)/i,[`Cubot`,2]],[/(umidigi)[-_ ]?([-\w]*)/i,[`UMIDIGI`,2]],[/(oukitel)[-_ ]?([-\w]*)/i,[`Oukitel`,2]],[/(fairphone)[-_ ]?([-\w]*)/i,[`Fairphone`,2]],[/(cat)[-_ ]?([-\w]*)/i,[`Cat`,2]],[/(energy)[-_ ]?([-\w]*)/i,[`Energizer`,2]],[/(land rover)[-_ ]?([-\w]*)/i,[`Land Rover`,2]],[/(shield[\w\-_ ]*)/i,[`Nvidia`,0]],[/(crkey)/i,[`Google`,`Chromecast`]],[/(roku)[\dx]*/i,[`Roku`,0]],[/(apple)[-_ ]?tv/i,[`Apple`,`TV`]],[/(amazon)[-_ ]?tv/i,[`Amazon`,`Fire TV`]],[/(google)[-_ ]?tv/i,[`Google`,`TV`]],[/(smart[\w\-_ ]*tv)/i,[0,`Smart TV`]],[/(playstation[\w\-_ ]*)/i,[`Sony`,0]],[/(nintendo[\w\-_ ]*)/i,[`Nintendo`,0]],[/(xbox[\w\-_ ]*)/i,[`Microsoft`,0]],[/(googlebot)/i,[`Google`,`Bot`]],[/(bingbot)/i,[`Microsoft`,`Bing Bot`]],[/(yandexbot)/i,[`Yandex`,`Bot`]],[/(slackbot)/i,[`Slack`,`Bot`]],[/(twitterbot)/i,[`Twitter`,`Bot`]],[/(facebookbot)/i,[`Facebook`,`Bot`]],[/(linkedinbot)/i,[`LinkedIn`,`Bot`]],[/(tesla)[-_ ]?([-\w]*)/i,[`Tesla`,2]],[/(raspberry[\w\-_ ]*)/i,[`Raspberry Pi`,0]]]){let r=e.match(t);if(r){let e=n[0],t=n[1],i=typeof e==`number`?r[e]===void 0?`Unknown`:this.normalizeVendorName(r[e]):this.normalizeVendorName(e),a=`Unknown`;typeof t==`number`?a=r[t]===void 0?`Unknown`:r[t]:t===void 0?r[1]===void 0?r[0]!==void 0&&(a=r[0]):a=r[1]:a=t,a=this.normalizeModelName(a,i),this.details.vendor=i,this.details.model=a;break}}}catch(e){console.error(`DeviceChecker: device details detection error - `,e)}}normalizeVendorName(e){return e?{apple:`Apple`,samsung:`Samsung`,google:`Google`,xiaomi:`Xiaomi`,huawei:`Huawei`,oneplus:`OnePlus`,oppo:`OPPO`,vivo:`Vivo`,realme:`Realme`,motorola:`Motorola`,sony:`Sony`,lg:`LG`,nokia:`Nokia`,asus:`ASUS`,lenovo:`Lenovo`,amazon:`Amazon`,blackberry:`BlackBerry`,microsoft:`Microsoft`,zte:`ZTE`,htc:`HTC`,alcatel:`Alcatel`,tcl:`TCL`,meizu:`Meizu`,tecno:`Tecno`,infinix:`Infinix`,micromax:`Micromax`,lava:`Lava`,panasonic:`Panasonic`,sharp:`Sharp`,benq:`BenQ`,palm:`Palm`,honor:`Honor`,nvidia:`NVIDIA`,roku:`Roku`}[e.toLowerCase()]||e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():`Unknown`}normalizeModelName(e,t){if(!e||e===`Unknown`)return e;if(e===`0`)return`Unknown`;let n=e.replace(/^build\//i,``).replace(/\s+bui$/i,``).replace(/\)$/,``).replace(/[;,)]/g,``).replace(/\s*\(.*?\)\s*/g,``).trim(),r=t.toLowerCase();return r.includes(`samsung`)?n=n.replace(/^(sm-|gt-|sgh-|sch-)/i,``):r.includes(`xiaomi`)?n=n.replace(/^(mi[\s\-_]*|redmi[\s\-_]*)/i,``):r.includes(`oneplus`)?n=n.replace(/^oneplus[\s\-_]*/i,``):r.includes(`google`)&&(n=n.replace(/^(pixel[\s\-_]*|nexus[\s\-_]*)/i,``)),n=n.replace(/_/g,` `).replace(/-/g,` `).replace(/\s+/g,` `).trim(),n?(n.length>0&&/^[a-z]/.test(n)&&(n=n.charAt(0).toUpperCase()+n.slice(1)),n):`Unknown`}detectIOSVersion(){try{let e=xi();if(!Si(e))return;if(this._highEntropyValues.platformVersion){let e=this._highEntropyValues.platformVersion.split(`.`).slice(0,2).join(`.`);this._iosVersion=parseFloat(e);return}if(this._os.version!==`Unknown`){let e=this._os.version.split(`.`),t=e.length>=2?`${e[0]}.${e[1]}`:e[0];this._iosVersion=parseFloat(t);return}let t=e.navigator.userAgent.match(/OS (\d+(_\d+)?)/i);t?.[1]&&(this._iosVersion=parseFloat(t[1].replace(/_/g,`.`)))}catch(e){console.error(`DeviceChecker: iOS version detection error - `,e)}}}import{getWindow as Ti,isBrowserWindow as Ei}from"@vkontakte/videoplayer-shared/es2015";class Di{constructor(){i(this,`_maxTouchPoints`,void 0),i(this,`_height`,void 0),i(this,`_width`,void 0),i(this,`_isHdr`,void 0),i(this,`_pixelRatio`,void 0),i(this,`_screenHeight`,void 0),i(this,`_screenWidth`,void 0),i(this,`_colorDepth`,void 0)}get isTouch(){return typeof this._maxTouchPoints==`number`?this._maxTouchPoints>1:`ontouchstart`in Ti()}get maxTouchPoints(){return this._maxTouchPoints}get height(){return this._height}get width(){return this._width}get screenHeight(){return this._screenHeight}get screenWidth(){return this._screenWidth}get pixelRatio(){return this._pixelRatio}get isHDR(){return this._isHdr}get colorDepth(){return this._colorDepth}detect(){let e=Ti();if(!Ei(e))return;let{navigator:t,screen:n}=e,{maxTouchPoints:r}=t;try{this._maxTouchPoints=r??0,this._isHdr=!!e.matchMedia(`(dynamic-range: high)`)?.matches,this._colorDepth=n.colorDepth}catch(e){console.error(e)}try{this._pixelRatio=e.devicePixelRatio||1,this._height=n.height,this._width=n.width,this._height=n.height,this._screenHeight=this._height*this._pixelRatio,this._screenWidth=this._width*this._pixelRatio}catch(e){console.error(e)}}}import{getWindow as Oi,isBrowserWindow as ki}from"@vkontakte/videoplayer-shared/es2015";var Ai=()=>window.ManagedMediaSource||window.MediaSource,ji=()=>{var e;return!!(window.ManagedMediaSource&&!((e=window.ManagedSourceBuffer)==null||(e=e.prototype)==null)&&e.appendBuffer)},Mi=()=>{var e;return!!(window.MediaSource&&!((e=window.SourceBuffer)==null||(e=e.prototype)==null)&&e.appendBuffer)},Ni=()=>window.ManagedMediaSource?new ManagedMediaSource:new MediaSource,Pi=Oi().document?.createElement(`video`),Fi=`video/mp4; codecs="avc1.42000a,mp4a.40.2"`,Ii=`video/mp4; codecs="hev1.1.6.L93.B0"`,Li=`video/webm; codecs="vp09.00.10.08"`,Ri=`video/webm; codecs="av01.0.00M.08"`,zi=`audio/mp4; codecs="mp4a.40.2"`,Bi=`audio/webm; codecs="opus"`,Vi;(function(){var e=a(function*(){let e=Oi();if(!ki(e)||!(`mediaCapabilities`in e.navigator))return;let t={type:`media-source`,video:{contentType:`video/webm`,width:1280,height:720,bitrate:1e6,framerate:30}},[n,r]=yield Promise.all([e.navigator.mediaCapabilities.decodingInfo(o(o({},t),{},{video:o(o({},t.video),{},{contentType:Ri})})),e.navigator.mediaCapabilities.decodingInfo(o(o({},t),{},{video:o(o({},t.video),{},{contentType:Li})}))]);Vi={DASH_WEBM_AV1:n,DASH_WEBM:r}});return function(){return e.apply(this,arguments)}})()().catch(e=>{console.log(Pi),console.error(e)});class Hi{constructor(e,t){i(this,`_video`,void 0),i(this,`_deviceChecker`,void 0),i(this,`_browserChecker`,void 0),i(this,`_protocols`,void 0),i(this,`_containers`,void 0),i(this,`_codecs`,void 0),i(this,`_nativeHlsSupported`,void 0),this._deviceChecker=e,this._browserChecker=t}get protocols(){return this._protocols}get containers(){return this._containers}get codecs(){return this._codecs}get webmDecodingInfo(){return Vi}get supportedCodecs(){return Object.keys(this._codecs).filter(e=>this._codecs[e])}get nativeHlsSupported(){return this._nativeHlsSupported}detect(){let e=Oi();if(ki(e)){this._video=e.document.createElement(`video`);try{var t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g;this._protocols={mms:ji(),mse:Mi(),hls:!!((t=this._video).canPlayType?.call(t,`application/x-mpegurl`)||(n=this._video).canPlayType?.call(n,`vnd.apple.mpegURL`)),webrtc:!!e.RTCPeerConnection,ws:!!e.WebSocket},this._containers={mp4:!!(r=this._video).canPlayType?.call(r,`video/mp4`),webm:!!(i=this._video).canPlayType?.call(i,`video/webm`),cmaf:!0};let _=!!(!((a=Ai())==null||(o=a.isTypeSupported)==null)&&o.call(a,Fi)),v=!!(!((s=Ai())==null||(c=s.isTypeSupported)==null)&&c.call(s,Ii)),y=!!(!((l=Ai())==null||(u=l.isTypeSupported)==null)&&u.call(l,zi));this._codecs={h264:_,h265:v,vp9:!!(!((d=Ai())==null||(f=d.isTypeSupported)==null)&&f.call(d,Li)),av1:!!(!((p=Ai())==null||(m=p.isTypeSupported)==null)&&m.call(p,Ri)),aac:y,opus:!!(!((h=Ai())==null||(g=h.isTypeSupported)==null)&&g.call(h,Bi)),mpeg:(_||v)&&y},this._nativeHlsSupported=this._protocols.hls&&this._containers.mp4}catch(e){console.error(e)}try{this.destroyVideoElement()}catch(e){console.error(`Error destroying video element:`,e)}}}destroyVideoElement(){if(!this._video)return;if(this._video.pause(),this._video.currentTime=0,this._video.removeAttribute(`src`),this._video.src=``,this._video.load(),this._video.remove){this._video.remove(),this._video=null;return}this._video.parentNode&&this._video.parentNode.removeChild(this._video);let e=this._video.cloneNode(!1);this._video.parentNode?.replaceChild(e,this._video),this._video=null}}import{getWindow as Ui,isBrowserWindow as Wi}from"@vkontakte/videoplayer-shared/es2015";var Gi=`audio/mpeg`;class Ki{constructor(){i(this,`_audio`,void 0),i(this,`_containers`,void 0),i(this,`_codecs`,void 0)}supportMp3(){return this._codecs.mp3&&this._containers.mpeg}detect(){let e=Ui();if(Wi(e)){this._audio=e.document.createElement(`audio`);try{var t,n,r;this._containers={mpeg:!!(t=this._audio).canPlayType?.call(t,Gi)},this._codecs={mp3:!!(!((n=Ai())==null||(r=n.isTypeSupported)==null)&&r.call(n,Gi))}}catch(e){console.error(e)}try{this.destroyAudioElement()}catch(e){console.error(`Error destroying audio element:`,e)}}}destroyAudioElement(){if(!this._audio)return;if(this._audio.pause(),this._audio.currentTime=0,this._audio.removeAttribute(`src`),this._audio.src=``,this._audio.load(),this._audio.remove){this._audio.remove(),this._audio=null;return}this._audio.parentNode&&this._audio.parentNode.removeChild(this._audio);let e=this._audio.cloneNode(!1);this._audio.parentNode?.replaceChild(e,this._audio),this._audio=null}}class qi{constructor(){i(this,`isInited$`,new gi(!1)),i(this,`_displayChecker`,void 0),i(this,`_deviceChecker`,void 0),i(this,`_browserChecker`,void 0),i(this,`_videoChecker`,void 0),i(this,`_audioChecker`,void 0),this._displayChecker=new Di,this._deviceChecker=new wi(this._displayChecker),this._browserChecker=new yi,this._videoChecker=new Hi(this._deviceChecker,this._browserChecker),this._audioChecker=new Ki,this.detect()}get display(){return this._displayChecker}get device(){return this._deviceChecker}get browser(){return this._browserChecker}get video(){return this._videoChecker}get audio(){return this._audioChecker}detect(){var e=this;return a(function*(){hi()&&(e._displayChecker.detect(),e._deviceChecker.detect(),e._browserChecker.detect(),e._videoChecker.detect(),e._audioChecker.detect(),e.isInited$.next(!0))})()}}var F=new qi,Ji=e=>{let{containers:t,protocols:n,codecs:r,nativeHlsSupported:i}=F.video,a=(r.h264||r.h265)&&r.aac,o=n.mse||n.mms;return e.filter(e=>{switch(e){case`DASH_SEP`:return o&&t.mp4&&a;case`DASH_WEBM`:return o&&t.webm&&r.vp9&&r.opus;case`DASH_WEBM_AV1`:return o&&t.webm&&r.av1&&r.opus;case`DASH_STREAMS`:return o&&(t.mp4&&a||t.webm&&(r.vp9||r.av1)&&(r.opus||r.aac));case`DASH_LIVE`:return o&&t.mp4&&a;case`DASH_LIVE_CMAF`:return o&&t.mp4&&a&&t.cmaf;case`DASH_ONDEMAND`:return o&&t.mp4&&a;case`HLS`:case`HLS_ONDEMAND`:case`HLS_FMP4`:case`HLS_LIVE`:case`HLS_LIVE_CMAF`:return i;case`MPEG`:return t.mp4;case`DASH`:case`DASH_LIVE_WEBM`:return!1;case`WEB_RTC_LIVE`:return n.webrtc&&n.ws&&r.h264&&(t.mp4||t.webm);default:return mi(e)}})},Yi=e=>{switch(e){case`MPEG`:case`DASH`:case`DASH_SEP`:case`DASH_ONDEMAND`:case`DASH_WEBM`:case`DASH_WEBM_AV1`:case`DASH_STREAMS`:case`HLS`:case`HLS_FMP4`:case`HLS_ONDEMAND`:return!1;case`DASH_LIVE`:case`DASH_LIVE_CMAF`:case`HLS_LIVE`:case`HLS_LIVE_CMAF`:case`DASH_LIVE_WEBM`:case`WEB_RTC_LIVE`:return!0;default:return mi(e)}},Xi=e=>Ji(Object.keys(e).filter(e=>!Yi(e))).length>0;class Zi{constructor(e){i(this,`subscription`,new Qr),i(this,`log`,void 0),i(this,`params`,void 0),i(this,`sessionId$`,new $r(null)),i(this,`mediaSessionId$`,new $r(null)),i(this,`contentId$`,new $r(null)),i(this,`progressTicker`,void 0),i(this,`isMobile`,Ci()),i(this,`mobileVolumeState`,{muted:!1,volume:0}),i(this,`media`,null),i(this,`lastRequestedVolume`,null),i(this,`syncMediaState`,e=>{if(Xr(e))return;this.media=e,this.mediaSessionId$.next(e.mediaSessionId??null);let t=e.media?.contentId;t&&this.contentId$.next(t),this.syncPlaybackState(e);let n=e.media?.duration;Yr(n)&&this.params.output.duration$.next(Math.max(0,n));let r=e.currentTime;if(Yr(r)){this.params.desiredState.seekState.getState().state===`applying`&&this.params.output.seekedEvent$.next(),this.params.output.position$.next(r);let t=this.params.output.isLive$.getValue();e.playerState===`PLAYING`&&!t?this.progressTicker.start(r):this.progressTicker.pause()}}),this.params=e,this.progressTicker=new pi(e),this.log=this.params.dependencies.logger.createComponentLog(`ChromecastPresentationApiProvider`),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(Yi(e.format)),this.subscribe()}subscribe(){let e=e=>{this.params.output.error$.next({category:Kr.WTF,id:`ChromecastPresentationApiProvider`,message:e?.message??`Unknown error`,thrown:e})};this.subscription.add(this.params.chromecastConnector.message$.pipe(qr(e=>!!e)).subscribe(e=>{this.handleMessage(e)},e)),this.subscription.add(this.sessionId$.pipe(qr(Yr),Jr(),Gr(0)).subscribe(()=>{this.loadMedia()},e));let t=this.contentId$.pipe(Jr(),Zr(Boolean));this.subscription.add(Wr({seekState:this.params.desiredState.seekState.stateChangeEnded$,mediaLoaded:t}).pipe(qr(({mediaLoaded:e})=>e)).subscribe(()=>{let e=this.params.desiredState.seekState.getState();e.state===`requested`&&this.seek(e.position/1e3)},e));let n=Wr({playbackState:this.params.desiredState.playbackState.stateChangeStarted$,mediaLoaded:t});this.subscription.add(n.pipe(qr(({mediaLoaded:e})=>e),Gr(0)).subscribe(()=>{this.syncPlayback()},e)),this.subscription.add(n.pipe(qr(({mediaLoaded:e,playbackState:{from:t,to:n}})=>!e&&t===`stopped`&&n===`playing`)).subscribe(()=>{this.loadMedia()},e)),this.subscription.add(Wr({volumeState:this.params.desiredState.volume.stateChangeStarted$.pipe(Gr(30)),mediaLoaded:t}).pipe(qr(({mediaLoaded:e})=>e)).subscribe(({volumeState:e})=>{let{muted:t,volume:n}=e.to;this.setVolume(n,t)},e))}handleMessage(e){switch(e.type){case`new_session`:case`update_session`:{var t;this.sessionId$.next(e.message.sessionId);let n=(t=e.message)==null||(t=t.media)==null?void 0:t[0];this.syncMediaState(n);let r=e.message?.receiver.volume;this.syncVolumeState(r)}break;case`v2_message`:switch(e.message?.type){case`MEDIA_STATUS`:{var n;let t=(n=e.message)==null||(n=n.status)==null?void 0:n[0];this.syncMediaState(t);break}}break}}loadMedia(){let e=ci(this.params),t=this.media?.currentTime,n=this.params.desiredState.seekState.getState(),r=t??(n.state===`none`?0:n.position/1e3),i=this.params.desiredState.playbackState.getState()===`playing`;this.params.chromecastConnector.sendV2Message({type:`LOAD`,requestId:0,media:e,autoplay:i,currentTime:r,customData:null,activeTrackIds:null}),this.params.output.willSeekEvent$.next()}stop(){this.params.chromecastConnector.stopMedia()}play(){let e=this.mediaSessionId$.getValue();Ur(e,`play on null mediaSessionId`),this.params.chromecastConnector.sendV2Message({type:`PLAY`,mediaSessionId:e,customData:null})}pause(){let e=this.mediaSessionId$.getValue();Ur(e,`pause on null mediaSessionId`),this.params.chromecastConnector.sendV2Message({type:`PAUSE`,mediaSessionId:e,customData:null})}seek(e){let t=this.mediaSessionId$.getValue();Ur(t,`seek on null mediaSessionId`),this.params.chromecastConnector.sendV2Message({type:`SEEK`,currentTime:e,mediaSessionId:t}),this.params.output.willSeekEvent$.next()}setVolume(e,t){let n=e,r=`[setVolume] volume: ${e}, muted: ${t}`;this.isMobile&&(n=this.mobileVolumeState.volume,r+=`, mobile next volume: ${n}`),this.log({message:r}),this.lastRequestedVolume={volume:n,muted:t},this.params.chromecastConnector.sendV2Message({type:`SET_VOLUME`,requestId:0,volume:{level:t?0:n,muted:t?!0:null}})}syncPlaybackState({playerState:e,idleReason:t}){let n=this.params.output.isBuffering$.getValue(),r=e===`BUFFERING`;switch(n!==r&&this.params.output.isBuffering$.next(r),e){case`PAUSED`:P(this.params.desiredState.playbackState,`paused`);break;case`PLAYING`:P(this.params.desiredState.playbackState,`playing`);break;case`IDLE`:t===`FINISHED`?(this.params.output.endedEvent$.next(),P(this.params.desiredState.playbackState,`stopped`),this.contentId$.next(null)):P(this.params.desiredState.playbackState,`ready`);break;case`BUFFERING`:break}}syncPlayback(){let e=this.params.desiredState.playbackState.getState();switch(this.log({message:`[syncPlayback] ${e}`}),e){case`ready`:break;case`playing`:this.play();break;case`paused`:this.pause();break;case`stopped`:this.stop();break}}syncVolumeState(e){if(Xr(e))return;let{level:t,muted:n}=e,r={muted:n??!1,volume:t??0};this.lastRequestedVolume&&=(n&&(r.volume=this.lastRequestedVolume.volume),this.lastRequestedVolume.muted&&!t&&!n&&(r.volume=this.lastRequestedVolume.volume,r.muted=!0),null);let i=`[syncVolumeState] volume: ${r.volume}, muted: ${r.muted}`;this.isMobile&&(this.mobileVolumeState.volume=r.volume,this.mobileVolumeState.muted=r.muted,r.volume=this.params.output.volume$.getValue().volume,i+=`, volume passed to state machine: ${r.volume}`),this.log({message:i}),this.params.output.volume$.next(r)}destroy(){this.progressTicker.destroy(),this.subscription.unsubscribe()}}import{assertNonNullable as Qi,ErrorCategory as $i,filter as ea,Subject as ta,Subscription as na,tap as ra,ValueSubject as ia,fromEvent as aa,getWindow as oa}from"@vkontakte/videoplayer-shared/es2015";var sa=e=>({castDevice:{friendlyName:e},remotePlayer:{},remotePlayerController:{},session:{}}),ca=()=>String(Date.now())+String(Math.floor(Math.random()*1e5));class la{constructor(e){i(this,`params`,void 0),i(this,`clientId`,void 0),i(this,`capabilities`,[`WEB`]),i(this,`presentationRequest$`,new ia(null)),i(this,`log`,void 0),i(this,`sessionId$`,new ia(null)),i(this,`broadcastChannel`,new BroadcastChannel(`vk_player_chromecast_events`)),i(this,`subscription`,new na),i(this,`subscriptionEvents`,new na),i(this,`isDestroyed`,!1),i(this,`sequenceNumber`,0),i(this,`presentationAvailable$`,new ia(!1)),i(this,`presentationConnection$`,new ia(null)),i(this,`message$`,new ia(null)),i(this,`friendlyName$`,new ia(null)),i(this,`errorEvent$`,new ta),this.clientId=this.getClientId(),this.params=e,this.log=e.logger.createComponentLog(`ChromecastPresentationApiConnector`),this.log({message:`constructor`}),this.safeReinitPresentation(),this.subscribe()}destroy(){this.log({message:`destroy`}),this.subscription.unsubscribe(),this.subscriptionEvents.unsubscribe(),this.broadcastChannel.close(),this.isDestroyed=!0}disconnect(e=!0){this.log({message:`disconnect`}),e&&this.stopMedia(),this.presentationRequest$.next(null);let t=this.presentationConnection$.getValue();t&&t.close(),this.presentationConnection$.next(null),this.friendlyName$.next(null),this.resetSequenceNumber(),this.resetSubscriptionEvents()}stopMedia(){this.log({message:`stopMedia`}),this.sendV2Message({type:`STOP`})}reinitPresentation(e=!0){let t=this.createCastUrl(),n=new PresentationRequest(t);this.presentationRequest$.next(n),this.log({message:`PresentationRequest created`}),n.getAvailability().then(e=>{let t=()=>{this.log({message:`PresentationRequest presentation availability: ${e.value}`}),this.presentationAvailable$.next(e.value)};this.subscriptionEvents.add(aa(e,`change`).subscribe(()=>{t()})),t()}).catch(()=>{this.presentationAvailable$.next(!0)}),oa().navigator.presentation.defaultRequest=n,e&&n.reconnect(`auto-join`).then(e=>{this.log({message:`PresentationRequest reconnect success`}),this.handleConnection(e)}).catch(()=>{this.log({message:`PresentationRequest reconnect failed`})})}safeReinitPresentation(e){try{this.reinitPresentation(e)}catch(e){this.errorEvent$.next({category:$i.WTF,id:`ChromecastPresentationApiConnector`,message:e?.message??`reinitPresentation error`,thrown:e})}}connect(){var e=this;return a(function*(){e.log({message:`connect`});try{e.presentationRequest$.getValue()||(e.log({message:`reinitPresentation`}),e.reinitPresentation(!1));let t=e.presentationRequest$.getValue();Qi(t,`connect with null presentationRequest`);let n=yield t.start();e.handleConnection(n)}catch(t){switch(t?.name){case`AbortError`:case`NotAllowedError`:break;default:e.errorEvent$.next({category:$i.WTF,id:`ChromecastPresentationApiConnector`,message:t?.message??`connect error`,thrown:t});break}}})()}subscribe(){this.subscription.add(aa(this.broadcastChannel,`message`).subscribe(e=>{this.log({message:`broadcast connection data: ${e.data}`}),e.data===`connection`&&this.disconnect(!1)})),this.subscription.add(this.presentationAvailable$.subscribe(e=>{this.log({message:`presentationAvailable$: ${e}`})})),this.subscription.add(this.presentationConnection$.pipe(ra(e=>{this.log({message:`presentationConnection$: ${!!e}`})}),ea(e=>!!e)).subscribe(e=>{let t=aa(e,`message`).subscribe(e=>{let t=JSON.parse(e.data);t.clientId===this.clientId&&(this.log({message:`[onmessage] ${e.data}`}),this.handleMessage(t),this.message$.next(t))}),n=aa(e,`connect`).subscribe(()=>{this.send(`client_connect`)}),r=aa(e,`close`).subscribe(e=>{switch(e.reason){case`error`:this.errorEvent$.next({category:$i.WTF,id:`ChromecastPresentationApiConnector`,message:`Session error`,thrown:e});break;case`closed`:break}});this.subscriptionEvents.add(t),this.subscriptionEvents.add(n),this.subscriptionEvents.add(r)}))}send(e){switch(e){case`client_connect`:{let e={type:`client_connect`,message:this.clientId,sequenceNumber:-1,timeoutMillis:0,clientId:this.clientId};this.safeSend(JSON.stringify(e));break}}}sendV2Message(e){let t=this.sessionId$.getValue();if(t){let n={type:`v2_message`,sequenceNumber:this.getSequenceNumber(),timeoutMillis:0,clientId:this.clientId,message:o(o({},e),{},{sessionId:t})};this.safeSend(JSON.stringify(n))}}safeSend(e){try{this.log({message:`[send] ${e}`});let t=this.presentationConnection$.getValue();t?.state===`connected`&&t?.send(e)}catch(t){this.errorEvent$.next({category:$i.WTF,id:`ChromecastPresentationApiConnector`,message:`PresentationConnection send error`,data:{message:e},thrown:t})}}handleMessage(e){switch(e.type){case`new_session`:case`update_session`:this.sessionId$.next(e.message.sessionId),this.friendlyName$.next(e.message.receiver.friendlyName||`Chromecast Device`);break;case`receiver_action`:e.message?.action===`stop`&&this.disconnect();break}}createCastUrl(){return`cast:${this.params.appId}?clientId=${this.clientId}&autoJoinPolicy=tab_and_origin_scoped&defaultActionPolicy=create_session&launchTimeout=60000&supportedAppTypes=${this.capabilities}&appParams=%7B%22launchCheckerParams%22%3A%7B%7D%7D`}getSequenceNumber(){let e=this.sequenceNumber;return this.sequenceNumber=(this.sequenceNumber+1)%(2**53-1),e}resetSequenceNumber(){this.sequenceNumber=0}getClientId(){let e=`__vk_player_chromecast_id`;return oa()[e]=oa()[e]||ca()}resetSubscriptionEvents(){this.subscriptionEvents.unsubscribe(),this.subscriptionEvents=new na}handleConnection(e){this.log({message:`connection available`}),this.isDestroyed?(this.log({message:`connected on already destroyed component`}),e.close()):(this.broadcastChannel.postMessage(`connection`),this.presentationConnection$.next(e))}}import{ValueSubject as ua,Subject as da,map as fa,Subscription as pa,combine as ma,filterChanged as ha,assertNonNullable as ga}from"@vkontakte/videoplayer-shared/es2015";class _a{static isSupported(){return`chrome`in window&&`presentation`in navigator&&`BroadcastChannel`in window}constructor(e){i(this,`subscription`,new pa),i(this,`log`,void 0),i(this,`contentId`,void 0),i(this,`connection$`,new ua(void 0)),i(this,`castState$`,new ua(`NOT_AVAILABLE`)),i(this,`errorEvent$`,new da),i(this,`chromecastConnector`,void 0);let t=_a.isSupported();this.log=e.dependencies.logger.createComponentLog(`ChromecastPresentationApiInitializer`),this.log({message:`[constructor] receiverApplicationId: ${e.receiverApplicationId}, isDisabled: ${e.isDisabled}, isSupported: ${t}`}),!(!t||e.isDisabled||!e.receiverApplicationId)&&(this.chromecastConnector=new la({appId:e.receiverApplicationId,logger:e.dependencies.logger}),this.subscribe())}subscribe(){ga(this.chromecastConnector,`subscribe with null chromecastConnector`),this.subscription.add(this.chromecastConnector.errorEvent$.subscribe(this.errorEvent$));let e=ma({connection:this.chromecastConnector.presentationConnection$,available:this.chromecastConnector.presentationAvailable$,friendlyName:this.chromecastConnector.friendlyName$.pipe(ha())});this.subscription.add(e.pipe(fa(({connection:e,friendlyName:t})=>!!(e&&t)),ha()).subscribe(e=>{let t=this.chromecastConnector?.friendlyName$.getValue()??``;this.connection$.next(e?sa(t):void 0)})).add(e.subscribe(({available:e,connection:t})=>{e?t?this.castState$.next(`CONNECTED`):this.castState$.next(`AVAILABLE`):this.castState$.next(`NOT_AVAILABLE`)}))}connect(){this.log({message:`connect`}),this.chromecastConnector?.connect()}disconnect(){this.log({message:`disconnect`}),this.chromecastConnector?.disconnect()}stopMedia(){var e=this;return a(function*(){e.log({message:`stopMedia`}),e.chromecastConnector?.stopMedia()})()}toggleConnection(){let e=!!this.chromecastConnector?.presentationConnection$.getValue();this.log({message:`toggleConnection: isConnected - ${e}`}),e?this.disconnect():this.connect()}setVolume(e){}setMuted(e){}destroy(){this.log({message:`destroy`}),this.chromecastConnector?.destroy(),this.subscription.unsubscribe()}}var va=v(it(),1),ya=(e,...t)=>typeof e==`string`?e.includes(...t):va.default(e,...t),ba=v(ct(),1),xa=v(Vt(),1),Sa=v(Tn(),1);import{isNonNullable as Ca,Subject as wa,merge as Ta}from"@vkontakte/videoplayer-shared/es2015";class I{constructor(e){i(this,`state`,void 0),i(this,`prevState`,void 0),i(this,`transition`,void 0),i(this,`transitionStarted$`,new wa),i(this,`transitionEnded$`,new wa),i(this,`transitionUpdated$`,new wa),i(this,`forceChanged$`,new wa),i(this,`stateChangeStarted$`,Ta(this.transitionStarted$,this.transitionUpdated$)),i(this,`stateChangeEnded$`,Ta(this.transitionEnded$,this.forceChanged$)),this.state=e,this.prevState=void 0}setState(e){let t=this.transition,n=this.state;this.transition=void 0,this.prevState=n,this.state=e,t?t.to===e?this.transitionEnded$.next(t):this.forceChanged$.next({from:t.from,to:e,canceledTransition:t}):this.forceChanged$.next({from:n,to:e,canceledTransition:t})}startTransitionTo(e){let t=this.transition,n=this.state;n===e||Ca(t)&&t.to===e||(this.prevState=n,this.state=e,t?(this.transition={from:t.from,to:e,canceledTransition:t},this.transitionUpdated$.next(this.transition)):(this.transition={from:n,to:e},this.transitionStarted$.next(this.transition)))}getTransition(){return this.transition}getState(){return this.state}getPrevState(){return this.prevState}}import{assertNever as Ea,debounce as Da,ErrorCategory as Oa,fromEvent as ka,map as Aa,merge as ja,observableFrom as Ma,Subject as Na,Subscription as Pa,timeout as Fa}from"@vkontakte/videoplayer-shared/es2015";var Ia=5,La=5,Ra=500,za=7e3;class Ba{constructor(e){i(this,`subscription`,new Pa),i(this,`loadMediaTimeoutSubscription`,new Pa),i(this,`videoState`,new I(`stopped`)),i(this,`params`,void 0),i(this,`log`,void 0),i(this,`syncPlayback`,()=>{let e=this.videoState.getState(),t=this.videoState.getTransition(),n=this.params.desiredState.playbackState.getState(),r=this.params.desiredState.playbackState.getTransition(),i=this.params.desiredState.seekState.getState();if(this.log({message:`[syncPlayback] videoState: ${e}; videoTransition: ${JSON.stringify(t)}; desiredPlaybackState: ${n}; desiredPlaybackStateTransition: ${this.params.desiredState.playbackState.getTransition()}; seekState: ${JSON.stringify(i)};`}),n===`stopped`){e!==`stopped`&&(this.videoState.startTransitionTo(`stopped`),this.stop());return}if(!t){if(r?.to!==`paused`&&i.state===`requested`&&e!==`stopped`){this.seek(i.position/1e3);return}switch(n){case`ready`:switch(e){case`playing`:case`paused`:case`ready`:break;case`stopped`:this.videoState.startTransitionTo(`ready`),this.prepare();break;default:Ea(e)}break;case`playing`:switch(e){case`playing`:break;case`paused`:this.videoState.startTransitionTo(`playing`),this.params.connection.remotePlayerController.playOrPause();break;case`ready`:this.videoState.startTransitionTo(`playing`),this.params.connection.remotePlayerController.playOrPause();break;case`stopped`:this.videoState.startTransitionTo(`ready`),this.prepare();break;default:Ea(e)}break;case`paused`:switch(e){case`playing`:this.videoState.startTransitionTo(`paused`),this.params.connection.remotePlayerController.playOrPause();break;case`paused`:break;case`ready`:this.videoState.startTransitionTo(`paused`),this.videoState.setState(`paused`);break;case`stopped`:this.videoState.startTransitionTo(`ready`),this.prepare();break;default:Ea(e)}break;default:Ea(n)}}}),this.params=e,this.log=this.params.dependencies.logger.createComponentLog(`ChromecastProvider`),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(Yi(e.format)),this.params.output.isAudioAvailable$.next(!0),this.handleRemoteVolumeChange({volume:this.params.connection.remotePlayer.volumeLevel,muted:this.params.connection.remotePlayer.isMuted});let t=this.params.connection.session.getMediaSession();t&&this.restoreSession(t),this.subscribe()}destroy(){this.log({message:`[destroy]`}),this.subscription.unsubscribe()}subscribe(){this.subscription.add(this.loadMediaTimeoutSubscription);let e=new Pa;this.subscription.add(e),this.subscription.add(ja(this.videoState.stateChangeStarted$.pipe(Aa(e=>`stateChangeStarted$ ${JSON.stringify(e)}`)),this.videoState.stateChangeEnded$.pipe(Aa(e=>`stateChangeEnded$ ${JSON.stringify(e)}`))).subscribe(e=>this.log({message:`[videoState] ${e}`})));let t=(e,t)=>this.subscription.add(e.subscribe(t));if(this.params.output.isLive$.getValue())this.params.output.position$.next(0),this.params.output.duration$.next(0);else{let t=new Na;e.add(t.pipe(Da(Ra)).subscribe(()=>{this.params.output.seekedEvent$.next()}));let n=NaN;e.add(ka(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED).subscribe(e=>{this.logRemoteEvent(e);let r=e.value;this.params.output.position$.next(r),(this.params.desiredState.seekState.getState().state===`applying`||Math.abs(r-n)>Ia)&&t.next(r),n=r})),e.add(ka(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.DURATION_CHANGED).subscribe(e=>{this.logRemoteEvent(e),this.params.output.duration$.next(e.value)}))}t(ka(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED),t=>{this.logRemoteEvent(t),t.value?this.handleRemoteReady():(this.handleRemoteStop(),e.unsubscribe())}),t(ka(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),e=>{this.logRemoteEvent(e),e.value?this.handleRemotePause():this.handleRemotePlay()}),t(ka(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED),e=>{this.logRemoteEvent(e);let{remotePlayer:t}=this.params.connection,n=e.value,r=this.params.output.isBuffering$.getValue(),i=n===chrome.cast.media.PlayerState.BUFFERING;switch(r!==i&&this.params.output.isBuffering$.next(i),n){case chrome.cast.media.PlayerState.IDLE:!this.params.output.isLive$.getValue()&&t.duration-t.currentTime<La&&this.params.output.endedEvent$.next(),this.handleRemoteStop(),P(this.params.desiredState.playbackState,`stopped`);break;case chrome.cast.media.PlayerState.PAUSED:this.handleRemotePause();break;case chrome.cast.media.PlayerState.PLAYING:this.handleRemotePlay();break;case chrome.cast.media.PlayerState.BUFFERING:break;default:Ea(n)}}),t(ka(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED),e=>{this.logRemoteEvent(e),this.handleRemoteVolumeChange({volume:e.value})}),t(ka(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),e=>{this.logRemoteEvent(e),this.handleRemoteVolumeChange({muted:e.value})}),t(ja(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,Ma([`init`])).pipe(Da(0)),this.syncPlayback)}restoreSession(e){this.log({message:`restoreSession`});let{remotePlayer:t}=this.params.connection;if(e.playerState!==chrome.cast.media.PlayerState.IDLE){t.isPaused?(this.videoState.setState(`paused`),P(this.params.desiredState.playbackState,`paused`)):(this.videoState.setState(`playing`),P(this.params.desiredState.playbackState,`playing`));let e=this.params.output.isLive$.getValue();this.params.output.duration$.next(e?0:t.duration),this.params.output.position$.next(e?0:t.currentTime),this.params.desiredState.seekState.setState({state:`none`})}}prepare(){let e=this.params.format;this.log({message:`[prepare] format: ${e}`});let t=ci(this.params),n=this.createLoadRequest(t);this.loadMedia(n)}handleRemotePause(){let e=this.videoState.getState();(this.videoState.getTransition()?.to===`paused`||e===`playing`)&&(this.videoState.setState(`paused`),P(this.params.desiredState.playbackState,`paused`))}handleRemotePlay(){let e=this.videoState.getState();(this.videoState.getTransition()?.to===`playing`||e===`paused`)&&(this.videoState.setState(`playing`),P(this.params.desiredState.playbackState,`playing`))}handleRemoteReady(){this.videoState.getTransition()?.to===`ready`&&this.videoState.setState(`ready`),this.params.desiredState.playbackState.getTransition()?.to===`ready`&&P(this.params.desiredState.playbackState,`ready`)}handleRemoteStop(){this.videoState.getState()!==`stopped`&&this.videoState.setState(`stopped`)}handleRemoteVolumeChange(e){let t=this.params.output.volume$.getValue(),n={volume:e.volume??t.volume,muted:e.muted??t.muted};(n.volume!==t.volume||n.muted!==n.muted)&&this.params.output.volume$.next(n)}seek(e){this.params.output.willSeekEvent$.next();let{remotePlayer:t,remotePlayerController:n}=this.params.connection;t.currentTime=e,n.seek()}stop(){let{remotePlayerController:e}=this.params.connection;e.stop()}createLoadRequest(e){let t=new chrome.cast.media.LoadRequest(e);t.autoplay=!1;let n=this.params.desiredState.seekState.getState();return n.state===`applying`||n.state===`requested`?t.currentTime=this.params.output.isLive$.getValue()?0:n.position/1e3:t.currentTime=0,t}loadMedia(e){let t=this.params.connection.session.loadMedia(e),n=new Promise((e,t)=>{this.loadMediaTimeoutSubscription.add(Fa(za).subscribe(()=>t(`timeout(${za})`)))});Sa.default(Promise.race([t,n]).then(()=>{this.log({message:`[loadMedia] completed, format: ${this.params.format}`}),this.params.desiredState.seekState.getState().state===`applying`&&this.params.output.seekedEvent$.next(),this.handleRemoteReady()},e=>{let t=`[prepare] loadMedia failed, format: ${this.params.format}, reason: ${e}`;this.log({message:t}),this.params.output.error$.next({id:`ChromecastProvider.loadMedia`,category:Oa.VIDEO_PIPELINE,message:t,thrown:e})}),()=>{this.loadMediaTimeoutSubscription.unsubscribe()})}logRemoteEvent(e){this.log({message:`[remoteEvent] ${JSON.stringify(e)}`})}}var Va=v(it(),1);import{clearVideoElement as Ha,getWindow as Ua}from"@vkontakte/videoplayer-shared/es2015";import{clearVideoElement as Wa}from"@vkontakte/videoplayer-shared/es2015";var Ga=(e,t)=>{try{e.pause(),e.playbackRate=0,Wa(e,t),e.remove()}catch(e){console.error(e)}};import{fromEvent as Ka,Subscription as qa}from"@vkontakte/videoplayer-shared/es2015";var Ja=`__spvc`;class Ya{constructor(){i(this,`attribute`,`data-pool-reused`)}get(e){return e.hasAttribute(this.attribute)}set(e,t){e.toggleAttribute(this.attribute,t)}delete(e){e.removeAttribute(this.attribute)}}var Xa=Ua(),Za=Xa.WeakMap?new Xa.WeakMap:new Ya,Qa=Xa.WeakMap?new Xa.WeakMap:new Map,$a=(e,t=20)=>{let n=0;return Ka(e,`ratechange`).subscribe(r=>{n++,n>=t&&(e.currentTime=e.currentTime,n=0)})};function eo(e){e.style.position=`fixed`,e.style.left=`100%`,e.setAttribute(`data-role`,`screen`),Ua().document.body.appendChild(e)}function to(e,t){e.style.position=``,e.style.left=``,t.appendChild(e)}var no=(e,{audioVideoSyncRate:t,disableYandexPiP:n,clearVideoElementInnerHTML:r,reuseOwnVideoElement:i})=>{let a,o=e.querySelector(`video`),s=!!o,c=Ua().document.querySelector(`body > video[data-role=screen]`)||void 0;i?Xa[Ja]=c:(c?.remove(),delete Xa[Ja]),o?(a=o,Ha(a,r)):c&&c===Xa[Ja]?(a=c,to(a,e)):(a=Ua().document.createElement(`video`),e.appendChild(a),i&&(Xa[Ja]=a)),Za.set(a,s);let l=new qa;return l.add($a(a,t)),Qa.set(a,l),a.setAttribute(`crossorigin`,`anonymous`),a.setAttribute(`playsinline`,`playsinline`),n&&a.setAttribute(`x-yandex-pip`,`false`),a.controls=!1,a.setAttribute(`poster`,`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=`),a},ro=(e,{keepVideoElement:t,clearVideoElementInnerHTML:n,reuseOwnVideoElement:r})=>{Qa.get(e)?.unsubscribe(),Qa.delete(e);let i=Za.get(e);Za.delete(e),i||t?Ha(e,n):r?(Ha(e,n),eo(e)):Ga(e,n)},io=v(Qe(),1);import{assertNonNullable as ao,isNonNullable as oo,isNullable as so,fromEvent as co,merge as lo,observableFrom as uo,filterChanged as fo,map as po,Subject as mo,Subscription as ho,ValueSubject as go,ErrorCategory as _o}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as vo,isNullable as yo,Subscription as bo}from"@vkontakte/videoplayer-shared/es2015";var xo=(e,t,n,{equal:r=(e,t)=>e===t,changed$:i,onError:a}={})=>{let o=e.getState(),s=t(),c=yo(i),l=new bo;return i&&l.add(i.subscribe(t=>{r(t,e.getState())&&e.setState(t)},a)),r(s,o)||(n(o),c&&e.setState(o)),l.add(e.stateChangeStarted$.subscribe(t=>{n(t.to),c&&e.setState(t.to)},a)),l},So=(e,t,n)=>xo(t,()=>e.loop,t=>{vo(t)&&(e.loop=t)},{onError:n}),Co=(e,t,n,r,i)=>xo(t,()=>({muted:e.muted,volume:e.volume}),t=>{i?.skipVideoElVolumeSync$.getValue()||vo(t)&&(e.muted=t.muted,e.volume=t.volume)},{equal:(e,t)=>e===t||e?.muted===t?.muted&&e?.volume===t?.volume,changed$:n,onError:r}),wo=(e,t,n,r)=>xo(t,()=>e.playbackRate,t=>{vo(t)&&(e.playbackRate=t)},{changed$:n,onError:r}),To=xo,Eo=e=>[`__`,e.language,e.label].join(`|`),Do=(e,t)=>{if(e.id===t)return!0;let[n,r,i]=t.split(`|`);return e.language===r&&e.label===i};class Oo{constructor(e){i(this,`available$`,new mo),i(this,`current$`,new go(void 0)),i(this,`error$`,new mo),i(this,`video`,void 0),i(this,`cueSettings`,void 0),i(this,`subscription`,new ho),i(this,`externalTracks`,new Map),i(this,`internalTracks`,new Map),i(this,`baseURL`,void 0),this.baseURL=e}connect(e,t,n){this.video=e,this.cueSettings=t.textTrackCuesSettings,this.subscribe();let r=e=>{this.error$.next({id:`TextTracksManager`,category:_o.WTF,message:`Generic HtmlVideoTextTrackManager error`,thrown:e})};this.subscription.add(this.available$.subscribe(n.availableTextTracks$)),this.subscription.add(this.current$.subscribe(n.currentTextTrack$)),this.subscription.add(this.error$.subscribe(n.error$)),this.subscription.add(To(t.internalTextTracks,()=>io.default(this.internalTracks),e=>{oo(e)&&this.setInternal(e)},{equal:(e,t)=>oo(e)&&oo(t)&&e.length===t.length&&e.every(({id:e},n)=>e===t[n].id),changed$:this.available$.pipe(po(e=>e.filter(({type:e})=>e===`internal`))),onError:r})),this.subscription.add(To(t.externalTextTracks,()=>io.default(this.externalTracks),e=>{oo(e)&&this.setExternal(e)},{equal:(e,t)=>oo(e)&&oo(t)&&e.length===t.length&&e.every(({id:e},n)=>e===t[n].id),changed$:this.available$.pipe(po(e=>e.filter(({type:e})=>e===`external`))),onError:r})),this.subscription.add(To(t.currentTextTrack,()=>{if(this.video)return;let e=this.htmlTextTracksAsArray().find(({mode:e})=>e===`showing`);return e&&this.htmlTextTrackToITextTrack(e).id},e=>this.select(e),{changed$:this.current$,onError:r})),this.subscription.add(To(t.textTrackCuesSettings,()=>({}),()=>{if(this.video)for(let e of this.htmlTextTracksAsArray())this.applyCueSettings(e.cues),this.applyCueSettings(e.activeCues)}))}subscribe(){ao(this.video);let{textTracks:e}=this.video;this.subscription.add(co(e,`addtrack`).subscribe(()=>{let e=this.current$.getValue();e&&this.select(e)})),this.subscription.add(lo(co(e,`addtrack`),co(e,`removetrack`),uo([`init`])).pipe(po(()=>this.htmlTextTracksAsArray().map(e=>this.htmlTextTrackToITextTrack(e))),fo((e,t)=>e.length===t.length&&e.every(({id:e},n)=>e===t[n].id))).subscribe(this.available$)),this.subscription.add(lo(co(e,`change`),uo([`init`])).pipe(po(()=>this.htmlTextTracksAsArray().find(({mode:e})=>e===`showing`)),po(e=>e&&this.htmlTextTrackToITextTrack(e).id),fo()).subscribe(this.current$));let t=e=>this.applyCueSettings(e.target?.activeCues??null);this.subscription.add(co(e,`addtrack`).subscribe(e=>{e.track?.addEventListener(`cuechange`,t);let n=e=>{let t=e.target?.cues??null;t&&t.length&&(this.applyCueSettings(e.target?.cues??null),e.target?.removeEventListener(`cuechange`,n))};e.track?.addEventListener(`cuechange`,n)})),this.subscription.add(co(e,`removetrack`).subscribe(e=>{e.track?.removeEventListener(`cuechange`,t)}))}applyCueSettings(e){if(!e||!e.length)return;let t=this.cueSettings.getState();for(let n of Array.from(e)){let e=n;oo(t.align)&&(e.align=t.align),oo(t.position)&&(e.position=t.position),oo(t.size)&&(e.size=t.size),oo(t.line)&&(e.line=t.line)}}htmlTextTracksAsArray(e=!1){ao(this.video);let t=[...this.video.textTracks];return e?t:t.filter(Oo.isHealthyTrack)}htmlTextTrackToITextTrack(e){let{language:t,label:n}=e,r=e.id?e.id:Eo(e),i=this.externalTracks.has(r),a=(i?this.externalTracks.get(r)?.isAuto:this.internalTracks.get(r)?.isAuto)??r.includes(`auto`);return i?{id:r,type:`external`,isAuto:a,language:t,label:n,url:this.externalTracks.get(r)?.url}:{id:r,type:`internal`,isAuto:a,language:t,label:n,url:this.internalTracks.get(r)?.url}}static isHealthyTrack(e){return!(e.kind===`metadata`||e.groupId||e.id===``&&e.label===``&&e.language===``)}setExternal(e){this.internalTracks.size>0&&Array.from(this.internalTracks).forEach(([,e])=>this.detach(e)),e.filter(({id:e})=>!this.externalTracks.has(e)).forEach(e=>this.attach(e)),Array.from(this.externalTracks).filter(([t])=>!e.find(e=>e.id===t)).forEach(([,e])=>this.detach(e))}setInternal(e){let t=[...this.externalTracks];e.filter(({id:e,language:n,isAuto:r})=>!this.internalTracks.has(e)&&!t.some(([,e])=>e.language===n&&e.isAuto===r)).forEach(e=>this.attach(e)),Array.from(this.internalTracks).filter(([t])=>!e.find(e=>e.id===t)).forEach(([,e])=>this.detach(e))}select(e){ao(this.video);for(let e of this.htmlTextTracksAsArray(!0))e.mode=`showing`;for(let t of this.htmlTextTracksAsArray(!0))(so(e)||!Do(t,e))&&(t.mode=`disabled`)}destroy(){if(this.subscription.unsubscribe(),this.video)for(let e of Array.from(this.video.getElementsByTagName(`track`))){let t=e.getAttribute(`id`);t&&this.externalTracks.has(t)&&this.video.removeChild(e)}this.externalTracks.clear()}attach(e){ao(this.video);let t=document.createElement(`track`);this.baseURL?t.setAttribute(`src`,new URL(e.url,this.baseURL).toString()):t.setAttribute(`src`,e.url),t.setAttribute(`id`,e.id),e.label&&t.setAttribute(`label`,e.label),e.language&&t.setAttribute(`srclang`,e.language),e.type===`external`?this.externalTracks.set(e.id,e):e.type===`internal`&&this.internalTracks.set(e.id,e),this.video.appendChild(t)}detach(e){ao(this.video);let t=Array.prototype.find.call(this.video.getElementsByTagName(`track`),t=>t.getAttribute(`id`)===e.id);t&&this.video.removeChild(t),e.type===`external`?this.externalTracks.delete(e.id):e.type===`internal`&&this.internalTracks.delete(e.id)}}var ko=Oo;class Ao{constructor(){i(this,`pausedTime`,0),i(this,`streamOffset`,0),i(this,`pauseTimestamp`,0)}getTotalPausedTime(){return this.pausedTime+this.getCurrentPausedTime()}getCurrentPausedTime(){return this.pauseTimestamp>0?Date.now()-this.pauseTimestamp:0}getStreamOffset(){return this.streamOffset}getTotalOffset(){return this.getTotalPausedTime()+this.streamOffset}pause(){this.pauseTimestamp===0&&(this.pauseTimestamp=Date.now())}resume(){this.pauseTimestamp>0&&(this.pausedTime+=this.getCurrentPausedTime(),this.pauseTimestamp=0)}resetTo(e,t=!1){this.streamOffset=e,this.pauseTimestamp=0,this.pausedTime=0,t&&this.pause()}}var jo=e=>{let t=e;for(;!(t instanceof Document)&&!(t instanceof ShadowRoot)&&t!==null;)t=t?.parentNode;return t??void 0},Mo=e=>{let t=jo(e);return!!(t&&t.fullscreenElement&&t.fullscreenElement===e)},No=e=>{let t=jo(e);return!!(t&&t.pictureInPictureElement&&t.pictureInPictureElement===e)};import{fromEvent as Po,map as Fo,merge as Io,filterChanged as Lo,isNonNullable as Ro,Subject as zo,filter as Bo,mapTo as Vo,combine as Ho,once as Uo,shareReplay as Wo,throttle as Go,ErrorCategory as Ko,ValueSubject as qo,Subscription as Jo}from"@vkontakte/videoplayer-shared/es2015";var Yo=3,Xo=(e,t,n=Yo)=>{let r=0,i=0;for(let a=0;a<e.length;a++){let o=e.start(a),s=e.end(a);if(o<=t&&t<=s){if(r=o,i=s,!n)return{from:r,to:i};for(let t=a-1;t>=0;t--)e.end(t)+n>=r&&(r=e.start(t));for(let t=a+1;t<e.length;t++)e.start(t)-n<=i&&(i=e.end(t))}}return{from:r,to:i}},Zo=e=>{let t=t=>Po(e,t).pipe(Vo(void 0),Wo(1)),n=new Jo,r=()=>n.unsubscribe(),i=Io(Po(e,`progress`),Po(e,`timeupdate`)).pipe(Fo(()=>Xo(e.buffered,e.currentTime)),Wo(1)),a=F.browser.isSafari?Ho({play:t(`play`).pipe(Uo()),playing:t(`playing`)}).pipe(Vo(void 0),Wo(1)):t(`playing`),o=Po(e,`volumechange`).pipe(Fo(()=>({muted:e.muted,volume:e.volume})),Wo(1)),s=Po(e,`ratechange`).pipe(Fo(()=>e.playbackRate),Wo(1)),c=Po(e,`error`).pipe(Bo(()=>!!(e.error||e.played.length)),Fo(()=>{let t=e.error;return{id:t?`MediaError#${t.code}`:`HtmlVideoError`,category:Ko.VIDEO_PIPELINE,message:t?t.message:`Error event from HTML video element`,thrown:e.error??void 0}}),Wo(1)),l=Po(e,`timeupdate`).pipe(Fo(()=>e.currentTime),Wo(1)),u=[`waiting`,`seeking`,`seeked`,`timeupdate`],d=new zo,f=.3,p;n.add(Io(...u.map(t=>Po(e,t))).subscribe(t=>{let n=e.currentTime;e.loop&&Ro(p)&&Ro(n)&&p>=e.duration-f&&n<=f&&d.next(p),p=n}));let m=t(`pause`).pipe(Bo(()=>!e.error&&p!==e.duration),Wo(1)),h=Po(e,`enterpictureinpicture`).pipe(Wo(1)),g=Po(e,`leavepictureinpicture`).pipe(Wo(1)),_=new qo(No(e));n.add(h.subscribe(()=>_.next(!0))),n.add(g.subscribe(()=>_.next(!1)));let v=new qo(Mo(e)),y=Po(e,`fullscreenchange`).pipe(Wo(1));n.add(y.pipe(Fo(()=>Mo(e))).subscribe(v));let b=Po(e,`timeupdate`).pipe(Fo(t=>e.duration-e.currentTime<.1),Lo(),Wo(1)),x=Io(b.pipe(Bo(t=>!e.loop&&t)),Po(e,`ended`)).pipe(Go(1e3),Vo(void 0),Wo(1)),S=Io(...[`waiting`,`pause`,`canplay`,`play`,`canplaythrough`,`playing`,`seeking`,`seeked`,`ended`].map(t=>Po(e,t)),b.pipe(Fo(e=>({type:e?`ended`:`unknown`})))).pipe(Fo(t=>F.browser.isFirefox&&t.type===`ended`?e.readyState<2:e.readyState<3),Lo(),Wo(1));return{playing$:a,pause$:m,canplay$:t(`canplay`),ended$:x,looped$:d,error$:c,seeked$:t(`seeked`),seeking$:t(`seeking`),progress$:t(`progress`),loadStart$:t(`loadstart`),loadedMetadata$:t(`loadedmetadata`),loadedData$:t(`loadeddata`),timeUpdate$:l,durationChange$:Po(e,`durationchange`).pipe(Fo(()=>e.duration),Wo(1)),isBuffering$:S,currentBuffer$:i,volumeState$:o,playbackRateState$:s,inPiP$:_,inFullscreen$:v,enterPip$:h,leavePip$:g,destroy:r}};import{VideoQuality as Qo}from"@vkontakte/videoplayer-shared/es2015";var $o=e=>{switch(e){case`mobile`:return Qo.Q_144P;case`lowest`:return Qo.Q_240P;case`low`:return Qo.Q_360P;case`sd`:case`medium`:return Qo.Q_480P;case`hd`:case`high`:return Qo.Q_720P;case`fullhd`:case`full`:return Qo.Q_1080P;case`quadhd`:case`quad`:return Qo.Q_1440P;case`ultrahd`:case`ultra`:return Qo.Q_2160P}},es=v(kn(),1),ts=v(it(),1),ns=v(ct(),1);import{isNonNullable as L,isNullable as rs,now as is,isHigher as as,isHigherOrEqual as os,isInvariantQuality as ss,isLowerOrEqual as cs,videoSizeToQuality as ls,assertNotEmptyArray as us,assertNonNullable as ds}from"@vkontakte/videoplayer-shared/es2015";var fs=!1,ps={},ms=e=>{fs=e},hs=()=>{ps={}},gs=e=>{e(ps)},_s=(e,t)=>{fs&&(ps.meta=ps.meta??{},ps.meta[e]=t)};class vs{constructor(e){i(this,`name`,void 0),this.name=e}next(e){if(!fs)return;ps.series=ps.series??{};let t=ps.series[this.name]??[];t.push([Date.now(),e]),ps.series[this.name]=t}}import{isHigher as ys,isLower as bs,isNonNullable as xs,isNullable as Ss,videoHeightToQuality as Cs}from"@vkontakte/videoplayer-shared/es2015";function ws(e,t,n){return!e.max&&e.min===t?`high_quality`:!e.min&&e.max===n?`traffic_saving`:`unknown`}function Ts(e,t,n){return Ss(e)||xs(e.min)&&xs(e.max)&&bs(e.max,e.min)||xs(e.min)&&xs(t)&&ys(e.min,t)||xs(e.max)&&xs(n)&&bs(e.max,n)}function Es({limits:e,highestAvailableHeight:t,lowestAvailableHeight:n}){return Ts({max:e?.max?Cs(e.max):void 0,min:e?.min?Cs(e.min):void 0},t?Cs(t):void 0,n?Cs(n):void 0)}var Ds=new vs(`best_bitrate`),Os=(e,t,n)=>(t-n)*2**(-10*e)+n,ks=e=>(t,n)=>e*(Number(t.bitrate)-Number(n.bitrate));class As{constructor(){i(this,`last`,void 0),i(this,`history`,{})}recordSelection(e){this.history[e.id]=is()}recordSwitch(e){this.last=e}clear(){this.last=void 0,this.history={}}}var js=`Assertion "ABR Tracks is empty array" failed`,Ms=new WeakMap,Ns=new WeakMap,Ps=new WeakMap,Fs=(e,t,n,r)=>{let i=[...t].sort(ks(1)),a=[...n].sort(ks(1)),o=a.filter(t=>L(t.bitrate)&&L(e.bitrate)?e.bitrate/t.bitrate>r:!0),s=es.default(a,Math.round(a.length*i.indexOf(e)/(i.length+1)))??es.default(a,-1);return s&&ts.default(o,s)?s:o.length?es.default(o,-1):es.default(a,0)},Is=(e,t,n,r)=>{let i=Ms.get(t);i||(i=[...t].sort(ks(1)),Ms.set(t,i));let a=Ms.get(n);a||(a=[...n].sort(ks(1)),Ms.set(n,a));let o=Ps.get(e);o||(o=a.filter(t=>L(t.bitrate)&&L(e.bitrate)?e.bitrate/t.bitrate>r:!0),Ps.set(e,o));let s=es.default(a,Math.round(a.length*i.indexOf(e)/(i.length+1)))??es.default(a,-1);return s&&ts.default(o,s)?s:o.length?es.default(o,-1):es.default(a,0)},Ls=e=>`quality`in e,Rs=(e,t,n,r)=>{var i;let a=L(r==null||(i=r.last)==null?void 0:i.bitrate)&&L(n?.bitrate)&&r.last.bitrate<n.bitrate?e.trackCooldownIncreaseQuality:e.trackCooldownDecreaseQuality,o=n&&r&&r.history[n.id]&&is()-r.history[n.id]<=a&&(!r.last||n.id!==r.last.id);if(n?.id&&r&&!o&&r.recordSelection(n),o&&r?.last){let e=r.last;return r?.recordSwitch(e),t({message:`
|
|
8
8
|
[last ${Ls(e)?`video`:`audio`} selected] ${Ls(e)?e.quality:e.bitrate}
|
|
9
9
|
`}),e}return r?.recordSwitch(n),n},zs=(e,t)=>Math.log(t)/Math.log(e),Bs=({tuning:e,container:t,limits:n,panelSize:r})=>{let i=e.containerSizeFactor;if(r)return{containerSizeLimit:r,containerSizeFactor:i};if(e.usePixelRatio&&F.display.pixelRatio){let t=F.display.pixelRatio;if(e.pixelRatioMultiplier)i*=e.pixelRatioMultiplier*(t-1)+1;else{let n=e.pixelRatioLogBase,[r=0,a=0,o=0]=e.pixelRatioLogCoefficients,s=zs(n,r*t+a)+o;Number.isFinite(s)&&(i*=s)}}return L(n?.min)&&os(n.min,e.highQualityLimit)&&(i*=2),{containerSizeLimit:e.limitByContainer&&t&&t.width>0&&t.height>0?{width:t.width*i,height:t.height*i}:void 0,containerSizeFactor:i}},Vs=new WeakMap,Hs=(e,{container:t,estimatedThroughput:n,tuning:r,limits:i,reserve:a=0,forwardBufferHealth:o,playbackRate:s,current:c,history:l,visible:u,droppedVideoMaxQualityLimit:d,stallsVideoMaxQualityLimit:f,stallsPredictedThroughput:p,abrLogger:m,panelSize:h})=>{us(e,js);let{containerSizeFactor:g,containerSizeLimit:_}=Bs({container:t,tuning:r,limits:i,panelSize:h}),v=r.considerPlaybackRate&&L(s)?s:1,y=Vs.get(e);y||(y=e.filter(e=>!ss(e.quality)).sort((e,t)=>as(e.quality,t.quality)?-1:1),Vs.set(e,y));let b=es.default(y,-1)?.quality,x=es.default(y,0)?.quality,S=Ts(i,x,b),C=v*Os(o??.5,r.bitrateFactorAtEmptyBuffer,r.bitrateFactorAtFullBuffer),w={},T=null;for(let e of y){if(e.tvDisabled){w[e.quality]=`TvDisabled`;continue}let t=!0;if(_)if(e.size)t=e.size.width<=_.width&&e.size.height<=_.height;else{let n=_&&ls(_);t=n?cs(e.quality,n):!0}if(!t){w[e.quality]=`FitsContainer`;continue}let s=p||n,l=L(s)&&isFinite(s)&&L(e.bitrate)?s-a>=e.bitrate*C:!0,m=i?.min===e.quality;if(!l&&!m){w[e.quality]=`FitsThroughput`;continue}if(r.lazyQualitySwitch&&L(r.minBufferToSwitchUp)&&c&&!ss(c.quality)&&(o??0)<r.minBufferToSwitchUp&&as(e.quality,c.quality)){w[e.quality]=`Buffer`;continue}if(d&&os(e.quality,d)&&!m){w[e.quality]=`DroppedFramesLimit`;continue}if(f&&os(e.quality,f)&&!m){w[e.quality]=`StallsLimit`;continue}let h=S||(rs(i?.max)||cs(e.quality,i.max))&&(rs(i?.min)||os(e.quality,i.min)),g=L(u)&&!u?cs(e.quality,r.backgroundVideoQualityLimit):!0;if(!h||!g){w[e.quality]=`FitsQualityLimits`;continue}T||=e}T&&T.bitrate&&Ds.next(T.bitrate);let E=T??es.default(y,-1)??e[0],D=l?.last,O=Rs(r,m,E,l);return L(l)&&O.quality!==D?.quality&&m({message:`
|
|
10
10
|
[VIDEO TRACKS ABR]
|