import{ao as k,aq as I,g as v,at as y,bN as S,bO as z,v as V,aF as B,bP as b,bQ as P,c as w,o as n,w as q,b as g,E as s,e as c,l as f,a as N,m as o,ag as d,n as p,t as m,ai as j,bR as C}from"./Dk4AzF7j.js";import{L as F}from"./D9EMGUu-.js";const D={slots:{root:"",wrapper:"",labelWrapper:"flex content-center items-center justify-between",label:"block font-medium text-default",container:"mt-1 relative",description:"text-muted",error:"mt-2 text-error",hint:"text-muted",help:"mt-2 text-muted"},variants:{size:{xs:{root:"text-xs"},sm:{root:"text-xs"},md:{root:"text-sm"},lg:{root:"text-sm"},xl:{root:"text-base"}},required:{true:{label:"after:content-['*'] after:ms-0.5 after:text-error"}}},defaultVariants:{size:"md"}},E=["id"],O=["id"],K=["id"],W=["id"],R={__name:"UFormField",props:{as:{type:null,required:!1},name:{type:String,required:!1},errorPattern:{type:null,required:!1},label:{type:String,required:!1},description:{type:String,required:!1},help:{type:String,required:!1},error:{type:[Boolean,String],required:!1},hint:{type:String,required:!1},size:{type:null,required:!1},required:{type:Boolean,required:!1},eagerValidation:{type:Boolean,required:!1},validateOnInputDelay:{type:Number,required:!1},class:{type:null,required:!1},ui:{type:null,required:!1}},setup(t){const e=t,l=k(),x=I(),r=v(()=>y({extend:y(D),...x.ui?.formField||{}})({size:e.size,required:e.required})),$=S(z,null),i=v(()=>e.error||$?.value?.find(a=>a.name&&(a.name===e.name||e.errorPattern&&a.name.match(e.errorPattern)))?.message),h=V(B()),u=h.value;return b(C,h),b(P,v(()=>({error:i.value,name:e.name,size:e.size,eagerValidation:e.eagerValidation,validateOnInputDelay:e.validateOnInputDelay,errorPattern:e.errorPattern,hint:e.hint,description:e.description,help:e.help,ariaId:u}))),(a,L)=>(n(),w(o(j),{as:t.as,class:s(r.value.root({class:[e.ui?.root,e.class]}))},{default:q(()=>[g("div",{class:s(r.value.wrapper({class:e.ui?.wrapper}))},[t.label||l.label?(n(),c("div",{key:0,class:s(r.value.labelWrapper({class:e.ui?.labelWrapper}))},[N(o(F),{for:h.value,class:s(r.value.label({class:e.ui?.label}))},{default:q(()=>[d(a.$slots,"label",{label:t.label},()=>[p(m(t.label),1)])]),_:3},8,["for","class"]),t.hint||l.hint?(n(),c("span",{key:0,id:`${o(u)}-hint`,class:s(r.value.hint({class:e.ui?.hint}))},[d(a.$slots,"hint",{hint:t.hint},()=>[p(m(t.hint),1)])],10,E)):f("",!0)],2)):f("",!0),t.description||l.description?(n(),c("p",{key:1,id:`${o(u)}-description`,class:s(r.value.description({class:e.ui?.description}))},[d(a.$slots,"description",{description:t.description},()=>[p(m(t.description),1)])],10,O)):f("",!0)],2),g("div",{class:s([(t.label||!!l.label||t.description||!!l.description)&&r.value.container({class:e.ui?.container})])},[d(a.$slots,"default",{error:i.value}),typeof i.value=="string"&&i.value||l.error?(n(),c("div",{key:0,id:`${o(u)}-error`,class:s(r.value.error({class:e.ui?.error}))},[d(a.$slots,"error",{error:i.value},()=>[p(m(i.value),1)])],10,K)):t.help||l.help?(n(),c("div",{key:1,id:`${o(u)}-help`,class:s(r.value.help({class:e.ui?.help}))},[d(a.$slots,"help",{help:t.help},()=>[p(m(t.help),1)])],10,W)):f("",!0)],2)]),_:3},8,["as","class"]))}};export{R as _};
