@vkontakte/videoplayer-shared 1.0.38-dev.87754f30.0 → 1.0.38-dev.abb9bed7.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.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @vkontakte/videoplayer-shared v1.0.38-dev.87754f30.0
3
- * Tue, 06 Aug 2024 11:52:24 GMT
2
+ * @vkontakte/videoplayer-shared v1.0.38-dev.abb9bed7.0
3
+ * Mon, 19 Aug 2024 11:00:39 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-38/doc/
5
5
  */
6
- "use strict";var Q=Object.defineProperty,dt=Object.defineProperties,ft=Object.getOwnPropertyDescriptor,mt=Object.getOwnPropertyDescriptors,Tt=Object.getOwnPropertyNames,Ie=Object.getOwnPropertySymbols;var he=Object.prototype.hasOwnProperty,vt=Object.prototype.propertyIsEnumerable;var ge=Math.pow,xe=(t,e,r)=>e in t?Q(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,w=(t,e)=>{for(var r in e||(e={}))he.call(e,r)&&xe(t,r,e[r]);if(Ie)for(var r of Ie(e))vt.call(e,r)&&xe(t,r,e[r]);return t},_=(t,e)=>dt(t,mt(e));var ye=(t,e)=>{for(var r in e)Q(t,r,{get:e[r],enumerable:!0})},It=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Tt(e))!he.call(t,i)&&i!==r&&Q(t,i,{get:()=>e[i],enumerable:!(n=ft(e,i))||n.enumerable});return t};var xt=t=>It(Q({},"__esModule",{value:!0}),t);var D=(t,e,r)=>new Promise((n,i)=>{var s=a=>{try{o(r.next(a))}catch(p){i(p)}},u=a=>{try{o(r.throw(a))}catch(p){i(p)}},o=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,u);o((r=r.apply(t,e)).next())});var Nt={};ye(Nt,{CurrentClientBrowser:()=>H,CurrentClientDevice:()=>K,ErrorCategory:()=>ot,InterfaceLanguage:()=>st,Logger:()=>U,Observable:()=>l,Subject:()=>x,Subscription:()=>m,VERSION:()=>Oe,VKNumericLanguage:()=>it,ValueSubject:()=>k,VideoQuality:()=>z,abortable:()=>Pe,addScript:()=>Ce,areQualitiesExact:()=>Ke,assertEmptyArray:()=>Re,assertNever:()=>I,assertNonNullable:()=>Ee,assertNotEmptyArray:()=>Ae,assertNullable:()=>Se,assertQualityIsExact:()=>$e,buffer:()=>Z,checkNever:()=>we,cloneDeep:()=>Xe,cloneDeepWith:()=>C,combine:()=>Y,debounce:()=>te,debounceFn:()=>G,detectEmbed:()=>Ue,fillWithDefault:()=>Ye,filter:()=>ie,filterChanged:()=>ae,fromEvent:()=>rt,getCurrentBrowser:()=>R,getExponentialDelay:()=>De,getHighestQuality:()=>je,getIOSVersion:()=>Ne,interval:()=>et,isAndroid:()=>Ve,isHigher:()=>Be,isHigherOrEqual:()=>Fe,isIOS:()=>Me,isInvariantQuality:()=>W,isLower:()=>j,isLowerOrEqual:()=>ze,isMacLike:()=>Qe,isMobile:()=>_e,isNonNullable:()=>y,isNullable:()=>B,loadVKLangPack:()=>Lt,map:()=>L,mapTo:()=>ue,merge:()=>X,noop:()=>h,now:()=>Le,observableFrom:()=>tt,observeElementSize:()=>Je,once:()=>ce,pairwise:()=>be,safeStorage:()=>F,tap:()=>fe,throttle:()=>ne,throttleFn:()=>q,timeCodeToString:()=>St,timeout:()=>Ze,videoHeightToQuality:()=>Ge,videoQualityToHeight:()=>He,videoSizeToQuality:()=>qe});module.exports=xt(Nt);var Oe="1.0.38-dev.87754f30.0";var m=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(r=>typeof r=="function"?r():r.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var I=t=>{throw new Error(`${t} is value of unexpected type`)},we=t=>{};var h=()=>{};var l=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,r){var u;let n;r?typeof r=="function"?n={next:r,error:h}:n={next:o=>r.next(o),error:o=>{var a;return(a=r.error)==null?void 0:a.call(r,o)}}:n={next:h,error:h};let i=typeof e=="function"?{next:o=>{try{e(o)}catch(a){n.next(a)}},error:o=>n.next(o)}:{next:o=>e.next(o),error:o=>e.error?e.error(o):n.next(o)},s;try{s=this._subscribe(i)}catch(o){(u=i.error)==null||u.call(i,o)}return new m().add(()=>{switch(i.next=h,i.error=h,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return I(s)}})}pipe(...e){return e.reduce((r,n)=>n(r),this)}_subscribe(e){}};var x=class extends l{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(r){this.subscribers.forEach(n=>n.next(r))}error(r){this.subscribers.forEach(n=>{var i;return(i=n.error)==null?void 0:i.call(n,r)})}_subscribe(r){let n=this.keyCounter++;return this.subscribers.set(n,r),new m().add(()=>this.subscribers.delete(n))}};var U=class{constructor(){this.log$=new x;this.logs=[];this.log=e=>{let r=_(w({},e),{timestamp:Date.now()});this.logs.push(r),this.log$.next(r)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...r)=>{let n;try{n=e(...r)}catch(i){n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(r=>w({component:e},r))}};function Ee(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function Se(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function y(t){return typeof t!="undefined"&&t!==null}function B(t){return t==null}function Ae(t,e){if(!(t!=null&&t.length))throw new Error(e)}function Re(t,e){if(t!=null&&t.length)throw new Error(e)}var Ce=(t,e,r)=>new Promise((n,i)=>{e.addEventListener("abort",()=>{o(),p.remove()});let s=()=>{o(),i()},u=()=>{o(),n()},o=()=>{a&&clearTimeout(a),p.removeEventListener("load",u),p.removeEventListener("error",s)},a;r&&(a=window.setTimeout(s,r));let p=document.createElement("script");p.addEventListener("load",u),p.addEventListener("error",s),p.src=t,document.head.appendChild(p)});var ke,Le=typeof((ke=window.performance)==null?void 0:ke.now)=="function"?()=>window.performance.now():()=>Date.now();var Pe=(t,e)=>(...r)=>D(void 0,null,function*(){var u;let n=e(...r),i=t.aborted,s;for(;!i&&!t.aborted;)try{let o=yield n.next(s);i=(u=o.done)!=null?u:!1,s=o.value}catch(o){yield n.throw(o)}return s});var H=(c=>(c.Unknown="Unknown",c.Yandex="Yandex",c.Chrome="Chrome",c.Chromium="Chromium",c.Firefox="Firefox",c.Safari="Safari",c.Opera="Opera",c.Edge="Edge",c.SamsungBrowser="SamsungBrowser",c.Rest="Rest",c))(H||{}),K=(a=>(a.Unknown="Unknown",a.Android="Android",a.iPhone="iPhone",a.iPad="iPad",a.iPod="iPod",a.RestMobile="RestMobile",a.Mac="Mac",a.Desktop="Desktop",a))(K||{}),R=()=>{let{userAgent:t}=window.navigator,e=/yabrowser/i.test(t)?"Yandex":void 0,r=/samsungbrowser/i.test(t)?"SamsungBrowser":void 0,n=/chrome|crios/i.test(t)?"Chrome":void 0,i=/chromium/i.test(t)?"Chromium":void 0,s=/firefox|fxios/i.test(t)?"Firefox":void 0,u=/webkit|safari|khtml/i.test(t)?"Safari":void 0,o=/opr\//i.test(t)?"Opera":void 0,a=/edg/i.test(t)?"Edge":void 0,p=/android/i.test(t)?"Android":void 0,c=/iphone/i.test(t)?"iPhone":void 0,d=/ipad/i.test(t)?"iPad":void 0,S=/ipod/i.test(t)?"iPod":void 0,P=/mac/i.test(t)?"Mac":void 0,A=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(t)?"RestMobile":void 0;return{browser:e||r||s||o||a||n||i||u||"Rest",device:p||c||d||S||A||P||"Desktop"}},Me=(t=!1)=>{let r=["iPhone","iPad","iPod"].includes(R().device);if(!t)return r;let{userAgent:n,maxTouchPoints:i}=window.navigator;return!!(r||/macintosh/i.test(n)&&i>0)},Ne=()=>{let{userAgent:t}=window.navigator,e=t.match(/Version\/(\d+(\.\d+)?)/i);if(!e)return null;let r=e[1],n=parseFloat(r);return isNaN(n)?null:n},Ve=()=>R().device==="Android",Qe=()=>["Mac","iPhone","iPad","iPod"].includes(R().device),_e=()=>{var t,e;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test((t=navigator.appVersion)!=null?t:navigator.userAgent)||((e=navigator==null?void 0:navigator.userAgentData)==null?void 0:e.mobile)};var De=(t,{start:e=0,factor:r=2,max:n=1/0,min:i=e,random:s=0}={})=>{let u=e;return u*=ge(r,t),u*=1+(Math.random()*s*2-s),u=Math.round(u),u=Math.min(u,n),u=Math.max(u,i),u};var F={};ye(F,{clear:()=>Et,get:()=>gt,has:()=>Ot,isPersistent:()=>ht,remove:()=>wt,set:()=>yt});var f,O,$=`vk-videoplayer-dummy-key-${Math.random()}`,E=()=>{if(O!==void 0)return O;try{localStorage.setItem($,"test"),localStorage.removeItem($),O=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem($),O=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)O=2;else throw e}else throw t}return O===2&&(f=new Map),O},ht=()=>E()===0,gt=t=>{var r,n;let e=E();switch(e){case 0:return(r=localStorage.getItem(t))!=null?r:void 0;case 1:return(n=sessionStorage.getItem(t))!=null?n:void 0;case 2:return f==null?void 0:f.get(t);default:I(e)}},yt=(t,e)=>{let r=E();switch(r){case 0:try{localStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void(f==null?void 0:f.set(t,e));default:I(r)}},Ot=t=>{var r;let e=E();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return(r=f==null?void 0:f.has(t))!=null?r:!1;default:return I(e),!1}},wt=t=>{let e=E();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:return void(f==null?void 0:f.delete(t));default:I(e)}},Et=()=>{let t=E();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return f==null?void 0:f.clear();default:I(t)}};var Ue=()=>{let t,e;try{t=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?t=!0:(t=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let r=e?new URL(e).hostname:void 0;return{isEmbed:t,host:r}};var z=(c=>(c.INVARIANT="Invariant quality",c.Q_144P="144p",c.Q_240P="240p",c.Q_360P="360p",c.Q_480P="480p",c.Q_720P="720p",c.Q_1080P="1080p",c.Q_1440P="1440p",c.Q_2160P="2160p",c.Q_4320P="4320p",c))(z||{});var T={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"720p":{width:1280,height:720},"1080p":{width:1920,height:1080},"1440p":{width:2560,height:1440},"2160p":{width:3840,height:2160},"4320p":{width:7680,height:4320}},Be=(t,e)=>T[t].height>T[e].height,Fe=(t,e)=>T[t].height>=T[e].height,j=(t,e)=>T[t].height<T[e].height,ze=(t,e)=>T[t].height<=T[e].height,je=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:j(e,r)?1:-1)[0],We=Object.keys(T).sort((t,e)=>j(t,e)?-1:1),Ge=(t,e=.02)=>[...We].find(n=>T[n].height*(1+e)>=t),qe=({width:t,height:e})=>{let r=Math.min(t,e),n=Math.max(t,e);return We.find(i=>{let s=T[i];return s.width>=n&&s.height>=r})},He=t=>T[t].height,W=t=>t==="Invariant quality",Ke=t=>t.every(e=>!W(e));function $e(t){if(W(t))throw new Error("Expected exact quality")}var Ye=(t,e)=>{let r={};for(let n of Object.keys(e)){let i=e[n],s=t[n];Array.isArray(i)&&Array.isArray(s)?r[n]=s:typeof i=="object"&&typeof s=="object"?r[n]=Ye(s,i):r[n]=n in t?s:i}return r};var St=t=>{let e="";return t>=3600&&(e+=Math.floor(t/3600)+"h",t=t%3600),t>=60&&(e+=Math.floor(t/60)+"m",t=t%60),t>0&&(e+=Math.floor(t)+"s"),e};function G(t,e=0,r){let n,i,s,u,o,a,p=0,c=!1,d=!1,S=!0,P=!e&&e!==0&&typeof window.requestAnimationFrame=="function";r&&(c=!!r.leading,d="maxWait"in r,s=r!=null&&r.maxWait?Math.max(+(r==null?void 0:r.maxWait)||0,e):s,S="trailing"in r?!!r.trailing:S);function A(b){let v=n,g=i;return n=i=void 0,p=b,u=t.apply(g,v),u}function M(b,v){return P?(o&&window.cancelAnimationFrame(o),window.requestAnimationFrame(b)):setTimeout(b,v)}function at(b){if(P){window.cancelAnimationFrame(b);return}clearTimeout(b)}function lt(b){return p=b,o=M(N,e),c?A(b):u}function ut(b){let v=b-a,g=b-p,ve=e-v;return d?Math.min(ve,s-g):ve}function me(b){let v=b-a,g=b-p;return a===void 0||v>=e||v<0||d&&g>=s}function N(){let b=Date.now();if(me(b))return Te(b);o=M(N,ut(b))}function Te(b){return o=void 0,S&&n?A(b):(n=i=void 0,u)}function ct(){o!==void 0&&at(o),p=0,n=a=i=o=void 0}function pt(){return o===void 0?u:Te(Date.now())}function bt(){return o!==void 0}function V(...b){let v=Date.now(),g=me(v);if(n=b,i=this,a=v,g){if(o===void 0)return lt(a);if(d)return o=M(N,e),A(a)}return o===void 0&&(o=M(N,e)),u}return V.cancel=ct,V.flush=pt,V.pending=bt,V}var q=(t,e=0,r)=>G(t,e,_(w(w({},{leading:!0,trailing:!0}),r),{maxWait:e}));var C=(t,e)=>{if(t===null||typeof t!="object")return t;let r=Array.isArray(t)?[]:{};for(let n in t){if(typeof e=="function"){let i=e(t[n],n,t,r);if(i!==void 0){r[n]=i;continue}}typeof t[n]=="object"?r[n]=C(t[n],e):r[n]=t[n]}return r};var Xe=t=>C(t);var At=300,Je=(t,e=At)=>new l(r=>{let{width:n,height:i}=t.getBoundingClientRect();if(r.next({width:n,height:i}),!window.ResizeObserver)return;let s=new ResizeObserver(q(u=>{let o=u[0];if(!o)return;let a,p;o.contentBoxSize&&o.contentBoxSize[0]?(p=o.contentBoxSize[0].blockSize,a=o.contentBoxSize[0].inlineSize):o.contentRect&&(a=o.contentRect.width,p=o.contentRect.height),y(a)&&y(p)&&r.next({width:a,height:p})},e));return s.observe(t),()=>s.disconnect()});var k=class extends x{constructor(r){super();this.value=r}next(r){super.next(this.value=r)}error(r){super.error(this.value=r)}getValue(){return this.value}_subscribe(r){let n=super._subscribe(r);return r.next(this.value),n}};function Y(t){return new l(e=>{let r={},n=Object.keys(t).length,i=s=>u=>{s in r||n--,r[s]=u,n===0&&e.next(r)};return Object.entries(t).reduce((s,[u,o])=>s.add(o.subscribe(i(u))),new m)})}function X(...t){return new l(e=>t.reduce((r,n)=>r.add(n.subscribe(e)),new m))}var Ze=t=>new l(e=>{let r=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},t);return()=>window.clearTimeout(r)});var et=t=>new l(e=>{let r=window.setInterval(()=>e.next(),t);return()=>{r&&(window.clearInterval(r),r=void 0)}});var tt=t=>new l(e=>{t.forEach(r=>e.next(r))});var rt=(t,e)=>new l(r=>{let n=i=>r.next(i);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)});function Z(t){return e=>new l(r=>e.subscribe(new J(r,t)))}var J=class{constructor(e,r){this.destination=e;this.size=r;this.lastValues=[]}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};var Rt={leading:!1,trailing:!0};function te(t,e=Rt){return r=>new l(n=>r.subscribe(new ee(n,t,e)))}var ee=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,y(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(r){if(this.destination.error)this.destination.error(r);else throw r}this.timeout=void 0},this.time)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};var Ct={leading:!0,trailing:!1};function ne(t,e=Ct){return r=>new l(n=>r.subscribe(new re(n,t,e)))}var re=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,B(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function ie(t){return e=>new l(r=>e.subscribe(new oe(r,t)))}var oe=class{constructor(e,r){this.destination=e;this.predicate=r}next(e){let r;try{r=this.predicate(e)}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function ae(t=(e,r)=>e===r){return e=>new l(r=>e.subscribe(new se(r,t)))}var nt={},se=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=nt}next(e){let r;try{r=this.lastValue===nt||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function L(t){return e=>new l(r=>e.subscribe(new le(r,t)))}var le=class{constructor(e,r){this.destination=e;this.mapper=r}next(e){let r;try{r=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(r)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function ue(t){return L(()=>t)}function ce(){return t=>new l(e=>{let r=!1,n=!1,i=t.subscribe(s=>{r||(r=!0,e.next(s)),n&&i.unsubscribe()},s=>{var u;r=!0,(u=e.error)==null||u.call(e,s),n&&i.unsubscribe()});return n=!0,r&&i.unsubscribe(),i})}function be(){return t=>new l(e=>t.subscribe(new pe(e)))}var pe=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let r=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([r,e])}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function fe(t){return e=>new l(r=>e.subscribe(new de(r,t)))}var de=class{constructor(e,r){this.destination=e;this.effect=r}next(e){try{this.effect(e)}catch(r){throw this.error(r),r}this.destination.next(e)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};var ot=(o=>(o.NETWORK="network",o.VIDEO_PIPELINE="video_pipeline",o.EXTERNAL_API="external_api",o.PARSER="parser",o.DOM="dom",o.WTF="wtf",o.FATAL="fatal",o))(ot||{});var it=(d=>(d.Armenian="58",d.Azerbaijani="57",d.Belarusian="114",d.English="3",d.Kazakh="97",d.Portuguese="73",d.Russian="0",d.Spanish="4",d.Ukrainian="1",d.Uzbek="65",d.Vietnamese="75",d))(it||{}),kt="vk.com",Lt=(t,e,r)=>D(void 0,null,function*(){let n=new URL(`https://${kt}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),t!==void 0&&n.searchParams.set("lang",t);let s=yield(yield fetch(n.toString())).json();return Pt(s,r)}),Pt=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,n])=>[r.substring(`${e}_`.length),Mt(n)])),Mt=t=>Array.isArray(t)?t[0]:t;var st=(r=>(r.RU="ru",r.EN="en",r))(st||{});
6
+ "use strict";var L=Object.defineProperty,ct=Object.defineProperties,ut=Object.getOwnPropertyDescriptor,pt=Object.getOwnPropertyDescriptors,bt=Object.getOwnPropertyNames,ve=Object.getOwnPropertySymbols;var Ie=Object.prototype.hasOwnProperty,dt=Object.prototype.propertyIsEnumerable;var xe=Math.pow,he=(r,e,t)=>e in r?L(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,w=(r,e)=>{for(var t in e||(e={}))Ie.call(e,t)&&he(r,t,e[t]);if(ve)for(var t of ve(e))dt.call(e,t)&&he(r,t,e[t]);return r},M=(r,e)=>ct(r,pt(e));var ge=(r,e)=>{for(var t in e)L(r,t,{get:e[t],enumerable:!0})},ft=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of bt(e))!Ie.call(r,i)&&i!==t&&L(r,i,{get:()=>e[i],enumerable:!(n=ut(e,i))||n.enumerable});return r};var mt=r=>ft(L({},"__esModule",{value:!0}),r);var V=(r,e,t)=>new Promise((n,i)=>{var s=c=>{try{o(t.next(c))}catch(u){i(u)}},a=c=>{try{o(t.throw(c))}catch(u){i(u)}},o=c=>c.done?n(c.value):Promise.resolve(c.value).then(s,a);o((t=t.apply(r,e)).next())});var Ct={};ge(Ct,{ErrorCategory:()=>et,InterfaceLanguage:()=>rt,Logger:()=>_,Observable:()=>l,Subject:()=>I,Subscription:()=>m,VERSION:()=>ye,VKNumericLanguage:()=>tt,ValueSubject:()=>R,VideoQuality:()=>D,abortable:()=>Pe,addScript:()=>Ae,areQualitiesExact:()=>je,assertEmptyArray:()=>Re,assertNever:()=>h,assertNonNullable:()=>we,assertNotEmptyArray:()=>Se,assertNullable:()=>Ee,assertQualityIsExact:()=>We,buffer:()=>X,checkNever:()=>Oe,clearVideoElement:()=>Ke,clientChecker:()=>Le,cloneDeep:()=>He,cloneDeepWith:()=>S,combine:()=>K,debounce:()=>Z,debounceFn:()=>F,detectEmbed:()=>Ve,fillWithDefault:()=>Ge,filter:()=>ne,filterChanged:()=>oe,fromEvent:()=>Je,getExponentialDelay:()=>Me,getHighestQuality:()=>De,interval:()=>$e,isHigher:()=>_e,isHigherOrEqual:()=>Ne,isInvariantQuality:()=>B,isLower:()=>U,isLowerOrEqual:()=>Qe,isMobile:()=>H,isNonNullable:()=>y,isNullable:()=>N,loadVKLangPack:()=>Rt,map:()=>A,mapTo:()=>ae,merge:()=>Y,noop:()=>x,now:()=>Ce,observableFrom:()=>Xe,observeElementSize:()=>qe,once:()=>le,pairwise:()=>ue,safeStorage:()=>Q,tap:()=>be,throttle:()=>te,throttleFn:()=>z,timeCodeToString:()=>yt,timeout:()=>Ye,videoHeightToQuality:()=>Be,videoQualityToHeight:()=>ze,videoSizeToQuality:()=>Fe});module.exports=mt(Ct);var ye="1.0.38-dev.abb9bed7.0";var m=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(t=>typeof t=="function"?t():t.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var h=r=>{throw new Error(`${r} is value of unexpected type`)},Oe=r=>{};var x=()=>{};var l=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,t){var a;let n;t?typeof t=="function"?n={next:t,error:x}:n={next:o=>t.next(o),error:o=>{var c;return(c=t.error)==null?void 0:c.call(t,o)}}:n={next:x,error:x};let i=typeof e=="function"?{next:o=>{try{e(o)}catch(c){n.next(c)}},error:o=>n.next(o)}:{next:o=>e.next(o),error:o=>e.error?e.error(o):n.next(o)},s;try{s=this._subscribe(i)}catch(o){(a=i.error)==null||a.call(i,o)}return new m().add(()=>{switch(i.next=x,i.error=x,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return h(s)}})}pipe(...e){return e.reduce((t,n)=>n(t),this)}_subscribe(e){}};var I=class extends l{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(t){this.subscribers.forEach(n=>n.next(t))}error(t){this.subscribers.forEach(n=>{var i;return(i=n.error)==null?void 0:i.call(n,t)})}_subscribe(t){let n=this.keyCounter++;return this.subscribers.set(n,t),new m().add(()=>this.subscribers.delete(n))}};var _=class{constructor(){this.log$=new I;this.logs=[];this.log=e=>{let t=M(w({},e),{timestamp:Date.now()});this.logs.push(t),this.log$.next(t)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...t)=>{let n;try{n=e(...t)}catch(i){n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(t=>w({component:e},t))}};function we(r,e='Assertion "value is not nullable" failed'){if(r==null)throw new Error(e)}function Ee(r,e='Assertion "value is nullable" failed'){if(r!=null)throw new Error(e)}function y(r){return typeof r!="undefined"&&r!==null}function N(r){return r==null}function Se(r,e){if(!(r!=null&&r.length))throw new Error(e)}function Re(r,e){if(r!=null&&r.length)throw new Error(e)}var Ae=(r,e,t)=>new Promise((n,i)=>{e.addEventListener("abort",()=>{o(),u.remove()});let s=()=>{o(),i()},a=()=>{o(),n()},o=()=>{c&&clearTimeout(c),u.removeEventListener("load",a),u.removeEventListener("error",s)},c;t&&(c=window.setTimeout(s,t));let u=document.createElement("script");u.addEventListener("load",a),u.addEventListener("error",s),u.src=r,document.head.appendChild(u)});var ke,Ce=typeof((ke=window.performance)==null?void 0:ke.now)=="function"?()=>window.performance.now():()=>Date.now();var Pe=(r,e)=>(...t)=>V(void 0,null,function*(){var a;let n=e(...t),i=r.aborted,s;for(;!i&&!r.aborted;)try{let o=yield n.next(s);i=(a=o.done)!=null?a:!1,s=o.value}catch(o){yield n.throw(o)}return s});var H=()=>{var r,e;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test((r=navigator.appVersion)!=null?r:navigator.userAgent)||((e=navigator==null?void 0:navigator.userAgentData)==null?void 0:e.mobile)},G=class{constructor(){this.detect()}get browser(){return this._currentBrowser}get device(){return this._currentDevice}get isTouch(){return this._maxTouchPoints>0}get isIOS(){return["iPhone","iPad","iPod"].includes(this.device)}get isMac(){return this.device==="Mac"}get isApple(){return this.isIOS||this.isMac}get isIphoneOrOldIpad(){if(!this.isApple||!this.isTouch)return!1;let e=this.device==="iPad"||(window==null?void 0:window.screen.width)>700,t=this._iosVersion;return!e||e&&!!t&&t<16}get isAndroid(){return this.device==="Android"}get isMobile(){return this._isMobile}get iOSVersion(){return this._iosVersion}get macVersion(){return this._macVersion}get isYandex(){return this.browser==="Yandex"}get isSafari(){return this.browser==="Safari"}get isSamsungBrowser(){return this.browser==="SamsungBrowser"}get isHDR(){return this._isHdr}detect(){var n;let{userAgent:e,maxTouchPoints:t}=navigator;try{this._maxTouchPoints=t,this._isHdr=!!((n=matchMedia("(dynamic-range: high)"))!=null&&n.matches)}catch(i){console.error(i)}try{this._isMobile=H()}catch(i){console.error(i)}this.detectBrowser(e),this.detectDevice(e),this.isIOS&&this.detectIOSVersion(),this.isMac&&this.detectMacVersion()}detectBrowser(e){try{let t=/yabrowser/i.test(e)?"Yandex":void 0,n=/samsungbrowser/i.test(e)?"SamsungBrowser":void 0,i=/chrome|crios/i.test(e)?"Chrome":void 0,s=/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,c=/opr\//i.test(e)?"Opera":void 0,u=/edg/i.test(e)?"Edge":void 0;this._currentBrowser=t||n||a||c||u||i||s||o||"Rest"}catch(t){console.error(t)}}detectDevice(e){try{let t=/android/i.test(e)?"Android":void 0,n=/iphone/i.test(e)?"iPhone":void 0,i=/ipad/i.test(e)?"iPad":void 0,s=/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._currentDevice=t||n||i||s||o||a||"Desktop"}catch(t){console.error(t)}}detectIOSVersion(){try{let{userAgent:e}=window.navigator,t=e.match(/Version\/(\d+(\.\d+)?)/i);if(!t)return;let n=t[1],i=parseFloat(n);if(isNaN(i))return;this._iosVersion=i}catch(e){console.error(e)}}detectMacVersion(){try{let{userAgent:e}=window.navigator,t=e.match(/Version\/(\d+)/);if(!t)return;let n=t[1],i=parseInt(n,10);if(isNaN(i))return;this._macVersion=i}catch(e){console.error(e)}}},Le=new G;var Me=(r,{start:e=0,factor:t=2,max:n=1/0,min:i=e,random:s=0}={})=>{let a=e;return a*=xe(t,r),a*=1+(Math.random()*s*2-s),a=Math.round(a),a=Math.min(a,n),a=Math.max(a,i),a};var Q={};ge(Q,{clear:()=>gt,get:()=>vt,has:()=>It,isPersistent:()=>Tt,remove:()=>xt,set:()=>ht});var d,O,q=`vk-videoplayer-dummy-key-${Math.random()}`,E=()=>{if(O!==void 0)return O;try{localStorage.setItem(q,"test"),localStorage.removeItem(q),O=0}catch(r){if(r instanceof DOMException||r instanceof TypeError)try{sessionStorage.getItem(q),O=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)O=2;else throw e}else throw r}return O===2&&(d=new Map),O},Tt=()=>E()===0,vt=r=>{var t,n;let e=E();switch(e){case 0:return(t=localStorage.getItem(r))!=null?t:void 0;case 1:return(n=sessionStorage.getItem(r))!=null?n:void 0;case 2:return d==null?void 0:d.get(r);default:h(e)}},ht=(r,e)=>{let t=E();switch(t){case 0:try{localStorage.setItem(r,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(r,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void(d==null?void 0:d.set(r,e));default:h(t)}},It=r=>{var t;let e=E();switch(e){case 0:return r in localStorage;case 1:return r in sessionStorage;case 2:return(t=d==null?void 0:d.has(r))!=null?t:!1;default:return h(e),!1}},xt=r=>{let e=E();switch(e){case 0:return localStorage.removeItem(r);case 1:return sessionStorage.removeItem(r);case 2:return void(d==null?void 0:d.delete(r));default:h(e)}},gt=()=>{let r=E();switch(r){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return d==null?void 0:d.clear();default:h(r)}};var Ve=()=>{let r,e;try{r=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?r=!0:(r=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let t=e?new URL(e).hostname:void 0;return{isEmbed:r,host:t}};var D=(f=>(f.INVARIANT="Invariant quality",f.Q_144P="144p",f.Q_240P="240p",f.Q_360P="360p",f.Q_480P="480p",f.Q_720P="720p",f.Q_1080P="1080p",f.Q_1440P="1440p",f.Q_2160P="2160p",f.Q_4320P="4320p",f))(D||{});var T={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"720p":{width:1280,height:720},"1080p":{width:1920,height:1080},"1440p":{width:2560,height:1440},"2160p":{width:3840,height:2160},"4320p":{width:7680,height:4320}},_e=(r,e)=>T[r].height>T[e].height,Ne=(r,e)=>T[r].height>=T[e].height,U=(r,e)=>T[r].height<T[e].height,Qe=(r,e)=>T[r].height<=T[e].height,De=r=>r.sort((e,t)=>e===t?0:e==="Invariant quality"?1:t==="Invariant quality"?-1:U(e,t)?1:-1)[0],Ue=Object.keys(T).sort((r,e)=>U(r,e)?-1:1),Be=(r,e=.02)=>[...Ue].find(n=>T[n].height*(1+e)>=r),Fe=({width:r,height:e})=>{let t=Math.min(r,e),n=Math.max(r,e);return Ue.find(i=>{let s=T[i];return s.width>=n&&s.height>=t})},ze=r=>T[r].height,B=r=>r==="Invariant quality",je=r=>r.every(e=>!B(e));function We(r){if(B(r))throw new Error("Expected exact quality")}var Ge=(r,e)=>{let t={};for(let n of Object.keys(e)){let i=e[n],s=r[n];Array.isArray(i)&&Array.isArray(s)?t[n]=s:typeof i=="object"&&typeof s=="object"?t[n]=Ge(s,i):t[n]=n in r?s:i}return t};var yt=r=>{let e="";return r>=3600&&(e+=Math.floor(r/3600)+"h",r=r%3600),r>=60&&(e+=Math.floor(r/60)+"m",r=r%60),r>0&&(e+=Math.floor(r)+"s"),e};function F(r,e=0,t){let n,i,s,a,o,c,u=0,f=!1,b=!1,j=!0,de=!e&&e!==0&&typeof window.requestAnimationFrame=="function";t&&(f=!!t.leading,b="maxWait"in t,s=t!=null&&t.maxWait?Math.max(+(t==null?void 0:t.maxWait)||0,e):s,j="trailing"in t?!!t.trailing:j);function W(p){let v=n,g=i;return n=i=void 0,u=p,a=r.apply(g,v),a}function k(p,v){return de?(o&&window.cancelAnimationFrame(o),window.requestAnimationFrame(p)):setTimeout(p,v)}function nt(p){if(de){window.cancelAnimationFrame(p);return}clearTimeout(p)}function it(p){return u=p,o=k(C,e),f?W(p):a}function ot(p){let v=p-c,g=p-u,Te=e-v;return b?Math.min(Te,s-g):Te}function fe(p){let v=p-c,g=p-u;return c===void 0||v>=e||v<0||b&&g>=s}function C(){let p=Date.now();if(fe(p))return me(p);o=k(C,ot(p))}function me(p){return o=void 0,j&&n?W(p):(n=i=void 0,a)}function st(){o!==void 0&&nt(o),u=0,n=c=i=o=void 0}function at(){return o===void 0?a:me(Date.now())}function lt(){return o!==void 0}function P(...p){let v=Date.now(),g=fe(v);if(n=p,i=this,c=v,g){if(o===void 0)return it(c);if(b)return o=k(C,e),W(c)}return o===void 0&&(o=k(C,e)),a}return P.cancel=st,P.flush=at,P.pending=lt,P}var z=(r,e=0,t)=>F(r,e,M(w(w({},{leading:!0,trailing:!0}),t),{maxWait:e}));var S=(r,e)=>{if(r===null||typeof r!="object")return r;let t=Array.isArray(r)?[]:{};for(let n in r){if(typeof e=="function"){let i=e(r[n],n,r,t);if(i!==void 0){t[n]=i;continue}}typeof r[n]=="object"?t[n]=S(r[n],e):t[n]=r[n]}return t};var He=r=>S(r);var Ot=300,qe=(r,e=Ot)=>new l(t=>{let{width:n,height:i}=r.getBoundingClientRect();if(t.next({width:n,height:i}),!window.ResizeObserver)return;let s=new ResizeObserver(z(a=>{let o=a[0];if(!o)return;let c,u;o.contentBoxSize&&o.contentBoxSize[0]?(u=o.contentBoxSize[0].blockSize,c=o.contentBoxSize[0].inlineSize):o.contentRect&&(c=o.contentRect.width,u=o.contentRect.height),y(c)&&y(u)&&t.next({width:c,height:u})},e));return s.observe(r),()=>s.disconnect()});var Ke=r=>{r.removeAttribute("src"),r.load()};var R=class extends I{constructor(e){super(),this.value=e}next(e){super.next(this.value=e)}error(e){super.error(this.value=e)}getValue(){return this.value}_subscribe(e){let t=super._subscribe(e);return e.next(this.value),t}};function K(r){return new l(e=>{let t={},n=Object.keys(r).length,i=s=>a=>{s in t||n--,t[s]=a,n===0&&e.next(t)};return Object.entries(r).reduce((s,[a,o])=>s.add(o.subscribe(i(a))),new m)})}function Y(...r){return new l(e=>r.reduce((t,n)=>t.add(n.subscribe(e)),new m))}var Ye=r=>new l(e=>{let t=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},r);return()=>window.clearTimeout(t)});var $e=r=>new l(e=>{let t=window.setInterval(()=>e.next(),r);return()=>{t&&(window.clearInterval(t),t=void 0)}});var Xe=r=>new l(e=>{r.forEach(t=>e.next(t))});var Je=(r,e)=>new l(t=>{let n=i=>t.next(i);return r.addEventListener(e,n),()=>r.removeEventListener(e,n)});function X(r){return e=>new l(t=>e.subscribe(new $(t,r)))}var $=class{constructor(e,t){this.destination=e;this.size=t;this.lastValues=[]}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};var wt={leading:!1,trailing:!0};function Z(r,e=wt){return t=>new l(n=>t.subscribe(new J(n,r,e)))}var J=class{constructor(e,t,n){this.destination=e;this.time=t;this.config=n}next(e){this.lastValue=e,y(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(t){if(this.destination.error)this.destination.error(t);else throw t}this.timeout=void 0},this.time)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};var Et={leading:!0,trailing:!1};function te(r,e=Et){return t=>new l(n=>t.subscribe(new ee(n,r,e)))}var ee=class{constructor(e,t,n){this.destination=e;this.time=t;this.config=n}next(e){this.lastValue=e,N(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function ne(r){return e=>new l(t=>e.subscribe(new re(t,r)))}var re=class{constructor(e,t){this.destination=e;this.predicate=t}next(e){let t;try{t=this.predicate(e)}catch(n){throw this.error(n),n}t&&this.destination.next(e)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function oe(r=(e,t)=>e===t){return e=>new l(t=>e.subscribe(new ie(t,r)))}var Ze={},ie=class{constructor(e,t){this.destination=e;this.predicate=t;this.lastValue=Ze}next(e){let t;try{t=this.lastValue===Ze||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}t&&this.destination.next(e)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function A(r){return e=>new l(t=>e.subscribe(new se(t,r)))}var se=class{constructor(e,t){this.destination=e;this.mapper=t}next(e){let t;try{t=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(t)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function ae(r){return A(()=>r)}function le(){return r=>new l(e=>{let t=!1,n=!1,i=r.subscribe(s=>{t||(t=!0,e.next(s)),n&&i.unsubscribe()},s=>{var a;t=!0,(a=e.error)==null||a.call(e,s),n&&i.unsubscribe()});return n=!0,t&&i.unsubscribe(),i})}function ue(){return r=>new l(e=>r.subscribe(new ce(e)))}var ce=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let t=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([t,e])}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function be(r){return e=>new l(t=>e.subscribe(new pe(t,r)))}var pe=class{constructor(e,t){this.destination=e;this.effect=t}next(e){try{this.effect(e)}catch(t){throw this.error(t),t}this.destination.next(e)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};var et=(o=>(o.NETWORK="network",o.VIDEO_PIPELINE="video_pipeline",o.EXTERNAL_API="external_api",o.PARSER="parser",o.DOM="dom",o.WTF="wtf",o.FATAL="fatal",o))(et||{});var tt=(b=>(b.Armenian="58",b.Azerbaijani="57",b.Belarusian="114",b.English="3",b.Kazakh="97",b.Portuguese="73",b.Russian="0",b.Spanish="4",b.Ukrainian="1",b.Uzbek="65",b.Vietnamese="75",b))(tt||{}),St="vk.com",Rt=(r,e,t)=>V(void 0,null,function*(){let n=new URL(`https://${St}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),r!==void 0&&n.searchParams.set("lang",r);let s=yield(yield fetch(n.toString())).json();return At(s,t)}),At=(r,e)=>Object.fromEntries(Object.entries(r.keys).map(([t,n])=>[t.substring(`${e}_`.length),kt(n)])),kt=r=>Array.isArray(r)?r[0]:r;var rt=(t=>(t.RU="ru",t.EN="en",t))(rt||{});
package/es2015.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @vkontakte/videoplayer-shared v1.0.38-dev.87754f30.0
3
- * Tue, 06 Aug 2024 11:52:24 GMT
2
+ * @vkontakte/videoplayer-shared v1.0.38-dev.abb9bed7.0
3
+ * Mon, 19 Aug 2024 11:00:39 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-38/doc/
5
5
  */
6
- var se=Object.defineProperty,ke=Object.defineProperties;var Le=Object.getOwnPropertyDescriptors;var oe=Object.getOwnPropertySymbols;var Pe=Object.prototype.hasOwnProperty,Me=Object.prototype.propertyIsEnumerable;var ae=Math.pow,ie=(t,e,r)=>e in t?se(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,O=(t,e)=>{for(var r in e||(e={}))Pe.call(e,r)&&ie(t,r,e[r]);if(oe)for(var r of oe(e))Me.call(e,r)&&ie(t,r,e[r]);return t},P=(t,e)=>ke(t,Le(e));var Ne=(t,e)=>{for(var r in e)se(t,r,{get:e[r],enumerable:!0})};var M=(t,e,r)=>new Promise((n,i)=>{var s=a=>{try{o(r.next(a))}catch(p){i(p)}},l=a=>{try{o(r.throw(a))}catch(p){i(p)}},o=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,l);o((r=r.apply(t,e)).next())});var Ve="1.0.38-dev.87754f30.0";var m=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(r=>typeof r=="function"?r():r.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var I=t=>{throw new Error(`${t} is value of unexpected type`)},Qe=t=>{};var g=()=>{};var u=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,r){var l;let n;r?typeof r=="function"?n={next:r,error:g}:n={next:o=>r.next(o),error:o=>{var a;return(a=r.error)==null?void 0:a.call(r,o)}}:n={next:g,error:g};let i=typeof e=="function"?{next:o=>{try{e(o)}catch(a){n.next(a)}},error:o=>n.next(o)}:{next:o=>e.next(o),error:o=>e.error?e.error(o):n.next(o)},s;try{s=this._subscribe(i)}catch(o){(l=i.error)==null||l.call(i,o)}return new m().add(()=>{switch(i.next=g,i.error=g,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return I(s)}})}pipe(...e){return e.reduce((r,n)=>n(r),this)}_subscribe(e){}};var x=class extends u{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(r){this.subscribers.forEach(n=>n.next(r))}error(r){this.subscribers.forEach(n=>{var i;return(i=n.error)==null?void 0:i.call(n,r)})}_subscribe(r){let n=this.keyCounter++;return this.subscribers.set(n,r),new m().add(()=>this.subscribers.delete(n))}};var D=class{constructor(){this.log$=new x;this.logs=[];this.log=e=>{let r=P(O({},e),{timestamp:Date.now()});this.logs.push(r),this.log$.next(r)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...r)=>{let n;try{n=e(...r)}catch(i){n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(r=>O({component:e},r))}};function _e(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function De(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function w(t){return typeof t!="undefined"&&t!==null}function U(t){return t==null}function Ue(t,e){if(!(t!=null&&t.length))throw new Error(e)}function Be(t,e){if(t!=null&&t.length)throw new Error(e)}var Fe=(t,e,r)=>new Promise((n,i)=>{e.addEventListener("abort",()=>{o(),p.remove()});let s=()=>{o(),i()},l=()=>{o(),n()},o=()=>{a&&clearTimeout(a),p.removeEventListener("load",l),p.removeEventListener("error",s)},a;r&&(a=window.setTimeout(s,r));let p=document.createElement("script");p.addEventListener("load",l),p.addEventListener("error",s),p.src=t,document.head.appendChild(p)});var le,ze=typeof((le=window.performance)==null?void 0:le.now)=="function"?()=>window.performance.now():()=>Date.now();var je=(t,e)=>(...r)=>M(void 0,null,function*(){var l;let n=e(...r),i=t.aborted,s;for(;!i&&!t.aborted;)try{let o=yield n.next(s);i=(l=o.done)!=null?l:!1,s=o.value}catch(o){yield n.throw(o)}return s});var ue=(c=>(c.Unknown="Unknown",c.Yandex="Yandex",c.Chrome="Chrome",c.Chromium="Chromium",c.Firefox="Firefox",c.Safari="Safari",c.Opera="Opera",c.Edge="Edge",c.SamsungBrowser="SamsungBrowser",c.Rest="Rest",c))(ue||{}),ce=(a=>(a.Unknown="Unknown",a.Android="Android",a.iPhone="iPhone",a.iPad="iPad",a.iPod="iPod",a.RestMobile="RestMobile",a.Mac="Mac",a.Desktop="Desktop",a))(ce||{}),N=()=>{let{userAgent:t}=window.navigator,e=/yabrowser/i.test(t)?"Yandex":void 0,r=/samsungbrowser/i.test(t)?"SamsungBrowser":void 0,n=/chrome|crios/i.test(t)?"Chrome":void 0,i=/chromium/i.test(t)?"Chromium":void 0,s=/firefox|fxios/i.test(t)?"Firefox":void 0,l=/webkit|safari|khtml/i.test(t)?"Safari":void 0,o=/opr\//i.test(t)?"Opera":void 0,a=/edg/i.test(t)?"Edge":void 0,p=/android/i.test(t)?"Android":void 0,c=/iphone/i.test(t)?"iPhone":void 0,d=/ipad/i.test(t)?"iPad":void 0,S=/ipod/i.test(t)?"iPod":void 0,R=/mac/i.test(t)?"Mac":void 0,A=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(t)?"RestMobile":void 0;return{browser:e||r||s||o||a||n||i||l||"Rest",device:p||c||d||S||A||R||"Desktop"}},We=(t=!1)=>{let r=["iPhone","iPad","iPod"].includes(N().device);if(!t)return r;let{userAgent:n,maxTouchPoints:i}=window.navigator;return!!(r||/macintosh/i.test(n)&&i>0)},Ge=()=>{let{userAgent:t}=window.navigator,e=t.match(/Version\/(\d+(\.\d+)?)/i);if(!e)return null;let r=e[1],n=parseFloat(r);return isNaN(n)?null:n},qe=()=>N().device==="Android",He=()=>["Mac","iPhone","iPad","iPod"].includes(N().device),Ke=()=>{var t,e;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test((t=navigator.appVersion)!=null?t:navigator.userAgent)||((e=navigator==null?void 0:navigator.userAgentData)==null?void 0:e.mobile)};var $e=(t,{start:e=0,factor:r=2,max:n=1/0,min:i=e,random:s=0}={})=>{let l=e;return l*=ae(r,t),l*=1+(Math.random()*s*2-s),l=Math.round(l),l=Math.min(l,n),l=Math.max(l,i),l};var F={};Ne(F,{clear:()=>tt,get:()=>Xe,has:()=>Ze,isPersistent:()=>Ye,remove:()=>et,set:()=>Je});var f,y,B=`vk-videoplayer-dummy-key-${Math.random()}`,E=()=>{if(y!==void 0)return y;try{localStorage.setItem(B,"test"),localStorage.removeItem(B),y=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem(B),y=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)y=2;else throw e}else throw t}return y===2&&(f=new Map),y},Ye=()=>E()===0,Xe=t=>{var r,n;let e=E();switch(e){case 0:return(r=localStorage.getItem(t))!=null?r:void 0;case 1:return(n=sessionStorage.getItem(t))!=null?n:void 0;case 2:return f==null?void 0:f.get(t);default:I(e)}},Je=(t,e)=>{let r=E();switch(r){case 0:try{localStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void(f==null?void 0:f.set(t,e));default:I(r)}},Ze=t=>{var r;let e=E();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return(r=f==null?void 0:f.has(t))!=null?r:!1;default:return I(e),!1}},et=t=>{let e=E();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:return void(f==null?void 0:f.delete(t));default:I(e)}},tt=()=>{let t=E();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return f==null?void 0:f.clear();default:I(t)}};var rt=()=>{let t,e;try{t=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?t=!0:(t=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let r=e?new URL(e).hostname:void 0;return{isEmbed:t,host:r}};var z=(c=>(c.INVARIANT="Invariant quality",c.Q_144P="144p",c.Q_240P="240p",c.Q_360P="360p",c.Q_480P="480p",c.Q_720P="720p",c.Q_1080P="1080p",c.Q_1440P="1440p",c.Q_2160P="2160p",c.Q_4320P="4320p",c))(z||{});var T={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"720p":{width:1280,height:720},"1080p":{width:1920,height:1080},"1440p":{width:2560,height:1440},"2160p":{width:3840,height:2160},"4320p":{width:7680,height:4320}},nt=(t,e)=>T[t].height>T[e].height,ot=(t,e)=>T[t].height>=T[e].height,j=(t,e)=>T[t].height<T[e].height,it=(t,e)=>T[t].height<=T[e].height,st=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:j(e,r)?1:-1)[0],pe=Object.keys(T).sort((t,e)=>j(t,e)?-1:1),at=(t,e=.02)=>[...pe].find(n=>T[n].height*(1+e)>=t),lt=({width:t,height:e})=>{let r=Math.min(t,e),n=Math.max(t,e);return pe.find(i=>{let s=T[i];return s.width>=n&&s.height>=r})},ut=t=>T[t].height,W=t=>t==="Invariant quality",ct=t=>t.every(e=>!W(e));function pt(t){if(W(t))throw new Error("Expected exact quality")}var bt=(t,e)=>{let r={};for(let n of Object.keys(e)){let i=e[n],s=t[n];Array.isArray(i)&&Array.isArray(s)?r[n]=s:typeof i=="object"&&typeof s=="object"?r[n]=bt(s,i):r[n]=n in t?s:i}return r};var sr=t=>{let e="";return t>=3600&&(e+=Math.floor(t/3600)+"h",t=t%3600),t>=60&&(e+=Math.floor(t/60)+"m",t=t%60),t>0&&(e+=Math.floor(t)+"s"),e};function G(t,e=0,r){let n,i,s,l,o,a,p=0,c=!1,d=!1,S=!0,R=!e&&e!==0&&typeof window.requestAnimationFrame=="function";r&&(c=!!r.leading,d="maxWait"in r,s=r!=null&&r.maxWait?Math.max(+(r==null?void 0:r.maxWait)||0,e):s,S="trailing"in r?!!r.trailing:S);function A(b){let v=n,h=i;return n=i=void 0,p=b,l=t.apply(h,v),l}function C(b,v){return R?(o&&window.cancelAnimationFrame(o),window.requestAnimationFrame(b)):setTimeout(b,v)}function we(b){if(R){window.cancelAnimationFrame(b);return}clearTimeout(b)}function Ee(b){return p=b,o=C(k,e),c?A(b):l}function Se(b){let v=b-a,h=b-p,ne=e-v;return d?Math.min(ne,s-h):ne}function te(b){let v=b-a,h=b-p;return a===void 0||v>=e||v<0||d&&h>=s}function k(){let b=Date.now();if(te(b))return re(b);o=C(k,Se(b))}function re(b){return o=void 0,S&&n?A(b):(n=i=void 0,l)}function Ae(){o!==void 0&&we(o),p=0,n=a=i=o=void 0}function Re(){return o===void 0?l:re(Date.now())}function Ce(){return o!==void 0}function L(...b){let v=Date.now(),h=te(v);if(n=b,i=this,a=v,h){if(o===void 0)return Ee(a);if(d)return o=C(k,e),A(a)}return o===void 0&&(o=C(k,e)),l}return L.cancel=Ae,L.flush=Re,L.pending=Ce,L}var q=(t,e=0,r)=>G(t,e,P(O(O({},{leading:!0,trailing:!0}),r),{maxWait:e}));var V=(t,e)=>{if(t===null||typeof t!="object")return t;let r=Array.isArray(t)?[]:{};for(let n in t){if(typeof e=="function"){let i=e(t[n],n,t,r);if(i!==void 0){r[n]=i;continue}}typeof t[n]=="object"?r[n]=V(t[n],e):r[n]=t[n]}return r};var dt=t=>V(t);var ft=300,mt=(t,e=ft)=>new u(r=>{let{width:n,height:i}=t.getBoundingClientRect();if(r.next({width:n,height:i}),!window.ResizeObserver)return;let s=new ResizeObserver(q(l=>{let o=l[0];if(!o)return;let a,p;o.contentBoxSize&&o.contentBoxSize[0]?(p=o.contentBoxSize[0].blockSize,a=o.contentBoxSize[0].inlineSize):o.contentRect&&(a=o.contentRect.width,p=o.contentRect.height),w(a)&&w(p)&&r.next({width:a,height:p})},e));return s.observe(t),()=>s.disconnect()});var Q=class extends x{constructor(r){super();this.value=r}next(r){super.next(this.value=r)}error(r){super.error(this.value=r)}getValue(){return this.value}_subscribe(r){let n=super._subscribe(r);return r.next(this.value),n}};function be(t){return new u(e=>{let r={},n=Object.keys(t).length,i=s=>l=>{s in r||n--,r[s]=l,n===0&&e.next(r)};return Object.entries(t).reduce((s,[l,o])=>s.add(o.subscribe(i(l))),new m)})}function de(...t){return new u(e=>t.reduce((r,n)=>r.add(n.subscribe(e)),new m))}var Tt=t=>new u(e=>{let r=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},t);return()=>window.clearTimeout(r)});var vt=t=>new u(e=>{let r=window.setInterval(()=>e.next(),t);return()=>{r&&(window.clearInterval(r),r=void 0)}});var It=t=>new u(e=>{t.forEach(r=>e.next(r))});var xt=(t,e)=>new u(r=>{let n=i=>r.next(i);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)});function fe(t){return e=>new u(r=>e.subscribe(new H(r,t)))}var H=class{constructor(e,r){this.destination=e;this.size=r;this.lastValues=[]}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};var ht={leading:!1,trailing:!0};function me(t,e=ht){return r=>new u(n=>r.subscribe(new K(n,t,e)))}var K=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,w(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(r){if(this.destination.error)this.destination.error(r);else throw r}this.timeout=void 0},this.time)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};var gt={leading:!0,trailing:!1};function Te(t,e=gt){return r=>new u(n=>r.subscribe(new $(n,t,e)))}var $=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,U(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function ve(t){return e=>new u(r=>e.subscribe(new Y(r,t)))}var Y=class{constructor(e,r){this.destination=e;this.predicate=r}next(e){let r;try{r=this.predicate(e)}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function xe(t=(e,r)=>e===r){return e=>new u(r=>e.subscribe(new X(r,t)))}var Ie={},X=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=Ie}next(e){let r;try{r=this.lastValue===Ie||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function _(t){return e=>new u(r=>e.subscribe(new J(r,t)))}var J=class{constructor(e,r){this.destination=e;this.mapper=r}next(e){let r;try{r=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(r)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function he(t){return _(()=>t)}function ge(){return t=>new u(e=>{let r=!1,n=!1,i=t.subscribe(s=>{r||(r=!0,e.next(s)),n&&i.unsubscribe()},s=>{var l;r=!0,(l=e.error)==null||l.call(e,s),n&&i.unsubscribe()});return n=!0,r&&i.unsubscribe(),i})}function ye(){return t=>new u(e=>t.subscribe(new Z(e)))}var Z=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let r=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([r,e])}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function Oe(t){return e=>new u(r=>e.subscribe(new ee(r,t)))}var ee=class{constructor(e,r){this.destination=e;this.effect=r}next(e){try{this.effect(e)}catch(r){throw this.error(r),r}this.destination.next(e)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};var yt=(o=>(o.NETWORK="network",o.VIDEO_PIPELINE="video_pipeline",o.EXTERNAL_API="external_api",o.PARSER="parser",o.DOM="dom",o.WTF="wtf",o.FATAL="fatal",o))(yt||{});var Ot=(d=>(d.Armenian="58",d.Azerbaijani="57",d.Belarusian="114",d.English="3",d.Kazakh="97",d.Portuguese="73",d.Russian="0",d.Spanish="4",d.Ukrainian="1",d.Uzbek="65",d.Vietnamese="75",d))(Ot||{}),wt="vk.com",Yn=(t,e,r)=>M(void 0,null,function*(){let n=new URL(`https://${wt}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),t!==void 0&&n.searchParams.set("lang",t);let s=yield(yield fetch(n.toString())).json();return Et(s,r)}),Et=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,n])=>[r.substring(`${e}_`.length),St(n)])),St=t=>Array.isArray(t)?t[0]:t;var At=(r=>(r.RU="ru",r.EN="en",r))(At||{});export{ue as CurrentClientBrowser,ce as CurrentClientDevice,yt as ErrorCategory,At as InterfaceLanguage,D as Logger,u as Observable,x as Subject,m as Subscription,Ve as VERSION,Ot as VKNumericLanguage,Q as ValueSubject,z as VideoQuality,je as abortable,Fe as addScript,ct as areQualitiesExact,Be as assertEmptyArray,I as assertNever,_e as assertNonNullable,Ue as assertNotEmptyArray,De as assertNullable,pt as assertQualityIsExact,fe as buffer,Qe as checkNever,dt as cloneDeep,V as cloneDeepWith,be as combine,me as debounce,G as debounceFn,rt as detectEmbed,bt as fillWithDefault,ve as filter,xe as filterChanged,xt as fromEvent,N as getCurrentBrowser,$e as getExponentialDelay,st as getHighestQuality,Ge as getIOSVersion,vt as interval,qe as isAndroid,nt as isHigher,ot as isHigherOrEqual,We as isIOS,W as isInvariantQuality,j as isLower,it as isLowerOrEqual,He as isMacLike,Ke as isMobile,w as isNonNullable,U as isNullable,Yn as loadVKLangPack,_ as map,he as mapTo,de as merge,g as noop,ze as now,It as observableFrom,mt as observeElementSize,ge as once,ye as pairwise,F as safeStorage,Oe as tap,Te as throttle,q as throttleFn,sr as timeCodeToString,Tt as timeout,at as videoHeightToQuality,ut as videoQualityToHeight,lt as videoSizeToQuality};
6
+ var se=Object.defineProperty,ke=Object.defineProperties;var Ce=Object.getOwnPropertyDescriptors;var ie=Object.getOwnPropertySymbols;var Pe=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable;var ae=Math.pow,oe=(r,e,t)=>e in r?se(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,O=(r,e)=>{for(var t in e||(e={}))Pe.call(e,t)&&oe(r,t,e[t]);if(ie)for(var t of ie(e))Le.call(e,t)&&oe(r,t,e[t]);return r},k=(r,e)=>ke(r,Ce(e));var Me=(r,e)=>{for(var t in e)se(r,t,{get:e[t],enumerable:!0})};var C=(r,e,t)=>new Promise((n,o)=>{var s=c=>{try{i(t.next(c))}catch(u){o(u)}},a=c=>{try{i(t.throw(c))}catch(u){o(u)}},i=c=>c.done?n(c.value):Promise.resolve(c.value).then(s,a);i((t=t.apply(r,e)).next())});var Ve="1.0.38-dev.abb9bed7.0";var m=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(t=>typeof t=="function"?t():t.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var h=r=>{throw new Error(`${r} is value of unexpected type`)},_e=r=>{};var g=()=>{};var l=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,t){var a;let n;t?typeof t=="function"?n={next:t,error:g}:n={next:i=>t.next(i),error:i=>{var c;return(c=t.error)==null?void 0:c.call(t,i)}}:n={next:g,error:g};let o=typeof e=="function"?{next:i=>{try{e(i)}catch(c){n.next(c)}},error:i=>n.next(i)}:{next:i=>e.next(i),error:i=>e.error?e.error(i):n.next(i)},s;try{s=this._subscribe(o)}catch(i){(a=o.error)==null||a.call(o,i)}return new m().add(()=>{switch(o.next=g,o.error=g,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return h(s)}})}pipe(...e){return e.reduce((t,n)=>n(t),this)}_subscribe(e){}};var I=class extends l{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(t){this.subscribers.forEach(n=>n.next(t))}error(t){this.subscribers.forEach(n=>{var o;return(o=n.error)==null?void 0:o.call(n,t)})}_subscribe(t){let n=this.keyCounter++;return this.subscribers.set(n,t),new m().add(()=>this.subscribers.delete(n))}};var N=class{constructor(){this.log$=new I;this.logs=[];this.log=e=>{let t=k(O({},e),{timestamp:Date.now()});this.logs.push(t),this.log$.next(t)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...t)=>{let n;try{n=e(...t)}catch(o){n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(t=>O({component:e},t))}};function Ne(r,e='Assertion "value is not nullable" failed'){if(r==null)throw new Error(e)}function Qe(r,e='Assertion "value is nullable" failed'){if(r!=null)throw new Error(e)}function w(r){return typeof r!="undefined"&&r!==null}function Q(r){return r==null}function De(r,e){if(!(r!=null&&r.length))throw new Error(e)}function Ue(r,e){if(r!=null&&r.length)throw new Error(e)}var Be=(r,e,t)=>new Promise((n,o)=>{e.addEventListener("abort",()=>{i(),u.remove()});let s=()=>{i(),o()},a=()=>{i(),n()},i=()=>{c&&clearTimeout(c),u.removeEventListener("load",a),u.removeEventListener("error",s)},c;t&&(c=window.setTimeout(s,t));let u=document.createElement("script");u.addEventListener("load",a),u.addEventListener("error",s),u.src=r,document.head.appendChild(u)});var le,Fe=typeof((le=window.performance)==null?void 0:le.now)=="function"?()=>window.performance.now():()=>Date.now();var ze=(r,e)=>(...t)=>C(void 0,null,function*(){var a;let n=e(...t),o=r.aborted,s;for(;!o&&!r.aborted;)try{let i=yield n.next(s);o=(a=i.done)!=null?a:!1,s=i.value}catch(i){yield n.throw(i)}return s});var ce=()=>{var r,e;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test((r=navigator.appVersion)!=null?r:navigator.userAgent)||((e=navigator==null?void 0:navigator.userAgentData)==null?void 0:e.mobile)},D=class{constructor(){this.detect()}get browser(){return this._currentBrowser}get device(){return this._currentDevice}get isTouch(){return this._maxTouchPoints>0}get isIOS(){return["iPhone","iPad","iPod"].includes(this.device)}get isMac(){return this.device==="Mac"}get isApple(){return this.isIOS||this.isMac}get isIphoneOrOldIpad(){if(!this.isApple||!this.isTouch)return!1;let e=this.device==="iPad"||(window==null?void 0:window.screen.width)>700,t=this._iosVersion;return!e||e&&!!t&&t<16}get isAndroid(){return this.device==="Android"}get isMobile(){return this._isMobile}get iOSVersion(){return this._iosVersion}get macVersion(){return this._macVersion}get isYandex(){return this.browser==="Yandex"}get isSafari(){return this.browser==="Safari"}get isSamsungBrowser(){return this.browser==="SamsungBrowser"}get isHDR(){return this._isHdr}detect(){var n;let{userAgent:e,maxTouchPoints:t}=navigator;try{this._maxTouchPoints=t,this._isHdr=!!((n=matchMedia("(dynamic-range: high)"))!=null&&n.matches)}catch(o){console.error(o)}try{this._isMobile=ce()}catch(o){console.error(o)}this.detectBrowser(e),this.detectDevice(e),this.isIOS&&this.detectIOSVersion(),this.isMac&&this.detectMacVersion()}detectBrowser(e){try{let t=/yabrowser/i.test(e)?"Yandex":void 0,n=/samsungbrowser/i.test(e)?"SamsungBrowser":void 0,o=/chrome|crios/i.test(e)?"Chrome":void 0,s=/chromium/i.test(e)?"Chromium":void 0,a=/firefox|fxios/i.test(e)?"Firefox":void 0,i=/webkit|safari|khtml/i.test(e)?"Safari":void 0,c=/opr\//i.test(e)?"Opera":void 0,u=/edg/i.test(e)?"Edge":void 0;this._currentBrowser=t||n||a||c||u||o||s||i||"Rest"}catch(t){console.error(t)}}detectDevice(e){try{let t=/android/i.test(e)?"Android":void 0,n=/iphone/i.test(e)?"iPhone":void 0,o=/ipad/i.test(e)?"iPad":void 0,s=/ipod/i.test(e)?"iPod":void 0,a=/mac/i.test(e)?"Mac":void 0,i=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(e)?"RestMobile":void 0;this._currentDevice=t||n||o||s||i||a||"Desktop"}catch(t){console.error(t)}}detectIOSVersion(){try{let{userAgent:e}=window.navigator,t=e.match(/Version\/(\d+(\.\d+)?)/i);if(!t)return;let n=t[1],o=parseFloat(n);if(isNaN(o))return;this._iosVersion=o}catch(e){console.error(e)}}detectMacVersion(){try{let{userAgent:e}=window.navigator,t=e.match(/Version\/(\d+)/);if(!t)return;let n=t[1],o=parseInt(n,10);if(isNaN(o))return;this._macVersion=o}catch(e){console.error(e)}}},je=new D;var We=(r,{start:e=0,factor:t=2,max:n=1/0,min:o=e,random:s=0}={})=>{let a=e;return a*=ae(t,r),a*=1+(Math.random()*s*2-s),a=Math.round(a),a=Math.min(a,n),a=Math.max(a,o),a};var B={};Me(B,{clear:()=>$e,get:()=>He,has:()=>Ke,isPersistent:()=>Ge,remove:()=>Ye,set:()=>qe});var d,y,U=`vk-videoplayer-dummy-key-${Math.random()}`,E=()=>{if(y!==void 0)return y;try{localStorage.setItem(U,"test"),localStorage.removeItem(U),y=0}catch(r){if(r instanceof DOMException||r instanceof TypeError)try{sessionStorage.getItem(U),y=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)y=2;else throw e}else throw r}return y===2&&(d=new Map),y},Ge=()=>E()===0,He=r=>{var t,n;let e=E();switch(e){case 0:return(t=localStorage.getItem(r))!=null?t:void 0;case 1:return(n=sessionStorage.getItem(r))!=null?n:void 0;case 2:return d==null?void 0:d.get(r);default:h(e)}},qe=(r,e)=>{let t=E();switch(t){case 0:try{localStorage.setItem(r,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(r,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void(d==null?void 0:d.set(r,e));default:h(t)}},Ke=r=>{var t;let e=E();switch(e){case 0:return r in localStorage;case 1:return r in sessionStorage;case 2:return(t=d==null?void 0:d.has(r))!=null?t:!1;default:return h(e),!1}},Ye=r=>{let e=E();switch(e){case 0:return localStorage.removeItem(r);case 1:return sessionStorage.removeItem(r);case 2:return void(d==null?void 0:d.delete(r));default:h(e)}},$e=()=>{let r=E();switch(r){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return d==null?void 0:d.clear();default:h(r)}};var Xe=()=>{let r,e;try{r=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?r=!0:(r=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let t=e?new URL(e).hostname:void 0;return{isEmbed:r,host:t}};var F=(f=>(f.INVARIANT="Invariant quality",f.Q_144P="144p",f.Q_240P="240p",f.Q_360P="360p",f.Q_480P="480p",f.Q_720P="720p",f.Q_1080P="1080p",f.Q_1440P="1440p",f.Q_2160P="2160p",f.Q_4320P="4320p",f))(F||{});var T={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"720p":{width:1280,height:720},"1080p":{width:1920,height:1080},"1440p":{width:2560,height:1440},"2160p":{width:3840,height:2160},"4320p":{width:7680,height:4320}},Je=(r,e)=>T[r].height>T[e].height,Ze=(r,e)=>T[r].height>=T[e].height,z=(r,e)=>T[r].height<T[e].height,et=(r,e)=>T[r].height<=T[e].height,tt=r=>r.sort((e,t)=>e===t?0:e==="Invariant quality"?1:t==="Invariant quality"?-1:z(e,t)?1:-1)[0],ue=Object.keys(T).sort((r,e)=>z(r,e)?-1:1),rt=(r,e=.02)=>[...ue].find(n=>T[n].height*(1+e)>=r),nt=({width:r,height:e})=>{let t=Math.min(r,e),n=Math.max(r,e);return ue.find(o=>{let s=T[o];return s.width>=n&&s.height>=t})},it=r=>T[r].height,j=r=>r==="Invariant quality",ot=r=>r.every(e=>!j(e));function st(r){if(j(r))throw new Error("Expected exact quality")}var at=(r,e)=>{let t={};for(let n of Object.keys(e)){let o=e[n],s=r[n];Array.isArray(o)&&Array.isArray(s)?t[n]=s:typeof o=="object"&&typeof s=="object"?t[n]=at(s,o):t[n]=n in r?s:o}return t};var rr=r=>{let e="";return r>=3600&&(e+=Math.floor(r/3600)+"h",r=r%3600),r>=60&&(e+=Math.floor(r/60)+"m",r=r%60),r>0&&(e+=Math.floor(r)+"s"),e};function W(r,e=0,t){let n,o,s,a,i,c,u=0,f=!1,b=!1,V=!0,ee=!e&&e!==0&&typeof window.requestAnimationFrame=="function";t&&(f=!!t.leading,b="maxWait"in t,s=t!=null&&t.maxWait?Math.max(+(t==null?void 0:t.maxWait)||0,e):s,V="trailing"in t?!!t.trailing:V);function _(p){let v=n,x=o;return n=o=void 0,u=p,a=r.apply(x,v),a}function S(p,v){return ee?(i&&window.cancelAnimationFrame(i),window.requestAnimationFrame(p)):setTimeout(p,v)}function Oe(p){if(ee){window.cancelAnimationFrame(p);return}clearTimeout(p)}function we(p){return u=p,i=S(R,e),f?_(p):a}function Ee(p){let v=p-c,x=p-u,ne=e-v;return b?Math.min(ne,s-x):ne}function te(p){let v=p-c,x=p-u;return c===void 0||v>=e||v<0||b&&x>=s}function R(){let p=Date.now();if(te(p))return re(p);i=S(R,Ee(p))}function re(p){return i=void 0,V&&n?_(p):(n=o=void 0,a)}function Se(){i!==void 0&&Oe(i),u=0,n=c=o=i=void 0}function Re(){return i===void 0?a:re(Date.now())}function Ae(){return i!==void 0}function A(...p){let v=Date.now(),x=te(v);if(n=p,o=this,c=v,x){if(i===void 0)return we(c);if(b)return i=S(R,e),_(c)}return i===void 0&&(i=S(R,e)),a}return A.cancel=Se,A.flush=Re,A.pending=Ae,A}var G=(r,e=0,t)=>W(r,e,k(O(O({},{leading:!0,trailing:!0}),t),{maxWait:e}));var P=(r,e)=>{if(r===null||typeof r!="object")return r;let t=Array.isArray(r)?[]:{};for(let n in r){if(typeof e=="function"){let o=e(r[n],n,r,t);if(o!==void 0){t[n]=o;continue}}typeof r[n]=="object"?t[n]=P(r[n],e):t[n]=r[n]}return t};var lt=r=>P(r);var ct=300,ut=(r,e=ct)=>new l(t=>{let{width:n,height:o}=r.getBoundingClientRect();if(t.next({width:n,height:o}),!window.ResizeObserver)return;let s=new ResizeObserver(G(a=>{let i=a[0];if(!i)return;let c,u;i.contentBoxSize&&i.contentBoxSize[0]?(u=i.contentBoxSize[0].blockSize,c=i.contentBoxSize[0].inlineSize):i.contentRect&&(c=i.contentRect.width,u=i.contentRect.height),w(c)&&w(u)&&t.next({width:c,height:u})},e));return s.observe(r),()=>s.disconnect()});var pt=r=>{r.removeAttribute("src"),r.load()};var L=class extends I{constructor(e){super(),this.value=e}next(e){super.next(this.value=e)}error(e){super.error(this.value=e)}getValue(){return this.value}_subscribe(e){let t=super._subscribe(e);return e.next(this.value),t}};function pe(r){return new l(e=>{let t={},n=Object.keys(r).length,o=s=>a=>{s in t||n--,t[s]=a,n===0&&e.next(t)};return Object.entries(r).reduce((s,[a,i])=>s.add(i.subscribe(o(a))),new m)})}function be(...r){return new l(e=>r.reduce((t,n)=>t.add(n.subscribe(e)),new m))}var bt=r=>new l(e=>{let t=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},r);return()=>window.clearTimeout(t)});var dt=r=>new l(e=>{let t=window.setInterval(()=>e.next(),r);return()=>{t&&(window.clearInterval(t),t=void 0)}});var ft=r=>new l(e=>{r.forEach(t=>e.next(t))});var mt=(r,e)=>new l(t=>{let n=o=>t.next(o);return r.addEventListener(e,n),()=>r.removeEventListener(e,n)});function de(r){return e=>new l(t=>e.subscribe(new H(t,r)))}var H=class{constructor(e,t){this.destination=e;this.size=t;this.lastValues=[]}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};var Tt={leading:!1,trailing:!0};function fe(r,e=Tt){return t=>new l(n=>t.subscribe(new q(n,r,e)))}var q=class{constructor(e,t,n){this.destination=e;this.time=t;this.config=n}next(e){this.lastValue=e,w(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(t){if(this.destination.error)this.destination.error(t);else throw t}this.timeout=void 0},this.time)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};var vt={leading:!0,trailing:!1};function me(r,e=vt){return t=>new l(n=>t.subscribe(new K(n,r,e)))}var K=class{constructor(e,t,n){this.destination=e;this.time=t;this.config=n}next(e){this.lastValue=e,Q(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function Te(r){return e=>new l(t=>e.subscribe(new Y(t,r)))}var Y=class{constructor(e,t){this.destination=e;this.predicate=t}next(e){let t;try{t=this.predicate(e)}catch(n){throw this.error(n),n}t&&this.destination.next(e)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function he(r=(e,t)=>e===t){return e=>new l(t=>e.subscribe(new $(t,r)))}var ve={},$=class{constructor(e,t){this.destination=e;this.predicate=t;this.lastValue=ve}next(e){let t;try{t=this.lastValue===ve||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}t&&this.destination.next(e)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function M(r){return e=>new l(t=>e.subscribe(new X(t,r)))}var X=class{constructor(e,t){this.destination=e;this.mapper=t}next(e){let t;try{t=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(t)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function Ie(r){return M(()=>r)}function xe(){return r=>new l(e=>{let t=!1,n=!1,o=r.subscribe(s=>{t||(t=!0,e.next(s)),n&&o.unsubscribe()},s=>{var a;t=!0,(a=e.error)==null||a.call(e,s),n&&o.unsubscribe()});return n=!0,t&&o.unsubscribe(),o})}function ge(){return r=>new l(e=>r.subscribe(new J(e)))}var J=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let t=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([t,e])}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function ye(r){return e=>new l(t=>e.subscribe(new Z(t,r)))}var Z=class{constructor(e,t){this.destination=e;this.effect=t}next(e){try{this.effect(e)}catch(t){throw this.error(t),t}this.destination.next(e)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};var ht=(i=>(i.NETWORK="network",i.VIDEO_PIPELINE="video_pipeline",i.EXTERNAL_API="external_api",i.PARSER="parser",i.DOM="dom",i.WTF="wtf",i.FATAL="fatal",i))(ht||{});var It=(b=>(b.Armenian="58",b.Azerbaijani="57",b.Belarusian="114",b.English="3",b.Kazakh="97",b.Portuguese="73",b.Russian="0",b.Spanish="4",b.Ukrainian="1",b.Uzbek="65",b.Vietnamese="75",b))(It||{}),xt="vk.com",Kn=(r,e,t)=>C(void 0,null,function*(){let n=new URL(`https://${xt}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),r!==void 0&&n.searchParams.set("lang",r);let s=yield(yield fetch(n.toString())).json();return gt(s,t)}),gt=(r,e)=>Object.fromEntries(Object.entries(r.keys).map(([t,n])=>[t.substring(`${e}_`.length),yt(n)])),yt=r=>Array.isArray(r)?r[0]:r;var Ot=(t=>(t.RU="ru",t.EN="en",t))(Ot||{});export{ht as ErrorCategory,Ot as InterfaceLanguage,N as Logger,l as Observable,I as Subject,m as Subscription,Ve as VERSION,It as VKNumericLanguage,L as ValueSubject,F as VideoQuality,ze as abortable,Be as addScript,ot as areQualitiesExact,Ue as assertEmptyArray,h as assertNever,Ne as assertNonNullable,De as assertNotEmptyArray,Qe as assertNullable,st as assertQualityIsExact,de as buffer,_e as checkNever,pt as clearVideoElement,je as clientChecker,lt as cloneDeep,P as cloneDeepWith,pe as combine,fe as debounce,W as debounceFn,Xe as detectEmbed,at as fillWithDefault,Te as filter,he as filterChanged,mt as fromEvent,We as getExponentialDelay,tt as getHighestQuality,dt as interval,Je as isHigher,Ze as isHigherOrEqual,j as isInvariantQuality,z as isLower,et as isLowerOrEqual,ce as isMobile,w as isNonNullable,Q as isNullable,Kn as loadVKLangPack,M as map,Ie as mapTo,be as merge,g as noop,Fe as now,ft as observableFrom,ut as observeElementSize,xe as once,ge as pairwise,B as safeStorage,ye as tap,me as throttle,G as throttleFn,rr as timeCodeToString,bt as timeout,rt as videoHeightToQuality,it as videoQualityToHeight,nt as videoSizeToQuality};
package/es2018.cjs.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @vkontakte/videoplayer-shared v1.0.38-dev.87754f30.0
3
- * Tue, 06 Aug 2024 11:52:24 GMT
2
+ * @vkontakte/videoplayer-shared v1.0.38-dev.abb9bed7.0
3
+ * Mon, 19 Aug 2024 11:00:39 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-38/doc/
5
5
  */
6
- "use strict";var j=Object.defineProperty;var st=Object.getOwnPropertyDescriptor;var at=Object.getOwnPropertyNames;var lt=Object.prototype.hasOwnProperty;var me=(t,e)=>{for(var r in e)j(t,r,{get:e[r],enumerable:!0})},ut=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of at(e))!lt.call(t,i)&&i!==r&&j(t,i,{get:()=>e[i],enumerable:!(n=st(e,i))||n.enumerable});return t};var ct=t=>ut(j({},"__esModule",{value:!0}),t);var Et={};me(Et,{CurrentClientBrowser:()=>W,CurrentClientDevice:()=>G,ErrorCategory:()=>Xe,InterfaceLanguage:()=>Ze,Logger:()=>V,Observable:()=>a,Subject:()=>x,Subscription:()=>m,VERSION:()=>Te,VKNumericLanguage:()=>Je,ValueSubject:()=>C,VideoQuality:()=>D,abortable:()=>Ee,addScript:()=>ye,areQualitiesExact:()=>Fe,assertEmptyArray:()=>ge,assertNever:()=>I,assertNonNullable:()=>Ie,assertNotEmptyArray:()=>he,assertNullable:()=>xe,assertQualityIsExact:()=>ze,buffer:()=>Y,checkNever:()=>ve,cloneDeep:()=>We,cloneDeepWith:()=>R,combine:()=>H,debounce:()=>J,debounceFn:()=>F,detectEmbed:()=>Pe,fillWithDefault:()=>je,filter:()=>re,filterChanged:()=>oe,fromEvent:()=>$e,getCurrentBrowser:()=>A,getExponentialDelay:()=>Le,getHighestQuality:()=>Qe,getIOSVersion:()=>Ae,interval:()=>He,isAndroid:()=>Re,isHigher:()=>Me,isHigherOrEqual:()=>Ne,isIOS:()=>Se,isInvariantQuality:()=>B,isLower:()=>U,isLowerOrEqual:()=>Ve,isMacLike:()=>Ce,isMobile:()=>ke,isNonNullable:()=>y,isNullable:()=>Q,loadVKLangPack:()=>yt,map:()=>k,mapTo:()=>se,merge:()=>K,noop:()=>h,now:()=>we,observableFrom:()=>Ke,observeElementSize:()=>Ge,once:()=>ae,pairwise:()=>ue,safeStorage:()=>_,tap:()=>pe,throttle:()=>ee,throttleFn:()=>z,timeCodeToString:()=>vt,timeout:()=>qe,videoHeightToQuality:()=>De,videoQualityToHeight:()=>Be,videoSizeToQuality:()=>Ue});module.exports=ct(Et);var Te="1.0.38-dev.87754f30.0";var m=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(r=>typeof r=="function"?r():r.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var I=t=>{throw new Error(`${t} is value of unexpected type`)},ve=t=>{};var h=()=>{};var a=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,r){var l;let n;r?typeof r=="function"?n={next:r,error:h}:n={next:o=>r.next(o),error:o=>{var u;return(u=r.error)==null?void 0:u.call(r,o)}}:n={next:h,error:h};let i=typeof e=="function"?{next:o=>{try{e(o)}catch(u){n.next(u)}},error:o=>n.next(o)}:{next:o=>e.next(o),error:o=>e.error?e.error(o):n.next(o)},s;try{s=this._subscribe(i)}catch(o){(l=i.error)==null||l.call(i,o)}return new m().add(()=>{switch(i.next=h,i.error=h,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return I(s)}})}pipe(...e){return e.reduce((r,n)=>n(r),this)}_subscribe(e){}};var x=class extends a{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(r){this.subscribers.forEach(n=>n.next(r))}error(r){this.subscribers.forEach(n=>{var i;return(i=n.error)==null?void 0:i.call(n,r)})}_subscribe(r){let n=this.keyCounter++;return this.subscribers.set(n,r),new m().add(()=>this.subscribers.delete(n))}};var V=class{constructor(){this.log$=new x;this.logs=[];this.log=e=>{let r={...e,timestamp:Date.now()};this.logs.push(r),this.log$.next(r)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...r)=>{let n;try{n=e(...r)}catch(i){n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(r=>({component:e,...r}))}};function Ie(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function xe(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function y(t){return typeof t!="undefined"&&t!==null}function Q(t){return t==null}function he(t,e){if(!(t!=null&&t.length))throw new Error(e)}function ge(t,e){if(t!=null&&t.length)throw new Error(e)}var ye=(t,e,r)=>new Promise((n,i)=>{e.addEventListener("abort",()=>{o(),b.remove()});let s=()=>{o(),i()},l=()=>{o(),n()},o=()=>{u&&clearTimeout(u),b.removeEventListener("load",l),b.removeEventListener("error",s)},u;r&&(u=window.setTimeout(s,r));let b=document.createElement("script");b.addEventListener("load",l),b.addEventListener("error",s),b.src=t,document.head.appendChild(b)});var Oe,we=typeof((Oe=window.performance)==null?void 0:Oe.now)=="function"?()=>window.performance.now():()=>Date.now();var Ee=(t,e)=>async(...r)=>{var l;let n=e(...r),i=t.aborted,s;for(;!i&&!t.aborted;)try{let o=await n.next(s);i=(l=o.done)!=null?l:!1,s=o.value}catch(o){await n.throw(o)}return s};var W=(c=>(c.Unknown="Unknown",c.Yandex="Yandex",c.Chrome="Chrome",c.Chromium="Chromium",c.Firefox="Firefox",c.Safari="Safari",c.Opera="Opera",c.Edge="Edge",c.SamsungBrowser="SamsungBrowser",c.Rest="Rest",c))(W||{}),G=(u=>(u.Unknown="Unknown",u.Android="Android",u.iPhone="iPhone",u.iPad="iPad",u.iPod="iPod",u.RestMobile="RestMobile",u.Mac="Mac",u.Desktop="Desktop",u))(G||{}),A=()=>{let{userAgent:t}=window.navigator,e=/yabrowser/i.test(t)?"Yandex":void 0,r=/samsungbrowser/i.test(t)?"SamsungBrowser":void 0,n=/chrome|crios/i.test(t)?"Chrome":void 0,i=/chromium/i.test(t)?"Chromium":void 0,s=/firefox|fxios/i.test(t)?"Firefox":void 0,l=/webkit|safari|khtml/i.test(t)?"Safari":void 0,o=/opr\//i.test(t)?"Opera":void 0,u=/edg/i.test(t)?"Edge":void 0,b=/android/i.test(t)?"Android":void 0,c=/iphone/i.test(t)?"iPhone":void 0,d=/ipad/i.test(t)?"iPad":void 0,E=/ipod/i.test(t)?"iPod":void 0,L=/mac/i.test(t)?"Mac":void 0,S=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(t)?"RestMobile":void 0;return{browser:e||r||s||o||u||n||i||l||"Rest",device:b||c||d||E||S||L||"Desktop"}},Se=(t=!1)=>{let r=["iPhone","iPad","iPod"].includes(A().device);if(!t)return r;let{userAgent:n,maxTouchPoints:i}=window.navigator;return!!(r||/macintosh/i.test(n)&&i>0)},Ae=()=>{let{userAgent:t}=window.navigator,e=t.match(/Version\/(\d+(\.\d+)?)/i);if(!e)return null;let r=e[1],n=parseFloat(r);return isNaN(n)?null:n},Re=()=>A().device==="Android",Ce=()=>["Mac","iPhone","iPad","iPod"].includes(A().device),ke=()=>{var t,e;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test((t=navigator.appVersion)!=null?t:navigator.userAgent)||((e=navigator==null?void 0:navigator.userAgentData)==null?void 0:e.mobile)};var Le=(t,{start:e=0,factor:r=2,max:n=1/0,min:i=e,random:s=0}={})=>{let l=e;return l*=r**t,l*=1+(Math.random()*s*2-s),l=Math.round(l),l=Math.min(l,n),l=Math.max(l,i),l};var _={};me(_,{clear:()=>Tt,get:()=>bt,has:()=>ft,isPersistent:()=>pt,remove:()=>mt,set:()=>dt});var f,O,q=`vk-videoplayer-dummy-key-${Math.random()}`,w=()=>{if(O!==void 0)return O;try{localStorage.setItem(q,"test"),localStorage.removeItem(q),O=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem(q),O=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)O=2;else throw e}else throw t}return O===2&&(f=new Map),O},pt=()=>w()===0,bt=t=>{var r,n;let e=w();switch(e){case 0:return(r=localStorage.getItem(t))!=null?r:void 0;case 1:return(n=sessionStorage.getItem(t))!=null?n:void 0;case 2:return f==null?void 0:f.get(t);default:I(e)}},dt=(t,e)=>{let r=w();switch(r){case 0:try{localStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void(f==null?void 0:f.set(t,e));default:I(r)}},ft=t=>{var r;let e=w();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return(r=f==null?void 0:f.has(t))!=null?r:!1;default:return I(e),!1}},mt=t=>{let e=w();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:return void(f==null?void 0:f.delete(t));default:I(e)}},Tt=()=>{let t=w();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return f==null?void 0:f.clear();default:I(t)}};var Pe=()=>{let t,e;try{t=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?t=!0:(t=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let r=e?new URL(e).hostname:void 0;return{isEmbed:t,host:r}};var D=(c=>(c.INVARIANT="Invariant quality",c.Q_144P="144p",c.Q_240P="240p",c.Q_360P="360p",c.Q_480P="480p",c.Q_720P="720p",c.Q_1080P="1080p",c.Q_1440P="1440p",c.Q_2160P="2160p",c.Q_4320P="4320p",c))(D||{});var T={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"720p":{width:1280,height:720},"1080p":{width:1920,height:1080},"1440p":{width:2560,height:1440},"2160p":{width:3840,height:2160},"4320p":{width:7680,height:4320}},Me=(t,e)=>T[t].height>T[e].height,Ne=(t,e)=>T[t].height>=T[e].height,U=(t,e)=>T[t].height<T[e].height,Ve=(t,e)=>T[t].height<=T[e].height,Qe=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:U(e,r)?1:-1)[0],_e=Object.keys(T).sort((t,e)=>U(t,e)?-1:1),De=(t,e=.02)=>[..._e].find(n=>T[n].height*(1+e)>=t),Ue=({width:t,height:e})=>{let r=Math.min(t,e),n=Math.max(t,e);return _e.find(i=>{let s=T[i];return s.width>=n&&s.height>=r})},Be=t=>T[t].height,B=t=>t==="Invariant quality",Fe=t=>t.every(e=>!B(e));function ze(t){if(B(t))throw new Error("Expected exact quality")}var je=(t,e)=>{let r={};for(let n of Object.keys(e)){let i=e[n],s=t[n];Array.isArray(i)&&Array.isArray(s)?r[n]=s:typeof i=="object"&&typeof s=="object"?r[n]=je(s,i):r[n]=n in t?s:i}return r};var vt=t=>{let e="";return t>=3600&&(e+=Math.floor(t/3600)+"h",t=t%3600),t>=60&&(e+=Math.floor(t/60)+"m",t=t%60),t>0&&(e+=Math.floor(t)+"s"),e};function F(t,e=0,r){let n,i,s,l,o,u,b=0,c=!1,d=!1,E=!0,L=!e&&e!==0&&typeof window.requestAnimationFrame=="function";r&&(c=!!r.leading,d="maxWait"in r,s=r!=null&&r.maxWait?Math.max(+(r==null?void 0:r.maxWait)||0,e):s,E="trailing"in r?!!r.trailing:E);function S(p){let v=n,g=i;return n=i=void 0,b=p,l=t.apply(g,v),l}function P(p,v){return L?(o&&window.cancelAnimationFrame(o),window.requestAnimationFrame(p)):setTimeout(p,v)}function et(p){if(L){window.cancelAnimationFrame(p);return}clearTimeout(p)}function tt(p){return b=p,o=P(M,e),c?S(p):l}function rt(p){let v=p-u,g=p-b,fe=e-v;return d?Math.min(fe,s-g):fe}function be(p){let v=p-u,g=p-b;return u===void 0||v>=e||v<0||d&&g>=s}function M(){let p=Date.now();if(be(p))return de(p);o=P(M,rt(p))}function de(p){return o=void 0,E&&n?S(p):(n=i=void 0,l)}function nt(){o!==void 0&&et(o),b=0,n=u=i=o=void 0}function ot(){return o===void 0?l:de(Date.now())}function it(){return o!==void 0}function N(...p){let v=Date.now(),g=be(v);if(n=p,i=this,u=v,g){if(o===void 0)return tt(u);if(d)return o=P(M,e),S(u)}return o===void 0&&(o=P(M,e)),l}return N.cancel=nt,N.flush=ot,N.pending=it,N}var z=(t,e=0,r)=>F(t,e,{...{leading:!0,trailing:!0},...r,maxWait:e});var R=(t,e)=>{if(t===null||typeof t!="object")return t;let r=Array.isArray(t)?[]:{};for(let n in t){if(typeof e=="function"){let i=e(t[n],n,t,r);if(i!==void 0){r[n]=i;continue}}typeof t[n]=="object"?r[n]=R(t[n],e):r[n]=t[n]}return r};var We=t=>R(t);var It=300,Ge=(t,e=It)=>new a(r=>{let{width:n,height:i}=t.getBoundingClientRect();if(r.next({width:n,height:i}),!window.ResizeObserver)return;let s=new ResizeObserver(z(l=>{let o=l[0];if(!o)return;let u,b;o.contentBoxSize&&o.contentBoxSize[0]?(b=o.contentBoxSize[0].blockSize,u=o.contentBoxSize[0].inlineSize):o.contentRect&&(u=o.contentRect.width,b=o.contentRect.height),y(u)&&y(b)&&r.next({width:u,height:b})},e));return s.observe(t),()=>s.disconnect()});var C=class extends x{constructor(r){super();this.value=r}next(r){super.next(this.value=r)}error(r){super.error(this.value=r)}getValue(){return this.value}_subscribe(r){let n=super._subscribe(r);return r.next(this.value),n}};function H(t){return new a(e=>{let r={},n=Object.keys(t).length,i=s=>l=>{s in r||n--,r[s]=l,n===0&&e.next(r)};return Object.entries(t).reduce((s,[l,o])=>s.add(o.subscribe(i(l))),new m)})}function K(...t){return new a(e=>t.reduce((r,n)=>r.add(n.subscribe(e)),new m))}var qe=t=>new a(e=>{let r=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},t);return()=>window.clearTimeout(r)});var He=t=>new a(e=>{let r=window.setInterval(()=>e.next(),t);return()=>{r&&(window.clearInterval(r),r=void 0)}});var Ke=t=>new a(e=>{t.forEach(r=>e.next(r))});var $e=(t,e)=>new a(r=>{let n=i=>r.next(i);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)});function Y(t){return e=>new a(r=>e.subscribe(new $(r,t)))}var $=class{constructor(e,r){this.destination=e;this.size=r;this.lastValues=[]}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};var xt={leading:!1,trailing:!0};function J(t,e=xt){return r=>new a(n=>r.subscribe(new X(n,t,e)))}var X=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,y(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(r){if(this.destination.error)this.destination.error(r);else throw r}this.timeout=void 0},this.time)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};var ht={leading:!0,trailing:!1};function ee(t,e=ht){return r=>new a(n=>r.subscribe(new Z(n,t,e)))}var Z=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,Q(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function re(t){return e=>new a(r=>e.subscribe(new te(r,t)))}var te=class{constructor(e,r){this.destination=e;this.predicate=r}next(e){let r;try{r=this.predicate(e)}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function oe(t=(e,r)=>e===r){return e=>new a(r=>e.subscribe(new ne(r,t)))}var Ye={},ne=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=Ye}next(e){let r;try{r=this.lastValue===Ye||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function k(t){return e=>new a(r=>e.subscribe(new ie(r,t)))}var ie=class{constructor(e,r){this.destination=e;this.mapper=r}next(e){let r;try{r=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(r)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function se(t){return k(()=>t)}function ae(){return t=>new a(e=>{let r=!1,n=!1,i=t.subscribe(s=>{r||(r=!0,e.next(s)),n&&i.unsubscribe()},s=>{var l;r=!0,(l=e.error)==null||l.call(e,s),n&&i.unsubscribe()});return n=!0,r&&i.unsubscribe(),i})}function ue(){return t=>new a(e=>t.subscribe(new le(e)))}var le=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let r=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([r,e])}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function pe(t){return e=>new a(r=>e.subscribe(new ce(r,t)))}var ce=class{constructor(e,r){this.destination=e;this.effect=r}next(e){try{this.effect(e)}catch(r){throw this.error(r),r}this.destination.next(e)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};var Xe=(o=>(o.NETWORK="network",o.VIDEO_PIPELINE="video_pipeline",o.EXTERNAL_API="external_api",o.PARSER="parser",o.DOM="dom",o.WTF="wtf",o.FATAL="fatal",o))(Xe||{});var Je=(d=>(d.Armenian="58",d.Azerbaijani="57",d.Belarusian="114",d.English="3",d.Kazakh="97",d.Portuguese="73",d.Russian="0",d.Spanish="4",d.Ukrainian="1",d.Uzbek="65",d.Vietnamese="75",d))(Je||{}),gt="vk.com",yt=async(t,e,r)=>{let n=new URL(`https://${gt}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),t!==void 0&&n.searchParams.set("lang",t);let s=await(await fetch(n.toString())).json();return Ot(s,r)},Ot=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,n])=>[r.substring(`${e}_`.length),wt(n)])),wt=t=>Array.isArray(t)?t[0]:t;var Ze=(r=>(r.RU="ru",r.EN="en",r))(Ze||{});
6
+ "use strict";var F=Object.defineProperty;var rt=Object.getOwnPropertyDescriptor;var nt=Object.getOwnPropertyNames;var it=Object.prototype.hasOwnProperty;var fe=(r,e)=>{for(var t in e)F(r,t,{get:e[t],enumerable:!0})},ot=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of nt(e))!it.call(r,i)&&i!==t&&F(r,i,{get:()=>e[i],enumerable:!(n=rt(e,i))||n.enumerable});return r};var st=r=>ot(F({},"__esModule",{value:!0}),r);var gt={};fe(gt,{ErrorCategory:()=>qe,InterfaceLanguage:()=>Ye,Logger:()=>P,Observable:()=>a,Subject:()=>I,Subscription:()=>m,VERSION:()=>me,VKNumericLanguage:()=>Ke,ValueSubject:()=>S,VideoQuality:()=>V,abortable:()=>we,addScript:()=>ge,areQualitiesExact:()=>Ne,assertEmptyArray:()=>xe,assertNever:()=>h,assertNonNullable:()=>ve,assertNotEmptyArray:()=>Ie,assertNullable:()=>he,assertQualityIsExact:()=>Qe,buffer:()=>K,checkNever:()=>Te,clearVideoElement:()=>Fe,clientChecker:()=>Ee,cloneDeep:()=>Ue,cloneDeepWith:()=>E,combine:()=>G,debounce:()=>$,debounceFn:()=>Q,detectEmbed:()=>Re,fillWithDefault:()=>De,filter:()=>ee,filterChanged:()=>re,fromEvent:()=>Ge,getExponentialDelay:()=>Se,getHighestQuality:()=>Pe,interval:()=>je,isHigher:()=>Ae,isHigherOrEqual:()=>ke,isInvariantQuality:()=>N,isLower:()=>_,isLowerOrEqual:()=>Ce,isMobile:()=>j,isNonNullable:()=>y,isNullable:()=>L,loadVKLangPack:()=>ht,map:()=>R,mapTo:()=>ie,merge:()=>H,noop:()=>x,now:()=>Oe,observableFrom:()=>We,observeElementSize:()=>Be,once:()=>oe,pairwise:()=>ae,safeStorage:()=>M,tap:()=>ce,throttle:()=>J,throttleFn:()=>D,timeCodeToString:()=>dt,timeout:()=>ze,videoHeightToQuality:()=>Me,videoQualityToHeight:()=>_e,videoSizeToQuality:()=>Ve});module.exports=st(gt);var me="1.0.38-dev.abb9bed7.0";var m=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(t=>typeof t=="function"?t():t.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var h=r=>{throw new Error(`${r} is value of unexpected type`)},Te=r=>{};var x=()=>{};var a=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,t){var l;let n;t?typeof t=="function"?n={next:t,error:x}:n={next:o=>t.next(o),error:o=>{var u;return(u=t.error)==null?void 0:u.call(t,o)}}:n={next:x,error:x};let i=typeof e=="function"?{next:o=>{try{e(o)}catch(u){n.next(u)}},error:o=>n.next(o)}:{next:o=>e.next(o),error:o=>e.error?e.error(o):n.next(o)},s;try{s=this._subscribe(i)}catch(o){(l=i.error)==null||l.call(i,o)}return new m().add(()=>{switch(i.next=x,i.error=x,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return h(s)}})}pipe(...e){return e.reduce((t,n)=>n(t),this)}_subscribe(e){}};var I=class extends a{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(t){this.subscribers.forEach(n=>n.next(t))}error(t){this.subscribers.forEach(n=>{var i;return(i=n.error)==null?void 0:i.call(n,t)})}_subscribe(t){let n=this.keyCounter++;return this.subscribers.set(n,t),new m().add(()=>this.subscribers.delete(n))}};var P=class{constructor(){this.log$=new I;this.logs=[];this.log=e=>{let t={...e,timestamp:Date.now()};this.logs.push(t),this.log$.next(t)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...t)=>{let n;try{n=e(...t)}catch(i){n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(t=>({component:e,...t}))}};function ve(r,e='Assertion "value is not nullable" failed'){if(r==null)throw new Error(e)}function he(r,e='Assertion "value is nullable" failed'){if(r!=null)throw new Error(e)}function y(r){return typeof r!="undefined"&&r!==null}function L(r){return r==null}function Ie(r,e){if(!(r!=null&&r.length))throw new Error(e)}function xe(r,e){if(r!=null&&r.length)throw new Error(e)}var ge=(r,e,t)=>new Promise((n,i)=>{e.addEventListener("abort",()=>{o(),p.remove()});let s=()=>{o(),i()},l=()=>{o(),n()},o=()=>{u&&clearTimeout(u),p.removeEventListener("load",l),p.removeEventListener("error",s)},u;t&&(u=window.setTimeout(s,t));let p=document.createElement("script");p.addEventListener("load",l),p.addEventListener("error",s),p.src=r,document.head.appendChild(p)});var ye,Oe=typeof((ye=window.performance)==null?void 0:ye.now)=="function"?()=>window.performance.now():()=>Date.now();var we=(r,e)=>async(...t)=>{var l;let n=e(...t),i=r.aborted,s;for(;!i&&!r.aborted;)try{let o=await n.next(s);i=(l=o.done)!=null?l:!1,s=o.value}catch(o){await n.throw(o)}return s};var j=()=>{var r,e;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test((r=navigator.appVersion)!=null?r:navigator.userAgent)||((e=navigator==null?void 0:navigator.userAgentData)==null?void 0:e.mobile)},z=class{constructor(){this.detect()}get browser(){return this._currentBrowser}get device(){return this._currentDevice}get isTouch(){return this._maxTouchPoints>0}get isIOS(){return["iPhone","iPad","iPod"].includes(this.device)}get isMac(){return this.device==="Mac"}get isApple(){return this.isIOS||this.isMac}get isIphoneOrOldIpad(){if(!this.isApple||!this.isTouch)return!1;let e=this.device==="iPad"||(window==null?void 0:window.screen.width)>700,t=this._iosVersion;return!e||e&&!!t&&t<16}get isAndroid(){return this.device==="Android"}get isMobile(){return this._isMobile}get iOSVersion(){return this._iosVersion}get macVersion(){return this._macVersion}get isYandex(){return this.browser==="Yandex"}get isSafari(){return this.browser==="Safari"}get isSamsungBrowser(){return this.browser==="SamsungBrowser"}get isHDR(){return this._isHdr}detect(){var n;let{userAgent:e,maxTouchPoints:t}=navigator;try{this._maxTouchPoints=t,this._isHdr=!!((n=matchMedia("(dynamic-range: high)"))!=null&&n.matches)}catch(i){console.error(i)}try{this._isMobile=j()}catch(i){console.error(i)}this.detectBrowser(e),this.detectDevice(e),this.isIOS&&this.detectIOSVersion(),this.isMac&&this.detectMacVersion()}detectBrowser(e){try{let t=/yabrowser/i.test(e)?"Yandex":void 0,n=/samsungbrowser/i.test(e)?"SamsungBrowser":void 0,i=/chrome|crios/i.test(e)?"Chrome":void 0,s=/chromium/i.test(e)?"Chromium":void 0,l=/firefox|fxios/i.test(e)?"Firefox":void 0,o=/webkit|safari|khtml/i.test(e)?"Safari":void 0,u=/opr\//i.test(e)?"Opera":void 0,p=/edg/i.test(e)?"Edge":void 0;this._currentBrowser=t||n||l||u||p||i||s||o||"Rest"}catch(t){console.error(t)}}detectDevice(e){try{let t=/android/i.test(e)?"Android":void 0,n=/iphone/i.test(e)?"iPhone":void 0,i=/ipad/i.test(e)?"iPad":void 0,s=/ipod/i.test(e)?"iPod":void 0,l=/mac/i.test(e)?"Mac":void 0,o=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(e)?"RestMobile":void 0;this._currentDevice=t||n||i||s||o||l||"Desktop"}catch(t){console.error(t)}}detectIOSVersion(){try{let{userAgent:e}=window.navigator,t=e.match(/Version\/(\d+(\.\d+)?)/i);if(!t)return;let n=t[1],i=parseFloat(n);if(isNaN(i))return;this._iosVersion=i}catch(e){console.error(e)}}detectMacVersion(){try{let{userAgent:e}=window.navigator,t=e.match(/Version\/(\d+)/);if(!t)return;let n=t[1],i=parseInt(n,10);if(isNaN(i))return;this._macVersion=i}catch(e){console.error(e)}}},Ee=new z;var Se=(r,{start:e=0,factor:t=2,max:n=1/0,min:i=e,random:s=0}={})=>{let l=e;return l*=t**r,l*=1+(Math.random()*s*2-s),l=Math.round(l),l=Math.min(l,n),l=Math.max(l,i),l};var M={};fe(M,{clear:()=>bt,get:()=>lt,has:()=>ut,isPersistent:()=>at,remove:()=>pt,set:()=>ct});var d,O,W=`vk-videoplayer-dummy-key-${Math.random()}`,w=()=>{if(O!==void 0)return O;try{localStorage.setItem(W,"test"),localStorage.removeItem(W),O=0}catch(r){if(r instanceof DOMException||r instanceof TypeError)try{sessionStorage.getItem(W),O=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)O=2;else throw e}else throw r}return O===2&&(d=new Map),O},at=()=>w()===0,lt=r=>{var t,n;let e=w();switch(e){case 0:return(t=localStorage.getItem(r))!=null?t:void 0;case 1:return(n=sessionStorage.getItem(r))!=null?n:void 0;case 2:return d==null?void 0:d.get(r);default:h(e)}},ct=(r,e)=>{let t=w();switch(t){case 0:try{localStorage.setItem(r,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(r,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void(d==null?void 0:d.set(r,e));default:h(t)}},ut=r=>{var t;let e=w();switch(e){case 0:return r in localStorage;case 1:return r in sessionStorage;case 2:return(t=d==null?void 0:d.has(r))!=null?t:!1;default:return h(e),!1}},pt=r=>{let e=w();switch(e){case 0:return localStorage.removeItem(r);case 1:return sessionStorage.removeItem(r);case 2:return void(d==null?void 0:d.delete(r));default:h(e)}},bt=()=>{let r=w();switch(r){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return d==null?void 0:d.clear();default:h(r)}};var Re=()=>{let r,e;try{r=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?r=!0:(r=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let t=e?new URL(e).hostname:void 0;return{isEmbed:r,host:t}};var V=(f=>(f.INVARIANT="Invariant quality",f.Q_144P="144p",f.Q_240P="240p",f.Q_360P="360p",f.Q_480P="480p",f.Q_720P="720p",f.Q_1080P="1080p",f.Q_1440P="1440p",f.Q_2160P="2160p",f.Q_4320P="4320p",f))(V||{});var T={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"720p":{width:1280,height:720},"1080p":{width:1920,height:1080},"1440p":{width:2560,height:1440},"2160p":{width:3840,height:2160},"4320p":{width:7680,height:4320}},Ae=(r,e)=>T[r].height>T[e].height,ke=(r,e)=>T[r].height>=T[e].height,_=(r,e)=>T[r].height<T[e].height,Ce=(r,e)=>T[r].height<=T[e].height,Pe=r=>r.sort((e,t)=>e===t?0:e==="Invariant quality"?1:t==="Invariant quality"?-1:_(e,t)?1:-1)[0],Le=Object.keys(T).sort((r,e)=>_(r,e)?-1:1),Me=(r,e=.02)=>[...Le].find(n=>T[n].height*(1+e)>=r),Ve=({width:r,height:e})=>{let t=Math.min(r,e),n=Math.max(r,e);return Le.find(i=>{let s=T[i];return s.width>=n&&s.height>=t})},_e=r=>T[r].height,N=r=>r==="Invariant quality",Ne=r=>r.every(e=>!N(e));function Qe(r){if(N(r))throw new Error("Expected exact quality")}var De=(r,e)=>{let t={};for(let n of Object.keys(e)){let i=e[n],s=r[n];Array.isArray(i)&&Array.isArray(s)?t[n]=s:typeof i=="object"&&typeof s=="object"?t[n]=De(s,i):t[n]=n in r?s:i}return t};var dt=r=>{let e="";return r>=3600&&(e+=Math.floor(r/3600)+"h",r=r%3600),r>=60&&(e+=Math.floor(r/60)+"m",r=r%60),r>0&&(e+=Math.floor(r)+"s"),e};function Q(r,e=0,t){let n,i,s,l,o,u,p=0,f=!1,b=!1,U=!0,ue=!e&&e!==0&&typeof window.requestAnimationFrame=="function";t&&(f=!!t.leading,b="maxWait"in t,s=t!=null&&t.maxWait?Math.max(+(t==null?void 0:t.maxWait)||0,e):s,U="trailing"in t?!!t.trailing:U);function B(c){let v=n,g=i;return n=i=void 0,p=c,l=r.apply(g,v),l}function A(c,v){return ue?(o&&window.cancelAnimationFrame(o),window.requestAnimationFrame(c)):setTimeout(c,v)}function $e(c){if(ue){window.cancelAnimationFrame(c);return}clearTimeout(c)}function Xe(c){return p=c,o=A(k,e),f?B(c):l}function Je(c){let v=c-u,g=c-p,de=e-v;return b?Math.min(de,s-g):de}function pe(c){let v=c-u,g=c-p;return u===void 0||v>=e||v<0||b&&g>=s}function k(){let c=Date.now();if(pe(c))return be(c);o=A(k,Je(c))}function be(c){return o=void 0,U&&n?B(c):(n=i=void 0,l)}function Ze(){o!==void 0&&$e(o),p=0,n=u=i=o=void 0}function et(){return o===void 0?l:be(Date.now())}function tt(){return o!==void 0}function C(...c){let v=Date.now(),g=pe(v);if(n=c,i=this,u=v,g){if(o===void 0)return Xe(u);if(b)return o=A(k,e),B(u)}return o===void 0&&(o=A(k,e)),l}return C.cancel=Ze,C.flush=et,C.pending=tt,C}var D=(r,e=0,t)=>Q(r,e,{...{leading:!0,trailing:!0},...t,maxWait:e});var E=(r,e)=>{if(r===null||typeof r!="object")return r;let t=Array.isArray(r)?[]:{};for(let n in r){if(typeof e=="function"){let i=e(r[n],n,r,t);if(i!==void 0){t[n]=i;continue}}typeof r[n]=="object"?t[n]=E(r[n],e):t[n]=r[n]}return t};var Ue=r=>E(r);var ft=300,Be=(r,e=ft)=>new a(t=>{let{width:n,height:i}=r.getBoundingClientRect();if(t.next({width:n,height:i}),!window.ResizeObserver)return;let s=new ResizeObserver(D(l=>{let o=l[0];if(!o)return;let u,p;o.contentBoxSize&&o.contentBoxSize[0]?(p=o.contentBoxSize[0].blockSize,u=o.contentBoxSize[0].inlineSize):o.contentRect&&(u=o.contentRect.width,p=o.contentRect.height),y(u)&&y(p)&&t.next({width:u,height:p})},e));return s.observe(r),()=>s.disconnect()});var Fe=r=>{r.removeAttribute("src"),r.load()};var S=class extends I{constructor(e){super(),this.value=e}next(e){super.next(this.value=e)}error(e){super.error(this.value=e)}getValue(){return this.value}_subscribe(e){let t=super._subscribe(e);return e.next(this.value),t}};function G(r){return new a(e=>{let t={},n=Object.keys(r).length,i=s=>l=>{s in t||n--,t[s]=l,n===0&&e.next(t)};return Object.entries(r).reduce((s,[l,o])=>s.add(o.subscribe(i(l))),new m)})}function H(...r){return new a(e=>r.reduce((t,n)=>t.add(n.subscribe(e)),new m))}var ze=r=>new a(e=>{let t=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},r);return()=>window.clearTimeout(t)});var je=r=>new a(e=>{let t=window.setInterval(()=>e.next(),r);return()=>{t&&(window.clearInterval(t),t=void 0)}});var We=r=>new a(e=>{r.forEach(t=>e.next(t))});var Ge=(r,e)=>new a(t=>{let n=i=>t.next(i);return r.addEventListener(e,n),()=>r.removeEventListener(e,n)});function K(r){return e=>new a(t=>e.subscribe(new q(t,r)))}var q=class{constructor(e,t){this.destination=e;this.size=t;this.lastValues=[]}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};var mt={leading:!1,trailing:!0};function $(r,e=mt){return t=>new a(n=>t.subscribe(new Y(n,r,e)))}var Y=class{constructor(e,t,n){this.destination=e;this.time=t;this.config=n}next(e){this.lastValue=e,y(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(t){if(this.destination.error)this.destination.error(t);else throw t}this.timeout=void 0},this.time)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};var Tt={leading:!0,trailing:!1};function J(r,e=Tt){return t=>new a(n=>t.subscribe(new X(n,r,e)))}var X=class{constructor(e,t,n){this.destination=e;this.time=t;this.config=n}next(e){this.lastValue=e,L(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function ee(r){return e=>new a(t=>e.subscribe(new Z(t,r)))}var Z=class{constructor(e,t){this.destination=e;this.predicate=t}next(e){let t;try{t=this.predicate(e)}catch(n){throw this.error(n),n}t&&this.destination.next(e)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function re(r=(e,t)=>e===t){return e=>new a(t=>e.subscribe(new te(t,r)))}var He={},te=class{constructor(e,t){this.destination=e;this.predicate=t;this.lastValue=He}next(e){let t;try{t=this.lastValue===He||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}t&&this.destination.next(e)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function R(r){return e=>new a(t=>e.subscribe(new ne(t,r)))}var ne=class{constructor(e,t){this.destination=e;this.mapper=t}next(e){let t;try{t=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(t)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function ie(r){return R(()=>r)}function oe(){return r=>new a(e=>{let t=!1,n=!1,i=r.subscribe(s=>{t||(t=!0,e.next(s)),n&&i.unsubscribe()},s=>{var l;t=!0,(l=e.error)==null||l.call(e,s),n&&i.unsubscribe()});return n=!0,t&&i.unsubscribe(),i})}function ae(){return r=>new a(e=>r.subscribe(new se(e)))}var se=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let t=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([t,e])}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function ce(r){return e=>new a(t=>e.subscribe(new le(t,r)))}var le=class{constructor(e,t){this.destination=e;this.effect=t}next(e){try{this.effect(e)}catch(t){throw this.error(t),t}this.destination.next(e)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};var qe=(o=>(o.NETWORK="network",o.VIDEO_PIPELINE="video_pipeline",o.EXTERNAL_API="external_api",o.PARSER="parser",o.DOM="dom",o.WTF="wtf",o.FATAL="fatal",o))(qe||{});var Ke=(b=>(b.Armenian="58",b.Azerbaijani="57",b.Belarusian="114",b.English="3",b.Kazakh="97",b.Portuguese="73",b.Russian="0",b.Spanish="4",b.Ukrainian="1",b.Uzbek="65",b.Vietnamese="75",b))(Ke||{}),vt="vk.com",ht=async(r,e,t)=>{let n=new URL(`https://${vt}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),r!==void 0&&n.searchParams.set("lang",r);let s=await(await fetch(n.toString())).json();return It(s,t)},It=(r,e)=>Object.fromEntries(Object.entries(r.keys).map(([t,n])=>[t.substring(`${e}_`.length),xt(n)])),xt=r=>Array.isArray(r)?r[0]:r;var Ye=(t=>(t.RU="ru",t.EN="en",t))(Ye||{});
package/es2018.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @vkontakte/videoplayer-shared v1.0.38-dev.87754f30.0
3
- * Tue, 06 Aug 2024 11:52:24 GMT
2
+ * @vkontakte/videoplayer-shared v1.0.38-dev.abb9bed7.0
3
+ * Mon, 19 Aug 2024 11:00:39 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-38/doc/
5
5
  */
6
- var Oe=Object.defineProperty;var we=(t,e)=>{for(var r in e)Oe(t,r,{get:e[r],enumerable:!0})};var Ee="1.0.38-dev.87754f30.0";var m=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(r=>typeof r=="function"?r():r.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var I=t=>{throw new Error(`${t} is value of unexpected type`)},Se=t=>{};var g=()=>{};var a=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,r){var l;let n;r?typeof r=="function"?n={next:r,error:g}:n={next:o=>r.next(o),error:o=>{var u;return(u=r.error)==null?void 0:u.call(r,o)}}:n={next:g,error:g};let i=typeof e=="function"?{next:o=>{try{e(o)}catch(u){n.next(u)}},error:o=>n.next(o)}:{next:o=>e.next(o),error:o=>e.error?e.error(o):n.next(o)},s;try{s=this._subscribe(i)}catch(o){(l=i.error)==null||l.call(i,o)}return new m().add(()=>{switch(i.next=g,i.error=g,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return I(s)}})}pipe(...e){return e.reduce((r,n)=>n(r),this)}_subscribe(e){}};var x=class extends a{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(r){this.subscribers.forEach(n=>n.next(r))}error(r){this.subscribers.forEach(n=>{var i;return(i=n.error)==null?void 0:i.call(n,r)})}_subscribe(r){let n=this.keyCounter++;return this.subscribers.set(n,r),new m().add(()=>this.subscribers.delete(n))}};var V=class{constructor(){this.log$=new x;this.logs=[];this.log=e=>{let r={...e,timestamp:Date.now()};this.logs.push(r),this.log$.next(r)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...r)=>{let n;try{n=e(...r)}catch(i){n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(r=>({component:e,...r}))}};function Ae(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function Re(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function O(t){return typeof t!="undefined"&&t!==null}function Q(t){return t==null}function Ce(t,e){if(!(t!=null&&t.length))throw new Error(e)}function ke(t,e){if(t!=null&&t.length)throw new Error(e)}var Le=(t,e,r)=>new Promise((n,i)=>{e.addEventListener("abort",()=>{o(),b.remove()});let s=()=>{o(),i()},l=()=>{o(),n()},o=()=>{u&&clearTimeout(u),b.removeEventListener("load",l),b.removeEventListener("error",s)},u;r&&(u=window.setTimeout(s,r));let b=document.createElement("script");b.addEventListener("load",l),b.addEventListener("error",s),b.src=t,document.head.appendChild(b)});var te,Pe=typeof((te=window.performance)==null?void 0:te.now)=="function"?()=>window.performance.now():()=>Date.now();var Me=(t,e)=>async(...r)=>{var l;let n=e(...r),i=t.aborted,s;for(;!i&&!t.aborted;)try{let o=await n.next(s);i=(l=o.done)!=null?l:!1,s=o.value}catch(o){await n.throw(o)}return s};var re=(c=>(c.Unknown="Unknown",c.Yandex="Yandex",c.Chrome="Chrome",c.Chromium="Chromium",c.Firefox="Firefox",c.Safari="Safari",c.Opera="Opera",c.Edge="Edge",c.SamsungBrowser="SamsungBrowser",c.Rest="Rest",c))(re||{}),ne=(u=>(u.Unknown="Unknown",u.Android="Android",u.iPhone="iPhone",u.iPad="iPad",u.iPod="iPod",u.RestMobile="RestMobile",u.Mac="Mac",u.Desktop="Desktop",u))(ne||{}),L=()=>{let{userAgent:t}=window.navigator,e=/yabrowser/i.test(t)?"Yandex":void 0,r=/samsungbrowser/i.test(t)?"SamsungBrowser":void 0,n=/chrome|crios/i.test(t)?"Chrome":void 0,i=/chromium/i.test(t)?"Chromium":void 0,s=/firefox|fxios/i.test(t)?"Firefox":void 0,l=/webkit|safari|khtml/i.test(t)?"Safari":void 0,o=/opr\//i.test(t)?"Opera":void 0,u=/edg/i.test(t)?"Edge":void 0,b=/android/i.test(t)?"Android":void 0,c=/iphone/i.test(t)?"iPhone":void 0,d=/ipad/i.test(t)?"iPad":void 0,E=/ipod/i.test(t)?"iPod":void 0,A=/mac/i.test(t)?"Mac":void 0,S=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(t)?"RestMobile":void 0;return{browser:e||r||s||o||u||n||i||l||"Rest",device:b||c||d||E||S||A||"Desktop"}},Ne=(t=!1)=>{let r=["iPhone","iPad","iPod"].includes(L().device);if(!t)return r;let{userAgent:n,maxTouchPoints:i}=window.navigator;return!!(r||/macintosh/i.test(n)&&i>0)},Ve=()=>{let{userAgent:t}=window.navigator,e=t.match(/Version\/(\d+(\.\d+)?)/i);if(!e)return null;let r=e[1],n=parseFloat(r);return isNaN(n)?null:n},Qe=()=>L().device==="Android",_e=()=>["Mac","iPhone","iPad","iPod"].includes(L().device),De=()=>{var t,e;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test((t=navigator.appVersion)!=null?t:navigator.userAgent)||((e=navigator==null?void 0:navigator.userAgentData)==null?void 0:e.mobile)};var Ue=(t,{start:e=0,factor:r=2,max:n=1/0,min:i=e,random:s=0}={})=>{let l=e;return l*=r**t,l*=1+(Math.random()*s*2-s),l=Math.round(l),l=Math.min(l,n),l=Math.max(l,i),l};var D={};we(D,{clear:()=>Ge,get:()=>Fe,has:()=>je,isPersistent:()=>Be,remove:()=>We,set:()=>ze});var f,y,_=`vk-videoplayer-dummy-key-${Math.random()}`,w=()=>{if(y!==void 0)return y;try{localStorage.setItem(_,"test"),localStorage.removeItem(_),y=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem(_),y=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)y=2;else throw e}else throw t}return y===2&&(f=new Map),y},Be=()=>w()===0,Fe=t=>{var r,n;let e=w();switch(e){case 0:return(r=localStorage.getItem(t))!=null?r:void 0;case 1:return(n=sessionStorage.getItem(t))!=null?n:void 0;case 2:return f==null?void 0:f.get(t);default:I(e)}},ze=(t,e)=>{let r=w();switch(r){case 0:try{localStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void(f==null?void 0:f.set(t,e));default:I(r)}},je=t=>{var r;let e=w();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return(r=f==null?void 0:f.has(t))!=null?r:!1;default:return I(e),!1}},We=t=>{let e=w();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:return void(f==null?void 0:f.delete(t));default:I(e)}},Ge=()=>{let t=w();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return f==null?void 0:f.clear();default:I(t)}};var qe=()=>{let t,e;try{t=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?t=!0:(t=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let r=e?new URL(e).hostname:void 0;return{isEmbed:t,host:r}};var U=(c=>(c.INVARIANT="Invariant quality",c.Q_144P="144p",c.Q_240P="240p",c.Q_360P="360p",c.Q_480P="480p",c.Q_720P="720p",c.Q_1080P="1080p",c.Q_1440P="1440p",c.Q_2160P="2160p",c.Q_4320P="4320p",c))(U||{});var T={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"720p":{width:1280,height:720},"1080p":{width:1920,height:1080},"1440p":{width:2560,height:1440},"2160p":{width:3840,height:2160},"4320p":{width:7680,height:4320}},He=(t,e)=>T[t].height>T[e].height,Ke=(t,e)=>T[t].height>=T[e].height,B=(t,e)=>T[t].height<T[e].height,$e=(t,e)=>T[t].height<=T[e].height,Ye=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:B(e,r)?1:-1)[0],oe=Object.keys(T).sort((t,e)=>B(t,e)?-1:1),Xe=(t,e=.02)=>[...oe].find(n=>T[n].height*(1+e)>=t),Je=({width:t,height:e})=>{let r=Math.min(t,e),n=Math.max(t,e);return oe.find(i=>{let s=T[i];return s.width>=n&&s.height>=r})},Ze=t=>T[t].height,F=t=>t==="Invariant quality",et=t=>t.every(e=>!F(e));function tt(t){if(F(t))throw new Error("Expected exact quality")}var rt=(t,e)=>{let r={};for(let n of Object.keys(e)){let i=e[n],s=t[n];Array.isArray(i)&&Array.isArray(s)?r[n]=s:typeof i=="object"&&typeof s=="object"?r[n]=rt(s,i):r[n]=n in t?s:i}return r};var Ht=t=>{let e="";return t>=3600&&(e+=Math.floor(t/3600)+"h",t=t%3600),t>=60&&(e+=Math.floor(t/60)+"m",t=t%60),t>0&&(e+=Math.floor(t)+"s"),e};function z(t,e=0,r){let n,i,s,l,o,u,b=0,c=!1,d=!1,E=!0,A=!e&&e!==0&&typeof window.requestAnimationFrame=="function";r&&(c=!!r.leading,d="maxWait"in r,s=r!=null&&r.maxWait?Math.max(+(r==null?void 0:r.maxWait)||0,e):s,E="trailing"in r?!!r.trailing:E);function S(p){let v=n,h=i;return n=i=void 0,b=p,l=t.apply(h,v),l}function R(p,v){return A?(o&&window.cancelAnimationFrame(o),window.requestAnimationFrame(p)):setTimeout(p,v)}function ve(p){if(A){window.cancelAnimationFrame(p);return}clearTimeout(p)}function Ie(p){return b=p,o=R(C,e),c?S(p):l}function xe(p){let v=p-u,h=p-b,ee=e-v;return d?Math.min(ee,s-h):ee}function J(p){let v=p-u,h=p-b;return u===void 0||v>=e||v<0||d&&h>=s}function C(){let p=Date.now();if(J(p))return Z(p);o=R(C,xe(p))}function Z(p){return o=void 0,E&&n?S(p):(n=i=void 0,l)}function he(){o!==void 0&&ve(o),b=0,n=u=i=o=void 0}function ge(){return o===void 0?l:Z(Date.now())}function ye(){return o!==void 0}function k(...p){let v=Date.now(),h=J(v);if(n=p,i=this,u=v,h){if(o===void 0)return Ie(u);if(d)return o=R(C,e),S(u)}return o===void 0&&(o=R(C,e)),l}return k.cancel=he,k.flush=ge,k.pending=ye,k}var j=(t,e=0,r)=>z(t,e,{...{leading:!0,trailing:!0},...r,maxWait:e});var P=(t,e)=>{if(t===null||typeof t!="object")return t;let r=Array.isArray(t)?[]:{};for(let n in t){if(typeof e=="function"){let i=e(t[n],n,t,r);if(i!==void 0){r[n]=i;continue}}typeof t[n]=="object"?r[n]=P(t[n],e):r[n]=t[n]}return r};var nt=t=>P(t);var ot=300,it=(t,e=ot)=>new a(r=>{let{width:n,height:i}=t.getBoundingClientRect();if(r.next({width:n,height:i}),!window.ResizeObserver)return;let s=new ResizeObserver(j(l=>{let o=l[0];if(!o)return;let u,b;o.contentBoxSize&&o.contentBoxSize[0]?(b=o.contentBoxSize[0].blockSize,u=o.contentBoxSize[0].inlineSize):o.contentRect&&(u=o.contentRect.width,b=o.contentRect.height),O(u)&&O(b)&&r.next({width:u,height:b})},e));return s.observe(t),()=>s.disconnect()});var M=class extends x{constructor(r){super();this.value=r}next(r){super.next(this.value=r)}error(r){super.error(this.value=r)}getValue(){return this.value}_subscribe(r){let n=super._subscribe(r);return r.next(this.value),n}};function ie(t){return new a(e=>{let r={},n=Object.keys(t).length,i=s=>l=>{s in r||n--,r[s]=l,n===0&&e.next(r)};return Object.entries(t).reduce((s,[l,o])=>s.add(o.subscribe(i(l))),new m)})}function se(...t){return new a(e=>t.reduce((r,n)=>r.add(n.subscribe(e)),new m))}var st=t=>new a(e=>{let r=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},t);return()=>window.clearTimeout(r)});var at=t=>new a(e=>{let r=window.setInterval(()=>e.next(),t);return()=>{r&&(window.clearInterval(r),r=void 0)}});var lt=t=>new a(e=>{t.forEach(r=>e.next(r))});var ut=(t,e)=>new a(r=>{let n=i=>r.next(i);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)});function ae(t){return e=>new a(r=>e.subscribe(new W(r,t)))}var W=class{constructor(e,r){this.destination=e;this.size=r;this.lastValues=[]}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};var ct={leading:!1,trailing:!0};function le(t,e=ct){return r=>new a(n=>r.subscribe(new G(n,t,e)))}var G=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,O(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(r){if(this.destination.error)this.destination.error(r);else throw r}this.timeout=void 0},this.time)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};var pt={leading:!0,trailing:!1};function ue(t,e=pt){return r=>new a(n=>r.subscribe(new q(n,t,e)))}var q=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,Q(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function ce(t){return e=>new a(r=>e.subscribe(new H(r,t)))}var H=class{constructor(e,r){this.destination=e;this.predicate=r}next(e){let r;try{r=this.predicate(e)}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function be(t=(e,r)=>e===r){return e=>new a(r=>e.subscribe(new K(r,t)))}var pe={},K=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=pe}next(e){let r;try{r=this.lastValue===pe||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function N(t){return e=>new a(r=>e.subscribe(new $(r,t)))}var $=class{constructor(e,r){this.destination=e;this.mapper=r}next(e){let r;try{r=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(r)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function de(t){return N(()=>t)}function fe(){return t=>new a(e=>{let r=!1,n=!1,i=t.subscribe(s=>{r||(r=!0,e.next(s)),n&&i.unsubscribe()},s=>{var l;r=!0,(l=e.error)==null||l.call(e,s),n&&i.unsubscribe()});return n=!0,r&&i.unsubscribe(),i})}function me(){return t=>new a(e=>t.subscribe(new Y(e)))}var Y=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let r=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([r,e])}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};function Te(t){return e=>new a(r=>e.subscribe(new X(r,t)))}var X=class{constructor(e,r){this.destination=e;this.effect=r}next(e){try{this.effect(e)}catch(r){throw this.error(r),r}this.destination.next(e)}error(e){var r,n;(n=(r=this.destination).error)==null||n.call(r,e)}};var bt=(o=>(o.NETWORK="network",o.VIDEO_PIPELINE="video_pipeline",o.EXTERNAL_API="external_api",o.PARSER="parser",o.DOM="dom",o.WTF="wtf",o.FATAL="fatal",o))(bt||{});var dt=(d=>(d.Armenian="58",d.Azerbaijani="57",d.Belarusian="114",d.English="3",d.Kazakh="97",d.Portuguese="73",d.Russian="0",d.Spanish="4",d.Ukrainian="1",d.Uzbek="65",d.Vietnamese="75",d))(dt||{}),ft="vk.com",Qn=async(t,e,r)=>{let n=new URL(`https://${ft}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),t!==void 0&&n.searchParams.set("lang",t);let s=await(await fetch(n.toString())).json();return mt(s,r)},mt=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,n])=>[r.substring(`${e}_`.length),Tt(n)])),Tt=t=>Array.isArray(t)?t[0]:t;var vt=(r=>(r.RU="ru",r.EN="en",r))(vt||{});export{re as CurrentClientBrowser,ne as CurrentClientDevice,bt as ErrorCategory,vt as InterfaceLanguage,V as Logger,a as Observable,x as Subject,m as Subscription,Ee as VERSION,dt as VKNumericLanguage,M as ValueSubject,U as VideoQuality,Me as abortable,Le as addScript,et as areQualitiesExact,ke as assertEmptyArray,I as assertNever,Ae as assertNonNullable,Ce as assertNotEmptyArray,Re as assertNullable,tt as assertQualityIsExact,ae as buffer,Se as checkNever,nt as cloneDeep,P as cloneDeepWith,ie as combine,le as debounce,z as debounceFn,qe as detectEmbed,rt as fillWithDefault,ce as filter,be as filterChanged,ut as fromEvent,L as getCurrentBrowser,Ue as getExponentialDelay,Ye as getHighestQuality,Ve as getIOSVersion,at as interval,Qe as isAndroid,He as isHigher,Ke as isHigherOrEqual,Ne as isIOS,F as isInvariantQuality,B as isLower,$e as isLowerOrEqual,_e as isMacLike,De as isMobile,O as isNonNullable,Q as isNullable,Qn as loadVKLangPack,N as map,de as mapTo,se as merge,g as noop,Pe as now,lt as observableFrom,it as observeElementSize,fe as once,me as pairwise,D as safeStorage,Te as tap,ue as throttle,j as throttleFn,Ht as timeCodeToString,st as timeout,Xe as videoHeightToQuality,Ze as videoQualityToHeight,Je as videoSizeToQuality};
6
+ var ye=Object.defineProperty;var Oe=(r,e)=>{for(var t in e)ye(r,t,{get:e[t],enumerable:!0})};var we="1.0.38-dev.abb9bed7.0";var m=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(t=>typeof t=="function"?t():t.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var h=r=>{throw new Error(`${r} is value of unexpected type`)},Ee=r=>{};var g=()=>{};var l=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,t){var a;let n;t?typeof t=="function"?n={next:t,error:g}:n={next:i=>t.next(i),error:i=>{var u;return(u=t.error)==null?void 0:u.call(t,i)}}:n={next:g,error:g};let o=typeof e=="function"?{next:i=>{try{e(i)}catch(u){n.next(u)}},error:i=>n.next(i)}:{next:i=>e.next(i),error:i=>e.error?e.error(i):n.next(i)},s;try{s=this._subscribe(o)}catch(i){(a=o.error)==null||a.call(o,i)}return new m().add(()=>{switch(o.next=g,o.error=g,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return h(s)}})}pipe(...e){return e.reduce((t,n)=>n(t),this)}_subscribe(e){}};var I=class extends l{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(t){this.subscribers.forEach(n=>n.next(t))}error(t){this.subscribers.forEach(n=>{var o;return(o=n.error)==null?void 0:o.call(n,t)})}_subscribe(t){let n=this.keyCounter++;return this.subscribers.set(n,t),new m().add(()=>this.subscribers.delete(n))}};var M=class{constructor(){this.log$=new I;this.logs=[];this.log=e=>{let t={...e,timestamp:Date.now()};this.logs.push(t),this.log$.next(t)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...t)=>{let n;try{n=e(...t)}catch(o){n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(t=>({component:e,...t}))}};function Se(r,e='Assertion "value is not nullable" failed'){if(r==null)throw new Error(e)}function Re(r,e='Assertion "value is nullable" failed'){if(r!=null)throw new Error(e)}function O(r){return typeof r!="undefined"&&r!==null}function V(r){return r==null}function Ae(r,e){if(!(r!=null&&r.length))throw new Error(e)}function ke(r,e){if(r!=null&&r.length)throw new Error(e)}var Ce=(r,e,t)=>new Promise((n,o)=>{e.addEventListener("abort",()=>{i(),p.remove()});let s=()=>{i(),o()},a=()=>{i(),n()},i=()=>{u&&clearTimeout(u),p.removeEventListener("load",a),p.removeEventListener("error",s)},u;t&&(u=window.setTimeout(s,t));let p=document.createElement("script");p.addEventListener("load",a),p.addEventListener("error",s),p.src=r,document.head.appendChild(p)});var te,Pe=typeof((te=window.performance)==null?void 0:te.now)=="function"?()=>window.performance.now():()=>Date.now();var Le=(r,e)=>async(...t)=>{var a;let n=e(...t),o=r.aborted,s;for(;!o&&!r.aborted;)try{let i=await n.next(s);o=(a=i.done)!=null?a:!1,s=i.value}catch(i){await n.throw(i)}return s};var re=()=>{var r,e;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test((r=navigator.appVersion)!=null?r:navigator.userAgent)||((e=navigator==null?void 0:navigator.userAgentData)==null?void 0:e.mobile)},_=class{constructor(){this.detect()}get browser(){return this._currentBrowser}get device(){return this._currentDevice}get isTouch(){return this._maxTouchPoints>0}get isIOS(){return["iPhone","iPad","iPod"].includes(this.device)}get isMac(){return this.device==="Mac"}get isApple(){return this.isIOS||this.isMac}get isIphoneOrOldIpad(){if(!this.isApple||!this.isTouch)return!1;let e=this.device==="iPad"||(window==null?void 0:window.screen.width)>700,t=this._iosVersion;return!e||e&&!!t&&t<16}get isAndroid(){return this.device==="Android"}get isMobile(){return this._isMobile}get iOSVersion(){return this._iosVersion}get macVersion(){return this._macVersion}get isYandex(){return this.browser==="Yandex"}get isSafari(){return this.browser==="Safari"}get isSamsungBrowser(){return this.browser==="SamsungBrowser"}get isHDR(){return this._isHdr}detect(){var n;let{userAgent:e,maxTouchPoints:t}=navigator;try{this._maxTouchPoints=t,this._isHdr=!!((n=matchMedia("(dynamic-range: high)"))!=null&&n.matches)}catch(o){console.error(o)}try{this._isMobile=re()}catch(o){console.error(o)}this.detectBrowser(e),this.detectDevice(e),this.isIOS&&this.detectIOSVersion(),this.isMac&&this.detectMacVersion()}detectBrowser(e){try{let t=/yabrowser/i.test(e)?"Yandex":void 0,n=/samsungbrowser/i.test(e)?"SamsungBrowser":void 0,o=/chrome|crios/i.test(e)?"Chrome":void 0,s=/chromium/i.test(e)?"Chromium":void 0,a=/firefox|fxios/i.test(e)?"Firefox":void 0,i=/webkit|safari|khtml/i.test(e)?"Safari":void 0,u=/opr\//i.test(e)?"Opera":void 0,p=/edg/i.test(e)?"Edge":void 0;this._currentBrowser=t||n||a||u||p||o||s||i||"Rest"}catch(t){console.error(t)}}detectDevice(e){try{let t=/android/i.test(e)?"Android":void 0,n=/iphone/i.test(e)?"iPhone":void 0,o=/ipad/i.test(e)?"iPad":void 0,s=/ipod/i.test(e)?"iPod":void 0,a=/mac/i.test(e)?"Mac":void 0,i=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(e)?"RestMobile":void 0;this._currentDevice=t||n||o||s||i||a||"Desktop"}catch(t){console.error(t)}}detectIOSVersion(){try{let{userAgent:e}=window.navigator,t=e.match(/Version\/(\d+(\.\d+)?)/i);if(!t)return;let n=t[1],o=parseFloat(n);if(isNaN(o))return;this._iosVersion=o}catch(e){console.error(e)}}detectMacVersion(){try{let{userAgent:e}=window.navigator,t=e.match(/Version\/(\d+)/);if(!t)return;let n=t[1],o=parseInt(n,10);if(isNaN(o))return;this._macVersion=o}catch(e){console.error(e)}}},Me=new _;var Ve=(r,{start:e=0,factor:t=2,max:n=1/0,min:o=e,random:s=0}={})=>{let a=e;return a*=t**r,a*=1+(Math.random()*s*2-s),a=Math.round(a),a=Math.min(a,n),a=Math.max(a,o),a};var Q={};Oe(Q,{clear:()=>Be,get:()=>Ne,has:()=>De,isPersistent:()=>_e,remove:()=>Ue,set:()=>Qe});var d,y,N=`vk-videoplayer-dummy-key-${Math.random()}`,w=()=>{if(y!==void 0)return y;try{localStorage.setItem(N,"test"),localStorage.removeItem(N),y=0}catch(r){if(r instanceof DOMException||r instanceof TypeError)try{sessionStorage.getItem(N),y=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)y=2;else throw e}else throw r}return y===2&&(d=new Map),y},_e=()=>w()===0,Ne=r=>{var t,n;let e=w();switch(e){case 0:return(t=localStorage.getItem(r))!=null?t:void 0;case 1:return(n=sessionStorage.getItem(r))!=null?n:void 0;case 2:return d==null?void 0:d.get(r);default:h(e)}},Qe=(r,e)=>{let t=w();switch(t){case 0:try{localStorage.setItem(r,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(r,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void(d==null?void 0:d.set(r,e));default:h(t)}},De=r=>{var t;let e=w();switch(e){case 0:return r in localStorage;case 1:return r in sessionStorage;case 2:return(t=d==null?void 0:d.has(r))!=null?t:!1;default:return h(e),!1}},Ue=r=>{let e=w();switch(e){case 0:return localStorage.removeItem(r);case 1:return sessionStorage.removeItem(r);case 2:return void(d==null?void 0:d.delete(r));default:h(e)}},Be=()=>{let r=w();switch(r){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return d==null?void 0:d.clear();default:h(r)}};var Fe=()=>{let r,e;try{r=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?r=!0:(r=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let t=e?new URL(e).hostname:void 0;return{isEmbed:r,host:t}};var D=(f=>(f.INVARIANT="Invariant quality",f.Q_144P="144p",f.Q_240P="240p",f.Q_360P="360p",f.Q_480P="480p",f.Q_720P="720p",f.Q_1080P="1080p",f.Q_1440P="1440p",f.Q_2160P="2160p",f.Q_4320P="4320p",f))(D||{});var T={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"720p":{width:1280,height:720},"1080p":{width:1920,height:1080},"1440p":{width:2560,height:1440},"2160p":{width:3840,height:2160},"4320p":{width:7680,height:4320}},ze=(r,e)=>T[r].height>T[e].height,je=(r,e)=>T[r].height>=T[e].height,U=(r,e)=>T[r].height<T[e].height,We=(r,e)=>T[r].height<=T[e].height,Ge=r=>r.sort((e,t)=>e===t?0:e==="Invariant quality"?1:t==="Invariant quality"?-1:U(e,t)?1:-1)[0],ne=Object.keys(T).sort((r,e)=>U(r,e)?-1:1),He=(r,e=.02)=>[...ne].find(n=>T[n].height*(1+e)>=r),qe=({width:r,height:e})=>{let t=Math.min(r,e),n=Math.max(r,e);return ne.find(o=>{let s=T[o];return s.width>=n&&s.height>=t})},Ke=r=>T[r].height,B=r=>r==="Invariant quality",Ye=r=>r.every(e=>!B(e));function $e(r){if(B(r))throw new Error("Expected exact quality")}var Xe=(r,e)=>{let t={};for(let n of Object.keys(e)){let o=e[n],s=r[n];Array.isArray(o)&&Array.isArray(s)?t[n]=s:typeof o=="object"&&typeof s=="object"?t[n]=Xe(s,o):t[n]=n in r?s:o}return t};var jt=r=>{let e="";return r>=3600&&(e+=Math.floor(r/3600)+"h",r=r%3600),r>=60&&(e+=Math.floor(r/60)+"m",r=r%60),r>0&&(e+=Math.floor(r)+"s"),e};function F(r,e=0,t){let n,o,s,a,i,u,p=0,f=!1,b=!1,P=!0,X=!e&&e!==0&&typeof window.requestAnimationFrame=="function";t&&(f=!!t.leading,b="maxWait"in t,s=t!=null&&t.maxWait?Math.max(+(t==null?void 0:t.maxWait)||0,e):s,P="trailing"in t?!!t.trailing:P);function L(c){let v=n,x=o;return n=o=void 0,p=c,a=r.apply(x,v),a}function E(c,v){return X?(i&&window.cancelAnimationFrame(i),window.requestAnimationFrame(c)):setTimeout(c,v)}function Te(c){if(X){window.cancelAnimationFrame(c);return}clearTimeout(c)}function ve(c){return p=c,i=E(S,e),f?L(c):a}function he(c){let v=c-u,x=c-p,ee=e-v;return b?Math.min(ee,s-x):ee}function J(c){let v=c-u,x=c-p;return u===void 0||v>=e||v<0||b&&x>=s}function S(){let c=Date.now();if(J(c))return Z(c);i=E(S,he(c))}function Z(c){return i=void 0,P&&n?L(c):(n=o=void 0,a)}function Ie(){i!==void 0&&Te(i),p=0,n=u=o=i=void 0}function xe(){return i===void 0?a:Z(Date.now())}function ge(){return i!==void 0}function R(...c){let v=Date.now(),x=J(v);if(n=c,o=this,u=v,x){if(i===void 0)return ve(u);if(b)return i=E(S,e),L(u)}return i===void 0&&(i=E(S,e)),a}return R.cancel=Ie,R.flush=xe,R.pending=ge,R}var z=(r,e=0,t)=>F(r,e,{...{leading:!0,trailing:!0},...t,maxWait:e});var A=(r,e)=>{if(r===null||typeof r!="object")return r;let t=Array.isArray(r)?[]:{};for(let n in r){if(typeof e=="function"){let o=e(r[n],n,r,t);if(o!==void 0){t[n]=o;continue}}typeof r[n]=="object"?t[n]=A(r[n],e):t[n]=r[n]}return t};var Je=r=>A(r);var Ze=300,et=(r,e=Ze)=>new l(t=>{let{width:n,height:o}=r.getBoundingClientRect();if(t.next({width:n,height:o}),!window.ResizeObserver)return;let s=new ResizeObserver(z(a=>{let i=a[0];if(!i)return;let u,p;i.contentBoxSize&&i.contentBoxSize[0]?(p=i.contentBoxSize[0].blockSize,u=i.contentBoxSize[0].inlineSize):i.contentRect&&(u=i.contentRect.width,p=i.contentRect.height),O(u)&&O(p)&&t.next({width:u,height:p})},e));return s.observe(r),()=>s.disconnect()});var tt=r=>{r.removeAttribute("src"),r.load()};var k=class extends I{constructor(e){super(),this.value=e}next(e){super.next(this.value=e)}error(e){super.error(this.value=e)}getValue(){return this.value}_subscribe(e){let t=super._subscribe(e);return e.next(this.value),t}};function ie(r){return new l(e=>{let t={},n=Object.keys(r).length,o=s=>a=>{s in t||n--,t[s]=a,n===0&&e.next(t)};return Object.entries(r).reduce((s,[a,i])=>s.add(i.subscribe(o(a))),new m)})}function oe(...r){return new l(e=>r.reduce((t,n)=>t.add(n.subscribe(e)),new m))}var rt=r=>new l(e=>{let t=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},r);return()=>window.clearTimeout(t)});var nt=r=>new l(e=>{let t=window.setInterval(()=>e.next(),r);return()=>{t&&(window.clearInterval(t),t=void 0)}});var it=r=>new l(e=>{r.forEach(t=>e.next(t))});var ot=(r,e)=>new l(t=>{let n=o=>t.next(o);return r.addEventListener(e,n),()=>r.removeEventListener(e,n)});function se(r){return e=>new l(t=>e.subscribe(new j(t,r)))}var j=class{constructor(e,t){this.destination=e;this.size=t;this.lastValues=[]}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};var st={leading:!1,trailing:!0};function ae(r,e=st){return t=>new l(n=>t.subscribe(new W(n,r,e)))}var W=class{constructor(e,t,n){this.destination=e;this.time=t;this.config=n}next(e){this.lastValue=e,O(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(t){if(this.destination.error)this.destination.error(t);else throw t}this.timeout=void 0},this.time)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};var at={leading:!0,trailing:!1};function le(r,e=at){return t=>new l(n=>t.subscribe(new G(n,r,e)))}var G=class{constructor(e,t,n){this.destination=e;this.time=t;this.config=n}next(e){this.lastValue=e,V(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function ce(r){return e=>new l(t=>e.subscribe(new H(t,r)))}var H=class{constructor(e,t){this.destination=e;this.predicate=t}next(e){let t;try{t=this.predicate(e)}catch(n){throw this.error(n),n}t&&this.destination.next(e)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function pe(r=(e,t)=>e===t){return e=>new l(t=>e.subscribe(new q(t,r)))}var ue={},q=class{constructor(e,t){this.destination=e;this.predicate=t;this.lastValue=ue}next(e){let t;try{t=this.lastValue===ue||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}t&&this.destination.next(e)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function C(r){return e=>new l(t=>e.subscribe(new K(t,r)))}var K=class{constructor(e,t){this.destination=e;this.mapper=t}next(e){let t;try{t=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(t)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function be(r){return C(()=>r)}function de(){return r=>new l(e=>{let t=!1,n=!1,o=r.subscribe(s=>{t||(t=!0,e.next(s)),n&&o.unsubscribe()},s=>{var a;t=!0,(a=e.error)==null||a.call(e,s),n&&o.unsubscribe()});return n=!0,t&&o.unsubscribe(),o})}function fe(){return r=>new l(e=>r.subscribe(new Y(e)))}var Y=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let t=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([t,e])}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};function me(r){return e=>new l(t=>e.subscribe(new $(t,r)))}var $=class{constructor(e,t){this.destination=e;this.effect=t}next(e){try{this.effect(e)}catch(t){throw this.error(t),t}this.destination.next(e)}error(e){var t,n;(n=(t=this.destination).error)==null||n.call(t,e)}};var lt=(i=>(i.NETWORK="network",i.VIDEO_PIPELINE="video_pipeline",i.EXTERNAL_API="external_api",i.PARSER="parser",i.DOM="dom",i.WTF="wtf",i.FATAL="fatal",i))(lt||{});var ct=(b=>(b.Armenian="58",b.Azerbaijani="57",b.Belarusian="114",b.English="3",b.Kazakh="97",b.Portuguese="73",b.Russian="0",b.Spanish="4",b.Ukrainian="1",b.Uzbek="65",b.Vietnamese="75",b))(ct||{}),ut="vk.com",Vn=async(r,e,t)=>{let n=new URL(`https://${ut}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),r!==void 0&&n.searchParams.set("lang",r);let s=await(await fetch(n.toString())).json();return pt(s,t)},pt=(r,e)=>Object.fromEntries(Object.entries(r.keys).map(([t,n])=>[t.substring(`${e}_`.length),bt(n)])),bt=r=>Array.isArray(r)?r[0]:r;var dt=(t=>(t.RU="ru",t.EN="en",t))(dt||{});export{lt as ErrorCategory,dt as InterfaceLanguage,M as Logger,l as Observable,I as Subject,m as Subscription,we as VERSION,ct as VKNumericLanguage,k as ValueSubject,D as VideoQuality,Le as abortable,Ce as addScript,Ye as areQualitiesExact,ke as assertEmptyArray,h as assertNever,Se as assertNonNullable,Ae as assertNotEmptyArray,Re as assertNullable,$e as assertQualityIsExact,se as buffer,Ee as checkNever,tt as clearVideoElement,Me as clientChecker,Je as cloneDeep,A as cloneDeepWith,ie as combine,ae as debounce,F as debounceFn,Fe as detectEmbed,Xe as fillWithDefault,ce as filter,pe as filterChanged,ot as fromEvent,Ve as getExponentialDelay,Ge as getHighestQuality,nt as interval,ze as isHigher,je as isHigherOrEqual,B as isInvariantQuality,U as isLower,We as isLowerOrEqual,re as isMobile,O as isNonNullable,V as isNullable,Vn as loadVKLangPack,C as map,be as mapTo,oe as merge,g as noop,Pe as now,it as observableFrom,et as observeElementSize,de as once,fe as pairwise,Q as safeStorage,me as tap,le as throttle,z as throttleFn,jt as timeCodeToString,rt as timeout,He as videoHeightToQuality,Ke as videoQualityToHeight,qe as videoSizeToQuality};
package/esnext.cjs.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @vkontakte/videoplayer-shared v1.0.38-dev.87754f30.0
3
- * Tue, 06 Aug 2024 11:52:24 GMT
2
+ * @vkontakte/videoplayer-shared v1.0.38-dev.abb9bed7.0
3
+ * Mon, 19 Aug 2024 11:00:39 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-38/doc/
5
5
  */
6
- "use strict";var z=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var st=Object.getOwnPropertyNames;var at=Object.prototype.hasOwnProperty;var me=(t,e)=>{for(var r in e)z(t,r,{get:e[r],enumerable:!0})},lt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of st(e))!at.call(t,o)&&o!==r&&z(t,o,{get:()=>e[o],enumerable:!(n=it(e,o))||n.enumerable});return t};var ut=t=>lt(z({},"__esModule",{value:!0}),t);var wt={};me(wt,{CurrentClientBrowser:()=>j,CurrentClientDevice:()=>W,ErrorCategory:()=>Ye,InterfaceLanguage:()=>Je,Logger:()=>V,Observable:()=>l,Subject:()=>I,Subscription:()=>f,VERSION:()=>Te,VKNumericLanguage:()=>Xe,ValueSubject:()=>C,VideoQuality:()=>_,abortable:()=>we,addScript:()=>ye,areQualitiesExact:()=>Be,assertEmptyArray:()=>he,assertNever:()=>v,assertNonNullable:()=>Ie,assertNotEmptyArray:()=>ge,assertNullable:()=>xe,assertQualityIsExact:()=>Fe,buffer:()=>Y,checkNever:()=>ve,cloneDeep:()=>je,cloneDeepWith:()=>R,combine:()=>H,debounce:()=>J,debounceFn:()=>B,detectEmbed:()=>Le,fillWithDefault:()=>ze,filter:()=>re,filterChanged:()=>oe,fromEvent:()=>Ke,getCurrentBrowser:()=>A,getExponentialDelay:()=>ke,getHighestQuality:()=>Ve,getIOSVersion:()=>Se,interval:()=>qe,isAndroid:()=>Ae,isHigher:()=>Pe,isHigherOrEqual:()=>Me,isIOS:()=>Ee,isInvariantQuality:()=>U,isLower:()=>D,isLowerOrEqual:()=>Ne,isMacLike:()=>Re,isMobile:()=>Ce,isNonNullable:()=>h,isNullable:()=>Q,loadVKLangPack:()=>ht,map:()=>k,mapTo:()=>se,merge:()=>K,noop:()=>x,now:()=>Oe,observableFrom:()=>He,observeElementSize:()=>We,once:()=>ae,pairwise:()=>ue,safeStorage:()=>q,tap:()=>pe,throttle:()=>ee,throttleFn:()=>F,timeCodeToString:()=>Tt,timeout:()=>Ge,videoHeightToQuality:()=>_e,videoQualityToHeight:()=>Ue,videoSizeToQuality:()=>De});module.exports=ut(wt);var Te="1.0.38-dev.87754f30.0";var f=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(r=>typeof r=="function"?r():r.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var v=t=>{throw new Error(`${t} is value of unexpected type`)},ve=t=>{};var x=()=>{};var l=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,r){let n;r?typeof r=="function"?n={next:r,error:x}:n={next:i=>r.next(i),error:i=>r.error?.(i)}:n={next:x,error:x};let o=typeof e=="function"?{next:i=>{try{e(i)}catch(a){n.next(a)}},error:i=>n.next(i)}:{next:i=>e.next(i),error:i=>e.error?e.error(i):n.next(i)},s;try{s=this._subscribe(o)}catch(i){o.error?.(i)}return new f().add(()=>{switch(o.next=x,o.error=x,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return v(s)}})}pipe(...e){return e.reduce((r,n)=>n(r),this)}_subscribe(e){}};var I=class extends l{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(r){this.subscribers.forEach(n=>n.next(r))}error(r){this.subscribers.forEach(n=>n.error?.(r))}_subscribe(r){let n=this.keyCounter++;return this.subscribers.set(n,r),new f().add(()=>this.subscribers.delete(n))}};var V=class{constructor(){this.log$=new I;this.logs=[];this.log=e=>{let r={...e,timestamp:Date.now()};this.logs.push(r),this.log$.next(r)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...r)=>{let n;try{n=e(...r)}catch{n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(r=>({component:e,...r}))}};function Ie(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function xe(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function h(t){return typeof t<"u"&&t!==null}function Q(t){return t==null}function ge(t,e){if(!t?.length)throw new Error(e)}function he(t,e){if(t?.length)throw new Error(e)}var ye=(t,e,r)=>new Promise((n,o)=>{e.addEventListener("abort",()=>{a(),b.remove()});let s=()=>{a(),o()},i=()=>{a(),n()},a=()=>{u&&clearTimeout(u),b.removeEventListener("load",i),b.removeEventListener("error",s)},u;r&&(u=window.setTimeout(s,r));let b=document.createElement("script");b.addEventListener("load",i),b.addEventListener("error",s),b.src=t,document.head.appendChild(b)});var Oe=typeof window.performance?.now=="function"?()=>window.performance.now():()=>Date.now();var we=(t,e)=>async(...r)=>{let n=e(...r),o=t.aborted,s;for(;!o&&!t.aborted;)try{let i=await n.next(s);o=i.done??!1,s=i.value}catch(i){await n.throw(i)}return s};var j=(c=>(c.Unknown="Unknown",c.Yandex="Yandex",c.Chrome="Chrome",c.Chromium="Chromium",c.Firefox="Firefox",c.Safari="Safari",c.Opera="Opera",c.Edge="Edge",c.SamsungBrowser="SamsungBrowser",c.Rest="Rest",c))(j||{}),W=(u=>(u.Unknown="Unknown",u.Android="Android",u.iPhone="iPhone",u.iPad="iPad",u.iPod="iPod",u.RestMobile="RestMobile",u.Mac="Mac",u.Desktop="Desktop",u))(W||{}),A=()=>{let{userAgent:t}=window.navigator,e=/yabrowser/i.test(t)?"Yandex":void 0,r=/samsungbrowser/i.test(t)?"SamsungBrowser":void 0,n=/chrome|crios/i.test(t)?"Chrome":void 0,o=/chromium/i.test(t)?"Chromium":void 0,s=/firefox|fxios/i.test(t)?"Firefox":void 0,i=/webkit|safari|khtml/i.test(t)?"Safari":void 0,a=/opr\//i.test(t)?"Opera":void 0,u=/edg/i.test(t)?"Edge":void 0,b=/android/i.test(t)?"Android":void 0,c=/iphone/i.test(t)?"iPhone":void 0,d=/ipad/i.test(t)?"iPad":void 0,E=/ipod/i.test(t)?"iPod":void 0,L=/mac/i.test(t)?"Mac":void 0,S=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(t)?"RestMobile":void 0;return{browser:e||r||s||a||u||n||o||i||"Rest",device:b||c||d||E||S||L||"Desktop"}},Ee=(t=!1)=>{let r=["iPhone","iPad","iPod"].includes(A().device);if(!t)return r;let{userAgent:n,maxTouchPoints:o}=window.navigator;return!!(r||/macintosh/i.test(n)&&o>0)},Se=()=>{let{userAgent:t}=window.navigator,e=t.match(/Version\/(\d+(\.\d+)?)/i);if(!e)return null;let r=e[1],n=parseFloat(r);return isNaN(n)?null:n},Ae=()=>A().device==="Android",Re=()=>["Mac","iPhone","iPad","iPod"].includes(A().device),Ce=()=>/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(navigator.appVersion??navigator.userAgent)||navigator?.userAgentData?.mobile;var ke=(t,{start:e=0,factor:r=2,max:n=1/0,min:o=e,random:s=0}={})=>{let i=e;return i*=r**t,i*=1+(Math.random()*s*2-s),i=Math.round(i),i=Math.min(i,n),i=Math.max(i,o),i};var q={};me(q,{clear:()=>mt,get:()=>pt,has:()=>dt,isPersistent:()=>ct,remove:()=>ft,set:()=>bt});var O,y,G=`vk-videoplayer-dummy-key-${Math.random()}`,w=()=>{if(y!==void 0)return y;try{localStorage.setItem(G,"test"),localStorage.removeItem(G),y=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem(G),y=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)y=2;else throw e}else throw t}return y===2&&(O=new Map),y},ct=()=>w()===0,pt=t=>{let e=w();switch(e){case 0:return localStorage.getItem(t)??void 0;case 1:return sessionStorage.getItem(t)??void 0;case 2:return O?.get(t);default:v(e)}},bt=(t,e)=>{let r=w();switch(r){case 0:try{localStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void O?.set(t,e);default:v(r)}},dt=t=>{let e=w();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return O?.has(t)??!1;default:return v(e),!1}},ft=t=>{let e=w();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:return void O?.delete(t);default:v(e)}},mt=()=>{let t=w();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return O?.clear();default:v(t)}};var Le=()=>{let t,e;try{t=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?t=!0:(t=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let r=e?new URL(e).hostname:void 0;return{isEmbed:t,host:r}};var _=(c=>(c.INVARIANT="Invariant quality",c.Q_144P="144p",c.Q_240P="240p",c.Q_360P="360p",c.Q_480P="480p",c.Q_720P="720p",c.Q_1080P="1080p",c.Q_1440P="1440p",c.Q_2160P="2160p",c.Q_4320P="4320p",c))(_||{});var m={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"720p":{width:1280,height:720},"1080p":{width:1920,height:1080},"1440p":{width:2560,height:1440},"2160p":{width:3840,height:2160},"4320p":{width:7680,height:4320}},Pe=(t,e)=>m[t].height>m[e].height,Me=(t,e)=>m[t].height>=m[e].height,D=(t,e)=>m[t].height<m[e].height,Ne=(t,e)=>m[t].height<=m[e].height,Ve=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:D(e,r)?1:-1)[0],Qe=Object.keys(m).sort((t,e)=>D(t,e)?-1:1),_e=(t,e=.02)=>[...Qe].find(n=>m[n].height*(1+e)>=t),De=({width:t,height:e})=>{let r=Math.min(t,e),n=Math.max(t,e);return Qe.find(o=>{let s=m[o];return s.width>=n&&s.height>=r})},Ue=t=>m[t].height,U=t=>t==="Invariant quality",Be=t=>t.every(e=>!U(e));function Fe(t){if(U(t))throw new Error("Expected exact quality")}var ze=(t,e)=>{let r={};for(let n of Object.keys(e)){let o=e[n],s=t[n];Array.isArray(o)&&Array.isArray(s)?r[n]=s:typeof o=="object"&&typeof s=="object"?r[n]=ze(s,o):r[n]=n in t?s:o}return r};var Tt=t=>{let e="";return t>=3600&&(e+=Math.floor(t/3600)+"h",t=t%3600),t>=60&&(e+=Math.floor(t/60)+"m",t=t%60),t>0&&(e+=Math.floor(t)+"s"),e};function B(t,e=0,r){let n,o,s,i,a,u,b=0,c=!1,d=!1,E=!0,L=!e&&e!==0&&typeof window.requestAnimationFrame=="function";r&&(c=!!r.leading,d="maxWait"in r,s=r?.maxWait?Math.max(+r?.maxWait||0,e):s,E="trailing"in r?!!r.trailing:E);function S(p){let T=n,g=o;return n=o=void 0,b=p,i=t.apply(g,T),i}function P(p,T){return L?(a&&window.cancelAnimationFrame(a),window.requestAnimationFrame(p)):setTimeout(p,T)}function Ze(p){if(L){window.cancelAnimationFrame(p);return}clearTimeout(p)}function et(p){return b=p,a=P(M,e),c?S(p):i}function tt(p){let T=p-u,g=p-b,fe=e-T;return d?Math.min(fe,s-g):fe}function be(p){let T=p-u,g=p-b;return u===void 0||T>=e||T<0||d&&g>=s}function M(){let p=Date.now();if(be(p))return de(p);a=P(M,tt(p))}function de(p){return a=void 0,E&&n?S(p):(n=o=void 0,i)}function rt(){a!==void 0&&Ze(a),b=0,n=u=o=a=void 0}function nt(){return a===void 0?i:de(Date.now())}function ot(){return a!==void 0}function N(...p){let T=Date.now(),g=be(T);if(n=p,o=this,u=T,g){if(a===void 0)return et(u);if(d)return a=P(M,e),S(u)}return a===void 0&&(a=P(M,e)),i}return N.cancel=rt,N.flush=nt,N.pending=ot,N}var F=(t,e=0,r)=>B(t,e,{...{leading:!0,trailing:!0},...r,maxWait:e});var R=(t,e)=>{if(t===null||typeof t!="object")return t;let r=Array.isArray(t)?[]:{};for(let n in t){if(typeof e=="function"){let o=e(t[n],n,t,r);if(o!==void 0){r[n]=o;continue}}typeof t[n]=="object"?r[n]=R(t[n],e):r[n]=t[n]}return r};var je=t=>R(t);var vt=300,We=(t,e=vt)=>new l(r=>{let{width:n,height:o}=t.getBoundingClientRect();if(r.next({width:n,height:o}),!window.ResizeObserver)return;let s=new ResizeObserver(F(i=>{let a=i[0];if(!a)return;let u,b;a.contentBoxSize&&a.contentBoxSize[0]?(b=a.contentBoxSize[0].blockSize,u=a.contentBoxSize[0].inlineSize):a.contentRect&&(u=a.contentRect.width,b=a.contentRect.height),h(u)&&h(b)&&r.next({width:u,height:b})},e));return s.observe(t),()=>s.disconnect()});var C=class extends I{constructor(r){super();this.value=r}next(r){super.next(this.value=r)}error(r){super.error(this.value=r)}getValue(){return this.value}_subscribe(r){let n=super._subscribe(r);return r.next(this.value),n}};function H(t){return new l(e=>{let r={},n=Object.keys(t).length,o=s=>i=>{s in r||n--,r[s]=i,n===0&&e.next(r)};return Object.entries(t).reduce((s,[i,a])=>s.add(a.subscribe(o(i))),new f)})}function K(...t){return new l(e=>t.reduce((r,n)=>r.add(n.subscribe(e)),new f))}var Ge=t=>new l(e=>{let r=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},t);return()=>window.clearTimeout(r)});var qe=t=>new l(e=>{let r=window.setInterval(()=>e.next(),t);return()=>{r&&(window.clearInterval(r),r=void 0)}});var He=t=>new l(e=>{t.forEach(r=>e.next(r))});var Ke=(t,e)=>new l(r=>{let n=o=>r.next(o);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)});function Y(t){return e=>new l(r=>e.subscribe(new $(r,t)))}var $=class{constructor(e,r){this.destination=e;this.size=r;this.lastValues=[]}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){this.destination.error?.(e)}};var It={leading:!1,trailing:!0};function J(t,e=It){return r=>new l(n=>r.subscribe(new X(n,t,e)))}var X=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,h(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(r){if(this.destination.error)this.destination.error(r);else throw r}this.timeout=void 0},this.time)}error(e){this.destination.error?.(e)}};var xt={leading:!0,trailing:!1};function ee(t,e=xt){return r=>new l(n=>r.subscribe(new Z(n,t,e)))}var Z=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,Q(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){this.destination.error?.(e)}};function re(t){return e=>new l(r=>e.subscribe(new te(r,t)))}var te=class{constructor(e,r){this.destination=e;this.predicate=r}next(e){let r;try{r=this.predicate(e)}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function oe(t=(e,r)=>e===r){return e=>new l(r=>e.subscribe(new ne(r,t)))}var $e={},ne=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=$e}next(e){let r;try{r=this.lastValue===$e||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function k(t){return e=>new l(r=>e.subscribe(new ie(r,t)))}var ie=class{constructor(e,r){this.destination=e;this.mapper=r}next(e){let r;try{r=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(r)}error(e){this.destination.error?.(e)}};function se(t){return k(()=>t)}function ae(){return t=>new l(e=>{let r=!1,n=!1,o=t.subscribe(s=>{r||(r=!0,e.next(s)),n&&o.unsubscribe()},s=>{r=!0,e.error?.(s),n&&o.unsubscribe()});return n=!0,r&&o.unsubscribe(),o})}function ue(){return t=>new l(e=>t.subscribe(new le(e)))}var le=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let r=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([r,e])}error(e){this.destination.error?.(e)}};function pe(t){return e=>new l(r=>e.subscribe(new ce(r,t)))}var ce=class{constructor(e,r){this.destination=e;this.effect=r}next(e){try{this.effect(e)}catch(r){throw this.error(r),r}this.destination.next(e)}error(e){this.destination.error?.(e)}};var Ye=(a=>(a.NETWORK="network",a.VIDEO_PIPELINE="video_pipeline",a.EXTERNAL_API="external_api",a.PARSER="parser",a.DOM="dom",a.WTF="wtf",a.FATAL="fatal",a))(Ye||{});var Xe=(d=>(d.Armenian="58",d.Azerbaijani="57",d.Belarusian="114",d.English="3",d.Kazakh="97",d.Portuguese="73",d.Russian="0",d.Spanish="4",d.Ukrainian="1",d.Uzbek="65",d.Vietnamese="75",d))(Xe||{}),gt="vk.com",ht=async(t,e,r)=>{let n=new URL(`https://${gt}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),t!==void 0&&n.searchParams.set("lang",t);let s=await(await fetch(n.toString())).json();return yt(s,r)},yt=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,n])=>[r.substring(`${e}_`.length),Ot(n)])),Ot=t=>Array.isArray(t)?t[0]:t;var Je=(r=>(r.RU="ru",r.EN="en",r))(Je||{});
6
+ "use strict";var B=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var nt=Object.prototype.hasOwnProperty;var fe=(t,e)=>{for(var r in e)B(t,r,{get:e[r],enumerable:!0})},it=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of rt(e))!nt.call(t,i)&&i!==r&&B(t,i,{get:()=>e[i],enumerable:!(n=tt(e,i))||n.enumerable});return t};var ot=t=>it(B({},"__esModule",{value:!0}),t);var gt={};fe(gt,{ErrorCategory:()=>He,InterfaceLanguage:()=>Ke,Logger:()=>P,Observable:()=>l,Subject:()=>h,Subscription:()=>f,VERSION:()=>me,VKNumericLanguage:()=>qe,ValueSubject:()=>S,VideoQuality:()=>M,abortable:()=>Oe,addScript:()=>xe,areQualitiesExact:()=>_e,assertEmptyArray:()=>ge,assertNever:()=>v,assertNonNullable:()=>ve,assertNotEmptyArray:()=>Ie,assertNullable:()=>he,assertQualityIsExact:()=>Ne,buffer:()=>K,checkNever:()=>Te,clearVideoElement:()=>Be,clientChecker:()=>we,cloneDeep:()=>De,cloneDeepWith:()=>E,combine:()=>G,debounce:()=>$,debounceFn:()=>N,detectEmbed:()=>Se,fillWithDefault:()=>Qe,filter:()=>ee,filterChanged:()=>re,fromEvent:()=>We,getExponentialDelay:()=>Ee,getHighestQuality:()=>Ce,interval:()=>ze,isHigher:()=>Re,isHigherOrEqual:()=>Ae,isInvariantQuality:()=>_,isLower:()=>V,isLowerOrEqual:()=>ke,isMobile:()=>z,isNonNullable:()=>x,isNullable:()=>L,loadVKLangPack:()=>vt,map:()=>R,mapTo:()=>ie,merge:()=>H,noop:()=>I,now:()=>ye,observableFrom:()=>je,observeElementSize:()=>Ue,once:()=>oe,pairwise:()=>ae,safeStorage:()=>W,tap:()=>ue,throttle:()=>J,throttleFn:()=>Q,timeCodeToString:()=>bt,timeout:()=>Fe,videoHeightToQuality:()=>Le,videoQualityToHeight:()=>Ve,videoSizeToQuality:()=>Me});module.exports=ot(gt);var me="1.0.38-dev.abb9bed7.0";var f=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(r=>typeof r=="function"?r():r.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var v=t=>{throw new Error(`${t} is value of unexpected type`)},Te=t=>{};var I=()=>{};var l=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,r){let n;r?typeof r=="function"?n={next:r,error:I}:n={next:o=>r.next(o),error:o=>r.error?.(o)}:n={next:I,error:I};let i=typeof e=="function"?{next:o=>{try{e(o)}catch(a){n.next(a)}},error:o=>n.next(o)}:{next:o=>e.next(o),error:o=>e.error?e.error(o):n.next(o)},s;try{s=this._subscribe(i)}catch(o){i.error?.(o)}return new f().add(()=>{switch(i.next=I,i.error=I,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return v(s)}})}pipe(...e){return e.reduce((r,n)=>n(r),this)}_subscribe(e){}};var h=class extends l{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(r){this.subscribers.forEach(n=>n.next(r))}error(r){this.subscribers.forEach(n=>n.error?.(r))}_subscribe(r){let n=this.keyCounter++;return this.subscribers.set(n,r),new f().add(()=>this.subscribers.delete(n))}};var P=class{constructor(){this.log$=new h;this.logs=[];this.log=e=>{let r={...e,timestamp:Date.now()};this.logs.push(r),this.log$.next(r)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...r)=>{let n;try{n=e(...r)}catch{n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(r=>({component:e,...r}))}};function ve(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function he(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function x(t){return typeof t<"u"&&t!==null}function L(t){return t==null}function Ie(t,e){if(!t?.length)throw new Error(e)}function ge(t,e){if(t?.length)throw new Error(e)}var xe=(t,e,r)=>new Promise((n,i)=>{e.addEventListener("abort",()=>{a(),c.remove()});let s=()=>{a(),i()},o=()=>{a(),n()},a=()=>{p&&clearTimeout(p),c.removeEventListener("load",o),c.removeEventListener("error",s)},p;r&&(p=window.setTimeout(s,r));let c=document.createElement("script");c.addEventListener("load",o),c.addEventListener("error",s),c.src=t,document.head.appendChild(c)});var ye=typeof window.performance?.now=="function"?()=>window.performance.now():()=>Date.now();var Oe=(t,e)=>async(...r)=>{let n=e(...r),i=t.aborted,s;for(;!i&&!t.aborted;)try{let o=await n.next(s);i=o.done??!1,s=o.value}catch(o){await n.throw(o)}return s};var z=()=>/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(navigator.appVersion??navigator.userAgent)||navigator?.userAgentData?.mobile,F=class{constructor(){this.detect()}get browser(){return this._currentBrowser}get device(){return this._currentDevice}get isTouch(){return this._maxTouchPoints>0}get isIOS(){return["iPhone","iPad","iPod"].includes(this.device)}get isMac(){return this.device==="Mac"}get isApple(){return this.isIOS||this.isMac}get isIphoneOrOldIpad(){if(!this.isApple||!this.isTouch)return!1;let e=this.device==="iPad"||window?.screen.width>700,r=this._iosVersion;return!e||e&&!!r&&r<16}get isAndroid(){return this.device==="Android"}get isMobile(){return this._isMobile}get iOSVersion(){return this._iosVersion}get macVersion(){return this._macVersion}get isYandex(){return this.browser==="Yandex"}get isSafari(){return this.browser==="Safari"}get isSamsungBrowser(){return this.browser==="SamsungBrowser"}get isHDR(){return this._isHdr}detect(){let{userAgent:e,maxTouchPoints:r}=navigator;try{this._maxTouchPoints=r,this._isHdr=!!matchMedia("(dynamic-range: high)")?.matches}catch(n){console.error(n)}try{this._isMobile=z()}catch(n){console.error(n)}this.detectBrowser(e),this.detectDevice(e),this.isIOS&&this.detectIOSVersion(),this.isMac&&this.detectMacVersion()}detectBrowser(e){try{let r=/yabrowser/i.test(e)?"Yandex":void 0,n=/samsungbrowser/i.test(e)?"SamsungBrowser":void 0,i=/chrome|crios/i.test(e)?"Chrome":void 0,s=/chromium/i.test(e)?"Chromium":void 0,o=/firefox|fxios/i.test(e)?"Firefox":void 0,a=/webkit|safari|khtml/i.test(e)?"Safari":void 0,p=/opr\//i.test(e)?"Opera":void 0,c=/edg/i.test(e)?"Edge":void 0;this._currentBrowser=r||n||o||p||c||i||s||a||"Rest"}catch(r){console.error(r)}}detectDevice(e){try{let r=/android/i.test(e)?"Android":void 0,n=/iphone/i.test(e)?"iPhone":void 0,i=/ipad/i.test(e)?"iPad":void 0,s=/ipod/i.test(e)?"iPod":void 0,o=/mac/i.test(e)?"Mac":void 0,a=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(e)?"RestMobile":void 0;this._currentDevice=r||n||i||s||a||o||"Desktop"}catch(r){console.error(r)}}detectIOSVersion(){try{let{userAgent:e}=window.navigator,r=e.match(/Version\/(\d+(\.\d+)?)/i);if(!r)return;let n=r[1],i=parseFloat(n);if(isNaN(i))return;this._iosVersion=i}catch(e){console.error(e)}}detectMacVersion(){try{let{userAgent:e}=window.navigator,r=e.match(/Version\/(\d+)/);if(!r)return;let n=r[1],i=parseInt(n,10);if(isNaN(i))return;this._macVersion=i}catch(e){console.error(e)}}},we=new F;var Ee=(t,{start:e=0,factor:r=2,max:n=1/0,min:i=e,random:s=0}={})=>{let o=e;return o*=r**t,o*=1+(Math.random()*s*2-s),o=Math.round(o),o=Math.min(o,n),o=Math.max(o,i),o};var W={};fe(W,{clear:()=>pt,get:()=>at,has:()=>ut,isPersistent:()=>st,remove:()=>ct,set:()=>lt});var O,y,j=`vk-videoplayer-dummy-key-${Math.random()}`,w=()=>{if(y!==void 0)return y;try{localStorage.setItem(j,"test"),localStorage.removeItem(j),y=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem(j),y=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)y=2;else throw e}else throw t}return y===2&&(O=new Map),y},st=()=>w()===0,at=t=>{let e=w();switch(e){case 0:return localStorage.getItem(t)??void 0;case 1:return sessionStorage.getItem(t)??void 0;case 2:return O?.get(t);default:v(e)}},lt=(t,e)=>{let r=w();switch(r){case 0:try{localStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void O?.set(t,e);default:v(r)}},ut=t=>{let e=w();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return O?.has(t)??!1;default:return v(e),!1}},ct=t=>{let e=w();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:return void O?.delete(t);default:v(e)}},pt=()=>{let t=w();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return O?.clear();default:v(t)}};var Se=()=>{let t,e;try{t=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?t=!0:(t=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let r=e?new URL(e).hostname:void 0;return{isEmbed:t,host:r}};var M=(d=>(d.INVARIANT="Invariant quality",d.Q_144P="144p",d.Q_240P="240p",d.Q_360P="360p",d.Q_480P="480p",d.Q_720P="720p",d.Q_1080P="1080p",d.Q_1440P="1440p",d.Q_2160P="2160p",d.Q_4320P="4320p",d))(M||{});var m={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"720p":{width:1280,height:720},"1080p":{width:1920,height:1080},"1440p":{width:2560,height:1440},"2160p":{width:3840,height:2160},"4320p":{width:7680,height:4320}},Re=(t,e)=>m[t].height>m[e].height,Ae=(t,e)=>m[t].height>=m[e].height,V=(t,e)=>m[t].height<m[e].height,ke=(t,e)=>m[t].height<=m[e].height,Ce=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:V(e,r)?1:-1)[0],Pe=Object.keys(m).sort((t,e)=>V(t,e)?-1:1),Le=(t,e=.02)=>[...Pe].find(n=>m[n].height*(1+e)>=t),Me=({width:t,height:e})=>{let r=Math.min(t,e),n=Math.max(t,e);return Pe.find(i=>{let s=m[i];return s.width>=n&&s.height>=r})},Ve=t=>m[t].height,_=t=>t==="Invariant quality",_e=t=>t.every(e=>!_(e));function Ne(t){if(_(t))throw new Error("Expected exact quality")}var Qe=(t,e)=>{let r={};for(let n of Object.keys(e)){let i=e[n],s=t[n];Array.isArray(i)&&Array.isArray(s)?r[n]=s:typeof i=="object"&&typeof s=="object"?r[n]=Qe(s,i):r[n]=n in t?s:i}return r};var bt=t=>{let e="";return t>=3600&&(e+=Math.floor(t/3600)+"h",t=t%3600),t>=60&&(e+=Math.floor(t/60)+"m",t=t%60),t>0&&(e+=Math.floor(t)+"s"),e};function N(t,e=0,r){let n,i,s,o,a,p,c=0,d=!1,b=!1,D=!0,ce=!e&&e!==0&&typeof window.requestAnimationFrame=="function";r&&(d=!!r.leading,b="maxWait"in r,s=r?.maxWait?Math.max(+r?.maxWait||0,e):s,D="trailing"in r?!!r.trailing:D);function U(u){let T=n,g=i;return n=i=void 0,c=u,o=t.apply(g,T),o}function A(u,T){return ce?(a&&window.cancelAnimationFrame(a),window.requestAnimationFrame(u)):setTimeout(u,T)}function Ye(u){if(ce){window.cancelAnimationFrame(u);return}clearTimeout(u)}function $e(u){return c=u,a=A(k,e),d?U(u):o}function Xe(u){let T=u-p,g=u-c,de=e-T;return b?Math.min(de,s-g):de}function pe(u){let T=u-p,g=u-c;return p===void 0||T>=e||T<0||b&&g>=s}function k(){let u=Date.now();if(pe(u))return be(u);a=A(k,Xe(u))}function be(u){return a=void 0,D&&n?U(u):(n=i=void 0,o)}function Je(){a!==void 0&&Ye(a),c=0,n=p=i=a=void 0}function Ze(){return a===void 0?o:be(Date.now())}function et(){return a!==void 0}function C(...u){let T=Date.now(),g=pe(T);if(n=u,i=this,p=T,g){if(a===void 0)return $e(p);if(b)return a=A(k,e),U(p)}return a===void 0&&(a=A(k,e)),o}return C.cancel=Je,C.flush=Ze,C.pending=et,C}var Q=(t,e=0,r)=>N(t,e,{...{leading:!0,trailing:!0},...r,maxWait:e});var E=(t,e)=>{if(t===null||typeof t!="object")return t;let r=Array.isArray(t)?[]:{};for(let n in t){if(typeof e=="function"){let i=e(t[n],n,t,r);if(i!==void 0){r[n]=i;continue}}typeof t[n]=="object"?r[n]=E(t[n],e):r[n]=t[n]}return r};var De=t=>E(t);var dt=300,Ue=(t,e=dt)=>new l(r=>{let{width:n,height:i}=t.getBoundingClientRect();if(r.next({width:n,height:i}),!window.ResizeObserver)return;let s=new ResizeObserver(Q(o=>{let a=o[0];if(!a)return;let p,c;a.contentBoxSize&&a.contentBoxSize[0]?(c=a.contentBoxSize[0].blockSize,p=a.contentBoxSize[0].inlineSize):a.contentRect&&(p=a.contentRect.width,c=a.contentRect.height),x(p)&&x(c)&&r.next({width:p,height:c})},e));return s.observe(t),()=>s.disconnect()});var Be=t=>{t.removeAttribute("src"),t.load()};var S=class extends h{constructor(e){super(),this.value=e}next(e){super.next(this.value=e)}error(e){super.error(this.value=e)}getValue(){return this.value}_subscribe(e){let r=super._subscribe(e);return e.next(this.value),r}};function G(t){return new l(e=>{let r={},n=Object.keys(t).length,i=s=>o=>{s in r||n--,r[s]=o,n===0&&e.next(r)};return Object.entries(t).reduce((s,[o,a])=>s.add(a.subscribe(i(o))),new f)})}function H(...t){return new l(e=>t.reduce((r,n)=>r.add(n.subscribe(e)),new f))}var Fe=t=>new l(e=>{let r=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},t);return()=>window.clearTimeout(r)});var ze=t=>new l(e=>{let r=window.setInterval(()=>e.next(),t);return()=>{r&&(window.clearInterval(r),r=void 0)}});var je=t=>new l(e=>{t.forEach(r=>e.next(r))});var We=(t,e)=>new l(r=>{let n=i=>r.next(i);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)});function K(t){return e=>new l(r=>e.subscribe(new q(r,t)))}var q=class{constructor(e,r){this.destination=e;this.size=r;this.lastValues=[]}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){this.destination.error?.(e)}};var ft={leading:!1,trailing:!0};function $(t,e=ft){return r=>new l(n=>r.subscribe(new Y(n,t,e)))}var Y=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,x(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(r){if(this.destination.error)this.destination.error(r);else throw r}this.timeout=void 0},this.time)}error(e){this.destination.error?.(e)}};var mt={leading:!0,trailing:!1};function J(t,e=mt){return r=>new l(n=>r.subscribe(new X(n,t,e)))}var X=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,L(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){this.destination.error?.(e)}};function ee(t){return e=>new l(r=>e.subscribe(new Z(r,t)))}var Z=class{constructor(e,r){this.destination=e;this.predicate=r}next(e){let r;try{r=this.predicate(e)}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function re(t=(e,r)=>e===r){return e=>new l(r=>e.subscribe(new te(r,t)))}var Ge={},te=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=Ge}next(e){let r;try{r=this.lastValue===Ge||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function R(t){return e=>new l(r=>e.subscribe(new ne(r,t)))}var ne=class{constructor(e,r){this.destination=e;this.mapper=r}next(e){let r;try{r=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(r)}error(e){this.destination.error?.(e)}};function ie(t){return R(()=>t)}function oe(){return t=>new l(e=>{let r=!1,n=!1,i=t.subscribe(s=>{r||(r=!0,e.next(s)),n&&i.unsubscribe()},s=>{r=!0,e.error?.(s),n&&i.unsubscribe()});return n=!0,r&&i.unsubscribe(),i})}function ae(){return t=>new l(e=>t.subscribe(new se(e)))}var se=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let r=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([r,e])}error(e){this.destination.error?.(e)}};function ue(t){return e=>new l(r=>e.subscribe(new le(r,t)))}var le=class{constructor(e,r){this.destination=e;this.effect=r}next(e){try{this.effect(e)}catch(r){throw this.error(r),r}this.destination.next(e)}error(e){this.destination.error?.(e)}};var He=(a=>(a.NETWORK="network",a.VIDEO_PIPELINE="video_pipeline",a.EXTERNAL_API="external_api",a.PARSER="parser",a.DOM="dom",a.WTF="wtf",a.FATAL="fatal",a))(He||{});var qe=(b=>(b.Armenian="58",b.Azerbaijani="57",b.Belarusian="114",b.English="3",b.Kazakh="97",b.Portuguese="73",b.Russian="0",b.Spanish="4",b.Ukrainian="1",b.Uzbek="65",b.Vietnamese="75",b))(qe||{}),Tt="vk.com",vt=async(t,e,r)=>{let n=new URL(`https://${Tt}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),t!==void 0&&n.searchParams.set("lang",t);let s=await(await fetch(n.toString())).json();return ht(s,r)},ht=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,n])=>[r.substring(`${e}_`.length),It(n)])),It=t=>Array.isArray(t)?t[0]:t;var Ke=(r=>(r.RU="ru",r.EN="en",r))(Ke||{});
package/esnext.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @vkontakte/videoplayer-shared v1.0.38-dev.87754f30.0
3
- * Tue, 06 Aug 2024 11:52:24 GMT
2
+ * @vkontakte/videoplayer-shared v1.0.38-dev.abb9bed7.0
3
+ * Mon, 19 Aug 2024 11:00:39 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-38/doc/
5
5
  */
6
- var ye=Object.defineProperty;var Oe=(t,e)=>{for(var r in e)ye(t,r,{get:e[r],enumerable:!0})};var we="1.0.38-dev.87754f30.0";var f=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(r=>typeof r=="function"?r():r.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var v=t=>{throw new Error(`${t} is value of unexpected type`)},Ee=t=>{};var g=()=>{};var l=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,r){let n;r?typeof r=="function"?n={next:r,error:g}:n={next:o=>r.next(o),error:o=>r.error?.(o)}:n={next:g,error:g};let s=typeof e=="function"?{next:o=>{try{e(o)}catch(a){n.next(a)}},error:o=>n.next(o)}:{next:o=>e.next(o),error:o=>e.error?e.error(o):n.next(o)},i;try{i=this._subscribe(s)}catch(o){s.error?.(o)}return new f().add(()=>{switch(s.next=g,s.error=g,typeof i){case"function":i();return;case"object":i.unsubscribe();return;case"undefined":return;default:return v(i)}})}pipe(...e){return e.reduce((r,n)=>n(r),this)}_subscribe(e){}};var I=class extends l{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(r){this.subscribers.forEach(n=>n.next(r))}error(r){this.subscribers.forEach(n=>n.error?.(r))}_subscribe(r){let n=this.keyCounter++;return this.subscribers.set(n,r),new f().add(()=>this.subscribers.delete(n))}};var V=class{constructor(){this.log$=new I;this.logs=[];this.log=e=>{let r={...e,timestamp:Date.now()};this.logs.push(r),this.log$.next(r)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...r)=>{let n;try{n=e(...r)}catch{n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(r=>({component:e,...r}))}};function Se(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function Ae(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function y(t){return typeof t<"u"&&t!==null}function Q(t){return t==null}function Re(t,e){if(!t?.length)throw new Error(e)}function Ce(t,e){if(t?.length)throw new Error(e)}var ke=(t,e,r)=>new Promise((n,s)=>{e.addEventListener("abort",()=>{a(),b.remove()});let i=()=>{a(),s()},o=()=>{a(),n()},a=()=>{u&&clearTimeout(u),b.removeEventListener("load",o),b.removeEventListener("error",i)},u;r&&(u=window.setTimeout(i,r));let b=document.createElement("script");b.addEventListener("load",o),b.addEventListener("error",i),b.src=t,document.head.appendChild(b)});var Le=typeof window.performance?.now=="function"?()=>window.performance.now():()=>Date.now();var Pe=(t,e)=>async(...r)=>{let n=e(...r),s=t.aborted,i;for(;!s&&!t.aborted;)try{let o=await n.next(i);s=o.done??!1,i=o.value}catch(o){await n.throw(o)}return i};var ee=(c=>(c.Unknown="Unknown",c.Yandex="Yandex",c.Chrome="Chrome",c.Chromium="Chromium",c.Firefox="Firefox",c.Safari="Safari",c.Opera="Opera",c.Edge="Edge",c.SamsungBrowser="SamsungBrowser",c.Rest="Rest",c))(ee||{}),te=(u=>(u.Unknown="Unknown",u.Android="Android",u.iPhone="iPhone",u.iPad="iPad",u.iPod="iPod",u.RestMobile="RestMobile",u.Mac="Mac",u.Desktop="Desktop",u))(te||{}),L=()=>{let{userAgent:t}=window.navigator,e=/yabrowser/i.test(t)?"Yandex":void 0,r=/samsungbrowser/i.test(t)?"SamsungBrowser":void 0,n=/chrome|crios/i.test(t)?"Chrome":void 0,s=/chromium/i.test(t)?"Chromium":void 0,i=/firefox|fxios/i.test(t)?"Firefox":void 0,o=/webkit|safari|khtml/i.test(t)?"Safari":void 0,a=/opr\//i.test(t)?"Opera":void 0,u=/edg/i.test(t)?"Edge":void 0,b=/android/i.test(t)?"Android":void 0,c=/iphone/i.test(t)?"iPhone":void 0,d=/ipad/i.test(t)?"iPad":void 0,E=/ipod/i.test(t)?"iPod":void 0,A=/mac/i.test(t)?"Mac":void 0,S=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(t)?"RestMobile":void 0;return{browser:e||r||i||a||u||n||s||o||"Rest",device:b||c||d||E||S||A||"Desktop"}},Me=(t=!1)=>{let r=["iPhone","iPad","iPod"].includes(L().device);if(!t)return r;let{userAgent:n,maxTouchPoints:s}=window.navigator;return!!(r||/macintosh/i.test(n)&&s>0)},Ne=()=>{let{userAgent:t}=window.navigator,e=t.match(/Version\/(\d+(\.\d+)?)/i);if(!e)return null;let r=e[1],n=parseFloat(r);return isNaN(n)?null:n},Ve=()=>L().device==="Android",Qe=()=>["Mac","iPhone","iPad","iPod"].includes(L().device),_e=()=>/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(navigator.appVersion??navigator.userAgent)||navigator?.userAgentData?.mobile;var De=(t,{start:e=0,factor:r=2,max:n=1/0,min:s=e,random:i=0}={})=>{let o=e;return o*=r**t,o*=1+(Math.random()*i*2-i),o=Math.round(o),o=Math.min(o,n),o=Math.max(o,s),o};var re={};Oe(re,{clear:()=>We,get:()=>Be,has:()=>ze,isPersistent:()=>Ue,remove:()=>je,set:()=>Fe});var O,h,_=`vk-videoplayer-dummy-key-${Math.random()}`,w=()=>{if(h!==void 0)return h;try{localStorage.setItem(_,"test"),localStorage.removeItem(_),h=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem(_),h=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)h=2;else throw e}else throw t}return h===2&&(O=new Map),h},Ue=()=>w()===0,Be=t=>{let e=w();switch(e){case 0:return localStorage.getItem(t)??void 0;case 1:return sessionStorage.getItem(t)??void 0;case 2:return O?.get(t);default:v(e)}},Fe=(t,e)=>{let r=w();switch(r){case 0:try{localStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void O?.set(t,e);default:v(r)}},ze=t=>{let e=w();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return O?.has(t)??!1;default:return v(e),!1}},je=t=>{let e=w();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:return void O?.delete(t);default:v(e)}},We=()=>{let t=w();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return O?.clear();default:v(t)}};var Ge=()=>{let t,e;try{t=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?t=!0:(t=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let r=e?new URL(e).hostname:void 0;return{isEmbed:t,host:r}};var D=(c=>(c.INVARIANT="Invariant quality",c.Q_144P="144p",c.Q_240P="240p",c.Q_360P="360p",c.Q_480P="480p",c.Q_720P="720p",c.Q_1080P="1080p",c.Q_1440P="1440p",c.Q_2160P="2160p",c.Q_4320P="4320p",c))(D||{});var m={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"720p":{width:1280,height:720},"1080p":{width:1920,height:1080},"1440p":{width:2560,height:1440},"2160p":{width:3840,height:2160},"4320p":{width:7680,height:4320}},qe=(t,e)=>m[t].height>m[e].height,He=(t,e)=>m[t].height>=m[e].height,U=(t,e)=>m[t].height<m[e].height,Ke=(t,e)=>m[t].height<=m[e].height,$e=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:U(e,r)?1:-1)[0],ne=Object.keys(m).sort((t,e)=>U(t,e)?-1:1),Ye=(t,e=.02)=>[...ne].find(n=>m[n].height*(1+e)>=t),Xe=({width:t,height:e})=>{let r=Math.min(t,e),n=Math.max(t,e);return ne.find(s=>{let i=m[s];return i.width>=n&&i.height>=r})},Je=t=>m[t].height,B=t=>t==="Invariant quality",Ze=t=>t.every(e=>!B(e));function et(t){if(B(t))throw new Error("Expected exact quality")}var tt=(t,e)=>{let r={};for(let n of Object.keys(e)){let s=e[n],i=t[n];Array.isArray(s)&&Array.isArray(i)?r[n]=i:typeof s=="object"&&typeof i=="object"?r[n]=tt(i,s):r[n]=n in t?i:s}return r};var qt=t=>{let e="";return t>=3600&&(e+=Math.floor(t/3600)+"h",t=t%3600),t>=60&&(e+=Math.floor(t/60)+"m",t=t%60),t>0&&(e+=Math.floor(t)+"s"),e};function F(t,e=0,r){let n,s,i,o,a,u,b=0,c=!1,d=!1,E=!0,A=!e&&e!==0&&typeof window.requestAnimationFrame=="function";r&&(c=!!r.leading,d="maxWait"in r,i=r?.maxWait?Math.max(+r?.maxWait||0,e):i,E="trailing"in r?!!r.trailing:E);function S(p){let T=n,x=s;return n=s=void 0,b=p,o=t.apply(x,T),o}function R(p,T){return A?(a&&window.cancelAnimationFrame(a),window.requestAnimationFrame(p)):setTimeout(p,T)}function Te(p){if(A){window.cancelAnimationFrame(p);return}clearTimeout(p)}function ve(p){return b=p,a=R(C,e),c?S(p):o}function Ie(p){let T=p-u,x=p-b,Z=e-T;return d?Math.min(Z,i-x):Z}function X(p){let T=p-u,x=p-b;return u===void 0||T>=e||T<0||d&&x>=i}function C(){let p=Date.now();if(X(p))return J(p);a=R(C,Ie(p))}function J(p){return a=void 0,E&&n?S(p):(n=s=void 0,o)}function xe(){a!==void 0&&Te(a),b=0,n=u=s=a=void 0}function ge(){return a===void 0?o:J(Date.now())}function he(){return a!==void 0}function k(...p){let T=Date.now(),x=X(T);if(n=p,s=this,u=T,x){if(a===void 0)return ve(u);if(d)return a=R(C,e),S(u)}return a===void 0&&(a=R(C,e)),o}return k.cancel=xe,k.flush=ge,k.pending=he,k}var z=(t,e=0,r)=>F(t,e,{...{leading:!0,trailing:!0},...r,maxWait:e});var P=(t,e)=>{if(t===null||typeof t!="object")return t;let r=Array.isArray(t)?[]:{};for(let n in t){if(typeof e=="function"){let s=e(t[n],n,t,r);if(s!==void 0){r[n]=s;continue}}typeof t[n]=="object"?r[n]=P(t[n],e):r[n]=t[n]}return r};var rt=t=>P(t);var nt=300,ot=(t,e=nt)=>new l(r=>{let{width:n,height:s}=t.getBoundingClientRect();if(r.next({width:n,height:s}),!window.ResizeObserver)return;let i=new ResizeObserver(z(o=>{let a=o[0];if(!a)return;let u,b;a.contentBoxSize&&a.contentBoxSize[0]?(b=a.contentBoxSize[0].blockSize,u=a.contentBoxSize[0].inlineSize):a.contentRect&&(u=a.contentRect.width,b=a.contentRect.height),y(u)&&y(b)&&r.next({width:u,height:b})},e));return i.observe(t),()=>i.disconnect()});var M=class extends I{constructor(r){super();this.value=r}next(r){super.next(this.value=r)}error(r){super.error(this.value=r)}getValue(){return this.value}_subscribe(r){let n=super._subscribe(r);return r.next(this.value),n}};function oe(t){return new l(e=>{let r={},n=Object.keys(t).length,s=i=>o=>{i in r||n--,r[i]=o,n===0&&e.next(r)};return Object.entries(t).reduce((i,[o,a])=>i.add(a.subscribe(s(o))),new f)})}function ie(...t){return new l(e=>t.reduce((r,n)=>r.add(n.subscribe(e)),new f))}var it=t=>new l(e=>{let r=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},t);return()=>window.clearTimeout(r)});var st=t=>new l(e=>{let r=window.setInterval(()=>e.next(),t);return()=>{r&&(window.clearInterval(r),r=void 0)}});var at=t=>new l(e=>{t.forEach(r=>e.next(r))});var lt=(t,e)=>new l(r=>{let n=s=>r.next(s);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)});function se(t){return e=>new l(r=>e.subscribe(new j(r,t)))}var j=class{constructor(e,r){this.destination=e;this.size=r;this.lastValues=[]}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){this.destination.error?.(e)}};var ut={leading:!1,trailing:!0};function ae(t,e=ut){return r=>new l(n=>r.subscribe(new W(n,t,e)))}var W=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,y(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(r){if(this.destination.error)this.destination.error(r);else throw r}this.timeout=void 0},this.time)}error(e){this.destination.error?.(e)}};var ct={leading:!0,trailing:!1};function le(t,e=ct){return r=>new l(n=>r.subscribe(new G(n,t,e)))}var G=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,Q(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){this.destination.error?.(e)}};function ue(t){return e=>new l(r=>e.subscribe(new q(r,t)))}var q=class{constructor(e,r){this.destination=e;this.predicate=r}next(e){let r;try{r=this.predicate(e)}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function pe(t=(e,r)=>e===r){return e=>new l(r=>e.subscribe(new H(r,t)))}var ce={},H=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=ce}next(e){let r;try{r=this.lastValue===ce||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function N(t){return e=>new l(r=>e.subscribe(new K(r,t)))}var K=class{constructor(e,r){this.destination=e;this.mapper=r}next(e){let r;try{r=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(r)}error(e){this.destination.error?.(e)}};function be(t){return N(()=>t)}function de(){return t=>new l(e=>{let r=!1,n=!1,s=t.subscribe(i=>{r||(r=!0,e.next(i)),n&&s.unsubscribe()},i=>{r=!0,e.error?.(i),n&&s.unsubscribe()});return n=!0,r&&s.unsubscribe(),s})}function fe(){return t=>new l(e=>t.subscribe(new $(e)))}var $=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let r=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([r,e])}error(e){this.destination.error?.(e)}};function me(t){return e=>new l(r=>e.subscribe(new Y(r,t)))}var Y=class{constructor(e,r){this.destination=e;this.effect=r}next(e){try{this.effect(e)}catch(r){throw this.error(r),r}this.destination.next(e)}error(e){this.destination.error?.(e)}};var pt=(a=>(a.NETWORK="network",a.VIDEO_PIPELINE="video_pipeline",a.EXTERNAL_API="external_api",a.PARSER="parser",a.DOM="dom",a.WTF="wtf",a.FATAL="fatal",a))(pt||{});var bt=(d=>(d.Armenian="58",d.Azerbaijani="57",d.Belarusian="114",d.English="3",d.Kazakh="97",d.Portuguese="73",d.Russian="0",d.Spanish="4",d.Ukrainian="1",d.Uzbek="65",d.Vietnamese="75",d))(bt||{}),dt="vk.com",Vn=async(t,e,r)=>{let n=new URL(`https://${dt}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),t!==void 0&&n.searchParams.set("lang",t);let i=await(await fetch(n.toString())).json();return ft(i,r)},ft=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,n])=>[r.substring(`${e}_`.length),mt(n)])),mt=t=>Array.isArray(t)?t[0]:t;var Tt=(r=>(r.RU="ru",r.EN="en",r))(Tt||{});export{ee as CurrentClientBrowser,te as CurrentClientDevice,pt as ErrorCategory,Tt as InterfaceLanguage,V as Logger,l as Observable,I as Subject,f as Subscription,we as VERSION,bt as VKNumericLanguage,M as ValueSubject,D as VideoQuality,Pe as abortable,ke as addScript,Ze as areQualitiesExact,Ce as assertEmptyArray,v as assertNever,Se as assertNonNullable,Re as assertNotEmptyArray,Ae as assertNullable,et as assertQualityIsExact,se as buffer,Ee as checkNever,rt as cloneDeep,P as cloneDeepWith,oe as combine,ae as debounce,F as debounceFn,Ge as detectEmbed,tt as fillWithDefault,ue as filter,pe as filterChanged,lt as fromEvent,L as getCurrentBrowser,De as getExponentialDelay,$e as getHighestQuality,Ne as getIOSVersion,st as interval,Ve as isAndroid,qe as isHigher,He as isHigherOrEqual,Me as isIOS,B as isInvariantQuality,U as isLower,Ke as isLowerOrEqual,Qe as isMacLike,_e as isMobile,y as isNonNullable,Q as isNullable,Vn as loadVKLangPack,N as map,be as mapTo,ie as merge,g as noop,Le as now,at as observableFrom,ot as observeElementSize,de as once,fe as pairwise,re as safeStorage,me as tap,le as throttle,z as throttleFn,qt as timeCodeToString,it as timeout,Ye as videoHeightToQuality,Je as videoQualityToHeight,Xe as videoSizeToQuality};
6
+ var xe=Object.defineProperty;var ye=(t,e)=>{for(var r in e)xe(t,r,{get:e[r],enumerable:!0})};var Oe="1.0.38-dev.abb9bed7.0";var f=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(r=>typeof r=="function"?r():r.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var v=t=>{throw new Error(`${t} is value of unexpected type`)},we=t=>{};var g=()=>{};var l=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,r){let n;r?typeof r=="function"?n={next:r,error:g}:n={next:o=>r.next(o),error:o=>r.error?.(o)}:n={next:g,error:g};let i=typeof e=="function"?{next:o=>{try{e(o)}catch(a){n.next(a)}},error:o=>n.next(o)}:{next:o=>e.next(o),error:o=>e.error?e.error(o):n.next(o)},s;try{s=this._subscribe(i)}catch(o){i.error?.(o)}return new f().add(()=>{switch(i.next=g,i.error=g,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return v(s)}})}pipe(...e){return e.reduce((r,n)=>n(r),this)}_subscribe(e){}};var h=class extends l{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(r){this.subscribers.forEach(n=>n.next(r))}error(r){this.subscribers.forEach(n=>n.error?.(r))}_subscribe(r){let n=this.keyCounter++;return this.subscribers.set(n,r),new f().add(()=>this.subscribers.delete(n))}};var M=class{constructor(){this.log$=new h;this.logs=[];this.log=e=>{let r={...e,timestamp:Date.now()};this.logs.push(r),this.log$.next(r)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...r)=>{let n;try{n=e(...r)}catch{n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(r=>({component:e,...r}))}};function Ee(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function Se(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function y(t){return typeof t<"u"&&t!==null}function V(t){return t==null}function Re(t,e){if(!t?.length)throw new Error(e)}function Ae(t,e){if(t?.length)throw new Error(e)}var ke=(t,e,r)=>new Promise((n,i)=>{e.addEventListener("abort",()=>{a(),c.remove()});let s=()=>{a(),i()},o=()=>{a(),n()},a=()=>{p&&clearTimeout(p),c.removeEventListener("load",o),c.removeEventListener("error",s)},p;r&&(p=window.setTimeout(s,r));let c=document.createElement("script");c.addEventListener("load",o),c.addEventListener("error",s),c.src=t,document.head.appendChild(c)});var Ce=typeof window.performance?.now=="function"?()=>window.performance.now():()=>Date.now();var Pe=(t,e)=>async(...r)=>{let n=e(...r),i=t.aborted,s;for(;!i&&!t.aborted;)try{let o=await n.next(s);i=o.done??!1,s=o.value}catch(o){await n.throw(o)}return s};var ee=()=>/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(navigator.appVersion??navigator.userAgent)||navigator?.userAgentData?.mobile,_=class{constructor(){this.detect()}get browser(){return this._currentBrowser}get device(){return this._currentDevice}get isTouch(){return this._maxTouchPoints>0}get isIOS(){return["iPhone","iPad","iPod"].includes(this.device)}get isMac(){return this.device==="Mac"}get isApple(){return this.isIOS||this.isMac}get isIphoneOrOldIpad(){if(!this.isApple||!this.isTouch)return!1;let e=this.device==="iPad"||window?.screen.width>700,r=this._iosVersion;return!e||e&&!!r&&r<16}get isAndroid(){return this.device==="Android"}get isMobile(){return this._isMobile}get iOSVersion(){return this._iosVersion}get macVersion(){return this._macVersion}get isYandex(){return this.browser==="Yandex"}get isSafari(){return this.browser==="Safari"}get isSamsungBrowser(){return this.browser==="SamsungBrowser"}get isHDR(){return this._isHdr}detect(){let{userAgent:e,maxTouchPoints:r}=navigator;try{this._maxTouchPoints=r,this._isHdr=!!matchMedia("(dynamic-range: high)")?.matches}catch(n){console.error(n)}try{this._isMobile=ee()}catch(n){console.error(n)}this.detectBrowser(e),this.detectDevice(e),this.isIOS&&this.detectIOSVersion(),this.isMac&&this.detectMacVersion()}detectBrowser(e){try{let r=/yabrowser/i.test(e)?"Yandex":void 0,n=/samsungbrowser/i.test(e)?"SamsungBrowser":void 0,i=/chrome|crios/i.test(e)?"Chrome":void 0,s=/chromium/i.test(e)?"Chromium":void 0,o=/firefox|fxios/i.test(e)?"Firefox":void 0,a=/webkit|safari|khtml/i.test(e)?"Safari":void 0,p=/opr\//i.test(e)?"Opera":void 0,c=/edg/i.test(e)?"Edge":void 0;this._currentBrowser=r||n||o||p||c||i||s||a||"Rest"}catch(r){console.error(r)}}detectDevice(e){try{let r=/android/i.test(e)?"Android":void 0,n=/iphone/i.test(e)?"iPhone":void 0,i=/ipad/i.test(e)?"iPad":void 0,s=/ipod/i.test(e)?"iPod":void 0,o=/mac/i.test(e)?"Mac":void 0,a=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(e)?"RestMobile":void 0;this._currentDevice=r||n||i||s||a||o||"Desktop"}catch(r){console.error(r)}}detectIOSVersion(){try{let{userAgent:e}=window.navigator,r=e.match(/Version\/(\d+(\.\d+)?)/i);if(!r)return;let n=r[1],i=parseFloat(n);if(isNaN(i))return;this._iosVersion=i}catch(e){console.error(e)}}detectMacVersion(){try{let{userAgent:e}=window.navigator,r=e.match(/Version\/(\d+)/);if(!r)return;let n=r[1],i=parseInt(n,10);if(isNaN(i))return;this._macVersion=i}catch(e){console.error(e)}}},Le=new _;var Me=(t,{start:e=0,factor:r=2,max:n=1/0,min:i=e,random:s=0}={})=>{let o=e;return o*=r**t,o*=1+(Math.random()*s*2-s),o=Math.round(o),o=Math.min(o,n),o=Math.max(o,i),o};var te={};ye(te,{clear:()=>Ue,get:()=>_e,has:()=>Qe,isPersistent:()=>Ve,remove:()=>De,set:()=>Ne});var O,x,N=`vk-videoplayer-dummy-key-${Math.random()}`,w=()=>{if(x!==void 0)return x;try{localStorage.setItem(N,"test"),localStorage.removeItem(N),x=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem(N),x=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)x=2;else throw e}else throw t}return x===2&&(O=new Map),x},Ve=()=>w()===0,_e=t=>{let e=w();switch(e){case 0:return localStorage.getItem(t)??void 0;case 1:return sessionStorage.getItem(t)??void 0;case 2:return O?.get(t);default:v(e)}},Ne=(t,e)=>{let r=w();switch(r){case 0:try{localStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void O?.set(t,e);default:v(r)}},Qe=t=>{let e=w();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return O?.has(t)??!1;default:return v(e),!1}},De=t=>{let e=w();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:return void O?.delete(t);default:v(e)}},Ue=()=>{let t=w();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return O?.clear();default:v(t)}};var Be=()=>{let t,e;try{t=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?t=!0:(t=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let r=e?new URL(e).hostname:void 0;return{isEmbed:t,host:r}};var Q=(d=>(d.INVARIANT="Invariant quality",d.Q_144P="144p",d.Q_240P="240p",d.Q_360P="360p",d.Q_480P="480p",d.Q_720P="720p",d.Q_1080P="1080p",d.Q_1440P="1440p",d.Q_2160P="2160p",d.Q_4320P="4320p",d))(Q||{});var m={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"720p":{width:1280,height:720},"1080p":{width:1920,height:1080},"1440p":{width:2560,height:1440},"2160p":{width:3840,height:2160},"4320p":{width:7680,height:4320}},Fe=(t,e)=>m[t].height>m[e].height,ze=(t,e)=>m[t].height>=m[e].height,D=(t,e)=>m[t].height<m[e].height,je=(t,e)=>m[t].height<=m[e].height,We=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:D(e,r)?1:-1)[0],re=Object.keys(m).sort((t,e)=>D(t,e)?-1:1),Ge=(t,e=.02)=>[...re].find(n=>m[n].height*(1+e)>=t),He=({width:t,height:e})=>{let r=Math.min(t,e),n=Math.max(t,e);return re.find(i=>{let s=m[i];return s.width>=n&&s.height>=r})},qe=t=>m[t].height,U=t=>t==="Invariant quality",Ke=t=>t.every(e=>!U(e));function Ye(t){if(U(t))throw new Error("Expected exact quality")}var $e=(t,e)=>{let r={};for(let n of Object.keys(e)){let i=e[n],s=t[n];Array.isArray(i)&&Array.isArray(s)?r[n]=s:typeof i=="object"&&typeof s=="object"?r[n]=$e(s,i):r[n]=n in t?s:i}return r};var zt=t=>{let e="";return t>=3600&&(e+=Math.floor(t/3600)+"h",t=t%3600),t>=60&&(e+=Math.floor(t/60)+"m",t=t%60),t>0&&(e+=Math.floor(t)+"s"),e};function B(t,e=0,r){let n,i,s,o,a,p,c=0,d=!1,b=!1,P=!0,$=!e&&e!==0&&typeof window.requestAnimationFrame=="function";r&&(d=!!r.leading,b="maxWait"in r,s=r?.maxWait?Math.max(+r?.maxWait||0,e):s,P="trailing"in r?!!r.trailing:P);function L(u){let T=n,I=i;return n=i=void 0,c=u,o=t.apply(I,T),o}function E(u,T){return $?(a&&window.cancelAnimationFrame(a),window.requestAnimationFrame(u)):setTimeout(u,T)}function me(u){if($){window.cancelAnimationFrame(u);return}clearTimeout(u)}function Te(u){return c=u,a=E(S,e),d?L(u):o}function ve(u){let T=u-p,I=u-c,Z=e-T;return b?Math.min(Z,s-I):Z}function X(u){let T=u-p,I=u-c;return p===void 0||T>=e||T<0||b&&I>=s}function S(){let u=Date.now();if(X(u))return J(u);a=E(S,ve(u))}function J(u){return a=void 0,P&&n?L(u):(n=i=void 0,o)}function he(){a!==void 0&&me(a),c=0,n=p=i=a=void 0}function Ie(){return a===void 0?o:J(Date.now())}function ge(){return a!==void 0}function R(...u){let T=Date.now(),I=X(T);if(n=u,i=this,p=T,I){if(a===void 0)return Te(p);if(b)return a=E(S,e),L(p)}return a===void 0&&(a=E(S,e)),o}return R.cancel=he,R.flush=Ie,R.pending=ge,R}var F=(t,e=0,r)=>B(t,e,{...{leading:!0,trailing:!0},...r,maxWait:e});var A=(t,e)=>{if(t===null||typeof t!="object")return t;let r=Array.isArray(t)?[]:{};for(let n in t){if(typeof e=="function"){let i=e(t[n],n,t,r);if(i!==void 0){r[n]=i;continue}}typeof t[n]=="object"?r[n]=A(t[n],e):r[n]=t[n]}return r};var Xe=t=>A(t);var Je=300,Ze=(t,e=Je)=>new l(r=>{let{width:n,height:i}=t.getBoundingClientRect();if(r.next({width:n,height:i}),!window.ResizeObserver)return;let s=new ResizeObserver(F(o=>{let a=o[0];if(!a)return;let p,c;a.contentBoxSize&&a.contentBoxSize[0]?(c=a.contentBoxSize[0].blockSize,p=a.contentBoxSize[0].inlineSize):a.contentRect&&(p=a.contentRect.width,c=a.contentRect.height),y(p)&&y(c)&&r.next({width:p,height:c})},e));return s.observe(t),()=>s.disconnect()});var et=t=>{t.removeAttribute("src"),t.load()};var k=class extends h{constructor(e){super(),this.value=e}next(e){super.next(this.value=e)}error(e){super.error(this.value=e)}getValue(){return this.value}_subscribe(e){let r=super._subscribe(e);return e.next(this.value),r}};function ne(t){return new l(e=>{let r={},n=Object.keys(t).length,i=s=>o=>{s in r||n--,r[s]=o,n===0&&e.next(r)};return Object.entries(t).reduce((s,[o,a])=>s.add(a.subscribe(i(o))),new f)})}function ie(...t){return new l(e=>t.reduce((r,n)=>r.add(n.subscribe(e)),new f))}var tt=t=>new l(e=>{let r=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},t);return()=>window.clearTimeout(r)});var rt=t=>new l(e=>{let r=window.setInterval(()=>e.next(),t);return()=>{r&&(window.clearInterval(r),r=void 0)}});var nt=t=>new l(e=>{t.forEach(r=>e.next(r))});var it=(t,e)=>new l(r=>{let n=i=>r.next(i);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)});function oe(t){return e=>new l(r=>e.subscribe(new z(r,t)))}var z=class{constructor(e,r){this.destination=e;this.size=r;this.lastValues=[]}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){this.destination.error?.(e)}};var ot={leading:!1,trailing:!0};function se(t,e=ot){return r=>new l(n=>r.subscribe(new j(n,t,e)))}var j=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,y(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(r){if(this.destination.error)this.destination.error(r);else throw r}this.timeout=void 0},this.time)}error(e){this.destination.error?.(e)}};var st={leading:!0,trailing:!1};function ae(t,e=st){return r=>new l(n=>r.subscribe(new W(n,t,e)))}var W=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,V(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){this.destination.error?.(e)}};function le(t){return e=>new l(r=>e.subscribe(new G(r,t)))}var G=class{constructor(e,r){this.destination=e;this.predicate=r}next(e){let r;try{r=this.predicate(e)}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function ce(t=(e,r)=>e===r){return e=>new l(r=>e.subscribe(new H(r,t)))}var ue={},H=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=ue}next(e){let r;try{r=this.lastValue===ue||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function C(t){return e=>new l(r=>e.subscribe(new q(r,t)))}var q=class{constructor(e,r){this.destination=e;this.mapper=r}next(e){let r;try{r=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(r)}error(e){this.destination.error?.(e)}};function pe(t){return C(()=>t)}function be(){return t=>new l(e=>{let r=!1,n=!1,i=t.subscribe(s=>{r||(r=!0,e.next(s)),n&&i.unsubscribe()},s=>{r=!0,e.error?.(s),n&&i.unsubscribe()});return n=!0,r&&i.unsubscribe(),i})}function de(){return t=>new l(e=>t.subscribe(new K(e)))}var K=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let r=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([r,e])}error(e){this.destination.error?.(e)}};function fe(t){return e=>new l(r=>e.subscribe(new Y(r,t)))}var Y=class{constructor(e,r){this.destination=e;this.effect=r}next(e){try{this.effect(e)}catch(r){throw this.error(r),r}this.destination.next(e)}error(e){this.destination.error?.(e)}};var at=(a=>(a.NETWORK="network",a.VIDEO_PIPELINE="video_pipeline",a.EXTERNAL_API="external_api",a.PARSER="parser",a.DOM="dom",a.WTF="wtf",a.FATAL="fatal",a))(at||{});var lt=(b=>(b.Armenian="58",b.Azerbaijani="57",b.Belarusian="114",b.English="3",b.Kazakh="97",b.Portuguese="73",b.Russian="0",b.Spanish="4",b.Ukrainian="1",b.Uzbek="65",b.Vietnamese="75",b))(lt||{}),ut="vk.com",Mn=async(t,e,r)=>{let n=new URL(`https://${ut}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),t!==void 0&&n.searchParams.set("lang",t);let s=await(await fetch(n.toString())).json();return ct(s,r)},ct=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,n])=>[r.substring(`${e}_`.length),pt(n)])),pt=t=>Array.isArray(t)?t[0]:t;var bt=(r=>(r.RU="ru",r.EN="en",r))(bt||{});export{at as ErrorCategory,bt as InterfaceLanguage,M as Logger,l as Observable,h as Subject,f as Subscription,Oe as VERSION,lt as VKNumericLanguage,k as ValueSubject,Q as VideoQuality,Pe as abortable,ke as addScript,Ke as areQualitiesExact,Ae as assertEmptyArray,v as assertNever,Ee as assertNonNullable,Re as assertNotEmptyArray,Se as assertNullable,Ye as assertQualityIsExact,oe as buffer,we as checkNever,et as clearVideoElement,Le as clientChecker,Xe as cloneDeep,A as cloneDeepWith,ne as combine,se as debounce,B as debounceFn,Be as detectEmbed,$e as fillWithDefault,le as filter,ce as filterChanged,it as fromEvent,Me as getExponentialDelay,We as getHighestQuality,rt as interval,Fe as isHigher,ze as isHigherOrEqual,U as isInvariantQuality,D as isLower,je as isLowerOrEqual,ee as isMobile,y as isNonNullable,V as isNullable,Mn as loadVKLangPack,C as map,pe as mapTo,ie as merge,g as noop,Ce as now,nt as observableFrom,Ze as observeElementSize,be as once,de as pairwise,te as safeStorage,fe as tap,ae as throttle,F as throttleFn,zt as timeCodeToString,tt as timeout,Ge as videoHeightToQuality,qe as videoQualityToHeight,He as videoSizeToQuality};
package/evergreen.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @vkontakte/videoplayer-shared v1.0.38-dev.87754f30.0
3
- * Tue, 06 Aug 2024 11:52:24 GMT
2
+ * @vkontakte/videoplayer-shared v1.0.38-dev.abb9bed7.0
3
+ * Mon, 19 Aug 2024 11:00:39 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-38/doc/
5
5
  */
6
- var ye=Object.defineProperty;var Oe=(t,e)=>{for(var r in e)ye(t,r,{get:e[r],enumerable:!0})};var we="1.0.38-dev.87754f30.0";var f=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(r=>typeof r=="function"?r():r.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var v=t=>{throw new Error(`${t} is value of unexpected type`)},Ee=t=>{};var g=()=>{};var l=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,r){let n;r?typeof r=="function"?n={next:r,error:g}:n={next:o=>r.next(o),error:o=>r.error?.(o)}:n={next:g,error:g};let s=typeof e=="function"?{next:o=>{try{e(o)}catch(a){n.next(a)}},error:o=>n.next(o)}:{next:o=>e.next(o),error:o=>e.error?e.error(o):n.next(o)},i;try{i=this._subscribe(s)}catch(o){s.error?.(o)}return new f().add(()=>{switch(s.next=g,s.error=g,typeof i){case"function":i();return;case"object":i.unsubscribe();return;case"undefined":return;default:return v(i)}})}pipe(...e){return e.reduce((r,n)=>n(r),this)}_subscribe(e){}};var I=class extends l{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(r){this.subscribers.forEach(n=>n.next(r))}error(r){this.subscribers.forEach(n=>n.error?.(r))}_subscribe(r){let n=this.keyCounter++;return this.subscribers.set(n,r),new f().add(()=>this.subscribers.delete(n))}};var V=class{constructor(){this.log$=new I;this.logs=[];this.log=e=>{let r={...e,timestamp:Date.now()};this.logs.push(r),this.log$.next(r)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...r)=>{let n;try{n=e(...r)}catch{n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(r=>({component:e,...r}))}};function Se(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function Ae(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function y(t){return typeof t<"u"&&t!==null}function Q(t){return t==null}function Re(t,e){if(!t?.length)throw new Error(e)}function Ce(t,e){if(t?.length)throw new Error(e)}var ke=(t,e,r)=>new Promise((n,s)=>{e.addEventListener("abort",()=>{a(),b.remove()});let i=()=>{a(),s()},o=()=>{a(),n()},a=()=>{u&&clearTimeout(u),b.removeEventListener("load",o),b.removeEventListener("error",i)},u;r&&(u=window.setTimeout(i,r));let b=document.createElement("script");b.addEventListener("load",o),b.addEventListener("error",i),b.src=t,document.head.appendChild(b)});var Le=typeof window.performance?.now=="function"?()=>window.performance.now():()=>Date.now();var Pe=(t,e)=>async(...r)=>{let n=e(...r),s=t.aborted,i;for(;!s&&!t.aborted;)try{let o=await n.next(i);s=o.done??!1,i=o.value}catch(o){await n.throw(o)}return i};var ee=(c=>(c.Unknown="Unknown",c.Yandex="Yandex",c.Chrome="Chrome",c.Chromium="Chromium",c.Firefox="Firefox",c.Safari="Safari",c.Opera="Opera",c.Edge="Edge",c.SamsungBrowser="SamsungBrowser",c.Rest="Rest",c))(ee||{}),te=(u=>(u.Unknown="Unknown",u.Android="Android",u.iPhone="iPhone",u.iPad="iPad",u.iPod="iPod",u.RestMobile="RestMobile",u.Mac="Mac",u.Desktop="Desktop",u))(te||{}),L=()=>{let{userAgent:t}=window.navigator,e=/yabrowser/i.test(t)?"Yandex":void 0,r=/samsungbrowser/i.test(t)?"SamsungBrowser":void 0,n=/chrome|crios/i.test(t)?"Chrome":void 0,s=/chromium/i.test(t)?"Chromium":void 0,i=/firefox|fxios/i.test(t)?"Firefox":void 0,o=/webkit|safari|khtml/i.test(t)?"Safari":void 0,a=/opr\//i.test(t)?"Opera":void 0,u=/edg/i.test(t)?"Edge":void 0,b=/android/i.test(t)?"Android":void 0,c=/iphone/i.test(t)?"iPhone":void 0,d=/ipad/i.test(t)?"iPad":void 0,E=/ipod/i.test(t)?"iPod":void 0,A=/mac/i.test(t)?"Mac":void 0,S=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(t)?"RestMobile":void 0;return{browser:e||r||i||a||u||n||s||o||"Rest",device:b||c||d||E||S||A||"Desktop"}},Me=(t=!1)=>{let r=["iPhone","iPad","iPod"].includes(L().device);if(!t)return r;let{userAgent:n,maxTouchPoints:s}=window.navigator;return!!(r||/macintosh/i.test(n)&&s>0)},Ne=()=>{let{userAgent:t}=window.navigator,e=t.match(/Version\/(\d+(\.\d+)?)/i);if(!e)return null;let r=e[1],n=parseFloat(r);return isNaN(n)?null:n},Ve=()=>L().device==="Android",Qe=()=>["Mac","iPhone","iPad","iPod"].includes(L().device),_e=()=>/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(navigator.appVersion??navigator.userAgent)||navigator?.userAgentData?.mobile;var De=(t,{start:e=0,factor:r=2,max:n=1/0,min:s=e,random:i=0}={})=>{let o=e;return o*=r**t,o*=1+(Math.random()*i*2-i),o=Math.round(o),o=Math.min(o,n),o=Math.max(o,s),o};var re={};Oe(re,{clear:()=>We,get:()=>Be,has:()=>ze,isPersistent:()=>Ue,remove:()=>je,set:()=>Fe});var O,h,_=`vk-videoplayer-dummy-key-${Math.random()}`,w=()=>{if(h!==void 0)return h;try{localStorage.setItem(_,"test"),localStorage.removeItem(_),h=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem(_),h=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)h=2;else throw e}else throw t}return h===2&&(O=new Map),h},Ue=()=>w()===0,Be=t=>{let e=w();switch(e){case 0:return localStorage.getItem(t)??void 0;case 1:return sessionStorage.getItem(t)??void 0;case 2:return O?.get(t);default:v(e)}},Fe=(t,e)=>{let r=w();switch(r){case 0:try{localStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void O?.set(t,e);default:v(r)}},ze=t=>{let e=w();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return O?.has(t)??!1;default:return v(e),!1}},je=t=>{let e=w();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:return void O?.delete(t);default:v(e)}},We=()=>{let t=w();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return O?.clear();default:v(t)}};var Ge=()=>{let t,e;try{t=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?t=!0:(t=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let r=e?new URL(e).hostname:void 0;return{isEmbed:t,host:r}};var D=(c=>(c.INVARIANT="Invariant quality",c.Q_144P="144p",c.Q_240P="240p",c.Q_360P="360p",c.Q_480P="480p",c.Q_720P="720p",c.Q_1080P="1080p",c.Q_1440P="1440p",c.Q_2160P="2160p",c.Q_4320P="4320p",c))(D||{});var m={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"720p":{width:1280,height:720},"1080p":{width:1920,height:1080},"1440p":{width:2560,height:1440},"2160p":{width:3840,height:2160},"4320p":{width:7680,height:4320}},qe=(t,e)=>m[t].height>m[e].height,He=(t,e)=>m[t].height>=m[e].height,U=(t,e)=>m[t].height<m[e].height,Ke=(t,e)=>m[t].height<=m[e].height,$e=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:U(e,r)?1:-1)[0],ne=Object.keys(m).sort((t,e)=>U(t,e)?-1:1),Ye=(t,e=.02)=>[...ne].find(n=>m[n].height*(1+e)>=t),Xe=({width:t,height:e})=>{let r=Math.min(t,e),n=Math.max(t,e);return ne.find(s=>{let i=m[s];return i.width>=n&&i.height>=r})},Je=t=>m[t].height,B=t=>t==="Invariant quality",Ze=t=>t.every(e=>!B(e));function et(t){if(B(t))throw new Error("Expected exact quality")}var tt=(t,e)=>{let r={};for(let n of Object.keys(e)){let s=e[n],i=t[n];Array.isArray(s)&&Array.isArray(i)?r[n]=i:typeof s=="object"&&typeof i=="object"?r[n]=tt(i,s):r[n]=n in t?i:s}return r};var qt=t=>{let e="";return t>=3600&&(e+=Math.floor(t/3600)+"h",t=t%3600),t>=60&&(e+=Math.floor(t/60)+"m",t=t%60),t>0&&(e+=Math.floor(t)+"s"),e};function F(t,e=0,r){let n,s,i,o,a,u,b=0,c=!1,d=!1,E=!0,A=!e&&e!==0&&typeof window.requestAnimationFrame=="function";r&&(c=!!r.leading,d="maxWait"in r,i=r?.maxWait?Math.max(+r?.maxWait||0,e):i,E="trailing"in r?!!r.trailing:E);function S(p){let T=n,x=s;return n=s=void 0,b=p,o=t.apply(x,T),o}function R(p,T){return A?(a&&window.cancelAnimationFrame(a),window.requestAnimationFrame(p)):setTimeout(p,T)}function Te(p){if(A){window.cancelAnimationFrame(p);return}clearTimeout(p)}function ve(p){return b=p,a=R(C,e),c?S(p):o}function Ie(p){let T=p-u,x=p-b,Z=e-T;return d?Math.min(Z,i-x):Z}function X(p){let T=p-u,x=p-b;return u===void 0||T>=e||T<0||d&&x>=i}function C(){let p=Date.now();if(X(p))return J(p);a=R(C,Ie(p))}function J(p){return a=void 0,E&&n?S(p):(n=s=void 0,o)}function xe(){a!==void 0&&Te(a),b=0,n=u=s=a=void 0}function ge(){return a===void 0?o:J(Date.now())}function he(){return a!==void 0}function k(...p){let T=Date.now(),x=X(T);if(n=p,s=this,u=T,x){if(a===void 0)return ve(u);if(d)return a=R(C,e),S(u)}return a===void 0&&(a=R(C,e)),o}return k.cancel=xe,k.flush=ge,k.pending=he,k}var z=(t,e=0,r)=>F(t,e,{...{leading:!0,trailing:!0},...r,maxWait:e});var P=(t,e)=>{if(t===null||typeof t!="object")return t;let r=Array.isArray(t)?[]:{};for(let n in t){if(typeof e=="function"){let s=e(t[n],n,t,r);if(s!==void 0){r[n]=s;continue}}typeof t[n]=="object"?r[n]=P(t[n],e):r[n]=t[n]}return r};var rt=t=>P(t);var nt=300,ot=(t,e=nt)=>new l(r=>{let{width:n,height:s}=t.getBoundingClientRect();if(r.next({width:n,height:s}),!window.ResizeObserver)return;let i=new ResizeObserver(z(o=>{let a=o[0];if(!a)return;let u,b;a.contentBoxSize&&a.contentBoxSize[0]?(b=a.contentBoxSize[0].blockSize,u=a.contentBoxSize[0].inlineSize):a.contentRect&&(u=a.contentRect.width,b=a.contentRect.height),y(u)&&y(b)&&r.next({width:u,height:b})},e));return i.observe(t),()=>i.disconnect()});var M=class extends I{constructor(r){super();this.value=r}next(r){super.next(this.value=r)}error(r){super.error(this.value=r)}getValue(){return this.value}_subscribe(r){let n=super._subscribe(r);return r.next(this.value),n}};function oe(t){return new l(e=>{let r={},n=Object.keys(t).length,s=i=>o=>{i in r||n--,r[i]=o,n===0&&e.next(r)};return Object.entries(t).reduce((i,[o,a])=>i.add(a.subscribe(s(o))),new f)})}function ie(...t){return new l(e=>t.reduce((r,n)=>r.add(n.subscribe(e)),new f))}var it=t=>new l(e=>{let r=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},t);return()=>window.clearTimeout(r)});var st=t=>new l(e=>{let r=window.setInterval(()=>e.next(),t);return()=>{r&&(window.clearInterval(r),r=void 0)}});var at=t=>new l(e=>{t.forEach(r=>e.next(r))});var lt=(t,e)=>new l(r=>{let n=s=>r.next(s);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)});function se(t){return e=>new l(r=>e.subscribe(new j(r,t)))}var j=class{constructor(e,r){this.destination=e;this.size=r;this.lastValues=[]}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){this.destination.error?.(e)}};var ut={leading:!1,trailing:!0};function ae(t,e=ut){return r=>new l(n=>r.subscribe(new W(n,t,e)))}var W=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,y(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(r){if(this.destination.error)this.destination.error(r);else throw r}this.timeout=void 0},this.time)}error(e){this.destination.error?.(e)}};var ct={leading:!0,trailing:!1};function le(t,e=ct){return r=>new l(n=>r.subscribe(new G(n,t,e)))}var G=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,Q(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){this.destination.error?.(e)}};function ue(t){return e=>new l(r=>e.subscribe(new q(r,t)))}var q=class{constructor(e,r){this.destination=e;this.predicate=r}next(e){let r;try{r=this.predicate(e)}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function pe(t=(e,r)=>e===r){return e=>new l(r=>e.subscribe(new H(r,t)))}var ce={},H=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=ce}next(e){let r;try{r=this.lastValue===ce||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function N(t){return e=>new l(r=>e.subscribe(new K(r,t)))}var K=class{constructor(e,r){this.destination=e;this.mapper=r}next(e){let r;try{r=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(r)}error(e){this.destination.error?.(e)}};function be(t){return N(()=>t)}function de(){return t=>new l(e=>{let r=!1,n=!1,s=t.subscribe(i=>{r||(r=!0,e.next(i)),n&&s.unsubscribe()},i=>{r=!0,e.error?.(i),n&&s.unsubscribe()});return n=!0,r&&s.unsubscribe(),s})}function fe(){return t=>new l(e=>t.subscribe(new $(e)))}var $=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let r=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([r,e])}error(e){this.destination.error?.(e)}};function me(t){return e=>new l(r=>e.subscribe(new Y(r,t)))}var Y=class{constructor(e,r){this.destination=e;this.effect=r}next(e){try{this.effect(e)}catch(r){throw this.error(r),r}this.destination.next(e)}error(e){this.destination.error?.(e)}};var pt=(a=>(a.NETWORK="network",a.VIDEO_PIPELINE="video_pipeline",a.EXTERNAL_API="external_api",a.PARSER="parser",a.DOM="dom",a.WTF="wtf",a.FATAL="fatal",a))(pt||{});var bt=(d=>(d.Armenian="58",d.Azerbaijani="57",d.Belarusian="114",d.English="3",d.Kazakh="97",d.Portuguese="73",d.Russian="0",d.Spanish="4",d.Ukrainian="1",d.Uzbek="65",d.Vietnamese="75",d))(bt||{}),dt="vk.com",Vn=async(t,e,r)=>{let n=new URL(`https://${dt}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),t!==void 0&&n.searchParams.set("lang",t);let i=await(await fetch(n.toString())).json();return ft(i,r)},ft=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,n])=>[r.substring(`${e}_`.length),mt(n)])),mt=t=>Array.isArray(t)?t[0]:t;var Tt=(r=>(r.RU="ru",r.EN="en",r))(Tt||{});export{ee as CurrentClientBrowser,te as CurrentClientDevice,pt as ErrorCategory,Tt as InterfaceLanguage,V as Logger,l as Observable,I as Subject,f as Subscription,we as VERSION,bt as VKNumericLanguage,M as ValueSubject,D as VideoQuality,Pe as abortable,ke as addScript,Ze as areQualitiesExact,Ce as assertEmptyArray,v as assertNever,Se as assertNonNullable,Re as assertNotEmptyArray,Ae as assertNullable,et as assertQualityIsExact,se as buffer,Ee as checkNever,rt as cloneDeep,P as cloneDeepWith,oe as combine,ae as debounce,F as debounceFn,Ge as detectEmbed,tt as fillWithDefault,ue as filter,pe as filterChanged,lt as fromEvent,L as getCurrentBrowser,De as getExponentialDelay,$e as getHighestQuality,Ne as getIOSVersion,st as interval,Ve as isAndroid,qe as isHigher,He as isHigherOrEqual,Me as isIOS,B as isInvariantQuality,U as isLower,Ke as isLowerOrEqual,Qe as isMacLike,_e as isMobile,y as isNonNullable,Q as isNullable,Vn as loadVKLangPack,N as map,be as mapTo,ie as merge,g as noop,Le as now,at as observableFrom,ot as observeElementSize,de as once,fe as pairwise,re as safeStorage,me as tap,le as throttle,z as throttleFn,qt as timeCodeToString,it as timeout,Ye as videoHeightToQuality,Je as videoQualityToHeight,Xe as videoSizeToQuality};
6
+ var xe=Object.defineProperty;var ye=(t,e)=>{for(var r in e)xe(t,r,{get:e[r],enumerable:!0})};var Oe="1.0.38-dev.abb9bed7.0";var f=class{constructor(){this.subscriptions=[]}unsubscribe(){let e=this.subscriptions;this.subscriptions=[],e.forEach(r=>typeof r=="function"?r():r.unsubscribe())}add(e){return this.subscriptions.push(e),this}};var v=t=>{throw new Error(`${t} is value of unexpected type`)},we=t=>{};var g=()=>{};var l=class{constructor(e){e&&(this._subscribe=e)}subscribe(e,r){let n;r?typeof r=="function"?n={next:r,error:g}:n={next:o=>r.next(o),error:o=>r.error?.(o)}:n={next:g,error:g};let i=typeof e=="function"?{next:o=>{try{e(o)}catch(a){n.next(a)}},error:o=>n.next(o)}:{next:o=>e.next(o),error:o=>e.error?e.error(o):n.next(o)},s;try{s=this._subscribe(i)}catch(o){i.error?.(o)}return new f().add(()=>{switch(i.next=g,i.error=g,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return v(s)}})}pipe(...e){return e.reduce((r,n)=>n(r),this)}_subscribe(e){}};var h=class extends l{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(r){this.subscribers.forEach(n=>n.next(r))}error(r){this.subscribers.forEach(n=>n.error?.(r))}_subscribe(r){let n=this.keyCounter++;return this.subscribers.set(n,r),new f().add(()=>this.subscribers.delete(n))}};var M=class{constructor(){this.log$=new h;this.logs=[];this.log=e=>{let r={...e,timestamp:Date.now()};this.logs.push(r),this.log$.next(r)};this.getAllLogs=()=>this.logs}createCustomLog(e){return(...r)=>{let n;try{n=e(...r)}catch{n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(e){return this.createCustomLog(r=>({component:e,...r}))}};function Ee(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function Se(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function y(t){return typeof t<"u"&&t!==null}function V(t){return t==null}function Re(t,e){if(!t?.length)throw new Error(e)}function Ae(t,e){if(t?.length)throw new Error(e)}var ke=(t,e,r)=>new Promise((n,i)=>{e.addEventListener("abort",()=>{a(),c.remove()});let s=()=>{a(),i()},o=()=>{a(),n()},a=()=>{p&&clearTimeout(p),c.removeEventListener("load",o),c.removeEventListener("error",s)},p;r&&(p=window.setTimeout(s,r));let c=document.createElement("script");c.addEventListener("load",o),c.addEventListener("error",s),c.src=t,document.head.appendChild(c)});var Ce=typeof window.performance?.now=="function"?()=>window.performance.now():()=>Date.now();var Pe=(t,e)=>async(...r)=>{let n=e(...r),i=t.aborted,s;for(;!i&&!t.aborted;)try{let o=await n.next(s);i=o.done??!1,s=o.value}catch(o){await n.throw(o)}return s};var ee=()=>/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(navigator.appVersion??navigator.userAgent)||navigator?.userAgentData?.mobile,_=class{constructor(){this.detect()}get browser(){return this._currentBrowser}get device(){return this._currentDevice}get isTouch(){return this._maxTouchPoints>0}get isIOS(){return["iPhone","iPad","iPod"].includes(this.device)}get isMac(){return this.device==="Mac"}get isApple(){return this.isIOS||this.isMac}get isIphoneOrOldIpad(){if(!this.isApple||!this.isTouch)return!1;let e=this.device==="iPad"||window?.screen.width>700,r=this._iosVersion;return!e||e&&!!r&&r<16}get isAndroid(){return this.device==="Android"}get isMobile(){return this._isMobile}get iOSVersion(){return this._iosVersion}get macVersion(){return this._macVersion}get isYandex(){return this.browser==="Yandex"}get isSafari(){return this.browser==="Safari"}get isSamsungBrowser(){return this.browser==="SamsungBrowser"}get isHDR(){return this._isHdr}detect(){let{userAgent:e,maxTouchPoints:r}=navigator;try{this._maxTouchPoints=r,this._isHdr=!!matchMedia("(dynamic-range: high)")?.matches}catch(n){console.error(n)}try{this._isMobile=ee()}catch(n){console.error(n)}this.detectBrowser(e),this.detectDevice(e),this.isIOS&&this.detectIOSVersion(),this.isMac&&this.detectMacVersion()}detectBrowser(e){try{let r=/yabrowser/i.test(e)?"Yandex":void 0,n=/samsungbrowser/i.test(e)?"SamsungBrowser":void 0,i=/chrome|crios/i.test(e)?"Chrome":void 0,s=/chromium/i.test(e)?"Chromium":void 0,o=/firefox|fxios/i.test(e)?"Firefox":void 0,a=/webkit|safari|khtml/i.test(e)?"Safari":void 0,p=/opr\//i.test(e)?"Opera":void 0,c=/edg/i.test(e)?"Edge":void 0;this._currentBrowser=r||n||o||p||c||i||s||a||"Rest"}catch(r){console.error(r)}}detectDevice(e){try{let r=/android/i.test(e)?"Android":void 0,n=/iphone/i.test(e)?"iPhone":void 0,i=/ipad/i.test(e)?"iPad":void 0,s=/ipod/i.test(e)?"iPod":void 0,o=/mac/i.test(e)?"Mac":void 0,a=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(e)?"RestMobile":void 0;this._currentDevice=r||n||i||s||a||o||"Desktop"}catch(r){console.error(r)}}detectIOSVersion(){try{let{userAgent:e}=window.navigator,r=e.match(/Version\/(\d+(\.\d+)?)/i);if(!r)return;let n=r[1],i=parseFloat(n);if(isNaN(i))return;this._iosVersion=i}catch(e){console.error(e)}}detectMacVersion(){try{let{userAgent:e}=window.navigator,r=e.match(/Version\/(\d+)/);if(!r)return;let n=r[1],i=parseInt(n,10);if(isNaN(i))return;this._macVersion=i}catch(e){console.error(e)}}},Le=new _;var Me=(t,{start:e=0,factor:r=2,max:n=1/0,min:i=e,random:s=0}={})=>{let o=e;return o*=r**t,o*=1+(Math.random()*s*2-s),o=Math.round(o),o=Math.min(o,n),o=Math.max(o,i),o};var te={};ye(te,{clear:()=>Ue,get:()=>_e,has:()=>Qe,isPersistent:()=>Ve,remove:()=>De,set:()=>Ne});var O,x,N=`vk-videoplayer-dummy-key-${Math.random()}`,w=()=>{if(x!==void 0)return x;try{localStorage.setItem(N,"test"),localStorage.removeItem(N),x=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem(N),x=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)x=2;else throw e}else throw t}return x===2&&(O=new Map),x},Ve=()=>w()===0,_e=t=>{let e=w();switch(e){case 0:return localStorage.getItem(t)??void 0;case 1:return sessionStorage.getItem(t)??void 0;case 2:return O?.get(t);default:v(e)}},Ne=(t,e)=>{let r=w();switch(r){case 0:try{localStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 1:try{sessionStorage.setItem(t,e)}catch(n){if(n instanceof DOMException)console.error(n);else throw n}break;case 2:return void O?.set(t,e);default:v(r)}},Qe=t=>{let e=w();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return O?.has(t)??!1;default:return v(e),!1}},De=t=>{let e=w();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:return void O?.delete(t);default:v(e)}},Ue=()=>{let t=w();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return O?.clear();default:v(t)}};var Be=()=>{let t,e;try{t=window.self!==window.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?t=!0:(t=!1,console.error(n))}try{window.location.ancestorOrigins&&(e=window.location.ancestorOrigins[window.location.ancestorOrigins.length-1])}catch(n){console.error(n)}try{!e&&document.referrer&&(e=document.referrer)}catch(n){console.error(n)}let r=e?new URL(e).hostname:void 0;return{isEmbed:t,host:r}};var Q=(d=>(d.INVARIANT="Invariant quality",d.Q_144P="144p",d.Q_240P="240p",d.Q_360P="360p",d.Q_480P="480p",d.Q_720P="720p",d.Q_1080P="1080p",d.Q_1440P="1440p",d.Q_2160P="2160p",d.Q_4320P="4320p",d))(Q||{});var m={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"720p":{width:1280,height:720},"1080p":{width:1920,height:1080},"1440p":{width:2560,height:1440},"2160p":{width:3840,height:2160},"4320p":{width:7680,height:4320}},Fe=(t,e)=>m[t].height>m[e].height,ze=(t,e)=>m[t].height>=m[e].height,D=(t,e)=>m[t].height<m[e].height,je=(t,e)=>m[t].height<=m[e].height,We=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:D(e,r)?1:-1)[0],re=Object.keys(m).sort((t,e)=>D(t,e)?-1:1),Ge=(t,e=.02)=>[...re].find(n=>m[n].height*(1+e)>=t),He=({width:t,height:e})=>{let r=Math.min(t,e),n=Math.max(t,e);return re.find(i=>{let s=m[i];return s.width>=n&&s.height>=r})},qe=t=>m[t].height,U=t=>t==="Invariant quality",Ke=t=>t.every(e=>!U(e));function Ye(t){if(U(t))throw new Error("Expected exact quality")}var $e=(t,e)=>{let r={};for(let n of Object.keys(e)){let i=e[n],s=t[n];Array.isArray(i)&&Array.isArray(s)?r[n]=s:typeof i=="object"&&typeof s=="object"?r[n]=$e(s,i):r[n]=n in t?s:i}return r};var zt=t=>{let e="";return t>=3600&&(e+=Math.floor(t/3600)+"h",t=t%3600),t>=60&&(e+=Math.floor(t/60)+"m",t=t%60),t>0&&(e+=Math.floor(t)+"s"),e};function B(t,e=0,r){let n,i,s,o,a,p,c=0,d=!1,b=!1,P=!0,$=!e&&e!==0&&typeof window.requestAnimationFrame=="function";r&&(d=!!r.leading,b="maxWait"in r,s=r?.maxWait?Math.max(+r?.maxWait||0,e):s,P="trailing"in r?!!r.trailing:P);function L(u){let T=n,I=i;return n=i=void 0,c=u,o=t.apply(I,T),o}function E(u,T){return $?(a&&window.cancelAnimationFrame(a),window.requestAnimationFrame(u)):setTimeout(u,T)}function me(u){if($){window.cancelAnimationFrame(u);return}clearTimeout(u)}function Te(u){return c=u,a=E(S,e),d?L(u):o}function ve(u){let T=u-p,I=u-c,Z=e-T;return b?Math.min(Z,s-I):Z}function X(u){let T=u-p,I=u-c;return p===void 0||T>=e||T<0||b&&I>=s}function S(){let u=Date.now();if(X(u))return J(u);a=E(S,ve(u))}function J(u){return a=void 0,P&&n?L(u):(n=i=void 0,o)}function he(){a!==void 0&&me(a),c=0,n=p=i=a=void 0}function Ie(){return a===void 0?o:J(Date.now())}function ge(){return a!==void 0}function R(...u){let T=Date.now(),I=X(T);if(n=u,i=this,p=T,I){if(a===void 0)return Te(p);if(b)return a=E(S,e),L(p)}return a===void 0&&(a=E(S,e)),o}return R.cancel=he,R.flush=Ie,R.pending=ge,R}var F=(t,e=0,r)=>B(t,e,{...{leading:!0,trailing:!0},...r,maxWait:e});var A=(t,e)=>{if(t===null||typeof t!="object")return t;let r=Array.isArray(t)?[]:{};for(let n in t){if(typeof e=="function"){let i=e(t[n],n,t,r);if(i!==void 0){r[n]=i;continue}}typeof t[n]=="object"?r[n]=A(t[n],e):r[n]=t[n]}return r};var Xe=t=>A(t);var Je=300,Ze=(t,e=Je)=>new l(r=>{let{width:n,height:i}=t.getBoundingClientRect();if(r.next({width:n,height:i}),!window.ResizeObserver)return;let s=new ResizeObserver(F(o=>{let a=o[0];if(!a)return;let p,c;a.contentBoxSize&&a.contentBoxSize[0]?(c=a.contentBoxSize[0].blockSize,p=a.contentBoxSize[0].inlineSize):a.contentRect&&(p=a.contentRect.width,c=a.contentRect.height),y(p)&&y(c)&&r.next({width:p,height:c})},e));return s.observe(t),()=>s.disconnect()});var et=t=>{t.removeAttribute("src"),t.load()};var k=class extends h{constructor(e){super(),this.value=e}next(e){super.next(this.value=e)}error(e){super.error(this.value=e)}getValue(){return this.value}_subscribe(e){let r=super._subscribe(e);return e.next(this.value),r}};function ne(t){return new l(e=>{let r={},n=Object.keys(t).length,i=s=>o=>{s in r||n--,r[s]=o,n===0&&e.next(r)};return Object.entries(t).reduce((s,[o,a])=>s.add(a.subscribe(i(o))),new f)})}function ie(...t){return new l(e=>t.reduce((r,n)=>r.add(n.subscribe(e)),new f))}var tt=t=>new l(e=>{let r=window.setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},t);return()=>window.clearTimeout(r)});var rt=t=>new l(e=>{let r=window.setInterval(()=>e.next(),t);return()=>{r&&(window.clearInterval(r),r=void 0)}});var nt=t=>new l(e=>{t.forEach(r=>e.next(r))});var it=(t,e)=>new l(r=>{let n=i=>r.next(i);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)});function oe(t){return e=>new l(r=>e.subscribe(new z(r,t)))}var z=class{constructor(e,r){this.destination=e;this.size=r;this.lastValues=[]}next(e){this.lastValues.length===this.size&&this.lastValues.shift(),this.lastValues.push(e),this.destination.next(this.lastValues)}error(e){this.destination.error?.(e)}};var ot={leading:!1,trailing:!0};function se(t,e=ot){return r=>new l(n=>r.subscribe(new j(n,t,e)))}var j=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,y(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(r){if(this.destination.error)this.destination.error(r);else throw r}this.timeout=void 0},this.time)}error(e){this.destination.error?.(e)}};var st={leading:!0,trailing:!1};function ae(t,e=st){return r=>new l(n=>r.subscribe(new W(n,t,e)))}var W=class{constructor(e,r,n){this.destination=e;this.time=r;this.config=n}next(e){this.lastValue=e,V(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){this.destination.error?.(e)}};function le(t){return e=>new l(r=>e.subscribe(new G(r,t)))}var G=class{constructor(e,r){this.destination=e;this.predicate=r}next(e){let r;try{r=this.predicate(e)}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function ce(t=(e,r)=>e===r){return e=>new l(r=>e.subscribe(new H(r,t)))}var ue={},H=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=ue}next(e){let r;try{r=this.lastValue===ue||!this.predicate(this.lastValue,e),this.lastValue=e}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function C(t){return e=>new l(r=>e.subscribe(new q(r,t)))}var q=class{constructor(e,r){this.destination=e;this.mapper=r}next(e){let r;try{r=this.mapper(e)}catch(n){throw this.error(n),n}this.destination.next(r)}error(e){this.destination.error?.(e)}};function pe(t){return C(()=>t)}function be(){return t=>new l(e=>{let r=!1,n=!1,i=t.subscribe(s=>{r||(r=!0,e.next(s)),n&&i.unsubscribe()},s=>{r=!0,e.error?.(s),n&&i.unsubscribe()});return n=!0,r&&i.unsubscribe(),i})}function de(){return t=>new l(e=>t.subscribe(new K(e)))}var K=class{constructor(e){this.destination=e;this.hasLast=!1}next(e){let r=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([r,e])}error(e){this.destination.error?.(e)}};function fe(t){return e=>new l(r=>e.subscribe(new Y(r,t)))}var Y=class{constructor(e,r){this.destination=e;this.effect=r}next(e){try{this.effect(e)}catch(r){throw this.error(r),r}this.destination.next(e)}error(e){this.destination.error?.(e)}};var at=(a=>(a.NETWORK="network",a.VIDEO_PIPELINE="video_pipeline",a.EXTERNAL_API="external_api",a.PARSER="parser",a.DOM="dom",a.WTF="wtf",a.FATAL="fatal",a))(at||{});var lt=(b=>(b.Armenian="58",b.Azerbaijani="57",b.Belarusian="114",b.English="3",b.Kazakh="97",b.Portuguese="73",b.Russian="0",b.Spanish="4",b.Ukrainian="1",b.Uzbek="65",b.Vietnamese="75",b))(lt||{}),ut="vk.com",Mn=async(t,e,r)=>{let n=new URL(`https://${ut}/js/lang-pack.js`);n.searchParams.set("format","json"),n.searchParams.set("name",e),t!==void 0&&n.searchParams.set("lang",t);let s=await(await fetch(n.toString())).json();return ct(s,r)},ct=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,n])=>[r.substring(`${e}_`.length),pt(n)])),pt=t=>Array.isArray(t)?t[0]:t;var bt=(r=>(r.RU="ru",r.EN="en",r))(bt||{});export{at as ErrorCategory,bt as InterfaceLanguage,M as Logger,l as Observable,h as Subject,f as Subscription,Oe as VERSION,lt as VKNumericLanguage,k as ValueSubject,Q as VideoQuality,Pe as abortable,ke as addScript,Ke as areQualitiesExact,Ae as assertEmptyArray,v as assertNever,Ee as assertNonNullable,Re as assertNotEmptyArray,Se as assertNullable,Ye as assertQualityIsExact,oe as buffer,we as checkNever,et as clearVideoElement,Le as clientChecker,Xe as cloneDeep,A as cloneDeepWith,ne as combine,se as debounce,B as debounceFn,Be as detectEmbed,$e as fillWithDefault,le as filter,ce as filterChanged,it as fromEvent,Me as getExponentialDelay,We as getHighestQuality,rt as interval,Fe as isHigher,ze as isHigherOrEqual,U as isInvariantQuality,D as isLower,je as isLowerOrEqual,ee as isMobile,y as isNonNullable,V as isNullable,Mn as loadVKLangPack,C as map,pe as mapTo,ie as merge,g as noop,Ce as now,nt as observableFrom,Ze as observeElementSize,be as once,de as pairwise,te as safeStorage,fe as tap,ae as throttle,F as throttleFn,zt as timeCodeToString,tt as timeout,Ge as videoHeightToQuality,qe as videoQualityToHeight,He as videoSizeToQuality};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vkontakte/videoplayer-shared",
3
- "version": "1.0.38-dev.87754f30.0",
3
+ "version": "1.0.38-dev.abb9bed7.0",
4
4
  "author": "vk.com",
5
5
  "description": "Shared code for vk.com videoplayer",
6
6
  "homepage": "https://vk.com",
@@ -0,0 +1 @@
1
+ export declare const clearVideoElement: (video: HTMLVideoElement) => void;
@@ -0,0 +1,54 @@
1
+ export declare enum CurrentClientBrowser {
2
+ Unknown = "Unknown",
3
+ Yandex = "Yandex",
4
+ Chrome = "Chrome",
5
+ Chromium = "Chromium",//Хром и хромиум разделяем специально. Почти единственное отличие, поддержка H.264 как раз важна для нас
6
+ Firefox = "Firefox",
7
+ Safari = "Safari",
8
+ Opera = "Opera",
9
+ Edge = "Edge",
10
+ SamsungBrowser = "SamsungBrowser",
11
+ Rest = "Rest"
12
+ }
13
+ export declare enum CurrentClientDevice {
14
+ Unknown = "Unknown",
15
+ Android = "Android",
16
+ iPhone = "iPhone",
17
+ iPad = "iPad",
18
+ iPod = "iPod",
19
+ RestMobile = "RestMobile",
20
+ Mac = "Mac",
21
+ Desktop = "Desktop"
22
+ }
23
+ export declare const isMobile: () => boolean;
24
+ export declare class ClientChecker {
25
+ private _currentBrowser;
26
+ private _currentDevice;
27
+ private _iosVersion;
28
+ private _macVersion;
29
+ private _maxTouchPoints;
30
+ private _isHdr;
31
+ private _isMobile;
32
+ constructor();
33
+ get browser(): CurrentClientBrowser;
34
+ get device(): CurrentClientDevice;
35
+ get isTouch(): boolean;
36
+ get isIOS(): boolean;
37
+ get isMac(): boolean;
38
+ get isApple(): boolean;
39
+ get isIphoneOrOldIpad(): boolean;
40
+ get isAndroid(): boolean;
41
+ get isMobile(): boolean;
42
+ get iOSVersion(): number | undefined;
43
+ get macVersion(): number | undefined;
44
+ get isYandex(): boolean;
45
+ get isSafari(): boolean;
46
+ get isSamsungBrowser(): boolean;
47
+ get isHDR(): boolean;
48
+ detect(): void;
49
+ private detectBrowser;
50
+ private detectDevice;
51
+ private detectIOSVersion;
52
+ private detectMacVersion;
53
+ }
54
+ export declare const clientChecker: ClientChecker;
@@ -1,3 +1,3 @@
1
1
  type CloneDeepWithCustomizer<TObject> = (value: unknown, key: number | string | undefined, object: TObject | undefined, stack: any) => any;
2
- export declare const cloneDeepWith: <T>(obj: T, customizer?: CloneDeepWithCustomizer<T> | undefined) => T;
2
+ export declare const cloneDeepWith: <T>(obj: T, customizer?: CloneDeepWithCustomizer<T>) => T;
3
3
  export {};
@@ -1,4 +1,4 @@
1
1
  export declare const detectEmbed: () => {
2
2
  isEmbed: boolean;
3
- host?: string | undefined;
3
+ host?: string;
4
4
  };
@@ -6,8 +6,7 @@ export { addScript } from './addScript';
6
6
  export type { Milliseconds, bps, Byte, Seconds, Kbps, Mbps, Percentage } from './semanticTypes';
7
7
  export { now } from './now';
8
8
  export { abortable } from './abortable';
9
- export { getCurrentBrowser, CurrentClientBrowser, CurrentClientDevice, isIOS, getIOSVersion, isMacLike, isMobile, isAndroid } from './detectBrowser';
10
- export type { ICurrentBrowserInfo } from './detectBrowser';
9
+ export { clientChecker, isMobile } from './clientChecker';
11
10
  export { getExponentialDelay, ExponentialBackoffConfig } from './exponentialBackoff';
12
11
  export * as safeStorage from './iframeSafeStorage';
13
12
  export { detectEmbed } from './detectEmbed';
@@ -20,3 +19,4 @@ export { throttleFn, ThrottleOptions } from './throttleFn';
20
19
  export { cloneDeep } from './cloneDeep';
21
20
  export { observeElementSize } from './observeElementSize';
22
21
  export { cloneDeepWith } from './cloneDeepWith';
22
+ export { clearVideoElement } from './clearVideoElement';
@@ -1,32 +0,0 @@
1
- export declare enum CurrentClientBrowser {
2
- Unknown = "Unknown",
3
- Yandex = "Yandex",
4
- Chrome = "Chrome",
5
- Chromium = "Chromium",
6
- Firefox = "Firefox",
7
- Safari = "Safari",
8
- Opera = "Opera",
9
- Edge = "Edge",
10
- SamsungBrowser = "SamsungBrowser",
11
- Rest = "Rest"
12
- }
13
- export declare enum CurrentClientDevice {
14
- Unknown = "Unknown",
15
- Android = "Android",
16
- iPhone = "iPhone",
17
- iPad = "iPad",
18
- iPod = "iPod",
19
- RestMobile = "RestMobile",
20
- Mac = "Mac",
21
- Desktop = "Desktop"
22
- }
23
- export type ICurrentBrowserInfo = {
24
- browser: CurrentClientBrowser;
25
- device: CurrentClientDevice;
26
- };
27
- export declare const getCurrentBrowser: () => ICurrentBrowserInfo;
28
- export declare const isIOS: (checkForceDesktop?: boolean) => boolean;
29
- export declare const getIOSVersion: () => number | null;
30
- export declare const isAndroid: () => boolean;
31
- export declare const isMacLike: () => boolean;
32
- export declare const isMobile: () => any;