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
package/dist/interval.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n}from"./chunk-F4RGUDA3.js";import"./chunk-4JWGUR4O.js";import"./chunk-R52YOKI3.js";import"./chunk-C5YESWFT.js";import"./chunk-3MZLTVP3.js";import"./chunk-5U5WJ465.js";import"./chunk-UJR6DHXY.js";import"./chunk-EHLRZULM.js";import"./chunk-C6ZZ62ET.js";export{b as contains,i as difference,m as formatRange,n as formatRangeToParts,g as intersection,d as intersects,a as interval,f as isAfter,e as isBefore,k as mergeIntervals,c as overlaps,l as splitInterval,j as subtract,h as union};
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n}from"./chunk-4XRE37WT.js";import"./chunk-SSPABEUR.js";import"./chunk-NPKJ7QFK.js";import"./chunk-GMGZZG6I.js";import"./chunk-3MZLTVP3.js";import"./chunk-5U5WJ465.js";import"./chunk-UJR6DHXY.js";import"./chunk-EHLRZULM.js";import"./chunk-C6ZZ62ET.js";export{b as contains,i as difference,m as formatRange,n as formatRangeToParts,g as intersection,d as intersects,a as interval,f as isAfter,e as isBefore,k as mergeIntervals,c as overlaps,l as splitInterval,j as subtract,h as union};
2
2
  //# sourceMappingURL=interval.js.map
package/dist/parse.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var pe=Object.defineProperty;var Ge=Object.getOwnPropertyDescriptor;var Ke=Object.getOwnPropertyNames;var We=Object.prototype.hasOwnProperty;var Qe=(e,t)=>{for(var n in t)pe(e,n,{get:t[n],enumerable:!0})},je=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ke(t))!We.call(e,o)&&o!==n&&pe(e,o,{get:()=>t[o],enumerable:!(r=Ge(t,o))||r.enumerable});return e};var qe=e=>je(pe({},"__esModule",{value:!0}),e);var _t={};Qe(_t,{compileParser:()=>At,parse:()=>de,parseToParts:()=>Ze,safeParse:()=>ze,tryParse:()=>Ve});module.exports=qe(_t);var Be,Je=[];function De(e){Je.push(e)}function et(){return Be??globalThis.Temporal}function se(){let e=et();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 E=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 r=Error.captureStackTrace;typeof r=="function"&&r(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}}},S=class extends E{constructor(t){let{message:n,...r}=t;super(n??`format string "${t.format??""}" has a syntax error${t.reason?`: ${t.reason}`:""}.`,{code:"FORMAT_SYNTAX_ERROR",...r}),this.name="FormatSyntaxError"}},I=class extends E{constructor(t){let{message:n,...r}=t;super(n??`token "${t.token??""}" is not a recognized temporal-fmt token${t.format?` in format string "${t.format}"`:""}.`,{code:"UNKNOWN_TOKEN",...r}),this.name="UnknownTokenError"}},T=class extends E{constructor(t){let{message:n,...r}=t;super(n??`input "${t.input??""}" does not match format "${t.format??""}"${t.reason?`: ${t.reason}`:""}.`,{code:"PARSE_MISMATCH",...r}),this.name="ParseMismatchError"}},L=class extends E{constructor(t){let{message:n,...r}=t;super(n??`input "${t.input??""}" does not describe a valid date${t.reason?`: ${t.reason}`:""}.`,{code:"INVALID_DATE",...r}),this.name="InvalidDateError"}};/* c8 ignore start @preserve -- InvalidTimeError is part of the public
1
+ "use strict";var he=Object.defineProperty;var Ke=Object.getOwnPropertyDescriptor;var We=Object.getOwnPropertyNames;var Qe=Object.prototype.hasOwnProperty;var je=(e,t)=>{for(var n in t)he(e,n,{get:t[n],enumerable:!0})},Be=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of We(t))!Qe.call(e,o)&&o!==n&&he(e,o,{get:()=>t[o],enumerable:!(r=Ke(t,o))||r.enumerable});return e};var qe=e=>Be(he({},"__esModule",{value:!0}),e);var Xt={};je(Xt,{compileParser:()=>Ct,parse:()=>ue,parseToParts:()=>Ze,safeParse:()=>Ve,tryParse:()=>Ue});module.exports=qe(Xt);var Je,et=[];function De(e){et.push(e)}function tt(){return Je??globalThis.Temporal}function R(){let e=tt();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 T=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 r=Error.captureStackTrace;typeof r=="function"&&r(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}}},S=class extends T{constructor(t){let{message:n,...r}=t;super(n??`format string "${t.format??""}" has a syntax error${t.reason?`: ${t.reason}`:""}.`,{code:"FORMAT_SYNTAX_ERROR",...r}),this.name="FormatSyntaxError"}},I=class extends T{constructor(t){let{message:n,...r}=t;super(n??`token "${t.token??""}" is not a recognized temporal-fmt token${t.format?` in format string "${t.format}"`:""}.`,{code:"UNKNOWN_TOKEN",...r}),this.name="UnknownTokenError"}},E=class extends T{constructor(t){let{message:n,...r}=t;super(n??`input "${t.input??""}" does not match format "${t.format??""}"${t.reason?`: ${t.reason}`:""}.`,{code:"PARSE_MISMATCH",...r}),this.name="ParseMismatchError"}},O=class extends T{constructor(t){let{message:n,...r}=t;super(n??`input "${t.input??""}" does not describe a valid date${t.reason?`: ${t.reason}`:""}.`,{code:"INVALID_DATE",...r}),this.name="InvalidDateError"}};/* 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
@@ -10,7 +10,7 @@
10
10
  is rejected as a plain shape mismatch before any semantic check
11
11
  could run. There's no live gap to hook this into without inventing a
12
12
  redundant check purely to give this class a body. Left unconstructed
13
- until the library actually has a real invalid-time case to report. *//* c8 ignore stop @preserve */var F=class extends E{constructor(t){let{message:n,...r}=t;super(n??`offset "${t.actual??""}" is invalid${t.reason?`: ${t.reason}`:""}.`,{code:"INVALID_OFFSET",...r}),this.name="InvalidOffsetError"}},G=class extends E{constructor(t){let{message:n,...r}=t;super(n??`time zone "${t.actual??""}" is not a recognized IANA time zone or fixed offset${t.reason?`: ${t.reason}`:""}.`,{code:"INVALID_TIME_ZONE",...r}),this.name="InvalidTimeZoneError"}};/* c8 ignore start @preserve -- InvalidCalendarError is part of the
13
+ until the library actually has a real invalid-time case to report. *//* c8 ignore stop @preserve */var P=class extends T{constructor(t){let{message:n,...r}=t;super(n??`offset "${t.actual??""}" is invalid${t.reason?`: ${t.reason}`:""}.`,{code:"INVALID_OFFSET",...r}),this.name="InvalidOffsetError"}},Y=class extends T{constructor(t){let{message:n,...r}=t;super(n??`time zone "${t.actual??""}" is not a recognized IANA time zone or fixed offset${t.reason?`: ${t.reason}`:""}.`,{code:"INVALID_TIME_ZONE",...r}),this.name="InvalidTimeZoneError"}};/* c8 ignore start @preserve -- InvalidCalendarError is part of the
14
14
  public error-class surface (exported from index.ts, code
15
15
  'INVALID_CALENDAR') but nothing in this package constructs one.
16
16
  Checked for a wiring opportunity the same way InvalidTimeZoneError
@@ -20,8 +20,8 @@
20
20
  of the locale string — it's never handed an arbitrary "calendar"
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
- parameter that could be invalid. *//* c8 ignore stop @preserve */var R=class extends E{constructor(t){let{message:n,...r}=t;super(n??`input "${t.input??""}" is ambiguous${t.reason?`: ${t.reason}`:""}.`,{code:"AMBIGUOUS_INPUT",...r}),this.name="AmbiguousInputError"}},N=class extends E{constructor(t){let{message:n,...r}=t;super(n??`locale "${t.actual??""}" is not a valid BCP-47 tag${t.reason?`: ${t.reason}`:""}.`,{code:"INVALID_LOCALE",...r}),this.name="InvalidLocaleError"}};/* c8 ignore start @preserve -- unreachable from the current test suite,
24
- see rationale above */function Me(e,t){let n=e.message;if(/unknown token|isn't a recognized token/.test(n))return new I({input:t.input,format:t.format,reason:n});if(/ambiguous/i.test(n))return new R({input:t.input,format:t.format,reason:n});if(/offset/.test(n)&&/out of range|exceeds|doesn't match the shape/i.test(n))return new F({input:t.input,format:t.format,reason:n});if(/no valid pattern matches/i.test(n))return new T({input:t.input,format:t.format,reason:n});if(/doesn't describe a valid date\/time|incomplete date|weekday token|quarter token/.test(n))return new L({input:t.input,format:t.format,reason:n});let r=n.toLowerCase();return r.includes("locale")&&(r.includes("produced no")||r.includes("not a valid"))||r.includes("cutoffs must be")?new N({input:t.input,format:t.format,reason:n}):/format string exceeds maximum length|input exceeds maximum length|unterminated quote|isn't a recognized token/i.test(n)?new S({input:t.input,format:t.format,reason:n}):new T({input:t.input,format:t.format,reason:n})}/* c8 ignore stop @preserve */var Le=new Map;var tt=[];function Oe(e){tt.push(e)}function Q(e){return e.replace(/_/g,"-")}var K=new Map,nt=500;function C(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>=nt){let r=K.keys().next().value;r!==void 0&&K.delete(r)}return K.set(e,n),n}function he(e){try{new Intl.Locale(Q(e))}catch{throw new N({actual:e,reason:"not a valid BCP-47 locale tag"})}}var W=new Map,rt=500;function z(e,t,n){let r=e.formatToParts(t),o=r.findIndex(p=>p.type===n);/* c8 ignore start @preserve -- defensive guard against a real but
23
+ parameter that could be invalid. *//* c8 ignore stop @preserve */var z=class extends T{constructor(t){let{message:n,...r}=t;super(n??`input "${t.input??""}" is ambiguous${t.reason?`: ${t.reason}`:""}.`,{code:"AMBIGUOUS_INPUT",...r}),this.name="AmbiguousInputError"}},N=class extends T{constructor(t){let{message:n,...r}=t;super(n??`locale "${t.actual??""}" is not a valid BCP-47 tag${t.reason?`: ${t.reason}`:""}.`,{code:"INVALID_LOCALE",...r}),this.name="InvalidLocaleError"}};/* c8 ignore start @preserve -- unreachable from the current test suite,
24
+ see rationale above */function Me(e,t){let n=e.message;if(/unknown token|isn't a recognized token/.test(n))return new I({input:t.input,format:t.format,reason:n});if(/ambiguous/i.test(n))return new z({input:t.input,format:t.format,reason:n});if(/offset/.test(n)&&/out of range|exceeds|doesn't match the shape/i.test(n))return new P({input:t.input,format:t.format,reason:n});if(/no valid pattern matches/i.test(n))return new E({input:t.input,format:t.format,reason:n});if(/doesn't describe a valid date\/time|incomplete date|weekday token|quarter token/.test(n))return new O({input:t.input,format:t.format,reason:n});let r=n.toLowerCase();return r.includes("locale")&&(r.includes("produced no")||r.includes("not a valid"))||r.includes("cutoffs must be")?new N({input:t.input,format:t.format,reason:n}):/format string exceeds maximum length|input exceeds maximum length|unterminated quote|isn't a recognized token/i.test(n)?new S({input:t.input,format:t.format,reason:n}):new E({input:t.input,format:t.format,reason:n})}/* c8 ignore stop @preserve */var Oe=new Map;var nt=[];function Le(e){nt.push(e)}function W(e){return e.replace(/_/g,"-")}var G=new Map,rt=500;function _(e){let t=G.get(e);if(t!==void 0)return t;let n;try{n=new Intl.Locale(e.replace(/_/g,"-")).toString().toLowerCase()}catch{n=e}if(G.size>=rt){let r=G.keys().next().value;r!==void 0&&G.delete(r)}return G.set(e,n),n}function ye(e){try{new Intl.Locale(W(e))}catch{throw new N({actual:e,reason:"not a valid BCP-47 locale tag"})}}var K=new Map,ot=500;function V(e,t,n){let r=e.formatToParts(t),o=r.findIndex(f=>f.type===n);/* c8 ignore start @preserve -- defensive guard against a real but
25
25
  unreproducible failure mode: an Intl implementation that omits the
26
26
  requested part type entirely for some locale. Checked every locale
27
27
  with unusual dayPeriod/weekday/month rendering available in this
@@ -32,19 +32,19 @@
32
32
  produced a false "gap" during investigation). None omit their part
33
33
  on this runtime. A different ICU version or a non-Node Intl
34
34
  implementation could plausibly behave differently, so this stays a
35
- real check rather than an assertion. *//* c8 ignore start @preserve */if(o===-1)throw new N({message:`temporal-fmt: locale produced no "${n}" part while building match vocabulary.`});/* c8 ignore stop @preserve */let a=r[o].value,s=r[o-1],m=r[o+1];return s?.type==="literal"&&!/\s/.test(s.value)&&(a=s.value+a),m?.type==="literal"&&!/\s/.test(m.value)&&(a=a+m.value),a}function ie(e,t,n){let r=new Map;for(let o=0;o<e.length;o++){let a=r.get(e[o]);if(a!==void 0)throw new Error(`temporal-fmt: locale "${n}" renders ${t} index ${a} and ${o} identically ("${e[o]}"). parse() can't reliably tell these apart for this locale/token, so this combination isn't supported.`);r.set(e[o],o)}}function M(e){let t=C(e);return Le.get(t)}function V(e){he(e);let t=C(e),n=Le.get(t);if(n)return n;let r=W.get(t);if(r)return r;let o=Q(e),a=new Intl.DateTimeFormat(o,{month:"long",timeZone:"UTC"}),s=new Intl.DateTimeFormat(o,{month:"short",timeZone:"UTC"}),m=[],p=[];for(let y=0;y<12;y++){let b=new Date(Date.UTC(2020,y,1));m.push(z(a,b,"month")),p.push(z(s,b,"month"))}ie(m,"MMMM month",e),ie(p,"MMM month",e);let l=new Intl.DateTimeFormat(o,{weekday:"long",timeZone:"UTC"}),c=new Intl.DateTimeFormat(o,{weekday:"short",timeZone:"UTC"}),i=[],d=[];for(let y=0;y<7;y++){let b=new Date(Date.UTC(2024,0,1+y));i.push(z(l,b,"weekday")),d.push(z(c,b,"weekday"))}ie(i,"EEEE weekday",e),ie(d,"EEE weekday",e);let u=new Intl.DateTimeFormat(o,{hour:"numeric",hour12:!0,timeZone:"UTC"}),h=z(u,new Date(Date.UTC(2020,0,1,1)),"dayPeriod"),k=z(u,new Date(Date.UTC(2020,0,1,13)),"dayPeriod"),$=[...new Set([h,k])],O={monthLong:m,monthShort:p,weekdayLong:i,weekdayShort:d,dayPeriod:$};if(W.size>=rt){let y=W.keys().next().value;y!==void 0&&W.delete(y)}return W.set(t,O),O}var ot=[0,31,59,90,120,151,181,212,243,273,304,334];function Pe(e){return e%4===0&&e%100!==0||e%400===0}function j(e){return Pe(e)?366:365}function q(e,t,n){let r=ot[t-1]+n;return t>2&&Pe(e)&&(r+=1),r}var ye=2e3;function at(e){let t=0;if(e>=ye)for(let r=ye;r<e;r++)t+=j(r);else for(let r=e;r<ye;r++)t-=j(r);return((5+t)%7+7)%7+1}function we(e,t,n,r){let a=q(e,t,n)+(4-r),s,m;a<1?(s=e-1,m=a+j(s)):a>j(e)?(s=e+1,m=a-j(e)):(s=e,m=a);let l=1+(4-at(s)+7)%7,c=1+Math.floor((m-l)/7);return{isoYear:s,week:c}}function g(e,t){let n=e<0,r=String(Math.abs(e)).padStart(t,"0");return n?"-"+r:r}g.fraction=function(t,n){let r=t.millisecond*1e6+(t.microsecond??0)*1e3+(t.nanosecond??0);return g(r,9).slice(0,n)};var me="en-US",B=new Map,st=500;function Ie(e,t){let n=JSON.stringify([C(e),t]),r=B.get(n);if(r)return r;if(B.size>=st){let o=B.keys().next().value;o!==void 0&&B.delete(o)}try{r=new Intl.DateTimeFormat(Q(e),t)}catch(o){throw new N({actual:e,reason:o.message})}return B.set(n,r),r}var J;De(()=>{J=void 0});function it(){if(J===void 0){J=!1;try{let e=se();new Intl.DateTimeFormat("en-US",{day:"numeric"}).formatToParts(e.PlainDate.from({year:1970,month:1,day:1})),J=!0}catch{}}return J}function ee(e,t,n,r){let o=e?.calendarId,a={...n,calendar:o&&o!=="iso8601"?o:"gregory"},s=e.toLocaleString;if(typeof s!="function"||s===Object.prototype.toLocaleString)throw new Error(`temporal-fmt: locale-aware part "${r}" 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(!it())try{return s.call(e,Q(t),a)}catch(y){throw y instanceof RangeError?new N({actual:t,reason:y.message}):y}let{toInstant:m,timeZoneId:p}=e,l=typeof m=="function"&&typeof p=="string",c=l?e.toInstant():e,i={...a,...l?{timeZone:p}:{}},u=Ie(t,i).formatToParts(c),h=u.findIndex(y=>y.type===r);if(h===-1)throw new Error(`temporal-fmt: locale "${t}" produced no "${r}" part for this token. This usually means the Temporal object is missing the field the token needs.`);let k=u[h].value,$=u[h-1],O=u[h+1];return $?.type==="literal"&&!/\s/.test($.value)&&(k=$.value+k),O?.type==="literal"&&!/\s/.test(O.value)&&(k=k+O.value),k}function mt(e,t){let n=M(t);if(n)return e<12?n.dayPeriod[0]:n.dayPeriod[1];let r=new Date(Date.UTC(1970,0,1,e)),a=Ie(t,{hour:"numeric",hour12:!0,timeZone:"UTC"}).formatToParts(r).find(s=>s.type==="dayPeriod");if(!a)throw new Error(`temporal-fmt: locale "${t}" produced no "dayPeriod" part for token "a".`);return a.value}function v(e,t,n,r,o,a){return o&&a!==void 0&&a>=0&&a<o.length?o[a]:ee(e,t,n,r)}function Z(e,t){if(e==="+00:00"&&(t==="X"||t==="XX"||t==="XXX"))return"Z";let n=e[0],r=e.slice(1,3),o=e.slice(4,6);switch(t){case"X":case"x":return o==="00"?`${n}${r}`:`${n}${r}${o}`;case"XX":case"xx":return`${n}${r}${o}`;case"XXX":case"xxx":return`${n}${r}:${o}`}}var Fe=[["yyyy",e=>g(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 g(e.year%100,2)},"year"],["MMMM",(e,t)=>{let n=M(t);return v(e,t,{month:"long"},"month",n?.monthLong,e.month-1)},"month"],["MMM",(e,t)=>{let n=M(t);return v(e,t,{month:"short"},"month",n?.monthShort,e.month-1)},"month"],["MM",e=>g(e.month,2),"month"],["M",e=>String(e.month),"month"],["dd",e=>g(e.day,2),"day"],["d",e=>String(e.day),"day"],["EEEE",(e,t)=>{let n=M(t);return v(e,t,{weekday:"long"},"weekday",n?.weekdayLong,e.dayOfWeek-1)},"dayOfWeek"],["EEE",(e,t)=>{let n=M(t);return v(e,t,{weekday:"short"},"weekday",n?.weekdayShort,e.dayOfWeek-1)},"dayOfWeek"],["HH",e=>g(e.hour,2),"hour"],["H",e=>String(e.hour),"hour"],["hh",e=>g(e.hour%12||12,2),"hour"],["h",e=>String(e.hour%12||12),"hour"],["mm",e=>g(e.minute,2),"minute"],["m",e=>String(e.minute),"minute"],["ss",e=>g(e.second,2),"second"],["s",e=>String(e.second),"second"],["SSSSSSSSS",e=>g.fraction(e,9),"millisecond"],["SSSSSSSS",e=>g.fraction(e,8),"millisecond"],["SSSSSSS",e=>g.fraction(e,7),"millisecond"],["SSSSSS",e=>g.fraction(e,6),"millisecond"],["SSSSS",e=>g.fraction(e,5),"millisecond"],["SSSS",e=>g.fraction(e,4),"millisecond"],["SSS",e=>g.fraction(e,3),"millisecond"],["SS",e=>g.fraction(e,2),"millisecond"],["S",e=>g.fraction(e,1),"millisecond"],["a",(e,t)=>mt(e.hour,t),"hour"],["zzz",e=>e.timeZoneId,"timeZoneId"],["xxx",e=>Z(e.offset,"xxx"),"offset"],["xx",e=>Z(e.offset,"xx"),"offset"],["X",e=>Z(e.offset,"X"),"offset"],["XX",e=>Z(e.offset,"XX"),"offset"],["XXX",e=>Z(e.offset,"XXX"),"offset"],["x",e=>Z(e.offset,"x"),"offset"],["do",e=>{let t=e.day,n=t%10,r=t%100;return r>=11&&r<=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}=we(e.year,e.month,e.day,e.dayOfWeek);return g(t,2)},"dayOfWeek"],["RRRR",e=>{let{isoYear:t}=we(e.year,e.month,e.day,e.dayOfWeek);return g(t,4)},"dayOfWeek"],["D",e=>String(q(e.year,e.month,e.day)),"day"],["DD",e=>g(q(e.year,e.month,e.day),2),"day"],["DDD",e=>g(q(e.year,e.month,e.day),3),"day"],["LLLL",(e,t)=>{let n=M(t);return v(e,t,{month:"long"},"month",n?.monthLong,e.month-1)},"month"],["LLL",(e,t)=>{let n=M(t);return v(e,t,{month:"short"},"month",n?.monthShort,e.month-1)},"month"],["cccc",(e,t)=>{let n=M(t);return v(e,t,{weekday:"long"},"weekday",n?.weekdayLong,e.dayOfWeek-1)},"dayOfWeek"],["ccc",(e,t)=>{let n=M(t);return v(e,t,{weekday:"short"},"weekday",n?.weekdayShort,e.dayOfWeek-1)},"dayOfWeek"],["GGGG",(e,t)=>ee(e,t,{era:"long"},"era"),"year"],["G",(e,t)=>ee(e,t,{era:"short"},"era"),"year"],["zzzz",(e,t)=>ee(e,t,{timeZoneName:"longGeneric"},"timeZoneName"),"timeZoneId"],["z",(e,t)=>ee(e,t,{timeZoneName:"short"},"timeZoneName"),"timeZoneId"]];var ct=Fe.map(([e])=>e).sort((e,t)=>t.length-e.length);function ve(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r==="'"){if(e[n+1]==="'"){Se(t,"'"),n+=2;continue}let a=n+1,s="",m=!1;for(;a<e.length;){if(e[a]==="'"){if(e[a+1]==="'"){s+="'",a+=2;continue}m=!0,a+=1;break}s+=e[a],a+=1}if(!m)throw new S({format:e,message:`temporal-fmt: unterminated quote in format string "${e}"`});Se(t,s),n=a;continue}let o=ct.find(a=>e.startsWith(a,n));if(o){let a=o[o.length-1];if(e[n+o.length]===a){let s=n+o.length;for(;e[s]===a;)s+=1;throw new I({format:e,token:e.slice(n,s),message:`temporal-fmt: "${e.slice(n,s)}" in format string "${e}" isn't a recognized token \u2014 did you mean "${o}"?`})}t.push({kind:"token",value:o}),n+=o.length;continue}Se(t,r),n+=1}return t}function Se(e,t){let n=e[e.length-1];n&&n.kind==="literal"?n.value+=t:e.push({kind:"literal",value:t})}function ut(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function te(e,t=!1){let n=e.map(ut);return t?`(?:${n.map(dt).join("|")})`:`(?:${n.join("|")})`}function dt(e){return e.replace(/[a-zA-Z]/g,t=>`[${t.toLowerCase()}${t.toUpperCase()}]`)}var lt="(?:UTC|[+-]\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d{1,9})?)?|[A-Za-z_]+(?:[+-]\\d{1,2})?(?:\\/[A-Za-z0-9_+-]+)*)",gt={X:"(?:Z|[+-]\\d{2}(?:\\d{2})?)",XX:"(?:Z|[+-]\\d{4})",XXX:"(?:Z|[+-]\\d{2}:\\d{2})",x:"[+-]\\d{2}(?:\\d{2})?",xx:"[+-]\\d{4}",xxx:"[+-]\\d{2}:\\d{2}"};function ft(){return lt}var ce;function pt(){return ce||(ce=new Set(Intl.supportedValuesOf("timeZone")),ce.add("UTC")),ce}var ht=/^[+-]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?$/;function ke(e){return ht.test(e)||pt().has(e)}var yt={yy:"\\d{2}",MM:"(?:0[1-9]|1[0-2])",M:"(?:1[0-2]|[1-9])",dd:"(?:0[1-9]|[12]\\d|3[01])",d:"(?:[12]\\d|3[01]|[1-9])",HH:"(?:[01]\\d|2[0-3])",H:"(?:1\\d|2[0-3]|[0-9])",hh:"(?:0[1-9]|1[0-2])",h:"(?:1[0-2]|[1-9])",mm:"(?:[0-5]\\d)",m:"(?:[1-5]\\d|[0-9])",ss:"(?:[0-5]\\d)",s:"(?:[1-5]\\d|[0-9])",SSSSSSSSS:"\\d{9}",SSSSSSSS:"\\d{8}",SSSSSSS:"\\d{7}",SSSSSS:"\\d{6}",SSSSS:"\\d{5}",SSSS:"\\d{4}",SSS:"\\d{3}",SS:"\\d{2}",S:"\\d",Q:"[1-4]"},wt="Q[1-4]",St=new Set(["do","ww","RRRR","D","DD","DDD","LLLL","LLL","cccc","ccc","GGGG","G","zzzz","z"]),kt="-?\\d{4}",bt="-?\\d{4,}",be=new Set(["yyyy","yy","MM","M","dd","d","HH","H","hh","h","mm","m","ss","s","SSSSSSSSS","SSSSSSSS","SSSSSSS","SSSSSS","SSSSS","SSSS","SSS","SS","S"]);function ue(e,t,n){if(e==="yyyy")return n!==void 0&&be.has(n)?kt:bt;let r=yt[e];if(r)return r;if(e==="QQQ")return wt;if(St.has(e))throw new I({token:e,message:`temporal-fmt: token "${e}" is format-only \u2014 it can't be parsed back into a value. Use a different token in the parse format string (e.g. "d" for "do", "MM" for "ww").`});let o=V(t);switch(e){case"MMMM":return te(o.monthLong);case"MMM":return te(o.monthShort);case"EEEE":return te(o.weekdayLong);case"EEE":return te(o.weekdayShort);case"a":return te(o.dayPeriod,!0);case"zzz":return ft();case"X":case"XX":case"XXX":case"x":case"xx":case"xxx":return gt[e];default:throw new I({token:e,message:`temporal-fmt: unknown token "${e}"`})}}var Ae=new Set(["M","d","H","h","m","s"]),xt={M:[{digits:1,min:1,max:9},{digits:2,min:10,max:12}],d:[{digits:1,min:1,max:9},{digits:2,min:10,max:31}],H:[{digits:1,min:0,max:9},{digits:2,min:10,max:23}],h:[{digits:1,min:1,max:9},{digits:2,min:10,max:12}],m:[{digits:1,min:0,max:9},{digits:2,min:10,max:59}],s:[{digits:1,min:0,max:9},{digits:2,min:10,max:59}]};function xe(e,t){let n=new Map;function r(o,a){let s=`${o}:${a}`,m=n.get(s);if(m)return m;if(o===t.length){let i=a===e.length?[[]]:[];return n.set(s,i),i}let p=t[o],l=xt[p];/* c8 ignore start @preserve -- defensive guard, not reachable through
35
+ real check rather than an assertion. *//* c8 ignore start @preserve */if(o===-1)throw new N({message:`temporal-fmt: locale produced no "${n}" part while building match vocabulary.`});/* c8 ignore stop @preserve */let a=r[o].value,s=r[o-1],m=r[o+1];return s?.type==="literal"&&!/\s/.test(s.value)&&(a=s.value+a),m?.type==="literal"&&!/\s/.test(m.value)&&(a=a+m.value),a}function ae(e,t,n){let r=new Map;for(let o=0;o<e.length;o++){let a=r.get(e[o]);if(a!==void 0)throw new Error(`temporal-fmt: locale "${n}" renders ${t} index ${a} and ${o} identically ("${e[o]}"). parse() can't reliably tell these apart for this locale/token, so this combination isn't supported.`);r.set(e[o],o)}}function M(e){let t=_(e);return Oe.get(t)}function Q(e){ye(e);let t=_(e),n=Oe.get(t);if(n)return n;let r=K.get(t);if(r)return r;let o=W(e),a=new Intl.DateTimeFormat(o,{month:"long",timeZone:"UTC"}),s=new Intl.DateTimeFormat(o,{month:"short",timeZone:"UTC"}),m=[],f=[];for(let y=0;y<12;y++){let b=new Date(Date.UTC(2020,y,1));m.push(V(a,b,"month")),f.push(V(s,b,"month"))}ae(m,"MMMM month",e),ae(f,"MMM month",e);let p=new Intl.DateTimeFormat(o,{weekday:"long",timeZone:"UTC"}),c=new Intl.DateTimeFormat(o,{weekday:"short",timeZone:"UTC"}),i=[],d=[];for(let y=0;y<7;y++){let b=new Date(Date.UTC(2024,0,1+y));i.push(V(p,b,"weekday")),d.push(V(c,b,"weekday"))}ae(i,"EEEE weekday",e),ae(d,"EEE weekday",e);let u=new Intl.DateTimeFormat(o,{hour:"numeric",hour12:!0,timeZone:"UTC"}),h=V(u,new Date(Date.UTC(2020,0,1,1)),"dayPeriod"),k=V(u,new Date(Date.UTC(2020,0,1,13)),"dayPeriod"),$=[...new Set([h,k])],L={monthLong:m,monthShort:f,weekdayLong:i,weekdayShort:d,dayPeriod:$};if(K.size>=ot){let y=K.keys().next().value;y!==void 0&&K.delete(y)}return K.set(t,L),L}var at=[0,31,59,90,120,151,181,212,243,273,304,334];function Ie(e){return e%4===0&&e%100!==0||e%400===0}function j(e){return Ie(e)?366:365}function B(e,t,n){let r=at[t-1]+n;return t>2&&Ie(e)&&(r+=1),r}var we=2e3;function st(e){let t=0;if(e>=we)for(let r=we;r<e;r++)t+=j(r);else for(let r=e;r<we;r++)t-=j(r);return((5+t)%7+7)%7+1}function Se(e,t,n,r){let a=B(e,t,n)+(4-r),s,m;a<1?(s=e-1,m=a+j(s)):a>j(e)?(s=e+1,m=a-j(e)):(s=e,m=a);let p=1+(4-st(s)+7)%7,c=1+Math.floor((m-p)/7);return{isoYear:s,week:c}}function l(e,t){let n=e<0,r=String(Math.abs(e)).padStart(t,"0");return n?"-"+r:r}l.fraction=function(t,n){let r=t.millisecond*1e6+(t.microsecond??0)*1e3+(t.nanosecond??0);return l(r,9).slice(0,n)};var se="en-US",q=new Map,it=500;function Pe(e,t){let n=JSON.stringify([_(e),t]),r=q.get(n);if(r)return r;if(q.size>=it){let o=q.keys().next().value;o!==void 0&&q.delete(o)}try{r=new Intl.DateTimeFormat(W(e),t)}catch(o){throw new N({actual:e,reason:o.message})}return q.set(n,r),r}var J;De(()=>{J=void 0});function mt(){if(J===void 0){J=!1;try{let e=R();new Intl.DateTimeFormat("en-US",{day:"numeric"}).formatToParts(e.PlainDate.from({year:1970,month:1,day:1})),J=!0}catch{}}return J}function ee(e,t,n,r){let o=e?.calendarId,a={...n,calendar:o&&o!=="iso8601"?o:"gregory"},s=e.toLocaleString;if(typeof s!="function"||s===Object.prototype.toLocaleString)throw new Error(`temporal-fmt: locale-aware part "${r}" 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(!mt())try{return s.call(e,W(t),a)}catch(y){throw y instanceof RangeError?new N({actual:t,reason:y.message}):y}let{toInstant:m,timeZoneId:f}=e,p=typeof m=="function"&&typeof f=="string",c=p?e.toInstant():e,i={...a,...p?{timeZone:f}:{}},u=Pe(t,i).formatToParts(c),h=u.findIndex(y=>y.type===r);if(h===-1)throw new Error(`temporal-fmt: locale "${t}" produced no "${r}" part for this token. This usually means the Temporal object is missing the field the token needs.`);let k=u[h].value,$=u[h-1],L=u[h+1];return $?.type==="literal"&&!/\s/.test($.value)&&(k=$.value+k),L?.type==="literal"&&!/\s/.test(L.value)&&(k=k+L.value),k}function ct(e,t){let n=M(t);if(n)return e<12?n.dayPeriod[0]:n.dayPeriod[1];let r=new Date(Date.UTC(1970,0,1,e)),a=Pe(t,{hour:"numeric",hour12:!0,timeZone:"UTC"}).formatToParts(r).find(s=>s.type==="dayPeriod");if(!a)throw new Error(`temporal-fmt: locale "${t}" produced no "dayPeriod" part for token "a".`);return a.value}function F(e,t,n,r,o,a){return o&&a!==void 0&&a>=0&&a<o.length?o[a]:ee(e,t,n,r)}function U(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],r=e.slice(1,3),o=e.slice(4,6);switch(t){case"X":case"x":return o==="00"?`${n}${r}`:`${n}${r}${o}`;case"XX":case"xx":return`${n}${r}${o}`;case"XXX":case"xxx":return`${n}${r}:${o}`}}var Fe=[["yyyy",e=>l(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 l(e.year%100,2)},"year"],["y",e=>l(e.year,0),"year"],["MMMM",(e,t)=>{let n=M(t);return F(e,t,{month:"long"},"month",n?.monthLong,e.month-1)},"month"],["MMM",(e,t)=>{let n=M(t);return F(e,t,{month:"short"},"month",n?.monthShort,e.month-1)},"month"],["MM",e=>l(e.month,2),"month"],["M",e=>String(e.month),"month"],["dd",e=>l(e.day,2),"day"],["d",e=>String(e.day),"day"],["EEEE",(e,t)=>{let n=M(t);return F(e,t,{weekday:"long"},"weekday",n?.weekdayLong,e.dayOfWeek-1)},"dayOfWeek"],["EEE",(e,t)=>{let n=M(t);return F(e,t,{weekday:"short"},"weekday",n?.weekdayShort,e.dayOfWeek-1)},"dayOfWeek"],["HH",e=>l(e.hour,2),"hour"],["H",e=>String(e.hour),"hour"],["hh",e=>l(e.hour%12||12,2),"hour"],["h",e=>String(e.hour%12||12),"hour"],["mm",e=>l(e.minute,2),"minute"],["m",e=>String(e.minute),"minute"],["ss",e=>l(e.second,2),"second"],["s",e=>String(e.second),"second"],["SSSSSSSSS",e=>l.fraction(e,9),"millisecond"],["SSSSSSSS",e=>l.fraction(e,8),"millisecond"],["SSSSSSS",e=>l.fraction(e,7),"millisecond"],["SSSSSS",e=>l.fraction(e,6),"millisecond"],["SSSSS",e=>l.fraction(e,5),"millisecond"],["SSSS",e=>l.fraction(e,4),"millisecond"],["SSS",e=>l.fraction(e,3),"millisecond"],["SS",e=>l.fraction(e,2),"millisecond"],["S",e=>l.fraction(e,1),"millisecond"],["a",(e,t)=>ct(e.hour,t),"hour"],["zzz",e=>e.timeZoneId,"timeZoneId"],["xxx",e=>U(e.offset,"xxx"),"offset"],["xx",e=>U(e.offset,"xx"),"offset"],["X",e=>U(e.offset,"X"),"offset"],["XX",e=>U(e.offset,"XX"),"offset"],["XXX",e=>U(e.offset,"XXX"),"offset"],["x",e=>U(e.offset,"x"),"offset"],["do",e=>{let t=e.day,n=t%10,r=t%100;return r>=11&&r<=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}=Se(e.year,e.month,e.day,e.dayOfWeek);return l(t,2)},"dayOfWeek"],["RRRR",e=>{let{isoYear:t}=Se(e.year,e.month,e.day,e.dayOfWeek);return l(t,4)},"dayOfWeek"],["D",e=>String(B(e.year,e.month,e.day)),"day"],["DD",e=>l(B(e.year,e.month,e.day),2),"day"],["DDD",e=>l(B(e.year,e.month,e.day),3),"day"],["LLLL",(e,t)=>{let n=M(t);return F(e,t,{month:"long"},"month",n?.monthLong,e.month-1)},"month"],["LLL",(e,t)=>{let n=M(t);return F(e,t,{month:"short"},"month",n?.monthShort,e.month-1)},"month"],["cccc",(e,t)=>{let n=M(t);return F(e,t,{weekday:"long"},"weekday",n?.weekdayLong,e.dayOfWeek-1)},"dayOfWeek"],["ccc",(e,t)=>{let n=M(t);return F(e,t,{weekday:"short"},"weekday",n?.weekdayShort,e.dayOfWeek-1)},"dayOfWeek"],["GGGG",(e,t)=>ee(e,t,{era:"long"},"era"),"year"],["G",(e,t)=>ee(e,t,{era:"short"},"era"),"year"],["zzzz",(e,t)=>ee(e,t,{timeZoneName:"longGeneric"},"timeZoneName"),"timeZoneId"],["z",(e,t)=>ee(e,t,{timeZoneName:"short"},"timeZoneName"),"timeZoneId"]];var ut=Fe.map(([e])=>e).sort((e,t)=>t.length-e.length);function Ae(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r==="'"){if(e[n+1]==="'"){ke(t,"'"),n+=2;continue}let a=n+1,s="",m=!1;for(;a<e.length;){if(e[a]==="'"){if(e[a+1]==="'"){s+="'",a+=2;continue}m=!0,a+=1;break}s+=e[a],a+=1}if(!m)throw new S({format:e,message:`temporal-fmt: unterminated quote in format string "${e}"`});ke(t,s),n=a;continue}let o=ut.find(a=>e.startsWith(a,n));if(o){let a=o[o.length-1];if(e[n+o.length]===a){let s=n+o.length;for(;e[s]===a;)s+=1;throw new I({format:e,token:e.slice(n,s),message:`temporal-fmt: "${e.slice(n,s)}" in format string "${e}" isn't a recognized token \u2014 did you mean "${o}"?`})}t.push({kind:"token",value:o}),n+=o.length;continue}ke(t,r),n+=1}return t}function ke(e,t){let n=e[e.length-1];n&&n.kind==="literal"?n.value+=t:e.push({kind:"literal",value:t})}function dt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function te(e,t=!1){let n=e.map(dt);return t?`(?:${n.map(lt).join("|")})`:`(?:${n.join("|")})`}function lt(e){return e.replace(/[a-zA-Z]/g,t=>`[${t.toLowerCase()}${t.toUpperCase()}]`)}var gt="(?:UTC|[+-]\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d{1,9})?)?|[A-Za-z_]+(?:[+-]\\d{1,2})?(?:\\/[A-Za-z0-9_+-]+)*)",ft={X:"(?:Z|[+-]\\d{2}(?:\\d{2})?)",XX:"(?:Z|[+-]\\d{4})",XXX:"(?:Z|[+-]\\d{2}:\\d{2})",x:"[+-]\\d{2}(?:\\d{2})?",xx:"[+-]\\d{4}",xxx:"[+-]\\d{2}:\\d{2}"};function pt(){return gt}var ie;function ht(){return ie||(ie=new Set(Intl.supportedValuesOf("timeZone")),ie.add("UTC")),ie}var yt=/^[+-]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?$/;function be(e){if(yt.test(e)||ht().has(e))return!0;try{return R().ZonedDateTime.from({year:2026,month:1,day:1,hour:0,minute:0,second:0,timeZone:e}),!0}catch{return!1}}var wt={yy:"\\d{2}",MM:"(?:0[1-9]|1[0-2])",M:"(?:1[0-2]|[1-9])",dd:"(?:0[1-9]|[12]\\d|3[01])",d:"(?:[12]\\d|3[01]|[1-9])",HH:"(?:[01]\\d|2[0-3])",H:"(?:1\\d|2[0-3]|[0-9])",hh:"(?:0[1-9]|1[0-2])",h:"(?:1[0-2]|[1-9])",mm:"(?:[0-5]\\d)",m:"(?:[1-5]\\d|[0-9])",ss:"(?:[0-5]\\d)",s:"(?:[1-5]\\d|[0-9])",SSSSSSSSS:"\\d{9}",SSSSSSSS:"\\d{8}",SSSSSSS:"\\d{7}",SSSSSS:"\\d{6}",SSSSS:"\\d{5}",SSSS:"\\d{4}",SSS:"\\d{3}",SS:"\\d{2}",S:"\\d",Q:"[1-4]"},St="Q[1-4]",kt=new Set(["do","ww","RRRR","D","DD","DDD","LLLL","LLL","cccc","ccc","GGGG","G","zzzz","z"]),bt="-?\\d{4}",xt="-?\\d{4,}",Et="-?\\d+",xe=new Set(["yyyy","yy","y","MM","M","dd","d","HH","H","hh","h","mm","m","ss","s","SSSSSSSSS","SSSSSSSS","SSSSSSS","SSSSSS","SSSSS","SSSS","SSS","SS","S"]),ve=new Set(["y"]);function me(e,t,n){if(e==="yyyy")return n!==void 0&&xe.has(n)?bt:xt;if(e==="y")return Et;let r=wt[e];if(r)return r;if(e==="QQQ")return St;if(kt.has(e))throw new I({token:e,message:`temporal-fmt: token "${e}" is format-only \u2014 it can't be parsed back into a value. Use a different token in the parse format string (e.g. "d" for "do", "MM" for "ww").`});let o=Q(t);switch(e){case"MMMM":return te(o.monthLong);case"MMM":return te(o.monthShort);case"EEEE":return te(o.weekdayLong);case"EEE":return te(o.weekdayShort);case"a":return te(o.dayPeriod,!0);case"zzz":return pt();case"X":case"XX":case"XXX":case"x":case"xx":case"xxx":return ft[e];default:throw new I({token:e,message:`temporal-fmt: unknown token "${e}"`})}}var _e=new Set(["M","d","H","h","m","s"]),Tt={M:[{digits:1,min:1,max:9},{digits:2,min:10,max:12}],d:[{digits:1,min:1,max:9},{digits:2,min:10,max:31}],H:[{digits:1,min:0,max:9},{digits:2,min:10,max:23}],h:[{digits:1,min:1,max:9},{digits:2,min:10,max:12}],m:[{digits:1,min:0,max:9},{digits:2,min:10,max:59}],s:[{digits:1,min:0,max:9},{digits:2,min:10,max:59}]};function Ee(e,t){let n=new Map;function r(o,a){let s=`${o}:${a}`,m=n.get(s);if(m)return m;if(o===t.length){let i=a===e.length?[[]]:[];return n.set(s,i),i}let f=t[o],p=Tt[f];/* c8 ignore start @preserve -- defensive guard, not reachable through
36
36
  the public API. enumerateValidSplits's only caller (parse.ts, both
37
37
  call sites) passes run.tokens straight from
38
38
  pattern.ambiguousRuns, which parsePattern.ts only ever populates
39
39
  with tokens already checked against UNPADDED_NUMERIC_TOKENS — the
40
40
  exact same key set as UNPADDED_NUMERIC_RANGES. There's no path
41
41
  where a token reaches here without having already passed that
42
- check. */if(!l)throw new Error(`temporal-fmt: internal error \u2014 "${p}" is not an unpadded numeric token`);/* c8 ignore stop @preserve */let c=[];for(let{digits:i,min:d,max:u}of l){if(a+i>e.length)continue;let h=e.slice(a,a+i);if(i===2&&h[0]==="0")continue;let k=Number(h);if(!(k<d||k>u)){for(let $ of r(o+1,a+i))if(c.push([k,...$]),c.length===2)break;if(c.length===2)break}}return n.set(s,c),c}return r(0,0)}function Et(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var _e=12;function Tt(e){return Math.ceil(Math.log2(Math.max(e,1)))}function Ee(e){return e===void 0?!1:e.kind==="literal"?/^[0-9]/.test(e.value):be.has(e.value)}function Ce(e,t){let n=[],r=[],o="",a=0,s=0,m={names:[],tokens:[]},p=l=>{if(m.tokens.length===1){let c=m.names[0],i=m.tokens[0];o+=`(?<${c}>${ue(i,t)})`,Ee(l)&&(s+=1)}else if(m.tokens.length>=2){let c=`r${a++}`,i=m.tokens.length;o+=`(?<${c}>\\d{${i},${i*2}})`,r.push({groupName:c,groupNames:m.names,tokens:m.tokens}),Ee(l)&&(s+=Tt(i+1))}m={names:[],tokens:[]}};for(let[l,c]of e.entries()){if(c.kind==="literal"){p(c),o+=Et(c.value);continue}if(Ae.has(c.value)){let h=`g${a++}`;n.push({name:h,token:c.value}),m.names.push(h),m.tokens.push(c.value);continue}p(c);let i=`g${a++}`;n.push({name:i,token:c.value});let d=e[l+1],u=d?.kind==="token"?d.value:void 0;c.value==="yyyy"&&u===void 0&&Ee(d)?o+=`(?<${i}>${ue(c.value,t,"M")})`:o+=`(?<${i}>${ue(c.value,t,u)})`}if(p(void 0),s>_e)throw new S({reason:`format string has too many variable-width numeric tokens glued to digit-consuming neighbors (ambiguity score ${s} > ${_e}). This shape makes the regex engine backtrack exponentially on near-miss input. Add a non-digit separator between these tokens (e.g. "-" or " ") or use their padded forms (MM/dd/HH/mm/ss).`});return{regex:new RegExp(`^(?:${o})$`,"ud"),groups:n,ambiguousRuns:r}}var $t=new Set(["latn","arab","deva","beng","guru","gujr","orya","tamldec","telu","knda","mlym","fullwide","hanidec"]),Xe=new Map;function Nt(e){let t=Xe.get(e);if(t)return t;/* c8 ignore start @preserve -- dead by construction, not just
42
+ check. */if(!p)throw new Error(`temporal-fmt: internal error \u2014 "${f}" is not an unpadded numeric token`);/* c8 ignore stop @preserve */let c=[];for(let{digits:i,min:d,max:u}of p){if(a+i>e.length)continue;let h=e.slice(a,a+i);if(i===2&&h[0]==="0")continue;let k=Number(h);if(!(k<d||k>u)){for(let $ of r(o+1,a+i))if(c.push([k,...$]),c.length===2)break;if(c.length===2)break}}return n.set(s,c),c}return r(0,0)}function $t(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Ce=12;function Nt(e){return Math.ceil(Math.log2(Math.max(e,1)))}function ce(e){return e===void 0?!1:e.kind==="literal"?/^[0-9]/.test(e.value):xe.has(e.value)}function Xe(e,t){let n=[],r=[],o="",a=0,s=0,m={names:[],tokens:[]},f=p=>{if(m.tokens.length===1){let c=m.names[0],i=m.tokens[0];o+=`(?<${c}>${me(i,t)})`,ce(p)&&(s+=1)}else if(m.tokens.length>=2){let c=`r${a++}`,i=m.tokens.length;o+=`(?<${c}>\\d{${i},${i*2}})`,r.push({groupName:c,groupNames:m.names,tokens:m.tokens}),ce(p)&&(s+=Nt(i+1))}m={names:[],tokens:[]}};for(let[p,c]of e.entries()){if(c.kind==="literal"){f(c),o+=$t(c.value);continue}if(_e.has(c.value)){let h=`g${a++}`;n.push({name:h,token:c.value}),m.names.push(h),m.tokens.push(c.value);continue}f(c);let i=`g${a++}`;n.push({name:i,token:c.value});let d=e[p+1],u=d?.kind==="token"?d.value:void 0;if(ve.has(c.value)&&ce(d))throw new S({reason:`token "${c.value}" has no fixed width \u2014 it can't be placed directly next to another digit-reading token or a literal that starts with a digit, since there's no way to tell where "${c.value}" ends and the next field begins. Add a non-digit separator (e.g. "-" or " ") after it.`});c.value==="yyyy"&&u===void 0&&ce(d)?o+=`(?<${i}>${me(c.value,t,"M")})`:o+=`(?<${i}>${me(c.value,t,u)})`}if(f(void 0),s>Ce)throw new S({reason:`format string has too many variable-width numeric tokens glued to digit-consuming neighbors (ambiguity score ${s} > ${Ce}). This shape makes the regex engine backtrack exponentially on near-miss input. Add a non-digit separator between these tokens (e.g. "-" or " ") or use their padded forms (MM/dd/HH/mm/ss).`});return{regex:new RegExp(`^(?:${o})$`,"ud"),groups:n,ambiguousRuns:r}}var Dt=new Set(["latn","arab","deva","beng","guru","gujr","orya","tamldec","telu","knda","mlym","fullwide","hanidec"]),Re=new Map;function Mt(e){let t=Re.get(e);if(t)return t;/* c8 ignore start @preserve -- dead by construction, not just
43
43
  untested: both callers (convertDigits, convertDigitsToAscii) already
44
44
  return early on system === 'latn' before calling getDigitMap at all,
45
45
  so this function is never invoked with 'latn'. Kept as a defensive
46
46
  fallback rather than trusting that stays true for any future
47
- 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 r=0;r<10;r++)t[String(r)]=n.format(r)}return Xe.set(e,t),t}function Dt(e,t){if(t==="latn")return e;if(!$t.has(t))throw new N({actual:t,reason:`numbering system "${t}" is not supported.`});let n=Nt(t),r={};for(let a of Object.keys(n))r[n[a]]=a;let o="";for(let a of e)o+=r[a]??a;return o}function Te(e,t){let n=t.parseNumberingSystem??"latn";return n==="latn"?e:Dt(e,n)}var Y=new Map,Mt=500;Oe(()=>{Y.clear()});function Ne(e,t){let n=JSON.stringify([C(t),e]),r=Y.get(n);if(r)return r;if(Y.size>=Mt){let o=Y.keys().next().value;o!==void 0&&Y.delete(o)}return r=Ce(ve(e),t),Y.set(n,r),r}var U=new Map,Lt=500;function Ot(e){he(e);let t=C(e);if(U.has(t))return U.get(t);if(U.size>=Lt){let s=U.keys().next().value;s!==void 0&&U.delete(s)}let n,r=t.split("-"),o=r.indexOf("u"),a=o===-1?-1:r.indexOf("ca",o+1);if(a!==-1&&a+1<r.length){let s=new Intl.DateTimeFormat(t).resolvedOptions().calendar;n=s==="gregory"?void 0:s}return U.set(t,n),n}function Pt(e,t){if(e==="Z"){/* c8 ignore start @preserve -- unreachable: lowercase tokens' regex
47
+ 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 r=0;r<10;r++)t[String(r)]=n.format(r)}return Re.set(e,t),t}function Ot(e,t){if(t==="latn")return e;if(!Dt.has(t))throw new N({actual:t,reason:`numbering system "${t}" is not supported.`});let n=Mt(t),r={};for(let a of Object.keys(n))r[n[a]]=a;let o="";for(let a of e)o+=r[a]??a;return o}function Te(e,t){let n=t.parseNumberingSystem??"latn";return n==="latn"?e:Ot(e,n)}var H=new Map,Lt=500;Le(()=>{H.clear()});function Ne(e,t){let n=JSON.stringify([_(t),e]),r=H.get(n);if(r)return r;if(H.size>=Lt){let o=H.keys().next().value;o!==void 0&&H.delete(o)}return r=Xe(Ae(e),t),H.set(n,r),r}var Z=new Map,It=500;function Pt(e){ye(e);let t=_(e);if(Z.has(t))return Z.get(t);if(Z.size>=It){let s=Z.keys().next().value;s!==void 0&&Z.delete(s)}let n,r=t.split("-"),o=r.indexOf("u"),a=o===-1?-1:r.indexOf("ca",o+1);if(a!==-1&&a+1<r.length){let s=new Intl.DateTimeFormat(t).resolvedOptions().calendar;n=s==="gregory"?void 0:s}return Z.set(t,n),n}function Ft(e,t){if(e==="Z"){/* c8 ignore start @preserve -- unreachable: lowercase tokens' regex
48
48
  (OFFSET_SHAPES in pattern.ts) has no "Z" alternative at all, so
49
49
  raw === 'Z' can only ever be reached when token is one of the
50
50
  uppercase variants (X/XX/XXX). A lowercase token can't even
@@ -65,10 +65,10 @@
65
65
  with a colon at index 2 (see OFFSET_SHAPES in pattern.ts) — no
66
66
  shape falls outside those three cases, so this else arm can't be
67
67
  taken through parse(). Kept as an exhaustiveness fallback so
68
- hoursStr/minutesStr are assigned on every path TypeScript can see. */}else throw new Error(`temporal-fmt: offset "${e}" doesn't match the shape token "${t}" accepts.`);/* c8 ignore stop @preserve */let s=Number(o),m=Number(a);if(s>14)throw new F({actual:e,message:`temporal-fmt: offset hours ${s} in "${e}" out of range (max 14 \u2014 Kiritimati, Line Islands is +14:00).`});if(m>59)throw new F({actual:e,message:`temporal-fmt: offset minutes ${m} in "${e}" out of range (max 59).`});if(n==="+"&&s===14&&m!==0)throw new F({actual:e,message:`temporal-fmt: offset "${e}" exceeds the maximum supported UTC offset of +14:00.`});if(n==="-"&&s===12&&m!==0)throw new F({actual:e,message:`temporal-fmt: offset "${e}" exceeds the maximum supported negative UTC offset of -12:00.`});return`${n}${o}:${a}`}function f(e,t,n){e[t]=n}function It(e,t,n,r,o){let a=V(r);switch(t){case"yyyy":f(e,"year",Number(n));break;case"yy":f(e,"twoDigitYear",Number(n));break;case"MM":case"M":f(e,"month",Number(n));break;case"MMMM":f(e,"month",a.monthLong.indexOf(n)+1);break;case"MMM":f(e,"month",a.monthShort.indexOf(n)+1);break;case"dd":case"d":f(e,"day",Number(n));break;case"EEEE":f(e,"weekdayRaw",n),f(e,"weekdayExpected",a.weekdayLong.indexOf(n)+1);break;case"EEE":f(e,"weekdayRaw",n),f(e,"weekdayExpected",a.weekdayShort.indexOf(n)+1);break;case"HH":case"H":f(e,"hour",Number(n));break;case"hh":case"h":f(e,"hour12",Number(n));break;case"mm":case"m":f(e,"minute",Number(n));break;case"ss":case"s":f(e,"second",Number(n));break;case"S":case"SS":case"SSS":case"SSSS":case"SSSSS":case"SSSSSS":case"SSSSSSS":case"SSSSSSSS":case"SSSSSSSSS":{let s=Number(n.padEnd(9,"0"));f(e,"millisecond",Math.floor(s/1e6)),f(e,"microsecond",Math.floor(s/1e3)%1e3),f(e,"nanosecond",s%1e3);break}case"a":{let s=a.dayPeriod.findIndex(m=>m.toLowerCase()===n.toLowerCase());/* c8 ignore start @preserve -- unreachable: the 'a' token's regex
68
+ hoursStr/minutesStr are assigned on every path TypeScript can see. */}else throw new Error(`temporal-fmt: offset "${e}" doesn't match the shape token "${t}" accepts.`);/* c8 ignore stop @preserve */let s=Number(o),m=Number(a);if(s>14)throw new P({actual:e,message:`temporal-fmt: offset hours ${s} in "${e}" out of range (max 14 \u2014 Kiritimati, Line Islands is +14:00).`});if(m>59)throw new P({actual:e,message:`temporal-fmt: offset minutes ${m} in "${e}" out of range (max 59).`});if(n==="+"&&s===14&&m!==0)throw new P({actual:e,message:`temporal-fmt: offset "${e}" exceeds the maximum supported UTC offset of +14:00.`});if(n==="-"&&s===12&&m!==0)throw new P({actual:e,message:`temporal-fmt: offset "${e}" exceeds the maximum supported negative UTC offset of -12:00.`});return`${n}${o}:${a}`}function g(e,t,n){e[t]=n}function At(e,t,n,r,o){let a=Q(r);switch(t){case"yyyy":case"y":g(e,"year",Number(n));break;case"yy":g(e,"twoDigitYear",Number(n));break;case"MM":case"M":g(e,"month",Number(n));break;case"MMMM":g(e,"month",a.monthLong.indexOf(n)+1);break;case"MMM":g(e,"month",a.monthShort.indexOf(n)+1);break;case"dd":case"d":g(e,"day",Number(n));break;case"EEEE":g(e,"weekdayRaw",n),g(e,"weekdayExpected",a.weekdayLong.indexOf(n)+1);break;case"EEE":g(e,"weekdayRaw",n),g(e,"weekdayExpected",a.weekdayShort.indexOf(n)+1);break;case"HH":case"H":g(e,"hour",Number(n));break;case"hh":case"h":g(e,"hour12",Number(n));break;case"mm":case"m":g(e,"minute",Number(n));break;case"ss":case"s":g(e,"second",Number(n));break;case"S":case"SS":case"SSS":case"SSSS":case"SSSSS":case"SSSSSS":case"SSSSSSS":case"SSSSSSSS":case"SSSSSSSSS":{let s=Number(n.padEnd(9,"0"));g(e,"millisecond",Math.floor(s/1e6)),g(e,"microsecond",Math.floor(s/1e3)%1e3),g(e,"nanosecond",s%1e3);break}case"a":{let s=a.dayPeriod.findIndex(m=>m.toLowerCase()===n.toLowerCase());/* c8 ignore start @preserve -- unreachable: the 'a' token's regex
69
69
  fragment (pattern.ts's alternation() over vocab.dayPeriod) can
70
70
  only ever capture a case-insensitive match of one of
71
71
  vocab.dayPeriod's own entries. Both the regex and this lookup
72
72
  derive their vocab from the same `locale` via getLocaleVocab(),
73
- so periodIndex can't come back negative through parse(). */if(s<0)throw new Error(`temporal-fmt: unknown day period "${n}" for locale "${r}".`);/* c8 ignore stop @preserve */f(e,"dayPeriodRaw",n),f(e,"isPM",s===1);break}case"zzz":f(e,"timeZoneId",n);break;case"X":case"XX":case"XXX":case"x":case"xx":case"xxx":f(e,"offsetString",Pt(n,t));break;case"Q":f(e,"quarter",Number(n));break;case"QQQ":f(e,"quarter",Number(n.slice(1)));break}}function Re(e,t){let n=t.indexOf("d");if(n!==-1){let r=e.filter(o=>o[n]<=12);if(r.length>0)return r[0]}return e[0]}function Ft(e){if(e.year!==void 0&&e.twoDigitYear!==void 0)throw new S({message:'temporal-fmt: format string mixes "yyyy" and "yy" year representations.'});if(e.year!==void 0)return e.year;if(e.twoDigitYear!==void 0)return e.twoDigitYear<=68?2e3+e.twoDigitYear:1900+e.twoDigitYear}function vt(e,t,n){if(e.hour!==void 0&&e.hour12!==void 0)throw new S({format:t,message:`temporal-fmt: format string "${t}" mixes a 24-hour token ("HH"/"H") with a 12-hour token ("hh"/"h").`});if(e.hour!==void 0){if(e.dayPeriodRaw!==void 0){let r=V(n),o=e.hour<12?r.dayPeriod[0]:r.dayPeriod[1];if(e.dayPeriodRaw.toLowerCase()!==o?.toLowerCase())throw new S({format:t,message:`temporal-fmt: format string "${t}" contains a day period that contradicts the 24-hour value.`})}return e.hour}if(e.hour12!==void 0){if(e.isPM===void 0)throw new S({format:t,message:`temporal-fmt: format string "${t}" uses a 12-hour token ("hh"/"h") without an "a" token, so parse() can't tell AM from PM.`});return e.hour12%12+(e.isPM?12:0)}}function de(e,t,n={}){if(e.length>1e3)throw new S({format:e,message:`temporal-fmt: format string exceeds maximum length of ${1e3} characters (got ${e.length}).`});if(t.length>1e5)throw new S({input:t,message:`temporal-fmt: input exceeds maximum length of ${1e5} characters (got ${t.length}).`});n.parseNumberingSystem&&(t=Te(t,n));let r=n.locale??me,o=Ot(r),a=Ne(e,r),s=a.regex.exec(t);if(!s)throw new T({input:t,format:e,reason:"no valid pattern matches the format string and input shape",message:"temporal-fmt: no valid pattern matches the format string and input shape"});if(a.groups.length===0)throw new T({format:e,reason:`format string "${e}" has no tokens \u2014 nothing to parse into a value.`,message:`temporal-fmt: format string "${e}" has no tokens \u2014 nothing to parse into a value.`});for(let{name:w,token:x}of a.groups)if(x==="zzz"&&!ke(s.groups[w]))throw new G({input:t,format:e,actual:s.groups[w],reason:"not a recognized IANA time zone identifier"});let m=new Map;for(let w of a.ambiguousRuns){let x=s.groups[w.groupName],D=xe(x,w.tokens);if(D.length===0)throw new T({input:t,format:e,reason:"no valid pattern matches the format string and input shape",message:"temporal-fmt: no valid pattern matches the format string and input shape"});if(D.length>1){if(!n.lenient)throw new R({input:t,format:e,message:`temporal-fmt: "${x}" in format string "${e}" is ambiguous \u2014 ${D.length} different ways to read tokens "${w.tokens.join("")}" (with no separator between them) are all individually valid (e.g. ${JSON.stringify(D[0])} vs ${JSON.stringify(D[1])}). parse() won't guess; add a separator between these tokens, or use their padded form (e.g. "MM" instead of "M") so each one has a fixed width. Pass { lenient: true } to opt into a documented heuristic that picks one.`});let X=Re(D,w.tokens);w.groupNames.forEach((fe,He)=>m.set(fe,String(X[He])))}else w.groupNames.forEach((X,fe)=>m.set(X,String(D[0][fe])))}let p={};for(let{name:w,token:x}of a.groups){let D=m.get(w)??s.groups[w];It(p,x,D,r,e)}let l=Ft(p),c=vt(p,e,r),{month:i,day:d,minute:u,second:h,millisecond:k,microsecond:$,nanosecond:O,timeZoneId:y,offsetString:b,weekdayExpected:le,weekdayRaw:Ue,quarter:ge}=p,Ye=l!==void 0||i!==void 0||d!==void 0,A=l!==void 0&&i!==void 0&&d!==void 0;if(Ye&&!A)throw new L({format:e,message:`temporal-fmt: format string "${e}" has an incomplete date \u2014 year, month, and day tokens must all be present together.`});let re=c!==void 0||u!==void 0||h!==void 0||k!==void 0;if(y!==void 0&&!(A&&re))throw new S({format:e,message:`temporal-fmt: format string "${e}" has a "zzz" token but needs a full date and time to build a ZonedDateTime.`});if(b!==void 0&&!(A&&re))throw new S({format:e,message:`temporal-fmt: format string "${e}" has an offset token (X/XX/XXX/x/xx/xxx) but needs a full date and time to build a ZonedDateTime.`});if(le!==void 0&&!A)throw new S({format:e,message:`temporal-fmt: format string "${e}" has a weekday token ("EEEE"/"EEE") but needs a full date to validate it against.`});if(!A&&!re)throw new S({format:e,message:`temporal-fmt: format string "${e}" has no date or time tokens to parse.`});let H=se(),_={hour:c??0,minute:u??0,second:h??0,millisecond:k??0,microsecond:$??0,nanosecond:O??0},oe=o?{calendar:o}:{},ae={overflow:"reject"},P;try{if(y!==void 0){let w={overflow:"reject",offset:"prefer"};if(P=H.ZonedDateTime.from({year:l,month:i,day:d,..._,...oe,timeZone:y,...b!==void 0?{offset:b}:{}},w),b!==void 0){let x=P;if(x.hour!==_.hour||x.minute!==_.minute||x.second!==_.second)throw new L({input:t,format:e,message:`"${y}" has no such wall-clock time on this date \u2014 it falls in a DST gap, not an ambiguous or valid instant.`});let X=x.offset;if(X!==b)throw new T({input:t,format:e,message:`has both a "zzz" zone (${y}) and an offset token (${b}), but the zone's actual offset at this date/time is ${X}, not ${b}.`})}}else b!==void 0?P=H.ZonedDateTime.from({year:l,month:i,day:d,..._,...oe,timeZone:b},ae):A&&re?P=H.PlainDateTime.from({year:l,month:i,day:d,..._,...oe},ae):A?P=H.PlainDate.from({year:l,month:i,day:d,...oe},ae):P=H.PlainTime.from(_,ae)}catch(w){throw new L({input:t,format:e,message:`temporal-fmt: "${t}" doesn't describe a valid date/time for format "${e}": ${w.message}`})}if(le!==void 0){let w=P.dayOfWeek;if(w!==le){let x=V(r);throw new L({input:t,format:e,message:`temporal-fmt: "${Ue}" doesn't match the actual weekday (${x.weekdayLong[w-1]}) for the parsed date.`})}}if(ge!==void 0&&i!==void 0){let w=Math.ceil(i/3);if(ge!==w)throw new L({format:e,message:`temporal-fmt: format string "${e}" contains a quarter token (Q/QQQ) whose value (Q${ge}) disagrees with the parsed month's actual quarter \u2014 month ${i} is in Q${w}.`})}return P}function ze(e,t,n={}){try{return{ok:!0,value:de(e,t,n)}}catch(r){/* c8 ignore start @preserve */return r instanceof E?{ok:!1,error:r}:{ok:!1,error:Me(r,{input:t,format:e})}}/* c8 ignore stop @preserve */}function Ve(e,t,n={}){try{return de(e,t,n)}catch{return}}function Ze(e,t,n={}){if(e.length>1e3)throw new S({format:e,message:`temporal-fmt: format string exceeds maximum length of ${1e3} characters (got ${e.length}).`});if(t.length>1e5)throw new S({input:t,message:`temporal-fmt: input exceeds maximum length of ${1e5} characters (got ${t.length}).`});n.parseNumberingSystem&&(t=Te(t,n));let r=n.locale??me,o=Ne(e,r),a=o.regex.exec(t);if(!a)throw new T({input:t,format:e,reason:"no valid pattern matches the format string and input shape",message:"temporal-fmt: no valid pattern matches the format string and input shape"});if(o.groups.length===0)throw new T({format:e,reason:`format string "${e}" has no tokens \u2014 nothing to parse into a value.`,message:`temporal-fmt: format string "${e}" has no tokens \u2014 nothing to parse into a value.`});for(let{name:i,token:d}of o.groups)if(d==="zzz"&&!ke(a.groups[i]))throw new G({input:t,format:e,actual:a.groups[i],reason:"not a recognized IANA time zone identifier"});let s=new Map;for(let i of o.ambiguousRuns){let d=a.groups[i.groupName],u=xe(d,i.tokens);if(u.length===0)throw new T({input:t,format:e,reason:"no valid pattern matches the format string and input shape",message:"temporal-fmt: no valid pattern matches the format string and input shape"});if(u.length>1){if(!n.lenient)throw new R({input:t,format:e,message:`temporal-fmt: "${d}" in format string "${e}" is ambiguous \u2014 ${u.length} different ways to read tokens "${i.tokens.join("")}" (with no separator between them) are all individually valid (e.g. ${JSON.stringify(u[0])} vs ${JSON.stringify(u[1])}). parse() won't guess; add a separator between these tokens, or use their padded form (e.g. "MM" instead of "M") so each one has a fixed width. Pass { lenient: true } to opt into a documented heuristic that picks one.`});let h=Re(u,i.tokens);i.groupNames.forEach((k,$)=>s.set(k,String(h[$])))}else i.groupNames.forEach((h,k)=>s.set(h,String(u[0][k])))}let m=[],l=a.indices?.groups,c=0;for(let{name:i,token:d}of o.groups){let u=s.get(i)??a.groups[i],h=!s.has(i)&&l?.[i],k=h?h[0]:(a.index??0)+c;m.push({token:d,raw:u,position:k}),c+=u.length}return m}function At(e,t={}){if(e.length>1e3)throw new S({format:e,message:`temporal-fmt: format string exceeds maximum length of ${1e3} characters (got ${e.length}).`});let n=t.locale??me,r=Ne(e,n);return{formatStr:e,pattern:r,parse(o,a={}){return de(e,o,{locale:n,...a})},safeParse(o,a={}){return ze(e,o,{locale:n,...a})},tryParse(o,a={}){return Ve(e,o,{locale:n,...a})},parseToParts(o,a={}){return Ze(e,o,{locale:n,...a})}}}0&&(module.exports={compileParser,parse,parseToParts,safeParse,tryParse});
73
+ so periodIndex can't come back negative through parse(). */if(s<0)throw new Error(`temporal-fmt: unknown day period "${n}" for locale "${r}".`);/* c8 ignore stop @preserve */g(e,"dayPeriodRaw",n),g(e,"isPM",s===1);break}case"zzz":g(e,"timeZoneId",n);break;case"X":case"XX":case"XXX":case"x":case"xx":case"xxx":g(e,"offsetString",Ft(n,t));break;case"Q":g(e,"quarter",Number(n));break;case"QQQ":g(e,"quarter",Number(n.slice(1)));break}}function ze(e,t){let n=t.indexOf("d");if(n!==-1){let r=e.filter(o=>o[n]<=12);if(r.length>0)return r[0]}return e[0]}function vt(e){if(e.year!==void 0&&e.twoDigitYear!==void 0)throw new S({message:'temporal-fmt: format string mixes a full-year token ("yyyy"/"y") with the two-digit "yy" token.'});if(e.year!==void 0)return e.year;if(e.twoDigitYear!==void 0)return e.twoDigitYear<=68?2e3+e.twoDigitYear:1900+e.twoDigitYear}function _t(e,t,n){if(e.hour!==void 0&&e.hour12!==void 0)throw new S({format:t,message:`temporal-fmt: format string "${t}" mixes a 24-hour token ("HH"/"H") with a 12-hour token ("hh"/"h").`});if(e.hour!==void 0){if(e.dayPeriodRaw!==void 0)throw new S({format:t,message:`temporal-fmt: format string "${t}" mixes a 24-hour token ("HH"/"H") with a day-period token ("a"). Both describe the same field; use one or the other, not both.`});return e.hour}if(e.hour12!==void 0){if(e.isPM===void 0)throw new S({format:t,message:`temporal-fmt: format string "${t}" uses a 12-hour token ("hh"/"h") without an "a" token, so parse() can't tell AM from PM.`});return e.hour12%12+(e.isPM?12:0)}}function ue(e,t,n={}){if(e.length>1e3)throw new S({format:e,message:`temporal-fmt: format string exceeds maximum length of ${1e3} characters (got ${e.length}).`});if(t.length>1e5)throw new S({input:t,message:`temporal-fmt: input exceeds maximum length of ${1e5} characters (got ${t.length}).`});n.parseNumberingSystem&&(t=Te(t,n));let r=n.locale??se,o=Pt(r),a=Ne(e,r),s=a.regex.exec(t);if(!s)throw new E({input:t,format:e,reason:"no valid pattern matches the format string and input shape",message:"temporal-fmt: no valid pattern matches the format string and input shape"});if(a.groups.length===0)throw new E({format:e,reason:`format string "${e}" has no tokens \u2014 nothing to parse into a value.`,message:`temporal-fmt: format string "${e}" has no tokens \u2014 nothing to parse into a value.`});for(let{name:w,token:x}of a.groups)if(x==="zzz"&&!be(s.groups[w]))throw new Y({input:t,format:e,actual:s.groups[w],reason:"not a recognized IANA time zone identifier"});let m=new Map;for(let w of a.ambiguousRuns){let x=s.groups[w.groupName],D=Ee(x,w.tokens);if(D.length===0)throw new E({input:t,format:e,reason:"no valid pattern matches the format string and input shape",message:"temporal-fmt: no valid pattern matches the format string and input shape"});if(D.length>1){if(!n.lenient)throw new z({input:t,format:e,message:`temporal-fmt: "${x}" in format string "${e}" is ambiguous \u2014 ${D.length} different ways to read tokens "${w.tokens.join("")}" (with no separator between them) are all individually valid (e.g. ${JSON.stringify(D[0])} vs ${JSON.stringify(D[1])}). parse() won't guess; add a separator between these tokens, or use their padded form (e.g. "MM" instead of "M") so each one has a fixed width. Pass { lenient: true } to opt into a documented heuristic that picks one.`});let X=ze(D,w.tokens);w.groupNames.forEach((pe,Ge)=>m.set(pe,String(X[Ge])))}else w.groupNames.forEach((X,pe)=>m.set(X,String(D[0][pe])))}let f={};for(let{name:w,token:x}of a.groups){let D=m.get(w)??s.groups[w];At(f,x,D,r,e)}let p=vt(f),c=_t(f,e,r),{month:i,day:d,minute:u,second:h,millisecond:k,microsecond:$,nanosecond:L,timeZoneId:y,offsetString:b,weekdayExpected:de,weekdayRaw:He,quarter:le}=f,Ye=p!==void 0||i!==void 0||d!==void 0,A=p!==void 0&&i!==void 0&&d!==void 0;if(Ye&&!A)throw new O({format:e,message:`temporal-fmt: format string "${e}" has an incomplete date \u2014 year, month, and day tokens must all be present together.`});let re=c!==void 0||u!==void 0||h!==void 0||k!==void 0;if(y!==void 0&&!(A&&re))throw new S({format:e,message:`temporal-fmt: format string "${e}" has a "zzz" token but needs a full date and time to build a ZonedDateTime.`});if(b!==void 0&&!(A&&re))throw new S({format:e,message:`temporal-fmt: format string "${e}" has an offset token (X/XX/XXX/x/xx/xxx) but needs a full date and time to build a ZonedDateTime.`});if(de!==void 0&&!A)throw new S({format:e,message:`temporal-fmt: format string "${e}" has a weekday token ("EEEE"/"EEE") but needs a full date to validate it against.`});if(!A&&!re)throw new S({format:e,message:`temporal-fmt: format string "${e}" has no date or time tokens to parse.`});let oe=R(),C={hour:c??0,minute:u??0,second:h??0,millisecond:k??0,microsecond:$??0,nanosecond:L??0},ge=o?{calendar:o}:{},fe={overflow:"reject"},v;try{if(y!==void 0){let w={overflow:"reject",offset:"prefer"};if(v=oe.ZonedDateTime.from({year:p,month:i,day:d,...C,...ge,timeZone:y,...b!==void 0?{offset:b}:{}},w),b!==void 0){let x=v;if(x.hour!==C.hour||x.minute!==C.minute||x.second!==C.second)throw new O({input:t,format:e,message:`"${y}" has no such wall-clock time on this date \u2014 it falls in a DST gap, not an ambiguous or valid instant.`});let X=x.offset;if(X!==b)throw new E({input:t,format:e,message:`has both a "zzz" zone (${y}) and an offset token (${b}), but the zone's actual offset at this date/time is ${X}, not ${b}.`})}}else{if(b!==void 0)throw new E({input:t,format:e,message:`format string "${e}" has an offset token but no "zzz" zone token. An offset does not identify a time zone by itself \u2014 add "zzz" to the pattern, or parse into a PlainDateTime/PlainDate/PlainTime if a zone isn't needed.`});A&&re?v=oe.PlainDateTime.from({year:p,month:i,day:d,...C,...ge},fe):A?v=oe.PlainDate.from({year:p,month:i,day:d,...ge},fe):v=oe.PlainTime.from(C,fe)}}catch(w){throw new O({input:t,format:e,message:`temporal-fmt: "${t}" doesn't describe a valid date/time for format "${e}": ${w.message}`})}if(de!==void 0){let w=v.dayOfWeek;if(w!==de){let x=Q(r);throw new O({input:t,format:e,message:`temporal-fmt: "${He}" doesn't match the actual weekday (${x.weekdayLong[w-1]}) for the parsed date.`})}}if(le!==void 0&&i!==void 0){let w=Math.ceil(i/3);if(le!==w)throw new O({format:e,message:`temporal-fmt: format string "${e}" contains a quarter token (Q/QQQ) whose value (Q${le}) disagrees with the parsed month's actual quarter \u2014 month ${i} is in Q${w}.`})}return v}function Ve(e,t,n={}){try{return{ok:!0,value:ue(e,t,n)}}catch(r){/* c8 ignore start @preserve */return r instanceof T?{ok:!1,error:r}:{ok:!1,error:Me(r,{input:t,format:e})}}/* c8 ignore stop @preserve */}function Ue(e,t,n={}){try{return ue(e,t,n)}catch{return}}function Ze(e,t,n={}){if(e.length>1e3)throw new S({format:e,message:`temporal-fmt: format string exceeds maximum length of ${1e3} characters (got ${e.length}).`});if(t.length>1e5)throw new S({input:t,message:`temporal-fmt: input exceeds maximum length of ${1e5} characters (got ${t.length}).`});n.parseNumberingSystem&&(t=Te(t,n));let r=n.locale??se,o=Ne(e,r),a=o.regex.exec(t);if(!a)throw new E({input:t,format:e,reason:"no valid pattern matches the format string and input shape",message:"temporal-fmt: no valid pattern matches the format string and input shape"});if(o.groups.length===0)throw new E({format:e,reason:`format string "${e}" has no tokens \u2014 nothing to parse into a value.`,message:`temporal-fmt: format string "${e}" has no tokens \u2014 nothing to parse into a value.`});for(let{name:i,token:d}of o.groups)if(d==="zzz"&&!be(a.groups[i]))throw new Y({input:t,format:e,actual:a.groups[i],reason:"not a recognized IANA time zone identifier"});let s=new Map;for(let i of o.ambiguousRuns){let d=a.groups[i.groupName],u=Ee(d,i.tokens);if(u.length===0)throw new E({input:t,format:e,reason:"no valid pattern matches the format string and input shape",message:"temporal-fmt: no valid pattern matches the format string and input shape"});if(u.length>1){if(!n.lenient)throw new z({input:t,format:e,message:`temporal-fmt: "${d}" in format string "${e}" is ambiguous \u2014 ${u.length} different ways to read tokens "${i.tokens.join("")}" (with no separator between them) are all individually valid (e.g. ${JSON.stringify(u[0])} vs ${JSON.stringify(u[1])}). parse() won't guess; add a separator between these tokens, or use their padded form (e.g. "MM" instead of "M") so each one has a fixed width. Pass { lenient: true } to opt into a documented heuristic that picks one.`});let h=ze(u,i.tokens);i.groupNames.forEach((k,$)=>s.set(k,String(h[$])))}else i.groupNames.forEach((h,k)=>s.set(h,String(u[0][k])))}let m=[],p=a.indices?.groups,c=0;for(let{name:i,token:d}of o.groups){let u=s.get(i)??a.groups[i],h=!s.has(i)&&p?.[i],k=h?h[0]:(a.index??0)+c;m.push({token:d,raw:u,position:k}),c+=u.length}return m}function Ct(e,t={}){if(e.length>1e3)throw new S({format:e,message:`temporal-fmt: format string exceeds maximum length of ${1e3} characters (got ${e.length}).`});let n=t.locale??se,r=Ne(e,n);return{formatStr:e,pattern:r,parse(o,a={}){return ue(e,o,{locale:n,...a})},safeParse(o,a={}){return Ve(e,o,{locale:n,...a})},tryParse(o,a={}){return Ue(e,o,{locale:n,...a})},parseToParts(o,a={}){return Ze(e,o,{locale:n,...a})}}}0&&(module.exports={compileParser,parse,parseToParts,safeParse,tryParse});
74
74
  //# sourceMappingURL=parse.cjs.map