/* Sentinel — change registry (tracker, with rounds) + audit trail.
   Rows are tagged with clauseKey so the tracker can group every provider's
   variation of the same standard clause together.
   state: proposed | accepted | edited | rejected | renegotiated */

const REGISTRY = [
  /* Real-time EHIS / data access */
  { id: "RG-1", clauseKey: "ehis", clause: "Real-time EHIS / data access", clauseRisk: "high", contract: "CT-2841", provider: "Nairobi West Hospital", type: "HSA", round: 1, routedTo: "CEO",
    providerAsk: "Limited, revocable, suspendable access; EHIS sole system of record", ourCounter: "Term-long, irrevocable access; both systems authoritative", state: "proposed", decidedBy: "—", date: "5 Jun 2026" },
  { id: "RG-2", clauseKey: "ehis", clause: "Real-time EHIS / data access", clauseRisk: "high", contract: "CT-2844", provider: "Premier Hospital", type: "HSA", round: 1, routedTo: "CEO",
    providerAsk: "Revocable access", ourCounter: "Term-long access", state: "accepted", decidedBy: "M. Mukundi", date: "12 May 2026", final: "Held — term-long access retained" },
  { id: "RG-3", clauseKey: "ehis", clause: "Real-time EHIS / data access", clauseRisk: "high", contract: "CT-2840", provider: "Coptic Hospital", type: "HSA", round: 2, routedTo: "CEO",
    providerAsk: "Suspend access on dispute", ourCounter: "No suspension except uncured breach", state: "renegotiated", decidedBy: "—", date: "5 Jun 2026", final: "Re-opened in round 2" },

  /* Claims-payment window */
  { id: "RG-4", clauseKey: "payment", clause: "Claims-payment window", clauseRisk: "high", contract: "CT-2841", provider: "Nairobi West Hospital", type: "HSA", round: 1, routedTo: "CEO",
    providerAsk: "30 days + 2%/mo penalty", ourCounter: "60 days, undisputed only", state: "proposed", decidedBy: "—", date: "5 Jun 2026" },
  { id: "RG-5", clauseKey: "payment", clause: "Claims-payment window", clauseRisk: "high", contract: "CT-2843", provider: "Goodlife Pharmacy", type: "SLA", round: 1, routedTo: "CEO",
    providerAsk: "30 days", ourCounter: "60 days", state: "edited", decidedBy: "M. Mukundi", date: "21 May 2026", final: "Compromised at 45 days (one-off)" },
  { id: "RG-6", clauseKey: "payment", clause: "Claims-payment window", clauseRisk: "high", contract: "CT-2847", provider: "Plainsview Hospital", type: "HSA", round: 1, routedTo: "CEO",
    providerAsk: "15-day settlement", ourCounter: "60 days", state: "accepted", decidedBy: "M. Mukundi", date: "2 May 2026", final: "Held — 60-day window" },

  /* Data ownership & licence */
  { id: "RG-7", clauseKey: "ownership", clause: "Data ownership & licence to use data", clauseRisk: "high", contract: "CT-2842", provider: "Cerba Lancet", type: "DPA", round: 1, routedTo: "CEO",
    providerAsk: "SP owns all data; consent-gated use", ourCounter: "Irrevocable royalty-free licence; anonymised use permitted", state: "proposed", decidedBy: "—", date: "5 Jun 2026" },
  { id: "RG-8", clauseKey: "ownership", clause: "Data ownership & licence to use data", clauseRisk: "high", contract: "CT-2845", provider: "Sonar Imaging", type: "SLA", round: 1, routedTo: "CEO",
    providerAsk: "Bar commercialising anonymised data", ourCounter: "Anonymised/aggregated use permitted", state: "accepted", decidedBy: "M. Mukundi", date: "30 Apr 2026", final: "Licence retained in full" },

  /* Liability & indemnity */
  { id: "RG-9", clauseKey: "liability", clause: "Liability & indemnity", clauseRisk: "high", contract: "CT-2841", provider: "Nairobi West Hospital", type: "HSA", round: 1, routedTo: "CEO",
    providerAsk: "Cap deleted; no liability for own systems", ourCounter: "Re-insert mutual cap (KES 5M)", state: "proposed", decidedBy: "—", date: "5 Jun 2026" },
  { id: "RG-10", clauseKey: "liability", clause: "Liability & indemnity", clauseRisk: "high", contract: "CT-2846", provider: "Coptic Hospital", type: "HSA", round: 1, routedTo: "CEO",
    providerAsk: "Remove cap", ourCounter: "Mutual cap retained", state: "accepted", decidedBy: "M. Mukundi", date: "29 Apr 2026", final: "Held — mutual cap (KES 5M)" },

  /* Data localisation / cross-border */
  { id: "RG-11", clauseKey: "localisation", clause: "Data localisation / cross-border", clauseRisk: "high", contract: "CT-2842", provider: "Cerba Lancet", type: "DPA", round: 1, routedTo: "CEO",
    providerAsk: "No transfer outside Kenya", ourCounter: "Lawful-safeguard transfers permitted", state: "proposed", decidedBy: "—", date: "5 Jun 2026" },
  { id: "RG-12", clauseKey: "localisation", clause: "Data localisation / cross-border", clauseRisk: "high", contract: "CT-2848", provider: "Dr Ritesh Clinic", type: "DSA", round: 1, routedTo: "CEO",
    providerAsk: "No transfer outside Kenya", ourCounter: "Lawful-safeguard transfers", state: "rejected", decidedBy: "M. Mukundi", date: "26 Apr 2026", final: "Provider ask rejected; safeguards clause kept" },

  /* Credit / deposit security */
  { id: "RG-13", clauseKey: "credit", clause: "Credit / deposit security", clauseRisk: "medhigh", contract: "CT-2842", provider: "Cerba Lancet", type: "DPA", round: 1, routedTo: "Head of SP",
    providerAsk: "Deposit on any creditworthiness concern", ourCounter: "Deposit on defined defaults only", state: "accepted", decidedBy: "D. Otieno", date: "28 May 2026", final: "Narrowed to defined defaults" },
  { id: "RG-14", clauseKey: "credit", clause: "Credit / deposit security", clauseRisk: "medhigh", contract: "CT-2841", provider: "Nairobi West Hospital", type: "HSA", round: 1, routedTo: "Head of SP",
    providerAsk: "Revoke credit without notice", ourCounter: "No unilateral revocation; Appendix 6 governs", state: "proposed", decidedBy: "—", date: "5 Jun 2026" },

  /* Termination for cause */
  { id: "RG-15", clauseKey: "termination", clause: "Termination for cause", clauseRisk: "medhigh", contract: "CT-2843", provider: "Goodlife Pharmacy", type: "SLA", round: 2, routedTo: "Head of SP",
    providerAsk: "Broaden triggers; single breach", ourCounter: "4 standard triggers; delete catch-alls", state: "renegotiated", decidedBy: "—", date: "5 Jun 2026" },
  { id: "RG-16", clauseKey: "termination", clause: "Termination for cause", clauseRisk: "medhigh", contract: "CT-2844", provider: "Premier Hospital", type: "HSA", round: 1, routedTo: "Head of SP",
    providerAsk: "Broaden triggers", ourCounter: "4 standard triggers", state: "accepted", decidedBy: "D. Otieno", date: "12 May 2026", final: "Narrowed to 4 triggers" },

  /* Fees & charges adjustment */
  { id: "RG-17", clauseKey: "fees", clause: "Fees & charges adjustment", clauseRisk: "medhigh", contract: "CT-2843", provider: "Goodlife Pharmacy", type: "SLA", round: 2, routedTo: "Head of SP",
    providerAsk: "Unilateral reprice, 7-day notice", ourCounter: "Mutual, 30-day notice", state: "renegotiated", decidedBy: "—", date: "5 Jun 2026" },
  { id: "RG-18", clauseKey: "fees", clause: "Fees & charges adjustment", clauseRisk: "medhigh", contract: "CT-2843", provider: "Goodlife Pharmacy", type: "SLA", round: 1, routedTo: "Head of SP",
    providerAsk: "Unilateral reprice", ourCounter: "Mutual 30-day notice", state: "accepted", decidedBy: "D. Otieno", date: "20 May 2026", final: "Held — mutual 30-day notice" },

  /* Entity characterisation */
  { id: "RG-19", clauseKey: "entity", clause: "Entity characterisation (MIP / TPA)", clauseRisk: "medlow", contract: "CT-2842", provider: "Cerba Lancet", type: "DPA", round: 1, routedTo: "Head of SP",
    providerAsk: "Relabel as billing platform", ourCounter: "Licensed insurer (IRA)", state: "edited", decidedBy: "D. Otieno", date: "earlier today", final: "Corrected to licensed insurer" },
  { id: "RG-20", clauseKey: "entity", clause: "Entity characterisation (MIP / TPA)", clauseRisk: "medlow", contract: "CT-2847", provider: "Plainsview Hospital", type: "DPA", round: 1, routedTo: "Head of SP",
    providerAsk: "Relabel as TPA", ourCounter: "Licensed insurer", state: "accepted", decidedBy: "D. Otieno", date: "2 May 2026", final: "Corrected to licensed insurer" },

  /* Dispute resolution */
  { id: "RG-21", clauseKey: "dispute", clause: "Dispute resolution process", clauseRisk: "medlow", contract: "CT-2841", provider: "Nairobi West Hospital", type: "HSA", round: 1, routedTo: "Head of SP",
    providerAsk: "Skip mediation, straight to arbitration", ourCounter: "Retain mediation step", state: "accepted", decidedBy: "D. Otieno", date: "earlier today", final: "Mediation step retained" },
  { id: "RG-22", clauseKey: "dispute", clause: "Dispute resolution process", clauseRisk: "medlow", contract: "CT-2846", provider: "Coptic Hospital", type: "HSA", round: 1, routedTo: "Head of SP",
    providerAsk: "Skip mediation", ourCounter: "Retain mediation step", state: "accepted", decidedBy: "D. Otieno", date: "29 Apr 2026", final: "Mediation retained" },

  /* Pre-auth / system-failure */
  { id: "RG-23", clauseKey: "preauth", clause: "Pre-auth / system-failure & emergency", clauseRisk: "medhigh", contract: "CT-2843", provider: "Goodlife Pharmacy", type: "SLA", round: 2, routedTo: "Head of SP",
    providerAsk: "Cap emergency recovery at 80%", ourCounter: "Full recovery; SP standard rate", state: "proposed", decidedBy: "—", date: "5 Jun 2026" },

  /* Exclusion of services */
  { id: "RG-24", clauseKey: "exclusion", clause: "Exclusion of services / scope", clauseRisk: "medlow", contract: "CT-2843", provider: "Goodlife Pharmacy", type: "SLA", round: 2, routedTo: "Head of SP",
    providerAsk: "14-day exclusion notice", ourCounter: "7-day notice; 5-day to raise concerns", state: "accepted", decidedBy: "D. Otieno", date: "earlier today", final: "7-day notice retained" },

  /* Coordination with SHA */
  { id: "RG-25", clauseKey: "coordination", clause: "Coordination with SHA / SHIF / NHIF", clauseRisk: "medlow", contract: "CT-2844", provider: "Premier Hospital", type: "HSA", round: 1, routedTo: "Head of SP",
    providerAsk: "‘Does not deal with SHA’ + rebate", ourCounter: "Coordinate per COB; correct payer order", state: "proposed", decidedBy: "—", date: "5 Jun 2026" },

  /* Force majeure */
  { id: "RG-26", clauseKey: "forcemajeure", clause: "Force majeure / notices", clauseRisk: "low", contract: "CT-2841", provider: "Nairobi West Hospital", type: "HSA", round: 1, routedTo: "Head of SP",
    providerAsk: "10-day notice", ourCounter: "Accept 10-day; 60-day termination kept", state: "accepted", decidedBy: "D. Otieno", date: "earlier today", final: "Accepted — 10-day notice" },
];

/* Audit trail seed — immutable, tamper-evident log. */
const AUDIT = [
  { id: "AU-1", actor: "Aisha Karega", role: "RM", action: "upload", target: "CT-2841", detail: "Uploaded Nairobi West HSA (R1) · nairobiwest_hsa_r1.docx", mins: 212, hash: "9f2a…4c1" },
  { id: "AU-2", actor: "Sentinel engine", role: "System", action: "classify", target: "CT-2841", detail: "7 changes classified · 3 High, 1 Med-High, 1 Med-Low, 1 Low, 1 Minor", mins: 211, hash: "1b77…e02" },
  { id: "AU-3", actor: "Sentinel engine", role: "System", action: "omission", target: "CT-2841", detail: "Omission scan: Clause 11.4 (Liability cap) deleted by provider — flagged High", mins: 211, hash: "a830…09d" },
  { id: "AU-4", actor: "Sentinel engine", role: "System", action: "auto_accept", target: "CT-2841", detail: "Clause 1.2 (Housekeeping) auto-accepted · confidence 99% · within allow-list", mins: 211, hash: "55c1…fa2" },
  { id: "AU-5", actor: "Sentinel engine", role: "System", action: "route", target: "CT-2841", detail: "Routed: 3 High → CEO queue; 1 Med-High, 1 Med-Low, 1 Low → Head of SP queue", mins: 210, hash: "7d44…b13" },
  { id: "AU-6", actor: "Daniel Otieno", role: "Head of SP", action: "login", target: "—", detail: "Signed in · OTP verified · daniel@edencaremedical.com", mins: 95, hash: "e221…77a" },
  { id: "AU-7", actor: "Daniel Otieno", role: "Head of SP", action: "decision", target: "CT-2841", detail: "Dispute resolution process (18.1) · Medium-Low · counter accepted", mins: 88, hash: "44ad…1e7" },
  { id: "AU-8", actor: "Sentinel engine", role: "System", action: "classify", target: "CT-2843", detail: "Goodlife SLA (R2): 5 changes · 3 Med-High, 1 Med-Low, 1 Minor", mins: 95, hash: "3c90…d51" },
  { id: "AU-9", actor: "Moses Mukundi", role: "CEO", action: "login", target: "—", detail: "Signed in · OTP verified · moss@ginja.ai", mins: 60, hash: "0aa2…cc8" },
];

Object.assign(window, { REGISTRY, AUDIT });
