import{c as f}from"./create-recipe-context-BU56IzEo.js";import{r as c,j as l}from"./iframe-B8FSoBNY.js";import{q as v,g,m as x,a as h,e as b}from"./factory-BR3bc_RM.js";import{u as y}from"./use-field-context-DoxKQlMm.js";import{g as w}from"./computed-style-C0hzrq9-.js";var F=e=>{if(!e)return;const t=w(e),s=v(e),n=g(e),r=()=>{requestAnimationFrame(()=>{e.style.height="auto";let o;t.boxSizing==="content-box"?o=e.scrollHeight-(parseFloat(t.paddingTop)+parseFloat(t.paddingBottom)):o=e.scrollHeight+parseFloat(t.borderTopWidth)+parseFloat(t.borderBottomWidth),t.maxHeight!=="none"&&o>parseFloat(t.maxHeight)?(t.overflowY==="hidden"&&(e.style.overflowY="scroll"),o=parseFloat(t.maxHeight)):t.overflowY!=="hidden"&&(e.style.overflowY="hidden"),e.style.height=`${o}px`})};e.addEventListener("input",r),e.form?.addEventListener("reset",r);const i=Object.getPrototypeOf(e),a=Object.getOwnPropertyDescriptor(i,"value");a&&Object.defineProperty(e,"value",{...a,set(o){const u=a.get?.call(this);a.set?.call(this,o),r(),u!==o&&queueMicrotask(()=>{e.dispatchEvent(new s.InputEvent("input",{bubbles:!0}))})}});const d=new s.ResizeObserver(()=>{requestAnimationFrame(()=>r())});d.observe(e);const p=new s.MutationObserver(()=>r());return p.observe(e,{attributes:!0,attributeFilter:["rows","placeholder"]}),n.fonts?.addEventListener("loadingdone",r),()=>{e.removeEventListener("input",r),e.form?.removeEventListener("reset",r),n.fonts?.removeEventListener("loadingdone",r),d.disconnect(),p.disconnect()}};const m=c.forwardRef((e,t)=>{const{autoresize:s,...n}=e,r=c.useRef(null),i=y(),a=x(i?.getTextareaProps(),{style:{resize:s?"none":void 0}},n);return c.useEffect(()=>{if(s)return F(r.current)},[s]),l.jsx(h.textarea,{...a,ref:b(t,r)})});m.displayName="FieldTextarea";const{withContext:E}=f({key:"textarea"}),O=E(m);O.displayName="Textarea";export{O as T};
