import { jsx as e, jsxs as p } from "react/jsx-runtime";
import { isAddress as u, formatFullAddress as h, formatAddress as w } from "@argent/x-shared";
import { typographyStyles as x } from "../features/theme/typographyStyles.generated.js";
import { Flex as n, Tooltip as s, Text as l } from "@chakra-ui/react";
import { isString as g } from "lodash-es";
import { useMemo as b, isValidElement as A, useState as S, useRef as y, useCallback as V } from "react";
function W(r) {
  return /* @__PURE__ */ e(n, { direction: "column", w: "full", ...r });
}
function C({ label: r, value: t }) {
  const i = b(() => t === void 0 ? null : A(t) ? t : g(t) && u(t) ? /* @__PURE__ */ e(s, { label: h(t), placement: "top", children: /* @__PURE__ */ e(l, { ml: "auto", textAlign: "right", children: w(t) }) }) : /* @__PURE__ */ e(F, { ml: "auto", textAlign: "right", value: t }), [t]);
  return /* @__PURE__ */ p(n, { alignItems: "center", flex: 1, gap: 1, _notFirst: { mt: 2 }, ...x.P3, children: [
    /* @__PURE__ */ e(l, { color: "text-secondary", whiteSpace: "nowrap", children: r }),
    i
  ] });
}
function F({ value: r, ...t }) {
  const [i, c] = S(!1), o = y(null), f = V((a) => {
    if (o.current = a, o != null && o.current) {
      const { scrollWidth: m, offsetWidth: d } = o.current;
      c(m > d);
    }
  }, []);
  return /* @__PURE__ */ e(s, { label: r, placement: "top", isDisabled: !i, children: /* @__PURE__ */ e(l, { ref: f, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", ...t, children: r }) });
}
export {
  F as LabelValueAutoTooltip,
  C as LabelValueRow,
  W as LabelValueStack
};
