import { forEach as o, isFunction as F, isNumber as P, isObject as E, isArray as p } from "../../../min-dash/dist/index.esm.mjs";
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$1) {
  if ((F(e) || P(e)) && (o$1 = t, t = f, f = c, c = e, e = null), F(c) && (o$1 = t, t = f, f = c, c = r), E(t) && (o$1 = t, t = false), !F(f))
    throw new Error("handlerFn must be a function");
  p(u) || (u = [u]);
  var E$1 = this._eventBus;
  o(u, function(x) {
    var l = ["commandStack", x, e].filter(function(B) {
      return B;
    }).join(".");
    E$1.on(l, c, t ? v(f, o$1) : f, o$1);
  });
};
var I = [
  "canExecute",
  "preExecute",
  "preExecuted",
  "execute",
  "executed",
  "postExecute",
  "postExecuted",
  "revert",
  "reverted"
];
o(I, function(u) {
  n.prototype[u] = function(e, c, f, t, o2) {
    (F(e) || P(e)) && (o2 = t, t = f, f = c, c = e, e = null), this.on(e, u, c, f, t, o2);
  };
});
export {
  n as default
};
