"use client";
import { clsx as B } from "../../../../clsx/dist/clsx.js";
import { isNumber as r } from "../DataUtils.js";
var f = "recharts-tooltip-wrapper", T = {
  visibility: "hidden"
};
function D(n) {
  var {
    coordinate: t,
    translateX: o,
    translateY: e
  } = n;
  return B(f, {
    ["".concat(f, "-right")]: r(o) && t && r(t.x) && o >= t.x,
    ["".concat(f, "-left")]: r(o) && t && r(t.x) && o < t.x,
    ["".concat(f, "-bottom")]: r(e) && t && r(t.y) && e >= t.y,
    ["".concat(f, "-top")]: r(e) && t && r(t.y) && e < t.y
  });
}
function m(n) {
  var {
    allowEscapeViewBox: t,
    coordinate: o,
    key: e,
    offsetTopLeft: c,
    position: p,
    reverseDirection: s,
    tooltipDimension: u,
    viewBox: v,
    viewBoxDimension: x
  } = n;
  if (p && r(p[e]))
    return p[e];
  var i = o[e] - u - (c > 0 ? c : 0), a = o[e] + c;
  if (t[e])
    return s[e] ? i : a;
  var l = v[e];
  if (l == null)
    return 0;
  if (s[e]) {
    var h = i, w = l;
    return h < w ? Math.max(a, l) : Math.max(i, l);
  }
  if (x == null)
    return 0;
  var d = a + u, y = l + x;
  return d > y ? Math.max(i, l) : Math.max(a, l);
}
function g(n) {
  var {
    translateX: t,
    translateY: o,
    useTranslate3d: e
  } = n;
  return {
    transform: e ? "translate3d(".concat(t, "px, ").concat(o, "px, 0)") : "translate(".concat(t, "px, ").concat(o, "px)")
  };
}
function X(n) {
  var {
    allowEscapeViewBox: t,
    coordinate: o,
    offsetTopLeft: e,
    position: c,
    reverseDirection: p,
    tooltipBox: s,
    useTranslate3d: u,
    viewBox: v
  } = n, x, i, a;
  return s.height > 0 && s.width > 0 && o ? (i = m({
    allowEscapeViewBox: t,
    coordinate: o,
    key: "x",
    offsetTopLeft: e,
    position: c,
    reverseDirection: p,
    tooltipDimension: s.width,
    viewBox: v,
    viewBoxDimension: v.width
  }), a = m({
    allowEscapeViewBox: t,
    coordinate: o,
    key: "y",
    offsetTopLeft: e,
    position: c,
    reverseDirection: p,
    tooltipDimension: s.height,
    viewBox: v,
    viewBoxDimension: v.height
  }), x = g({
    translateX: i,
    translateY: a,
    useTranslate3d: u
  })) : x = T, {
    cssProperties: x,
    cssClasses: D({
      translateX: i,
      translateY: a,
      coordinate: o
    })
  };
}
export {
  D as getTooltipCSSClassName,
  X as getTooltipTranslate,
  m as getTooltipTranslateXY,
  g as getTransformStyle
};
