{"version":3,"file":"storebFuEZaoQ.js","sources":["../src/app/services/store.js"],"sourcesContent":["import { defineStore } from \"pinia\";\r\nimport api from \"./api.js\";\r\n\r\nexport const storeService = defineStore(\"main\", {\r\n\tstate: () => ({\r\n\t\tstore: {},\r\n\t}),\r\n\tgetters: {},\r\n\tactions: {\r\n\t\tasync getStore(storeSlug) {\r\n\t\t\t//throw new Error(\"Store not found\");\r\n\r\n\t\t\tif (this.store && this.store.slug == storeSlug) return this.store;\r\n\r\n\t\t\tvar theStore = await api\r\n\t\t\t\t.get(`Store/Store/${storeSlug}`, 10 * 1000)\r\n\t\t\t\t.then((response) => response)\r\n\t\t\t\t.catch((error) => {\r\n\t\t\t\t\tif (error.response && error.response.status === 404) {\r\n\t\t\t\t\t\tthrow new Error(\"Store not found\");\r\n\t\t\t\t\t} else if (error.response && error.response.message) {\r\n\t\t\t\t\t\tthrow new Error(error.response.message);\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tthrow new Error(\"An unknown error occurred\");\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\r\n\t\t\tObject.assign(this.store, theStore);\r\n\t\t\treturn this.store;\r\n\t\t},\r\n\t\tgetBranch(branchSlug) {\r\n\t\t\tif (!this.store || !this.store.branches) throw new Error(\"Store not found\");\r\n\r\n\t\t\tvar branch = this.store.branches.find((branch) => branch.slug === branchSlug);\r\n\t\t\tif (!branch) throw new Error(\"Branch not found\");\r\n\r\n\t\t\treturn branch;\r\n\t\t},\r\n\t\tsetStore(value) {\r\n\t\t\tObject.assign(this.store, value);\r\n\t\t},\r\n\t},\r\n});\r\n"],"names":["storeService","defineStore","storeSlug","theStore","api","response","error","branchSlug","branch","value"],"mappings":"wCAGY,MAACA,EAAeC,EAAY,OAAQ,CAC/C,MAAO,KAAO,CACb,MAAO,CAAE,CACX,GACC,QAAS,CAAE,EACX,QAAS,CACR,MAAM,SAASC,EAAW,CAGzB,GAAI,KAAK,OAAS,KAAK,MAAM,MAAQA,EAAW,OAAO,KAAK,MAE5D,IAAIC,EAAW,MAAMC,EACnB,IAAI,eAAeF,CAAS,GAAI,GAAK,GAAI,EACzC,KAAMG,GAAaA,CAAQ,EAC3B,MAAOC,GAAU,CACjB,MAAIA,EAAM,UAAYA,EAAM,SAAS,SAAW,IACzC,IAAI,MAAM,iBAAiB,EACvBA,EAAM,UAAYA,EAAM,SAAS,QACrC,IAAI,MAAMA,EAAM,SAAS,OAAO,EAEhC,IAAI,MAAM,2BAA2B,CAEjD,CAAK,EAEF,cAAO,OAAO,KAAK,MAAOH,CAAQ,EAC3B,KAAK,KACZ,EACD,UAAUI,EAAY,CACrB,GAAI,CAAC,KAAK,OAAS,CAAC,KAAK,MAAM,SAAU,MAAM,IAAI,MAAM,iBAAiB,EAE1E,IAAIC,EAAS,KAAK,MAAM,SAAS,KAAMA,GAAWA,EAAO,OAASD,CAAU,EAC5E,GAAI,CAACC,EAAQ,MAAM,IAAI,MAAM,kBAAkB,EAE/C,OAAOA,CACP,EACD,SAASC,EAAO,CACf,OAAO,OAAO,KAAK,MAAOA,CAAK,CAC/B,CACD,CACF,CAAC"}