System.register(["__unresolved_0", "cc", "__unresolved_1"], function (_export, _context) {
  "use strict";

  var _reporterNs, _cclegacy, Singleton, GameEvent, _crd;

  function _reportPossibleCrUseOfSingleton(extras) {
    _reporterNs.report("Singleton", "../manager/Singleton", _context.meta, extras);
  }

  _export("default", void 0);

  return {
    setters: [function (_unresolved_) {
      _reporterNs = _unresolved_;
    }, function (_cc) {
      _cclegacy = _cc.cclegacy;
    }, function (_unresolved_2) {
      Singleton = _unresolved_2.default;
    }],
    execute: function () {
      _crd = true;

      _cclegacy._RF.push({}, "02f97/UrU1GaLXVFol1IYPD", "GameEvent", undefined);

      _export("default", GameEvent = class GameEvent extends (_crd && Singleton === void 0 ? (_reportPossibleCrUseOfSingleton({
        error: Error()
      }), Singleton) : Singleton) {
        constructor(...args) {
          super(...args);
          this.eventHash = {};
          this.ower = null;
          this.type = null;
          this.callback = null;
        }

        clearAll() {
          console.log("-------clearall");
          this.eventHash = {};
        } // cb:必须使用 function(){}.bind(this) 的写法


        register(ower, type, cb) {
          var event = {};
          event["ower"] = ower;
          event["type"] = type;
          event["callback"] = cb;

          if (!this.eventHash.hasOwnProperty(type)) {
            this.eventHash[type] = [];
          }

          this.eventHash[type].push(event);
        }

        unregister(ower, type) {
          var events = this.eventHash[type];

          if (events && events.length > 0) {
            events.forEach((event, index) => {
              if (event.ower === ower && event.type === type) {
                events.splice(index, 1);
              }
            });
          }

          ;
        }

        dispatch(type, ...data) {
          console.log(this.eventHash);
          var events = this.eventHash[type];

          if (events && events.length > 0) {
            for (var i in events) {
              var event = events[i];
              event.callback && event.callback(...data);
            }
          }
        }

      });

      ;

      _cclegacy._RF.pop();

      _crd = false;
    }
  };
});
//# sourceMappingURL=5885dd29eb18496bf662aa8001f3ab74e36e1753.js.map