import{n as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{$a as n,i as r,n as i,to as a}from"./ws-BfVPV0ME.js";import{n as o,r as s}from"./IPCRegistry-OPUQsWEY.js";import{a as c,d as l,u}from"./client-api-DGgiwyPh.js";import{a as d,n as f,r as p,t as m}from"./messageBus-BP3WwRHh.js";var h=t({CastAPI:()=>b,isNaruCastNative:()=>v});function g(e,t={},n){return a(e,{method:`POST`,body:JSON.stringify(t)},n)}async function _(e){try{return await e()}catch(e){throw Error(e instanceof Error?e.message:String(e))}}var v,y,b,x=e((()=>{l(),p(),s(),n(),i(),v=()=>c()===`naru`&&f()&&u(`cast:chromecast`),y=()=>c()===`pixie`?`pixie`:v()?`naru`:`izanami`,b={listDevices(e=!0){switch(y()){case`pixie`:return _(()=>o.cast.devices({refresh:e}));case`naru`:return m(`devices`,{refresh:e},e?15e3:5e3);case`izanami`:return a(`/_/cast/devices?refresh=${e}`,{method:`GET`},e?15e3:5e3)}},getSession(){switch(y()){case`pixie`:return _(()=>o.cast.getSession());case`naru`:return m(`session`,{},5e3);case`izanami`:return a(`/_/cast/session`,{method:`GET`},5e3)}},connect(e){switch(y()){case`pixie`:return _(()=>o.cast.connect({deviceId:e}));case`naru`:return m(`connect`,{deviceId:e},55e3);case`izanami`:return g(`/_/cast/connect`,{deviceId:e},3e4)}},disconnect(){switch(y()){case`pixie`:return _(()=>o.cast.disconnect());case`naru`:return m(`disconnect`,{},15e3);case`izanami`:return g(`/_/cast/disconnect`)}},load(e,t=0,n=!0){switch(y()){case`pixie`:return _(()=>o.cast.load({track:e,startTimeSec:t,autoplay:n}));case`naru`:return m(`load`,{track:e,startTimeSec:t,autoplay:n},3e4);case`izanami`:return g(`/_/cast/load`,{track:e,startTimeSec:t,autoplay:n})}},preload(e){switch(y()){case`pixie`:return _(()=>o.cast.preload({track:e}));case`naru`:return m(`preload`,{track:e},3e4);case`izanami`:return g(`/_/cast/preload`,{track:e})}},metadata(e){switch(y()){case`pixie`:return _(()=>o.cast.metadata(e));case`naru`:return m(`metadata`,e,1e4);case`izanami`:return g(`/_/cast/metadata`,e)}},lyrics(e){switch(y()){case`pixie`:return _(()=>o.cast.lyrics(e));case`naru`:return m(`lyrics`,e,1e4);case`izanami`:return Promise.resolve({applied:!1})}},lyricsVisibility(e){switch(y()){case`pixie`:return _(()=>o.cast.lyricsVisibility({enabled:e}));case`naru`:return m(`lyricsVisibility`,{enabled:e},1e4);case`izanami`:return Promise.resolve({applied:!1})}},command(e,t={}){switch(y()){case`pixie`:return _(()=>{switch(e){case`seek`:if(typeof t.timeSec!=`number`)throw Error(`The seek command requires timeSec`);return o.cast.command({action:e,timeSec:t.timeSec});case`volume`:if(typeof t.level!=`number`)throw Error(`The volume command requires level`);return o.cast.command({action:e,level:t.level,muted:t.muted});default:return o.cast.command({action:e})}});case`naru`:return m(`command`,{action:e,...t},15e3);case`izanami`:return g(`/_/cast/command`,{action:e,...t})}},setAppleTokens(e){switch(y()){case`pixie`:return _(()=>o.cast.setAppleTokens(e));case`naru`:return m(`setAppleTokens`,e,1e4);case`izanami`:return g(`/_/fetch/setTokens`,e)}},onEvent(e){switch(y()){case`pixie`:return o.cast.onCastEvent(e);case`naru`:return d(e);case`izanami`:return r?.on(`API:Cast`,e),()=>{r?.off(`API:Cast`,e)}}}}}));export{h as n,x as r,b as t};