import { O as Observer } from './observer-3959f9dd.js';
import { C as ChangeManager } from './change-manager-6a7eb88c.js';
import { d as domNodeSubjectFactory } from './dom-node-subject-observer-factory-aca0116e.js';
import { s as VegaInternalComponentDidRender } from './vega-internal-event-id-194bac82.js';

/**
 * Wait for the component has been rendered.
 *
 * @param {HTMLStencilElement} componentRef - The reference to the component that needs to be rendered.
 * @returns {Promise<unknown>} A promise that resolves when the component has been rendered.
 */
const waitForComponentDidRender = async (componentRef) => {
  return new Promise((resolve) => {
    const observer = new Observer(isAcceptableComponentDidRender.bind(null), () => {
      ChangeManager.unregister(domNodeSubjectFactory.getSubject(componentRef, VegaInternalComponentDidRender), observer);
      resolve(null);
    });
    ChangeManager.register(domNodeSubjectFactory.getSubject(componentRef, VegaInternalComponentDidRender), observer);
  });
};
/**
 * Determines whether the observer should accept changes.
 *
 * @returns {boolean} Always returns true in the current implementation.
 */
const isAcceptableComponentDidRender = () => {
  return true;
};

export { waitForComponentDidRender as w };
