// cities.jsx — canonical Texas city list shared by Footer and CityLinkGrid.
//
// Single source of truth for city METADATA (name, slug, TDU, status). Display
// ORDER stays per-consumer (each component maintains its own DISPLAY_ORDER)
// because Footer and the city-link pill grid have intentionally different
// reading orders that we don't want to flatten in a refactor.
//
// As cities launch (status: "planned" → "built"), or new cities are added,
// edit ONLY this file — both the footer Service Area column and the
// CityLinkGrid pill grid will pick up the change.
//
// Exports (via window):
//   CITIES      — Array<{ name, slug, tdu, tduCode, footerLabel, gridLabel, status }>
//                 Ordered alphabetically; consumers reorder for display.
//   TEXAS_HUB   — the state hub entry (used by Footer's Service Area column
//                 above the city list, and by CityLinkGrid's "View all
//                 Texas cities" footer link). Not a city — kept separate so
//                 city iteration never accidentally renders the hub.
//   cityUrl(slugOrEntry) — helper that returns "/<slug>-electricity-rates.html"
//                          for a city entry or slug string.

const TEXAS_HUB = {
  name: 'Texas',
  slug: 'texas',
  footerLabel: 'Texas',
  status: 'built',
  type: 'hub',
};

// Alphabetical by `name`. Consumers reorder via their own DISPLAY_ORDER list.
const CITIES = [
  { name: 'Arlington',      slug: 'arlington',       tdu: 'Oncor',                  tduCode: 'ONC',  footerLabel: 'Arlington',      gridLabel: 'Arlington',      status: 'planned' },
  { name: 'Corpus Christi', slug: 'corpus-christi',  tdu: 'AEP Texas',              tduCode: 'AEPC', footerLabel: 'Corpus Christi', gridLabel: 'Corpus Christi', status: 'planned' },
  { name: 'Dallas',         slug: 'dallas',          tdu: 'Oncor',                  tduCode: 'ONC',  footerLabel: 'Dallas',         gridLabel: 'Dallas',         status: 'planned' },
  { name: 'Fort Worth',     slug: 'fort-worth',      tdu: 'Oncor',                  tduCode: 'ONC',  footerLabel: 'Fort Worth',     gridLabel: 'Fort Worth',     status: 'planned' },
  { name: 'Frisco',         slug: 'frisco',          tdu: 'Oncor',                  tduCode: 'ONC',  footerLabel: 'Frisco',         gridLabel: 'Frisco',         status: 'planned' },
  { name: 'Houston',        slug: 'houston',         tdu: 'CenterPoint Energy',     tduCode: 'CNP',  footerLabel: 'Houston',        gridLabel: 'Houston',        status: 'built'   },
  { name: 'Irving',         slug: 'irving',          tdu: 'Oncor',                  tduCode: 'ONC',  footerLabel: 'Irving',         gridLabel: 'Irving',         status: 'planned' },
  { name: 'Katy',           slug: 'katy',            tdu: 'CenterPoint Energy',     tduCode: 'CNP',  footerLabel: 'Katy',           gridLabel: 'Katy',           status: 'planned' },
  { name: 'Lubbock',        slug: 'lubbock',         tdu: 'Oncor',                  tduCode: 'ONC',  footerLabel: 'Lubbock',        gridLabel: 'Lubbock',        status: 'planned' },
  { name: 'Plano',          slug: 'plano',           tdu: 'Oncor',                  tduCode: 'ONC',  footerLabel: 'Plano',          gridLabel: 'Plano',          status: 'planned' },
  { name: 'Sugar Land',     slug: 'sugar-land',      tdu: 'CenterPoint Energy',     tduCode: 'CNP',  footerLabel: 'Sugar Land',     gridLabel: 'Sugar Land',     status: 'planned' },
  { name: 'The Woodlands',  slug: 'the-woodlands',   tdu: 'CenterPoint Energy',     tduCode: 'CNP',  footerLabel: 'The Woodlands',  gridLabel: 'The Woodlands',  status: 'planned' },
];

function cityUrl(slugOrEntry) {
  const slug = typeof slugOrEntry === 'string' ? slugOrEntry : (slugOrEntry && slugOrEntry.slug);
  return slug ? `/${slug}-electricity-rates.html` : '#';
}

window.CITIES = CITIES;
window.TEXAS_HUB = TEXAS_HUB;
window.cityUrl = cityUrl;
