import React from 'react';
import { Box, makeStyles, TableCell, useTheme, Tooltip } from '@material-ui/core';
import { DateTime } from 'luxon';
import { UnityFluentIcon } from '../../../../utilities/iconLibrary/UnityFluentIcon';
import { getIconFromName } from '../../../../utilities/tree/TreeUtilities';
import { StatusChip } from '../../status/StatusChip';
import clsx from 'clsx';
const useStyles = makeStyles((theme) => ({
    labelText: {
        color: theme.palette.text.primary,
        fontSize: '12px',
    },
    tableCell: {
        fontSize: '12px',
        letterSpacing: '0.4px',
        fontWeight: (props) => ((props === null || props === void 0 ? void 0 : props.bold) ? 500 : 400),
    },
    unityIconWrapper: {
        gap: theme.spacing(1),
    },
}));
const CellUnityIcon = (props) => {
    const theme = useTheme();
    const { icon = '', size = 'large', color = theme.palette.primary.main, children } = props;
    const classes = useStyles(props);
    return (React.createElement(FluentCell, Object.assign({}, props), React.createElement(Box, { display: "flex", alignItems: "center", className: classes.unityIconWrapper }, React.createElement(UnityFluentIcon, { size: size, color: color, icon: getIconFromName(icon) }), children && children)));
};
const CellImage = (props) => (React.createElement(FluentCell, Object.assign({}, props), React.createElement("img", { src: props === null || props === void 0 ? void 0 : props.src, alt: props === null || props === void 0 ? void 0 : props.alt, style: props === null || props === void 0 ? void 0 : props.style }), props === null || props === void 0 ? void 0 : props.title));
const CellIcon = (props) => (React.createElement(FluentCell, Object.assign({}, props), React.createElement(React.Fragment, null, (props === null || props === void 0 ? void 0 : props.label) ? (
// @ts-ignore
React.createElement(Box, { display: "flex", alignItems: "center", style: { gap: '8px' } }, React.createElement(Box, null, props === null || props === void 0 ? void 0 : props.icon), props === null || props === void 0 ? void 0 : props.label)) : (props === null || props === void 0 ? void 0 : props.icon), props === null || props === void 0 ? void 0 : props.children)));
const CellNumber = (props) => {
    var _a;
    return (React.createElement(FluentCell, Object.assign({}, props), Number(props === null || props === void 0 ? void 0 : props.children).toFixed(Number((_a = props === null || props === void 0 ? void 0 : props.decimals) !== null && _a !== void 0 ? _a : 2))));
};
const CellDate = (props) => (React.createElement(FluentCell, Object.assign({}, props), DateTime.fromJSDate(new Date(props === null || props === void 0 ? void 0 : props.children)).toFormat((props === null || props === void 0 ? void 0 : props.format) || 'MM/dd/yyyy')));
const CellCurrency = (props) => (React.createElement(FluentCell, Object.assign({}, props), (props === null || props === void 0 ? void 0 : props.currencySymbol) || '$', props === null || props === void 0 ? void 0 : props.children));
const CellText = (props) => React.createElement(FluentCell, Object.assign({}, props), props.children);
const CellChip = (props) => (React.createElement(FluentCell, Object.assign({}, props), React.createElement(StatusChip, { status: (props === null || props === void 0 ? void 0 : props.status) || 'success', label: props === null || props === void 0 ? void 0 : props.children })));
const FluentCell = (props) => {
    const classes = useStyles(props);
    const { scope = 'row', style, align, colSpan, className, tooltip, children } = props;
    const cellContent = children;
    return (React.createElement(TableCell, { scope: scope, className: clsx(classes.tableCell, className), style: style, align: align, colSpan: colSpan }, tooltip ? (React.createElement(Tooltip, { title: tooltip || '', children: React.createElement("span", null, cellContent || '') })) : (cellContent)));
};
FluentCell.UnityIcon = CellUnityIcon;
FluentCell.Icon = CellIcon;
FluentCell.Number = CellNumber;
FluentCell.Text = CellText;
FluentCell.Currency = CellCurrency;
FluentCell.Date = CellDate;
FluentCell.Chip = CellChip;
FluentCell.Image = CellImage;
export default FluentCell;
//# sourceMappingURL=index.js.map