<?php

namespace App\Http\Middleware;

use App\Services\System\TimeService;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class PrimeTimezone
{
    public function __construct(private TimeService $timeService)
    {
    }

    public function handle(Request $request, Closure $next): Response
    {
        try {
            $this->timeService->primeFromRequest($request);
        } catch (\Throwable $e) {
            // ignore; fallback detection still works
        }

        return $next($request);
    }
}
