import { jsx } from "react/jsx-runtime";
import { Table, TableCell, TableHead, TableRow } from "@mui/material";
import apollo_core from "@uipath/apollo-core";
import react from "react";
import { ApTypography } from "../../../../ap-typography/index.js";
import { useChatState } from "../../../providers/chat-state-provider.js";
import { Text } from "./text.js";
const table_Table = /*#__PURE__*/ react.memo(({ children })=>/*#__PURE__*/ jsx(Table, {
        sx: {
            border: "1px solid var(--color-border-de-emp)",
            borderRadius: apollo_core.Border.BorderRadiusL,
            borderCollapse: 'separate',
            borderSpacing: 0,
            '& td, & th': {
                border: 'unset',
                borderBottom: "1px solid var(--color-border-de-emp)"
            },
            '& tr:last-child td': {
                borderBottom: 'unset'
            },
            '& .MuiTableHead-root th:first-of-type': {
                borderTopLeftRadius: apollo_core.Border.BorderRadiusL
            },
            '& .MuiTableHead-root th:last-of-type': {
                borderTopRightRadius: apollo_core.Border.BorderRadiusL
            }
        },
        children: children
    }));
const TableHeader = /*#__PURE__*/ react.memo(({ children })=>/*#__PURE__*/ jsx(TableHead, {
        sx: {
            backgroundColor: 'var(--color-background-secondary)'
        },
        children: children
    }));
const Row = /*#__PURE__*/ react.memo(({ children })=>/*#__PURE__*/ jsx(TableRow, {
        children: children
    }));
const Cell = /*#__PURE__*/ react.memo(({ children })=>{
    const { spacing } = useChatState();
    return /*#__PURE__*/ jsx(TableCell, {
        children: react.Children.map(children, (child)=>{
            if ('string' == typeof child) {
                const trimmedString = child.trim();
                const hasVisibleContent = trimmedString.length > 0;
                if (!hasVisibleContent) return null;
                return Text({
                    children: trimmedString.replace(/<br\s*\/?>/gi, '\n'),
                    customStyle: {
                        display: 'inline'
                    },
                    variant: spacing.markdownTokens.td
                });
            }
            return child;
        })
    });
});
const HeaderCell = /*#__PURE__*/ react.memo(({ children })=>{
    const { spacing } = useChatState();
    return /*#__PURE__*/ jsx(TableCell, {
        children: /*#__PURE__*/ jsx(ApTypography, {
            variant: spacing.markdownTokens.th,
            color: 'var(--color-foreground)',
            children: children
        })
    });
});
export { Cell, HeaderCell, Row, table_Table as Table, TableHeader };
