import{r as a,j as n,b8 as d}from"./index-7T7TTikv.js";import{F as u,C as x,b as F,c as b}from"./index.esm-BRNlF2G3.js";import{L as I}from"./label-CABYEcfW.js";const p=u,l=a.createContext({}),j=({...e})=>n.jsx(l.Provider,{value:{name:e.name},children:n.jsx(x,{...e})}),c=()=>{const e=a.useContext(l),r=a.useContext(f),{getFieldState:t}=F(),o=b({name:e.name}),s=t(e.name,o);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:i}=r;return{id:i,name:e.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...s}},f=a.createContext({});function h({className:e,...r}){const t=a.useId();return n.jsx(f.Provider,{value:{id:t},children:n.jsx("div",{"data-slot":"form-item",className:d("grid gap-2",e),...r})})}function y({className:e,...r}){const{error:t,formItemId:o}=c();return n.jsx(I,{"data-slot":"form-label","data-error":!!t,className:d("data-[error=true]:text-destructive-foreground",e),htmlFor:o,...r})}function E({children:e,...r}){const{error:t,formItemId:o,formDescriptionId:s,formMessageId:i}=c(),m={id:o,"aria-describedby":t?`${s} ${i}`:s,"aria-invalid":!!t,...r};return a.isValidElement(e)?a.cloneElement(e,{...m,...e.props,id:o,"aria-describedby":m["aria-describedby"],"aria-invalid":m["aria-invalid"]}):n.jsx("div",{"data-slot":"form-control",...m,children:e})}function S({className:e,...r}){const{error:t,formMessageId:o}=c(),s=t?String((t==null?void 0:t.message)??""):r.children;return s?n.jsx("p",{"data-slot":"form-message",id:o,className:d("text-destructive-foreground text-sm",e),...r,children:s}):null}export{p as F,j as a,h as b,y as c,E as d,S as e};
