import{g as re,p as se,b6 as p,a5 as ce,a7 as b,a1 as h,a2 as de,X as fe,b5 as ve,ak as me,a8 as f,aR as xe,c as ge,aA as he,d as A,i as r,F as B,E as M,I as O,aU as we,e as Ve,aJ as z,af as ye,a9 as P,aZ as Fe,aB as Ce}from"./index-B7JqxkHf.js";import{a as be,g as Pe,b as W,c as $,d as ke,k as Ie,e as Re,f as Ne,l as Se}from"./VTextField-Cxcf3dh_.js";const He=se({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))},maxHeight:{type:[Number,String],validator:e=>!isNaN(parseFloat(e))},maxRows:{type:[Number,String],validator:e=>!isNaN(parseFloat(e))},suffix:String,modelModifiers:Object,...Se(),...Ne(),...Re()},"VTextarea"),Me=re()({name:"VTextarea",directives:{vIntersect:p},inheritAttrs:!1,props:He(),emits:{"click:control":e=>!0,"mousedown:control":e=>!0,"update:focused":e=>!0,"update:modelValue":e=>!0,"update:rows":e=>!0},setup(e,j){let{attrs:k,emit:I,slots:o}=j;const l=ce(e,"modelValue"),{isFocused:w,focus:J,blur:X}=be(e),{onIntersect:Z}=Ie(e),q=b(()=>typeof e.counterValue=="function"?e.counterValue(l.value):(l.value||"").toString().length),K=b(()=>{if(k.maxlength)return k.maxlength;if(!(!e.counter||typeof e.counter!="number"&&typeof e.counter!="string"))return e.counter}),T=h(),y=h(),_=de(""),v=h(),R=h(0),{platform:L}=fe(),F=Pe(e),Q=b(()=>e.persistentPlaceholder||w.value||e.active);function N(){var t;F.isSuppressing.value&&F.update(),v.value!==document.activeElement&&((t=v.value)==null||t.focus()),w.value||J()}function Y(t){N(),I("click:control",t)}function ee(t){I("mousedown:control",t)}function te(t){t.stopPropagation(),N(),P(()=>{l.value="",Ce(e["onClick:clear"],t)})}function ae(t){var g;const a=t.target;if(!((g=e.modelModifiers)!=null&&g.trim)){l.value=a.value;return}const n=a.value,x=a.selectionStart,c=a.selectionEnd;l.value=n,P(()=>{let d=0;n.trimStart().length===a.value.length&&(d=n.length-a.value.length),x!=null&&(a.selectionStart=x-d),c!=null&&(a.selectionEnd=c-d)})}const m=h(),V=h(Number(e.rows)),S=b(()=>["plain","underlined"].includes(e.variant));ve(()=>{e.autoGrow||(V.value=Number(e.rows))});function s(){P(()=>{if(!v.value)return;if(L.value.firefox){R.value=12;return}const{offsetWidth:t,clientWidth:a}=v.value;R.value=Math.max(0,t-a)}),e.autoGrow&&P(()=>{if(!m.value||!y.value)return;const t=getComputedStyle(m.value),a=getComputedStyle(y.value.$el),n=parseFloat(t.getPropertyValue("--v-field-padding-top"))+parseFloat(t.getPropertyValue("--v-input-padding-top"))+parseFloat(t.getPropertyValue("--v-field-padding-bottom")),x=m.value.scrollHeight,c=parseFloat(t.lineHeight),g=Math.max(parseFloat(e.rows)*c+n,parseFloat(a.getPropertyValue("--v-input-control-height"))),d=e.maxHeight?parseFloat(e.maxHeight):parseFloat(e.maxRows)*c+n||1/0,i=Fe(x??0,g,d);V.value=Math.floor((i-n)/c),_.value=z(i)})}me(s),f(l,s),f(()=>e.rows,s),f(()=>e.maxHeight,s),f(()=>e.maxRows,s),f(()=>e.density,s),f(V,t=>{I("update:rows",t)});let u;return f(m,t=>{t?(u=new ResizeObserver(s),u.observe(m.value)):u==null||u.disconnect()}),xe(()=>{u==null||u.disconnect()}),ge(()=>{const t=!!(o.counter||e.counter||e.counterValue),a=!!(t||o.details),[n,x]=he(k),{modelValue:c,...g}=W.filterProps(e),d={...$.filterProps(e),"onClick:clear":te};return A(W,M({ref:T,modelValue:l.value,"onUpdate:modelValue":i=>l.value=i,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":S.value},e.class],style:[{"--v-textarea-max-height":e.maxHeight?z(e.maxHeight):void 0,"--v-textarea-scroll-bar-width":z(R.value)},e.style]},n,g,{centerAffix:V.value===1&&!S.value,focused:w.value}),{...o,default:i=>{let{id:C,isDisabled:D,isDirty:E,isReadonly:le,isValid:ne,hasDetails:oe}=i;return A($,M({ref:y,style:{"--v-textarea-control-height":_.value},onClick:Y,onMousedown:ee,"onClick:prependInner":e["onClick:prependInner"],"onClick:appendInner":e["onClick:appendInner"]},d,{id:C.value,active:Q.value||E.value,centerAffix:V.value===1&&!S.value,dirty:E.value||e.dirty,disabled:D.value,focused:w.value,details:oe.value,error:ne.value===!1}),{...o,default:ue=>{let{props:{class:G,...U},controlRef:ie}=ue;return r(B,null,[e.prefix&&r("span",{class:"v-text-field__prefix"},[e.prefix]),O(r("textarea",M({ref:H=>v.value=ie.value=H,class:G,value:l.value,onInput:ae,autofocus:e.autofocus,readonly:le.value,disabled:D.value,placeholder:e.placeholder,rows:e.rows,name:F.fieldName.value,autocomplete:F.fieldAutocomplete.value,onFocus:N,onBlur:X},U,x),null),[[p,{handler:Z},null,{once:!0}]]),e.autoGrow&&O(r("textarea",{class:Ve([G,"v-textarea__sizer"]),id:`${U.id}-sizer`,"onUpdate:modelValue":H=>l.value=H,ref:m,readonly:!0,"aria-hidden":"true"},null),[[we,l.value]]),e.suffix&&r("span",{class:"v-text-field__suffix"},[e.suffix])])}})},details:a?i=>{var C;return r(B,null,[(C=o.details)==null?void 0:C.call(o,i),t&&r(B,null,[r("span",null,null),A(ke,{active:e.persistentCounter||w.value,value:q.value,max:K.value,disabled:e.disabled},o.counter)])])}:void 0})}),ye({},T,y,v)}});export{Me as V};