<?php

namespace Database\Factories;

use App\Enums\LandingPageLayoutMode;
use App\Models\LandingPageGeneration;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends Factory<LandingPageGeneration>
 */
class LandingPageGenerationFactory extends Factory
{
    /**
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        return [
            'user_id' => User::factory(),
            'brand_name' => fake()->company(),
            'brand_url' => null,
            'website_url' => null,
            'product_urls' => ['https://example.com/product'],
            'notes' => null,
            'layout_mode' => LandingPageLayoutMode::Unique,
            'html_template' => null,
            'brief' => null,
            'catalog' => null,
            'status' => 'queued',
            'failure_reason' => null,
        ];
    }

    public function template(string $html = '<html id="hero-banner"><body>Template</body></html>'): static
    {
        return $this->state(fn (array $attributes) => [
            'layout_mode' => LandingPageLayoutMode::Template,
            'html_template' => $html,
        ]);
    }

    public function catalog(): static
    {
        return $this->state(fn (array $attributes) => [
            'layout_mode' => LandingPageLayoutMode::Catalog,
            'html_template' => null,
        ]);
    }

    public function withPartnerWebsite(string $url = 'https://attestpath.ai'): static
    {
        return $this->state(fn (array $attributes) => [
            'website_url' => $url,
        ]);
    }

    public function withAffiliateTracking(
        string $admediaCampaignId = '122609',
        string $affiliateKey = 'rateit_shop',
    ): static {
        return $this->state(fn (array $attributes) => [
            'admedia_campaign_id' => $admediaCampaignId,
            'affiliate_key' => $affiliateKey,
        ]);
    }
}
