const e=require("../_util/warning.js"),t=require("../_util/classNames.js"),n=require("../_util/omit.js"),r=require("../_util/raf.js"),i=require("../vc-resize-observer/index.js"),a=require("../_util/BaseInput.js"),o=require("./inputProps.js"),s=require("./calculateNodeHeight.js");let c=require("vue");var l=0,u=1,d=2,f=(0,c.defineComponent)({compatConfig:{MODE:3},name:`ResizableTextArea`,inheritAttrs:!1,props:o.textAreaProps(),setup(o,{attrs:f,emit:p,expose:m}){let h=(0,c.ref)(),g=(0,c.ref)({}),_=(0,c.ref)(d);(0,c.onBeforeUnmount)(()=>{r.default.cancel(void 0),r.default.cancel(void 0)});let v=()=>{try{if(h.value&&document.activeElement===h.value.input){let e=h.value.getSelectionStart(),t=h.value.getSelectionEnd(),n=h.value.getScrollTop();h.value.setSelectionRange(e,t),h.value.setScrollTop(n)}}catch{}},y=(0,c.ref)(),b=(0,c.ref)();(0,c.watchEffect)(()=>{let e=o.autoSize||o.autosize;e?(y.value=e.minRows,b.value=e.maxRows):(y.value=void 0,b.value=void 0)});let x=(0,c.computed)(()=>!!(o.autoSize||o.autosize)),S=()=>{_.value=l};(0,c.watch)([()=>o.value,y,b,x],()=>{x.value&&S()},{immediate:!0});let C=(0,c.ref)();(0,c.watch)([_,h],()=>{if(h.value)if(_.value===l)_.value=u;else if(_.value===u){let e=s.default(h.value.input,!1,y.value,b.value);_.value=d,C.value=e}else v()},{immediate:!0,flush:`post`});let w=(0,c.getCurrentInstance)(),T=(0,c.ref)(),E=()=>{r.default.cancel(T.value)},D=e=>{_.value===d&&(p(`resize`,e),x.value&&(E(),T.value=r.default(()=>{S()})))};(0,c.onBeforeUnmount)(()=>{E()}),m({resizeTextarea:()=>{S()},textArea:(0,c.computed)(()=>h.value?.input),instance:w}),e.default(o.autosize===void 0,`Input.TextArea`,`autosize is deprecated, please use autoSize instead.`);let O=()=>{let{prefixCls:e,disabled:r}=o,s=n.default(o,[`prefixCls`,`onPressEnter`,`autoSize`,`autosize`,`defaultValue`,`allowClear`,`type`,`maxlength`,`valueModifiers`]),d=t.default(e,f.class,{[`${e}-disabled`]:r}),p=x.value?C.value:null,m=[f.style,g.value,p],v={...s,...f,style:m,class:d};return(_.value===l||_.value===u)&&m.push({overflowX:`hidden`,overflowY:`hidden`}),v.autofocus||delete v.autofocus,v.rows===0&&delete v.rows,(0,c.createVNode)(i.default,{onResize:D,disabled:!x.value},{default:()=>[(0,c.createVNode)(a.default,{...v,ref:h,tag:`textarea`},null)]})};return()=>O()}});exports.default=f;