import { Component, EventEmitter, HostBinding, Input, Output } from '@angular/core';
import { TableService } from '@ironsource/fusion-ui/components/table/common/services';
import * as i0 from "@angular/core";
import * as i1 from "@ironsource/fusion-ui/components/table/common/services";
import * as i2 from "@angular/common";
import * as i3 from "../table-cell/table-cell.component";
const _c0 = ["fusionTableRowGrouped", ""];
const _c1 = (a0, a1) => ({ x: a0, y: a1 });
function TableRowGroupedComponent_td_0_Template(rf, ctx) { if (rf & 1) {
    const _r5 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "td", 1);
    i0.ɵɵlistener("remove", function TableRowGroupedComponent_td_0_Template_td_remove_0_listener() { i0.ɵɵrestoreView(_r5); const ctx_r4 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r4.rowRemoved.emit()); })("selectedChange", function TableRowGroupedComponent_td_0_Template_td_selectedChange_0_listener($event) { i0.ɵɵrestoreView(_r5); const ctx_r6 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r6.onRowSelectedChange($event)); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const cell_r1 = ctx.$implicit;
    const cellIndex_r2 = ctx.index;
    const isLast_r3 = ctx.last;
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵstyleProp("width", ctx_r0.tableService.getWidth(ctx_r0.columns, ctx_r0.columns[ctx_r0.getColumnIndex(ctx_r0.row.data, cellIndex_r2)]));
    i0.ɵɵproperty("data", ctx_r0.getCellValue(cell_r1, ctx_r0.columns[ctx_r0.getColumnIndex(ctx_r0.row.data, cellIndex_r2)]))("column", ctx_r0.columns[ctx_r0.getColumnIndex(ctx_r0.row.data, cellIndex_r2)])("position", i0.ɵɵpureFunction2(8, _c1, ctx_r0.rowIndex, cellIndex_r2))("options", ctx_r0.options)("isRemove", ctx_r0.tableService.isRemove(isLast_r3, ctx_r0.options, ctx_r0.row.options));
    i0.ɵɵattribute("rowspan", ctx_r0.getCellRowspan(cell_r1));
} }
export class TableRowGroupedComponent {
    constructor(tableService) {
        this.tableService = tableService;
        this.rowRemoved = new EventEmitter();
        this.selectedChanged = new EventEmitter();
        this.isRowSelected = false;
    }
    getCellRowspan(cell) {
        return typeof cell === 'object' && cell ? cell.rowspan : undefined;
    }
    getCellValue(cell, column) {
        if (!cell) {
            return cell;
        }
        else if (typeof cell !== 'object') {
            return cell;
        }
        else if (this.tableService.isTypeComponent(column)) {
            return cell.value ? cell.value : cell;
        }
        else {
            return cell.value;
        }
    }
    getColumnIndex(row, cellIndex) {
        return this.columns.length - row.length + cellIndex;
    }
    onRowSelectedChange(value) {
        this.selectedChanged.emit(value);
        this.isRowSelected = value;
    }
    static { this.ɵfac = function TableRowGroupedComponent_Factory(t) { return new (t || TableRowGroupedComponent)(i0.ɵɵdirectiveInject(i1.TableService)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: TableRowGroupedComponent, selectors: [["", "fusionTableRowGrouped", ""]], hostVars: 2, hostBindings: function TableRowGroupedComponent_HostBindings(rf, ctx) { if (rf & 2) {
            i0.ɵɵclassProp("is-selected", ctx.isRowSelected);
        } }, inputs: { row: "row", columns: "columns", rowIndex: "rowIndex", options: "options" }, outputs: { rowRemoved: "rowRemoved", selectedChanged: "selectedChanged" }, attrs: _c0, decls: 1, vars: 1, consts: [["fusionTableCell", "", 3, "data", "column", "position", "options", "isRemove", "width", "remove", "selectedChange", 4, "ngFor", "ngForOf"], ["fusionTableCell", "", 3, "data", "column", "position", "options", "isRemove", "remove", "selectedChange"]], template: function TableRowGroupedComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, TableRowGroupedComponent_td_0_Template, 1, 11, "td", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngForOf", ctx.row.data);
        } }, dependencies: [i2.NgForOf, i3.TableCellComponent], styles: ["[_nghost-%COMP%]:hover{background-color:var(--light-color-200, #F3F5F7)}.is-selected[_nghost-%COMP%]{background-color:var(--primary-color-100, #F3F9FF)}.is-row-disabled[_nghost-%COMP%]   td[_ngcontent-%COMP%]{color:var(--light-color-800, #678099);pointer-events:none}.is-row-disabled[_nghost-%COMP%]   td[_ngcontent-%COMP%]   fusion-icon[_ngcontent-%COMP%]{opacity:.6}"] }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TableRowGroupedComponent, [{
        type: Component,
        args: [{ selector: '[fusionTableRowGrouped]', template: "<td *ngFor=\"let cell of row.data; let cellIndex = index; let isLast = last\"\n    [attr.rowspan]=\"getCellRowspan(cell)\"\n    fusionTableCell\n    [data]=\"getCellValue(cell, columns[getColumnIndex(row.data, cellIndex)])\"\n    [column]=\"columns[getColumnIndex(row.data, cellIndex)]\"\n    [position]=\"{x: rowIndex, y: cellIndex}\"\n    [options]=\"options\"\n    [isRemove]=\"tableService.isRemove(isLast, options, row.options)\"\n    (remove)=\"rowRemoved.emit()\"\n    (selectedChange)=\"onRowSelectedChange($event)\"\n    [style.width]=\"tableService.getWidth(columns, columns[getColumnIndex(row.data, cellIndex)])\"\n>\n</td>\n", styles: [":host:hover{background-color:var(--light-color-200, #F3F5F7)}:host.is-selected{background-color:var(--primary-color-100, #F3F9FF)}:host.is-row-disabled td{color:var(--light-color-800, #678099);pointer-events:none}:host.is-row-disabled td fusion-icon{opacity:.6}\n"] }]
    }], () => [{ type: i1.TableService }], { row: [{
            type: Input
        }], columns: [{
            type: Input
        }], rowIndex: [{
            type: Input
        }], options: [{
            type: Input
        }], rowRemoved: [{
            type: Output
        }], selectedChanged: [{
            type: Output
        }], isRowSelected: [{
            type: HostBinding,
            args: ['class.is-selected']
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(TableRowGroupedComponent, { className: "TableRowGroupedComponent", filePath: "components/table-row-grouped/table-row-grouped.component.ts", lineNumber: 10 }); })();
//# sourceMappingURL=data:application/json;base64, 