"use client";
import * as n from "react";
import V from "../../../../_virtual/sortBy.js";
import { clsx as w } from "../../../clsx/dist/clsx.js";
import { isNullish as I, isNumOrStr as u } from "../util/DataUtils.js";
function y() {
  return y = Object.assign ? Object.assign.bind() : function(e) {
    for (var r = 1; r < arguments.length; r++) {
      var t = arguments[r];
      for (var a in t) ({}).hasOwnProperty.call(t, a) && (e[a] = t[a]);
    }
    return e;
  }, y.apply(null, arguments);
}
function P(e, r) {
  var t = Object.keys(e);
  if (Object.getOwnPropertySymbols) {
    var a = Object.getOwnPropertySymbols(e);
    r && (a = a.filter(function(m) {
      return Object.getOwnPropertyDescriptor(e, m).enumerable;
    })), t.push.apply(t, a);
  }
  return t;
}
function b(e) {
  for (var r = 1; r < arguments.length; r++) {
    var t = arguments[r] != null ? arguments[r] : {};
    r % 2 ? P(Object(t), !0).forEach(function(a) {
      R(e, a, t[a]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : P(Object(t)).forEach(function(a) {
      Object.defineProperty(e, a, Object.getOwnPropertyDescriptor(t, a));
    });
  }
  return e;
}
function R(e, r, t) {
  return (r = q(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e;
}
function q(e) {
  var r = z(e, "string");
  return typeof r == "symbol" ? r : r + "";
}
function z(e, r) {
  if (typeof e != "object" || !e) return e;
  var t = e[Symbol.toPrimitive];
  if (t !== void 0) {
    var a = t.call(e, r);
    if (typeof a != "object") return a;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return (r === "string" ? String : Number)(e);
}
function G(e) {
  return Array.isArray(e) && u(e[0]) && u(e[1]) ? e.join(" ~ ") : e;
}
var Q = (e) => {
  var {
    separator: r = " : ",
    contentStyle: t = {},
    itemStyle: a = {},
    labelStyle: m = {},
    payload: l,
    formatter: S,
    itemSorter: v,
    wrapperClassName: E,
    labelClassName: C,
    label: p,
    labelFormatter: g,
    accessibilityLayer: A = !1
  } = e, D = () => {
    if (l && l.length) {
      var T = {
        padding: 0,
        margin: 0
      }, B = (v ? V(l, v) : l).map((i, O) => {
        if (i.type === "none")
          return null;
        var h = i.formatter || S || G, {
          value: j,
          name: N
        } = i, f = j, s = N;
        if (h) {
          var c = h(j, N, i, O, l);
          if (Array.isArray(c))
            [f, s] = c;
          else if (c != null)
            f = c;
          else
            return null;
        }
        var K = b({
          display: "block",
          paddingTop: 4,
          paddingBottom: 4,
          color: i.color || "#000"
        }, a);
        return (
          // eslint-disable-next-line react/no-array-index-key
          /* @__PURE__ */ n.createElement("li", {
            className: "recharts-tooltip-item",
            key: "tooltip-item-".concat(O),
            style: K
          }, u(s) ? /* @__PURE__ */ n.createElement("span", {
            className: "recharts-tooltip-item-name"
          }, s) : null, u(s) ? /* @__PURE__ */ n.createElement("span", {
            className: "recharts-tooltip-item-separator"
          }, r) : null, /* @__PURE__ */ n.createElement("span", {
            className: "recharts-tooltip-item-value"
          }, f), /* @__PURE__ */ n.createElement("span", {
            className: "recharts-tooltip-item-unit"
          }, i.unit || ""))
        );
      });
      return /* @__PURE__ */ n.createElement("ul", {
        className: "recharts-tooltip-item-list",
        style: T
      }, B);
    }
    return null;
  }, _ = b({
    margin: 0,
    padding: 10,
    backgroundColor: "#fff",
    border: "1px solid #ccc",
    whiteSpace: "nowrap"
  }, t), k = b({
    margin: 0
  }, m), d = !I(p), o = d ? p : "", x = w("recharts-default-tooltip", E), L = w("recharts-tooltip-label", C);
  d && g && l !== void 0 && l !== null && (o = g(p, l));
  var F = A ? {
    role: "status",
    "aria-live": "assertive"
  } : {};
  return /* @__PURE__ */ n.createElement("div", y({
    className: x,
    style: _
  }, F), /* @__PURE__ */ n.createElement("p", {
    className: L,
    style: k
  }, /* @__PURE__ */ n.isValidElement(o) ? o : "".concat(o)), D());
};
export {
  Q as DefaultTooltipContent
};
