/*
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 { __extends } from "tslib";
import { ScatterBase } from "./ScatterBase";
import { DependencyProperty } from "igniteui-react-core";
import { Point_$type, typeCast, runOn, markType, markDep } from "igniteui-react-core";
import { ScatterFrame } from "./ScatterFrame";
import { ScatterSplineSeriesView } from "./ScatterSplineSeriesView";
import { Defaults } from "./Defaults";
import { Clipper } from "igniteui-react-core";
import { ScalerParams } from "./ScalerParams";
import { OwnedPoint } from "./OwnedPoint";
import { PathGeometry } from "igniteui-react-core";
import { Numeric } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { isNaN_ } from "igniteui-react-core";
/**
 * @hidden
 */
var ScatterSplineSeries = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(ScatterSplineSeries, _super);
    function ScatterSplineSeries() {
        var _this = _super.call(this) || this;
        _this.ab = ScatterSplineSeries.$;
        _this.v0 = new ScatterFrame();
        _this.v2 = new ScatterFrame();
        _this.vy = new ScatterFrame();
        return _this;
    }
    ScatterSplineSeries.prototype.get_fd = function () {
        return true;
    };
    ScatterSplineSeries.prototype.cg = function () {
        return new ScatterSplineSeriesView(this);
    };
    ScatterSplineSeries.prototype.wp = function () {
        return true;
    };
    ScatterSplineSeries.prototype.ip = function () {
        if (!isNaN_(this.io)) {
            return _super.prototype.ip.call(this);
        }
        return Defaults.x;
    };
    ScatterSplineSeries.prototype.o8 = function (a, b, c, d) {
        _super.prototype.o8.call(this, a, b, c, d);
        switch (b) {
            case ScatterSplineSeries.$$p[0]:
                this.pp(false);
                this.ol();
                break;
        }
    };
    ScatterSplineSeries.prototype.bx = function () {
        if (this.by == 0) {
            return 2;
        }
        else {
            return _super.prototype.bx.call(this);
        }
    };
    ScatterSplineSeries.prototype.x6 = function (a, b) {
        var _this = this;
        _super.prototype.x6.call(this, a, b);
        a.m.clear();
        a.u.clear();
        var c = b.by;
        var d = b.bx;
        var e = this.getEffectiveViewport1(b);
        var f = this.hj * this.hj;
        var g = Math.min(this.wa != null ? this.wa.count : 0, this.wb != null ? this.wb.count : 0);
        var h = new ScalerParams(0, c, d, this.vu.d, e);
        var i = ((function () {
            var $ret = new ScalerParams(0, c, d, _this.vu.e, e);
            $ret.b = _this.h2();
            return $ret;
        })());
        var j = function (k) { return _this.vu.a.ej(_this.wa.item(k), h); };
        var k = function (l) { return _this.vu.b.ej(_this.wb.item(l), i); };
        var l = ((function () {
            var $ret = new Clipper(0, d, false);
            $ret.i = a.m;
            return $ret;
        })());
        for (var m = 0; m < g;) {
            var n = m;
            ++m;
            while (m < g && this.ze(j, k, n, m) < f) {
                ++m;
            }
            if (g > this.w1) {
                l.j(this.zi(j, k, n, m - 1));
            }
            else {
                var o = new OwnedPoint();
                o.c = { $type: Point_$type, x: j(n), y: k(n) };
                o.a = this.c6.item(n);
                if (!a.u.containsKey(o.a)) {
                    a.u.addItem(o.a, o);
                }
            }
        }
        if (g > this.w1) {
            l.i = null;
        }
    };
    ScatterSplineSeries.prototype.zi = function (a, b, c, d) {
        if (c == d) {
            return { $type: Point_$type, x: a(c), y: b(c) };
        }
        var e = 0;
        var f = 0;
        var g = (d - c + 1);
        for (var h = c; h <= d; ++h) {
            e += a(h);
            f += b(h);
        }
        return { $type: Point_$type, x: e / g, y: f / g };
    };
    ScatterSplineSeries.prototype.ze = function (a, b, c, d) {
        var e = a(d) - a(c);
        var f = b(d) - b(c);
        return e * e + f * f;
    };
    ScatterSplineSeries.prototype.get_wj = function () {
        return true;
    };
    ScatterSplineSeries.prototype.nj = function (a, b) {
        _super.prototype.nj.call(this, a, b);
        var c = typeCast(ScatterSplineSeriesView.$, b);
        c.c7(false);
    };
    ScatterSplineSeries.prototype.yh = function (a, b) {
        this.nj(false, b);
        _super.prototype.yh.call(this, a, b);
        this.x9(a);
        var c = typeCast(ScatterSplineSeriesView.$, b);
        var d = c.dj;
        this.v7.az(this, this.wo(), runOn(this, this.vi));
        var e = false;
        var f = this.v7.b;
        if (f != null) {
            e = true;
        }
        if (e) {
            this.x2(-1, this.wa.count, b.q);
        }
        this.v7.ad(d, true, false, true, false);
        c.dj.an = new PathGeometry();
        c.dj.an.c = Numeric.h(a.m.count, function (g) { return a.m._inner[g].x; }, function (g) { return a.m._inner[g].y; }, this.zf);
    };
    ScatterSplineSeries.$t = markType(ScatterSplineSeries, 'ScatterSplineSeries', ScatterBase.$);
    ScatterSplineSeries.$$p = markDep(DependencyProperty, PropertyMetadata, ScatterSplineSeries, 'raisePropertyChanged', ['Stiffness:zf:zh', [1, 0.5]]);
    return ScatterSplineSeries;
}(ScatterBase));
export { ScatterSplineSeries };
