import { jsx as l, Fragment as d } from "@emotion/react/jsx-runtime";
import { getPropertyByString as c } from "@m4l/core";
import P, { useMemo as S } from "react";
import { PointsFormatterRootStyled as g } from "./slots/ointsFormatterSlots.js";
import { getComponentSlotRoot as F } from "../../../utils/getComponentSlotRoot.js";
import { getPropDataTestId as z } from "../../../test/getNameDataTestId.js";
import T from "clsx";
import { POINTS_FORMATTER_KEY_COMPONENT as p } from "./constants.js";
import { PointsFormatterSlots as y } from "./slots/PointsFormatterEnum.js";
import { useComponentSize as N } from "../../../hooks/useComponentSize/index.js";
function R(m, s, n, r) {
  let t = "";
  const o = c(m, s), i = c(m, n) || "";
  return o == null || !Array.isArray(o) ? "[]" : (o.map((e) => (e && (t = r ? t.concat(`[${c(e, r)}${i}]`) : t.concat(`[${e}${i}]`)), t)), t);
}
function v(m) {
  const { size: s = "medium", obProps: n, fieldValue: r, fieldUnit: t, Component: o = g, dataTestId: i, className: e, componentProps: u } = m, { currentSize: a } = N(s), f = S(
    () => R(n, r, t),
    [n, r, t]
  );
  return o === P.Fragment ? /* @__PURE__ */ l(d, { children: f }) : /* @__PURE__ */ l(
    o,
    {
      size: a === "small" || a === "medium" ? a : "medium",
      className: T(F(p), e),
      ...z(p, y.root, i),
      role: "points-formatter-role",
      ...u,
      children: f
    }
  );
}
export {
  v as PointsFormatter,
  R as getFormatPoints
};
