/* Mock data for Pelagia Portal */

const VESSELS = [
  { id: "v1", name: "MV Pelagia Voyager", imo: "IMO 9342711" },
  { id: "v2", name: "MV Coral Crescent",  imo: "IMO 9518342" },
  { id: "v3", name: "MV Arctic Halo",     imo: "IMO 9712095" },
  { id: "v4", name: "MV North Drift",     imo: "IMO 9665203" },
  { id: "v5", name: "MV Saffron Star",    imo: "IMO 9883017" },
];

const ACCOUNTS = [
  { id: "a1", code: "VC-OPS",   name: "Voyager Operations",  desc: "Fleet operations cost centre" },
  { id: "a2", code: "DD-2026",  name: "Dry Dock 2026",        desc: "Scheduled dry-docking expenses" },
  { id: "a3", code: "PROV-MAR", name: "Provisions — Mar",     desc: "Crew provisions monthly" },
  { id: "a4", code: "ENGINE",   name: "Engine Department",    desc: "Engine spares & consumables" },
  { id: "a5", code: "DECK",     name: "Deck Department",      desc: "Deck spares & consumables" },
];

const VENDORS = [
  { id: "vn1", vid: "VID-00214", name: "Mahalakshmi Marine Stores",  gstin: "29ABCDE1234F1Z5", contact: "R. Subramanian", email: "sales@mahalakshmimarine.in", phone: "+91 98450 12011", pin: "682002", verified: true,  active: true,  city: "Kochi" },
  { id: "vn2", vid: "VID-00339", name: "Coastline Engineering Co.",  gstin: "27FGHIJ5678K2Z3", contact: "Priya Nair",      email: "po@coastline-eng.com",       phone: "+91 91670 88324", pin: "400062", verified: true,  active: true,  city: "Mumbai" },
  { id: "vn3", vid: "VID-00402", name: "Bluewater Provisions",       gstin: "33LMNOP1245Q1Z7", contact: "Karthik V.",       email: "orders@bluewaterprov.in",     phone: "+91 90030 41560", pin: "600002", verified: true,  active: true,  city: "Chennai" },
  { id: "vn4", vid: null,        name: "Anchor Supply Traders",      gstin: "06RSTUV4567W1Z9", contact: "Tarun Mehta",     email: "tarun@anchorsupply.in",       phone: "+91 88260 19972", pin: "122002", verified: false, active: true,  city: "Gurugram" },
  { id: "vn5", vid: "VID-00128", name: "Konark Industrial Spares",   gstin: "24WXYZ7890A1Z2", contact: "Meera Joshi",      email: "meera@konark.co.in",          phone: "+91 99250 33041", pin: "395003", verified: true,  active: true,  city: "Surat" },
  { id: "vn6", vid: "VID-00501", name: "Sealine Maritime Pvt Ltd",   gstin: "32BCDEF0192G1Z4", contact: "Anu Pillai",       email: "buying@sealine.in",           phone: "+91 90490 21188", pin: "682304", verified: true,  active: false, city: "Kochi" },
];

const PRODUCTS = [
  { id: "p1", code: "ENG-BR-040", name: "Marine Bearing 6310-2RS",     desc: "Sealed deep-groove bearing, 50×110×27mm", vendors: 4, lastPrice: 4250, lastVendor: "Mahalakshmi Marine Stores", updated: "Apr 22, 2026", active: true },
  { id: "p2", code: "FLT-OIL-LO", name: "Lube Oil Filter — Element",   desc: "Cellulose element, 10µ rated",          vendors: 5, lastPrice: 1180, lastVendor: "Coastline Engineering", updated: "May 02, 2026", active: true },
  { id: "p3", code: "DCK-RP-024", name: "Mooring Rope — 24mm Polyester", desc: "8-strand, 200m coil, breaking load 11.2t", vendors: 3, lastPrice: 38900, lastVendor: "Konark Industrial Spares", updated: "Apr 11, 2026", active: true },
  { id: "p4", code: "PRV-RIC-25", name: "Basmati Rice — 25kg",          desc: "Aged, sortex-cleaned",                   vendors: 6, lastPrice: 2200, lastVendor: "Bluewater Provisions", updated: "May 10, 2026", active: true },
  { id: "p5", code: "SAF-EXT-09", name: "CO₂ Fire Extinguisher 9kg",    desc: "Marine-grade, BIS certified",            vendors: 4, lastPrice: 8400, lastVendor: "Sealine Maritime", updated: "Mar 30, 2026", active: true },
  { id: "p6", code: "ENG-GSK-12", name: "Cylinder Head Gasket Set",     desc: "MAN B&W L28/32H spares",                 vendors: 2, lastPrice: 18750, lastVendor: "Coastline Engineering", updated: "Feb 18, 2026", active: true },
  { id: "p7", code: "DCK-CHN-16", name: "Anchor Chain Shackle — D-type", desc: "16mm forged, galvanised",               vendors: 3, lastPrice: 3200, lastVendor: "Konark Industrial Spares", updated: "Apr 29, 2026", active: true },
];

const SITES = [
  { id: "s1", name: "Cochin Port Depot",  code: "COK-D1",  address: "Willingdon Island, Kochi 682003", pin: "682003", vessels: 2, items: 142, status: "active" },
  { id: "s2", name: "Mumbai BPX Office",  code: "BOM-O1",  address: "Ballard Estate, Mumbai 400001",  pin: "400001", vessels: 1, items: 38,  status: "active" },
  { id: "s3", name: "Chennai South Dock", code: "MAA-D1",  address: "Chennai Port Trust, 600001",     pin: "600001", vessels: 1, items: 96,  status: "active" },
  { id: "s4", name: "Visakhapatnam Yard", code: "VTZ-Y1",  address: "Outer Harbour Rd, 530035",       pin: "530035", vessels: 1, items: 64,  status: "active" },
];

const USERS = [
  { id: "u1", emp: "EMP-1042", name: "Anjali Krishnan",  email: "anjali.k@pelagia.co",  role: "MANAGER",   status: "active",   created: "Sep 14, 2024" },
  { id: "u2", emp: "EMP-1058", name: "Vikram Iyer",       email: "vikram.i@pelagia.co", role: "ACCOUNTS",   status: "active",   created: "Oct 03, 2024" },
  { id: "u3", emp: "EMP-1077", name: "Rajesh Pillai",     email: "rajesh.p@pelagia.co", role: "TECHNICAL",  status: "active",   created: "Nov 21, 2024" },
  { id: "u4", emp: "EMP-1083", name: "Fatima Sheikh",     email: "fatima.s@pelagia.co", role: "MANNING",    status: "active",   created: "Dec 05, 2024" },
  { id: "u5", emp: "EMP-1091", name: "Dev Shah",          email: "dev.s@pelagia.co",    role: "SUPERUSER",  status: "active",   created: "Jan 17, 2025" },
  { id: "u6", emp: "EMP-1106", name: "Lakshmi Rao",       email: "lakshmi.r@pelagia.co",role: "AUDITOR",    status: "active",   created: "Feb 02, 2025" },
];

const ORDERS = [
  {
    id: "PO-2026-00481", title: "Engine room bearings — Q2 replenishment",
    vessel: "MV Pelagia Voyager", account: "ENGINE", vendor: "Mahalakshmi Marine Stores", vendorId: "vn1",
    submitter: "Rajesh Pillai", status: "MGR_REVIEW",
    amount: 248300, currency: "INR", project: "ER-MAINT-2026",
    submitted: "May 11, 2026 · 09:42", created: "May 10, 2026", required: "May 28, 2026",
    items: [
      { name: "Marine Bearing 6310-2RS",      desc: "50×110×27mm, sealed",         qty: 24, unit: "ea", price: 4250,  gst: 18 },
      { name: "Marine Bearing 6207-ZZ",       desc: "35×72×17mm, shielded",        qty: 36, unit: "ea", price: 1850,  gst: 18 },
      { name: "Cylinder Head Gasket Set",     desc: "MAN B&W L28/32H",             qty: 4,  unit: "set", price: 18750, gst: 18 },
    ],
    terms: {
      delivery: "FOB Cochin Port. Vendor responsible until cargo cleared at gate.",
      dispatch: "Within 14 days of approval.",
      inspection: "Joint inspection at vendor warehouse prior to dispatch.",
      insurance: "Transit insurance included in vendor scope.",
      payment: "30 days from receipt of goods and invoice.",
      others: "All items to be packed with desiccant and shrink-wrapped."
    },
    docs: [
      { name: "Vendor Quotation Q-2841.pdf", size: "412 KB" },
      { name: "Engine Inspection Report.pdf", size: "1.8 MB" }
    ],
    audit: [
      { who: "Rajesh Pillai", what: "Created draft",         when: "May 10, 2026 · 16:24", done: true },
      { who: "Rajesh Pillai", what: "Submitted for approval", when: "May 11, 2026 · 09:42", done: true },
      { who: "Anjali Krishnan", what: "Opened for review",   when: "May 11, 2026 · 14:15", done: true },
    ]
  },
  {
    id: "PO-2026-00478", title: "Bridge electronics — radar maintenance",
    vessel: "MV Coral Crescent", account: "VC-OPS", vendor: "Coastline Engineering Co.", vendorId: "vn2",
    submitter: "Fatima Sheikh", status: "MGR_APPROVED",
    amount: 84200, currency: "INR", project: "NAV-RADAR",
    submitted: "May 09, 2026", created: "May 08, 2026", required: "Jun 02, 2026", approved: "May 10, 2026",
    items: [
      { name: "Radar Magnetron — X-band",    desc: "Replacement unit",   qty: 1, unit: "ea", price: 67500, gst: 18 },
      { name: "RF Connector N-type",          desc: "Bulkhead, IP67",     qty: 6, unit: "ea", price: 850,   gst: 18 },
    ]
  },
  {
    id: "PO-2026-00475", title: "Provisions — March crew rotation",
    vessel: "MV Arctic Halo", account: "PROV-MAR", vendor: "Bluewater Provisions", vendorId: "vn3",
    submitter: "Rajesh Pillai", status: "SENT_FOR_PAYMENT",
    amount: 142800, currency: "INR", project: null,
    submitted: "May 04, 2026", required: "May 18, 2026", approved: "May 06, 2026",
    items: []
  },
  {
    id: "PO-2026-00472", title: "Mooring ropes — port-side replacement",
    vessel: "MV North Drift", account: "DECK", vendor: "Konark Industrial Spares", vendorId: "vn5",
    submitter: "Fatima Sheikh", status: "EDITS_REQUESTED",
    amount: 198000, currency: "INR", project: "DCK-Q2",
    submitted: "May 02, 2026", required: "May 22, 2026",
    managerNote: "Please split into two POs — port and starboard side — as the budget owner differs. Also confirm 200m or 300m coil length.",
    items: []
  },
  {
    id: "PO-2026-00469", title: "Fire safety equipment — annual recert",
    vessel: "MV Saffron Star", account: "VC-OPS", vendor: "Sealine Maritime Pvt Ltd", vendorId: "vn6",
    submitter: "Dev Shah", status: "PAID_DELIVERED",
    amount: 67200, currency: "INR", project: null,
    submitted: "Apr 28, 2026", required: "May 12, 2026", approved: "Apr 30, 2026", paid: "May 07, 2026",
    items: []
  },
  {
    id: "PO-2026-00466", title: "Lube oil filter elements — bulk",
    vessel: "MV Pelagia Voyager", account: "ENGINE", vendor: "Coastline Engineering Co.", vendorId: "vn2",
    submitter: "Rajesh Pillai", status: "CLOSED",
    amount: 38700, currency: "INR", project: "ER-MAINT-2026",
    submitted: "Apr 22, 2026", approved: "Apr 24, 2026", paid: "Apr 30, 2026", closed: "May 06, 2026",
    items: []
  },
  {
    id: "PO-2026-00463", title: "Cabin linens & cleaning supplies",
    vessel: "MV Coral Crescent", account: "PROV-MAR", vendor: null,
    submitter: "Fatima Sheikh", status: "VENDOR_ID_PENDING",
    amount: 24600, currency: "INR", project: null,
    submitted: "Apr 21, 2026", items: []
  },
  {
    id: "PO-2026-00459", title: "Anchor chain inspection tools",
    vessel: "MV Arctic Halo", account: "DECK", vendor: "Mahalakshmi Marine Stores", vendorId: "vn1",
    submitter: "Rajesh Pillai", status: "DRAFT",
    amount: 14200, currency: "INR", project: null,
    items: []
  },
  {
    id: "PO-2026-00456", title: "Welding consumables — Q2",
    vessel: "MV North Drift", account: "ENGINE", vendor: "Konark Industrial Spares", vendorId: "vn5",
    submitter: "Dev Shah", status: "REJECTED",
    amount: 92400, currency: "INR", project: "ER-MAINT-2026",
    submitted: "Apr 19, 2026", rejected: "Apr 21, 2026",
    managerNote: "Rejected — duplicate of PO-2026-00451. Use existing requisition.",
    items: []
  },
  {
    id: "PO-2026-00453", title: "Galley equipment — coffee maker",
    vessel: "MV Saffron Star", account: "PROV-MAR", vendor: "Bluewater Provisions", vendorId: "vn3",
    submitter: "Fatima Sheikh", status: "MGR_APPROVED",
    amount: 18900, currency: "INR", project: null,
    submitted: "Apr 16, 2026", approved: "Apr 17, 2026",
    items: []
  },
  {
    id: "PO-2026-00451", title: "Welding consumables — Q2",
    vessel: "MV North Drift", account: "ENGINE", vendor: "Konark Industrial Spares", vendorId: "vn5",
    submitter: "Rajesh Pillai", status: "CLOSED",
    amount: 88300, currency: "INR", project: "ER-MAINT-2026",
    items: []
  },
];

// Approval queue derived
const APPROVAL_QUEUE = ORDERS.filter(o => o.status === "MGR_REVIEW").concat([
  {
    id: "PO-2026-00485", title: "Hydraulic hose replacement",
    vessel: "MV Saffron Star", account: "ENGINE", vendor: "Coastline Engineering Co.",
    submitter: "Dev Shah", status: "MGR_REVIEW",
    amount: 62400, submitted: "May 12, 2026 · 11:08"
  },
  {
    id: "PO-2026-00483", title: "Navigation chart subscriptions Q2",
    vessel: "MV Coral Crescent", account: "VC-OPS", vendor: "Sealine Maritime Pvt Ltd",
    submitter: "Fatima Sheikh", status: "MGR_REVIEW",
    amount: 31800, submitted: "May 12, 2026 · 08:30"
  },
  {
    id: "PO-2026-00482", title: "Crew safety boots — 24 pairs",
    vessel: "MV Arctic Halo", account: "DECK", vendor: "Anchor Supply Traders",
    submitter: "Rajesh Pillai", status: "MGR_REVIEW",
    amount: 96000, submitted: "May 11, 2026 · 16:55"
  },
]);

// Spend trend (last 8 months)
const SPEND_TREND = [
  { m: "Oct", v: 1240 }, { m: "Nov", v: 980 }, { m: "Dec", v: 1410 },
  { m: "Jan", v: 1820 }, { m: "Feb", v: 1580 }, { m: "Mar", v: 2110 },
  { m: "Apr", v: 1940 }, { m: "May", v: 1340 },
];

const VESSEL_SPEND = [
  { name: "MV Pelagia Voyager", v: 2840 },
  { name: "MV Coral Crescent",   v: 1620 },
  { name: "MV Arctic Halo",      v: 1180 },
  { name: "MV North Drift",      v: 920 },
  { name: "MV Saffron Star",     v: 760 },
];

// Vendor pricing for Item Detail
const ITEM_VENDORS = [
  { vendor: "Mahalakshmi Marine Stores", verified: true, price: 4250, distance: 12, updated: "Apr 22, 2026", closest: true },
  { vendor: "Coastline Engineering Co.", verified: true, price: 4380, distance: 1240, updated: "Mar 18, 2026" },
  { vendor: "Konark Industrial Spares",  verified: true, price: 4520, distance: 1820, updated: "Feb 02, 2026" },
  { vendor: "Anchor Supply Traders",     verified: false, price: 4180, distance: 2410, updated: "Jan 28, 2026" },
];

// Site inventory mock
const SITE_INVENTORY = [
  { name: "Marine Bearing 6310-2RS",    qty: 18, updated: "May 11" },
  { name: "Lube Oil Filter — Element",  qty: 64, updated: "May 09" },
  { name: "CO₂ Fire Extinguisher 9kg",  qty: 12, updated: "May 03" },
  { name: "Anchor Chain Shackle",       qty: 22, updated: "Apr 28" },
  { name: "Basmati Rice — 25kg",        qty: 8,  updated: "May 10" },
  { name: "Welding Rods — E7018",       qty: 40, updated: "May 02" },
];

const CONSUMPTION = [
  { d: 1, vals: [2,1,0,3,1] }, { d: 2, vals: [1,2,1,2,2] }, { d: 3, vals: [0,1,2,1,0] },
  { d: 4, vals: [3,2,0,2,1] }, { d: 5, vals: [2,3,1,1,2] }, { d: 6, vals: [1,1,2,0,3] },
  { d: 7, vals: [0,2,1,3,1] }, { d: 8, vals: [2,1,0,1,2] }, { d: 9, vals: [1,3,2,2,0] },
  { d: 10, vals: [3,2,1,0,2] }, { d: 11, vals: [2,1,3,1,1] }, { d: 12, vals: [1,2,0,2,3] },
];

Object.assign(window, {
  VESSELS, ACCOUNTS, VENDORS, PRODUCTS, SITES, USERS, ORDERS,
  APPROVAL_QUEUE, SPEND_TREND, VESSEL_SPEND, ITEM_VENDORS,
  SITE_INVENTORY, CONSUMPTION
});
