import { useState as v, useEffect as d } from "react";
import { throttle as l } from "es-toolkit/function";
const g = () => {
  const [u, E] = v({}), [c, p] = v(0);
  return d(() => {
    console.log("init useEventListener interceptor");
    const o = /* @__PURE__ */ new Set(), s = EventTarget.prototype.addEventListener, i = EventTarget.prototype.removeEventListener, a = l(() => {
      const e = Array.from(o).reduce(
        (t, { type: n }) => (t[n] = (t[n] || 0) + 1, t),
        {}
      );
      E(e), p(o.size);
    }, 1e3);
    return EventTarget.prototype.addEventListener = function(e, t, n) {
      t && (o.add({ type: e, listener: t }), a()), s.call(this, e, t, n);
    }, EventTarget.prototype.removeEventListener = function(e, t, n) {
      o.forEach((r) => {
        r.type === e && r.listener === t && o.delete(r);
      }), a(), i.call(this, e, t, n);
    }, () => {
      EventTarget.prototype.addEventListener = s, EventTarget.prototype.removeEventListener = i;
    };
  }, []), { counts: u, total: c };
};
export {
  g as default
};
//# sourceMappingURL=useEventListenerCount.js.map
