"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("../cache-utils/idle-callback.js"),t=require("./constants.js"),c=require("./useTileCacheHydration.js"),a=require("./createTileCacheFlusher.js");exports.useTileCache=function(){var n=e.useRef(new Map),u=e.useRef(new Map),l=e.useRef(new Set);c.useTileCacheHydration(n,l);var s=e.useRef(a.createTileCacheFlusher({pendingWritesRef:u,idleHandlesRef:l}));return e.useEffect((function(){var e=s.current,t=l.current;return function(){e.cancel(),t.forEach(r.cancelIdleWork),t.clear()}}),[]),{getCachedTile:e.useCallback((function(e){var r=Date.now(),c=n.current.get(e);if(c&&r-c.timestamp<t.CACHE_TTL)return c.wellIds;var a=u.current.get(e);return a&&r-a.timestamp<t.CACHE_TTL?a.wellIds:(c&&n.current.delete(e),null)}),[]),setCachedTile:e.useCallback((function(e,r){var t={wellIds:r,timestamp:Date.now()};n.current.set(e,t),u.current.set(e,t),s.current()}),[]),clearCache:e.useCallback((function(){n.current.clear(),u.current.clear(),s.current.cancel(),l.current.forEach(r.cancelIdleWork),l.current.clear(),sessionStorage.removeItem(t.STORAGE_KEY)}),[])}};
//# sourceMappingURL=useTileCache.js.map
