import { jsx as m } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import { memo as v } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/compat/dist/compat.module.js";
import { useMemo as L, useCallback as y } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import { Tooltip as I } from "../../../../internal/Tooltip/Tooltip.js";
import { TX_DATA_LABEL as p, TX_DATA_LIST as k } from "../../constants.js";
import { TypographyVariant as D, TypographyElement as P } from "../../../../internal/Typography/types.js";
import { getTransactionAmountAdjustmentType as A, getTransactionAmountAdjustmentTypeInformation as S } from "../../../../utils/translation/getters.js";
import V from "../../../../internal/Typography/Typography.js";
import f from "classnames";
import _ from "../../../../../core/Context/preact/useCoreContext.js";
import x from "../../../../internal/StructuredList/StructuredList.js";
import { isNullish as B } from "../../../../../utils/value/is.js";
const i = {
  grossAmount: "transactions.details.summary.fields.grossAmount",
  netAmount: "transactions.details.summary.fields.netAmount",
  originalAmount: "transactions.details.summary.fields.originalAmount"
}, C = null, N = ({ transaction: c }) => {
  const { i18n: o } = _(), g = L(() => {
    const { additions: t, deductions: a, amountBeforeDeductions: e, netAmount: u, originalAmount: l } = c, r = (n) => {
      if (B(n)) return null;
      const { value: s, currency: d } = n;
      return `${o.amount(s, d, { hideCurrency: !0 })} ${d}`;
    };
    return [
      // original amount
      l && (t && t.length > 0 || l.value !== e.value) ? {
        id: "originalAmount",
        key: i.originalAmount,
        value: r(l)
      } : C,
      // additions
      ...t?.map(({ type: n, ...s }) => ({
        key: A(o, n),
        value: r(s)
      })) ?? [],
      // amountBeforeDeductions
      {
        id: "grossAmount",
        key: i.grossAmount,
        value: r(e)
      },
      // deductions
      ...a?.map(({ type: n, ...s }) => ({
        key: A(o, n),
        value: r(s),
        rawValue: S(o, n)
        // tooltip content
      })) ?? [],
      // netAmount
      {
        id: "netAmount",
        key: i.netAmount,
        value: r(u)
      }
    ].filter(Boolean);
  }, [o, c]), T = y((t, a, e) => e ? /* @__PURE__ */ m(I, { content: e, isUnderlineVisible: !0, children: /* @__PURE__ */ m("span", { className: f(p), children: t }) }) : /* @__PURE__ */ m("div", { className: f(p), children: t }), []), h = y((t, a) => {
    const e = a === i.netAmount, u = D.BODY;
    return /* @__PURE__ */ m(V, { el: P.DIV, variant: u, strongest: e, children: t });
  }, []);
  return /* @__PURE__ */ m(
    x,
    {
      classNames: k,
      items: g,
      layout: "5-7",
      renderLabel: T,
      renderValue: h
    }
  );
}, z = v(N);
export {
  z as default
};
