/* 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. */
var __create = Object.create;
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __pow = Math.pow;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
  var target = {};
  for (var prop in source)
    if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
      target[prop] = source[prop];
  if (source != null && __getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(source)) {
      if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
        target[prop] = source[prop];
    }
  return target;
};
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/Legends.tsx
var Legends_exports = {};
__export(Legends_exports, {
  BottomLegend: () => BottomLegend,
  BottomLegendComponent: () => BottomLegendComponent,
  BottomLegendFactory: () => BottomLegendFactory,
  LegendMap: () => LegendMap,
  SideLegend: () => SideLegend,
  SideLegendComponent: () => SideLegendComponent,
  SideLegendFactory: () => SideLegendFactory
});
module.exports = __toCommonJS(Legends_exports);

// esm-externals:react
var react_exports = {};
__export(react_exports, {
  default: () => react_default
});
var defaultImport = __toESM(require("react"));
__reExport(react_exports, require("react"));
var react_default = "default" in defaultImport ? defaultImport.default : defaultImport;

// esm-externals:styled-components
var styled_components_exports = {};
__export(styled_components_exports, {
  default: () => styled_components_default
});
var defaultImport2 = __toESM(require("styled-components"));
__reExport(styled_components_exports, require("styled-components"));
var styled_components_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;

// esm-externals:@splunk/react-ui/Heading
var Heading_exports = {};
__export(Heading_exports, {
  default: () => Heading_default
});
var defaultImport3 = __toESM(require("@splunk/react-ui/Heading"));
__reExport(Heading_exports, require("@splunk/react-ui/Heading"));
var Heading_default = "default" in defaultImport3 ? defaultImport3.default : defaultImport3;

// esm-externals:@splunk/react-ui/Tooltip
var Tooltip_exports = {};
__export(Tooltip_exports, {
  default: () => Tooltip_default
});
var defaultImport4 = __toESM(require("@splunk/react-ui/Tooltip"));
__reExport(Tooltip_exports, require("@splunk/react-ui/Tooltip"));
var Tooltip_default = "default" in defaultImport4 ? defaultImport4.default : defaultImport4;

// esm-externals:@splunk/themes
var themes_exports = {};
__export(themes_exports, {
  default: () => themes_default
});
var defaultImport5 = __toESM(require("@splunk/themes"));
__reExport(themes_exports, require("@splunk/themes"));
var themes_default = "default" in defaultImport5 ? defaultImport5.default : defaultImport5;

// src/theme.tsx
var lightVizTheme = {
  name: "light",
  color: "#2C2C2C",
  font: "10px Arial",
  labelFont: "12px Arial",
  axis: {
    axisStroke: "#E6E6E6",
    gridStroke: "#DDDDDD",
    xLabelStroke: "#6B6B6B",
    yLabelStroke: "#4D4D4D"
  },
  tooltip: {
    lineStroke: "rgba(44, 44, 44, 0.85)",
    inactiveLineStroke: "#999",
    backgroundColor: "rgba(44, 44, 44, 0.85)",
    color: "white",
    secondaryColor: "#999"
  },
  pin: {
    iconStroke: "white",
    lineStroke: "#9e9e9e",
    dotFill: "#9e9e9e"
  },
  heatmap: {
    axisStroke: "#2c2c2c",
    axisFontSize: 12,
    colorScheme: [
      "#ffffff",
      "#ccd6d7",
      "#aec8cd",
      "#8fb8c7",
      "#6ea8c1",
      "#4b96bd",
      "#2181bb",
      "#0067ba",
      "#0047bd",
      "#0502ca"
    ]
  },
  annotationIcon: {
    customEventIconColor: "#818285",
    alertIconColor: {
      critical: "#E00000",
      major: "#C97705",
      minor: "#155A4E",
      warning: "#006BE5",
      info: "#7B4DF5"
    }
  }
};
var darkVizTheme = {
  name: "dark",
  color: "#FAFAFA",
  font: "10px Arial",
  labelFont: "12px Arial",
  axis: {
    axisStroke: "#43454B",
    gridStroke: "#43454B",
    xLabelStroke: "#909090",
    yLabelStroke: "#B5B5B5"
  },
  tooltip: {
    lineStroke: "white",
    inactiveLineStroke: "#666",
    backgroundColor: "rgba(64, 64, 64, 0.85)",
    color: "white",
    secondaryColor: "#999"
  },
  pin: {
    iconStroke: "white",
    lineStroke: "white",
    dotFill: "#bdbdbd"
  },
  heatmap: {
    axisStroke: "#fafafa",
    axisFontSize: 12,
    colorScheme: [
      "#000000",
      "#15355a",
      "#315272",
      "#496d89",
      "#60869e",
      "#759db3",
      "#89b4c7",
      "#9ccad9",
      "#afdfec",
      "#c2f5ff"
    ]
  },
  annotationIcon: {
    customEventIconColor: "#818285",
    alertIconColor: {
      critical: "#FF4242",
      major: "#F49106",
      minor: "#2CBDA3",
      warning: "#61CAFA",
      info: "#AB74F1"
    }
  }
};
function getVizThemeForKey(key) {
  switch (key) {
    case "dark": {
      return darkVizTheme;
    }
    case "light":
    default: {
      return lightVizTheme;
    }
  }
}
function useVizTheme() {
  const { colorScheme } = (0, themes_exports.useSplunkTheme)();
  return getVizThemeForKey(colorScheme);
}

// esm-externals:lodash
var lodash_exports = {};
__export(lodash_exports, {
  default: () => lodash_default
});
var defaultImport6 = __toESM(require("lodash"));
__reExport(lodash_exports, require("lodash"));
var lodash_default = "default" in defaultImport6 ? defaultImport6.default : defaultImport6;

// src/utilities/scaleTime.ts
var timeScaleMap = {
  ["w" /* Weeks */]: { unit: "w", scaleUp: null, scaleUpValue: null, decimalPlaces: 0 },
  ["d" /* Days */]: {
    unit: "d",
    scaleUp: "w" /* Weeks */,
    scaleUpValue: 7,
    decimalPlaces: 0
  },
  ["h" /* Hours */]: { unit: "h", scaleUp: "d" /* Days */, scaleUpValue: 24, decimalPlaces: 1 },
  ["m" /* Minutes */]: {
    unit: "m",
    scaleUp: "h" /* Hours */,
    scaleUpValue: 60,
    decimalPlaces: 1
  },
  ["s" /* Seconds */]: {
    unit: "s",
    scaleUp: "m" /* Minutes */,
    scaleUpValue: 60,
    decimalPlaces: 2
  },
  ["ms" /* Milliseconds */]: {
    unit: "ms",
    scaleUp: "s" /* Seconds */,
    scaleUpValue: 1e3,
    decimalPlaces: 0
  },
  ["us" /* Microseconds */]: {
    unit: `${String.fromCharCode(181)}s`,
    scaleUp: "ms" /* Milliseconds */,
    scaleUpValue: 1e3,
    decimalPlaces: 0
  },
  ["ns" /* Nanoseconds */]: {
    unit: "ns",
    scaleUp: "us" /* Microseconds */,
    scaleUpValue: 1e3,
    decimalPlaces: 0
  }
};
function scaleTime(time, startingScale = "us" /* Microseconds */, decimalPlaces) {
  if (!time || time === 0) {
    return {
      scale: timeScaleMap["ms" /* Milliseconds */].unit,
      value: 0
    };
  }
  let iScale = timeScaleMap[startingScale];
  let timeValue = time;
  let sign = 1;
  if (time < 0) {
    sign = -1;
    timeValue = Math.abs(time);
  }
  while (iScale.scaleUpValue !== null && timeValue >= iScale.scaleUpValue && iScale.scaleUp) {
    timeValue /= iScale.scaleUpValue;
    iScale = timeScaleMap[iScale.scaleUp];
  }
  timeValue *= sign;
  return {
    scale: iScale.unit,
    value: timeValue.toFixed(typeof decimalPlaces !== "undefined" ? decimalPlaces : iScale.decimalPlaces)
  };
}

// src/utilities/formatDuration.ts
var formatDurationMicros = (tickValue, decimalPlaces) => {
  const { value, scale } = scaleTime(tickValue, "us" /* Microseconds */, decimalPlaces || void 0);
  return parseFloat(value.toString()).toString() + scale;
};

// src/utilities/shortenByte.ts
function shortenByte(num, decimalPlaces = 1) {
  let str;
  let suffix = "";
  if (!num) {
    return "0B";
  }
  decimalPlaces = decimalPlaces || 0;
  num = +num.toFixed(decimalPlaces);
  const factor = __pow(10, decimalPlaces);
  if (num < 1e3) {
    str = num;
    suffix = "B";
  } else if (num < 1e6) {
    str = Math.floor(num / (1e3 / factor)) / factor;
    suffix = "KB";
  } else if (num < 1e9) {
    str = Math.floor(num / (1e6 / factor)) / factor;
    suffix = "MB";
  } else if (num < 1e12) {
    str = Math.floor(num / (1e9 / factor)) / factor;
    suffix = "GB";
  } else if (num < 1e15) {
    str = Math.floor(num / (1e12 / factor)) / factor;
    suffix = "TB";
  } else if (num < 1e18) {
    str = Math.floor(num / (1e15 / factor)) / factor;
    suffix = "PB";
  }
  return str + suffix;
}

// src/utilities/shortenNumber.ts
var generateShortenNumberComponents = (num, decimalPlaces) => {
  let str;
  let suffix = "";
  let value;
  if (num === 0 || !num) {
    value = 0;
    return { value, str: "0", suffix };
  }
  if (typeof decimalPlaces === "undefined") {
    decimalPlaces = num < 10 ? 2 : 1;
  }
  num = +num.toFixed(decimalPlaces);
  const factor = __pow(10, decimalPlaces);
  if (num === 0) {
    if (decimalPlaces === 0) {
      str = "<1";
    } else {
      str = `<0.${"0".repeat(decimalPlaces - 1)}1`;
    }
  } else if (num < 1e3) {
    value = num;
    str = value;
  } else if (num < 1e6) {
    value = Math.floor(num / (1e3 / factor)) / factor;
    str = value;
    suffix = "k";
  } else if (num < 1e9) {
    value = Math.floor(num / (1e6 / factor)) / factor;
    str = value;
    suffix = "m";
  } else if (num < 1e12) {
    value = Math.floor(num / (1e9 / factor)) / factor;
    str = value;
    suffix = "b";
  } else if (num < 1e15) {
    value = Math.floor(num / (1e12 / factor)) / factor;
    str = value;
    suffix = "t";
  }
  return { value, str: String(str), suffix };
};
function shortenNumber(num, decimalPlaces) {
  const { str, suffix } = generateShortenNumberComponents(num, decimalPlaces);
  return str + suffix;
}

// esm-externals:lodash/some
var some_exports = {};
__export(some_exports, {
  default: () => some_default
});
var defaultImport7 = __toESM(require("lodash/some"));
__reExport(some_exports, require("lodash/some"));
var some_default = "default" in defaultImport7 ? defaultImport7.default : defaultImport7;

// esm-externals:uplot
var uplot_exports = {};
__export(uplot_exports, {
  default: () => uplot_default
});
var defaultImport8 = __toESM(require("uplot"));
__reExport(uplot_exports, require("uplot"));
var uplot_default = "default" in defaultImport8 ? defaultImport8.default : defaultImport8;

// esm-externals:temporal-polyfill
var temporal_polyfill_exports = {};
__export(temporal_polyfill_exports, {
  default: () => temporal_polyfill_default
});
var defaultImport9 = __toESM(require("temporal-polyfill"));
__reExport(temporal_polyfill_exports, require("temporal-polyfill"));
var temporal_polyfill_default = "default" in defaultImport9 ? defaultImport9.default : defaultImport9;

// esm-externals:string-format-obj
var string_format_obj_exports = {};
__export(string_format_obj_exports, {
  default: () => string_format_obj_default
});
var defaultImport10 = __toESM(require("string-format-obj"));
__reExport(string_format_obj_exports, require("string-format-obj"));
var string_format_obj_default = "default" in defaultImport10 ? defaultImport10.default : defaultImport10;

// src/utilities/formatTimestamp.ts
var EPOCH_SECONDS_MAX_VALUE = Date.now() / 100;

// src/renderers/uplot-utils.ts
var { bars } = uplot_default.paths;
var bars90PercentGap100MaxWidthPaths = bars ? bars({ size: [0.9, 100] }) : void 0;

// src/utilities/utils.ts
var DAY = 24 * 60 * 60;
function exists(value) {
  return value !== void 0 && value !== null;
}
function getMergedSeriesConfigForField(seriesConfigMap = {}, scaleConfigMap = {}, field) {
  const defaults = { scale: "y" };
  if (!exists(field)) {
    return defaults;
  }
  const seriesConfig = seriesConfigMap[field];
  const scale = (seriesConfig == null ? void 0 : seriesConfig.scale) || "y";
  const scaleConfig = scaleConfigMap[scale] || {};
  const mergedSeriesConfig = __spreadValues(__spreadValues(__spreadValues({}, defaults), scaleConfig.seriesConfig), seriesConfig);
  return mergedSeriesConfig;
}
var formatKibBytes = (bytes, decimals = 2) => {
  if (!+bytes) {
    return "0B";
  }
  const k = 1024;
  const dm = decimals < 0 ? 0 : decimals;
  const sizes = ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];
  const i = Math.floor(Math.log(bytes) / Math.log(k));
  return `${parseFloat((bytes / __pow(k, i)).toFixed(dm))}${sizes[i]}`;
};
var namedFormatters = {
  durationMicros: (value) => formatDurationMicros(value),
  rate: (value, xAxisResolution) => `${shortenNumber(value / (xAxisResolution || 1))} /s`,
  count: (value) => `${shortenNumber(value)}`,
  bytes: (value) => `${shortenByte(value)}`,
  percentage: (value) => `${shortenNumber(value)}%`,
  kibBytes: (value) => `${formatKibBytes(value, 0)}`
};
var scaleNamedFormatters = __spreadProps(__spreadValues({}, namedFormatters), {
  percentage: (value) => `${shortenNumber(value, value < 10 ? 3 : 2)}%`
});
var getXAxisResolution = (data) => {
  if ((0, lodash_exports.isEmpty)(data.columns)) {
    return 0;
  }
  const timeSeries = data.columns[0];
  const firstNonNullIndex = timeSeries.findIndex((val, i) => val !== null && timeSeries[i + 1] !== null);
  if (firstNonNullIndex === -1) {
    return 0;
  }
  return timeSeries[firstNonNullIndex + 1] - timeSeries[firstNonNullIndex];
};
var formatValueWithSeriesConfig = (value, seriesConfig, data) => {
  const formatter = seriesConfig.valueFmt;
  if (!formatter) {
    return String(value);
  }
  const formatFn = typeof formatter === "string" ? namedFormatters[formatter] : formatter;
  const xAxisResolution = getXAxisResolution(data);
  return formatFn(value, xAxisResolution);
};
var markPrefix = "mark-";
var buildSeriesForLegend = (series, reversedOrder, marks) => {
  const slicedSeries = series.slice(1);
  if (reversedOrder) {
    slicedSeries.reverse();
  }
  marks == null ? void 0 : marks.forEach(({ legendLabel, color }) => {
    if (!legendLabel) {
      return;
    }
    slicedSeries.push({
      field: `${markPrefix}${legendLabel}`,
      fill: color,
      label: legendLabel,
      show: true
    });
  });
  return slicedSeries;
};

// src/Legends.tsx
var StyledTooltip = styled_components_default(Tooltip_default)`
    flex-shrink: 0;
`;
var DEFAULT_BOTTOM_LEGEND_HEIGHT = 35;
var DEFAULT_SIDE_LEGEND_WIDTH = 200;
var LegendSeriesItem = ({
  series,
  defocus,
  onSeriesClick,
  onSeriesHover,
  formattedValue,
  fontSize
}) => {
  const { field, label, fill, stroke, show } = series;
  const [isOverflowed, setIsOverflowed] = (0, react_exports.useState)(false);
  const ref = (0, react_exports.useRef)(null);
  const handleClick = (0, react_exports.useCallback)(() => {
    onSeriesClick(field, ref);
  }, [onSeriesClick, field]);
  const handleMouseEnter = (0, react_exports.useCallback)(() => {
    onSeriesHover(field);
  }, [onSeriesHover, field]);
  const handleHover = (0, react_exports.useCallback)(() => {
    onSeriesHover(null);
  }, [onSeriesHover]);
  const handleMouseOver = (0, react_exports.useCallback)(({ currentTarget }) => {
    setIsOverflowed(currentTarget.scrollWidth > currentTarget.offsetWidth);
  }, []);
  return /* @__PURE__ */ react_default.createElement(StyledTooltip, { content: label && isOverflowed ? /* @__PURE__ */ react_default.createElement("span", null, label) : "", inline: false }, /* @__PURE__ */ react_default.createElement(
    "div",
    {
      ref,
      style: {
        display: "flex",
        flexDirection: "row",
        alignItems: "center",
        cursor: "pointer",
        fontSize: `${fontSize || 10}px`,
        opacity: show && !defocus ? 1 : 0.3,
        height: "13px"
      },
      role: "button",
      onClick: handleClick,
      onMouseEnter: handleMouseEnter,
      onMouseLeave: handleHover
    },
    /* @__PURE__ */ react_default.createElement(
      "div",
      {
        style: {
          display: "flex",
          position: "relative",
          width: 6,
          height: 11,
          borderRadius: "1px",
          backgroundColor: fill ? String(fill) : String(stroke),
          marginRight: 5,
          marginTop: 1
        }
      }
    ),
    /* @__PURE__ */ react_default.createElement(
      "div",
      {
        style: __spreadValues({
          flex: 1,
          whiteSpace: "nowrap",
          textOverflow: "ellipsis",
          overflow: "hidden"
        }, formattedValue && { marginRight: 3 }),
        onMouseOver: handleMouseOver
      },
      label
    ),
    /* @__PURE__ */ react_default.createElement("div", null, formattedValue)
  ));
};
var LegendSeriesList = (props) => {
  const {
    plotUtilities,
    data,
    cursorState,
    seriesConfig = {},
    scaleConfig = {},
    hideSeriesValue,
    seriesDataAccessor = (i) => (cursorState == null ? void 0 : cursorState.cursor) ? data.columns[i + 1][cursorState.cursor.index] : null,
    fontSize,
    reversedOrder,
    onSeriesClick,
    onSeriesHover,
    marks
  } = props;
  const slicedSeries = buildSeriesForLegend(plotUtilities.allSeries, reversedOrder, marks);
  const [hoveredSeriesKey, setHoveredSeriesKey] = (0, react_exports.useState)();
  const handleSeriesHover = (0, react_exports.useCallback)(
    (field) => {
      setHoveredSeriesKey(field);
      onSeriesHover(field);
    },
    [onSeriesHover]
  );
  return /* @__PURE__ */ react_default.createElement(react_default.Fragment, null, slicedSeries.map((series, i) => {
    const { field } = series;
    let formattedValue = hideSeriesValue ? null : " ";
    const seriesIndex = reversedOrder ? slicedSeries.length - i - 1 : i;
    if (seriesIndex < data.columns.length - 1) {
      const value = seriesDataAccessor(seriesIndex);
      if (value !== null) {
        const config = getMergedSeriesConfigForField(seriesConfig, scaleConfig, field);
        formattedValue = formatValueWithSeriesConfig(value, config, data);
      }
    }
    let defocus = false;
    if (exists(cursorState == null ? void 0 : cursorState.seriesIndex) || hoveredSeriesKey) {
      if (hoveredSeriesKey) {
        defocus = field !== hoveredSeriesKey;
      } else {
        defocus = reversedOrder ? slicedSeries.length - i !== (cursorState == null ? void 0 : cursorState.seriesIndex) : i + 1 !== (cursorState == null ? void 0 : cursorState.seriesIndex);
      }
    }
    return /* @__PURE__ */ react_default.createElement(
      LegendSeriesItem,
      {
        key: field,
        series,
        defocus,
        formattedValue,
        onSeriesClick,
        onSeriesHover: handleSeriesHover,
        fontSize
      }
    );
  }));
};
var SideLegendComponent = (props) => {
  const _a = props, { plotUtilities, title, width } = _a, legendSeriesProps = __objRest(_a, ["plotUtilities", "title", "width"]);
  const theme = useVizTheme();
  if (!plotUtilities) {
    return null;
  }
  return /* @__PURE__ */ react_default.createElement(
    "div",
    {
      style: {
        display: "flex",
        flexDirection: "column",
        width,
        color: theme.color,
        height: "100%",
        overflowX: "hidden",
        overflowY: "auto",
        paddingRight: 5
      }
    },
    title && /* @__PURE__ */ react_default.createElement(Heading_default, { level: 6 }, " ", title, " "),
    /* @__PURE__ */ react_default.createElement(LegendSeriesList, __spreadValues({ plotUtilities }, legendSeriesProps))
  );
};
var BottomLegendComponent = (props) => {
  const _a = props, { plotUtilities, title, wrap } = _a, legendSeriesProps = __objRest(_a, ["plotUtilities", "title", "wrap"]);
  const theme = useVizTheme();
  if (!plotUtilities) {
    return null;
  }
  return /* @__PURE__ */ react_default.createElement("div", null, title && /* @__PURE__ */ react_default.createElement(Heading_default, { style: { marginTop: "0" }, level: 6 }, title), /* @__PURE__ */ react_default.createElement(
    "div",
    {
      style: {
        display: "flex",
        flexWrap: wrap ? "wrap" : "nowrap",
        color: theme.color,
        gap: "0px 10px"
      }
    },
    /* @__PURE__ */ react_default.createElement(LegendSeriesList, __spreadValues({ plotUtilities }, legendSeriesProps))
  ));
};
var SideLegendFactory = (props) => {
  const component = (componentProps) => {
    if (props) {
      const { aggregateData, title, reversedOrder, width, fontSize, hideSeriesValue } = props;
      if (hideSeriesValue === true) {
        return /* @__PURE__ */ react_default.createElement(
          SideLegendComponent,
          __spreadProps(__spreadValues({}, componentProps), {
            width: width || DEFAULT_SIDE_LEGEND_WIDTH,
            hideSeriesValue: true,
            seriesDataAccessor: () => null,
            fontSize,
            title,
            reversedOrder
          })
        );
      }
      const { cursorState } = componentProps;
      if (aggregateData && (cursorState === void 0 || cursorState.cursor === null)) {
        return /* @__PURE__ */ react_default.createElement(
          SideLegendComponent,
          __spreadProps(__spreadValues({}, componentProps), {
            width: width || DEFAULT_SIDE_LEGEND_WIDTH,
            title,
            seriesDataAccessor: (i) => aggregateData[i],
            fontSize,
            reversedOrder
          })
        );
      }
      return /* @__PURE__ */ react_default.createElement(
        SideLegendComponent,
        __spreadProps(__spreadValues({}, componentProps), {
          width: width || DEFAULT_SIDE_LEGEND_WIDTH,
          fontSize,
          title,
          reversedOrder
        })
      );
    }
    return /* @__PURE__ */ react_default.createElement(SideLegendComponent, __spreadProps(__spreadValues({}, componentProps), { width: 200 }));
  };
  return {
    component,
    size: { width: (props == null ? void 0 : props.width) || DEFAULT_SIDE_LEGEND_WIDTH },
    anchor: "right"
  };
};
var BottomLegendFactory = (props) => {
  const component = (componentProps) => {
    if (props) {
      const { aggregateData, title, reversedOrder, wrap, fontSize, hideSeriesValue } = props;
      if (hideSeriesValue === true) {
        return /* @__PURE__ */ react_default.createElement(
          BottomLegendComponent,
          __spreadProps(__spreadValues({}, componentProps), {
            hideSeriesValue: true,
            seriesDataAccessor: () => null,
            wrap,
            fontSize,
            title,
            reversedOrder
          })
        );
      }
      const { cursorState } = componentProps;
      if (aggregateData && (cursorState === void 0 || cursorState.cursor === null)) {
        return /* @__PURE__ */ react_default.createElement(
          BottomLegendComponent,
          __spreadProps(__spreadValues({}, componentProps), {
            seriesDataAccessor: (i) => aggregateData[i],
            wrap,
            fontSize,
            title,
            reversedOrder
          })
        );
      }
      return /* @__PURE__ */ react_default.createElement(
        BottomLegendComponent,
        __spreadProps(__spreadValues({}, componentProps), {
          wrap,
          fontSize,
          title,
          reversedOrder
        })
      );
    }
    return /* @__PURE__ */ react_default.createElement(BottomLegendComponent, __spreadValues({}, componentProps));
  };
  return {
    component,
    size: { height: (props == null ? void 0 : props.height) || DEFAULT_BOTTOM_LEGEND_HEIGHT },
    anchor: "bottom"
  };
};
var BottomLegend = BottomLegendFactory();
var SideLegend = SideLegendFactory();
var LegendMap = {
  bottom: BottomLegend,
  right: SideLegend
};
//# sourceMappingURL=Legends.js.map
