import { loadDevEnv } from "@/lib/dev-env";
import { resolveMothershipCandidates } from "@/modules/address/mothership-candidates";

loadDevEnv();

async function main(): Promise<void> {
  const started = Date.now();
  const result = await resolveMothershipCandidates({
    pickup: {
      street: "1234 Warehouse Blvd",
      city: "Los Angeles",
      state: "CA",
      zip: "90001",
    },
    delivery: {
      street: "5678 Distribution Dr",
      city: "Dallas",
      state: "TX",
      zip: "75201",
    },
  });

  console.log(
    JSON.stringify(
      {
        ok: true,
        elapsedMs: Date.now() - started,
        pickupCount: result.pickup_candidates.length,
        deliveryCount: result.delivery_candidates.length,
        requiresSelection: result.requires_selection,
      },
      null,
      2,
    ),
  );
}

main().catch((error) => {
  console.error("[FAIL]", error);
  process.exitCode = 1;
});
