import{ac as X,aV as p,cx as ee,af as te,cL as ae,aW as ne,aY as le,J as y,l as x,bh as oe,bc as ue,ax as ie,G as m,c2 as re,ag as se,a_ as ce,a$ as _,cy as de,q as l,cA as fe,K as I,F as R,N as z,cf as ve,cM as xe,cE as me,bZ as ge,ba as S,cF as he,bs as we,bl as Ve}from"./index-2e57ee69.js";const ye=X({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,...p(),...ee()},"VTextarea"),Ce=te()({name:"VTextarea",directives:{Intersect:ae},inheritAttrs:!1,props:ye(),emits:{"click:control":e=>!0,"mousedown:control":e=>!0,"update:focused":e=>!0,"update:modelValue":e=>!0},setup(e,G){let{attrs:F,emit:M,slots:i}=G;const o=ne(e,"modelValue"),{isFocused:f,focus:E,blur:D}=le(e),U=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 O(t,n){var a,u;!e.autofocus||!t||(u=(a=n[0].target)==null?void 0:a.focus)==null||u.call(a)}const N=x(),g=x(),A=oe(""),h=x(),j=y(()=>e.persistentPlaceholder||f.value||e.active);function C(){var t;h.value!==document.activeElement&&((t=h.value)==null||t.focus()),f.value||E()}function q(t){C(),M("click:control",t)}function J(t){M("mousedown:control",t)}function K(t){t.stopPropagation(),C(),S(()=>{o.value="",he(e["onClick:clear"],t)})}function L(t){var a;const n=t.target;if(o.value=n.value,(a=e.modelModifiers)!=null&&a.trim){const u=[n.selectionStart,n.selectionEnd];S(()=>{n.selectionStart=u[0],n.selectionEnd=u[1]})}}const c=x(),w=x(+e.rows),P=y(()=>["plain","underlined"].includes(e.variant));ue(()=>{e.autoGrow||(w.value=+e.rows)});function d(){e.autoGrow&&S(()=>{if(!c.value||!g.value)return;const t=getComputedStyle(c.value),n=getComputedStyle(g.value.$el),a=parseFloat(t.getPropertyValue("--v-field-padding-top"))+parseFloat(t.getPropertyValue("--v-input-padding-top"))+parseFloat(t.getPropertyValue("--v-field-padding-bottom")),u=c.value.scrollHeight,V=parseFloat(t.lineHeight),b=Math.max(parseFloat(e.rows)*V+a,parseFloat(n.getPropertyValue("--v-input-control-height"))),k=parseFloat(e.maxRows)*V+a||1/0,s=Ve(u??0,b,k);w.value=Math.floor((s-a)/V),A.value=we(s)})}ie(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()}),re(()=>{r==null||r.disconnect()}),se(()=>{const t=!!(i.counter||e.counter||e.counterValue),n=!!(t||i.details),[a,u]=ce(F),[{modelValue:V,...b}]=_.filterProps(e),[k]=de(e);return l(_,I({ref:N,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-text-field--plain-underlined":P.value},e.class],style:e.style},a,b,{centerAffix:w.value===1&&!P.value,focused:f.value}),{...i,default:s=>{let{isDisabled:v,isDirty:B,isReadonly:W,isValid:Y}=s;return l(fe,I({ref:g,style:{"--v-textarea-control-height":A.value},onClick:q,onMousedown:J,"onClick:clear":K,"onClick:prependInner":e["onClick:prependInner"],"onClick:appendInner":e["onClick:appendInner"]},k,{active:j.value||B.value,centerAffix:w.value===1&&!P.value,dirty:B.value||e.dirty,disabled:v.value,focused:f.value,error:Y.value===!1}),{...i,default:Z=>{let{props:{class:H,...T}}=Z;return l(R,null,[e.prefix&&l("span",{class:"v-text-field__prefix"},[e.prefix]),z(l("textarea",I({ref:h,class:H,value:o.value,onInput:L,autofocus:e.autofocus,readonly:W.value,disabled:v.value,placeholder:e.placeholder,rows:e.rows,name:e.name,onFocus:C,onBlur:D},T,u),null),[[ve("intersect"),{handler:O},null,{once:!0}]]),e.autoGrow&&z(l("textarea",{class:[H,"v-textarea__sizer"],id:`${T.id}-sizer`,"onUpdate:modelValue":Q=>o.value=Q,ref:c,readonly:!0,"aria-hidden":"true"},null),[[xe,o.value]]),e.suffix&&l("span",{class:"v-text-field__suffix"},[e.suffix])])}})},details:n?s=>{var v;return l(R,null,[(v=i.details)==null?void 0:v.call(i,s),t&&l(R,null,[l("span",null,null),l(me,{active:e.persistentCounter||f.value,value:U.value,max:$.value},i.counter)])])}:void 0})}),ge({},N,g,h)}});export{Ce as V};
