{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "input-date-picker",
  "type": "registry:component",
  "title": "Date Picker",
  "description": "A date field that understands plain words like tomorrow, next fri, Dec 3 or +10d and previews the parsed date as you type, with a calendar that slides between months. The grid supports arrows, Page Up and Down, Home and End.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "forms",
    "date",
    "calendar",
    "picker",
    "natural-language",
    "input",
    "keyboard"
  ],
  "docs": "https://hyperblur.dev/effects/input-date-picker",
  "files": [
    {
      "path": "registry/hyperblur/input-date-picker.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/input-date-picker.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface InputDatePickerProps\n  extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onChange\" | \"defaultValue\"> {\n  label?: string;\n  value?: string | null;\n  defaultValue?: string | null;\n  onChange?: (value: string | null) => void;\n  defaultMonth?: string;\n  today?: string;\n  min?: string;\n  max?: string;\n  disableWeekends?: boolean;\n  weekStartsOn?: 0 | 1;\n  inline?: boolean;\n  layout?: \"stack\" | \"split\";\n  cellSize?: number;\n  accent?: string;\n  placeholder?: string;\n}\n\nconst MONTHS = [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"];\nconst DAYS = [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"];\n\nfunction toDays(y: number, m: number, d: number) {\n  const yy = m <= 2 ? y - 1 : y;\n  const era = Math.floor(yy / 400);\n  const yoe = yy - era * 400;\n  const mp = (m + 9) % 12;\n  const doy = Math.floor((153 * mp + 2) / 5) + d - 1;\n  const doe = yoe * 365 + Math.floor(yoe / 4) - Math.floor(yoe / 100) + doy;\n  return era * 146097 + doe - 719468;\n}\n\nfunction fromDays(n: number) {\n  const z = n + 719468;\n  const era = Math.floor(z / 146097);\n  const doe = z - era * 146097;\n  const yoe = Math.floor((doe - Math.floor(doe / 1460) + Math.floor(doe / 36524) - Math.floor(doe / 146096)) / 365);\n  const doy = doe - (365 * yoe + Math.floor(yoe / 4) - Math.floor(yoe / 100));\n  const mp = Math.floor((5 * doy + 2) / 153);\n  const d = doy - Math.floor((153 * mp + 2) / 5) + 1;\n  const m = mp < 10 ? mp + 3 : mp - 9;\n  return { y: yoe + era * 400 + (m <= 2 ? 1 : 0), m, d };\n}\n\nfunction weekday(n: number) {\n  return (((n + 4) % 7) + 7) % 7;\n}\n\nfunction dim(y: number, m: number) {\n  return toDays(m === 12 ? y + 1 : y, m === 12 ? 1 : m + 1, 1) - toDays(y, m, 1);\n}\n\nfunction pad(n: number) {\n  return String(n).padStart(2, \"0\");\n}\n\nfunction toIso(n: number) {\n  const { y, m, d } = fromDays(n);\n  return `${y}-${pad(m)}-${pad(d)}`;\n}\n\nfunction fromIso(s?: string | null) {\n  if (!s) return null;\n  const r = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(s);\n  if (!r) return null;\n  const y = Number(r[1]);\n  const m = Number(r[2]);\n  const d = Number(r[3]);\n  if (m < 1 || m > 12 || d < 1 || d > dim(y, m)) return null;\n  return toDays(y, m, d);\n}\n\nfunction subscribeNone() {\n  return () => {};\n}\n\nfunction readToday() {\n  return new Intl.DateTimeFormat(\"en-CA\").format();\n}\n\nfunction readNull() {\n  return null;\n}\n\nfunction formatLong(n: number) {\n  const { y, m, d } = fromDays(n);\n  return `${DAYS[weekday(n)]}, ${MONTHS[m - 1].slice(0, 3)} ${d}, ${y}`;\n}\n\nfunction parseLoose(text: string, today: number | null): number | null {\n  const t = text\n    .trim()\n    .toLowerCase()\n    .replace(/,/g, \" \")\n    .replace(/\\s+/g, \" \")\n    .replace(/^(sun|mon|tue|wed|thu|fri|sat)[a-z]* (?=[a-z]{3,9} \\d)/, \"\");\n  if (!t) return null;\n  const iso = fromIso(t);\n  if (iso !== null) return iso;\n  if (today !== null) {\n    if (t === \"today\" || t === \"now\") return today;\n    if (t === \"tomorrow\" || t === \"tmr\") return today + 1;\n    if (t === \"yesterday\") return today - 1;\n    const rel = /^(?:in |\\+)(\\d{1,3}) ?(d|day|days|w|week|weeks)$/.exec(t);\n    if (rel) return today + Number(rel[1]) * (rel[2].startsWith(\"w\") ? 7 : 1);\n    const nx = /^(next |this )?(sun|mon|tue|wed|thu|fri|sat)[a-z]*$/.exec(t);\n    if (nx) {\n      const target = DAYS.findIndex((x) => x.toLowerCase() === nx[2]);\n      const diff = (target - weekday(today) + 7) % 7;\n      return today + (diff === 0 ? 7 : diff);\n    }\n  }\n  const ref = today !== null ? fromDays(today) : null;\n  const num = /^(\\d{1,2})[/.-](\\d{1,2})(?:[/.-](\\d{2,4}))?$/.exec(t);\n  if (num) {\n    const m = Number(num[1]);\n    const d = Number(num[2]);\n    const y = num[3] ? (num[3].length === 2 ? 2000 + Number(num[3]) : Number(num[3])) : ref?.y;\n    if (!y || m < 1 || m > 12 || d < 1 || d > dim(y, m)) return null;\n    return toDays(y, m, d);\n  }\n  const named = /^([a-z]{3,9}) (\\d{1,2})(?: (\\d{4}))?$|^(\\d{1,2}) ([a-z]{3,9})(?: (\\d{4}))?$/.exec(t);\n  if (named) {\n    const mon = named[1] ?? named[5];\n    const d = Number(named[2] ?? named[4]);\n    const y = Number(named[3] ?? named[6]) || ref?.y;\n    const m = MONTHS.findIndex((x) => x.toLowerCase().startsWith(mon.slice(0, 3))) + 1;\n    if (!y || m < 1 || d < 1 || d > dim(y, m)) return null;\n    return toDays(y, m, d);\n  }\n  return null;\n}\n\nconst css = `\n.hb-xg3 {\n  --hb-xg3-c: #2f7bff;\n  --hb-xg3-cell: 36px;\n  position: relative;\n  box-sizing: border-box;\n  width: 100%;\n  font-family: inherit;\n  color: #ededed;\n}\n.hb-xg3 *, .hb-xg3 *::before, .hb-xg3 *::after { box-sizing: border-box; }\n.hb-xg3-label { display: block; margin: 0 0 7px; font-size: 12.5px; font-weight: 500; color: #a1a1a1; }\n.hb-xg3-split { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: start; }\n.hb-xg3-field {\n  position: relative;\n  display: flex;\n  align-items: center;\n  height: 44px;\n  border: 1px solid #262626;\n  border-radius: 12px;\n  background: linear-gradient(180deg, #161616, #0f0f0f);\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045), 0 1px 2px rgba(0, 0, 0, 0.5);\n  transition: border-color 0.2s ease, box-shadow 0.25s ease;\n}\n.hb-xg3-field:hover { border-color: #333; }\n.hb-xg3-field:focus-within {\n  border-color: var(--hb-xg3-c);\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045), 0 0 0 4px color-mix(in srgb, var(--hb-xg3-c) 16%, transparent);\n}\n.hb-xg3[data-bad=\"true\"] .hb-xg3-field { border-color: #8a3a3c; }\n.hb-xg3-in {\n  flex: 1;\n  min-width: 0;\n  height: 100%;\n  margin: 0;\n  padding: 0 4px 0 12px;\n  border: 0;\n  outline: 0;\n  background: transparent;\n  color: #ededed;\n  font: inherit;\n  font-size: 14px;\n  caret-color: var(--hb-xg3-c);\n}\n.hb-xg3-in::placeholder { color: #5a5a5a; }\n.hb-xg3-icon {\n  display: grid;\n  place-items: center;\n  width: 34px;\n  height: 34px;\n  margin: 0 4px 0 0;\n  padding: 0;\n  border: 0;\n  border-radius: 9px;\n  background: transparent;\n  color: #8f8f8f;\n  cursor: pointer;\n  transition: background 0.2s ease, color 0.2s ease;\n}\n.hb-xg3-icon:hover { background: rgba(255, 255, 255, 0.05); color: #ededed; }\n.hb-xg3-icon:focus-visible { outline: 2px solid var(--hb-xg3-c); outline-offset: -2px; }\n.hb-xg3-icon svg { width: 16px; height: 16px; }\n.hb-xg3-preview {\n  display: flex;\n  align-items: center;\n  gap: 6px;\n  min-height: 18px;\n  margin-top: 7px;\n  font-size: 12px;\n  color: #6f6f6f;\n}\n.hb-xg3-arrow { color: var(--hb-xg3-c); font-weight: 600; }\n.hb-xg3-preview strong { font-weight: 500; color: #ededed; animation: hb-xg3-fade 0.25s ease; }\n.hb-xg3[data-bad=\"true\"] .hb-xg3-preview { color: #d97a7c; }\n.hb-xg3-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }\n.hb-xg3-chip {\n  height: 24px;\n  margin: 0;\n  padding: 0 9px;\n  border: 1px solid #262626;\n  border-radius: 999px;\n  background: #121212;\n  color: #a1a1a1;\n  font: inherit;\n  font-size: 11.5px;\n  cursor: pointer;\n  transition: border-color 0.2s ease, color 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);\n}\n.hb-xg3-chip:hover { border-color: #3a3a3a; color: #ededed; }\n.hb-xg3-chip:active { transform: scale(0.95); }\n.hb-xg3-chip:focus-visible { outline: 2px solid var(--hb-xg3-c); outline-offset: 2px; }\n.hb-xg3-cal {\n  width: calc(var(--hb-xg3-cell) * 7 + 18px);\n  padding: 9px;\n  border: 1px solid #262626;\n  border-radius: 14px;\n  background: linear-gradient(180deg, #151515, #101010);\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 20px 40px -20px rgba(0, 0, 0, 0.8);\n  overflow: hidden;\n}\n.hb-xg3-pop {\n  position: absolute;\n  z-index: 30;\n  top: calc(100% + 6px);\n  left: 0;\n  transform-origin: top left;\n  animation: hb-xg3-pop 0.26s cubic-bezier(0.22, 1, 0.36, 1);\n}\n.hb-xg3-stack .hb-xg3-cal { margin-top: 8px; }\n.hb-xg3-head { display: flex; align-items: center; justify-content: space-between; height: calc(var(--hb-xg3-cell) * 0.6 + 12px); padding: 0 2px 6px; }\n.hb-xg3-title { position: relative; flex: 1; overflow: hidden; font-size: 13px; font-weight: 600; letter-spacing: -0.005em; }\n.hb-xg3-title span { display: block; animation: hb-xg3-slide-n 0.32s cubic-bezier(0.22, 1, 0.36, 1); }\n.hb-xg3[data-dir=\"prev\"] .hb-xg3-title span { animation-name: hb-xg3-slide-p; }\n.hb-xg3-title small { font-size: inherit; font-weight: 500; color: #6f6f6f; }\n.hb-xg3-nav {\n  display: grid;\n  place-items: center;\n  width: 24px;\n  height: 24px;\n  margin: 0;\n  padding: 0;\n  border: 0;\n  border-radius: 7px;\n  background: transparent;\n  color: #a1a1a1;\n  cursor: pointer;\n}\n.hb-xg3-nav:hover { background: rgba(255, 255, 255, 0.06); color: #ededed; }\n.hb-xg3-nav:focus-visible { outline: 2px solid var(--hb-xg3-c); outline-offset: -1px; }\n.hb-xg3-nav svg { width: 12px; height: 12px; }\n.hb-xg3-wk, .hb-xg3-grid { display: grid; grid-template-columns: repeat(7, var(--hb-xg3-cell)); }\n.hb-xg3-wk span {\n  height: calc(var(--hb-xg3-cell) * 0.55 + 4px);\n  font-size: 10.5px;\n  font-weight: 500;\n  color: #6f6f6f;\n  text-align: center;\n  line-height: calc(var(--hb-xg3-cell) * 0.55);\n}\n.hb-xg3-grid { animation: hb-xg3-grid-n 0.36s cubic-bezier(0.22, 1, 0.36, 1); }\n.hb-xg3[data-dir=\"prev\"] .hb-xg3-grid { animation-name: hb-xg3-grid-p; }\n.hb-xg3[data-dir=\"none\"] .hb-xg3-grid, .hb-xg3[data-dir=\"none\"] .hb-xg3-title span { animation: none; }\n.hb-xg3-day {\n  position: relative;\n  display: grid;\n  place-items: center;\n  width: var(--hb-xg3-cell);\n  height: var(--hb-xg3-cell);\n  margin: 0;\n  padding: 0;\n  border: 0;\n  border-radius: 50%;\n  background: transparent;\n  color: #d4d4d4;\n  font: inherit;\n  font-size: calc(var(--hb-xg3-cell) * 0.36 + 0.5px);\n  font-variant-numeric: tabular-nums;\n  cursor: pointer;\n  transition: background 0.18s ease, color 0.18s ease;\n}\n.hb-xg3-day:hover { background: rgba(255, 255, 255, 0.07); }\n.hb-xg3-day:focus-visible { outline: 2px solid var(--hb-xg3-c); outline-offset: -2px; }\n.hb-xg3-day[data-out=\"true\"] { color: #4a4a4a; }\n.hb-xg3-day[data-wkend=\"true\"] { color: #9a9a9a; }\n.hb-xg3-day:disabled { color: #3a3a3a; cursor: not-allowed; background: transparent; text-decoration: line-through; text-decoration-color: #2e2e2e; }\n.hb-xg3-day[data-today=\"true\"]::after {\n  content: \"\";\n  position: absolute;\n  bottom: calc(var(--hb-xg3-cell) * 0.12);\n  left: 50%;\n  width: 4px;\n  height: 4px;\n  margin-left: -2px;\n  border-radius: 50%;\n  background: var(--hb-xg3-c);\n}\n.hb-xg3-day[aria-selected=\"true\"] {\n  color: #fff;\n  font-weight: 600;\n  background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--hb-xg3-c) 70%, #fff), var(--hb-xg3-c) 70%);\n  box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--hb-xg3-c) 80%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.35);\n  animation: hb-xg3-pick 0.42s cubic-bezier(0.34, 1.56, 0.64, 1);\n}\n.hb-xg3-day[aria-selected=\"true\"]::after { background: #fff; }\n.hb-xg3-ph { height: calc(var(--hb-xg3-cell) * 6.6); }\n@keyframes hb-xg3-pop { from { opacity: 0; transform: translateY(-6px) scale(0.97); } }\n@keyframes hb-xg3-fade { from { opacity: 0; transform: translateY(2px); } }\n@keyframes hb-xg3-slide-n { from { opacity: 0; transform: translateY(70%); } }\n@keyframes hb-xg3-slide-p { from { opacity: 0; transform: translateY(-70%); } }\n@keyframes hb-xg3-grid-n { from { opacity: 0; transform: translateX(18px); } }\n@keyframes hb-xg3-grid-p { from { opacity: 0; transform: translateX(-18px); } }\n@keyframes hb-xg3-pick { 0% { transform: scale(0.6); } 100% { transform: scale(1); } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-xg3 *, .hb-xg3-pop { transition: none !important; animation: none !important; }\n}\n`;\n\nexport function InputDatePicker({\n  label = \"Date\",\n  value,\n  defaultValue = null,\n  onChange,\n  defaultMonth,\n  today,\n  min,\n  max,\n  disableWeekends = false,\n  weekStartsOn = 0,\n  inline = false,\n  layout = \"stack\",\n  cellSize = 36,\n  accent = \"#2f7bff\",\n  placeholder = \"Type a date, like next friday\",\n  className = \"\",\n  style,\n  ...rest\n}: InputDatePickerProps) {\n  const id = React.useId();\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const gridRef = React.useRef<HTMLDivElement>(null);\n  const inputRef = React.useRef<HTMLInputElement>(null);\n  const iconRef = React.useRef<HTMLButtonElement>(null);\n  const wantFocus = React.useRef(false);\n  const controlled = value !== undefined;\n  const [inner, setInner] = React.useState<string | null>(defaultValue);\n  const current = controlled ? value : inner;\n  const selected = fromIso(current);\n  const clock = React.useSyncExternalStore(subscribeNone, readToday, readNull);\n  const now = fromIso(today) ?? fromIso(clock);\n  const initialView = selected ?? fromIso(defaultMonth ? `${defaultMonth}-01`.slice(0, 10) : null);\n  const [viewState, setView] = React.useState<{ y: number; m: number } | null>(\n    initialView !== null ? { y: fromDays(initialView).y, m: fromDays(initialView).m } : null,\n  );\n  const view = viewState ?? (now !== null ? { y: fromDays(now).y, m: fromDays(now).m } : null);\n  const [cursorState, setCursor] = React.useState<number | null>(selected);\n  const cursor = cursorState ?? now;\n  const [dir, setDir] = React.useState<\"next\" | \"prev\" | \"none\">(\"none\");\n  const [open, setOpen] = React.useState(false);\n  const [text, setText] = React.useState(\"\");\n  const [typing, setTyping] = React.useState(false);\n\n  const minD = fromIso(min);\n  const maxD = fromIso(max);\n  const isOff = React.useCallback(\n    (n: number) =>\n      (minD !== null && n < minD) || (maxD !== null && n > maxD) || (disableWeekends && (weekday(n) === 0 || weekday(n) === 6)),\n    [minD, maxD, disableWeekends],\n  );\n\n  const parsed = typing ? parseLoose(text, now) : null;\n  const bad = typing && text.trim().length > 0 && (parsed === null || isOff(parsed));\n\n  function commit(n: number | null, close = true) {\n    if (n !== null && isOff(n)) return;\n    const iso = n === null ? null : toIso(n);\n    if (!controlled) setInner(iso);\n    onChange?.(iso);\n    if (n !== null) {\n      const { y, m } = fromDays(n);\n      jump(y, m);\n      setCursor(n);\n    }\n    setTyping(false);\n    setText(\"\");\n    if (close && !inline) {\n      setOpen(false);\n      inputRef.current?.focus();\n    }\n  }\n\n  function jump(y: number, m: number) {\n    if (view && view.y === y && view.m === m) return;\n    if (view) setDir(y * 12 + m > view.y * 12 + view.m ? \"next\" : \"prev\");\n    setView({ y, m });\n  }\n\n  function shiftMonth(delta: number) {\n    if (!view) return;\n    const t = view.y * 12 + (view.m - 1) + delta;\n    jump(Math.floor(t / 12), (t % 12) + 1);\n  }\n\n  React.useEffect(() => {\n    if (!open || inline) return;\n    function down(e: PointerEvent) {\n      if (!rootRef.current?.contains(e.target as Node)) setOpen(false);\n    }\n    document.addEventListener(\"pointerdown\", down);\n    return () => document.removeEventListener(\"pointerdown\", down);\n  }, [open, inline]);\n\n  React.useEffect(() => {\n    if (!wantFocus.current) return;\n    wantFocus.current = false;\n    gridRef.current?.querySelector<HTMLButtonElement>('[tabindex=\"0\"]')?.focus();\n  });\n\n  function moveCursor(next: number) {\n    setCursor(next);\n    const { y, m } = fromDays(next);\n    if (!view || view.y !== y || view.m !== m) jump(y, m);\n    wantFocus.current = true;\n  }\n\n  function onGridKey(e: React.KeyboardEvent) {\n    if (cursor === null) return;\n    const map: Record<string, number> = { ArrowLeft: -1, ArrowRight: 1, ArrowUp: -7, ArrowDown: 7 };\n    if (map[e.key] !== undefined) {\n      e.preventDefault();\n      moveCursor(cursor + map[e.key]);\n    } else if (e.key === \"PageUp\" || e.key === \"PageDown\") {\n      e.preventDefault();\n      const c = fromDays(cursor);\n      const t = c.y * 12 + (c.m - 1) + (e.key === \"PageUp\" ? -1 : 1) * (e.shiftKey ? 12 : 1);\n      const y = Math.floor(t / 12);\n      const m = (t % 12) + 1;\n      moveCursor(toDays(y, m, Math.min(c.d, dim(y, m))));\n    } else if (e.key === \"Home\") {\n      e.preventDefault();\n      moveCursor(cursor - ((weekday(cursor) - weekStartsOn + 7) % 7));\n    } else if (e.key === \"End\") {\n      e.preventDefault();\n      moveCursor(cursor + (6 - ((weekday(cursor) - weekStartsOn + 7) % 7)));\n    } else if (e.key === \"Escape\" && !inline) {\n      e.preventDefault();\n      setOpen(false);\n      iconRef.current?.focus();\n    }\n  }\n\n  const quick = now === null ? [] : [\n    { label: \"Today\", n: now },\n    { label: \"Tomorrow\", n: now + 1 },\n    { label: \"Next Monday\", n: now + ((1 - weekday(now) + 7) % 7 || 7) },\n    { label: \"In 2 weeks\", n: now + 14 },\n  ];\n\n  let cal: React.ReactNode = null;\n  if (view) {\n    const first = toDays(view.y, view.m, 1);\n    const offset = (weekday(first) - weekStartsOn + 7) % 7;\n    const rows = Math.ceil((offset + dim(view.y, view.m)) / 7);\n    const start = first - offset;\n    const wk = Array.from({ length: 7 }, (_, i) => DAYS[(i + weekStartsOn) % 7]);\n    const viewKey = `${view.y}-${view.m}`;\n    const inView = cursor !== null && fromDays(cursor).y === view.y && fromDays(cursor).m === view.m;\n    const focusDay = inView && cursor !== null ? cursor : selected !== null && fromDays(selected).m === view.m && fromDays(selected).y === view.y ? selected : first;\n    cal = (\n      <div className=\"hb-xg3-cal\" role={inline ? \"group\" : \"dialog\"} aria-label=\"Choose date\">\n        <div className=\"hb-xg3-head\">\n          <div className=\"hb-xg3-title\" aria-live=\"polite\">\n            <span key={viewKey}>\n              {MONTHS[view.m - 1]} <small>{view.y}</small>\n            </span>\n          </div>\n          <button type=\"button\" className=\"hb-xg3-nav\" aria-label=\"Previous month\" onClick={() => shiftMonth(-1)}>\n            <svg viewBox=\"0 0 12 12\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" aria-hidden=\"true\">\n              <path d=\"M7.5 2.5L4 6l3.5 3.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n            </svg>\n          </button>\n          <button type=\"button\" className=\"hb-xg3-nav\" aria-label=\"Next month\" onClick={() => shiftMonth(1)}>\n            <svg viewBox=\"0 0 12 12\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" aria-hidden=\"true\">\n              <path d=\"M4.5 2.5L8 6 4.5 9.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n            </svg>\n          </button>\n        </div>\n        <div className=\"hb-xg3-wk\" aria-hidden=\"true\">\n          {wk.map((d) => (\n            <span key={d}>{d.slice(0, 2)}</span>\n          ))}\n        </div>\n        <div className=\"hb-xg3-grid\" key={viewKey} ref={gridRef} role=\"grid\" aria-label={`${MONTHS[view.m - 1]} ${view.y}`} onKeyDown={onGridKey}>\n          {Array.from({ length: rows * 7 }, (_, i) => {\n            const n = start + i;\n            const c = fromDays(n);\n            const wd = weekday(n);\n            return (\n              <button\n                key={n}\n                type=\"button\"\n                role=\"gridcell\"\n                className=\"hb-xg3-day\"\n                tabIndex={n === focusDay ? 0 : -1}\n                data-out={c.m !== view.m}\n                data-today={n === now}\n                data-wkend={wd === 0 || wd === 6}\n                aria-selected={n === selected}\n                aria-label={formatLong(n)}\n                disabled={isOff(n)}\n                onClick={() => commit(n)}\n                onFocus={() => setCursor(n)}\n              >\n                {c.d}\n              </button>\n            );\n          })}\n        </div>\n      </div>\n    );\n  } else if (inline) {\n    cal = <div className=\"hb-xg3-cal hb-xg3-ph\" aria-hidden=\"true\" />;\n  }\n\n  const field = (\n    <div>\n      {label && (\n        <label className=\"hb-xg3-label\" htmlFor={`${id}-in`}>\n          {label}\n        </label>\n      )}\n      <div className=\"hb-xg3-field\">\n        <input\n          ref={inputRef}\n          id={`${id}-in`}\n          className=\"hb-xg3-in\"\n          value={typing ? text : selected !== null ? formatLong(selected) : \"\"}\n          placeholder={placeholder}\n          autoComplete=\"off\"\n          aria-invalid={bad}\n          aria-label={label ? undefined : \"Date\"}\n          aria-describedby={`${id}-pv`}\n          onFocus={(e) => {\n            if (!typing) {\n              setText(selected !== null ? formatLong(selected) : \"\");\n              setTyping(true);\n              requestAnimationFrame(() => e.target.select());\n            }\n          }}\n          onChange={(e) => {\n            setText(e.target.value);\n            setTyping(true);\n            const p = parseLoose(e.target.value, now);\n            if (p !== null) {\n              const { y, m } = fromDays(p);\n              jump(y, m);\n              setCursor(p);\n            }\n          }}\n          onKeyDown={(e) => {\n            if (e.key === \"Enter\") {\n              e.preventDefault();\n              if (!text.trim()) commit(null, false);\n              else if (parsed !== null && !isOff(parsed)) commit(parsed, false);\n            } else if (e.key === \"ArrowDown\" && !inline) {\n              e.preventDefault();\n              setOpen(true);\n              wantFocus.current = true;\n            } else if (e.key === \"Escape\") {\n              setTyping(false);\n              setText(\"\");\n              setOpen(false);\n            }\n          }}\n          onBlur={() => {\n            if (parsed !== null && !isOff(parsed)) commit(parsed, false);\n            else if (!text.trim() && typing) commit(null, false);\n            else {\n              setTyping(false);\n              setText(\"\");\n            }\n          }}\n        />\n        {!inline && (\n          <button\n            ref={iconRef}\n            type=\"button\"\n            className=\"hb-xg3-icon\"\n            aria-label={open ? \"Close calendar\" : \"Open calendar\"}\n            aria-expanded={open}\n            onClick={() => {\n              setOpen((o) => !o);\n              if (!open) wantFocus.current = true;\n            }}\n          >\n            <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.4\" aria-hidden=\"true\">\n              <rect x=\"2.3\" y=\"3.2\" width=\"11.4\" height=\"10.5\" rx=\"2.2\" />\n              <path d=\"M2.3 6.6h11.4M5.4 1.8v2.6M10.6 1.8v2.6\" strokeLinecap=\"round\" />\n            </svg>\n          </button>\n        )}\n      </div>\n      <div className=\"hb-xg3-preview\" id={`${id}-pv`} aria-live=\"polite\">\n        {typing && text.trim() ? (\n          parsed !== null && !bad ? (\n            <>\n              <span className=\"hb-xg3-arrow\">→</span>\n              <strong key={parsed}>{formatLong(parsed)}</strong>\n              <span>· Enter to set</span>\n            </>\n          ) : parsed !== null ? (\n            \"That date isn't available.\"\n          ) : (\n            \"Try 'tomorrow', 'next fri', 'Dec 3' or '+10d'.\"\n          )\n        ) : selected !== null && now !== null ? (\n          selected === now ? \"That's today.\" : selected > now ? `In ${selected - now} day${selected - now === 1 ? \"\" : \"s\"}` : `${now - selected} day${now - selected === 1 ? \"\" : \"s\"} ago`\n        ) : (\n          \"Plain words work too.\"\n        )}\n      </div>\n      {inline && quick.length > 0 && (\n        <div className=\"hb-xg3-chips\">\n          {quick.map((q) => (\n            <button key={q.label} type=\"button\" className=\"hb-xg3-chip\" onClick={() => commit(q.n, false)} disabled={isOff(q.n)}>\n              {q.label}\n            </button>\n          ))}\n        </div>\n      )}\n    </div>\n  );\n\n  const vars = { \"--hb-xg3-c\": accent, \"--hb-xg3-cell\": `${cellSize}px`, ...style } as React.CSSProperties;\n\n  return (\n    <div ref={rootRef} className={`hb-xg3 ${className}`} style={vars} data-dir={dir} data-bad={bad} {...rest}>\n      <style href=\"hb-input-date-picker\" precedence=\"default\">{css}</style>\n      {inline ? (\n        <div className={layout === \"split\" ? \"hb-xg3-split\" : \"hb-xg3-stack\"}>\n          {field}\n          {cal}\n        </div>\n      ) : (\n        <>\n          {field}\n          {open && <div className=\"hb-xg3-pop\">{cal}</div>}\n        </>\n      )}\n    </div>\n  );\n}\n"
    }
  ]
}