import{t as e}from"./http-BrugN6o-.js";import{t}from"./notification-BM55Quw3.js";import{n}from"./auth-CmHHJsI-.js";var r={name:null,phone:null,address_street_1:null,address_street_2:null,city:null,state:null,country_id:null,zip:null,type:null},{defineStore:i}=window.pinia,a=i(`customerUserStore`,{state:()=>({customers:[],userForm:{avatar:null,name:``,email:``,password:``,company:``,confirm_password:``,billing:{...r},shipping:{...r}}}),actions:{copyAddress(){this.userForm.shipping={...this.userForm.billing,type:`shipping`}},fetchCurrentUser(){let t=c();return new Promise((r,i)=>{e.get(`/api/v1/${t.companySlug}/customer/me`).then(e=>{Object.assign(this.userForm,e.data.data),r(e)}).catch(e=>{n(e),i(e)})})},updateCurrentUser({data:r,message:i}){let a=c();return new Promise((o,s)=>{e.post(`/api/v1/${a.companySlug}/customer/profile`,r).then(e=>{this.userForm=e.data.data,a.currentUser=e.data.data,o(e),i&&t(!0).showNotification({type:`success`,message:i})}).catch(e=>{n(e),s(e)})})}}}),{defineStore:o}=window.pinia,{global:s}=window.i18n,c=o(`CustomerPortalGlobalStore`,{state:()=>({languages:[],currency:null,isAppLoaded:!1,countries:[],getDashboardDataLoaded:!1,currentUser:null,companySlug:``,mainMenu:null,enabledModules:[]}),actions:{bootstrap(t){this.companySlug=t;let r=a();return new Promise((i,a)=>{e.get(`/api/v1/${t}/customer/bootstrap`).then(e=>{this.currentUser=e.data.data,this.mainMenu=e.data.meta.menu,this.currency=e.data.data.currency,this.enabledModules=e.data.meta.modules,Object.assign(r.userForm,e.data.data),typeof s.locale!=`string`&&(s.locale.value=e.data.meta.current_company_language||`en`),this.isAppLoaded=!0,i(e)}).catch(e=>{n(e),a(e)})})},fetchCountries(){return new Promise((t,r)=>{this.countries.length?t(this.countries):e.get(`/api/v1/${this.companySlug}/customer/countries`).then(e=>{this.countries=e.data.data,t(e)}).catch(e=>{n(e),r(e)})})}}});export{a as n,c as t};