import{a as e}from"./chunk-Cyuzqnbw.js";import{i as t}from"./bundle-mjs-DssaXR6m.js";import{t as n}from"./useBaseUiId-DL38u1cQ.js";import{A as r,B as i,V as a,m as o,v as s,y as c,z as l}from"./api-DTaM-PBA.js";var u=e(t()),d=function(e){return e.disabled=`data-disabled`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),f={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},p={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},m={disabled:!1,...p},h={valid(e){return e===null?null:e?{[d.valid]:``}:{[d.invalid]:``}}},g={invalid:void 0,name:void 0,validityData:{state:f,errors:[],error:``,value:``,initialValue:null},setValidityData:c,disabled:void 0,touched:p.touched,setTouched:c,dirty:p.dirty,setDirty:c,filled:p.filled,setFilled:c,focused:p.focused,setFocused:c,validate:()=>null,validationMode:`onSubmit`,validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:m,markedDirtyRef:{current:!1},registerFieldControl:c,validation:{getValidationProps:(e=s)=>e,getInputValidationProps:(e=s)=>e,inputRef:{current:null},commit:async()=>{}}},_=u.createContext(g);function v(e=!0){let t=u.useContext(_);if(t.setValidityData===c&&!e)throw Error(l(28));return t}var y=u.createContext({controlId:void 0,registerControlId:c,labelId:void 0,setLabelId:c,messageIds:[],setMessageIds:c,getDescriptionProps:e=>e});function b(){return u.useContext(y)}function x(e={}){let{id:t,implicit:s=!1,controlRef:l}=e,{controlId:d,registerControlId:f}=b(),p=n(t),m=s?d:void 0,h=a(()=>Symbol(`labelable-control`)),g=u.useRef(!1),_=u.useRef(t!=null),v=o(()=>{!g.current||f===c||(g.current=!1,f(h.current,void 0))});return i(()=>{if(f===c)return;let e;if(s){let n=l?.current;e=r(n)&&n.closest(`label`)!=null?t??null:m??p}else if(t!=null)_.current=!0,e=t;else if(_.current)e=p;else{v();return}if(e===void 0){v();return}g.current=!0,f(h.current,e)},[t,l,m,f,s,p,h,v]),u.useEffect(()=>v,[v]),d??p}function S(e,t,n,r,a=!0){let{registerFieldControl:o}=v(),s=u.useRef(null);s.current||=Symbol(),i(()=>{let i=s.current;if(!(!i||!a))return o(i,{controlRef:e,getValue:r,id:t,value:n}),()=>{o(i,void 0)}},[e,a,r,t,o,n])}export{h as a,v as i,x as n,b as r,S as t};