1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[878],{70878:function(e,t,s){s.r(t),s.d(t,{GoogleCastProvider:function(){return c}});var a=s(41240),i=s(13711),n=s(99274);s(67294);class r{#e;constructor(e){this.#e=new chrome.cast.media.MediaInfo(e.src,e.type)}build(){return this.#e}setStreamType(e){return e.includes("live")?this.#e.streamType=chrome.cast.media.StreamType.LIVE:this.#e.streamType=chrome.cast.media.StreamType.BUFFERED,this}setTracks(e){return this.#e.tracks=e.map(this.#t),this}setMetadata(e,t){return this.#e.metadata=new chrome.cast.media.GenericMediaMetadata,this.#e.metadata.title=e,this.#e.metadata.images=[{url:t}],this}#t(e,t){const s=new chrome.cast.media.Track(t,chrome.cast.media.TrackType.TEXT);return s.name=e.label,s.trackContentId=e.src,s.trackContentType="text/vtt",s.language=e.language,s.subtype=e.kind.toUpperCase(),s}}class o{#s;#a;#i;constructor(e,t,s){this.#s=e,this.#a=t,this.#i=s}setup(){const e=this.syncRemoteActiveIds.bind(this);(0,a.listenEvent)(this.#a.audioTracks,"change",e),(0,a.listenEvent)(this.#a.textTracks,"mode-change",e),(0,a.effect)(this.#n.bind(this))}getLocalTextTracks(){return this.#a.$state.textTracks().filter((e=>e.src&&"vtt"===e.type))}#r(){return this.#a.$state.audioTracks()}#o(e){const t=this.#s.mediaInfo?.tracks??[];return e?t.filter((t=>t.type===e)):t}#c(){const e=[],t=this.#r().find((e=>e.selected)),s=this.getLocalTextTracks().filter((e=>"showing"===e.mode));if(t){const s=this.#o(chrome.cast.media.TrackType.AUDIO),a=this.#h(s,t);a&&e.push(a.trackId)}if(s?.length){const t=this.#o(chrome.cast.media.TrackType.TEXT);if(t.length)for(const a of s){const s=this.#h(t,a);s&&e.push(s.trackId)}}return e}#n(){const e=this.getLocalTextTracks();if(!this.#s.isMediaLoaded)return;const t=this.#o(chrome.cast.media.TrackType.TEXT);for(const s of e){if(!this.#h(t,s)){(0,a.untrack)((()=>this.#i?.()));break}}}syncRemoteTracks(e){if(!this.#s.isMediaLoaded)return;const t=this.#r(),s=this.getLocalTextTracks(),a=this.#o(chrome.cast.media.TrackType.AUDIO),n=this.#o(chrome.cast.media.TrackType.TEXT);for(const r of a){if(this.#l(t,r))continue;const s={id:r.trackId.toString(),label:r.name,language:r.language,kind:r.subtype??"main",selected:!1};this.#a.audioTracks[i.HV.add](s,e)}for(const i of n){if(this.#l(s,i))continue;const t={id:i.trackId.toString(),src:i.trackContentId,label:i.name,language:i.language,kind:i.subtype.toLowerCase()};this.#a.textTracks.add(t,e)}}syncRemoteActiveIds(e){if(!this.#s.isMediaLoaded)return;const t=this.#c(),s=new chrome.cast.media.EditTracksInfoRequest(t);this.#d(s).catch((e=>{}))}#d(e){const t=(0,n.getCastSessionMedia)();return new Promise(((s,a)=>t?.editTracksInfo(e,s,a)))}#l(e,t){return e.find((e=>this.#u(e,t)))}#h(e,t){return e.find((e=>this.#u(t,e)))}#u(e,t){return t.name===e.label&&t.language===e.language&&t.subtype.toLowerCase()===e.kind.toLowerCase()}}class c{$$PROVIDER_TYPE="GOOGLE_CAST";scope=(0,a.createScope)();#m;#a;#y;#p=null;#g="disconnected";#T=0;#k=0;#f=new i.tn(0,0);#C=new i.LK(this.#E.bind(this));#v;#S=null;#L=!1;constructor(e,t){this.#m=e,this.#a=t,this.#y=new o(e,t,this.#i.bind(this))}get type(){return"google-cast"}get currentSrc(){return this.#p}get player(){return this.#m}get cast(){return(0,n.getCastContext)()}get session(){return(0,n.getCastSession)()}get media(){return(0,n.getCastSessionMedia)()}get hasActiveSession(){return(0,n.hasActiveCastSession)(this.#p)}setup(){this.#x(),this.#I(),this.#y.setup(),this.#a.notify("provider-setup",this)}#x(){(0,n.listenCastContextEvent)(cast.framework.CastContextEventType.CAST_STATE_CHANGED,this.#R.bind(this))}#I(){const e=cast.framework.RemotePlayerEventType,t={[e.IS_CONNECTED_CHANGED]:this.#R,[e.IS_MEDIA_LOADED_CHANGED]:this.#A,[e.CAN_CONTROL_VOLUME_CHANGED]:this.#b,[e.CAN_SEEK_CHANGED]:this.#w,[e.DURATION_CHANGED]:this.#M,[e.IS_MUTED_CHANGED]:this.#N,[e.VOLUME_LEVEL_CHANGED]:this.#N,[e.IS_PAUSED_CHANGED]:this.#D,[e.LIVE_SEEKABLE_RANGE_CHANGED]:this.#P,[e.PLAYER_STATE_CHANGED]:this.#_};this.#v=t;const s=this.#O.bind(this);for(const i of(0,a.keysOf)(t))this.#m.controller.addEventListener(i,s);(0,a.onDispose)((()=>{for(const e of(0,a.keysOf)(t))this.#m.controller.removeEventListener(e,s)}))}async play(){(this.#m.isPaused||this.#L)&&(this.#L?await this.#V(!1,0):this.#m.controller?.playOrPause())}async pause(){this.#m.isPaused||this.#m.controller?.playOrPause()}getMediaStatus(e){return new Promise(((t,s)=>{this.media?.getStatus(e,t,s)}))}setMuted(e){(e&&!this.#m.isMuted||!e&&this.#m.isMuted)&&this.#m.controller?.muteOr
1Unmute()}setCurrentTime(e){this.#m.currentTime=e,this.#a.notify("seeking",e),this.#m.controller?.seek()}setVolume(e){this.#m.volumeLevel=e,this.#m.controller?.setVolumeLevel()}async loadSource(e){if(this.#S?.src!==e&&(this.#S=null),(0,n.hasActiveCastSession)(e))return this.#G(),void(this.#p=e);this.#a.notify("load-start");const t=this.#H(e),s=await this.session.loadMedia(t);if(s)return this.#p=null,void this.#a.notify("error",Error((0,n.getCastErrorMessage)(s)));this.#p=e}destroy(){this.#$(),this.#F()}#$(){this.#S||(this.#k=0,this.#f=new i.tn(0,0)),this.#C.stop(),this.#T=0,this.#S=null}#G(){const e=new a.DOMEvent("resume-session",{detail:this.session});this.#A(e);const{muted:t,volume:s,savedState:i}=this.#a.$state,n=i();this.setCurrentTime(Math.max(this.#m.currentTime,n?.currentTime??0)),this.setMuted(t()),this.setVolume(s()),!1===n?.paused&&this.play()}#F(){this.cast.endCurrentSession(!0);const{remotePlaybackLoader:e}=this.#a.$state;e.set(null)}#U(){const{savedState:e}=this.#a.$state;e.set({paused:this.#m.isPaused,currentTime:this.#m.currentTime}),this.#F()}#E(){this.#q()}#O(e){this.#v[e.type].call(this,e)}#R(e){const t=this.cast.getCastState(),s=t===cast.framework.CastState.CONNECTED?"connected":t===cast.framework.CastState.CONNECTING?"connecting":"disconnected";if(this.#g===s)return;const a={type:"google-cast",state:s},i=this.#X(e);this.#g=s,this.#a.notify("remote-playback-change",a,i),"disconnected"===s&&this.#U()}#A(e){if(!!!this.#m.isMediaLoaded)return;const t=(0,a.peek)(this.#a.$state.source);Promise.resolve().then((()=>
1{if(t!==(0,a.peek)(this.#a.$state.source)||!this.#m.isMediaLoaded)return;this.#$();const s=this.#m.duration;this.#f=new i.tn(0,s);const n={provider:this,duration:s,buffered:new i.tn(0,0),seekable:this.#B()},r=this.#X(e);this.#a.notify("loaded-metadata",void 0,r),this.#a.notify("loaded-data",void 0,r),this.#a.notify("can-play",n,r),this.#b(),this.#w(e);const{volume:o,muted:c}=this.#a.$state;this.setVolume(o()),this.setMuted(c()),this.#C.start(),this.#y.syncRemoteTracks(r),this.#y.syncRemoteActiveIds(r)}))}#b(){this.#a.$state.canSetVolume.set(this.#m.canControlVolume)}#w(e){const t=this.#X(e);this.#a.notify("stream-type-change",this.#K(),t)}#K(){const e=this.#m.mediaInfo?.streamType;return e===chrome.cast.media.StreamType.LIVE?this.#m.canSeek?"live:dvr":"live":"on-demand"}#q(){if(this.#S)return;const e=this.#m.currentTime;e!==this.#T&&(this.#a.notify("time-change",e),e>this.#k&&(this.#k=e,this.#P()),this.#a.$state.seeking()&&this.#a.notify("seeked",e),this.#T=e)}#M(e){if(!this.#m.isMediaLoaded||this.#S)return;const t=this.#m.duration,s=this.#X(e);this.#f=new i.tn(0,t),this.#a.notify("duration-change",t,s)}#N(e){if(!this.#m.isMediaLoaded)return;const t={muted:this.#m.isMuted,volume:this.#m.volumeLevel},s=this.#X(e);this.#a.notify("volume-change",t,s)}#D(e){const t=this.#X(e);this.#m.isPaused?this.#a.notify("pause",void 0,t):this.#a.notify("play",void 0,t)}#P(e){const t={seekable:this.#B(),buffered:new i.tn(0,this.#k)},s=e?this.#X(e):void 0;this.#a.notify("progress",t,s)}#_(e){const t=this.#m.playerState,s=chrome.cast.media.PlayerState;if(this.#L=t===s.IDLE,t===s.PAUSED)return;const a=this.#X(e);switch(t){case s.PLAYING:this.#a.notify("playing",void 0,a);break;case s.BUFFERING:this.#a.notify("waiting",void 0,a);break;case s.IDLE:this.#C.stop(),this.#a.notify("pause"),this.#a.notify("end")}}#B(){return this.#m.liveSeekableRange?new i.tn(this.#m.liveSeekableRange.start,this.#m.liveSeekableRange.end):this.#f}#X(e){return e instanceof Event?e:new a.DOMEvent(e.type,{detail:e})}#Y(e){const{streamType:t,title:s,poster:a}=this.#a.$state;return new r(e).setMetadata(s(),a()).setStreamType(t()).setTracks(this.#y.getLocalTextTracks()).build()}#H(e){const t=this.#Y(e),s=new chrome.cast.media.LoadRequest(t),a=this.#a.$state.savedState();return s.autoplay=!1===(this.#S?.paused??a?.paused),s.currentTime=this.#S?.time??a?.currentTime??0,s}async#V(e,t){const s=(0,a.peek)(this.#a.$state.source);this.#S={src:s,paused:e,time:t},await this.loadSource(s)}#i(){this.#V(this.#m.isPaused,this.#m.currentTime).catch((e=>{}))}}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.