// Mock dataset — 12 UK marine vessels with realistic data
// 3 flagged: #3 outstanding charge, #7 duplicate active policy, #9 stolen vessel alert

const BOATS = [
  {
    id: 'SLV-2019',
    src: 'images/1.jpg',
    name: 'Solent Voyager',
    make: 'Princess',
    model: 'V58',
    year: 2019,
    length: '17.8 m',
    hin: 'GB-PRC58V019-A0142',
    reg: 'SSR 142907',
    value: 845000,
    moorings: 'Hamble Point Marina',
    type: 'Motor yacht',
    owner: { name: 'Avalon Maritime Ltd', kind: 'Company', since: '2021-03-14' },
    insurance: { insurer: 'Pantaenius UK', policy: 'PAN-2024-58219', status: 'Active', expires: '2026-09-30', premium: 6450 },
    finance: { lender: 'Marine Finance Co.', balance: 312000, term: 'Aug 2029', status: 'Active' },
    claims: [],
    flags: [],
    state: 'clean',
  },
  {
    id: 'WKR-2021',
    src: 'images/2.jpg',
    name: 'Whitstable Rose',
    make: 'Beneteau',
    model: 'Oceanis 46.1',
    year: 2021,
    length: '14.6 m',
    hin: 'FR-BENO461-21-2208',
    reg: 'SSR 209114',
    value: 285000,
    moorings: 'Port Solent',
    type: 'Sailing yacht',
    owner: { name: 'Harriet & Mark Caldwell', kind: 'Joint individuals', since: '2022-05-08' },
    insurance: { insurer: 'GJW Direct', policy: 'GJW-2024-14082', status: 'Active', expires: '2026-05-31', premium: 1820 },
    finance: null,
    claims: [{ date: '2023-08-12', type: 'Hull damage – pontoon contact', settled: 4200, status: 'Settled' }],
    flags: [],
    state: 'clean',
  },
  {
    id: 'NTH-2017',
    src: 'images/3.jpg',
    name: 'Northumbria',
    make: 'Sunseeker',
    model: 'Manhattan 52',
    year: 2017,
    length: '15.8 m',
    hin: 'GB-SSM52-2017-0089',
    reg: 'SSR 187220',
    value: 695000,
    moorings: 'Poole Quay Boat Haven',
    type: 'Motor yacht',
    owner: { name: 'James A. Holloway', kind: 'Individual', since: '2020-11-02' },
    insurance: { insurer: 'Haven Knox-Johnston', policy: 'HKJ-2024-99021', status: 'Active', expires: '2026-11-12', premium: 5290 },
    finance: { lender: 'Coastline Capital', balance: 178000, term: 'Jun 2027', status: 'Active' },
    claims: [],
    flags: [
      { kind: 'charge', severity: 'flag', summary: 'Existing charge held by Coastline Capital', detail: 'Outstanding marine mortgage of £178,000 registered 22 Jun 2020. Term: Jun 2027.' },
    ],
    state: 'flag',
  },
  {
    id: 'DAR-2020',
    src: 'images/4.jpg',
    name: 'Daring',
    make: 'Hanse',
    model: '418',
    year: 2020,
    length: '12.4 m',
    hin: 'DE-HAN418-2020-1142',
    reg: 'SSR 198440',
    value: 215000,
    moorings: 'Lymington Yacht Haven',
    type: 'Sailing yacht',
    owner: { name: 'Eleanor Whitcombe', kind: 'Individual', since: '2020-07-19' },
    insurance: { insurer: 'Topsail Insurance', policy: 'TOP-2024-30219', status: 'Active', expires: '2026-07-19', premium: 1290 },
    finance: null,
    claims: [],
    flags: [],
    state: 'clean',
  },
  {
    id: 'ABS-2018',
    src: 'images/5.jpg',
    name: 'Albion Star',
    make: 'Fairline',
    model: 'Targa 43',
    year: 2018,
    length: '13.3 m',
    hin: 'GB-FRTG43-2018-0301',
    reg: 'SSR 174822',
    value: 395000,
    moorings: 'Brighton Marina',
    type: 'Motor yacht',
    owner: { name: 'Albion Charter Ltd', kind: 'Company', since: '2019-02-28' },
    insurance: { insurer: 'Navigators & General', policy: 'NG-2024-77041', status: 'Active', expires: '2026-02-28', premium: 3120 },
    finance: { lender: 'Marine Finance Co.', balance: 87000, term: 'Feb 2026', status: 'Active' },
    claims: [{ date: '2022-04-03', type: 'Engine — saltwater ingress', settled: 18700, status: 'Settled' }],
    flags: [],
    state: 'clean',
  },
  {
    id: 'MMG-2022',
    src: 'images/6.jpg',
    name: 'Misty Morgan',
    make: 'Bavaria',
    model: 'C42',
    year: 2022,
    length: '12.9 m',
    hin: 'DE-BAVC42-2022-0418',
    reg: 'SSR 214066',
    value: 305000,
    moorings: 'Falmouth Marina',
    type: 'Sailing yacht',
    owner: { name: 'Owen Trelawney', kind: 'Individual', since: '2022-09-04' },
    insurance: { insurer: 'Pantaenius UK', policy: 'PAN-2024-12087', status: 'Active', expires: '2026-09-04', premium: 1640 },
    finance: { lender: 'Coastline Capital', balance: 142000, term: 'Sep 2029', status: 'Active' },
    claims: [],
    flags: [],
    state: 'clean',
  },
  {
    id: 'KES-2019',
    src: 'images/7.jpg',
    name: 'Kestrel',
    make: 'Jeanneau',
    model: 'Sun Odyssey 410',
    year: 2019,
    length: '12.4 m',
    hin: 'FR-JNSO410-19-0844',
    reg: 'SSR 190281',
    value: 240000,
    moorings: 'Plymouth Yacht Haven',
    type: 'Sailing yacht',
    owner: { name: 'Daniel & Sara Reston', kind: 'Joint individuals', since: '2019-12-10' },
    insurance: { insurer: 'GJW Direct', policy: 'GJW-2024-08114', status: 'Active', expires: '2026-12-10', premium: 1490 },
    duplicateInsurance: { insurer: 'Topsail Insurance', policy: 'TOP-2024-44119', status: 'Active', expires: '2026-08-22', premium: 1380, bound: '2024-08-22' },
    finance: null,
    claims: [],
    flags: [
      { kind: 'duplicate', severity: 'flag', summary: 'Duplicate active policy detected', detail: 'A second active policy (TOP-2024-44119, Topsail Insurance) is registered against this vessel, bound 22 Aug 2024.' },
    ],
    state: 'flag',
  },
  {
    id: 'SVP-2020',
    src: 'images/8.jpg',
    name: 'Severn Pearl',
    make: 'Princess',
    model: 'F45',
    year: 2020,
    length: '13.8 m',
    hin: 'GB-PRF45-2020-0212',
    reg: 'SSR 202155',
    value: 575000,
    moorings: 'Cardiff Marina',
    type: 'Motor yacht',
    owner: { name: 'Severn Holdings Ltd', kind: 'Company', since: '2020-06-22' },
    insurance: { insurer: 'Haven Knox-Johnston', policy: 'HKJ-2024-44211', status: 'Active', expires: '2026-06-22', premium: 4180 },
    finance: { lender: 'Anchor Lending Group', balance: 280000, term: 'Jun 2028', status: 'Active' },
    claims: [{ date: '2024-01-18', type: 'Storm damage — canvas/rigging', settled: 8100, status: 'Settled' }],
    flags: [],
    state: 'clean',
  },
  {
    id: 'BMB-2016',
    src: 'images/9.jpg',
    name: 'Black Mamba',
    make: 'Sealine',
    model: 'F430',
    year: 2016,
    length: '13.1 m',
    hin: 'GB-SLF430-16-0094',
    reg: 'SSR 162007',
    value: 280000,
    moorings: 'Last seen — Chichester',
    type: 'Motor yacht',
    owner: { name: 'Thomas Verity (disputed)', kind: 'Individual', since: '2019-04-11' },
    insurance: { insurer: 'Navigators & General', policy: 'NG-2024-LAPSE', status: 'Lapsed 22 Feb 2026', expires: '2026-02-22', premium: 2980 },
    finance: null,
    claims: [{ date: '2025-11-04', type: 'Reported stolen — Chichester berth', settled: null, status: 'Open' }],
    flags: [
      { kind: 'stolen', severity: 'alert', summary: 'Reported stolen — active alert', detail: 'Vessel reported stolen from Chichester berth, 4 Nov 2025. Sussex Police ref 44/210081/25. Hull markings may have been altered.' },
      { kind: 'lapsed', severity: 'flag', summary: 'Insurance lapsed 22 Feb 2026', detail: 'Last active policy with Navigators & General lapsed without renewal.' },
    ],
    state: 'alert',
  },
  {
    id: 'MLP-1989',
    src: 'images/10.jfif',
    name: "Marlow's Pride",
    make: 'Westerly',
    model: 'Konsort',
    year: 1989,
    length: '8.6 m',
    hin: 'GB-WSTKON-89-0411',
    reg: 'SSR 102214',
    value: 22000,
    moorings: 'Conwy Marina',
    type: 'Sailing yacht (classic)',
    owner: { name: 'Geoffrey Marlow', kind: 'Individual', since: '2014-08-30' },
    insurance: { insurer: 'GJW Direct', policy: 'GJW-2024-19922', status: 'Active', expires: '2026-08-30', premium: 480 },
    finance: null,
    claims: [{ date: '2020-09-22', type: 'Grounding — keel inspection', settled: 1900, status: 'Settled' }],
    flags: [],
    state: 'clean',
  },
  {
    id: 'TRN-2022',
    src: 'images/11.jfif',
    name: 'Tide Runner',
    make: 'Axopar',
    model: '37',
    year: 2022,
    length: '11.3 m',
    hin: 'FI-AXP37-2022-0708',
    reg: 'SSR 218903',
    value: 295000,
    moorings: 'Cowes Yacht Haven',
    type: 'Sportscruiser',
    owner: { name: 'Verity Cole', kind: 'Individual', since: '2022-04-12' },
    insurance: { insurer: 'Topsail Insurance', policy: 'TOP-2024-12044', status: 'Active', expires: '2026-04-12', premium: 2240 },
    finance: { lender: 'Marine Finance Co.', balance: 165000, term: 'Apr 2027', status: 'Active' },
    claims: [],
    flags: [],
    state: 'clean',
  },
  {
    id: 'SAL-2021',
    src: 'images/12.jfif',
    name: 'Salacia',
    make: 'Oyster',
    model: '565',
    year: 2021,
    length: '17.2 m',
    hin: 'GB-OYS565-21-0033',
    reg: 'SSR 210504',
    value: 1450000,
    moorings: 'Berthon, Lymington',
    type: 'Bluewater sailing yacht',
    owner: { name: 'Salacia Holdings (BVI)', kind: 'Company', since: '2021-10-15' },
    insurance: { insurer: 'Pantaenius UK', policy: 'PAN-2024-04018', status: 'Active', expires: '2026-10-15', premium: 12800 },
    finance: { lender: 'Anchor Lending Group', balance: 720000, term: 'Oct 2031', status: 'Active' },
    claims: [],
    flags: [],
    state: 'clean',
  },
];

const PERSONAS = [
  {
    id: 'lender',
    label: 'Finance / Lender',
    org: 'Coastline Capital',
    user: 'A. Mortimer · Underwriting',
    objective: 'Register a new marine finance agreement and verify no prior charge exists against the vessel before funds are released.',
  },
  {
    id: 'insurer',
    label: 'Insurance / MGA',
    org: 'Haven Knox-Johnston',
    user: 'R. Lewis · Marine Underwriting',
    objective: 'Detect duplicate cover, beneficial ownership, fraud history, and claims history before quoting.',
  },
  {
    id: 'broker',
    label: 'Broker / Dealer',
    org: 'Solent Yacht Brokers',
    user: 'P. Cavendish · Sales Director',
    objective: 'Verify a vessel is free of encumbrances before listing or selling, and provide buyers with a certified clean title check.',
  },
  {
    id: 'marina',
    label: 'Marina / Harbourmaster',
    org: 'Hamble Point Marina',
    user: 'D. Whitley · Berthing Office',
    objective: 'Verify any vessel applying for a berth is legitimately owned, properly insured, and has no fraud or stolen alerts.',
  },
  {
    id: 'consumer',
    label: 'Boat Buyer / Consumer',
    org: 'marinecheckhq.co.uk',
    user: 'Guest',
    objective: 'Confirm a vessel is free of hidden finance and has a clean history before committing any money.',
  },
];

const formatGBP = (n) => '£' + n.toLocaleString('en-GB');
const formatDate = (s) => {
  if (!s) return '—';
  const d = new Date(s);
  return d.toLocaleDateString('en-GB', { day: '2-digit', month: 'short', year: 'numeric' });
};

Object.assign(window, { BOATS, PERSONAS, formatGBP, formatDate });
