'use strict';

const observer = require('./observer-f49483e8.js');
const changeManager = require('./change-manager-72f643de.js');
const domNodeSubjectFactory = require('./dom-node-subject-factory-36b5fdbc.js');
const vegaInternalEventId = require('./vega-internal-event-id-87014e4f.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$1 = new observer.Observer(isAcceptableComponentDidRender.bind(null), () => {
      changeManager.ChangeManager.unregister(domNodeSubjectFactory.domNodeSubjectFactory.getSubject(componentRef, vegaInternalEventId.VegaInternalComponentDidRender), observer$1);
      resolve(null);
    });
    changeManager.ChangeManager.register(domNodeSubjectFactory.domNodeSubjectFactory.getSubject(componentRef, vegaInternalEventId.VegaInternalComponentDidRender), observer$1);
  });
};
/**
 * Determines whether the observer should accept changes.
 *
 * @returns {boolean} Always returns true in the current implementation.
 */
const isAcceptableComponentDidRender = () => {
  return true;
};

exports.waitForComponentDidRender = waitForComponentDidRender;
