import{r as F,j as e}from"./wp-i18n-shim-DUX0OV_V.js";import{L as v}from"./label-CwRAQd0m.js";import{I as A}from"./input-Dw-69aYW.js";import{C as m}from"./circle-alert-COuSc4NK.js";import{I as E}from"./withIconDefaults-BJCqj2oX.js";const $=(s,t="This field is required")=>s?typeof s=="string"?s:Array.isArray(s)?s[0]||t:typeof s=="object"&&(s.first_message||s.message||s.msg||s.error)||t:null,w=s=>s?typeof s=="string"||Array.isArray(s)?s.length>0:typeof s=="object"?!!(s.first_message||s.message||s.msg||s.error):!1:!1,C=F.memo(({id:s,label:t,value:f,onChange:x,error:r,type:o="text",placeholder:p,component:d=A,className:u="",labelClass:g="",required:h=!1,gap:n="gap-3",helperText:l,showValidation:j=!0,icon:i,disabled:c=!1,...b})=>{const a=w(r),N=$(r),y=()=>a?"border-red-300 focus:border-red-500 focus:ring-red-200 bg-red-50":"border-slate-300 focus:border-[#1d4ed8] focus:ring-blue-200";return e.jsxs("div",{className:`space-y-${n.includes("gap-")?n.replace("gap-",""):"3"}`,children:[e.jsxs(v,{htmlFor:s,className:`rtrb-label flex items-center gap-2 ${a?"text-red-700":""} ${g}`,children:[i&&e.jsx(i,{className:"h-4 w-4 text-slate-600"}),t,h&&e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(d,{id:s,type:o,value:f??"",onChange:x,placeholder:p,disabled:c,className:`h-[45px] text-base rounded-[8px] transition-all ${y()} ${u}`,...b}),j&&!c&&e.jsx(e.Fragment,{children:a&&e.jsx(m,{className:"absolute right-3 top-1/2 transform -translate-y-1/2 h-5 w-5 text-red-500 pointer-events-none"})})]}),a?e.jsxs("p",{className:"text-xs text-red-600 flex items-center gap-1",children:[e.jsx(m,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{children:N})]}):l?e.jsxs("p",{className:"text-xs text-small-font flex items-center gap-1",children:[e.jsx(E,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{children:l})]}):null]})});C.displayName="FormField";export{C as F};
//# sourceMappingURL=FormField-8HG4dTZR.js.map
