import a from "../../../@babel/runtime/helpers/esm/classCallCheck.mjs";
import N from "../../../@babel/runtime/helpers/esm/createClass.mjs";
import s from "../../../@babel/runtime/helpers/esm/defineProperty.mjs";
import { getNumberPrecision as u, num2str as o, isEmpty as b } from "./numberUtil.mjs";
var v = /* @__PURE__ */ function() {
  function r(e) {
    if (a(this, r), s(this, "origin", ""), s(this, "number", void 0), s(this, "empty", void 0), b(e)) {
      this.empty = !0;
      return;
    }
    this.origin = String(e), this.number = Number(e);
  }
  return N(r, [{
    key: "negate",
    value: function() {
      return new r(-this.toNumber());
    }
  }, {
    key: "add",
    value: function(t) {
      if (this.isInvalidate())
        return new r(t);
      var i = Number(t);
      if (Number.isNaN(i))
        return this;
      var n = this.number + i;
      if (n > Number.MAX_SAFE_INTEGER)
        return new r(Number.MAX_SAFE_INTEGER);
      if (n < Number.MIN_SAFE_INTEGER)
        return new r(Number.MIN_SAFE_INTEGER);
      var m = Math.max(u(this.number), u(i));
      return new r(n.toFixed(m));
    }
  }, {
    key: "multi",
    value: function(t) {
      var i = Number(t);
      if (this.isInvalidate() || Number.isNaN(i))
        return new r(NaN);
      var n = this.number * i;
      if (n > Number.MAX_SAFE_INTEGER)
        return new r(Number.MAX_SAFE_INTEGER);
      if (n < Number.MIN_SAFE_INTEGER)
        return new r(Number.MIN_SAFE_INTEGER);
      var m = Math.max(u(this.number), u(i));
      return new r(n.toFixed(m));
    }
  }, {
    key: "isEmpty",
    value: function() {
      return this.empty;
    }
  }, {
    key: "isNaN",
    value: function() {
      return Number.isNaN(this.number);
    }
  }, {
    key: "isInvalidate",
    value: function() {
      return this.isEmpty() || this.isNaN();
    }
  }, {
    key: "equals",
    value: function(t) {
      return this.toNumber() === (t == null ? void 0 : t.toNumber());
    }
  }, {
    key: "lessEquals",
    value: function(t) {
      return this.add(t.negate().toString()).toNumber() <= 0;
    }
  }, {
    key: "toNumber",
    value: function() {
      return this.number;
    }
  }, {
    key: "toString",
    value: function() {
      var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !0;
      return t ? this.isInvalidate() ? "" : o(this.number) : this.origin;
    }
  }]), r;
}();
export {
  v as default
};
