/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { ScatterBase } from "./ScatterBase";
import { DependencyProperty } from "igniteui-angular-core";
import { Point_$type, typeCast, markType, markDep } from "igniteui-angular-core";
import { ScatterFrame } from "./ScatterFrame";
import { ScatterSplineSeriesView } from "./ScatterSplineSeriesView";
import { Clipper } from "igniteui-angular-core";
import { OwnedPoint } from "./OwnedPoint";
import { ScalerParams } from "./ScalerParams";
import { PathGeometry } from "igniteui-angular-core";
import { Numeric } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
/**
 * @hidden
 */
export class ScatterSplineSeries extends ScatterBase {
    constructor() {
        super();
        this.ab = ScatterSplineSeries.$;
        this.m9 = new ScatterFrame();
        this.nb = new ScatterFrame();
        this.m8 = new ScatterFrame();
    }
    bf() {
        return new ScatterSplineSeriesView(this);
    }
    iz(a, b, c, d) {
        super.iz(a, b, c, d);
        switch (b) {
            case ScatterSplineSeries.$$p[0]:
                this.jd(false);
                this.ik();
                break;
        }
    }
    bd() {
        if (this.be == 0) {
            return 2;
        }
        else {
            return super.bd();
        }
    }
    n2(a, b) {
        super.n2(a, b);
        a.m.clear();
        a.u.clear();
        let c = b.bs;
        let d = b.br;
        let e = this.getEffectiveViewport1(b);
        let f = this.eu * this.eu;
        let g = Math.min(this.nd != null ? this.nd.count : 0, this.nf != null ? this.nf.count : 0);
        let h = new ScalerParams(0, c, d, this.m4.d, e);
        let i = ((() => {
            let $ret = new ScalerParams(0, c, d, this.m4.e, e);
            $ret.b = this.eh();
            return $ret;
        })());
        let j = (k) => this.m4.a.dw(this.nd.item(k), h);
        let k = (l) => this.m4.b.dw(this.nf.item(l), i);
        let l = ((() => {
            let $ret = new Clipper(0, d, false);
            $ret.i = a.m;
            return $ret;
        })());
        for (let m = 0; m < g;) {
            let n = m;
            ++m;
            while (m < g && this.ox(j, k, n, m) < f) {
                ++m;
            }
            if (g > this.nk) {
                l.j(this.o1(j, k, n, m - 1));
            }
            else {
                let o = new OwnedPoint();
                o.c = { $type: Point_$type, x: j(n), y: k(n) };
                o.a = this.bz.item(n);
                if (!a.u.containsKey(o.a)) {
                    a.u.addItem(o.a, o);
                }
            }
        }
        if (g > this.nk) {
            l.i = null;
        }
    }
    o1(a, b, c, d) {
        if (c == d) {
            return { $type: Point_$type, x: a(c), y: b(c) };
        }
        let e = 0;
        let f = 0;
        let g = (d - c + 1);
        for (let h = c; h <= d; ++h) {
            e += a(h);
            f += b(h);
        }
        return { $type: Point_$type, x: e / g, y: f / g };
    }
    ox(a, b, c, d) {
        let e = a(d) - a(c);
        let f = b(d) - b(c);
        return e * e + f * f;
    }
    hv(a, b) {
        super.hv(a, b);
        let c = typeCast(ScatterSplineSeriesView.$, b);
        c.c0(false);
    }
    ob(a, b) {
        this.hv(false, b);
        super.ob(a, b);
        this.n5(a);
        let c = typeCast(ScatterSplineSeriesView.$, b);
        c.da.ak = new PathGeometry();
        c.da.ak.c = Numeric.h(a.m.count, (d) => a.m._inner[d].x, (d) => a.m._inner[d].y, this.oy);
    }
}
ScatterSplineSeries.$t = markType(ScatterSplineSeries, 'ScatterSplineSeries', ScatterBase.$);
ScatterSplineSeries.$$p = markDep(DependencyProperty, PropertyMetadata, ScatterSplineSeries, 'raisePropertyChanged', ['Stiffness:oy:o0', [1, 0.5]]);
//# sourceMappingURL=ScatterSplineSeries.js.map