//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// TypeScript support for Blazor-WASM application | Author: Sergei Y.Kitaev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Modal dialog frame support (user dialog at 1-st level) — instance class:
class ModalDialogFrame {
    constructor() {
        this.DialogDIV = HById.ElementOf('modal_dialog_DialogDIV', 'DIV');
        this.VeilDIV = HById.ElementOf('modal_dialog_VeilDIV', 'DIV');
        this.SpaceDIV = HById.ElementOf('modal_dialog_SpaceDIV', 'DIV');
    }
    ContainsFocus() {
        return HElement.ContainsFocus(this.DialogDIV);
    }
    ShowDiv(divElement) {
        let style = divElement.style;
        style.left = style.top = '0';
        style.right = Magistral.GetPageContentWidthDiff() + 'px';
        style.bottom = '';
        style.height = '100%';
        style.overflowY = 'hidden';
        style.visibility = 'visible';
    }
    CollapseDiv(divElement) {
        divElement.style.visibility = 'collapse';
    }
    Window_OnResize() {
        var fullSpaceRect = this.SpaceDIV.getBoundingClientRect();
        var style = this.DialogDIV.style;
        style.maxWidth = fullSpaceRect.width + 'px';
        style.maxHeight = fullSpaceRect.height + 'px';
    }
    HandleEarly_Window_OnFocus() {
    }
    HandleLate_Window_OnFocus() {
        let activeElement = HDoc.FocusedElement();
        if (activeElement && this.DialogDIV.contains(activeElement))
            this.LastFocusedElem = activeElement;
        else if (this.LastFocusedElem)
            this.LastFocusedElem.focus();
    }
    RecoverFocus() {
        if (this.LastFocusedElem)
            this.LastFocusedElem.focus();
    }
    Open() {
        this.ShowDiv(this.VeilDIV);
        this.ShowDiv(this.SpaceDIV);
        this.Window_OnResize();
    }
    Close() {
        this.CollapseDiv(this.SpaceDIV);
        this.CollapseDiv(this.VeilDIV);
        this.LastFocusedElem = null;
    }
    static IsOpen() {
        return ModalDialogFrame.CR != null;
    }
    static Current() {
        let curr = ModalDialogFrame.CR;
        if (!curr)
            throw new Error('Dialog is not open (\"ModalDialogFrame\").');
        return curr;
    }
    static DialogSpaceWidth() {
        return ModalDialogFrame.Current().SpaceDIV.getBoundingClientRect().width;
    }
    static Window_OnResize() {
        let curr = ModalDialogFrame.CR;
        if (curr != null)
            curr.Window_OnResize();
    }
    static HandleEarly_Window_OnFocus() {
        let curr = ModalDialogFrame.CR;
        if (curr != null)
            curr.HandleEarly_Window_OnFocus();
    }
    static HandleLate_Window_OnFocus() {
        let curr = ModalDialogFrame.CR;
        if (curr != null)
            curr.HandleLate_Window_OnFocus();
    }
    static RecoverFocus() {
        let curr = ModalDialogFrame.CR;
        if (curr != null)
            curr.RecoverFocus();
    }
    static ContainsFocus() {
        let curr = ModalDialogFrame.CR;
        return curr ? curr.ContainsFocus() : false;
    }
    static LastFocused() {
        let curr = ModalDialogFrame.CR;
        return curr ? curr.LastFocusedElem : null;
    }
    static Open() {
        ModalDialogFrame.Close();
        let inst = new ModalDialogFrame();
        inst.Open();
        ModalDialogFrame.CR = inst;
    }
    static Close() {
        let curr = ModalDialogFrame.CR;
        if (curr) {
            curr.Close();
            ModalDialogFrame.CR = null;
        }
    }
} // ModalDialogFrame
//==================================================================================================
// MODAL DIALOG FRAME SUPPORT — INITIALIZATION:
//--------------------------------------------------------------------------------------------------
window.addEventListener('resize', ModalDialogFrame.Window_OnResize, true);
window.addEventListener('click', ModalDialogFrame.RecoverFocus, true);
window.addEventListener('contextmenu', ModalDialogFrame.RecoverFocus, true);
window.addEventListener('auxclick', ModalDialogFrame.RecoverFocus, true);
//==================================================================================================
// MODAL DIALOG FRAME SUPPORT — FUNCTIONS:
//--------------------------------------------------------------------------------------------------
function ModalDialogFrame_Open() {
    ModalDialogFrame.Open();
}
function ModalDialogFrame_Close() {
    ModalDialogFrame.Close();
}
//==================================================================================================
//# sourceMappingURL=ModalDialogFrame.js.map