import{A as p,B as ee,aw as te,c as y,g as v,s as ae,at as ne,W as le,w as m,X as oe,I as ie,ac as R,aU as ue,aN as re,bL as se,d as l,K as k,F as S,R as _,b8 as ce,ah as de,c1 as fe}from"./main-CJbVOHh0.js";import{a as ve,f as me,b as xe,c as ge}from"./VTextField-Dp4iab_E.js";import{b as he,m as we,d as G}from"./VInput-DB7cgrUt.js";import{f as Ve}from"./forwardRefs-D3j0TLhE.js";import{I as ye}from"./VImg-CzIdDjU-.js";const Fe=ee({autoGrow:Boolean,autofocus:Boolean,counter:[Boolean,Number,String],counterValue:Function,prefix:String,placeholder:String,persistentPlaceholder:Boolean,persistentCounter:Boolean,noResize:Boolean,rows:{type:[Number,String],default:5,validator:e=>!isNaN(parseFloat(e))},maxRows:{type:[Number,String],validator:e=>!isNaN(parseFloat(e))},suffix:String,modelModifiers:Object,...we(),...ve()},"VTextarea"),ke=p()({name:"VTextarea",directives:{Intersect:ye},inheritAttrs:!1,props:Fe(),emits:{"click:control":e=>!0,"mousedown:control":e=>!0,"update:focused":e=>!0,"update:modelValue":e=>!0},setup(e,U){let{attrs:F,emit:B,slots:u}=U;const o=te(e,"modelValue"),{isFocused:f,focus:D,blur:E}=he(e),O=y(()=>typeof e.counterValue=="function"?e.counterValue(o.value):(o.value||"").toString().length),$=y(()=>{if(F.maxlength)return F.maxlength;if(!(!e.counter||typeof e.counter!="number"&&typeof e.counter!="string"))return e.counter});function j(t,n){var a,i;!e.autofocus||!t||(i=(a=n[0].target)==null?void 0:a.focus)==null||i.call(a)}const M=v(),x=v(),N=ae(""),g=v(),K=y(()=>e.persistentPlaceholder||f.value||e.active);function C(){var t;g.value!==document.activeElement&&((t=g.value)==null||t.focus()),f.value||D()}function L(t){C(),B("click:control",t)}function W(t){B("mousedown:control",t)}function X(t){t.stopPropagation(),C(),R(()=>{o.value="",fe(e["onClick:clear"],t)})}function q(t){var a;const n=t.target;if(o.value=n.value,(a=e.modelModifiers)!=null&&a.trim){const i=[n.selectionStart,n.selectionEnd];R(()=>{n.selectionStart=i[0],n.selectionEnd=i[1]})}}const c=v(),h=v(+e.rows),P=y(()=>["plain","underlined"].includes(e.variant));ne(()=>{e.autoGrow||(h.value=+e.rows)});function d(){e.autoGrow&&R(()=>{if(!c.value||!x.value)return;const t=getComputedStyle(c.value),n=getComputedStyle(x.value.$el),a=parseFloat(t.getPropertyValue("--v-field-padding-top"))+parseFloat(t.getPropertyValue("--v-input-padding-top"))+parseFloat(t.getPropertyValue("--v-field-padding-bottom")),i=c.value.scrollHeight,w=parseFloat(t.lineHeight),I=Math.max(parseFloat(e.rows)*w+a,parseFloat(n.getPropertyValue("--v-input-control-height"))),b=parseFloat(e.maxRows)*w+a||1/0,s=re(i??0,I,b);h.value=Math.floor((s-a)/w),N.value=ue(s)})}le(d),m(o,d),m(()=>e.rows,d),m(()=>e.maxRows,d),m(()=>e.density,d);let r;return m(c,t=>{t?(r=new ResizeObserver(d),r.observe(c.value)):r==null||r.disconnect()}),oe(()=>{r==null||r.disconnect()}),ie(()=>{const t=!!(u.counter||e.counter||e.counterValue),n=!!(t||u.details),[a,i]=se(F),{modelValue:w,...I}=G.filterProps(e),b=me(e);return l(G,k({ref:M,modelValue:o.value,"onUpdate:modelValue":s=>o.value=s,class:["v-textarea v-text-field",{"v-textarea--prefixed":e.prefix,"v-textarea--suffixed":e.suffix,"v-text-field--prefixed":e.prefix,"v-text-field--suffixed":e.suffix,"v-textarea--auto-grow":e.autoGrow,"v-textarea--no-resize":e.noResize||e.autoGrow,"v-input--plain-underlined":P.value},e.class],style:e.style},a,I,{centerAffix:h.value===1&&!P.value,focused:f.value}),{...u,default:s=>{let{id:V,isDisabled:A,isDirty:H,isReadonly:J,isValid:Q}=s;return l(ge,k({ref:x,style:{"--v-textarea-control-height":N.value},onClick:L,onMousedown:W,"onClick:clear":X,"onClick:prependInner":e["onClick:prependInner"],"onClick:appendInner":e["onClick:appendInner"]},b,{id:V.value,active:K.value||H.value,centerAffix:h.value===1&&!P.value,dirty:H.value||e.dirty,disabled:A.value,focused:f.value,error:Q.value===!1}),{...u,default:Y=>{let{props:{class:z,...T}}=Y;return l(S,null,[e.prefix&&l("span",{class:"v-text-field__prefix"},[e.prefix]),_(l("textarea",k({ref:g,class:z,value:o.value,onInput:q,autofocus:e.autofocus,readonly:J.value,disabled:A.value,placeholder:e.placeholder,rows:e.rows,name:e.name,onFocus:C,onBlur:E},T,i),null),[[ce("intersect"),{handler:j},null,{once:!0}]]),e.autoGrow&&_(l("textarea",{class:[z,"v-textarea__sizer"],id:`${T.id}-sizer`,"onUpdate:modelValue":Z=>o.value=Z,ref:c,readonly:!0,"aria-hidden":"true"},null),[[de,o.value]]),e.suffix&&l("span",{class:"v-text-field__suffix"},[e.suffix])])}})},details:n?s=>{var V;return l(S,null,[(V=u.details)==null?void 0:V.call(u,s),t&&l(S,null,[l("span",null,null),l(xe,{active:e.persistentCounter||f.value,value:O.value,max:$.value,disabled:e.disabled},u.counter)])])}:void 0})}),Ve({},M,x,g)}});export{ke as V};
