"use client";
import * as w from "react";
import { clsx as B } from "../../../clsx/dist/clsx.js";
import { adaptEventHandlers as S } from "../util/types.js";
import { isNumber as y, upperFirst as E } from "../util/DataUtils.js";
import { isWellBehavedNumber as b } from "../util/isWellBehavedNumber.js";
import { svgPropertiesNoEvents as N } from "../util/svgPropertiesNoEvents.js";
import m from "../../../d3-shape/src/area.js";
import A from "../../../d3-shape/src/line.js";
import C, { stepBefore as X, stepAfter as Y } from "../../../d3-shape/src/curve/step.js";
import _ from "../../../d3-shape/src/curve/natural.js";
import { monotoneY as F, monotoneX as D } from "../../../d3-shape/src/curve/monotone.js";
import P from "../../../d3-shape/src/curve/linear.js";
import L from "../../../d3-shape/src/curve/linearClosed.js";
import { bumpY as R, bumpX as M } from "../../../d3-shape/src/curve/bump.js";
import K from "../../../d3-shape/src/curve/basis.js";
import T from "../../../d3-shape/src/curve/basisOpen.js";
import k from "../../../d3-shape/src/curve/basisClosed.js";
function v() {
  return v = Object.assign ? Object.assign.bind() : function(e) {
    for (var t = 1; t < arguments.length; t++) {
      var r = arguments[t];
      for (var n in r) ({}).hasOwnProperty.call(r, n) && (e[n] = r[n]);
    }
    return e;
  }, v.apply(null, arguments);
}
function g(e, t) {
  var r = Object.keys(e);
  if (Object.getOwnPropertySymbols) {
    var n = Object.getOwnPropertySymbols(e);
    t && (n = n.filter(function(i) {
      return Object.getOwnPropertyDescriptor(e, i).enumerable;
    })), r.push.apply(r, n);
  }
  return r;
}
function O(e) {
  for (var t = 1; t < arguments.length; t++) {
    var r = arguments[t] != null ? arguments[t] : {};
    t % 2 ? g(Object(r), !0).forEach(function(n) {
      H(e, n, r[n]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : g(Object(r)).forEach(function(n) {
      Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(r, n));
    });
  }
  return e;
}
function H(e, t, r) {
  return (t = I(t)) in e ? Object.defineProperty(e, t, { value: r, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = r, e;
}
function I(e) {
  var t = U(e, "string");
  return typeof t == "symbol" ? t : t + "";
}
function U(e, t) {
  if (typeof e != "object" || !e) return e;
  var r = e[Symbol.toPrimitive];
  if (r !== void 0) {
    var n = r.call(e, t);
    if (typeof n != "object") return n;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return (t === "string" ? String : Number)(e);
}
var d = {
  curveBasisClosed: k,
  curveBasisOpen: T,
  curveBasis: K,
  curveBumpX: M,
  curveBumpY: R,
  curveLinearClosed: L,
  curveLinear: P,
  curveMonotoneX: D,
  curveMonotoneY: F,
  curveNatural: _,
  curveStep: C,
  curveStepAfter: Y,
  curveStepBefore: X
}, s = (e) => b(e.x) && b(e.y), c = (e) => e.x, f = (e) => e.y, V = (e, t) => {
  if (typeof e == "function")
    return e;
  var r = "curve".concat(E(e));
  return (r === "curveMonotone" || r === "curveBump") && t ? d["".concat(r).concat(t === "vertical" ? "Y" : "X")] : d[r] || P;
}, W = (e) => {
  var {
    type: t = "linear",
    points: r = [],
    baseLine: n,
    layout: i,
    connectNulls: u = !1
  } = e, p = V(t, i), l = u ? r.filter(s) : r, o;
  if (Array.isArray(n)) {
    var h = u ? n.filter((a) => s(a)) : n, j = l.map((a, x) => O(O({}, a), {}, {
      base: h[x]
    }));
    return i === "vertical" ? o = m().y(f).x1(c).x0((a) => a.base.x) : o = m().x(c).y1(f).y0((a) => a.base.y), o.defined(s).curve(p), o(j);
  }
  return i === "vertical" && y(n) ? o = m().y(f).x1(c).x0(n) : y(n) ? o = m().x(c).y1(f).y0(n) : o = A().x(c).y(f), o.defined(s).curve(p), o(l);
}, fe = (e) => {
  var {
    className: t,
    points: r,
    path: n,
    pathRef: i
  } = e;
  if ((!r || !r.length) && !n)
    return null;
  var u = r && r.length ? W(e) : n;
  return /* @__PURE__ */ w.createElement("path", v({}, N(e), S(e), {
    className: B("recharts-curve", t),
    d: u === null ? void 0 : u,
    ref: i
  }));
};
export {
  fe as Curve,
  W as getPath
};
