// #region Imports
import { AsyncDirectiveBase, PartType, compose } from '../../Controls/Directives/Abstracts/AsyncDirectiveBase';
import { nothing } from '../../Dom/Html';
import { AnimationPlayer2 } from '../AnimationPlayer2';
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function isAnimationRef(value) {
    return value && typeof value === 'object' && 'play' in value;
}
/**
 * The `AnimateDirective` class.
 *
 * @public
 */
export class AnimationRefDirective extends AsyncDirectiveBase {
    // #region Fields
    _animationPlayer;
    // #endregion
    // #region Ctor
    /**
     * Constructs a new instance of the `AnimateDirective` class.
     *
     * @public
     */
    constructor(args) {
        super(args);
        if (args.type !== PartType.ELEMENT) {
            throw new Error('The `animate` directive must be used in attribute position.');
        }
        this._animationPlayer = new AnimationPlayer2();
    }
    // #endregion
    // #region Methods
    render(cb) {
        cb({ play: (options) => this._animationPlayer.play(this.internals.element, options.from, options.options) });
        return nothing;
    }
}
export const animationRef = compose(AnimationRefDirective);
//# sourceMappingURL=AnimationRefDirective.js.map