/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import { o as whenTransitionDone } from "./dom.js";
function isOpen(component) {
  return component[component.openProp || "open"];
}
async function toggleOpenClose(component) {
  await component.updateComplete;
  if (isOpen(component)) {
    component.onBeforeOpen();
  } else {
    component.onBeforeClose();
  }
  await component.updateComplete;
  const transitionNode = hasRef(component) ? component.transitionRef.value : component.transitionEl;
  if (transitionNode) {
    await whenTransitionDone(transitionNode, component.transitionProp);
  }
  if (isOpen(component)) {
    component.onOpen();
  } else {
    component.onClose();
  }
}
function hasRef(component) {
  return "transitionRef" in component;
}
export {
  toggleOpenClose as t
};
