import { jsxs as x, jsx as c } from "@emotion/react/jsx-runtime";
import q, { useMemo as B } from "react";
import { CardContentWrapperStyled as G, CardContentStyled as H, ListStyled as W } from "../../../../slots/DataGridSlot.js";
import { deepEqual as h } from "fast-equals";
import { useListContent as z } from "../../hooks/useListContent/useListContent.js";
import { ListHeader as F } from "./subcomponents/ListHeader/ListHeader.js";
import { getDefaultAction as J } from "../../../../helpers/shared/getDefaultAction/getDefaultAction.js";
import { useDataGrid as K } from "../../../../hooks/shared/useDataGrid/useDataGrid.js";
function N({
  row: t,
  rows: o,
  rowIndex: I,
  columns: y,
  originalColumns: O,
  rowKeyGetter: u,
  selectedRows: n,
  onSelectedRowsChange: l,
  onRowsChange: L,
  customRender: e,
  isChecked: r,
  showCheckbox: m,
  checkedRows: f,
  onCheckedRowsChange: p,
  onOpenDetail: M,
  showExpandButton: C = !0,
  onExpandClick: d
}) {
  const { rowActionsGetter: b } = K(), i = u(t), S = e !== void 0, { listContent: g } = z({
    row: t,
    rows: o,
    rowIndex: I,
    columns: y,
    onRowsChange: L
  }), k = B(() => S ? e.renderContent(t) : /* @__PURE__ */ x(G, { ownerState: {}, children: [
    /* @__PURE__ */ c(
      F,
      {
        row: t,
        onOpenDetail: M,
        isChecked: r,
        showCheckbox: m,
        checkedRows: f,
        onCheckedRowsChange: p,
        showExpandButton: C,
        onExpandClick: d
      }
    ),
    /* @__PURE__ */ c(H, { ownerState: {}, children: g })
  ] }), [
    S,
    e,
    t,
    g,
    r,
    m,
    f,
    p,
    C,
    d
  ]), D = (a) => {
    if (!a.target.closest(
      'input, button, a, [role="button"], .MuiCheckbox-root, .MuiIconButton-root'
    ) && n && l) {
      if (n.has(i))
        return;
      const s = /* @__PURE__ */ new Set([u(t)]);
      l(s);
    }
  }, A = (a) => {
    if (a.target.closest(
      'input, button, a, [role="button"], .MuiCheckbox-root, .MuiIconButton-root'
    ) || !b)
      return;
    const s = b(t), v = J(s);
    v?.onClick && v.onClick(t);
  };
  return /* @__PURE__ */ c(
    W,
    {
      variant: "outlined",
      ownerState: {
        selected: n?.has(i) ?? !1,
        checked: r
      },
      onClick: D,
      onDoubleClick: A,
      "data-testid": "list-row",
      "data-row-key": i,
      children: k
    }
  );
}
const _ = q.memo(N, (t, o) => h(t, o));
export {
  _ as ListRow
};
