import{r as e,j as r}from"./router.chunk.YsRm4bSN.js";import{b as n}from"./forms.chunk.Bz8aaTWe.js";import{c as o,i as s,aV as a,F as d,a as l,p as t,B as u,b as c,d as i,e as f}from"./main.chunk.N-eZ2ybB.js";import{n as g}from"./icons.chunk.BwnSC3zE.js";const w=e.forwardRef(({className:e,...n},s)=>r.jsx("textarea",{className:o("growfund-flex growfund-min-h-[3.75rem] growfund-w-full growfund-rounded-md growfund-border growfund-border-border growfund-bg-transparent growfund-px-3 growfund-py-2 growfund-typo-small growfund-text-fg-primary placeholder:growfund-text-fg-subdued placeholder:growfund-font-regular growfund-ring-offset-2 focus-visible:growfund-ring-2 focus-visible:growfund-ring-ring disabled:growfund-cursor-not-allowed disabled:growfund-opacity-50",e),ref:s,...n}));function m({control:m,name:h,label:p,placeholder:b,description:x,disabled:j=!1,readOnly:y=!1,inline:v=!1,rows:N,cols:k,className:C,autoFocus:S=!1,shortCodes:R}){const F=e.useRef(null),$=e.useRef(null),O=e.useId(),[T,q]=e.useState(!1),{field:z}=n({control:m,name:h});return r.jsxs(r.Fragment,{children:[s(R)&&R.length>0&&r.jsx(a,{popoverRef:$,open:T,onOpenChange:e=>{q(e),e||F.current&&F.current.focus()},allShortcodes:R,onSelect:e=>{if(!F.current)return;const r=F.current,n=r.value,o=r.selectionStart,s=r.selectionEnd,a=`${n.substring(0,o)}${e}${n.substring(s)}`;z.onChange(a),setTimeout(()=>{r.focus();const n=o+e.length;r.setSelectionRange(n,n)},0)},popoverContainer:document.querySelector(`#${O}`)}),r.jsx(d,{control:m,name:h,render:({field:e,fieldState:n})=>r.jsxs(l,{className:o(v?"growfund-flex growfund-items-baseline gap-4":"growfund-space-y-2"),children:[(s(p)||s(R))&&r.jsxs("div",{className:"growfund-flex growfund-items-center growfund-justify-between",children:[s(p)&&r.jsx(t,{className:"growfund-flex-shrink-0",children:p}),s(R)&&R.length>0&&r.jsx(u,{variant:"ghost",size:"icon",onClick:()=>{q(!0)},children:r.jsx(g,{className:"growfund-text-icon-primary"})})]}),r.jsxs("div",{className:"growfund-space-y-2 growfund-w-full",children:[r.jsx(c,{children:r.jsx(w,{...e,id:O,ref:F,placeholder:b,value:String(e.value??""),readOnly:y,rows:N,cols:k,onChange:r=>{e.onChange(r.target.value)},autoFocus:S,autoComplete:"off",disabled:j,className:o("growfund-bg-background-white",!!n.error&&"growfund-border-border-critical growfund-bg-background-fill-critical-secondary",C)})}),s(x)&&r.jsx(i,{children:x}),r.jsx(f,{})]})]})})]})}w.displayName="Textarea";export{m as T,w as a};
