<?php

declare(strict_types=1);

namespace Database\Factories;

use App\Models\BasicBasketProduct;
use App\Models\PriceObservation;
use App\Models\PriceSyncTask;
use App\Models\Store;
use App\Models\StoreProductTarget;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends Factory<PriceObservation>
 */
class PriceObservationFactory extends Factory
{
    protected $model = PriceObservation::class;

    /**
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        return [
            'price_sync_task_id' => PriceSyncTask::factory(),
            'store_product_target_id' => StoreProductTarget::factory(),
            'basic_basket_product_id' => BasicBasketProduct::factory(),
            'store_id' => Store::factory(),
            'provider' => 'dataforseo_merchant_google_products',
            'query' => $this->faker->sentence(4),
            'detected_title' => ucfirst($this->faker->words(4, true)),
            'detected_seller' => $this->faker->company(),
            'detected_domain' => $this->faker->domainName(),
            'original_url' => $this->faker->url(),
            'normalized_url' => $this->faker->url(),
            'image_url' => $this->faker->imageUrl(),
            'position' => $this->faker->numberBetween(1, 10),
            'price' => $this->faker->randomFloat(2, 10, 300),
            'previous_price' => $this->faker->randomFloat(2, 10, 350),
            'currency' => 'MXN',
            'match_score' => $this->faker->numberBetween(80, 120),
            'selection_strategy' => 'url_weighted_match',
            'observed_at' => now(),
            'raw_payload' => ['source' => 'factory'],
        ];
    }
}
