/*
 * cenora-bundle-2-mocks.tsx — auto-generated. DO NOT EDIT.
 */

/* ═════ apps/web/lib/mock/irq.tsx ═════ */
;/*__IIFE_WRAP_START__*/(function(){
/**
 * ============================================================================
 * apps/web/lib/mock/irq.ts
 * ----------------------------------------------------------------------------
 * Mock IRQ data. Shape mirrors the cnr_itemrequest + cnr_itemrequestline
 * schema from the master ref doc (Part C2), so engineers can map directly.
 *
 * NOTE: In production this comes from PostgreSQL via Fastify middleware
 * (master ref D2). Replace this file with API calls.
 * ============================================================================
 */

type Stage = "draft" | "submitted" | "review" | "approved" | "rejected"

interface IRQ {
  id: string            /* documentno (e.g. IRQ-0212) */
  stage: Stage          /* derived from cnr_approvalstatus */
  title: string         /* cnr_itemname */
  family: string        /* cnr_productfamily */
  itemCount: number     /* count of cnr_itemrequestline rows */
  date: string          /* dateordered, formatted */
  dateISO: string
  requestor: { name: string; initials: string }
  /* Stage-specific */
  aiFlag?: string                                  /* cnr_duplicateflag detail */
  aiMatches?: { code: string; name: string; pct: number }[]
  pendingThread?: { from: string; message: string }[]
  approvers?: { initials: string; tone?: any }[]
  itemCode?: string                                /* cnr_itemcode once approved */
  rejection?: string
  /* Line items (cnr_itemrequestline) */
  lines?: {
    line: number
    itemName: string
    description?: string
    qty?: number
    uom?: string
    brand?: string
    specification?: string
    material?: string
    variant?: string
  }[]
}

const IRQ_DATA: IRQ[] = [
  /* DRAFT */
  { id: "IRQ-0211", stage: "draft", title: "Hydraulic Concrete Mixer 500L", family: "Construction",
    itemCount: 1, date: "Apr 16", dateISO: "2026-04-16", requestor: { name: "Leo M.", initials: "LM" } },
  { id: "IRQ-0210", stage: "draft", title: "Fire Extinguisher Powder 6kg × 20 units", family: "General",
    itemCount: 1, date: "Apr 15", dateISO: "2026-04-15", requestor: { name: "Ana R.", initials: "AR" } },

  /* SUBMITTED */
  { id: "IRQ-0209", stage: "submitted", title: "Structural Steel I-Beam 200×100mm, Grade 50", family: "Construction",
    itemCount: 3, date: "Apr 14", dateISO: "2026-04-14", requestor: { name: "Ben L.", initials: "BL" },
    aiFlag: "possible duplicate of 02CC0101-008",
    aiMatches: [
      { code: "02010101-008", name: "Steel I-Beam 203×102mm Grade 50 — SteelMark", pct: 91 },
      { code: "02010101-009", name: "I-Beam Structural Steel 200mm Wide Flange", pct: 74 },
    ],
    approvers: [{ initials: "MC", tone: "teal" }],
    lines: [
      { line: 10, itemName: "Steel I-Beam 200×100mm Grade 50", qty: 24, uom: "PC", brand: "SteelMark", specification: "Grade 50 · ASTM A992", material: "Structural Steel", variant: "W8×31" },
      { line: 20, itemName: "Anchor Bolt M16×200mm Galvanised", qty: 200, uom: "PC", brand: "BlueStar", material: "Galv. Steel" },
      { line: 30, itemName: "Steel Plate 10mm × 1200×2400", qty: 8, uom: "PC", material: "Steel" },
    ],
  },
  { id: "IRQ-0208", stage: "submitted", title: "Commercial Undercounter Refrigerator 150L", family: "Kitchen Equip",
    itemCount: 2, date: "Apr 13", dateISO: "2026-04-13", requestor: { name: "Maria S.", initials: "MS" },
    approvers: [{ initials: "MC", tone: "teal" }] },
  { id: "IRQ-0207", stage: "submitted", title: "Solar Panel 450W Monocrystalline", family: "Energy",
    itemCount: 5, date: "Apr 12", dateISO: "2026-04-12", requestor: { name: "Rico D.", initials: "RD" },
    approvers: [{ initials: "MC", tone: "teal" }] },

  /* UNDER REVIEW */
  { id: "IRQ-0206", stage: "review", title: "Precast Concrete Hollow Core Slab 200mm", family: "Fabrication",
    itemCount: 4, date: "Apr 10", dateISO: "2026-04-10", requestor: { name: "Rhino Cast team", initials: "RC" },
    pendingThread: [
      { from: "Maya C. · Approver", message: "Please confirm grade specification. Is this for the Calamba Phase 2 slabs? Need ACI compliance certification on file." },
      { from: "Rhino Cast team", message: "Yes — Phase 2. Grade 30 MPa per structural spec sheet rev. C. ACI cert from supplier (Holcim PH) attached." },
      { from: "Maya C. · Approver", message: "Got it. One more — what subcategory should this sit under? 0201-Structural-Concrete or 0202-Fabricated-Precast?" },
    ],
  },
  { id: "IRQ-0205", stage: "review", title: "Heavy Duty Extension Cord 50m with Ground", family: "General",
    itemCount: 1, date: "Apr 9", dateISO: "2026-04-09", requestor: { name: "Ana R.", initials: "AR" },
    approvers: [{ initials: "MC", tone: "teal" }, { initials: "JD", tone: "amber" }] },

  /* APPROVED */
  { id: "IRQ-0204", stage: "approved", title: "Network Switch 24-Port PoE Managed", family: "General",
    itemCount: 1, date: "Apr 8", dateISO: "2026-04-08", requestor: { name: "Maria S.", initials: "MS" },
    itemCode: "01010301-001" },
  { id: "IRQ-0203", stage: "approved", title: "Angle Grinder 230mm 2000W with Guards", family: "Tools & Equip",
    itemCount: 2, date: "Apr 7", dateISO: "2026-04-07", requestor: { name: "Ben L.", initials: "BL" },
    itemCode: "13020201-001" },

  /* REJECTED */
  { id: "IRQ-0202", stage: "rejected", title: "Laptop Dell Vostro 15\" i7 16GB RAM", family: "General",
    itemCount: 1, date: "Apr 5", dateISO: "2026-04-05", requestor: { name: "Maria S.", initials: "MS" },
    rejection: "Duplicate of 01010101-042" },
]

const STAGE_LABELS: Record<Stage, string> = {
  draft: "Draft", submitted: "Submitted", review: "Under Review",
  approved: "Approved", rejected: "Rejected",
}
const STAGE_TONES: Record<Stage, { badge: string; dot: string }> = {
  draft:     { badge: "neutral", dot: "bg-divider-strong" },
  submitted: { badge: "info",    dot: "bg-info" },
  review:    { badge: "warn",    dot: "bg-warn" },
  approved:  { badge: "success", dot: "bg-success" },
  rejected:  { badge: "danger",  dot: "bg-danger" },
}

const IRQ_BY_ID: Record<string, IRQ> = Object.fromEntries(IRQ_DATA.map(d => [d.id, d]))

// SANDBOX
Object.assign(globalThis as any, { IRQ_DATA, STAGE_LABELS, STAGE_TONES, IRQ_BY_ID })

})();/*__IIFE_WRAP_END__*/

/* ═════ apps/web/lib/mock/procurement.tsx ═════ */
;/*__IIFE_WRAP_START__*/(function(){
/**
 * ============================================================================
 * apps/web/lib/mock/procurement.ts
 * ----------------------------------------------------------------------------
 * Mock POs, Item Receipts, Vendors.
 * ============================================================================
 */

interface PO {
  id: string
  vendor: { id: string; name: string; category: string; tin?: string }
  items: string
  itemCount: number
  poDate: string
  expected: string
  expectedISO: string
  daysLate?: number
  amount: number
  match: "matched" | "pending" | "partial" | "no-ir" | "service"
  status: "draft" | "sent" | "partial" | "received" | "overdue" | "cancelled" | "in-progress"
  starred?: boolean
  lines?: {
    line: number
    itemCode: string
    description: string
    qty: number
    uom: string
    unitPrice: number
  }[]
}

const PO_DATA: PO[] = [
  { id: "PO-HVPH-1089",
    vendor: { id: "v-steelmark", name: "SteelMark Industries", category: "Construction · Steel", tin: "008-235-441-000" },
    items: "Steel Rebar 16mm × 200 pcs",
    itemCount: 1, poDate: "Apr 8, 2026", expected: "Apr 14 · 3 days late", expectedISO: "2026-04-14",
    daysLate: 3, amount: 18400, match: "no-ir", status: "overdue",
    lines: [
      { line: 10, itemCode: "02010102-014", description: "Steel Rebar 16mm × 12m Grade 60", qty: 200, uom: "PC", unitPrice: 92.00 },
    ],
  },
  { id: "PO-HVPH-1090",
    vendor: { id: "v-pacific-solar", name: "Pacific Solar PH", category: "Energy · Solar" },
    items: "Solar Panel 450W × 20 units",
    itemCount: 1, poDate: "Apr 10, 2026", expected: "Apr 20, 2026", expectedISO: "2026-04-20",
    amount: 22000, match: "pending", status: "sent" },
  { id: "PO-HVPH-1088",
    vendor: { id: "v-apex-kitchen", name: "Apex Kitchen Supplies", category: "Kitchen Equipment" },
    items: "Commercial Fryer 40L × 2 units",
    itemCount: 1, poDate: "Apr 6, 2026", expected: "Apr 16, 2026", expectedISO: "2026-04-16",
    amount: 8600, match: "partial", status: "partial" },
  { id: "PO-HVPH-1087",
    vendor: { id: "v-chem", name: "Chem Supplies Corp", category: "General · Chemical" },
    items: "Waterproof Sealant 5L × 50 pcs",
    itemCount: 1, poDate: "Apr 3, 2026", expected: "Apr 10 · 7 days late", expectedISO: "2026-04-10",
    daysLate: 7, amount: 4600, match: "no-ir", status: "overdue" },
  { id: "PO-HVPH-1086",
    vendor: { id: "v-technet", name: "TechNet Solutions", category: "General · IT" },
    items: "Network Switch 24-port PoE",
    itemCount: 1, poDate: "Apr 1, 2026", expected: "Apr 12, 2026", expectedISO: "2026-04-12",
    amount: 6100, match: "matched", status: "received" },
  { id: "PO-HVPH-1085",
    vendor: { id: "v-unioffice", name: "UniOffice Manila", category: "General · Office" },
    items: "Office Supplies Bundle Q2",
    itemCount: 1, poDate: "Mar 28, 2026", expected: "Apr 4, 2026", expectedISO: "2026-04-04",
    amount: 9200, match: "matched", status: "received" },
  { id: "PO-HVPH-1084",
    vendor: { id: "v-lydia", name: "Lydia V. Arellano", category: "Professional Services" },
    items: "Audited Financial Statements FY2025",
    itemCount: 1, poDate: "Mar 20, 2026", expected: "Apr 30, 2026", expectedISO: "2026-04-30",
    amount: 15000, match: "service", status: "in-progress", starred: true },
]

const PO_BY_ID: Record<string, PO> = Object.fromEntries(PO_DATA.map(p => [p.id, p]))

/* ─── ITEM RECEIPTS (IR — replacing GRN) ─────────────────────────────────── */
interface IR {
  id: string
  poId: string
  receivedDate: string
  receivedBy: string
  warehouse: string
  lines: {
    itemCode: string
    description: string
    ordered: number
    received: number
    uom: string
    lotNumber?: string
    variance?: number
  }[]
  threeWayMatch: { pr: boolean; po: boolean; ir: boolean; invoice: boolean }
}

const IR_DATA: IR[] = [
  { id: "IR-HVPH-1001",
    poId: "PO-HVPH-1089",
    receivedDate: "Apr 15, 2026",
    receivedBy: "Joel D.",
    warehouse: "Calamba Site Warehouse",
    lines: [
      { itemCode: "02010102-014", description: "Steel Rebar 16mm × 12m Grade 60", ordered: 200, received: 200, uom: "PC", lotNumber: "LOT-SMK-26041-A" },
    ],
    threeWayMatch: { pr: true, po: true, ir: true, invoice: false },
  },
]
const IR_BY_ID: Record<string, IR> = Object.fromEntries(IR_DATA.map(i => [i.id, i]))

/* ─── VENDORS ────────────────────────────────────────────────────────────── */
interface Vendor {
  id: string
  name: string
  initials: string
  tone: any
  tin: string
  starred?: boolean
  level1: "Supplier" | "Contractor" | "Prof Services"
  level2: string
  level3?: string
  ytdSpend: number
  openPOs: number
  onTimePct: number
  overdueAlert?: string
}

const VENDORS: Vendor[] = [
  { id: "v-steelmark",     name: "SteelMark Industries", initials: "SM", tone: "amber", tin: "008-235-441-000",
    level1: "Supplier", level2: "Steel & Rebar", level3: "Structural",
    ytdSpend: 184600, openPOs: 4, onTimePct: 78, overdueAlert: "PO-1089 · 3 days late", starred: true },
  { id: "v-pacific-solar", name: "Pacific Solar PH", initials: "PS", tone: "blue", tin: "002-118-340-000",
    level1: "Supplier", level2: "Solar", level3: "Panels",
    ytdSpend: 96400, openPOs: 2, onTimePct: 94, starred: true },
  { id: "v-apex-kitchen",  name: "Apex Kitchen Supplies", initials: "AK", tone: "amber", tin: "009-441-202-000",
    level1: "Supplier", level2: "Kitchen Equipment",
    ytdSpend: 42100, openPOs: 1, onTimePct: 88 },
  { id: "v-technet",       name: "TechNet Solutions", initials: "TN", tone: "teal", tin: "002-880-411-000",
    level1: "Supplier", level2: "IT Hardware",
    ytdSpend: 28800, openPOs: 0, onTimePct: 100 },
  { id: "v-unioffice",     name: "UniOffice Manila", initials: "UO", tone: "ink", tin: "008-204-993-000",
    level1: "Supplier", level2: "Office Supplies",
    ytdSpend: 14200, openPOs: 0, onTimePct: 96 },
  { id: "v-chem",          name: "Chem Supplies Corp", initials: "CS", tone: "red", tin: "008-410-202-000",
    level1: "Supplier", level2: "Chemical",
    ytdSpend: 8800, openPOs: 1, onTimePct: 64, overdueAlert: "PO-1087 · 7 days late" },
  { id: "v-lydia",         name: "Lydia V. Arellano", initials: "LA", tone: "sand", tin: "120-441-000-000",
    level1: "Prof Services", level2: "Audit & Accounting",
    ytdSpend: 30000, openPOs: 1, onTimePct: 100, starred: true },
  { id: "v-rhinocast",     name: "Rhino Cast Industries", initials: "RC", tone: "amber", tin: "008-880-111-000",
    level1: "Contractor", level2: "Fabrication", level3: "Precast Concrete",
    ytdSpend: 142000, openPOs: 2, onTimePct: 91 },
]

const PO_STATUS_LABEL: Record<PO["status"], string> = {
  draft: "Draft", sent: "Sent to Vendor", partial: "Partial Receipt",
  received: "Fully Received", overdue: "Overdue", cancelled: "Cancelled",
  "in-progress": "In Progress",
}
const PO_STATUS_TONE: Record<PO["status"], string> = {
  draft: "neutral", sent: "info", partial: "warn",
  received: "success", overdue: "danger", cancelled: "neutral", "in-progress": "info",
}

// SANDBOX
Object.assign(globalThis as any, { PO_DATA, PO_BY_ID, IR_DATA, IR_BY_ID, VENDORS, PO_STATUS_LABEL, PO_STATUS_TONE })

})();/*__IIFE_WRAP_END__*/

/* ═════ apps/web/lib/mock/pr.tsx ═════ */
;/*__IIFE_WRAP_START__*/(function(){
/**
 * ============================================================================
 * apps/web/lib/mock/pr.tsx
 * ----------------------------------------------------------------------------
 * Order Requests — upstream of POs. A PR is what an internal requestor
 * submits ("I need 50 hard hats for the Cebu site by next Friday"). The
 * procurement team approves, sources vendors, and converts the PR to one
 * or more POs.
 *
 * Master ref schema: cnr_purchaserequest + cnr_purchaserequestline.
 * ============================================================================
 */

interface PR {
  id: string                  /* OR-HVPH-2204 */
  title: string
  requestor: { name: string; initials: string; tone?: any }
  department: string
  costCenter: string
  needBy: string              /* "Apr 28, 2026" */
  needByISO: string
  status: "draft" | "submitted" | "review" | "approved" | "sourced" | "converted" | "rejected"
  urgent?: boolean
  totalEst: number
  currency: "PHP" | "SGD" | "HKD" | "USD"
  lineCount: number
  itemSummary: string         /* "3 line items · Hard hats, vests, gloves" */
  justification?: string
  daysOpen: number
  /* When converted to PO */
  convertedTo?: string[]      /* ["PO-HVPH-1089"] */
  /* Approval chain */
  approvers?: { name: string; initials: string; tone?: any; decision?: "pending" | "approved" | "rejected" }[]
  /* Sourcing — pending quotes */
  quotesReceived?: number
  quotesExpected?: number
}

const PRS: PR[] = [
  /* DRAFTS */
  { id: "OR-HVPH-2210", title: "Calamba Site — Q3 PPE replenishment",
    requestor: { name: "Warren C.", initials: "WC", tone: "amber" }, department: "Operations", costCenter: "OPS-CAL-PPE",
    needBy: "May 12, 2026", needByISO: "2026-05-12",
    status: "draft", totalEst: 38400, currency: "PHP", lineCount: 6,
    itemSummary: "Hard hats × 40 · Safety vests × 60 · Work gloves × 200 · …",
    daysOpen: 1 },
  { id: "OR-HVPH-2209", title: "IT — Monitoring stack annual licences",
    requestor: { name: "Pedro S.", initials: "PS", tone: "blue" }, department: "IT", costCenter: "IT-LIC-2026",
    needBy: "Jun 01, 2026", needByISO: "2026-06-01",
    status: "draft", totalEst: 14800, currency: "USD", lineCount: 4,
    itemSummary: "Grafana Cloud · Sentry Pro · PagerDuty · Datadog APM",
    daysOpen: 2 },

  /* SUBMITTED — awaiting first approval */
  { id: "OR-HVPH-2208", title: "Phase 2 — Structural steel package",
    requestor: { name: "Ben L.", initials: "BL", tone: "teal" }, department: "Construction", costCenter: "PROJ-CAL-P2",
    needBy: "Apr 28, 2026", needByISO: "2026-04-28",
    status: "submitted", urgent: true, totalEst: 184600, currency: "PHP", lineCount: 5,
    itemSummary: "I-Beam W8×31 × 24 · Rebar 16mm × 400 · Plate 10mm × 8 · …",
    daysOpen: 3,
    justification: "Phase 2 pour scheduled Apr 30. Without these the slab schedule slips by 2 weeks and we lose the dry-weather window.",
    approvers: [
      { name: "Maya C.",   initials: "MC", tone: "teal",  decision: "pending" },
      { name: "Rico T.",  initials: "RT", tone: "blue",  decision: "pending" },
    ] },
  { id: "OR-HVPH-2207", title: "Solar inverter spares — Cebu rooftop",
    requestor: { name: "Rico D.", initials: "RD", tone: "amber" }, department: "Operations", costCenter: "OPS-CEB-SOLAR",
    needBy: "May 03, 2026", needByISO: "2026-05-03",
    status: "submitted", totalEst: 88000, currency: "PHP", lineCount: 2,
    itemSummary: "String Inverter 50kW × 1 · DC isolator × 4",
    daysOpen: 4,
    approvers: [{ name: "Maya C.", initials: "MC", tone: "teal", decision: "pending" }] },
  { id: "OR-HVPH-2206", title: "Office paper Q2 — Manila HQ",
    requestor: { name: "Ana Q.", initials: "AQ", tone: "sand" }, department: "Procurement", costCenter: "GA-HQ-MNL",
    needBy: "Apr 30, 2026", needByISO: "2026-04-30",
    status: "submitted", totalEst: 14200, currency: "PHP", lineCount: 2,
    itemSummary: "A4 80gsm × 60 reams · A4 100gsm × 20 reams",
    daysOpen: 4,
    approvers: [{ name: "Maya C.", initials: "MC", tone: "teal", decision: "pending" }] },

  /* REVIEW — back-and-forth */
  { id: "OR-HVPH-2205", title: "Commercial fryer — Lipa canteen",
    requestor: { name: "Maria S.", initials: "MS", tone: "blue" }, department: "Facilities", costCenter: "FAC-LIPA-CAN",
    needBy: "May 15, 2026", needByISO: "2026-05-15",
    status: "review", totalEst: 8600, currency: "PHP", lineCount: 1,
    itemSummary: "Commercial Fryer 40L SS × 2",
    daysOpen: 6,
    approvers: [
      { name: "Maya C.", initials: "MC", tone: "teal", decision: "approved" },
      { name: "Rico T.", initials: "RT", tone: "blue", decision: "pending" },
    ] },

  /* APPROVED — ready for sourcing */
  { id: "OR-HVPH-2204", title: "WiFi 6 APs — Manila HQ refresh",
    requestor: { name: "Pedro S.", initials: "PS", tone: "blue" }, department: "IT", costCenter: "IT-INFRA-HQ",
    needBy: "May 18, 2026", needByISO: "2026-05-18",
    status: "approved", totalEst: 10560, currency: "USD", lineCount: 1,
    itemSummary: "WiFi 6 AP AX3000 × 22",
    daysOpen: 8 },
  { id: "OR-HVPH-2203", title: "Concrete order — Phase 2 slab pour",
    requestor: { name: "Ben L.", initials: "BL", tone: "teal" }, department: "Construction", costCenter: "PROJ-CAL-P2",
    needBy: "Apr 30, 2026", needByISO: "2026-04-30",
    status: "approved", urgent: true, totalEst: 326800, currency: "PHP", lineCount: 1,
    itemSummary: "Ready-Mix Concrete 25 MPa × 86 m³",
    daysOpen: 9 },

  /* SOURCED — quotes in, picking vendor */
  { id: "OR-HVPH-2202", title: "Network switches — Cebu branch upgrade",
    requestor: { name: "Pedro S.", initials: "PS", tone: "blue" }, department: "IT", costCenter: "IT-CEB-INFRA",
    needBy: "May 22, 2026", needByISO: "2026-05-22",
    status: "sourced", totalEst: 12240, currency: "USD", lineCount: 2,
    itemSummary: "Switch 48-port PoE++ × 3 · Switch 24-port PoE+ × 4",
    daysOpen: 12, quotesReceived: 3, quotesExpected: 3 },
  { id: "OR-HVPH-2201", title: "Industrial degreaser — Q2 stocking",
    requestor: { name: "Warren C.", initials: "WC", tone: "amber" }, department: "Operations", costCenter: "OPS-CAL-CHEM",
    needBy: "May 05, 2026", needByISO: "2026-05-05",
    status: "sourced", totalEst: 14400, currency: "PHP", lineCount: 1,
    itemSummary: "Industrial Degreaser 20L × 12",
    daysOpen: 13, quotesReceived: 2, quotesExpected: 3 },

  /* CONVERTED — has a PO already */
  { id: "OR-HVPH-2200", title: "Steel Rebar 16mm — Phase 1 finish",
    requestor: { name: "Ben L.", initials: "BL", tone: "teal" }, department: "Construction", costCenter: "PROJ-CAL-P1",
    needBy: "Apr 14, 2026", needByISO: "2026-04-14",
    status: "converted", totalEst: 18400, currency: "PHP", lineCount: 1,
    itemSummary: "Steel Rebar 16mm × 12m Grade 60 × 200",
    daysOpen: 18, convertedTo: ["PO-HVPH-1089"] },
  { id: "OR-HVPH-2199", title: "Office paper Q1 — Manila HQ",
    requestor: { name: "Ana Q.", initials: "AQ", tone: "sand" }, department: "Procurement", costCenter: "GA-HQ-MNL",
    needBy: "Apr 04, 2026", needByISO: "2026-04-04",
    status: "converted", totalEst: 9200, currency: "PHP", lineCount: 1,
    itemSummary: "Office Supplies Bundle Q2 × 1",
    daysOpen: 22, convertedTo: ["PO-HVPH-1085"] },

  /* REJECTED */
  { id: "OR-HVPH-2198", title: "MacBook Pro 16\" M3 Max × 4",
    requestor: { name: "Pedro S.", initials: "PS", tone: "blue" }, department: "IT", costCenter: "IT-HW-DEV",
    needBy: "Apr 18, 2026", needByISO: "2026-04-18",
    status: "rejected", totalEst: 24000, currency: "USD", lineCount: 1,
    itemSummary: "MacBook Pro 16\" M3 Max 64GB 2TB × 4",
    daysOpen: 24,
    justification: "Engineering team refresh — current MBPs are 4 years old.",
    approvers: [
      { name: "Maya C.",  initials: "MC", tone: "teal",  decision: "approved" },
      { name: "Olivia P.", initials: "OP", tone: "amber", decision: "rejected" },
    ] },
]

const PR_STATUS_LABEL: Record<PR["status"], string> = {
  draft: "Draft", submitted: "Submitted", review: "Under Review",
  approved: "Approved", sourced: "Sourcing", converted: "Converted to PO",
  rejected: "Rejected",
}
const PR_STATUS_TONE: Record<PR["status"], string> = {
  draft: "neutral", submitted: "info", review: "warn",
  approved: "success", sourced: "accent", converted: "brand", rejected: "danger",
}

const PR_BY_ID: Record<string, PR> = Object.fromEntries(PRS.map(p => [p.id, p]))

// SANDBOX
Object.assign(globalThis as any, { PRS, PR_BY_ID, PR_STATUS_LABEL, PR_STATUS_TONE })

})();/*__IIFE_WRAP_END__*/

/* ═════ apps/web/lib/mock/catalogue.tsx ═════ */
;/*__IIFE_WRAP_START__*/(function(){
/**
 * ============================================================================
 * apps/web/lib/mock/catalogue.tsx
 * ----------------------------------------------------------------------------
 * Master data for the Catalogue · MDM module:
 *
 *   • CATEGORIES   — 4-level hierarchy (cnr_category schema in master ref doc)
 *   • ATTRIBUTES   — attribute templates per category (cnr_attribute)
 *   • PRODUCTS     — approved items with codes, attributes, stock per WH
 *
 * Engineers replace this with API calls to /api/catalogue/* in production.
 * ============================================================================
 */

/* ─── CATEGORIES (4-level cnr_category tree) ────────────────────────────── */

interface CategoryNode {
  code: string
  name: string
  level: 1 | 2 | 3 | 4
  itemCount: number
  children?: CategoryNode[]
}

const CATEGORIES: CategoryNode[] = [
  { code: "01", name: "IT & Network", level: 1, itemCount: 184, children: [
    { code: "0101", name: "Hardware", level: 2, itemCount: 112, children: [
      { code: "010101", name: "Network Equipment", level: 3, itemCount: 48, children: [
        { code: "01010101", name: "Switches", level: 4, itemCount: 18 },
        { code: "01010102", name: "Routers", level: 4, itemCount: 12 },
        { code: "01010103", name: "Access Points", level: 4, itemCount: 11 },
        { code: "01010104", name: "Cabling & Patch", level: 4, itemCount: 7 },
      ]},
      { code: "010102", name: "Servers & Storage", level: 3, itemCount: 22 },
      { code: "010103", name: "End-User Devices", level: 3, itemCount: 42 },
    ]},
    { code: "0102", name: "Software & Licensing", level: 2, itemCount: 72 },
  ]},
  { code: "02", name: "Construction", level: 1, itemCount: 312, children: [
    { code: "0201", name: "Structural", level: 2, itemCount: 188, children: [
      { code: "020101", name: "Steel", level: 3, itemCount: 96, children: [
        { code: "02010101", name: "I-Beams", level: 4, itemCount: 28 },
        { code: "02010102", name: "Rebar", level: 4, itemCount: 34 },
        { code: "02010103", name: "Plates", level: 4, itemCount: 18 },
        { code: "02010104", name: "Tubing & Pipe", level: 4, itemCount: 16 },
      ]},
      { code: "020102", name: "Concrete", level: 3, itemCount: 62 },
      { code: "020103", name: "Aggregates", level: 3, itemCount: 30 },
    ]},
    { code: "0202", name: "Fabrication", level: 2, itemCount: 84, children: [
      { code: "020201", name: "Precast", level: 3, itemCount: 38 },
      { code: "020202", name: "Steel Fabrication", level: 3, itemCount: 46 },
    ]},
    { code: "0203", name: "Finishing", level: 2, itemCount: 40 },
  ]},
  { code: "03", name: "Chemical & Cleaning", level: 1, itemCount: 88 },
  { code: "04", name: "Energy & Power", level: 1, itemCount: 96, children: [
    { code: "0401", name: "Solar", level: 2, itemCount: 38, children: [
      { code: "040101", name: "Panels", level: 3, itemCount: 14 },
      { code: "040102", name: "Inverters", level: 3, itemCount: 12 },
      { code: "040103", name: "Mounts & BoS", level: 3, itemCount: 12 },
    ]},
    { code: "0402", name: "Generators & UPS", level: 2, itemCount: 28 },
    { code: "0403", name: "Electrical", level: 2, itemCount: 30 },
  ]},
  { code: "06", name: "Office Supplies", level: 1, itemCount: 64 },
  { code: "07", name: "Sealants & Adhesives", level: 1, itemCount: 32 },
  { code: "10", name: "Safety & PPE", level: 1, itemCount: 76, children: [
    { code: "1001", name: "Hand Protection", level: 2, itemCount: 22 },
    { code: "1002", name: "Head & Body PPE", level: 2, itemCount: 38 },
    { code: "1003", name: "Respiratory", level: 2, itemCount: 16 },
  ]},
  { code: "11", name: "Kitchen Equipment", level: 1, itemCount: 28 },
  { code: "12", name: "Emergency & Medical", level: 1, itemCount: 24 },
  { code: "13", name: "Tools & Equipment", level: 1, itemCount: 92 },
]

/* Flatten to a fast lookup (code → node) for breadcrumbs */
function flattenCategories(nodes: CategoryNode[], acc: CategoryNode[] = []): CategoryNode[] {
  for (const n of nodes) {
    acc.push(n)
    if (n.children) flattenCategories(n.children, acc)
  }
  return acc
}
const CATEGORY_BY_CODE: Record<string, CategoryNode> = Object.fromEntries(
  flattenCategories(CATEGORIES).map(n => [n.code, n])
)

/** "02010102" → ["Construction", "Structural", "Steel", "Rebar"] */
function categoryBreadcrumb(code: string): string[] {
  const out: string[] = []
  for (let i = 2; i <= code.length; i += 2) {
    const seg = code.slice(0, i)
    const node = CATEGORY_BY_CODE[seg]
    if (node) out.push(node.name)
  }
  return out
}

/* ─── ATTRIBUTE TEMPLATES (cnr_attribute schema) ─────────────────────────── */

interface AttributeTemplate {
  id: string
  name: string
  fieldType: "text" | "number" | "decimal" | "select" | "multi-select" | "boolean" | "date"
  unit?: string
  required: boolean
  validation?: string
  appliedTo: string[]        /* category codes this template applies to */
  appliedCount: number       /* products using this attr */
  options?: string[]         /* for select / multi-select */
}

const ATTRIBUTES: AttributeTemplate[] = [
  { id: "attr-diameter",     name: "Diameter",            fieldType: "decimal",    unit: "mm",  required: true,  validation: "> 0",
    appliedTo: ["02010102", "02010104"], appliedCount: 50 },
  { id: "attr-length",       name: "Length",              fieldType: "decimal",    unit: "m",   required: true,  validation: "> 0",
    appliedTo: ["020101", "020102"], appliedCount: 158 },
  { id: "attr-grade",        name: "Steel Grade",         fieldType: "select",     required: true,
    appliedTo: ["020101"], appliedCount: 96, options: ["Grade 33", "Grade 40", "Grade 50", "Grade 60", "Grade 75"] },
  { id: "attr-astm",         name: "ASTM Standard",       fieldType: "select",     required: false,
    appliedTo: ["020101"], appliedCount: 96, options: ["A36", "A572", "A615", "A706", "A992"] },
  { id: "attr-wattage",      name: "Wattage",             fieldType: "number",     unit: "W",   required: true,  validation: "> 0",
    appliedTo: ["0401", "0403"], appliedCount: 68 },
  { id: "attr-voltage",      name: "Voltage",             fieldType: "select",     unit: "V",   required: true,
    appliedTo: ["0401", "0403"], appliedCount: 68, options: ["12", "24", "120", "220", "240", "480"] },
  { id: "attr-ports",        name: "Port Count",          fieldType: "number",     required: true,
    appliedTo: ["010101"], appliedCount: 48 },
  { id: "attr-poe",          name: "PoE Support",         fieldType: "select",     required: false,
    appliedTo: ["010101"], appliedCount: 48, options: ["None", "PoE", "PoE+", "PoE++"] },
  { id: "attr-shelf-life",   name: "Shelf Life",          fieldType: "number",     unit: "months", required: true,  validation: "≥ 1",
    appliedTo: ["03", "07"], appliedCount: 120 },
  { id: "attr-haz",          name: "Hazardous",           fieldType: "boolean",    required: true,
    appliedTo: ["03"], appliedCount: 88 },
  { id: "attr-cert",         name: "Certification Type",  fieldType: "multi-select", required: false,
    appliedTo: ["10"], appliedCount: 76, options: ["ANSI Z89", "EN 397", "ISEA Z87", "ANSI Z358", "EN 388"] },
  { id: "attr-capacity",     name: "Capacity",            fieldType: "decimal",    unit: "L",   required: true,  validation: "> 0",
    appliedTo: ["11", "12"], appliedCount: 52 },
  { id: "attr-warranty",     name: "Warranty (months)",   fieldType: "number",     required: false, validation: "≥ 0",
    appliedTo: ["01", "04", "11", "13"], appliedCount: 380 },
  { id: "attr-haccp",        name: "HACCP Compliant",     fieldType: "boolean",    required: false,
    appliedTo: ["11"], appliedCount: 28 },
]

/* ─── PRODUCTS (cnr_item with cnr_itemcode) ─────────────────────────────── */

interface ProductRow {
  code: string                /* 8-digit cnr_itemcode */
  name: string
  category: string            /* 8-digit category code */
  uom: string
  lifecycle: "active" | "new" | "phasing-out" | "discontinued"
  unitCost: number            /* USD-equiv */
  currency: "PHP" | "SGD" | "HKD" | "USD"
  primaryVendor: string
  onHand: number              /* across selected entity */
  onHandWHs: number           /* warehouses carrying it */
  reorderLevel: number
  attrSummary: string         /* compact key attrs e.g. "Ø16mm · L12m · Grade 60" */
  created: string             /* ISO date */
  starred?: boolean
}

const PRODUCTS: ProductRow[] = [
  /* Steel */
  { code: "02010102-014", name: "Steel Rebar 16mm × 12m Grade 60",       category: "02010102", uom: "PC", lifecycle: "active", unitCost: 92,    currency: "PHP", primaryVendor: "SteelMark Industries",   onHand: 412, onHandWHs: 2, reorderLevel: 150, attrSummary: "Ø16mm · L12m · Grade 60 · ASTM A615", created: "2024-08-12", starred: true },
  { code: "02010102-018", name: "Steel Rebar 20mm × 12m Grade 60",       category: "02010102", uom: "PC", lifecycle: "active", unitCost: 132,   currency: "PHP", primaryVendor: "SteelMark Industries",   onHand: 224, onHandWHs: 1, reorderLevel: 100, attrSummary: "Ø20mm · L12m · Grade 60 · ASTM A615", created: "2024-08-12" },
  { code: "02010102-022", name: "Steel Rebar 25mm × 12m Grade 60",       category: "02010102", uom: "PC", lifecycle: "active", unitCost: 188,   currency: "PHP", primaryVendor: "SteelMark Industries",   onHand: 168, onHandWHs: 2, reorderLevel: 80,  attrSummary: "Ø25mm · L12m · Grade 60 · ASTM A615", created: "2024-09-04" },
  { code: "02010102-008", name: "Steel Rebar 10mm × 12m Grade 40",       category: "02010102", uom: "PC", lifecycle: "active", unitCost: 54,    currency: "PHP", primaryVendor: "Rhino Cast Industries",  onHand: 622, onHandWHs: 3, reorderLevel: 300, attrSummary: "Ø10mm · L12m · Grade 40 · ASTM A615", created: "2024-08-12" },
  { code: "02010101-008", name: "Steel I-Beam 203×102mm Grade 50",       category: "02010101", uom: "PC", lifecycle: "active", unitCost: 1850,  currency: "PHP", primaryVendor: "SteelMark Industries",   onHand: 38,  onHandWHs: 1, reorderLevel: 20,  attrSummary: "W8×31 · L12m · Grade 50 · ASTM A992", created: "2024-09-22" },
  { code: "02010103-012", name: "Steel Plate 10mm × 1200×2400",          category: "02010103", uom: "PC", lifecycle: "active", unitCost: 4200,  currency: "PHP", primaryVendor: "SteelMark Industries",   onHand: 14,  onHandWHs: 1, reorderLevel: 8,   attrSummary: "10mm · 1200×2400 · ASTM A36", created: "2024-10-01" },
  /* Concrete */
  { code: "01030102-010", name: "Portland Cement 40kg Type 1",           category: "020102",   uom: "BAG", lifecycle: "active", unitCost: 290,  currency: "PHP", primaryVendor: "Holcim Philippines",     onHand: 18,  onHandWHs: 1, reorderLevel: 30,  attrSummary: "40kg · Type 1 · ASTM C150", created: "2024-07-18" },
  { code: "02010202-004", name: "Ready-Mix Concrete 25 MPa",             category: "020102",   uom: "M3", lifecycle: "active", unitCost: 3800,  currency: "PHP", primaryVendor: "Republic Cement",        onHand: 86,  onHandWHs: 2, reorderLevel: 40,  attrSummary: "25 MPa · 28-day · slump 100±25mm", created: "2024-08-04" },
  /* Solar */
  { code: "04020210-002", name: "Solar Panel 450W Monocrystalline",      category: "040101",   uom: "PC", lifecycle: "active", unitCost: 1100,  currency: "PHP", primaryVendor: "Pacific Solar PH",       onHand: 14,  onHandWHs: 1, reorderLevel: 20,  attrSummary: "450W · 24V · Mono · IEC 61215", created: "2025-01-12", starred: true },
  { code: "04020210-005", name: "Solar Panel 550W Monocrystalline",      category: "040101",   uom: "PC", lifecycle: "new",    unitCost: 1380,  currency: "PHP", primaryVendor: "Pacific Solar PH",       onHand: 24,  onHandWHs: 1, reorderLevel: 12,  attrSummary: "550W · 24V · Mono · IEC 61215", created: "2026-03-04" },
  { code: "04010220-001", name: "String Inverter 50kW 3-phase",          category: "040102",   uom: "PC", lifecycle: "active", unitCost: 88000, currency: "PHP", primaryVendor: "Pacific Solar PH",       onHand: 6,   onHandWHs: 1, reorderLevel: 3,   attrSummary: "50kW · 3φ · 480V · 98.2% η", created: "2024-11-08" },
  /* Network */
  { code: "08010102-021", name: "Network Switch 24-port PoE+",           category: "01010101", uom: "PC", lifecycle: "active", unitCost: 1020,  currency: "USD", primaryVendor: "TechNet Solutions",      onHand: 6,   onHandWHs: 1, reorderLevel: 4,   attrSummary: "24-port · PoE+ · L2+ · 1G", created: "2024-09-30" },
  { code: "08010102-024", name: "Network Switch 48-port PoE++",          category: "01010101", uom: "PC", lifecycle: "active", unitCost: 2480,  currency: "USD", primaryVendor: "TechNet Solutions",      onHand: 3,   onHandWHs: 1, reorderLevel: 2,   attrSummary: "48-port · PoE++ · L3 · 1G/10G uplink", created: "2024-10-22" },
  { code: "08010103-010", name: "WiFi 6 Access Point AX3000",            category: "01010103", uom: "PC", lifecycle: "active", unitCost: 480,   currency: "USD", primaryVendor: "TechNet Solutions",      onHand: 22,  onHandWHs: 2, reorderLevel: 10,  attrSummary: "WiFi 6 · AX3000 · PoE · 2×2 MIMO", created: "2024-08-15" },
  /* Sealants */
  { code: "07030101-014", name: "Waterproof Sealant 5L Grey",            category: "07",       uom: "PC", lifecycle: "active", unitCost: 92,    currency: "PHP", primaryVendor: "Chem Supplies Corp",     onHand: 38,  onHandWHs: 1, reorderLevel: 30,  attrSummary: "5L · Grey · Polyurethane · 6-mo shelf", created: "2024-06-12" },
  { code: "07030101-018", name: "Silicone Sealant 300ml Clear",          category: "07",       uom: "TUBE", lifecycle: "active", unitCost: 18,  currency: "PHP", primaryVendor: "Chem Supplies Corp",   onHand: 144, onHandWHs: 3, reorderLevel: 80,  attrSummary: "300ml · Clear · Silicone · 12-mo shelf", created: "2024-06-12" },
  /* Chem */
  { code: "03020101-044", name: "Hand Sanitiser 1L · Lot 26-Q1",         category: "03",       uom: "BOT", lifecycle: "phasing-out", unitCost: 110, currency: "PHP", primaryVendor: "Chem Supplies Corp",  onHand: 48,  onHandWHs: 1, reorderLevel: 30,  attrSummary: "1L · 70% IPA · 18-mo shelf", created: "2024-01-04" },
  { code: "03020201-002", name: "Industrial Degreaser 20L",              category: "03",       uom: "PAIL", lifecycle: "active", unitCost: 1200, currency: "PHP", primaryVendor: "Chem Supplies Corp",    onHand: 18,  onHandWHs: 1, reorderLevel: 10,  attrSummary: "20L · Hazardous · 24-mo shelf", created: "2024-04-22" },
  /* Office */
  { code: "06020401-005", name: "Office Paper A4 80gsm",                 category: "06",       uom: "REA", lifecycle: "active", unitCost: 105,  currency: "PHP", primaryVendor: "UniOffice Manila",       onHand: 88,  onHandWHs: 2, reorderLevel: 50,  attrSummary: "A4 · 80gsm · 500 sheets · FSC", created: "2023-11-10" },
  { code: "06020401-008", name: "Office Paper A4 100gsm Premium",        category: "06",       uom: "REA", lifecycle: "active", unitCost: 168,  currency: "PHP", primaryVendor: "UniOffice Manila",       onHand: 44,  onHandWHs: 1, reorderLevel: 30,  attrSummary: "A4 · 100gsm · 500 sheets · FSC", created: "2024-02-18" },
  /* Safety */
  { code: "10020401-008", name: "Hard Hat — Yellow",                     category: "1002",     uom: "PC", lifecycle: "active", unitCost: 240,   currency: "PHP", primaryVendor: "SafeGear PH",            onHand: 24,  onHandWHs: 1, reorderLevel: 20,  attrSummary: "Yellow · ANSI Z89.1 Type 1 · 4-pt", created: "2024-03-12" },
  { code: "10020401-002", name: "Safety Vest — Orange",                  category: "1002",     uom: "PC", lifecycle: "active", unitCost: 180,   currency: "PHP", primaryVendor: "SafeGear PH",            onHand: 36,  onHandWHs: 1, reorderLevel: 25,  attrSummary: "Orange · ANSI 107 Class 2 · L/XL", created: "2024-03-12" },
  { code: "10010101-014", name: "Work Gloves Pair Leather",              category: "1001",     uom: "PR", lifecycle: "active", unitCost: 95,    currency: "PHP", primaryVendor: "SafeGear PH",            onHand: 60,  onHandWHs: 2, reorderLevel: 40,  attrSummary: "Leather · EN 388 · 4-1-3-1", created: "2024-04-04" },
  /* Tools */
  { code: "13020201-001", name: "Angle Grinder 230mm 2000W",             category: "13",       uom: "PC", lifecycle: "active", unitCost: 4600,  currency: "PHP", primaryVendor: "ToolDepot PH",           onHand: 8,   onHandWHs: 1, reorderLevel: 4,   attrSummary: "230mm · 2000W · 6600 rpm · 220V", created: "2024-05-08" },
  /* Kitchen */
  { code: "11010101-088", name: "Commercial Fryer 40L SS",               category: "11",       uom: "PC", lifecycle: "active", unitCost: 4300,  currency: "PHP", primaryVendor: "Apex Kitchen Supplies",  onHand: 0,   onHandWHs: 0, reorderLevel: 4,   attrSummary: "40L · SS304 · 22kW · HACCP", created: "2024-06-18" },
  { code: "11010101-104", name: "Undercounter Refrigerator 150L",        category: "11",       uom: "PC", lifecycle: "active", unitCost: 18400, currency: "PHP", primaryVendor: "Apex Kitchen Supplies",  onHand: 2,   onHandWHs: 1, reorderLevel: 2,   attrSummary: "150L · SS · -2°C to 8°C · HACCP", created: "2024-09-12" },
  /* Emergency */
  { code: "12010202-006", name: "Fire Extinguisher 5kg ABC Dry Chem",    category: "12",       uom: "PC", lifecycle: "active", unitCost: 1850,  currency: "PHP", primaryVendor: "SafeGear PH",            onHand: 4,   onHandWHs: 1, reorderLevel: 6,   attrSummary: "5kg · ABC Dry Chemical · BFP cert", created: "2024-03-12" },
  { code: "12050101-009", name: "First-aid Kit Class B",                 category: "12",       uom: "PC", lifecycle: "active", unitCost: 880,   currency: "PHP", primaryVendor: "SafeGear PH",            onHand: 4,   onHandWHs: 1, reorderLevel: 6,   attrSummary: "Class B · 25+ items · OSHA", created: "2024-03-12" },
  /* New items pending lifecycle */
  { code: "13020201-014", name: "Cordless Impact Driver 1/2\" 20V Brushless", category: "13", uom: "PC", lifecycle: "new", unitCost: 8800, currency: "PHP", primaryVendor: "ToolDepot PH",        onHand: 12,  onHandWHs: 1, reorderLevel: 6,   attrSummary: "1/2\" · 20V · Brushless · 280Nm", created: "2026-04-02" },
  { code: "11010102-220", name: "Convection Oven 100L 3-Phase",          category: "11",       uom: "PC", lifecycle: "new",    unitCost: 32000, currency: "PHP", primaryVendor: "Apex Kitchen Supplies",  onHand: 1,   onHandWHs: 1, reorderLevel: 1,   attrSummary: "100L · 3φ · 220V · HACCP · steam-inject", created: "2026-03-22" },
  /* Discontinued */
  { code: "08010101-002", name: "Network Switch 24-port (Legacy 100M)",  category: "01010101", uom: "PC", lifecycle: "discontinued", unitCost: 480, currency: "USD", primaryVendor: "TechNet Solutions",  onHand: 2,   onHandWHs: 1, reorderLevel: 0,   attrSummary: "24-port · 100M · No PoE · EoL Apr 2025", created: "2022-04-18" },
]

const LIFECYCLE_LABEL: Record<ProductRow["lifecycle"], string> = {
  active: "Active", new: "New", "phasing-out": "Phasing Out", discontinued: "Discontinued",
}
const LIFECYCLE_TONE: Record<ProductRow["lifecycle"], string> = {
  active: "success", new: "info", "phasing-out": "warn", discontinued: "neutral",
}
const FIELD_TYPE_LABEL: Record<AttributeTemplate["fieldType"], string> = {
  text: "Text", number: "Number", decimal: "Decimal", select: "Select",
  "multi-select": "Multi-select", boolean: "Yes / No", date: "Date",
}
const FIELD_TYPE_TONE: Record<AttributeTemplate["fieldType"], string> = {
  text: "neutral", number: "info", decimal: "info", select: "accent",
  "multi-select": "accent", boolean: "success", date: "warn",
}

// SANDBOX
Object.assign(globalThis as any, {
  CATEGORIES, CATEGORY_BY_CODE, categoryBreadcrumb,
  ATTRIBUTES, FIELD_TYPE_LABEL, FIELD_TYPE_TONE,
  PRODUCTS, LIFECYCLE_LABEL, LIFECYCLE_TONE,
})

})();/*__IIFE_WRAP_END__*/

/* ═════ apps/web/lib/mock/finance.tsx ═════ */
;/*__IIFE_WRAP_START__*/(function(){
/**
 * ============================================================================
 * apps/web/lib/mock/finance.tsx
 * ----------------------------------------------------------------------------
 * Finance data for Dashboard, Bank Recon, Month-End Close.
 * Mirrors the V1 screens — same vendor/customer set so cross-screen narratives
 * (e.g. SteelMark, Bright Industries, Pacific Solar) stay coherent.
 * ============================================================================
 */

/* ─── Cash accounts (per-entity) ─────────────────────────────────────────── */
const CASH_ACCOUNTS = [
  { acct: "EastWest Bank · ···4291", label: "HVPH Current",   currency: "PHP", balance: 11242000, balanceUSD: 188400 },
  { acct: "EastWest Bank · ···8804", label: "HVPH USD",       currency: "USD", balance: 96200,    balanceUSD: 96200 },
  { acct: "DBS · ···1102",            label: "HVSG Operating",  currency: "SGD", balance: 84000,    balanceUSD: 62100 },
  { acct: "HSBC · ···4470",           label: "HVHK Trade",      currency: "HKD", balance: 412000,   balanceUSD: 52800 },
]

/* ─── AR aging summary ──────────────────────────────────────────────────── */
const AR_AGING = [
  { customer: "Prime Hotels Group",    current: 28400, b30: 0,    b60: 0,    b90: 0,     contact: "ap@primehotels.ph" },
  { customer: "Pacific Ventures Ltd",  current: 0,     b30: 19200, b60: 0,    b90: 0,     contact: "ap@pacific.sg" },
  { customer: "SG Construction Corp",  current: 0,     b30: 0,    b60: 31000, b90: 0,     contact: "ap@sgcc.sg" },
  { customer: "Bright Industries HK",  current: 0,     b30: 0,    b60: 0,    b90: 15600, contact: "ap@brightind.hk" },
  { customer: "Metro Retail Chain",    current: 33600, b30: 0,    b60: 0,    b90: 0,     contact: "billing@metroretail.ph" },
]

/* ─── AP aging summary ──────────────────────────────────────────────────── */
const AP_AGING = [
  { vendor: "SteelMark Industries",   current: 0,    b30: 12200, b60: 8400, b90: 0,    overdue: true },
  { vendor: "Chem Supplies Corp",     current: 0,    b30: 4600,  b60: 8200, b90: 7800, overdue: true },
  { vendor: "Pacific Solar PH",       current: 22000, b30: 0,    b60: 0,    b90: 0,    overdue: false },
  { vendor: "Apex Kitchen Supplies",  current: 8600,  b30: 0,    b60: 0,    b90: 0,    overdue: false },
  { vendor: "TechNet Solutions",      current: 6100,  b30: 0,    b60: 0,    b90: 0,    overdue: false },
]

/* ─── Monthly revenue trend (last 7 months) ─────────────────────────────── */
const REVENUE_TREND = [
  { month: "Oct", value: 142000, budget: 140000 },
  { month: "Nov", value: 168000, budget: 160000 },
  { month: "Dec", value: 152000, budget: 165000 },
  { month: "Jan", value: 178000, budget: 170000 },
  { month: "Feb", value: 164000, budget: 175000 },
  { month: "Mar", value: 192000, budget: 180000 },
  { month: "Apr", value: 198400, budget: 210000, current: true },
]

/* ─── AI feed for finance dashboard ─────────────────────────────────────── */
const FIN_AI_FEED = [
  { dot: "alert",  text: "**Bright Industries HK** is 62 days overdue — $15,600 unpaid. Last payment received Nov 2025.", time: "Flagged · now", chip: { tone: "danger" as const, label: "Send reminder" } },
  { dot: "warn",   text: "**3 vendor invoices** matched to POs. Ready to post. Total: $28,450.", time: "14 min ago",       chip: { tone: "warn" as const, label: "Review & post" } },
  { dot: "action", text: "April period closes in **13 days.** Month-end checklist is 4 of 12 steps complete.",            time: "Apr 2026",         chip: { tone: "info" as const, label: "Open checklist" } },
  { dot: "ok",     text: "Bank reconciliation for March is **complete.** All 47 transactions matched.",                   time: "2 Apr 2026",       chip: { tone: "success" as const, label: "View report" } },
]

/* ─── Bank Reconciliation — Apr 17, 2026 ─────────────────────────────────── */
const BANK_STATEMENT = {
  accountLabel: "EastWest Bank · ···4291 · HVPH Current",
  currency: "PHP",
  openingBalance: 12_120_000,
  closingBalance: 11_242_000,
  unmatchedCount: 5,
  matchedCount: 43,
}

const BANK_UNMATCHED = [
  { id: "b1", date: "Apr 17", desc: "ATLAS PH RECEIVABLES INC",              ref: "Wire transfer", amount: 1680000, dir: "credit" as const },
  { id: "b2", date: "Apr 16", desc: "PACIFIC VENTURES SG",                    ref: "OTC deposit",   amount: 1152000, dir: "credit" as const },
  { id: "b3", date: "Apr 15", desc: "OUTWARD REMITTANCE — STEELMARK",         ref: "Bank charge",   amount: 1104000, dir: "debit"  as const },
  { id: "b4", date: "Apr 14", desc: "MERALCO — UTILITIES",                    ref: "Auto debit",    amount: 48200,   dir: "debit"  as const },
  { id: "b5", date: "Apr 12", desc: "PAYROLL DISB APR 1-15",                  ref: "Salary batch",  amount: 2840000, dir: "debit"  as const },
]

const LEDGER_UNMATCHED = [
  { id: "g1", date: "Apr 17", desc: "AR Receipt — Prime Hotels Group",        ref: "INV-HVPH-0824 · Sales Invoice",  amount: 1680000, dir: "credit" as const, suggested: "b1" },
  { id: "g2", date: "Apr 16", desc: "AR Receipt — Pacific Ventures",          ref: "INV-HVPH-0818 · Sales Invoice",  amount: 1152000, dir: "credit" as const, suggested: "b2" },
  { id: "g3", date: "Apr 15", desc: "AP Payment — SteelMark Industries",      ref: "BILL-HVPH-0412 · Vendor Invoice", amount: 1104000, dir: "debit"  as const, suggested: "b3" },
  { id: "g4", date: "Apr 14", desc: "Utilities — Electricity Meralco",        ref: "JE-2026-04-0192 · Utility expense", amount: 48200,  dir: "debit"  as const, suggested: "b4" },
  { id: "g5", date: "Apr 12", desc: "Payroll Disbursement Apr 1-15",          ref: "JE-2026-04-0188 · Payroll journal", amount: 2840000, dir: "debit" as const, suggested: "b5" },
]

/* ─── Month-end close checklist ──────────────────────────────────────────── */
type MEStatus = "done" | "in-progress" | "todo" | "blocked"
const MONTH_END_TASKS: { id: string; group: string; title: string; owner: string; ownerInitials: string; ownerTone: any; status: MEStatus; dueDay: number; note?: string }[] = [
  /* Pre-close */
  { id: "t1",  group: "Pre-close",     title: "Approve open POs (>30 days)",              owner: "Rico T.",   ownerInitials: "RT", ownerTone: "blue",  status: "done",        dueDay: 24 },
  { id: "t2",  group: "Pre-close",     title: "Run vendor statement matching",            owner: "Maria A.",  ownerInitials: "MA", ownerTone: "sand",  status: "done",        dueDay: 25 },
  { id: "t3",  group: "Pre-close",     title: "Close AP cutoff",                          owner: "Joel D.",   ownerInitials: "JD", ownerTone: "green", status: "done",        dueDay: 25 },
  { id: "t4",  group: "Pre-close",     title: "Inventory cycle count complete",           owner: "Warren C.", ownerInitials: "WC", ownerTone: "amber", status: "done",        dueDay: 26 },
  /* Close */
  { id: "t5",  group: "Close",         title: "Bank reconciliation — HVPH (PHP)",        owner: "Maria A.",  ownerInitials: "MA", ownerTone: "sand",  status: "in-progress", dueDay: 27, note: "43 of 48 matched · 5 outstanding" },
  { id: "t6",  group: "Close",         title: "Bank reconciliation — HVSG (SGD)",        owner: "Wei T.",    ownerInitials: "WT", ownerTone: "blue",  status: "todo",        dueDay: 27 },
  { id: "t7",  group: "Close",         title: "Accruals review",                          owner: "Maria A.",  ownerInitials: "MA", ownerTone: "sand",  status: "in-progress", dueDay: 28, note: "2 invoices outstanding" },
  { id: "t8",  group: "Close",         title: "FX revaluation",                           owner: "CFO",       ownerInitials: "CF", ownerTone: "teal",  status: "blocked",     dueDay: 29, note: "Awaiting CFO sign-off" },
  /* Post-close */
  { id: "t9",  group: "Post-close",    title: "Run trial balance & GL lock",              owner: "Maria A.",  ownerInitials: "MA", ownerTone: "sand",  status: "todo",        dueDay: 30 },
  { id: "t10", group: "Post-close",    title: "Generate financial statements",             owner: "Maria A.",  ownerInitials: "MA", ownerTone: "sand",  status: "todo",        dueDay: 30 },
  { id: "t11", group: "Post-close",    title: "Distribute board pack",                    owner: "CFO",       ownerInitials: "CF", ownerTone: "teal",  status: "todo",        dueDay: 30 },
  { id: "t12", group: "Post-close",    title: "Period 4 GL hard-close",                   owner: "Maria A.",  ownerInitials: "MA", ownerTone: "sand",  status: "todo",        dueDay: 30 },
]

// SANDBOX
Object.assign(globalThis as any, {
  CASH_ACCOUNTS, AR_AGING, AP_AGING, REVENUE_TREND, FIN_AI_FEED,
  BANK_STATEMENT, BANK_UNMATCHED, LEDGER_UNMATCHED, MONTH_END_TASKS,
})

})();/*__IIFE_WRAP_END__*/

/* ═════ apps/web/lib/mock/inventory.tsx ═════ */
;/*__IIFE_WRAP_START__*/(function(){
/**
 * ============================================================================
 * apps/web/lib/mock/inventory.tsx
 * ----------------------------------------------------------------------------
 * Stock dashboard rows + cycle count mobile data.
 * ============================================================================
 */

const STOCK_KPIS = {
  totalValue: 1_842_000, // USD
  uniqueSKUs: 1140,
  belowReorder: 38,
  expiringSoon: 12,
  warehouses: 4,
}

interface StockRow {
  itemCode: string
  description: string
  warehouse: string
  onHand: number
  uom: string
  reorder: number
  unitCost: number
  value: number
  status: "ok" | "low" | "out" | "expiring"
  lastMovement: string
}

const STOCK_ROWS: StockRow[] = [
  { itemCode: "02010102-014", description: "Steel Rebar 16mm × 12m Grade 60", warehouse: "Calamba Site WH",  onHand: 412, uom: "PC", reorder: 150, unitCost: 92,    value: 37904, status: "ok",       lastMovement: "Apr 15" },
  { itemCode: "04020210-002", description: "Solar Panel 450W Monocrystalline", warehouse: "Manila Main WH", onHand: 14,  uom: "PC", reorder: 20,  unitCost: 1100,  value: 15400, status: "low",      lastMovement: "Apr 10" },
  { itemCode: "11010101-088", description: "Commercial Fryer 40L SS",         warehouse: "Manila Main WH",  onHand: 0,   uom: "PC", reorder: 4,   unitCost: 4300,  value: 0,     status: "out",      lastMovement: "Apr 06" },
  { itemCode: "07030101-014", description: "Waterproof Sealant 5L Grey",      warehouse: "Calamba Site WH", onHand: 38,  uom: "PC", reorder: 30,  unitCost: 92,    value: 3496,  status: "ok",       lastMovement: "Apr 03" },
  { itemCode: "08010102-021", description: "Network Switch 24-port PoE+",     warehouse: "Manila Main WH",  onHand: 6,   uom: "PC", reorder: 4,   unitCost: 1020,  value: 6120,  status: "ok",       lastMovement: "Apr 01" },
  { itemCode: "06020401-005", description: "Office Paper A4 80gsm",           warehouse: "Manila Main WH",  onHand: 88,  uom: "REA", reorder: 50, unitCost: 105,   value: 9240,  status: "ok",       lastMovement: "Mar 28" },
  { itemCode: "12050101-009", description: "First-aid Kit Class B",            warehouse: "Cebu Branch WH", onHand: 4,   uom: "PC", reorder: 6,   unitCost: 880,   value: 3520,  status: "low",      lastMovement: "Mar 22" },
  { itemCode: "03020101-044", description: "Hand Sanitiser 1L · Lot 26-Q1",   warehouse: "Manila Main WH",  onHand: 48,  uom: "BOT", reorder: 30, unitCost: 110,   value: 5280,  status: "expiring", lastMovement: "Apr 04" },
  { itemCode: "02010102-018", description: "Steel Rebar 20mm × 12m Grade 60", warehouse: "Calamba Site WH", onHand: 224, uom: "PC", reorder: 100, unitCost: 132,  value: 29568, status: "ok",       lastMovement: "Apr 11" },
  { itemCode: "01030102-010", description: "Portland Cement 40kg Type 1",     warehouse: "Calamba Site WH", onHand: 18,  uom: "BAG", reorder: 30, unitCost: 290,  value: 5220,  status: "low",      lastMovement: "Apr 13" },
]

/* ─── Cycle count mobile session ──────────────────────────────────────────── */
const CYCLE_COUNT_SESSION = {
  id: "CC-HVPH-0418",
  warehouse: "Calamba Site Warehouse",
  zone: "Zone B · Rack 4",
  counter: "Joel D.",
  startedAt: "08:14 AM",
  progress: { counted: 14, expected: 22 },
  variance: { matched: 11, variance: 3 },
}

interface CountItem {
  itemCode: string
  description: string
  expected: number
  counted: number | null
  uom: string
  status: "ok" | "variance" | "pending"
  note?: string
}

const COUNT_ITEMS: CountItem[] = [
  { itemCode: "02010102-014", description: "Steel Rebar 16mm × 12m",   expected: 412, counted: 412, uom: "PC", status: "ok" },
  { itemCode: "02010102-018", description: "Steel Rebar 20mm × 12m",   expected: 224, counted: 220, uom: "PC", status: "variance", note: "4 pcs short — check load-out log" },
  { itemCode: "07030101-014", description: "Waterproof Sealant 5L",    expected: 38,  counted: 38,  uom: "PC", status: "ok" },
  { itemCode: "01030102-010", description: "Portland Cement 40kg",     expected: 18,  counted: 14,  uom: "BAG", status: "variance", note: "4 bags damaged · staged for write-off" },
  { itemCode: "10020401-008", description: "Hard Hat — Yellow",        expected: 24,  counted: 24,  uom: "PC", status: "ok" },
  { itemCode: "10020401-002", description: "Safety Vest — Orange",     expected: 36,  counted: null, uom: "PC", status: "pending" },
  { itemCode: "10010101-014", description: "Work Gloves Pair",         expected: 60,  counted: null, uom: "PR", status: "pending" },
  { itemCode: "12010202-006", description: "Fire Extinguisher 5kg",    expected: 4,   counted: 4,   uom: "PC", status: "ok" },
]

// SANDBOX
Object.assign(globalThis as any, {
  STOCK_KPIS, STOCK_ROWS, CYCLE_COUNT_SESSION, COUNT_ITEMS,
})

})();/*__IIFE_WRAP_END__*/

/* ═════ apps/web/lib/mock/hr.tsx ═════ */
;/*__IIFE_WRAP_START__*/(function(){
/**
 * ============================================================================
 * apps/web/lib/mock/hr.tsx
 * ----------------------------------------------------------------------------
 * Employees + org structure + hire-to-retire pipeline.
 * ============================================================================
 */

interface Employee {
  id: string
  name: string
  initials: string
  tone: any
  title: string
  dept: "Finance" | "Procurement" | "Operations" | "HRIS" | "Construction" | "IT" | "Executive"
  managerId?: string
  email: string
  location: string
  status: "active" | "probation" | "on-leave"
  hireDate: string
  tenure: string
}

const EMPLOYEES: Employee[] = [
  { id: "e1",  name: "Atlas C.",       initials: "AC", tone: "teal",  title: "CEO",                       dept: "Executive",    email: "atlas.c@atlas.ph",   location: "Manila HQ",  status: "active",    hireDate: "2018-01-15", tenure: "8y 3m" },
  { id: "e2",  name: "Olivia P.",      initials: "OP", tone: "sand",  title: "CFO",                       dept: "Finance",      managerId: "e1", email: "olivia.p@atlas.ph", location: "Manila HQ",  status: "active", hireDate: "2019-06-01", tenure: "6y 10m" },
  { id: "e3",  name: "Rico T.",        initials: "RT", tone: "blue",  title: "Procurement Director",      dept: "Procurement",  managerId: "e1", email: "rico.t@atlas.ph",   location: "Manila HQ",  status: "active", hireDate: "2020-03-12", tenure: "6y 1m" },
  { id: "e4",  name: "Warren C.",      initials: "WC", tone: "amber", title: "Warehouse Supervisor",      dept: "Operations",   managerId: "e1", email: "warren.c@atlas.ph", location: "Calamba",    status: "active", hireDate: "2020-09-04", tenure: "5y 7m" },
  { id: "e5",  name: "Hannah R.",      initials: "HR", tone: "red",   title: "HR Manager",                dept: "HRIS",         managerId: "e1", email: "hannah.r@atlas.ph", location: "Manila HQ",  status: "active", hireDate: "2021-02-08", tenure: "5y 2m" },
  { id: "e6",  name: "Pedro S.",       initials: "PS", tone: "red",   title: "Project Manager",            dept: "Construction", managerId: "e1", email: "pedro.s@atlas.ph",  location: "Calamba",    status: "active", hireDate: "2019-11-19", tenure: "6y 5m" },
  /* Finance team */
  { id: "e7",  name: "Maria A.",       initials: "MA", tone: "sand",  title: "Senior Accountant",         dept: "Finance",      managerId: "e2", email: "maria.a@atlas.ph",  location: "Manila HQ",  status: "active", hireDate: "2021-04-15", tenure: "5y 0m" },
  { id: "e8",  name: "Joel D.",        initials: "JD", tone: "green", title: "AP Specialist",             dept: "Finance",      managerId: "e2", email: "joel.d@atlas.ph",   location: "Manila HQ",  status: "active", hireDate: "2022-08-22", tenure: "3y 8m" },
  { id: "e9",  name: "Wei T.",         initials: "WT", tone: "blue",  title: "Regional Accountant — SG",  dept: "Finance",      managerId: "e2", email: "wei.t@atlas.sg",    location: "Singapore",  status: "active", hireDate: "2022-01-10", tenure: "4y 3m" },
  /* Procurement team */
  { id: "e10", name: "Ana Q.",         initials: "AQ", tone: "red",   title: "Purchasing Officer",        dept: "Procurement",  managerId: "e3", email: "ana.q@atlas.ph",    location: "Manila HQ",  status: "active", hireDate: "2022-05-30", tenure: "3y 11m" },
  { id: "e11", name: "Maya C.",         initials: "MC", tone: "teal",  title: "Product Manager",           dept: "Procurement",  managerId: "e3", email: "maya.c@atlas.ph",    location: "Manila HQ",  status: "active", hireDate: "2023-01-09", tenure: "3y 3m" },
  /* Operations */
  { id: "e12", name: "Ben L.",         initials: "BL", tone: "ink",   title: "Site Storekeeper",          dept: "Operations",   managerId: "e4", email: "ben.l@atlas.ph",    location: "Calamba",    status: "active", hireDate: "2023-04-04", tenure: "3y 0m" },
  { id: "e13", name: "Rex S.",         initials: "RS", tone: "red",   title: "Logistics Officer",         dept: "Operations",   managerId: "e4", email: "rex.s@atlas.ph",    location: "Calamba",    status: "probation", hireDate: "2026-02-10", tenure: "2m" },
  /* HRIS */
  { id: "e14", name: "Grace C.",       initials: "GC", tone: "red",   title: "HR Officer",                dept: "HRIS",         managerId: "e5", email: "grace.c@atlas.ph",  location: "Manila HQ",  status: "active", hireDate: "2023-09-25", tenure: "2y 7m" },
  /* Construction */
  { id: "e15", name: "Jose M.",        initials: "JM", tone: "ink",   title: "Site Engineer",             dept: "Construction", managerId: "e6", email: "jose.m@atlas.ph",   location: "Calamba",    status: "active", hireDate: "2022-11-14", tenure: "3y 5m" },
  { id: "e16", name: "Carlo F.",       initials: "CF", tone: "ink",   title: "Foreman",                   dept: "Construction", managerId: "e6", email: "carlo.f@atlas.ph",  location: "Calamba",    status: "on-leave", hireDate: "2021-10-04", tenure: "4y 6m" },
  /* IT */
  { id: "e17", name: "Sam V.",         initials: "SV", tone: "blue",  title: "IT Lead",                   dept: "IT",           managerId: "e1", email: "sam.v@atlas.ph",    location: "Manila HQ",  status: "active", hireDate: "2021-07-11", tenure: "4y 9m" },
]

const HR_KPIS = {
  headcount: EMPLOYEES.length,
  openReqs: 6,
  onProbation: EMPLOYEES.filter(e => e.status === "probation").length,
  onLeave: EMPLOYEES.filter(e => e.status === "on-leave").length,
  attritionPct: 4.2,
}

/* ─── Hire-to-Retire pipeline ──────────────────────────────────────────── */
type H2RStage = "requisition" | "shortlist" | "interview" | "offer" | "onboarding" | "active" | "exit"

interface H2REntry {
  id: string
  name: string
  role: string
  dept: string
  stage: H2RStage
  daysInStage: number
  owner: string
  ownerInitials: string
  ownerTone: any
  note?: string
}

const H2R_PIPELINE: H2REntry[] = [
  { id: "h1",  name: "Senior FP&A Analyst",      role: "Position",     dept: "Finance",       stage: "requisition", daysInStage: 3,  owner: "Olivia P.", ownerInitials: "OP", ownerTone: "sand",  note: "JD draft pending" },
  { id: "h2",  name: "Logistics Coordinator",    role: "Position",     dept: "Operations",    stage: "requisition", daysInStage: 8,  owner: "Warren C.", ownerInitials: "WC", ownerTone: "amber" },
  { id: "h3",  name: "Mae Bautista",             role: "AP Specialist",dept: "Finance",       stage: "shortlist",   daysInStage: 4,  owner: "Hannah R.", ownerInitials: "HR", ownerTone: "red" },
  { id: "h4",  name: "Reagan Cruz",              role: "AP Specialist",dept: "Finance",       stage: "shortlist",   daysInStage: 4,  owner: "Hannah R.", ownerInitials: "HR", ownerTone: "red" },
  { id: "h5",  name: "Diego Lim",                role: "Site Engineer",dept: "Construction",  stage: "interview",   daysInStage: 2,  owner: "Pedro S.",  ownerInitials: "PS", ownerTone: "red",  note: "Panel: Apr 19" },
  { id: "h6",  name: "Issa Reyes",               role: "FP&A Analyst", dept: "Finance",       stage: "interview",   daysInStage: 6,  owner: "Olivia P.", ownerInitials: "OP", ownerTone: "sand", note: "Round 2 scheduled" },
  { id: "h7",  name: "Marco Tan",                role: "Purchasing Officer", dept: "Procurement", stage: "offer",  daysInStage: 1,  owner: "Rico T.",   ownerInitials: "RT", ownerTone: "blue", note: "Offer letter sent" },
  { id: "h8",  name: "Lena Cho",                 role: "HR Officer",   dept: "HRIS",          stage: "onboarding",  daysInStage: 5,  owner: "Hannah R.", ownerInitials: "HR", ownerTone: "red",  note: "Day 5 of 30 · all gates green" },
  { id: "h9",  name: "Rex S.",                   role: "Logistics Officer", dept: "Operations", stage: "active",    daysInStage: 66, owner: "Warren C.", ownerInitials: "WC", ownerTone: "amber", note: "Probation review Apr 30" },
  { id: "h10", name: "Tito M.",                  role: "Foreman",      dept: "Construction",  stage: "exit",        daysInStage: 12, owner: "Hannah R.", ownerInitials: "HR", ownerTone: "red",  note: "Final pay Apr 30 · clearance running" },
]

const H2R_STAGES: { key: H2RStage; label: string; tone: "neutral" | "info" | "warn" | "success" | "accent" | "danger"; tint: string }[] = [
  { key: "requisition", label: "Requisition", tone: "neutral", tint: "bg-muted" },
  { key: "shortlist",   label: "Shortlist",   tone: "info",    tint: "bg-info-soft" },
  { key: "interview",   label: "Interview",   tone: "warn",    tint: "bg-warn-soft" },
  { key: "offer",       label: "Offer",       tone: "accent",  tint: "bg-accent-soft" },
  { key: "onboarding",  label: "Onboarding",  tone: "success", tint: "bg-success-soft" },
  { key: "active",      label: "Active",      tone: "success", tint: "bg-brand-soft" },
  { key: "exit",        label: "Exit",        tone: "danger",  tint: "bg-danger-soft" },
]

// SANDBOX
Object.assign(globalThis as any, {
  EMPLOYEES, HR_KPIS, H2R_PIPELINE, H2R_STAGES,
})

})();/*__IIFE_WRAP_END__*/

/* ═════ apps/web/lib/mock/reports.tsx ═════ */
;/*__IIFE_WRAP_START__*/(function(){
/**
 * ============================================================================
 * apps/web/lib/mock/reports.tsx
 * ----------------------------------------------------------------------------
 * Report catalogue + AI-generated example reports.
 * ============================================================================
 */

interface Report {
  id: string
  title: string
  category: "Finance" | "Procurement" | "Inventory" | "HRIS" | "Operations" | "Multi-Entity"
  format: "table" | "chart" | "matrix" | "statement"
  description: string
  starred?: boolean
  scheduled?: string
  lastRun: string
  runs: number
  badges?: string[]
}

const REPORTS: Report[] = [
  /* Finance — standard statements + GL */
  { id: "r1",  title: "Profit & Loss",                   category: "Finance",      format: "statement", description: "Income statement with budget variance, per period or YTD",                   starred: true,  scheduled: "Monthly · 1st",       lastRun: "Apr 1, 2026",  runs: 42 },
  { id: "r2",  title: "Balance Sheet",                   category: "Finance",      format: "statement", description: "Comparative balance sheet · current vs prior period",                          starred: true,  scheduled: "Monthly · 1st",       lastRun: "Apr 1, 2026",  runs: 42 },
  { id: "r3",  title: "Cash Flow Statement",             category: "Finance",      format: "statement", description: "Indirect method, with operating / investing / financing sections",              starred: true,  lastRun: "Apr 12, 2026", runs: 28 },
  { id: "r4",  title: "Trial Balance",                   category: "Finance",      format: "table",     description: "All GL accounts with debit / credit movement and ending balance",               lastRun: "Apr 16, 2026", runs: 88 },
  { id: "r5",  title: "AR Aging by Customer",            category: "Finance",      format: "table",     description: "Current / 1-30 / 31-60 / 61-90 / 90+ buckets",                                   lastRun: "Apr 17, 2026", runs: 156 },
  { id: "r6",  title: "AP Aging by Vendor",              category: "Finance",      format: "table",     description: "Outstanding vendor invoices grouped by aging bucket",                            lastRun: "Apr 17, 2026", runs: 144 },
  /* Procurement */
  { id: "r7",  title: "Spend by Vendor",                 category: "Procurement",  format: "chart",     description: "YTD spend per vendor with horizontal bar chart and category split",            starred: true,  scheduled: "Weekly · Mon",       lastRun: "Apr 15, 2026", runs: 64 },
  { id: "r8",  title: "PO Cycle-Time Analysis",          category: "Procurement",  format: "chart",     description: "Average days from PR-to-PO and PO-to-receipt, per category",                  lastRun: "Apr 8, 2026",  runs: 32 },
  { id: "r9",  title: "Vendor Scorecard",                category: "Procurement",  format: "matrix",    description: "On-time rate, price variance, quality returns — per vendor",                      lastRun: "Apr 10, 2026", runs: 28 },
  { id: "r10", title: "3-Way Match Exception",           category: "Procurement",  format: "table",     description: "POs / IRs / Invoices that don't reconcile",                                       lastRun: "Apr 17, 2026", runs: 96, badges: ["Auto-alert"] },
  /* Inventory */
  { id: "r11", title: "Stock Aging & Slow-movers",       category: "Inventory",    format: "table",     description: "On-hand value bucketed by last-movement date · over-90-days flagged",          lastRun: "Apr 12, 2026", runs: 22 },
  { id: "r12", title: "Stock Valuation",                 category: "Inventory",    format: "statement", description: "Cost basis valuation per warehouse and category",                                lastRun: "Apr 14, 2026", runs: 18 },
  { id: "r13", title: "Cycle Count Variance Log",        category: "Inventory",    format: "table",     description: "Variances flagged in last 90 days with root-cause notes",                       lastRun: "Apr 16, 2026", runs: 14 },
  /* HRIS */
  { id: "r14", title: "Headcount by Department",          category: "HRIS",         format: "chart",     description: "Active headcount + deltas vs prior period",                                       lastRun: "Apr 1, 2026",  runs: 22 },
  { id: "r15", title: "Tenure Distribution",              category: "HRIS",         format: "chart",     description: "Histogram of tenure buckets · retention signals",                                  lastRun: "Mar 28, 2026", runs: 10 },
  { id: "r16", title: "Probation Tracker",                category: "HRIS",         format: "table",     description: "Employees on probation with review-due-date",                                     lastRun: "Apr 16, 2026", runs: 18 },
  /* Multi-Entity */
  { id: "r17", title: "Consolidated P&L",                 category: "Multi-Entity", format: "statement", description: "FX-translated and inter-entity-eliminated income statement",                     starred: true,  scheduled: "Monthly · 5th",      lastRun: "Apr 5, 2026",  runs: 36 },
  { id: "r18", title: "Inter-entity Reconciliation",      category: "Multi-Entity", format: "table",     description: "Mirror entries between entities · auto-elimination check",                       lastRun: "Apr 11, 2026", runs: 22 },
]

/* ─── Consolidated multi-entity figures ──────────────────────────────────── */
const ENTITY_PNL = [
  { entity: "HVPH",  country: "🇵🇭 PH", revenue: 198400, expenses: 132100, netUSD: 66300, revenueLocal: "₱11,308,800", currency: "PHP" },
  { entity: "HVSG",  country: "🇸🇬 SG", revenue: 124800, expenses: 86200,  netUSD: 38600, revenueLocal: "S$168,480",   currency: "SGD" },
  { entity: "HVHK",  country: "🇭🇰 HK", revenue: 88200,  expenses: 71500,  netUSD: 16700, revenueLocal: "HK$688,560",  currency: "HKD" },
  { entity: "HVAU",  country: "🇦🇺 AU", revenue: 152400, expenses: 108900, netUSD: 43500, revenueLocal: "A$233,180",   currency: "AUD" },
  { entity: "HVIN",  country: "🇮🇳 IN", revenue: 96100,  expenses: 64200,  netUSD: 31900, revenueLocal: "₹8,011,930",  currency: "INR" },
]

const CONS_ELIMINATIONS = [
  { id: "el1", description: "Inter-co loan HVPH → HVSG",            amount: 84000, type: "Intercompany loan" },
  { id: "el2", description: "Shared services billing HVAU → HVPH",  amount: 12400, type: "Management fee" },
  { id: "el3", description: "Inter-co inventory transfer HVPH → HVHK", amount: 22600, type: "Internal sales" },
]

// SANDBOX
Object.assign(globalThis as any, {
  REPORTS, ENTITY_PNL, CONS_ELIMINATIONS,
})

})();/*__IIFE_WRAP_END__*/

/* ═════ apps/web/lib/mock/sales.tsx ═════ */
;/*__IIFE_WRAP_START__*/(function(){
/**
 * ============================================================================
 * apps/web/lib/mock/sales.tsx
 * ----------------------------------------------------------------------------
 * Sales · CRM mock data — opportunities, customers, quotes, invoices.
 * ============================================================================
 */

interface Opportunity {
  id: string
  title: string
  customer: { name: string; initials: string; tone?: any; tier?: "Enterprise" | "Mid-market" | "SMB" }
  owner: { name: string; initials: string; tone?: any }
  stage: "qualify" | "discovery" | "proposal" | "negotiation" | "won" | "lost"
  value: number
  currency: "PHP" | "SGD" | "HKD" | "USD"
  probability: number      /* 0–100 */
  closeDate: string
  closeDays: number        /* positive = future, negative = past */
  daysInStage: number
  nextStep?: string
  source: "Inbound" | "Outbound" | "Partner" | "Referral" | "Event"
  industry: string
  starred?: boolean
  health: "on-track" | "at-risk" | "stalled"
}

const OPPORTUNITIES: Opportunity[] = [
  /* QUALIFY (3) */
  { id: "OPP-3104", title: "PH National Bank — branch ATM refresh", customer: { name: "PH National Bank", initials: "PNB", tone: "blue", tier: "Enterprise" }, owner: { name: "Rico T.", initials: "RT", tone: "blue" }, stage: "qualify", value: 184000, currency: "USD", probability: 15, closeDate: "Jul 12, 2026", closeDays: 67, daysInStage: 4, nextStep: "Schedule discovery", source: "Inbound", industry: "Banking", health: "on-track" },
  { id: "OPP-3103", title: "Globe Telecom — store POS rollout PHII", customer: { name: "Globe Telecom", initials: "GT", tone: "amber", tier: "Enterprise" }, owner: { name: "Maya C.", initials: "MC", tone: "teal" }, stage: "qualify", value: 268000, currency: "USD", probability: 20, closeDate: "Aug 30, 2026", closeDays: 116, daysInStage: 2, nextStep: "Send credentials packet", source: "Partner", industry: "Telecom", health: "on-track", starred: true },
  { id: "OPP-3102", title: "Cebu Pacific — fleet maintenance ERP", customer: { name: "Cebu Pacific", initials: "CP", tone: "amber", tier: "Enterprise" }, owner: { name: "Rico T.", initials: "RT", tone: "blue" }, stage: "qualify", value: 420000, currency: "USD", probability: 10, closeDate: "Sep 20, 2026", closeDays: 137, daysInStage: 8, nextStep: "Procurement intro call", source: "Event", industry: "Aviation", health: "stalled" },

  /* DISCOVERY (3) */
  { id: "OPP-3101", title: "Singapore Holdings SG — multi-entity finance", customer: { name: "Singapore Holdings", initials: "SH", tone: "blue", tier: "Mid-market" }, owner: { name: "Ana Q.", initials: "AQ", tone: "sand" }, stage: "discovery", value: 96000, currency: "SGD", probability: 35, closeDate: "Jun 30, 2026", closeDays: 55, daysInStage: 12, nextStep: "Demo Bank Recon + Consolidated", source: "Outbound", industry: "Holdings", health: "on-track", starred: true },
  { id: "OPP-3100", title: "HK Logistics — WMS + Fixed Assets", customer: { name: "HK Logistics Ltd", initials: "HK", tone: "red", tier: "Mid-market" }, owner: { name: "Maya C.", initials: "MC", tone: "teal" }, stage: "discovery", value: 480000, currency: "HKD", probability: 30, closeDate: "Jul 20, 2026", closeDays: 75, daysInStage: 9, nextStep: "Warehouse walkthrough", source: "Referral", industry: "Logistics", health: "on-track" },
  { id: "OPP-3099", title: "Filinvest Land — project accounting", customer: { name: "Filinvest Land", initials: "FL", tone: "teal", tier: "Enterprise" }, owner: { name: "Rico T.", initials: "RT", tone: "blue" }, stage: "discovery", value: 142000, currency: "USD", probability: 40, closeDate: "Jun 18, 2026", closeDays: 43, daysInStage: 6, nextStep: "Stakeholder interviews", source: "Outbound", industry: "Real Estate", health: "on-track" },

  /* PROPOSAL (4) */
  { id: "OPP-3098", title: "SteelMark — vendor portal + AP automation", customer: { name: "SteelMark Industries", initials: "SM", tone: "amber", tier: "Mid-market" }, owner: { name: "Ana Q.", initials: "AQ", tone: "sand" }, stage: "proposal", value: 64000, currency: "USD", probability: 55, closeDate: "May 28, 2026", closeDays: 22, daysInStage: 5, nextStep: "Send revised SoW", source: "Partner", industry: "Manufacturing", health: "on-track" },
  { id: "OPP-3097", title: "Bright Industries HK — full suite (8 entities)", customer: { name: "Bright Industries HK", initials: "BI", tone: "red", tier: "Enterprise" }, owner: { name: "Maya C.", initials: "MC", tone: "teal" }, stage: "proposal", value: 880000, currency: "HKD", probability: 60, closeDate: "Jun 05, 2026", closeDays: 30, daysInStage: 14, nextStep: "Pricing call w/ CFO", source: "Outbound", industry: "Conglomerate", health: "at-risk", starred: true },
  { id: "OPP-3096", title: "Rhino Cast — manufacturing ERP", customer: { name: "Rhino Cast Industries", initials: "RC", tone: "amber", tier: "Mid-market" }, owner: { name: "Rico T.", initials: "RT", tone: "blue" }, stage: "proposal", value: 78000, currency: "USD", probability: 50, closeDate: "May 22, 2026", closeDays: 16, daysInStage: 7, nextStep: "Tech architecture review", source: "Referral", industry: "Manufacturing", health: "on-track" },
  { id: "OPP-3095", title: "Pacific Solar — field service add-on", customer: { name: "Pacific Solar PH", initials: "PS", tone: "blue", tier: "SMB" }, owner: { name: "Ana Q.", initials: "AQ", tone: "sand" }, stage: "proposal", value: 22000, currency: "USD", probability: 65, closeDate: "May 18, 2026", closeDays: 12, daysInStage: 3, nextStep: "Pilot site selection", source: "Inbound", industry: "Energy", health: "on-track" },

  /* NEGOTIATION (3) */
  { id: "OPP-3094", title: "Megaworld — procurement consolidation", customer: { name: "Megaworld Corp", initials: "MW", tone: "teal", tier: "Enterprise" }, owner: { name: "Maya C.", initials: "MC", tone: "teal" }, stage: "negotiation", value: 320000, currency: "USD", probability: 75, closeDate: "May 12, 2026", closeDays: 6, daysInStage: 18, nextStep: "Legal redlines round 2", source: "Outbound", industry: "Real Estate", health: "on-track", starred: true },
  { id: "OPP-3093", title: "Republic Cement — month-end automation", customer: { name: "Republic Cement", initials: "RC", tone: "teal", tier: "Enterprise" }, owner: { name: "Rico T.", initials: "RT", tone: "blue" }, stage: "negotiation", value: 144000, currency: "USD", probability: 80, closeDate: "May 09, 2026", closeDays: 3, daysInStage: 9, nextStep: "Final terms approval", source: "Outbound", industry: "Manufacturing", health: "on-track" },
  { id: "OPP-3092", title: "Apex Kitchen — multi-entity HRIS", customer: { name: "Apex Kitchen Supplies", initials: "AK", tone: "amber", tier: "SMB" }, owner: { name: "Ana Q.", initials: "AQ", tone: "sand" }, stage: "negotiation", value: 38000, currency: "USD", probability: 70, closeDate: "May 22, 2026", closeDays: 16, daysInStage: 6, nextStep: "Payment terms finalisation", source: "Referral", industry: "F&B", health: "at-risk" },

  /* WON (recent — for revenue panel) */
  { id: "OPP-3091", title: "TechNet Solutions — Suite Subscription", customer: { name: "TechNet Solutions", initials: "TN", tone: "teal", tier: "Mid-market" }, owner: { name: "Maya C.", initials: "MC", tone: "teal" }, stage: "won", value: 88000, currency: "USD", probability: 100, closeDate: "Apr 14, 2026", closeDays: -3, daysInStage: 0, source: "Referral", industry: "IT Services", health: "on-track" },
  { id: "OPP-3090", title: "UniOffice Manila — Catalogue + AR", customer: { name: "UniOffice Manila", initials: "UO", tone: "ink", tier: "SMB" }, owner: { name: "Ana Q.", initials: "AQ", tone: "sand" }, stage: "won", value: 18000, currency: "USD", probability: 100, closeDate: "Apr 08, 2026", closeDays: -9, daysInStage: 0, source: "Inbound", industry: "Retail", health: "on-track" },

  /* LOST (recent — for postmortem) */
  { id: "OPP-3089", title: "Holcim Philippines — full suite", customer: { name: "Holcim Philippines", initials: "HP", tone: "red", tier: "Enterprise" }, owner: { name: "Rico T.", initials: "RT", tone: "blue" }, stage: "lost", value: 240000, currency: "USD", probability: 0, closeDate: "Apr 02, 2026", closeDays: -15, daysInStage: 0, source: "Outbound", industry: "Manufacturing", health: "on-track" },
]

const OPP_STAGES: { key: Opportunity["stage"]; label: string; color: string }[] = [
  { key: "qualify",     label: "Qualify",     color: "neutral" },
  { key: "discovery",   label: "Discovery",   color: "info" },
  { key: "proposal",    label: "Proposal",    color: "warn" },
  { key: "negotiation", label: "Negotiation", color: "accent" },
  { key: "won",         label: "Closed Won",  color: "success" },
  { key: "lost",        label: "Closed Lost", color: "danger" },
]

/* ─── Customers (consolidated CRM list) ─────────────────────────────────── */
interface CRMCustomer {
  id: string
  name: string
  initials: string
  tone: any
  tier: "Enterprise" | "Mid-market" | "SMB"
  industry: string
  country: "PH" | "SG" | "HK" | "Global"
  lifetimeValue: number
  openOpps: number
  arOpen: number
  lastTouch: string
  health: "green" | "amber" | "red"
}
const CRM_CUSTOMERS: CRMCustomer[] = [
  { id: "c-pnb",      name: "PH National Bank",     initials: "PNB", tone: "blue", tier: "Enterprise",  industry: "Banking",      country: "PH", lifetimeValue: 1840000, openOpps: 1, arOpen: 0,      lastTouch: "Apr 16", health: "green" },
  { id: "c-globe",    name: "Globe Telecom",        initials: "GT",  tone: "amber", tier: "Enterprise", industry: "Telecom",      country: "PH", lifetimeValue: 4200000, openOpps: 1, arOpen: 0,      lastTouch: "Apr 17", health: "green" },
  { id: "c-megawd",   name: "Megaworld Corp",       initials: "MW",  tone: "teal", tier: "Enterprise",  industry: "Real Estate",  country: "PH", lifetimeValue: 1280000, openOpps: 1, arOpen: 84000,  lastTouch: "Apr 17", health: "green" },
  { id: "c-bright",   name: "Bright Industries HK", initials: "BI",  tone: "red", tier: "Enterprise",   industry: "Conglomerate", country: "HK", lifetimeValue:  920000, openOpps: 1, arOpen: 15600,  lastTouch: "Apr 03", health: "red" },
  { id: "c-singh",    name: "Singapore Holdings",   initials: "SH",  tone: "blue", tier: "Mid-market",  industry: "Holdings",     country: "SG", lifetimeValue:  340000, openOpps: 1, arOpen: 0,      lastTouch: "Apr 15", health: "green" },
  { id: "c-hklog",    name: "HK Logistics Ltd",     initials: "HK",  tone: "red", tier: "Mid-market",   industry: "Logistics",    country: "HK", lifetimeValue:  220000, openOpps: 1, arOpen: 0,      lastTouch: "Apr 14", health: "green" },
  { id: "c-cebpac",   name: "Cebu Pacific",         initials: "CP",  tone: "amber", tier: "Enterprise", industry: "Aviation",     country: "PH", lifetimeValue:  120000, openOpps: 1, arOpen: 0,      lastTouch: "Apr 09", health: "amber" },
  { id: "c-rhino",    name: "Rhino Cast Industries", initials: "RC", tone: "amber", tier: "Mid-market", industry: "Manufacturing", country: "PH", lifetimeValue:  340000, openOpps: 1, arOpen: 0,     lastTouch: "Apr 16", health: "green" },
  { id: "c-republic", name: "Republic Cement",      initials: "RP",  tone: "teal", tier: "Enterprise",  industry: "Manufacturing", country: "PH", lifetimeValue:  680000, openOpps: 1, arOpen: 0,     lastTouch: "Apr 17", health: "green" },
  { id: "c-prime",    name: "Prime Hotels Group",   initials: "PH",  tone: "amber", tier: "Mid-market", industry: "Hospitality",  country: "PH", lifetimeValue:  280000, openOpps: 0, arOpen: 28400,  lastTouch: "Apr 12", health: "green" },
  { id: "c-pacvent",  name: "Pacific Ventures Ltd", initials: "PV",  tone: "blue", tier: "Mid-market",  industry: "Investments",  country: "SG", lifetimeValue:  220000, openOpps: 0, arOpen: 19200,  lastTouch: "Apr 11", health: "amber" },
  { id: "c-metro",    name: "Metro Retail Chain",   initials: "MR",  tone: "ink", tier: "Mid-market",   industry: "Retail",       country: "PH", lifetimeValue:  140000, openOpps: 0, arOpen: 33600,  lastTouch: "Apr 17", health: "green" },
]

const OPP_BY_ID: Record<string, Opportunity> = Object.fromEntries(OPPORTUNITIES.map(o => [o.id, o]))

// SANDBOX
Object.assign(globalThis as any, { OPPORTUNITIES, OPP_BY_ID, OPP_STAGES, CRM_CUSTOMERS })

})();/*__IIFE_WRAP_END__*/

/* ═════ apps/web/lib/mock/manufacturing.tsx ═════ */
;/*__IIFE_WRAP_START__*/(function(){
/**
 * ============================================================================
 * apps/web/lib/mock/manufacturing.tsx
 * ----------------------------------------------------------------------------
 * Work orders + BOMs for the Manufacturing module.
 * ============================================================================
 */

interface WorkOrder {
  id: string
  product: { code: string; name: string }
  qty: number
  uom: string
  status: "planned" | "released" | "in-progress" | "qc" | "done" | "blocked"
  station: string
  operator: { name: string; initials: string; tone?: any }
  due: string
  startedAt?: string
  completionPct: number       /* 0–100 */
  bomShortages?: string[]     /* item codes missing */
  customer?: string
  priority: "normal" | "rush" | "expedited"
}

const WORK_ORDERS: WorkOrder[] = [
  { id: "WO-2026-0142", product: { code: "FAB-PCS-200", name: "Precast Hollow Core Slab 200mm" },  qty: 24,  uom: "PC",   status: "in-progress", station: "Bay 3 · Casting",       operator: { name: "Warren C.", initials: "WC", tone: "amber" }, due: "Apr 22",            startedAt: "Apr 16 06:00", completionPct: 62, customer: "Megaworld · Phase 2", priority: "rush" },
  { id: "WO-2026-0141", product: { code: "FAB-IBM-W8",  name: "I-Beam W8×31 — pre-cut to 12m" },    qty: 18,  uom: "PC",   status: "in-progress", station: "Bay 1 · Cutting",       operator: { name: "Pedro S.", initials: "PS", tone: "blue" },  due: "Apr 21",            startedAt: "Apr 17 07:30", completionPct: 38, customer: "Atlas Phase 2",       priority: "normal" },
  { id: "WO-2026-0140", product: { code: "FAB-RBR-16",  name: "Rebar 16mm × 12m Grade 60" },        qty: 400, uom: "PC",   status: "qc",          station: "QC Bay",                 operator: { name: "Joel D.", initials: "JD", tone: "amber" },  due: "Apr 18",            startedAt: "Apr 15 06:00", completionPct: 96, customer: "SteelMark Order 22", priority: "normal" },
  { id: "WO-2026-0139", product: { code: "FAB-WLD-FRA", name: "Welded Frame Assembly Type A" },     qty: 12,  uom: "ASSY", status: "blocked",     station: "Bay 2 · Welding",        operator: { name: "Warren C.", initials: "WC", tone: "amber" }, due: "Apr 20",            startedAt: "Apr 14 07:00", completionPct: 45, customer: "Filinvest · Marikina", priority: "rush", bomShortages: ["02010102-022", "07030101-014"] },
  { id: "WO-2026-0138", product: { code: "FAB-PCS-150", name: "Precast Hollow Core Slab 150mm" },   qty: 40,  uom: "PC",   status: "released",    station: "Bay 3 · Casting (next)", operator: { name: "—",        initials: "" },                       due: "Apr 25",            completionPct: 0,  customer: "Megaworld · Phase 2", priority: "normal" },
  { id: "WO-2026-0137", product: { code: "FAB-PLT-10",  name: "Steel Plate 10mm — drilled" },       qty: 8,   uom: "PC",   status: "released",    station: "Bay 1 · Drilling (next)", operator: { name: "—",       initials: "" },                       due: "Apr 24",            completionPct: 0,  customer: "Atlas Phase 2",        priority: "normal" },
  { id: "WO-2026-0136", product: { code: "FAB-IBM-W12", name: "I-Beam W12×35 — pre-cut to 12m" },   qty: 6,   uom: "PC",   status: "planned",     station: "—",                       operator: { name: "—",       initials: "" },                       due: "Apr 28",            completionPct: 0,  customer: "Globe Telecom site",   priority: "normal" },
  { id: "WO-2026-0135", product: { code: "FAB-PRC-FND", name: "Precast Foundation Pad 1.2m" },      qty: 16,  uom: "PC",   status: "planned",     station: "—",                       operator: { name: "—",       initials: "" },                       due: "Apr 30",            completionPct: 0,  customer: "Rhino Cast Order 8",  priority: "normal" },
  { id: "WO-2026-0134", product: { code: "FAB-WLD-FRB", name: "Welded Frame Assembly Type B" },     qty: 8,   uom: "ASSY", status: "done",        station: "Shipping bay",            operator: { name: "Joel D.", initials: "JD", tone: "amber" },  due: "Apr 15",            startedAt: "Apr 12 06:00", completionPct: 100, customer: "Megaworld · Phase 1", priority: "normal" },
  { id: "WO-2026-0133", product: { code: "FAB-RBR-20",  name: "Rebar 20mm × 12m Grade 60" },        qty: 220, uom: "PC",   status: "done",        station: "Shipping bay",            operator: { name: "Warren C.", initials: "WC", tone: "amber" }, due: "Apr 14",            startedAt: "Apr 11 06:00", completionPct: 100, customer: "SteelMark Order 21", priority: "expedited" },
  { id: "WO-2026-0132", product: { code: "FAB-PCS-200", name: "Precast Hollow Core Slab 200mm" },   qty: 16,  uom: "PC",   status: "done",        station: "Shipping bay",            operator: { name: "Pedro S.", initials: "PS", tone: "blue" },  due: "Apr 12",            startedAt: "Apr 10 06:00", completionPct: 100, customer: "Atlas Phase 1",        priority: "normal" },
]

const WO_STATUS_LABEL: Record<WorkOrder["status"], string> = {
  planned: "Planned", released: "Released", "in-progress": "In Progress",
  qc: "QC", done: "Done", blocked: "Blocked",
}
const WO_STATUS_TONE: Record<WorkOrder["status"], string> = {
  planned: "neutral", released: "info", "in-progress": "accent",
  qc: "warn", done: "success", blocked: "danger",
}

/* ─── BOMs (compact) ────────────────────────────────────────────────────── */
interface BOM {
  id: string
  product: { code: string; name: string }
  version: string
  components: number
  totalCost: number
  currency: "PHP"
  lastChanged: string
  changedBy: string
  status: "active" | "draft" | "deprecated"
}
const BOMS: BOM[] = [
  { id: "BOM-FAB-PCS-200-v4", product: { code: "FAB-PCS-200", name: "Precast Hollow Core Slab 200mm" }, version: "v4", components: 8,  totalCost: 14200, currency: "PHP", lastChanged: "Apr 11", changedBy: "Warren C.", status: "active" },
  { id: "BOM-FAB-IBM-W8-v2",  product: { code: "FAB-IBM-W8",  name: "I-Beam W8×31 — pre-cut" },           version: "v2", components: 3,  totalCost:  1850, currency: "PHP", lastChanged: "Mar 22", changedBy: "Pedro S.",  status: "active" },
  { id: "BOM-FAB-WLD-FRA-v3", product: { code: "FAB-WLD-FRA", name: "Welded Frame Assembly Type A" },     version: "v3", components: 12, totalCost: 18400, currency: "PHP", lastChanged: "Apr 04", changedBy: "Warren C.", status: "active" },
  { id: "BOM-FAB-PCS-150-v3", product: { code: "FAB-PCS-150", name: "Precast Hollow Core Slab 150mm" },   version: "v3", components: 7,  totalCost: 10800, currency: "PHP", lastChanged: "Feb 14", changedBy: "Warren C.", status: "active" },
  { id: "BOM-FAB-WLD-FRA-v4", product: { code: "FAB-WLD-FRA", name: "Welded Frame Assembly Type A" },     version: "v4", components: 13, totalCost: 19200, currency: "PHP", lastChanged: "Apr 16", changedBy: "Warren C.", status: "draft" },
]

const WO_BY_ID: Record<string, WorkOrder> = Object.fromEntries(WORK_ORDERS.map(w => [w.id, w]))

// SANDBOX
Object.assign(globalThis as any, { WORK_ORDERS, WO_BY_ID, WO_STATUS_LABEL, WO_STATUS_TONE, BOMS })

})();/*__IIFE_WRAP_END__*/

/* ═════ apps/web/lib/mock/projects.tsx ═════ */
;/*__IIFE_WRAP_START__*/(function(){
/**
 * ============================================================================
 * apps/web/lib/mock/projects.tsx
 * ----------------------------------------------------------------------------
 * Project Accounting — portfolio + timesheets + WIP.
 * ============================================================================
 */

interface Project {
  id: string
  name: string
  client: string
  clientInitials: string
  clientTone?: any
  pm: { name: string; initials: string; tone?: any }
  type: "Fixed Bid" | "T&M" | "Retainer"
  status: "active" | "at-risk" | "on-hold" | "completed"
  startDate: string
  targetEnd: string
  budget: number
  spent: number              /* incurred cost */
  billed: number             /* invoiced to date */
  wipUnbilled: number        /* unbilled WIP */
  marginPct: number          /* gross margin % */
  completionPct: number
  hoursTotal: number
  hoursLogged: number
  team: { initials: string; tone?: any }[]
  currency: "PHP" | "SGD" | "HKD" | "USD"
  starred?: boolean
}

const PROJECTS: Project[] = [
  { id: "PRJ-2026-014", name: "Megaworld · Marikina Tower B fit-out", client: "Megaworld Corp", clientInitials: "MW", clientTone: "teal", pm: { name: "Ben L.", initials: "BL", tone: "teal" }, type: "Fixed Bid", status: "active",   startDate: "Mar 01", targetEnd: "Jul 30", budget: 480000, spent: 240000, billed: 192000, wipUnbilled: 48000, marginPct: 28, completionPct: 50, hoursTotal: 3200, hoursLogged: 1664, team: [{ initials: "BL", tone: "teal" }, { initials: "WC", tone: "amber" }, { initials: "MA", tone: "blue" }, { initials: "JD", tone: "amber" }], currency: "PHP", starred: true },
  { id: "PRJ-2026-013", name: "Filinvest · Calamba Phase 2", client: "Filinvest Land", clientInitials: "FL", clientTone: "teal", pm: { name: "Ben L.", initials: "BL", tone: "teal" }, type: "Fixed Bid", status: "at-risk",  startDate: "Feb 12", targetEnd: "Jun 18", budget: 720000, spent: 540000, billed: 360000, wipUnbilled: 180000, marginPct: 18, completionPct: 75, hoursTotal: 4800, hoursLogged: 3600, team: [{ initials: "BL", tone: "teal" }, { initials: "WC", tone: "amber" }, { initials: "PS", tone: "blue" }, { initials: "JD", tone: "amber" }, { initials: "MA", tone: "blue" }], currency: "PHP", starred: true },
  { id: "PRJ-2026-012", name: "Globe Telecom · Cebu Branch refit", client: "Globe Telecom", clientInitials: "GT", clientTone: "amber", pm: { name: "Pedro S.", initials: "PS", tone: "blue" }, type: "T&M", status: "active", startDate: "Apr 01", targetEnd: "May 30", budget: 84000, spent: 22400, billed: 18000, wipUnbilled: 4400, marginPct: 32, completionPct: 25, hoursTotal: 800, hoursLogged: 200, team: [{ initials: "PS", tone: "blue" }, { initials: "BL", tone: "teal" }], currency: "USD" },
  { id: "PRJ-2026-011", name: "SteelMark · Production line audit", client: "SteelMark Industries", clientInitials: "SM", clientTone: "amber", pm: { name: "Maria A.", initials: "MA", tone: "blue" }, type: "Retainer", status: "active", startDate: "Jan 15", targetEnd: "Dec 31", budget: 96000, spent: 38400, billed: 40000, wipUnbilled: 0, marginPct: 42, completionPct: 40, hoursTotal: 1200, hoursLogged: 480, team: [{ initials: "MA", tone: "blue" }, { initials: "BL", tone: "teal" }], currency: "USD" },
  { id: "PRJ-2026-010", name: "Republic Cement · Month-end automation rollout", client: "Republic Cement", clientInitials: "RP", clientTone: "teal", pm: { name: "Maria A.", initials: "MA", tone: "blue" }, type: "Fixed Bid", status: "active", startDate: "Mar 18", targetEnd: "Jun 30", budget: 144000, spent: 38800, billed: 28800, wipUnbilled: 10000, marginPct: 36, completionPct: 30, hoursTotal: 1800, hoursLogged: 540, team: [{ initials: "MA", tone: "blue" }, { initials: "RT", tone: "blue" }], currency: "USD" },
  { id: "PRJ-2026-009", name: "Pacific Solar · Cebu rooftop install", client: "Pacific Solar PH", clientInitials: "PS", clientTone: "blue", pm: { name: "Warren C.", initials: "WC", tone: "amber" }, type: "Fixed Bid", status: "on-hold", startDate: "Feb 28", targetEnd: "May 12", budget: 220000, spent: 88000, billed: 88000, wipUnbilled: 0, marginPct: 22, completionPct: 40, hoursTotal: 1600, hoursLogged: 640, team: [{ initials: "WC", tone: "amber" }, { initials: "BL", tone: "teal" }], currency: "PHP" },
  { id: "PRJ-2026-008", name: "Atlas Phase 1 · Calamba site", client: "Internal", clientInitials: "AT", clientTone: "blue", pm: { name: "Ben L.", initials: "BL", tone: "teal" }, type: "Fixed Bid", status: "completed", startDate: "Sep 12, 2025", targetEnd: "Mar 30, 2026", budget: 1200000, spent: 1080000, billed: 1200000, wipUnbilled: 0, marginPct: 10, completionPct: 100, hoursTotal: 9600, hoursLogged: 9420, team: [{ initials: "BL", tone: "teal" }, { initials: "WC", tone: "amber" }, { initials: "PS", tone: "blue" }, { initials: "MA", tone: "blue" }], currency: "PHP" },
  { id: "PRJ-2026-007", name: "TechNet Solutions · Office IT refresh", client: "TechNet Solutions", clientInitials: "TN", clientTone: "teal", pm: { name: "Pedro S.", initials: "PS", tone: "blue" }, type: "T&M", status: "completed", startDate: "Jan 04", targetEnd: "Mar 18", budget: 32000, spent: 28400, billed: 32000, wipUnbilled: 0, marginPct: 11, completionPct: 100, hoursTotal: 320, hoursLogged: 296, team: [{ initials: "PS", tone: "blue" }], currency: "USD" },
]

const PRJ_STATUS_LABEL: Record<Project["status"], string> = {
  active: "Active", "at-risk": "At Risk", "on-hold": "On Hold", completed: "Completed",
}
const PRJ_STATUS_TONE: Record<Project["status"], string> = {
  active: "success", "at-risk": "warn", "on-hold": "neutral", completed: "info",
}

const PROJECT_BY_ID: Record<string, Project> = Object.fromEntries(PROJECTS.map(p => [p.id, p]))

// SANDBOX
Object.assign(globalThis as any, { PROJECTS, PROJECT_BY_ID, PRJ_STATUS_LABEL, PRJ_STATUS_TONE })

})();/*__IIFE_WRAP_END__*/

/* ═════ apps/web/lib/mock/assets.tsx ═════ */
;/*__IIFE_WRAP_START__*/(function(){
/**
 * ============================================================================
 * apps/web/lib/mock/assets.tsx
 * ----------------------------------------------------------------------------
 * Fixed Assets register — for the Fixed Assets module.
 * ============================================================================
 */

interface FixedAsset {
  id: string                   /* FA-HVPH-0231 */
  name: string
  category: "Plant & Machinery" | "Vehicles" | "IT Equipment" | "Buildings" | "Furniture & Fixtures" | "Tools"
  location: string
  custodian: { name: string; initials: string; tone?: any }
  acquiredDate: string
  acquiredISO: string
  cost: number
  currency: "PHP" | "SGD" | "HKD" | "USD"
  usefulLifeYrs: number
  method: "Straight-line" | "Declining balance" | "Units of production"
  accumDepr: number
  nbv: number                  /* Net Book Value = cost - accumDepr */
  status: "in-use" | "idle" | "under-maintenance" | "retired"
  warrantyEnd?: string
  insurancePolicy?: string
  serial?: string
}

const FIXED_ASSETS: FixedAsset[] = [
  /* Plant */
  { id: "FA-HVPH-0231", name: "CAT 320D Hydraulic Excavator", category: "Plant & Machinery", location: "Calamba Site WH", custodian: { name: "Warren C.", initials: "WC", tone: "amber" }, acquiredDate: "Jan 18, 2024", acquiredISO: "2024-01-18", cost: 8800000, currency: "PHP", usefulLifeYrs: 10, method: "Straight-line", accumDepr: 1980000, nbv: 6820000, status: "in-use", warrantyEnd: "Jan 18, 2027", insurancePolicy: "INS-2024-PCH-0042", serial: "CAT320D-2024-MNL-0118" },
  { id: "FA-HVPH-0228", name: "Concrete Mixer Truck 8m³",       category: "Vehicles",         location: "Calamba Site WH", custodian: { name: "Warren C.", initials: "WC", tone: "amber" }, acquiredDate: "Mar 04, 2023", acquiredISO: "2023-03-04", cost: 4200000, currency: "PHP", usefulLifeYrs: 8, method: "Straight-line",  accumDepr: 1575000, nbv: 2625000, status: "in-use", warrantyEnd: "Mar 04, 2026", insurancePolicy: "INS-2024-VEH-0011", serial: "TRK-CMT-8M3-2023" },
  { id: "FA-HVPH-0224", name: "Tower Crane 50m boom",            category: "Plant & Machinery", location: "Calamba Site WH (active)", custodian: { name: "Pedro S.", initials: "PS", tone: "blue" }, acquiredDate: "Aug 22, 2022", acquiredISO: "2022-08-22", cost: 18400000, currency: "PHP", usefulLifeYrs: 15, method: "Straight-line", accumDepr: 4293333, nbv: 14106667, status: "in-use", warrantyEnd: "Aug 22, 2025", insurancePolicy: "INS-2024-PCH-0021", serial: "TC-50M-2022-PH-022" },
  { id: "FA-HVPH-0218", name: "Welding Robot Cell — Bay 2",       category: "Plant & Machinery", location: "Calamba Fab Bay 2", custodian: { name: "Warren C.", initials: "WC", tone: "amber" }, acquiredDate: "Nov 12, 2023", acquiredISO: "2023-11-12", cost: 5800000, currency: "PHP", usefulLifeYrs: 12, method: "Straight-line", accumDepr: 676667,  nbv: 5123333, status: "under-maintenance", warrantyEnd: "Nov 12, 2026", insurancePolicy: "INS-2024-PCH-0033", serial: "WRC-2023-CAL-B2" },

  /* Vehicles */
  { id: "FA-HVPH-0207", name: "Toyota Hilux 4×4 — PM-1432",      category: "Vehicles",         location: "Manila HQ pool", custodian: { name: "Rico T.", initials: "RT", tone: "blue" }, acquiredDate: "Sep 15, 2022", acquiredISO: "2022-09-15", cost: 1850000, currency: "PHP", usefulLifeYrs: 6, method: "Straight-line", accumDepr: 1080000, nbv: 770000,  status: "in-use", warrantyEnd: "Sep 15, 2025", insurancePolicy: "INS-2024-VEH-0008", serial: "TOY-HLX-PM1432" },
  { id: "FA-HVPH-0210", name: "Isuzu N-Series Delivery Truck",   category: "Vehicles",         location: "Cebu Branch WH", custodian: { name: "Joel D.", initials: "JD", tone: "amber" }, acquiredDate: "Feb 28, 2023", acquiredISO: "2023-02-28", cost: 2400000, currency: "PHP", usefulLifeYrs: 8, method: "Straight-line", accumDepr: 937500,  nbv: 1462500, status: "in-use", warrantyEnd: "Feb 28, 2026", insurancePolicy: "INS-2024-VEH-0014", serial: "ISZ-N-CEB-0228" },

  /* IT */
  { id: "FA-HVPH-0312", name: "Dell PowerEdge R740 — server-mn1", category: "IT Equipment",     location: "Manila HQ · Server Room", custodian: { name: "Pedro S.", initials: "PS", tone: "blue" }, acquiredDate: "Jun 04, 2024", acquiredISO: "2024-06-04", cost: 480000, currency: "PHP", usefulLifeYrs: 5, method: "Straight-line", accumDepr: 80000,   nbv: 400000,  status: "in-use", warrantyEnd: "Jun 04, 2027", serial: "DELL-R740-MN1-0604" },
  { id: "FA-HVPH-0314", name: "Cisco Catalyst 9500 switch",       category: "IT Equipment",     location: "Manila HQ · Network",     custodian: { name: "Pedro S.", initials: "PS", tone: "blue" }, acquiredDate: "Jul 22, 2024", acquiredISO: "2024-07-22", cost: 220000, currency: "PHP", usefulLifeYrs: 7, method: "Straight-line", accumDepr: 24286,   nbv: 195714,  status: "in-use", warrantyEnd: "Jul 22, 2029", serial: "CSCO-C9500-MN1-0722" },
  { id: "FA-HVPH-0320", name: "Display Wall — 6×Samsung 55\"",   category: "IT Equipment",     location: "Manila HQ · NOC",         custodian: { name: "Pedro S.", initials: "PS", tone: "blue" }, acquiredDate: "Jan 30, 2025", acquiredISO: "2025-01-30", cost: 380000, currency: "PHP", usefulLifeYrs: 5, method: "Straight-line", accumDepr: 18800,   nbv: 361200,  status: "in-use" },

  /* Buildings & F&F */
  { id: "FA-HVPH-0101", name: "Calamba Site · Warehouse Building", category: "Buildings",      location: "Calamba", custodian: { name: "Olivia P.", initials: "OP", tone: "amber" }, acquiredDate: "May 04, 2019", acquiredISO: "2019-05-04", cost: 28000000, currency: "PHP", usefulLifeYrs: 40, method: "Straight-line", accumDepr: 4900000, nbv: 23100000, status: "in-use" },
  { id: "FA-HVPH-0420", name: "Office Furniture set — Manila L8",  category: "Furniture & Fixtures", location: "Manila HQ", custodian: { name: "Hannah R.", initials: "HR", tone: "blue" }, acquiredDate: "Mar 12, 2024", acquiredISO: "2024-03-12", cost: 480000, currency: "PHP", usefulLifeYrs: 10, method: "Straight-line", accumDepr: 51000,   nbv: 429000,  status: "in-use" },

  /* Idle / retired */
  { id: "FA-HVPH-0182", name: "Older CAT 312 Excavator",          category: "Plant & Machinery", location: "Yard A · Idle", custodian: { name: "Warren C.", initials: "WC", tone: "amber" }, acquiredDate: "Feb 22, 2017", acquiredISO: "2017-02-22", cost: 5400000, currency: "PHP", usefulLifeYrs: 10, method: "Straight-line", accumDepr: 4860000, nbv: 540000, status: "idle" },
  { id: "FA-HVPH-0192", name: "Honda Civic — sales fleet (retired)", category: "Vehicles",       location: "Disposed Mar 2026",      custodian: { name: "Olivia P.", initials: "OP", tone: "amber" }, acquiredDate: "Jun 04, 2018", acquiredISO: "2018-06-04", cost: 1200000, currency: "PHP", usefulLifeYrs: 6, method: "Straight-line", accumDepr: 1200000, nbv: 0, status: "retired" },
]

const FA_STATUS_LABEL: Record<FixedAsset["status"], string> = {
  "in-use": "In Use", idle: "Idle", "under-maintenance": "Maintenance", retired: "Retired",
}
const FA_STATUS_TONE: Record<FixedAsset["status"], string> = {
  "in-use": "success", idle: "warn", "under-maintenance": "info", retired: "neutral",
}

const FA_BY_ID: Record<string, FixedAsset> = Object.fromEntries(FIXED_ASSETS.map(f => [f.id, f]))

// SANDBOX
Object.assign(globalThis as any, { FIXED_ASSETS, FA_BY_ID, FA_STATUS_LABEL, FA_STATUS_TONE })

})();/*__IIFE_WRAP_END__*/

/* ═════ apps/web/lib/mock/tax.tsx ═════ */
;/*__IIFE_WRAP_START__*/(function(){
/**
 * ============================================================================
 * apps/web/lib/mock/tax.tsx
 * ----------------------------------------------------------------------------
 * Tax & Compliance mock — multi-jurisdiction filing calendar.
 * ============================================================================
 */

interface TaxFiling {
  id: string
  form: string                  /* "BIR 1601-C", "GST F5", "IRD BIR 56A" */
  jurisdiction: "PH" | "SG" | "HK"
  entity: string                /* "HVPH", "HVSG", "HVHK" */
  period: string                /* "April 2026", "Q1 2026" */
  dueDate: string
  dueISO: string
  daysUntilDue: number          /* negative = overdue */
  status: "draft" | "ready" | "submitted" | "accepted" | "overdue"
  preparer: { name: string; initials: string; tone?: any }
  amountDue?: number
  currency?: "PHP" | "SGD" | "HKD"
  notes?: string
  category: "Withholding" | "VAT/GST" | "Income Tax" | "Payroll" | "Annual" | "Other"
}

const TAX_FILINGS: TaxFiling[] = [
  /* OVERDUE (1) */
  { id: "FIL-2026-0418", form: "BIR 2550M (Monthly VAT)", jurisdiction: "PH", entity: "HVPH", period: "March 2026", dueDate: "Apr 20, 2026", dueISO: "2026-04-20", daysUntilDue: 3,  status: "draft",     preparer: { name: "Maria A.", initials: "MA", tone: "blue" },  amountDue: 248000, currency: "PHP", category: "VAT/GST", notes: "Awaiting AP cutoff" },

  /* DUE THIS WEEK */
  { id: "FIL-2026-0419", form: "BIR 1601-C (Compensation WHT)", jurisdiction: "PH", entity: "HVPH", period: "April 2026", dueDate: "Apr 10, 2026", dueISO: "2026-04-10", daysUntilDue: -7, status: "overdue",  preparer: { name: "Maria A.", initials: "MA", tone: "blue" }, amountDue: 84200, currency: "PHP", category: "Payroll", notes: "Penalty accruing · file immediately" },
  { id: "FIL-2026-0420", form: "BIR 1601-E (Expanded WHT)",     jurisdiction: "PH", entity: "HVPH", period: "March 2026", dueDate: "Apr 20, 2026", dueISO: "2026-04-20", daysUntilDue: 3,  status: "ready",     preparer: { name: "Maria A.", initials: "MA", tone: "blue" },  amountDue: 32400, currency: "PHP", category: "Withholding" },
  { id: "FIL-2026-0421", form: "BIR 0619-E (Monthly Remittance)", jurisdiction: "PH", entity: "HVPH", period: "March 2026", dueDate: "Apr 20, 2026", dueISO: "2026-04-20", daysUntilDue: 3, status: "draft",   preparer: { name: "Maria A.", initials: "MA", tone: "blue" }, amountDue: 12800, currency: "PHP", category: "Withholding" },

  /* DUE LATER THIS MONTH */
  { id: "FIL-2026-0422", form: "IRAS GST F5",                  jurisdiction: "SG", entity: "HVSG", period: "Q1 2026 (Jan–Mar)", dueDate: "Apr 30, 2026", dueISO: "2026-04-30", daysUntilDue: 13, status: "ready",     preparer: { name: "Wei T.", initials: "WT", tone: "blue" },  amountDue: 14200, currency: "SGD", category: "VAT/GST" },
  { id: "FIL-2026-0423", form: "IRD BIR 56A (Employer Return)",jurisdiction: "HK", entity: "HVHK", period: "FY 2025-26",        dueDate: "Apr 30, 2026", dueISO: "2026-04-30", daysUntilDue: 13, status: "draft",     preparer: { name: "Wei T.", initials: "WT", tone: "blue" },  category: "Annual", notes: "Annual filing — final review pending" },
  { id: "FIL-2026-0424", form: "BIR 2307 (Certificate)",       jurisdiction: "PH", entity: "HVPH", period: "Q1 2026",          dueDate: "Apr 30, 2026", dueISO: "2026-04-30", daysUntilDue: 13, status: "submitted", preparer: { name: "Joel D.", initials: "JD", tone: "amber" }, amountDue: 0,    currency: "PHP", category: "Withholding" },

  /* MAY */
  { id: "FIL-2026-0425", form: "BIR 1701Q (Quarterly Income Tax)",   jurisdiction: "PH", entity: "HVPH", period: "Q1 2026", dueDate: "May 15, 2026", dueISO: "2026-05-15", daysUntilDue: 28, status: "draft", preparer: { name: "Maria A.", initials: "MA", tone: "blue" }, amountDue: 184000, currency: "PHP", category: "Income Tax" },
  { id: "FIL-2026-0426", form: "BIR 2550M (Monthly VAT)",            jurisdiction: "PH", entity: "HVPH", period: "April 2026", dueDate: "May 20, 2026", dueISO: "2026-05-20", daysUntilDue: 33, status: "draft", preparer: { name: "Maria A.", initials: "MA", tone: "blue" }, currency: "PHP", category: "VAT/GST" },
  { id: "FIL-2026-0427", form: "BIR 1601-C (Compensation WHT)",      jurisdiction: "PH", entity: "HVPH", period: "May 2026", dueDate: "Jun 10, 2026", dueISO: "2026-06-10", daysUntilDue: 54, status: "draft", preparer: { name: "Maria A.", initials: "MA", tone: "blue" }, currency: "PHP", category: "Payroll" },
  { id: "FIL-2026-0428", form: "MPF Form A",                          jurisdiction: "HK", entity: "HVHK", period: "May 2026", dueDate: "Jun 10, 2026", dueISO: "2026-06-10", daysUntilDue: 54, status: "draft", preparer: { name: "Wei T.", initials: "WT", tone: "blue" }, currency: "HKD", category: "Payroll" },

  /* RECENT ACCEPTED */
  { id: "FIL-2026-0410", form: "BIR 1701Q (Quarterly Income Tax)", jurisdiction: "PH", entity: "HVPH", period: "Q4 2025", dueDate: "Feb 15, 2026", dueISO: "2026-02-15", daysUntilDue: -61, status: "accepted", preparer: { name: "Maria A.", initials: "MA", tone: "blue" }, amountDue: 161200, currency: "PHP", category: "Income Tax" },
  { id: "FIL-2026-0405", form: "IRAS GST F5", jurisdiction: "SG", entity: "HVSG", period: "Q4 2025", dueDate: "Jan 31, 2026", dueISO: "2026-01-31", daysUntilDue: -76, status: "accepted", preparer: { name: "Wei T.", initials: "WT", tone: "blue" }, amountDue: 9200, currency: "SGD", category: "VAT/GST" },
]

const TAX_STATUS_LABEL: Record<TaxFiling["status"], string> = {
  draft: "Draft", ready: "Ready", submitted: "Submitted", accepted: "Accepted", overdue: "Overdue",
}
const TAX_STATUS_TONE: Record<TaxFiling["status"], string> = {
  draft: "neutral", ready: "info", submitted: "accent", accepted: "success", overdue: "danger",
}
const JURISDICTION_LABEL: Record<TaxFiling["jurisdiction"], string> = {
  PH: "🇵🇭 Philippines", SG: "🇸🇬 Singapore", HK: "🇭🇰 Hong Kong",
}

const TAX_BY_ID: Record<string, TaxFiling> = Object.fromEntries(TAX_FILINGS.map(t => [t.id, t]))

// SANDBOX
Object.assign(globalThis as any, { TAX_FILINGS, TAX_BY_ID, TAX_STATUS_LABEL, TAX_STATUS_TONE, JURISDICTION_LABEL })

})();/*__IIFE_WRAP_END__*/

/* ═════ apps/web/lib/mock/field.tsx ═════ */
;/*__IIFE_WRAP_START__*/(function(){
/**
 * ============================================================================
 * apps/web/lib/mock/field.tsx
 * ----------------------------------------------------------------------------
 * Field Service mock — dispatch jobs across PH NCR + Calabarzon region.
 * ============================================================================
 */

interface FieldJob {
  id: string
  title: string
  customer: { name: string; initials: string; tone?: any }
  address: string
  serviceType: "Install" | "Maintenance" | "Repair" | "Inspection" | "Pickup/Delivery"
  priority: "P1" | "P2" | "P3"
  status: "queued" | "assigned" | "en-route" | "on-site" | "completed" | "blocked"
  crew?: { name: string; initials: string; tone?: any }[]
  scheduledStart: string         /* "08:30" */
  scheduledEnd: string
  durationMin: number
  /* Coordinates approximate for the demo map — center on Manila */
  lat: number                    /* relative to 0–100 grid */
  lng: number                    /* relative to 0–100 grid */
  sla: "on-track" | "at-risk" | "breached"
  partsRequired?: string[]
  notes?: string
}

const FIELD_JOBS: FieldJob[] = [
  /* En route + on-site (active) */
  { id: "FJ-2026-0418-01", title: "Solar panel install · Bldg C rooftop",  customer: { name: "Pacific Solar PH",     initials: "PS", tone: "blue" },   address: "Calamba Site, Laguna", serviceType: "Install",       priority: "P2", status: "on-site",  crew: [{ initials: "WC", tone: "amber" }, { initials: "RD", tone: "amber" }], scheduledStart: "08:00", scheduledEnd: "12:30", durationMin: 270, lat: 78, lng: 32, sla: "on-track" },
  { id: "FJ-2026-0418-02", title: "ATM maintenance · Branch 142",          customer: { name: "PH National Bank",     initials: "PNB", tone: "blue" },  address: "Makati CBD, NCR",      serviceType: "Maintenance",   priority: "P2", status: "on-site",  crew: [{ initials: "JD", tone: "amber" }],                                       scheduledStart: "09:00", scheduledEnd: "10:30", durationMin: 90,  lat: 48, lng: 52, sla: "on-track" },
  { id: "FJ-2026-0418-03", title: "Generator repair · POS battery fault",  customer: { name: "Metro Retail Chain",   initials: "MR", tone: "ink" },    address: "Quezon City, NCR",     serviceType: "Repair",        priority: "P1", status: "en-route", crew: [{ initials: "PS", tone: "blue" }],                                        scheduledStart: "10:00", scheduledEnd: "13:00", durationMin: 180, lat: 32, lng: 48, sla: "at-risk", notes: "Battery + alternator + inverter check" },
  { id: "FJ-2026-0418-04", title: "WiFi AP install · 3rd floor",           customer: { name: "Filinvest Land",       initials: "FL", tone: "teal" },   address: "Alabang, NCR",         serviceType: "Install",       priority: "P3", status: "en-route", crew: [{ initials: "WT", tone: "blue" }, { initials: "RT", tone: "blue" }],     scheduledStart: "10:30", scheduledEnd: "13:30", durationMin: 180, lat: 62, lng: 42, sla: "on-track" },

  /* Assigned (scheduled today) */
  { id: "FJ-2026-0418-05", title: "Annual inspection · fire safety",       customer: { name: "Globe Telecom",        initials: "GT", tone: "amber" },  address: "BGC, Taguig, NCR",     serviceType: "Inspection",    priority: "P2", status: "assigned", crew: [{ initials: "JD", tone: "amber" }],                                       scheduledStart: "13:00", scheduledEnd: "14:30", durationMin: 90,  lat: 52, lng: 56, sla: "on-track" },
  { id: "FJ-2026-0418-06", title: "Refrigerator service · Lipa canteen",   customer: { name: "Apex Kitchen Supplies",initials: "AK", tone: "amber" },  address: "Lipa, Batangas",       serviceType: "Maintenance",   priority: "P3", status: "assigned", crew: [{ initials: "WC", tone: "amber" }],                                       scheduledStart: "14:00", scheduledEnd: "16:00", durationMin: 120, lat: 92, lng: 22, sla: "on-track" },
  { id: "FJ-2026-0418-07", title: "Server rack delivery + commissioning",  customer: { name: "TechNet Solutions",    initials: "TN", tone: "teal" },   address: "Ortigas Center, NCR",  serviceType: "Install",       priority: "P2", status: "assigned", crew: [{ initials: "PS", tone: "blue" }, { initials: "WT", tone: "blue" }],     scheduledStart: "14:30", scheduledEnd: "17:30", durationMin: 180, lat: 42, lng: 56, sla: "on-track" },

  /* Queued (unassigned, waiting on crew) */
  { id: "FJ-2026-0418-08", title: "Emergency leak repair · cold storage",  customer: { name: "Prime Hotels Group",   initials: "PH", tone: "amber" },  address: "Pasay, NCR",           serviceType: "Repair",        priority: "P1", status: "queued",                                                                                                              scheduledStart: "—",     scheduledEnd: "—",     durationMin: 120, lat: 38, lng: 52, sla: "breached", notes: "SLA breached — assign within 30min", partsRequired: ["Refrigerant R-404a", "Compressor seal kit"] },
  { id: "FJ-2026-0418-09", title: "Solar inverter swap · Cebu rooftop",    customer: { name: "Pacific Solar PH",     initials: "PS", tone: "blue" },   address: "Mactan, Cebu",         serviceType: "Repair",        priority: "P2", status: "queued",                                                                                                              scheduledStart: "—",     scheduledEnd: "—",     durationMin: 240, lat: 88, lng: 78, sla: "at-risk" },

  /* Completed today (recent activity strip) */
  { id: "FJ-2026-0418-10", title: "POS terminal swap × 4",                 customer: { name: "Metro Retail Chain",   initials: "MR", tone: "ink" },    address: "Pasig, NCR",           serviceType: "Install",       priority: "P3", status: "completed", crew: [{ initials: "JD", tone: "amber" }],                                       scheduledStart: "07:30", scheduledEnd: "08:45", durationMin: 75,  lat: 44, lng: 54, sla: "on-track" },
]

const FJ_STATUS_LABEL: Record<FieldJob["status"], string> = {
  queued: "Queued", assigned: "Assigned", "en-route": "En Route",
  "on-site": "On Site", completed: "Completed", blocked: "Blocked",
}
const FJ_STATUS_TONE: Record<FieldJob["status"], string> = {
  queued: "warn", assigned: "info", "en-route": "accent",
  "on-site": "brand", completed: "success", blocked: "danger",
}

/* Available crew today (for the unassigned dispatcher panel) */
interface FieldCrew {
  initials: string
  name: string
  tone: any
  skills: string[]
  status: "available" | "on-job" | "off"
  currentJob?: string
  hoursToday: number
}
const FIELD_CREW: FieldCrew[] = [
  { initials: "WC", name: "Warren C.", tone: "amber", skills: ["Solar", "Mechanical"],   status: "on-job",     currentJob: "FJ-2026-0418-01", hoursToday: 6.5 },
  { initials: "JD", name: "Joel D.",   tone: "amber", skills: ["Electrical", "POS"],     status: "on-job",     currentJob: "FJ-2026-0418-02", hoursToday: 5.0 },
  { initials: "PS", name: "Pedro S.",  tone: "blue",  skills: ["IT", "Networking"],      status: "on-job",     currentJob: "FJ-2026-0418-03", hoursToday: 7.0 },
  { initials: "WT", name: "Wei T.",    tone: "blue",  skills: ["IT", "Networking"],      status: "on-job",     currentJob: "FJ-2026-0418-04", hoursToday: 4.0 },
  { initials: "RD", name: "Rico D.",   tone: "amber", skills: ["Solar", "Mechanical"],   status: "on-job",     currentJob: "FJ-2026-0418-01", hoursToday: 6.5 },
  { initials: "RT", name: "Rico T.",   tone: "blue",  skills: ["IT", "Networking"],      status: "available",  hoursToday: 2.0 },
  { initials: "BE", name: "Ben Q.",    tone: "amber", skills: ["HVAC", "Plumbing"],      status: "available",  hoursToday: 0 },
  { initials: "AM", name: "Ann M.",    tone: "blue",  skills: ["Electrical", "Solar"],   status: "available",  hoursToday: 0 },
]

const FJ_BY_ID: Record<string, FieldJob> = Object.fromEntries(FIELD_JOBS.map(f => [f.id, f]))

// SANDBOX
Object.assign(globalThis as any, { FIELD_JOBS, FJ_BY_ID, FJ_STATUS_LABEL, FJ_STATUS_TONE, FIELD_CREW })

})();/*__IIFE_WRAP_END__*/

/* ═════ apps/web/lib/mock/approvals.tsx ═════ */
;/*__IIFE_WRAP_START__*/(function(){
/**
 * apps/web/lib/mock/approvals.tsx
 * Core Approvals — central inbox of pending approvals across all document
 * types. In production this comes from a polymorphic approvals table; here
 * we mock it as a flat array with everything needed to render the inbox,
 * rules engine, and history.
 */

interface ApprovalDoc {
  id: string
  type: "PO" | "PR" | "REQ" | "OR" | "SO" | "BILL" | "REIMB" | "LEAVE" | "RFQ" | "JE" | "CR" | "VENDOR" | "CONTRACT"
  typeLabel: string
  title: string
  amount?: string
  amountCcy?: string
  amountUsd?: number
  requestor: { name: string; initials: string; role: string }
  entity: string
  submittedAt: string
  urgency: "normal" | "urgent" | "blocker"
  status: "pending" | "approved" | "rejected"
  step: { current: number; total: number; label: string }
  thread?: { who: string; initials: string; when: string; text: string; tone?: "approve" | "reject" | "note" }[]
  context?: { label: string; value: string }[]
}

const APPROVALS: ApprovalDoc[] = [
  { id: "PO-HVPH-1142", type: "PO", typeLabel: "Purchase Order", title: "Pacific Steel Co. · Steel reinforcement bars (Calamba plant)",
    amount: "₱ 4,852,000", amountCcy: "PHP", amountUsd: 87420, entity: "HVPH",
    requestor: { name: "Daniel Reyes", initials: "DR", role: "Operations Manager" },
    submittedAt: "12m ago", urgency: "urgent", status: "pending",
    step: { current: 2, total: 3, label: "Finance review" },
    thread: [
      { who: "Daniel R.", initials: "DR", when: "12m ago", text: "Calamba project needs rebar by next Tuesday. Confirmed pricing with vendor." },
    ],
    context: [{ label: "Project", value: "PRJ-2026-088 · Calamba phase 2" }, { label: "OR ref", value: "OR-HVPH-0117" }],
  },
  { id: "OR-HVPH-0118", type: "OR", typeLabel: "Order Request", title: "12-month maintenance contract for backup generators",
    amount: "₱ 1,250,000", amountCcy: "PHP", amountUsd: 22480, entity: "HVPH",
    requestor: { name: "Lara Cruz", initials: "LC", role: "Facilities" },
    submittedAt: "1h ago", urgency: "normal", status: "pending",
    step: { current: 1, total: 2, label: "Procurement review" },
  },
  { id: "REIMB-2614", type: "REIMB", typeLabel: "Reimbursement", title: "Singapore trade fair · Travel + meals (3 days)",
    amount: "S$ 4,820", amountCcy: "SGD", amountUsd: 3565, entity: "HVSG",
    requestor: { name: "Kenneth Tan", initials: "KT", role: "Sales Lead" },
    submittedAt: "2h ago", urgency: "normal", status: "pending",
    step: { current: 1, total: 1, label: "Manager approval" },
  },
  { id: "LEAVE-918", type: "LEAVE", typeLabel: "Leave Request", title: "Personal leave · 12 May – 16 May (5 days)",
    entity: "HVSG",
    requestor: { name: "Vanessa Lim", initials: "VL", role: "Engineer II" },
    submittedAt: "3h ago", urgency: "normal", status: "pending",
    step: { current: 1, total: 2, label: "HR Business Partner" },
  },
  { id: "SO-HVAU-0312", type: "SO", typeLabel: "Sales Order", title: "Crown Holdings — Site equipment bundle (Sydney)",
    amount: "A$ 248,500", amountCcy: "AUD", amountUsd: 161525, entity: "HVAU",
    requestor: { name: "Mason Pham", initials: "MP", role: "Account Exec" },
    submittedAt: "5h ago", urgency: "urgent", status: "pending",
    step: { current: 2, total: 3, label: "Credit hold review" },
    context: [{ label: "Customer credit", value: "A$ 50k over limit" }],
  },
  { id: "OR-HVPH-0445", type: "OR", typeLabel: "Order Request", title: "Field laptops × 12 for Calamba field team",
    amount: "₱ 720,000", amountCcy: "PHP", amountUsd: 12960, entity: "HVPH",
    requestor: { name: "Karla Mendoza", initials: "KM", role: "Engineering Mgr" },
    submittedAt: "Yesterday", urgency: "normal", status: "pending",
    step: { current: 1, total: 2, label: "Department head approval" },
  },
  { id: "BILL-HVHK-0467", type: "BILL", typeLabel: "Vendor Bill", title: "Yuen Long Logistics · Q1 freight invoice",
    amount: "HK$ 156,400", amountCcy: "HKD", amountUsd: 20030, entity: "HVHK",
    requestor: { name: "Eric Wong", initials: "EW", role: "AP Specialist" },
    submittedAt: "Yesterday", urgency: "normal", status: "pending",
    step: { current: 2, total: 2, label: "Final approval (Controller)" },
  },
  { id: "RFQ-HVIN-0089", type: "RFQ", typeLabel: "RFQ Award", title: "Mumbai project — packaging supplier (3-vendor RFQ)",
    amount: "₹ 8,40,000", amountCcy: "INR", amountUsd: 10100, entity: "HVIN",
    requestor: { name: "Priya Iyer", initials: "PI", role: "Procurement Lead" },
    submittedAt: "Yesterday", urgency: "normal", status: "pending",
    step: { current: 1, total: 2, label: "Department head" },
    context: [{ label: "Award to", value: "Devanand Packaging Pvt. Ltd." }, { label: "Savings vs avg", value: "8.2%" }],
  },
  { id: "REIMB-2607", type: "REIMB", typeLabel: "Reimbursement", title: "Client lunch · Sydney CBD (4 attendees)",
    amount: "A$ 268", amountCcy: "AUD", amountUsd: 175, entity: "HVAU",
    requestor: { name: "Mason Pham", initials: "MP", role: "Account Exec" },
    submittedAt: "Yesterday", urgency: "normal", status: "pending",
    step: { current: 1, total: 1, label: "Manager approval" },
  },
  { id: "CONTRACT-HVSG-0024", type: "CONTRACT", typeLabel: "Customer Contract", title: "Tan Beng Holdings · MSA renewal (2 years, S$ 1.2M)",
    amount: "S$ 1,200,000", amountCcy: "SGD", amountUsd: 887000, entity: "HVSG",
    requestor: { name: "Kenneth Tan", initials: "KT", role: "Sales Lead" },
    submittedAt: "2 days ago", urgency: "blocker", status: "pending",
    step: { current: 3, total: 4, label: "Legal" },
    context: [{ label: "Renewal", value: "75% margin · 2-yr term" }],
  },
  { id: "VENDOR-0098", type: "VENDOR", typeLabel: "Vendor Onboarding", title: "Mumbai Logistics LLP · New vendor approval",
    entity: "HVIN",
    requestor: { name: "Priya Iyer", initials: "PI", role: "Procurement Lead" },
    submittedAt: "2 days ago", urgency: "normal", status: "pending",
    step: { current: 2, total: 3, label: "Risk & compliance" },
  },
  { id: "JE-2026-04-0089", type: "JE", typeLabel: "Journal Entry", title: "April FX revaluation · all entities (group close)",
    amount: "$ 41,820",  amountCcy: "USD", amountUsd: 41820, entity: "HVG",
    requestor: { name: "Anil Verma",   initials: "AV", role: "CFO" },
    submittedAt: "3 days ago", urgency: "normal", status: "pending",
    step: { current: 1, total: 1, label: "Controller approval" },
  },
]

/* Approved history sample */
const APPROVAL_HISTORY = [
  { id: "PO-HVPH-1138", type: "Purchase Order", title: "Calamba safety equipment", who: "Maya C.", when: "Today 10:14", status: "approved", amount: "₱ 845,000" },
  { id: "OR-HVPH-0117", type: "Order Request", title: "Steel reinforcement bars", who: "Maya C.", when: "Today 09:30", status: "approved", amount: "₱ 4,852,000" },
  { id: "LEAVE-914",   type: "Leave Request", title: "Daniel Reyes · 4 days personal leave", who: "Sofia M.", when: "Today 08:45", status: "approved", amount: "—" },
  { id: "REIMB-2598",  type: "Reimbursement", title: "Marketing — Q1 trade fair invoice", who: "Maria A.", when: "Yesterday 16:20", status: "approved", amount: "S$ 12,400" },
  { id: "SO-HVSG-0298", type: "Sales Order", title: "Tan Beng Holdings — repeat order", who: "Anil V.", when: "Yesterday 14:30", status: "approved", amount: "S$ 88,500" },
  { id: "VENDOR-0095", type: "Vendor Onboarding", title: "Pacific Steel Co.", who: "Maya C.", when: "Yesterday 11:05", status: "approved", amount: "—" },
  { id: "PO-HVSG-1108", type: "Purchase Order", title: "Office furniture refresh", who: "Maria A.", when: "Yesterday 10:15", status: "rejected", amount: "S$ 28,600" },
  { id: "REIMB-2592",  type: "Reimbursement", title: "Daniel R. — Calamba site visit", who: "Maya C.", when: "2d ago 15:20", status: "approved", amount: "₱ 12,800" },
  { id: "OR-HVHK-0086", type: "Order Request", title: "Hong Kong showroom signage", who: "Maya C.", when: "2d ago 09:30", status: "rejected", amount: "HK$ 88,000" },
  { id: "JE-2026-03-0112", type: "Journal Entry", title: "March FX revaluation", who: "Anil V.", when: "3d ago", status: "approved", amount: "$ 28,540" },
]

/* Approval rules sample */
const APPROVAL_RULES = [
  { id: "R-001", scope: "Purchase Order", trigger: "Amount > $10,000 USD-equivalent", chain: ["Dept Head", "Procurement", "Finance"], active: true },
  { id: "R-002", scope: "Purchase Order", trigger: "Amount > $100,000 USD-equivalent", chain: ["Dept Head", "Procurement", "Finance", "CFO"], active: true },
  { id: "R-003", scope: "Reimbursement",   trigger: "Amount > local currency 5,000", chain: ["Manager", "Finance"], active: true },
  { id: "R-004", scope: "Leave Request",   trigger: "More than 3 days", chain: ["Manager", "HR Business Partner"], active: true },
  { id: "R-005", scope: "Sales Order",     trigger: "Customer over credit limit",  chain: ["Sales Manager", "Credit Controller", "Finance"], active: true },
  { id: "R-006", scope: "Vendor Onboarding", trigger: "Always",   chain: ["Procurement", "Risk & Compliance", "Procurement Director"], active: true },
  { id: "R-007", scope: "Journal Entry",   trigger: "Amount > $25,000 USD-equivalent", chain: ["Controller"], active: true },
  { id: "R-008", scope: "Customer Contract", trigger: "Term > 1 year OR value > $50k", chain: ["Sales", "Legal", "Finance", "CFO"], active: true },
  { id: "R-009", scope: "Order Request",   trigger: "Capex tag = true", chain: ["Dept Head", "Finance", "CFO"], active: true },
  { id: "R-010", scope: "Order Request",   trigger: "Capex tag = false", chain: ["Dept Head"], active: true },
]

// SANDBOX
Object.assign(globalThis as any, { APPROVALS, APPROVAL_HISTORY, APPROVAL_RULES })

})();/*__IIFE_WRAP_END__*/

/* ═════ apps/web/lib/mock/logistics.tsx ═════ */
;/*__IIFE_WRAP_START__*/(function(){
/**
 * apps/web/lib/mock/logistics.tsx
 * Logistics / TMS mock data — transport orders, routes, fleet, drivers, GPS.
 */

interface TransportOrder {
  id: string
  status: "draft" | "scheduled" | "in-transit" | "delivered" | "exception"
  ref: string                  /* originating doc — SO, PO, IR, etc */
  origin: { entity: string; city: string; country: string }
  destination: { city: string; country: string; customer?: string }
  loadKg: number
  loadM3: number
  vehicle?: string             /* license plate */
  driver?: string
  driverInitials?: string
  carrier?: string
  eta: string
  cost: { amount: number; ccy: string }
  progress: number             /* 0..1 */
}

const TRANSPORT: TransportOrder[] = [
  { id: "TO-HVPH-0167", status: "in-transit", ref: "SO-HVPH-0312", origin: { entity: "HVPH", city: "Manila", country: "PH" }, destination: { city: "Calamba", country: "PH", customer: "Pacific Steel Co." }, loadKg: 4200, loadM3: 18.2, vehicle: "NCJ-2148", driver: "Romulo Cruz", driverInitials: "RC", eta: "Today 16:20", cost: { amount: 14800, ccy: "PHP" }, progress: 0.65 },
  { id: "TO-HVPH-0166", status: "in-transit", ref: "SO-HVPH-0310", origin: { entity: "HVPH", city: "Manila", country: "PH" }, destination: { city: "Quezon City", country: "PH" }, loadKg: 1850, loadM3: 8.4, vehicle: "NCJ-2152", driver: "Joseph Reyes", driverInitials: "JR", eta: "Today 13:15", cost: { amount: 6200, ccy: "PHP" }, progress: 0.90 },
  { id: "TO-HVSG-0084", status: "scheduled", ref: "PO-HVSG-1108", origin: { entity: "HVSG", city: "Singapore", country: "SG" }, destination: { city: "Jurong", country: "SG", customer: "Tan Beng Holdings" }, loadKg: 920, loadM3: 4.1, vehicle: "SGE-184C", driver: "Lim Wei Ming", driverInitials: "LW", eta: "Tomorrow 09:00", cost: { amount: 480, ccy: "SGD" }, progress: 0 },
  { id: "TO-HVAU-0042", status: "in-transit", ref: "SO-HVAU-0214", origin: { entity: "HVAU", city: "Sydney", country: "AU" }, destination: { city: "Parramatta", country: "AU", customer: "Crown Holdings" }, loadKg: 3400, loadM3: 14.6, carrier: "TollExpress", vehicle: "BS28-PQR", driver: "TollExpress (3PL)", driverInitials: "TX", eta: "Today 14:00", cost: { amount: 1850, ccy: "AUD" }, progress: 0.45 },
  { id: "TO-HVIN-0118", status: "exception", ref: "PO-HVIN-0894", origin: { entity: "HVIN", city: "Mumbai", country: "IN" }, destination: { city: "Pune", country: "IN" }, loadKg: 2100, loadM3: 9.8, carrier: "Delhivery", vehicle: "MH-12-AB-3389", driver: "Anand Kumar", driverInitials: "AK", eta: "Delayed +3h", cost: { amount: 14800, ccy: "INR" }, progress: 0.40 },
  { id: "TO-HVHK-0029", status: "scheduled", ref: "IR-HVHK-1019", origin: { entity: "HVHK", city: "Central", country: "HK" }, destination: { city: "Sha Tin", country: "HK" }, loadKg: 1400, loadM3: 6.2, vehicle: "GH-2148", driver: "Lau Chi Wai", driverInitials: "LC", eta: "Tomorrow 14:00", cost: { amount: 880, ccy: "HKD" }, progress: 0 },
  { id: "TO-HVPH-0165", status: "delivered", ref: "SO-HVPH-0309", origin: { entity: "HVPH", city: "Manila", country: "PH" }, destination: { city: "Makati", country: "PH" }, loadKg: 220, loadM3: 1.2, vehicle: "NCJ-2148", driver: "Romulo Cruz", driverInitials: "RC", eta: "Delivered 11:14", cost: { amount: 1200, ccy: "PHP" }, progress: 1 },
  { id: "TO-HVAU-0041", status: "delivered", ref: "PO-HVAU-0488", origin: { entity: "HVAU", city: "Sydney", country: "AU" }, destination: { city: "Wollongong", country: "AU" }, loadKg: 880, loadM3: 4.4, carrier: "StarTrack", vehicle: "ST-1A4PRX", driver: "StarTrack (3PL)", driverInitials: "ST", eta: "Delivered Yesterday", cost: { amount: 620, ccy: "AUD" }, progress: 1 },
  { id: "TO-HVIN-0117", status: "draft", ref: "—", origin: { entity: "HVIN", city: "Mumbai", country: "IN" }, destination: { city: "Bengaluru", country: "IN" }, loadKg: 5400, loadM3: 22.0, eta: "—", cost: { amount: 0, ccy: "INR" }, progress: 0 },
  { id: "TO-HVSG-0083", status: "delivered", ref: "SO-HVSG-0296", origin: { entity: "HVSG", city: "Singapore", country: "SG" }, destination: { city: "Tuas", country: "SG" }, loadKg: 1280, loadM3: 6.0, vehicle: "SGE-184C", driver: "Lim Wei Ming", driverInitials: "LW", eta: "Delivered 09:30", cost: { amount: 620, ccy: "SGD" }, progress: 1 },
]

const VEHICLES = [
  { plate: "NCJ-2148", entity: "HVPH", type: "Truck",     model: "Hino 500 6x4",       capacityKg: 8000,  status: "active",   driver: "Romulo Cruz",   driverInitials: "RC", odometer: 184820, lastService: "12 Apr 2026", nextService: "12 Jul 2026" },
  { plate: "NCJ-2152", entity: "HVPH", type: "Van",       model: "Toyota HiAce 2024",  capacityKg: 3000,  status: "active",   driver: "Joseph Reyes",  driverInitials: "JR", odometer: 84120, lastService: "20 Apr 2026", nextService: "20 Jul 2026" },
  { plate: "NCJ-2155", entity: "HVPH", type: "Van",       model: "Toyota HiAce 2023",  capacityKg: 3000,  status: "maintenance", driver: "—",         driverInitials: "—",  odometer: 154200, lastService: "Today",       nextService: "—" },
  { plate: "SGE-184C", entity: "HVSG", type: "Truck",     model: "Isuzu Forward 8t",   capacityKg: 8000,  status: "active",   driver: "Lim Wei Ming",  driverInitials: "LW", odometer: 64800, lastService: "1 May 2026",  nextService: "1 Aug 2026" },
  { plate: "SGE-188D", entity: "HVSG", type: "Refrigerated", model: "Mitsubishi Canter 4t", capacityKg: 4000, status: "active", driver: "Goh Beng Hock", driverInitials: "GB", odometer: 48200, lastService: "5 May 2026",  nextService: "5 Aug 2026" },
  { plate: "GH-2148",  entity: "HVHK", type: "Van",       model: "Ford Transit 2024",  capacityKg: 1800,  status: "active",   driver: "Lau Chi Wai",   driverInitials: "LC", odometer: 38400, lastService: "10 Apr 2026", nextService: "10 Jul 2026" },
  { plate: "BS28-PQR", entity: "HVAU", type: "Truck",     model: "Hino 500 Series",    capacityKg: 12000, status: "active",   driver: "Tom Ngata",     driverInitials: "TN", odometer: 92800, lastService: "8 Mar 2026",  nextService: "8 Jun 2026" },
  { plate: "BS31-XYC", entity: "HVAU", type: "Van",       model: "Ford Transit 2025",  capacityKg: 2200,  status: "active",   driver: "Mia Hartley",   driverInitials: "MH", odometer: 12600, lastService: "20 Apr 2026", nextService: "20 Jul 2026" },
  { plate: "MH-12-AB-3389", entity: "HVIN", type: "Truck", model: "Tata Signa 2825",  capacityKg: 14000, status: "active", driver: "Anand Kumar",  driverInitials: "AK", odometer: 184200, lastService: "Apr 2026",   nextService: "Jul 2026" },
  { plate: "MH-12-CD-4912", entity: "HVIN", type: "Van",   model: "Mahindra Bolero",   capacityKg: 1500,  status: "active", driver: "Suresh Patel", driverInitials: "SP", odometer: 64800, lastService: "Mar 2026", nextService: "Jun 2026" },
]

const ROUTES_TMS = [
  { id: "R-MANILA-CALAMBA", name: "Manila → Calamba", stops: 4, distanceKm: 56, avgHours: 1.8, avgCost: 14800, ccy: "PHP", lastRun: "Today", efficiency: 0.92 },
  { id: "R-MANILA-QC",      name: "Manila → Quezon City Loop", stops: 8, distanceKm: 32, avgHours: 2.4, avgCost: 6200, ccy: "PHP", lastRun: "Today", efficiency: 0.88 },
  { id: "R-SG-JURONG",      name: "Singapore HQ → Jurong Industrial", stops: 3, distanceKm: 22, avgHours: 1.1, avgCost: 480, ccy: "SGD", lastRun: "Today", efficiency: 0.94 },
  { id: "R-SG-TUAS",        name: "Singapore HQ → Tuas Port", stops: 1, distanceKm: 38, avgHours: 1.4, avgCost: 620, ccy: "SGD", lastRun: "Yesterday", efficiency: 0.91 },
  { id: "R-HK-NT",          name: "Central → New Territories Loop", stops: 6, distanceKm: 48, avgHours: 2.8, avgCost: 880, ccy: "HKD", lastRun: "Today", efficiency: 0.85 },
  { id: "R-SYDNEY-PARRA",   name: "Sydney → Parramatta Corridor", stops: 5, distanceKm: 24, avgHours: 1.6, avgCost: 1850, ccy: "AUD", lastRun: "Today", efficiency: 0.82 },
  { id: "R-MUM-PUNE",       name: "Mumbai → Pune Express", stops: 2, distanceKm: 148, avgHours: 4.2, avgCost: 14800, ccy: "INR", lastRun: "Today", efficiency: 0.78 },
  { id: "R-MUM-LOOP",       name: "Mumbai Metro Loop", stops: 12, distanceKm: 84, avgHours: 5.8, avgCost: 8800, ccy: "INR", lastRun: "Today", efficiency: 0.81 },
]

const FLEET_KPIS = {
  totalVehicles: VEHICLES.length,
  active: VEHICLES.filter(v => v.status === "active").length,
  maintenance: VEHICLES.filter(v => v.status === "maintenance").length,
  utilization: 0.78,
  onTimeDeliveries: 0.91,
  fuelCostMtd: 142800,         /* USD */
  freightSpendMtd: 248600,     /* USD */
  deliveriesToday: 24,
  exceptionsActive: 3,
}

// SANDBOX
Object.assign(globalThis as any, { TRANSPORT, VEHICLES, ROUTES_TMS, FLEET_KPIS })

})();/*__IIFE_WRAP_END__*/

/* ═════ apps/web/lib/mock/project-mgmt.tsx ═════ */
;/*__IIFE_WRAP_START__*/(function(){
/**
 * apps/web/lib/mock/project-mgmt.tsx
 * Project Management — the operational side of projects (not the money).
 * Projects, tasks, milestones, schedule, resources.
 */

interface PMProject {
  id: string
  name: string
  client: string
  entity: string
  status: "planning" | "active" | "on-hold" | "complete"
  health: "green" | "amber" | "red"
  pm: string
  pmInitials: string
  startDate: string
  endDate: string
  progress: number      /* 0..1 */
  budgetUsd: number
  spentUsd: number
  tasksTotal: number
  tasksDone: number
  milestonesNext: string
}

const PM_PROJECTS: PMProject[] = [
  { id: "PRJ-2026-088", name: "Calamba Industrial Phase 2", client: "Pacific Steel Co.", entity: "HVPH", status: "active", health: "amber", pm: "Daniel Reyes", pmInitials: "DR", startDate: "12 Jan 2026", endDate: "15 Sep 2026", progress: 0.62, budgetUsd: 3_200_000, spentUsd: 2_180_000, tasksTotal: 142, tasksDone: 88, milestonesNext: "Foundation pour · 24 May" },
  { id: "PRJ-2026-082", name: "Tuas Cold Storage Build-Out", client: "Tan Beng Holdings", entity: "HVSG", status: "active", health: "green", pm: "Wei Ming Lim", pmInitials: "WL", startDate: "5 Feb 2026", endDate: "12 Aug 2026", progress: 0.78, budgetUsd: 4_100_000, spentUsd: 2_980_000, tasksTotal: 96, tasksDone: 75, milestonesNext: "Refrigeration commissioning · 18 May" },
  { id: "PRJ-2026-091", name: "Sydney Distribution Hub Fit-Out", client: "Crown Holdings", entity: "HVAU", status: "active", health: "green", pm: "Mia Hartley", pmInitials: "MH", startDate: "1 Mar 2026", endDate: "30 Jun 2026", progress: 0.55, budgetUsd: 1_850_000, spentUsd: 1_018_000, tasksTotal: 74, tasksDone: 40, milestonesNext: "MEP rough-in · 20 May" },
  { id: "PRJ-2026-078", name: "Mumbai Plant Phase 3 Expansion", client: "Internal — HVIN", entity: "HVIN", status: "active", health: "red", pm: "Priya Iyer", pmInitials: "PI", startDate: "10 Jan 2026", endDate: "30 Nov 2026", progress: 0.42, budgetUsd: 5_800_000, spentUsd: 3_580_000, tasksTotal: 188, tasksDone: 84, milestonesNext: "Steel structure complete · 28 May" },
  { id: "PRJ-2026-095", name: "Hong Kong Showroom Refresh", client: "Internal — HVHK", entity: "HVHK", status: "planning", health: "green", pm: "Eric Wong", pmInitials: "EW", startDate: "20 May 2026", endDate: "30 Jul 2026", progress: 0.10, budgetUsd: 480_000, spentUsd: 38_000, tasksTotal: 42, tasksDone: 5, milestonesNext: "Design freeze · 12 May" },
  { id: "PRJ-2026-072", name: "Quezon City Warehouse Retrofit", client: "Internal — HVPH", entity: "HVPH", status: "active", health: "green", pm: "Karla Mendoza", pmInitials: "KM", startDate: "20 Dec 2025", endDate: "30 May 2026", progress: 0.88, budgetUsd: 920_000, spentUsd: 818_000, tasksTotal: 64, tasksDone: 58, milestonesNext: "Final handover · 25 May" },
  { id: "PRJ-2026-101", name: "Bengaluru Tech Campus", client: "Stellar Tech Ltd.", entity: "HVIN", status: "planning", health: "amber", pm: "Anand Kumar", pmInitials: "AK", startDate: "1 Jun 2026", endDate: "31 Mar 2027", progress: 0.04, budgetUsd: 7_400_000, spentUsd: 184_000, tasksTotal: 220, tasksDone: 6, milestonesNext: "Site survey · 18 May" },
  { id: "PRJ-2026-085", name: "Pune Modular Warehouse", client: "Devanand Logistics", entity: "HVIN", status: "active", health: "green", pm: "Suresh Patel", pmInitials: "SP", startDate: "1 Feb 2026", endDate: "30 Sep 2026", progress: 0.51, budgetUsd: 2_200_000, spentUsd: 1_018_000, tasksTotal: 88, tasksDone: 42, milestonesNext: "Modular delivery · 8 Jun" },
  { id: "PRJ-2026-068", name: "Singapore HQ Solar PV Install", client: "Internal — HVSG", entity: "HVSG", status: "on-hold", health: "red", pm: "Kenneth Tan", pmInitials: "KT", startDate: "15 Nov 2025", endDate: "—", progress: 0.32, budgetUsd: 680_000, spentUsd: 218_000, tasksTotal: 40, tasksDone: 12, milestonesNext: "Permit re-submission · 30 May" },
  { id: "PRJ-2025-228", name: "Sydney Retail Pop-Up Build", client: "Crown Holdings", entity: "HVAU", status: "complete", health: "green", pm: "Mason Pham", pmInitials: "MP", startDate: "10 Sep 2025", endDate: "20 Dec 2025", progress: 1, budgetUsd: 420_000, spentUsd: 412_000, tasksTotal: 38, tasksDone: 38, milestonesNext: "—" },
]

interface PMTask {
  id: string
  projectId: string
  title: string
  assignee: string
  assigneeInitials: string
  status: "todo" | "in-progress" | "blocked" | "review" | "done"
  due: string
  priority: "low" | "med" | "high" | "urgent"
  hoursPlanned: number
  hoursLogged: number
}

const PM_TASKS: PMTask[] = [
  /* Calamba */
  { id: "T-9012", projectId: "PRJ-2026-088", title: "Foundation rebar layout review", assignee: "Daniel R.", assigneeInitials: "DR", status: "in-progress", due: "20 May",  priority: "urgent", hoursPlanned: 16, hoursLogged: 12 },
  { id: "T-9014", projectId: "PRJ-2026-088", title: "Calamba — site safety audit prep", assignee: "Lara C.", assigneeInitials: "LC", status: "todo", due: "22 May", priority: "high", hoursPlanned: 8,  hoursLogged: 0 },
  { id: "T-9015", projectId: "PRJ-2026-088", title: "Daily progress photos · week 18", assignee: "Joseph R.", assigneeInitials: "JR", status: "in-progress", due: "ongoing", priority: "low", hoursPlanned: 5, hoursLogged: 3 },
  { id: "T-9018", projectId: "PRJ-2026-088", title: "Rebar delivery scheduling with logistics", assignee: "Daniel R.", assigneeInitials: "DR", status: "blocked", due: "21 May", priority: "urgent", hoursPlanned: 4, hoursLogged: 1 },
  /* Tuas */
  { id: "T-8801", projectId: "PRJ-2026-082", title: "Refrigeration unit FAT review", assignee: "Wei Ming L.", assigneeInitials: "WL", status: "review",  due: "18 May", priority: "urgent", hoursPlanned: 12, hoursLogged: 11 },
  { id: "T-8802", projectId: "PRJ-2026-082", title: "Insulation panel QC report", assignee: "Goh Beng H.",   assigneeInitials: "GB", status: "in-progress", due: "20 May", priority: "high", hoursPlanned: 8,  hoursLogged: 4 },
  /* Sydney */
  { id: "T-7705", projectId: "PRJ-2026-091", title: "MEP coordination drawing v3", assignee: "Mia H.",       assigneeInitials: "MH", status: "in-progress", due: "20 May", priority: "high", hoursPlanned: 20, hoursLogged: 14 },
  { id: "T-7707", projectId: "PRJ-2026-091", title: "Fire safety permit application", assignee: "Tom N.",   assigneeInitials: "TN", status: "todo", due: "30 May", priority: "med", hoursPlanned: 6, hoursLogged: 0 },
  /* Mumbai (red project) */
  { id: "T-6601", projectId: "PRJ-2026-078", title: "Steel erection — weld inspection", assignee: "Anand K.", assigneeInitials: "AK", status: "blocked", due: "25 May", priority: "urgent", hoursPlanned: 16, hoursLogged: 2 },
  { id: "T-6602", projectId: "PRJ-2026-078", title: "Vendor delay escalation memo", assignee: "Priya I.", assigneeInitials: "PI", status: "in-progress", due: "20 May", priority: "urgent", hoursPlanned: 4,  hoursLogged: 3 },
  { id: "T-6605", projectId: "PRJ-2026-078", title: "Re-baseline schedule with PMO",  assignee: "Priya I.", assigneeInitials: "PI", status: "todo", due: "22 May", priority: "urgent", hoursPlanned: 12, hoursLogged: 0 },
  /* Quezon City */
  { id: "T-5501", projectId: "PRJ-2026-072", title: "Final racking installation",  assignee: "Karla M.", assigneeInitials: "KM", status: "done",  due: "10 May", priority: "high", hoursPlanned: 16, hoursLogged: 16 },
  { id: "T-5502", projectId: "PRJ-2026-072", title: "Punch list walkthrough", assignee: "Karla M.", assigneeInitials: "KM", status: "in-progress", due: "20 May", priority: "high", hoursPlanned: 8, hoursLogged: 5 },
  { id: "T-5503", projectId: "PRJ-2026-072", title: "Owner handover documentation", assignee: "Karla M.", assigneeInitials: "KM", status: "review", due: "23 May", priority: "med", hoursPlanned: 12, hoursLogged: 8 },
]

interface PMResource {
  name: string
  initials: string
  role: string
  entity: string
  capacityHrs: number
  assignedHrs: number
  utilization: number   /* 0..1 */
  projects: { id: string; name: string; hours: number }[]
}

const PM_RESOURCES: PMResource[] = [
  { name: "Daniel Reyes",   initials: "DR", role: "Operations Manager", entity: "HVPH", capacityHrs: 40, assignedHrs: 38, utilization: 0.95, projects: [{ id: "PRJ-2026-088", name: "Calamba Phase 2", hours: 28 }, { id: "PRJ-2026-072", name: "QC Retrofit", hours: 10 }] },
  { name: "Lara Cruz",      initials: "LC", role: "Site Engineer", entity: "HVPH", capacityHrs: 40, assignedHrs: 32, utilization: 0.80, projects: [{ id: "PRJ-2026-088", name: "Calamba Phase 2", hours: 32 }] },
  { name: "Joseph Reyes",   initials: "JR", role: "Field Coordinator", entity: "HVPH", capacityHrs: 40, assignedHrs: 28, utilization: 0.70, projects: [{ id: "PRJ-2026-088", name: "Calamba Phase 2", hours: 16 }, { id: "PRJ-2026-072", name: "QC Retrofit", hours: 12 }] },
  { name: "Karla Mendoza",  initials: "KM", role: "Project Manager", entity: "HVPH", capacityHrs: 40, assignedHrs: 36, utilization: 0.90, projects: [{ id: "PRJ-2026-072", name: "QC Retrofit", hours: 36 }] },
  { name: "Wei Ming Lim",   initials: "WL", role: "Senior PM", entity: "HVSG", capacityHrs: 40, assignedHrs: 42, utilization: 1.05, projects: [{ id: "PRJ-2026-082", name: "Tuas Cold Storage", hours: 42 }] },
  { name: "Goh Beng Hock",  initials: "GB", role: "QC Lead", entity: "HVSG", capacityHrs: 40, assignedHrs: 24, utilization: 0.60, projects: [{ id: "PRJ-2026-082", name: "Tuas Cold Storage", hours: 24 }] },
  { name: "Mia Hartley",    initials: "MH", role: "Project Manager", entity: "HVAU", capacityHrs: 40, assignedHrs: 30, utilization: 0.75, projects: [{ id: "PRJ-2026-091", name: "Sydney Hub", hours: 30 }] },
  { name: "Tom Ngata",      initials: "TN", role: "Site Engineer", entity: "HVAU", capacityHrs: 40, assignedHrs: 22, utilization: 0.55, projects: [{ id: "PRJ-2026-091", name: "Sydney Hub", hours: 22 }] },
  { name: "Priya Iyer",     initials: "PI", role: "Senior PM", entity: "HVIN", capacityHrs: 40, assignedHrs: 48, utilization: 1.20, projects: [{ id: "PRJ-2026-078", name: "Mumbai Phase 3", hours: 32 }, { id: "PRJ-2026-101", name: "Bengaluru Campus", hours: 16 }] },
  { name: "Anand Kumar",    initials: "AK", role: "Site Engineer", entity: "HVIN", capacityHrs: 40, assignedHrs: 40, utilization: 1.00, projects: [{ id: "PRJ-2026-078", name: "Mumbai Phase 3", hours: 40 }] },
  { name: "Suresh Patel",   initials: "SP", role: "Project Manager", entity: "HVIN", capacityHrs: 40, assignedHrs: 26, utilization: 0.65, projects: [{ id: "PRJ-2026-085", name: "Pune Modular", hours: 26 }] },
]

const PM_KPIS = {
  active:    PM_PROJECTS.filter(p => p.status === "active").length,
  planning:  PM_PROJECTS.filter(p => p.status === "planning").length,
  onHold:    PM_PROJECTS.filter(p => p.status === "on-hold").length,
  complete:  PM_PROJECTS.filter(p => p.status === "complete").length,
  green:     PM_PROJECTS.filter(p => p.health === "green").length,
  amber:     PM_PROJECTS.filter(p => p.health === "amber").length,
  red:       PM_PROJECTS.filter(p => p.health === "red").length,
  budgetTotalM: PM_PROJECTS.reduce((s, p) => s + p.budgetUsd, 0) / 1_000_000,
  burnRatePct: PM_PROJECTS.reduce((s, p) => s + p.spentUsd, 0) / PM_PROJECTS.reduce((s, p) => s + p.budgetUsd, 0),
  upcomingMilestones: 14,
  overdueTasks: 7,
}

// SANDBOX
Object.assign(globalThis as any, { PM_PROJECTS, PM_TASKS, PM_RESOURCES, PM_KPIS })

})();/*__IIFE_WRAP_END__*/

/* ═════ apps/web/lib/mock/hris-extras.tsx ═════ */
;/*__IIFE_WRAP_START__*/(function(){
/**
 * apps/web/lib/mock/hris-extras.tsx
 * HRIS — Recruitment, Performance, Training, Payroll, Attendance, Cases.
 */

/* ─── RECRUITMENT ─────────────────────────────────────────────────── */
const RECRUITMENT_REQS = [
  { id: "REQ-2026-014", title: "Senior Procurement Specialist", entity: "HVPH", dept: "Procurement", hiringMgr: "Maya C.", level: "Senior", openings: 1, applicants: 47, source: "Indeed + Referrals", stage: "interviewing", daysOpen: 22, target: "Jun 2026" },
  { id: "REQ-2026-017", title: "Site Engineer (3 positions)",  entity: "HVPH", dept: "Engineering", hiringMgr: "Daniel R.", level: "Mid", openings: 3, applicants: 88, source: "Indeed", stage: "screening",   daysOpen: 14, target: "May 2026" },
  { id: "REQ-2026-018", title: "Account Executive (APAC)",     entity: "HVSG", dept: "Sales", hiringMgr: "Kenneth T.", level: "Mid", openings: 2, applicants: 64, source: "LinkedIn", stage: "interviewing", daysOpen: 18, target: "Jun 2026" },
  { id: "REQ-2026-019", title: "AP Specialist",                 entity: "HVHK", dept: "Finance", hiringMgr: "Maria A.", level: "Junior", openings: 1, applicants: 34, source: "Referrals", stage: "offer", daysOpen: 28, target: "May 2026" },
  { id: "REQ-2026-021", title: "Logistics Coordinator",         entity: "HVAU", dept: "Logistics", hiringMgr: "Mia H.", level: "Junior", openings: 1, applicants: 22, source: "Indeed", stage: "screening", daysOpen: 9, target: "Jul 2026" },
  { id: "REQ-2026-022", title: "Software Engineer · ERP Integrations", entity: "HVSG", dept: "IT", hiringMgr: "Tom K.", level: "Senior", openings: 1, applicants: 118, source: "LinkedIn", stage: "interviewing", daysOpen: 32, target: "Jun 2026" },
]

const RECRUITMENT_CANDIDATES = [
  /* For REQ-2026-014 — Procurement Specialist */
  { id: "CND-9012", reqId: "REQ-2026-014", name: "Marco Santos",    initials: "MS", stage: "interviewing", score: 8.4, source: "Indeed",    last: "Tech round 2 · Tomorrow", fit: "Strong PHP-based ERP background, 6 yrs P2P", flagAi: true },
  { id: "CND-9013", reqId: "REQ-2026-014", name: "Diana Ramos",     initials: "DR", stage: "interviewing", score: 8.1, source: "Referral",  last: "HR round · Wed",          fit: "Strong PHP-based ERP background, 5 yrs" },
  { id: "CND-9014", reqId: "REQ-2026-014", name: "Jocelyn Aquino",  initials: "JA", stage: "screening",     score: 7.6, source: "Indeed",    last: "CV review",                 fit: "4 yrs procurement, no ERP exposure" },
  { id: "CND-9015", reqId: "REQ-2026-014", name: "Carlo Bautista",  initials: "CB", stage: "offer",         score: 8.8, source: "Referral",  last: "Offer extended Mon",       fit: "Excellent · former vendor mgmt at Ayala" },
  /* For REQ-2026-018 — AE */
  { id: "CND-9101", reqId: "REQ-2026-018", name: "Rachael Ong",     initials: "RO", stage: "interviewing", score: 8.5, source: "LinkedIn",  last: "Panel · Thursday",         fit: "Industrial sales 7yr, hit quota 4yr running" },
  { id: "CND-9102", reqId: "REQ-2026-018", name: "Ravi Mehta",      initials: "RM", stage: "screening",     score: 7.4, source: "LinkedIn",  last: "Recruiter call · Today",   fit: "Industrial chems sales, exploring move" },
  /* For REQ-2026-022 — Eng */
  { id: "CND-9201", reqId: "REQ-2026-022", name: "Akira Tanaka",    initials: "AT", stage: "interviewing", score: 9.1, source: "LinkedIn",  last: "Tech 2 · Fri",             fit: "Strong Next.js + ERP integrations bg",  flagAi: true },
  { id: "CND-9202", reqId: "REQ-2026-022", name: "Naveen Kumar",    initials: "NK", stage: "interviewing", score: 8.7, source: "LinkedIn",  last: "Sys design · Thu",         fit: "Distributed systems lead, 10 yrs" },
]

/* ─── PERFORMANCE ─────────────────────────────────────────────────── */
const PERF_CYCLE = { name: "Q1 2026 Mid-year Calibration", endsOn: "30 May 2026", participation: 0.87 }
const PERF_REVIEWS = [
  { dept: "Procurement",  reviewers: 4, employees: 22, completed: 18, avgScore: 4.1, aiFlag: 0 },
  { dept: "Engineering",  reviewers: 8, employees: 64, completed: 52, avgScore: 3.9, aiFlag: 2 },
  { dept: "Finance",      reviewers: 3, employees: 16, completed: 14, avgScore: 4.3, aiFlag: 0 },
  { dept: "Sales",        reviewers: 5, employees: 28, completed: 25, avgScore: 4.0, aiFlag: 1 },
  { dept: "Operations",   reviewers: 6, employees: 38, completed: 30, avgScore: 4.0, aiFlag: 1 },
  { dept: "HR",           reviewers: 2, employees: 9,  completed: 9,  avgScore: 4.4, aiFlag: 0 },
  { dept: "IT",           reviewers: 2, employees: 12, completed: 10, avgScore: 4.2, aiFlag: 0 },
  { dept: "Logistics",    reviewers: 3, employees: 18, completed: 14, avgScore: 3.7, aiFlag: 1 },
]
const PERF_TOP_FLAGS = [
  { who: "Anand Kumar",   initials: "AK", entity: "HVIN", flag: "Score dropped 2 cycles in a row (3.2 → 2.8)", severity: "high" },
  { who: "Vanessa Lim",   initials: "VL", entity: "HVSG", flag: "Peer feedback significantly above manager rating",      severity: "med" },
  { who: "Mason Pham",    initials: "MP", entity: "HVAU", flag: "Sales quota attainment 142% vs rating 3.5",             severity: "med" },
  { who: "Tom Ngata",     initials: "TN", entity: "HVAU", flag: "No 1:1s logged in last 6 weeks",                         severity: "low"  },
]

/* ─── TRAINING ────────────────────────────────────────────────────── */
const TRAINING_PROGRAMS = [
  { id: "TR-101", title: "Workplace Safety & Compliance 2026", required: true, enrolled: 720, completed: 612, dueBy: "30 Jun 2026", mode: "Online · 2hr", category: "Compliance" },
  { id: "TR-102", title: "Ethics & Anti-Corruption Refresher", required: true, enrolled: 1240, completed: 1184, dueBy: "31 May 2026", mode: "Online · 45m", category: "Compliance" },
  { id: "TR-110", title: "Cenora ERP — Procurement Module",     required: false, enrolled: 84, completed: 62, dueBy: "—", mode: "Online · 3hr", category: "Product" },
  { id: "TR-204", title: "Project Management Fundamentals (PMI)", required: false, enrolled: 48, completed: 32, dueBy: "—", mode: "Hybrid · 8wk", category: "Skills" },
  { id: "TR-208", title: "Heavy Equipment Operations Certification", required: true, enrolled: 38, completed: 31, dueBy: "30 Jul 2026", mode: "In-person · 5d", category: "Safety" },
  { id: "TR-301", title: "Leadership Foundations (1st-time Mgrs)", required: false, enrolled: 28, completed: 24, dueBy: "—", mode: "Hybrid · 6wk", category: "Leadership" },
  { id: "TR-405", title: "GDPR & APAC Data Privacy 2026",      required: true, enrolled: 1240, completed: 962, dueBy: "30 Jun 2026", mode: "Online · 1hr", category: "Compliance" },
  { id: "TR-501", title: "Welding Skills Certification (Gr 2)",    required: false, enrolled: 22, completed: 20, dueBy: "—", mode: "In-person · 10d", category: "Trade Skill" },
]

/* ─── PAYROLL ────────────────────────────────────────────────────── */
const PAYROLL_RUNS = [
  { entity: "HVPH", month: "Apr 2026", employees: 412, gross: 18_240_000, net: 14_820_000, ccy: "PHP", status: "posted", processedAt: "28 Apr 2026" },
  { entity: "HVSG", month: "Apr 2026", employees: 168, gross:    948_000, net:    762_000, ccy: "SGD", status: "posted", processedAt: "28 Apr 2026" },
  { entity: "HVHK", month: "Apr 2026", employees: 84,  gross:    920_000, net:    782_000, ccy: "HKD", status: "posted", processedAt: "28 Apr 2026" },
  { entity: "HVAU", month: "Apr 2026", employees: 142, gross: 1_680_000, net: 1_140_000, ccy: "AUD", status: "posted", processedAt: "28 Apr 2026" },
  { entity: "HVIN", month: "Apr 2026", employees: 464, gross: 32_400_000, net: 26_180_000, ccy: "INR", status: "posted", processedAt: "28 Apr 2026" },
  { entity: "HVPH", month: "May 2026", employees: 414, gross: 18_540_000, net: 15_080_000, ccy: "PHP", status: "in-progress", processedAt: "Processing — 9/14 steps" },
  { entity: "HVSG", month: "May 2026", employees: 168, gross:    948_000, net:    762_000, ccy: "SGD", status: "draft", processedAt: "—" },
]
const PAYROLL_KPIS = {
  totalEmployees: 1270,
  totalGrossUsdM: 7.42,
  bonusPoolUsd: 880_000,
  cpfContribUsd: 124_800,
  taxWithheldUsd: 1_840_000,
}

/* ─── ATTENDANCE ─────────────────────────────────────────────────── */
const ATTENDANCE_TODAY = [
  /* Entity-level rollup */
  { entity: "HVPH", expected: 412, present: 384, remote: 12, late: 8, absent: 8,   onLeave: 24, source: "Hikvision Biometric" },
  { entity: "HVSG", expected: 168, present: 152, remote: 8,  late: 4, absent: 4,   onLeave: 12, source: "MS Teams Shifts" },
  { entity: "HVHK", expected: 84,  present: 76,  remote: 4,  late: 2, absent: 2,   onLeave: 4,  source: "Dahua Biometric" },
  { entity: "HVAU", expected: 142, present: 128, remote: 22, late: 1, absent: 13,  onLeave: 18, source: "MS Teams Shifts" },
  { entity: "HVIN", expected: 464, present: 412, remote: 18, late: 14, absent: 38, onLeave: 32, source: "Hikvision Biometric" },
]

const ATTENDANCE_RECENT = [
  /* Most-recent punches */
  { who: "Romulo Cruz",  initials: "RC", entity: "HVPH", action: "Punch IN",  ts: "06:42", source: "Hikvision · Manila Gate B", anomaly: false },
  { who: "Daniel Reyes", initials: "DR", entity: "HVPH", action: "Punch IN",  ts: "07:15", source: "Cenora App GPS",          anomaly: false },
  { who: "Karla Mendoza", initials: "KM", entity: "HVPH", action: "Punch OUT", ts: "Yesterday 18:30", source: "Hikvision", anomaly: false },
  { who: "Mason Pham",   initials: "MP", entity: "HVAU", action: "Punch IN",  ts: "09:08", source: "Cenora App GPS · 3km from office", anomaly: true },
  { who: "Lim Wei Ming", initials: "LW", entity: "HVSG", action: "Punch IN",  ts: "08:22", source: "MS Teams Shifts",          anomaly: false },
  { who: "Anand Kumar",  initials: "AK", entity: "HVIN", action: "Punch IN",  ts: "08:18 IST", source: "Hikvision · Mumbai",   anomaly: false },
  { who: "Priya Iyer",   initials: "PI", entity: "HVIN", action: "Punch IN",  ts: "09:48 IST", source: "Cenora App GPS",        anomaly: false },
  { who: "Eric Wong",    initials: "EW", entity: "HVHK", action: "Punch OUT", ts: "Yesterday 19:14", source: "Dahua",  anomaly: false },
]

/* ─── HR CASES ──────────────────────────────────────────────────── */
const HR_CASES = [
  { id: "CASE-088", type: "Grievance",       severity: "high",   summary: "Reported conflict between team members in HVIN Mumbai team",   reporter: "Anonymous",  entity: "HVIN", assignedTo: "Sofia M.", status: "investigation", openedDaysAgo: 3 },
  { id: "CASE-087", type: "Compensation",    severity: "med",    summary: "Question on overtime calculation for shift workers · Apr cycle", reporter: "Romulo Cruz", entity: "HVPH", assignedTo: "Sofia M.", status: "in-progress",   openedDaysAgo: 5 },
  { id: "CASE-086", type: "Policy",          severity: "low",    summary: "Clarification on dependent care benefit eligibility",              reporter: "Karla Mendoza", entity: "HVPH", assignedTo: "Anya R.", status: "resolved",       openedDaysAgo: 8 },
  { id: "CASE-085", type: "Performance",     severity: "med",    summary: "Performance improvement plan for warehouse associate (PIP)",       reporter: "Daniel Reyes", entity: "HVPH", assignedTo: "Sofia M.", status: "in-progress",     openedDaysAgo: 12 },
  { id: "CASE-084", type: "Harassment",      severity: "high",   summary: "Allegation under review — investigation per policy",             reporter: "Confidential", entity: "HVSG", assignedTo: "Legal · M.K.", status: "investigation",  openedDaysAgo: 14 },
  { id: "CASE-083", type: "Compensation",    severity: "low",    summary: "Promotion request review — Senior Engineer track",               reporter: "Vanessa Lim", entity: "HVSG", assignedTo: "Sofia M.", status: "resolved",        openedDaysAgo: 18 },
]

// SANDBOX
Object.assign(globalThis as any, {
  RECRUITMENT_REQS, RECRUITMENT_CANDIDATES,
  PERF_CYCLE, PERF_REVIEWS, PERF_TOP_FLAGS,
  TRAINING_PROGRAMS,
  PAYROLL_RUNS, PAYROLL_KPIS,
  ATTENDANCE_TODAY, ATTENDANCE_RECENT,
  HR_CASES,
})

})();/*__IIFE_WRAP_END__*/

/* ═════ apps/web/lib/mock/support.tsx ═════ */
;/*__IIFE_WRAP_START__*/(function(){
/**
 * ============================================================================
 * apps/web/lib/mock/support.tsx
 * ----------------------------------------------------------------------------
 * Customer Support mock — tickets across channels, queues, agents, SLA tiers,
 * and a small KB. Tied to existing demo customers (Globe, Metro Retail, etc.)
 * and cross-linked to PO / IR / INV records from the Procurement & Finance
 * mocks for realism.
 * ============================================================================
 */

/* ─── Channels ─────────────────────────────────────────────────────── */
type Channel = "email" | "portal" | "chat" | "phone" | "whatsapp"
const CH_LABEL: Record<Channel, string> = {
  email: "Email", portal: "Web portal", chat: "Live chat", phone: "Phone", whatsapp: "WhatsApp",
}
const CH_ICON: Record<Channel, string> = {
  email: "mail", portal: "globe", chat: "message", phone: "phone", whatsapp: "message",
}

/* ─── Queues ───────────────────────────────────────────────────────── */
interface SupportQueue {
  id: string
  label: string
  blurb: string
  open: number
  pending: number
  breached: number
  firstResponseTargetMin: number   /* SLA commit */
  resolveTargetHours: number
  compliancePct: number
}

const SUPPORT_QUEUES: SupportQueue[] = [
  { id: "billing",   label: "Billing & Invoicing",  blurb: "Invoice disputes, payments, credit memos", open: 12, pending: 4, breached: 1, firstResponseTargetMin: 60,  resolveTargetHours: 24, compliancePct: 96.1 },
  { id: "delivery",  label: "Order & Delivery",     blurb: "Order status, lead times, deliveries",     open: 18, pending: 3, breached: 2, firstResponseTargetMin: 30,  resolveTargetHours: 12, compliancePct: 92.4 },
  { id: "returns",   label: "Returns & Warranty",   blurb: "RMAs, defects, replacements",              open: 9,  pending: 5, breached: 0, firstResponseTargetMin: 120, resolveTargetHours: 72, compliancePct: 98.0 },
  { id: "technical", label: "Technical Support",    blurb: "Product configuration & break-fix",        open: 14, pending: 2, breached: 3, firstResponseTargetMin: 30,  resolveTargetHours: 8,  compliancePct: 89.2 },
  { id: "account",   label: "Account Management",   blurb: "Pricing, contracts, escalations",          open: 5,  pending: 1, breached: 0, firstResponseTargetMin: 240, resolveTargetHours: 48, compliancePct: 99.0 },
  { id: "onboarding", label: "Customer Onboarding", blurb: "New customer setup, first-order help",     open: 4,  pending: 0, breached: 0, firstResponseTargetMin: 120, resolveTargetHours: 48, compliancePct: 100  },
]

/* ─── Agents ───────────────────────────────────────────────────────── */
interface SupportAgent {
  initials: string
  name: string
  tone: any
  role: string
  queues: string[]                 /* queue ids they cover */
  openLoad: number                 /* current assigned + open */
  todayResolved: number
  csatRolling: number              /* % positive last 30d */
  status: "online" | "away" | "off"
}
const SUPPORT_AGENTS: SupportAgent[] = [
  { initials: "SM", name: "Sofia M.",  tone: "amber", role: "Customer Support Lead",     queues: ["billing", "account", "technical"],  openLoad: 7,  todayResolved: 12, csatRolling: 96.4, status: "online" },
  { initials: "OP", name: "Olivia P.", tone: "amber", role: "Senior Support Specialist", queues: ["delivery", "returns", "technical"], openLoad: 9,  todayResolved: 14, csatRolling: 94.1, status: "online" },
  { initials: "MR", name: "Maya R.",   tone: "blue",  role: "Support Specialist",        queues: ["billing", "delivery"],              openLoad: 6,  todayResolved: 9,  csatRolling: 92.8, status: "online" },
  { initials: "CB", name: "Carlos B.", tone: "blue",  role: "Support Specialist",        queues: ["technical", "returns"],             openLoad: 5,  todayResolved: 8,  csatRolling: 95.0, status: "online" },
  { initials: "NT", name: "Niko T.",   tone: "teal",  role: "Support Agent",             queues: ["delivery", "onboarding"],           openLoad: 4,  todayResolved: 7,  csatRolling: 91.2, status: "away" },
  { initials: "RP", name: "Rina P.",   tone: "teal",  role: "Support Agent",             queues: ["billing", "account"],               openLoad: 3,  todayResolved: 6,  csatRolling: 93.7, status: "online" },
  { initials: "AI", name: "Cenora AI", tone: "ink",   role: "Auto-resolve · Tier 0",     queues: ["billing", "delivery", "returns", "technical", "onboarding"], openLoad: 0, todayResolved: 38, csatRolling: 88.4, status: "online" },
]

/* ─── Ticket message thread shape ──────────────────────────────────── */
interface TicketMessage {
  from: string
  initials: string
  tone: any
  role: "customer" | "agent" | "ai" | "system"
  time: string                     /* "Apr 18 · 09:31" */
  body: string
  internal?: boolean               /* internal note, not customer-visible */
  attachments?: { name: string; size: string }[]
}

interface SupportTicket {
  id: string
  subject: string
  channel: Channel
  queue: string                    /* queue id */
  priority: "P1" | "P2" | "P3"
  status: "new" | "open" | "pending" | "on-hold" | "resolved" | "closed"
  customer: { name: string; initials: string; tone: any; tier: "Enterprise" | "Business" | "Starter"; contact: string }
  assignee?: { name: string; initials: string; tone: any }
  entity: "HVPH" | "HVSG" | "HVHK" | "HVAU" | "HVIN"
  createdAt: string
  lastUpdated: string
  firstResponse?: string           /* "1h 24m" or undefined if not yet */
  slaState: "on-track" | "at-risk" | "breached"
  resolveDueIn: string             /* "in 2h 14m" / "overdue 18m" */
  tags: string[]
  sentiment: "positive" | "neutral" | "negative"
  csat?: 1 | 2 | 3 | 4 | 5         /* post-resolve survey */
  linkedDocs?: { type: string; id: string }[]
  messages: TicketMessage[]
}

/* ─── Tickets (the heart of the demo) ──────────────────────────────── */
const SUPPORT_TICKETS: SupportTicket[] = [

  /* ── P1 BREACHED — top of inbox ─────────────────────────────────── */
  {
    id: "TKT-2026-1418",
    subject: "POS terminals offline at 4 stores since 06:30",
    channel: "phone",
    queue: "technical",
    priority: "P1",
    status: "open",
    customer: { name: "Metro Retail Chain", initials: "MR", tone: "ink", tier: "Enterprise", contact: "Janine Tan · IT Director" },
    assignee: { name: "Carlos B.", initials: "CB", tone: "blue" },
    entity: "HVPH",
    createdAt: "Apr 18 · 06:42",
    lastUpdated: "Apr 18 · 09:14",
    firstResponse: "8m",
    slaState: "breached",
    resolveDueIn: "overdue 1h 14m",
    tags: ["POS-T4", "outage", "multi-site"],
    sentiment: "negative",
    linkedDocs: [
      { type: "IR",  id: "IR-HVPH-1001" },
      { type: "FJ",  id: "FJ-2026-0418-10" },
      { type: "PO",  id: "PO-HVPH-1089" },
    ],
    messages: [
      { from: "Janine Tan",  initials: "JT", tone: "ink",   role: "customer", time: "Apr 18 · 06:42", body: "Four of our Pasig, Ortigas, Cubao and Makati stores cannot complete sales — POS-T4 terminals stuck on the boot screen. Reboot does not help. We are losing roughly ₱45,000/hour of revenue per store. Need someone on the phone NOW." },
      { from: "Carlos B.",   initials: "CB", tone: "blue",  role: "agent",    time: "Apr 18 · 06:50", body: "Hi Janine — I have the priority escalation. Confirming the 4 affected stores. We pushed firmware 2.4.0 last night across the POS fleet; rolling back via OTA. ETA 25 min." },
      { from: "Cenora AI",   initials: "AI", tone: "ink",   role: "ai",       time: "Apr 18 · 06:51", body: "Likely root cause: firmware 2.4.0 introduced a TLS handshake regression with the payment gateway when device clock drift exceeds 90 seconds. Suggested KB: KB-POS-021 (firmware rollback)." , internal: true },
      { from: "Carlos B.",   initials: "CB", tone: "blue",  role: "agent",    time: "Apr 18 · 07:18", body: "Rollback pushed to 18 of 28 terminals. The 4 stuck stores are 4G-only and need a manual reset — Field Service is dispatching Joel D. now (job FJ-2026-0418-10, ETA 35 min Pasig first)." },
      { from: "Janine Tan",  initials: "JT", tone: "ink",   role: "customer", time: "Apr 18 · 08:54", body: "Pasig is back up. Ortigas tech says he cannot get the SIM to register. Can someone call the SIM vendor on our behalf?" },
      { from: "Sofia M.",    initials: "SM", tone: "amber", role: "agent",    time: "Apr 18 · 09:14", body: "Escalating to Globe enterprise account manager. We will own the SIM vendor handoff so you do not have to chase. Bridge call in 10 min, will dial you in." , internal: false },
    ],
  },

  /* ── P1 at-risk ─────────────────────────────────────────────────── */
  {
    id: "TKT-2026-1417",
    subject: "Cold-storage controller alarm — refrigerant low",
    channel: "whatsapp",
    queue: "technical",
    priority: "P1",
    status: "open",
    customer: { name: "Prime Hotels Group", initials: "PH", tone: "amber", tier: "Enterprise", contact: "Marco S. · Facilities" },
    assignee: { name: "Olivia P.", initials: "OP", tone: "amber" },
    entity: "HVPH",
    createdAt: "Apr 18 · 08:11",
    lastUpdated: "Apr 18 · 09:02",
    firstResponse: "12m",
    slaState: "at-risk",
    resolveDueIn: "in 1h 48m",
    tags: ["cold-storage", "SLA-credit-risk"],
    sentiment: "negative",
    linkedDocs: [
      { type: "FJ",  id: "FJ-2026-0418-08" },
      { type: "RMA", id: "RMA-HVPH-0042" },
    ],
    messages: [
      { from: "Marco S.",   initials: "MS", tone: "amber", role: "customer", time: "Apr 18 · 08:11", body: "Refrigeration controller is reading 11°C — we have ~90 minutes before the seafood inventory is compromised. Need a technician on-site at Pasay by 09:30." },
      { from: "Olivia P.",  initials: "OP", tone: "amber", role: "agent",    time: "Apr 18 · 08:23", body: "Job dispatched (FJ-2026-0418-08). Crew is 38 min out. In the meantime please move perishables to the secondary unit if possible." },
      { from: "Marco S.",   initials: "MS", tone: "amber", role: "customer", time: "Apr 18 · 09:02", body: "Crew arrived. Confirming the diagnosis — compressor seal failure, replacing now." },
    ],
  },

  /* ── P2 new — billing ───────────────────────────────────────────── */
  {
    id: "TKT-2026-1416",
    subject: "Invoice INV-HVPH-0451 — VAT amount looks wrong",
    channel: "email",
    queue: "billing",
    priority: "P2",
    status: "new",
    customer: { name: "Globe Telecom", initials: "GT", tone: "amber", tier: "Enterprise", contact: "Rina Cruz · AP Manager" },
    entity: "HVPH",
    createdAt: "Apr 18 · 09:04",
    lastUpdated: "Apr 18 · 09:04",
    slaState: "on-track",
    resolveDueIn: "in 23h 56m",
    tags: ["VAT", "PH-tax"],
    sentiment: "neutral",
    linkedDocs: [
      { type: "INV", id: "INV-HVPH-0451" },
      { type: "PO",  id: "PO-HVPH-1089" },
    ],
    messages: [
      { from: "Rina Cruz",  initials: "RC", tone: "amber", role: "customer", time: "Apr 18 · 09:04", body: "Hi team — our AP system reads VAT of ₱48,214 on invoice INV-HVPH-0451 but our PO line items only sum to ₱402,000 net. Expected VAT 12% = ₱48,240. Off by ₱26. Could you check?" },
      { from: "Cenora AI",  initials: "AI", tone: "ink",   role: "ai",       time: "Apr 18 · 09:05", body: "Detected rounding mismatch on freight line item (rounded per-line before sum). Suggested action: reissue credit memo CM-HVPH-0091 for ₱26 — auto-prepared. Suggested KB: KB-BILL-007.", internal: true },
    ],
  },

  /* ── P2 pending customer ────────────────────────────────────────── */
  {
    id: "TKT-2026-1411",
    subject: "Delivery delayed — Mumbai consignment XR-1142",
    channel: "portal",
    queue: "delivery",
    priority: "P2",
    status: "pending",
    customer: { name: "Reliance Industrial", initials: "RI", tone: "blue", tier: "Enterprise", contact: "Aman P. · Procurement" },
    assignee: { name: "Niko T.", initials: "NT", tone: "teal" },
    entity: "HVIN",
    createdAt: "Apr 17 · 16:42",
    lastUpdated: "Apr 18 · 07:55",
    firstResponse: "44m",
    slaState: "on-track",
    resolveDueIn: "in 4h 5m",
    tags: ["customs", "IN-cross-border"],
    sentiment: "neutral",
    linkedDocs: [
      { type: "TO", id: "TO-HVIN-2241" },
    ],
    messages: [
      { from: "Aman P.",  initials: "AP", tone: "blue",  role: "customer", time: "Apr 17 · 16:42", body: "Where is consignment XR-1142? Promised window was today by 14:00 IST." },
      { from: "Niko T.",  initials: "NT", tone: "teal",  role: "agent",    time: "Apr 17 · 17:26", body: "Held at Nhava Sheva customs since 13:10 IST — paperwork review (Form-13 missing GSTIN). Re-filed at 16:55. Expected release tomorrow 09:00 IST. Will confirm on release." },
      { from: "Aman P.",  initials: "AP", tone: "blue",  role: "customer", time: "Apr 18 · 07:55", body: "Acknowledged — please make sure it is on the Bandra-Kurla truck, not the Thane route." },
    ],
  },

  /* ── P2 returns ─────────────────────────────────────────────────── */
  {
    id: "TKT-2026-1409",
    subject: "Warranty claim — solar inverter batch SI-0418 (DOA)",
    channel: "email",
    queue: "returns",
    priority: "P2",
    status: "open",
    customer: { name: "Pacific Solar PH", initials: "PS", tone: "blue", tier: "Business", contact: "Karla B. · Operations" },
    assignee: { name: "Olivia P.", initials: "OP", tone: "amber" },
    entity: "HVPH",
    createdAt: "Apr 17 · 11:08",
    lastUpdated: "Apr 18 · 08:30",
    firstResponse: "31m",
    slaState: "on-track",
    resolveDueIn: "in 1d 14h",
    tags: ["warranty", "DOA", "batch-SI-0418"],
    sentiment: "neutral",
    linkedDocs: [
      { type: "RMA", id: "RMA-HVPH-0041" },
      { type: "PO",  id: "PO-HVPH-1071" },
    ],
    messages: [
      { from: "Karla B.",  initials: "KB", tone: "blue",  role: "customer", time: "Apr 17 · 11:08", body: "Six of the 24 inverters shipped on PO-HVPH-1071 are DOA. Serials in attachment. Need replacements before Friday." },
      { from: "Olivia P.", initials: "OP", tone: "amber", role: "agent",    time: "Apr 17 · 11:39", body: "RMA-HVPH-0041 opened. Inspection at Calamba warehouse confirmed batch-level firmware issue. Cross-shipping 6 replacement units from Manila DC, ETA Thursday EOD." },
      { from: "Karla B.",  initials: "KB", tone: "blue",  role: "customer", time: "Apr 18 · 08:30", body: "Thank you. Please mark serials clearly so we know which to install." },
    ],
  },

  /* ── P3 routine ─────────────────────────────────────────────────── */
  {
    id: "TKT-2026-1404",
    subject: "How to add a new shipping address in the portal?",
    channel: "chat",
    queue: "onboarding",
    priority: "P3",
    status: "resolved",
    customer: { name: "Filinvest Land", initials: "FL", tone: "teal", tier: "Business", contact: "Mike L. · Project Buyer" },
    assignee: { name: "Cenora AI", initials: "AI", tone: "ink" },
    entity: "HVPH",
    createdAt: "Apr 18 · 08:48",
    lastUpdated: "Apr 18 · 08:52",
    firstResponse: "8s",
    slaState: "on-track",
    resolveDueIn: "—",
    tags: ["self-serve", "auto-resolved"],
    sentiment: "positive",
    csat: 5,
    messages: [
      { from: "Mike L.",  initials: "ML", tone: "teal", role: "customer", time: "Apr 18 · 08:48", body: "Hi — how do I add a new shipping address to our account?" },
      { from: "Cenora AI", initials: "AI", tone: "ink",  role: "ai",       time: "Apr 18 · 08:48", body: "Hi Mike! In the portal, head to **Account → Addresses → Add new**. You can also set the new address as default for future orders. Article: KB-ACCT-014.\n\nI marked this resolved — flag it back open if anything is unclear." },
      { from: "Mike L.",  initials: "ML", tone: "teal", role: "customer", time: "Apr 18 · 08:52", body: "Got it, thanks!" },
    ],
  },

  /* ── More compact tickets to populate the inbox ───────────────── */
  { id: "TKT-2026-1415", subject: "Request: extended payment terms NET-45 for Q2",                  channel: "email",    queue: "account",   priority: "P3", status: "open",     customer: { name: "Cebu Pacific",      initials: "CP",  tone: "amber", tier: "Enterprise", contact: "Pia R. · Sourcing"      }, assignee: { name: "Sofia M.",  initials: "SM", tone: "amber" }, entity: "HVPH", createdAt: "Apr 18 · 08:31", lastUpdated: "Apr 18 · 08:31", firstResponse: "—",   slaState: "on-track", resolveDueIn: "in 1d 23h", tags: ["contract", "credit"],     sentiment: "neutral",  messages: [{ from: "Pia R.", initials: "PR", tone: "amber", role: "customer", time: "Apr 18 · 08:31", body: "Hi Sofia — would you be open to NET-45 terms for our Q2 spend? Volumes are tracking +18%." }] },
  { id: "TKT-2026-1414", subject: "Bill of lading missing on TO-HVSG-1180",                          channel: "email",    queue: "delivery",  priority: "P2", status: "open",     customer: { name: "OCBC Bank",         initials: "OC",  tone: "blue",  tier: "Enterprise", contact: "Tan W. · Logistics"     }, assignee: { name: "Maya R.",   initials: "MR", tone: "blue"  }, entity: "HVSG", createdAt: "Apr 18 · 08:02", lastUpdated: "Apr 18 · 08:48", firstResponse: "26m", slaState: "on-track", resolveDueIn: "in 11h 10m", tags: ["BOL", "SG"],            sentiment: "neutral",  messages: [{ from: "Tan W.",  initials: "TW", tone: "blue",  role: "customer", time: "Apr 18 · 08:02", body: "Driver showed up without a BOL. We need it stamped before unloading at the data center." }, { from: "Maya R.",  initials: "MR", tone: "blue", role: "agent", time: "Apr 18 · 08:28", body: "Couriering a signed PDF to your inbox in 10 min and the original by motorcycle within the hour. Apologies."  }] },
  { id: "TKT-2026-1413", subject: "Quote SLA — turnaround on RFQ for HVAC retrofit?",                channel: "portal",   queue: "account",   priority: "P3", status: "pending",  customer: { name: "DBS Bank",          initials: "DB",  tone: "blue",  tier: "Enterprise", contact: "Ling K. · Procurement"  }, assignee: { name: "Rina P.",   initials: "RP", tone: "teal"  }, entity: "HVSG", createdAt: "Apr 18 · 07:48", lastUpdated: "Apr 18 · 08:16", firstResponse: "28m", slaState: "on-track", resolveDueIn: "in 1d 16h",  tags: ["RFQ", "HVAC"],          sentiment: "neutral",  messages: [{ from: "Ling K.",  initials: "LK", tone: "blue", role: "customer", time: "Apr 18 · 07:48", body: "Hi — when can we expect the RFQ response for Tower 3 retrofit?" }, { from: "Rina P.", initials: "RP", tone: "teal", role: "agent", time: "Apr 18 · 08:16", body: "Engineering is on it — committed delivery Friday EOD. Will share interim cost band tomorrow."  }] },
  { id: "TKT-2026-1412", subject: "Where is my refund? RMA-HVHK-0019 closed 2 weeks ago",            channel: "phone",    queue: "billing",   priority: "P2", status: "open",     customer: { name: "Cathay Logistics", initials: "CL",  tone: "amber", tier: "Business",   contact: "Jeremy W. · Finance"   }, assignee: { name: "Rina P.",   initials: "RP", tone: "teal"  }, entity: "HVHK", createdAt: "Apr 18 · 07:31", lastUpdated: "Apr 18 · 08:04", firstResponse: "33m", slaState: "at-risk",  resolveDueIn: "in 18h 22m",   tags: ["refund", "HK"],         sentiment: "negative", messages: [{ from: "Jeremy W.", initials: "JW", tone: "amber", role: "customer", time: "Apr 18 · 07:31", body: "The credit memo was approved on Apr 4 but we have not seen the HKD 18,400 land. Where is it?" }, { from: "Rina P.", initials: "RP", tone: "teal", role: "agent", time: "Apr 18 · 08:04", body: "Apologies — the bank-out file was stuck behind month-end. Pushed for release today. Confirming reference in 2 hours."  }] },
  { id: "TKT-2026-1410", subject: "API auth tokens expiring nightly — integration breaking",        channel: "email",    queue: "technical", priority: "P2", status: "open",     customer: { name: "TechNet Solutions", initials: "TN",  tone: "teal",  tier: "Business",   contact: "Greg L. · Engineering" }, assignee: { name: "Carlos B.", initials: "CB", tone: "blue"  }, entity: "HVPH", createdAt: "Apr 17 · 14:08", lastUpdated: "Apr 18 · 07:11", firstResponse: "1h 4m", slaState: "on-track", resolveDueIn: "in 50m",     tags: ["API", "integration"],   sentiment: "neutral",  messages: [{ from: "Greg L.",  initials: "GL", tone: "teal",  role: "customer", time: "Apr 17 · 14:08", body: "Service-account token life is set to 24h. We need long-lived for our middleware. Can you extend or move us to OIDC?" }, { from: "Carlos B.", initials: "CB", tone: "blue", role: "agent", time: "Apr 17 · 15:12", body: "OIDC rollout is in beta — we can move TechNet onto the long-lived audience scope today. ETA fix 2h."  }] },
  { id: "TKT-2026-1408", subject: "Add second authorized signatory on account",                      channel: "email",    queue: "account",   priority: "P3", status: "resolved", customer: { name: "Maybank PH",        initials: "MB",  tone: "blue",  tier: "Business",   contact: "Cris G. · Treasury"   }, assignee: { name: "Sofia M.",  initials: "SM", tone: "amber" }, entity: "HVPH", createdAt: "Apr 17 · 09:18", lastUpdated: "Apr 17 · 13:45", firstResponse: "22m", slaState: "on-track", resolveDueIn: "—",          tags: ["KYC"],                  sentiment: "positive", csat: 5, messages: [{ from: "Cris G.",  initials: "CG", tone: "blue",  role: "customer", time: "Apr 17 · 09:18", body: "Please add Mara Reyes as a second signatory. Letter attached." }, { from: "Sofia M.", initials: "SM", tone: "amber", role: "agent", time: "Apr 17 · 13:45", body: "Done — Mara is added. Confirmation email out. KYC closed."  }] },
  { id: "TKT-2026-1407", subject: "Faulty pallet jack — bent fork tine",                              channel: "whatsapp", queue: "returns",   priority: "P3", status: "open",     customer: { name: "Apex Kitchen Supplies", initials: "AK", tone: "amber", tier: "Business",   contact: "Boy L. · Warehouse"    }, assignee: { name: "Olivia P.", initials: "OP", tone: "amber" }, entity: "HVPH", createdAt: "Apr 17 · 08:32", lastUpdated: "Apr 17 · 14:01", firstResponse: "1h 18m", slaState: "on-track", resolveDueIn: "in 2d 6h",  tags: ["warranty"],             sentiment: "neutral",  messages: [{ from: "Boy L.",  initials: "BL", tone: "amber", role: "customer", time: "Apr 17 · 08:32", body: "One of the PJ-2T pallet jacks delivered last week has a bent tine. Photos attached." }, { from: "Olivia P.", initials: "OP", tone: "amber", role: "agent", time: "Apr 17 · 09:50", body: "Approved a no-questions replacement. New unit out tomorrow. Old unit pickup attached to the same dispatch."  }] },
  { id: "TKT-2026-1406", subject: "Renewal — 1-yr managed services for Tower 3",                     channel: "portal",   queue: "account",   priority: "P3", status: "open",     customer: { name: "PH National Bank",  initials: "PNB", tone: "blue",  tier: "Enterprise", contact: "Reggie U. · CRE"        }, assignee: { name: "Sofia M.",  initials: "SM", tone: "amber" }, entity: "HVPH", createdAt: "Apr 17 · 14:02", lastUpdated: "Apr 17 · 18:11", firstResponse: "1h 32m", slaState: "on-track", resolveDueIn: "in 3d 4h",  tags: ["renewal", "MSA"],       sentiment: "positive", messages: [{ from: "Reggie U.", initials: "RU", tone: "blue", role: "customer", time: "Apr 17 · 14:02", body: "Ready to renew for another year. Same scope plus add the new 14F build-out." }] },
  { id: "TKT-2026-1405", subject: "Onboarding — first PO with HVAU, courier address",                channel: "chat",     queue: "onboarding", priority: "P3", status: "open",     customer: { name: "BHP Coal Australia", initials: "BHP", tone: "amber", tier: "Enterprise", contact: "Liam K. · Procurement" }, assignee: { name: "Niko T.",   initials: "NT", tone: "teal"  }, entity: "HVAU", createdAt: "Apr 17 · 11:20", lastUpdated: "Apr 17 · 16:28", firstResponse: "11m", slaState: "on-track", resolveDueIn: "in 1d 8h",   tags: ["new-customer"],         sentiment: "positive", messages: [{ from: "Liam K.",  initials: "LK", tone: "amber", role: "customer", time: "Apr 17 · 11:20", body: "Hi Niko — we are placing our first PO with HVAU. Where do we send delivery instructions?" }] },
  { id: "TKT-2026-1403", subject: "GST exemption certificate not on file",                            channel: "email",    queue: "billing",   priority: "P3", status: "on-hold",  customer: { name: "Indian Railways (RVNL)", initials: "IR", tone: "blue", tier: "Enterprise", contact: "Kavita S. · Finance"   }, assignee: { name: "Maya R.",   initials: "MR", tone: "blue"  }, entity: "HVIN", createdAt: "Apr 16 · 15:30", lastUpdated: "Apr 17 · 10:12", firstResponse: "2h 12m", slaState: "on-track", resolveDueIn: "in 4d",     tags: ["GST", "IN"],            sentiment: "neutral",  messages: [{ from: "Kavita S.", initials: "KS", tone: "blue", role: "customer", time: "Apr 16 · 15:30", body: "Our exemption certificate copy needs to be on file. Attached." }, { from: "Maya R.", initials: "MR", tone: "blue", role: "agent", time: "Apr 16 · 17:42", body: "Received. We are awaiting clarification from your finance lead on validity range — will resume once we have it." }] },
  { id: "TKT-2026-1402", subject: "Driver no-show — Ortigas pickup window 06:00",                     channel: "phone",    queue: "delivery",  priority: "P1", status: "resolved", customer: { name: "Metro Retail Chain", initials: "MR", tone: "ink",   tier: "Enterprise", contact: "Boy A. · DC Manager"   }, assignee: { name: "Olivia P.", initials: "OP", tone: "amber" }, entity: "HVPH", createdAt: "Apr 16 · 06:08", lastUpdated: "Apr 16 · 07:55", firstResponse: "3m",  slaState: "on-track", resolveDueIn: "—",          tags: ["fleet", "no-show"],     sentiment: "negative", csat: 3, messages: [{ from: "Boy A.",  initials: "BA", tone: "ink",   role: "customer", time: "Apr 16 · 06:08", body: "Driver did not show. Dock is held." }, { from: "Olivia P.", initials: "OP", tone: "amber", role: "agent", time: "Apr 16 · 06:11", body: "Dispatched a backup vehicle. ETA 26 min. Issuing SLA credit." }] },
  { id: "TKT-2026-1401", subject: "Praise — Carlos solved our DNS issue at 11pm",                     channel: "portal",   queue: "technical", priority: "P3", status: "closed",   customer: { name: "Globe Telecom",     initials: "GT",  tone: "amber", tier: "Enterprise", contact: "Anna P. · NetOps"      }, assignee: { name: "Carlos B.", initials: "CB", tone: "blue"  }, entity: "HVPH", createdAt: "Apr 15 · 23:02", lastUpdated: "Apr 16 · 09:14", firstResponse: "4m",  slaState: "on-track", resolveDueIn: "—",          tags: ["compliment"],           sentiment: "positive", csat: 5, messages: [{ from: "Anna P.", initials: "AP", tone: "amber", role: "customer", time: "Apr 15 · 23:02", body: "Just a note — Carlos stayed on with us until past midnight to fix our DNS forwarding. Above and beyond." }] },
]

const TKT_BY_ID: Record<string, SupportTicket> = Object.fromEntries(SUPPORT_TICKETS.map(t => [t.id, t]))
const SUPPORT_QUEUE_BY_ID: Record<string, SupportQueue> = Object.fromEntries(SUPPORT_QUEUES.map(q => [q.id, q]))

/* ─── KB articles ────────────────────────────────────────────────── */
interface KBArticle {
  id: string
  title: string
  category: string
  views30d: number
  deflections30d: number   /* tickets auto-resolved by AI citing this */
  helpfulPct: number
  updated: string          /* "3 days ago" */
  owner: { initials: string; name: string; tone: any }
}
const SUPPORT_KB: KBArticle[] = [
  { id: "KB-POS-021", title: "POS-T4 firmware rollback steps",                category: "Technical · POS",     views30d: 1842, deflections30d: 64, helpfulPct: 92, updated: "2 days ago",  owner: { initials: "CB", name: "Carlos B.", tone: "blue"  } },
  { id: "KB-BILL-007", title: "Reading VAT and EWT on PH invoices",            category: "Billing · PH",         views30d: 2104, deflections30d: 188, helpfulPct: 96, updated: "1 week ago",  owner: { initials: "SM", name: "Sofia M.",  tone: "amber" } },
  { id: "KB-ACCT-014", title: "Add shipping addresses in the customer portal", category: "Account · Portal",     views30d: 968,  deflections30d: 142, helpfulPct: 98, updated: "5 days ago",  owner: { initials: "NT", name: "Niko T.",   tone: "teal"  } },
  { id: "KB-RET-002",  title: "Open a warranty RMA and ship return labels",    category: "Returns",              views30d: 1330, deflections30d: 91,  helpfulPct: 94, updated: "3 days ago",  owner: { initials: "OP", name: "Olivia P.", tone: "amber" } },
  { id: "KB-DLV-009",  title: "PH customs paperwork checklist (HVPH ↔ HVIN)", category: "Delivery · Cross-border", views30d: 614, deflections30d: 38,  helpfulPct: 88, updated: "1 day ago",   owner: { initials: "MR", name: "Maya R.",   tone: "blue"  } },
  { id: "KB-API-001",  title: "Long-lived service tokens via OIDC audience",  category: "Technical · API",      views30d: 412,  deflections30d: 12,  helpfulPct: 81, updated: "4 days ago",  owner: { initials: "CB", name: "Carlos B.", tone: "blue"  } },
  { id: "KB-ONB-003",  title: "First PO workflow — Australia (HVAU)",         category: "Onboarding",           views30d: 248,  deflections30d: 18,  helpfulPct: 100, updated: "today",       owner: { initials: "NT", name: "Niko T.",   tone: "teal"  } },
]

/* ─── Top-level KPIs (for dashboard) ─────────────────────────────── */
const SUPPORT_KPIS = {
  openTickets: SUPPORT_TICKETS.filter(t => !["resolved", "closed"].includes(t.status)).length,
  newToday: 14,
  resolvedToday: 22,
  firstResponseMedian: "27 min",
  firstResponseTrend: "+2 min",        /* vs 7-day avg */
  firstResponseTrendDir: "down",       /* worse */
  csat: 94.2,                          /* % positive last 30d */
  csatTrend: "+0.8pp",
  csatTrendDir: "up",
  slaCompliance: 95.7,
  slaTrend: "-0.6pp",
  slaTrendDir: "down",
  aiDeflection: 38,                    /* tickets auto-resolved today */
  aiDeflectionPctOfNew: 28.5,
  breached: SUPPORT_TICKETS.filter(t => t.slaState === "breached").length,
  atRisk: SUPPORT_TICKETS.filter(t => t.slaState === "at-risk").length,
}

/* 30-day inbound volume trend (for sparkline / area chart) — counts per day */
const SUPPORT_TREND_30D = [
  92, 88, 102, 99, 95, 78, 64,
  104, 110, 118, 121, 116, 88, 72,
  124, 132, 128, 134, 127, 99, 84,
  138, 142, 137, 141, 135, 108, 94, 132, 138,
]

/* CSAT distribution last 30d (1..5 stars) */
const SUPPORT_CSAT_DIST = [3, 4, 8, 22, 63]   /* % of responses */

// SANDBOX
Object.assign(globalThis as any, {
  SUPPORT_TICKETS, TKT_BY_ID, SUPPORT_QUEUES, SUPPORT_QUEUE_BY_ID,
  SUPPORT_AGENTS, SUPPORT_KB, SUPPORT_KPIS, SUPPORT_TREND_30D, SUPPORT_CSAT_DIST,
  CH_LABEL, CH_ICON,
})

})();/*__IIFE_WRAP_END__*/

/* ═════ apps/web/lib/mock/multi-entity.tsx ═════ */
;/*__IIFE_WRAP_START__*/(function(){
/**
 * ============================================================================
 * apps/web/lib/mock/multi-entity.tsx
 * ----------------------------------------------------------------------------
 * Multi-Entity module mock data — intercompany, eliminations, transfers, rules.
 *
 * The Consolidated Dashboard reuses ENTITIES from app-shell.tsx and the
 * mock finance numbers; this file adds the data unique to the multi-entity
 * module:
 *
 *   ICTxn           — intercompany transactions (matched / unmatched / disputed)
 *   ICElim          — elimination entries (revenue, AR/AP, profit-in-inventory)
 *   IETransfer      — inter-entity transfers (cash, inventory, fixed asset)
 *   ConsolRule      — consolidation rules (ownership %, FX policy, eliminations)
 *
 * FX rates intentionally NOT here — those stay in Finance core because
 * single-entity tenants still need FX.
 * ============================================================================
 */

interface ICTxn {
  id: string
  date: string
  fromEntity: string   /* code, e.g. HVPH */
  toEntity:   string
  doctype: "invoice" | "bill" | "service" | "loan" | "expense-recharge"
  reference: string
  description: string
  amount: number       /* in USD presentation currency */
  currency: string     /* local currency */
  amountLocal: number
  status: "matched" | "unmatched" | "disputed" | "pending"
  matchReference?: string  /* peer doc id if matched */
  flagReason?: string
}

interface ICElim {
  id: string
  category: "ic-revenue" | "ic-ar-ap" | "profit-in-inventory" | "investment-in-sub" | "dividends"
  label: string
  pair: string  /* "HVPH ↔ HVSG" */
  amount: number
  status: "auto" | "manual" | "needs-review"
  basis: string
  postedBy?: string
  postedAt?: string
}

interface IETransfer {
  id: string
  kind: "cash" | "inventory" | "fixed-asset" | "service-charge"
  date: string
  fromEntity: string
  toEntity: string
  amount: number
  currency: string
  fxRateUsed?: number
  description: string
  status: "draft" | "approved" | "posted" | "settled"
  approver?: string
}

interface ConsolRule {
  id: string
  scope: string  /* "HVPH", "APAC", "All entities" */
  category: "ownership" | "fx-policy" | "elimination" | "minority-interest" | "rollup"
  rule: string
  value: string
  effectiveFrom: string
  changedBy?: string
  changedAt?: string
}

interface SubsidiaryKPI {
  entityCode: string
  health: "good" | "watch" | "concern"
  revenueYTD: number  /* USD */
  netIncomeYTD: number
  closeStatus: "complete" | "in-progress" | "blocked"
  closeProgress: number  /* 0..100 */
  arOverdue: number
  apOverdue: number
  headcount: number
  flags: string[]   /* short alerts */
}

/* ─── INTERCOMPANY TRANSACTIONS ──────────────────────────────────────── */
const IC_TXNS: ICTxn[] = [
  { id: "ic-2026-0042", date: "Apr 18, 2026", fromEntity: "HVPH", toEntity: "HVSG", doctype: "service",       reference: "IC-INV-1042", description: "Management fee · Mar 2026",                       amount:  84_000, currency: "USD", amountLocal:  84_000, status: "matched",   matchReference: "BILL-HVSG-0421" },
  { id: "ic-2026-0043", date: "Apr 18, 2026", fromEntity: "HVHK", toEntity: "HVSG", doctype: "expense-recharge", reference: "IC-EXP-1043", description: "Shared APAC IT licensing recharge",              amount:  12_400, currency: "USD", amountLocal:  12_400, status: "matched",   matchReference: "BILL-HVSG-0418" },
  { id: "ic-2026-0044", date: "Apr 17, 2026", fromEntity: "HVSG", toEntity: "HVAU", doctype: "loan",          reference: "IC-LOAN-002",  description: "Intercompany working-capital loan tranche 2",     amount: 250_000, currency: "USD", amountLocal: 250_000, status: "matched",   matchReference: "BILL-HVAU-0220" },
  { id: "ic-2026-0045", date: "Apr 16, 2026", fromEntity: "HVPH", toEntity: "HVAU", doctype: "invoice",       reference: "IC-INV-1045", description: "Custom fabrication · 24 monoblock units",         amount:   4_320, currency: "USD", amountLocal:   4_320, status: "unmatched", flagReason: "Peer bill not yet booked in HVAU" },
  { id: "ic-2026-0046", date: "Apr 14, 2026", fromEntity: "HVIN", toEntity: "HVSG", doctype: "service",       reference: "IC-INV-1046", description: "Engineering services · 240h @ USD 55",            amount:  13_200, currency: "USD", amountLocal:  13_200, status: "matched",   matchReference: "BILL-HVSG-0414" },
  { id: "ic-2026-0047", date: "Apr 12, 2026", fromEntity: "HVPH", toEntity: "HVHK", doctype: "invoice",       reference: "IC-INV-1047", description: "Equipment rental · CNC platform Q2",              amount:  18_000, currency: "USD", amountLocal:  18_000, status: "disputed",  flagReason: "HVHK queries scope; awaiting Maria/Maya review" },
  { id: "ic-2026-0048", date: "Apr 11, 2026", fromEntity: "HVAU", toEntity: "HVPH", doctype: "bill",          reference: "IC-BILL-204", description: "Counter-charge · regional travel reimbursement",  amount:   2_640, currency: "USD", amountLocal:   2_640, status: "matched",   matchReference: "INV-HVPH-0089" },
  { id: "ic-2026-0049", date: "Apr 09, 2026", fromEntity: "HVSG", toEntity: "HVPH", doctype: "service",       reference: "IC-INV-1049", description: "APAC HR shared services · Mar 2026",              amount:  22_000, currency: "USD", amountLocal:  22_000, status: "matched",   matchReference: "BILL-HVPH-0314" },
  { id: "ic-2026-0050", date: "Apr 08, 2026", fromEntity: "HVIN", toEntity: "HVPH", doctype: "invoice",       reference: "IC-INV-1050", description: "Software license re-billing · Q2",                amount:   3_840, currency: "USD", amountLocal:   3_840, status: "pending",   flagReason: "Awaiting HVPH approval in workflow" },
  { id: "ic-2026-0051", date: "Apr 05, 2026", fromEntity: "HVPH", toEntity: "HVSG", doctype: "invoice",       reference: "IC-INV-1051", description: "Fabricated parts · custom rebar brackets",        amount:   9_600, currency: "USD", amountLocal:   9_600, status: "matched",   matchReference: "BILL-HVSG-0408" },
  { id: "ic-2026-0052", date: "Apr 02, 2026", fromEntity: "HVHK", toEntity: "HVAU", doctype: "loan",          reference: "IC-LOAN-003",  description: "Short-term loan · 90-day @ 4.2%",                amount: 100_000, currency: "USD", amountLocal: 100_000, status: "matched",   matchReference: "BILL-HVAU-0210" },
  { id: "ic-2026-0053", date: "Apr 01, 2026", fromEntity: "HVPH", toEntity: "HVIN", doctype: "expense-recharge", reference: "IC-EXP-1053", description: "Regional ERP rollout costs (Mar)",               amount:   6_900, currency: "USD", amountLocal:   6_900, status: "unmatched", flagReason: "Peer bill missing — chase HVIN finance" },
]

/* ─── ELIMINATIONS ───────────────────────────────────────────────────── */
const IC_ELIMS: ICElim[] = [
  { id: "el-001", category: "ic-revenue",        label: "IC management fees · Mar–Apr",          pair: "HVPH ↔ HVSG",  amount: 168_000, status: "auto",         basis: "Auto-eliminated against matched IC bill", postedBy: "system", postedAt: "Apr 19 · 02:14" },
  { id: "el-002", category: "ic-ar-ap",          label: "IC AR/AP balances · APAC",              pair: "All APAC",     amount: 412_800, status: "auto",         basis: "All matched intercompany invoices + bills",  postedBy: "system", postedAt: "Apr 19 · 02:14" },
  { id: "el-003", category: "profit-in-inventory", label: "Profit in HVPH→HVSG fabricated parts",  pair: "HVPH → HVSG",  amount:  18_400, status: "needs-review", basis: "32% intercompany markup on inventory held by HVSG at period end", postedBy: undefined, postedAt: undefined },
  { id: "el-004", category: "investment-in-sub", label: "Investment in HVPH (HVG)",             pair: "HVG → HVPH",    amount: 4_200_000, status: "manual",     basis: "100% ownership · cost method · last revalued Dec 2025", postedBy: "Maria A.", postedAt: "Apr 18 · 16:42" },
  { id: "el-005", category: "investment-in-sub", label: "Investment in HVSG (HVG)",             pair: "HVG → HVSG",    amount: 3_400_000, status: "manual",     basis: "100% ownership · cost method", postedBy: "Maria A.", postedAt: "Apr 18 · 16:42" },
  { id: "el-006", category: "investment-in-sub", label: "Investment in HVAU (HVG)",             pair: "HVG → HVAU",    amount: 2_100_000, status: "manual",     basis: "70% ownership · 30% minority interest", postedBy: "Maria A.", postedAt: "Apr 18 · 16:48" },
  { id: "el-007", category: "dividends",         label: "HVPH → HVG Q1 dividend",                pair: "HVPH → HVG",    amount:  240_000, status: "manual",     basis: "Declared Apr 12, paid Apr 15", postedBy: "Anil V.",  postedAt: "Apr 15 · 11:22" },
  { id: "el-008", category: "ic-ar-ap",          label: "IC loan balances · APS region",         pair: "HVSG ↔ HVAU",   amount:  500_000, status: "auto",       basis: "Working capital loan tranches 1+2", postedBy: "system",   postedAt: "Apr 19 · 02:14" },
]

/* ─── INTER-ENTITY TRANSFERS ─────────────────────────────────────────── */
const IE_TRANSFERS: IETransfer[] = [
  { id: "iet-2026-0024", kind: "cash",         date: "Apr 19, 2026", fromEntity: "HVSG", toEntity: "HVPH", amount: 180_000, currency: "PHP", fxRateUsed: 0.0177, description: "Q2 working capital top-up",                       status: "settled",  approver: "Anil V." },
  { id: "iet-2026-0025", kind: "inventory",    date: "Apr 18, 2026", fromEntity: "HVPH", toEntity: "HVAU", amount:  24_400, currency: "AUD", fxRateUsed: 0.6700, description: "Rebar brackets · 1,200 units · Tower B AU",       status: "posted",   approver: "Maya C."   },
  { id: "iet-2026-0026", kind: "service-charge", date: "Apr 18, 2026", fromEntity: "HVSG", toEntity: "HVPH", amount:  22_000, currency: "USD",                  description: "APAC HR shared services · Mar 2026",                status: "posted",   approver: "Sofia M." },
  { id: "iet-2026-0027", kind: "fixed-asset",  date: "Apr 14, 2026", fromEntity: "HVHK", toEntity: "HVPH", amount:  48_000, currency: "USD",                  description: "CNC platform transfer · NBV USD 48k",               status: "approved", approver: "Anil V." },
  { id: "iet-2026-0028", kind: "cash",         date: "Apr 12, 2026", fromEntity: "HVAU", toEntity: "HVPH", amount:  60_000, currency: "AUD", fxRateUsed: 0.6700, description: "Settle PO-HVPH-1089 advance",                       status: "settled",  approver: "Maria A." },
  { id: "iet-2026-0029", kind: "cash",         date: "Apr 10, 2026", fromEntity: "HVIN", toEntity: "HVSG", amount: 800_000, currency: "INR", fxRateUsed: 0.0120, description: "Repatriation of Q1 retained earnings",              status: "settled",  approver: "Anil V."  },
  { id: "iet-2026-0030", kind: "inventory",    date: "Apr 08, 2026", fromEntity: "HVPH", toEntity: "HVHK", amount:  18_000, currency: "USD",                  description: "Spare parts kit · CNC platform · pre-rental",        status: "posted",   approver: "Daniel R." },
  { id: "iet-2026-0031", kind: "service-charge", date: "Apr 05, 2026", fromEntity: "HVPH", toEntity: "HVSG", amount:  84_000, currency: "USD",                  description: "Management fee · Mar 2026",                          status: "settled",  approver: "Anil V."  },
  { id: "iet-2026-0032", kind: "cash",         date: "Apr 02, 2026", fromEntity: "HVSG", toEntity: "HVHK", amount:  40_000, currency: "HKD", fxRateUsed: 0.1280, description: "Wind-down funding · period close",                  status: "draft",    approver: undefined  },
]

/* ─── CONSOLIDATION RULES ────────────────────────────────────────────── */
const CONSOL_RULES: ConsolRule[] = [
  /* Ownership */
  { id: "rule-own-hvph", scope: "HVPH",        category: "ownership", rule: "Ownership %",            value: "100% (wholly-owned)", effectiveFrom: "2020-01-01", changedBy: "Anil V.", changedAt: "2020-01-01" },
  { id: "rule-own-hvsg", scope: "HVSG",        category: "ownership", rule: "Ownership %",            value: "100% (wholly-owned)", effectiveFrom: "2020-01-01", changedBy: "Anil V.", changedAt: "2020-01-01" },
  { id: "rule-own-hvhk", scope: "HVHK",        category: "ownership", rule: "Ownership %",            value: "100% (wholly-owned)", effectiveFrom: "2020-01-01" },
  { id: "rule-own-hvau", scope: "HVAU",        category: "ownership", rule: "Ownership %",            value: "70% (30% MI)",         effectiveFrom: "2022-07-01", changedBy: "Anil V.", changedAt: "2022-07-01" },
  { id: "rule-own-hvin", scope: "HVIN",        category: "ownership", rule: "Ownership %",            value: "100% (wholly-owned)", effectiveFrom: "2023-04-01" },

  /* FX policy */
  { id: "rule-fx-bs",    scope: "All entities", category: "fx-policy", rule: "Balance sheet translation", value: "Closing rate (period end)",  effectiveFrom: "2024-01-01" },
  { id: "rule-fx-pl",    scope: "All entities", category: "fx-policy", rule: "P&L translation",            value: "Avg monthly rate",          effectiveFrom: "2024-01-01" },
  { id: "rule-fx-eq",    scope: "All entities", category: "fx-policy", rule: "Equity translation",         value: "Historical rate (at posting)", effectiveFrom: "2024-01-01" },
  { id: "rule-fx-cta",   scope: "All entities", category: "fx-policy", rule: "Translation diff → CTA",     value: "Auto-post to OCI · CTA reserve", effectiveFrom: "2024-01-01" },

  /* Elimination policies */
  { id: "rule-el-revenue", scope: "All entities", category: "elimination", rule: "IC revenue / cost",        value: "Auto-eliminate when matched on both sides", effectiveFrom: "2024-01-01" },
  { id: "rule-el-arap",    scope: "All entities", category: "elimination", rule: "IC AR/AP balances",        value: "Auto-eliminate against IC counterparty",     effectiveFrom: "2024-01-01" },
  { id: "rule-el-pii",     scope: "All entities", category: "elimination", rule: "Profit in inventory",      value: "Manual review · markup ≥ 5%",                effectiveFrom: "2024-01-01" },

  /* Minority interest */
  { id: "rule-mi-hvau",   scope: "HVAU",        category: "minority-interest", rule: "30% minority interest", value: "Auto-allocate 30% of NI to MI line",         effectiveFrom: "2022-07-01" },

  /* Rollup */
  { id: "rule-roll-apac", scope: "APAC Hub",    category: "rollup", rule: "Region rollup",  value: "HVPH + HVSG + HVHK → APAC",                     effectiveFrom: "2024-01-01" },
  { id: "rule-roll-aps",  scope: "Asia Pacific South", category: "rollup", rule: "Region rollup", value: "HVAU + HVIN → APS", effectiveFrom: "2024-01-01" },
  { id: "rule-roll-hv",   scope: "Helios Vertex Group", category: "rollup", rule: "Group rollup", value: "APAC + APS → HVG", effectiveFrom: "2024-01-01" },
]

/* ─── SUBSIDIARY KPIs (for the navigator hero) ───────────────────────── */
const SUBSIDIARY_KPIS: SubsidiaryKPI[] = [
  { entityCode: "HVPH", health: "good",    revenueYTD:  8_240_000, netIncomeYTD:   980_000, closeStatus: "in-progress", closeProgress: 75, arOverdue:  84_000, apOverdue:  22_000, headcount: 412, flags: ["BIR 1601-EQ due Apr 30"] },
  { entityCode: "HVSG", health: "watch",   revenueYTD:  6_120_000, netIncomeYTD:   742_000, closeStatus: "in-progress", closeProgress: 40, arOverdue:  31_000, apOverdue:  18_400, headcount: 184, flags: ["Bank rec outstanding", "Pacific Steel invoice late"] },
  { entityCode: "HVHK", health: "concern", revenueYTD:  2_840_000, netIncomeYTD:   142_000, closeStatus: "blocked",     closeProgress: 15, arOverdue: 124_000, apOverdue:   8_200, headcount:  84, flags: ["Bright Industries 62d late", "IC dispute open"] },
  { entityCode: "HVAU", health: "good",    revenueYTD:  4_220_000, netIncomeYTD:   612_000, closeStatus: "in-progress", closeProgress: 60, arOverdue:  18_400, apOverdue:  12_200, headcount: 142, flags: ["MI allocation needs review"] },
  { entityCode: "HVIN", health: "good",    revenueYTD:  3_180_000, netIncomeYTD:   428_000, closeStatus: "in-progress", closeProgress: 80, arOverdue:   8_400, apOverdue:   4_200, headcount: 278, flags: [] },
]

function subsidiaryKPI(code: string): SubsidiaryKPI | undefined {
  return SUBSIDIARY_KPIS.find(k => k.entityCode === code)
}

// SANDBOX
Object.assign(globalThis as any, {
  IC_TXNS, IC_ELIMS, IE_TRANSFERS, CONSOL_RULES, SUBSIDIARY_KPIS, subsidiaryKPI,
})

})();/*__IIFE_WRAP_END__*/

/* ═════ apps/web/lib/mock/comms.tsx ═════ */
;/*__IIFE_WRAP_START__*/(function(){
/**
 * ============================================================================
 * apps/web/lib/mock/comms.tsx
 * ----------------------------------------------------------------------------
 * Mock data for the Cenora Communications module.
 *
 * Modelled on Microsoft Teams but reworked:
 *   GROUPS         (Teams equivalent)
 *     ├ CHANNELS
 *     │   └ SUB-CHANNELS         (Cenora addition — Teams flattens this)
 *     └ ...
 *   DIRECT MESSAGES  — 1:1 + small ad-hoc groups
 *   CALLS            — call history (voice + video)
 *   MEETINGS         — scheduled + recurring meetings
 *
 * Groups are seeded as "realistic mess": by entity (HVPH/HVSG/HVHK/HVAU),
 * by function (Procurement/Finance/HR), and by project — exactly how a
 * real multi-entity org organizes itself.
 *
 * Every message can pin to a Cenora document via `linkedDoc` — that's what
 * powers the doc-embedded chat surfaces (PO form, IRQ, Sales Opp, etc).
 * ============================================================================
 */

/* ─── TYPES ──────────────────────────────────────────────────────────── */
interface CommsUser {
  id: string
  name: string
  initials: string
  role: string
  tone: "teal" | "sand" | "ink" | "ocean" | "amber"
  presence: "available" | "busy" | "dnd" | "focus" | "away" | "offline"
  statusMsg?: string
}

interface SubChannel {
  id: string
  name: string
  emoji?: string
  unread?: number
  muted?: boolean
}

interface Channel {
  id: string
  name: string
  emoji?: string
  private?: boolean
  unread?: number
  muted?: boolean
  subChannels?: SubChannel[]
  /* If this channel is auto-linked to a Cenora doctype, this fills in. */
  linkedDoctype?: string
}

interface Group {
  id: string
  name: string
  kind: "entity" | "function" | "project" | "leadership"
  blurb: string
  members: number
  color: string  /* avatar tile bg */
  initials: string
  channels: Channel[]
}

interface ChatMsg {
  id: string
  authorId: string
  time: string  /* display string */
  text: string
  reactions?: { emoji: string; count: number; mine?: boolean }[]
  attachments?: { kind: "doc" | "image" | "file"; name: string; sub?: string }[]
  linkedDoc?: { kind: string; id: string; label: string }   /* clickable chip */
  pinned?: boolean
  edited?: boolean
  thread?: ChatMsg[]
  /* AI summaries */
  aiSummary?: string
  /* System messages (call started, user joined, etc) */
  system?: "call-started" | "call-ended" | "user-joined" | "decision" | "action-item"
  systemMeta?: any
}

interface DirectChat {
  id: string
  /* For 1:1, single participant; for ad-hoc groups, multiple */
  participantIds: string[]
  unread?: number
  pinned?: boolean
  lastMsgPreview: string
  lastMsgTime: string
  muted?: boolean
}

interface CallHistoryEntry {
  id: string
  kind: "voice" | "video" | "meeting"
  direction: "in" | "out" | "missed"
  participantIds: string[]
  startedAt: string  /* display string */
  duration?: string  /* "12m" / "1h 04m" */
  recording?: boolean
  hasTranscript?: boolean
  topic?: string
}

interface Meeting {
  id: string
  title: string
  when: string   /* display string */
  startISO: string
  durationMin: number
  recurring?: string  /* "Weekly · Mondays" */
  participantIds: string[]
  organizerId: string
  hostedBy: "cenora" | "zoom" | "google" | "teams"
  agenda?: string[]
  joinable?: boolean   /* If true, "Join now" button live */
  isLive?: boolean
}

/* ─── USERS ──────────────────────────────────────────────────────────── */
const COMMS_USERS: CommsUser[] = [
  /* The default tenant user is Maya C. — Procurement Director */
  { id: "u-kim",      name: "Maya C.",      initials: "MC", role: "Procurement Director",   tone: "teal",  presence: "available" },
  { id: "u-maria",    name: "Maria A.",    initials: "MA", role: "Senior Accountant · HVPH", tone: "sand",  presence: "available" },
  { id: "u-daniel",   name: "Daniel R.",   initials: "DR", role: "Operations Manager",     tone: "ocean", presence: "busy",      statusMsg: "In a meeting until 3pm" },
  { id: "u-sofia",    name: "Sofia M.",    initials: "SM", role: "HR Business Partner",    tone: "amber", presence: "available" },
  { id: "u-anil",     name: "Anil V.",     initials: "AV", role: "CFO · Group",            tone: "ink",   presence: "focus",     statusMsg: "Focus mode · do not disturb until 4pm" },
  { id: "u-tom",      name: "Tom K.",      initials: "TK", role: "Platform Admin",         tone: "ink",   presence: "available" },
  { id: "u-priya",    name: "Priya I.",    initials: "PI", role: "VP Operations · APAC",   tone: "amber", presence: "available" },
  { id: "u-mason",    name: "Mason P.",    initials: "MP", role: "Account Executive",      tone: "ocean", presence: "available" },
  { id: "u-vanessa",  name: "Vanessa L.",  initials: "VL", role: "Ops Engineer",           tone: "teal",  presence: "away" },
  { id: "u-kenneth",  name: "Kenneth T.",  initials: "KT", role: "Sales Lead · HVSG",      tone: "sand",  presence: "dnd",      statusMsg: "On a customer call" },
  { id: "u-anya",     name: "Anya R.",     initials: "AR", role: "Practice Lead · PS",     tone: "ocean", presence: "available" },
  { id: "u-anand",    name: "Anand K.",    initials: "AK", role: "Plant Manager · HVIN",   tone: "amber", presence: "available" },
  { id: "u-mia",      name: "Mia H.",      initials: "MH", role: "PM · HVAU",              tone: "teal",  presence: "offline" },
  { id: "u-eric",     name: "Eric W.",     initials: "EW", role: "E-comm Manager",         tone: "ink",   presence: "available" },
  { id: "u-maya",     name: "Maya R.",     initials: "MR", role: "Finance Manager · HVHK", tone: "sand",  presence: "busy" },
  { id: "u-james",    name: "James O.",    initials: "JO", role: "Warehouse Lead · HVPH",  tone: "ocean", presence: "available" },
  { id: "u-ling",     name: "Ling W.",     initials: "LW", role: "Buyer · HVSG",           tone: "amber", presence: "available" },
  { id: "u-bot-ai",   name: "@cenora",     initials: "AI", role: "AI assistant",            tone: "teal",  presence: "available" },
]

function commsUser(id: string): CommsUser {
  return COMMS_USERS.find(u => u.id === id) ?? COMMS_USERS[0]
}

/* ─── GROUPS / CHANNELS / SUB-CHANNELS ──────────────────────────────── */
const COMMS_GROUPS: Group[] = [
  /* ━━━ ENTITY-BASED ━━━ */
  {
    id: "g-hvph", name: "HVPH · Manila", kind: "entity",
    blurb: "Helios Vertex Philippines — daily ops, BIR filings, Manila warehouse",
    members: 38, color: "bg-brand", initials: "PH",
    channels: [
      { id: "c-hvph-general",   name: "general",   emoji: "🏢", unread: 0 },
      { id: "c-hvph-announce",  name: "announcements", emoji: "📣", unread: 2 },
      { id: "c-hvph-wh", name: "warehouse-floor", emoji: "📦",
        subChannels: [
          { id: "sc-hvph-receiving", name: "receiving",  unread: 3 },
          { id: "sc-hvph-shipping",  name: "shipping" },
          { id: "sc-hvph-cycle",     name: "cycle-count" },
        ]},
      { id: "c-hvph-bir", name: "bir-compliance", emoji: "📋", unread: 1,
        subChannels: [
          { id: "sc-hvph-2307",   name: "form-2307" },
          { id: "sc-hvph-1601eq", name: "form-1601eq" },
          { id: "sc-hvph-vat",    name: "vat-filings", unread: 1 },
        ]},
      { id: "c-hvph-supervisor", name: "supervisor-only", emoji: "🔒", private: true },
    ],
  },
  {
    id: "g-hvsg", name: "HVSG · Singapore", kind: "entity",
    blurb: "Helios Vertex Singapore — APAC HQ, treasury, GST F5",
    members: 22, color: "bg-info", initials: "SG",
    channels: [
      { id: "c-hvsg-general",  name: "general",     emoji: "🏢" },
      { id: "c-hvsg-treasury", name: "treasury",    emoji: "💰", unread: 4 },
      { id: "c-hvsg-gst",      name: "gst-filings", emoji: "📋" },
    ],
  },
  {
    id: "g-hvhk", name: "HVHK · Hong Kong", kind: "entity",
    blurb: "Helios Vertex HK — closing this period",
    members: 14, color: "bg-danger", initials: "HK",
    channels: [
      { id: "c-hvhk-general", name: "general", emoji: "🏢" },
      { id: "c-hvhk-closing", name: "period-close", emoji: "🗓️", unread: 6 },
    ],
  },
  {
    id: "g-hvau", name: "HVAU · Sydney", kind: "entity",
    blurb: "Helios Vertex Australia — BAS, STP, Xero handoff",
    members: 18, color: "bg-info", initials: "AU",
    channels: [
      { id: "c-hvau-general", name: "general", emoji: "🏢" },
    ],
  },

  /* ━━━ FUNCTION-BASED ━━━ */
  {
    id: "g-procurement", name: "Procurement", kind: "function",
    blurb: "Cross-entity procurement — POs, vendors, contracts",
    members: 24, color: "bg-accent-deep", initials: "PR",
    channels: [
      { id: "c-proc-general",  name: "general",  emoji: "🛒", unread: 0 },
      { id: "c-proc-pos", name: "purchase-orders", emoji: "📄", unread: 5, linkedDoctype: "po",
        subChannels: [
          { id: "sc-po-overdue",  name: "overdue-pos",  unread: 2 },
          { id: "sc-po-vendor-issues", name: "vendor-issues", unread: 3 },
          { id: "sc-po-approvals", name: "needs-approval" },
        ]},
      { id: "c-proc-vendors",  name: "vendors",  emoji: "🏭",
        subChannels: [
          { id: "sc-vendor-onboarding", name: "onboarding" },
          { id: "sc-vendor-perf",       name: "performance", unread: 1 },
        ]},
      { id: "c-proc-irq",      name: "item-requests", emoji: "🏷️", unread: 2, linkedDoctype: "irq" },
      { id: "c-proc-contracts", name: "contracts", emoji: "📜" },
      { id: "c-proc-sourcing",  name: "sourcing-projects", emoji: "🔍", private: true },
    ],
  },
  {
    id: "g-finance", name: "Finance", kind: "function",
    blurb: "Group finance — close, consolidation, treasury, audit",
    members: 16, color: "bg-success", initials: "FN",
    channels: [
      { id: "c-fin-general",   name: "general",      emoji: "📊" },
      { id: "c-fin-close",     name: "month-end-close", emoji: "🗓️", unread: 3,
        subChannels: [
          { id: "sc-close-apr26", name: "april-2026",  unread: 3 },
          { id: "sc-close-mar26", name: "march-2026",  muted: true },
          { id: "sc-close-runbook", name: "runbook-edits" },
        ]},
      { id: "c-fin-ar",        name: "ar-collections", emoji: "💵", unread: 1 },
      { id: "c-fin-bankrecon", name: "bank-recon",   emoji: "🏦", linkedDoctype: "bank-recon" },
      { id: "c-fin-audit",     name: "audit-pbc",    emoji: "🔎", private: true },
    ],
  },
  {
    id: "g-ops", name: "Operations", kind: "function",
    blurb: "Manufacturing · Warehouse · Logistics · Field Service",
    members: 31, color: "bg-warn", initials: "OP",
    channels: [
      { id: "c-ops-general",   name: "general",         emoji: "⚙️" },
      { id: "c-ops-mfg",       name: "manufacturing",   emoji: "🏭", unread: 2, linkedDoctype: "work-order",
        subChannels: [
          { id: "sc-wo-shopfloor", name: "shop-floor-live", unread: 2 },
          { id: "sc-wo-quality",   name: "quality-holds" },
          { id: "sc-wo-bom-changes", name: "bom-changes" },
        ]},
      { id: "c-ops-field",     name: "field-service",   emoji: "🛠️", unread: 1, linkedDoctype: "field-job" },
      { id: "c-ops-logistics", name: "logistics",       emoji: "🚚" },
    ],
  },
  {
    id: "g-hr", name: "People & Culture", kind: "function",
    blurb: "HR — hiring, performance, payroll, cases, culture",
    members: 12, color: "bg-accent-deep", initials: "HR",
    channels: [
      { id: "c-hr-general",    name: "general",     emoji: "🤝" },
      { id: "c-hr-hiring",     name: "active-reqs", emoji: "💼", unread: 2 },
      { id: "c-hr-payroll",    name: "payroll-runs", emoji: "💸" },
      { id: "c-hr-culture",    name: "culture-club", emoji: "🎉" },
    ],
  },

  /* ━━━ PROJECT-BASED ━━━ */
  {
    id: "g-prj-cebu", name: "Project · Cebu Warehouse", kind: "project",
    blurb: "Greenfield WH build, Cebu — opening Q4 2026",
    members: 9, color: "bg-info", initials: "CB",
    channels: [
      { id: "c-prj-cebu-general",  name: "general",       emoji: "🏗️", unread: 1 },
      { id: "c-prj-cebu-vendors",  name: "vendor-bids",   emoji: "📄" },
      { id: "c-prj-cebu-permits",  name: "permits-pcab",  emoji: "📋", unread: 1 },
    ],
  },
  {
    id: "g-prj-sap", name: "Project · SAP Decommission", kind: "project",
    blurb: "Sunset SAP Business One — full migration to Cenora",
    members: 6, color: "bg-ink", initials: "SP",
    channels: [
      { id: "c-prj-sap-general",  name: "general",      emoji: "⚡", unread: 8 },
      { id: "c-prj-sap-cutover",  name: "cutover-plan", emoji: "🚦",
        subChannels: [
          { id: "sc-sap-week1",  name: "week-1-pilot" },
          { id: "sc-sap-week2",  name: "week-2-finance", unread: 2 },
          { id: "sc-sap-rollback", name: "rollback-plan" },
        ]},
    ],
  },
  {
    id: "g-leadership", name: "Leadership Council", kind: "leadership",
    blurb: "Executive — strategy, board prep, M&A",
    members: 6, color: "bg-brand", initials: "LC",
    channels: [
      { id: "c-lc-general",     name: "general",      emoji: "🎯" },
      { id: "c-lc-board",       name: "board-prep",   emoji: "📊", unread: 1 },
      { id: "c-lc-ma",          name: "m-and-a",      emoji: "🤝", private: true },
    ],
  },
]

/* ─── MESSAGES per channel (selected channels populated) ────────────── */
const COMMS_MESSAGES: Record<string, ChatMsg[]> = {
  /* Procurement > Purchase Orders > overdue-pos */
  "sc-po-overdue": [
    { id: "m1", authorId: "u-kim", time: "Yesterday · 4:12 PM",
      text: "Pulling together the overdue list for Mon standup. SteelMark are still ghosting us on PO-HVPH-1089. Anyone in touch with their AP?",
      pinned: true,
    },
    { id: "m2", authorId: "u-ling", time: "Yesterday · 4:31 PM",
      text: "I have Lin's WhatsApp — let me ping her tonight. Last time it took 2 days but she actually responds.",
    },
    { id: "m3", authorId: "u-james", time: "Yesterday · 5:02 PM",
      text: "FYI we have ~8 working days of buffer rebar before the Tower B pour. After that we need to lock an alt.",
      linkedDoc: { kind: "wo", id: "WO-2026-0142", label: "WO-2026-0142 · Tower B foundation" },
    },
    { id: "m4", authorId: "u-bot-ai", time: "Yesterday · 5:03 PM",
      text: "Heads up — Pacific Steel Co is 8% cheaper and 94% on-time. I drafted a quick RFQ; want me to send it to your contact there?",
      reactions: [{ emoji: "👍", count: 3, mine: true }],
    },
    { id: "m5", authorId: "u-kim", time: "Today · 9:14 AM",
      text: "Let's do it. @Ling can you draft the cutover comms to the Tower B PM in case we have to switch mid-pour?",
    },
    { id: "m6", authorId: "u-ling", time: "Today · 9:21 AM",
      text: "On it. Will share a draft by EOD.",
      reactions: [{ emoji: "🙏", count: 2 }],
    },
    { id: "m7", authorId: "u-bot-ai", time: "Today · 11:30 AM",
      text: "**Channel summary (last 24h)** — 6 messages on PO-1089 SteelMark delay. Decision: pursue Pacific Steel as backup. Ling drafting cutover comms by EOD. @Maya to send formal RFQ.",
      aiSummary: "summary",
    },
  ],

  /* Procurement > IRQs */
  "c-proc-irq": [
    { id: "m1", authorId: "u-james", time: "Mon · 10:15 AM",
      text: "New IRQ for monoblock chairs (200 units) — Tower B canteen.",
      linkedDoc: { kind: "irq", id: "IRQ-0206", label: "IRQ-0206 · Monoblock Chairs" },
    },
    { id: "m2", authorId: "u-kim", time: "Mon · 10:42 AM",
      text: "Approved. @Ling source from existing vendors first, please.",
    },
    { id: "m3", authorId: "u-ling", time: "Mon · 11:14 AM",
      text: "PlasticHub MNL has them at ₱180/unit, lead time 4 days. Cheaper than UniOffice.",
      reactions: [{ emoji: "✅", count: 2, mine: true }],
    },
  ],

  /* Finance > Month-End Close > April 2026 */
  "sc-close-apr26": [
    { id: "m1", authorId: "u-maria", time: "Yesterday · 8:00 AM",
      text: "Apr close kickoff — checklist refreshed. 4/12 steps done. HVSG bank rec still outstanding.",
      pinned: true,
    },
    { id: "m2", authorId: "u-maya", time: "Yesterday · 9:14 AM",
      text: "HVHK accruals — I posted the rent and utility accruals last night. JE-2026-04-0142 / 0143.",
    },
    { id: "m3", authorId: "u-anil", time: "Yesterday · 11:30 AM",
      text: "Need FX revaluation signed off by Wed. @Maria can you send me the snapshot?",
    },
    { id: "m4", authorId: "u-maria", time: "Yesterday · 2:18 PM",
      text: "Sending tonight after the rates close. Tagging the relevant entries.",
    },
    { id: "m5", authorId: "u-bot-ai", time: "Today · 8:00 AM",
      text: "**Daily close digest** — 4/12 steps complete · 2 vendor invoices still late · forecast close: Apr 30 (on track). HVSG bank rec is the critical path.",
      aiSummary: "daily-digest",
    },
    { id: "m6", authorId: "u-maya", time: "Today · 9:42 AM",
      text: "FYI Bright Industries HK paid USD 8k against AR-2026-0218 overnight. Allocation done.",
      linkedDoc: { kind: "bill", id: "AR-2026-0218", label: "AR-2026-0218 · Bright Industries" },
      reactions: [{ emoji: "🎉", count: 3 }],
    },
  ],

  /* Operations > Manufacturing > shop-floor-live */
  "sc-wo-shopfloor": [
    { id: "m1", authorId: "u-anand", time: "Today · 7:00 AM",
      text: "Shift A standup — WO-2026-0142 on track for 2pm completion. Line 2 has a calibration issue on the heat sealer; quality holding the run.",
      linkedDoc: { kind: "wo", id: "WO-2026-0142", label: "WO-2026-0142" },
    },
    { id: "m2", authorId: "u-daniel", time: "Today · 7:14 AM",
      text: "Maintenance ETA on the heat sealer? @Anand",
    },
    { id: "m3", authorId: "u-anand", time: "Today · 7:18 AM",
      text: "30 min. Tech is on site. Will resume by 8am.",
    },
  ],

  /* Project · SAP Decom > week-2-finance */
  "sc-sap-week2": [
    { id: "m1", authorId: "u-tom", time: "Mon · 9:00 AM",
      text: "Week 2 starts Mon. Finance modules cut over: GL, AP, AR, Cash. Bank rec on Tue.",
      pinned: true,
    },
    { id: "m2", authorId: "u-anil", time: "Mon · 9:42 AM",
      text: "Risk: the SAP B1 → Cenora COA mapping needs final sign-off. @Maria can you confirm by tomorrow?",
    },
    { id: "m3", authorId: "u-maria", time: "Mon · 11:15 AM",
      text: "Sign-off done. One open Q on account 620100 → 620150 split; covered in the mapping sheet.",
      attachments: [{ kind: "doc", name: "COA-mapping-SAP-Cenora-v4.xlsx", sub: "Updated yesterday · Maria A." }],
    },
  ],

  /* Generic fallback used by less-detailed channels — keeps the UI live */
  "_default": [
    { id: "m1", authorId: "u-tom", time: "Today · 9:00 AM",
      text: "Welcome to the channel. Pinned the channel charter — read before posting.", pinned: true,
    },
    { id: "m2", authorId: "u-vanessa", time: "Today · 9:30 AM",
      text: "Quick reminder: use sub-channels for focused topics, keep #general light.",
      reactions: [{ emoji: "👍", count: 4 }],
    },
  ],
}

function commsMessages(channelId: string): ChatMsg[] {
  return COMMS_MESSAGES[channelId] ?? COMMS_MESSAGES["_default"]
}

/* ─── DIRECT MESSAGES ────────────────────────────────────────────────── */
const COMMS_DMS: DirectChat[] = [
  { id: "dm-maria",   participantIds: ["u-maria"],            unread: 2, pinned: true,  lastMsgPreview: "Sending tonight after the rates close.", lastMsgTime: "2h" },
  { id: "dm-daniel",  participantIds: ["u-daniel"],           unread: 0, pinned: true,  lastMsgPreview: "Maintenance ETA on the heat sealer?",     lastMsgTime: "4h" },
  { id: "dm-anil",    participantIds: ["u-anil"],             unread: 1,                lastMsgPreview: "Pls send me the Apr close snapshot",      lastMsgTime: "5h" },
  { id: "dm-ling-james", participantIds: ["u-ling", "u-james"], unread: 0, lastMsgPreview: "On it. Will share a draft by EOD.",                    lastMsgTime: "1d" },
  { id: "dm-mason",   participantIds: ["u-mason"],            unread: 0,                lastMsgPreview: "Closed-won Pacific Ventures, $48k.",       lastMsgTime: "1d" },
  { id: "dm-sofia",   participantIds: ["u-sofia"],            unread: 0,                lastMsgPreview: "New hire paperwork sent.",                 lastMsgTime: "2d" },
  { id: "dm-tom",     participantIds: ["u-tom"],              unread: 0,                lastMsgPreview: "Week 2 cutover starts Mon.",               lastMsgTime: "2d" },
  { id: "dm-priya",   participantIds: ["u-priya"],            unread: 0,                lastMsgPreview: "Pls sign off Q1 OKRs",                     lastMsgTime: "3d", muted: true },
]

/* DM "channels" use their own message buckets */
const COMMS_DM_MESSAGES: Record<string, ChatMsg[]> = {
  "dm-maria": [
    { id: "m1", authorId: "u-kim",   time: "Yesterday · 3:42 PM",
      text: "Hey — quick one. Did Bright Industries HK ever come back to us on the Apr invoice?",
    },
    { id: "m2", authorId: "u-maria", time: "Yesterday · 4:11 PM",
      text: "Just did — paid USD 8k overnight. I'll allocate it this morning.",
      linkedDoc: { kind: "bill", id: "AR-2026-0218", label: "AR-2026-0218" },
    },
    { id: "m3", authorId: "u-kim",   time: "Today · 9:02 AM",
      text: "Nice. Also — Apr close snapshot — Anil needs it by Wed.",
    },
    { id: "m4", authorId: "u-maria", time: "Today · 9:14 AM",
      text: "Sending tonight after the rates close.",
    },
  ],
  "dm-daniel": [
    { id: "m1", authorId: "u-kim",    time: "Today · 7:12 AM", text: "Maintenance ETA on the heat sealer?" },
    { id: "m2", authorId: "u-daniel", time: "Today · 7:18 AM", text: "30 min. Tech is on site. Will resume by 8am." },
  ],
  "_default": [
    { id: "m1", authorId: "u-kim", time: "Today", text: "Hey 👋" },
  ],
}
function commsDMMessages(dmId: string): ChatMsg[] {
  return COMMS_DM_MESSAGES[dmId] ?? COMMS_DM_MESSAGES["_default"]
}

/* ─── CALL HISTORY ───────────────────────────────────────────────────── */
const COMMS_CALL_HISTORY: CallHistoryEntry[] = [
  { id: "cl1",  kind: "video",   direction: "out",     participantIds: ["u-maria"],          startedAt: "Today · 10:14 AM", duration: "12m 04s", recording: true,  hasTranscript: true, topic: "Apr close snapshot review" },
  { id: "cl2",  kind: "voice",   direction: "in",      participantIds: ["u-daniel"],         startedAt: "Today · 8:02 AM",  duration: "3m 12s", topic: "Heat sealer maintenance" },
  { id: "cl3",  kind: "video",   direction: "missed",  participantIds: ["u-anil"],           startedAt: "Today · 7:45 AM" },
  { id: "cl4",  kind: "meeting", direction: "out",     participantIds: ["u-daniel", "u-anand", "u-james"], startedAt: "Yesterday · 4:00 PM", duration: "48m 22s", recording: true, hasTranscript: true, topic: "Shop floor weekly" },
  { id: "cl5",  kind: "voice",   direction: "out",     participantIds: ["u-ling"],           startedAt: "Yesterday · 2:14 PM", duration: "8m 34s", topic: "PlasticHub MNL pricing" },
  { id: "cl6",  kind: "meeting", direction: "in",      participantIds: ["u-anil", "u-priya", "u-maria", "u-tom"], startedAt: "Yesterday · 10:00 AM", duration: "1h 04m", recording: true, hasTranscript: true, topic: "Leadership · weekly" },
  { id: "cl7",  kind: "video",   direction: "missed",  participantIds: ["u-mason"],          startedAt: "Mon · 3:14 PM" },
  { id: "cl8",  kind: "voice",   direction: "in",      participantIds: ["u-sofia"],          startedAt: "Mon · 1:42 PM",  duration: "5m 18s", topic: "New hire IT setup" },
  { id: "cl9",  kind: "meeting", direction: "out",     participantIds: ["u-tom", "u-vanessa", "u-anil"], startedAt: "Mon · 11:00 AM", duration: "57m 12s", recording: true, hasTranscript: true, topic: "SAP cutover plan walkthrough" },
  { id: "cl10", kind: "voice",   direction: "out",     participantIds: ["u-mia"],            startedAt: "Fri · 4:32 PM",  duration: "14m 02s", topic: "HVAU Q1 reporting" },
]

/* ─── MEETINGS ───────────────────────────────────────────────────────── */
const COMMS_MEETINGS: Meeting[] = [
  { id: "mt1", title: "Procurement standup",            when: "Today · 9:30 AM",  startISO: "2026-04-21T09:30",  durationMin: 25,
    recurring: "Daily · Weekdays",
    participantIds: ["u-kim", "u-ling", "u-james", "u-vanessa"], organizerId: "u-kim", hostedBy: "cenora",
    agenda: ["Overdue POs", "IRQ approvals queue", "Vendor escalations"],
    joinable: true, isLive: true,
  },
  { id: "mt2", title: "Apr close — daily sync",          when: "Today · 10:30 AM", startISO: "2026-04-21T10:30",  durationMin: 30,
    recurring: "Daily · Apr 1 → Apr 30",
    participantIds: ["u-maria", "u-anil", "u-maya"], organizerId: "u-maria", hostedBy: "cenora",
    agenda: ["Step-by-step status", "Blockers", "Tomorrow's targets"],
    joinable: true,
  },
  { id: "mt3", title: "Shop floor weekly",               when: "Today · 4:00 PM",  startISO: "2026-04-21T16:00",  durationMin: 45,
    recurring: "Weekly · Tuesdays",
    participantIds: ["u-daniel", "u-anand", "u-james"], organizerId: "u-daniel", hostedBy: "cenora",
    agenda: ["OEE trend", "Quality holds", "Maintenance backlog"],
  },
  { id: "mt4", title: "Leadership Council",              when: "Tomorrow · 10:00 AM", startISO: "2026-04-22T10:00", durationMin: 60,
    recurring: "Weekly · Wednesdays",
    participantIds: ["u-anil", "u-priya", "u-maria", "u-kim", "u-sofia"], organizerId: "u-anil", hostedBy: "cenora",
    agenda: ["Apr close status", "Cebu warehouse update", "M&A pipeline"],
  },
  { id: "mt5", title: "SAP cutover — Week 2 kickoff",    when: "Tomorrow · 2:00 PM",  startISO: "2026-04-22T14:00", durationMin: 90,
    participantIds: ["u-tom", "u-vanessa", "u-maria", "u-anil"], organizerId: "u-tom", hostedBy: "cenora",
    agenda: ["GL/AP/AR/Cash cutover sequence", "Bank rec Tue", "Rollback plan"],
  },
  { id: "mt6", title: "Vendor QBR · Pacific Steel",       when: "Thu · 11:00 AM",     startISO: "2026-04-24T11:00", durationMin: 45,
    participantIds: ["u-kim", "u-ling", "u-james"], organizerId: "u-kim", hostedBy: "zoom",
    agenda: ["YTD performance", "Pricing for FY27", "Tower C forecast"],
  },
  { id: "mt7", title: "HR onboarding · 8 new hires",      when: "Fri · 9:00 AM",      startISO: "2026-04-25T09:00", durationMin: 120,
    participantIds: ["u-sofia", "u-tom"], organizerId: "u-sofia", hostedBy: "cenora",
    agenda: ["Welcome", "IT setup", "Tour", "First week plan"],
  },
]

/* ─── ACTIVE CALL (mock) ─────────────────────────────────────────────── */
const ACTIVE_CALL_PARTICIPANTS = [
  { id: "u-kim",    speaking: true,  muted: false, video: true,  hand: false, you: true },
  { id: "u-maria",  speaking: false, muted: false, video: true,  hand: false },
  { id: "u-anil",   speaking: false, muted: true,  video: false, hand: true  },
  { id: "u-maya",   speaking: false, muted: true,  video: true,  hand: false },
  { id: "u-tom",    speaking: false, muted: false, video: false, hand: false },
]

const ACTIVE_CALL_TRANSCRIPT = [
  { who: "u-maria", time: "00:14", text: "Apr close is 4 of 12 steps. HVSG bank rec is the critical path." },
  { who: "u-anil",  time: "00:42", text: "What's blocking HVSG specifically?" },
  { who: "u-maria", time: "00:58", text: "Two vendor invoices late from Pacific Steel and Manila Iron. Both expected today." },
  { who: "u-kim",   time: "01:24", text: "Pacific Steel sent theirs this morning — Ling forwarded it 10 min ago." },
  { who: "u-anil",  time: "01:38", text: "Good. Maya — HVHK accruals?" },
  { who: "u-maya",  time: "01:46", text: "Done last night. JE-2026-04-0142 and 0143 — rent and utilities." },
  { who: "u-bot-ai", time: "02:12", text: "Action item captured: Maria to send Apr close snapshot to Anil by Wed." },
]

// SANDBOX
Object.assign(globalThis as any, {
  COMMS_USERS, COMMS_GROUPS, COMMS_MESSAGES, COMMS_DMS, COMMS_DM_MESSAGES,
  COMMS_CALL_HISTORY, COMMS_MEETINGS, ACTIVE_CALL_PARTICIPANTS, ACTIVE_CALL_TRANSCRIPT,
  commsUser, commsMessages, commsDMMessages,
})

})();/*__IIFE_WRAP_END__*/


/* ============================================================================
 * IMPORTED MOCKS (merge v3.3): Tickets, Customer Service, IT, Facilities, Marketing
 * ============================================================================ */

/* ═════ apps/web/lib/mock/tickets.tsx ═════ */
;/*__IIFE_WRAP_START__*/(function(){
/**
 * ============================================================================
 * apps/web/lib/mock/tickets.tsx
 * ----------------------------------------------------------------------------
 * Cross-module Ticketing engine seed data. Six ticket types:
 *   customer_support, it_request, facility_request, hr_case,
 *   project_issue, asset_request
 *
 * Each ticket shares a common shape (id, type, status, priority, sla,
 * assignee, requester, createdAt, dueIn, subject, body, comments, audit,
 * linkedRecords) plus a `custom` object with per-type fields.
 *
 * Six type-registry rows define the per-type queue columns + ActionBar
 * actions consumed by <TicketQueue> and the unified <TicketsInbox>.
 * ============================================================================
 */

/* ─── Type registry ────────────────────────────────────────────────── */
const TKT_TYPES = [
  { id: "customer_support", label: "Customer Support",  ownerModule: "customer-service", icon: "headphones", tone: "brand",   color: "var(--brand)",
    sla: { firstResponseMin: 30, resolveHours: 8 },   queueRoute: "/customer-service/tickets",
    customColumns: ["channel", "customer", "linkedDoc"],
    actions: ["assign-me", "reply", "internal-note", "resolve", "send-csat", "escalate"] },
  { id: "it_request",       label: "IT Request",        ownerModule: "it",               icon: "monitor", tone: "info",    color: "var(--info)",
    sla: { firstResponseMin: 60, resolveHours: 24 },  queueRoute: "/it/tickets",
    customColumns: ["category", "device", "asset"],
    actions: ["assign-me", "request-info", "schedule-visit", "resolve", "escalate"] },
  { id: "facility_request", label: "Facilities",         ownerModule: "facilities",        icon: "building", tone: "warn",   color: "var(--warn)",
    sla: { firstResponseMin: 120, resolveHours: 48 }, queueRoute: "/facilities/tickets",
    customColumns: ["location", "equipment", "severity"],
    actions: ["assign-me", "dispatch-vendor", "schedule-visit", "resolve", "escalate"] },
  { id: "hr_case",          label: "HR Case",            ownerModule: "hr",                icon: "user",    tone: "danger", color: "var(--danger)",
    sla: { firstResponseMin: 240, resolveHours: 72 }, queueRoute: "/hr/cases",
    customColumns: ["category", "confidential", "employee"],
    actions: ["assign-me", "schedule-meeting", "request-docs", "resolve", "escalate"] },
  { id: "project_issue",    label: "Project Issue",      ownerModule: "pm",                icon: "briefcase", tone: "accent", color: "var(--accent)",
    sla: { firstResponseMin: 240, resolveHours: 96 }, queueRoute: "/pm/issues",
    customColumns: ["project", "blocker", "story"],
    actions: ["assign-me", "link-task", "resolve", "escalate"] },
  { id: "asset_request",    label: "Asset Request",      ownerModule: "assets",            icon: "package", tone: "success", color: "var(--success)",
    sla: { firstResponseMin: 480, resolveHours: 120 }, queueRoute: "/assets/requests",
    customColumns: ["asset", "issueType", "downtime"],
    actions: ["assign-me", "schedule-maintenance", "resolve", "escalate"] },
]

/* ─── Agents/owners pool ────────────────────────────────────────────── */
const TKT_AGENTS = [
  { initials: "SM", name: "Sofia M.",   tone: "amber", team: "customer-service" },
  { initials: "OP", name: "Olivia P.",  tone: "amber", team: "customer-service" },
  { initials: "MR", name: "Maya R.",    tone: "blue",  team: "customer-service" },
  { initials: "RT", name: "Ramon T.",   tone: "teal",  team: "it" },
  { initials: "AK", name: "Anand K.",   tone: "blue",  team: "it" },
  { initials: "DL", name: "Diane L.",   tone: "amber", team: "it" },
  { initials: "BP", name: "Ben P.",     tone: "amber", team: "facilities" },
  { initials: "GC", name: "Grace C.",   tone: "teal",  team: "facilities" },
  { initials: "EL", name: "Elena L.",   tone: "blue",  team: "hr" },
  { initials: "JM", name: "Jaime M.",   tone: "ink",   team: "hr" },
  { initials: "MC", name: "Maya C.",     tone: "teal",  team: "pm" },
  { initials: "FB", name: "Felix B.",   tone: "amber", team: "pm" },
  { initials: "NS", name: "Nina S.",    tone: "blue",  team: "assets" },
]

/* ─── Ticket bank — 30 tickets across 6 types ───────────────────────── */
const TKT_TICKETS = [
  /* Customer Support · 8 */
  { id: "TKT-1041", type: "customer_support", subject: "Invoice INV-2026-1184 — wrong VAT applied",       status: "open",     priority: "P1", sla: "breached", assignee: "SM", requester: "Jose A. Reyes · Globe Telecom", entity: "HVPH", createdAgo: "3h",  dueIn: "−12m",  custom: { channel: "email",    customer: "Globe Telecom",    linkedDoc: { type: "Invoice", id: "INV-2026-1184" } } },
  { id: "TKT-1040", type: "customer_support", subject: "Order SO-0884 — delivery delayed?",               status: "open",     priority: "P2", sla: "at-risk",  assignee: "MR", requester: "Mei Lin Tan · Metro Retail SG", entity: "HVSG", createdAgo: "5h",  dueIn: "1h 12m", custom: { channel: "chat",     customer: "Metro Retail SG",  linkedDoc: { type: "SO", id: "SO-0884" } } },
  { id: "TKT-1039", type: "customer_support", subject: "Return request — defective unit (RMA)",            status: "pending", priority: "P2", sla: "on-track", assignee: "OP", requester: "Hana Park · Park Hospitality", entity: "HVHK", createdAgo: "1d",  dueIn: "5h 40m", custom: { channel: "portal",  customer: "Park Hospitality", linkedDoc: { type: "RMA", id: "RMA-0042" } } },
  { id: "TKT-1038", type: "customer_support", subject: "Account locked after 5 failed logins",            status: "open",     priority: "P3", sla: "on-track", assignee: "MR", requester: "Daniel Ng · BuildRight SG",   entity: "HVSG", createdAgo: "2d",  dueIn: "23h",   custom: { channel: "email",   customer: "BuildRight SG" } },
  { id: "TKT-1037", type: "customer_support", subject: "Webhook integration — events dropping",            status: "new",      priority: "P1", sla: "at-risk",  assignee: null, requester: "Connor Walsh · Walsh Homes",   entity: "HVAU", createdAgo: "42m", dueIn: "18m",   custom: { channel: "email",    customer: "Walsh Homes" } },
  { id: "TKT-1036", type: "customer_support", subject: "Late delivery — order SO-0871",                   status: "open",     priority: "P2", sla: "on-track", assignee: "SM", requester: "Ravi Subramanian · Indre Logistics", entity: "HVIN", createdAgo: "8h",  dueIn: "4h 12m", custom: { channel: "whatsapp", customer: "Indre Logistics", linkedDoc: { type: "SO", id: "SO-0871" } } },
  { id: "TKT-1035", type: "customer_support", subject: "Where do I download my paid invoice?",            status: "resolved", priority: "P3", sla: "on-track", assignee: "AI · auto", requester: "Felicity Cruz · Sunlight Solar", entity: "HVPH", createdAgo: "1d",  dueIn: "—",     custom: { channel: "chat",     customer: "Sunlight Solar PH",  linkedDoc: { type: "Invoice", id: "INV-2026-1124" } } },
  { id: "TKT-1034", type: "customer_support", subject: "Question on bulk pricing — 100+ users",           status: "open",     priority: "P3", sla: "on-track", assignee: "OP", requester: "Sophie Hartmann · Hartmann Aus.", entity: "HVAU", createdAgo: "1d",  dueIn: "22h 14m", custom: { channel: "email",   customer: "Hartmann Aus." } },

  /* IT Request · 5 */
  { id: "TKT-2021", type: "it_request",       subject: "Replace laptop · screen flickering",               status: "open",     priority: "P2", sla: "at-risk",  assignee: "RT", requester: "Maria A. · Accounting",         entity: "HVPH", createdAgo: "6h",  dueIn: "3h 42m", custom: { category: "hardware", device: "MacBook Pro 14",  asset: "FA-PH-0184", urgency: "high" } },
  { id: "TKT-2020", type: "it_request",       subject: "VPN access — new joiner setup",                    status: "pending",  priority: "P3", sla: "on-track", assignee: "AK", requester: "Tomas R. · Procurement (new joiner)", entity: "HVSG", createdAgo: "1d",  dueIn: "16h",    custom: { category: "access",   device: "—",                asset: "—",          urgency: "normal" } },
  { id: "TKT-2019", type: "it_request",       subject: "Power BI connector failing — Finance report",      status: "open",     priority: "P2", sla: "on-track", assignee: "DL", requester: "Maria A. · Accounting",         entity: "HVPH", createdAgo: "4h",  dueIn: "12h",    custom: { category: "software", device: "—",                asset: "—",          urgency: "normal" } },
  { id: "TKT-2018", type: "it_request",       subject: "Slack workspace — invite engineering vendor",      status: "new",      priority: "P3", sla: "on-track", assignee: null, requester: "Felix B. · Project Mgmt",       entity: "HVHK", createdAgo: "2h",  dueIn: "1d 21h", custom: { category: "access",   device: "—",                asset: "—",          urgency: "normal" } },
  { id: "TKT-2017", type: "it_request",       subject: "Password reset — admin portal locked out",         status: "resolved", priority: "P2", sla: "on-track", assignee: "AK", requester: "Maya C. · Procurement Director", entity: "HVPH", createdAgo: "1d",  dueIn: "—",      custom: { category: "access",   device: "—",                asset: "—",          urgency: "high" } },

  /* Facilities · 3 */
  { id: "TKT-3015", type: "facility_request", subject: "Aircon broken — Manila office, 5F west wing",      status: "open",     priority: "P1", sla: "at-risk",  assignee: "BP", requester: "Helena Cruz · Facilities point", entity: "HVPH", createdAgo: "3h",  dueIn: "9h",     custom: { location: "HVPH · 5F West",     equipment: "HVAC unit · split-type",   severity: "high",   asset: "FA-PH-0042", photoCount: 2 } },
  { id: "TKT-3014", type: "facility_request", subject: "Printer jam — SG office, finance corner",          status: "open",     priority: "P3", sla: "on-track", assignee: "GC", requester: "Lin Wei · Finance SG",          entity: "HVSG", createdAgo: "5h",  dueIn: "1d 4h",  custom: { location: "HVSG · 3F NE corner", equipment: "Printer · HP LJ M501",      severity: "low",    asset: "FA-SG-0078", photoCount: 1 } },
  { id: "TKT-3013", type: "facility_request", subject: "Lighting flickering — HK lobby",                   status: "pending",  priority: "P3", sla: "on-track", assignee: "BP", requester: "Akira Tanaka · Operations HK",  entity: "HVHK", createdAgo: "1d",  dueIn: "2d 1h",  custom: { location: "HVHK · Ground lobby", equipment: "LED panel · suspended ceiling", severity: "low", asset: "FA-HK-0124", photoCount: 0 } },

  /* HR Case · 2 */
  { id: "TKT-4011", type: "hr_case",          subject: "Leave dispute · annual vs sick balance",           status: "open",     priority: "P2", sla: "on-track", assignee: "EL", requester: "Confidential · MID-1042",       entity: "HVPH", createdAgo: "1d",  dueIn: "2d 6h",  custom: { category: "leave-dispute", confidential: true,  employee: "MID-1042 (confidential)", openedBy: "self" } },
  { id: "TKT-4010", type: "hr_case",          subject: "External certification training request",          status: "pending",  priority: "P3", sla: "on-track", assignee: "JM", requester: "Tomas R. · Procurement",         entity: "HVSG", createdAgo: "2d",  dueIn: "3d",     custom: { category: "training",        confidential: false, employee: "Tomas R.",               openedBy: "self" } },

  /* Project Issue · 6 */
  { id: "TKT-5031", type: "project_issue",    subject: "API integration · vendor SDK breaking change",     status: "open",     priority: "P1", sla: "breached", assignee: "FB", requester: "Felix B. · Sprint 24",          entity: "HVPH", createdAgo: "2d",  dueIn: "−1d 6h", custom: { project: "PRJ-2026-008 · Cenora Mobile",  sprint: "S24",  blocker: true,  story: "STY-218" } },
  { id: "TKT-5030", type: "project_issue",    subject: "Design review pending · onboarding flow",          status: "pending",  priority: "P2", sla: "on-track", assignee: "KL", requester: "Maya C. · PM",                    entity: "HVPH", createdAgo: "1d",  dueIn: "1d 8h",  custom: { project: "PRJ-2026-008 · Cenora Mobile",  sprint: "S24",  blocker: false, story: "STY-202" } },
  { id: "TKT-5029", type: "project_issue",    subject: "Test data missing for QA cycle",                    status: "open",     priority: "P2", sla: "at-risk",  assignee: "FB", requester: "QA team",                        entity: "HVSG", createdAgo: "8h",  dueIn: "3h 20m", custom: { project: "PRJ-2026-008 · Cenora Mobile",  sprint: "S24",  blocker: true,  story: "STY-194" } },
  { id: "TKT-5028", type: "project_issue",    subject: "Deployment environment broken · staging",          status: "open",     priority: "P1", sla: "at-risk",  assignee: "FB", requester: "DevOps",                         entity: "HVPH", createdAgo: "4h",  dueIn: "32m",    custom: { project: "PRJ-2026-012 · ERP Rollout HK", sprint: "S07",  blocker: true,  story: "STY-088" } },
  { id: "TKT-5027", type: "project_issue",    subject: "Scope clarification needed · GL mapping",          status: "pending",  priority: "P3", sla: "on-track", assignee: "KL", requester: "Maria A. · Accounting",         entity: "HVSG", createdAgo: "1d",  dueIn: "2d 12h", custom: { project: "PRJ-2026-012 · ERP Rollout HK", sprint: "S07",  blocker: false, story: "STY-076" } },
  { id: "TKT-5026", type: "project_issue",    subject: "External translator deliverable late · INR docs",  status: "open",     priority: "P3", sla: "at-risk",  assignee: "KL", requester: "Priya I. · India ops",          entity: "HVIN", createdAgo: "1d",  dueIn: "12h 41m", custom: { project: "PRJ-2026-015 · INR Localization", sprint: "S04", blocker: true,  story: "STY-040" } },

  /* Asset Request · 4 */
  { id: "TKT-6021", type: "asset_request",    subject: "Forklift FK-007 — service due (overdue 4 days)",   status: "open",     priority: "P2", sla: "breached", assignee: "NS", requester: "Auto · scheduler",               entity: "HVPH", createdAgo: "4d",  dueIn: "−1d",    custom: { asset: "FA-PH-0211 · Forklift FK-007", issueType: "preventive",  downtime: "potential",  manufacturer: "Yale" } },
  { id: "TKT-6020", type: "asset_request",    subject: "Delivery van WK-22 — annual inspection due",        status: "pending",  priority: "P3", sla: "on-track", assignee: "NS", requester: "Auto · scheduler",               entity: "HVSG", createdAgo: "1d",  dueIn: "5d",     custom: { asset: "FA-SG-0084 · Van WK-22",        issueType: "preventive",  downtime: "none",       manufacturer: "Toyota" } },
  { id: "TKT-6019", type: "asset_request",    subject: "Production server PS-04 — warranty expiring",       status: "new",      priority: "P3", sla: "on-track", assignee: null, requester: "Auto · scheduler",               entity: "HVHK", createdAgo: "6h",  dueIn: "4d",     custom: { asset: "FA-HK-0011 · Server PS-04",     issueType: "warranty",    downtime: "none",       manufacturer: "Dell" } },
  { id: "TKT-6018", type: "asset_request",    subject: "Compressor #3 — vibration above threshold",         status: "open",     priority: "P2", sla: "at-risk",  assignee: "NS", requester: "Sensor alert · CMMS",            entity: "HVPH", createdAgo: "8h",  dueIn: "16h",    custom: { asset: "FA-PH-0188 · Compressor #3",    issueType: "reactive",     downtime: "active",     manufacturer: "Atlas Copco" } },
]

/* ─── SLA rules ─────────────────────────────────────────────────────── */
const TKT_SLA_RULES = [
  { id: "SLA-01", type: "customer_support", priority: "P1", firstResponseMin: 15,  resolveHours: 4,   hours: "24/7",           escalateTo: "Tier-2 lead" },
  { id: "SLA-02", type: "customer_support", priority: "P2", firstResponseMin: 30,  resolveHours: 8,   hours: "Business",       escalateTo: "Tier-2 lead" },
  { id: "SLA-03", type: "customer_support", priority: "P3", firstResponseMin: 120, resolveHours: 24,  hours: "Business",       escalateTo: "—" },
  { id: "SLA-04", type: "it_request",       priority: "P1", firstResponseMin: 30,  resolveHours: 4,   hours: "Business + on-call", escalateTo: "IT Admin" },
  { id: "SLA-05", type: "it_request",       priority: "P2", firstResponseMin: 60,  resolveHours: 24,  hours: "Business",       escalateTo: "IT Admin" },
  { id: "SLA-06", type: "facility_request", priority: "P1", firstResponseMin: 30,  resolveHours: 8,   hours: "24/7",           escalateTo: "Facilities Mgr" },
  { id: "SLA-07", type: "facility_request", priority: "P2", firstResponseMin: 120, resolveHours: 48,  hours: "Business",       escalateTo: "Facilities Mgr" },
  { id: "SLA-08", type: "hr_case",          priority: "P2", firstResponseMin: 240, resolveHours: 72,  hours: "Business",       escalateTo: "HR Director" },
  { id: "SLA-09", type: "project_issue",    priority: "P1", firstResponseMin: 60,  resolveHours: 24,  hours: "Business",       escalateTo: "PM lead" },
  { id: "SLA-10", type: "asset_request",    priority: "P2", firstResponseMin: 480, resolveHours: 120, hours: "Business",       escalateTo: "Facilities Mgr" },
]

/* ─── Automation rules ──────────────────────────────────────────────── */
const TKT_AUTOMATIONS = [
  { id: "AUT-01", name: "Unassigned > 1h → notify supervisor",          trigger: "stale_unassigned",  type: "any",              enabled: true,  fired: 14 },
  { id: "AUT-02", name: "P1 breach risk → escalate to lead",            trigger: "sla_at_risk",       type: "customer_support", enabled: true,  fired: 8  },
  { id: "AUT-03", name: "Customer replies → re-open closed ticket",     trigger: "customer_reply",    type: "customer_support", enabled: true,  fired: 42 },
  { id: "AUT-04", name: "Same asset + 2 tickets in 7d → mark recurring", trigger: "recurring_asset",   type: "facility_request", enabled: true,  fired: 6  },
  { id: "AUT-05", name: "Auto-CSAT survey on resolve",                  trigger: "ticket_resolved",   type: "customer_support", enabled: true,  fired: 124 },
  { id: "AUT-06", name: "Joiner setup checklist on new hire",           trigger: "new_employee",      type: "it_request",       enabled: true,  fired: 18 },
  { id: "AUT-07", name: "Maintenance due → auto-create work order",     trigger: "maintenance_due",   type: "asset_request",    enabled: true,  fired: 28 },
  { id: "AUT-08", name: "Confidential HR case → restrict visibility",   trigger: "tag_confidential",  type: "hr_case",          enabled: true,  fired: 4  },
]

/* ─── Knowledge base (shared) ───────────────────────────────────────── */
const TKT_KB = [
  { id: "KB-CS-014",  type: "customer_support", title: "How to add a shipping address", deflections: 142, lastReviewed: "Mar 18" },
  { id: "KB-CS-018",  type: "customer_support", title: "VAT/EWT on PH invoices",         deflections: 188, lastReviewed: "Apr 02" },
  { id: "KB-CS-027",  type: "customer_support", title: "Opening a warranty RMA",          deflections: 91,  lastReviewed: "Apr 11" },
  { id: "KB-IT-008",  type: "it_request",       title: "Reset corporate Wi-Fi password",  deflections: 84,  lastReviewed: "Apr 14" },
  { id: "KB-IT-014",  type: "it_request",       title: "VPN setup · macOS / Windows",     deflections: 56,  lastReviewed: "Mar 28" },
  { id: "KB-FC-006",  type: "facility_request", title: "Report a leak in office",         deflections: 21,  lastReviewed: "Mar 02" },
  { id: "KB-HR-002",  type: "hr_case",          title: "Leave balance calculation",       deflections: 38,  lastReviewed: "Feb 18" },
  { id: "KB-AS-004",  type: "asset_request",    title: "Reporting equipment damage",      deflections: 18,  lastReviewed: "Mar 22" },
]

/* ─── KPIs for /tickets module home ─────────────────────────────────── */
const TKT_KPIS = {
  openAll: 27,
  byType: { customer_support: 8, it_request: 5, facility_request: 3, hr_case: 2, project_issue: 6, asset_request: 4 },
  breached: 4, atRisk: 7,
  resolvedToday: 24,
  medianFirstResponse: "0h 38m",
  medianResolve: "6h 12m",
  csat: 92.4,
  deflectedToday: 38,
  aiAutoResolveRate: 22.4,   /* % of inbound */
}

/* ─── Helpers ───────────────────────────────────────────────────────── */
function tktByType(typeId: string) { return (TKT_TICKETS as any[]).filter(t => t.type === typeId) }
function tktAgent(initials: string) { return (TKT_AGENTS as any[]).find(a => a.initials === initials) || null }
function tktType(typeId: string)  { return (TKT_TYPES   as any[]).find(t => t.id === typeId) || null }

/* SANDBOX exports */
const _tktExports = { TKT_TYPES, TKT_AGENTS, TKT_TICKETS, TKT_SLA_RULES, TKT_AUTOMATIONS, TKT_KB, TKT_KPIS, tktByType, tktAgent, tktType }
Object.assign(globalThis as any, _tktExports)

})();/*__IIFE_WRAP_END__*/

/* ═════ apps/web/lib/mock/customer-service.tsx ═════ */
;/*__IIFE_WRAP_START__*/(function(){
/**
 * apps/web/lib/mock/customer-service.tsx
 * Customer Service / Contact Centre — voice/SIP calls, IVR, agent
 * routing, omnichannel inbox. Tickets queue itself reuses tickets.tsx
 * filtered to customer_support type (and the existing /support legacy
 * data for richer detail content).
 */

const CS_KPIS = {
  queueDepth: 14,
  longestWait: "4m 22s",
  agentsOnline: 6,
  agentsAvail: 3,
  agentsOnCall: 2,
  agentsAway: 1,
  callsToday: 142, callsAnswered: 124, callsMissed: 18, callsAbandoned: 4,
  avgWait: "1m 12s",
  avgHandle: "4m 38s",
  fcr: 78.4,
  csat: 4.2,
  csatResponseRate: 87,
  channels: { voice: 38, whatsapp: 28, email: 24, chat: 18, sms: 6, telegram: 4, viber: 2 },
}

const CS_QUEUES = [
  { id: "Q-GEN", label: "General Support · EN",  language: "English",                agents: 4, waiting: 6, longestWait: "2m 12s", slaPct: 96.2 },
  { id: "Q-VIP", label: "VIP · Tier-1",          language: "English",                agents: 2, waiting: 2, longestWait: "0m 38s", slaPct: 99.0 },
  { id: "Q-RET", label: "Returns · Multi-lang",  language: "EN · ZH · FIL · HI",     agents: 3, waiting: 4, longestWait: "4m 22s", slaPct: 92.4 },
  { id: "Q-BIL", label: "Billing & Disputes",    language: "English",                agents: 1, waiting: 2, longestWait: "1m 48s", slaPct: 94.1 },
]

const CS_AGENTS = [
  { initials: "SM", name: "Sofia M.",     tone: "amber", role: "CS Lead",            languages: ["EN", "FIL"],          queues: ["Q-GEN","Q-VIP","Q-BIL"], status: "available", currentCall: null, csatRolling: 96.4, handledToday: 18 },
  { initials: "OP", name: "Olivia P.",    tone: "amber", role: "Senior CS",          languages: ["EN", "ZH"],           queues: ["Q-GEN","Q-RET"],         status: "on-call",   currentCall: "0:04:12 · Globe Telecom",    csatRolling: 94.1, handledToday: 14 },
  { initials: "MR", name: "Maya R.",      tone: "blue",  role: "CS Agent",           languages: ["EN"],                 queues: ["Q-GEN","Q-BIL"],          status: "available", currentCall: null, csatRolling: 92.8, handledToday: 12 },
  { initials: "CB", name: "Carlos B.",    tone: "blue",  role: "CS Agent",            languages: ["EN", "FIL"],          queues: ["Q-GEN","Q-RET"],         status: "on-call",   currentCall: "0:02:38 · Metro Retail SG",   csatRolling: 95.0, handledToday: 10 },
  { initials: "NT", name: "Niko T.",      tone: "teal",  role: "CS Agent",            languages: ["EN"],                 queues: ["Q-GEN"],                 status: "away",      currentCall: null, csatRolling: 91.2, handledToday: 7  },
  { initials: "RP", name: "Rina P.",      tone: "teal",  role: "CS Agent",            languages: ["EN", "FIL"],          queues: ["Q-GEN","Q-VIP"],         status: "available", currentCall: null, csatRolling: 93.7, handledToday: 9  },
  { initials: "JL", name: "Jin L.",       tone: "ink",   role: "CS Agent · HK",       languages: ["EN", "ZH", "YUE"],   queues: ["Q-RET","Q-GEN"],         status: "available", currentCall: null, csatRolling: 95.2, handledToday: 11 },
  { initials: "AI", name: "Cenora AI",    tone: "ink",   role: "Tier-0 deflection",  languages: ["all"],                queues: ["all"],                   status: "available", currentCall: null, csatRolling: 88.4, handledToday: 38 },
]

const CS_CALLS = [
  { id: "CALL-2826", direction: "inbound",  status: "in-progress", queue: "Q-VIP", agent: "OP", from: "+63 917 555 0184", customer: "Globe Telecom · Jose Reyes",    duration: "0:04:12", startedAgo: "4m", sentiment: "neutral" },
  { id: "CALL-2825", direction: "inbound",  status: "in-progress", queue: "Q-RET", agent: "CB", from: "+65 8123 4422",    customer: "Metro Retail SG · Mei Lin Tan", duration: "0:02:38", startedAgo: "2m", sentiment: "neutral" },
  { id: "CALL-2824", direction: "inbound",  status: "in-queue",    queue: "Q-GEN", agent: null, from: "+852 9024 8124",   customer: "Park Hospitality · Hana P.",    duration: "0:01:08", startedAgo: "1m", sentiment: "—" },
  { id: "CALL-2823", direction: "inbound",  status: "in-queue",    queue: "Q-RET", agent: null, from: "+91 98765 11042",  customer: "Aurora Mfg · Priya I.",         duration: "0:00:42", startedAgo: "<1m", sentiment: "—" },
  { id: "CALL-2822", direction: "outbound", status: "completed",   queue: "Q-VIP", agent: "SM", from: "+1 415-555-0142", customer: "Walsh Homes · Connor W.",      duration: "0:08:14", startedAgo: "32m", sentiment: "positive" },
  { id: "CALL-2821", direction: "inbound",  status: "missed",      queue: "Q-GEN", agent: null, from: "+63 917 421 0042", customer: "Sunlight Solar PH",            duration: "—",       startedAgo: "48m", sentiment: "—" },
  { id: "CALL-2820", direction: "inbound",  status: "completed",   queue: "Q-BIL", agent: "MR", from: "+63 917 211 4400", customer: "Diaz Enterprises",            duration: "0:06:42", startedAgo: "1h",  sentiment: "neutral" },
  { id: "CALL-2819", direction: "outbound", status: "completed",   queue: "Q-VIP", agent: "SM", from: "+65 9183 2244",    customer: "BuildRight SG",               duration: "0:04:18", startedAgo: "1h 14m", sentiment: "positive" },
  { id: "CALL-2818", direction: "inbound",  status: "completed",   queue: "Q-GEN", agent: "RP", from: "+63 917 884 0021", customer: "Felicity Cruz",               duration: "0:03:42", startedAgo: "1h 38m", sentiment: "positive" },
  { id: "CALL-2817", direction: "inbound",  status: "missed",      queue: "Q-GEN", agent: null, from: "+852 9011 1188",   customer: "Weicraft HK",                 duration: "—",       startedAgo: "2h",  sentiment: "—" },
  { id: "CALL-2816", direction: "inbound",  status: "completed",   queue: "Q-RET", agent: "JL", from: "+852 6044 9912",   customer: "Summit Engineering · Akira T.", duration: "0:09:14", startedAgo: "2h 22m", sentiment: "negative" },
  { id: "CALL-2815", direction: "inbound",  status: "completed",   queue: "Q-GEN", agent: "OP", from: "+61 412 003 411",   customer: "Hartmann Aus.",              duration: "0:05:42", startedAgo: "3h",  sentiment: "positive" },
]

const CS_IVR = {
  name: "Main IVR · Helios Vertex",
  language: "EN (auto-detect ZH, FIL, HI)",
  branches: [
    { key: "1", label: "Existing customer · billing & invoicing", route: "Q-BIL" },
    { key: "2", label: "Order status · deliveries",                 route: "Q-GEN" },
    { key: "3", label: "Returns · warranty",                         route: "Q-RET" },
    { key: "4", label: "New customer · sales",                       route: "Q-GEN" },
    { key: "*", label: "Speak to an agent (skip menu)",             route: "Q-GEN" },
  ],
  voicemail: "If outside business hours, please leave a message. We will call back within 4 business hours.",
}

const CS_OMNI_THREADS = [
  { id: "OM-001", channel: "whatsapp", customer: "Globe Telecom · Jose Reyes",    preview: "Need help with invoice INV-2026-1184 …",                  ts: "12m",  unread: true,  status: "open",     sentiment: "neutral" },
  { id: "OM-002", channel: "email",    customer: "Metro Retail SG · Mei Lin Tan", preview: "Order delivery delayed? SO-0884 — when can we expect …",   ts: "38m",  unread: true,  status: "open",     sentiment: "neutral" },
  { id: "OM-003", channel: "chat",     customer: "Park Hospitality · Hana P.",    preview: "RMA process for damaged unit?",                            ts: "1h",   unread: false, status: "open",     sentiment: "neutral" },
  { id: "OM-004", channel: "whatsapp", customer: "Felicity Cruz",                  preview: "Thank you, all sorted!",                                   ts: "2h",   unread: false, status: "resolved", sentiment: "positive" },
  { id: "OM-005", channel: "telegram", customer: "@miguel_ph",                     preview: "Hi, just signed up — onboarding question",                ts: "2h",   unread: false, status: "open",     sentiment: "neutral" },
  { id: "OM-006", channel: "sms",      customer: "+63 917 084 1102",               preview: "Where's my courier? Order #SO-0871",                       ts: "3h",   unread: true,  status: "open",     sentiment: "negative" },
  { id: "OM-007", channel: "viber",    customer: "Marco Diaz",                     preview: "Promo code not working at checkout",                       ts: "4h",   unread: false, status: "pending",  sentiment: "neutral" },
  { id: "OM-008", channel: "email",    customer: "Sophie Hartmann",                preview: "Bulk pricing question — 100+ users",                       ts: "5h",   unread: false, status: "open",     sentiment: "neutral" },
  { id: "OM-009", channel: "chat",     customer: "Daniel Ng",                      preview: "Login locked, password reset link didn't arrive",          ts: "6h",   unread: true,  status: "open",     sentiment: "negative" },
  { id: "OM-010", channel: "whatsapp", customer: "Ravi Subramanian",               preview: "Quote ref 2026-0188 — any updates?",                       ts: "1d",   unread: false, status: "open",     sentiment: "neutral" },
]

const CS_VOLUME_24H = [
  /* hour-bucketed inbound contact volume — 24 entries */
  4, 3, 2, 1, 1, 2, 6, 14, 24, 32, 28, 31, 22, 26, 34, 38, 32, 28, 18, 12, 8, 6, 4, 3,
]

const _csExports = { CS_KPIS, CS_QUEUES, CS_AGENTS, CS_CALLS, CS_IVR, CS_OMNI_THREADS, CS_VOLUME_24H }
Object.assign(globalThis as any, _csExports)

})();/*__IIFE_WRAP_END__*/

/* ═════ apps/web/lib/mock/it-ops.tsx ═════ */
;/*__IIFE_WRAP_START__*/(function(){
/**
 * apps/web/lib/mock/it-ops.tsx
 * IT module mock — devices, software/SaaS licenses, joiner/mover/leaver tasks.
 * Ticket data lives in mock/tickets.tsx (it_request type).
 */

const IT_KPIS = {
  openTickets: 5,
  devices: 412, devicesAssigned: 384, devicesAvailable: 18, devicesEOL: 10,
  licensesTotal: 24, licensesUtilized: 0.78, licensesRenewSoon: 4,
  joinersThisMonth: 6, leaversThisMonth: 2,
  mttr: "6h 42m",
}

const IT_DEVICES = [
  { id: "DEV-001", tag: "HVPH-LAP-0184", type: "Laptop",   model: "MacBook Pro 14",        owner: "Maria A.",   entity: "HVPH", status: "in-service", warrantyEnds: "Jun 2027", asset: "FA-PH-0184" },
  { id: "DEV-002", tag: "HVPH-LAP-0212", type: "Laptop",   model: "Dell XPS 13",            owner: "Maya C.",     entity: "HVPH", status: "in-service", warrantyEnds: "Sep 2026", asset: "FA-PH-0212" },
  { id: "DEV-003", tag: "HVPH-LAP-0241", type: "Laptop",   model: "MacBook Air M3",         owner: "Sofia M.",   entity: "HVPH", status: "in-service", warrantyEnds: "Mar 2028", asset: "FA-PH-0241" },
  { id: "DEV-004", tag: "HVSG-LAP-0088", type: "Laptop",   model: "ThinkPad T14",           owner: "Lin Wei",    entity: "HVSG", status: "in-service", warrantyEnds: "Apr 2026", asset: "FA-SG-0088" },
  { id: "DEV-005", tag: "HVSG-LAP-0091", type: "Laptop",   model: "MacBook Pro 16",         owner: "Tomas R.",   entity: "HVSG", status: "provisioning", warrantyEnds: "Apr 2028", asset: "—" },
  { id: "DEV-006", tag: "HVHK-LAP-0044", type: "Laptop",   model: "Dell Latitude 7440",    owner: "Akira T.",   entity: "HVHK", status: "in-service", warrantyEnds: "Aug 2025", asset: "FA-HK-0044" },
  { id: "DEV-007", tag: "HVPH-DSK-0021", type: "Desktop",  model: "iMac 24",                owner: "Design pod", entity: "HVPH", status: "in-service", warrantyEnds: "Nov 2026", asset: "FA-PH-0021" },
  { id: "DEV-008", tag: "HVPH-MON-0048", type: "Monitor",  model: "LG 27UN850",             owner: "Maria A.",   entity: "HVPH", status: "in-service", warrantyEnds: "Mar 2026", asset: "FA-PH-0148" },
  { id: "DEV-009", tag: "HVSG-PHN-0014", type: "Phone",    model: "iPhone 14 Pro",          owner: "Lin Wei",    entity: "HVSG", status: "in-service", warrantyEnds: "—",        asset: "FA-SG-0114" },
  { id: "DEV-010", tag: "HVPH-TAB-0009", type: "Tablet",   model: "iPad Pro 11",            owner: "Sales pod",  entity: "HVPH", status: "available",  warrantyEnds: "Jul 2026", asset: "FA-PH-0109" },
  { id: "DEV-011", tag: "HVAU-LAP-0019", type: "Laptop",   model: "MacBook Pro 13",         owner: "Connor W.",  entity: "HVAU", status: "in-service", warrantyEnds: "Dec 2024", asset: "FA-AU-0019" },
  { id: "DEV-012", tag: "HVIN-LAP-0034", type: "Laptop",   model: "Dell Vostro 14",         owner: "Priya I.",   entity: "HVIN", status: "in-service", warrantyEnds: "Feb 2025", asset: "FA-IN-0034" },
]

const IT_SOFTWARE = [
  { id: "SW-001", name: "Microsoft 365 · Business",   vendor: "Microsoft", seatsTotal: 412, seatsUsed: 384, costMonth: 8240, renewsOn: "Sep 2026", autoRenew: true },
  { id: "SW-002", name: "Adobe Creative Cloud",       vendor: "Adobe",     seatsTotal: 18,  seatsUsed: 14,  costMonth: 1080, renewsOn: "Jul 2026", autoRenew: true },
  { id: "SW-003", name: "Atlassian Jira + Confluence", vendor: "Atlassian", seatsTotal: 80,  seatsUsed: 68,  costMonth: 920,  renewsOn: "Jun 2026", autoRenew: true },
  { id: "SW-004", name: "Slack Business+",            vendor: "Slack",     seatsTotal: 412, seatsUsed: 396, costMonth: 4944, renewsOn: "Mar 2027", autoRenew: true },
  { id: "SW-005", name: "Zoom · One Business",        vendor: "Zoom",      seatsTotal: 80,  seatsUsed: 72,  costMonth: 1600, renewsOn: "May 2026", autoRenew: false },
  { id: "SW-006", name: "Figma · Organization",       vendor: "Figma",     seatsTotal: 28,  seatsUsed: 22,  costMonth: 1232, renewsOn: "Aug 2026", autoRenew: true },
  { id: "SW-007", name: "1Password Business",         vendor: "1Password", seatsTotal: 412, seatsUsed: 384, costMonth: 3296, renewsOn: "Feb 2027", autoRenew: true },
  { id: "SW-008", name: "Notion · Team",              vendor: "Notion",    seatsTotal: 60,  seatsUsed: 38,  costMonth: 600,  renewsOn: "Oct 2026", autoRenew: true },
  { id: "SW-009", name: "Tableau · Creator",          vendor: "Tableau",   seatsTotal: 14,  seatsUsed: 9,   costMonth: 980,  renewsOn: "Jun 2026", autoRenew: false },
  { id: "SW-010", name: "Datadog · Pro",              vendor: "Datadog",   seatsTotal: 24,  seatsUsed: 22,  costMonth: 1680, renewsOn: "Dec 2026", autoRenew: true },
  { id: "SW-011", name: "GitHub Enterprise",          vendor: "GitHub",    seatsTotal: 32,  seatsUsed: 28,  costMonth: 672,  renewsOn: "May 2026", autoRenew: true },
  { id: "SW-012", name: "Linear",                     vendor: "Linear",    seatsTotal: 28,  seatsUsed: 21,  costMonth: 280,  renewsOn: "Apr 2027", autoRenew: true },
]

const IT_ACCESS = [
  { id: "AX-001", employee: "Tomas R. · Procurement SG",  type: "joiner", status: "in-progress", taskCount: 8, completed: 5, target: "Apr 30" },
  { id: "AX-002", employee: "Anna L. · Marketing PH",     type: "joiner", status: "in-progress", taskCount: 7, completed: 7, target: "Apr 29" },
  { id: "AX-003", employee: "Vince R. · IT HK",            type: "mover",  status: "in-progress", taskCount: 5, completed: 2, target: "May 02" },
  { id: "AX-004", employee: "Henry W. · CRM AU",           type: "leaver", status: "in-progress", taskCount: 6, completed: 3, target: "Apr 30" },
  { id: "AX-005", employee: "Lara M. · Sales PH",          type: "joiner", status: "complete",    taskCount: 8, completed: 8, target: "Apr 22" },
]

const IT_TREND_30D = [3, 4, 2, 5, 4, 6, 4, 5, 7, 3, 4, 6, 5, 4, 8, 6, 5, 4, 7, 5, 3, 6, 5, 4, 8, 6, 7, 5, 4, 5]

const _itExports = { IT_KPIS, IT_DEVICES, IT_SOFTWARE, IT_ACCESS, IT_TREND_30D }
Object.assign(globalThis as any, _itExports)

})();/*__IIFE_WRAP_END__*/

/* ═════ apps/web/lib/mock/facilities.tsx ═════ */
;/*__IIFE_WRAP_START__*/(function(){
/**
 * apps/web/lib/mock/facilities.tsx
 * Facilities module mock — building/floor/equipment registry, work orders,
 * room bookings, vendor list. Ticket data lives in mock/tickets.tsx
 * (facility_request type).
 */

const FAC_KPIS = {
  openWorkOrders: 14,
  overdue: 2,
  ppmCompliance: 96.4,
  assetHealth: 94.1,
  buildings: 5,
  rooms: 184,
  hotDesks: 132,
  hotDesksBooked: 86,
  vendorsActive: 18,
}

const FAC_BUILDINGS = [
  { id: "BLDG-PH", name: "HVPH · Manila HQ",   address: "BGC, Taguig City, Metro Manila",     floors: 12, equipment: 84, openTickets: 5, ppmDue: 3 },
  { id: "BLDG-SG", name: "HVSG · Singapore",   address: "Marina One, 5 Straits View",         floors: 8,  equipment: 56, openTickets: 3, ppmDue: 2 },
  { id: "BLDG-HK", name: "HVHK · Hong Kong",    address: "Central Plaza, Wan Chai",            floors: 6,  equipment: 42, openTickets: 2, ppmDue: 1 },
  { id: "BLDG-AU", name: "HVAU · Sydney",      address: "1 Martin Place, Sydney CBD",         floors: 4,  equipment: 28, openTickets: 1, ppmDue: 0 },
  { id: "BLDG-IN", name: "HVIN · Mumbai",      address: "BKC, Bandra Kurla Complex",          floors: 3,  equipment: 18, openTickets: 3, ppmDue: 2 },
]

const FAC_WORK_ORDERS = [
  { id: "WO-2026-184", kind: "reactive",   asset: "HVAC · 5F West HVPH",         status: "in-progress", assignee: "Ben P.",  vendor: "Cooltech PH",     scheduled: "Today",     priority: "P1" },
  { id: "WO-2026-183", kind: "preventive", asset: "Lift A · HVPH",                status: "scheduled",   assignee: "Vendor",  vendor: "OTIS service",     scheduled: "May 02",    priority: "P3" },
  { id: "WO-2026-182", kind: "preventive", asset: "Fire suppression · HVSG L3",   status: "scheduled",   assignee: "Vendor",  vendor: "SafeGuard SG",     scheduled: "May 05",    priority: "P2" },
  { id: "WO-2026-181", kind: "reactive",   asset: "Printer · HVSG Finance corner", status: "in-progress", assignee: "Grace C.", vendor: "—",              scheduled: "Today",     priority: "P3" },
  { id: "WO-2026-180", kind: "reactive",   asset: "Lighting · HVHK lobby",         status: "scheduled",   assignee: "Ben P.",  vendor: "BrightHK",         scheduled: "Apr 30",    priority: "P3" },
  { id: "WO-2026-179", kind: "inspection", asset: "Sprinkler check · HVPH",        status: "completed",   assignee: "Vendor",  vendor: "SafeGuard PH",     scheduled: "Apr 22",    priority: "P2" },
  { id: "WO-2026-178", kind: "preventive", asset: "Generator monthly · HVPH",      status: "completed",   assignee: "Vendor",  vendor: "PowerPro PH",      scheduled: "Apr 18",    priority: "P3" },
  { id: "WO-2026-177", kind: "reactive",   asset: "Aircon · HVIN reception",       status: "scheduled",   assignee: "Grace C.", vendor: "CoolAir IN",      scheduled: "Apr 30",    priority: "P2" },
  { id: "WO-2026-176", kind: "preventive", asset: "Building security cameras",    status: "scheduled",   assignee: "Vendor",  vendor: "SecureWatch",      scheduled: "May 12",    priority: "P3" },
  { id: "WO-2026-175", kind: "reactive",   asset: "Reception door auto-close",     status: "in-progress", assignee: "Ben P.",  vendor: "—",                scheduled: "Apr 29",    priority: "P3" },
  { id: "WO-2026-174", kind: "preventive", asset: "HVAC quarterly · HVAU",          status: "scheduled",   assignee: "Vendor",  vendor: "AirAU",            scheduled: "May 06",    priority: "P3" },
  { id: "WO-2026-173", kind: "reactive",   asset: "Loose tile · HVPH 7F break",    status: "overdue",     assignee: "Ben P.",  vendor: "—",                scheduled: "Apr 24",    priority: "P3" },
  { id: "WO-2026-172", kind: "reactive",   asset: "Tap leak · HVHK pantry",         status: "overdue",     assignee: "Ben P.",  vendor: "FixIt HK",         scheduled: "Apr 23",    priority: "P2" },
  { id: "WO-2026-171", kind: "inspection", asset: "Pest control · HVIN",            status: "scheduled",   assignee: "Vendor",  vendor: "Pestaway IN",      scheduled: "May 02",    priority: "P3" },
]

const FAC_ROOMS = [
  { id: "RM-PH-501", building: "BLDG-PH", floor: "5F", name: "Boardroom · Apollo",   capacity: 14, bookings: 4, nextSlot: "10:30 today" },
  { id: "RM-PH-502", building: "BLDG-PH", floor: "5F", name: "Huddle · Vega",        capacity: 6,  bookings: 8, nextSlot: "11:00 today" },
  { id: "RM-PH-503", building: "BLDG-PH", floor: "5F", name: "Phone booth · #3",     capacity: 1,  bookings: 12, nextSlot: "09:30 today" },
  { id: "RM-PH-401", building: "BLDG-PH", floor: "4F", name: "Conf · Halley",        capacity: 10, bookings: 3, nextSlot: "14:00 today" },
  { id: "RM-SG-301", building: "BLDG-SG", floor: "3F", name: "Boardroom · Orchid",    capacity: 16, bookings: 2, nextSlot: "13:00 today" },
  { id: "RM-SG-302", building: "BLDG-SG", floor: "3F", name: "Huddle · Lily",         capacity: 6,  bookings: 6, nextSlot: "10:00 today" },
  { id: "RM-HK-201", building: "BLDG-HK", floor: "2F", name: "Boardroom · Peony",     capacity: 12, bookings: 3, nextSlot: "15:00 today" },
  { id: "RM-AU-101", building: "BLDG-AU", floor: "1F", name: "Boardroom · Wattle",    capacity: 10, bookings: 2, nextSlot: "12:30 today" },
]

const FAC_VENDORS = [
  { id: "VND-FC-01", name: "Cooltech PH",      service: "HVAC",          city: "Manila",    rating: 4.6, openWO: 3, contract: "Annual · renews Oct" },
  { id: "VND-FC-02", name: "OTIS service",     service: "Lifts/Elevators", city: "Multi-region", rating: 4.8, openWO: 2, contract: "Multi-year" },
  { id: "VND-FC-03", name: "SafeGuard PH",     service: "Fire safety",   city: "Manila",    rating: 4.7, openWO: 1, contract: "Annual" },
  { id: "VND-FC-04", name: "SafeGuard SG",     service: "Fire safety",   city: "Singapore", rating: 4.7, openWO: 1, contract: "Annual" },
  { id: "VND-FC-05", name: "BrightHK",         service: "Lighting",      city: "Hong Kong", rating: 4.5, openWO: 1, contract: "Ad-hoc" },
  { id: "VND-FC-06", name: "AirAU",            service: "HVAC",          city: "Sydney",    rating: 4.4, openWO: 1, contract: "Annual" },
  { id: "VND-FC-07", name: "PowerPro PH",      service: "Generators",    city: "Manila",    rating: 4.6, openWO: 0, contract: "Monthly" },
  { id: "VND-FC-08", name: "SecureWatch",      service: "Security",      city: "Multi-region", rating: 4.5, openWO: 1, contract: "Annual" },
  { id: "VND-FC-09", name: "Pestaway IN",      service: "Pest control",  city: "Mumbai",    rating: 4.3, openWO: 0, contract: "Quarterly" },
  { id: "VND-FC-10", name: "CleanCo PH",       service: "Cleaning",      city: "Manila",    rating: 4.4, openWO: 0, contract: "Daily" },
  { id: "VND-FC-11", name: "CleanRight SG",     service: "Cleaning",      city: "Singapore", rating: 4.7, openWO: 0, contract: "Daily" },
  { id: "VND-FC-12", name: "GardenAU",         service: "Landscaping",   city: "Sydney",    rating: 4.2, openWO: 0, contract: "Bi-weekly" },
]

const _facExports = { FAC_KPIS, FAC_BUILDINGS, FAC_WORK_ORDERS, FAC_ROOMS, FAC_VENDORS }
Object.assign(globalThis as any, _facExports)

})();/*__IIFE_WRAP_END__*/

/* ═════ apps/web/lib/mock/marketing.tsx ═════ */
;/*__IIFE_WRAP_START__*/(function(){
/**
 * ============================================================================
 * apps/web/lib/mock/marketing.tsx
 * ----------------------------------------------------------------------------
 * Marketing module mock data — campaigns, email sequences, social posts,
 * landing pages, contacts, ROI metrics. Cross-linked to CRM customers
 * (sales.tsx) and finance AR invoices (finance.tsx) for ROI attribution.
 * ============================================================================
 */

/* ─── Module-level KPIs ─────────────────────────────────────────────── */
const MKT_KPIS = {
  leadsThisWeek: 142,
  leadsTrend: "+18%",
  campaignsActive: 8,
  emailOpenRate: 38.2,
  emailOpenTrend: "+2.4pp",
  emailCTR: 6.8,
  landingConversion: 12.4,
  revenueAttributed: 487200,    /* USD, last 30d */
  revenueTrend: "+24%",
  cpl: 31.40,
  cplTrend: "-8%",
  socialEngagement: 4.2,        /* avg %, last 7d */
  socialReach: 184000,
  emailSendsToday: 8420,
  unsubRate: 0.18,
}

/* ─── Campaigns ─────────────────────────────────────────────────────── */
type CampaignStatus = "draft" | "scheduled" | "live" | "paused" | "completed"
type CampaignKind   = "email" | "multi-channel" | "social" | "landing"
const MKT_CAMPAIGNS = [
  { id: "CMP-2026-018", name: "PH Solar Promo · Q2",        kind: "multi-channel", status: "live",       entity: "HVPH",
    channels: ["email", "facebook", "whatsapp"], spendUSD: 4200, revenueUSD: 87000, leads: 312, conv: 9.4,
    starts: "Apr 14", ends: "Jun 30", owner: "MR", linkedOppCount: 18, lastSentAgo: "2h" },
  { id: "CMP-2026-017", name: "SG Construction Mat. Restock", kind: "email",       status: "live",       entity: "HVSG",
    channels: ["email"], spendUSD: 980,  revenueUSD: 41000, leads: 184, conv: 11.2,
    starts: "Apr 22", ends: "May 12", owner: "LC", linkedOppCount: 11, lastSentAgo: "1d" },
  { id: "CMP-2026-016", name: "HK Premium Series Launch",    kind: "multi-channel", status: "scheduled", entity: "HVHK",
    channels: ["email", "linkedin", "social"], spendUSD: 6800, revenueUSD: 0, leads: 0, conv: 0,
    starts: "May 06", ends: "Jun 20", owner: "JT", linkedOppCount: 0, lastSentAgo: "—" },
  { id: "CMP-2026-015", name: "Welcome Series · New Customers", kind: "email",     status: "live",       entity: "HVPH",
    channels: ["email"], spendUSD: 200,  revenueUSD: 19400, leads: 96,  conv: 14.8,
    starts: "Feb 01", ends: "Ongoing", owner: "MR", linkedOppCount: 24, lastSentAgo: "12m" },
  { id: "CMP-2026-014", name: "AU Win-Back · Lapsed 90d+",   kind: "multi-channel", status: "live",       entity: "HVAU",
    channels: ["email", "sms"], spendUSD: 1800, revenueUSD: 28200, leads: 64, conv: 7.1,
    starts: "Apr 02", ends: "May 31", owner: "KP", linkedOppCount: 8, lastSentAgo: "4h" },
  { id: "CMP-2026-013", name: "IN Diwali Pre-Book",          kind: "landing",       status: "completed",  entity: "HVIN",
    channels: ["landing", "social"], spendUSD: 3200, revenueUSD: 124000, leads: 488, conv: 18.4,
    starts: "Oct 15", ends: "Nov 12", owner: "SP", linkedOppCount: 41, lastSentAgo: "5mo" },
  { id: "CMP-2026-012", name: "Quarterly Newsletter · Q2",   kind: "email",         status: "draft",      entity: "HVPH",
    channels: ["email"], spendUSD: 0, revenueUSD: 0, leads: 0, conv: 0,
    starts: "—", ends: "—", owner: "MR", linkedOppCount: 0, lastSentAgo: "—" },
  { id: "CMP-2026-011", name: "SG Trade Show · Follow-up",   kind: "email",         status: "paused",     entity: "HVSG",
    channels: ["email"], spendUSD: 680, revenueUSD: 12400, leads: 42, conv: 4.8,
    starts: "Mar 18", ends: "Paused", owner: "LC", linkedOppCount: 5, lastSentAgo: "8d" },
] as any[]

/* ─── Email sequences (drip) ────────────────────────────────────────── */
const MKT_SEQUENCES = [
  { id: "SEQ-001", name: "Welcome · New Customer",      steps: 5, active: true,  enrolledCount: 412, completedCount: 287, openRate: 64.2 },
  { id: "SEQ-002", name: "Abandoned Quote",             steps: 3, active: true,  enrolledCount: 86,  completedCount: 41,  openRate: 48.1 },
  { id: "SEQ-003", name: "Post-Purchase Review Request", steps: 2, active: true,  enrolledCount: 248, completedCount: 198, openRate: 71.8 },
  { id: "SEQ-004", name: "Win-Back · Lapsed Customer",  steps: 4, active: true,  enrolledCount: 124, completedCount: 38,  openRate: 32.4 },
  { id: "SEQ-005", name: "Onboarding · Cenora Suite",   steps: 6, active: false, enrolledCount: 0,   completedCount: 0,   openRate: 0    },
] as any[]

/* ─── Email templates ───────────────────────────────────────────────── */
const MKT_TEMPLATES = [
  { id: "TPL-001", name: "Monthly Newsletter",       category: "Newsletter",  uses: 18, lastUsed: "Apr 22" },
  { id: "TPL-002", name: "Product Launch Announce",  category: "Promo",       uses: 12, lastUsed: "Apr 14" },
  { id: "TPL-003", name: "Webinar Invitation",       category: "Event",       uses: 7,  lastUsed: "Mar 28" },
  { id: "TPL-004", name: "Quote Follow-up",          category: "Transactional", uses: 96, lastUsed: "Apr 28" },
  { id: "TPL-005", name: "Welcome · Customer",       category: "Onboarding",  uses: 412, lastUsed: "Apr 28" },
  { id: "TPL-006", name: "Restock Alert",            category: "Transactional", uses: 24, lastUsed: "Apr 27" },
  { id: "TPL-007", name: "Holiday Promo",            category: "Promo",       uses: 8,  lastUsed: "Dec 18" },
  { id: "TPL-008", name: "Customer Survey",          category: "Research",    uses: 14, lastUsed: "Mar 11" },
] as any[]

/* ─── Mailing lists / segments ──────────────────────────────────────── */
const MKT_LISTS = [
  { id: "LST-001", name: "All Customers (active)",       count: 2484, dynamic: true,  source: "CRM" },
  { id: "LST-002", name: "Enterprise · MRR > $5k",       count: 142,  dynamic: true,  source: "CRM × Finance" },
  { id: "LST-003", name: "New leads · last 30d",         count: 312,  dynamic: true,  source: "Marketing forms" },
  { id: "LST-004", name: "PH Construction sector",       count: 486,  dynamic: true,  source: "CRM segment" },
  { id: "LST-005", name: "Quarterly Newsletter · opt-in", count: 1842, dynamic: false, source: "Manual" },
  { id: "LST-006", name: "Lapsed · 90d no activity",     count: 248,  dynamic: true,  source: "CRM" },
  { id: "LST-007", name: "Trade show · 2026 Q1",         count: 92,   dynamic: false, source: "Event import" },
] as any[]

/* ─── Social posts (calendar) ───────────────────────────────────────── */
type SocialChannel = "facebook" | "instagram" | "linkedin" | "x" | "tiktok" | "youtube"
const MKT_SOCIAL_POSTS = [
  /* Past week */
  { id: "SOC-101", channels: ["facebook", "instagram"], status: "published", scheduledAt: "Apr 23 · 09:00", topic: "Customer story · Globe PH", engagement: 482, reach: 12400 },
  { id: "SOC-102", channels: ["linkedin"],              status: "published", scheduledAt: "Apr 24 · 10:30", topic: "Industry insight · ERP adoption SEA", engagement: 218, reach: 6800 },
  { id: "SOC-103", channels: ["instagram", "tiktok"],   status: "published", scheduledAt: "Apr 25 · 16:00", topic: "Behind the scenes · HVPH warehouse",   engagement: 1240, reach: 28000 },
  { id: "SOC-104", channels: ["x", "linkedin"],          status: "published", scheduledAt: "Apr 26 · 08:15", topic: "Q2 product roadmap teaser",           engagement: 312, reach: 8200 },
  /* This week + scheduled */
  { id: "SOC-105", channels: ["facebook"],               status: "scheduled", scheduledAt: "Apr 28 · 11:00", topic: "PH Solar Promo · launch banner",    engagement: 0, reach: 0 },
  { id: "SOC-106", channels: ["instagram", "facebook"], status: "scheduled", scheduledAt: "Apr 29 · 14:00", topic: "Solar installation customer reel",  engagement: 0, reach: 0 },
  { id: "SOC-107", channels: ["linkedin"],               status: "draft",     scheduledAt: "Apr 30 · 09:00", topic: "Whitepaper · Multi-entity ERP",     engagement: 0, reach: 0 },
  { id: "SOC-108", channels: ["x"],                      status: "scheduled", scheduledAt: "May 02 · 17:00", topic: "Build-in-public · feature spotlight", engagement: 0, reach: 0 },
  { id: "SOC-109", channels: ["tiktok"],                 status: "needs-approval", scheduledAt: "May 03 · 12:00", topic: "Quick tip · Tax calendar PH", engagement: 0, reach: 0 },
  { id: "SOC-110", channels: ["facebook", "instagram"], status: "scheduled", scheduledAt: "May 05 · 10:00", topic: "Helios Vertex anniversary",         engagement: 0, reach: 0 },
] as any[]

/* ─── Social inbox (DMs / comments / mentions) ──────────────────────── */
const MKT_SOCIAL_INBOX = [
  { id: "SI-201", channel: "instagram", kind: "DM",      from: "@miguel_ph",     ts: "12m",  preview: "Hi! Any updates on solar lead times for Cebu?",  sentiment: "neutral",  unread: true },
  { id: "SI-202", channel: "facebook",  kind: "comment", from: "Anna L.",        ts: "38m",  preview: "Love the new packaging! Just received my order today.", sentiment: "positive", unread: true },
  { id: "SI-203", channel: "linkedin",  kind: "mention", from: "Maya C.",         ts: "1h",   preview: "Featured Cenora in our quarterly review — link in bio.",  sentiment: "positive", unread: false },
  { id: "SI-204", channel: "x",         kind: "mention", from: "@retail_sg",     ts: "2h",   preview: "Anyone tried Cenora for multi-store inventory? Thoughts?", sentiment: "neutral", unread: true },
  { id: "SI-205", channel: "instagram", kind: "comment", from: "@buildph",       ts: "3h",   preview: "Pricing for 50+ user tier?",                              sentiment: "neutral",  unread: true },
  { id: "SI-206", channel: "facebook",  kind: "DM",      from: "Maria S.",       ts: "5h",   preview: "Order #SO-1112 — when does it ship?",                    sentiment: "neutral",  unread: false },
  { id: "SI-207", channel: "tiktok",    kind: "comment", from: "@apac_logistics", ts: "8h",  preview: "Where can I demo this?",                                  sentiment: "positive", unread: false },
] as any[]

/* ─── Landing pages ─────────────────────────────────────────────────── */
const MKT_PAGES = [
  { id: "LP-2026-09", slug: "ph-solar-promo",          name: "PH Solar Promo · Q2",         views: 8420, submissions: 312, convPct: 3.7, status: "live",   updatedAgo: "2d" },
  { id: "LP-2026-08", slug: "construction-restock",    name: "SG Construction Restock",     views: 2480, submissions: 84,  convPct: 3.4, status: "live",   updatedAgo: "5d" },
  { id: "LP-2026-07", slug: "diwali-prebook",          name: "IN Diwali Pre-book",          views: 18400, submissions: 488, convPct: 2.7, status: "archived", updatedAgo: "5mo" },
  { id: "LP-2026-06", slug: "demo-request",            name: "Demo Request · Generic",      views: 12480, submissions: 612, convPct: 4.9, status: "live",   updatedAgo: "1mo" },
  { id: "LP-2026-05", slug: "whitepaper-multi-entity", name: "Whitepaper · Multi-Entity",   views: 6240, submissions: 312, convPct: 5.0, status: "live",   updatedAgo: "2w" },
  { id: "LP-2026-04", slug: "hk-launch-2026",          name: "HK Premium Launch",           views: 0, submissions: 0, convPct: 0, status: "draft",  updatedAgo: "1d" },
] as any[]

/* ─── Forms ─────────────────────────────────────────────────────────── */
const MKT_FORMS = [
  { id: "FRM-01", name: "Demo Request",         fields: 6, submissions: 612, autoCreate: "Opportunity" },
  { id: "FRM-02", name: "Newsletter Signup",    fields: 2, submissions: 1842, autoCreate: "Contact" },
  { id: "FRM-03", name: "Whitepaper Download",  fields: 4, submissions: 312, autoCreate: "Lead" },
  { id: "FRM-04", name: "PH Solar Inquiry",     fields: 8, submissions: 312, autoCreate: "Opportunity" },
  { id: "FRM-05", name: "Event RSVP · HK Launch", fields: 5, submissions: 84,  autoCreate: "Contact" },
] as any[]

/* ─── Marketing contacts (sample) ───────────────────────────────────── */
const MKT_CONTACTS = [
  { id: "MC-0001", name: "Jose A. Reyes",   email: "j.reyes@globephil.com",       company: "Globe Telecom",      segment: "Enterprise",  source: "Demo form",     entity: "HVPH", optIn: true,  lastEngaged: "Apr 27", lifetime: 24800 },
  { id: "MC-0002", name: "Mei Lin Tan",     email: "mei.lin@metroretail.sg",      company: "Metro Retail SG",    segment: "Enterprise",  source: "Trade show",    entity: "HVSG", optIn: true,  lastEngaged: "Apr 26", lifetime: 18200 },
  { id: "MC-0003", name: "Akira Tanaka",    email: "akira.t@summit-eng.hk",       company: "Summit Engineering", segment: "Business",    source: "Newsletter",    entity: "HVHK", optIn: true,  lastEngaged: "Apr 25", lifetime: 9400 },
  { id: "MC-0004", name: "Priya Iyer",      email: "priya@aurora-mfg.in",         company: "Aurora Mfg",         segment: "Business",    source: "LinkedIn",      entity: "HVIN", optIn: true,  lastEngaged: "Apr 24", lifetime: 6200 },
  { id: "MC-0005", name: "Connor Walsh",    email: "c.walsh@walshhomes.au",       company: "Walsh Homes",        segment: "Starter",     source: "Whitepaper",    entity: "HVAU", optIn: true,  lastEngaged: "Apr 22", lifetime: 2400 },
  { id: "MC-0006", name: "Felicity Cruz",   email: "felicity@sunlight-ph.com",    company: "Sunlight Solar PH",  segment: "Business",    source: "PH Solar Promo", entity: "HVPH", optIn: true, lastEngaged: "Apr 23", lifetime: 4800 },
  { id: "MC-0007", name: "Daniel Ng",       email: "dng@buildright.sg",           company: "BuildRight SG",      segment: "Starter",     source: "Demo form",     entity: "HVSG", optIn: false, lastEngaged: "Apr 18", lifetime: 0 },
  { id: "MC-0008", name: "Hana Park",       email: "hana@parkhospitality.hk",     company: "Park Hospitality",   segment: "Enterprise",  source: "Event RSVP",    entity: "HVHK", optIn: true,  lastEngaged: "Apr 20", lifetime: 31200 },
  { id: "MC-0009", name: "Ravi Subramanian", email: "r.sub@indrelogistics.in",    company: "Indre Logistics",    segment: "Business",    source: "Newsletter",    entity: "HVIN", optIn: true,  lastEngaged: "Apr 21", lifetime: 8400 },
  { id: "MC-0010", name: "Sophie Hartmann", email: "s.hartmann@hartmann-aus.com", company: "Hartmann Aus.",      segment: "Business",    source: "Win-back",      entity: "HVAU", optIn: true,  lastEngaged: "Apr 19", lifetime: 11800 },
  { id: "MC-0011", name: "Marco Diaz",      email: "m.diaz@diaz-ent.ph",          company: "Diaz Enterprises",   segment: "Starter",     source: "Cold outreach", entity: "HVPH", optIn: true,  lastEngaged: "Apr 14", lifetime: 1200 },
  { id: "MC-0012", name: "Lin Wei",         email: "lin.w@weicraft.hk",           company: "Weicraft HK",        segment: "Business",    source: "Demo form",     entity: "HVHK", optIn: true,  lastEngaged: "Apr 12", lifetime: 7600 },
] as any[]

/* ─── Funnel report ─────────────────────────────────────────────────── */
const MKT_FUNNEL = [
  { stage: "Impressions",   value: 482000, pct: 100,  delta: "+8%" },
  { stage: "Clicks",        value: 38400,  pct: 7.97, delta: "+12%" },
  { stage: "Leads",         value: 4820,   pct: 1.00, delta: "+18%" },
  { stage: "Qualified",     value: 1240,   pct: 0.26, delta: "+24%" },
  { stage: "Opportunities", value: 482,    pct: 0.10, delta: "+14%" },
  { stage: "Won",           value: 142,    pct: 0.029, delta: "+22%" },
  { stage: "Invoiced",      value: 138,    pct: 0.029, delta: "+19%" },
]

/* ─── Channel performance ───────────────────────────────────────────── */
const MKT_CHANNELS_PERF = [
  { channel: "Email",     spend: 4200, revenue: 184000, roi: 43.8, leads: 1240 },
  { channel: "Landing pages", spend: 6800, revenue: 124000, roi: 18.2, leads: 612 },
  { channel: "Facebook",  spend: 3400, revenue: 68000,  roi: 20.0, leads: 412 },
  { channel: "Instagram", spend: 2200, revenue: 41000,  roi: 18.6, leads: 248 },
  { channel: "LinkedIn",  spend: 4800, revenue: 92000,  roi: 19.2, leads: 184 },
  { channel: "WhatsApp",  spend: 1200, revenue: 38000,  roi: 31.7, leads: 142 },
  { channel: "X",         spend: 600,  revenue: 4200,   roi: 7.0,  leads: 38  },
  { channel: "TikTok",    spend: 2800, revenue: 14000,  roi: 5.0,  leads: 82  },
]

/* ─── 30-day daily lead trend ──────────────────────────────────────── */
const MKT_LEADS_TREND_30D = [
  18, 24, 22, 28, 31, 19, 14, 36, 42, 38, 46, 51, 32, 28,
  48, 52, 64, 58, 47, 41, 38, 64, 78, 82, 76, 68, 54, 52, 84, 142,
]

/* ─── AI insights ───────────────────────────────────────────────────── */
const MKT_AI_INSIGHTS = [
  { kind: "send-time",   title: "Tuesday 09:30 PHT outperforms Monday 09:00 by 28%",       cta: "Shift PH Solar Promo send window" },
  { kind: "subject",     title: "Subject lines under 42 chars get 19% higher opens",       cta: "Trim 4 lines in queue" },
  { kind: "segment",     title: "Enterprise segment hasn't been emailed in 14d",           cta: "Schedule re-engagement" },
  { kind: "attribution", title: "PH Solar Promo's ROI doubled when paired with WhatsApp",  cta: "Replicate for HK Launch" },
]

/* SANDBOX exports */
const _mktExports = { MKT_KPIS, MKT_CAMPAIGNS, MKT_SEQUENCES, MKT_TEMPLATES, MKT_LISTS, MKT_SOCIAL_POSTS, MKT_SOCIAL_INBOX, MKT_PAGES, MKT_FORMS, MKT_CONTACTS, MKT_FUNNEL, MKT_CHANNELS_PERF, MKT_LEADS_TREND_30D, MKT_AI_INSIGHTS }
Object.assign(globalThis as any, _mktExports)

})();/*__IIFE_WRAP_END__*/
