/*!
 * Built by Revolist OU ❤️
 */
import { h } from "@stencil/core";
import { dispatch } from "../../plugins/dispatcher";
import { doPropMerge } from "../data/column.service";
import { ResizableElement, } from "./resizable.element";
export const ON_COLUMN_CLICK = 'columnclick';
export const HeaderCellRenderer = ({ data, props, additionalData }, children) => {
    let colTemplate = (data === null || data === void 0 ? void 0 : data.name) || '';
    let cellProps = props;
    if (data === null || data === void 0 ? void 0 : data.columnTemplate) {
        colTemplate = data.columnTemplate(h, data, additionalData);
    }
    if (data === null || data === void 0 ? void 0 : data.columnProperties) {
        const extra = data.columnProperties(data);
        if (extra) {
            cellProps = doPropMerge(props, extra);
        }
    }
    const resizeProps = Object.assign(Object.assign({}, cellProps), { onMouseDown(e) {
            dispatch(e.currentTarget, ON_COLUMN_CLICK, {
                data,
                event: e,
            });
        } });
    return (h(ResizableElement, Object.assign({}, resizeProps), h("div", { class: "header-content" }, colTemplate), children));
};
