<?php

namespace App\Domain\Questions\Stages;

use App\Services\AiQuestionStructService;

class EstimateDifficulty
{
    public function __construct(private readonly AiQuestionStructService $service)
    {
    }

    public function handle(array $payload, \Closure $next): array
    {
        $payload['difficulty'] = $this->service->estimateDifficulty(
            (string) ($payload['stem'] ?? ''),
            $payload
        );

        return $next($payload);
    }
}
