@filamentScripts
@livewireScripts
@if(config('wave.dev_bar'))
    @include('theme::partials.dev_bar')
@endif

<script>
    // Initialize Alpine.js toast store
    document.addEventListener('alpine:init', () => {
        Alpine.store('toast', {
            show: false,
            type: 'info',
            message: '',
            
            open() {
                this.show = true;
            },
            
            close() {
                this.show = false;
            },
            
            update(data) {
                this.type = data.type || 'info';
                this.message = data.message || '';
                this.show = data.show || false;
            }
        });
    });

    // Listen for toast events from Livewire
    document.addEventListener('livewire:init', () => {
        Livewire.on('toast', (data) => {
            if (window.popToast) {
                window.popToast(data.type, data.message);
            } else {
                Alpine.store('toast').update({
                    type: data.type,
                    message: data.message,
                    show: true
                });
            }
        });
    });
</script>

{{-- @yield('javascript') --}}

@if(setting('site.google_analytics_tracking_id', ''))
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id={{ setting('site.google_analytics_tracking_id') }}"></script>
    <script>
        window.dataLayer = window.dataLayer || [];
        function gtag(){dataLayer.push(arguments);}
        gtag('js', new Date());

        gtag('config', '{{ setting("site.google_analytics_tracking_id") }}');
    </script>
@endif