<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Api\V1\HealthController;
use App\Http\Controllers\Api\V1\Draw\DrawCurrentController;
use App\Http\Controllers\Api\V1\Draw\DrawResultShowController;
use App\Http\Controllers\Api\V1\Draw\DrawResultsIndexController;
use App\Http\Controllers\Api\V1\Currency\CurrencyIndexController;
use App\Http\Controllers\Api\V1\Jackpot\JackpotSummaryController;
use App\Http\Controllers\Api\V1\Play\PlayEffectiveCatalogController;
use App\Http\Controllers\Api\V1\Player\PingController as PlayerPingController;
use App\Http\Controllers\Api\V1\Player\PlayerAuthCaptchaController;
use App\Http\Controllers\Api\V1\Player\PlayerAuthLoginController;
use App\Http\Controllers\Api\V1\Setting\SettingIndexController;
use App\Http\Controllers\Api\V1\Integration\IntegrationRuntimeOriginsController;

/**
 * 公开路由（无需登录）。
 */

// 健康检查
Route::get('health', HealthController::class)->name('api.v1.health');

// 币种主数据（公开，只给玩家端展示/金额精度使用）
Route::get('currencies', CurrencyIndexController::class)->name('api.v1.currencies.index');

// 开奖相关（公开）
Route::get('draw/current', DrawCurrentController::class)->name('api.v1.draw.current');
Route::get('draw/results', DrawResultsIndexController::class)->name('api.v1.draw.results');
Route::get('draw/results/{draw_no}', DrawResultShowController::class)
    ->where('draw_no', '[0-9]{8}-[0-9]{3}')
    ->name('api.v1.draw.results.show');

// 奖池水位（公开）
Route::get('jackpot/summary', JackpotSummaryController::class)->name('api.v1.jackpot.summary');

// 玩法目录（公开）
Route::get('play/effective', PlayEffectiveCatalogController::class)->name('api.v1.play.effective');

// 玩家端连通性探测
Route::prefix('player')
    ->name('api.v1.player.')
    ->group(function (): void {
        Route::get('ping', PlayerPingController::class)->name('ping');
        Route::middleware('throttle:player-auth-captcha')
            ->get('auth/captcha', PlayerAuthCaptchaController::class)
            ->name('auth.captcha');
        Route::middleware('throttle:player-auth-login')
            ->post('auth/login', PlayerAuthLoginController::class)
            ->name('auth.login');
    });

// 系统公共配置（如前端规则等）
Route::get('settings', SettingIndexController::class)->name('api.v1.settings.index');

// iframe 运行时白名单（只公开启用接入站点的 origin，不公开密钥）
Route::get('integration/runtime-origins', IntegrationRuntimeOriginsController::class)
    ->name('api.v1.integration.runtime-origins');
