import{r as c}from"./index.BIRwh3HZ.js";function f(e,t,u){let r=new Set(t).add(void 0);return e.listen((i,l,n)=>{r.has(n)&&u(i,l,n)})}let s=(e,t)=>u=>{e.current!==u&&(e.current=u,t())};function S(e,{keys:t,deps:u=[e,t]}={}){let r=c.useRef();r.current=e.get();let i=c.useCallback(n=>(s(r,n)(e.value),t?.length>0?f(e,t,s(r,n)):e.listen(s(r,n))),u),l=()=>r.current;return c.useSyncExternalStore(i,l,l)}export{S as u};
