import{I as V,J as f,h as N,K as w,r as z,Z as $,k as C,l as q,Y as F,v as A,S as H,U as R,o as D,c as J,a as P,P as U,M as E,B as G,a3 as K}from"./entry.RGd0w9hd.js";import{t as Y,u as Z}from"./selectMenu.C9lwG85K.js";import{u as L}from"./useFormGroup.Y2N1Wpzd.js";import{_ as Q}from"./_plugin-vue_export-helper.x3n3nnut.js";import"./uid.KLLbMoZc.js";import"./index.g8c07QCY.js";const o=V(f.ui.strategy,f.ui.textarea,Y),W=N({inheritAttrs:!1,props:{modelValue:{type:[String,Number],default:""},id:{type:String,default:null},name:{type:String,default:null},placeholder:{type:String,default:null},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},rows:{type:Number,default:3},autoresize:{type:Boolean,default:!1},autofocus:{type:Boolean,default:!1},autofocusDelay:{type:Number,default:100},resize:{type:Boolean,default:!1},padded:{type:Boolean,default:!0},size:{type:String,default:null,validator(e){return Object.keys(o.size).includes(e)}},color:{type:String,default:()=>o.default.color,validator(e){return[...f.ui.colors,...Object.keys(o.color)].includes(e)}},variant:{type:String,default:()=>o.default.variant,validator(e){return[...Object.keys(o.variant),...Object.values(o.color).flatMap(t=>Object.keys(t))].includes(e)}},textareaClass:{type:String,default:null},class:{type:[String,Object,Array],default:()=>""},ui:{type:Object,default:()=>({})},modelModifiers:{type:Object,default:()=>({})}},emits:["update:modelValue","blur"],setup(e,{emit:t}){const{ui:l,attrs:m}=Z("textarea",w(e,"ui"),o,w(e,"class")),{emitFormBlur:p,emitFormInput:c,inputId:r,color:v,size:g,name:I}=L(e,o),n=z($({},e.modelModifiers,{trim:!1,lazy:!1,number:!1})),u=z(null),y=()=>{var a;e.autofocus&&((a=u.value)==null||a.focus())},d=()=>{if(e.autoresize){if(!u.value)return;u.value.rows=e.rows;const a=window.getComputedStyle(u.value),s=parseInt(a.paddingTop),i=parseInt(a.paddingBottom),O=s+i,M=parseInt(a.lineHeight),{scrollHeight:T}=u.value,B=(T-O)/M;B>e.rows&&(u.value.rows=B)}},b=a=>{n.value.trim&&(a=a.trim()),n.value.number&&(a=K(a)),t("update:modelValue",a),c()},S=a=>{d(),n.value.lazy||b(a.target.value)},h=a=>{const s=a.target.value;n.value.lazy&&b(s),n.value.trim&&(a.target.value=s.trim())},j=a=>{t("blur",a),p()};C(()=>{setTimeout(()=>{y()},e.autofocusDelay)}),q(()=>e.modelValue,()=>{F(d)}),C(()=>{setTimeout(()=>{y(),d()},100)});const k=A(()=>{var s,i;const a=((i=(s=l.value.color)==null?void 0:s[v.value])==null?void 0:i[e.variant])||l.value.variant[e.variant];return H(R(l.value.base,l.value.form,l.value.rounded,l.value.placeholder,l.value.size[g.value],e.padded?l.value.padding[g.value]:"p-0",a==null?void 0:a.replaceAll("{color}",v.value),!e.resize&&"resize-none"),e.textareaClass)});return{ui:l,attrs:m,name:I,inputId:r,textarea:u,textareaClass:k,onInput:S,onChange:h,onBlur:j}}}),X=["id","value","name","rows","required","disabled","placeholder"];function x(e,t,l,m,p,c){return D(),J("div",{class:G(e.ui.wrapper)},[P("textarea",U({id:e.inputId,ref:"textarea",value:e.modelValue,name:e.name,rows:e.rows,required:e.required,disabled:e.disabled,placeholder:e.placeholder,class:e.textareaClass},e.attrs,{onInput:t[0]||(t[0]=(...r)=>e.onInput&&e.onInput(...r)),onBlur:t[1]||(t[1]=(...r)=>e.onBlur&&e.onBlur(...r)),onChange:t[2]||(t[2]=(...r)=>e.onChange&&e.onChange(...r))}),null,16,X),E(e.$slots,"default")],2)}const re=Q(W,[["render",x]]);export{re as default};
