@vkontakte/videoplayer-core 2.0.97-beta.0 → 2.0.97

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es2015.cjs.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @vkontakte/videoplayer-core v2.0.97-beta.0
3
- * Wed, 13 Dec 2023 15:53:57 GMT
2
+ * @vkontakte/videoplayer-core v2.0.97
3
+ * Mon, 18 Dec 2023 13:57:26 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/2-0-97/doc/
5
5
  */
6
- "use strict";var Rd=Object.create;var Yn=Object.defineProperty;var Cd=Object.getOwnPropertyDescriptor;var xd=Object.getOwnPropertyNames;var Ld=Object.getPrototypeOf,Nd=Object.prototype.hasOwnProperty;var Od=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of xd(e))!Nd.call(i,r)&&r!==t&&Yn(i,r,{get:()=>e[r],enumerable:!(s=Cd(e,r))||s.enumerable});return i};var zn=(i,e,t)=>(t=i!=null?Rd(Ld(i)):{},Od(e||!i||!i.__esModule?Yn(t,"default",{value:i,enumerable:!0}):t,i));var a=require("@vkontakte/videoplayer-shared/es2015.cjs.js"),Bd=require("lodash/debounce.js");const Vl="2.0.97-beta.0";exports.PlaybackState=void 0;(function(i){i.STOPPED="stopped",i.READY="ready",i.PLAYING="playing",i.PAUSED="paused"})(exports.PlaybackState||(exports.PlaybackState={}));exports.VideoFormat=void 0;(function(i){i.MPEG="MPEG",i.DASH="DASH",i.DASH_SEP="DASH_SEP",i.DASH_SEP_VK="DASH_SEP",i.DASH_WEBM="DASH_WEBM",i.DASH_WEBM_AV1="DASH_WEBM_AV1",i.DASH_WEBM_VK="DASH_WEBM",i.DASH_ONDEMAND="DASH_ONDEMAND",i.DASH_ONDEMAND_VK="DASH_ONDEMAND",i.DASH_LIVE="DASH_LIVE",i.DASH_LIVE_CMAF="DASH_LIVE_CMAF",i.DASH_LIVE_WEBM="DASH_LIVE_WEBM",i.HLS="HLS",i.HLS_ONDEMAND="HLS_ONDEMAND",i.HLS_JS="HLS",i.HLS_LIVE="HLS_LIVE",i.HLS_LIVE_CMAF="HLS_LIVE_CMAF",i.WEB_RTC_LIVE="WEB_RTC_LIVE"})(exports.VideoFormat||(exports.VideoFormat={}));var Ae;(function(i){i.SCREEN="SCREEN",i.CHROMECAST="CHROMECAST"})(Ae||(Ae={}));exports.ChromecastState=void 0;(function(i){i.NOT_AVAILABLE="NOT_AVAILABLE",i.AVAILABLE="AVAILABLE",i.CONNECTING="CONNECTING",i.CONNECTED="CONNECTED"})(exports.ChromecastState||(exports.ChromecastState={}));exports.HttpConnectionType=void 0;(function(i){i.HTTP1="http1",i.HTTP2="http2",i.QUIC="quic"})(exports.HttpConnectionType||(exports.HttpConnectionType={}));var Y;(function(i){i.None="none",i.Requested="requested",i.Applying="applying"})(Y||(Y={}));exports.Surface=void 0;(function(i){i.NONE="none",i.INLINE="inline",i.FULLSCREEN="fullscreen",i.SECOND_SCREEN="second_screen",i.PIP="pip"})(exports.Surface||(exports.Surface={}));function H(i,e,t,s){function r(n){return n instanceof t?n:new t(function(o){o(n)})}return new(t||(t=Promise))(function(n,o){function l(c){try{u(s.next(c))}catch(h){o(h)}}function d(c){try{u(s.throw(c))}catch(h){o(h)}}function u(c){c.done?n(c.value):r(c.value).then(l,d)}u((s=s.apply(i,e||[])).next())})}function A(i){return this instanceof A?(this.v=i,this):new A(i)}function Z(i,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=t.apply(i,e||[]),r,n=[];return r={},o("next"),o("throw"),o("return"),r[Symbol.asyncIterator]=function(){return this},r;function o(f){s[f]&&(r[f]=function(p){return new Promise(function(m,g){n.push([f,p,m,g])>1||l(f,p)})})}function l(f,p){try{d(s[f](p))}catch(m){h(n[0][3],m)}}function d(f){f.value instanceof A?Promise.resolve(f.value.v).then(u,c):h(n[0][2],f)}function u(f){l("next",f)}function c(f){l("throw",f)}function h(f,p){f(p),n.shift(),n.length&&l(n[0][0],n[0][1])}}var Md=i=>new Promise((e,t)=>{const s=document.createElement("script");s.setAttribute("src",i),s.onload=()=>e,s.onerror=()=>t,document.body.appendChild(s)});class Vd{constructor(e){var t;this.connection$=new a.ValueSubject(void 0),this.castState$=new a.ValueSubject(exports.ChromecastState.NOT_AVAILABLE),this.errorEvent$=new a.Subject,this.realCastState$=new a.ValueSubject(exports.ChromecastState.NOT_AVAILABLE),this.subscription=new a.Subscription,this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastInitializer");const s="chrome"in window;if(this.log({message:`[constructor] receiverApplicationId: ${this.params.receiverApplicationId}, isDisabled: ${this.params.isDisabled}, isSupported: ${s}`}),e.isDisabled||!s)return;const r=a.isNonNullable((t=window.chrome)===null||t===void 0?void 0:t.cast),n=!!window.__onGCastApiAvailable;r?this.initializeCastApi():(window.__onGCastApiAvailable=o=>{delete window.__onGCastApiAvailable,o&&this.initializeCastApi()},n||Md("https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1").catch(()=>this.errorEvent$.next({id:"ChromecastLoading",category:a.ErrorCategory.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 s,r,n;(n=(r=(s=cast.framework.CastContext.getInstance())===null||s===void 0?void 0:s.getCurrentSession())===null||r===void 0?void 0:r.getMediaSession())===null||n===void 0||n.stop(new chrome.cast.media.StopRequest,e,t)})}toggleConnection(){a.isNonNullable(this.connection$.getValue())?this.disconnect():this.connect()}setVolume(e){const t=this.connection$.getValue();a.isNullable(t)||(t.remotePlayer.volumeLevel=e,t.remotePlayerController.setVolumeLevel())}setMuted(e){const t=this.connection$.getValue();a.isNullable(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),s=cast.framework.CastContext.getInstance();this.subscription.add(a.fromEvent(s,cast.framework.CastContextEventType.SESSION_STATE_CHANGED).subscribe(r=>{var n,o;switch(r.sessionState){case cast.framework.SessionState.SESSION_STARTED:case cast.framework.SessionState.SESSION_STARTING:case cast.framework.SessionState.SESSION_RESUMED:this.contentId=(o=(n=s.getCurrentSession())===null||n===void 0?void 0:n.getMediaSession())===null||o===void 0?void 0:o.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 a.assertNever(r.sessionState)}})).add(a.merge(a.fromEvent(s,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe(a.tap(r=>{this.log({message:`[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: ${JSON.stringify(r)}`})}),a.map(r=>r.castState)),a.observableFrom([s.getCastState()])).pipe(a.filterChanged(),a.map(Fd),a.tap(r=>{this.log({message:`realCastState$: ${r}`})})).subscribe(this.realCastState$)).add(this.realCastState$.subscribe(r=>{var n;const o=r===exports.ChromecastState.CONNECTED,l=a.isNonNullable(this.connection$.getValue());if(o&&!l){const d=s.getCurrentSession();a.assertNonNullable(d);const u=d.getCastDevice(),c=(n=d.getMediaSession())===null||n===void 0?void 0:n.media.contentId;(a.isNullable(c)||c===this.contentId)&&(this.log({message:"connection created"}),this.connection$.next({remotePlayer:e,remotePlayerController:t,session:d,castDevice:u}))}else!o&&l&&(this.log({message:"connection destroyed"}),this.connection$.next(void 0));this.castState$.next(r===exports.ChromecastState.CONNECTED?a.isNonNullable(this.connection$.getValue())?exports.ChromecastState.CONNECTED:exports.ChromecastState.AVAILABLE:r)}))}initializeCastApi(){var e;let t,s,r;try{t=cast.framework.CastContext.getInstance(),s=chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,r=chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}catch(n){return}try{t.setOptions({receiverApplicationId:(e=this.params.receiverApplicationId)!==null&&e!==void 0?e:s,autoJoinPolicy:r}),this.initListeners()}catch(n){this.errorEvent$.next({id:"ChromecastInitializer",category:a.ErrorCategory.EXTERNAL_API,message:"[initializeCastApi] failed",thrown:n})}}}const Fd=i=>{switch(i){case cast.framework.CastState.NO_DEVICES_AVAILABLE:return exports.ChromecastState.NOT_AVAILABLE;case cast.framework.CastState.NOT_CONNECTED:return exports.ChromecastState.AVAILABLE;case cast.framework.CastState.CONNECTING:return exports.ChromecastState.CONNECTING;case cast.framework.CastState.CONNECTED:return exports.ChromecastState.CONNECTED;default:return a.assertNever(i)}};var Ur=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function fr(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Ke=function(i){try{return!!i()}catch(e){return!0}},Ud=Ke,pr=!Ud(function(){var i=function(){}.bind();return typeof i!="function"||i.hasOwnProperty("prototype")}),Fl=pr,Ul=Function.prototype,Ua=Ul.call,jd=Fl&&Ul.bind.bind(Ua,Ua),Je=Fl?jd:function(i){return function(){return Ua.apply(i,arguments)}},jl=Je,Hd=jl({}.toString),Gd=jl("".slice),cs=function(i){return Gd(Hd(i),8,-1)},Yd=Je,zd=Ke,qd=cs,jr=Object,Wd=Yd("".split),Qd=zd(function(){return!jr("z").propertyIsEnumerable(0)})?function(i){return qd(i)=="String"?Wd(i,""):jr(i)}:jr,hs=function(i){return i==null},Kd=hs,Jd=TypeError,mn=function(i){if(Kd(i))throw Jd("Can't call method on "+i);return i},Xd=Qd,Zd=mn,fs=function(i){return Xd(Zd(i))},Ni={},$s=function(i){return i&&i.Math==Math&&i},Te=$s(typeof globalThis=="object"&&globalThis)||$s(typeof window=="object"&&window)||$s(typeof self=="object"&&self)||$s(typeof Ur=="object"&&Ur)||function(){return this}()||Ur||Function("return this")(),ja=typeof document=="object"&&document.all,ec=typeof ja=="undefined"&&ja!==void 0,Hl={all:ja,IS_HTMLDDA:ec},Gl=Hl,tc=Gl.all,pe=Gl.IS_HTMLDDA?function(i){return typeof i=="function"||i===tc}:function(i){return typeof i=="function"},ic=Te,sc=pe,qn=ic.WeakMap,rc=sc(qn)&&/native code/.test(String(qn)),Wn=pe,Yl=Hl,ac=Yl.all,Ct=Yl.IS_HTMLDDA?function(i){return typeof i=="object"?i!==null:Wn(i)||i===ac}:function(i){return typeof i=="object"?i!==null:Wn(i)},nc=Ke,jt=!nc(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),ui={},oc=Te,Qn=Ct,Ha=oc.document,lc=Qn(Ha)&&Qn(Ha.createElement),vn=function(i){return lc?Ha.createElement(i):{}},uc=jt,dc=Ke,cc=vn,zl=!uc&&!dc(function(){return Object.defineProperty(cc("div"),"a",{get:function(){return 7}}).a!=7}),hc=jt,fc=Ke,ql=hc&&fc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),pc=Ct,mc=String,vc=TypeError,xt=function(i){if(pc(i))return i;throw vc(mc(i)+" is not an object")},bc=pr,ks=Function.prototype.call,He=bc?ks.bind(ks):function(){return ks.apply(ks,arguments)},bn={},Hr=bn,Gr=Te,gc=pe,Kn=function(i){return gc(i)?i:void 0},di=function(i,e){return arguments.length<2?Kn(Hr[i])||Kn(Gr[i]):Hr[i]&&Hr[i][e]||Gr[i]&&Gr[i][e]},Sc=Je,mr=Sc({}.isPrototypeOf),vr=typeof navigator!="undefined"&&String(navigator.userAgent)||"",Wl=Te,Yr=vr,Jn=Wl.process,Xn=Wl.Deno,Zn=Jn&&Jn.versions||Xn&&Xn.version,eo=Zn&&Zn.v8,st,Ks;eo&&(st=eo.split("."),Ks=st[0]>0&&st[0]<4?1:+(st[0]+st[1]));!Ks&&Yr&&(st=Yr.match(/Edge\/(\d+)/),(!st||st[1]>=74)&&(st=Yr.match(/Chrome\/(\d+)/),st&&(Ks=+st[1])));var Ql=Ks,to=Ql,yc=Ke,Tc=Te,Ec=Tc.String,Kl=!!Object.getOwnPropertySymbols&&!yc(function(){var i=Symbol();return!Ec(i)||!(Object(i)instanceof Symbol)||!Symbol.sham&&to&&to<41}),$c=Kl,Jl=$c&&!Symbol.sham&&typeof Symbol.iterator=="symbol",kc=di,Ac=pe,wc=mr,Pc=Jl,_c=Object,Xl=Pc?function(i){return typeof i=="symbol"}:function(i){var e=kc("Symbol");return Ac(e)&&wc(e.prototype,_c(i))},Dc=String,br=function(i){try{return Dc(i)}catch(e){return"Object"}},Ic=pe,Rc=br,Cc=TypeError,ci=function(i){if(Ic(i))return i;throw Cc(Rc(i)+" is not a function")},xc=ci,Lc=hs,gr=function(i,e){var t=i[e];return Lc(t)?void 0:xc(t)},zr=He,qr=pe,Wr=Ct,Nc=TypeError,Oc=function(i,e){var t,s;if(e==="string"&&qr(t=i.toString)&&!Wr(s=zr(t,i))||qr(t=i.valueOf)&&!Wr(s=zr(t,i))||e!=="string"&&qr(t=i.toString)&&!Wr(s=zr(t,i)))return s;throw Nc("Can't convert object to primitive value")},Zl={exports:{}},Bc=!0,io=Te,Mc=Object.defineProperty,Vc=function(i,e){try{Mc(io,i,{value:e,configurable:!0,writable:!0})}catch(t){io[i]=e}return e},Fc=Te,Uc=Vc,so="__core-js_shared__",jc=Fc[so]||Uc(so,{}),gn=jc,ro=gn;(Zl.exports=function(i,e){return ro[i]||(ro[i]=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 eu=Zl.exports,Hc=mn,Gc=Object,Sr=function(i){return Gc(Hc(i))},Yc=Je,zc=Sr,qc=Yc({}.hasOwnProperty),mt=Object.hasOwn||function(e,t){return qc(zc(e),t)},Wc=Je,Qc=0,Kc=Math.random(),Jc=Wc(1 .toString),tu=function(i){return"Symbol("+(i===void 0?"":i)+")_"+Jc(++Qc+Kc,36)},Xc=Te,Zc=eu,ao=mt,eh=tu,th=Kl,ih=Jl,ki=Xc.Symbol,Qr=Zc("wks"),sh=ih?ki.for||ki:ki&&ki.withoutSetter||eh,De=function(i){return ao(Qr,i)||(Qr[i]=th&&ao(ki,i)?ki[i]:sh("Symbol."+i)),Qr[i]},rh=He,no=Ct,oo=Xl,ah=gr,nh=Oc,oh=De,lh=TypeError,uh=oh("toPrimitive"),dh=function(i,e){if(!no(i)||oo(i))return i;var t=ah(i,uh),s;if(t){if(e===void 0&&(e="default"),s=rh(t,i,e),!no(s)||oo(s))return s;throw lh("Can't convert object to primitive value")}return e===void 0&&(e="number"),nh(i,e)},ch=dh,hh=Xl,Sn=function(i){var e=ch(i,"string");return hh(e)?e:e+""},fh=jt,ph=zl,mh=ql,As=xt,lo=Sn,vh=TypeError,Kr=Object.defineProperty,bh=Object.getOwnPropertyDescriptor,Jr="enumerable",Xr="configurable",Zr="writable";ui.f=fh?mh?function(e,t,s){if(As(e),t=lo(t),As(s),typeof e=="function"&&t==="prototype"&&"value"in s&&Zr in s&&!s[Zr]){var r=bh(e,t);r&&r[Zr]&&(e[t]=s.value,s={configurable:Xr in s?s[Xr]:r[Xr],enumerable:Jr in s?s[Jr]:r[Jr],writable:!1})}return Kr(e,t,s)}:Kr:function(e,t,s){if(As(e),t=lo(t),As(s),ph)try{return Kr(e,t,s)}catch(r){}if("get"in s||"set"in s)throw vh("Accessors not supported");return"value"in s&&(e[t]=s.value),e};var yr=function(i,e){return{enumerable:!(i&1),configurable:!(i&2),writable:!(i&4),value:e}},gh=jt,Sh=ui,yh=yr,ps=gh?function(i,e,t){return Sh.f(i,e,yh(1,t))}:function(i,e,t){return i[e]=t,i},Th=eu,Eh=tu,uo=Th("keys"),yn=function(i){return uo[i]||(uo[i]=Eh(i))},Tn={},$h=rc,iu=Te,kh=Ct,Ah=ps,ea=mt,ta=gn,wh=yn,Ph=Tn,co="Object already initialized",Ga=iu.TypeError,_h=iu.WeakMap,Js,os,Xs,Dh=function(i){return Xs(i)?os(i):Js(i,{})},Ih=function(i){return function(e){var t;if(!kh(e)||(t=os(e)).type!==i)throw Ga("Incompatible receiver, "+i+" required");return t}};if($h||ta.state){var lt=ta.state||(ta.state=new _h);lt.get=lt.get,lt.has=lt.has,lt.set=lt.set,Js=function(i,e){if(lt.has(i))throw Ga(co);return e.facade=i,lt.set(i,e),e},os=function(i){return lt.get(i)||{}},Xs=function(i){return lt.has(i)}}else{var vi=wh("state");Ph[vi]=!0,Js=function(i,e){if(ea(i,vi))throw Ga(co);return e.facade=i,Ah(i,vi,e),e},os=function(i){return ea(i,vi)?i[vi]:{}},Xs=function(i){return ea(i,vi)}}var su={set:Js,get:os,has:Xs,enforce:Dh,getterFor:Ih},Rh=pr,ru=Function.prototype,ho=ru.apply,fo=ru.call,au=typeof Reflect=="object"&&Reflect.apply||(Rh?fo.bind(ho):function(){return fo.apply(ho,arguments)}),Ch=cs,xh=Je,nu=function(i){if(Ch(i)==="Function")return xh(i)},En={},ou={},lu={}.propertyIsEnumerable,uu=Object.getOwnPropertyDescriptor,Lh=uu&&!lu.call({1:2},1);ou.f=Lh?function(e){var t=uu(this,e);return!!t&&t.enumerable}:lu;var Nh=jt,Oh=He,Bh=ou,Mh=yr,Vh=fs,Fh=Sn,Uh=mt,jh=zl,po=Object.getOwnPropertyDescriptor;En.f=Nh?po:function(e,t){if(e=Vh(e),t=Fh(t),jh)try{return po(e,t)}catch(s){}if(Uh(e,t))return Mh(!Oh(Bh.f,e,t),e[t])};var Hh=Ke,Gh=pe,Yh=/#|\.prototype\./,ms=function(i,e){var t=qh[zh(i)];return t==Qh?!0:t==Wh?!1:Gh(e)?Hh(e):!!e},zh=ms.normalize=function(i){return String(i).replace(Yh,".").toLowerCase()},qh=ms.data={},Wh=ms.NATIVE="N",Qh=ms.POLYFILL="P",du=ms,mo=nu,Kh=ci,Jh=pr,Xh=mo(mo.bind),Tr=function(i,e){return Kh(i),e===void 0?i:Jh?Xh(i,e):function(){return i.apply(e,arguments)}},ws=Te,Zh=au,ef=nu,tf=pe,sf=En.f,rf=du,bi=bn,af=Tr,gi=ps,vo=mt,nf=function(i){var e=function(t,s,r){if(this instanceof e){switch(arguments.length){case 0:return new i;case 1:return new i(t);case 2:return new i(t,s)}return new i(t,s,r)}return Zh(i,this,arguments)};return e.prototype=i.prototype,e},at=function(i,e){var t=i.target,s=i.global,r=i.stat,n=i.proto,o=s?ws:r?ws[t]:(ws[t]||{}).prototype,l=s?bi:bi[t]||gi(bi,t,{})[t],d=l.prototype,u,c,h,f,p,m,g,S,v;for(f in e)u=rf(s?f:t+(r?".":"#")+f,i.forced),c=!u&&o&&vo(o,f),m=l[f],c&&(i.dontCallGetSet?(v=sf(o,f),g=v&&v.value):g=o[f]),p=c&&g?g:e[f],!(c&&typeof m==typeof p)&&(i.bind&&c?S=af(p,ws):i.wrap&&c?S=nf(p):n&&tf(p)?S=ef(p):S=p,(i.sham||p&&p.sham||m&&m.sham)&&gi(S,"sham",!0),gi(l,f,S),n&&(h=t+"Prototype",vo(bi,h)||gi(bi,h,{}),gi(bi[h],f,p),i.real&&d&&(u||!d[f])&&gi(d,f,p)))},Ya=jt,of=mt,cu=Function.prototype,lf=Ya&&Object.getOwnPropertyDescriptor,$n=of(cu,"name"),uf=$n&&function(){}.name==="something",df=$n&&(!Ya||Ya&&lf(cu,"name").configurable),cf={EXISTS:$n,PROPER:uf,CONFIGURABLE:df},hu={},hf=Math.ceil,ff=Math.floor,pf=Math.trunc||function(e){var t=+e;return(t>0?ff:hf)(t)},mf=pf,kn=function(i){var e=+i;return e!==e||e===0?0:mf(e)},vf=kn,bf=Math.max,gf=Math.min,Sf=function(i,e){var t=vf(i);return t<0?bf(t+e,0):gf(t,e)},yf=kn,Tf=Math.min,Ef=function(i){return i>0?Tf(yf(i),9007199254740991):0},$f=Ef,An=function(i){return $f(i.length)},kf=fs,Af=Sf,wf=An,bo=function(i){return function(e,t,s){var r=kf(e),n=wf(r),o=Af(s,n),l;if(i&&t!=t){for(;n>o;)if(l=r[o++],l!=l)return!0}else for(;n>o;o++)if((i||o in r)&&r[o]===t)return i||o||0;return!i&&-1}},Pf={includes:bo(!0),indexOf:bo(!1)},_f=Je,ia=mt,Df=fs,If=Pf.indexOf,Rf=Tn,go=_f([].push),Cf=function(i,e){var t=Df(i),s=0,r=[],n;for(n in t)!ia(Rf,n)&&ia(t,n)&&go(r,n);for(;e.length>s;)ia(t,n=e[s++])&&(~If(r,n)||go(r,n));return r},fu=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],xf=Cf,Lf=fu,Nf=Object.keys||function(e){return xf(e,Lf)},Of=jt,Bf=ql,Mf=ui,Vf=xt,Ff=fs,Uf=Nf;hu.f=Of&&!Bf?Object.defineProperties:function(e,t){Vf(e);for(var s=Ff(t),r=Uf(t),n=r.length,o=0,l;n>o;)Mf.f(e,l=r[o++],s[l]);return e};var jf=di,pu=jf("document","documentElement"),Hf=xt,Gf=hu,So=fu,Yf=Tn,zf=pu,qf=vn,Wf=yn,yo=">",To="<",za="prototype",qa="script",mu=Wf("IE_PROTO"),sa=function(){},vu=function(i){return To+qa+yo+i+To+"/"+qa+yo},Eo=function(i){i.write(vu("")),i.close();var e=i.parentWindow.Object;return i=null,e},Qf=function(){var i=qf("iframe"),e="java"+qa+":",t;return i.style.display="none",zf.appendChild(i),i.src=String(e),t=i.contentWindow.document,t.open(),t.write(vu("document.F=Object")),t.close(),t.F},Ps,zs=function(){try{Ps=new ActiveXObject("htmlfile")}catch(e){}zs=typeof document!="undefined"?document.domain&&Ps?Eo(Ps):Qf():Eo(Ps);for(var i=So.length;i--;)delete zs[za][So[i]];return zs()};Yf[mu]=!0;var bu=Object.create||function(e,t){var s;return e!==null?(sa[za]=Hf(e),s=new sa,sa[za]=null,s[mu]=e):s=zs(),t===void 0?s:Gf.f(s,t)},Kf=Ke,Jf=!Kf(function(){function i(){}return i.prototype.constructor=null,Object.getPrototypeOf(new i)!==i.prototype}),Xf=mt,Zf=pe,ep=Sr,tp=yn,ip=Jf,$o=tp("IE_PROTO"),Wa=Object,sp=Wa.prototype,gu=ip?Wa.getPrototypeOf:function(i){var e=ep(i);if(Xf(e,$o))return e[$o];var t=e.constructor;return Zf(t)&&e instanceof t?t.prototype:e instanceof Wa?sp:null},rp=ps,wn=function(i,e,t,s){return s&&s.enumerable?i[e]=t:rp(i,e,t),i},ap=Ke,np=pe,op=Ct,lp=bu,ko=gu,up=wn,dp=De,Qa=dp("iterator"),Su=!1,Dt,ra,aa;[].keys&&(aa=[].keys(),"next"in aa?(ra=ko(ko(aa)),ra!==Object.prototype&&(Dt=ra)):Su=!0);var cp=!op(Dt)||ap(function(){var i={};return Dt[Qa].call(i)!==i});cp?Dt={}:Dt=lp(Dt);np(Dt[Qa])||up(Dt,Qa,function(){return this});var yu={IteratorPrototype:Dt,BUGGY_SAFARI_ITERATORS:Su},hp=De,fp=hp("toStringTag"),Tu={};Tu[fp]="z";var Pn=String(Tu)==="[object z]",pp=Pn,mp=pe,qs=cs,vp=De,bp=vp("toStringTag"),gp=Object,Sp=qs(function(){return arguments}())=="Arguments",yp=function(i,e){try{return i[e]}catch(t){}},vs=pp?qs:function(i){var e,t,s;return i===void 0?"Undefined":i===null?"Null":typeof(t=yp(e=gp(i),bp))=="string"?t:Sp?qs(e):(s=qs(e))=="Object"&&mp(e.callee)?"Arguments":s},Tp=Pn,Ep=vs,$p=Tp?{}.toString:function(){return"[object "+Ep(this)+"]"},kp=Pn,Ap=ui.f,wp=ps,Pp=mt,_p=$p,Dp=De,Ao=Dp("toStringTag"),_n=function(i,e,t,s){if(i){var r=t?i:i.prototype;Pp(r,Ao)||Ap(r,Ao,{configurable:!0,value:e}),s&&!kp&&wp(r,"toString",_p)}},Ip=yu.IteratorPrototype,Rp=bu,Cp=yr,xp=_n,Lp=Ni,Np=function(){return this},Op=function(i,e,t,s){var r=e+" Iterator";return i.prototype=Rp(Ip,{next:Cp(+!s,t)}),xp(i,r,!1,!0),Lp[r]=Np,i},Bp=at,Mp=He,Eu=cf,Vp=Op,Fp=gu,Up=_n,wo=wn,jp=De,Po=Ni,$u=yu,Hp=Eu.PROPER;Eu.CONFIGURABLE;$u.IteratorPrototype;var _s=$u.BUGGY_SAFARI_ITERATORS,na=jp("iterator"),_o="keys",Ds="values",Do="entries",Gp=function(){return this},Yp=function(i,e,t,s,r,n,o){Vp(t,e,s);var l=function(v){if(v===r&&f)return f;if(!_s&&v in c)return c[v];switch(v){case _o:return function(){return new t(this,v)};case Ds:return function(){return new t(this,v)};case Do:return function(){return new t(this,v)}}return function(){return new t(this)}},d=e+" Iterator",u=!1,c=i.prototype,h=c[na]||c["@@iterator"]||r&&c[r],f=!_s&&h||l(r),p=e=="Array"&&c.entries||h,m,g,S;if(p&&(m=Fp(p.call(new i)),m!==Object.prototype&&m.next&&(Up(m,d,!0,!0),Po[d]=Gp)),Hp&&r==Ds&&h&&h.name!==Ds&&(u=!0,f=function(){return Mp(h,this)}),r)if(g={values:l(Ds),keys:n?f:l(_o),entries:l(Do)},o)for(S in g)(_s||u||!(S in c))&&wo(c,S,g[S]);else Bp({target:e,proto:!0,forced:_s||u},g);return o&&c[na]!==f&&wo(c,na,f,{name:r}),Po[e]=f,g},zp=function(i,e){return{value:i,done:e}},qp=fs,Io=Ni,ku=su;ui.f;var Wp=Yp,Is=zp,Au="Array Iterator",Qp=ku.set,Kp=ku.getterFor(Au);Wp(Array,"Array",function(i,e){Qp(this,{type:Au,target:qp(i),index:0,kind:e})},function(){var i=Kp(this),e=i.target,t=i.kind,s=i.index++;return!e||s>=e.length?(i.target=void 0,Is(void 0,!0)):t=="keys"?Is(s,!1):t=="values"?Is(e[s],!1):Is([s,e[s]],!1)},"values");Io.Arguments=Io.Array;var Jp=De,Xp=Ni,Zp=Jp("iterator"),em=Array.prototype,tm=function(i){return i!==void 0&&(Xp.Array===i||em[Zp]===i)},im=vs,Ro=gr,sm=hs,rm=Ni,am=De,nm=am("iterator"),wu=function(i){if(!sm(i))return Ro(i,nm)||Ro(i,"@@iterator")||rm[im(i)]},om=He,lm=ci,um=xt,dm=br,cm=wu,hm=TypeError,fm=function(i,e){var t=arguments.length<2?cm(i):e;if(lm(t))return um(om(t,i));throw hm(dm(i)+" is not iterable")},pm=He,Co=xt,mm=gr,vm=function(i,e,t){var s,r;Co(i);try{if(s=mm(i,"return"),!s){if(e==="throw")throw t;return t}s=pm(s,i)}catch(n){r=!0,s=n}if(e==="throw")throw t;if(r)throw s;return Co(s),t},bm=Tr,gm=He,Sm=xt,ym=br,Tm=tm,Em=An,xo=mr,$m=fm,km=wu,Lo=vm,Am=TypeError,Ws=function(i,e){this.stopped=i,this.result=e},No=Ws.prototype,Dn=function(i,e,t){var s=t&&t.that,r=!!(t&&t.AS_ENTRIES),n=!!(t&&t.IS_RECORD),o=!!(t&&t.IS_ITERATOR),l=!!(t&&t.INTERRUPTED),d=bm(e,s),u,c,h,f,p,m,g,S=function(y){return u&&Lo(u,"normal",y),new Ws(!0,y)},v=function(y){return r?(Sm(y),l?d(y[0],y[1],S):d(y[0],y[1])):l?d(y,S):d(y)};if(n)u=i.iterator;else if(o)u=i;else{if(c=km(i),!c)throw Am(ym(i)+" is not iterable");if(Tm(c)){for(h=0,f=Em(i);f>h;h++)if(p=v(i[h]),p&&xo(No,p))return p;return new Ws(!1)}u=$m(i,c)}for(m=n?i.next:u.next;!(g=gm(m,u)).done;){try{p=v(g.value)}catch(y){Lo(u,"throw",y)}if(typeof p=="object"&&p&&xo(No,p))return p}return new Ws(!1)},wm=Sn,Pm=ui,_m=yr,Dm=function(i,e,t){var s=wm(e);s in i?Pm.f(i,s,_m(0,t)):i[s]=t},Im=at,Rm=Dn,Cm=Dm;Im({target:"Object",stat:!0},{fromEntries:function(e){var t={};return Rm(e,function(s,r){Cm(t,s,r)},{AS_ENTRIES:!0}),t}});var xm=bn,Lm=xm.Object.fromEntries,Nm={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=Nm,Bm=Te,Mm=vs,Vm=ps,Oo=Ni,Fm=De,Bo=Fm("toStringTag");for(var oa in Om){var Mo=Bm[oa],la=Mo&&Mo.prototype;la&&Mm(la)!==Bo&&Vm(la,Bo,oa),Oo[oa]=Oo.Array}var Um=Lm,jm=Um,Hm=jm,Gm=Hm,ni=fr(Gm),Ym=cs,Er=typeof process!="undefined"&&Ym(process)=="process",zm=ui,qm=function(i,e,t){return zm.f(i,e,t)},Wm=di,Qm=qm,Km=De,Jm=jt,Vo=Km("species"),Xm=function(i){var e=Wm(i);Jm&&e&&!e[Vo]&&Qm(e,Vo,{configurable:!0,get:function(){return this}})},Zm=mr,ev=TypeError,tv=function(i,e){if(Zm(e,i))return i;throw ev("Incorrect invocation")},iv=Je,sv=pe,Ka=gn,rv=iv(Function.toString);sv(Ka.inspectSource)||(Ka.inspectSource=function(i){return rv(i)});var Pu=Ka.inspectSource,av=Je,nv=Ke,_u=pe,ov=vs,lv=di,uv=Pu,Du=function(){},dv=[],Iu=lv("Reflect","construct"),In=/^\s*(?:class|function)\b/,cv=av(In.exec),hv=!In.exec(Du),Ki=function(e){if(!_u(e))return!1;try{return Iu(Du,dv,e),!0}catch(t){return!1}},Ru=function(e){if(!_u(e))return!1;switch(ov(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return hv||!!cv(In,uv(e))}catch(t){return!0}};Ru.sham=!0;var fv=!Iu||nv(function(){var i;return Ki(Ki.call)||!Ki(Object)||!Ki(function(){i=!0})||i})?Ru:Ki,pv=fv,mv=br,vv=TypeError,bv=function(i){if(pv(i))return i;throw vv(mv(i)+" is not a constructor")},Fo=xt,gv=bv,Sv=hs,yv=De,Tv=yv("species"),Cu=function(i,e){var t=Fo(i).constructor,s;return t===void 0||Sv(s=Fo(t)[Tv])?e:gv(s)},Ev=Je,$v=Ev([].slice),kv=TypeError,Av=function(i,e){if(i<e)throw kv("Not enough arguments");return i},wv=vr,xu=/(?:ipad|iphone|ipod).*applewebkit/i.test(wv),je=Te,Pv=au,_v=Tr,Uo=pe,Dv=mt,Lu=Ke,jo=pu,Iv=$v,Ho=vn,Rv=Av,Cv=xu,xv=Er,Ja=je.setImmediate,Xa=je.clearImmediate,Lv=je.process,ua=je.Dispatch,Nv=je.Function,Go=je.MessageChannel,Ov=je.String,da=0,rs={},Yo="onreadystatechange",ls,ti,ca,ha;Lu(function(){ls=je.location});var Rn=function(i){if(Dv(rs,i)){var e=rs[i];delete rs[i],e()}},fa=function(i){return function(){Rn(i)}},zo=function(i){Rn(i.data)},qo=function(i){je.postMessage(Ov(i),ls.protocol+"//"+ls.host)};(!Ja||!Xa)&&(Ja=function(e){Rv(arguments.length,1);var t=Uo(e)?e:Nv(e),s=Iv(arguments,1);return rs[++da]=function(){Pv(t,void 0,s)},ti(da),da},Xa=function(e){delete rs[e]},xv?ti=function(i){Lv.nextTick(fa(i))}:ua&&ua.now?ti=function(i){ua.now(fa(i))}:Go&&!Cv?(ca=new Go,ha=ca.port2,ca.port1.onmessage=zo,ti=_v(ha.postMessage,ha)):je.addEventListener&&Uo(je.postMessage)&&!je.importScripts&&ls&&ls.protocol!=="file:"&&!Lu(qo)?(ti=qo,je.addEventListener("message",zo,!1)):Yo in Ho("script")?ti=function(i){jo.appendChild(Ho("script"))[Yo]=function(){jo.removeChild(this),Rn(i)}}:ti=function(i){setTimeout(fa(i),0)});var Nu={set:Ja,clear:Xa},Ou=function(){this.head=null,this.tail=null};Ou.prototype={add:function(i){var e={item:i,next:null},t=this.tail;t?t.next=e:this.head=e,this.tail=e},get:function(){var i=this.head;if(i){var e=this.head=i.next;return e===null&&(this.tail=null),i.item}}};var Bu=Ou,Bv=vr,Mv=/ipad|iphone|ipod/i.test(Bv)&&typeof Pebble!="undefined",Vv=vr,Fv=/web0s(?!.*chrome)/i.test(Vv),oi=Te,Wo=Tr,Uv=En.f,pa=Nu.set,jv=Bu,Hv=xu,Gv=Mv,Yv=Fv,ma=Er,Qo=oi.MutationObserver||oi.WebKitMutationObserver,Ko=oi.document,Jo=oi.process,Rs=oi.Promise,Xo=Uv(oi,"queueMicrotask"),Za=Xo&&Xo.value,Si,va,ba,Cs,Zo;if(!Za){var xs=new jv,Ls=function(){var i,e;for(ma&&(i=Jo.domain)&&i.exit();e=xs.get();)try{e()}catch(t){throw xs.head&&Si(),t}i&&i.enter()};!Hv&&!ma&&!Yv&&Qo&&Ko?(va=!0,ba=Ko.createTextNode(""),new Qo(Ls).observe(ba,{characterData:!0}),Si=function(){ba.data=va=!va}):!Gv&&Rs&&Rs.resolve?(Cs=Rs.resolve(void 0),Cs.constructor=Rs,Zo=Wo(Cs.then,Cs),Si=function(){Zo(Ls)}):ma?Si=function(){Jo.nextTick(Ls)}:(pa=Wo(pa,oi),Si=function(){pa(Ls)}),Za=function(i){xs.head||Si(),xs.add(i)}}var zv=Za,qv=function(i,e){try{arguments.length==1?console.error(i):console.error(i,e)}catch(t){}},Cn=function(i){try{return{error:!1,value:i()}}catch(e){return{error:!0,value:e}}},Wv=Te,Oi=Wv.Promise,Mu=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",Qv=Mu,Kv=Er,Jv=!Qv&&!Kv&&typeof window=="object"&&typeof document=="object",Xv=Te,as=Oi,Zv=pe,eb=du,tb=Pu,ib=De,sb=Jv,rb=Mu,ga=Ql,el=as&&as.prototype,ab=ib("species"),en=!1,Vu=Zv(Xv.PromiseRejectionEvent),nb=eb("Promise",function(){var i=tb(as),e=i!==String(as);if(!e&&ga===66||!(el.catch&&el.finally))return!0;if(!ga||ga<51||!/native code/.test(i)){var t=new as(function(n){n(1)}),s=function(n){n(function(){},function(){})},r=t.constructor={};if(r[ab]=s,en=t.then(function(){})instanceof s,!en)return!0}return!e&&(sb||rb)&&!Vu}),bs={CONSTRUCTOR:nb,REJECTION_EVENT:Vu,SUBCLASSING:en},Bi={},tl=ci,ob=TypeError,lb=function(i){var e,t;this.promise=new i(function(s,r){if(e!==void 0||t!==void 0)throw ob("Bad Promise constructor");e=s,t=r}),this.resolve=tl(e),this.reject=tl(t)};Bi.f=function(i){return new lb(i)};var ub=at,Zs=Er,Ft=Te,gs=He,db=wn,cb=_n,hb=Xm,fb=ci,tn=pe,pb=Ct,mb=tv,vb=Cu,Fu=Nu.set,xn=zv,bb=qv,gb=Cn,Sb=Bu,Uu=su,sn=Oi,Ln=bs,ju=Bi,$r="Promise",Hu=Ln.CONSTRUCTOR,yb=Ln.REJECTION_EVENT;Ln.SUBCLASSING;var Sa=Uu.getterFor($r),Tb=Uu.set,Eb=sn&&sn.prototype,Ai=sn,ya=Eb,Gu=Ft.TypeError,rn=Ft.document,Nn=Ft.process,an=ju.f,$b=an,kb=!!(rn&&rn.createEvent&&Ft.dispatchEvent),Yu="unhandledrejection",Ab="rejectionhandled",il=0,zu=1,wb=2,On=1,qu=2,Ns,sl,Pb,Wu=function(i){var e;return pb(i)&&tn(e=i.then)?e:!1},Qu=function(i,e){var t=e.value,s=e.state==zu,r=s?i.ok:i.fail,n=i.resolve,o=i.reject,l=i.domain,d,u,c;try{r?(s||(e.rejection===qu&&Db(e),e.rejection=On),r===!0?d=t:(l&&l.enter(),d=r(t),l&&(l.exit(),c=!0)),d===i.promise?o(Gu("Promise-chain cycle")):(u=Wu(d))?gs(u,d,n,o):n(d)):o(t)}catch(h){l&&!c&&l.exit(),o(h)}},Ku=function(i,e){i.notified||(i.notified=!0,xn(function(){for(var t=i.reactions,s;s=t.get();)Qu(s,i);i.notified=!1,e&&!i.rejection&&_b(i)}))},Ju=function(i,e,t){var s,r;kb?(s=rn.createEvent("Event"),s.promise=e,s.reason=t,s.initEvent(i,!1,!0),Ft.dispatchEvent(s)):s={promise:e,reason:t},!yb&&(r=Ft["on"+i])?r(s):i===Yu&&bb("Unhandled promise rejection",t)},_b=function(i){gs(Fu,Ft,function(){var e=i.facade,t=i.value,s=rl(i),r;if(s&&(r=gb(function(){Zs?Nn.emit("unhandledRejection",t,e):Ju(Yu,e,t)}),i.rejection=Zs||rl(i)?qu:On,r.error))throw r.value})},rl=function(i){return i.rejection!==On&&!i.parent},Db=function(i){gs(Fu,Ft,function(){var e=i.facade;Zs?Nn.emit("rejectionHandled",e):Ju(Ab,e,i.value)})},wi=function(i,e,t){return function(s){i(e,s,t)}},Di=function(i,e,t){i.done||(i.done=!0,t&&(i=t),i.value=e,i.state=wb,Ku(i,!0))},nn=function(i,e,t){if(!i.done){i.done=!0,t&&(i=t);try{if(i.facade===e)throw Gu("Promise can't be resolved itself");var s=Wu(e);s?xn(function(){var r={done:!1};try{gs(s,e,wi(nn,r,i),wi(Di,r,i))}catch(n){Di(r,n,i)}}):(i.value=e,i.state=zu,Ku(i,!1))}catch(r){Di({done:!1},r,i)}}};Hu&&(Ai=function(e){mb(this,ya),fb(e),gs(Ns,this);var t=Sa(this);try{e(wi(nn,t),wi(Di,t))}catch(s){Di(t,s)}},ya=Ai.prototype,Ns=function(e){Tb(this,{type:$r,done:!1,notified:!1,parent:!1,reactions:new Sb,rejection:!1,state:il,value:void 0})},Ns.prototype=db(ya,"then",function(e,t){var s=Sa(this),r=an(vb(this,Ai));return s.parent=!0,r.ok=tn(e)?e:!0,r.fail=tn(t)&&t,r.domain=Zs?Nn.domain:void 0,s.state==il?s.reactions.add(r):xn(function(){Qu(r,s)}),r.promise}),sl=function(){var i=new Ns,e=Sa(i);this.promise=i,this.resolve=wi(nn,e),this.reject=wi(Di,e)},ju.f=an=function(i){return i===Ai||i===Pb?new sl(i):$b(i)});ub({global:!0,constructor:!0,wrap:!0,forced:Hu},{Promise:Ai});cb(Ai,$r,!1,!0);hb($r);var Ib=De,Xu=Ib("iterator"),Zu=!1;try{var Rb=0,al={next:function(){return{done:!!Rb++}},return:function(){Zu=!0}};al[Xu]=function(){return this},Array.from(al,function(){throw 2})}catch(i){}var Cb=function(i,e){if(!e&&!Zu)return!1;var t=!1;try{var s={};s[Xu]=function(){return{next:function(){return{done:t=!0}}}},i(s)}catch(r){}return t},xb=Oi,Lb=Cb,Nb=bs.CONSTRUCTOR,ed=Nb||!Lb(function(i){xb.all(i).then(void 0,function(){})}),Ob=at,Bb=He,Mb=ci,Vb=Bi,Fb=Cn,Ub=Dn,jb=ed;Ob({target:"Promise",stat:!0,forced:jb},{all:function(e){var t=this,s=Vb.f(t),r=s.resolve,n=s.reject,o=Fb(function(){var l=Mb(t.resolve),d=[],u=0,c=1;Ub(e,function(h){var f=u++,p=!1;c++,Bb(l,t,h).then(function(m){p||(p=!0,d[f]=m,--c||r(d))},n)}),--c||r(d)});return o.error&&n(o.value),s.promise}});var Hb=at,Gb=bs.CONSTRUCTOR,nl=Oi;nl&&nl.prototype;Hb({target:"Promise",proto:!0,forced:Gb,real:!0},{catch:function(i){return this.then(void 0,i)}});var Yb=at,zb=He,qb=ci,Wb=Bi,Qb=Cn,Kb=Dn,Jb=ed;Yb({target:"Promise",stat:!0,forced:Jb},{race:function(e){var t=this,s=Wb.f(t),r=s.reject,n=Qb(function(){var o=qb(t.resolve);Kb(e,function(l){zb(o,t,l).then(s.resolve,r)})});return n.error&&r(n.value),s.promise}});var Xb=at,Zb=He,eg=Bi,tg=bs.CONSTRUCTOR;Xb({target:"Promise",stat:!0,forced:tg},{reject:function(e){var t=eg.f(this);return Zb(t.reject,void 0,e),t.promise}});var ig=xt,sg=Ct,rg=Bi,td=function(i,e){if(ig(i),sg(e)&&e.constructor===i)return e;var t=rg.f(i),s=t.resolve;return s(e),t.promise},ag=at,ng=di,og=Bc,lg=Oi,ug=bs.CONSTRUCTOR,dg=td,cg=ng("Promise"),hg=!ug;ag({target:"Promise",stat:!0,forced:og},{resolve:function(e){return dg(hg&&this===cg?lg:this,e)}});var fg=at,on=Oi,pg=Ke,mg=di,vg=pe,bg=Cu,ol=td,gg=on&&on.prototype,Sg=!!on&&pg(function(){gg.finally.call({then:function(){}},function(){})});fg({target:"Promise",proto:!0,real:!0,forced:Sg},{finally:function(i){var e=bg(this,mg("Promise")),t=vg(i);return this.then(t?function(s){return ol(e,i()).then(function(){return s})}:i,t?function(s){return ol(e,i()).then(function(){throw s})}:i)}});var yg=di,Bn=yg,Tg=Bn,Eg=Tg("Promise","finally"),$g=Eg,kg=$g,Ag=kg,wg=Ag,Ss=fr(wg),ae;(function(i){i[i.OFFSET_P=0]="OFFSET_P",i[i.PLAYBACK_SHIFT=1]="PLAYBACK_SHIFT",i[i.DASH_CMAF_OFFSET_P=2]="DASH_CMAF_OFFSET_P"})(ae||(ae={}));var Pe=(i,e=0,t=ae.OFFSET_P)=>{switch(t){case ae.OFFSET_P:return i.replace("_offset_p",e===0?"":"_"+e.toFixed(0));case ae.PLAYBACK_SHIFT:{if(e===0)return i;const s=new URL(i);return s.searchParams.append("playback_shift",e.toFixed(0)),s.toString()}case ae.DASH_CMAF_OFFSET_P:{const s=new URL(i);return!s.searchParams.get("offset_p")&&e===0?i:(s.searchParams.set("offset_p",e.toFixed(0)),s.toString())}default:a.assertNever(t)}return i};const er=(i,e)=>{var t;switch(e){case ae.OFFSET_P:return NaN;case ae.PLAYBACK_SHIFT:{const s=new URL(i);return Number(s.searchParams.get("playback_shift"))}case ae.DASH_CMAF_OFFSET_P:{const s=new URL(i);return Number((t=s.searchParams.get("offset_p"))!==null&&t!==void 0?t:0)}default:a.assertNever(e)}};var w=(i,e,t=!1)=>{const s=i.getTransition();(t||!s||s.to===e)&&i.setState(e)};class ee{constructor(e){this.transitionStarted$=new a.Subject,this.transitionEnded$=new a.Subject,this.transitionUpdated$=new a.Subject,this.forceChanged$=new a.Subject,this.stateChangeStarted$=a.merge(this.transitionStarted$,this.transitionUpdated$),this.stateChangeEnded$=a.merge(this.transitionEnded$,this.forceChanged$),this.state=e,this.prevState=void 0}setState(e){const t=this.transition,s=this.state;this.transition=void 0,this.prevState=s,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:s,to:e,canceledTransition:t})}startTransitionTo(e){const t=this.transition,s=this.state;s===e||a.isNonNullable(t)&&t.to===e||(this.prevState=s,this.state=e,t?(this.transition={from:t.from,to:e,canceledTransition:t},this.transitionUpdated$.next(this.transition)):(this.transition={from:s,to:e},this.transitionStarted$.next(this.transition)))}getTransition(){return this.transition}getState(){return this.state}getPrevState(){return this.prevState}}const Pg=i=>{switch(i){case exports.VideoFormat.MPEG:case exports.VideoFormat.DASH:case exports.VideoFormat.DASH_SEP:case exports.VideoFormat.DASH_ONDEMAND:case exports.VideoFormat.DASH_WEBM:case exports.VideoFormat.DASH_WEBM_AV1:case exports.VideoFormat.HLS:case exports.VideoFormat.HLS_ONDEMAND:return!1;case exports.VideoFormat.DASH_LIVE:case exports.VideoFormat.DASH_LIVE_CMAF:case exports.VideoFormat.HLS_LIVE:case exports.VideoFormat.HLS_LIVE_CMAF:case exports.VideoFormat.DASH_LIVE_WEBM:case exports.VideoFormat.WEB_RTC_LIVE:return!0;default:return a.assertNever(i)}};var G;(function(i){i.STOPPED="stopped",i.READY="ready",i.PLAYING="playing",i.PAUSED="paused"})(G||(G={}));const _g=5,Dg=5,Ig=500,ll=7e3;class Rg{constructor(e){this.subscription=new a.Subscription,this.loadMediaTimeoutSubscription=new a.Subscription,this.videoState=new ee(G.STOPPED),this.syncPlayback=()=>{const s=this.videoState.getState(),r=this.videoState.getTransition(),n=this.params.desiredState.playbackState.getState(),o=this.params.desiredState.playbackState.getTransition(),l=this.params.desiredState.seekState.getState();if(this.log({message:`[syncPlayback] videoState: ${s}; videoTransition: ${JSON.stringify(r)}; desiredPlaybackState: ${n}; desiredPlaybackStateTransition: ${this.params.desiredState.playbackState.getTransition()}; seekState: ${JSON.stringify(l)};`}),n===exports.PlaybackState.STOPPED){s!==G.STOPPED&&(this.videoState.startTransitionTo(G.STOPPED),this.stop());return}if(!r){if((o==null?void 0:o.to)!==exports.PlaybackState.PAUSED&&l.state===Y.Requested&&s!==G.STOPPED){this.seek(l.position/1e3);return}switch(n){case exports.PlaybackState.READY:{switch(s){case G.PLAYING:case G.PAUSED:case G.READY:break;case G.STOPPED:this.videoState.startTransitionTo(G.READY),this.prepare();break;default:a.assertNever(s)}break}case exports.PlaybackState.PLAYING:{switch(s){case G.PLAYING:break;case G.PAUSED:this.videoState.startTransitionTo(G.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case G.READY:this.videoState.startTransitionTo(G.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case G.STOPPED:this.videoState.startTransitionTo(G.READY),this.prepare();break;default:a.assertNever(s)}break}case exports.PlaybackState.PAUSED:{switch(s){case G.PLAYING:this.videoState.startTransitionTo(G.PAUSED),this.params.connection.remotePlayerController.playOrPause();break;case G.PAUSED:break;case G.READY:this.videoState.startTransitionTo(G.PAUSED),this.videoState.setState(G.PAUSED);break;case G.STOPPED:this.videoState.startTransitionTo(G.READY),this.prepare();break;default:a.assertNever(s)}break}default:a.assertNever(n)}}},this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastProvider"),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(Pg(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 a.Subscription;this.subscription.add(e),this.subscription.add(a.merge(this.videoState.stateChangeStarted$.pipe(a.map(r=>`stateChangeStarted$ ${JSON.stringify(r)}`)),this.videoState.stateChangeEnded$.pipe(a.map(r=>`stateChangeEnded$ ${JSON.stringify(r)}`))).subscribe(r=>this.log({message:`[videoState] ${r}`})));const t=(r,n)=>this.subscription.add(r.subscribe(n));if(this.params.output.isLive$.getValue())this.params.output.position$.next(0),this.params.output.duration$.next(0);else{const r=new a.Subject;e.add(r.pipe(a.debounce(Ig)).subscribe(()=>{this.params.output.seekedEvent$.next()}));let n=NaN;e.add(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED).subscribe(o=>{this.logRemoteEvent(o);const l=o.value;this.params.output.position$.next(l),(this.params.desiredState.seekState.getState().state===Y.Applying||Math.abs(l-n)>_g)&&r.next(l),n=l})),e.add(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.DURATION_CHANGED).subscribe(o=>{this.logRemoteEvent(o),this.params.output.duration$.next(o.value)}))}t(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED),r=>{this.logRemoteEvent(r),r.value?this.handleRemoteReady():(this.handleRemoteStop(),e.unsubscribe())}),t(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),r=>{this.logRemoteEvent(r),r.value?this.handleRemotePause():this.handleRemotePlay()}),t(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED),r=>{this.logRemoteEvent(r);const{remotePlayer:n}=this.params.connection,o=r.value,l=this.params.output.isBuffering$.getValue(),d=o===chrome.cast.media.PlayerState.BUFFERING;switch(l!==d&&this.params.output.isBuffering$.next(d),o){case chrome.cast.media.PlayerState.IDLE:!this.params.output.isLive$.getValue()&&n.duration-n.currentTime<Dg&&this.params.output.endedEvent$.next(),this.handleRemoteStop(),w(this.params.desiredState.playbackState,exports.PlaybackState.STOPPED);break;case chrome.cast.media.PlayerState.PAUSED:{this.handleRemotePause();break}case chrome.cast.media.PlayerState.PLAYING:this.handleRemotePlay();break;case chrome.cast.media.PlayerState.BUFFERING:break;default:a.assertNever(o)}}),t(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED),r=>{this.logRemoteEvent(r),this.handleRemoteVolumeChange({volume:r.value})}),t(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),r=>{this.logRemoteEvent(r),this.handleRemoteVolumeChange({muted:r.value})});const s=a.merge(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,a.observableFrom(["init"])).pipe(a.debounce(0));t(s,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(G.PAUSED),w(this.params.desiredState.playbackState,exports.PlaybackState.PAUSED)):(this.videoState.setState(G.PLAYING),w(this.params.desiredState.playbackState,exports.PlaybackState.PLAYING));const s=this.params.output.isLive$.getValue();this.params.output.duration$.next(s?0:t.duration),this.params.output.position$.next(s?0:t.currentTime),this.params.desiredState.seekState.setState({state:Y.None})}}prepare(){const e=this.params.format;this.log({message:`[prepare] format: ${e}`});const t=this.createMediaInfo(e),s=this.createLoadRequest(t);this.loadMedia(s)}handleRemotePause(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===G.PAUSED||e===G.PLAYING)&&(this.videoState.setState(G.PAUSED),w(this.params.desiredState.playbackState,exports.PlaybackState.PAUSED))}handleRemotePlay(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===G.PLAYING||e===G.PAUSED)&&(this.videoState.setState(G.PLAYING),w(this.params.desiredState.playbackState,exports.PlaybackState.PLAYING))}handleRemoteReady(){var e;const t=this.videoState.getTransition();(t==null?void 0:t.to)===G.READY&&this.videoState.setState(G.READY),((e=this.params.desiredState.playbackState.getTransition())===null||e===void 0?void 0:e.to)===exports.PlaybackState.READY&&w(this.params.desiredState.playbackState,exports.PlaybackState.READY)}handleRemoteStop(){this.videoState.getState()!==G.STOPPED&&this.videoState.setState(G.STOPPED)}handleRemoteVolumeChange(e){var t,s;const r=this.params.output.volume$.getValue(),n={volume:(t=e.volume)!==null&&t!==void 0?t:r.volume,muted:(s=e.muted)!==null&&s!==void 0?s:r.muted};(n.volume!==r.volume||n.muted!==n.muted)&&this.params.output.volume$.next(n)}seek(e){this.params.output.willSeekEvent$.next();const{remotePlayer:t,remotePlayerController:s}=this.params.connection;t.currentTime=e,s.seek()}stop(){const{remotePlayerController:e}=this.params.connection;e.stop()}createMediaInfo(e){var t;const s=this.params.source;let r,n,o;switch(e){case exports.VideoFormat.MPEG:{const c=s[e];a.assertNonNullable(c);const h=a.getHighestQuality(Object.keys(c));a.assertNonNullable(h);const f=c[h];a.assertNonNullable(f),r=f,n="video/mp4",o=chrome.cast.media.StreamType.BUFFERED;break}case exports.VideoFormat.HLS:case exports.VideoFormat.HLS_ONDEMAND:{const c=s[e];a.assertNonNullable(c),r=c.url,n="application/x-mpegurl",o=chrome.cast.media.StreamType.BUFFERED;break}case exports.VideoFormat.DASH_SEP:case exports.VideoFormat.DASH_ONDEMAND:case exports.VideoFormat.DASH_WEBM:case exports.VideoFormat.DASH_WEBM_AV1:{const c=s[e];a.assertNonNullable(c),r=c.url,n="application/dash+xml",o=chrome.cast.media.StreamType.BUFFERED;break}case exports.VideoFormat.DASH_LIVE_CMAF:{const c=s[e];a.assertNonNullable(c),r=c.url,n="application/dash+xml",o=chrome.cast.media.StreamType.LIVE;break}case exports.VideoFormat.HLS_LIVE:case exports.VideoFormat.HLS_LIVE_CMAF:{const c=s[e];a.assertNonNullable(c),r=Pe(c.url),n="application/x-mpegurl",o=chrome.cast.media.StreamType.LIVE;break}case exports.VideoFormat.DASH:case exports.VideoFormat.DASH_LIVE:case exports.VideoFormat.WEB_RTC_LIVE:{const c="Unsupported format for Chromecast",h=new Error(c);throw this.params.output.error$.next({id:"ChromecastProvider.createMediaInfo()",category:a.ErrorCategory.VIDEO_PIPELINE,message:c,thrown:h}),h}case exports.VideoFormat.DASH_LIVE_WEBM:throw new Error("DASH_LIVE_WEBM is no longer supported");default:return a.assertNever(e)}const l=new chrome.cast.media.MediaInfo((t=this.params.meta.videoId)!==null&&t!==void 0?t:r,n);l.contentUrl=r,l.streamType=o,l.metadata=new chrome.cast.media.GenericMediaMetadata;const{title:d,subtitle:u}=this.params.meta;return a.isNonNullable(d)&&(l.metadata.title=d),a.isNonNullable(u)&&(l.metadata.subtitle=u),l}createLoadRequest(e){const t=new chrome.cast.media.LoadRequest(e);t.autoplay=!1;const s=this.params.desiredState.seekState.getState();return s.state===Y.Applying||s.state===Y.Requested?t.currentTime=this.params.output.isLive$.getValue()?0:s.position/1e3:t.currentTime=0,t}loadMedia(e){const t=this.params.connection.session.loadMedia(e),s=new Promise((r,n)=>{this.loadMediaTimeoutSubscription.add(a.timeout(ll).subscribe(()=>n(`timeout(${ll})`)))});Ss(Promise.race([t,s]).then(()=>{this.log({message:`[loadMedia] completed, format: ${this.params.format}`}),this.params.desiredState.seekState.getState().state===Y.Applying&&this.params.output.seekedEvent$.next(),this.handleRemoteReady()},r=>{const n=`[prepare] loadMedia failed, format: ${this.params.format}, reason: ${r}`;this.log({message:n}),this.params.output.error$.next({id:"ChromecastProvider.loadMedia",category:a.ErrorCategory.VIDEO_PIPELINE,message:n,thrown:r})}),()=>{this.loadMediaTimeoutSubscription.unsubscribe()})}logRemoteEvent(e){this.log({message:`[remoteEvent] ${JSON.stringify(e)}`})}}var Cg=i=>{let e,t=!1,s=!1;i.on("playbackTimeUpdated",({timeToEnd:r})=>{s=r<=3,t&&s&&(e==null||e())}),i.extend("MediaSourceController",function(){const{parent:r}=this,n=r.signalEndOfStream;return{signalEndOfStream:o=>{t=!0,e=()=>n(o),t&&s&&(e==null||e())}}},!0)},xg=i=>{const e=new a.ValueSubject(1/0),t=new a.Subject,s=new a.ValueSubject(void 0),r=new a.ValueSubject(void 0);let n=NaN,o=!1;const l=()=>{n=Date.now(),o=!1},d=c=>{var h,f,p,m,g;const S=ni(c.getAllResponseHeaders().trim().split(/[\n\r]+/).map(b=>b.split(": ")));if("x-playback-duration"in S||"x-playback-duration-millis"in S){const b=parseInt((h=c.getResponseHeader("X-Playback-Duration"))!==null&&h!==void 0?h:"",10),T=parseInt((f=c.getResponseHeader("X-Playback-Duration-Millis"))!==null&&f!==void 0?f:"",10),E=(p=T!=null?T:b*1e3)!==null&&p!==void 0?p:NaN;a.isNonNullable(E)&&!isNaN(E)&&e.next(E)}const v=(m=S["x-delivery-type"])!==null&&m!==void 0?m:exports.HttpConnectionType.HTTP1,y=(g={1:!0,0:!1}[S["x-reused"]])!==null&&g!==void 0?g:void 0;s.next(v),r.next(y)},u=c=>{c.readyState>=2&&!o&&(o=!0,t.next(Date.now()-n))};return i.extend("XHRLoader",function(){const{parent:c}=this,h=c.load.bind(c);return{load:function(f){if(f.request.type==="MPD"){const p=f.onload,m=f.progress;f.onload=function(...g){return d(this),p(...g)},f.progress=function(...g){return u(this),m(...g)},l()}return h(f)}}},!0),{playbackDuration$:e,ping$:t,connectionReused$:r,connectionType$:s}},Ut=i=>{const e=new URL(i);return e.searchParams.set("quic","1"),e.toString()},Lg=i=>i.extend("RequestModifier",()=>({modifyRequestURL:Ut}),!0),Ng=i=>{i.extend("HTTPLoader",function(){const{parent:e}=this,t=e.load;return{load:s=>{if(s.request&&s.request.range){const[r,n]=s.request.range.split("-").map(l=>parseInt(l,10)),o=new URL(s.request.url,location.href);o.searchParams.append("bytes",`${r}-${n}`),s.request.url=o.toString(),s.request.range=void 0}t(s)}}},!0)};const rt=(i,e,t,{equal:s=(o,l)=>o===l,changed$:r,onError:n}={})=>{const o=i.getState(),l=e(),d=a.isNullable(r),u=new a.Subscription;return r&&u.add(r.subscribe(c=>{const h=i.getState();s(c,h)&&i.setState(c)},n)),s(l,o)||(t(o),d&&i.setState(o)),u.add(i.stateChangeStarted$.subscribe(c=>{t(c.to),d&&i.setState(c.to)},n)),u},Ht=(i,e,t)=>rt(e,()=>i.loop,s=>{a.isNonNullable(s)&&(i.loop=s)},{onError:t}),vt=(i,e,t,s)=>rt(e,()=>({muted:i.muted,volume:i.volume}),r=>{a.isNonNullable(r)&&(i.muted=r.muted,i.volume=r.volume)},{equal:(r,n)=>r===n||(r==null?void 0:r.muted)===(n==null?void 0:n.muted)&&(r==null?void 0:r.volume)===(n==null?void 0:n.volume),changed$:t,onError:s}),Lt=(i,e,t,s)=>rt(e,()=>i.playbackRate,r=>{a.isNonNullable(r)&&(i.playbackRate=r)},{changed$:t,onError:s}),Og=i=>["__",i.language,i.label].join("|"),Bg=(i,e)=>{if(i.id===e)return!0;const[t,s,r]=e.split("|");return i.language===s&&i.label===r};class nt{constructor(){this.available$=new a.Subject,this.current$=new a.ValueSubject(void 0),this.error$=new a.Subject,this.subscription=new a.Subscription,this.externalTracks=new Map,this.internalTracks=new Map}connect(e,t,s){this.video=e,this.cueSettings=t.textTrackCuesSettings,this.subscribe();const r=n=>{this.error$.next({id:"TextTracksManager",category:a.ErrorCategory.WTF,message:"Generic HtmlVideoTextTrackManager error",thrown:n})};this.subscription.add(this.available$.subscribe(s.availableTextTracks$)),this.subscription.add(this.current$.subscribe(s.currentTextTrack$)),this.subscription.add(this.error$.subscribe(s.error$)),this.subscription.add(rt(t.internalTextTracks,()=>Object.values(this.internalTracks),n=>{a.isNonNullable(n)&&this.setInternal(n)},{equal:(n,o)=>a.isNonNullable(n)&&a.isNonNullable(o)&&n.length===o.length&&n.every(({id:l},d)=>l===o[d].id),changed$:this.available$.pipe(a.map(n=>n.filter(({type:o})=>o==="internal"))),onError:r})),this.subscription.add(rt(t.externalTextTracks,()=>Object.values(this.externalTracks),n=>{a.isNonNullable(n)&&this.setExternal(n)},{equal:(n,o)=>a.isNonNullable(n)&&a.isNonNullable(o)&&n.length===o.length&&n.every(({id:l},d)=>l===o[d].id),changed$:this.available$.pipe(a.map(n=>n.filter(({type:o})=>o==="external"))),onError:r})),this.subscription.add(rt(t.currentTextTrack,()=>{if(this.video)return;const n=this.htmlTextTracksAsArray().find(({mode:o})=>o==="showing");return n&&this.htmlTextTrackToITextTrack(n).id},n=>this.select(n),{changed$:this.current$,onError:r})),this.subscription.add(rt(t.textTrackCuesSettings,()=>({}),()=>{if(this.video)for(const n of this.htmlTextTracksAsArray())this.applyCueSettings(n.cues),this.applyCueSettings(n.activeCues)}))}subscribe(){a.assertNonNullable(this.video);const{textTracks:e}=this.video;this.subscription.add(a.fromEvent(e,"addtrack").subscribe(()=>{const s=this.current$.getValue();s&&this.select(s)})),this.subscription.add(a.merge(a.fromEvent(e,"addtrack"),a.fromEvent(e,"removetrack"),a.observableFrom(["init"])).pipe(a.map(()=>this.htmlTextTracksAsArray().map(s=>this.htmlTextTrackToITextTrack(s))),a.filterChanged((s,r)=>s.length===r.length&&s.every(({id:n},o)=>n===r[o].id))).subscribe(this.available$)),this.subscription.add(a.merge(a.fromEvent(e,"change"),a.observableFrom(["init"])).pipe(a.map(()=>this.htmlTextTracksAsArray().find(({mode:s})=>s==="showing")),a.map(s=>s&&this.htmlTextTrackToITextTrack(s).id),a.filterChanged()).subscribe(this.current$));const t=s=>{var r,n;return this.applyCueSettings((n=(r=s.target)===null||r===void 0?void 0:r.activeCues)!==null&&n!==void 0?n:null)};this.subscription.add(a.fromEvent(e,"addtrack").subscribe(s=>{var r,n;(r=s.track)===null||r===void 0||r.addEventListener("cuechange",t);const o=l=>{var d,u,c,h,f;const p=(u=(d=l.target)===null||d===void 0?void 0:d.cues)!==null&&u!==void 0?u:null;p&&p.length&&(this.applyCueSettings((h=(c=l.target)===null||c===void 0?void 0:c.cues)!==null&&h!==void 0?h:null),(f=l.target)===null||f===void 0||f.removeEventListener("cuechange",o))};(n=s.track)===null||n===void 0||n.addEventListener("cuechange",o)})),this.subscription.add(a.fromEvent(e,"removetrack").subscribe(s=>{var r;(r=s.track)===null||r===void 0||r.removeEventListener("cuechange",t)}))}applyCueSettings(e){if(!e||!e.length)return;const t=this.cueSettings.getState();for(const s of Array.from(e)){const r=s;a.isNonNullable(t.align)&&(r.align=t.align),a.isNonNullable(t.position)&&(r.position=t.position),a.isNonNullable(t.size)&&(r.size=t.size),a.isNonNullable(t.line)&&(r.line=t.line)}}htmlTextTracksAsArray(e=!1){a.assertNonNullable(this.video);const t=[...this.video.textTracks];return e?t:t.filter(nt.isHealthyTrack)}htmlTextTrackToITextTrack(e){var t,s;const{language:r,label:n}=e,o=e.id?e.id:Og(e),l=this.externalTracks.has(o),d=o.includes("auto");return l?{id:o,type:"external",isAuto:d,language:r,label:n,url:(t=this.externalTracks.get(o))===null||t===void 0?void 0:t.url}:{id:o,type:"internal",isAuto:d,language:r,label:n,url:(s=this.internalTracks.get(o))===null||s===void 0?void 0:s.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(s=>s.id===t)).forEach(([,t])=>this.detach(t))}setInternal(e){const t=[...this.externalTracks];e.filter(({id:s,language:r,isAuto:n})=>!this.internalTracks.has(s)&&!t.some(([,o])=>o.language===r&&o.isAuto===n)).forEach(s=>this.attach(s)),Array.from(this.internalTracks).filter(([s])=>!e.find(r=>r.id===s)).forEach(([,s])=>this.detach(s))}select(e){a.assertNonNullable(this.video);for(const t of this.htmlTextTracksAsArray(!0))t.mode="showing";for(const t of this.htmlTextTracksAsArray(!0))(a.isNullable(e)||!Bg(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){a.assertNonNullable(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){a.assertNonNullable(this.video);const t=Array.prototype.find.call(this.video.getElementsByTagName("track"),s=>s.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 Mn=i=>{i.removeAttribute("src"),i.load()},Mg=i=>{try{i.pause(),i.playbackRate=0,Mn(i),i.remove()}catch(e){console.error(e)}};class Vg{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 ln=window.WeakMap?new WeakMap:new Vg,bt=i=>{let e=i.querySelector("video");const t=!!e;return e?Mn(e):(e=document.createElement("video"),i.appendChild(e)),ln.set(e,t),e.setAttribute("crossorigin","anonymous"),e.setAttribute("playsinline","playsinline"),e.controls=!1,e.setAttribute("poster","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),e},gt=i=>{const e=ln.get(i);ln.delete(i),e?Mn(i):Mg(i)};class ys{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 id=i=>{var e;let t=i;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},ul=i=>{const e=id(i);return!!(e&&e.fullscreenElement&&e.fullscreenElement===i)},Fg=i=>{const e=id(i);return!!(e&&e.pictureInPictureElement&&e.pictureInPictureElement===i)},un=3;class Ug{constructor(e){this._buffer=[],this._source=e}fill(){this._buffer=[];const e=this._source.currentTime;for(let t=0,s=this._source.buffered.length;t<s;t++){let r=this._source.buffered.start(t);const n=this._source.buffered.end(t);r>e&&r-e<un&&(r=e),this._buffer.push({from:r,to:n,i:t})}return this._buffer.sort(function(t,s){return t.from-s.from}),this._buffer}getByTime(e){return this._buffer.find(t=>e>=t.from&&e<t.to)}getNextWithGap(e,t){const s=this.getNext(e);if(s&&s.from-e.to<(t||un))return s}getNext(e){let t=this._buffer.indexOf(e);if(~t&&this._buffer.length-1>t)return this._buffer[++t]}smartRemove(e,t,s){this._buffer.forEach(({from:r,to:n})=>{const o=r>=e&&r<t,l=n>=e&&n<t;o&&l||(o?s(t,n):l?s(r,e):r<e&&n>t?(s(t,n),s(r,e)):s(r,n))})}destroy(){this._buffer=[]}}var sd=(i,e,t=un)=>{let s=0,r=0;for(let n=0;n<i.length;n++){const o=i.start(n),l=i.end(n);if(o<=e&&e<=l){if(s=o,r=l,!t)return{from:s,to:r};for(let d=n-1;d>=0;d--)i.end(d)+t>=s&&(s=i.start(d));for(let d=n+1;d<i.length;d++)i.start(d)-t<=r&&(r=i.end(d))}}return{from:s,to:r}};const St=i=>{const e=b=>a.fromEvent(i,b).pipe(a.mapTo(void 0)),t=["waiting","pause","canplay","play","canplaythrough","playing","seeking","seeked","ended"],s=a.merge(...t.map(b=>a.fromEvent(i,b))).pipe(a.map(b=>b.type==="ended"?i.readyState<2:i.readyState<3),a.filterChanged()),r=a.merge(a.fromEvent(i,"progress"),a.fromEvent(i,"timeupdate")).pipe(a.map(()=>sd(i.buffered,i.currentTime))),o=a.getCurrentBrowser().browser===a.CurrentClientBrowser.Safari?a.combine({play:e("play").pipe(a.once()),playing:e("playing")}).pipe(a.mapTo(void 0)):e("playing"),l=a.fromEvent(i,"volumechange").pipe(a.map(()=>({muted:i.muted,volume:i.volume}))),d=a.fromEvent(i,"ratechange").pipe(a.map(()=>i.playbackRate)),u=a.fromEvent(i,"error").pipe(a.filter(()=>!!(i.error||i.played.length)),a.map(()=>{var b;const T=i.error;return{id:T?`MediaError#${T.code}`:"HtmlVideoError",category:a.ErrorCategory.VIDEO_PIPELINE,message:T?T.message:"Error event from HTML video element",thrown:(b=i.error)!==null&&b!==void 0?b:void 0}})),c=a.fromEvent(i,"timeupdate").pipe(a.map(()=>i.currentTime)),h=new a.Subject,f=.3;let p;c.subscribe(b=>{i.loop&&a.isNonNullable(p)&&a.isNonNullable(b)&&p>=i.duration-f&&b<=f&&h.next(p),p=b});const m=a.fromEvent(i,"enterpictureinpicture"),g=a.fromEvent(i,"leavepictureinpicture"),S=new a.ValueSubject(Fg(i));m.subscribe(()=>S.next(!0)),g.subscribe(()=>S.next(!1));const v=new a.ValueSubject(ul(i));return a.fromEvent(i,"fullscreenchange").pipe(a.map(()=>ul(i))).subscribe(v),{playing$:o,pause$:e("pause").pipe(a.filter(()=>!i.error)),canplay$:e("canplay"),ended$:e("ended"),looped$:h,error$:u,seeked$:e("seeked"),seeking$:e("seeking"),progress$:e("progress"),loadStart$:e("loadstart"),loadedMetadata$:e("loadedmetadata"),loadedData$:e("loadeddata"),timeUpdate$:c,durationChange$:a.fromEvent(i,"durationchange").pipe(a.map(()=>i.duration)),isBuffering$:s,currentBuffer$:r,volumeState$:l,playbackRateState$:d,inPiP$:S,inFullscreen$:v}},kr=i=>{if(i.includes("/")){const e=i.split("/");return parseInt(e[0])/parseInt(e[1])}else return parseFloat(i)};var jg=at,Hg=Sr,Gg=An,Yg=kn;jg({target:"Array",proto:!0},{at:function(e){var t=Hg(this),s=Gg(t),r=Yg(e),n=r>=0?r:s+r;return n<0||n>=s?void 0:t[n]}});var zg=Bn,qg=zg("Array","at"),Wg=qg,Qg=Wg,Kg=Qg,Jg=Kg,ge=fr(Jg);let Vn=!1,_t={};const Xg=i=>{Vn=i},Zg=()=>{_t={}},eS=i=>{i(_t)},Os=(i,e)=>{var t;Vn&&(_t.meta=(t=_t.meta)!==null&&t!==void 0?t:{},_t.meta[i]=e)};class ct{constructor(e){this.name=e}next(e){var t,s;if(!Vn)return;_t.series=(t=_t.series)!==null&&t!==void 0?t:{};const r=(s=_t.series[this.name])!==null&&s!==void 0?s:[];r.push([Date.now(),e]),_t.series[this.name]=r}}var si;(function(i){i.FitsContainer="FitsContainer",i.FitsThroughput="FitsThroughput",i.Buffer="Buffer",i.DroppedFramesLimit="DroppedFramesLimit",i.FitsQualityLimits="FitsQualityLimits"})(si||(si={}));const tS=new ct("best_bitrate"),iS=(i,e,t)=>(e-t)*Math.pow(2,-10*i)+t;class rd{constructor(){this.history={}}recordSelection(e){this.history[e.id]=a.now()}recordSwitch(e){this.last=e}clear(){this.last=void 0,this.history={}}}const sS='Assertion "ABR Tracks is empty array" failed',hi=(i,{container:e,throughput:t,tuning:s,limits:r,reserve:n=0,forwardBufferHealth:o,playbackRate:l,current:d,history:u,droppedVideoMaxQualityLimit:c,abrLogger:h})=>{var f,p,m,g,S;a.assertNotEmptyArray(i,sS);const v=s.usePixelRatio&&(f=window.devicePixelRatio)!==null&&f!==void 0?f:1,y=s.limitByContainer&&e&&e.width>0&&e.height>0&&{width:e.width*v*s.containerSizeFactor,height:e.height*v*s.containerSizeFactor},b=y&&a.videoSizeToQuality(y),T=s.considerPlaybackRate&&a.isNonNullable(l)?l:1,E=i.filter(R=>!a.isInvariantQuality(R.quality)).sort((R,_)=>a.isHigher(R.quality,_.quality)?-1:1),P=(p=ge(E,-1))===null||p===void 0?void 0:p.quality,N=(m=ge(E,0))===null||m===void 0?void 0:m.quality,V=a.isNullable(r)||a.isNonNullable(r.min)&&a.isNonNullable(r.max)&&a.isLower(r.max,r.min)||a.isNonNullable(r.min)&&N&&a.isHigher(r.min,N)||a.isNonNullable(r.max)&&P&&a.isLower(r.max,P),L=T*iS(o!=null?o:.5,s.bitrateFactorAtEmptyBuffer,s.bitrateFactorAtFullBuffer),B={},D=E.filter(R=>(b?a.isLower(R.quality,b):!0)?(a.isNonNullable(t)&&isFinite(t)&&a.isNonNullable(R.bitrate)?t-n>=R.bitrate*L:!0)?s.lazyQualitySwitch&&a.isNonNullable(s.minBufferToSwitchUp)&&d&&!a.isInvariantQuality(d.quality)&&(o!=null?o:0)<s.minBufferToSwitchUp&&a.isHigher(R.quality,d.quality)?(B[R.quality]=si.Buffer,!1):!!c&&a.isHigherOrEqual(R.quality,c)?(B[R.quality]=si.DroppedFramesLimit,!1):V||(a.isNullable(r.max)||a.isLowerOrEqual(R.quality,r.max))&&(a.isNullable(r.min)||a.isHigherOrEqual(R.quality,r.min))?!0:(B[R.quality]=si.FitsQualityLimits,!1):(B[R.quality]=si.FitsThroughput,!1):(B[R.quality]=si.FitsContainer,!1))[0];D&&D.bitrate&&tS.next(D.bitrate);const I=(g=D!=null?D:E[Math.ceil((E.length-1)/2)])!==null&&g!==void 0?g:i[0];I.quality!==((S=u==null?void 0:u.last)===null||S===void 0?void 0:S.quality)&&h({message:`
6
+ "use strict";var Rd=Object.create;var Yn=Object.defineProperty;var Cd=Object.getOwnPropertyDescriptor;var xd=Object.getOwnPropertyNames;var Ld=Object.getPrototypeOf,Nd=Object.prototype.hasOwnProperty;var Od=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of xd(e))!Nd.call(i,r)&&r!==t&&Yn(i,r,{get:()=>e[r],enumerable:!(s=Cd(e,r))||s.enumerable});return i};var zn=(i,e,t)=>(t=i!=null?Rd(Ld(i)):{},Od(e||!i||!i.__esModule?Yn(t,"default",{value:i,enumerable:!0}):t,i));var a=require("@vkontakte/videoplayer-shared/es2015.cjs.js"),Bd=require("lodash/debounce.js");const Vl="2.0.97";exports.PlaybackState=void 0;(function(i){i.STOPPED="stopped",i.READY="ready",i.PLAYING="playing",i.PAUSED="paused"})(exports.PlaybackState||(exports.PlaybackState={}));exports.VideoFormat=void 0;(function(i){i.MPEG="MPEG",i.DASH="DASH",i.DASH_SEP="DASH_SEP",i.DASH_SEP_VK="DASH_SEP",i.DASH_WEBM="DASH_WEBM",i.DASH_WEBM_AV1="DASH_WEBM_AV1",i.DASH_WEBM_VK="DASH_WEBM",i.DASH_ONDEMAND="DASH_ONDEMAND",i.DASH_ONDEMAND_VK="DASH_ONDEMAND",i.DASH_LIVE="DASH_LIVE",i.DASH_LIVE_CMAF="DASH_LIVE_CMAF",i.DASH_LIVE_WEBM="DASH_LIVE_WEBM",i.HLS="HLS",i.HLS_ONDEMAND="HLS_ONDEMAND",i.HLS_JS="HLS",i.HLS_LIVE="HLS_LIVE",i.HLS_LIVE_CMAF="HLS_LIVE_CMAF",i.WEB_RTC_LIVE="WEB_RTC_LIVE"})(exports.VideoFormat||(exports.VideoFormat={}));var Ae;(function(i){i.SCREEN="SCREEN",i.CHROMECAST="CHROMECAST"})(Ae||(Ae={}));exports.ChromecastState=void 0;(function(i){i.NOT_AVAILABLE="NOT_AVAILABLE",i.AVAILABLE="AVAILABLE",i.CONNECTING="CONNECTING",i.CONNECTED="CONNECTED"})(exports.ChromecastState||(exports.ChromecastState={}));exports.HttpConnectionType=void 0;(function(i){i.HTTP1="http1",i.HTTP2="http2",i.QUIC="quic"})(exports.HttpConnectionType||(exports.HttpConnectionType={}));var Y;(function(i){i.None="none",i.Requested="requested",i.Applying="applying"})(Y||(Y={}));exports.Surface=void 0;(function(i){i.NONE="none",i.INLINE="inline",i.FULLSCREEN="fullscreen",i.SECOND_SCREEN="second_screen",i.PIP="pip"})(exports.Surface||(exports.Surface={}));function H(i,e,t,s){function r(n){return n instanceof t?n:new t(function(o){o(n)})}return new(t||(t=Promise))(function(n,o){function l(c){try{u(s.next(c))}catch(h){o(h)}}function d(c){try{u(s.throw(c))}catch(h){o(h)}}function u(c){c.done?n(c.value):r(c.value).then(l,d)}u((s=s.apply(i,e||[])).next())})}function A(i){return this instanceof A?(this.v=i,this):new A(i)}function Z(i,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=t.apply(i,e||[]),r,n=[];return r={},o("next"),o("throw"),o("return"),r[Symbol.asyncIterator]=function(){return this},r;function o(f){s[f]&&(r[f]=function(p){return new Promise(function(m,g){n.push([f,p,m,g])>1||l(f,p)})})}function l(f,p){try{d(s[f](p))}catch(m){h(n[0][3],m)}}function d(f){f.value instanceof A?Promise.resolve(f.value.v).then(u,c):h(n[0][2],f)}function u(f){l("next",f)}function c(f){l("throw",f)}function h(f,p){f(p),n.shift(),n.length&&l(n[0][0],n[0][1])}}var Md=i=>new Promise((e,t)=>{const s=document.createElement("script");s.setAttribute("src",i),s.onload=()=>e,s.onerror=()=>t,document.body.appendChild(s)});class Vd{constructor(e){var t;this.connection$=new a.ValueSubject(void 0),this.castState$=new a.ValueSubject(exports.ChromecastState.NOT_AVAILABLE),this.errorEvent$=new a.Subject,this.realCastState$=new a.ValueSubject(exports.ChromecastState.NOT_AVAILABLE),this.subscription=new a.Subscription,this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastInitializer");const s="chrome"in window;if(this.log({message:`[constructor] receiverApplicationId: ${this.params.receiverApplicationId}, isDisabled: ${this.params.isDisabled}, isSupported: ${s}`}),e.isDisabled||!s)return;const r=a.isNonNullable((t=window.chrome)===null||t===void 0?void 0:t.cast),n=!!window.__onGCastApiAvailable;r?this.initializeCastApi():(window.__onGCastApiAvailable=o=>{delete window.__onGCastApiAvailable,o&&this.initializeCastApi()},n||Md("https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1").catch(()=>this.errorEvent$.next({id:"ChromecastLoading",category:a.ErrorCategory.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 s,r,n;(n=(r=(s=cast.framework.CastContext.getInstance())===null||s===void 0?void 0:s.getCurrentSession())===null||r===void 0?void 0:r.getMediaSession())===null||n===void 0||n.stop(new chrome.cast.media.StopRequest,e,t)})}toggleConnection(){a.isNonNullable(this.connection$.getValue())?this.disconnect():this.connect()}setVolume(e){const t=this.connection$.getValue();a.isNullable(t)||(t.remotePlayer.volumeLevel=e,t.remotePlayerController.setVolumeLevel())}setMuted(e){const t=this.connection$.getValue();a.isNullable(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),s=cast.framework.CastContext.getInstance();this.subscription.add(a.fromEvent(s,cast.framework.CastContextEventType.SESSION_STATE_CHANGED).subscribe(r=>{var n,o;switch(r.sessionState){case cast.framework.SessionState.SESSION_STARTED:case cast.framework.SessionState.SESSION_STARTING:case cast.framework.SessionState.SESSION_RESUMED:this.contentId=(o=(n=s.getCurrentSession())===null||n===void 0?void 0:n.getMediaSession())===null||o===void 0?void 0:o.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 a.assertNever(r.sessionState)}})).add(a.merge(a.fromEvent(s,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe(a.tap(r=>{this.log({message:`[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: ${JSON.stringify(r)}`})}),a.map(r=>r.castState)),a.observableFrom([s.getCastState()])).pipe(a.filterChanged(),a.map(Fd),a.tap(r=>{this.log({message:`realCastState$: ${r}`})})).subscribe(this.realCastState$)).add(this.realCastState$.subscribe(r=>{var n;const o=r===exports.ChromecastState.CONNECTED,l=a.isNonNullable(this.connection$.getValue());if(o&&!l){const d=s.getCurrentSession();a.assertNonNullable(d);const u=d.getCastDevice(),c=(n=d.getMediaSession())===null||n===void 0?void 0:n.media.contentId;(a.isNullable(c)||c===this.contentId)&&(this.log({message:"connection created"}),this.connection$.next({remotePlayer:e,remotePlayerController:t,session:d,castDevice:u}))}else!o&&l&&(this.log({message:"connection destroyed"}),this.connection$.next(void 0));this.castState$.next(r===exports.ChromecastState.CONNECTED?a.isNonNullable(this.connection$.getValue())?exports.ChromecastState.CONNECTED:exports.ChromecastState.AVAILABLE:r)}))}initializeCastApi(){var e;let t,s,r;try{t=cast.framework.CastContext.getInstance(),s=chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,r=chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}catch(n){return}try{t.setOptions({receiverApplicationId:(e=this.params.receiverApplicationId)!==null&&e!==void 0?e:s,autoJoinPolicy:r}),this.initListeners()}catch(n){this.errorEvent$.next({id:"ChromecastInitializer",category:a.ErrorCategory.EXTERNAL_API,message:"[initializeCastApi] failed",thrown:n})}}}const Fd=i=>{switch(i){case cast.framework.CastState.NO_DEVICES_AVAILABLE:return exports.ChromecastState.NOT_AVAILABLE;case cast.framework.CastState.NOT_CONNECTED:return exports.ChromecastState.AVAILABLE;case cast.framework.CastState.CONNECTING:return exports.ChromecastState.CONNECTING;case cast.framework.CastState.CONNECTED:return exports.ChromecastState.CONNECTED;default:return a.assertNever(i)}};var Ur=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function fr(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Ke=function(i){try{return!!i()}catch(e){return!0}},Ud=Ke,pr=!Ud(function(){var i=function(){}.bind();return typeof i!="function"||i.hasOwnProperty("prototype")}),Fl=pr,Ul=Function.prototype,Ua=Ul.call,jd=Fl&&Ul.bind.bind(Ua,Ua),Je=Fl?jd:function(i){return function(){return Ua.apply(i,arguments)}},jl=Je,Hd=jl({}.toString),Gd=jl("".slice),cs=function(i){return Gd(Hd(i),8,-1)},Yd=Je,zd=Ke,qd=cs,jr=Object,Wd=Yd("".split),Qd=zd(function(){return!jr("z").propertyIsEnumerable(0)})?function(i){return qd(i)=="String"?Wd(i,""):jr(i)}:jr,hs=function(i){return i==null},Kd=hs,Jd=TypeError,mn=function(i){if(Kd(i))throw Jd("Can't call method on "+i);return i},Xd=Qd,Zd=mn,fs=function(i){return Xd(Zd(i))},Ni={},$s=function(i){return i&&i.Math==Math&&i},Te=$s(typeof globalThis=="object"&&globalThis)||$s(typeof window=="object"&&window)||$s(typeof self=="object"&&self)||$s(typeof Ur=="object"&&Ur)||function(){return this}()||Ur||Function("return this")(),ja=typeof document=="object"&&document.all,ec=typeof ja=="undefined"&&ja!==void 0,Hl={all:ja,IS_HTMLDDA:ec},Gl=Hl,tc=Gl.all,pe=Gl.IS_HTMLDDA?function(i){return typeof i=="function"||i===tc}:function(i){return typeof i=="function"},ic=Te,sc=pe,qn=ic.WeakMap,rc=sc(qn)&&/native code/.test(String(qn)),Wn=pe,Yl=Hl,ac=Yl.all,Ct=Yl.IS_HTMLDDA?function(i){return typeof i=="object"?i!==null:Wn(i)||i===ac}:function(i){return typeof i=="object"?i!==null:Wn(i)},nc=Ke,jt=!nc(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),ui={},oc=Te,Qn=Ct,Ha=oc.document,lc=Qn(Ha)&&Qn(Ha.createElement),vn=function(i){return lc?Ha.createElement(i):{}},uc=jt,dc=Ke,cc=vn,zl=!uc&&!dc(function(){return Object.defineProperty(cc("div"),"a",{get:function(){return 7}}).a!=7}),hc=jt,fc=Ke,ql=hc&&fc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),pc=Ct,mc=String,vc=TypeError,xt=function(i){if(pc(i))return i;throw vc(mc(i)+" is not an object")},bc=pr,ks=Function.prototype.call,He=bc?ks.bind(ks):function(){return ks.apply(ks,arguments)},bn={},Hr=bn,Gr=Te,gc=pe,Kn=function(i){return gc(i)?i:void 0},di=function(i,e){return arguments.length<2?Kn(Hr[i])||Kn(Gr[i]):Hr[i]&&Hr[i][e]||Gr[i]&&Gr[i][e]},Sc=Je,mr=Sc({}.isPrototypeOf),vr=typeof navigator!="undefined"&&String(navigator.userAgent)||"",Wl=Te,Yr=vr,Jn=Wl.process,Xn=Wl.Deno,Zn=Jn&&Jn.versions||Xn&&Xn.version,eo=Zn&&Zn.v8,st,Ks;eo&&(st=eo.split("."),Ks=st[0]>0&&st[0]<4?1:+(st[0]+st[1]));!Ks&&Yr&&(st=Yr.match(/Edge\/(\d+)/),(!st||st[1]>=74)&&(st=Yr.match(/Chrome\/(\d+)/),st&&(Ks=+st[1])));var Ql=Ks,to=Ql,yc=Ke,Tc=Te,Ec=Tc.String,Kl=!!Object.getOwnPropertySymbols&&!yc(function(){var i=Symbol();return!Ec(i)||!(Object(i)instanceof Symbol)||!Symbol.sham&&to&&to<41}),$c=Kl,Jl=$c&&!Symbol.sham&&typeof Symbol.iterator=="symbol",kc=di,Ac=pe,wc=mr,Pc=Jl,_c=Object,Xl=Pc?function(i){return typeof i=="symbol"}:function(i){var e=kc("Symbol");return Ac(e)&&wc(e.prototype,_c(i))},Dc=String,br=function(i){try{return Dc(i)}catch(e){return"Object"}},Ic=pe,Rc=br,Cc=TypeError,ci=function(i){if(Ic(i))return i;throw Cc(Rc(i)+" is not a function")},xc=ci,Lc=hs,gr=function(i,e){var t=i[e];return Lc(t)?void 0:xc(t)},zr=He,qr=pe,Wr=Ct,Nc=TypeError,Oc=function(i,e){var t,s;if(e==="string"&&qr(t=i.toString)&&!Wr(s=zr(t,i))||qr(t=i.valueOf)&&!Wr(s=zr(t,i))||e!=="string"&&qr(t=i.toString)&&!Wr(s=zr(t,i)))return s;throw Nc("Can't convert object to primitive value")},Zl={exports:{}},Bc=!0,io=Te,Mc=Object.defineProperty,Vc=function(i,e){try{Mc(io,i,{value:e,configurable:!0,writable:!0})}catch(t){io[i]=e}return e},Fc=Te,Uc=Vc,so="__core-js_shared__",jc=Fc[so]||Uc(so,{}),gn=jc,ro=gn;(Zl.exports=function(i,e){return ro[i]||(ro[i]=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 eu=Zl.exports,Hc=mn,Gc=Object,Sr=function(i){return Gc(Hc(i))},Yc=Je,zc=Sr,qc=Yc({}.hasOwnProperty),mt=Object.hasOwn||function(e,t){return qc(zc(e),t)},Wc=Je,Qc=0,Kc=Math.random(),Jc=Wc(1 .toString),tu=function(i){return"Symbol("+(i===void 0?"":i)+")_"+Jc(++Qc+Kc,36)},Xc=Te,Zc=eu,ao=mt,eh=tu,th=Kl,ih=Jl,ki=Xc.Symbol,Qr=Zc("wks"),sh=ih?ki.for||ki:ki&&ki.withoutSetter||eh,De=function(i){return ao(Qr,i)||(Qr[i]=th&&ao(ki,i)?ki[i]:sh("Symbol."+i)),Qr[i]},rh=He,no=Ct,oo=Xl,ah=gr,nh=Oc,oh=De,lh=TypeError,uh=oh("toPrimitive"),dh=function(i,e){if(!no(i)||oo(i))return i;var t=ah(i,uh),s;if(t){if(e===void 0&&(e="default"),s=rh(t,i,e),!no(s)||oo(s))return s;throw lh("Can't convert object to primitive value")}return e===void 0&&(e="number"),nh(i,e)},ch=dh,hh=Xl,Sn=function(i){var e=ch(i,"string");return hh(e)?e:e+""},fh=jt,ph=zl,mh=ql,As=xt,lo=Sn,vh=TypeError,Kr=Object.defineProperty,bh=Object.getOwnPropertyDescriptor,Jr="enumerable",Xr="configurable",Zr="writable";ui.f=fh?mh?function(e,t,s){if(As(e),t=lo(t),As(s),typeof e=="function"&&t==="prototype"&&"value"in s&&Zr in s&&!s[Zr]){var r=bh(e,t);r&&r[Zr]&&(e[t]=s.value,s={configurable:Xr in s?s[Xr]:r[Xr],enumerable:Jr in s?s[Jr]:r[Jr],writable:!1})}return Kr(e,t,s)}:Kr:function(e,t,s){if(As(e),t=lo(t),As(s),ph)try{return Kr(e,t,s)}catch(r){}if("get"in s||"set"in s)throw vh("Accessors not supported");return"value"in s&&(e[t]=s.value),e};var yr=function(i,e){return{enumerable:!(i&1),configurable:!(i&2),writable:!(i&4),value:e}},gh=jt,Sh=ui,yh=yr,ps=gh?function(i,e,t){return Sh.f(i,e,yh(1,t))}:function(i,e,t){return i[e]=t,i},Th=eu,Eh=tu,uo=Th("keys"),yn=function(i){return uo[i]||(uo[i]=Eh(i))},Tn={},$h=rc,iu=Te,kh=Ct,Ah=ps,ea=mt,ta=gn,wh=yn,Ph=Tn,co="Object already initialized",Ga=iu.TypeError,_h=iu.WeakMap,Js,os,Xs,Dh=function(i){return Xs(i)?os(i):Js(i,{})},Ih=function(i){return function(e){var t;if(!kh(e)||(t=os(e)).type!==i)throw Ga("Incompatible receiver, "+i+" required");return t}};if($h||ta.state){var lt=ta.state||(ta.state=new _h);lt.get=lt.get,lt.has=lt.has,lt.set=lt.set,Js=function(i,e){if(lt.has(i))throw Ga(co);return e.facade=i,lt.set(i,e),e},os=function(i){return lt.get(i)||{}},Xs=function(i){return lt.has(i)}}else{var vi=wh("state");Ph[vi]=!0,Js=function(i,e){if(ea(i,vi))throw Ga(co);return e.facade=i,Ah(i,vi,e),e},os=function(i){return ea(i,vi)?i[vi]:{}},Xs=function(i){return ea(i,vi)}}var su={set:Js,get:os,has:Xs,enforce:Dh,getterFor:Ih},Rh=pr,ru=Function.prototype,ho=ru.apply,fo=ru.call,au=typeof Reflect=="object"&&Reflect.apply||(Rh?fo.bind(ho):function(){return fo.apply(ho,arguments)}),Ch=cs,xh=Je,nu=function(i){if(Ch(i)==="Function")return xh(i)},En={},ou={},lu={}.propertyIsEnumerable,uu=Object.getOwnPropertyDescriptor,Lh=uu&&!lu.call({1:2},1);ou.f=Lh?function(e){var t=uu(this,e);return!!t&&t.enumerable}:lu;var Nh=jt,Oh=He,Bh=ou,Mh=yr,Vh=fs,Fh=Sn,Uh=mt,jh=zl,po=Object.getOwnPropertyDescriptor;En.f=Nh?po:function(e,t){if(e=Vh(e),t=Fh(t),jh)try{return po(e,t)}catch(s){}if(Uh(e,t))return Mh(!Oh(Bh.f,e,t),e[t])};var Hh=Ke,Gh=pe,Yh=/#|\.prototype\./,ms=function(i,e){var t=qh[zh(i)];return t==Qh?!0:t==Wh?!1:Gh(e)?Hh(e):!!e},zh=ms.normalize=function(i){return String(i).replace(Yh,".").toLowerCase()},qh=ms.data={},Wh=ms.NATIVE="N",Qh=ms.POLYFILL="P",du=ms,mo=nu,Kh=ci,Jh=pr,Xh=mo(mo.bind),Tr=function(i,e){return Kh(i),e===void 0?i:Jh?Xh(i,e):function(){return i.apply(e,arguments)}},ws=Te,Zh=au,ef=nu,tf=pe,sf=En.f,rf=du,bi=bn,af=Tr,gi=ps,vo=mt,nf=function(i){var e=function(t,s,r){if(this instanceof e){switch(arguments.length){case 0:return new i;case 1:return new i(t);case 2:return new i(t,s)}return new i(t,s,r)}return Zh(i,this,arguments)};return e.prototype=i.prototype,e},at=function(i,e){var t=i.target,s=i.global,r=i.stat,n=i.proto,o=s?ws:r?ws[t]:(ws[t]||{}).prototype,l=s?bi:bi[t]||gi(bi,t,{})[t],d=l.prototype,u,c,h,f,p,m,g,S,v;for(f in e)u=rf(s?f:t+(r?".":"#")+f,i.forced),c=!u&&o&&vo(o,f),m=l[f],c&&(i.dontCallGetSet?(v=sf(o,f),g=v&&v.value):g=o[f]),p=c&&g?g:e[f],!(c&&typeof m==typeof p)&&(i.bind&&c?S=af(p,ws):i.wrap&&c?S=nf(p):n&&tf(p)?S=ef(p):S=p,(i.sham||p&&p.sham||m&&m.sham)&&gi(S,"sham",!0),gi(l,f,S),n&&(h=t+"Prototype",vo(bi,h)||gi(bi,h,{}),gi(bi[h],f,p),i.real&&d&&(u||!d[f])&&gi(d,f,p)))},Ya=jt,of=mt,cu=Function.prototype,lf=Ya&&Object.getOwnPropertyDescriptor,$n=of(cu,"name"),uf=$n&&function(){}.name==="something",df=$n&&(!Ya||Ya&&lf(cu,"name").configurable),cf={EXISTS:$n,PROPER:uf,CONFIGURABLE:df},hu={},hf=Math.ceil,ff=Math.floor,pf=Math.trunc||function(e){var t=+e;return(t>0?ff:hf)(t)},mf=pf,kn=function(i){var e=+i;return e!==e||e===0?0:mf(e)},vf=kn,bf=Math.max,gf=Math.min,Sf=function(i,e){var t=vf(i);return t<0?bf(t+e,0):gf(t,e)},yf=kn,Tf=Math.min,Ef=function(i){return i>0?Tf(yf(i),9007199254740991):0},$f=Ef,An=function(i){return $f(i.length)},kf=fs,Af=Sf,wf=An,bo=function(i){return function(e,t,s){var r=kf(e),n=wf(r),o=Af(s,n),l;if(i&&t!=t){for(;n>o;)if(l=r[o++],l!=l)return!0}else for(;n>o;o++)if((i||o in r)&&r[o]===t)return i||o||0;return!i&&-1}},Pf={includes:bo(!0),indexOf:bo(!1)},_f=Je,ia=mt,Df=fs,If=Pf.indexOf,Rf=Tn,go=_f([].push),Cf=function(i,e){var t=Df(i),s=0,r=[],n;for(n in t)!ia(Rf,n)&&ia(t,n)&&go(r,n);for(;e.length>s;)ia(t,n=e[s++])&&(~If(r,n)||go(r,n));return r},fu=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],xf=Cf,Lf=fu,Nf=Object.keys||function(e){return xf(e,Lf)},Of=jt,Bf=ql,Mf=ui,Vf=xt,Ff=fs,Uf=Nf;hu.f=Of&&!Bf?Object.defineProperties:function(e,t){Vf(e);for(var s=Ff(t),r=Uf(t),n=r.length,o=0,l;n>o;)Mf.f(e,l=r[o++],s[l]);return e};var jf=di,pu=jf("document","documentElement"),Hf=xt,Gf=hu,So=fu,Yf=Tn,zf=pu,qf=vn,Wf=yn,yo=">",To="<",za="prototype",qa="script",mu=Wf("IE_PROTO"),sa=function(){},vu=function(i){return To+qa+yo+i+To+"/"+qa+yo},Eo=function(i){i.write(vu("")),i.close();var e=i.parentWindow.Object;return i=null,e},Qf=function(){var i=qf("iframe"),e="java"+qa+":",t;return i.style.display="none",zf.appendChild(i),i.src=String(e),t=i.contentWindow.document,t.open(),t.write(vu("document.F=Object")),t.close(),t.F},Ps,zs=function(){try{Ps=new ActiveXObject("htmlfile")}catch(e){}zs=typeof document!="undefined"?document.domain&&Ps?Eo(Ps):Qf():Eo(Ps);for(var i=So.length;i--;)delete zs[za][So[i]];return zs()};Yf[mu]=!0;var bu=Object.create||function(e,t){var s;return e!==null?(sa[za]=Hf(e),s=new sa,sa[za]=null,s[mu]=e):s=zs(),t===void 0?s:Gf.f(s,t)},Kf=Ke,Jf=!Kf(function(){function i(){}return i.prototype.constructor=null,Object.getPrototypeOf(new i)!==i.prototype}),Xf=mt,Zf=pe,ep=Sr,tp=yn,ip=Jf,$o=tp("IE_PROTO"),Wa=Object,sp=Wa.prototype,gu=ip?Wa.getPrototypeOf:function(i){var e=ep(i);if(Xf(e,$o))return e[$o];var t=e.constructor;return Zf(t)&&e instanceof t?t.prototype:e instanceof Wa?sp:null},rp=ps,wn=function(i,e,t,s){return s&&s.enumerable?i[e]=t:rp(i,e,t),i},ap=Ke,np=pe,op=Ct,lp=bu,ko=gu,up=wn,dp=De,Qa=dp("iterator"),Su=!1,Dt,ra,aa;[].keys&&(aa=[].keys(),"next"in aa?(ra=ko(ko(aa)),ra!==Object.prototype&&(Dt=ra)):Su=!0);var cp=!op(Dt)||ap(function(){var i={};return Dt[Qa].call(i)!==i});cp?Dt={}:Dt=lp(Dt);np(Dt[Qa])||up(Dt,Qa,function(){return this});var yu={IteratorPrototype:Dt,BUGGY_SAFARI_ITERATORS:Su},hp=De,fp=hp("toStringTag"),Tu={};Tu[fp]="z";var Pn=String(Tu)==="[object z]",pp=Pn,mp=pe,qs=cs,vp=De,bp=vp("toStringTag"),gp=Object,Sp=qs(function(){return arguments}())=="Arguments",yp=function(i,e){try{return i[e]}catch(t){}},vs=pp?qs:function(i){var e,t,s;return i===void 0?"Undefined":i===null?"Null":typeof(t=yp(e=gp(i),bp))=="string"?t:Sp?qs(e):(s=qs(e))=="Object"&&mp(e.callee)?"Arguments":s},Tp=Pn,Ep=vs,$p=Tp?{}.toString:function(){return"[object "+Ep(this)+"]"},kp=Pn,Ap=ui.f,wp=ps,Pp=mt,_p=$p,Dp=De,Ao=Dp("toStringTag"),_n=function(i,e,t,s){if(i){var r=t?i:i.prototype;Pp(r,Ao)||Ap(r,Ao,{configurable:!0,value:e}),s&&!kp&&wp(r,"toString",_p)}},Ip=yu.IteratorPrototype,Rp=bu,Cp=yr,xp=_n,Lp=Ni,Np=function(){return this},Op=function(i,e,t,s){var r=e+" Iterator";return i.prototype=Rp(Ip,{next:Cp(+!s,t)}),xp(i,r,!1,!0),Lp[r]=Np,i},Bp=at,Mp=He,Eu=cf,Vp=Op,Fp=gu,Up=_n,wo=wn,jp=De,Po=Ni,$u=yu,Hp=Eu.PROPER;Eu.CONFIGURABLE;$u.IteratorPrototype;var _s=$u.BUGGY_SAFARI_ITERATORS,na=jp("iterator"),_o="keys",Ds="values",Do="entries",Gp=function(){return this},Yp=function(i,e,t,s,r,n,o){Vp(t,e,s);var l=function(v){if(v===r&&f)return f;if(!_s&&v in c)return c[v];switch(v){case _o:return function(){return new t(this,v)};case Ds:return function(){return new t(this,v)};case Do:return function(){return new t(this,v)}}return function(){return new t(this)}},d=e+" Iterator",u=!1,c=i.prototype,h=c[na]||c["@@iterator"]||r&&c[r],f=!_s&&h||l(r),p=e=="Array"&&c.entries||h,m,g,S;if(p&&(m=Fp(p.call(new i)),m!==Object.prototype&&m.next&&(Up(m,d,!0,!0),Po[d]=Gp)),Hp&&r==Ds&&h&&h.name!==Ds&&(u=!0,f=function(){return Mp(h,this)}),r)if(g={values:l(Ds),keys:n?f:l(_o),entries:l(Do)},o)for(S in g)(_s||u||!(S in c))&&wo(c,S,g[S]);else Bp({target:e,proto:!0,forced:_s||u},g);return o&&c[na]!==f&&wo(c,na,f,{name:r}),Po[e]=f,g},zp=function(i,e){return{value:i,done:e}},qp=fs,Io=Ni,ku=su;ui.f;var Wp=Yp,Is=zp,Au="Array Iterator",Qp=ku.set,Kp=ku.getterFor(Au);Wp(Array,"Array",function(i,e){Qp(this,{type:Au,target:qp(i),index:0,kind:e})},function(){var i=Kp(this),e=i.target,t=i.kind,s=i.index++;return!e||s>=e.length?(i.target=void 0,Is(void 0,!0)):t=="keys"?Is(s,!1):t=="values"?Is(e[s],!1):Is([s,e[s]],!1)},"values");Io.Arguments=Io.Array;var Jp=De,Xp=Ni,Zp=Jp("iterator"),em=Array.prototype,tm=function(i){return i!==void 0&&(Xp.Array===i||em[Zp]===i)},im=vs,Ro=gr,sm=hs,rm=Ni,am=De,nm=am("iterator"),wu=function(i){if(!sm(i))return Ro(i,nm)||Ro(i,"@@iterator")||rm[im(i)]},om=He,lm=ci,um=xt,dm=br,cm=wu,hm=TypeError,fm=function(i,e){var t=arguments.length<2?cm(i):e;if(lm(t))return um(om(t,i));throw hm(dm(i)+" is not iterable")},pm=He,Co=xt,mm=gr,vm=function(i,e,t){var s,r;Co(i);try{if(s=mm(i,"return"),!s){if(e==="throw")throw t;return t}s=pm(s,i)}catch(n){r=!0,s=n}if(e==="throw")throw t;if(r)throw s;return Co(s),t},bm=Tr,gm=He,Sm=xt,ym=br,Tm=tm,Em=An,xo=mr,$m=fm,km=wu,Lo=vm,Am=TypeError,Ws=function(i,e){this.stopped=i,this.result=e},No=Ws.prototype,Dn=function(i,e,t){var s=t&&t.that,r=!!(t&&t.AS_ENTRIES),n=!!(t&&t.IS_RECORD),o=!!(t&&t.IS_ITERATOR),l=!!(t&&t.INTERRUPTED),d=bm(e,s),u,c,h,f,p,m,g,S=function(y){return u&&Lo(u,"normal",y),new Ws(!0,y)},v=function(y){return r?(Sm(y),l?d(y[0],y[1],S):d(y[0],y[1])):l?d(y,S):d(y)};if(n)u=i.iterator;else if(o)u=i;else{if(c=km(i),!c)throw Am(ym(i)+" is not iterable");if(Tm(c)){for(h=0,f=Em(i);f>h;h++)if(p=v(i[h]),p&&xo(No,p))return p;return new Ws(!1)}u=$m(i,c)}for(m=n?i.next:u.next;!(g=gm(m,u)).done;){try{p=v(g.value)}catch(y){Lo(u,"throw",y)}if(typeof p=="object"&&p&&xo(No,p))return p}return new Ws(!1)},wm=Sn,Pm=ui,_m=yr,Dm=function(i,e,t){var s=wm(e);s in i?Pm.f(i,s,_m(0,t)):i[s]=t},Im=at,Rm=Dn,Cm=Dm;Im({target:"Object",stat:!0},{fromEntries:function(e){var t={};return Rm(e,function(s,r){Cm(t,s,r)},{AS_ENTRIES:!0}),t}});var xm=bn,Lm=xm.Object.fromEntries,Nm={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=Nm,Bm=Te,Mm=vs,Vm=ps,Oo=Ni,Fm=De,Bo=Fm("toStringTag");for(var oa in Om){var Mo=Bm[oa],la=Mo&&Mo.prototype;la&&Mm(la)!==Bo&&Vm(la,Bo,oa),Oo[oa]=Oo.Array}var Um=Lm,jm=Um,Hm=jm,Gm=Hm,ni=fr(Gm),Ym=cs,Er=typeof process!="undefined"&&Ym(process)=="process",zm=ui,qm=function(i,e,t){return zm.f(i,e,t)},Wm=di,Qm=qm,Km=De,Jm=jt,Vo=Km("species"),Xm=function(i){var e=Wm(i);Jm&&e&&!e[Vo]&&Qm(e,Vo,{configurable:!0,get:function(){return this}})},Zm=mr,ev=TypeError,tv=function(i,e){if(Zm(e,i))return i;throw ev("Incorrect invocation")},iv=Je,sv=pe,Ka=gn,rv=iv(Function.toString);sv(Ka.inspectSource)||(Ka.inspectSource=function(i){return rv(i)});var Pu=Ka.inspectSource,av=Je,nv=Ke,_u=pe,ov=vs,lv=di,uv=Pu,Du=function(){},dv=[],Iu=lv("Reflect","construct"),In=/^\s*(?:class|function)\b/,cv=av(In.exec),hv=!In.exec(Du),Ki=function(e){if(!_u(e))return!1;try{return Iu(Du,dv,e),!0}catch(t){return!1}},Ru=function(e){if(!_u(e))return!1;switch(ov(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return hv||!!cv(In,uv(e))}catch(t){return!0}};Ru.sham=!0;var fv=!Iu||nv(function(){var i;return Ki(Ki.call)||!Ki(Object)||!Ki(function(){i=!0})||i})?Ru:Ki,pv=fv,mv=br,vv=TypeError,bv=function(i){if(pv(i))return i;throw vv(mv(i)+" is not a constructor")},Fo=xt,gv=bv,Sv=hs,yv=De,Tv=yv("species"),Cu=function(i,e){var t=Fo(i).constructor,s;return t===void 0||Sv(s=Fo(t)[Tv])?e:gv(s)},Ev=Je,$v=Ev([].slice),kv=TypeError,Av=function(i,e){if(i<e)throw kv("Not enough arguments");return i},wv=vr,xu=/(?:ipad|iphone|ipod).*applewebkit/i.test(wv),je=Te,Pv=au,_v=Tr,Uo=pe,Dv=mt,Lu=Ke,jo=pu,Iv=$v,Ho=vn,Rv=Av,Cv=xu,xv=Er,Ja=je.setImmediate,Xa=je.clearImmediate,Lv=je.process,ua=je.Dispatch,Nv=je.Function,Go=je.MessageChannel,Ov=je.String,da=0,rs={},Yo="onreadystatechange",ls,ti,ca,ha;Lu(function(){ls=je.location});var Rn=function(i){if(Dv(rs,i)){var e=rs[i];delete rs[i],e()}},fa=function(i){return function(){Rn(i)}},zo=function(i){Rn(i.data)},qo=function(i){je.postMessage(Ov(i),ls.protocol+"//"+ls.host)};(!Ja||!Xa)&&(Ja=function(e){Rv(arguments.length,1);var t=Uo(e)?e:Nv(e),s=Iv(arguments,1);return rs[++da]=function(){Pv(t,void 0,s)},ti(da),da},Xa=function(e){delete rs[e]},xv?ti=function(i){Lv.nextTick(fa(i))}:ua&&ua.now?ti=function(i){ua.now(fa(i))}:Go&&!Cv?(ca=new Go,ha=ca.port2,ca.port1.onmessage=zo,ti=_v(ha.postMessage,ha)):je.addEventListener&&Uo(je.postMessage)&&!je.importScripts&&ls&&ls.protocol!=="file:"&&!Lu(qo)?(ti=qo,je.addEventListener("message",zo,!1)):Yo in Ho("script")?ti=function(i){jo.appendChild(Ho("script"))[Yo]=function(){jo.removeChild(this),Rn(i)}}:ti=function(i){setTimeout(fa(i),0)});var Nu={set:Ja,clear:Xa},Ou=function(){this.head=null,this.tail=null};Ou.prototype={add:function(i){var e={item:i,next:null},t=this.tail;t?t.next=e:this.head=e,this.tail=e},get:function(){var i=this.head;if(i){var e=this.head=i.next;return e===null&&(this.tail=null),i.item}}};var Bu=Ou,Bv=vr,Mv=/ipad|iphone|ipod/i.test(Bv)&&typeof Pebble!="undefined",Vv=vr,Fv=/web0s(?!.*chrome)/i.test(Vv),oi=Te,Wo=Tr,Uv=En.f,pa=Nu.set,jv=Bu,Hv=xu,Gv=Mv,Yv=Fv,ma=Er,Qo=oi.MutationObserver||oi.WebKitMutationObserver,Ko=oi.document,Jo=oi.process,Rs=oi.Promise,Xo=Uv(oi,"queueMicrotask"),Za=Xo&&Xo.value,Si,va,ba,Cs,Zo;if(!Za){var xs=new jv,Ls=function(){var i,e;for(ma&&(i=Jo.domain)&&i.exit();e=xs.get();)try{e()}catch(t){throw xs.head&&Si(),t}i&&i.enter()};!Hv&&!ma&&!Yv&&Qo&&Ko?(va=!0,ba=Ko.createTextNode(""),new Qo(Ls).observe(ba,{characterData:!0}),Si=function(){ba.data=va=!va}):!Gv&&Rs&&Rs.resolve?(Cs=Rs.resolve(void 0),Cs.constructor=Rs,Zo=Wo(Cs.then,Cs),Si=function(){Zo(Ls)}):ma?Si=function(){Jo.nextTick(Ls)}:(pa=Wo(pa,oi),Si=function(){pa(Ls)}),Za=function(i){xs.head||Si(),xs.add(i)}}var zv=Za,qv=function(i,e){try{arguments.length==1?console.error(i):console.error(i,e)}catch(t){}},Cn=function(i){try{return{error:!1,value:i()}}catch(e){return{error:!0,value:e}}},Wv=Te,Oi=Wv.Promise,Mu=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",Qv=Mu,Kv=Er,Jv=!Qv&&!Kv&&typeof window=="object"&&typeof document=="object",Xv=Te,as=Oi,Zv=pe,eb=du,tb=Pu,ib=De,sb=Jv,rb=Mu,ga=Ql,el=as&&as.prototype,ab=ib("species"),en=!1,Vu=Zv(Xv.PromiseRejectionEvent),nb=eb("Promise",function(){var i=tb(as),e=i!==String(as);if(!e&&ga===66||!(el.catch&&el.finally))return!0;if(!ga||ga<51||!/native code/.test(i)){var t=new as(function(n){n(1)}),s=function(n){n(function(){},function(){})},r=t.constructor={};if(r[ab]=s,en=t.then(function(){})instanceof s,!en)return!0}return!e&&(sb||rb)&&!Vu}),bs={CONSTRUCTOR:nb,REJECTION_EVENT:Vu,SUBCLASSING:en},Bi={},tl=ci,ob=TypeError,lb=function(i){var e,t;this.promise=new i(function(s,r){if(e!==void 0||t!==void 0)throw ob("Bad Promise constructor");e=s,t=r}),this.resolve=tl(e),this.reject=tl(t)};Bi.f=function(i){return new lb(i)};var ub=at,Zs=Er,Ft=Te,gs=He,db=wn,cb=_n,hb=Xm,fb=ci,tn=pe,pb=Ct,mb=tv,vb=Cu,Fu=Nu.set,xn=zv,bb=qv,gb=Cn,Sb=Bu,Uu=su,sn=Oi,Ln=bs,ju=Bi,$r="Promise",Hu=Ln.CONSTRUCTOR,yb=Ln.REJECTION_EVENT;Ln.SUBCLASSING;var Sa=Uu.getterFor($r),Tb=Uu.set,Eb=sn&&sn.prototype,Ai=sn,ya=Eb,Gu=Ft.TypeError,rn=Ft.document,Nn=Ft.process,an=ju.f,$b=an,kb=!!(rn&&rn.createEvent&&Ft.dispatchEvent),Yu="unhandledrejection",Ab="rejectionhandled",il=0,zu=1,wb=2,On=1,qu=2,Ns,sl,Pb,Wu=function(i){var e;return pb(i)&&tn(e=i.then)?e:!1},Qu=function(i,e){var t=e.value,s=e.state==zu,r=s?i.ok:i.fail,n=i.resolve,o=i.reject,l=i.domain,d,u,c;try{r?(s||(e.rejection===qu&&Db(e),e.rejection=On),r===!0?d=t:(l&&l.enter(),d=r(t),l&&(l.exit(),c=!0)),d===i.promise?o(Gu("Promise-chain cycle")):(u=Wu(d))?gs(u,d,n,o):n(d)):o(t)}catch(h){l&&!c&&l.exit(),o(h)}},Ku=function(i,e){i.notified||(i.notified=!0,xn(function(){for(var t=i.reactions,s;s=t.get();)Qu(s,i);i.notified=!1,e&&!i.rejection&&_b(i)}))},Ju=function(i,e,t){var s,r;kb?(s=rn.createEvent("Event"),s.promise=e,s.reason=t,s.initEvent(i,!1,!0),Ft.dispatchEvent(s)):s={promise:e,reason:t},!yb&&(r=Ft["on"+i])?r(s):i===Yu&&bb("Unhandled promise rejection",t)},_b=function(i){gs(Fu,Ft,function(){var e=i.facade,t=i.value,s=rl(i),r;if(s&&(r=gb(function(){Zs?Nn.emit("unhandledRejection",t,e):Ju(Yu,e,t)}),i.rejection=Zs||rl(i)?qu:On,r.error))throw r.value})},rl=function(i){return i.rejection!==On&&!i.parent},Db=function(i){gs(Fu,Ft,function(){var e=i.facade;Zs?Nn.emit("rejectionHandled",e):Ju(Ab,e,i.value)})},wi=function(i,e,t){return function(s){i(e,s,t)}},Di=function(i,e,t){i.done||(i.done=!0,t&&(i=t),i.value=e,i.state=wb,Ku(i,!0))},nn=function(i,e,t){if(!i.done){i.done=!0,t&&(i=t);try{if(i.facade===e)throw Gu("Promise can't be resolved itself");var s=Wu(e);s?xn(function(){var r={done:!1};try{gs(s,e,wi(nn,r,i),wi(Di,r,i))}catch(n){Di(r,n,i)}}):(i.value=e,i.state=zu,Ku(i,!1))}catch(r){Di({done:!1},r,i)}}};Hu&&(Ai=function(e){mb(this,ya),fb(e),gs(Ns,this);var t=Sa(this);try{e(wi(nn,t),wi(Di,t))}catch(s){Di(t,s)}},ya=Ai.prototype,Ns=function(e){Tb(this,{type:$r,done:!1,notified:!1,parent:!1,reactions:new Sb,rejection:!1,state:il,value:void 0})},Ns.prototype=db(ya,"then",function(e,t){var s=Sa(this),r=an(vb(this,Ai));return s.parent=!0,r.ok=tn(e)?e:!0,r.fail=tn(t)&&t,r.domain=Zs?Nn.domain:void 0,s.state==il?s.reactions.add(r):xn(function(){Qu(r,s)}),r.promise}),sl=function(){var i=new Ns,e=Sa(i);this.promise=i,this.resolve=wi(nn,e),this.reject=wi(Di,e)},ju.f=an=function(i){return i===Ai||i===Pb?new sl(i):$b(i)});ub({global:!0,constructor:!0,wrap:!0,forced:Hu},{Promise:Ai});cb(Ai,$r,!1,!0);hb($r);var Ib=De,Xu=Ib("iterator"),Zu=!1;try{var Rb=0,al={next:function(){return{done:!!Rb++}},return:function(){Zu=!0}};al[Xu]=function(){return this},Array.from(al,function(){throw 2})}catch(i){}var Cb=function(i,e){if(!e&&!Zu)return!1;var t=!1;try{var s={};s[Xu]=function(){return{next:function(){return{done:t=!0}}}},i(s)}catch(r){}return t},xb=Oi,Lb=Cb,Nb=bs.CONSTRUCTOR,ed=Nb||!Lb(function(i){xb.all(i).then(void 0,function(){})}),Ob=at,Bb=He,Mb=ci,Vb=Bi,Fb=Cn,Ub=Dn,jb=ed;Ob({target:"Promise",stat:!0,forced:jb},{all:function(e){var t=this,s=Vb.f(t),r=s.resolve,n=s.reject,o=Fb(function(){var l=Mb(t.resolve),d=[],u=0,c=1;Ub(e,function(h){var f=u++,p=!1;c++,Bb(l,t,h).then(function(m){p||(p=!0,d[f]=m,--c||r(d))},n)}),--c||r(d)});return o.error&&n(o.value),s.promise}});var Hb=at,Gb=bs.CONSTRUCTOR,nl=Oi;nl&&nl.prototype;Hb({target:"Promise",proto:!0,forced:Gb,real:!0},{catch:function(i){return this.then(void 0,i)}});var Yb=at,zb=He,qb=ci,Wb=Bi,Qb=Cn,Kb=Dn,Jb=ed;Yb({target:"Promise",stat:!0,forced:Jb},{race:function(e){var t=this,s=Wb.f(t),r=s.reject,n=Qb(function(){var o=qb(t.resolve);Kb(e,function(l){zb(o,t,l).then(s.resolve,r)})});return n.error&&r(n.value),s.promise}});var Xb=at,Zb=He,eg=Bi,tg=bs.CONSTRUCTOR;Xb({target:"Promise",stat:!0,forced:tg},{reject:function(e){var t=eg.f(this);return Zb(t.reject,void 0,e),t.promise}});var ig=xt,sg=Ct,rg=Bi,td=function(i,e){if(ig(i),sg(e)&&e.constructor===i)return e;var t=rg.f(i),s=t.resolve;return s(e),t.promise},ag=at,ng=di,og=Bc,lg=Oi,ug=bs.CONSTRUCTOR,dg=td,cg=ng("Promise"),hg=!ug;ag({target:"Promise",stat:!0,forced:og},{resolve:function(e){return dg(hg&&this===cg?lg:this,e)}});var fg=at,on=Oi,pg=Ke,mg=di,vg=pe,bg=Cu,ol=td,gg=on&&on.prototype,Sg=!!on&&pg(function(){gg.finally.call({then:function(){}},function(){})});fg({target:"Promise",proto:!0,real:!0,forced:Sg},{finally:function(i){var e=bg(this,mg("Promise")),t=vg(i);return this.then(t?function(s){return ol(e,i()).then(function(){return s})}:i,t?function(s){return ol(e,i()).then(function(){throw s})}:i)}});var yg=di,Bn=yg,Tg=Bn,Eg=Tg("Promise","finally"),$g=Eg,kg=$g,Ag=kg,wg=Ag,Ss=fr(wg),ae;(function(i){i[i.OFFSET_P=0]="OFFSET_P",i[i.PLAYBACK_SHIFT=1]="PLAYBACK_SHIFT",i[i.DASH_CMAF_OFFSET_P=2]="DASH_CMAF_OFFSET_P"})(ae||(ae={}));var Pe=(i,e=0,t=ae.OFFSET_P)=>{switch(t){case ae.OFFSET_P:return i.replace("_offset_p",e===0?"":"_"+e.toFixed(0));case ae.PLAYBACK_SHIFT:{if(e===0)return i;const s=new URL(i);return s.searchParams.append("playback_shift",e.toFixed(0)),s.toString()}case ae.DASH_CMAF_OFFSET_P:{const s=new URL(i);return!s.searchParams.get("offset_p")&&e===0?i:(s.searchParams.set("offset_p",e.toFixed(0)),s.toString())}default:a.assertNever(t)}return i};const er=(i,e)=>{var t;switch(e){case ae.OFFSET_P:return NaN;case ae.PLAYBACK_SHIFT:{const s=new URL(i);return Number(s.searchParams.get("playback_shift"))}case ae.DASH_CMAF_OFFSET_P:{const s=new URL(i);return Number((t=s.searchParams.get("offset_p"))!==null&&t!==void 0?t:0)}default:a.assertNever(e)}};var w=(i,e,t=!1)=>{const s=i.getTransition();(t||!s||s.to===e)&&i.setState(e)};class ee{constructor(e){this.transitionStarted$=new a.Subject,this.transitionEnded$=new a.Subject,this.transitionUpdated$=new a.Subject,this.forceChanged$=new a.Subject,this.stateChangeStarted$=a.merge(this.transitionStarted$,this.transitionUpdated$),this.stateChangeEnded$=a.merge(this.transitionEnded$,this.forceChanged$),this.state=e,this.prevState=void 0}setState(e){const t=this.transition,s=this.state;this.transition=void 0,this.prevState=s,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:s,to:e,canceledTransition:t})}startTransitionTo(e){const t=this.transition,s=this.state;s===e||a.isNonNullable(t)&&t.to===e||(this.prevState=s,this.state=e,t?(this.transition={from:t.from,to:e,canceledTransition:t},this.transitionUpdated$.next(this.transition)):(this.transition={from:s,to:e},this.transitionStarted$.next(this.transition)))}getTransition(){return this.transition}getState(){return this.state}getPrevState(){return this.prevState}}const Pg=i=>{switch(i){case exports.VideoFormat.MPEG:case exports.VideoFormat.DASH:case exports.VideoFormat.DASH_SEP:case exports.VideoFormat.DASH_ONDEMAND:case exports.VideoFormat.DASH_WEBM:case exports.VideoFormat.DASH_WEBM_AV1:case exports.VideoFormat.HLS:case exports.VideoFormat.HLS_ONDEMAND:return!1;case exports.VideoFormat.DASH_LIVE:case exports.VideoFormat.DASH_LIVE_CMAF:case exports.VideoFormat.HLS_LIVE:case exports.VideoFormat.HLS_LIVE_CMAF:case exports.VideoFormat.DASH_LIVE_WEBM:case exports.VideoFormat.WEB_RTC_LIVE:return!0;default:return a.assertNever(i)}};var G;(function(i){i.STOPPED="stopped",i.READY="ready",i.PLAYING="playing",i.PAUSED="paused"})(G||(G={}));const _g=5,Dg=5,Ig=500,ll=7e3;class Rg{constructor(e){this.subscription=new a.Subscription,this.loadMediaTimeoutSubscription=new a.Subscription,this.videoState=new ee(G.STOPPED),this.syncPlayback=()=>{const s=this.videoState.getState(),r=this.videoState.getTransition(),n=this.params.desiredState.playbackState.getState(),o=this.params.desiredState.playbackState.getTransition(),l=this.params.desiredState.seekState.getState();if(this.log({message:`[syncPlayback] videoState: ${s}; videoTransition: ${JSON.stringify(r)}; desiredPlaybackState: ${n}; desiredPlaybackStateTransition: ${this.params.desiredState.playbackState.getTransition()}; seekState: ${JSON.stringify(l)};`}),n===exports.PlaybackState.STOPPED){s!==G.STOPPED&&(this.videoState.startTransitionTo(G.STOPPED),this.stop());return}if(!r){if((o==null?void 0:o.to)!==exports.PlaybackState.PAUSED&&l.state===Y.Requested&&s!==G.STOPPED){this.seek(l.position/1e3);return}switch(n){case exports.PlaybackState.READY:{switch(s){case G.PLAYING:case G.PAUSED:case G.READY:break;case G.STOPPED:this.videoState.startTransitionTo(G.READY),this.prepare();break;default:a.assertNever(s)}break}case exports.PlaybackState.PLAYING:{switch(s){case G.PLAYING:break;case G.PAUSED:this.videoState.startTransitionTo(G.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case G.READY:this.videoState.startTransitionTo(G.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case G.STOPPED:this.videoState.startTransitionTo(G.READY),this.prepare();break;default:a.assertNever(s)}break}case exports.PlaybackState.PAUSED:{switch(s){case G.PLAYING:this.videoState.startTransitionTo(G.PAUSED),this.params.connection.remotePlayerController.playOrPause();break;case G.PAUSED:break;case G.READY:this.videoState.startTransitionTo(G.PAUSED),this.videoState.setState(G.PAUSED);break;case G.STOPPED:this.videoState.startTransitionTo(G.READY),this.prepare();break;default:a.assertNever(s)}break}default:a.assertNever(n)}}},this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastProvider"),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(Pg(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 a.Subscription;this.subscription.add(e),this.subscription.add(a.merge(this.videoState.stateChangeStarted$.pipe(a.map(r=>`stateChangeStarted$ ${JSON.stringify(r)}`)),this.videoState.stateChangeEnded$.pipe(a.map(r=>`stateChangeEnded$ ${JSON.stringify(r)}`))).subscribe(r=>this.log({message:`[videoState] ${r}`})));const t=(r,n)=>this.subscription.add(r.subscribe(n));if(this.params.output.isLive$.getValue())this.params.output.position$.next(0),this.params.output.duration$.next(0);else{const r=new a.Subject;e.add(r.pipe(a.debounce(Ig)).subscribe(()=>{this.params.output.seekedEvent$.next()}));let n=NaN;e.add(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED).subscribe(o=>{this.logRemoteEvent(o);const l=o.value;this.params.output.position$.next(l),(this.params.desiredState.seekState.getState().state===Y.Applying||Math.abs(l-n)>_g)&&r.next(l),n=l})),e.add(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.DURATION_CHANGED).subscribe(o=>{this.logRemoteEvent(o),this.params.output.duration$.next(o.value)}))}t(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED),r=>{this.logRemoteEvent(r),r.value?this.handleRemoteReady():(this.handleRemoteStop(),e.unsubscribe())}),t(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),r=>{this.logRemoteEvent(r),r.value?this.handleRemotePause():this.handleRemotePlay()}),t(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED),r=>{this.logRemoteEvent(r);const{remotePlayer:n}=this.params.connection,o=r.value,l=this.params.output.isBuffering$.getValue(),d=o===chrome.cast.media.PlayerState.BUFFERING;switch(l!==d&&this.params.output.isBuffering$.next(d),o){case chrome.cast.media.PlayerState.IDLE:!this.params.output.isLive$.getValue()&&n.duration-n.currentTime<Dg&&this.params.output.endedEvent$.next(),this.handleRemoteStop(),w(this.params.desiredState.playbackState,exports.PlaybackState.STOPPED);break;case chrome.cast.media.PlayerState.PAUSED:{this.handleRemotePause();break}case chrome.cast.media.PlayerState.PLAYING:this.handleRemotePlay();break;case chrome.cast.media.PlayerState.BUFFERING:break;default:a.assertNever(o)}}),t(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED),r=>{this.logRemoteEvent(r),this.handleRemoteVolumeChange({volume:r.value})}),t(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),r=>{this.logRemoteEvent(r),this.handleRemoteVolumeChange({muted:r.value})});const s=a.merge(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,a.observableFrom(["init"])).pipe(a.debounce(0));t(s,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(G.PAUSED),w(this.params.desiredState.playbackState,exports.PlaybackState.PAUSED)):(this.videoState.setState(G.PLAYING),w(this.params.desiredState.playbackState,exports.PlaybackState.PLAYING));const s=this.params.output.isLive$.getValue();this.params.output.duration$.next(s?0:t.duration),this.params.output.position$.next(s?0:t.currentTime),this.params.desiredState.seekState.setState({state:Y.None})}}prepare(){const e=this.params.format;this.log({message:`[prepare] format: ${e}`});const t=this.createMediaInfo(e),s=this.createLoadRequest(t);this.loadMedia(s)}handleRemotePause(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===G.PAUSED||e===G.PLAYING)&&(this.videoState.setState(G.PAUSED),w(this.params.desiredState.playbackState,exports.PlaybackState.PAUSED))}handleRemotePlay(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===G.PLAYING||e===G.PAUSED)&&(this.videoState.setState(G.PLAYING),w(this.params.desiredState.playbackState,exports.PlaybackState.PLAYING))}handleRemoteReady(){var e;const t=this.videoState.getTransition();(t==null?void 0:t.to)===G.READY&&this.videoState.setState(G.READY),((e=this.params.desiredState.playbackState.getTransition())===null||e===void 0?void 0:e.to)===exports.PlaybackState.READY&&w(this.params.desiredState.playbackState,exports.PlaybackState.READY)}handleRemoteStop(){this.videoState.getState()!==G.STOPPED&&this.videoState.setState(G.STOPPED)}handleRemoteVolumeChange(e){var t,s;const r=this.params.output.volume$.getValue(),n={volume:(t=e.volume)!==null&&t!==void 0?t:r.volume,muted:(s=e.muted)!==null&&s!==void 0?s:r.muted};(n.volume!==r.volume||n.muted!==n.muted)&&this.params.output.volume$.next(n)}seek(e){this.params.output.willSeekEvent$.next();const{remotePlayer:t,remotePlayerController:s}=this.params.connection;t.currentTime=e,s.seek()}stop(){const{remotePlayerController:e}=this.params.connection;e.stop()}createMediaInfo(e){var t;const s=this.params.source;let r,n,o;switch(e){case exports.VideoFormat.MPEG:{const c=s[e];a.assertNonNullable(c);const h=a.getHighestQuality(Object.keys(c));a.assertNonNullable(h);const f=c[h];a.assertNonNullable(f),r=f,n="video/mp4",o=chrome.cast.media.StreamType.BUFFERED;break}case exports.VideoFormat.HLS:case exports.VideoFormat.HLS_ONDEMAND:{const c=s[e];a.assertNonNullable(c),r=c.url,n="application/x-mpegurl",o=chrome.cast.media.StreamType.BUFFERED;break}case exports.VideoFormat.DASH_SEP:case exports.VideoFormat.DASH_ONDEMAND:case exports.VideoFormat.DASH_WEBM:case exports.VideoFormat.DASH_WEBM_AV1:{const c=s[e];a.assertNonNullable(c),r=c.url,n="application/dash+xml",o=chrome.cast.media.StreamType.BUFFERED;break}case exports.VideoFormat.DASH_LIVE_CMAF:{const c=s[e];a.assertNonNullable(c),r=c.url,n="application/dash+xml",o=chrome.cast.media.StreamType.LIVE;break}case exports.VideoFormat.HLS_LIVE:case exports.VideoFormat.HLS_LIVE_CMAF:{const c=s[e];a.assertNonNullable(c),r=Pe(c.url),n="application/x-mpegurl",o=chrome.cast.media.StreamType.LIVE;break}case exports.VideoFormat.DASH:case exports.VideoFormat.DASH_LIVE:case exports.VideoFormat.WEB_RTC_LIVE:{const c="Unsupported format for Chromecast",h=new Error(c);throw this.params.output.error$.next({id:"ChromecastProvider.createMediaInfo()",category:a.ErrorCategory.VIDEO_PIPELINE,message:c,thrown:h}),h}case exports.VideoFormat.DASH_LIVE_WEBM:throw new Error("DASH_LIVE_WEBM is no longer supported");default:return a.assertNever(e)}const l=new chrome.cast.media.MediaInfo((t=this.params.meta.videoId)!==null&&t!==void 0?t:r,n);l.contentUrl=r,l.streamType=o,l.metadata=new chrome.cast.media.GenericMediaMetadata;const{title:d,subtitle:u}=this.params.meta;return a.isNonNullable(d)&&(l.metadata.title=d),a.isNonNullable(u)&&(l.metadata.subtitle=u),l}createLoadRequest(e){const t=new chrome.cast.media.LoadRequest(e);t.autoplay=!1;const s=this.params.desiredState.seekState.getState();return s.state===Y.Applying||s.state===Y.Requested?t.currentTime=this.params.output.isLive$.getValue()?0:s.position/1e3:t.currentTime=0,t}loadMedia(e){const t=this.params.connection.session.loadMedia(e),s=new Promise((r,n)=>{this.loadMediaTimeoutSubscription.add(a.timeout(ll).subscribe(()=>n(`timeout(${ll})`)))});Ss(Promise.race([t,s]).then(()=>{this.log({message:`[loadMedia] completed, format: ${this.params.format}`}),this.params.desiredState.seekState.getState().state===Y.Applying&&this.params.output.seekedEvent$.next(),this.handleRemoteReady()},r=>{const n=`[prepare] loadMedia failed, format: ${this.params.format}, reason: ${r}`;this.log({message:n}),this.params.output.error$.next({id:"ChromecastProvider.loadMedia",category:a.ErrorCategory.VIDEO_PIPELINE,message:n,thrown:r})}),()=>{this.loadMediaTimeoutSubscription.unsubscribe()})}logRemoteEvent(e){this.log({message:`[remoteEvent] ${JSON.stringify(e)}`})}}var Cg=i=>{let e,t=!1,s=!1;i.on("playbackTimeUpdated",({timeToEnd:r})=>{s=r<=3,t&&s&&(e==null||e())}),i.extend("MediaSourceController",function(){const{parent:r}=this,n=r.signalEndOfStream;return{signalEndOfStream:o=>{t=!0,e=()=>n(o),t&&s&&(e==null||e())}}},!0)},xg=i=>{const e=new a.ValueSubject(1/0),t=new a.Subject,s=new a.ValueSubject(void 0),r=new a.ValueSubject(void 0);let n=NaN,o=!1;const l=()=>{n=Date.now(),o=!1},d=c=>{var h,f,p,m,g;const S=ni(c.getAllResponseHeaders().trim().split(/[\n\r]+/).map(b=>b.split(": ")));if("x-playback-duration"in S||"x-playback-duration-millis"in S){const b=parseInt((h=c.getResponseHeader("X-Playback-Duration"))!==null&&h!==void 0?h:"",10),T=parseInt((f=c.getResponseHeader("X-Playback-Duration-Millis"))!==null&&f!==void 0?f:"",10),E=(p=T!=null?T:b*1e3)!==null&&p!==void 0?p:NaN;a.isNonNullable(E)&&!isNaN(E)&&e.next(E)}const v=(m=S["x-delivery-type"])!==null&&m!==void 0?m:exports.HttpConnectionType.HTTP1,y=(g={1:!0,0:!1}[S["x-reused"]])!==null&&g!==void 0?g:void 0;s.next(v),r.next(y)},u=c=>{c.readyState>=2&&!o&&(o=!0,t.next(Date.now()-n))};return i.extend("XHRLoader",function(){const{parent:c}=this,h=c.load.bind(c);return{load:function(f){if(f.request.type==="MPD"){const p=f.onload,m=f.progress;f.onload=function(...g){return d(this),p(...g)},f.progress=function(...g){return u(this),m(...g)},l()}return h(f)}}},!0),{playbackDuration$:e,ping$:t,connectionReused$:r,connectionType$:s}},Ut=i=>{const e=new URL(i);return e.searchParams.set("quic","1"),e.toString()},Lg=i=>i.extend("RequestModifier",()=>({modifyRequestURL:Ut}),!0),Ng=i=>{i.extend("HTTPLoader",function(){const{parent:e}=this,t=e.load;return{load:s=>{if(s.request&&s.request.range){const[r,n]=s.request.range.split("-").map(l=>parseInt(l,10)),o=new URL(s.request.url,location.href);o.searchParams.append("bytes",`${r}-${n}`),s.request.url=o.toString(),s.request.range=void 0}t(s)}}},!0)};const rt=(i,e,t,{equal:s=(o,l)=>o===l,changed$:r,onError:n}={})=>{const o=i.getState(),l=e(),d=a.isNullable(r),u=new a.Subscription;return r&&u.add(r.subscribe(c=>{const h=i.getState();s(c,h)&&i.setState(c)},n)),s(l,o)||(t(o),d&&i.setState(o)),u.add(i.stateChangeStarted$.subscribe(c=>{t(c.to),d&&i.setState(c.to)},n)),u},Ht=(i,e,t)=>rt(e,()=>i.loop,s=>{a.isNonNullable(s)&&(i.loop=s)},{onError:t}),vt=(i,e,t,s)=>rt(e,()=>({muted:i.muted,volume:i.volume}),r=>{a.isNonNullable(r)&&(i.muted=r.muted,i.volume=r.volume)},{equal:(r,n)=>r===n||(r==null?void 0:r.muted)===(n==null?void 0:n.muted)&&(r==null?void 0:r.volume)===(n==null?void 0:n.volume),changed$:t,onError:s}),Lt=(i,e,t,s)=>rt(e,()=>i.playbackRate,r=>{a.isNonNullable(r)&&(i.playbackRate=r)},{changed$:t,onError:s}),Og=i=>["__",i.language,i.label].join("|"),Bg=(i,e)=>{if(i.id===e)return!0;const[t,s,r]=e.split("|");return i.language===s&&i.label===r};class nt{constructor(){this.available$=new a.Subject,this.current$=new a.ValueSubject(void 0),this.error$=new a.Subject,this.subscription=new a.Subscription,this.externalTracks=new Map,this.internalTracks=new Map}connect(e,t,s){this.video=e,this.cueSettings=t.textTrackCuesSettings,this.subscribe();const r=n=>{this.error$.next({id:"TextTracksManager",category:a.ErrorCategory.WTF,message:"Generic HtmlVideoTextTrackManager error",thrown:n})};this.subscription.add(this.available$.subscribe(s.availableTextTracks$)),this.subscription.add(this.current$.subscribe(s.currentTextTrack$)),this.subscription.add(this.error$.subscribe(s.error$)),this.subscription.add(rt(t.internalTextTracks,()=>Object.values(this.internalTracks),n=>{a.isNonNullable(n)&&this.setInternal(n)},{equal:(n,o)=>a.isNonNullable(n)&&a.isNonNullable(o)&&n.length===o.length&&n.every(({id:l},d)=>l===o[d].id),changed$:this.available$.pipe(a.map(n=>n.filter(({type:o})=>o==="internal"))),onError:r})),this.subscription.add(rt(t.externalTextTracks,()=>Object.values(this.externalTracks),n=>{a.isNonNullable(n)&&this.setExternal(n)},{equal:(n,o)=>a.isNonNullable(n)&&a.isNonNullable(o)&&n.length===o.length&&n.every(({id:l},d)=>l===o[d].id),changed$:this.available$.pipe(a.map(n=>n.filter(({type:o})=>o==="external"))),onError:r})),this.subscription.add(rt(t.currentTextTrack,()=>{if(this.video)return;const n=this.htmlTextTracksAsArray().find(({mode:o})=>o==="showing");return n&&this.htmlTextTrackToITextTrack(n).id},n=>this.select(n),{changed$:this.current$,onError:r})),this.subscription.add(rt(t.textTrackCuesSettings,()=>({}),()=>{if(this.video)for(const n of this.htmlTextTracksAsArray())this.applyCueSettings(n.cues),this.applyCueSettings(n.activeCues)}))}subscribe(){a.assertNonNullable(this.video);const{textTracks:e}=this.video;this.subscription.add(a.fromEvent(e,"addtrack").subscribe(()=>{const s=this.current$.getValue();s&&this.select(s)})),this.subscription.add(a.merge(a.fromEvent(e,"addtrack"),a.fromEvent(e,"removetrack"),a.observableFrom(["init"])).pipe(a.map(()=>this.htmlTextTracksAsArray().map(s=>this.htmlTextTrackToITextTrack(s))),a.filterChanged((s,r)=>s.length===r.length&&s.every(({id:n},o)=>n===r[o].id))).subscribe(this.available$)),this.subscription.add(a.merge(a.fromEvent(e,"change"),a.observableFrom(["init"])).pipe(a.map(()=>this.htmlTextTracksAsArray().find(({mode:s})=>s==="showing")),a.map(s=>s&&this.htmlTextTrackToITextTrack(s).id),a.filterChanged()).subscribe(this.current$));const t=s=>{var r,n;return this.applyCueSettings((n=(r=s.target)===null||r===void 0?void 0:r.activeCues)!==null&&n!==void 0?n:null)};this.subscription.add(a.fromEvent(e,"addtrack").subscribe(s=>{var r,n;(r=s.track)===null||r===void 0||r.addEventListener("cuechange",t);const o=l=>{var d,u,c,h,f;const p=(u=(d=l.target)===null||d===void 0?void 0:d.cues)!==null&&u!==void 0?u:null;p&&p.length&&(this.applyCueSettings((h=(c=l.target)===null||c===void 0?void 0:c.cues)!==null&&h!==void 0?h:null),(f=l.target)===null||f===void 0||f.removeEventListener("cuechange",o))};(n=s.track)===null||n===void 0||n.addEventListener("cuechange",o)})),this.subscription.add(a.fromEvent(e,"removetrack").subscribe(s=>{var r;(r=s.track)===null||r===void 0||r.removeEventListener("cuechange",t)}))}applyCueSettings(e){if(!e||!e.length)return;const t=this.cueSettings.getState();for(const s of Array.from(e)){const r=s;a.isNonNullable(t.align)&&(r.align=t.align),a.isNonNullable(t.position)&&(r.position=t.position),a.isNonNullable(t.size)&&(r.size=t.size),a.isNonNullable(t.line)&&(r.line=t.line)}}htmlTextTracksAsArray(e=!1){a.assertNonNullable(this.video);const t=[...this.video.textTracks];return e?t:t.filter(nt.isHealthyTrack)}htmlTextTrackToITextTrack(e){var t,s;const{language:r,label:n}=e,o=e.id?e.id:Og(e),l=this.externalTracks.has(o),d=o.includes("auto");return l?{id:o,type:"external",isAuto:d,language:r,label:n,url:(t=this.externalTracks.get(o))===null||t===void 0?void 0:t.url}:{id:o,type:"internal",isAuto:d,language:r,label:n,url:(s=this.internalTracks.get(o))===null||s===void 0?void 0:s.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(s=>s.id===t)).forEach(([,t])=>this.detach(t))}setInternal(e){const t=[...this.externalTracks];e.filter(({id:s,language:r,isAuto:n})=>!this.internalTracks.has(s)&&!t.some(([,o])=>o.language===r&&o.isAuto===n)).forEach(s=>this.attach(s)),Array.from(this.internalTracks).filter(([s])=>!e.find(r=>r.id===s)).forEach(([,s])=>this.detach(s))}select(e){a.assertNonNullable(this.video);for(const t of this.htmlTextTracksAsArray(!0))t.mode="showing";for(const t of this.htmlTextTracksAsArray(!0))(a.isNullable(e)||!Bg(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){a.assertNonNullable(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){a.assertNonNullable(this.video);const t=Array.prototype.find.call(this.video.getElementsByTagName("track"),s=>s.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 Mn=i=>{i.removeAttribute("src"),i.load()},Mg=i=>{try{i.pause(),i.playbackRate=0,Mn(i),i.remove()}catch(e){console.error(e)}};class Vg{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 ln=window.WeakMap?new WeakMap:new Vg,bt=i=>{let e=i.querySelector("video");const t=!!e;return e?Mn(e):(e=document.createElement("video"),i.appendChild(e)),ln.set(e,t),e.setAttribute("crossorigin","anonymous"),e.setAttribute("playsinline","playsinline"),e.controls=!1,e.setAttribute("poster","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),e},gt=i=>{const e=ln.get(i);ln.delete(i),e?Mn(i):Mg(i)};class ys{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 id=i=>{var e;let t=i;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},ul=i=>{const e=id(i);return!!(e&&e.fullscreenElement&&e.fullscreenElement===i)},Fg=i=>{const e=id(i);return!!(e&&e.pictureInPictureElement&&e.pictureInPictureElement===i)},un=3;class Ug{constructor(e){this._buffer=[],this._source=e}fill(){this._buffer=[];const e=this._source.currentTime;for(let t=0,s=this._source.buffered.length;t<s;t++){let r=this._source.buffered.start(t);const n=this._source.buffered.end(t);r>e&&r-e<un&&(r=e),this._buffer.push({from:r,to:n,i:t})}return this._buffer.sort(function(t,s){return t.from-s.from}),this._buffer}getByTime(e){return this._buffer.find(t=>e>=t.from&&e<t.to)}getNextWithGap(e,t){const s=this.getNext(e);if(s&&s.from-e.to<(t||un))return s}getNext(e){let t=this._buffer.indexOf(e);if(~t&&this._buffer.length-1>t)return this._buffer[++t]}smartRemove(e,t,s){this._buffer.forEach(({from:r,to:n})=>{const o=r>=e&&r<t,l=n>=e&&n<t;o&&l||(o?s(t,n):l?s(r,e):r<e&&n>t?(s(t,n),s(r,e)):s(r,n))})}destroy(){this._buffer=[]}}var sd=(i,e,t=un)=>{let s=0,r=0;for(let n=0;n<i.length;n++){const o=i.start(n),l=i.end(n);if(o<=e&&e<=l){if(s=o,r=l,!t)return{from:s,to:r};for(let d=n-1;d>=0;d--)i.end(d)+t>=s&&(s=i.start(d));for(let d=n+1;d<i.length;d++)i.start(d)-t<=r&&(r=i.end(d))}}return{from:s,to:r}};const St=i=>{const e=b=>a.fromEvent(i,b).pipe(a.mapTo(void 0)),t=["waiting","pause","canplay","play","canplaythrough","playing","seeking","seeked","ended"],s=a.merge(...t.map(b=>a.fromEvent(i,b))).pipe(a.map(b=>b.type==="ended"?i.readyState<2:i.readyState<3),a.filterChanged()),r=a.merge(a.fromEvent(i,"progress"),a.fromEvent(i,"timeupdate")).pipe(a.map(()=>sd(i.buffered,i.currentTime))),o=a.getCurrentBrowser().browser===a.CurrentClientBrowser.Safari?a.combine({play:e("play").pipe(a.once()),playing:e("playing")}).pipe(a.mapTo(void 0)):e("playing"),l=a.fromEvent(i,"volumechange").pipe(a.map(()=>({muted:i.muted,volume:i.volume}))),d=a.fromEvent(i,"ratechange").pipe(a.map(()=>i.playbackRate)),u=a.fromEvent(i,"error").pipe(a.filter(()=>!!(i.error||i.played.length)),a.map(()=>{var b;const T=i.error;return{id:T?`MediaError#${T.code}`:"HtmlVideoError",category:a.ErrorCategory.VIDEO_PIPELINE,message:T?T.message:"Error event from HTML video element",thrown:(b=i.error)!==null&&b!==void 0?b:void 0}})),c=a.fromEvent(i,"timeupdate").pipe(a.map(()=>i.currentTime)),h=new a.Subject,f=.3;let p;c.subscribe(b=>{i.loop&&a.isNonNullable(p)&&a.isNonNullable(b)&&p>=i.duration-f&&b<=f&&h.next(p),p=b});const m=a.fromEvent(i,"enterpictureinpicture"),g=a.fromEvent(i,"leavepictureinpicture"),S=new a.ValueSubject(Fg(i));m.subscribe(()=>S.next(!0)),g.subscribe(()=>S.next(!1));const v=new a.ValueSubject(ul(i));return a.fromEvent(i,"fullscreenchange").pipe(a.map(()=>ul(i))).subscribe(v),{playing$:o,pause$:e("pause").pipe(a.filter(()=>!i.error)),canplay$:e("canplay"),ended$:e("ended"),looped$:h,error$:u,seeked$:e("seeked"),seeking$:e("seeking"),progress$:e("progress"),loadStart$:e("loadstart"),loadedMetadata$:e("loadedmetadata"),loadedData$:e("loadeddata"),timeUpdate$:c,durationChange$:a.fromEvent(i,"durationchange").pipe(a.map(()=>i.duration)),isBuffering$:s,currentBuffer$:r,volumeState$:l,playbackRateState$:d,inPiP$:S,inFullscreen$:v}},kr=i=>{if(i.includes("/")){const e=i.split("/");return parseInt(e[0])/parseInt(e[1])}else return parseFloat(i)};var jg=at,Hg=Sr,Gg=An,Yg=kn;jg({target:"Array",proto:!0},{at:function(e){var t=Hg(this),s=Gg(t),r=Yg(e),n=r>=0?r:s+r;return n<0||n>=s?void 0:t[n]}});var zg=Bn,qg=zg("Array","at"),Wg=qg,Qg=Wg,Kg=Qg,Jg=Kg,ge=fr(Jg);let Vn=!1,_t={};const Xg=i=>{Vn=i},Zg=()=>{_t={}},eS=i=>{i(_t)},Os=(i,e)=>{var t;Vn&&(_t.meta=(t=_t.meta)!==null&&t!==void 0?t:{},_t.meta[i]=e)};class ct{constructor(e){this.name=e}next(e){var t,s;if(!Vn)return;_t.series=(t=_t.series)!==null&&t!==void 0?t:{};const r=(s=_t.series[this.name])!==null&&s!==void 0?s:[];r.push([Date.now(),e]),_t.series[this.name]=r}}var si;(function(i){i.FitsContainer="FitsContainer",i.FitsThroughput="FitsThroughput",i.Buffer="Buffer",i.DroppedFramesLimit="DroppedFramesLimit",i.FitsQualityLimits="FitsQualityLimits"})(si||(si={}));const tS=new ct("best_bitrate"),iS=(i,e,t)=>(e-t)*Math.pow(2,-10*i)+t;class rd{constructor(){this.history={}}recordSelection(e){this.history[e.id]=a.now()}recordSwitch(e){this.last=e}clear(){this.last=void 0,this.history={}}}const sS='Assertion "ABR Tracks is empty array" failed',hi=(i,{container:e,throughput:t,tuning:s,limits:r,reserve:n=0,forwardBufferHealth:o,playbackRate:l,current:d,history:u,droppedVideoMaxQualityLimit:c,abrLogger:h})=>{var f,p,m,g,S;a.assertNotEmptyArray(i,sS);const v=s.usePixelRatio&&(f=window.devicePixelRatio)!==null&&f!==void 0?f:1,y=s.limitByContainer&&e&&e.width>0&&e.height>0&&{width:e.width*v*s.containerSizeFactor,height:e.height*v*s.containerSizeFactor},b=y&&a.videoSizeToQuality(y),T=s.considerPlaybackRate&&a.isNonNullable(l)?l:1,E=i.filter(R=>!a.isInvariantQuality(R.quality)).sort((R,_)=>a.isHigher(R.quality,_.quality)?-1:1),P=(p=ge(E,-1))===null||p===void 0?void 0:p.quality,N=(m=ge(E,0))===null||m===void 0?void 0:m.quality,V=a.isNullable(r)||a.isNonNullable(r.min)&&a.isNonNullable(r.max)&&a.isLower(r.max,r.min)||a.isNonNullable(r.min)&&N&&a.isHigher(r.min,N)||a.isNonNullable(r.max)&&P&&a.isLower(r.max,P),L=T*iS(o!=null?o:.5,s.bitrateFactorAtEmptyBuffer,s.bitrateFactorAtFullBuffer),B={},D=E.filter(R=>(b?a.isLower(R.quality,b):!0)?(a.isNonNullable(t)&&isFinite(t)&&a.isNonNullable(R.bitrate)?t-n>=R.bitrate*L:!0)?s.lazyQualitySwitch&&a.isNonNullable(s.minBufferToSwitchUp)&&d&&!a.isInvariantQuality(d.quality)&&(o!=null?o:0)<s.minBufferToSwitchUp&&a.isHigher(R.quality,d.quality)?(B[R.quality]=si.Buffer,!1):!!c&&a.isHigherOrEqual(R.quality,c)?(B[R.quality]=si.DroppedFramesLimit,!1):V||(a.isNullable(r.max)||a.isLowerOrEqual(R.quality,r.max))&&(a.isNullable(r.min)||a.isHigherOrEqual(R.quality,r.min))?!0:(B[R.quality]=si.FitsQualityLimits,!1):(B[R.quality]=si.FitsThroughput,!1):(B[R.quality]=si.FitsContainer,!1))[0];D&&D.bitrate&&tS.next(D.bitrate);const I=(g=D!=null?D:E[Math.ceil((E.length-1)/2)])!==null&&g!==void 0?g:i[0];I.quality!==((S=u==null?void 0:u.last)===null||S===void 0?void 0:S.quality)&&h({message:`
7
7
  [available tracks]
8
8
  ${i.map(R=>`{ id: ${R.id}, quality: ${R.quality}, bitrate: ${R.bitrate} }`).join(`
9
9
  `)}