<?php
    $sharedBranding = data_get($page ?? [], 'props.branding', []);
    $siteTitle = data_get($sharedBranding, 'site_title', config('branding.site_title', config('app.name', 'Pitchbar')));
    $customFavicon = data_get($sharedBranding, 'favicon_url');
    $initialFavicon = $customFavicon ?: asset('favicon.ico');
    $initialTouchIcon = $customFavicon ?: asset('apple-touch-icon.png');

    // SEO payload — per-page seo[] from the controller, or a sane
    // fallback so every render gets <meta description> + canonical
    // + Open Graph + Twitter Card + JSON-LD even when a page didn't
    // declare its own. Pure-PHP, hot-path safe.
    $seo = data_get($page ?? [], 'props.seo')
        ?: \App\Support\SeoMeta::defaults();
    $seoTitle = (string) ($seo['title'] ?? $siteTitle);
    $seoDescription = (string) ($seo['description'] ?? '');
    $seoCanonical = (string) ($seo['canonical'] ?? '');
    $seoSiteName = (string) ($seo['site_name'] ?? $siteTitle);
    $seoImage = $seo['image_url'] ?? null;
    $seoTwitterCard = (string) ($seo['twitter_card'] ?? 'summary_large_image');
    $seoTwitterHandle = $seo['twitter_handle'] ?? null;
    $seoNoindex = (bool) ($seo['noindex'] ?? false);
    $seoJsonLd = (array) ($seo['json_ld'] ?? []);

    // Resolve locale metadata once per render so <html dir>, lang
    // attributes, and the locale picker can all read from the same
    // source without re-instantiating the catalog lookup three times.
    $_localeEntry = \App\Services\I18n\LocaleCatalog::entryFor(app()->getLocale());
?>
<!DOCTYPE html>
<html lang="<?php echo e(str_replace('_', '-', app()->getLocale())); ?>" dir="<?php echo e($_localeEntry['rtl'] ? 'rtl' : 'ltr'); ?>" class="<?php echo \Illuminate\Support\Arr::toCssClasses(['dark' => ($appearance ?? 'system') == 'dark']); ?>">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="application-name" content="<?php echo e($siteTitle); ?>">
        
        <meta name="google" content="notranslate">
        <meta name="google" content="notranslate" lang="<?php echo e(str_replace('_', '-', app()->getLocale())); ?>">

        
        <?php if($seoDescription !== ''): ?>
            <meta name="description" content="<?php echo e($seoDescription); ?>">
        <?php endif; ?>
        <?php if($seoCanonical !== ''): ?>
            <link rel="canonical" href="<?php echo e($seoCanonical); ?>">
        <?php endif; ?>
        <?php if($seoNoindex): ?>
            <meta name="robots" content="noindex,nofollow">
        <?php endif; ?>

        
        <meta property="og:type" content="website">
        <meta property="og:site_name" content="<?php echo e($seoSiteName); ?>">
        <meta property="og:title" content="<?php echo e($seoTitle); ?>">
        <?php if($seoDescription !== ''): ?>
            <meta property="og:description" content="<?php echo e($seoDescription); ?>">
        <?php endif; ?>
        <?php if($seoCanonical !== ''): ?>
            <meta property="og:url" content="<?php echo e($seoCanonical); ?>">
        <?php endif; ?>
        <?php if($seoImage): ?>
            <meta property="og:image" content="<?php echo e($seoImage); ?>">
            <meta property="og:image:width" content="1200">
            <meta property="og:image:height" content="630">
            <meta property="og:image:alt" content="<?php echo e($seoSiteName); ?>">
        <?php endif; ?>

        
        <meta name="twitter:card" content="<?php echo e($seoTwitterCard); ?>">
        <meta name="twitter:title" content="<?php echo e($seoTitle); ?>">
        <?php if($seoDescription !== ''): ?>
            <meta name="twitter:description" content="<?php echo e($seoDescription); ?>">
        <?php endif; ?>
        <?php if($seoImage): ?>
            <meta name="twitter:image" content="<?php echo e($seoImage); ?>">
        <?php endif; ?>
        <?php if($seoTwitterHandle): ?>
            <meta name="twitter:site" content="<?php echo e($seoTwitterHandle); ?>">
        <?php endif; ?>

        
        <?php $__currentLoopData = $seoJsonLd; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $jsonLdBlock): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <script type="application/ld+json"><?php echo json_encode($jsonLdBlock, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); ?></script>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

        
        <script>
            (function() {
                const appearance = '<?php echo e($appearance ?? "system"); ?>';

                if (appearance === 'system') {
                    const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;

                    if (prefersDark) {
                        document.documentElement.classList.add('dark');
                    }
                }
            })();
        </script>

        
        <style>
            html {
                background-color: oklch(1 0 0);
            }

            html.dark {
                background-color: oklch(0.145 0 0);
            }
        </style>

        <script>
            window.__PITCHBAR_SITE_TITLE__ = <?php echo json_encode($siteTitle, 15, 512) ?>;
            window.__PITCHBAR_DEFAULT_FAVICON_URL__ = <?php echo json_encode($initialFavicon, 15, 512) ?>;
            window.__PITCHBAR_DEFAULT_TOUCH_ICON_URL__ = <?php echo json_encode($initialTouchIcon, 15, 512) ?>;
        </script>

        <link id="app-favicon" rel="icon" href="<?php echo e($initialFavicon); ?>" sizes="any">
        <link id="app-apple-touch-icon" rel="apple-touch-icon" href="<?php echo e($initialTouchIcon); ?>">

        
        <link rel="preconnect" href="https://fonts.bunny.net">
        <link
            href="https://fonts.bunny.net/css?family=geist:100,200,300,400,500,600,700,800,900|geist-mono:400,500,600&display=swap"
            rel="stylesheet"
        >

        <?php echo app('Illuminate\Foundation\Vite')->fonts(); ?>

        <?php echo app('Illuminate\Foundation\Vite')->reactRefresh(); ?>
        <?php echo app('Illuminate\Foundation\Vite')(['resources/css/app.css', 'resources/js/app.tsx', "resources/js/pages/{$page['component']}.tsx"]); ?>
        <?php if (isset($component)) { $__componentOriginal56673881198e3a2924721e242dee6899 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal56673881198e3a2924721e242dee6899 = $attributes; } ?>
<?php $component = Inertia\View\Components\Head::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('inertia::head'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Inertia\View\Components\Head::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
            <title><?php echo e($seoTitle); ?></title>
         <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal56673881198e3a2924721e242dee6899)): ?>
<?php $attributes = $__attributesOriginal56673881198e3a2924721e242dee6899; ?>
<?php unset($__attributesOriginal56673881198e3a2924721e242dee6899); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal56673881198e3a2924721e242dee6899)): ?>
<?php $component = $__componentOriginal56673881198e3a2924721e242dee6899; ?>
<?php unset($__componentOriginal56673881198e3a2924721e242dee6899); ?>
<?php endif; ?>
    </head>
    <body class="font-sans antialiased notranslate" translate="no">
        <?php if (isset($component)) { $__componentOriginal1830bdc8f8b965a5838ec47487b5507c = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal1830bdc8f8b965a5838ec47487b5507c = $attributes; } ?>
<?php $component = Inertia\View\Components\App::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('inertia::app'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Inertia\View\Components\App::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal1830bdc8f8b965a5838ec47487b5507c)): ?>
<?php $attributes = $__attributesOriginal1830bdc8f8b965a5838ec47487b5507c; ?>
<?php unset($__attributesOriginal1830bdc8f8b965a5838ec47487b5507c); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal1830bdc8f8b965a5838ec47487b5507c)): ?>
<?php $component = $__componentOriginal1830bdc8f8b965a5838ec47487b5507c; ?>
<?php unset($__componentOriginal1830bdc8f8b965a5838ec47487b5507c); ?>
<?php endif; ?>

        <?php
            $component = $page['component'] ?? null;
            $isMarketingComponent = $component === 'welcome' || str_starts_with((string) $component, 'marketing/');
            // Auth check is the safety net — even if a future page is
            // mis-categorised as "marketing", the demo widget never
            // mounts for authed admin / customer surfaces. A signed-in
            // workspace owner sitting on /dashboard should never see
            // their own marketing site's demo bot watching them.
            $isAuthenticated = auth()->check();
            $marketingDemoAgentId = ($isMarketingComponent && ! $isAuthenticated)
                ? (data_get($page, 'props.demoAgentId') ?: \App\Support\MarketingDemoAgent::id())
                : null;
        ?>
        <?php if($marketingDemoAgentId): ?>
            
            <?php
                $marketingWidgetPath = public_path('widget/widget.js');
                $marketingWidgetVersion = is_file($marketingWidgetPath)
                    ? substr((string) md5_file($marketingWidgetPath), 0, 8)
                    : 'dev';
            ?>
            <script
                src="<?php echo e(rtrim(config('app.url'), '/')); ?>/widget/widget.js?v=<?php echo e($marketingWidgetVersion); ?>"
                data-agent-id="<?php echo e($marketingDemoAgentId); ?>"
                data-demo="true"
                defer
            ></script>
        <?php endif; ?>
    </body>
</html>
<?php /**PATH /Users/prinnce/Documents/php/superbar/resources/views/app.blade.php ENDPATH**/ ?>