import { jsxs as h, Fragment as w, jsx as e } from "react/jsx-runtime";
import { justifyContentCenter as M, alignItemsCenter as v, dFlexColumn as F } from "./index-general.module.js";
import { classNames as g } from "./index-classNames.js";
import { Button as j } from "./index-Button.js";
import { IconNames as G } from "./index-IconNames.js";
import { Render as a } from "./index-Render.js";
import { TableProvider as I } from "./index-Table.js";
import { TableBodyRenderer as y } from "./index-TableBodyRenderer.js";
import { Text as W, FontWeights as D, TextTypes as E } from "./index-Text.js";
import { useContext as O } from "react";
import l from "./index-TableBody.module.scss.js";
const J = (x) => {
  const {
    provider: R = I,
    hasGreyBody: p
  } = x, b = O(R), {
    data: o,
    pagination: m
  } = b, {
    blurredCta: t,
    blurredMessage: c,
    collections: s = [],
    replacements: u,
    hideBlurredMessage: d
  } = o ?? {}, n = (o == null ? void 0 : o.columns) ?? [], f = (o == null ? void 0 : o.options) ?? {};
  m == null || m.limit;
  const C = s == null ? void 0 : s.filter((i) => !i.isBlurred), r = s == null ? void 0 : s.filter((i) => i.isBlurred).map((i) => i), T = n == null ? void 0 : n.length, B = 3;
  if (r.length > 0 && r.length < B && c)
    for (; r.length < B; )
      r.push({
        isBlurred: !0,
        [n[0].alias]: "",
        prefixForColumn: null
      });
  const N = (r == null ? void 0 : r.length) > 0;
  return h(w, {
    children: [e(y, {
      rows: C,
      columns: n,
      options: f,
      hideBlurred: d,
      hasGreyBody: p
    }), h(a, {
      if: N,
      children: [e("tbody", {
        className: g(l.tableBody, l.blurredTable),
        children: e(a, {
          if: !!c && !0 && !d,
          children: e("tr", {
            className: l.blurredMessageContainer,
            children: e("td", {
              className: g(F, v, M),
              colSpan: T,
              children: h("div", {
                className: l.blurredMessage,
                children: [e(W, {
                  replacements: u,
                  type: E.textIntro,
                  fontWeight: D.medium,
                  children: c
                }), e(a, {
                  if: !!t,
                  children: e(j, {
                    replacements: u,
                    onClick: t == null ? void 0 : t.cta,
                    iconRight: G.arrowRight,
                    children: t == null ? void 0 : t.text
                  })
                })]
              })
            })
          })
        })
      }), e(y, {
        rows: r,
        columns: n,
        options: f,
        hideBlurred: d,
        hasGreyBody: p
      })]
    })]
  });
};
export {
  J as TableBody
};
