<?php

namespace App\View\Components;

use Illuminate\View\Component;

class AgencyThemeLayout extends Component
{
    public $agency;
    public $page;
    public $theme;
    public $themeSettings;

    public function __construct($agency, $page, $theme, $themeSettings)
    {
        $this->agency = $agency;
        $this->page = $page;
        $this->theme = $theme;
        $this->themeSettings = $themeSettings;
    }

    public function render()
    {
        $themeName = $this->theme->name ?? 'default';
        $viewPath = "page.agency.themes.{$themeName}.layout";

        // Tema layout'u yoksa default kullan
        if (!view()->exists($viewPath)) {
            $viewPath = 'page.agency.themes.default.layout';
        }

        return view($viewPath, [
            'agency' => $this->agency,
            'page' => $this->page,
            'theme' => $this->theme,
            'themeSettings' => $this->themeSettings,
        ]);
    }
}
