export class NativeRenderer {
    cellTemplate(cell, offset, col, row, rowIndex, template) {
        if (!cell || rowIndex === undefined) {
            return;
        }
        this.fromTemplate(template, cell, row, rowIndex);
        col.initCell(cell, offset);
    }
    // No different in vanilla/native, but there is in Angular
    rowTemplate(template, targetEl, row, rowIndex) {
        return this.fromTemplate(template, targetEl, row, rowIndex);
    }
    fromTemplate(template, targetEl, row, rowIndex) {
        if (!template || !targetEl || rowIndex === undefined) {
            return;
        }
        targetEl.innerHTML = fromTemplate(template, row);
    }
}
const fromTemplate = (template, row) => {
    const parts = template.split(/\${(.*?)}/g);
    return parts.reduce((total = '', part) => {
        part = template.includes('\${' + part + '}') ? getValue(row, part.replace('row.', '')) : part;
        return total + part;
    });
};
const getValue = (obj, keys) => {
    const parts = Array.isArray(keys) ? keys : keys.split('.');
    return keys.length === 0 ? obj : getValue(obj[parts[0]], parts.slice(1));
};
