/**
 * Flock 登录态 Quick 表单 → 官网 RPA 选项文案映射
 * 须与 Flock UI option 文本一致（英文）
 */
export const FLOCK_LOCATION_RPA_LABELS: Record<string, readonly string[]> = {
  business_with_dock: ["Business with Dock"],
  business_without_dock: ["Business without Dock"],
  residential: ["Residential"],
  trade_show: ["Trade Show"],
  limited_construction: ["Construction Site"],
  limited_farm: ["Farm"],
  limited_airport: [
    "Limited Access - Airport",
    "Limited Access – Airport",
    "Airport",
  ],
  limited_port: ["Limited Access - Port", "Limited Access – Port", "Port"],
  limited_military: [
    "Limited Access - Military Base",
    "Limited Access – Military Base",
    "Limited Access - Military",
    "Limited Access – Military",
    "Military Base",
    "Military",
  ],
  limited_worship: [
    "Limited Access - Church",
    "Limited Access – Church",
    "Place of Worship",
    "Church",
  ],
  limited_school: [
    "Limited Access - School",
    "Limited Access – School",
    "School",
  ],
  limited_other: [
    "Limited Access - Other",
    "Limited Access – Other",
    "Other Limited Access",
    "Other",
  ],
};

export const FLOCK_PACKAGING_RPA_LABELS: Record<string, readonly string[]> = {
  pallets_48x40: ["Pallets (48x40)", "Pallets 48x40"],
  pallets_48x48: ["Pallets (48x48)", "Pallets 48x48"],
  pallets_60x48: ["Pallets (60x48)", "Pallets 60x48"],
  pallets_custom: ["Pallets Custom", "Pallets (Custom)", "Custom Pallets"],
  bags: ["Bags"],
  bales: ["Bales"],
  boxes: ["Boxes"],
  bundles: ["Bundles"],
  coils: ["Coils"],
  crates: ["Crates"],
  cylinders: ["Cylinders"],
  drums: ["Drums"],
  pails: ["Pails"],
  reels: ["Reels"],
  rolls: ["Rolls"],
  slipsheets: ["Slipsheets", "Slip Sheets"],
  tubes_pipes: ["Tubes/Pipes", "Tubes / Pipes"],
  units: ["Units"],
};

export const FLOCK_SERVICE_RPA_LABELS: Record<string, string> = {
  blind_shipment: "Blind Shipment Coordination",
  food_grade: "Food Grade",
  load_to_ride: "Load to Ride",
  temperature_control: "Temperature Control",
  unloading: "Unloading Services",
};

export const FLOCK_VEHICLE_RPA_LABELS: Record<string, string> = {
  box_truck: "Box Truck",
  dry_van: "Dry Van",
  refrigerated: "Refrigerated Truck",
  sprinter: "Sprinter Van",
};

/** 调度服务 radio 官网文案（截图对齐） */
export const FLOCK_PICKUP_SERVICE_RPA_LABELS: Record<string, readonly string[]> = {
  standard_fcfs: ["Standard Pickup (FCFS)", "Standard Pickup"],
  during_window: ["During pickup window", "Within Pickup Window"],
  have_appointment: [
    "I HAVE pickup appointment",
    "I Have a Pickup Appointment",
  ],
  need_appointment: [
    "I NEED pickup appointment",
    "I Need a Pickup Appointment",
  ],
};

export const FLOCK_DELIVERY_SERVICE_RPA_LABELS: Record<
  string,
  readonly string[]
> = {
  standard_fcfs: ["Standard Delivery (FCFS)", "Standard Delivery"],
  during_window: ["During delivery window", "Within Delivery Window"],
  have_appointment: [
    "I HAVE delivery appointment",
    "I Have a Delivery Appointment",
  ],
  need_appointment: [
    "I NEED delivery appointment",
    "I Need a Delivery Appointment",
  ],
  must_arrive_by: ["Must arrive by date", "Must Arrive By Date"],
};

/** 与 UI weightLocked 对齐：总重 ≤5000 时官网灰色 */
export const FLOCK_PICKUP_SERVICE_WEIGHT_LOCKED: Record<string, boolean> = {
  standard_fcfs: false,
  during_window: true,
  have_appointment: true,
  need_appointment: true,
};

export const FLOCK_DELIVERY_SERVICE_WEIGHT_LOCKED: Record<string, boolean> = {
  standard_fcfs: false,
  during_window: true,
  have_appointment: true,
  need_appointment: false,
  must_arrive_by: true,
};

export const FLOCK_DEFAULT_VEHICLE_IDS = [
  "box_truck",
  "dry_van",
  "refrigerated",
] as const;

export function flockLocationRpaLabels(typeId: string): readonly string[] {
  return (
    FLOCK_LOCATION_RPA_LABELS[typeId] ?? ["Business with Dock", "Business"]
  );
}

export function flockPackagingRpaLabels(packagingId: string): readonly string[] {
  return FLOCK_PACKAGING_RPA_LABELS[packagingId] ?? ["Pallets (48x40)", "Pallets"];
}

export function flockFreightClassRpaLabels(
  freightClass: string,
): readonly string[] {
  if (freightClass === "density") {
    return [
      "Use density-based calculation",
      "Use density-based",
      "Density",
      "density",
    ];
  }
  return [freightClass];
}
