<?php

namespace App\Services\Moderation;

use App\Contracts\Moderation\ModerationSuggestionProviderInterface;
use App\Data\Moderation\ModerationResultData;
use App\Data\Moderation\ModerationSuggestionData;
use App\Services\Moderation\Providers\HeuristicModerationSuggestionProvider;
use App\Services\Moderation\Providers\NullModerationSuggestionProvider;

class ModerationSuggestionService
{
    public function provider(): ModerationSuggestionProviderInterface
    {
        $provider = (string) app('config')->get('content_moderation.suggestions.provider', 'heuristic');

        return match ($provider) {
            'null' => app(NullModerationSuggestionProvider::class),
            default => app(HeuristicModerationSuggestionProvider::class),
        };
    }

    /**
     * @param array<string, mixed> $context
     */
    public function suggest(string $content, ModerationResultData $result, array $context = []): ModerationSuggestionData
    {
        return $this->provider()->suggest($content, $result, $context);
    }
}