import type { V3Route } from './registry';
import { evaluateV3CapabilityEvidence } from './capabilities';

/**
 * V3 has no verified deployment/payee map or durable route-bound settlement
 * evidence. This intentionally does not parse a payment header, read a body,
 * emit a 402 requirement, or construct an address-bearing payment option.
 */
export function createUnpaidV3Challenge(_request: Request, route: V3Route): Response {
  return Response.json(
    {
      schema: 'vaultfire.v3.x402.challenge-status.v1',
      schemaVersion: '1.0.0',
      protocolVersion: '3.0.0',
      error: 'V3 payment challenges are unavailable pending real V3 address and durable settlement evidence',
      code: 'v3_payment_challenge_unavailable',
      route: route.path,
      retryable: false,
      evidence: {
        requestInspected: false,
        paymentHeaderObserved: false,
        paymentParsed: false,
        paymentProcessed: false,
        requestBound: false,
        receiptCreated: false,
        settlementVerified: false,
        bazaarIndexingVerified: false,
      },
      safety: {
        walletConnectionRequested: false,
        signatureRequested: false,
        paymentSubmitted: false,
        v2FallbackUsed: false,
      },
      capabilityGate: evaluateV3CapabilityEvidence(),
    },
    {
      status: 503,
      headers: {
        'Cache-Control': 'no-store',
        'X-Robots-Tag': 'noindex',
      },
    },
  );
}
