"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.StatusIndicator = void 0;
var _react = _interopRequireDefault(require("react"));
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
/*
 * Copyright OpenSearch Contributors
 * SPDX-License-Identifier: Apache-2.0
 */

const STATUS_COLORS = {
  ok: 'var(--osd-color-status-ok, #22C55E)',
  warning: 'var(--osd-color-status-warning, #EAB308)',
  error: 'var(--osd-color-status-error, #EF4444)',
  critical: 'var(--osd-color-status-critical, #DC2626)',
  unknown: 'var(--osd-color-status-unknown, #6B7280)'
};
const STATUS_ICONS = {
  ok: '\u2713',
  // checkmark
  warning: '\u26A0',
  // warning triangle
  error: '\u2716',
  // X mark
  critical: '\u2716',
  // X mark
  unknown: '\u2014' // em dash
};

/**
 * Universal status indicator. Renders a colored icon (or custom icon) with an
 * optional text label. Replaces hardcoded SLI status icon logic.
 */
const StatusIndicator = ({
  status,
  label,
  icon
}) => {
  const color = STATUS_COLORS[status];
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
    className: "osd:inline-flex osd:items-center osd:gap-1",
    children: [icon ? /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
      className: "osd:flex osd:items-center",
      style: {
        color
      },
      children: icon
    }) : /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
      className: "osd:inline-flex osd:items-center osd:justify-center osd:w-4 osd:h-4 osd:text-xs osd:font-bold osd:leading-none",
      style: {
        color
      },
      role: "img",
      "aria-label": status,
      children: STATUS_ICONS[status]
    }), label && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
      className: "osd:text-xs osd:text-body-secondary",
      children: label
    })]
  });
};
exports.StatusIndicator = StatusIndicator;