import{P as n,_ as K,R as T,a1 as u,a2 as _,a0 as b,X as s,F as O,ai as Z,as as ee,m as ae,L as le,aE as te,M as p,J as oe,Q as se,T as r,$ as ne,e,Y as f}from"./vendor-D8NNcBCx.js";import{_ as ce,a6 as ue,a8 as re,bp as de,bU as me,g as U,h as ie,o as pe,bV as fe,q as ge,r as _e}from"./index-ID5VX6TZ.js";const be={};function ve(d,w){const t=n("VcButton"),v=n("VcModal");return T(),K(v,{variant:"success",title:d.$t("shared.account.profile_update_success_modal.title"),icon:"apply"},{actions:u(({close:c})=>[s(t,{class:"mx-auto",onClick:c},{default:u(()=>[_(b(d.$t("shared.account.profile_update_success_modal.ok_button")),1)]),_:1},8,["onClick"])]),default:u(()=>[_(" "+b(d.$t("shared.account.profile_update_success_modal.message")),1)]),_:1},8,["title"])}const Ce=ce(be,[["render",ve]]),ye={class:"flex gap-4"},Ve={class:"grow"},Ne={class:"grow"},he={class:"mt-5 w-1/2 self-center lg:self-auto"},g=64,we=O({__name:"profile",setup(d){const{t:w}=Z(),{user:t,updateUser:v}=ue(),{themeContext:c}=re(),{openModal:k}=pe(),{currentLanguage:q,removeLocaleFromUrl:x,unpinLocale:E}=de(),{currentCurrency:F,supportedCurrencies:I,saveCurrencyCode:P}=fe(),{mutate:A}=ee(me),D=ge(),{storeId:H,cultureName:R}=U;ie({title:ae(()=>w("pages.account.profile.meta.title"))});const W=le(te({firstName:p().trim().required().max(g),lastName:p().trim().required().max(g),defaultLanguage:p(),currencyCode:p()}));function M(){return{firstName:t.value.contact?.firstName??"",lastName:t.value.contact?.lastName??"",defaultLanguage:t.value?.contact?.defaultLanguage??c.value?.defaultLanguage?.cultureName,currencyCode:t.value?.contact?.currencyCode??c.value?.defaultCurrency?.code}}const{defineField:m,errors:i,isSubmitting:C,meta:y,handleSubmit:X,resetForm:z}=oe({validationSchema:W,initialValues:M()}),[V]=m("firstName"),[N]=m("lastName"),[h]=m("defaultLanguage"),[$]=m("currencyCode");function G(){E(),x()}async function J(){if(t.value?.contact?.currencyCode){await A({command:{storeId:H,userId:t.value.id,newCurrencyCode:t.value.contact.currencyCode,cultureName:R,currencyCode:U.currencyCode}});const a=I.value.find(l=>l.code===t.value.contact.currencyCode);a&&P(a.code,!1)}}const S=X(async a=>{await v(a),z({values:M()}),k({component:Ce,props:{async onClose(){q.value.cultureName!==a.defaultLanguage&&G(),F.value.code!==a.currencyCode&&await J(),D.emit(_e),location.reload()}}})});return(a,l)=>{const Q=n("VcTypography"),L=n("VcInput"),B=n("VcSelect"),Y=n("VcButton"),j=n("VcWidget");return T(),se("div",null,[s(Q,{tag:"h1"},{default:u(()=>[_(b(a.$t("pages.account.profile.title")),1)]),_:1}),s(j,{size:"lg"},{default:u(()=>[r("form",{class:"flex flex-col lg:w-1/2",onSubmit:l[4]||(l[4]=ne((...o)=>e(S)&&e(S)(...o),["prevent"]))},[s(L,{modelValue:e(V),"onUpdate:modelValue":l[0]||(l[0]=o=>f(V)?V.value=o:null),label:a.$t("common.labels.first_name"),placeholder:a.$t("common.placeholders.first_name"),disabled:e(C),maxlength:g,message:e(i).firstName,error:!!e(i).firstName,name:"firstName",class:"mb-5",required:""},null,8,["modelValue","label","placeholder","disabled","message","error"]),s(L,{modelValue:e(N),"onUpdate:modelValue":l[1]||(l[1]=o=>f(N)?N.value=o:null),label:a.$t("common.labels.last_name"),placeholder:a.$t("common.placeholders.first_name"),disabled:e(C),maxlength:g,message:e(i).lastName,error:!!e(i).lastName,name:"lastName",class:"mb-5",required:""},null,8,["modelValue","label","placeholder","disabled","message","error"]),s(L,{"model-value":e(t).email,label:a.$t("common.labels.email"),placeholder:a.$t("common.placeholders.first_name"),name:"email",autocomplete:"off",class:"mb-5",disabled:""},null,8,["model-value","label","placeholder"]),r("div",ye,[r("div",Ve,[s(B,{modelValue:e(h),"onUpdate:modelValue":l[2]||(l[2]=o=>f(h)?h.value=o:null),items:e(c).availableLanguages,label:a.$t("common.labels.default_language"),"text-field":"nativeName","value-field":"cultureName"},null,8,["modelValue","items","label"])]),r("div",Ne,[s(B,{modelValue:e($),"onUpdate:modelValue":l[3]||(l[3]=o=>f($)?$.value=o:null),items:e(c).availableCurrencies,label:a.$t("common.labels.default_currency"),"text-field":"code","value-field":"code"},null,8,["modelValue","items","label"])])]),r("div",he,[s(Y,{disabled:!e(y).dirty||!e(y).valid||e(y).pending,loading:e(C),type:"submit",class:"w-full lg:w-48"},{default:u(()=>[_(b(a.$t("common.buttons.update")),1)]),_:1},8,["disabled","loading"])])],32)]),_:1})])}}});export{we as default};
//# sourceMappingURL=profile-BBBPGXVD.js.map
