import h from "../../../../../@babel/runtime/helpers/esm/classCallCheck.mjs";
import n from "../../../../../@babel/runtime/helpers/esm/createClass.mjs";
import a from "../../../../../@babel/runtime/helpers/esm/inherits.mjs";
import c from "../../../../../@babel/runtime/helpers/esm/createSuper.mjs";
import y from "./calculator.mjs";
const l = "CALC_UNIT";
function i(r) {
  return typeof r == "number" ? `${r}${l}` : r;
}
let d = /* @__PURE__ */ function(r) {
  a(s, r);
  var u = c(s);
  function s(e) {
    var t;
    return h(this, s), t = u.call(this), t.result = "", e instanceof s ? t.result = `(${e.result})` : typeof e == "number" ? t.result = i(e) : typeof e == "string" && (t.result = e), t;
  }
  return n(s, [{
    key: "add",
    value: function(t) {
      return t instanceof s ? this.result = `${this.result} + ${t.getResult()}` : (typeof t == "number" || typeof t == "string") && (this.result = `${this.result} + ${i(t)}`), this.lowPriority = !0, this;
    }
  }, {
    key: "sub",
    value: function(t) {
      return t instanceof s ? this.result = `${this.result} - ${t.getResult()}` : (typeof t == "number" || typeof t == "string") && (this.result = `${this.result} - ${i(t)}`), this.lowPriority = !0, this;
    }
  }, {
    key: "mul",
    value: function(t) {
      return this.lowPriority && (this.result = `(${this.result})`), t instanceof s ? this.result = `${this.result} * ${t.getResult(!0)}` : (typeof t == "number" || typeof t == "string") && (this.result = `${this.result} * ${t}`), this.lowPriority = !1, this;
    }
  }, {
    key: "div",
    value: function(t) {
      return this.lowPriority && (this.result = `(${this.result})`), t instanceof s ? this.result = `${this.result} / ${t.getResult(!0)}` : (typeof t == "number" || typeof t == "string") && (this.result = `${this.result} / ${t}`), this.lowPriority = !1, this;
    }
  }, {
    key: "getResult",
    value: function(t) {
      return this.lowPriority || t ? `(${this.result})` : this.result;
    }
  }, {
    key: "equal",
    value: function(t) {
      const {
        unit: o = !0
      } = t || {}, f = new RegExp(`${l}`, "g");
      return this.result = this.result.replace(f, o ? "px" : ""), typeof this.lowPriority < "u" ? `calc(${this.result})` : this.result;
    }
  }]), s;
}(y);
export {
  d as default
};
