/* 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 {
  Alert,
  CriticalSeverity,
  Event,
  InfoSeverity,
  MajorSeverity,
  MinorSeverity,
  WarningSeverity
} from "./chunk-OHHNF4E3.js";
import {
  useVizTheme
} from "./chunk-P6Y5CKTH.js";
import {
  react_default,
  react_exports
} from "./chunk-V3S5WUKN.js";
import {
  __export,
  __reExport,
  __spreadProps,
  __spreadValues
} from "./chunk-XC4WXK3L.js";

// esm-externals:@splunk/react-icons/ArrowTriangleDown
var ArrowTriangleDown_exports = {};
__export(ArrowTriangleDown_exports, {
  default: () => ArrowTriangleDown_default
});
__reExport(ArrowTriangleDown_exports, ArrowTriangleDown_star);
import * as defaultImport from "@splunk/react-icons/ArrowTriangleDown";
import * as ArrowTriangleDown_star from "@splunk/react-icons/ArrowTriangleDown";
var ArrowTriangleDown_default = "default" in defaultImport ? defaultImport.default : defaultImport;

// esm-externals:@splunk/react-icons/Circle
var Circle_exports = {};
__export(Circle_exports, {
  default: () => Circle_default
});
__reExport(Circle_exports, Circle_star);
import * as defaultImport2 from "@splunk/react-icons/Circle";
import * as Circle_star from "@splunk/react-icons/Circle";
var Circle_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;

// esm-externals:@splunk/react-icons/Diamond
var Diamond_exports = {};
__export(Diamond_exports, {
  default: () => Diamond_default
});
__reExport(Diamond_exports, Diamond_star);
import * as defaultImport3 from "@splunk/react-icons/Diamond";
import * as Diamond_star from "@splunk/react-icons/Diamond";
var Diamond_default = "default" in defaultImport3 ? defaultImport3.default : defaultImport3;

// esm-externals:@splunk/react-icons/Triangle
var Triangle_exports = {};
__export(Triangle_exports, {
  default: () => Triangle_default
});
__reExport(Triangle_exports, Triangle_star);
import * as defaultImport4 from "@splunk/react-icons/Triangle";
import * as Triangle_star from "@splunk/react-icons/Triangle";
var Triangle_default = "default" in defaultImport4 ? defaultImport4.default : defaultImport4;

// esm-externals:@splunk/react-icons/TrianglesLayeredDouble
var TrianglesLayeredDouble_exports = {};
__export(TrianglesLayeredDouble_exports, {
  default: () => TrianglesLayeredDouble_default
});
__reExport(TrianglesLayeredDouble_exports, TrianglesLayeredDouble_star);
import * as defaultImport5 from "@splunk/react-icons/TrianglesLayeredDouble";
import * as TrianglesLayeredDouble_star from "@splunk/react-icons/TrianglesLayeredDouble";
var TrianglesLayeredDouble_default = "default" in defaultImport5 ? defaultImport5.default : defaultImport5;

// src/icons/AlertIcon.tsx
var AlertIcon = (props) => {
  switch (props.severity) {
    case WarningSeverity:
      return /* @__PURE__ */ react_default.createElement(
        Diamond_default,
        {
          width: `${props.dimensions.width}px`,
          height: `${props.dimensions.width}px`,
          viewBox: "0 0 24 24",
          style: { color: props.theme.annotationIcon.alertIconColor.warning },
          variant: `${props.isCleared ? "outlined" : "filled"}`
        }
      );
    case InfoSeverity:
      return /* @__PURE__ */ react_default.createElement(
        Circle_default,
        {
          width: `${props.dimensions.width}px`,
          height: `${props.dimensions.width}px`,
          viewBox: "0 0 24 24",
          style: { color: props.theme.annotationIcon.alertIconColor.info },
          variant: `${props.isCleared ? "outlined" : "filled"}`
        }
      );
    case MinorSeverity:
      return /* @__PURE__ */ react_default.createElement(
        ArrowTriangleDown_default,
        {
          width: `${props.dimensions.width}px`,
          height: `${props.dimensions.width}px`,
          viewBox: "0 0 24 24",
          style: { color: props.theme.annotationIcon.alertIconColor.minor },
          variant: `${props.isCleared ? "outlined" : "filled"}`
        }
      );
    case MajorSeverity:
      return /* @__PURE__ */ react_default.createElement(
        Triangle_default,
        {
          width: `${props.dimensions.width}px`,
          height: `${props.dimensions.width}px`,
          viewBox: "0 0 24 24",
          style: { color: props.theme.annotationIcon.alertIconColor.major },
          variant: `${props.isCleared ? "outlined" : "filled"}`
        }
      );
    case CriticalSeverity:
    default:
      return /* @__PURE__ */ react_default.createElement(
        TrianglesLayeredDouble_default,
        {
          width: `${props.dimensions.width}px`,
          height: `${props.dimensions.width}px`,
          viewBox: "0 0 24 24",
          style: { color: props.theme.annotationIcon.alertIconColor.critical },
          variant: `${props.isCleared ? "outlined" : "filled"}`
        }
      );
  }
};

// esm-externals:@splunk/react-icons/CheckBox
var CheckBox_exports = {};
__export(CheckBox_exports, {
  default: () => CheckBox_default
});
__reExport(CheckBox_exports, CheckBox_star);
import * as defaultImport6 from "@splunk/react-icons/CheckBox";
import * as CheckBox_star from "@splunk/react-icons/CheckBox";
var CheckBox_default = "default" in defaultImport6 ? defaultImport6.default : defaultImport6;

// src/icons/CustomEventIcon.tsx
var CustomEventIcon = (props) => /* @__PURE__ */ react_default.createElement(
  CheckBox_default,
  {
    width: `${props.dimensions.width}px`,
    height: `${props.dimensions.width}px`,
    viewBox: "0 0 24 24",
    style: { color: props.theme.annotationIcon.customEventIconColor },
    variant: `${props.isCleared ? "outlined" : "filled"}`
  }
);

// src/EventAnnotations.tsx
var EVENT_ANNOTATION_DIMENSIONS = {
  width: 12,
  height: 12
};
var EventAnnotationContainer = (props) => {
  const {
    plotUtilities,
    events,
    eventAnnotationConfig,
    onEventAnnotationHover,
    onEventAnnotationClick,
    xResolution
  } = props;
  const theme = useVizTheme();
  if (!events || !plotUtilities) {
    return null;
  }
  const { height: overHeight } = plotUtilities.dimensions.over;
  const annotationRenderer = getEventAnnotationRenderer(eventAnnotationConfig);
  return /* @__PURE__ */ react_default.createElement("div", { className: "olly-viz-event-annotation-wrap", style: { position: "absolute" } }, events.map((event) => {
    const x = plotUtilities.valToPos(event.time, "x") - EVENT_ANNOTATION_DIMENSIONS.width / 2;
    const y = overHeight;
    const annotationNode = annotationRenderer({
      event,
      theme,
      dimensions: EVENT_ANNOTATION_DIMENSIONS
    });
    return /* @__PURE__ */ react_default.createElement(
      "div",
      {
        key: `${event.key || ""}${event.time}`,
        className: "olly-viz-event-annotation",
        "data-test": "viz-event-annotation",
        style: {
          position: "absolute",
          left: `${x}px`,
          top: `${y}px`,
          width: `${EVENT_ANNOTATION_DIMENSIONS.width}px`,
          height: `${EVENT_ANNOTATION_DIMENSIONS.height}px`,
          display: "flex",
          alignItems: "center",
          justifyContent: "center",
          pointerEvents: "auto"
        },
        onMouseEnter: () => onEventAnnotationHover(event),
        onMouseLeave: () => onEventAnnotationHover(void 0),
        onClick: (mouseEvent) => {
          if (onEventAnnotationClick) {
            onEventAnnotationClick(__spreadProps(__spreadValues({}, event), { xResolution }), mouseEvent);
          }
        }
      },
      annotationNode
    );
  }));
};
var getEventAnnotationRenderer = (eventAnnotationConfig) => {
  const defaultAnnotationRenderer = ({
    event,
    theme,
    dimensions
  }) => {
    switch (event.type) {
      case Alert:
        return /* @__PURE__ */ react_default.createElement(
          AlertIcon,
          {
            theme,
            dimensions,
            severity: event.severity,
            isCleared: event.isCleared
          }
        );
      case Event:
      default:
        return /* @__PURE__ */ react_default.createElement(CustomEventIcon, { theme, dimensions, isCleared: event.isCleared });
    }
  };
  return (eventAnnotationConfig == null ? void 0 : eventAnnotationConfig.renderer) || defaultAnnotationRenderer;
};

export {
  AlertIcon,
  EVENT_ANNOTATION_DIMENSIONS,
  EventAnnotationContainer,
  getEventAnnotationRenderer
};
//# sourceMappingURL=chunk-BI5HQSM3.js.map
