"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.flushAnimation = flushAnimation;
exports.waitFinish = waitFinish;
function flushAnimation(animation) {
    animation.commitStyles();
    animation.cancel();
    try {
    }
    catch {
        //
    }
}
async function waitFinish(animation) {
    if (animation.playState === 'finished') {
        return animation;
    }
    return Promise.race([
        new Promise((resolve) => {
            const listener = () => {
                animation.removeEventListener('finish', listener);
                resolve(animation);
            };
            animation.addEventListener('finish', listener);
        }),
        new Promise((resolve) => {
            const listener = () => {
                animation.removeEventListener('cancel', listener);
                resolve(animation);
            };
            animation.addEventListener('cancel', listener);
        }),
    ]);
}
//# sourceMappingURL=animation.js.map