(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", "styled-components", "../typography/P1", "../Pallette/themes", "../Pallette/style-utils", "../Pallette/Shape", "../utils/theme/getTheme", "./themes"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.ButtonComponent = exports.transformValueProps = void 0;
    var tslib_1 = require("tslib");
    var styled_components_1 = (0, tslib_1.__importStar)(require("styled-components"));
    var P1_1 = (0, tslib_1.__importDefault)(require("../typography/P1"));
    var themes_1 = require("../Pallette/themes");
    var style_utils_1 = require("../Pallette/style-utils");
    var Shape_1 = require("../Pallette/Shape");
    var getTheme_1 = require("../utils/theme/getTheme");
    var themes_2 = require("./themes");
    var COMPONENT_NAME = "button";
    var ButtonSizeStyles = {
        m: (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = (0, tslib_1.__makeTemplateObject)(["\n    height: 48px;\n    border-radius: ", ";\n    ", ";\n  "], ["\n    height: 48px;\n    border-radius: ", ";\n    ", ";\n  "])), Shape_1.Shape.borderRadiusMedium, style_utils_1.Padding.allSide(2, 3)),
        l: (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = (0, tslib_1.__makeTemplateObject)(["\n    height: 56px;\n    border-radius: ", ";\n    ", ";\n  "], ["\n    height: 56px;\n    border-radius: ", ";\n    ", ";\n  "])), Shape_1.Shape.borderRadiusMedium, style_utils_1.Padding.allSide(2, 4)),
        s: (0, styled_components_1.css)(templateObject_3 || (templateObject_3 = (0, tslib_1.__makeTemplateObject)(["\n    height: 32px;\n    border-radius: ", ";\n    ", ";\n  "], ["\n    height: 32px;\n    border-radius: ", ";\n    ", ";\n  "])), Shape_1.Shape.borderRadiusDefault, style_utils_1.Padding.allSide(1, 2)),
        xs: (0, styled_components_1.css)(templateObject_4 || (templateObject_4 = (0, tslib_1.__makeTemplateObject)(["\n    height: 24px;\n    border-radius: ", ";\n    ", ";\n  "], ["\n    height: 24px;\n    border-radius: ", ";\n    ", ";\n  "])), Shape_1.Shape.borderRadiusDefault, style_utils_1.Padding.allSide(1, 1))
    };
    var pressedStylesButton = function (_a) {
        var theme = _a.theme, viewType = _a.viewType, $color = _a.$color;
        switch (viewType) {
            case "ghost":
                return (0, styled_components_1.css)(templateObject_5 || (templateObject_5 = (0, tslib_1.__makeTemplateObject)(["\n        color: ", ";\n        .lead-icon {\n          color: ", ";\n        }\n      "], ["\n        color: ", ";\n        .lead-icon {\n          color: ", ";\n        }\n      "])), theme.components.button.colorGhostPressed, theme.components.button.iconColorGhostPressed);
            case "link":
                return (0, styled_components_1.css)(templateObject_6 || (templateObject_6 = (0, tslib_1.__makeTemplateObject)(["\n        color: ", ";\n        .lead-icon {\n          color: ", ";\n        }\n      "], ["\n        color: ", ";\n        .lead-icon {\n          color: ", ";\n        }\n      "])), theme.components.button.colorLinkPressed, theme.components.button.iconColorLinkPressed);
            case "secondary":
                return (0, styled_components_1.css)(templateObject_7 || (templateObject_7 = (0, tslib_1.__makeTemplateObject)(["\n        background-color: ", ";\n        color: ", ";\n        .lead-icon {\n          color: ", ";\n        }\n      "], ["\n        background-color: ", ";\n        color: ", ";\n        .lead-icon {\n          color: ", ";\n        }\n      "])), theme.components.button.backgroundSecondaryPressed, theme.components.button.colorSecondaryPressed, theme.components.button.iconColorSecondaryPressed);
            case "primary":
            default:
                return (0, styled_components_1.css)(templateObject_8 || (templateObject_8 = (0, tslib_1.__makeTemplateObject)(["\n        background: ", ";\n        color: ", ";\n        .lead-icon {\n          color: ", ";\n        }\n      "], ["\n        background: ", ";\n        color: ", ";\n        .lead-icon {\n          color: ", ";\n        }\n      "])), theme.components.button["backgroundPrimary" + ($color || "") + "Pressed"], theme.components.button.colorPrimaryPressed, theme.components.button.iconColorPrimaryPressed);
        }
    };
    var transformValueProps = function (_a) {
        var _b = _a.viewType, viewType = _b === void 0 ? "primary" : _b, $color = _a.$color, theme = _a.theme, $content = _a.$content, props = (0, tslib_1.__rest)(_a, ["viewType", "$color", "theme", "$content"]);
        return ((0, tslib_1.__assign)({ theme: theme, viewType: viewType, $content: $content, $color: $color ? $color.charAt(0).toUpperCase() + $color.slice(1) : undefined }, props));
    };
    exports.transformValueProps = transformValueProps;
    exports.ButtonComponent = (0, styled_components_1.default)(P1_1.default).attrs(function (props) { return ((0, tslib_1.__assign)((0, tslib_1.__assign)({}, (0, exports.transformValueProps)(props)), { theme: (0, getTheme_1.getTheme)({
            theme: props.theme,
            componentName: COMPONENT_NAME,
            defaultTheme: themes_2.defaultThemeButton
        }) })); })(templateObject_17 || (templateObject_17 = (0, tslib_1.__makeTemplateObject)(["\n  ", ";\n  position: relative;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  border: 0;\n  cursor: pointer;\n  transition: all 0.1s linear;\n  ", "\n  max-width: 100%;\n  white-space: nowrap;\n  user-select: none;\n  -webkit-user-select: none;\n  touch-action: manipulation;\n  text-decoration: none;\n  ", ";\n  .button-text {\n    text-overflow: ellipsis;\n    white-space: nowrap;\n    overflow: hidden;\n  }\n  ", ";\n\n  ", ";\n\n  ", ";\n\n  ", "\n"], ["\n  ", ";\n  position: relative;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  border: 0;\n  cursor: pointer;\n  transition: all 0.1s linear;\n  ", "\n  max-width: 100%;\n  white-space: nowrap;\n  user-select: none;\n  -webkit-user-select: none;\n  touch-action: manipulation;\n  text-decoration: none;\n  ", ";\n  .button-text {\n    text-overflow: ellipsis;\n    white-space: nowrap;\n    overflow: hidden;\n  }\n  ", ";\n\n  ", ";\n\n  ", ";\n\n  ", "\n"])), function (_a) {
        var theme = _a.theme;
        return (0, styled_components_1.css)(templateObject_9 || (templateObject_9 = (0, tslib_1.__makeTemplateObject)(["\n    font-weight: ", ";\n    font-size: ", ";\n    font-family: ", ";\n  "], ["\n    font-weight: ", ";\n    font-size: ", ";\n    font-family: ", ";\n  "])), theme.typography.fontWeightMedium, theme.typography.fontSizeM, theme.typography.fontFamily);
    }, function (_a) {
        var width = _a.width;
        return width && (0, styled_components_1.css)(templateObject_10 || (templateObject_10 = (0, tslib_1.__makeTemplateObject)(["\n      width: ", ";\n    "], ["\n      width: ", ";\n    "])), width);
    }, function (_a) {
        var $content = _a.$content;
        return $content && (0, styled_components_1.css)(templateObject_11 || (templateObject_11 = (0, tslib_1.__makeTemplateObject)(["\n      .lead-icon {\n        margin-right: 12px;\n        min-width: 16px;\n      }\n    "], ["\n      .lead-icon {\n        margin-right: 12px;\n        min-width: 16px;\n      }\n    "])));
    }, function (_a) {
        var _b = _a.size, size = _b === void 0 ? "l" : _b;
        return ButtonSizeStyles[size];
    }, function (_a) {
        var viewType = _a.viewType, theme = _a.theme, $color = _a.$color;
        if (viewType === "ghost") {
            return (0, styled_components_1.css)(templateObject_12 || (templateObject_12 = (0, tslib_1.__makeTemplateObject)(["\n        background: ", ";\n        color: ", ";\n        .lead-icon {\n          color: ", ";\n        }\n\n        &:hover:enabled {\n          color: ", ";\n          .lead-icon {\n            color: ", ";\n          }\n        }\n\n        &:active:enabled {\n          ", ";\n        }\n      "], ["\n        background: ", ";\n        color: ", ";\n        .lead-icon {\n          color: ", ";\n        }\n\n        &:hover:enabled {\n          color: ", ";\n          .lead-icon {\n            color: ", ";\n          }\n        }\n\n        &:active:enabled {\n          ", ";\n        }\n      "])), theme.components.button.backgroundGhost, theme.components.button.colorGhost, theme.components.button.iconColorGhost, theme.components.button.colorGhostHover, theme.components.button.iconColorGhostHover, pressedStylesButton);
        }
        if (viewType === "link") {
            return (0, styled_components_1.css)(templateObject_13 || (templateObject_13 = (0, tslib_1.__makeTemplateObject)(["\n        background: ", ";\n        color: ", ";\n        .lead-icon {\n          color: ", ";\n        }\n\n        &:hover:enabled {\n          color: ", ";\n          .lead-icon {\n            color: ", ";\n          }\n        }\n\n        &:active:enabled {\n          ", ";\n        }\n      "], ["\n        background: ", ";\n        color: ", ";\n        .lead-icon {\n          color: ", ";\n        }\n\n        &:hover:enabled {\n          color: ", ";\n          .lead-icon {\n            color: ", ";\n          }\n        }\n\n        &:active:enabled {\n          ", ";\n        }\n      "])), theme.components.button.backgroundLink, theme.components.button.colorLink, theme.components.button.iconColorLink, theme.components.button.colorLinkHover, theme.components.button.iconColorLinkHover, pressedStylesButton);
        }
        if (viewType === "secondary") {
            return (0, styled_components_1.css)(templateObject_14 || (templateObject_14 = (0, tslib_1.__makeTemplateObject)(["\n        background: ", ";\n        color: ", ";\n        .lead-icon {\n          color: ", ";\n        }\n\n        &:disabled {\n          background: ", ";\n        }\n\n        &:hover:enabled {\n          background: ", ";\n          color: ", ";\n          .lead-icon {\n            color: ", ";\n          }\n        }\n\n        &:active:enabled {\n          ", ";\n        }\n      "], ["\n        background: ", ";\n        color: ", ";\n        .lead-icon {\n          color: ", ";\n        }\n\n        &:disabled {\n          background: ", ";\n        }\n\n        &:hover:enabled {\n          background: ", ";\n          color: ", ";\n          .lead-icon {\n            color: ", ";\n          }\n        }\n\n        &:active:enabled {\n          ", ";\n        }\n      "])), theme.components.button.backgroundSecondary, theme.components.button.colorSecondary, theme.components.button.iconColorSecondary, theme.components.button.backgroundDisabled, theme.components.button.backgroundSecondaryHover, theme.components.button.colorSecondaryHover, theme.components.button.iconColorSecondaryHover, pressedStylesButton);
        }
        return (0, styled_components_1.css)(templateObject_15 || (templateObject_15 = (0, tslib_1.__makeTemplateObject)(["\n      background: ", ";\n      color: ", ";\n      .lead-icon {\n        color: ", ";\n      }\n\n      &:disabled {\n        background: ", ";\n      }\n\n      &:hover:enabled {\n        background: ", ";\n        color: ", ";\n        .lead-icon {\n          color: ", ";\n        }\n      }\n      &:active:enabled {\n        ", ";\n      }\n    "], ["\n      background: ", ";\n      color: ", ";\n      .lead-icon {\n        color: ", ";\n      }\n\n      &:disabled {\n        background: ", ";\n      }\n\n      &:hover:enabled {\n        background: ", ";\n        color: ", ";\n        .lead-icon {\n          color: ", ";\n        }\n      }\n      &:active:enabled {\n        ", ";\n      }\n    "])), theme.components.button["backgroundPrimary" + ($color || "")], theme.components.button.colorPrimary, theme.components.button.iconColorPrimary, theme.components.button.backgroundDisabled, theme.components.button["backgroundPrimary" + ($color || "") + "Hover"], theme.components.button.colorPrimaryHover, theme.components.button.iconColorPrimaryHover, pressedStylesButton);
    }, function (_a) {
        var isPressed = _a.isPressed;
        return isPressed && pressedStylesButton;
    }, function (_a) {
        var theme = _a.theme;
        return (0, styled_components_1.css)(templateObject_16 || (templateObject_16 = (0, tslib_1.__makeTemplateObject)(["\n    &:disabled {\n      color: ", ";\n      .lead-icon {\n        color: ", ";\n      }\n      cursor: not-allowed;\n    }\n  "], ["\n    &:disabled {\n      color: ", ";\n      .lead-icon {\n        color: ", ";\n      }\n      cursor: not-allowed;\n    }\n  "])), theme.components.button.colorDisabled, theme.components.button.iconColorDisabled);
    });
    exports.ButtonComponent.defaultProps = {
        theme: themes_1.LIGHT_THEME
    };
    var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15, templateObject_16, templateObject_17;
});
