import { forEach, isArray, isFunction, isNumber, isObject } from "./chunk-4AK4GF4H.js"; // node_modules/.pnpm/diagram-js@11.9.1/node_modules/diagram-js/lib/command/CommandInterceptor.js var DEFAULT_PRIORITY = 1e3; function CommandInterceptor(eventBus) { this._eventBus = eventBus; } CommandInterceptor.$inject = ["eventBus"]; function unwrapEvent(fn, that) { return function(event) { return fn.call(that || null, event.context, event.command, event); }; } CommandInterceptor.prototype.on = function(events, hook, priority, handlerFn, unwrap, that) { if (isFunction(hook) || isNumber(hook)) { that = unwrap; unwrap = handlerFn; handlerFn = priority; priority = hook; hook = null; } if (isFunction(priority)) { that = unwrap; unwrap = handlerFn; handlerFn = priority; priority = DEFAULT_PRIORITY; } if (isObject(unwrap)) { that = unwrap; unwrap = false; } if (!isFunction(handlerFn)) { throw new Error("handlerFn must be a function"); } if (!isArray(events)) { events = [events]; } var eventBus = this._eventBus; forEach(events, function(event) { var fullEvent = ["commandStack", event, hook].filter(function(e) { return e; }).join("."); eventBus.on(fullEvent, priority, unwrap ? unwrapEvent(handlerFn, that) : handlerFn, that); }); }; var hooks = [ "canExecute", "preExecute", "preExecuted", "execute", "executed", "postExecute", "postExecuted", "revert", "reverted" ]; forEach(hooks, function(hook) { CommandInterceptor.prototype[hook] = function(events, priority, handlerFn, unwrap, that) { if (isFunction(events) || isNumber(events)) { that = unwrap; unwrap = handlerFn; handlerFn = priority; priority = events; events = null; } this.on(events, hook, priority, handlerFn, unwrap, that); }; }); export { CommandInterceptor }; //# sourceMappingURL=chunk-6IT32OMX.js.map