'use client';
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
import React from 'react';
import './index.scss';
const baseClass = 'table';
export const Table = ({ appearance, BeforeTable, columns, data })=>{
    const activeColumns = columns?.filter((col)=>col?.active);
    if (!activeColumns || activeColumns.length === 0) {
        return /*#__PURE__*/ _jsxDEV("div", {
            children: "No columns selected"
        }, void 0, false, {
            fileName: "src/elements/Table/index.tsx",
            lineNumber: 22,
            columnNumber: 12
        }, this);
    }
    return /*#__PURE__*/ _jsxDEV("div", {
        className: [
            baseClass,
            appearance && `${baseClass}--appearance-${appearance}`
        ].filter(Boolean).join(' '),
        children: [
            BeforeTable,
            /*#__PURE__*/ _jsxDEV("table", {
                cellPadding: "0",
                cellSpacing: "0",
                children: [
                    /*#__PURE__*/ _jsxDEV("thead", {
                        children: /*#__PURE__*/ _jsxDEV("tr", {
                            children: activeColumns.map((col, i)=>/*#__PURE__*/ _jsxDEV("th", {
                                    id: `heading-${col.accessor.replace(/\./g, '__')}`,
                                    children: col.Heading
                                }, i, false, {
                                    fileName: "src/elements/Table/index.tsx",
                                    lineNumber: 36,
                                    columnNumber: 15
                                }, this))
                        }, void 0, false, {
                            fileName: "src/elements/Table/index.tsx",
                            lineNumber: 34,
                            columnNumber: 11
                        }, this)
                    }, void 0, false, {
                        fileName: "src/elements/Table/index.tsx",
                        lineNumber: 33,
                        columnNumber: 9
                    }, this),
                    /*#__PURE__*/ _jsxDEV("tbody", {
                        children: data && data?.map((row, rowIndex)=>{
                            return /*#__PURE__*/ _jsxDEV("tr", {
                                className: `row-${rowIndex + 1}`,
                                "data-id": row.id,
                                children: activeColumns.map((col, colIndex)=>{
                                    const { accessor } = col;
                                    return /*#__PURE__*/ _jsxDEV("td", {
                                        className: `cell-${accessor.replace(/\./g, '__')}`,
                                        children: col.renderedCells[rowIndex]
                                    }, colIndex, false, {
                                        fileName: "src/elements/Table/index.tsx",
                                        lineNumber: 59,
                                        columnNumber: 23
                                    }, this);
                                })
                            }, typeof row.id === 'string' || typeof row.id === 'number' ? String(row.id) : rowIndex, false, {
                                fileName: "src/elements/Table/index.tsx",
                                lineNumber: 46,
                                columnNumber: 17
                            }, this);
                        })
                    }, void 0, false, {
                        fileName: "src/elements/Table/index.tsx",
                        lineNumber: 42,
                        columnNumber: 9
                    }, this)
                ]
            }, void 0, true, {
                fileName: "src/elements/Table/index.tsx",
                lineNumber: 32,
                columnNumber: 7
            }, this)
        ]
    }, void 0, true, {
        fileName: "src/elements/Table/index.tsx",
        lineNumber: 26,
        columnNumber: 5
    }, this);
};

//# sourceMappingURL=index.js.map