function _check_private_redeclaration(obj, privateCollection) {
    if (privateCollection.has(obj)) {
        throw new TypeError("Cannot initialize the same private elements twice on an object");
    }
}
function _class_apply_descriptor_get(receiver, descriptor) {
    if (descriptor.get) {
        return descriptor.get.call(receiver);
    }
    return descriptor.value;
}
function _class_apply_descriptor_set(receiver, descriptor, value) {
    if (descriptor.set) {
        descriptor.set.call(receiver, value);
    } else {
        if (!descriptor.writable) {
            throw new TypeError("attempted to set read only private field");
        }
        descriptor.value = value;
    }
}
function _class_extract_field_descriptor(receiver, privateMap, action) {
    if (!privateMap.has(receiver)) {
        throw new TypeError("attempted to " + action + " private field on non-instance");
    }
    return privateMap.get(receiver);
}
function _class_private_field_get(receiver, privateMap) {
    var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
    return _class_apply_descriptor_get(receiver, descriptor);
}
function _class_private_field_init(obj, privateMap, value) {
    _check_private_redeclaration(obj, privateMap);
    privateMap.set(obj, value);
}
function _class_private_field_set(receiver, privateMap, value) {
    var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
    _class_apply_descriptor_set(receiver, descriptor, value);
    return value;
}
function _class_private_method_get(receiver, privateSet, fn) {
    if (!privateSet.has(receiver)) {
        throw new TypeError("attempted to get private field on non-instance");
    }
    return fn;
}
function _class_private_method_init(obj, privateSet) {
    _check_private_redeclaration(obj, privateSet);
    privateSet.add(obj);
}
import { BasePlugin } from '../base/index.mjs';
import { throwWithCause } from '../../helpers/errors.mjs';
import { isObject } from '../../helpers/object.mjs';
import { randomString } from '../../helpers/string.mjs';
import * as C from '../../i18n/constants.mjs';
import { NotificationUI } from './ui.mjs';
import { FOCUS_SOURCES } from '../../focusManager/constants.mjs';
import { GRID_SCOPE } from '../../shortcutContexts/constants.mjs';
import { NOTIFICATION_CLASS_NAME, NOTIFICATION_POSITIONS, NOTIFICATION_VARIANTS } from './constants.mjs';
export const PLUGIN_KEY = 'notification';
export const PLUGIN_PRIORITY = 375;
const SHORTCUTS_CONTEXT_NAME = `plugin:${PLUGIN_KEY}`;
const SHORTCUTS_GLOBAL_CONTEXT_NAME = `plugin:${PLUGIN_KEY}:global`;
const SHORTCUTS_GROUP = PLUGIN_KEY;
const POSITION_SET = new Set(NOTIFICATION_POSITIONS);
const VARIANT_SET = new Set(NOTIFICATION_VARIANTS);
const TICK_MS = 200;
var /**
   * @type {NotificationUI | null}
   */ _ui = /*#__PURE__*/ new WeakMap(), /**
   * @type {Map<string, object>}
   */ _toasts = /*#__PURE__*/ new WeakMap(), /**
   * @type {Record<string, object[]>}
   */ _queues = /*#__PURE__*/ new WeakMap(), /**
   * Element focused before the user moved into the notification region (F6, click, or relatedTarget).
   *
   * @type {HTMLElement | null}
   */ _focusBeforeRegion = /*#__PURE__*/ new WeakMap(), /**
   * Whether notification controls use sequential tab order (after F6 or focus inside the region).
   *
   * @type {boolean}
   */ _regionTabOrderActive = /*#__PURE__*/ new WeakMap(), /**
   * @type {boolean}
   */ _tickQueued = /*#__PURE__*/ new WeakMap(), /**
   * @type {boolean}
   */ _focusScopeActive = /*#__PURE__*/ new WeakMap(), /**
   * When true, {@link Notification#registerFocusScope} `onDeactivate` restores `#focusBeforeRegion` after clearing tab order.
   *
   * @type {boolean}
   */ _notificationDeactivateRestorePrior = /*#__PURE__*/ new WeakMap(), /**
   * Effective {@link Notification.DEFAULT_SETTINGS} after the last full enable or rebuild, used to skip tearing down
   * the UI when `updateSettings` includes `notification` but those options did not change (for example a spread of
   * `getSettings()` with unrelated keys).
   *
   * @type {{ stackLimit: number, animation: boolean } | null}
   */ _lastEffectiveNotificationOptions = /*#__PURE__*/ new WeakMap(), /**
   * @returns {{ stackLimit: number, animation: boolean }}
   */ _captureEffectiveNotificationOptions = /*#__PURE__*/ new WeakSet(), /**
   * @param {{ stackLimit: number, animation: boolean }} a First snapshot.
   * @param {{ stackLimit: number, animation: boolean }} b Second snapshot.
   * @returns {boolean}
   */ _effectiveNotificationOptionsEqual = /*#__PURE__*/ new WeakSet(), /**
   * Aligns toast host `dir` and message sanitizer with the grid after any `updateSettings` call.
   */ _onAfterUpdateSettings = /*#__PURE__*/ new WeakMap(), /**
   * Builds the internal toast payload used by hooks and the UI layer.
   *
   * @param {object} raw User options passed to {@link Notification#showMessage}.
   * @returns {object} Normalized options including `id`, `variant`, `position`, `duration`, `closable`, and `actions`.
   * @throws {Error} When `message` or action entries are invalid.
   */ _normalizeOptions = /*#__PURE__*/ new WeakSet(), /**
   * @param {string} position Stack key.
   * @returns {number}
   */ _countVisibleAt = /*#__PURE__*/ new WeakSet(), /**
   * Inserts a toast into the DOM, binds hover pause for timed toasts, and runs `afterNotificationShow`.
   *
   * @param {object} normalized Validated toast options including `id` and `position`.
   */ _mountToast = /*#__PURE__*/ new WeakSet(), /**
   * Wires click handling for close and action buttons and hover pause for timed dismiss.
   *
   * @param {object} state Toast state.
   */ _bindToastEvents = /*#__PURE__*/ new WeakSet(), /**
   * Delegates clicks on the close control or action buttons.
   *
   * @param {MouseEvent} event Click event.
   * @param {object} state Toast state.
   */ _onToastClick = /*#__PURE__*/ new WeakSet(), /**
   * Sets `tabIndex` on toast controls to `-1` and clears the in-region keyboard flag.
   */ _clearNotificationRegionTabOrder = /*#__PURE__*/ new WeakSet(), /**
   * Puts every visible toast control back in the tab order after programmatic refocus (for example closing a toast).
   * Without this, controls stay at `tabIndex = -1` and **Tab** skips to the next element in the document, often
   * outside the grid.
   */ _reapplySequentialTabOrderInNotificationHost = /*#__PURE__*/ new WeakSet(), /**
   * Moves keyboard focus into the notification region (F6). Does not run when a toast opens.
   * Stores the previous `activeElement` whenever it lies outside the notification host so Escape can restore it.
   */ _enterNotificationRegion = /*#__PURE__*/ new WeakSet(), /**
   * If the grid focus scope is not already active, activates it so shortcut context matches the table after leaving
   * the notification region. `FocusScopeManager#processScopes` usually does this when focus moves; this covers cases
   * where there is no prior element or focus did not leave notification chrome.
   */ _ensureGridScopeActiveForShortcuts = /*#__PURE__*/ new WeakSet(), /**
   * Deactivates the notification focus scope (runs `onDeactivate` tab-order cleanup) and restores `#focusBeforeRegion`
   * when it is still connected (via `onDeactivate` when the scope was active).
   */ _leaveNotificationRegionRestoringPriorFocus = /*#__PURE__*/ new WeakSet(), /**
   * Leaves the notification region when focus is inside the host (**Escape**, or **Shift+Tab** from the first control).
   */ _exitNotificationRegion = /*#__PURE__*/ new WeakSet(), /**
   * Registers the notification region with the focus scope manager when toasts are present.
   */ _registerFocusScope = /*#__PURE__*/ new WeakSet(), /**
   * Registers Escape, Tab, and Shift+Tab inside the notification shortcuts context.
   */ _registerNotificationShortcuts = /*#__PURE__*/ new WeakSet(), /**
   * Unregisters notification shortcut group from the plugin context.
   */ _unregisterNotificationShortcuts = /*#__PURE__*/ new WeakSet(), /**
   * Document-level `focusin` (capture): (1) when focus moves **into** the notification host from elsewhere in the
   * wrapper, stores `#focusBeforeRegion` using `FocusEvent.relatedTarget` so **Escape** can restore after a
   * click-focused control. `FocusScopeManager` skips forwarding `focusin` while `mousedown` is down, and
   * programmatic `onActivate` from `click` runs after `activeElement` already moved into the host, so neither path
   * exposes `relatedTarget`. (2) when focus lands **outside** the host, clears sequential tab order (host `focusout`
   * misses moves via the grid in the same wrapper).
   *
   * @param {FocusEvent} event Focusin event on the root document (capture phase).
   */ _onDocumentFocusInForNotificationTabOrder = /*#__PURE__*/ new WeakMap(), /**
   * Lists focusable controls in host DOM order (stack positions, then toasts in document order).
   *
   * @returns {HTMLElement[]}
   */ _getAllFocusablesInNotificationRegion = /*#__PURE__*/ new WeakSet(), /**
   * @returns {HTMLElement | undefined}
   */ _getFirstFocusableInNotificationRegion = /*#__PURE__*/ new WeakSet(), /**
   * When sequential tab order is active, returns in-region focusables and the index of the focused control, or `null`.
   *
   * @returns {{ list: HTMLElement[], idx: number } | null}
   */ _getNotificationRegionFocusableContext = /*#__PURE__*/ new WeakSet(), /**
   * @returns {boolean}
   */ _shouldHandleTabForwardExitFromNotificationRegion = /*#__PURE__*/ new WeakSet(), /**
   * @returns {boolean}
   */ _shouldHandleShiftTabExitFromNotificationRegion = /*#__PURE__*/ new WeakSet(), /**
   * The notification host sits after the grid in the DOM; default **Tab** from the last control would leave the table.
   * Deactivates the notification scope (so `onDeactivate` clears tab order), then activates the grid scope with
   * `tab_from_above` so {@link focusGridScope} selects the cell, moves keyboard focus, and aligns shortcut context.
   *
   * Clears `#focusBeforeRegion` after the transition so a later click into a toast stores a new prior for **Escape**.
   */ _onTabForwardExitNotificationRegionToGrid = /*#__PURE__*/ new WeakSet(), /**
   * Unregisters the notification focus scope.
   */ _unregisterFocusScope = /*#__PURE__*/ new WeakSet(), /**
   * Removes toast state from the plugin map and optionally removes the toast element from the DOM.
   *
   * @param {object} state Toast state.
   * @param {boolean} removeDom Whether to remove the DOM node.
   */ _removeToastState = /*#__PURE__*/ new WeakSet(), /**
   * @param {EventTarget | null} node DOM node to test.
   * @returns {boolean}
   */ _isElementInsideNotificationHost = /*#__PURE__*/ new WeakSet(), /**
   * @param {HTMLElement} active Currently focused element.
   * @returns {boolean} Whether `active` lies inside a visible toast element.
   */ _isActiveInsideAnyRemainingToast = /*#__PURE__*/ new WeakSet(), /**
   * After a toast is removed while others remain: re-sync listening, toggle the notification focus scope so `onActivate`
   * runs again (including first-focusable when focus is on empty host chrome).
   */ _refocusFirstOpenToastAfterPartialHide = /*#__PURE__*/ new WeakSet(), /**
   * Focuses the first notification control when focus is not already inside a visible toast.
   */ _focusFirstInNotificationRegionUnlessAlreadyFocused = /*#__PURE__*/ new WeakSet(), /**
   * Whether this instance should handle document-level **F6** for the current `activeElement`.
   * When focus is inside a grid, only that instance's plugin may move focus into its notification region.
   * When focus is outside every `.ht-root-wrapper`, only a single Handsontable on the page may claim **F6** so
   * multi-instance pages do not all activate at once; with multiple roots, **F6** does nothing until focus is in a grid.
   *
   * @param {Element | null} active `document.activeElement`.
   * @returns {boolean}
   */ _shouldThisInstanceHandleF6ForActiveElement = /*#__PURE__*/ new WeakSet(), /**
   * `runOnlyIf` guard for **F6** shortcuts on the grid and `scope: 'global'` contexts (see {@link ShortcutManager}).
   * The manager only calls this after the registered `[['f6']]` combo matches (exact pressed key set, no extra modifiers).
   *
   * @returns {boolean}
   */ _shouldRunNotificationF6Shortcut = /*#__PURE__*/ new WeakSet(), /**
   * When the last toast is removed: same prior-focus restoration as **Escape** via the focus scope pipeline.
   * Further focus alignment is left to `FocusScopeManager#processScopes` after the DOM update.
   */ _restoreFocusAfterLastToastLikeEscape = /*#__PURE__*/ new WeakSet(), /**
   * After a toast is removed, moves focus to another toast if needed. When the last toast is removed, restores focus
   * the same way as **Escape** when focus was in the notification region or on the closing toast.
   *
   * @param {boolean} focusInClosingToast Whether `document.activeElement` was inside the removed toast before DOM removal.
   */ _restoreFocusIfIdle = /*#__PURE__*/ new WeakSet(), /**
   * Mounts queued toasts for one corner when a slot opens after `hide` or `stackLimit` changes.
   * `beforeNotificationShow` already ran for each queued entry in {@link Notification#showMessage}.
   *
   * @param {string} position Stack key.
   */ _drainQueueForPosition = /*#__PURE__*/ new WeakSet(), /**
   * Drops a toast id from all per-position queues when it was never mounted.
   *
   * @param {string} toastId Toast id.
   */ _removeFromQueue = /*#__PURE__*/ new WeakSet(), /**
   * Schedules a single timer pass that decrements visible countdown toasts.
   */ _queueTick = /*#__PURE__*/ new WeakSet(), /**
   * Decrements `remainingMs` for timed toasts and calls `hide` when a countdown reaches zero.
   */ _runTick = /*#__PURE__*/ new WeakSet(), /**
   * @returns {boolean} Whether any visible toast has a positive duration and is not paused while the tab is visible.
   */ _hasActiveCountdowns = /*#__PURE__*/ new WeakSet();
/**
 * @typedef {object} NotificationActionSpec
 * @property {string} label Text shown on the button.
 * @property {'primary'|'secondary'} [type] Visual style. Omit for secondary.
 * @property {function(): void} callback Invoked when the button is activated.
 */ /**
 * @plugin Notification
 * @class Notification
 *
 * @description
 * The Notification plugin shows non-blocking toast messages anchored to the Handsontable root.
 * Enable it with the {@link Options#notification} option. Toasts are exposed to assistive technologies with
 * `aria-live` and do not take keyboard focus when they appear; use **F6** to move focus into the notification region
 * for the grid that currently contains keyboard focus (with several instances on one page, each grid only handles **F6**
 * for its own focus scope, except when a single grid is on the page and focus is outside every grid).
 * **Tab** / **Shift+Tab** between controls, **Escape** to leave, and programmatic `hide` restores focus like **Escape**
 * when the last toast closes while focus is in the region.
 *
 * @example
 * ```js
 * const hot = new Handsontable(container, {
 *   data: data,
 *   notification: true,
 *   licenseKey: 'non-commercial-and-evaluation',
 * });
 * const notification = hot.getPlugin('notification');
 * notification.showMessage({ message: 'Saved.' });
 * ```
 */ export class Notification extends BasePlugin {
    static get PLUGIN_KEY() {
        return PLUGIN_KEY;
    }
    static get PLUGIN_PRIORITY() {
        return PLUGIN_PRIORITY;
    }
    static get DEFAULT_SETTINGS() {
        return {
            stackLimit: 10,
            animation: true
        };
    }
    static get SETTINGS_VALIDATORS() {
        return {
            stackLimit: (value)=>typeof value === 'number' && value > 0 && Number.isInteger(value),
            animation: (value)=>typeof value === 'boolean'
        };
    }
    /**
   * Returns whether the `notification` setting is enabled for this instance.
   *
   * @returns {boolean}
   */ isEnabled() {
        return !!this.hot.getSettings()[PLUGIN_KEY];
    }
    /**
   * Installs the notification host, document `focusin` listener (tab order + prior-focus for click paths), shortcuts
   * (**F6** via grid + global shortcut contexts, Escape, Tab, Shift+Tab), and the focus scope.
   */ enablePlugin() {
        if (this.enabled) {
            return;
        }
        if (!_class_private_field_get(this, _ui)) {
            _class_private_field_set(this, _ui, new NotificationUI({
                rootElement: this.hot.rootGridElement,
                sanitizer: this.hot.getSettings().sanitizer,
                isRtl: this.hot.isRtl()
            }));
        }
        _class_private_field_get(this, _ui).install();
        _class_private_method_get(this, _registerFocusScope, registerFocusScope).call(this);
        _class_private_method_get(this, _registerNotificationShortcuts, registerNotificationShortcuts).call(this);
        this.eventManager.addEventListener(this.hot.rootDocument, 'focusin', _class_private_field_get(this, _onDocumentFocusInForNotificationTabOrder), true);
        this.addHook('afterUpdateSettings', _class_private_field_get(this, _onAfterUpdateSettings));
        this.eventManager.addEventListener(this.hot.rootDocument, 'visibilitychange', ()=>{
            if (_class_private_method_get(this, _hasActiveCountdowns, hasActiveCountdowns).call(this)) {
                _class_private_method_get(this, _queueTick, queueTick).call(this);
            }
        });
        super.enablePlugin();
        _class_private_field_set(this, _lastEffectiveNotificationOptions, _class_private_method_get(this, _captureEffectiveNotificationOptions, captureEffectiveNotificationOptions).call(this));
    }
    /**
   * Rebuilds the plugin after settings change when notification options actually change.
   *
   * @param {object} [newSettings] Settings object passed to `updateSettings` (partial).
   */ updatePlugin(newSettings) {
        const nextEffective = _class_private_method_get(this, _captureEffectiveNotificationOptions, captureEffectiveNotificationOptions).call(this);
        const notificationKeyPresent = newSettings && typeof newSettings === 'object' && Object.prototype.hasOwnProperty.call(newSettings, PLUGIN_KEY);
        if (notificationKeyPresent && _class_private_field_get(this, _lastEffectiveNotificationOptions) !== null && _class_private_method_get(this, _effectiveNotificationOptionsEqual, effectiveNotificationOptionsEqual).call(this, _class_private_field_get(this, _lastEffectiveNotificationOptions), nextEffective)) {
            super.updatePlugin();
            return;
        }
        this.disablePlugin();
        this.enablePlugin();
        super.updatePlugin();
    }
    /**
   * Hides all toasts, removes shortcuts and listeners, and destroys the UI host.
   *
   * `hideAll()` must run before `super.disablePlugin()` because `BasePlugin.disablePlugin()` clears
   * `this.enabled` first, and `hideAll()` relies on the plugin still being enabled. The superclass
   * call then removes hooks and clears the shared `EventManager`.
   */ disablePlugin() {
        this.hideAll();
        _class_private_method_get(this, _unregisterNotificationShortcuts, unregisterNotificationShortcuts).call(this);
        _class_private_method_get(this, _unregisterFocusScope, unregisterFocusScope).call(this);
        super.disablePlugin();
        _class_private_field_get(this, _ui)?.destroy();
        _class_private_field_set(this, _ui, null);
        _class_private_field_set(this, _focusBeforeRegion, null);
        _class_private_field_set(this, _regionTabOrderActive, false);
        _class_private_field_set(this, _lastEffectiveNotificationOptions, null);
    }
    /**
   * Displays a toast. Returns the toast id, or an empty string when the toast is not shown.
   *
   * @param {object} options Toast options.
   * @param {'info' | 'success' | 'warning' | 'error'} [options.variant] Visual variant.
   * @param {string} [options.title] Optional title.
   * @param {string | HTMLElement} options.message Main message body.
   * @param {number} [options.duration] Auto-dismiss delay in ms. `0` keeps the toast until dismissed manually.
   * @param {'top-start' | 'top-end' | 'bottom-start' | 'bottom-end'} [options.position] Corner stack.
   * @param {boolean} [options.closable] Whether the close control is shown.
   * @param {NotificationActionSpec[]} [options.actions] Action buttons.
   * @returns {string}
   * @throws {Error} When `options` is invalid or actions are malformed.
   */ showMessage(options) {
        if (!this.enabled) {
            return '';
        }
        const normalized = _class_private_method_get(this, _normalizeOptions, normalizeOptions).call(this, options);
        if (this.hot.runHooks('beforeNotificationShow', normalized) === false) {
            return '';
        }
        const limit = this.getSetting('stackLimit');
        const visibleAtPosition = _class_private_method_get(this, _countVisibleAt, countVisibleAt).call(this, normalized.position);
        if (visibleAtPosition >= limit) {
            _class_private_field_get(this, _queues)[normalized.position].push(normalized);
            return normalized.id;
        }
        _class_private_method_get(this, _mountToast, mountToast).call(this, normalized);
        return normalized.id;
    }
    /**
   * Hides a toast by id.
   *
   * @param {string} id Toast id returned from {@link Notification#showMessage}.
   */ hide(id) {
        if (!this.enabled || !id) {
            return;
        }
        const state = _class_private_field_get(this, _toasts).get(id);
        if (!state) {
            _class_private_method_get(this, _removeFromQueue, removeFromQueue).call(this, id);
            return;
        }
        if (this.hot.runHooks('beforeNotificationHide', id) === false) {
            if (state.durationMs > 0 && state.remainingMs <= 0) {
                state.remainingMs = state.durationMs;
            }
            return;
        }
        const doc = this.hot.rootDocument;
        const activeBeforeRemove = doc.activeElement;
        const focusInClosingToast = activeBeforeRemove instanceof this.hot.rootWindow.HTMLElement && state.element.contains(activeBeforeRemove);
        _class_private_method_get(this, _removeToastState, removeToastState).call(this, state, true);
        this.hot.runHooks('afterNotificationHide', id);
        _class_private_method_get(this, _drainQueueForPosition, drainQueueForPosition).call(this, state.options.position);
        _class_private_method_get(this, _restoreFocusIfIdle, restoreFocusIfIdle).call(this, focusInClosingToast);
    }
    /**
   * Hides every visible toast and clears all per-position queues.
   */ hideAll() {
        if (!this.enabled) {
            return;
        }
        NOTIFICATION_POSITIONS.forEach((p)=>{
            _class_private_field_get(this, _queues)[p].length = 0;
        });
        const ids = [
            ..._class_private_field_get(this, _toasts).keys()
        ];
        ids.forEach((toastId)=>this.hide(toastId));
    }
    /**
   * Returns whether a toast is visible, or whether any toast is visible when `id` is omitted.
   *
   * @param {string} [id] Toast id.
   * @returns {boolean}
   */ isVisible(id) {
        if (id === undefined) {
            return _class_private_field_get(this, _toasts).size > 0;
        }
        return _class_private_field_get(this, _toasts).has(id);
    }
    /**
   * Returns how many toasts are waiting in per-position queues.
   *
   * @returns {number}
   */ getQueueSize() {
        return NOTIFICATION_POSITIONS.reduce((sum, p)=>sum + _class_private_field_get(this, _queues)[p].length, 0);
    }
    /**
   * Clears queues and toast state, unregisters shortcuts and focus scope, and removes the host from the DOM.
   */ destroy() {
        NOTIFICATION_POSITIONS.forEach((p)=>{
            _class_private_field_get(this, _queues)[p].length = 0;
        });
        _class_private_field_get(this, _toasts).clear();
        _class_private_method_get(this, _unregisterNotificationShortcuts, unregisterNotificationShortcuts).call(this);
        _class_private_method_get(this, _unregisterFocusScope, unregisterFocusScope).call(this);
        _class_private_field_get(this, _ui)?.destroy();
        _class_private_field_set(this, _ui, null);
        _class_private_field_set(this, _focusBeforeRegion, null);
        _class_private_field_set(this, _regionTabOrderActive, false);
        _class_private_field_set(this, _lastEffectiveNotificationOptions, null);
        super.destroy();
    }
    constructor(...args){
        super(...args), _class_private_method_init(this, _captureEffectiveNotificationOptions), _class_private_method_init(this, _effectiveNotificationOptionsEqual), _class_private_method_init(this, _normalizeOptions), _class_private_method_init(this, _countVisibleAt), _class_private_method_init(this, _mountToast), _class_private_method_init(this, _bindToastEvents), _class_private_method_init(this, _onToastClick), _class_private_method_init(this, _clearNotificationRegionTabOrder), _class_private_method_init(this, _reapplySequentialTabOrderInNotificationHost), _class_private_method_init(this, _enterNotificationRegion), _class_private_method_init(this, _ensureGridScopeActiveForShortcuts), _class_private_method_init(this, _leaveNotificationRegionRestoringPriorFocus), _class_private_method_init(this, _exitNotificationRegion), _class_private_method_init(this, _registerFocusScope), _class_private_method_init(this, _registerNotificationShortcuts), _class_private_method_init(this, _unregisterNotificationShortcuts), _class_private_method_init(this, _getAllFocusablesInNotificationRegion), _class_private_method_init(this, _getFirstFocusableInNotificationRegion), _class_private_method_init(this, _getNotificationRegionFocusableContext), _class_private_method_init(this, _shouldHandleTabForwardExitFromNotificationRegion), _class_private_method_init(this, _shouldHandleShiftTabExitFromNotificationRegion), _class_private_method_init(this, _onTabForwardExitNotificationRegionToGrid), _class_private_method_init(this, _unregisterFocusScope), _class_private_method_init(this, _removeToastState), _class_private_method_init(this, _isElementInsideNotificationHost), _class_private_method_init(this, _isActiveInsideAnyRemainingToast), _class_private_method_init(this, _refocusFirstOpenToastAfterPartialHide), _class_private_method_init(this, _focusFirstInNotificationRegionUnlessAlreadyFocused), _class_private_method_init(this, _shouldThisInstanceHandleF6ForActiveElement), _class_private_method_init(this, _shouldRunNotificationF6Shortcut), _class_private_method_init(this, _restoreFocusAfterLastToastLikeEscape), _class_private_method_init(this, _restoreFocusIfIdle), _class_private_method_init(this, _drainQueueForPosition), _class_private_method_init(this, _removeFromQueue), _class_private_method_init(this, _queueTick), _class_private_method_init(this, _runTick), _class_private_method_init(this, _hasActiveCountdowns), _class_private_field_init(this, _ui, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _toasts, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _queues, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _focusBeforeRegion, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _regionTabOrderActive, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _tickQueued, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _focusScopeActive, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _notificationDeactivateRestorePrior, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _lastEffectiveNotificationOptions, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _onAfterUpdateSettings, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _onDocumentFocusInForNotificationTabOrder, {
            writable: true,
            value: void 0
        }), _class_private_field_set(this, _ui, null), _class_private_field_set(this, _toasts, new Map()), _class_private_field_set(this, _queues, {
            'top-start': [],
            'top-end': [],
            'bottom-start': [],
            'bottom-end': []
        }), _class_private_field_set(this, _focusBeforeRegion, null), _class_private_field_set(this, _regionTabOrderActive, false), _class_private_field_set(this, _tickQueued, false), _class_private_field_set(this, _focusScopeActive, false), _class_private_field_set(this, _notificationDeactivateRestorePrior, false), _class_private_field_set(this, _lastEffectiveNotificationOptions, null), _class_private_field_set(this, _onAfterUpdateSettings, ()=>{
            if (!this.enabled || !_class_private_field_get(this, _ui)) {
                return;
            }
            const root = this.hot.rootElement;
            const dirAttr = root.getAttribute('dir');
            if (dirAttr === 'rtl' || dirAttr === 'ltr') {
                _class_private_field_get(this, _ui).setRtl(dirAttr === 'rtl');
            } else {
                _class_private_field_get(this, _ui).setRtl(this.hot.isRtl());
            }
            _class_private_field_get(this, _ui).setSanitizer(this.hot.getSettings().sanitizer);
        }), _class_private_field_set(this, _onDocumentFocusInForNotificationTabOrder, (event)=>{
            if (_class_private_field_get(this, _toasts).size === 0) {
                return;
            }
            const host = _class_private_field_get(this, _ui)?.getHost();
            const target = event.target;
            if (!(target instanceof this.hot.rootWindow.HTMLElement) || !host) {
                return;
            }
            if (host.contains(target)) {
                if (_class_private_field_get(this, _focusBeforeRegion) !== null) {
                    return;
                }
                const related = event.relatedTarget;
                if (related instanceof this.hot.rootWindow.HTMLElement && this.hot.rootWrapperElement.contains(related) && !host.contains(related)) {
                    _class_private_field_set(this, _focusBeforeRegion, related);
                }
                return;
            }
            _class_private_method_get(this, _clearNotificationRegionTabOrder, clearNotificationRegionTabOrder).call(this);
        });
    }
}
function captureEffectiveNotificationOptions() {
    return {
        stackLimit: this.getSetting('stackLimit'),
        animation: this.getSetting('animation')
    };
}
function effectiveNotificationOptionsEqual(a, b) {
    return a.stackLimit === b.stackLimit && a.animation === b.animation;
}
function normalizeOptions(raw) {
    if (!isObject(raw) || typeof raw.message !== 'string' && !(typeof HTMLElement !== 'undefined' && raw.message instanceof HTMLElement)) {
        throwWithCause('Notification.showMessage expects an object with a `message` string or HTMLElement.');
    }
    const id = `htn-${randomString()}`;
    const variant = VARIANT_SET.has(raw.variant) ? raw.variant : 'info';
    const position = POSITION_SET.has(raw.position) ? raw.position : 'bottom-end';
    const duration = typeof raw.duration === 'number' && raw.duration >= 0 ? raw.duration : 4000;
    const closable = typeof raw.closable === 'boolean' ? raw.closable : true;
    const actions = Array.isArray(raw.actions) ? raw.actions.map((a)=>{
        if (!isObject(a) || typeof a.label !== 'string' || typeof a.callback !== 'function') {
            throwWithCause('Each notification action needs `label` (string) and `callback` (function).');
        }
        const type = a.type === 'primary' ? 'primary' : 'secondary';
        return {
            label: a.label,
            type,
            callback: a.callback
        };
    }) : [];
    return {
        id,
        variant,
        title: typeof raw.title === 'string' ? raw.title : undefined,
        message: raw.message,
        duration,
        position,
        closable,
        actions
    };
}
function countVisibleAt(position) {
    let n = 0;
    _class_private_field_get(this, _toasts).forEach((state)=>{
        if (state.options.position === position) {
            n += 1;
        }
    });
    return n;
}
function mountToast(normalized) {
    const closeLabel = this.hot.getTranslatedPhrase(C.NOTIFICATION_BUTTONS_CLOSE);
    const animation = this.getSetting('animation');
    const { element } = _class_private_field_get(this, _ui).createToastElement(normalized, closeLabel, animation);
    const stack = _class_private_field_get(this, _ui).getStack(normalized.position);
    if (!stack) {
        throwWithCause(`Unknown notification position "${normalized.position}".`);
    }
    if (normalized.position.startsWith('top')) {
        stack.prepend(element);
    } else {
        stack.appendChild(element);
    }
    if (normalized.position.startsWith('bottom')) {
        const win = this.hot.rootWindow;
        win.requestAnimationFrame(()=>{
            if (!this.enabled) {
                return;
            }
            stack.scrollTop = stack.scrollHeight;
        });
    }
    const durationMs = normalized.duration;
    const state = {
        id: normalized.id,
        options: normalized,
        element,
        durationMs,
        remainingMs: durationMs,
        paused: false
    };
    _class_private_field_get(this, _toasts).set(normalized.id, state);
    _class_private_method_get(this, _bindToastEvents, bindToastEvents).call(this, state);
    if (_class_private_field_get(this, _regionTabOrderActive)) {
        _class_private_method_get(this, _reapplySequentialTabOrderInNotificationHost, reapplySequentialTabOrderInNotificationHost).call(this);
    }
    this.hot.runHooks('afterNotificationShow', normalized.id, normalized);
    if (durationMs > 0) {
        _class_private_method_get(this, _queueTick, queueTick).call(this);
    }
}
function bindToastEvents(state) {
    state.toastEventDisposers = [
        this.eventManager.addEventListener(state.element, 'click', (event)=>_class_private_method_get(this, _onToastClick, onToastClick).call(this, event, state)),
        this.eventManager.addEventListener(state.element, 'mouseenter', ()=>{
            state.paused = true;
        }),
        this.eventManager.addEventListener(state.element, 'mouseleave', ()=>{
            state.paused = false;
            if (state.durationMs > 0 && !this.hot.rootDocument.hidden) {
                _class_private_method_get(this, _queueTick, queueTick).call(this);
            }
        })
    ];
}
function onToastClick(event, state) {
    const target = event.target;
    if (!(target instanceof this.hot.rootWindow.HTMLElement)) {
        return;
    }
    if (target.closest(`.${NOTIFICATION_CLASS_NAME}__close`)) {
        this.hide(state.id);
        return;
    }
    const actionHost = target.closest('[data-ht-notification-action]');
    if (!actionHost || !state.element.contains(actionHost)) {
        return;
    }
    const index = Number.parseInt(actionHost.dataset.htNotificationAction, 10);
    const action = state.options.actions[index];
    if (action) {
        action.callback();
    }
}
function clearNotificationRegionTabOrder() {
    const host = _class_private_field_get(this, _ui)?.getHost();
    if (host) {
        NotificationUI.setSequentialFocusWithinHost(host, false);
    }
    _class_private_field_set(this, _regionTabOrderActive, false);
}
function reapplySequentialTabOrderInNotificationHost() {
    const host = _class_private_field_get(this, _ui)?.getHost();
    if (!host || _class_private_field_get(this, _toasts).size === 0) {
        return;
    }
    NotificationUI.setSequentialFocusWithinHost(host, true);
    _class_private_field_set(this, _regionTabOrderActive, true);
}
function enterNotificationRegion() {
    const host = _class_private_field_get(this, _ui)?.getHost();
    if (!host || _class_private_field_get(this, _toasts).size === 0) {
        return;
    }
    const doc = this.hot.rootDocument;
    const active = doc.activeElement;
    if (active instanceof this.hot.rootWindow.HTMLElement && !host.contains(active)) {
        _class_private_field_set(this, _focusBeforeRegion, active);
    }
    this.hot.listen();
    this.hot.getFocusScopeManager().activateScope(PLUGIN_KEY);
}
function ensureGridScopeActiveForShortcuts() {
    const fsm = this.hot.getFocusScopeManager();
    if (fsm.getActiveScopeId() !== GRID_SCOPE) {
        fsm.activateScope(GRID_SCOPE);
    }
}
function leaveNotificationRegionRestoringPriorFocus() {
    const fsm = this.hot.getFocusScopeManager();
    _class_private_field_set(this, _notificationDeactivateRestorePrior, true);
    if (fsm.getActiveScopeId() === PLUGIN_KEY) {
        fsm.deactivateScope(PLUGIN_KEY);
    } else {
        _class_private_field_set(this, _notificationDeactivateRestorePrior, false);
        _class_private_method_get(this, _clearNotificationRegionTabOrder, clearNotificationRegionTabOrder).call(this);
        const prev = _class_private_field_get(this, _focusBeforeRegion);
        _class_private_field_set(this, _focusBeforeRegion, null);
        if (prev?.isConnected) {
            this.hot.getFocusManager().focusElement(prev, {
                preventScroll: true
            });
        }
        _class_private_method_get(this, _ensureGridScopeActiveForShortcuts, ensureGridScopeActiveForShortcuts).call(this);
    }
}
function exitNotificationRegion() {
    const doc = this.hot.rootDocument;
    const host = _class_private_field_get(this, _ui)?.getHost();
    if (!host?.contains(doc.activeElement)) {
        return;
    }
    _class_private_method_get(this, _leaveNotificationRegionRestoringPriorFocus, leaveNotificationRegionRestoringPriorFocus).call(this);
}
function registerFocusScope() {
    if (_class_private_field_get(this, _focusScopeActive)) {
        return;
    }
    this.hot.getFocusScopeManager().registerScope(PLUGIN_KEY, _class_private_field_get(this, _ui).getHost(), {
        shortcutsContextName: SHORTCUTS_CONTEXT_NAME,
        runOnlyIf: ()=>_class_private_field_get(this, _toasts).size > 0,
        enableFocusCatchers: false,
        onActivate: ()=>{
            const host = _class_private_field_get(this, _ui)?.getHost();
            if (!host) {
                return;
            }
            _class_private_method_get(this, _reapplySequentialTabOrderInNotificationHost, reapplySequentialTabOrderInNotificationHost).call(this);
            _class_private_method_get(this, _focusFirstInNotificationRegionUnlessAlreadyFocused, focusFirstInNotificationRegionUnlessAlreadyFocused).call(this);
        },
        onDeactivate: ()=>{
            _class_private_method_get(this, _clearNotificationRegionTabOrder, clearNotificationRegionTabOrder).call(this);
            const restorePrior = _class_private_field_get(this, _notificationDeactivateRestorePrior);
            if (restorePrior) {
                _class_private_field_set(this, _notificationDeactivateRestorePrior, false);
                const prev = _class_private_field_get(this, _focusBeforeRegion);
                _class_private_field_set(this, _focusBeforeRegion, null);
                if (prev?.isConnected) {
                    this.hot.getFocusManager().focusElement(prev, {
                        preventScroll: true
                    });
                }
                _class_private_method_get(this, _ensureGridScopeActiveForShortcuts, ensureGridScopeActiveForShortcuts).call(this);
            }
        }
    });
    _class_private_field_set(this, _focusScopeActive, true);
}
function registerNotificationShortcuts() {
    const manager = this.hot.getShortcutManager();
    const pluginContext = manager.getContext(SHORTCUTS_CONTEXT_NAME) ?? manager.addContext(SHORTCUTS_CONTEXT_NAME);
    const globalContext = manager.getOrCreateContext(SHORTCUTS_GLOBAL_CONTEXT_NAME, 'global');
    const gridContext = manager.getContext(GRID_SCOPE);
    const f6Shortcut = {
        keys: [
            [
                'f6'
            ]
        ],
        preventDefault: true,
        callback: ()=>{
            _class_private_method_get(this, _enterNotificationRegion, enterNotificationRegion).call(this);
        },
        runOnlyIf: ()=>_class_private_method_get(this, _shouldRunNotificationF6Shortcut, shouldRunNotificationF6Shortcut).call(this),
        group: SHORTCUTS_GROUP
    };
    globalContext.addShortcut(f6Shortcut);
    if (gridContext) {
        gridContext.addShortcut(f6Shortcut);
    }
    pluginContext.addShortcut({
        keys: [
            [
                'Escape'
            ]
        ],
        callback: ()=>_class_private_method_get(this, _exitNotificationRegion, exitNotificationRegion).call(this),
        runOnlyIf: ()=>_class_private_field_get(this, _ui)?.getHost()?.contains(this.hot.rootDocument.activeElement) === true,
        group: SHORTCUTS_GROUP
    });
    pluginContext.addShortcut({
        keys: [
            [
                'Tab'
            ]
        ],
        preventDefault: true,
        callback: ()=>_class_private_method_get(this, _onTabForwardExitNotificationRegionToGrid, onTabForwardExitNotificationRegionToGrid).call(this),
        runOnlyIf: ()=>_class_private_method_get(this, _shouldHandleTabForwardExitFromNotificationRegion, shouldHandleTabForwardExitFromNotificationRegion).call(this),
        group: SHORTCUTS_GROUP
    });
    pluginContext.addShortcut({
        keys: [
            [
                'Shift',
                'Tab'
            ]
        ],
        preventDefault: true,
        callback: ()=>_class_private_method_get(this, _exitNotificationRegion, exitNotificationRegion).call(this),
        runOnlyIf: ()=>_class_private_method_get(this, _shouldHandleShiftTabExitFromNotificationRegion, shouldHandleShiftTabExitFromNotificationRegion).call(this),
        group: SHORTCUTS_GROUP
    });
}
function unregisterNotificationShortcuts() {
    const sm = this.hot.getShortcutManager();
    sm.getContext(SHORTCUTS_CONTEXT_NAME)?.removeShortcutsByGroup(SHORTCUTS_GROUP);
    sm.getContext(SHORTCUTS_GLOBAL_CONTEXT_NAME)?.removeShortcutsByGroup(SHORTCUTS_GROUP);
    sm.getContext(GRID_SCOPE)?.removeShortcutsByGroup(SHORTCUTS_GROUP);
}
function getAllFocusablesInNotificationRegion() {
    const host = _class_private_field_get(this, _ui)?.getHost();
    if (!host) {
        return [];
    }
    const toasts = [
        ...host.querySelectorAll(`.${NOTIFICATION_CLASS_NAME}__toast`)
    ];
    const results = [];
    for(let i = 0; i < toasts.length; i += 1){
        results.push(...NotificationUI.getFocusables(toasts[i]));
    }
    return results;
}
function getFirstFocusableInNotificationRegion() {
    const all = _class_private_method_get(this, _getAllFocusablesInNotificationRegion, getAllFocusablesInNotificationRegion).call(this);
    return all[0];
}
function getNotificationRegionFocusableContext() {
    if (_class_private_field_get(this, _toasts).size === 0) {
        return null;
    }
    const active = this.hot.rootDocument.activeElement;
    const host = _class_private_field_get(this, _ui)?.getHost();
    if (!(active instanceof this.hot.rootWindow.HTMLElement) || !host?.contains(active)) {
        return null;
    }
    const list = _class_private_method_get(this, _getAllFocusablesInNotificationRegion, getAllFocusablesInNotificationRegion).call(this);
    if (list.length === 0) {
        return null;
    }
    const idx = list.indexOf(active);
    if (idx === -1) {
        return null;
    }
    if (!_class_private_field_get(this, _regionTabOrderActive)) {
        _class_private_method_get(this, _reapplySequentialTabOrderInNotificationHost, reapplySequentialTabOrderInNotificationHost).call(this);
    }
    return {
        list,
        idx
    };
}
function shouldHandleTabForwardExitFromNotificationRegion() {
    const ctx = _class_private_method_get(this, _getNotificationRegionFocusableContext, getNotificationRegionFocusableContext).call(this);
    return ctx !== null && ctx.idx === ctx.list.length - 1;
}
function shouldHandleShiftTabExitFromNotificationRegion() {
    const ctx = _class_private_method_get(this, _getNotificationRegionFocusableContext, getNotificationRegionFocusableContext).call(this);
    return ctx !== null && ctx.idx === 0;
}
function onTabForwardExitNotificationRegionToGrid() {
    const fsm = this.hot.getFocusScopeManager();
    _class_private_field_set(this, _notificationDeactivateRestorePrior, false);
    if (fsm.getActiveScopeId() === PLUGIN_KEY) {
        fsm.deactivateScope(PLUGIN_KEY);
    } else {
        _class_private_method_get(this, _clearNotificationRegionTabOrder, clearNotificationRegionTabOrder).call(this);
    }
    this.hot.listen();
    fsm.activateScope(GRID_SCOPE, FOCUS_SOURCES.TAB_FROM_ABOVE);
    _class_private_field_set(this, _focusBeforeRegion, null);
}
function unregisterFocusScope() {
    if (!_class_private_field_get(this, _focusScopeActive)) {
        return;
    }
    this.hot.getFocusScopeManager().unregisterScope(PLUGIN_KEY);
    _class_private_field_set(this, _focusScopeActive, false);
}
function removeToastState(state, removeDom) {
    if (state.toastEventDisposers) {
        state.toastEventDisposers.forEach((dispose)=>dispose());
        state.toastEventDisposers = null;
    }
    _class_private_field_get(this, _toasts).delete(state.id);
    if (removeDom) {
        state.element.remove();
    }
}
function isElementInsideNotificationHost(node) {
    const host = _class_private_field_get(this, _ui)?.getHost();
    if (!host) {
        return false;
    }
    return node instanceof this.hot.rootWindow.HTMLElement && host.contains(node);
}
function isActiveInsideAnyRemainingToast(active) {
    let inside = false;
    _class_private_field_get(this, _toasts).forEach((state)=>{
        if (state.element.contains(active)) {
            inside = true;
        }
    });
    return inside;
}
function refocusFirstOpenToastAfterPartialHide() {
    this.hot.listen();
    const fsm = this.hot.getFocusScopeManager();
    if (fsm.getActiveScopeId() === PLUGIN_KEY) {
        fsm.deactivateScope(PLUGIN_KEY);
    }
    fsm.activateScope(PLUGIN_KEY);
}
function focusFirstInNotificationRegionUnlessAlreadyFocused() {
    const doc = this.hot.rootDocument;
    if (!this.enabled || _class_private_field_get(this, _toasts).size === 0) {
        return;
    }
    if (_class_private_method_get(this, _isActiveInsideAnyRemainingToast, isActiveInsideAnyRemainingToast).call(this, doc.activeElement)) {
        return;
    }
    const first = _class_private_method_get(this, _getFirstFocusableInNotificationRegion, getFirstFocusableInNotificationRegion).call(this);
    if (first) {
        this.hot.getFocusManager().focusElement(first);
    }
}
function shouldThisInstanceHandleF6ForActiveElement(active) {
    if (!(active instanceof this.hot.rootWindow.HTMLElement)) {
        return false;
    }
    const ownerWrapper = active.closest('.ht-root-wrapper');
    if (ownerWrapper !== null) {
        return ownerWrapper === this.hot.rootWrapperElement;
    }
    const roots = this.hot.rootDocument.querySelectorAll('.ht-root-wrapper');
    return roots.length <= 1;
}
function shouldRunNotificationF6Shortcut() {
    if (!this.enabled || _class_private_field_get(this, _toasts).size === 0) {
        return false;
    }
    const host = _class_private_field_get(this, _ui)?.getHost();
    if (!host) {
        return false;
    }
    const active = this.hot.rootDocument.activeElement;
    if (active instanceof this.hot.rootWindow.HTMLElement && host.contains(active)) {
        return false;
    }
    return _class_private_method_get(this, _shouldThisInstanceHandleF6ForActiveElement, shouldThisInstanceHandleF6ForActiveElement).call(this, active);
}
function restoreFocusAfterLastToastLikeEscape() {
    _class_private_method_get(this, _leaveNotificationRegionRestoringPriorFocus, leaveNotificationRegionRestoringPriorFocus).call(this);
}
function restoreFocusIfIdle(focusInClosingToast = false) {
    const doc = this.hot.rootDocument;
    const host = _class_private_field_get(this, _ui)?.getHost();
    const active = doc.activeElement;
    if (_class_private_field_get(this, _toasts).size > 0) {
        const activeInHost = active instanceof this.hot.rootWindow.HTMLElement && host?.contains(active) === true;
        if (activeInHost && !_class_private_method_get(this, _isActiveInsideAnyRemainingToast, isActiveInsideAnyRemainingToast).call(this, active)) {
            _class_private_method_get(this, _refocusFirstOpenToastAfterPartialHide, refocusFirstOpenToastAfterPartialHide).call(this);
        } else if (!activeInHost && focusInClosingToast) {
            _class_private_method_get(this, _refocusFirstOpenToastAfterPartialHide, refocusFirstOpenToastAfterPartialHide).call(this);
        }
        return;
    }
    const hadRegionFocus = _class_private_field_get(this, _regionTabOrderActive);
    const focusStillInNotificationChrome = _class_private_method_get(this, _isElementInsideNotificationHost, isElementInsideNotificationHost).call(this, doc.activeElement);
    const shouldRestoreLikeEscape = hadRegionFocus || focusInClosingToast || focusStillInNotificationChrome;
    if (!shouldRestoreLikeEscape) {
        return;
    }
    _class_private_method_get(this, _restoreFocusAfterLastToastLikeEscape, restoreFocusAfterLastToastLikeEscape).call(this);
}
function drainQueueForPosition(position) {
    const limit = this.getSetting('stackLimit');
    while(_class_private_field_get(this, _queues)[position].length > 0 && _class_private_method_get(this, _countVisibleAt, countVisibleAt).call(this, position) < limit){
        const next = _class_private_field_get(this, _queues)[position].shift();
        _class_private_method_get(this, _mountToast, mountToast).call(this, next);
    }
}
function removeFromQueue(toastId) {
    NOTIFICATION_POSITIONS.forEach((p)=>{
        const q = _class_private_field_get(this, _queues)[p];
        const idx = q.findIndex((entry)=>entry.id === toastId);
        if (idx >= 0) {
            q.splice(idx, 1);
        }
    });
}
function queueTick() {
    if (_class_private_field_get(this, _tickQueued) || !this.enabled) {
        return;
    }
    _class_private_field_set(this, _tickQueued, true);
    this.hot._registerTimeout(()=>{
        _class_private_field_set(this, _tickQueued, false);
        if (!this.enabled) {
            return;
        }
        _class_private_method_get(this, _runTick, runTick).call(this);
        if (_class_private_method_get(this, _hasActiveCountdowns, hasActiveCountdowns).call(this)) {
            _class_private_method_get(this, _queueTick, queueTick).call(this);
        }
    }, TICK_MS);
}
function runTick() {
    const doc = this.hot.rootDocument;
    const tabActive = !doc.hidden;
    const toHide = [];
    _class_private_field_get(this, _toasts).forEach((state)=>{
        if (state.durationMs <= 0) {
            return;
        }
        if (state.paused || !tabActive) {
            return;
        }
        state.remainingMs -= TICK_MS;
        if (state.remainingMs <= 0) {
            toHide.push(state.id);
        }
    });
    toHide.forEach((id)=>this.hide(id));
}
function hasActiveCountdowns() {
    const doc = this.hot.rootDocument;
    if (doc.hidden) {
        return false;
    }
    let active = false;
    _class_private_field_get(this, _toasts).forEach((s)=>{
        if (s.durationMs > 0 && !s.paused) {
            active = true;
        }
    });
    return active;
}
