import { ensureBool } from "igniteui-angular-core";
import { IgxChartSummaryDescription } from "./igx-chart-summary-description";
import { ChartSummaryDescriptionCollection as ChartSummaryDescriptionCollection_internal } from "./ChartSummaryDescriptionCollection";
export class IgxChartSummaryDescriptionCollection {
    constructor() {
        this._implementation = this.createImplementation();
        this._implementation.externalObject = this;
        this.onImplementationCreated();
    }
    createImplementation() {
        return new ChartSummaryDescriptionCollection_internal();
    }
    get i() {
        return this._implementation;
    }
    onImplementationCreated() {
    }
    _provideImplementation(i) {
        this._implementation = i;
        this._implementation.externalObject = this;
        this.onImplementationCreated();
    }
    item(index, value) {
        let int = null;
        if (value !== undefined) {
            int = this.i.set(index, value == null ? null : value.i);
        }
        else {
            int = this.i.get(index);
        }
        let ext = null;
        if (int != null) {
            ext = int.externalObject;
            if (!ext) {
                ext = new IgxChartSummaryDescription();
                ext._implementation = int;
                int.externalObject = ext;
            }
        }
        return ext;
    }
    get count() {
        return this.i.size();
    }
    toArray() {
        let arr = [];
        for (let i = 0; i < this.count; i++) {
            arr[i] = this.item(i);
        }
        return arr;
    }
    *[Symbol.iterator]() {
        for (let i = 0; i < this.count; i++) {
            let item = this.item(i);
            if (item.externalObject) {
                item = item.externalObject;
            }
            yield item;
        }
    }
    /**
 * Gets or sets whether this collection should detach the sync when the target collection changes.
*/
    get shouldDetachOnTargetChange() {
        return this.i.i;
    }
    set shouldDetachOnTargetChange(v) {
        this.i.i = ensureBool(v);
    }
    findByName(name) {
        if (this.findEphemera) {
            if (name && name.indexOf("@@e:") == 0) {
                return this.findEphemera(name);
            }
        }
        return null;
    }
    add(item) {
        let iv = this.i.g((item == null ? null : item.i));
        return (iv);
    }
    insert(index, item) {
        this.i.o(index, (item == null ? null : item.i));
    }
    clear() {
        this.i.n();
    }
    indexOf(item) {
        let iv = this.i.k((item == null ? null : item.i));
        return (iv);
    }
    remove(item) {
        let iv = this.i.h((item == null ? null : item.i));
        return (iv);
    }
    removeAt(index) {
        let iv = this.i.b(index);
        let ret = null;
        if (iv && iv.externalObject) {
            ret = iv.externalObject;
        }
        else {
            if (iv) {
                let e = new IgxChartSummaryDescription();
                e._implementation = iv;
                iv.externalObject = e;
                ret = e;
            }
        }
        return ret;
    }
}
