"use strict";
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Link = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const styled_components_1 = __importDefault(require("styled-components"));
const Icon_1 = require("../Icon");
const theme_1 = require("../../theme");
const Flex_1 = require("../Flex");
const Text_1 = require("../Text");
const StyledAnchor = styled_components_1.default.a `
  text-decoration: none;
  :hover, :focus: {
    text-decoration: none;
  }
`;
const TextComponent = (0, styled_components_1.default)(Text_1.Text)(({ disabled }) => ({
    cursor: disabled ? 'not-allowed' : 'pointer',
}));
const IconComponent = (0, styled_components_1.default)(Icon_1.Icon)(({ disabled }) => ({
    cursor: disabled ? 'not-allowed' : 'pointer',
}));
const sizeMap = {
    s: {
        format: 'b3m',
        size: '12px',
    },
    m: {
        format: 'b2m',
        size: '14px',
    },
    l: {
        format: 'b1m',
        size: '16px',
    },
};
const Link = (_a) => {
    var { href, onClick, label, size, disabled, variant } = _a, rest = __rest(_a, ["href", "onClick", "label", "size", "disabled", "variant"]);
    let component;
    const labelComponent = ((0, jsx_runtime_1.jsx)(TextComponent, Object.assign({ format: sizeMap[size].format, variant: "p", color: disabled ? 'gray3' : variant === 'primary' ? 'brandMain' : 'gray1', disabled: disabled }, { children: label }), void 0));
    if (disabled) {
        component = (0, jsx_runtime_1.jsx)("div", Object.assign({}, rest, { children: labelComponent }), void 0);
    }
    else if (onClick) {
        component = ((0, jsx_runtime_1.jsx)("div", Object.assign({ role: "none", onClick: onClick }, rest, { children: labelComponent }), void 0));
    }
    else if (href) {
        component = ((0, jsx_runtime_1.jsx)(StyledAnchor, Object.assign({ href: href }, rest, { children: labelComponent }), void 0));
    }
    return ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, Object.assign({ variant: "raw", align: "center" }, { children: [component, (0, jsx_runtime_1.jsx)(IconComponent, { variant: "basic", icon: theme_1.polyIcons.ArrowRight, margin: "0 5px", size: sizeMap[size].size, color: disabled ? 'gray3' : variant === 'primary' ? 'brandMain' : 'gray1', disabled: disabled }, void 0)] }), void 0));
};
exports.Link = Link;
//# sourceMappingURL=Link.js.map