import{useRef as r,useEffect as e,useCallback as t}from"react";import{cancelIdleWork as n}from"../cache-utils/idle-callback.js";import{CACHE_TTL as c,STORAGE_KEY as l}from"./constants.js";import{useHydrateFromStorage as a}from"./useHydrateFromStorage.js";import{createStorageFlusher as u}from"./createStorageFlusher.js";var o=function(){var o=r(null),s=r(null),i=r(new Set);a(o,i);var m=r(u({pendingWriteRef:s,idleHandlesRef:i}));return e((function(){var r=m.current,e=i.current;return function(){r.cancel(),e.forEach(n),e.clear()}}),[]),{getCachedWellIds:t((function(){var r=Date.now(),e=o.current,t=s.current;return e&&r-e.timestamp<c?e.wellIds:t&&r-t.timestamp<c?t.wellIds:(e&&(o.current=null),null)}),[]),setCachedWellIds:t((function(r){var e={wellIds:r,timestamp:Date.now()};o.current=e,s.current=e,m.current()}),[]),clearCache:t((function(){o.current=null,s.current=null,m.current.cancel(),i.current.forEach(n),i.current.clear(),sessionStorage.removeItem(l)}),[])}};export{o as useAllWellsCache};
//# sourceMappingURL=useAllWellsCache.js.map
