import{g as ee,p as te,c6 as ae,a6 as ne,f as y,r as v,s as le,w as oe,ac as ue,a8 as m,bi as ie,j as re,aK as se,k as l,F as I,X as R,aG as T,aS as ce,c7 as de,aM as fe,ad as S,l as ve,bA as me,aN as xe}from"./index-DHJ8t5vF.js";import{u as ge,a as _,b as D,c as he,d as we,m as Ve}from"./VTextField-AERAqvmQ.js";const ye=te({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,...Ve(),...we()},"VTextarea"),Pe=ee()({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,E){let{attrs:F,emit:N,slots:i}=E;const o=ne(e,"modelValue"),{isFocused:f,focus:U,blur:O}=ge(e),j=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 K(t,n){var a,u;!e.autofocus||!t||(u=(a=n[0].target)==null?void 0:a.focus)==null||u.call(a)}const M=v(),x=v(),A=le(""),g=v(),X=y(()=>e.persistentPlaceholder||f.value||e.active);function C(){var t;g.value!==document.activeElement&&((t=g.value)==null||t.focus()),f.value||U()}function q(t){C(),N("click:control",t)}function J(t){N("mousedown:control",t)}function L(t){t.stopPropagation(),C(),S(()=>{o.value="",xe(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 u=[n.selectionStart,n.selectionEnd];S(()=>{n.selectionStart=u[0],n.selectionEnd=u[1]})}}const c=v(),h=v(Number(e.rows)),P=y(()=>["plain","underlined"].includes(e.variant));oe(()=>{e.autoGrow||(h.value=Number(e.rows))});function d(){e.autoGrow&&S(()=>{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")),u=c.value.scrollHeight,w=parseFloat(t.lineHeight),b=Math.max(parseFloat(e.rows)*w+a,parseFloat(n.getPropertyValue("--v-input-control-height"))),k=parseFloat(e.maxRows)*w+a||1/0,s=me(u??0,b,k);h.value=Math.floor((s-a)/w),A.value=ve(s)})}ue(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()}),ie(()=>{r==null||r.disconnect()}),re(()=>{const t=!!(i.counter||e.counter||e.counterValue),n=!!(t||i.details),[a,u]=se(F),{modelValue:w,...b}=_.filterProps(e),k=D.filterProps(e);return l(_,R({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,b,{centerAffix:h.value===1&&!P.value,focused:f.value}),{...i,default:s=>{let{id:V,isDisabled:B,isDirty:H,isReadonly:W,isValid:Y}=s;return l(D,R({ref:x,style:{"--v-textarea-control-height":A.value},onClick:q,onMousedown:J,"onClick:clear":L,"onClick:prependInner":e["onClick:prependInner"],"onClick:appendInner":e["onClick:appendInner"]},k,{id:V.value,active:X.value||H.value,centerAffix:h.value===1&&!P.value,dirty:H.value||e.dirty,disabled:B.value,focused:f.value,error:Y.value===!1}),{...i,default:Z=>{let{props:{class:z,...G}}=Z;return l(I,null,[e.prefix&&l("span",{class:"v-text-field__prefix"},[e.prefix]),T(l("textarea",R({ref:g,class:z,value:o.value,onInput:Q,autofocus:e.autofocus,readonly:W.value,disabled:B.value,placeholder:e.placeholder,rows:e.rows,name:e.name,onFocus:C,onBlur:O},G,u),null),[[ce("intersect"),{handler:K},null,{once:!0}]]),e.autoGrow&&T(l("textarea",{class:[z,"v-textarea__sizer"],id:`${G.id}-sizer`,"onUpdate:modelValue":p=>o.value=p,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(I,null,[(V=i.details)==null?void 0:V.call(i,s),t&&l(I,null,[l("span",null,null),l(he,{active:e.persistentCounter||f.value,value:j.value,max:$.value,disabled:e.disabled},i.counter)])])}:void 0})}),fe({},M,x,g)}});export{Pe as V};
