var p=Object.defineProperty,g=Object.defineProperties;var f=Object.getOwnPropertyDescriptors;var c=Object.getOwnPropertySymbols;var S=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable;var l=(e,a,t)=>a in e?p(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t,i=(e,a)=>{for(var t in a||(a={}))S.call(a,t)&&l(e,t,a[t]);if(c)for(var t of c(a))b.call(a,t)&&l(e,t,a[t]);return e},d=(e,a)=>g(e,f(a));import{h as r}from"./auth.a07e0850.js";import{u as y}from"./main.c7bd6c0e.js";import{a as u}from"./vendor.d12b5734.js";var m={name:null,phone:null,address_street_1:null,address_street_2:null,city:null,state:null,country_id:null,zip:null,type:null};const{defineStore:w}=window.pinia,U=w({id:"customerUserStore",state:()=>({customers:[],userForm:{avatar:null,name:"",email:"",password:"",company:"",confirm_password:"",billing:i({},m),shipping:i({},m)}}),actions:{copyAddress(){this.userForm.shipping=d(i({},this.userForm.billing),{type:"shipping"})},fetchCurrentUser(){const e=h();return new Promise((a,t)=>{u.get(`/api/v1/${e.companySlug}/customer/me`).then(s=>{Object.assign(this.userForm,s.data.data),a(s)}).catch(s=>{r(s),t(s)})})},updateCurrentUser({data:e,message:a}){const t=h();return new Promise((s,o)=>{u.post(`/api/v1/${t.companySlug}/customer/profile`,e).then(n=>{this.userForm=n.data.data,t.currentUser=n.data.data,s(n),a&&y(!0).showNotification({type:"success",message:a})}).catch(n=>{r(n),o(n)})})}}}),{defineStore:_}=window.pinia,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 a=U();return new Promise((t,s)=>{u.get(`/api/v1/${e}/customer/bootstrap`).then(o=>{this.currentUser=o.data.data,this.mainMenu=o.data.meta.menu,this.currency=o.data.data.currency,this.enabledModules=o.data.meta.modules,Object.assign(a.userForm,o.data.data),window.i18n.locale=o.data.default_language,this.isAppLoaded=!0,t(o)}).catch(o=>{r(o),s(o)})})},fetchCountries(){return new Promise((e,a)=>{this.countries.length?e(this.countries):u.get(`/api/v1/${this.companySlug}/customer/countries`).then(t=>{this.countries=t.data.data,e(t)}).catch(t=>{r(t),a(t)})})}}});export{U as a,h as u};