"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports.Link = void 0;

var _style = _interopRequireDefault(require("styled-jsx/style"));

var _react = _interopRequireDefault(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _useTheme = _interopRequireDefault(require("../../hooks/useTheme"));

var _isThemePalette = _interopRequireDefault(require("../../utils/isThemePalette"));

var _opacity = _interopRequireDefault(require("../../utils/opacity"));

var _jsxRuntime = require("react/jsx-runtime");

// Generated with util/create-component.js
const Link = props => {
  const theme = (0, _useTheme.default)();
  const {
    color = "primary",
    component = "a",
    children,
    className = null,
    ...otherProps
  } = props;
  const Component = component ? component : "a";

  function handleColor() {
    if (!color) return `color: ${theme.palette.text};`;

    switch (color) {
      case "text":
        return `color: ${theme.palette.text};`;

      case "subtext":
        return `color: ${theme.palette.subtext};`;

      default:
        return `color: ${(0, _isThemePalette.default)(color) ? theme.palette[color][500] : color};`;
    }
  }

  function handleColorHover() {
    if (!color) return `color: ${theme.palette.text};`;

    switch (color) {
      case "text":
        return `color: ${(0, _opacity.default)(theme.palette.text, 50)};`;

      case "subtext":
        return `color: ${(0, _opacity.default)(theme.palette.subtext, 50)};`;

      default:
        return `color: ${(0, _isThemePalette.default)(color) ? (0, _opacity.default)(theme.palette[color][500], 50) : (0, _opacity.default)(color, 50)};`;
    }
  }

  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Component, {
    "data-testid": "Wps-Link",
    ...otherProps,
    className: _style.default.dynamic([["2126543404", [handleColor(), handleColorHover()]]]) + " " + (otherProps && otherProps.className != null && otherProps.className || (0, _classnames.default)("Wps-Link", className) || ""),
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_style.default, {
      id: "2126543404",
      dynamic: [handleColor(), handleColorHover()],
      children: `.Wps-Link.__jsx-style-dynamic-selector{${handleColor()} transition:all 250ms ease 0ms;}.Wps-Link.__jsx-style-dynamic-selector:hover{${handleColorHover()};}`
    }), children]
  });
};

exports.Link = Link;