import{t as e}from"./http-BdoVLsWz.js";import{n as t}from"./notification-BM55Quw3.js";import{t as n}from"./error-handling-CuGxlkPL.js";var r=(r=!1)=>{let i=r?window.pinia.defineStore:t,{global:a}=window.i18n;return i(`notes`,{state:()=>({notes:[],currentNote:{id:null,type:``,is_default:!1,name:``,notes:``}}),getters:{isEdit:e=>!!e.currentNote.id},actions:{getDefaultNoteForType(e){return this.notes.find(t=>t.type===e&&t.is_default)},resetCurrentNote(){this.currentNote={type:``,is_default:!1,name:``,notes:``}},fetchNotes(t){return new Promise((r,i)=>{e.get(`/api/v1/notes`,{params:t}).then(e=>{this.notes=e.data.data,r(e)}).catch(e=>{n(e),i(e)})})},fetchNote(t){return new Promise((r,i)=>{e.get(`/api/v1/notes/${t}`).then(e=>{this.currentNote=e.data.data,r(e)}).catch(e=>{n(e),i(e)})})},addNote(t){return new Promise((r,i)=>{e.post(`/api/v1/notes`,t).then(e=>{this.notes.push(e.data),r(e)}).catch(e=>{n(e),i(e)})})},updateNote(t){return new Promise((r,i)=>{e.put(`/api/v1/notes/${t.id}`,t).then(e=>{if(e.data){let n=this.notes.findIndex(t=>t.id===e.data.data.id);this.notes[n]=t.notes}r(e)}).catch(e=>{n(e),i(e)})})},deleteNote(t){return new Promise((r,i)=>{e.delete(`/api/v1/notes/${t}`).then(e=>{let n=this.notes.findIndex(e=>e.id===t);this.notes.splice(n,1),r(e)}).catch(e=>{n(e),i(e)})})}}})()};export{r as t};