import{c as V}from"./component-C-Q4t0gB.js";import{n as x}from"./common-U_VzDrmL.js";import{_ as B}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{H as C,r as L,g as o,v as g,o as i,c as u,a as w,f as N,t as y,i as b,b as D,n as c,B as M,I as h}from"./index-Bb2UEb_P.js";function E(e,a){const r=a.split(",").map(l=>l.trim());for(const l of r)switch(l){case"FirstCapitalLetter":e=P(e);break;case"RussianCellPhone":e=U(e);break;case"DeleteSpace":e=A(e);break;case"AddUrlScheme":e=I(e);break}return e}const P=(e="")=>e.trim().split(/\s+/).filter(a=>a.length>0).map(a=>a[0].toLocaleUpperCase()+a.slice(1).toLocaleLowerCase()).join(" "),U=e=>e.startsWith("+7 ")&&e[3]!=="9"?`+7 9${e.slice(4)}`:e,A=e=>e.replace(/\s+/g,""),I=e=>{if(typeof e!="string")return e;let a=e.trim();return!a||/^(?:https?|ftps?):\/\//i.test(a)||!/^[^.\s]+\.[^.\s]+/.test(a)?a:"https://"+a},R={class:"tw-flex-none tw-w-64 tw-mr-4 tw-mb-4 sm:tw-mb-0"},T={key:0,class:"tw-text-red-500"},j={key:0,class:"tw-text-red-500 tw-mt-1"},z={__name:"BasicInput",props:h({label:{type:String,default:""},vertical:{type:Boolean,default:!1},name:{type:String,default:""},placeholder:{type:String,default:""},isPassword:{type:Boolean,default:!1},isNumber:{type:Boolean,default:!1},necessarily:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},regexp:{type:String,default:null},regexpErrorMessage:{type:String,default:null},formatters:{type:String,default:""}},{modelValue:{type:[String,Number]},modelModifiers:{}}),emits:h(["input","error"],["update:modelValue"]),setup(e,{emit:a}){const r=e,l=C(e,"modelValue"),n=a,s=L(null),v=o(()=>{const t=!r.disabled&&(r.necessarily&&!s.value||r.regexp&&!f.value);return t?n("error",!0):n("error",!1),t});function d(){let t=s.value;t=E(t,r.formatters),(r.name==="Name"||r.name==="Sourname"||r.name==="Lastname")&&(t=t.replace(/\s/g,""),t=t.charAt(0).toUpperCase()+t.slice(1)),l.value=t,n("input",t)}const k=o(()=>r.name==="BornDate"||r.name==="PasportDate"?"00.00.0000":null),m=o(()=>x(r.regexp)),f=o(()=>{if(!r.regexp||!s.value||!m.value)return!0;try{return m.value.test(s.value)}catch(t){return console.error(t),!0}});return g(l,t=>{s.value=t},{immediate:!0}),g(s,()=>{d()}),(t,p)=>(i(),u("div",{class:c([{"form-field__column":e.vertical},"form-field"])},[w("div",R,[N(y(e.label)+" ",1),e.necessarily?(i(),u("span",T," * ")):b("",!0)]),w("div",{class:c(["tw-w-full",{"form-field-input__wrapper_disabled":e.disabled}])},[D(M(V),{modelValue:s.value,"onUpdate:modelValue":p[0]||(p[0]=S=>s.value=S),disabled:e.disabled,mask:k.value,name:e.name,placeholder:e.placeholder,type:e.isPassword?"password":e.isNumber?"number":"text",class:c(["tw-text-black tw-placeholder-gray-300",{"tw-border-red-500":v.value}]),onInput:d},null,8,["modelValue","disabled","mask","name","placeholder","type","class"]),e.regexpErrorMessage&&!f.value?(i(),u("div",j,y(e.regexpErrorMessage),1)):b("",!0)],2)],2))}},$=B(z,[["__scopeId","data-v-5648755e"]]);export{$ as _,E as f};
