Socket
Socket
Sign inDemoInstall

temporal-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

temporal-polyfill - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

dist/common-9bc60891.mjs

7

CHANGELOG.md
v0.0.8 (2022-08-24)
-------------------
- Support environments without BigInt. See browser version matrix in README.
- Fixed TypeScript syntax error in `temporal-spec/index.d.ts` (#10)
- Fixed missing .d.ts files for environments that don't support export maps.
v0.0.7 (2022-05-06)

@@ -3,0 +10,0 @@ -------------------

2

dist/global.js

@@ -1,2 +0,2 @@

!function(){const n=1000n,t=1000000n,e=1000000000n,o=60000000000n,r=3600000000000n,i=86400000000000n,s=1e3,a=1e6,c=1e9,u=6e10,d=36e11,h=864e11,l=[1,s,a,c,u,d,h],f=864e5,m=1e3,g=[9,6,3];function y(n){return n<=6}function w(n){return n>=6}const p=M("overflow",{constrain:0,reject:1},0);function M(n,t,e){const o=function(n,t,e){return(o,r)=>{if(void 0===o){const t=r??e;if(void 0===t)throw new RangeError(`Must specify a ${n}`);return t}if(void 0===t[o])throw new RangeError(`Invalid ${n}: ${o}`);return t[o]}}(n,t,e);return(t,e)=>{const r=S(t);return o(r[n],e)}}function v(n,t,e,o){if(void 0===n)return t;if(!Number.isFinite(n))throw new RangeError("Number must be finite");n=Math.trunc(n);const r=Math.min(Math.max(n,t),e);if(r!==n&&1===o)throw new RangeError("Invalid overflowed value "+n);return r}function I(n,t){const e={};for(const o in t)void 0!==n[o]&&(e[o]=t[o](n[o]));return e}function S(n,t){if(void 0===n&&!t)return{};if(!b(n))throw TypeError("options must be an object or undefined");return n}const F=/object|function/;function b(n){return null!==n&&F.test(typeof n)}const N=M("roundingMode",{halfExpand:Math.round,ceil:Math.ceil,trunc:Math.trunc,floor:Math.floor});function T(){const n=new WeakMap;return[n.get.bind(n),n.set.bind(n)]}function O(n,t){Object.defineProperties(n.prototype,D(t,(n=>({get:n}))))}function D(n,t){const e={};for(const o in n)e[o]=t(n[o],o);return e}function Y(n,t,e){const o={};for(const r of t)o[r]=e(n[r]);return o}function E(n,t){const e={};return n.forEach(((n,o)=>{e[n]=t(n,o)})),e}const Z=["nanosecond","microsecond","millisecond","second","minute","hour"],C=[...Z,"day","week","month","year"],U=C.map((n=>n+"s")),P=E(C,((n,t)=>t)),R=E(U,((n,t)=>t));function B(n,t,e,o){let r;if(void 0===n){if(void 0===t)throw new RangeError("Unit is required");r=t}else if(r=P[n]??R[n],void 0===r||r<e||r>o)throw new RangeError("Invalid unit "+n);return r}function k(n,t,e,o,r,i){const s=S(n),a=s.roundingIncrement??1,c=B(s.smallestUnit,e,o,r),u=N(s,i?Math.round:Math.trunc);let d=s.largestUnit;"auto"===d&&(d=void 0);const h=B(d,t=Math.max(t,c),o,r);if(c>h)throw new RangeError("Bad smallestUnit/largestUnit");if(c<6){const n=l[c+1],t=l[c]*a;if(n===t)throw new RangeError("Must not equal larger unit");if(n%t)throw new RangeError("Must divide into larger unit")}return{smallestUnit:c,largestUnit:h,roundingFunc:u,roundingIncrement:a}}function x(n,t,e,o){const r=S("string"==typeof n?{smallestUnit:n}:n,!0),i=r.roundingIncrement??1,s=B(r.smallestUnit,void 0,t,e),a=N(r,Math.round),c=l[s]*i;if(6===s){if(1!==i)throw new RangeError("When smallestUnit is days, roundingIncrement must be 1")}else{const n=o?h:l[s+1];if(!o&&n===c)throw new RangeError("Must not equal larger unit");if(n%c)throw new RangeError("Must divide into larger unit")}return{smallestUnit:s,roundingFunc:a,incNano:c}}const j=Symbol();function q(n,t,...e){return t instanceof n?t:n.from(t,...e)}class H{toJSON(){return this.toString()}}class L extends H{valueOf(){throw new Error("Cannot convert object using valueOf")}}const[$,z]=T();class A extends L{constructor(n){super(),z(this,Object.freeze(n))}getISOFields(){return $(this)}}function W(n,t){return n<t?-1:n>t?1:0}function K(n){return W(n,0)}function G(n,t,e){return e(n/t)*t}function J(n){return G(n,u,Q)}function Q(n){return Math.round(Math.abs(n))*K(n)}function V(n,t,e){const o=BigInt(t),r=n/o*o,i=Number(n-r);return r+BigInt(e(i/t))*o}function X(n,t){return(n%t+t)%t}const _=U.concat("sign");function nn(n){return Y(n,_,(n=>-n||0))}function tn(n,t){return en({years:t.years??n.years,months:t.months??n.months,weeks:t.weeks??n.weeks,days:t.days??n.days,hours:t.hours??n.hours,minutes:t.minutes??n.minutes,seconds:t.seconds??n.seconds,milliseconds:t.milliseconds??n.milliseconds,microseconds:t.microseconds??n.microseconds,nanoseconds:t.nanoseconds??n.nanoseconds})}function en(n){return{...n,sign:on(n)}}function on(n){let t=0;for(const e of U){if(n[e]){t=K(n[e]);break}}return t}function rn(n){let t=9;for(;t>0&&!n[U[t]];)t--;return t}const sn={isoHour:0,isoMinute:0,isoSecond:0,isoMillisecond:0,isoMicrosecond:0,isoNanosecond:0},an={hours:0,minutes:0,seconds:0,milliseconds:0,microseconds:0,nanoseconds:0};function cn(n){return{isoHour:n.hour||0,isoMinute:n.minute||0,isoSecond:n.second||0,isoMillisecond:n.millisecond||0,isoMicrosecond:n.microsecond||0,isoNanosecond:n.nanosecond||0}}function un(n){return BigInt(n.days)*i+dn(n)}function dn(i){return BigInt(i.hours)*r+BigInt(i.minutes)*o+BigInt(i.seconds)*e+BigInt(i.milliseconds)*t+BigInt(i.microseconds)*n+BigInt(i.nanoseconds)}function hn(n){return n.isoHour*d+n.isoMinute*u+n.isoSecond*c+n.isoMillisecond*a+n.isoMicrosecond*s+n.isoNanosecond}function ln(s,a){let c,u=0,d=0,h=0,l=0,f=0,m=0;switch(a){case 6:c=s/i,u=Number(c),s-=c*i;case 5:c=s/r,d=Number(c),s-=c*r;case 4:c=s/o,h=Number(c),s-=c*o;case 3:c=s/e,l=Number(c),s-=c*e;case 2:c=s/t,f=Number(c),s-=c*t;case 1:c=s/n,m=Number(c),s-=c*n}return en({years:0,months:0,weeks:0,days:u,hours:d,minutes:h,seconds:l,milliseconds:f,microseconds:m,nanoseconds:Number(s)})}function fn(n){const t=Math.floor(n/h);n-=t*h;const e=Math.floor(n/d);n-=e*d;const o=Math.floor(n/u);n-=o*u;const r=Math.floor(n/c);n-=r*c;const i=Math.floor(n/a);n-=i*a;const l=Math.floor(n/s);return[{isoHour:e,isoMinute:o,isoSecond:r,isoMillisecond:i,isoMicrosecond:l,isoNanosecond:n-=l*s},t]}function mn(n,t){return String(n).padStart(t,"0")}function gn(n){return n<0?"-":"+"}const yn={gregory:{bce:-1,ce:0},ethioaa:{era0:0},ethiopic:{era0:0,era1:5500},coptic:{era0:-1,era1:0},roc:{beforeroc:-1,minguo:0},buddhist:{be:0},islamic:{ah:0},indian:{saka:0},persian:{ap:0},japanese:{bce:-1,ce:0,meiji:1867,taisho:1911,showa:1925,heisei:1988,reiwa:2018}};class wn{constructor(n){this.id=n}monthCode(n,t){return"M"+mn(n,2)}convertMonthCode(n,t){const e=/L$/.test(n),o=parseInt(n.substr(1));if(e)throw new RangeError("Calendar system doesnt support leap months");return[o,!1]}}function pn(n,t,e,o){let r=yn[Mn(n)]?.[e];if(void 0===r){if(!o)throw new Error("Unkown era "+e);r=0}return(r+t)*(K(r)||1)}function Mn(n){return n.split("-")[0]}class vn extends wn{computeFields(n){const t=Dn(n);return{era:void 0,eraYear:void 0,year:t.isoYear,month:t.isoMonth,day:t.isoDay}}epochMilliseconds(n,t,e){return Tn(n,t,e)}daysInMonth(n,t){return 2===t?this.inLeapYear(n)?29:28:4===t||6===t||9===t||11===t?30:31}monthsInYear(){return 12}inLeapYear(n){return n%4==0&&(n%100!=0||n%400==0)}guessYearForMonthDay(){return Fn}normalizeISOYearForMonthDay(){return Fn}}const In="iso8601",Sn=new vn(In),Fn=1972;function bn(n){return Nn(n.isoYear,n.isoMonth,n.isoDay,n.isoHour,n.isoMinute,n.isoSecond,n.isoMillisecond,n.isoMicrosecond,n.isoNanosecond)}function Nn(e,o,r,i,s,a,c,u,d){return BigInt(Tn(e,o,r,i,s,a,c))*t+BigInt(u??0)*n+BigInt(d??0)}function Tn(n,t,e,o,r,i,s){const a=K(n);let c,u,d=0;const h=n>=0&&n<1e3,l=h?n+1200:n;for(;d<31;d++){c=e-a*d;const n=Date.UTC(l,t-1,c,o??0,r??0,i??0,s??0);if(!Pn(n)){u=n+a*d*f;break}}return(void 0===u||c<1||c>Sn.daysInMonth(n,t))&&Rn(),h&&(u=new Date(u).setUTCFullYear(n)),u}function On(n){let e=n/t,o=Number(n-e*t);o<0&&(o+=a,e-=1n);const r=Math.floor(o/s);return o-=r*s,{...Dn(Number(e)),isoMicrosecond:r,isoNanosecond:o}}function Dn(n){const[t,e]=Un(n);return{isoYear:t.getUTCFullYear(),isoMonth:t.getUTCMonth()+1,isoDay:t.getUTCDate()+e,isoHour:t.getUTCHours(),isoMinute:t.getUTCMinutes(),isoSecond:t.getUTCSeconds(),isoMillisecond:t.getUTCMilliseconds()}}function Yn(n){return n.epochNanoseconds??bn(n.getISOFields())}function En(n){return Math.floor(Tn(n,1,1)/m)}function Zn(n){return Un(Number(n/t))[0].getUTCFullYear()}function Cn(n,t,e){const[o,r]=Un(Tn(n,t,e));return X(o.getUTCDay()+r,7)||7}function Un(n){const t=K(n);let e,o=0;for(;o<31;o++){const r=new Date(n-t*o*f);if(!Pn(r)){e=r;break}}return void 0===e&&Rn(),[e,t*o]}function Pn(n){return isNaN(n.valueOf())}function Rn(){throw new RangeError("Date outside of supported range")}function Bn(n,t){return Math.round((t-n)/f)}function kn(n,t){return n+t*f}function xn(n,t){return!jn(n,t)&&n.calendar.toString()===t.calendar.toString()}function jn(n,t){return W(bn(n.getISOFields()),bn(t.getISOFields()))}function qn(n,t){return W(hn(n.getISOFields()),hn(t.getISOFields()))}function Hn(n,t){return W(n.year,t.year)||W(n.month,t.month)||W(n.day,t.day)}function Ln(n,t){return W(n.epochNanoseconds,t.epochNanoseconds)}function $n(n,t,e,o,r){return[n=Number(n),t=v(t,1,o.monthsInYear(n),r),e=v(e,1,o.daysInMonth(n,t),r)]}function zn(n,t){const[e,o,r]=$n(n.isoYear,n.isoMonth,n.isoDay,Sn,t);return{isoYear:e,isoMonth:o,isoDay:r}}function An(n,t){return{...zn(n,t),...Wn(n,t)}}function Wn({isoHour:n,isoMinute:t,isoSecond:e,isoMillisecond:o,isoMicrosecond:r,isoNanosecond:i},s){return{isoHour:n=v(n,0,23,s),isoMinute:t=v(t,0,59,s),isoSecond:e=v(e,0,59,s),isoMillisecond:o=v(o,0,999,s),isoMicrosecond:r=v(r,0,999,s),isoNanosecond:i=v(i,0,999,s)}}const Kn={era:String,eraYear:Number,year:Number,month:Number,monthCode:String},Gn={...Kn,day:Number},Jn={hour:Number,minute:Number,second:Number,millisecond:Number,microsecond:Number,nanosecond:Number},Qn={era:String,eraYear:Number,year:Number,month:Number,monthCode:String,day:Number},Vn=E(U,(()=>Number));class Xn extends vn{computeFields(n){const t=super.computeFields(n),{year:e}=t;return{...t,era:e<1?"bce":"ce",eraYear:e<1?-(e-1):e}}}const _n=M("calendarName",{auto:0,never:1,always:2},0),nt=M("disambiguation",{compatible:0,earlier:1,later:2,reject:3},0);function tt(n,t=4){const e=S(n),o=e.smallestUnit,r=e.fractionalSecondDigits;let i,s=0,a=1;return void 0!==o?(s=B(o,void 0,0,t),a=l[s],i=g[s]||0):void 0!==r&&"auto"!==r&&(i=v(r,0,9,1),a=Math.pow(10,9-i)),{smallestUnit:s,fractionalSecondDigits:i,roundingFunc:N(n,Math.trunc),incNano:a}}const et=M("timeZoneName",{auto:0,never:1},0);function ot(n,t){return rt(n)+"T"+st(n,t)}function rt(n){return it(n)+"-"+mn(n.isoDay,2)}function it(n){const{isoYear:t}=n;return(t<1e3||t>9999?gn(t)+mn(Math.abs(t),6):mn(t,4))+"-"+mn(n.isoMonth,2)}function st(n,t){const e=[mn(n.isoHour,2)];return t.smallestUnit<=4&&(e.push(mn(n.isoMinute,2)),t.smallestUnit<=3&&e.push(mn(n.isoSecond,2)+dt(n.isoMillisecond,n.isoMicrosecond,n.isoNanosecond,t.fractionalSecondDigits)[0])),e.join(":")}function at(n){const[t,e]=fn(Math.abs(n)),o=dt(t.isoMillisecond,t.isoMicrosecond,t.isoNanosecond,void 0)[0];return gn(n)+mn(t.isoHour+24*e,2)+":"+mn(t.isoMinute,2)+(t.isoSecond||o?":"+mn(t.isoSecond,2)+o:"")}function ct(n,t){return n&&(2===t||1!==t&&n!==In)?`[u-ca=${n}]`:""}function ut(n){return n.map((([n,t,e])=>e||n?(n<BigInt(0)?-n:n)+t:"")).join("")}function dt(o,r,i,s,a,c){let u=BigInt(i)+BigInt(r)*n+BigInt(o)*t;a&&(u=V(u,void 0===s?l[c]:Math.pow(10,9-s),a));const d=u<0?-u:u,h=d/e;let f=mn(Number(d-h*e),9);return f=void 0===s?f.replace(/0+$/,""):f.substr(0,s),[f?"."+f:"",Number(h)*(u<0?-1:1)]}function ht(o){O(o,{epochMicroseconds(){return this.epochNanoseconds/n},epochMilliseconds(){return Number(this.epochNanoseconds/t)},epochSeconds(){return Number(this.epochNanoseconds/e)}})}const lt={calendar:"calendar"};for(const n of C)lt[n]="iso"+((ft=n).charAt(0).toUpperCase()+ft.slice(1));var ft;function mt(n,t=[]){O(n,E(t.concat("calendar"),(n=>function(){return this.getISOFields()[lt[n]]})))}const gt=["era","eraYear","year","month","monthCode","daysInMonth","daysInYear","monthsInYear","inLeapYear"],yt=[...gt,"day","dayOfWeek","dayOfYear","weekOfYear","daysInWeek"];function wt(n,t){O(n,E(t,(n=>function(){const t=this.calendar[n](this);return Object.defineProperty(this,n,{value:t}),t})))}function pt(n,t){(n.prototype||n)[Symbol.toStringTag]="Temporal."+t}const Mt=M("offset",{prefer:0,use:1,ignore:2,reject:3});function vt(n,t,e=0){const o=n.getPossibleInstantsFor(t);if(1===o.length)return o[0];if(3===e)throw new RangeError("Ambiguous offset");if(o.length)return o[2===e?1:0];{const o=function(n,t){const e=Yn(t),o=n.getOffsetNanosecondsFor(new Cr(e+-1n*i)),r=n.getOffsetNanosecondsFor(new Cr(e+1n*i));return Number(r-o)}(n,t),r=n.getPossibleInstantsFor(t.add({nanoseconds:o*(1===e?-1:1)}));return r[1===e?0:r.length-1]}}function It({year:n,month:t,day:e},o,r,i){n+=o;const s=v(t,1,r.monthsInYear(n),i);let a=t===s?e:1;return a=v(a,1,r.daysInMonth(n,s),i),{year:n,month:s,day:a}}function St({year:n,month:t,day:e},o,r,i){if(o){if(t+=o,o<0)for(;t<1;)t+=r.monthsInYear(--n);else{let e;for(;t>(e=r.monthsInYear(n));)t-=e,n++}e=v(e,1,r.daysInMonth(n,t),i)}return{year:n,month:t,day:e}}function Ft({isoYear:n,isoMonth:t,isoDay:e},o){if(o){let r=Tn(n,t,e);r=kn(r,o),({isoYear:n,isoMonth:t,isoDay:e}=Dn(r))}return{isoYear:n,isoMonth:t,isoDay:e}}function bt(n,t){if(rn(t)>=6)throw new RangeError("Duration cant have units >= days");return n+dn(t)}function Nt(n,t,e=3,o){const{offsetNanoseconds:r,timeZone:i,Z:s}=n;if(void 0!==r&&2!==e){if(1===e||s)return bn(n)-BigInt(r);{const o=Tt(n,r,i,t);if(void 0!==o)return o;if(3===e)throw new RangeError("Mismatching offset/timezone")}}return vt(i,Ho(n),nt(o)).epochNanoseconds}function Tt(n,t,e,o){const r=e.getPossibleInstantsFor(Ho(n)),i=bn(n),s=o?J(t):t;for(const n of r){const t=n.epochNanoseconds,e=Number(i-t);if((o?J(e):e)===s)return t}}function Ot(n){const{timeZone:t}=n,e={...n,...sn,calendar:new gr("iso8601")},o={...Ft(e,1),...sn,calendar:new gr("iso8601")},r=vt(t,Ho(e)).epochNanoseconds,i=vt(t,Ho(o)).epochNanoseconds;return Number(i-r)}const Dt="([+-]\\d{6}|\\d{4})-?(\\d{2})",Yt="(\\d{2})(:?(\\d{2})(:?(\\d{2})([.,](\\d{1,9}))?)?)?",Et="([+-])"+Yt,Zt="(Z|"+Et+")?(\\[([^=\\]]+)\\])?(\\[u-ca=([^\\]]+)\\])?",Ct=jt(Dt+Zt),Ut=jt("(--)?(\\d{2})-?(\\d{2})"+Zt),Pt=jt("([+-]\\d{6}|\\d{4})-?(\\d{2})-?(\\d{2})([T ](\\d{2})(:?(\\d{2})(:?(\\d{2})([.,](\\d{1,9}))?)?)?)?"+Zt),Rt=jt("T?"+Yt+Zt),Bt=jt(Et),kt=/^([-+])?P(\d+Y)?(\d+M)?(\d+W)?(\d+D)?(T((\d+)([.,](\d{1,9}))?H)?((\d+)([.,](\d{1,9}))?M)?((\d+)([.,](\d{1,9}))?S)?)?$/i,xt=/\u2212/g;function jt(n){return new RegExp(`^${n}$`,"i")}function qt(n){return n.replace(xt,"-")}function Ht(n){const t=Wt(n);if(!t)throw re("dateTime",n);return t}function Lt(n){const t=Kt(n);if(!t)throw re("dateTime",n);return t}function $t(n){const t=Qt(n);if(void 0===t)throw re("timeZone",n);return t}function zt(n){let t=function(n){const t=Rt.exec(qt(n));if(t)return Xt(t.slice(1))}(n);if(void 0!==t){if("T"!==n.charAt(0)){const e=Gt(n)||Jt(n);e&&function(n){try{return zn(n,1),!0}catch(n){return!1}}(e)&&(t=void 0)}}else t=Kt(n,!0);if(void 0===t)throw re("time",n);return t}const At=/^Z$/i;function Wt(n){const t=Pt.exec(qt(n));if(t)return function(n){const t=n[11];let e,o=!1;t&&(o=At.test(t),e=o?0:_t(n.slice(12)));return{...Vt(n),timeZone:n[21],offsetNanoseconds:e,Z:o}}(t.slice(1))}function Kt(n,t,e){const o=Pt.exec(qt(n));if(o&&(e||!At.test(o[12]))&&(!t||o[4]))return Vt(o.slice(1))}function Gt(n){const t=Ct.exec(qt(n));if(t)return{calendar:(e=t.slice(1))[14],isoYear:ee(e[0]),isoMonth:ee(e[1]),isoDay:1};var e}function Jt(n){const t=Ut.exec(qt(n));if(t)return{calendar:(e=t.slice(1))[15],isoYear:Fn,isoMonth:ee(e[1]),isoDay:ee(e[2])};var e}function Qt(n){const t=Bt.exec(qt(n));if(t)return _t(t.slice(1))}function Vt(n){return{calendar:n[23],isoYear:ee(n[0]),isoMonth:ee(n[1]),isoDay:ee(n[2]),...Xt(n.slice(4))}}function Xt(n){const t=te(n[4]);return{...fn(ne(n[6]||""))[0],isoHour:te(n[0]),isoMinute:te(n[2]),isoSecond:60===t?59:t}}function _t(n){return("+"===n[0]?1:-1)*function(n){return te(n[0])*d+te(n[2])*u+te(n[4])*c+ne(n[6]||"")}(n.slice(1))}function ne(n){return parseInt(n.padEnd(9,"0"))}function te(n){return parseInt(n||"0")}function ee(n){return parseInt(n||"1")}function oe(n){return void 0===n?void 0:parseInt(n)}function re(n,t){throw new RangeError(`Cannot parse ${n} '${t}'`)}function ie(n){return{...n,calendar:void 0===n.calendar?yr():new gr(n.calendar)}}function se(n){return{...ie(n),timeZone:new Ie(n.timeZone)}}class ae{constructor(n){this.id=n}}class ce extends ae{constructor(n,t){super(n),this.offsetNano=t}getPossibleOffsets(){return[this.offsetNano]}getOffset(){return this.offsetNano}getTransition(){}}function ue(n,t){const e={},o=n.formatToParts(t);for(const n of o)e[n.type]=n.value;return e}const de={bc:"bce",ad:"ce"};function he(n){return n=n.toLowerCase().normalize("NFD").replace(/[^a-z0-9]/g,""),de[n]||n}const le=Intl.DateTimeFormat;function fe(n){return[].concat(n||[])}const me={"Pacific/Apia":{2011:[[1301752800000000000n,-36e12,-396e11],[1316872800000000000n,-396e11,-36e12],[1325239200000000000n,-36e12,504e11]]}},ge=(new Date).getUTCFullYear()+10,ye=[182,91,273];class we extends ae{format;yearEndOffsets;transitionsInYear;constructor(n){const t=new le("en-GB",{era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZone:n});super(t.resolvedOptions().timeZone),this.format=t,this.yearEndOffsets={},this.transitionsInYear=me[n]||{}}getPossibleOffsets(n){let t;const e=[this.getTransition(n,-1),this.getTransition(n-1n,1)].filter(Boolean);for(const o of e){const[e,r,i]=o,s=n-BigInt(r),a=n-BigInt(i);if(e>s&&e>a)return[r];if(!(e<=s&&e<=a))return r<i?[]:[r,i];t=i}return void 0!==t?[t]:[this.getYearEndOffsetSec(Zn(n))*c]}getOffset(n){return this.getOffsetForEpochSecs(Number(n/e))*c}getOffsetForEpochSecs(n){const t=ue(this.format,n*m);let e=parseInt(t.year);"bce"===he(t.era)&&(e=-(e-1));const o=Tn(e,parseInt(t.month),parseInt(t.day),parseInt(t.hour),parseInt(t.minute),parseInt(t.second));return Math.floor(o/m)-n}getTransition(n,t){let e=Zn(n);if(e>ge){const o=this.getTransitionFrom(e,e+t,t,n);if(o||t>0)return o;e=ge}return this.getTransitionFrom(Math.max(e,1847),t<0?1846:ge,t,n)}getTransitionFrom(n,t,e,o){for(;n!==t;n+=e){let t=this.getTransitionsInYear(n);e<0&&(t=t.slice().reverse());for(const n of t)if(W(n[0],o)===e)return n}}getYearEndOffsetSec(n){const{yearEndOffsets:t}=this;return t[n]||(t[n]=this.getOffsetForEpochSecs(En(n+1)-1))}getTransitionsInYear(n){const{transitionsInYear:t}=this;return t[n]||(t[n]=this.computeTransitionsInYear(n))}computeTransitionsInYear(n){const t=this.getYearEndOffsetSec(n-1),e=this.getYearEndOffsetSec(n),o=En(n)-1,r=En(n+1)-1;if(t!==e)return[this.searchTransition(o,r,t,e)];const i=this.searchIsland(t,o);return void 0!==i?[this.searchTransition(o,i[0],t,i[1]),this.searchTransition(i[0],r,i[1],e)]:[]}searchTransition(n,t,o,r){for(;t-n>1;){const e=Math.floor(n+(t-n)/2);this.getOffsetForEpochSecs(e)===o?n=e:t=e}return[BigInt(t)*e,o*c,r*c]}searchIsland(n,t){for(const e of ye){const o=t+86400*e,r=this.getOffsetForEpochSecs(o);if(r!==n)return[o,r]}}}const pe={UTC:new ce("UTC",0)};const[Me,ve]=T();class Ie extends H{constructor(n){if(!n)throw new RangeError("Invalid timezone ID");super(),ve(this,function(n){const t=(n=String(n)).toLocaleUpperCase();if(pe[t])return pe[t];const e=Qt(n);if(void 0!==e){if(Math.abs(e)>h)throw new RangeError("Offset out of bounds");return new ce(at(e),e)}return pe[t]=new we(n)}(n))}static from(n){if(b(n))return function(n){const t=n.timeZone;if(void 0===t)return n;if(b(t)&&void 0===t.timeZone)return t;return new Ie(t)}(n);const t=Wt(String(n));if(t){if(t.timeZone){const n=se(t);return function(n){const{offsetNanoseconds:t,timeZone:e,Z:o}=n;if(void 0!==t&&!o&&void 0===Tt(n,t,e,!0))throw new RangeError("Mismatching offset/timezone")}(n),n.timeZone}if(t.Z)return new Ie("UTC");if(void 0!==t.offsetNanoseconds)return new Ie(at(t.offsetNanoseconds))}return new Ie(String(n))}get id(){return this.toString()}getOffsetStringFor(n){return at(this.getOffsetNanosecondsFor(n))}getOffsetNanosecondsFor(n){const t=q(Cr,n);return Me(this).getOffset(t.epochNanoseconds)}getPlainDateTimeFor(n,t=yr()){const e=q(Cr,n);return Ho({...On(e.epochNanoseconds+BigInt(this.getOffsetNanosecondsFor(e))),calendar:q(gr,t)})}getInstantFor(n,t){return vt(this,q(qo,n),nt(t))}getPossibleInstantsFor(n){const t=bn(q(qo,n).getISOFields());return Me(this).getPossibleOffsets(t).map((n=>new Cr(t-BigInt(n))))}getPreviousTransition(n){const t=q(Cr,n),e=Me(this).getTransition(t.epochNanoseconds,-1);return e?new Cr(e[0]):null}getNextTransition(n){const t=q(Cr,n),e=Me(this).getTransition(t.epochNanoseconds,1);return e?new Cr(e[0]):null}toString(){return Me(this).id}}function Se(n){if(void 0===n.timeZone)throw new TypeError("Must specify timeZone");return q(Ie,n.timeZone)}pt(Ie,"TimeZone");const Fe=Ae((function(n,t,e){const o=Be(n,t,e);if(o)return{...o,timeZone:Se(n),offsetNanoseconds:void 0!==n.offset?$t(String(n.offset)):void 0}})),be=Ae(Be),Ne=Ae(ke),Te=Ae((function(n,t){const e=Mr(n),o=Le(n,Kn,e);if(We(o))return e.yearMonthFromFields(o,t)})),Oe=Ae((function(n,t){const e=Mr(n),o=Le(n,Qn,e);if(We(o))return void 0===n.year&&void 0===n.calendar&&(o.year=Fn),e.monthDayFromFields(o,t)})),De=Ae(xe),Ye=Ae((function(n,t,e,o){const r=je(n,t,e,o),i=void 0!==t.offset;if(r||i)return{...r||n.getISOFields(),timeZone:n.timeZone,offsetNanoseconds:i?$t(String(t.offset)):n.offsetNanoseconds}}),!0),Ee=Ae(je,!0),Ze=Ae(qe,!0),Ce=Ae((function(n,t,e){const o=n.calendar;if(We(Le(t,Kn,o))){const r=ze(n,t,Kn,o);return o.yearMonthFromFields(r,e)}}),!0),Ue=Ae((function(n,t,e){const o=n.calendar;if(We(Le(t,Qn,o))){const r=ze(n,t,Qn,o);return o.monthDayFromFields(r,e)}}),!0),Pe=Ae(He,!0),Re=Ae((function(n){const t=I(n,Vn);if(We(t))return t}));function Be(n,t,e){const o=ke(n,e),r=xe(n,t);if(o)return{...o.getISOFields(),...r||sn}}function ke(n,t){const e=Mr(n),o=Le(n,Gn,e);if(We(o))return e.dateFromFields(o,t)}function xe(n,t){const e=I(n,Jn);if(We(e))return Wn(cn(e),t)}function je(n,t,e,o){const r=qe(n,t,o),i=He(n,t,e);if(r||i)return{...n.getISOFields(),...r?r.getISOFields():{},...i}}function qe(n,t,e){const o=n.calendar,r=Le(t,Gn,o);if(We(r)){const t=ze(n,r,Gn,o);return o.dateFromFields(t,e)}}function He(n,t,e){const o=I(t,Jn);if(We(o)){return Wn(cn((r=n,i=o,D(Jn,((n,t)=>i[t]??r[t])))),e)}var r,i}function Le(n,t,e){let o=Object.keys(t);return o=e.fields?Array.prototype.slice.call(e.fields(o)):Object.keys($e(e,o)),$e(n,o)}function $e(n,t){const e={};for(const o of t)void 0!==n[o]&&(e[o]=n[o]);return e}function ze(n,t,e,o){const r=Le(n,e,o);return o.mergeFields?o.mergeFields(r,t):wr(r,t)}function Ae(n,t){return(...e)=>{if(t){const n=e[1];if(!b(n))throw new TypeError("must be object-like");if(void 0!==n.calendar)throw new TypeError("calendar not allowed");if(void 0!==n.timeZone)throw new TypeError("timeZone not allowed")}const o=n(...e);if(!o)throw new TypeError("No valid fields");return o}}function We(n){return Object.keys(n).length>0}function Ke(n,t){const e=bn(n);Ge(e),ur(e,t)}function Ge(n){(n<-8640000086399999999999n||n>8640000086399999999999n)&&Rn()}function Je(n,t){const e=Xe(hn(n),t),[o,r]=fn(e);return{...Ft(n,r),...o}}function Qe(n,t){const e=Xe(hn(n),t),[o]=fn(e);return o}function Ve(n,t){const[e,o]=function(n){const t=On(n);return[Nn(t.isoYear,t.isoMonth,t.isoDay),hn(t)]}(n),r=Xe(o,t);return e+BigInt(r)}function Xe(n,t){return G(n,t.incNano,t.roundingFunc)}function _e(n,t,e){return(o,r)=>{const i=io(n,r)?{}:{...n,...t};return{buildKey:ro(o,r,!1),buildFormat:function(n,t){return new le(o,{calendar:n,timeZone:t||void 0,...i,...r,...e})},buildEpochMilli:no}}}function no(n){return n.epochMilliseconds}function to(n,t,e){return(o,r)=>{const i=io(n,r)?{}:n;return{buildKey:ro(o,r,e),buildFormat:function(n,e){return new le(o,{calendar:n,...i,...r,...t,timeZone:e,timeZoneName:void 0})},buildEpochMilli:void 0!==r.timeZone?eo.bind(null,new Ie(r.timeZone)):oo}}}function eo(n,t){const e=Ho({...sn,...t.getISOFields()});return n.getInstantFor(e).epochMilliseconds}function oo(n){return Tn((t=n.getISOFields()).isoYear,t.isoMonth,t.isoDay,t.isoHour,t.isoMinute,t.isoSecond,t.isoMillisecond);var t}function ro(n,t,e){const o=t.calendar??function(n){for(const t of n){const n=t.match(/-u-ca-(.*)$/);if(n)return n[1]}return}(n),r=t.timeZone;return function(n,t){const i=n.calendar?.id,s=n.timeZone?.id;if(t){if(t.calendar?.id!==i)throw new RangeError("Mismatching calendar");if(t.timeZone?.id!==s)throw new RangeError("Mismatching timeZone")}if((e||i!==In)&&void 0!==i&&void 0!==o&&o!==i)throw new RangeError("Non-iso calendar mismatch");if(void 0!==s&&void 0!==r&&r!==s)throw new RangeError("Given timeZone must agree");return[o||i||In,r||s||"UTC"]}}function io(n,t){for(const e in n)if(void 0!==t[e])return!0;return!1}function so(n,t){n.prototype.toLocaleString=function(n,e){const o=t(fe(n),e||{});return o.buildFormat(...o.buildKey(this)).format(o.buildEpochMilli(this))},n.prototype[j]=t}function ao(n){return n?.[j]}function co(n){const t=function(n){const t=kt.exec(qt(n));if(t){let n,e,o,r;[n,r]=uo(t[8],t[10],5,void 0),[e,r]=uo(t[12],t[14],4,r),[o,r]=uo(t[16],t[18],3,r);const i=function(n){const t={};for(const e in n)void 0!==n[e]&&(t[e]=n[e]);return t}({years:oe(t[2]),months:oe(t[3]),weeks:oe(t[4]),days:oe(t[5]),hours:n,minutes:e,seconds:o});if(!Object.keys(i).length)throw new RangeError("Duration string must have at least one field");const s=ln(BigInt(r||0),2);i.milliseconds=s.milliseconds,i.microseconds=s.microseconds,i.nanoseconds=s.nanoseconds;let a=en(i);return"-"===t[1]&&(a=nn(a)),a}}(n);if(void 0===t)throw re("duration",n);return t}function uo(n,t,e,o){if(void 0!==n){if(void 0!==o)throw new RangeError("Partial units must be last unit");return[parseInt(n),void 0!==t?ne(t)*(l[e]/c):void 0]}if(void 0!==o){const n=Math.trunc(o/l[e]);return[n,o-n*l[e]]}return[void 0,void 0]}const ho=M("offset",{auto:0,never:1},0);class lo extends A{constructor(n=0,t=0,e=0,o=0,r=0,i=0){super({...Wn({isoHour:n,isoMinute:t,isoSecond:e,isoMillisecond:o,isoMicrosecond:r,isoNanosecond:i},1),calendar:yr()})}static from(n,t){const e=p(t);return fo(n instanceof lo?n.getISOFields():"object"==typeof n?De(n,e):zt(String(n)))}static compare(n,t){return qn(q(lo,n),q(lo,t))}with(n,t){return fo(Pe(this,n,p(t)))}add(n){return go(this,q(ko,n))}subtract(n){return go(this,nn(q(ko,n)))}until(n,t){return yo(this,q(lo,n),t)}since(n,t){return yo(q(lo,n),this,t)}round(n){const t=x(n,0,5);return fo(Qe(this.getISOFields(),t))}equals(n){return!qn(this,q(lo,n))}toString(n){const t=tt(n);return st(Qe(this.getISOFields(),t),t)}toZonedDateTime(n){const t=q(Fr,n.plainDate),e=q(Ie,n.timeZone);return No({...t.getISOFields(),...this.getISOFields(),timeZone:e})}toPlainDateTime(n){return q(Fr,n).toPlainDateTime(this)}}function fo(n){return new lo(n.isoHour,n.isoMinute,n.isoSecond,n.isoMillisecond,n.isoMicrosecond,n.isoNanosecond)}function mo(n){return q(lo,n??{hour:0})}function go(n,t){return fo(function(n,t){const e=hn(n)+Number(dn(t)),[o]=fn(e);return o}(n.getISOFields(),t))}function yo(n,t,e){const o=k(e,5,0,0,5);return xo(function(n,t,e){const o=G(hn(t)-hn(n),l[e.smallestUnit]*e.roundingIncrement,e.roundingFunc);return ln(BigInt(o),e.largestUnit)}(n.getISOFields(),t.getISOFields(),o))}pt(lo,"PlainTime"),mt(lo,Z),so(lo,(function(n,t){return{buildKey:()=>["",""],buildFormat:()=>new le(n,{hour:"numeric",minute:"2-digit",second:"2-digit",...t,timeZone:"UTC",timeZoneName:void 0,year:void 0,month:void 0,day:void 0,weekday:void 0}),buildEpochMilli:n=>Math.trunc(hn(n.getISOFields())/a)}}));const wo={day:1};class po extends A{constructor(n,t,e=yr(),o=1){const r=zn({isoYear:n,isoMonth:t,isoDay:o},1),i=q(gr,e);var s,a;s=r,a=i.toString(),ur(bn(s),a),super({...r,calendar:i})}static from(n,t){if(p(t),n instanceof po)return Mo(n.getISOFields());if("object"==typeof n)return Te(n,t);const e=function(n){const t=Gt(n)||Kt(n);if(!t)throw re("yearMonth",n);return t}(String(n));return void 0===e.calendar&&(e.isoDay=1),Mo(ie(e))}static compare(n,t){return jn(q(po,n),q(po,t))}with(n,t){return Ce(this,n,t)}add(n,t){return vo(this,q(ko,n),t)}subtract(n,t){return vo(this,nn(q(ko,n)),t)}until(n,t){return Io(this,q(po,n),!1,t)}since(n,t){return Io(this,q(po,n),!0,t)}equals(n){return!jn(this,q(po,n))}toString(n){const t=this.getISOFields(),e=t.calendar.toString(),o=_n(n);return(e===In?it(t):rt(t))+ct(e,o)}toPlainDate(n){return this.calendar.dateFromFields({year:this.year,month:this.month,day:n.day})}}function Mo(n){return new po(n.isoYear,n.isoMonth,n.calendar,n.isoDay)}function vo(n,t,e){return n.toPlainDate({day:t.sign<0?n.daysInMonth:1}).add(t,e).toPlainYearMonth()}function Io(n,t,e,o){return xo(Or(n.toPlainDate(wo),t.toPlainDate(wo),vr(n,t),e,k(o,9,8,8,9)))}pt(po,"PlainYearMonth"),mt(po),wt(po,gt),so(po,to({year:"numeric",month:"numeric"},{weekday:void 0,day:void 0,hour:void 0,minute:void 0,second:void 0},!0));const[So,Fo]=T();class bo extends A{constructor(n,t,e=yr()){const o=q(Ie,t),r=q(gr,e),[i,s]=To(n,o);Ke(i,r.toString()),super({...i,calendar:r,timeZone:o,offset:at(s)}),Fo(this,{epochNanoseconds:n,offsetNanoseconds:s})}static from(n,t){const e=Mt(t,3),o=p(t);if(n instanceof bo)return new bo(n.epochNanoseconds,n.timeZone,n.calendar);const r="object"==typeof n;return No(r?Fe(n,o,t):se(Ht(String(n))),!r,e,t)}static compare(n,t){return Ln(q(bo,n),q(bo,t))}get timeZone(){return this.getISOFields().timeZone}get epochNanoseconds(){return So(this).epochNanoseconds}get offsetNanoseconds(){return So(this).offsetNanoseconds}get offset(){return this.getISOFields().offset}with(n,t){nt(t);const e=p(t),o=Mt(t,0);return No(Ye(this,n,e,t),!1,o,t)}withPlainDate(n){const t=q(Fr,n),e=t.toPlainDateTime(this),{timeZone:o}=this,r=vt(o,e);return new bo(r.epochNanoseconds,o,Ir(this,t))}withPlainTime(n){return No({...this.getISOFields(),...void 0===n?sn:q(lo,n).getISOFields()})}withCalendar(n){return new bo(this.epochNanoseconds,this.timeZone,n)}withTimeZone(n){return new bo(this.epochNanoseconds,n,this.calendar)}add(n,t){return Oo(this,q(ko,n),t)}subtract(n,t){return Oo(this,nn(q(ko,n)),t)}until(n,t){return Yo(this,q(bo,n),!1,t)}since(n,t){return Yo(this,q(bo,n),!0,t)}round(n){return Do(this,x(n,0,6))}equals(n){return t=this,e=q(bo,n),xn(t,e)&&t.timeZone.toString()===e.timeZone.toString();var t,e}startOfDay(){return No({...this.getISOFields(),...sn,offsetNanoseconds:this.offsetNanoseconds},!1,0)}get hoursInDay(){return Ot(this.getISOFields())/d}toString(n){const t=tt(n),e=ho(n),o=et(n),r=_n(n),i=Do(this,t);return ot(i.getISOFields(),t)+(0===e?at(J(i.offsetNanoseconds)):"")+(s=this.timeZone.toString(),1!==o?`[${s}]`:"")+ct(this.calendar.toString(),r);var s}toPlainYearMonth(){return Mo(this.getISOFields())}toPlainMonthDay(){return this.calendar.monthDayFromFields(this)}toPlainDateTime(){return Ho(this.getISOFields())}toPlainDate(){return br(this.getISOFields())}toPlainTime(){return fo(this.getISOFields())}toInstant(){return new Cr(this.epochNanoseconds)}}function No(n,t,e,o){const r=Nt(n,t,e,o);return new bo(r,n.timeZone,n.calendar)}function To(n,t){const e=new Cr(n),o=t.getOffsetNanosecondsFor(e);return[On(n+BigInt(o)),o]}function Oo(n,t,e){const o=n.getISOFields(),r=function(n,t,e){const{calendar:o,timeZone:r}=n,i=o.dateAdd(br(n),tn(t,an),e);return vt(r,Ho({...n,...i.getISOFields()})).epochNanoseconds+dn(t)}(o,t,e);return new bo(r,o.timeZone,o.calendar)}function Do(n,t){const e=n.getISOFields(),o=function(n,t,e){const{calendar:o,timeZone:r}=n;let i,s,a=hn(n);return 6===e.smallestUnit?(i=sn,s=e.roundingFunc(a/Ot(n))):(a=Xe(a,e),[i,s]=fn(a)),Nt({...Ft(n,s),...i,offsetNanoseconds:t,calendar:o,timeZone:r},!1,0)}(e,n.offsetNanoseconds,t);return new bo(o,e.timeZone,e.calendar)}function Yo(n,t,e,o){const r=k(o,5,0,0,9),{largestUnit:i}=r;if(i>=6&&n.timeZone.id!==t.timeZone.id)throw new Error("Must be same timeZone");return xo(Tr(n,t,vr(n,t),e,r))}function Eo(n){if(void 0===n)return;if(b(n))return n instanceof bo||n instanceof qo?n:q(void 0!==n.timeZone?bo:qo,n);if("symbol"==typeof n)throw new TypeError("Incorrect relativeTo type");const t=Wt(String(n));if(t)return void 0!==t.timeZone?No(se(t),!0):Ho(ie(t));throw new RangeError("Invalid value of relativeTo")}function Zo(n,t,e,o){return(e instanceof Fr?function(n,t,e,o){const r=e.add(n);return[o.dateUntil(e,r,{largestUnit:C[t]}),r]}(n,Math.max(6,t),e,o):Co(n,t,e,o))[0]}function Co(n,t,e,o,r){const i=!0!==r&&t>7&&n.weeks;i&&(n=tn(n,{weeks:0}));let s=e.add(n),a=Dr(e,s,o,t);return i&&(a=tn(a,{weeks:i}),s=s.add({weeks:i})),[a,s]}function Uo(n,t,e,o){const r=U[t],{sign:i}=n;if(!i)return n;const s={};for(let e=9;e>=t;e--){const t=U[e];s[t]=n[t]}const a={[r]:i},c=e.add(s),u=c.add(a),d=Yn(c),h=Yn(u),l=Yn(o),f=Number(l-d)/Number(h-d)*i;return s[r]+=f,s}function Po(n,t,e,o,r,i){const{largestUnit:s,smallestUnit:a,roundingIncrement:c,roundingFunc:u}=i;if(!w(s)){return ln(V((Yn(e)-Yn(t))*(r?-1n:1n),l[a]*c,u),s)}let d=Uo(n,a,t,e);const h=U[a];function f(){const n=d[h];d[h]=G(n,c,u)}return u===Math.round&&f(),r&&(d=nn(d)),u!==Math.round&&f(),a>0&&(d=r?nn(Zo(nn(d),s,t,o)):Zo(d,s,t,o)),d}pt(bo,"ZonedDateTime"),mt(bo,Z),wt(bo,yt),ht(bo),so(bo,_e({year:"numeric",month:"numeric",day:"numeric",weekday:void 0,hour:"numeric",minute:"2-digit",second:"2-digit"},{timeZoneName:"short"},{}));const[Ro,Bo]=T();class ko extends L{constructor(n=0,t=0,e=0,o=0,r=0,i=0,s=0,a=0,c=0,u=0){super();const d=Re({years:n,months:t,weeks:e,days:o,hours:r,minutes:i,seconds:s,milliseconds:a,microseconds:c,nanoseconds:u});Bo(this,function(n){const t=en(n),{sign:e}=t;for(const n of U){const o=t[n],r=K(t[n]);if(r&&r!==e)throw new RangeError("All fields must be same sign");if(!Number.isInteger(o))throw new RangeError("Duration fields must be integers")}return t}(d))}static from(n){return xo("object"==typeof n?Re(n):co(n))}static compare(n,t,e){return function(n,t,e){if(void 0===e&&rn(n)<=6&&rn(t)<=6)return W(un(n),un(t));if(!e)throw new RangeError("Need relativeTo");const o=e.add(n),r=e.add(t);return void 0!==e.epochNanoseconds?Ln(o,r):jn(o,r)}(q(ko,n),q(ko,t),Eo(S(e).relativeTo))}get years(){return Ro(this).years}get months(){return Ro(this).months}get weeks(){return Ro(this).weeks}get days(){return Ro(this).days}get hours(){return Ro(this).hours}get minutes(){return Ro(this).minutes}get seconds(){return Ro(this).seconds}get milliseconds(){return Ro(this).milliseconds}get microseconds(){return Ro(this).microseconds}get nanoseconds(){return Ro(this).nanoseconds}get sign(){return Ro(this).sign}get blank(){return!this.sign}with(n){return xo({...Ro(this),...Re(n)})}negated(){return xo(nn(Ro(this)))}abs(){return xo(Y(Ro(this),_,(n=>Math.abs(n))))}add(n,t){return jo(this,q(ko,n),t)}subtract(n,t){return jo(this,nn(q(ko,n)),t)}round(n){const t="string"==typeof n?{smallestUnit:n}:n;if(!b(t))throw new TypeError("Must specify options");if(void 0===t.largestUnit&&void 0===t.smallestUnit)throw new RangeError("Must specify either largestUnit or smallestUnit");const e=k(t,rn(this),0,0,9,!0),o=Eo(t.relativeTo);return xo(function(n,t,e,o){const{largestUnit:r,smallestUnit:i,roundingIncrement:s,roundingFunc:a}=t;if(void 0===e&&rn(n)<=6&&y(r)&&y(i))return ln(V(un(n),l[i]*s,a),r);if(!e)throw new RangeError("Need relativeTo");const[c,u]=Co(n,r,e,o);return Po(c,e,u,o,!1,t)}(this,e,o,o?o.calendar:void 0))}total(n){const t=function(n){let t,e;return"string"==typeof n?e=n:(e=S(n).unit,t=n.relativeTo),{unit:B(e,void 0,0,9),relativeTo:t}}(n),e=Eo(t.relativeTo);return function(n,t,e,o){if(void 0===e&&rn(n)<=6&&y(t))return Number(un(n))/l[t];if(!e)throw new RangeError("Need relativeTo");const[r,i]=Co(n,t,e,o,!0);return Uo(r,t,e,i)[U[t]]}(this,t.unit,e,e?e.calendar:void 0)}toString(n){const t=tt(n,3);return function(n,t){const{smallestUnit:e,fractionalSecondDigits:o,roundingFunc:r}=t,{sign:i}=n,s=BigInt(n.hours),a=BigInt(n.minutes);let c=BigInt(n.seconds),u="";if(e<=3){const t=dt(n.milliseconds,n.microseconds,n.nanoseconds,o,r,e);u=t[0],c+=BigInt(t[1])}const d=void 0!==o||u||!i;return(i<0?"-":"")+"P"+ut([[BigInt(n.years),"Y"],[BigInt(n.months),"M"],[BigInt(n.weeks),"W"],[BigInt(n.days),"D"]])+(s||a||c||d?"T"+ut([[s,"H"],[a,"M"],[e<=3?c:BigInt(0),u+"S",d]]):"")}(Ro(this),t)}toLocaleString(n,t){return this.toString()}}function xo(n){return new ko(n.years,n.months,n.weeks,n.days,n.hours,n.minutes,n.seconds,n.milliseconds,n.microseconds,n.nanoseconds)}function jo(n,t,e){const o=Eo(S(e).relativeTo);return xo(function(n,t,e,o){const r=Math.max(rn(n),rn(t));if(void 0===e&&r<=6)return ln(un(n)+un(t),r);if(!e)throw new RangeError("Need relativeTo");const i=e.add(n).add(t);return Dr(e,i,o,r)}(n,t,o,o?o.calendar:void 0))}pt(ko,"Duration");class qo extends A{constructor(n,t,e,o=0,r=0,i=0,s=0,a=0,c=0,u=yr()){const d=An({isoYear:n,isoMonth:t,isoDay:e,isoHour:o,isoMinute:r,isoSecond:i,isoMillisecond:s,isoMicrosecond:a,isoNanosecond:c},1),h=q(gr,u);Ke(d,h.toString()),super({...d,calendar:h})}static from(n,t){const e=p(t);return Ho(n instanceof qo?n.getISOFields():"object"==typeof n?be(n,e,t):ie(Lt(String(n))))}static compare(n,t){return jn(q(qo,n),q(qo,t))}with(n,t){const e=p(t);return Ho(Ee(this,n,e,t))}withPlainDate(n){const t=q(Fr,n);return Ho({...this.getISOFields(),...t.getISOFields(),calendar:Ir(this,t)})}withPlainTime(n){return Ho({...this.getISOFields(),...mo(n).getISOFields()})}withCalendar(n){return Ho({...this.getISOFields(),calendar:q(gr,n)})}add(n,t){return Lo(this,q(ko,n),t)}subtract(n,t){return Lo(this,nn(q(ko,n)),t)}until(n,t){return $o(this,q(qo,n),!1,t)}since(n,t){return $o(this,q(qo,n),!0,t)}round(n){const t=x(n,0,6);return Ho({...Je(this.getISOFields(),t),calendar:this.calendar})}equals(n){return xn(this,q(qo,n))}toString(n){const t=tt(n),e=_n(n);return ot(Je(this.getISOFields(),t),t)+ct(this.calendar.toString(),e)}toZonedDateTime(n,t){const e=q(Ie,n),o=vt(e,this,nt(t));return new bo(o.epochNanoseconds,e,this.calendar)}toPlainYearMonth(){return Mo(this.getISOFields())}toPlainMonthDay(){return this.calendar.monthDayFromFields(this)}toPlainDate(){return br(this.getISOFields())}toPlainTime(){return fo(this.getISOFields())}}function Ho(n){return new qo(n.isoYear,n.isoMonth,n.isoDay,n.isoHour,n.isoMinute,n.isoSecond,n.isoMillisecond,n.isoMicrosecond,n.isoNanosecond,n.calendar)}function Lo(n,t,e){const o=function(n,t,e){const{calendar:o}=n;return On(bn(o.dateAdd(br(n),tn(t,an),e).getISOFields())+BigInt(hn(n))+dn(t))}(n.getISOFields(),t,e);return Ho({...o,calendar:n.calendar})}function $o(n,t,e,o){const r=k(o,6,0,0,9);return xo(Tr(n,t,vr(n,t),e,r))}pt(qo,"PlainDateTime"),mt(qo,Z),wt(qo,yt),so(qo,to({year:"numeric",month:"numeric",day:"numeric",weekday:void 0,hour:"numeric",minute:"2-digit",second:"2-digit"},{}));class zo extends A{constructor(n,t,e=yr(),o=Fn){super({...zn({isoYear:o,isoMonth:n,isoDay:t},1),calendar:q(gr,e)})}static from(n,t){if(p(t),n instanceof zo)return Ao(n.getISOFields());if("object"==typeof n)return Oe(n,t);const e=function(n){const t=Jt(n)||Kt(n);if(!t)throw re("monthDay",n);return t}(String(n));return void 0===e.calendar&&(e.isoYear=Fn),Ao(ie(e))}with(n,t){return Ue(this,n,t)}equals(n){return!jn(this,q(zo,n))}toString(n){const t=this.getISOFields(),e=t.calendar.toString(),o=_n(n);return(e===In?function(n){return mn(n.isoMonth,2)+"-"+mn(n.isoDay,2)}(t):rt(t))+ct(e,o)}toPlainDate(n){return this.calendar.dateFromFields({year:n.year,monthCode:this.monthCode,day:this.day},{overflow:"reject"})}}function Ao(n){return new zo(n.isoMonth,n.isoDay,n.calendar,n.isoYear)}function Wo(n){return n instanceof Fr||n instanceof qo||n instanceof bo||n instanceof po||n instanceof zo}function Ko(n,t,e){let o;if(n instanceof Fr)o=n;else if(Wo(n)){if(e&&n instanceof zo)throw new TypeError("PlainMonthDay not allowed");o=br(n.getISOFields())}else o=Fr.from(n);return Sr(o.calendar,t),o}function Go(n,t,e){if(Wo(n))return n.getISOFields();let{era:o,eraYear:r,year:i,month:s,monthCode:a,day:c}=n;const u=void 0!==r&&void 0!==o?pn(t.id,r,o):void 0;if(void 0===i){if(void 0===u)throw new TypeError("Must specify either a year or an era & eraYear");i=u}else if(void 0!==u&&u!==i)throw new RangeError("year and era/eraYear must match");if(void 0===c)throw new TypeError("Must specify day");const d=p(e);if(void 0!==a){const[n,e]=t.convertMonthCode(a,i);if(void 0!==s&&s!==n)throw new RangeError("Month doesnt match with monthCode");if(s=n,e){if(1===d)throw new RangeError("Month code out of range");c=t.daysInMonth(i,s)}}else if(void 0===s)throw new TypeError("Must specify either a month or monthCode");return[i,s,c]=$n(i,s,c,t,d),Dn(t.epochMilliseconds(i,s,c))}function Jo(n,t){if(Wo(n)){if(t&&n instanceof zo)throw new TypeError("PlainMonthDay not allowed");return n.getISOFields()}return Fr.from(n).getISOFields()}function Qo(n,t){return Bn(n.epochMilliseconds(t,1,1),n.epochMilliseconds(t+1,1,1))}function Vo(n,t,e,o){return Bn(n.epochMilliseconds(t,1,1),n.epochMilliseconds(t,e,o))+1}pt(zo,"PlainMonthDay"),mt(zo),wt(zo,["monthCode","day"]),so(zo,to({month:"numeric",day:"numeric"},{weekday:void 0,year:void 0,hour:void 0,minute:void 0,second:void 0},!0));const Xo={hebrew:6,chinese:0,dangi:0};class _o extends wn{format;yearCorrection;monthCacheByYear;constructor(n){const t=nr(n);if(e=n,o=t.resolvedOptions().calendar,Mn(e)!==Mn(o))throw new RangeError("Invalid calendar: "+n);var e,o;super(n),this.format=t,this.yearCorrection=this.computeFieldsDumb(0).year-1970,this.monthCacheByYear={}}epochMilliseconds(n,t,e){return kn(this.queryMonthCache(n)[0][t-1],e-1)}daysInMonth(n,t){const e=this.queryMonthCache(n)[0],o=e[t-1];t>=e.length&&(n++,t=0);return Bn(o,this.queryMonthCache(n)[0][t])}monthsInYear(n){return this.queryMonthCache(n)[0].length}monthCode(n,t){const e=this.queryLeapMonthByYear(t);return!e||n<e?super.monthCode(n,t):super.monthCode(n-1,t)+(n===e?"L":"")}convertMonthCode(n,t){const e=this.queryLeapMonthByYear(t);let o=/L$/.test(n),r=parseInt(n.substr(1)),i=!1;if(o){const n=Xo[this.id];if(void 0===n)throw new RangeError("Calendar system doesnt support leap months");if(n){if(r!==n-1)throw new RangeError("Invalid leap-month month code")}else if(r<=1||r>=12)throw new RangeError("Invalid leap-month month code")}return!o||e&&r===e-1||(i=!0,o=!1),(o||e&&r>=e)&&r++,[r,i]}inLeapYear(n){const t=Qo(this,n);return t>Qo(this,n-1)&&t>Qo(this,n+1)}guessYearForMonthDay(n,t){let e=1970+this.yearCorrection;const o=e+100;for(;e<o;e++){const[o,r]=this.convertMonthCode(n,e);if(!r&&o<=this.monthsInYear(e)&&t<=this.daysInMonth(e,o))return e}throw new Error("Could not guess year")}normalizeISOYearForMonthDay(n){return n}computeFields(n){const t=this.computeFieldsDumb(n),e=this.queryMonthCache(t.year)[2];return{...t,month:e[t.month]}}computeFieldsDumb(n){const t=ue(this.format,n);let e,o,r=parseInt(t.relatedYear||t.year);var i;return t.era&&(i=this.id,void 0!==yn[Mn(i)])&&(e=he(t.era),o=r,r=pn(this.id,o,e,!0)),{era:e,eraYear:o,year:r,month:t.month,day:parseInt(t.day)}}queryLeapMonthByYear(n){const t=this.queryMonthCache(n),e=this.queryMonthCache(n-1),o=this.queryMonthCache(n+1);if(t[0].length>e[0].length&&t[0].length>o[0].length){const n=t[1],o=e[1];for(let t=0;t<o.length;t++)if(o[t]!==n[t])return t+1}}queryMonthCache(n){const{monthCacheByYear:t}=this;return t[n]||(t[n]=this.buildMonthCache(n))}buildMonthCache(n){const t=[],e=[],o={};let r=Tn(this.guessISOYear(n),1,1);for(r=kn(r,400);;){const o=this.computeFieldsDumb(r);if(o.year<n)break;r=kn(r,1-o.day),o.year===n&&(t.unshift(r),e.unshift(o.month)),r=kn(r,-1)}for(let n=0;n<e.length;n++)o[e[n]]=n+1;return[t,e,o]}guessISOYear(n){return n-this.yearCorrection}}function nr(n){return new le("en-US",{calendar:n,era:"short",year:"numeric",month:"short",day:"numeric",timeZone:"UTC"})}const tr=Tn(1868,9,8);const er={gregory:Xn,japanese:class extends Xn{format=nr("japanese");computeFields(n){const t=super.computeFields(n);if(n>=tr){const e=ue(this.format,n);t.era=he(e.era),t.eraYear=parseInt(e.relatedYear||e.year)}return t}},islamic:class extends _o{guessISOYear(n){return Math.ceil(32*n/33+622)}}},or={[In]:Sn};function rr(n){const t=(n=String(n)).toLocaleLowerCase();return or[t]||(or[t]=new(er[Mn(t)]||_o)(n))}const ir=Tn(1582,10,15),sr=Tn(622,7,18),ar={buddhist:ir,japanese:ir,roc:ir,islamic:sr,"islamic-rgsa":sr,indian:0},cr={};function ur(n,e){return dr(Number(n/t),e)}function dr(n,t){if(function(n,t){return function(n){let t=cr[n];if(void 0===t){const e=ar[n];if(void 0===e)t=!1;else{let o=rr(n);o instanceof _o||(o=new _o(n));const r=e-f,i=o.computeFields(r);t=r!==o.epochMilliseconds(i.year,i.month,i.day)}cr[n]=t}return t}(t)&&n<ar[t]}(n,t))throw new RangeError("Invalid timestamp for calendar")}function hr(n,t,e){const o=7+t-e;return-X(Cn(n,1,o)-t,7)+o-1}function lr(n,t,e){const o=hr(n,t,e),r=hr(n+1,t,e);return(Qo(Sn,n)-o+r)/7}const[fr,mr]=T();class gr extends H{constructor(n){super(),"islamicc"===n&&(n="islamic-civil"),mr(this,rr(n))}static from(n){if(b(n))return function(n){const t=n.calendar;if(void 0===t)return n;if(b(t)&&void 0===t.calendar)return t;return new gr(t)}(n);const t=Kt(String(n),!1,!0);return new gr(t?t.calendar||In:String(n))}get id(){return this.toString()}era(n){const t=Jo(n,!0);return pr(fr(this),t.isoYear,t.isoMonth,t.isoDay).era}eraYear(n){const t=Jo(n,!0);return pr(fr(this),t.isoYear,t.isoMonth,t.isoDay).eraYear}year(n){const t=Jo(n,!0);return pr(fr(this),t.isoYear,t.isoMonth,t.isoDay).year}month(n){const t=Jo(n,!0);return pr(fr(this),t.isoYear,t.isoMonth,t.isoDay).month}monthCode(n){const t=Ko(n,this);return fr(this).monthCode(t.month,t.year)}day(n){const t=Jo(n);return pr(fr(this),t.isoYear,t.isoMonth,t.isoDay).day}dayOfWeek(n){const t=Jo(n,!0);return Cn(t.isoYear,t.isoMonth,t.isoDay)}dayOfYear(n){const t=Ko(n,this,!0);return Vo(fr(this),t.year,t.month,t.day)}weekOfYear(n){const t=Jo(n,!0);return function(n,t,e,o,r){const i=hr(n,o,r),s=Math.floor((Vo(Sn,n,t,e)-i-1)/7)+1;if(s<1)return s+lr(n-1,o,r);const a=lr(n,o,r);return s>a?s-a:s}(t.isoYear,t.isoMonth,t.isoDay,1,4)}daysInWeek(n){return Jo(n,!0),7}daysInMonth(n){const t=Ko(n,this,!0);return fr(this).daysInMonth(t.year,t.month)}daysInYear(n){const t=Ko(n,this,!0);return Qo(fr(this),t.year)}monthsInYear(n){const t=Ko(n,this,!0);return fr(this).monthsInYear(t.year)}inLeapYear(n){return fr(this).inLeapYear(this.year(n))}dateFromFields(n,t){const e=Go(I(n,Gn),fr(this),t);return new Fr(e.isoYear,e.isoMonth,e.isoDay,this)}yearMonthFromFields(n,t){const e=Go({...I(n,Kn),day:1},fr(this),t);return new po(e.isoYear,e.isoMonth,this,e.isoDay)}monthDayFromFields(n,t){const e=fr(this);let{era:o,eraYear:r,year:i,month:s,monthCode:a,day:c}=I(n,Qn);if(void 0===c)throw new TypeError("required property 'day' missing or undefined");if(void 0!==a?i=Fn:void 0!==o&&void 0!==r&&(i=pn(e.id,r,o)),void 0===i){if(void 0===a)throw new TypeError("either year or monthCode required with month");i=e.guessYearForMonthDay(a,c)}const u=Go({year:i,month:s,monthCode:a,day:c},e,t);return new zo(u.isoMonth,u.isoDay,this,e.normalizeISOYearForMonthDay(u.isoYear))}dateAdd(n,t,e){const o=fr(this),r=function(n,t,e,o){n=St(n=It(n,t.years,e,o),t.months,e,o);let r=e.epochMilliseconds(n.year,n.month,n.day);const i=Math.trunc(Number(dn(t))/h);return r=kn(r,7*t.weeks+t.days+i),Dn(r)}(q(Fr,n,e),q(ko,t),o,p(e));return new Fr(r.isoYear,r.isoMonth,r.isoDay,this)}dateUntil(n,t,e){const o=fr(this),r=q(Fr,n),i=q(Fr,t),s=S(e).largestUnit,a="auto"===s?6:B(s,6,6,9);return Sr(this,vr(r,i)),xo(function(n,t,e,o){let r=0,i=0,s=0,a=0;switch(o){case 9:r=function(n,t,e){const[,o,r]=$n(t.year,n.month,n.day,e,0),i=Hn(t,n),s=W(t.month,o)||W(t.day,r);return t.year-n.year-(s&&i&&s!==i?i:0)}(n,t,e),n=It(n,r,e,0);case 8:i=function(n,t,e){let o=0;const r=Hn(t,n);if(r){let{year:i}=n;for(;i!==t.year;)o+=e.monthsInYear(i)*r,i+=r;const[,s,a]=$n(t.year,n.month,n.day,e,0);o+=t.month-s;const c=W(t.day,a);c&&r&&c!==r&&(o-=r)}return o}(n,t,e),n=St(n,i,e,0)}a=Bn(e.epochMilliseconds(n.year,n.month,n.day),e.epochMilliseconds(t.year,t.month,t.day)),7===o&&(s=Math.trunc(a/7),a%=7);return en({years:r,months:i,weeks:s,days:a,hours:0,minutes:0,seconds:0,milliseconds:0,microseconds:0,nanoseconds:0})}(r,i,o,a))}fields(n){return n.slice()}mergeFields(n,t){return wr(n,t)}toString(){return fr(this).id}}function yr(){return new gr(In)}function wr(n,t){const e={...n,...t};if(void 0!==n.year){delete e.era,delete e.eraYear,delete e.year;let o=!1;void 0===t.era&&void 0===t.eraYear||(e.era=t.era,e.eraYear=t.eraYear,o=!0),void 0!==t.year&&(e.year=t.year,o=!0),o||(e.year=n.year)}if(void 0!==n.monthCode){delete e.monthCode,delete e.month;let o=!1;void 0!==t.month&&(e.month=t.month,o=!0),void 0!==t.monthCode&&(e.monthCode=t.monthCode,o=!0),o||(e.monthCode=n.monthCode)}return void 0!==n.day&&(e.day=t.day??n.day),e}function pr(n,t,e,o){const r=Tn(t,e,o);return dr(r,n.id),n.computeFields(r)}function Mr(n){return void 0===n.calendar?yr():q(gr,n.calendar)}function vr(n,t){const{calendar:e}=n;return Sr(e,t.calendar),e}function Ir(n,t){const e=n.calendar,o=t.calendar;if(e.id===In)return o;if(o.id===In)return e;if(e.id!==o.id)throw new RangeError("Non-ISO calendars incompatible");return e}function Sr(n,t){if(n.toString()!==t.toString())throw new RangeError("Calendars must match")}pt(gr,"Calendar");class Fr extends A{constructor(n,t,e,o=yr()){const r=zn({isoYear:n,isoMonth:t,isoDay:e},1),i=q(gr,o);!function(n,t){const e=bn(n);Ge(e+(e<0n?86399999999999n:0n)),ur(e,t)}(r,i.toString()),super({...r,calendar:i})}static from(n,t){return p(t),n instanceof Fr?br(n.getISOFields()):"object"==typeof n?Ne(n,t):br(ie(Lt(String(n))))}static compare(n,t){return jn(q(Fr,n),q(Fr,t))}with(n,t){return Ze(this,n,t)}withCalendar(n){const t=this.getISOFields();return new Fr(t.isoYear,t.isoMonth,t.isoDay,n)}add(n,t){return this.calendar.dateAdd(this,n,t)}subtract(n,t){return this.calendar.dateAdd(this,q(ko,n).negated(),t)}until(n,t){return Nr(this,q(Fr,n),!1,t)}since(n,t){return Nr(this,q(Fr,n),!0,t)}equals(n){return!jn(this,q(Fr,n))}toString(n){const t=_n(n),e=this.getISOFields();return rt(e)+ct(e.calendar.toString(),t)}toZonedDateTime(n){const t=function(n){let t,e;if("string"==typeof n)e=n;else{if("object"!=typeof n)throw new TypeError("Invalid options/timeZone argument");if(void 0!==n.id?e=n:(e=n.timeZone,t=n.plainTime),void 0===e)throw new TypeError("Invalid timeZone argument")}return{plainTime:t,timeZone:e}}(n),e=q(Ie,t.timeZone),o=void 0===t.plainTime?void 0:q(lo,t.plainTime);return No({...this.getISOFields(),...o?o.getISOFields():sn,timeZone:e})}toPlainDateTime(n){return Ho({...this.getISOFields(),...mo(n).getISOFields()})}toPlainYearMonth(){return Mo(this.getISOFields())}toPlainMonthDay(){return this.calendar.monthDayFromFields(this)}}function br(n){return new Fr(n.isoYear,n.isoMonth,n.isoDay,n.calendar)}function Nr(n,t,e,o){return xo(Or(n,t,vr(n,t),e,k(o,6,6,6,9)))}function Tr(n,t,e,o,r){return Po(Dr(n,t,e,r.largestUnit),n,t,e,o,r)}function Or(n,t,e,o,r){return Po(e.dateUntil(n,t,{largestUnit:C[r.largestUnit]}),n,t,e,o,r)}function Dr(n,t,e,o){if(!w(o))return Yr(n,t,o);const r=br({...n.getISOFields(),calendar:e});let i,s,a,c,u,d=br({...t.getISOFields(),calendar:e});do{s=e.dateUntil(r,d,{largestUnit:C[o]}),i=n.add(s),a=Yr(i,t,5),c=s.sign,u=a.sign}while(c&&u&&c!==u&&(d=d.add({days:u})));return l=a,{sign:(h=s).sign||l.sign,years:h.years+l.years,months:h.months+l.months,weeks:h.weeks+l.weeks,days:h.days+l.days,hours:h.hours+l.hours,minutes:h.minutes+l.minutes,seconds:h.seconds+l.seconds,milliseconds:h.milliseconds+l.milliseconds,microseconds:h.microseconds+l.microseconds,nanoseconds:h.nanoseconds+l.nanoseconds};var h,l}function Yr(n,t,e){return ln(Yn(t)-Yn(n),e)}pt(Fr,"PlainDate"),mt(Fr),wt(Fr,yt),so(Fr,to({year:"numeric",month:"numeric",day:"numeric",weekday:void 0},{hour:void 0,minute:void 0,second:void 0}));const[Er,Zr]=T();class Cr extends L{constructor(n){if(super(),"number"==typeof n)throw new TypeError("Must supply bigint, not number");var t;n=BigInt(n),((t=n)<-8640000000000000000000n||t>8640000000000000000000n)&&Rn(),Zr(this,n)}static from(n){if(n instanceof Cr)return new Cr(n.epochNanoseconds);const t=Ht(String(n)),e=t.offsetNanoseconds;if(void 0===e)throw new RangeError("Must specify an offset");return new Cr(bn(An(t,1))-BigInt(e))}static fromEpochSeconds(n){return new Cr(BigInt(n)*e)}static fromEpochMilliseconds(n){return new Cr(BigInt(n)*t)}static fromEpochMicroseconds(t){return new Cr(t*n)}static fromEpochNanoseconds(n){return new Cr(n)}static compare(n,t){return Ln(q(Cr,n),q(Cr,t))}get epochNanoseconds(){return Er(this)}add(n){return new Cr(bt(this.epochNanoseconds,q(ko,n)))}subtract(n){return new Cr(bt(this.epochNanoseconds,nn(q(ko,n))))}until(n,t){return Ur(this,q(Cr,n),t)}since(n,t){return Ur(q(Cr,n),this,t)}round(n){const t=x(n,0,5,!0);return new Cr(Ve(this.epochNanoseconds,t))}equals(n){return!Ln(this,q(Cr,n))}toString(n){const t=S(n).timeZone;return this.toZonedDateTimeISO(t??"UTC").toString({...n,offset:void 0===t?"never":"auto",timeZoneName:"never"})+(void 0===t?"Z":"")}toZonedDateTimeISO(n){return new bo(this.epochNanoseconds,n)}toZonedDateTime(n){if(!b(n))throw new TypeError("Must specify options");if(void 0===n.calendar)throw new TypeError("Must specify a calendar");if(void 0===n.timeZone)throw new TypeError("Must specify a timeZone");return new bo(this.epochNanoseconds,n.timeZone,n.calendar)}}function Ur(n,t,e){const o=k(e,3,0,0,5);return xo(function(n,t,e){return ln(V(t-n,l[e.smallestUnit]*e.roundingIncrement,e.roundingFunc),e.largestUnit)}(n.epochNanoseconds,t.epochNanoseconds,o))}function Pr(){return Cr.fromEpochMilliseconds(this.valueOf())}pt(Cr,"Instant"),ht(Cr),so(Cr,_e({year:"numeric",month:"numeric",day:"numeric",weekday:void 0,hour:"numeric",minute:"2-digit",second:"2-digit"},{timeZoneName:void 0},{}));const Rr=Symbol(),Br=Symbol(),kr=Symbol();class xr extends Intl.DateTimeFormat{constructor(n,t){const e=fe(n),o=function(n){const t={};for(const e in n){let o=n[e];b(o)&&(o=o.toString()),t[e]=o}return t}(t||{});super(e,o),this[Rr]=e,this[Br]=o,this[kr]=new Map}format(n){const t=qr(this,n);return t[0]===this?super.format(t[1]):t[0].format(t[1])}formatToParts(n){return super.formatToParts.call(...qr(this,n))}formatRange(n,t){return super.formatRange.call(...Hr(this,n,t))}formatRangeToParts(n,t){return super.formatRangeToParts.call(...Hr(this,n,t))}}const jr=xr;function qr(n,t){const e=ao(t);if(e){const o=Lr(n,e);return[o.buildFormat(t),o.buildEpochMilli(t)]}return[n,t]}function Hr(n,t,e){const o=ao(t);if(o!==ao(e))throw new TypeError("Mismatch of types");if(o){const r=Lr(n,o);return[r.buildFormat(t,e),new Date(r.buildEpochMilli(t)),new Date(r.buildEpochMilli(e))]}return[n,t,e]}function Lr(n,t){const e=n[kr];let o=e.get(t);return o||(o=function(n){const t={};return{buildFormat:function(e,o){const r=n.buildKey(e,o),i=r.join("|");return t[i]||(t[i]=n.buildFormat(...r))},buildEpochMilli:n.buildEpochMilli}}(t(n[Rr],n[Br])),e.set(t,o)),o}const $r={zonedDateTimeISO:function(n){return No(Ar(In,n))},zonedDateTime:function(n,t){return No(Ar(n,t))},plainDateTimeISO:function(n){return Ho(Ar(In,n))},plainDateTime:function(n,t){return Ho(Ar(n,t))},plainDateISO:function(n){return br(Ar(In,n))},plainDate:function(n,t){return br(Ar(n,t))},plainTimeISO:function(n){return fo(Ar(In,n))},instant:function(){return new Cr(Wr())},timeZone:zr};pt($r,"Now");function zr(){return new Ie((new le).resolvedOptions().timeZone)}function Ar(n,t=zr()){const e=q(Ie,t);return{...To(Wr(),e)[0],timeZone:e,calendar:q(gr,n)}}function Wr(){return BigInt(Date.now())*t}const Kr={PlainYearMonth:po,PlainMonthDay:zo,PlainDate:Fr,PlainTime:lo,PlainDateTime:qo,ZonedDateTime:bo,Instant:Cr,Calendar:gr,TimeZone:Ie,Duration:ko,Now:$r,[Symbol.toStringTag]:"Temporal"};globalThis.Temporal||(globalThis.Temporal=Kr,Intl.DateTimeFormat=jr,Date.prototype.toTemporalInstant=Pr)}();
!function(){const n=1e3,t=1e6,e=1e9,o=6e10,r=36e11,i=864e11,s=[1,n,t,e,o,r,i],a=864e5,c=1e3,u=[9,6,3];function d(n){return n<=6}function l(n){return n>=6}const h=f("overflow",{constrain:0,reject:1},0);function f(n,t,e){const o=function(n,t,e){return(o,r)=>{if(void 0===o){const t=null!=r?r:e;if(void 0===t)throw new RangeError(`Must specify a ${n}`);return t}if(void 0===t[o])throw new RangeError(`Invalid ${n}: ${o}`);return t[o]}}(n,t,e);return(t,e)=>{const r=y(t);return o(r[n],e)}}function m(n,t,e,o){if(void 0===n)return t;if(!Number.isFinite(n))throw new RangeError("Number must be finite");n=Math.trunc(n);const r=Math.min(Math.max(n,t),e);if(r!==n&&1===o)throw new RangeError("Invalid overflowed value "+n);return r}function g(n,t){const e={};for(const o in t)void 0!==n[o]&&(e[o]=t[o](n[o]));return e}function y(n,t){if(void 0===n&&!t)return{};if(!p(n))throw TypeError("options must be an object or undefined");return n}const w=/object|function/;function p(n){return null!==n&&w.test(typeof n)}const v=f("roundingMode",{halfExpand:Math.round,ceil:Math.ceil,trunc:Math.trunc,floor:Math.floor});function M(){const n=new WeakMap;return[n.get.bind(n),n.set.bind(n)]}function b(n,t){Object.defineProperties(n.prototype,S(t,(n=>({get:n}))))}function S(n,t){const e={};for(const o in n)e[o]=t(n[o],o);return e}function I(n,t,e){const o={};for(const r of t)o[r]=e(n[r]);return o}function F(n,t){const e={};return n.forEach(((n,o)=>{e[n]=t(n,o)})),e}const T=["nanosecond","microsecond","millisecond","second","minute","hour"],O=[...T,"day","week","month","year"],D=O.map((n=>n+"s")),N=F(O,((n,t)=>t)),Y=F(D,((n,t)=>t));function E(n,t,e,o){var r;let i;if(void 0===n){if(void 0===t)throw new RangeError("Unit is required");i=t}else if(i=null!=(r=N[n])?r:Y[n],void 0===i||i<e||i>o)throw new RangeError("Invalid unit "+n);return i}function Z(n,t,e,o,r,i){var a;const c=y(n),u=null!=(a=c.roundingIncrement)?a:1,d=E(c.smallestUnit,e,o,r),l=v(c,i?Math.round:Math.trunc);let h=c.largestUnit;"auto"===h&&(h=void 0);const f=E(h,t=Math.max(t,d),o,r);if(d>f)throw new RangeError("Bad smallestUnit/largestUnit");if(d<6){const n=s[d+1],t=s[d]*u;if(n===t)throw new RangeError("Must not equal larger unit");if(n%t)throw new RangeError("Must divide into larger unit")}return{smallestUnit:d,largestUnit:f,roundingFunc:l,roundingIncrement:u}}function C(n,t,e,o){var r;const a=y("string"==typeof n?{smallestUnit:n}:n,!0),c=null!=(r=a.roundingIncrement)?r:1,u=E(a.smallestUnit,void 0,t,e),d=v(a,Math.round),l=s[u]*c;if(6===u){if(1!==c)throw new RangeError("When smallestUnit is days, roundingIncrement must be 1")}else{const n=o?i:s[u+1];if(!o&&n===l)throw new RangeError("Must not equal larger unit");if(n%l)throw new RangeError("Must divide into larger unit")}return{smallestUnit:u,roundingFunc:d,incNano:l}}const U=Symbol();function P(n,t,...e){return t instanceof n?t:n.from(t,...e)}class R{toJSON(){return this.toString()}}class k extends R{valueOf(){throw new Error("Cannot convert object using valueOf")}}const[x,j]=M();class q extends k{constructor(n){super(),j(this,Object.freeze(n))}getISOFields(){return x(this)}}function H(n,t){return n<t?-1:n>t?1:0}function L(n){return H(n,0)}function B(n,t,e){return e(n/t)*t}function $(n){return B(n,o,A)}function A(n){return Math.round(Math.abs(n))*L(n)}function z(n,t,e){const o=n.div(t).mult(t),r=n.sub(o).toNumber();return o.add(e(r/t)*t)}function W(n,t){return(n%t+t)%t}function K(n,t){return J(e=String(n),t,"0")+e;var e}function G(n,t,e){return n+J(n,t,e)}function J(n,t,e){return new Array(Math.max(0,t-n.length+1)).join(e)}function Q(n){return n<0?"-":"+"}const V=Math.pow(10,8);class X{constructor(n,t){this.high=n,this.low=t}sign(){return L(this.high)||L(this.low)}neg(){return new X(-this.high||0,-this.low||0)}abs(){return this.sign()<0?this.neg():this}add(n){const[t,e]=tn(n);return en(this.high+t,this.low+e)}sub(n){const[t,e]=tn(n);return en(this.high-t,this.low-e)}mult(n){return en(this.high*n,this.low*n)}div(n){const t=this.high/n;let e=String(t);-1!==e.indexOf("e-")&&(e=t.toFixed(20));const o=e.indexOf(".");let r=0;if(-1!==o){let n=e.substr(o+1);n=G(n,8,"0"),n=n.substr(0,8),r=parseInt(n)*(L(t)||1)}return en(Math.trunc(t)||0,Math.trunc(this.low/n)+r)}toNumber(){return this.high*V+this.low}toBigInt(){return BigInt(this.high)*BigInt(V)+BigInt(this.low)}}function _(n,t){let e,o;if(n instanceof X)e=n.high,o=n.low;else if("number"==typeof n){if(t)throw new TypeError("Must supply bigint, not number");e=Math.trunc(n/V),o=n%V||0}else if("bigint"==typeof n){const t=BigInt(V);e=Number(n/t),o=Number(n%t||0)}else{if("string"!=typeof n)throw new Error("Invalid type of BigNano");{if((n=n.trim()).match(/\D/))throw new SyntaxError(`Cannot parse ${n} to a BigInt`);const t=n.length-8;e=Number(n.substr(t)),o=Number(n.substr(0,t))}}return new X(e,o)}function nn(n,t){return H(n.high,t.high)||H(n.low,t.low)}function tn(n){return"number"==typeof n?[0,n]:[n.high,n.low]}function en(n,t){let e=t%V||0,o=n+Math.trunc(t/V);const r=L(o),i=L(e);return i&&r&&i!==r&&(o+=i,e-=V*i),new X(o,e)}const on=D.concat("sign");function rn(n){return I(n,on,(n=>-n||0))}function sn(n,t){var e,o,r,i,s,a,c,u,d,l;return an({years:null!=(e=t.years)?e:n.years,months:null!=(o=t.months)?o:n.months,weeks:null!=(r=t.weeks)?r:n.weeks,days:null!=(i=t.days)?i:n.days,hours:null!=(s=t.hours)?s:n.hours,minutes:null!=(a=t.minutes)?a:n.minutes,seconds:null!=(c=t.seconds)?c:n.seconds,milliseconds:null!=(u=t.milliseconds)?u:n.milliseconds,microseconds:null!=(d=t.microseconds)?d:n.microseconds,nanoseconds:null!=(l=t.nanoseconds)?l:n.nanoseconds})}function an(n){return{...n,sign:cn(n)}}function cn(n){let t=0;for(const e of D){if(n[e]){t=L(n[e]);break}}return t}function un(n){let t=9;for(;t>0&&!n[D[t]];)t--;return t}const dn={isoHour:0,isoMinute:0,isoSecond:0,isoMillisecond:0,isoMicrosecond:0,isoNanosecond:0},ln={hours:0,minutes:0,seconds:0,milliseconds:0,microseconds:0,nanoseconds:0};function hn(n){return{isoHour:n.hour||0,isoMinute:n.minute||0,isoSecond:n.second||0,isoMillisecond:n.millisecond||0,isoMicrosecond:n.microsecond||0,isoNanosecond:n.nanosecond||0}}function fn(n){return _(i).mult(n.days).add(mn(n))}function mn(i){return _(i.nanoseconds).add(_(i.microseconds).mult(n)).add(_(i.milliseconds).mult(t)).add(_(i.seconds).mult(e)).add(_(i.minutes).mult(o)).add(_(i.hours).mult(r))}function gn(i){return i.isoHour*r+i.isoMinute*o+i.isoSecond*e+i.isoMillisecond*t+i.isoMicrosecond*n+i.isoNanosecond}function yn(s,a){let c,u=0,d=0,l=0,h=0,f=0,m=0;switch(a){case 6:c=s.div(i),u=c.toNumber(),s=s.sub(c.mult(i));case 5:c=s.div(r),d=c.toNumber(),s=s.sub(c.mult(r));case 4:c=s.div(o),l=c.toNumber(),s=s.sub(c.mult(o));case 3:c=s.div(e),h=c.toNumber(),s=s.sub(c.mult(e));case 2:c=s.div(t),f=c.toNumber(),s=s.sub(c.mult(t));case 1:c=s.div(n),m=c.toNumber(),s=s.sub(c.mult(n))}return an({years:0,months:0,weeks:0,days:u,hours:d,minutes:l,seconds:h,milliseconds:f,microseconds:m,nanoseconds:s.toNumber()})}function wn(s){const a=Math.floor(s/i);s-=a*i;const c=Math.floor(s/r);s-=c*r;const u=Math.floor(s/o);s-=u*o;const d=Math.floor(s/e);s-=d*e;const l=Math.floor(s/t);s-=l*t;const h=Math.floor(s/n);return[{isoHour:c,isoMinute:u,isoSecond:d,isoMillisecond:l,isoMicrosecond:h,isoNanosecond:s-=h*n},a]}const pn={gregory:{bce:-1,ce:0},ethioaa:{era0:0},ethiopic:{era0:0,era1:5500},coptic:{era0:-1,era1:0},roc:{beforeroc:-1,minguo:0},buddhist:{be:0},islamic:{ah:0},indian:{saka:0},persian:{ap:0},japanese:{bce:-1,ce:0,meiji:1867,taisho:1911,showa:1925,heisei:1988,reiwa:2018}};class vn{constructor(n){this.id=n}monthCode(n,t){return"M"+K(n,2)}convertMonthCode(n,t){const e=/L$/.test(n),o=parseInt(n.substr(1));if(e)throw new RangeError("Calendar system doesnt support leap months");return[o,!1]}}function Mn(n,t,e,o){var r;let i=null==(r=pn[bn(n)])?void 0:r[e];if(void 0===i){if(!o)throw new Error("Unkown era "+e);i=0}return(i+t)*(L(i)||1)}function bn(n){return n.split("-")[0]}class Sn extends vn{computeFields(n){const t=Zn(n);return{era:void 0,eraYear:void 0,year:t.isoYear,month:t.isoMonth,day:t.isoDay}}epochMilliseconds(n,t,e){return Yn(n,t,e)}daysInMonth(n,t){return 2===t?this.inLeapYear(n)?29:28:4===t||6===t||9===t||11===t?30:31}monthsInYear(){return 12}inLeapYear(n){return n%4==0&&(n%100!=0||n%400==0)}guessYearForMonthDay(){return Tn}normalizeISOYearForMonthDay(){return Tn}}const In="iso8601",Fn=new Sn(In),Tn=1972,On=Symbol();function Dn(n){return Nn(n.isoYear,n.isoMonth,n.isoDay,n.isoHour,n.isoMinute,n.isoSecond,n.isoMillisecond,n.isoMicrosecond,n.isoNanosecond)}function Nn(e,o,r,i,s,a,c,u,d){return _(Yn(e,o,r,i,s,a,c)).mult(t).add((null!=u?u:0)*n+(null!=d?d:0))}function Yn(n,t,e,o,r,i,s){const c=L(n);let u,d,l=0;const h=n>=0&&n<1e3,f=h?n+1200:n;for(;l<31;l++){u=e-c*l;const n=Date.UTC(f,t-1,u,null!=o?o:0,null!=r?r:0,null!=i?i:0,null!=s?s:0);if(!xn(n)){d=n+c*l*a;break}}return(void 0===d||u<1||u>Fn.daysInMonth(n,t))&&jn(),h&&(d=new Date(d).setUTCFullYear(n)),d}function En(e){let o=e.div(t),r=e.sub(o.mult(t)).toNumber();r<0&&(r+=t,o=o.sub(1));const i=Math.floor(r/n);return r-=i*n,{...Zn(o.toNumber()),isoMicrosecond:i,isoNanosecond:r}}function Zn(n){const[t,e]=kn(n);return{isoYear:t.getUTCFullYear(),isoMonth:t.getUTCMonth()+1,isoDay:t.getUTCDate()+e,isoHour:t.getUTCHours(),isoMinute:t.getUTCMinutes(),isoSecond:t.getUTCSeconds(),isoMillisecond:t.getUTCMilliseconds()}}function Cn(n){var t;return null!=(t=n[On])?t:Dn(n.getISOFields())}function Un(n){return Math.floor(Yn(n,1,1)/c)}function Pn(n){return kn(n.div(t).toNumber())[0].getUTCFullYear()}function Rn(n,t,e){const[o,r]=kn(Yn(n,t,e));return W(o.getUTCDay()+r,7)||7}function kn(n){const t=L(n);let e,o=0;for(;o<31;o++){const r=new Date(n-t*o*a);if(!xn(r)){e=r;break}}return void 0===e&&jn(),[e,t*o]}function xn(n){return isNaN(n.valueOf())}function jn(){throw new RangeError("Date outside of supported range")}function qn(n,t){return Math.round((t-n)/a)}function Hn(n,t){return n+t*a}function Ln(n,t){return!Bn(n,t)&&n.calendar.toString()===t.calendar.toString()}function Bn(n,t){return nn(Dn(n.getISOFields()),Dn(t.getISOFields()))}function $n(n,t){return H(gn(n.getISOFields()),gn(t.getISOFields()))}function An(n,t){return H(n.year,t.year)||H(n.month,t.month)||H(n.day,t.day)}function zn(n,t){return nn(n[On],t[On])}function Wn(n,t,e,o,r){return[n=Number(n),t=m(t,1,o.monthsInYear(n),r),e=m(e,1,o.daysInMonth(n,t),r)]}function Kn(n,t){const[e,o,r]=Wn(n.isoYear,n.isoMonth,n.isoDay,Fn,t);return{isoYear:e,isoMonth:o,isoDay:r}}function Gn(n,t){return{...Kn(n,t),...Jn(n,t)}}function Jn({isoHour:n,isoMinute:t,isoSecond:e,isoMillisecond:o,isoMicrosecond:r,isoNanosecond:i},s){return{isoHour:n=m(n,0,23,s),isoMinute:t=m(t,0,59,s),isoSecond:e=m(e,0,59,s),isoMillisecond:o=m(o,0,999,s),isoMicrosecond:r=m(r,0,999,s),isoNanosecond:i=m(i,0,999,s)}}const Qn={era:String,eraYear:Number,year:Number,month:Number,monthCode:String},Vn={...Qn,day:Number},Xn={hour:Number,minute:Number,second:Number,millisecond:Number,microsecond:Number,nanosecond:Number},_n={era:String,eraYear:Number,year:Number,month:Number,monthCode:String,day:Number},nt=F(D,(()=>Number));class tt extends Sn{computeFields(n){const t=super.computeFields(n),{year:e}=t;return{...t,era:e<1?"bce":"ce",eraYear:e<1?-(e-1):e}}}const et=f("calendarName",{auto:0,never:1,always:2},0),ot=f("disambiguation",{compatible:0,earlier:1,later:2,reject:3},0);function rt(n,t=4){const e=y(n),o=e.smallestUnit,r=e.fractionalSecondDigits;let i,a=0,c=1;return void 0!==o?(a=E(o,void 0,0,t),c=s[a],i=u[a]||0):void 0!==r&&"auto"!==r&&(i=m(r,0,9,1),c=Math.pow(10,9-i)),{smallestUnit:a,fractionalSecondDigits:i,roundingFunc:v(n,Math.trunc),incNano:c}}const it=f("timeZoneName",{auto:0,never:1},0);function st(n,t){return at(n)+"T"+ut(n,t)}function at(n){return ct(n)+"-"+K(n.isoDay,2)}function ct(n){const{isoYear:t}=n;return(t<1e3||t>9999?Q(t)+K(Math.abs(t),6):K(t,4))+"-"+K(n.isoMonth,2)}function ut(n,t){const e=[K(n.isoHour,2)];return t.smallestUnit<=4&&(e.push(K(n.isoMinute,2)),t.smallestUnit<=3&&e.push(K(n.isoSecond,2)+ft(n.isoMillisecond,n.isoMicrosecond,n.isoNanosecond,t.fractionalSecondDigits)[0])),e.join(":")}function dt(n){const[t,e]=wn(Math.abs(n)),o=ft(t.isoMillisecond,t.isoMicrosecond,t.isoNanosecond,void 0)[0];return Q(n)+K(t.isoHour+24*e,2)+":"+K(t.isoMinute,2)+(t.isoSecond||o?":"+K(t.isoSecond,2)+o:"")}function lt(n,t){return n&&(2===t||1!==t&&n!==In)?`[u-ca=${n}]`:""}function ht(n){return n.map((([n,t,e])=>{if(e||n){return Math.abs(n).toLocaleString("fullwide",{useGrouping:!1})+t}return""})).join("")}function ft(o,r,i,a,c,u){let d=_(o).mult(t).add(_(r).mult(n)).add(i);c&&(d=z(d,void 0===a?s[u]:Math.pow(10,9-a),c));const l=d.abs(),h=l.div(e);let f=K(l.sub(h.mult(e)).toNumber(),9);return f=void 0===a?f.replace(/0+$/,""):f.substr(0,a),[f?"."+f:"",h.toNumber()*(d.sign()||1)]}function mt(o){b(o,{epochNanoseconds(){return this[On].toBigInt()},epochMicroseconds(){return this[On].div(n).toBigInt()},epochMilliseconds(){return this[On].div(t).toNumber()},epochSeconds(){return this[On].div(e).toNumber()}})}const gt={calendar:"calendar"};for(const n of O)gt[n]="iso"+((yt=n).charAt(0).toUpperCase()+yt.slice(1));var yt;function wt(n,t=[]){b(n,F(t.concat("calendar"),(n=>function(){return this.getISOFields()[gt[n]]})))}const pt=["era","eraYear","year","month","monthCode","daysInMonth","daysInYear","monthsInYear","inLeapYear"],vt=[...pt,"day","dayOfWeek","dayOfYear","weekOfYear","daysInWeek"];function Mt(n,t){b(n,F(t,(n=>function(){const t=this.calendar[n](this);return Object.defineProperty(this,n,{value:t}),t})))}function bt(n,t){(n.prototype||n)[Symbol.toStringTag]="Temporal."+t}const St=f("offset",{prefer:0,use:1,ignore:2,reject:3});function It(n,t,e=0){const o=n.getPossibleInstantsFor(t);if(1===o.length)return o[0];if(3===e)throw new RangeError("Ambiguous offset");if(o.length)return o[2===e?1:0];{const o=function(n,t){const e=Cn(t),o=n.getOffsetNanosecondsFor(new jr(e.sub(i)));return n.getOffsetNanosecondsFor(new jr(e.add(i)))-o}(n,t),r=n.getPossibleInstantsFor(t.add({nanoseconds:o*(1===e?-1:1)}));return r[1===e?0:r.length-1]}}function Ft({year:n,month:t,day:e},o,r,i){n+=o;const s=m(t,1,r.monthsInYear(n),i);let a=t===s?e:1;return a=m(a,1,r.daysInMonth(n,s),i),{year:n,month:s,day:a}}function Tt({year:n,month:t,day:e},o,r,i){if(o){if(t+=o,o<0)for(;t<1;)t+=r.monthsInYear(--n);else{let e;for(;t>(e=r.monthsInYear(n));)t-=e,n++}e=m(e,1,r.daysInMonth(n,t),i)}return{year:n,month:t,day:e}}function Ot({isoYear:n,isoMonth:t,isoDay:e},o){if(o){let r=Yn(n,t,e);r=Hn(r,o),({isoYear:n,isoMonth:t,isoDay:e}=Zn(r))}return{isoYear:n,isoMonth:t,isoDay:e}}function Dt(n,t){if(un(t)>=6)throw new RangeError("Duration cant have units >= days");return n.add(mn(t))}function Nt(n,t,e=3,o){const{offsetNanoseconds:r,timeZone:i,Z:s}=n;if(void 0!==r&&2!==e){if(1===e||s)return Dn(n).sub(r);{const o=Yt(n,r,i,t);if(void 0!==o)return o;if(3===e)throw new RangeError("Mismatching offset/timezone")}}return It(i,Jo(n),ot(o))[On]}function Yt(n,t,e,o){const r=e.getPossibleInstantsFor(Jo(n)),i=Dn(n),s=o?$(t):t;for(const n of r){const t=n[On],e=i.sub(t).toNumber();if((o?$(e):e)===s)return t}}function Et(n){const{timeZone:t}=n,e={...n,...dn,calendar:new Ir("iso8601")},o={...Ot(e,1),...dn,calendar:new Ir("iso8601")},r=It(t,Jo(e))[On];return It(t,Jo(o))[On].sub(r).toNumber()}const Zt="([+-]\\d{6}|\\d{4})-?(\\d{2})",Ct="(\\d{2})(:?(\\d{2})(:?(\\d{2})([.,](\\d{1,9}))?)?)?",Ut="([+-])"+Ct,Pt="(Z|"+Ut+")?(\\[([^=\\]]+)\\])?(\\[u-ca=([^\\]]+)\\])?",Rt=Bt(Zt+Pt),kt=Bt("(--)?(\\d{2})-?(\\d{2})"+Pt),xt=Bt("([+-]\\d{6}|\\d{4})-?(\\d{2})-?(\\d{2})([T ](\\d{2})(:?(\\d{2})(:?(\\d{2})([.,](\\d{1,9}))?)?)?)?"+Pt),jt=Bt("T?"+Ct+Pt),qt=Bt(Ut),Ht=/^([-+])?P(\d+Y)?(\d+M)?(\d+W)?(\d+D)?(T((\d+)([.,](\d{1,9}))?H)?((\d+)([.,](\d{1,9}))?M)?((\d+)([.,](\d{1,9}))?S)?)?$/i,Lt=/\u2212/g;function Bt(n){return new RegExp(`^${n}$`,"i")}function $t(n){return n.replace(Lt,"-")}function At(n){const t=Jt(n);if(!t)throw ae("dateTime",n);return t}function zt(n){const t=Qt(n);if(!t)throw ae("dateTime",n);return t}function Wt(n){const t=_t(n);if(void 0===t)throw ae("timeZone",n);return t}function Kt(n){let t=function(n){const t=jt.exec($t(n));if(t)return te(t.slice(1))}(n);if(void 0!==t){if("T"!==n.charAt(0)){const e=Vt(n)||Xt(n);e&&function(n){try{return Kn(n,1),!0}catch(n){return!1}}(e)&&(t=void 0)}}else t=Qt(n,!0);if(void 0===t)throw ae("time",n);return t}const Gt=/^Z$/i;function Jt(n){const t=xt.exec($t(n));if(t)return function(n){const t=n[11];let e,o=!1;t&&(o=Gt.test(t),e=o?0:ee(n.slice(12)));return{...ne(n),timeZone:n[21],offsetNanoseconds:e,Z:o}}(t.slice(1))}function Qt(n,t,e){const o=xt.exec($t(n));if(o&&(e||!Gt.test(o[12]))&&(!t||o[4]))return ne(o.slice(1))}function Vt(n){const t=Rt.exec($t(n));if(t)return{calendar:(e=t.slice(1))[14],isoYear:ie(e[0]),isoMonth:ie(e[1]),isoDay:1};var e}function Xt(n){const t=kt.exec($t(n));if(t)return{calendar:(e=t.slice(1))[15],isoYear:Tn,isoMonth:ie(e[1]),isoDay:ie(e[2])};var e}function _t(n){const t=qt.exec($t(n));if(t)return ee(t.slice(1))}function ne(n){return{calendar:n[23],isoYear:ie(n[0]),isoMonth:ie(n[1]),isoDay:ie(n[2]),...te(n.slice(4))}}function te(n){const t=re(n[4]);return{...wn(oe(n[6]||""))[0],isoHour:re(n[0]),isoMinute:re(n[2]),isoSecond:60===t?59:t}}function ee(n){return("+"===n[0]?1:-1)*function(n){return re(n[0])*r+re(n[2])*o+re(n[4])*e+oe(n[6]||"")}(n.slice(1))}function oe(n){return parseInt(G(n,9,"0"))}function re(n){return parseInt(n||"0")}function ie(n){return parseInt(n||"1")}function se(n){return void 0===n?void 0:parseInt(n)}function ae(n,t){throw new RangeError(`Cannot parse ${n} '${t}'`)}function ce(n){return{...n,calendar:void 0===n.calendar?Fr():new Ir(n.calendar)}}function ue(n){return{...ce(n),timeZone:new Te(n.timeZone)}}class de{constructor(n){this.id=n}}class le extends de{constructor(n,t){super(n),this.offsetNano=t}getPossibleOffsets(){return[this.offsetNano]}getOffset(){return this.offsetNano}getTransition(){}}function he(n,t){const e={},o=n.formatToParts(t);for(const n of o)e[n.type]=n.value;return e}const fe={bc:"bce",ad:"ce"};function me(n){return n=n.toLowerCase().normalize("NFD").replace(/[^a-z0-9]/g,""),fe[n]||n}const ge=Intl.DateTimeFormat;function ye(n){return[].concat(n||[])}const we={"Pacific/Apia":{2011:[[pe(13017528e5),-36e12,-396e11],[pe(13168728e5),-396e11,-36e12],[pe(13252392e5),-36e12,504e11]]}};function pe(n){return _(n).mult(t)}const ve=(new Date).getUTCFullYear()+10,Me=[182,91,273];class be extends de{constructor(n){const t=new ge("en-GB",{era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZone:n});super(t.resolvedOptions().timeZone),this.format=t,this.yearEndOffsets={},this.transitionsInYear=we[n]||{}}getPossibleOffsets(n){let t;const o=[this.getTransition(n,-1),this.getTransition(n.sub(1),1)].filter(Boolean);for(const e of o){const[o,r,i]=e,s=n.sub(r),a=n.sub(i);if(nn(o,s)>0&&nn(o,a)>0)return[r];if(!(nn(o,s)<=0&&nn(o,a)<=0))return r<i?[]:[r,i];t=i}return void 0!==t?[t]:[this.getYearEndOffsetSec(Pn(n))*e]}getOffset(n){return this.getOffsetForEpochSecs(n.div(e).toNumber())*e}getOffsetForEpochSecs(n){const t=he(this.format,n*c);let e=parseInt(t.year);"bce"===me(t.era)&&(e=-(e-1));const o=Yn(e,parseInt(t.month),parseInt(t.day),parseInt(t.hour),parseInt(t.minute),parseInt(t.second));return Math.floor(o/c)-n}getTransition(n,t){let e=Pn(n);if(e>ve){const o=this.getTransitionFrom(e,e+t,t,n);if(o||t>0)return o;e=ve}return this.getTransitionFrom(Math.max(e,1847),t<0?1846:ve,t,n)}getTransitionFrom(n,t,e,o){for(;n!==t;n+=e){let t=this.getTransitionsInYear(n);e<0&&(t=t.slice().reverse());for(const n of t)if(nn(n[0],o)===e)return n}}getYearEndOffsetSec(n){const{yearEndOffsets:t}=this;return t[n]||(t[n]=this.getOffsetForEpochSecs(Un(n+1)-1))}getTransitionsInYear(n){const{transitionsInYear:t}=this;return t[n]||(t[n]=this.computeTransitionsInYear(n))}computeTransitionsInYear(n){const t=this.getYearEndOffsetSec(n-1),e=this.getYearEndOffsetSec(n),o=Un(n)-1,r=Un(n+1)-1;if(t!==e)return[this.searchTransition(o,r,t,e)];const i=this.searchIsland(t,o);return void 0!==i?[this.searchTransition(o,i[0],t,i[1]),this.searchTransition(i[0],r,i[1],e)]:[]}searchTransition(n,t,o,r){for(;t-n>1;){const e=Math.floor(n+(t-n)/2);this.getOffsetForEpochSecs(e)===o?n=e:t=e}return[_(t).mult(e),o*e,r*e]}searchIsland(n,t){for(const e of Me){const o=t+86400*e,r=this.getOffsetForEpochSecs(o);if(r!==n)return[o,r]}}}const Se={UTC:new le("UTC",0)};const[Ie,Fe]=M();class Te extends R{constructor(n){if(!n)throw new RangeError("Invalid timezone ID");super(),Fe(this,function(n){const t=(n=String(n)).toLocaleUpperCase();if(Se[t])return Se[t];const e=_t(n);if(void 0!==e){if(Math.abs(e)>i)throw new RangeError("Offset out of bounds");return new le(dt(e),e)}return Se[t]=new be(n)}(n))}static from(n){if(p(n))return function(n){const t=n.timeZone;if(void 0===t)return n;if(p(t)&&void 0===t.timeZone)return t;return new Te(t)}(n);const t=Jt(String(n));if(t){if(t.timeZone){const n=ue(t);return function(n){const{offsetNanoseconds:t,timeZone:e,Z:o}=n;if(void 0!==t&&!o&&void 0===Yt(n,t,e,!0))throw new RangeError("Mismatching offset/timezone")}(n),n.timeZone}if(t.Z)return new Te("UTC");if(void 0!==t.offsetNanoseconds)return new Te(dt(t.offsetNanoseconds))}return new Te(String(n))}get id(){return this.toString()}getOffsetStringFor(n){return dt(this.getOffsetNanosecondsFor(n))}getOffsetNanosecondsFor(n){const t=P(jr,n);return Ie(this).getOffset(t[On])}getPlainDateTimeFor(n,t=Fr()){const e=P(jr,n);return Jo({...En(e[On].add(this.getOffsetNanosecondsFor(e))),calendar:P(Ir,t)})}getInstantFor(n,t){return It(this,P(Go,n),ot(t))}getPossibleInstantsFor(n){const t=Dn(P(Go,n).getISOFields());return Ie(this).getPossibleOffsets(t).map((n=>new jr(t.sub(n))))}getPreviousTransition(n){const t=P(jr,n),e=Ie(this).getTransition(t[On],-1);return e?new jr(e[0]):null}getNextTransition(n){const t=P(jr,n),e=Ie(this).getTransition(t[On],1);return e?new jr(e[0]):null}toString(){return Ie(this).id}}function Oe(n){if(void 0===n.timeZone)throw new TypeError("Must specify timeZone");return P(Te,n.timeZone)}bt(Te,"TimeZone");const De=Je((function(n,t,e){const o=He(n,t,e);if(o)return{...o,timeZone:Oe(n),offsetNanoseconds:void 0!==n.offset?Wt(String(n.offset)):void 0}})),Ne=Je(He),Ye=Je(Le),Ee=Je((function(n,t){const e=Dr(n),o=We(n,Qn,e);if(Qe(o))return e.yearMonthFromFields(o,t)})),Ze=Je((function(n,t){const e=Dr(n),o=We(n,_n,e);if(Qe(o))return void 0===n.year&&void 0===n.calendar&&(o.year=Tn),e.monthDayFromFields(o,t)})),Ce=Je(Be),Ue=Je((function(n,t,e,o){const r=$e(n,t,e,o),i=void 0!==t.offset;if(r||i)return{...r||n.getISOFields(),timeZone:n.timeZone,offsetNanoseconds:i?Wt(String(t.offset)):n.offsetNanoseconds}}),!0),Pe=Je($e,!0),Re=Je(Ae,!0),ke=Je((function(n,t,e){const o=n.calendar;if(Qe(We(t,Qn,o))){const r=Ge(n,t,Qn,o);return o.yearMonthFromFields(r,e)}}),!0),xe=Je((function(n,t,e){const o=n.calendar;if(Qe(We(t,_n,o))){const r=Ge(n,t,_n,o);return o.monthDayFromFields(r,e)}}),!0),je=Je(ze,!0),qe=Je((function(n){const t=g(n,nt);if(Qe(t))return t}));function He(n,t,e){const o=Le(n,e),r=Be(n,t);if(o)return{...o.getISOFields(),...r||dn}}function Le(n,t){const e=Dr(n),o=We(n,Vn,e);if(Qe(o))return e.dateFromFields(o,t)}function Be(n,t){const e=g(n,Xn);if(Qe(e))return Jn(hn(e),t)}function $e(n,t,e,o){const r=Ae(n,t,o),i=ze(n,t,e);if(r||i)return{...n.getISOFields(),...r?r.getISOFields():{},...i}}function Ae(n,t,e){const o=n.calendar,r=We(t,Vn,o);if(Qe(r)){const t=Ge(n,r,Vn,o);return o.dateFromFields(t,e)}}function ze(n,t,e){const o=g(t,Xn);if(Qe(o)){return Jn(hn((r=n,i=o,S(Xn,((n,t)=>{var e;return null!=(e=i[t])?e:r[t]})))),e)}var r,i}function We(n,t,e){let o=Object.keys(t);return o=e.fields?Array.prototype.slice.call(e.fields(o)):Object.keys(Ke(e,o)),Ke(n,o)}function Ke(n,t){const e={};for(const o of t)void 0!==n[o]&&(e[o]=n[o]);return e}function Ge(n,t,e,o){const r=We(n,e,o);return o.mergeFields?o.mergeFields(r,t):Tr(r,t)}function Je(n,t){return(...e)=>{if(t){const n=e[1];if(!p(n))throw new TypeError("must be object-like");if(void 0!==n.calendar)throw new TypeError("calendar not allowed");if(void 0!==n.timeZone)throw new TypeError("timeZone not allowed")}const o=n(...e);if(!o)throw new TypeError("No valid fields");return o}}function Qe(n){return Object.keys(n).length>0}const Ve=i-1,Xe=_(i).mult(1e8),_e=Xe.mult(-1),no=Xe.add(Ve),to=_e.sub(Ve);function eo(n,t){const e=Dn(n);oo(e),wr(e,t)}function oo(n){-1!==nn(n,to)&&1!==nn(n,no)||jn()}function ro(n,t){const e=ao(gn(n),t),[o,r]=wn(e);return{...Ot(n,r),...o}}function io(n,t){const e=ao(gn(n),t),[o]=wn(e);return o}function so(n,t){const[e,o]=function(n){const t=En(n);return[Nn(t.isoYear,t.isoMonth,t.isoDay),gn(t)]}(n),r=ao(o,t);return e.add(r)}function ao(n,t){return B(n,t.incNano,t.roundingFunc)}function co(n,t,e){return(o,r)=>{const i=go(n,r)?{}:{...n,...t};return{buildKey:mo(o,r,!1),buildFormat:function(n,t){return new ge(o,{calendar:n,timeZone:t||void 0,...i,...r,...e})},buildEpochMilli:uo}}}function uo(n){return n.epochMilliseconds}function lo(n,t,e){return(o,r)=>{const i=go(n,r)?{}:n;return{buildKey:mo(o,r,e),buildFormat:function(n,e){return new ge(o,{calendar:n,...i,...r,...t,timeZone:e,timeZoneName:void 0})},buildEpochMilli:void 0!==r.timeZone?ho.bind(null,new Te(r.timeZone)):fo}}}function ho(n,t){const e=Jo({...dn,...t.getISOFields()});return n.getInstantFor(e).epochMilliseconds}function fo(n){return Yn((t=n.getISOFields()).isoYear,t.isoMonth,t.isoDay,t.isoHour,t.isoMinute,t.isoSecond,t.isoMillisecond);var t}function mo(n,t,e){var o;const r=null!=(o=t.calendar)?o:function(n){for(const t of n){const n=t.match(/-u-ca-(.*)$/);if(n)return n[1]}return}(n),i=t.timeZone;return function(n,t){var o,s,a,c;const u=null==(o=n.calendar)?void 0:o.id,d=null==(s=n.timeZone)?void 0:s.id;if(t){if((null==(a=t.calendar)?void 0:a.id)!==u)throw new RangeError("Mismatching calendar");if((null==(c=t.timeZone)?void 0:c.id)!==d)throw new RangeError("Mismatching timeZone")}if((e||u!==In)&&void 0!==u&&void 0!==r&&r!==u)throw new RangeError("Non-iso calendar mismatch");if(void 0!==d&&void 0!==i&&i!==d)throw new RangeError("Given timeZone must agree");return[r||u||In,i||d||"UTC"]}}function go(n,t){for(const e in n)if(void 0!==t[e])return!0;return!1}function yo(n,t){n.prototype.toLocaleString=function(n,e){const o=t(ye(n),e||{});return o.buildFormat(...o.buildKey(this)).format(o.buildEpochMilli(this))},n.prototype[U]=t}function wo(n){return null==n?void 0:n[U]}function po(n){const t=function(n){const t=Ht.exec($t(n));if(t){let n,e,o,r;[n,r]=vo(t[8],t[10],5,void 0),[e,r]=vo(t[12],t[14],4,r),[o,r]=vo(t[16],t[18],3,r);const i=function(n){const t={};for(const e in n)void 0!==n[e]&&(t[e]=n[e]);return t}({years:se(t[2]),months:se(t[3]),weeks:se(t[4]),days:se(t[5]),hours:n,minutes:e,seconds:o});if(!Object.keys(i).length)throw new RangeError("Duration string must have at least one field");const s=yn(_(r||0),2);i.milliseconds=s.milliseconds,i.microseconds=s.microseconds,i.nanoseconds=s.nanoseconds;let a=an(i);return"-"===t[1]&&(a=rn(a)),a}}(n);if(void 0===t)throw ae("duration",n);return t}function vo(n,t,o,r){if(void 0!==n){if(void 0!==r)throw new RangeError("Partial units must be last unit");return[parseInt(n),void 0!==t?oe(t)*(s[o]/e):void 0]}if(void 0!==r){const n=Math.trunc(r/s[o]);return[n,r-n*s[o]]}return[void 0,void 0]}const Mo=f("offset",{auto:0,never:1},0);class bo extends q{constructor(n=0,t=0,e=0,o=0,r=0,i=0){super({...Jn({isoHour:n,isoMinute:t,isoSecond:e,isoMillisecond:o,isoMicrosecond:r,isoNanosecond:i},1),calendar:Fr()})}static from(n,t){const e=h(t);return So(n instanceof bo?n.getISOFields():"object"==typeof n?Ce(n,e):Kt(String(n)))}static compare(n,t){return $n(P(bo,n),P(bo,t))}with(n,t){return So(je(this,n,h(t)))}add(n){return Fo(this,P(zo,n))}subtract(n){return Fo(this,rn(P(zo,n)))}until(n,t){return To(this,P(bo,n),t)}since(n,t){return To(P(bo,n),this,t)}round(n){const t=C(n,0,5);return So(io(this.getISOFields(),t))}equals(n){return!$n(this,P(bo,n))}toString(n){const t=rt(n);return ut(io(this.getISOFields(),t),t)}toZonedDateTime(n){const t=P(Zr,n.plainDate),e=P(Te,n.timeZone);return Uo({...t.getISOFields(),...this.getISOFields(),timeZone:e})}toPlainDateTime(n){return P(Zr,n).toPlainDateTime(this)}}function So(n){return new bo(n.isoHour,n.isoMinute,n.isoSecond,n.isoMillisecond,n.isoMicrosecond,n.isoNanosecond)}function Io(n){return P(bo,null!=n?n:{hour:0})}function Fo(n,t){return So(function(n,t){const e=gn(n)+mn(t).toNumber(),[o]=wn(e);return o}(n.getISOFields(),t))}function To(n,t,e){const o=Z(e,5,0,0,5);return Wo(function(n,t,e){return yn(_(B(gn(t)-gn(n),s[e.smallestUnit]*e.roundingIncrement,e.roundingFunc)),e.largestUnit)}(n.getISOFields(),t.getISOFields(),o))}bt(bo,"PlainTime"),wt(bo,T),yo(bo,(function(n,e){return{buildKey:()=>["",""],buildFormat:()=>new ge(n,{hour:"numeric",minute:"2-digit",second:"2-digit",...e,timeZone:"UTC",timeZoneName:void 0,year:void 0,month:void 0,day:void 0,weekday:void 0}),buildEpochMilli:n=>Math.trunc(gn(n.getISOFields())/t)}}));const Oo={day:1};class Do extends q{constructor(n,t,e=Fr(),o=1){const r=Kn({isoYear:n,isoMonth:t,isoDay:o},1),i=P(Ir,e);var s,a;s=r,a=i.toString(),wr(Dn(s),a),super({...r,calendar:i})}static from(n,t){if(h(t),n instanceof Do)return No(n.getISOFields());if("object"==typeof n)return Ee(n,t);const e=function(n){const t=Vt(n)||Qt(n);if(!t)throw ae("yearMonth",n);return t}(String(n));return void 0===e.calendar&&(e.isoDay=1),No(ce(e))}static compare(n,t){return Bn(P(Do,n),P(Do,t))}with(n,t){return ke(this,n,t)}add(n,t){return Yo(this,P(zo,n),t)}subtract(n,t){return Yo(this,rn(P(zo,n)),t)}until(n,t){return Eo(this,P(Do,n),!1,t)}since(n,t){return Eo(this,P(Do,n),!0,t)}equals(n){return!Bn(this,P(Do,n))}toString(n){const t=this.getISOFields(),e=t.calendar.toString(),o=et(n);return(e===In?ct(t):at(t))+lt(e,o)}toPlainDate(n){return this.calendar.dateFromFields({year:this.year,month:this.month,day:n.day})}}function No(n){return new Do(n.isoYear,n.isoMonth,n.calendar,n.isoDay)}function Yo(n,t,e){return n.toPlainDate({day:t.sign<0?n.daysInMonth:1}).add(t,e).toPlainYearMonth()}function Eo(n,t,e,o){return Wo(Rr(n.toPlainDate(Oo),t.toPlainDate(Oo),Nr(n,t),e,Z(o,9,8,8,9)))}bt(Do,"PlainYearMonth"),wt(Do),Mt(Do,pt),yo(Do,lo({year:"numeric",month:"numeric"},{weekday:void 0,day:void 0,hour:void 0,minute:void 0,second:void 0},!0));const Zo=Symbol();class Co extends q{constructor(n,t,e=Fr()){const o=P(Te,t),r=P(Ir,e),i=_(n),[s,a]=Po(i,o);eo(s,r.toString()),super({...s,calendar:r,timeZone:o,offset:dt(a)}),this[On]=i,this[Zo]=a}static from(n,t){const e=St(t,3),o=h(t);if(n instanceof Co)return new Co(n.epochNanoseconds,n.timeZone,n.calendar);const r="object"==typeof n;return Uo(r?De(n,o,t):ue(At(String(n))),!r,e,t)}static compare(n,t){return zn(P(Co,n),P(Co,t))}get timeZone(){return this.getISOFields().timeZone}get offsetNanoseconds(){return this[Zo]}get offset(){return this.getISOFields().offset}with(n,t){ot(t);const e=h(t),o=St(t,0);return Uo(Ue(this,n,e,t),!1,o,t)}withPlainDate(n){const t=P(Zr,n),e=t.toPlainDateTime(this),{timeZone:o}=this,r=It(o,e);return new Co(r.epochNanoseconds,o,Yr(this,t))}withPlainTime(n){return Uo({...this.getISOFields(),...void 0===n?dn:P(bo,n).getISOFields()})}withCalendar(n){return new Co(this.epochNanoseconds,this.timeZone,n)}withTimeZone(n){return new Co(this.epochNanoseconds,n,this.calendar)}add(n,t){return Ro(this,P(zo,n),t)}subtract(n,t){return Ro(this,rn(P(zo,n)),t)}until(n,t){return xo(this,P(Co,n),!1,t)}since(n,t){return xo(this,P(Co,n),!0,t)}round(n){return ko(this,C(n,0,6))}equals(n){return t=this,e=P(Co,n),Ln(t,e)&&t.timeZone.toString()===e.timeZone.toString();var t,e}startOfDay(){return Uo({...this.getISOFields(),...dn,offsetNanoseconds:this.offsetNanoseconds},!1,0)}get hoursInDay(){return Et(this.getISOFields())/r}toString(n){const t=rt(n),e=Mo(n),o=it(n),r=et(n),i=ko(this,t);return st(i.getISOFields(),t)+(0===e?dt($(i.offsetNanoseconds)):"")+(s=this.timeZone.toString(),1!==o?`[${s}]`:"")+lt(this.calendar.toString(),r);var s}toPlainYearMonth(){return No(this.getISOFields())}toPlainMonthDay(){return this.calendar.monthDayFromFields(this)}toPlainDateTime(){return Jo(this.getISOFields())}toPlainDate(){return Cr(this.getISOFields())}toPlainTime(){return So(this.getISOFields())}toInstant(){return new jr(this.epochNanoseconds)}}function Uo(n,t,e,o){const r=Nt(n,t,e,o);return new Co(r,n.timeZone,n.calendar)}function Po(n,t){const e=new jr(n),o=t.getOffsetNanosecondsFor(e);return[En(n.add(o)),o]}function Ro(n,t,e){const o=n.getISOFields(),r=function(n,t,e){const{calendar:o,timeZone:r}=n,i=o.dateAdd(Cr(n),sn(t,ln),e);return It(r,Jo({...n,...i.getISOFields()}))[On].add(mn(t))}(o,t,e);return new Co(r,o.timeZone,o.calendar)}function ko(n,t){const e=n.getISOFields(),o=function(n,t,e){const{calendar:o,timeZone:r}=n;let i,s,a=gn(n);return 6===e.smallestUnit?(i=dn,s=e.roundingFunc(a/Et(n))):(a=ao(a,e),[i,s]=wn(a)),Nt({...Ot(n,s),...i,offsetNanoseconds:t,calendar:o,timeZone:r},!1,0)}(e,n.offsetNanoseconds,t);return new Co(o,e.timeZone,e.calendar)}function xo(n,t,e,o){const r=Z(o,5,0,0,9),{largestUnit:i}=r;if(i>=6&&n.timeZone.id!==t.timeZone.id)throw new Error("Must be same timeZone");return Wo(Pr(n,t,Nr(n,t),e,r))}function jo(n){if(void 0===n)return;if(p(n))return n instanceof Co||n instanceof Go?n:P(void 0!==n.timeZone?Co:Go,n);if("symbol"==typeof n)throw new TypeError("Incorrect relativeTo type");const t=Jt(String(n));if(t)return void 0!==t.timeZone?Uo(ue(t),!0):Jo(ce(t));throw new RangeError("Invalid value of relativeTo")}function qo(n,t,e,o){return(e instanceof Zr?function(n,t,e,o){const r=e.add(n);return[o.dateUntil(e,r,{largestUnit:O[t]}),r]}(n,Math.max(6,t),e,o):Ho(n,t,e,o))[0]}function Ho(n,t,e,o,r){const i=!0!==r&&t>7&&n.weeks;i&&(n=sn(n,{weeks:0}));let s=e.add(n),a=kr(e,s,o,t);return i&&(a=sn(a,{weeks:i}),s=s.add({weeks:i})),[a,s]}function Lo(n,t,e,o){const r=D[t],{sign:i}=n;if(!i)return n;const s={};for(let e=9;e>=t;e--){const t=D[e];s[t]=n[t]}const a={[r]:i},c=e.add(s),u=c.add(a),d=Cn(c),l=Cn(u),h=Cn(o).sub(d).toNumber()/l.sub(d).toNumber()*i;return s[r]+=h,s}function Bo(n,t,e,o,r,i){const{largestUnit:a,smallestUnit:c,roundingIncrement:u,roundingFunc:d}=i;if(!l(a)){return yn(z(Cn(e).sub(Cn(t)).mult(r?-1:1),s[c]*u,d),a)}let h=Lo(n,c,t,e);const f=D[c];function m(){const n=h[f];h[f]=B(n,u,d)}return d===Math.round&&m(),r&&(h=rn(h)),d!==Math.round&&m(),c>0&&(h=r?rn(qo(rn(h),a,t,o)):qo(h,a,t,o)),h}bt(Co,"ZonedDateTime"),wt(Co,T),Mt(Co,vt),mt(Co),yo(Co,co({year:"numeric",month:"numeric",day:"numeric",weekday:void 0,hour:"numeric",minute:"2-digit",second:"2-digit"},{timeZoneName:"short"},{}));const[$o,Ao]=M();class zo extends k{constructor(n=0,t=0,e=0,o=0,r=0,i=0,s=0,a=0,c=0,u=0){super();const d=qe({years:n,months:t,weeks:e,days:o,hours:r,minutes:i,seconds:s,milliseconds:a,microseconds:c,nanoseconds:u});Ao(this,function(n){const t=an(n),{sign:e}=t;for(const n of D){const o=t[n],r=L(t[n]);if(r&&r!==e)throw new RangeError("All fields must be same sign");if(!Number.isInteger(o))throw new RangeError("Duration fields must be integers")}return t}(d))}static from(n){return Wo("object"==typeof n?qe(n):po(n))}static compare(n,t,e){return function(n,t,e){if(void 0===e&&un(n)<=6&&un(t)<=6)return nn(fn(n),fn(t));if(!e)throw new RangeError("Need relativeTo");const o=e.add(n),r=e.add(t);return void 0!==e[On]?zn(o,r):Bn(o,r)}(P(zo,n),P(zo,t),jo(y(e).relativeTo))}get years(){return $o(this).years}get months(){return $o(this).months}get weeks(){return $o(this).weeks}get days(){return $o(this).days}get hours(){return $o(this).hours}get minutes(){return $o(this).minutes}get seconds(){return $o(this).seconds}get milliseconds(){return $o(this).milliseconds}get microseconds(){return $o(this).microseconds}get nanoseconds(){return $o(this).nanoseconds}get sign(){return $o(this).sign}get blank(){return!this.sign}with(n){return Wo({...$o(this),...qe(n)})}negated(){return Wo(rn($o(this)))}abs(){return Wo(I($o(this),on,(n=>Math.abs(n))))}add(n,t){return Ko(this,P(zo,n),t)}subtract(n,t){return Ko(this,rn(P(zo,n)),t)}round(n){const t="string"==typeof n?{smallestUnit:n}:n;if(!p(t))throw new TypeError("Must specify options");if(void 0===t.largestUnit&&void 0===t.smallestUnit)throw new RangeError("Must specify either largestUnit or smallestUnit");const e=Z(t,un(this),0,0,9,!0),o=jo(t.relativeTo);return Wo(function(n,t,e,o){const{largestUnit:r,smallestUnit:i,roundingIncrement:a,roundingFunc:c}=t;if(void 0===e&&un(n)<=6&&d(r)&&d(i))return yn(z(fn(n),s[i]*a,c),r);if(!e)throw new RangeError("Need relativeTo");const[u,l]=Ho(n,r,e,o);return Bo(u,e,l,o,!1,t)}(this,e,o,o?o.calendar:void 0))}total(n){const t=function(n){let t,e;return"string"==typeof n?e=n:(e=y(n).unit,t=n.relativeTo),{unit:E(e,void 0,0,9),relativeTo:t}}(n),e=jo(t.relativeTo);return function(n,t,e,o){if(void 0===e&&un(n)<=6&&d(t))return fn(n).toNumber()/s[t];if(!e)throw new RangeError("Need relativeTo");const[r,i]=Ho(n,t,e,o,!0);return Lo(r,t,e,i)[D[t]]}(this,t.unit,e,e?e.calendar:void 0)}toString(n){const t=rt(n,3);return function(n,t){const{smallestUnit:e,fractionalSecondDigits:o,roundingFunc:r}=t,{sign:i}=n,s=n.hours,a=n.minutes;let c=n.seconds,u="";if(e<=3){const t=ft(n.milliseconds,n.microseconds,n.nanoseconds,o,r,e);u=t[0],c+=t[1]}const d=void 0!==o||u||!i;return(i<0?"-":"")+"P"+ht([[n.years,"Y"],[n.months,"M"],[n.weeks,"W"],[n.days,"D"]])+(s||a||c||d?"T"+ht([[s,"H"],[a,"M"],[e<=3?c:0,u+"S",d]]):"")}($o(this),t)}toLocaleString(n,t){return this.toString()}}function Wo(n){return new zo(n.years,n.months,n.weeks,n.days,n.hours,n.minutes,n.seconds,n.milliseconds,n.microseconds,n.nanoseconds)}function Ko(n,t,e){const o=jo(y(e).relativeTo);return Wo(function(n,t,e,o){const r=Math.max(un(n),un(t));if(void 0===e&&r<=6)return yn(fn(n).add(fn(t)),r);if(!e)throw new RangeError("Need relativeTo");const i=e.add(n).add(t);return kr(e,i,o,r)}(n,t,o,o?o.calendar:void 0))}bt(zo,"Duration");class Go extends q{constructor(n,t,e,o=0,r=0,i=0,s=0,a=0,c=0,u=Fr()){const d=Gn({isoYear:n,isoMonth:t,isoDay:e,isoHour:o,isoMinute:r,isoSecond:i,isoMillisecond:s,isoMicrosecond:a,isoNanosecond:c},1),l=P(Ir,u);eo(d,l.toString()),super({...d,calendar:l})}static from(n,t){const e=h(t);return Jo(n instanceof Go?n.getISOFields():"object"==typeof n?Ne(n,e,t):ce(zt(String(n))))}static compare(n,t){return Bn(P(Go,n),P(Go,t))}with(n,t){const e=h(t);return Jo(Pe(this,n,e,t))}withPlainDate(n){const t=P(Zr,n);return Jo({...this.getISOFields(),...t.getISOFields(),calendar:Yr(this,t)})}withPlainTime(n){return Jo({...this.getISOFields(),...Io(n).getISOFields()})}withCalendar(n){return Jo({...this.getISOFields(),calendar:P(Ir,n)})}add(n,t){return Qo(this,P(zo,n),t)}subtract(n,t){return Qo(this,rn(P(zo,n)),t)}until(n,t){return Vo(this,P(Go,n),!1,t)}since(n,t){return Vo(this,P(Go,n),!0,t)}round(n){const t=C(n,0,6);return Jo({...ro(this.getISOFields(),t),calendar:this.calendar})}equals(n){return Ln(this,P(Go,n))}toString(n){const t=rt(n),e=et(n);return st(ro(this.getISOFields(),t),t)+lt(this.calendar.toString(),e)}toZonedDateTime(n,t){const e=P(Te,n),o=It(e,this,ot(t));return new Co(o.epochNanoseconds,e,this.calendar)}toPlainYearMonth(){return No(this.getISOFields())}toPlainMonthDay(){return this.calendar.monthDayFromFields(this)}toPlainDate(){return Cr(this.getISOFields())}toPlainTime(){return So(this.getISOFields())}}function Jo(n){return new Go(n.isoYear,n.isoMonth,n.isoDay,n.isoHour,n.isoMinute,n.isoSecond,n.isoMillisecond,n.isoMicrosecond,n.isoNanosecond,n.calendar)}function Qo(n,t,e){const o=function(n,t,e){const{calendar:o}=n;return En(Dn(o.dateAdd(Cr(n),sn(t,ln),e).getISOFields()).add(gn(n)).add(mn(t)))}(n.getISOFields(),t,e);return Jo({...o,calendar:n.calendar})}function Vo(n,t,e,o){const r=Z(o,6,0,0,9);return Wo(Pr(n,t,Nr(n,t),e,r))}bt(Go,"PlainDateTime"),wt(Go,T),Mt(Go,vt),yo(Go,lo({year:"numeric",month:"numeric",day:"numeric",weekday:void 0,hour:"numeric",minute:"2-digit",second:"2-digit"},{}));class Xo extends q{constructor(n,t,e=Fr(),o=Tn){super({...Kn({isoYear:o,isoMonth:n,isoDay:t},1),calendar:P(Ir,e)})}static from(n,t){if(h(t),n instanceof Xo)return _o(n.getISOFields());if("object"==typeof n)return Ze(n,t);const e=function(n){const t=Xt(n)||Qt(n);if(!t)throw ae("monthDay",n);return t}(String(n));return void 0===e.calendar&&(e.isoYear=Tn),_o(ce(e))}with(n,t){return xe(this,n,t)}equals(n){return!Bn(this,P(Xo,n))}toString(n){const t=this.getISOFields(),e=t.calendar.toString(),o=et(n);return(e===In?function(n){return K(n.isoMonth,2)+"-"+K(n.isoDay,2)}(t):at(t))+lt(e,o)}toPlainDate(n){return this.calendar.dateFromFields({year:n.year,monthCode:this.monthCode,day:this.day},{overflow:"reject"})}}function _o(n){return new Xo(n.isoMonth,n.isoDay,n.calendar,n.isoYear)}function nr(n){return n instanceof Zr||n instanceof Go||n instanceof Co||n instanceof Do||n instanceof Xo}function tr(n,t,e){let o;if(n instanceof Zr)o=n;else if(nr(n)){if(e&&n instanceof Xo)throw new TypeError("PlainMonthDay not allowed");o=Cr(n.getISOFields())}else o=Zr.from(n);return Er(o.calendar,t),o}function er(n,t,e){if(nr(n))return n.getISOFields();let{era:o,eraYear:r,year:i,month:s,monthCode:a,day:c}=n;const u=void 0!==r&&void 0!==o?Mn(t.id,r,o):void 0;if(void 0===i){if(void 0===u)throw new TypeError("Must specify either a year or an era & eraYear");i=u}else if(void 0!==u&&u!==i)throw new RangeError("year and era/eraYear must match");if(void 0===c)throw new TypeError("Must specify day");const d=h(e);if(void 0!==a){const[n,e]=t.convertMonthCode(a,i);if(void 0!==s&&s!==n)throw new RangeError("Month doesnt match with monthCode");if(s=n,e){if(1===d)throw new RangeError("Month code out of range");c=t.daysInMonth(i,s)}}else if(void 0===s)throw new TypeError("Must specify either a month or monthCode");return[i,s,c]=Wn(i,s,c,t,d),Zn(t.epochMilliseconds(i,s,c))}function or(n,t){if(nr(n)){if(t&&n instanceof Xo)throw new TypeError("PlainMonthDay not allowed");return n.getISOFields()}return Zr.from(n).getISOFields()}function rr(n,t){return qn(n.epochMilliseconds(t,1,1),n.epochMilliseconds(t+1,1,1))}function ir(n,t,e,o){return qn(n.epochMilliseconds(t,1,1),n.epochMilliseconds(t,e,o))+1}bt(Xo,"PlainMonthDay"),wt(Xo),Mt(Xo,["monthCode","day"]),yo(Xo,lo({month:"numeric",day:"numeric"},{weekday:void 0,year:void 0,hour:void 0,minute:void 0,second:void 0},!0));const sr={hebrew:6,chinese:0,dangi:0};class ar extends vn{constructor(n){const t=cr(n);if(e=n,o=t.resolvedOptions().calendar,bn(e)!==bn(o))throw new RangeError("Invalid calendar: "+n);var e,o;super(n),this.format=t,this.yearCorrection=this.computeFieldsDumb(0).year-1970,this.monthCacheByYear={}}epochMilliseconds(n,t,e){return Hn(this.queryMonthCache(n)[0][t-1],e-1)}daysInMonth(n,t){const e=this.queryMonthCache(n)[0],o=e[t-1];t>=e.length&&(n++,t=0);return qn(o,this.queryMonthCache(n)[0][t])}monthsInYear(n){return this.queryMonthCache(n)[0].length}monthCode(n,t){const e=this.queryLeapMonthByYear(t);return!e||n<e?super.monthCode(n,t):super.monthCode(n-1,t)+(n===e?"L":"")}convertMonthCode(n,t){const e=this.queryLeapMonthByYear(t);let o=/L$/.test(n),r=parseInt(n.substr(1)),i=!1;if(o){const n=sr[this.id];if(void 0===n)throw new RangeError("Calendar system doesnt support leap months");if(n){if(r!==n-1)throw new RangeError("Invalid leap-month month code")}else if(r<=1||r>=12)throw new RangeError("Invalid leap-month month code")}return!o||e&&r===e-1||(i=!0,o=!1),(o||e&&r>=e)&&r++,[r,i]}inLeapYear(n){const t=rr(this,n);return t>rr(this,n-1)&&t>rr(this,n+1)}guessYearForMonthDay(n,t){let e=1970+this.yearCorrection;const o=e+100;for(;e<o;e++){const[o,r]=this.convertMonthCode(n,e);if(!r&&o<=this.monthsInYear(e)&&t<=this.daysInMonth(e,o))return e}throw new Error("Could not guess year")}normalizeISOYearForMonthDay(n){return n}computeFields(n){const t=this.computeFieldsDumb(n),e=this.queryMonthCache(t.year)[2];return{...t,month:e[t.month]}}computeFieldsDumb(n){const t=he(this.format,n);let e,o,r=parseInt(t.relatedYear||t.year);var i;return t.era&&(i=this.id,void 0!==pn[bn(i)])&&(e=me(t.era),o=r,r=Mn(this.id,o,e,!0)),{era:e,eraYear:o,year:r,month:t.month,day:parseInt(t.day)}}queryLeapMonthByYear(n){const t=this.queryMonthCache(n),e=this.queryMonthCache(n-1),o=this.queryMonthCache(n+1);if(t[0].length>e[0].length&&t[0].length>o[0].length){const n=t[1],o=e[1];for(let t=0;t<o.length;t++)if(o[t]!==n[t])return t+1}}queryMonthCache(n){const{monthCacheByYear:t}=this;return t[n]||(t[n]=this.buildMonthCache(n))}buildMonthCache(n){const t=[],e=[],o={};let r=Yn(this.guessISOYear(n),1,1);for(r=Hn(r,400);;){const o=this.computeFieldsDumb(r);if(o.year<n)break;r=Hn(r,1-o.day),o.year===n&&(t.unshift(r),e.unshift(o.month)),r=Hn(r,-1)}for(let n=0;n<e.length;n++)o[e[n]]=n+1;return[t,e,o]}guessISOYear(n){return n-this.yearCorrection}}function cr(n){return new ge("en-US",{calendar:n,era:"short",year:"numeric",month:"short",day:"numeric",timeZone:"UTC"})}const ur=Yn(1868,9,8);const dr={gregory:tt,japanese:class extends tt{constructor(){super(...arguments),this.format=cr("japanese")}computeFields(n){const t=super.computeFields(n);if(n>=ur){const e=he(this.format,n);t.era=me(e.era),t.eraYear=parseInt(e.relatedYear||e.year)}return t}},islamic:class extends ar{guessISOYear(n){return Math.ceil(32*n/33+622)}}},lr={[In]:Fn};function hr(n){const t=(n=String(n)).toLocaleLowerCase();return lr[t]||(lr[t]=new(dr[bn(t)]||ar)(n))}const fr=Yn(1582,10,15),mr=Yn(622,7,18),gr={buddhist:fr,japanese:fr,roc:fr,islamic:mr,"islamic-rgsa":mr,indian:0},yr={};function wr(n,e){return pr(n.div(t).toNumber(),e)}function pr(n,t){if(function(n,t){return function(n){let t=yr[n];if(void 0===t){const e=gr[n];if(void 0===e)t=!1;else{let o=hr(n);o instanceof ar||(o=new ar(n));const r=e-a,i=o.computeFields(r);t=r!==o.epochMilliseconds(i.year,i.month,i.day)}yr[n]=t}return t}(t)&&n<gr[t]}(n,t))throw new RangeError("Invalid timestamp for calendar")}function vr(n,t,e){const o=7+t-e;return-W(Rn(n,1,o)-t,7)+o-1}function Mr(n,t,e){const o=vr(n,t,e),r=vr(n+1,t,e);return(rr(Fn,n)-o+r)/7}const[br,Sr]=M();class Ir extends R{constructor(n){super(),"islamicc"===n&&(n="islamic-civil"),Sr(this,hr(n))}static from(n){if(p(n))return function(n){const t=n.calendar;if(void 0===t)return n;if(p(t)&&void 0===t.calendar)return t;return new Ir(t)}(n);const t=Qt(String(n),!1,!0);return new Ir(t?t.calendar||In:String(n))}get id(){return this.toString()}era(n){const t=or(n,!0);return Or(br(this),t.isoYear,t.isoMonth,t.isoDay).era}eraYear(n){const t=or(n,!0);return Or(br(this),t.isoYear,t.isoMonth,t.isoDay).eraYear}year(n){const t=or(n,!0);return Or(br(this),t.isoYear,t.isoMonth,t.isoDay).year}month(n){const t=or(n,!0);return Or(br(this),t.isoYear,t.isoMonth,t.isoDay).month}monthCode(n){const t=tr(n,this);return br(this).monthCode(t.month,t.year)}day(n){const t=or(n);return Or(br(this),t.isoYear,t.isoMonth,t.isoDay).day}dayOfWeek(n){const t=or(n,!0);return Rn(t.isoYear,t.isoMonth,t.isoDay)}dayOfYear(n){const t=tr(n,this,!0);return ir(br(this),t.year,t.month,t.day)}weekOfYear(n){const t=or(n,!0);return function(n,t,e,o,r){const i=vr(n,o,r),s=Math.floor((ir(Fn,n,t,e)-i-1)/7)+1;if(s<1)return s+Mr(n-1,o,r);const a=Mr(n,o,r);return s>a?s-a:s}(t.isoYear,t.isoMonth,t.isoDay,1,4)}daysInWeek(n){return or(n,!0),7}daysInMonth(n){const t=tr(n,this,!0);return br(this).daysInMonth(t.year,t.month)}daysInYear(n){const t=tr(n,this,!0);return rr(br(this),t.year)}monthsInYear(n){const t=tr(n,this,!0);return br(this).monthsInYear(t.year)}inLeapYear(n){return br(this).inLeapYear(this.year(n))}dateFromFields(n,t){const e=er(g(n,Vn),br(this),t);return new Zr(e.isoYear,e.isoMonth,e.isoDay,this)}yearMonthFromFields(n,t){const e=er({...g(n,Qn),day:1},br(this),t);return new Do(e.isoYear,e.isoMonth,this,e.isoDay)}monthDayFromFields(n,t){const e=br(this);let{era:o,eraYear:r,year:i,month:s,monthCode:a,day:c}=g(n,_n);if(void 0===c)throw new TypeError("required property 'day' missing or undefined");if(void 0!==a?i=Tn:void 0!==o&&void 0!==r&&(i=Mn(e.id,r,o)),void 0===i){if(void 0===a)throw new TypeError("either year or monthCode required with month");i=e.guessYearForMonthDay(a,c)}const u=er({year:i,month:s,monthCode:a,day:c},e,t);return new Xo(u.isoMonth,u.isoDay,this,e.normalizeISOYearForMonthDay(u.isoYear))}dateAdd(n,t,e){const o=br(this),r=function(n,t,e,o){n=Tt(n=Ft(n,t.years,e,o),t.months,e,o);let r=e.epochMilliseconds(n.year,n.month,n.day);const s=Math.trunc(mn(t).div(i).toNumber());return r=Hn(r,7*t.weeks+t.days+s),Zn(r)}(P(Zr,n,e),P(zo,t),o,h(e));return new Zr(r.isoYear,r.isoMonth,r.isoDay,this)}dateUntil(n,t,e){const o=br(this),r=P(Zr,n),i=P(Zr,t),s=y(e).largestUnit,a="auto"===s?6:E(s,6,6,9);return Er(this,Nr(r,i)),Wo(function(n,t,e,o){let r=0,i=0,s=0,a=0;switch(o){case 9:r=function(n,t,e){const[,o,r]=Wn(t.year,n.month,n.day,e,0),i=An(t,n),s=H(t.month,o)||H(t.day,r);return t.year-n.year-(s&&i&&s!==i?i:0)}(n,t,e),n=Ft(n,r,e,0);case 8:i=function(n,t,e){let o=0;const r=An(t,n);if(r){let{year:i}=n;for(;i!==t.year;)o+=e.monthsInYear(i)*r,i+=r;const[,s,a]=Wn(t.year,n.month,n.day,e,0);o+=t.month-s;const c=H(t.day,a);c&&r&&c!==r&&(o-=r)}return o}(n,t,e),n=Tt(n,i,e,0)}a=qn(e.epochMilliseconds(n.year,n.month,n.day),e.epochMilliseconds(t.year,t.month,t.day)),7===o&&(s=Math.trunc(a/7),a%=7);return an({years:r,months:i,weeks:s,days:a,hours:0,minutes:0,seconds:0,milliseconds:0,microseconds:0,nanoseconds:0})}(r,i,o,a))}fields(n){return n.slice()}mergeFields(n,t){return Tr(n,t)}toString(){return br(this).id}}function Fr(){return new Ir(In)}function Tr(n,t){var e;const o={...n,...t};if(void 0!==n.year){delete o.era,delete o.eraYear,delete o.year;let e=!1;void 0===t.era&&void 0===t.eraYear||(o.era=t.era,o.eraYear=t.eraYear,e=!0),void 0!==t.year&&(o.year=t.year,e=!0),e||(o.year=n.year)}if(void 0!==n.monthCode){delete o.monthCode,delete o.month;let e=!1;void 0!==t.month&&(o.month=t.month,e=!0),void 0!==t.monthCode&&(o.monthCode=t.monthCode,e=!0),e||(o.monthCode=n.monthCode)}return void 0!==n.day&&(o.day=null!=(e=t.day)?e:n.day),o}function Or(n,t,e,o){const r=Yn(t,e,o);return pr(r,n.id),n.computeFields(r)}function Dr(n){return void 0===n.calendar?Fr():P(Ir,n.calendar)}function Nr(n,t){const{calendar:e}=n;return Er(e,t.calendar),e}function Yr(n,t){const e=n.calendar,o=t.calendar;if(e.id===In)return o;if(o.id===In)return e;if(e.id!==o.id)throw new RangeError("Non-ISO calendars incompatible");return e}function Er(n,t){if(n.toString()!==t.toString())throw new RangeError("Calendars must match")}bt(Ir,"Calendar");class Zr extends q{constructor(n,t,e,o=Fr()){const r=Kn({isoYear:n,isoMonth:t,isoDay:e},1),i=P(Ir,o);!function(n,t){const e=Dn(n);oo(e.add(e.sign()<0?Ve:0)),wr(e,t)}(r,i.toString()),super({...r,calendar:i})}static from(n,t){return h(t),n instanceof Zr?Cr(n.getISOFields()):"object"==typeof n?Ye(n,t):Cr(ce(zt(String(n))))}static compare(n,t){return Bn(P(Zr,n),P(Zr,t))}with(n,t){return Re(this,n,t)}withCalendar(n){const t=this.getISOFields();return new Zr(t.isoYear,t.isoMonth,t.isoDay,n)}add(n,t){return this.calendar.dateAdd(this,n,t)}subtract(n,t){return this.calendar.dateAdd(this,P(zo,n).negated(),t)}until(n,t){return Ur(this,P(Zr,n),!1,t)}since(n,t){return Ur(this,P(Zr,n),!0,t)}equals(n){return!Bn(this,P(Zr,n))}toString(n){const t=et(n),e=this.getISOFields();return at(e)+lt(e.calendar.toString(),t)}toZonedDateTime(n){const t=function(n){let t,e;if("string"==typeof n)e=n;else{if("object"!=typeof n)throw new TypeError("Invalid options/timeZone argument");if(void 0!==n.id?e=n:(e=n.timeZone,t=n.plainTime),void 0===e)throw new TypeError("Invalid timeZone argument")}return{plainTime:t,timeZone:e}}(n),e=P(Te,t.timeZone),o=void 0===t.plainTime?void 0:P(bo,t.plainTime);return Uo({...this.getISOFields(),...o?o.getISOFields():dn,timeZone:e})}toPlainDateTime(n){return Jo({...this.getISOFields(),...Io(n).getISOFields()})}toPlainYearMonth(){return No(this.getISOFields())}toPlainMonthDay(){return this.calendar.monthDayFromFields(this)}}function Cr(n){return new Zr(n.isoYear,n.isoMonth,n.isoDay,n.calendar)}function Ur(n,t,e,o){return Wo(Rr(n,t,Nr(n,t),e,Z(o,6,6,6,9)))}function Pr(n,t,e,o,r){return Bo(kr(n,t,e,r.largestUnit),n,t,e,o,r)}function Rr(n,t,e,o,r){return Bo(e.dateUntil(n,t,{largestUnit:O[r.largestUnit]}),n,t,e,o,r)}function kr(n,t,e,o){if(!l(o))return xr(n,t,o);const r=Cr({...n.getISOFields(),calendar:e});let i,s,a,c,u,d=Cr({...t.getISOFields(),calendar:e});do{s=e.dateUntil(r,d,{largestUnit:O[o]}),i=n.add(s),a=xr(i,t,5),c=s.sign,u=a.sign}while(c&&u&&c!==u&&(d=d.add({days:u})));return f=a,{sign:(h=s).sign||f.sign,years:h.years+f.years,months:h.months+f.months,weeks:h.weeks+f.weeks,days:h.days+f.days,hours:h.hours+f.hours,minutes:h.minutes+f.minutes,seconds:h.seconds+f.seconds,milliseconds:h.milliseconds+f.milliseconds,microseconds:h.microseconds+f.microseconds,nanoseconds:h.nanoseconds+f.nanoseconds};var h,f}function xr(n,t,e){return yn(Cn(t).sub(Cn(n)),e)}bt(Zr,"PlainDate"),wt(Zr),Mt(Zr,vt),yo(Zr,lo({year:"numeric",month:"numeric",day:"numeric",weekday:void 0},{hour:void 0,minute:void 0,second:void 0}));class jr extends k{constructor(n){super();const t=_(n,!0);!function(n){-1!==nn(n,_e)&&1!==nn(n,Xe)||jn()}(t),this[On]=t}static from(n){if(n instanceof jr)return new jr(n.epochNanoseconds);const t=At(String(n)),e=t.offsetNanoseconds;if(void 0===e)throw new RangeError("Must specify an offset");return new jr(Dn(Gn(t,1)).sub(e))}static fromEpochSeconds(n){return new jr(_(n).mult(e))}static fromEpochMilliseconds(n){return new jr(_(n).mult(t))}static fromEpochMicroseconds(t){return new jr(t*BigInt(n))}static fromEpochNanoseconds(n){return new jr(n)}static compare(n,t){return zn(P(jr,n),P(jr,t))}add(n){return new jr(Dt(this[On],P(zo,n)))}subtract(n){return new jr(Dt(this[On],rn(P(zo,n))))}until(n,t){return qr(this,P(jr,n),t)}since(n,t){return qr(P(jr,n),this,t)}round(n){const t=C(n,0,5,!0);return new jr(so(this[On],t))}equals(n){return!zn(this,P(jr,n))}toString(n){const t=y(n).timeZone;return this.toZonedDateTimeISO(null!=t?t:"UTC").toString({...n,offset:void 0===t?"never":"auto",timeZoneName:"never"})+(void 0===t?"Z":"")}toZonedDateTimeISO(n){return new Co(this.epochNanoseconds,n)}toZonedDateTime(n){if(!p(n))throw new TypeError("Must specify options");if(void 0===n.calendar)throw new TypeError("Must specify a calendar");if(void 0===n.timeZone)throw new TypeError("Must specify a timeZone");return new Co(this.epochNanoseconds,n.timeZone,n.calendar)}}function qr(n,t,e){const o=Z(e,3,0,0,5);return Wo(function(n,t,e){return yn(z(t.sub(n),s[e.smallestUnit]*e.roundingIncrement,e.roundingFunc),e.largestUnit)}(n[On],t[On],o))}function Hr(){return jr.fromEpochMilliseconds(this.valueOf())}bt(jr,"Instant"),mt(jr),yo(jr,co({year:"numeric",month:"numeric",day:"numeric",weekday:void 0,hour:"numeric",minute:"2-digit",second:"2-digit"},{timeZoneName:void 0},{}));const Lr=Symbol(),Br=Symbol(),$r=Symbol();class Ar extends Intl.DateTimeFormat{constructor(n,t){const e=ye(n),o=function(n){const t={};for(const e in n){let o=n[e];p(o)&&(o=o.toString()),t[e]=o}return t}(t||{});super(e,o),this[Lr]=e,this[Br]=o,this[$r]=new Map}format(n){const t=Wr(this,n);return t[0]===this?super.format(t[1]):t[0].format(t[1])}formatToParts(n){return super.formatToParts.call(...Wr(this,n))}formatRange(n,t){return super.formatRange.call(...Kr(this,n,t))}formatRangeToParts(n,t){return super.formatRangeToParts.call(...Kr(this,n,t))}}const zr=Ar;function Wr(n,t){const e=wo(t);if(e){const o=Gr(n,e);return[o.buildFormat(t),o.buildEpochMilli(t)]}return[n,t]}function Kr(n,t,e){const o=wo(t);if(o!==wo(e))throw new TypeError("Mismatch of types");if(o){const r=Gr(n,o);return[r.buildFormat(t,e),new Date(r.buildEpochMilli(t)),new Date(r.buildEpochMilli(e))]}return[n,t,e]}function Gr(n,t){const e=n[$r];let o=e.get(t);return o||(o=function(n){const t={};return{buildFormat:function(e,o){const r=n.buildKey(e,o),i=r.join("|");return t[i]||(t[i]=n.buildFormat(...r))},buildEpochMilli:n.buildEpochMilli}}(t(n[Lr],n[Br])),e.set(t,o)),o}const Jr={zonedDateTimeISO:function(n){return Uo(Vr(In,n))},zonedDateTime:function(n,t){return Uo(Vr(n,t))},plainDateTimeISO:function(n){return Jo(Vr(In,n))},plainDateTime:function(n,t){return Jo(Vr(n,t))},plainDateISO:function(n){return Cr(Vr(In,n))},plainDate:function(n,t){return Cr(Vr(n,t))},plainTimeISO:function(n){return So(Vr(In,n))},instant:function(){return new jr(Xr())},timeZone:Qr};bt(Jr,"Now");function Qr(){return new Te((new ge).resolvedOptions().timeZone)}function Vr(n,t=Qr()){const e=P(Te,t);return{...Po(Xr(),e)[0],timeZone:e,calendar:P(Ir,n)}}function Xr(){return _(Date.now()).mult(t)}const _r={PlainYearMonth:Do,PlainMonthDay:Xo,PlainDate:Zr,PlainTime:bo,PlainDateTime:Go,ZonedDateTime:Co,Instant:jr,Calendar:Ir,TimeZone:Te,Duration:zo,Now:Jr,[Symbol.toStringTag]:"Temporal"};!function(){const n="undefined"!=typeof globalThis?globalThis:window;n.Temporal||(n.Temporal=_r,Intl.DateTimeFormat=zr,Date.prototype.toTemporalInstant=Hr)}()}();
//# sourceMappingURL=global.js.map

@@ -1,1 +0,1 @@

export * from './dist/global.d.ts'
export * from './dist/global'
{
"name": "temporal-polyfill",
"version": "0.0.7",
"version": "0.0.8",
"title": "Temporal Polyfill",

@@ -55,3 +55,3 @@ "description": "A spec-compliant Temporal JavaScript polyfill in 16kb",

"dependencies": {
"temporal-spec": "0.0.2"
"temporal-spec": "0.0.3"
},

@@ -58,0 +58,0 @@ "devDependencies": {

# temporal-polyfill
A spec-compliant [Temporal] JavaScript polyfill in 16kb<super>*</super>.
A spec-compliant [Temporal] JavaScript polyfill in 16kb.
Works in modern browsers<super>**</super>, not Internet Explorer.
[Codepen](https://codepen.io/arshaw/pen/VwrMQPJ?editors=1111)
[CDN link](https://cdn.jsdelivr.net/npm/temporal-polyfill@0.0.7/dist/global.js)
[CDN link](https://cdn.jsdelivr.net/npm/temporal-polyfill@0.0.8/dist/global.js)
<!-- NOTE: when updating this link, update the codepen too -->
## Browser Support
| Minimum required version if... | Chrome | Edge | Safari | Safari iOS | Firefox | Node |
| --- | --- | --- | --- | --- | --- | --- |
| ...transpiling to target environment | 36 (Jul 2014) | 14 (Aug 2016) | 10 (Sep 2016) | 10 (Sep 2016) | 52 (Mar 2017) | 12 (Apr 2019) |
| ...leaving untranspiled | 60 (Jul 2017) | 79 (Jan 2020) | 11.1 (Mar 2018) | 11.3 (Mar 2018) | 55 (Aug 2017) | 12 (Apr 2019) |
| ...using BigInt features | 67 (May 2018) | 79 (Jan 2020) | 14 (Sep 2020) | 14 (Sep 2020) | 68 (July 2019) | 12 (Apr 2019) |
## BigInt Considerations
This polyfill works fine in environments without [BigInt]. However, without BigInt, the following will throw errors:
| ❌ Avoid microseconds/nanoseconds | ✅ Use milliseconds instead |
| -------------------------------- | --------------------------- |
| `instant.epochMicroseconds` | `instant.epochMilliseconds` |
| `instant.epochNanoseconds` | `instant.epochMilliseconds` |
| `Temporal.Instant.fromEpochMicroseconds(micro)` | `Temporal.Instant.fromEpochMilliseconds(milli)` |
| `Temporal.Instant.fromEpochNanoseconds(nano)` | `Temporal.Instant.fromEpochMilliseconds(milli)` |
| `new Temporal.Instant(nano)` | `Temporal.Instant.fromEpochMilliseconds(milli)` |
| `zonedDateTime.epochMicroseconds` | `zonedDateTime.epochMilliseconds` |
| `zonedDateTime.epochNanoseconds` | `zonedDateTime.epochMilliseconds` |
| `new Temporal.ZonedDateTime(nano, tz, cal)` | `Temporal.Instant.fromEpochMilliseconds(milli).toZonedDateTimeISO()` |
| | `Temporal.Instant.fromEpochMilliseconds(milli).toZonedDateTime(cal)` |
FYI, it is not possible to properly polyfill BigInt. [More Information][JSBI-why]
## Installation

@@ -44,9 +71,5 @@

<super>*</super> = the size will shrink as the codebase is cleaned up
<super>**</super> = targets browsers that support [BigInt], however, more browser-compatibility
work is needed
[Temporal]: https://github.com/tc39/proposal-temporal
[BigInt]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt
[JSBI-why]: https://github.com/GoogleChromeLabs/jsbi#why

@@ -1,1 +0,1 @@

export * from './dist/shim.d.ts'
export * from './dist/shim'
import { isoToEpochMilli } from '../dateUtils/epoch'
import { milliInDay, nanoInMilliBI } from '../dateUtils/units'
import { milliInDay, nanoInMilli } from '../dateUtils/units'
import { LargeInt } from '../utils/largeInt'
import { queryCalendarImpl } from './calendarImplQuery'

@@ -23,4 +24,4 @@ import { IntlCalendarImpl } from './intlCalendarImpl'

export function checkEpochNanoBuggy(epochNano: bigint, calendarID: string): void {
return checkEpochMilliBuggy(Number(epochNano / nanoInMilliBI), calendarID)
export function checkEpochNanoBuggy(epochNano: LargeInt, calendarID: string): void {
return checkEpochMilliBuggy(epochNano.div(nanoInMilli).toNumber(), calendarID)
}

@@ -27,0 +28,0 @@

import { Temporal } from 'temporal-spec'
import { LargeInt, compareLargeInts } from '../utils/largeInt'
import { compareValues } from '../utils/math'

@@ -6,3 +7,3 @@ import { durationDayTimeToNano, isoTimeToNano } from './dayAndTime'

import { DurationFields, computeLargestDurationUnit } from './durationFields'
import { EpochableFields, isoFieldsToEpochNano } from './epoch'
import { EpochableFields, epochNanoSymbol, isoFieldsToEpochNano } from './epoch'
import { ISOTimeFields } from './isoFields'

@@ -21,3 +22,3 @@ import { LocalDateFields } from './localFields'

export interface ComparableEpochObj {
epochNanoseconds: bigint
[epochNanoSymbol]: LargeInt
}

@@ -48,3 +49,3 @@

): Temporal.ComparisonResult {
return compareValues(
return compareLargeInts(
isoFieldsToEpochNano(a.getISOFields()),

@@ -75,3 +76,6 @@ isoFieldsToEpochNano(b.getISOFields()),

): Temporal.ComparisonResult {
return compareValues(a.epochNanoseconds, b.epochNanoseconds)
return compareLargeInts(
a[epochNanoSymbol],
b[epochNanoSymbol],
)
}

@@ -89,3 +93,3 @@

) {
return compareValues(
return compareLargeInts(
durationDayTimeToNano(fields0),

@@ -103,3 +107,3 @@ durationDayTimeToNano(fields1),

if (relativeTo.epochNanoseconds !== undefined) {
if (relativeTo[epochNanoSymbol] !== undefined) {
return compareEpochObjs(date0 as ComparableEpochObj, date1 as ComparableEpochObj)

@@ -106,0 +110,0 @@ }

import { Temporal } from 'temporal-spec'
import { LargeInt, createLargeInt } from '../utils/largeInt'
import { DurationFields, DurationTimeFields, signDuration } from './durationFields'

@@ -14,13 +15,7 @@ import { ISOTimeFields } from './isoFields'

nanoInDay,
nanoInDayBI,
nanoInHour,
nanoInHourBI,
nanoInMicro,
nanoInMicroBI,
nanoInMilli,
nanoInMilliBI,
nanoInMinute,
nanoInMinuteBI,
nanoInSecond,
nanoInSecondBI,
} from './units'

@@ -66,4 +61,6 @@

export function durationDayTimeToNano(fields: DurationFields): bigint {
return BigInt(fields.days) * nanoInDayBI + durationTimeToNano(fields)
export function durationDayTimeToNano(fields: DurationFields): LargeInt {
return createLargeInt(nanoInDay)
.mult(fields.days)
.add(durationTimeToNano(fields))
}

@@ -73,9 +70,9 @@

// which would cause the nanosecond's precision to max out.
export function durationTimeToNano(fields: DurationTimeFields): bigint {
return BigInt(fields.hours) * nanoInHourBI +
BigInt(fields.minutes) * nanoInMinuteBI +
BigInt(fields.seconds) * nanoInSecondBI +
BigInt(fields.milliseconds) * nanoInMilliBI +
BigInt(fields.microseconds) * nanoInMicroBI +
BigInt(fields.nanoseconds)
export function durationTimeToNano(fields: DurationTimeFields): LargeInt {
return createLargeInt(fields.nanoseconds)
.add(createLargeInt(fields.microseconds).mult(nanoInMicro))
.add(createLargeInt(fields.milliseconds).mult(nanoInMilli))
.add(createLargeInt(fields.seconds).mult(nanoInSecond))
.add(createLargeInt(fields.minutes).mult(nanoInMinute))
.add(createLargeInt(fields.hours).mult(nanoInHour))
}

@@ -95,3 +92,3 @@

export function nanoToDuration(nano: bigint, largestUnit: DayTimeUnitInt): DurationFields {
export function nanoToDuration(nano: LargeInt, largestUnit: DayTimeUnitInt): DurationFields {
let days = 0

@@ -103,34 +100,34 @@ let hours = 0

let microseconds = 0
let temp: bigint
let temp: LargeInt
switch (largestUnit) {
case DAY:
temp = nano / nanoInDayBI // does trunc
days = Number(temp)
nano -= temp * nanoInDayBI
temp = nano.div(nanoInDay)
days = temp.toNumber()
nano = nano.sub(temp.mult(nanoInDay))
// fall through
case HOUR:
temp = nano / nanoInHourBI
hours = Number(temp)
nano -= temp * nanoInHourBI
temp = nano.div(nanoInHour)
hours = temp.toNumber()
nano = nano.sub(temp.mult(nanoInHour))
// fall through
case MINUTE:
temp = nano / nanoInMinuteBI
minutes = Number(temp)
nano -= temp * nanoInMinuteBI
temp = nano.div(nanoInMinute)
minutes = temp.toNumber()
nano = nano.sub(temp.mult(nanoInMinute))
// fall through
case SECOND:
temp = nano / nanoInSecondBI
seconds = Number(temp)
nano -= temp * nanoInSecondBI
temp = nano.div(nanoInSecond)
seconds = temp.toNumber()
nano = nano.sub(temp.mult(nanoInSecond))
// fall through
case MILLISECOND:
temp = nano / nanoInMilliBI
milliseconds = Number(temp)
nano -= temp * nanoInMilliBI
temp = nano.div(nanoInMilli)
milliseconds = temp.toNumber()
nano = nano.sub(temp.mult(nanoInMilli))
// fall through
case MICROSECOND:
temp = nano / nanoInMicroBI
microseconds = Number(temp)
nano -= temp * nanoInMicroBI
temp = nano.div(nanoInMicro)
microseconds = temp.toNumber()
nano = nano.sub(temp.mult(nanoInMicro))
}

@@ -148,3 +145,3 @@

microseconds,
nanoseconds: Number(nano),
nanoseconds: nano.toNumber(),
})

@@ -151,0 +148,0 @@ }

@@ -7,2 +7,3 @@ import { Temporal } from 'temporal-spec'

import { createDate } from '../public/plainDate'
import { LargeInt, createLargeInt } from '../utils/largeInt'
import { compareValues, roundToIncrement, roundToIncrementBI } from '../utils/math'

@@ -74,12 +75,12 @@ import { compareLocalDateFields } from './compare'

)
return nanoToDuration(BigInt(roundedDiff), diffConfig.largestUnit)
return nanoToDuration(createLargeInt(roundedDiff), diffConfig.largestUnit)
}
export function diffEpochNanos(
epochNano0: bigint,
epochNano1: bigint,
epochNano0: LargeInt,
epochNano1: LargeInt,
diffConfig: DiffConfig<TimeUnitInt>,
): DurationFields {
const roundedDiff = roundToIncrementBI(
epochNano1 - epochNano0,
epochNano1.sub(epochNano0),
nanoIn[diffConfig.smallestUnit] * diffConfig.roundingIncrement,

@@ -242,3 +243,3 @@ diffConfig.roundingFunc,

): DurationFields {
return nanoToDuration(toEpochNano(dt1) - toEpochNano(dt0), largestUnit)
return nanoToDuration(toEpochNano(dt1).sub(toEpochNano(dt0)), largestUnit)
}
import { isoCalendarImpl } from '../calendarImpl/isoCalendarImpl'
import { LargeInt, createLargeInt } from '../utils/largeInt'
import { numSign, positiveModulo } from '../utils/math'

@@ -13,5 +14,3 @@ import { isoTimeToNano } from './dayAndTime'

milliInSecond, nanoInMicro,
nanoInMicroBI,
nanoInMilli,
nanoInMilliBI,
} from './units'

@@ -24,4 +23,6 @@

export const epochNanoSymbol = Symbol()
export interface EpochableObj {
epochNanoseconds?: bigint
[epochNanoSymbol]?: LargeInt
getISOFields(): EpochableFields

@@ -39,3 +40,3 @@ }

export function isoFieldsToEpochNano(isoFields: EpochableFields): bigint {
export function isoFieldsToEpochNano(isoFields: EpochableFields): LargeInt {
return isoToEpochNano(

@@ -76,4 +77,4 @@ isoFields.isoYear,

isoNanosecond?: number,
): bigint {
return BigInt(
): LargeInt {
return createLargeInt(
isoToEpochMilli(

@@ -88,5 +89,6 @@ isoYear,

),
) * nanoInMilliBI +
BigInt(isoMicrosecond ?? 0) * nanoInMicroBI +
BigInt(isoNanosecond ?? 0)
).mult(nanoInMilli).add(
(isoMicrosecond ?? 0) * nanoInMicro +
(isoNanosecond ?? 0),
)
}

@@ -134,6 +136,8 @@

if (milli === undefined ||
if (
milli === undefined ||
// ensure day didn't underflow/overflow to get to an in-bounds date
isoDayTry! < 1 ||
isoDayTry! > isoCalendarImpl.daysInMonth(isoYear, isoMonth)) {
isoDayTry! > isoCalendarImpl.daysInMonth(isoYear, isoMonth)
) {
throwOutOfRange()

@@ -149,15 +153,10 @@ }

/*
TODO: audit Math.floors that happen on rounding of bigints
TODO: audit Number() on bigints
*/
export function epochNanoToISOFields(epochNano: LargeInt): ISODateTimeFields {
let epochMilli = epochNano.div(nanoInMilli)
let leftoverNano = epochNano.sub(epochMilli.mult(nanoInMilli)).toNumber()
export function epochNanoToISOFields(epochNano: bigint): ISODateTimeFields {
let epochMilli = epochNano / nanoInMilliBI
let leftoverNano = Number(epochNano - (epochMilli * nanoInMilliBI))
// HACK for flooring bigints
// ensure leftoverNano. bump to millisecond below if necessary
if (leftoverNano < 0) {
leftoverNano += nanoInMilli
epochMilli -= 1n
epochMilli = epochMilli.sub(1)
}

@@ -169,3 +168,3 @@

return {
...epochMilliToISOFields(Number(epochMilli)),
...epochMilliToISOFields(epochMilli.toNumber()),
isoMicrosecond,

@@ -191,4 +190,4 @@ isoNanosecond: leftoverNano,

export function toEpochNano(dt: EpochableObj): bigint {
return dt.epochNanoseconds ?? isoFieldsToEpochNano(dt.getISOFields())
export function toEpochNano(dt: EpochableObj): LargeInt {
return dt[epochNanoSymbol] ?? isoFieldsToEpochNano(dt.getISOFields())
}

@@ -202,4 +201,6 @@

export function epochNanoToISOYear(epochNano: bigint): number {
return nudgeToLegacyDate(Number(epochNano / nanoInMilliBI))[0].getUTCFullYear()
export function epochNanoToISOYear(epochNano: LargeInt): number {
return nudgeToLegacyDate(
epochNano.div(nanoInMilli).toNumber(),
)[0].getUTCFullYear()
}

@@ -261,3 +262,3 @@

export function splitEpochNano(epochNano: bigint): [bigint, number] {
export function splitEpochNano(epochNano: LargeInt): [LargeInt, number] {
const isoFields = epochNanoToISOFields(epochNano)

@@ -264,0 +265,0 @@ const dayEpochNano = isoToEpochNano(isoFields.isoYear, isoFields.isoMonth, isoFields.isoDay)

import { checkEpochNanoBuggy } from '../calendarImpl/bugs'
import { LargeInt, compareLargeInts, createLargeInt } from '../utils/largeInt'
import { isoFieldsToEpochNano, throwOutOfRange } from './epoch'
import { ISODateFields, ISODateTimeFields } from './isoFields'
import { nanoInDay } from './units'

@@ -24,2 +26,8 @@ /*

const almostDay = nanoInDay - 1 // one nanosecond shy of day
const maxInstantBI = createLargeInt(nanoInDay).mult(100000000) // 100,000,000 days
const minInstantBI = maxInstantBI.mult(-1)
const maxPlainBI = maxInstantBI.add(almostDay)
const minPlainBI = minInstantBI.sub(almostDay)
export function validateYearMonth(isoFields: ISODateFields, calendarID: string): void {

@@ -38,4 +46,4 @@ // might throw an error

// if potentially very negative, measure last nanosecond of day
// to increase changes it's in-bounds
epochNano + (epochNano < 0n ? 86399999999999n : 0n),
// to increase chances it's in-bounds
epochNano.add(epochNano.sign() < 0 ? almostDay : 0),
)

@@ -52,6 +60,6 @@ checkEpochNanoBuggy(epochNano, calendarID)

export function validateInstant(epochNano: bigint): void {
export function validateInstant(epochNano: LargeInt): void {
if (
epochNano < -8640000000000000000000n ||
epochNano > 8640000000000000000000n
compareLargeInts(epochNano, minInstantBI) === -1 ||
compareLargeInts(epochNano, maxInstantBI) === 1
) {

@@ -62,7 +70,7 @@ throwOutOfRange()

export function validatePlain(epochNano: bigint): void {
export function validatePlain(epochNano: LargeInt): void {
// like validateInstant's bounds, but expanded 24:59:59.999999999
if (
epochNano < -8640000086399999999999n ||
epochNano > 8640000086399999999999n
compareLargeInts(epochNano, minPlainBI) === -1 ||
compareLargeInts(epochNano, maxPlainBI) === 1
) {

@@ -69,0 +77,0 @@ throwOutOfRange()

@@ -9,2 +9,3 @@ import {

import { isoCalendarID } from '../calendarImpl/isoCalendarImpl'
import { createLargeInt } from '../utils/largeInt'
import { RoundingFunc, roundToIncrementBI } from '../utils/math'

@@ -20,5 +21,5 @@ import { getSignStr, padZeros } from '../utils/string'

nanoIn,
nanoInMicroBI,
nanoInMilliBI,
nanoInSecondBI,
nanoInMicro,
nanoInMilli,
nanoInSecond,
} from './units'

@@ -127,5 +128,5 @@

const { sign } = fields
const hours = BigInt(fields.hours)
const minutes = BigInt(fields.minutes)
let seconds = BigInt(fields.seconds)
const hours = fields.hours
const minutes = fields.minutes
let seconds = fields.seconds
let partialSecondsStr = ''

@@ -143,3 +144,3 @@

partialSecondsStr = res[0]
seconds += BigInt(res[1])
seconds += res[1]
}

@@ -155,6 +156,6 @@

collapseDurationTuples([
[BigInt(fields.years), 'Y'],
[BigInt(fields.months), 'M'],
[BigInt(fields.weeks), 'W'],
[BigInt(fields.days), 'D'],
[fields.years, 'Y'],
[fields.months, 'M'],
[fields.weeks, 'W'],
[fields.days, 'D'],
]) +

@@ -167,3 +168,3 @@ (hours || minutes || seconds || forceSeconds

[
smallestUnit <= SECOND ? seconds : BigInt(0), // TODO: BigInt(0) const
smallestUnit <= SECOND ? seconds : 0,
partialSecondsStr + 'S',

@@ -177,7 +178,9 @@ forceSeconds,

// use BigInts, because less likely to overflow and formatting never does scientific notation
function collapseDurationTuples(tuples: [BigInt, string, unknown?][]): string {
function collapseDurationTuples(tuples: [number, string, unknown?][]): string {
return tuples.map(([num, postfix, forceShow]) => {
if (forceShow || num) {
// TODO: make BigInt Math.abs util
return (num < BigInt(0) ? -num : num) + postfix
// avoid outputting scientific notation
// https://stackoverflow.com/a/50978675/96342
const numStr = Math.abs(num).toLocaleString('fullwide', { useGrouping: false })
return numStr + postfix
}

@@ -196,6 +199,5 @@ return ''

): [string, number] { // [afterDecimalStr, secondsOverflow]
let totalNano =
BigInt(nanoseconds) +
BigInt(microseconds) * nanoInMicroBI +
BigInt(milliseconds) * nanoInMilliBI
let totalNano = createLargeInt(milliseconds).mult(nanoInMilli)
.add(createLargeInt(microseconds).mult(nanoInMicro))
.add(nanoseconds)

@@ -214,7 +216,7 @@ // HACK. sometimes input is pre-rounded, other times not

const totalNanoAbs = totalNano < 0 ? -totalNano : totalNano // TODO: util for abs() for bigints
const seconds = totalNanoAbs / nanoInSecondBI
const leftoverNano = totalNanoAbs - (seconds * nanoInSecondBI)
const totalNanoAbs = totalNano.abs()
const seconds = totalNanoAbs.div(nanoInSecond)
const leftoverNano = totalNanoAbs.sub(seconds.mult(nanoInSecond))
let afterDecimal = padZeros(Number(leftoverNano), 9)
let afterDecimal = padZeros(leftoverNano.toNumber(), 9)
afterDecimal = fractionalSecondDigits === undefined

@@ -226,4 +228,4 @@ ? afterDecimal.replace(/0+$/, '') // strip trailing zeros

afterDecimal ? '.' + afterDecimal : '',
Number(seconds) * (totalNano < 0 ? -1 : 1), // restore sign (TODO: sign util for bigints)
seconds.toNumber() * (totalNano.sign() || 1), // restore sign
]
}
import { Temporal } from 'temporal-spec'
import { unitNames } from '../argParse/unitStr'
import { LargeInt } from '../utils/largeInt'
import { attachGetters, strArrayToHash } from '../utils/obj'
import { capitalizeFirstLetter } from '../utils/string'
import { DateISOInstance } from './calendar'
import { nanoInMicroBI, nanoInMilliBI, nanoInSecondBI } from './units'
import { epochNanoSymbol } from './epoch'
import { nanoInMicro, nanoInMilli, nanoInSecond } from './units'

@@ -11,2 +13,3 @@ // Epoch Fields

export interface ComputedEpochFields {
epochNanoseconds: bigint
epochMicroseconds: bigint

@@ -17,14 +20,17 @@ epochMilliseconds: number

export function mixinEpochFields<Obj extends { epochNanoseconds: bigint }>(
export function mixinEpochFields<Obj extends { [epochNanoSymbol]: LargeInt }>(
ObjClass: { prototype: Obj },
): void {
attachGetters(ObjClass, {
epochNanoseconds(): bigint {
return this[epochNanoSymbol].toBigInt()
},
epochMicroseconds(): bigint {
return this.epochNanoseconds / nanoInMicroBI
return this[epochNanoSymbol].div(nanoInMicro).toBigInt()
},
epochMilliseconds(): number {
return Number(this.epochNanoseconds / nanoInMilliBI)
return this[epochNanoSymbol].div(nanoInMilli).toNumber()
},
epochSeconds(): number {
return Number(this.epochNanoseconds / nanoInSecondBI)
return this[epochNanoSymbol].div(nanoInSecond).toNumber()
},

@@ -31,0 +37,0 @@ })

@@ -10,6 +10,8 @@ import { Temporal } from 'temporal-spec'

import { Calendar } from '../public/calendar'
import { Instant } from '../public/instant'
import { createDateTime } from '../public/plainDateTime'
import { LargeInt } from '../utils/largeInt'
import { roundToMinute } from '../utils/math'
import { zeroISOTimeFields } from './dayAndTime'
import { isoFieldsToEpochNano } from './epoch'
import { epochNanoSymbol, isoFieldsToEpochNano } from './epoch'
import { ISODateFields, ISODateTimeFields } from './isoFields'

@@ -44,3 +46,3 @@ import { getInstantFor } from './timeZone'

disambigOptions?: Temporal.AssignmentOptions,
): bigint {
): LargeInt {
const { offsetNanoseconds: offsetNano, timeZone, Z } = isoFields

@@ -51,3 +53,3 @@

if (offsetHandling === OFFSET_USE || Z) {
return isoFieldsToEpochNano(isoFields) - BigInt(offsetNano)
return isoFieldsToEpochNano(isoFields).sub(offsetNano)
} else {

@@ -71,7 +73,10 @@ const matchingEpochNano = findMatchingEpochNano(

// compute fresh from TimeZone
return getInstantFor(
const instant = getInstantFor(
timeZone,
createDateTime(isoFields),
parseDisambigOption(disambigOptions),
).epochNanoseconds
)
// TODO: better typing solution
return (instant as Instant)[epochNanoSymbol]
}

@@ -84,3 +89,3 @@

fuzzyMatching?: boolean,
): bigint | undefined {
): LargeInt | undefined {
const possibleInstants = timeZone.getPossibleInstantsFor(createDateTime(isoFields))

@@ -91,4 +96,4 @@ const utcEpochNano = isoFieldsToEpochNano(isoFields)

for (const instant of possibleInstants) {
const possibleEpochNano = instant.epochNanoseconds
const possibleOffsetNano = Number(utcEpochNano - possibleEpochNano)
const possibleEpochNano = (instant as Instant)[epochNanoSymbol] // TODO: better typing
const possibleOffsetNano = utcEpochNano.sub(possibleEpochNano).toNumber()
const possibleOffsetRefined = fuzzyMatching

@@ -113,6 +118,6 @@ ? roundToMinute(possibleOffsetNano)

const day1 = { ...addDays(day0, 1), ...zeroISOTimeFields, calendar: new Calendar('iso8601') }
const epochNano0 = getInstantFor(timeZone, createDateTime(day0)).epochNanoseconds
const epochNano1 = getInstantFor(timeZone, createDateTime(day1)).epochNanoseconds
const epochNano0 = (getInstantFor(timeZone, createDateTime(day0)) as Instant)[epochNanoSymbol]
const epochNano1 = (getInstantFor(timeZone, createDateTime(day1)) as Instant)[epochNanoSymbol]
return Number(epochNano1 - epochNano0)
return epochNano1.sub(epochNano0).toNumber()
}

@@ -0,1 +1,2 @@

import { padEnd } from '../utils/string'
import { isValidDateISO } from './constrain'

@@ -225,3 +226,3 @@ import { nanoToISOTime } from './dayAndTime'

export function parseNanoAfterDecimal(str: string): number {
return parseInt(str.padEnd(9, '0'))
return parseInt(padEnd(str, 9, '0'))
}

@@ -228,0 +229,0 @@

@@ -0,1 +1,2 @@

import { createLargeInt } from '../utils/largeInt'
import { excludeUndefined } from '../utils/obj'

@@ -55,3 +56,3 @@ import { nanoToDuration } from './dayAndTime'

const small = nanoToDuration(BigInt(leftoverNano || 0), MILLISECOND)
const small = nanoToDuration(createLargeInt(leftoverNano || 0), MILLISECOND)
// TODO: use mergeDurations somehow?

@@ -58,0 +59,0 @@ fields.milliseconds = small.milliseconds

import { Temporal } from 'temporal-spec'
import { OFFSET_PREFER } from '../argParse/offsetHandling'
import { RoundingConfig } from '../argParse/roundingOptions'
import { LargeInt } from '../utils/largeInt'
import { roundToIncrement, roundToIncrementBI } from '../utils/math'

@@ -35,8 +36,8 @@ import { isoTimeToNano, nanoToISOTime, zeroISOTimeFields } from './dayAndTime'

export function roundEpochNano(
epochNano: bigint,
epochNano: LargeInt,
roundingConfig: RoundingConfig<TimeUnitInt>,
): bigint {
): LargeInt {
const [dayEpochNano, timeNano] = splitEpochNano(epochNano)
const roundedTimeNano = roundNano(timeNano, roundingConfig)
return dayEpochNano + BigInt(roundedTimeNano)
return dayEpochNano.add(roundedTimeNano)
}

@@ -52,3 +53,3 @@

roundingConfig: RoundingConfig<DayTimeUnitInt>,
): bigint {
): LargeInt {
const { calendar, timeZone } = fields

@@ -91,3 +92,6 @@ let timeNano = isoTimeToNano(fields)

export function roundNanoBI(nano: bigint, roundingConfig: RoundingConfig<DayTimeUnitInt>): bigint {
export function roundNanoBI(
nano: LargeInt,
roundingConfig: RoundingConfig<DayTimeUnitInt>,
): LargeInt {
return roundToIncrementBI(

@@ -94,0 +98,0 @@ nano,

@@ -84,3 +84,3 @@ import { Temporal } from 'temporal-spec'

if (!isDateUnit(largestUnit)) {
const diffNano = (toEpochNano(d1) - toEpochNano(d0)) * (flip ? -1n : 1n)
const diffNano = toEpochNano(d1).sub(toEpochNano(d0)).mult(flip ? -1 : 1)
const diffNanoRounded = roundToIncrementBI(

@@ -87,0 +87,0 @@ diffNano,

@@ -12,3 +12,3 @@ import { Temporal } from 'temporal-spec'

import { toEpochNano } from './epoch'
import { nanoInDayBI } from './units'
import { nanoInDay } from './units'

@@ -69,8 +69,8 @@ // Utils for working with TimeZoneProtocol

const offsetDayBefore = timeZoneProtocol.getOffsetNanosecondsFor(
new Instant(utcEpochNano + nanoInDayBI * -1n),
new Instant(utcEpochNano.sub(nanoInDay)),
)
const offsetDayAfter = timeZoneProtocol.getOffsetNanosecondsFor(
new Instant(utcEpochNano + nanoInDayBI * 1n),
new Instant(utcEpochNano.add(nanoInDay)),
)
return Number(offsetDayAfter - offsetDayBefore)
return offsetDayAfter - offsetDayBefore
}

@@ -26,3 +26,3 @@ import { Temporal } from 'temporal-spec'

// TODO: accidentaly loss of precision?
return Number(durationDayTimeToNano(duration)) / nanoIn[unit]
return durationDayTimeToNano(duration).toNumber() / nanoIn[unit]
}

@@ -85,3 +85,5 @@

const middleNano = toEpochNano(dt1)
const unitFrac = Number(middleNano - startNano) / Number(endNano - startNano) * sign
const unitFrac =
middleNano.sub(startNano).toNumber() /
endNano.sub(startNano).toNumber() * sign

@@ -88,0 +90,0 @@ dur[smallestUnitName]! += unitFrac // above loop populated this

@@ -5,4 +5,6 @@ import { Temporal } from 'temporal-spec'

import { CalendarImpl } from '../calendarImpl/calendarImpl'
import { Instant } from '../public/instant'
import { createDate } from '../public/plainDate'
import { createDateTime } from '../public/plainDateTime'
import { LargeInt } from '../utils/largeInt'
import {

@@ -21,2 +23,3 @@ durationDayTimeToNano,

epochMilliToISOFields,
epochNanoSymbol,
epochNanoToISOFields,

@@ -42,3 +45,3 @@ isoFieldsToEpochNano,

options: Temporal.AssignmentOptions | undefined, // Calendar needs these options to be raw
): bigint {
): LargeInt {
const { calendar, timeZone } = fields

@@ -61,4 +64,4 @@

// add time fields of duration
const translatedInstant = getInstantFor(timeZone, translatedDateTime)
return translatedInstant.epochNanoseconds + durationTimeToNano(duration)
const translatedInstant = getInstantFor(timeZone, translatedDateTime) as Instant // TODO: better
return translatedInstant[epochNanoSymbol].add(durationTimeToNano(duration))
}

@@ -81,5 +84,5 @@

const epochNano = isoFieldsToEpochNano(date.getISOFields()) +
BigInt(isoTimeToNano(fields)) + // restore original time-of-day
durationTimeToNano(duration) // add duration time parts
const epochNano = isoFieldsToEpochNano(date.getISOFields())
.add(isoTimeToNano(fields)) // restore original time-of-day
.add(durationTimeToNano(duration)) // add duration time parts

@@ -100,4 +103,3 @@ return epochNanoToISOFields(epochNano)

// TODO: loss of precision?
const daysFromTime = Math.trunc(Number(durationTimeToNano(durationFields)) / nanoInDay)
const daysFromTime = Math.trunc(durationTimeToNano(durationFields).div(nanoInDay).toNumber())
const days = durationFields.weeks * 7 + durationFields.days + daysFromTime

@@ -165,3 +167,3 @@ epochMilli = addDaysMilli(epochMilli, days)

// TODO: will loss of precision cause a bug?
const nano = isoTimeToNano(timeFields) + Number(durationTimeToNano(durationFields))
const nano = isoTimeToNano(timeFields) + durationTimeToNano(durationFields).toNumber()
const [newTimeFields] = nanoToISOTime(nano)

@@ -171,3 +173,3 @@ return newTimeFields

export function translateEpochNano(epochNano: bigint, durationFields: DurationFields): bigint {
export function translateEpochNano(epochNano: LargeInt, durationFields: DurationFields): LargeInt {
const largestUnit = computeLargestDurationUnit(durationFields)

@@ -179,3 +181,3 @@

return epochNano + durationTimeToNano(durationFields)
return epochNano.add(durationTimeToNano(durationFields))
}

@@ -198,3 +200,3 @@

return nanoToDuration(
durationDayTimeToNano(d0) + durationDayTimeToNano(d1),
durationDayTimeToNano(d0).add(durationDayTimeToNano(d1)),
largestUnit,

@@ -201,0 +203,0 @@ )

@@ -20,10 +20,2 @@ // TODO: rename everything to 'sec'/'min'?

export const nanoInMicroBI = 1000n
export const nanoInMilliBI = 1000000n
export const nanoInSecondBI = 1000000000n
export const nanoInMinuteBI = 60000000000n
export const nanoInHourBI = 3600000000000n
export const nanoInDayBI = 86400000000000n
// TODO: audit use of these. Use bigint exclusively?
export const nanoInMicro = 1000

@@ -46,2 +38,4 @@ export const nanoInMilli = 1000000

export const milliInDay = 86400000
export const milliInHour = 3600000
export const milliInMinute = 60000
export const milliInSecond = 1000

@@ -48,0 +42,0 @@ export const secondsInDay = 24 * 60 * 60

@@ -5,5 +5,6 @@ import type * as Spec from 'temporal-spec'

import { Temporal as TemporalImpl } from './public/temporal'
import { getGlobalThis } from './utils/dom'
export const Temporal: typeof Spec.Temporal = TemporalImpl
export const Intl: typeof Spec.Intl = { ...globalThis.Intl, DateTimeFormat }
export const Intl: typeof Spec.Intl = { ...getGlobalThis().Intl, DateTimeFormat }
export const toTemporalInstant = toTemporalInstantImpl
import type * as Spec from 'temporal-spec'
import { getGlobalThis } from './utils/dom'
import {

@@ -8,10 +9,11 @@ Intl as IntlImpl,

const TemporalNative = globalThis.Temporal
const theGlobalThis = getGlobalThis()
const TemporalNative = theGlobalThis.Temporal
export const Temporal: typeof Spec.Temporal = TemporalNative || TemporalImpl
export const Intl: typeof Spec.Intl = TemporalNative
? (globalThis.Intl as any) // because of DateTimeFormatOptions shortcoming temporal-spec/global
? (theGlobalThis.Intl as any) // because of DateTimeFormatOptions shortcoming temporal-spec/global
: IntlImpl
export const toTemporalInstant = TemporalNative
? globalThis.Date.prototype.toTemporalInstant
? theGlobalThis.Date.prototype.toTemporalInstant
: toTemporalInstantImpl

@@ -0,1 +1,2 @@

import { Temporal } from 'temporal-spec'
import { Instant } from '../public/instant'

@@ -13,4 +14,4 @@

export function toTemporalInstant(this: Date): Instant {
export function toTemporalInstant(this: Date): Temporal.Instant {
return Instant.fromEpochMilliseconds(this.valueOf())
}

@@ -11,3 +11,3 @@ import { Temporal } from 'temporal-spec'

import { negateDuration } from '../dateUtils/durationFields'
import { isoFieldsToEpochNano } from '../dateUtils/epoch'
import { epochNanoSymbol, isoFieldsToEpochNano } from '../dateUtils/epoch'
import { validateInstant } from '../dateUtils/isoFieldValidation'

@@ -22,9 +22,9 @@ import { ComputedEpochFields, attachStringTag, mixinEpochFields } from '../dateUtils/mixins'

SECOND,
nanoInMicroBI,
nanoInMilliBI,
nanoInSecondBI,
nanoInMicro,
nanoInMilli,
nanoInSecond,
} from '../dateUtils/units'
import { createZonedFormatFactoryFactory } from '../native/intlFactory'
import { ToLocaleStringMethods, mixinLocaleStringMethods } from '../native/intlMixins'
import { createWeakMap } from '../utils/obj'
import { LargeInt, LargeIntArgStrict, createLargeInt } from '../utils/largeInt'
import { Duration, createDuration } from './duration'

@@ -54,16 +54,14 @@ import { ZonedDateTime } from './zonedDateTime'

const [getEpochNano, setEpochNano] = createWeakMap<Instant, bigint>()
export interface Instant {
[epochNanoSymbol]: LargeInt
}
export class Instant extends AbstractNoValueObj implements Temporal.Instant {
constructor(epochNanoseconds: bigint) {
constructor(epochNanoseconds: LargeIntArgStrict) {
super()
if (typeof epochNanoseconds === 'number') {
throw new TypeError('Must supply bigint, not number')
}
epochNanoseconds = BigInt(epochNanoseconds) // cast
validateInstant(epochNanoseconds)
setEpochNano(this, epochNanoseconds)
const epochNano = createLargeInt(epochNanoseconds, true) // strict=true
validateInstant(epochNano)
this[epochNanoSymbol] = epochNano
}
static from(arg: InstantArg): Temporal.Instant {
static from(arg: InstantArg): Instant { // okay to have return-type be Instant? needed
if (arg instanceof Instant) {

@@ -80,4 +78,4 @@ return new Instant(arg.epochNanoseconds)

return new Instant(
isoFieldsToEpochNano(constrainDateTimeISO(fields, OVERFLOW_REJECT)) -
BigInt(offsetNano),
isoFieldsToEpochNano(constrainDateTimeISO(fields, OVERFLOW_REJECT))
.sub(offsetNano),
)

@@ -87,11 +85,11 @@ }

static fromEpochSeconds(epochSeconds: number): Temporal.Instant {
return new Instant(BigInt(epochSeconds) * nanoInSecondBI)
return new Instant(createLargeInt(epochSeconds).mult(nanoInSecond))
}
static fromEpochMilliseconds(epochMilliseconds: number): Temporal.Instant {
return new Instant(BigInt(epochMilliseconds) * nanoInMilliBI)
return new Instant(createLargeInt(epochMilliseconds).mult(nanoInMilli))
}
static fromEpochMicroseconds(epochMicroseconds: bigint): Temporal.Instant {
return new Instant(epochMicroseconds * nanoInMicroBI)
return new Instant(epochMicroseconds * BigInt(nanoInMicro))
}

@@ -110,7 +108,5 @@

get epochNanoseconds(): bigint { return getEpochNano(this) }
add(durationArg: TranslateArg): Temporal.Instant {
return new Instant(
translateEpochNano(this.epochNanoseconds, ensureObj(Duration, durationArg)),
translateEpochNano(this[epochNanoSymbol], ensureObj(Duration, durationArg)),
)

@@ -121,3 +117,3 @@ }

return new Instant(
translateEpochNano(this.epochNanoseconds, negateDuration(ensureObj(Duration, durationArg))),
translateEpochNano(this[epochNanoSymbol], negateDuration(ensureObj(Duration, durationArg))),
)

@@ -138,3 +134,3 @@ }

return new Instant(
roundEpochNano(this.epochNanoseconds, roundingConfig),
roundEpochNano(this[epochNanoSymbol], roundingConfig),
)

@@ -211,4 +207,4 @@ }

return createDuration(
diffEpochNanos(inst0.epochNanoseconds, inst1.epochNanoseconds, diffConfig),
diffEpochNanos(inst0[epochNanoSymbol], inst1[epochNanoSymbol], diffConfig),
)
}

@@ -6,4 +6,5 @@ import { Temporal } from 'temporal-spec'

import { attachStringTag } from '../dateUtils/mixins'
import { nanoInMilliBI } from '../dateUtils/units'
import { nanoInMilli } from '../dateUtils/units'
import { OrigDateTimeFormat } from '../native/intlUtils'
import { LargeInt, createLargeInt } from '../utils/largeInt'
import { Calendar } from './calendar'

@@ -99,4 +100,4 @@ import { Instant } from './instant'

function getEpochNano(): bigint {
return BigInt(Date.now()) * nanoInMilliBI
function getEpochNano(): LargeInt {
return createLargeInt(Date.now()).mult(nanoInMilli)
}

@@ -6,3 +6,3 @@ import { Temporal } from 'temporal-spec'

import { AbstractObj, ensureObj } from '../dateUtils/abstract'
import { epochNanoToISOFields, isoFieldsToEpochNano } from '../dateUtils/epoch'
import { epochNanoSymbol, epochNanoToISOFields, isoFieldsToEpochNano } from '../dateUtils/epoch'
import { formatOffsetISO } from '../dateUtils/isoFormat'

@@ -67,3 +67,3 @@ import { attachStringTag } from '../dateUtils/mixins'

const instant = ensureObj(Instant, instantArg)
return getImpl(this).getOffset(instant.epochNanoseconds)
return getImpl(this).getOffset(instant[epochNanoSymbol])
}

@@ -77,3 +77,3 @@

const isoFields = epochNanoToISOFields(
instant.epochNanoseconds + BigInt(this.getOffsetNanosecondsFor(instant)),
instant[epochNanoSymbol].add(this.getOffsetNanosecondsFor(instant)),
)

@@ -99,3 +99,3 @@ return createDateTime({

return possibleOffsetNanos.map((offsetNano) => (
new Instant(zoneNano - BigInt(offsetNano))
new Instant(zoneNano.sub(offsetNano))
))

@@ -106,3 +106,3 @@ }

const instant = ensureObj(Instant, instantArg)
const rawTransition = getImpl(this).getTransition(instant.epochNanoseconds, -1)
const rawTransition = getImpl(this).getTransition(instant[epochNanoSymbol], -1)
if (rawTransition) {

@@ -116,3 +116,3 @@ return new Instant(rawTransition[0])

const instant = ensureObj(Instant, instantArg)
const rawTransition = getImpl(this).getTransition(instant.epochNanoseconds, 1)
const rawTransition = getImpl(this).getTransition(instant[epochNanoSymbol], 1)
if (rawTransition) {

@@ -119,0 +119,0 @@ return new Instant(rawTransition[0])

@@ -23,3 +23,3 @@ import { Temporal } from 'temporal-spec'

import { DurationFields, negateDuration } from '../dateUtils/durationFields'
import { epochNanoToISOFields } from '../dateUtils/epoch'
import { epochNanoSymbol, epochNanoToISOFields } from '../dateUtils/epoch'
import {

@@ -68,4 +68,4 @@ processZonedDateTimeFromFields,

import { ToLocaleStringMethods, mixinLocaleStringMethods } from '../native/intlMixins'
import { LargeInt, LargeIntArg, createLargeInt } from '../utils/largeInt'
import { roundToMinute } from '../utils/math'
import { createWeakMap } from '../utils/obj'
import { Calendar, createDefaultCalendar } from './calendar'

@@ -92,21 +92,21 @@ import { Duration, DurationArg, createDuration } from './duration'

interface ZonedDateTimePrivateFields {
offsetNanoseconds: number
epochNanoseconds: bigint
const offsetNanoSymbol = Symbol()
export interface ZonedDateTime {
[offsetNanoSymbol]: number
[epochNanoSymbol]: LargeInt
}
const [getPrivateFields, setPrivateFields] =
createWeakMap<ZonedDateTime, ZonedDateTimePrivateFields>()
export class ZonedDateTime extends AbstractISOObj<Temporal.ZonedDateTimeISOFields>
implements Temporal.ZonedDateTime {
constructor(
epochNanoseconds: bigint,
epochNanoseconds: LargeIntArg,
timeZoneArg: Temporal.TimeZoneLike,
calendarArg: Temporal.CalendarLike = createDefaultCalendar(),
) {
// TODO: throw error when number?
const timeZone = ensureObj(TimeZone, timeZoneArg)
const calendar = ensureObj(Calendar, calendarArg)
const [isoFields, offsetNano] = buildZonedDateTimeISOFields(epochNanoseconds, timeZone)
const epochNano = createLargeInt(epochNanoseconds) // TODO: do strict, like Instant?
const [isoFields, offsetNano] = buildZonedDateTimeISOFields(epochNano, timeZone)
validateDateTime(isoFields, calendar.toString())

@@ -123,9 +123,8 @@

setPrivateFields(this, {
epochNanoseconds,
offsetNanoseconds: offsetNano,
})
this[epochNanoSymbol] = epochNano
this[offsetNanoSymbol] = offsetNano
}
static from(arg: ZonedDateTimeArg, options?: Temporal.AssignmentOptions): Temporal.ZonedDateTime {
// okay to have return-type be ZonedDateTime? needed
static from(arg: ZonedDateTimeArg, options?: Temporal.AssignmentOptions): ZonedDateTime {
const offsetHandling = parseOffsetHandlingOption(options, OFFSET_REJECT)

@@ -159,4 +158,3 @@ const overflowHandling = parseOverflowOption(options)

get timeZone(): Temporal.TimeZoneProtocol { return this.getISOFields().timeZone }
get epochNanoseconds(): bigint { return getPrivateFields(this).epochNanoseconds }
get offsetNanoseconds(): number { return getPrivateFields(this).offsetNanoseconds }
get offsetNanoseconds(): number { return this[offsetNanoSymbol] }
get offset(): string { return this.getISOFields().offset }

@@ -321,3 +319,3 @@

export function buildZonedDateTimeISOFields(
epochNano: bigint,
epochNano: LargeInt,
timeZone: Temporal.TimeZoneProtocol,

@@ -327,3 +325,3 @@ ): [ISODateTimeFields, number] {

const offsetNano = timeZone.getOffsetNanosecondsFor(instant)
const isoFields = epochNanoToISOFields(epochNano + BigInt(offsetNano))
const isoFields = epochNanoToISOFields(epochNano.add(offsetNano))
return [isoFields, offsetNano]

@@ -330,0 +328,0 @@ }

import { toTemporalInstant } from './native/date'
import { DateTimeFormat } from './native/intlTemporal'
import { Temporal } from './public/temporal'
import { getGlobalThis } from './utils/dom'
// TODO: better way to extend already-polyfilled rootObj
// somehow WRAP the whole lib, UMD-style?
export function shim(): void {
if (!globalThis.Temporal) {
globalThis.Temporal = Temporal
const theGlobalThis = getGlobalThis()
if (!theGlobalThis.Temporal) {
theGlobalThis.Temporal = Temporal
Intl.DateTimeFormat = DateTimeFormat

@@ -11,0 +15,0 @@ // eslint-disable-next-line no-extend-native

import { epochNanoToISOYear, isoToEpochMilli, isoYearToEpochSeconds } from '../dateUtils/epoch'
import { hashIntlFormatParts, normalizeShortEra } from '../dateUtils/intlFormat'
import { milliInSecond, nanoInSecond, nanoInSecondBI, secondsInDay } from '../dateUtils/units'
import { milliInSecond, nanoInSecond, secondsInDay } from '../dateUtils/units'
import { OrigDateTimeFormat } from '../native/intlUtils'
import { compareValues } from '../utils/math'
import { LargeInt, compareLargeInts, createLargeInt } from '../utils/largeInt'
import { specialCases } from './specialCases'

@@ -48,3 +48,3 @@ import { RawTransition, TimeZoneImpl } from './timeZoneImpl'

// `zoneNano` is like epochNano, but from zone's pseudo-epoch
getPossibleOffsets(zoneNano: bigint): number[] {
getPossibleOffsets(zoneNano: LargeInt): number[] {
let lastOffsetNano: number | undefined

@@ -54,3 +54,4 @@

this.getTransition(zoneNano, -1),
this.getTransition(zoneNano - 1n, 1), // subtract 1 b/c getTransition is always exclusive
this.getTransition(zoneNano.sub(1), 1),
// ^subtract 1 b/c getTransition is always exclusive
].filter(Boolean) as RawTransition[]

@@ -65,11 +66,17 @@

// two possibilities (no guarantee of chronology)
const epochNanoA = zoneNano - BigInt(offsetNanoBefore)
const epochNanoB = zoneNano - BigInt(offsetNanoAfter)
const epochNanoA = zoneNano.sub(offsetNanoBefore)
const epochNanoB = zoneNano.sub(offsetNanoAfter)
// is the transition after both possibilities?
if (transitionEpochNano > epochNanoA && transitionEpochNano > epochNanoB) {
if (
compareLargeInts(transitionEpochNano, epochNanoA) > 0 && // >
compareLargeInts(transitionEpochNano, epochNanoB) > 0 // >
) {
return [offsetNanoBefore]
// is the transition before both possibilities?
} else if (transitionEpochNano <= epochNanoA && transitionEpochNano <= epochNanoB) {
} else if (
compareLargeInts(transitionEpochNano, epochNanoA) <= 0 && // <=
compareLargeInts(transitionEpochNano, epochNanoB) <= 0 // <=
) {
// keep looping...

@@ -102,4 +109,6 @@

getOffset(epochNano: bigint): number {
return this.getOffsetForEpochSecs(Number(epochNano / nanoInSecondBI)) * nanoInSecond
getOffset(epochNano: LargeInt): number {
return this.getOffsetForEpochSecs(
epochNano.div(nanoInSecond).toNumber(),
) * nanoInSecond
}

@@ -133,3 +142,3 @@

*/
getTransition(epochNano: bigint, direction: -1 | 1): RawTransition | undefined {
getTransition(epochNano: LargeInt, direction: -1 | 1): RawTransition | undefined {
let year = epochNanoToISOYear(epochNano)

@@ -161,3 +170,3 @@

direction: -1 | 1,
epochNano: bigint,
epochNano: LargeInt,
): RawTransition | undefined {

@@ -173,3 +182,3 @@ for (; year !== endYear; year += direction) {

// does the current transition overtake epochNano in the direction of travel?
if (compareValues(transition[0], epochNano) === direction) {
if (compareLargeInts(transition[0], epochNano) === direction) {
return transition

@@ -241,3 +250,3 @@ }

return [
BigInt(endEpochSec) * nanoInSecondBI,
createLargeInt(endEpochSec).mult(nanoInSecond),
startOffsetSec * nanoInSecond,

@@ -244,0 +253,0 @@ endOffsetSec * nanoInSecond,

@@ -0,1 +1,3 @@

import { nanoInMilli } from '../dateUtils/units'
import { LargeInt, createLargeInt } from '../utils/largeInt'
import { RawTransition } from './timeZoneImpl'

@@ -10,7 +12,11 @@

// TODO: have RawTransitions be seconds again?
[1301752800000000000n, -36000000000000, -39600000000000], // start DST
[1316872800000000000n, -39600000000000, -36000000000000], // end DST
[1325239200000000000n, -36000000000000, 50400000000000], // change of time zone
[toNano(1301752800000), -36000000000000, -39600000000000], // start DST
[toNano(1316872800000), -39600000000000, -36000000000000], // end DST
[toNano(1325239200000), -36000000000000, 50400000000000], // change of time zone
],
},
}
function toNano(milli: number): LargeInt {
return createLargeInt(milli).mult(nanoInMilli)
}

@@ -0,4 +1,5 @@

import { LargeInt } from '../utils/largeInt'
export type RawTransition = [
bigint, // epochNano
LargeInt, // epochNano
number, // offsetNanoBefore

@@ -11,5 +12,5 @@ number, // offsetNanoAfter

abstract getPossibleOffsets(zoneNano: bigint): number[] // offsetNanos
abstract getOffset(epochNano: bigint): number // offsetNano
abstract getTransition(epochNano: bigint, direction: -1 | 1): RawTransition | undefined
abstract getPossibleOffsets(zoneNano: LargeInt): number[] // offsetNanos
abstract getOffset(epochNano: LargeInt): number // offsetNano
abstract getTransition(epochNano: LargeInt, direction: -1 | 1): RawTransition | undefined
}
import { Temporal } from 'temporal-spec'
import { nanoInMinute } from '../dateUtils/units'
import { LargeInt } from './largeInt'
export type RoundingFunc = (n: number) => number
export function compareValues<T extends (number | bigint | string)>(
a: T,
b: T,
): Temporal.ComparisonResult {
export function compareValues(a: number, b: number): Temporal.ComparisonResult {
if (a < b) {

@@ -22,7 +20,2 @@ return -1

// HACK
export function numSignBI(num: bigint): Temporal.ComparisonResult {
return !num ? 0 : num < 0n ? -1 : 1
}
export function roundToIncrement(

@@ -47,11 +40,10 @@ num: number,

export function roundToIncrementBI(
num: bigint,
num: LargeInt,
inc: number,
roundingFunc: RoundingFunc,
): bigint {
const incBI = BigInt(inc)
const wholeUnits = num / incBI
const wholeNum = wholeUnits * incBI
const leftover = Number(num - wholeNum)
return wholeNum + BigInt(roundingFunc(leftover / inc)) * incBI
): LargeInt {
const wholeUnits = num.div(inc)
const wholeNum = wholeUnits.mult(inc)
const leftover = num.sub(wholeNum).toNumber()
return wholeNum.add(roundingFunc(leftover / inc) * inc)
}

@@ -58,0 +50,0 @@

@@ -10,7 +10,19 @@

export function padZeros(num: number, length: number): string {
return String(num).padStart(length, '0')
return padStart(String(num), length, '0')
}
export function padStart(str: string, len: number, padChar: string): string {
return buildPadding(str, len, padChar) + str
}
export function padEnd(str: string, len: number, padChar: string): string {
return str + buildPadding(str, len, padChar)
}
function buildPadding(str: string, len: number, padChar: string): string {
return new Array(Math.max(0, len - str.length + 1)).join(padChar)
}
export function getSignStr(num: number): string {
return num < 0 ? '-' : '+'
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc