@vkontakte/videoplayer-core 2.0.102-beta.0 → 2.0.102-beta.1

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.102-beta.0
3
- * Tue, 07 May 2024 23:33:38 GMT
2
+ * @vkontakte/videoplayer-core v2.0.102-beta.1
3
+ * Wed, 15 May 2024 15:26:48 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/2-0-102/doc/
5
5
  */
6
- "use strict";var Vu=Object.create;var Ya=Object.defineProperty;var Fu=Object.getOwnPropertyDescriptor;var Uu=Object.getOwnPropertyNames;var ju=Object.getPrototypeOf,Hu=Object.prototype.hasOwnProperty;var Gu=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Uu(e))!Hu.call(i,s)&&s!==t&&Ya(i,s,{get:()=>e[s],enumerable:!(r=Fu(e,s))||r.enumerable});return i};var Yu=(i,e,t)=>(t=i!=null?Vu(ju(i)):{},Gu(e||!i||!i.__esModule?Ya(t,"default",{value:i,enumerable:!0}):t,i));var a=require("@vkontakte/videoplayer-shared/es2015.cjs.js");const Bo="2.0.102-beta.0";exports.PlaybackState=void 0;(function(i){i.STOPPED="stopped",i.READY="ready",i.PLAYING="playing",i.PAUSED="paused"})(exports.PlaybackState||(exports.PlaybackState={}));exports.VideoFormat=void 0;(function(i){i.MPEG="MPEG",i.DASH="DASH_SEP",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 le;(function(i){i.SCREEN="SCREEN",i.CHROMECAST="CHROMECAST"})(le||(le={}));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 N;(function(i){i.None="none",i.Requested="requested",i.Applying="applying"})(N||(N={}));exports.Surface=void 0;(function(i){i.NONE="none",i.INLINE="inline",i.FULLSCREEN="fullscreen",i.SECOND_SCREEN="second_screen",i.PIP="pip"})(exports.Surface||(exports.Surface={}));function H(i,e,t,r){function s(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(r.next(c))}catch(h){o(h)}}function d(c){try{u(r.throw(c))}catch(h){o(h)}}function u(c){c.done?n(c.value):s(c.value).then(l,d)}u((r=r.apply(i,e||[])).next())})}function C(i){return this instanceof C?(this.v=i,this):new C(i)}function he(i,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(i,e||[]),s,n=[];return s={},o("next"),o("throw"),o("return"),s[Symbol.asyncIterator]=function(){return this},s;function o(f){r[f]&&(s[f]=function(p){return new Promise(function(v,m){n.push([f,p,v,m])>1||l(f,p)})})}function l(f,p){try{d(r[f](p))}catch(v){h(n[0][3],v)}}function d(f){f.value instanceof C?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 qu=i=>new Promise((e,t)=>{const r=document.createElement("script");r.setAttribute("src",i),r.onload=()=>e,r.onerror=()=>t,document.body.appendChild(r)});class Wu{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 r="chrome"in window;if(this.log({message:`[constructor] receiverApplicationId: ${this.params.receiverApplicationId}, isDisabled: ${this.params.isDisabled}, isSupported: ${r}`}),e.isDisabled||!r)return;const s=a.isNonNullable((t=window.chrome)===null||t===void 0?void 0:t.cast),n=!!window.__onGCastApiAvailable;s?this.initializeCastApi():(window.__onGCastApiAvailable=o=>{delete window.__onGCastApiAvailable,o&&this.initializeCastApi()},n||qu("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 r,s,n;(n=(s=(r=cast.framework.CastContext.getInstance())===null||r===void 0?void 0:r.getCurrentSession())===null||s===void 0?void 0:s.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),r=cast.framework.CastContext.getInstance();this.subscription.add(a.fromEvent(r,cast.framework.CastContextEventType.SESSION_STATE_CHANGED).subscribe(s=>{var n,o;switch(s.sessionState){case cast.framework.SessionState.SESSION_STARTED:case cast.framework.SessionState.SESSION_STARTING:case cast.framework.SessionState.SESSION_RESUMED:this.contentId=(o=(n=r.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(s.sessionState)}})).add(a.merge(a.fromEvent(r,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe(a.tap(s=>{this.log({message:`[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: ${JSON.stringify(s)}`})}),a.map(s=>s.castState)),a.observableFrom([r.getCastState()])).pipe(a.filterChanged(),a.map(zu),a.tap(s=>{this.log({message:`realCastState$: ${s}`})})).subscribe(this.realCastState$)).add(this.realCastState$.subscribe(s=>{var n;const o=s===exports.ChromecastState.CONNECTED,l=a.isNonNullable(this.connection$.getValue());if(o&&!l){const d=r.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(s===exports.ChromecastState.CONNECTED?a.isNonNullable(this.connection$.getValue())?exports.ChromecastState.CONNECTED:exports.ChromecastState.AVAILABLE:s)}))}initializeCastApi(){var e;let t,r,s;try{t=cast.framework.CastContext.getInstance(),r=chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,s=chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}catch(n){return}try{t.setOptions({receiverApplicationId:(e=this.params.receiverApplicationId)!==null&&e!==void 0?e:r,autoJoinPolicy:s}),this.initListeners()}catch(n){this.errorEvent$.next({id:"ChromecastInitializer",category:a.ErrorCategory.EXTERNAL_API,message:"[initializeCastApi] failed",thrown:n})}}}const zu=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 Lr=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function or(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Te=function(i){try{return!!i()}catch(e){return!0}},Qu=Te,lr=!Qu(function(){var i=function(){}.bind();return typeof i!="function"||i.hasOwnProperty("prototype")}),Vo=lr,Fo=Function.prototype,Rs=Fo.call,Ku=Vo&&Fo.bind.bind(Rs,Rs),Ee=Vo?Ku:function(i){return function(){return Rs.apply(i,arguments)}},Uo=Ee,Ju=Uo({}.toString),Xu=Uo("".slice),di=function(i){return Xu(Ju(i),8,-1)},Zu=Ee,ec=Te,tc=di,xr=Object,ic=Zu("".split),rc=ec(function(){return!xr("z").propertyIsEnumerable(0)})?function(i){return tc(i)=="String"?ic(i,""):xr(i)}:xr,hi=function(i){return i==null},sc=hi,ac=TypeError,ra=function(i){if(sc(i))throw ac("Can't call method on "+i);return i},nc=rc,oc=ra,fi=function(i){return nc(oc(i))},Gt={},Ai=function(i){return i&&i.Math==Math&&i},ne=Ai(typeof globalThis=="object"&&globalThis)||Ai(typeof window=="object"&&window)||Ai(typeof self=="object"&&self)||Ai(typeof Lr=="object"&&Lr)||function(){return this}()||Lr||Function("return this")(),_s=typeof document=="object"&&document.all,lc=typeof _s=="undefined"&&_s!==void 0,jo={all:_s,IS_HTMLDDA:lc},Ho=jo,uc=Ho.all,ie=Ho.IS_HTMLDDA?function(i){return typeof i=="function"||i===uc}:function(i){return typeof i=="function"},cc=ne,dc=ie,qa=cc.WeakMap,hc=dc(qa)&&/native code/.test(String(qa)),Wa=ie,Go=jo,fc=Go.all,Ye=Go.IS_HTMLDDA?function(i){return typeof i=="object"?i!==null:Wa(i)||i===fc}:function(i){return typeof i=="object"?i!==null:Wa(i)},pc=Te,Ze=!pc(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),pt={},mc=ne,za=Ye,Ds=mc.document,vc=za(Ds)&&za(Ds.createElement),sa=function(i){return vc?Ds.createElement(i):{}},bc=Ze,Sc=Te,gc=sa,Yo=!bc&&!Sc(function(){return Object.defineProperty(gc("div"),"a",{get:function(){return 7}}).a!=7}),yc=Ze,Tc=Te,qo=yc&&Tc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),Ec=Ye,$c=String,kc=TypeError,qe=function(i){if(Ec(i))return i;throw kc($c(i)+" is not an object")},wc=lr,Ci=Function.prototype.call,me=wc?Ci.bind(Ci):function(){return Ci.apply(Ci,arguments)},aa={},Nr=aa,Or=ne,Pc=ie,Qa=function(i){return Pc(i)?i:void 0},mt=function(i,e){return arguments.length<2?Qa(Nr[i])||Qa(Or[i]):Nr[i]&&Nr[i][e]||Or[i]&&Or[i][e]},Ac=Ee,ur=Ac({}.isPrototypeOf),cr=typeof navigator!="undefined"&&String(navigator.userAgent)||"",Wo=ne,Mr=cr,Ka=Wo.process,Ja=Wo.Deno,Xa=Ka&&Ka.versions||Ja&&Ja.version,Za=Xa&&Xa.v8,we,Xi;Za&&(we=Za.split("."),Xi=we[0]>0&&we[0]<4?1:+(we[0]+we[1]));!Xi&&Mr&&(we=Mr.match(/Edge\/(\d+)/),(!we||we[1]>=74)&&(we=Mr.match(/Chrome\/(\d+)/),we&&(Xi=+we[1])));var zo=Xi,en=zo,Cc=Te,Ic=ne,Rc=Ic.String,Qo=!!Object.getOwnPropertySymbols&&!Cc(function(){var i=Symbol();return!Rc(i)||!(Object(i)instanceof Symbol)||!Symbol.sham&&en&&en<41}),_c=Qo,Ko=_c&&!Symbol.sham&&typeof Symbol.iterator=="symbol",Dc=mt,Lc=ie,xc=ur,Nc=Ko,Oc=Object,Jo=Nc?function(i){return typeof i=="symbol"}:function(i){var e=Dc("Symbol");return Lc(e)&&xc(e.prototype,Oc(i))},Mc=String,dr=function(i){try{return Mc(i)}catch(e){return"Object"}},Bc=ie,Vc=dr,Fc=TypeError,vt=function(i){if(Bc(i))return i;throw Fc(Vc(i)+" is not a function")},Uc=vt,jc=hi,hr=function(i,e){var t=i[e];return jc(t)?void 0:Uc(t)},Br=me,Vr=ie,Fr=Ye,Hc=TypeError,Gc=function(i,e){var t,r;if(e==="string"&&Vr(t=i.toString)&&!Fr(r=Br(t,i))||Vr(t=i.valueOf)&&!Fr(r=Br(t,i))||e!=="string"&&Vr(t=i.toString)&&!Fr(r=Br(t,i)))return r;throw Hc("Can't convert object to primitive value")},Xo={exports:{}},Yc=!0,tn=ne,qc=Object.defineProperty,Wc=function(i,e){try{qc(tn,i,{value:e,configurable:!0,writable:!0})}catch(t){tn[i]=e}return e},zc=ne,Qc=Wc,rn="__core-js_shared__",Kc=zc[rn]||Qc(rn,{}),na=Kc,sn=na;(Xo.exports=function(i,e){return sn[i]||(sn[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 Zo=Xo.exports,Jc=ra,Xc=Object,fr=function(i){return Xc(Jc(i))},Zc=Ee,ed=fr,td=Zc({}.hasOwnProperty),Me=Object.hasOwn||function(e,t){return td(ed(e),t)},id=Ee,rd=0,sd=Math.random(),ad=id(1 .toString),el=function(i){return"Symbol("+(i===void 0?"":i)+")_"+ad(++rd+sd,36)},nd=ne,od=Zo,an=Me,ld=el,ud=Qo,cd=Ko,Nt=nd.Symbol,Ur=od("wks"),dd=cd?Nt.for||Nt:Nt&&Nt.withoutSetter||ld,ce=function(i){return an(Ur,i)||(Ur[i]=ud&&an(Nt,i)?Nt[i]:dd("Symbol."+i)),Ur[i]},hd=me,nn=Ye,on=Jo,fd=hr,pd=Gc,md=ce,vd=TypeError,bd=md("toPrimitive"),Sd=function(i,e){if(!nn(i)||on(i))return i;var t=fd(i,bd),r;if(t){if(e===void 0&&(e="default"),r=hd(t,i,e),!nn(r)||on(r))return r;throw vd("Can't convert object to primitive value")}return e===void 0&&(e="number"),pd(i,e)},gd=Sd,yd=Jo,oa=function(i){var e=gd(i,"string");return yd(e)?e:e+""},Td=Ze,Ed=Yo,$d=qo,Ii=qe,ln=oa,kd=TypeError,jr=Object.defineProperty,wd=Object.getOwnPropertyDescriptor,Hr="enumerable",Gr="configurable",Yr="writable";pt.f=Td?$d?function(e,t,r){if(Ii(e),t=ln(t),Ii(r),typeof e=="function"&&t==="prototype"&&"value"in r&&Yr in r&&!r[Yr]){var s=wd(e,t);s&&s[Yr]&&(e[t]=r.value,r={configurable:Gr in r?r[Gr]:s[Gr],enumerable:Hr in r?r[Hr]:s[Hr],writable:!1})}return jr(e,t,r)}:jr:function(e,t,r){if(Ii(e),t=ln(t),Ii(r),Ed)try{return jr(e,t,r)}catch(s){}if("get"in r||"set"in r)throw kd("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var pr=function(i,e){return{enumerable:!(i&1),configurable:!(i&2),writable:!(i&4),value:e}},Pd=Ze,Ad=pt,Cd=pr,pi=Pd?function(i,e,t){return Ad.f(i,e,Cd(1,t))}:function(i,e,t){return i[e]=t,i},Id=Zo,Rd=el,un=Id("keys"),la=function(i){return un[i]||(un[i]=Rd(i))},ua={},_d=hc,tl=ne,Dd=Ye,Ld=pi,qr=Me,Wr=na,xd=la,Nd=ua,cn="Object already initialized",Ls=tl.TypeError,Od=tl.WeakMap,Zi,oi,er,Md=function(i){return er(i)?oi(i):Zi(i,{})},Bd=function(i){return function(e){var t;if(!Dd(e)||(t=oi(e)).type!==i)throw Ls("Incompatible receiver, "+i+" required");return t}};if(_d||Wr.state){var Re=Wr.state||(Wr.state=new Od);Re.get=Re.get,Re.has=Re.has,Re.set=Re.set,Zi=function(i,e){if(Re.has(i))throw Ls(cn);return e.facade=i,Re.set(i,e),e},oi=function(i){return Re.get(i)||{}},er=function(i){return Re.has(i)}}else{var Ct=xd("state");Nd[Ct]=!0,Zi=function(i,e){if(qr(i,Ct))throw Ls(cn);return e.facade=i,Ld(i,Ct,e),e},oi=function(i){return qr(i,Ct)?i[Ct]:{}},er=function(i){return qr(i,Ct)}}var il={set:Zi,get:oi,has:er,enforce:Md,getterFor:Bd},Vd=lr,rl=Function.prototype,dn=rl.apply,hn=rl.call,sl=typeof Reflect=="object"&&Reflect.apply||(Vd?hn.bind(dn):function(){return hn.apply(dn,arguments)}),Fd=di,Ud=Ee,al=function(i){if(Fd(i)==="Function")return Ud(i)},ca={},nl={},ol={}.propertyIsEnumerable,ll=Object.getOwnPropertyDescriptor,jd=ll&&!ol.call({1:2},1);nl.f=jd?function(e){var t=ll(this,e);return!!t&&t.enumerable}:ol;var Hd=Ze,Gd=me,Yd=nl,qd=pr,Wd=fi,zd=oa,Qd=Me,Kd=Yo,fn=Object.getOwnPropertyDescriptor;ca.f=Hd?fn:function(e,t){if(e=Wd(e),t=zd(t),Kd)try{return fn(e,t)}catch(r){}if(Qd(e,t))return qd(!Gd(Yd.f,e,t),e[t])};var Jd=Te,Xd=ie,Zd=/#|\.prototype\./,mi=function(i,e){var t=th[eh(i)];return t==rh?!0:t==ih?!1:Xd(e)?Jd(e):!!e},eh=mi.normalize=function(i){return String(i).replace(Zd,".").toLowerCase()},th=mi.data={},ih=mi.NATIVE="N",rh=mi.POLYFILL="P",ul=mi,pn=al,sh=vt,ah=lr,nh=pn(pn.bind),mr=function(i,e){return sh(i),e===void 0?i:ah?nh(i,e):function(){return i.apply(e,arguments)}},Ri=ne,oh=sl,lh=al,uh=ie,ch=ca.f,dh=ul,It=aa,hh=mr,Rt=pi,mn=Me,fh=function(i){var e=function(t,r,s){if(this instanceof e){switch(arguments.length){case 0:return new i;case 1:return new i(t);case 2:return new i(t,r)}return new i(t,r,s)}return oh(i,this,arguments)};return e.prototype=i.prototype,e},Ae=function(i,e){var t=i.target,r=i.global,s=i.stat,n=i.proto,o=r?Ri:s?Ri[t]:(Ri[t]||{}).prototype,l=r?It:It[t]||Rt(It,t,{})[t],d=l.prototype,u,c,h,f,p,v,m,b,S;for(f in e)u=dh(r?f:t+(s?".":"#")+f,i.forced),c=!u&&o&&mn(o,f),v=l[f],c&&(i.dontCallGetSet?(S=ch(o,f),m=S&&S.value):m=o[f]),p=c&&m?m:e[f],!(c&&typeof v==typeof p)&&(i.bind&&c?b=hh(p,Ri):i.wrap&&c?b=fh(p):n&&uh(p)?b=lh(p):b=p,(i.sham||p&&p.sham||v&&v.sham)&&Rt(b,"sham",!0),Rt(l,f,b),n&&(h=t+"Prototype",mn(It,h)||Rt(It,h,{}),Rt(It[h],f,p),i.real&&d&&(u||!d[f])&&Rt(d,f,p)))},xs=Ze,ph=Me,cl=Function.prototype,mh=xs&&Object.getOwnPropertyDescriptor,da=ph(cl,"name"),vh=da&&function(){}.name==="something",bh=da&&(!xs||xs&&mh(cl,"name").configurable),Sh={EXISTS:da,PROPER:vh,CONFIGURABLE:bh},dl={},gh=Math.ceil,yh=Math.floor,Th=Math.trunc||function(e){var t=+e;return(t>0?yh:gh)(t)},Eh=Th,ha=function(i){var e=+i;return e!==e||e===0?0:Eh(e)},$h=ha,kh=Math.max,wh=Math.min,Ph=function(i,e){var t=$h(i);return t<0?kh(t+e,0):wh(t,e)},Ah=ha,Ch=Math.min,Ih=function(i){return i>0?Ch(Ah(i),9007199254740991):0},Rh=Ih,fa=function(i){return Rh(i.length)},_h=fi,Dh=Ph,Lh=fa,vn=function(i){return function(e,t,r){var s=_h(e),n=Lh(s),o=Dh(r,n),l;if(i&&t!=t){for(;n>o;)if(l=s[o++],l!=l)return!0}else for(;n>o;o++)if((i||o in s)&&s[o]===t)return i||o||0;return!i&&-1}},xh={includes:vn(!0),indexOf:vn(!1)},Nh=Ee,zr=Me,Oh=fi,Mh=xh.indexOf,Bh=ua,bn=Nh([].push),Vh=function(i,e){var t=Oh(i),r=0,s=[],n;for(n in t)!zr(Bh,n)&&zr(t,n)&&bn(s,n);for(;e.length>r;)zr(t,n=e[r++])&&(~Mh(s,n)||bn(s,n));return s},hl=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Fh=Vh,Uh=hl,jh=Object.keys||function(e){return Fh(e,Uh)},Hh=Ze,Gh=qo,Yh=pt,qh=qe,Wh=fi,zh=jh;dl.f=Hh&&!Gh?Object.defineProperties:function(e,t){qh(e);for(var r=Wh(t),s=zh(t),n=s.length,o=0,l;n>o;)Yh.f(e,l=s[o++],r[l]);return e};var Qh=mt,fl=Qh("document","documentElement"),Kh=qe,Jh=dl,Sn=hl,Xh=ua,Zh=fl,ef=sa,tf=la,gn=">",yn="<",Ns="prototype",Os="script",pl=tf("IE_PROTO"),Qr=function(){},ml=function(i){return yn+Os+gn+i+yn+"/"+Os+gn},Tn=function(i){i.write(ml("")),i.close();var e=i.parentWindow.Object;return i=null,e},rf=function(){var i=ef("iframe"),e="java"+Os+":",t;return i.style.display="none",Zh.appendChild(i),i.src=String(e),t=i.contentWindow.document,t.open(),t.write(ml("document.F=Object")),t.close(),t.F},_i,zi=function(){try{_i=new ActiveXObject("htmlfile")}catch(e){}zi=typeof document!="undefined"?document.domain&&_i?Tn(_i):rf():Tn(_i);for(var i=Sn.length;i--;)delete zi[Ns][Sn[i]];return zi()};Xh[pl]=!0;var vl=Object.create||function(e,t){var r;return e!==null?(Qr[Ns]=Kh(e),r=new Qr,Qr[Ns]=null,r[pl]=e):r=zi(),t===void 0?r:Jh.f(r,t)},sf=Te,af=!sf(function(){function i(){}return i.prototype.constructor=null,Object.getPrototypeOf(new i)!==i.prototype}),nf=Me,of=ie,lf=fr,uf=la,cf=af,En=uf("IE_PROTO"),Ms=Object,df=Ms.prototype,bl=cf?Ms.getPrototypeOf:function(i){var e=lf(i);if(nf(e,En))return e[En];var t=e.constructor;return of(t)&&e instanceof t?t.prototype:e instanceof Ms?df:null},hf=pi,pa=function(i,e,t,r){return r&&r.enumerable?i[e]=t:hf(i,e,t),i},ff=Te,pf=ie,mf=Ye,vf=vl,$n=bl,bf=pa,Sf=ce,Bs=Sf("iterator"),Sl=!1,je,Kr,Jr;[].keys&&(Jr=[].keys(),"next"in Jr?(Kr=$n($n(Jr)),Kr!==Object.prototype&&(je=Kr)):Sl=!0);var gf=!mf(je)||ff(function(){var i={};return je[Bs].call(i)!==i});gf?je={}:je=vf(je);pf(je[Bs])||bf(je,Bs,function(){return this});var gl={IteratorPrototype:je,BUGGY_SAFARI_ITERATORS:Sl},yf=ce,Tf=yf("toStringTag"),yl={};yl[Tf]="z";var ma=String(yl)==="[object z]",Ef=ma,$f=ie,Qi=di,kf=ce,wf=kf("toStringTag"),Pf=Object,Af=Qi(function(){return arguments}())=="Arguments",Cf=function(i,e){try{return i[e]}catch(t){}},vi=Ef?Qi:function(i){var e,t,r;return i===void 0?"Undefined":i===null?"Null":typeof(t=Cf(e=Pf(i),wf))=="string"?t:Af?Qi(e):(r=Qi(e))=="Object"&&$f(e.callee)?"Arguments":r},If=ma,Rf=vi,_f=If?{}.toString:function(){return"[object "+Rf(this)+"]"},Df=ma,Lf=pt.f,xf=pi,Nf=Me,Of=_f,Mf=ce,kn=Mf("toStringTag"),va=function(i,e,t,r){if(i){var s=t?i:i.prototype;Nf(s,kn)||Lf(s,kn,{configurable:!0,value:e}),r&&!Df&&xf(s,"toString",Of)}},Bf=gl.IteratorPrototype,Vf=vl,Ff=pr,Uf=va,jf=Gt,Hf=function(){return this},Gf=function(i,e,t,r){var s=e+" Iterator";return i.prototype=Vf(Bf,{next:Ff(+!r,t)}),Uf(i,s,!1,!0),jf[s]=Hf,i},Yf=Ae,qf=me,Tl=Sh,Wf=Gf,zf=bl,Qf=va,wn=pa,Kf=ce,Pn=Gt,El=gl,Jf=Tl.PROPER;Tl.CONFIGURABLE;El.IteratorPrototype;var Di=El.BUGGY_SAFARI_ITERATORS,Xr=Kf("iterator"),An="keys",Li="values",Cn="entries",Xf=function(){return this},Zf=function(i,e,t,r,s,n,o){Wf(t,e,r);var l=function(S){if(S===s&&f)return f;if(!Di&&S in c)return c[S];switch(S){case An:return function(){return new t(this,S)};case Li:return function(){return new t(this,S)};case Cn:return function(){return new t(this,S)}}return function(){return new t(this)}},d=e+" Iterator",u=!1,c=i.prototype,h=c[Xr]||c["@@iterator"]||s&&c[s],f=!Di&&h||l(s),p=e=="Array"&&c.entries||h,v,m,b;if(p&&(v=zf(p.call(new i)),v!==Object.prototype&&v.next&&(Qf(v,d,!0,!0),Pn[d]=Xf)),Jf&&s==Li&&h&&h.name!==Li&&(u=!0,f=function(){return qf(h,this)}),s)if(m={values:l(Li),keys:n?f:l(An),entries:l(Cn)},o)for(b in m)(Di||u||!(b in c))&&wn(c,b,m[b]);else Yf({target:e,proto:!0,forced:Di||u},m);return o&&c[Xr]!==f&&wn(c,Xr,f,{name:s}),Pn[e]=f,m},ep=function(i,e){return{value:i,done:e}},tp=fi,In=Gt,$l=il;pt.f;var ip=Zf,xi=ep,kl="Array Iterator",rp=$l.set,sp=$l.getterFor(kl);ip(Array,"Array",function(i,e){rp(this,{type:kl,target:tp(i),index:0,kind:e})},function(){var i=sp(this),e=i.target,t=i.kind,r=i.index++;return!e||r>=e.length?(i.target=void 0,xi(void 0,!0)):t=="keys"?xi(r,!1):t=="values"?xi(e[r],!1):xi([r,e[r]],!1)},"values");In.Arguments=In.Array;var ap=ce,np=Gt,op=ap("iterator"),lp=Array.prototype,up=function(i){return i!==void 0&&(np.Array===i||lp[op]===i)},cp=vi,Rn=hr,dp=hi,hp=Gt,fp=ce,pp=fp("iterator"),wl=function(i){if(!dp(i))return Rn(i,pp)||Rn(i,"@@iterator")||hp[cp(i)]},mp=me,vp=vt,bp=qe,Sp=dr,gp=wl,yp=TypeError,Tp=function(i,e){var t=arguments.length<2?gp(i):e;if(vp(t))return bp(mp(t,i));throw yp(Sp(i)+" is not iterable")},Ep=me,_n=qe,$p=hr,kp=function(i,e,t){var r,s;_n(i);try{if(r=$p(i,"return"),!r){if(e==="throw")throw t;return t}r=Ep(r,i)}catch(n){s=!0,r=n}if(e==="throw")throw t;if(s)throw r;return _n(r),t},wp=mr,Pp=me,Ap=qe,Cp=dr,Ip=up,Rp=fa,Dn=ur,_p=Tp,Dp=wl,Ln=kp,Lp=TypeError,Ki=function(i,e){this.stopped=i,this.result=e},xn=Ki.prototype,ba=function(i,e,t){var r=t&&t.that,s=!!(t&&t.AS_ENTRIES),n=!!(t&&t.IS_RECORD),o=!!(t&&t.IS_ITERATOR),l=!!(t&&t.INTERRUPTED),d=wp(e,r),u,c,h,f,p,v,m,b=function(y){return u&&Ln(u,"normal",y),new Ki(!0,y)},S=function(y){return s?(Ap(y),l?d(y[0],y[1],b):d(y[0],y[1])):l?d(y,b):d(y)};if(n)u=i.iterator;else if(o)u=i;else{if(c=Dp(i),!c)throw Lp(Cp(i)+" is not iterable");if(Ip(c)){for(h=0,f=Rp(i);f>h;h++)if(p=S(i[h]),p&&Dn(xn,p))return p;return new Ki(!1)}u=_p(i,c)}for(v=n?i.next:u.next;!(m=Pp(v,u)).done;){try{p=S(m.value)}catch(y){Ln(u,"throw",y)}if(typeof p=="object"&&p&&Dn(xn,p))return p}return new Ki(!1)},xp=oa,Np=pt,Op=pr,Mp=function(i,e,t){var r=xp(e);r in i?Np.f(i,r,Op(0,t)):i[r]=t},Bp=Ae,Vp=ba,Fp=Mp;Bp({target:"Object",stat:!0},{fromEntries:function(e){var t={};return Vp(e,function(r,s){Fp(t,r,s)},{AS_ENTRIES:!0}),t}});var Up=aa,jp=Up.Object.fromEntries,Hp={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},Gp=Hp,Yp=ne,qp=vi,Wp=pi,Nn=Gt,zp=ce,On=zp("toStringTag");for(var Zr in Gp){var Mn=Yp[Zr],es=Mn&&Mn.prototype;es&&qp(es)!==On&&Wp(es,On,Zr),Nn[Zr]=Nn.Array}var Qp=jp,Kp=Qp,Jp=Kp,Xp=Jp,tr=or(Xp),Zp=di,vr=typeof process!="undefined"&&Zp(process)=="process",em=pt,tm=function(i,e,t){return em.f(i,e,t)},im=mt,rm=tm,sm=ce,am=Ze,Bn=sm("species"),nm=function(i){var e=im(i);am&&e&&!e[Bn]&&rm(e,Bn,{configurable:!0,get:function(){return this}})},om=ur,lm=TypeError,um=function(i,e){if(om(e,i))return i;throw lm("Incorrect invocation")},cm=Ee,dm=ie,Vs=na,hm=cm(Function.toString);dm(Vs.inspectSource)||(Vs.inspectSource=function(i){return hm(i)});var Pl=Vs.inspectSource,fm=Ee,pm=Te,Al=ie,mm=vi,vm=mt,bm=Pl,Cl=function(){},Sm=[],Il=vm("Reflect","construct"),Sa=/^\s*(?:class|function)\b/,gm=fm(Sa.exec),ym=!Sa.exec(Cl),Zt=function(e){if(!Al(e))return!1;try{return Il(Cl,Sm,e),!0}catch(t){return!1}},Rl=function(e){if(!Al(e))return!1;switch(mm(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return ym||!!gm(Sa,bm(e))}catch(t){return!0}};Rl.sham=!0;var Tm=!Il||pm(function(){var i;return Zt(Zt.call)||!Zt(Object)||!Zt(function(){i=!0})||i})?Rl:Zt,Em=Tm,$m=dr,km=TypeError,wm=function(i){if(Em(i))return i;throw km($m(i)+" is not a constructor")},Vn=qe,Pm=wm,Am=hi,Cm=ce,Im=Cm("species"),_l=function(i,e){var t=Vn(i).constructor,r;return t===void 0||Am(r=Vn(t)[Im])?e:Pm(r)},Rm=Ee,_m=Rm([].slice),Dm=TypeError,Lm=function(i,e){if(i<e)throw Dm("Not enough arguments");return i},xm=cr,Dl=/(?:ipad|iphone|ipod).*applewebkit/i.test(xm),pe=ne,Nm=sl,Om=mr,Fn=ie,Mm=Me,Ll=Te,Un=fl,Bm=_m,jn=sa,Vm=Lm,Fm=Dl,Um=vr,Fs=pe.setImmediate,Us=pe.clearImmediate,jm=pe.process,ts=pe.Dispatch,Hm=pe.Function,Hn=pe.MessageChannel,Gm=pe.String,is=0,si={},Gn="onreadystatechange",li,nt,rs,ss;Ll(function(){li=pe.location});var ga=function(i){if(Mm(si,i)){var e=si[i];delete si[i],e()}},as=function(i){return function(){ga(i)}},Yn=function(i){ga(i.data)},qn=function(i){pe.postMessage(Gm(i),li.protocol+"//"+li.host)};(!Fs||!Us)&&(Fs=function(e){Vm(arguments.length,1);var t=Fn(e)?e:Hm(e),r=Bm(arguments,1);return si[++is]=function(){Nm(t,void 0,r)},nt(is),is},Us=function(e){delete si[e]},Um?nt=function(i){jm.nextTick(as(i))}:ts&&ts.now?nt=function(i){ts.now(as(i))}:Hn&&!Fm?(rs=new Hn,ss=rs.port2,rs.port1.onmessage=Yn,nt=Om(ss.postMessage,ss)):pe.addEventListener&&Fn(pe.postMessage)&&!pe.importScripts&&li&&li.protocol!=="file:"&&!Ll(qn)?(nt=qn,pe.addEventListener("message",Yn,!1)):Gn in jn("script")?nt=function(i){Un.appendChild(jn("script"))[Gn]=function(){Un.removeChild(this),ga(i)}}:nt=function(i){setTimeout(as(i),0)});var xl={set:Fs,clear:Us},Nl=function(){this.head=null,this.tail=null};Nl.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 Ol=Nl,Ym=cr,qm=/ipad|iphone|ipod/i.test(Ym)&&typeof Pebble!="undefined",Wm=cr,zm=/web0s(?!.*chrome)/i.test(Wm),ht=ne,Wn=mr,Qm=ca.f,ns=xl.set,Km=Ol,Jm=Dl,Xm=qm,Zm=zm,os=vr,zn=ht.MutationObserver||ht.WebKitMutationObserver,Qn=ht.document,Kn=ht.process,Ni=ht.Promise,Jn=Qm(ht,"queueMicrotask"),js=Jn&&Jn.value,_t,ls,us,Oi,Xn;if(!js){var Mi=new Km,Bi=function(){var i,e;for(os&&(i=Kn.domain)&&i.exit();e=Mi.get();)try{e()}catch(t){throw Mi.head&&_t(),t}i&&i.enter()};!Jm&&!os&&!Zm&&zn&&Qn?(ls=!0,us=Qn.createTextNode(""),new zn(Bi).observe(us,{characterData:!0}),_t=function(){us.data=ls=!ls}):!Xm&&Ni&&Ni.resolve?(Oi=Ni.resolve(void 0),Oi.constructor=Ni,Xn=Wn(Oi.then,Oi),_t=function(){Xn(Bi)}):os?_t=function(){Kn.nextTick(Bi)}:(ns=Wn(ns,ht),_t=function(){ns(Bi)}),js=function(i){Mi.head||_t(),Mi.add(i)}}var ev=js,tv=function(i,e){try{arguments.length==1?console.error(i):console.error(i,e)}catch(t){}},ya=function(i){try{return{error:!1,value:i()}}catch(e){return{error:!0,value:e}}},iv=ne,Yt=iv.Promise,Ml=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",rv=Ml,sv=vr,av=!rv&&!sv&&typeof window=="object"&&typeof document=="object",nv=ne,ai=Yt,ov=ie,lv=ul,uv=Pl,cv=ce,dv=av,hv=Ml,cs=zo,Zn=ai&&ai.prototype,fv=cv("species"),Hs=!1,Bl=ov(nv.PromiseRejectionEvent),pv=lv("Promise",function(){var i=uv(ai),e=i!==String(ai);if(!e&&cs===66||!(Zn.catch&&Zn.finally))return!0;if(!cs||cs<51||!/native code/.test(i)){var t=new ai(function(n){n(1)}),r=function(n){n(function(){},function(){})},s=t.constructor={};if(s[fv]=r,Hs=t.then(function(){})instanceof r,!Hs)return!0}return!e&&(dv||hv)&&!Bl}),bi={CONSTRUCTOR:pv,REJECTION_EVENT:Bl,SUBCLASSING:Hs},qt={},eo=vt,mv=TypeError,vv=function(i){var e,t;this.promise=new i(function(r,s){if(e!==void 0||t!==void 0)throw mv("Bad Promise constructor");e=r,t=s}),this.resolve=eo(e),this.reject=eo(t)};qt.f=function(i){return new vv(i)};var bv=Ae,ir=vr,Xe=ne,Si=me,Sv=pa,gv=va,yv=nm,Tv=vt,Gs=ie,Ev=Ye,$v=um,kv=_l,Vl=xl.set,Ta=ev,wv=tv,Pv=ya,Av=Ol,Fl=il,Ys=Yt,Ea=bi,Ul=qt,br="Promise",jl=Ea.CONSTRUCTOR,Cv=Ea.REJECTION_EVENT;Ea.SUBCLASSING;var ds=Fl.getterFor(br),Iv=Fl.set,Rv=Ys&&Ys.prototype,Ot=Ys,hs=Rv,Hl=Xe.TypeError,qs=Xe.document,$a=Xe.process,Ws=Ul.f,_v=Ws,Dv=!!(qs&&qs.createEvent&&Xe.dispatchEvent),Gl="unhandledrejection",Lv="rejectionhandled",to=0,Yl=1,xv=2,ka=1,ql=2,Vi,io,Nv,Wl=function(i){var e;return Ev(i)&&Gs(e=i.then)?e:!1},zl=function(i,e){var t=e.value,r=e.state==Yl,s=r?i.ok:i.fail,n=i.resolve,o=i.reject,l=i.domain,d,u,c;try{s?(r||(e.rejection===ql&&Mv(e),e.rejection=ka),s===!0?d=t:(l&&l.enter(),d=s(t),l&&(l.exit(),c=!0)),d===i.promise?o(Hl("Promise-chain cycle")):(u=Wl(d))?Si(u,d,n,o):n(d)):o(t)}catch(h){l&&!c&&l.exit(),o(h)}},Ql=function(i,e){i.notified||(i.notified=!0,Ta(function(){for(var t=i.reactions,r;r=t.get();)zl(r,i);i.notified=!1,e&&!i.rejection&&Ov(i)}))},Kl=function(i,e,t){var r,s;Dv?(r=qs.createEvent("Event"),r.promise=e,r.reason=t,r.initEvent(i,!1,!0),Xe.dispatchEvent(r)):r={promise:e,reason:t},!Cv&&(s=Xe["on"+i])?s(r):i===Gl&&wv("Unhandled promise rejection",t)},Ov=function(i){Si(Vl,Xe,function(){var e=i.facade,t=i.value,r=ro(i),s;if(r&&(s=Pv(function(){ir?$a.emit("unhandledRejection",t,e):Kl(Gl,e,t)}),i.rejection=ir||ro(i)?ql:ka,s.error))throw s.value})},ro=function(i){return i.rejection!==ka&&!i.parent},Mv=function(i){Si(Vl,Xe,function(){var e=i.facade;ir?$a.emit("rejectionHandled",e):Kl(Lv,e,i.value)})},Mt=function(i,e,t){return function(r){i(e,r,t)}},Ft=function(i,e,t){i.done||(i.done=!0,t&&(i=t),i.value=e,i.state=xv,Ql(i,!0))},zs=function(i,e,t){if(!i.done){i.done=!0,t&&(i=t);try{if(i.facade===e)throw Hl("Promise can't be resolved itself");var r=Wl(e);r?Ta(function(){var s={done:!1};try{Si(r,e,Mt(zs,s,i),Mt(Ft,s,i))}catch(n){Ft(s,n,i)}}):(i.value=e,i.state=Yl,Ql(i,!1))}catch(s){Ft({done:!1},s,i)}}};jl&&(Ot=function(e){$v(this,hs),Tv(e),Si(Vi,this);var t=ds(this);try{e(Mt(zs,t),Mt(Ft,t))}catch(r){Ft(t,r)}},hs=Ot.prototype,Vi=function(e){Iv(this,{type:br,done:!1,notified:!1,parent:!1,reactions:new Av,rejection:!1,state:to,value:void 0})},Vi.prototype=Sv(hs,"then",function(e,t){var r=ds(this),s=Ws(kv(this,Ot));return r.parent=!0,s.ok=Gs(e)?e:!0,s.fail=Gs(t)&&t,s.domain=ir?$a.domain:void 0,r.state==to?r.reactions.add(s):Ta(function(){zl(s,r)}),s.promise}),io=function(){var i=new Vi,e=ds(i);this.promise=i,this.resolve=Mt(zs,e),this.reject=Mt(Ft,e)},Ul.f=Ws=function(i){return i===Ot||i===Nv?new io(i):_v(i)});bv({global:!0,constructor:!0,wrap:!0,forced:jl},{Promise:Ot});gv(Ot,br,!1,!0);yv(br);var Bv=ce,Jl=Bv("iterator"),Xl=!1;try{var Vv=0,so={next:function(){return{done:!!Vv++}},return:function(){Xl=!0}};so[Jl]=function(){return this},Array.from(so,function(){throw 2})}catch(i){}var Fv=function(i,e){if(!e&&!Xl)return!1;var t=!1;try{var r={};r[Jl]=function(){return{next:function(){return{done:t=!0}}}},i(r)}catch(s){}return t},Uv=Yt,jv=Fv,Hv=bi.CONSTRUCTOR,Zl=Hv||!jv(function(i){Uv.all(i).then(void 0,function(){})}),Gv=Ae,Yv=me,qv=vt,Wv=qt,zv=ya,Qv=ba,Kv=Zl;Gv({target:"Promise",stat:!0,forced:Kv},{all:function(e){var t=this,r=Wv.f(t),s=r.resolve,n=r.reject,o=zv(function(){var l=qv(t.resolve),d=[],u=0,c=1;Qv(e,function(h){var f=u++,p=!1;c++,Yv(l,t,h).then(function(v){p||(p=!0,d[f]=v,--c||s(d))},n)}),--c||s(d)});return o.error&&n(o.value),r.promise}});var Jv=Ae,Xv=bi.CONSTRUCTOR,ao=Yt;ao&&ao.prototype;Jv({target:"Promise",proto:!0,forced:Xv,real:!0},{catch:function(i){return this.then(void 0,i)}});var Zv=Ae,eb=me,tb=vt,ib=qt,rb=ya,sb=ba,ab=Zl;Zv({target:"Promise",stat:!0,forced:ab},{race:function(e){var t=this,r=ib.f(t),s=r.reject,n=rb(function(){var o=tb(t.resolve);sb(e,function(l){eb(o,t,l).then(r.resolve,s)})});return n.error&&s(n.value),r.promise}});var nb=Ae,ob=me,lb=qt,ub=bi.CONSTRUCTOR;nb({target:"Promise",stat:!0,forced:ub},{reject:function(e){var t=lb.f(this);return ob(t.reject,void 0,e),t.promise}});var cb=qe,db=Ye,hb=qt,eu=function(i,e){if(cb(i),db(e)&&e.constructor===i)return e;var t=hb.f(i),r=t.resolve;return r(e),t.promise},fb=Ae,pb=mt,mb=Yc,vb=Yt,bb=bi.CONSTRUCTOR,Sb=eu,gb=pb("Promise"),yb=!bb;fb({target:"Promise",stat:!0,forced:mb},{resolve:function(e){return Sb(yb&&this===gb?vb:this,e)}});var Tb=Ae,Qs=Yt,Eb=Te,$b=mt,kb=ie,wb=_l,no=eu,Pb=Qs&&Qs.prototype,Ab=!!Qs&&Eb(function(){Pb.finally.call({then:function(){}},function(){})});Tb({target:"Promise",proto:!0,real:!0,forced:Ab},{finally:function(i){var e=wb(this,$b("Promise")),t=kb(i);return this.then(t?function(r){return no(e,i()).then(function(){return r})}:i,t?function(r){return no(e,i()).then(function(){throw r})}:i)}});var Cb=mt,wa=Cb,Ib=wa,Rb=Ib("Promise","finally"),_b=Rb,Db=_b,Lb=Db,xb=Lb,Pa=or(xb),re;(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"})(re||(re={}));var Pe=(i,e=0,t=re.OFFSET_P)=>{switch(t){case re.OFFSET_P:return i.replace("_offset_p",e===0?"":"_"+e.toFixed(0));case re.PLAYBACK_SHIFT:{if(e===0)return i;const r=new URL(i);return r.searchParams.append("playback_shift",e.toFixed(0)),r.toString()}case re.DASH_CMAF_OFFSET_P:{const r=new URL(i);return!r.searchParams.get("offset_p")&&e===0?i:(r.searchParams.set("offset_p",e.toFixed(0)),r.toString())}default:a.assertNever(t)}return i};const oo=(i,e)=>{var t;switch(e){case re.OFFSET_P:return NaN;case re.PLAYBACK_SHIFT:{const r=new URL(i);return Number(r.searchParams.get("playback_shift"))}case re.DASH_CMAF_OFFSET_P:{const r=new URL(i);return Number((t=r.searchParams.get("offset_p"))!==null&&t!==void 0?t:0)}default:a.assertNever(e)}};var A=(i,e,t=!1)=>{const r=i.getTransition();(t||!r||r.to===e)&&i.setState(e)};class Z{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,r=this.state;this.transition=void 0,this.prevState=r,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:r,to:e,canceledTransition:t})}startTransitionTo(e){const t=this.transition,r=this.state;r===e||a.isNonNullable(t)&&t.to===e||(this.prevState=r,this.state=e,t?(this.transition={from:t.from,to:e,canceledTransition:t},this.transitionUpdated$.next(this.transition)):(this.transition={from:r,to:e},this.transitionStarted$.next(this.transition)))}getTransition(){return this.transition}getState(){return this.state}getPrevState(){return this.prevState}}const Nb=i=>{switch(i){case exports.VideoFormat.MPEG: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 D;(function(i){i.STOPPED="stopped",i.READY="ready",i.PLAYING="playing",i.PAUSED="paused"})(D||(D={}));const Ob=5,Mb=5,Bb=500,lo=7e3;class Vb{constructor(e){this.subscription=new a.Subscription,this.loadMediaTimeoutSubscription=new a.Subscription,this.videoState=new Z(D.STOPPED),this.syncPlayback=()=>{const r=this.videoState.getState(),s=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: ${r}; videoTransition: ${JSON.stringify(s)}; desiredPlaybackState: ${n}; desiredPlaybackStateTransition: ${this.params.desiredState.playbackState.getTransition()}; seekState: ${JSON.stringify(l)};`}),n===exports.PlaybackState.STOPPED){r!==D.STOPPED&&(this.videoState.startTransitionTo(D.STOPPED),this.stop());return}if(!s){if((o==null?void 0:o.to)!==exports.PlaybackState.PAUSED&&l.state===N.Requested&&r!==D.STOPPED){this.seek(l.position/1e3);return}switch(n){case exports.PlaybackState.READY:{switch(r){case D.PLAYING:case D.PAUSED:case D.READY:break;case D.STOPPED:this.videoState.startTransitionTo(D.READY),this.prepare();break;default:a.assertNever(r)}break}case exports.PlaybackState.PLAYING:{switch(r){case D.PLAYING:break;case D.PAUSED:this.videoState.startTransitionTo(D.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case D.READY:this.videoState.startTransitionTo(D.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case D.STOPPED:this.videoState.startTransitionTo(D.READY),this.prepare();break;default:a.assertNever(r)}break}case exports.PlaybackState.PAUSED:{switch(r){case D.PLAYING:this.videoState.startTransitionTo(D.PAUSED),this.params.connection.remotePlayerController.playOrPause();break;case D.PAUSED:break;case D.READY:this.videoState.startTransitionTo(D.PAUSED),this.videoState.setState(D.PAUSED);break;case D.STOPPED:this.videoState.startTransitionTo(D.READY),this.prepare();break;default:a.assertNever(r)}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(Nb(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(s=>`stateChangeStarted$ ${JSON.stringify(s)}`)),this.videoState.stateChangeEnded$.pipe(a.map(s=>`stateChangeEnded$ ${JSON.stringify(s)}`))).subscribe(s=>this.log({message:`[videoState] ${s}`})));const t=(s,n)=>this.subscription.add(s.subscribe(n));if(this.params.output.isLive$.getValue())this.params.output.position$.next(0),this.params.output.duration$.next(0);else{const s=new a.Subject;e.add(s.pipe(a.debounce(Bb)).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===N.Applying||Math.abs(l-n)>Ob)&&s.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),s=>{this.logRemoteEvent(s),s.value?this.handleRemoteReady():(this.handleRemoteStop(),e.unsubscribe())}),t(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),s=>{this.logRemoteEvent(s),s.value?this.handleRemotePause():this.handleRemotePlay()}),t(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED),s=>{this.logRemoteEvent(s);const{remotePlayer:n}=this.params.connection,o=s.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<Mb&&this.params.output.endedEvent$.next(),this.handleRemoteStop(),A(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),s=>{this.logRemoteEvent(s),this.handleRemoteVolumeChange({volume:s.value})}),t(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),s=>{this.logRemoteEvent(s),this.handleRemoteVolumeChange({muted:s.value})});const r=a.merge(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,a.observableFrom(["init"])).pipe(a.debounce(0));t(r,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(D.PAUSED),A(this.params.desiredState.playbackState,exports.PlaybackState.PAUSED)):(this.videoState.setState(D.PLAYING),A(this.params.desiredState.playbackState,exports.PlaybackState.PLAYING));const r=this.params.output.isLive$.getValue();this.params.output.duration$.next(r?0:t.duration),this.params.output.position$.next(r?0:t.currentTime),this.params.desiredState.seekState.setState({state:N.None})}}prepare(){const e=this.params.format;this.log({message:`[prepare] format: ${e}`});const t=this.createMediaInfo(e),r=this.createLoadRequest(t);this.loadMedia(r)}handleRemotePause(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===D.PAUSED||e===D.PLAYING)&&(this.videoState.setState(D.PAUSED),A(this.params.desiredState.playbackState,exports.PlaybackState.PAUSED))}handleRemotePlay(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===D.PLAYING||e===D.PAUSED)&&(this.videoState.setState(D.PLAYING),A(this.params.desiredState.playbackState,exports.PlaybackState.PLAYING))}handleRemoteReady(){var e;const t=this.videoState.getTransition();(t==null?void 0:t.to)===D.READY&&this.videoState.setState(D.READY),((e=this.params.desiredState.playbackState.getTransition())===null||e===void 0?void 0:e.to)===exports.PlaybackState.READY&&A(this.params.desiredState.playbackState,exports.PlaybackState.READY)}handleRemoteStop(){this.videoState.getState()!==D.STOPPED&&this.videoState.setState(D.STOPPED)}handleRemoteVolumeChange(e){var t,r;const s=this.params.output.volume$.getValue(),n={volume:(t=e.volume)!==null&&t!==void 0?t:s.volume,muted:(r=e.muted)!==null&&r!==void 0?r:s.muted};(n.volume!==s.volume||n.muted!==n.muted)&&this.params.output.volume$.next(n)}seek(e){this.params.output.willSeekEvent$.next();const{remotePlayer:t,remotePlayerController:r}=this.params.connection;t.currentTime=e,r.seek()}stop(){const{remotePlayerController:e}=this.params.connection;e.stop()}createMediaInfo(e){var t;const r=this.params.source;let s,n,o;switch(e){case exports.VideoFormat.MPEG:{const c=r[e];a.assertNonNullable(c);const h=a.getHighestQuality(Object.keys(c));a.assertNonNullable(h);const f=c[h];a.assertNonNullable(f),s=f,n="video/mp4",o=chrome.cast.media.StreamType.BUFFERED;break}case exports.VideoFormat.HLS:case exports.VideoFormat.HLS_ONDEMAND:{const c=r[e];a.assertNonNullable(c),s=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=r[e];a.assertNonNullable(c),s=c.url,n="application/dash+xml",o=chrome.cast.media.StreamType.BUFFERED;break}case exports.VideoFormat.DASH_LIVE_CMAF:{const c=r[e];a.assertNonNullable(c),s=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=r[e];a.assertNonNullable(c),s=Pe(c.url),n="application/x-mpegurl",o=chrome.cast.media.StreamType.LIVE;break}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:s,n);l.contentUrl=s,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 r=this.params.desiredState.seekState.getState();return r.state===N.Applying||r.state===N.Requested?t.currentTime=this.params.output.isLive$.getValue()?0:r.position/1e3:t.currentTime=0,t}loadMedia(e){const t=this.params.connection.session.loadMedia(e),r=new Promise((s,n)=>{this.loadMediaTimeoutSubscription.add(a.timeout(lo).subscribe(()=>n(`timeout(${lo})`)))});Pa(Promise.race([t,r]).then(()=>{this.log({message:`[loadMedia] completed, format: ${this.params.format}`}),this.params.desiredState.seekState.getState().state===N.Applying&&this.params.output.seekedEvent$.next(),this.handleRemoteReady()},s=>{const n=`[prepare] loadMedia failed, format: ${this.params.format}, reason: ${s}`;this.log({message:n}),this.params.output.error$.next({id:"ChromecastProvider.loadMedia",category:a.ErrorCategory.VIDEO_PIPELINE,message:n,thrown:s})}),()=>{this.loadMediaTimeoutSubscription.unsubscribe()})}logRemoteEvent(e){this.log({message:`[remoteEvent] ${JSON.stringify(e)}`})}}const Aa=i=>{i.removeAttribute("src"),i.load()},Fb=i=>{try{i.pause(),i.playbackRate=0,Aa(i),i.remove()}catch(e){console.error(e)}};class Ub{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 Ks=window.WeakMap?new WeakMap:new Ub,bt=i=>{let e=i.querySelector("video");const t=!!e;return e?Aa(e):(e=document.createElement("video"),i.appendChild(e)),Ks.set(e,t),e.setAttribute("crossorigin","anonymous"),e.setAttribute("playsinline","playsinline"),e.controls=!1,e.setAttribute("poster","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),e},St=i=>{const e=Ks.get(i);Ks.delete(i),e?Aa(i):Fb(i)},Fe=(i,e,t,{equal:r=(o,l)=>o===l,changed$:s,onError:n}={})=>{const o=i.getState(),l=e(),d=a.isNullable(s),u=new a.Subscription;return s&&u.add(s.subscribe(c=>{const h=i.getState();r(c,h)&&i.setState(c)},n)),r(l,o)||(t(o),d&&i.setState(o)),u.add(i.stateChangeStarted$.subscribe(c=>{t(c.to),d&&i.setState(c.to)},n)),u},gi=(i,e,t)=>Fe(e,()=>i.loop,r=>{a.isNonNullable(r)&&(i.loop=r)},{onError:t}),gt=(i,e,t,r)=>Fe(e,()=>({muted:i.muted,volume:i.volume}),s=>{a.isNonNullable(s)&&(i.muted=s.muted,i.volume=s.volume)},{equal:(s,n)=>s===n||(s==null?void 0:s.muted)===(n==null?void 0:n.muted)&&(s==null?void 0:s.volume)===(n==null?void 0:n.volume),changed$:t,onError:r}),Wt=(i,e,t,r)=>Fe(e,()=>i.playbackRate,s=>{a.isNonNullable(s)&&(i.playbackRate=s)},{changed$:t,onError:r}),jb=i=>["__",i.language,i.label].join("|"),Hb=(i,e)=>{if(i.id===e)return!0;const[t,r,s]=e.split("|");return i.language===r&&i.label===s};class et{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,r){this.video=e,this.cueSettings=t.textTrackCuesSettings,this.subscribe();const s=n=>{this.error$.next({id:"TextTracksManager",category:a.ErrorCategory.WTF,message:"Generic HtmlVideoTextTrackManager error",thrown:n})};this.subscription.add(this.available$.subscribe(r.availableTextTracks$)),this.subscription.add(this.current$.subscribe(r.currentTextTrack$)),this.subscription.add(this.error$.subscribe(r.error$)),this.subscription.add(Fe(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:s})),this.subscription.add(Fe(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:s})),this.subscription.add(Fe(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:s})),this.subscription.add(Fe(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 r=this.current$.getValue();r&&this.select(r)})),this.subscription.add(a.merge(a.fromEvent(e,"addtrack"),a.fromEvent(e,"removetrack"),a.observableFrom(["init"])).pipe(a.map(()=>this.htmlTextTracksAsArray().map(r=>this.htmlTextTrackToITextTrack(r))),a.filterChanged((r,s)=>r.length===s.length&&r.every(({id:n},o)=>n===s[o].id))).subscribe(this.available$)),this.subscription.add(a.merge(a.fromEvent(e,"change"),a.observableFrom(["init"])).pipe(a.map(()=>this.htmlTextTracksAsArray().find(({mode:r})=>r==="showing")),a.map(r=>r&&this.htmlTextTrackToITextTrack(r).id),a.filterChanged()).subscribe(this.current$));const t=r=>{var s,n;return this.applyCueSettings((n=(s=r.target)===null||s===void 0?void 0:s.activeCues)!==null&&n!==void 0?n:null)};this.subscription.add(a.fromEvent(e,"addtrack").subscribe(r=>{var s,n;(s=r.track)===null||s===void 0||s.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=r.track)===null||n===void 0||n.addEventListener("cuechange",o)})),this.subscription.add(a.fromEvent(e,"removetrack").subscribe(r=>{var s;(s=r.track)===null||s===void 0||s.removeEventListener("cuechange",t)}))}applyCueSettings(e){if(!e||!e.length)return;const t=this.cueSettings.getState();for(const r of Array.from(e)){const s=r;a.isNonNullable(t.align)&&(s.align=t.align),a.isNonNullable(t.position)&&(s.position=t.position),a.isNonNullable(t.size)&&(s.size=t.size),a.isNonNullable(t.line)&&(s.line=t.line)}}htmlTextTracksAsArray(e=!1){a.assertNonNullable(this.video);const t=[...this.video.textTracks];return e?t:t.filter(et.isHealthyTrack)}htmlTextTrackToITextTrack(e){var t,r;const{language:s,label:n}=e,o=e.id?e.id:jb(e),l=this.externalTracks.has(o),d=o.includes("auto");return l?{id:o,type:"external",isAuto:d,language:s,label:n,url:(t=this.externalTracks.get(o))===null||t===void 0?void 0:t.url}:{id:o,type:"internal",isAuto:d,language:s,label:n,url:(r=this.internalTracks.get(o))===null||r===void 0?void 0:r.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(r=>r.id===t)).forEach(([,t])=>this.detach(t))}setInternal(e){const t=[...this.externalTracks];e.filter(({id:r,language:s,isAuto:n})=>!this.internalTracks.has(r)&&!t.some(([,o])=>o.language===s&&o.isAuto===n)).forEach(r=>this.attach(r)),Array.from(this.internalTracks).filter(([r])=>!e.find(s=>s.id===r)).forEach(([,r])=>this.detach(r))}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)||!Hb(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"),r=>r.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)}}class Ca{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 tu=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},uo=i=>{const e=tu(i);return!!(e&&e.fullscreenElement&&e.fullscreenElement===i)},Gb=i=>{const e=tu(i);return!!(e&&e.pictureInPictureElement&&e.pictureInPictureElement===i)},Yb=3;var qb=(i,e,t=Yb)=>{let r=0,s=0;for(let n=0;n<i.length;n++){const o=i.start(n),l=i.end(n);if(o<=e&&e<=l){if(r=o,s=l,!t)return{from:r,to:s};for(let d=n-1;d>=0;d--)i.end(d)+t>=r&&(r=i.start(d));for(let d=n+1;d<i.length;d++)i.start(d)-t<=s&&(s=i.end(d))}}return{from:r,to:s}};const yt=i=>{const e=T=>a.fromEvent(i,T).pipe(a.mapTo(void 0)),t=["waiting","pause","canplay","play","canplaythrough","playing","seeking","seeked","ended"],r=a.merge(...t.map(T=>a.fromEvent(i,T))).pipe(a.map(T=>T.type==="ended"?i.readyState<2:i.readyState<3),a.filterChanged()),s=a.merge(a.fromEvent(i,"progress"),a.fromEvent(i,"timeupdate")).pipe(a.map(()=>qb(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 T;const E=i.error;return{id:E?`MediaError#${E.code}`:"HtmlVideoError",category:a.ErrorCategory.VIDEO_PIPELINE,message:E?E.message:"Error event from HTML video element",thrown:(T=i.error)!==null&&T!==void 0?T:void 0}})),c=a.fromEvent(i,"timeupdate").pipe(a.map(()=>i.currentTime)),h=new a.Subject,f=.3;let p;c.subscribe(T=>{i.loop&&a.isNonNullable(p)&&a.isNonNullable(T)&&p>=i.duration-f&&T<=f&&h.next(p),p=T});const v=a.fromEvent(i,"enterpictureinpicture"),m=a.fromEvent(i,"leavepictureinpicture"),b=new a.ValueSubject(Gb(i));v.subscribe(()=>b.next(!0)),m.subscribe(()=>b.next(!1));const S=new a.ValueSubject(uo(i));return a.fromEvent(i,"fullscreenchange").pipe(a.map(()=>uo(i))).subscribe(S),{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$:r,currentBuffer$:s,volumeState$:l,playbackRateState$:d,inPiP$:b,inFullscreen$:S}};var Sr=i=>{switch(i){case"mobile":return a.VideoQuality.Q_144P;case"lowest":return a.VideoQuality.Q_240P;case"low":return a.VideoQuality.Q_360P;case"sd":case"medium":return a.VideoQuality.Q_480P;case"hd":case"high":return a.VideoQuality.Q_720P;case"fullhd":case"full":return a.VideoQuality.Q_1080P;case"quadhd":case"quad":return a.VideoQuality.Q_1440P;case"ultrahd":case"ultra":return a.VideoQuality.Q_2160P}},Wb=Ae,zb=fr,Qb=fa,Kb=ha;Wb({target:"Array",proto:!0},{at:function(e){var t=zb(this),r=Qb(t),s=Kb(e),n=s>=0?s:r+s;return n<0||n>=r?void 0:t[n]}});var Jb=wa,Xb=Jb("Array","at"),Zb=Xb,eS=Zb,tS=eS,iS=tS,Ve=or(iS);let Ia=!1,Ue={};const rS=i=>{Ia=i},sS=()=>{Ue={}},aS=i=>{i(Ue)},Fi=(i,e)=>{var t;Ia&&(Ue.meta=(t=Ue.meta)!==null&&t!==void 0?t:{},Ue.meta[i]=e)};class Le{constructor(e){this.name=e}next(e){var t,r;if(!Ia)return;Ue.series=(t=Ue.series)!==null&&t!==void 0?t:{};const s=(r=Ue.series[this.name])!==null&&r!==void 0?r:[];s.push([Date.now(),e]),Ue.series[this.name]=s}}var ct;(function(i){i.FitsContainer="FitsContainer",i.FitsThroughput="FitsThroughput",i.Buffer="Buffer",i.DroppedFramesLimit="DroppedFramesLimit",i.FitsQualityLimits="FitsQualityLimits"})(ct||(ct={}));const nS=new Le("best_bitrate"),oS=(i,e,t)=>(e-t)*Math.pow(2,-10*i)+t;class lS{constructor(){this.history={}}recordSelection(e){this.history[e.id]=a.now()}recordSwitch(e){this.last=e}clear(){this.last=void 0,this.history={}}}const uS='Assertion "ABR Tracks is empty array" failed',gr=(i,{container:e,throughput:t,tuning:r,limits:s,reserve:n=0,forwardBufferHealth:o,playbackRate:l,current:d,history:u,droppedVideoMaxQualityLimit:c,abrLogger:h})=>{var f,p,v,m,b;a.assertNotEmptyArray(i,uS);const S=r.usePixelRatio&&(f=window.devicePixelRatio)!==null&&f!==void 0?f:1,y=r.limitByContainer&&e&&e.width>0&&e.height>0&&{width:e.width*S*r.containerSizeFactor,height:e.height*S*r.containerSizeFactor},T=y&&a.videoSizeToQuality(y),E=r.considerPlaybackRate&&a.isNonNullable(l)?l:1,$=i.filter(R=>!a.isInvariantQuality(R.quality)).sort((R,w)=>a.isHigher(R.quality,w.quality)?-1:1),O=(p=Ve($,-1))===null||p===void 0?void 0:p.quality,M=(v=Ve($,0))===null||v===void 0?void 0:v.quality,F=a.isNullable(s)||a.isNonNullable(s.min)&&a.isNonNullable(s.max)&&a.isLower(s.max,s.min)||a.isNonNullable(s.min)&&M&&a.isHigher(s.min,M)||a.isNonNullable(s.max)&&O&&a.isLower(s.max,O),x=E*oS(o!=null?o:.5,r.bitrateFactorAtEmptyBuffer,r.bitrateFactorAtFullBuffer),U={},I=$.filter(R=>(T?a.isLower(R.quality,T):!0)?(a.isNonNullable(t)&&isFinite(t)&&a.isNonNullable(R.bitrate)?t-n>=R.bitrate*x:!0)?r.lazyQualitySwitch&&a.isNonNullable(r.minBufferToSwitchUp)&&d&&!a.isInvariantQuality(d.quality)&&(o!=null?o:0)<r.minBufferToSwitchUp&&a.isHigher(R.quality,d.quality)?(U[R.quality]=ct.Buffer,!1):!!c&&a.isHigherOrEqual(R.quality,c)?(U[R.quality]=ct.DroppedFramesLimit,!1):F||(a.isNullable(s.max)||a.isLowerOrEqual(R.quality,s.max))&&(a.isNullable(s.min)||a.isHigherOrEqual(R.quality,s.min))?!0:(U[R.quality]=ct.FitsQualityLimits,!1):(U[R.quality]=ct.FitsThroughput,!1):(U[R.quality]=ct.FitsContainer,!1))[0];I&&I.bitrate&&nS.next(I.bitrate);const P=(m=I!=null?I:$[Math.ceil(($.length-1)/2)])!==null&&m!==void 0?m:i[0];P.quality!==((b=u==null?void 0:u.last)===null||b===void 0?void 0:b.quality)&&h({message:`
6
+ "use strict";var Vu=Object.create;var Ya=Object.defineProperty;var Fu=Object.getOwnPropertyDescriptor;var Uu=Object.getOwnPropertyNames;var ju=Object.getPrototypeOf,Hu=Object.prototype.hasOwnProperty;var Gu=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Uu(e))!Hu.call(i,s)&&s!==t&&Ya(i,s,{get:()=>e[s],enumerable:!(r=Fu(e,s))||r.enumerable});return i};var Yu=(i,e,t)=>(t=i!=null?Vu(ju(i)):{},Gu(e||!i||!i.__esModule?Ya(t,"default",{value:i,enumerable:!0}):t,i));var a=require("@vkontakte/videoplayer-shared/es2015.cjs.js");const Bo="2.0.102-beta.1";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_SEP",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 le;(function(i){i.SCREEN="SCREEN",i.CHROMECAST="CHROMECAST"})(le||(le={}));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 N;(function(i){i.None="none",i.Requested="requested",i.Applying="applying"})(N||(N={}));exports.Surface=void 0;(function(i){i.NONE="none",i.INLINE="inline",i.FULLSCREEN="fullscreen",i.SECOND_SCREEN="second_screen",i.PIP="pip"})(exports.Surface||(exports.Surface={}));function H(i,e,t,r){function s(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(r.next(c))}catch(h){o(h)}}function d(c){try{u(r.throw(c))}catch(h){o(h)}}function u(c){c.done?n(c.value):s(c.value).then(l,d)}u((r=r.apply(i,e||[])).next())})}function C(i){return this instanceof C?(this.v=i,this):new C(i)}function he(i,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(i,e||[]),s,n=[];return s={},o("next"),o("throw"),o("return"),s[Symbol.asyncIterator]=function(){return this},s;function o(f){r[f]&&(s[f]=function(p){return new Promise(function(v,m){n.push([f,p,v,m])>1||l(f,p)})})}function l(f,p){try{d(r[f](p))}catch(v){h(n[0][3],v)}}function d(f){f.value instanceof C?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 qu=i=>new Promise((e,t)=>{const r=document.createElement("script");r.setAttribute("src",i),r.onload=()=>e,r.onerror=()=>t,document.body.appendChild(r)});class Wu{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 r="chrome"in window;if(this.log({message:`[constructor] receiverApplicationId: ${this.params.receiverApplicationId}, isDisabled: ${this.params.isDisabled}, isSupported: ${r}`}),e.isDisabled||!r)return;const s=a.isNonNullable((t=window.chrome)===null||t===void 0?void 0:t.cast),n=!!window.__onGCastApiAvailable;s?this.initializeCastApi():(window.__onGCastApiAvailable=o=>{delete window.__onGCastApiAvailable,o&&this.initializeCastApi()},n||qu("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 r,s,n;(n=(s=(r=cast.framework.CastContext.getInstance())===null||r===void 0?void 0:r.getCurrentSession())===null||s===void 0?void 0:s.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),r=cast.framework.CastContext.getInstance();this.subscription.add(a.fromEvent(r,cast.framework.CastContextEventType.SESSION_STATE_CHANGED).subscribe(s=>{var n,o;switch(s.sessionState){case cast.framework.SessionState.SESSION_STARTED:case cast.framework.SessionState.SESSION_STARTING:case cast.framework.SessionState.SESSION_RESUMED:this.contentId=(o=(n=r.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(s.sessionState)}})).add(a.merge(a.fromEvent(r,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe(a.tap(s=>{this.log({message:`[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: ${JSON.stringify(s)}`})}),a.map(s=>s.castState)),a.observableFrom([r.getCastState()])).pipe(a.filterChanged(),a.map(zu),a.tap(s=>{this.log({message:`realCastState$: ${s}`})})).subscribe(this.realCastState$)).add(this.realCastState$.subscribe(s=>{var n;const o=s===exports.ChromecastState.CONNECTED,l=a.isNonNullable(this.connection$.getValue());if(o&&!l){const d=r.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(s===exports.ChromecastState.CONNECTED?a.isNonNullable(this.connection$.getValue())?exports.ChromecastState.CONNECTED:exports.ChromecastState.AVAILABLE:s)}))}initializeCastApi(){var e;let t,r,s;try{t=cast.framework.CastContext.getInstance(),r=chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,s=chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}catch(n){return}try{t.setOptions({receiverApplicationId:(e=this.params.receiverApplicationId)!==null&&e!==void 0?e:r,autoJoinPolicy:s}),this.initListeners()}catch(n){this.errorEvent$.next({id:"ChromecastInitializer",category:a.ErrorCategory.EXTERNAL_API,message:"[initializeCastApi] failed",thrown:n})}}}const zu=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 Lr=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function or(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Te=function(i){try{return!!i()}catch(e){return!0}},Qu=Te,lr=!Qu(function(){var i=function(){}.bind();return typeof i!="function"||i.hasOwnProperty("prototype")}),Vo=lr,Fo=Function.prototype,Rs=Fo.call,Ku=Vo&&Fo.bind.bind(Rs,Rs),Ee=Vo?Ku:function(i){return function(){return Rs.apply(i,arguments)}},Uo=Ee,Ju=Uo({}.toString),Xu=Uo("".slice),di=function(i){return Xu(Ju(i),8,-1)},Zu=Ee,ec=Te,tc=di,xr=Object,ic=Zu("".split),rc=ec(function(){return!xr("z").propertyIsEnumerable(0)})?function(i){return tc(i)=="String"?ic(i,""):xr(i)}:xr,hi=function(i){return i==null},sc=hi,ac=TypeError,ra=function(i){if(sc(i))throw ac("Can't call method on "+i);return i},nc=rc,oc=ra,fi=function(i){return nc(oc(i))},Gt={},Ai=function(i){return i&&i.Math==Math&&i},ne=Ai(typeof globalThis=="object"&&globalThis)||Ai(typeof window=="object"&&window)||Ai(typeof self=="object"&&self)||Ai(typeof Lr=="object"&&Lr)||function(){return this}()||Lr||Function("return this")(),_s=typeof document=="object"&&document.all,lc=typeof _s=="undefined"&&_s!==void 0,jo={all:_s,IS_HTMLDDA:lc},Ho=jo,uc=Ho.all,ie=Ho.IS_HTMLDDA?function(i){return typeof i=="function"||i===uc}:function(i){return typeof i=="function"},cc=ne,dc=ie,qa=cc.WeakMap,hc=dc(qa)&&/native code/.test(String(qa)),Wa=ie,Go=jo,fc=Go.all,Ye=Go.IS_HTMLDDA?function(i){return typeof i=="object"?i!==null:Wa(i)||i===fc}:function(i){return typeof i=="object"?i!==null:Wa(i)},pc=Te,Ze=!pc(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),pt={},mc=ne,za=Ye,Ds=mc.document,vc=za(Ds)&&za(Ds.createElement),sa=function(i){return vc?Ds.createElement(i):{}},bc=Ze,Sc=Te,gc=sa,Yo=!bc&&!Sc(function(){return Object.defineProperty(gc("div"),"a",{get:function(){return 7}}).a!=7}),yc=Ze,Tc=Te,qo=yc&&Tc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),Ec=Ye,$c=String,kc=TypeError,qe=function(i){if(Ec(i))return i;throw kc($c(i)+" is not an object")},wc=lr,Ci=Function.prototype.call,me=wc?Ci.bind(Ci):function(){return Ci.apply(Ci,arguments)},aa={},Nr=aa,Or=ne,Pc=ie,Qa=function(i){return Pc(i)?i:void 0},mt=function(i,e){return arguments.length<2?Qa(Nr[i])||Qa(Or[i]):Nr[i]&&Nr[i][e]||Or[i]&&Or[i][e]},Ac=Ee,ur=Ac({}.isPrototypeOf),cr=typeof navigator!="undefined"&&String(navigator.userAgent)||"",Wo=ne,Mr=cr,Ka=Wo.process,Ja=Wo.Deno,Xa=Ka&&Ka.versions||Ja&&Ja.version,Za=Xa&&Xa.v8,we,Xi;Za&&(we=Za.split("."),Xi=we[0]>0&&we[0]<4?1:+(we[0]+we[1]));!Xi&&Mr&&(we=Mr.match(/Edge\/(\d+)/),(!we||we[1]>=74)&&(we=Mr.match(/Chrome\/(\d+)/),we&&(Xi=+we[1])));var zo=Xi,en=zo,Cc=Te,Ic=ne,Rc=Ic.String,Qo=!!Object.getOwnPropertySymbols&&!Cc(function(){var i=Symbol();return!Rc(i)||!(Object(i)instanceof Symbol)||!Symbol.sham&&en&&en<41}),_c=Qo,Ko=_c&&!Symbol.sham&&typeof Symbol.iterator=="symbol",Dc=mt,Lc=ie,xc=ur,Nc=Ko,Oc=Object,Jo=Nc?function(i){return typeof i=="symbol"}:function(i){var e=Dc("Symbol");return Lc(e)&&xc(e.prototype,Oc(i))},Mc=String,dr=function(i){try{return Mc(i)}catch(e){return"Object"}},Bc=ie,Vc=dr,Fc=TypeError,vt=function(i){if(Bc(i))return i;throw Fc(Vc(i)+" is not a function")},Uc=vt,jc=hi,hr=function(i,e){var t=i[e];return jc(t)?void 0:Uc(t)},Br=me,Vr=ie,Fr=Ye,Hc=TypeError,Gc=function(i,e){var t,r;if(e==="string"&&Vr(t=i.toString)&&!Fr(r=Br(t,i))||Vr(t=i.valueOf)&&!Fr(r=Br(t,i))||e!=="string"&&Vr(t=i.toString)&&!Fr(r=Br(t,i)))return r;throw Hc("Can't convert object to primitive value")},Xo={exports:{}},Yc=!0,tn=ne,qc=Object.defineProperty,Wc=function(i,e){try{qc(tn,i,{value:e,configurable:!0,writable:!0})}catch(t){tn[i]=e}return e},zc=ne,Qc=Wc,rn="__core-js_shared__",Kc=zc[rn]||Qc(rn,{}),na=Kc,sn=na;(Xo.exports=function(i,e){return sn[i]||(sn[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 Zo=Xo.exports,Jc=ra,Xc=Object,fr=function(i){return Xc(Jc(i))},Zc=Ee,ed=fr,td=Zc({}.hasOwnProperty),Me=Object.hasOwn||function(e,t){return td(ed(e),t)},id=Ee,rd=0,sd=Math.random(),ad=id(1 .toString),el=function(i){return"Symbol("+(i===void 0?"":i)+")_"+ad(++rd+sd,36)},nd=ne,od=Zo,an=Me,ld=el,ud=Qo,cd=Ko,Nt=nd.Symbol,Ur=od("wks"),dd=cd?Nt.for||Nt:Nt&&Nt.withoutSetter||ld,ce=function(i){return an(Ur,i)||(Ur[i]=ud&&an(Nt,i)?Nt[i]:dd("Symbol."+i)),Ur[i]},hd=me,nn=Ye,on=Jo,fd=hr,pd=Gc,md=ce,vd=TypeError,bd=md("toPrimitive"),Sd=function(i,e){if(!nn(i)||on(i))return i;var t=fd(i,bd),r;if(t){if(e===void 0&&(e="default"),r=hd(t,i,e),!nn(r)||on(r))return r;throw vd("Can't convert object to primitive value")}return e===void 0&&(e="number"),pd(i,e)},gd=Sd,yd=Jo,oa=function(i){var e=gd(i,"string");return yd(e)?e:e+""},Td=Ze,Ed=Yo,$d=qo,Ii=qe,ln=oa,kd=TypeError,jr=Object.defineProperty,wd=Object.getOwnPropertyDescriptor,Hr="enumerable",Gr="configurable",Yr="writable";pt.f=Td?$d?function(e,t,r){if(Ii(e),t=ln(t),Ii(r),typeof e=="function"&&t==="prototype"&&"value"in r&&Yr in r&&!r[Yr]){var s=wd(e,t);s&&s[Yr]&&(e[t]=r.value,r={configurable:Gr in r?r[Gr]:s[Gr],enumerable:Hr in r?r[Hr]:s[Hr],writable:!1})}return jr(e,t,r)}:jr:function(e,t,r){if(Ii(e),t=ln(t),Ii(r),Ed)try{return jr(e,t,r)}catch(s){}if("get"in r||"set"in r)throw kd("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var pr=function(i,e){return{enumerable:!(i&1),configurable:!(i&2),writable:!(i&4),value:e}},Pd=Ze,Ad=pt,Cd=pr,pi=Pd?function(i,e,t){return Ad.f(i,e,Cd(1,t))}:function(i,e,t){return i[e]=t,i},Id=Zo,Rd=el,un=Id("keys"),la=function(i){return un[i]||(un[i]=Rd(i))},ua={},_d=hc,tl=ne,Dd=Ye,Ld=pi,qr=Me,Wr=na,xd=la,Nd=ua,cn="Object already initialized",Ls=tl.TypeError,Od=tl.WeakMap,Zi,oi,er,Md=function(i){return er(i)?oi(i):Zi(i,{})},Bd=function(i){return function(e){var t;if(!Dd(e)||(t=oi(e)).type!==i)throw Ls("Incompatible receiver, "+i+" required");return t}};if(_d||Wr.state){var Re=Wr.state||(Wr.state=new Od);Re.get=Re.get,Re.has=Re.has,Re.set=Re.set,Zi=function(i,e){if(Re.has(i))throw Ls(cn);return e.facade=i,Re.set(i,e),e},oi=function(i){return Re.get(i)||{}},er=function(i){return Re.has(i)}}else{var Ct=xd("state");Nd[Ct]=!0,Zi=function(i,e){if(qr(i,Ct))throw Ls(cn);return e.facade=i,Ld(i,Ct,e),e},oi=function(i){return qr(i,Ct)?i[Ct]:{}},er=function(i){return qr(i,Ct)}}var il={set:Zi,get:oi,has:er,enforce:Md,getterFor:Bd},Vd=lr,rl=Function.prototype,dn=rl.apply,hn=rl.call,sl=typeof Reflect=="object"&&Reflect.apply||(Vd?hn.bind(dn):function(){return hn.apply(dn,arguments)}),Fd=di,Ud=Ee,al=function(i){if(Fd(i)==="Function")return Ud(i)},ca={},nl={},ol={}.propertyIsEnumerable,ll=Object.getOwnPropertyDescriptor,jd=ll&&!ol.call({1:2},1);nl.f=jd?function(e){var t=ll(this,e);return!!t&&t.enumerable}:ol;var Hd=Ze,Gd=me,Yd=nl,qd=pr,Wd=fi,zd=oa,Qd=Me,Kd=Yo,fn=Object.getOwnPropertyDescriptor;ca.f=Hd?fn:function(e,t){if(e=Wd(e),t=zd(t),Kd)try{return fn(e,t)}catch(r){}if(Qd(e,t))return qd(!Gd(Yd.f,e,t),e[t])};var Jd=Te,Xd=ie,Zd=/#|\.prototype\./,mi=function(i,e){var t=th[eh(i)];return t==rh?!0:t==ih?!1:Xd(e)?Jd(e):!!e},eh=mi.normalize=function(i){return String(i).replace(Zd,".").toLowerCase()},th=mi.data={},ih=mi.NATIVE="N",rh=mi.POLYFILL="P",ul=mi,pn=al,sh=vt,ah=lr,nh=pn(pn.bind),mr=function(i,e){return sh(i),e===void 0?i:ah?nh(i,e):function(){return i.apply(e,arguments)}},Ri=ne,oh=sl,lh=al,uh=ie,ch=ca.f,dh=ul,It=aa,hh=mr,Rt=pi,mn=Me,fh=function(i){var e=function(t,r,s){if(this instanceof e){switch(arguments.length){case 0:return new i;case 1:return new i(t);case 2:return new i(t,r)}return new i(t,r,s)}return oh(i,this,arguments)};return e.prototype=i.prototype,e},Ae=function(i,e){var t=i.target,r=i.global,s=i.stat,n=i.proto,o=r?Ri:s?Ri[t]:(Ri[t]||{}).prototype,l=r?It:It[t]||Rt(It,t,{})[t],d=l.prototype,u,c,h,f,p,v,m,b,S;for(f in e)u=dh(r?f:t+(s?".":"#")+f,i.forced),c=!u&&o&&mn(o,f),v=l[f],c&&(i.dontCallGetSet?(S=ch(o,f),m=S&&S.value):m=o[f]),p=c&&m?m:e[f],!(c&&typeof v==typeof p)&&(i.bind&&c?b=hh(p,Ri):i.wrap&&c?b=fh(p):n&&uh(p)?b=lh(p):b=p,(i.sham||p&&p.sham||v&&v.sham)&&Rt(b,"sham",!0),Rt(l,f,b),n&&(h=t+"Prototype",mn(It,h)||Rt(It,h,{}),Rt(It[h],f,p),i.real&&d&&(u||!d[f])&&Rt(d,f,p)))},xs=Ze,ph=Me,cl=Function.prototype,mh=xs&&Object.getOwnPropertyDescriptor,da=ph(cl,"name"),vh=da&&function(){}.name==="something",bh=da&&(!xs||xs&&mh(cl,"name").configurable),Sh={EXISTS:da,PROPER:vh,CONFIGURABLE:bh},dl={},gh=Math.ceil,yh=Math.floor,Th=Math.trunc||function(e){var t=+e;return(t>0?yh:gh)(t)},Eh=Th,ha=function(i){var e=+i;return e!==e||e===0?0:Eh(e)},$h=ha,kh=Math.max,wh=Math.min,Ph=function(i,e){var t=$h(i);return t<0?kh(t+e,0):wh(t,e)},Ah=ha,Ch=Math.min,Ih=function(i){return i>0?Ch(Ah(i),9007199254740991):0},Rh=Ih,fa=function(i){return Rh(i.length)},_h=fi,Dh=Ph,Lh=fa,vn=function(i){return function(e,t,r){var s=_h(e),n=Lh(s),o=Dh(r,n),l;if(i&&t!=t){for(;n>o;)if(l=s[o++],l!=l)return!0}else for(;n>o;o++)if((i||o in s)&&s[o]===t)return i||o||0;return!i&&-1}},xh={includes:vn(!0),indexOf:vn(!1)},Nh=Ee,zr=Me,Oh=fi,Mh=xh.indexOf,Bh=ua,bn=Nh([].push),Vh=function(i,e){var t=Oh(i),r=0,s=[],n;for(n in t)!zr(Bh,n)&&zr(t,n)&&bn(s,n);for(;e.length>r;)zr(t,n=e[r++])&&(~Mh(s,n)||bn(s,n));return s},hl=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Fh=Vh,Uh=hl,jh=Object.keys||function(e){return Fh(e,Uh)},Hh=Ze,Gh=qo,Yh=pt,qh=qe,Wh=fi,zh=jh;dl.f=Hh&&!Gh?Object.defineProperties:function(e,t){qh(e);for(var r=Wh(t),s=zh(t),n=s.length,o=0,l;n>o;)Yh.f(e,l=s[o++],r[l]);return e};var Qh=mt,fl=Qh("document","documentElement"),Kh=qe,Jh=dl,Sn=hl,Xh=ua,Zh=fl,ef=sa,tf=la,gn=">",yn="<",Ns="prototype",Os="script",pl=tf("IE_PROTO"),Qr=function(){},ml=function(i){return yn+Os+gn+i+yn+"/"+Os+gn},Tn=function(i){i.write(ml("")),i.close();var e=i.parentWindow.Object;return i=null,e},rf=function(){var i=ef("iframe"),e="java"+Os+":",t;return i.style.display="none",Zh.appendChild(i),i.src=String(e),t=i.contentWindow.document,t.open(),t.write(ml("document.F=Object")),t.close(),t.F},_i,zi=function(){try{_i=new ActiveXObject("htmlfile")}catch(e){}zi=typeof document!="undefined"?document.domain&&_i?Tn(_i):rf():Tn(_i);for(var i=Sn.length;i--;)delete zi[Ns][Sn[i]];return zi()};Xh[pl]=!0;var vl=Object.create||function(e,t){var r;return e!==null?(Qr[Ns]=Kh(e),r=new Qr,Qr[Ns]=null,r[pl]=e):r=zi(),t===void 0?r:Jh.f(r,t)},sf=Te,af=!sf(function(){function i(){}return i.prototype.constructor=null,Object.getPrototypeOf(new i)!==i.prototype}),nf=Me,of=ie,lf=fr,uf=la,cf=af,En=uf("IE_PROTO"),Ms=Object,df=Ms.prototype,bl=cf?Ms.getPrototypeOf:function(i){var e=lf(i);if(nf(e,En))return e[En];var t=e.constructor;return of(t)&&e instanceof t?t.prototype:e instanceof Ms?df:null},hf=pi,pa=function(i,e,t,r){return r&&r.enumerable?i[e]=t:hf(i,e,t),i},ff=Te,pf=ie,mf=Ye,vf=vl,$n=bl,bf=pa,Sf=ce,Bs=Sf("iterator"),Sl=!1,je,Kr,Jr;[].keys&&(Jr=[].keys(),"next"in Jr?(Kr=$n($n(Jr)),Kr!==Object.prototype&&(je=Kr)):Sl=!0);var gf=!mf(je)||ff(function(){var i={};return je[Bs].call(i)!==i});gf?je={}:je=vf(je);pf(je[Bs])||bf(je,Bs,function(){return this});var gl={IteratorPrototype:je,BUGGY_SAFARI_ITERATORS:Sl},yf=ce,Tf=yf("toStringTag"),yl={};yl[Tf]="z";var ma=String(yl)==="[object z]",Ef=ma,$f=ie,Qi=di,kf=ce,wf=kf("toStringTag"),Pf=Object,Af=Qi(function(){return arguments}())=="Arguments",Cf=function(i,e){try{return i[e]}catch(t){}},vi=Ef?Qi:function(i){var e,t,r;return i===void 0?"Undefined":i===null?"Null":typeof(t=Cf(e=Pf(i),wf))=="string"?t:Af?Qi(e):(r=Qi(e))=="Object"&&$f(e.callee)?"Arguments":r},If=ma,Rf=vi,_f=If?{}.toString:function(){return"[object "+Rf(this)+"]"},Df=ma,Lf=pt.f,xf=pi,Nf=Me,Of=_f,Mf=ce,kn=Mf("toStringTag"),va=function(i,e,t,r){if(i){var s=t?i:i.prototype;Nf(s,kn)||Lf(s,kn,{configurable:!0,value:e}),r&&!Df&&xf(s,"toString",Of)}},Bf=gl.IteratorPrototype,Vf=vl,Ff=pr,Uf=va,jf=Gt,Hf=function(){return this},Gf=function(i,e,t,r){var s=e+" Iterator";return i.prototype=Vf(Bf,{next:Ff(+!r,t)}),Uf(i,s,!1,!0),jf[s]=Hf,i},Yf=Ae,qf=me,Tl=Sh,Wf=Gf,zf=bl,Qf=va,wn=pa,Kf=ce,Pn=Gt,El=gl,Jf=Tl.PROPER;Tl.CONFIGURABLE;El.IteratorPrototype;var Di=El.BUGGY_SAFARI_ITERATORS,Xr=Kf("iterator"),An="keys",Li="values",Cn="entries",Xf=function(){return this},Zf=function(i,e,t,r,s,n,o){Wf(t,e,r);var l=function(S){if(S===s&&f)return f;if(!Di&&S in c)return c[S];switch(S){case An:return function(){return new t(this,S)};case Li:return function(){return new t(this,S)};case Cn:return function(){return new t(this,S)}}return function(){return new t(this)}},d=e+" Iterator",u=!1,c=i.prototype,h=c[Xr]||c["@@iterator"]||s&&c[s],f=!Di&&h||l(s),p=e=="Array"&&c.entries||h,v,m,b;if(p&&(v=zf(p.call(new i)),v!==Object.prototype&&v.next&&(Qf(v,d,!0,!0),Pn[d]=Xf)),Jf&&s==Li&&h&&h.name!==Li&&(u=!0,f=function(){return qf(h,this)}),s)if(m={values:l(Li),keys:n?f:l(An),entries:l(Cn)},o)for(b in m)(Di||u||!(b in c))&&wn(c,b,m[b]);else Yf({target:e,proto:!0,forced:Di||u},m);return o&&c[Xr]!==f&&wn(c,Xr,f,{name:s}),Pn[e]=f,m},ep=function(i,e){return{value:i,done:e}},tp=fi,In=Gt,$l=il;pt.f;var ip=Zf,xi=ep,kl="Array Iterator",rp=$l.set,sp=$l.getterFor(kl);ip(Array,"Array",function(i,e){rp(this,{type:kl,target:tp(i),index:0,kind:e})},function(){var i=sp(this),e=i.target,t=i.kind,r=i.index++;return!e||r>=e.length?(i.target=void 0,xi(void 0,!0)):t=="keys"?xi(r,!1):t=="values"?xi(e[r],!1):xi([r,e[r]],!1)},"values");In.Arguments=In.Array;var ap=ce,np=Gt,op=ap("iterator"),lp=Array.prototype,up=function(i){return i!==void 0&&(np.Array===i||lp[op]===i)},cp=vi,Rn=hr,dp=hi,hp=Gt,fp=ce,pp=fp("iterator"),wl=function(i){if(!dp(i))return Rn(i,pp)||Rn(i,"@@iterator")||hp[cp(i)]},mp=me,vp=vt,bp=qe,Sp=dr,gp=wl,yp=TypeError,Tp=function(i,e){var t=arguments.length<2?gp(i):e;if(vp(t))return bp(mp(t,i));throw yp(Sp(i)+" is not iterable")},Ep=me,_n=qe,$p=hr,kp=function(i,e,t){var r,s;_n(i);try{if(r=$p(i,"return"),!r){if(e==="throw")throw t;return t}r=Ep(r,i)}catch(n){s=!0,r=n}if(e==="throw")throw t;if(s)throw r;return _n(r),t},wp=mr,Pp=me,Ap=qe,Cp=dr,Ip=up,Rp=fa,Dn=ur,_p=Tp,Dp=wl,Ln=kp,Lp=TypeError,Ki=function(i,e){this.stopped=i,this.result=e},xn=Ki.prototype,ba=function(i,e,t){var r=t&&t.that,s=!!(t&&t.AS_ENTRIES),n=!!(t&&t.IS_RECORD),o=!!(t&&t.IS_ITERATOR),l=!!(t&&t.INTERRUPTED),d=wp(e,r),u,c,h,f,p,v,m,b=function(y){return u&&Ln(u,"normal",y),new Ki(!0,y)},S=function(y){return s?(Ap(y),l?d(y[0],y[1],b):d(y[0],y[1])):l?d(y,b):d(y)};if(n)u=i.iterator;else if(o)u=i;else{if(c=Dp(i),!c)throw Lp(Cp(i)+" is not iterable");if(Ip(c)){for(h=0,f=Rp(i);f>h;h++)if(p=S(i[h]),p&&Dn(xn,p))return p;return new Ki(!1)}u=_p(i,c)}for(v=n?i.next:u.next;!(m=Pp(v,u)).done;){try{p=S(m.value)}catch(y){Ln(u,"throw",y)}if(typeof p=="object"&&p&&Dn(xn,p))return p}return new Ki(!1)},xp=oa,Np=pt,Op=pr,Mp=function(i,e,t){var r=xp(e);r in i?Np.f(i,r,Op(0,t)):i[r]=t},Bp=Ae,Vp=ba,Fp=Mp;Bp({target:"Object",stat:!0},{fromEntries:function(e){var t={};return Vp(e,function(r,s){Fp(t,r,s)},{AS_ENTRIES:!0}),t}});var Up=aa,jp=Up.Object.fromEntries,Hp={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},Gp=Hp,Yp=ne,qp=vi,Wp=pi,Nn=Gt,zp=ce,On=zp("toStringTag");for(var Zr in Gp){var Mn=Yp[Zr],es=Mn&&Mn.prototype;es&&qp(es)!==On&&Wp(es,On,Zr),Nn[Zr]=Nn.Array}var Qp=jp,Kp=Qp,Jp=Kp,Xp=Jp,tr=or(Xp),Zp=di,vr=typeof process!="undefined"&&Zp(process)=="process",em=pt,tm=function(i,e,t){return em.f(i,e,t)},im=mt,rm=tm,sm=ce,am=Ze,Bn=sm("species"),nm=function(i){var e=im(i);am&&e&&!e[Bn]&&rm(e,Bn,{configurable:!0,get:function(){return this}})},om=ur,lm=TypeError,um=function(i,e){if(om(e,i))return i;throw lm("Incorrect invocation")},cm=Ee,dm=ie,Vs=na,hm=cm(Function.toString);dm(Vs.inspectSource)||(Vs.inspectSource=function(i){return hm(i)});var Pl=Vs.inspectSource,fm=Ee,pm=Te,Al=ie,mm=vi,vm=mt,bm=Pl,Cl=function(){},Sm=[],Il=vm("Reflect","construct"),Sa=/^\s*(?:class|function)\b/,gm=fm(Sa.exec),ym=!Sa.exec(Cl),Zt=function(e){if(!Al(e))return!1;try{return Il(Cl,Sm,e),!0}catch(t){return!1}},Rl=function(e){if(!Al(e))return!1;switch(mm(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return ym||!!gm(Sa,bm(e))}catch(t){return!0}};Rl.sham=!0;var Tm=!Il||pm(function(){var i;return Zt(Zt.call)||!Zt(Object)||!Zt(function(){i=!0})||i})?Rl:Zt,Em=Tm,$m=dr,km=TypeError,wm=function(i){if(Em(i))return i;throw km($m(i)+" is not a constructor")},Vn=qe,Pm=wm,Am=hi,Cm=ce,Im=Cm("species"),_l=function(i,e){var t=Vn(i).constructor,r;return t===void 0||Am(r=Vn(t)[Im])?e:Pm(r)},Rm=Ee,_m=Rm([].slice),Dm=TypeError,Lm=function(i,e){if(i<e)throw Dm("Not enough arguments");return i},xm=cr,Dl=/(?:ipad|iphone|ipod).*applewebkit/i.test(xm),pe=ne,Nm=sl,Om=mr,Fn=ie,Mm=Me,Ll=Te,Un=fl,Bm=_m,jn=sa,Vm=Lm,Fm=Dl,Um=vr,Fs=pe.setImmediate,Us=pe.clearImmediate,jm=pe.process,ts=pe.Dispatch,Hm=pe.Function,Hn=pe.MessageChannel,Gm=pe.String,is=0,si={},Gn="onreadystatechange",li,nt,rs,ss;Ll(function(){li=pe.location});var ga=function(i){if(Mm(si,i)){var e=si[i];delete si[i],e()}},as=function(i){return function(){ga(i)}},Yn=function(i){ga(i.data)},qn=function(i){pe.postMessage(Gm(i),li.protocol+"//"+li.host)};(!Fs||!Us)&&(Fs=function(e){Vm(arguments.length,1);var t=Fn(e)?e:Hm(e),r=Bm(arguments,1);return si[++is]=function(){Nm(t,void 0,r)},nt(is),is},Us=function(e){delete si[e]},Um?nt=function(i){jm.nextTick(as(i))}:ts&&ts.now?nt=function(i){ts.now(as(i))}:Hn&&!Fm?(rs=new Hn,ss=rs.port2,rs.port1.onmessage=Yn,nt=Om(ss.postMessage,ss)):pe.addEventListener&&Fn(pe.postMessage)&&!pe.importScripts&&li&&li.protocol!=="file:"&&!Ll(qn)?(nt=qn,pe.addEventListener("message",Yn,!1)):Gn in jn("script")?nt=function(i){Un.appendChild(jn("script"))[Gn]=function(){Un.removeChild(this),ga(i)}}:nt=function(i){setTimeout(as(i),0)});var xl={set:Fs,clear:Us},Nl=function(){this.head=null,this.tail=null};Nl.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 Ol=Nl,Ym=cr,qm=/ipad|iphone|ipod/i.test(Ym)&&typeof Pebble!="undefined",Wm=cr,zm=/web0s(?!.*chrome)/i.test(Wm),ht=ne,Wn=mr,Qm=ca.f,ns=xl.set,Km=Ol,Jm=Dl,Xm=qm,Zm=zm,os=vr,zn=ht.MutationObserver||ht.WebKitMutationObserver,Qn=ht.document,Kn=ht.process,Ni=ht.Promise,Jn=Qm(ht,"queueMicrotask"),js=Jn&&Jn.value,_t,ls,us,Oi,Xn;if(!js){var Mi=new Km,Bi=function(){var i,e;for(os&&(i=Kn.domain)&&i.exit();e=Mi.get();)try{e()}catch(t){throw Mi.head&&_t(),t}i&&i.enter()};!Jm&&!os&&!Zm&&zn&&Qn?(ls=!0,us=Qn.createTextNode(""),new zn(Bi).observe(us,{characterData:!0}),_t=function(){us.data=ls=!ls}):!Xm&&Ni&&Ni.resolve?(Oi=Ni.resolve(void 0),Oi.constructor=Ni,Xn=Wn(Oi.then,Oi),_t=function(){Xn(Bi)}):os?_t=function(){Kn.nextTick(Bi)}:(ns=Wn(ns,ht),_t=function(){ns(Bi)}),js=function(i){Mi.head||_t(),Mi.add(i)}}var ev=js,tv=function(i,e){try{arguments.length==1?console.error(i):console.error(i,e)}catch(t){}},ya=function(i){try{return{error:!1,value:i()}}catch(e){return{error:!0,value:e}}},iv=ne,Yt=iv.Promise,Ml=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",rv=Ml,sv=vr,av=!rv&&!sv&&typeof window=="object"&&typeof document=="object",nv=ne,ai=Yt,ov=ie,lv=ul,uv=Pl,cv=ce,dv=av,hv=Ml,cs=zo,Zn=ai&&ai.prototype,fv=cv("species"),Hs=!1,Bl=ov(nv.PromiseRejectionEvent),pv=lv("Promise",function(){var i=uv(ai),e=i!==String(ai);if(!e&&cs===66||!(Zn.catch&&Zn.finally))return!0;if(!cs||cs<51||!/native code/.test(i)){var t=new ai(function(n){n(1)}),r=function(n){n(function(){},function(){})},s=t.constructor={};if(s[fv]=r,Hs=t.then(function(){})instanceof r,!Hs)return!0}return!e&&(dv||hv)&&!Bl}),bi={CONSTRUCTOR:pv,REJECTION_EVENT:Bl,SUBCLASSING:Hs},qt={},eo=vt,mv=TypeError,vv=function(i){var e,t;this.promise=new i(function(r,s){if(e!==void 0||t!==void 0)throw mv("Bad Promise constructor");e=r,t=s}),this.resolve=eo(e),this.reject=eo(t)};qt.f=function(i){return new vv(i)};var bv=Ae,ir=vr,Xe=ne,Si=me,Sv=pa,gv=va,yv=nm,Tv=vt,Gs=ie,Ev=Ye,$v=um,kv=_l,Vl=xl.set,Ta=ev,wv=tv,Pv=ya,Av=Ol,Fl=il,Ys=Yt,Ea=bi,Ul=qt,br="Promise",jl=Ea.CONSTRUCTOR,Cv=Ea.REJECTION_EVENT;Ea.SUBCLASSING;var ds=Fl.getterFor(br),Iv=Fl.set,Rv=Ys&&Ys.prototype,Ot=Ys,hs=Rv,Hl=Xe.TypeError,qs=Xe.document,$a=Xe.process,Ws=Ul.f,_v=Ws,Dv=!!(qs&&qs.createEvent&&Xe.dispatchEvent),Gl="unhandledrejection",Lv="rejectionhandled",to=0,Yl=1,xv=2,ka=1,ql=2,Vi,io,Nv,Wl=function(i){var e;return Ev(i)&&Gs(e=i.then)?e:!1},zl=function(i,e){var t=e.value,r=e.state==Yl,s=r?i.ok:i.fail,n=i.resolve,o=i.reject,l=i.domain,d,u,c;try{s?(r||(e.rejection===ql&&Mv(e),e.rejection=ka),s===!0?d=t:(l&&l.enter(),d=s(t),l&&(l.exit(),c=!0)),d===i.promise?o(Hl("Promise-chain cycle")):(u=Wl(d))?Si(u,d,n,o):n(d)):o(t)}catch(h){l&&!c&&l.exit(),o(h)}},Ql=function(i,e){i.notified||(i.notified=!0,Ta(function(){for(var t=i.reactions,r;r=t.get();)zl(r,i);i.notified=!1,e&&!i.rejection&&Ov(i)}))},Kl=function(i,e,t){var r,s;Dv?(r=qs.createEvent("Event"),r.promise=e,r.reason=t,r.initEvent(i,!1,!0),Xe.dispatchEvent(r)):r={promise:e,reason:t},!Cv&&(s=Xe["on"+i])?s(r):i===Gl&&wv("Unhandled promise rejection",t)},Ov=function(i){Si(Vl,Xe,function(){var e=i.facade,t=i.value,r=ro(i),s;if(r&&(s=Pv(function(){ir?$a.emit("unhandledRejection",t,e):Kl(Gl,e,t)}),i.rejection=ir||ro(i)?ql:ka,s.error))throw s.value})},ro=function(i){return i.rejection!==ka&&!i.parent},Mv=function(i){Si(Vl,Xe,function(){var e=i.facade;ir?$a.emit("rejectionHandled",e):Kl(Lv,e,i.value)})},Mt=function(i,e,t){return function(r){i(e,r,t)}},Ft=function(i,e,t){i.done||(i.done=!0,t&&(i=t),i.value=e,i.state=xv,Ql(i,!0))},zs=function(i,e,t){if(!i.done){i.done=!0,t&&(i=t);try{if(i.facade===e)throw Hl("Promise can't be resolved itself");var r=Wl(e);r?Ta(function(){var s={done:!1};try{Si(r,e,Mt(zs,s,i),Mt(Ft,s,i))}catch(n){Ft(s,n,i)}}):(i.value=e,i.state=Yl,Ql(i,!1))}catch(s){Ft({done:!1},s,i)}}};jl&&(Ot=function(e){$v(this,hs),Tv(e),Si(Vi,this);var t=ds(this);try{e(Mt(zs,t),Mt(Ft,t))}catch(r){Ft(t,r)}},hs=Ot.prototype,Vi=function(e){Iv(this,{type:br,done:!1,notified:!1,parent:!1,reactions:new Av,rejection:!1,state:to,value:void 0})},Vi.prototype=Sv(hs,"then",function(e,t){var r=ds(this),s=Ws(kv(this,Ot));return r.parent=!0,s.ok=Gs(e)?e:!0,s.fail=Gs(t)&&t,s.domain=ir?$a.domain:void 0,r.state==to?r.reactions.add(s):Ta(function(){zl(s,r)}),s.promise}),io=function(){var i=new Vi,e=ds(i);this.promise=i,this.resolve=Mt(zs,e),this.reject=Mt(Ft,e)},Ul.f=Ws=function(i){return i===Ot||i===Nv?new io(i):_v(i)});bv({global:!0,constructor:!0,wrap:!0,forced:jl},{Promise:Ot});gv(Ot,br,!1,!0);yv(br);var Bv=ce,Jl=Bv("iterator"),Xl=!1;try{var Vv=0,so={next:function(){return{done:!!Vv++}},return:function(){Xl=!0}};so[Jl]=function(){return this},Array.from(so,function(){throw 2})}catch(i){}var Fv=function(i,e){if(!e&&!Xl)return!1;var t=!1;try{var r={};r[Jl]=function(){return{next:function(){return{done:t=!0}}}},i(r)}catch(s){}return t},Uv=Yt,jv=Fv,Hv=bi.CONSTRUCTOR,Zl=Hv||!jv(function(i){Uv.all(i).then(void 0,function(){})}),Gv=Ae,Yv=me,qv=vt,Wv=qt,zv=ya,Qv=ba,Kv=Zl;Gv({target:"Promise",stat:!0,forced:Kv},{all:function(e){var t=this,r=Wv.f(t),s=r.resolve,n=r.reject,o=zv(function(){var l=qv(t.resolve),d=[],u=0,c=1;Qv(e,function(h){var f=u++,p=!1;c++,Yv(l,t,h).then(function(v){p||(p=!0,d[f]=v,--c||s(d))},n)}),--c||s(d)});return o.error&&n(o.value),r.promise}});var Jv=Ae,Xv=bi.CONSTRUCTOR,ao=Yt;ao&&ao.prototype;Jv({target:"Promise",proto:!0,forced:Xv,real:!0},{catch:function(i){return this.then(void 0,i)}});var Zv=Ae,eb=me,tb=vt,ib=qt,rb=ya,sb=ba,ab=Zl;Zv({target:"Promise",stat:!0,forced:ab},{race:function(e){var t=this,r=ib.f(t),s=r.reject,n=rb(function(){var o=tb(t.resolve);sb(e,function(l){eb(o,t,l).then(r.resolve,s)})});return n.error&&s(n.value),r.promise}});var nb=Ae,ob=me,lb=qt,ub=bi.CONSTRUCTOR;nb({target:"Promise",stat:!0,forced:ub},{reject:function(e){var t=lb.f(this);return ob(t.reject,void 0,e),t.promise}});var cb=qe,db=Ye,hb=qt,eu=function(i,e){if(cb(i),db(e)&&e.constructor===i)return e;var t=hb.f(i),r=t.resolve;return r(e),t.promise},fb=Ae,pb=mt,mb=Yc,vb=Yt,bb=bi.CONSTRUCTOR,Sb=eu,gb=pb("Promise"),yb=!bb;fb({target:"Promise",stat:!0,forced:mb},{resolve:function(e){return Sb(yb&&this===gb?vb:this,e)}});var Tb=Ae,Qs=Yt,Eb=Te,$b=mt,kb=ie,wb=_l,no=eu,Pb=Qs&&Qs.prototype,Ab=!!Qs&&Eb(function(){Pb.finally.call({then:function(){}},function(){})});Tb({target:"Promise",proto:!0,real:!0,forced:Ab},{finally:function(i){var e=wb(this,$b("Promise")),t=kb(i);return this.then(t?function(r){return no(e,i()).then(function(){return r})}:i,t?function(r){return no(e,i()).then(function(){throw r})}:i)}});var Cb=mt,wa=Cb,Ib=wa,Rb=Ib("Promise","finally"),_b=Rb,Db=_b,Lb=Db,xb=Lb,Pa=or(xb),re;(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"})(re||(re={}));var Pe=(i,e=0,t=re.OFFSET_P)=>{switch(t){case re.OFFSET_P:return i.replace("_offset_p",e===0?"":"_"+e.toFixed(0));case re.PLAYBACK_SHIFT:{if(e===0)return i;const r=new URL(i);return r.searchParams.append("playback_shift",e.toFixed(0)),r.toString()}case re.DASH_CMAF_OFFSET_P:{const r=new URL(i);return!r.searchParams.get("offset_p")&&e===0?i:(r.searchParams.set("offset_p",e.toFixed(0)),r.toString())}default:a.assertNever(t)}return i};const oo=(i,e)=>{var t;switch(e){case re.OFFSET_P:return NaN;case re.PLAYBACK_SHIFT:{const r=new URL(i);return Number(r.searchParams.get("playback_shift"))}case re.DASH_CMAF_OFFSET_P:{const r=new URL(i);return Number((t=r.searchParams.get("offset_p"))!==null&&t!==void 0?t:0)}default:a.assertNever(e)}};var A=(i,e,t=!1)=>{const r=i.getTransition();(t||!r||r.to===e)&&i.setState(e)};class Z{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,r=this.state;this.transition=void 0,this.prevState=r,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:r,to:e,canceledTransition:t})}startTransitionTo(e){const t=this.transition,r=this.state;r===e||a.isNonNullable(t)&&t.to===e||(this.prevState=r,this.state=e,t?(this.transition={from:t.from,to:e,canceledTransition:t},this.transitionUpdated$.next(this.transition)):(this.transition={from:r,to:e},this.transitionStarted$.next(this.transition)))}getTransition(){return this.transition}getState(){return this.state}getPrevState(){return this.prevState}}const Nb=i=>{switch(i){case exports.VideoFormat.MPEG: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 D;(function(i){i.STOPPED="stopped",i.READY="ready",i.PLAYING="playing",i.PAUSED="paused"})(D||(D={}));const Ob=5,Mb=5,Bb=500,lo=7e3;class Vb{constructor(e){this.subscription=new a.Subscription,this.loadMediaTimeoutSubscription=new a.Subscription,this.videoState=new Z(D.STOPPED),this.syncPlayback=()=>{const r=this.videoState.getState(),s=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: ${r}; videoTransition: ${JSON.stringify(s)}; desiredPlaybackState: ${n}; desiredPlaybackStateTransition: ${this.params.desiredState.playbackState.getTransition()}; seekState: ${JSON.stringify(l)};`}),n===exports.PlaybackState.STOPPED){r!==D.STOPPED&&(this.videoState.startTransitionTo(D.STOPPED),this.stop());return}if(!s){if((o==null?void 0:o.to)!==exports.PlaybackState.PAUSED&&l.state===N.Requested&&r!==D.STOPPED){this.seek(l.position/1e3);return}switch(n){case exports.PlaybackState.READY:{switch(r){case D.PLAYING:case D.PAUSED:case D.READY:break;case D.STOPPED:this.videoState.startTransitionTo(D.READY),this.prepare();break;default:a.assertNever(r)}break}case exports.PlaybackState.PLAYING:{switch(r){case D.PLAYING:break;case D.PAUSED:this.videoState.startTransitionTo(D.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case D.READY:this.videoState.startTransitionTo(D.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case D.STOPPED:this.videoState.startTransitionTo(D.READY),this.prepare();break;default:a.assertNever(r)}break}case exports.PlaybackState.PAUSED:{switch(r){case D.PLAYING:this.videoState.startTransitionTo(D.PAUSED),this.params.connection.remotePlayerController.playOrPause();break;case D.PAUSED:break;case D.READY:this.videoState.startTransitionTo(D.PAUSED),this.videoState.setState(D.PAUSED);break;case D.STOPPED:this.videoState.startTransitionTo(D.READY),this.prepare();break;default:a.assertNever(r)}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(Nb(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(s=>`stateChangeStarted$ ${JSON.stringify(s)}`)),this.videoState.stateChangeEnded$.pipe(a.map(s=>`stateChangeEnded$ ${JSON.stringify(s)}`))).subscribe(s=>this.log({message:`[videoState] ${s}`})));const t=(s,n)=>this.subscription.add(s.subscribe(n));if(this.params.output.isLive$.getValue())this.params.output.position$.next(0),this.params.output.duration$.next(0);else{const s=new a.Subject;e.add(s.pipe(a.debounce(Bb)).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===N.Applying||Math.abs(l-n)>Ob)&&s.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),s=>{this.logRemoteEvent(s),s.value?this.handleRemoteReady():(this.handleRemoteStop(),e.unsubscribe())}),t(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),s=>{this.logRemoteEvent(s),s.value?this.handleRemotePause():this.handleRemotePlay()}),t(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED),s=>{this.logRemoteEvent(s);const{remotePlayer:n}=this.params.connection,o=s.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<Mb&&this.params.output.endedEvent$.next(),this.handleRemoteStop(),A(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),s=>{this.logRemoteEvent(s),this.handleRemoteVolumeChange({volume:s.value})}),t(a.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),s=>{this.logRemoteEvent(s),this.handleRemoteVolumeChange({muted:s.value})});const r=a.merge(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,a.observableFrom(["init"])).pipe(a.debounce(0));t(r,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(D.PAUSED),A(this.params.desiredState.playbackState,exports.PlaybackState.PAUSED)):(this.videoState.setState(D.PLAYING),A(this.params.desiredState.playbackState,exports.PlaybackState.PLAYING));const r=this.params.output.isLive$.getValue();this.params.output.duration$.next(r?0:t.duration),this.params.output.position$.next(r?0:t.currentTime),this.params.desiredState.seekState.setState({state:N.None})}}prepare(){const e=this.params.format;this.log({message:`[prepare] format: ${e}`});const t=this.createMediaInfo(e),r=this.createLoadRequest(t);this.loadMedia(r)}handleRemotePause(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===D.PAUSED||e===D.PLAYING)&&(this.videoState.setState(D.PAUSED),A(this.params.desiredState.playbackState,exports.PlaybackState.PAUSED))}handleRemotePlay(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===D.PLAYING||e===D.PAUSED)&&(this.videoState.setState(D.PLAYING),A(this.params.desiredState.playbackState,exports.PlaybackState.PLAYING))}handleRemoteReady(){var e;const t=this.videoState.getTransition();(t==null?void 0:t.to)===D.READY&&this.videoState.setState(D.READY),((e=this.params.desiredState.playbackState.getTransition())===null||e===void 0?void 0:e.to)===exports.PlaybackState.READY&&A(this.params.desiredState.playbackState,exports.PlaybackState.READY)}handleRemoteStop(){this.videoState.getState()!==D.STOPPED&&this.videoState.setState(D.STOPPED)}handleRemoteVolumeChange(e){var t,r;const s=this.params.output.volume$.getValue(),n={volume:(t=e.volume)!==null&&t!==void 0?t:s.volume,muted:(r=e.muted)!==null&&r!==void 0?r:s.muted};(n.volume!==s.volume||n.muted!==n.muted)&&this.params.output.volume$.next(n)}seek(e){this.params.output.willSeekEvent$.next();const{remotePlayer:t,remotePlayerController:r}=this.params.connection;t.currentTime=e,r.seek()}stop(){const{remotePlayerController:e}=this.params.connection;e.stop()}createMediaInfo(e){var t;const r=this.params.source;let s,n,o;switch(e){case exports.VideoFormat.MPEG:{const c=r[e];a.assertNonNullable(c);const h=a.getHighestQuality(Object.keys(c));a.assertNonNullable(h);const f=c[h];a.assertNonNullable(f),s=f,n="video/mp4",o=chrome.cast.media.StreamType.BUFFERED;break}case exports.VideoFormat.HLS:case exports.VideoFormat.HLS_ONDEMAND:{const c=r[e];a.assertNonNullable(c),s=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=r[e];a.assertNonNullable(c),s=c.url,n="application/dash+xml",o=chrome.cast.media.StreamType.BUFFERED;break}case exports.VideoFormat.DASH_LIVE_CMAF:{const c=r[e];a.assertNonNullable(c),s=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=r[e];a.assertNonNullable(c),s=Pe(c.url),n="application/x-mpegurl",o=chrome.cast.media.StreamType.LIVE;break}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:s,n);l.contentUrl=s,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 r=this.params.desiredState.seekState.getState();return r.state===N.Applying||r.state===N.Requested?t.currentTime=this.params.output.isLive$.getValue()?0:r.position/1e3:t.currentTime=0,t}loadMedia(e){const t=this.params.connection.session.loadMedia(e),r=new Promise((s,n)=>{this.loadMediaTimeoutSubscription.add(a.timeout(lo).subscribe(()=>n(`timeout(${lo})`)))});Pa(Promise.race([t,r]).then(()=>{this.log({message:`[loadMedia] completed, format: ${this.params.format}`}),this.params.desiredState.seekState.getState().state===N.Applying&&this.params.output.seekedEvent$.next(),this.handleRemoteReady()},s=>{const n=`[prepare] loadMedia failed, format: ${this.params.format}, reason: ${s}`;this.log({message:n}),this.params.output.error$.next({id:"ChromecastProvider.loadMedia",category:a.ErrorCategory.VIDEO_PIPELINE,message:n,thrown:s})}),()=>{this.loadMediaTimeoutSubscription.unsubscribe()})}logRemoteEvent(e){this.log({message:`[remoteEvent] ${JSON.stringify(e)}`})}}const Aa=i=>{i.removeAttribute("src"),i.load()},Fb=i=>{try{i.pause(),i.playbackRate=0,Aa(i),i.remove()}catch(e){console.error(e)}};class Ub{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 Ks=window.WeakMap?new WeakMap:new Ub,bt=i=>{let e=i.querySelector("video");const t=!!e;return e?Aa(e):(e=document.createElement("video"),i.appendChild(e)),Ks.set(e,t),e.setAttribute("crossorigin","anonymous"),e.setAttribute("playsinline","playsinline"),e.controls=!1,e.setAttribute("poster","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),e},St=i=>{const e=Ks.get(i);Ks.delete(i),e?Aa(i):Fb(i)},Fe=(i,e,t,{equal:r=(o,l)=>o===l,changed$:s,onError:n}={})=>{const o=i.getState(),l=e(),d=a.isNullable(s),u=new a.Subscription;return s&&u.add(s.subscribe(c=>{const h=i.getState();r(c,h)&&i.setState(c)},n)),r(l,o)||(t(o),d&&i.setState(o)),u.add(i.stateChangeStarted$.subscribe(c=>{t(c.to),d&&i.setState(c.to)},n)),u},gi=(i,e,t)=>Fe(e,()=>i.loop,r=>{a.isNonNullable(r)&&(i.loop=r)},{onError:t}),gt=(i,e,t,r)=>Fe(e,()=>({muted:i.muted,volume:i.volume}),s=>{a.isNonNullable(s)&&(i.muted=s.muted,i.volume=s.volume)},{equal:(s,n)=>s===n||(s==null?void 0:s.muted)===(n==null?void 0:n.muted)&&(s==null?void 0:s.volume)===(n==null?void 0:n.volume),changed$:t,onError:r}),Wt=(i,e,t,r)=>Fe(e,()=>i.playbackRate,s=>{a.isNonNullable(s)&&(i.playbackRate=s)},{changed$:t,onError:r}),jb=i=>["__",i.language,i.label].join("|"),Hb=(i,e)=>{if(i.id===e)return!0;const[t,r,s]=e.split("|");return i.language===r&&i.label===s};class et{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,r){this.video=e,this.cueSettings=t.textTrackCuesSettings,this.subscribe();const s=n=>{this.error$.next({id:"TextTracksManager",category:a.ErrorCategory.WTF,message:"Generic HtmlVideoTextTrackManager error",thrown:n})};this.subscription.add(this.available$.subscribe(r.availableTextTracks$)),this.subscription.add(this.current$.subscribe(r.currentTextTrack$)),this.subscription.add(this.error$.subscribe(r.error$)),this.subscription.add(Fe(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:s})),this.subscription.add(Fe(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:s})),this.subscription.add(Fe(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:s})),this.subscription.add(Fe(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 r=this.current$.getValue();r&&this.select(r)})),this.subscription.add(a.merge(a.fromEvent(e,"addtrack"),a.fromEvent(e,"removetrack"),a.observableFrom(["init"])).pipe(a.map(()=>this.htmlTextTracksAsArray().map(r=>this.htmlTextTrackToITextTrack(r))),a.filterChanged((r,s)=>r.length===s.length&&r.every(({id:n},o)=>n===s[o].id))).subscribe(this.available$)),this.subscription.add(a.merge(a.fromEvent(e,"change"),a.observableFrom(["init"])).pipe(a.map(()=>this.htmlTextTracksAsArray().find(({mode:r})=>r==="showing")),a.map(r=>r&&this.htmlTextTrackToITextTrack(r).id),a.filterChanged()).subscribe(this.current$));const t=r=>{var s,n;return this.applyCueSettings((n=(s=r.target)===null||s===void 0?void 0:s.activeCues)!==null&&n!==void 0?n:null)};this.subscription.add(a.fromEvent(e,"addtrack").subscribe(r=>{var s,n;(s=r.track)===null||s===void 0||s.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=r.track)===null||n===void 0||n.addEventListener("cuechange",o)})),this.subscription.add(a.fromEvent(e,"removetrack").subscribe(r=>{var s;(s=r.track)===null||s===void 0||s.removeEventListener("cuechange",t)}))}applyCueSettings(e){if(!e||!e.length)return;const t=this.cueSettings.getState();for(const r of Array.from(e)){const s=r;a.isNonNullable(t.align)&&(s.align=t.align),a.isNonNullable(t.position)&&(s.position=t.position),a.isNonNullable(t.size)&&(s.size=t.size),a.isNonNullable(t.line)&&(s.line=t.line)}}htmlTextTracksAsArray(e=!1){a.assertNonNullable(this.video);const t=[...this.video.textTracks];return e?t:t.filter(et.isHealthyTrack)}htmlTextTrackToITextTrack(e){var t,r;const{language:s,label:n}=e,o=e.id?e.id:jb(e),l=this.externalTracks.has(o),d=o.includes("auto");return l?{id:o,type:"external",isAuto:d,language:s,label:n,url:(t=this.externalTracks.get(o))===null||t===void 0?void 0:t.url}:{id:o,type:"internal",isAuto:d,language:s,label:n,url:(r=this.internalTracks.get(o))===null||r===void 0?void 0:r.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(r=>r.id===t)).forEach(([,t])=>this.detach(t))}setInternal(e){const t=[...this.externalTracks];e.filter(({id:r,language:s,isAuto:n})=>!this.internalTracks.has(r)&&!t.some(([,o])=>o.language===s&&o.isAuto===n)).forEach(r=>this.attach(r)),Array.from(this.internalTracks).filter(([r])=>!e.find(s=>s.id===r)).forEach(([,r])=>this.detach(r))}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)||!Hb(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"),r=>r.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)}}class Ca{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 tu=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},uo=i=>{const e=tu(i);return!!(e&&e.fullscreenElement&&e.fullscreenElement===i)},Gb=i=>{const e=tu(i);return!!(e&&e.pictureInPictureElement&&e.pictureInPictureElement===i)},Yb=3;var qb=(i,e,t=Yb)=>{let r=0,s=0;for(let n=0;n<i.length;n++){const o=i.start(n),l=i.end(n);if(o<=e&&e<=l){if(r=o,s=l,!t)return{from:r,to:s};for(let d=n-1;d>=0;d--)i.end(d)+t>=r&&(r=i.start(d));for(let d=n+1;d<i.length;d++)i.start(d)-t<=s&&(s=i.end(d))}}return{from:r,to:s}};const yt=i=>{const e=T=>a.fromEvent(i,T).pipe(a.mapTo(void 0)),t=["waiting","pause","canplay","play","canplaythrough","playing","seeking","seeked","ended"],r=a.merge(...t.map(T=>a.fromEvent(i,T))).pipe(a.map(T=>T.type==="ended"?i.readyState<2:i.readyState<3),a.filterChanged()),s=a.merge(a.fromEvent(i,"progress"),a.fromEvent(i,"timeupdate")).pipe(a.map(()=>qb(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 T;const E=i.error;return{id:E?`MediaError#${E.code}`:"HtmlVideoError",category:a.ErrorCategory.VIDEO_PIPELINE,message:E?E.message:"Error event from HTML video element",thrown:(T=i.error)!==null&&T!==void 0?T:void 0}})),c=a.fromEvent(i,"timeupdate").pipe(a.map(()=>i.currentTime)),h=new a.Subject,f=.3;let p;c.subscribe(T=>{i.loop&&a.isNonNullable(p)&&a.isNonNullable(T)&&p>=i.duration-f&&T<=f&&h.next(p),p=T});const v=a.fromEvent(i,"enterpictureinpicture"),m=a.fromEvent(i,"leavepictureinpicture"),b=new a.ValueSubject(Gb(i));v.subscribe(()=>b.next(!0)),m.subscribe(()=>b.next(!1));const S=new a.ValueSubject(uo(i));return a.fromEvent(i,"fullscreenchange").pipe(a.map(()=>uo(i))).subscribe(S),{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$:r,currentBuffer$:s,volumeState$:l,playbackRateState$:d,inPiP$:b,inFullscreen$:S}};var Sr=i=>{switch(i){case"mobile":return a.VideoQuality.Q_144P;case"lowest":return a.VideoQuality.Q_240P;case"low":return a.VideoQuality.Q_360P;case"sd":case"medium":return a.VideoQuality.Q_480P;case"hd":case"high":return a.VideoQuality.Q_720P;case"fullhd":case"full":return a.VideoQuality.Q_1080P;case"quadhd":case"quad":return a.VideoQuality.Q_1440P;case"ultrahd":case"ultra":return a.VideoQuality.Q_2160P}},Wb=Ae,zb=fr,Qb=fa,Kb=ha;Wb({target:"Array",proto:!0},{at:function(e){var t=zb(this),r=Qb(t),s=Kb(e),n=s>=0?s:r+s;return n<0||n>=r?void 0:t[n]}});var Jb=wa,Xb=Jb("Array","at"),Zb=Xb,eS=Zb,tS=eS,iS=tS,Ve=or(iS);let Ia=!1,Ue={};const rS=i=>{Ia=i},sS=()=>{Ue={}},aS=i=>{i(Ue)},Fi=(i,e)=>{var t;Ia&&(Ue.meta=(t=Ue.meta)!==null&&t!==void 0?t:{},Ue.meta[i]=e)};class Le{constructor(e){this.name=e}next(e){var t,r;if(!Ia)return;Ue.series=(t=Ue.series)!==null&&t!==void 0?t:{};const s=(r=Ue.series[this.name])!==null&&r!==void 0?r:[];s.push([Date.now(),e]),Ue.series[this.name]=s}}var ct;(function(i){i.FitsContainer="FitsContainer",i.FitsThroughput="FitsThroughput",i.Buffer="Buffer",i.DroppedFramesLimit="DroppedFramesLimit",i.FitsQualityLimits="FitsQualityLimits"})(ct||(ct={}));const nS=new Le("best_bitrate"),oS=(i,e,t)=>(e-t)*Math.pow(2,-10*i)+t;class lS{constructor(){this.history={}}recordSelection(e){this.history[e.id]=a.now()}recordSwitch(e){this.last=e}clear(){this.last=void 0,this.history={}}}const uS='Assertion "ABR Tracks is empty array" failed',gr=(i,{container:e,throughput:t,tuning:r,limits:s,reserve:n=0,forwardBufferHealth:o,playbackRate:l,current:d,history:u,droppedVideoMaxQualityLimit:c,abrLogger:h})=>{var f,p,v,m,b;a.assertNotEmptyArray(i,uS);const S=r.usePixelRatio&&(f=window.devicePixelRatio)!==null&&f!==void 0?f:1,y=r.limitByContainer&&e&&e.width>0&&e.height>0&&{width:e.width*S*r.containerSizeFactor,height:e.height*S*r.containerSizeFactor},T=y&&a.videoSizeToQuality(y),E=r.considerPlaybackRate&&a.isNonNullable(l)?l:1,$=i.filter(R=>!a.isInvariantQuality(R.quality)).sort((R,w)=>a.isHigher(R.quality,w.quality)?-1:1),O=(p=Ve($,-1))===null||p===void 0?void 0:p.quality,M=(v=Ve($,0))===null||v===void 0?void 0:v.quality,F=a.isNullable(s)||a.isNonNullable(s.min)&&a.isNonNullable(s.max)&&a.isLower(s.max,s.min)||a.isNonNullable(s.min)&&M&&a.isHigher(s.min,M)||a.isNonNullable(s.max)&&O&&a.isLower(s.max,O),x=E*oS(o!=null?o:.5,r.bitrateFactorAtEmptyBuffer,r.bitrateFactorAtFullBuffer),U={},I=$.filter(R=>(T?a.isLower(R.quality,T):!0)?(a.isNonNullable(t)&&isFinite(t)&&a.isNonNullable(R.bitrate)?t-n>=R.bitrate*x:!0)?r.lazyQualitySwitch&&a.isNonNullable(r.minBufferToSwitchUp)&&d&&!a.isInvariantQuality(d.quality)&&(o!=null?o:0)<r.minBufferToSwitchUp&&a.isHigher(R.quality,d.quality)?(U[R.quality]=ct.Buffer,!1):!!c&&a.isHigherOrEqual(R.quality,c)?(U[R.quality]=ct.DroppedFramesLimit,!1):F||(a.isNullable(s.max)||a.isLowerOrEqual(R.quality,s.max))&&(a.isNullable(s.min)||a.isHigherOrEqual(R.quality,s.min))?!0:(U[R.quality]=ct.FitsQualityLimits,!1):(U[R.quality]=ct.FitsThroughput,!1):(U[R.quality]=ct.FitsContainer,!1))[0];I&&I.bitrate&&nS.next(I.bitrate);const P=(m=I!=null?I:$[Math.ceil(($.length-1)/2)])!==null&&m!==void 0?m:i[0];P.quality!==((b=u==null?void 0:u.last)===null||b===void 0?void 0:b.quality)&&h({message:`
7
7
  [available tracks]
8
8
  ${i.map(R=>`{ id: ${R.id}, quality: ${R.quality}, bitrate: ${R.bitrate} }`).join(`
9
9
  `)}