// #region Imports
// #endregion
/**
 * The `Scroller` class.
 *
 * @public
 */
export class Scroller {
    // #region Ctor
    /**
     * Constructs a new instance of the `Scroller` class.
     *
     * @public
     */
    constructor() {
    }
    // #endregion
    // #region Methods
    scrollToTop(element, options) {
        element.scroll({
            top: 0,
            behavior: 'smooth',
            ...options
        });
    }
    scrollToBottom(element, options) {
        element.scroll({
            top: element.scrollHeight,
            behavior: 'smooth',
            ...options
        });
    }
    scrollToLeft(element, options) {
        element.scroll({
            left: 0,
            behavior: 'smooth',
            ...options
        });
    }
    scrollToRight(element, options) {
        element.scroll({
            left: element.scrollWidth,
            behavior: 'smooth',
            ...options
        });
    }
    scrollToElement(element, options) {
        element.scrollIntoView({
            behavior: 'smooth',
            block: 'start',
            inline: 'nearest',
            ...options
        });
    }
    scrollToElementInContainer(container, element, options) {
        const containerTop = container.getBoundingClientRect().top;
        const itemTop = element.getBoundingClientRect().top;
        const scrollPosition = container.scrollTop + (itemTop - containerTop);
        container.scroll({
            top: scrollPosition,
            behavior: 'smooth',
            ...options
        });
    }
}
/**
 * @public
 */
export class ScrollerServiceLocator {
    // #region Fields
    static _current = null;
    // #endregion
    // #region Properties
    static get current() {
        if (!ScrollerServiceLocator.isSet()) {
            throw new Error('\'Scroller\' not set.');
        }
        // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
        return ScrollerServiceLocator._current;
    }
    // #endregion
    // #region Methods
    static isSet() {
        return ScrollerServiceLocator._current !== null;
    }
    static set(current) {
        ScrollerServiceLocator._current = current;
    }
}
ScrollerServiceLocator.set(new Scroller());
//# sourceMappingURL=Scroller.js.map