@leancodepl/api-date-datefns
Version:
Date-fns integration for API date type conversion
2 lines (1 loc) • 41.3 kB
JavaScript
(function(T,L){typeof exports=="object"&&typeof module<"u"?L(exports):typeof define=="function"&&define.amd?define(["exports"],L):(T=typeof globalThis<"u"?globalThis:T||self,L(T["@leancodepl/api-date-datefns"]={}))})(this,(function(T){"use strict";const Z=Symbol.for("constructDateFrom");function x(r,e){return typeof r=="function"?r(e):r&&typeof r=="object"&&Z in r?r[Z](e):r instanceof Date?new r.constructor(e):new Date(e)}function b(r,e){return x(e||r,r)}function K(r,e,t){const n=b(r,t?.in);return isNaN(e)?x(t?.in||r,NaN):(e&&n.setDate(n.getDate()+e),n)}let pe={};function W(){return pe}function O(r,e){const t=W(),n=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??t.weekStartsOn??t.locale?.options?.weekStartsOn??0,a=b(r,e?.in),s=a.getDay(),o=(s<n?7:0)+s-n;return a.setDate(a.getDate()-o),a.setHours(0,0,0,0),a}function _(r,e){return O(r,{...e,weekStartsOn:1})}function U(r,e){const t=b(r,e?.in),n=t.getFullYear(),a=x(t,0);a.setFullYear(n+1,0,4),a.setHours(0,0,0,0);const s=_(a),o=x(t,0);o.setFullYear(n,0,4),o.setHours(0,0,0,0);const i=_(o);return t.getTime()>=s.getTime()?n+1:t.getTime()>=i.getTime()?n:n-1}function C(r){const e=b(r),t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),+r-+t}function xe(r,...e){const t=x.bind(null,e.find(n=>typeof n=="object"));return e.map(t)}function S(r,e){const t=b(r,e?.in);return t.setHours(0,0,0,0),t}function Me(r,e,t){const[n,a]=xe(t?.in,r,e),s=S(n),o=S(a),i=+s-C(s),g=+o-C(o);return Math.round((i-g)/864e5)}function Te(r,e){const t=U(r,e),n=x(r,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),_(n)}function Pe(r){return r instanceof Date||typeof r=="object"&&Object.prototype.toString.call(r)==="[object Date]"}function De(r){return!(!Pe(r)&&typeof r!="number"||isNaN(+b(r)))}function ke(r,e){const t=b(r,e?.in);return t.setFullYear(t.getFullYear(),0,1),t.setHours(0,0,0,0),t}const Oe={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},ve=(r,e,t)=>{let n;const a=Oe[r];return typeof a=="string"?n=a:e===1?n=a.one:n=a.other.replace("{{count}}",e.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"in "+n:n+" ago":n};function A(r){return(e={})=>{const t=e.width?String(e.width):r.defaultWidth;return r.formats[t]||r.formats[r.defaultWidth]}}const Ye={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Ee={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},We={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},_e={date:A({formats:Ye,defaultWidth:"full"}),time:A({formats:Ee,defaultWidth:"full"}),dateTime:A({formats:We,defaultWidth:"full"})},He={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},qe=(r,e,t,n)=>He[r];function N(r){return(e,t)=>{const n=t?.context?String(t.context):"standalone";let a;if(n==="formatting"&&r.formattingValues){const o=r.defaultFormattingWidth||r.defaultWidth,i=t?.width?String(t.width):o;a=r.formattingValues[i]||r.formattingValues[o]}else{const o=r.defaultWidth,i=t?.width?String(t.width):r.defaultWidth;a=r.values[i]||r.values[o]}const s=r.argumentCallback?r.argumentCallback(e):e;return a[s]}}const Ne={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Ie={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Fe={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Le={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Ce={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Qe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Ae={ordinalNumber:(r,e)=>{const t=Number(r),n=t%100;if(n>20||n<10)switch(n%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},era:N({values:Ne,defaultWidth:"wide"}),quarter:N({values:Ie,defaultWidth:"wide",argumentCallback:r=>r-1}),month:N({values:Fe,defaultWidth:"wide"}),day:N({values:Le,defaultWidth:"wide"}),dayPeriod:N({values:Ce,defaultWidth:"wide",formattingValues:Qe,defaultFormattingWidth:"wide"})};function I(r){return(e,t={})=>{const n=t.width,a=n&&r.matchPatterns[n]||r.matchPatterns[r.defaultMatchWidth],s=e.match(a);if(!s)return null;const o=s[0],i=n&&r.parsePatterns[n]||r.parsePatterns[r.defaultParseWidth],g=Array.isArray(i)?Xe(i,p=>p.test(o)):Re(i,p=>p.test(o));let M;M=r.valueCallback?r.valueCallback(g):g,M=t.valueCallback?t.valueCallback(M):M;const y=e.slice(o.length);return{value:M,rest:y}}}function Re(r,e){for(const t in r)if(Object.prototype.hasOwnProperty.call(r,t)&&e(r[t]))return t}function Xe(r,e){for(let t=0;t<r.length;t++)if(e(r[t]))return t}function Be(r){return(e,t={})=>{const n=e.match(r.matchPattern);if(!n)return null;const a=n[0],s=e.match(r.parsePattern);if(!s)return null;let o=r.valueCallback?r.valueCallback(s[0]):s[0];o=t.valueCallback?t.valueCallback(o):o;const i=e.slice(a.length);return{value:o,rest:i}}}const Ge=/^(\d+)(th|st|nd|rd)?/i,$e=/\d+/i,je={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Ve={any:[/^b/i,/^(a|c)/i]},ze={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Je={any:[/1/i,/2/i,/3/i,/4/i]},Ze={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Ke={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},Ue={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Se={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},et={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},tt={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},nt={ordinalNumber:Be({matchPattern:Ge,parsePattern:$e,valueCallback:r=>parseInt(r,10)}),era:I({matchPatterns:je,defaultMatchWidth:"wide",parsePatterns:Ve,defaultParseWidth:"any"}),quarter:I({matchPatterns:ze,defaultMatchWidth:"wide",parsePatterns:Je,defaultParseWidth:"any",valueCallback:r=>r+1}),month:I({matchPatterns:Ze,defaultMatchWidth:"wide",parsePatterns:Ke,defaultParseWidth:"any"}),day:I({matchPatterns:Ue,defaultMatchWidth:"wide",parsePatterns:Se,defaultParseWidth:"any"}),dayPeriod:I({matchPatterns:et,defaultMatchWidth:"any",parsePatterns:tt,defaultParseWidth:"any"})},ee={code:"en-US",formatDistance:ve,formatLong:_e,formatRelative:qe,localize:Ae,match:nt,options:{weekStartsOn:0,firstWeekContainsDate:1}};function rt(r,e){const t=b(r,e?.in);return Me(t,ke(t))+1}function te(r,e){const t=b(r,e?.in),n=+_(t)-+Te(t);return Math.round(n/6048e5)+1}function R(r,e){const t=b(r,e?.in),n=t.getFullYear(),a=W(),s=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,o=x(e?.in||r,0);o.setFullYear(n+1,0,s),o.setHours(0,0,0,0);const i=O(o,e),g=x(e?.in||r,0);g.setFullYear(n,0,s),g.setHours(0,0,0,0);const M=O(g,e);return+t>=+i?n+1:+t>=+M?n:n-1}function at(r,e){const t=W(),n=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??t.firstWeekContainsDate??t.locale?.options?.firstWeekContainsDate??1,a=R(r,e),s=x(e?.in||r,0);return s.setFullYear(a,0,n),s.setHours(0,0,0,0),O(s,e)}function ne(r,e){const t=b(r,e?.in),n=+O(t,e)-+at(t,e);return Math.round(n/6048e5)+1}function d(r,e){const t=r<0?"-":"",n=Math.abs(r).toString().padStart(e,"0");return t+n}const v={y(r,e){const t=r.getFullYear(),n=t>0?t:1-t;return d(e==="yy"?n%100:n,e.length)},M(r,e){const t=r.getMonth();return e==="M"?String(t+1):d(t+1,2)},d(r,e){return d(r.getDate(),e.length)},a(r,e){const t=r.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return t.toUpperCase();case"aaa":return t;case"aaaaa":return t[0];default:return t==="am"?"a.m.":"p.m."}},h(r,e){return d(r.getHours()%12||12,e.length)},H(r,e){return d(r.getHours(),e.length)},m(r,e){return d(r.getMinutes(),e.length)},s(r,e){return d(r.getSeconds(),e.length)},S(r,e){const t=e.length,n=r.getMilliseconds(),a=Math.trunc(n*Math.pow(10,t-3));return d(a,e.length)}},H={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},re={G:function(r,e,t){const n=r.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return t.era(n,{width:"abbreviated"});case"GGGGG":return t.era(n,{width:"narrow"});default:return t.era(n,{width:"wide"})}},y:function(r,e,t){if(e==="yo"){const n=r.getFullYear(),a=n>0?n:1-n;return t.ordinalNumber(a,{unit:"year"})}return v.y(r,e)},Y:function(r,e,t,n){const a=R(r,n),s=a>0?a:1-a;if(e==="YY"){const o=s%100;return d(o,2)}return e==="Yo"?t.ordinalNumber(s,{unit:"year"}):d(s,e.length)},R:function(r,e){const t=U(r);return d(t,e.length)},u:function(r,e){const t=r.getFullYear();return d(t,e.length)},Q:function(r,e,t){const n=Math.ceil((r.getMonth()+1)/3);switch(e){case"Q":return String(n);case"QQ":return d(n,2);case"Qo":return t.ordinalNumber(n,{unit:"quarter"});case"QQQ":return t.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return t.quarter(n,{width:"narrow",context:"formatting"});default:return t.quarter(n,{width:"wide",context:"formatting"})}},q:function(r,e,t){const n=Math.ceil((r.getMonth()+1)/3);switch(e){case"q":return String(n);case"qq":return d(n,2);case"qo":return t.ordinalNumber(n,{unit:"quarter"});case"qqq":return t.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return t.quarter(n,{width:"narrow",context:"standalone"});default:return t.quarter(n,{width:"wide",context:"standalone"})}},M:function(r,e,t){const n=r.getMonth();switch(e){case"M":case"MM":return v.M(r,e);case"Mo":return t.ordinalNumber(n+1,{unit:"month"});case"MMM":return t.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return t.month(n,{width:"narrow",context:"formatting"});default:return t.month(n,{width:"wide",context:"formatting"})}},L:function(r,e,t){const n=r.getMonth();switch(e){case"L":return String(n+1);case"LL":return d(n+1,2);case"Lo":return t.ordinalNumber(n+1,{unit:"month"});case"LLL":return t.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return t.month(n,{width:"narrow",context:"standalone"});default:return t.month(n,{width:"wide",context:"standalone"})}},w:function(r,e,t,n){const a=ne(r,n);return e==="wo"?t.ordinalNumber(a,{unit:"week"}):d(a,e.length)},I:function(r,e,t){const n=te(r);return e==="Io"?t.ordinalNumber(n,{unit:"week"}):d(n,e.length)},d:function(r,e,t){return e==="do"?t.ordinalNumber(r.getDate(),{unit:"date"}):v.d(r,e)},D:function(r,e,t){const n=rt(r);return e==="Do"?t.ordinalNumber(n,{unit:"dayOfYear"}):d(n,e.length)},E:function(r,e,t){const n=r.getDay();switch(e){case"E":case"EE":case"EEE":return t.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return t.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return t.day(n,{width:"short",context:"formatting"});default:return t.day(n,{width:"wide",context:"formatting"})}},e:function(r,e,t,n){const a=r.getDay(),s=(a-n.weekStartsOn+8)%7||7;switch(e){case"e":return String(s);case"ee":return d(s,2);case"eo":return t.ordinalNumber(s,{unit:"day"});case"eee":return t.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return t.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return t.day(a,{width:"short",context:"formatting"});default:return t.day(a,{width:"wide",context:"formatting"})}},c:function(r,e,t,n){const a=r.getDay(),s=(a-n.weekStartsOn+8)%7||7;switch(e){case"c":return String(s);case"cc":return d(s,e.length);case"co":return t.ordinalNumber(s,{unit:"day"});case"ccc":return t.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return t.day(a,{width:"narrow",context:"standalone"});case"cccccc":return t.day(a,{width:"short",context:"standalone"});default:return t.day(a,{width:"wide",context:"standalone"})}},i:function(r,e,t){const n=r.getDay(),a=n===0?7:n;switch(e){case"i":return String(a);case"ii":return d(a,e.length);case"io":return t.ordinalNumber(a,{unit:"day"});case"iii":return t.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return t.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return t.day(n,{width:"short",context:"formatting"});default:return t.day(n,{width:"wide",context:"formatting"})}},a:function(r,e,t){const a=r.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return t.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return t.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return t.dayPeriod(a,{width:"narrow",context:"formatting"});default:return t.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(r,e,t){const n=r.getHours();let a;switch(n===12?a=H.noon:n===0?a=H.midnight:a=n/12>=1?"pm":"am",e){case"b":case"bb":return t.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return t.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return t.dayPeriod(a,{width:"narrow",context:"formatting"});default:return t.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(r,e,t){const n=r.getHours();let a;switch(n>=17?a=H.evening:n>=12?a=H.afternoon:n>=4?a=H.morning:a=H.night,e){case"B":case"BB":case"BBB":return t.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return t.dayPeriod(a,{width:"narrow",context:"formatting"});default:return t.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(r,e,t){if(e==="ho"){let n=r.getHours()%12;return n===0&&(n=12),t.ordinalNumber(n,{unit:"hour"})}return v.h(r,e)},H:function(r,e,t){return e==="Ho"?t.ordinalNumber(r.getHours(),{unit:"hour"}):v.H(r,e)},K:function(r,e,t){const n=r.getHours()%12;return e==="Ko"?t.ordinalNumber(n,{unit:"hour"}):d(n,e.length)},k:function(r,e,t){let n=r.getHours();return n===0&&(n=24),e==="ko"?t.ordinalNumber(n,{unit:"hour"}):d(n,e.length)},m:function(r,e,t){return e==="mo"?t.ordinalNumber(r.getMinutes(),{unit:"minute"}):v.m(r,e)},s:function(r,e,t){return e==="so"?t.ordinalNumber(r.getSeconds(),{unit:"second"}):v.s(r,e)},S:function(r,e){return v.S(r,e)},X:function(r,e,t){const n=r.getTimezoneOffset();if(n===0)return"Z";switch(e){case"X":return se(n);case"XXXX":case"XX":return Y(n);default:return Y(n,":")}},x:function(r,e,t){const n=r.getTimezoneOffset();switch(e){case"x":return se(n);case"xxxx":case"xx":return Y(n);default:return Y(n,":")}},O:function(r,e,t){const n=r.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+ae(n,":");default:return"GMT"+Y(n,":")}},z:function(r,e,t){const n=r.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+ae(n,":");default:return"GMT"+Y(n,":")}},t:function(r,e,t){const n=Math.trunc(+r/1e3);return d(n,e.length)},T:function(r,e,t){return d(+r,e.length)}};function ae(r,e=""){const t=r>0?"-":"+",n=Math.abs(r),a=Math.trunc(n/60),s=n%60;return s===0?t+String(a):t+String(a)+e+d(s,2)}function se(r,e){return r%60===0?(r>0?"-":"+")+d(Math.abs(r)/60,2):Y(r,e)}function Y(r,e=""){const t=r>0?"-":"+",n=Math.abs(r),a=d(Math.trunc(n/60),2),s=d(n%60,2);return t+a+e+s}const oe=(r,e)=>{switch(r){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});default:return e.date({width:"full"})}},ie=(r,e)=>{switch(r){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});default:return e.time({width:"full"})}},X={p:ie,P:(r,e)=>{const t=r.match(/(P+)(p+)?/)||[],n=t[1],a=t[2];if(!a)return oe(r,e);let s;switch(n){case"P":s=e.dateTime({width:"short"});break;case"PP":s=e.dateTime({width:"medium"});break;case"PPP":s=e.dateTime({width:"long"});break;default:s=e.dateTime({width:"full"});break}return s.replace("{{date}}",oe(n,e)).replace("{{time}}",ie(a,e))}},st=/^D+$/,ot=/^Y+$/,it=["D","DD","YY","YYYY"];function ue(r){return st.test(r)}function ce(r){return ot.test(r)}function B(r,e,t){const n=ut(r,e,t);if(console.warn(n),it.includes(r))throw new RangeError(n)}function ut(r,e,t){const n=r[0]==="Y"?"years":"days of the month";return`Use \`${r.toLowerCase()}\` instead of \`${r}\` (in \`${e}\`) for formatting ${n} to the input \`${t}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const ct=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,dt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,lt=/^'([^]*?)'?$/,ft=/''/g,ht=/[a-zA-Z]/;function G(r,e,t){const n=W(),a=n.locale??ee,s=n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,o=n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=b(r,t?.in);if(!De(i))throw new RangeError("Invalid time value");let g=e.match(dt).map(y=>{const p=y[0];if(p==="p"||p==="P"){const E=X[p];return E(y,a.formatLong)}return y}).join("").match(ct).map(y=>{if(y==="''")return{isToken:!1,value:"'"};const p=y[0];if(p==="'")return{isToken:!1,value:mt(y)};if(re[p])return{isToken:!0,value:y};if(p.match(ht))throw new RangeError("Format string contains an unescaped latin alphabet character `"+p+"`");return{isToken:!1,value:y}});a.localize.preprocessor&&(g=a.localize.preprocessor(i,g));const M={firstWeekContainsDate:s,weekStartsOn:o,locale:a};return g.map(y=>{if(!y.isToken)return y.value;const p=y.value;(ce(p)||ue(p))&&B(p,e,String(r));const E=re[p[0]];return E(i,p,a.localize,M)}).join("")}function mt(r){const e=r.match(lt);return e?e[1].replace(ft,"'"):r}function wt(){return Object.assign({},W())}function yt(r,e){const t=b(r,e?.in).getDay();return t===0?7:t}function de(r){return Math.trunc(r*36e5)}function bt(r,e){const t=gt(e)?new e(0):x(e,0);return t.setFullYear(r.getFullYear(),r.getMonth(),r.getDate()),t.setHours(r.getHours(),r.getMinutes(),r.getSeconds(),r.getMilliseconds()),t}function gt(r){return typeof r=="function"&&r.prototype?.constructor===r}const pt=10;class le{subPriority=0;validate(e,t){return!0}}class xt extends le{constructor(e,t,n,a,s){super(),this.value=e,this.validateValue=t,this.setValue=n,this.priority=a,s&&(this.subPriority=s)}validate(e,t){return this.validateValue(e,this.value,t)}set(e,t,n){return this.setValue(e,t,this.value,n)}}class Mt extends le{priority=pt;subPriority=-1;constructor(e,t){super(),this.context=e||(n=>x(t,n))}set(e,t){return t.timestampIsSet?e:x(e,bt(e,this.context))}}class c{run(e,t,n,a){const s=this.parse(e,t,n,a);return s?{setter:new xt(s.value,this.validate,this.set,this.priority,this.subPriority),rest:s.rest}:null}validate(e,t,n){return!0}}class Tt extends c{priority=140;parse(e,t,n){switch(t){case"G":case"GG":case"GGG":return n.era(e,{width:"abbreviated"})||n.era(e,{width:"narrow"});case"GGGGG":return n.era(e,{width:"narrow"});default:return n.era(e,{width:"wide"})||n.era(e,{width:"abbreviated"})||n.era(e,{width:"narrow"})}}set(e,t,n){return t.era=n,e.setFullYear(n,0,1),e.setHours(0,0,0,0),e}incompatibleTokens=["R","u","t","T"]}const m={month:/^(1[0-2]|0?\d)/,date:/^(3[0-1]|[0-2]?\d)/,dayOfYear:/^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,week:/^(5[0-3]|[0-4]?\d)/,hour23h:/^(2[0-3]|[0-1]?\d)/,hour24h:/^(2[0-4]|[0-1]?\d)/,hour11h:/^(1[0-1]|0?\d)/,hour12h:/^(1[0-2]|0?\d)/,minute:/^[0-5]?\d/,second:/^[0-5]?\d/,singleDigit:/^\d/,twoDigits:/^\d{1,2}/,threeDigits:/^\d{1,3}/,fourDigits:/^\d{1,4}/,anyDigitsSigned:/^-?\d+/,singleDigitSigned:/^-?\d/,twoDigitsSigned:/^-?\d{1,2}/,threeDigitsSigned:/^-?\d{1,3}/,fourDigitsSigned:/^-?\d{1,4}/},P={basicOptionalMinutes:/^([+-])(\d{2})(\d{2})?|Z/,basic:/^([+-])(\d{2})(\d{2})|Z/,basicOptionalSeconds:/^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,extended:/^([+-])(\d{2}):(\d{2})|Z/,extendedOptionalSeconds:/^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/};function w(r,e){return r&&{value:e(r.value),rest:r.rest}}function l(r,e){const t=e.match(r);return t?{value:parseInt(t[0],10),rest:e.slice(t[0].length)}:null}function D(r,e){const t=e.match(r);if(!t)return null;if(t[0]==="Z")return{value:0,rest:e.slice(1)};const n=t[1]==="+"?1:-1,a=t[2]?parseInt(t[2],10):0,s=t[3]?parseInt(t[3],10):0,o=t[5]?parseInt(t[5],10):0;return{value:n*(a*36e5+s*6e4+o*1e3),rest:e.slice(t[0].length)}}function fe(r){return l(m.anyDigitsSigned,r)}function f(r,e){switch(r){case 1:return l(m.singleDigit,e);case 2:return l(m.twoDigits,e);case 3:return l(m.threeDigits,e);case 4:return l(m.fourDigits,e);default:return l(new RegExp("^\\d{1,"+r+"}"),e)}}function Q(r,e){switch(r){case 1:return l(m.singleDigitSigned,e);case 2:return l(m.twoDigitsSigned,e);case 3:return l(m.threeDigitsSigned,e);case 4:return l(m.fourDigitsSigned,e);default:return l(new RegExp("^-?\\d{1,"+r+"}"),e)}}function $(r){switch(r){case"morning":return 4;case"evening":return 17;case"pm":case"noon":case"afternoon":return 12;default:return 0}}function he(r,e){const t=e>0,n=t?e:1-e;let a;if(n<=50)a=r||100;else{const s=n+50,o=Math.trunc(s/100)*100,i=r>=s%100;a=r+o-(i?100:0)}return t?a:1-a}function me(r){return r%400===0||r%4===0&&r%100!==0}class Pt extends c{priority=130;incompatibleTokens=["Y","R","u","w","I","i","e","c","t","T"];parse(e,t,n){const a=s=>({year:s,isTwoDigitYear:t==="yy"});switch(t){case"y":return w(f(4,e),a);case"yo":return w(n.ordinalNumber(e,{unit:"year"}),a);default:return w(f(t.length,e),a)}}validate(e,t){return t.isTwoDigitYear||t.year>0}set(e,t,n){const a=e.getFullYear();if(n.isTwoDigitYear){const o=he(n.year,a);return e.setFullYear(o,0,1),e.setHours(0,0,0,0),e}const s=!("era"in t)||t.era===1?n.year:1-n.year;return e.setFullYear(s,0,1),e.setHours(0,0,0,0),e}}class Dt extends c{priority=130;parse(e,t,n){const a=s=>({year:s,isTwoDigitYear:t==="YY"});switch(t){case"Y":return w(f(4,e),a);case"Yo":return w(n.ordinalNumber(e,{unit:"year"}),a);default:return w(f(t.length,e),a)}}validate(e,t){return t.isTwoDigitYear||t.year>0}set(e,t,n,a){const s=R(e,a);if(n.isTwoDigitYear){const i=he(n.year,s);return e.setFullYear(i,0,a.firstWeekContainsDate),e.setHours(0,0,0,0),O(e,a)}const o=!("era"in t)||t.era===1?n.year:1-n.year;return e.setFullYear(o,0,a.firstWeekContainsDate),e.setHours(0,0,0,0),O(e,a)}incompatibleTokens=["y","R","u","Q","q","M","L","I","d","D","i","t","T"]}class kt extends c{priority=130;parse(e,t){return Q(t==="R"?4:t.length,e)}set(e,t,n){const a=x(e,0);return a.setFullYear(n,0,4),a.setHours(0,0,0,0),_(a)}incompatibleTokens=["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"]}class Ot extends c{priority=130;parse(e,t){return Q(t==="u"?4:t.length,e)}set(e,t,n){return e.setFullYear(n,0,1),e.setHours(0,0,0,0),e}incompatibleTokens=["G","y","Y","R","w","I","i","e","c","t","T"]}class vt extends c{priority=120;parse(e,t,n){switch(t){case"Q":case"QQ":return f(t.length,e);case"Qo":return n.ordinalNumber(e,{unit:"quarter"});case"QQQ":return n.quarter(e,{width:"abbreviated",context:"formatting"})||n.quarter(e,{width:"narrow",context:"formatting"});case"QQQQQ":return n.quarter(e,{width:"narrow",context:"formatting"});default:return n.quarter(e,{width:"wide",context:"formatting"})||n.quarter(e,{width:"abbreviated",context:"formatting"})||n.quarter(e,{width:"narrow",context:"formatting"})}}validate(e,t){return t>=1&&t<=4}set(e,t,n){return e.setMonth((n-1)*3,1),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","M","L","w","I","d","D","i","e","c","t","T"]}class Yt extends c{priority=120;parse(e,t,n){switch(t){case"q":case"qq":return f(t.length,e);case"qo":return n.ordinalNumber(e,{unit:"quarter"});case"qqq":return n.quarter(e,{width:"abbreviated",context:"standalone"})||n.quarter(e,{width:"narrow",context:"standalone"});case"qqqqq":return n.quarter(e,{width:"narrow",context:"standalone"});default:return n.quarter(e,{width:"wide",context:"standalone"})||n.quarter(e,{width:"abbreviated",context:"standalone"})||n.quarter(e,{width:"narrow",context:"standalone"})}}validate(e,t){return t>=1&&t<=4}set(e,t,n){return e.setMonth((n-1)*3,1),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","Q","M","L","w","I","d","D","i","e","c","t","T"]}class Et extends c{incompatibleTokens=["Y","R","q","Q","L","w","I","D","i","e","c","t","T"];priority=110;parse(e,t,n){const a=s=>s-1;switch(t){case"M":return w(l(m.month,e),a);case"MM":return w(f(2,e),a);case"Mo":return w(n.ordinalNumber(e,{unit:"month"}),a);case"MMM":return n.month(e,{width:"abbreviated",context:"formatting"})||n.month(e,{width:"narrow",context:"formatting"});case"MMMMM":return n.month(e,{width:"narrow",context:"formatting"});default:return n.month(e,{width:"wide",context:"formatting"})||n.month(e,{width:"abbreviated",context:"formatting"})||n.month(e,{width:"narrow",context:"formatting"})}}validate(e,t){return t>=0&&t<=11}set(e,t,n){return e.setMonth(n,1),e.setHours(0,0,0,0),e}}class Wt extends c{priority=110;parse(e,t,n){const a=s=>s-1;switch(t){case"L":return w(l(m.month,e),a);case"LL":return w(f(2,e),a);case"Lo":return w(n.ordinalNumber(e,{unit:"month"}),a);case"LLL":return n.month(e,{width:"abbreviated",context:"standalone"})||n.month(e,{width:"narrow",context:"standalone"});case"LLLLL":return n.month(e,{width:"narrow",context:"standalone"});default:return n.month(e,{width:"wide",context:"standalone"})||n.month(e,{width:"abbreviated",context:"standalone"})||n.month(e,{width:"narrow",context:"standalone"})}}validate(e,t){return t>=0&&t<=11}set(e,t,n){return e.setMonth(n,1),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","Q","M","w","I","D","i","e","c","t","T"]}function _t(r,e,t){const n=b(r,t?.in),a=ne(n,t)-e;return n.setDate(n.getDate()-a*7),b(n,t?.in)}class Ht extends c{priority=100;parse(e,t,n){switch(t){case"w":return l(m.week,e);case"wo":return n.ordinalNumber(e,{unit:"week"});default:return f(t.length,e)}}validate(e,t){return t>=1&&t<=53}set(e,t,n,a){return O(_t(e,n,a),a)}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","i","t","T"]}function qt(r,e,t){const n=b(r,t?.in),a=te(n,t)-e;return n.setDate(n.getDate()-a*7),n}class Nt extends c{priority=100;parse(e,t,n){switch(t){case"I":return l(m.week,e);case"Io":return n.ordinalNumber(e,{unit:"week"});default:return f(t.length,e)}}validate(e,t){return t>=1&&t<=53}set(e,t,n){return _(qt(e,n))}incompatibleTokens=["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"]}const It=[31,28,31,30,31,30,31,31,30,31,30,31],Ft=[31,29,31,30,31,30,31,31,30,31,30,31];class Lt extends c{priority=90;subPriority=1;parse(e,t,n){switch(t){case"d":return l(m.date,e);case"do":return n.ordinalNumber(e,{unit:"date"});default:return f(t.length,e)}}validate(e,t){const n=e.getFullYear(),a=me(n),s=e.getMonth();return a?t>=1&&t<=Ft[s]:t>=1&&t<=It[s]}set(e,t,n){return e.setDate(n),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","Q","w","I","D","i","e","c","t","T"]}class Ct extends c{priority=90;subpriority=1;parse(e,t,n){switch(t){case"D":case"DD":return l(m.dayOfYear,e);case"Do":return n.ordinalNumber(e,{unit:"date"});default:return f(t.length,e)}}validate(e,t){const n=e.getFullYear();return me(n)?t>=1&&t<=366:t>=1&&t<=365}set(e,t,n){return e.setMonth(0,n),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","Q","M","L","w","I","d","E","i","e","c","t","T"]}function j(r,e,t){const n=W(),a=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,s=b(r,t?.in),o=s.getDay(),g=(e%7+7)%7,M=7-a,y=e<0||e>6?e-(o+M)%7:(g+M)%7-(o+M)%7;return K(s,y,t)}class Qt extends c{priority=90;parse(e,t,n){switch(t){case"E":case"EE":case"EEE":return n.day(e,{width:"abbreviated",context:"formatting"})||n.day(e,{width:"short",context:"formatting"})||n.day(e,{width:"narrow",context:"formatting"});case"EEEEE":return n.day(e,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(e,{width:"short",context:"formatting"})||n.day(e,{width:"narrow",context:"formatting"});default:return n.day(e,{width:"wide",context:"formatting"})||n.day(e,{width:"abbreviated",context:"formatting"})||n.day(e,{width:"short",context:"formatting"})||n.day(e,{width:"narrow",context:"formatting"})}}validate(e,t){return t>=0&&t<=6}set(e,t,n,a){return e=j(e,n,a),e.setHours(0,0,0,0),e}incompatibleTokens=["D","i","e","c","t","T"]}class At extends c{priority=90;parse(e,t,n,a){const s=o=>{const i=Math.floor((o-1)/7)*7;return(o+a.weekStartsOn+6)%7+i};switch(t){case"e":case"ee":return w(f(t.length,e),s);case"eo":return w(n.ordinalNumber(e,{unit:"day"}),s);case"eee":return n.day(e,{width:"abbreviated",context:"formatting"})||n.day(e,{width:"short",context:"formatting"})||n.day(e,{width:"narrow",context:"formatting"});case"eeeee":return n.day(e,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(e,{width:"short",context:"formatting"})||n.day(e,{width:"narrow",context:"formatting"});default:return n.day(e,{width:"wide",context:"formatting"})||n.day(e,{width:"abbreviated",context:"formatting"})||n.day(e,{width:"short",context:"formatting"})||n.day(e,{width:"narrow",context:"formatting"})}}validate(e,t){return t>=0&&t<=6}set(e,t,n,a){return e=j(e,n,a),e.setHours(0,0,0,0),e}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"]}class Rt extends c{priority=90;parse(e,t,n,a){const s=o=>{const i=Math.floor((o-1)/7)*7;return(o+a.weekStartsOn+6)%7+i};switch(t){case"c":case"cc":return w(f(t.length,e),s);case"co":return w(n.ordinalNumber(e,{unit:"day"}),s);case"ccc":return n.day(e,{width:"abbreviated",context:"standalone"})||n.day(e,{width:"short",context:"standalone"})||n.day(e,{width:"narrow",context:"standalone"});case"ccccc":return n.day(e,{width:"narrow",context:"standalone"});case"cccccc":return n.day(e,{width:"short",context:"standalone"})||n.day(e,{width:"narrow",context:"standalone"});default:return n.day(e,{width:"wide",context:"standalone"})||n.day(e,{width:"abbreviated",context:"standalone"})||n.day(e,{width:"short",context:"standalone"})||n.day(e,{width:"narrow",context:"standalone"})}}validate(e,t){return t>=0&&t<=6}set(e,t,n,a){return e=j(e,n,a),e.setHours(0,0,0,0),e}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"]}function Xt(r,e,t){const n=b(r,t?.in),a=yt(n,t),s=e-a;return K(n,s,t)}class Bt extends c{priority=90;parse(e,t,n){const a=s=>s===0?7:s;switch(t){case"i":case"ii":return f(t.length,e);case"io":return n.ordinalNumber(e,{unit:"day"});case"iii":return w(n.day(e,{width:"abbreviated",context:"formatting"})||n.day(e,{width:"short",context:"formatting"})||n.day(e,{width:"narrow",context:"formatting"}),a);case"iiiii":return w(n.day(e,{width:"narrow",context:"formatting"}),a);case"iiiiii":return w(n.day(e,{width:"short",context:"formatting"})||n.day(e,{width:"narrow",context:"formatting"}),a);default:return w(n.day(e,{width:"wide",context:"formatting"})||n.day(e,{width:"abbreviated",context:"formatting"})||n.day(e,{width:"short",context:"formatting"})||n.day(e,{width:"narrow",context:"formatting"}),a)}}validate(e,t){return t>=1&&t<=7}set(e,t,n){return e=Xt(e,n),e.setHours(0,0,0,0),e}incompatibleTokens=["y","Y","u","q","Q","M","L","w","d","D","E","e","c","t","T"]}class Gt extends c{priority=80;parse(e,t,n){switch(t){case"a":case"aa":case"aaa":return n.dayPeriod(e,{width:"abbreviated",context:"formatting"})||n.dayPeriod(e,{width:"narrow",context:"formatting"});case"aaaaa":return n.dayPeriod(e,{width:"narrow",context:"formatting"});default:return n.dayPeriod(e,{width:"wide",context:"formatting"})||n.dayPeriod(e,{width:"abbreviated",context:"formatting"})||n.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,t,n){return e.setHours($(n),0,0,0),e}incompatibleTokens=["b","B","H","k","t","T"]}class $t extends c{priority=80;parse(e,t,n){switch(t){case"b":case"bb":case"bbb":return n.dayPeriod(e,{width:"abbreviated",context:"formatting"})||n.dayPeriod(e,{width:"narrow",context:"formatting"});case"bbbbb":return n.dayPeriod(e,{width:"narrow",context:"formatting"});default:return n.dayPeriod(e,{width:"wide",context:"formatting"})||n.dayPeriod(e,{width:"abbreviated",context:"formatting"})||n.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,t,n){return e.setHours($(n),0,0,0),e}incompatibleTokens=["a","B","H","k","t","T"]}class jt extends c{priority=80;parse(e,t,n){switch(t){case"B":case"BB":case"BBB":return n.dayPeriod(e,{width:"abbreviated",context:"formatting"})||n.dayPeriod(e,{width:"narrow",context:"formatting"});case"BBBBB":return n.dayPeriod(e,{width:"narrow",context:"formatting"});default:return n.dayPeriod(e,{width:"wide",context:"formatting"})||n.dayPeriod(e,{width:"abbreviated",context:"formatting"})||n.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,t,n){return e.setHours($(n),0,0,0),e}incompatibleTokens=["a","b","t","T"]}class Vt extends c{priority=70;parse(e,t,n){switch(t){case"h":return l(m.hour12h,e);case"ho":return n.ordinalNumber(e,{unit:"hour"});default:return f(t.length,e)}}validate(e,t){return t>=1&&t<=12}set(e,t,n){const a=e.getHours()>=12;return a&&n<12?e.setHours(n+12,0,0,0):!a&&n===12?e.setHours(0,0,0,0):e.setHours(n,0,0,0),e}incompatibleTokens=["H","K","k","t","T"]}class zt extends c{priority=70;parse(e,t,n){switch(t){case"H":return l(m.hour23h,e);case"Ho":return n.ordinalNumber(e,{unit:"hour"});default:return f(t.length,e)}}validate(e,t){return t>=0&&t<=23}set(e,t,n){return e.setHours(n,0,0,0),e}incompatibleTokens=["a","b","h","K","k","t","T"]}class Jt extends c{priority=70;parse(e,t,n){switch(t){case"K":return l(m.hour11h,e);case"Ko":return n.ordinalNumber(e,{unit:"hour"});default:return f(t.length,e)}}validate(e,t){return t>=0&&t<=11}set(e,t,n){return e.getHours()>=12&&n<12?e.setHours(n+12,0,0,0):e.setHours(n,0,0,0),e}incompatibleTokens=["h","H","k","t","T"]}class Zt extends c{priority=70;parse(e,t,n){switch(t){case"k":return l(m.hour24h,e);case"ko":return n.ordinalNumber(e,{unit:"hour"});default:return f(t.length,e)}}validate(e,t){return t>=1&&t<=24}set(e,t,n){const a=n<=24?n%24:n;return e.setHours(a,0,0,0),e}incompatibleTokens=["a","b","h","H","K","t","T"]}class Kt extends c{priority=60;parse(e,t,n){switch(t){case"m":return l(m.minute,e);case"mo":return n.ordinalNumber(e,{unit:"minute"});default:return f(t.length,e)}}validate(e,t){return t>=0&&t<=59}set(e,t,n){return e.setMinutes(n,0,0),e}incompatibleTokens=["t","T"]}class Ut extends c{priority=50;parse(e,t,n){switch(t){case"s":return l(m.second,e);case"so":return n.ordinalNumber(e,{unit:"second"});default:return f(t.length,e)}}validate(e,t){return t>=0&&t<=59}set(e,t,n){return e.setSeconds(n,0),e}incompatibleTokens=["t","T"]}class St extends c{priority=30;parse(e,t){const n=a=>Math.trunc(a*Math.pow(10,-t.length+3));return w(f(t.length,e),n)}set(e,t,n){return e.setMilliseconds(n),e}incompatibleTokens=["t","T"]}class en extends c{priority=10;parse(e,t){switch(t){case"X":return D(P.basicOptionalMinutes,e);case"XX":return D(P.basic,e);case"XXXX":return D(P.basicOptionalSeconds,e);case"XXXXX":return D(P.extendedOptionalSeconds,e);default:return D(P.extended,e)}}set(e,t,n){return t.timestampIsSet?e:x(e,e.getTime()-C(e)-n)}incompatibleTokens=["t","T","x"]}class tn extends c{priority=10;parse(e,t){switch(t){case"x":return D(P.basicOptionalMinutes,e);case"xx":return D(P.basic,e);case"xxxx":return D(P.basicOptionalSeconds,e);case"xxxxx":return D(P.extendedOptionalSeconds,e);default:return D(P.extended,e)}}set(e,t,n){return t.timestampIsSet?e:x(e,e.getTime()-C(e)-n)}incompatibleTokens=["t","T","X"]}class nn extends c{priority=40;parse(e){return fe(e)}set(e,t,n){return[x(e,n*1e3),{timestampIsSet:!0}]}incompatibleTokens="*"}class rn extends c{priority=20;parse(e){return fe(e)}set(e,t,n){return[x(e,n),{timestampIsSet:!0}]}incompatibleTokens="*"}const an={G:new Tt,y:new Pt,Y:new Dt,R:new kt,u:new Ot,Q:new vt,q:new Yt,M:new Et,L:new Wt,w:new Ht,I:new Nt,d:new Lt,D:new Ct,E:new Qt,e:new At,c:new Rt,i:new Bt,a:new Gt,b:new $t,B:new jt,h:new Vt,H:new zt,K:new Jt,k:new Zt,m:new Kt,s:new Ut,S:new St,X:new en,x:new tn,t:new nn,T:new rn},sn=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,on=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,un=/^'([^]*?)'?$/,cn=/''/g,dn=/\S/,ln=/[a-zA-Z]/;function V(r,e,t,n){const a=()=>x(t,NaN),s=wt(),o=s.locale??ee,i=s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,g=s.weekStartsOn??s.locale?.options?.weekStartsOn??0;if(!e)return r?a():b(t,n?.in);const M={firstWeekContainsDate:i,weekStartsOn:g,locale:o},y=[new Mt(n?.in,t)],p=e.match(on).map(u=>{const h=u[0];if(h in X){const k=X[h];return k(u,o.formatLong)}return u}).join("").match(sn),E=[];for(let u of p){ce(u)&&B(u,e,r),ue(u)&&B(u,e,r);const h=u[0],k=an[h];if(k){const{incompatibleTokens:ye}=k;if(Array.isArray(ye)){const be=E.find(ge=>ye.includes(ge.token)||ge.token===h);if(be)throw new RangeError(`The format string mustn't contain \`${be.fullToken}\` and \`${u}\` at the same time`)}else if(k.incompatibleTokens==="*"&&E.length>0)throw new RangeError(`The format string mustn't contain \`${u}\` and any other token at the same time`);E.push({token:h,fullToken:u});const J=k.run(r,u,o.match,M);if(!J)return a();y.push(J.setter),r=J.rest}else{if(h.match(ln))throw new RangeError("Format string contains an unescaped latin alphabet character `"+h+"`");if(u==="''"?u="'":h==="'"&&(u=fn(u)),r.indexOf(u)===0)r=r.slice(u.length);else return a()}}if(r.length>0&&dn.test(r))return a();const kn=y.map(u=>u.priority).sort((u,h)=>h-u).filter((u,h,k)=>k.indexOf(u)===h).map(u=>y.filter(h=>h.priority===u).sort((h,k)=>k.subPriority-h.subPriority)).map(u=>u[0]);let q=b(t,n?.in);if(isNaN(+q))return a();const we={};for(const u of kn){if(!u.validate(q,M))return a();const h=u.set(q,we,M);Array.isArray(h)?(q=h[0],Object.assign(we,h[1])):q=h}return q}function fn(r){return r.match(un)[1].replace(cn,"'")}function hn(r){return Math.trunc(r*6e4)}function mn(r){return r*1e3}function wn(r){if(r)return V(r,"HH:mm:ss.SSS",new Date)}function yn(r){if(r)return G(r,"HH:mm:ss.SSS")}function bn(r){if(r&&typeof r=="string")return V(r,"yyyy-MM-dd",new Date)}function gn(r){if(r)return G(r,"yyyy-MM-dd")}function pn(r){if(r)return V(r,"yyyy-MM-dd'T'HH:mm:ss.SSSXXX",new Date)}function xn(r){if(r)return G(r,"yyyy-MM-dd'T'HH:mm:ss.SSSXXX")}const F=r=>Number.parseInt(r??"0");function Mn(r){const e=r.match(/^(-)?(\d+)?\.?(\d{2}):(\d{2}):(\d{2})\.?(\d{3})?$/);return{sign:e?.[1],values:{days:F(e?.[2]),hours:F(e?.[3]),minutes:F(e?.[4]),seconds:F(e?.[5]),milliseconds:F(e?.[6])}}}function Tn(r){if(!r)return;const e=Mn(r),t=e.values,n=de(t.days*24),a=de(t.hours),s=hn(t.minutes),o=mn(t.seconds),i=n+a+s+o+t.milliseconds;return(e.sign==="-"?-1:1)*i}function z(r){return(r?.toFixed(0)??"0").padStart(2,"0")}function Pn(r){const e=r%1e3,t=Math.floor(r/1e3%60),n=Math.floor(r/(1e3*60)%60),a=Math.floor(r/(1e3*60*60)%24),s=Math.floor(r/(1e3*60*60*24));return{milliseconds:e,seconds:t,minutes:n,hours:a,days:s}}function Dn(r){let e="";if(!r)return;const t=r<0,n=Math.abs(r),{milliseconds:a,seconds:s,minutes:o,hours:i,days:g}=Pn(n);return t&&(e+="-"),g>0&&(e+=`${g}.`),e+=`${z(i)}:${z(o)}:${z(s)}`,a>0&&(e+=`.${a}`),e}T.fromApiDate=bn,T.fromApiDateTimeOffset=pn,T.fromApiTime=wn,T.fromApiTimeSpan=Tn,T.toApiDate=gn,T.toApiDateTimeOffset=xn,T.toApiTime=yn,T.toApiTimeSpan=Dn,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})}));