import { r as registerInstance, d as createEvent, h } from './core-3f33e631.js';
import './utils-3aef1637.js';
import { C as ColumnRenderer } from './column.renderer-b9656ad4.js';

const RenderCell = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        /**
         * Renderer to use for cell content when the selected cell conditions are met
         * (row: RowData, field: ColumnDefinition, rowIndex?: number) => any;
         */
        this.cell = this.renderCell.bind(this);
        /**
         * Test function for when to use this renderer
         * (column: ColumnDefinition, rowIndex: number, columnIndex: number) => boolean;
         */
        this.when = () => true;
        this.anjCellControlDidLoad = createEvent(this, "anjCellControlDidLoad", 7);
    }
    componentDidLoad() {
        this.anjCellControlDidLoad.emit();
    }
    renderCell({ column, columnIndex, classList, offset, renderer, row, rowIndex }) {
        const attrs = ColumnRenderer.columnAttributes(column, columnIndex, row);
        const refFn = r => column.initCell(r, offset);
        if (this.template) {
            return h("td", Object.assign({}, attrs, { class: classList, ref: r => renderer.cellTemplate(r, offset, column, row, rowIndex, this.template) }));
        }
        else if (this.formatter) {
            return h("td", Object.assign({}, attrs, { class: classList, innerHTML: this.formatter(row, column, rowIndex), ref: refFn }));
        }
        else {
            return h("td", Object.assign({}, attrs, { class: classList, ref: refFn }), this.renderer(row, column, rowIndex));
        }
    }
};

export { RenderCell as anj_render_cell };
