/*
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 { BuiltInFunctionBase } from "./BuiltInFunctionBase";
import { ExcelCalcValue } from "./ExcelCalcValue";
import { StringBuilder } from "igniteui-angular-core";
import { markType } from "igniteui-angular-core";
import { stringIsNullOrEmpty } from "igniteui-angular-core";
/**
 * @hidden
 */
export let UltraCalcFunctionClean = /*@__PURE__*/ (() => {
    class UltraCalcFunctionClean extends BuiltInFunctionBase {
        evaluate(a, b) {
            let c = a.pop();
            if (c.isError) {
                return c;
            }
            let d = c.toString();
            if (!stringIsNullOrEmpty(d)) {
                let e = null;
                let f = false;
                for (let g = 0; g < d.length; g++) {
                    let h = d.charAt(g);
                    if (h.charCodeAt(0) <= 31) {
                        f = true;
                    }
                    else {
                        switch (h.charCodeAt(0)) {
                            case 129:
                            case 141:
                            case 143:
                            case 144:
                            case 157:
                                f = true;
                                break;
                            default:
                                f = false;
                                break;
                        }
                    }
                    if (f) {
                        if (e == null) {
                            e = new StringBuilder(1, d.length - 1);
                            if (g > 0) {
                                e.m(d, 0, g);
                            }
                        }
                    }
                    else if (e != null) {
                        e.h(h);
                    }
                }
                if (e != null) {
                    d = e.toString();
                }
            }
            return new ExcelCalcValue(d);
        }
        get_maxArgs() {
            return 1;
        }
        get maxArgs() {
            return this.get_maxArgs();
        }
        get_minArgs() {
            return 1;
        }
        get minArgs() {
            return this.get_minArgs();
        }
        get_name() {
            return "clean";
        }
        get name() {
            return this.get_name();
        }
    }
    UltraCalcFunctionClean.$t = markType(UltraCalcFunctionClean, 'UltraCalcFunctionClean', BuiltInFunctionBase.$);
    return UltraCalcFunctionClean;
})();
