<?php

use App\Http\Controllers\Auth\SanctumAuthController;
use App\Http\Controllers\FrontMediaController;
use App\Http\Controllers\UserAccountController;
use App\Http\Controllers\UserAIController;
use App\Http\Controllers\UserExportController;
use App\Http\Controllers\UserPurchaseController;
use Illuminate\Support\Facades\Route;

Route::group(['prefix' => 'user'], function () {
    Route::post('/register', [SanctumAuthController::class, 'register']);
    Route::post('/login', [SanctumAuthController::class, 'login']);
});

Route::post('/pricing', [UserPurchaseController::class, 'pricingPage'])->name('api.pricing_page');

Route::post('/ai-hints', [UserAIController::class, 'aiHints'])->name('api.ai_hints');

Route::middleware('auth:sanctum')->group(function () {

    Route::group(['prefix' => 'user'], function () {

        Route::post('/', [UserAccountController::class, 'index'])->name('api.user');

        Route::post('/subscribe', [UserPurchaseController::class, 'subscribe'])->name('api.user.subscribe');

        Route::post('/purchase', [UserPurchaseController::class, 'purchase'])->name('api.user.purchase');

        Route::post('/billing-portal', [UserPurchaseController::class, 'billingPortal'])->name('api.user.billing_portal');

        Route::post('/logout', [SanctumAuthController::class, 'logout']);

        Route::post('/premium-export/request', [UserExportController::class, 'premiumExportRequest'])->name('api.user.premium_export.request');

        Route::post('/premium-export/complete', [UserExportController::class, 'premiumExportComplete'])->name('api.user.premium_export.complete');

        Route::group(['prefix' => 'generate_meme'], function () {
            Route::post('/', [UserAIController::class, 'generateMeme'])->name('api.user.generate_meme');
            Route::post('/status', [UserAIController::class, 'checkMemeJobStatus'])->name('api.user.check_meme_job_status');
            Route::post('/active', [UserAIController::class, 'getActiveJob'])->name('api.user.get_active_job');
            Route::post('/history', [UserAIController::class, 'getMemeHistory'])->name('api.user.get_meme_history');
        });
    });
});

Route::group(['prefix' => 'app'], function () {

    Route::post('init', [FrontMediaController::class, 'init'])->name('api.app.init');

    Route::post('memes', [FrontMediaController::class, 'memes'])->name('api.app.memes');

    Route::post('background', [FrontMediaController::class, 'background'])->name('api.app.background');
});
