import { RendererServiceLocator } from '../Dom/Renderer';
/**
 * The `AnimationPlayer2` class.
 *
 * @public
 */
export class AnimationPlayer2 {
    // #region Ctor
    /**
     * Constructs a new instance of the `MotionManager` class.
     *
     * @public
     */
    constructor() {
    }
    // #endregion
    // #region Methods
    /**
     * @public
     */
    play(element, props, options) {
        const animation = element.animate(props, options);
        return new Promise((resolve) => {
            animation.addEventListener('finish', (x) => {
                this.applyAnimation(element, props);
                resolve(x);
            }, { once: true });
            animation.play();
        });
    }
    /**
     * @private
     */
    applyAnimation(element, prop) {
        Object.entries(prop).forEach(([k, v]) => {
            if (k in element.style) {
                RendererServiceLocator.current.setProperty(element, k, v?.toString() ?? '');
            }
        });
    }
}
//# sourceMappingURL=AnimationPlayer2.js.map