'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const core = require('./core-b7b9d752.js');
require('./utils-2a7c8f6e.js');
const column_renderer = require('./column.renderer-62044f6a.js');

const RenderCell = class {
    constructor(hostRef) {
        core.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 = core.createEvent(this, "anjCellControlDidLoad", 7);
    }
    componentDidLoad() {
        this.anjCellControlDidLoad.emit();
    }
    renderCell({ column, columnIndex, classList, offset, renderer, row, rowIndex }) {
        const attrs = column_renderer.ColumnRenderer.columnAttributes(column, columnIndex, row);
        const refFn = r => column.initCell(r, offset);
        if (this.template) {
            return core.h("td", Object.assign({}, attrs, { class: classList, ref: r => renderer.cellTemplate(r, offset, column, row, rowIndex, this.template) }));
        }
        else if (this.formatter) {
            return core.h("td", Object.assign({}, attrs, { class: classList, innerHTML: this.formatter(row, column, rowIndex), ref: refFn }));
        }
        else {
            return core.h("td", Object.assign({}, attrs, { class: classList, ref: refFn }), this.renderer(row, column, rowIndex));
        }
    }
};

exports.anj_render_cell = RenderCell;
