import { __extends } from "tslib";
import { Component, forwardRef, Input, ChangeDetectionStrategy } from '@angular/core';
import { IgxRing } from "./igx-ring";
import { IgxRingSeriesBaseComponent } from "./igx-ring-series-base-component";
import { RingSeries } from "./RingSeries";
import { IgxIndexCollection } from "./igx-index-collection";
import { IndexCollection as IndexCollection_internal } from "./IndexCollection";
import { Number_$type } from "igniteui-angular-core";
import { SyncableObservableCollection$1 } from "igniteui-angular-core";
import * as i0 from "@angular/core";
/**
 * Represents one ring in
 * IgxDoughnutChartComponent series.
*/
var IgxRingSeriesComponent = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(IgxRingSeriesComponent, _super);
    function IgxRingSeriesComponent() {
        var _this = _super.call(this) || this;
        _this._explodedSlices = null;
        _this._selectedSlices = null;
        return _this;
    }
    IgxRingSeriesComponent.prototype.createImplementation = function () {
        return new RingSeries();
    };
    Object.defineProperty(IgxRingSeriesComponent.prototype, "i", {
        get: function () {
            return this._implementation;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IgxRingSeriesComponent.prototype, "explodedSlices", {
        /**
         * Gets or sets the collection of exploded slice indices.
        */
        get: function () {
            if (this._explodedSlices === null) {
                var coll = new IgxIndexCollection();
                var innerColl = void 0;
                if (this.ring.i.ringControl.arcs.count == 0) {
                    innerColl = new IndexCollection_internal();
                }
                else {
                    innerColl = this.ring.i.ringControl.arcs.item(0).explodedSlices;
                }
                this._explodedSlices = coll._fromInner(innerColl);
            }
            return this._explodedSlices;
        },
        set: function (v) {
            if (this._explodedSlices !== null) {
                this._explodedSlices._setSyncTarget(null);
                this._explodedSlices = null;
            }
            var coll = new IgxIndexCollection();
            this._explodedSlices = coll._fromOuter(v);
            var syncColl = new SyncableObservableCollection$1(Number_$type);
            var innerColl;
            if (this.ring.i.ringControl.arcs.count == 0) {
                innerColl = new IndexCollection_internal();
            }
            else {
                innerColl = this.ring.i.ringControl.arcs.item(0).explodedSlices;
            }
            syncColl._inner = innerColl;
            syncColl.clear();
            this._explodedSlices._setSyncTarget(syncColl);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IgxRingSeriesComponent.prototype, "selectedSlices", {
        /**
         * Gets or sets the collection of selected slice indices.
        */
        get: function () {
            if (this._selectedSlices === null) {
                var coll = new IgxIndexCollection();
                var innerColl = void 0;
                if (this.ring.i.ringControl.arcs.count == 0) {
                    innerColl = new IndexCollection_internal();
                }
                else {
                    innerColl = this.ring.i.ringControl.arcs.item(0).selectedSlices;
                }
                this._selectedSlices = coll._fromInner(innerColl);
            }
            return this._selectedSlices;
        },
        set: function (v) {
            if (this._selectedSlices !== null) {
                this._selectedSlices._setSyncTarget(null);
                this._selectedSlices = null;
            }
            var coll = new IgxIndexCollection();
            this._selectedSlices = coll._fromOuter(v);
            var syncColl = new SyncableObservableCollection$1(Number_$type);
            var innerColl;
            if (this.ring.i.ringControl.arcs.count == 0) {
                innerColl = new IndexCollection_internal();
            }
            else {
                innerColl = this.ring.i.ringControl.arcs.item(0).selectedSlices;
            }
            syncColl._inner = innerColl;
            syncColl.clear();
            this._selectedSlices._setSyncTarget(syncColl);
        },
        enumerable: false,
        configurable: true
    });
    IgxRingSeriesComponent.prototype.sychronizeCollections = function () {
        if (this._explodedSlices) {
            var inner = this._explodedSlices._inner;
            if (inner && inner !== this.ring.i.ringControl.arcs.item(0).explodedSlices) {
                this._explodedSlices._inner = this.ring.i.ringControl.arcs.item(0).explodedSlices;
                for (var i = 0; i < inner.count; i++) {
                    this._explodedSlices.add(inner.item(i));
                }
            }
        }
        if (this._selectedSlices) {
            var inner = this._selectedSlices._inner;
            if (inner && inner !== this.ring.i.ringControl.arcs.item(0).selectedSlices) {
                this._selectedSlices._inner = this.ring.i.ringControl.arcs.item(0).selectedSlices;
                for (var i = 0; i < inner.count; i++) {
                    this._selectedSlices.add(inner.item(i));
                }
            }
        }
    };
    Object.defineProperty(IgxRingSeriesComponent.prototype, "ring", {
        /**
     * Gets reference to the ring data.
    */
        get: function () {
            var r = this.i.eo;
            if (r == null) {
                return null;
            }
            if (!r.externalObject) {
                var e = new IgxRing();
                if (r.$type) {
                    e._implementation = r;
                }
                else {
                    if (e.i.setNativeElement) {
                        e.i.setNativeElement(r);
                    }
                }
                r.externalObject = e;
            }
            return r.externalObject;
        },
        set: function (v) {
            v == null ? this.i.eo = null : this.i.eo = v.i;
        },
        enumerable: false,
        configurable: true
    });
    IgxRingSeriesComponent.prototype.findByName = function (name) {
        var baseResult = _super.prototype.findByName.call(this, name);
        if (baseResult) {
            return baseResult;
        }
        if (this.ring && this.ring.name && this.ring.name == name) {
            return this.ring;
        }
        return null;
    };
    IgxRingSeriesComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.14", ngImport: i0, type: IgxRingSeriesComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
    IgxRingSeriesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.14", type: IgxRingSeriesComponent, selector: "igx-ring-series", inputs: { explodedSlices: "explodedSlices", selectedSlices: "selectedSlices", ring: "ring" }, providers: [{ provide: IgxRingSeriesBaseComponent, useExisting: forwardRef(function () { return IgxRingSeriesComponent; }) }], usesInheritance: true, ngImport: i0, template: "", isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
    return IgxRingSeriesComponent;
}(IgxRingSeriesBaseComponent));
export { IgxRingSeriesComponent };
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.14", ngImport: i0, type: IgxRingSeriesComponent, decorators: [{
            type: Component,
            args: [{
                    selector: 'igx-ring-series',
                    template: "",
                    providers: [{ provide: IgxRingSeriesBaseComponent, useExisting: forwardRef(function () { return IgxRingSeriesComponent; }) }],
                    changeDetection: ChangeDetectionStrategy.OnPush
                }]
        }], ctorParameters: function () { return []; }, propDecorators: { explodedSlices: [{
                type: Input
            }], selectedSlices: [{
                type: Input
            }], ring: [{
                type: Input
            }] } });
