import{E as k,G as i,g as O,j as n,r as T,s as y,D as V,S as F,N as q,o as N,c as $,a as x,K as G,y as H}from"./entry.9e31e8a4.js";import{t as M}from"./tw-merge.27ca352e.js";import{t as A,u as E}from"./ui.config.7ae255de.js";import{u as R}from"./useFormGroup.38d9f2fe.js";import{_ as D}from"./_plugin-vue_export-helper.c27b6911.js";import"./index.87a09f8b.js";const l=k(i.ui.strategy,i.ui.textarea,A),J=O({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},resize:{type:Boolean,default:!1},padded:{type:Boolean,default:!0},size:{type:String,default:()=>l.default.size,validator(e){return Object.keys(l.size).includes(e)}},color:{type:String,default:()=>l.default.color,validator(e){return[...i.ui.colors,...Object.keys(l.color)].includes(e)}},variant:{type:String,default:()=>l.default.variant,validator(e){return[...Object.keys(l.variant),...Object.values(l.color).flatMap(a=>Object.keys(a))].includes(e)}},textareaClass:{type:String,default:null},ui:{type:Object,default:void 0}},emits:["update:modelValue","blur"],setup(e,{emit:a}){const{ui:t,attrs:d}=E("textarea",e.ui,l,{mergeWrapper:!0}),{emitFormBlur:f,emitFormInput:c,formGroup:r}=R(e),p=n(()=>r?.error?.value?"red":e.color),m=n(()=>r?.size?.value??e.size),b=r?.labelFor,u=T(null),v=()=>{e.autofocus&&u.value?.focus()},s=()=>{if(e.autoresize){if(!u.value)return;u.value.rows=e.rows;const o=window.getComputedStyle(u.value),S=parseInt(o.paddingTop),C=parseInt(o.paddingBottom),I=S+C,h=parseInt(o.lineHeight),{scrollHeight:j}=u.value,g=(j-I)/h;g>e.rows&&(u.value.rows=g)}},w=o=>{s(),a("update:modelValue",o.target.value),c()},B=o=>{a("blur",o),f()};y(()=>{setTimeout(()=>{v()},100)}),V(()=>e.modelValue,()=>{F(s)}),y(()=>{setTimeout(()=>{v(),s()},100)});const z=n(()=>{const o=t.value.color?.[p.value]?.[e.variant]||t.value.variant[e.variant];return M(q(t.value.base,t.value.rounded,t.value.placeholder,t.value.size[m.value],e.padded?t.value.padding[m.value]:"p-0",o?.replaceAll("{color}",p.value),!e.resize&&"resize-none"),e.textareaClass)});return{ui:t,attrs:d,id:b,textarea:u,textareaClass:z,onInput:w,onBlur:B}}}),K=["id","value","name","rows","required","disabled","placeholder"];function P(e,a,t,d,f,c){return N(),$("div",{class:H(e.ui.wrapper)},[x("textarea",G({id:e.id,ref:"textarea",value:e.modelValue,name:e.name,rows:e.rows,required:e.required,disabled:e.disabled,placeholder:e.placeholder,class:["form-textarea",e.textareaClass]},e.attrs,{onInput:a[0]||(a[0]=(...r)=>e.onInput&&e.onInput(...r)),onBlur:a[1]||(a[1]=(...r)=>e.onBlur&&e.onBlur(...r))}),null,16,K)],2)}const Z=D(J,[["render",P]]);export{Z as default};
