"use client";

import type { Priority1ShipmentType } from "@/workers/rpa/priority1/shipment-types";

/** Priority1 官网 #freight-shipment 选项（2026-06 页面实测） */
export const P1_SHIPMENT_FREQUENCY_VALUES = [
  "1-5",
  "5-10",
  "10-30",
  "30-100",
  "100+",
  "One Time Shipment",
] as const;

export type P1ShipmentFrequency = (typeof P1_SHIPMENT_FREQUENCY_VALUES)[number];

export const P1_FREQUENCY_OPTIONS: Array<{
  value: P1ShipmentFrequency;
  label: string;
}> = [
  { value: "1-5", label: "每月 1–5 票" },
  { value: "5-10", label: "每月 5–10 票" },
  { value: "10-30", label: "每月 10–30 票" },
  { value: "30-100", label: "每月 30–100 票" },
  { value: "100+", label: "每月 100 票以上" },
  { value: "One Time Shipment", label: "单次发货" },
];

/** Step 1 运输类型卡片（界面中文；RPA 仍用英文 card 文本） */
export const P1_SHIPMENT_CARDS: Array<{
  id: Priority1ShipmentType;
  title: string;
  description: string;
}> = [
  {
    id: "ltl",
    title: "零担运输",
    description:
      "适用于 15,000 磅以下小票货；共享车厢空间，按实际占用计费。",
  },
  {
    id: "ftl",
    title: "整车运输",
    description:
      "适用于最高约 45,000 磅整车；可询价干货厢、平板、温控、加急等车型。",
  },
  {
    id: "expedited",
    title: "加急运输",
    description:
      "时效敏感或高价值货物，最高约 10,000 磅；Sprinter 厢式车与直卡可选。",
  },
];

/** Step 2 标题 */
export const P1_STEP2_HEADING: Record<Priority1ShipmentType, string> = {
  ltl: "零担运输报价",
  ftl: "整车运输报价",
  expedited: "加急运输报价",
};

export const P1_STEP2_SUBTITLE =
  "填写货物与车型信息，提交后系统将在 Priority1 官网按相同参数自动询价。";

/** 系统内 Priority1 模块开发态提示 */
export const P1_DEV_NOTICE = {
  title: "开发中，敬请期待",
  description:
    "本模块仍在完善中。请手动填写全部参数进行测试，系统不会预填邮编、日期、邮箱等字段。",
} as const;

/** 零担 Step 2 — 对齐官网 LTL Step 2 */
export const P1_LTL_UI = {
  freightSection: "货物信息",
  length: "长度",
  width: "宽度",
  height: "高度",
  dimensionUnit: "in",
  totalWeight: "总重量",
  weightUnit: "lbs",
  packaging: "货物如何包装？",
  palletCount: "托盘数量",
  freightClass: "货运等级",
  pickupSection: "提货信息",
  pickupLocation: "提货地点类型",
  pickupServices: "提货附加服务（可选）",
  deliverySection: "派送信息",
  deliveryLocation: "派送地点类型",
  deliveryServices: "派送附加服务（可选）",
} as const;

/** 整车 Step 2 区块文案 */
export const P1_FTL_UI = {
  selectTrailer: "选择拖车类型",
  openDeckType: "开放式平板类型",
  openDeckPlaceholder: "请选择平板子类型",
  tempMin: "最低温度（°F）",
  tempMax: "最高温度（°F）",
  tempMinPlaceholder: "请输入最低温度",
  tempMaxPlaceholder: "请输入最高温度",
  selectExpeditedTrailer: "选择加急车型",
  liftgate: "尾板（升降尾板）",
  liftgateDesc:
    "在无装卸台或叉车的场所安全装卸重货，适合紧急派送。",
  additionalServices: "附加服务（可选）",
  specialHandling: "特殊处理要求（可选）",
  freightSection: "货物信息",
  commodity: "您运送的是什么？",
  commodityPlaceholder: "例如：托盘",
  totalWeight: "总重量",
  weightUnit: "lbs",
  palletCount: "托盘数量",
  palletPlaceholder: "请输入托盘数量",
  subtitle:
    "填写货运详情，查看可节省的费用；在 CaboTMS 获取实时市场价格并在线预订。",
} as const;

/** 加急主类型 Step 2 — 对齐官网 EXPEDITED QUOTE */
export const P1_EXPEDITED_UI = {
  selectTrailer: "选择拖车类型",
  additionalServices: "附加服务（可选）",
  freightSection: "货物信息",
  commodity: "您运送的是什么？",
  totalWeight: "总重量",
  subtitle:
    "可在 CaboTMS 即时询价并预订 Sprinter 厢式车或直卡加急运单，支持紧急、周末及尾板选项。",
} as const;

export const P1_COMMON_UI = {
  step1: "第 1 步",
  step2: "第 2 步",
  step2Of2: "第 2 步（共 2 步）",
  shipmentType: "运输类型",
  originZip: "起运邮编",
  destZip: "目的邮编",
  frequency: "每月发货频次",
  pickupDate: "提货日期",
  pickupDateHint: "仅可选择今天之后的日期",
  email: "商务邮箱",
  getQuotes: "获取即时报价",
  backStep1: "返回第 1 步",
  stickyHint: "填写完成后点击按钮进入下一步或提交询价",
} as const;

/** 整车 — 主拖车四选一（id 对应 RPA） */
export const P1_FTL_TRAILERS = [
  {
    id: "dry_van" as const,
    label: "干货厢式车",
    desc: "53 英尺全封闭厢；最多约 26 托盘、45,000 磅，最常选。",
  },
  {
    id: "open_deck" as const,
    label: "开放式平板",
    desc: "无顶无侧板；含平板、阶梯板、侧帘、鹅颈低板等。",
  },
  {
    id: "temperature_controlled" as const,
    label: "温控冷藏车",
    desc: "全封闭冷藏厢，内置温控单元。",
  },
  {
    id: "ftl_expedited" as const,
    label: "加急运输",
    desc: "Sprinter 厢式车与直卡，适合时效敏感货。",
  },
];

/** Open Deck 子类型（value 为官网选项文本，供 RPA selectOption） */
export const P1_OPEN_DECK_OPTIONS = [
  { value: "48 Foot Flatbed", label: "48 英尺平板车" },
  { value: "53 Foot Flatbed", label: "53 英尺平板车" },
  { value: "48 Foot Step Deck", label: "48 英尺阶梯式平板" },
  { value: "53 Foot Step Deck", label: "53 英尺阶梯式平板" },
  { value: "Removable Gooseneck", label: "可拆卸鹅颈车" },
  { value: "Double Drop", label: "双降平板车" },
  { value: "Conestoga", label: "伸缩蓬车" },
  { value: "Hot Shot/Gooseneck", label: "轻型急件 / 鹅颈车" },
];

/** 整车标准附加服务（干货厢 / 平板 / 温控）— Full FTL + Partial PTL + Team Drivers */
export const P1_FTL_ADDITIONAL = [
  {
    id: "full_ftl" as const,
    label: "整车 FTL",
    desc: "大批量、专属运力、较短在途时间。",
  },
  {
    id: "partial_ptl" as const,
    label: "拼车 PTL",
    desc: "中等货量拼车，分摊车厢成本。",
  },
  {
    id: "team_drivers" as const,
    label: "双驾团队",
    desc: "紧急货物，尽可能缩短在途时间。",
  },
];

/** @deprecated 请使用 P1_FTL_ADDITIONAL */
export const P1_FTL_ADDITIONAL_STANDARD = P1_FTL_ADDITIONAL.filter(
  (s) => s.id !== "team_drivers",
);

/** FTL 内嵌 Expedited — 附加服务仅尾板卡片 */
export const P1_FTL_LIFTGATE_SERVICE = {
  label: "尾板（升降尾板）",
  desc: "在无装卸台或叉车的场所安全装卸重货，适合紧急派送。",
} as const;

/** FTL 内嵌 Expedited — 特殊处理（value 为官网标签） */
export const P1_SPECIAL_HANDLING = [
  { value: "Hazmat", label: "危险品" },
  { value: "High Value", label: "高价值物品" },
  { value: "Tanker Endorsed", label: "油罐车背书" },
  { value: "Overdimensional", label: "超限货物" },
];

/** 加急车型（整车内嵌加急 / 主类型加急共用） */
export const P1_EXP_TRAILERS = [
  {
    id: "sprinter_van" as const,
    label: "Sprinter 厢式车",
    desc: "约 172×52×72 in；最多 3 托盘、3,500 磅；非 dock 高度。",
  },
  {
    id: "small_straight" as const,
    label: "小型直卡",
    desc: "约 169×90×101 in；最多 6 托盘、5,000 磅。",
  },
  {
    id: "large_straight" as const,
    label: "大型直卡",
    desc: "约 312×96×96 in；最多 14 托盘、10,000 磅。",
  },
];

export const P1_PACKAGING_OPTIONS = [
  { value: "Pallet", label: "托盘" },
  { value: "Crate", label: "木箱" },
  { value: "Box", label: "纸箱" },
  { value: "Bundle", label: "捆扎" },
];

export const P1_LOCATION_OPTIONS = [
  { value: "Residence / Home Business", label: "住宅 / 家庭办公" },
  {
    value: "Business (with loading docks or forklift)",
    label: "商业（有装卸台或叉车）",
  },
  {
    value: "Business (no loading dock, no forklift)",
    label: "商业（无装卸台、无叉车）",
  },
];

export const P1_PICKUP_ACCESSORIALS = [
  { value: "Liftgate at Pickup", label: "提货尾板" },
  { value: "Inside Pickup", label: "室内提货" },
  { value: "Limited Access Pickup", label: "限制进入" },
  { value: "Residential Pickup", label: "住宅提货" },
];

export const P1_DELIVERY_ACCESSORIALS = [
  { value: "Liftgate at Delivery", label: "派送尾板" },
  { value: "Inside Delivery", label: "室内派送" },
  { value: "Delivery Appointment", label: "派送预约" },
  { value: "Call Before Delivery", label: "派送前电话" },
  { value: "Limited Access Delivery", label: "限制进入" },
  { value: "Hazardous Material", label: "危险品" },
  { value: "Residential Delivery", label: "住宅派送" },
];

export const P1_FREIGHT_CLASS_OPTIONS = [
  { value: "Not Sure", label: "不确定" },
  { value: "50", label: "50" },
  { value: "55", label: "55" },
  { value: "60", label: "60" },
  { value: "65", label: "65" },
  { value: "70", label: "70" },
  { value: "77.5", label: "77.5" },
  { value: "85", label: "85" },
  { value: "92.5", label: "92.5" },
  { value: "100", label: "100" },
  { value: "110", label: "110" },
  { value: "125", label: "125" },
  { value: "150", label: "150" },
  { value: "175", label: "175" },
  { value: "200", label: "200" },
  { value: "250", label: "250" },
  { value: "300", label: "300" },
  { value: "400", label: "400" },
  { value: "500", label: "500" },
];

/** Priority1 报价结果页（中文展示） */
export const P1_RESULT_UI = {
  title: "即时报价方案",
  intro:
    "以下为含客户加价的最终报价；管理端可为每位客户配置百分比或固定加价。",
  includesMarkup: (amount: string) => `含加价 ${amount}`,
  standardLtl: "标准零担（LTL）",
  quoteBadge: (n: number) => `报价 ${n}`,
  transit: (days: number) =>
    days === 1 ? "时效：1 个工作日" : `时效：${days} 个工作日`,
  transitUnknown: "时效：—",
  expiration: "报价失效日",
  delivery: "预计送达日",
  dateUnknown: "—",
  ftlTitle: "即时报价方案",
  ftlIntro: "整车报价按日历展示各提货日价格，与官网一致。",
  ftlLowest: (amount: string) => `本月最低报价：$${amount}`,
  shippingDetails: "运单摘要",
  from: "起运",
  to: "目的",
  date: "提货日",
  weight: "重量",
  items: "货物",
  requestNewQuote: "重新询价",
  schedule: "日程",
} as const;

export { p1DateFromIso, p1DateToIso } from "@/lib/priority1/date-format";
