// CSS imports - ALLEMAAL hier importeren, niet in main.css!
import 'bootstrap/dist/css/bootstrap.min.css';
import 'tabulator-tables/dist/css/tabulator_bootstrap5.min.css';
import 'select2/dist/css/select2.min.css';
import 'vanilla-jsoneditor/themes/jse-theme-dark.css';
import 'prismjs/themes/prism.css';
import 'highlight.js/styles/default.css';
import 'nouislider/dist/nouislider.css';

// Lokale CSS files
// Material Kit Pro
import '../../../eveai_app/static/assets/css/material-kit-pro.css';
import '../../../eveai_app/static/assets/css/nucleo-icons.css';
import '../../../eveai_app/static/assets/css/nucleo-svg.css';
// Eveai customisations
import '../../../eveai_app/static/assets/css/eveai.css';
import '../../../eveai_app/static/assets/css/eveai-chat-session-view.css';
import '../../../eveai_app/static/assets/css/eveai-forms.css'
import '../../../eveai_app/static/assets/css/eveai-json-editor.css'
import '../../../eveai_app/static/assets/css/eveai-markdown.css'
import '../../../eveai_app/static/assets/css/eveai-select2.css'
import '../../../eveai_app/static/assets/css/eveai-tabulator.css'
import '../../../eveai_app/static/assets/css/eveai-responsive-table.css'
import '../../../eveai_app/static/assets/css/eveai-consent-viewer.css'

// Javascript Libraries

// jQuery
import $ from 'jquery';
window.jQuery = $;
window.$ = $;

import * as Popper from '@popperjs/core';
window.Popper = Popper;

import * as bootstrap from 'bootstrap'; // Importeer Bootstrap als object
window.bootstrap = bootstrap; // Maak bootstrap globaal beschikbaar

import DataTable from 'datatables.net';
window.DataTable = DataTable;

import 'select2';

import { createJSONEditor } from 'vanilla-jsoneditor';
window.createJSONEditor = createJSONEditor;

// Importeer Tabulator en maak deze globaal beschikbaar
import { TabulatorFull } from 'tabulator-tables';
window.Tabulator = TabulatorFull;

import './tabulator-setup.js';

// Importeer extra tabulator setup script
import '../../../eveai_app/static/assets/js/eveai-tabulator-setup.js';

// Controleer of alle benodigde Tabulator modules correct zijn geladen
document.addEventListener('DOMContentLoaded', function() {
    if (typeof window.Tabulator === 'function') {
        console.log(`Tabulator versie: ${window.Tabulator.version || 'onbekend'}`);

        // Zorg ervoor dat benodigde modules beschikbaar zijn
        window.Tabulator.modules = window.Tabulator.modules || {};
        window.Tabulator.modules.format = window.Tabulator.modules.format || { formatters: {} };
        window.Tabulator.modules.sort = window.Tabulator.modules.sort || { sorters: {} };
        window.Tabulator.modules.filter = window.Tabulator.modules.filter || { filters: {} };
    }
});

import { createApp } from 'vue';
window.Vue = { createApp };

import { marked } from 'marked';
window.marked = marked;

import Typed from 'typed.js';
window.Typed = Typed;

import Prism from 'prismjs';
import 'prismjs/components/prism-javascript';
import 'prismjs/components/prism-json';
import 'prismjs/components/prism-python';
import 'prismjs/components/prism-bash';
window.Prism = Prism;

import hljs from 'highlight.js';
window.hljs = hljs;

import * as anime from 'animejs';
window.anime = anime;

import noUiSlider from 'nouislider';
window.noUiSlider = noUiSlider;

// Material Kit Pro main script (blijft local file)
import '../../../eveai_app/static/assets/js/material-kit-pro.js';

// Conditioneel laden van chat client code
// if (document.querySelector('.chat-container') ||
//     window.location.pathname.includes('/chat') ||
//     document.body.classList.contains('chat-page')) {
//
//     import('./chat-client.js').then(() => {
//         console.log('Chat client modules dynamisch geladen.');
//     }).catch(error => {
//         console.error('Fout bij laden chat client modules:', error);
//     });
// }

// Eveai Consent Viewer
import '../../../eveai_app/static/assets/js/eveai-consent-viewer.js'

// Eventueel een log om te bevestigen dat de bundel is geladen
console.log('JavaScript en CSS bibliotheken gebundeld en geladen via main.js.');
