"use strict";exports.__esModule = true;exports.ConditionalHandler = void 0;var _utils = require("./utils");var









ConditionalHandler = exports.ConditionalHandler = /*#__PURE__*/function () {function ConditionalHandler() {this.
    actions = [];}var _proto = ConditionalHandler.prototype;_proto.

  add = function add(condition, handler) {
    this.actions.push({ condition: condition, handler: handler });
    return this;
  }

  /**
   * @returns {Boolean} found - был ли найден и вызван хоть один обработчик
   */;_proto.
  build = function build() {var _this = this;
    return function (reference) {for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {args[_key - 1] = arguments[_key];}
      var found = false;
      _this.actions.forEach(function (_ref) {var condition = _ref.condition,handler = _ref.handler;
        if ((0, _utils.isFunction)(condition) ? condition(reference) : condition === reference) {
          handler.apply(void 0, args);
          found = true;
        }
      });

      return found;
    };
  };return ConditionalHandler;}();