{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sales-overview",
  "type": "registry:block",
  "title": "Sales Overview",
  "description": "A year of sales on one page: pick a number up top and the monthly chart, best sellers and channel split all follow it, with a line or bar view to taste.",
  "categories": [
    "block",
    "Dashboards"
  ],
  "dependencies": [
    "lucide-react",
    "motion"
  ],
  "registryDependencies": [
    "utils"
  ],
  "files": [
    {
      "path": "registry/devl/sales-overview.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport {\n  ArrowDownRightIcon,\n  ArrowUpRightIcon,\n  BackpackIcon,\n  ChartColumnIcon,\n  ChartLineIcon,\n  CoffeeIcon,\n  HeadphonesIcon,\n  type LucideIcon,\n  ShirtIcon,\n  WatchIcon,\n} from \"lucide-react\";\nimport { AnimatePresence, LayoutGroup, motion, useReducedMotion } from \"motion/react\";\nimport { useEffect, useId, useRef, useState } from \"react\";\nimport { cn } from \"@/lib/utils\";\n\nexport type SalesMetric = \"revenue\" | \"orders\" | \"aov\" | \"customers\";\n\nexport interface SalesMonth {\n  month: string;\n  revenue: number;\n  orders: number;\n  customers: number;\n}\n\nexport interface SalesProduct {\n  name: string;\n  category: string;\n  icon: LucideIcon;\n  revenue: number;\n  units: number;\n}\n\nexport interface SalesChannel {\n  name: string;\n  revenueShare: number;\n  orderShare: number;\n}\n\nexport interface SalesYear {\n  label: string;\n  months: SalesMonth[];\n  products: SalesProduct[];\n  channels: SalesChannel[];\n}\n\nexport interface SalesOverviewProps {\n  years?: SalesYear[];\n  title?: string;\n  currency?: string;\n  className?: string;\n}\n\nconst monthNames = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"];\n\nfunction sampleYear(label: string, scale: number, seed: number): SalesYear {\n  let s = seed;\n  const rand = () => {\n    s = (s * 16807) % 2147483647;\n    return s / 2147483647;\n  };\n  const months = monthNames.map((month, i) => {\n    const season = 1 + 0.18 * Math.sin((i - 2) / 1.9) + (i >= 10 ? 0.35 : 0);\n    const orders = Math.round(1180 * scale * season * (0.88 + rand() * 0.24));\n    return {\n      month,\n      orders,\n      revenue: Math.round(orders * (52 + rand() * 9)),\n      customers: Math.round(orders * (0.42 + rand() * 0.08)),\n    };\n  });\n  return {\n    label,\n    months,\n    products: [\n      { name: \"Trail Shell Jacket\", category: \"Outerwear\", icon: ShirtIcon, revenue: Math.round(184_000 * scale), units: Math.round(1310 * scale) },\n      { name: \"Daypack 22L\", category: \"Bags\", icon: BackpackIcon, revenue: Math.round(126_500 * scale), units: Math.round(1890 * scale) },\n      { name: \"Field Watch\", category: \"Accessories\", icon: WatchIcon, revenue: Math.round(142_300 * scale), units: Math.round(620 * scale) },\n      { name: \"Studio Headphones\", category: \"Audio\", icon: HeadphonesIcon, revenue: Math.round(98_400 * scale), units: Math.round(740 * scale) },\n      { name: \"Camp Mug Set\", category: \"Kitchen\", icon: CoffeeIcon, revenue: Math.round(41_200 * scale), units: Math.round(2210 * scale) },\n    ],\n    channels: [\n      { name: \"Direct\", revenueShare: 0.34, orderShare: 0.29 },\n      { name: \"Organic search\", revenueShare: 0.27, orderShare: 0.31 },\n      { name: \"Paid social\", revenueShare: 0.18, orderShare: 0.2 },\n      { name: \"Email\", revenueShare: 0.13, orderShare: 0.12 },\n      { name: \"Referral\", revenueShare: 0.08, orderShare: 0.08 },\n    ],\n  };\n}\n\nconst fallbackYears = [sampleYear(\"2026\", 1.18, 4242), sampleYear(\"2025\", 1, 1717)];\n\nconst metricInfo: Record<SalesMetric, { label: string; hint: string }> = {\n  revenue: { label: \"Revenue\", hint: \"Gross sales\" },\n  orders: { label: \"Orders\", hint: \"Completed checkouts\" },\n  aov: { label: \"Avg. order\", hint: \"Revenue per order\" },\n  customers: { label: \"Customers\", hint: \"First-time buyers\" },\n};\n\nconst channelTones = [\n  \"bg-blue-500 dark:bg-blue-400\",\n  \"bg-emerald-500 dark:bg-emerald-400\",\n  \"bg-amber-500 dark:bg-amber-400\",\n  \"bg-violet-500 dark:bg-violet-400\",\n  \"bg-rose-500 dark:bg-rose-400\",\n];\nconst accent = \"text-blue-600 dark:text-blue-400\";\nconst settle = { type: \"spring\", stiffness: 300, damping: 34 } as const;\n\nfunction Roll({ text, className }: { text: string; className?: string }) {\n  const reduce = useReducedMotion();\n  const chars = text.split(\"\");\n  return (\n    <span className={cn(\"inline-flex align-top tabular-nums leading-[1.15em]\", className)}>\n      <span className=\"sr-only\">{text}</span>\n      {chars.map((char, i) => {\n        const key = chars.length - i;\n        if (!/\\d/.test(char)) {\n          return (\n            <span aria-hidden key={`s${key}`}>\n              {char}\n            </span>\n          );\n        }\n        return (\n          <span aria-hidden className=\"relative inline-block h-[1.15em] w-[1ch] overflow-hidden\" key={`d${key}`}>\n            <motion.span\n              animate={{ y: `${-Number(char) * 1.15}em` }}\n              className=\"absolute inset-x-0 top-0 flex flex-col\"\n              initial={false}\n              transition={reduce ? { duration: 0 } : settle}\n            >\n              {Array.from({ length: 10 }, (_, n) => (\n                <span className=\"block h-[1.15em]\" key={n}>\n                  {n}\n                </span>\n              ))}\n            </motion.span>\n          </span>\n        );\n      })}\n    </span>\n  );\n}\n\nfunction niceStep(value: number) {\n  const exp = 10 ** Math.floor(Math.log10(Math.max(1, value)));\n  const f = value / exp;\n  const nice = f <= 1 ? 1 : f <= 2 ? 2 : f <= 2.5 ? 2.5 : f <= 5 ? 5 : 10;\n  return nice * exp;\n}\n\nfunction compact(n: number) {\n  if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(1).replace(/\\.0$/, \"\")}M`;\n  if (n >= 1000) return `${(n / 1000).toFixed(n >= 10_000 ? 0 : 1).replace(/\\.0$/, \"\")}k`;\n  return `${Math.round(n)}`;\n}\n\nexport function SalesOverview({\n  years = fallbackYears,\n  title = \"Sales overview\",\n  currency = \"$\",\n  className,\n}: SalesOverviewProps) {\n  const uid = useId().replace(/:/g, \"\");\n  const reduce = useReducedMotion();\n  const [yearIndex, setYearIndex] = useState(0);\n  const [metric, setMetric] = useState<SalesMetric>(\"revenue\");\n  const [mode, setMode] = useState<\"line\" | \"bars\">(\"line\");\n  const [hover, setHover] = useState<number | null>(null);\n  const chartRef = useRef<HTMLDivElement>(null);\n  const [size, setSize] = useState({ width: 640, height: 260 });\n  const width = size.width;\n  const lastSize = useRef(size);\n  const resized = lastSize.current !== size;\n  useEffect(() => {\n    lastSize.current = size;\n  });\n\n  useEffect(() => {\n    const el = chartRef.current;\n    if (!el) return;\n    const observer = new ResizeObserver(([entry]) =>\n      setSize({ width: entry.contentRect.width, height: Math.max(220, entry.contentRect.height) }),\n    );\n    observer.observe(el);\n    return () => observer.disconnect();\n  }, []);\n\n  const year = years[yearIndex];\n  const prior = years[yearIndex + 1];\n\n  const monthValue = (m: SalesMonth, key: SalesMetric) =>\n    key === \"aov\" ? m.revenue / Math.max(1, m.orders) : m[key];\n  const totalOf = (y: SalesYear | undefined, key: SalesMetric) => {\n    if (!y) return 0;\n    const rev = y.months.reduce((a, m) => a + m.revenue, 0);\n    const ord = y.months.reduce((a, m) => a + m.orders, 0);\n    if (key === \"aov\") return rev / Math.max(1, ord);\n    if (key === \"revenue\") return rev;\n    if (key === \"orders\") return ord;\n    return y.months.reduce((a, m) => a + m.customers, 0);\n  };\n  const format = (key: SalesMetric, n: number) => {\n    if (key === \"revenue\") return `${currency}${Math.round(n).toLocaleString(\"en-US\")}`;\n    if (key === \"aov\") return `${currency}${n.toFixed(2)}`;\n    return Math.round(n).toLocaleString(\"en-US\");\n  };\n\n  const H = size.height;\n  const padL = 40;\n  const padB = 26;\n  const padT = 12;\n  const plotW = Math.max(120, width - padL);\n  const plotH = H - padB - padT;\n  const values = year.months.map((m) => monthValue(m, metric));\n  const tickStep = niceStep((Math.max(...values) * 1.08) / 5);\n  const top = Math.ceil((Math.max(...values) * 1.08) / tickStep) * tickStep;\n  const slot = plotW / values.length;\n  const xAt = (i: number) => padL + slot * i + slot / 2;\n  const yAt = (v: number) => padT + plotH - (v / top) * plotH;\n  const linePath = values.map((v, i) => `${i ? \"L\" : \"M\"}${xAt(i).toFixed(1)},${yAt(v).toFixed(1)}`).join(\" \");\n  const ticks = Array.from({ length: Math.round(top / tickStep) + 1 }, (_, i) => i * tickStep);\n  const areaPath = `${linePath} L${xAt(values.length - 1).toFixed(1)},${yAt(0)} L${xAt(0).toFixed(1)},${yAt(0)} Z`;\n  const barW = Math.min(36, slot * 0.56);\n\n  const productValue = (p: SalesProduct) => (metric === \"orders\" || metric === \"customers\" ? p.units : p.revenue);\n  const products = [...year.products].sort((a, b) => productValue(b) - productValue(a));\n  const topProduct = products[0] ? productValue(products[0]) : 1;\n  const channelMetricTotal = totalOf(year, metric === \"aov\" ? \"revenue\" : metric);\n  const shareOf = (c: SalesChannel) => (metric === \"orders\" || metric === \"customers\" ? c.orderShare : c.revenueShare);\n\n  const spring = reduce ? { duration: 0 } : ({ type: \"spring\", stiffness: 380, damping: 38 } as const);\n  const morph = resized ? { duration: 0 } : spring;\n\n  return (\n    <LayoutGroup id={uid}>\n      <section className={cn(\"mx-auto w-full max-w-[1100px] space-y-4\", className)}>\n        <header className=\"flex flex-wrap items-end justify-between gap-3\">\n          <div>\n            <h2 className=\"font-semibold text-xl tracking-tight\">{title}</h2>\n            <p className=\"text-muted-foreground text-sm\">\n              January – December {year.label}\n              {prior ? ` · compared with ${prior.label}` : \"\"}\n            </p>\n          </div>\n          {years.length > 1 && (\n            <div aria-label=\"Year\" className=\"inline-flex rounded-full border bg-muted p-1\" role=\"radiogroup\">\n              {years.map((y, i) => (\n                <button\n                  aria-checked={i === yearIndex}\n                  className={cn(\n                    \"relative h-7 cursor-pointer rounded-full px-3.5 font-medium text-xs tabular-nums outline-none transition-colors duration-150 after:absolute after:-inset-y-1 after:inset-x-0 after:content-[''] focus-visible:ring-2 focus-visible:ring-ring\",\n                    i === yearIndex ? \"text-foreground\" : \"text-muted-foreground hover:text-foreground\",\n                  )}\n                  key={y.label}\n                  onClick={() => setYearIndex(i)}\n                  role=\"radio\"\n                  type=\"button\"\n                >\n                  {i === yearIndex && (\n                    <motion.span\n                      className=\"absolute inset-0 rounded-full bg-background shadow-xs/5 dark:bg-accent\"\n                      layoutId=\"year-pill\"\n                      transition={spring}\n                    />\n                  )}\n                  <span className=\"relative\">{y.label}</span>\n                </button>\n              ))}\n            </div>\n          )}\n        </header>\n\n        <div aria-label=\"Metric\" className=\"grid grid-cols-2 gap-3 lg:grid-cols-4\" role=\"radiogroup\">\n          {(Object.keys(metricInfo) as SalesMetric[]).map((key) => {\n            const value = totalOf(year, key);\n            const before = totalOf(prior, key);\n            const change = before ? (value - before) / before : 0;\n            const up = change >= 0;\n            const active = metric === key;\n            return (\n              <button\n                aria-checked={active}\n                className={cn(\n                  \"group relative flex cursor-pointer flex-col justify-start rounded-2xl border bg-card p-4 text-start shadow-xs/5 outline-none transition-[border-color,transform] duration-150 ease-out focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.98] motion-reduce:active:scale-100\",\n                  active ? \"border-transparent\" : \"hover:border-foreground/16\",\n                )}\n                key={key}\n                onClick={() => {\n                  setMetric(key);\n                  setHover(null);\n                }}\n                role=\"radio\"\n                type=\"button\"\n              >\n                {active && (\n                  <motion.span\n                    aria-hidden\n                    className=\"absolute -inset-px rounded-2xl border border-blue-500/80 bg-blue-500/[0.04] ring-4 ring-blue-500/10 dark:border-blue-400/80 dark:bg-blue-400/[0.06] dark:ring-blue-400/10\"\n                    layoutId=\"metric-outline\"\n                    transition={spring}\n                  />\n                )}\n                <span className=\"relative block\">\n                  <span className=\"flex items-center justify-between gap-2\">\n                    <span className=\"text-muted-foreground text-sm\">{metricInfo[key].label}</span>\n                    {prior && (\n                      <span\n                        className={cn(\n                          \"inline-flex items-center gap-0.5 font-medium text-xs tabular-nums\",\n                          up ? \"text-success-foreground\" : \"text-destructive-foreground\",\n                        )}\n                      >\n                        {up ? <ArrowUpRightIcon className=\"size-3\" /> : <ArrowDownRightIcon className=\"size-3\" />}\n                        {Math.abs(change * 100).toFixed(1)}%\n                      </span>\n                    )}\n                  </span>\n                  <span className=\"mt-1.5 block font-semibold text-xl tracking-tight sm:text-2xl\">\n                    <Roll text={format(key, value)} />\n                  </span>\n                  <span className=\"mt-0.5 block text-muted-foreground text-xs\">{metricInfo[key].hint}</span>\n                </span>\n              </button>\n            );\n          })}\n        </div>\n\n        <div className=\"grid gap-4 lg:grid-cols-3\">\n          <article className=\"flex flex-col rounded-2xl border bg-card p-4 shadow-xs/5 lg:col-span-2\">\n            <div className=\"flex flex-wrap items-center justify-between gap-2\">\n              <div>\n                <h3 className=\"font-medium text-sm\">{metricInfo[metric].label} by month</h3>\n                <p className=\"text-muted-foreground text-xs\">\n                  {hover !== null\n                    ? `${year.months[hover].month} ${year.label}: ${format(metric, values[hover])}`\n                    : `Peak in ${year.months[values.indexOf(Math.max(...values))].month}`}\n                </p>\n              </div>\n              <div aria-label=\"Chart style\" className=\"inline-flex rounded-lg border bg-muted p-0.5\" role=\"radiogroup\">\n                {(\n                  [\n                    { value: \"line\", label: \"Line\", icon: ChartLineIcon },\n                    { value: \"bars\", label: \"Bars\", icon: ChartColumnIcon },\n                  ] as const\n                ).map((opt) => (\n                  <button\n                    aria-checked={mode === opt.value}\n                    aria-label={opt.label}\n                    className={cn(\n                      \"relative inline-flex size-7 cursor-pointer items-center justify-center rounded-md outline-none transition-colors duration-150 after:absolute after:-inset-0.5 after:content-[''] focus-visible:ring-2 focus-visible:ring-ring\",\n                      mode === opt.value ? \"text-foreground\" : \"text-muted-foreground hover:text-foreground\",\n                    )}\n                    key={opt.value}\n                    onClick={() => setMode(opt.value)}\n                    role=\"radio\"\n                    type=\"button\"\n                  >\n                    {mode === opt.value && (\n                      <motion.span\n                        className=\"absolute inset-0 rounded-md bg-background shadow-xs/5 dark:bg-accent\"\n                        layoutId=\"mode-pill\"\n                        transition={spring}\n                      />\n                    )}\n                    <opt.icon className=\"relative size-4\" />\n                  </button>\n                ))}\n              </div>\n            </div>\n\n            <div className=\"relative mt-4 h-[260px] lg:h-auto lg:min-h-[260px] lg:flex-1\" ref={chartRef}>\n              <svg aria-hidden className={cn(\"absolute inset-0 overflow-visible\", accent)} height={H} width={width}>\n                {ticks.map((t) => (\n                  <g key={t}>\n                    <line\n                      className={t === 0 ? \"stroke-border\" : \"stroke-border/70\"}\n                      strokeDasharray={t === 0 ? undefined : \"2 4\"}\n                      x1={padL}\n                      x2={width}\n                      y1={yAt(t)}\n                      y2={yAt(t)}\n                    />\n                    <text className=\"fill-muted-foreground text-[0.6875rem] tabular-nums\" dominantBaseline=\"middle\" x={0} y={yAt(t)}>\n                      {metric === \"revenue\" || metric === \"aov\" ? currency : \"\"}\n                      {compact(t)}\n                    </text>\n                  </g>\n                ))}\n                {year.months.map((m, i) => (\n                  <text\n                    className={cn(\n                      \"text-[0.6875rem] transition-colors\",\n                      hover === i ? \"fill-foreground font-medium\" : \"fill-muted-foreground\",\n                    )}\n                    key={m.month}\n                    textAnchor=\"middle\"\n                    x={xAt(i)}\n                    y={H - 6}\n                  >\n                    {slot < 34 ? m.month[0] : m.month}\n                  </text>\n                ))}\n\n                {hover !== null && (\n                  <rect\n                    className=\"fill-muted/70\"\n                    height={plotH}\n                    rx={8}\n                    width={slot - 4}\n                    x={padL + slot * hover + 2}\n                    y={padT}\n                  />\n                )}\n\n                <AnimatePresence initial={false}>\n                  {mode === \"bars\" ? (\n                    <motion.g animate={{ opacity: 1 }} exit={{ opacity: 0 }} initial={{ opacity: 1 }} key=\"bars\">\n                      {values.map((v, i) => (\n                        <motion.rect\n                          animate={{ y: yAt(v), height: Math.max(2, yAt(0) - yAt(v)) }}\n                          className={cn(\n                            \"fill-current transition-opacity duration-150\",\n                            hover !== null && hover !== i && \"opacity-40\",\n                          )}\n                          initial={{ y: yAt(0), height: 0 }}\n                          key={year.months[i].month}\n                          rx={Math.min(6, barW / 3)}\n                          transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 320, damping: 34, delay: i * 0.02 }}\n                          width={barW}\n                          x={xAt(i) - barW / 2}\n                        />\n                      ))}\n                    </motion.g>\n                  ) : (\n                    <motion.g animate={{ opacity: 1 }} exit={{ opacity: 0 }} initial={{ opacity: 0 }} key=\"line\">\n                      <defs>\n                        <linearGradient id={`${uid}-area`} x1=\"0\" x2=\"0\" y1=\"0\" y2=\"1\">\n                          <stop offset=\"0%\" stopColor=\"currentColor\" stopOpacity={0.14} />\n                          <stop offset=\"100%\" stopColor=\"currentColor\" stopOpacity={0} />\n                        </linearGradient>\n                      </defs>\n                      <motion.path\n                        animate={{ d: areaPath }}\n                        fill={`url(#${uid}-area)`}\n                        initial={{ d: areaPath }}\n                        transition={morph}\n                      />\n                      <motion.path\n                        animate={{ d: linePath }}\n                        className=\"stroke-current\"\n                        fill=\"none\"\n                        initial={{ d: linePath }}\n                        strokeLinecap=\"round\"\n                        strokeLinejoin=\"round\"\n                        strokeWidth={2.25}\n                        transition={morph}\n                      />\n                      {values.map((v, i) => (\n                        <motion.circle\n                          animate={{ cy: yAt(v), r: hover === i ? 5.5 : 3.5 }}\n                          className=\"fill-card stroke-current\"\n                          cx={xAt(i)}\n                          initial={{ cy: yAt(0), r: 3.5 }}\n                          key={year.months[i].month}\n                          strokeWidth={2}\n                          transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 320, damping: 34, delay: i * 0.02 }}\n                        />\n                      ))}\n                    </motion.g>\n                  )}\n                </AnimatePresence>\n              </svg>\n\n              <div className=\"absolute inset-y-0 right-0 flex\" style={{ left: padL }}>\n                {year.months.map((m, i) => (\n                  <button\n                    aria-label={`${m.month}: ${format(metric, values[i])}`}\n                    className=\"h-full flex-1 cursor-default outline-none focus-visible:rounded-lg focus-visible:ring-2 focus-visible:ring-ring\"\n                    key={m.month}\n                    onBlur={() => setHover(null)}\n                    onFocus={() => setHover(i)}\n                    onPointerEnter={() => setHover(i)}\n                    onPointerLeave={() => setHover((h) => (h === i ? null : h))}\n                    type=\"button\"\n                  />\n                ))}\n              </div>\n\n              <AnimatePresence>\n                {hover !== null && (\n                  <motion.div\n                    animate={{ opacity: 1 }}\n                    className={cn(\n                      \"pointer-events-none absolute z-10 w-40 rounded-xl border bg-popover p-2.5 text-xs shadow-xs/5\",\n                      hover > 6 ? \"-translate-x-[calc(100%+14px)]\" : \"translate-x-3.5\",\n                    )}\n                    exit={{ opacity: 0 }}\n                    initial={{ opacity: 0 }}\n                    style={{ left: xAt(hover), top: Math.max(0, Math.min(yAt(values[hover]) - 30, H - 110)) }}\n                    transition={{ duration: 0.12, ease: \"easeOut\" }}\n                  >\n                    <p className=\"font-medium\">\n                      {year.months[hover].month} {year.label}\n                    </p>\n                    <p className=\"mt-1 font-semibold text-sm tabular-nums\">{format(metric, values[hover])}</p>\n                    {prior && (\n                      <p className=\"mt-0.5 text-muted-foreground tabular-nums\">\n                        {prior.label}: {format(metric, monthValue(prior.months[hover], metric))}\n                      </p>\n                    )}\n                  </motion.div>\n                )}\n              </AnimatePresence>\n            </div>\n          </article>\n\n          <div className=\"grid gap-4 sm:grid-cols-2 lg:grid-cols-1\">\n            <article className=\"rounded-2xl border bg-card p-4 shadow-xs/5\">\n              <div className=\"flex items-center justify-between\">\n                <h3 className=\"font-medium text-sm\">Top products</h3>\n                <span className=\"text-muted-foreground text-xs\">\n                  by {metric === \"orders\" || metric === \"customers\" ? \"units\" : \"revenue\"}\n                </span>\n              </div>\n              <ol className=\"mt-3 space-y-2.5\">\n                {products.map((p, i) => {\n                  const value = productValue(p);\n                  return (\n                    <motion.li className=\"flex items-center gap-3\" key={p.name} layout=\"position\" transition={spring}>\n                      <span className=\"flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted text-foreground/80\">\n                        <p.icon className=\"size-4\" />\n                      </span>\n                      <span className=\"min-w-0 flex-1\">\n                        <span className=\"flex items-center justify-between gap-2 text-sm\">\n                          <span className=\"truncate font-medium\">{p.name}</span>\n                          <span className=\"flex shrink-0 tabular-nums\">\n                            {metric === \"orders\" || metric === \"customers\" ? (\n                              <Roll text={value.toLocaleString(\"en-US\")} />\n                            ) : (\n                              <Roll text={`${currency}${compact(value)}`} />\n                            )}\n                          </span>\n                        </span>\n                        <span className=\"mt-1 block h-1 overflow-hidden rounded-full bg-muted\">\n                          <motion.span\n                            animate={{ scaleX: value / topProduct }}\n                            className={cn(\n                              \"block h-full origin-left rounded-full\",\n                              i === 0 ? \"bg-blue-500 dark:bg-blue-400\" : \"bg-foreground/24\",\n                            )}\n                            initial={false}\n                            transition={spring}\n                          />\n                        </span>\n                      </span>\n                    </motion.li>\n                  );\n                })}\n              </ol>\n            </article>\n\n            <article className=\"rounded-2xl border bg-card p-4 shadow-xs/5\">\n              <div className=\"flex items-center justify-between\">\n                <h3 className=\"font-medium text-sm\">Channels</h3>\n                <span className=\"text-muted-foreground text-xs\">share of {metricInfo[metric === \"aov\" ? \"revenue\" : metric].label.toLowerCase()}</span>\n              </div>\n              <div className=\"mt-3 flex h-2.5 gap-0.5 overflow-hidden rounded-full\">\n                {year.channels.map((c, i) => (\n                  <motion.span\n                    animate={{ flexGrow: shareOf(c) }}\n                    className={cn(\"h-full basis-0 first:rounded-s-full last:rounded-e-full\", channelTones[i % channelTones.length])}\n                    initial={false}\n                    key={c.name}\n                    transition={spring}\n                  />\n                ))}\n              </div>\n              <ul className=\"mt-3 space-y-2 text-sm\">\n                {year.channels.map((c, i) => (\n                  <li className=\"flex items-center gap-2\" key={c.name}>\n                    <span className={cn(\"size-2 rounded-full\", channelTones[i % channelTones.length])} />\n                    <span className=\"flex-1 truncate\">{c.name}</span>\n                    <span className=\"text-muted-foreground text-xs tabular-nums\">\n                      {metric === \"revenue\" || metric === \"aov\" ? currency : \"\"}\n                      {compact(shareOf(c) * channelMetricTotal)}\n                    </span>\n                    <span className=\"flex w-10 justify-end font-medium tabular-nums\">\n                      <Roll text={`${Math.round(shareOf(c) * 100)}%`} />\n                    </span>\n                  </li>\n                ))}\n              </ul>\n            </article>\n          </div>\n        </div>\n      </section>\n    </LayoutGroup>\n  );\n}\n"
    }
  ]
}