/* Copyright © 2020 Splunk Inc.
SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
in part without a valid written license from Splunk Inc. is PROHIBITED. */
import {
  EVENT_ANNOTATION_DIMENSIONS,
  getEventAnnotationRenderer
} from "./chunk-BI5HQSM3.js";
import {
  Alert,
  CriticalSeverity,
  DefaultAnnotationLabels
} from "./chunk-OHHNF4E3.js";
import {
  def
} from "./chunk-SIXD2HQM.js";
import {
  useVizTheme
} from "./chunk-P6Y5CKTH.js";
import {
  styled_components_default,
  styled_components_exports
} from "./chunk-5LUILIR3.js";
import {
  formatTimestamp
} from "./chunk-FWZM3EJJ.js";
import {
  react_default,
  react_exports
} from "./chunk-V3S5WUKN.js";

// src/AnnotationTooltip.tsx
var StyledAnnotationContainer = styled_components_default.div`
    display: flex;
    flex-direction: row;
    align-items: center;
`;
var StyledAnnotationIconContainer = styled_components_default.div`
    margin-right: 10px;
    display: flex;
    align-items: center;
`;
var StyledAnnotationSeverityContainer = styled_components_default.div`
    color: ${(props) => props.theme.tooltip.color};
    margin-right: 10px;
    display: flex;
    align-items: center;
`;
var StyledAnnotationTriggeredContainer = styled_components_default.div`
    color: ${(props) => props.theme.tooltip.color};
`;
var StyledAnnotationTimeContainer = styled_components_default.div`
    color: #ccc;
    font-size: 12px;
    margin-bottom: 1;
`;
var StyledAnnotationDetailsContainer = styled_components_default.div`
    color: #ccc;
    font-size: 12px;
    margin-bottom: 1;
`;
var StyledAnnotationTooltip = styled_components_default.div`
    border-radius: 5px;
    background-color: ${(props) => props.theme.tooltip.backgroundColor};
    color: ${(props) => props.theme.tooltip.color};
    margin: 0 5px;
    padding: 5px 10px;
    font-size: 14px;
    text-align: left;
`;
var CLICK_ANNOTATION_DETAILS_LABEL = "Click on annotation for details";
var BasicEventAnnotationTooltip = (props) => {
  var _a;
  const theme = useVizTheme();
  const locale = props == null ? void 0 : props.userLocale;
  let formattedDate = null;
  if (props.eventAnnotationCursorState.time) {
    formattedDate = formatTimestamp(
      props.eventAnnotationCursorState.time * 1e3,
      "dateVerboseTimePrecise",
      locale
    );
  }
  const onClickAnnotationEnabled = def((_a = props.eventAnnotationConfig) == null ? void 0 : _a.onEventAnnotationClick);
  const annotationRenderer = getEventAnnotationRenderer(props.eventAnnotationConfig);
  const getAnnotationInfoRow = (eventAnnotationCursorState) => {
    if (eventAnnotationCursorState.type === Alert) {
      return /* @__PURE__ */ react_default.createElement(react_default.Fragment, null, /* @__PURE__ */ react_default.createElement(StyledAnnotationSeverityContainer, { theme }, DefaultAnnotationLabels[eventAnnotationCursorState.severity || CriticalSeverity]), /* @__PURE__ */ react_default.createElement(StyledAnnotationIconContainer, null, annotationRenderer({
        event: eventAnnotationCursorState,
        theme,
        dimensions: EVENT_ANNOTATION_DIMENSIONS
      })), /* @__PURE__ */ react_default.createElement(StyledAnnotationTriggeredContainer, { theme }, "1 triggered"));
    }
    return /* @__PURE__ */ react_default.createElement(StyledAnnotationTriggeredContainer, { theme }, eventAnnotationCursorState.key);
  };
  return /* @__PURE__ */ react_default.createElement(StyledAnnotationTooltip, { theme }, formattedDate && /* @__PURE__ */ react_default.createElement(StyledAnnotationTimeContainer, null, formattedDate), /* @__PURE__ */ react_default.createElement(StyledAnnotationContainer, null, getAnnotationInfoRow(props.eventAnnotationCursorState)), onClickAnnotationEnabled && /* @__PURE__ */ react_default.createElement(StyledAnnotationDetailsContainer, null, CLICK_ANNOTATION_DETAILS_LABEL));
};

export {
  BasicEventAnnotationTooltip
};
//# sourceMappingURL=chunk-G727SYRY.js.map
