<?php

use App\Http\Controllers\Api\DownloadApiController;
use App\Http\Controllers\Api\HentaiApiController;
use App\Http\Controllers\Api\StreamApiController;
use App\Http\Controllers\ContactController;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\PlaylistController;
use App\Http\Controllers\StreamController;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
*/

Route::get('/', [HomeController::class, 'index'])->name('home.index');
Route::get('/stats', [HomeController::class, 'stats'])->name('home.stats');
Route::get('/banned', [HomeController::class, 'banned'])->name('home.banned');
Route::get('/random', [HomeController::class, 'random'])->name('hentai.random');

// API Endpoint
Route::get('/v1/hentai-list', [HentaiApiController::class, 'index'])->name('api.hentai.index');
Route::get('/v1/monthly-views', [HentaiApiController::class, 'getMonthlyViews'])->name('api.hentai.monthly');

// Stream Page
Route::get('/hentai/{title}', [StreamController::class, 'index'])->name('hentai.index');
Route::post('/player/api', [StreamApiController::class, 'getStream'])->name('hentai.player');
Route::post('/watched/track', [StreamApiController::class, 'trackWatched'])->name('hentai.watched');
Route::post('/player/engagement', [StreamApiController::class, 'trackEngagement'])->name('hentai.engagement');
Route::get('/player/engagement/{episodeId}', [StreamApiController::class, 'getEngagement'])->name('hentai.engagement.data');

// Search
Route::get('/search', [HomeController::class, 'search'])->name('hentai.search');
Route::post('/search', [HomeController::class, 'searchRedirect'])->name('hentai.searchredirect');

// Contact Form
Route::get('/contact', [ContactController::class, 'index'])->name('contact.index');
Route::post('/contact', [ContactController::class, 'store'])->name('contact.store');

// Public Playlists
Route::get('/playlists', [PlaylistController::class, 'index'])->name('playlist.index');
Route::get('/playlist/{playlist_id}', [PlaylistController::class, 'show'])->name('playlist.show');

// Download
Route::post('/get-download', [DownloadApiController::class, 'getDownload']);

Route::post('/update-language', [HomeController::class, 'updateLanguage'])->name('update.language');

/**
 * Passkey Routes
 */
Route::passkeys();

require __DIR__.'/user.php';
require __DIR__.'/admin.php';
require __DIR__.'/auth.php';
