<!DOCTYPE html>
<html lang="<?php echo e(str_replace('_', '-', app()->getLocale())); ?>">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <?php
            // Extract current page props from Inertia
            $page = json_decode(json_encode($page ?? []), true);
            $post = $page['props']['post'] ?? null;
            $siteName = $seo['site_name'] ?? config('app.name', 'Titan News');
            $currentUrl = url()->current();

            // Determine Meta Details
            $metaTitle = $post ? $post['title'] : ($seo['og_title'] ?? $siteName);
            $metaDesc = $post ? $post['meta_description'] : ($seo['og_description'] ?? '');
            
            // Image Logic (Ensure Absolute URL)
            $metaImage = $seo['og_image'] ?? null;
            if ($post && !empty($post['image_path'])) {
                $metaImage = str_starts_with($post['image_path'], 'http') 
                    ? $post['image_path'] 
                    : url($post['image_path']);
            } elseif ($metaImage && !str_starts_with($metaImage, 'http')) {
                $metaImage = url($metaImage);
            }
        ?>

        <!-- Standard SEO Meta Tags -->
        <title inertia><?php echo e($metaTitle); ?> | <?php echo e($siteName); ?></title>
        <meta name="description" content="<?php echo e($metaDesc); ?>">
        <meta name="keywords" content="<?php echo e($seo['meta_keywords'] ?? ''); ?>">

        <!-- Open Graph / Facebook / LinkedIn / Pinterest -->
        <meta property="og:site_name" content="<?php echo e($siteName); ?>">
        <meta property="og:type" content="<?php echo e($post ? 'article' : 'website'); ?>">
        <meta property="og:url" content="<?php echo e($currentUrl); ?>">
        <meta property="og:title" content="<?php echo e($metaTitle); ?>">
        <meta property="og:description" content="<?php echo e($metaDesc); ?>">
        <?php if($metaImage): ?>
            <meta property="og:image" content="<?php echo e($metaImage); ?>">
            <meta property="og:image:width" content="1200">
            <meta property="og:image:height" content="630">
        <?php endif; ?>

        <!-- Pinterest Rich Pin / Article Tags -->
        <?php if($post): ?>
            <meta property="article:published_time" content="<?php echo e($post['created_at']); ?>">
            <meta property="article:modified_time" content="<?php echo e($post['updated_at']); ?>">
            <?php if(isset($post['category']['name'])): ?>
                <meta property="article:section" content="<?php echo e($post['category']['name']); ?>">
            <?php endif; ?>
            <?php if(isset($post['tags']) && is_array($post['tags'])): ?>
                <?php $__currentLoopData = $post['tags']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tag): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <meta property="article:tag" content="<?php echo e($tag); ?>">
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            <?php endif; ?>
            <?php if(isset($post['user']['name'])): ?>
                <meta property="article:author" content="<?php echo e($post['user']['name']); ?>">
            <?php endif; ?>
        <?php endif; ?>

        <!-- Twitter Card -->
        <meta name="twitter:card" content="summary_large_image">
        <meta name="twitter:url" content="<?php echo e($currentUrl); ?>">
        <meta name="twitter:title" content="<?php echo e($metaTitle); ?>">
        <meta name="twitter:description" content="<?php echo e($metaDesc); ?>">
        <?php if($metaImage): ?>
            <meta name="twitter:image" content="<?php echo e($metaImage); ?>">
        <?php endif; ?>

        <!-- Dynamic Favicon -->
        <?php if(isset($seo['site_favicon'])): ?>
            <link rel="icon" href="<?php echo e(asset($seo['site_favicon'])); ?>">
        <?php endif; ?>

        <!-- CUSTOM HEADER CODE INJECTION -->
        <?php if(isset($scripts['header_code'])): ?>
            <?php echo $scripts['header_code']; ?>

        <?php endif; ?>

        <!-- Fonts -->
        <link rel="preconnect" href="https://fonts.bunny.net">
        <link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />

        <!-- Scripts -->
        <?php echo app('Tighten\Ziggy\BladeRouteGenerator')->generate(); ?>
        <?php echo app('Illuminate\Foundation\Vite')->reactRefresh(); ?>
        <?php echo app('Illuminate\Foundation\Vite')(['resources/js/app.jsx', "resources/js/Pages/{$page['component']}.jsx"]); ?>
        <?php if (!isset($__inertiaSsrDispatched)) { $__inertiaSsrDispatched = true; $__inertiaSsrResponse = app(\Inertia\Ssr\Gateway::class)->dispatch($page); }  if ($__inertiaSsrResponse) { echo $__inertiaSsrResponse->head; } ?>
    </head>
    <body class="font-sans antialiased">
        <?php if (!isset($__inertiaSsrDispatched)) { $__inertiaSsrDispatched = true; $__inertiaSsrResponse = app(\Inertia\Ssr\Gateway::class)->dispatch($page); }  if ($__inertiaSsrResponse) { echo $__inertiaSsrResponse->body; } elseif (config('inertia.use_script_element_for_initial_page')) { ?><script data-page="app" type="application/json"><?php echo json_encode($page); ?></script><div id="app"></div><?php } else { ?><div id="app" data-page="<?php echo e(json_encode($page)); ?>"></div><?php } ?>

        <?php if(isset($scripts['footer_code'])): ?>
            <?php echo $scripts['footer_code']; ?>

        <?php endif; ?>
    </body>
</html><?php /**PATH C:\xampp\htdocs\my-app\resources\views/app.blade.php ENDPATH**/ ?>