import{defineProperty as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as o,jsx as n}from"react/jsx-runtime";import{forwardRef as a,useRef as t,useEffect as i}from"react";import r from"../../hooks/useMergeRefs.js";import s from"../../hooks/useDebounceEvent/index.js";import{NOOP as l}from"../../utils/function-utils.js";import u from"../IconButton/IconButton.js";import c from"../Icon/Icons/components/CloseSmall.js";import d from"classnames";import m from"./Textarea.module.scss.js";var v=a((function(a,v){var p,f=a.placeholder,h=void 0===f?"":f,g=a.autoComplete,C=void 0===g?"off":g,b=a.initialValue,j=a.value,x=a.onChange,I=a.onBlur,y=void 0===I?l:I,F=a.onFocus,O=void 0===F?l:F,S=a.onKeyDown,N=void 0===S?l:S,k=a.onChangeCapture,B=a.debounceRate,D=void 0===B?0:B,L=a.autoFocus,R=void 0!==L&&L,V=a.disabled,w=void 0!==V&&V,_=a.readonly,q=void 0!==_&&_,A=a.setRef,E=void 0===A?l:A,T=a.trim,K=void 0!==T&&T,P=a.id,z=void 0===P?"textarea":P,H=a.required,M=void 0!==H&&H,W=a.name,Y=a.cols,G=void 0===Y?40:Y,J=a.rows,Q=void 0===J?7:J,U=a.maxLenght,X=void 0===U?1200:U,Z=a.minLenght,$=a.onInvalid,ee=a.onInvalidCapture,oe=a.onSelect,ne=a.onSelectCapture,ae=a.hint,te=a.validation,ie=void 0===te?null:te,re=t(null),se=s({delay:D,onChange:x,initialStateValue:j,trim:K}),le=se.inputValue,ue=se.onEventChanged,ce=se.clearValue,de=r({refs:[v,re,E]});return i((function(){if(re.current&&R){var e=requestAnimationFrame((function(){return re.current.focus()}));return function(){return cancelAnimationFrame(e)}}}),[re,R]),o("div",Object.assign({className:d(m.mainWrapper,(p={},e(p,m.status_error,ie&&"error"===ie.status),e(p,m.status_success,ie&&"success"===ie.status),e(p,m.disabled,!0===w),p))},{children:[w&&n("div",Object.assign({style:{position:"absolute"}},{children:"Disabled"})),o("label",Object.assign({htmlFor:"".concat(z),className:m.labelTop},{children:[le?le.length:0,"/",X]})),le&&n("div",Object.assign({className:m.clearIcon},{children:n(u,{size:"xxs",ariaLabel:"Remove",hideTooltip:!0,icon:c,onClick:ce,kind:u.kinds.SECONDARY})})),n("textarea",{ref:de,id:"".concat(z),className:m.textarea,value:le,placeholder:h,autoComplete:C,autoFocus:R,defaultValue:b,cols:G,rows:Q,disabled:w,maxLength:X,minLength:Z,name:W,onBlur:y,onFocus:O,onKeyDown:N,onChange:ue,onChangeCapture:k,onInvalid:$,onInvalidCapture:ee,onSelect:oe,onSelectCapture:ne,readOnly:q,required:M}),ae&&n("div",Object.assign({className:m.hint},{children:ae}))]}))}));export{v as default};
