const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vidstack-google-cast-D0kI588c.js","assets/app-CWjefGxh.js","assets/Button-1eZ2gOMK.js","assets/app-Vs0ZL9L-.css","assets/vidstack-DqAw8m9J-DNH03ElA.js"])))=>i.map(i=>d[i]);
import{H as d,X as g,C as p,aa as u,F as C,_ as m,$ as h}from"./app-CWjefGxh.js";function f(){return"https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"}function w(){return!!window.cast?.framework}function v(){return!!window.chrome?.cast?.isAvailable}function c(){return s().getCastState()===cast.framework.CastState.CONNECTED}function s(){return window.cast.framework.CastContext.getInstance()}function l(){return s().getCurrentSession()}function y(){return l()?.getSessionObj().media[0]}function P(r){return y()?.media.contentId===r?.src}function E(){return{language:"en-US",autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,resumeSavedSession:!0,androidReceiverCompatible:!0}}function S(r){return`Google Cast Error Code: ${r}`}function k(r,e){return d(s(),r,e)}class _{name="google-cast";target;#e;get cast(){return s()}mediaType(){return"video"}canPlay(e){return g&&!p&&u(e)}async prompt(e){let t,a,o;try{t=await this.#r(e),this.#e||(this.#e=new cast.framework.RemotePlayer,new cast.framework.RemotePlayerController(this.#e)),a=e.player.createEvent("google-cast-prompt-open",{trigger:t}),e.player.dispatchEvent(a),this.#t(e,"connecting",a),await this.#o(C(e.$props.googleCast)),e.$state.remotePlaybackInfo.set({deviceName:l()?.getCastDevice().friendlyName}),c()&&this.#t(e,"connected",a)}catch(n){const i=n instanceof Error?n:this.#a((n+"").toUpperCase(),"Prompt failed.");throw o=e.player.createEvent("google-cast-prompt-error",{detail:i,trigger:a??t,cancelable:!0}),e.player.dispatch(o),this.#t(e,c()?"connected":"disconnected",o),i}finally{e.player.dispatch("google-cast-prompt-close",{trigger:o??a??t})}}async load(e){if(!this.#e)throw Error("[vidstack] google cast player was not initialized");return new(await m(async()=>{const{GoogleCastProvider:t}=await import("./vidstack-google-cast-D0kI588c.js");return{GoogleCastProvider:t}},__vite__mapDeps([0,1,2,3,4]))).GoogleCastProvider(this.#e,e)}async#r(e){if(w())return;const t=e.player.createEvent("google-cast-load-start");e.player.dispatch(t),await h(f()),await customElements.whenDefined("google-cast-launcher");const a=e.player.createEvent("google-cast-loaded",{trigger:t});if(e.player.dispatch(a),!v())throw this.#a("CAST_NOT_AVAILABLE","Google Cast not available on this platform.");return a}async#o(e){this.#s(e);const t=await this.cast.requestSession();if(t)throw this.#a(t.toUpperCase(),S(t))}#s(e){this.cast?.setOptions({...E(),...e})}#t(e,t,a){const o={type:"google-cast",state:t};e.notify("remote-playback-change",o,a)}#a(e,t){const a=Error(t);return a.code=e,a}}const A=Object.freeze(Object.defineProperty({__proto__:null,GoogleCastLoader:_},Symbol.toStringTag,{value:"Module"}));export{l as a,y as b,S as c,s as g,P as h,k as l,A as v};
