// Sample shipping method data + pre-built templates
const SHIPPING_TYPES = [
  "Parcel", "LTL Freight", "FTL Freight", "Ocean Freight", "Air Freight",
  "Local Delivery", "Customer Pickup", "Digital / No Shipment", "Other"
];

const CARRIERS = ["UPS", "FedEx", "DHL", "USPS", "Internal Fleet", "Custom"];

// Locked tracking URL templates for known carriers. "Custom" / "Internal Fleet"
// / blank carrier let the user define their own.
const CARRIER_TRACKING_URLS = {
  "UPS":   "https://www.ups.com/track?tracknum={tracking_number}",
  "FedEx": "https://www.fedex.com/fedextrack/?trknbr={tracking_number}",
  "DHL":   "https://www.dhl.com/en/express/tracking.html?AWB={tracking_number}",
  "USPS":  "https://tools.usps.com/go/TrackConfirmAction?tLabels={tracking_number}",
};
const CARRIER_TRACKING_LOCKED = (carrier) =>
  Object.prototype.hasOwnProperty.call(CARRIER_TRACKING_URLS, carrier);

const PRICING_METHODS = ["Flat Rate", "Manual", "Automated (API)", "Free Shipping"];

const AMOUNT_ENTRY_POINTS = [
  { value: "Sales Order", label: "Sales Order", hint: "Freight quoted upfront before the order is confirmed." },
  { value: "Shipment",    label: "Shipment",    hint: "Actual cost is known at fulfillment time." },
  { value: "Delivery",    label: "Delivery",    hint: "Charge is captured when the order is delivered." },
  { value: "Invoice",     label: "Invoice",     hint: "Shipping is billed with the invoice." },
  { value: "Manual / Anytime", label: "Manual / Anytime", hint: "Enter the shipping charge at any step." },
];

const SHIPPING_PRIORITIES = ["Standard", "Expedited", "Overnight"];

const OWNERSHIP_OPTIONS = ["When Shipped", "When Delivered", "Manual / Custom"];

const WAREHOUSES = ["Atlanta DC", "Cleveland Plant", "Long Beach Port", "Reno Hub", "Newark Cross-dock"];
const COUNTRIES = ["United States", "Canada", "Mexico", "United Kingdom", "Germany", "Japan"];

// Templates (pre-built starting points)
const TEMPLATES = [
  { id: "ups-ground",     name: "UPS",              type: "Parcel",          carrier: "UPS",      transit: 4, tracking: true,  pricing: "Flat Rate", flat: 12.99, signature: false, ownership: "When Shipped",  description: "Day-definite ground delivery within the contiguous US." },
  { id: "fedex-overnight",name: "FedEx",            type: "Parcel",          carrier: "FedEx",    transit: 1, tracking: true,  pricing: "Flat Rate", flat: 38.50, signature: true,  ownership: "When Shipped",  description: "Next-business-day delivery by 10:30 a.m." },
  { id: "usps-priority",  name: "USPS",             type: "Parcel",          carrier: "USPS",     transit: 3, tracking: true,  pricing: "Flat Rate", flat: 9.85,  signature: false, ownership: "When Shipped",  description: "1–3 day Priority Mail with flat-rate options." },
  { id: "dhl",            name: "DHL",              type: "Parcel",          carrier: "DHL",      transit: 5, tracking: true,  pricing: "Flat Rate", flat: 22.00, signature: false, ownership: "When Shipped",  description: "International express parcel delivery." },
  { id: "ltl",            name: "LTL Freight",      type: "LTL Freight",     carrier: "Custom",   transit: 5, tracking: true,  pricing: "Manual",    flat: 0,     signature: true,  ownership: "When Delivered",description: "Less-than-truckload palletized freight with BOL." },
  { id: "ftl",            name: "Full Truckload",   type: "FTL Freight",     carrier: "Custom",   transit: 3, tracking: false, pricing: "Manual",    flat: 0,     signature: true,  ownership: "When Delivered",description: "Dedicated trailer for full-truckload shipments." },
  { id: "ocean",          name: "Ocean Freight",    type: "Ocean Freight",   carrier: "Custom",   transit: 28,tracking: false, pricing: "Manual",    flat: 0,     signature: false, ownership: "When Shipped",  description: "FCL/LCL ocean container shipping for international orders." },
  { id: "air",            name: "Air Freight",      type: "Air Freight",     carrier: "DHL",      transit: 4, tracking: true,  pricing: "Manual",    flat: 0,     signature: true,  ownership: "When Shipped",  description: "Expedited international air freight." },
  { id: "local",          name: "Local Delivery",   type: "Local Delivery",  carrier: "Internal Fleet", transit: 1, tracking: true, pricing: "Flat Rate", flat: 15.00, signature: false, ownership: "When Delivered", description: "Same-day delivery using internal fleet." },
  { id: "pickup",         name: "Customer Pickup",  type: "Customer Pickup", carrier: "Internal Fleet", transit: 0, tracking: false, pricing: "Free Shipping", flat: 0, signature: true, ownership: "When Delivered", description: "Customer collects order at warehouse or branch." },
];

// Sample saved shipping methods (the list view's data)
const SAMPLE_METHODS = [
  { id: "sm-001", code: "UPS-GRD",   name: "UPS Ground",          type: "Parcel",          carrier: "UPS",      pricing: "Flat Rate",    flat: 12.99, transit: 4,  active: true,  isDefault: true,  customerVisible: true,  trackingEnabled: true,  signature: false, ownership: "When Shipped",   warehouses: ["Atlanta DC","Cleveland Plant","Reno Hub"], countries: ["United States"], updated: "11/04/2025", updatedBy: "RF", description: "Default contiguous-US ground service. Used for the majority of B2B parcel orders." },
  { id: "sm-002", code: "FDX-1D",    name: "FedEx Overnight",     type: "Parcel",          carrier: "FedEx",    pricing: "Flat Rate",    flat: 38.50, transit: 1,  active: true,  isDefault: false, customerVisible: true,  trackingEnabled: true,  signature: true,  ownership: "When Shipped",   warehouses: ["Atlanta DC","Newark Cross-dock"], countries: ["United States","Canada"], updated: "10/22/2025", updatedBy: "EC", description: "Next-business-day delivery for urgent orders." },
  { id: "sm-003", code: "USPS-PRI",  name: "USPS Priority Mail",  type: "Parcel",          carrier: "USPS",     pricing: "Flat Rate",    flat: 9.85,  transit: 3,  active: true,  isDefault: false, customerVisible: true,  trackingEnabled: true,  signature: false, ownership: "When Shipped",   warehouses: ["Atlanta DC","Cleveland Plant"], countries: ["United States"], updated: "10/18/2025", updatedBy: "RF", description: "Lightweight orders under 5 lbs." },
  { id: "sm-004", code: "LTL-STD",   name: "LTL Freight — Standard", type: "LTL Freight",  carrier: "Custom",   pricing: "Manual",       flat: 0,     transit: 5,  active: true,  isDefault: false, customerVisible: false, trackingEnabled: true,  signature: true,  ownership: "When Delivered", warehouses: ["Cleveland Plant","Reno Hub"], countries: ["United States","Canada","Mexico"], updated: "10/14/2025", updatedBy: "JL", description: "Standard palletized freight quoted manually by ops." },
  { id: "sm-005", code: "FTL-DED",   name: "Full Truckload — Dedicated", type: "FTL Freight", carrier: "Custom", pricing: "Manual",     flat: 0,     transit: 3,  active: true,  isDefault: false, customerVisible: false, trackingEnabled: false, signature: true,  ownership: "When Delivered", warehouses: ["Cleveland Plant"], countries: ["United States"], updated: "09/30/2025", updatedBy: "NM", description: "" },
  { id: "sm-006", code: "OCN-FCL",   name: "Ocean Freight — FCL", type: "Ocean Freight",   carrier: "Custom",   pricing: "Manual",       flat: 0,     transit: 28, active: true,  isDefault: false, customerVisible: false, trackingEnabled: false, signature: false, ownership: "When Shipped",   warehouses: ["Long Beach Port"], countries: ["United Kingdom","Germany","Japan"], updated: "09/12/2025", updatedBy: "JL", description: "Full container loads for international wholesale orders." },
  { id: "sm-007", code: "AIR-INTL",  name: "Air Freight — International", type: "Air Freight", carrier: "DHL",  pricing: "Manual",       flat: 0,     transit: 4,  active: true,  isDefault: false, customerVisible: true,  trackingEnabled: true,  signature: true,  ownership: "When Shipped",   warehouses: ["Atlanta DC","Newark Cross-dock"], countries: ["United Kingdom","Germany","Japan"], updated: "09/05/2025", updatedBy: "EC", description: "" },
  { id: "sm-008", code: "LOC-DLV",   name: "Local Same-Day Delivery", type: "Local Delivery", carrier: "Internal Fleet", pricing: "Flat Rate", flat: 15.00, transit: 1, active: true, isDefault: false, customerVisible: true, trackingEnabled: true, signature: false, ownership: "When Delivered", warehouses: ["Atlanta DC"], countries: ["United States"], updated: "08/28/2025", updatedBy: "RF", description: "Atlanta-metro same-day service with our internal fleet." },
  { id: "sm-009", code: "PICKUP",    name: "Customer Pickup",     type: "Customer Pickup", carrier: "Internal Fleet", pricing: "Free Shipping", flat: 0, transit: 0, active: true,  isDefault: false, customerVisible: true,  trackingEnabled: false, signature: true,  ownership: "When Delivered", warehouses: ["Atlanta DC","Cleveland Plant","Reno Hub"], countries: ["United States"], updated: "08/14/2025", updatedBy: "NM", description: "Will-call pickup at any branch." },
  { id: "sm-010", code: "DIG-NONE",  name: "Digital — No Shipment", type: "Digital / No Shipment", carrier: "", pricing: "Free Shipping", flat: 0, transit: 0, active: true,  isDefault: false, customerVisible: true,  trackingEnabled: false, signature: false, ownership: "When Shipped",   warehouses: [], countries: [], updated: "07/30/2025", updatedBy: "EC", description: "Software licenses and digital deliverables." },
  { id: "sm-011", code: "FDX-2D-OLD",name: "FedEx 2-Day (legacy)",type: "Parcel",          carrier: "FedEx",    pricing: "Flat Rate",    flat: 24.00, transit: 2,  active: false, isDefault: false, customerVisible: false, trackingEnabled: true,  signature: false, ownership: "When Shipped",   warehouses: ["Atlanta DC"], countries: ["United States"], updated: "06/02/2025", updatedBy: "RF", description: "Replaced by FedEx Overnight + Ground combination." },
];

const USERS = {
  RF: { name: "Robert Fox",   color: "#76ADFF" },
  EC: { name: "Emma Connor",  color: "#22863A" },
  NM: { name: "Nick Merley",  color: "#B279FF" },
  JL: { name: "Jordan Lin",   color: "#FF9143" },
};

window.SHIPPING_TYPES = SHIPPING_TYPES;
window.CARRIERS = CARRIERS;
window.CARRIER_TRACKING_URLS = CARRIER_TRACKING_URLS;
window.CARRIER_TRACKING_LOCKED = CARRIER_TRACKING_LOCKED;
window.PRICING_METHODS = PRICING_METHODS;
window.AMOUNT_ENTRY_POINTS = AMOUNT_ENTRY_POINTS;
window.SHIPPING_PRIORITIES = SHIPPING_PRIORITIES;
window.OWNERSHIP_OPTIONS = OWNERSHIP_OPTIONS;
window.WAREHOUSES = WAREHOUSES;
window.COUNTRIES = COUNTRIES;
window.TEMPLATES = TEMPLATES;
window.SAMPLE_METHODS = SAMPLE_METHODS;
window.USERS = USERS;
