<?php

namespace Database\Seeders;

use App\Enums\ApprovalMode;
use App\Enums\EventStatus;
use App\Enums\EventType;
use App\Enums\LocationType;
use App\Enums\ParticipationType;
use App\Enums\PricingType;
use App\Enums\UserRole;
use App\Enums\UserStatus;
use App\Models\Event;
use App\Models\EventPaymentMethod;
use App\Models\EventPrize;
use App\Models\Game;
use App\Models\ManualPaymentMethod;
use App\Models\PlayerProfile;
use App\Models\User;
use App\Support\PublicId;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;

class AdminUserSeeder extends Seeder
{
    public function run(): void
    {
        $admin = User::updateOrCreate(
            ['email' => 'admin@algaarena.gg'],
            [
                'name' => 'ALGA Admin',
                'username' => 'algaadmin',
                'display_name' => 'ALGA Admin',
                'password' => Hash::make('password'),
                'country_code' => 'EG',
                'preferred_locale' => 'en',
                'timezone' => 'Africa/Cairo',
                'phone_country_code' => '20',
                'phone_number' => '1000000001',
                'phone_e164' => '+201000000001',
                'role' => UserRole::SuperAdmin,
                'status' => UserStatus::Active,
                'email_verified_at' => now(),
                'terms_accepted_at' => now(),
            ],
        );

        if (blank($admin->public_id)) {
            $admin->update(['public_id' => PublicId::generate()]);
            $admin->refresh();
        }

        PlayerProfile::updateOrCreate(
            ['user_id' => $admin->id],
            [
                'public_id' => $admin->public_id,
                'display_name' => 'ALGA Admin',
                'bio' => 'Platform administrator account.',
                'country_code' => 'EG',
                'timezone' => 'Africa/Cairo',
                'profile_visibility' => 'public',
                'profile_completion_percentage' => 40,
                'status' => 'active',
            ],
        );
    }
}
