import{Ct as e,n as t}from"./vue-vendor-DMUmTARL.js";import{n}from"./index-kSn5YXd0.js";var r=e=>n({url:`/api/favorite/add`,method:`post`,data:e}),i=e=>n({url:`/api/favorite/remove`,method:`delete`,data:e}),a=e=>n({url:`/api/favorite/list`,method:`get`,data:e}),o=e=>n({url:`/api/favorite/keys`,method:`get`,data:{storageKey:e},config:{showDefaultMsg:!1}}),s=()=>n({url:`/api/favorite/invalid`,method:`delete`}),c=t(`favoriteStore`,()=>{let t=e({}),n=e(new Set),a=(e,n)=>{if(!e||!n)return!1;let r=t[e];return r?r.has(n):!1},s=(e,n)=>{t[e]||(t[e]=new Set),t[e].add(n)},c=(e,n)=>{t[e]?.delete(n)};return{favoriteMap:t,isFavorited:a,markFavorited:s,unmarkFavorited:c,loadKeys:async(e,r=!1)=>{if(e&&!(!r&&n.has(e)))try{let r=(await o(e))?.data||[];t[e]=new Set(r),n.add(e)}catch{}},addFavorite:async e=>{let{storageKey:t,fullPath:n}=e;if(!a(t,n)){s(t,n);try{await r(e)}catch(e){throw c(t,n),e}}},removeFavorite:async(e,t)=>{if(a(e,t)){c(e,t);try{await i({storageKey:e,fullPath:t})}catch(n){throw s(e,t),n}}},clear:()=>{Object.keys(t).forEach(e=>{delete t[e]}),n.clear()}}});export{i,s as n,a as r,c as t};