<?php

declare(strict_types=1);

return [
    'env' => env('APP_ENV', 'local'),
    'debug' => env('APP_DEBUG', '1') === '1',
    'timezone' => env('APP_TIMEZONE', 'Europe/Paris'),
    'base_url' => rtrim((string) env('APP_BASE_URL', 'http://localhost/camparts/public'), '/'),
    'api_base_path' => '/' . trim((string) env('API_BASE_PATH', '/camparts/api'), '/'),
    'session_name' => env('SESSION_NAME', 'camparts_session'),
    'session_cookie_secure' => strtolower(trim((string) env('SESSION_COOKIE_SECURE', 'auto'))),
    'session_cookie_samesite' => trim((string) env('SESSION_COOKIE_SAMESITE', 'Lax')),
    'session_cookie_path' => trim((string) env('SESSION_COOKIE_PATH', '/')),
    'session_cookie_domain' => trim((string) env('SESSION_COOKIE_DOMAIN', '')),
    'session_cookie_lifetime' => (int) env('SESSION_COOKIE_LIFETIME', '0'),
    'cors_allowed_origins' => array_values(array_filter(array_map(
        static fn (string $origin): string => trim($origin),
        explode(',', (string) env('CORS_ALLOWED_ORIGINS', 'http://localhost:5173,http://127.0.0.1:5173,http://localhost'))
    ))),
    'rate_limit_per_minute' => (int) env('RATE_LIMIT_PER_MINUTE', '120'),
    'rate_limit_auth_per_minute' => (int) env('RATE_LIMIT_AUTH_PER_MINUTE', '20'),
    'rate_limit_cart_per_minute' => (int) env('RATE_LIMIT_CART_PER_MINUTE', '60'),
    'rate_limit_order_per_minute' => (int) env('RATE_LIMIT_ORDER_PER_MINUTE', '20'),
    'cart_reservation_ttl_seconds' => (int) env('CART_RESERVATION_TTL_SECONDS', '86400'),
    'cache_ttl_articles' => (int) env('CACHE_TTL_ARTICLES', '45'),
    'cache_ttl_marques' => (int) env('CACHE_TTL_MARQUES', '300'),
    'cache_ttl_modeles' => (int) env('CACHE_TTL_MODELES', '300'),
    'image_base_url' => rtrim((string) env('IMAGE_BASE_URL', ''), '/'),
    'image_fetch_timeout' => (int) env('IMAGE_FETCH_TIMEOUT', '4'),
    'image_cache_ttl' => (int) env('IMAGE_CACHE_TTL', '604800'),
    'image_thumb_quality' => (int) env('IMAGE_THUMB_QUALITY', '82'),
];
