/*!
 * Copyright (c) Microsoft. All rights reserved.
 * Licensed under the MIT license. See LICENSE file in the project.
 */ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
import { CommandBarContainer } from './CommandBarContainer.js';
import { DefaultColumnHeader } from './DefaultColumnHeader.js';
import { FeaturesCell } from './FeaturesCell.js';
import { HistogramColumnHeader } from './HistogramColumnHeader.js';
import { SmartCell, StatsColumnHeader } from './index.js';
export const createRenderSmartCell = (field, color, onColumnClick, onCellDropdownSelect)=>function renderSmartCell(item, index, column) {
        return /*#__PURE__*/ _jsx(SmartCell, {
            item: item,
            index: index,
            column: column,
            field: field,
            color: color,
            onColumnClick: onColumnClick,
            onCellDropdownSelect: onCellDropdownSelect
        });
    };
export const createRenderFeaturesCell = (features, field, color, onColumnClick, onCellDropdownSelect)=>function renderDropdownCell(item, index, column) {
        return /*#__PURE__*/ _jsx(FeaturesCell, {
            index: index || 0,
            item: item,
            column: column,
            onCellDropdownSelect: onCellDropdownSelect,
            onColumnClick: onColumnClick,
            field: field,
            color: color,
            features: features
        });
    };
export const createRenderColumnHeader = (renderers)=>function renderColumnHeader(props, defaultRender) {
        if (!props || !defaultRender) {
            return null;
        }
        return /*#__PURE__*/ _jsx(_Fragment, {
            children: renderers.map((renderer, i)=>renderer({
                    key: `renderer-${props.column.key}${i}`,
                    ...props
                }, defaultRender))
        });
    };
/**
 * Establish our own default rendering for column headers.
 * This gives us full control over the layout so we can cleanly
 * handle the default while also stacking in advanced render features.
 * @returns
 */ export const createRenderDefaultColumnHeader = (originalProps, isClickable, isSortable, onColumnHeaderClick, onSort)=>function renderDefaultColumnHeader(props, defaultRender) {
        if (!props || !defaultRender) {
            return null;
        }
        const p = fixProps(originalProps, props);
        return /*#__PURE__*/ _jsx(DefaultColumnHeader, {
            ...p,
            isClickable: isClickable,
            isSortable: isSortable,
            onClick: onColumnHeaderClick,
            onSort: onSort
        });
    };
export const createRenderStatsColumnHeader = (field, onClick, stats)=>{
    return function renderStatsColumnHeader(props, defaultRender) {
        if (!props || !defaultRender) {
            return null;
        }
        return /*#__PURE__*/ _jsx(StatsColumnHeader, {
            onClick: onClick,
            field: field,
            stats: stats,
            ...props
        });
    };
};
export const createRenderCommandBarColumnHeader = (renderers)=>{
    return function renderCommandBarColumnHeader(props, defaultRender) {
        if (!props || !defaultRender) {
            return null;
        }
        return /*#__PURE__*/ _jsx(CommandBarContainer, {
            props: props,
            renderers: renderers
        }, props.key);
    };
};
export const createRenderHistogramColumnHeader = (field, color, onClick)=>{
    return function renderHistogramColumnHeader(props, defaultRender) {
        if (!props || !defaultRender) {
            return null;
        }
        return /*#__PURE__*/ _jsx(HistogramColumnHeader, {
            onClick: onClick,
            field: field,
            color: color,
            ...props
        });
    };
};
function fixProps(original, updated) {
    const iconName = original?.iconName;
    if (iconName) {
        return {
            ...updated,
            column: {
                ...updated.column,
                iconName
            }
        };
    }
    return updated;
}
