{"version":3,"file":"await-exit.cjs","names":[],"sources":["../../../src/overlay/shared/await-exit.ts"],"sourcesContent":["/**\n * Waits for a CSS exit animation or transition to finish, then calls `onDone`.\n *\n * Uses the Web Animations API (`element.getAnimations()`) when available for\n * precise, synchronous detection. Falls back to a single microtask + immediate\n * call when no relevant animations are running (e.g. `prefers-reduced-motion`\n * or overridden styles).\n *\n * @param el   - The element whose animations/transitions to observe.\n * @param onDone - Callback invoked exactly once when all animations end.\n * @param type - `'animation'` (default) or `'transition'`.\n */\nexport function awaitExit(el: Element, onDone: () => void, type: 'animation' | 'transition' = 'animation'): void {\n  // Force a synchronous style recalc so that any CSS class changes applied\n  // immediately before this call (e.g. adding 'closing') are committed and\n  // CSSTransition / CSSAnimation instances appear in getAnimations().\n  // Reading getComputedStyle() is the lightest layout-flush trigger available;\n  // in jsdom it is a no-op stub so test timing is unaffected.\n  if (typeof getComputedStyle === 'function') void getComputedStyle(el).opacity;\n\n  queueMicrotask(() => {\n    const getAnimations = typeof el.getAnimations === 'function' ? () => el.getAnimations() : () => [];\n    const relevant = getAnimations().filter((a) => {\n      if (type === 'animation') return a instanceof CSSAnimation;\n\n      if (type === 'transition') return a instanceof CSSTransition;\n\n      return false;\n    });\n\n    if (relevant.length === 0) {\n      onDone();\n\n      return;\n    }\n\n    let done = false;\n    const finish = () => {\n      if (done) return;\n\n      done = true;\n      onDone();\n    };\n\n    // Resolve when ALL relevant animations are finished or cancelled.\n    Promise.allSettled(relevant.map((a) => a.finished)).then(finish);\n  });\n}\n"],"mappings":"AAYA,SAAgB,EAAU,EAAa,EAAoB,EAAmC,YAAmB,CAM3G,OAAO,kBAAqB,YAAY,iBAAsB,CAAE,CAAC,CAAC,QAEtE,mBAAqB,CAEnB,IAAM,GADgB,OAAO,EAAG,eAAkB,eAAmB,EAAG,cAAc,MAAU,CAAC,EAAA,CAClE,CAAC,CAAC,OAAQ,GACnC,IAAS,YAAoB,aAAa,aAE1C,IAAS,cAAqB,aAAa,aAGhD,EAED,GAAI,EAAS,SAAW,EAAG,CACzB,EAAO,EAEP,MACF,CAEA,IAAI,EAAO,GASX,QAAQ,WAAW,EAAS,IAAK,GAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,SAR/B,CACf,IAEJ,EAAO,GACP,EAAO,EACT,CAG+D,CACjE,CAAC,CACH"}