<?php

declare(strict_types=1);

/**
 * Demo Mode (IP-isolated sandbox) configuration.
 *
 * When `enabled` is true, the DemoMode middleware will transparently create
 * a per-IP tenant sandbox so that anonymous visitors can exercise every
 * authoring feature without affecting other visitors or the production data.
 *
 * easybox (production / 116):   DEMO_MODE_ENABLED=false  (default — safe).
 * demo01  (showcase  / 118):    DEMO_MODE_ENABLED=true.
 */
return [
    // Master switch.
    'enabled' => filter_var(env('DEMO_MODE_ENABLED', false), FILTER_VALIDATE_BOOLEAN),

    // How long an inactive sandbox lives before cleanup hard-deletes it.
    'sandbox_ttl_hours' => (int) env('DEMO_SANDBOX_TTL_HOURS', 24),

    // Auto-issue Sanctum token + Auth::login() in DemoMode middleware.
    'auto_login' => filter_var(env('DEMO_AUTO_LOGIN', true), FILTER_VALIDATE_BOOLEAN),

    // If true, the sandbox is destroyed and recreated on every fresh visit
    // (no persisted state). Default false — visitors keep their changes
    // until TTL expiry.
    'auto_reset_on_visit' => filter_var(env('DEMO_AUTO_RESET_ON_VISIT', false), FILTER_VALIDATE_BOOLEAN),

    // Tenant UUID whose content is cloned into each new sandbox.
    'base_tenant_id' => env('DEMO_BASE_TENANT_ID'),

    // Tables that sandboxes are NOT allowed to mutate even though they
    // technically would pass tenant scope. Stops accidental destruction
    // of cross-tenant or sensitive data.
    'read_only_tables' => [
        'users',           // outside of the sandbox's own admin user
        'tenants',         // sandbox cannot rename itself
        'audit_logs',
        'legal_documents',
        'payment_methods',
    ],

    // Per-IP rate limit for demo routes (requests / minute).
    'rate_limit_per_minute' => (int) env('DEMO_RATE_LIMIT', 100),

    // Maximum upload size inside a sandbox (bytes). Capped at 5 MB.
    'max_upload_bytes' => (int) env('DEMO_MAX_UPLOAD_BYTES', 5 * 1024 * 1024),

    // Force mock providers regardless of project .env settings.
    // Demo mode must never hit a real PG / SMS / OAuth / LLM.
    'force_mocks' => [
        'payment'  => true,
        'identity' => true,
        'oauth'    => true,
        'ai'       => true,
        'webhook'  => false, // outbound webhooks disabled, not mocked
    ],

    // Tables that are eagerly cloned from the base tenant on sandbox
    // creation. Anything not listed is cloned lazily on first read or
    // simply not visible (read-through to base tenant is not used in
    // the simple copy-on-create model).
    'seed_tables' => [
        'board_categories',
        'boards',
        'posts',
        'post_comments',
        'pages',
        'menu_groups',
        'menu_sections',
        'product_categories',
        'products',
        'product_variants',
        'product_images',
        'marketplace_categories',
        'marketplace_items',
    ],
];
