<?php

declare(strict_types=1);

require_once __DIR__ . '/includes/bootstrap.php';

if (request_method() !== 'GET') {
    http_response_code(405);
    header('Allow: GET');
    header('Content-Type: application/json; charset=utf-8');
    echo json_encode(['ok' => false, 'message' => 'Method not allowed'], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
    exit;
}

$guard = booking_form_guard_fields(true);

header('Content-Type: application/json; charset=utf-8');
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Pragma: no-cache');
header('X-Content-Type-Options: nosniff');

echo json_encode([
    'ok' => true,
    'csrf_token' => csrf_token(),
    'form_issued_at' => $guard['issued_at'],
    'form_token' => $guard['token'],
    'form_signature' => $guard['signature'],
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
