import "./chunk-KWPVD4H7.js"; // node_modules/@surdeddd/wmkit/dist/persist.js function defaultStorage() { try { const storage = globalThis.localStorage; const probe = "__wmkit_probe__"; storage.setItem(probe, "1"); storage.removeItem(probe); return storage; } catch { return null; } } function persist(wm, options = {}) { const key = options.key ?? "wmkit"; const storage = options.storage ?? defaultStorage(); const debounce = options.debounce ?? 150; let timer; let suspended = false; function save() { if (!storage) return; try { storage.setItem(key, JSON.stringify(wm.serialize())); } catch { } } function restore() { if (!storage) return false; let raw = null; try { raw = storage.getItem(key); } catch { return false; } if (!raw) return false; let data; try { data = JSON.parse(raw); } catch { return false; } suspended = true; const restored = wm.hydrate(data); suspended = false; return restored; } function clear() { if (!storage) return; try { storage.removeItem(key); } catch { } } const unsubscribe = wm.subscribe(() => { if (suspended || !storage) return; if (timer !== void 0) clearTimeout(timer); timer = setTimeout(save, debounce); }); if (options.autoRestore !== false) restore(); return { restore, save, clear, destroy() { unsubscribe(); if (timer !== void 0) clearTimeout(timer); } }; } export { persist }; //# sourceMappingURL=@surdeddd_wmkit_persist.js.map