temporal-fmt 0.9.2 → 0.9.4

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 (103) hide show
  1. package/README.md +480 -9
  2. package/dist/calendarUtils.cjs +259 -4
  3. package/dist/calendarUtils.cjs.map +1 -1
  4. package/dist/calendarUtils.js +33 -1
  5. package/dist/chunk-4N3WCGEY.js +183 -0
  6. package/dist/{chunk-4JWGUR4O.js.map → chunk-4N3WCGEY.js.map} +1 -1
  7. package/dist/chunk-5UTV5VP6.js +984 -0
  8. package/dist/chunk-5UTV5VP6.js.map +1 -0
  9. package/dist/chunk-ACKKWH5Z.js +578 -0
  10. package/dist/{chunk-2JHEV7ZF.js.map → chunk-ACKKWH5Z.js.map} +1 -1
  11. package/dist/chunk-EGUUO6LE.js +439 -0
  12. package/dist/chunk-EGUUO6LE.js.map +1 -0
  13. package/dist/chunk-FBPHNRVW.js +2939 -0
  14. package/dist/chunk-FBPHNRVW.js.map +1 -0
  15. package/dist/chunk-GPB4JHGI.js +65 -0
  16. package/dist/chunk-GPB4JHGI.js.map +1 -0
  17. package/dist/chunk-H7YQX25T.js +170 -0
  18. package/dist/{chunk-J2AQNXF2.js.map → chunk-H7YQX25T.js.map} +1 -1
  19. package/dist/chunk-HXY2GUUM.js +182 -0
  20. package/dist/{chunk-EHLRZULM.js.map → chunk-HXY2GUUM.js.map} +1 -1
  21. package/dist/chunk-L24NPTAJ.js +328 -0
  22. package/dist/chunk-L24NPTAJ.js.map +1 -0
  23. package/dist/chunk-M3GDTHMT.js +169 -0
  24. package/dist/chunk-M3GDTHMT.js.map +1 -0
  25. package/dist/chunk-MKPDLQKD.js +51 -0
  26. package/dist/chunk-MKPDLQKD.js.map +1 -0
  27. package/dist/chunk-TSLPIURC.js +242 -0
  28. package/dist/{chunk-VQXUMFB2.js.map → chunk-TSLPIURC.js.map} +1 -1
  29. package/dist/chunk-UOPAV3WX.js +75 -0
  30. package/dist/chunk-UOPAV3WX.js.map +1 -0
  31. package/dist/chunk-VNIUIQA4.js +398 -0
  32. package/dist/chunk-VNIUIQA4.js.map +1 -0
  33. package/dist/chunk-YEUASGDK.js +9 -0
  34. package/dist/chunk-YEUASGDK.js.map +1 -0
  35. package/dist/chunk-ZQZF5EXW.js +29 -0
  36. package/dist/chunk-ZQZF5EXW.js.map +1 -0
  37. package/dist/config.d.cts +4 -2
  38. package/dist/config.d.ts +4 -2
  39. package/dist/duration.cjs +638 -26
  40. package/dist/duration.cjs.map +1 -1
  41. package/dist/duration.js +28 -1
  42. package/dist/format.cjs +833 -35
  43. package/dist/format.cjs.map +1 -1
  44. package/dist/format.js +20 -1
  45. package/dist/index.cjs +7698 -163
  46. package/dist/index.cjs.map +1 -1
  47. package/dist/index.d.cts +108 -24
  48. package/dist/index.d.ts +108 -24
  49. package/dist/index.js +1536 -58
  50. package/dist/index.js.map +1 -1
  51. package/dist/interval.cjs +5480 -35
  52. package/dist/interval.cjs.map +1 -1
  53. package/dist/interval.js +46 -1
  54. package/dist/localeRegistry.cjs +375 -32
  55. package/dist/localeRegistry.cjs.map +1 -1
  56. package/dist/localeRegistry.js +11 -1
  57. package/dist/modApi.d.cts +131 -0
  58. package/dist/modApi.d.ts +131 -0
  59. package/dist/parse.cjs +1797 -70
  60. package/dist/parse.cjs.map +1 -1
  61. package/dist/parse.js +20 -1
  62. package/dist/pattern.d.cts +1 -0
  63. package/dist/pattern.d.ts +1 -0
  64. package/dist/recurrence.cjs +452 -20
  65. package/dist/recurrence.cjs.map +1 -1
  66. package/dist/recurrence.js +19 -1
  67. package/dist/relativeTime.cjs +268 -21
  68. package/dist/relativeTime.cjs.map +1 -1
  69. package/dist/relativeTime.js +14 -1
  70. package/dist/runtime.d.cts +201 -0
  71. package/dist/runtime.d.ts +201 -0
  72. package/dist/timezone.cjs +387 -20
  73. package/dist/timezone.cjs.map +1 -1
  74. package/dist/timezone.js +26 -1
  75. package/package.json +4 -6
  76. package/scripts/cli.mjs +27 -5
  77. package/dist/chunk-2JHEV7ZF.js +0 -7
  78. package/dist/chunk-3MZLTVP3.js +0 -2
  79. package/dist/chunk-3MZLTVP3.js.map +0 -1
  80. package/dist/chunk-4JWGUR4O.js +0 -11
  81. package/dist/chunk-5U5WJ465.js +0 -36
  82. package/dist/chunk-5U5WJ465.js.map +0 -1
  83. package/dist/chunk-C5YESWFT.js +0 -2
  84. package/dist/chunk-C5YESWFT.js.map +0 -1
  85. package/dist/chunk-C6ZZ62ET.js +0 -2
  86. package/dist/chunk-C6ZZ62ET.js.map +0 -1
  87. package/dist/chunk-EHLRZULM.js +0 -5
  88. package/dist/chunk-F4RGUDA3.js +0 -2
  89. package/dist/chunk-F4RGUDA3.js.map +0 -1
  90. package/dist/chunk-J2AQNXF2.js +0 -2
  91. package/dist/chunk-NBXF7V5B.js +0 -2
  92. package/dist/chunk-NBXF7V5B.js.map +0 -1
  93. package/dist/chunk-R52YOKI3.js +0 -7
  94. package/dist/chunk-R52YOKI3.js.map +0 -1
  95. package/dist/chunk-UJR6DHXY.js +0 -2
  96. package/dist/chunk-UJR6DHXY.js.map +0 -1
  97. package/dist/chunk-VQXUMFB2.js +0 -21
  98. package/dist/chunk-XH46JNPK.js +0 -2
  99. package/dist/chunk-XH46JNPK.js.map +0 -1
  100. package/dist/chunk-YB6YAG7E.js +0 -35
  101. package/dist/chunk-YB6YAG7E.js.map +0 -1
  102. package/dist/chunk-ZGMTY52O.js +0 -2
  103. package/dist/chunk-ZGMTY52O.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/relativeGrammar.ts","../src/parseRelative.ts","../src/tokenMetadata.ts","../src/analyze.ts","../src/serialization.ts","../src/config.ts","../src/businessCalendar.ts","../src/holidays.ts","../src/ideData.ts","../src/codemod.ts","../src/runtime.ts","../src/interval.ts"],"sourcesContent":["// lets people register their own relative-date grammars on top of\n// parseRelative.ts, which only ships with English/Spanish/French/German\n// baked in.\n//\n// parseRelative() looks at the locale option, figures out the language,\n// and dispatches. registerRelativeGrammar() means someone can bolt on\n// a new language without touching parseRelative.ts itself.\n//\n// a grammar is just a list of matchers, each one either resolves to a\n// Temporal field bag or returns null. tries them in order, first match\n// wins — same shape as the ENGLISH/SPANISH/FRENCH/GERMAN_GRAMMAR objects\n// parseRelative already has internally, just made pluggable\n\nimport { getTemporal, type TemporalNamespace } from './temporalProvider.js';\n\nexport interface RelativeGrammarMatch {\n // whatever fields the matcher figured out, gets fed to Temporal.PlainDate.from()\n year?: number;\n month?: number;\n day?: number;\n // for cases like \"next Tuesday\" where you can't compute the fields\n // without knowing the reference date's weekday first — pass a function\n // instead of raw fields\n resolve?: (reference: { year: number; month: number; day: number; dayOfWeek: number }) => { year: number; month: number; day: number };\n}\n\nexport interface RelativeGrammar {\n // language subtag ('en', 'es', etc), matched against the locale option\n language: string;\n // tried top to bottom, first one that matches wins\n matchers: Array<(input: string) => RelativeGrammarMatch | null>;\n}\n\n// cap so nobody can loop registerRelativeGrammar() and blow up the array\n// (and the scan in tryRegisteredGrammar with it) forever. re-registering\n// an existing language doesn't count against this, only actually new ones.\n// same idea as what registerLocaleVocab does for custom vocabs\nconst MAX_REGISTERED_GRAMMARS = 100;\n\nconst registeredGrammars: RelativeGrammar[] = [];\n\nexport function registerRelativeGrammar(grammar: RelativeGrammar): void {\n if (typeof grammar.language !== 'string' || grammar.language.length === 0) {\n throw new Error('temporal-fmt: registerRelativeGrammar requires a non-empty language string.');\n }\n if (!Array.isArray(grammar.matchers) || grammar.matchers.length === 0) {\n throw new Error('temporal-fmt: registerRelativeGrammar requires at least one matcher.');\n }\n // if this language's already registered, just swap it out\n const existingIdx = registeredGrammars.findIndex((g) => g.language === grammar.language);\n if (existingIdx >= 0) {\n registeredGrammars[existingIdx] = grammar;\n } else {\n if (registeredGrammars.length >= MAX_REGISTERED_GRAMMARS) {\n throw new RangeError(`temporal-fmt: registerRelativeGrammar reached the ${MAX_REGISTERED_GRAMMARS}-grammar limit.`);\n }\n registeredGrammars.push(grammar);\n }\n}\n\n// parseRelative() calls this first, before falling back to the built-ins.\n// null means nothing registered matched\nexport function tryRegisteredGrammar(\n language: string,\n input: string,\n reference: { year: number; month: number; day: number; dayOfWeek: number },\n): unknown | null {\n for (const grammar of registeredGrammars) {\n if (grammar.language !== language) continue;\n for (const matcher of grammar.matchers) {\n const match = matcher(input);\n if (match === null) continue;\n const temporal = getTemporal();\n if (match.resolve) {\n const fields = match.resolve(reference);\n return temporal.PlainDate.from(fields, { overflow: 'reject' });\n }\n return temporal.PlainDate.from(\n { year: match.year ?? reference.year, month: match.month ?? reference.month, day: match.day ?? reference.day },\n { overflow: 'reject' },\n );\n }\n }\n return null;\n}\n\n// just for introspection, lists what's registered\nexport function listRegisteredGrammars(): string[] {\n return registeredGrammars.map((g) => g.language);\n}\n\n// this is just here so TS doesn't complain about the unused import —\n// TemporalNamespace shows up in the type signature above but not as a\n// real runtime reference\nvoid (undefined as unknown as TemporalNamespace);\n","import { getTemporal } from './temporalProvider.js';\nimport { type TemporalNamespace } from './temporalProvider.js';\nimport { tryRegisteredGrammar } from './relativeGrammar.js';\nimport { DEFAULT_LOCALE, type FormatOptions } from './tokens.js';\n\n// parseRelative resolves common relative-date phrases (\"next Tuesday\",\n// \"in 3 days\", \"March 5th\") against a reference date, returning a\n// Temporal.PlainDate. It's a different subsystem from the token-based\n// parse(): the input is free natural-language text, not a structurally-\n// typed format string, so this module owns its own grammar rather than\n// bolting a natural-language layer onto the existing tokenizer.\n//\n// Per-language grammars: each locale's grammar lives in its own\n// clearly-labeled section below (ENGLISH_GRAMMAR, SPANISH_GRAMMAR,\n// FRENCH_GRAMMAR, GERMAN_GRAMMAR). The vocabulary and phrase patterns\n// are NOT shared across languages — Spanish \"hace 2 semanas\" and\n// French \"il y a 2 semaines\" are different idioms and get their own\n// regexes. What IS shared is the matching engine (iterate matchers in\n// order, first match wins, throw on no match) and the resolution\n// helpers (addDays, addUnits, weekdayOffset, resolveToNextOccurrence).\n// Same approach the humanizing skill calls \"solve each recurring\n// problem once\": the matching strategy is shared, the per-language\n// vocabulary is not.\n//\n// Default locale (no `locale` option) uses English — matches the\n// pre-change behavior byte-for-byte. Passing `locale: 'es'`,\n// `locale: 'fr'`, or `locale: 'de'` (or any locale tag with that\n// language subtag) routes to the corresponding grammar. Unrecognized\n// languages fall back to English rather than throwing — a caller\n// passing `locale: 'it-IT'` still gets *some* result, just from the\n// English grammar. (We could throw instead; the current contract is\n// \"best effort.\" If the caller wanted Italian specifically, they'd\n// pass an Italian grammar via registerLocaleVocab-style extension —\n// not implemented here.)\n\n// Lowercase + expand German umlauts (ä→ae, ö→oe, ü→ue, ß→ss) + strip\n// remaining diacritics. Three things going on at once:\n//\n// 1. Lowercase — case-insensitive matching without forcing the\n// regex flag to do it (also keeps the captured groups lowercase\n// for the resolver's comparisons).\n// 2. Expand German umlaut transliterations. Germans without an\n// umlaut key write \"ä\" as \"ae\" — the standard transliteration.\n// Expanding \"ä\" → \"ae\" (before NFD stripping) means both \"März\"\n// and \"Maerz\" normalize to \"maerz\" and match the same pattern.\n// The reverse (ae → ä) would be wrong: \"Tage\" has \"ae\" as a\n// coincidence, not as an umlaut transliteration. Forward expansion\n// is unambiguous because the source string already has the\n// umlaut — the expansion only affects the matched form.\n// 3. Strip combining marks via NFD. \"Miércoles\" → \"Miercoles\",\n// \"février\" → \"fevrier\", \"août\" → \"aout\". Pairs with the umlaut\n// expansion above so all four languages' accented forms collapse\n// to one canonical unaccented form for matching.\n//\n// Both sides of the match — input string AND the weekday/month name\n// lists — get the same normalization applied, so this is symmetric.\nfunction normalizeForMatch(s: string): string {\n return s.toLowerCase()\n .replace(/ä/g, 'ae')\n .replace(/ö/g, 'oe')\n .replace(/ü/g, 'ue')\n .replace(/ß/g, 'ss')\n .normalize('NFD')\n .replace(/[\\u0300-\\u036f]/g, '');\n}\n\n// Standard Levenshtein edit distance (insert/delete/substitute, cost 1\n// each). Used only by the opt-in fuzzy layer below — the exact matcher\n// pass never calls this. Iterative DP over two rows, not the full\n// matrix, since only the previous row is ever needed.\nfunction levenshtein(a: string, b: string): number {\n /* c8 ignore start @preserve -- unreachable through the only call\n * site (fuzzyCorrectEnglish): `a` is always a word that already\n * failed the `vocabulary.includes(word)` exact-match check, so\n * a === b never holds against any `b` drawn from that same\n * vocabulary; and neither `a` (split from a non-empty normalized\n * string) nor `b` (a vocabulary entry) is ever empty. Kept as\n * general-purpose guards in case levenshtein() gets a second caller\n * later. */\n if (a === b) return 0;\n if (a.length === 0) return b.length;\n if (b.length === 0) return a.length;\n /* c8 ignore stop @preserve */\n let prev = new Array(b.length + 1);\n let curr = new Array(b.length + 1);\n for (let j = 0; j <= b.length; j++) prev[j] = j;\n for (let i = 1; i <= a.length; i++) {\n curr[0] = i;\n for (let j = 1; j <= b.length; j++) {\n const cost = a[i - 1] === b[j - 1] ? 0 : 1;\n curr[j] = Math.min(\n prev[j] + 1, // deletion\n curr[j - 1] + 1, // insertion\n prev[j - 1] + cost, // substitution\n );\n }\n [prev, curr] = [curr, prev];\n }\n return prev[b.length];\n}\n\n// Max edit distance a fuzzy correction is allowed to bridge. 2 covers\n// the common single-finger-slip and single-transposed-letter typo cases\n// (\"tommorow\" is distance 1 from \"tomorrow\"; \"tuesady\" is distance 2\n// from \"tuesday\" — a transposition costs 2 under simple Levenshtein,\n// which doesn't special-case adjacent-swap as a single edit) without\n// opening the door to correcting a word into something only vaguely\n// similar. Deliberately conservative — this is a typo-tolerance layer,\n// not a \"guess what they meant\" layer; the library's whole design\n// philosophy elsewhere (parse()'s strict-by-default ambiguity handling,\n// the lenient opt-in) is to bound how much guessing is allowed and make\n// the caller ask for it explicitly.\nconst FUZZY_MAX_DISTANCE = 2;\nconst MAX_RELATIVE_INPUT_LENGTH = 4096;\nconst MAX_RELATIVE_WORDS = 32;\n\n// English-only fuzzy vocabulary. Anything a matcher's regex treats as a\n// fixed keyword (not a captured number) belongs here — weekday names,\n// month names (long and short), and the marker words the matchers\n// switch on (today/tomorrow/yesterday/next/last/this/in/ago and the\n// unit words day/week/month/year). Numbers and ordinal suffixes are\n// deliberately excluded: \"5th\" vs \"5tj\" isn't a word-shaped typo this\n// layer is trying to solve, and correcting digits is a much easier way\n// to silently produce a wrong date than correcting a weekday name is.\n//\n// Scoped to English only for this pass — the other three grammars have\n// enough positional/multi-word-marker variation (French's \"il y a\",\n// Spanish's dual pre/post weekday-modifier shapes) that a single\n// word-substitution corrector isn't a good fit for all of them without\n// per-language tuning this change doesn't attempt. parseRelative()\n// throws a clear scope-limited error if { fuzzy: true } is combined\n// with a non-English locale, rather than silently no-op-ing.\nfunction buildEnglishFuzzyVocabulary(): string[] {\n return [\n ...ENGLISH_WEEKDAYS,\n ...ENGLISH_MONTHS,\n ...ENGLISH_MONTH_SHORT,\n 'today', 'tomorrow', 'yesterday',\n 'next', 'last', 'this',\n 'in', 'ago',\n 'day', 'days', 'week', 'weeks', 'month', 'months', 'year', 'years',\n ].map(normalizeForMatch);\n}\n\n// Lazily built and cached — the vocabulary is static per process, no\n// need to rebuild the normalized list on every fuzzy call.\nlet englishFuzzyVocabulary: readonly string[] | undefined;\nfunction getEnglishFuzzyVocabulary(): readonly string[] {\n if (!englishFuzzyVocabulary) englishFuzzyVocabulary = Object.freeze(buildEnglishFuzzyVocabulary());\n return englishFuzzyVocabulary;\n}\n\n// Attempts a word-level fuzzy correction of `normalized` against the\n// English vocabulary, returning a corrected string or undefined if no\n// correction was needed/possible. Tokenizes on whitespace; each token\n// that isn't already an exact vocabulary word (or a pure number/ordinal,\n// which passes through untouched) gets replaced with its closest\n// vocabulary match, if one exists within FUZZY_MAX_DISTANCE. If a token\n// has no sufficiently-close vocabulary match, it's left as-is — the\n// re-attempted exact match will then fail on that token same as before,\n// which is the correct outcome for \"this word isn't a typo of anything\n// we know, it's just not a phrase we support.\"\nfunction fuzzyCorrectEnglish(normalized: string): string | undefined {\n const vocabulary = getEnglishFuzzyVocabulary();\n const words = normalized.split(' ');\n if (normalized.length > MAX_RELATIVE_INPUT_LENGTH || words.length > MAX_RELATIVE_WORDS) {\n throw new RangeError(\n `temporal-fmt: parseRelative fuzzy input is too large (maximum ${MAX_RELATIVE_INPUT_LENGTH} characters and ${MAX_RELATIVE_WORDS} words).`,\n );\n }\n let changed = false;\n const corrected = words.map((word) => {\n // Pure digits, or digits with an ordinal suffix (st/nd/rd/th) —\n // never touched by fuzzy correction. See the vocabulary comment\n // above for why.\n if (/^\\d+(?:st|nd|rd|th)?$/.test(word)) return word;\n // Already an exact vocabulary word — nothing to correct.\n if (vocabulary.includes(word)) return word;\n\n let best: string | undefined;\n let bestDist = FUZZY_MAX_DISTANCE + 1;\n for (const candidate of vocabulary) {\n const dist = levenshtein(word, candidate);\n if (dist < bestDist) {\n bestDist = dist;\n best = candidate;\n }\n }\n if (best !== undefined && bestDist <= FUZZY_MAX_DISTANCE) {\n changed = true;\n return best;\n }\n return word;\n });\n\n return changed ? corrected.join(' ') : undefined;\n}\n\ninterface TemporalFieldBag {\n year?: number;\n month?: number;\n day?: number;\n dayOfWeek?: number;\n hour?: number;\n minute?: number;\n second?: number;\n millisecond?: number;\n}\n\nfunction readYear(reference: TemporalFieldBag): number {\n if (typeof reference.year !== 'number') {\n throw new Error('temporal-fmt: parseRelative reference date is missing year.');\n }\n return reference.year;\n}\nfunction readMonth(reference: TemporalFieldBag): number {\n if (typeof reference.month !== 'number') {\n throw new Error('temporal-fmt: parseRelative reference date is missing month.');\n }\n return reference.month;\n}\nfunction readDay(reference: TemporalFieldBag): number {\n if (typeof reference.day !== 'number') {\n throw new Error('temporal-fmt: parseRelative reference date is missing day.');\n }\n return reference.day;\n}\n\nfunction extractDayOfWeek(reference: TemporalFieldBag): number {\n const dow = reference.dayOfWeek;\n if (typeof dow !== 'number') {\n throw new Error(\n 'temporal-fmt: parseRelative needs a reference date exposing dayOfWeek (a Temporal.PlainDate / PlainDateTime / ZonedDateTime).'\n );\n }\n return dow;\n}\n\n// Build an alternation regex fragment from a name list, normalized for\n// matching. Longest-first so \"September\" wins over \"Sep\" in the same\n// match position. The caller is responsible for any wrapping groups\n// or anchors — this just produces the inner alternation.\nfunction nameAlternation(names: string[]): string {\n const normalized = names.map(normalizeForMatch);\n // Dedupe — some locales render the long and short form identically\n // (English \"May\" is the same in both MMMM and MMM lists). Keep both\n // in the alternation rather than deduping, since duplicates in a\n // regex alternation don't change behavior and the dedupe would just\n // be a micro-optimization.\n // Sort longest-first so a longer name wins over its own prefix.\n const sorted = [...normalized].sort((a, b) => b.length - a.length);\n // Escape regex metacharacters — names shouldn't contain any, but\n // belt-and-braces avoids a future \"M+1\" month name from breaking\n // the alternation silently.\n return sorted.map((n) => n.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')).join('|');\n}\n\n// Resolves to a PlainDate by adding `days` to the reference. Used for\n// weekday refs and the today/tomorrow/yesterday family.\nfunction buildPlainDate(temporal: { PlainDate: { from: (fields: Record<string, number>, options?: { overflow?: 'constrain' | 'reject' }) => unknown } }, year: number, month: number, day: number): unknown {\n return temporal.PlainDate.from({ year, month, day }, { overflow: 'reject' });\n}\n\nfunction addDays(\n temporal: { PlainDate: { from: (fields: Record<string, number>) => unknown } },\n reference: TemporalFieldBag,\n days: number,\n): unknown {\n // Build the reference as a real PlainDate so we can use Temporal's\n // own add() for date arithmetic — calendar-correct (handles month\n // boundaries, leap years, etc.) so we don't have to reimplement it.\n const refDate = temporal.PlainDate.from({\n year: readYear(reference),\n month: readMonth(reference),\n day: readDay(reference),\n }) as { add: (duration: Record<string, number>) => unknown };\n return refDate.add({ days });\n}\n\nfunction addUnits(\n temporal: { PlainDate: { from: (fields: Record<string, number>) => unknown } },\n reference: TemporalFieldBag,\n count: number,\n unit: 'day' | 'week' | 'month' | 'year',\n): unknown {\n const refDate = temporal.PlainDate.from({\n year: readYear(reference),\n month: readMonth(reference),\n day: readDay(reference),\n }) as { add: (duration: Record<string, number>) => unknown };\n const duration: Record<string, number> = {};\n if (unit === 'day') duration.days = count;\n if (unit === 'week') duration.weeks = count;\n if (unit === 'month') duration.months = count;\n if (unit === 'year') duration.years = count;\n return refDate.add(duration);\n}\n\n// \"next X\" — strictly future next occurrence. Said on a Tuesday:\n// \"next Tuesday\" = 7 days from now, not today. Rationale: \"this\n// Tuesday\" handles the same-week case, so \"next Tuesday\" staying\n// strictly-future gives the two phrases distinct, non-overlapping\n// meanings. Documented in README \"parseRelative\".\n//\n// \"last X\" — strictly past most recent occurrence. Symmetric to \"next\".\n//\n// \"this X\" — the X of the current ISO week (Mon..Sun). Can land on\n// today, past, or future depending on where in the week today falls.\n//\n// All three resolve the same way across the four supported languages\n// (en/es/fr/de): the equivalent idiom in each language maps to one of\n// these three rel words. The natural-language reading is consistent\n// — \"next Tuesday\" said on a Tuesday means next week's Tuesday in\n// every language we support.\nfunction weekdayOffset(rel: 'next' | 'last' | 'this', refDow: number, targetDow: number): number {\n // refDow and targetDow are both 1..7 (ISO Mon=1..Sun=7).\n if (rel === 'next') {\n let diff = targetDow - refDow;\n if (diff <= 0) diff += 7; // 0 (today) → 7, negative → wrap forward\n return diff; // 1..7\n }\n if (rel === 'last') {\n let diff = targetDow - refDow;\n if (diff >= 0) diff -= 7; // 0 (today) → -7, positive → wrap backward\n return diff; // -7..-1\n }\n // rel === 'this' — X of the current week. Can be today, past, or future.\n return targetDow - refDow; // -6..+6\n}\n\n// \"March 5th\" without a year → resolve to the next occurrence of that\n// month/day. If today is that date, return today. Otherwise, if it's\n// already past this year, return next year's occurrence.\n//\n// \"Next occurrence\" semantics: future-leaning. Documented in README\n// as the chosen behavior. The alternative (\"nearest in time, past or\n// future\") would mean \"March 5th\" said on March 6 returns yesterday —\n// counterintuitive for the typical \"next birthday\"/\"next deadline\"\n// use case this kind of phrase tends to drive.\nfunction resolveToNextOccurrence(\n temporal: {\n PlainDate: {\n from: (fields: Record<string, number>, options?: { overflow?: 'constrain' | 'reject' }) => unknown;\n compare?: (one: unknown, two: unknown) => number;\n };\n },\n reference: TemporalFieldBag,\n month: number,\n day: number,\n): unknown {\n const refYear = readYear(reference);\n const refDate = temporal.PlainDate.from({\n year: refYear,\n month: readMonth(reference),\n day: readDay(reference),\n });\n // PlainDate.compare is a static method on the namespace, not an\n // instance method — that's why it's called off temporal.PlainDate\n // rather than off an instance below. Checked outside the try/catch\n // below on purpose: that block's catch is scoped to Feb-29-style\n // overflow errors from from(), and silently retries with next year's\n // date. A missing-compare error thrown from inside that try would get\n // caught by the same handler and swallowed by that retry (next year's\n // from() usually succeeds), masking the real problem instead of\n // surfacing it.\n if (!temporal.PlainDate.compare) {\n throw new Error('temporal-fmt: parseRelative needs Temporal.PlainDate.compare to resolve month-day phrases; the active implementation does not expose it.');\n }\n // try this year first; if Feb 29 in a non-leap year, Temporal will\n // throw via overflow: 'reject' — fall through to next year.\n try {\n const thisYear = temporal.PlainDate.from({ year: refYear, month, day }, { overflow: 'reject' });\n // Returns -1 / 0 / 1.\n if (temporal.PlainDate.compare(thisYear, refDate) >= 0) {\n // today or in the future → use this year's occurrence\n return thisYear;\n }\n // already past this year → next year's occurrence\n return temporal.PlainDate.from({ year: refYear + 1, month, day }, { overflow: 'reject' });\n } catch (err) {\n // Feb 29 in a non-leap year, or similar. Try next year — if the\n // caller asked for \"Feb 29\" said in a non-leap year, next year may\n // also not be leap, in which case the inner from() will throw and\n // surface a clear error rather than silently landing on Feb 28.\n try {\n return temporal.PlainDate.from({ year: refYear + 1, month, day }, { overflow: 'reject' });\n } catch {\n throw new Error(\n `temporal-fmt: parseRelative can't resolve month ${month} day ${day} — ` +\n `it isn't a valid date in either ${refYear} or ${refYear + 1}. ` +\n `Original error: ${(err as Error).message}`\n );\n }\n }\n}\n\n// Each language provides a list of matchers. The shared engine\n// iterates them in order and returns the first match. A matcher is a\n// (regex, resolver) pair — the regex captures the structural pieces\n// (count, unit name, weekday name, etc.), the resolver turns them\n// into a Temporal.PlainDate using the shared helpers above.\ninterface ResolveContext {\n temporal: TemporalNamespace;\n reference: TemporalFieldBag;\n}\n\ninterface Matcher {\n pattern: RegExp;\n resolve: (match: RegExpMatchArray, ctx: ResolveContext) => unknown;\n}\n\ninterface RelativeDateGrammar {\n // Single-line description of supported phrase classes, included in\n // the \"doesn't recognize\" error so the caller knows what to try.\n supportedHint: string;\n // Ordered matchers; first match wins.\n matchers: Matcher[];\n}\n\nfunction weekdayIndexFromName(name: string, names: string[]): number {\n const normalized = normalizeForMatch(name);\n const idx = names.findIndex((n) => normalizeForMatch(n) === normalized);\n /* c8 ignore start @preserve -- unreachable: every caller passes a\n * name captured by nameAlternation(names), which builds its regex\n * alternation from this same list under the same normalizeForMatch\n * transform. The regex can't match anything findIndex() wouldn't\n * also find here. Defensive throw kept for the type checker and as\n * a tripwire if that invariant ever breaks. Ignore comment sits on\n * the `if` itself, not just the throw inside it — c8 tracks the\n * branch outcome (was the true side ever taken) separately from the\n * statements inside, so excluding only the inner throw still leaves\n * the branch itself flagged as uncovered. */\n /* c8 ignore next */\n if (idx < 0) {\n throw new Error(`temporal-fmt: parseRelative internal error — weekday \"${name}\" not in names list.`);\n }\n /* c8 ignore stop @preserve */\n return idx + 1;\n}\n\nfunction monthIndexFromName(name: string, longNames: string[], shortNames: string[] = []): number {\n const normalized = normalizeForMatch(name);\n const longIdx = longNames.findIndex((n) => normalizeForMatch(n) === normalized);\n if (longIdx >= 0) return longIdx + 1;\n const shortIdx = shortNames.findIndex((n) => normalizeForMatch(n) === normalized);\n /* c8 ignore next */\n if (shortIdx >= 0) return shortIdx + 1;\n /* c8 ignore start @preserve -- unreachable: every caller passes a name\n * captured by nameAlternation([...longNames, ...shortNames]), so the\n * regex alternation and these two findIndex() scans are built from\n * the same lists under the same normalizeForMatch transform. Kept as\n * a tripwire for the type checker in case that invariant ever breaks. */\n throw new Error(`temporal-fmt: parseRelative internal error — month \"${name}\" not in names list.`);\n /* c8 ignore stop @preserve */\n /* c8 ignore next -- defensive block is unreachable by construction. */\n}\n\n// English grammar — also the default when no locale is supplied. The\n// regexes here are the same ones the pre-change parseRelative() used\n// inline; they've just been pulled into a matcher list so the matching\n// engine can iterate them the same way it does for es/fr/de.\nconst ENGLISH_WEEKDAYS = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];\nconst ENGLISH_MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];\nconst ENGLISH_MONTH_SHORT = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];\n\nconst ENGLISH_GRAMMAR: RelativeDateGrammar = {\n supportedHint: 'Supported: weekday refs (\"next Tuesday\"), day offsets (\"today\"/\"tomorrow\"/\"yesterday\"), unit offsets (\"in 3 days\", \"2 weeks ago\"), and month-day (\"March 5th\").',\n matchers: [\n // today / tomorrow / yesterday — exact match, most rigid shape.\n // Checked first because they're the most common phrase class.\n {\n pattern: /^today$/i,\n resolve: (_m, ctx) => buildPlainDate(ctx.temporal, readYear(ctx.reference), readMonth(ctx.reference), readDay(ctx.reference)),\n },\n {\n pattern: /^tomorrow$/i,\n resolve: (_m, ctx) => addDays(ctx.temporal, ctx.reference, 1),\n },\n {\n pattern: /^yesterday$/i,\n resolve: (_m, ctx) => addDays(ctx.temporal, ctx.reference, -1),\n },\n // weekday references: \"next/last/this Tuesday\". Capture the relative\n // word and the weekday name separately, then resolve via +7 / -7.\n {\n pattern: new RegExp(`^(next|last|this)\\\\s+(${nameAlternation(ENGLISH_WEEKDAYS)})$`, 'i'),\n resolve: (m, ctx) => {\n const rel = m[1]!.toLowerCase() as 'next' | 'last' | 'this';\n const targetDow = weekdayIndexFromName(m[2]!, ENGLISH_WEEKDAYS);\n const refDow = extractDayOfWeek(ctx.reference);\n return addDays(ctx.temporal, ctx.reference, weekdayOffset(rel, refDow, targetDow));\n },\n },\n // unit offsets: \"in 3 days\", \"2 weeks ago\", \"in 1 month\", \"1 year ago\".\n // Two shapes share this matcher — leading \"in\" (future) or trailing\n // \"ago\" (past). Both lead with <number> <unit>.\n {\n pattern: /^(in\\s+)?(\\d+)\\s+(day|week|month|year)s?(?:\\s+ago)?$/i,\n resolve: (m, ctx) => {\n const inPrefix = m[1];\n const count = m[2]!;\n const unitName = m[3]!.toLowerCase() as 'day' | 'week' | 'month' | 'year';\n // Disambiguate future vs past: \"in N units\" is always future; \"N\n // units ago\" is always past. A bare \"N units\" without either is\n // a sign error — throw, since neither direction is implied and\n // guessing is exactly what this library refuses to do.\n const hasIn = !!inPrefix;\n const hasAgo = /\\bago\\b/i.test(m[0]!);\n if (!hasIn && !hasAgo) {\n throw new Error(\n `temporal-fmt: parseRelative can't tell whether \"${m[0]}\" is past or future — ` +\n `use \"in ${count} ${unitName}s\" or \"${count} ${unitName}s ago\".`\n );\n }\n const sign = hasIn ? 1 : -1;\n return addUnits(ctx.temporal, ctx.reference, sign * Number(count), unitName);\n },\n },\n // month-day without year, e.g. \"March 5th\", \"March 5\", \"March 5, 2026\"\n // (year is ignored if present). The ordinal suffix is decorative —\n // strip it. The day-of-month is a 1- or 2-digit number.\n {\n pattern: new RegExp(`^(${nameAlternation([...ENGLISH_MONTHS, ...ENGLISH_MONTH_SHORT])})\\\\s+(\\\\d{1,2})(?:st|nd|rd|th)?(?:,?\\\\s*(\\\\d{4}))?$`, 'i'),\n resolve: (m, ctx) => {\n const month = monthIndexFromName(m[1]!, ENGLISH_MONTHS, ENGLISH_MONTH_SHORT);\n const day = Number(m[2]!);\n return resolveToNextOccurrence(ctx.temporal, ctx.reference, month, day);\n },\n },\n ],\n};\n\n// Spanish grammar. Distinct phrase shapes from English:\n// - \"hace 2 semanas\" (past unit offset) — distinct word \"hace\", not\n// the English \"X units ago\" suffix shape.\n// - \"5 de marzo\" — day-first, with required \"de\" between day and\n// month, opposite of English \"March 5\".\n// - \"el próximo lunes\" / \"lunes pasado\" — weekday ref has the relative\n// word sometimes as a prefix with article, sometimes as a suffix.\n//\n// All four phrase classes the English grammar supports have Spanish\n// equivalents here.\nconst SPANISH_WEEKDAYS = ['lunes', 'martes', 'miércoles', 'jueves', 'viernes', 'sábado', 'domingo'];\nconst SPANISH_MONTHS = ['enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'];\n// Spanish month abbreviations vary by region (\"set\" vs \"sept\" for\n// September). Sticking with the most common ICU form per locale.\nconst SPANISH_MONTH_SHORT = ['ene', 'feb', 'mar', 'abr', 'may', 'jun', 'jul', 'ago', 'sept', 'oct', 'nov', 'dic'];\n\nconst SPANISH_GRAMMAR: RelativeDateGrammar = {\n supportedHint: 'Frases soportadas: referencias de día de la semana (\"el próximo lunes\", \"el lunes pasado\", \"este martes\"), offsets de día (\"hoy\"/\"mañana\"/\"ayer\"), offsets de unidad (\"en 3 días\", \"hace 2 semanas\"), y mes-día (\"5 de marzo\").',\n matchers: [\n {\n pattern: /^hoy$/i,\n resolve: (_m, ctx) => buildPlainDate(ctx.temporal, readYear(ctx.reference), readMonth(ctx.reference), readDay(ctx.reference)),\n },\n {\n pattern: /^ma[ñn]ana$/i,\n resolve: (_m, ctx) => addDays(ctx.temporal, ctx.reference, 1),\n },\n {\n pattern: /^ayer$/i,\n resolve: (_m, ctx) => addDays(ctx.temporal, ctx.reference, -1),\n },\n // weekday references. Spanish has three common shapes, all meaning\n // the same thing per rel word:\n // \"el próximo lunes\" / \"próximo lunes\" → next\n // \"el lunes próximo\" → next (suffix variant)\n // \"el lunes pasado\" / \"lunes pasado\" → last\n // \"este lunes\" → this\n // Capture the rel word from whichever shape matched, then resolve\n // the same way English does.\n {\n pattern: new RegExp(\n `^(?:el\\\\s+)?(?:(pr[oó]ximo|pasado)\\\\s+(${nameAlternation(SPANISH_WEEKDAYS)})|(${nameAlternation(SPANISH_WEEKDAYS)})\\\\s+(pr[oó]ximo|pasado)|este\\\\s+(${nameAlternation(SPANISH_WEEKDAYS)}))$`,\n 'i',\n ),\n resolve: (m, ctx) => {\n let relWord: string;\n let weekdayName: string;\n if (m[1] && m[2]) {\n // prefix variant: \"próximo lunes\" / \"pasado lunes\"\n relWord = m[1]!;\n weekdayName = m[2]!;\n } else if (m[3] && m[4]) {\n // suffix variant: \"lunes próximo\" / \"lunes pasado\"\n weekdayName = m[3]!;\n relWord = m[4]!;\n } else {\n // \"este lunes\"\n relWord = 'este';\n weekdayName = m[5]!;\n }\n const rel = normalizeForMatch(relWord) === 'proximo' ? 'next' : relWord.toLowerCase() === 'este' ? 'this' : 'last';\n const targetDow = weekdayIndexFromName(weekdayName, SPANISH_WEEKDAYS);\n const refDow = extractDayOfWeek(ctx.reference);\n return addDays(ctx.temporal, ctx.reference, weekdayOffset(rel, refDow, targetDow));\n },\n },\n // unit offsets. Spanish uses distinct markers:\n // \"en 3 días\" / \"dentro de 3 días\" → future\n // \"hace 2 semanas\" → past\n // Both shapes lead with the marker, unlike English where one\n // shape leads and the other trails.\n {\n pattern: new RegExp(\n `^(?:(en|dentro\\\\s+de)\\\\s+(\\\\d+)\\\\s+(d[ií]a|semana|mes|a[ñn]o)s?|(\\\\d+)\\\\s+(d[ií]a|semana|mes|a[ñn]o)s?\\\\s+(hace))$`,\n 'i',\n ),\n resolve: (m, ctx) => {\n let count: string;\n let unitWord: string;\n let sign: number;\n if (m[1] && m[2] && m[3]) {\n // future: \"en 3 días\" / \"dentro de 3 días\"\n count = m[2]!;\n unitWord = m[3]!;\n sign = 1;\n } else {\n // past: \"2 semanas hace\" — but the more natural Spanish is\n // \"hace 2 semanas\" (marker first). The regex above only\n // matches \"N units hace\"; that's a less common but\n // grammatical alternative. The primary past form \"hace N\n // unidades\" is matched by the next matcher.\n count = m[4]!;\n unitWord = m[5]!;\n sign = -1;\n }\n const unit = unitWordToEnglish(unitWord);\n return addUnits(ctx.temporal, ctx.reference, sign * Number(count), unit);\n },\n },\n // \"hace 2 semanas\" — the primary past-offset shape. Matcher kept\n // separate from the future \"en/dentro de\" matcher above because\n // Spanish word order differs between the two (marker-first for\n // past, marker-first for future too, but with different markers).\n {\n pattern: new RegExp(`^hace\\\\s+(\\\\d+)\\\\s+(d[ií]a|semana|mes|a[ñn]o)s?$`, 'i'),\n resolve: (m, ctx) => {\n const count = Number(m[1]!);\n const unit = unitWordToEnglish(m[2]!);\n return addUnits(ctx.temporal, ctx.reference, -count, unit);\n },\n },\n // bare \"N <unit>\" without \"en\" / \"hace\" — throw, since direction\n // is ambiguous. Matched AFTER the directional shapes so the\n // directional ones win when their marker is present.\n {\n pattern: new RegExp(`^(\\\\d+)\\\\s+(d[ií]a|semana|mes|a[ñn]o)s?$`, 'i'),\n resolve: (m, _ctx) => {\n throw new Error(\n `temporal-fmt: parseRelative no puede decidir si \"${m[0]}\" es pasado o futuro — ` +\n `usa \"en ${m[1]} ${m[2]}s\" o \"hace ${m[1]} ${m[2]}s\".`\n );\n },\n },\n // month-day: \"5 de marzo\" (day first), \"5 de marzo de 2026\" (year\n // ignored if present). Day is 1-2 digits, with optional trailing\n // \".\" (rare in Spanish but tolerated).\n {\n pattern: new RegExp(\n `^(\\\\d{1,2})\\\\.?\\\\s+de\\\\s+(${nameAlternation([...SPANISH_MONTHS, ...SPANISH_MONTH_SHORT])})(?:\\\\s+de\\\\s+(\\\\d{4}))?$`,\n 'i',\n ),\n resolve: (m, ctx) => {\n const day = Number(m[1]!);\n const month = monthIndexFromName(m[2]!, SPANISH_MONTHS, SPANISH_MONTH_SHORT);\n return resolveToNextOccurrence(ctx.temporal, ctx.reference, month, day);\n },\n },\n ],\n};\n\n// French grammar. Distinct from English/Spanish:\n// - \"il y a 2 semaines\" (past marker is a 3-word phrase, not a single word).\n// - \"mardi prochain\" — relative word is a SUFFIX on the weekday,\n// opposite of English \"next Tuesday\".\n// - \"5 mars\" — day-first, no \"de\" between day and month (unlike\n// Spanish's \"5 de marzo\").\nconst FRENCH_WEEKDAYS = ['lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi', 'dimanche'];\nconst FRENCH_MONTHS = ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'];\nconst FRENCH_MONTH_SHORT = ['janv.', 'févr.', 'mars', 'avr.', 'mai', 'juin', 'juil.', 'août', 'sept.', 'oct.', 'nov.', 'déc.'];\n\nconst FRENCH_GRAMMAR: RelativeDateGrammar = {\n supportedHint: 'Phrases prises en charge : références de jour de la semaine (\"lundi prochain\", \"mardi dernier\", \"ce mercredi\"), décalages de jour (\"aujourd\\'hui\"/\"demain\"/\"hier\"), décalages d\\'unité (\"dans 3 jours\", \"il y a 2 semaines\"), et mois-jour (\"5 mars\").',\n matchers: [\n {\n pattern: /^aujourd'hui$/i,\n resolve: (_m, ctx) => buildPlainDate(ctx.temporal, readYear(ctx.reference), readMonth(ctx.reference), readDay(ctx.reference)),\n },\n {\n pattern: /^demain$/i,\n resolve: (_m, ctx) => addDays(ctx.temporal, ctx.reference, 1),\n },\n {\n pattern: /^hier$/i,\n resolve: (_m, ctx) => addDays(ctx.temporal, ctx.reference, -1),\n },\n // weekday references: \"lundi prochain\" (next), \"lundi dernier\"\n // (last), \"ce lundi\" (this). The relative word follows the\n // weekday for next/last, precedes it for this.\n {\n pattern: new RegExp(\n `^(?:(${nameAlternation(FRENCH_WEEKDAYS)})\\\\s+(prochain|dernier)|ce\\\\s+(${nameAlternation(FRENCH_WEEKDAYS)}))$`,\n 'i',\n ),\n resolve: (m, ctx) => {\n let rel: 'next' | 'last' | 'this';\n let weekdayName: string;\n if (m[1] && m[2]) {\n weekdayName = m[1]!;\n rel = m[2]!.toLowerCase() === 'prochain' ? 'next' : 'last';\n } else {\n rel = 'this';\n weekdayName = m[3]!;\n }\n const targetDow = weekdayIndexFromName(weekdayName, FRENCH_WEEKDAYS);\n const refDow = extractDayOfWeek(ctx.reference);\n return addDays(ctx.temporal, ctx.reference, weekdayOffset(rel, refDow, targetDow));\n },\n },\n // past: \"il y a 2 semaines\" — multi-word marker.\n {\n pattern: new RegExp(`^il\\\\s+y\\\\s+a\\\\s+(\\\\d+)\\\\s+(jour|semaine|mois|an|ann[eée]e)s?$`, 'i'),\n resolve: (m, ctx) => {\n const count = Number(m[1]!);\n const unit = unitWordToEnglish(m[2]!);\n return addUnits(ctx.temporal, ctx.reference, -count, unit);\n },\n },\n // future: \"dans 3 jours\"\n {\n pattern: new RegExp(`^dans\\\\s+(\\\\d+)\\\\s+(jour|semaine|mois|an|ann[eée]e)s?$`, 'i'),\n resolve: (m, ctx) => {\n const count = Number(m[1]!);\n const unit = unitWordToEnglish(m[2]!);\n return addUnits(ctx.temporal, ctx.reference, count, unit);\n },\n },\n // bare \"N <unit>\" without marker — throw.\n {\n pattern: new RegExp(`^(\\\\d+)\\\\s+(jour|semaine|mois|an|ann[eée]e)s?$`, 'i'),\n resolve: (m, _ctx) => {\n throw new Error(\n `temporal-fmt: parseRelative ne peut pas déterminer si \"${m[0]}\" est passé ou futur — ` +\n `utilisez \"dans ${m[1]} ${m[2]}s\" ou \"il y a ${m[1]} ${m[2]}s\".`\n );\n },\n },\n // month-day: \"5 mars\" (day first, no separator word). Year ignored.\n {\n pattern: new RegExp(\n `^(\\\\d{1,2})\\\\s+(${nameAlternation([...FRENCH_MONTHS, ...FRENCH_MONTH_SHORT])})(?:\\\\s+(\\\\d{4}))?$`,\n 'i',\n ),\n resolve: (m, ctx) => {\n const day = Number(m[1]!);\n const month = monthIndexFromName(m[2]!, FRENCH_MONTHS, FRENCH_MONTH_SHORT);\n return resolveToNextOccurrence(ctx.temporal, ctx.reference, month, day);\n },\n },\n ],\n};\n\n// German grammar. Distinct from the others:\n// - Unit words pluralize with -n in the dative after \"in\"/\"vor\":\n// \"in 3 Tagen\" (vs nominative \"3 Tage\"). The regex accepts both\n// since callers may not always get the case right, and accepting\n// both doesn't introduce ambiguity.\n// - \"nächsten Dienstag\" — relative word precedes weekday as a\n// declined adjective, with the weekday capitalized as a noun.\n// - \"5. März\" — day-first with a period after the day number,\n// matching German date convention.\nconst GERMAN_WEEKDAYS = ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag'];\nconst GERMAN_MONTHS = ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'];\nconst GERMAN_MONTH_SHORT = ['Jan', 'Feb', 'Mär', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'];\n\nconst GERMAN_GRAMMAR: RelativeDateGrammar = {\n supportedHint: 'Unterstützte Phrasen: Wochentag-Bezüge (\"nächsten Dienstag\", \"letzten Freitag\", \"diesen Montag\"), Tages-Offsets (\"heute\"/\"morgen\"/\"gestern\"), Einheiten-Offsets (\"in 3 Tagen\", \"vor 2 Wochen\"), und Monat-Tag (\"5. März\").',\n matchers: [\n {\n pattern: /^heute$/i,\n resolve: (_m, ctx) => buildPlainDate(ctx.temporal, readYear(ctx.reference), readMonth(ctx.reference), readDay(ctx.reference)),\n },\n {\n pattern: /^morgen$/i,\n resolve: (_m, ctx) => addDays(ctx.temporal, ctx.reference, 1),\n },\n {\n pattern: /^gestern$/i,\n resolve: (_m, ctx) => addDays(ctx.temporal, ctx.reference, -1),\n },\n // weekday references: \"nächsten Dienstag\" (next), \"letzten\n // Dienstag\" (last), \"diesen Dienstag\" (this). Adjective precedes\n // the weekday; case varies (nächsten/letzten/diesen all take the\n // weak-declension -en/-en/-en ending when no article, which is\n // convenient — one regex alternation covers all three.\n {\n pattern: new RegExp(`^(n(?:ae|a|ä)chsten|letzten|diesen)\\\\s+(${nameAlternation(GERMAN_WEEKDAYS)})$`, 'i'),\n resolve: (m, ctx) => {\n const adj = normalizeForMatch(m[1]!);\n const rel: 'next' | 'last' | 'this' = (adj === 'nachsten' || adj === 'naechsten') ? 'next' : adj === 'diesen' ? 'this' : 'last';\n const targetDow = weekdayIndexFromName(m[2]!, GERMAN_WEEKDAYS);\n const refDow = extractDayOfWeek(ctx.reference);\n return addDays(ctx.temporal, ctx.reference, weekdayOffset(rel, refDow, targetDow));\n },\n },\n // past: \"vor 2 Wochen\"\n {\n pattern: new RegExp(`^vor\\\\s+(\\\\d+)\\\\s+(Tag(?:e|n|en)?|Woche(?:n)?|Monat(?:e|n|en)?|Jahr(?:e|n|en)?)$`, 'i'),\n resolve: (m, ctx) => {\n const count = Number(m[1]!);\n const unit = unitWordToEnglish(m[2]!);\n return addUnits(ctx.temporal, ctx.reference, -count, unit);\n },\n },\n // future: \"in 3 Tagen\"\n {\n pattern: new RegExp(`^in\\\\s+(\\\\d+)\\\\s+(Tag(?:e|n|en)?|Woche(?:n)?|Monat(?:e|n|en)?|Jahr(?:e|n|en)?)$`, 'i'),\n resolve: (m, ctx) => {\n const count = Number(m[1]!);\n const unit = unitWordToEnglish(m[2]!);\n return addUnits(ctx.temporal, ctx.reference, count, unit);\n },\n },\n // bare \"N <unit>\" without \"in\" or \"vor\" — throw.\n {\n pattern: new RegExp(`^(\\\\d+)\\\\s+(Tag(?:e|n|en)?|Woche(?:n)?|Monat(?:e|n|en)?|Jahr(?:e|n|en)?)$`, 'i'),\n resolve: (m, _ctx) => {\n throw new Error(\n `temporal-fmt: parseRelative kann nicht erkennen, ob \"${m[0]}\" Vergangenheit oder Zukunft ist — ` +\n `verwende \"in ${m[1]} ${m[2]}\" oder \"vor ${m[1]} ${m[2]}\".`\n );\n },\n },\n // month-day: \"5. März\" (day-first with period). Year ignored.\n {\n pattern: new RegExp(\n `^(\\\\d{1,2})\\\\.?\\\\s+(${nameAlternation([...GERMAN_MONTHS, ...GERMAN_MONTH_SHORT, 'Maerz', 'Maer'])})(?:\\\\s+(\\\\d{4}))?$`,\n 'i',\n ),\n resolve: (m, ctx) => {\n const day = Number(m[1]!);\n const month = monthIndexFromName(m[2]!, GERMAN_MONTHS, GERMAN_MONTH_SHORT);\n return resolveToNextOccurrence(ctx.temporal, ctx.reference, month, day);\n },\n },\n ],\n};\n\nconst GRAMMARS: Record<string, RelativeDateGrammar> = {\n en: ENGLISH_GRAMMAR,\n es: SPANISH_GRAMMAR,\n fr: FRENCH_GRAMMAR,\n de: GERMAN_GRAMMAR,\n};\n\n// Pick a grammar for a locale. Falls back to English for languages we\n// don't have a grammar for (Italian, Portuguese, etc.) rather than\n// throwing — best-effort, matches how formatDistance treats unknown\n// locales (Intl.RelativeTimeFormat accepts them; here we fall back to\n// English so the call still succeeds with reasonable output).\nfunction grammarForLocale(locale: string | undefined): RelativeDateGrammar {\n if (!locale) return ENGLISH_GRAMMAR;\n try {\n // Intl.Locale requires BCP-47 hyphens — same normalization as the\n // other locale-handling code in this library.\n const tag = new Intl.Locale(locale.replace(/_/g, '-'));\n const lang = tag.language.toLowerCase();\n return GRAMMARS[lang] ?? ENGLISH_GRAMMAR;\n } catch {\n // Malformed locale tag — fall back to English. The actual Intl\n // call downstream will throw if the tag is genuinely unusable,\n // which is a better surface for that error than here.\n return ENGLISH_GRAMMAR;\n }\n}\n\n// Language subtag of a locale option, for dispatching to grammars\n// registered via registerRelativeGrammar(). Mirrors grammarForLocale's\n// normalization and fallback.\nfunction languageOf(locale: string | undefined): string {\n if (!locale) return 'en';\n try {\n return new Intl.Locale(locale.replace(/_/g, '-')).language.toLowerCase();\n } catch {\n return 'en';\n }\n}\n\n// Map a per-language unit word back to the English unit name the\n// shared addUnits() helper expects. Each language contributes its own\n// regex alternation of unit words; this function normalizes the\n// captured word back to a unit enum value.\nfunction unitWordToEnglish(word: string): 'day' | 'week' | 'month' | 'year' {\n const w = normalizeForMatch(word);\n // English\n /* c8 ignore next */\n if (w === 'day' || w === 'week' || w === 'month' || w === 'year') return w;\n // Spanish (accent-stripped)\n if (w === 'dia') return 'day';\n if (w === 'semana') return 'week';\n if (w === 'mes') return 'month';\n if (w === 'ano' || w === 'año') return 'year';\n // French\n if (w === 'jour') return 'day';\n if (w === 'semaine') return 'week';\n if (w === 'mois') return 'month';\n if (w === 'an' || w === 'annee') return 'year';\n // German\n if (w === 'tag' || w === 'tagen') return 'day';\n if (w === 'woche' || w === 'wochen') return 'week';\n if (w === 'monat' || w === 'monaten') return 'month';\n /* c8 ignore next */\n if (w === 'jahr' || w === 'jahren') return 'year';\n /* c8 ignore start @preserve -- unreachable: every caller passes a word\n * captured by a regex alternation built from exactly these unit-word\n * forms (day/week/month/year across en/es/fr/de), so the branches\n * above already cover every string that can reach this function.\n * Kept as a tripwire for the type checker in case a grammar adds a\n * unit word here without a matching regex update. */\n throw new Error(`temporal-fmt: parseRelative internal error — unrecognized unit word \"${word}\".`);\n /* c8 ignore stop @preserve */\n /* c8 ignore next -- defensive block is unreachable by construction. */\n}\n\n// Reference: kept exported for the unit tests that need it. The other\n// helpers above are not exported since tests only need to drive\n// parseRelative() through the public API + this one constant for the\n// Tuesday-on-Tuesday fixture.\nexport const WEEKDAY_NAMES = ENGLISH_WEEKDAYS;\nexport const MONTH_NAMES = ENGLISH_MONTHS;\n// Exported for the localeVocab-style stub-test pattern in case a future\n// test wants to verify a grammar's name list against Intl's actual\n// output for that locale — same pattern localeVocab.test.js uses to\n// catch a mismatch between what format() produces and what parse()\n// expects.\nexport const SPANISH_MONTH_NAMES = SPANISH_MONTHS;\nexport const FRENCH_MONTH_NAMES = FRENCH_MONTHS;\nexport const GERMAN_MONTH_NAMES = GERMAN_MONTHS;\nexport const SPANISH_WEEKDAY_NAMES = SPANISH_WEEKDAYS;\nexport const FRENCH_WEEKDAY_NAMES = FRENCH_WEEKDAYS;\nexport const GERMAN_WEEKDAY_NAMES = GERMAN_WEEKDAYS;\nvoid WEEKDAY_NAMES;\nvoid MONTH_NAMES;\n\nexport interface ParseRelativeOptions extends FormatOptions {\n /**\n * Opt-in typo tolerance. When the input doesn't match any phrase\n * exactly, retry after correcting individual words (weekday names,\n * month names, and marker words like \"next\"/\"ago\"/\"tomorrow\") that\n * are within a small edit distance of a known word — e.g.\n * \"tommorow\" → \"tomorrow\", \"next tuesady\" → \"next tuesday\". Numbers\n * are never touched.\n *\n * Off by default, matching this library's throw-rather-than-guess\n * philosophy elsewhere (parse()'s `lenient` option is the same shape\n * of opt-in). English only for this option currently — combining\n * `fuzzy: true` with a non-English `locale` throws rather than\n * silently skipping the fuzzy pass.\n *\n * If no correction produces a recognized phrase, throws the same\n * \"doesn't recognize\" error the exact pass would have thrown.\n */\n fuzzy?: boolean;\n}\n\n/**\n * Resolve common relative-date phrases against a reference date,\n * returning a Temporal.PlainDate. Supports English by default, plus\n * Spanish (es), French (fr), and German (de) via the `locale` option.\n *\n * Supported phrase classes (with examples per language):\n *\n * - weekday refs: \"next Tuesday\" / \"el próximo martes\" / \"mardi prochain\" / \"nächsten Dienstag\"\n * - day offsets: \"today\" / \"hoy\" / \"aujourd'hui\" / \"heute\" (and tomorrow/yesterday equivalents)\n * - unit offsets: \"in 3 days\" / \"en 3 días\" / \"dans 3 jours\" / \"in 3 Tagen\"\n * - month-day without year: \"March 5th\" / \"5 de marzo\" / \"5 mars\" / \"5. März\"\n *\n * Ambiguous-case handling is consistent across all four languages:\n * \"next X\" said on X (today is the named weekday) means 7 days from\n * now, not today. \"last X\" said on X means 7 days ago. See README\n * \"parseRelative\" for the documented behavior of each ambiguous case.\n *\n * Throws a descriptive error for any phrase it doesn't recognize in\n * the target language, rather than guessing. A bare \"5 days\" without\n * \"in\" or \"ago\" (or the per-language equivalent) throws with a message\n * pointing at the disambiguation options.\n *\n * Returns a Temporal.PlainDate for every supported phrase. Time-of-day\n * extensions like \"next Tuesday at 3pm\" aren't supported in this pass.\n */\nexport function parseRelative(\n input: string,\n referenceDate: unknown,\n options: ParseRelativeOptions = {},\n): unknown {\n const reference = referenceDate as TemporalFieldBag;\n const temporal = getTemporal();\n\n // Trim, collapse internal whitespace, strip diacritics, and lowercase.\n // Whitespace normalization is shared with the pre-change behavior;\n // diacritic stripping pairs with nameAlternation()'s normalization so\n // \"mi[eé]rcoles\" and \"miercoles\" both match the same pattern.\n // Lowercasing matches the case-insensitive regex flag explicitly so\n // the user's input never gets case-swapped on its way through the\n // matcher (the regexes are 'i'-flagged, but normalizing here keeps\n // the original-trimmed-string echo in error messages predictable).\n const trimmed = (input ?? '').trim().replace(/\\s+/g, ' ');\n if (trimmed.length === 0) {\n throw new Error('temporal-fmt: parseRelative got an empty input string.');\n }\n if (trimmed.length > MAX_RELATIVE_INPUT_LENGTH) {\n throw new RangeError(\n `temporal-fmt: parseRelative input is too large (maximum ${MAX_RELATIVE_INPUT_LENGTH} characters).`,\n );\n }\n // For error messages, keep the user's original spelling (with accents)\n // so the echo in the \"doesn't recognize\" error matches what they\n // typed. The matching itself uses the diacritic-stripped form so\n // \"mi[eé]rcoles\" / \"miercoles\" / \"MI[ÉE]RCOLES\" all match the same\n // pattern without forcing the user to remember the accent.\n const normalized = normalizeForMatch(trimmed);\n\n const grammar = grammarForLocale(options.locale);\n const ctx: ResolveContext = { temporal, reference };\n\n // Registered grammars (registerRelativeGrammar) take precedence over\n // the built-in ones for their language — that's the documented\n // contract in relativeGrammar.ts (\"try registered grammars before\n // falling back to the built-in ones\"). This wiring was missing\n // entirely before: registered grammars were stored and listed but\n // never consulted, so the extension point silently did nothing.\n // Returns null quickly when nothing is registered for the language.\n const registered = tryRegisteredGrammar(languageOf(options.locale), trimmed, {\n year: reference.year as number,\n month: reference.month as number,\n day: reference.day as number,\n dayOfWeek: reference.dayOfWeek as number,\n });\n if (registered !== null) {\n return registered;\n }\n\n const tryMatch = (text: string): unknown | typeof NO_MATCH => {\n for (const matcher of grammar.matchers) {\n const match = text.match(matcher.pattern);\n if (match) {\n return matcher.resolve(match, ctx);\n }\n }\n return NO_MATCH;\n };\n\n const exactResult = tryMatch(normalized);\n if (exactResult !== NO_MATCH) {\n return exactResult;\n }\n\n if (options.fuzzy) {\n // Fuzzy mode is English-only for this pass — see the vocabulary\n // comment above fuzzyCorrectEnglish for why the other three\n // grammars aren't covered. Fail loudly rather than silently\n // skipping the fuzzy attempt, so a caller relying on fuzzy mode\n // for, say, French input doesn't get a confusing \"doesn't\n // recognize\" error with no indication fuzzy matching never ran.\n if (grammar !== ENGLISH_GRAMMAR) {\n throw new Error(\n `temporal-fmt: parseRelative's { fuzzy: true } option currently only supports English. ` +\n `Pass no locale (or locale: 'en'), or omit { fuzzy: true } for this locale.`\n );\n }\n const corrected = fuzzyCorrectEnglish(normalized);\n if (corrected !== undefined) {\n const fuzzyResult = tryMatch(corrected);\n if (fuzzyResult !== NO_MATCH) {\n return fuzzyResult;\n }\n }\n }\n\n throw new Error(\n `temporal-fmt: parseRelative doesn't recognize \"${trimmed}\". ` +\n grammar.supportedHint\n );\n}\n\n// Sentinel distinguishing \"no matcher matched\" from a legitimate\n// resolve() return value of `undefined`/`null` (matchers can throw\n// their own errors, e.g. the ambiguous-direction case, but none\n// currently return a nullish PlainDate — this sentinel just makes the\n// \"no match\" case unambiguous regardless).\nconst NO_MATCH = Symbol('temporal-fmt: parseRelative no match');\n\n// DEFAULT_LOCALE is imported for the option's default-value documentation\n// above (no locale → English). The symbol itself isn't read at runtime\n// here, but the import keeps the dependency edge explicit so future\n// changes to the default-locale constant propagate here too.\nvoid DEFAULT_LOCALE;","// Per-token metadata: the structured descriptor this module\n// asks for (meaning, format-capable?, parse-capable?, locale-sensitive?,\n// calendar-sensitive?, timezone-sensitive?, supported Temporal types,\n// round-trip-safe?). One table, kept in sync with TOKENS in tokens.ts\n// by tests (see test/tokenMetadata.test.js — every entry in TOKENS has\n// a metadata entry, and vice versa).\n//\n// This is the single source of truth that analyzeFormat() (section E)\n// and the ESLint plugin / codemod consume — never read the\n// TOKENS array directly for metadata; use TOKEN_METADATA here, or the\n// tokenInfo() / listTokens() wrappers in analyze.ts.\n\nimport type { TemporalLike } from './tokens.js';\n\nexport type TemporalType =\n | 'Instant'\n | 'PlainDate'\n | 'PlainTime'\n | 'PlainDateTime'\n | 'ZonedDateTime'\n | 'PlainYearMonth'\n | 'PlainMonthDay';\n\nexport interface TokenMetadata {\n // Short human-readable description of what the token represents.\n meaning: string;\n // True if format() accepts this token. Every token in TOKENS is\n // format-capable by construction; this flag exists so the table is\n // self-describing for callers (the codemod) that work with token\n // families including format-only tokens from other libraries.\n formatCapable: boolean;\n // True if parse() accepts this token. False for `do`, `ww`, `RRRR`\n // — see FORMAT_ONLY_TOKENS in pattern.ts.\n parseCapable: boolean;\n // True if the output depends on locale (resolves via Intl or\n // custom vocab). MMMM/MMM/EEEE/EEE/a are true; everything else is\n // numeric ASCII and locale-independent.\n localeSensitive: boolean;\n // True if the output depends on the calendar (gregory, hebrew,\n // etc.). Locale-aware tokens inherit calendar sensitivity from\n // the Intl path (a hebrew PlainDate's month name depends on the\n // hebrew calendar). Year/month/day numeric tokens are calendar-\n // sensitive in principle (a Hebrew year/month renders differently\n // than a Gregorian one) but stay ISO-numeric on the format side\n // because tokens.ts reads straight off TemporalLike fields, which\n // are already calendar-specific by the time format() sees them.\n calendarSensitive: boolean;\n // True if the token requires a timeZoneId or offset field — i.e.\n // only ZonedDateTime supports it. zzz and the six offset tokens\n // (X/XX/XXX/x/xx/xxx) are timezone-sensitive.\n timezoneSensitive: boolean;\n // Which Temporal types can supply the field this token needs.\n // PlainTime can't supply year; PlainDate can't supply hour; only\n // ZonedDateTime carries timeZoneId/offset.\n supportedTypes: TemporalType[];\n // True if format(x, fmt) → parse(fmt, output) round-trips back to\n // a value equal to x. False when the format is fundamentally lossy:\n // `do` (ordinal suffix isn't structurally parseable), `ww`/`RRRR`\n // (week + weekday alone can't reconstruct a date without an extra\n // disambiguator), `yy` (two-digit year loses century — strptime\n // heuristic resolves it, but the heuristic isn't symmetric with\n // how `yy` formats BCE years, so round-trip only works for years\n // where 00-68/69-99 lands back on the same century).\n roundTripSafe: boolean;\n}\n\n// Helper: which Temporal types carry each field. Centralized here so\n// the supportedTypes arrays below stay short and the table is easy to\n// audit. Mirrors the field checks in tokens.ts (handler third tuple\n// element).\nconst TYPES_WITH: Record<string, TemporalType[]> = {\n year: ['PlainDate', 'PlainDateTime', 'ZonedDateTime', 'PlainYearMonth'],\n month: ['PlainDate', 'PlainDateTime', 'ZonedDateTime', 'PlainYearMonth', 'PlainMonthDay'],\n day: ['PlainDate', 'PlainDateTime', 'ZonedDateTime', 'PlainMonthDay'],\n hour: ['PlainTime', 'PlainDateTime', 'ZonedDateTime', 'Instant'],\n minute: ['PlainTime', 'PlainDateTime', 'ZonedDateTime', 'Instant'],\n second: ['PlainTime', 'PlainDateTime', 'ZonedDateTime', 'Instant'],\n millisecond: ['PlainTime', 'PlainDateTime', 'ZonedDateTime', 'Instant'],\n dayOfWeek: ['PlainDate', 'PlainDateTime', 'ZonedDateTime'],\n timeZoneId: ['ZonedDateTime'],\n offset: ['ZonedDateTime'],\n};\n\n// Every token in TOKENS gets an entry here. Adding a token to TOKENS\n// without adding one here makes test/tokenMetadata.test.js fail.\nexport const TOKEN_METADATA: Record<string, TokenMetadata> = {\n yyyy: {\n meaning: 'Four-digit year (preserves sign for BCE; no truncation).',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: true, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.year, roundTripSafe: true,\n },\n yy: {\n meaning: 'Two-digit year (year % 100). Throws on negative years.',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: true, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.year, roundTripSafe: false,\n },\n y: {\n meaning: 'Unpadded year, any width (preserves sign for BCE; no truncation, no minimum digits). Cannot sit directly next to another digit-reading token or a literal starting with a digit — there would be no way to tell where it ends.',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: true, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.year, roundTripSafe: true,\n },\n MMMM: {\n meaning: 'Long month name (locale-aware, e.g. \"January\", \"janvier\").',\n formatCapable: true, parseCapable: true, localeSensitive: true, calendarSensitive: true, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.month, roundTripSafe: true,\n },\n MMM: {\n meaning: 'Short month name (locale-aware, e.g. \"Jan\", \"janv.\").',\n formatCapable: true, parseCapable: true, localeSensitive: true, calendarSensitive: true, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.month, roundTripSafe: true,\n },\n MM: {\n meaning: 'Two-digit month (01-12, zero-padded).',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: true, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.month, roundTripSafe: true,\n },\n M: {\n meaning: 'One- or two-digit month (1-12, no padding).',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: true, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.month, roundTripSafe: true,\n },\n dd: {\n meaning: 'Two-digit day-of-month (01-31, zero-padded).',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: true, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.day, roundTripSafe: true,\n },\n d: {\n meaning: 'One- or two-digit day-of-month (1-31, no padding).',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: true, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.day, roundTripSafe: true,\n },\n EEEE: {\n meaning: 'Long weekday name (locale-aware, e.g. \"Monday\", \"lundi\"). Parse cross-checks against the parsed date.',\n formatCapable: true, parseCapable: true, localeSensitive: true, calendarSensitive: true, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.dayOfWeek, roundTripSafe: true,\n },\n EEE: {\n meaning: 'Short weekday name (locale-aware, e.g. \"Mon\", \"lun.\"). Parse cross-checks against the parsed date.',\n formatCapable: true, parseCapable: true, localeSensitive: true, calendarSensitive: true, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.dayOfWeek, roundTripSafe: true,\n },\n HH: {\n meaning: 'Two-digit hour, 24-hour clock (00-23, zero-padded).',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: false, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.hour, roundTripSafe: true,\n },\n H: {\n meaning: 'One- or two-digit hour, 24-hour clock (0-23, no padding).',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: false, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.hour, roundTripSafe: true,\n },\n hh: {\n meaning: 'Two-digit hour, 12-hour clock (01-12, zero-padded). Requires `a` token on parse.',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: false, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.hour, roundTripSafe: true,\n },\n h: {\n meaning: 'One- or two-digit hour, 12-hour clock (1-12, no padding). Requires `a` token on parse.',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: false, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.hour, roundTripSafe: true,\n },\n mm: {\n meaning: 'Two-digit minute (00-59, zero-padded).',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: false, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.minute, roundTripSafe: true,\n },\n m: {\n meaning: 'One- or two-digit minute (0-59, no padding).',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: false, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.minute, roundTripSafe: true,\n },\n ss: {\n meaning: 'Two-digit second (00-59, zero-padded).',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: false, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.second, roundTripSafe: true,\n },\n s: {\n meaning: 'One- or two-digit second (0-59, no padding).',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: false, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.second, roundTripSafe: true,\n },\n S: {\n meaning: 'Fractional second, 1 digit (tenths of a second).',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: false, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.millisecond, roundTripSafe: true,\n },\n SS: {\n meaning: 'Fractional second, 2 digits (hundredths of a second).',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: false, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.millisecond, roundTripSafe: true,\n },\n SSS: {\n meaning: 'Fractional second, 3 digits (milliseconds).',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: false, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.millisecond, roundTripSafe: true,\n },\n SSSS: {\n meaning: 'Fractional second, 4 digits (tens of microseconds).',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: false, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.millisecond, roundTripSafe: true,\n },\n SSSSS: {\n meaning: 'Fractional second, 5 digits (hundred-thousandths of a second).',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: false, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.millisecond, roundTripSafe: true,\n },\n SSSSSS: {\n meaning: 'Fractional second, 6 digits (microseconds).',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: false, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.millisecond, roundTripSafe: true,\n },\n SSSSSSS: {\n meaning: 'Fractional second, 7 digits (tens of nanoseconds).',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: false, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.millisecond, roundTripSafe: true,\n },\n SSSSSSSS: {\n meaning: 'Fractional second, 8 digits (hundred-millionths of a second).',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: false, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.millisecond, roundTripSafe: true,\n },\n SSSSSSSSS: {\n meaning: 'Fractional second, 9 digits (nanoseconds).',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: false, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.millisecond, roundTripSafe: true,\n },\n a: {\n meaning: 'Day period (locale-aware: \"AM\"/\"PM\", \"午前\"/\"午後\", etc.). Required alongside 12-hour tokens on parse.',\n formatCapable: true, parseCapable: true, localeSensitive: true, calendarSensitive: false, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.hour, roundTripSafe: true,\n },\n zzz: {\n meaning: 'IANA time zone id (e.g. \"America/New_York\") or fixed offset (\"+05:30\"). Requires full date+time on parse.',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: false, timezoneSensitive: true,\n supportedTypes: TYPES_WITH.timeZoneId, roundTripSafe: true,\n },\n X: {\n meaning: 'Numeric UTC offset, short (Z for UTC, ±HH[MM] otherwise). Minutes omitted when zero.',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: false, timezoneSensitive: true,\n supportedTypes: TYPES_WITH.offset, roundTripSafe: true,\n },\n XX: {\n meaning: 'Numeric UTC offset, no colon (Z for UTC, ±HHMM otherwise).',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: false, timezoneSensitive: true,\n supportedTypes: TYPES_WITH.offset, roundTripSafe: true,\n },\n XXX: {\n meaning: 'Numeric UTC offset, with colon (Z for UTC, ±HH:MM otherwise).',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: false, timezoneSensitive: true,\n supportedTypes: TYPES_WITH.offset, roundTripSafe: true,\n },\n x: {\n meaning: 'Numeric UTC offset, short, never Z (always ±HH[MM]). Lowercase variant of X.',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: false, timezoneSensitive: true,\n supportedTypes: TYPES_WITH.offset, roundTripSafe: true,\n },\n xx: {\n meaning: 'Numeric UTC offset, no colon, never Z (always ±HHMM). Lowercase variant of XX.',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: false, timezoneSensitive: true,\n supportedTypes: TYPES_WITH.offset, roundTripSafe: true,\n },\n xxx: {\n meaning: 'Numeric UTC offset, with colon, never Z (always ±HH:MM). Lowercase variant of XXX.',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: false, timezoneSensitive: true,\n supportedTypes: TYPES_WITH.offset, roundTripSafe: true,\n },\n do: {\n meaning: 'Ordinal day-of-month with English suffix (\"1st\", \"2nd\", \"3rd\", \"4th\", ... 21st, 22nd, ...). Format-only — not parseable.',\n formatCapable: true, parseCapable: false, localeSensitive: false, calendarSensitive: true, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.day, roundTripSafe: false,\n },\n Q: {\n meaning: 'Quarter as a digit (1-4). Derived from month.',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: true, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.month, roundTripSafe: true,\n },\n QQQ: {\n meaning: 'Quarter with \"Q\" prefix (\"Q1\"..\"Q4\"). Derived from month.',\n formatCapable: true, parseCapable: true, localeSensitive: false, calendarSensitive: true, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.month, roundTripSafe: true,\n },\n ww: {\n meaning: 'ISO 8601 week number (01-53). Format-only — week alone can\\'t reconstruct a date.',\n formatCapable: true, parseCapable: false, localeSensitive: false, calendarSensitive: true, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.dayOfWeek, roundTripSafe: false,\n },\n RRRR: {\n meaning: 'ISO 8601 week-numbering year (4-digit, may differ from calendar year at year boundaries). Format-only.',\n formatCapable: true, parseCapable: false, localeSensitive: false, calendarSensitive: true, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.dayOfWeek, roundTripSafe: false,\n },\n D: {\n meaning: 'Day of year, unpadded (1-366). Format-only — parsing requires resolving against a year.',\n formatCapable: true, parseCapable: false, localeSensitive: false, calendarSensitive: true, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.day, roundTripSafe: false,\n },\n DD: {\n meaning: 'Day of year, 2-digit minimum (01-366). Format-only.',\n formatCapable: true, parseCapable: false, localeSensitive: false, calendarSensitive: true, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.day, roundTripSafe: false,\n },\n DDD: {\n meaning: 'Day of year, 3-digit zero-padded (001-366). Format-only.',\n formatCapable: true, parseCapable: false, localeSensitive: false, calendarSensitive: true, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.day, roundTripSafe: false,\n },\n LLLL: {\n meaning: 'Stand-alone long month name (nominative case in Slavic locales). Identical to MMMM in most locales.',\n formatCapable: true, parseCapable: false, localeSensitive: true, calendarSensitive: true, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.month, roundTripSafe: true,\n },\n LLL: {\n meaning: 'Stand-alone short month name. Identical to MMM in most locales.',\n formatCapable: true, parseCapable: false, localeSensitive: true, calendarSensitive: true, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.month, roundTripSafe: true,\n },\n cccc: {\n meaning: 'Stand-alone long weekday name. Identical to EEEE in most locales.',\n formatCapable: true, parseCapable: false, localeSensitive: true, calendarSensitive: true, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.dayOfWeek, roundTripSafe: true,\n },\n ccc: {\n meaning: 'Stand-alone short weekday name. Identical to EEE in most locales.',\n formatCapable: true, parseCapable: false, localeSensitive: true, calendarSensitive: true, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.dayOfWeek, roundTripSafe: true,\n },\n GGGG: {\n meaning: 'Long era name (locale-aware, e.g. \"Anno Domini\"/\"Before Christ\"). Format-only.',\n formatCapable: true, parseCapable: false, localeSensitive: true, calendarSensitive: true, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.year, roundTripSafe: false,\n },\n G: {\n meaning: 'Short era name (locale-aware, e.g. \"AD\"/\"BC\"). Format-only.',\n formatCapable: true, parseCapable: false, localeSensitive: true, calendarSensitive: true, timezoneSensitive: false,\n supportedTypes: TYPES_WITH.year, roundTripSafe: false,\n },\n zzzz: {\n meaning: 'Localized long timezone name (e.g. \"Eastern Standard Time\"). Format-only.',\n formatCapable: true, parseCapable: false, localeSensitive: true, calendarSensitive: false, timezoneSensitive: true,\n supportedTypes: TYPES_WITH.timeZoneId, roundTripSafe: false,\n },\n z: {\n meaning: 'Localized short timezone name (e.g. \"EST\"). Format-only.',\n formatCapable: true, parseCapable: false, localeSensitive: true, calendarSensitive: false, timezoneSensitive: true,\n supportedTypes: TYPES_WITH.timeZoneId, roundTripSafe: false,\n },\n\n};\n\nexport const ALL_TOKEN_NAMES: string[] = Object.keys(TOKEN_METADATA);","// Format-string analysis and introspection. Single source of truth for\n// \"what does this format string need / accept / produce\" — consumed by\n// the ESLint plugin and the codemod\n// so they don't each carry their own token table that drifts out of\n// sync with the runtime. Everything here reads from TOKENS in\n// tokens.ts and TOKEN_METADATA in tokenMetadata.ts, so adding a token\n// to those two tables automatically makes it visible to analyze()\n// without touching this file.\n\nimport { TOKENS, type TemporalLike } from './tokens.js';\nimport { TOKEN_METADATA, type TokenMetadata, type TemporalType } from './tokenMetadata.js';\nimport { tokenize, type Piece } from './tokenize.js';\nimport { _handlerFor } from './format.js';\nimport { UNPADDED_NUMERIC_TOKENS, FORMAT_ONLY_TOKENS } from './pattern.js';\nimport { MAX_FORMAT_LENGTH } from './constants.js';\n\n// Re-exported so callers can import everything analyzer-related from a\n// single entry point — analyze.ts is the introspection surface.\nexport type { TokenMetadata, TemporalType } from './tokenMetadata.js';\nexport type { Piece } from './tokenize.js';\n\n// tokenizeFormat is the same tokenize() the runtime uses, exposed\n// under a name that signals \"this is the introspection entry point.\"\n// Same implementation, different name — callers reading analyze.ts\n// see a coherent API surface rather than having to know that the\n// runtime tokenizer is the right thing to call.\nexport function tokenizeFormat(formatStr: string): Piece[] {\n return tokenize(formatStr);\n}\n\n// listTokens: every token the runtime recognizes, with metadata. Used\n// by IDE autocomplete data (section AC) and the codemod's \"can this\n// source-library token be translated?\" lookup (section Z).\nexport function listTokens(): Array<{ name: string; metadata: TokenMetadata }> {\n return TOKENS.map(([name]) => ({ name, metadata: TOKEN_METADATA[name]! }));\n}\n\n// tokenInfo: one token's metadata. Returns undefined for unknown\n// tokens rather than throwing — callers (autocomplete, hover docs)\n// want a sentinel, not an exception, when a user types a partial token.\nexport function tokenInfo(name: string): TokenMetadata | undefined {\n return TOKEN_METADATA[name];\n}\n\nexport interface AnalyzedToken {\n name: string;\n // Position in the format string, 0-indexed. Useful for IDE diagnostics\n // that highlight a specific token.\n position: number;\n metadata: TokenMetadata;\n}\n\nexport interface FormatAnalysis {\n // Every token in the format string, in order, with metadata.\n tokens: AnalyzedToken[];\n // Fields (year/month/day/hour/...) any token in this format string\n // reads off the input. Lets a caller statically check \"does this\n // format string need a field PlainDate doesn't have?\"\n requiredFields: string[];\n // Temporal types that can supply every required field. The intersection\n // across all tokens — a format string with both `yyyy` (needs year)\n // and `HH` (needs hour) is compatible only with types carrying both,\n // i.e. PlainDateTime/ZonedDateTime.\n compatibleTypes: TemporalType[];\n // Can parse() accept this format string? False when any token is\n // format-only (do/ww/RRRR per FORMAT_ONLY_TOKENS in pattern.ts).\n parseable: boolean;\n // Does the format string contain any locale-aware token (MMMM/MMM/\n // EEEE/EEE/a)? True means the output depends on the locale option\n // and a registered custom vocab can override the result.\n localeSensitive: boolean;\n // Does the format string contain any calendar-sensitive token?\n // Almost every date/weekday token is, since its output depends on\n // the object's calendar (a hebrew PlainDate's \"MMMM\" is a hebrew\n // month name). Pure-time tokens (HH/mm/ss) are not.\n calendarSensitive: boolean;\n // Does the format string contain zzz or any offset token? If yes,\n // only ZonedDateTime can supply the field.\n timezoneSensitive: boolean;\n // Does the format string contain a run of 2+ adjacent unpadded\n // numeric tokens with no literal between them (Md, dM, Hms, ...)?\n // Such runs can be ambiguous at parse time — strict mode throws,\n // lenient mode picks one split via the documented heuristic.\n ambiguous: boolean;\n // Does format(x, fmt) → parse(fmt, output) round-trip? False when\n // any token is format-only OR when yy is used (century loss).\n roundTripSafe: boolean;\n // Non-fatal issues found during analysis. Each carries a `code`\n // the IDE plugin / CLI can switch on. Empty for clean format strings.\n warnings: Array<{ code: string; message: string }>;\n}\n\nexport function analyzeFormat(formatStr: string): FormatAnalysis {\n if (formatStr.length > MAX_FORMAT_LENGTH) {\n throw new Error(\n `temporal-fmt: format string exceeds maximum length of ${MAX_FORMAT_LENGTH} characters ` +\n `(got ${formatStr.length}).`\n );\n }\n const pieces = tokenize(formatStr);\n const tokens: AnalyzedToken[] = [];\n const requiredFields = new Set<string>();\n const compatibleTypesSet = new Set<TemporalType>();\n let parseable = true;\n let localeSensitive = false;\n let calendarSensitive = false;\n let timezoneSensitive = false;\n let roundTripSafe = true;\n const warnings: Array<{ code: string; message: string }> = [];\n\n // Walk pieces, building up the analysis. Position is computed per\n // token piece (literals count toward offset but don't appear in the\n // tokens array).\n let offset = 0;\n const unpaddedRun: string[] = [];\n const flushRun = () => {\n if (unpaddedRun.length >= 2) {\n warnings.push({\n code: 'AMBIGUOUS_NUMERIC_RUN',\n message: `Adjacent unpadded numeric tokens \"${unpaddedRun.join('')}\" with no separator can be ambiguous to parse. Add a separator or use the padded form (e.g. \"MM\" instead of \"M\").`,\n });\n }\n unpaddedRun.length = 0;\n };\n\n for (const piece of pieces) {\n if (piece.kind === 'literal') {\n offset += piece.value.length;\n flushRun();\n continue;\n }\n const metadata = TOKEN_METADATA[piece.value];\n // Dead by construction, confirmed via listTokens(): every token in\n // TOKENS has a matching TOKEN_METADATA entry (51/51), and tokenize()\n // already throws on any string that isn't in TOKENS before this loop\n // ever runs. Kept as a guard against the two tables drifting apart.\n /* c8 ignore start */\n if (!metadata) {\n warnings.push({\n code: 'UNKNOWN_TOKEN_NO_METADATA',\n message: `Token \"${piece.value}\" is recognized by the tokenizer but has no metadata entry in tokenMetadata.ts — this is a bug in temporal-fmt.`,\n });\n offset += piece.value.length;\n continue;\n }\n /* c8 ignore stop */\n tokens.push({ name: piece.value, position: offset, metadata });\n\n // Required fields: read off the handler map (the source of truth\n // for \"what field does this token need\"). Falls back to the\n // metadata's supportedTypes-derived field set if the handler isn't\n // found, which also shouldn't happen.\n const handler = _handlerFor(piece.value);\n if (handler) {\n requiredFields.add(handler.field as string);\n }\n\n // compatibleTypes: intersect every token's supportedTypes. The\n // first token seeds the set; subsequent tokens narrow it.\n if (tokens.length === 1) {\n for (const t of metadata.supportedTypes) compatibleTypesSet.add(t);\n } else {\n const stillCompatible = new Set<TemporalType>();\n for (const t of compatibleTypesSet) {\n if (metadata.supportedTypes.includes(t)) stillCompatible.add(t);\n }\n compatibleTypesSet.clear();\n for (const t of stillCompatible) compatibleTypesSet.add(t);\n }\n\n if (!metadata.parseCapable) {\n parseable = false;\n warnings.push({\n code: 'FORMAT_ONLY_TOKEN',\n message: `Token \"${piece.value}\" is format-only — it can't be parsed back into a value. Use a parse-capable variant (e.g. \"d\" instead of \"do\") if you need round-trip.`,\n });\n }\n if (metadata.localeSensitive) localeSensitive = true;\n if (metadata.calendarSensitive) calendarSensitive = true;\n if (metadata.timezoneSensitive) timezoneSensitive = true;\n if (!metadata.roundTripSafe) roundTripSafe = false;\n\n // Track runs of adjacent unpadded numeric tokens — same definition\n // as parsePattern.ts uses (UNPADDED_NUMERIC_TOKENS). A literal\n // between tokens breaks the run; this is checked by the flushRun\n // call above.\n if (UNPADDED_NUMERIC_TOKENS.has(piece.value)) {\n unpaddedRun.push(piece.value);\n } else {\n flushRun();\n }\n\n offset += piece.value.length;\n }\n flushRun();\n\n // Cross-token checks the runtime parse() performs. Mirroring them\n // here lets the ESLint plugin flag them statically without having\n // to re-derive the logic.\n const tokenNames = tokens.map((t) => t.name);\n const has12Hour = tokenNames.some((t) => t === 'hh' || t === 'h');\n const has24Hour = tokenNames.some((t) => t === 'HH' || t === 'H');\n const hasAPeriod = tokenNames.some((t) => t === 'a');\n if (has12Hour && !hasAPeriod) {\n warnings.push({\n code: 'TWELVE_HOUR_WITHOUT_A',\n message: '12-hour token (\"hh\"/\"h\") used without an \"a\" (AM/PM) token — parse() can\\'t tell AM from PM and throws at runtime.',\n });\n }\n if (has12Hour && has24Hour) {\n warnings.push({\n code: 'MIXED_12_AND_24_HOUR',\n message: 'Mixing 24-hour and 12-hour tokens — parse() refuses to guess which is authoritative and throws at runtime.',\n });\n }\n\n const hasOffset = tokenNames.some((t) => t === 'X' || t === 'XX' || t === 'XXX' || t === 'x' || t === 'xx' || t === 'xxx');\n const hasZzz = tokenNames.some((t) => t === 'zzz');\n if (hasOffset && hasZzz) {\n warnings.push({\n code: 'ZZZ_WITH_OFFSET_TOKEN',\n message: 'Format string has both \"zzz\" and an offset token — parse() cross-checks them and throws if the parsed offset disagrees with the zone\\'s actual offset.',\n });\n }\n if (hasOffset && !requiredFields.has('year')) {\n warnings.push({\n code: 'OFFSET_WITHOUT_FULL_DATE',\n message: 'Offset token used without a full date — parse() needs a complete date and time to build a ZonedDateTime and throws at runtime otherwise.',\n });\n }\n\n return {\n tokens,\n requiredFields: [...requiredFields].sort(),\n compatibleTypes: [...compatibleTypesSet].sort(),\n parseable,\n localeSensitive,\n calendarSensitive,\n timezoneSensitive,\n // Ambiguous iff at least one warning fired about an ambiguous run.\n ambiguous: warnings.some((w) => w.code === 'AMBIGUOUS_NUMERIC_RUN'),\n roundTripSafe: roundTripSafe && parseable,\n warnings,\n };\n}\n\n// explainFormat: human-readable rendering of analyzeFormat's output.\n// Used by the CLI (section AD) for `temporal-fmt inspect <fmt>` and by\n// the IDE for hover docs on a format string. Plain prose, no JSON —\n// callers wanting machine-readable output should call analyzeFormat()\n// directly.\nexport function explainFormat(formatStr: string): string {\n const analysis = analyzeFormat(formatStr);\n const lines: string[] = [];\n lines.push(`Format string: \"${formatStr}\"`);\n lines.push(`Tokens (${analysis.tokens.length}):`);\n for (const t of analysis.tokens) {\n lines.push(` ${t.name} @${t.position} — ${t.metadata.meaning}`);\n }\n if (analysis.requiredFields.length > 0) {\n lines.push(`Required fields: ${analysis.requiredFields.join(', ')}`);\n }\n if (analysis.compatibleTypes.length > 0) {\n lines.push(`Compatible Temporal types: ${analysis.compatibleTypes.join(', ')}`);\n }\n lines.push(`Parseable: ${analysis.parseable ? 'yes' : 'no'}`);\n lines.push(`Locale-sensitive: ${analysis.localeSensitive ? 'yes' : 'no'}`);\n lines.push(`Calendar-sensitive: ${analysis.calendarSensitive ? 'yes' : 'no'}`);\n lines.push(`Timezone-sensitive: ${analysis.timezoneSensitive ? 'yes' : 'no'}`);\n lines.push(`Ambiguous: ${analysis.ambiguous ? 'yes' : 'no'}`);\n lines.push(`Round-trip safe: ${analysis.roundTripSafe ? 'yes' : 'no'}`);\n if (analysis.warnings.length > 0) {\n lines.push('Warnings:');\n for (const w of analysis.warnings) {\n lines.push(` [${w.code}] ${w.message}`);\n }\n }\n return lines.join('\\n');\n}\n\n// isValidFormat: true iff tokenize() accepts the string without\n// throwing. Distinct from analyzeFormat's `parseable` flag — a format\n// string can be valid (tokenizes cleanly) but not parseable (contains\n// a format-only token like `do`). Both checks are exposed since callers\n// want different things: validity for \"will format() throw\", parseability\n// for \"will parse() throw\".\nexport function isValidFormat(formatStr: string): boolean {\n if (formatStr.length > MAX_FORMAT_LENGTH) return false;\n try {\n tokenize(formatStr);\n return true;\n } catch {\n return false;\n }\n}\n\n// validateFormat: throws on invalid format strings instead of\n// returning a boolean. Mirrors the existing strict-validation\n// convention (descriptive thrown errors, never silent failures).\n// Returns the analysis for callers who want both — validate-then-use.\nexport function validateFormat(formatStr: string): FormatAnalysis {\n const analysis = analyzeFormat(formatStr);\n return analysis;\n}\n\n// Exported for callers that want to query the token table without\n// touching internals. Kept here rather than re-exported from\n// tokenMetadata.ts so this module is the single import for \"anything\n// analyzer-related.\"\nexport { TOKEN_METADATA, ALL_TOKEN_NAMES } from './tokenMetadata.js';\n\n// Re-export FORMAT_ONLY_TOKENS so callers don't have to import from\n// pattern.ts (which is a lower-level module they shouldn't need to\n// know about).\nexport { FORMAT_ONLY_TOKENS } from './pattern.js';\n\n// Used by callers that need to look up which field a token requires —\n// e.g. the ESLint plugin's \"type mismatch\" check (section Y) wants to\n// answer \"does the type the caller passed to format() carry this\n// field?\" without having to actually call format() and catch the\n// thrown error. Mirrors the same lookup format.ts does internally.\nexport function fieldForToken(token: string): keyof TemporalLike | undefined {\n return _handlerFor(token)?.field;\n}","// Serialization / interop helpers. Standardized\n// parse/format pairs for ISO 8601, RFC 3339, RFC 2822, HTTP-date,\n// plus epoch conversions to/from unix seconds/ms/µs/ns.\n//\n// All of these wrap the existing parse()/format() surface rather than\n// reimplementing the formats — same convention as the rest of the\n// library (one tokenizer, one parser, one constructor path). The\n// standard-format helpers are essentially pre-baked format strings\n// with the right tokens, plus stricter input validation where the\n// standard demands it (e.g. RFC 3339 requires UTC-offset-only zones,\n// not named IANA zones).\n\nimport { parse } from './parse.js';\nimport { format } from './format.js';\nimport { getFormatImpl, getParseImpl } from './runtime.js';\nimport { getTemporal, type TemporalNamespace } from './temporalProvider.js';\nimport { FormatSyntaxError, InvalidDateError } from './errors.js';\n\n// Build a Temporal instance from a field bag. Used by the parse helpers\n// to construct PlainDate / PlainDateTime / ZonedDateTime / Instant from\n// the fields the standard format carries. Throws on construction errors\n// (Feb 30, etc.) wrapped in InvalidDateError so callers get the typed\n// error surface.\nfunction constructFromFields(fields: Record<string, unknown>, kind: 'PlainDate' | 'PlainDateTime' | 'ZonedDateTime' | 'Instant'): unknown {\n const temporal = getTemporal();\n try {\n switch (kind) {\n case 'PlainDate':\n return temporal.PlainDate.from(fields as Record<string, number | string | undefined>, { overflow: 'reject' });\n case 'PlainDateTime':\n return temporal.PlainDateTime.from(fields as Record<string, number | string | undefined>, { overflow: 'reject' });\n case 'ZonedDateTime':\n return temporal.ZonedDateTime.from(fields as Record<string, number | string | undefined>, { overflow: 'reject' });\n case 'Instant': {\n // Instant.from takes an ISO string, not a field bag. Build the\n // ISO string ourselves and parse it.\n const iso = buildISOFromFields(fields);\n if (!temporal.Instant) {\n throw new Error('temporal-fmt: Temporal.Instant is not available in this implementation.');\n }\n return temporal.Instant.from(iso);\n }\n }\n } catch (err) {\n throw new InvalidDateError({ input: JSON.stringify(fields), reason: (err as Error).message });\n }\n}\n\nfunction buildISOFromFields(fields: Record<string, unknown>): string {\n const y = String(fields.year).padStart(4, '0');\n const m = String(fields.month).padStart(2, '0');\n const d = String(fields.day).padStart(2, '0');\n const h = fields.hour !== undefined ? `T${String(fields.hour).padStart(2, '0')}` : '';\n const min = fields.minute !== undefined ? `:${String(fields.minute).padStart(2, '0')}` : '';\n const sec = fields.second !== undefined ? `:${String(fields.second).padStart(2, '0')}` : '';\n const frac = fields.millisecond !== undefined && (fields.millisecond as number) > 0\n ? `.${String(fields.millisecond).padStart(3, '0')}`\n : '';\n const tz = typeof fields.timeZone === 'string' ? fields.timeZone : 'Z';\n return `${y}-${m}-${d}${h}${min}${sec}${frac}${tz}`;\n}\n\n// ISO 8601 is the most permissive of the standards here — accepts\n// calendar dates, week dates, ordinal dates, times with optional\n// fractional seconds, timezone offsets or 'Z'. Delegates to\n// Temporal's own ISO parsing (which is ISO 8601-compliant) by\n// constructing from the raw ISO string.\n\nexport function parseISO(input: string): unknown {\n const temporal = getTemporal();\n // Detect what kind of Temporal object the ISO string describes.\n // ISO 8601 strings have a date part, optional time part, optional\n // timezone. We dispatch to the right Temporal constructor based on\n // which parts are present.\n try {\n if (/^\\d{4}-\\d{2}-\\d{2}T/.test(input) || /T\\d{2}:\\d{2}/.test(input)) {\n // Has a time component.\n if (/[zZ]$/.test(input) || /[+-]\\d{2}:?\\d{2}$/.test(input)) {\n // ZonedDateTime. Temporal.ZonedDateTime.from accepts ISO with\n // a zone bracket (e.g. \"2026-08-04T15:45:30[UTC]\") but rejects\n // a bare offset with no bracket. For \"Z\" suffix, expand to\n // \"+00:00[UTC]\"; for a numeric offset, append that same offset\n // as the bracket (e.g. \"+05:30\" → \"+05:30[+05:30]\").\n let iso = input;\n if (/[zZ]$/.test(iso)) {\n iso = iso.slice(0, -1) + '+00:00[UTC]';\n } else {\n const offsetMatch = /([+-]\\d{2}:?\\d{2})$/.exec(iso);\n if (offsetMatch) {\n iso = `${iso}[${offsetMatch[1]}]`;\n }\n }\n return temporal.ZonedDateTime.from(iso as unknown as Record<string, number | string | undefined>, { overflow: 'reject' });\n }\n return temporal.PlainDateTime.from(input as unknown as Record<string, number | string | undefined>, { overflow: 'reject' });\n }\n if (/^\\d{4}-\\d{2}-\\d{2}/.test(input)) {\n return temporal.PlainDate.from(input as unknown as Record<string, number | string | undefined>, { overflow: 'reject' });\n }\n if (/^\\d{2}:\\d{2}/.test(input)) {\n return temporal.PlainTime.from(input as unknown as Record<string, number | string | undefined>);\n }\n throw new Error(`temporal-fmt: parseISO(\"${input}\") doesn't look like an ISO 8601 string.`);\n } catch (err) {\n throw new InvalidDateError({ input, reason: (err as Error).message });\n }\n}\n\nexport function formatISO(value: unknown): string {\n // Temporal objects expose toString() which produces ISO 8601 output\n // by spec. So formatting IS just toString().\n const v = value as { toString?: () => string };\n if (typeof v?.toString !== 'function') {\n throw new FormatSyntaxError({ reason: `formatISO() expects a Temporal value with toString(), got ${typeof value}.` });\n }\n return v.toString();\n}\n\n// RFC 3339 is a profile of ISO 8601 used in network protocols (HTTP,\n// JSON-RPC, etc.). Stricter than ISO 8601: requires full date+time,\n// requires seconds, requires UTC offset or 'Z', disallows IANA zone\n// names. Delegates to parseISO then validates the constraints.\n\nexport function parseRFC3339(input: string): unknown {\n // RFC 3339 grammar (https://www.rfc-editor.org/rfc/rfc3339#section-5.6):\n // date-fullyear = 4DIGIT\n // date-month = 2DIGIT ; 01-12\n // date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31\n // time-hour = 2DIGIT ; 00-23\n // time-minute = 2DIGIT ; 00-59\n // time-second = 2DIGIT ; 00-58, 00-59, 00-60 (leap second)\n // time-secfrac = \".\" 1*DIGIT\n // time-numoffset = (\"+\" / \"-\") time-hour \":\" time-minute\n // time-offset = \"Z\" / time-numoffset\n // partial-time = time-hour \":\" time-minute \":\" time-second [time-secfrac]\n // full-date = date-fullyear \"-\" date-month \"-\" date-mday\n // full-time = partial-time time-offset\n // date-time = full-date \"T\" full-time\n const re = /^(\\d{4})-(\\d{2})-(\\d{2})[Tt](\\d{2}):(\\d{2}):(\\d{2})(\\.\\d+)?([Zz]|[+-]\\d{2}:\\d{2})$/;\n const m = re.exec(input);\n if (!m) {\n throw new FormatSyntaxError({ input, reason: 'does not match RFC 3339 date-time grammar' });\n }\n // Construct via parseISO with the same expansion for bare Z.\n const iso = input.replace(/[tT]/, 'T').replace(/[zZ]$/, '+00:00[UTC]');\n return parseISO(iso);\n}\n\nexport function formatRFC3339(value: unknown): string {\n // RFC 3339 output is ISO 8601 with a UTC offset. toString() on a\n // ZonedDateTime produces this shape; we just verify the result looks\n // like RFC 3339 and pass it through.\n const s = formatISO(value);\n if (!/^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]+)?(Z|[+-][0-9]{2}:[0-9]{2})$/.test(s)) {\n throw new FormatSyntaxError({ input: s, reason: 'value did not produce RFC 3339-compliant output' });\n }\n return s;\n}\n\n// RFC 2822 date-time (used in email Message-ID headers, etc.). Format:\n// day-of-week, day month year hour:minute:second zone\n// e.g. \"Mon, 04 Aug 2026 15:45:30 +0000\"\n// JS Date can parse this natively, so we use Date.parse and convert\n// to a Temporal.Instant. (Date.parse's RFC 2822 support is universal\n// across engines, unlike its ISO 8601 support which varies.)\n\nexport function parseRFC2822(input: string): unknown {\n // Strict shape pre-check: Date.parse is far more permissive than RFC 2822\n // (it happily accepts ISO 8601 and other dialects), so without this gate\n // parseRFC2822(\"2026-08-04\") would succeed despite not being an RFC 2822\n // date at all. The regex mirrors RFC 2822 §3.3's date-time grammar:\n // optional day-of-week, 1-2 digit day, month name, 2-4 digit year (the\n // obsolete two-digit form included), time with optional seconds, and a\n // zone that is either a numeric ±HHMM offset or an alphabetic zone name.\n const RFC2822_SHAPE =\n /^(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),\\s+)?\\d{1,2}\\s+(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\s+\\d{2,4}\\s+\\d{2}:\\d{2}(?::\\d{2})?\\s+(?:[+-]\\d{4}|[A-Za-z]{1,5})$/;\n if (!RFC2822_SHAPE.test(input.trim())) {\n throw new FormatSyntaxError({ input, reason: 'not a valid RFC 2822 date' });\n }\n const ms = Date.parse(input);\n if (Number.isNaN(ms)) {\n throw new FormatSyntaxError({ input, reason: 'not a valid RFC 2822 date' });\n }\n return requireInstant().fromEpochMilliseconds(ms);\n}\n\nexport function formatRFC2822(value: unknown): string {\n // Format using format() with the right tokens, then construct via\n // the value's epoch ms. RFC 2822 requires a fixed offset, not an\n // IANA zone, so we read the value's offset directly.\n const v = value as { toEpochMilliseconds?: () => number; epochMilliseconds?: number; toInstant?: () => { epochMilliseconds: number } };\n let ms: number | undefined;\n if (typeof v?.toEpochMilliseconds === 'function') {\n ms = v.toEpochMilliseconds();\n } else if (typeof v?.epochMilliseconds === 'number') {\n // Temporal.Instant exposes epochMilliseconds as a property.\n ms = v.epochMilliseconds;\n } else if (typeof v?.toInstant === 'function') {\n // ZonedDateTime.toInstant() → Instant.\n const inst = v.toInstant();\n if (typeof (inst as { epochMilliseconds?: number }).epochMilliseconds === 'number') {\n ms = (inst as { epochMilliseconds: number }).epochMilliseconds;\n }\n }\n if (ms === undefined) {\n throw new FormatSyntaxError({ reason: `formatRFC2822() expects a value with epochMilliseconds, toEpochMilliseconds(), or toInstant(), got ${typeof value}.` });\n }\n return formatRFC2822FromMs(ms);\n}\n\nfunction formatRFC2822FromMs(ms: number): string {\n // Use Intl.DateTimeFormat with the en-US POSIX locale and the rfc822\n // format option. Modern Node ships Intl with this option; if not\n // available, fall back to manual formatting.\n try {\n const fmt = new Intl.DateTimeFormat('en-US', {\n weekday: 'short', day: '2-digit', month: 'short', year: 'numeric',\n hour: '2-digit', minute: '2-digit', second: '2-digit',\n timeZone: 'UTC', timeZoneName: 'shortOffset',\n hour12: false,\n });\n const parts = fmt.formatToParts(new Date(ms));\n /* c8 ignore start -- every part type get() is called with (weekday,\n day, month, year, hour, minute, second, timeZoneName) is always\n present given the fixed options above, so the ?? '' fallback\n can't fire without a different Intl implementation. */\n const get = (t: string) => parts.find((p) => p.type === t)?.value ?? '';\n /* c8 ignore stop */\n const tzRaw = get('timeZoneName');\n // Intl's shortOffset returns \"GMT+0\", \"GMT-8\", \"GMT+5:30\", etc.\n // RFC 2822 wants \"+0000\", \"-0800\", \"+0530\". Parse and reformat.\n const tzMatch = tzRaw?.match(/GMT([+-])(\\d+)(?::(\\d+))?/);\n let tz: string;\n if (tzMatch) {\n const sign = tzMatch[1]!;\n const hours = tzMatch[2]!.padStart(2, '0');\n const minutes = (tzMatch[3] ?? '0').padStart(2, '0');\n tz = `${sign}${hours}${minutes}`;\n /* c8 ignore start @preserve -- timeZone is hardcoded to 'UTC' above,\n which always resolves cleanly, so shortOffset always returns a\n parseable \"GMT+0\"-shaped string in this environment's ICU. This\n branch only guards against an ICU build whose shortOffset output\n doesn't match the regex; can't trigger it without mocking Intl.\n The ignore starts before the closing brace of the if-block so it\n covers the whole else-branch node c8 tracks as a single unit. */\n } else {\n tz = '+0000';\n }\n /* c8 ignore stop @preserve */\n let hour = get('hour');\n /* c8 ignore start @preserve -- hour12:false with a fixed UTC zone\n never yields \"24\" in this environment's ICU (midnight formats as\n \"00\"). Some ICU versions/locales are documented to emit \"24\" for\n hour12:false, so this stays as a defensive normalization; not\n reachable here without mocking Intl.DateTimeFormat's output. */\n if (hour === '24') hour = '00';\n /* c8 ignore stop @preserve */\n return `${get('weekday')}, ${get('day')} ${get('month')} ${get('year')} ${hour}:${get('minute')}:${get('second')} ${tz}`;\n /* c8 ignore start @preserve -- Intl.DateTimeFormat is constructed\n above with a literal, always-valid timeZone: 'UTC' and no other\n user input reaches the constructor or formatToParts call, so this\n catch can't be triggered through the public API in a normal Intl\n environment (e.g. Node with full-icu). Kept as a genuine fallback\n for runtimes with a broken or absent Intl implementation. */\n } catch {\n // Fallback: hand-rolled RFC 2822 format via Date's UTC methods.\n const d = new Date(ms);\n const days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];\n const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];\n const wd = days[d.getUTCDay()];\n const dd = String(d.getUTCDate()).padStart(2, '0');\n const mon = months[d.getUTCMonth()]!;\n const yyyy = d.getUTCFullYear();\n const hh = String(d.getUTCHours()).padStart(2, '0');\n const mm = String(d.getUTCMinutes()).padStart(2, '0');\n const ss = String(d.getUTCSeconds()).padStart(2, '0');\n return `${wd}, ${dd} ${mon} ${yyyy} ${hh}:${mm}:${ss} +0000`;\n }\n /* c8 ignore stop @preserve */\n}\n\n// RFC 7231 defines three formats: IMF-fixdate, RFC 850, asctime.\n// The canonical format is IMF-fixdate (RFC 2822-like with required\n// seconds and UTC-only). Delegates to Date.parse for parsing and to\n// formatRFC2822 for formatting (they're nearly identical).\n\nexport function parseHTTPDate(input: string): unknown {\n const trimmed = input.trim();\n const ms = Date.parse(trimmed);\n if (Number.isNaN(ms)) {\n throw new FormatSyntaxError({ input, reason: 'not a valid HTTP-date' });\n }\n return requireInstant().fromEpochMilliseconds(ms);\n}\n\nexport function formatHTTPDate(value: unknown): string {\n // IMF-fixdate format: \"Sun, 06 Nov 1994 08:49:37 GMT\"\n const instant = (value as { toInstant?: () => { epochMilliseconds: number } })?.toInstant?.()\n ?? (value as { epochMilliseconds?: number });\n const ms = typeof instant === 'object' && instant !== null && 'epochMilliseconds' in instant\n ? (instant as { epochMilliseconds: number }).epochMilliseconds\n : (() => { throw new FormatSyntaxError({ reason: `formatHTTPDate() expects an Instant or ZonedDateTime, got ${typeof value}.` }); })();\n const d = new Date(ms);\n const days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];\n const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];\n const wd = days[d.getUTCDay()];\n const dd = String(d.getUTCDate()).padStart(2, '0');\n const mon = months[d.getUTCMonth()]!;\n const yyyy = d.getUTCFullYear();\n const hh = String(d.getUTCHours()).padStart(2, '0');\n const mm = String(d.getUTCMinutes()).padStart(2, '0');\n const ss = String(d.getUTCSeconds()).padStart(2, '0');\n return `${wd}, ${dd} ${mon} ${yyyy} ${hh}:${mm}:${ss} GMT`;\n}\n\n// All epoch conversions go through Temporal.Instant, which has spec\n// methods for each epoch granularity. Wrapped here for the\n// temporal-fmt surface so callers don't have to import Temporal\n// directly.\n\nfunction getInstant(value: unknown): { epochMilliseconds: number; epochNanoseconds: bigint } {\n const v = value as { toInstant?: () => { epochMilliseconds: number; epochNanoseconds: bigint }; epochMilliseconds?: number; epochNanoseconds?: bigint };\n if (typeof v?.toInstant === 'function') {\n const inst = v.toInstant();\n // Prefer the instant's own epochNanoseconds when present — same\n // precision reasoning as below, since toInstant() can return a\n // real Temporal.Instant carrying both fields.\n if (typeof (inst as { epochNanoseconds?: bigint }).epochNanoseconds === 'bigint') {\n return { epochMilliseconds: inst.epochMilliseconds, epochNanoseconds: (inst as { epochNanoseconds: bigint }).epochNanoseconds };\n }\n return { epochMilliseconds: inst.epochMilliseconds, epochNanoseconds: BigInt(inst.epochMilliseconds) * 1_000_000n };\n }\n // Check epochNanoseconds before epochMilliseconds: a real\n // Temporal.Instant exposes both, and epochMilliseconds is truncated\n // to millisecond precision. Deriving epochNanoseconds by scaling\n // epochMilliseconds back up would silently drop sub-ms precision\n // that was available on the object all along.\n if (typeof v?.epochNanoseconds === 'bigint') {\n return { epochMilliseconds: Number(v.epochNanoseconds / 1_000_000n), epochNanoseconds: v.epochNanoseconds };\n }\n if (typeof v?.epochMilliseconds === 'number') {\n return { epochMilliseconds: v.epochMilliseconds, epochNanoseconds: BigInt(v.epochMilliseconds) * 1_000_000n };\n }\n throw new FormatSyntaxError({ reason: `expected an Instant or ZonedDateTime, got ${typeof value}.` });\n}\n\nfunction requireInstant(): NonNullable<TemporalNamespace['Instant']> {\n const t = getTemporal().Instant;\n if (!t) throw new Error('temporal-fmt: Temporal.Instant is not available in this implementation.');\n return t;\n}\n\nexport function toUnixSeconds(value: unknown): number {\n return getInstant(value).epochMilliseconds / 1000;\n}\n\nexport function fromUnixSeconds(seconds: number): unknown {\n return requireInstant().fromEpochMilliseconds(seconds * 1000);\n}\n\nexport function fromUnixMilliseconds(ms: number): unknown {\n return requireInstant().fromEpochMilliseconds(ms);\n}\n\nexport function fromUnixMicroseconds(µs: number): unknown {\n // Temporal.Instant has no fromEpochMicroseconds in the spec — only\n // fromEpochMilliseconds and fromEpochNanoseconds. Convert via ns.\n return requireInstant().fromEpochNanoseconds(BigInt(µs) * 1_000n);\n}\n\nexport function fromUnixNanoseconds(ns: bigint): unknown {\n return requireInstant().fromEpochNanoseconds(ns);\n}\n\nexport function toUnixMilliseconds(value: unknown): number {\n return getInstant(value).epochMilliseconds;\n}\n\nexport function toUnixMicroseconds(value: unknown): number {\n const { epochNanoseconds } = getInstant(value);\n return Number(epochNanoseconds / 1_000n);\n}\n\nexport function toUnixNanoseconds(value: unknown): bigint {\n return getInstant(value).epochNanoseconds;\n}\n\n// SQL-oriented helpers. SQL date/time formats are simpler than the\n// network standards above — just 'YYYY-MM-DD' for dates, 'HH:MM:SS'\n// for times, 'YYYY-MM-DD HH:MM:SS' for datetimes. Delegating to\n// parse() with the right format strings keeps the validation surface\n// consistent.\nexport function parseSQL(input: string): unknown {\n const trimmed = input.trim();\n const parseImpl = getParseImpl();\n if (/^\\d{4}-\\d{2}-\\d{2}$/.test(trimmed)) {\n return parseImpl('yyyy-MM-dd', trimmed);\n }\n if (/^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$/.test(trimmed)) {\n return parseImpl('yyyy-MM-dd HH:mm:ss', trimmed);\n }\n if (/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}/.test(trimmed)) {\n return parseISO(trimmed);\n }\n throw new FormatSyntaxError({ input, reason: 'not a recognized SQL date/time format' });\n}\n\nexport function formatSQL(value: unknown): string {\n // Detect what kind of Temporal value this is and pick the format.\n const v = value as { year?: number; hour?: number };\n const formatImpl = getFormatImpl();\n if (typeof v?.hour === 'number') {\n return formatImpl(value as Parameters<typeof format>[0], 'yyyy-MM-dd HH:mm:ss');\n }\n return formatImpl(value as Parameters<typeof format>[0], 'yyyy-MM-dd');\n}","// central config stuff. per-call options is the convention we use\n// everywhere else in this lib (formatDistance's cutoffs did it this way\n// first — deliberately NOT a global). so this module just gives callers\n// a typed config object they can build once and pass around, defaults\n// match whatever the per-call defaults already were.\n//\n// no global mutable state, on purpose. don't want a setConfig() anywhere —\n// createConfig() just hands back a frozen object and that's it.\n\nimport { DEFAULT_LOCALE } from './tokens.js';\nimport type { NumberingSystem } from './numbering.js';\n\nexport interface TemporalFmtConfig {\n // BCP-47 tag, defaults to 'en-US'\n locale: string;\n // 'gregory', 'hebrew', whatever — leave undefined and it'll just use\n // whatever the locale defaults to\n calendar?: string;\n // IANA id like 'America/New_York', or leave it undefined for system tz\n timezone?: string;\n // defaults to 'latn'\n numberingSystem: NumberingSystem | string;\n // 1 = Monday, 7 = Sunday. default's 1, matches what isoWeek.ts already does\n firstDayOfWeek: 1 | 7;\n // for round()/roundDuration(), defaults to 'nearest'\n roundingMode: 'nearest' | 'floor' | 'ceil' | 'trunc';\n // what to do when a ZonedDateTime construction hits a gap/overlap.\n // defaults to 'compatible' since that's Temporal's own default too\n disambiguation: 'compatible' | 'earlier' | 'later' | 'reject';\n // handles stuff like Feb 30 when building fields. defaults to 'reject',\n // same as what parse() already did before this existed\n overflow: 'constrain' | 'reject';\n // strict by default (false)\n parseLenient: boolean;\n // false by default so zero values just get omitted, not printed\n durationShowZeroValues: boolean;\n}\n\nexport const DEFAULT_CONFIG: TemporalFmtConfig = {\n locale: DEFAULT_LOCALE,\n numberingSystem: 'latn',\n firstDayOfWeek: 1,\n roundingMode: 'nearest',\n disambiguation: 'compatible',\n overflow: 'reject',\n parseLenient: false,\n durationShowZeroValues: false,\n};\n\n// merges whatever overrides get passed in on top of the defaults, then\n// freezes it so nobody can mutate it after — Temporal's own options\n// work this way too so figured we'd match that\nexport function createConfig(overrides: Partial<TemporalFmtConfig> = {}): Readonly<TemporalFmtConfig> {\n const merged: TemporalFmtConfig = { ...DEFAULT_CONFIG, ...overrides };\n // sanity checks before we freeze it\n if (typeof merged.locale !== 'string' || merged.locale.length === 0) {\n throw new Error(`temporal-fmt: config.locale must be a non-empty string (got ${String(merged.locale)}).`);\n }\n if (merged.firstDayOfWeek !== 1 && merged.firstDayOfWeek !== 7) {\n throw new Error(`temporal-fmt: config.firstDayOfWeek must be 1 (Monday) or 7 (Sunday) (got ${merged.firstDayOfWeek}).`);\n }\n if (!['nearest', 'floor', 'ceil', 'trunc'].includes(merged.roundingMode)) {\n throw new Error(`temporal-fmt: config.roundingMode \"${merged.roundingMode}\" is not recognized.`);\n }\n if (!['compatible', 'earlier', 'later', 'reject'].includes(merged.disambiguation)) {\n throw new Error(`temporal-fmt: config.disambiguation \"${merged.disambiguation}\" is not recognized.`);\n }\n if (!['constrain', 'reject'].includes(merged.overflow)) {\n throw new Error(`temporal-fmt: config.overflow \"${merged.overflow}\" is not recognized.`);\n }\n return Object.freeze(merged);\n}\n\n// merges a config into per-call options — whatever's already set in\n// per-call wins. format()/parse()/etc use this to fold config in\ninterface ConfigOverrides {\n locale?: string;\n calendar?: string;\n timezone?: string;\n numberingSystem?: string;\n lenient?: boolean;\n}\n\nexport function mergeWithConfig<T extends Record<string, unknown>>(\n config: Readonly<TemporalFmtConfig> | undefined,\n perCall: T,\n): Record<string, unknown> & ConfigOverrides {\n if (!config) return perCall;\n // Returns a fresh object typed by its own actual shape (perCall's\n // fields plus these five, each optionally overridden) instead of\n // asserting the result back into the generic T. A `{ ...perCall } as T\n // & {...}` cast here previously claimed a freshly spread object was\n // still exactly T, which isn't something a spread can guarantee for an\n // arbitrary caller-supplied T — tsc rightly rejected that once this\n // generic got exercised through a real call site (mergeWithConfig's\n // override wrapper in modApi.ts). Nothing in this codebase currently\n // calls mergeWithConfig and relies on getting T back rather than this\n // wider shape, so there's no correctness cost to being honest about\n // what's actually returned.\n const extras: ConfigOverrides = {};\n if (perCall.locale === undefined) extras.locale = config.locale;\n if (perCall.calendar === undefined && config.calendar !== undefined) extras.calendar = config.calendar;\n if (perCall.timezone === undefined && config.timezone !== undefined) extras.timezone = config.timezone;\n if (perCall.numberingSystem === undefined) extras.numberingSystem = config.numberingSystem;\n if (perCall.lenient === undefined && config.parseLenient) extras.lenient = true;\n return { ...perCall, ...extras };\n}","// business calendar stuff — configurable weekends, holiday sets, observed\n// holidays, working hours, half days if you need em. holiday checking\n// itself is handed off to a HolidayCalendar (holidays.ts) so this file\n// can just worry about the weekday-vs-weekend part\n\nimport { add } from './arithmetic.js';\nimport type { HolidayCalendar } from './holidays.js';\n\nexport interface BusinessCalendarOptions {\n // defaults to [6, 7] (Sat/Sun). ISO weekday numbers, 1-7\n weekend?: number[];\n // pass a holiday calendar if you want holidays factored in too —\n // skip it and you just get weekend logic\n holidays?: HolidayCalendar;\n // hours per weekday, 1=Mon..7=Sun. defaults to 8hrs weekdays, 0 weekend.\n // addBusinessDays() uses this for partial-day math\n workingHours?: Record<number, number>;\n // which weekdays get reduced hours. empty by default\n halfDays?: number[];\n}\n\nexport interface BusinessCalendar {\n weekend: Set<number>;\n holidays?: HolidayCalendar;\n workingHours: Record<number, number>;\n halfDays: Set<number>;\n}\n\nexport function createBusinessCalendar(options: BusinessCalendarOptions = {}): BusinessCalendar {\n const weekend = new Set(options.weekend ?? [6, 7]);\n // gotta copy this before filling in defaults — used to write the missing\n // weekday entries straight into options.workingHours, which mutated\n // the caller's actual object. so someone's { 1: 6 } would silently grow\n // keys 2-7 just from \"creating\" a calendar, and if they reused that\n // object across calendars, the first one's defaults leaked into all of them\n const workingHours: Record<number, number> = { ...(options.workingHours ?? {}) };\n for (let i = 1; i <= 7; i++) {\n if (workingHours[i] === undefined) {\n workingHours[i] = weekend.has(i) ? 0 : 8;\n }\n }\n return {\n weekend,\n holidays: options.holidays,\n workingHours,\n halfDays: new Set(options.halfDays ?? []),\n };\n}\n\nexport function isBusinessDay(cal: BusinessCalendar, value: unknown): boolean {\n const v = value as { dayOfWeek?: number; year?: number; month?: number; day?: number };\n // add() over in arithmetic.ts doesn't touch dayOfWeek — it just hands back\n // whatever dayOfWeek the input had, stale or not. so recompute it from\n // year/month/day whenever we've got those, don't trust the cached value\n let dow = v.dayOfWeek;\n if (typeof v.year === 'number' && typeof v.month === 'number' && typeof v.day === 'number') {\n const d = new Date(Date.UTC(v.year, v.month - 1, v.day));\n const jsDow = d.getUTCDay(); // 0=Sun..6=Sat\n dow = jsDow === 0 ? 7 : jsDow; // 1=Mon..7=Sun\n }\n if (typeof dow !== 'number') {\n throw new Error('temporal-fmt: isBusinessDay() needs a value with dayOfWeek (or year/month/day to compute it).');\n }\n if (cal.weekend.has(dow)) return false;\n if (cal.holidays && cal.holidays.isHoliday(value)) return false;\n return true;\n}\n\nexport function nextBusinessDay(cal: BusinessCalendar, value: unknown): unknown {\n let candidate = add(value, 1, 'days');\n // keep going till we hit a business day. capped at 14 just to be safe —\n // a week is really the natural bound even with weekend + holidays combined\n for (let i = 0; i < 14; i++) {\n if (isBusinessDay(cal, candidate)) return candidate;\n candidate = add(candidate, 1, 'days');\n }\n throw new Error('temporal-fmt: nextBusinessDay() gave up after 14 days — likely a misconfigured calendar (e.g. all days are weekends or holidays).');\n}\n\nexport function previousBusinessDay(cal: BusinessCalendar, value: unknown): unknown {\n let candidate = add(value, -1, 'days');\n for (let i = 0; i < 14; i++) {\n if (isBusinessDay(cal, candidate)) return candidate;\n candidate = add(candidate, -1, 'days');\n }\n throw new Error('temporal-fmt: previousBusinessDay() gave up after 14 days — likely a misconfigured calendar.');\n}\n\nconst MAX_BUSINESS_DAY_TRAVERSAL = 100_000;\n\nfunction assertBusinessDayCount(days: number): void {\n if (!Number.isSafeInteger(days)) {\n throw new RangeError(\n `temporal-fmt: business-day count must be a finite safe integer (got ${days}).`,\n );\n }\n}\n\nfunction compareDateFields(a: unknown, b: unknown): number {\n const av = a as { year: number; month: number; day: number };\n const bv = b as { year: number; month: number; day: number };\n const ay = av.year * 10000 + av.month * 100 + av.day;\n const by = bv.year * 10000 + bv.month * 100 + bv.day;\n return ay - by;\n}\n\nexport function addBusinessDays(cal: BusinessCalendar, value: unknown, days: number): unknown {\n assertBusinessDayCount(days);\n if (days === 0) return value;\n const sign = days > 0 ? 1 : -1;\n const absDays = Math.abs(days);\n if (absDays > MAX_BUSINESS_DAY_TRAVERSAL) {\n throw new RangeError(\n `temporal-fmt: addBusinessDays() exceeded the ${MAX_BUSINESS_DAY_TRAVERSAL}-day limit.`,\n );\n }\n let candidate = value;\n for (let i = 0; i < absDays; i++) {\n candidate = sign > 0 ? nextBusinessDay(cal, candidate) : previousBusinessDay(cal, candidate);\n }\n return candidate;\n}\n\nexport function subtractBusinessDays(cal: BusinessCalendar, value: unknown, days: number): unknown {\n assertBusinessDayCount(days);\n return addBusinessDays(cal, value, -days);\n}\n\nexport function differenceInBusinessDays(cal: BusinessCalendar, a: unknown, b: unknown): number {\n const rawDirection = compareDateFields(b, a);\n if (rawDirection === 0) return 0;\n\n const direction = rawDirection > 0 ? 1 : -1;\n let candidate = a;\n let count = 0;\n let traversedDays = 0;\n\n while (compareDateFields(candidate, b) !== 0) {\n candidate = add(candidate, direction, 'days');\n traversedDays++;\n if (traversedDays > MAX_BUSINESS_DAY_TRAVERSAL) {\n throw new RangeError(\n `temporal-fmt: differenceInBusinessDays() exceeded the ${MAX_BUSINESS_DAY_TRAVERSAL}-day traversal limit.`,\n );\n }\n if (isBusinessDay(cal, candidate)) count += direction;\n }\n\n return count;\n}\n","// holiday framework. core just gives you the abstraction — actual\n// country-specific holiday lists live outside this package, could be\n// their own ecosystem packages built on top. a holiday calendar is\n// basically a date -> boolean function (\"is this a holiday\") plus some\n// iteration helpers (nextHoliday, previousHoliday, holidaysBetween)\n\nimport { add } from './arithmetic.js';\nimport { compare } from './comparison.js';\n\nexport interface HolidayCalendar {\n isHoliday(value: unknown): boolean;\n // everything in [start, end], inclusive on both ends\n holidaysBetween(start: unknown, end: unknown): unknown[];\n}\n\nexport interface HolidaySpec {\n // for fixed-date holidays, like Jan 1 for New Year's\n month?: number;\n day?: number;\n // for the floating ones — give it a year, get back { month, day } for\n // that year. this is how you'd do \"last Monday of May\" type rules\n compute?: (year: number) => { month: number; day: number };\n // just a name, mostly for debugging\n name?: string;\n}\n\n// cap on how many years holidaysBetween() will walk through. it's a\n// year-by-year loop with no bounds checking on the inputs, so someone\n// passing year 1 to year 300000 would've made it iterate (and cache!)\n// every single year in between. either an accident or someone being\n// hostile, either way that used to just hang the process. 5000 matches\n// the same walk-cap businessCalendar.ts and recurrence.ts already use\nconst MAX_HOLIDAY_YEAR_RANGE = 5_000;\n\nexport function createHolidayCalendar(specs: HolidaySpec[]): HolidayCalendar {\n // computes a year's holiday list lazily, then caches it\n const cache = new Map<number, Array<{ month: number; day: number; name?: string }>>();\n function forYear(year: number) {\n let list = cache.get(year);\n if (list) return list;\n list = specs.map((s) => {\n let md: { month: number; day: number };\n if (s.compute) {\n md = s.compute(year);\n } else {\n md = { month: s.month!, day: s.day! };\n }\n return { ...md, name: s.name };\n });\n cache.set(year, list);\n return list;\n }\n return {\n isHoliday(value: unknown) {\n const v = value as { year?: number; month?: number; day?: number };\n if (typeof v.year !== 'number' || typeof v.month !== 'number' || typeof v.day !== 'number') {\n throw new Error('temporal-fmt: isHoliday() needs a value with year/month/day.');\n }\n const list = forYear(v.year);\n return list.some((h) => h.month === v.month && h.day === v.day);\n },\n holidaysBetween(start: unknown, end: unknown) {\n const sv = start as { year: number; month: number; day: number };\n const ev = end as { year: number; month: number; day: number };\n if (typeof sv?.year !== 'number' || typeof ev?.year !== 'number') {\n throw new Error('temporal-fmt: holidaysBetween() needs start/end values with year/month/day.');\n }\n if (ev.year - sv.year > MAX_HOLIDAY_YEAR_RANGE) {\n throw new RangeError(\n `temporal-fmt: holidaysBetween() year range (${sv.year}–${ev.year}) exceeds the ` +\n `${MAX_HOLIDAY_YEAR_RANGE}-year limit. Split the query into smaller ranges.`\n );\n }\n const result: unknown[] = [];\n for (let y = sv.year; y <= ev.year; y++) {\n const list = forYear(y);\n for (const h of list) {\n const date = { year: y, month: h.month, day: h.day };\n if (compare(date, sv) >= 0 && compare(date, ev) <= 0) {\n result.push({ year: y, month: h.month, day: h.day });\n }\n }\n }\n return result;\n },\n };\n}\n\n// finds the next holiday strictly after `value`. gives up and returns\n// undefined if nothing shows up within 5 years — sanity cap so this\n// can't loop forever on an empty calendar\nexport function nextHoliday(cal: HolidayCalendar, value: unknown): unknown | undefined {\n let candidate = add(value, 1, 'days');\n for (let i = 0; i < 365 * 5; i++) {\n if (cal.isHoliday(candidate)) return candidate;\n candidate = add(candidate, 1, 'days');\n }\n return undefined;\n}\n\nexport function previousHoliday(cal: HolidayCalendar, value: unknown): unknown | undefined {\n let candidate = add(value, -1, 'days');\n for (let i = 0; i < 365 * 5; i++) {\n if (cal.isHoliday(candidate)) return candidate;\n candidate = add(candidate, -1, 'days');\n }\n return undefined;\n}\n\n// holidaysBetween already exists as a method on HolidayCalendar (above),\n// this is just a standalone version so you don't have to type cal.holidaysBetween\nexport function holidaysBetween(cal: HolidayCalendar, start: unknown, end: unknown): unknown[] {\n return cal.holidaysBetween(start, end);\n}\n","// IDE tooling data exports. Provides structured data editor plugins can\n// consume for: token autocomplete, hover docs, inline diagnostics,\n// quick fixes, format preview, token conversion hints from\n// Day.js/date-fns, documentation links.\n//\n// This is the data layer only — an actual VS Code extension is out of\n// scope for this package. A separate package can build the extension\n// on top of these exports.\n\nimport { TOKEN_METADATA, ALL_TOKEN_NAMES } from './tokenMetadata.js';\nimport { analyzeFormat, listTokens } from './analyze.js';\nimport { format as builtinFormat } from './format.js';\n\nexport interface TokenAutocompleteEntry {\n label: string;\n detail: string;\n documentation: string;\n // Sort group — same-family tokens sort together in the autocomplete list.\n family: string;\n}\n\n// Token family grouping for autocomplete organization: year, month,\n// day, etc.\nfunction tokenFamily(name: string): string {\n if (/^y+$/.test(name)) return 'Year';\n if (/^[ML]+$/.test(name)) return 'Month';\n if (/^[decD]+$/.test(name)) return 'Day';\n if (/^[Ec]+$/.test(name)) return 'Weekday';\n if (/^[Qq]+$/.test(name)) return 'Quarter';\n if (/^[Gg]+$/.test(name)) return 'Era';\n if (/^[Hh]+$/.test(name)) return 'Hour';\n if (/^m+$/.test(name)) return 'Minute';\n if (/^s+$/.test(name)) return 'Second';\n if (/^S+$/.test(name)) return 'Fractional Second';\n if (name === 'a') return 'Day Period';\n if (name === 'zzz') return 'Time Zone';\n if (/^[Xx]+$/.test(name)) return 'UTC Offset';\n if (name === 'do') return 'Ordinal Day';\n if (name === 'ww' || name === 'RRRR') return 'ISO Week';\n return 'Other';\n}\n\nexport function getAutocompleteData(): TokenAutocompleteEntry[] {\n return ALL_TOKEN_NAMES.map((name) => {\n const meta = TOKEN_METADATA[name]!;\n return {\n label: name,\n detail: meta.meaning,\n documentation: [\n meta.meaning,\n ``,\n `Format-capable: ${meta.formatCapable}`,\n `Parse-capable: ${meta.parseCapable}`,\n `Locale-sensitive: ${meta.localeSensitive}`,\n `Calendar-sensitive: ${meta.calendarSensitive}`,\n `Timezone-sensitive: ${meta.timezoneSensitive}`,\n `Round-trip safe: ${meta.roundTripSafe}`,\n `Supported types: ${meta.supportedTypes.join(', ')}`,\n ].join('\\n'),\n family: tokenFamily(name),\n };\n });\n}\n\nexport interface TokenHoverDoc {\n signature: string;\n summary: string;\n details: string;\n examples?: string[];\n}\n\nexport function getHoverDocs(): Record<string, TokenHoverDoc> {\n const result: Record<string, TokenHoverDoc> = {};\n for (const name of ALL_TOKEN_NAMES) {\n const meta = TOKEN_METADATA[name]!;\n result[name] = {\n signature: name,\n summary: meta.meaning,\n details: [\n // every entry in TOKEN_METADATA currently has formatCapable:\n // true (verified: 51/51). The 'no' branch reflects real,\n // intended behavior for a future format-incapable token —\n // there's no such token today, so this isn't reachable data,\n // not dead logic. Every other field on this line has real\n // true/false variance across the token table and is exercised\n // by this same loop running over ALL_TOKEN_NAMES.\n /* c8 ignore next */\n `Format-capable: ${meta.formatCapable ? 'yes' : 'no'}`,\n `Parse-capable: ${meta.parseCapable ? 'yes' : 'no'}`,\n `Locale-sensitive: ${meta.localeSensitive ? 'yes' : 'no'}`,\n `Calendar-sensitive: ${meta.calendarSensitive ? 'yes' : 'no'}`,\n `Timezone-sensitive: ${meta.timezoneSensitive ? 'yes' : 'no'}`,\n `Round-trip safe: ${meta.roundTripSafe ? 'yes' : 'no'}`,\n `Supported types: ${meta.supportedTypes.join(', ')}`,\n ].join('\\n'),\n };\n }\n return result;\n}\n\n// Inline diagnostic data for a format string. Returns a list of issues\n// (warnings + errors) with position + message + suggested fix where\n// available. Mirrors analyzeFormat's warnings but adds the position\n// info an editor needs to draw squigglies.\nexport interface InlineDiagnostic {\n startColumn: number;\n endColumn: number;\n severity: 'error' | 'warning' | 'info';\n message: string;\n code: string;\n // Suggested replacement (for quick-fix). Empty when no quick fix exists.\n suggestion?: string;\n}\n\nexport function getInlineDiagnostics(formatStr: string): InlineDiagnostic[] {\n const analysis = analyzeFormat(formatStr);\n const diagnostics: InlineDiagnostic[] = [];\n for (const warning of analysis.warnings) {\n // Find the token that triggered the warning. analyzeFormat doesn't\n // currently surface which token caused which warning — we'd need\n // to extend it to track per-warning source positions. For now,\n // surface as a whole-string diagnostic.\n let message = warning.message;\n let suggestion: string | undefined;\n if (warning.code === 'TWELVE_HOUR_WITHOUT_A') {\n suggestion = 'Add an \"a\" token (e.g. \"h:mm a\") or use \"H:mm\" for 24-hour.';\n } else if (warning.code === 'MIXED_12_AND_24_HOUR') {\n suggestion = 'Pick one form: \"HH:mm\" for 24-hour or \"h:mm a\" for 12-hour.';\n } else if (warning.code === 'AMBIGUOUS_NUMERIC_RUN') {\n suggestion = 'Add a separator or use padded forms (e.g. \"MM\" instead of \"M\").';\n } else if (warning.code === 'FORMAT_ONLY_TOKEN') {\n suggestion = 'Use a parse-capable variant (e.g. \"d\" instead of \"do\").';\n }\n diagnostics.push({\n startColumn: 0,\n endColumn: formatStr.length,\n severity: 'warning',\n message,\n code: warning.code,\n suggestion,\n });\n }\n return diagnostics;\n}\n\n// Day.js / date-fns token conversion hints. Used by the IDE to suggest\n// the temporal-fmt equivalent when a user types a Day.js or date-fns\n// token. Pulls the translation tables from the codemod if available;\n// falls back to inline tables otherwise.\nexport interface TokenConversionHint {\n from: string;\n // null means \"real token in the source library, no temporal-fmt\n // equivalent\" — the codemod throws on these rather than treating\n // them as unrecognized text (see codemod.ts).\n to: string | null;\n notes?: string;\n}\n\n// Day.js → temporal-fmt mappings. Day.js uses Moment-style tokens:\n// `D`/`DD` are day-of-*month* here (unlike date-fns below, where the\n// same letters mean day-of-year). Assumes the AdvancedFormat plugin\n// for `Do`/`Q`/`k`/`kk`/`X`/`x` — see codemod.ts's doc comment for why.\nexport const DAYJS_TO_TEMPORAL_FMT: TokenConversionHint[] = [\n { from: 'YYYY', to: 'yyyy' },\n { from: 'YY', to: 'yy' },\n { from: 'MMMM', to: 'MMMM' },\n { from: 'MMM', to: 'MMM' },\n { from: 'MM', to: 'MM' },\n { from: 'M', to: 'M' },\n { from: 'DD', to: 'dd' },\n { from: 'D', to: 'd' },\n { from: 'Do', to: null, notes: 'Ordinal day (AdvancedFormat) — use temporal-fmt\\'s own \"do\" token instead.' },\n { from: 'dddd', to: 'EEEE' },\n { from: 'ddd', to: 'EEE' },\n { from: 'dd', to: null, notes: 'Min-name weekday (e.g. \"Tu\") — temporal-fmt has no equivalent width.' },\n { from: 'd', to: null, notes: 'Numeric weekday (0-6) — no temporal-fmt equivalent; not the same as \"d\" here, which is day-of-month.' },\n { from: 'HH', to: 'HH' },\n { from: 'H', to: 'H' },\n { from: 'hh', to: 'hh' },\n { from: 'h', to: 'h' },\n { from: 'kk', to: null, notes: 'Hour 1-24 (AdvancedFormat) — no temporal-fmt equivalent.' },\n { from: 'k', to: null, notes: 'Hour 1-24 (AdvancedFormat) — no temporal-fmt equivalent.' },\n { from: 'mm', to: 'mm' },\n { from: 'm', to: 'm' },\n { from: 'ss', to: 'ss' },\n { from: 's', to: 's' },\n { from: 'SSS', to: 'SSS' },\n { from: 'A', to: 'a', notes: 'Uppercase AM/PM in Day.js — temporal-fmt is always lowercase.' },\n { from: 'a', to: 'a' },\n { from: 'ZZ', to: 'XX', notes: 'Numeric UTC offset, no colon.' },\n { from: 'Z', to: 'XXX', notes: 'Numeric UTC offset with colon.' },\n { from: 'X', to: null, notes: 'Unix timestamp (seconds) — use fromUnixSeconds() instead.' },\n { from: 'x', to: null, notes: 'Unix timestamp (ms) — use fromUnixMilliseconds() instead.' },\n { from: 'Qo', to: null, notes: 'Ordinal quarter (AdvancedFormat) — no temporal-fmt equivalent.' },\n { from: 'Q', to: 'Q' },\n { from: 'Mo', to: null, notes: 'Ordinal month (AdvancedFormat) — no temporal-fmt equivalent.' },\n { from: 'ww', to: 'ww' },\n { from: 'wo', to: null, notes: 'Ordinal ISO week (AdvancedFormat) — no temporal-fmt equivalent.' },\n { from: 'w', to: null, notes: 'Unpadded ISO week — temporal-fmt\\'s \"ww\" is always 2-digit.' },\n { from: 'gggg', to: 'RRRR', notes: 'Week-numbering year, not the calendar year — same caveat as temporal-fmt\\'s RRRR.' },\n { from: 'L', to: null, notes: 'Localized date format (AdvancedFormat) — write the format string out explicitly.' },\n { from: 'LL', to: null, notes: 'Localized date format (AdvancedFormat) — write the format string out explicitly.' },\n { from: 'LLL', to: null, notes: 'Localized date format (AdvancedFormat) — write the format string out explicitly.' },\n { from: 'LLLL', to: null, notes: 'Localized date format (AdvancedFormat) — write the format string out explicitly.' },\n { from: 'LT', to: null, notes: 'Localized time format (AdvancedFormat) — write the format string out explicitly.' },\n { from: 'LTS', to: null, notes: 'Localized time format (AdvancedFormat) — write the format string out explicitly.' },\n];\n\n// date-fns → temporal-fmt mappings. date-fns already uses Unicode/LDML\n// -style tokens close to temporal-fmt's own vocabulary — most strings\n// pass through unchanged. The catch: `D`/`DD` here mean day-of-*year*\n// (same as temporal-fmt's `D`/`DD`), not day-of-month like Day.js's\n// `D`/`DD` above — don't reuse the Day.js table for this, they collide.\nexport const DATE_FNS_TO_TEMPORAL_FMT: TokenConversionHint[] = [\n { from: 'yyyy', to: 'yyyy' },\n { from: 'yy', to: 'yy' },\n { from: 'y', to: null, notes: 'Unpadded calendar year, opt-in via useAdditionalWeekYearTokens — temporal-fmt has no unpadded-year token; use \"yyyy\".' },\n { from: 'MMMM', to: 'MMMM' },\n { from: 'MMM', to: 'MMM' },\n { from: 'MM', to: 'MM' },\n { from: 'M', to: 'M' },\n { from: 'LLLL', to: 'LLLL' },\n { from: 'LLL', to: 'LLL' },\n { from: 'dd', to: 'dd' },\n { from: 'd', to: 'd' },\n { from: 'do', to: 'do' },\n { from: 'DDD', to: 'DDD' },\n { from: 'DD', to: 'DD' },\n { from: 'D', to: 'D', notes: 'Day-of-year, opt-in via useAdditionalDayOfYearTokens — matches temporal-fmt\\'s own \"D\" already.' },\n { from: 'EEEE', to: 'EEEE' },\n { from: 'EEE', to: 'EEE' },\n { from: 'eeee', to: null, notes: 'Locale-aware numeric weekday — no temporal-fmt equivalent.' },\n { from: 'cccc', to: 'cccc' },\n { from: 'ccc', to: 'ccc' },\n { from: 'HH', to: 'HH' },\n { from: 'H', to: 'H' },\n { from: 'hh', to: 'hh' },\n { from: 'h', to: 'h' },\n { from: 'mm', to: 'mm' },\n { from: 'm', to: 'm' },\n { from: 'ss', to: 'ss' },\n { from: 's', to: 's' },\n { from: 'SSS', to: 'SSS' },\n { from: 'a', to: 'a' },\n { from: 'aaa', to: 'a' },\n { from: 'XXX', to: 'XXX' },\n { from: 'XX', to: 'XX' },\n { from: 'X', to: 'X', notes: 'Opt-in via useAdditionalDayOfYearTokens-adjacent rules in date-fns v3+; matches temporal-fmt\\'s own \"X\" already.' },\n { from: 'xxx', to: 'xxx' },\n { from: 'xx', to: 'xx' },\n { from: 'x', to: 'x' },\n { from: 'zzzz', to: 'zzzz' },\n { from: 'zzz', to: 'zzz' },\n { from: 'z', to: 'z' },\n { from: 'QQQ', to: 'QQQ' },\n { from: 'Q', to: 'Q' },\n { from: 'GGGG', to: 'GGGG' },\n { from: 'GGG', to: null, notes: 'Abbreviated era — temporal-fmt only has \"G\" (short) and \"GGGG\" (long).' },\n { from: 'GG', to: null, notes: 'Abbreviated era — temporal-fmt only has \"G\" (short) and \"GGGG\" (long).' },\n { from: 'G', to: 'G' },\n { from: 'ww', to: 'ww' },\n { from: 'w', to: null, notes: 'Unpadded local week number — temporal-fmt\\'s \"ww\" is ISO-week and always 2-digit.' },\n { from: 'RRRR', to: 'RRRR' },\n { from: 'R', to: null, notes: 'Unpadded ISO week-numbering year — temporal-fmt\\'s \"RRRR\" is always 4-digit.' },\n { from: 'Y', to: null, notes: 'Week-numbering year (locale week rules), opt-in — no temporal-fmt equivalent; \"RRRR\" is ISO week-numbering, a different rule set.' },\n { from: 'PPPP', to: null, notes: 'Localized composite format — write the format string out explicitly.' },\n { from: 'PPP', to: null, notes: 'Localized composite format — write the format string out explicitly.' },\n { from: 'PP', to: null, notes: 'Localized composite format — write the format string out explicitly.' },\n { from: 'P', to: null, notes: 'Localized composite format — write the format string out explicitly.' },\n { from: 'pppp', to: null, notes: 'Localized composite format — write the format string out explicitly.' },\n { from: 'ppp', to: null, notes: 'Localized composite format — write the format string out explicitly.' },\n { from: 'pp', to: null, notes: 'Localized composite format — write the format string out explicitly.' },\n { from: 'p', to: null, notes: 'Localized composite format — write the format string out explicitly.' },\n];\n\n// Format preview — for a given format string and a sample Temporal\n// value, returns the formatted string. Editor plugins use this for\n// live preview as the user types.\nexport function previewFormat(formatStr: string, sample?: unknown): string {\n // Use a fixed sample date if none provided — 2026-08-04T15:45:30.\n // Picked because it exercises every common token: weekday is Tuesday,\n // month name has 5 chars, day is single-digit, hour is 12-hour-style,\n // minute/second both pad.\n const value = sample ?? {\n year: 2026, month: 8, day: 4, hour: 15, minute: 45, second: 30, millisecond: 123,\n dayOfWeek: 2, timeZoneId: 'UTC', offset: '+00:00', calendarId: 'iso8601',\n };\n return builtinFormat(value as Parameters<typeof builtinFormat>[0], formatStr, { locale: 'en-US' });\n}\n\n// Documentation links. Docs used to live under docs/ as one file per\n// token family; they're now consolidated into the root README's \"Token\n// reference\" section, which has no per-token anchors — so this points\n// at the section instead of a token-specific fragment.\nexport function getDocUrl(tokenName: string): string {\n void tokenName;\n return 'README.md#token-reference';\n}\n\n// Re-exports for callers that want everything IDE-related from one module.\nexport { listTokens, TOKEN_METADATA, ALL_TOKEN_NAMES };","// translates Day.js / date-fns format strings — this is what backs the\n// CLI's `translate` subcommand. the mapping tables were already sitting\n// in ideData.ts (built for the IDE tooling), so this just builds the\n// actual string translator on top instead of pulling in anything else.\n//\n// heads up: this only handles format *strings* (\"YYYY-MM-DD\" -> \"yyyy-MM-dd\"),\n// not an actual AST codemod that goes and rewrites call sites in your code.\n// that's a bigger separate thing — check temporal-fmt-codemod if that's\n// what you actually need\n\nimport { DAYJS_TO_TEMPORAL_FMT, DATE_FNS_TO_TEMPORAL_FMT, type TokenConversionHint } from './ideData.js';\n\ninterface SourcePiece {\n kind: 'token' | 'literal';\n value: string;\n}\n\n// Day.js and date-fns escape literal text with square brackets — [MM]\n// stays as literal \"MM\" — not single quotes like temporal-fmt does.\n// splitting on brackets first keeps the token scan below from accidentally\n// matching stuff inside an escaped span\nfunction splitOnBrackets(source: string): SourcePiece[] {\n const pieces: SourcePiece[] = [];\n let i = 0;\n while (i < source.length) {\n if (source[i] === '[') {\n const end = source.indexOf(']', i + 1);\n if (end === -1) {\n pieces.push({ kind: 'token', value: source.slice(i) });\n break;\n }\n pieces.push({ kind: 'literal', value: source.slice(i + 1, end) });\n i = end + 1;\n } else {\n let j = i;\n while (j < source.length && source[j] !== '[') j += 1;\n pieces.push({ kind: 'token', value: source.slice(i, j) });\n i = j;\n }\n }\n return pieces;\n}\n\n// splits a non-bracketed span into runs, matching greedy-longest against\n// the known token table — basically the same idea as tokenize.ts, just\n// scanning the SOURCE library's tokens here instead of temporal-fmt's own\nfunction splitIntoRuns(span: string, sortedFrom: string[]): SourcePiece[] {\n const pieces: SourcePiece[] = [];\n let i = 0;\n while (i < span.length) {\n const match = sortedFrom.find((tok) => span.startsWith(tok, i));\n if (match) {\n pieces.push({ kind: 'token', value: match });\n i += match.length;\n continue;\n }\n const last = pieces[pieces.length - 1];\n if (last && last.kind === 'literal') {\n last.value += span[i];\n } else {\n pieces.push({ kind: 'literal', value: span[i] });\n }\n i += 1;\n }\n return pieces;\n}\n\nfunction translate(source: string, table: TokenConversionHint[], sourceLibLabel: string): string {\n const byFrom = new Map(table.map((hint) => [hint.from, hint.to]));\n const sortedFrom = [...byFrom.keys()].sort((a, b) => b.length - a.length);\n\n const bracketPieces = splitOnBrackets(source);\n let out = '';\n for (const piece of bracketPieces) {\n if (piece.kind === 'literal') {\n // re-escape for temporal-fmt's quote syntax — any literal quote\n // char inside the escaped bit needs doubling up\n out += `'${piece.value.replace(/'/g, \"''\")}'`;\n continue;\n }\n for (const run of splitIntoRuns(piece.value, sortedFrom)) {\n if (run.kind === 'token') {\n const mapped = byFrom.get(run.value);\n if (mapped === undefined || mapped === null) {\n throw new Error(\n `temporal-fmt: \"${run.value}\" has no ${sourceLibLabel} -> temporal-fmt mapping ` +\n `(in format string \"${source}\"). Write the equivalent temporal-fmt token in by hand, ` +\n `or wrap it in brackets if it was meant as literal text.`\n );\n }\n out += mapped;\n } else if (/[a-zA-Z]/.test(run.value)) {\n // can't just let unrecognized letters through as-is — temporal-fmt\n // would read them as its own tokens by accident. gotta quote the run\n out += `'${run.value.replace(/'/g, \"''\")}'`;\n } else {\n out += run.value;\n }\n }\n }\n return out;\n}\n\n/**\n * Translates a Day.js format string to the equivalent temporal-fmt\n * token string.\n *\n * ```js\n * translateDayjsFormatString('YYYY-MM-DD HH:mm:ss'); // \"yyyy-MM-dd HH:mm:ss\"\n * translateDayjsFormatString('[Q]Q YYYY'); // \"'Q'Q yyyy\" (bracketed text stays literal)\n * ```\n *\n * Throws if the format string uses a Day.js token with no temporal-fmt\n * equivalent (`Do`, `Mo`, `Qo`, `k`, `kk`, `X`, `x`, the localized\n * `L`-family tokens) — these need to be rewritten by hand, since\n * there's no single temporal-fmt token that means the same thing.\n *\n * Note: `Do`/`Mo`/`Qo`/`k`/`kk`/`X`/`x` only have meaning in Day.js\n * once the `AdvancedFormat` (and, for `X`/`x`, base) plugins are\n * loaded — without them Day.js silently glues the parts together or\n * passes the letters through unrendered instead of erroring. This\n * function assumes the plugin is loaded, since that's the common case\n * for anyone who put these tokens in a format string on purpose.\n */\nexport function translateDayjsFormatString(formatStr: string): string {\n return translate(formatStr, DAYJS_TO_TEMPORAL_FMT, 'Day.js');\n}\n\n/**\n * Translates a date-fns format string to the equivalent temporal-fmt\n * token string. date-fns already uses Unicode-style tokens close to\n * temporal-fmt's own, so most strings pass through with only a case\n * change on the weekday tokens; the notable divergences are date-fns's\n * `D`/`DD` (day-of-year, matches temporal-fmt already) versus its `d`/\n * `dd` (day-of-month, also matches already) and the locale-dependent\n * `P`/`p` composite tokens, which have no single temporal-fmt token\n * and throw.\n */\nexport function translateDateFnsFormatString(formatStr: string): string {\n return translate(formatStr, DATE_FNS_TO_TEMPORAL_FMT, 'date-fns');\n}\n","// Runtime override registry for format() and parse(). Exists for one\n// reason: mods (see modApi.ts) need to be able to swap the real\n// implementation everywhere it's used, not just for whoever imports\n// `format` from the package root. Without this, `interval.ts`'s\n// formatRange() and `serialization.ts`'s formatSQL() would keep calling\n// the original format() forever, since they'd still hold their own\n// direct reference to it — a mod's fix would look like it worked (the\n// export changed) while half the library silently ignored it. That gap\n// is worse than not having overrides at all, so every internal call\n// site that used to `import { format } from './format.js'` now goes\n// through getFormatImpl()/getParseImpl() instead.\n//\n// format.ts and parse.ts themselves are untouched — this module sits\n// beside them, not inside them. Baseline behavior with no mods loaded\n// is exactly what it always was; this is pure indirection, not a\n// rewrite of either implementation.\n\nimport { format as baseFormat, formatToParts as baseFormatToParts } from './format.js';\nimport { parse as baseParse } from './parse.js';\nimport { safeParse as base_safeParse, tryParse as base_tryParse, parseToParts as base_parseToParts } from './parse.js';\nimport { formatDistance as base_formatDistance, formatDistanceToNow as base_formatDistanceToNow } from './formatDistance.js';\nimport { daysInYear as base_daysInYear, getQuarter as base_getQuarter, startOf as base_startOf, endOf as base_endOf } from './calendarUtils.js';\nimport { subtract as base_subtract, difference as base_difference } from './arithmetic.js';\nimport { min as base_min, max as base_max, isWeekend as base_isWeekend } from './comparison.js';\nimport { round as base_round } from './rounding.js';\nimport { parseISO as base_parseISO, formatISO as base_formatISO, formatRFC2822 as base_formatRFC2822, formatHTTPDate as base_formatHTTPDate, fromUnixSeconds as base_fromUnixSeconds, fromUnixMilliseconds as base_fromUnixMilliseconds } from './serialization.js';\nimport { totalDuration as base_totalDuration, addDuration as base_addDuration } from './duration.js';\nimport { formatRelative as base_formatRelative, formatRelativeToNow as base_formatRelativeToNow } from './relativeTime.js';\nimport { convertDigits as base_convertDigits, convertDigitsToAscii as base_convertDigitsToAscii } from './numbering.js';\nimport { intersects as base_intersects, splitInterval as base_splitInterval, formatRange as base_formatRange } from './interval.js';\nimport { recurrence as base_recurrence, take as base_take, skip as base_skip } from './recurrence.js';\nimport { isBusinessDay as base_isBusinessDay, addBusinessDays as base_addBusinessDays, differenceInBusinessDays as base_differenceInBusinessDays, nextBusinessDay as base_nextBusinessDay, previousBusinessDay as base_previousBusinessDay } from './businessCalendar.js';\nimport { holidaysBetween as base_holidaysBetween } from './holidays.js';\nimport { getTimeZone as base_getTimeZone, getOffset as base_getOffset, getOffsetNanoseconds as base_getOffsetNanoseconds, isDST as base_isDST, getTransitions as base_getTransitions } from './timezone.js';\nimport { translateDayjsFormatString as base_translateDayjsFormatString } from './codemod.js';\n\ntype FormatFn = typeof baseFormat;\ntype FormatToPartsFn = typeof baseFormatToParts;\ntype ParseFn = typeof baseParse;\n\ninterface OverrideRecord<Fn> {\n impl: Fn;\n // which mod installed this, so a collision or a \"what's active right\n // now\" query can name it instead of just saying \"something\"\n installedBy: string;\n}\n\nlet formatOverride: OverrideRecord<FormatFn> | undefined;\nlet formatToPartsOverride: OverrideRecord<FormatToPartsFn> | undefined;\nlet parseOverride: OverrideRecord<ParseFn> | undefined;\n\nexport function getFormatImpl(): FormatFn {\n return formatOverride ? formatOverride.impl : baseFormat;\n}\n\nexport function getFormatToPartsImpl(): FormatToPartsFn {\n return formatToPartsOverride ? formatToPartsOverride.impl : baseFormatToParts;\n}\n\nexport function getParseImpl(): ParseFn {\n return parseOverride ? parseOverride.impl : baseParse;\n}\n\n// Thrown on a second mod trying to override the same point — see\n// modApi.ts's ModContext.overrideFormat/overrideParse for why this is a\n// hard failure rather than last-write-wins like locale/token\n// registration: two mods silently fighting over how dates get\n// formatted is a correctness bug in whatever app depends on this\n// library, not a cosmetic surprise.\nexport class OverrideConflictError extends Error {\n constructor(\n public readonly point: string,\n public readonly existingOwner: string,\n public readonly attemptedBy: string\n ) {\n super(\n `temporal-fmt: \"${point}\" is already overridden by mod \"${existingOwner}\" — ` +\n `mod \"${attemptedBy}\" can't also override it. Only one mod may hold each override ` +\n `point; if \"${attemptedBy}\" needs \"${existingOwner}\"'s behavior included, that logic ` +\n `needs to move into whichever mod ends up owning the override, not be layered ` +\n `through a second overrideFormat()/overrideParse() call.`\n );\n this.name = 'OverrideConflictError';\n }\n}\n\nexport function setFormatOverride(impl: FormatFn, installedBy: string): void {\n if (formatOverride) throw new OverrideConflictError('format', formatOverride.installedBy, installedBy);\n formatOverride = { impl, installedBy };\n}\n\nexport function setFormatToPartsOverride(impl: FormatToPartsFn, installedBy: string): void {\n if (formatToPartsOverride) throw new OverrideConflictError('formatToParts', formatToPartsOverride.installedBy, installedBy);\n formatToPartsOverride = { impl, installedBy };\n}\n\nexport function setParseOverride(impl: ParseFn, installedBy: string): void {\n if (parseOverride) throw new OverrideConflictError('parse', parseOverride.installedBy, installedBy);\n parseOverride = { impl, installedBy };\n}\n\n// Test-only escape hatch — vitest runs all suites in one process, so\n// without this, an override installed in one test file's mod-loading\n// test would leak into every test that runs after it.\nexport function _resetOverridesForTesting(): void {\n formatOverride = undefined;\n formatToPartsOverride = undefined;\n parseOverride = undefined;\n}\n\n// Resets the 81 generated override points (see bottom of file) — split\n// from the block above so that block still reads clearly as \"the three\n// hand-written ones,\" and this one can be regenerated wholesale by\n// generate.mjs without touching hand-written code.\n\n\nimport { compileFormat as base_compileFormat } from './format.js';\nimport { compileParser as base_compileParser } from './parse.js';\nimport { parseRelative as base_parseRelative } from './parseRelative.js';\nimport { explainFormat as base_explainFormat, tokenizeFormat as base_tokenizeFormat, listTokens as base_listTokens, tokenInfo as base_tokenInfo, isValidFormat as base_isValidFormat, validateFormat as base_validateFormat, fieldForToken as base_fieldForToken } from './analyze.js';\nimport { monthsInYear as base_monthsInYear, isLeapYear as base_isLeapYear, isLeapMonth as base_isLeapMonth, weekOfYear as base_weekOfYear, weekYear as base_weekYear, getMonth as base_getMonth, getWeekday as base_getWeekday } from './calendarUtils.js';\nimport { isEqual as base_isEqual, isBefore as base_isBefore, isAfter as base_isAfter, clamp as base_clamp, isBetween as base_isBetween, isToday as base_isToday, isTomorrow as base_isTomorrow, isYesterday as base_isYesterday, isSameDay as base_isSameDay, isSameWeek as base_isSameWeek, isSameMonth as base_isSameMonth, isSameQuarter as base_isSameQuarter, isSameYear as base_isSameYear, isWeekday as base_isWeekday } from './comparison.js';\nimport { floor as base_floor, ceil as base_ceil, truncate as base_truncate } from './rounding.js';\nimport { parseRFC3339 as base_parseRFC3339, formatRFC3339 as base_formatRFC3339, parseRFC2822 as base_parseRFC2822, parseHTTPDate as base_parseHTTPDate, fromUnixMicroseconds as base_fromUnixMicroseconds, fromUnixNanoseconds as base_fromUnixNanoseconds, toUnixSeconds as base_toUnixSeconds, toUnixMilliseconds as base_toUnixMilliseconds, toUnixMicroseconds as base_toUnixMicroseconds, toUnixNanoseconds as base_toUnixNanoseconds, parseSQL as base_parseSQL, formatSQL as base_formatSQL } from './serialization.js';\nimport { formatDurationToParts as base_formatDurationToParts, parseDuration as base_parseDuration, parseISODuration as base_parseISODuration, formatISODuration as base_formatISODuration, balanceDuration as base_balanceDuration, compareDuration as base_compareDuration, subtractDuration as base_subtractDuration } from './duration.js';\nimport { getLocale as base_getLocale, hasLocale as base_hasLocale } from './localeRegistry.js';\nimport { createConfig as base_createConfig, mergeWithConfig as base_mergeWithConfig } from './config.js';\nimport { listRegisteredGrammars as base_listRegisteredGrammars } from './relativeGrammar.js';\nimport { interval as base_interval, overlaps as base_overlaps, intersection as base_intersection, union as base_union, mergeIntervals as base_mergeIntervals, formatRangeToParts as base_formatRangeToParts } from './interval.js';\nimport { between as base_between, parseRRule as base_parseRRule, formatRRule as base_formatRRule } from './recurrence.js';\nimport { createBusinessCalendar as base_createBusinessCalendar, subtractBusinessDays as base_subtractBusinessDays } from './businessCalendar.js';\nimport { nextHoliday as base_nextHoliday, previousHoliday as base_previousHoliday } from './holidays.js';\nimport { resolveZoned as base_resolveZoned, getNextTransition as base_getNextTransition, getPreviousTransition as base_getPreviousTransition, possibleInstantsFor as base_possibleInstantsFor } from './timezone.js';\nimport { getAutocompleteData as base_getAutocompleteData, getHoverDocs as base_getHoverDocs, getInlineDiagnostics as base_getInlineDiagnostics, previewFormat as base_previewFormat, getDocUrl as base_getDocUrl } from './ideData.js';\nimport { translateDateFnsFormatString as base_translateDateFnsFormatString } from './codemod.js';\n\n// --- Generated override points below ---\n// Same pattern as format/parse above, generalized: one owner per named\n// point, hard collision (not last-write-wins) because two mods silently\n// fighting over a function's behavior is a correctness bug in whatever\n// depends on this library, not a cosmetic surprise. createOverridable\n// exists so this section doesn't repeat the same five-line shape 126\n// times by hand — the behavior is identical to formatOverride/\n// parseOverride above, just factored into one generic instead of typed\n// out per function.\nfunction createOverridable<Fn>(base: Fn, pointName: string) {\n let current: OverrideRecord<Fn> | undefined;\n return {\n get: (): Fn => (current ? current.impl : base),\n set: (impl: Fn, installedBy: string): void => {\n if (current) throw new OverrideConflictError(pointName, current.installedBy, installedBy);\n current = { impl, installedBy };\n },\n /* c8 ignore start @preserve -- reset() is only ever called from\n * _resetGeneratedOverridesForTesting(), which itself is a\n * vitest-only escape hatch not exported from dist/index.js (see its\n * own doc comment below) — so this function has no path reachable\n * from test/*.test.js, which imports only the public dist/index.js\n * surface. Covered instead by vitest/modApi.unit.test.ts's afterEach\n * hook, which calls _resetGeneratedOverridesForTesting() directly\n * against src/runtime.js on every run. */\n reset: (): void => { current = undefined; },\n /* c8 ignore stop @preserve */\n };\n}\n \n\nconst compileFormatRegistry = createOverridable(base_compileFormat, 'compileFormat');\nconst compileParserRegistry = createOverridable(base_compileParser, 'compileParser');\nconst parseRelativeRegistry = createOverridable(base_parseRelative, 'parseRelative');\nconst explainFormatRegistry = createOverridable(base_explainFormat, 'explainFormat');\nconst tokenizeFormatRegistry = createOverridable(base_tokenizeFormat, 'tokenizeFormat');\nconst listTokensRegistry = createOverridable(base_listTokens, 'listTokens');\nconst tokenInfoRegistry = createOverridable(base_tokenInfo, 'tokenInfo');\nconst isValidFormatRegistry = createOverridable(base_isValidFormat, 'isValidFormat');\nconst validateFormatRegistry = createOverridable(base_validateFormat, 'validateFormat');\nconst fieldForTokenRegistry = createOverridable(base_fieldForToken, 'fieldForToken');\nconst monthsInYearRegistry = createOverridable(base_monthsInYear, 'monthsInYear');\nconst isLeapYearRegistry = createOverridable(base_isLeapYear, 'isLeapYear');\nconst isLeapMonthRegistry = createOverridable(base_isLeapMonth, 'isLeapMonth');\nconst weekOfYearRegistry = createOverridable(base_weekOfYear, 'weekOfYear');\nconst weekYearRegistry = createOverridable(base_weekYear, 'weekYear');\nconst getMonthRegistry = createOverridable(base_getMonth, 'getMonth');\nconst getWeekdayRegistry = createOverridable(base_getWeekday, 'getWeekday');\nconst isEqualRegistry = createOverridable(base_isEqual, 'isEqual');\nconst isBeforeRegistry = createOverridable(base_isBefore, 'isBefore');\nconst isAfterRegistry = createOverridable(base_isAfter, 'isAfter');\nconst clampRegistry = createOverridable(base_clamp, 'clamp');\nconst isBetweenRegistry = createOverridable(base_isBetween, 'isBetween');\nconst isTodayRegistry = createOverridable(base_isToday, 'isToday');\nconst isTomorrowRegistry = createOverridable(base_isTomorrow, 'isTomorrow');\nconst isYesterdayRegistry = createOverridable(base_isYesterday, 'isYesterday');\nconst isSameDayRegistry = createOverridable(base_isSameDay, 'isSameDay');\nconst isSameWeekRegistry = createOverridable(base_isSameWeek, 'isSameWeek');\nconst isSameMonthRegistry = createOverridable(base_isSameMonth, 'isSameMonth');\nconst isSameQuarterRegistry = createOverridable(base_isSameQuarter, 'isSameQuarter');\nconst isSameYearRegistry = createOverridable(base_isSameYear, 'isSameYear');\nconst isWeekdayRegistry = createOverridable(base_isWeekday, 'isWeekday');\nconst floorRegistry = createOverridable(base_floor, 'floor');\nconst ceilRegistry = createOverridable(base_ceil, 'ceil');\nconst truncateRegistry = createOverridable(base_truncate, 'truncate');\nconst parseRFC3339Registry = createOverridable(base_parseRFC3339, 'parseRFC3339');\nconst formatRFC3339Registry = createOverridable(base_formatRFC3339, 'formatRFC3339');\nconst parseRFC2822Registry = createOverridable(base_parseRFC2822, 'parseRFC2822');\nconst parseHTTPDateRegistry = createOverridable(base_parseHTTPDate, 'parseHTTPDate');\nconst fromUnixMicrosecondsRegistry = createOverridable(base_fromUnixMicroseconds, 'fromUnixMicroseconds');\nconst fromUnixNanosecondsRegistry = createOverridable(base_fromUnixNanoseconds, 'fromUnixNanoseconds');\nconst toUnixSecondsRegistry = createOverridable(base_toUnixSeconds, 'toUnixSeconds');\nconst toUnixMillisecondsRegistry = createOverridable(base_toUnixMilliseconds, 'toUnixMilliseconds');\nconst toUnixMicrosecondsRegistry = createOverridable(base_toUnixMicroseconds, 'toUnixMicroseconds');\nconst toUnixNanosecondsRegistry = createOverridable(base_toUnixNanoseconds, 'toUnixNanoseconds');\nconst parseSQLRegistry = createOverridable(base_parseSQL, 'parseSQL');\nconst formatSQLRegistry = createOverridable(base_formatSQL, 'formatSQL');\nconst formatDurationToPartsRegistry = createOverridable(base_formatDurationToParts, 'formatDurationToParts');\nconst parseDurationRegistry = createOverridable(base_parseDuration, 'parseDuration');\nconst parseISODurationRegistry = createOverridable(base_parseISODuration, 'parseISODuration');\nconst formatISODurationRegistry = createOverridable(base_formatISODuration, 'formatISODuration');\nconst balanceDurationRegistry = createOverridable(base_balanceDuration, 'balanceDuration');\nconst compareDurationRegistry = createOverridable(base_compareDuration, 'compareDuration');\nconst subtractDurationRegistry = createOverridable(base_subtractDuration, 'subtractDuration');\nconst getLocaleRegistry = createOverridable(base_getLocale, 'getLocale');\nconst hasLocaleRegistry = createOverridable(base_hasLocale, 'hasLocale');\nconst createConfigRegistry = createOverridable(base_createConfig, 'createConfig');\nconst mergeWithConfigRegistry = createOverridable(base_mergeWithConfig, 'mergeWithConfig');\nconst listRegisteredGrammarsRegistry = createOverridable(base_listRegisteredGrammars, 'listRegisteredGrammars');\nconst intervalRegistry = createOverridable(base_interval, 'interval');\nconst overlapsRegistry = createOverridable(base_overlaps, 'overlaps');\nconst intersectionRegistry = createOverridable(base_intersection, 'intersection');\nconst unionRegistry = createOverridable(base_union, 'union');\nconst mergeIntervalsRegistry = createOverridable(base_mergeIntervals, 'mergeIntervals');\nconst formatRangeToPartsRegistry = createOverridable(base_formatRangeToParts, 'formatRangeToParts');\nconst betweenRegistry = createOverridable(base_between, 'between');\nconst parseRRuleRegistry = createOverridable(base_parseRRule, 'parseRRule');\nconst formatRRuleRegistry = createOverridable(base_formatRRule, 'formatRRule');\nconst createBusinessCalendarRegistry = createOverridable(base_createBusinessCalendar, 'createBusinessCalendar');\nconst subtractBusinessDaysRegistry = createOverridable(base_subtractBusinessDays, 'subtractBusinessDays');\nconst nextHolidayRegistry = createOverridable(base_nextHoliday, 'nextHoliday');\nconst previousHolidayRegistry = createOverridable(base_previousHoliday, 'previousHoliday');\nconst resolveZonedRegistry = createOverridable(base_resolveZoned, 'resolveZoned');\nconst getNextTransitionRegistry = createOverridable(base_getNextTransition, 'getNextTransition');\nconst getPreviousTransitionRegistry = createOverridable(base_getPreviousTransition, 'getPreviousTransition');\nconst possibleInstantsForRegistry = createOverridable(base_possibleInstantsFor, 'possibleInstantsFor');\nconst getAutocompleteDataRegistry = createOverridable(base_getAutocompleteData, 'getAutocompleteData');\nconst getHoverDocsRegistry = createOverridable(base_getHoverDocs, 'getHoverDocs');\nconst getInlineDiagnosticsRegistry = createOverridable(base_getInlineDiagnostics, 'getInlineDiagnostics');\nconst previewFormatRegistry = createOverridable(base_previewFormat, 'previewFormat');\nconst getDocUrlRegistry = createOverridable(base_getDocUrl, 'getDocUrl');\nconst translateDateFnsFormatStringRegistry = createOverridable(base_translateDateFnsFormatString, 'translateDateFnsFormatString');\n\nexport const getCompileFormatImpl = compileFormatRegistry.get;\nexport const setCompileFormatOverride = compileFormatRegistry.set;\nexport const getCompileParserImpl = compileParserRegistry.get;\nexport const setCompileParserOverride = compileParserRegistry.set;\nexport const getParseRelativeImpl = parseRelativeRegistry.get;\nexport const setParseRelativeOverride = parseRelativeRegistry.set;\nexport const getExplainFormatImpl = explainFormatRegistry.get;\nexport const setExplainFormatOverride = explainFormatRegistry.set;\nexport const getTokenizeFormatImpl = tokenizeFormatRegistry.get;\nexport const setTokenizeFormatOverride = tokenizeFormatRegistry.set;\nexport const getListTokensImpl = listTokensRegistry.get;\nexport const setListTokensOverride = listTokensRegistry.set;\nexport const getTokenInfoImpl = tokenInfoRegistry.get;\nexport const setTokenInfoOverride = tokenInfoRegistry.set;\nexport const getIsValidFormatImpl = isValidFormatRegistry.get;\nexport const setIsValidFormatOverride = isValidFormatRegistry.set;\nexport const getValidateFormatImpl = validateFormatRegistry.get;\nexport const setValidateFormatOverride = validateFormatRegistry.set;\nexport const getFieldForTokenImpl = fieldForTokenRegistry.get;\nexport const setFieldForTokenOverride = fieldForTokenRegistry.set;\nexport const getMonthsInYearImpl = monthsInYearRegistry.get;\nexport const setMonthsInYearOverride = monthsInYearRegistry.set;\nexport const getIsLeapYearImpl = isLeapYearRegistry.get;\nexport const setIsLeapYearOverride = isLeapYearRegistry.set;\nexport const getIsLeapMonthImpl = isLeapMonthRegistry.get;\nexport const setIsLeapMonthOverride = isLeapMonthRegistry.set;\nexport const getWeekOfYearImpl = weekOfYearRegistry.get;\nexport const setWeekOfYearOverride = weekOfYearRegistry.set;\nexport const getWeekYearImpl = weekYearRegistry.get;\nexport const setWeekYearOverride = weekYearRegistry.set;\nexport const getGetMonthImpl = getMonthRegistry.get;\nexport const setGetMonthOverride = getMonthRegistry.set;\nexport const getGetWeekdayImpl = getWeekdayRegistry.get;\nexport const setGetWeekdayOverride = getWeekdayRegistry.set;\nexport const getIsEqualImpl = isEqualRegistry.get;\nexport const setIsEqualOverride = isEqualRegistry.set;\nexport const getIsBeforeImpl = isBeforeRegistry.get;\nexport const setIsBeforeOverride = isBeforeRegistry.set;\nexport const getIsAfterImpl = isAfterRegistry.get;\nexport const setIsAfterOverride = isAfterRegistry.set;\nexport const getClampImpl = clampRegistry.get;\nexport const setClampOverride = clampRegistry.set;\nexport const getIsBetweenImpl = isBetweenRegistry.get;\nexport const setIsBetweenOverride = isBetweenRegistry.set;\nexport const getIsTodayImpl = isTodayRegistry.get;\nexport const setIsTodayOverride = isTodayRegistry.set;\nexport const getIsTomorrowImpl = isTomorrowRegistry.get;\nexport const setIsTomorrowOverride = isTomorrowRegistry.set;\nexport const getIsYesterdayImpl = isYesterdayRegistry.get;\nexport const setIsYesterdayOverride = isYesterdayRegistry.set;\nexport const getIsSameDayImpl = isSameDayRegistry.get;\nexport const setIsSameDayOverride = isSameDayRegistry.set;\nexport const getIsSameWeekImpl = isSameWeekRegistry.get;\nexport const setIsSameWeekOverride = isSameWeekRegistry.set;\nexport const getIsSameMonthImpl = isSameMonthRegistry.get;\nexport const setIsSameMonthOverride = isSameMonthRegistry.set;\nexport const getIsSameQuarterImpl = isSameQuarterRegistry.get;\nexport const setIsSameQuarterOverride = isSameQuarterRegistry.set;\nexport const getIsSameYearImpl = isSameYearRegistry.get;\nexport const setIsSameYearOverride = isSameYearRegistry.set;\nexport const getIsWeekdayImpl = isWeekdayRegistry.get;\nexport const setIsWeekdayOverride = isWeekdayRegistry.set;\nexport const getFloorImpl = floorRegistry.get;\nexport const setFloorOverride = floorRegistry.set;\nexport const getCeilImpl = ceilRegistry.get;\nexport const setCeilOverride = ceilRegistry.set;\nexport const getTruncateImpl = truncateRegistry.get;\nexport const setTruncateOverride = truncateRegistry.set;\nexport const getParseRFC3339Impl = parseRFC3339Registry.get;\nexport const setParseRFC3339Override = parseRFC3339Registry.set;\nexport const getFormatRFC3339Impl = formatRFC3339Registry.get;\nexport const setFormatRFC3339Override = formatRFC3339Registry.set;\nexport const getParseRFC2822Impl = parseRFC2822Registry.get;\nexport const setParseRFC2822Override = parseRFC2822Registry.set;\nexport const getParseHTTPDateImpl = parseHTTPDateRegistry.get;\nexport const setParseHTTPDateOverride = parseHTTPDateRegistry.set;\nexport const getFromUnixMicrosecondsImpl = fromUnixMicrosecondsRegistry.get;\nexport const setFromUnixMicrosecondsOverride = fromUnixMicrosecondsRegistry.set;\nexport const getFromUnixNanosecondsImpl = fromUnixNanosecondsRegistry.get;\nexport const setFromUnixNanosecondsOverride = fromUnixNanosecondsRegistry.set;\nexport const getToUnixSecondsImpl = toUnixSecondsRegistry.get;\nexport const setToUnixSecondsOverride = toUnixSecondsRegistry.set;\nexport const getToUnixMillisecondsImpl = toUnixMillisecondsRegistry.get;\nexport const setToUnixMillisecondsOverride = toUnixMillisecondsRegistry.set;\nexport const getToUnixMicrosecondsImpl = toUnixMicrosecondsRegistry.get;\nexport const setToUnixMicrosecondsOverride = toUnixMicrosecondsRegistry.set;\nexport const getToUnixNanosecondsImpl = toUnixNanosecondsRegistry.get;\nexport const setToUnixNanosecondsOverride = toUnixNanosecondsRegistry.set;\nexport const getParseSQLImpl = parseSQLRegistry.get;\nexport const setParseSQLOverride = parseSQLRegistry.set;\nexport const getFormatSQLImpl = formatSQLRegistry.get;\nexport const setFormatSQLOverride = formatSQLRegistry.set;\nexport const getFormatDurationToPartsImpl = formatDurationToPartsRegistry.get;\nexport const setFormatDurationToPartsOverride = formatDurationToPartsRegistry.set;\nexport const getParseDurationImpl = parseDurationRegistry.get;\nexport const setParseDurationOverride = parseDurationRegistry.set;\nexport const getParseISODurationImpl = parseISODurationRegistry.get;\nexport const setParseISODurationOverride = parseISODurationRegistry.set;\nexport const getFormatISODurationImpl = formatISODurationRegistry.get;\nexport const setFormatISODurationOverride = formatISODurationRegistry.set;\nexport const getBalanceDurationImpl = balanceDurationRegistry.get;\nexport const setBalanceDurationOverride = balanceDurationRegistry.set;\nexport const getCompareDurationImpl = compareDurationRegistry.get;\nexport const setCompareDurationOverride = compareDurationRegistry.set;\nexport const getSubtractDurationImpl = subtractDurationRegistry.get;\nexport const setSubtractDurationOverride = subtractDurationRegistry.set;\nexport const getGetLocaleImpl = getLocaleRegistry.get;\nexport const setGetLocaleOverride = getLocaleRegistry.set;\nexport const getHasLocaleImpl = hasLocaleRegistry.get;\nexport const setHasLocaleOverride = hasLocaleRegistry.set;\nexport const getCreateConfigImpl = createConfigRegistry.get;\nexport const setCreateConfigOverride = createConfigRegistry.set;\nexport const getMergeWithConfigImpl = mergeWithConfigRegistry.get;\nexport const setMergeWithConfigOverride = mergeWithConfigRegistry.set;\nexport const getListRegisteredGrammarsImpl = listRegisteredGrammarsRegistry.get;\nexport const setListRegisteredGrammarsOverride = listRegisteredGrammarsRegistry.set;\nexport const getIntervalImpl = intervalRegistry.get;\nexport const setIntervalOverride = intervalRegistry.set;\nexport const getOverlapsImpl = overlapsRegistry.get;\nexport const setOverlapsOverride = overlapsRegistry.set;\nexport const getIntersectionImpl = intersectionRegistry.get;\nexport const setIntersectionOverride = intersectionRegistry.set;\nexport const getUnionImpl = unionRegistry.get;\nexport const setUnionOverride = unionRegistry.set;\nexport const getMergeIntervalsImpl = mergeIntervalsRegistry.get;\nexport const setMergeIntervalsOverride = mergeIntervalsRegistry.set;\nexport const getFormatRangeToPartsImpl = formatRangeToPartsRegistry.get;\nexport const setFormatRangeToPartsOverride = formatRangeToPartsRegistry.set;\nexport const getBetweenImpl = betweenRegistry.get;\nexport const setBetweenOverride = betweenRegistry.set;\nexport const getParseRRuleImpl = parseRRuleRegistry.get;\nexport const setParseRRuleOverride = parseRRuleRegistry.set;\nexport const getFormatRRuleImpl = formatRRuleRegistry.get;\nexport const setFormatRRuleOverride = formatRRuleRegistry.set;\nexport const getCreateBusinessCalendarImpl = createBusinessCalendarRegistry.get;\nexport const setCreateBusinessCalendarOverride = createBusinessCalendarRegistry.set;\nexport const getSubtractBusinessDaysImpl = subtractBusinessDaysRegistry.get;\nexport const setSubtractBusinessDaysOverride = subtractBusinessDaysRegistry.set;\nexport const getNextHolidayImpl = nextHolidayRegistry.get;\nexport const setNextHolidayOverride = nextHolidayRegistry.set;\nexport const getPreviousHolidayImpl = previousHolidayRegistry.get;\nexport const setPreviousHolidayOverride = previousHolidayRegistry.set;\nexport const getResolveZonedImpl = resolveZonedRegistry.get;\nexport const setResolveZonedOverride = resolveZonedRegistry.set;\nexport const getGetNextTransitionImpl = getNextTransitionRegistry.get;\nexport const setGetNextTransitionOverride = getNextTransitionRegistry.set;\nexport const getGetPreviousTransitionImpl = getPreviousTransitionRegistry.get;\nexport const setGetPreviousTransitionOverride = getPreviousTransitionRegistry.set;\nexport const getPossibleInstantsForImpl = possibleInstantsForRegistry.get;\nexport const setPossibleInstantsForOverride = possibleInstantsForRegistry.set;\nexport const getGetAutocompleteDataImpl = getAutocompleteDataRegistry.get;\nexport const setGetAutocompleteDataOverride = getAutocompleteDataRegistry.set;\nexport const getGetHoverDocsImpl = getHoverDocsRegistry.get;\nexport const setGetHoverDocsOverride = getHoverDocsRegistry.set;\nexport const getGetInlineDiagnosticsImpl = getInlineDiagnosticsRegistry.get;\nexport const setGetInlineDiagnosticsOverride = getInlineDiagnosticsRegistry.set;\nexport const getPreviewFormatImpl = previewFormatRegistry.get;\nexport const setPreviewFormatOverride = previewFormatRegistry.set;\nexport const getGetDocUrlImpl = getDocUrlRegistry.get;\nexport const setGetDocUrlOverride = getDocUrlRegistry.set;\nexport const getTranslateDateFnsFormatStringImpl = translateDateFnsFormatStringRegistry.get;\nexport const setTranslateDateFnsFormatStringOverride = translateDateFnsFormatStringRegistry.set;\n\n// Resets the 81 generated override points above — split from\n// _resetOverridesForTesting so that one still reads clearly as \"the\n// three hand-written ones,\" and this one can be regenerated wholesale\n// by generate.mjs without touching hand-written code.\nexport function _resetGeneratedOverridesForTesting(): void {\n compileFormatRegistry.reset();\n compileParserRegistry.reset();\n parseRelativeRegistry.reset();\n explainFormatRegistry.reset();\n tokenizeFormatRegistry.reset();\n listTokensRegistry.reset();\n tokenInfoRegistry.reset();\n isValidFormatRegistry.reset();\n validateFormatRegistry.reset();\n fieldForTokenRegistry.reset();\n monthsInYearRegistry.reset();\n isLeapYearRegistry.reset();\n isLeapMonthRegistry.reset();\n weekOfYearRegistry.reset();\n weekYearRegistry.reset();\n getMonthRegistry.reset();\n getWeekdayRegistry.reset();\n isEqualRegistry.reset();\n isBeforeRegistry.reset();\n isAfterRegistry.reset();\n clampRegistry.reset();\n isBetweenRegistry.reset();\n isTodayRegistry.reset();\n isTomorrowRegistry.reset();\n isYesterdayRegistry.reset();\n isSameDayRegistry.reset();\n isSameWeekRegistry.reset();\n isSameMonthRegistry.reset();\n isSameQuarterRegistry.reset();\n isSameYearRegistry.reset();\n isWeekdayRegistry.reset();\n floorRegistry.reset();\n ceilRegistry.reset();\n truncateRegistry.reset();\n parseRFC3339Registry.reset();\n formatRFC3339Registry.reset();\n parseRFC2822Registry.reset();\n parseHTTPDateRegistry.reset();\n fromUnixMicrosecondsRegistry.reset();\n fromUnixNanosecondsRegistry.reset();\n toUnixSecondsRegistry.reset();\n toUnixMillisecondsRegistry.reset();\n toUnixMicrosecondsRegistry.reset();\n toUnixNanosecondsRegistry.reset();\n parseSQLRegistry.reset();\n formatSQLRegistry.reset();\n formatDurationToPartsRegistry.reset();\n parseDurationRegistry.reset();\n parseISODurationRegistry.reset();\n formatISODurationRegistry.reset();\n balanceDurationRegistry.reset();\n compareDurationRegistry.reset();\n subtractDurationRegistry.reset();\n getLocaleRegistry.reset();\n hasLocaleRegistry.reset();\n createConfigRegistry.reset();\n mergeWithConfigRegistry.reset();\n listRegisteredGrammarsRegistry.reset();\n intervalRegistry.reset();\n overlapsRegistry.reset();\n intersectionRegistry.reset();\n unionRegistry.reset();\n mergeIntervalsRegistry.reset();\n formatRangeToPartsRegistry.reset();\n betweenRegistry.reset();\n parseRRuleRegistry.reset();\n formatRRuleRegistry.reset();\n createBusinessCalendarRegistry.reset();\n subtractBusinessDaysRegistry.reset();\n nextHolidayRegistry.reset();\n previousHolidayRegistry.reset();\n resolveZonedRegistry.reset();\n getNextTransitionRegistry.reset();\n getPreviousTransitionRegistry.reset();\n possibleInstantsForRegistry.reset();\n getAutocompleteDataRegistry.reset();\n getHoverDocsRegistry.reset();\n getInlineDiagnosticsRegistry.reset();\n previewFormatRegistry.reset();\n getDocUrlRegistry.reset();\n translateDateFnsFormatStringRegistry.reset();\n}\n","// Intervals / ranges. An interval is a pair of\n// (start, end) Temporal values with bounds semantics: open, closed,\n// or half-open. Operations: contains, overlaps, intersects, isBefore,\n// isAfter, intersection, union, difference, subtract, mergeIntervals,\n// splitInterval. Plus formatRange / formatRangeToParts with intelligent\n// collapsing.\n//\n// All operations are field-based (no instanceof), matching the rest of\n// the library. Internally uses the comparison helpers from comparison.ts\n// to order endpoints.\n\nimport { compare } from './comparison.js';\nimport { formatToParts, type FormattedPart } from './format.js';\nimport { getFormatImpl } from './runtime.js';\nimport { asDateFieldView, type DateFieldView } from './calendarUtils.js';\nimport { normalizeLocaleTag } from './localeVocab.js';\nimport type { FormatOptions } from './tokens.js';\n\nexport type IntervalBounds = 'open' | 'closed' | 'half-open-start' | 'half-open-end';\n\nexport interface Interval {\n start: unknown;\n end: unknown;\n bounds: IntervalBounds;\n}\n\nexport function interval(start: unknown, end: unknown, bounds: IntervalBounds = 'closed'): Interval {\n // Validate that start ≤ end, otherwise the interval is malformed.\n const cmp = compare(start, end);\n if (cmp > 0) {\n throw new Error(\n `temporal-fmt: interval start must be ≤ end (got start > end). Pass them in chronological order.`\n );\n }\n return { start, end, bounds };\n}\n\n// Inclusive containment check accounting for bounds semantics.\n// - 'closed': [start, end] — both endpoints included\n// - 'open': (start, end) — neither endpoint included\n// - 'half-open-start': (start, end] — start excluded, end included\n// - 'half-open-end': [start, end) — start included, end excluded\nexport function contains(iv: Interval, value: unknown): boolean {\n const startCmp = compare(value, iv.start);\n const endCmp = compare(value, iv.end);\n const afterStart = iv.bounds === 'open' || iv.bounds === 'half-open-end'\n ? startCmp > 0\n : startCmp >= 0;\n const beforeEnd = iv.bounds === 'open' || iv.bounds === 'half-open-start'\n ? endCmp < 0\n : endCmp <= 0;\n return afterStart && beforeEnd;\n}\n\n// Two intervals overlap iff their ranges intersect, regardless of bounds.\n// intersects() is the boolean form; intersection() returns the actual\n// overlap interval.\nexport function overlaps(a: Interval, b: Interval): boolean {\n return intersects(a, b);\n}\n\nexport function intersects(a: Interval, b: Interval): boolean {\n // a is entirely before b: a.end < b.start\n if (compare(a.end, b.start) < 0) return false;\n // a is entirely after b: a.start > b.end\n if (compare(a.start, b.end) > 0) return false;\n // Touching endpoints with both-closed bounds counts as overlap;\n // open bounds would not. To keep it simple, touching counts.\n return true;\n}\n\nexport function isBefore(a: Interval, b: Interval): boolean {\n return compare(a.end, b.start) < 0;\n}\n\nexport function isAfter(a: Interval, b: Interval): boolean {\n return compare(a.start, b.end) > 0;\n}\n\n// Returns the intersection of two intervals, or null if they don't\n// overlap. The result's bounds are the more restrictive of the two\n// inputs (closed ∩ open = open, etc.).\nexport function intersection(a: Interval, b: Interval): Interval | null {\n if (!intersects(a, b)) return null;\n const start = compare(a.start, b.start) >= 0 ? a.start : b.start;\n const end = compare(a.end, b.end) <= 0 ? a.end : b.end;\n // Compute resulting bounds: take the more restrictive at each endpoint.\n // If a.start === b.start, the more restrictive of (a.bounds, b.bounds)\n // at that endpoint wins.\n const startBoundsOpen = (a.bounds === 'open' || a.bounds === 'half-open-end')\n || (b.bounds === 'open' || b.bounds === 'half-open-end');\n const endBoundsOpen = (a.bounds === 'open' || a.bounds === 'half-open-start')\n || (b.bounds === 'open' || b.bounds === 'half-open-start');\n const bounds: IntervalBounds = startBoundsOpen && endBoundsOpen ? 'open'\n : startBoundsOpen ? 'half-open-end'\n : endBoundsOpen ? 'half-open-start'\n : 'closed';\n return { start, end, bounds };\n}\n\n// Returns the union of two intervals (the smallest interval containing\n// both), or null if they don't overlap (caller should use mergeIntervals\n// for that case).\nexport function union(a: Interval, b: Interval): Interval | null {\n if (!intersects(a, b)) return null;\n const start = compare(a.start, b.start) <= 0 ? a.start : b.start;\n const end = compare(a.end, b.end) >= 0 ? a.end : b.end;\n // Union's bounds are the less restrictive at each endpoint.\n const startBoundsOpen = (a.bounds === 'open' || a.bounds === 'half-open-end')\n && (b.bounds === 'open' || b.bounds === 'half-open-end');\n const endBoundsOpen = (a.bounds === 'open' || a.bounds === 'half-open-start')\n && (b.bounds === 'open' || b.bounds === 'half-open-start');\n const bounds: IntervalBounds = startBoundsOpen && endBoundsOpen ? 'open'\n : startBoundsOpen ? 'half-open-end'\n : endBoundsOpen ? 'half-open-start'\n : 'closed';\n return { start, end, bounds };\n}\n\n// Returns the part of `a` that is not in `b`. May produce 0, 1, or 2\n// intervals depending on the overlap shape.\n//\n// Bounds semantics: each surviving piece keeps the inclusivity of the\n// original endpoint it inherits from `a`, and the endpoint created by the\n// cut is always exclusive (it is `b`'s edge, which belongs to the removed\n// overlap). The old implementation derived both bounds from a lossy\n// helper that collapsed several of these combinations — the pieces'\n// endpoints were right, but the bounds metadata was stricter than the\n// actual remainder for open/half-open inputs.\nexport function difference(a: Interval, b: Interval): Interval[] {\n if (!intersects(a, b)) return [a];\n const result: Interval[] = [];\n // Does `a` include its own start / end?\n const aStartIncluded = a.bounds === 'closed' || a.bounds === 'half-open-end';\n const aEndIncluded = a.bounds === 'closed' || a.bounds === 'half-open-start';\n // Part of `a` before `b` starts: [a.start, b.start) — start inclusivity\n // inherited from a, cut end always exclusive.\n if (compare(a.start, b.start) < 0) {\n result.push({ start: a.start, end: b.start, bounds: aStartIncluded ? 'half-open-end' : 'open' });\n }\n // Part of `a` after `b` ends: (b.end, a.end] — cut start always\n // exclusive, end inclusivity inherited from a.\n if (compare(a.end, b.end) > 0) {\n result.push({ start: b.end, end: a.end, bounds: aEndIncluded ? 'half-open-start' : 'open' });\n }\n return result;\n}\n\n// Alias for difference() — \"subtract\" reads more naturally at some\n// call sites than \"difference\" does.\nexport const subtract = difference;\n\n// Merges a list of intervals, combining overlapping ones. Returns a\n// sorted list of disjoint intervals. The inputs are treated as\n// immutable — the merged result carries shallow copies of any interval\n// object it extends, so a caller's own `end` reference is never\n// reassigned under them (mergeIntervals used to write `last.end =\n// current.end` straight into the caller's object).\nexport function mergeIntervals(intervals: Interval[]): Interval[] {\n if (intervals.length === 0) return [];\n const sorted = [...intervals].sort((a, b) => compare(a.start, b.start));\n const result: Interval[] = [{ ...sorted[0]! }];\n for (let i = 1; i < sorted.length; i++) {\n const current = sorted[i]!;\n const last = result[result.length - 1]!;\n if (intersects(last, current) || compare(last.end, current.start) === 0) {\n // Merge into last.\n if (compare(current.end, last.end) > 0) {\n last.end = current.end;\n }\n } else {\n result.push(current);\n }\n }\n return result;\n}\n\n// Widest instant JS Date can represent (±8.64e15 ms, i.e. ±100,000,000\n// days from the Unix epoch). splitInterval rebuilds endpoints via Date,\n// so anything outside this window would silently produce Invalid Date\n// objects with NaN year/month/day fields — reject it descriptively\n// instead.\nconst MAX_DATE_MS = 8.64e15;\n\n// Splits an interval into N equal sub-intervals. Throws if N ≤ 0.\n// Equality is by ms-distance between start and end — for date ranges\n// this approximates \"equal time slices\", which is the most useful\n// interpretation. For calendar-bound splits (e.g. \"split this month\n// into weeks\"), callers should use recurrence() instead.\nexport function splitInterval(iv: Interval, n: number): Interval[] {\n if (n <= 0) throw new Error(`temporal-fmt: splitInterval requires n > 0 (got ${n}).`);\n if (n === 1) return [iv];\n const startFields = asDateFieldView(iv.start) as DateFieldView & { hour?: number; minute?: number; second?: number; millisecond?: number };\n const endFields = asDateFieldView(iv.end) as DateFieldView & { hour?: number; minute?: number; second?: number; millisecond?: number };\n const startMs = toMs(startFields);\n const endMs = toMs(endFields);\n if (Math.abs(startMs) > MAX_DATE_MS || Math.abs(endMs) > MAX_DATE_MS) {\n throw new RangeError(\n `temporal-fmt: splitInterval() endpoints are outside the representable Date range ` +\n `(approximately ±275,760 years). Split the interval into smaller ranges first.`\n );\n }\n const step = (endMs - startMs) / n;\n const result: Interval[] = [];\n for (let i = 0; i < n; i++) {\n const sliceStart = startMs + i * step;\n const sliceEnd = i === n - 1 ? endMs : sliceStart + step;\n result.push({\n start: fromMs(sliceStart, startFields),\n end: fromMs(sliceEnd, endFields),\n bounds: i === 0 ? iv.bounds : 'half-open-start',\n });\n }\n return result;\n}\n\nfunction toMs(v: DateFieldView & { hour?: number; minute?: number; second?: number; millisecond?: number }): number {\n // Reuse the same day-count math arithmetic.ts uses, inlined.\n const y = v.year!, m = v.month!, d = v.day!;\n const y2 = m <= 2 ? y - 1 : y;\n const era = Math.floor((y2 >= 0 ? y2 : y2 - 399) / 400);\n const yoe = y2 - era * 400;\n const m2 = m > 2 ? m - 3 : m + 9;\n const doy = Math.floor((153 * m2 + 2) / 5) + d - 1;\n const doe = yoe * 365 + Math.floor(yoe / 4) - Math.floor(yoe / 100) + doy;\n const days = era * 146097 + doe - 719468;\n return days * 86_400_000\n + (v.hour ?? 0) * 3_600_000\n + (v.minute ?? 0) * 60_000\n + (v.second ?? 0) * 1_000\n + (v.millisecond ?? 0);\n}\n\nfunction fromMs(ms: number, base: DateFieldView & { hour?: number; minute?: number; second?: number; millisecond?: number }): DateFieldView {\n const MS_PER_DAY = 86_400_000;\n const dayOverflow = Math.floor(ms / MS_PER_DAY);\n let withinDay = ms % MS_PER_DAY;\n if (withinDay < 0) withinDay += MS_PER_DAY;\n const hour = Math.floor(withinDay / 3_600_000);\n const minute = Math.floor((withinDay % 3_600_000) / 60_000);\n const second = Math.floor((withinDay % 60_000) / 1_000);\n const millisecond = withinDay % 1_000;\n // `ms` (and therefore `dayOverflow`) is already an absolute epoch-ms /\n // epoch-day value — toMs() computed it via Howard Hinnant's algorithm\n // from scratch, not as an offset from `base`. So the date only needs\n // reconstructing from the Unix epoch itself; `base` is just a template\n // for whatever extra (non-date) fields get spread into the result.\n // (Previously this added dayOverflow on top of base's own epoch-ms,\n // double-counting base's offset and landing tens of thousands of days\n // away from the intended date for any non-epoch base.)\n const newMs = dayOverflow * MS_PER_DAY;\n const d = new Date(newMs);\n return {\n ...base,\n year: d.getUTCFullYear(),\n month: d.getUTCMonth() + 1,\n day: d.getUTCDate(),\n hour,\n minute,\n second,\n millisecond,\n };\n}\n\n// Formats an interval as a single string, collapsing shared fields.\n// E.g. \"August 4 – August 6, 2026\" rather than \"August 4, 2026 – August 6, 2026\".\n// Uses Intl.DateTimeFormat's formatRange when available (most engines),\n// falling back to format(start, fmt) + '–' + format(end, fmt) when not.\n\nexport function formatRange(\n iv: Interval,\n formatStr: string,\n options: FormatOptions = {},\n): string {\n // The formatStr parameter is this function's contract — the caller\n // asked for their token format on both endpoints. Honor it first:\n // format each side with the caller's format string and join with an\n // en dash. (This used to try Intl.DateTimeFormat.formatRange() first,\n // which ignores formatStr entirely — formatRange(iv, 'yyyy-MM-dd')\n // silently returned locale-default output like \"8/4/2026 – 8/6/2026\"\n // instead of \"2026-08-04 – 2026-08-06\".) Intl's range collapsing is\n // kept as a fallback for inputs the token path can't render.\n try {\n const format = getFormatImpl();\n const startStr = format(iv.start as Parameters<typeof format>[0], formatStr, options);\n const endStr = format(iv.end as Parameters<typeof format>[0], formatStr, options);\n return `${startStr} – ${endStr}`;\n } catch (err) {\n // Fallback: Intl.DateTimeFormat.formatRange is the standard\n // mechanism with native field-collapse behavior, but it has no\n // knowledge of the caller's token format string.\n try {\n const fmt = new Intl.DateTimeFormat(normalizeLocaleTag(options.locale ?? 'en-US'), {});\n // Cast the interval endpoints to Date for the Intl call. Both\n // endpoints must be Temporal values that can convert to a Date;\n // for non-ZonedDateTime values we synthesize a Date via the field\n // shape (year/month/day/hour/...).\n const startDate = toJSDate(iv.start);\n const endDate = toJSDate(iv.end);\n return fmt.formatRange(startDate, endDate);\n } catch {\n // Neither path could render — surface the token-path error, since\n // the formatStr contract is the primary one.\n throw err;\n }\n }\n}\n\nexport function formatRangeToParts(\n iv: Interval,\n formatStr: string,\n options: FormatOptions = {},\n): FormattedPart[] {\n // Best-effort: returns formatToParts for the start, then a literal\n // \" – \" part, then formatToParts for the end. Doesn't currently\n // expose Intl.DateTimeFormat.formatRangeToParts's collapsed shape —\n // that would require mapping Intl's part types back to temporal-fmt's\n // token strings, which is locale-dependent and not stable across\n // engines.\n const startParts = formatToParts(iv.start as Parameters<typeof formatToParts>[0], formatStr, options);\n const endParts = formatToParts(iv.end as Parameters<typeof formatToParts>[0], formatStr, options);\n const result: FormattedPart[] = [...startParts];\n result.push({ type: 'literal', value: ' – ' });\n result.push(...endParts);\n return result;\n}\n\nfunction toJSDate(value: unknown): Date {\n const v = value as { year?: number; month?: number; day?: number; hour?: number; minute?: number; second?: number; millisecond?: number; toInstant?: () => { epochMilliseconds: number } };\n if (typeof v?.toInstant === 'function') {\n return new Date(v.toInstant().epochMilliseconds);\n }\n if (typeof v?.year === 'number' && typeof v?.month === 'number' && typeof v?.day === 'number') {\n return new Date(Date.UTC(v.year, v.month - 1, v.day, v.hour ?? 0, v.minute ?? 0, v.second ?? 0, v.millisecond ?? 0));\n }\n throw new Error(`temporal-fmt: formatRange() expected Temporal values with year/month/day, got ${typeof value}.`);\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,IAAM,0BAA0B;AAEhC,IAAM,qBAAwC,CAAC;AAExC,SAAS,wBAAwB,SAAgC;AACtE,MAAI,OAAO,QAAQ,aAAa,YAAY,QAAQ,SAAS,WAAW,GAAG;AACzE,UAAM,IAAI,MAAM,6EAA6E;AAAA,EAC/F;AACA,MAAI,CAAC,MAAM,QAAQ,QAAQ,QAAQ,KAAK,QAAQ,SAAS,WAAW,GAAG;AACrE,UAAM,IAAI,MAAM,sEAAsE;AAAA,EACxF;AAEA,QAAM,cAAc,mBAAmB,UAAU,CAAC,MAAM,EAAE,aAAa,QAAQ,QAAQ;AACvF,MAAI,eAAe,GAAG;AACpB,uBAAmB,WAAW,IAA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