import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var HV="Cannot seek during ads playout.",IV="Cannot switch track",JV="Media session does not exist.",KV="No receivers available",LV="Reset ABR functionality not available on cast.",MV="SDK not yet ready",NV="Sender is destroyed.",OV="clpp.cast.CastProxy",PV="clpp.cast.Player",QV="clpp.cast.Receiver",RV="urn:x-cast:castlabs",SV="urn:x-cast:com.google.cast.media",TV=function(a){return _.x(function*(){yield _.Nr(a,_.He);yield _.Nr(a,_.Ge)})},UV=function(a){return JSON.stringify(a,(b,c)=>
{if("license"!==b&&typeof c!==_.Yd){if(c instanceof Event){b={};for(const d in c){const e=c[d];typeof e===_.Ce?"detail"===d&&(b[d]=e):d in Event||(b[d]=e)}return b}return typeof c===_.t?isNaN(c)?"NaN":isFinite(c)?c:0>c?"-Infinity":"Infinity":c}})},VV=function(a){if(typeof a!==_.Nf)return a;try{return JSON.parse(a,(b,c)=>"NaN"===c?NaN:"-Infinity"===c?-Infinity:"Infinity"===c?Infinity:c)}catch(b){return a}},WV=function(a,b,c,d){return _.x(function*(){if(b.includes(a.mimeType))return a;var e=null;let f=
null,g=null;for(var h=0;h<b.length&&!f;)g=b[h++],f=_.dk(d,a.mimeType,g);f&&g&&(h=_.mj(a.url),(h=yield c.fetch(h).T)&&h.data&&(e=f.a(_.K(h.data)),e={url:URL.createObjectURL(new Blob([e])),kind:a.kind,language:a.language,label:a.label,mimeType:g}));return e})},XV=function(a,b){let c,d;if(window.chrome&&chrome.cast&&chrome.cast.media)c=chrome.cast.media.HlsSegmentFormat,d=chrome.cast.media.HlsVideoSegmentFormat;else if(window.cast&&cast.framework&&cast.framework.messages)c=cast.framework.messages.HlsSegmentFormat,
d=cast.framework.messages.HlsVideoSegmentFormat;else return;switch(a){case _.pg:return d.FMP4;case _.og:return b===_.N?d.MPEG2_TS:c.TS;case _.Ac:return c.AAC;case _.Dc:return c.AC3;case _.Ec:return c.E_AC3;case "audio/mpeg":return c.MP3;case _.Fc:return c.FMP4}},ZV=function(a){a=void 0===a?YV:a;var b=cast.framework.messages||chrome.cast.media;if(!b)throw new _.I(1,8,8001);const c=b.MetadataType,d=b.GenericMediaMetadata,e=b.MovieMediaMetadata,f=b.TvShowMediaMetadata,g=b.MusicTrackMediaMetadata,h=b.PhotoMediaMetadata;
b=b.AudiobookChapterMediaMetadata;switch(a){case c.MOVIE:return new e;case c.TV_SHOW:return new f;case c.MUSIC_TRACK:return new g;case c.PHOTO:return new h;case c.AUDIOBOOK_CHAPTER:return new b;default:return new d}},$V=function(a,b){return a.h.filter(c=>c.type===b)},bW=function(a,b){const c=aW(a);return $V(a,b).find(d=>c.includes(d.id))||null},dW=function(a,b,c){const d=a.a.a;if(d)if(c){a.f[b]=c.renditions[0];c=[+c.id];if(b!==_.L){const e=a.wa();e&&c.push(+e.id)}c=new chrome.cast.media.EditTracksInfoRequest(c);
d.editTracksInfo(c,()=>{a.f[b]=null;cW(a,b)},e=>{a.f[b]=null;a.g.debug(IV,e)})}else b===_.L&&(c=new chrome.cast.media.EditTracksInfoRequest([]),d.editTracksInfo(c,()=>{cW(a,b)},e=>{a.g.debug(IV,e)}))},aW=function(a){a=a.a?a.a.a:null;return(a?a.activeTrackIds||[]:[]).map(b=>b.toString())},cW=function(a,b){b===_.M?a.a.trigger(new _.F(_.Ic)):b===_.L&&a.a.trigger(new _.F(_.Uf))},gW=function(a){if(a)for(const b of eW)fW(b)},fW=function(a){if(!a.w&&window.chrome&&chrome.cast&&chrome.cast.isAvailable&&window.cast&&
cast.framework&&cast.framework.CastContext&&a.S.length){a.w=!0;a.o.kf();var b=cast.framework.CastContext.getInstance(),c=new cast.framework.CastOptions;c.receiverApplicationId=a.S;c.autoJoinPolicy=chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED;b.setOptions(c);b.addEventListener(cast.framework.CastContextEventType.CAST_STATE_CHANGED,a.M);b.addEventListener(cast.framework.CastContextEventType.SESSION_STATE_CHANGED,a.da);hW&&a.o.ka(.02)}},iW=function(a){return _.x(function*(){eW.delete(a);if(a.w){a.w=!1;var b=
cast.framework.CastContext.getInstance();b.removeEventListener(cast.framework.CastContextEventType.CAST_STATE_CHANGED,a.M);b.removeEventListener(cast.framework.CastContextEventType.SESSION_STATE_CHANGED,a.da)}b=[];a.f&&(b.push(a.f.destroy()),a.f=null);a.j&&(b.push(a.j.destroy()),a.j=null);yield Promise.all(b);a.A=!1;a.o&&(a.o.stop(),a.o=null);a.R=null;a.X=null})},jW=function(a){return _.x(function*(){a.Mb()||(yield cast.framework.CastContext.getInstance().requestSession())})},lW=function(a,b,c){c=
void 0===c?0:c;return _.x(function*(){var d=a.f.wa();d&&d.language&&(a.h.preferredTextLanguage=d.language);(d=a.f.qa())&&d.language&&(a.h.preferredAudioLanguage=d.language);yield kW(a,{source:a.getLoadedSource(),currentTime:c,isLive:a.isLive(),Ve:a.getPresentationStartTime(),autoplay:b,ib:a.h})})},kW=function(a,b){return _.x(function*(){var c=chrome.cast.media.StreamType;yield jW(a);if(b){var d=cast.framework.CastContext.getInstance().getCurrentSession(),e=new chrome.cast.media.MediaInfo(b.source.url,
b.source.type);e.streamType=b.isLive?c.LIVE:c.BUFFERED;c=b.audioMimeType;e.hlsVideoSegmentFormat=XV(b.Zb,_.N);e.hlsSegmentFormat=XV(c,_.M);b.ib&&(a.L&&(c=yield Promise.resolve(a.L(b.ib)))&&(b.ib=c),a.h=b.ib,a.C=_.Zo(a.h),a.B=a.C.findIndex(k=>k.url===b.source.url),b.ib.remoteTextTracks&&(c=yield Promise.all(b.ib.remoteTextTracks.map(a.za.bind(a))),e.tracks=c.filter(k=>k),b.ib.remoteTextTracks=void 0),delete b.ib.autoplay,b.ib.startTime=null,e.customData={playerConfiguration:UV(b.ib)});c=a.Eb()||{};
var f=mW(c.metadataType),g;typeof b.Ve===_.t&&(g={metadataType:f,sectionStartAbsoluteTime:b.Ve});var h;b.source.name&&(h={metadataType:f,title:b.source.name});c=nW(c);if(g=oW(Object.assign({},g,h,c)))e.metadata=g;e=new chrome.cast.media.LoadRequest(e);typeof b.autoplay===_.Lc&&(e.autoplay=b.autoplay);typeof b.currentTime===_.t&&(e.currentTime=b.currentTime);yield d.loadMedia(e)}})},oW=function(a){if(!a)return null;a:{var b=a.metadataType;const c=Object.entries(pW);for(const d of c){const [e,f]=d;
if(f===b){b=e;break a}}b=null}if(!b)return null;b=ZV(pW[b]);return Object.assign(b,a)},mW=function(a){var b=void 0===b?YV:b;return Object.values(pW).includes(a)?a:b},nW=function(a){const b={};for(const c in a)void 0!==a[c]&&(b[c]=a[c]);return b},rW=function(a,b){qW(a,b.getMediaSession());b.addEventListener(cast.framework.SessionEventType.MEDIA_SESSION,a.V);b.addMessageListener(RV,a.P)},sW=function(a){const b=a.getPosition();a.a&&a.a.media?(a=a.a.media.startAbsoluteTime,a=typeof a!==_.t?null:a):a=
null;a=null===a?null:a+b;return null===a?b:a},qW=function(a,b){a.a=b;a.a&&(a.G.release(),a.F=null,a.l=null,a.l=new cast.framework.RemotePlayer,a.F=new cast.framework.RemotePlayerController(a.l),a.G.on(a.F,cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED,a.ia.bind(a)),a.G.on(a.F,cast.framework.RemotePlayerEventType.MEDIA_INFO_CHANGED,a.bb.bind(a)),a.j&&a.j.init(),a.trigger(new _.F(_.me)))},vW=function(a){return new tW(a.h,()=>{a.trigger(new _.F(_.Rc))},(b,c)=>{{const d=a.f.getConfiguration();
d.source=c.source;d.autoplay=!1;d.startTime=c.currentTime?Math.max(c.currentTime-1,0):null;d.ima&&d.startTime&&(d.ima.playAdsAfterTime=d.startTime);c.Ef&&(d.preferredAudioLanguage=c.Ef);c.Fg&&(d.preferredTextLanguage=c.Fg);_.Pr(a.f,null);a.trigger(new _.F("castingended"));a.j(b,d)}},()=>uW(a))},uW=function(a){return _.x(function*(){a.trigger(new _.F(_.Qc));a.f.a!==a.a&&a.f&&a.a&&(yield a.f.release(),_.Pr(a.f,a.a))})},yW=function(a,b,c){return _.x(function*(){var d=b.adTagUrl;if(d)try{wW=!1;const e=
_.mj(d),f=yield c.fetch(e).T;if(f&&f.data){const g=_.Ui(f.data),h=(new DOMParser).parseFromString(g,_.Tf);if(h.getElementsByTagName("vmap:VMAP").length)_.C("VMAP detected."),a.vmapAdsRequest=xW(g);else if(h.getElementsByTagName("VAST").length){_.C("VAST detected.");{d=g;const k=new cast.framework.messages.BreakClip("bc1");k.vastAdsRequest=xW(d);const l=new cast.framework.messages.Break("b1",[k.id],0);a.breakClips=[k];a.breaks=[l]}}else _.C("Unsupported schema."),wW=!0}}catch(e){_.C("Failed to fetch an ad",
e),wW=!0}})},xW=function(a){const b=new cast.framework.messages.VastAdsRequest;b.adsResponse=a;return b},zW=function(a,b){b=new _.I(1,10,10003,{errorType:b});a.m.onError(b)},AW=function(){return cast.framework.CastReceiverContext.getInstance().getPlayerManager()},CW=function(a,b,c){if(c instanceof cast.framework.events.BreaksEvent||-1!==a.getPosition()){var d=null;(c=BW(a,c))&&(d={ad:c});a.m.trigger(new _.F(b,d))}},BW=function(a,b){let c=null;if(a.a&&b instanceof cast.framework.events.BreaksEvent){let d=
null,e=null,f;typeof b.breakClipId===_.Nf&&(d=a.a.getBreakClipById(b.breakClipId));typeof b.breakId===_.Nf&&(e=a.a.getBreakById(b.breakId),!e&&d&&(e=a.a.getBreaks().find(g=>g.breakClipIds.includes(d.id))||null),e&&(f=a.a.getBreaks().filter(g=>0<=g.position).sort((g,h)=>g.position-h.position).findIndex(g=>g===e)));c=new Z(d,e,b.index,b.total,f)}return c},DW=function(){return[cast.framework.events.EventType.PLAYER_LOAD_COMPLETE,cast.framework.events.EventType.TIMED_METADATA_CHANGED,cast.framework.events.EventType.TIMED_METADATA_ENTER,
cast.framework.events.EventType.TIMED_METADATA_EXIT]},EW=function(a){const b=a.dashTimedMetadata;let c=_.hg;b&&(c=b.schemeIdUri);return{type:c.startsWith(_.gg)?_.Ph:_.eg,schemeIdUri:c,id:a.id||"",startTime:a.startTime,endTime:a.endTime,value:b&&b.value||"",eventElement:b?b.eventElement:null}},FW=function(){return cast.framework.CastReceiverContext.getInstance().getPlayerManager()},HW=function(a){a.a=FW().getTextTracksManager();const b=a.a.getTracks();a.j=GW(_.L,b)},GW=function(a,b){const c=[];for(const d of b)b=
new _.Ij(d.trackId.toString(),a),b.roles=d.roles||[],b.kind=d.subtype||null,b.language=d.language||null,b.originalLanguage=d.language||null,b.label=d.name||null,b.src=d.trackContentId||null,b.mimeType=d.trackContentType||null,d.customData&&(b.mimeType=d.customData.mimeType||b.mimeType,b.src=d.customData.url||b.src),b.renditions.push(new _.Qj(b.id,b)),c.push(b);return c},IW=function(a,b,c,d){c=_.$h(c).filter(g=>g);var e=!1;let f=[];b===_.M?f=a.getAudioTracks():b===_.L&&(f=a.ma());if(c=c.find(g=>{const h=
_.Bi(g);return f.some(k=>{k=_.Bi(k.language||"");return _.Ci(h,k)})})){const g=_.Bi(c);c=f.filter(h=>{h=_.Bi(h.language||"");return _.Ci(g,h)});f=c.length?c:f;e=e||!!c.length}_.cj(d)&&(c=f.filter(g=>g.roles.includes(d)),f=c.length?c:f,e=e||!!c.length);e&&f[0]&&(e=f[0],a.g.info("Will select track",e),b===_.M?a.xa(e):b===_.L&&a.Sa(e))},JW=function(){return cast.framework.CastReceiverContext.getInstance().getPlayerManager()},MW=function(a,b){var c=()=>{b.protectionSystem=cast.framework.ContentProtection.NONE;
b.licenseUrl=void 0;b.licenseRequestHandler=void 0;b.licenseHandler=void 0};if(a&&a.drm){var d=a.drm,e=_.Tl(d);if(e){var f=[_.rd];_.Zo(a)[0].type!==_.yc&&f.unshift(_.td);d.preferredDrmSystem===_.rd&&f.reverse();for(var g,h;f.length&&!h;)g=f.shift(),h=e.Ia[g];h?(c=g===_.td?cast.framework.ContentProtection.WIDEVINE:g===_.rd?cast.framework.ContentProtection.PLAYREADY:void 0,b.protectionSystem=c,b.licenseUrl=h.licenseUrl,c={ldlDelay:0,customData:{}},KW(b,h,a,c),LW(b,h,a,c)):c()}else c()}else c()},KW=
function(a,b,c,d){b.modifiers.licenseRequest?a.licenseRequestHandler=e=>{const f=_.mj({method:_.cb,uris:[e.url]});e.headers&&(f.headers=e.headers);f.body=e.content;f.allowCrossSiteCredentials=e.withCredentials;b.modifiers.licenseRequest(c,f,d);e.url=f.uris[0];e.headers=f.headers;e.content=f.body;e.withCredentials=f.allowCrossSiteCredentials}:a.licenseRequestHandler=void 0},LW=function(a,b,c,d){b.modifiers.licenseResponse?a.licenseHandler=(e,f)=>_.x(function*(){const g=_.qj(Object.assign({},f.headers),
e.buffer,200,"");yield b.modifiers.licenseResponse(c,g,d);return _.K(g.data)}):a.licenseHandler=void 0},PW=function(){return NW||(NW=new OW)},QW=function(){return cast.framework.CastReceiverContext.getInstance()},RW=function(){const a=QW().getPlayerManager().getMediaInformation();return a&&a.metadata?a.metadata:null},SW=function(a,b){const c=QW().getPlayerManager().getMediaInformation();c?(b?c.metadata=b:delete c.metadata,a=!0,a=void 0===a?!1:a,QW().getPlayerManager().setMediaInformation(c,a)):a.g.warn("No mediaInformation is present. Skipping metadata update.")},
UW=function(a,b){a.g.debug("Detected HLS, parsing");var c=cast.framework.messages.HlsVideoSegmentFormat;a=QW();var {hlsVideoSegmentFormat:d}=QW().getPlayerManager().getMediaInformation()||{};c=d===c.FMP4?_.pg:_.og;b=b.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");b=b.split(/\n+/m);d=[];let e=0;for(;e<b.length;){const f=b[e].trim();if(b[e].startsWith("#EXT-X-STREAM-INF")){const g=TW(f,_.oa),h=TW(f,_.kb);let [k,l]=[];h&&([k,l]=h.split("x").map(m=>+m));if(!a.canDisplayType(c,g,k,l)){e+=2;continue}}d.push(f);
++e}return d.join("\n")},TW=function(a,b){let c;b+="\x3d";let d=a.indexOf(b);0<=d&&(c=a.substring(d+b.length),c.startsWith('"')?(c=c.substring(1),c=c.substring(0,c.indexOf('"'))):(d=c.indexOf(","),0<=d&&(c=c.substring(0,d))));return c},WW=function(a,b){let c=null;const d=VW(a);d&&(c={ad:d});a.f.trigger(new _.F(b,c))},VW=function(a){var b=null;if(a.a&&a.a.mediaInfo){b=a.a.mediaInfo;let c=null,d=null,e,f;const g=a.a.currentBreakClipNumber;b.breaks&&(c=b.breaks.find(h=>h.id===a.a.breakId)||null)&&(e=
c.breakClipIds.length,f=0>=c.position?c.position:b.breaks.filter(h=>0<=h.position).sort((h,k)=>h.position-k.position).findIndex(h=>h===c));b.breakClips&&(d=b.breakClips.find(h=>h.id===a.a.breakClipId)||null);b=new Z(d,c,g,e,f)}return b},XW=class{constructor(a,b){this.log=new _.S(b);this.player=a;this.l=null;this.h=_.To;this.o=_.hv;this.j=2;this.C=Date.now();this.B=-1}release(){this.a(_.To)}destroy(){this.l=this.player=null;return Promise.resolve()}getState(){return this.h}onError(a){a.severity===
_.G&&this.a(_.Mo)}a(a){if(a!==this.h)if(this.h===_.Mo&&a!==_.To)this.log.debug("Player is in ERROR state and can not switch to",a);else{var b=Date.now();this.o=this.h;this.h=a;this.h===_.Po?(this.B=b,this.player.trigger(new _.F(_.Nc,{detail:{bufferedTimeMS:-1,reason:this.j}}))):this.o===_.Po&&this.player.trigger(new _.F(_.Mc,{detail:{bufferedTimeMS:b-this.B,reason:this.j}}));a={currentState:this.h,previousState:this.o,timeSinceLastStateChangeMS:b-this.C};this.C=b;this.l&&_.Eo(this.l,this.h);this.player.trigger(new _.F(_.Kf,
{detail:a}))}}};_.z("clpp.cast.CastUtils",class{});var YV=0,pW={GENERIC:YV,MOVIE:1,TV_SHOW:2,MUSIC_TRACK:3,PHOTO:4,AUDIOBOOK_CHAPTER:5};var YW=class extends XW{constructor(a){super(a,"clpp.cast.SenderStateManager");this.w=this.f=null;this.A=this.Vb.bind(this)}init(){const a=this.player,b=a.a;b&&(this.f&&this.f.removeUpdateListener(this.A),this.f=b,this.f.addUpdateListener(this.A),this.w=a.l)}destroy(){const a=this,b=()=>Object.getPrototypeOf(Object.getPrototypeOf(this)).destroy;return _.x(function*(){a.f&&(a.f.removeUpdateListener(a.A),a.f=null);yield b().call(a)})}a(a){const b=this.player.l;b&&b.isPlayingBreak||super.a(a)}Vb(){if(this.f&&
this.w&&!this.w.isPlayingBreak)switch(this.f.playerState){case chrome.cast.media.PlayerState.IDLE:switch(this.f.idleReason){case chrome.cast.media.IdleReason.FINISHED:this.a(_.Lo);break;case chrome.cast.media.IdleReason.ERROR:this.a(_.Mo);break;default:this.a(_.To)}break;case chrome.cast.media.PlayerState.PLAYING:this.a(_.Wo);break;case chrome.cast.media.PlayerState.PAUSED:this.a(_.Vo);break;case chrome.cast.media.PlayerState.BUFFERING:this.a(_.Po)}}};var ZW=class extends _.T{constructor(){super();this.g=new _.S("clpp.cast.SenderTrackManager");this.a=null;this.h=[];this.f={}}initialize(a){this.a=a}release(){this.h=[];this.f={}}load(){this.release();var a=this.a.a;a&&(a=a.media)&&(this.h=(a=a.tracks)?a.map(b=>{switch(b.type){case chrome.cast.media.TrackType.VIDEO:var c=_.N;break;case chrome.cast.media.TrackType.AUDIO:c=_.M;break;case chrome.cast.media.TrackType.TEXT:c=_.L}c=new _.Ij(b.trackId.toString(),c);c.kind=b.subtype;c.language=b.language;
c.label=b.name;c.src=b.trackContentId;c.mimeType=b.trackContentType;b.customData&&(c.src=b.customData.url||c.src,c.mimeType=b.customData.mimeType||c.mimeType);c.renditions.push(new _.Qj(c.id,c));return c}):[],this.a.trigger(new _.F(_.$f)))}destroy(){this.a=null}getVideoTracks(){return $V(this,_.N)}getAudioTracks(){return $V(this,_.M)}ma(){return $V(this,_.L)}na(){const a=this.Ea();return a?a.renditions[0]:null}Ma(){const a=this.qa();return a?a.renditions[0]:null}Qa(){const a=this.wa();return a?a.renditions[0]:
null}rb(){return this.f[_.N]||null}Fb(){return this.f[_.M]||null}Gb(){return this.f[_.L]||null}Ea(){return bW(this,_.N)}qa(){return bW(this,_.M)}wa(){return bW(this,_.L)}Ab(a){dW(this,_.N,a)}xa(a){dW(this,_.M,a)}Sa(a){dW(this,_.L,a)}jb(a){this.Ab(a&&a.track)}yb(a){this.xa(a&&a.track)}zb(a){this.Sa(a&&a.track)}addTextTrack(){return _.x(function*(){})}ta(){return!0}};ZW.prototype.isAbrEnabled=ZW.prototype.ta;ZW.prototype.addTextTrack=ZW.prototype.addTextTrack;ZW.prototype.setTextRendition=ZW.prototype.zb;
ZW.prototype.setAudioRendition=ZW.prototype.yb;ZW.prototype.setVideoRendition=ZW.prototype.jb;ZW.prototype.setTextTrack=ZW.prototype.Sa;ZW.prototype.setAudioTrack=ZW.prototype.xa;ZW.prototype.setVideoTrack=ZW.prototype.Ab;ZW.prototype.getTextTrack=ZW.prototype.wa;ZW.prototype.getAudioTrack=ZW.prototype.qa;ZW.prototype.getVideoTrack=ZW.prototype.Ea;ZW.prototype.getLoadingTextRendition=ZW.prototype.Gb;ZW.prototype.getLoadingAudioRendition=ZW.prototype.Fb;ZW.prototype.getLoadingVideoRendition=ZW.prototype.rb;
ZW.prototype.getTextRendition=ZW.prototype.Qa;ZW.prototype.getAudioRendition=ZW.prototype.Ma;ZW.prototype.getVideoRendition=ZW.prototype.na;ZW.prototype.getTextTracks=ZW.prototype.ma;ZW.prototype.getAudioTracks=ZW.prototype.getAudioTracks;ZW.prototype.getVideoTracks=ZW.prototype.getVideoTracks;var tW=class extends _.su{constructor(a,b,c,d){super();this.g=new _.S(_.dd);this.S=a;this.o=new _.rk(b);this.R=c;this.X=d;this.h=this.I=_.rl();this.C=[];this.B=0;this.K=new _.zr;this.F=this.l=this.a=null;this.A=this.w=!1;this.ba="";this.fa=1E6;this.f=new ZW;this.f.initialize(this);this.j=new YW(this);this.G=new _.Nt;this.J=null;this.H=new Set;this.M=this.Ja.bind(this);this.da=this.Db.bind(this);this.V=this.Cb.bind(this);this.P=this.Ua.bind(this);this.L=null;window.cast||Object.defineProperty(window,
"cast",{get:()=>window.cast_,set:e=>{window.cast_=e;window.setTimeout(()=>{gW(!0)},0)}});fW(this);eW.add(this)}init(a,b){this.h=this.I=b}unload(){return new Promise((a,b)=>{this.f&&this.f.release();this.a&&!this.a.idleReason||a();this.a.stop(null,a,b)})}release(){return this.unload().then(()=>{this.j&&this.j.release()})}getTimeline(){return null}setupPlaylist(){return Promise.reject(_.Za)}appendLoad(){return Promise.reject(_.Za)}seekWith(){return Promise.reject(_.Za)}setSeekInterceptor(){}setPlaybackSessionId(){}getBandwidthEstimate(){return null}destroy(){return _.x(function*(){})}Cd(a){this.L=
a}xc(){return this.w}Mb(){return this.A}Ee(){return this.ba}sendMessage(a,b){const c=this;return _.x(function*(){let d;const e=cast.framework.CastContext.getInstance().getCurrentSession();if(e)try{yield e.sendMessage(a,UV(b))}catch(f){d=new _.I(1,8,8E3,{detailedErrorCode:f})}else d=new _.I(1,8,8004,void 0);if(d)c.onError(d)})}cast(){const a=this;return _.x(function*(){if(!a.xc())throw a.g.warn(MV),new _.I(1,8,8001,void 0);if(!hW)throw a.g.warn(KV),new _.I(1,8,8002,void 0);if(a.Mb())throw a.g.warn("Already casting"),
new _.I(1,8,8003,void 0);try{yield jW(a)}catch(b){const c={};b instanceof chrome.cast.Error?(c.detailedErrorCode=b.code,c.details=b.details,c.reason=b.description):c.detailedErrorCode=b;throw new _.I(1,8,8E3,c);}})}De(){this.Mb()&&cast.framework.CastContext.getInstance().endCurrentSession(!0)}addMessageListener(a){typeof a===_.Yd&&this.H.add(a)}removeMessageListener(a){typeof a===_.Yd&&this.H.delete(a)}play(){return this.isEnded()?lW(this,!0):new Promise((a,b)=>{if(!this.a)return b(JV);this.a.play(null,
a,b)})}pause(){return new Promise((a,b)=>{this.isEnded()&&a();if(!this.a)return b(JV);this.a.pause(null,a,b)})}isPaused(){return!!this.a&&this.a.playerState===chrome.cast.media.PlayerState.PAUSED}isEnded(){return this.getState()===_.Lo}seek(a){return this.isEnded()?lW(this,!1,a):new Promise((b,c)=>{this.a||c(JV);this.l.isPlayingBreak&&c(HV);const d=new chrome.cast.media.SeekRequest;d.currentTime=a;this.trigger(new _.F(_.jg));this.a.seek(d,()=>{this.trigger(new _.F(_.ig));b()},c)})}getPosition(){return this.getMediaPosition()}getMediaPosition(){return this.a&&
this.a.getEstimatedTime()||0}getDuration(){return this.getMediaDuration()}getMediaDuration(){if(!this.a||!this.a.media)return-1;const a=this.a.media.duration;return typeof a!==_.t?-1:-1===a?Infinity:a}setDrmCustomDataModifier(){}setCdnErrorCallback(){}detach(){}getPlaybackRate(){return this.a&&this.a.playbackRate||0}setPlaybackRate(a){this.a&&0<a&&this.sendMessage(SV,{type:"SET_PLAYBACK_RATE",requestId:Math.round(1E3*Math.random()),mediaSessionId:this.a.mediaSessionId,playbackRate:a})}getVolume(){return this.a&&
this.a.volume.level}setVolume(a){this.a&&0<=a&&1>=a&&(a=new chrome.cast.media.VolumeRequest(new chrome.cast.Volume(a)),this.a.setVolume(a))}isMuted(){return this.a&&this.a.volume.muted}setMuted(a){this.a&&(a=new chrome.cast.media.VolumeRequest(new chrome.cast.Volume(void 0,a)),this.a.setVolume(a))}getPresentationStartTime(){if(!this.a||!this.a.media||!this.a.media.metadata)return null;const a=this.a.media.metadata.sectionStartAbsoluteTime;return typeof a!==_.t?null:1E-8===a?0:a}getSeekRange(){let a=
{start:0,end:this.getDuration()};if(this.isLive()){const b=this.a.getEstimatedLiveSeekableRange();b&&typeof b.start===_.t&&typeof b.end===_.t&&(a={start:b.start,end:b.end})}return a}getState(){return this.j?this.j.getState():_.hv}getStats(){return this.a&&this.a.customData&&this.a.customData.stats?VV(this.a.customData.stats):_.Io()}isLive(){return Infinity===this.getDuration()}load(a){const b=this;return _.x(function*(){if(b.xc())if(hW){b.C=_.Zo(a);b.h=_.tl(b.I,a);var c=b.C[b.B];yield kW(b,{source:c,
isLive:c.isLive,autoplay:b.h.autoplay,ib:b.h,Zb:c.Zb,audioMimeType:c.audioMimeType})}else b.g.warn(KV);else b.g.warn(MV)})}getBufferInfo(){return new _.ru}getTrackManager(){return this.f}getConfiguration(){return this.h}getSurface(){return null}setNetworkEngine(a){this.K=a}getNetworkEngine(){return this.K}getSourceIndex(){return this.B}setSourceIndex(a){this.B=a}setCmsdManager(){}getLoadedSource(){return this.C[this.B]}getPeriods(){return[]}getDrmInfo(){return null}getTimelineCues(){return[]}getCueTimeline(){return null}resetAbr(){this.g.warn(LV)}onError(a){if(a&&
(this.trigger(new _.F(_.q,{detail:a})),this.j))this.j.onError(a)}namespace(){return _.dd}canPlay(){return this.xc()?2:0}Eb(){return this.J}Yb(a){this.J=oW(a)}ze(){this.J=null}ef(a){const b=this.Eb()||{};a={metadataType:mW(b.metadataType),title:a};this.Yb(Object.assign({},b,a))}cf(a){const b=this.Eb()||{},c=mW(b.metadataType);a=new chrome.cast.Image(a);this.Yb(Object.assign({},b,{metadataType:c,images:[a]}))}bf(a){const b=this.Eb()||{};this.Yb(Object.assign({},b,{metadataType:3,artist:a}))}df(a){const b=
this.Eb()||{};a={metadataType:mW(b.metadataType),releaseDate:a};this.Yb(Object.assign({},b,a))}Ja(a){const b=cast.framework.CastContext.getInstance(),c=a.castState===cast.framework.CastState.CONNECTED;hW=a.castState!==cast.framework.CastState.NO_DEVICES_AVAILABLE;this.ba=c?b.getCurrentSession().getCastDevice().friendlyName:"";this.o.kf()}Db(a){this.g.debug(`state: ${a.sessionState}, details:`,a);switch(a.sessionState){case cast.framework.SessionState.SESSION_STARTED:this.A=!0;rW(this,a.session);break;
case cast.framework.SessionState.SESSION_RESUMED:this.Mb()||(this.A=!0,rW(this,a.session),this.X());break;case cast.framework.SessionState.SESSION_ENDED:if(this.Mb()&&this.a){const d=this.a.media;var b=this.f.qa(),c=this.f.wa();b=b&&b.language||void 0;c=c&&c.language||void 0;this.R(this.getState(),{source:{url:d.contentId,type:d.contentType,isLive:this.isLive()},currentTime:sW(this),Fg:c,Ef:b})}a.session.removeEventListener(cast.framework.SessionEventType.MEDIA_SESSION,this.V);a.session.removeMessageListener(RV,
this.P);this.A=!1;this.a=null;this.G.release();this.l=this.F=null}}Cb(a){this.g.debug("New media session",a.mediaSession);qW(this,a.mediaSession)}bb(a){a.value&&a.value.tracks&&this.f&&this.f.load()}Ua(a,b){if(a===RV&&0<this.H.size){const c=VV(b);this.H.forEach(d=>d(c))}}ia(){this.trigger(new _.F(_.Zf))}za(a){const b=this;return _.x(function*(){let c=null;const d=yield WV(a,[_.Sf,_.xc],b.K,b.h);d&&(c=new chrome.cast.media.Track(b.fa++,chrome.cast.media.TrackType.TEXT),c.language=d.language,c.name=
d.label||null,c.trackContentId=d.url,c.trackContentType=d.mimeType,c.customData={mimeType:a.mimeType,url:a.url});return c})}getTextDisplayer(){return null}},hW=!1,eW=new Set;window.__onGCastApiAvailable=gW;var $W=class extends _.su{constructor(a,b,c){super();this.f=a;this.h=b;this.j=typeof c===_.Yd?c:this.l;this.a=vW(this);this.g=new _.S(OV);this.f&&this.forwardEventsTo(this.f)}destroy(){const a=this;return _.x(function*(){a.a&&(yield iW(a.a),a.a=null);a.f&&a.stopForwardingEventsTo(a.f)})}l(a,b){this.f&&a!==_.Lo&&a!==_.To&&(delete b.license,this.f.load(b))}we(){return!!this.a&&this.a.xc()&&hW}Mb(){return!!this.a&&this.a.Mb()}Ee(){return this.a?this.a.Ee():""}Cd(a){this.a&&this.a.Cd(a)}cast(a){const b=
this;return _.x(function*(){if(b.a)try{if(yield b.a.cast(),b.f&&b.a){{let d=null;const e=b.f.getLoadedSource();if(e){const f=b.f.getTrackManager(),g=f.getVideoTracks()[0];let h,k;g&&g.mimeType&&(h=g.mimeType);const l=b.f.getConfiguration(),m=f.qa();m&&(m.mimeType&&(k=m.mimeType),m.language&&(l.preferredAudioLanguage=m.language),m.roles.length&&(l.preferredAudioRole=m.roles[0]));const n=f.wa();n&&(n.language&&(l.preferredTextLanguage=n.language),n.roles.length&&(l.preferredTextRole=n.roles[0]));const r=
e&&typeof e.isLive===_.Lc?e.isLive:b.f.isLive();d={source:e,isLive:r,autoplay:!b.f.isPaused(),currentTime:Math.max(b.f.getPosition()-1,0),Ve:b.f.getPresentationStartTime(),Zb:h,audioMimeType:k,ib:l}}var c=d}yield uW(b);b.a&&(c&&(c.autoplay=!b.f.isPaused()),a?yield b.f.load(a):b.a.a||(yield kW(b.a,c)))}}catch(d){b.g.error("Error while trying to cast",d),c=new _.F(_.q,{detail:d}),b.trigger(c)}})}De(){this.a&&this.a.De()}hh(a){const b=this;return _.x(function*(){a!==b.h&&(b.h=a,b.a&&(yield iW(b.a)),
b.a=vW(b))})}sendMessage(a){const b=this;return _.x(function*(){b.a?yield b.a.sendMessage(RV,a):b.g.warn(NV)})}addMessageListener(a){this.a?this.a.addMessageListener(a):this.g.warn(NV)}removeMessageListener(a){this.a?this.a.removeMessageListener(a):this.g.warn(NV)}Eb(){return this.a&&this.a.Eb()}Yb(a){this.a&&this.a.Yb(a)}ze(){this.a&&this.a.ze()}ef(a){this.a&&this.a.ef(a)}cf(a){this.a&&this.a.cf(a)}bf(a){this.a&&this.a.bf(a)}df(a){this.a&&this.a.df(a)}};_.z(OV,$W);
$W.prototype.setContentReleaseDate=$W.prototype.df;$W.prototype.setContentArtist=$W.prototype.bf;$W.prototype.setContentImage=$W.prototype.cf;$W.prototype.setContentTitle=$W.prototype.ef;$W.prototype.clearContentMetadata=$W.prototype.ze;$W.prototype.setContentMetadata=$W.prototype.Yb;$W.prototype.getContentMetadata=$W.prototype.Eb;$W.prototype.removeMessageListener=$W.prototype.removeMessageListener;$W.prototype.addMessageListener=$W.prototype.addMessageListener;$W.prototype.sendMessage=$W.prototype.sendMessage;
$W.prototype.changeReceiverId=$W.prototype.hh;$W.prototype.forceDisconnect=$W.prototype.De;$W.prototype.cast=$W.prototype.cast;$W.prototype.setPlayerConfigInterceptor=$W.prototype.Cd;$W.prototype.getReceiverName=$W.prototype.Ee;$W.prototype.isCasting=$W.prototype.Mb;$W.prototype.canCast=$W.prototype.we;$W.prototype.destroy=$W.prototype.destroy;var aX=class extends XW{constructor(a){super(a,"clpp.cast.StateManager");this.I=this.S.bind(this);this.H=this.R.bind(this);this.A=this.da.bind(this);this.w=this.ba.bind(this);this.K=this.X.bind(this);this.J=this.V.bind(this);this.L=this.ia.bind(this);this.G=this.fa.bind(this);this.F=this.P.bind(this);this.f=this.M.bind(this)}init(){const a=cast.framework.events.EventType,b=cast.framework.CastReceiverContext.getInstance().getPlayerManager();b.addEventListener(a.PLAYING,this.I);b.addEventListener(a.PAUSE,
this.H);b.addEventListener(a.MEDIA_FINISHED,this.A);b.addEventListener(a.BUFFERING,this.w);b.addEventListener(a.SEEKING,this.K);b.addEventListener(a.SEEKED,this.J);b.addEventListener(a.STALLED,this.L);b.addEventListener(a.PLAYER_LOADING,this.G);b.addEventListener(a.ERROR,this.F);b.addEventListener(a.BITRATE_CHANGED,this.f)}destroy(){const a=this,b=()=>Object.getPrototypeOf(Object.getPrototypeOf(this)).destroy;return _.x(function*(){const c=cast.framework.events.EventType,d=cast.framework.CastReceiverContext.getInstance().getPlayerManager();
d.removeEventListener(c.PLAYING,a.I);d.removeEventListener(c.PAUSE,a.H);d.removeEventListener(c.MEDIA_FINISHED,a.A);d.removeEventListener(c.BUFFERING,a.w);d.removeEventListener(c.SEEKING,a.K);d.removeEventListener(c.SEEKED,a.J);d.removeEventListener(c.STALLED,a.L);d.removeEventListener(c.PLAYER_LOADING,a.G);d.removeEventListener(c.ERROR,a.F);d.removeEventListener(c.BITRATE_CHANGED,a.f);yield b().call(a)})}S(){this.player.trigger(new _.F(_.Re));this.a(_.Wo)}R(){this.a(_.Vo)}da(){this.a(_.Lo)}ba(a){a.isBuffering?
this.a(_.Po):(a=this.player.isPaused()?_.Vo:_.Wo,this.a(a))}X(){this.j=1;this.player.trigger(new _.F(_.jg))}V(){this.player.trigger(new _.F(_.ig))}ia(){this.j=2}fa(){this.a(_.Uo)}M(a){const b=this.player.getStats();this.player.trigger(new _.F(_.Kc,{detail:{bandwidth:a.totalBitrate,width:b.width,height:b.height}}))}P(a){a=new _.I(_.G,7,7300,{detailedErrorCode:a.detailedErrorCode,error:a.error,reason:a.reason});this.player.trigger(new _.F(_.q,{detail:a}));this.a(_.Mo)}};var Z=class{constructor(a,b,c,d,e){this.a=a;this.f=b;this.l=typeof c===_.t?c:1;this.h=typeof d===_.t?d:1;this.j=typeof e===_.t?e:0}ob(){return"Google Cast Framework"}pb(){return cast.framework.VERSION}ub(){return 0}getId(){return""}getCreativeId(){return""}Qb(){return""}getApiFramework(){return null}getAdSystem(){return""}getAdvertiserName(){return""}getTitle(){return this.a.title||""}getDuration(){return this.a.duration||0}getPosition(){return 0}getSkipTimeOffset(){return this.a.whenSkippable||0}Tb(){return!1}qb(){return this.a.clickThroughUrl||
null}getMediaUrl(){return this.a.contentUrl||this.a.contentId||null}fb(){return 0}eb(){return 0}Oa(){return 0}Pa(){switch(this.Hb()){case 0:return 0;case -1:return 2;default:return 1}}getPodIndex(){return this.j}Hb(){return this.f.position}sb(){return this.l}gb(){return this.h}getWrapperAdIds(){return[]}canSeek(){return!1}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}Sb(){return null}};Z.prototype.getVideoElement=Z.prototype.Sb;Z.prototype.getWrapperCreativeIds=Z.prototype.getWrapperCreativeIds;
Z.prototype.getWrapperAdSystems=Z.prototype.getWrapperAdSystems;Z.prototype.canSeek=Z.prototype.canSeek;Z.prototype.getWrapperAdIds=Z.prototype.getWrapperAdIds;Z.prototype.getSequenceLength=Z.prototype.gb;Z.prototype.getPositionInSequence=Z.prototype.sb;Z.prototype.getPodTimeOffset=Z.prototype.Hb;Z.prototype.getPodIndex=Z.prototype.getPodIndex;Z.prototype.getPodType=Z.prototype.Pa;Z.prototype.getMediaBitrate=Z.prototype.Oa;Z.prototype.getMediaHeight=Z.prototype.eb;Z.prototype.getMediaWidth=Z.prototype.fb;
Z.prototype.getMediaUrl=Z.prototype.getMediaUrl;Z.prototype.getClickThroughUrl=Z.prototype.qb;Z.prototype.isBumper=Z.prototype.Tb;Z.prototype.getSkipTimeOffset=Z.prototype.getSkipTimeOffset;Z.prototype.getPosition=Z.prototype.getPosition;Z.prototype.getDuration=Z.prototype.getDuration;Z.prototype.getTitle=Z.prototype.getTitle;Z.prototype.getAdvertiserName=Z.prototype.getAdvertiserName;Z.prototype.getAdSystem=Z.prototype.getAdSystem;Z.prototype.getApiFramework=Z.prototype.getApiFramework;
Z.prototype.getSourceId=Z.prototype.Qb;Z.prototype.getCreativeId=Z.prototype.getCreativeId;Z.prototype.getId=Z.prototype.getId;Z.prototype.getTechnology=Z.prototype.ub;Z.prototype.getAdManagerVersion=Z.prototype.pb;Z.prototype.getAdManagerName=Z.prototype.ob;var bX=class{constructor(a){this.a=a}getCuePoints(){return this.a.map(a=>a.position)}Kb(){return!!this.a.find(a=>0===a.position)}Jb(){return!!this.a.find(a=>-1===a.position)}};bX.prototype.hasPostroll=bX.prototype.Jb;bX.prototype.hasPreroll=bX.prototype.Kb;bX.prototype.getCuePoints=bX.prototype.getCuePoints;var cX=class{constructor(a){this.m=a;this.a=null;this.j=this.w.bind(this);this.f=[cast.framework.events.EventType.PLAYER_LOADING,cast.framework.events.EventType.BREAK_CLIP_LOADING,cast.framework.events.EventType.BREAK_STARTED,cast.framework.events.EventType.BREAK_ENDED,cast.framework.events.EventType.BREAK_CLIP_STARTED,cast.framework.events.EventType.BREAK_CLIP_ENDED,cast.framework.events.EventType.PLAYING,cast.framework.events.EventType.PAUSE,cast.framework.events.EventType.BUFFERING];AW().addEventListener(this.f,
this.j)}load(){const a=this;return _.x(function*(){wW&&(wW=!1,zW(a,0))})}start(){return _.x(function*(){AW().play()})}o(){}resume(){-1!==this.getPosition()&&AW().play()}pause(){-1!==this.getPosition()&&AW().pause()}skip(){}getVolume(){return this.m.getVolume()||0}setVolume(a){this.m.setVolume(a)}getPosition(){const a=this.a&&this.a.getBreakClipCurrentTimeSec();return typeof a===_.t?a:-1}l(){return!0}h(){const a=this;return _.x(function*(){AW().removeEventListener(a.f,a.j)})}w(a){const b=cast.framework.events.EndedReason;
switch(a.type){case cast.framework.events.EventType.PLAYER_LOADING:this.a=AW().getBreakManager();this.a.setPlayWatchedBreak(!0);a=this.a.getBreaks();this.m.trigger(new _.F(_.oc,{adsTimeline:new bX(a)}));break;case cast.framework.events.EventType.BREAK_CLIP_LOADING:CW(this,_.ac,a);break;case cast.framework.events.EventType.BREAK_STARTED:CW(this,_.Rb,a);break;case cast.framework.events.EventType.BREAK_ENDED:CW(this,_.Sb,a);break;case cast.framework.events.EventType.BREAK_CLIP_STARTED:CW(this,_.jc,a);
break;case cast.framework.events.EventType.BREAK_CLIP_ENDED:a.endedReason===b.SKIPPED?(CW(this,_.fc,a),CW(this,_.lc,a)):a.endedReason===b.STOPPED?CW(this,_.lc,a):a.endedReason===b.END_OF_STREAM?(CW(this,_.Vb,a),CW(this,_.lc,a)):a.endedReason===b.ERROR&&zW(this,1);break;case cast.framework.events.EventType.PLAYING:CW(this,_.ec,a);break;case cast.framework.events.EventType.PAUSE:CW(this,_.cc,a);break;case cast.framework.events.EventType.BUFFERING:a.isBuffering?CW(this,_.Tb,a):CW(this,_.ec,a)}}};
cX.prototype.getPosition=cX.prototype.getPosition;cX.prototype.setVolume=cX.prototype.setVolume;cX.prototype.getVolume=cX.prototype.getVolume;cX.prototype.skip=cX.prototype.skip;cX.prototype.pause=cX.prototype.pause;cX.prototype.resume=cX.prototype.resume;var wW=!1;var dX=class{constructor(a){this.Ta=a;this.a=this.f.bind(this)}init(){cast.framework.CastReceiverContext.getInstance().getPlayerManager().addEventListener(DW(),this.a)}release(){cast.framework.CastReceiverContext.getInstance().getPlayerManager().removeEventListener(DW(),this.a)}getTimelineCues(){return cast.framework.CastReceiverContext.getInstance().getPlayerManager().getTimedMetadata().map(a=>EW(a))}f(a){if(a instanceof cast.framework.events.TimedMetadataEvent){var b=null;switch(a.type){case cast.framework.events.EventType.TIMED_METADATA_CHANGED:b=
_.Vf;break;case cast.framework.events.EventType.TIMED_METADATA_ENTER:b=_.Wf;break;case cast.framework.events.EventType.TIMED_METADATA_EXIT:b=_.Xf}b&&this.Ta(new _.F(b,{detail:EW(a.timedMetadataInfo)}))}else for(b of this.getTimelineCues())this.Ta(new _.F(_.Vf,{detail:b}))}};var eX=class extends _.T{constructor(){super();this.g=new _.S("clpp.cast.TrackManager");this.m=null;this.o=1E9;this.h=[];this.j=[];this.l=this.w.bind(this);this.a=this.f=null}initialize(a){this.m=a;FW().addEventListener(cast.framework.events.EventType.PLAYER_LOAD_COMPLETE,this.l)}release(){this.h=[];this.j=[];this.a=this.f=null}load(){}destroy(){this.m=null;FW().removeEventListener(cast.framework.events.EventType.PLAYER_LOAD_COMPLETE,this.l)}getVideoTracks(){return[]}getAudioTracks(){return this.h}ma(){return this.j}na(){return null}Ma(){const a=
this.qa();return a&&a.renditions[0]}Qa(){const a=this.wa();return a&&a.renditions[0]}rb(){return null}Fb(){return null}Gb(){return null}Ea(){return null}qa(){let a=null;if(this.f){let b=this.f.getActiveId();typeof b===_.t&&(b=b.toString(),a=this.getAudioTracks().find(c=>c.id===b)||null)}return a}wa(){let a=null;if(this.a){let b=this.a.getActiveIds()[0];typeof b===_.t&&(b=b.toString(),a=this.ma().find(c=>c.id===b)||null)}return a}Ab(){this.g.warn("Video tracks unavailable on Cast")}xa(a){a&&this.f&&
this.f.setActiveById(+a.id)}Sa(a){this.a&&(a?this.a.setActiveByIds([+a.id]):this.a.setActiveByIds([]))}jb(){this.g.warn("Video renditions unavailable on Cast")}yb(a){this.xa(a&&a.track)}zb(a){this.Sa(a&&a.track)}addTextTrack(a){const b=this;return _.x(function*(){var c=b.m.getConfiguration();if((c=yield WV(a,Object.values(cast.framework.messages.CaptionMimeType),b.m.getNetworkEngine(),c))&&b.a){const d=new cast.framework.messages.Track(b.o++,cast.framework.messages.TrackType.TEXT);d.isInband=!1;d.language=
c.language;d.name=c.label;d.subtype=c.kind;d.trackContentId=c.url;d.trackContentType=c.mimeType;d.customData={mimeType:a.mimeType,url:a.url};try{b.a.addTracks([d]),HW(b)}catch(e){throw b.g.warn("failed on track",a),e;}}})}ta(){return!0}w(){this.f=FW().getAudioTracksManager();var a=this.f.getTracks();this.h=GW(_.M,a);HW(this);a=this.m.getConfiguration();IW(this,_.M,a.preferredAudioLanguage,a.preferredAudioRole);IW(this,_.L,a.preferredTextLanguage,a.preferredTextRole)}};eX.prototype.isAbrEnabled=eX.prototype.ta;
eX.prototype.addTextTrack=eX.prototype.addTextTrack;eX.prototype.setTextRendition=eX.prototype.zb;eX.prototype.setAudioRendition=eX.prototype.yb;eX.prototype.setVideoRendition=eX.prototype.jb;eX.prototype.setTextTrack=eX.prototype.Sa;eX.prototype.setAudioTrack=eX.prototype.xa;eX.prototype.setVideoTrack=eX.prototype.Ab;eX.prototype.getTextTrack=eX.prototype.wa;eX.prototype.getAudioTrack=eX.prototype.qa;eX.prototype.getVideoTrack=eX.prototype.Ea;eX.prototype.getLoadingTextRendition=eX.prototype.Gb;
eX.prototype.getLoadingAudioRendition=eX.prototype.Fb;eX.prototype.getLoadingVideoRendition=eX.prototype.rb;eX.prototype.getTextRendition=eX.prototype.Qa;eX.prototype.getAudioRendition=eX.prototype.Ma;eX.prototype.getVideoRendition=eX.prototype.na;eX.prototype.getTextTracks=eX.prototype.ma;eX.prototype.getAudioTracks=eX.prototype.getAudioTracks;eX.prototype.getVideoTracks=eX.prototype.getVideoTracks;var fX=class extends _.su{constructor(){super();this.g=new _.S(PV);this.h=this.w=_.rl();this.A=null;this.l=-1;this.F=new _.zr;this.f=this.o=this.j=this.a=this.B=null;this.C=!1}init(a,b){this.B=a;b&&(this.h=this.w=b);a=JW();a.setMessageInterceptor(cast.framework.messages.MessageType.MEDIA_STATUS,this.H.bind(this));a.setMediaPlaybackInfoHandler(this.G.bind(this));this.a=new aX(this);this.a.init();this.j=new eX;this.j.initialize(this);this.o=new dX(c=>this.trigger(c));this.o.init()}unload(){const a=
cast.framework.messages.PlayerState,b=JW();b.getPlayerState()!==a.IDLE&&b.stop();this.j&&this.j.release();this.o&&this.o.release();this.f=null;return Promise.resolve()}release(){return this.unload().then(()=>{this.a&&this.a.release()})}destroy(){const a=this;return _.x(function*(){a.B=null;a.w=_.rl();a.h=a.w;a.l=-1;a.A=null;a.a&&(yield a.a.destroy(),a.a=null);a.j&&(a.j.destroy(),a.j=null)})}play(){const a=JW();if(null!==a.getBreakManager().getBreakClipCurrentTimeSec())return Promise.reject("Cannot play during ads playout.");
a.play();return Promise.resolve()}pause(){const a=JW();if(null!==a.getBreakManager().getBreakClipCurrentTimeSec())return Promise.reject("Cannot pause during ads playout.");a.pause();return Promise.resolve()}isPaused(){return JW().getPlayerState()===cast.framework.messages.PlayerState.PAUSED}isEnded(){return JW().getPlayerState()===cast.framework.messages.PlayerState.IDLE}seek(a){const b=JW();if(null!==b.getBreakManager().getBreakClipCurrentTimeSec())return Promise.reject(HV);b.seek(a);return Promise.resolve()}getPosition(){return this.getMediaPosition()}setSeekInterceptor(){}setPlaybackSessionId(){}getBandwidthEstimate(){return null}getMediaPosition(){return JW().getCurrentTimeSec()}getDuration(){return this.getMediaDuration()}getMediaDuration(){const a=
JW().getDurationSec();return typeof a===_.t?-1===a?Infinity:a:-1}getPlaybackRate(){return JW().getPlaybackRate()}setPlaybackRate(a){if(0<a){const b=new cast.framework.messages.SetPlaybackRateRequestData;b.playbackRate=a;JW().sendLocalMediaRequest(b)}}getVolume(){return cast.framework.CastReceiverContext.getInstance().getSystemVolume().level||null}setVolume(a){0<=a&&1>=a&&cast.framework.CastReceiverContext.getInstance().setSystemVolumeLevel(a)}setMuted(a){cast.framework.CastReceiverContext.getInstance().setSystemVolumeMuted(a)}isMuted(){return cast.framework.CastReceiverContext.getInstance().getSystemVolume().muted||
null}getLoadedSource(){const a=JW().getMediaInformation();if(a){var b=JW().getPlaybackConfig();b=!!b&&b.protectionSystem!==cast.framework.ContentProtection.NONE;var c=this.A&&-1!==this.l?this.A[this.l]:null;c=c?c.name:void 0;!c&&a.metadata&&(c=a.metadata.title);return{url:a.contentId,type:a.contentType,$i:b,name:c}}return null}getDrmInfo(){return null}getPresentationStartTime(){return JW().getStartAbsoluteTime()}getSeekRange(){let a={start:0,end:this.getDuration()};if(this.isLive()){const b=JW().getLiveSeekableRange();
b&&typeof b.start===_.t&&typeof b.end===_.t&&(a={start:b.start,end:b.end})}return a}getState(){return this.a?this.a.getState():_.hv}getStats(){var a=_.Io();if(this.f){a=JW().getStats();this.f.h=a.estimatedBandwidth||NaN;this.f.w=a.streamBandwidth||NaN;var b=this.f,c=a.height||NaN;b.A=a.width||NaN;b.j=c;b=this.f;c=typeof a.decodedFrames===_.t?a.decodedFrames:NaN;b.o=typeof a.droppedFrames===_.t?a.droppedFrames:NaN;b.l=c;a=this.f.getStats()}return a}isLive(){return Infinity===this.getDuration()}load(a){const b=
this;return _.x(function*(){b.f=new _.gv;b.a.l=b.f.a;b.A=_.Zo(a);b.h=_.tl(b.w,a);if(b.C)b.C=!1;else{var c=b.A[b.l],d=new cast.framework.messages.LoadRequestData;d.autoplay=b.h.autoplay;typeof b.h.startTime===_.t&&(d.currentTime=b.h.startTime);c.type&&(d.media.contentType=c.type);d.media.contentId=c.url;d.media.customData={playerConfiguration:UV(b.h),local:!0};yield JW().load(d)}})}getBufferInfo(){this.g.warn(_.pa);return new _.ru}getTrackManager(){return this.j}getConfiguration(){return this.h}getSurface(){return this.B}getTimeline(){return null}setupPlaylist(){return Promise.reject(_.Za)}appendLoad(){return Promise.reject(_.Za)}seekWith(){return Promise.reject(_.Za)}setNetworkEngine(a){this.F=
a}setCmsdManager(){}getNetworkEngine(){return this.F}getSourceIndex(){return this.l}setSourceIndex(a){this.l=a}getPeriods(){return[]}namespace(){return PV}getTimelineCues(){return this.o&&this.o.getTimelineCues()||[]}getCueTimeline(){return null}resetAbr(){this.g.warn(LV)}onError(a){a=new _.F(_.q,{detail:a});this.trigger(a)}canPlay(){return _.Ek()?2:0}H(a){a=Object.assign({},a);a.customData||(a.customData={});a.customData.stats=UV(this.getStats());var b=JW(),c=a.media||b.getMediaInformation();b=b.getStartAbsoluteTime();
c&&typeof b===_.t&&c.startAbsoluteTime!==b&&(this.g.info("Syncing startAbsoluteTime."+`Old value: ${c.startAbsoluteTime}, `+`new value: ${b}`),c.startAbsoluteTime=b,a=Object.assign({},a,{media:c}));{c=cast.framework.messages.StreamType;b=a.media;var d=!!b;const e=this.isLive(),f=d&&!b.metadata,g=!!a.liveSeekableRange;if(d&&g&&(!e||e&&f)){d=JW().getStartAbsoluteTime();if(typeof d===_.t){b.startAbsoluteTime=d;let h;f?h=new cast.framework.messages.GenericMediaMetadata:h=b.metadata;h.sectionStartAbsoluteTime=
d;b.metadata=h}b.streamType=c.LIVE;a=Object.assign({},a,{media:b})}}return a}G(a,b){var c=null;a.media.customData&&(c=VV(a.media.customData.playerConfiguration));var d=c?c.abr||null:null,e=b;d&&typeof d.defaultBandwidthEstimate===_.t?e.initialBandwidth=d.defaultBandwidthEstimate:e.initialBandwidth=void 0;MW(c,b);d=null;a.media.customData&&(d=VV(a.media.customData["com.castlabs.reactnative.PlayerConfiguration"]));a=(a=d&&d.LiveConfiguration)?0===a.liveEdgeLatencyMs:!1;if(a=null!=c&&c.lowLatencyMode||
a)a=Object.assign({},b.shakaConfig,{streaming:{lowLatencyMode:!0}}),b=Object.assign({},b,{shakaConfig:a});return b}getTextDisplayer(){return null}setDrmCustomDataModifier(){}setCdnErrorCallback(){}detach(){}};var OW=class{constructor(){this.a=!1;this.g=new _.S(QV);this.f=this.m=null;this.h=new Set;this.A=this.G.bind(this);this.w=this.B.bind(this);this.j=null;this.o=new _.Nt;this.l=null}init(a){a&&(this.f=new fX,_.Pr(a,this.f),this.m=a,this.o.on(window,"unload",()=>{const b=this;return _.x(function*(){b.m&&b.m.getState()!==_.To&&(yield TV(b.m))})}))}start(){if(!this.a&&window.cast&&cast.framework&&cast.framework.CastReceiverContext){this.a=!0;var a=QW(),b=QW().getPlayerManager(),c=new cast.framework.CastReceiverOptions;
c.customNamespaces={};c.customNamespaces[RV]=cast.framework.system.MessageType.JSON;var d=new cast.framework.PlaybackConfig;d.manifestHandler=this.F.bind(this);d.shakaConfig={streaming:{ignoreTextStreamFailures:!0}};d.enableSmoothLiveRefresh=!0;c.playbackConfig=d;if(d=this.m&&this.m.getSurface().getMedia())c.mediaElement=d;c.disableIdleTimeout=!0;c.maxInactivity=Infinity;b.setMessageInterceptor(cast.framework.messages.MessageType.LOAD,this.C.bind(this));b.addEventListener(cast.framework.events.EventType.PLAYER_LOAD_COMPLETE,
this.A);a.start(c);a.addCustomMessageListener(RV,this.w)}}stop(){if(this.a){this.a=!1;this.o.release();const a=QW();QW().getPlayerManager().removeEventListener(cast.framework.events.EventType.PLAYER_LOAD_COMPLETE,this.A);a.removeCustomMessageListener(RV,this.w);a.stop();this.m=this.f=null}}Cd(a){this.j=a}yi(a){this.l=a}on(a,b){QW().addEventListener(a,b)}off(a,b){QW().removeEventListener(a,b)}addMessageListener(a){typeof a===_.Yd&&this.h.add(a)}removeMessageListener(a){typeof a===_.Yd&&this.h.delete(a)}sendMessage(a,
b){QW().sendCustomMessage(RV,b,UV(a))}xc(){return this.a}Eb(){return RW()}Yb(a){SW(this,a)}Mi(a){const b=RW();let c=null;a?c=Object.assign({},b,a):c=b;SW(this,c)}F(a){a=a.trim();if(a.startsWith("#EXTM3U"))return UW(this,a);try{var b=(new DOMParser).parseFromString(a,_.Tf)}catch(k){return a}var c=b.getElementsByTagName("MPD")[0];if(c){a=c;this.g.debug("Detected DASH, parsing");b=QW();c=a.getElementsByTagName("Period");for(var d=c.length-1;0<=d;--d){var e=c[d].getElementsByTagName(_.fa);for(var f=e.length-
1;0<=f;--f){var g=e[f].getAttribute("contentType");if(g===_.w||g===_.p){g=e[f].getAttribute(_.te);var h=e[f].getElementsByTagName(_.lb);for(let k=h.length-1;0<=k;--k){const l=h[k].getAttribute(_.te)||g,m=h[k].getAttribute(_.md);let n=h[k].getAttribute(_.Fg)||void 0,r=h[k].getAttribute(_.Zd)||void 0;void 0!==n&&(n=+n);void 0!==r&&(r=+r);b.canDisplayType(l,m,n,r)||e[f].removeChild(h[k])}e[f].getElementsByTagName(_.lb).length||c[d].removeChild(e[f])}}c[d].getElementsByTagName(_.fa).length||a.removeChild(c[d])}return a=
(new XMLSerializer).serializeToString(a)}if(c=b.getElementsByTagName(_.qb)[0]){a=c;this.g.debug("Detected Smooth, parsing");b=QW();c=a.getElementsByTagName("StreamIndex");for(d=c.length-1;0<=d;--d)if(c[d].getAttribute("Type")===_.w){e=c[d].getElementsByTagName(_.jb);for(f=e.length-1;0<=f;--f)g=e[f].getAttribute(_.Qa)||void 0,h=e[f].getAttribute(_.Pa)||void 0,void 0!==g&&(g=+g),void 0!==h&&(h=+h),b.canDisplayType(_.pg,void 0,g,h)||c[d].removeChild(e[f]);c[d].getElementsByTagName(_.jb).length||a.removeChild(c[d])}a=
(new XMLSerializer).serializeToString(a)}return a}C(a){const b=this;return _.x(function*(){let c=a;var d;c.media.customData&&(d=VV(c.media.customData.playerConfiguration));if(b.m&&d){b.j&&(d=(yield Promise.resolve(b.j(d)))||d);d.ima&&(yield yW(c.media,d.ima,b.m.getNetworkEngine()));typeof d.startTime===_.t&&d.startTime!==c.currentTime?c.currentTime=d.startTime:d.startTime=c.currentTime||null;c.media.customData.local||(b.f.C=!0,yield _.$r(b.m,d),yield _.as(b.m),d=b.m.getLoadedSource(),c.media.contentId=
d.url,c.media.contentType=d.type,d.Zb&&(c.media.hlsVideoSegmentFormat=XV(d.Zb,_.N)),d.audioMimeType&&(c.media.hlsSegmentFormat=XV(d.audioMimeType,_.M)));const e=c.media.metadata;e&&typeof e.sectionStartAbsoluteTime===_.t&&(d=e.sectionStartAbsoluteTime,e.sectionStartAbsoluteTime=0===d?1E-8:d);void 0===c.autoplay&&(c.autoplay=b.m.getConfiguration().autoplay)}b.l&&(d=yield Promise.resolve(b.l(c)))&&(c=d);return c})}G(a){if(this.m&&(!a.media.customData||!a.media.customData.local)){var b=QW().getPlayerManager(),
c=b.getLiveSeekableRange();if(c){a=c.start;c=c.end;var d=this.m.getConfiguration().startTime;typeof a!==_.t||typeof c!==_.t||typeof d!==_.t||d>=a&&d<=c||(b=b.getMediaTimeForAbsoluteTime(d),typeof b===_.t&&b>=a&&b<=c&&this.m.seek(b))}_.cs(this.m)}}B(a){if(0<this.h.size){const b=VV(a.data);this.h.forEach(c=>c(b))}}};_.z(QV,OW);OW.prototype.updateContentMetadata=OW.prototype.Mi;OW.prototype.setContentMetadata=OW.prototype.Yb;OW.prototype.getContentMetadata=OW.prototype.Eb;OW.prototype.isApiReady=OW.prototype.xc;
OW.prototype.sendMessage=OW.prototype.sendMessage;OW.prototype.removeMessageListener=OW.prototype.removeMessageListener;OW.prototype.addMessageListener=OW.prototype.addMessageListener;OW.prototype.off=OW.prototype.off;OW.prototype.on=OW.prototype.on;OW.prototype.setLoadRequestDataInterceptor=OW.prototype.yi;OW.prototype.setPlayerConfigInterceptor=OW.prototype.Cd;OW.prototype.stop=OW.prototype.stop;OW.prototype.start=OW.prototype.start;OW.prototype.init=OW.prototype.init;OW.getInstance=PW;var NW=null;var gX=class{constructor(a){this.f=a;this.a=null;this.j=new _.Nt;this.w=[cast.framework.RemotePlayerEventType.IS_PLAYING_BREAK_CHANGED,cast.framework.RemotePlayerEventType.CURRENT_BREAK_CLIP_NUMBER_CHANGED,cast.framework.RemotePlayerEventType.MEDIA_INFO_CHANGED,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]}load(){const a=this;return _.x(function*(){a.a=a.f.l;if(a.a){const b=a.a.controller,c=a.A.bind(a);for(const d of a.w)a.j.on(b,d,c)}})}start(){return _.x(function*(){})}o(){}resume(){this.a&&
this.a.isPlayingBreak&&this.a.isPaused&&this.a.controller.playOrPause()}pause(){this.a&&this.a.isPlayingBreak&&!this.a.isPaused&&this.a.controller.playOrPause()}skip(){const a=this.f.a;a&&this.f.sendMessage(SV,{type:"SKIP_AD",requestId:Math.round(1E3*Math.random()),mediaSessionId:a.mediaSessionId})}getVolume(){return this.f.getVolume()||0}setVolume(a){this.f.setVolume(a)}getPosition(){let a=-1;var b=this.f.a;b&&(b=b.getEstimatedBreakClipTime(),typeof b===_.t&&(a=b));return a}l(){return!0}h(){const a=
this;return _.x(function*(){a.j.release()})}A(a){switch(a.field){case "mediaInfo":a.value&&(a=a.value,a.breaks&&this.f.trigger(new _.F(_.oc,{adsTimeline:new bX(a.breaks)})));break;case "isPlayingBreak":a.value?WW(this,_.Rb):(WW(this,_.Vb),WW(this,_.lc),WW(this,_.Sb));break;case "currentBreakClipNumber":0<=a.value&&(0<a.value&&(WW(this,_.Vb),WW(this,_.lc)),WW(this,_.jc));break;case "isPaused":this.a.isPlayingBreak&&(a.value?WW(this,_.cc):WW(this,_.ec))}}};gX.prototype.getPosition=gX.prototype.getPosition;
gX.prototype.setVolume=gX.prototype.setVolume;gX.prototype.getVolume=gX.prototype.getVolume;gX.prototype.skip=gX.prototype.skip;gX.prototype.pause=gX.prototype.pause;gX.prototype.resume=gX.prototype.resume;_.mp(new class{name(){return"clpp.cast.ads.SenderAdsManagerFactory"}a(a,b){return a.namespace()!==_.dd?!1:!(!b||!b.ima)}create(a){return new gX(a.a)}});_.mp(new class{name(){return"clpp.cast.ads.AdsManagerFactory"}a(a,b){return PW().xc()?!(!b||!b.ima):!1}create(a){return new cX(a)}});};f.call(g, window);