import{G as I,v as S,e as V,j as p,f as P,J as q,g as C,i as k,r as u,K as j,o as x,w as r,b as c,m as D,a as s,l as a,q as y,t as M,M as N}from"./main-FAzQ_AST.js";import{u as G}from"./payment-e0dcl5MG.js";const z={class:"flex justify-between w-full"},A={class:"p-4 sm:p-6"},L={class:"z-0 flex justify-end p-4 border-t border-gray-200 border-solid"},K={__name:"PaymentModeModal",setup(T){const o=I(),e=G(),{t:v}=S.useI18n(),l=V(!1),g=p(()=>({currentPaymentMode:{name:{required:P.withMessage(v("validation.required"),C),minLength:P.withMessage(v("validation.name_min_length",{count:3}),q(3))}}})),t=k(g,p(()=>e)),h=p(()=>o.active&&o.componentName==="PaymentModeModal");async function B(){if(t.value.currentPaymentMode.$touch(),t.value.currentPaymentMode.$invalid)return!0;try{const n=e.currentPaymentMode.id?e.updatePaymentMode:e.addPaymentMode;l.value=!0,await n(e.currentPaymentMode),l.value=!1,o.refreshData&&o.refreshData(),d()}catch{return l.value=!1,!0}}function d(){o.closeModal(),setTimeout(()=>{t.value.$reset(),e.currentPaymentMode={id:"",name:null}})}return(n,m)=>{const f=u("BaseIcon"),$=u("BaseInput"),b=u("BaseInputGroup"),_=u("BaseButton"),w=u("BaseModal");return x(),j(w,{show:h.value,onClose:d},{header:r(()=>[c("div",z,[y(M(a(o).title)+" ",1),s(f,{name:"XMarkIcon",class:"w-6 h-6 text-gray-500 cursor-pointer",onClick:d})])]),default:r(()=>[c("form",{action:"",onSubmit:D(B,["prevent"])},[c("div",A,[s(b,{label:n.$t("settings.payment_modes.mode_name"),error:a(t).currentPaymentMode.name.$error&&a(t).currentPaymentMode.name.$errors[0].$message,required:""},{default:r(()=>[s($,{modelValue:a(e).currentPaymentMode.name,"onUpdate:modelValue":m[0]||(m[0]=i=>a(e).currentPaymentMode.name=i),invalid:a(t).currentPaymentMode.name.$error,onInput:m[1]||(m[1]=i=>a(t).currentPaymentMode.name.$touch())},null,8,["modelValue","invalid"])]),_:1},8,["label","error"])]),c("div",L,[s(_,{variant:"primary-outline",class:"mr-3",type:"button",onClick:d},{default:r(()=>[y(M(n.$t("general.cancel")),1)]),_:1}),s(_,{loading:l.value,disabled:l.value,variant:"primary",type:"submit"},{left:r(i=>[s(f,{name:"ArrowDownOnSquareIcon",class:N(i.class)},null,8,["class"])]),default:r(()=>[y(" "+M(a(e).currentPaymentMode.id?n.$t("general.update"):n.$t("general.save")),1)]),_:1},8,["loading","disabled"])])],32)]),_:1},8,["show"])}}};export{K as _};
