import{h as i}from"./auth-6FPSPboo.js";import{s as r,u as l}from"./main-B9dpPbRR.js";const u={name:null,phone:null,address_street_1:null,address_street_2:null,city:null,state:null,country_id:null,zip:null,type:null},{defineStore:d}=window.pinia,m=d({id:"customerUserStore",state:()=>({customers:[],userForm:{avatar:null,name:"",email:"",password:"",company:"",confirm_password:"",billing:{...u},shipping:{...u}}}),actions:{copyAddress(){this.userForm.shipping={...this.userForm.billing,type:"shipping"}},fetchCurrentUser(){const e=c();return new Promise((o,t)=>{r.get(`/api/v1/${e.companySlug}/customer/me`).then(s=>{Object.assign(this.userForm,s.data.data),o(s)}).catch(s=>{i(s),t(s)})})},updateCurrentUser({data:e,message:o}){const t=c();return new Promise((s,a)=>{r.post(`/api/v1/${t.companySlug}/customer/profile`,e).then(n=>{this.userForm=n.data.data,t.currentUser=n.data.data,s(n),o&&l(!0).showNotification({type:"success",message:o})}).catch(n=>{i(n),a(n)})})}}}),{defineStore:h}=window.pinia,c=h({id:"CustomerPortalGlobalStore",state:()=>({languages:[],currency:null,isAppLoaded:!1,countries:[],getDashboardDataLoaded:!1,currentUser:null,companySlug:"",mainMenu:null,enabledModules:[]}),actions:{bootstrap(e){this.companySlug=e;const o=m();return new Promise((t,s)=>{r.get(`/api/v1/${e}/customer/bootstrap`).then(a=>{this.currentUser=a.data.data,this.mainMenu=a.data.meta.menu,this.currency=a.data.data.currency,this.enabledModules=a.data.meta.modules,Object.assign(o.userForm,a.data.data),window.i18n.locale=a.data.default_language,this.isAppLoaded=!0,t(a)}).catch(a=>{i(a),s(a)})})},fetchCountries(){return new Promise((e,o)=>{this.countries.length?e(this.countries):r.get(`/api/v1/${this.companySlug}/customer/countries`).then(t=>{this.countries=t.data.data,e(t)}).catch(t=>{i(t),o(t)})})}}});export{m as a,c as u};
