{"version":3,"names":["state","onChange","createStore","toasts","showToast","message","type","id","Math","random","toString","substr","setTimeout","index","findIndex","toast","splice","toastStore"],"sources":["src/store/toast.store.ts"],"sourcesContent":["import { createStore } from '@stencil/store';\n\n// import { pb } from '../pocketbase';\n\ninterface IToast {\n id: string;\n message: string;\n type: 'success' | 'error' | 'warning' | 'info';\n}\n\ninterface State {\n toasts: IToast[];\n}\n\nconst { state, onChange } = createStore({\n toasts: [],\n});\n\nexport const showToast = (message: string, type: 'success' | 'error' | 'warning' | 'info') => {\n const id = Math.random().toString(36).substr(2, 9);\n state.toasts = [...state.toasts, { id, message, type }];\n\n setTimeout(() => {\n const index = state.toasts.findIndex((toast) => toast.id === id);\n if (index > -1) {\n state.toasts.splice(index, 1);\n }\n\n state.toasts = [ ...state.toasts ];\n }, 5000);\n}\n\nexport default {\n state,\n onChange,\n};\n"],"mappings":"oCAcA,MAAMA,MAAEA,EAAKC,SAAEA,GAAaC,EAAmB,CAC7CC,OAAQ,K,MAGGC,EAAY,CAACC,EAAiBC,KACzC,MAAMC,EAAKC,KAAKC,SAASC,SAAS,IAAIC,OAAO,EAAG,GAChDX,EAAMG,OAAS,IAAIH,EAAMG,OAAQ,CAAEI,KAAIF,UAASC,SAEhDM,YAAW,KACT,MAAMC,EAAQb,EAAMG,OAAOW,WAAWC,GAAUA,EAAMR,KAAOA,IAC7D,GAAIM,GAAS,EAAG,CACdb,EAAMG,OAAOa,OAAOH,EAAO,E,CAG7Bb,EAAMG,OAAS,IAAKH,EAAMG,OAAQ,GACjC,IAAK,EAGV,MAAAc,EAAe,CACbjB,QACAC,mB","ignoreList":[]}