temporal-fmt 0.9.1 → 0.9.2

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 (78) hide show
  1. package/dist/chunk-2JHEV7ZF.js +7 -0
  2. package/dist/chunk-2JHEV7ZF.js.map +1 -0
  3. package/dist/{chunk-DXLBLPLQ.js → chunk-4JWGUR4O.js} +2 -2
  4. package/dist/{chunk-H52AMABK.js → chunk-5U5WJ465.js} +6 -6
  5. package/dist/chunk-5U5WJ465.js.map +1 -0
  6. package/dist/chunk-C5YESWFT.js +2 -0
  7. package/dist/chunk-C5YESWFT.js.map +1 -0
  8. package/dist/chunk-F4RGUDA3.js +2 -0
  9. package/dist/chunk-F4RGUDA3.js.map +1 -0
  10. package/dist/chunk-NBXF7V5B.js +2 -0
  11. package/dist/chunk-NBXF7V5B.js.map +1 -0
  12. package/dist/{chunk-M5WL5VGW.js → chunk-R52YOKI3.js} +2 -2
  13. package/dist/chunk-UJR6DHXY.js +2 -0
  14. package/dist/chunk-UJR6DHXY.js.map +1 -0
  15. package/dist/{chunk-6UNSCZPL.js → chunk-XH46JNPK.js} +2 -2
  16. package/dist/chunk-XH46JNPK.js.map +1 -0
  17. package/dist/chunk-YB6YAG7E.js +35 -0
  18. package/dist/chunk-YB6YAG7E.js.map +1 -0
  19. package/dist/chunk-ZGMTY52O.js +2 -0
  20. package/dist/chunk-ZGMTY52O.js.map +1 -0
  21. package/dist/duration.cjs +4 -10
  22. package/dist/duration.cjs.map +1 -1
  23. package/dist/duration.js +1 -1
  24. package/dist/format.cjs +6 -6
  25. package/dist/format.cjs.map +1 -1
  26. package/dist/format.js +1 -1
  27. package/dist/formatDuration.d.cts +6 -0
  28. package/dist/formatDuration.d.ts +6 -0
  29. package/dist/index.cjs +37 -43
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.js +15 -15
  32. package/dist/index.js.map +1 -1
  33. package/dist/interval.cjs +6 -6
  34. package/dist/interval.cjs.map +1 -1
  35. package/dist/interval.js +1 -1
  36. package/dist/localeRegistry.cjs +4 -4
  37. package/dist/localeRegistry.cjs.map +1 -1
  38. package/dist/localeRegistry.js +1 -1
  39. package/dist/localeVocab.d.cts +3 -0
  40. package/dist/localeVocab.d.ts +3 -0
  41. package/dist/parse.cjs +9 -9
  42. package/dist/parse.cjs.map +1 -1
  43. package/dist/parse.js +1 -1
  44. package/dist/parsePattern.d.cts +1 -0
  45. package/dist/parsePattern.d.ts +1 -0
  46. package/dist/pattern.d.cts +1 -0
  47. package/dist/pattern.d.ts +1 -0
  48. package/dist/recurrence.cjs +4 -4
  49. package/dist/recurrence.cjs.map +1 -1
  50. package/dist/recurrence.js +1 -1
  51. package/dist/relativeTime.cjs +24 -1
  52. package/dist/relativeTime.cjs.map +1 -1
  53. package/dist/relativeTime.js +1 -1
  54. package/dist/rounding.d.cts +1 -0
  55. package/dist/rounding.d.ts +1 -0
  56. package/dist/serialization.d.cts +1 -1
  57. package/dist/serialization.d.ts +1 -1
  58. package/dist/typeGuards.d.cts +9 -9
  59. package/dist/typeGuards.d.ts +9 -9
  60. package/package.json +1 -1
  61. package/dist/chunk-6JAWE65A.js +0 -2
  62. package/dist/chunk-6JAWE65A.js.map +0 -1
  63. package/dist/chunk-6UNSCZPL.js.map +0 -1
  64. package/dist/chunk-CUTVOO4Y.js +0 -35
  65. package/dist/chunk-CUTVOO4Y.js.map +0 -1
  66. package/dist/chunk-H52AMABK.js.map +0 -1
  67. package/dist/chunk-ILXRFTAE.js +0 -13
  68. package/dist/chunk-ILXRFTAE.js.map +0 -1
  69. package/dist/chunk-LYWOLBMV.js +0 -2
  70. package/dist/chunk-LYWOLBMV.js.map +0 -1
  71. package/dist/chunk-QASXSTBN.js +0 -2
  72. package/dist/chunk-QASXSTBN.js.map +0 -1
  73. package/dist/chunk-YAVXHM4W.js +0 -2
  74. package/dist/chunk-YAVXHM4W.js.map +0 -1
  75. package/dist/chunk-ZYVMZRMR.js +0 -2
  76. package/dist/chunk-ZYVMZRMR.js.map +0 -1
  77. /package/dist/{chunk-DXLBLPLQ.js.map → chunk-4JWGUR4O.js.map} +0 -0
  78. /package/dist/{chunk-M5WL5VGW.js.map → chunk-R52YOKI3.js.map} +0 -0
package/dist/format.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var _=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var Q=(e,t)=>{for(var n in t)_(e,n,{get:t[n],enumerable:!0})},J=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of q(t))!B.call(e,i)&&i!==n&&_(e,i,{get:()=>t[i],enumerable:!(o=H(t,i))||o.enumerable});return e};var ee=e=>J(_({},"__esModule",{value:!0}),e);var we={};Q(we,{_getPieces:()=>ye,_handlerFor:()=>ke,compileFormat:()=>he,format:()=>ge,formatToParts:()=>fe});module.exports=ee(we);var te,ne=[];function U(e){ne.push(e)}function oe(){return te??globalThis.Temporal}function Z(){let e=oe();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 h=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 h{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 h{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 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
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
@@ -20,20 +20,20 @@
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 D=class extends h{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 re=new Map;function C(e){try{return new Intl.Locale(e.replace(/_/g,"-")).toString().toLowerCase()}catch{return e}}function u(e){let t=C(e);return re.get(t)}var ae=[0,31,59,90,120,151,181,212,243,273,304,334];function z(e){return e%4===0&&e%100!==0||e%400===0}function y(e){return z(e)?366:365}function k(e,t,n){let o=ae[t-1]+n;return t>2&&z(e)&&(o+=1),o}var V=2e3;function ie(e){let t=0;if(e>=V)for(let o=V;o<e;o++)t+=y(o);else for(let o=e;o<V;o++)t-=y(o);return((5+t)%7+7)%7+1}function R(e,t,n,o){let a=k(e,t,n)+(4-o),r,s;a<1?(r=e-1,s=a+y(r)):a>y(e)?(r=e+1,s=a-y(e)):(r=e,s=a);let v=1+(4-ie(r)+7)%7,A=1+Math.floor((s-v)/7);return{isoYear:r,week:A}}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 b="en-US",w=new Map,se=500;function W(e,t){let n=JSON.stringify([C(e),t]),o=w.get(n);if(o)return o;if(w.size>=se){let i=w.keys().next().value;i!==void 0&&w.delete(i)}return o=new Intl.DateTimeFormat(e,t),w.set(n,o),o}var T;U(()=>{T=void 0});function me(){if(T===void 0){T=!1;try{let e=Z();new Intl.DateTimeFormat("en-US",{day:"numeric"}).formatToParts(e.PlainDate.from({year:1970,month:1,day:1})),T=!0}catch{}}return T}function E(e,t,n,o){let i=e?.calendarId,a={...n,calendar:i&&i!=="iso8601"?i:"gregory"};if(!me())return e.toLocaleString(t,a);let{toInstant:r,timeZoneId:s}=e,l=typeof r=="function"&&typeof s=="string",v=l?e.toInstant():e,A={...a,...l?{timeZone:s}:{}},$=W(t,A).formatToParts(v),O=$.findIndex(G=>G.type===o);if(O===-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 f=$[O].value,P=$[O-1],M=$[O+1];return P?.type==="literal"&&!/\s/.test(P.value)&&(f=P.value+f),M?.type==="literal"&&!/\s/.test(M.value)&&(f=f+M.value),f}function ce(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=W(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]:E(e,t,n,o)}function g(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 I=[["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)=>ce(e.hour,t),"hour"],["zzz",e=>e.timeZoneId,"timeZoneId"],["xxx",e=>g(e.offset,"xxx"),"offset"],["xx",e=>g(e.offset,"xx"),"offset"],["X",e=>g(e.offset,"X"),"offset"],["XX",e=>g(e.offset,"XX"),"offset"],["XXX",e=>g(e.offset,"XXX"),"offset"],["x",e=>g(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}=R(e.year,e.month,e.day,e.dayOfWeek);return m(t,2)},"dayOfWeek"],["RRRR",e=>{let{isoYear:t}=R(e.year,e.month,e.day,e.dayOfWeek);return m(t,4)},"dayOfWeek"],["D",e=>String(k(e.year,e.month,e.day)),"day"],["DD",e=>m(k(e.year,e.month,e.day),2),"day"],["DDD",e=>m(k(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)=>E(e,t,{era:"long"},"era"),"year"],["G",(e,t)=>E(e,t,{era:"short"},"era"),"year"],["zzzz",(e,t)=>E(e,t,{timeZoneName:"longGeneric"},"timeZoneName"),"timeZoneId"],["z",(e,t)=>E(e,t,{timeZoneName:"short"},"timeZoneName"),"timeZoneId"]];var le=I.map(([e])=>e).sort((e,t)=>t.length-e.length);function Y(e){let t=[],n=0;for(;n<e.length;){let o=e[n];if(o==="'"){if(e[n+1]==="'"){X(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}"`});X(t,r),n=a;continue}let i=le.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}X(t,o),n+=1}return t}function X(e,t){let n=e[e.length-1];n&&n.kind==="literal"?n.value+=t:e.push({kind:"literal",value:t})}var K=new Set(["latn","arab","deva","beng","guru","gujr","orya","tamldec","telu","knda","mlym","fullwide","hanidec"]),j=new Map;function ue(e){let t=j.get(e);if(t)return t;/* c8 ignore start @preserve -- dead by construction, not just
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
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 j.set(e,t),t}function de(e,t){if(t==="latn")return e;if(!K.has(t))throw new D({actual:t,reason:`numbering system "${t}" is not supported. Supported: ${[...K].join(", ")}.`});let n=ue(t),o="";for(let i of e)i>="0"&&i<="9"?o+=n[i]??i:o+=i;return o}function F(e,t){let n=t.numberingSystem??"latn";return n==="latn"?e:de(e,n)}var L=new Map(I.map(([e,t,n])=>[e,{fn:t,field:n}])),S=new Map,pe=500;function N(e){let t=S.get(e);if(t)return t;if(S.size>=pe){let n=S.keys().next().value;n!==void 0&&S.delete(n)}return t=Y(e),S.set(e,t),t}function ge(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??b,i=N(t),a="";for(let r of i){if(r.kind==="literal"){a+=r.value;continue}let s=L.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 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
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 F(a,n)}function fe(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??b,i=N(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 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
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=L.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:F(s.fn(e,o),n),token:r.value})}return a}function he(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=N(e);return{formatStr:e,pieces:t,format(n,o={}){let i=o.locale??b,a="";for(let r of t){if(r.kind==="literal"){a+=r.value;continue}let s=L.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 F(a,o)},formatToParts(n,o={}){let i=o.locale??b,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=L.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:F(s.fn(n,i),o),token:r.value})}return a}}}function ye(e){return N(e)}function ke(e){return L.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: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});
39
39
  //# sourceMappingURL=format.cjs.map