<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="builder-prefix" content="{{ config('builder.prefix', 'admin') }}">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title inertia>Builder</title>

    @php
        $modules = app(\Builder\Core\Foundation\Registry::class)->all();
        $hasModules = count($modules) > 0;
    @endphp

    @if ($hasModules)
    <script type="importmap">
        {!! \Builder\Core\Foundation\Assets::importMap(
            collect($modules)->mapWithKeys(fn (\Builder\Core\Foundation\Definition\JsModule $m) => [
                'builder-' . $m->getKey() => ['package' => $m->getKey(), 'entry' => $m->getEntry()],
            ])->all()
        ) !!}
    </script>
    @endif

    <script>
(function () {
    var t = localStorage.getItem('builder-theme') || 'system';
    if (t === 'dark' || (t === 'system' && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
        document.documentElement.classList.add('dark');
    }
})();
</script>

    @builderAssets
</head>

<body>

@inertia

</body>

</html>
