import { DataSourceSchemaPropertyType_$type } from "igniteui-webcomponents-core";
import { IgcGridFilterDialogViewModelGroupingLevelCollection } from "./igc-grid-filter-dialog-view-model-grouping-level-collection";
import { IgcGridFilterDialogViewModelRowCollection } from "./igc-grid-filter-dialog-view-model-row-collection";
import { GridFilterDialogViewModel as GridFilterDialogViewModel_internal } from "./GridFilterDialogViewModel";
import { ensureEnum, ensureBool } from "igniteui-webcomponents-core";
import { GridFilterDialogViewModelGroupingLevelCollection as GridFilterDialogViewModelGroupingLevelCollection_internal } from "./GridFilterDialogViewModelGroupingLevelCollection";
import { GridFilterDialogViewModelGroupingLevel } from "./GridFilterDialogViewModelGroupingLevel";
import { SyncableObservableCollection$1 } from "igniteui-webcomponents-core";
import { GridFilterDialogViewModelRowCollection as GridFilterDialogViewModelRowCollection_internal } from "./GridFilterDialogViewModelRowCollection";
import { GridFilterDialogViewModelRow } from "./GridFilterDialogViewModelRow";
export class IgcGridFilterDialogViewModel {
    constructor() {
        this._groupingLevels = null;
        this._rows = null;
        this._implementation = this.createImplementation();
        this._implementation.externalObject = this;
        this.onImplementationCreated();
    }
    createImplementation() {
        return new GridFilterDialogViewModel_internal();
    }
    /**
     * @hidden
     */
    get i() {
        return this._implementation;
    }
    onImplementationCreated() {
    }
    _provideImplementation(i) {
        this._implementation = i;
        this._implementation.externalObject = this;
        this.onImplementationCreated();
    }
    get propertyType() {
        return this.i.a;
    }
    set propertyType(v) {
        this.i.a = ensureEnum(DataSourceSchemaPropertyType_$type, v);
    }
    get groupingLevels() {
        if (this._groupingLevels === null) {
            let coll = new IgcGridFilterDialogViewModelGroupingLevelCollection();
            let innerColl = this.i.e;
            if (!innerColl) {
                innerColl = new GridFilterDialogViewModelGroupingLevelCollection_internal();
            }
            this._groupingLevels = coll._fromInner(innerColl);
            this.i.e = innerColl;
        }
        return this._groupingLevels;
    }
    set groupingLevels(v) {
        if (this._groupingLevels !== null) {
            this._groupingLevels._setSyncTarget(null);
            this._groupingLevels = null;
        }
        let coll = new IgcGridFilterDialogViewModelGroupingLevelCollection();
        this._groupingLevels = coll._fromOuter(v);
        let syncColl = new SyncableObservableCollection$1(GridFilterDialogViewModelGroupingLevel.$type);
        let innerColl = this.i.e;
        if (!innerColl) {
            innerColl = new GridFilterDialogViewModelGroupingLevelCollection_internal();
        }
        syncColl._inner = innerColl;
        syncColl.clear();
        this._groupingLevels._setSyncTarget(syncColl);
        this.i.e = innerColl;
    }
    get isTopLevelOr() {
        return this.i.k;
    }
    set isTopLevelOr(v) {
        this.i.k = ensureBool(v);
    }
    get maxGroupingLevels() {
        return this.i.m;
    }
    set maxGroupingLevels(v) {
        this.i.m = +v;
    }
    get rows() {
        if (this._rows === null) {
            let coll = new IgcGridFilterDialogViewModelRowCollection();
            let innerColl = this.i.f;
            if (!innerColl) {
                innerColl = new GridFilterDialogViewModelRowCollection_internal();
            }
            this._rows = coll._fromInner(innerColl);
            this.i.f = innerColl;
        }
        return this._rows;
    }
    set rows(v) {
        if (this._rows !== null) {
            this._rows._setSyncTarget(null);
            this._rows = null;
        }
        let coll = new IgcGridFilterDialogViewModelRowCollection();
        this._rows = coll._fromOuter(v);
        let syncColl = new SyncableObservableCollection$1(GridFilterDialogViewModelRow.$type);
        let innerColl = this.i.f;
        if (!innerColl) {
            innerColl = new GridFilterDialogViewModelRowCollection_internal();
        }
        syncColl._inner = innerColl;
        syncColl.clear();
        this._rows._setSyncTarget(syncColl);
        this.i.f = innerColl;
    }
    findByName(name) {
        if (this.rows != null && this.rows.findByName && this.rows.findByName(name)) {
            return this.rows.findByName(name);
        }
        return null;
    }
    addNewRow() {
        this.i.n();
    }
    canGroupRange(startIndex, endIndex) {
        let iv = this.i.h(startIndex, endIndex);
        return (iv);
    }
    ungroupRange(startIndex, endIndex) {
        this.i.aa(startIndex, endIndex);
    }
    targetingRange(startIndex, endIndex) {
        let iv = this.i.l(startIndex, endIndex);
        return (iv);
    }
    toggleRange(startIndex, endIndex) {
        this.i.z(startIndex, endIndex);
    }
    groupRange(startIndex, endIndex, isOrGrouping) {
        this.i.o(startIndex, endIndex, isOrGrouping);
    }
}
//# sourceMappingURL=igc-grid-filter-dialog-view-model.js.map
