<?php

declare(strict_types=1);

return [
    'storage_root' => env('SKINBASE_STORAGE_ROOT', storage_path('app/artworks')),

    'paths' => [
        'tmp'      => 'tmp',
        'quarantine' => 'quarantine',
        'original' => 'original',
        'xs'       => 'xs',
        'sm'       => 'sm',
        'md'       => 'md',
        'lg'       => 'lg',
        'xl'       => 'xl',
    ],

    'max_size_mb' => 50,
    'max_pixels' => 12000,

    'allowed_mimes' => [
        'image/jpeg',
        'image/png',
        'image/webp',
    ],

    'allow_gif' => env('UPLOAD_ALLOW_GIF', false),

    'derivatives' => [
        'xs' => ['max' => 320],
        'sm' => ['max' => 680],
        'md' => ['max' => 1024],
        'lg' => ['max' => 1920],
        'xl' => ['max' => 2560],
    ],

    'quality' => 85,

    'queue_derivatives' => env('UPLOAD_QUEUE_DERIVATIVES', false),

    'rate_limits' => [
        'decay_minutes' => env('UPLOAD_RATE_DECAY_MINUTES', 1),
        'init' => [
            'per_user' => env('UPLOAD_RATE_INIT_USER', 10),
            'per_ip' => env('UPLOAD_RATE_INIT_IP', 30),
        ],
        'finish' => [
            'per_user' => env('UPLOAD_RATE_FINISH_USER', 6),
            'per_ip' => env('UPLOAD_RATE_FINISH_IP', 12),
        ],
        'status' => [
            'per_user' => env('UPLOAD_RATE_STATUS_USER', 60),
            'per_ip' => env('UPLOAD_RATE_STATUS_IP', 120),
        ],
    ],

    'quotas' => [
        'max_active_sessions' => env('UPLOAD_MAX_ACTIVE_SESSIONS', 100),
        'max_daily_sessions' => env('UPLOAD_MAX_DAILY_SESSIONS', 250),
    ],

    'draft_quota' => [
        'max_drafts_per_user' => env('SKINBASE_MAX_DRAFTS', 10),
        'max_draft_storage_mb_per_user' => env('SKINBASE_MAX_DRAFT_STORAGE_MB', 1024),
        'duplicate_hash_policy' => env('SKINBASE_DUPLICATE_HASH_POLICY', 'block'), // block|warn
    ],

    'tokens' => [
        'ttl_minutes' => env('UPLOAD_TOKEN_TTL_MINUTES', 60),
    ],

    'chunk' => [
        'max_bytes' => env('UPLOAD_CHUNK_MAX_BYTES', 5242880),
        'lock_seconds' => env('UPLOAD_CHUNK_LOCK_SECONDS', 10),
        'lock_wait_seconds' => env('UPLOAD_CHUNK_LOCK_WAIT_SECONDS', 5),
    ],

    'scan' => [
        'enabled' => env('UPLOAD_SCAN_ENABLED', false),
        'command' => env('UPLOAD_SCAN_COMMAND', []),
    ],
];
