"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: all[name]
    });
}
_export(exports, {
    parseInputHelper: function() {
        return parseInputHelper;
    },
    todpIfNeed: function() {
        return todpIfNeed;
    }
});
const _utils = require("@orderly.network/utils");
const parseInputHelper = (input)=>{
    if (input === undefined || input === "") return input;
    if (input.startsWith(".")) return `0${input}`;
    input = input.replace(/,/g, "");
    input = input.replace(/[^\d.]/g, "").replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
    return input;
};
const todpIfNeed = (value, dp, round = _utils.Decimal.ROUND_DOWN)=>{
    if (value === undefined || value === "") return value;
    if (typeof value === "number") {
        value = value.toString();
    }
    if (value.endsWith(".")) {
        return value;
    }
    const numbers = value.split(".");
    if (numbers.length === 1) {
        return value;
    }
    if (numbers[1].length <= dp || !numbers[1]) {
        return value;
    }
    return new _utils.Decimal(value).todp(dp, round).toNumber();
};

//# sourceMappingURL=utils.js.map