//#region src/utils/SubscriptionManager.d.ts
/** The shape a subscription map has to have: a handler per event name. */
type HandlerMap = Record<string, (...args: never[]) => void>;
/**
 * A typed event emitter, small enough to avoid a dependency and precise enough
 * that a wrong payload is a compile error rather than a runtime surprise.
 *
 * The map it is given must be declared as a `type` rather than an `interface`,
 * because an interface has no implicit index signature and cannot satisfy the
 * constraint above.
 *
 * Both methods are fields rather than prototype methods so they can be handed
 * out on their own, which is how `subscribe` reaches a consumer.
 */
declare class SubscriptionManager<Subscriptions extends HandlerMap> {
  private readonly listeners;
  /** Registers a handler and returns the function that removes it. */
  subscribe: <Type extends keyof Subscriptions>(type: Type, handler: Subscriptions[Type]) => (() => void);
  /**
   * Calls every handler registered for an event.
   *
   * The set is walked in place rather than copied, because `frame` is notified
   * once per rendered frame and a copy per notification would allocate at that
   * rate. A handler that removes itself while being called is safe; one that
   * subscribes during its own notification may be called in the same pass.
   */
  notify: <Type extends keyof Subscriptions>(type: Type, ...args: Parameters<Subscriptions[Type]>) => void;
}
//#endregion
export { SubscriptionManager };