@vkontakte/videoplayer-core 2.0.98-dev.5902fe89.0 → 2.0.98-dev.b4734e48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es2015.cjs.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @vkontakte/videoplayer-core v2.0.98-dev.5902fe89.0
3
- * Thu, 21 Dec 2023 11:07:44 GMT
2
+ * @vkontakte/videoplayer-core v2.0.98-dev.b4734e48.0
3
+ * Thu, 28 Dec 2023 05:26:59 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/2-0-98/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"),Md=require("lodash");const Vl="2.0.98-dev.5902fe89.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 F(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 Vd=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 Fd{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||Vd("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(Ud),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 Ud=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}},jd=Ke,pr=!jd(function(){var i=function(){}.bind();return typeof i!="function"||i.hasOwnProperty("prototype")}),Fl=pr,Ul=Function.prototype,Ua=Ul.call,Hd=Fl&&Ul.bind.bind(Ua,Ua),Je=Fl?Hd:function(i){return function(){return Ua.apply(i,arguments)}},jl=Je,Gd=jl({}.toString),Yd=jl("".slice),cs=function(i){return Yd(Gd(i),8,-1)},zd=Je,qd=Ke,Wd=cs,jr=Object,Qd=zd("".split),Kd=qd(function(){return!jr("z").propertyIsEnumerable(0)})?function(i){return Wd(i)=="String"?Qd(i,""):jr(i)}:jr,hs=function(i){return i==null},Jd=hs,Xd=TypeError,mn=function(i){if(Jd(i))throw Xd("Can't call method on "+i);return i},Zd=Kd,ec=mn,fs=function(i){return Zd(ec(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,tc=typeof ja=="undefined"&&ja!==void 0,Hl={all:ja,IS_HTMLDDA:tc},Gl=Hl,ic=Gl.all,pe=Gl.IS_HTMLDDA?function(i){return typeof i=="function"||i===ic}:function(i){return typeof i=="function"},sc=Te,rc=pe,qn=sc.WeakMap,ac=rc(qn)&&/native code/.test(String(qn)),Wn=pe,Yl=Hl,nc=Yl.all,Ct=Yl.IS_HTMLDDA?function(i){return typeof i=="object"?i!==null:Wn(i)||i===nc}:function(i){return typeof i=="object"?i!==null:Wn(i)},oc=Ke,jt=!oc(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),ui={},lc=Te,Qn=Ct,Ha=lc.document,uc=Qn(Ha)&&Qn(Ha.createElement),vn=function(i){return uc?Ha.createElement(i):{}},dc=jt,cc=Ke,hc=vn,zl=!dc&&!cc(function(){return Object.defineProperty(hc("div"),"a",{get:function(){return 7}}).a!=7}),fc=jt,pc=Ke,ql=fc&&pc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),mc=Ct,vc=String,bc=TypeError,xt=function(i){if(mc(i))return i;throw bc(vc(i)+" is not an object")},gc=pr,ks=Function.prototype.call,He=gc?ks.bind(ks):function(){return ks.apply(ks,arguments)},bn={},Hr=bn,Gr=Te,Sc=pe,Kn=function(i){return Sc(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]},yc=Je,mr=yc({}.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,Tc=Ke,Ec=Te,$c=Ec.String,Kl=!!Object.getOwnPropertySymbols&&!Tc(function(){var i=Symbol();return!$c(i)||!(Object(i)instanceof Symbol)||!Symbol.sham&&to&&to<41}),kc=Kl,Jl=kc&&!Symbol.sham&&typeof Symbol.iterator=="symbol",Ac=di,wc=pe,Pc=mr,_c=Jl,Dc=Object,Xl=_c?function(i){return typeof i=="symbol"}:function(i){var e=Ac("Symbol");return wc(e)&&Pc(e.prototype,Dc(i))},Ic=String,br=function(i){try{return Ic(i)}catch(e){return"Object"}},Rc=pe,Cc=br,xc=TypeError,ci=function(i){if(Rc(i))return i;throw xc(Cc(i)+" is not a function")},Lc=ci,Nc=hs,gr=function(i,e){var t=i[e];return Nc(t)?void 0:Lc(t)},zr=He,qr=pe,Wr=Ct,Oc=TypeError,Bc=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 Oc("Can't convert object to primitive value")},Zl={exports:{}},Mc=!0,io=Te,Vc=Object.defineProperty,Fc=function(i,e){try{Vc(io,i,{value:e,configurable:!0,writable:!0})}catch(t){io[i]=e}return e},Uc=Te,jc=Fc,so="__core-js_shared__",Hc=Uc[so]||jc(so,{}),gn=Hc,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,Gc=mn,Yc=Object,Sr=function(i){return Yc(Gc(i))},zc=Je,qc=Sr,Wc=zc({}.hasOwnProperty),mt=Object.hasOwn||function(e,t){return Wc(qc(e),t)},Qc=Je,Kc=0,Jc=Math.random(),Xc=Qc(1 .toString),tu=function(i){return"Symbol("+(i===void 0?"":i)+")_"+Xc(++Kc+Jc,36)},Zc=Te,eh=eu,ao=mt,th=tu,ih=Kl,sh=Jl,ki=Zc.Symbol,Qr=eh("wks"),rh=sh?ki.for||ki:ki&&ki.withoutSetter||th,De=function(i){return ao(Qr,i)||(Qr[i]=ih&&ao(ki,i)?ki[i]:rh("Symbol."+i)),Qr[i]},ah=He,no=Ct,oo=Xl,nh=gr,oh=Bc,lh=De,uh=TypeError,dh=lh("toPrimitive"),ch=function(i,e){if(!no(i)||oo(i))return i;var t=nh(i,dh),s;if(t){if(e===void 0&&(e="default"),s=ah(t,i,e),!no(s)||oo(s))return s;throw uh("Can't convert object to primitive value")}return e===void 0&&(e="number"),oh(i,e)},hh=ch,fh=Xl,Sn=function(i){var e=hh(i,"string");return fh(e)?e:e+""},ph=jt,mh=zl,vh=ql,As=xt,lo=Sn,bh=TypeError,Kr=Object.defineProperty,gh=Object.getOwnPropertyDescriptor,Jr="enumerable",Xr="configurable",Zr="writable";ui.f=ph?vh?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=gh(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),mh)try{return Kr(e,t,s)}catch(r){}if("get"in s||"set"in s)throw bh("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}},Sh=jt,yh=ui,Th=yr,ps=Sh?function(i,e,t){return yh.f(i,e,Th(1,t))}:function(i,e,t){return i[e]=t,i},Eh=eu,$h=tu,uo=Eh("keys"),yn=function(i){return uo[i]||(uo[i]=$h(i))},Tn={},kh=ac,iu=Te,Ah=Ct,wh=ps,ea=mt,ta=gn,Ph=yn,_h=Tn,co="Object already initialized",Ga=iu.TypeError,Dh=iu.WeakMap,Js,os,Xs,Ih=function(i){return Xs(i)?os(i):Js(i,{})},Rh=function(i){return function(e){var t;if(!Ah(e)||(t=os(e)).type!==i)throw Ga("Incompatible receiver, "+i+" required");return t}};if(kh||ta.state){var lt=ta.state||(ta.state=new Dh);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=Ph("state");_h[vi]=!0,Js=function(i,e){if(ea(i,vi))throw Ga(co);return e.facade=i,wh(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:Ih,getterFor:Rh},Ch=pr,ru=Function.prototype,ho=ru.apply,fo=ru.call,au=typeof Reflect=="object"&&Reflect.apply||(Ch?fo.bind(ho):function(){return fo.apply(ho,arguments)}),xh=cs,Lh=Je,nu=function(i){if(xh(i)==="Function")return Lh(i)},En={},ou={},lu={}.propertyIsEnumerable,uu=Object.getOwnPropertyDescriptor,Nh=uu&&!lu.call({1:2},1);ou.f=Nh?function(e){var t=uu(this,e);return!!t&&t.enumerable}:lu;var Oh=jt,Bh=He,Mh=ou,Vh=yr,Fh=fs,Uh=Sn,jh=mt,Hh=zl,po=Object.getOwnPropertyDescriptor;En.f=Oh?po:function(e,t){if(e=Fh(e),t=Uh(t),Hh)try{return po(e,t)}catch(s){}if(jh(e,t))return Vh(!Bh(Mh.f,e,t),e[t])};var Gh=Ke,Yh=pe,zh=/#|\.prototype\./,ms=function(i,e){var t=Wh[qh(i)];return t==Kh?!0:t==Qh?!1:Yh(e)?Gh(e):!!e},qh=ms.normalize=function(i){return String(i).replace(zh,".").toLowerCase()},Wh=ms.data={},Qh=ms.NATIVE="N",Kh=ms.POLYFILL="P",du=ms,mo=nu,Jh=ci,Xh=pr,Zh=mo(mo.bind),Tr=function(i,e){return Jh(i),e===void 0?i:Xh?Zh(i,e):function(){return i.apply(e,arguments)}},ws=Te,ef=au,tf=nu,sf=pe,rf=En.f,af=du,bi=bn,nf=Tr,gi=ps,vo=mt,of=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 ef(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=af(s?f:t+(r?".":"#")+f,i.forced),c=!u&&o&&vo(o,f),m=l[f],c&&(i.dontCallGetSet?(v=rf(o,f),g=v&&v.value):g=o[f]),p=c&&g?g:e[f],!(c&&typeof m==typeof p)&&(i.bind&&c?S=nf(p,ws):i.wrap&&c?S=of(p):n&&sf(p)?S=tf(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,lf=mt,cu=Function.prototype,uf=Ya&&Object.getOwnPropertyDescriptor,$n=lf(cu,"name"),df=$n&&function(){}.name==="something",cf=$n&&(!Ya||Ya&&uf(cu,"name").configurable),hf={EXISTS:$n,PROPER:df,CONFIGURABLE:cf},hu={},ff=Math.ceil,pf=Math.floor,mf=Math.trunc||function(e){var t=+e;return(t>0?pf:ff)(t)},vf=mf,kn=function(i){var e=+i;return e!==e||e===0?0:vf(e)},bf=kn,gf=Math.max,Sf=Math.min,yf=function(i,e){var t=bf(i);return t<0?gf(t+e,0):Sf(t,e)},Tf=kn,Ef=Math.min,$f=function(i){return i>0?Ef(Tf(i),9007199254740991):0},kf=$f,An=function(i){return kf(i.length)},Af=fs,wf=yf,Pf=An,bo=function(i){return function(e,t,s){var r=Af(e),n=Pf(r),o=wf(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}},_f={includes:bo(!0),indexOf:bo(!1)},Df=Je,ia=mt,If=fs,Rf=_f.indexOf,Cf=Tn,go=Df([].push),xf=function(i,e){var t=If(i),s=0,r=[],n;for(n in t)!ia(Cf,n)&&ia(t,n)&&go(r,n);for(;e.length>s;)ia(t,n=e[s++])&&(~Rf(r,n)||go(r,n));return r},fu=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Lf=xf,Nf=fu,Of=Object.keys||function(e){return Lf(e,Nf)},Bf=jt,Mf=ql,Vf=ui,Ff=xt,Uf=fs,jf=Of;hu.f=Bf&&!Mf?Object.defineProperties:function(e,t){Ff(e);for(var s=Uf(t),r=jf(t),n=r.length,o=0,l;n>o;)Vf.f(e,l=r[o++],s[l]);return e};var Hf=di,pu=Hf("document","documentElement"),Gf=xt,Yf=hu,So=fu,zf=Tn,qf=pu,Wf=vn,Qf=yn,yo=">",To="<",za="prototype",qa="script",mu=Qf("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},Kf=function(){var i=Wf("iframe"),e="java"+qa+":",t;return i.style.display="none",qf.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):Kf():Eo(Ps);for(var i=So.length;i--;)delete zs[za][So[i]];return zs()};zf[mu]=!0;var bu=Object.create||function(e,t){var s;return e!==null?(sa[za]=Gf(e),s=new sa,sa[za]=null,s[mu]=e):s=zs(),t===void 0?s:Yf.f(s,t)},Jf=Ke,Xf=!Jf(function(){function i(){}return i.prototype.constructor=null,Object.getPrototypeOf(new i)!==i.prototype}),Zf=mt,ep=pe,tp=Sr,ip=yn,sp=Xf,$o=ip("IE_PROTO"),Wa=Object,rp=Wa.prototype,gu=sp?Wa.getPrototypeOf:function(i){var e=tp(i);if(Zf(e,$o))return e[$o];var t=e.constructor;return ep(t)&&e instanceof t?t.prototype:e instanceof Wa?rp:null},ap=ps,wn=function(i,e,t,s){return s&&s.enumerable?i[e]=t:ap(i,e,t),i},np=Ke,op=pe,lp=Ct,up=bu,ko=gu,dp=wn,cp=De,Qa=cp("iterator"),Su=!1,Dt,ra,aa;[].keys&&(aa=[].keys(),"next"in aa?(ra=ko(ko(aa)),ra!==Object.prototype&&(Dt=ra)):Su=!0);var hp=!lp(Dt)||np(function(){var i={};return Dt[Qa].call(i)!==i});hp?Dt={}:Dt=up(Dt);op(Dt[Qa])||dp(Dt,Qa,function(){return this});var yu={IteratorPrototype:Dt,BUGGY_SAFARI_ITERATORS:Su},fp=De,pp=fp("toStringTag"),Tu={};Tu[pp]="z";var Pn=String(Tu)==="[object z]",mp=Pn,vp=pe,qs=cs,bp=De,gp=bp("toStringTag"),Sp=Object,yp=qs(function(){return arguments}())=="Arguments",Tp=function(i,e){try{return i[e]}catch(t){}},vs=mp?qs:function(i){var e,t,s;return i===void 0?"Undefined":i===null?"Null":typeof(t=Tp(e=Sp(i),gp))=="string"?t:yp?qs(e):(s=qs(e))=="Object"&&vp(e.callee)?"Arguments":s},Ep=Pn,$p=vs,kp=Ep?{}.toString:function(){return"[object "+$p(this)+"]"},Ap=Pn,wp=ui.f,Pp=ps,_p=mt,Dp=kp,Ip=De,Ao=Ip("toStringTag"),_n=function(i,e,t,s){if(i){var r=t?i:i.prototype;_p(r,Ao)||wp(r,Ao,{configurable:!0,value:e}),s&&!Ap&&Pp(r,"toString",Dp)}},Rp=yu.IteratorPrototype,Cp=bu,xp=yr,Lp=_n,Np=Ni,Op=function(){return this},Bp=function(i,e,t,s){var r=e+" Iterator";return i.prototype=Cp(Rp,{next:xp(+!s,t)}),Lp(i,r,!1,!0),Np[r]=Op,i},Mp=at,Vp=He,Eu=hf,Fp=Bp,Up=gu,jp=_n,wo=wn,Hp=De,Po=Ni,$u=yu,Gp=Eu.PROPER;Eu.CONFIGURABLE;$u.IteratorPrototype;var _s=$u.BUGGY_SAFARI_ITERATORS,na=Hp("iterator"),_o="keys",Ds="values",Do="entries",Yp=function(){return this},zp=function(i,e,t,s,r,n,o){Fp(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=Up(p.call(new i)),m!==Object.prototype&&m.next&&(jp(m,d,!0,!0),Po[d]=Yp)),Gp&&r==Ds&&h&&h.name!==Ds&&(u=!0,f=function(){return Vp(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 Mp({target:e,proto:!0,forced:_s||u},g);return o&&c[na]!==f&&wo(c,na,f,{name:r}),Po[e]=f,g},qp=function(i,e){return{value:i,done:e}},Wp=fs,Io=Ni,ku=su;ui.f;var Qp=zp,Is=qp,Au="Array Iterator",Kp=ku.set,Jp=ku.getterFor(Au);Qp(Array,"Array",function(i,e){Kp(this,{type:Au,target:Wp(i),index:0,kind:e})},function(){var i=Jp(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 Xp=De,Zp=Ni,em=Xp("iterator"),tm=Array.prototype,im=function(i){return i!==void 0&&(Zp.Array===i||tm[em]===i)},sm=vs,Ro=gr,rm=hs,am=Ni,nm=De,om=nm("iterator"),wu=function(i){if(!rm(i))return Ro(i,om)||Ro(i,"@@iterator")||am[sm(i)]},lm=He,um=ci,dm=xt,cm=br,hm=wu,fm=TypeError,pm=function(i,e){var t=arguments.length<2?hm(i):e;if(um(t))return dm(lm(t,i));throw fm(cm(i)+" is not iterable")},mm=He,Co=xt,vm=gr,bm=function(i,e,t){var s,r;Co(i);try{if(s=vm(i,"return"),!s){if(e==="throw")throw t;return t}s=mm(s,i)}catch(n){r=!0,s=n}if(e==="throw")throw t;if(r)throw s;return Co(s),t},gm=Tr,Sm=He,ym=xt,Tm=br,Em=im,$m=An,xo=mr,km=pm,Am=wu,Lo=bm,wm=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=gm(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?(ym(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=Am(i),!c)throw wm(Tm(i)+" is not iterable");if(Em(c)){for(h=0,f=$m(i);f>h;h++)if(p=v(i[h]),p&&xo(No,p))return p;return new Ws(!1)}u=km(i,c)}for(m=n?i.next:u.next;!(g=Sm(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)},Pm=Sn,_m=ui,Dm=yr,Im=function(i,e,t){var s=Pm(e);s in i?_m.f(i,s,Dm(0,t)):i[s]=t},Rm=at,Cm=Dn,xm=Im;Rm({target:"Object",stat:!0},{fromEntries:function(e){var t={};return Cm(e,function(s,r){xm(t,s,r)},{AS_ENTRIES:!0}),t}});var Lm=bn,Nm=Lm.Object.fromEntries,Om={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},Bm=Om,Mm=Te,Vm=vs,Fm=ps,Oo=Ni,Um=De,Bo=Um("toStringTag");for(var oa in Bm){var Mo=Mm[oa],la=Mo&&Mo.prototype;la&&Vm(la)!==Bo&&Fm(la,Bo,oa),Oo[oa]=Oo.Array}var jm=Nm,Hm=jm,Gm=Hm,Ym=Gm,ni=fr(Ym),zm=cs,Er=typeof process!="undefined"&&zm(process)=="process",qm=ui,Wm=function(i,e,t){return qm.f(i,e,t)},Qm=di,Km=Wm,Jm=De,Xm=jt,Vo=Jm("species"),Zm=function(i){var e=Qm(i);Xm&&e&&!e[Vo]&&Km(e,Vo,{configurable:!0,get:function(){return this}})},ev=mr,tv=TypeError,iv=function(i,e){if(ev(e,i))return i;throw tv("Incorrect invocation")},sv=Je,rv=pe,Ka=gn,av=sv(Function.toString);rv(Ka.inspectSource)||(Ka.inspectSource=function(i){return av(i)});var Pu=Ka.inspectSource,nv=Je,ov=Ke,_u=pe,lv=vs,uv=di,dv=Pu,Du=function(){},cv=[],Iu=uv("Reflect","construct"),In=/^\s*(?:class|function)\b/,hv=nv(In.exec),fv=!In.exec(Du),Ki=function(e){if(!_u(e))return!1;try{return Iu(Du,cv,e),!0}catch(t){return!1}},Ru=function(e){if(!_u(e))return!1;switch(lv(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return fv||!!hv(In,dv(e))}catch(t){return!0}};Ru.sham=!0;var pv=!Iu||ov(function(){var i;return Ki(Ki.call)||!Ki(Object)||!Ki(function(){i=!0})||i})?Ru:Ki,mv=pv,vv=br,bv=TypeError,gv=function(i){if(mv(i))return i;throw bv(vv(i)+" is not a constructor")},Fo=xt,Sv=gv,yv=hs,Tv=De,Ev=Tv("species"),Cu=function(i,e){var t=Fo(i).constructor,s;return t===void 0||yv(s=Fo(t)[Ev])?e:Sv(s)},$v=Je,kv=$v([].slice),Av=TypeError,wv=function(i,e){if(i<e)throw Av("Not enough arguments");return i},Pv=vr,xu=/(?:ipad|iphone|ipod).*applewebkit/i.test(Pv),je=Te,_v=au,Dv=Tr,Uo=pe,Iv=mt,Lu=Ke,jo=pu,Rv=kv,Ho=vn,Cv=wv,xv=xu,Lv=Er,Ja=je.setImmediate,Xa=je.clearImmediate,Nv=je.process,ua=je.Dispatch,Ov=je.Function,Go=je.MessageChannel,Bv=je.String,da=0,rs={},Yo="onreadystatechange",ls,ti,ca,ha;Lu(function(){ls=je.location});var Rn=function(i){if(Iv(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(Bv(i),ls.protocol+"//"+ls.host)};(!Ja||!Xa)&&(Ja=function(e){Cv(arguments.length,1);var t=Uo(e)?e:Ov(e),s=Rv(arguments,1);return rs[++da]=function(){_v(t,void 0,s)},ti(da),da},Xa=function(e){delete rs[e]},Lv?ti=function(i){Nv.nextTick(fa(i))}:ua&&ua.now?ti=function(i){ua.now(fa(i))}:Go&&!xv?(ca=new Go,ha=ca.port2,ca.port1.onmessage=zo,ti=Dv(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,Mv=vr,Vv=/ipad|iphone|ipod/i.test(Mv)&&typeof Pebble!="undefined",Fv=vr,Uv=/web0s(?!.*chrome)/i.test(Fv),oi=Te,Wo=Tr,jv=En.f,pa=Nu.set,Hv=Bu,Gv=xu,Yv=Vv,zv=Uv,ma=Er,Qo=oi.MutationObserver||oi.WebKitMutationObserver,Ko=oi.document,Jo=oi.process,Rs=oi.Promise,Xo=jv(oi,"queueMicrotask"),Za=Xo&&Xo.value,Si,va,ba,Cs,Zo;if(!Za){var xs=new Hv,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()};!Gv&&!ma&&!zv&&Qo&&Ko?(va=!0,ba=Ko.createTextNode(""),new Qo(Ls).observe(ba,{characterData:!0}),Si=function(){ba.data=va=!va}):!Yv&&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 qv=Za,Wv=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}}},Qv=Te,Oi=Qv.Promise,Mu=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",Kv=Mu,Jv=Er,Xv=!Kv&&!Jv&&typeof window=="object"&&typeof document=="object",Zv=Te,as=Oi,eb=pe,tb=du,ib=Pu,sb=De,rb=Xv,ab=Mu,ga=Ql,el=as&&as.prototype,nb=sb("species"),en=!1,Vu=eb(Zv.PromiseRejectionEvent),ob=tb("Promise",function(){var i=ib(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[nb]=s,en=t.then(function(){})instanceof s,!en)return!0}return!e&&(rb||ab)&&!Vu}),bs={CONSTRUCTOR:ob,REJECTION_EVENT:Vu,SUBCLASSING:en},Bi={},tl=ci,lb=TypeError,ub=function(i){var e,t;this.promise=new i(function(s,r){if(e!==void 0||t!==void 0)throw lb("Bad Promise constructor");e=s,t=r}),this.resolve=tl(e),this.reject=tl(t)};Bi.f=function(i){return new ub(i)};var db=at,Zs=Er,Ft=Te,gs=He,cb=wn,hb=_n,fb=Zm,pb=ci,tn=pe,mb=Ct,vb=iv,bb=Cu,Fu=Nu.set,xn=qv,gb=Wv,Sb=Cn,yb=Bu,Uu=su,sn=Oi,Ln=bs,ju=Bi,$r="Promise",Hu=Ln.CONSTRUCTOR,Tb=Ln.REJECTION_EVENT;Ln.SUBCLASSING;var Sa=Uu.getterFor($r),Eb=Uu.set,$b=sn&&sn.prototype,Ai=sn,ya=$b,Gu=Ft.TypeError,rn=Ft.document,Nn=Ft.process,an=ju.f,kb=an,Ab=!!(rn&&rn.createEvent&&Ft.dispatchEvent),Yu="unhandledrejection",wb="rejectionhandled",il=0,zu=1,Pb=2,On=1,qu=2,Ns,sl,_b,Wu=function(i){var e;return mb(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&&Ib(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&&Db(i)}))},Ju=function(i,e,t){var s,r;Ab?(s=rn.createEvent("Event"),s.promise=e,s.reason=t,s.initEvent(i,!1,!0),Ft.dispatchEvent(s)):s={promise:e,reason:t},!Tb&&(r=Ft["on"+i])?r(s):i===Yu&&gb("Unhandled promise rejection",t)},Db=function(i){gs(Fu,Ft,function(){var e=i.facade,t=i.value,s=rl(i),r;if(s&&(r=Sb(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},Ib=function(i){gs(Fu,Ft,function(){var e=i.facade;Zs?Nn.emit("rejectionHandled",e):Ju(wb,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=Pb,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){vb(this,ya),pb(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){Eb(this,{type:$r,done:!1,notified:!1,parent:!1,reactions:new yb,rejection:!1,state:il,value:void 0})},Ns.prototype=cb(ya,"then",function(e,t){var s=Sa(this),r=an(bb(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===_b?new sl(i):kb(i)});db({global:!0,constructor:!0,wrap:!0,forced:Hu},{Promise:Ai});hb(Ai,$r,!1,!0);fb($r);var Rb=De,Xu=Rb("iterator"),Zu=!1;try{var Cb=0,al={next:function(){return{done:!!Cb++}},return:function(){Zu=!0}};al[Xu]=function(){return this},Array.from(al,function(){throw 2})}catch(i){}var xb=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},Lb=Oi,Nb=xb,Ob=bs.CONSTRUCTOR,ed=Ob||!Nb(function(i){Lb.all(i).then(void 0,function(){})}),Bb=at,Mb=He,Vb=ci,Fb=Bi,Ub=Cn,jb=Dn,Hb=ed;Bb({target:"Promise",stat:!0,forced:Hb},{all:function(e){var t=this,s=Fb.f(t),r=s.resolve,n=s.reject,o=Ub(function(){var l=Vb(t.resolve),d=[],u=0,c=1;jb(e,function(h){var f=u++,p=!1;c++,Mb(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 Gb=at,Yb=bs.CONSTRUCTOR,nl=Oi;nl&&nl.prototype;Gb({target:"Promise",proto:!0,forced:Yb,real:!0},{catch:function(i){return this.then(void 0,i)}});var zb=at,qb=He,Wb=ci,Qb=Bi,Kb=Cn,Jb=Dn,Xb=ed;zb({target:"Promise",stat:!0,forced:Xb},{race:function(e){var t=this,s=Qb.f(t),r=s.reject,n=Kb(function(){var o=Wb(t.resolve);Jb(e,function(l){qb(o,t,l).then(s.resolve,r)})});return n.error&&r(n.value),s.promise}});var Zb=at,eg=He,tg=Bi,ig=bs.CONSTRUCTOR;Zb({target:"Promise",stat:!0,forced:ig},{reject:function(e){var t=tg.f(this);return eg(t.reject,void 0,e),t.promise}});var sg=xt,rg=Ct,ag=Bi,td=function(i,e){if(sg(i),rg(e)&&e.constructor===i)return e;var t=ag.f(i),s=t.resolve;return s(e),t.promise},ng=at,og=di,lg=Mc,ug=Oi,dg=bs.CONSTRUCTOR,cg=td,hg=og("Promise"),fg=!dg;ng({target:"Promise",stat:!0,forced:lg},{resolve:function(e){return cg(fg&&this===hg?ug:this,e)}});var pg=at,on=Oi,mg=Ke,vg=di,bg=pe,gg=Cu,ol=td,Sg=on&&on.prototype,yg=!!on&&mg(function(){Sg.finally.call({then:function(){}},function(){})});pg({target:"Promise",proto:!0,real:!0,forced:yg},{finally:function(i){var e=gg(this,vg("Promise")),t=bg(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 Tg=di,Bn=Tg,Eg=Bn,$g=Eg("Promise","finally"),kg=$g,Ag=kg,wg=Ag,Pg=wg,Ss=fr(Pg),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 _g=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 H;(function(i){i.STOPPED="stopped",i.READY="ready",i.PLAYING="playing",i.PAUSED="paused"})(H||(H={}));const Dg=5,Ig=5,Rg=500,ll=7e3;class Cg{constructor(e){this.subscription=new a.Subscription,this.loadMediaTimeoutSubscription=new a.Subscription,this.videoState=new ee(H.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!==H.STOPPED&&(this.videoState.startTransitionTo(H.STOPPED),this.stop());return}if(!r){if((o==null?void 0:o.to)!==exports.PlaybackState.PAUSED&&l.state===Y.Requested&&s!==H.STOPPED){this.seek(l.position/1e3);return}switch(n){case exports.PlaybackState.READY:{switch(s){case H.PLAYING:case H.PAUSED:case H.READY:break;case H.STOPPED:this.videoState.startTransitionTo(H.READY),this.prepare();break;default:a.assertNever(s)}break}case exports.PlaybackState.PLAYING:{switch(s){case H.PLAYING:break;case H.PAUSED:this.videoState.startTransitionTo(H.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case H.READY:this.videoState.startTransitionTo(H.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case H.STOPPED:this.videoState.startTransitionTo(H.READY),this.prepare();break;default:a.assertNever(s)}break}case exports.PlaybackState.PAUSED:{switch(s){case H.PLAYING:this.videoState.startTransitionTo(H.PAUSED),this.params.connection.remotePlayerController.playOrPause();break;case H.PAUSED:break;case H.READY:this.videoState.startTransitionTo(H.PAUSED),this.videoState.setState(H.PAUSED);break;case H.STOPPED:this.videoState.startTransitionTo(H.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(_g(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(Rg)).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)>Dg)&&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<Ig&&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(H.PAUSED),w(this.params.desiredState.playbackState,exports.PlaybackState.PAUSED)):(this.videoState.setState(H.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)===H.PAUSED||e===H.PLAYING)&&(this.videoState.setState(H.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)===H.PLAYING||e===H.PAUSED)&&(this.videoState.setState(H.PLAYING),w(this.params.desiredState.playbackState,exports.PlaybackState.PLAYING))}handleRemoteReady(){var e;const t=this.videoState.getTransition();(t==null?void 0:t.to)===H.READY&&this.videoState.setState(H.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()!==H.STOPPED&&this.videoState.setState(H.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 xg=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)},Lg=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()},Ng=i=>i.extend("RequestModifier",()=>({modifyRequestURL:Ut}),!0),Og=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}),Bg=i=>["__",i.language,i.label].join("|"),Mg=(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:Bg(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)||!Mg(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()},Vg=i=>{try{i.pause(),i.playbackRate=0,Mn(i),i.remove()}catch(e){console.error(e)}};class Fg{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 Fg,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):Vg(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)},Ug=i=>{const e=id(i);return!!(e&&e.pictureInPictureElement&&e.pictureInPictureElement===i)},un=3;class jg{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(Ug(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 Hg=at,Gg=Sr,Yg=An,zg=kn;Hg({target:"Array",proto:!0},{at:function(e){var t=Gg(this),s=Yg(t),r=zg(e),n=r>=0?r:s+r;return n<0||n>=s?void 0:t[n]}});var qg=Bn,Wg=qg("Array","at"),Qg=Wg,Kg=Qg,Jg=Kg,Xg=Jg,ge=fr(Xg);let Vn=!1,_t={};const Zg=i=>{Vn=i},eS=()=>{_t={}},tS=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 iS=new ct("best_bitrate"),sS=(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 rS='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,rS);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*sS(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&&iS.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"),Md=require("lodash");const Vl="2.0.98-dev.b4734e48.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 F(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 Vd=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 Fd{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||Vd("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(Ud),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 Ud=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}},jd=Ke,pr=!jd(function(){var i=function(){}.bind();return typeof i!="function"||i.hasOwnProperty("prototype")}),Fl=pr,Ul=Function.prototype,Ua=Ul.call,Hd=Fl&&Ul.bind.bind(Ua,Ua),Je=Fl?Hd:function(i){return function(){return Ua.apply(i,arguments)}},jl=Je,Gd=jl({}.toString),Yd=jl("".slice),cs=function(i){return Yd(Gd(i),8,-1)},zd=Je,qd=Ke,Wd=cs,jr=Object,Qd=zd("".split),Kd=qd(function(){return!jr("z").propertyIsEnumerable(0)})?function(i){return Wd(i)=="String"?Qd(i,""):jr(i)}:jr,hs=function(i){return i==null},Jd=hs,Xd=TypeError,mn=function(i){if(Jd(i))throw Xd("Can't call method on "+i);return i},Zd=Kd,ec=mn,fs=function(i){return Zd(ec(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,tc=typeof ja=="undefined"&&ja!==void 0,Hl={all:ja,IS_HTMLDDA:tc},Gl=Hl,ic=Gl.all,pe=Gl.IS_HTMLDDA?function(i){return typeof i=="function"||i===ic}:function(i){return typeof i=="function"},sc=Te,rc=pe,qn=sc.WeakMap,ac=rc(qn)&&/native code/.test(String(qn)),Wn=pe,Yl=Hl,nc=Yl.all,Ct=Yl.IS_HTMLDDA?function(i){return typeof i=="object"?i!==null:Wn(i)||i===nc}:function(i){return typeof i=="object"?i!==null:Wn(i)},oc=Ke,jt=!oc(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),ui={},lc=Te,Qn=Ct,Ha=lc.document,uc=Qn(Ha)&&Qn(Ha.createElement),vn=function(i){return uc?Ha.createElement(i):{}},dc=jt,cc=Ke,hc=vn,zl=!dc&&!cc(function(){return Object.defineProperty(hc("div"),"a",{get:function(){return 7}}).a!=7}),fc=jt,pc=Ke,ql=fc&&pc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),mc=Ct,vc=String,bc=TypeError,xt=function(i){if(mc(i))return i;throw bc(vc(i)+" is not an object")},gc=pr,ks=Function.prototype.call,He=gc?ks.bind(ks):function(){return ks.apply(ks,arguments)},bn={},Hr=bn,Gr=Te,Sc=pe,Kn=function(i){return Sc(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]},yc=Je,mr=yc({}.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,Tc=Ke,Ec=Te,$c=Ec.String,Kl=!!Object.getOwnPropertySymbols&&!Tc(function(){var i=Symbol();return!$c(i)||!(Object(i)instanceof Symbol)||!Symbol.sham&&to&&to<41}),kc=Kl,Jl=kc&&!Symbol.sham&&typeof Symbol.iterator=="symbol",Ac=di,wc=pe,Pc=mr,_c=Jl,Dc=Object,Xl=_c?function(i){return typeof i=="symbol"}:function(i){var e=Ac("Symbol");return wc(e)&&Pc(e.prototype,Dc(i))},Ic=String,br=function(i){try{return Ic(i)}catch(e){return"Object"}},Rc=pe,Cc=br,xc=TypeError,ci=function(i){if(Rc(i))return i;throw xc(Cc(i)+" is not a function")},Lc=ci,Nc=hs,gr=function(i,e){var t=i[e];return Nc(t)?void 0:Lc(t)},zr=He,qr=pe,Wr=Ct,Oc=TypeError,Bc=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 Oc("Can't convert object to primitive value")},Zl={exports:{}},Mc=!0,io=Te,Vc=Object.defineProperty,Fc=function(i,e){try{Vc(io,i,{value:e,configurable:!0,writable:!0})}catch(t){io[i]=e}return e},Uc=Te,jc=Fc,so="__core-js_shared__",Hc=Uc[so]||jc(so,{}),gn=Hc,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,Gc=mn,Yc=Object,Sr=function(i){return Yc(Gc(i))},zc=Je,qc=Sr,Wc=zc({}.hasOwnProperty),mt=Object.hasOwn||function(e,t){return Wc(qc(e),t)},Qc=Je,Kc=0,Jc=Math.random(),Xc=Qc(1 .toString),tu=function(i){return"Symbol("+(i===void 0?"":i)+")_"+Xc(++Kc+Jc,36)},Zc=Te,eh=eu,ao=mt,th=tu,ih=Kl,sh=Jl,ki=Zc.Symbol,Qr=eh("wks"),rh=sh?ki.for||ki:ki&&ki.withoutSetter||th,De=function(i){return ao(Qr,i)||(Qr[i]=ih&&ao(ki,i)?ki[i]:rh("Symbol."+i)),Qr[i]},ah=He,no=Ct,oo=Xl,nh=gr,oh=Bc,lh=De,uh=TypeError,dh=lh("toPrimitive"),ch=function(i,e){if(!no(i)||oo(i))return i;var t=nh(i,dh),s;if(t){if(e===void 0&&(e="default"),s=ah(t,i,e),!no(s)||oo(s))return s;throw uh("Can't convert object to primitive value")}return e===void 0&&(e="number"),oh(i,e)},hh=ch,fh=Xl,Sn=function(i){var e=hh(i,"string");return fh(e)?e:e+""},ph=jt,mh=zl,vh=ql,As=xt,lo=Sn,bh=TypeError,Kr=Object.defineProperty,gh=Object.getOwnPropertyDescriptor,Jr="enumerable",Xr="configurable",Zr="writable";ui.f=ph?vh?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=gh(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),mh)try{return Kr(e,t,s)}catch(r){}if("get"in s||"set"in s)throw bh("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}},Sh=jt,yh=ui,Th=yr,ps=Sh?function(i,e,t){return yh.f(i,e,Th(1,t))}:function(i,e,t){return i[e]=t,i},Eh=eu,$h=tu,uo=Eh("keys"),yn=function(i){return uo[i]||(uo[i]=$h(i))},Tn={},kh=ac,iu=Te,Ah=Ct,wh=ps,ea=mt,ta=gn,Ph=yn,_h=Tn,co="Object already initialized",Ga=iu.TypeError,Dh=iu.WeakMap,Js,os,Xs,Ih=function(i){return Xs(i)?os(i):Js(i,{})},Rh=function(i){return function(e){var t;if(!Ah(e)||(t=os(e)).type!==i)throw Ga("Incompatible receiver, "+i+" required");return t}};if(kh||ta.state){var lt=ta.state||(ta.state=new Dh);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=Ph("state");_h[vi]=!0,Js=function(i,e){if(ea(i,vi))throw Ga(co);return e.facade=i,wh(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:Ih,getterFor:Rh},Ch=pr,ru=Function.prototype,ho=ru.apply,fo=ru.call,au=typeof Reflect=="object"&&Reflect.apply||(Ch?fo.bind(ho):function(){return fo.apply(ho,arguments)}),xh=cs,Lh=Je,nu=function(i){if(xh(i)==="Function")return Lh(i)},En={},ou={},lu={}.propertyIsEnumerable,uu=Object.getOwnPropertyDescriptor,Nh=uu&&!lu.call({1:2},1);ou.f=Nh?function(e){var t=uu(this,e);return!!t&&t.enumerable}:lu;var Oh=jt,Bh=He,Mh=ou,Vh=yr,Fh=fs,Uh=Sn,jh=mt,Hh=zl,po=Object.getOwnPropertyDescriptor;En.f=Oh?po:function(e,t){if(e=Fh(e),t=Uh(t),Hh)try{return po(e,t)}catch(s){}if(jh(e,t))return Vh(!Bh(Mh.f,e,t),e[t])};var Gh=Ke,Yh=pe,zh=/#|\.prototype\./,ms=function(i,e){var t=Wh[qh(i)];return t==Kh?!0:t==Qh?!1:Yh(e)?Gh(e):!!e},qh=ms.normalize=function(i){return String(i).replace(zh,".").toLowerCase()},Wh=ms.data={},Qh=ms.NATIVE="N",Kh=ms.POLYFILL="P",du=ms,mo=nu,Jh=ci,Xh=pr,Zh=mo(mo.bind),Tr=function(i,e){return Jh(i),e===void 0?i:Xh?Zh(i,e):function(){return i.apply(e,arguments)}},ws=Te,ef=au,tf=nu,sf=pe,rf=En.f,af=du,bi=bn,nf=Tr,gi=ps,vo=mt,of=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 ef(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=af(s?f:t+(r?".":"#")+f,i.forced),c=!u&&o&&vo(o,f),m=l[f],c&&(i.dontCallGetSet?(v=rf(o,f),g=v&&v.value):g=o[f]),p=c&&g?g:e[f],!(c&&typeof m==typeof p)&&(i.bind&&c?S=nf(p,ws):i.wrap&&c?S=of(p):n&&sf(p)?S=tf(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,lf=mt,cu=Function.prototype,uf=Ya&&Object.getOwnPropertyDescriptor,$n=lf(cu,"name"),df=$n&&function(){}.name==="something",cf=$n&&(!Ya||Ya&&uf(cu,"name").configurable),hf={EXISTS:$n,PROPER:df,CONFIGURABLE:cf},hu={},ff=Math.ceil,pf=Math.floor,mf=Math.trunc||function(e){var t=+e;return(t>0?pf:ff)(t)},vf=mf,kn=function(i){var e=+i;return e!==e||e===0?0:vf(e)},bf=kn,gf=Math.max,Sf=Math.min,yf=function(i,e){var t=bf(i);return t<0?gf(t+e,0):Sf(t,e)},Tf=kn,Ef=Math.min,$f=function(i){return i>0?Ef(Tf(i),9007199254740991):0},kf=$f,An=function(i){return kf(i.length)},Af=fs,wf=yf,Pf=An,bo=function(i){return function(e,t,s){var r=Af(e),n=Pf(r),o=wf(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}},_f={includes:bo(!0),indexOf:bo(!1)},Df=Je,ia=mt,If=fs,Rf=_f.indexOf,Cf=Tn,go=Df([].push),xf=function(i,e){var t=If(i),s=0,r=[],n;for(n in t)!ia(Cf,n)&&ia(t,n)&&go(r,n);for(;e.length>s;)ia(t,n=e[s++])&&(~Rf(r,n)||go(r,n));return r},fu=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Lf=xf,Nf=fu,Of=Object.keys||function(e){return Lf(e,Nf)},Bf=jt,Mf=ql,Vf=ui,Ff=xt,Uf=fs,jf=Of;hu.f=Bf&&!Mf?Object.defineProperties:function(e,t){Ff(e);for(var s=Uf(t),r=jf(t),n=r.length,o=0,l;n>o;)Vf.f(e,l=r[o++],s[l]);return e};var Hf=di,pu=Hf("document","documentElement"),Gf=xt,Yf=hu,So=fu,zf=Tn,qf=pu,Wf=vn,Qf=yn,yo=">",To="<",za="prototype",qa="script",mu=Qf("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},Kf=function(){var i=Wf("iframe"),e="java"+qa+":",t;return i.style.display="none",qf.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):Kf():Eo(Ps);for(var i=So.length;i--;)delete zs[za][So[i]];return zs()};zf[mu]=!0;var bu=Object.create||function(e,t){var s;return e!==null?(sa[za]=Gf(e),s=new sa,sa[za]=null,s[mu]=e):s=zs(),t===void 0?s:Yf.f(s,t)},Jf=Ke,Xf=!Jf(function(){function i(){}return i.prototype.constructor=null,Object.getPrototypeOf(new i)!==i.prototype}),Zf=mt,ep=pe,tp=Sr,ip=yn,sp=Xf,$o=ip("IE_PROTO"),Wa=Object,rp=Wa.prototype,gu=sp?Wa.getPrototypeOf:function(i){var e=tp(i);if(Zf(e,$o))return e[$o];var t=e.constructor;return ep(t)&&e instanceof t?t.prototype:e instanceof Wa?rp:null},ap=ps,wn=function(i,e,t,s){return s&&s.enumerable?i[e]=t:ap(i,e,t),i},np=Ke,op=pe,lp=Ct,up=bu,ko=gu,dp=wn,cp=De,Qa=cp("iterator"),Su=!1,Dt,ra,aa;[].keys&&(aa=[].keys(),"next"in aa?(ra=ko(ko(aa)),ra!==Object.prototype&&(Dt=ra)):Su=!0);var hp=!lp(Dt)||np(function(){var i={};return Dt[Qa].call(i)!==i});hp?Dt={}:Dt=up(Dt);op(Dt[Qa])||dp(Dt,Qa,function(){return this});var yu={IteratorPrototype:Dt,BUGGY_SAFARI_ITERATORS:Su},fp=De,pp=fp("toStringTag"),Tu={};Tu[pp]="z";var Pn=String(Tu)==="[object z]",mp=Pn,vp=pe,qs=cs,bp=De,gp=bp("toStringTag"),Sp=Object,yp=qs(function(){return arguments}())=="Arguments",Tp=function(i,e){try{return i[e]}catch(t){}},vs=mp?qs:function(i){var e,t,s;return i===void 0?"Undefined":i===null?"Null":typeof(t=Tp(e=Sp(i),gp))=="string"?t:yp?qs(e):(s=qs(e))=="Object"&&vp(e.callee)?"Arguments":s},Ep=Pn,$p=vs,kp=Ep?{}.toString:function(){return"[object "+$p(this)+"]"},Ap=Pn,wp=ui.f,Pp=ps,_p=mt,Dp=kp,Ip=De,Ao=Ip("toStringTag"),_n=function(i,e,t,s){if(i){var r=t?i:i.prototype;_p(r,Ao)||wp(r,Ao,{configurable:!0,value:e}),s&&!Ap&&Pp(r,"toString",Dp)}},Rp=yu.IteratorPrototype,Cp=bu,xp=yr,Lp=_n,Np=Ni,Op=function(){return this},Bp=function(i,e,t,s){var r=e+" Iterator";return i.prototype=Cp(Rp,{next:xp(+!s,t)}),Lp(i,r,!1,!0),Np[r]=Op,i},Mp=at,Vp=He,Eu=hf,Fp=Bp,Up=gu,jp=_n,wo=wn,Hp=De,Po=Ni,$u=yu,Gp=Eu.PROPER;Eu.CONFIGURABLE;$u.IteratorPrototype;var _s=$u.BUGGY_SAFARI_ITERATORS,na=Hp("iterator"),_o="keys",Ds="values",Do="entries",Yp=function(){return this},zp=function(i,e,t,s,r,n,o){Fp(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=Up(p.call(new i)),m!==Object.prototype&&m.next&&(jp(m,d,!0,!0),Po[d]=Yp)),Gp&&r==Ds&&h&&h.name!==Ds&&(u=!0,f=function(){return Vp(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 Mp({target:e,proto:!0,forced:_s||u},g);return o&&c[na]!==f&&wo(c,na,f,{name:r}),Po[e]=f,g},qp=function(i,e){return{value:i,done:e}},Wp=fs,Io=Ni,ku=su;ui.f;var Qp=zp,Is=qp,Au="Array Iterator",Kp=ku.set,Jp=ku.getterFor(Au);Qp(Array,"Array",function(i,e){Kp(this,{type:Au,target:Wp(i),index:0,kind:e})},function(){var i=Jp(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 Xp=De,Zp=Ni,em=Xp("iterator"),tm=Array.prototype,im=function(i){return i!==void 0&&(Zp.Array===i||tm[em]===i)},sm=vs,Ro=gr,rm=hs,am=Ni,nm=De,om=nm("iterator"),wu=function(i){if(!rm(i))return Ro(i,om)||Ro(i,"@@iterator")||am[sm(i)]},lm=He,um=ci,dm=xt,cm=br,hm=wu,fm=TypeError,pm=function(i,e){var t=arguments.length<2?hm(i):e;if(um(t))return dm(lm(t,i));throw fm(cm(i)+" is not iterable")},mm=He,Co=xt,vm=gr,bm=function(i,e,t){var s,r;Co(i);try{if(s=vm(i,"return"),!s){if(e==="throw")throw t;return t}s=mm(s,i)}catch(n){r=!0,s=n}if(e==="throw")throw t;if(r)throw s;return Co(s),t},gm=Tr,Sm=He,ym=xt,Tm=br,Em=im,$m=An,xo=mr,km=pm,Am=wu,Lo=bm,wm=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=gm(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?(ym(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=Am(i),!c)throw wm(Tm(i)+" is not iterable");if(Em(c)){for(h=0,f=$m(i);f>h;h++)if(p=v(i[h]),p&&xo(No,p))return p;return new Ws(!1)}u=km(i,c)}for(m=n?i.next:u.next;!(g=Sm(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)},Pm=Sn,_m=ui,Dm=yr,Im=function(i,e,t){var s=Pm(e);s in i?_m.f(i,s,Dm(0,t)):i[s]=t},Rm=at,Cm=Dn,xm=Im;Rm({target:"Object",stat:!0},{fromEntries:function(e){var t={};return Cm(e,function(s,r){xm(t,s,r)},{AS_ENTRIES:!0}),t}});var Lm=bn,Nm=Lm.Object.fromEntries,Om={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},Bm=Om,Mm=Te,Vm=vs,Fm=ps,Oo=Ni,Um=De,Bo=Um("toStringTag");for(var oa in Bm){var Mo=Mm[oa],la=Mo&&Mo.prototype;la&&Vm(la)!==Bo&&Fm(la,Bo,oa),Oo[oa]=Oo.Array}var jm=Nm,Hm=jm,Gm=Hm,Ym=Gm,ni=fr(Ym),zm=cs,Er=typeof process!="undefined"&&zm(process)=="process",qm=ui,Wm=function(i,e,t){return qm.f(i,e,t)},Qm=di,Km=Wm,Jm=De,Xm=jt,Vo=Jm("species"),Zm=function(i){var e=Qm(i);Xm&&e&&!e[Vo]&&Km(e,Vo,{configurable:!0,get:function(){return this}})},ev=mr,tv=TypeError,iv=function(i,e){if(ev(e,i))return i;throw tv("Incorrect invocation")},sv=Je,rv=pe,Ka=gn,av=sv(Function.toString);rv(Ka.inspectSource)||(Ka.inspectSource=function(i){return av(i)});var Pu=Ka.inspectSource,nv=Je,ov=Ke,_u=pe,lv=vs,uv=di,dv=Pu,Du=function(){},cv=[],Iu=uv("Reflect","construct"),In=/^\s*(?:class|function)\b/,hv=nv(In.exec),fv=!In.exec(Du),Ki=function(e){if(!_u(e))return!1;try{return Iu(Du,cv,e),!0}catch(t){return!1}},Ru=function(e){if(!_u(e))return!1;switch(lv(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return fv||!!hv(In,dv(e))}catch(t){return!0}};Ru.sham=!0;var pv=!Iu||ov(function(){var i;return Ki(Ki.call)||!Ki(Object)||!Ki(function(){i=!0})||i})?Ru:Ki,mv=pv,vv=br,bv=TypeError,gv=function(i){if(mv(i))return i;throw bv(vv(i)+" is not a constructor")},Fo=xt,Sv=gv,yv=hs,Tv=De,Ev=Tv("species"),Cu=function(i,e){var t=Fo(i).constructor,s;return t===void 0||yv(s=Fo(t)[Ev])?e:Sv(s)},$v=Je,kv=$v([].slice),Av=TypeError,wv=function(i,e){if(i<e)throw Av("Not enough arguments");return i},Pv=vr,xu=/(?:ipad|iphone|ipod).*applewebkit/i.test(Pv),je=Te,_v=au,Dv=Tr,Uo=pe,Iv=mt,Lu=Ke,jo=pu,Rv=kv,Ho=vn,Cv=wv,xv=xu,Lv=Er,Ja=je.setImmediate,Xa=je.clearImmediate,Nv=je.process,ua=je.Dispatch,Ov=je.Function,Go=je.MessageChannel,Bv=je.String,da=0,rs={},Yo="onreadystatechange",ls,ti,ca,ha;Lu(function(){ls=je.location});var Rn=function(i){if(Iv(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(Bv(i),ls.protocol+"//"+ls.host)};(!Ja||!Xa)&&(Ja=function(e){Cv(arguments.length,1);var t=Uo(e)?e:Ov(e),s=Rv(arguments,1);return rs[++da]=function(){_v(t,void 0,s)},ti(da),da},Xa=function(e){delete rs[e]},Lv?ti=function(i){Nv.nextTick(fa(i))}:ua&&ua.now?ti=function(i){ua.now(fa(i))}:Go&&!xv?(ca=new Go,ha=ca.port2,ca.port1.onmessage=zo,ti=Dv(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,Mv=vr,Vv=/ipad|iphone|ipod/i.test(Mv)&&typeof Pebble!="undefined",Fv=vr,Uv=/web0s(?!.*chrome)/i.test(Fv),oi=Te,Wo=Tr,jv=En.f,pa=Nu.set,Hv=Bu,Gv=xu,Yv=Vv,zv=Uv,ma=Er,Qo=oi.MutationObserver||oi.WebKitMutationObserver,Ko=oi.document,Jo=oi.process,Rs=oi.Promise,Xo=jv(oi,"queueMicrotask"),Za=Xo&&Xo.value,Si,va,ba,Cs,Zo;if(!Za){var xs=new Hv,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()};!Gv&&!ma&&!zv&&Qo&&Ko?(va=!0,ba=Ko.createTextNode(""),new Qo(Ls).observe(ba,{characterData:!0}),Si=function(){ba.data=va=!va}):!Yv&&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 qv=Za,Wv=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}}},Qv=Te,Oi=Qv.Promise,Mu=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",Kv=Mu,Jv=Er,Xv=!Kv&&!Jv&&typeof window=="object"&&typeof document=="object",Zv=Te,as=Oi,eb=pe,tb=du,ib=Pu,sb=De,rb=Xv,ab=Mu,ga=Ql,el=as&&as.prototype,nb=sb("species"),en=!1,Vu=eb(Zv.PromiseRejectionEvent),ob=tb("Promise",function(){var i=ib(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[nb]=s,en=t.then(function(){})instanceof s,!en)return!0}return!e&&(rb||ab)&&!Vu}),bs={CONSTRUCTOR:ob,REJECTION_EVENT:Vu,SUBCLASSING:en},Bi={},tl=ci,lb=TypeError,ub=function(i){var e,t;this.promise=new i(function(s,r){if(e!==void 0||t!==void 0)throw lb("Bad Promise constructor");e=s,t=r}),this.resolve=tl(e),this.reject=tl(t)};Bi.f=function(i){return new ub(i)};var db=at,Zs=Er,Ft=Te,gs=He,cb=wn,hb=_n,fb=Zm,pb=ci,tn=pe,mb=Ct,vb=iv,bb=Cu,Fu=Nu.set,xn=qv,gb=Wv,Sb=Cn,yb=Bu,Uu=su,sn=Oi,Ln=bs,ju=Bi,$r="Promise",Hu=Ln.CONSTRUCTOR,Tb=Ln.REJECTION_EVENT;Ln.SUBCLASSING;var Sa=Uu.getterFor($r),Eb=Uu.set,$b=sn&&sn.prototype,Ai=sn,ya=$b,Gu=Ft.TypeError,rn=Ft.document,Nn=Ft.process,an=ju.f,kb=an,Ab=!!(rn&&rn.createEvent&&Ft.dispatchEvent),Yu="unhandledrejection",wb="rejectionhandled",il=0,zu=1,Pb=2,On=1,qu=2,Ns,sl,_b,Wu=function(i){var e;return mb(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&&Ib(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&&Db(i)}))},Ju=function(i,e,t){var s,r;Ab?(s=rn.createEvent("Event"),s.promise=e,s.reason=t,s.initEvent(i,!1,!0),Ft.dispatchEvent(s)):s={promise:e,reason:t},!Tb&&(r=Ft["on"+i])?r(s):i===Yu&&gb("Unhandled promise rejection",t)},Db=function(i){gs(Fu,Ft,function(){var e=i.facade,t=i.value,s=rl(i),r;if(s&&(r=Sb(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},Ib=function(i){gs(Fu,Ft,function(){var e=i.facade;Zs?Nn.emit("rejectionHandled",e):Ju(wb,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=Pb,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){vb(this,ya),pb(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){Eb(this,{type:$r,done:!1,notified:!1,parent:!1,reactions:new yb,rejection:!1,state:il,value:void 0})},Ns.prototype=cb(ya,"then",function(e,t){var s=Sa(this),r=an(bb(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===_b?new sl(i):kb(i)});db({global:!0,constructor:!0,wrap:!0,forced:Hu},{Promise:Ai});hb(Ai,$r,!1,!0);fb($r);var Rb=De,Xu=Rb("iterator"),Zu=!1;try{var Cb=0,al={next:function(){return{done:!!Cb++}},return:function(){Zu=!0}};al[Xu]=function(){return this},Array.from(al,function(){throw 2})}catch(i){}var xb=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},Lb=Oi,Nb=xb,Ob=bs.CONSTRUCTOR,ed=Ob||!Nb(function(i){Lb.all(i).then(void 0,function(){})}),Bb=at,Mb=He,Vb=ci,Fb=Bi,Ub=Cn,jb=Dn,Hb=ed;Bb({target:"Promise",stat:!0,forced:Hb},{all:function(e){var t=this,s=Fb.f(t),r=s.resolve,n=s.reject,o=Ub(function(){var l=Vb(t.resolve),d=[],u=0,c=1;jb(e,function(h){var f=u++,p=!1;c++,Mb(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 Gb=at,Yb=bs.CONSTRUCTOR,nl=Oi;nl&&nl.prototype;Gb({target:"Promise",proto:!0,forced:Yb,real:!0},{catch:function(i){return this.then(void 0,i)}});var zb=at,qb=He,Wb=ci,Qb=Bi,Kb=Cn,Jb=Dn,Xb=ed;zb({target:"Promise",stat:!0,forced:Xb},{race:function(e){var t=this,s=Qb.f(t),r=s.reject,n=Kb(function(){var o=Wb(t.resolve);Jb(e,function(l){qb(o,t,l).then(s.resolve,r)})});return n.error&&r(n.value),s.promise}});var Zb=at,eg=He,tg=Bi,ig=bs.CONSTRUCTOR;Zb({target:"Promise",stat:!0,forced:ig},{reject:function(e){var t=tg.f(this);return eg(t.reject,void 0,e),t.promise}});var sg=xt,rg=Ct,ag=Bi,td=function(i,e){if(sg(i),rg(e)&&e.constructor===i)return e;var t=ag.f(i),s=t.resolve;return s(e),t.promise},ng=at,og=di,lg=Mc,ug=Oi,dg=bs.CONSTRUCTOR,cg=td,hg=og("Promise"),fg=!dg;ng({target:"Promise",stat:!0,forced:lg},{resolve:function(e){return cg(fg&&this===hg?ug:this,e)}});var pg=at,on=Oi,mg=Ke,vg=di,bg=pe,gg=Cu,ol=td,Sg=on&&on.prototype,yg=!!on&&mg(function(){Sg.finally.call({then:function(){}},function(){})});pg({target:"Promise",proto:!0,real:!0,forced:yg},{finally:function(i){var e=gg(this,vg("Promise")),t=bg(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 Tg=di,Bn=Tg,Eg=Bn,$g=Eg("Promise","finally"),kg=$g,Ag=kg,wg=Ag,Pg=wg,Ss=fr(Pg),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 _g=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 H;(function(i){i.STOPPED="stopped",i.READY="ready",i.PLAYING="playing",i.PAUSED="paused"})(H||(H={}));const Dg=5,Ig=5,Rg=500,ll=7e3;class Cg{constructor(e){this.subscription=new a.Subscription,this.loadMediaTimeoutSubscription=new a.Subscription,this.videoState=new ee(H.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!==H.STOPPED&&(this.videoState.startTransitionTo(H.STOPPED),this.stop());return}if(!r){if((o==null?void 0:o.to)!==exports.PlaybackState.PAUSED&&l.state===Y.Requested&&s!==H.STOPPED){this.seek(l.position/1e3);return}switch(n){case exports.PlaybackState.READY:{switch(s){case H.PLAYING:case H.PAUSED:case H.READY:break;case H.STOPPED:this.videoState.startTransitionTo(H.READY),this.prepare();break;default:a.assertNever(s)}break}case exports.PlaybackState.PLAYING:{switch(s){case H.PLAYING:break;case H.PAUSED:this.videoState.startTransitionTo(H.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case H.READY:this.videoState.startTransitionTo(H.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case H.STOPPED:this.videoState.startTransitionTo(H.READY),this.prepare();break;default:a.assertNever(s)}break}case exports.PlaybackState.PAUSED:{switch(s){case H.PLAYING:this.videoState.startTransitionTo(H.PAUSED),this.params.connection.remotePlayerController.playOrPause();break;case H.PAUSED:break;case H.READY:this.videoState.startTransitionTo(H.PAUSED),this.videoState.setState(H.PAUSED);break;case H.STOPPED:this.videoState.startTransitionTo(H.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(_g(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(Rg)).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)>Dg)&&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<Ig&&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(H.PAUSED),w(this.params.desiredState.playbackState,exports.PlaybackState.PAUSED)):(this.videoState.setState(H.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)===H.PAUSED||e===H.PLAYING)&&(this.videoState.setState(H.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)===H.PLAYING||e===H.PAUSED)&&(this.videoState.setState(H.PLAYING),w(this.params.desiredState.playbackState,exports.PlaybackState.PLAYING))}handleRemoteReady(){var e;const t=this.videoState.getTransition();(t==null?void 0:t.to)===H.READY&&this.videoState.setState(H.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()!==H.STOPPED&&this.videoState.setState(H.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 xg=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)},Lg=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()},Ng=i=>i.extend("RequestModifier",()=>({modifyRequestURL:Ut}),!0),Og=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}),Bg=i=>["__",i.language,i.label].join("|"),Mg=(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:Bg(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)||!Mg(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()},Vg=i=>{try{i.pause(),i.playbackRate=0,Mn(i),i.remove()}catch(e){console.error(e)}};class Fg{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 Fg,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):Vg(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)},Ug=i=>{const e=id(i);return!!(e&&e.pictureInPictureElement&&e.pictureInPictureElement===i)},un=3;class jg{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(Ug(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 Hg=at,Gg=Sr,Yg=An,zg=kn;Hg({target:"Array",proto:!0},{at:function(e){var t=Gg(this),s=Yg(t),r=zg(e),n=r>=0?r:s+r;return n<0||n>=s?void 0:t[n]}});var qg=Bn,Wg=qg("Array","at"),Qg=Wg,Kg=Qg,Jg=Kg,Xg=Jg,ge=fr(Xg);let Vn=!1,_t={};const Zg=i=>{Vn=i},eS=()=>{_t={}},tS=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 iS=new ct("best_bitrate"),sS=(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 rS='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,rS);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*sS(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&&iS.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
  `)}