@vkontakte/videoplayer-shared 1.0.82-dev.44065e09.0 → 1.0.82-dev.4dbe88bb.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/evergreen.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @vkontakte/videoplayer-shared v1.0.82-dev.44065e09.0
3
- * Mon, 16 Feb 2026 07:36:26 GMT
2
+ * @vkontakte/videoplayer-shared v1.0.82-dev.4dbe88bb.0
3
+ * Fri, 06 Mar 2026 09:55:22 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-82/doc/
5
5
  */
6
- var _e=Object.defineProperty;var ue=(t,e)=>{for(var r in e)_e(t,r,{get:e[r],enumerable:!0})};var De="1.0.82-dev.44065e09.0";var d=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 g=t=>{throw new Error(`${t} is value of unexpected type`)},Ue=t=>{};var w=()=>{};var je=t=>{throw console.error(t),t},We=t=>{console.error(t)},c=class{constructor(e){this.suppressErrors=!1;e&&(this._subscribe=e)}setSuppressErrors(e){this.suppressErrors=e}subscribe(e,r){let n=this.suppressErrors?We:je,o;r?typeof r=="function"?o={next:r,error:w}:o={next:a=>r.next(a),error:a=>r.error?.(a)}:o={next:n,error:w};let s=typeof e=="function"?{next:a=>{try{let l=e(a);l instanceof Promise&&l.catch(b=>o.next(b))}catch(l){o.next(l)}},error:a=>o.next(a)}:{next:a=>e.next(a),error:a=>e.error?e.error(a):o.next(a)},i;try{i=this._subscribe(s)}catch(a){s.error?.(a)}return new d().add(()=>{switch(s.next=w,s.error=w,typeof i){case"function":i();return;case"object":i.unsubscribe();return;case"undefined":return;default:return g(i)}})}pipe(...e){return e.reduce((r,n)=>n(r),this)}_subscribe(e){}};var I=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 d().add(()=>this.subscribers.delete(n))}};var G=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 ze(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function Fe(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function O(t){return typeof t<"u"&&t!==null}function k(t){return t==null}var Ge=t=>Object.fromEntries(Object.entries(t).filter(([e,r])=>O(r)));function Be(t,e){if(!t?.length)throw new Error(e)}function Ke(t,e){if(t?.length)throw new Error(e)}var m=()=>globalThis,me=(t=m())=>!!(t.window&&t.screen);var He=(t,e,r)=>new Promise((n,o)=>{e.addEventListener("abort",()=>{a(),b.remove()});let s=()=>{a(),o("error")},i=()=>{a(),n()},a=()=>{l&&clearTimeout(l),b.removeEventListener("load",i),b.removeEventListener("error",s)},l;r&&(l=m().setTimeout(()=>{a(),o("timeout")},r));let b=document.createElement("script");b.addEventListener("load",i),b.addEventListener("error",s),b.src=t,document.head.appendChild(b)});var qe=typeof m().performance?.now=="function"?()=>m().performance.now():()=>Date.now();var $e=(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 Xe=(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 be={};ue(be,{clear:()=>rt,get:()=>Je,has:()=>et,isPersistent:()=>Ye,remove:()=>tt,set:()=>Ze});var S,E,B=`vk-videoplayer-dummy-key-${Math.random()}`,A=()=>{if(E!==void 0)return E;try{localStorage.setItem(B,"test"),localStorage.removeItem(B),E=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem(B),E=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)E=2;else throw e}else throw t}return E===2&&(S=new Map),E},Ye=()=>A()===0,Je=t=>{let e=A();switch(e){case 0:return localStorage.getItem(t)??void 0;case 1:return sessionStorage.getItem(t)??void 0;case 2:return S?.get(t);default:g(e)}},Ze=(t,e)=>{let r=A();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:S?.set(t,e);return;default:g(r)}},et=t=>{let e=A();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return S?.has(t)??!1;default:return g(e),!1}},tt=t=>{let e=A();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:S?.delete(t);return;default:g(e)}},rt=()=>{let t=A();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return S?.clear();default:g(t)}};var nt=()=>{let t,e=[],r=m();try{t=r.self!==r.top}catch(n){n instanceof DOMException&&n.name==="SecurityError"?t=!0:(t=!1,console.error(n))}try{r.location.ancestorOrigins&&(e=[...r.location.ancestorOrigins])}catch(n){console.error(n)}try{!e.length&&r.document.referrer&&(e=[new URL(r.document.referrer).origin])}catch(n){console.error(n)}return e=e.filter(n=>URL.canParse(n)),{isEmbed:t,origins:e,topOrigin:e.at(-1),immediateOrigin:e.at(0)}};var K=(p=>(p.INVARIANT="Invariant quality",p.Q_144P="144p",p.Q_240P="240p",p.Q_360P="360p",p.Q_480P="480p",p.Q_576P="576p",p.Q_720P="720p",p.Q_1080P="1080p",p.Q_1440P="1440p",p.Q_2160P="2160p",p.Q_4320P="4320p",p))(K||{});var T={"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}},ot=(t,e)=>T[t].height>T[e].height,it=(t,e)=>T[t].height>=T[e].height,H=(t,e)=>T[t].height<T[e].height,st=(t,e)=>T[t].height<=T[e].height,at=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:H(e,r)?1:-1)[0],de=Object.keys(T).sort((t,e)=>H(t,e)?-1:1),ct=(t,e=.02)=>[...de].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 de.find(o=>{let s=T[o];return s.width>=n&&s.height>=r})},pt=t=>T[t].height,q=t=>t==="Invariant quality",ut=t=>t.every(e=>!q(e));function mt(t){if(q(t))throw new Error("Expected exact quality")}var bt=t=>{switch(t){case"4320p":return"8K";case"2160p":return"4K";case"1440p":return"QHD";case"1080p":return"FHD";case"720p":return"HD";default:return""}};var dt=(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]=dt(s,o):r[n]=n in t?s:o}return r};var xr=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 $(t,e=0,r){let n,o,s,i,a,l,b=0,v=!1,p=!1,z=!0,ae=!e&&e!==0&&typeof m().requestAnimationFrame=="function";r&&(v=!!r.leading,p="maxWait"in r,s=r?.maxWait?Math.max(+r?.maxWait||0,e):s,z="trailing"in r?!!r.trailing:z);function F(u){let y=n,x=o;return n=o=void 0,b=u,i=t.apply(x,y),i}function L(u,y){return ae?(a&&m().cancelAnimationFrame(a),m().requestAnimationFrame(u)):setTimeout(u,y)}function Le(u){if(ae){m().cancelAnimationFrame(u);return}clearTimeout(u)}function Ne(u){return b=u,a=L(N,e),v?F(u):i}function Ce(u){let y=u-l,x=u-b,pe=e-y;return p?Math.min(pe,s-x):pe}function ce(u){let y=u-l,x=u-b;return l===void 0||y>=e||y<0||p&&x>=s}function N(){let u=Date.now();if(ce(u))return le(u);a=L(N,Ce(u))}function le(u){return a=void 0,z&&n?F(u):(n=o=void 0,i)}function Me(){a!==void 0&&Le(a),b=0,n=l=o=a=void 0}function Ve(){return a===void 0?i:le(Date.now())}function Qe(){return a!==void 0}function C(...u){let y=Date.now(),x=ce(y);if(n=u,o=this,l=y,x){if(a===void 0)return Ne(l);if(p)return a=L(N,e),F(l)}return a===void 0&&(a=L(N,e)),i}return C.cancel=Me,C.flush=Ve,C.pending=Qe,C}var X=(t,e=0,r)=>$(t,e,{...{leading:!0,trailing:!0},...r,maxWait:e});var M=(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]=M(t[n],e):r[n]=t[n]}return r};var ft=t=>M(t);var P=class extends I{constructor(r){super();this.buffer=[];this.cursorEnd=-1;this.cursorStart=0;this.bufferSize=r,this.buffer=Array(r)}next(r){this.cursorEnd+=1,this.cursorStart=this.cursorEnd>=this.bufferSize?this.cursorStart+1:0,this.buffer[this.cursorEnd%this.bufferSize]=r,this.subscribers.forEach(n=>n.next(r))}_subscribe(r){for(let o=this.cursorStart;o<=this.cursorEnd;o++)r.next(this.buffer[o%this.bufferSize]);let n=this.keyCounter++;return this.subscribers.set(n,r),new d().add(()=>this.subscribers.delete(n))}};var V=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 r=super._subscribe(e);return e.next(this.value),r}};function fe(t){return new c(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 d)})}function Te(...t){return new c(e=>t.reduce((r,n)=>r.add(n.subscribe(e)),new d))}var Tt=t=>new c(e=>{let r=m().setTimeout(()=>{try{e.next()}catch(n){if(e.error)e.error(n);else throw n}},t);return()=>m().clearTimeout(r)});var yt=t=>new c(e=>{let r=m(),n=r.setInterval(()=>e.next(),t);return()=>{n&&(r.clearInterval(n),n=void 0)}});var It=t=>new c(e=>{t.forEach(r=>e.next(r))});var gt=(t,e)=>new c(r=>{let n=o=>r.next(o);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)});var Q=class extends d{remove(e){this.subscriptions=this.subscriptions.filter(r=>r!==e)}};function ye(t){return e=>new c(r=>e.subscribe(new Y(r,t)))}var Y=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 ht={leading:!1,trailing:!0};function Ie(t,e=ht){return r=>new c(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;let r=m();O(this.timeout)?r.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=r.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(n){if(this.destination.error)this.destination.error(n);else throw n}this.timeout=void 0},this.time)}error(e){this.destination.error?.(e)}};var vt={leading:!0,trailing:!1};function ge(t,e=vt){return r=>new c(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,k(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=m().setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){this.destination.error?.(e)}};function he(t){return e=>new c(r=>e.subscribe(new ee(r,t)))}var ee=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)}};var xt=(t,e)=>{let r=(n,o)=>{let s=Object.keys(n);for(let i in o)if(!s.includes(i)||o[i]!==n[i])return!1;return!0};return r(t,e)&&r(e,t)},Ot=(t,e)=>t instanceof Object&&e instanceof Object?xt(t,e):t===e;function xe(t=Ot){return e=>new c(r=>e.subscribe(new te(r,t)))}var ve={},te=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=ve}next(e){let r;try{r=this.lastValue===ve||!this.predicate(this.lastValue,e),this.lastValue=e instanceof Object&&!Array.isArray(e)?{...e}:e}catch(n){throw this.error(n),n}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function _(t){return e=>new c(r=>e.subscribe(new re(r,t)))}var re=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 Oe(t){return _(()=>t)}function Ee(){return t=>new c(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 we(){return t=>new c(e=>t.subscribe(new ne(e)))}var ne=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 Se(t){return e=>new c(r=>e.subscribe(new oe(r,t)))}var oe=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)}};function Ae(t){return e=>new c(r=>e.subscribe(new ie(r,t)))}var ie=class{constructor(e,r){this.destination=e;this.count=r;r<0&&this.destination.error?.(new Error("Count can not be less than zero"))}next(e){this.count===0?this.destination.next(e):this.count--}error(e){this.destination.error?.(e)}};function Pe(t=0){return e=>{let r=0,n=new P(t),o=e.subscribe(n),s=i=>()=>{i.unsubscribe(),r--,r===0&&o.unsubscribe()};return new c(i=>(r++,s(n.subscribe(i))))}}var Et=300,wt=(t,e=Et)=>new c(r=>{let n=m(),{width:o,height:s}=t.getBoundingClientRect();if(r.next({width:o,height:s}),!me(n))return;let i=new n.ResizeObserver(X(a=>{let l=a[0];if(!l)return;let b,v;l.contentBoxSize&&l.contentBoxSize[0]?(v=l.contentBoxSize[0].blockSize,b=l.contentBoxSize[0].inlineSize):l.contentRect&&(b=l.contentRect.width,v=l.contentRect.height),O(b)&&O(v)&&r.next({width:b,height:v})},e));return i.observe(t),()=>i.disconnect()});var D=(t,e=6,r=".")=>{let n={};for(let o in t)if(!(!t.hasOwnProperty(o)||t[o]instanceof HTMLElement||!e))if(typeof t[o]=="object"&&t[o]!==null){let s=D(t[o],e-1);for(let i in s)s.hasOwnProperty(i)&&(n[o+r+i]=s[i])}else n[o]=t[o];return n};var St=t=>{t.removeAttribute("src"),t.load()};var mo=t=>{let e;try{e=new URL(t)}catch{return!1}return e.protocol==="https:"};var At=(t,e)=>!(t.right<e.left||t.left>e.right||t.bottom<e.top||t.top>e.bottom);var Pt=(()=>{let t=0;return()=>{let e=t;return t=(t+1)%Number.MAX_SAFE_INTEGER,e}})(),kt=t=>t!==void 0&&t!==""?t:Pt().toString();function Rt(t,e,r){if(t<=e[0])return r[0];if(t>=e[e.length-1])return r[r.length-1];let n=1;for(;n<e.length&&e[n]<t;)n++;n>=e.length&&(n=e.length-1);let o=e[n-1],s=e[n],i=r[n-1],a=r[n];if(t===o)return i;if(t===s)return a;let l=(t-o)/(s-o);return i+l*(a-i)}function Lt(t,e,r){if(t<=0||r<0)return[];let n=[],o=Math.floor((t-1)/2),s=Math.floor(t/2),i=e-o,a=e+s;i<0&&(a+=Math.abs(i),i=0),a>r&&(i-=a-r,a=r),i=Math.max(0,i),a=Math.min(r,a);for(let l=i;l<=a;l++)n.push(l);return n}var Nt=t=>e=>r=>{let n=typeof r=="object";r==null||n&&!Object.keys(r).length||t(e,n?D(r):{value:r})},U=(t={})=>{let e=n=>{let o=n;return n===void 0?o="undefined":n===null?o="null":(typeof n=="number"||typeof n=="boolean")&&(o=n.toString()),o},r={};for(let n in t)Array.isArray(t[n])?r[n]=t[n].map(e):r[n]=e(t[n]);return r};var h=class t{constructor({name:e,getParentContext:r}){this.dynamicImportTimeout=5e3;this.childTracers=[];t.dynamicImportStatus==="not_started"&&(t.dynamicImportPromise=this.loadOpentelemetry());let n=Date.now();this.initPromise=t.dynamicImportPromise.then(o=>{t.dynamicImportStatus==="completed"&&this.init({name:e,getParentContext:r},n)})}static{this.dynamicImportStatus="not_started"}init({name:e,getParentContext:r},n){this.span=t.rootTracer.startSpan(e,{startTime:n},r?.()),this.context=t.dynamicImports.opentelemetryApi.trace.setSpan(t.dynamicImports.opentelemetryApi.context.active(),this.span)}async loadOpentelemetry(){if(t.dynamicImportStatus==="not_started"){t.dynamicImportStatus="in_progress";try{let e=new Promise((i,a)=>setTimeout(a,this.dynamicImportTimeout)),r=Promise.all([import("@opentelemetry/api"),import("@opentelemetry/sdk-trace-web"),import("@apptracer/opentelemetry")]),[n,o,s]=await Promise.race([r,e]);t.dynamicImports={opentelemetryApi:n,opentelemetrySdk:o,tracer:s},t.dynamicImportStatus="completed"}catch{t.dynamicImportStatus="failed"}}}isComponentTracerNotInitialized(){return k(this.span)||t.dynamicImportStatus==="failed"}log(e,r){let n=Date.now();this.initPromise.then(o=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...U(r),type:"log"},n)})}error(e,r){let n=Date.now();this.initPromise.then(o=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...U(r),type:"error"},n)})}critical(e,r){let n=Date.now();this.initPromise.then(o=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...U(r),type:"critical"},n)})}createComponentTracer(e){let r=new t({name:e,getParentContext:()=>this.context});return this.childTracers.push(r),r}end(){this.initPromise.then(e=>{this.isComponentTracerNotInitialized()||(this.childTracers.forEach(r=>r.end()),this.span.end())})}};var j=class extends h{constructor(){super({name:"Root"})}init({name:e,getParentContext:r},n){let s=h.dynamicImports.tracer.initTracerOpenTelemetry({serviceName:"videoplayer-sdk-web",appToken:"L9SBoka6ZWk4xPjaK7tmfSfYvMhcge7nvGDjpdMmscb",spanLimits:{attributeCountLimit:1/0,eventCountLimit:1/0,attributePerEventCountLimit:1/0}}).getProvider(),i=new h.dynamicImports.tracer.TracerMemorySpanExporter;this.spanExporter=i,s.addSpanProcessor(new h.dynamicImports.tracer.TracerAllSpansProcessor({startedSpansExporter:i})),h.rootTracer=s.getTracer("sdk-videoplayer-tracer"),super.init({name:e,getParentContext:r},n)}getFinishedSpans(){if(!this.isComponentTracerNotInitialized())return this.spanExporter?.getJsonData()}getTraceId(){return this.isComponentTracerNotInitialized()?"":this.span.spanContext().traceId}};var W=class t{constructor(e){}log(e,r){}error(e,r){}critical(e,r){}createComponentTracer(e){return new t({name:e})}end(){}getFinishedSpans(){}getTraceId(){return this.fakeTraceId}};var se=class{static createRootTracer(e=!1){return e?new j:new W}};var Ct=(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))(Ct||{});var Mt=(p=>(p.Armenian="58",p.Azerbaijani="57",p.Belarusian="114",p.English="3",p.Kazakh="97",p.Portuguese="73",p.Russian="0",p.Spanish="4",p.Ukrainian="1",p.Uzbek="65",p.Vietnamese="75",p))(Mt||{}),Vt="vk.com",Si=async(t,e,r)=>{let n=new URL(`https://${Vt}/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 Qt(s,r)},Qt=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,n])=>[r.substring(`${e}_`.length),_t(n)])),_t=t=>Array.isArray(t)?t[0]:t;var Dt=(r=>(r.RU="ru",r.EN="en",r))(Dt||{});var f="__vk_vp_internals_exposure",ke=class{constructor(e,r){this.playerId=r,this.type=e,this.initWindowObjects()}getWindowObject(){if(typeof window>"u")return{};let e=this.playerId,r=this.type;return window[f]?.[e]?.[r]??{}}initWindowObjects(){if(typeof window>"u")return;let e=this.playerId,r=this.type;window[f]||(window[f]={}),window[f][e]||(window[f][e]={}),window[f][e][r]||(window[f][e][r]={})}expose(e){typeof window>"u"||Object.assign(this.getWindowObject(),e)}destroy(){if(typeof window>"u")return;let e=this.playerId,r=this.type;window[f]&&window[f][e]&&window[f][e][r]&&(delete window[f][e][r],Object.keys(window[f][e]).length||delete window[f][e],Object.keys(window[f]).length||delete window[f])}};var Re={};ue(Re,{create:()=>Ut,destroy:()=>jt,push:()=>Wt,subscribe:()=>zt});var R=new Map,Ut=(t,e)=>R.set(t,e??[]),jt=t=>R.delete(t),Wt=(t,e)=>{let r=R.get(t);r&&(typeof r=="function"?r(e):r.push(e))},zt=(t,e)=>{let r=R.get(t);if(r){if(r&&Array.isArray(r))for(let n of r)e(n);R.set(t,e)}};export{Ct as ErrorCategory,f as INTERNAL_EXPOSE_GLOBAL_KEY,Dt as InterfaceLanguage,ke as InternalsExposure,G as Logger,c as Observable,P as ReplaySubject,I as Subject,d as Subscription,Q as SubscriptionRemovable,se as TracerFactory,De as VERSION,Mt as VKNumericLanguage,V as ValueSubject,K as VideoQuality,$e as abortable,He as addScript,ut as areQualitiesExact,Ke as assertEmptyArray,g as assertNever,ze as assertNonNullable,Be as assertNotEmptyArray,Fe as assertNullable,mt as assertQualityIsExact,ye as buffer,Ue as checkNever,St as clearVideoElement,ft as cloneDeep,M as cloneDeepWith,fe as combine,Ie as debounce,$ as debounceFn,nt as detectEmbed,Re as devNull,dt as fillWithDefault,he as filter,xe as filterChanged,D as flattenObject,gt as fromEvent,Xe as getExponentialDelay,at as getHighestQuality,kt as getPlayerId,Lt as getRangeAroundIndex,Nt as getTraceSubscriptionMethod,bt as getVideoQualityLabel,m as getWindow,Rt as interpolate,yt as interval,me as isBrowserWindow,ot as isHigher,it as isHigherOrEqual,At as isIntersecting,q as isInvariantQuality,H as isLower,st as isLowerOrEqual,O as isNonNullable,k as isNullable,mo as isValidURL,Si as loadVKLangPack,_ as map,Oe as mapTo,Te as merge,w as noop,qe as now,It as observableFrom,wt as observeElementSize,Ee as once,we as pairwise,be as safeStorage,Pe as shareReplay,Ae as skip,Se as tap,ge as throttle,X as throttleFn,xr as timeCodeToString,Tt as timeout,ct as videoHeightToQuality,pt as videoQualityToHeight,lt as videoSizeToQuality,Ge as withoutNullable};
6
+ var Fe=Object.defineProperty;var de=(t,e)=>{for(var r in e)Fe(t,r,{get:e[r],enumerable:!0})};var Ke="1.0.82-dev.4dbe88bb.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 h=t=>{throw new Error(`${t} is value of unexpected type`)},Be=t=>{};var S=()=>{};var Ge=t=>{throw console.error(t),t},He=t=>{console.error(t)},c=class{constructor(e){this.suppressErrors=!1;e&&(this._subscribe=e)}setSuppressErrors(e){this.suppressErrors=e}subscribe(e,r){let o=this.suppressErrors?He:Ge,n;r?typeof r=="function"?n={next:r,error:S}:n={next:a=>r.next(a),error:a=>r.error?.(a)}:n={next:o,error:S};let s=typeof e=="function"?{next:a=>{try{let p=e(a);p instanceof Promise&&p.catch(d=>n.next(d))}catch(p){n.next(p)}},error:a=>n.next(a)}:{next:a=>e.next(a),error:a=>e.error?e.error(a):n.next(a)},i;try{i=this._subscribe(s)}catch(a){s.error?.(a)}return new b().add(()=>{switch(s.next=S,s.error=S,typeof i){case"function":i();return;case"object":i.unsubscribe();return;case"undefined":return;default:return h(i)}})}pipe(...e){return e.reduce((r,o)=>o(r),this)}_subscribe(e){}};var I=class extends c{constructor(){super();this.keyCounter=0;this.subscribers=new Map}next(r){this.subscribers.forEach(o=>o.next(r))}error(r){this.subscribers.forEach(o=>o.error?.(r))}_subscribe(r){let o=this.keyCounter++;return this.subscribers.set(o,r),new b().add(()=>this.subscribers.delete(o))}};var K=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 o;try{o=e(...r)}catch{o={message:"error in `createCustomLog`",component:"Logger"}}this.log(o)}}createComponentLog(e){return this.createCustomLog(r=>({component:e,...r}))}};function qe(t,e='Assertion "value is not nullable" failed'){if(t==null)throw new Error(e)}function $e(t,e='Assertion "value is nullable" failed'){if(t!=null)throw new Error(e)}function g(t){return typeof t<"u"&&t!==null}function O(t){return t==null}var B=t=>Object.fromEntries(Object.entries(t).filter(([e,r])=>g(r)));function Je(t,e){if(!t?.length)throw new Error(e)}function Ye(t,e){if(t?.length)throw new Error(e)}var u=()=>globalThis,be=(t=u())=>!!(t.window&&t.screen);var Xe=(t,e,r)=>new Promise((o,n)=>{e.addEventListener("abort",()=>{a(),d.remove()});let s=()=>{a(),n("error")},i=()=>{a(),o()},a=()=>{p&&clearTimeout(p),d.removeEventListener("load",i),d.removeEventListener("error",s)},p;r&&(p=u().setTimeout(()=>{a(),n("timeout")},r));let d=document.createElement("script");d.addEventListener("load",i),d.addEventListener("error",s),d.src=t,document.head.appendChild(d)});var Ze=typeof u().performance?.now=="function"?()=>u().performance.now():()=>Date.now();var et=(t,e)=>async(...r)=>{let o=e(...r),n=t.aborted,s;for(;!n&&!t.aborted;)try{let i=await o.next(s);n=i.done??!1,s=i.value}catch(i){await o.throw(i)}return s};var tt=(t,{start:e=0,factor:r=2,max:o=1/0,min:n=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,o),i=Math.max(i,n),i};var fe={};de(fe,{clear:()=>at,get:()=>ot,has:()=>it,isPersistent:()=>rt,remove:()=>st,set:()=>nt});var A,w,G=`vk-videoplayer-dummy-key-${Math.random()}`,P=()=>{if(w!==void 0)return w;try{localStorage.setItem(G,"test"),localStorage.removeItem(G),w=0}catch(t){if(t instanceof DOMException||t instanceof TypeError)try{sessionStorage.getItem(G),w=1}catch(e){if(e instanceof DOMException||e instanceof TypeError)w=2;else throw e}else throw t}return w===2&&(A=new Map),w},rt=()=>P()===0,ot=t=>{let e=P();switch(e){case 0:return localStorage.getItem(t)??void 0;case 1:return sessionStorage.getItem(t)??void 0;case 2:return A?.get(t);default:h(e)}},nt=(t,e)=>{let r=P();switch(r){case 0:try{localStorage.setItem(t,e)}catch(o){if(o instanceof DOMException)console.error(o);else throw o}break;case 1:try{sessionStorage.setItem(t,e)}catch(o){if(o instanceof DOMException)console.error(o);else throw o}break;case 2:A?.set(t,e);return;default:h(r)}},it=t=>{let e=P();switch(e){case 0:return t in localStorage;case 1:return t in sessionStorage;case 2:return A?.has(t)??!1;default:return h(e),!1}},st=t=>{let e=P();switch(e){case 0:return localStorage.removeItem(t);case 1:return sessionStorage.removeItem(t);case 2:A?.delete(t);return;default:h(e)}},at=()=>{let t=P();switch(t){case 0:return localStorage.clear();case 1:return sessionStorage.clear();case 2:return A?.clear();default:h(t)}};var ct=()=>{let t,e=[],r=u();try{t=r.self!==r.top}catch(o){o instanceof DOMException&&o.name==="SecurityError"?t=!0:(t=!1,console.error(o))}try{r.location.ancestorOrigins&&(e=[...r.location.ancestorOrigins])}catch(o){console.error(o)}try{!e.length&&r.document.referrer&&(e=[new URL(r.document.referrer).origin])}catch(o){console.error(o)}return e=e.filter(o=>URL.canParse(o)),{isEmbed:t,origins:e,topOrigin:e.at(-1),immediateOrigin:e.at(0)}};var H=(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))(H||{});var T={"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}},pt=(t,e)=>T[t].height>T[e].height,lt=(t,e)=>T[t].height>=T[e].height,q=(t,e)=>T[t].height<T[e].height,ut=(t,e)=>T[t].height<=T[e].height,mt=t=>t.sort((e,r)=>e===r?0:e==="Invariant quality"?1:r==="Invariant quality"?-1:q(e,r)?1:-1)[0],Te=Object.keys(T).sort((t,e)=>q(t,e)?-1:1),dt=(t,e=.02)=>[...Te].find(o=>T[o].height*(1+e)>=t),bt=({width:t,height:e})=>{let r=Math.min(t,e),o=Math.max(t,e);return Te.find(n=>{let s=T[n];return s.width>=o&&s.height>=r})},ft=t=>T[t].height,$=t=>t==="Invariant quality",Tt=t=>t.every(e=>!$(e));function yt(t){if($(t))throw new Error("Expected exact quality")}var It=t=>{switch(t){case"4320p":return"8K";case"2160p":return"4K";case"1440p":return"QHD";case"1080p":return"FHD";case"720p":return"HD";default:return""}};var ht=(t,e)=>{let r={};for(let o of Object.keys(e)){let n=e[o],s=t[o];Array.isArray(n)&&Array.isArray(s)?r[o]=s:typeof n=="object"&&typeof s=="object"?r[o]=ht(s,n):r[o]=o in t?s:n}return r};var Ar=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 J(t,e=0,r){let o,n,s,i,a,p,d=0,v=!1,l=!1,z=!0,pe=!e&&e!==0&&typeof u().requestAnimationFrame=="function";r&&(v=!!r.leading,l="maxWait"in r,s=r?.maxWait?Math.max(+r?.maxWait||0,e):s,z="trailing"in r?!!r.trailing:z);function F(m){let y=o,E=n;return o=n=void 0,d=m,i=t.apply(E,y),i}function R(m,y){return pe?(a&&u().cancelAnimationFrame(a),u().requestAnimationFrame(m)):setTimeout(m,y)}function _e(m){if(pe){u().cancelAnimationFrame(m);return}clearTimeout(m)}function De(m){return d=m,a=R(L,e),v?F(m):i}function Ue(m){let y=m-p,E=m-d,me=e-y;return l?Math.min(me,s-E):me}function le(m){let y=m-p,E=m-d;return p===void 0||y>=e||y<0||l&&E>=s}function L(){let m=Date.now();if(le(m))return ue(m);a=R(L,Ue(m))}function ue(m){return a=void 0,z&&o?F(m):(o=n=void 0,i)}function je(){a!==void 0&&_e(a),d=0,o=p=n=a=void 0}function We(){return a===void 0?i:ue(Date.now())}function ze(){return a!==void 0}function C(...m){let y=Date.now(),E=le(y);if(o=m,n=this,p=y,E){if(a===void 0)return De(p);if(l)return a=R(L,e),F(p)}return a===void 0&&(a=R(L,e)),i}return C.cancel=je,C.flush=We,C.pending=ze,C}var Y=(t,e=0,r)=>J(t,e,{...{leading:!0,trailing:!0},...r,maxWait:e});var M=(t,e)=>{if(t===null||typeof t!="object")return t;let r=Array.isArray(t)?[]:{};for(let o in t){if(typeof e=="function"){let n=e(t[o],o,t,r);if(n!==void 0){r[o]=n;continue}}typeof t[o]=="object"?r[o]=M(t[o],e):r[o]=t[o]}return r};var gt=t=>M(t);var k=class extends I{constructor(r){super();this.buffer=[];this.cursorEnd=-1;this.cursorStart=0;this.bufferSize=r,this.buffer=Array(r)}next(r){this.cursorEnd+=1,this.cursorStart=this.cursorEnd>=this.bufferSize?this.cursorStart+1:0,this.buffer[this.cursorEnd%this.bufferSize]=r,this.subscribers.forEach(o=>o.next(r))}_subscribe(r){for(let n=this.cursorStart;n<=this.cursorEnd;n++)r.next(this.buffer[n%this.bufferSize]);let o=this.keyCounter++;return this.subscribers.set(o,r),new b().add(()=>this.subscribers.delete(o))}};var V=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 r=super._subscribe(e);return e.next(this.value),r}};function ye(t){return new c(e=>{let r={},o=Object.keys(t).length,n=s=>i=>{s in r||o--,r[s]=i,o===0&&e.next(r)};return Object.entries(t).reduce((s,[i,a])=>s.add(a.subscribe(n(i))),new b)})}function Ie(...t){return new c(e=>t.reduce((r,o)=>r.add(o.subscribe(e)),new b))}var vt=t=>new c(e=>{let r=u().setTimeout(()=>{try{e.next()}catch(o){if(e.error)e.error(o);else throw o}},t);return()=>u().clearTimeout(r)});var xt=t=>new c(e=>{let r=u(),o=r.setInterval(()=>e.next(),t);return()=>{o&&(r.clearInterval(o),o=void 0)}});var Et=t=>new c(e=>{t.forEach(r=>e.next(r))});var Ot=(t,e)=>new c(r=>{let o=n=>r.next(n);return t.addEventListener(e,o),()=>t.removeEventListener(e,o)});var Q=class extends b{remove(e){this.subscriptions=this.subscriptions.filter(r=>r!==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.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 wt={leading:!1,trailing:!0};function ge(t,e=wt){return r=>new c(o=>r.subscribe(new Z(o,t,e)))}var Z=class{constructor(e,r,o){this.destination=e;this.time=r;this.config=o}next(e){this.lastValue=e;let r=u();g(this.timeout)?r.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=r.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(o){if(this.destination.error)this.destination.error(o);else throw o}this.timeout=void 0},this.time)}error(e){this.destination.error?.(e)}};var St={leading:!0,trailing:!1};function ve(t,e=St){return r=>new c(o=>r.subscribe(new ee(o,t,e)))}var ee=class{constructor(e,r,o){this.destination=e;this.time=r;this.config=o}next(e){this.lastValue=e,O(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=u().setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){this.destination.error?.(e)}};function xe(t){return e=>new c(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(o){throw this.error(o),o}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};var At=(t,e)=>{let r=(o,n)=>{let s=Object.keys(o);for(let i in n)if(!s.includes(i)||n[i]!==o[i])return!1;return!0};return r(t,e)&&r(e,t)},Pt=(t,e)=>t instanceof Object&&e instanceof Object?At(t,e):t===e;function Oe(t=Pt){return e=>new c(r=>e.subscribe(new re(r,t)))}var Ee={},re=class{constructor(e,r){this.destination=e;this.predicate=r;this.lastValue=Ee}next(e){let r;try{r=this.lastValue===Ee||!this.predicate(this.lastValue,e),this.lastValue=e instanceof Object&&!Array.isArray(e)?{...e}:e}catch(o){throw this.error(o),o}r&&this.destination.next(e)}error(e){this.destination.error?.(e)}};function _(t){return e=>new c(r=>e.subscribe(new oe(r,t)))}var oe=class{constructor(e,r){this.destination=e;this.mapper=r}next(e){let r;try{r=this.mapper(e)}catch(o){throw this.error(o),o}this.destination.next(r)}error(e){this.destination.error?.(e)}};function we(t){return _(()=>t)}function Se(){return t=>new c(e=>{let r=!1,o=!1,n=t.subscribe(s=>{r||(r=!0,e.next(s)),o&&n.unsubscribe()},s=>{r=!0,e.error?.(s),o&&n.unsubscribe()});return o=!0,r&&n.unsubscribe(),n})}function Ae(){return t=>new c(e=>t.subscribe(new ne(e)))}var ne=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 c(r=>e.subscribe(new ie(r,t)))}var ie=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)}};function ke(t){return e=>new c(r=>e.subscribe(new se(r,t)))}var se=class{constructor(e,r){this.destination=e;this.count=r;r<0&&this.destination.error?.(new Error("Count can not be less than zero"))}next(e){this.count===0?this.destination.next(e):this.count--}error(e){this.destination.error?.(e)}};function Ne(t=0){return e=>{let r=0,o=new k(t),n=e.subscribe(o),s=i=>()=>{i.unsubscribe(),r--,r===0&&n.unsubscribe()};return new c(i=>(r++,s(o.subscribe(i))))}}var kt=300,Nt=(t,e=kt)=>new c(r=>{let o=u(),{width:n,height:s}=t.getBoundingClientRect();if(r.next({width:n,height:s}),!be(o))return;let i=new o.ResizeObserver(Y(a=>{let p=a[0];if(!p)return;let d,v;p.contentBoxSize&&p.contentBoxSize[0]?(v=p.contentBoxSize[0].blockSize,d=p.contentBoxSize[0].inlineSize):p.contentRect&&(d=p.contentRect.width,v=p.contentRect.height),g(d)&&g(v)&&r.next({width:d,height:v})},e));return i.observe(t),()=>i.disconnect()});var D=(t,e=6,r=".")=>{let o={};for(let n in t)if(!(!t.hasOwnProperty(n)||t[n]instanceof HTMLElement||!e))if(typeof t[n]=="object"&&t[n]!==null){let s=D(t[n],e-1);for(let i in s)s.hasOwnProperty(i)&&(o[n+r+i]=s[i])}else o[n]=t[n];return o};var Rt=t=>{t.removeAttribute("src"),t.load()};var In=t=>{let e;try{e=new URL(t)}catch{return!1}return e.protocol==="https:"};var Lt=(t,e)=>!(t.right<e.left||t.left>e.right||t.bottom<e.top||t.top>e.bottom);var Ct=(()=>{let t=0;return()=>{let e=t;return t=(t+1)%Number.MAX_SAFE_INTEGER,e}})(),Mt=t=>t!==void 0&&t!==""?t:Ct().toString();function Vt(t,e,r){if(t<=e[0])return r[0];if(t>=e[e.length-1])return r[r.length-1];let o=1;for(;o<e.length&&e[o]<t;)o++;o>=e.length&&(o=e.length-1);let n=e[o-1],s=e[o],i=r[o-1],a=r[o];if(t===n)return i;if(t===s)return a;let p=(t-n)/(s-n);return i+p*(a-i)}function Qt(t,e,r){if(t<=0||r<0)return[];let o=[],n=Math.floor((t-1)/2),s=Math.floor(t/2),i=e-n,a=e+s;i<0&&(a+=Math.abs(i),i=0),a>r&&(i-=a-r,a=r),i=Math.max(0,i),a=Math.min(r,a);for(let p=i;p<=a;p++)o.push(p);return o}var _t=t=>e=>r=>{let o=typeof r=="object";r==null||o&&!Object.keys(r).length||t(e,o?D(r):{value:r})},U=(t={})=>{let e=o=>{let n=o;return o===void 0?n="undefined":o===null?n="null":(typeof o=="number"||typeof o=="boolean")&&(n=o.toString()),n},r={};for(let o in t)Array.isArray(t[o])?r[o]=t[o].map(e):r[o]=e(t[o]);return r};var x=class t{constructor({name:e,getParentContext:r}){this.dynamicImportTimeout=5e3;this.childTracers=[];t.dynamicImportStatus==="not_started"&&(t.dynamicImportPromise=this.loadOpentelemetry());let o=Date.now();this.initPromise=t.dynamicImportPromise.then(n=>{t.dynamicImportStatus==="completed"&&this.init({name:e,getParentContext:r},o)})}static{this.dynamicImportStatus="not_started"}init({name:e,getParentContext:r},o){this.span=t.rootTracer.startSpan(e,{startTime:o},r?.()),this.context=t.dynamicImports.opentelemetryApi.trace.setSpan(t.dynamicImports.opentelemetryApi.context.active(),this.span)}async loadOpentelemetry(){if(t.dynamicImportStatus==="not_started"){t.dynamicImportStatus="in_progress";try{let e=new Promise((i,a)=>setTimeout(a,this.dynamicImportTimeout)),r=Promise.all([import("@opentelemetry/api"),import("@opentelemetry/sdk-trace-web"),import("@apptracer/opentelemetry")]),[o,n,s]=await Promise.race([r,e]);t.dynamicImports={opentelemetryApi:o,opentelemetrySdk:n,tracer:s},t.dynamicImportStatus="completed"}catch{t.dynamicImportStatus="failed"}}}isComponentTracerNotInitialized(){return O(this.span)||t.dynamicImportStatus==="failed"}log(e,r){let o=Date.now();this.initPromise.then(n=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...U(r),type:"log"},o)})}error(e,r){let o=Date.now();this.initPromise.then(n=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...U(r),type:"error"},o)})}critical(e,r){let o=Date.now();this.initPromise.then(n=>{this.isComponentTracerNotInitialized()||this.span.addEvent(e,{...U(r),type:"critical"},o)})}createComponentTracer(e){let r=new t({name:e,getParentContext:()=>this.context});return this.childTracers.push(r),r}end(){this.initPromise.then(e=>{this.isComponentTracerNotInitialized()||(this.childTracers.forEach(r=>r.end()),this.span.end())})}};var j=class extends x{constructor(){super({name:"Root"})}init({name:e,getParentContext:r},o){let s=x.dynamicImports.tracer.initTracerOpenTelemetry({serviceName:"videoplayer-sdk-web",appToken:"L9SBoka6ZWk4xPjaK7tmfSfYvMhcge7nvGDjpdMmscb",spanLimits:{attributeCountLimit:1/0,eventCountLimit:1/0,attributePerEventCountLimit:1/0}}).getProvider(),i=new x.dynamicImports.tracer.TracerMemorySpanExporter;this.spanExporter=i,s.addSpanProcessor(new x.dynamicImports.tracer.TracerAllSpansProcessor({startedSpansExporter:i})),x.rootTracer=s.getTracer("sdk-videoplayer-tracer"),super.init({name:e,getParentContext:r},o)}getFinishedSpans(){if(!this.isComponentTracerNotInitialized())return this.spanExporter?.getJsonData()}getTraceId(){return this.isComponentTracerNotInitialized()?"":this.span.spanContext().traceId}};var W=class t{constructor(e){}log(e,r){console.log(e),console.log(JSON.stringify(r))}error(e,r){console.error(e),console.error(JSON.stringify(r))}critical(e,r){console.error(e),console.error(JSON.stringify(r))}createComponentTracer(e){return new t({name:e})}end(){}getFinishedSpans(){}getTraceId(){return this.fakeTraceId}};var ae=class{static createRootTracer(e=!1){return e?new j:new W}};var Re=(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))(Re||{});var Dt=(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))(Dt||{}),Ut="vk.com",Ri=async(t,e,r)=>{let o=new URL(`https://${Ut}/js/lang-pack.js`);o.searchParams.set("format","json"),o.searchParams.set("name",e),t!==void 0&&o.searchParams.set("lang",t);let s=await(await fetch(o.toString())).json();return jt(s,r)},jt=(t,e)=>Object.fromEntries(Object.entries(t.keys).map(([r,o])=>[r.substring(`${e}_`.length),Wt(o)])),Wt=t=>Array.isArray(t)?t[0]:t;var zt=(r=>(r.RU="ru",r.EN="en",r))(zt||{});var f="__vk_vp_internals_exposure",Le=class{constructor(e,r){this.playerId=r,this.type=e,this.initWindowObjects()}getWindowObject(){if(typeof window>"u")return{};let e=this.playerId,r=this.type;return window[f]?.[e]?.[r]??{}}initWindowObjects(){if(typeof window>"u")return;let e=this.playerId,r=this.type;window[f]||(window[f]={}),window[f][e]||(window[f][e]={}),window[f][e][r]||(window[f][e][r]={})}expose(e){typeof window>"u"||Object.assign(this.getWindowObject(),e)}destroy(){if(typeof window>"u")return;let e=this.playerId,r=this.type;window[f]&&window[f][e]&&window[f][e][r]&&(delete window[f][e][r],Object.keys(window[f][e]).length||delete window[f][e],Object.keys(window[f]).length||delete window[f])}};var Ce={};de(Ce,{create:()=>Ft,destroy:()=>Kt,push:()=>Bt,subscribe:()=>Gt});var N=new Map,Ft=(t,e)=>N.set(t,e??[]),Kt=t=>N.delete(t),Bt=(t,e)=>{let r=N.get(t);r&&(typeof r=="function"?r(e):r.push(e))},Gt=(t,e)=>{let r=N.get(t);if(r){if(r&&Array.isArray(r))for(let o of r)e(o);N.set(t,e)}};var Me="gW5EerTD5QhAnsbpF7Hd2NSMRteYIUUMjFbSyI68Pf5";var Ve=t=>{let e={id:t.id,message:t.message,category:t.category,data:Ht(t.data),httpCode:t.httpCode,UVBackendErrorCode:t.UVBackendErrorCode};return B(e)};function Ht(t){switch(typeof t){case"boolean":case"string":case"number":return t;case"object":try{return JSON.stringify(t)}catch{return}default:return}}var Qe=t=>{let e=t.thrown instanceof Error?t.thrown:new Error(t.message);return e.name=t.id,e};var ce=class t{constructor(e,r,o,n){this.dynamicImportTimeout=5e3;this.subscription=new b;this.componentName=e,this.options=r,this.envParams=o,this.context=n,this.options.enabled&&(this.loadModule(),this.init())}static{this.tracerErrorMap=new Map}static{this.appTracerModule=null}static{this.loadPromise=null}error(e,r){let{blackErrorCategoryList:o,blackErrorIdList:n,sampleRate:s,whiteErrorCategoryList:i,whiteErrorIdList:a}=this.options,{id:p,category:d}=e;if(o.length&&o.includes(d)||n.length&&n.includes(p)||i.length&&!i.includes(d)||a.length&&!a.includes(p)||Math.random()>=s)return;t.tracerErrorMap.get(this.componentName)?.error(Qe(e),{severity:r?.severity??(e.traceAsLog?"debug":void 0),keys:{...this.context,...Ve(e)}})}addSubscription(e){this.subscription.add(e)}destroy(){this.subscription.unsubscribe()}async init(){try{if(await t.loadPromise,t.tracerErrorMap.has(this.componentName)||O(t.appTracerModule))return;let{appTracerModule:e}=t,{initTracerError:r,initTracerErrorUploader:o,addTracerPlugin:n}=e,s=r(this.componentName,{enableUnhandledErrorsListeners:!1,stringifyErrorDataObject:!0});o(this.componentName,{appToken:Me,environment:this.envParams.env,versionCode:1,versionName:this.envParams.version}),n(this.componentName,{name:"addedCategory",errorBeforeAdd(i){let a=i.keys?.category??"wtf";if(typeof a=="string")return{issueKey:a}}}),t.tracerErrorMap.set(this.componentName,s)}catch{}}loadModule(){if(g(t.loadPromise))return;let e=async()=>{try{let r=new Promise((n,s)=>u().setTimeout(s,this.dynamicImportTimeout)),o=await Promise.race([r,import("@apptracer/sdk/lite")]);t.appTracerModule=o}catch{t.loadPromise=null}};t.loadPromise=e()}};export{ce as AppTracer,Re as ErrorCategory,f as INTERNAL_EXPOSE_GLOBAL_KEY,zt as InterfaceLanguage,Le as InternalsExposure,K as Logger,c as Observable,k as ReplaySubject,I as Subject,b as Subscription,Q as SubscriptionRemovable,ae as TracerFactory,Ke as VERSION,Dt as VKNumericLanguage,V as ValueSubject,H as VideoQuality,et as abortable,Xe as addScript,Tt as areQualitiesExact,Ye as assertEmptyArray,h as assertNever,qe as assertNonNullable,Je as assertNotEmptyArray,$e as assertNullable,yt as assertQualityIsExact,he as buffer,Be as checkNever,Rt as clearVideoElement,gt as cloneDeep,M as cloneDeepWith,ye as combine,ge as debounce,J as debounceFn,ct as detectEmbed,Ce as devNull,ht as fillWithDefault,xe as filter,Oe as filterChanged,D as flattenObject,Ot as fromEvent,tt as getExponentialDelay,mt as getHighestQuality,Mt as getPlayerId,Qt as getRangeAroundIndex,_t as getTraceSubscriptionMethod,It as getVideoQualityLabel,u as getWindow,Vt as interpolate,xt as interval,be as isBrowserWindow,pt as isHigher,lt as isHigherOrEqual,Lt as isIntersecting,$ as isInvariantQuality,q as isLower,ut as isLowerOrEqual,g as isNonNullable,O as isNullable,In as isValidURL,Ri as loadVKLangPack,_ as map,we as mapTo,Ie as merge,S as noop,Ze as now,Et as observableFrom,Nt as observeElementSize,Se as once,Ae as pairwise,fe as safeStorage,Ne as shareReplay,ke as skip,Pe as tap,ve as throttle,Y as throttleFn,Ar as timeCodeToString,vt as timeout,dt as videoHeightToQuality,ft as videoQualityToHeight,bt as videoSizeToQuality,B as withoutNullable};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vkontakte/videoplayer-shared",
3
- "version": "1.0.82-dev.44065e09.0",
3
+ "version": "1.0.82-dev.4dbe88bb.0",
4
4
  "author": "vk.com",
5
5
  "description": "Shared code for vk.com videoplayer",
6
6
  "homepage": "https://vk.com",
@@ -54,8 +54,9 @@
54
54
  "**/*.d.ts"
55
55
  ],
56
56
  "dependencies": {
57
+ "@apptracer/opentelemetry": "1.1.8",
58
+ "@apptracer/sdk": "^2.6.3",
57
59
  "@opentelemetry/api": "^1.8.0",
58
- "@opentelemetry/sdk-trace-web": "^1.24.1",
59
- "@apptracer/opentelemetry": "1.1.8"
60
+ "@opentelemetry/sdk-trace-web": "^1.24.1"
60
61
  }
61
62
  }
@@ -0,0 +1,25 @@
1
+ import { ISubscription } from '../reactive';
2
+ import type { ITracerError, ITracerErrorData } from '@apptracer/sdk/lite';
3
+ import type { AppTracerSdk, IAppTracerContext, IAppTracerEnvParams, IAppTracerOptions, IComponentName } from './types';
4
+ import { IError } from '../types';
5
+ export declare class AppTracer {
6
+ protected static readonly tracerErrorMap: Map<IComponentName, ITracerError>;
7
+ protected static appTracerModule: typeof AppTracerSdk | null;
8
+ protected static loadPromise: Promise<unknown> | null;
9
+ private readonly dynamicImportTimeout;
10
+ private readonly componentName;
11
+ private readonly subscription;
12
+ private readonly options;
13
+ private readonly envParams;
14
+ private readonly context?;
15
+ /**
16
+ * на каждый `componentName` создаётся 1 уникальный экземпляр трейсера.
17
+ * пересоздать его уже будет нельзя
18
+ */
19
+ constructor(componentName: IComponentName, options: IAppTracerOptions, envParams: IAppTracerEnvParams, context?: IAppTracerContext);
20
+ error(error: IError, errorData?: Partial<Pick<ITracerErrorData, 'severity'>>): void;
21
+ addSubscription(item: Parameters<ISubscription['add']>[0]): void;
22
+ destroy(): void;
23
+ private init;
24
+ private loadModule;
25
+ }
@@ -0,0 +1 @@
1
+ export declare const APP_TOKEN = "gW5EerTD5QhAnsbpF7Hd2NSMRteYIUUMjFbSyI68Pf5";
@@ -0,0 +1,2 @@
1
+ export { AppTracer } from './AppTracer';
2
+ export type { IAppTracerOptions, IAppTracerEnvParams, IAppTracerContext } from './types';
@@ -0,0 +1,19 @@
1
+ import { ErrorCategory } from '../types';
2
+ import type * as AppTracerSdk from '@apptracer/sdk/lite';
3
+ import type { ITracerError, ITracerErrorData, ITracerUploaderConfig } from '@apptracer/sdk/lite';
4
+ export { AppTracerSdk };
5
+ export type IComponentName = string & {};
6
+ export interface IAppTracerOptions {
7
+ enabled: boolean;
8
+ sampleRate: number;
9
+ whiteErrorCategoryList: ErrorCategory[];
10
+ blackErrorCategoryList: ErrorCategory[];
11
+ whiteErrorIdList: string[];
12
+ blackErrorIdList: string[];
13
+ }
14
+ export interface IAppTracerEnvParams {
15
+ version: ITracerUploaderConfig['versionName'];
16
+ env: ITracerUploaderConfig['environment'];
17
+ }
18
+ export type IAppTracerContext = Parameters<ITracerError['setErrorKeys']>[0];
19
+ export type IAppTracerErrorDataKeys = ITracerErrorData['keys'];
@@ -0,0 +1,4 @@
1
+ import { IError } from '../types';
2
+ import type { IAppTracerErrorDataKeys } from './types';
3
+ export declare const mapIErrorToAppTracerErrorKeys: (error: IError) => IAppTracerErrorDataKeys;
4
+ export declare const mapIErrorThrownToError: (error: IError) => Error;
package/types/index.d.ts CHANGED
@@ -8,3 +8,4 @@ export * from './translation';
8
8
  export * from './InternalsExposure';
9
9
  export * as devNull from './devNull';
10
10
  export { DevNullEntry } from './devNull';
11
+ export * from './AppTracer';