import e from"lz-string";import t from"lodash/debounce";import{formatBytesToKB as r}from"../cache-utils/formatBytes.js";import{scheduleIdleWork as n}from"../cache-utils/idle-callback.js";import{CACHE_VERSION as i,CACHE_SCHEMA as s,STORAGE_KEY as o,DEBOUNCE_DELAY as l}from"./constants.js";var a=function(a){return t((function(){var t=a.pendingWriteRef.current;if(t){var l=n((function(){a.idleHandlesRef.current.delete(l);try{var n=JSON.stringify(t.wellIds),c={version:i,timestamp:t.timestamp,schema:s,compression:"lz-utf16",count:t.wellIds.length,sizeKB:r(n.length),state:e.compressToUTF16(n)};sessionStorage.setItem(o,JSON.stringify(c))}finally{a.pendingWriteRef.current===t&&(a.pendingWriteRef.current=null)}}),{timeout:5e3});a.idleHandlesRef.current.add(l)}}),l)};export{a as createStorageFlusher};
//# sourceMappingURL=createStorageFlusher.js.map
