{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sales-heatmap-chart",
  "description": "A year of shop orders on a Monday-first calendar: weekend peaks, a summer lull, and the holiday rush",
  "dependencies": [
    "recharts",
    "motion"
  ],
  "registryDependencies": [
    "@evilcharts/recharts-heatmap-chart"
  ],
  "files": [
    {
      "path": "src/registry/blocks/recharts/b-sales-heatmap-chart.tsx",
      "content": "\"use client\";\n\nimport {\n  EvilHeatmapChart,\n  type ChartConfig,\n  type HeatmapDatum,\n} from \"@/registry/charts/recharts-heatmap-chart\";\n\nconst YEAR_START = Date.UTC(2025, 0, 1);\nconst YEAR_END = Date.UTC(2025, 11, 31);\nconst DAY_MS = 86_400_000;\nconst AVERAGE_ORDER = 42; // dollars per order, turns the order count into revenue\n\n// How busy each month runs relative to a normal one: a summer lull, then the holiday rush.\nconst SEASON = [0.85, 0.8, 0.9, 0.95, 1, 0.95, 0.85, 0.6, 1, 1.05, 1.15, 1.5];\n// Days that break the pattern on purpose, so the calendar has something to find.\nconst EVENTS: Record<string, { name: string; orders: number }> = {\n  \"2025-02-14\": { name: \"Valentine's Day\", orders: 95 },\n  \"2025-11-28\": { name: \"Black Friday\", orders: 320 },\n  \"2025-12-01\": { name: \"Cyber Monday\", orders: 210 },\n};\nconst WEEKDAY_NAMES = [\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\", \"Sun\"];\n\n// A year of daily orders for an online shop, seeded — weekends sell about twice as much.\nfunction buildOrders(seed: number): HeatmapDatum[] {\n  let state = seed;\n  const random = () => {\n    state = (state * 1664525 + 1013904223) % 4294967296;\n    return state / 4294967296;\n  };\n  const data: HeatmapDatum[] = [];\n  for (let ms = YEAR_START; ms <= YEAR_END; ms += DAY_MS) {\n    const day = new Date(ms);\n    const date = day.toISOString().slice(0, 10);\n    const weekday = day.getUTCDay();\n    const isWeekend = weekday === 0 || weekday === 6;\n    // The week between Christmas and New Year is quiet once shipping cuts off.\n    const season = ms >= Date.UTC(2025, 11, 24) ? 0.45 : SEASON[day.getUTCMonth()];\n    const base = 22 + random() * 14;\n    data.push({\n      date,\n      value: EVENTS[date]?.orders ?? Math.round(base * season * (isWeekend ? 1.9 : 1)),\n    });\n  }\n  return data;\n}\n\nconst chartData = buildOrders(4242);\n\n// Pinned levels so a normal weekday, a weekend, the holiday rush, and the sale\n// days each get their own shade — a quantile ramp would flatten the peaks.\nconst THRESHOLDS = [40, 75, 150];\n\nconst chartConfig = {\n  orders: {\n    label: \"Orders\",\n    colors: {\n      light: [\"#fde68a\", \"#fbbf24\", \"#d97706\", \"#92400e\"],\n      dark: [\"#451a03\", \"#b45309\", \"#f59e0b\", \"#fef3c7\"],\n    },\n  },\n} satisfies ChartConfig;\n\nconst TOTAL = chartData.reduce((sum, day) => sum + day.value, 0);\nconst BEST = chartData.reduce((best, day) => (day.value > best.value ? day : best), chartData[0]);\n// Average orders per weekday, Monday first, leaving the sale days out so they\n// don't skew the week they land in.\nconst BY_WEEKDAY = (() => {\n  const sums = Array.from({ length: 7 }, () => ({ orders: 0, days: 0 }));\n  for (const day of chartData) {\n    if (day.date in EVENTS) continue;\n    const slot = sums[(new Date(Date.parse(`${day.date}T00:00:00Z`)).getUTCDay() + 6) % 7];\n    slot.orders += day.value;\n    slot.days += 1;\n  }\n  return sums.map((slot, index) => ({\n    name: WEEKDAY_NAMES[index],\n    average: slot.orders / slot.days,\n    isWeekend: index >= 5,\n  }));\n})();\nconst PEAK_AVERAGE = Math.max(...BY_WEEKDAY.map((day) => day.average));\nconst average = (days: typeof BY_WEEKDAY) =>\n  days.reduce((sum, day) => sum + day.average, 0) / days.length;\nconst WEEKEND_LIFT =\n  average(BY_WEEKDAY.filter((day) => day.isWeekend)) /\n    average(BY_WEEKDAY.filter((day) => !day.isWeekend)) -\n  1;\nconst PEAK_DAYS = Object.entries(EVENTS).sort(([, a], [, b]) => b.orders - a.orders);\n\nfunction formatDate(date: string) {\n  return new Date(Date.parse(`${date}T00:00:00Z`)).toLocaleDateString(\"en-US\", {\n    month: \"short\",\n    day: \"numeric\",\n    timeZone: \"UTC\",\n  });\n}\n\nexport function EvilSalesHeatmapChart() {\n  return (\n    <div className=\"flex h-full w-full flex-col p-4\">\n      <div className=\"grid grid-cols-3 gap-3\">\n        <div className=\"flex flex-col gap-0.5\">\n          <span className=\"text-muted-foreground text-[11px]\">Revenue · 2025</span>\n          <span className=\"text-primary text-xl leading-none font-semibold tracking-tight tabular-nums\">\n            ${((TOTAL * AVERAGE_ORDER) / 1000).toFixed(0)}k\n          </span>\n        </div>\n        <div className=\"flex flex-col gap-0.5\">\n          <span className=\"text-muted-foreground text-[11px]\">Best day</span>\n          <span className=\"text-primary text-xl leading-none font-semibold tracking-tight\">\n            {formatDate(BEST.date)}\n          </span>\n        </div>\n        <div className=\"flex flex-col gap-0.5\">\n          <span className=\"text-muted-foreground text-[11px]\">Weekend lift</span>\n          <span className=\"text-primary text-xl leading-none font-semibold tracking-tight tabular-nums\">\n            +{Math.round(WEEKEND_LIFT * 100)}%\n          </span>\n        </div>\n      </div>\n\n      <EvilHeatmapChart\n        className=\"mt-4 min-h-0 w-full flex-1\"\n        data={chartData}\n        config={chartConfig}\n        range={2025}\n        weekStart=\"monday\"\n        thresholds={THRESHOLDS}\n      >\n        <EvilHeatmapChart.Cell dataKey=\"orders\" radius={2} gap={2} />\n        <EvilHeatmapChart.MonthLabel />\n        <EvilHeatmapChart.DayLabel labels={[\"Sun\", \"Mon\", \"\", \"Wed\", \"\", \"Fri\", \"\"]} />\n        <EvilHeatmapChart.Tooltip />\n        <EvilHeatmapChart.Legend align=\"left\" lessLabel=\"Quiet\" moreLabel=\"Sale days\" />\n      </EvilHeatmapChart>\n\n      <div className=\"mt-3 hidden grid-cols-2 gap-6 border-t pt-3 sm:grid\">\n        <div className=\"flex flex-col gap-2\">\n          <span className=\"text-muted-foreground text-[11px]\">Avg orders by weekday</span>\n          <div className=\"flex h-12 items-end gap-1.5\">\n            {BY_WEEKDAY.map((day) => (\n              <div key={day.name} className=\"flex h-full flex-1 flex-col justify-end gap-1\">\n                <div\n                  className={\n                    day.isWeekend ? \"rounded-sm bg-amber-500\" : \"rounded-sm bg-amber-500/30\"\n                  }\n                  style={{ height: `${(day.average / PEAK_AVERAGE) * 100}%` }}\n                />\n                <span className=\"text-muted-foreground text-center text-[10px] leading-none\">\n                  {day.name}\n                </span>\n              </div>\n            ))}\n          </div>\n        </div>\n        <div className=\"flex flex-col gap-2\">\n          <span className=\"text-muted-foreground text-[11px]\">Peak days</span>\n          <ul className=\"flex flex-col gap-1.5\">\n            {PEAK_DAYS.map(([date, event]) => (\n              <li key={date} className=\"flex items-baseline gap-2 text-[11px]\">\n                <span className=\"text-primary font-medium\">{event.name}</span>\n                <span className=\"text-muted-foreground\">{formatDate(date)}</span>\n                <span className=\"text-primary ml-auto font-medium tabular-nums\">\n                  {event.orders}\n                </span>\n              </li>\n            ))}\n          </ul>\n        </div>\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:block",
      "target": "components/evilcharts/blocks/sales-heatmap-chart.tsx"
    }
  ],
  "type": "registry:block"
}