export function animateTo(e,n,t){return new Promise((i=>{if((null==t?void 0:t.duration)===1/0)throw new Error("Promise-based animations must be finite.");if(!(null==e?void 0:e.animate))return;const o=e.animate(n,{...t,duration:prefersReducedMotion()?0:t.duration});o&&(o.addEventListener("cancel",i,{once:!0}),o.addEventListener("finish",i,{once:!0}))}))}export function parseDuration(e){return(e=e.toString().toLowerCase()).indexOf("ms")>-1?parseFloat(e):e.indexOf("s")>-1?1e3*parseFloat(e):parseFloat(e)}export function prefersReducedMotion(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}export function stopAnimations(e){var n;return Promise.all(((null===(n=null==e?void 0:e.getAnimations)||void 0===n?void 0:n.call(e))||[]).map((e=>new Promise((n=>{const t=requestAnimationFrame(n);e.addEventListener("cancel",(()=>t),{once:!0}),e.addEventListener("finish",(()=>t),{once:!0}),e.cancel()})))))}export function shimKeyframesHeightAuto(e,n){return e.map((e=>({...e,height:"auto"===e.height?`${n}px`:e.height})))}