(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "tslib", "react", "./components/IconsBox", "./style"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var tslib_1 = require("tslib");
    var react_1 = (0, tslib_1.__importStar)(require("react"));
    var IconsBox_1 = (0, tslib_1.__importDefault)(require("./components/IconsBox"));
    var style_1 = require("./style");
    var InputBase = (0, react_1.forwardRef)(function (props, ref) {
        var error = props.error, type = props.type, isDisabled = props.isDisabled, placeholder = props.placeholder, tooltipContent = props.tooltipContent, tooltipPosition = props.tooltipPosition, alignText = props.alignText, className = props.className, children = props.children, isFocused = props.isFocused, onClear = props.onClear, onPasswordToggle = props.onPasswordToggle, width = props.width, isPasswordVisible = props.isPasswordVisible, isHasValue = props.isHasValue, isShowClearIcon = props.isShowClearIcon, isShowMask = props.isShowMask, _a = props.testId, testId = _a === void 0 ? "testIDWithoutName" : _a, isReadOnly = props.isReadOnly, isRequired = props.isRequired, _b = props.size, size = _b === void 0 ? "l" : _b, status = props.status, statusText = props.statusText, iconLeft = props.iconLeft, iconRight = props.iconRight, classNameIconBox = props.classNameIconBox, isShowLabel = props.isShowLabel, classNameAddonsRight = props.classNameAddonsRight, classNameContent = props.classNameContent, classNamePlaceholder = props.classNamePlaceholder, onIconLeftClick = props.onIconLeftClick, onIconRightClick = props.onIconRightClick, _c = props.viewType, viewType = _c === void 0 ? "round" : _c, otherProps = (0, tslib_1.__rest)(props, ["error", "type", "isDisabled", "placeholder", "tooltipContent", "tooltipPosition", "alignText", "className", "children", "isFocused", "onClear", "onPasswordToggle", "width", "isPasswordVisible", "isHasValue", "isShowClearIcon", "isShowMask", "testId", "isReadOnly", "isRequired", "size", "status", "statusText", "iconLeft", "iconRight", "classNameIconBox", "isShowLabel", "classNameAddonsRight", "classNameContent", "classNamePlaceholder", "onIconLeftClick", "onIconRightClick", "viewType"]);
        var IconsBoxProps = {
            isHasValue: isHasValue,
            isDisabled: isDisabled,
            isShowClearIcon: isShowClearIcon,
            type: type,
            isPasswordVisible: isPasswordVisible,
            tooltipContent: tooltipContent,
            tooltipPosition: tooltipPosition,
            onClear: onClear,
            onPasswordToggle: onPasswordToggle,
            classNameIconBox: classNameIconBox,
            isReadOnly: isReadOnly
        };
        var getPlaceholder = function (value) {
            if (typeof value === "string") {
                return value;
            }
            else {
                return isHasValue || isFocused ? value[1] : value[0];
            }
        };
        return (react_1.default.createElement(style_1.LabelStyled, { width: width, "data-testid": testId + "_label" },
            react_1.default.createElement(style_1.InputWrapperStyled, (0, tslib_1.__assign)({ ref: ref, isFocused: isFocused, isDisabled: isDisabled, isReadOnly: isReadOnly, size: size, width: width, alignText: alignText, className: className, status: status, viewType: viewType, statusText: statusText, error: error, isHasValue: isHasValue, "data-testid": testId }, otherProps),
                react_1.default.createElement(style_1.InputLeadContentStyled, { isDisabled: isDisabled, isReadOnly: isReadOnly, isFocused: isFocused, isHasValue: isHasValue || isReadOnly, isPlaceholder: Boolean(placeholder), className: classNameContent },
                    iconLeft && (react_1.default.createElement(style_1.IconStyled, { isFocused: isFocused, isDisabled: isDisabled, isReadOnly: isReadOnly, onClick: onIconLeftClick }, iconLeft)),
                    placeholder && (isShowLabel || (!isFocused && !isHasValue)) && (react_1.default.createElement(style_1.PlaceholderStyled, { iconLeft: Boolean(iconLeft), isReadOnly: isReadOnly, isDisabled: isDisabled, "data-element": "input-placeholder", "data-testid": testId + "-placeholder", error: error, size: size, isFocused: isFocused, isHasValue: isHasValue || Boolean(isShowMask) || Boolean(isReadOnly), title: isDisabled ? undefined : getPlaceholder(placeholder), status: status, className: classNamePlaceholder },
                        react_1.default.createElement("span", { className: "placeholder-text" }, getPlaceholder(placeholder)),
                        isRequired && (react_1.default.createElement(react_1.default.Fragment, null,
                            "\u00A0",
                            react_1.default.createElement(style_1.RequiredStyle, { isDisabled: isDisabled || isReadOnly }, "*"))))),
                    children),
                react_1.default.createElement(IconsBox_1.default, (0, tslib_1.__assign)({}, IconsBoxProps)),
                iconRight && (react_1.default.createElement(style_1.IconRightStyled, { isFocused: isFocused, isDisabled: isDisabled, isReadOnly: isReadOnly, className: classNameAddonsRight, onClick: function (e) {
                        onIconRightClick && onIconRightClick();
                        e.preventDefault();
                    } }, iconRight))),
            typeof error === "string" && Boolean(error.trim()) && (react_1.default.createElement(style_1.TextStatusStyled, { status: "error", "data-element": "input-error", type: "pavo" }, error)),
            status && statusText && (react_1.default.createElement(style_1.TextStatusStyled, { status: status, "data-element": "input-text", "data-testid": testId + "_status-text", type: "pavo" }, statusText))));
    });
    InputBase.displayName = "InputBase";
    exports.default = InputBase;
});
