/*
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 { OwnedPoint } from "./OwnedPoint";
import { ScalerParams } from "./ScalerParams";
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.yu = new ScatterFrame();
        _this.yw = new ScatterFrame();
        _this.ys = new ScatterFrame();
        return _this;
    }
    ScatterSplineSeries.prototype.bi = function () {
        return new ScatterSplineSeries();
    };
    ScatterSplineSeries.prototype.get_fy = function () {
        return true;
    };
    ScatterSplineSeries.prototype.cq = function () {
        return new ScatterSplineSeriesView(this);
    };
    ScatterSplineSeries.prototype.zo = function () {
        return true;
    };
    ScatterSplineSeries.prototype.ji = function () {
        if (!isNaN_(this.jh)) {
            return _super.prototype.ji.call(this);
        }
        return Defaults.x;
    };
    ScatterSplineSeries.prototype.q5 = function (a, b, c, d) {
        _super.prototype.q5.call(this, a, b, c, d);
        switch (b) {
            case ScatterSplineSeries.$$p[0]:
                this.rn(false);
                this.qh();
                break;
        }
    };
    ScatterSplineSeries.prototype.b0 = function () {
        if (this.b1 == 0) {
            return 2;
        }
        else {
            return _super.prototype.b0.call(this);
        }
    };
    ScatterSplineSeries.prototype.aa6 = function (a, b) {
        var _this = this;
        _super.prototype.aa6.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.ib * this.ib;
        var g = Math.min(this.y9 != null ? this.y9.count : 0, this.za != null ? this.za.count : 0);
        var h = new ScalerParams(0, c, d, this.yo.d, e);
        var i = ((function () {
            var $ret = new ScalerParams(0, c, d, _this.yo.e, e);
            $ret.b = _this.iw();
            return $ret;
        })());
        var j = function (k) { return _this.yo.a.ek(_this.y9.item(k), h); };
        var k = function (l) { return _this.yo.b.ek(_this.za.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.ace(j, k, n, m) < f) {
                ++m;
            }
            if (g > this.z1) {
                l.j(this.aci(j, k, n, m - 1));
            }
            else {
                var o = new OwnedPoint();
                o.c = { $type: Point_$type, x: j(n), y: k(n) };
                o.a = this.dl.item(n);
                if (!a.u.containsKey(o.a)) {
                    a.u.addItem(o.a, o);
                }
            }
        }
        if (g > this.z1) {
            l.i = null;
        }
    };
    ScatterSplineSeries.prototype.aci = 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.ace = 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_zi = function () {
        return true;
    };
    ScatterSplineSeries.prototype.o3 = function (a, b) {
        _super.prototype.o3.call(this, a, b);
        var c = typeCast(ScatterSplineSeriesView.$, b);
        c.c9(false);
    };
    ScatterSplineSeries.prototype.abh = function (a, b) {
        this.o3(false, b);
        _super.prototype.abh.call(this, a, b);
        this.aa9(a);
        var c = typeCast(ScatterSplineSeriesView.$, b);
        var d = c.dl;
        this.y1.az(this, this.zn(), runOn(this, this.yh));
        var e = false;
        var f = this.y1.b;
        if (f != null) {
            e = true;
        }
        if (e) {
            this.aa2(-1, this.y9.count, b.q);
        }
        this.y1.ad(d, true, false, true, false);
        c.dl.an = new PathGeometry();
        c.dl.an.c = Numeric.h(a.m.count, function (g) { return a.m._inner[g].x; }, function (g) { return a.m._inner[g].y; }, this.acf);
    };
    ScatterSplineSeries.$t = markType(ScatterSplineSeries, 'ScatterSplineSeries', ScatterBase.$);
    ScatterSplineSeries.$$p = markDep(DependencyProperty, PropertyMetadata, ScatterSplineSeries, 'raisePropertyChanged', ['Stiffness:acf:ach', [1, 0.5]]);
    return ScatterSplineSeries;
}(ScatterBase));
export { ScatterSplineSeries };
