let sideBarZIndex = 892, sideBarShownList = [];
window.addEventListener('load', () => {
    document.querySelectorAll('.side-bar').forEach((sidebar) => {
        let width = sidebar.clientWidth;
        sidebar.style.right = -width + 'px';
    });
});
let showSideBar = (index, hideTop, callback) => {
    let sidebar = document.querySelector(`.side-bar[data-index="${index}"]`);
    if (sidebar.classList.contains('side-bar-show')) {
        return;
    }
    if (hideTop) {
        hideTopSideBar();
    }
    sidebar.style.right = 0;
    sidebar.style.zIndex = sideBarZIndex++;
    sidebar.classList.add('side-bar-show');
    if (sidebar.attributes['data-width']) {
        sidebar.style.width = sidebar.attributes['data-width'].value;
    }
    sideBarShownList.push(sidebar);
    document.querySelector('.side-bar-shadow').style.display = 'block';
    if (callback && typeof callback === 'function') {
        callback();
    }
}
let hideTopSideBar = () => {
    let lastSideBar = sideBarShownList.pop();
    if (!lastSideBar) {
        return;
    }
    lastSideBar.classList.remove('side-bar-show');
    lastSideBar.style.right = -lastSideBar.clientWidth + 'px';
    sideBarZIndex--;
    if (sideBarShownList.length) {
        return;
    }
    document.querySelector('.side-bar-shadow').style.display = 'none';
}
document.querySelector('.side-bar-shadow').addEventListener('click', () => {
    hideTopSideBar();
});