/*
 * ============================================================
 * OPENAI BD USER APPLICATION
 * CLEAN FOUNDATION
 * ============================================================
 *
 * Old user feature engines removed.
 *
 * New modules will be built here:
 *
 * 01. Composer / Send
 * 02. Voice
 * 03. Attachment / File Upload
 * 04. Image
 * 05. Files / Library
 * 06. Projects
 * 07. Work
 * 08. Video
 * 09. Plugins
 * 10. Recent / Pin
 *
 * Admin configuration remains the source of truth.
 */

(() => {
    'use strict';

    /*
     * Sidebar only.
     * No AI/chat/file/voice engine is active yet.
     */

    const openButton =
        document.querySelector('[data-open-sidebar]');

    const closeButtons =
        document.querySelectorAll(
            '[data-close-sidebar]'
        );

    const sidebar =
        document.querySelector('.sidebar');

    const openSidebar = () => {
        document.body.classList.add(
            'sidebar-open'
        );
    };

    const closeSidebar = () => {
        document.body.classList.remove(
            'sidebar-open'
        );
    };

    openButton?.addEventListener(
        'click',
        openSidebar
    );

    closeButtons.forEach((button) => {
        button.addEventListener(
            'click',
            closeSidebar
        );
    });

    document.addEventListener(
        'keydown',
        (event) => {
            if (event.key === 'Escape') {
                closeSidebar();
            }
        }
    );

    window.OpenAIBD = {
        version: 'user-foundation-v1',
        ready: true
    };

    console.info(
        'OpenAI BD clean user foundation loaded.'
    );
})();
