<?php
require_once __DIR__.'/../../_bootstrap.php';
if($_SERVER['REQUEST_METHOD']!=='POST')jsonResponse(['ok'=>false,'erro'=>'Método não permitido.'],405);
afValidarCsrfApi();
$u=afApiOuSessaoUsuario($pdo);
$d=requestJson();$eventId=max(0,(int)($d['event_id']??0));
try{if($eventId<=0)throw new RuntimeException('Evento inválido.');$state=afControlledEventHeartbeat($pdo,$eventId,(int)$u['id']);jsonResponse(['ok'=>true,'supervision'=>$state]);}
catch(Throwable $e){jsonResponse(['ok'=>false,'erro'=>$e->getMessage()],422);}
