/**
 * Smoke test for lib/opensrs.ts against the OpenSRS Horizon sandbox.
 *
 * Usage (from repo root):
 *   source .opensrs.env
 *   cd vibn-frontend && npx tsx scripts/smoke-opensrs.ts vibnai-smoke-$(date +%s).com
 *
 * - Prints availability + price for the given domain.
 * - Does NOT attempt registration (that belongs to a separate manual test).
 */

import { checkDomain, getResellerBalance, lookupDomain } from '../lib/opensrs';

async function main() {
  const domain = process.argv[2] ?? `vibnai-smoke-${Date.now()}.com`;
  console.log(`[smoke-opensrs] mode=${process.env.OPENSRS_MODE ?? 'test'} domain=${domain}`);

  const balance = await getResellerBalance();
  console.log('[smoke-opensrs] reseller balance:', balance);

  const avail = await lookupDomain(domain);
  console.log('[smoke-opensrs] lookup:', avail);

  const check = await checkDomain(domain, 1);
  console.log('[smoke-opensrs] check (availability + price):', check);
}

main().catch(err => {
  console.error('[smoke-opensrs] FAILED:', err);
  process.exit(1);
});
