// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
    devtools: {
        enabled: false,
        timeline: {
            enabled: true
        }
    },

    modules: ['@vite-pwa/nuxt','@pinia/nuxt', '@nuxt/ui-pro', "nuxt-editorjs", '@nuxtjs/fontaine', 'nuxt-viewport', '@nuxtjs/leaflet', '@vueuse/nuxt'],

    ssr: false,

    imports: {
        dirs: ['stores']
    },

    components: [{
        path: '~/components'
    }],

    css: ['~/assets/css/main.css'],

    build: {
        transpile: ['@vuepic/vue-datepicker','@tiptap/vue-3','@tiptap/extension-code-block-lowlight',
            'lowlight',]
    },


    routeRules: {
        '/printing': {ssr: false}

    },

    vite: {
        resolve: {
            dedupe: [
                'vue',
                '@tiptap/vue-3',
                'prosemirror-model',
                'prosemirror-view',
                'prosemirror-state',
                'prosemirror-commands',
                'prosemirror-schema-list',
                'prosemirror-transform',
                'prosemirror-history',
                'prosemirror-gapcursor',
                'prosemirror-dropcursor',
                'prosemirror-tables'
            ]
        },
        optimizeDeps: {
            include: [
                "@editorjs/editorjs",
                "dayjs",
                '@tiptap/vue-3',
                '@tiptap/extension-code-block-lowlight',
                'lowlight',
                'vue',
                '@tiptap/extension-task-item',
                '@tiptap/extension-task-list',
                '@tiptap/extension-table',
                '@tiptap/extension-mention',
                'prosemirror-model',
                'prosemirror-view',
                'prosemirror-state',
                'prosemirror-commands',
                'prosemirror-transform',
                'tippy.js',
                'prosemirror-tables',
            ],
        },
    },

    colorMode: {
        preference: 'system'
    },

    runtimeConfig: {

        public: {
            apiBase: '',
            pdfLicense: '',
            matrixElementUrl: process.env.NUXT_PUBLIC_MATRIX_ELEMENT_URL || 'http://localhost:8080'
        }
    },

    pwa: {
        /* Automatische Updates des Service Workers (optional, aber empfohlen) */
        registerType: 'autoUpdate',

        manifest: {
            name: 'FEDEO',
            short_name: 'FEDEO',
            description: 'FEDEO',
            theme_color: '#69c350',
            background_color: '#ffffff',

            /* WICHTIG: Dies sorgt dafür, dass die URL-Leiste verschwindet */
            display: 'standalone',

            /* Icons sind essentiell für den Home Screen */
            icons: [
                {
                    src: '192.png',
                    sizes: '192x192',
                    type: 'image/png'
                },
                {
                    src: '512.png',
                    sizes: '512x512',
                    type: 'image/png'
                },
                {
                    src: '512.png',
                    sizes: '512x512',
                    type: 'image/png',
                    purpose: 'any maskable'
                }
            ]
        },

        /* WICHTIG FÜR SAFARI / iOS */
        workbox: {
            navigateFallback: '/',
        },

        devOptions: {
            enabled: false,
            type: 'module',
        },
    },

    app: {
        head: {
            meta: [
                // Sagt iOS, dass es eine WebApp ist
                { name: 'apple-mobile-web-app-capable', content: 'yes' },
                // Steuert die Farbe der Statusleiste (weiß, schwarz oder transparent)
                { name: 'apple-mobile-web-app-status-bar-style', content: 'black-translucent' },
                // Name der App unter dem Icon
                { name: 'apple-mobile-web-app-title', content: 'FEDEO' },
            ],
            link: [
                // Wichtig: Das Icon für den Home Screen
                { rel: 'apple-touch-icon', href: '/512.png' }
            ]
        }
    },

    compatibilityDate: '2024-12-18'
})
