"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: Object.getOwnPropertyDescriptor(all, name).get
    });
}
_export(exports, {
    get getDynamicLabelClasses () {
        return getDynamicLabelClasses;
    },
    get textAreaConfig () {
        return textAreaConfig;
    },
    get textAreaRoot () {
        return textAreaRoot;
    }
});
var _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
var _styledcomponents = require("styled-components");
var _utils = require("../../utils");
var _hooks = require("../../hooks");
var _mixins = require("./mixins");
var _hooks1 = require("./hooks");
var _TextAreastyles = require("./TextArea.styles");
var _TextAreatokens = require("./TextArea.tokens");
var _base = require("./variations/_view/base");
var _base1 = require("./variations/_size/base");
var _base2 = require("./variations/_read-only/base");
var _base3 = require("./variations/_disabled/base");
var _base4 = require("./variations/_hint-view/base");
var _base5 = require("./variations/_hint-size/base");
var _Hint = require("./ui/Hint/Hint");
function _array_like_to_array(arr, len) {
    if (len == null || len > arr.length) len = arr.length;
    for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
    return arr2;
}
function _array_with_holes(arr) {
    if (Array.isArray(arr)) return arr;
}
function _array_without_holes(arr) {
    if (Array.isArray(arr)) return _array_like_to_array(arr);
}
function _define_property(obj, key, value) {
    if (key in obj) {
        Object.defineProperty(obj, key, {
            value: value,
            enumerable: true,
            configurable: true,
            writable: true
        });
    } else {
        obj[key] = value;
    }
    return obj;
}
function _getRequireWildcardCache(nodeInterop) {
    if (typeof WeakMap !== "function") return null;
    var cacheBabelInterop = new WeakMap();
    var cacheNodeInterop = new WeakMap();
    return (_getRequireWildcardCache = function(nodeInterop) {
        return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
    })(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
    if (!nodeInterop && obj && obj.__esModule) {
        return obj;
    }
    if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
        return {
            default: obj
        };
    }
    var cache = _getRequireWildcardCache(nodeInterop);
    if (cache && cache.has(obj)) {
        return cache.get(obj);
    }
    var newObj = {
        __proto__: null
    };
    var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
    for(var key in obj){
        if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
            var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
            if (desc && (desc.get || desc.set)) {
                Object.defineProperty(newObj, key, desc);
            } else {
                newObj[key] = obj[key];
            }
        }
    }
    newObj.default = obj;
    if (cache) {
        cache.set(obj, newObj);
    }
    return newObj;
}
function _iterable_to_array(iter) {
    if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
}
function _iterable_to_array_limit(arr, i) {
    var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
    if (_i == null) return;
    var _arr = [];
    var _n = true;
    var _d = false;
    var _s, _e;
    try {
        for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
            _arr.push(_s.value);
            if (i && _arr.length === i) break;
        }
    } catch (err) {
        _d = true;
        _e = err;
    } finally{
        try {
            if (!_n && _i["return"] != null) _i["return"]();
        } finally{
            if (_d) throw _e;
        }
    }
    return _arr;
}
function _non_iterable_rest() {
    throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _non_iterable_spread() {
    throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _object_spread(target) {
    for(var i = 1; i < arguments.length; i++){
        var source = arguments[i] != null ? arguments[i] : {};
        var ownKeys = Object.keys(source);
        if (typeof Object.getOwnPropertySymbols === "function") {
            ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
                return Object.getOwnPropertyDescriptor(source, sym).enumerable;
            }));
        }
        ownKeys.forEach(function(key) {
            _define_property(target, key, source[key]);
        });
    }
    return target;
}
function _object_without_properties(source, excluded) {
    if (source == null) return {};
    var target = {}, sourceKeys, key, i;
    if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
        sourceKeys = Reflect.ownKeys(source);
        for(i = 0; i < sourceKeys.length; i++){
            key = sourceKeys[i];
            if (excluded.indexOf(key) >= 0) continue;
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
            target[key] = source[key];
        }
        return target;
    }
    target = _object_without_properties_loose(source, excluded);
    if (Object.getOwnPropertySymbols) {
        sourceKeys = Object.getOwnPropertySymbols(source);
        for(i = 0; i < sourceKeys.length; i++){
            key = sourceKeys[i];
            if (excluded.indexOf(key) >= 0) continue;
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
            target[key] = source[key];
        }
    }
    return target;
}
function _object_without_properties_loose(source, excluded) {
    if (source == null) return {};
    var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
    for(i = 0; i < sourceKeys.length; i++){
        key = sourceKeys[i];
        if (excluded.indexOf(key) >= 0) continue;
        if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
        target[key] = source[key];
    }
    return target;
}
function _sliced_to_array(arr, i) {
    return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
}
function _to_consumable_array(arr) {
    return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
}
function _unsupported_iterable_to_array(o, minLen) {
    if (!o) return;
    if (typeof o === "string") return _array_like_to_array(o, minLen);
    var n = Object.prototype.toString.call(o).slice(8, -1);
    if (n === "Object" && o.constructor) n = o.constructor.name;
    if (n === "Map" || n === "Set") return Array.from(n);
    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
}
var innerPlaceholderUp = _TextAreatokens.classes.innerPlaceholderUp, focusedOuterPlaceholderColor = _TextAreatokens.classes.focusedOuterPlaceholderColor, hidePlaceHolder = _TextAreatokens.classes.hidePlaceHolder, styledContainer = _TextAreatokens.classes.styledContainer, styledTextArea = _TextAreatokens.classes.styledTextArea, styledTextAreaWrapper = _TextAreatokens.classes.styledTextAreaWrapper, styledPlaceholder = _TextAreatokens.classes.styledPlaceholder, styledHelpers = _TextAreatokens.classes.styledHelpers, hasHeaderSlot = _TextAreatokens.classes.hasHeaderSlot, styledContentWrapper = _TextAreatokens.classes.styledContentWrapper;
var base = (0, _styledcomponents.css)([
    "",
    ";position:relative;box-sizing:border-box;"
], _mixins.applyDynamicLabel);
// TODO: Удалить после отказа от старых библиотек plasma-web / plasma-b2c
var fallbackStatusMap = {
    '': 'primary',
    success: 'positive',
    warning: 'warning',
    error: 'negative'
};
var HINT_DEFAULT_OFFSET = [
    0,
    0
];
var getDynamicLabelClasses = function getDynamicLabelClasses(props, focused) {
    var readOnly = props.readOnly, label = props.label, labelPlacement = props.labelPlacement, rows = props.rows, value = props.value, size = props.size;
    // Добавить класс отвечающий за изменение цвета плейсхолдера при фокусе
    var withFocusedOuterUpPlaceholder = !readOnly && focused && (!label || labelPlacement === 'outer') ? focusedOuterPlaceholderColor : undefined;
    // Добавить класс отвечающий за поднятие и уменьшение плейсхолдера
    var withInnerPlaceholderUp = labelPlacement === 'inner' && label && !rows && size !== 'xs' && (!readOnly && (value || focused) || readOnly && value) ? innerPlaceholderUp : undefined;
    // Добавить класс отвечающий за скрытие плейсхолдера
    var withHidePlaceholder = value && !label || labelPlacement === 'inner' && (focused && !readOnly || value) && label && rows || labelPlacement === 'outer' && value || labelPlacement === 'inner' && size === 'xs' && value ? hidePlaceHolder : undefined;
    return [
        withFocusedOuterUpPlaceholder,
        withInnerPlaceholderUp,
        withHidePlaceholder
    ];
};
var textAreaRoot = function textAreaRoot(Root) {
    return /*#__PURE__*/ (0, _react.forwardRef)(function(props, innerRef) {
        var id = props.id, className = props.className, style = props.style, // layout
        label = props.label, _props_labelPlacement = props.labelPlacement, labelPlacement = _props_labelPlacement === void 0 ? 'inner' : _props_labelPlacement, titleCaption = props.titleCaption, placeholder = props.placeholder, leftHelper = props.leftHelper, _props_leftHelperPlacement = props.leftHelperPlacement, leftHelperPlacement = _props_leftHelperPlacement === void 0 ? 'inner' : _props_leftHelperPlacement, helperText = props.helperText, rightHelper = props.rightHelper, contentRight = props.contentRight, headerSlot = props.headerSlot, _props_requiredPlacement = props.requiredPlacement, requiredPlacement = _props_requiredPlacement === void 0 ? 'right' : _props_requiredPlacement, _props_hasRequiredIndicator = props.hasRequiredIndicator, hasRequiredIndicator = _props_hasRequiredIndicator === void 0 ? false : _props_hasRequiredIndicator, _props_hintTrigger = props.// hint
        hintTrigger, hintTrigger = _props_hintTrigger === void 0 ? 'hover' : _props_hintTrigger, hintText = props.hintText, _props_hintView = props.hintView, hintView = _props_hintView === void 0 ? 'default' : _props_hintView, _props_hintSize = props.hintSize, hintSize = _props_hintSize === void 0 ? 'm' : _props_hintSize, hintTargetIcon = props.hintTargetIcon, _props_hintPlacement = props.hintPlacement, hintPlacement = _props_hintPlacement === void 0 ? 'auto' : _props_hintPlacement, hintHasArrow = props.hintHasArrow, _props_hintOffset = props.hintOffset, hintOffset = _props_hintOffset === void 0 ? HINT_DEFAULT_OFFSET : _props_hintOffset, hintWidth = props.hintWidth, hintContentLeft = props.hintContentLeft, // variations
        appearance = props.appearance, status = props.status, view = props.view, size = props.size, readOnly = props.readOnly, disabled = props.disabled, _props_required = props.required, required = _props_required === void 0 ? false : _props_required, clear = props.clear, _props_optional = props.optional, optional = _props_optional === void 0 ? false : _props_optional, _props_optionalText = props.optionalText, optionalText = _props_optionalText === void 0 ? 'optional' : _props_optionalText, hasDivider = props.hasDivider, // controlled
        value = props.value, defaultValue = props.defaultValue, // textarea-specific
        resize = props.resize, _props_autoResize = props.autoResize, autoResize = _props_autoResize === void 0 ? false : _props_autoResize, _props_minAuto = props.minAuto, minAuto = _props_minAuto === void 0 ? 0 : _props_minAuto, maxAuto = props.maxAuto, height = props.height, width = props.width, rows = props.rows, cols = props.cols, // events
        onChange = props.onChange, _props_labelAriaHidden = props.// additional
        labelAriaHidden, labelAriaHidden = _props_labelAriaHidden === void 0 ? false : _props_labelAriaHidden, rest = _object_without_properties(props, [
            "id",
            "className",
            "style",
            "label",
            "labelPlacement",
            "titleCaption",
            "placeholder",
            "leftHelper",
            "leftHelperPlacement",
            "helperText",
            "rightHelper",
            "contentRight",
            "headerSlot",
            "requiredPlacement",
            "hasRequiredIndicator",
            "hintTrigger",
            "hintText",
            "hintView",
            "hintSize",
            "hintTargetIcon",
            "hintPlacement",
            "hintHasArrow",
            "hintOffset",
            "hintWidth",
            "hintContentLeft",
            "appearance",
            "status",
            "view",
            "size",
            "readOnly",
            "disabled",
            "required",
            "clear",
            "optional",
            "optionalText",
            "hasDivider",
            "value",
            "defaultValue",
            "resize",
            "autoResize",
            "minAuto",
            "maxAuto",
            "height",
            "width",
            "rows",
            "cols",
            "onChange",
            "labelAriaHidden"
        ]);
        var _useState = _sliced_to_array((0, _react.useState)(false), 2), isHintVisible = _useState[0], setIsHintVisible = _useState[1];
        var _useState1 = _sliced_to_array((0, _react.useState)(width ? "".concat(width, "rem") : '100%'), 2), helperWidth = _useState1[0], setHelperWidth = _useState1[1];
        var _useState2 = _sliced_to_array((0, _react.useState)(false), 2), focused = _useState2[0], setFocused = _useState2[1];
        // TODO: перенести в общую переменную для value снаружи и внутри
        var _useState3 = _sliced_to_array((0, _react.useState)(), 2), uncontrolledValue = _useState3[0], setUncontrolledValue = _useState3[1];
        var outerRef = /*#__PURE__*/ (0, _react.createRef)();
        var hiddenRef = (0, _react.useRef)(null);
        var hintRef = (0, _react.useRef)(null);
        (0, _hooks.useOutsideClick)(function() {
            setIsHintVisible(false);
        }, [
            hintRef
        ]);
        var isInnerLeftHelperPlacement = leftHelperPlacement === 'inner';
        var leftHelperText = leftHelper || helperText;
        var innerOptional = required ? false : optional;
        var hasLeftHelper = Boolean(leftHelper || helperText);
        var hasRightHelper = Boolean(rightHelper);
        var hasHelper = !isInnerLeftHelperPlacement ? hasRightHelper : hasLeftHelper || hasRightHelper;
        var hasOuterLabel = Boolean(label && labelPlacement === 'outer');
        var hasInnerLabel = Boolean(label && labelPlacement === 'inner' && size !== 'xs');
        var hasPlaceholderOptional = innerOptional && !hasOuterLabel;
        var hasHeader = Boolean(headerSlot) && !(clear || appearance === 'clear');
        var overriddenView = status !== undefined ? fallbackStatusMap[status] : view;
        var textareaHelperId = id ? "".concat(id, "-helper") : undefined;
        var applyCustomWidth = resize !== 'horizontal' && resize !== 'both' && !cols;
        var placeholderLabel = hasInnerLabel ? label : placeholder;
        var applyAutoResize = autoResize || Boolean(clear || appearance === 'clear');
        var clearClass = clear || appearance === 'clear' ? _TextAreatokens.classes.clear : undefined;
        var hasHintClass = hintText ? _TextAreatokens.classes.hasHint : undefined;
        var hasRightContentClass = contentRight ? _TextAreatokens.classes.hasRightContent : undefined;
        var hasDividerClass = hasDivider ? _TextAreatokens.classes.hasDivider : undefined;
        var requiredPlacementClass = requiredPlacement === 'right' ? _TextAreatokens.classes.requiredAlignRight : undefined;
        var handleHintShow = function handleHintShow() {
            return setIsHintVisible(true);
        };
        var handleHintHide = function handleHintHide() {
            return setIsHintVisible(false);
        };
        var handleHintClick = function handleHintClick(event) {
            var _hintRef_current;
            if (!hintText || hintTrigger !== 'click') {
                return;
            }
            event.stopPropagation();
            var targetIsPopover = event.target === hintRef.current;
            var rootHasTarget = (_hintRef_current = hintRef.current) === null || _hintRef_current === void 0 ? void 0 : _hintRef_current.contains(event.target);
            if (!targetIsPopover && !rootHasTarget) {
                setIsHintVisible(true);
            }
        };
        (0, _react.useLayoutEffect)(function() {
            if (outerRef.current) {
                setUncontrolledValue(outerRef.current.value);
            }
        }, [
            outerRef
        ]);
        (0, _react.useLayoutEffect)(function() {
            if (!hiddenRef.current || !cols) {
                return;
            }
            var _hiddenRef_current_getBoundingClientRect = hiddenRef.current.getBoundingClientRect(), elementWidth = _hiddenRef_current_getBoundingClientRect.width;
            setHelperWidth("".concat(elementWidth / _hooks1.ROOT_FONT_SIZE, "rem"));
        }, [
            cols
        ]);
        (0, _hooks.useResizeObserver)(outerRef, function(currentElement) {
            var _currentElement_style = currentElement.style, inlineWidth = _currentElement_style.width;
            if (inlineWidth) {
                var _currentElement_getBoundingClientRect = currentElement.getBoundingClientRect(), elementWidth = _currentElement_getBoundingClientRect.width;
                setHelperWidth("".concat(elementWidth / _hooks1.ROOT_FONT_SIZE, "rem"));
            }
        });
        (0, _hooks1.useAutoResize)(applyAutoResize, outerRef, value || uncontrolledValue, minAuto, maxAuto, resize, hiddenRef, size);
        var onFocusHandler = (0, _react.useCallback)(function() {
            setFocused(true);
        }, []);
        var onBlurHandler = (0, _react.useCallback)(function() {
            setFocused(false);
        }, []);
        var onChangeHandler = (0, _react.useCallback)(function(event) {
            // INFO: Для крайне редких кейсов, когда value снаружи не контролируется
            if (value === undefined) {
                setUncontrolledValue(event === null || event === void 0 ? void 0 : event.target.value);
            }
            onChange === null || onChange === void 0 ? void 0 : onChange(event);
        }, [
            value,
            onChange
        ]);
        var handleTextAreaFocus = function handleTextAreaFocus() {
            if (readOnly || disabled || !(outerRef === null || outerRef === void 0 ? void 0 : outerRef.current)) {
                return;
            }
            outerRef.current.focus();
        };
        var dynamicLabelClasses = getDynamicLabelClasses({
            size: size,
            readOnly: readOnly,
            label: label,
            labelPlacement: labelPlacement,
            value: value || uncontrolledValue || defaultValue,
            rows: rows,
            labelAriaHidden: labelAriaHidden
        }, focused);
        var optionalTextNode = innerOptional ? /*#__PURE__*/ _react.default.createElement(_TextAreastyles.StyledOptionalText, {
            inheritFont: !hasOuterLabel
        }, Boolean(hasPlaceholderOptional && (placeholderLabel || label)) && '\xa0', optionalText) : null;
        return /*#__PURE__*/ _react.default.createElement(Root, _object_spread({
            view: overriddenView,
            size: size,
            disabled: disabled,
            readOnly: readOnly,
            style: _object_spread({
                width: helperWidth
            }, style),
            className: (0, _utils.cx)(clearClass, hasDividerClass, hasHintClass, className),
            onClick: handleTextAreaFocus,
            "data-root": true
        }, hintText && {
            hintView: hintView,
            hintSize: hintSize
        }), (hasOuterLabel || titleCaption) && /*#__PURE__*/ _react.default.createElement(_TextAreastyles.OuterLabelWrapper, {
            width: helperWidth,
            isInnerLabel: labelPlacement === 'inner'
        }, hasOuterLabel && /*#__PURE__*/ _react.default.createElement(_TextAreastyles.StyledIndicatorWrapper, null, /*#__PURE__*/ _react.default.createElement(_TextAreastyles.StyledLabel, {
            "aria-hidden": labelAriaHidden
        }, label), hintText && /*#__PURE__*/ _react.default.createElement(_TextAreastyles.StyledHintWrapper, null, /*#__PURE__*/ _react.default.createElement(_Hint.HintComponent, {
            ref: hintRef,
            hintText: hintText,
            hintTrigger: hintTrigger,
            isHintVisible: isHintVisible,
            hintTargetIcon: hintTargetIcon,
            hintPlacement: hintPlacement,
            hintHasArrow: hintHasArrow,
            hintOffset: hintOffset,
            hintWidth: hintWidth,
            hintContentLeft: hintContentLeft,
            handleHintShow: handleHintShow,
            handleHintHide: handleHintHide,
            handleHintClick: handleHintClick
        })), required && hasRequiredIndicator && /*#__PURE__*/ _react.default.createElement(_TextAreastyles.StyledIndicator, {
            className: (0, _utils.cx)(_TextAreatokens.classes.outerLabelPlacement, requiredPlacementClass, hasHintClass)
        }), optionalTextNode), titleCaption && /*#__PURE__*/ _react.default.createElement(_TextAreastyles.TitleCaption, null, titleCaption)), /*#__PURE__*/ _react.default.createElement(_TextAreastyles.StyledContainer, {
            className: _utils.cx.apply(void 0, [
                styledContainer
            ].concat(_to_consumable_array(dynamicLabelClasses))),
            width: helperWidth,
            onFocus: onFocusHandler,
            onBlur: onBlurHandler
        }, !hasOuterLabel && /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, required && hasRequiredIndicator && /*#__PURE__*/ _react.default.createElement(_TextAreastyles.StyledIndicator, {
            className: (0, _utils.cx)(_TextAreatokens.classes.innerLabelPlacement, requiredPlacementClass)
        }), hintText && /*#__PURE__*/ _react.default.createElement(_TextAreastyles.StyledHintWrapper, {
            className: _TextAreatokens.classes.innerLabelPlacement
        }, /*#__PURE__*/ _react.default.createElement(_Hint.HintComponent, {
            ref: hintRef,
            hintText: hintText,
            hintTrigger: hintTrigger,
            isHintVisible: isHintVisible,
            hintTargetIcon: hintTargetIcon,
            hintPlacement: hintPlacement,
            hintHasArrow: hintHasArrow,
            hintOffset: hintOffset,
            hintWidth: hintWidth,
            hintContentLeft: hintContentLeft,
            size: size,
            handleHintShow: handleHintShow,
            handleHintHide: handleHintHide,
            handleHintClick: handleHintClick,
            isInnerLabel: true
        }))), /*#__PURE__*/ _react.default.createElement(_TextAreastyles.StyledTextAreaWrapper, {
            className: (0, _utils.cx)(styledTextAreaWrapper, hasHeader && hasHeaderSlot),
            hasHelper: hasHelper,
            hasHeader: hasHeader
        }, headerSlot && !clear && /*#__PURE__*/ _react.default.createElement(_TextAreastyles.StyledHeaderSlot, null, headerSlot), contentRight && !hasHeader && /*#__PURE__*/ _react.default.createElement(_TextAreastyles.StyledContent, null, contentRight), hasHeader && /*#__PURE__*/ _react.default.createElement(_TextAreastyles.StyledContentWrapper, {
            className: styledContentWrapper,
            hasHeader: hasHeader
        }, contentRight && /*#__PURE__*/ _react.default.createElement(_TextAreastyles.StyledContent, {
            hasHeader: hasHeader
        }, contentRight), headerSlot && placeholderLabel && /*#__PURE__*/ _react.default.createElement(_TextAreastyles.StyledPlaceholder, {
            hasContentRight: Boolean(contentRight),
            className: styledPlaceholder,
            htmlFor: id
        }, placeholderLabel, !hasOuterLabel && optionalTextNode)), /*#__PURE__*/ _react.default.createElement(_TextAreastyles.StyledTextArea, _object_spread({
            className: (0, _utils.cx)(styledTextArea, hasRightContentClass),
            id: id,
            hasContentRight: Boolean(contentRight),
            hasHelper: hasHelper,
            applyCustomWidth: applyCustomWidth,
            ref: (0, _utils.mergeRefs)(outerRef, innerRef),
            disabled: disabled,
            required: required,
            height: applyAutoResize ? minAuto : height,
            width: width,
            placeholder: placeholderLabel,
            "aria-describedby": textareaHelperId,
            value: value,
            readOnly: readOnly,
            rows: rows,
            cols: cols,
            resize: resize,
            defaultValue: defaultValue,
            onChange: onChangeHandler,
            "data-tour": true
        }, rest)), Boolean(applyAutoResize || cols) && /*#__PURE__*/ _react.default.createElement(_TextAreastyles.StyledHiddenTextArea, {
            "aria-hidden": true,
            ref: hiddenRef,
            hasContentRight: Boolean(contentRight),
            value: value || uncontrolledValue || ' ',
            onChange: function onChange() {},
            defaultValue: defaultValue,
            cols: cols
        })), hasHelper && /*#__PURE__*/ _react.default.createElement(_TextAreastyles.StyledHelpers, {
            className: styledHelpers,
            id: textareaHelperId
        }, isInnerLeftHelperPlacement && (leftHelper || helperText) && /*#__PURE__*/ _react.default.createElement(_TextAreastyles.StyledLeftHelper, {
            className: focused ? _TextAreatokens.classes.leftHelperFocus : ''
        }, leftHelper || helperText), rightHelper && /*#__PURE__*/ _react.default.createElement(_TextAreastyles.StyledRightHelper, {
            "data-root": true
        }, rightHelper)), !hasHeader && placeholderLabel && /*#__PURE__*/ _react.default.createElement(_TextAreastyles.StyledPlaceholder, {
            hasContentRight: Boolean(contentRight),
            className: styledPlaceholder,
            htmlFor: id
        }, placeholderLabel, !hasOuterLabel && optionalTextNode)), hasLeftHelper && !isInnerLeftHelperPlacement && /*#__PURE__*/ _react.default.createElement(_TextAreastyles.StyledOutsideHelpersWrapper, {
            id: textareaHelperId
        }, /*#__PURE__*/ _react.default.createElement(_TextAreastyles.StyledLeftHelper, null, leftHelperText)));
    });
};
var textAreaConfig = {
    name: 'TextArea',
    tag: 'div',
    layout: textAreaRoot,
    base: base,
    variations: {
        size: {
            css: _base1.base
        },
        view: {
            css: _base.base
        },
        readOnly: {
            css: _base2.base,
            attrs: true
        },
        disabled: {
            css: _base3.base,
            attrs: true
        },
        hintView: {
            css: _base4.base
        },
        hintSize: {
            css: _base5.base
        }
    },
    defaults: {
        size: 'm',
        view: 'primary'
    }
};
