@vkontakte/videoplayer-shared 1.0.52-dev.7c065070.0 → 1.0.52-dev.efc0bd7d.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 +3 -3
- package/es2015.esm.js +3 -3
- package/es2018.cjs.js +3 -3
- package/es2018.esm.js +3 -3
- package/esnext.cjs.js +3 -3
- package/esnext.esm.js +3 -3
- package/evergreen.esm.js +3 -3
- package/package.json +1 -1
package/evergreen.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-shared v1.0.52-dev.
|
|
3
|
-
*
|
|
2
|
+
* @vkontakte/videoplayer-shared v1.0.52-dev.efc0bd7d.0
|
|
3
|
+
* Wed, 18 Dec 2024 02:18:39 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-52/doc/
|
|
5
5
|
*/
|
|
6
|
-
var Se=Object.defineProperty;var Re=(t,e)=>{for(var r in e)Se(t,r,{get:e[r],enumerable:!0})};var ke="1.0.52-dev.7c065070.0";var b=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 T=t=>{throw new Error(`${t} is value of unexpected type`)},Ae=t=>{};var g=()=>{};var c=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 b().add(()=>{switch(i.next=g,i.error=g,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return T(s)}})}pipe(...e){return e.reduce((r,n)=>n(r),this)}_subscribe(e){}};var v=class extends c{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 b().add(()=>this.subscribers.delete(n))}};var M=class{constructor(){this.log$=new v;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}))}};import{trace as Pe,context as Ce}from"@opentelemetry/api";import{TracerAllSpansProcessor as Le,TracerMemorySpanExporter as ne,initTracerOpenTelemetry as Me}from"@tracer/opentelemetry";var _=class t{constructor({name:e}){}log(e,r){}error(e,r){}critical(e,r){}createComponentTracer(e){return new t({name:e})}end(){}getFinishedSpans(){}getTraceId(){return this.fakeTraceId}},V=class t{constructor({name:e,parentContext:r,tracer:n}){this.childTracers=[];let i=!n;if(i){let o=Me({serviceName:"videoplayer-sdk-web",appToken:"L9SBoka6ZWk4xPjaK7tmfSfYvMhcge7nvGDjpdMmscb",spanLimits:{attributeCountLimit:1/0,eventCountLimit:1/0,attributePerEventCountLimit:1/0}}).getProvider(),a=new ne,p=new ne;this.spanExporter=a,o.addSpanProcessor(new Le({startedSpansExporter:a,endedSpansExporter:p})),this.tracer=o.getTracer("sdk-videoplayer-tracer")}else this.tracer=n;this.span=this.tracer.startSpan(e,{root:i},r),this.context=Pe.setSpan(Ce.active(),this.span)}log(e,r){this.span.addEvent(e,{...r,type:"log"})}error(e,r){this.span.addEvent(e,{...r,type:"error"})}critical(e,r){this.span.addEvent(e,{...r,type:"critical"})}static createRootTracer(e=!1){return e?new t({name:"Root"}):new _({name:"Root"})}createComponentTracer(e){let r=new t({name:e,parentContext:this.context,tracer:this.tracer});return this.childTracers.push(r),r}end(){this.childTracers.forEach(e=>e.end()),this.span.end()}getFinishedSpans(){return this.spanExporter?.getJsonData()}getTraceId(){return this.span.spanContext().traceId}};function _e(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function Ve(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function x(t){return typeof t<"u"&&t!==null}function N(t){return t==null}function Ne(t,e){if(!t?.length)throw new Error(e)}function Qe(t,e){if(t?.length)throw new Error(e)}var De=(t,e,r)=>new Promise((n,i)=>{e.addEventListener("abort",()=>{a(),d.remove()});let s=()=>{a(),i()},o=()=>{a(),n()},a=()=>{p&&clearTimeout(p),d.removeEventListener("load",o),d.removeEventListener("error",s)},p;r&&(p=window.setTimeout(s,r));let d=document.createElement("script");d.addEventListener("load",o),d.addEventListener("error",s),d.src=t,document.head.appendChild(d)});var Ue=typeof window.performance?.now=="function"?()=>window.performance.now():()=>Date.now();var je=(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 ie=()=>/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(navigator.appVersion??navigator.userAgent)||navigator?.userAgentData?.mobile,Q=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=ie()}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,d=/edg/i.test(e)?"Edge":void 0;this._currentBrowser=r||n||o||p||d||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)}}},Be=new Q;var Fe=(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 oe={};Re(oe,{clear:()=>Ke,get:()=>ze,has:()=>He,isPersistent:()=>We,remove:()=>qe,set:()=>Ge});var y,I,D=`vk-videoplayer-dummy-key-${Math.random()}`,O=()=>{if(I!==void 0)return I;try{localStorage.setItem(D,"test"),localStorage.removeItem(D),I=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem(D),I=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)I=2;else throw e}else throw t}return I===2&&(y=new Map),I},We=()=>O()===0,ze=t=>{let e=O();switch(e){case 0:return localStorage.getItem(t)??void 0;case 1:return sessionStorage.getItem(t)??void 0;case 2:return y?.get(t);default:T(e)}},Ge=(t,e)=>{let r=O();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 y?.set(t,e);default:T(r)}},He=t=>{let e=O();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return y?.has(t)??!1;default:return T(e),!1}},qe=t=>{let e=O();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:return void y?.delete(t);default:T(e)}},Ke=()=>{let t=O();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return y?.clear();default:T(t)}};var Ye=()=>{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=(l=>(l.INVARIANT="Invariant quality",l.Q_144P="144p",l.Q_240P="240p",l.Q_360P="360p",l.Q_480P="480p",l.Q_576P="576p",l.Q_720P="720p",l.Q_1080P="1080p",l.Q_1440P="1440p",l.Q_2160P="2160p",l.Q_4320P="4320p",l))(U||{});var m={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"576p":{width:1024,height:576},"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=(t,e)=>m[t].height>m[e].height,Xe=(t,e)=>m[t].height>=m[e].height,j=(t,e)=>m[t].height<m[e].height,Je=(t,e)=>m[t].height<=m[e].height,Ze=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:j(e,r)?1:-1)[0],se=Object.keys(m).sort((t,e)=>j(t,e)?-1:1),et=(t,e=.02)=>[...se].find(n=>m[n].height*(1+e)>=t),tt=({width:t,height:e})=>{let r=Math.min(t,e),n=Math.max(t,e);return se.find(i=>{let s=m[i];return s.width>=n&&s.height>=r})},rt=t=>m[t].height,B=t=>t==="Invariant quality",nt=t=>t.every(e=>!B(e));function it(t){if(B(t))throw new Error("Expected exact quality")}var ot=(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]=ot(s,i):r[n]=n in t?s:i}return r};var pr=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,o,a,p,d=0,J=!1,l=!1,C=!0,Z=!e&&e!==0&&typeof window.requestAnimationFrame=="function";r&&(J=!!r.leading,l="maxWait"in r,s=r?.maxWait?Math.max(+r?.maxWait||0,e):s,C="trailing"in r?!!r.trailing:C);function L(u){let f=n,h=i;return n=i=void 0,d=u,o=t.apply(h,f),o}function w(u,f){return Z?(a&&window.cancelAnimationFrame(a),window.requestAnimationFrame(u)):setTimeout(u,f)}function Ie(u){if(Z){window.cancelAnimationFrame(u);return}clearTimeout(u)}function xe(u){return d=u,a=w(E,e),J?L(u):o}function ye(u){let f=u-p,h=u-d,re=e-f;return l?Math.min(re,s-h):re}function ee(u){let f=u-p,h=u-d;return p===void 0||f>=e||f<0||l&&h>=s}function E(){let u=Date.now();if(ee(u))return te(u);a=w(E,ye(u))}function te(u){return a=void 0,C&&n?L(u):(n=i=void 0,o)}function Oe(){a!==void 0&&Ie(a),d=0,n=p=i=a=void 0}function we(){return a===void 0?o:te(Date.now())}function Ee(){return a!==void 0}function S(...u){let f=Date.now(),h=ee(f);if(n=u,i=this,p=f,h){if(a===void 0)return xe(p);if(l)return a=w(E,e),L(p)}return a===void 0&&(a=w(E,e)),o}return S.cancel=Oe,S.flush=we,S.pending=Ee,S}var W=(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 st=t=>R(t);var at=300,ct=(t,e=at)=>new c(r=>{let{width:n,height:i}=t.getBoundingClientRect();if(r.next({width:n,height:i}),!window.ResizeObserver)return;let s=new ResizeObserver(W(o=>{let a=o[0];if(!a)return;let p,d;a.contentBoxSize&&a.contentBoxSize[0]?(d=a.contentBoxSize[0].blockSize,p=a.contentBoxSize[0].inlineSize):a.contentRect&&(p=a.contentRect.width,d=a.contentRect.height),x(p)&&x(d)&&r.next({width:p,height:d})},e));return s.observe(t),()=>s.disconnect()});var k=(t,e=6,r=".")=>{let n={};for(let i in t)if(!(!t.hasOwnProperty(i)||t[i]instanceof HTMLElement||!e))if(typeof t[i]=="object"&&t[i]!==null){let s=k(t[i],e-1);for(let o in s)s.hasOwnProperty(o)&&(n[i+r+o]=s[o])}else n[i]=t[i];return n};var lt=t=>{t.removeAttribute("src"),t.load()};var wr=t=>{let e;try{e=new URL(t)}catch{return!1}return e.protocol==="https:"};var Sr=t=>{try{return new URL(t)}catch{return null}};var ut=t=>e=>r=>{let n=typeof r=="object";r==null||n&&!Object.keys(r).length||t(e,n?k(r):{value:r})};var A=class extends v{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 ae(t){return new c(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 b)})}function ce(...t){return new c(e=>t.reduce((r,n)=>r.add(n.subscribe(e)),new b))}var pt=t=>new c(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 dt=t=>new c(e=>{let r=window.setInterval(()=>e.next(),t);return()=>{r&&(window.clearInterval(r),r=void 0)}});var bt=t=>new c(e=>{t.forEach(r=>e.next(r))});var mt=(t,e)=>new c(r=>{let n=i=>r.next(i);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)});function le(t){return e=>new c(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 ft={leading:!1,trailing:!0};function ue(t,e=ft){return r=>new c(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,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 Tt={leading:!0,trailing:!1};function pe(t,e=Tt){return r=>new c(n=>r.subscribe(new H(n,t,e)))}var H=class{constructor(e,r,n){this.destination=e;this.time=r;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){this.destination.error?.(e)}};function de(t){return e=>new c(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 me(t=(e,r)=>e===r){return e=>new c(r=>e.subscribe(new K(r,t)))}var be={},K=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=be}next(e){let r;try{r=this.lastValue===be||!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 P(t){return e=>new c(r=>e.subscribe(new Y(r,t)))}var Y=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 fe(t){return P(()=>t)}function Te(){return t=>new c(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 ve(){return t=>new c(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 he(t){return e=>new c(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){this.destination.error?.(e)}};var vt=(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))(vt||{});var ht=(l=>(l.Armenian="58",l.Azerbaijani="57",l.Belarusian="114",l.English="3",l.Kazakh="97",l.Portuguese="73",l.Russian="0",l.Spanish="4",l.Ukrainian="1",l.Uzbek="65",l.Vietnamese="75",l))(ht||{}),gt="vk.com",vi=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 It(s,r)},It=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,n])=>[r.substring(`${e}_`.length),xt(n)])),xt=t=>Array.isArray(t)?t[0]:t;var yt=(r=>(r.RU="ru",r.EN="en",r))(yt||{});var Ot={UI:"__vkVideoPlayer",CORE:"__vkVideoCore"},wt=(()=>{let t=0;return()=>{let e=t;return t=(t+1)%Number.MAX_SAFE_INTEGER,e}})(),ge=class{constructor(e){this.id=wt();this.type=e,this.initWindowObjects()}getWindowObject(){let e=this.key();return window[e]?.[this.id]??{}}initWindowObjects(){let e=this.key();window[e]||(window[e]={}),window[e][this.id]={}}expose(e){Object.assign(this.getWindowObject(),e)}destroy(){let e=this.key();window&&window[e]&&window[e][this.id]&&(delete window[e][this.id],Object.keys(window[e]).length||delete window[e])}key(){let{type:e}=this;return Ot[e]}};export{vt as ErrorCategory,yt as InterfaceLanguage,ge as InternalsExposure,M as Logger,c as Observable,v as Subject,b as Subscription,V as Tracer,ke as VERSION,ht as VKNumericLanguage,A as ValueSubject,U as VideoQuality,je as abortable,De as addScript,nt as areQualitiesExact,Qe as assertEmptyArray,T as assertNever,_e as assertNonNullable,Ne as assertNotEmptyArray,Ve as assertNullable,it as assertQualityIsExact,le as buffer,Ae as checkNever,lt as clearVideoElement,Be as clientChecker,st as cloneDeep,R as cloneDeepWith,ae as combine,Sr as createURL,ue as debounce,F as debounceFn,Ye as detectEmbed,ot as fillWithDefault,de as filter,me as filterChanged,k as flattenObject,mt as fromEvent,Fe as getExponentialDelay,Ze as getHighestQuality,ut as getTraceSubscriptionMethod,dt as interval,$e as isHigher,Xe as isHigherOrEqual,B as isInvariantQuality,j as isLower,Je as isLowerOrEqual,ie as isMobile,x as isNonNullable,N as isNullable,wr as isValidURL,vi as loadVKLangPack,P as map,fe as mapTo,ce as merge,g as noop,Ue as now,bt as observableFrom,ct as observeElementSize,Te as once,ve as pairwise,oe as safeStorage,he as tap,pe as throttle,W as throttleFn,pr as timeCodeToString,pt as timeout,et as videoHeightToQuality,rt as videoQualityToHeight,tt as videoSizeToQuality};
|
|
6
|
+
var Se=Object.defineProperty;var Re=(t,e)=>{for(var r in e)Se(t,r,{get:e[r],enumerable:!0})};var ke="1.0.52-dev.efc0bd7d.0";var b=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 T=t=>{throw new Error(`${t} is value of unexpected type`)},Ae=t=>{};var g=()=>{};var c=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 b().add(()=>{switch(i.next=g,i.error=g,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return T(s)}})}pipe(...e){return e.reduce((r,n)=>n(r),this)}_subscribe(e){}};var v=class extends c{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 b().add(()=>this.subscribers.delete(n))}};var M=class{constructor(){this.log$=new v;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}))}};import{trace as Pe,context as Ce}from"@opentelemetry/api";import{TracerAllSpansProcessor as Le,TracerMemorySpanExporter as ne,initTracerOpenTelemetry as Me}from"@tracer/opentelemetry";var _=class t{constructor({name:e}){}log(e,r){}error(e,r){}critical(e,r){}createComponentTracer(e){return new t({name:e})}end(){}getFinishedSpans(){}getTraceId(){return this.fakeTraceId}},V=class t{constructor({name:e,parentContext:r,tracer:n}){this.childTracers=[];let i=!n;if(i){let o=Me({serviceName:"videoplayer-sdk-web",appToken:"L9SBoka6ZWk4xPjaK7tmfSfYvMhcge7nvGDjpdMmscb",spanLimits:{attributeCountLimit:1/0,eventCountLimit:1/0,attributePerEventCountLimit:1/0}}).getProvider(),a=new ne,p=new ne;this.spanExporter=a,o.addSpanProcessor(new Le({startedSpansExporter:a,endedSpansExporter:p})),this.tracer=o.getTracer("sdk-videoplayer-tracer")}else this.tracer=n;this.span=this.tracer.startSpan(e,{root:i},r),this.context=Pe.setSpan(Ce.active(),this.span)}log(e,r){this.span.addEvent(e,{...r,type:"log"})}error(e,r){this.span.addEvent(e,{...r,type:"error"})}critical(e,r){this.span.addEvent(e,{...r,type:"critical"})}static createRootTracer(e=!1){return e?new t({name:"Root"}):new _({name:"Root"})}createComponentTracer(e){let r=new t({name:e,parentContext:this.context,tracer:this.tracer});return this.childTracers.push(r),r}end(){this.childTracers.forEach(e=>e.end()),this.span.end()}getFinishedSpans(){return this.spanExporter?.getJsonData()}getTraceId(){return this.span.spanContext().traceId}};function _e(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function Ve(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function x(t){return typeof t<"u"&&t!==null}function N(t){return t==null}function Ne(t,e){if(!t?.length)throw new Error(e)}function Qe(t,e){if(t?.length)throw new Error(e)}var De=(t,e,r)=>new Promise((n,i)=>{e.addEventListener("abort",()=>{a(),d.remove()});let s=()=>{a(),i()},o=()=>{a(),n()},a=()=>{p&&clearTimeout(p),d.removeEventListener("load",o),d.removeEventListener("error",s)},p;r&&(p=window.setTimeout(s,r));let d=document.createElement("script");d.addEventListener("load",o),d.addEventListener("error",s),d.src=t,document.head.appendChild(d)});var Ue=typeof window.performance?.now=="function"?()=>window.performance.now():()=>Date.now();var je=(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 ie=()=>/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(navigator.appVersion??navigator.userAgent)||navigator?.userAgentData?.mobile,Q=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=ie()}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,d=/edg/i.test(e)?"Edge":void 0;this._currentBrowser=r||n||o||p||d||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)}}},Be=new Q;var Fe=(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 oe={};Re(oe,{clear:()=>Ke,get:()=>ze,has:()=>He,isPersistent:()=>We,remove:()=>qe,set:()=>Ge});var y,I,D=`vk-videoplayer-dummy-key-${Math.random()}`,O=()=>{if(I!==void 0)return I;try{localStorage.setItem(D,"test"),localStorage.removeItem(D),I=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem(D),I=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)I=2;else throw e}else throw t}return I===2&&(y=new Map),I},We=()=>O()===0,ze=t=>{let e=O();switch(e){case 0:return localStorage.getItem(t)??void 0;case 1:return sessionStorage.getItem(t)??void 0;case 2:return y?.get(t);default:T(e)}},Ge=(t,e)=>{let r=O();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 y?.set(t,e);default:T(r)}},He=t=>{let e=O();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return y?.has(t)??!1;default:return T(e),!1}},qe=t=>{let e=O();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:return void y?.delete(t);default:T(e)}},Ke=()=>{let t=O();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return y?.clear();default:T(t)}};var Ye=()=>{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=(l=>(l.INVARIANT="Invariant quality",l.Q_144P="144p",l.Q_240P="240p",l.Q_360P="360p",l.Q_480P="480p",l.Q_576P="576p",l.Q_720P="720p",l.Q_1080P="1080p",l.Q_1440P="1440p",l.Q_2160P="2160p",l.Q_4320P="4320p",l))(U||{});var m={"144p":{width:256,height:144},"240p":{width:428,height:240},"360p":{width:640,height:360},"480p":{width:856,height:480},"576p":{width:1024,height:576},"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=(t,e)=>m[t].height>m[e].height,Xe=(t,e)=>m[t].height>=m[e].height,j=(t,e)=>m[t].height<m[e].height,Je=(t,e)=>m[t].height<=m[e].height,Ze=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:j(e,r)?1:-1)[0],se=Object.keys(m).sort((t,e)=>j(t,e)?-1:1),et=(t,e=.02)=>[...se].find(n=>m[n].height*(1+e)>=t),tt=({width:t,height:e})=>{let r=Math.min(t,e),n=Math.max(t,e);return se.find(i=>{let s=m[i];return s.width>=n&&s.height>=r})},rt=t=>m[t].height,B=t=>t==="Invariant quality",nt=t=>t.every(e=>!B(e));function it(t){if(B(t))throw new Error("Expected exact quality")}var ot=(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]=ot(s,i):r[n]=n in t?s:i}return r};var pr=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,o,a,p,d=0,J=!1,l=!1,C=!0,Z=!e&&e!==0&&typeof window.requestAnimationFrame=="function";r&&(J=!!r.leading,l="maxWait"in r,s=r?.maxWait?Math.max(+r?.maxWait||0,e):s,C="trailing"in r?!!r.trailing:C);function L(u){let f=n,h=i;return n=i=void 0,d=u,o=t.apply(h,f),o}function w(u,f){return Z?(a&&window.cancelAnimationFrame(a),window.requestAnimationFrame(u)):setTimeout(u,f)}function Ie(u){if(Z){window.cancelAnimationFrame(u);return}clearTimeout(u)}function xe(u){return d=u,a=w(E,e),J?L(u):o}function ye(u){let f=u-p,h=u-d,re=e-f;return l?Math.min(re,s-h):re}function ee(u){let f=u-p,h=u-d;return p===void 0||f>=e||f<0||l&&h>=s}function E(){let u=Date.now();if(ee(u))return te(u);a=w(E,ye(u))}function te(u){return a=void 0,C&&n?L(u):(n=i=void 0,o)}function Oe(){a!==void 0&&Ie(a),d=0,n=p=i=a=void 0}function we(){return a===void 0?o:te(Date.now())}function Ee(){return a!==void 0}function S(...u){let f=Date.now(),h=ee(f);if(n=u,i=this,p=f,h){if(a===void 0)return xe(p);if(l)return a=w(E,e),L(p)}return a===void 0&&(a=w(E,e)),o}return S.cancel=Oe,S.flush=we,S.pending=Ee,S}var W=(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 st=t=>R(t);var at=300,ct=(t,e=at)=>new c(r=>{let{width:n,height:i}=t.getBoundingClientRect();if(r.next({width:n,height:i}),!window.ResizeObserver)return;let s=new ResizeObserver(W(o=>{let a=o[0];if(!a)return;let p,d;a.contentBoxSize&&a.contentBoxSize[0]?(d=a.contentBoxSize[0].blockSize,p=a.contentBoxSize[0].inlineSize):a.contentRect&&(p=a.contentRect.width,d=a.contentRect.height),x(p)&&x(d)&&r.next({width:p,height:d})},e));return s.observe(t),()=>s.disconnect()});var k=(t,e=6,r=".")=>{let n={};for(let i in t)if(!(!t.hasOwnProperty(i)||t[i]instanceof HTMLElement||!e))if(typeof t[i]=="object"&&t[i]!==null){let s=k(t[i],e-1);for(let o in s)s.hasOwnProperty(o)&&(n[i+r+o]=s[o])}else n[i]=t[i];return n};var lt=t=>{t.removeAttribute("src"),t.load()};var wr=t=>{let e;try{e=new URL(t)}catch{return!1}return e.protocol==="https:"};var Sr=t=>{try{return new URL(t)}catch{return null}};var ut=t=>e=>r=>{let n=typeof r=="object";r==null||n&&!Object.keys(r).length||t(e,n?k(r):{value:r})};var A=class extends v{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 ae(t){return new c(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 b)})}function ce(...t){return new c(e=>t.reduce((r,n)=>r.add(n.subscribe(e)),new b))}var pt=t=>new c(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 dt=t=>new c(e=>{let r=window.setInterval(()=>e.next(),t);return()=>{r&&(window.clearInterval(r),r=void 0)}});var bt=t=>new c(e=>{t.forEach(r=>e.next(r))});var mt=(t,e)=>new c(r=>{let n=i=>r.next(i);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)});function le(t){return e=>new c(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 ft={leading:!1,trailing:!0};function ue(t,e=ft){return r=>new c(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,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 Tt={leading:!0,trailing:!1};function pe(t,e=Tt){return r=>new c(n=>r.subscribe(new H(n,t,e)))}var H=class{constructor(e,r,n){this.destination=e;this.time=r;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){this.destination.error?.(e)}};function de(t){return e=>new c(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 me(t=(e,r)=>e===r){return e=>new c(r=>e.subscribe(new K(r,t)))}var be={},K=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=be}next(e){let r;try{r=this.lastValue===be||!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 P(t){return e=>new c(r=>e.subscribe(new Y(r,t)))}var Y=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 fe(t){return P(()=>t)}function Te(){return t=>new c(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 ve(){return t=>new c(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 he(t){return e=>new c(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){this.destination.error?.(e)}};var vt=(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))(vt||{});var ht=(l=>(l.Armenian="58",l.Azerbaijani="57",l.Belarusian="114",l.English="3",l.Kazakh="97",l.Portuguese="73",l.Russian="0",l.Spanish="4",l.Ukrainian="1",l.Uzbek="65",l.Vietnamese="75",l))(ht||{}),gt="vk.com",vi=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 It(s,r)},It=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,n])=>[r.substring(`${e}_`.length),xt(n)])),xt=t=>Array.isArray(t)?t[0]:t;var yt=(r=>(r.RU="ru",r.EN="en",r))(yt||{});var Ot={UI:"__vkVideoPlayer",CORE:"__vkVideoCore"},wt=(()=>{let t=0;return()=>{let e=t;return t=(t+1)%Number.MAX_SAFE_INTEGER,e}})(),ge=class{constructor(e){this.id=wt();this.type=e,this.initWindowObjects()}getWindowObject(){let e=this.key();return window[e]?.[this.id]??{}}initWindowObjects(){let e=this.key();window[e]||(window[e]={}),window[e][this.id]={}}expose(e){Object.assign(this.getWindowObject(),e)}destroy(){let e=this.key();window&&window[e]&&window[e][this.id]&&(delete window[e][this.id],Object.keys(window[e]).length||delete window[e])}key(){let{type:e}=this;return Ot[e]}};export{vt as ErrorCategory,yt as InterfaceLanguage,ge as InternalsExposure,M as Logger,c as Observable,v as Subject,b as Subscription,V as Tracer,ke as VERSION,ht as VKNumericLanguage,A as ValueSubject,U as VideoQuality,je as abortable,De as addScript,nt as areQualitiesExact,Qe as assertEmptyArray,T as assertNever,_e as assertNonNullable,Ne as assertNotEmptyArray,Ve as assertNullable,it as assertQualityIsExact,le as buffer,Ae as checkNever,lt as clearVideoElement,Be as clientChecker,st as cloneDeep,R as cloneDeepWith,ae as combine,Sr as createURL,ue as debounce,F as debounceFn,Ye as detectEmbed,ot as fillWithDefault,de as filter,me as filterChanged,k as flattenObject,mt as fromEvent,Fe as getExponentialDelay,Ze as getHighestQuality,ut as getTraceSubscriptionMethod,dt as interval,$e as isHigher,Xe as isHigherOrEqual,B as isInvariantQuality,j as isLower,Je as isLowerOrEqual,ie as isMobile,x as isNonNullable,N as isNullable,wr as isValidURL,vi as loadVKLangPack,P as map,fe as mapTo,ce as merge,g as noop,Ue as now,bt as observableFrom,ct as observeElementSize,Te as once,ve as pairwise,oe as safeStorage,he as tap,pe as throttle,W as throttleFn,pr as timeCodeToString,pt as timeout,et as videoHeightToQuality,rt as videoQualityToHeight,tt as videoSizeToQuality};
|