@empoweredvote/ev-ui 0.8.13 → 0.8.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4341,6 +4341,17 @@ function qualifyLocalTitle(baseTitle, pol) {
4341
4341
  prefix = prefix.replace(/\s+County$/, "");
4342
4342
  return `${prefix} ${baseTitle}`;
4343
4343
  }
4344
+ function deriveSeatSubtitle(pol, cleanTitle) {
4345
+ const dt = pol.district_type || "";
4346
+ if (!dt.startsWith("LOCAL") && dt !== "COUNTY") return null;
4347
+ const t = cleanTitle || "";
4348
+ if (/\bat[- ]large\b/i.test(t)) return "At-Large";
4349
+ let m = t.match(/\bward\s+(\d+)/i);
4350
+ if (m) return `Ward ${m[1]}`;
4351
+ m = t.match(/\bdistrict\s+(\d+)/i);
4352
+ if (m) return `District ${m[1]}`;
4353
+ return null;
4354
+ }
4344
4355
  function buildTitleAndSubtitle(pol) {
4345
4356
  const cleanTitle = stripRetain(pol.office_title);
4346
4357
  const cleanChamber = stripRetain(pol.chamber_name);
@@ -4361,6 +4372,8 @@ function buildTitleAndSubtitle(pol) {
4361
4372
  if (dashIdx > 0) return normalizeDistrictSubtitle(cleanTitle.slice(dashIdx + 3));
4362
4373
  if (pol.district_type === "NATIONAL_JUDICIAL")
4363
4374
  return cleanChamber || null;
4375
+ const seatFromTitle = deriveSeatSubtitle(pol, cleanTitle);
4376
+ if (seatFromTitle) return seatFromTitle;
4364
4377
  if (pol.district_id && /^[1-9]\d*$/.test(pol.district_id))
4365
4378
  return `District ${pol.district_id}`;
4366
4379
  if (pol.district_id === "0" && !/(_EXEC)$/.test(pol.district_type))