{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "app-calendar-week",
  "type": "registry:component",
  "title": "App Calendar Week",
  "description": "A week view on a time grid where events can be dragged to another day or hour and stretched from their bottom edge, snapping to 15 minutes with a live time tooltip. Overlapping events share the column, a red line marks the current time and a click on an empty slot creates an event.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "app-ui",
    "calendar",
    "week view",
    "drag and drop",
    "schedule",
    "resize",
    "events"
  ],
  "docs": "https://hyperblur.dev/effects/app-calendar-week",
  "files": [
    {
      "path": "registry/hyperblur/app-calendar-week.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/app-calendar-week.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface AppWeekEvent {\n  id: string;\n  day: number;\n  start: number;\n  end: number;\n  title: string;\n  color?: string;\n  location?: string;\n}\n\nexport interface AppCalendarWeekProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onChange\"> {\n  events?: AppWeekEvent[];\n  defaultEvents?: AppWeekEvent[];\n  onEventsChange?: (events: AppWeekEvent[]) => void;\n  onEventChange?: (event: AppWeekEvent) => void;\n  onEventOpen?: (event: AppWeekEvent) => void;\n  onCreate?: (event: AppWeekEvent) => void;\n  onWeekChange?: (direction: -1 | 0 | 1) => void;\n  weekStart?: string;\n  dayNames?: string[];\n  today?: number;\n  nowMinutes?: number;\n  startHour?: number;\n  endHour?: number;\n  hourHeight?: number;\n  snap?: number;\n  accent?: string;\n}\n\nconst palette: Record<string, string> = {\n  blue: \"#4c8dff\",\n  violet: \"#9a7bff\",\n  emerald: \"#34c78a\",\n  amber: \"#f0b24a\",\n  coral: \"#ff7a66\",\n  cyan: \"#3cc6e0\",\n  pink: \"#f36fb0\",\n};\n\nconst sampleEvents: AppWeekEvent[] = [\n  { id: \"e1\", day: 0, start: 540, end: 570, title: \"Standup\", color: \"blue\", location: \"Huddle\" },\n  { id: \"e2\", day: 0, start: 630, end: 720, title: \"Design review: Billing v2\", color: \"violet\", location: \"Room 4B\" },\n  { id: \"e3\", day: 0, start: 810, end: 870, title: \"1:1 with Priya\", color: \"emerald\" },\n  { id: \"e4\", day: 1, start: 540, end: 570, title: \"Standup\", color: \"blue\", location: \"Huddle\" },\n  { id: \"e5\", day: 1, start: 600, end: 690, title: \"Roadmap sync\", color: \"amber\", location: \"Zoom\" },\n  { id: \"e6\", day: 1, start: 645, end: 735, title: \"Interview: Staff engineer\", color: \"coral\", location: \"Room 2A\" },\n  { id: \"e7\", day: 1, start: 900, end: 990, title: \"Focus: pricing page copy\", color: \"cyan\" },\n  { id: \"e8\", day: 2, start: 540, end: 570, title: \"Standup\", color: \"blue\", location: \"Huddle\" },\n  { id: \"e9\", day: 2, start: 720, end: 780, title: \"Lunch with Marco\", color: \"pink\", location: \"Pellegrino's\" },\n  { id: \"e10\", day: 2, start: 840, end: 960, title: \"Sprint planning\", color: \"violet\", location: \"Room 4B\" },\n  { id: \"e11\", day: 3, start: 540, end: 570, title: \"Standup\", color: \"blue\", location: \"Huddle\" },\n  { id: \"e12\", day: 3, start: 660, end: 720, title: \"Customer call: Lumen Bank\", color: \"emerald\", location: \"Zoom\" },\n  { id: \"e13\", day: 3, start: 930, end: 1020, title: \"Release go/no-go\", color: \"coral\" },\n  { id: \"e14\", day: 4, start: 600, end: 660, title: \"Analytics office hours\", color: \"cyan\", location: \"Room 1C\" },\n  { id: \"e15\", day: 4, start: 960, end: 1050, title: \"Team demo + drinks\", color: \"amber\", location: \"Lounge\" },\n  { id: \"e16\", day: 5, start: 600, end: 690, title: \"Climbing\", color: \"pink\", location: \"Boulder Lab\" },\n];\n\nconst daysIn = (y: number, m: number) => [31, (y % 4 === 0 && y % 100 !== 0) || y % 400 === 0 ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][m - 1];\nconst months = [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"];\n\nfunction weekDates(iso: string) {\n  const [y, m, d] = iso.split(\"-\").map((n) => parseInt(n, 10));\n  const out: { day: number; month: number; year: number }[] = [];\n  let yy = y;\n  let mm = m;\n  let dd = d;\n  for (let i = 0; i < 7; i++) {\n    out.push({ day: dd, month: mm, year: yy });\n    dd += 1;\n    if (dd > daysIn(yy, mm)) {\n      dd = 1;\n      mm += 1;\n      if (mm > 12) {\n        mm = 1;\n        yy += 1;\n      }\n    }\n  }\n  return out;\n}\n\nconst fmt = (min: number) => {\n  const h = Math.floor(min / 60);\n  const m = min % 60;\n  const h12 = h % 12 === 0 ? 12 : h % 12;\n  return `${h12}:${m.toString().padStart(2, \"0\")}`;\n};\nconst hourLabel = (h: number) => `${h % 12 === 0 ? 12 : h % 12} ${h < 12 ? \"AM\" : \"PM\"}`;\nconst tone = (c?: string) => (c && palette[c]) || c || palette.blue;\n\nfunction layout(events: AppWeekEvent[]) {\n  const pos = new Map<string, { lane: number; lanes: number }>();\n  for (let day = 0; day < 7; day++) {\n    const list = events.filter((e) => e.day === day).sort((a, b) => a.start - b.start || b.end - a.end);\n    let cluster: AppWeekEvent[] = [];\n    let laneEnds: number[] = [];\n    let clusterEnd = -1;\n    const flush = () => {\n      for (const e of cluster) {\n        const p = pos.get(e.id);\n        if (p) p.lanes = laneEnds.length;\n      }\n      cluster = [];\n      laneEnds = [];\n    };\n    for (const e of list) {\n      if (e.start >= clusterEnd) flush();\n      let lane = laneEnds.findIndex((end) => end <= e.start);\n      if (lane === -1) {\n        lane = laneEnds.length;\n        laneEnds.push(e.end);\n      } else laneEnds[lane] = e.end;\n      pos.set(e.id, { lane, lanes: 1 });\n      cluster.push(e);\n      clusterEnd = Math.max(clusterEnd, e.end);\n    }\n    flush();\n  }\n  return pos;\n}\n\nconst css = `\n.hb-wj1 {\n  --hb-wj1-a: #2f7bff;\n  box-sizing: border-box;\n  display: flex;\n  flex-direction: column;\n  width: 100%;\n  font-family: inherit;\n  font-size: 13px;\n  color: #ededed;\n  background: linear-gradient(180deg, #121212, #0d0d0d);\n  border: 1px solid #262626;\n  border-radius: 16px;\n  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 24px 60px -30px rgba(0,0,0,0.8);\n  overflow: hidden;\n  user-select: none;\n  container-type: inline-size;\n}\n.hb-wj1 *, .hb-wj1 *::before, .hb-wj1 *::after { box-sizing: border-box; font-family: inherit; }\n.hb-wj1-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 12px; border-bottom: 1px solid #1f1f1f; }\n.hb-wj1-title { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.015em; }\n.hb-wj1-title span { color: #8f8f8f; font-weight: 500; }\n.hb-wj1-sub { margin: 2px 0 0; font-size: 11.5px; color: #8f8f8f; font-variant-numeric: tabular-nums; }\n.hb-wj1-nav { display: flex; align-items: center; gap: 6px; }\n.hb-wj1-btn { display: inline-grid; place-items: center; height: 28px; min-width: 28px; padding: 0 10px; font: inherit; font-size: 12px; font-weight: 500; color: #d4d4d4; background: #171717; border: 1px solid #262626; border-radius: 8px; cursor: pointer; transition: background-color .15s ease, border-color .15s ease, color .15s ease; }\n.hb-wj1-btn[data-icon=\"true\"] { padding: 0; }\n.hb-wj1-btn svg { width: 14px; height: 14px; }\n.hb-wj1-btn:hover { background: #1e1e1e; border-color: #333; color: #fff; }\n.hb-wj1-btn:focus-visible, .hb-wj1-ev:focus-visible, .hb-wj1-col:focus-visible { outline: 2px solid var(--hb-wj1-a); outline-offset: 1px; }\n.hb-wj1-head { display: grid; grid-template-columns: 52px repeat(7, minmax(0, 1fr)); border-bottom: 1px solid #1f1f1f; background: rgba(255,255,255,0.012); }\n.hb-wj1-dh { display: flex; align-items: baseline; justify-content: center; gap: 6px; padding: 9px 4px 8px; font-size: 11px; color: #8f8f8f; letter-spacing: 0.02em; text-transform: uppercase; }\n.hb-wj1-dh b { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 5px; font-size: 13.5px; font-weight: 600; color: #ededed; letter-spacing: -0.01em; text-transform: none; border-radius: 999px; font-variant-numeric: tabular-nums; }\n.hb-wj1-dh[data-today=\"true\"] { color: var(--hb-wj1-a); }\n.hb-wj1-dh[data-today=\"true\"] b { color: #fff; background: var(--hb-wj1-a); box-shadow: 0 4px 14px -4px var(--hb-wj1-a); }\n.hb-wj1-dh[data-weekend=\"true\"] b { color: #a1a1a1; }\n.hb-wj1-body { position: relative; display: grid; grid-template-columns: 52px minmax(0, 1fr); }\n.hb-wj1-gutter { position: relative; }\n.hb-wj1-hl { position: absolute; right: 8px; transform: translateY(-50%); font-size: 10px; color: #6f6f6f; font-variant-numeric: tabular-nums; white-space: nowrap; }\n.hb-wj1-now-label { position: absolute; right: 4px; transform: translateY(-50%); padding: 1px 5px; font-size: 10px; font-weight: 600; color: #fff; background: #ff5a4f; border-radius: 5px; font-variant-numeric: tabular-nums; }\n.hb-wj1-grid { position: relative; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background-image: repeating-linear-gradient(180deg, #1c1c1c 0 1px, transparent 1px var(--hb-wj1-hh)), repeating-linear-gradient(180deg, transparent 0 calc(var(--hb-wj1-hh) / 2), rgba(255,255,255,0.025) calc(var(--hb-wj1-hh) / 2) calc(var(--hb-wj1-hh) / 2 + 1px), transparent calc(var(--hb-wj1-hh) / 2 + 1px) var(--hb-wj1-hh)); }\n.hb-wj1-col { position: relative; border-left: 1px solid #1c1c1c; cursor: copy; }\n.hb-wj1-col[data-weekend=\"true\"] { background: repeating-linear-gradient(135deg, rgba(255,255,255,0.012) 0 6px, transparent 6px 12px); }\n.hb-wj1-col[data-today=\"true\"] { background: linear-gradient(180deg, color-mix(in srgb, var(--hb-wj1-a) 7%, transparent), transparent 70%); }\n.hb-wj1-now { position: absolute; left: -1px; right: 0; height: 2px; background: #ff5a4f; z-index: 4; pointer-events: none; box-shadow: 0 0 10px rgba(255,90,79,0.5); }\n.hb-wj1-now::before { content: \"\"; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: #ff5a4f; }\n.hb-wj1-ev {\n  --c: #4c8dff;\n  position: absolute;\n  z-index: 2;\n  display: flex;\n  flex-direction: column;\n  gap: 1px;\n  padding: 4px 7px 6px 9px;\n  overflow: hidden;\n  font-size: 11.5px;\n  line-height: 1.25;\n  color: color-mix(in srgb, var(--c) 30%, #ffffff);\n  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 24%, #141414), color-mix(in srgb, var(--c) 15%, #121212));\n  border: 1px solid color-mix(in srgb, var(--c) 34%, transparent);\n  border-radius: 8px;\n  box-shadow: 0 1px 0 rgba(255,255,255,0.06) inset;\n  cursor: grab;\n  touch-action: none;\n  transition: top .22s cubic-bezier(.2,.8,.2,1), height .22s cubic-bezier(.2,.8,.2,1), left .22s cubic-bezier(.2,.8,.2,1), box-shadow .2s ease, transform .2s ease;\n}\n.hb-wj1-ev::before { content: \"\"; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--c); }\n.hb-wj1-ev:hover { box-shadow: 0 1px 0 rgba(255,255,255,0.08) inset, 0 6px 18px -10px var(--c); }\n.hb-wj1-ev[data-selected=\"true\"] { border-color: var(--c); box-shadow: 0 0 0 1px var(--c), 0 10px 24px -14px var(--c); z-index: 3; }\n.hb-wj1-ev[data-dragging=\"true\"] { z-index: 6; cursor: grabbing; transition: box-shadow .2s ease, transform .2s ease; transform: scale(1.02); box-shadow: 0 0 0 1px var(--c), 0 18px 36px -12px rgba(0,0,0,0.9), 0 8px 28px -14px var(--c); }\n.hb-wj1-ev[data-new=\"true\"] { animation: hb-wj1-pop .32s cubic-bezier(.2,1.4,.4,1) both; }\n.hb-wj1-et { font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.hb-wj1-em { font-size: 10.5px; opacity: 0.85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }\n.hb-wj1-grip { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; cursor: ns-resize; }\n.hb-wj1-grip::after { content: \"\"; position: absolute; left: 50%; bottom: 2px; width: 16px; height: 3px; margin-left: -8px; border-radius: 3px; background: currentColor; opacity: 0; transition: opacity .15s ease; }\n.hb-wj1-ev:hover .hb-wj1-grip::after, .hb-wj1-ev[data-selected=\"true\"] .hb-wj1-grip::after { opacity: 0.55; }\n.hb-wj1-tip { position: absolute; z-index: 8; left: 50%; top: -24px; transform: translateX(-50%); padding: 2px 7px; font-size: 10.5px; font-weight: 600; color: #0a0a0a; background: #fff; border-radius: 6px; white-space: nowrap; pointer-events: none; font-variant-numeric: tabular-nums; box-shadow: 0 6px 16px -6px rgba(0,0,0,0.7); }\n.hb-wj1-ghost { position: absolute; z-index: 1; border: 1px dashed color-mix(in srgb, var(--c) 60%, transparent); border-radius: 8px; background: color-mix(in srgb, var(--c) 6%, transparent); pointer-events: none; }\n.hb-wj1-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }\n@keyframes hb-wj1-pop { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: none; } }\n@container (max-width: 520px) {\n  .hb-wj1-dh { flex-direction: column; align-items: center; gap: 2px; font-size: 9.5px; }\n  .hb-wj1-em { display: none; }\n  .hb-wj1-ev { padding: 3px 4px 4px 6px; font-size: 10.5px; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-wj1-ev, .hb-wj1-btn { transition: none; animation: none; }\n  .hb-wj1-ev[data-dragging=\"true\"] { transform: none; }\n}\n`;\n\ntype Drag = { id: string; mode: \"move\" | \"resize\"; x0: number; y0: number; day0: number; start0: number; end0: number; moved: boolean };\n\nexport function AppCalendarWeek({\n  events,\n  defaultEvents = sampleEvents,\n  onEventsChange,\n  onEventChange,\n  onEventOpen,\n  onCreate,\n  onWeekChange,\n  weekStart = \"2026-11-09\",\n  dayNames = [\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\", \"Sun\"],\n  today = 1,\n  nowMinutes = 652,\n  startHour = 8,\n  endHour = 19,\n  hourHeight = 44,\n  snap = 15,\n  accent = \"#2f7bff\",\n  className,\n  style,\n  ...rest\n}: AppCalendarWeekProps) {\n  const [inner, setInner] = React.useState(defaultEvents);\n  const list = events ?? inner;\n  const [selected, setSelected] = React.useState<string | null>(null);\n  const [preview, setPreview] = React.useState<{ id: string; day: number; start: number; end: number } | null>(null);\n  const [fresh, setFresh] = React.useState<string | null>(null);\n  const [announce, setAnnounce] = React.useState(\"\");\n  const drag = React.useRef<Drag | null>(null);\n  const gridRef = React.useRef<HTMLDivElement>(null);\n  const counter = React.useRef(0);\n\n  const minT = startHour * 60;\n  const maxT = endHour * 60;\n  const pxPerMin = hourHeight / 60;\n  const dates = React.useMemo(() => weekDates(weekStart), [weekStart]);\n  const first = dates[0];\n  const last = dates[6];\n  const range = first.month === last.month ? `${months[first.month - 1].slice(0, 3)} ${first.day} – ${last.day}` : `${months[first.month - 1].slice(0, 3)} ${first.day} – ${months[last.month - 1].slice(0, 3)} ${last.day}`;\n\n  const shown = React.useMemo(() => (preview ? list.map((e) => (e.id === preview.id ? { ...e, ...preview } : e)) : list), [list, preview]);\n  const pos = React.useMemo(() => layout(shown), [shown]);\n  const hours = React.useMemo(() => Array.from({ length: endHour - startHour + 1 }, (_, i) => startHour + i), [startHour, endHour]);\n\n  const commit = (next: AppWeekEvent[], changed?: AppWeekEvent) => {\n    if (events === undefined) setInner(next);\n    onEventsChange?.(next);\n    if (changed) {\n      onEventChange?.(changed);\n      setAnnounce(`${changed.title} moved to ${dayNames[changed.day]}, ${fmt(changed.start)} to ${fmt(changed.end)}`);\n    }\n  };\n\n  const update = (id: string, patch: Partial<AppWeekEvent>) => {\n    let changed: AppWeekEvent | undefined;\n    const next = list.map((e) => {\n      if (e.id !== id) return e;\n      changed = { ...e, ...patch };\n      return changed;\n    });\n    commit(next, changed);\n  };\n\n  const down = (e: React.PointerEvent<HTMLDivElement>, ev: AppWeekEvent, mode: \"move\" | \"resize\") => {\n    if (e.button !== 0) return;\n    e.stopPropagation();\n    e.currentTarget.setPointerCapture(e.pointerId);\n    drag.current = { id: ev.id, mode, x0: e.clientX, y0: e.clientY, day0: ev.day, start0: ev.start, end0: ev.end, moved: false };\n    setSelected(ev.id);\n  };\n\n  const move = (e: React.PointerEvent<HTMLDivElement>) => {\n    const d = drag.current;\n    if (!d) return;\n    const dx = e.clientX - d.x0;\n    const dy = e.clientY - d.y0;\n    if (!d.moved && Math.abs(dx) + Math.abs(dy) < 4) return;\n    d.moved = true;\n    const colW = (gridRef.current?.clientWidth ?? 700) / 7;\n    const dMin = Math.round(dy / pxPerMin / snap) * snap;\n    if (d.mode === \"move\") {\n      const dur = d.end0 - d.start0;\n      const day = Math.min(6, Math.max(0, d.day0 + Math.round(dx / colW)));\n      const start = Math.min(maxT - dur, Math.max(minT, d.start0 + dMin));\n      setPreview({ id: d.id, day, start, end: start + dur });\n    } else {\n      const end = Math.min(maxT, Math.max(d.start0 + snap, d.end0 + dMin));\n      setPreview({ id: d.id, day: d.day0, start: d.start0, end });\n    }\n  };\n\n  const up = (ev: AppWeekEvent) => {\n    const d = drag.current;\n    drag.current = null;\n    if (!d) return;\n    if (d.moved && preview && preview.id === d.id) {\n      if (preview.day !== d.day0 || preview.start !== d.start0 || preview.end !== d.end0) update(d.id, { day: preview.day, start: preview.start, end: preview.end });\n    } else if (!d.moved) onEventOpen?.(ev);\n    setPreview(null);\n  };\n\n  const key = (e: React.KeyboardEvent<HTMLDivElement>, ev: AppWeekEvent) => {\n    const dur = ev.end - ev.start;\n    if (e.key === \"Enter\" || e.key === \" \") {\n      e.preventDefault();\n      onEventOpen?.(ev);\n      return;\n    }\n    if (e.key === \"Escape\") {\n      setSelected(null);\n      return;\n    }\n    let patch: Partial<AppWeekEvent> | null = null;\n    if (e.shiftKey && (e.key === \"ArrowDown\" || e.key === \"ArrowUp\")) {\n      const end = Math.min(maxT, Math.max(ev.start + snap, ev.end + (e.key === \"ArrowDown\" ? snap : -snap)));\n      patch = { end };\n    } else if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n      const start = Math.min(maxT - dur, Math.max(minT, ev.start + (e.key === \"ArrowDown\" ? snap : -snap)));\n      patch = { start, end: start + dur };\n    } else if (e.key === \"ArrowLeft\" || e.key === \"ArrowRight\") {\n      patch = { day: Math.min(6, Math.max(0, ev.day + (e.key === \"ArrowRight\" ? 1 : -1))) };\n    }\n    if (patch) {\n      e.preventDefault();\n      update(ev.id, patch);\n    }\n  };\n\n  const create = (e: React.MouseEvent<HTMLDivElement>, day: number) => {\n    if (e.target !== e.currentTarget) return;\n    const rect = e.currentTarget.getBoundingClientRect();\n    const raw = minT + (e.clientY - rect.top) / pxPerMin;\n    const start = Math.min(maxT - 60, Math.max(minT, Math.floor(raw / 30) * 30));\n    counter.current += 1;\n    const ev: AppWeekEvent = { id: `new-${counter.current}`, day, start, end: start + 60, title: \"New event\", color: \"blue\" };\n    commit([...list, ev]);\n    setSelected(ev.id);\n    setFresh(ev.id);\n    onCreate?.(ev);\n  };\n\n  const count = list.length;\n  const busy = list.reduce((s, e) => s + (e.end - e.start), 0);\n\n  return (\n    <div className={[\"hb-wj1\", className].filter(Boolean).join(\" \")} style={{ \"--hb-wj1-a\": accent, ...style } as React.CSSProperties} {...rest}>\n      <style href=\"hb-app-calendar-week\" precedence=\"default\">{css}</style>\n      <div className=\"hb-wj1-top\">\n        <div>\n          <h3 className=\"hb-wj1-title\">\n            {months[first.month - 1]} <span>{first.year}</span>\n          </h3>\n          <p className=\"hb-wj1-sub\">\n            {range} · {count} events · {(busy / 60).toFixed(1)} h booked\n          </p>\n        </div>\n        <div className=\"hb-wj1-nav\">\n          <button type=\"button\" className=\"hb-wj1-btn\" onClick={() => onWeekChange?.(0)}>\n            Today\n          </button>\n          <button type=\"button\" className=\"hb-wj1-btn\" data-icon=\"true\" aria-label=\"Previous week\" onClick={() => onWeekChange?.(-1)}>\n            <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\"><path d=\"M10 3.5 5.5 8l4.5 4.5\" /></svg>\n          </button>\n          <button type=\"button\" className=\"hb-wj1-btn\" data-icon=\"true\" aria-label=\"Next week\" onClick={() => onWeekChange?.(1)}>\n            <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\"><path d=\"M6 3.5 10.5 8 6 12.5\" /></svg>\n          </button>\n        </div>\n      </div>\n      <div className=\"hb-wj1-head\">\n        <div />\n        {dates.map((d, i) => (\n          <div key={i} className=\"hb-wj1-dh\" data-today={i === today} data-weekend={i >= 5}>\n            {dayNames[i]} <b>{d.day}</b>\n          </div>\n        ))}\n      </div>\n      <div className=\"hb-wj1-body\" style={{ height: (maxT - minT) * pxPerMin + 12, paddingTop: 6 }}>\n        <div className=\"hb-wj1-gutter\">\n          {hours.map((h) => (\n            <span key={h} className=\"hb-wj1-hl\" style={{ top: (h * 60 - minT) * pxPerMin }}>\n              {h === endHour ? \"\" : hourLabel(h)}\n            </span>\n          ))}\n          {today >= 0 && today < 7 && nowMinutes > minT && nowMinutes < maxT && (\n            <span className=\"hb-wj1-now-label\" style={{ top: (nowMinutes - minT) * pxPerMin }}>\n              {fmt(nowMinutes)}\n            </span>\n          )}\n        </div>\n        <div ref={gridRef} className=\"hb-wj1-grid\" style={{ \"--hb-wj1-hh\": `${hourHeight}px`, height: (maxT - minT) * pxPerMin } as React.CSSProperties}>\n          {dates.map((_, day) => (\n            <div key={day} className=\"hb-wj1-col\" data-today={day === today} data-weekend={day >= 5} onClick={(e) => create(e, day)} role=\"presentation\">\n              {day === today && nowMinutes > minT && nowMinutes < maxT && <div className=\"hb-wj1-now\" style={{ top: (nowMinutes - minT) * pxPerMin }} />}\n              {preview && (() => {\n                const orig = list.find((x) => x.id === preview.id);\n                if (!orig || orig.day !== day) return null;\n                return <div className=\"hb-wj1-ghost\" style={{ \"--c\": tone(orig.color), top: (orig.start - minT) * pxPerMin, height: (orig.end - orig.start) * pxPerMin - 2, left: 2, right: 4 } as React.CSSProperties} />;\n              })()}\n              {shown\n                .filter((ev) => ev.day === day)\n                .map((ev) => {\n                  const p = pos.get(ev.id) ?? { lane: 0, lanes: 1 };\n                  const w = 100 / p.lanes;\n                  const h = (ev.end - ev.start) * pxPerMin - 2;\n                  const dragging = preview?.id === ev.id;\n                  return (\n                    <div\n                      key={ev.id}\n                      className=\"hb-wj1-ev\"\n                      role=\"button\"\n                      tabIndex={0}\n                      aria-label={`${ev.title}, ${dayNames[ev.day]} ${fmt(ev.start)} to ${fmt(ev.end)}${ev.location ? `, ${ev.location}` : \"\"}. Arrow keys move, Shift and arrows resize.`}\n                      data-selected={selected === ev.id}\n                      data-dragging={dragging}\n                      data-new={fresh === ev.id}\n                      style={{ \"--c\": tone(ev.color), top: (ev.start - minT) * pxPerMin, height: h, left: `calc(${(p.lane * w).toFixed(3)}% + 2px)`, width: `calc(${w.toFixed(3)}% - ${p.lanes > 1 ? 3 : 6}px)` } as React.CSSProperties}\n                      onPointerDown={(e) => down(e, ev, \"move\")}\n                      onPointerMove={move}\n                      onPointerUp={() => up(ev)}\n                      onPointerCancel={() => {\n                        drag.current = null;\n                        setPreview(null);\n                      }}\n                      onFocus={() => setSelected(ev.id)}\n                      onKeyDown={(e) => key(e, ev)}\n                    >\n                      {dragging && <span className=\"hb-wj1-tip\">{`${dayNames[ev.day]} ${fmt(ev.start)} – ${fmt(ev.end)}`}</span>}\n                      <span className=\"hb-wj1-et\">{ev.title}</span>\n                      {h > 26 && <span className=\"hb-wj1-em\">{`${fmt(ev.start)} – ${fmt(ev.end)}`}</span>}\n                      {h > 52 && ev.location && <span className=\"hb-wj1-em\">{ev.location}</span>}\n                      <div className=\"hb-wj1-grip\" onPointerDown={(e) => down(e, ev, \"resize\")} onPointerMove={move} onPointerUp={() => up(ev)} aria-hidden=\"true\" />\n                    </div>\n                  );\n                })}\n            </div>\n          ))}\n        </div>\n      </div>\n      <span className=\"hb-wj1-live\" aria-live=\"polite\">{announce}</span>\n    </div>\n  );\n}\n"
    }
  ]
}