/*
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-react-core/ES2015/DependencyProperty";
import { Type, Point_$type, typeCast, markType } from "igniteui-react-core/ES2015/type";
import { ScatterFrame } from "./ScatterFrame";
import { ScatterSplineSeriesView } from "./ScatterSplineSeriesView";
import { Clipper } from "igniteui-react-core/ES2015/Clipper";
import { OwnedPoint } from "./OwnedPoint";
import { ScalerParams } from "./ScalerParams";
import { PathGeometry } from "igniteui-react-core/ES2015/PathGeometry";
import { Numeric } from "igniteui-react-core/ES2015/Numeric";
import { PropertyMetadata } from "igniteui-react-core/ES2015/PropertyMetadata";
export class ScatterSplineSeries extends ScatterBase {
    constructor() {
        super();
        this.ab = ScatterSplineSeries.$;
        this.m0 = new ScatterFrame();
        this.m2 = new ScatterFrame();
        this.mz = new ScatterFrame();
    }
    bf() {
        return new ScatterSplineSeriesView(this);
    }
    ir(a, b, c, d) {
        super.ir(a, b, c, d);
        switch (b) {
            case ScatterSplineSeries.$$p[0]:
                this.i4(false);
                this.ib();
                break;
        }
    }
    bd() {
        if (this.be == 0) {
            return 2;
        }
        else {
            return super.bd();
        }
    }
    nt(a, b) {
        super.nt(a, b);
        a.m.clear();
        a.u.clear();
        let c = b.bs;
        let d = b.br;
        let e = this.getEffectiveViewport1(b);
        let f = this.eq * this.eq;
        let g = Math.min(this.m4 != null ? this.m4.count : 0, this.m6 != null ? this.m6.count : 0);
        let h = new ScalerParams(0, c, d, this.mv.d, e);
        let i = ((() => {
            let $ret = new ScalerParams(0, c, d, this.mv.e, e);
            $ret.b = this.ed();
            return $ret;
        })());
        let j = (k) => this.mv.a.dt(this.m4.item(k), h);
        let k = (l) => this.mv.b.dt(this.m6.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.oo(j, k, n, m) < f) {
                ++m;
            }
            if (g > this.nb) {
                l.j(this.os(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.nb) {
            l.i = null;
        }
    }
    os(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 };
    }
    oo(a, b, c, d) {
        let e = a(d) - a(c);
        let f = b(d) - b(c);
        return e * e + f * f;
    }
    ho(a, b) {
        super.ho(a, b);
        let c = typeCast(ScatterSplineSeriesView.$, b);
        c.c0(false);
    }
    n2(a, b) {
        this.ho(false, b);
        super.n2(a, b);
        this.nw(a);
        let c = typeCast(ScatterSplineSeriesView.$, b);
        c.da.aj = new PathGeometry();
        c.da.aj.b = Numeric.h(a.m.count, (d) => a.m._inner[d].x, (d) => a.m._inner[d].y, this.op);
    }
}
ScatterSplineSeries.$t = markType(ScatterSplineSeries, 'ScatterSplineSeries', ScatterBase.$);
Type.dep(DependencyProperty, PropertyMetadata, ScatterSplineSeries, 'raisePropertyChanged', ['Stiffness:op:or', [1, 0.5]]);
