import { C as ChangeManager } from './change-manager-ecbd3a2a.js';
import { O as Observer } from './observer-3959f9dd.js';
import { d as domNodeSubjectFactory } from './dom-node-subject-factory-6894df15.js';

/**
 * The function `domAcceptableHandle` always returns `true`.
 *
 * @returns {boolean} true
 */
const domAcceptableHandle = () => {
  return true;
};
/** The `DomNodeSubjectObserverFactory` class provides methods to add and remove observers to HTML element nodes. */
class DomNodeSubjectObserverFactory {
  /**
   * add observer to a given HTML element node
   *
   * @param {HTMLElement} node the node ref
   * @param {VegaEventIDInterface} eventId The `eventId` parameter is of type `VegaEventIDInterface`. It represents the ID of a Vega event.
   * @param {(input?: unknown) => void} callback the callback handle
   * @param {(input?: unknown) => boolean} acceptableHandle the acceptable handle
   */
  static addUniqueObserverToNode(node, eventId, callback, acceptableHandle) {
    if (node) {
      const domNodesObserver = new Observer(typeof acceptableHandle === 'function' ? acceptableHandle.bind(null) : domAcceptableHandle, callback);
      DomNodeSubjectObserverFactory.removeUniqueObserverFromNode(node, eventId);
      ChangeManager.register(domNodeSubjectFactory.getSubject(node, eventId), domNodesObserver);
    }
  }
  /**
   * The function removes observers from a given HTML element node.
   *
   * @param {HTMLElement} node - The `node` parameter is an `HTMLElement` object representing an HTML element in the DOM (Document Object Model).
   * @param {VegaEventIDInterface} eventId The `eventId` parameter is of type `VegaEventIDInterface`. It represents the ID of a Vega event.
   */
  static removeUniqueObserverFromNode(node, eventId) {
    if (domNodeSubjectFactory.isExist(node, eventId)) {
      ChangeManager.clearObserversBySubject(domNodeSubjectFactory.getSubject(node, eventId));
    }
  }
}

export { DomNodeSubjectObserverFactory as D };
