temporal-fmt 0.9.2 → 0.9.3

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 (36) hide show
  1. package/README.md +166 -1
  2. package/dist/chunk-4JDAJSEM.js +35 -0
  3. package/dist/chunk-4JDAJSEM.js.map +1 -0
  4. package/dist/{chunk-F4RGUDA3.js → chunk-4XRE37WT.js} +2 -2
  5. package/dist/chunk-GMGZZG6I.js +2 -0
  6. package/dist/chunk-GMGZZG6I.js.map +1 -0
  7. package/dist/{chunk-R52YOKI3.js → chunk-NPKJ7QFK.js} +2 -2
  8. package/dist/{chunk-NBXF7V5B.js → chunk-R4YEFOVE.js} +2 -2
  9. package/dist/{chunk-4JWGUR4O.js → chunk-SSPABEUR.js} +2 -2
  10. package/dist/format.cjs +5 -5
  11. package/dist/format.cjs.map +1 -1
  12. package/dist/format.js +1 -1
  13. package/dist/index.cjs +24 -24
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.js +2 -2
  16. package/dist/index.js.map +1 -1
  17. package/dist/interval.cjs +2 -2
  18. package/dist/interval.cjs.map +1 -1
  19. package/dist/interval.js +1 -1
  20. package/dist/parse.cjs +9 -9
  21. package/dist/parse.cjs.map +1 -1
  22. package/dist/parse.js +1 -1
  23. package/dist/pattern.d.cts +1 -0
  24. package/dist/pattern.d.ts +1 -0
  25. package/dist/relativeTime.cjs +1 -1
  26. package/dist/relativeTime.cjs.map +1 -1
  27. package/dist/relativeTime.js +1 -1
  28. package/package.json +1 -1
  29. package/dist/chunk-C5YESWFT.js +0 -2
  30. package/dist/chunk-C5YESWFT.js.map +0 -1
  31. package/dist/chunk-YB6YAG7E.js +0 -35
  32. package/dist/chunk-YB6YAG7E.js.map +0 -1
  33. /package/dist/{chunk-F4RGUDA3.js.map → chunk-4XRE37WT.js.map} +0 -0
  34. /package/dist/{chunk-R52YOKI3.js.map → chunk-NPKJ7QFK.js.map} +0 -0
  35. /package/dist/{chunk-NBXF7V5B.js.map → chunk-R4YEFOVE.js.map} +0 -0
  36. /package/dist/{chunk-4JWGUR4O.js.map → chunk-SSPABEUR.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/tokens.ts"],"sourcesContent":["import { getTemporal, subscribeToTemporalChanges } from './temporalProvider.js';\nimport { canonicalCacheKey, getCustomVocab, normalizeLocaleTag } from './localeVocab.js';\nimport { InvalidLocaleError } from './errors.js';\nimport { isoWeekYearAndWeek, dayOfYear } from './isoWeek.js';\n\nexport function pad(n: number, len: number): string {\n // padStart pads the whole string, sign included, so pad(-45, 4) used to\n // come out \"0-45\" instead of \"-045\" — split the sign off first.\n const negative = n < 0;\n const digits = String(Math.abs(n)).padStart(len, '0');\n return negative ? '-' + digits : digits;\n}\n\n// Combines the three sub-second fields Temporal exposes into one 9-digit\n// nanosecond-of-second value, then truncates (never rounds) to the\n// requested width. Truncating matches what every digit-width token in\n// this library already does elsewhere (yy, MM, dd, ...) — the token\n// asked for N digits of precision, not a rounded N-digit approximation.\n// A caller asking for SSS on a value with nanosecond precision gets the\n// leading 3 digits of it, same as they'd get the leading 3 digits of any\n// other multi-digit field this library formats.\n//\n// Attached to pad() rather than declared standalone: the bundler's\n// per-function coverage instrumentation attributes hits to each of the\n// 9 fraction-token arrow functions individually but not to a shared\n// helper they all close over, so a correctly-exercised helper still\n// shows as 0 hits under c8. pad() itself is called directly all over\n// this file and is reliably attributed — routing through it here keeps\n// the coverage numbers honest without duplicating the slice logic\n// across every token entry below.\npad.fraction = function formatFraction(t: TemporalLike, width: number): string {\n const nanoOfSecond = t.millisecond! * 1_000_000 + (t.microsecond ?? 0) * 1_000 + (t.nanosecond ?? 0);\n return pad(nanoOfSecond, 9).slice(0, width);\n};\n\n// Not every field exists on every Temporal type (PlainDate has no .hour,\n// etc). Callers check for undefined before formatting a token.\nexport interface TemporalLike {\n year?: number;\n month?: number;\n day?: number;\n hour?: number;\n minute?: number;\n second?: number;\n millisecond?: number;\n microsecond?: number;\n nanosecond?: number;\n timeZoneId?: string;\n // ZonedDateTime.prototype.offset — `±HH:MM` (6 chars) for any modern\n // date, but pre-1900 local-mean-time zones (e.g. America/New_York\n // before 1883) surface a seconds component too: `±HH:MM:SS` (9\n // chars). Format-side offset tokens must check the length rather\n // than assume 6. Parse-side writes a canonicalized `+HH:MM` here\n // before handing it to Temporal.ZonedDateTime.from as the\n // `timeZone` value.\n offset?: string;\n dayOfWeek?: number; // 1=Mon, 7=Sun, per Temporal spec\n calendarId?: string;\n toInstant?: () => unknown;\n toLocaleString?: (locale: string, options: Intl.DateTimeFormatOptions) => string;\n}\n\nexport interface FormatOptions {\n /** BCP 47 locale tag, e.g. 'en-US', 'fr-FR', 'ar-EG'. Defaults to 'en-US'. */\n locale?: string;\n /**\n * When set on parse(), opts into the lenient split heuristic for ambiguous\n * glued numeric runs (e.g. \"121\" against \"Md\"). Default (false) keeps\n * parse()'s strict behavior — throw on ambiguity rather than guess.\n * See README \"Lenient parse mode\" for the heuristic and why it's opt-in.\n */\n lenient?: boolean;\n}\n\nexport const DEFAULT_LOCALE = 'en-US';\n\n// Intl.DateTimeFormat is expensive to construct and format() can run in a\n// loop (rendering a table of dates), so cache by (locale, options).\nconst formatterCache = new Map<string, Intl.DateTimeFormat>();\nconst MAX_CACHE_SIZE = 500;\n\nfunction getFormatter(locale: string, options: Intl.DateTimeFormatOptions): Intl.DateTimeFormat {\n const key = JSON.stringify([canonicalCacheKey(locale), options]);\n let formatter = formatterCache.get(key);\n if (formatter) {\n return formatter;\n }\n if (formatterCache.size >= MAX_CACHE_SIZE) {\n // not real LRU, just evicts oldest insertion — fine for this key space\n const oldestKey = formatterCache.keys().next().value;\n if (oldestKey !== undefined) formatterCache.delete(oldestKey);\n }\n try {\n formatter = new Intl.DateTimeFormat(normalizeLocaleTag(locale), options);\n } catch (err) {\n // Malformed locale tags reach Intl as a bare RangeError; surface the\n // library's typed error instead (reached via dayPeriodPart — the\n // 'a' token — on any runtime, and the native-Intl path for the rest).\n // Every failure mode of this constructor with a string locale is a\n // RangeError, so converting unconditionally preserves the original\n // message in `reason` either way.\n throw new InvalidLocaleError({ actual: locale, reason: (err as Error).message });\n }\n formatterCache.set(key, formatter);\n return formatter;\n}\n\n// Passing a Temporal object straight into `new Intl.DateTimeFormat().formatToParts()`\n// only works when the engine's Intl implementation has special-cased support for\n// *native* Temporal instances (checked via internal slots and/or gated behind a V8 flag,\n// not tied to a specific Node version).\n//\n// A Temporal polyfill's instances don't have those slots, so the engine falls back to ToNumber() -> .valueOf(),\n// which the polyfill deliberately throws on (\"Cannot use valueOf\").\n// Probed once and memoized and only from intlPart(), so it never\n// runs unless a format string actually uses a locale-aware token.\nlet nativeSupport: boolean | undefined;\n// Invalidate the memoized probe whenever setTemporal() swaps the active\n// implementation — otherwise a probe result from \"is native Temporal\n// supported\" could keep being used after the active implementation is\n// no longer the one that was probed. See setTemporal() in\n// temporalProvider.ts for the other half of this.\nsubscribeToTemporalChanges(() => { nativeSupport = undefined; });\n\nfunction intlSupportsNativeTemporal(): boolean {\n if (nativeSupport === undefined) {\n nativeSupport = false;\n try {\n const temporal = getTemporal();\n new Intl.DateTimeFormat('en-US', { day: 'numeric' })\n .formatToParts(temporal.PlainDate.from({ year: 1970, month: 1, day: 1 }) as Date);\n // Version-gated, not dead — see the matching note on the\n // !intlSupportsNativeTemporal() branch in intlPart() below for\n // why this can't be exercised from this environment.\n /* c8 ignore next */\n nativeSupport = true;\n /* c8 ignore start */\n } catch {\n // native Temporal absent, or present but not recognized by Intl — fall back.\n // Version-gated, not dead: this catch only fires on runtimes where the\n // probe above throws (no native Temporal, or Intl doesn't recognize it).\n // On a runtime with full native support (e.g. Node builds where Intl\n // accepts native Temporal instances directly) the try succeeds and this\n // branch is unreachable — mirror case of the block below.\n }\n /* c8 ignore stop */\n }\n return nativeSupport;\n}\n\nfunction intlPart(\n temporal: TemporalLike,\n locale: string,\n options: Intl.DateTimeFormatOptions,\n partType: Intl.DateTimeFormatPartTypes\n): string {\n // Intl throws \"Mismatching Calendars\" if the formatter's calendar doesn't\n // match the object's own (e.g. en-US formatter defaults to gregory, but\n // a hebrew/islamic PlainDate needs its own calendar passed through).\n //\n // For iso8601 specifically, force 'gregory' rather than leaving calendar\n // unset: numeric fields (yyyy/dd, see tokens' pad()-based handlers) are\n // always pulled straight off the object's own ISO fields — so if the\n // *locale* carries a `-u-ca-*` extension (e.g. 'en-u-ca-hebrew') and this\n // step left calendar unset, the formatter would resolve its own default\n // calendar from the locale and format MMMM/EEEE in that calendar while\n // yyyy/dd stay ISO, producing a date that looks internally consistent\n // (a real Hebrew month name next to a real-looking day/year) but names a\n // completely different day than the object actually represents. Forcing\n // 'gregory' here keeps every field of an ISO object's output anchored to\n // the same (ISO/Gregorian) calendar — a locale's calendar extension only\n // takes effect when the object itself already carries a non-ISO calendar\n // (via `.withCalendar()`), matching what the README documents.\n //\n // 'gregory' specifically, not 'iso8601' — passing `calendar: 'iso8601'`\n // explicitly alongside a single-field options object makes\n // formatToParts() come back empty for some reason, but 'gregory' doesn't\n // have that problem and Temporal's iso8601 calendar is Gregorian-shaped\n // (proleptic Gregorian throughout, no Julian cutover) so the two agree\n // on every numeric field this library ever reads.\n const calendar = temporal?.calendarId;\n const formatterOptions: Intl.DateTimeFormatOptions = {\n ...options,\n calendar: calendar && calendar !== 'iso8601' ? calendar : 'gregory',\n };\n\n // Field-bag guard: a plain { year, month, day } object only has\n // Object.prototype.toLocaleString, which ignores both arguments and\n // returns \"[object Object]\". On engines without native Temporal\n // support in Intl this used to be caught below, but on engines where\n // Intl *does* recognize native Temporal instances (Node 26+), a bag\n // skips that branch entirely and reaches formatToParts() directly —\n // which doesn't throw \"[object Object]\", it throws a bare\n // \"RangeError: Invalid time value\" once the bag fails ToNumber()\n // coercion. Neither failure mode is useful to a caller, so check for\n // a real toLocaleString up front, before branching on native support,\n // so the descriptive error fires on every engine.\n const ls = temporal.toLocaleString;\n if (typeof ls !== 'function' || ls === Object.prototype.toLocaleString) {\n throw new Error(\n `temporal-fmt: locale-aware part \"${partType}\" needs a value that implements ` +\n `toLocaleString (a real Temporal object). A plain field bag cannot render ` +\n `locale-aware names — pass a Temporal.PlainDate/PlainDateTime/ZonedDateTime.`\n );\n }\n\n // Temporal.prototype.toLocaleString() is part of the Temporal spec itself:\n // polyfills implement the ICU formatting internally without needing the\n // engine to recognize the object, so it works without native Intl support.\n //\n // Everything from here to the end of this function is genuinely\n // reachable — NOT dead code — but only on a Node build where a global\n // `Temporal` exists AND Intl.DateTimeFormat.formatToParts() recognizes\n // native Temporal instances directly (this is real, observed to vary\n // across Node versions: absent on the Node 22/24 builds this suite has\n // been run against, present on at least one Node 26 build). This\n // environment has no native Temporal (`typeof globalThis.Temporal ===\n // 'undefined'`), so intlSupportsNativeTemporal() always returns false\n // here and this branch can't be exercised from this test suite without\n // faking native-instance recognition, which turned out to be\n // impractical (Intl's native-Temporal detection isn't spoofable via a\n // Proxy or valueOf() shim — see the M-02 regression test in\n // temporalProvider.test.js for the same conclusion reached about the\n // sibling probe function). Coverage numbers for this block will differ\n // between Node versions for that reason; that's expected, not a\n // regression.\n /* c8 ignore start */\n if (!intlSupportsNativeTemporal()) {\n // normalizeLocaleTag: the active Temporal implementation's\n // toLocaleString forwards the locale to Intl.DateTimeFormat, which\n // (unlike this library's cache keys) rejects underscore-separated\n // tags like 'en_US' outright.\n // (Field-bag guard now runs unconditionally above, before this\n // native-support branch, so it's not repeated here.)\n try {\n return ls.call(temporal, normalizeLocaleTag(locale), formatterOptions);\n } catch (err) {\n // The active Temporal implementation forwards the tag to Intl, which\n // throws a bare RangeError for a malformed one — rethrow typed.\n if (err instanceof RangeError) {\n throw new InvalidLocaleError({ actual: locale, reason: err.message });\n }\n throw err;\n }\n }\n\n // formatToParts() throws on ZonedDateTime directly (per spec), so convert\n // to Instant and pass the zone via `timeZone` instead. Don't convert to\n // PlainDateTime — that drops the zone, which breaks 'MMMM' + 'zzz' combos.\n const { toInstant, timeZoneId } = temporal;\n const isZoned = typeof toInstant === 'function' && typeof timeZoneId === 'string';\n // has to be called as temporal.toInstant() because destructuring it off breaks\n // the receiver and throws\n const intlSafeTemporal = isZoned ? temporal.toInstant!() : temporal;\n const nativeOptions: Intl.DateTimeFormatOptions = {\n ...formatterOptions,\n ...(isZoned ? { timeZone: timeZoneId } : {}),\n };\n\n const formatter = getFormatter(locale, nativeOptions);\n const parts = formatter.formatToParts(intlSafeTemporal as Date | number);\n const index = parts.findIndex((p) => p.type === partType);\n if (index === -1) {\n throw new Error(\n `temporal-fmt: locale \"${locale}\" produced no \"${partType}\" part for this token. ` +\n `This usually means the Temporal object is missing the field the token needs.`\n );\n }\n // some locales (ja-JP) split a field across two parts — e.g. month \"8\"\n // plus a counter suffix \"月\" as a separate sibling literal part. Merge in\n // an adjacent literal only if it has no whitespace, so a genuine suffix\n // gets folded in but an ordinary separator (the space before \"AM\") stays\n // a separator. Mirrors partValue() in localeVocab.ts, which builds the\n // vocab this token's output needs to match for parse() to round-trip.\n let value = parts[index]!.value;\n const prev = parts[index - 1];\n const next = parts[index + 1];\n if (prev?.type === 'literal' && !/\\s/.test(prev.value)) value = prev.value + value;\n if (next?.type === 'literal' && !/\\s/.test(next.value)) value = value + next.value;\n return value;\n}\n/* c8 ignore stop */\n\n// Temporal.prototype.toLocaleString() can't isolate a single field the way\n// formatToParts() can — asking for `hour` + `dayPeriod` together returns one\n// joined string (e.g. \"3 in the afternoon\"), and `dayPeriod` alone resolves\n// against a different, non-hour-anchored set of periods (\"in the\n// afternoon\"/\"昼\" instead of \"PM\"/\"午後\"). Day period only depends on the\n// hour anyway, so route it through a plain UTC Date and Intl.DateTimeFormat\n// instead — that's worked the same on every engine regardless of whether\n// Temporal itself is native or polyfilled.\nfunction dayPeriodPart(hour: number, locale: string): string {\n // Custom vocab (when registered) takes precedence over Intl — same\n // contract as the other locale-aware tokens. Intl won't know about a\n // caller-supplied AM/PM string for a made-up locale key, so going\n // through Intl would produce something other than what the caller\n // registered.\n const custom = getCustomVocab(locale);\n if (custom) {\n return hour < 12 ? custom.dayPeriod[0]! : custom.dayPeriod[1]!;\n }\n const date = new Date(Date.UTC(1970, 0, 1, hour));\n const formatter = getFormatter(locale, { hour: 'numeric', hour12: true, timeZone: 'UTC' });\n const part = formatter.formatToParts(date).find((p) => p.type === 'dayPeriod');\n // Defensive guard, confirmed unreachable on this ICU build: forcing\n // hour12: true (as this call always does) produces a dayPeriod part\n // for every locale checked, including 24-hour-clock locales (ja-JP,\n // zh-CN, th-TH, he-IL) and a wide sweep of less-common tags (dz-BT,\n // bo-CN, am-ET, etc.). Same finding as partValue()'s twin guard in\n // localeVocab.ts. Kept in case a future ICU/locale-data update\n // produces a locale that genuinely omits it.\n /* c8 ignore start */\n if (!part) {\n throw new Error(`temporal-fmt: locale \"${locale}\" produced no \"dayPeriod\" part for token \"a\".`);\n }\n /* c8 ignore stop */\n return part.value;\n}\n\n// Resolves a locale-aware month/weekday name from the registered custom\n// vocab when one exists for this locale, falling through to Intl otherwise.\n// Without this, format() would silently keep producing Intl's strings while\n// parse() matched against the registered vocab — the two would round-trip-fail\n// against each other.\nfunction localeAwareName(\n temporal: TemporalLike,\n locale: string,\n options: Intl.DateTimeFormatOptions,\n partType: Intl.DateTimeFormatPartTypes,\n customArray: string[] | undefined,\n customIndex: number | undefined,\n): string {\n if (customArray && customIndex !== undefined && customIndex >= 0 && customIndex < customArray.length) {\n return customArray[customIndex]!;\n }\n return intlPart(temporal, locale, options, partType);\n}\n\n// Formats a `±HH:MM` offset string (the shape Temporal exposes on\n// ZonedDateTime.prototype.offset) into one of the six offset-token widths.\n// Width and Z-handling come from the variant letter+case:\n//\n// X / x — short form: minutes omitted when zero, no colon otherwise\n// XX / xx — hours + minutes, no colon\n// XXX / xxx — hours + minutes, with colon\n//\n// Uppercase (X) collapses +00:00 to \"Z\"; lowercase (x) always emits a\n// numeric offset, even for UTC. Mirrors the date-fns/Unicode-LDML offset\n// family — see README for the full variant table.\nfunction formatOffset(offset: string, variant: 'X' | 'XX' | 'XXX' | 'x' | 'xx' | 'xxx'): string {\n if (offset === '+00:00' && (variant === 'X' || variant === 'XX' || variant === 'XXX')) {\n return 'Z';\n }\n // Most offsets are 6 chars: sign + HH + ':' + MM. Pre-1900 local-mean-time\n // zones can surface a seconds component too, 9 chars: sign + HH + ':' +\n // MM + ':' + SS. \"xxx\" is the one variant with a always-signed,\n // never-\"Z\" colon-separated shape wide enough to carry that unchanged,\n // so it passes a sub-minute offset through verbatim. Every other\n // variant has no seconds slot and must throw rather than silently\n // truncate them away.\n if (offset.length > 6) {\n if (variant === 'xxx') {\n return offset;\n }\n throw new Error(\n `temporal-fmt: token \"${variant}\" cannot represent the offset \"${offset}\", ` +\n `which has a seconds component. None of the X/XX/XXX/x/xx tokens ` +\n `support offset seconds; use \"xxx\" instead, which formats the full ` +\n `offset unchanged.`\n );\n }\n const sign = offset[0]!;\n const hours = offset.slice(1, 3);\n const minutes = offset.slice(4, 6);\n switch (variant) {\n case 'X': case 'x':\n // minutes only matter when they're non-zero — otherwise drop them\n // entirely. Matches LDML: \"With a single X, the hours field is\n // required. The minutes field is optional, but only if the\n // minutes value is 0.\"\n return minutes === '00' ? `${sign}${hours}` : `${sign}${hours}${minutes}`;\n case 'XX': case 'xx':\n return `${sign}${hours}${minutes}`;\n case 'XXX': case 'xxx':\n return `${sign}${hours}:${minutes}`;\n }\n}\n\ntype TokenHandler = (t: TemporalLike, locale: string) => string;\n\n// Longest-first — tokenizer is greedy, \"yyyy\" has to be tried before \"yy\".\n//\n// Numeric tokens always render in ASCII digits, never locale-native\n// (Arabic-Indic, Devanagari, etc). Padding non-ASCII digits isn't as simple\n// as padding \"3\", and most consumers parsing these back out want plain\n// digits anyway.\nexport const TOKENS: Array<[string, TokenHandler, keyof TemporalLike]> = [\n ['yyyy', (t) => pad(t.year!, 4), 'year'],\n ['yy', (t) => {\n // -45 % 100 === -45, so truncating negative years to 2 digits doesn't\n // work and Math.abs() would make 45 CE and 45 BCE render the same.\n if (t.year! < 0) {\n throw new Error(\n `temporal-fmt: token \"yy\" doesn't support negative years (got ${t.year}), ` +\n `since truncating to 2 digits would make it indistinguishable from a ` +\n `positive year. Use \"yyyy\" instead.`\n );\n }\n return pad(t.year! % 100, 2);\n }, 'year'],\n // Unpadded year — no minimum width, unlike yyyy's fixed 4 digits.\n // pad(n, 0) still does the right thing here: Math.abs(n) with no\n // padStart floor just yields the plain digit string, and the sign\n // handling (split off before padding) already covers negative years,\n // so this doesn't need its own sign branch the way \"yy\" does.\n ['y', (t) => pad(t.year!, 0), 'year'],\n ['MMMM', (t, locale) => {\n const custom = getCustomVocab(locale);\n return localeAwareName(t, locale, { month: 'long' }, 'month', custom?.monthLong, t.month! - 1);\n }, 'month'],\n ['MMM', (t, locale) => {\n const custom = getCustomVocab(locale);\n return localeAwareName(t, locale, { month: 'short' }, 'month', custom?.monthShort, t.month! - 1);\n }, 'month'],\n ['MM', (t) => pad(t.month!, 2), 'month'],\n ['M', (t) => String(t.month!), 'month'],\n ['dd', (t) => pad(t.day!, 2), 'day'],\n ['d', (t) => String(t.day!), 'day'],\n ['EEEE', (t, locale) => {\n const custom = getCustomVocab(locale);\n return localeAwareName(t, locale, { weekday: 'long' }, 'weekday', custom?.weekdayLong, t.dayOfWeek! - 1);\n }, 'dayOfWeek'],\n ['EEE', (t, locale) => {\n const custom = getCustomVocab(locale);\n return localeAwareName(t, locale, { weekday: 'short' }, 'weekday', custom?.weekdayShort, t.dayOfWeek! - 1);\n }, 'dayOfWeek'],\n ['HH', (t) => pad(t.hour!, 2), 'hour'],\n ['H', (t) => String(t.hour!), 'hour'],\n ['hh', (t) => pad(t.hour! % 12 || 12, 2), 'hour'],\n ['h', (t) => String(t.hour! % 12 || 12), 'hour'],\n ['mm', (t) => pad(t.minute!, 2), 'minute'],\n ['m', (t) => String(t.minute!), 'minute'],\n ['ss', (t) => pad(t.second!, 2), 'second'],\n ['s', (t) => String(t.second!), 'second'],\n // Fractional-second tokens, S through SSSSSSSSS (1-9 digits). Each token\n // formats a slice of the same underlying nanosecond-of-second value —\n // combining millisecond/microsecond/nanosecond into one 9-digit number\n // and truncating to the token's width — so \"SSS\" keeps meaning exactly\n // what it always meant (3-digit milliseconds) while wider tokens expose\n // the precision Temporal actually carries. formatFraction below is the\n // shared implementation; see its comment for the truncate-not-round\n // rule and why.\n ['SSSSSSSSS', (t) => pad.fraction(t, 9), 'millisecond'],\n ['SSSSSSSS', (t) => pad.fraction(t, 8), 'millisecond'],\n ['SSSSSSS', (t) => pad.fraction(t, 7), 'millisecond'],\n ['SSSSSS', (t) => pad.fraction(t, 6), 'millisecond'],\n ['SSSSS', (t) => pad.fraction(t, 5), 'millisecond'],\n ['SSSS', (t) => pad.fraction(t, 4), 'millisecond'],\n ['SSS', (t) => pad.fraction(t, 3), 'millisecond'],\n ['SS', (t) => pad.fraction(t, 2), 'millisecond'],\n ['S', (t) => pad.fraction(t, 1), 'millisecond'],\n // dayPeriod text is locale-specific (AM/PM in en-US, م/ص in ar-EG) but\n // still needs .hour on the input to compute which period it is\n ['a', (t, locale) => dayPeriodPart(t.hour!, locale), 'hour'],\n ['zzz', (t) => t.timeZoneId!, 'timeZoneId'],\n // Numeric UTC offset tokens (date-fns/Unicode-LDML family). Only\n // ZonedDateTime carries an offset, so the field check in format() throws\n // the same \"requires offset, which this Temporal object doesn't have\"\n // error zzz throws on PlainDate/PlainTime/PlainDateTime — same\n // validation path, just a different field name. See formatOffset above\n // for the per-variant width and Z/numeric distinction.\n ['xxx', (t) => formatOffset(t.offset!, 'xxx'), 'offset'],\n ['xx', (t) => formatOffset(t.offset!, 'xx'), 'offset'],\n ['X', (t) => formatOffset(t.offset!, 'X'), 'offset'],\n ['XX', (t) => formatOffset(t.offset!, 'XX'), 'offset'],\n ['XXX', (t) => formatOffset(t.offset!, 'XXX'), 'offset'],\n ['x', (t) => formatOffset(t.offset!, 'x'), 'offset'],\n\n // Ordinal day (1st, 2nd, 3rd, ... 21st). English suffix rules only —\n // locale-aware ordinals (\"2.\" in de-DE, \"2日\" in ja-JP) are out of scope,\n // since the rest of this library routes locale-specific names through\n // Intl.DateTimeFormat, and Intl has no part type for ordinals. Format-only:\n // the suffix isn't structurally distinguishable from a literal in a parse\n // context (a \"st\"/\"nd\"/\"rd\"/\"th\" suffix isn't a digit and would collide\n // with any adjacent literal text), so there's no good way to read it back.\n ['do', (t) => {\n const day = t.day!;\n const lastDigit = day % 10;\n // 11, 12, 13 are the exception — they'd otherwise match the 1/2/3 rule\n // and produce \"11st\"/\"12nd\"/\"13rd\", which is wrong. They always take \"th\".\n const lastTwoDigits = day % 100;\n if (lastTwoDigits >= 11 && lastTwoDigits <= 13) {\n return day + 'th';\n }\n if (lastDigit === 1) return day + 'st';\n if (lastDigit === 2) return day + 'nd';\n if (lastDigit === 3) return day + 'rd';\n return day + 'th';\n }, 'day'],\n\n // Quarter computed from month: 1-3=Q1, 4-6=Q2, 7-9=Q3, 10-12=Q4.\n // `Q` is plain numeric, `QQQ` renders as \"Q3\" — same convention as\n // date-fns's `Q` and `QQQ` for parity with the most common prior art.\n // Both format and parse; parse() cross-checks Q/QQQ against the parsed\n // month in the same spirit as the EEEE-vs-date cross-check.\n ['Q', (t) => String(Math.ceil(t.month! / 3)), 'month'],\n ['QQQ', (t) => 'Q' + Math.ceil(t.month! / 3), 'month'],\n\n // ISO 8601 week and week-numbering year. Both are format-only — parsing\n // \"ww\"/\"RRRR\" back into a real date requires resolving an ISO week + a\n // weekday (or some other disambiguator) to a specific date, which is a\n // different parsing surface than the token-based parse() here. The\n // ISO-week year (RRRR) can differ from the calendar year at the boundary:\n // Dec 29-31 often belong to week 1 of the *next* year; Jan 1-3 often\n // belong to week 52/53 of the *previous* year. See isoWeekYearAndWeek().\n ['ww', (t) => {\n const { week } = isoWeekYearAndWeek(t.year!, t.month!, t.day!, t.dayOfWeek!);\n return pad(week, 2);\n }, 'dayOfWeek'],\n ['RRRR', (t) => {\n const { isoYear } = isoWeekYearAndWeek(t.year!, t.month!, t.day!, t.dayOfWeek!);\n return pad(isoYear, 4);\n }, 'dayOfWeek'],\n\n // Day of year — number of days since Jan 1 (1-366). Three widths:\n // D — unpadded (1, 2, 366)\n // DD — 2-digit minimum (zero-padded if <100)\n // DDD — 3-digit zero-padded (001, 002, 366)\n // Format-only — parsing day-of-year requires resolving against a year,\n // which is a different shape from the token-based parse() surface.\n // The dayOfYearHelper() in calendarUtils.ts covers the same field for\n // callers who need the numeric value.\n ['D', (t) => String(dayOfYear(t.year!, t.month!, t.day!)), 'day'],\n ['DD', (t) => pad(dayOfYear(t.year!, t.month!, t.day!), 2), 'day'],\n ['DDD', (t) => pad(dayOfYear(t.year!, t.month!, t.day!), 3), 'day'],\n\n // Stand-alone month — uses Intl's stand-alone form. In most locales\n // (en, fr, de, es) this is identical to MMMM/MMM. In Slavic/Baltic\n // locales (cs, sk, pl, ru) the stand-alone form differs from the\n // format form (nominative vs genitive case). LLLL = long, LLL = short.\n ['LLLL', (t, locale) => {\n const custom = getCustomVocab(locale);\n return localeAwareName(t, locale, { month: 'long' }, 'month', custom?.monthLong, t.month! - 1);\n }, 'month'],\n ['LLL', (t, locale) => {\n const custom = getCustomVocab(locale);\n return localeAwareName(t, locale, { month: 'short' }, 'month', custom?.monthShort, t.month! - 1);\n }, 'month'],\n\n // Stand-alone weekday — same pattern as stand-alone month but for\n // weekday names. cccc = long, ccc = short.\n ['cccc', (t, locale) => {\n const custom = getCustomVocab(locale);\n return localeAwareName(t, locale, { weekday: 'long' }, 'weekday', custom?.weekdayLong, t.dayOfWeek! - 1);\n }, 'dayOfWeek'],\n ['ccc', (t, locale) => {\n const custom = getCustomVocab(locale);\n return localeAwareName(t, locale, { weekday: 'short' }, 'weekday', custom?.weekdayShort, t.dayOfWeek! - 1);\n }, 'dayOfWeek'],\n\n // Era — locale-aware (\"AD\"/\"BC\" in en, \"ap. J.-C.\"/\"av. J.-C.\" in fr).\n // GGGG = long, G = short. Format-only.\n ['GGGG', (t, locale) => {\n return intlPart(t, locale, { era: 'long' }, 'era');\n }, 'year'],\n ['G', (t, locale) => {\n return intlPart(t, locale, { era: 'short' }, 'era');\n }, 'year'],\n\n // Localized timezone name — uses Intl's longLocalized/short timezone\n // name option. Format-only — these names are locale-dependent and\n // vary by season (EST vs EDT), so parsing them back requires a\n // lookup table that isn't practical to ship.\n ['zzzz', (t, locale) => {\n return intlPart(t, locale, { timeZoneName: 'longGeneric' as Intl.DateTimeFormatOptions['timeZoneName'] }, 'timeZoneName' as Intl.DateTimeFormatPartTypes);\n }, 'timeZoneId'],\n ['z', (t, locale) => {\n return intlPart(t, locale, { timeZoneName: 'short' as Intl.DateTimeFormatOptions['timeZoneName'] }, 'timeZoneName' as Intl.DateTimeFormatPartTypes);\n }, 'timeZoneId'],\n\n];"],"mappings":"sJAKO,SAASA,EAAIC,EAAWC,EAAqB,CAGlD,IAAMC,EAAWF,EAAI,EACfG,EAAS,OAAO,KAAK,IAAIH,CAAC,CAAC,EAAE,SAASC,EAAK,GAAG,EACpD,OAAOC,EAAW,IAAMC,EAASA,CACnC,CAmBAJ,EAAI,SAAW,SAAwB,EAAiBK,EAAuB,CAC7E,IAAMC,EAAe,EAAE,YAAe,KAAa,EAAE,aAAe,GAAK,KAAS,EAAE,YAAc,GAClG,OAAON,EAAIM,EAAc,CAAC,EAAE,MAAM,EAAGD,CAAK,CAC5C,EAyCO,IAAME,EAAiB,QAIxBC,EAAiB,IAAI,IACrBC,EAAiB,IAEvB,SAASC,EAAaC,EAAgBC,EAA0D,CAC9F,IAAMC,EAAM,KAAK,UAAU,CAACC,EAAkBH,CAAM,EAAGC,CAAO,CAAC,EAC3DG,EAAYP,EAAe,IAAIK,CAAG,EACtC,GAAIE,EACF,OAAOA,EAET,GAAIP,EAAe,MAAQC,EAAgB,CAEzC,IAAMO,EAAYR,EAAe,KAAK,EAAE,KAAK,EAAE,MAC3CQ,IAAc,QAAWR,EAAe,OAAOQ,CAAS,CAC9D,CACA,GAAI,CACFD,EAAY,IAAI,KAAK,eAAeE,EAAmBN,CAAM,EAAGC,CAAO,CACzE,OA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,EAAE,MAAS,CAAC,CACjG,EAAG,OAAO,EAIV,CAAC,OAAQ,CAACA,EAAG9C,IAAW,CACtB,IAAMgC,EAASC,EAAejC,CAAM,EACpC,OAAOoC,EAAgBU,EAAG9C,EAAQ,CAAE,QAAS,MAAO,EAAG,UAAWgC,GAAQ,YAAac,EAAE,UAAa,CAAC,CACzG,EAAG,WAAW,EACd,CAAC,MAAO,CAACA,EAAG9C,IAAW,CACrB,IAAMgC,EAASC,EAAejC,CAAM,EACpC,OAAOoC,EAAgBU,EAAG9C,EAAQ,CAAE,QAAS,OAAQ,EAAG,UAAWgC,GAAQ,aAAcc,EAAE,UAAa,CAAC,CAC3G,EAAG,WAAW,EAId,CAAC,OAAQ,CAACA,EAAG9C,IACJc,EAASgC,EAAG9C,EAAQ,CAAE,IAAK,MAAO,EAAG,KAAK,EAChD,MAAM,EACT,CAAC,IAAK,CAAC8C,EAAG9C,IACDc,EAASgC,EAAG9C,EAAQ,CAAE,IAAK,OAAQ,EAAG,KAAK,EACjD,MAAM,EAMT,CAAC,OAAQ,CAAC8C,EAAG9C,IACJc,EAASgC,EAAG9C,EAAQ,CAAE,aAAc,aAA4D,EAAG,cAA8C,EACvJ,YAAY,EACf,CAAC,IAAK,CAAC8C,EAAG9C,IACDc,EAASgC,EAAG9C,EAAQ,CAAE,aAAc,OAAsD,EAAG,cAA8C,EACjJ,YAAY,CAEjB","names":["pad","n","len","negative","digits","width","nanoOfSecond","DEFAULT_LOCALE","formatterCache","MAX_CACHE_SIZE","getFormatter","locale","options","key","canonicalCacheKey","formatter","oldestKey","normalizeLocaleTag","err","InvalidLocaleError","nativeSupport","subscribeToTemporalChanges","intlSupportsNativeTemporal","temporal","getTemporal","intlPart","partType","calendar","formatterOptions","ls","toInstant","timeZoneId","isZoned","intlSafeTemporal","nativeOptions","parts","index","p","value","prev","next","dayPeriodPart","hour","custom","getCustomVocab","date","part","localeAwareName","customArray","customIndex","formatOffset","offset","variant","sign","hours","minutes","TOKENS","t","day","lastDigit","lastTwoDigits","week","isoWeekYearAndWeek","isoYear","dayOfYear"]}
@@ -1,7 +1,7 @@
1
- import{b as d}from"./chunk-C5YESWFT.js";import{b as c,c as p,k as l}from"./chunk-5U5WJ465.js";var h=d.map(([n])=>n).sort((n,t)=>t.length-n.length);function N(n){let t=[],e=0;for(;e<n.length;){let o=n[e];if(o==="'"){if(n[e+1]==="'"){a(t,"'"),e+=2;continue}let r=e+1,s="",u=!1;for(;r<n.length;){if(n[r]==="'"){if(n[r+1]==="'"){s+="'",r+=2;continue}u=!0,r+=1;break}s+=n[r],r+=1}if(!u)throw new c({format:n,message:`temporal-fmt: unterminated quote in format string "${n}"`});a(t,s),e=r;continue}let i=h.find(r=>n.startsWith(r,e));if(i){let r=i[i.length-1];if(n[e+i.length]===r){let s=e+i.length;for(;n[s]===r;)s+=1;throw new p({format:n,token:n.slice(e,s),message:`temporal-fmt: "${n.slice(e,s)}" in format string "${n}" isn't a recognized token \u2014 did you mean "${i}"?`})}t.push({kind:"token",value:i}),e+=i.length;continue}a(t,o),e+=1}return t}function a(n,t){let e=n[n.length-1];e&&e.kind==="literal"?e.value+=t:n.push({kind:"literal",value:t})}var g=new Set(["latn","arab","deva","beng","guru","gujr","orya","tamldec","telu","knda","mlym","fullwide","hanidec"]),m=new Map;function f(n){let t=m.get(n);if(t)return t;/* c8 ignore start @preserve -- dead by construction, not just
1
+ import{b as d}from"./chunk-GMGZZG6I.js";import{b as c,c as p,k as l}from"./chunk-5U5WJ465.js";var h=d.map(([n])=>n).sort((n,t)=>t.length-n.length);function N(n){let t=[],e=0;for(;e<n.length;){let o=n[e];if(o==="'"){if(n[e+1]==="'"){a(t,"'"),e+=2;continue}let r=e+1,s="",u=!1;for(;r<n.length;){if(n[r]==="'"){if(n[r+1]==="'"){s+="'",r+=2;continue}u=!0,r+=1;break}s+=n[r],r+=1}if(!u)throw new c({format:n,message:`temporal-fmt: unterminated quote in format string "${n}"`});a(t,s),e=r;continue}let i=h.find(r=>n.startsWith(r,e));if(i){let r=i[i.length-1];if(n[e+i.length]===r){let s=e+i.length;for(;n[s]===r;)s+=1;throw new p({format:n,token:n.slice(e,s),message:`temporal-fmt: "${n.slice(e,s)}" in format string "${n}" isn't a recognized token \u2014 did you mean "${i}"?`})}t.push({kind:"token",value:i}),e+=i.length;continue}a(t,o),e+=1}return t}function a(n,t){let e=n[n.length-1];e&&e.kind==="literal"?e.value+=t:n.push({kind:"literal",value:t})}var g=new Set(["latn","arab","deva","beng","guru","gujr","orya","tamldec","telu","knda","mlym","fullwide","hanidec"]),m=new Map;function f(n){let t=m.get(n);if(t)return t;/* c8 ignore start @preserve -- dead by construction, not just
2
2
  untested: both callers (convertDigits, convertDigitsToAscii) already
3
3
  return early on system === 'latn' before calling getDigitMap at all,
4
4
  so this function is never invoked with 'latn'. Kept as a defensive
5
5
  fallback rather than trusting that stays true for any future
6
6
  caller. */if(n==="latn"){t={};for(let e=0;e<10;e++)t[String(e)]=String(e)}else{/* c8 ignore stop @preserve */let e=new Intl.NumberFormat("en-US-u-nu-"+n,{useGrouping:!1});t={};for(let o=0;o<10;o++)t[String(o)]=e.format(o)}return m.set(n,t),t}function S(n,t){if(t==="latn")return n;if(!g.has(t))throw new l({actual:t,reason:`numbering system "${t}" is not supported. Supported: ${[...g].join(", ")}.`});let e=f(t),o="";for(let i of n)i>="0"&&i<="9"?o+=e[i]??i:o+=i;return o}function b(n,t){if(t==="latn")return n;if(!g.has(t))throw new l({actual:t,reason:`numbering system "${t}" is not supported.`});let e=f(t),o={};for(let r of Object.keys(e))o[e[r]]=r;let i="";for(let r of n)i+=o[r]??r;return i}function O(n,t){let e=t.numberingSystem??"latn";return e==="latn"?n:S(n,e)}function v(n,t){let e=t.parseNumberingSystem??"latn";return e==="latn"?n:b(n,e)}export{N as a,g as b,S as c,b as d,O as e,v as f};
7
- //# sourceMappingURL=chunk-R52YOKI3.js.map
7
+ //# sourceMappingURL=chunk-NPKJ7QFK.js.map
@@ -1,2 +1,2 @@
1
- import{a as u}from"./chunk-C5YESWFT.js";import{k as f,p as c}from"./chunk-5U5WJ465.js";import{w as l}from"./chunk-VQXUMFB2.js";var s=new Map,y=100;function w(r,n){let t=`${r}|${n}`,e=s.get(t);if(e)return e;if(s.size>=y){let o=s.keys().next().value;o!==void 0&&s.delete(o)}try{e=new Intl.RelativeTimeFormat(c(r),{numeric:n})}catch(o){throw new f({actual:r,reason:o.message})}return s.set(t,e),e}function p(r,n,t={}){let e=t.locale??u,o=t.numeric??"auto",a=w(e,o),i=-l(r,n),m=Math.abs(i);return m===0?a.format(0,"day"):m<7?a.format(i,"day"):m<30?a.format(-Math.trunc(-i/7),"week"):m<365?a.format(-Math.trunc(-i/30),"month"):a.format(-Math.trunc(-i/365),"year")}function v(r,n={}){let t=new Date,e={year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()};return p(r,e,n)}export{p as a,v as b};
2
- //# sourceMappingURL=chunk-NBXF7V5B.js.map
1
+ import{a as u}from"./chunk-GMGZZG6I.js";import{k as f,p as c}from"./chunk-5U5WJ465.js";import{w as l}from"./chunk-VQXUMFB2.js";var s=new Map,y=100;function w(r,n){let t=`${r}|${n}`,e=s.get(t);if(e)return e;if(s.size>=y){let o=s.keys().next().value;o!==void 0&&s.delete(o)}try{e=new Intl.RelativeTimeFormat(c(r),{numeric:n})}catch(o){throw new f({actual:r,reason:o.message})}return s.set(t,e),e}function p(r,n,t={}){let e=t.locale??u,o=t.numeric??"auto",a=w(e,o),i=-l(r,n),m=Math.abs(i);return m===0?a.format(0,"day"):m<7?a.format(i,"day"):m<30?a.format(-Math.trunc(-i/7),"week"):m<365?a.format(-Math.trunc(-i/30),"month"):a.format(-Math.trunc(-i/365),"year")}function v(r,n={}){let t=new Date,e={year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()};return p(r,e,n)}export{p as a,v as b};
2
+ //# sourceMappingURL=chunk-R4YEFOVE.js.map
@@ -1,4 +1,4 @@
1
- import{a as v,e as c}from"./chunk-R52YOKI3.js";import{a as f,b as k}from"./chunk-C5YESWFT.js";import{b as r,c as u}from"./chunk-5U5WJ465.js";var d=new Map(k.map(([t,n,i])=>[t,{fn:n,field:i}])),p=new Map,w=500;function h(t){let n=p.get(t);if(n)return n;if(p.size>=w){let i=p.keys().next().value;i!==void 0&&p.delete(i)}return n=v(t),p.set(t,n),n}function $(t,n,i={}){if(n.length>1e3)throw new r({format:n,message:`temporal-fmt: format string exceeds maximum length of ${1e3} characters (got ${n.length}).`});let l=i.locale??f,s=h(n),o="";for(let e of s){if(e.kind==="literal"){o+=e.value;continue}let a=d.get(e.value);/* c8 ignore start @preserve -- unreachable: tokenize() only ever emits
1
+ import{a as v,e as c}from"./chunk-NPKJ7QFK.js";import{a as f,b as k}from"./chunk-GMGZZG6I.js";import{b as r,c as u}from"./chunk-5U5WJ465.js";var d=new Map(k.map(([t,n,i])=>[t,{fn:n,field:i}])),p=new Map,w=500;function h(t){let n=p.get(t);if(n)return n;if(p.size>=w){let i=p.keys().next().value;i!==void 0&&p.delete(i)}return n=v(t),p.set(t,n),n}function $(t,n,i={}){if(n.length>1e3)throw new r({format:n,message:`temporal-fmt: format string exceeds maximum length of ${1e3} characters (got ${n.length}).`});let l=i.locale??f,s=h(n),o="";for(let e of s){if(e.kind==="literal"){o+=e.value;continue}let a=d.get(e.value);/* c8 ignore start @preserve -- unreachable: tokenize() only ever emits
2
2
  tokens present in TOKENS, and HANDLER_BY_TOKEN is built from that
3
3
  same list, so every token piece.value can hold already has an entry
4
4
  here. Same defensive-guard category as the twin checks in
@@ -8,4 +8,4 @@ import{a as v,e as c}from"./chunk-R52YOKI3.js";import{a as f,b as k}from"./chunk
8
8
  two 'literal' pieces never sit back-to-back in the array this
9
9
  loop walks. Kept as defense-in-depth in case that invariant ever
10
10
  changes upstream. */if(m&&m.type==="literal")m.value+=e.value;else{/* c8 ignore stop @preserve */o.push({type:"literal",value:e.value})}continue}let a=d.get(e.value);/* c8 ignore start @preserve -- unreachable, see the note in format() above */if(!a)throw new u({token:e.value,format:n,message:`temporal-fmt: unknown token "${e.value}"`});/* c8 ignore stop @preserve */if(t[a.field]===void 0)throw new r({format:n,token:e.value,message:`temporal-fmt: token "${e.value}" requires "${a.field}", which this Temporal object doesn't have. (e.g. PlainDate has no time fields, PlainTime has no date fields)`});o.push({type:"token",value:c(a.fn(t,l),i),token:e.value})}return o}function L(t){if(t.length>1e3)throw new r({format:t,message:`temporal-fmt: format string exceeds maximum length of ${1e3} characters (got ${t.length}).`});let n=h(t);return{formatStr:t,pieces:n,format(i,l={}){let s=l.locale??f,o="";for(let e of n){if(e.kind==="literal"){o+=e.value;continue}let a=d.get(e.value);if(!a)throw new u({token:e.value,format:t,message:`temporal-fmt: unknown token "${e.value}"`});if(i[a.field]===void 0)throw new r({format:t,token:e.value,message:`temporal-fmt: token "${e.value}" requires "${a.field}", which this Temporal object doesn't have. (e.g. PlainDate has no time fields, PlainTime has no date fields)`});o+=a.fn(i,s)}return c(o,l)},formatToParts(i,l={}){let s=l.locale??f,o=[];for(let e of n){if(e.kind==="literal"){let m=o[o.length-1];m&&m.type==="literal"?m.value+=e.value:o.push({type:"literal",value:e.value});continue}let a=d.get(e.value);if(!a)throw new u({token:e.value,format:t,message:`temporal-fmt: unknown token "${e.value}"`});if(i[a.field]===void 0)throw new r({format:t,token:e.value,message:`temporal-fmt: token "${e.value}" requires "${a.field}", which this Temporal object doesn't have. (e.g. PlainDate has no time fields, PlainTime has no date fields)`});o.push({type:"token",value:c(a.fn(i,s),l),token:e.value})}return o}}}function N(t){return h(t)}function O(t){return d.get(t)}export{$ as a,x as b,L as c,N as d,O as e};
11
- //# sourceMappingURL=chunk-4JWGUR4O.js.map
11
+ //# sourceMappingURL=chunk-SSPABEUR.js.map
package/dist/format.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var V=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var ee=Object.prototype.hasOwnProperty;var te=(e,t)=>{for(var n in t)V(e,n,{get:t[n],enumerable:!0})},ne=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of J(t))!ee.call(e,i)&&i!==n&&V(e,i,{get:()=>t[i],enumerable:!(o=Q(t,i))||o.enumerable});return e};var oe=e=>ne(V({},"__esModule",{value:!0}),e);var Le={};te(Le,{_getPieces:()=>Ee,_handlerFor:()=>be,compileFormat:()=>ke,format:()=>we,formatToParts:()=>Te});module.exports=oe(Le);var re,ae=[];function W(e){ae.push(e)}function ie(){return re??globalThis.Temporal}function K(){let e=ie();if(!e)throw new Error("temporal-fmt: parse() needs a Temporal implementation to construct its result. Call setTemporal(Temporal) once at startup, or assign one to globalThis.Temporal (native on Node 26+, or a polyfill like temporal-polyfill).");return e}var w=class extends Error{code;input;format;token;position;expected;actual;reason;constructor(t,n){super(t),this.name="TemporalFmtError",this.code=n.code,this.input=n.input,this.format=n.format,this.token=n.token,this.position=n.position,this.expected=n.expected,this.actual=n.actual,this.reason=n.reason;let o=Error.captureStackTrace;typeof o=="function"&&o(this,this.constructor)}toJSON(){return{name:this.name,message:this.message,code:this.code,input:this.input,format:this.format,token:this.token,position:this.position,expected:this.expected,actual:this.actual,reason:this.reason}}},c=class extends w{constructor(t){let{message:n,...o}=t;super(n??`format string "${t.format??""}" has a syntax error${t.reason?`: ${t.reason}`:""}.`,{code:"FORMAT_SYNTAX_ERROR",...o}),this.name="FormatSyntaxError"}},d=class extends w{constructor(t){let{message:n,...o}=t;super(n??`token "${t.token??""}" is not a recognized temporal-fmt token${t.format?` in format string "${t.format}"`:""}.`,{code:"UNKNOWN_TOKEN",...o}),this.name="UnknownTokenError"}};/* c8 ignore start @preserve -- InvalidTimeError is part of the public
1
+ "use strict";var V=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var ee=Object.prototype.hasOwnProperty;var te=(e,t)=>{for(var n in t)V(e,n,{get:t[n],enumerable:!0})},ne=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of J(t))!ee.call(e,i)&&i!==n&&V(e,i,{get:()=>t[i],enumerable:!(o=Q(t,i))||o.enumerable});return e};var oe=e=>ne(V({},"__esModule",{value:!0}),e);var xe={};te(xe,{_getPieces:()=>Ee,_handlerFor:()=>be,compileFormat:()=>Te,format:()=>we,formatToParts:()=>ke});module.exports=oe(xe);var re,ae=[];function W(e){ae.push(e)}function ie(){return re??globalThis.Temporal}function K(){let e=ie();if(!e)throw new Error("temporal-fmt: parse() needs a Temporal implementation to construct its result. Call setTemporal(Temporal) once at startup, or assign one to globalThis.Temporal (native on Node 26+, or a polyfill like temporal-polyfill).");return e}var w=class extends Error{code;input;format;token;position;expected;actual;reason;constructor(t,n){super(t),this.name="TemporalFmtError",this.code=n.code,this.input=n.input,this.format=n.format,this.token=n.token,this.position=n.position,this.expected=n.expected,this.actual=n.actual,this.reason=n.reason;let o=Error.captureStackTrace;typeof o=="function"&&o(this,this.constructor)}toJSON(){return{name:this.name,message:this.message,code:this.code,input:this.input,format:this.format,token:this.token,position:this.position,expected:this.expected,actual:this.actual,reason:this.reason}}},c=class extends w{constructor(t){let{message:n,...o}=t;super(n??`format string "${t.format??""}" has a syntax error${t.reason?`: ${t.reason}`:""}.`,{code:"FORMAT_SYNTAX_ERROR",...o}),this.name="FormatSyntaxError"}},d=class extends w{constructor(t){let{message:n,...o}=t;super(n??`token "${t.token??""}" is not a recognized temporal-fmt token${t.format?` in format string "${t.format}"`:""}.`,{code:"UNKNOWN_TOKEN",...o}),this.name="UnknownTokenError"}};/* c8 ignore start @preserve -- InvalidTimeError is part of the public
2
2
  error-class surface (exported from index.ts, code 'INVALID_TIME')
3
3
  but nothing in this package constructs one. Investigated wiring it
4
4
  in the same way InvalidTimeZoneError was just wired (see parse.ts's
@@ -21,19 +21,19 @@
21
21
  value a caller could get wrong. There's no live input to reject.
22
22
  Left unconstructed until the library actually accepts a calendar
23
23
  parameter that could be invalid. *//* c8 ignore stop @preserve */var g=class extends w{constructor(t){let{message:n,...o}=t;super(n??`locale "${t.actual??""}" is not a valid BCP-47 tag${t.reason?`: ${t.reason}`:""}.`,{code:"INVALID_LOCALE",...o}),this.name="InvalidLocaleError"}};/* c8 ignore start @preserve -- unreachable from the current test suite,
24
- see rationale above *//* c8 ignore stop @preserve */var se=new Map;function R(e){return e.replace(/_/g,"-")}var T=new Map,me=500;function X(e){let t=T.get(e);if(t!==void 0)return t;let n;try{n=new Intl.Locale(e.replace(/_/g,"-")).toString().toLowerCase()}catch{n=e}if(T.size>=me){let o=T.keys().next().value;o!==void 0&&T.delete(o)}return T.set(e,n),n}function u(e){let t=X(e);return se.get(t)}var ce=[0,31,59,90,120,151,181,212,243,273,304,334];function Y(e){return e%4===0&&e%100!==0||e%400===0}function k(e){return Y(e)?366:365}function E(e,t,n){let o=ce[t-1]+n;return t>2&&Y(e)&&(o+=1),o}var U=2e3;function le(e){let t=0;if(e>=U)for(let o=U;o<e;o++)t+=k(o);else for(let o=e;o<U;o++)t-=k(o);return((5+t)%7+7)%7+1}function Z(e,t,n,o){let a=E(e,t,n)+(4-o),r,s;a<1?(r=e-1,s=a+k(r)):a>k(e)?(r=e+1,s=a-k(e)):(r=e,s=a);let I=1+(4-le(r)+7)%7,M=1+Math.floor((s-I)/7);return{isoYear:r,week:M}}function m(e,t){let n=e<0,o=String(Math.abs(e)).padStart(t,"0");return n?"-"+o:o}m.fraction=function(t,n){let o=t.millisecond*1e6+(t.microsecond??0)*1e3+(t.nanosecond??0);return m(o,9).slice(0,n)};var S="en-US",b=new Map,ue=500;function j(e,t){let n=JSON.stringify([X(e),t]),o=b.get(n);if(o)return o;if(b.size>=ue){let i=b.keys().next().value;i!==void 0&&b.delete(i)}try{o=new Intl.DateTimeFormat(R(e),t)}catch(i){throw new g({actual:e,reason:i.message})}return b.set(n,o),o}var L;W(()=>{L=void 0});function de(){if(L===void 0){L=!1;try{let e=K();new Intl.DateTimeFormat("en-US",{day:"numeric"}).formatToParts(e.PlainDate.from({year:1970,month:1,day:1})),L=!0}catch{}}return L}function F(e,t,n,o){let i=e?.calendarId,a={...n,calendar:i&&i!=="iso8601"?i:"gregory"},r=e.toLocaleString;if(typeof r!="function"||r===Object.prototype.toLocaleString)throw new Error(`temporal-fmt: locale-aware part "${o}" needs a value that implements toLocaleString (a real Temporal object). A plain field bag cannot render locale-aware names \u2014 pass a Temporal.PlainDate/PlainDateTime/ZonedDateTime.`);if(!de())try{return r.call(e,R(t),a)}catch(y){throw y instanceof RangeError?new g({actual:t,reason:y.message}):y}let{toInstant:s,timeZoneId:l}=e,I=typeof s=="function"&&typeof l=="string",M=I?e.toInstant():e,B={...a,...I?{timeZone:l}:{}},v=j(t,B).formatToParts(M),N=v.findIndex(y=>y.type===o);if(N===-1)throw new Error(`temporal-fmt: locale "${t}" produced no "${o}" part for this token. This usually means the Temporal object is missing the field the token needs.`);let h=v[N].value,_=v[N-1],C=v[N+1];return _?.type==="literal"&&!/\s/.test(_.value)&&(h=_.value+h),C?.type==="literal"&&!/\s/.test(C.value)&&(h=h+C.value),h}function pe(e,t){let n=u(t);if(n)return e<12?n.dayPeriod[0]:n.dayPeriod[1];let o=new Date(Date.UTC(1970,0,1,e)),a=j(t,{hour:"numeric",hour12:!0,timeZone:"UTC"}).formatToParts(o).find(r=>r.type==="dayPeriod");if(!a)throw new Error(`temporal-fmt: locale "${t}" produced no "dayPeriod" part for token "a".`);return a.value}function p(e,t,n,o,i,a){return i&&a!==void 0&&a>=0&&a<i.length?i[a]:F(e,t,n,o)}function f(e,t){if(e==="+00:00"&&(t==="X"||t==="XX"||t==="XXX"))return"Z";let n=e[0],o=e.slice(1,3),i=e.slice(4,6);switch(t){case"X":case"x":return i==="00"?`${n}${o}`:`${n}${o}${i}`;case"XX":case"xx":return`${n}${o}${i}`;case"XXX":case"xxx":return`${n}${o}:${i}`}}var A=[["yyyy",e=>m(e.year,4),"year"],["yy",e=>{if(e.year<0)throw new Error(`temporal-fmt: token "yy" doesn't support negative years (got ${e.year}), since truncating to 2 digits would make it indistinguishable from a positive year. Use "yyyy" instead.`);return m(e.year%100,2)},"year"],["MMMM",(e,t)=>{let n=u(t);return p(e,t,{month:"long"},"month",n?.monthLong,e.month-1)},"month"],["MMM",(e,t)=>{let n=u(t);return p(e,t,{month:"short"},"month",n?.monthShort,e.month-1)},"month"],["MM",e=>m(e.month,2),"month"],["M",e=>String(e.month),"month"],["dd",e=>m(e.day,2),"day"],["d",e=>String(e.day),"day"],["EEEE",(e,t)=>{let n=u(t);return p(e,t,{weekday:"long"},"weekday",n?.weekdayLong,e.dayOfWeek-1)},"dayOfWeek"],["EEE",(e,t)=>{let n=u(t);return p(e,t,{weekday:"short"},"weekday",n?.weekdayShort,e.dayOfWeek-1)},"dayOfWeek"],["HH",e=>m(e.hour,2),"hour"],["H",e=>String(e.hour),"hour"],["hh",e=>m(e.hour%12||12,2),"hour"],["h",e=>String(e.hour%12||12),"hour"],["mm",e=>m(e.minute,2),"minute"],["m",e=>String(e.minute),"minute"],["ss",e=>m(e.second,2),"second"],["s",e=>String(e.second),"second"],["SSSSSSSSS",e=>m.fraction(e,9),"millisecond"],["SSSSSSSS",e=>m.fraction(e,8),"millisecond"],["SSSSSSS",e=>m.fraction(e,7),"millisecond"],["SSSSSS",e=>m.fraction(e,6),"millisecond"],["SSSSS",e=>m.fraction(e,5),"millisecond"],["SSSS",e=>m.fraction(e,4),"millisecond"],["SSS",e=>m.fraction(e,3),"millisecond"],["SS",e=>m.fraction(e,2),"millisecond"],["S",e=>m.fraction(e,1),"millisecond"],["a",(e,t)=>pe(e.hour,t),"hour"],["zzz",e=>e.timeZoneId,"timeZoneId"],["xxx",e=>f(e.offset,"xxx"),"offset"],["xx",e=>f(e.offset,"xx"),"offset"],["X",e=>f(e.offset,"X"),"offset"],["XX",e=>f(e.offset,"XX"),"offset"],["XXX",e=>f(e.offset,"XXX"),"offset"],["x",e=>f(e.offset,"x"),"offset"],["do",e=>{let t=e.day,n=t%10,o=t%100;return o>=11&&o<=13?t+"th":n===1?t+"st":n===2?t+"nd":n===3?t+"rd":t+"th"},"day"],["Q",e=>String(Math.ceil(e.month/3)),"month"],["QQQ",e=>"Q"+Math.ceil(e.month/3),"month"],["ww",e=>{let{week:t}=Z(e.year,e.month,e.day,e.dayOfWeek);return m(t,2)},"dayOfWeek"],["RRRR",e=>{let{isoYear:t}=Z(e.year,e.month,e.day,e.dayOfWeek);return m(t,4)},"dayOfWeek"],["D",e=>String(E(e.year,e.month,e.day)),"day"],["DD",e=>m(E(e.year,e.month,e.day),2),"day"],["DDD",e=>m(E(e.year,e.month,e.day),3),"day"],["LLLL",(e,t)=>{let n=u(t);return p(e,t,{month:"long"},"month",n?.monthLong,e.month-1)},"month"],["LLL",(e,t)=>{let n=u(t);return p(e,t,{month:"short"},"month",n?.monthShort,e.month-1)},"month"],["cccc",(e,t)=>{let n=u(t);return p(e,t,{weekday:"long"},"weekday",n?.weekdayLong,e.dayOfWeek-1)},"dayOfWeek"],["ccc",(e,t)=>{let n=u(t);return p(e,t,{weekday:"short"},"weekday",n?.weekdayShort,e.dayOfWeek-1)},"dayOfWeek"],["GGGG",(e,t)=>F(e,t,{era:"long"},"era"),"year"],["G",(e,t)=>F(e,t,{era:"short"},"era"),"year"],["zzzz",(e,t)=>F(e,t,{timeZoneName:"longGeneric"},"timeZoneName"),"timeZoneId"],["z",(e,t)=>F(e,t,{timeZoneName:"short"},"timeZoneName"),"timeZoneId"]];var ge=A.map(([e])=>e).sort((e,t)=>t.length-e.length);function H(e){let t=[],n=0;for(;n<e.length;){let o=e[n];if(o==="'"){if(e[n+1]==="'"){z(t,"'"),n+=2;continue}let a=n+1,r="",s=!1;for(;a<e.length;){if(e[a]==="'"){if(e[a+1]==="'"){r+="'",a+=2;continue}s=!0,a+=1;break}r+=e[a],a+=1}if(!s)throw new c({format:e,message:`temporal-fmt: unterminated quote in format string "${e}"`});z(t,r),n=a;continue}let i=ge.find(a=>e.startsWith(a,n));if(i){let a=i[i.length-1];if(e[n+i.length]===a){let r=n+i.length;for(;e[r]===a;)r+=1;throw new d({format:e,token:e.slice(n,r),message:`temporal-fmt: "${e.slice(n,r)}" in format string "${e}" isn't a recognized token \u2014 did you mean "${i}"?`})}t.push({kind:"token",value:i}),n+=i.length;continue}z(t,o),n+=1}return t}function z(e,t){let n=e[e.length-1];n&&n.kind==="literal"?n.value+=t:e.push({kind:"literal",value:t})}var G=new Set(["latn","arab","deva","beng","guru","gujr","orya","tamldec","telu","knda","mlym","fullwide","hanidec"]),q=new Map;function fe(e){let t=q.get(e);if(t)return t;/* c8 ignore start @preserve -- dead by construction, not just
24
+ see rationale above *//* c8 ignore stop @preserve */var se=new Map;function X(e){return e.replace(/_/g,"-")}var k=new Map,me=500;function R(e){let t=k.get(e);if(t!==void 0)return t;let n;try{n=new Intl.Locale(e.replace(/_/g,"-")).toString().toLowerCase()}catch{n=e}if(k.size>=me){let o=k.keys().next().value;o!==void 0&&k.delete(o)}return k.set(e,n),n}function u(e){let t=R(e);return se.get(t)}var ce=[0,31,59,90,120,151,181,212,243,273,304,334];function Y(e){return e%4===0&&e%100!==0||e%400===0}function T(e){return Y(e)?366:365}function E(e,t,n){let o=ce[t-1]+n;return t>2&&Y(e)&&(o+=1),o}var U=2e3;function le(e){let t=0;if(e>=U)for(let o=U;o<e;o++)t+=T(o);else for(let o=e;o<U;o++)t-=T(o);return((5+t)%7+7)%7+1}function Z(e,t,n,o){let a=E(e,t,n)+(4-o),r,s;a<1?(r=e-1,s=a+T(r)):a>T(e)?(r=e+1,s=a-T(e)):(r=e,s=a);let I=1+(4-le(r)+7)%7,M=1+Math.floor((s-I)/7);return{isoYear:r,week:M}}function m(e,t){let n=e<0,o=String(Math.abs(e)).padStart(t,"0");return n?"-"+o:o}m.fraction=function(t,n){let o=t.millisecond*1e6+(t.microsecond??0)*1e3+(t.nanosecond??0);return m(o,9).slice(0,n)};var F="en-US",b=new Map,ue=500;function j(e,t){let n=JSON.stringify([R(e),t]),o=b.get(n);if(o)return o;if(b.size>=ue){let i=b.keys().next().value;i!==void 0&&b.delete(i)}try{o=new Intl.DateTimeFormat(X(e),t)}catch(i){throw new g({actual:e,reason:i.message})}return b.set(n,o),o}var x;W(()=>{x=void 0});function de(){if(x===void 0){x=!1;try{let e=K();new Intl.DateTimeFormat("en-US",{day:"numeric"}).formatToParts(e.PlainDate.from({year:1970,month:1,day:1})),x=!0}catch{}}return x}function L(e,t,n,o){let i=e?.calendarId,a={...n,calendar:i&&i!=="iso8601"?i:"gregory"},r=e.toLocaleString;if(typeof r!="function"||r===Object.prototype.toLocaleString)throw new Error(`temporal-fmt: locale-aware part "${o}" needs a value that implements toLocaleString (a real Temporal object). A plain field bag cannot render locale-aware names \u2014 pass a Temporal.PlainDate/PlainDateTime/ZonedDateTime.`);if(!de())try{return r.call(e,X(t),a)}catch(y){throw y instanceof RangeError?new g({actual:t,reason:y.message}):y}let{toInstant:s,timeZoneId:l}=e,I=typeof s=="function"&&typeof l=="string",M=I?e.toInstant():e,B={...a,...I?{timeZone:l}:{}},N=j(t,B).formatToParts(M),v=N.findIndex(y=>y.type===o);if(v===-1)throw new Error(`temporal-fmt: locale "${t}" produced no "${o}" part for this token. This usually means the Temporal object is missing the field the token needs.`);let h=N[v].value,_=N[v-1],C=N[v+1];return _?.type==="literal"&&!/\s/.test(_.value)&&(h=_.value+h),C?.type==="literal"&&!/\s/.test(C.value)&&(h=h+C.value),h}function pe(e,t){let n=u(t);if(n)return e<12?n.dayPeriod[0]:n.dayPeriod[1];let o=new Date(Date.UTC(1970,0,1,e)),a=j(t,{hour:"numeric",hour12:!0,timeZone:"UTC"}).formatToParts(o).find(r=>r.type==="dayPeriod");if(!a)throw new Error(`temporal-fmt: locale "${t}" produced no "dayPeriod" part for token "a".`);return a.value}function p(e,t,n,o,i,a){return i&&a!==void 0&&a>=0&&a<i.length?i[a]:L(e,t,n,o)}function f(e,t){if(e==="+00:00"&&(t==="X"||t==="XX"||t==="XXX"))return"Z";if(e.length>6){if(t==="xxx")return e;throw new Error(`temporal-fmt: token "${t}" cannot represent the offset "${e}", which has a seconds component. None of the X/XX/XXX/x/xx tokens support offset seconds; use "xxx" instead, which formats the full offset unchanged.`)}let n=e[0],o=e.slice(1,3),i=e.slice(4,6);switch(t){case"X":case"x":return i==="00"?`${n}${o}`:`${n}${o}${i}`;case"XX":case"xx":return`${n}${o}${i}`;case"XXX":case"xxx":return`${n}${o}:${i}`}}var A=[["yyyy",e=>m(e.year,4),"year"],["yy",e=>{if(e.year<0)throw new Error(`temporal-fmt: token "yy" doesn't support negative years (got ${e.year}), since truncating to 2 digits would make it indistinguishable from a positive year. Use "yyyy" instead.`);return m(e.year%100,2)},"year"],["y",e=>m(e.year,0),"year"],["MMMM",(e,t)=>{let n=u(t);return p(e,t,{month:"long"},"month",n?.monthLong,e.month-1)},"month"],["MMM",(e,t)=>{let n=u(t);return p(e,t,{month:"short"},"month",n?.monthShort,e.month-1)},"month"],["MM",e=>m(e.month,2),"month"],["M",e=>String(e.month),"month"],["dd",e=>m(e.day,2),"day"],["d",e=>String(e.day),"day"],["EEEE",(e,t)=>{let n=u(t);return p(e,t,{weekday:"long"},"weekday",n?.weekdayLong,e.dayOfWeek-1)},"dayOfWeek"],["EEE",(e,t)=>{let n=u(t);return p(e,t,{weekday:"short"},"weekday",n?.weekdayShort,e.dayOfWeek-1)},"dayOfWeek"],["HH",e=>m(e.hour,2),"hour"],["H",e=>String(e.hour),"hour"],["hh",e=>m(e.hour%12||12,2),"hour"],["h",e=>String(e.hour%12||12),"hour"],["mm",e=>m(e.minute,2),"minute"],["m",e=>String(e.minute),"minute"],["ss",e=>m(e.second,2),"second"],["s",e=>String(e.second),"second"],["SSSSSSSSS",e=>m.fraction(e,9),"millisecond"],["SSSSSSSS",e=>m.fraction(e,8),"millisecond"],["SSSSSSS",e=>m.fraction(e,7),"millisecond"],["SSSSSS",e=>m.fraction(e,6),"millisecond"],["SSSSS",e=>m.fraction(e,5),"millisecond"],["SSSS",e=>m.fraction(e,4),"millisecond"],["SSS",e=>m.fraction(e,3),"millisecond"],["SS",e=>m.fraction(e,2),"millisecond"],["S",e=>m.fraction(e,1),"millisecond"],["a",(e,t)=>pe(e.hour,t),"hour"],["zzz",e=>e.timeZoneId,"timeZoneId"],["xxx",e=>f(e.offset,"xxx"),"offset"],["xx",e=>f(e.offset,"xx"),"offset"],["X",e=>f(e.offset,"X"),"offset"],["XX",e=>f(e.offset,"XX"),"offset"],["XXX",e=>f(e.offset,"XXX"),"offset"],["x",e=>f(e.offset,"x"),"offset"],["do",e=>{let t=e.day,n=t%10,o=t%100;return o>=11&&o<=13?t+"th":n===1?t+"st":n===2?t+"nd":n===3?t+"rd":t+"th"},"day"],["Q",e=>String(Math.ceil(e.month/3)),"month"],["QQQ",e=>"Q"+Math.ceil(e.month/3),"month"],["ww",e=>{let{week:t}=Z(e.year,e.month,e.day,e.dayOfWeek);return m(t,2)},"dayOfWeek"],["RRRR",e=>{let{isoYear:t}=Z(e.year,e.month,e.day,e.dayOfWeek);return m(t,4)},"dayOfWeek"],["D",e=>String(E(e.year,e.month,e.day)),"day"],["DD",e=>m(E(e.year,e.month,e.day),2),"day"],["DDD",e=>m(E(e.year,e.month,e.day),3),"day"],["LLLL",(e,t)=>{let n=u(t);return p(e,t,{month:"long"},"month",n?.monthLong,e.month-1)},"month"],["LLL",(e,t)=>{let n=u(t);return p(e,t,{month:"short"},"month",n?.monthShort,e.month-1)},"month"],["cccc",(e,t)=>{let n=u(t);return p(e,t,{weekday:"long"},"weekday",n?.weekdayLong,e.dayOfWeek-1)},"dayOfWeek"],["ccc",(e,t)=>{let n=u(t);return p(e,t,{weekday:"short"},"weekday",n?.weekdayShort,e.dayOfWeek-1)},"dayOfWeek"],["GGGG",(e,t)=>L(e,t,{era:"long"},"era"),"year"],["G",(e,t)=>L(e,t,{era:"short"},"era"),"year"],["zzzz",(e,t)=>L(e,t,{timeZoneName:"longGeneric"},"timeZoneName"),"timeZoneId"],["z",(e,t)=>L(e,t,{timeZoneName:"short"},"timeZoneName"),"timeZoneId"]];var ge=A.map(([e])=>e).sort((e,t)=>t.length-e.length);function H(e){let t=[],n=0;for(;n<e.length;){let o=e[n];if(o==="'"){if(e[n+1]==="'"){z(t,"'"),n+=2;continue}let a=n+1,r="",s=!1;for(;a<e.length;){if(e[a]==="'"){if(e[a+1]==="'"){r+="'",a+=2;continue}s=!0,a+=1;break}r+=e[a],a+=1}if(!s)throw new c({format:e,message:`temporal-fmt: unterminated quote in format string "${e}"`});z(t,r),n=a;continue}let i=ge.find(a=>e.startsWith(a,n));if(i){let a=i[i.length-1];if(e[n+i.length]===a){let r=n+i.length;for(;e[r]===a;)r+=1;throw new d({format:e,token:e.slice(n,r),message:`temporal-fmt: "${e.slice(n,r)}" in format string "${e}" isn't a recognized token \u2014 did you mean "${i}"?`})}t.push({kind:"token",value:i}),n+=i.length;continue}z(t,o),n+=1}return t}function z(e,t){let n=e[e.length-1];n&&n.kind==="literal"?n.value+=t:e.push({kind:"literal",value:t})}var G=new Set(["latn","arab","deva","beng","guru","gujr","orya","tamldec","telu","knda","mlym","fullwide","hanidec"]),q=new Map;function fe(e){let t=q.get(e);if(t)return t;/* c8 ignore start @preserve -- dead by construction, not just
25
25
  untested: both callers (convertDigits, convertDigitsToAscii) already
26
26
  return early on system === 'latn' before calling getDigitMap at all,
27
27
  so this function is never invoked with 'latn'. Kept as a defensive
28
28
  fallback rather than trusting that stays true for any future
29
- caller. */if(e==="latn"){t={};for(let n=0;n<10;n++)t[String(n)]=String(n)}else{/* c8 ignore stop @preserve */let n=new Intl.NumberFormat("en-US-u-nu-"+e,{useGrouping:!1});t={};for(let o=0;o<10;o++)t[String(o)]=n.format(o)}return q.set(e,t),t}function he(e,t){if(t==="latn")return e;if(!G.has(t))throw new g({actual:t,reason:`numbering system "${t}" is not supported. Supported: ${[...G].join(", ")}.`});let n=fe(t),o="";for(let i of e)i>="0"&&i<="9"?o+=n[i]??i:o+=i;return o}function x(e,t){let n=t.numberingSystem??"latn";return n==="latn"?e:he(e,n)}var O=new Map(A.map(([e,t,n])=>[e,{fn:t,field:n}])),$=new Map,ye=500;function P(e){let t=$.get(e);if(t)return t;if($.size>=ye){let n=$.keys().next().value;n!==void 0&&$.delete(n)}return t=H(e),$.set(e,t),t}function we(e,t,n={}){if(t.length>1e3)throw new c({format:t,message:`temporal-fmt: format string exceeds maximum length of ${1e3} characters (got ${t.length}).`});let o=n.locale??S,i=P(t),a="";for(let r of i){if(r.kind==="literal"){a+=r.value;continue}let s=O.get(r.value);/* c8 ignore start @preserve -- unreachable: tokenize() only ever emits
29
+ caller. */if(e==="latn"){t={};for(let n=0;n<10;n++)t[String(n)]=String(n)}else{/* c8 ignore stop @preserve */let n=new Intl.NumberFormat("en-US-u-nu-"+e,{useGrouping:!1});t={};for(let o=0;o<10;o++)t[String(o)]=n.format(o)}return q.set(e,t),t}function he(e,t){if(t==="latn")return e;if(!G.has(t))throw new g({actual:t,reason:`numbering system "${t}" is not supported. Supported: ${[...G].join(", ")}.`});let n=fe(t),o="";for(let i of e)i>="0"&&i<="9"?o+=n[i]??i:o+=i;return o}function S(e,t){let n=t.numberingSystem??"latn";return n==="latn"?e:he(e,n)}var O=new Map(A.map(([e,t,n])=>[e,{fn:t,field:n}])),$=new Map,ye=500;function P(e){let t=$.get(e);if(t)return t;if($.size>=ye){let n=$.keys().next().value;n!==void 0&&$.delete(n)}return t=H(e),$.set(e,t),t}function we(e,t,n={}){if(t.length>1e3)throw new c({format:t,message:`temporal-fmt: format string exceeds maximum length of ${1e3} characters (got ${t.length}).`});let o=n.locale??F,i=P(t),a="";for(let r of i){if(r.kind==="literal"){a+=r.value;continue}let s=O.get(r.value);/* c8 ignore start @preserve -- unreachable: tokenize() only ever emits
30
30
  tokens present in TOKENS, and HANDLER_BY_TOKEN is built from that
31
31
  same list, so every token piece.value can hold already has an entry
32
32
  here. Same defensive-guard category as the twin checks in
33
- analyze.ts/formatDuration.ts. */if(!s)throw new d({token:r.value,format:t,message:`temporal-fmt: unknown token "${r.value}"`});/* c8 ignore stop @preserve */if(e[s.field]===void 0)throw new c({format:t,token:r.value,message:`temporal-fmt: token "${r.value}" requires "${s.field}", which this Temporal object doesn't have. (e.g. PlainDate has no time fields, PlainTime has no date fields)`});a+=s.fn(e,o)}return x(a,n)}function Te(e,t,n={}){if(t.length>1e3)throw new c({format:t,message:`temporal-fmt: format string exceeds maximum length of ${1e3} characters (got ${t.length}).`});let o=n.locale??S,i=P(t),a=[];for(let r of i){if(r.kind==="literal"){let l=a[a.length-1];/* c8 ignore start @preserve -- unreachable through tokenize()'s own
33
+ analyze.ts/formatDuration.ts. */if(!s)throw new d({token:r.value,format:t,message:`temporal-fmt: unknown token "${r.value}"`});/* c8 ignore stop @preserve */if(e[s.field]===void 0)throw new c({format:t,token:r.value,message:`temporal-fmt: token "${r.value}" requires "${s.field}", which this Temporal object doesn't have. (e.g. PlainDate has no time fields, PlainTime has no date fields)`});a+=s.fn(e,o)}return S(a,n)}function ke(e,t,n={}){if(t.length>1e3)throw new c({format:t,message:`temporal-fmt: format string exceeds maximum length of ${1e3} characters (got ${t.length}).`});let o=n.locale??F,i=P(t),a=[];for(let r of i){if(r.kind==="literal"){let l=a[a.length-1];/* c8 ignore start @preserve -- unreachable through tokenize()'s own
34
34
  output: appendLiteral() in tokenize.ts already merges every
35
35
  adjacent literal character before pieces ever reaches here, so
36
36
  two 'literal' pieces never sit back-to-back in the array this
37
37
  loop walks. Kept as defense-in-depth in case that invariant ever
38
- changes upstream. */if(l&&l.type==="literal")l.value+=r.value;else{/* c8 ignore stop @preserve */a.push({type:"literal",value:r.value})}continue}let s=O.get(r.value);/* c8 ignore start @preserve -- unreachable, see the note in format() above */if(!s)throw new d({token:r.value,format:t,message:`temporal-fmt: unknown token "${r.value}"`});/* c8 ignore stop @preserve */if(e[s.field]===void 0)throw new c({format:t,token:r.value,message:`temporal-fmt: token "${r.value}" requires "${s.field}", which this Temporal object doesn't have. (e.g. PlainDate has no time fields, PlainTime has no date fields)`});a.push({type:"token",value:x(s.fn(e,o),n),token:r.value})}return a}function ke(e){if(e.length>1e3)throw new c({format:e,message:`temporal-fmt: format string exceeds maximum length of ${1e3} characters (got ${e.length}).`});let t=P(e);return{formatStr:e,pieces:t,format(n,o={}){let i=o.locale??S,a="";for(let r of t){if(r.kind==="literal"){a+=r.value;continue}let s=O.get(r.value);if(!s)throw new d({token:r.value,format:e,message:`temporal-fmt: unknown token "${r.value}"`});if(n[s.field]===void 0)throw new c({format:e,token:r.value,message:`temporal-fmt: token "${r.value}" requires "${s.field}", which this Temporal object doesn't have. (e.g. PlainDate has no time fields, PlainTime has no date fields)`});a+=s.fn(n,i)}return x(a,o)},formatToParts(n,o={}){let i=o.locale??S,a=[];for(let r of t){if(r.kind==="literal"){let l=a[a.length-1];l&&l.type==="literal"?l.value+=r.value:a.push({type:"literal",value:r.value});continue}let s=O.get(r.value);if(!s)throw new d({token:r.value,format:e,message:`temporal-fmt: unknown token "${r.value}"`});if(n[s.field]===void 0)throw new c({format:e,token:r.value,message:`temporal-fmt: token "${r.value}" requires "${s.field}", which this Temporal object doesn't have. (e.g. PlainDate has no time fields, PlainTime has no date fields)`});a.push({type:"token",value:x(s.fn(n,i),o),token:r.value})}return a}}}function Ee(e){return P(e)}function be(e){return O.get(e)}0&&(module.exports={_getPieces,_handlerFor,compileFormat,format,formatToParts});
38
+ changes upstream. */if(l&&l.type==="literal")l.value+=r.value;else{/* c8 ignore stop @preserve */a.push({type:"literal",value:r.value})}continue}let s=O.get(r.value);/* c8 ignore start @preserve -- unreachable, see the note in format() above */if(!s)throw new d({token:r.value,format:t,message:`temporal-fmt: unknown token "${r.value}"`});/* c8 ignore stop @preserve */if(e[s.field]===void 0)throw new c({format:t,token:r.value,message:`temporal-fmt: token "${r.value}" requires "${s.field}", which this Temporal object doesn't have. (e.g. PlainDate has no time fields, PlainTime has no date fields)`});a.push({type:"token",value:S(s.fn(e,o),n),token:r.value})}return a}function Te(e){if(e.length>1e3)throw new c({format:e,message:`temporal-fmt: format string exceeds maximum length of ${1e3} characters (got ${e.length}).`});let t=P(e);return{formatStr:e,pieces:t,format(n,o={}){let i=o.locale??F,a="";for(let r of t){if(r.kind==="literal"){a+=r.value;continue}let s=O.get(r.value);if(!s)throw new d({token:r.value,format:e,message:`temporal-fmt: unknown token "${r.value}"`});if(n[s.field]===void 0)throw new c({format:e,token:r.value,message:`temporal-fmt: token "${r.value}" requires "${s.field}", which this Temporal object doesn't have. (e.g. PlainDate has no time fields, PlainTime has no date fields)`});a+=s.fn(n,i)}return S(a,o)},formatToParts(n,o={}){let i=o.locale??F,a=[];for(let r of t){if(r.kind==="literal"){let l=a[a.length-1];l&&l.type==="literal"?l.value+=r.value:a.push({type:"literal",value:r.value});continue}let s=O.get(r.value);if(!s)throw new d({token:r.value,format:e,message:`temporal-fmt: unknown token "${r.value}"`});if(n[s.field]===void 0)throw new c({format:e,token:r.value,message:`temporal-fmt: token "${r.value}" requires "${s.field}", which this Temporal object doesn't have. (e.g. PlainDate has no time fields, PlainTime has no date fields)`});a.push({type:"token",value:S(s.fn(n,i),o),token:r.value})}return a}}}function Ee(e){return P(e)}function be(e){return O.get(e)}0&&(module.exports={_getPieces,_handlerFor,compileFormat,format,formatToParts});
39
39
  //# sourceMappingURL=format.cjs.map