/**
 * @jsxRuntime classic
 * @jsx jsx
 */
import React from 'react';

// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
import { jsx } from '@emotion/react';
import EditorDoneIcon from '@atlaskit/icon/core/check-mark';
import Tooltip from '@atlaskit/tooltip';
import { buttonStyle, buttonWrapperStyle } from './styles';
var Color = function Color(props) {
  var autoFocus = props.autoFocus,
    tabIndex = props.tabIndex,
    value = props.value,
    label = props.label,
    isSelected = props.isSelected,
    borderColor = props.borderColor,
    hexToPaletteColor = props.hexToPaletteColor,
    decorator = props.decorator;
  var colorStyle = hexToPaletteColor ? hexToPaletteColor(value) : value;
  var onMouseDown = function onMouseDown(e) {
    e.preventDefault();
  };
  var onClick = function onClick(e) {
    var onClick = props.onClick,
      value = props.value,
      label = props.label;
    e.preventDefault();
    onClick(value, label);
  };
  var onKeyDown = function onKeyDown(e) {
    var onKeyDown = props.onKeyDown,
      value = props.value,
      label = props.label;
    if (!onKeyDown) {
      return undefined;
    }
    e.preventDefault();
    onKeyDown(value, label, e);
  };
  return jsx(Tooltip, {
    content: label
  }, jsx("span", {
    css: buttonWrapperStyle
  }, jsx("button", {
    type: "button"
    // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
    ,
    css: buttonStyle,
    "aria-label": label,
    role: "radio",
    "aria-checked": isSelected,
    onClick: onClick,
    onKeyDown: onKeyDown,
    onMouseDown: onMouseDown,
    tabIndex: tabIndex
    // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
    ,
    className: "".concat(isSelected ? 'selected' : ''),
    style: {
      backgroundColor: colorStyle || "var(--ds-background-input, #FFFFFF)",
      border: "var(--ds-border-width, 1px)".concat(" solid ", borderColor)
    },
    autoFocus: autoFocus
  }, !decorator && isSelected && jsx(EditorDoneIcon, {
    label: ""
  }), decorator)));
};
export default Color;