import{d as e}from"./destr-9c6e2924.js";import{d as r,a as t}from"./deep-pick-omit-418f72d7.js";
// src/index.ts
function i(e,{storage:i,serializer:a,key:s,debug:o,pick:c,omit:n,beforeHydrate:d,afterHydrate:f},y,p=!0){try{p&&d?.(y);const o=i.getItem(s);if(o){const i=a.deserialize(o),s=c?r(i,c):i,d=n?t(s,n):s;e.$patch(d)}p&&f?.(y)}catch(u){}}function a(e,{storage:i,serializer:a,key:s,debug:o,pick:c,omit:n}){try{const o=c?r(e,c):e,d=n?t(o,n):o,f=a.serialize(d);i.setItem(s,f)}catch(d){}}var s=
// src/index.ts
function(r={}){return function(t){!function(e,r,t){const{pinia:s,store:o,options:{persist:c=t}}=e;if(!c)return;if(!(o.$id in s.state.value)){const e=s._s.get(o.$id.replace("__hot:",""));return void(e&&Promise.resolve().then((()=>e.$persist())))}const n=(Array.isArray(c)?c:!0===c?[{}]:[c]).map(r);o.$hydrate=({runHooks:r=!0}={})=>{n.forEach((t=>{i(o,t,e,r)}))},o.$persist=()=>{n.forEach((e=>{a(o.$state,e)}))},n.forEach((r=>{i(o,r,e),o.$subscribe(((e,t)=>a(t,r)),{detached:!0})}))}(t,(i=>({key:(r.key?r.key:e=>e)(i.key??t.store.$id),debug:i.debug??r.debug??!1,serializer:i.serializer??r.serializer??{serialize:e=>JSON.stringify(e),deserialize:r=>e(r)},storage:i.storage??r.storage??window.localStorage,beforeHydrate:i.beforeHydrate,afterHydrate:i.afterHydrate,pick:i.pick,omit:i.omit})),r.auto??!1)}}();export{s};
//# sourceMappingURL=pinia-plugin-persistedstate-1ec13968.js.map
