<?php
declare(strict_types=1);

require_once __DIR__ . '/../config/helpers.php';

$data = input_json();
$codigo = trim((string) ($data['codigoind'] ?? ''));

if ($codigo === '') {
    echo json_encode(['disponivel' => false], JSON_UNESCAPED_UNICODE);
    exit;
}

$stmt = db()->prepare('SELECT id FROM usuarios WHERE codigoind = ? LIMIT 1');
$stmt->execute([$codigo]);
echo json_encode(['disponivel' => !$stmt->fetch()], JSON_UNESCAPED_UNICODE);

