<?php

use Illuminate\Support\Facades\Route;
use Mtc\Plugins\BlockManager\Http\Controllers\AdminController;

Route::prefix('admin/block-manager')
    ->middleware('auth')
    ->group(function () {
        // Blocks tab (Composer)
        Route::get('/', [AdminController::class, 'index']);

        // Elements tab (Designer / element-variant authoring)
        Route::get('/elements', [AdminController::class, 'elements']);
        Route::get('/elements/{id}', [AdminController::class, 'elements'])->whereNumber('id');

        // Legacy aliases — serve the unified shell on the Elements tab.
        Route::get('/designer', [AdminController::class, 'designer']);
        Route::get('/designer/{id}', [AdminController::class, 'designer'])->whereNumber('id');

        // Composer in create-mode — same shell, no id; SPA reads the URL.
        Route::get('/new', [AdminController::class, 'index']);

        // Blocks deep-link (kept last so /elements + /designer + /new match first).
        Route::get('/{id}', [AdminController::class, 'index'])->whereNumber('id');
    });
