<?php

use App\Http\Controllers\Api\UserApiController;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\MatrixController;
use App\Http\Controllers\NotificationController;
use App\Http\Controllers\PlaylistController;
use App\Http\Controllers\ProfileController;
use Illuminate\Support\Facades\Route;

/*
|---------------------------------------------------------------------------------
| User Routes
|---------------------------------------------------------------------------------
*/

// Matrix
Route::get('/join-matrix', [MatrixController::class, 'index'])->name('join.matrix');

Route::middleware('auth')->group(function () {
    // Matrix
    Route::post('/join-matrix', [MatrixController::class, 'store'])->name('join.matrix.create');

    Route::get('/user/profile', [ProfileController::class, 'index'])->name('profile.show');
    Route::get('/user/comments', [ProfileController::class, 'comments'])->name('profile.comments');
    Route::get('/user/likes', [ProfileController::class, 'likes'])->name('profile.likes');
    Route::get('/user/watched', [ProfileController::class, 'watched'])->name('user.watched');
    Route::get('/user/subscription', [ProfileController::class, 'subscription'])->name('profile.subscription');

    // Notifications
    Route::get('/user/notifications', [NotificationController::class, 'index'])->name('profile.notifications');
    Route::delete('/user/notifications', [NotificationController::class, 'delete'])->name('profile.notifications.delete');

    // User Profile Actions
    Route::get('/user/settings', [ProfileController::class, 'settings'])->name('profile.settings');
    Route::patch('/user/settings', [ProfileController::class, 'update'])->name('profile.update');
    Route::delete('/user/delete', [ProfileController::class, 'destroy'])->name('profile.delete');
    Route::post('/user/settings', [ProfileController::class, 'saveSettings'])->name('profile.settings.save');
    Route::get('/user/blacklist', [UserApiController::class, 'getBlacklist'])->name('profile.blacklist');
    Route::post('/user/blacklist', [ProfileController::class, 'saveBlacklist'])->name('profile.blacklist.save');

    // Playlist Routes for User Page
    Route::get('/user/playlists', [PlaylistController::class, 'playlists'])->name('profile.playlists');
    Route::get('/user/playlist/{playlist_id}', [PlaylistController::class, 'showPlaylist'])->name('profile.playlist.show');
    Route::post('/create-playlist', [PlaylistController::class, 'createPlaylist'])->name('profile.playlists.create');
    Route::delete('/user/playlist/{playlist_id}', [PlaylistController::class, 'deletePlaylist'])->name('profile.playlist.delete');
    Route::post('/user/playlist-episode', [PlaylistController::class, 'deleteEpisodeFromPlaylist'])->name('playlist.delete.episode');

    // Playlist Routes for Modals on Stream Page
    Route::post('/hentai/add-to-playlist', [PlaylistController::class, 'addPlaylistApi'])->name('hentai.playlists.add');
    Route::post('/hentai/create-playlist', [PlaylistController::class, 'createPlaylistApi'])->name('hentai.playlists.create');

    // Download Page
    Route::get('/download-search', [HomeController::class, 'downloadSearch'])->name('download.search');
});
