"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const index_esm = require("../../../min-dash/dist/index.esm.js");
var r = 1e3;
function n(u) {
  this._eventBus = u;
}
n.$inject = ["eventBus"];
function v(u, e) {
  return function(c) {
    return u.call(e || null, c.context, c.command, c);
  };
}
n.prototype.on = function(u, e, c, f, t, o) {
  if ((index_esm.isFunction(e) || index_esm.isNumber(e)) && (o = t, t = f, f = c, c = e, e = null), index_esm.isFunction(c) && (o = t, t = f, f = c, c = r), index_esm.isObject(t) && (o = t, t = false), !index_esm.isFunction(f))
    throw new Error("handlerFn must be a function");
  index_esm.isArray(u) || (u = [u]);
  var E = this._eventBus;
  index_esm.forEach(u, function(x) {
    var l = ["commandStack", x, e].filter(function(B) {
      return B;
    }).join(".");
    E.on(l, c, t ? v(f, o) : f, o);
  });
};
var I = [
  "canExecute",
  "preExecute",
  "preExecuted",
  "execute",
  "executed",
  "postExecute",
  "postExecuted",
  "revert",
  "reverted"
];
index_esm.forEach(I, function(u) {
  n.prototype[u] = function(e, c, f, t, o) {
    (index_esm.isFunction(e) || index_esm.isNumber(e)) && (o = t, t = f, f = c, c = e, e = null), this.on(e, u, c, f, t, o);
  };
});
exports.default = n;
