import{a3 as g,ao as y,a4 as f,r as t,L as m,b1 as p}from"./index-D92x6h1h.js";const b=g("dvrEntries",()=>{const a=t([]),r=t(!1),l=t(!1),u=t(null);let e=null,o=null;async function d(){l.value=!0,u.value=null;try{const n=await m("dvr/entry/grid_upcoming",{start:0,limit:p});a.value=Array.isArray(n?.entries)?n.entries:[],r.value=!0}catch(n){u.value=n instanceof Error?n:new Error(String(n)),a.value=[]}finally{l.value=!1,e=null}}async function h(){if(!r.value)return e||(e=d(),e)}async function s(){return e?(o??=e.then(()=>(o=null,s())),o):(e=d(),e)}const v=y(()=>{s()},500);function i(n){if(!r.value)return;const c=n;(c.create?.length??0)+(c.change?.length??0)+(c.delete?.length??0)!==0&&v()}return f.on("dvrentry",i),f.on("dvrconfig",i),f.on("channel",i),{entries:a,loaded:r,loading:l,error:u,ensure:h,refresh:s}});export{b as u};
