<?php

namespace App\Http\Controllers\Api\V1\Admin\Auth;

use App\Support\ApiResponse;
use Illuminate\Http\JsonResponse;
use App\Services\AdminCaptchaService;

/**
 * GET /api/v1/admin/auth/captcha
 *
 * 返回一次性验证码 Key 与 SVG（Base64 便于前台直接赋值给 img.src）。
 */
final class CaptchaController
{
    public function __invoke(AdminCaptchaService $captcha): JsonResponse
    {
        $payload = $captcha->create();

        return ApiResponse::success([
            'captcha_key' => $payload['captcha_key'],
            'image_base64' => $payload['image_base64'],
        ]);
    }
}
