<?php $attributes ??= new \Illuminate\View\ComponentAttributeBag;

$__newAttributes = [];
$__propNames = \Illuminate\View\ComponentAttributeBag::extractPropNames((['page' => null, 'item' => null]));

foreach ($attributes->all() as $__key => $__value) {
    if (in_array($__key, $__propNames)) {
        $$__key = $$__key ?? $__value;
    } else {
        $__newAttributes[$__key] = $__value;
    }
}

$attributes = new \Illuminate\View\ComponentAttributeBag($__newAttributes);

unset($__propNames);
unset($__newAttributes);

foreach (array_filter((['page' => null, 'item' => null]), 'is_string', ARRAY_FILTER_USE_KEY) as $__key => $__value) {
    $$__key = $$__key ?? $__value;
}

$__defined_vars = get_defined_vars();

foreach ($attributes->all() as $__key => $__value) {
    if (array_key_exists($__key, $__defined_vars)) unset($$__key);
}

unset($__defined_vars, $__key, $__value); ?>

<?php
    use App\Models\SeoData;
    use App\Models\SiteSetting;

    $settings = SiteSetting::pluck('setting_value', 'setting_key');
    $siteName = $settings['site_name'] ?? 'ECS';
    
    // Default fallback values
    $title = $siteName;
    $description = $settings['welcome_message'] ?? 'Extensive Creativity Solutions';

    $keywords = 'innovation, creativity, IT, construction, logistics';
    $ogImage = asset('ecs-logo.png');

    // If a specific page identifier is provided (home, about, etc.)
    if ($page) {
        $seo = SeoData::where('page_identifier', $page)->first();
        if ($seo) {
            $title = $seo->title;
            $description = $seo->description;
            $keywords = $seo->keywords;
            if ($seo->og_image_path) {
                $ogImage = asset($seo->og_image_path);
            }
        }
    }

    // If a dynamic item is provided (like a Blog Post) - future proofing
    if ($item) {
        $title = $item->title . ' | ' . $siteName;
        // Strip tags for description
        $description = Str::limit(strip_tags($item->content), 160);
        if (isset($item->image_path)) {
            $ogImage = asset($item->image_path);
        }
    }
?>

<!-- Primary Meta Tags -->
<title><?php echo e($title); ?></title>
<meta name="title" content="<?php echo e($title); ?>">
<meta name="description" content="<?php echo e($description); ?>">
<?php if($keywords): ?>
<meta name="keywords" content="<?php echo e($keywords); ?>">
<?php endif; ?>

<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="<?php echo e(url()->current()); ?>">
<meta property="og:title" content="<?php echo e($title); ?>">
<meta property="og:description" content="<?php echo e($description); ?>">
<meta property="og:image" content="<?php echo e($ogImage); ?>">

<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="<?php echo e(url()->current()); ?>">
<meta property="twitter:title" content="<?php echo e($title); ?>">
<meta property="twitter:description" content="<?php echo e($description); ?>">
<meta property="twitter:image" content="<?php echo e($ogImage); ?>">

<!-- Canonical Link -->
<link rel="canonical" href="<?php echo e(url()->current()); ?>">
<?php /**PATH C:\xampp\htdocs\ecs\resources\views/components/seo-tags.blade.php ENDPATH**/ ?>