import{o as h,r as g,a as y,F as I,C,b as j}from"./vendor-forms-Bkp1rCGP.js";import{j as c}from"./vendor-query-BSpUEUJE.js";import{r as i}from"./vendor-react-CWq2BoMo.js";import{k as N}from"./vendor-ui-core-BWFXPlYg.js";import{a as u}from"./index-DVdSf46I.js";import{L as w}from"./Index-CsHtvMhJ.js";var E=function(o,t){for(var r={};o.length;){var e=o[0],a=e.code,s=e.message,n=e.path.join(".");if(!r[n])if("unionErrors"in e){var m=e.unionErrors[0].errors[0];r[n]={message:m.message,type:m.code}}else r[n]={message:s,type:a};if("unionErrors"in e&&e.unionErrors.forEach(function(x){return x.errors.forEach(function(v){return o.push(v)})}),t){var d=r[n].types,f=d&&d[e.code];r[n]=y(n,t,r,a,f?[].concat(f,e.message):e.message)}o.shift()}return r},k=function(o,t,r){return r===void 0&&(r={}),function(e,a,s){try{return Promise.resolve(function(n,m){try{var d=Promise.resolve(o[r.mode==="sync"?"parse":"parseAsync"](e,t)).then(function(f){return s.shouldUseNativeValidation&&h({},s),{errors:{},values:r.raw?e:f}})}catch(f){return m(f)}return d&&d.then?d.then(void 0,m):d}(0,function(n){if(function(m){return Array.isArray(m==null?void 0:m.errors)}(n))return{values:{},errors:g(E(n.errors,!s.shouldUseNativeValidation&&s.criteriaMode==="all"),s)};throw n}))}catch(n){return Promise.reject(n)}}};const q=I,p=i.createContext({}),z=({...o})=>c.jsx(p.Provider,{value:{name:o.name},children:c.jsx(C,{...o})}),l=()=>{const o=i.useContext(p),t=i.useContext(F),{getFieldState:r,formState:e}=j(),a=r(o.name,e);if(!o)throw new Error("useFormField should be used within <FormField>");const{id:s}=t;return{id:s,name:o.name,formItemId:`${s}-form-item`,formDescriptionId:`${s}-form-item-description`,formMessageId:`${s}-form-item-message`,...a}},F=i.createContext({}),b=i.forwardRef(({className:o,...t},r)=>{const e=i.useId();return c.jsx(F.Provider,{value:{id:e},children:c.jsx("div",{ref:r,className:u("space-y-2",o),...t})})});b.displayName="FormItem";const M=i.forwardRef(({className:o,...t},r)=>{const{error:e,formItemId:a}=l();return c.jsx(w,{ref:r,className:u(e&&"text-destructive",o),htmlFor:a,...t})});M.displayName="FormLabel";const P=i.forwardRef(({...o},t)=>{const{error:r,formItemId:e,formDescriptionId:a,formMessageId:s}=l();return c.jsx(N,{ref:t,id:e,"aria-describedby":r?`${a} ${s}`:`${a}`,"aria-invalid":!!r,...o})});P.displayName="FormControl";const R=i.forwardRef(({className:o,...t},r)=>{const{formDescriptionId:e}=l();return c.jsx("p",{ref:r,id:e,className:u("text-sm text-muted-foreground",o),...t})});R.displayName="FormDescription";const D=i.forwardRef(({className:o,children:t,...r},e)=>{const{error:a,formMessageId:s}=l(),n=a?String(a==null?void 0:a.message):t;return n?c.jsx("p",{ref:e,id:s,className:u("text-sm font-medium text-destructive",o),...r,children:n}):null});D.displayName="FormMessage";export{q as F,z as a,b,M as c,P as d,D as e,R as f,k as t};
