// HireArt Onboarding Form — sample data (jobs, supervisors, candidates, countries)

const COUNTRIES = [
  { id: "USA", label: "United States" },
  { id: "CAN", label: "Canada" },
  { id: "GBR", label: "United Kingdom" },
  { id: "DEU", label: "Germany" },
  { id: "FRA", label: "France" },
  { id: "ESP", label: "Spain" },
  { id: "PRT", label: "Portugal" },
  { id: "MEX", label: "Mexico" },
  { id: "BRA", label: "Brazil" },
  { id: "ARG", label: "Argentina" },
  { id: "IND", label: "India" },
  { id: "PHL", label: "Philippines" },
  { id: "AUS", label: "Australia" },
  { id: "JPN", label: "Japan" },
  { id: "SGP", label: "Singapore" },
];

// Country dial codes — id is the dial code, label is for the dropdown row
const PHONE_CODES = [
  { id: "+1",   country: "US", label: "United States" },
  { id: "+1-ca",country: "CA", label: "Canada",          dial: "+1" },
  { id: "+44",  country: "GB", label: "United Kingdom" },
  { id: "+33",  country: "FR", label: "France" },
  { id: "+49",  country: "DE", label: "Germany" },
  { id: "+34",  country: "ES", label: "Spain" },
  { id: "+351", country: "PT", label: "Portugal" },
  { id: "+52",  country: "MX", label: "Mexico" },
  { id: "+55",  country: "BR", label: "Brazil" },
  { id: "+54",  country: "AR", label: "Argentina" },
  { id: "+91",  country: "IN", label: "India" },
  { id: "+63",  country: "PH", label: "Philippines" },
  { id: "+61",  country: "AU", label: "Australia" },
  { id: "+81",  country: "JP", label: "Japan" },
  { id: "+65",  country: "SG", label: "Singapore" },
];

const STATES_USA = [
  "California", "New York", "Texas", "Washington", "Massachusetts",
  "Illinois", "Florida", "Colorado", "Oregon", "Georgia",
  "Pennsylvania", "Virginia", "Michigan", "Ohio", "Arizona",
];

const PROVINCES_CAN = ["Ontario", "Quebec", "British Columbia", "Alberta", "Manitoba"];

const CURRENCIES = [
  { id: "USD", label: "USD — US Dollar" },
  { id: "CAD", label: "CAD — Canadian Dollar" },
  { id: "GBP", label: "GBP — British Pound" },
  { id: "EUR", label: "EUR — Euro" },
  { id: "AUD", label: "AUD — Australian Dollar" },
  { id: "INR", label: "INR — Indian Rupee" },
];

const DEPARTMENTS = [
  "Engineering", "Product", "Design", "Marketing",
  "Sales", "Operations", "Finance", "Legal",
  "Human Resources", "Customer Success",
];

const SUPERVISORS = [
  { id: "sup_1", name: "Jane Smith", email: "jane.smith@aurora.example", department: "Engineering", team: "Platform" },
  { id: "sup_6", name: "David Park", email: "david.park@aurora.example", department: "Engineering", team: "Infrastructure" },
  { id: "sup_2", name: "John Doe", email: "john.doe@aurora.example", department: "Product", team: "Growth" },
  { id: "sup_3", name: "Emily Chen", email: "emily.chen@aurora.example", department: "Design", team: "Core" },
  { id: "sup_4", name: "Michael Brown", email: "michael.brown@aurora.example", department: "Marketing", team: "Brand" },
  { id: "sup_5", name: "Sarah Davis", email: "sarah.davis@aurora.example", department: "Sales", team: "Enterprise" },
  { id: "sup_7", name: "Rachel Kim", email: "rachel.kim@aurora.example", department: "Operations", team: "Logistics" },
  { id: "sup_8", name: "Tom Nguyen", email: "tom.nguyen@aurora.example", department: "Finance", team: "FP&A" },
  { id: "sup_9", name: "Lisa Patel", email: "lisa.patel@aurora.example", department: "Legal", team: "Compliance" },
  { id: "sup_10", name: "Chris Martinez", email: "chris.martinez@aurora.example", department: "Human Resources", team: "People Ops" },
  { id: "sup_11", name: "Amy Walker", email: "amy.walker@aurora.example", department: "Customer Success", team: "Client Relations" },
];

const TEAMS = (() => {
  const seen = new Set();
  const rows = [];
  SUPERVISORS.forEach((s) => {
    const key = `${s.department}::${s.team}`;
    if (!seen.has(key)) {
      seen.add(key);
      rows.push({ id: key, team: s.team, department: s.department });
    }
  });
  return rows;
})();

const EXISTING_JOBS = [
  {
    id: "job_1",
    roleName: "Senior Software Engineer",
    department: "Engineering",
    country: "USA",
    state: "California",
    classification: "employee",
    employmentType: "w2",
    schedule: "full_time",
    workEnvironment: "remote",
  },
  {
    id: "job_2",
    roleName: "Product Designer",
    department: "Design",
    country: "USA",
    state: "New York",
    classification: "contractor",
    employmentType: "ic_1099",
    schedule: "part_time",
    workEnvironment: "hybrid",
  },
  {
    id: "job_3",
    roleName: "Backend Engineer",
    department: "Engineering",
    country: "CAN",
    state: "Ontario",
    classification: "employee",
    employmentType: "t4",
    schedule: "full_time",
    workEnvironment: "remote",
  },
  {
    id: "job_4",
    roleName: "Customer Success Manager",
    department: "Customer Success",
    country: "GBR",
    state: "",
    classification: "employee",
    employmentType: "international_eor",
    schedule: "full_time",
    workEnvironment: "onsite",
  },
  {
    id: "job_5",
    roleName: "ML Engineer",
    department: "Engineering",
    country: "USA",
    state: "Washington",
    classification: "employee",
    employmentType: "w2",
    schedule: "full_time",
    workEnvironment: "hybrid",
  },
];

const EXISTING_CANDIDATES = [
  { id: "cand_1", name: "Alex Rivera", email: "alex.rivera@example.com", phone: "(415) 555-0142" },
  { id: "cand_2", name: "Priya Sharma", email: "priya.sharma@example.com", phone: "(212) 555-0118" },
  { id: "cand_3", name: "Marcus Johnson", email: "marcus.j@example.com", phone: "(206) 555-0167" },
  { id: "cand_4", name: "Yuki Tanaka", email: "yuki.t@example.com", phone: "(415) 555-0193" },
];

const EOR_PROVIDERS = [
  { id: "deel", label: "Deel" },
  { id: "remote", label: "Remote.com" },
  { id: "rippling", label: "Rippling" },
  { id: "papaya", label: "Papaya Global" },
  { id: "oyster", label: "Oyster" },
  { id: "other", label: "Other" },
];

// Saved company office addresses
const OFFICES = [
  { id: "ny",   label: "New York HQ",     address: "123 Broadway, New York, NY 10001",     country: "USA", state: "New York" },
  { id: "ldn",  label: "London Hub",      address: "456 Oxford St, London W1C 1AP",        country: "GBR", state: "" },
  { id: "tor",  label: "Toronto Branch",  address: "789 King St W, Toronto, ON M5V 1N4",   country: "CAN", state: "Ontario" },
  { id: "ber",  label: "Berlin Office",   address: "101 Friedrichstraße, 10117 Berlin",    country: "DEU", state: "" },
];

// Map country + classification → employment type (mirrors source form)
function deriveEmploymentType(country, classification) {
  if (!country || !classification || classification === "eor") return "";
  if (country === "USA") return classification === "employee" ? "w2" : "ic_1099";
  if (country === "CAN") return classification === "employee" ? "t4" : "international_ic";
  return classification === "employee" ? "international_eor" : "international_ic";
}

function employmentTypeLabel(et) {
  return ({
    w2: "W-2 Employee",
    ic_1099: "1099 Independent Contractor",
    t4: "T4 Employee (Canada)",
    international_eor: "International EOR Employee",
    international_ic: "International Contractor",
  })[et] || et;
}

function scheduleLabel(s) {
  return ({ full_time: "Full-time", part_time: "Part-time" })[s] || s;
}
function workEnvLabel(e) {
  return ({ remote: "Fully remote", hybrid: "Hybrid", onsite: "In-person" })[e] || e;
}

function classificationLabel(cls) {
  return ({
    employee: "Employee",
    contractor: "Contractor",
    eor: "Let HireArt decide",
  })[cls] || cls;
}

Object.assign(window, {
  COUNTRIES, STATES_USA, PROVINCES_CAN, CURRENCIES, PHONE_CODES,
  DEPARTMENTS, SUPERVISORS, TEAMS,
  EXISTING_JOBS, EXISTING_CANDIDATES, EOR_PROVIDERS, OFFICES,
  deriveEmploymentType, employmentTypeLabel, classificationLabel,
  scheduleLabel, workEnvLabel,
});
