@photon-ai/pho-ui 4.21.0 → 4.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/chunks/{basic-page-B78a6jpw.js → basic-page-BYA1lkzf.js} +13 -13
  2. package/dist/chunks/basic-page-BYA1lkzf.js.map +1 -0
  3. package/dist/chunks/{chat-Dfbkf7g8.js → chat-j7XEdKEo.js} +48 -48
  4. package/dist/chunks/chat-j7XEdKEo.js.map +1 -0
  5. package/dist/chunks/{checkbox-DpWLbKVS.js → checkbox-D8smFViR.js} +2 -2
  6. package/dist/chunks/{checkbox-DpWLbKVS.js.map → checkbox-D8smFViR.js.map} +1 -1
  7. package/dist/chunks/chrome-Dyvv0FVf.js +14 -0
  8. package/dist/chunks/{chrome-Ds7WykBJ.js.map → chrome-Dyvv0FVf.js.map} +1 -1
  9. package/dist/chunks/{combobox-OQOi5hlB.js → combobox-C_yfFCFL.js} +2 -2
  10. package/dist/chunks/{combobox-OQOi5hlB.js.map → combobox-C_yfFCFL.js.map} +1 -1
  11. package/dist/chunks/{data-table-CAz_8HQw.js → data-table-C1tLUdw0.js} +4 -4
  12. package/dist/chunks/{data-table-CAz_8HQw.js.map → data-table-C1tLUdw0.js.map} +1 -1
  13. package/dist/chunks/{date-picker-vJQrTol9.js → date-picker-D-sWo3i8.js} +2 -2
  14. package/dist/chunks/{date-picker-vJQrTol9.js.map → date-picker-D-sWo3i8.js.map} +1 -1
  15. package/dist/chunks/{description-list-Duhhralt.js → description-list-DcTvBHzI.js} +6 -6
  16. package/dist/chunks/{description-list-Duhhralt.js.map → description-list-DcTvBHzI.js.map} +1 -1
  17. package/dist/chunks/{error-BObcQClz.js → error-BZU9vgnj.js} +2 -2
  18. package/dist/chunks/{error-BObcQClz.js.map → error-BZU9vgnj.js.map} +1 -1
  19. package/dist/chunks/{filter-bar-qqCZf1x4.js → filter-bar-CLLonntH.js} +2 -2
  20. package/dist/chunks/{filter-bar-qqCZf1x4.js.map → filter-bar-CLLonntH.js.map} +1 -1
  21. package/dist/chunks/{menu-CC3fhf83.js → menu-CZSn8JAX.js} +2 -2
  22. package/dist/chunks/{menu-CC3fhf83.js.map → menu-CZSn8JAX.js.map} +1 -1
  23. package/dist/chunks/{popover-B0NBrYV5.js → popover-Dtp9C6Qg.js} +4 -4
  24. package/dist/chunks/{popover-B0NBrYV5.js.map → popover-Dtp9C6Qg.js.map} +1 -1
  25. package/dist/chunks/{select-xhSvDNbw.js → select-Dux2SBVc.js} +2 -2
  26. package/dist/chunks/{select-xhSvDNbw.js.map → select-Dux2SBVc.js.map} +1 -1
  27. package/dist/chunks/{sidebar-DHYyBBUj.js → sidebar-BsBlAVM9.js} +2 -2
  28. package/dist/chunks/sidebar-BsBlAVM9.js.map +1 -0
  29. package/dist/chunks/{stat-VxA1SvS_.js → stat-DUq4roVt.js} +16 -16
  30. package/dist/chunks/{stat-VxA1SvS_.js.map → stat-DUq4roVt.js.map} +1 -1
  31. package/dist/chunks/{toast-B1GAdxXP.js → toast-K549iZEX.js} +2 -2
  32. package/dist/chunks/{toast-B1GAdxXP.js.map → toast-K549iZEX.js.map} +1 -1
  33. package/dist/chunks/{trace-D9F0sne7.js → trace-5Rh1ade9.js} +2 -2
  34. package/dist/chunks/{trace-D9F0sne7.js.map → trace-5Rh1ade9.js.map} +1 -1
  35. package/dist/components/accordion.js +1 -1
  36. package/dist/components/accordion.js.map +1 -1
  37. package/dist/components/autocomplete.js +5 -5
  38. package/dist/components/autocomplete.js.map +1 -1
  39. package/dist/components/chat.js +1 -1
  40. package/dist/components/checkbox.js +1 -1
  41. package/dist/components/combobox.js +1 -1
  42. package/dist/components/context-menu.js +5 -5
  43. package/dist/components/context-menu.js.map +1 -1
  44. package/dist/components/data-table.js +2 -2
  45. package/dist/components/date-picker.js +1 -1
  46. package/dist/components/description-list.js +1 -1
  47. package/dist/components/error.js +1 -1
  48. package/dist/components/field.js +1 -1
  49. package/dist/components/field.js.map +1 -1
  50. package/dist/components/fieldset.js +5 -5
  51. package/dist/components/fieldset.js.map +1 -1
  52. package/dist/components/filter-bar.js +1 -1
  53. package/dist/components/menu.js +1 -1
  54. package/dist/components/meter.js +12 -12
  55. package/dist/components/meter.js.map +1 -1
  56. package/dist/components/notification.js +1 -1
  57. package/dist/components/notification.js.map +1 -1
  58. package/dist/components/phone-input.js +1 -1
  59. package/dist/components/popover.js +1 -1
  60. package/dist/components/progress.js +16 -16
  61. package/dist/components/progress.js.map +1 -1
  62. package/dist/components/radio-group.js +1 -1
  63. package/dist/components/radio-group.js.map +1 -1
  64. package/dist/components/scope.js +2 -2
  65. package/dist/components/select.js +1 -1
  66. package/dist/components/slider.js +16 -16
  67. package/dist/components/slider.js.map +1 -1
  68. package/dist/components/stat.js +1 -1
  69. package/dist/components/toast.js +1 -1
  70. package/dist/components/trace.js +1 -1
  71. package/dist/index.js +10 -10
  72. package/dist/sections/basic-page.js +2 -2
  73. package/dist/sections/sidebar.js +1 -1
  74. package/dist/src/components/data-table/chrome.d.ts +1 -1
  75. package/dist/src/sections/sidebar/sidebar.d.ts +7 -2
  76. package/package.json +1 -1
  77. package/src/styles/fonts.css +6 -4
  78. package/src/styles/theme.css +5 -3
  79. package/dist/chunks/basic-page-B78a6jpw.js.map +0 -1
  80. package/dist/chunks/chat-Dfbkf7g8.js.map +0 -1
  81. package/dist/chunks/chrome-Ds7WykBJ.js +0 -14
  82. package/dist/chunks/sidebar-DHYyBBUj.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"date-picker-vJQrTol9.js","names":["_Fragment","cn","createReactComponent","Calendar","Popover","useCallback","useEffect","useId","useRef","useState","useSyncExternalStore","Fragment$1","jsx","jsxs","__iconNode","IconCalendar","TIME_STEP","SIZE_PAD","SIZE_RADIUS","TRIGGER_BASE","TRIGGER_FIELD","TRIGGER_NATIVE","PRESET","PRESET_ON","SPACE_SEPARATORS","flattenSpaces","words","NUMERIC_DATE","NUMERIC_CLOCK","SPAN_DASH","SAMPLE","numericFormat","locales","time","isDatePart","type","numericOrder","part","MASK","dateFieldMask","formatDateLabel","value","format","joinSpan","from","to","hasClock","a","b","text","parts","same","at","cut","keep","pad","n","toDateValue","date","toClockValue","hm","toDateTimeValue","fromInputValue","match","y","m","d","hh","mm","ss","makeLocalDate","shortYear","month","day","clock","year","parseDateText","trimmed","numbers","slots","made","spelled","clampTime","next","valueKey","withDay","keepTimeFrom","startOfMonth","endOfMonth","startOfDay","endOfDay","later","earlier","nativeBounds","calendarProps","min","max","rules","rule","COARSE_POINTER","useCoarsePointer","subscribe","notify","query","ClockField","label","disabled","onChange","event","DatePicker","props","mode","defaultValue","onValueChange","hint","placeholder","invalid","required","size","width","id","className","selectedPreset","align","ariaLabel","presets","minDays","maxDays","controlled","ownValue","setOwnValue","open","setOpen","picks","fieldPlaceholder","generatedId","triggerId","hintId","calendarId","gridFocus","setGridFocus","openPicker","focusGrid","setMonth","commit","details","setIgnoreSelected","setChosen","single","range","anchor","draft","setDraft","chosen","ignoreSelected","presetLabel","hugChars","hugToWords","pickPreset","preset","thisMonth","shownMonth","fieldRef","popupRef","coarse","bounds","native","face","typed","parsed","grid","clicked","first","kept"],"sources":["../../../../node_modules/.pnpm/@tabler+icons-react@3.49.0_react@19.3.1/node_modules/@tabler/icons-react/dist/esm/icons/IconCalendar.mjs","../../src/components/date-picker/date-picker.tsx"],"sourcesContent":["/**\n * @license @tabler/icons-react v3.49.0 - MIT\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createReactComponent from '../createReactComponent.mjs';\n\nconst __iconNode = [[\"path\", { \"d\": \"M4 7a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12\", \"key\": \"svg-0\" }], [\"path\", { \"d\": \"M16 3v4\", \"key\": \"svg-1\" }], [\"path\", { \"d\": \"M8 3v4\", \"key\": \"svg-2\" }], [\"path\", { \"d\": \"M4 11h16\", \"key\": \"svg-3\" }], [\"path\", { \"d\": \"M11 15h1\", \"key\": \"svg-4\" }], [\"path\", { \"d\": \"M12 15v3\", \"key\": \"svg-5\" }]];\nconst IconCalendar = createReactComponent(\"outline\", \"calendar\", \"Calendar\", __iconNode);\n\nexport { __iconNode, IconCalendar as default };\n","import {\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n useSyncExternalStore,\n type ReactNode,\n} from \"react\";\nimport { IconCalendar } from \"@tabler/icons-react\";\nimport type { DateRange, Matcher, PropsBase } from \"react-day-picker\";\nimport { Calendar } from \"../calendar\";\nimport { Popover } from \"../popover\";\nimport type { InputSize } from \"../input\";\nimport { cn } from \"../../utils/cn\";\n\n/** The trigger wears Input's sizes so the two line up in one form. */\nexport type DatePickerSize = InputSize;\n\n/**\n * How fine the time is asked for, and read back. Omit it for a date alone.\n * The value is always a `Date`; the granularity says which of its parts the\n * viewer sets, and everything below is zeroed.\n */\nexport type DatePickerTime = \"hour\" | \"minute\" | \"second\";\n\n/** `step` for a native time field — the unit it moves and shows. */\nconst TIME_STEP: Record<DatePickerTime, number> = {\n hour: 3600,\n minute: 60,\n second: 1,\n};\n\n// Effective padding matches Input's (12/8px, lg 14/10px); Input reaches it\n// through a 2px wrapper inset it has to compensate for, the trigger directly.\nconst SIZE_PAD: Record<DatePickerSize, string> = {\n // 16px until there is room — a 14px control next to a 16px field looks shrunk.\n sm: \"px-3 py-2 text-md md:text-base\",\n md: \"px-3 py-2 text-md\",\n lg: \"px-3.5 py-2.5 text-md\",\n};\n\nconst SIZE_RADIUS: Record<DatePickerSize, string> = {\n sm: \"rounded-base\",\n md: \"rounded-base\",\n lg: \"squircle rounded-base\",\n};\n\nconst TRIGGER_BASE = cn(\n \"bg-pho-primary ring-pho-primary text-pho-primary relative flex cursor-pointer items-center gap-2 text-left ring-1 ring-inset\",\n \"transition-shadow duration-100 ease-linear focus-visible:outline-none\",\n // Invalid is mid-weight — thicker than the rest hairline, thinner than focus.\n \"data-[invalid]:ring-pho-error-subtle data-[invalid]:ring-[1.5px]\",\n);\n\n// Open or focused, the edge is Input's: the brand ring at 2px in place of the\n// hairline. The popover path focuses the button itself; the native path puts a\n// system field over it, so the ring follows the field inside.\nconst TRIGGER_FIELD = cn(\n \"has-[input:focus-visible]:ring-pho-brand data-[popup-open]:ring-pho-brand has-[input:focus-visible]:ring-2 data-[popup-open]:ring-2\",\n \"data-[invalid]:has-[input:focus-visible]:ring-pho-error data-[invalid]:data-[popup-open]:ring-pho-error\",\n \"has-[input:disabled]:cursor-not-allowed has-[input:disabled]:opacity-50\",\n);\n\nconst TRIGGER_NATIVE = cn(\n \"has-[input:focus-visible]:ring-pho-brand has-[input:focus-visible]:ring-2\",\n \"data-[invalid]:has-[input:focus-visible]:ring-pho-error\",\n \"has-[input:disabled]:cursor-not-allowed has-[input:disabled]:opacity-50\",\n);\n\n/**\n * A named window in the rail beside the calendar — the Menu row's manners,\n * since that is what a list of choices is.\n */\nconst PRESET = cn(\n \"flex shrink-0 cursor-pointer items-center rounded-sm px-2.5 py-1.5 text-left text-base whitespace-nowrap select-none\",\n \"text-pho-secondary transition-[color,background-color] duration-150 ease-out\",\n \"hover:bg-pho-ghost-hover hover:text-pho-primary\",\n \"outline-pho-brand focus-visible:outline-2 focus-visible:-outline-offset-1\",\n \"sm:w-full\",\n);\n\n/** The one in play. Quiet, like a highlighted menu row — not an action fill. */\nconst PRESET_ON = \"bg-pho-ghost-hover text-pho-primary font-medium\";\n\n/* ------------------------------------------------------------------ words */\n\n/**\n * ICU disagrees with itself about which space belongs before `AM` and around\n * a range dash: Node sends a narrow no-break space and a thin space where\n * Chrome sends ordinary ones. The two strings look identical and are not, so\n * a server-rendered label would fail to hydrate. Flattening every space\n * separator to the ordinary one makes the words the same on both sides.\n */\nconst SPACE_SEPARATORS = /[\\u00a0\\u2000-\\u200a\\u202f\\u205f\\u3000]/g;\nconst flattenSpaces = (words: string) => words.replace(SPACE_SEPARATORS, \" \");\n\n/** The date's parts, all in figures — the shape that is quickest to type. */\nconst NUMERIC_DATE = {\n year: \"numeric\",\n month: \"2-digit\",\n day: \"2-digit\",\n} as const;\n\n/** The clock, on a 24-hour dial: `15:04` is fewer keystrokes than `3:04 PM`. */\nconst NUMERIC_CLOCK: Record<DatePickerTime, Intl.DateTimeFormatOptions> = {\n hour: { hour: \"2-digit\", minute: \"2-digit\", hourCycle: \"h23\" },\n minute: { hour: \"2-digit\", minute: \"2-digit\", hourCycle: \"h23\" },\n second: {\n hour: \"2-digit\",\n minute: \"2-digit\",\n second: \"2-digit\",\n hourCycle: \"h23\",\n },\n};\n\n/**\n * What sits between the two ends of a span. No spaces around it — the field\n * is tight and the dates are already grouped by their own separators. An en\n * dash rather than a hyphen because a hyphen is one: `2026-09-01-08` in a\n * year-first locale would read as three numbers, `2026-09-01–08` as two dates.\n */\nconst SPAN_DASH = \"\\u2013\";\n\n/** A day whose parts are all different, so the locale's order reads clearly. */\nconst SAMPLE = new Date(2026, 8, 12, 15, 4, 5);\n\nfunction numericFormat(\n locales: Intl.LocalesArgument,\n time: DatePickerTime | undefined,\n) {\n return new Intl.DateTimeFormat(locales, {\n ...NUMERIC_DATE,\n ...(time ? NUMERIC_CLOCK[time] : {}),\n });\n}\n\ntype DatePart = \"year\" | \"month\" | \"day\";\nconst isDatePart = (type: string): type is DatePart =>\n type === \"year\" || type === \"month\" || type === \"day\";\n\n/** Which of year, month and day comes first here, and which comes last. */\nfunction numericOrder(locales: Intl.LocalesArgument): DatePart[] {\n return new Intl.DateTimeFormat(locales, NUMERIC_DATE)\n .formatToParts(SAMPLE)\n .map((part) => part.type)\n .filter(isDatePart);\n}\n\nconst MASK: Record<DatePart, string> = {\n year: \"yyyy\",\n month: \"mm\",\n day: \"dd\",\n};\n\n/**\n * The shape to type, in this locale's own order — `mm/dd/yyyy`,\n * `yyyy-mm-dd`, `dd.mm.yyyy`. Lowercase, the way a browser's own date field\n * writes it, so the two paths read alike.\n */\nexport function dateFieldMask(\n locales?: Intl.LocalesArgument,\n time?: DatePickerTime,\n): string {\n return flattenSpaces(\n numericFormat(locales, time)\n .formatToParts(SAMPLE)\n .map((part) =>\n isDatePart(part.type)\n ? MASK[part.type]\n : part.type === \"hour\"\n ? \"hh\"\n : part.type === \"minute\"\n ? \"mm\"\n : part.type === \"second\"\n ? \"ss\"\n : part.value,\n )\n .join(\"\"),\n );\n}\n\n/**\n * The figures in the field — `09/12/2026`, or `09/10/2026–09/13/2026` for a\n * span, in the viewer's locale. An empty or half-finished range prints just\n * the day that is settled; nothing selected prints nothing. Pass `time` to\n * print the clock too, at the precision that was asked for.\n *\n * Figures rather than words (`Sep 12, 2026`) because the field is typed into:\n * a month's name is the one part of a date nobody wants to spell.\n */\nexport function formatDateLabel(\n value: Date | DateRange | undefined,\n locales?: Intl.LocalesArgument,\n time?: DatePickerTime,\n): string {\n if (value == null) return \"\";\n const format = numericFormat(locales, time);\n if (value instanceof Date) return flattenSpaces(format.format(value));\n if (value.from == null) return \"\";\n if (value.to == null) return flattenSpaces(format.format(value.from));\n // A span of one day is a day: printing it twice says nothing the once did\n // not, and the first click of a range makes exactly that shape.\n if (\n time == null &&\n value.from.getFullYear() === value.to.getFullYear() &&\n value.from.getMonth() === value.to.getMonth() &&\n value.from.getDate() === value.to.getDate()\n ) {\n return flattenSpaces(format.format(value.from));\n }\n return flattenSpaces(joinSpan(format, value.from, value.to, time != null));\n}\n\n/**\n * Both ends of a span, with whatever they say twice said once — a shared\n * year, and a shared month behind it, printed at the end that carries it.\n * `09/01–09/08/2026`, `01.–08.09.2026`, `2026-09-01–08`. A span carrying a\n * clock is printed whole.\n *\n * Joined here rather than by `Intl.formatRange`, which does this in `de-DE`\n * and `sv-SE` and not in `en-US` or `en-GB`, and which drops the padding the\n * single-date format asks for. Whole fields only, taken from whichever end\n * the year sits at, so the half that is dropped is never the half that\n * distinguishes the two dates.\n */\nfunction joinSpan(\n format: Intl.DateTimeFormat,\n from: Date,\n to: Date,\n hasClock: boolean,\n): string {\n const a = format.formatToParts(from);\n const b = format.formatToParts(to);\n const text = (parts: Intl.DateTimeFormatPart[]) =>\n parts.map((part) => part.value).join(\"\");\n\n // With a clock in it there is nothing worth merging: the tail fields are\n // hours and minutes, the saving is a year that would then print after a\n // time, and a trim that lands mid-clock eats one end's `:00`.\n if (hasClock || a.length !== b.length) {\n return `${text(a)}${SPAN_DASH}${text(b)}`;\n }\n const same = (at: number) =>\n a[at]!.type === b[at]!.type && a[at]!.value === b[at]!.value;\n\n // The year leads (`yyyy-mm-dd`): the second date drops the shared head.\n if (a[0]?.type === \"year\") {\n let cut = 0;\n while (cut < a.length && same(cut)) cut += 1;\n // Back off to a field boundary so a half-written number never survives.\n while (cut > 0 && b[cut - 1]!.type !== \"literal\") cut -= 1;\n if (cut > 0 && cut < a.length) {\n return `${text(a)}${SPAN_DASH}${text(b.slice(cut))}`;\n }\n return `${text(a)}${SPAN_DASH}${text(b)}`;\n }\n\n // The year trails (`mm/dd/yyyy`, `dd.mm.yyyy`): the first date drops the\n // shared tail.\n let keep = a.length;\n while (keep > 0 && same(keep - 1)) keep -= 1;\n while (keep < a.length && a[keep]!.type !== \"literal\") keep += 1;\n if (keep > 0 && keep < a.length) {\n return `${text(a.slice(0, keep))}${SPAN_DASH}${text(b)}`;\n }\n return `${text(a)}${SPAN_DASH}${text(b)}`;\n}\n\n/* ------------------------------------------------------- date arithmetic */\n\nconst pad = (n: number) => String(n).padStart(2, \"0\");\n\n/** `YYYY-MM-DD` in the viewer's own zone — never `toISOString`, which is UTC. */\nfunction toDateValue(date: Date): string {\n return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;\n}\n\nfunction toClockValue(date: Date, time: DatePickerTime): string {\n const hm = `${pad(date.getHours())}:${pad(date.getMinutes())}`;\n return time === \"second\" ? `${hm}:${pad(date.getSeconds())}` : hm;\n}\n\n/** The `datetime-local` spelling of an instant, at the asked-for precision. */\nfunction toDateTimeValue(date: Date, time: DatePickerTime): string {\n return `${toDateValue(date)}T${toClockValue(date, time)}`;\n}\n\n/**\n * Read back a `date` or `datetime-local` field. Parsed part by part rather\n * than handed to `new Date(string)`, which reads a bare `YYYY-MM-DD` as UTC\n * midnight and lands on the day before west of Greenwich.\n */\nfunction fromInputValue(value: string): Date | undefined {\n const match =\n /^(\\d{4})-(\\d{2})-(\\d{2})(?:T(\\d{2}):(\\d{2})(?::(\\d{2}))?)?$/.exec(value);\n if (!match) return undefined;\n const [, y, m, d, hh, mm, ss] = match;\n const date = new Date(\n Number(y),\n Number(m) - 1,\n Number(d),\n Number(hh ?? 0),\n Number(mm ?? 0),\n Number(ss ?? 0),\n 0,\n );\n return Number.isNaN(date.getTime()) ? undefined : date;\n}\n\n/** A date the calendar could actually show — `Feb 31` rolled over, so no. */\nfunction makeLocalDate(\n shortYear: number,\n month: number,\n day: number,\n clock: number[],\n): Date | undefined {\n // `12/25/26` means 2026, not the year 26 — and `new Date(26, …)` would say\n // 1926. Two figures are this century.\n const year = shortYear < 100 ? 2000 + shortYear : shortYear;\n if (month < 1 || month > 12 || day < 1 || day > 31) return undefined;\n const [hh = 0, mm = 0, ss = 0] = clock;\n if (hh > 23 || mm > 59 || ss > 59) return undefined;\n const date = new Date(year, month - 1, day, hh, mm, ss, 0);\n return date.getMonth() === month - 1 && date.getDate() === day\n ? date\n : undefined;\n}\n\n/**\n * A date out of whatever the viewer typed, read in the same order the field\n * writes it — so what it shows is what it takes back. `yyyy-mm-dd` is read as\n * itself wherever it turns up, since nothing else starts with four figures,\n * and a date spelled out in words still parses so a paste of `Sep 12, 2026`\n * lands. Three numbers at least: the field must not flicker through\n * Decembers on the way to one date.\n */\nfunction parseDateText(\n text: string,\n locales: Intl.LocalesArgument,\n): Date | undefined {\n const trimmed = text.trim();\n if (trimmed === \"\") return undefined;\n\n const numbers = (trimmed.match(/\\d+/g) ?? []).map(Number);\n if (numbers.length >= 3) {\n const clock = numbers.slice(3);\n // `3:04 pm` is not the shape the field writes, but it is a shape people\n // type; move it onto the 24-hour dial the rest of this speaks.\n if (/\\bpm\\b/i.test(trimmed) && clock[0] !== undefined && clock[0] < 12) {\n clock[0] += 12;\n } else if (/\\bam\\b/i.test(trimmed) && clock[0] === 12) {\n clock[0] = 0;\n }\n\n // Four figures up front can only be a year; no locale puts a day or a\n // month there.\n if (/^\\d{4}\\D/.test(trimmed)) {\n const [year, month, day] = numbers;\n return makeLocalDate(year!, month!, day!, clock);\n }\n\n const slots: Partial<Record<DatePart, number>> = {};\n numericOrder(locales).forEach((part, at) => {\n slots[part] = numbers[at];\n });\n if (slots.year != null && slots.month != null && slots.day != null) {\n const made = makeLocalDate(slots.year, slots.month, slots.day, clock);\n if (made) return made;\n }\n }\n\n // Words — a pasted `Sep 12, 2026`. Only worth trying with letters in it and\n // a four-figure year to go with them: `new Date` turns a bare `Sep 12` into\n // this year's, which is a guess the field should not make.\n if (!/[a-z]/i.test(trimmed)) return undefined;\n if (numbers.length < 2 || !/\\b\\d{4}\\b/.test(trimmed)) return undefined;\n const spelled = new Date(trimmed);\n return Number.isNaN(spelled.getTime()) ? undefined : spelled;\n}\n\n/** Zero everything finer than the granularity, so the value means what it says. */\nfunction clampTime(date: Date, time: DatePickerTime | undefined): Date {\n const next = new Date(date);\n next.setMilliseconds(0);\n if (time === \"second\") return next;\n next.setSeconds(0);\n if (time === \"minute\") return next;\n next.setMinutes(0);\n if (time === \"hour\") return next;\n next.setHours(0);\n return next;\n}\n\n/**\n * A value's identity, for telling whether the window on screen is still the\n * one a preset put there. Instants, so a re-render cannot change the answer.\n */\nfunction valueKey(value: Date | DateRange | undefined): string {\n if (value == null) return \"\";\n if (value instanceof Date) return String(value.getTime());\n return `${value.from?.getTime() ?? \"\"}-${value.to?.getTime() ?? \"\"}`;\n}\n\n/** A day from the calendar, wearing the clock the value already carried. */\nfunction withDay(day: Date, keepTimeFrom: Date | undefined): Date {\n const next = new Date(day);\n if (keepTimeFrom) {\n next.setHours(\n keepTimeFrom.getHours(),\n keepTimeFrom.getMinutes(),\n keepTimeFrom.getSeconds(),\n 0,\n );\n }\n return next;\n}\n\nconst startOfMonth = (d: Date) => new Date(d.getFullYear(), d.getMonth(), 1);\nconst endOfMonth = (d: Date) => new Date(d.getFullYear(), d.getMonth() + 1, 0);\n// DayPicker's matchers count calendar days, so a bound carrying a time of day\n// disables nothing extra on the calendar. Widen each to its whole day before\n// handing it to a system picker, which would otherwise enforce the clock too.\nconst startOfDay = (d: Date) =>\n new Date(d.getFullYear(), d.getMonth(), d.getDate());\nconst endOfDay = (d: Date) =>\n new Date(d.getFullYear(), d.getMonth(), d.getDate(), 23, 59, 59, 999);\nconst later = (a: Date | undefined, b: Date) => (a && a > b ? a : b);\nconst earlier = (a: Date | undefined, b: Date) => (a && a < b ? a : b);\n\n/**\n * The only rules a system picker enforces are its first and last day. Returns\n * them, or `null` when the page asked for something the OS cannot express — a\n * weekday rule, a predicate, a hidden set — in which case the calendar, which\n * can enforce it, stays on every device.\n */\nfunction nativeBounds(\n calendarProps: PropsBase | undefined,\n): { min?: Date; max?: Date } | null {\n if (calendarProps?.hidden != null) return null;\n\n let min: Date | undefined;\n let max: Date | undefined;\n const rules: Matcher[] =\n calendarProps?.disabled == null\n ? []\n : Array.isArray(calendarProps.disabled)\n ? calendarProps.disabled\n : [calendarProps.disabled];\n\n for (const rule of rules) {\n if (rule == null || typeof rule !== \"object\" || rule instanceof Date) {\n return null;\n }\n const keys = Object.keys(rule);\n // `{ before }` and `{ after }` alone are the two the OS understands; the\n // pair of them is DayPicker's *interval*, which means the opposite.\n if (keys.length !== 1) return null;\n if (\"before\" in rule && rule.before instanceof Date) {\n min = later(min, startOfDay(rule.before));\n } else if (\"after\" in rule && rule.after instanceof Date) {\n max = earlier(max, endOfDay(rule.after));\n } else {\n return null;\n }\n }\n\n if (calendarProps?.startMonth) {\n min = later(min, startOfMonth(calendarProps.startMonth));\n }\n if (calendarProps?.endMonth) {\n max = earlier(max, endOfDay(endOfMonth(calendarProps.endMonth)));\n }\n return { min, max };\n}\n\n/* --------------------------------------------------------------- devices */\n\nconst COARSE_POINTER = \"(pointer: coarse)\";\n\n/**\n * True where the primary input is a finger. `useSyncExternalStore` so the\n * server and the first client render agree (no match) and the swap happens in\n * the same commit as hydration, rather than as a mismatch.\n */\nfunction useCoarsePointer(): boolean {\n const subscribe = useCallback((notify: () => void) => {\n if (typeof window === \"undefined\" || !window.matchMedia) return () => {};\n const query = window.matchMedia(COARSE_POINTER);\n query.addEventListener(\"change\", notify);\n return () => query.removeEventListener(\"change\", notify);\n }, []);\n\n return useSyncExternalStore(\n subscribe,\n () =>\n typeof window !== \"undefined\" &&\n typeof window.matchMedia === \"function\" &&\n window.matchMedia(COARSE_POINTER).matches,\n () => false,\n );\n}\n\n/* ------------------------------------------------------------------ props */\n\n/**\n * A window the page offers by name — `Last 7 days` — beside the calendar.\n * Pass a function for anything measured from now, so it is resolved at the\n * click rather than at render.\n */\nexport interface DatePickerPreset<T> {\n label: string;\n value: T | (() => T);\n}\n\n/** Extra about a change — present when the value came from a named window. */\nexport interface DatePickerChangeDetails<T> {\n preset: DatePickerPreset<T>;\n}\n\ninterface DatePickerBaseProps {\n /** Field label (associated for accessibility). */\n label?: ReactNode;\n /** Helper text below the field; rendered in the error color when `invalid`. */\n hint?: ReactNode;\n /**\n * What the field shows until something is chosen.\n * @default the shape to type, in this locale's order (`mm/dd/yyyy`)\n */\n placeholder?: string;\n /** Render the invalid state (error ring + error-colored hint). */\n invalid?: boolean;\n disabled?: boolean;\n /** Marks the label with the required asterisk. */\n required?: boolean;\n /** Size variant. @default \"md\" */\n size?: DatePickerSize;\n /**\n * `fill` takes the column it is in, like every other field. `hug` shrinks\n * to the words it is showing, for a field that sits in a toolbar or beside\n * a title rather than in a form.\n * @default \"fill\"\n */\n width?: \"fill\" | \"hug\";\n /**\n * Ask for a time as well as a day, this fine. `hour` sets the hour and\n * zeroes the rest, `minute` the hour and minute, `second` all three. Omit\n * it and the value is midnight on the chosen day.\n */\n time?: DatePickerTime;\n /** Locale for the trigger's words. Defaults to the viewer's. */\n locales?: Intl.LocalesArgument;\n /**\n * Everything else React DayPicker takes — `disabled` days, `startMonth` /\n * `endMonth`, `numberOfMonths`, `weekStartsOn`, `captionLayout`.\n */\n calendarProps?: PropsBase;\n /** Id for the trigger, if the page needs its own. */\n id?: string;\n /** Class applied to the trigger. */\n className?: string;\n /**\n * Accessible name when there is no visible label — a toolbar control\n * beside a page title, which already says what the field is for.\n */\n \"aria-label\"?: string;\n /**\n * The named window the field should read. A page that already knows the\n * name (`Last 24 hours` in the URL) passes it so a remount, and a rolling\n * window recomputed each render, still write the name rather than the\n * figures. The name drops the moment the value is no longer that window\n * — a day picked by hand, or the page clearing this.\n */\n selectedPreset?: string;\n /**\n * How the popover lines up with the field. A hug field on the right of a\n * header wants `end`, so the calendar grows left instead of off-screen.\n * @default \"start\"\n */\n align?: \"start\" | \"center\" | \"end\";\n}\n\nexport interface DatePickerSingleProps extends DatePickerBaseProps {\n /** @default \"single\" */\n mode?: \"single\";\n value?: Date;\n defaultValue?: Date;\n onValueChange?: (\n value: Date | undefined,\n details?: DatePickerChangeDetails<Date>,\n ) => void;\n /** Named days offered beside the calendar. */\n presets?: DatePickerPreset<Date>[];\n}\n\nexport interface DatePickerRangeProps extends DatePickerBaseProps {\n mode: \"range\";\n value?: DateRange;\n defaultValue?: DateRange;\n onValueChange?: (\n value: DateRange | undefined,\n details?: DatePickerChangeDetails<DateRange>,\n ) => void;\n /** Named windows offered beside the calendar — `Last 7 days`, and so on. */\n presets?: DatePickerPreset<DateRange>[];\n /**\n * Shortest and longest span the viewer may pick, counted in days. A pick\n * that would break either restarts the span from the day just clicked, so\n * the bound is felt rather than explained.\n */\n minDays?: number;\n maxDays?: number;\n}\n\nexport type DatePickerProps = DatePickerSingleProps | DatePickerRangeProps;\n\n/* ------------------------------------------------------------- the clock */\n\n/** One labelled time field — the popover's way of asking for the clock. */\nfunction ClockField({\n label,\n value,\n time,\n disabled,\n onChange,\n}: {\n label: string;\n value: Date | undefined;\n time: DatePickerTime;\n disabled?: boolean;\n onChange: (next: string) => void;\n}) {\n return (\n <>\n <span className=\"text-pho-description text-xs\">{label}</span>\n <label\n className={cn(\n \"bg-pho-primary ring-pho-primary rounded-sm px-2 py-1 ring-1 ring-inset\",\n \"focus-within:ring-pho-brand transition-shadow duration-100 ease-linear focus-within:ring-2\",\n )}\n >\n <input\n type=\"time\"\n step={TIME_STEP[time]}\n disabled={disabled}\n aria-label={label}\n value={value ? toClockValue(value, time) : \"\"}\n onChange={(event) => onChange(event.target.value)}\n className={cn(\n \"text-pho-primary w-full bg-transparent text-base tabular-nums outline-none\",\n // The browser's own clock glyph is off-brand and unstyleable;\n // the field's words are the control.\n \"[&::-webkit-calendar-picker-indicator]:hidden\",\n )}\n />\n </label>\n </>\n );\n}\n\n/* ------------------------------------------------------------ the picker */\n\n/**\n * Date Picker — a field that shows the chosen date and opens a `Calendar` to\n * change it. `mode=\"range\"` picks a span instead of a day; the popover stays\n * open until both ends are down.\n *\n * The value is a `Date` (or a `{ from, to }` range), never a string: pass\n * `value` to control it, `defaultValue` to let it keep its own. Clearing is\n * built in — clicking the chosen day again unsets it.\n *\n * `time` asks for the clock as well, to the hour, the minute, or the second.\n *\n * On a touch device the field hands off to the system picker — the OS wheel or\n * dialog, which people already know — as long as the rules the page set are\n * ones it can enforce. A weekday rule or a predicate keeps the calendar, which\n * can; so does `mode=\"range\"`, which no system picker offers.\n */\nexport function DatePicker(props: DatePickerProps) {\n const {\n mode = \"single\",\n defaultValue,\n onValueChange,\n label,\n hint,\n placeholder,\n invalid,\n disabled,\n required,\n size = \"md\",\n width = \"fill\",\n time,\n locales,\n calendarProps,\n id,\n className,\n selectedPreset,\n align = \"start\",\n \"aria-label\": ariaLabel,\n } = props;\n const presets = props.presets as\n DatePickerPreset<Date | DateRange>[] | undefined;\n // Range-only, and read off the union the same way.\n const { minDays, maxDays } = props as DatePickerRangeProps;\n\n // Presence of the prop, not its value: an empty controlled picker is the\n // normal starting state, so `value === undefined` cannot mean \"uncontrolled\".\n const controlled = \"value\" in props;\n const [ownValue, setOwnValue] = useState<Date | DateRange | undefined>(\n defaultValue,\n );\n const value = controlled ? props.value : ownValue;\n const [open, setOpen] = useState(false);\n // A range takes two clicks, and the first one already reads as a complete\n // one-day range ({ from, to } both set), so the value alone can't say when\n // the question is answered. Count the picks in this opening instead.\n const picks = useRef(0);\n\n // Empty, the field shows the shape to type. A span cannot be typed, so it\n // asks in words instead.\n const fieldPlaceholder =\n placeholder ??\n (mode === \"range\" ? \"Pick a date range\" : dateFieldMask(locales, time));\n\n const generatedId = useId();\n const triggerId = id ?? generatedId;\n const hintId = hint ? `${triggerId}-hint` : undefined;\n const calendarId = `${triggerId}-calendar`;\n\n // Whether the calendar should take the caret as it appears — true only when\n // a key asked for it, so a click leaves the caret in the field.\n const [gridFocus, setGridFocus] = useState(false);\n\n // The field is not a `Popover.Trigger`, so Base UI never routes its own\n // opening through `onOpenChange`: a controlled `open` is written straight\n // into the store. Every way in goes through here instead, or the reset an\n // opening owes — the pick count, the month on screen — silently never runs.\n const openPicker = (focusGrid = false) => {\n if (open) return;\n picks.current = 0;\n setMonth(undefined);\n setGridFocus(focusGrid);\n setOpen(true);\n };\n\n const notify = onValueChange as\n | ((\n v: Date | DateRange | undefined,\n d?: DatePickerChangeDetails<Date | DateRange>,\n ) => void)\n | undefined;\n\n const commit = (\n next: Date | DateRange | undefined,\n details?: DatePickerChangeDetails<Date | DateRange>,\n ) => {\n if (details) {\n setIgnoreSelected(false);\n } else {\n setIgnoreSelected(true);\n setChosen(null);\n }\n if (!controlled) setOwnValue(next);\n // The two modes have disjoint value types, and the union's callback is\n // only ever handed the shape its own mode produces. A second argument\n // is reserved for a named window, so a calendar pick stays a one-arg\n // call — existing listeners keep matching.\n if (details) notify?.(next, details);\n else notify?.(next);\n };\n\n const single = mode === \"single\" ? (value as Date | undefined) : undefined;\n const range = mode === \"range\" ? (value as DateRange | undefined) : undefined;\n // Reopen where the value lives, not on today's month.\n const anchor = single ?? range?.from;\n\n // The field is a text input, so the words in it are the viewer's until they\n // leave: `null` means \"whatever the value says\", anything else is what they\n // typed. Blur, a pick, and closing all hand the field back to the value.\n const [draft, setDraft] = useState<string | null>(null);\n // A preset names the window it set; the name stands only while the value is\n // still the one it produced, so a day picked afterwards drops the name with\n // no bookkeeping.\n const [chosen, setChosen] = useState<{ label: string; key: string } | null>(\n null,\n );\n // `selectedPreset` is the page's name for a rolling window. A hand pick\n // has to drop that name even if the page is a frame late clearing it —\n // otherwise the field still says \"Last 24 hours\" over a day the viewer\n // just chose. A new name from the page (or the same name after a remount)\n // starts honoring it again.\n const [ignoreSelected, setIgnoreSelected] = useState(false);\n useEffect(() => {\n setIgnoreSelected(false);\n }, [selectedPreset]);\n const presetLabel =\n selectedPreset && !ignoreSelected\n ? selectedPreset\n : chosen && chosen.key === valueKey(value)\n ? chosen.label\n : null;\n\n const text = draft ?? presetLabel ?? formatDateLabel(value, locales, time);\n // A typeable field stays wide enough for the shape to type, so it does\n // not jump when a date answers it. A span is read-only — hug the words\n // on screen, not the empty-state sentence sitting underneath.\n const hugChars = Math.max(\n text.length,\n mode === \"range\" ? 0 : fieldPlaceholder.length,\n 1,\n );\n const hugToWords = width === \"hug\" && mode === \"range\";\n\n const pickPreset = (preset: DatePickerPreset<Date | DateRange>) => {\n const next =\n typeof preset.value === \"function\" ? preset.value() : preset.value;\n setChosen({ label: preset.label, key: valueKey(next) });\n setDraft(null);\n commit(next, { preset });\n // A named window is the whole answer, clock included.\n setOpen(false);\n };\n\n // The month on screen follows what is typed, and resets to the value's own\n // month each time the calendar opens. Held from the first render rather than\n // handed over later: DayPicker keeps its own month until the prop arrives,\n // and a calendar that starts uncontrolled would ignore the first jump.\n const [month, setMonth] = useState<Date | undefined>(undefined);\n const [thisMonth] = useState(() => calendarProps?.today ?? new Date());\n const shownMonth =\n month ?? calendarProps?.defaultMonth ?? anchor ?? thisMonth;\n\n const fieldRef = useRef<HTMLDivElement>(null);\n const popupRef = useRef<HTMLDivElement>(null);\n\n const coarse = useCoarsePointer();\n const bounds = nativeBounds(calendarProps);\n // No system picker offers a range, so that mode keeps the calendar; so does\n // a rule the OS cannot enforce.\n const native =\n coarse && mode === \"single\" && bounds != null && !presets?.length;\n\n const face = (\n <>\n <IconCalendar className=\"text-pho-secondary size-4 shrink-0\" />\n <span\n className={cn(\n \"min-w-0 flex-1 truncate\",\n text === \"\" && \"text-pho-placeholder\",\n )}\n >\n {text === \"\" ? fieldPlaceholder : text}\n </span>\n </>\n );\n\n return (\n <div\n className={cn(\n \"flex flex-col gap-1.5\",\n width === \"hug\" ? \"w-fit\" : \"w-full\",\n )}\n >\n {label ? (\n <label\n htmlFor={triggerId}\n className=\"text-pho-secondary flex w-fit cursor-default items-center gap-0.5 text-base font-medium\"\n >\n {label}\n {required ? <span className=\"text-pho-brand\">*</span> : null}\n </label>\n ) : null}\n\n {native ? (\n <div\n data-invalid={invalid || undefined}\n className={cn(\n TRIGGER_BASE,\n TRIGGER_NATIVE,\n width === \"hug\" ? \"w-fit\" : \"w-full\",\n SIZE_PAD[size],\n SIZE_RADIUS[size],\n className,\n )}\n >\n {face}\n {/* The system field lies over the whole control at zero opacity:\n the tap opens the OS picker, the words underneath stay Pho's. */}\n <input\n id={triggerId}\n type={time ? \"datetime-local\" : \"date\"}\n step={time ? TIME_STEP[time] : undefined}\n min={\n bounds?.min\n ? time\n ? toDateTimeValue(clampTime(bounds.min, time), time)\n : toDateValue(bounds.min)\n : undefined\n }\n max={\n bounds?.max\n ? time\n ? toDateTimeValue(clampTime(bounds.max, time), time)\n : toDateValue(bounds.max)\n : undefined\n }\n required={required}\n disabled={disabled}\n aria-label={ariaLabel}\n aria-describedby={hintId}\n value={\n single\n ? time\n ? toDateTimeValue(single, time)\n : toDateValue(single)\n : \"\"\n }\n onChange={(event) => {\n const next = fromInputValue(event.target.value);\n commit(next ? clampTime(next, time) : undefined);\n }}\n className=\"absolute inset-0 size-full cursor-pointer opacity-0\"\n />\n </div>\n ) : (\n <Popover.Root\n open={open}\n onOpenChange={(next, details) => {\n // Clicking in the field is how the viewer reaches the caret, so it\n // opens the calendar and never takes it away again — the field is\n // not a trigger Base UI knows about, so its own presses arrive\n // here as presses from outside.\n if (\n !next &&\n details.reason === \"outside-press\" &&\n details.event.target instanceof Node &&\n fieldRef.current?.contains(details.event.target)\n ) {\n return;\n }\n // Opening is `openPicker`'s job; this only ever hears about\n // closes (Escape, a click outside) and the odd programmatic open.\n if (next) {\n picks.current = 0;\n setMonth(undefined);\n } else {\n setDraft(null);\n setGridFocus(false);\n }\n setOpen(next);\n }}\n >\n <div\n ref={fieldRef}\n data-invalid={invalid || undefined}\n data-popup-open={open || undefined}\n className={cn(\n TRIGGER_BASE,\n TRIGGER_FIELD,\n width === \"hug\" ? \"w-fit\" : \"w-full\",\n SIZE_PAD[size],\n SIZE_RADIUS[size],\n className,\n )}\n >\n <IconCalendar className=\"text-pho-secondary size-4 shrink-0\" />\n <input\n id={triggerId}\n type=\"text\"\n // A span is two dates and a separator; there is nothing\n // sensible to type, so the field only opens the calendar.\n readOnly={mode === \"range\"}\n disabled={disabled}\n required={required}\n placeholder={fieldPlaceholder}\n aria-label={ariaLabel}\n aria-describedby={hintId}\n // The APG's date-picker combobox: a text field that also says\n // what it opens. `textbox` alone does not support `aria-expanded`.\n role=\"combobox\"\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n aria-controls={open ? calendarId : undefined}\n autoComplete=\"off\"\n spellCheck={false}\n value={text}\n onFocus={() => openPicker()}\n onMouseDown={() => openPicker()}\n onChange={(event) => {\n const typed = event.target.value;\n setDraft(typed);\n if (typed.trim() === \"\") {\n commit(undefined);\n return;\n }\n const parsed = parseDateText(typed, locales);\n if (parsed) {\n commit(clampTime(parsed, time));\n // Follow the words: the calendar shows what was typed.\n setMonth(parsed);\n }\n }}\n onBlur={() => setDraft(null)}\n onKeyDown={(event) => {\n if (event.key === \"Escape\" && open) {\n event.preventDefault();\n setDraft(null);\n setOpen(false);\n return;\n }\n if (event.key === \"ArrowDown\") {\n event.preventDefault();\n // Hand the caret to the grid, where the arrows mean days.\n const grid = popupRef.current?.querySelector<HTMLElement>(\n \"td[data-day] button[tabindex='0']\",\n );\n if (grid) {\n grid.focus();\n return;\n }\n // Closed: the grid is not mounted yet, so the calendar takes\n // the caret itself as it appears — one press, not two.\n openPicker(true);\n }\n }}\n // Typed fields use `size`, not `field-sizing: content` — that\n // sizes from the current content and ignores `size` outright,\n // so a one-letter draft collapsed the field to 20px against\n // the shape to type. A span cannot be typed, so it hugs the\n // glyphs on screen (`Last 30 minutes`, not sixteen `M`s).\n size={width === \"hug\" && !hugToWords ? hugChars : undefined}\n className={cn(\n \"text-pho-primary placeholder:text-pho-placeholder bg-transparent outline-none\",\n hugToWords\n ? \"field-sizing-content w-auto min-w-min\"\n : width === \"hug\"\n ? \"min-w-0\"\n : \"min-w-0 flex-1\",\n mode === \"range\" && \"cursor-pointer\",\n )}\n />\n </div>\n\n <Popover.Portal>\n <Popover.Positioner anchor={fieldRef} align={align} sideOffset={6}>\n {/* Two months on a phone are taller than the room under the\n field; cap the popup at what Base UI measured and let it\n scroll rather than running off the screen. */}\n <Popover.Popup\n ref={popupRef}\n id={calendarId}\n // The field keeps the caret: the viewer is mid-word, and the\n // calendar is a second way to answer, not a takeover.\n initialFocus={false}\n finalFocus={false}\n className=\"max-h-[var(--available-height)] overflow-y-auto p-3\"\n >\n <div className=\"flex flex-col gap-3 sm:flex-row\">\n {presets?.length ? (\n // Beside the calendar where there is room, above it on a\n // phone, where a row that scrolls sideways costs no height.\n <div\n // A labelled set of buttons, not a form section.\n // oxlint-disable-next-line jsx-a11y/prefer-tag-over-role\n role=\"group\"\n aria-label=\"Presets\"\n className={cn(\n \"flex shrink-0 gap-1 overflow-x-auto\",\n \"sm:border-pho-secondary sm:w-36 sm:flex-col sm:gap-0.5 sm:overflow-visible sm:border-r sm:pr-3\",\n )}\n >\n {presets.map((preset) => (\n <button\n key={preset.label}\n type=\"button\"\n aria-pressed={preset.label === presetLabel}\n onClick={() => pickPreset(preset)}\n className={cn(\n PRESET,\n preset.label === presetLabel && PRESET_ON,\n )}\n >\n {preset.label}\n </button>\n ))}\n </div>\n ) : null}\n\n <div>\n {mode === \"range\" ? (\n <Calendar\n {...calendarProps}\n mode=\"range\"\n min={minDays}\n max={maxDays}\n month={shownMonth}\n onMonthChange={setMonth}\n // DayPicker's own prop, not the DOM attribute.\n // oxlint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={gridFocus}\n selected={range}\n onSelect={(next, clicked) => {\n const first = picks.current === 0;\n picks.current += 1;\n // Reopened on a span that is already settled: the first\n // click starts a new one. DayPicker would otherwise drag\n // the nearer end over, so asking for Sep 20 – 25 on top\n // of Sep 1 – 8 would land on Sep 1 – 25.\n if (first && range?.to) {\n const day = clampTime(\n withDay(clicked, time ? range.from : undefined),\n time,\n );\n commit({ from: day, to: new Date(day) });\n setDraft(null);\n return;\n }\n const kept = next && {\n from:\n next.from &&\n clampTime(\n withDay(\n next.from,\n time ? range?.from : undefined,\n ),\n time,\n ),\n to:\n next.to &&\n clampTime(\n withDay(next.to, time ? range?.to : undefined),\n time,\n ),\n };\n commit(kept);\n setDraft(null);\n // Second pick, and the question is answered either way:\n // both ends down, or the same day twice, which DayPicker\n // reads as clearing the span. Unless a time is still to\n // be set, which lives below.\n if (\n !time &&\n picks.current >= 2 &&\n (!kept || (kept.from && kept.to))\n ) {\n setOpen(false);\n }\n }}\n />\n ) : (\n <Calendar\n {...calendarProps}\n mode=\"single\"\n month={shownMonth}\n onMonthChange={setMonth}\n // oxlint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={gridFocus}\n selected={single}\n onSelect={(next) => {\n commit(\n next &&\n clampTime(\n withDay(next, time ? single : undefined),\n time,\n ),\n );\n setDraft(null);\n // The clock is still to be set, and it is below.\n if (!time) setOpen(false);\n }}\n />\n )}\n\n {time ? (\n <div className=\"border-pho-secondary mt-3 grid grid-cols-[auto_1fr] items-center gap-x-3 gap-y-2 border-t pt-3\">\n {mode === \"range\" ? (\n <>\n <ClockField\n label=\"From\"\n value={range?.from}\n time={time}\n onChange={(clock) => {\n if (!range?.from) return;\n const next = fromInputValue(\n `${toDateValue(range.from)}T${clock}`,\n );\n if (next) {\n commit({\n ...range,\n from: clampTime(next, time),\n });\n }\n }}\n disabled={!range?.from}\n />\n <ClockField\n label=\"To\"\n value={range?.to}\n time={time}\n onChange={(clock) => {\n if (!range?.to) return;\n const next = fromInputValue(\n `${toDateValue(range.to)}T${clock}`,\n );\n if (next) {\n commit({\n ...range,\n to: clampTime(next, time),\n });\n }\n }}\n disabled={!range?.to}\n />\n </>\n ) : (\n <ClockField\n label=\"Time\"\n value={single}\n time={time}\n onChange={(clock) => {\n if (!single) return;\n const next = fromInputValue(\n `${toDateValue(single)}T${clock}`,\n );\n if (next) commit(clampTime(next, time));\n }}\n disabled={!single}\n />\n )}\n </div>\n ) : null}\n </div>\n </div>\n </Popover.Popup>\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n )}\n\n {hint ? (\n <p\n id={hintId}\n className={cn(\n \"text-pho-description text-base\",\n invalid && \"text-pho-error\",\n )}\n >\n {hint}\n </p>\n ) : null}\n </div>\n );\n}\n\nDatePicker.displayName = \"DatePicker\";"],"ignoreList":[0],"mappings":";;;;;;;AASA,IAAMc,KAAa;AAAA,EAAC,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAkF,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAW,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAU,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAY,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAY,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,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A,gBACZ,CAAA;AAAA,cAEA,CAAA,IACH,IACD,EAAA,CAAA,CACF;AAAA,Y;A,UACQ,CAAA;AAAA,QACG,CAAA,EACN,CAAA,CACJ;AAAA,M;A,MAGflC,IACC,gBAAAtG,EAAC,KAAD;AAAA,QACE,IAAI6H;AAAA,QACJ,WAAWxI,EACT,kCACAmH,KAAW,gBACb;AAAA,QAEC,UAAAF;AAAA,MACA,CAAA,IACD;AAAA,IACD;AAAA,E;AAET;AAEAL,GAAW,cAAc"}
1
+ {"version":3,"file":"date-picker-D-sWo3i8.js","names":["_Fragment","cn","createReactComponent","Calendar","Popover","useCallback","useEffect","useId","useRef","useState","useSyncExternalStore","Fragment$1","jsx","jsxs","__iconNode","IconCalendar","TIME_STEP","SIZE_PAD","SIZE_RADIUS","TRIGGER_BASE","TRIGGER_FIELD","TRIGGER_NATIVE","PRESET","PRESET_ON","SPACE_SEPARATORS","flattenSpaces","words","NUMERIC_DATE","NUMERIC_CLOCK","SPAN_DASH","SAMPLE","numericFormat","locales","time","isDatePart","type","numericOrder","part","MASK","dateFieldMask","formatDateLabel","value","format","joinSpan","from","to","hasClock","a","b","text","parts","same","at","cut","keep","pad","n","toDateValue","date","toClockValue","hm","toDateTimeValue","fromInputValue","match","y","m","d","hh","mm","ss","makeLocalDate","shortYear","month","day","clock","year","parseDateText","trimmed","numbers","slots","made","spelled","clampTime","next","valueKey","withDay","keepTimeFrom","startOfMonth","endOfMonth","startOfDay","endOfDay","later","earlier","nativeBounds","calendarProps","min","max","rules","rule","COARSE_POINTER","useCoarsePointer","subscribe","notify","query","ClockField","label","disabled","onChange","event","DatePicker","props","mode","defaultValue","onValueChange","hint","placeholder","invalid","required","size","width","id","className","selectedPreset","align","ariaLabel","presets","minDays","maxDays","controlled","ownValue","setOwnValue","open","setOpen","picks","fieldPlaceholder","generatedId","triggerId","hintId","calendarId","gridFocus","setGridFocus","openPicker","focusGrid","setMonth","commit","details","setIgnoreSelected","setChosen","single","range","anchor","draft","setDraft","chosen","ignoreSelected","presetLabel","hugChars","hugToWords","pickPreset","preset","thisMonth","shownMonth","fieldRef","popupRef","coarse","bounds","native","face","typed","parsed","grid","clicked","first","kept"],"sources":["../../../../node_modules/.pnpm/@tabler+icons-react@3.49.0_react@19.3.1/node_modules/@tabler/icons-react/dist/esm/icons/IconCalendar.mjs","../../src/components/date-picker/date-picker.tsx"],"sourcesContent":["/**\n * @license @tabler/icons-react v3.49.0 - MIT\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createReactComponent from '../createReactComponent.mjs';\n\nconst __iconNode = [[\"path\", { \"d\": \"M4 7a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12\", \"key\": \"svg-0\" }], [\"path\", { \"d\": \"M16 3v4\", \"key\": \"svg-1\" }], [\"path\", { \"d\": \"M8 3v4\", \"key\": \"svg-2\" }], [\"path\", { \"d\": \"M4 11h16\", \"key\": \"svg-3\" }], [\"path\", { \"d\": \"M11 15h1\", \"key\": \"svg-4\" }], [\"path\", { \"d\": \"M12 15v3\", \"key\": \"svg-5\" }]];\nconst IconCalendar = createReactComponent(\"outline\", \"calendar\", \"Calendar\", __iconNode);\n\nexport { __iconNode, IconCalendar as default };\n","import {\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n useSyncExternalStore,\n type ReactNode,\n} from \"react\";\nimport { IconCalendar } from \"@tabler/icons-react\";\nimport type { DateRange, Matcher, PropsBase } from \"react-day-picker\";\nimport { Calendar } from \"../calendar\";\nimport { Popover } from \"../popover\";\nimport type { InputSize } from \"../input\";\nimport { cn } from \"../../utils/cn\";\n\n/** The trigger wears Input's sizes so the two line up in one form. */\nexport type DatePickerSize = InputSize;\n\n/**\n * How fine the time is asked for, and read back. Omit it for a date alone.\n * The value is always a `Date`; the granularity says which of its parts the\n * viewer sets, and everything below is zeroed.\n */\nexport type DatePickerTime = \"hour\" | \"minute\" | \"second\";\n\n/** `step` for a native time field — the unit it moves and shows. */\nconst TIME_STEP: Record<DatePickerTime, number> = {\n hour: 3600,\n minute: 60,\n second: 1,\n};\n\n// Effective padding matches Input's (12/8px, lg 14/10px); Input reaches it\n// through a 2px wrapper inset it has to compensate for, the trigger directly.\nconst SIZE_PAD: Record<DatePickerSize, string> = {\n // 16px until there is room — a 14px control next to a 16px field looks shrunk.\n sm: \"px-3 py-2 text-md md:text-base\",\n md: \"px-3 py-2 text-md\",\n lg: \"px-3.5 py-2.5 text-md\",\n};\n\nconst SIZE_RADIUS: Record<DatePickerSize, string> = {\n sm: \"rounded-base\",\n md: \"rounded-base\",\n lg: \"squircle rounded-base\",\n};\n\nconst TRIGGER_BASE = cn(\n \"bg-pho-primary ring-pho-primary text-pho-primary relative flex cursor-pointer items-center gap-2 text-left ring-1 ring-inset\",\n \"transition-shadow duration-100 ease-linear focus-visible:outline-none\",\n // Invalid is mid-weight — thicker than the rest hairline, thinner than focus.\n \"data-[invalid]:ring-pho-error-subtle data-[invalid]:ring-[1.5px]\",\n);\n\n// Open or focused, the edge is Input's: the brand ring at 2px in place of the\n// hairline. The popover path focuses the button itself; the native path puts a\n// system field over it, so the ring follows the field inside.\nconst TRIGGER_FIELD = cn(\n \"has-[input:focus-visible]:ring-pho-brand data-[popup-open]:ring-pho-brand has-[input:focus-visible]:ring-2 data-[popup-open]:ring-2\",\n \"data-[invalid]:has-[input:focus-visible]:ring-pho-error data-[invalid]:data-[popup-open]:ring-pho-error\",\n \"has-[input:disabled]:cursor-not-allowed has-[input:disabled]:opacity-50\",\n);\n\nconst TRIGGER_NATIVE = cn(\n \"has-[input:focus-visible]:ring-pho-brand has-[input:focus-visible]:ring-2\",\n \"data-[invalid]:has-[input:focus-visible]:ring-pho-error\",\n \"has-[input:disabled]:cursor-not-allowed has-[input:disabled]:opacity-50\",\n);\n\n/**\n * A named window in the rail beside the calendar — the Menu row's manners,\n * since that is what a list of choices is.\n */\nconst PRESET = cn(\n \"flex shrink-0 cursor-pointer items-center rounded-sm px-2.5 py-1.5 text-left text-base whitespace-nowrap select-none\",\n \"text-pho-secondary transition-[color,background-color] duration-150 ease-out\",\n \"hover:bg-pho-ghost-hover hover:text-pho-primary\",\n \"outline-pho-brand focus-visible:outline-2 focus-visible:-outline-offset-1\",\n \"sm:w-full\",\n);\n\n/** The one in play. Quiet, like a highlighted menu row — not an action fill. */\nconst PRESET_ON = \"bg-pho-ghost-hover text-pho-primary font-medium\";\n\n/* ------------------------------------------------------------------ words */\n\n/**\n * ICU disagrees with itself about which space belongs before `AM` and around\n * a range dash: Node sends a narrow no-break space and a thin space where\n * Chrome sends ordinary ones. The two strings look identical and are not, so\n * a server-rendered label would fail to hydrate. Flattening every space\n * separator to the ordinary one makes the words the same on both sides.\n */\nconst SPACE_SEPARATORS = /[\\u00a0\\u2000-\\u200a\\u202f\\u205f\\u3000]/g;\nconst flattenSpaces = (words: string) => words.replace(SPACE_SEPARATORS, \" \");\n\n/** The date's parts, all in figures — the shape that is quickest to type. */\nconst NUMERIC_DATE = {\n year: \"numeric\",\n month: \"2-digit\",\n day: \"2-digit\",\n} as const;\n\n/** The clock, on a 24-hour dial: `15:04` is fewer keystrokes than `3:04 PM`. */\nconst NUMERIC_CLOCK: Record<DatePickerTime, Intl.DateTimeFormatOptions> = {\n hour: { hour: \"2-digit\", minute: \"2-digit\", hourCycle: \"h23\" },\n minute: { hour: \"2-digit\", minute: \"2-digit\", hourCycle: \"h23\" },\n second: {\n hour: \"2-digit\",\n minute: \"2-digit\",\n second: \"2-digit\",\n hourCycle: \"h23\",\n },\n};\n\n/**\n * What sits between the two ends of a span. No spaces around it — the field\n * is tight and the dates are already grouped by their own separators. An en\n * dash rather than a hyphen because a hyphen is one: `2026-09-01-08` in a\n * year-first locale would read as three numbers, `2026-09-01–08` as two dates.\n */\nconst SPAN_DASH = \"\\u2013\";\n\n/** A day whose parts are all different, so the locale's order reads clearly. */\nconst SAMPLE = new Date(2026, 8, 12, 15, 4, 5);\n\nfunction numericFormat(\n locales: Intl.LocalesArgument,\n time: DatePickerTime | undefined,\n) {\n return new Intl.DateTimeFormat(locales, {\n ...NUMERIC_DATE,\n ...(time ? NUMERIC_CLOCK[time] : {}),\n });\n}\n\ntype DatePart = \"year\" | \"month\" | \"day\";\nconst isDatePart = (type: string): type is DatePart =>\n type === \"year\" || type === \"month\" || type === \"day\";\n\n/** Which of year, month and day comes first here, and which comes last. */\nfunction numericOrder(locales: Intl.LocalesArgument): DatePart[] {\n return new Intl.DateTimeFormat(locales, NUMERIC_DATE)\n .formatToParts(SAMPLE)\n .map((part) => part.type)\n .filter(isDatePart);\n}\n\nconst MASK: Record<DatePart, string> = {\n year: \"yyyy\",\n month: \"mm\",\n day: \"dd\",\n};\n\n/**\n * The shape to type, in this locale's own order — `mm/dd/yyyy`,\n * `yyyy-mm-dd`, `dd.mm.yyyy`. Lowercase, the way a browser's own date field\n * writes it, so the two paths read alike.\n */\nexport function dateFieldMask(\n locales?: Intl.LocalesArgument,\n time?: DatePickerTime,\n): string {\n return flattenSpaces(\n numericFormat(locales, time)\n .formatToParts(SAMPLE)\n .map((part) =>\n isDatePart(part.type)\n ? MASK[part.type]\n : part.type === \"hour\"\n ? \"hh\"\n : part.type === \"minute\"\n ? \"mm\"\n : part.type === \"second\"\n ? \"ss\"\n : part.value,\n )\n .join(\"\"),\n );\n}\n\n/**\n * The figures in the field — `09/12/2026`, or `09/10/2026–09/13/2026` for a\n * span, in the viewer's locale. An empty or half-finished range prints just\n * the day that is settled; nothing selected prints nothing. Pass `time` to\n * print the clock too, at the precision that was asked for.\n *\n * Figures rather than words (`Sep 12, 2026`) because the field is typed into:\n * a month's name is the one part of a date nobody wants to spell.\n */\nexport function formatDateLabel(\n value: Date | DateRange | undefined,\n locales?: Intl.LocalesArgument,\n time?: DatePickerTime,\n): string {\n if (value == null) return \"\";\n const format = numericFormat(locales, time);\n if (value instanceof Date) return flattenSpaces(format.format(value));\n if (value.from == null) return \"\";\n if (value.to == null) return flattenSpaces(format.format(value.from));\n // A span of one day is a day: printing it twice says nothing the once did\n // not, and the first click of a range makes exactly that shape.\n if (\n time == null &&\n value.from.getFullYear() === value.to.getFullYear() &&\n value.from.getMonth() === value.to.getMonth() &&\n value.from.getDate() === value.to.getDate()\n ) {\n return flattenSpaces(format.format(value.from));\n }\n return flattenSpaces(joinSpan(format, value.from, value.to, time != null));\n}\n\n/**\n * Both ends of a span, with whatever they say twice said once — a shared\n * year, and a shared month behind it, printed at the end that carries it.\n * `09/01–09/08/2026`, `01.–08.09.2026`, `2026-09-01–08`. A span carrying a\n * clock is printed whole.\n *\n * Joined here rather than by `Intl.formatRange`, which does this in `de-DE`\n * and `sv-SE` and not in `en-US` or `en-GB`, and which drops the padding the\n * single-date format asks for. Whole fields only, taken from whichever end\n * the year sits at, so the half that is dropped is never the half that\n * distinguishes the two dates.\n */\nfunction joinSpan(\n format: Intl.DateTimeFormat,\n from: Date,\n to: Date,\n hasClock: boolean,\n): string {\n const a = format.formatToParts(from);\n const b = format.formatToParts(to);\n const text = (parts: Intl.DateTimeFormatPart[]) =>\n parts.map((part) => part.value).join(\"\");\n\n // With a clock in it there is nothing worth merging: the tail fields are\n // hours and minutes, the saving is a year that would then print after a\n // time, and a trim that lands mid-clock eats one end's `:00`.\n if (hasClock || a.length !== b.length) {\n return `${text(a)}${SPAN_DASH}${text(b)}`;\n }\n const same = (at: number) =>\n a[at]!.type === b[at]!.type && a[at]!.value === b[at]!.value;\n\n // The year leads (`yyyy-mm-dd`): the second date drops the shared head.\n if (a[0]?.type === \"year\") {\n let cut = 0;\n while (cut < a.length && same(cut)) cut += 1;\n // Back off to a field boundary so a half-written number never survives.\n while (cut > 0 && b[cut - 1]!.type !== \"literal\") cut -= 1;\n if (cut > 0 && cut < a.length) {\n return `${text(a)}${SPAN_DASH}${text(b.slice(cut))}`;\n }\n return `${text(a)}${SPAN_DASH}${text(b)}`;\n }\n\n // The year trails (`mm/dd/yyyy`, `dd.mm.yyyy`): the first date drops the\n // shared tail.\n let keep = a.length;\n while (keep > 0 && same(keep - 1)) keep -= 1;\n while (keep < a.length && a[keep]!.type !== \"literal\") keep += 1;\n if (keep > 0 && keep < a.length) {\n return `${text(a.slice(0, keep))}${SPAN_DASH}${text(b)}`;\n }\n return `${text(a)}${SPAN_DASH}${text(b)}`;\n}\n\n/* ------------------------------------------------------- date arithmetic */\n\nconst pad = (n: number) => String(n).padStart(2, \"0\");\n\n/** `YYYY-MM-DD` in the viewer's own zone — never `toISOString`, which is UTC. */\nfunction toDateValue(date: Date): string {\n return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;\n}\n\nfunction toClockValue(date: Date, time: DatePickerTime): string {\n const hm = `${pad(date.getHours())}:${pad(date.getMinutes())}`;\n return time === \"second\" ? `${hm}:${pad(date.getSeconds())}` : hm;\n}\n\n/** The `datetime-local` spelling of an instant, at the asked-for precision. */\nfunction toDateTimeValue(date: Date, time: DatePickerTime): string {\n return `${toDateValue(date)}T${toClockValue(date, time)}`;\n}\n\n/**\n * Read back a `date` or `datetime-local` field. Parsed part by part rather\n * than handed to `new Date(string)`, which reads a bare `YYYY-MM-DD` as UTC\n * midnight and lands on the day before west of Greenwich.\n */\nfunction fromInputValue(value: string): Date | undefined {\n const match =\n /^(\\d{4})-(\\d{2})-(\\d{2})(?:T(\\d{2}):(\\d{2})(?::(\\d{2}))?)?$/.exec(value);\n if (!match) return undefined;\n const [, y, m, d, hh, mm, ss] = match;\n const date = new Date(\n Number(y),\n Number(m) - 1,\n Number(d),\n Number(hh ?? 0),\n Number(mm ?? 0),\n Number(ss ?? 0),\n 0,\n );\n return Number.isNaN(date.getTime()) ? undefined : date;\n}\n\n/** A date the calendar could actually show — `Feb 31` rolled over, so no. */\nfunction makeLocalDate(\n shortYear: number,\n month: number,\n day: number,\n clock: number[],\n): Date | undefined {\n // `12/25/26` means 2026, not the year 26 — and `new Date(26, …)` would say\n // 1926. Two figures are this century.\n const year = shortYear < 100 ? 2000 + shortYear : shortYear;\n if (month < 1 || month > 12 || day < 1 || day > 31) return undefined;\n const [hh = 0, mm = 0, ss = 0] = clock;\n if (hh > 23 || mm > 59 || ss > 59) return undefined;\n const date = new Date(year, month - 1, day, hh, mm, ss, 0);\n return date.getMonth() === month - 1 && date.getDate() === day\n ? date\n : undefined;\n}\n\n/**\n * A date out of whatever the viewer typed, read in the same order the field\n * writes it — so what it shows is what it takes back. `yyyy-mm-dd` is read as\n * itself wherever it turns up, since nothing else starts with four figures,\n * and a date spelled out in words still parses so a paste of `Sep 12, 2026`\n * lands. Three numbers at least: the field must not flicker through\n * Decembers on the way to one date.\n */\nfunction parseDateText(\n text: string,\n locales: Intl.LocalesArgument,\n): Date | undefined {\n const trimmed = text.trim();\n if (trimmed === \"\") return undefined;\n\n const numbers = (trimmed.match(/\\d+/g) ?? []).map(Number);\n if (numbers.length >= 3) {\n const clock = numbers.slice(3);\n // `3:04 pm` is not the shape the field writes, but it is a shape people\n // type; move it onto the 24-hour dial the rest of this speaks.\n if (/\\bpm\\b/i.test(trimmed) && clock[0] !== undefined && clock[0] < 12) {\n clock[0] += 12;\n } else if (/\\bam\\b/i.test(trimmed) && clock[0] === 12) {\n clock[0] = 0;\n }\n\n // Four figures up front can only be a year; no locale puts a day or a\n // month there.\n if (/^\\d{4}\\D/.test(trimmed)) {\n const [year, month, day] = numbers;\n return makeLocalDate(year!, month!, day!, clock);\n }\n\n const slots: Partial<Record<DatePart, number>> = {};\n numericOrder(locales).forEach((part, at) => {\n slots[part] = numbers[at];\n });\n if (slots.year != null && slots.month != null && slots.day != null) {\n const made = makeLocalDate(slots.year, slots.month, slots.day, clock);\n if (made) return made;\n }\n }\n\n // Words — a pasted `Sep 12, 2026`. Only worth trying with letters in it and\n // a four-figure year to go with them: `new Date` turns a bare `Sep 12` into\n // this year's, which is a guess the field should not make.\n if (!/[a-z]/i.test(trimmed)) return undefined;\n if (numbers.length < 2 || !/\\b\\d{4}\\b/.test(trimmed)) return undefined;\n const spelled = new Date(trimmed);\n return Number.isNaN(spelled.getTime()) ? undefined : spelled;\n}\n\n/** Zero everything finer than the granularity, so the value means what it says. */\nfunction clampTime(date: Date, time: DatePickerTime | undefined): Date {\n const next = new Date(date);\n next.setMilliseconds(0);\n if (time === \"second\") return next;\n next.setSeconds(0);\n if (time === \"minute\") return next;\n next.setMinutes(0);\n if (time === \"hour\") return next;\n next.setHours(0);\n return next;\n}\n\n/**\n * A value's identity, for telling whether the window on screen is still the\n * one a preset put there. Instants, so a re-render cannot change the answer.\n */\nfunction valueKey(value: Date | DateRange | undefined): string {\n if (value == null) return \"\";\n if (value instanceof Date) return String(value.getTime());\n return `${value.from?.getTime() ?? \"\"}-${value.to?.getTime() ?? \"\"}`;\n}\n\n/** A day from the calendar, wearing the clock the value already carried. */\nfunction withDay(day: Date, keepTimeFrom: Date | undefined): Date {\n const next = new Date(day);\n if (keepTimeFrom) {\n next.setHours(\n keepTimeFrom.getHours(),\n keepTimeFrom.getMinutes(),\n keepTimeFrom.getSeconds(),\n 0,\n );\n }\n return next;\n}\n\nconst startOfMonth = (d: Date) => new Date(d.getFullYear(), d.getMonth(), 1);\nconst endOfMonth = (d: Date) => new Date(d.getFullYear(), d.getMonth() + 1, 0);\n// DayPicker's matchers count calendar days, so a bound carrying a time of day\n// disables nothing extra on the calendar. Widen each to its whole day before\n// handing it to a system picker, which would otherwise enforce the clock too.\nconst startOfDay = (d: Date) =>\n new Date(d.getFullYear(), d.getMonth(), d.getDate());\nconst endOfDay = (d: Date) =>\n new Date(d.getFullYear(), d.getMonth(), d.getDate(), 23, 59, 59, 999);\nconst later = (a: Date | undefined, b: Date) => (a && a > b ? a : b);\nconst earlier = (a: Date | undefined, b: Date) => (a && a < b ? a : b);\n\n/**\n * The only rules a system picker enforces are its first and last day. Returns\n * them, or `null` when the page asked for something the OS cannot express — a\n * weekday rule, a predicate, a hidden set — in which case the calendar, which\n * can enforce it, stays on every device.\n */\nfunction nativeBounds(\n calendarProps: PropsBase | undefined,\n): { min?: Date; max?: Date } | null {\n if (calendarProps?.hidden != null) return null;\n\n let min: Date | undefined;\n let max: Date | undefined;\n const rules: Matcher[] =\n calendarProps?.disabled == null\n ? []\n : Array.isArray(calendarProps.disabled)\n ? calendarProps.disabled\n : [calendarProps.disabled];\n\n for (const rule of rules) {\n if (rule == null || typeof rule !== \"object\" || rule instanceof Date) {\n return null;\n }\n const keys = Object.keys(rule);\n // `{ before }` and `{ after }` alone are the two the OS understands; the\n // pair of them is DayPicker's *interval*, which means the opposite.\n if (keys.length !== 1) return null;\n if (\"before\" in rule && rule.before instanceof Date) {\n min = later(min, startOfDay(rule.before));\n } else if (\"after\" in rule && rule.after instanceof Date) {\n max = earlier(max, endOfDay(rule.after));\n } else {\n return null;\n }\n }\n\n if (calendarProps?.startMonth) {\n min = later(min, startOfMonth(calendarProps.startMonth));\n }\n if (calendarProps?.endMonth) {\n max = earlier(max, endOfDay(endOfMonth(calendarProps.endMonth)));\n }\n return { min, max };\n}\n\n/* --------------------------------------------------------------- devices */\n\nconst COARSE_POINTER = \"(pointer: coarse)\";\n\n/**\n * True where the primary input is a finger. `useSyncExternalStore` so the\n * server and the first client render agree (no match) and the swap happens in\n * the same commit as hydration, rather than as a mismatch.\n */\nfunction useCoarsePointer(): boolean {\n const subscribe = useCallback((notify: () => void) => {\n if (typeof window === \"undefined\" || !window.matchMedia) return () => {};\n const query = window.matchMedia(COARSE_POINTER);\n query.addEventListener(\"change\", notify);\n return () => query.removeEventListener(\"change\", notify);\n }, []);\n\n return useSyncExternalStore(\n subscribe,\n () =>\n typeof window !== \"undefined\" &&\n typeof window.matchMedia === \"function\" &&\n window.matchMedia(COARSE_POINTER).matches,\n () => false,\n );\n}\n\n/* ------------------------------------------------------------------ props */\n\n/**\n * A window the page offers by name — `Last 7 days` — beside the calendar.\n * Pass a function for anything measured from now, so it is resolved at the\n * click rather than at render.\n */\nexport interface DatePickerPreset<T> {\n label: string;\n value: T | (() => T);\n}\n\n/** Extra about a change — present when the value came from a named window. */\nexport interface DatePickerChangeDetails<T> {\n preset: DatePickerPreset<T>;\n}\n\ninterface DatePickerBaseProps {\n /** Field label (associated for accessibility). */\n label?: ReactNode;\n /** Helper text below the field; rendered in the error color when `invalid`. */\n hint?: ReactNode;\n /**\n * What the field shows until something is chosen.\n * @default the shape to type, in this locale's order (`mm/dd/yyyy`)\n */\n placeholder?: string;\n /** Render the invalid state (error ring + error-colored hint). */\n invalid?: boolean;\n disabled?: boolean;\n /** Marks the label with the required asterisk. */\n required?: boolean;\n /** Size variant. @default \"md\" */\n size?: DatePickerSize;\n /**\n * `fill` takes the column it is in, like every other field. `hug` shrinks\n * to the words it is showing, for a field that sits in a toolbar or beside\n * a title rather than in a form.\n * @default \"fill\"\n */\n width?: \"fill\" | \"hug\";\n /**\n * Ask for a time as well as a day, this fine. `hour` sets the hour and\n * zeroes the rest, `minute` the hour and minute, `second` all three. Omit\n * it and the value is midnight on the chosen day.\n */\n time?: DatePickerTime;\n /** Locale for the trigger's words. Defaults to the viewer's. */\n locales?: Intl.LocalesArgument;\n /**\n * Everything else React DayPicker takes — `disabled` days, `startMonth` /\n * `endMonth`, `numberOfMonths`, `weekStartsOn`, `captionLayout`.\n */\n calendarProps?: PropsBase;\n /** Id for the trigger, if the page needs its own. */\n id?: string;\n /** Class applied to the trigger. */\n className?: string;\n /**\n * Accessible name when there is no visible label — a toolbar control\n * beside a page title, which already says what the field is for.\n */\n \"aria-label\"?: string;\n /**\n * The named window the field should read. A page that already knows the\n * name (`Last 24 hours` in the URL) passes it so a remount, and a rolling\n * window recomputed each render, still write the name rather than the\n * figures. The name drops the moment the value is no longer that window\n * — a day picked by hand, or the page clearing this.\n */\n selectedPreset?: string;\n /**\n * How the popover lines up with the field. A hug field on the right of a\n * header wants `end`, so the calendar grows left instead of off-screen.\n * @default \"start\"\n */\n align?: \"start\" | \"center\" | \"end\";\n}\n\nexport interface DatePickerSingleProps extends DatePickerBaseProps {\n /** @default \"single\" */\n mode?: \"single\";\n value?: Date;\n defaultValue?: Date;\n onValueChange?: (\n value: Date | undefined,\n details?: DatePickerChangeDetails<Date>,\n ) => void;\n /** Named days offered beside the calendar. */\n presets?: DatePickerPreset<Date>[];\n}\n\nexport interface DatePickerRangeProps extends DatePickerBaseProps {\n mode: \"range\";\n value?: DateRange;\n defaultValue?: DateRange;\n onValueChange?: (\n value: DateRange | undefined,\n details?: DatePickerChangeDetails<DateRange>,\n ) => void;\n /** Named windows offered beside the calendar — `Last 7 days`, and so on. */\n presets?: DatePickerPreset<DateRange>[];\n /**\n * Shortest and longest span the viewer may pick, counted in days. A pick\n * that would break either restarts the span from the day just clicked, so\n * the bound is felt rather than explained.\n */\n minDays?: number;\n maxDays?: number;\n}\n\nexport type DatePickerProps = DatePickerSingleProps | DatePickerRangeProps;\n\n/* ------------------------------------------------------------- the clock */\n\n/** One labelled time field — the popover's way of asking for the clock. */\nfunction ClockField({\n label,\n value,\n time,\n disabled,\n onChange,\n}: {\n label: string;\n value: Date | undefined;\n time: DatePickerTime;\n disabled?: boolean;\n onChange: (next: string) => void;\n}) {\n return (\n <>\n <span className=\"text-pho-description text-xs\">{label}</span>\n <label\n className={cn(\n \"bg-pho-primary ring-pho-primary rounded-sm px-2 py-1 ring-1 ring-inset\",\n \"focus-within:ring-pho-brand transition-shadow duration-100 ease-linear focus-within:ring-2\",\n )}\n >\n <input\n type=\"time\"\n step={TIME_STEP[time]}\n disabled={disabled}\n aria-label={label}\n value={value ? toClockValue(value, time) : \"\"}\n onChange={(event) => onChange(event.target.value)}\n className={cn(\n \"text-pho-primary w-full bg-transparent text-base tabular-nums outline-none\",\n // The browser's own clock glyph is off-brand and unstyleable;\n // the field's words are the control.\n \"[&::-webkit-calendar-picker-indicator]:hidden\",\n )}\n />\n </label>\n </>\n );\n}\n\n/* ------------------------------------------------------------ the picker */\n\n/**\n * Date Picker — a field that shows the chosen date and opens a `Calendar` to\n * change it. `mode=\"range\"` picks a span instead of a day; the popover stays\n * open until both ends are down.\n *\n * The value is a `Date` (or a `{ from, to }` range), never a string: pass\n * `value` to control it, `defaultValue` to let it keep its own. Clearing is\n * built in — clicking the chosen day again unsets it.\n *\n * `time` asks for the clock as well, to the hour, the minute, or the second.\n *\n * On a touch device the field hands off to the system picker — the OS wheel or\n * dialog, which people already know — as long as the rules the page set are\n * ones it can enforce. A weekday rule or a predicate keeps the calendar, which\n * can; so does `mode=\"range\"`, which no system picker offers.\n */\nexport function DatePicker(props: DatePickerProps) {\n const {\n mode = \"single\",\n defaultValue,\n onValueChange,\n label,\n hint,\n placeholder,\n invalid,\n disabled,\n required,\n size = \"md\",\n width = \"fill\",\n time,\n locales,\n calendarProps,\n id,\n className,\n selectedPreset,\n align = \"start\",\n \"aria-label\": ariaLabel,\n } = props;\n const presets = props.presets as\n DatePickerPreset<Date | DateRange>[] | undefined;\n // Range-only, and read off the union the same way.\n const { minDays, maxDays } = props as DatePickerRangeProps;\n\n // Presence of the prop, not its value: an empty controlled picker is the\n // normal starting state, so `value === undefined` cannot mean \"uncontrolled\".\n const controlled = \"value\" in props;\n const [ownValue, setOwnValue] = useState<Date | DateRange | undefined>(\n defaultValue,\n );\n const value = controlled ? props.value : ownValue;\n const [open, setOpen] = useState(false);\n // A range takes two clicks, and the first one already reads as a complete\n // one-day range ({ from, to } both set), so the value alone can't say when\n // the question is answered. Count the picks in this opening instead.\n const picks = useRef(0);\n\n // Empty, the field shows the shape to type. A span cannot be typed, so it\n // asks in words instead.\n const fieldPlaceholder =\n placeholder ??\n (mode === \"range\" ? \"Pick a date range\" : dateFieldMask(locales, time));\n\n const generatedId = useId();\n const triggerId = id ?? generatedId;\n const hintId = hint ? `${triggerId}-hint` : undefined;\n const calendarId = `${triggerId}-calendar`;\n\n // Whether the calendar should take the caret as it appears — true only when\n // a key asked for it, so a click leaves the caret in the field.\n const [gridFocus, setGridFocus] = useState(false);\n\n // The field is not a `Popover.Trigger`, so Base UI never routes its own\n // opening through `onOpenChange`: a controlled `open` is written straight\n // into the store. Every way in goes through here instead, or the reset an\n // opening owes — the pick count, the month on screen — silently never runs.\n const openPicker = (focusGrid = false) => {\n if (open) return;\n picks.current = 0;\n setMonth(undefined);\n setGridFocus(focusGrid);\n setOpen(true);\n };\n\n const notify = onValueChange as\n | ((\n v: Date | DateRange | undefined,\n d?: DatePickerChangeDetails<Date | DateRange>,\n ) => void)\n | undefined;\n\n const commit = (\n next: Date | DateRange | undefined,\n details?: DatePickerChangeDetails<Date | DateRange>,\n ) => {\n if (details) {\n setIgnoreSelected(false);\n } else {\n setIgnoreSelected(true);\n setChosen(null);\n }\n if (!controlled) setOwnValue(next);\n // The two modes have disjoint value types, and the union's callback is\n // only ever handed the shape its own mode produces. A second argument\n // is reserved for a named window, so a calendar pick stays a one-arg\n // call — existing listeners keep matching.\n if (details) notify?.(next, details);\n else notify?.(next);\n };\n\n const single = mode === \"single\" ? (value as Date | undefined) : undefined;\n const range = mode === \"range\" ? (value as DateRange | undefined) : undefined;\n // Reopen where the value lives, not on today's month.\n const anchor = single ?? range?.from;\n\n // The field is a text input, so the words in it are the viewer's until they\n // leave: `null` means \"whatever the value says\", anything else is what they\n // typed. Blur, a pick, and closing all hand the field back to the value.\n const [draft, setDraft] = useState<string | null>(null);\n // A preset names the window it set; the name stands only while the value is\n // still the one it produced, so a day picked afterwards drops the name with\n // no bookkeeping.\n const [chosen, setChosen] = useState<{ label: string; key: string } | null>(\n null,\n );\n // `selectedPreset` is the page's name for a rolling window. A hand pick\n // has to drop that name even if the page is a frame late clearing it —\n // otherwise the field still says \"Last 24 hours\" over a day the viewer\n // just chose. A new name from the page (or the same name after a remount)\n // starts honoring it again.\n const [ignoreSelected, setIgnoreSelected] = useState(false);\n useEffect(() => {\n setIgnoreSelected(false);\n }, [selectedPreset]);\n const presetLabel =\n selectedPreset && !ignoreSelected\n ? selectedPreset\n : chosen && chosen.key === valueKey(value)\n ? chosen.label\n : null;\n\n const text = draft ?? presetLabel ?? formatDateLabel(value, locales, time);\n // A typeable field stays wide enough for the shape to type, so it does\n // not jump when a date answers it. A span is read-only — hug the words\n // on screen, not the empty-state sentence sitting underneath.\n const hugChars = Math.max(\n text.length,\n mode === \"range\" ? 0 : fieldPlaceholder.length,\n 1,\n );\n const hugToWords = width === \"hug\" && mode === \"range\";\n\n const pickPreset = (preset: DatePickerPreset<Date | DateRange>) => {\n const next =\n typeof preset.value === \"function\" ? preset.value() : preset.value;\n setChosen({ label: preset.label, key: valueKey(next) });\n setDraft(null);\n commit(next, { preset });\n // A named window is the whole answer, clock included.\n setOpen(false);\n };\n\n // The month on screen follows what is typed, and resets to the value's own\n // month each time the calendar opens. Held from the first render rather than\n // handed over later: DayPicker keeps its own month until the prop arrives,\n // and a calendar that starts uncontrolled would ignore the first jump.\n const [month, setMonth] = useState<Date | undefined>(undefined);\n const [thisMonth] = useState(() => calendarProps?.today ?? new Date());\n const shownMonth =\n month ?? calendarProps?.defaultMonth ?? anchor ?? thisMonth;\n\n const fieldRef = useRef<HTMLDivElement>(null);\n const popupRef = useRef<HTMLDivElement>(null);\n\n const coarse = useCoarsePointer();\n const bounds = nativeBounds(calendarProps);\n // No system picker offers a range, so that mode keeps the calendar; so does\n // a rule the OS cannot enforce.\n const native =\n coarse && mode === \"single\" && bounds != null && !presets?.length;\n\n const face = (\n <>\n <IconCalendar className=\"text-pho-secondary size-4 shrink-0\" />\n <span\n className={cn(\n \"min-w-0 flex-1 truncate\",\n text === \"\" && \"text-pho-placeholder\",\n )}\n >\n {text === \"\" ? fieldPlaceholder : text}\n </span>\n </>\n );\n\n return (\n <div\n className={cn(\n \"flex flex-col gap-1.5\",\n width === \"hug\" ? \"w-fit\" : \"w-full\",\n )}\n >\n {label ? (\n <label\n htmlFor={triggerId}\n className=\"text-pho-secondary flex w-fit cursor-default items-center gap-0.5 text-base font-medium\"\n >\n {label}\n {required ? <span className=\"text-pho-brand\">*</span> : null}\n </label>\n ) : null}\n\n {native ? (\n <div\n data-invalid={invalid || undefined}\n className={cn(\n TRIGGER_BASE,\n TRIGGER_NATIVE,\n width === \"hug\" ? \"w-fit\" : \"w-full\",\n SIZE_PAD[size],\n SIZE_RADIUS[size],\n className,\n )}\n >\n {face}\n {/* The system field lies over the whole control at zero opacity:\n the tap opens the OS picker, the words underneath stay Pho's. */}\n <input\n id={triggerId}\n type={time ? \"datetime-local\" : \"date\"}\n step={time ? TIME_STEP[time] : undefined}\n min={\n bounds?.min\n ? time\n ? toDateTimeValue(clampTime(bounds.min, time), time)\n : toDateValue(bounds.min)\n : undefined\n }\n max={\n bounds?.max\n ? time\n ? toDateTimeValue(clampTime(bounds.max, time), time)\n : toDateValue(bounds.max)\n : undefined\n }\n required={required}\n disabled={disabled}\n aria-label={ariaLabel}\n aria-describedby={hintId}\n value={\n single\n ? time\n ? toDateTimeValue(single, time)\n : toDateValue(single)\n : \"\"\n }\n onChange={(event) => {\n const next = fromInputValue(event.target.value);\n commit(next ? clampTime(next, time) : undefined);\n }}\n className=\"absolute inset-0 size-full cursor-pointer opacity-0\"\n />\n </div>\n ) : (\n <Popover.Root\n open={open}\n onOpenChange={(next, details) => {\n // Clicking in the field is how the viewer reaches the caret, so it\n // opens the calendar and never takes it away again — the field is\n // not a trigger Base UI knows about, so its own presses arrive\n // here as presses from outside.\n if (\n !next &&\n details.reason === \"outside-press\" &&\n details.event.target instanceof Node &&\n fieldRef.current?.contains(details.event.target)\n ) {\n return;\n }\n // Opening is `openPicker`'s job; this only ever hears about\n // closes (Escape, a click outside) and the odd programmatic open.\n if (next) {\n picks.current = 0;\n setMonth(undefined);\n } else {\n setDraft(null);\n setGridFocus(false);\n }\n setOpen(next);\n }}\n >\n <div\n ref={fieldRef}\n data-invalid={invalid || undefined}\n data-popup-open={open || undefined}\n className={cn(\n TRIGGER_BASE,\n TRIGGER_FIELD,\n width === \"hug\" ? \"w-fit\" : \"w-full\",\n SIZE_PAD[size],\n SIZE_RADIUS[size],\n className,\n )}\n >\n <IconCalendar className=\"text-pho-secondary size-4 shrink-0\" />\n <input\n id={triggerId}\n type=\"text\"\n // A span is two dates and a separator; there is nothing\n // sensible to type, so the field only opens the calendar.\n readOnly={mode === \"range\"}\n disabled={disabled}\n required={required}\n placeholder={fieldPlaceholder}\n aria-label={ariaLabel}\n aria-describedby={hintId}\n // The APG's date-picker combobox: a text field that also says\n // what it opens. `textbox` alone does not support `aria-expanded`.\n role=\"combobox\"\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n aria-controls={open ? calendarId : undefined}\n autoComplete=\"off\"\n spellCheck={false}\n value={text}\n onFocus={() => openPicker()}\n onMouseDown={() => openPicker()}\n onChange={(event) => {\n const typed = event.target.value;\n setDraft(typed);\n if (typed.trim() === \"\") {\n commit(undefined);\n return;\n }\n const parsed = parseDateText(typed, locales);\n if (parsed) {\n commit(clampTime(parsed, time));\n // Follow the words: the calendar shows what was typed.\n setMonth(parsed);\n }\n }}\n onBlur={() => setDraft(null)}\n onKeyDown={(event) => {\n if (event.key === \"Escape\" && open) {\n event.preventDefault();\n setDraft(null);\n setOpen(false);\n return;\n }\n if (event.key === \"ArrowDown\") {\n event.preventDefault();\n // Hand the caret to the grid, where the arrows mean days.\n const grid = popupRef.current?.querySelector<HTMLElement>(\n \"td[data-day] button[tabindex='0']\",\n );\n if (grid) {\n grid.focus();\n return;\n }\n // Closed: the grid is not mounted yet, so the calendar takes\n // the caret itself as it appears — one press, not two.\n openPicker(true);\n }\n }}\n // Typed fields use `size`, not `field-sizing: content` — that\n // sizes from the current content and ignores `size` outright,\n // so a one-letter draft collapsed the field to 20px against\n // the shape to type. A span cannot be typed, so it hugs the\n // glyphs on screen (`Last 30 minutes`, not sixteen `M`s).\n size={width === \"hug\" && !hugToWords ? hugChars : undefined}\n className={cn(\n \"text-pho-primary placeholder:text-pho-placeholder bg-transparent outline-none\",\n hugToWords\n ? \"field-sizing-content w-auto min-w-min\"\n : width === \"hug\"\n ? \"min-w-0\"\n : \"min-w-0 flex-1\",\n mode === \"range\" && \"cursor-pointer\",\n )}\n />\n </div>\n\n <Popover.Portal>\n <Popover.Positioner anchor={fieldRef} align={align} sideOffset={6}>\n {/* Two months on a phone are taller than the room under the\n field; cap the popup at what Base UI measured and let it\n scroll rather than running off the screen. */}\n <Popover.Popup\n ref={popupRef}\n id={calendarId}\n // The field keeps the caret: the viewer is mid-word, and the\n // calendar is a second way to answer, not a takeover.\n initialFocus={false}\n finalFocus={false}\n className=\"max-h-[var(--available-height)] overflow-y-auto p-3\"\n >\n <div className=\"flex flex-col gap-3 sm:flex-row\">\n {presets?.length ? (\n // Beside the calendar where there is room, above it on a\n // phone, where a row that scrolls sideways costs no height.\n <div\n // A labelled set of buttons, not a form section.\n // oxlint-disable-next-line jsx-a11y/prefer-tag-over-role\n role=\"group\"\n aria-label=\"Presets\"\n className={cn(\n \"flex shrink-0 gap-1 overflow-x-auto\",\n \"sm:border-pho-secondary sm:w-36 sm:flex-col sm:gap-0.5 sm:overflow-visible sm:border-r sm:pr-3\",\n )}\n >\n {presets.map((preset) => (\n <button\n key={preset.label}\n type=\"button\"\n aria-pressed={preset.label === presetLabel}\n onClick={() => pickPreset(preset)}\n className={cn(\n PRESET,\n preset.label === presetLabel && PRESET_ON,\n )}\n >\n {preset.label}\n </button>\n ))}\n </div>\n ) : null}\n\n <div>\n {mode === \"range\" ? (\n <Calendar\n {...calendarProps}\n mode=\"range\"\n min={minDays}\n max={maxDays}\n month={shownMonth}\n onMonthChange={setMonth}\n // DayPicker's own prop, not the DOM attribute.\n // oxlint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={gridFocus}\n selected={range}\n onSelect={(next, clicked) => {\n const first = picks.current === 0;\n picks.current += 1;\n // Reopened on a span that is already settled: the first\n // click starts a new one. DayPicker would otherwise drag\n // the nearer end over, so asking for Sep 20 – 25 on top\n // of Sep 1 – 8 would land on Sep 1 – 25.\n if (first && range?.to) {\n const day = clampTime(\n withDay(clicked, time ? range.from : undefined),\n time,\n );\n commit({ from: day, to: new Date(day) });\n setDraft(null);\n return;\n }\n const kept = next && {\n from:\n next.from &&\n clampTime(\n withDay(\n next.from,\n time ? range?.from : undefined,\n ),\n time,\n ),\n to:\n next.to &&\n clampTime(\n withDay(next.to, time ? range?.to : undefined),\n time,\n ),\n };\n commit(kept);\n setDraft(null);\n // Second pick, and the question is answered either way:\n // both ends down, or the same day twice, which DayPicker\n // reads as clearing the span. Unless a time is still to\n // be set, which lives below.\n if (\n !time &&\n picks.current >= 2 &&\n (!kept || (kept.from && kept.to))\n ) {\n setOpen(false);\n }\n }}\n />\n ) : (\n <Calendar\n {...calendarProps}\n mode=\"single\"\n month={shownMonth}\n onMonthChange={setMonth}\n // oxlint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={gridFocus}\n selected={single}\n onSelect={(next) => {\n commit(\n next &&\n clampTime(\n withDay(next, time ? single : undefined),\n time,\n ),\n );\n setDraft(null);\n // The clock is still to be set, and it is below.\n if (!time) setOpen(false);\n }}\n />\n )}\n\n {time ? (\n <div className=\"border-pho-secondary mt-3 grid grid-cols-[auto_1fr] items-center gap-x-3 gap-y-2 border-t pt-3\">\n {mode === \"range\" ? (\n <>\n <ClockField\n label=\"From\"\n value={range?.from}\n time={time}\n onChange={(clock) => {\n if (!range?.from) return;\n const next = fromInputValue(\n `${toDateValue(range.from)}T${clock}`,\n );\n if (next) {\n commit({\n ...range,\n from: clampTime(next, time),\n });\n }\n }}\n disabled={!range?.from}\n />\n <ClockField\n label=\"To\"\n value={range?.to}\n time={time}\n onChange={(clock) => {\n if (!range?.to) return;\n const next = fromInputValue(\n `${toDateValue(range.to)}T${clock}`,\n );\n if (next) {\n commit({\n ...range,\n to: clampTime(next, time),\n });\n }\n }}\n disabled={!range?.to}\n />\n </>\n ) : (\n <ClockField\n label=\"Time\"\n value={single}\n time={time}\n onChange={(clock) => {\n if (!single) return;\n const next = fromInputValue(\n `${toDateValue(single)}T${clock}`,\n );\n if (next) commit(clampTime(next, time));\n }}\n disabled={!single}\n />\n )}\n </div>\n ) : null}\n </div>\n </div>\n </Popover.Popup>\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n )}\n\n {hint ? (\n <p\n id={hintId}\n className={cn(\n \"text-pho-description text-base\",\n invalid && \"text-pho-error\",\n )}\n >\n {hint}\n </p>\n ) : null}\n </div>\n );\n}\n\nDatePicker.displayName = \"DatePicker\";"],"ignoreList":[0],"mappings":";;;;;;;AASA,IAAMc,KAAa;AAAA,EAAC,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAkF,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAW,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAU,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAY,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAY,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAY,KAAO;AAAA,EAAQ,CAAC;AAAC,GACzWC,KAAeb,GAAqB,WAAW,YAAY,YAAYY,EAAU,GCiBjFE,KAA4C;AAAA,EAChD,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AACV,GAIMC,KAA2C;AAAA,EAE/C,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN,GAEMC,KAA8C;AAAA,EAClD,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN,GAEMC,KAAelB,EACnB,gIACA,yEAEA,kEACF,GAKMmB,KAAgBnB,EACpB,uIACA,2GACA,yEACF,GAEMoB,KAAiBpB,EACrB,6EACA,2DACA,yEACF,GAMMqB,KAASrB,EACb,wHACA,gFACA,mDACA,6EACA,WACF,GAGMsB,KAAY,mDAWZC,KAAmB,4CACnBC,IAAA,CAAiBC,MAAkBA,EAAM,QAAQF,IAAkB,GAAG,GAGtEG,KAAe;AAAA,EACnB,MAAM;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,GAAO,GAAI;AAChB,0BAAMlE,IAAOrB,EACX,GAAGL,EAAY4F,EAAM,EAAE,CAAA,IAAK3E,CAAA,EAC9B;AACA,oBAAIS,KACF6D,EAAO;AAAA,sBACL,GAAGK;AAAA,sBACH,IAAInE,EAAUC,GAAMlD,CAAI;AAAA,oBAC1B,CAAC;AAAA,kBAEL;AAAA,kBACA,UAAU,CAACoH,GAAO;AAAA,gBACnB,CAAA,CACD,EAAA,CAAA,IAEF,gBAAAzI,EAAC4F,IAAD;AAAA,kBACE,OAAM;AAAA,kBACN,OAAO4C;AAAA,kBACD,MAAAnH;AAAA,kBACN,UAAA,CAAWyC,MAAU;AACnB,wBAAI,CAAC0E,EAAQ;AACb,0BAAMjE,IAAOrB,EACX,GAAGL,EAAY2F,CAAM,CAAA,IAAK1E,CAAA,EAC5B;AACA,oBAAIS,KAAM6D,EAAO9D,EAAUC,GAAMlD,CAAI,CAAC;AAAA,kBACxC;AAAA,kBACA,UAAU,CAACmH;AAAA,gBACZ,CAAA;AAAA,cAEA,CAAA,IACH,IACD,EAAA,CAAA,CACF;AAAA,Y;A,UACQ,CAAA;AAAA,QACG,CAAA,EACN,CAAA,CACJ;AAAA,M;A,MAGflC,IACC,gBAAAtG,EAAC,KAAD;AAAA,QACE,IAAI6H;AAAA,QACJ,WAAWxI,EACT,kCACAmH,KAAW,gBACb;AAAA,QAEC,UAAAF;AAAA,MACA,CAAA,IACD;AAAA,IACD;AAAA,E;AAET;AAEAL,GAAW,cAAc"}
@@ -18,18 +18,18 @@ function C({ layout: e = "inline", columns: n = 1, className: o, ...a }) {
18
18
  })
19
19
  });
20
20
  }
21
- function L({ label: e, value: n, children: o, mono: a, copy: r, optional: x, empty: h = "Not set", className: f, ...u }) {
22
- const g = v(d), i = o ?? n, l = i == null || i === "" || i === !1, c = typeof r == "string" ? r : r && typeof n == "string" ? n : null, w = typeof e == "string" ? e : "value", m = /* @__PURE__ */ t("span", {
21
+ function L({ label: e, value: n, children: o, mono: a, copy: r, optional: x, empty: h = "Not set", className: f, ...g }) {
22
+ const u = v(d), i = o ?? n, l = i == null || i === "" || i === !1, c = typeof r == "string" ? r : r && typeof n == "string" ? n : null, w = typeof e == "string" ? e : "value", m = /* @__PURE__ */ t("span", {
23
23
  className: s("min-w-0", a ? "truncate" : "font-sans text-base [overflow-wrap:anywhere] whitespace-normal"),
24
24
  children: i
25
25
  });
26
26
  return /* @__PURE__ */ p("div", {
27
27
  "data-description-item": "",
28
28
  "data-empty": l || void 0,
29
- className: s("min-w-0", g === "inline" ? "col-span-2 grid grid-cols-subgrid items-baseline py-1" : "flex flex-col gap-0.5", f),
30
- ...u,
29
+ className: s("min-w-0", u === "inline" ? "col-span-2 grid grid-cols-subgrid items-baseline py-1" : "flex flex-col gap-0.5", f),
30
+ ...g,
31
31
  children: [/* @__PURE__ */ p("dt", {
32
- className: "text-pho-description min-w-0 text-base [overflow-wrap:anywhere]",
32
+ className: "text-pho-description font-heading min-w-0 text-base [overflow-wrap:anywhere]",
33
33
  children: [e, x ? /* @__PURE__ */ t("span", {
34
34
  className: "text-pho-placeholder",
35
35
  children: " (Optional)"
@@ -57,4 +57,4 @@ export {
57
57
  D as t
58
58
  };
59
59
 
60
- //# sourceMappingURL=description-list-Duhhralt.js.map
60
+ //# sourceMappingURL=description-list-DcTvBHzI.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"description-list-Duhhralt.js","names":["cn","CopyButton","createContext","useContext","jsx","jsxs","LayoutContext","COLUMNS","Root","layout","columns","className","props","Item","label","value","children","mono","copy","optional","empty","content","absent","copyText","copyLabel","shown","DescriptionList"],"sources":["../../src/components/description-list/description-list.tsx"],"sourcesContent":["import {\n createContext,\n useContext,\n type ComponentProps,\n type ReactNode,\n type Ref,\n} from \"react\";\nimport { CopyButton } from \"../copy-button\";\nimport { cn } from \"../../utils/cn\";\n\n/**\n * Description List — the facts about one record, label beside value:\n * the status, the request id, the time, the ip, the api version, the\n * idempotency key, the api key. A `<dl>` under the hood.\n *\n * Where `BasicPage.Row` is a 68px row built for a control on its right,\n * these are dense lines of text: `inline` puts the label in a column\n * beside the value, every label the same width (a subgrid), one line per\n * fact; `stacked` puts the label above the value and flows the pairs\n * into `columns`. A `mono` value wears the mono face with a copy\n * control after it; a value that is not there says so in muted ink.\n */\n\nexport type DescriptionListLayout = \"inline\" | \"stacked\";\n\nconst LayoutContext = createContext<DescriptionListLayout>(\"inline\");\n\nexport interface DescriptionListRootProps extends ComponentProps<\"dl\"> {\n /**\n * `inline` (default): label column beside the value column, one line\n * per item. `stacked`: label above value, pairs flowing into `columns`.\n */\n layout?: DescriptionListLayout;\n /** For `stacked`: pairs per row from `sm` up. @default 1 */\n columns?: 1 | 2 | 3;\n ref?: Ref<HTMLDListElement>;\n}\n\nconst COLUMNS: Record<1 | 2 | 3, string> = {\n 1: \"\",\n 2: \"sm:grid-cols-2\",\n 3: \"sm:grid-cols-3\",\n};\n\nfunction Root({\n layout = \"inline\",\n columns = 1,\n className,\n ...props\n}: DescriptionListRootProps) {\n return (\n <LayoutContext.Provider value={layout}>\n <dl\n data-description-list={layout}\n className={cn(\n \"m-0 grid min-w-0\",\n layout === \"inline\"\n ? \"grid-cols-[minmax(0,auto)_minmax(0,1fr)] gap-x-6\"\n : cn(\"gap-x-6 gap-y-3\", COLUMNS[columns]),\n className,\n )}\n {...props}\n />\n </LayoutContext.Provider>\n );\n}\n\nexport interface DescriptionListItemProps extends Omit<\n ComponentProps<\"div\">,\n \"children\" | \"title\"\n> {\n /** The fact's name — \"Request ID\", \"Idempotency key\". */\n label: ReactNode;\n /** The fact. A string wears the item's type; a node is yours to style. */\n value?: ReactNode;\n /** Composed content instead of `value` — a `Badge`, a link. */\n children?: ReactNode;\n /** The value in the mono face — ids, keys, addresses. */\n mono?: boolean;\n /**\n * A copy control after the value, and a click on the value copies\n * too. `true` copies a string `value`; pass the text to copy when the\n * value is composed.\n */\n copy?: boolean | string;\n /** Marks the label `(Optional)` — a fact that may not be there. */\n optional?: boolean;\n /** What an absent value says. @default \"Not set\" */\n empty?: ReactNode;\n ref?: Ref<HTMLDivElement>;\n}\n\nfunction Item({\n label,\n value,\n children,\n mono,\n copy,\n optional,\n empty = \"Not set\",\n className,\n ...props\n}: DescriptionListItemProps) {\n const layout = useContext(LayoutContext);\n const content = children ?? value;\n const absent = content == null || content === \"\" || content === false;\n const copyText =\n typeof copy === \"string\"\n ? copy\n : copy && typeof value === \"string\"\n ? value\n : null;\n // Verbatim: \"Copy Trace ID\" reads the acronym, \"Copy Meta number ID\" the brand.\n const copyLabel = typeof label === \"string\" ? label : \"value\";\n // An id keeps its line and truncates; prose wraps, in its own face\n // over the copy view's mono default.\n const shown = (\n <span\n className={cn(\n \"min-w-0\",\n mono\n ? \"truncate\"\n : \"font-sans text-base [overflow-wrap:anywhere] whitespace-normal\",\n )}\n >\n {content}\n </span>\n );\n return (\n <div\n data-description-item=\"\"\n data-empty={absent || undefined}\n className={cn(\n \"min-w-0\",\n layout === \"inline\"\n ? \"col-span-2 grid grid-cols-subgrid items-baseline py-1\"\n : \"flex flex-col gap-0.5\",\n className,\n )}\n {...props}\n >\n <dt className=\"text-pho-description min-w-0 text-base [overflow-wrap:anywhere]\">\n {label}\n {optional ? (\n <span className=\"text-pho-placeholder\"> (Optional)</span>\n ) : null}\n </dt>\n <dd\n className={cn(\n \"m-0 flex min-w-0 items-center gap-1\",\n absent\n ? \"text-pho-placeholder text-base\"\n : mono\n ? \"text-pho-primary font-mono text-xs\"\n : \"text-pho-primary text-base\",\n )}\n >\n {absent ? (\n <span className=\"truncate\">{empty}</span>\n ) : copyText != null && copyText !== \"\" ? (\n // The value is the copy control's too: a click on it copies.\n <CopyButton\n value={copyText}\n label={copyLabel}\n size=\"xs\"\n className=\"-my-1\"\n >\n {shown}\n </CopyButton>\n ) : (\n shown\n )}\n </dd>\n </div>\n );\n}\n\n/**\n * ```tsx\n * <DescriptionList.Root>\n * <DescriptionList.Item label=\"Status\"><Badge …/></DescriptionList.Item>\n * <DescriptionList.Item label=\"Request ID\" value=\"pho_req_…\" mono copy />\n * <DescriptionList.Item label=\"Idempotency key\" optional mono copy />\n * </DescriptionList.Root>\n * ```\n */\nexport const DescriptionList = { Root, Item };\n"],"mappings":";;;;;AAyBA,IAAMM,IAAgBJ,EAAqC,QAAQ,GAa7DK,IAAqC;AAAA,EACzC,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAEA,SAASC,EAAK,EACZ,QAAAC,IAAS,UACT,SAAAC,IAAU,GACV,WAAAC,GACA,GAAGC,EAAA,GACwB;AAC3B,SACE,gBAAAR,EAACE,EAAc,UAAf;AAAA,IAAwB,OAAOG;AAAA,IAC7B,UAAA,gBAAAL,EAAC,MAAD;AAAA,MACE,yBAAuBK;AAAA,MACvB,WAAWT,EACT,oBACAS,MAAW,WACP,qDACAT,EAAG,mBAAmBO,EAAQG,CAAA,CAAQ,GAC1CC,CACF;AAAA,MACA,GAAIC;AAAA,IACL,CAAA;AAAA,EACqB,CAAA;AAE5B;AA2BA,SAASC,EAAK,EACZ,OAAAC,GACA,OAAAC,GACA,UAAAC,GACA,MAAAC,GACA,MAAAC,GACA,UAAAC,GACA,OAAAC,IAAQ,WACR,WAAAT,GACA,GAAGC,EAAA,GACwB;AAC3B,QAAMH,IAASN,EAAWG,CAAa,GACjCe,IAAUL,KAAYD,GACtBO,IAASD,KAAW,QAAQA,MAAY,MAAMA,MAAY,IAC1DE,IACJ,OAAOL,KAAS,WACZA,IACAA,KAAQ,OAAOH,KAAU,WACvBA,IACA,MAEFS,IAAY,OAAOV,KAAU,WAAWA,IAAQ,SAGhDW,IACJ,gBAAArB,EAAC,QAAD;AAAA,IACE,WAAWJ,EACT,WACAiB,IACI,aACA,gEACN;AAAA,IAEC,UAAAI;AAAA,EACG,CAAA;AAER,SACE,gBAAAhB,EAAC,OAAD;AAAA,IACE,yBAAsB;AAAA,IACtB,cAAYiB,KAAU;AAAA,IACtB,WAAWtB,EACT,WACAS,MAAW,WACP,0DACA,yBACJE,CACF;AAAA,IACA,GAAIC;AAAA,IAVN,UAAA,CAYE,gBAAAP,EAAC,MAAD;AAAA,MAAI,WAAU;AAAA,MAAd,UAAA,CACGS,GACAK,IACC,gBAAAf,EAAC,QAAD;AAAA,QAAM,WAAU;AAAA,QAAuB,UAAA;AAAA,MAAiB,CAAA,IACtD,IACF;AAAA,IACJ,CAAA,GAAA,gBAAAA,EAAC,MAAD;AAAA,MACE,WAAWJ,EACT,uCACAsB,IACI,mCACAL,IACE,uCACA,4BACR;AAAA,MAEC,UAAAK,IACC,gBAAAlB,EAAC,QAAD;AAAA,QAAM,WAAU;AAAA,QAAY,UAAAgB;AAAA,MAAY,CAAA,IACtCG,KAAY,QAAQA,MAAa,KAEnC,gBAAAnB,EAACH,GAAD;AAAA,QACE,OAAOsB;AAAA,QACP,OAAOC;AAAA,QACP,MAAK;AAAA,QACL,WAAU;AAAA,QAET,UAAAC;AAAA,MACS,CAAA,IAEZA;AAAA,IAEA,CAAA,CACD;AAAA,E;AAET;AAWA,IAAaC,IAAkB;AAAA,EAAE,MAAAlB;AAAA,EAAM,MAAAK;AAAK"}
1
+ {"version":3,"file":"description-list-DcTvBHzI.js","names":["cn","CopyButton","createContext","useContext","jsx","jsxs","LayoutContext","COLUMNS","Root","layout","columns","className","props","Item","label","value","children","mono","copy","optional","empty","content","absent","copyText","copyLabel","shown","DescriptionList"],"sources":["../../src/components/description-list/description-list.tsx"],"sourcesContent":["import {\n createContext,\n useContext,\n type ComponentProps,\n type ReactNode,\n type Ref,\n} from \"react\";\nimport { CopyButton } from \"../copy-button\";\nimport { cn } from \"../../utils/cn\";\n\n/**\n * Description List — the facts about one record, label beside value:\n * the status, the request id, the time, the ip, the api version, the\n * idempotency key, the api key. A `<dl>` under the hood.\n *\n * Where `BasicPage.Row` is a 68px row built for a control on its right,\n * these are dense lines of text: `inline` puts the label in a column\n * beside the value, every label the same width (a subgrid), one line per\n * fact; `stacked` puts the label above the value and flows the pairs\n * into `columns`. A `mono` value wears the mono face with a copy\n * control after it; a value that is not there says so in muted ink.\n */\n\nexport type DescriptionListLayout = \"inline\" | \"stacked\";\n\nconst LayoutContext = createContext<DescriptionListLayout>(\"inline\");\n\nexport interface DescriptionListRootProps extends ComponentProps<\"dl\"> {\n /**\n * `inline` (default): label column beside the value column, one line\n * per item. `stacked`: label above value, pairs flowing into `columns`.\n */\n layout?: DescriptionListLayout;\n /** For `stacked`: pairs per row from `sm` up. @default 1 */\n columns?: 1 | 2 | 3;\n ref?: Ref<HTMLDListElement>;\n}\n\nconst COLUMNS: Record<1 | 2 | 3, string> = {\n 1: \"\",\n 2: \"sm:grid-cols-2\",\n 3: \"sm:grid-cols-3\",\n};\n\nfunction Root({\n layout = \"inline\",\n columns = 1,\n className,\n ...props\n}: DescriptionListRootProps) {\n return (\n <LayoutContext.Provider value={layout}>\n <dl\n data-description-list={layout}\n className={cn(\n \"m-0 grid min-w-0\",\n layout === \"inline\"\n ? \"grid-cols-[minmax(0,auto)_minmax(0,1fr)] gap-x-6\"\n : cn(\"gap-x-6 gap-y-3\", COLUMNS[columns]),\n className,\n )}\n {...props}\n />\n </LayoutContext.Provider>\n );\n}\n\nexport interface DescriptionListItemProps extends Omit<\n ComponentProps<\"div\">,\n \"children\" | \"title\"\n> {\n /** The fact's name — \"Request ID\", \"Idempotency key\". */\n label: ReactNode;\n /** The fact. A string wears the item's type; a node is yours to style. */\n value?: ReactNode;\n /** Composed content instead of `value` — a `Badge`, a link. */\n children?: ReactNode;\n /** The value in the mono face — ids, keys, addresses. */\n mono?: boolean;\n /**\n * A copy control after the value, and a click on the value copies\n * too. `true` copies a string `value`; pass the text to copy when the\n * value is composed.\n */\n copy?: boolean | string;\n /** Marks the label `(Optional)` — a fact that may not be there. */\n optional?: boolean;\n /** What an absent value says. @default \"Not set\" */\n empty?: ReactNode;\n ref?: Ref<HTMLDivElement>;\n}\n\nfunction Item({\n label,\n value,\n children,\n mono,\n copy,\n optional,\n empty = \"Not set\",\n className,\n ...props\n}: DescriptionListItemProps) {\n const layout = useContext(LayoutContext);\n const content = children ?? value;\n const absent = content == null || content === \"\" || content === false;\n const copyText =\n typeof copy === \"string\"\n ? copy\n : copy && typeof value === \"string\"\n ? value\n : null;\n // Verbatim: \"Copy Trace ID\" reads the acronym, \"Copy Meta number ID\" the brand.\n const copyLabel = typeof label === \"string\" ? label : \"value\";\n // An id keeps its line and truncates; prose wraps, in its own face\n // over the copy view's mono default.\n const shown = (\n <span\n className={cn(\n \"min-w-0\",\n mono\n ? \"truncate\"\n : \"font-sans text-base [overflow-wrap:anywhere] whitespace-normal\",\n )}\n >\n {content}\n </span>\n );\n return (\n <div\n data-description-item=\"\"\n data-empty={absent || undefined}\n className={cn(\n \"min-w-0\",\n layout === \"inline\"\n ? \"col-span-2 grid grid-cols-subgrid items-baseline py-1\"\n : \"flex flex-col gap-0.5\",\n className,\n )}\n {...props}\n >\n <dt className=\"text-pho-description font-heading min-w-0 text-base [overflow-wrap:anywhere]\">\n {label}\n {optional ? (\n <span className=\"text-pho-placeholder\"> (Optional)</span>\n ) : null}\n </dt>\n <dd\n className={cn(\n \"m-0 flex min-w-0 items-center gap-1\",\n absent\n ? \"text-pho-placeholder text-base\"\n : mono\n ? \"text-pho-primary font-mono text-xs\"\n : \"text-pho-primary text-base\",\n )}\n >\n {absent ? (\n <span className=\"truncate\">{empty}</span>\n ) : copyText != null && copyText !== \"\" ? (\n // The value is the copy control's too: a click on it copies.\n <CopyButton\n value={copyText}\n label={copyLabel}\n size=\"xs\"\n className=\"-my-1\"\n >\n {shown}\n </CopyButton>\n ) : (\n shown\n )}\n </dd>\n </div>\n );\n}\n\n/**\n * ```tsx\n * <DescriptionList.Root>\n * <DescriptionList.Item label=\"Status\"><Badge …/></DescriptionList.Item>\n * <DescriptionList.Item label=\"Request ID\" value=\"pho_req_…\" mono copy />\n * <DescriptionList.Item label=\"Idempotency key\" optional mono copy />\n * </DescriptionList.Root>\n * ```\n */\nexport const DescriptionList = { Root, Item };\n"],"mappings":";;;;;AAyBA,IAAMM,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AAU;AAAA,QAAuB,UAAA;AAAA,MAAiB,CAAA,IACtD,IACF;AAAA,IACJ,CAAA,GAAA,gBAAAA,EAAC,MAAD;AAAA,MACE,WAAWJ,EACT,uCACAsB,IACI,mCACAL,IACE,uCACA,4BACR;AAAA,MAEC,UAAAK,IACC,gBAAAlB,EAAC,QAAD;AAAA,QAAM,WAAU;AAAA,QAAY,UAAAgB;AAAA,MAAY,CAAA,IACtCG,KAAY,QAAQA,MAAa,KAEnC,gBAAAnB,EAACH,GAAD;AAAA,QACE,OAAOsB;AAAA,QACP,OAAOC;AAAA,QACP,MAAK;AAAA,QACL,WAAU;AAAA,QAET,UAAAC;AAAA,MACS,CAAA,IAEZA;AAAA,IAEA,CAAA,CACD;AAAA,E;AAET;AAWA,IAAaC,IAAkB;AAAA,EAAE,MAAAlB;AAAA,EAAM,MAAAK;AAAK"}
@@ -5,7 +5,7 @@ import { t as C } from "./createReactComponent-yKZn9MIX.js";
5
5
  import { t as S } from "./IconInfoCircle-CTAynhe8.js";
6
6
  import { t as g } from "./IconAlertCircleFilled-D6mUlVaE.js";
7
7
  import { t as A } from "./IconAlertTriangleFilled-QV-gsVQW.js";
8
- import { t as l } from "./popover-B0NBrYV5.js";
8
+ import { t as l } from "./popover-Dtp9C6Qg.js";
9
9
  import { i as _ } from "./status-view-I_Y6eEyX.js";
10
10
  import { useEffect as P, useRef as L, useState as k } from "react";
11
11
  import { Fragment as c, jsx as r, jsxs as s } from "react/jsx-runtime";
@@ -267,4 +267,4 @@ export {
267
267
  F as u
268
268
  };
269
269
 
270
- //# sourceMappingURL=error-BObcQClz.js.map
270
+ //# sourceMappingURL=error-BZU9vgnj.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"error-BObcQClz.js","names":["_Fragment","cn","Button","ButtonLink","createReactComponent","IconInfoCircle","IconAlertCircleFilled","IconAlertTriangleFilled","Popover","StatusView","useEffect","useRef","useState","Fragment$1","jsx","jsxs","__iconNode","IconAlertTriangle","isProblem","value","v","parseProblem","error","current","depth","carried","GENERIC_ERROR_TITLE","HTTP_REASON_PHRASE","HTTP_STATUS_EXPLANATION","hasContractCode","problem","httpReasonPhrase","status","fallbackTitle","httpStatusExplanation","capitalizeFirst","text","first","upper","describeError","description","part","displayCopy","DOC_LINK_LABEL","RETRY_LABEL","Error","children","className","props","copy","ErrorDetails","Warning","shown","requestId","statusLine","reason","RequestId","copied","setCopied","copiedTimer","ErrorView","title","icon","onRetry","actions","size","resolvedDescription","body","resolvedActions"],"sources":["../../../../node_modules/.pnpm/@tabler+icons-react@3.49.0_react@19.3.1/node_modules/@tabler/icons-react/dist/esm/icons/IconAlertTriangle.mjs","../../src/components/error/problem.ts","../../src/components/error/error.tsx"],"sourcesContent":["/**\n * @license @tabler/icons-react v3.49.0 - MIT\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createReactComponent from '../createReactComponent.mjs';\n\nconst __iconNode = [[\"path\", { \"d\": \"M12 9v4\", \"key\": \"svg-0\" }], [\"path\", { \"d\": \"M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0\", \"key\": \"svg-1\" }], [\"path\", { \"d\": \"M12 16h.01\", \"key\": \"svg-2\" }]];\nconst IconAlertTriangle = createReactComponent(\"outline\", \"alert-triangle\", \"AlertTriangle\", __iconNode);\n\nexport { __iconNode, IconAlertTriangle as default };\n","/**\n * Client-side mirror of the `@photon-hq/error` response contract — the\n * RFC 9457 Problem Details body every Photon service returns for 4xx / 5xx.\n * Machine logic branches on `code`; `title` / `detail` / `remediation` are\n * the human-readable copy, already reviewed server-side and safe to render.\n *\n * Fetch layers may also hand us a thin status-only shape when the response\n * was not ok but the body was not a contract problem — `title` + `status`\n * still count so the UI can disclose the HTTP code we already know.\n */\n\nexport interface ProblemRemediation {\n /** What the user can do about it — a full sentence. */\n action?: string;\n /** Docs URL explaining the problem. */\n documentation?: string;\n}\n\nexport interface Problem {\n /** Stable machine-readable key (`RATE_LIMITED`) — the field to branch on. */\n code?: string;\n /** Human summary of the problem type (\"Too Many Requests\"). */\n title: string;\n /** HTTP status (4xx / 5xx). */\n status: number;\n /** Problem type URI (`urn:photon:problem:*` or an https URL). */\n type?: string;\n /** Occurrence-specific human sentence. */\n detail?: string;\n /** Correlation id for support (`X-Request-ID`). */\n requestId?: string;\n remediation?: ProblemRemediation;\n /** RFC 9457 extensions (`issues`, `actualVersion`, …). */\n [extension: string]: unknown;\n}\n\n/** Structural check: `title` + a 4xx/5xx status. `code` is optional. */\nexport function isProblem(value: unknown): value is Problem {\n if (typeof value !== \"object\" || value === null) return false;\n const v = value as Record<string, unknown>;\n return (\n typeof v.title === \"string\" &&\n typeof v.status === \"number\" &&\n Number.isInteger(v.status) &&\n v.status >= 400 &&\n v.status <= 599 &&\n (v.code === undefined || typeof v.code === \"string\")\n );\n}\n\n/**\n * Find the problem a caught value carries — the value itself, one typed onto\n * an error as a `problem` field (dashboard's `ApiError` shape), or one\n * wrapped in an `Error` `cause` chain (how fetch layers usually rethrow a\n * parsed body). Returns `null` when there is none.\n */\nexport function parseProblem(error: unknown): Problem | null {\n let current: unknown = error;\n for (\n let depth = 0;\n depth < 8 && typeof current === \"object\" && current !== null;\n depth++\n ) {\n if (isProblem(current)) return current;\n const carried = (current as { problem?: unknown }).problem;\n if (isProblem(carried)) return carried;\n current = (current as { cause?: unknown }).cause;\n }\n return null;\n}\n\nexport interface ErrorDescription {\n /** Short name of the failure — the problem `title`, or a generic fallback. */\n title: string;\n /** Sentence(s) to show — `detail` and `remediation.action` joined. */\n description?: string;\n /** Docs URL from `remediation.documentation`. */\n documentation?: string;\n /** Correlation id for support. */\n requestId?: string;\n /** The matched problem, when the input carried one. */\n problem?: Problem;\n}\n\n/**\n * Anything that isn't a problem renders as this — raw `Error` messages are\n * not contract copy and never shown (the same fail-closed stance as the\n * server side of `@photon-hq/error`). Always a full sentence (trailing\n * period).\n */\nexport const GENERIC_ERROR_TITLE = \"Something went wrong.\";\n\n/** Standard reason phrases for statuses we commonly surface without a body. */\nconst HTTP_REASON_PHRASE: Record<number, string> = {\n 400: \"Bad Request\",\n 401: \"Unauthorized\",\n 403: \"Forbidden\",\n 404: \"Not Found\",\n 408: \"Request Timeout\",\n 409: \"Conflict\",\n 410: \"Gone\",\n 413: \"Payload Too Large\",\n 415: \"Unsupported Media Type\",\n 422: \"Unprocessable Entity\",\n 429: \"Too Many Requests\",\n 500: \"Internal Server Error\",\n 501: \"Not Implemented\",\n 502: \"Bad Gateway\",\n 503: \"Service Unavailable\",\n 504: \"Gateway Timeout\",\n};\n\n/** One-sentence explanations when the server gave a status but no problem copy. */\nconst HTTP_STATUS_EXPLANATION: Record<number, string> = {\n 400: \"The request was malformed or incomplete.\",\n 401: \"You need to sign in again.\",\n 403: \"You don't have permission to do that.\",\n 404: \"The requested resource was not found.\",\n 408: \"The request timed out before the server responded.\",\n 409: \"The request conflicts with the current state.\",\n 410: \"That resource is no longer available.\",\n 413: \"The request was too large for the server to accept.\",\n 415: \"That media type isn't supported.\",\n 422: \"The request was understood but couldn't be processed.\",\n 429: \"Request rate limit exceeded. Wait a moment before trying again.\",\n 500: \"The server hit an unexpected error.\",\n 501: \"The server doesn't support that operation.\",\n 502: \"The gateway got an invalid response from an upstream server.\",\n 503: \"The service is temporarily unavailable.\",\n 504: \"The gateway timed out waiting for an upstream server.\",\n};\n\nfunction hasContractCode(problem: Problem): boolean {\n return typeof problem.code === \"string\" && problem.code !== \"\";\n}\n\n/** Reason phrase for a status — map first, then a non-generic `problem.title`. */\nexport function httpReasonPhrase(\n status: number,\n fallbackTitle?: string,\n): string | undefined {\n if (HTTP_REASON_PHRASE[status]) return HTTP_REASON_PHRASE[status];\n if (\n fallbackTitle &&\n fallbackTitle !== GENERIC_ERROR_TITLE &&\n fallbackTitle !== \"Request failed\"\n ) {\n return fallbackTitle.replace(/\\.$/, \"\");\n }\n return undefined;\n}\n\n/** Human sentence for a bare HTTP status, when the body carried no copy. */\nexport function httpStatusExplanation(status: number): string {\n return (\n HTTP_STATUS_EXPLANATION[status] ??\n \"The request failed with an unexpected status.\"\n );\n}\n\n/**\n * Sentence-case the first character. Server `detail` / `title` sometimes\n * arrive fully lowercase; UI copy always leads with a capital.\n */\nexport function capitalizeFirst(text: string): string {\n if (!text) return text;\n const first = text.charAt(0);\n const upper = first.toUpperCase();\n if (first === upper) return text;\n return upper + text.slice(1);\n}\n\n/**\n * Turn a caught value into displayable copy. `Error` and `ErrorView` call\n * this internally; use it directly for other surfaces (a toast, a banner).\n *\n * Status-only failures (HTTP not ok, but no contract `code` / copy) still\n * keep `problem` so the details panel can show the status. Title becomes the\n * reason phrase (e.g. \"Bad Gateway\"); description is a short explanation —\n * not just the numeric code.\n */\nexport function describeError(error: unknown): ErrorDescription {\n const problem = parseProblem(error);\n if (problem == null) return { title: GENERIC_ERROR_TITLE };\n\n const description =\n [problem.detail, problem.remediation?.action]\n .filter((part): part is string => typeof part === \"string\" && part !== \"\")\n .join(\" \") || undefined;\n\n if (!hasContractCode(problem) && description == null) {\n const reason = httpReasonPhrase(problem.status, problem.title);\n return {\n title: capitalizeFirst(reason ?? GENERIC_ERROR_TITLE),\n description: httpStatusExplanation(problem.status),\n requestId: problem.requestId,\n problem,\n };\n }\n\n return {\n title: capitalizeFirst(problem.title || GENERIC_ERROR_TITLE),\n description: description ? capitalizeFirst(description) : undefined,\n documentation: problem.remediation?.documentation,\n requestId: problem.requestId,\n problem,\n };\n}\n","import {\n useEffect,\n useRef,\n useState,\n type ComponentProps,\n type ReactNode,\n} from \"react\";\nimport {\n IconAlertCircleFilled,\n IconAlertTriangle,\n IconAlertTriangleFilled,\n IconInfoCircle,\n} from \"@tabler/icons-react\";\nimport { cn } from \"../../utils/cn\";\nimport { Button, ButtonLink } from \"../button/button\";\nimport { Popover } from \"../popover/popover\";\nimport { StatusView, type StatusViewSize } from \"../status-view/status-view\";\nimport {\n capitalizeFirst,\n describeError,\n httpReasonPhrase,\n type ErrorDescription,\n} from \"./problem\";\n\n/** Capitalize string copy; leave custom ReactNode overrides alone. */\nfunction displayCopy(value: ReactNode): ReactNode {\n return typeof value === \"string\" ? capitalizeFirst(value) : value;\n}\n\n/**\n * Design notes:\n * - ONE input: `error` is the caught value, whatever it is — a Problem\n * Details body from `@photon-hq/error`, an `Error` carrying one as\n * `cause`, or something unknown. The component derives its copy via\n * `describeError`; unknowns fall back to a generic line rather than\n * leaking raw messages.\n * - TWO presentations, one per altitude: `Error` is the inline line for\n * forms, cards, and action rows; `ErrorView` is the region / page state\n * built on StatusView (same `sm` / `base` size axis).\n * - Both render `null` when there is nothing to show, so they can sit\n * unconditionally in JSX (`<Error error={mutation.error} />`).\n * - `Warning` is the inline line's second state: the same row in warning\n * ink, for something the user may go ahead with but should look at\n * twice. It never blocks, so it takes its copy and nothing else.\n * - Client-side *validation* is not this component's job — that belongs to\n * `Field.Error`, wired to control validity.\n */\n\nconst DOC_LINK_LABEL = \"Learn more\";\nconst RETRY_LABEL = \"Try again\";\n\ninterface ErrorBaseProps {\n /** The caught value — a problem body, an `Error` wrapping one, or unknown. */\n error?: unknown;\n /** Override the derived message. */\n children?: ReactNode;\n}\n\nexport interface ErrorProps\n extends ErrorBaseProps, Omit<ComponentProps<\"div\">, keyof ErrorBaseProps> {}\n\n/**\n * Error — one line of red ink naming a server failure (4xx / 5xx), placed\n * inline: under a form, in a card, beside the action that failed. Give it the\n * caught value and it renders the problem's `detail` (falling back to `title`,\n * then to a generic line), plus a docs link when the problem carries one.\n * Renders nothing while `error` is nullish, so it can stay mounted.\n *\n * For a region or page that failed to load, use {@link ErrorView}.\n */\nexport function Error({ error, children, className, ...props }: ErrorProps) {\n if (error == null && children == null) return null;\n const copy = describeError(error);\n return (\n <div\n role=\"alert\"\n className={cn(\n \"text-pho-error flex min-w-0 items-start gap-1.5 text-base\",\n className,\n )}\n {...props}\n >\n <span aria-hidden className=\"flex h-[1lh] shrink-0 items-center\">\n <IconAlertCircleFilled className=\"size-4\" />\n </span>\n <span className=\"min-w-0\">\n {displayCopy(children ?? copy.description ?? copy.title)}\n {copy.documentation != null && (\n <>\n {\" \"}\n <a\n href={copy.documentation}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"font-medium underline underline-offset-2\"\n >\n {DOC_LINK_LABEL}\n </a>\n </>\n )}\n {/* Trailing whitespace collapses when the details render null. */}{\" \"}\n <ErrorDetails copy={copy} />\n </span>\n </div>\n );\n}\n\nError.displayName = \"Error\";\n\nexport interface WarningProps extends Omit<\n ComponentProps<\"output\">,\n \"children\"\n> {\n /** What to look at twice. Shows nothing while nullish. */\n children?: ReactNode;\n}\n\n/**\n * Warning — the inline `Error` line in warning ink, a triangle in place of\n * the circle: something the user can go ahead with but may not mean (an\n * address outside the team, a value that differs from the usual one). Same\n * row, glyph seat and type as `Error`, so the two can take turns in one\n * place. It doesn't stop anything, so it announces politely (an `output`,\n * role `status`) and carries no details disclosure.\n *\n * A polite region is announced when its content changes, not when it is\n * inserted, so the `output` stays mounted while the copy is nullish:\n * empty and `sr-only`, the way pho-ui's other live regions sit, it keeps\n * its role and, out of flow, adds no gap to a stack.\n */\nexport function Warning({ children, className, ...props }: WarningProps) {\n // `{cond && copy}` leaves false behind: no copy either.\n const shown = children != null && children !== false && children !== \"\";\n return (\n <output\n className={\n shown\n ? cn(\n \"text-pho-warning flex min-w-0 items-start gap-1.5 text-base\",\n className,\n )\n : \"sr-only\"\n }\n {...props}\n >\n {shown && (\n <>\n <span aria-hidden className=\"flex h-[1lh] shrink-0 items-center\">\n <IconAlertTriangleFilled className=\"size-4\" />\n </span>\n <span className=\"min-w-0\">{displayCopy(children)}</span>\n </>\n )}\n </output>\n );\n}\n\nWarning.displayName = \"Warning\";\n\n/**\n * Hover / focus disclosure on the inline line — the request's fuller story:\n * problem `title` (with the same alert icon + `text-pho-error` ink as the\n * inline line), the untruncated description, then `status` + `code` and the\n * copyable request id grouped below for a support handoff. Renders only when\n * the caught value actually carried a problem (or at least a request id); a\n * generic unknown has nothing more to disclose. Built on `Popover` rather\n * than `Tooltip` because the panel holds an interactive control (the copy\n * button) — `openOnHover` keeps the tooltip-like gesture.\n */\nfunction ErrorDetails({ copy }: { copy: ErrorDescription }) {\n const { problem, requestId } = copy;\n if (problem == null && requestId == null) return null;\n\n // Contract problems show `status CODE`; status-only shows `status Reason`.\n let statusLine: string | null = null;\n if (problem != null) {\n if (problem.code) {\n statusLine = `${problem.status} ${problem.code}`;\n } else {\n const reason = httpReasonPhrase(problem.status, problem.title);\n statusLine = reason\n ? `${problem.status} ${reason}`\n : String(problem.status);\n }\n }\n\n return (\n <Popover.Root>\n <Popover.Trigger\n openOnHover\n delay={150}\n aria-label=\"Error details\"\n className=\"outline-pho-brand inline-flex size-4 shrink-0 translate-y-[3px] cursor-help items-center justify-center rounded-full opacity-70 transition-opacity hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-2\"\n >\n <IconInfoCircle className=\"size-3.5\" />\n </Popover.Trigger>\n <Popover.Portal>\n <Popover.Positioner align=\"start\">\n <Popover.Popup className=\"text-pho-error\">\n <Popover.Title className=\"text-pho-error flex items-start gap-1.5\">\n <span aria-hidden className=\"flex h-[1lh] shrink-0 items-center\">\n <IconAlertCircleFilled className=\"size-4\" />\n </span>\n {copy.title}\n </Popover.Title>\n {copy.description != null && (\n <Popover.Description className=\"text-pho-error\">\n {copy.description}\n </Popover.Description>\n )}\n {(statusLine != null || requestId != null) && (\n <div className=\"text-pho-error mt-1 font-mono text-[10px] leading-snug\">\n {statusLine != null && <p>{statusLine}</p>}\n {requestId != null && (\n <RequestId requestId={requestId} className=\"mt-0\" />\n )}\n </div>\n )}\n </Popover.Popup>\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n );\n}\n\n/** Request-id footnote — click copies the id for support handoff. */\nfunction RequestId({\n requestId,\n className,\n}: {\n requestId: string;\n className?: string;\n}) {\n const [copied, setCopied] = useState(false);\n const copiedTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(\n () => () => {\n if (copiedTimer.current) clearTimeout(copiedTimer.current);\n },\n [],\n );\n\n return (\n <span\n className={cn(\"mt-1 block font-mono text-[10px] leading-snug\", className)}\n >\n Request ID:{\" \"}\n <button\n type=\"button\"\n className=\"outline-pho-brand inline cursor-pointer underline-offset-2 select-all hover:underline focus-visible:underline focus-visible:outline-2 focus-visible:-outline-offset-1\"\n aria-label={\n copied ? \"Request ID copied\" : `Copy request ID ${requestId}`\n }\n onClick={async () => {\n try {\n await navigator.clipboard.writeText(requestId);\n } catch {\n return;\n }\n setCopied(true);\n if (copiedTimer.current) clearTimeout(copiedTimer.current);\n copiedTimer.current = setTimeout(() => setCopied(false), 1500);\n }}\n >\n {requestId}\n </button>\n <output className=\"sr-only\" aria-live=\"polite\">\n {copied ? \"Copied\" : \"\"}\n </output>\n </span>\n );\n}\n\ninterface ErrorViewBaseProps {\n /** The caught value — a problem body, an `Error` wrapping one, or unknown. */\n error?: unknown;\n /** Override the derived title. */\n title?: ReactNode;\n /** Override the derived description. */\n description?: ReactNode;\n /** Override the warning glyph. */\n icon?: ReactNode;\n /** Offer a retry — renders a \"Try again\" button. */\n onRetry?: () => void;\n /** Replace the built-in action row entirely. */\n actions?: ReactNode;\n /** Size variant — StatusView's axis. @default \"base\" */\n size?: StatusViewSize;\n}\n\nexport interface ErrorViewProps\n extends\n ErrorViewBaseProps,\n Omit<ComponentProps<\"div\">, keyof ErrorViewBaseProps | \"children\"> {}\n\n/**\n * ErrorView — the failed state of a region or page, built on StatusView:\n * warning icon over the problem's `title`, its `detail` and remediation\n * below, an action row (`onRetry` and the problem's docs link), and the\n * request id as a footnote for support. Announces via `role=\"alert\"`.\n *\n * Use `size=\"sm\"` inside cards and panels, the default `base` for whole\n * pages. Renders nothing while `error` is nullish (unless given a static\n * `title`), so it can sit unconditionally next to a query.\n */\nexport function ErrorView({\n error,\n title,\n description,\n icon,\n onRetry,\n actions,\n size = \"base\",\n ...props\n}: ErrorViewProps) {\n if (error == null && title == null) return null;\n const copy = describeError(error);\n\n const resolvedDescription = displayCopy(description ?? copy.description);\n const body =\n resolvedDescription != null || copy.requestId != null ? (\n <>\n {resolvedDescription}\n {copy.requestId != null && <RequestId requestId={copy.requestId} />}\n </>\n ) : undefined;\n\n const resolvedActions =\n actions ??\n (onRetry != null || copy.documentation != null ? (\n <>\n {onRetry != null && (\n <Button size=\"sm\" onClick={onRetry}>\n {RETRY_LABEL}\n </Button>\n )}\n {copy.documentation != null && (\n <ButtonLink\n size=\"sm\"\n variant=\"outlined\"\n href={copy.documentation}\n target=\"_blank\"\n rel=\"noreferrer\"\n >\n {DOC_LINK_LABEL}\n </ButtonLink>\n )}\n </>\n ) : undefined);\n\n return (\n <StatusView\n role=\"alert\"\n size={size}\n icon={icon ?? <IconAlertTriangle />}\n title={displayCopy(title ?? copy.title)}\n description={body}\n actions={resolvedActions}\n {...props}\n />\n );\n}\n\nErrorView.displayName = \"ErrorView\";\n"],"ignoreList":[0],"mappings":";;;;;;;;;;;AASA,IAAMgB,IAAa;AAAA,EAAC,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAW,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAA4I,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAc,KAAO;AAAA,EAAQ,CAAC;AAAC,GAC1RC,IAAoBb,EAAqB,WAAW,kBAAkB,iBAAiBY,CAAU;AC2BvG,SAAgBE,EAAUC,GAAkC;AAC1D,MAAI,OAAOA,KAAU,YAAYA,MAAU,KAAM,QAAO;AACxD,QAAMC,IAAID;AACV,SACE,OAAOC,EAAE,SAAU,YACnB,OAAOA,EAAE,UAAW,YACpB,OAAO,UAAUA,EAAE,MAAM,KACzBA,EAAE,UAAU,OACZA,EAAE,UAAU,QACXA,EAAE,SAAS,UAAa,OAAOA,EAAE,QAAS;AAE/C;AA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9vgnj.js","names":["_Fragment","cn","Button","ButtonLink","createReactComponent","IconInfoCircle","IconAlertCircleFilled","IconAlertTriangleFilled","Popover","StatusView","useEffect","useRef","useState","Fragment$1","jsx","jsxs","__iconNode","IconAlertTriangle","isProblem","value","v","parseProblem","error","current","depth","carried","GENERIC_ERROR_TITLE","HTTP_REASON_PHRASE","HTTP_STATUS_EXPLANATION","hasContractCode","problem","httpReasonPhrase","status","fallbackTitle","httpStatusExplanation","capitalizeFirst","text","first","upper","describeError","description","part","displayCopy","DOC_LINK_LABEL","RETRY_LABEL","Error","children","className","props","copy","ErrorDetails","Warning","shown","requestId","statusLine","reason","RequestId","copied","setCopied","copiedTimer","ErrorView","title","icon","onRetry","actions","size","resolvedDescription","body","resolvedActions"],"sources":["../../../../node_modules/.pnpm/@tabler+icons-react@3.49.0_react@19.3.1/node_modules/@tabler/icons-react/dist/esm/icons/IconAlertTriangle.mjs","../../src/components/error/problem.ts","../../src/components/error/error.tsx"],"sourcesContent":["/**\n * @license @tabler/icons-react v3.49.0 - MIT\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createReactComponent from '../createReactComponent.mjs';\n\nconst __iconNode = [[\"path\", { \"d\": \"M12 9v4\", \"key\": \"svg-0\" }], [\"path\", { \"d\": \"M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0\", \"key\": \"svg-1\" }], [\"path\", { \"d\": \"M12 16h.01\", \"key\": \"svg-2\" }]];\nconst IconAlertTriangle = createReactComponent(\"outline\", \"alert-triangle\", \"AlertTriangle\", __iconNode);\n\nexport { __iconNode, IconAlertTriangle as default };\n","/**\n * Client-side mirror of the `@photon-hq/error` response contract — the\n * RFC 9457 Problem Details body every Photon service returns for 4xx / 5xx.\n * Machine logic branches on `code`; `title` / `detail` / `remediation` are\n * the human-readable copy, already reviewed server-side and safe to render.\n *\n * Fetch layers may also hand us a thin status-only shape when the response\n * was not ok but the body was not a contract problem — `title` + `status`\n * still count so the UI can disclose the HTTP code we already know.\n */\n\nexport interface ProblemRemediation {\n /** What the user can do about it — a full sentence. */\n action?: string;\n /** Docs URL explaining the problem. */\n documentation?: string;\n}\n\nexport interface Problem {\n /** Stable machine-readable key (`RATE_LIMITED`) — the field to branch on. */\n code?: string;\n /** Human summary of the problem type (\"Too Many Requests\"). */\n title: string;\n /** HTTP status (4xx / 5xx). */\n status: number;\n /** Problem type URI (`urn:photon:problem:*` or an https URL). */\n type?: string;\n /** Occurrence-specific human sentence. */\n detail?: string;\n /** Correlation id for support (`X-Request-ID`). */\n requestId?: string;\n remediation?: ProblemRemediation;\n /** RFC 9457 extensions (`issues`, `actualVersion`, …). */\n [extension: string]: unknown;\n}\n\n/** Structural check: `title` + a 4xx/5xx status. `code` is optional. */\nexport function isProblem(value: unknown): value is Problem {\n if (typeof value !== \"object\" || value === null) return false;\n const v = value as Record<string, unknown>;\n return (\n typeof v.title === \"string\" &&\n typeof v.status === \"number\" &&\n Number.isInteger(v.status) &&\n v.status >= 400 &&\n v.status <= 599 &&\n (v.code === undefined || typeof v.code === \"string\")\n );\n}\n\n/**\n * Find the problem a caught value carries — the value itself, one typed onto\n * an error as a `problem` field (dashboard's `ApiError` shape), or one\n * wrapped in an `Error` `cause` chain (how fetch layers usually rethrow a\n * parsed body). Returns `null` when there is none.\n */\nexport function parseProblem(error: unknown): Problem | null {\n let current: unknown = error;\n for (\n let depth = 0;\n depth < 8 && typeof current === \"object\" && current !== null;\n depth++\n ) {\n if (isProblem(current)) return current;\n const carried = (current as { problem?: unknown }).problem;\n if (isProblem(carried)) return carried;\n current = (current as { cause?: unknown }).cause;\n }\n return null;\n}\n\nexport interface ErrorDescription {\n /** Short name of the failure — the problem `title`, or a generic fallback. */\n title: string;\n /** Sentence(s) to show — `detail` and `remediation.action` joined. */\n description?: string;\n /** Docs URL from `remediation.documentation`. */\n documentation?: string;\n /** Correlation id for support. */\n requestId?: string;\n /** The matched problem, when the input carried one. */\n problem?: Problem;\n}\n\n/**\n * Anything that isn't a problem renders as this — raw `Error` messages are\n * not contract copy and never shown (the same fail-closed stance as the\n * server side of `@photon-hq/error`). Always a full sentence (trailing\n * period).\n */\nexport const GENERIC_ERROR_TITLE = \"Something went wrong.\";\n\n/** Standard reason phrases for statuses we commonly surface without a body. */\nconst HTTP_REASON_PHRASE: Record<number, string> = {\n 400: \"Bad Request\",\n 401: \"Unauthorized\",\n 403: \"Forbidden\",\n 404: \"Not Found\",\n 408: \"Request Timeout\",\n 409: \"Conflict\",\n 410: \"Gone\",\n 413: \"Payload Too Large\",\n 415: \"Unsupported Media Type\",\n 422: \"Unprocessable Entity\",\n 429: \"Too Many Requests\",\n 500: \"Internal Server Error\",\n 501: \"Not Implemented\",\n 502: \"Bad Gateway\",\n 503: \"Service Unavailable\",\n 504: \"Gateway Timeout\",\n};\n\n/** One-sentence explanations when the server gave a status but no problem copy. */\nconst HTTP_STATUS_EXPLANATION: Record<number, string> = {\n 400: \"The request was malformed or incomplete.\",\n 401: \"You need to sign in again.\",\n 403: \"You don't have permission to do that.\",\n 404: \"The requested resource was not found.\",\n 408: \"The request timed out before the server responded.\",\n 409: \"The request conflicts with the current state.\",\n 410: \"That resource is no longer available.\",\n 413: \"The request was too large for the server to accept.\",\n 415: \"That media type isn't supported.\",\n 422: \"The request was understood but couldn't be processed.\",\n 429: \"Request rate limit exceeded. Wait a moment before trying again.\",\n 500: \"The server hit an unexpected error.\",\n 501: \"The server doesn't support that operation.\",\n 502: \"The gateway got an invalid response from an upstream server.\",\n 503: \"The service is temporarily unavailable.\",\n 504: \"The gateway timed out waiting for an upstream server.\",\n};\n\nfunction hasContractCode(problem: Problem): boolean {\n return typeof problem.code === \"string\" && problem.code !== \"\";\n}\n\n/** Reason phrase for a status — map first, then a non-generic `problem.title`. */\nexport function httpReasonPhrase(\n status: number,\n fallbackTitle?: string,\n): string | undefined {\n if (HTTP_REASON_PHRASE[status]) return HTTP_REASON_PHRASE[status];\n if (\n fallbackTitle &&\n fallbackTitle !== GENERIC_ERROR_TITLE &&\n fallbackTitle !== \"Request failed\"\n ) {\n return fallbackTitle.replace(/\\.$/, \"\");\n }\n return undefined;\n}\n\n/** Human sentence for a bare HTTP status, when the body carried no copy. */\nexport function httpStatusExplanation(status: number): string {\n return (\n HTTP_STATUS_EXPLANATION[status] ??\n \"The request failed with an unexpected status.\"\n );\n}\n\n/**\n * Sentence-case the first character. Server `detail` / `title` sometimes\n * arrive fully lowercase; UI copy always leads with a capital.\n */\nexport function capitalizeFirst(text: string): string {\n if (!text) return text;\n const first = text.charAt(0);\n const upper = first.toUpperCase();\n if (first === upper) return text;\n return upper + text.slice(1);\n}\n\n/**\n * Turn a caught value into displayable copy. `Error` and `ErrorView` call\n * this internally; use it directly for other surfaces (a toast, a banner).\n *\n * Status-only failures (HTTP not ok, but no contract `code` / copy) still\n * keep `problem` so the details panel can show the status. Title becomes the\n * reason phrase (e.g. \"Bad Gateway\"); description is a short explanation —\n * not just the numeric code.\n */\nexport function describeError(error: unknown): ErrorDescription {\n const problem = parseProblem(error);\n if (problem == null) return { title: GENERIC_ERROR_TITLE };\n\n const description =\n [problem.detail, problem.remediation?.action]\n .filter((part): part is string => typeof part === \"string\" && part !== \"\")\n .join(\" \") || undefined;\n\n if (!hasContractCode(problem) && description == null) {\n const reason = httpReasonPhrase(problem.status, problem.title);\n return {\n title: capitalizeFirst(reason ?? GENERIC_ERROR_TITLE),\n description: httpStatusExplanation(problem.status),\n requestId: problem.requestId,\n problem,\n };\n }\n\n return {\n title: capitalizeFirst(problem.title || GENERIC_ERROR_TITLE),\n description: description ? capitalizeFirst(description) : undefined,\n documentation: problem.remediation?.documentation,\n requestId: problem.requestId,\n problem,\n };\n}\n","import {\n useEffect,\n useRef,\n useState,\n type ComponentProps,\n type ReactNode,\n} from \"react\";\nimport {\n IconAlertCircleFilled,\n IconAlertTriangle,\n IconAlertTriangleFilled,\n IconInfoCircle,\n} from \"@tabler/icons-react\";\nimport { cn } from \"../../utils/cn\";\nimport { Button, ButtonLink } from \"../button/button\";\nimport { Popover } from \"../popover/popover\";\nimport { StatusView, type StatusViewSize } from \"../status-view/status-view\";\nimport {\n capitalizeFirst,\n describeError,\n httpReasonPhrase,\n type ErrorDescription,\n} from \"./problem\";\n\n/** Capitalize string copy; leave custom ReactNode overrides alone. */\nfunction displayCopy(value: ReactNode): ReactNode {\n return typeof value === \"string\" ? capitalizeFirst(value) : value;\n}\n\n/**\n * Design notes:\n * - ONE input: `error` is the caught value, whatever it is — a Problem\n * Details body from `@photon-hq/error`, an `Error` carrying one as\n * `cause`, or something unknown. The component derives its copy via\n * `describeError`; unknowns fall back to a generic line rather than\n * leaking raw messages.\n * - TWO presentations, one per altitude: `Error` is the inline line for\n * forms, cards, and action rows; `ErrorView` is the region / page state\n * built on StatusView (same `sm` / `base` size axis).\n * - Both render `null` when there is nothing to show, so they can sit\n * unconditionally in JSX (`<Error error={mutation.error} />`).\n * - `Warning` is the inline line's second state: the same row in warning\n * ink, for something the user may go ahead with but should look at\n * twice. It never blocks, so it takes its copy and nothing else.\n * - Client-side *validation* is not this component's job — that belongs to\n * `Field.Error`, wired to control validity.\n */\n\nconst DOC_LINK_LABEL = \"Learn more\";\nconst RETRY_LABEL = \"Try again\";\n\ninterface ErrorBaseProps {\n /** The caught value — a problem body, an `Error` wrapping one, or unknown. */\n error?: unknown;\n /** Override the derived message. */\n children?: ReactNode;\n}\n\nexport interface ErrorProps\n extends ErrorBaseProps, Omit<ComponentProps<\"div\">, keyof ErrorBaseProps> {}\n\n/**\n * Error — one line of red ink naming a server failure (4xx / 5xx), placed\n * inline: under a form, in a card, beside the action that failed. Give it the\n * caught value and it renders the problem's `detail` (falling back to `title`,\n * then to a generic line), plus a docs link when the problem carries one.\n * Renders nothing while `error` is nullish, so it can stay mounted.\n *\n * For a region or page that failed to load, use {@link ErrorView}.\n */\nexport function Error({ error, children, className, ...props }: ErrorProps) {\n if (error == null && children == null) return null;\n const copy = describeError(error);\n return (\n <div\n role=\"alert\"\n className={cn(\n \"text-pho-error flex min-w-0 items-start gap-1.5 text-base\",\n className,\n )}\n {...props}\n >\n <span aria-hidden className=\"flex h-[1lh] shrink-0 items-center\">\n <IconAlertCircleFilled className=\"size-4\" />\n </span>\n <span className=\"min-w-0\">\n {displayCopy(children ?? copy.description ?? copy.title)}\n {copy.documentation != null && (\n <>\n {\" \"}\n <a\n href={copy.documentation}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"font-medium underline underline-offset-2\"\n >\n {DOC_LINK_LABEL}\n </a>\n </>\n )}\n {/* Trailing whitespace collapses when the details render null. */}{\" \"}\n <ErrorDetails copy={copy} />\n </span>\n </div>\n );\n}\n\nError.displayName = \"Error\";\n\nexport interface WarningProps extends Omit<\n ComponentProps<\"output\">,\n \"children\"\n> {\n /** What to look at twice. Shows nothing while nullish. */\n children?: ReactNode;\n}\n\n/**\n * Warning — the inline `Error` line in warning ink, a triangle in place of\n * the circle: something the user can go ahead with but may not mean (an\n * address outside the team, a value that differs from the usual one). Same\n * row, glyph seat and type as `Error`, so the two can take turns in one\n * place. It doesn't stop anything, so it announces politely (an `output`,\n * role `status`) and carries no details disclosure.\n *\n * A polite region is announced when its content changes, not when it is\n * inserted, so the `output` stays mounted while the copy is nullish:\n * empty and `sr-only`, the way pho-ui's other live regions sit, it keeps\n * its role and, out of flow, adds no gap to a stack.\n */\nexport function Warning({ children, className, ...props }: WarningProps) {\n // `{cond && copy}` leaves false behind: no copy either.\n const shown = children != null && children !== false && children !== \"\";\n return (\n <output\n className={\n shown\n ? cn(\n \"text-pho-warning flex min-w-0 items-start gap-1.5 text-base\",\n className,\n )\n : \"sr-only\"\n }\n {...props}\n >\n {shown && (\n <>\n <span aria-hidden className=\"flex h-[1lh] shrink-0 items-center\">\n <IconAlertTriangleFilled className=\"size-4\" />\n </span>\n <span className=\"min-w-0\">{displayCopy(children)}</span>\n </>\n )}\n </output>\n );\n}\n\nWarning.displayName = \"Warning\";\n\n/**\n * Hover / focus disclosure on the inline line — the request's fuller story:\n * problem `title` (with the same alert icon + `text-pho-error` ink as the\n * inline line), the untruncated description, then `status` + `code` and the\n * copyable request id grouped below for a support handoff. Renders only when\n * the caught value actually carried a problem (or at least a request id); a\n * generic unknown has nothing more to disclose. Built on `Popover` rather\n * than `Tooltip` because the panel holds an interactive control (the copy\n * button) — `openOnHover` keeps the tooltip-like gesture.\n */\nfunction ErrorDetails({ copy }: { copy: ErrorDescription }) {\n const { problem, requestId } = copy;\n if (problem == null && requestId == null) return null;\n\n // Contract problems show `status CODE`; status-only shows `status Reason`.\n let statusLine: string | null = null;\n if (problem != null) {\n if (problem.code) {\n statusLine = `${problem.status} ${problem.code}`;\n } else {\n const reason = httpReasonPhrase(problem.status, problem.title);\n statusLine = reason\n ? `${problem.status} ${reason}`\n : String(problem.status);\n }\n }\n\n return (\n <Popover.Root>\n <Popover.Trigger\n openOnHover\n delay={150}\n aria-label=\"Error details\"\n className=\"outline-pho-brand inline-flex size-4 shrink-0 translate-y-[3px] cursor-help items-center justify-center rounded-full opacity-70 transition-opacity hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-2\"\n >\n <IconInfoCircle className=\"size-3.5\" />\n </Popover.Trigger>\n <Popover.Portal>\n <Popover.Positioner align=\"start\">\n <Popover.Popup className=\"text-pho-error\">\n <Popover.Title className=\"text-pho-error flex items-start gap-1.5\">\n <span aria-hidden className=\"flex h-[1lh] shrink-0 items-center\">\n <IconAlertCircleFilled className=\"size-4\" />\n </span>\n {copy.title}\n </Popover.Title>\n {copy.description != null && (\n <Popover.Description className=\"text-pho-error\">\n {copy.description}\n </Popover.Description>\n )}\n {(statusLine != null || requestId != null) && (\n <div className=\"text-pho-error mt-1 font-mono text-[10px] leading-snug\">\n {statusLine != null && <p>{statusLine}</p>}\n {requestId != null && (\n <RequestId requestId={requestId} className=\"mt-0\" />\n )}\n </div>\n )}\n </Popover.Popup>\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n );\n}\n\n/** Request-id footnote — click copies the id for support handoff. */\nfunction RequestId({\n requestId,\n className,\n}: {\n requestId: string;\n className?: string;\n}) {\n const [copied, setCopied] = useState(false);\n const copiedTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(\n () => () => {\n if (copiedTimer.current) clearTimeout(copiedTimer.current);\n },\n [],\n );\n\n return (\n <span\n className={cn(\"mt-1 block font-mono text-[10px] leading-snug\", className)}\n >\n Request ID:{\" \"}\n <button\n type=\"button\"\n className=\"outline-pho-brand inline cursor-pointer underline-offset-2 select-all hover:underline focus-visible:underline focus-visible:outline-2 focus-visible:-outline-offset-1\"\n aria-label={\n copied ? \"Request ID copied\" : `Copy request ID ${requestId}`\n }\n onClick={async () => {\n try {\n await navigator.clipboard.writeText(requestId);\n } catch {\n return;\n }\n setCopied(true);\n if (copiedTimer.current) clearTimeout(copiedTimer.current);\n copiedTimer.current = setTimeout(() => setCopied(false), 1500);\n }}\n >\n {requestId}\n </button>\n <output className=\"sr-only\" aria-live=\"polite\">\n {copied ? \"Copied\" : \"\"}\n </output>\n </span>\n );\n}\n\ninterface ErrorViewBaseProps {\n /** The caught value — a problem body, an `Error` wrapping one, or unknown. */\n error?: unknown;\n /** Override the derived title. */\n title?: ReactNode;\n /** Override the derived description. */\n description?: ReactNode;\n /** Override the warning glyph. */\n icon?: ReactNode;\n /** Offer a retry — renders a \"Try again\" button. */\n onRetry?: () => void;\n /** Replace the built-in action row entirely. */\n actions?: ReactNode;\n /** Size variant — StatusView's axis. @default \"base\" */\n size?: StatusViewSize;\n}\n\nexport interface ErrorViewProps\n extends\n ErrorViewBaseProps,\n Omit<ComponentProps<\"div\">, keyof ErrorViewBaseProps | \"children\"> {}\n\n/**\n * ErrorView — the failed state of a region or page, built on StatusView:\n * warning icon over the problem's `title`, its `detail` and remediation\n * below, an action row (`onRetry` and the problem's docs link), and the\n * request id as a footnote for support. Announces via `role=\"alert\"`.\n *\n * Use `size=\"sm\"` inside cards and panels, the default `base` for whole\n * pages. Renders nothing while `error` is nullish (unless given a static\n * `title`), so it can sit unconditionally next to a query.\n */\nexport function ErrorView({\n error,\n title,\n description,\n icon,\n onRetry,\n actions,\n size = \"base\",\n ...props\n}: ErrorViewProps) {\n if (error == null && title == null) return null;\n const copy = describeError(error);\n\n const resolvedDescription = displayCopy(description ?? copy.description);\n const body =\n resolvedDescription != null || copy.requestId != null ? (\n <>\n {resolvedDescription}\n {copy.requestId != null && <RequestId requestId={copy.requestId} />}\n </>\n ) : undefined;\n\n const resolvedActions =\n actions ??\n (onRetry != null || copy.documentation != null ? (\n <>\n {onRetry != null && (\n <Button size=\"sm\" onClick={onRetry}>\n {RETRY_LABEL}\n </Button>\n )}\n {copy.documentation != null && (\n <ButtonLink\n size=\"sm\"\n variant=\"outlined\"\n href={copy.documentation}\n target=\"_blank\"\n rel=\"noreferrer\"\n >\n {DOC_LINK_LABEL}\n </ButtonLink>\n )}\n </>\n ) : undefined);\n\n return (\n <StatusView\n role=\"alert\"\n size={size}\n icon={icon ?? <IconAlertTriangle />}\n title={displayCopy(title ?? copy.title)}\n description={body}\n actions={resolvedActions}\n {...props}\n />\n );\n}\n\nErrorView.displayName = \"ErrorView\";\n"],"ignoreList":[0],"mappings":";;;;;;;;;;;AASA,IAAMgB,IAAa;AAAA,EAAC,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAW,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAA4I,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAc,KAAO;AAAA,EAAQ,CAAC;AAAC,GAC1RC,IAAoBb,EAAqB,WAAW,kBAAkB,iBAAiBY,CAAU;AC2BvG,SAAgBE,EAAUC,GAAkC;AAC1D,MAAI,OAAOA,KAAU,YAAYA,MAAU,KAAM,QAAO;AACxD,QAAMC,IAAID;AACV,SACE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