@vkontakte/videoplayer-core 2.0.99-dev.49004322.0 → 2.0.99-dev.8e8ba4ac.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 +2 -2
package/es2015.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-core v2.0.99-dev.
|
|
3
|
-
* Wed, 13 Mar 2024 12:
|
|
2
|
+
* @vkontakte/videoplayer-core v2.0.99-dev.8e8ba4ac.0
|
|
3
|
+
* Wed, 13 Mar 2024 12:42:15 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/2-0-99/doc/
|
|
5
5
|
*/
|
|
6
|
-
import{ValueSubject as y,Subject as M,Subscription as ne,isNonNullable as _,ErrorCategory as O,isNullable as te,fromEvent as U,assertNever as j,merge as H,tap as Vi,map as k,observableFrom as Ce,filterChanged as me,assertNonNullable as P,debounce as Ye,getHighestQuality as _l,timeout as Pl,getCurrentBrowser as za,CurrentClientBrowser as kd,combine as Le,once as ge,mapTo as Ti,filter as X,now as le,assertNotEmptyArray as Dl,videoSizeToQuality as Qt,isInvariantQuality as zt,isHigher as Si,isLower as Is,isHigherOrEqual as ba,isLowerOrEqual as _d,Observable as zs,debounceFn as Rl,interval as Ms,VideoQuality as He,videoQualityToHeight as Il,abortable as Re,getExponentialDelay as Er,isIOS as Ll,CurrentClientDevice as Cl,safeStorage as $r,fillWithDefault as xl,Logger as Ol}from"@vkontakte/videoplayer-shared/es2015.esm.js";import{Observable as ZT,Subject as e0,Subscription as t0,ValueSubject as i0,VideoQuality as s0}from"@vkontakte/videoplayer-shared/es2015.esm.js";const Ml="2.0.99-dev.49004322.0";var p;(function(s){s.STOPPED="stopped",s.READY="ready",s.PLAYING="playing",s.PAUSED="paused"})(p||(p={}));var E;(function(s){s.MPEG="MPEG",s.DASH="DASH",s.DASH_SEP="DASH_SEP",s.DASH_SEP_VK="DASH_SEP",s.DASH_WEBM="DASH_WEBM",s.DASH_WEBM_AV1="DASH_WEBM_AV1",s.DASH_WEBM_VK="DASH_WEBM",s.DASH_ONDEMAND="DASH_ONDEMAND",s.DASH_ONDEMAND_VK="DASH_ONDEMAND",s.DASH_LIVE="DASH_LIVE",s.DASH_LIVE_CMAF="DASH_LIVE_CMAF",s.DASH_LIVE_WEBM="DASH_LIVE_WEBM",s.HLS="HLS",s.HLS_ONDEMAND="HLS_ONDEMAND",s.HLS_JS="HLS",s.HLS_LIVE="HLS_LIVE",s.HLS_LIVE_CMAF="HLS_LIVE_CMAF",s.WEB_RTC_LIVE="WEB_RTC_LIVE"})(E||(E={}));var ke;(function(s){s.SCREEN="SCREEN",s.CHROMECAST="CHROMECAST"})(ke||(ke={}));var $e;(function(s){s.NOT_AVAILABLE="NOT_AVAILABLE",s.AVAILABLE="AVAILABLE",s.CONNECTING="CONNECTING",s.CONNECTED="CONNECTED"})($e||($e={}));var Hi;(function(s){s.HTTP1="http1",s.HTTP2="http2",s.QUIC="quic"})(Hi||(Hi={}));var K;(function(s){s.None="none",s.Requested="requested",s.Applying="applying"})(K||(K={}));var _t;(function(s){s.NONE="none",s.INLINE="inline",s.FULLSCREEN="fullscreen",s.SECOND_SCREEN="second_screen",s.PIP="pip"})(_t||(_t={}));function ae(s,e,t,i){function r(a){return a instanceof t?a:new t(function(n){n(a)})}return new(t||(t=Promise))(function(a,n){function o(l){try{d(i.next(l))}catch(c){n(c)}}function u(l){try{d(i.throw(l))}catch(c){n(c)}}function d(l){l.done?a(l.value):r(l.value).then(o,u)}d((i=i.apply(s,e||[])).next())})}function V(s){return this instanceof V?(this.v=s,this):new V(s)}function Ie(s,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(s,e||[]),r,a=[];return r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r;function n(h){i[h]&&(r[h]=function(f){return new Promise(function(g,m){a.push([h,f,g,m])>1||o(h,f)})})}function o(h,f){try{u(i[h](f))}catch(g){c(a[0][3],g)}}function u(h){h.value instanceof V?Promise.resolve(h.value.v).then(d,l):c(a[0][2],h)}function d(h){o("next",h)}function l(h){o("throw",h)}function c(h,f){h(f),a.shift(),a.length&&o(a[0][0],a[0][1])}}var Bl=s=>new Promise((e,t)=>{const i=document.createElement("script");i.setAttribute("src",s),i.onload=()=>e,i.onerror=()=>t,document.body.appendChild(i)});class Nl{constructor(e){var t;this.connection$=new y(void 0),this.castState$=new y($e.NOT_AVAILABLE),this.errorEvent$=new M,this.realCastState$=new y($e.NOT_AVAILABLE),this.subscription=new ne,this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastInitializer");const i="chrome"in window;if(this.log({message:`[constructor] receiverApplicationId: ${this.params.receiverApplicationId}, isDisabled: ${this.params.isDisabled}, isSupported: ${i}`}),e.isDisabled||!i)return;const r=_((t=window.chrome)===null||t===void 0?void 0:t.cast),a=!!window.__onGCastApiAvailable;r?this.initializeCastApi():(window.__onGCastApiAvailable=n=>{delete window.__onGCastApiAvailable,n&&this.initializeCastApi()},a||Bl("https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1").catch(()=>this.errorEvent$.next({id:"ChromecastLoading",category:O.NETWORK,message:"Script loading failed!"})))}connect(){var e;(e=cast.framework.CastContext.getInstance())===null||e===void 0||e.requestSession()}disconnect(){var e,t;(t=(e=cast.framework.CastContext.getInstance())===null||e===void 0?void 0:e.getCurrentSession())===null||t===void 0||t.endSession(!0)}stopMedia(){return new Promise((e,t)=>{var i,r,a;(a=(r=(i=cast.framework.CastContext.getInstance())===null||i===void 0?void 0:i.getCurrentSession())===null||r===void 0?void 0:r.getMediaSession())===null||a===void 0||a.stop(new chrome.cast.media.StopRequest,e,t)})}toggleConnection(){_(this.connection$.getValue())?this.disconnect():this.connect()}setVolume(e){const t=this.connection$.getValue();te(t)||(t.remotePlayer.volumeLevel=e,t.remotePlayerController.setVolumeLevel())}setMuted(e){const t=this.connection$.getValue();te(t)||e!==t.remotePlayer.isMuted&&t.remotePlayerController.muteOrUnmute()}destroy(){this.subscription.unsubscribe()}initListeners(){const e=new cast.framework.RemotePlayer,t=new cast.framework.RemotePlayerController(e),i=cast.framework.CastContext.getInstance();this.subscription.add(U(i,cast.framework.CastContextEventType.SESSION_STATE_CHANGED).subscribe(r=>{var a,n;switch(r.sessionState){case cast.framework.SessionState.SESSION_STARTED:case cast.framework.SessionState.SESSION_STARTING:case cast.framework.SessionState.SESSION_RESUMED:this.contentId=(n=(a=i.getCurrentSession())===null||a===void 0?void 0:a.getMediaSession())===null||n===void 0?void 0:n.media.contentId;break;case cast.framework.SessionState.NO_SESSION:case cast.framework.SessionState.SESSION_ENDING:case cast.framework.SessionState.SESSION_ENDED:case cast.framework.SessionState.SESSION_START_FAILED:this.contentId=void 0;break;default:return j(r.sessionState)}})).add(H(U(i,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe(Vi(r=>{this.log({message:`[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: ${JSON.stringify(r)}`})}),k(r=>r.castState)),Ce([i.getCastState()])).pipe(me(),k(Fl),Vi(r=>{this.log({message:`realCastState$: ${r}`})})).subscribe(this.realCastState$)).add(this.realCastState$.subscribe(r=>{var a;const n=r===$e.CONNECTED,o=_(this.connection$.getValue());if(n&&!o){const u=i.getCurrentSession();P(u);const d=u.getCastDevice(),l=(a=u.getMediaSession())===null||a===void 0?void 0:a.media.contentId;(te(l)||l===this.contentId)&&(this.log({message:"connection created"}),this.connection$.next({remotePlayer:e,remotePlayerController:t,session:u,castDevice:d}))}else!n&&o&&(this.log({message:"connection destroyed"}),this.connection$.next(void 0));this.castState$.next(r===$e.CONNECTED?_(this.connection$.getValue())?$e.CONNECTED:$e.AVAILABLE:r)}))}initializeCastApi(){var e;let t,i,r;try{t=cast.framework.CastContext.getInstance(),i=chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,r=chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}catch(a){return}try{t.setOptions({receiverApplicationId:(e=this.params.receiverApplicationId)!==null&&e!==void 0?e:i,autoJoinPolicy:r}),this.initListeners()}catch(a){this.errorEvent$.next({id:"ChromecastInitializer",category:O.EXTERNAL_API,message:"[initializeCastApi] failed",thrown:a})}}}const Fl=s=>{switch(s){case cast.framework.CastState.NO_DEVICES_AVAILABLE:return $e.NOT_AVAILABLE;case cast.framework.CastState.NOT_CONNECTED:return $e.AVAILABLE;case cast.framework.CastState.CONNECTING:return $e.CONNECTING;case cast.framework.CastState.CONNECTED:return $e.CONNECTED;default:return j(s)}};var Ar=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Ws(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var qe=function(s){try{return!!s()}catch(e){return!0}},Ul=qe,Qs=!Ul(function(){var s=function(){}.bind();return typeof s!="function"||s.hasOwnProperty("prototype")}),Pd=Qs,Dd=Function.prototype,ya=Dd.call,Vl=Pd&&Dd.bind.bind(ya,ya),ze=Pd?Vl:function(s){return function(){return ya.apply(s,arguments)}},Rd=ze,Hl=Rd({}.toString),Gl=Rd("".slice),zi=function(s){return Gl(Hl(s),8,-1)},jl=ze,Yl=qe,ql=zi,wr=Object,zl=jl("".split),Wl=Yl(function(){return!wr("z").propertyIsEnumerable(0)})?function(s){return ql(s)=="String"?zl(s,""):wr(s)}:wr,Wi=function(s){return s==null},Ql=Wi,Kl=TypeError,Wa=function(s){if(Ql(s))throw Kl("Can't call method on "+s);return s},Jl=Wl,Xl=Wa,Qi=function(s){return Jl(Xl(s))},ki={},us=function(s){return s&&s.Math==Math&&s},we=us(typeof globalThis=="object"&&globalThis)||us(typeof window=="object"&&window)||us(typeof self=="object"&&self)||us(typeof Ar=="object"&&Ar)||function(){return this}()||Ar||Function("return this")(),Ta=typeof document=="object"&&document.all,Zl=typeof Ta=="undefined"&&Ta!==void 0,Id={all:Ta,IS_HTMLDDA:Zl},Ld=Id,ec=Ld.all,Ee=Ld.IS_HTMLDDA?function(s){return typeof s=="function"||s===ec}:function(s){return typeof s=="function"},tc=we,ic=Ee,xn=tc.WeakMap,sc=ic(xn)&&/native code/.test(String(xn)),On=Ee,Cd=Id,rc=Cd.all,vt=Cd.IS_HTMLDDA?function(s){return typeof s=="object"?s!==null:On(s)||s===rc}:function(s){return typeof s=="object"?s!==null:On(s)},ac=qe,Lt=!ac(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),Kt={},nc=we,Mn=vt,Ea=nc.document,oc=Mn(Ea)&&Mn(Ea.createElement),Qa=function(s){return oc?Ea.createElement(s):{}},dc=Lt,uc=qe,lc=Qa,xd=!dc&&!uc(function(){return Object.defineProperty(lc("div"),"a",{get:function(){return 7}}).a!=7}),cc=Lt,hc=qe,Od=cc&&hc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),fc=vt,pc=String,mc=TypeError,gt=function(s){if(fc(s))return s;throw mc(pc(s)+" is not an object")},vc=Qs,ls=Function.prototype.call,Fe=vc?ls.bind(ls):function(){return ls.apply(ls,arguments)},Ka={},kr=Ka,_r=we,gc=Ee,Bn=function(s){return gc(s)?s:void 0},Jt=function(s,e){return arguments.length<2?Bn(kr[s])||Bn(_r[s]):kr[s]&&kr[s][e]||_r[s]&&_r[s][e]},Sc=ze,Ks=Sc({}.isPrototypeOf),Js=typeof navigator!="undefined"&&String(navigator.userAgent)||"",Md=we,Pr=Js,Nn=Md.process,Fn=Md.Deno,Un=Nn&&Nn.versions||Fn&&Fn.version,Vn=Un&&Un.v8,Je,Bs;Vn&&(Je=Vn.split("."),Bs=Je[0]>0&&Je[0]<4?1:+(Je[0]+Je[1]));!Bs&&Pr&&(Je=Pr.match(/Edge\/(\d+)/),(!Je||Je[1]>=74)&&(Je=Pr.match(/Chrome\/(\d+)/),Je&&(Bs=+Je[1])));var Bd=Bs,Hn=Bd,bc=qe,yc=we,Tc=yc.String,Nd=!!Object.getOwnPropertySymbols&&!bc(function(){var s=Symbol();return!Tc(s)||!(Object(s)instanceof Symbol)||!Symbol.sham&&Hn&&Hn<41}),Ec=Nd,Fd=Ec&&!Symbol.sham&&typeof Symbol.iterator=="symbol",$c=Jt,Ac=Ee,wc=Ks,kc=Fd,_c=Object,Ud=kc?function(s){return typeof s=="symbol"}:function(s){var e=$c("Symbol");return Ac(e)&&wc(e.prototype,_c(s))},Pc=String,Xs=function(s){try{return Pc(s)}catch(e){return"Object"}},Dc=Ee,Rc=Xs,Ic=TypeError,Xt=function(s){if(Dc(s))return s;throw Ic(Rc(s)+" is not a function")},Lc=Xt,Cc=Wi,Zs=function(s,e){var t=s[e];return Cc(t)?void 0:Lc(t)},Dr=Fe,Rr=Ee,Ir=vt,xc=TypeError,Oc=function(s,e){var t,i;if(e==="string"&&Rr(t=s.toString)&&!Ir(i=Dr(t,s))||Rr(t=s.valueOf)&&!Ir(i=Dr(t,s))||e!=="string"&&Rr(t=s.toString)&&!Ir(i=Dr(t,s)))return i;throw xc("Can't convert object to primitive value")},Vd={exports:{}},Mc=!0,Gn=we,Bc=Object.defineProperty,Nc=function(s,e){try{Bc(Gn,s,{value:e,configurable:!0,writable:!0})}catch(t){Gn[s]=e}return e},Fc=we,Uc=Nc,jn="__core-js_shared__",Vc=Fc[jn]||Uc(jn,{}),Ja=Vc,Yn=Ja;(Vd.exports=function(s,e){return Yn[s]||(Yn[s]=e!==void 0?e:{})})("versions",[]).push({version:"3.31.0",mode:"pure",copyright:"\xA9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.31.0/LICENSE",source:"https://github.com/zloirock/core-js"});var Hd=Vd.exports,Hc=Wa,Gc=Object,er=function(s){return Gc(Hc(s))},jc=ze,Yc=er,qc=jc({}.hasOwnProperty),ut=Object.hasOwn||function(e,t){return qc(Yc(e),t)},zc=ze,Wc=0,Qc=Math.random(),Kc=zc(1 .toString),Gd=function(s){return"Symbol("+(s===void 0?"":s)+")_"+Kc(++Wc+Qc,36)},Jc=we,Xc=Hd,qn=ut,Zc=Gd,eh=Nd,th=Fd,pi=Jc.Symbol,Lr=Xc("wks"),ih=th?pi.for||pi:pi&&pi.withoutSetter||Zc,Pe=function(s){return qn(Lr,s)||(Lr[s]=eh&&qn(pi,s)?pi[s]:ih("Symbol."+s)),Lr[s]},sh=Fe,zn=vt,Wn=Ud,rh=Zs,ah=Oc,nh=Pe,oh=TypeError,dh=nh("toPrimitive"),uh=function(s,e){if(!zn(s)||Wn(s))return s;var t=rh(s,dh),i;if(t){if(e===void 0&&(e="default"),i=sh(t,s,e),!zn(i)||Wn(i))return i;throw oh("Can't convert object to primitive value")}return e===void 0&&(e="number"),ah(s,e)},lh=uh,ch=Ud,Xa=function(s){var e=lh(s,"string");return ch(e)?e:e+""},hh=Lt,fh=xd,ph=Od,cs=gt,Qn=Xa,mh=TypeError,Cr=Object.defineProperty,vh=Object.getOwnPropertyDescriptor,xr="enumerable",Or="configurable",Mr="writable";Kt.f=hh?ph?function(e,t,i){if(cs(e),t=Qn(t),cs(i),typeof e=="function"&&t==="prototype"&&"value"in i&&Mr in i&&!i[Mr]){var r=vh(e,t);r&&r[Mr]&&(e[t]=i.value,i={configurable:Or in i?i[Or]:r[Or],enumerable:xr in i?i[xr]:r[xr],writable:!1})}return Cr(e,t,i)}:Cr:function(e,t,i){if(cs(e),t=Qn(t),cs(i),fh)try{return Cr(e,t,i)}catch(r){}if("get"in i||"set"in i)throw mh("Accessors not supported");return"value"in i&&(e[t]=i.value),e};var tr=function(s,e){return{enumerable:!(s&1),configurable:!(s&2),writable:!(s&4),value:e}},gh=Lt,Sh=Kt,bh=tr,Ki=gh?function(s,e,t){return Sh.f(s,e,bh(1,t))}:function(s,e,t){return s[e]=t,s},yh=Hd,Th=Gd,Kn=yh("keys"),Za=function(s){return Kn[s]||(Kn[s]=Th(s))},en={},Eh=sc,jd=we,$h=vt,Ah=Ki,Br=ut,Nr=Ja,wh=Za,kh=en,Jn="Object already initialized",$a=jd.TypeError,_h=jd.WeakMap,Ns,Gi,Fs,Ph=function(s){return Fs(s)?Gi(s):Ns(s,{})},Dh=function(s){return function(e){var t;if(!$h(e)||(t=Gi(e)).type!==s)throw $a("Incompatible receiver, "+s+" required");return t}};if(Eh||Nr.state){var st=Nr.state||(Nr.state=new _h);st.get=st.get,st.has=st.has,st.set=st.set,Ns=function(s,e){if(st.has(s))throw $a(Jn);return e.facade=s,st.set(s,e),e},Gi=function(s){return st.get(s)||{}},Fs=function(s){return st.has(s)}}else{var ni=wh("state");kh[ni]=!0,Ns=function(s,e){if(Br(s,ni))throw $a(Jn);return e.facade=s,Ah(s,ni,e),e},Gi=function(s){return Br(s,ni)?s[ni]:{}},Fs=function(s){return Br(s,ni)}}var Yd={set:Ns,get:Gi,has:Fs,enforce:Ph,getterFor:Dh},Rh=Qs,qd=Function.prototype,Xn=qd.apply,Zn=qd.call,zd=typeof Reflect=="object"&&Reflect.apply||(Rh?Zn.bind(Xn):function(){return Zn.apply(Xn,arguments)}),Ih=zi,Lh=ze,Wd=function(s){if(Ih(s)==="Function")return Lh(s)},tn={},Qd={},Kd={}.propertyIsEnumerable,Jd=Object.getOwnPropertyDescriptor,Ch=Jd&&!Kd.call({1:2},1);Qd.f=Ch?function(e){var t=Jd(this,e);return!!t&&t.enumerable}:Kd;var xh=Lt,Oh=Fe,Mh=Qd,Bh=tr,Nh=Qi,Fh=Xa,Uh=ut,Vh=xd,eo=Object.getOwnPropertyDescriptor;tn.f=xh?eo:function(e,t){if(e=Nh(e),t=Fh(t),Vh)try{return eo(e,t)}catch(i){}if(Uh(e,t))return Bh(!Oh(Mh.f,e,t),e[t])};var Hh=qe,Gh=Ee,jh=/#|\.prototype\./,Ji=function(s,e){var t=qh[Yh(s)];return t==Wh?!0:t==zh?!1:Gh(e)?Hh(e):!!e},Yh=Ji.normalize=function(s){return String(s).replace(jh,".").toLowerCase()},qh=Ji.data={},zh=Ji.NATIVE="N",Wh=Ji.POLYFILL="P",Xd=Ji,to=Wd,Qh=Xt,Kh=Qs,Jh=to(to.bind),ir=function(s,e){return Qh(s),e===void 0?s:Kh?Jh(s,e):function(){return s.apply(e,arguments)}},hs=we,Xh=zd,Zh=Wd,ef=Ee,tf=tn.f,sf=Xd,oi=Ka,rf=ir,di=Ki,io=ut,af=function(s){var e=function(t,i,r){if(this instanceof e){switch(arguments.length){case 0:return new s;case 1:return new s(t);case 2:return new s(t,i)}return new s(t,i,r)}return Xh(s,this,arguments)};return e.prototype=s.prototype,e},et=function(s,e){var t=s.target,i=s.global,r=s.stat,a=s.proto,n=i?hs:r?hs[t]:(hs[t]||{}).prototype,o=i?oi:oi[t]||di(oi,t,{})[t],u=o.prototype,d,l,c,h,f,g,m,S,b;for(h in e)d=sf(i?h:t+(r?".":"#")+h,s.forced),l=!d&&n&&io(n,h),g=o[h],l&&(s.dontCallGetSet?(b=tf(n,h),m=b&&b.value):m=n[h]),f=l&&m?m:e[h],!(l&&typeof g==typeof f)&&(s.bind&&l?S=rf(f,hs):s.wrap&&l?S=af(f):a&&ef(f)?S=Zh(f):S=f,(s.sham||f&&f.sham||g&&g.sham)&&di(S,"sham",!0),di(o,h,S),a&&(c=t+"Prototype",io(oi,c)||di(oi,c,{}),di(oi[c],h,f),s.real&&u&&(d||!u[h])&&di(u,h,f)))},Aa=Lt,nf=ut,Zd=Function.prototype,of=Aa&&Object.getOwnPropertyDescriptor,sn=nf(Zd,"name"),df=sn&&function(){}.name==="something",uf=sn&&(!Aa||Aa&&of(Zd,"name").configurable),lf={EXISTS:sn,PROPER:df,CONFIGURABLE:uf},eu={},cf=Math.ceil,hf=Math.floor,ff=Math.trunc||function(e){var t=+e;return(t>0?hf:cf)(t)},pf=ff,rn=function(s){var e=+s;return e!==e||e===0?0:pf(e)},mf=rn,vf=Math.max,gf=Math.min,Sf=function(s,e){var t=mf(s);return t<0?vf(t+e,0):gf(t,e)},bf=rn,yf=Math.min,Tf=function(s){return s>0?yf(bf(s),9007199254740991):0},Ef=Tf,an=function(s){return Ef(s.length)},$f=Qi,Af=Sf,wf=an,so=function(s){return function(e,t,i){var r=$f(e),a=wf(r),n=Af(i,a),o;if(s&&t!=t){for(;a>n;)if(o=r[n++],o!=o)return!0}else for(;a>n;n++)if((s||n in r)&&r[n]===t)return s||n||0;return!s&&-1}},kf={includes:so(!0),indexOf:so(!1)},_f=ze,Fr=ut,Pf=Qi,Df=kf.indexOf,Rf=en,ro=_f([].push),If=function(s,e){var t=Pf(s),i=0,r=[],a;for(a in t)!Fr(Rf,a)&&Fr(t,a)&&ro(r,a);for(;e.length>i;)Fr(t,a=e[i++])&&(~Df(r,a)||ro(r,a));return r},tu=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Lf=If,Cf=tu,xf=Object.keys||function(e){return Lf(e,Cf)},Of=Lt,Mf=Od,Bf=Kt,Nf=gt,Ff=Qi,Uf=xf;eu.f=Of&&!Mf?Object.defineProperties:function(e,t){Nf(e);for(var i=Ff(t),r=Uf(t),a=r.length,n=0,o;a>n;)Bf.f(e,o=r[n++],i[o]);return e};var Vf=Jt,iu=Vf("document","documentElement"),Hf=gt,Gf=eu,ao=tu,jf=en,Yf=iu,qf=Qa,zf=Za,no=">",oo="<",wa="prototype",ka="script",su=zf("IE_PROTO"),Ur=function(){},ru=function(s){return oo+ka+no+s+oo+"/"+ka+no},uo=function(s){s.write(ru("")),s.close();var e=s.parentWindow.Object;return s=null,e},Wf=function(){var s=qf("iframe"),e="java"+ka+":",t;return s.style.display="none",Yf.appendChild(s),s.src=String(e),t=s.contentWindow.document,t.open(),t.write(ru("document.F=Object")),t.close(),t.F},fs,Ls=function(){try{fs=new ActiveXObject("htmlfile")}catch(e){}Ls=typeof document!="undefined"?document.domain&&fs?uo(fs):Wf():uo(fs);for(var s=ao.length;s--;)delete Ls[wa][ao[s]];return Ls()};jf[su]=!0;var au=Object.create||function(e,t){var i;return e!==null?(Ur[wa]=Hf(e),i=new Ur,Ur[wa]=null,i[su]=e):i=Ls(),t===void 0?i:Gf.f(i,t)},Qf=qe,Kf=!Qf(function(){function s(){}return s.prototype.constructor=null,Object.getPrototypeOf(new s)!==s.prototype}),Jf=ut,Xf=Ee,Zf=er,ep=Za,tp=Kf,lo=ep("IE_PROTO"),_a=Object,ip=_a.prototype,nu=tp?_a.getPrototypeOf:function(s){var e=Zf(s);if(Jf(e,lo))return e[lo];var t=e.constructor;return Xf(t)&&e instanceof t?t.prototype:e instanceof _a?ip:null},sp=Ki,nn=function(s,e,t,i){return i&&i.enumerable?s[e]=t:sp(s,e,t),s},rp=qe,ap=Ee,np=vt,op=au,co=nu,dp=nn,up=Pe,Pa=up("iterator"),ou=!1,ft,Vr,Hr;[].keys&&(Hr=[].keys(),"next"in Hr?(Vr=co(co(Hr)),Vr!==Object.prototype&&(ft=Vr)):ou=!0);var lp=!np(ft)||rp(function(){var s={};return ft[Pa].call(s)!==s});lp?ft={}:ft=op(ft);ap(ft[Pa])||dp(ft,Pa,function(){return this});var du={IteratorPrototype:ft,BUGGY_SAFARI_ITERATORS:ou},cp=Pe,hp=cp("toStringTag"),uu={};uu[hp]="z";var on=String(uu)==="[object z]",fp=on,pp=Ee,Cs=zi,mp=Pe,vp=mp("toStringTag"),gp=Object,Sp=Cs(function(){return arguments}())=="Arguments",bp=function(s,e){try{return s[e]}catch(t){}},Xi=fp?Cs:function(s){var e,t,i;return s===void 0?"Undefined":s===null?"Null":typeof(t=bp(e=gp(s),vp))=="string"?t:Sp?Cs(e):(i=Cs(e))=="Object"&&pp(e.callee)?"Arguments":i},yp=on,Tp=Xi,Ep=yp?{}.toString:function(){return"[object "+Tp(this)+"]"},$p=on,Ap=Kt.f,wp=Ki,kp=ut,_p=Ep,Pp=Pe,ho=Pp("toStringTag"),dn=function(s,e,t,i){if(s){var r=t?s:s.prototype;kp(r,ho)||Ap(r,ho,{configurable:!0,value:e}),i&&!$p&&wp(r,"toString",_p)}},Dp=du.IteratorPrototype,Rp=au,Ip=tr,Lp=dn,Cp=ki,xp=function(){return this},Op=function(s,e,t,i){var r=e+" Iterator";return s.prototype=Rp(Dp,{next:Ip(+!i,t)}),Lp(s,r,!1,!0),Cp[r]=xp,s},Mp=et,Bp=Fe,lu=lf,Np=Op,Fp=nu,Up=dn,fo=nn,Vp=Pe,po=ki,cu=du,Hp=lu.PROPER;lu.CONFIGURABLE;cu.IteratorPrototype;var ps=cu.BUGGY_SAFARI_ITERATORS,Gr=Vp("iterator"),mo="keys",ms="values",vo="entries",Gp=function(){return this},jp=function(s,e,t,i,r,a,n){Np(t,e,i);var o=function(b){if(b===r&&h)return h;if(!ps&&b in l)return l[b];switch(b){case mo:return function(){return new t(this,b)};case ms:return function(){return new t(this,b)};case vo:return function(){return new t(this,b)}}return function(){return new t(this)}},u=e+" Iterator",d=!1,l=s.prototype,c=l[Gr]||l["@@iterator"]||r&&l[r],h=!ps&&c||o(r),f=e=="Array"&&l.entries||c,g,m,S;if(f&&(g=Fp(f.call(new s)),g!==Object.prototype&&g.next&&(Up(g,u,!0,!0),po[u]=Gp)),Hp&&r==ms&&c&&c.name!==ms&&(d=!0,h=function(){return Bp(c,this)}),r)if(m={values:o(ms),keys:a?h:o(mo),entries:o(vo)},n)for(S in m)(ps||d||!(S in l))&&fo(l,S,m[S]);else Mp({target:e,proto:!0,forced:ps||d},m);return n&&l[Gr]!==h&&fo(l,Gr,h,{name:r}),po[e]=h,m},Yp=function(s,e){return{value:s,done:e}},qp=Qi,go=ki,hu=Yd;Kt.f;var zp=jp,vs=Yp,fu="Array Iterator",Wp=hu.set,Qp=hu.getterFor(fu);zp(Array,"Array",function(s,e){Wp(this,{type:fu,target:qp(s),index:0,kind:e})},function(){var s=Qp(this),e=s.target,t=s.kind,i=s.index++;return!e||i>=e.length?(s.target=void 0,vs(void 0,!0)):t=="keys"?vs(i,!1):t=="values"?vs(e[i],!1):vs([i,e[i]],!1)},"values");go.Arguments=go.Array;var Kp=Pe,Jp=ki,Xp=Kp("iterator"),Zp=Array.prototype,em=function(s){return s!==void 0&&(Jp.Array===s||Zp[Xp]===s)},tm=Xi,So=Zs,im=Wi,sm=ki,rm=Pe,am=rm("iterator"),pu=function(s){if(!im(s))return So(s,am)||So(s,"@@iterator")||sm[tm(s)]},nm=Fe,om=Xt,dm=gt,um=Xs,lm=pu,cm=TypeError,hm=function(s,e){var t=arguments.length<2?lm(s):e;if(om(t))return dm(nm(t,s));throw cm(um(s)+" is not iterable")},fm=Fe,bo=gt,pm=Zs,mm=function(s,e,t){var i,r;bo(s);try{if(i=pm(s,"return"),!i){if(e==="throw")throw t;return t}i=fm(i,s)}catch(a){r=!0,i=a}if(e==="throw")throw t;if(r)throw i;return bo(i),t},vm=ir,gm=Fe,Sm=gt,bm=Xs,ym=em,Tm=an,yo=Ks,Em=hm,$m=pu,To=mm,Am=TypeError,xs=function(s,e){this.stopped=s,this.result=e},Eo=xs.prototype,un=function(s,e,t){var i=t&&t.that,r=!!(t&&t.AS_ENTRIES),a=!!(t&&t.IS_RECORD),n=!!(t&&t.IS_ITERATOR),o=!!(t&&t.INTERRUPTED),u=vm(e,i),d,l,c,h,f,g,m,S=function(A){return d&&To(d,"normal",A),new xs(!0,A)},b=function(A){return r?(Sm(A),o?u(A[0],A[1],S):u(A[0],A[1])):o?u(A,S):u(A)};if(a)d=s.iterator;else if(n)d=s;else{if(l=$m(s),!l)throw Am(bm(s)+" is not iterable");if(ym(l)){for(c=0,h=Tm(s);h>c;c++)if(f=b(s[c]),f&&yo(Eo,f))return f;return new xs(!1)}d=Em(s,l)}for(g=a?s.next:d.next;!(m=gm(g,d)).done;){try{f=b(m.value)}catch(A){To(d,"throw",A)}if(typeof f=="object"&&f&&yo(Eo,f))return f}return new xs(!1)},wm=Xa,km=Kt,_m=tr,Pm=function(s,e,t){var i=wm(e);i in s?km.f(s,i,_m(0,t)):s[i]=t},Dm=et,Rm=un,Im=Pm;Dm({target:"Object",stat:!0},{fromEntries:function(e){var t={};return Rm(e,function(i,r){Im(t,i,r)},{AS_ENTRIES:!0}),t}});var Lm=Ka,Cm=Lm.Object.fromEntries,xm={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},Om=xm,Mm=we,Bm=Xi,Nm=Ki,$o=ki,Fm=Pe,Ao=Fm("toStringTag");for(var jr in Om){var wo=Mm[jr],Yr=wo&&wo.prototype;Yr&&Bm(Yr)!==Ao&&Nm(Yr,Ao,jr),$o[jr]=$o.Array}var Um=Cm,Vm=Um,Hm=Vm,Gm=Hm,Ei=Ws(Gm),jm=zi,sr=typeof process!="undefined"&&jm(process)=="process",Ym=Kt,qm=function(s,e,t){return Ym.f(s,e,t)},zm=Jt,Wm=qm,Qm=Pe,Km=Lt,ko=Qm("species"),Jm=function(s){var e=zm(s);Km&&e&&!e[ko]&&Wm(e,ko,{configurable:!0,get:function(){return this}})},Xm=Ks,Zm=TypeError,ev=function(s,e){if(Xm(e,s))return s;throw Zm("Incorrect invocation")},tv=ze,iv=Ee,Da=Ja,sv=tv(Function.toString);iv(Da.inspectSource)||(Da.inspectSource=function(s){return sv(s)});var mu=Da.inspectSource,rv=ze,av=qe,vu=Ee,nv=Xi,ov=Jt,dv=mu,gu=function(){},uv=[],Su=ov("Reflect","construct"),ln=/^\s*(?:class|function)\b/,lv=rv(ln.exec),cv=!ln.exec(gu),Li=function(e){if(!vu(e))return!1;try{return Su(gu,uv,e),!0}catch(t){return!1}},bu=function(e){if(!vu(e))return!1;switch(nv(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return cv||!!lv(ln,dv(e))}catch(t){return!0}};bu.sham=!0;var hv=!Su||av(function(){var s;return Li(Li.call)||!Li(Object)||!Li(function(){s=!0})||s})?bu:Li,fv=hv,pv=Xs,mv=TypeError,vv=function(s){if(fv(s))return s;throw mv(pv(s)+" is not a constructor")},_o=gt,gv=vv,Sv=Wi,bv=Pe,yv=bv("species"),yu=function(s,e){var t=_o(s).constructor,i;return t===void 0||Sv(i=_o(t)[yv])?e:gv(i)},Tv=ze,Ev=Tv([].slice),$v=TypeError,Av=function(s,e){if(s<e)throw $v("Not enough arguments");return s},wv=Js,Tu=/(?:ipad|iphone|ipod).*applewebkit/i.test(wv),Ne=we,kv=zd,_v=ir,Po=Ee,Pv=ut,Eu=qe,Do=iu,Dv=Ev,Ro=Qa,Rv=Av,Iv=Tu,Lv=sr,Ra=Ne.setImmediate,Ia=Ne.clearImmediate,Cv=Ne.process,qr=Ne.Dispatch,xv=Ne.Function,Io=Ne.MessageChannel,Ov=Ne.String,zr=0,Ni={},Lo="onreadystatechange",ji,Ht,Wr,Qr;Eu(function(){ji=Ne.location});var cn=function(s){if(Pv(Ni,s)){var e=Ni[s];delete Ni[s],e()}},Kr=function(s){return function(){cn(s)}},Co=function(s){cn(s.data)},xo=function(s){Ne.postMessage(Ov(s),ji.protocol+"//"+ji.host)};(!Ra||!Ia)&&(Ra=function(e){Rv(arguments.length,1);var t=Po(e)?e:xv(e),i=Dv(arguments,1);return Ni[++zr]=function(){kv(t,void 0,i)},Ht(zr),zr},Ia=function(e){delete Ni[e]},Lv?Ht=function(s){Cv.nextTick(Kr(s))}:qr&&qr.now?Ht=function(s){qr.now(Kr(s))}:Io&&!Iv?(Wr=new Io,Qr=Wr.port2,Wr.port1.onmessage=Co,Ht=_v(Qr.postMessage,Qr)):Ne.addEventListener&&Po(Ne.postMessage)&&!Ne.importScripts&&ji&&ji.protocol!=="file:"&&!Eu(xo)?(Ht=xo,Ne.addEventListener("message",Co,!1)):Lo in Ro("script")?Ht=function(s){Do.appendChild(Ro("script"))[Lo]=function(){Do.removeChild(this),cn(s)}}:Ht=function(s){setTimeout(Kr(s),0)});var $u={set:Ra,clear:Ia},Au=function(){this.head=null,this.tail=null};Au.prototype={add:function(s){var e={item:s,next:null},t=this.tail;t?t.next=e:this.head=e,this.tail=e},get:function(){var s=this.head;if(s){var e=this.head=s.next;return e===null&&(this.tail=null),s.item}}};var wu=Au,Mv=Js,Bv=/ipad|iphone|ipod/i.test(Mv)&&typeof Pebble!="undefined",Nv=Js,Fv=/web0s(?!.*chrome)/i.test(Nv),Wt=we,Oo=ir,Uv=tn.f,Jr=$u.set,Vv=wu,Hv=Tu,Gv=Bv,jv=Fv,Xr=sr,Mo=Wt.MutationObserver||Wt.WebKitMutationObserver,Bo=Wt.document,No=Wt.process,gs=Wt.Promise,Fo=Uv(Wt,"queueMicrotask"),La=Fo&&Fo.value,ui,Zr,ea,Ss,Uo;if(!La){var bs=new Vv,ys=function(){var s,e;for(Xr&&(s=No.domain)&&s.exit();e=bs.get();)try{e()}catch(t){throw bs.head&&ui(),t}s&&s.enter()};!Hv&&!Xr&&!jv&&Mo&&Bo?(Zr=!0,ea=Bo.createTextNode(""),new Mo(ys).observe(ea,{characterData:!0}),ui=function(){ea.data=Zr=!Zr}):!Gv&&gs&&gs.resolve?(Ss=gs.resolve(void 0),Ss.constructor=gs,Uo=Oo(Ss.then,Ss),ui=function(){Uo(ys)}):Xr?ui=function(){No.nextTick(ys)}:(Jr=Oo(Jr,Wt),ui=function(){Jr(ys)}),La=function(s){bs.head||ui(),bs.add(s)}}var Yv=La,qv=function(s,e){try{arguments.length==1?console.error(s):console.error(s,e)}catch(t){}},hn=function(s){try{return{error:!1,value:s()}}catch(e){return{error:!0,value:e}}},zv=we,_i=zv.Promise,ku=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",Wv=ku,Qv=sr,Kv=!Wv&&!Qv&&typeof window=="object"&&typeof document=="object",Jv=we,Fi=_i,Xv=Ee,Zv=Xd,eg=mu,tg=Pe,ig=Kv,sg=ku,ta=Bd,Vo=Fi&&Fi.prototype,rg=tg("species"),Ca=!1,_u=Xv(Jv.PromiseRejectionEvent),ag=Zv("Promise",function(){var s=eg(Fi),e=s!==String(Fi);if(!e&&ta===66||!(Vo.catch&&Vo.finally))return!0;if(!ta||ta<51||!/native code/.test(s)){var t=new Fi(function(a){a(1)}),i=function(a){a(function(){},function(){})},r=t.constructor={};if(r[rg]=i,Ca=t.then(function(){})instanceof i,!Ca)return!0}return!e&&(ig||sg)&&!_u}),Zi={CONSTRUCTOR:ag,REJECTION_EVENT:_u,SUBCLASSING:Ca},Pi={},Ho=Xt,ng=TypeError,og=function(s){var e,t;this.promise=new s(function(i,r){if(e!==void 0||t!==void 0)throw ng("Bad Promise constructor");e=i,t=r}),this.resolve=Ho(e),this.reject=Ho(t)};Pi.f=function(s){return new og(s)};var dg=et,Us=sr,It=we,es=Fe,ug=nn,lg=dn,cg=Jm,hg=Xt,xa=Ee,fg=vt,pg=ev,mg=yu,Pu=$u.set,fn=Yv,vg=qv,gg=hn,Sg=wu,Du=Yd,Oa=_i,pn=Zi,Ru=Pi,rr="Promise",Iu=pn.CONSTRUCTOR,bg=pn.REJECTION_EVENT;pn.SUBCLASSING;var ia=Du.getterFor(rr),yg=Du.set,Tg=Oa&&Oa.prototype,mi=Oa,sa=Tg,Lu=It.TypeError,Ma=It.document,mn=It.process,Ba=Ru.f,Eg=Ba,$g=!!(Ma&&Ma.createEvent&&It.dispatchEvent),Cu="unhandledrejection",Ag="rejectionhandled",Go=0,xu=1,wg=2,vn=1,Ou=2,Ts,jo,kg,Mu=function(s){var e;return fg(s)&&xa(e=s.then)?e:!1},Bu=function(s,e){var t=e.value,i=e.state==xu,r=i?s.ok:s.fail,a=s.resolve,n=s.reject,o=s.domain,u,d,l;try{r?(i||(e.rejection===Ou&&Pg(e),e.rejection=vn),r===!0?u=t:(o&&o.enter(),u=r(t),o&&(o.exit(),l=!0)),u===s.promise?n(Lu("Promise-chain cycle")):(d=Mu(u))?es(d,u,a,n):a(u)):n(t)}catch(c){o&&!l&&o.exit(),n(c)}},Nu=function(s,e){s.notified||(s.notified=!0,fn(function(){for(var t=s.reactions,i;i=t.get();)Bu(i,s);s.notified=!1,e&&!s.rejection&&_g(s)}))},Fu=function(s,e,t){var i,r;$g?(i=Ma.createEvent("Event"),i.promise=e,i.reason=t,i.initEvent(s,!1,!0),It.dispatchEvent(i)):i={promise:e,reason:t},!bg&&(r=It["on"+s])?r(i):s===Cu&&vg("Unhandled promise rejection",t)},_g=function(s){es(Pu,It,function(){var e=s.facade,t=s.value,i=Yo(s),r;if(i&&(r=gg(function(){Us?mn.emit("unhandledRejection",t,e):Fu(Cu,e,t)}),s.rejection=Us||Yo(s)?Ou:vn,r.error))throw r.value})},Yo=function(s){return s.rejection!==vn&&!s.parent},Pg=function(s){es(Pu,It,function(){var e=s.facade;Us?mn.emit("rejectionHandled",e):Fu(Ag,e,s.value)})},vi=function(s,e,t){return function(i){s(e,i,t)}},bi=function(s,e,t){s.done||(s.done=!0,t&&(s=t),s.value=e,s.state=wg,Nu(s,!0))},Na=function(s,e,t){if(!s.done){s.done=!0,t&&(s=t);try{if(s.facade===e)throw Lu("Promise can't be resolved itself");var i=Mu(e);i?fn(function(){var r={done:!1};try{es(i,e,vi(Na,r,s),vi(bi,r,s))}catch(a){bi(r,a,s)}}):(s.value=e,s.state=xu,Nu(s,!1))}catch(r){bi({done:!1},r,s)}}};Iu&&(mi=function(e){pg(this,sa),hg(e),es(Ts,this);var t=ia(this);try{e(vi(Na,t),vi(bi,t))}catch(i){bi(t,i)}},sa=mi.prototype,Ts=function(e){yg(this,{type:rr,done:!1,notified:!1,parent:!1,reactions:new Sg,rejection:!1,state:Go,value:void 0})},Ts.prototype=ug(sa,"then",function(e,t){var i=ia(this),r=Ba(mg(this,mi));return i.parent=!0,r.ok=xa(e)?e:!0,r.fail=xa(t)&&t,r.domain=Us?mn.domain:void 0,i.state==Go?i.reactions.add(r):fn(function(){Bu(r,i)}),r.promise}),jo=function(){var s=new Ts,e=ia(s);this.promise=s,this.resolve=vi(Na,e),this.reject=vi(bi,e)},Ru.f=Ba=function(s){return s===mi||s===kg?new jo(s):Eg(s)});dg({global:!0,constructor:!0,wrap:!0,forced:Iu},{Promise:mi});lg(mi,rr,!1,!0);cg(rr);var Dg=Pe,Uu=Dg("iterator"),Vu=!1;try{var Rg=0,qo={next:function(){return{done:!!Rg++}},return:function(){Vu=!0}};qo[Uu]=function(){return this},Array.from(qo,function(){throw 2})}catch(s){}var Ig=function(s,e){if(!e&&!Vu)return!1;var t=!1;try{var i={};i[Uu]=function(){return{next:function(){return{done:t=!0}}}},s(i)}catch(r){}return t},Lg=_i,Cg=Ig,xg=Zi.CONSTRUCTOR,Hu=xg||!Cg(function(s){Lg.all(s).then(void 0,function(){})}),Og=et,Mg=Fe,Bg=Xt,Ng=Pi,Fg=hn,Ug=un,Vg=Hu;Og({target:"Promise",stat:!0,forced:Vg},{all:function(e){var t=this,i=Ng.f(t),r=i.resolve,a=i.reject,n=Fg(function(){var o=Bg(t.resolve),u=[],d=0,l=1;Ug(e,function(c){var h=d++,f=!1;l++,Mg(o,t,c).then(function(g){f||(f=!0,u[h]=g,--l||r(u))},a)}),--l||r(u)});return n.error&&a(n.value),i.promise}});var Hg=et,Gg=Zi.CONSTRUCTOR,zo=_i;zo&&zo.prototype;Hg({target:"Promise",proto:!0,forced:Gg,real:!0},{catch:function(s){return this.then(void 0,s)}});var jg=et,Yg=Fe,qg=Xt,zg=Pi,Wg=hn,Qg=un,Kg=Hu;jg({target:"Promise",stat:!0,forced:Kg},{race:function(e){var t=this,i=zg.f(t),r=i.reject,a=Wg(function(){var n=qg(t.resolve);Qg(e,function(o){Yg(n,t,o).then(i.resolve,r)})});return a.error&&r(a.value),i.promise}});var Jg=et,Xg=Fe,Zg=Pi,eS=Zi.CONSTRUCTOR;Jg({target:"Promise",stat:!0,forced:eS},{reject:function(e){var t=Zg.f(this);return Xg(t.reject,void 0,e),t.promise}});var tS=gt,iS=vt,sS=Pi,Gu=function(s,e){if(tS(s),iS(e)&&e.constructor===s)return e;var t=sS.f(s),i=t.resolve;return i(e),t.promise},rS=et,aS=Jt,nS=Mc,oS=_i,dS=Zi.CONSTRUCTOR,uS=Gu,lS=aS("Promise"),cS=!dS;rS({target:"Promise",stat:!0,forced:nS},{resolve:function(e){return uS(cS&&this===lS?oS:this,e)}});var hS=et,Fa=_i,fS=qe,pS=Jt,mS=Ee,vS=yu,Wo=Gu,gS=Fa&&Fa.prototype,SS=!!Fa&&fS(function(){gS.finally.call({then:function(){}},function(){})});hS({target:"Promise",proto:!0,real:!0,forced:SS},{finally:function(s){var e=vS(this,pS("Promise")),t=mS(s);return this.then(t?function(i){return Wo(e,s()).then(function(){return i})}:s,t?function(i){return Wo(e,s()).then(function(){throw i})}:s)}});var bS=Jt,gn=bS,yS=gn,TS=yS("Promise","finally"),ES=TS,$S=ES,AS=$S,wS=AS,ar=Ws(wS),Te;(function(s){s[s.OFFSET_P=0]="OFFSET_P",s[s.PLAYBACK_SHIFT=1]="PLAYBACK_SHIFT",s[s.DASH_CMAF_OFFSET_P=2]="DASH_CMAF_OFFSET_P"})(Te||(Te={}));var Xe=(s,e=0,t=Te.OFFSET_P)=>{switch(t){case Te.OFFSET_P:return s.replace("_offset_p",e===0?"":"_"+e.toFixed(0));case Te.PLAYBACK_SHIFT:{if(e===0)return s;const i=new URL(s);return i.searchParams.append("playback_shift",e.toFixed(0)),i.toString()}case Te.DASH_CMAF_OFFSET_P:{const i=new URL(s);return!i.searchParams.get("offset_p")&&e===0?s:(i.searchParams.set("offset_p",e.toFixed(0)),i.toString())}default:j(t)}return s};const Qo=(s,e)=>{var t;switch(e){case Te.OFFSET_P:return NaN;case Te.PLAYBACK_SHIFT:{const i=new URL(s);return Number(i.searchParams.get("playback_shift"))}case Te.DASH_CMAF_OFFSET_P:{const i=new URL(s);return Number((t=i.searchParams.get("offset_p"))!==null&&t!==void 0?t:0)}default:j(e)}};var R=(s,e,t=!1)=>{const i=s.getTransition();(t||!i||i.to===e)&&s.setState(e)};class he{constructor(e){this.transitionStarted$=new M,this.transitionEnded$=new M,this.transitionUpdated$=new M,this.forceChanged$=new M,this.stateChangeStarted$=H(this.transitionStarted$,this.transitionUpdated$),this.stateChangeEnded$=H(this.transitionEnded$,this.forceChanged$),this.state=e,this.prevState=void 0}setState(e){const t=this.transition,i=this.state;this.transition=void 0,this.prevState=i,this.state=e,t?t.to===e?this.transitionEnded$.next(t):this.forceChanged$.next({from:t.from,to:e,canceledTransition:t}):this.forceChanged$.next({from:i,to:e,canceledTransition:t})}startTransitionTo(e){const t=this.transition,i=this.state;i===e||_(t)&&t.to===e||(this.prevState=i,this.state=e,t?(this.transition={from:t.from,to:e,canceledTransition:t},this.transitionUpdated$.next(this.transition)):(this.transition={from:i,to:e},this.transitionStarted$.next(this.transition)))}getTransition(){return this.transition}getState(){return this.state}getPrevState(){return this.prevState}}const kS=s=>{switch(s){case E.MPEG:case E.DASH:case E.DASH_SEP:case E.DASH_ONDEMAND:case E.DASH_WEBM:case E.DASH_WEBM_AV1:case E.HLS:case E.HLS_ONDEMAND:return!1;case E.DASH_LIVE:case E.DASH_LIVE_CMAF:case E.HLS_LIVE:case E.HLS_LIVE_CMAF:case E.DASH_LIVE_WEBM:case E.WEB_RTC_LIVE:return!0;default:return j(s)}};var z;(function(s){s.STOPPED="stopped",s.READY="ready",s.PLAYING="playing",s.PAUSED="paused"})(z||(z={}));const _S=5,PS=5,DS=500,Ko=7e3;class RS{constructor(e){this.subscription=new ne,this.loadMediaTimeoutSubscription=new ne,this.videoState=new he(z.STOPPED),this.syncPlayback=()=>{const i=this.videoState.getState(),r=this.videoState.getTransition(),a=this.params.desiredState.playbackState.getState(),n=this.params.desiredState.playbackState.getTransition(),o=this.params.desiredState.seekState.getState();if(this.log({message:`[syncPlayback] videoState: ${i}; videoTransition: ${JSON.stringify(r)}; desiredPlaybackState: ${a}; desiredPlaybackStateTransition: ${this.params.desiredState.playbackState.getTransition()}; seekState: ${JSON.stringify(o)};`}),a===p.STOPPED){i!==z.STOPPED&&(this.videoState.startTransitionTo(z.STOPPED),this.stop());return}if(!r){if((n==null?void 0:n.to)!==p.PAUSED&&o.state===K.Requested&&i!==z.STOPPED){this.seek(o.position/1e3);return}switch(a){case p.READY:{switch(i){case z.PLAYING:case z.PAUSED:case z.READY:break;case z.STOPPED:this.videoState.startTransitionTo(z.READY),this.prepare();break;default:j(i)}break}case p.PLAYING:{switch(i){case z.PLAYING:break;case z.PAUSED:this.videoState.startTransitionTo(z.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case z.READY:this.videoState.startTransitionTo(z.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case z.STOPPED:this.videoState.startTransitionTo(z.READY),this.prepare();break;default:j(i)}break}case p.PAUSED:{switch(i){case z.PLAYING:this.videoState.startTransitionTo(z.PAUSED),this.params.connection.remotePlayerController.playOrPause();break;case z.PAUSED:break;case z.READY:this.videoState.startTransitionTo(z.PAUSED),this.videoState.setState(z.PAUSED);break;case z.STOPPED:this.videoState.startTransitionTo(z.READY),this.prepare();break;default:j(i)}break}default:j(a)}}},this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastProvider"),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(kS(e.format)),this.params.output.isAudioAvailable$.next(!0),this.handleRemoteVolumeChange({volume:this.params.connection.remotePlayer.volumeLevel,muted:this.params.connection.remotePlayer.isMuted});const t=this.params.connection.session.getMediaSession();t&&this.restoreSession(t),this.subscribe()}destroy(){this.log({message:"[destroy]"}),this.subscription.unsubscribe()}subscribe(){this.subscription.add(this.loadMediaTimeoutSubscription);const e=new ne;this.subscription.add(e),this.subscription.add(H(this.videoState.stateChangeStarted$.pipe(k(r=>`stateChangeStarted$ ${JSON.stringify(r)}`)),this.videoState.stateChangeEnded$.pipe(k(r=>`stateChangeEnded$ ${JSON.stringify(r)}`))).subscribe(r=>this.log({message:`[videoState] ${r}`})));const t=(r,a)=>this.subscription.add(r.subscribe(a));if(this.params.output.isLive$.getValue())this.params.output.position$.next(0),this.params.output.duration$.next(0);else{const r=new M;e.add(r.pipe(Ye(DS)).subscribe(()=>{this.params.output.seekedEvent$.next()}));let a=NaN;e.add(U(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED).subscribe(n=>{this.logRemoteEvent(n);const o=n.value;this.params.output.position$.next(o),(this.params.desiredState.seekState.getState().state===K.Applying||Math.abs(o-a)>_S)&&r.next(o),a=o})),e.add(U(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.DURATION_CHANGED).subscribe(n=>{this.logRemoteEvent(n),this.params.output.duration$.next(n.value)}))}t(U(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED),r=>{this.logRemoteEvent(r),r.value?this.handleRemoteReady():(this.handleRemoteStop(),e.unsubscribe())}),t(U(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),r=>{this.logRemoteEvent(r),r.value?this.handleRemotePause():this.handleRemotePlay()}),t(U(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED),r=>{this.logRemoteEvent(r);const{remotePlayer:a}=this.params.connection,n=r.value,o=this.params.output.isBuffering$.getValue(),u=n===chrome.cast.media.PlayerState.BUFFERING;switch(o!==u&&this.params.output.isBuffering$.next(u),n){case chrome.cast.media.PlayerState.IDLE:!this.params.output.isLive$.getValue()&&a.duration-a.currentTime<PS&&this.params.output.endedEvent$.next(),this.handleRemoteStop(),R(this.params.desiredState.playbackState,p.STOPPED);break;case chrome.cast.media.PlayerState.PAUSED:{this.handleRemotePause();break}case chrome.cast.media.PlayerState.PLAYING:this.handleRemotePlay();break;case chrome.cast.media.PlayerState.BUFFERING:break;default:j(n)}}),t(U(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED),r=>{this.logRemoteEvent(r),this.handleRemoteVolumeChange({volume:r.value})}),t(U(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),r=>{this.logRemoteEvent(r),this.handleRemoteVolumeChange({muted:r.value})});const i=H(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,Ce(["init"])).pipe(Ye(0));t(i,this.syncPlayback)}restoreSession(e){this.log({message:"restoreSession"});const{remotePlayer:t}=this.params.connection;if(e.playerState!==chrome.cast.media.PlayerState.IDLE){t.isPaused?(this.videoState.setState(z.PAUSED),R(this.params.desiredState.playbackState,p.PAUSED)):(this.videoState.setState(z.PLAYING),R(this.params.desiredState.playbackState,p.PLAYING));const i=this.params.output.isLive$.getValue();this.params.output.duration$.next(i?0:t.duration),this.params.output.position$.next(i?0:t.currentTime),this.params.desiredState.seekState.setState({state:K.None})}}prepare(){const e=this.params.format;this.log({message:`[prepare] format: ${e}`});const t=this.createMediaInfo(e),i=this.createLoadRequest(t);this.loadMedia(i)}handleRemotePause(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===z.PAUSED||e===z.PLAYING)&&(this.videoState.setState(z.PAUSED),R(this.params.desiredState.playbackState,p.PAUSED))}handleRemotePlay(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===z.PLAYING||e===z.PAUSED)&&(this.videoState.setState(z.PLAYING),R(this.params.desiredState.playbackState,p.PLAYING))}handleRemoteReady(){var e;const t=this.videoState.getTransition();(t==null?void 0:t.to)===z.READY&&this.videoState.setState(z.READY),((e=this.params.desiredState.playbackState.getTransition())===null||e===void 0?void 0:e.to)===p.READY&&R(this.params.desiredState.playbackState,p.READY)}handleRemoteStop(){this.videoState.getState()!==z.STOPPED&&this.videoState.setState(z.STOPPED)}handleRemoteVolumeChange(e){var t,i;const r=this.params.output.volume$.getValue(),a={volume:(t=e.volume)!==null&&t!==void 0?t:r.volume,muted:(i=e.muted)!==null&&i!==void 0?i:r.muted};(a.volume!==r.volume||a.muted!==a.muted)&&this.params.output.volume$.next(a)}seek(e){this.params.output.willSeekEvent$.next();const{remotePlayer:t,remotePlayerController:i}=this.params.connection;t.currentTime=e,i.seek()}stop(){const{remotePlayerController:e}=this.params.connection;e.stop()}createMediaInfo(e){var t;const i=this.params.source;let r,a,n;switch(e){case E.MPEG:{const l=i[e];P(l);const c=_l(Object.keys(l));P(c);const h=l[c];P(h),r=h,a="video/mp4",n=chrome.cast.media.StreamType.BUFFERED;break}case E.HLS:case E.HLS_ONDEMAND:{const l=i[e];P(l),r=l.url,a="application/x-mpegurl",n=chrome.cast.media.StreamType.BUFFERED;break}case E.DASH_SEP:case E.DASH_ONDEMAND:case E.DASH_WEBM:case E.DASH_WEBM_AV1:{const l=i[e];P(l),r=l.url,a="application/dash+xml",n=chrome.cast.media.StreamType.BUFFERED;break}case E.DASH_LIVE_CMAF:{const l=i[e];P(l),r=l.url,a="application/dash+xml",n=chrome.cast.media.StreamType.LIVE;break}case E.HLS_LIVE:case E.HLS_LIVE_CMAF:{const l=i[e];P(l),r=Xe(l.url),a="application/x-mpegurl",n=chrome.cast.media.StreamType.LIVE;break}case E.DASH:case E.DASH_LIVE:case E.WEB_RTC_LIVE:{const l="Unsupported format for Chromecast",c=new Error(l);throw this.params.output.error$.next({id:"ChromecastProvider.createMediaInfo()",category:O.VIDEO_PIPELINE,message:l,thrown:c}),c}case E.DASH_LIVE_WEBM:throw new Error("DASH_LIVE_WEBM is no longer supported");default:return j(e)}const o=new chrome.cast.media.MediaInfo((t=this.params.meta.videoId)!==null&&t!==void 0?t:r,a);o.contentUrl=r,o.streamType=n,o.metadata=new chrome.cast.media.GenericMediaMetadata;const{title:u,subtitle:d}=this.params.meta;return _(u)&&(o.metadata.title=u),_(d)&&(o.metadata.subtitle=d),o}createLoadRequest(e){const t=new chrome.cast.media.LoadRequest(e);t.autoplay=!1;const i=this.params.desiredState.seekState.getState();return i.state===K.Applying||i.state===K.Requested?t.currentTime=this.params.output.isLive$.getValue()?0:i.position/1e3:t.currentTime=0,t}loadMedia(e){const t=this.params.connection.session.loadMedia(e),i=new Promise((r,a)=>{this.loadMediaTimeoutSubscription.add(Pl(Ko).subscribe(()=>a(`timeout(${Ko})`)))});ar(Promise.race([t,i]).then(()=>{this.log({message:`[loadMedia] completed, format: ${this.params.format}`}),this.params.desiredState.seekState.getState().state===K.Applying&&this.params.output.seekedEvent$.next(),this.handleRemoteReady()},r=>{const a=`[prepare] loadMedia failed, format: ${this.params.format}, reason: ${r}`;this.log({message:a}),this.params.output.error$.next({id:"ChromecastProvider.loadMedia",category:O.VIDEO_PIPELINE,message:a,thrown:r})}),()=>{this.loadMediaTimeoutSubscription.unsubscribe()})}logRemoteEvent(e){this.log({message:`[remoteEvent] ${JSON.stringify(e)}`})}}var IS=s=>{let e,t=!1,i=!1;s.on("playbackTimeUpdated",({timeToEnd:r})=>{i=r<=3,t&&i&&(e==null||e())}),s.extend("MediaSourceController",function(){const{parent:r}=this,a=r.signalEndOfStream;return{signalEndOfStream:n=>{t=!0,e=()=>a(n),t&&i&&(e==null||e())}}},!0)},LS=s=>{const e=new y(1/0),t=new M,i=new y(void 0),r=new y(void 0);let a=NaN,n=!1;const o=()=>{a=Date.now(),n=!1},u=l=>{var c,h,f,g,m;const S=Ei(l.getAllResponseHeaders().trim().split(/[\n\r]+/).map(v=>v.split(": ")));if("x-playback-duration"in S||"x-playback-duration-millis"in S){const v=parseInt((c=l.getResponseHeader("X-Playback-Duration"))!==null&&c!==void 0?c:"",10),T=parseInt((h=l.getResponseHeader("X-Playback-Duration-Millis"))!==null&&h!==void 0?h:"",10),$=(f=T!=null?T:v*1e3)!==null&&f!==void 0?f:NaN;_($)&&!isNaN($)&&e.next($)}const b=(g=S["x-delivery-type"])!==null&&g!==void 0?g:Hi.HTTP1,A=(m={1:!0,0:!1}[S["x-reused"]])!==null&&m!==void 0?m:void 0;i.next(b),r.next(A)},d=l=>{l.readyState>=2&&!n&&(n=!0,t.next(Date.now()-a))};return s.extend("XHRLoader",function(){const{parent:l}=this,c=l.load.bind(l);return{load:function(h){if(h.request.type==="MPD"){const f=h.onload,g=h.progress;h.onload=function(...m){return u(this),f(...m)},h.progress=function(...m){return d(this),g(...m)},o()}return c(h)}}},!0),{playbackDuration$:e,ping$:t,connectionReused$:r,connectionType$:i}},$i=s=>{const e=new URL(s);return e.searchParams.set("quic","1"),e.toString()},CS=s=>s.extend("RequestModifier",()=>({modifyRequestURL:$i}),!0),xS=s=>{s.extend("HTTPLoader",function(){const{parent:e}=this,t=e.load;return{load:i=>{if(i.request&&i.request.range){const[r,a]=i.request.range.split("-").map(o=>parseInt(o,10)),n=new URL(i.request.url,location.href);n.searchParams.append("bytes",`${r}-${a}`),i.request.url=n.toString(),i.request.range=void 0}t(i)}}},!0)};const Ze=(s,e,t,{equal:i=(n,o)=>n===o,changed$:r,onError:a}={})=>{const n=s.getState(),o=e(),u=te(r),d=new ne;return r&&d.add(r.subscribe(l=>{const c=s.getState();i(l,c)&&s.setState(l)},a)),i(o,n)||(t(n),u&&s.setState(n)),d.add(s.stateChangeStarted$.subscribe(l=>{t(l.to),u&&s.setState(l.to)},a)),d},Zt=(s,e,t)=>Ze(e,()=>s.loop,i=>{_(i)&&(s.loop=i)},{onError:t}),St=(s,e,t,i)=>Ze(e,()=>({muted:s.muted,volume:s.volume}),r=>{_(r)&&(s.muted=r.muted,s.volume=r.volume)},{equal:(r,a)=>r===a||(r==null?void 0:r.muted)===(a==null?void 0:a.muted)&&(r==null?void 0:r.volume)===(a==null?void 0:a.volume),changed$:t,onError:i}),Ct=(s,e,t,i)=>Ze(e,()=>s.playbackRate,r=>{_(r)&&(s.playbackRate=r)},{changed$:t,onError:i}),OS=s=>["__",s.language,s.label].join("|"),MS=(s,e)=>{if(s.id===e)return!0;const[t,i,r]=e.split("|");return s.language===i&&s.label===r};class lt{constructor(){this.available$=new M,this.current$=new y(void 0),this.error$=new M,this.subscription=new ne,this.externalTracks=new Map,this.internalTracks=new Map}connect(e,t,i){this.video=e,this.cueSettings=t.textTrackCuesSettings,this.subscribe();const r=a=>{this.error$.next({id:"TextTracksManager",category:O.WTF,message:"Generic HtmlVideoTextTrackManager error",thrown:a})};this.subscription.add(this.available$.subscribe(i.availableTextTracks$)),this.subscription.add(this.current$.subscribe(i.currentTextTrack$)),this.subscription.add(this.error$.subscribe(i.error$)),this.subscription.add(Ze(t.internalTextTracks,()=>Object.values(this.internalTracks),a=>{_(a)&&this.setInternal(a)},{equal:(a,n)=>_(a)&&_(n)&&a.length===n.length&&a.every(({id:o},u)=>o===n[u].id),changed$:this.available$.pipe(k(a=>a.filter(({type:n})=>n==="internal"))),onError:r})),this.subscription.add(Ze(t.externalTextTracks,()=>Object.values(this.externalTracks),a=>{_(a)&&this.setExternal(a)},{equal:(a,n)=>_(a)&&_(n)&&a.length===n.length&&a.every(({id:o},u)=>o===n[u].id),changed$:this.available$.pipe(k(a=>a.filter(({type:n})=>n==="external"))),onError:r})),this.subscription.add(Ze(t.currentTextTrack,()=>{if(this.video)return;const a=this.htmlTextTracksAsArray().find(({mode:n})=>n==="showing");return a&&this.htmlTextTrackToITextTrack(a).id},a=>this.select(a),{changed$:this.current$,onError:r})),this.subscription.add(Ze(t.textTrackCuesSettings,()=>({}),()=>{if(this.video)for(const a of this.htmlTextTracksAsArray())this.applyCueSettings(a.cues),this.applyCueSettings(a.activeCues)}))}subscribe(){P(this.video);const{textTracks:e}=this.video;this.subscription.add(U(e,"addtrack").subscribe(()=>{const i=this.current$.getValue();i&&this.select(i)})),this.subscription.add(H(U(e,"addtrack"),U(e,"removetrack"),Ce(["init"])).pipe(k(()=>this.htmlTextTracksAsArray().map(i=>this.htmlTextTrackToITextTrack(i))),me((i,r)=>i.length===r.length&&i.every(({id:a},n)=>a===r[n].id))).subscribe(this.available$)),this.subscription.add(H(U(e,"change"),Ce(["init"])).pipe(k(()=>this.htmlTextTracksAsArray().find(({mode:i})=>i==="showing")),k(i=>i&&this.htmlTextTrackToITextTrack(i).id),me()).subscribe(this.current$));const t=i=>{var r,a;return this.applyCueSettings((a=(r=i.target)===null||r===void 0?void 0:r.activeCues)!==null&&a!==void 0?a:null)};this.subscription.add(U(e,"addtrack").subscribe(i=>{var r,a;(r=i.track)===null||r===void 0||r.addEventListener("cuechange",t);const n=o=>{var u,d,l,c,h;const f=(d=(u=o.target)===null||u===void 0?void 0:u.cues)!==null&&d!==void 0?d:null;f&&f.length&&(this.applyCueSettings((c=(l=o.target)===null||l===void 0?void 0:l.cues)!==null&&c!==void 0?c:null),(h=o.target)===null||h===void 0||h.removeEventListener("cuechange",n))};(a=i.track)===null||a===void 0||a.addEventListener("cuechange",n)})),this.subscription.add(U(e,"removetrack").subscribe(i=>{var r;(r=i.track)===null||r===void 0||r.removeEventListener("cuechange",t)}))}applyCueSettings(e){if(!e||!e.length)return;const t=this.cueSettings.getState();for(const i of Array.from(e)){const r=i;_(t.align)&&(r.align=t.align),_(t.position)&&(r.position=t.position),_(t.size)&&(r.size=t.size),_(t.line)&&(r.line=t.line)}}htmlTextTracksAsArray(e=!1){P(this.video);const t=[...this.video.textTracks];return e?t:t.filter(lt.isHealthyTrack)}htmlTextTrackToITextTrack(e){var t,i;const{language:r,label:a}=e,n=e.id?e.id:OS(e),o=this.externalTracks.has(n),u=n.includes("auto");return o?{id:n,type:"external",isAuto:u,language:r,label:a,url:(t=this.externalTracks.get(n))===null||t===void 0?void 0:t.url}:{id:n,type:"internal",isAuto:u,language:r,label:a,url:(i=this.internalTracks.get(n))===null||i===void 0?void 0:i.url}}static isHealthyTrack(e){return!(e.kind==="metadata"||e.groupId||e.id===""&&e.label===""&&e.language==="")}setExternal(e){this.internalTracks.size>0&&Array.from(this.internalTracks).forEach(([,t])=>this.detach(t)),e.filter(({id:t})=>!this.externalTracks.has(t)).forEach(t=>this.attach(t)),Array.from(this.externalTracks).filter(([t])=>!e.find(i=>i.id===t)).forEach(([,t])=>this.detach(t))}setInternal(e){const t=[...this.externalTracks];e.filter(({id:i,language:r,isAuto:a})=>!this.internalTracks.has(i)&&!t.some(([,n])=>n.language===r&&n.isAuto===a)).forEach(i=>this.attach(i)),Array.from(this.internalTracks).filter(([i])=>!e.find(r=>r.id===i)).forEach(([,i])=>this.detach(i))}select(e){P(this.video);for(const t of this.htmlTextTracksAsArray(!0))t.mode="showing";for(const t of this.htmlTextTracksAsArray(!0))(te(e)||!MS(t,e))&&(t.mode="disabled")}destroy(){if(this.subscription.unsubscribe(),this.video)for(const e of Array.from(this.video.getElementsByTagName("track"))){const t=e.getAttribute("id");t&&this.externalTracks.has(t)&&this.video.removeChild(e)}this.externalTracks.clear()}attach(e){P(this.video);const t=document.createElement("track");t.setAttribute("src",e.url),t.setAttribute("id",e.id),e.label&&t.setAttribute("label",e.label),e.language&&t.setAttribute("srclang",e.language),e.type==="external"?this.externalTracks.set(e.id,e):e.type==="internal"&&this.internalTracks.set(e.id,e),this.video.appendChild(t)}detach(e){P(this.video);const t=Array.prototype.find.call(this.video.getElementsByTagName("track"),i=>i.getAttribute("id")===e.id);t&&this.video.removeChild(t),e.type==="external"?this.externalTracks.delete(e.id):e.type==="internal"&&this.internalTracks.delete(e.id)}}const Sn=s=>{s.removeAttribute("src"),s.load()},BS=s=>{try{s.pause(),s.playbackRate=0,Sn(s),s.remove()}catch(e){console.error(e)}};class NS{constructor(){this.attribute="data-pool-reused"}get(e){return e.hasAttribute(this.attribute)}set(e,t){e.toggleAttribute(this.attribute,t)}delete(e){e.removeAttribute(this.attribute)}}const Ua=window.WeakMap?new WeakMap:new NS,bt=s=>{let e=s.querySelector("video");const t=!!e;return e?Sn(e):(e=document.createElement("video"),s.appendChild(e)),Ua.set(e,t),e.setAttribute("crossorigin","anonymous"),e.setAttribute("playsinline","playsinline"),e.controls=!1,e.setAttribute("poster","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),e},yt=s=>{const e=Ua.get(s);Ua.delete(s),e?Sn(s):BS(s)};class nr{constructor(){this.pausedTime=0,this.streamOffset=0,this.pauseTimestamp=0}getTotalPausedTime(){return this.pausedTime+this.getCurrentPausedTime()}getCurrentPausedTime(){return this.pauseTimestamp>0?Date.now()-this.pauseTimestamp:0}getStreamOffset(){return this.streamOffset}getTotalOffset(){return this.getTotalPausedTime()+this.streamOffset}pause(){this.pauseTimestamp===0&&(this.pauseTimestamp=Date.now())}resume(){this.pauseTimestamp>0&&(this.pausedTime+=this.getCurrentPausedTime(),this.pauseTimestamp=0)}resetTo(e,t=!1){this.streamOffset=e,this.pauseTimestamp=0,this.pausedTime=0,t&&this.pause()}}const ju=s=>{var e;let t=s;for(;!(t instanceof Document)&&!(t instanceof ShadowRoot)&&t!==null;)t=t==null?void 0:t.parentNode;return(e=t)!==null&&e!==void 0?e:void 0},Jo=s=>{const e=ju(s);return!!(e&&e.fullscreenElement&&e.fullscreenElement===s)},FS=s=>{const e=ju(s);return!!(e&&e.pictureInPictureElement&&e.pictureInPictureElement===s)},Va=3;class US{constructor(e){this._buffer=[],this._source=e}fill(){this._buffer=[];const e=this._source.currentTime;for(let t=0,i=this._source.buffered.length;t<i;t++){let r=this._source.buffered.start(t);const a=this._source.buffered.end(t);r>e&&r-e<Va&&(r=e),this._buffer.push({from:r,to:a,i:t})}return this._buffer.sort(function(t,i){return t.from-i.from}),this._buffer}getByTime(e){return this._buffer.find(t=>e>=t.from&&e<t.to)}getNextWithGap(e,t){const i=this.getNext(e);if(i&&i.from-e.to<(t||Va))return i}getNext(e){let t=this._buffer.indexOf(e);if(~t&&this._buffer.length-1>t)return this._buffer[++t]}smartRemove(e,t,i){this._buffer.forEach(({from:r,to:a})=>{const n=r>=e&&r<t,o=a>=e&&a<t;n&&o||(n?i(t,a):o?i(r,e):r<e&&a>t?(i(t,a),i(r,e)):i(r,a))})}destroy(){this._buffer=[]}}var Yu=(s,e,t=Va)=>{let i=0,r=0;for(let a=0;a<s.length;a++){const n=s.start(a),o=s.end(a);if(n<=e&&e<=o){if(i=n,r=o,!t)return{from:i,to:r};for(let u=a-1;u>=0;u--)s.end(u)+t>=i&&(i=s.start(u));for(let u=a+1;u<s.length;u++)s.start(u)-t<=r&&(r=s.end(u))}}return{from:i,to:r}};const Tt=s=>{const e=v=>U(s,v).pipe(Ti(void 0)),i=H(...["waiting","pause","canplay","play","canplaythrough","playing","seeking","seeked","ended"].map(v=>U(s,v))).pipe(k(v=>v.type==="ended"?s.readyState<2:s.readyState<3),me()),r=H(U(s,"progress"),U(s,"timeupdate")).pipe(k(()=>Yu(s.buffered,s.currentTime))),n=za().browser===kd.Safari?Le({play:e("play").pipe(ge()),playing:e("playing")}).pipe(Ti(void 0)):e("playing"),o=U(s,"volumechange").pipe(k(()=>({muted:s.muted,volume:s.volume}))),u=U(s,"ratechange").pipe(k(()=>s.playbackRate)),d=U(s,"error").pipe(X(()=>!!(s.error||s.played.length)),k(()=>{var v;const T=s.error;return{id:T?`MediaError#${T.code}`:"HtmlVideoError",category:O.VIDEO_PIPELINE,message:T?T.message:"Error event from HTML video element",thrown:(v=s.error)!==null&&v!==void 0?v:void 0}})),l=U(s,"timeupdate").pipe(k(()=>s.currentTime)),c=new M,h=.3;let f;l.subscribe(v=>{s.loop&&_(f)&&_(v)&&f>=s.duration-h&&v<=h&&c.next(f),f=v});const g=U(s,"enterpictureinpicture"),m=U(s,"leavepictureinpicture"),S=new y(FS(s));g.subscribe(()=>S.next(!0)),m.subscribe(()=>S.next(!1));const b=new y(Jo(s));return U(s,"fullscreenchange").pipe(k(()=>Jo(s))).subscribe(b),{playing$:n,pause$:e("pause").pipe(X(()=>!s.error)),canplay$:e("canplay"),ended$:e("ended"),looped$:c,error$:d,seeked$:e("seeked"),seeking$:e("seeking"),progress$:e("progress"),loadStart$:e("loadstart"),loadedMetadata$:e("loadedmetadata"),loadedData$:e("loadeddata"),timeUpdate$:l,durationChange$:U(s,"durationchange").pipe(k(()=>s.duration)),isBuffering$:i,currentBuffer$:r,volumeState$:o,playbackRateState$:u,inPiP$:S,inFullscreen$:b}},bn=s=>{if(s.includes("/")){const e=s.split("/");return parseInt(e[0])/parseInt(e[1])}else return parseFloat(s)};var VS=et,HS=er,GS=an,jS=rn;VS({target:"Array",proto:!0},{at:function(e){var t=HS(this),i=GS(t),r=jS(e),a=r>=0?r:i+r;return a<0||a>=i?void 0:t[a]}});var YS=gn,qS=YS("Array","at"),zS=qS,WS=zS,QS=WS,KS=QS,ct=Ws(KS);let yn=!1,ht={};const JS=s=>{yn=s},XS=()=>{ht={}},ZS=s=>{s(ht)},Es=(s,e)=>{var t;yn&&(ht.meta=(t=ht.meta)!==null&&t!==void 0?t:{},ht.meta[s]=e)};class nt{constructor(e){this.name=e}next(e){var t,i;if(!yn)return;ht.series=(t=ht.series)!==null&&t!==void 0?t:{};const r=(i=ht.series[this.name])!==null&&i!==void 0?i:[];r.push([Date.now(),e]),ht.series[this.name]=r}}var Yt;(function(s){s.FitsContainer="FitsContainer",s.FitsThroughput="FitsThroughput",s.Buffer="Buffer",s.DroppedFramesLimit="DroppedFramesLimit",s.FitsQualityLimits="FitsQualityLimits"})(Yt||(Yt={}));const eb=new nt("best_bitrate"),tb=(s,e,t)=>(e-t)*Math.pow(2,-10*s)+t;class ib{constructor(){this.history={}}recordSelection(e){this.history[e.id]=le()}recordSwitch(e){this.last=e}clear(){this.last=void 0,this.history={}}}const sb='Assertion "ABR Tracks is empty array" failed',Di=(s,{container:e,throughput:t,tuning:i,limits:r,reserve:a=0,forwardBufferHealth:n,playbackRate:o,current:u,history:d,droppedVideoMaxQualityLimit:l,abrLogger:c})=>{var h,f,g,m,S;Dl(s,sb);const b=i.usePixelRatio&&(h=window.devicePixelRatio)!==null&&h!==void 0?h:1,A=i.limitByContainer&&e&&e.width>0&&e.height>0&&{width:e.width*b*i.containerSizeFactor,height:e.height*b*i.containerSizeFactor},v=A&&Qt(A),T=i.considerPlaybackRate&&_(o)?o:1,$=s.filter(F=>!zt(F.quality)).sort((F,L)=>Si(F.quality,L.quality)?-1:1),D=(f=ct($,-1))===null||f===void 0?void 0:f.quality,N=(g=ct($,0))===null||g===void 0?void 0:g.quality,G=te(r)||_(r.min)&&_(r.max)&&Is(r.max,r.min)||_(r.min)&&N&&Si(r.min,N)||_(r.max)&&D&&Is(r.max,D),B=T*tb(n!=null?n:.5,i.bitrateFactorAtEmptyBuffer,i.bitrateFactorAtFullBuffer),Y={},x=$.filter(F=>(v?Is(F.quality,v):!0)?(_(t)&&isFinite(t)&&_(F.bitrate)?t-a>=F.bitrate*B:!0)?i.lazyQualitySwitch&&_(i.minBufferToSwitchUp)&&u&&!zt(u.quality)&&(n!=null?n:0)<i.minBufferToSwitchUp&&Si(F.quality,u.quality)?(Y[F.quality]=Yt.Buffer,!1):!!l&&ba(F.quality,l)?(Y[F.quality]=Yt.DroppedFramesLimit,!1):G||(te(r.max)||_d(F.quality,r.max))&&(te(r.min)||ba(F.quality,r.min))?!0:(Y[F.quality]=Yt.FitsQualityLimits,!1):(Y[F.quality]=Yt.FitsThroughput,!1):(Y[F.quality]=Yt.FitsContainer,!1))[0];x&&x.bitrate&&eb.next(x.bitrate);const I=(m=x!=null?x:$[Math.ceil(($.length-1)/2)])!==null&&m!==void 0?m:s[0];I.quality!==((S=d==null?void 0:d.last)===null||S===void 0?void 0:S.quality)&&c({message:`
|
|
6
|
+
import{ValueSubject as y,Subject as M,Subscription as ne,isNonNullable as _,ErrorCategory as O,isNullable as te,fromEvent as U,assertNever as j,merge as H,tap as Vi,map as k,observableFrom as Ce,filterChanged as me,assertNonNullable as P,debounce as Ye,getHighestQuality as _l,timeout as Pl,getCurrentBrowser as za,CurrentClientBrowser as kd,combine as Le,once as ge,mapTo as Ti,filter as X,now as le,assertNotEmptyArray as Dl,videoSizeToQuality as Qt,isInvariantQuality as zt,isHigher as Si,isLower as Is,isHigherOrEqual as ba,isLowerOrEqual as _d,Observable as zs,debounceFn as Rl,interval as Ms,VideoQuality as He,videoQualityToHeight as Il,abortable as Re,getExponentialDelay as Er,isIOS as Ll,CurrentClientDevice as Cl,safeStorage as $r,fillWithDefault as xl,Logger as Ol}from"@vkontakte/videoplayer-shared/es2015.esm.js";import{Observable as ZT,Subject as e0,Subscription as t0,ValueSubject as i0,VideoQuality as s0}from"@vkontakte/videoplayer-shared/es2015.esm.js";const Ml="2.0.99-dev.8e8ba4ac.0";var p;(function(s){s.STOPPED="stopped",s.READY="ready",s.PLAYING="playing",s.PAUSED="paused"})(p||(p={}));var E;(function(s){s.MPEG="MPEG",s.DASH="DASH",s.DASH_SEP="DASH_SEP",s.DASH_SEP_VK="DASH_SEP",s.DASH_WEBM="DASH_WEBM",s.DASH_WEBM_AV1="DASH_WEBM_AV1",s.DASH_WEBM_VK="DASH_WEBM",s.DASH_ONDEMAND="DASH_ONDEMAND",s.DASH_ONDEMAND_VK="DASH_ONDEMAND",s.DASH_LIVE="DASH_LIVE",s.DASH_LIVE_CMAF="DASH_LIVE_CMAF",s.DASH_LIVE_WEBM="DASH_LIVE_WEBM",s.HLS="HLS",s.HLS_ONDEMAND="HLS_ONDEMAND",s.HLS_JS="HLS",s.HLS_LIVE="HLS_LIVE",s.HLS_LIVE_CMAF="HLS_LIVE_CMAF",s.WEB_RTC_LIVE="WEB_RTC_LIVE"})(E||(E={}));var ke;(function(s){s.SCREEN="SCREEN",s.CHROMECAST="CHROMECAST"})(ke||(ke={}));var $e;(function(s){s.NOT_AVAILABLE="NOT_AVAILABLE",s.AVAILABLE="AVAILABLE",s.CONNECTING="CONNECTING",s.CONNECTED="CONNECTED"})($e||($e={}));var Hi;(function(s){s.HTTP1="http1",s.HTTP2="http2",s.QUIC="quic"})(Hi||(Hi={}));var K;(function(s){s.None="none",s.Requested="requested",s.Applying="applying"})(K||(K={}));var _t;(function(s){s.NONE="none",s.INLINE="inline",s.FULLSCREEN="fullscreen",s.SECOND_SCREEN="second_screen",s.PIP="pip"})(_t||(_t={}));function ae(s,e,t,i){function r(a){return a instanceof t?a:new t(function(n){n(a)})}return new(t||(t=Promise))(function(a,n){function o(l){try{d(i.next(l))}catch(c){n(c)}}function u(l){try{d(i.throw(l))}catch(c){n(c)}}function d(l){l.done?a(l.value):r(l.value).then(o,u)}d((i=i.apply(s,e||[])).next())})}function V(s){return this instanceof V?(this.v=s,this):new V(s)}function Ie(s,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(s,e||[]),r,a=[];return r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r;function n(h){i[h]&&(r[h]=function(f){return new Promise(function(g,m){a.push([h,f,g,m])>1||o(h,f)})})}function o(h,f){try{u(i[h](f))}catch(g){c(a[0][3],g)}}function u(h){h.value instanceof V?Promise.resolve(h.value.v).then(d,l):c(a[0][2],h)}function d(h){o("next",h)}function l(h){o("throw",h)}function c(h,f){h(f),a.shift(),a.length&&o(a[0][0],a[0][1])}}var Bl=s=>new Promise((e,t)=>{const i=document.createElement("script");i.setAttribute("src",s),i.onload=()=>e,i.onerror=()=>t,document.body.appendChild(i)});class Nl{constructor(e){var t;this.connection$=new y(void 0),this.castState$=new y($e.NOT_AVAILABLE),this.errorEvent$=new M,this.realCastState$=new y($e.NOT_AVAILABLE),this.subscription=new ne,this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastInitializer");const i="chrome"in window;if(this.log({message:`[constructor] receiverApplicationId: ${this.params.receiverApplicationId}, isDisabled: ${this.params.isDisabled}, isSupported: ${i}`}),e.isDisabled||!i)return;const r=_((t=window.chrome)===null||t===void 0?void 0:t.cast),a=!!window.__onGCastApiAvailable;r?this.initializeCastApi():(window.__onGCastApiAvailable=n=>{delete window.__onGCastApiAvailable,n&&this.initializeCastApi()},a||Bl("https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1").catch(()=>this.errorEvent$.next({id:"ChromecastLoading",category:O.NETWORK,message:"Script loading failed!"})))}connect(){var e;(e=cast.framework.CastContext.getInstance())===null||e===void 0||e.requestSession()}disconnect(){var e,t;(t=(e=cast.framework.CastContext.getInstance())===null||e===void 0?void 0:e.getCurrentSession())===null||t===void 0||t.endSession(!0)}stopMedia(){return new Promise((e,t)=>{var i,r,a;(a=(r=(i=cast.framework.CastContext.getInstance())===null||i===void 0?void 0:i.getCurrentSession())===null||r===void 0?void 0:r.getMediaSession())===null||a===void 0||a.stop(new chrome.cast.media.StopRequest,e,t)})}toggleConnection(){_(this.connection$.getValue())?this.disconnect():this.connect()}setVolume(e){const t=this.connection$.getValue();te(t)||(t.remotePlayer.volumeLevel=e,t.remotePlayerController.setVolumeLevel())}setMuted(e){const t=this.connection$.getValue();te(t)||e!==t.remotePlayer.isMuted&&t.remotePlayerController.muteOrUnmute()}destroy(){this.subscription.unsubscribe()}initListeners(){const e=new cast.framework.RemotePlayer,t=new cast.framework.RemotePlayerController(e),i=cast.framework.CastContext.getInstance();this.subscription.add(U(i,cast.framework.CastContextEventType.SESSION_STATE_CHANGED).subscribe(r=>{var a,n;switch(r.sessionState){case cast.framework.SessionState.SESSION_STARTED:case cast.framework.SessionState.SESSION_STARTING:case cast.framework.SessionState.SESSION_RESUMED:this.contentId=(n=(a=i.getCurrentSession())===null||a===void 0?void 0:a.getMediaSession())===null||n===void 0?void 0:n.media.contentId;break;case cast.framework.SessionState.NO_SESSION:case cast.framework.SessionState.SESSION_ENDING:case cast.framework.SessionState.SESSION_ENDED:case cast.framework.SessionState.SESSION_START_FAILED:this.contentId=void 0;break;default:return j(r.sessionState)}})).add(H(U(i,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe(Vi(r=>{this.log({message:`[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: ${JSON.stringify(r)}`})}),k(r=>r.castState)),Ce([i.getCastState()])).pipe(me(),k(Fl),Vi(r=>{this.log({message:`realCastState$: ${r}`})})).subscribe(this.realCastState$)).add(this.realCastState$.subscribe(r=>{var a;const n=r===$e.CONNECTED,o=_(this.connection$.getValue());if(n&&!o){const u=i.getCurrentSession();P(u);const d=u.getCastDevice(),l=(a=u.getMediaSession())===null||a===void 0?void 0:a.media.contentId;(te(l)||l===this.contentId)&&(this.log({message:"connection created"}),this.connection$.next({remotePlayer:e,remotePlayerController:t,session:u,castDevice:d}))}else!n&&o&&(this.log({message:"connection destroyed"}),this.connection$.next(void 0));this.castState$.next(r===$e.CONNECTED?_(this.connection$.getValue())?$e.CONNECTED:$e.AVAILABLE:r)}))}initializeCastApi(){var e;let t,i,r;try{t=cast.framework.CastContext.getInstance(),i=chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,r=chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}catch(a){return}try{t.setOptions({receiverApplicationId:(e=this.params.receiverApplicationId)!==null&&e!==void 0?e:i,autoJoinPolicy:r}),this.initListeners()}catch(a){this.errorEvent$.next({id:"ChromecastInitializer",category:O.EXTERNAL_API,message:"[initializeCastApi] failed",thrown:a})}}}const Fl=s=>{switch(s){case cast.framework.CastState.NO_DEVICES_AVAILABLE:return $e.NOT_AVAILABLE;case cast.framework.CastState.NOT_CONNECTED:return $e.AVAILABLE;case cast.framework.CastState.CONNECTING:return $e.CONNECTING;case cast.framework.CastState.CONNECTED:return $e.CONNECTED;default:return j(s)}};var Ar=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Ws(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var qe=function(s){try{return!!s()}catch(e){return!0}},Ul=qe,Qs=!Ul(function(){var s=function(){}.bind();return typeof s!="function"||s.hasOwnProperty("prototype")}),Pd=Qs,Dd=Function.prototype,ya=Dd.call,Vl=Pd&&Dd.bind.bind(ya,ya),ze=Pd?Vl:function(s){return function(){return ya.apply(s,arguments)}},Rd=ze,Hl=Rd({}.toString),Gl=Rd("".slice),zi=function(s){return Gl(Hl(s),8,-1)},jl=ze,Yl=qe,ql=zi,wr=Object,zl=jl("".split),Wl=Yl(function(){return!wr("z").propertyIsEnumerable(0)})?function(s){return ql(s)=="String"?zl(s,""):wr(s)}:wr,Wi=function(s){return s==null},Ql=Wi,Kl=TypeError,Wa=function(s){if(Ql(s))throw Kl("Can't call method on "+s);return s},Jl=Wl,Xl=Wa,Qi=function(s){return Jl(Xl(s))},ki={},us=function(s){return s&&s.Math==Math&&s},we=us(typeof globalThis=="object"&&globalThis)||us(typeof window=="object"&&window)||us(typeof self=="object"&&self)||us(typeof Ar=="object"&&Ar)||function(){return this}()||Ar||Function("return this")(),Ta=typeof document=="object"&&document.all,Zl=typeof Ta=="undefined"&&Ta!==void 0,Id={all:Ta,IS_HTMLDDA:Zl},Ld=Id,ec=Ld.all,Ee=Ld.IS_HTMLDDA?function(s){return typeof s=="function"||s===ec}:function(s){return typeof s=="function"},tc=we,ic=Ee,xn=tc.WeakMap,sc=ic(xn)&&/native code/.test(String(xn)),On=Ee,Cd=Id,rc=Cd.all,vt=Cd.IS_HTMLDDA?function(s){return typeof s=="object"?s!==null:On(s)||s===rc}:function(s){return typeof s=="object"?s!==null:On(s)},ac=qe,Lt=!ac(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),Kt={},nc=we,Mn=vt,Ea=nc.document,oc=Mn(Ea)&&Mn(Ea.createElement),Qa=function(s){return oc?Ea.createElement(s):{}},dc=Lt,uc=qe,lc=Qa,xd=!dc&&!uc(function(){return Object.defineProperty(lc("div"),"a",{get:function(){return 7}}).a!=7}),cc=Lt,hc=qe,Od=cc&&hc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),fc=vt,pc=String,mc=TypeError,gt=function(s){if(fc(s))return s;throw mc(pc(s)+" is not an object")},vc=Qs,ls=Function.prototype.call,Fe=vc?ls.bind(ls):function(){return ls.apply(ls,arguments)},Ka={},kr=Ka,_r=we,gc=Ee,Bn=function(s){return gc(s)?s:void 0},Jt=function(s,e){return arguments.length<2?Bn(kr[s])||Bn(_r[s]):kr[s]&&kr[s][e]||_r[s]&&_r[s][e]},Sc=ze,Ks=Sc({}.isPrototypeOf),Js=typeof navigator!="undefined"&&String(navigator.userAgent)||"",Md=we,Pr=Js,Nn=Md.process,Fn=Md.Deno,Un=Nn&&Nn.versions||Fn&&Fn.version,Vn=Un&&Un.v8,Je,Bs;Vn&&(Je=Vn.split("."),Bs=Je[0]>0&&Je[0]<4?1:+(Je[0]+Je[1]));!Bs&&Pr&&(Je=Pr.match(/Edge\/(\d+)/),(!Je||Je[1]>=74)&&(Je=Pr.match(/Chrome\/(\d+)/),Je&&(Bs=+Je[1])));var Bd=Bs,Hn=Bd,bc=qe,yc=we,Tc=yc.String,Nd=!!Object.getOwnPropertySymbols&&!bc(function(){var s=Symbol();return!Tc(s)||!(Object(s)instanceof Symbol)||!Symbol.sham&&Hn&&Hn<41}),Ec=Nd,Fd=Ec&&!Symbol.sham&&typeof Symbol.iterator=="symbol",$c=Jt,Ac=Ee,wc=Ks,kc=Fd,_c=Object,Ud=kc?function(s){return typeof s=="symbol"}:function(s){var e=$c("Symbol");return Ac(e)&&wc(e.prototype,_c(s))},Pc=String,Xs=function(s){try{return Pc(s)}catch(e){return"Object"}},Dc=Ee,Rc=Xs,Ic=TypeError,Xt=function(s){if(Dc(s))return s;throw Ic(Rc(s)+" is not a function")},Lc=Xt,Cc=Wi,Zs=function(s,e){var t=s[e];return Cc(t)?void 0:Lc(t)},Dr=Fe,Rr=Ee,Ir=vt,xc=TypeError,Oc=function(s,e){var t,i;if(e==="string"&&Rr(t=s.toString)&&!Ir(i=Dr(t,s))||Rr(t=s.valueOf)&&!Ir(i=Dr(t,s))||e!=="string"&&Rr(t=s.toString)&&!Ir(i=Dr(t,s)))return i;throw xc("Can't convert object to primitive value")},Vd={exports:{}},Mc=!0,Gn=we,Bc=Object.defineProperty,Nc=function(s,e){try{Bc(Gn,s,{value:e,configurable:!0,writable:!0})}catch(t){Gn[s]=e}return e},Fc=we,Uc=Nc,jn="__core-js_shared__",Vc=Fc[jn]||Uc(jn,{}),Ja=Vc,Yn=Ja;(Vd.exports=function(s,e){return Yn[s]||(Yn[s]=e!==void 0?e:{})})("versions",[]).push({version:"3.31.0",mode:"pure",copyright:"\xA9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.31.0/LICENSE",source:"https://github.com/zloirock/core-js"});var Hd=Vd.exports,Hc=Wa,Gc=Object,er=function(s){return Gc(Hc(s))},jc=ze,Yc=er,qc=jc({}.hasOwnProperty),ut=Object.hasOwn||function(e,t){return qc(Yc(e),t)},zc=ze,Wc=0,Qc=Math.random(),Kc=zc(1 .toString),Gd=function(s){return"Symbol("+(s===void 0?"":s)+")_"+Kc(++Wc+Qc,36)},Jc=we,Xc=Hd,qn=ut,Zc=Gd,eh=Nd,th=Fd,pi=Jc.Symbol,Lr=Xc("wks"),ih=th?pi.for||pi:pi&&pi.withoutSetter||Zc,Pe=function(s){return qn(Lr,s)||(Lr[s]=eh&&qn(pi,s)?pi[s]:ih("Symbol."+s)),Lr[s]},sh=Fe,zn=vt,Wn=Ud,rh=Zs,ah=Oc,nh=Pe,oh=TypeError,dh=nh("toPrimitive"),uh=function(s,e){if(!zn(s)||Wn(s))return s;var t=rh(s,dh),i;if(t){if(e===void 0&&(e="default"),i=sh(t,s,e),!zn(i)||Wn(i))return i;throw oh("Can't convert object to primitive value")}return e===void 0&&(e="number"),ah(s,e)},lh=uh,ch=Ud,Xa=function(s){var e=lh(s,"string");return ch(e)?e:e+""},hh=Lt,fh=xd,ph=Od,cs=gt,Qn=Xa,mh=TypeError,Cr=Object.defineProperty,vh=Object.getOwnPropertyDescriptor,xr="enumerable",Or="configurable",Mr="writable";Kt.f=hh?ph?function(e,t,i){if(cs(e),t=Qn(t),cs(i),typeof e=="function"&&t==="prototype"&&"value"in i&&Mr in i&&!i[Mr]){var r=vh(e,t);r&&r[Mr]&&(e[t]=i.value,i={configurable:Or in i?i[Or]:r[Or],enumerable:xr in i?i[xr]:r[xr],writable:!1})}return Cr(e,t,i)}:Cr:function(e,t,i){if(cs(e),t=Qn(t),cs(i),fh)try{return Cr(e,t,i)}catch(r){}if("get"in i||"set"in i)throw mh("Accessors not supported");return"value"in i&&(e[t]=i.value),e};var tr=function(s,e){return{enumerable:!(s&1),configurable:!(s&2),writable:!(s&4),value:e}},gh=Lt,Sh=Kt,bh=tr,Ki=gh?function(s,e,t){return Sh.f(s,e,bh(1,t))}:function(s,e,t){return s[e]=t,s},yh=Hd,Th=Gd,Kn=yh("keys"),Za=function(s){return Kn[s]||(Kn[s]=Th(s))},en={},Eh=sc,jd=we,$h=vt,Ah=Ki,Br=ut,Nr=Ja,wh=Za,kh=en,Jn="Object already initialized",$a=jd.TypeError,_h=jd.WeakMap,Ns,Gi,Fs,Ph=function(s){return Fs(s)?Gi(s):Ns(s,{})},Dh=function(s){return function(e){var t;if(!$h(e)||(t=Gi(e)).type!==s)throw $a("Incompatible receiver, "+s+" required");return t}};if(Eh||Nr.state){var st=Nr.state||(Nr.state=new _h);st.get=st.get,st.has=st.has,st.set=st.set,Ns=function(s,e){if(st.has(s))throw $a(Jn);return e.facade=s,st.set(s,e),e},Gi=function(s){return st.get(s)||{}},Fs=function(s){return st.has(s)}}else{var ni=wh("state");kh[ni]=!0,Ns=function(s,e){if(Br(s,ni))throw $a(Jn);return e.facade=s,Ah(s,ni,e),e},Gi=function(s){return Br(s,ni)?s[ni]:{}},Fs=function(s){return Br(s,ni)}}var Yd={set:Ns,get:Gi,has:Fs,enforce:Ph,getterFor:Dh},Rh=Qs,qd=Function.prototype,Xn=qd.apply,Zn=qd.call,zd=typeof Reflect=="object"&&Reflect.apply||(Rh?Zn.bind(Xn):function(){return Zn.apply(Xn,arguments)}),Ih=zi,Lh=ze,Wd=function(s){if(Ih(s)==="Function")return Lh(s)},tn={},Qd={},Kd={}.propertyIsEnumerable,Jd=Object.getOwnPropertyDescriptor,Ch=Jd&&!Kd.call({1:2},1);Qd.f=Ch?function(e){var t=Jd(this,e);return!!t&&t.enumerable}:Kd;var xh=Lt,Oh=Fe,Mh=Qd,Bh=tr,Nh=Qi,Fh=Xa,Uh=ut,Vh=xd,eo=Object.getOwnPropertyDescriptor;tn.f=xh?eo:function(e,t){if(e=Nh(e),t=Fh(t),Vh)try{return eo(e,t)}catch(i){}if(Uh(e,t))return Bh(!Oh(Mh.f,e,t),e[t])};var Hh=qe,Gh=Ee,jh=/#|\.prototype\./,Ji=function(s,e){var t=qh[Yh(s)];return t==Wh?!0:t==zh?!1:Gh(e)?Hh(e):!!e},Yh=Ji.normalize=function(s){return String(s).replace(jh,".").toLowerCase()},qh=Ji.data={},zh=Ji.NATIVE="N",Wh=Ji.POLYFILL="P",Xd=Ji,to=Wd,Qh=Xt,Kh=Qs,Jh=to(to.bind),ir=function(s,e){return Qh(s),e===void 0?s:Kh?Jh(s,e):function(){return s.apply(e,arguments)}},hs=we,Xh=zd,Zh=Wd,ef=Ee,tf=tn.f,sf=Xd,oi=Ka,rf=ir,di=Ki,io=ut,af=function(s){var e=function(t,i,r){if(this instanceof e){switch(arguments.length){case 0:return new s;case 1:return new s(t);case 2:return new s(t,i)}return new s(t,i,r)}return Xh(s,this,arguments)};return e.prototype=s.prototype,e},et=function(s,e){var t=s.target,i=s.global,r=s.stat,a=s.proto,n=i?hs:r?hs[t]:(hs[t]||{}).prototype,o=i?oi:oi[t]||di(oi,t,{})[t],u=o.prototype,d,l,c,h,f,g,m,S,b;for(h in e)d=sf(i?h:t+(r?".":"#")+h,s.forced),l=!d&&n&&io(n,h),g=o[h],l&&(s.dontCallGetSet?(b=tf(n,h),m=b&&b.value):m=n[h]),f=l&&m?m:e[h],!(l&&typeof g==typeof f)&&(s.bind&&l?S=rf(f,hs):s.wrap&&l?S=af(f):a&&ef(f)?S=Zh(f):S=f,(s.sham||f&&f.sham||g&&g.sham)&&di(S,"sham",!0),di(o,h,S),a&&(c=t+"Prototype",io(oi,c)||di(oi,c,{}),di(oi[c],h,f),s.real&&u&&(d||!u[h])&&di(u,h,f)))},Aa=Lt,nf=ut,Zd=Function.prototype,of=Aa&&Object.getOwnPropertyDescriptor,sn=nf(Zd,"name"),df=sn&&function(){}.name==="something",uf=sn&&(!Aa||Aa&&of(Zd,"name").configurable),lf={EXISTS:sn,PROPER:df,CONFIGURABLE:uf},eu={},cf=Math.ceil,hf=Math.floor,ff=Math.trunc||function(e){var t=+e;return(t>0?hf:cf)(t)},pf=ff,rn=function(s){var e=+s;return e!==e||e===0?0:pf(e)},mf=rn,vf=Math.max,gf=Math.min,Sf=function(s,e){var t=mf(s);return t<0?vf(t+e,0):gf(t,e)},bf=rn,yf=Math.min,Tf=function(s){return s>0?yf(bf(s),9007199254740991):0},Ef=Tf,an=function(s){return Ef(s.length)},$f=Qi,Af=Sf,wf=an,so=function(s){return function(e,t,i){var r=$f(e),a=wf(r),n=Af(i,a),o;if(s&&t!=t){for(;a>n;)if(o=r[n++],o!=o)return!0}else for(;a>n;n++)if((s||n in r)&&r[n]===t)return s||n||0;return!s&&-1}},kf={includes:so(!0),indexOf:so(!1)},_f=ze,Fr=ut,Pf=Qi,Df=kf.indexOf,Rf=en,ro=_f([].push),If=function(s,e){var t=Pf(s),i=0,r=[],a;for(a in t)!Fr(Rf,a)&&Fr(t,a)&&ro(r,a);for(;e.length>i;)Fr(t,a=e[i++])&&(~Df(r,a)||ro(r,a));return r},tu=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Lf=If,Cf=tu,xf=Object.keys||function(e){return Lf(e,Cf)},Of=Lt,Mf=Od,Bf=Kt,Nf=gt,Ff=Qi,Uf=xf;eu.f=Of&&!Mf?Object.defineProperties:function(e,t){Nf(e);for(var i=Ff(t),r=Uf(t),a=r.length,n=0,o;a>n;)Bf.f(e,o=r[n++],i[o]);return e};var Vf=Jt,iu=Vf("document","documentElement"),Hf=gt,Gf=eu,ao=tu,jf=en,Yf=iu,qf=Qa,zf=Za,no=">",oo="<",wa="prototype",ka="script",su=zf("IE_PROTO"),Ur=function(){},ru=function(s){return oo+ka+no+s+oo+"/"+ka+no},uo=function(s){s.write(ru("")),s.close();var e=s.parentWindow.Object;return s=null,e},Wf=function(){var s=qf("iframe"),e="java"+ka+":",t;return s.style.display="none",Yf.appendChild(s),s.src=String(e),t=s.contentWindow.document,t.open(),t.write(ru("document.F=Object")),t.close(),t.F},fs,Ls=function(){try{fs=new ActiveXObject("htmlfile")}catch(e){}Ls=typeof document!="undefined"?document.domain&&fs?uo(fs):Wf():uo(fs);for(var s=ao.length;s--;)delete Ls[wa][ao[s]];return Ls()};jf[su]=!0;var au=Object.create||function(e,t){var i;return e!==null?(Ur[wa]=Hf(e),i=new Ur,Ur[wa]=null,i[su]=e):i=Ls(),t===void 0?i:Gf.f(i,t)},Qf=qe,Kf=!Qf(function(){function s(){}return s.prototype.constructor=null,Object.getPrototypeOf(new s)!==s.prototype}),Jf=ut,Xf=Ee,Zf=er,ep=Za,tp=Kf,lo=ep("IE_PROTO"),_a=Object,ip=_a.prototype,nu=tp?_a.getPrototypeOf:function(s){var e=Zf(s);if(Jf(e,lo))return e[lo];var t=e.constructor;return Xf(t)&&e instanceof t?t.prototype:e instanceof _a?ip:null},sp=Ki,nn=function(s,e,t,i){return i&&i.enumerable?s[e]=t:sp(s,e,t),s},rp=qe,ap=Ee,np=vt,op=au,co=nu,dp=nn,up=Pe,Pa=up("iterator"),ou=!1,ft,Vr,Hr;[].keys&&(Hr=[].keys(),"next"in Hr?(Vr=co(co(Hr)),Vr!==Object.prototype&&(ft=Vr)):ou=!0);var lp=!np(ft)||rp(function(){var s={};return ft[Pa].call(s)!==s});lp?ft={}:ft=op(ft);ap(ft[Pa])||dp(ft,Pa,function(){return this});var du={IteratorPrototype:ft,BUGGY_SAFARI_ITERATORS:ou},cp=Pe,hp=cp("toStringTag"),uu={};uu[hp]="z";var on=String(uu)==="[object z]",fp=on,pp=Ee,Cs=zi,mp=Pe,vp=mp("toStringTag"),gp=Object,Sp=Cs(function(){return arguments}())=="Arguments",bp=function(s,e){try{return s[e]}catch(t){}},Xi=fp?Cs:function(s){var e,t,i;return s===void 0?"Undefined":s===null?"Null":typeof(t=bp(e=gp(s),vp))=="string"?t:Sp?Cs(e):(i=Cs(e))=="Object"&&pp(e.callee)?"Arguments":i},yp=on,Tp=Xi,Ep=yp?{}.toString:function(){return"[object "+Tp(this)+"]"},$p=on,Ap=Kt.f,wp=Ki,kp=ut,_p=Ep,Pp=Pe,ho=Pp("toStringTag"),dn=function(s,e,t,i){if(s){var r=t?s:s.prototype;kp(r,ho)||Ap(r,ho,{configurable:!0,value:e}),i&&!$p&&wp(r,"toString",_p)}},Dp=du.IteratorPrototype,Rp=au,Ip=tr,Lp=dn,Cp=ki,xp=function(){return this},Op=function(s,e,t,i){var r=e+" Iterator";return s.prototype=Rp(Dp,{next:Ip(+!i,t)}),Lp(s,r,!1,!0),Cp[r]=xp,s},Mp=et,Bp=Fe,lu=lf,Np=Op,Fp=nu,Up=dn,fo=nn,Vp=Pe,po=ki,cu=du,Hp=lu.PROPER;lu.CONFIGURABLE;cu.IteratorPrototype;var ps=cu.BUGGY_SAFARI_ITERATORS,Gr=Vp("iterator"),mo="keys",ms="values",vo="entries",Gp=function(){return this},jp=function(s,e,t,i,r,a,n){Np(t,e,i);var o=function(b){if(b===r&&h)return h;if(!ps&&b in l)return l[b];switch(b){case mo:return function(){return new t(this,b)};case ms:return function(){return new t(this,b)};case vo:return function(){return new t(this,b)}}return function(){return new t(this)}},u=e+" Iterator",d=!1,l=s.prototype,c=l[Gr]||l["@@iterator"]||r&&l[r],h=!ps&&c||o(r),f=e=="Array"&&l.entries||c,g,m,S;if(f&&(g=Fp(f.call(new s)),g!==Object.prototype&&g.next&&(Up(g,u,!0,!0),po[u]=Gp)),Hp&&r==ms&&c&&c.name!==ms&&(d=!0,h=function(){return Bp(c,this)}),r)if(m={values:o(ms),keys:a?h:o(mo),entries:o(vo)},n)for(S in m)(ps||d||!(S in l))&&fo(l,S,m[S]);else Mp({target:e,proto:!0,forced:ps||d},m);return n&&l[Gr]!==h&&fo(l,Gr,h,{name:r}),po[e]=h,m},Yp=function(s,e){return{value:s,done:e}},qp=Qi,go=ki,hu=Yd;Kt.f;var zp=jp,vs=Yp,fu="Array Iterator",Wp=hu.set,Qp=hu.getterFor(fu);zp(Array,"Array",function(s,e){Wp(this,{type:fu,target:qp(s),index:0,kind:e})},function(){var s=Qp(this),e=s.target,t=s.kind,i=s.index++;return!e||i>=e.length?(s.target=void 0,vs(void 0,!0)):t=="keys"?vs(i,!1):t=="values"?vs(e[i],!1):vs([i,e[i]],!1)},"values");go.Arguments=go.Array;var Kp=Pe,Jp=ki,Xp=Kp("iterator"),Zp=Array.prototype,em=function(s){return s!==void 0&&(Jp.Array===s||Zp[Xp]===s)},tm=Xi,So=Zs,im=Wi,sm=ki,rm=Pe,am=rm("iterator"),pu=function(s){if(!im(s))return So(s,am)||So(s,"@@iterator")||sm[tm(s)]},nm=Fe,om=Xt,dm=gt,um=Xs,lm=pu,cm=TypeError,hm=function(s,e){var t=arguments.length<2?lm(s):e;if(om(t))return dm(nm(t,s));throw cm(um(s)+" is not iterable")},fm=Fe,bo=gt,pm=Zs,mm=function(s,e,t){var i,r;bo(s);try{if(i=pm(s,"return"),!i){if(e==="throw")throw t;return t}i=fm(i,s)}catch(a){r=!0,i=a}if(e==="throw")throw t;if(r)throw i;return bo(i),t},vm=ir,gm=Fe,Sm=gt,bm=Xs,ym=em,Tm=an,yo=Ks,Em=hm,$m=pu,To=mm,Am=TypeError,xs=function(s,e){this.stopped=s,this.result=e},Eo=xs.prototype,un=function(s,e,t){var i=t&&t.that,r=!!(t&&t.AS_ENTRIES),a=!!(t&&t.IS_RECORD),n=!!(t&&t.IS_ITERATOR),o=!!(t&&t.INTERRUPTED),u=vm(e,i),d,l,c,h,f,g,m,S=function(A){return d&&To(d,"normal",A),new xs(!0,A)},b=function(A){return r?(Sm(A),o?u(A[0],A[1],S):u(A[0],A[1])):o?u(A,S):u(A)};if(a)d=s.iterator;else if(n)d=s;else{if(l=$m(s),!l)throw Am(bm(s)+" is not iterable");if(ym(l)){for(c=0,h=Tm(s);h>c;c++)if(f=b(s[c]),f&&yo(Eo,f))return f;return new xs(!1)}d=Em(s,l)}for(g=a?s.next:d.next;!(m=gm(g,d)).done;){try{f=b(m.value)}catch(A){To(d,"throw",A)}if(typeof f=="object"&&f&&yo(Eo,f))return f}return new xs(!1)},wm=Xa,km=Kt,_m=tr,Pm=function(s,e,t){var i=wm(e);i in s?km.f(s,i,_m(0,t)):s[i]=t},Dm=et,Rm=un,Im=Pm;Dm({target:"Object",stat:!0},{fromEntries:function(e){var t={};return Rm(e,function(i,r){Im(t,i,r)},{AS_ENTRIES:!0}),t}});var Lm=Ka,Cm=Lm.Object.fromEntries,xm={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},Om=xm,Mm=we,Bm=Xi,Nm=Ki,$o=ki,Fm=Pe,Ao=Fm("toStringTag");for(var jr in Om){var wo=Mm[jr],Yr=wo&&wo.prototype;Yr&&Bm(Yr)!==Ao&&Nm(Yr,Ao,jr),$o[jr]=$o.Array}var Um=Cm,Vm=Um,Hm=Vm,Gm=Hm,Ei=Ws(Gm),jm=zi,sr=typeof process!="undefined"&&jm(process)=="process",Ym=Kt,qm=function(s,e,t){return Ym.f(s,e,t)},zm=Jt,Wm=qm,Qm=Pe,Km=Lt,ko=Qm("species"),Jm=function(s){var e=zm(s);Km&&e&&!e[ko]&&Wm(e,ko,{configurable:!0,get:function(){return this}})},Xm=Ks,Zm=TypeError,ev=function(s,e){if(Xm(e,s))return s;throw Zm("Incorrect invocation")},tv=ze,iv=Ee,Da=Ja,sv=tv(Function.toString);iv(Da.inspectSource)||(Da.inspectSource=function(s){return sv(s)});var mu=Da.inspectSource,rv=ze,av=qe,vu=Ee,nv=Xi,ov=Jt,dv=mu,gu=function(){},uv=[],Su=ov("Reflect","construct"),ln=/^\s*(?:class|function)\b/,lv=rv(ln.exec),cv=!ln.exec(gu),Li=function(e){if(!vu(e))return!1;try{return Su(gu,uv,e),!0}catch(t){return!1}},bu=function(e){if(!vu(e))return!1;switch(nv(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return cv||!!lv(ln,dv(e))}catch(t){return!0}};bu.sham=!0;var hv=!Su||av(function(){var s;return Li(Li.call)||!Li(Object)||!Li(function(){s=!0})||s})?bu:Li,fv=hv,pv=Xs,mv=TypeError,vv=function(s){if(fv(s))return s;throw mv(pv(s)+" is not a constructor")},_o=gt,gv=vv,Sv=Wi,bv=Pe,yv=bv("species"),yu=function(s,e){var t=_o(s).constructor,i;return t===void 0||Sv(i=_o(t)[yv])?e:gv(i)},Tv=ze,Ev=Tv([].slice),$v=TypeError,Av=function(s,e){if(s<e)throw $v("Not enough arguments");return s},wv=Js,Tu=/(?:ipad|iphone|ipod).*applewebkit/i.test(wv),Ne=we,kv=zd,_v=ir,Po=Ee,Pv=ut,Eu=qe,Do=iu,Dv=Ev,Ro=Qa,Rv=Av,Iv=Tu,Lv=sr,Ra=Ne.setImmediate,Ia=Ne.clearImmediate,Cv=Ne.process,qr=Ne.Dispatch,xv=Ne.Function,Io=Ne.MessageChannel,Ov=Ne.String,zr=0,Ni={},Lo="onreadystatechange",ji,Ht,Wr,Qr;Eu(function(){ji=Ne.location});var cn=function(s){if(Pv(Ni,s)){var e=Ni[s];delete Ni[s],e()}},Kr=function(s){return function(){cn(s)}},Co=function(s){cn(s.data)},xo=function(s){Ne.postMessage(Ov(s),ji.protocol+"//"+ji.host)};(!Ra||!Ia)&&(Ra=function(e){Rv(arguments.length,1);var t=Po(e)?e:xv(e),i=Dv(arguments,1);return Ni[++zr]=function(){kv(t,void 0,i)},Ht(zr),zr},Ia=function(e){delete Ni[e]},Lv?Ht=function(s){Cv.nextTick(Kr(s))}:qr&&qr.now?Ht=function(s){qr.now(Kr(s))}:Io&&!Iv?(Wr=new Io,Qr=Wr.port2,Wr.port1.onmessage=Co,Ht=_v(Qr.postMessage,Qr)):Ne.addEventListener&&Po(Ne.postMessage)&&!Ne.importScripts&&ji&&ji.protocol!=="file:"&&!Eu(xo)?(Ht=xo,Ne.addEventListener("message",Co,!1)):Lo in Ro("script")?Ht=function(s){Do.appendChild(Ro("script"))[Lo]=function(){Do.removeChild(this),cn(s)}}:Ht=function(s){setTimeout(Kr(s),0)});var $u={set:Ra,clear:Ia},Au=function(){this.head=null,this.tail=null};Au.prototype={add:function(s){var e={item:s,next:null},t=this.tail;t?t.next=e:this.head=e,this.tail=e},get:function(){var s=this.head;if(s){var e=this.head=s.next;return e===null&&(this.tail=null),s.item}}};var wu=Au,Mv=Js,Bv=/ipad|iphone|ipod/i.test(Mv)&&typeof Pebble!="undefined",Nv=Js,Fv=/web0s(?!.*chrome)/i.test(Nv),Wt=we,Oo=ir,Uv=tn.f,Jr=$u.set,Vv=wu,Hv=Tu,Gv=Bv,jv=Fv,Xr=sr,Mo=Wt.MutationObserver||Wt.WebKitMutationObserver,Bo=Wt.document,No=Wt.process,gs=Wt.Promise,Fo=Uv(Wt,"queueMicrotask"),La=Fo&&Fo.value,ui,Zr,ea,Ss,Uo;if(!La){var bs=new Vv,ys=function(){var s,e;for(Xr&&(s=No.domain)&&s.exit();e=bs.get();)try{e()}catch(t){throw bs.head&&ui(),t}s&&s.enter()};!Hv&&!Xr&&!jv&&Mo&&Bo?(Zr=!0,ea=Bo.createTextNode(""),new Mo(ys).observe(ea,{characterData:!0}),ui=function(){ea.data=Zr=!Zr}):!Gv&&gs&&gs.resolve?(Ss=gs.resolve(void 0),Ss.constructor=gs,Uo=Oo(Ss.then,Ss),ui=function(){Uo(ys)}):Xr?ui=function(){No.nextTick(ys)}:(Jr=Oo(Jr,Wt),ui=function(){Jr(ys)}),La=function(s){bs.head||ui(),bs.add(s)}}var Yv=La,qv=function(s,e){try{arguments.length==1?console.error(s):console.error(s,e)}catch(t){}},hn=function(s){try{return{error:!1,value:s()}}catch(e){return{error:!0,value:e}}},zv=we,_i=zv.Promise,ku=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",Wv=ku,Qv=sr,Kv=!Wv&&!Qv&&typeof window=="object"&&typeof document=="object",Jv=we,Fi=_i,Xv=Ee,Zv=Xd,eg=mu,tg=Pe,ig=Kv,sg=ku,ta=Bd,Vo=Fi&&Fi.prototype,rg=tg("species"),Ca=!1,_u=Xv(Jv.PromiseRejectionEvent),ag=Zv("Promise",function(){var s=eg(Fi),e=s!==String(Fi);if(!e&&ta===66||!(Vo.catch&&Vo.finally))return!0;if(!ta||ta<51||!/native code/.test(s)){var t=new Fi(function(a){a(1)}),i=function(a){a(function(){},function(){})},r=t.constructor={};if(r[rg]=i,Ca=t.then(function(){})instanceof i,!Ca)return!0}return!e&&(ig||sg)&&!_u}),Zi={CONSTRUCTOR:ag,REJECTION_EVENT:_u,SUBCLASSING:Ca},Pi={},Ho=Xt,ng=TypeError,og=function(s){var e,t;this.promise=new s(function(i,r){if(e!==void 0||t!==void 0)throw ng("Bad Promise constructor");e=i,t=r}),this.resolve=Ho(e),this.reject=Ho(t)};Pi.f=function(s){return new og(s)};var dg=et,Us=sr,It=we,es=Fe,ug=nn,lg=dn,cg=Jm,hg=Xt,xa=Ee,fg=vt,pg=ev,mg=yu,Pu=$u.set,fn=Yv,vg=qv,gg=hn,Sg=wu,Du=Yd,Oa=_i,pn=Zi,Ru=Pi,rr="Promise",Iu=pn.CONSTRUCTOR,bg=pn.REJECTION_EVENT;pn.SUBCLASSING;var ia=Du.getterFor(rr),yg=Du.set,Tg=Oa&&Oa.prototype,mi=Oa,sa=Tg,Lu=It.TypeError,Ma=It.document,mn=It.process,Ba=Ru.f,Eg=Ba,$g=!!(Ma&&Ma.createEvent&&It.dispatchEvent),Cu="unhandledrejection",Ag="rejectionhandled",Go=0,xu=1,wg=2,vn=1,Ou=2,Ts,jo,kg,Mu=function(s){var e;return fg(s)&&xa(e=s.then)?e:!1},Bu=function(s,e){var t=e.value,i=e.state==xu,r=i?s.ok:s.fail,a=s.resolve,n=s.reject,o=s.domain,u,d,l;try{r?(i||(e.rejection===Ou&&Pg(e),e.rejection=vn),r===!0?u=t:(o&&o.enter(),u=r(t),o&&(o.exit(),l=!0)),u===s.promise?n(Lu("Promise-chain cycle")):(d=Mu(u))?es(d,u,a,n):a(u)):n(t)}catch(c){o&&!l&&o.exit(),n(c)}},Nu=function(s,e){s.notified||(s.notified=!0,fn(function(){for(var t=s.reactions,i;i=t.get();)Bu(i,s);s.notified=!1,e&&!s.rejection&&_g(s)}))},Fu=function(s,e,t){var i,r;$g?(i=Ma.createEvent("Event"),i.promise=e,i.reason=t,i.initEvent(s,!1,!0),It.dispatchEvent(i)):i={promise:e,reason:t},!bg&&(r=It["on"+s])?r(i):s===Cu&&vg("Unhandled promise rejection",t)},_g=function(s){es(Pu,It,function(){var e=s.facade,t=s.value,i=Yo(s),r;if(i&&(r=gg(function(){Us?mn.emit("unhandledRejection",t,e):Fu(Cu,e,t)}),s.rejection=Us||Yo(s)?Ou:vn,r.error))throw r.value})},Yo=function(s){return s.rejection!==vn&&!s.parent},Pg=function(s){es(Pu,It,function(){var e=s.facade;Us?mn.emit("rejectionHandled",e):Fu(Ag,e,s.value)})},vi=function(s,e,t){return function(i){s(e,i,t)}},bi=function(s,e,t){s.done||(s.done=!0,t&&(s=t),s.value=e,s.state=wg,Nu(s,!0))},Na=function(s,e,t){if(!s.done){s.done=!0,t&&(s=t);try{if(s.facade===e)throw Lu("Promise can't be resolved itself");var i=Mu(e);i?fn(function(){var r={done:!1};try{es(i,e,vi(Na,r,s),vi(bi,r,s))}catch(a){bi(r,a,s)}}):(s.value=e,s.state=xu,Nu(s,!1))}catch(r){bi({done:!1},r,s)}}};Iu&&(mi=function(e){pg(this,sa),hg(e),es(Ts,this);var t=ia(this);try{e(vi(Na,t),vi(bi,t))}catch(i){bi(t,i)}},sa=mi.prototype,Ts=function(e){yg(this,{type:rr,done:!1,notified:!1,parent:!1,reactions:new Sg,rejection:!1,state:Go,value:void 0})},Ts.prototype=ug(sa,"then",function(e,t){var i=ia(this),r=Ba(mg(this,mi));return i.parent=!0,r.ok=xa(e)?e:!0,r.fail=xa(t)&&t,r.domain=Us?mn.domain:void 0,i.state==Go?i.reactions.add(r):fn(function(){Bu(r,i)}),r.promise}),jo=function(){var s=new Ts,e=ia(s);this.promise=s,this.resolve=vi(Na,e),this.reject=vi(bi,e)},Ru.f=Ba=function(s){return s===mi||s===kg?new jo(s):Eg(s)});dg({global:!0,constructor:!0,wrap:!0,forced:Iu},{Promise:mi});lg(mi,rr,!1,!0);cg(rr);var Dg=Pe,Uu=Dg("iterator"),Vu=!1;try{var Rg=0,qo={next:function(){return{done:!!Rg++}},return:function(){Vu=!0}};qo[Uu]=function(){return this},Array.from(qo,function(){throw 2})}catch(s){}var Ig=function(s,e){if(!e&&!Vu)return!1;var t=!1;try{var i={};i[Uu]=function(){return{next:function(){return{done:t=!0}}}},s(i)}catch(r){}return t},Lg=_i,Cg=Ig,xg=Zi.CONSTRUCTOR,Hu=xg||!Cg(function(s){Lg.all(s).then(void 0,function(){})}),Og=et,Mg=Fe,Bg=Xt,Ng=Pi,Fg=hn,Ug=un,Vg=Hu;Og({target:"Promise",stat:!0,forced:Vg},{all:function(e){var t=this,i=Ng.f(t),r=i.resolve,a=i.reject,n=Fg(function(){var o=Bg(t.resolve),u=[],d=0,l=1;Ug(e,function(c){var h=d++,f=!1;l++,Mg(o,t,c).then(function(g){f||(f=!0,u[h]=g,--l||r(u))},a)}),--l||r(u)});return n.error&&a(n.value),i.promise}});var Hg=et,Gg=Zi.CONSTRUCTOR,zo=_i;zo&&zo.prototype;Hg({target:"Promise",proto:!0,forced:Gg,real:!0},{catch:function(s){return this.then(void 0,s)}});var jg=et,Yg=Fe,qg=Xt,zg=Pi,Wg=hn,Qg=un,Kg=Hu;jg({target:"Promise",stat:!0,forced:Kg},{race:function(e){var t=this,i=zg.f(t),r=i.reject,a=Wg(function(){var n=qg(t.resolve);Qg(e,function(o){Yg(n,t,o).then(i.resolve,r)})});return a.error&&r(a.value),i.promise}});var Jg=et,Xg=Fe,Zg=Pi,eS=Zi.CONSTRUCTOR;Jg({target:"Promise",stat:!0,forced:eS},{reject:function(e){var t=Zg.f(this);return Xg(t.reject,void 0,e),t.promise}});var tS=gt,iS=vt,sS=Pi,Gu=function(s,e){if(tS(s),iS(e)&&e.constructor===s)return e;var t=sS.f(s),i=t.resolve;return i(e),t.promise},rS=et,aS=Jt,nS=Mc,oS=_i,dS=Zi.CONSTRUCTOR,uS=Gu,lS=aS("Promise"),cS=!dS;rS({target:"Promise",stat:!0,forced:nS},{resolve:function(e){return uS(cS&&this===lS?oS:this,e)}});var hS=et,Fa=_i,fS=qe,pS=Jt,mS=Ee,vS=yu,Wo=Gu,gS=Fa&&Fa.prototype,SS=!!Fa&&fS(function(){gS.finally.call({then:function(){}},function(){})});hS({target:"Promise",proto:!0,real:!0,forced:SS},{finally:function(s){var e=vS(this,pS("Promise")),t=mS(s);return this.then(t?function(i){return Wo(e,s()).then(function(){return i})}:s,t?function(i){return Wo(e,s()).then(function(){throw i})}:s)}});var bS=Jt,gn=bS,yS=gn,TS=yS("Promise","finally"),ES=TS,$S=ES,AS=$S,wS=AS,ar=Ws(wS),Te;(function(s){s[s.OFFSET_P=0]="OFFSET_P",s[s.PLAYBACK_SHIFT=1]="PLAYBACK_SHIFT",s[s.DASH_CMAF_OFFSET_P=2]="DASH_CMAF_OFFSET_P"})(Te||(Te={}));var Xe=(s,e=0,t=Te.OFFSET_P)=>{switch(t){case Te.OFFSET_P:return s.replace("_offset_p",e===0?"":"_"+e.toFixed(0));case Te.PLAYBACK_SHIFT:{if(e===0)return s;const i=new URL(s);return i.searchParams.append("playback_shift",e.toFixed(0)),i.toString()}case Te.DASH_CMAF_OFFSET_P:{const i=new URL(s);return!i.searchParams.get("offset_p")&&e===0?s:(i.searchParams.set("offset_p",e.toFixed(0)),i.toString())}default:j(t)}return s};const Qo=(s,e)=>{var t;switch(e){case Te.OFFSET_P:return NaN;case Te.PLAYBACK_SHIFT:{const i=new URL(s);return Number(i.searchParams.get("playback_shift"))}case Te.DASH_CMAF_OFFSET_P:{const i=new URL(s);return Number((t=i.searchParams.get("offset_p"))!==null&&t!==void 0?t:0)}default:j(e)}};var R=(s,e,t=!1)=>{const i=s.getTransition();(t||!i||i.to===e)&&s.setState(e)};class he{constructor(e){this.transitionStarted$=new M,this.transitionEnded$=new M,this.transitionUpdated$=new M,this.forceChanged$=new M,this.stateChangeStarted$=H(this.transitionStarted$,this.transitionUpdated$),this.stateChangeEnded$=H(this.transitionEnded$,this.forceChanged$),this.state=e,this.prevState=void 0}setState(e){const t=this.transition,i=this.state;this.transition=void 0,this.prevState=i,this.state=e,t?t.to===e?this.transitionEnded$.next(t):this.forceChanged$.next({from:t.from,to:e,canceledTransition:t}):this.forceChanged$.next({from:i,to:e,canceledTransition:t})}startTransitionTo(e){const t=this.transition,i=this.state;i===e||_(t)&&t.to===e||(this.prevState=i,this.state=e,t?(this.transition={from:t.from,to:e,canceledTransition:t},this.transitionUpdated$.next(this.transition)):(this.transition={from:i,to:e},this.transitionStarted$.next(this.transition)))}getTransition(){return this.transition}getState(){return this.state}getPrevState(){return this.prevState}}const kS=s=>{switch(s){case E.MPEG:case E.DASH:case E.DASH_SEP:case E.DASH_ONDEMAND:case E.DASH_WEBM:case E.DASH_WEBM_AV1:case E.HLS:case E.HLS_ONDEMAND:return!1;case E.DASH_LIVE:case E.DASH_LIVE_CMAF:case E.HLS_LIVE:case E.HLS_LIVE_CMAF:case E.DASH_LIVE_WEBM:case E.WEB_RTC_LIVE:return!0;default:return j(s)}};var z;(function(s){s.STOPPED="stopped",s.READY="ready",s.PLAYING="playing",s.PAUSED="paused"})(z||(z={}));const _S=5,PS=5,DS=500,Ko=7e3;class RS{constructor(e){this.subscription=new ne,this.loadMediaTimeoutSubscription=new ne,this.videoState=new he(z.STOPPED),this.syncPlayback=()=>{const i=this.videoState.getState(),r=this.videoState.getTransition(),a=this.params.desiredState.playbackState.getState(),n=this.params.desiredState.playbackState.getTransition(),o=this.params.desiredState.seekState.getState();if(this.log({message:`[syncPlayback] videoState: ${i}; videoTransition: ${JSON.stringify(r)}; desiredPlaybackState: ${a}; desiredPlaybackStateTransition: ${this.params.desiredState.playbackState.getTransition()}; seekState: ${JSON.stringify(o)};`}),a===p.STOPPED){i!==z.STOPPED&&(this.videoState.startTransitionTo(z.STOPPED),this.stop());return}if(!r){if((n==null?void 0:n.to)!==p.PAUSED&&o.state===K.Requested&&i!==z.STOPPED){this.seek(o.position/1e3);return}switch(a){case p.READY:{switch(i){case z.PLAYING:case z.PAUSED:case z.READY:break;case z.STOPPED:this.videoState.startTransitionTo(z.READY),this.prepare();break;default:j(i)}break}case p.PLAYING:{switch(i){case z.PLAYING:break;case z.PAUSED:this.videoState.startTransitionTo(z.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case z.READY:this.videoState.startTransitionTo(z.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case z.STOPPED:this.videoState.startTransitionTo(z.READY),this.prepare();break;default:j(i)}break}case p.PAUSED:{switch(i){case z.PLAYING:this.videoState.startTransitionTo(z.PAUSED),this.params.connection.remotePlayerController.playOrPause();break;case z.PAUSED:break;case z.READY:this.videoState.startTransitionTo(z.PAUSED),this.videoState.setState(z.PAUSED);break;case z.STOPPED:this.videoState.startTransitionTo(z.READY),this.prepare();break;default:j(i)}break}default:j(a)}}},this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastProvider"),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(kS(e.format)),this.params.output.isAudioAvailable$.next(!0),this.handleRemoteVolumeChange({volume:this.params.connection.remotePlayer.volumeLevel,muted:this.params.connection.remotePlayer.isMuted});const t=this.params.connection.session.getMediaSession();t&&this.restoreSession(t),this.subscribe()}destroy(){this.log({message:"[destroy]"}),this.subscription.unsubscribe()}subscribe(){this.subscription.add(this.loadMediaTimeoutSubscription);const e=new ne;this.subscription.add(e),this.subscription.add(H(this.videoState.stateChangeStarted$.pipe(k(r=>`stateChangeStarted$ ${JSON.stringify(r)}`)),this.videoState.stateChangeEnded$.pipe(k(r=>`stateChangeEnded$ ${JSON.stringify(r)}`))).subscribe(r=>this.log({message:`[videoState] ${r}`})));const t=(r,a)=>this.subscription.add(r.subscribe(a));if(this.params.output.isLive$.getValue())this.params.output.position$.next(0),this.params.output.duration$.next(0);else{const r=new M;e.add(r.pipe(Ye(DS)).subscribe(()=>{this.params.output.seekedEvent$.next()}));let a=NaN;e.add(U(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED).subscribe(n=>{this.logRemoteEvent(n);const o=n.value;this.params.output.position$.next(o),(this.params.desiredState.seekState.getState().state===K.Applying||Math.abs(o-a)>_S)&&r.next(o),a=o})),e.add(U(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.DURATION_CHANGED).subscribe(n=>{this.logRemoteEvent(n),this.params.output.duration$.next(n.value)}))}t(U(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED),r=>{this.logRemoteEvent(r),r.value?this.handleRemoteReady():(this.handleRemoteStop(),e.unsubscribe())}),t(U(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),r=>{this.logRemoteEvent(r),r.value?this.handleRemotePause():this.handleRemotePlay()}),t(U(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED),r=>{this.logRemoteEvent(r);const{remotePlayer:a}=this.params.connection,n=r.value,o=this.params.output.isBuffering$.getValue(),u=n===chrome.cast.media.PlayerState.BUFFERING;switch(o!==u&&this.params.output.isBuffering$.next(u),n){case chrome.cast.media.PlayerState.IDLE:!this.params.output.isLive$.getValue()&&a.duration-a.currentTime<PS&&this.params.output.endedEvent$.next(),this.handleRemoteStop(),R(this.params.desiredState.playbackState,p.STOPPED);break;case chrome.cast.media.PlayerState.PAUSED:{this.handleRemotePause();break}case chrome.cast.media.PlayerState.PLAYING:this.handleRemotePlay();break;case chrome.cast.media.PlayerState.BUFFERING:break;default:j(n)}}),t(U(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED),r=>{this.logRemoteEvent(r),this.handleRemoteVolumeChange({volume:r.value})}),t(U(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),r=>{this.logRemoteEvent(r),this.handleRemoteVolumeChange({muted:r.value})});const i=H(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,Ce(["init"])).pipe(Ye(0));t(i,this.syncPlayback)}restoreSession(e){this.log({message:"restoreSession"});const{remotePlayer:t}=this.params.connection;if(e.playerState!==chrome.cast.media.PlayerState.IDLE){t.isPaused?(this.videoState.setState(z.PAUSED),R(this.params.desiredState.playbackState,p.PAUSED)):(this.videoState.setState(z.PLAYING),R(this.params.desiredState.playbackState,p.PLAYING));const i=this.params.output.isLive$.getValue();this.params.output.duration$.next(i?0:t.duration),this.params.output.position$.next(i?0:t.currentTime),this.params.desiredState.seekState.setState({state:K.None})}}prepare(){const e=this.params.format;this.log({message:`[prepare] format: ${e}`});const t=this.createMediaInfo(e),i=this.createLoadRequest(t);this.loadMedia(i)}handleRemotePause(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===z.PAUSED||e===z.PLAYING)&&(this.videoState.setState(z.PAUSED),R(this.params.desiredState.playbackState,p.PAUSED))}handleRemotePlay(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===z.PLAYING||e===z.PAUSED)&&(this.videoState.setState(z.PLAYING),R(this.params.desiredState.playbackState,p.PLAYING))}handleRemoteReady(){var e;const t=this.videoState.getTransition();(t==null?void 0:t.to)===z.READY&&this.videoState.setState(z.READY),((e=this.params.desiredState.playbackState.getTransition())===null||e===void 0?void 0:e.to)===p.READY&&R(this.params.desiredState.playbackState,p.READY)}handleRemoteStop(){this.videoState.getState()!==z.STOPPED&&this.videoState.setState(z.STOPPED)}handleRemoteVolumeChange(e){var t,i;const r=this.params.output.volume$.getValue(),a={volume:(t=e.volume)!==null&&t!==void 0?t:r.volume,muted:(i=e.muted)!==null&&i!==void 0?i:r.muted};(a.volume!==r.volume||a.muted!==a.muted)&&this.params.output.volume$.next(a)}seek(e){this.params.output.willSeekEvent$.next();const{remotePlayer:t,remotePlayerController:i}=this.params.connection;t.currentTime=e,i.seek()}stop(){const{remotePlayerController:e}=this.params.connection;e.stop()}createMediaInfo(e){var t;const i=this.params.source;let r,a,n;switch(e){case E.MPEG:{const l=i[e];P(l);const c=_l(Object.keys(l));P(c);const h=l[c];P(h),r=h,a="video/mp4",n=chrome.cast.media.StreamType.BUFFERED;break}case E.HLS:case E.HLS_ONDEMAND:{const l=i[e];P(l),r=l.url,a="application/x-mpegurl",n=chrome.cast.media.StreamType.BUFFERED;break}case E.DASH_SEP:case E.DASH_ONDEMAND:case E.DASH_WEBM:case E.DASH_WEBM_AV1:{const l=i[e];P(l),r=l.url,a="application/dash+xml",n=chrome.cast.media.StreamType.BUFFERED;break}case E.DASH_LIVE_CMAF:{const l=i[e];P(l),r=l.url,a="application/dash+xml",n=chrome.cast.media.StreamType.LIVE;break}case E.HLS_LIVE:case E.HLS_LIVE_CMAF:{const l=i[e];P(l),r=Xe(l.url),a="application/x-mpegurl",n=chrome.cast.media.StreamType.LIVE;break}case E.DASH:case E.DASH_LIVE:case E.WEB_RTC_LIVE:{const l="Unsupported format for Chromecast",c=new Error(l);throw this.params.output.error$.next({id:"ChromecastProvider.createMediaInfo()",category:O.VIDEO_PIPELINE,message:l,thrown:c}),c}case E.DASH_LIVE_WEBM:throw new Error("DASH_LIVE_WEBM is no longer supported");default:return j(e)}const o=new chrome.cast.media.MediaInfo((t=this.params.meta.videoId)!==null&&t!==void 0?t:r,a);o.contentUrl=r,o.streamType=n,o.metadata=new chrome.cast.media.GenericMediaMetadata;const{title:u,subtitle:d}=this.params.meta;return _(u)&&(o.metadata.title=u),_(d)&&(o.metadata.subtitle=d),o}createLoadRequest(e){const t=new chrome.cast.media.LoadRequest(e);t.autoplay=!1;const i=this.params.desiredState.seekState.getState();return i.state===K.Applying||i.state===K.Requested?t.currentTime=this.params.output.isLive$.getValue()?0:i.position/1e3:t.currentTime=0,t}loadMedia(e){const t=this.params.connection.session.loadMedia(e),i=new Promise((r,a)=>{this.loadMediaTimeoutSubscription.add(Pl(Ko).subscribe(()=>a(`timeout(${Ko})`)))});ar(Promise.race([t,i]).then(()=>{this.log({message:`[loadMedia] completed, format: ${this.params.format}`}),this.params.desiredState.seekState.getState().state===K.Applying&&this.params.output.seekedEvent$.next(),this.handleRemoteReady()},r=>{const a=`[prepare] loadMedia failed, format: ${this.params.format}, reason: ${r}`;this.log({message:a}),this.params.output.error$.next({id:"ChromecastProvider.loadMedia",category:O.VIDEO_PIPELINE,message:a,thrown:r})}),()=>{this.loadMediaTimeoutSubscription.unsubscribe()})}logRemoteEvent(e){this.log({message:`[remoteEvent] ${JSON.stringify(e)}`})}}var IS=s=>{let e,t=!1,i=!1;s.on("playbackTimeUpdated",({timeToEnd:r})=>{i=r<=3,t&&i&&(e==null||e())}),s.extend("MediaSourceController",function(){const{parent:r}=this,a=r.signalEndOfStream;return{signalEndOfStream:n=>{t=!0,e=()=>a(n),t&&i&&(e==null||e())}}},!0)},LS=s=>{const e=new y(1/0),t=new M,i=new y(void 0),r=new y(void 0);let a=NaN,n=!1;const o=()=>{a=Date.now(),n=!1},u=l=>{var c,h,f,g,m;const S=Ei(l.getAllResponseHeaders().trim().split(/[\n\r]+/).map(v=>v.split(": ")));if("x-playback-duration"in S||"x-playback-duration-millis"in S){const v=parseInt((c=l.getResponseHeader("X-Playback-Duration"))!==null&&c!==void 0?c:"",10),T=parseInt((h=l.getResponseHeader("X-Playback-Duration-Millis"))!==null&&h!==void 0?h:"",10),$=(f=T!=null?T:v*1e3)!==null&&f!==void 0?f:NaN;_($)&&!isNaN($)&&e.next($)}const b=(g=S["x-delivery-type"])!==null&&g!==void 0?g:Hi.HTTP1,A=(m={1:!0,0:!1}[S["x-reused"]])!==null&&m!==void 0?m:void 0;i.next(b),r.next(A)},d=l=>{l.readyState>=2&&!n&&(n=!0,t.next(Date.now()-a))};return s.extend("XHRLoader",function(){const{parent:l}=this,c=l.load.bind(l);return{load:function(h){if(h.request.type==="MPD"){const f=h.onload,g=h.progress;h.onload=function(...m){return u(this),f(...m)},h.progress=function(...m){return d(this),g(...m)},o()}return c(h)}}},!0),{playbackDuration$:e,ping$:t,connectionReused$:r,connectionType$:i}},$i=s=>{const e=new URL(s);return e.searchParams.set("quic","1"),e.toString()},CS=s=>s.extend("RequestModifier",()=>({modifyRequestURL:$i}),!0),xS=s=>{s.extend("HTTPLoader",function(){const{parent:e}=this,t=e.load;return{load:i=>{if(i.request&&i.request.range){const[r,a]=i.request.range.split("-").map(o=>parseInt(o,10)),n=new URL(i.request.url,location.href);n.searchParams.append("bytes",`${r}-${a}`),i.request.url=n.toString(),i.request.range=void 0}t(i)}}},!0)};const Ze=(s,e,t,{equal:i=(n,o)=>n===o,changed$:r,onError:a}={})=>{const n=s.getState(),o=e(),u=te(r),d=new ne;return r&&d.add(r.subscribe(l=>{const c=s.getState();i(l,c)&&s.setState(l)},a)),i(o,n)||(t(n),u&&s.setState(n)),d.add(s.stateChangeStarted$.subscribe(l=>{t(l.to),u&&s.setState(l.to)},a)),d},Zt=(s,e,t)=>Ze(e,()=>s.loop,i=>{_(i)&&(s.loop=i)},{onError:t}),St=(s,e,t,i)=>Ze(e,()=>({muted:s.muted,volume:s.volume}),r=>{_(r)&&(s.muted=r.muted,s.volume=r.volume)},{equal:(r,a)=>r===a||(r==null?void 0:r.muted)===(a==null?void 0:a.muted)&&(r==null?void 0:r.volume)===(a==null?void 0:a.volume),changed$:t,onError:i}),Ct=(s,e,t,i)=>Ze(e,()=>s.playbackRate,r=>{_(r)&&(s.playbackRate=r)},{changed$:t,onError:i}),OS=s=>["__",s.language,s.label].join("|"),MS=(s,e)=>{if(s.id===e)return!0;const[t,i,r]=e.split("|");return s.language===i&&s.label===r};class lt{constructor(){this.available$=new M,this.current$=new y(void 0),this.error$=new M,this.subscription=new ne,this.externalTracks=new Map,this.internalTracks=new Map}connect(e,t,i){this.video=e,this.cueSettings=t.textTrackCuesSettings,this.subscribe();const r=a=>{this.error$.next({id:"TextTracksManager",category:O.WTF,message:"Generic HtmlVideoTextTrackManager error",thrown:a})};this.subscription.add(this.available$.subscribe(i.availableTextTracks$)),this.subscription.add(this.current$.subscribe(i.currentTextTrack$)),this.subscription.add(this.error$.subscribe(i.error$)),this.subscription.add(Ze(t.internalTextTracks,()=>Object.values(this.internalTracks),a=>{_(a)&&this.setInternal(a)},{equal:(a,n)=>_(a)&&_(n)&&a.length===n.length&&a.every(({id:o},u)=>o===n[u].id),changed$:this.available$.pipe(k(a=>a.filter(({type:n})=>n==="internal"))),onError:r})),this.subscription.add(Ze(t.externalTextTracks,()=>Object.values(this.externalTracks),a=>{_(a)&&this.setExternal(a)},{equal:(a,n)=>_(a)&&_(n)&&a.length===n.length&&a.every(({id:o},u)=>o===n[u].id),changed$:this.available$.pipe(k(a=>a.filter(({type:n})=>n==="external"))),onError:r})),this.subscription.add(Ze(t.currentTextTrack,()=>{if(this.video)return;const a=this.htmlTextTracksAsArray().find(({mode:n})=>n==="showing");return a&&this.htmlTextTrackToITextTrack(a).id},a=>this.select(a),{changed$:this.current$,onError:r})),this.subscription.add(Ze(t.textTrackCuesSettings,()=>({}),()=>{if(this.video)for(const a of this.htmlTextTracksAsArray())this.applyCueSettings(a.cues),this.applyCueSettings(a.activeCues)}))}subscribe(){P(this.video);const{textTracks:e}=this.video;this.subscription.add(U(e,"addtrack").subscribe(()=>{const i=this.current$.getValue();i&&this.select(i)})),this.subscription.add(H(U(e,"addtrack"),U(e,"removetrack"),Ce(["init"])).pipe(k(()=>this.htmlTextTracksAsArray().map(i=>this.htmlTextTrackToITextTrack(i))),me((i,r)=>i.length===r.length&&i.every(({id:a},n)=>a===r[n].id))).subscribe(this.available$)),this.subscription.add(H(U(e,"change"),Ce(["init"])).pipe(k(()=>this.htmlTextTracksAsArray().find(({mode:i})=>i==="showing")),k(i=>i&&this.htmlTextTrackToITextTrack(i).id),me()).subscribe(this.current$));const t=i=>{var r,a;return this.applyCueSettings((a=(r=i.target)===null||r===void 0?void 0:r.activeCues)!==null&&a!==void 0?a:null)};this.subscription.add(U(e,"addtrack").subscribe(i=>{var r,a;(r=i.track)===null||r===void 0||r.addEventListener("cuechange",t);const n=o=>{var u,d,l,c,h;const f=(d=(u=o.target)===null||u===void 0?void 0:u.cues)!==null&&d!==void 0?d:null;f&&f.length&&(this.applyCueSettings((c=(l=o.target)===null||l===void 0?void 0:l.cues)!==null&&c!==void 0?c:null),(h=o.target)===null||h===void 0||h.removeEventListener("cuechange",n))};(a=i.track)===null||a===void 0||a.addEventListener("cuechange",n)})),this.subscription.add(U(e,"removetrack").subscribe(i=>{var r;(r=i.track)===null||r===void 0||r.removeEventListener("cuechange",t)}))}applyCueSettings(e){if(!e||!e.length)return;const t=this.cueSettings.getState();for(const i of Array.from(e)){const r=i;_(t.align)&&(r.align=t.align),_(t.position)&&(r.position=t.position),_(t.size)&&(r.size=t.size),_(t.line)&&(r.line=t.line)}}htmlTextTracksAsArray(e=!1){P(this.video);const t=[...this.video.textTracks];return e?t:t.filter(lt.isHealthyTrack)}htmlTextTrackToITextTrack(e){var t,i;const{language:r,label:a}=e,n=e.id?e.id:OS(e),o=this.externalTracks.has(n),u=n.includes("auto");return o?{id:n,type:"external",isAuto:u,language:r,label:a,url:(t=this.externalTracks.get(n))===null||t===void 0?void 0:t.url}:{id:n,type:"internal",isAuto:u,language:r,label:a,url:(i=this.internalTracks.get(n))===null||i===void 0?void 0:i.url}}static isHealthyTrack(e){return!(e.kind==="metadata"||e.groupId||e.id===""&&e.label===""&&e.language==="")}setExternal(e){this.internalTracks.size>0&&Array.from(this.internalTracks).forEach(([,t])=>this.detach(t)),e.filter(({id:t})=>!this.externalTracks.has(t)).forEach(t=>this.attach(t)),Array.from(this.externalTracks).filter(([t])=>!e.find(i=>i.id===t)).forEach(([,t])=>this.detach(t))}setInternal(e){const t=[...this.externalTracks];e.filter(({id:i,language:r,isAuto:a})=>!this.internalTracks.has(i)&&!t.some(([,n])=>n.language===r&&n.isAuto===a)).forEach(i=>this.attach(i)),Array.from(this.internalTracks).filter(([i])=>!e.find(r=>r.id===i)).forEach(([,i])=>this.detach(i))}select(e){P(this.video);for(const t of this.htmlTextTracksAsArray(!0))t.mode="showing";for(const t of this.htmlTextTracksAsArray(!0))(te(e)||!MS(t,e))&&(t.mode="disabled")}destroy(){if(this.subscription.unsubscribe(),this.video)for(const e of Array.from(this.video.getElementsByTagName("track"))){const t=e.getAttribute("id");t&&this.externalTracks.has(t)&&this.video.removeChild(e)}this.externalTracks.clear()}attach(e){P(this.video);const t=document.createElement("track");t.setAttribute("src",e.url),t.setAttribute("id",e.id),e.label&&t.setAttribute("label",e.label),e.language&&t.setAttribute("srclang",e.language),e.type==="external"?this.externalTracks.set(e.id,e):e.type==="internal"&&this.internalTracks.set(e.id,e),this.video.appendChild(t)}detach(e){P(this.video);const t=Array.prototype.find.call(this.video.getElementsByTagName("track"),i=>i.getAttribute("id")===e.id);t&&this.video.removeChild(t),e.type==="external"?this.externalTracks.delete(e.id):e.type==="internal"&&this.internalTracks.delete(e.id)}}const Sn=s=>{s.removeAttribute("src"),s.load()},BS=s=>{try{s.pause(),s.playbackRate=0,Sn(s),s.remove()}catch(e){console.error(e)}};class NS{constructor(){this.attribute="data-pool-reused"}get(e){return e.hasAttribute(this.attribute)}set(e,t){e.toggleAttribute(this.attribute,t)}delete(e){e.removeAttribute(this.attribute)}}const Ua=window.WeakMap?new WeakMap:new NS,bt=s=>{let e=s.querySelector("video");const t=!!e;return e?Sn(e):(e=document.createElement("video"),s.appendChild(e)),Ua.set(e,t),e.setAttribute("crossorigin","anonymous"),e.setAttribute("playsinline","playsinline"),e.controls=!1,e.setAttribute("poster","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),e},yt=s=>{const e=Ua.get(s);Ua.delete(s),e?Sn(s):BS(s)};class nr{constructor(){this.pausedTime=0,this.streamOffset=0,this.pauseTimestamp=0}getTotalPausedTime(){return this.pausedTime+this.getCurrentPausedTime()}getCurrentPausedTime(){return this.pauseTimestamp>0?Date.now()-this.pauseTimestamp:0}getStreamOffset(){return this.streamOffset}getTotalOffset(){return this.getTotalPausedTime()+this.streamOffset}pause(){this.pauseTimestamp===0&&(this.pauseTimestamp=Date.now())}resume(){this.pauseTimestamp>0&&(this.pausedTime+=this.getCurrentPausedTime(),this.pauseTimestamp=0)}resetTo(e,t=!1){this.streamOffset=e,this.pauseTimestamp=0,this.pausedTime=0,t&&this.pause()}}const ju=s=>{var e;let t=s;for(;!(t instanceof Document)&&!(t instanceof ShadowRoot)&&t!==null;)t=t==null?void 0:t.parentNode;return(e=t)!==null&&e!==void 0?e:void 0},Jo=s=>{const e=ju(s);return!!(e&&e.fullscreenElement&&e.fullscreenElement===s)},FS=s=>{const e=ju(s);return!!(e&&e.pictureInPictureElement&&e.pictureInPictureElement===s)},Va=3;class US{constructor(e){this._buffer=[],this._source=e}fill(){this._buffer=[];const e=this._source.currentTime;for(let t=0,i=this._source.buffered.length;t<i;t++){let r=this._source.buffered.start(t);const a=this._source.buffered.end(t);r>e&&r-e<Va&&(r=e),this._buffer.push({from:r,to:a,i:t})}return this._buffer.sort(function(t,i){return t.from-i.from}),this._buffer}getByTime(e){return this._buffer.find(t=>e>=t.from&&e<t.to)}getNextWithGap(e,t){const i=this.getNext(e);if(i&&i.from-e.to<(t||Va))return i}getNext(e){let t=this._buffer.indexOf(e);if(~t&&this._buffer.length-1>t)return this._buffer[++t]}smartRemove(e,t,i){this._buffer.forEach(({from:r,to:a})=>{const n=r>=e&&r<t,o=a>=e&&a<t;n&&o||(n?i(t,a):o?i(r,e):r<e&&a>t?(i(t,a),i(r,e)):i(r,a))})}destroy(){this._buffer=[]}}var Yu=(s,e,t=Va)=>{let i=0,r=0;for(let a=0;a<s.length;a++){const n=s.start(a),o=s.end(a);if(n<=e&&e<=o){if(i=n,r=o,!t)return{from:i,to:r};for(let u=a-1;u>=0;u--)s.end(u)+t>=i&&(i=s.start(u));for(let u=a+1;u<s.length;u++)s.start(u)-t<=r&&(r=s.end(u))}}return{from:i,to:r}};const Tt=s=>{const e=v=>U(s,v).pipe(Ti(void 0)),i=H(...["waiting","pause","canplay","play","canplaythrough","playing","seeking","seeked","ended"].map(v=>U(s,v))).pipe(k(v=>v.type==="ended"?s.readyState<2:s.readyState<3),me()),r=H(U(s,"progress"),U(s,"timeupdate")).pipe(k(()=>Yu(s.buffered,s.currentTime))),n=za().browser===kd.Safari?Le({play:e("play").pipe(ge()),playing:e("playing")}).pipe(Ti(void 0)):e("playing"),o=U(s,"volumechange").pipe(k(()=>({muted:s.muted,volume:s.volume}))),u=U(s,"ratechange").pipe(k(()=>s.playbackRate)),d=U(s,"error").pipe(X(()=>!!(s.error||s.played.length)),k(()=>{var v;const T=s.error;return{id:T?`MediaError#${T.code}`:"HtmlVideoError",category:O.VIDEO_PIPELINE,message:T?T.message:"Error event from HTML video element",thrown:(v=s.error)!==null&&v!==void 0?v:void 0}})),l=U(s,"timeupdate").pipe(k(()=>s.currentTime)),c=new M,h=.3;let f;l.subscribe(v=>{s.loop&&_(f)&&_(v)&&f>=s.duration-h&&v<=h&&c.next(f),f=v});const g=U(s,"enterpictureinpicture"),m=U(s,"leavepictureinpicture"),S=new y(FS(s));g.subscribe(()=>S.next(!0)),m.subscribe(()=>S.next(!1));const b=new y(Jo(s));return U(s,"fullscreenchange").pipe(k(()=>Jo(s))).subscribe(b),{playing$:n,pause$:e("pause").pipe(X(()=>!s.error)),canplay$:e("canplay"),ended$:e("ended"),looped$:c,error$:d,seeked$:e("seeked"),seeking$:e("seeking"),progress$:e("progress"),loadStart$:e("loadstart"),loadedMetadata$:e("loadedmetadata"),loadedData$:e("loadeddata"),timeUpdate$:l,durationChange$:U(s,"durationchange").pipe(k(()=>s.duration)),isBuffering$:i,currentBuffer$:r,volumeState$:o,playbackRateState$:u,inPiP$:S,inFullscreen$:b}},bn=s=>{if(s.includes("/")){const e=s.split("/");return parseInt(e[0])/parseInt(e[1])}else return parseFloat(s)};var VS=et,HS=er,GS=an,jS=rn;VS({target:"Array",proto:!0},{at:function(e){var t=HS(this),i=GS(t),r=jS(e),a=r>=0?r:i+r;return a<0||a>=i?void 0:t[a]}});var YS=gn,qS=YS("Array","at"),zS=qS,WS=zS,QS=WS,KS=QS,ct=Ws(KS);let yn=!1,ht={};const JS=s=>{yn=s},XS=()=>{ht={}},ZS=s=>{s(ht)},Es=(s,e)=>{var t;yn&&(ht.meta=(t=ht.meta)!==null&&t!==void 0?t:{},ht.meta[s]=e)};class nt{constructor(e){this.name=e}next(e){var t,i;if(!yn)return;ht.series=(t=ht.series)!==null&&t!==void 0?t:{};const r=(i=ht.series[this.name])!==null&&i!==void 0?i:[];r.push([Date.now(),e]),ht.series[this.name]=r}}var Yt;(function(s){s.FitsContainer="FitsContainer",s.FitsThroughput="FitsThroughput",s.Buffer="Buffer",s.DroppedFramesLimit="DroppedFramesLimit",s.FitsQualityLimits="FitsQualityLimits"})(Yt||(Yt={}));const eb=new nt("best_bitrate"),tb=(s,e,t)=>(e-t)*Math.pow(2,-10*s)+t;class ib{constructor(){this.history={}}recordSelection(e){this.history[e.id]=le()}recordSwitch(e){this.last=e}clear(){this.last=void 0,this.history={}}}const sb='Assertion "ABR Tracks is empty array" failed',Di=(s,{container:e,throughput:t,tuning:i,limits:r,reserve:a=0,forwardBufferHealth:n,playbackRate:o,current:u,history:d,droppedVideoMaxQualityLimit:l,abrLogger:c})=>{var h,f,g,m,S;Dl(s,sb);const b=i.usePixelRatio&&(h=window.devicePixelRatio)!==null&&h!==void 0?h:1,A=i.limitByContainer&&e&&e.width>0&&e.height>0&&{width:e.width*b*i.containerSizeFactor,height:e.height*b*i.containerSizeFactor},v=A&&Qt(A),T=i.considerPlaybackRate&&_(o)?o:1,$=s.filter(F=>!zt(F.quality)).sort((F,L)=>Si(F.quality,L.quality)?-1:1),D=(f=ct($,-1))===null||f===void 0?void 0:f.quality,N=(g=ct($,0))===null||g===void 0?void 0:g.quality,G=te(r)||_(r.min)&&_(r.max)&&Is(r.max,r.min)||_(r.min)&&N&&Si(r.min,N)||_(r.max)&&D&&Is(r.max,D),B=T*tb(n!=null?n:.5,i.bitrateFactorAtEmptyBuffer,i.bitrateFactorAtFullBuffer),Y={},x=$.filter(F=>(v?Is(F.quality,v):!0)?(_(t)&&isFinite(t)&&_(F.bitrate)?t-a>=F.bitrate*B:!0)?i.lazyQualitySwitch&&_(i.minBufferToSwitchUp)&&u&&!zt(u.quality)&&(n!=null?n:0)<i.minBufferToSwitchUp&&Si(F.quality,u.quality)?(Y[F.quality]=Yt.Buffer,!1):!!l&&ba(F.quality,l)?(Y[F.quality]=Yt.DroppedFramesLimit,!1):G||(te(r.max)||_d(F.quality,r.max))&&(te(r.min)||ba(F.quality,r.min))?!0:(Y[F.quality]=Yt.FitsQualityLimits,!1):(Y[F.quality]=Yt.FitsThroughput,!1):(Y[F.quality]=Yt.FitsContainer,!1))[0];x&&x.bitrate&&eb.next(x.bitrate);const I=(m=x!=null?x:$[Math.ceil(($.length-1)/2)])!==null&&m!==void 0?m:s[0];I.quality!==((S=d==null?void 0:d.last)===null||S===void 0?void 0:S.quality)&&c({message:`
|
|
7
7
|
[available tracks]
|
|
8
8
|
${s.map(F=>`{ id: ${F.id}, quality: ${F.quality}, bitrate: ${F.bitrate} }`).join(`
|
|
9
9
|
`)}
|