import type {
  AlertItem,
  FinancialDetail,
  LocationRow,
  SankeyDataset,
} from "@/lib/types";

export const financialPreview: SankeyDataset = {
  nodes: [
    { name: "Ingreso", value: 1948, color: "#E8D8C8" },
    { name: "Nómina", value: 487, color: "#E4D4C6" },
    { name: "Insumos", value: 389, color: "#E5DCCF" },
    { name: "Impuestos", value: 195, color: "#C8C3BD" },
    { name: "Otros costos", value: 292, color: "#E0D8CC" },
    { name: "Utilidad", value: 585, color: "#BDE9C8" },
  ],
  links: [
    { source: 0, target: 1, value: 487 },
    { source: 0, target: 2, value: 389 },
    { source: 0, target: 3, value: 195 },
    { source: 0, target: 4, value: 292 },
    { source: 0, target: 5, value: 585 },
  ],
};

export const financialFlowMain: SankeyDataset = {
  nodes: [
    { name: "Ingreso Wansoft", value: 1948, color: "#D49667" },
    { name: "Costos", value: 1363, color: "#D49667" },
    { name: "Nómina", value: 487, color: "#D49667" },
    { name: "Insumos", value: 389, color: "#D49667" },
    { name: "Impuestos", value: 195, color: "#D49667" },
    { name: "Renta", value: 122, color: "#D49667" },
    { name: "Servicios", value: 94, color: "#D49667" },
    { name: "Logística", value: 76, color: "#D49667" },
    { name: "Utilidad", value: 585, color: "#D49667" },
  ],
  links: [
    { source: 0, target: 1, value: 1363 },
    { source: 0, target: 8, value: 585 },
    { source: 1, target: 2, value: 487 },
    { source: 1, target: 3, value: 389 },
    { source: 1, target: 4, value: 195 },
    { source: 1, target: 5, value: 122 },
    { source: 1, target: 6, value: 94 },
    { source: 1, target: 7, value: 76 },
  ],
};

export const financialNodeDetails: Record<string, FinancialDetail> = {
  "Ingreso Wansoft": {
    id: "ingreso",
    title: "Ingreso Wansoft",
    amount: "$1,948K",
    percentage: "100% del total",
    breakdown: [
      { label: "Ventas B2B", value: "$1,210K" },
      { label: "Ventas retail", value: "$542K" },
      { label: "Suscripciones", value: "$196K" },
    ],
    trend: [
      { week: "S1", value: 470, label: "$470K" },
      { week: "S2", value: 488, label: "$488K" },
      { week: "S3", value: 495, label: "$495K" },
      { week: "S4", value: 495, label: "$495K" },
    ],
    notes: "Crecimiento estable en tickets de Tampiquito a Centro.",
  },
  Costos: {
    id: "costos",
    title: "Costos",
    amount: "$1,363K",
    percentage: "70% del total",
    breakdown: [
      { label: "Nómina", value: "$487K" },
      { label: "Insumos", value: "$389K" },
      { label: "Impuestos", value: "$195K" },
      { label: "Otros", value: "$292K" },
    ],
    trend: [
      { week: "S1", value: 320, label: "$320K" },
      { week: "S2", value: 338, label: "$338K" },
      { week: "S3", value: 347, label: "$347K" },
      { week: "S4", value: 358, label: "$358K" },
    ],
    notes: "Costo de nómina aumentó por cobertura de turnos en MTY.",
  },
  "Nómina": {
    id: "nomina",
    title: "Nómina",
    amount: "$487K",
    percentage: "25% del total",
    breakdown: [
      { label: "Sueldos base", value: "$324K" },
      { label: "Prestaciones", value: "$97K" },
      { label: "Bonos", value: "$48K" },
      { label: "Otros", value: "$18K" },
    ],
    trend: [
      { week: "S1", value: 118, label: "$118K" },
      { week: "S2", value: 121, label: "$121K" },
      { week: "S3", value: 124, label: "$124K" },
      { week: "S4", value: 124, label: "$124K" },
    ],
    notes: "Incremento por nuevas contrataciones en Tampiquito y Cordillera.",
  },
  Insumos: {
    id: "insumos",
    title: "Insumos",
    amount: "$389K",
    percentage: "20% del total",
    breakdown: [
      { label: "Materia prima", value: "$198K" },
      { label: "Empaque", value: "$111K" },
      { label: "Reposición", value: "$80K" },
    ],
    trend: [
      { week: "S1", value: 88, label: "$88K" },
      { week: "S2", value: 96, label: "$96K" },
      { week: "S3", value: 104, label: "$104K" },
      { week: "S4", value: 101, label: "$101K" },
    ],
    notes: "Empaque con presión por retrasos de proveedor externo.",
  },
  Impuestos: {
    id: "impuestos",
    title: "Impuestos",
    amount: "$195K",
    percentage: "10% del total",
    breakdown: [
      { label: "ISR", value: "$83K" },
      { label: "IVA", value: "$71K" },
      { label: "Locales", value: "$41K" },
    ],
    trend: [
      { week: "S1", value: 47, label: "$47K" },
      { week: "S2", value: 48, label: "$48K" },
      { week: "S3", value: 50, label: "$50K" },
      { week: "S4", value: 50, label: "$50K" },
    ],
    notes: "Pico esperado por cierre de bimestre fiscal.",
  },
  Renta: {
    id: "renta",
    title: "Renta",
    amount: "$122K",
    percentage: "6.2% del total",
    breakdown: [
      { label: "Sucursales CDMX", value: "$42K" },
      { label: "Sucursales MTY", value: "$64K" },
      { label: "Almacén", value: "$16K" },
    ],
    trend: [
      { week: "S1", value: 30, label: "$30K" },
      { week: "S2", value: 30, label: "$30K" },
      { week: "S3", value: 31, label: "$31K" },
      { week: "S4", value: 31, label: "$31K" },
    ],
    notes: "Sin cambios relevantes; montos de contrato fijos.",
  },
  Servicios: {
    id: "servicios",
    title: "Servicios",
    amount: "$94K",
    percentage: "4.8% del total",
    breakdown: [
      { label: "Energía", value: "$41K" },
      { label: "Internet", value: "$14K" },
      { label: "Mantenimiento", value: "$39K" },
    ],
    trend: [
      { week: "S1", value: 20, label: "$20K" },
      { week: "S2", value: 24, label: "$24K" },
      { week: "S3", value: 25, label: "$25K" },
      { week: "S4", value: 25, label: "$25K" },
    ],
    notes: "Subió mantenimiento preventivo por equipos de cocina.",
  },
  Logística: {
    id: "logistica",
    title: "Logística",
    amount: "$76K",
    percentage: "3.9% del total",
    breakdown: [
      { label: "Reparto", value: "$48K" },
      { label: "Fletes", value: "$19K" },
      { label: "Peajes", value: "$9K" },
    ],
    trend: [
      { week: "S1", value: 17, label: "$17K" },
      { week: "S2", value: 19, label: "$19K" },
      { week: "S3", value: 20, label: "$20K" },
      { week: "S4", value: 20, label: "$20K" },
    ],
    notes: "En ruta; concentración de envíos nocturnos mantuvo costo.",
  },
  Utilidad: {
    id: "utilidad",
    title: "Utilidad",
    amount: "$585K",
    percentage: "30% del total",
    breakdown: [
      { label: "Margen operativo", value: "$481K" },
      { label: "Ingresos no operativos", value: "$104K" },
    ],
    trend: [
      { week: "S1", value: 150, label: "$150K" },
      { week: "S2", value: 141, label: "$141K" },
      { week: "S3", value: 145, label: "$145K" },
      { week: "S4", value: 149, label: "$149K" },
    ],
    notes: "Utilidad sólida por mejora de mix en productos premium.",
  },
};

export const alerts: AlertItem[] = [
  {
    id: "alert-1",
    title: "Rollout de empaque retrasado",
    owner: "María Gómez",
    timing: "10 Feb",
    level: "vencido",
    locationId: "mty-tampiquito",
  },
  {
    id: "alert-2",
    title: "% Costo de nómina fuera de meta",
    owner: "Admin",
    timing: "Esta semana",
    level: "riesgo",
    locationId: "todas",
  },
  {
    id: "alert-3",
    title: "Mantenimiento preventivo pendiente",
    owner: "Carlos Ruiz",
    timing: "08 Feb",
    level: "vencido",
    locationId: "cdmx-roma-norte",
  },
  {
    id: "alert-4",
    title: "Entregas perfectas bajo meta",
    owner: "Operaciones",
    timing: "Esta semana",
    level: "riesgo",
    locationId: "mty-armida",
  },
  {
    id: "alert-5",
    title: "Pico en impuestos detectado",
    owner: "Admin",
    timing: "Hoy",
    level: "riesgo",
    locationId: "todas",
  },
  {
    id: "alert-6",
    title: "Incremento en rotación Armida",
    owner: "Capital Humano",
    timing: "Esta semana",
    level: "riesgo",
    locationId: "mty-armida",
  },
];

export const locationComparisonRows: LocationRow[] = [
  {
    id: "loc-cdmx-roma-norte",
    location: "Roma norte",
    sales: "$142K",
    margin: "32%",
    perfectDeliveries: "96%",
    turnover: "3.2%",
    status: "en_ruta",
  },
  {
    id: "loc-mty-tampiquito",
    location: "Tampiquito",
    sales: "$87K",
    margin: "28%",
    perfectDeliveries: "94%",
    turnover: "4.1%",
    status: "en_ruta",
  },
  {
    id: "loc-mty-cordillera",
    location: "Cordillera",
    sales: "$76K",
    margin: "30%",
    perfectDeliveries: "92%",
    turnover: "3.8%",
    status: "riesgo",
  },
  {
    id: "loc-mty-armida",
    location: "Armida",
    sales: "$64K",
    margin: "26%",
    perfectDeliveries: "89%",
    turnover: "6.2%",
    status: "riesgo",
  },
  {
    id: "loc-mty-centro",
    location: "Centro",
    sales: "$58K",
    margin: "29%",
    perfectDeliveries: "95%",
    turnover: "3.5%",
    status: "en_ruta",
  },
  {
    id: "loc-mty-innovasport",
    location: "Innovasport",
    sales: "$54K",
    margin: "27%",
    perfectDeliveries: "91%",
    turnover: "4.4%",
    status: "en_ruta",
  },
  {
    id: "loc-mty-terminal-a",
    location: "Terminal A",
    sales: "$51K",
    margin: "25%",
    perfectDeliveries: "90%",
    turnover: "5.1%",
    status: "riesgo",
  },
  {
    id: "loc-mty-terminal-b",
    location: "Terminal B",
    sales: "$49K",
    margin: "29%",
    perfectDeliveries: "94%",
    turnover: "3.7%",
    status: "en_ruta",
  },
  {
    id: "loc-mty-park-point",
    location: "Park point",
    sales: "$45K",
    margin: "24%",
    perfectDeliveries: "88%",
    turnover: "6.0%",
    status: "riesgo",
  },
];
