import { jsx as o } from "react/jsx-runtime";
import { useReducedMotion as O, motion as u } from "motion/react";
import { useState as g, useMemo as R } from "react";
import C from "../../utils/classNames.js";
import { useOptionalTableInteractionContext as N } from "./context/TableInteractionContext.js";
import { useOptionalTableSection as v, useTableBodyContext as A } from "./context/TableStructureContext.js";
import { useOptionalTableRenderContext as T } from "./context/TableRenderContext.js";
const t = 0.22, U = (m) => {
  const { children: p, className: x, noHover: w, parentKey: i, ...h } = m, e = T(), a = N(), b = v(), r = A(), [y, s] = g(!0), l = O(), n = R(
    () => l ? {
      row: {
        initial: { opacity: 0 },
        animate: {
          opacity: 1,
          transition: { duration: t, ease: "easeInOut" }
        },
        exit: {
          opacity: 0,
          transition: { duration: t, ease: "easeInOut" }
        }
      },
      content: {
        initial: { opacity: 0 },
        animate: {
          opacity: 1,
          transition: { duration: t, ease: "easeInOut" }
        },
        exit: {
          opacity: 0,
          transition: { duration: t, ease: "easeInOut" }
        }
      }
    } : {
      row: {
        initial: { height: 0 },
        animate: {
          height: "auto",
          transition: { duration: t, ease: "easeInOut" }
        },
        exit: {
          height: 0,
          transition: { duration: t, ease: "easeInOut" }
        }
      },
      content: {
        initial: { opacity: 0 },
        animate: {
          opacity: 1,
          transition: {
            duration: t * 0.65,
            delay: t,
            ease: "easeOut"
          }
        },
        exit: {
          opacity: 0,
          transition: {
            duration: t * 0.65,
            ease: "easeInOut"
          }
        }
      }
    },
    [l]
  );
  if (!e || !a || e.columns.length === 0 || b !== "body" || !r)
    return null;
  const d = r.nextRowIndex(), f = e.columns.length + (a.showSelectionColumn ? 1 : 0), I = `expanded-content-${String(i)}`, c = /* @__PURE__ */ o(
    u.div,
    {
      ...h,
      className: C(
        "table-row table-row-expanded-full-width",
        w && "table-row-no-hover",
        x
      ),
      "data-index": d,
      "data-parent-row-id": String(i),
      role: "row",
      initial: n.row.initial,
      animate: n.row.animate,
      exit: n.row.exit,
      onAnimationStart: () => s(!0),
      onAnimationComplete: () => s(!1),
      style: {
        overflow: y ? "hidden" : "visible"
      },
      children: /* @__PURE__ */ o("div", { className: "table-cell table-expanded-cell", role: "cell", "aria-colspan": f, children: /* @__PURE__ */ o(
        u.div,
        {
          className: "table-cell-content",
          initial: n.content.initial,
          animate: n.content.animate,
          exit: n.content.exit,
          children: p
        }
      ) })
    }
  );
  return e.renderDraft.hasExpandableRows = !0, e.renderDraft.bodyRows.push({
    rowId: I,
    rowIndex: d,
    kind: "expanded-full-width",
    render: () => c
  }), e.isRegisteringBodyRows ? null : c;
};
export {
  U as default
};
//# sourceMappingURL=TableExpandedContentRow.js.map
