/*
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 { Base, fromEnum, String_$type, markType } from "./type";
import { Brush } from "./Brush";
import { BrushCollection } from "./BrushCollection";
import { List$1 } from "./List$1";
import { MathUtil } from "./MathUtil";
import { ColorUtil } from "./ColorUtil";
import { truncate, isNaN_ } from "./number";
/**
 * @hidden
 */
export let BrushCollectionUtil = /*@__PURE__*/ (() => {
    class BrushCollectionUtil extends Base {
        static d(a, b) {
            if (isNaN_(b)) {
                return null;
            }
            b = MathUtil.d(b, 0, a.count - 1);
            let c = truncate(Math.floor(b));
            if (c == b) {
                return a.item(c);
            }
            return BrushCollectionUtil.e(b - c, a.item(c), a.item(c + 1), a.af);
        }
        static e(a, b, c, d) {
            let e = b.color;
            let f = c.color;
            let g = ColorUtil.x(e, a, f, d);
            let h = new Brush();
            h.color = g;
            return h;
        }
        static b(a) {
            let b = new BrushCollection();
            for (let c of fromEnum(a)) {
                let d = ColorUtil.q(c);
                if (d != null) {
                    b.add(d);
                }
            }
            return b;
        }
        static c(a) {
            if (a == null) {
                return null;
            }
            let b = true;
            if (typeof a === 'string') {
                let str_ = a;
                str_ = str_.trim();
                let c = (str_.split(/[\s,]+(?![^(]*\))/gm));
                for (let d = 0; d < c.length; d++) {
                    c[d] = c[d].trim();
                }
                a = c;
            }
            let e = a != null ? a[0] : null;
            if (typeof e === 'string' && e == "HSV" || e == "RGB") {
                if (a[0] == "HSV") {
                    b = false;
                }
                let f = new Array(a.length - 1);
                for (let g = 1; g < a[0].length; g++) {
                    f[g] = a[g];
                }
                a = f;
            }
            let h = new BrushCollection();
            for (let i = 0; a != null && i < a.length; i++) {
                let j = Brush.create(a[i]);
                h.add(j);
            }
            return h;
        }
        static a(a) {
            if (a == null) {
                return null;
            }
            let b = a;
            let c = new List$1(String_$type, 0);
            for (let d = 0; d < b.count; d++) {
                let e = b.item(d);
                if (e != null) {
                    c.add(e._fill);
                }
            }
            return c.toArray();
        }
    }
    BrushCollectionUtil.$t = markType(BrushCollectionUtil, 'BrushCollectionUtil');
    return BrushCollectionUtil;
})();
