rrule-temporal 2.2.2 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -51
- package/dist/index.cjs +1 -6
- package/dist/index.d.cts +16 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.js +1 -2
- package/dist/src-CNIROjgI.js +2 -0
- package/dist/src-DP31wO2R.cjs +2 -0
- package/dist/totext.cjs +1 -951
- package/dist/totext.js +1 -950
- package/package.json +1 -1
- package/dist/src-B2AIB5jJ.cjs +0 -8389
- package/dist/src-B2XO5sNr.js +0 -8366
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=(e,t)=>`Non-positive ${e}: ${t}`,t=(e,t)=>`Non-finite ${e}: ${t}`,n=e=>`Cannot convert bigint to ${e}`,r=(e,t,n,r)=>i(e,t)+`; must be between ${n}-${r}`,i=(e,t)=>`Invalid ${e}: ${t}`;function a(e){return e===void 0?Object.create(null):f(e)}function o(e,r=`number`){if(typeof e==`bigint`)throw TypeError(n(r));if(e=Number(e),!Number.isFinite(e))throw RangeError(t(r,e));return e}function s(e,t){return Math.trunc(o(e,t))||0}function c(e,t){return l(s(e,t),t)}function l(t,n=`number`){if(t<=0)throw RangeError(e(n,t));return t}function u(e,t,n){return Math.min(Math.max(e,t),n)}function d(e){return e!==null&&(typeof e==`object`||typeof e==`function`)}function f(e){if(!d(e))throw TypeError(`Invalid object`);return e}const p=i,m=e=>`Missing ${e}`,h=e=>`No valid fields: `+e.join(),g=(e,t,n)=>i(e,t)+`; must be `+Object.keys(n).join(),_=e=>`Missing year`+(e?`/era/eraYear`:``),v=`Invalid leap month`,ee=e=>i(`Calendar`,e),te=e=>i(`TimeZone`,e),ne=e=>`Cannot parse: ${e}`,re=e=>`Invalid substring: ${e}`,ie=u,y=d;function b(e){throw RangeError(e)}function x(e){throw TypeError(e)}function ae(e,t,n,r,i){return oe(t,((e,t)=>{let n=e[t];return n===void 0&&x(m(t)),n})(e,t),n,r,i)}function oe(e,t,n,i,a,o){let s=ie(t,n,i);return a&&t!==s&&b(((e,t,n,i,a)=>a?r(e,a[t],a[n],a[i]):r(e,t,n,i))(e,t,n,i,o)),s}function se(e,t=Map){let n=new t;return(t,...r)=>{if(n.has(t))return n.get(t);let i=e(t,...r);return n.set(t,i),i}}const ce=e=>le({name:e},1),le=(e,t)=>de(e=>({value:e,configurable:1,writable:!t}),e),ue=e=>({[Symbol.toStringTag]:{value:e,configurable:1}});function de(e,t){let n={};for(let r in t)n[r]=e(t[r],r);return n}function fe(e,t){let n={};for(let r of e)n[r]=t;return n}function pe(e){let t={};for(let n of e)t[n]=e=>e[n];return t}function me(e,t,n=Object.create(null)){for(let r of e)n[r]=t[r];return n}function he(e,t,n){for(let r of e)if(t[r]!==n[r])return 0;return 1}function ge(e,t,n){let r={...n};for(let n=0;n<t;n++)r[e[n]]=0;return r}function S(e,...t){return(...n)=>e(...t,...n)}function _e(){}function ve(e){return e[0].toUpperCase()+e.substring(1)}function C(...e){return[].concat(...e).sort()}function ye(e){return RegExp(`^${e}$`,`i`)}function be(e){return parseInt(e.padEnd(9,`0`))}function xe(e){return e&&e!==`+`?-1:1}function Se(e){return e===void 0?0:parseInt(e)}function Ce(e,t){return String(t).padStart(e,`0`)}const we=S(Ce,2);function w(e,t){return Math.sign(e-t)}function T(e,t){return e<t?-1:e>t?1:0}function Te(e,t){let n=e/t;return e%t<0n?n-1n:n}function Ee(e,t){let n=Te(e,t);return[n,e-n*t]}function De(e,t){return[Math.floor(e/t),Oe(e,t)]}function Oe(e,t){return(e%t+t)%t}function ke(e,t){return Math.trunc(e/t)||0}function Ae(e,t){return e%t||0}function je(e,t=1){return t*(.5+e/5)}function Me(e){return Math.abs(e%1)===.5}const Ne={bce:-1,ce:0};function Pe(e){let t=e.normalize(`NFD`).toLowerCase().replace(/[^a-z0-9]/g,``);return t===`bc`||t===`b`?`bce`:t===`ad`||t===`a`?`ce`:t}function Fe(e){return e===void 0?`iso8601`:e===0?`gregory`:e.id}const Ie=/^M(\d{2})(L?)$/;function Le(e){let t=Ie.exec(e);return t||b((e=>`Invalid monthCode: ${e}`)(e)),[parseInt(t[1]),!!t[2]]}function Re(e,t){return`M`+we(e)+(t?`L`:``)}function ze(e,t,n){return e+(t||n&&e>=n?1:0)}function Be(e,t){return e-(t&&e>=t?1:0)}const Ve={nanosecond:0,microsecond:1,millisecond:2,second:3,minute:4,hour:5,day:6,week:7,month:8,year:9},He=Object.keys(Ve),Ue=864e5,We=1e3,Ge=1e6,Ke=1e9,qe=6e10,Je=36e11,Ye=864e11,Xe=[1,We,Ge,Ke,qe,Je,Ye],Ze=BigInt(We),Qe=BigInt(Ge),$e=BigInt(Ke),et=BigInt(qe),tt=BigInt(Je),E=BigInt(Ye);function nt(e,t){let n=Number(e/E),r=Number(e%E);return Ye/t*n+(Math.trunc(r/t)+r%t/t)}const D=He.slice(0,6),rt=pe(D),it=[`year`],at=[`day`],ot=[`day`,`month`,`year`],st=[`offset`],ct=[`timeZone`],lt=[`era`,`eraYear`],ut=[`era`,`eraYear`,`year`],dt=[`month`,`monthCode`],ft=[`day`,`month`,`monthCode`],pt=C(D),mt=C(lt,it),ht=C(dt,it),gt=C(lt,ht),_t=C([`monthCode`],it),vt=C(lt,_t),yt=C(at,[`monthCode`]),bt=C(at,ht),xt=C(at,lt,ht),St=C(bt,D),Ct=C(xt,D),wt=C(bt,D,st),Tt=C(xt,D,st),Et=C(bt,D,st,ct),Dt=C(xt,D,st,ct),Ot=C(at,_t),kt=C(at,lt,_t),At=fe(D,0);function jt(e){return Nt(e,1),e}const Mt={hour:23,minute:59,second:59};function Nt(e,t){let n={};for(let r of D)n[r]=oe(r,e[r],0,Mt[r]||999,t);return n}function O(e){return Ft(e)*Ke+It(e)}function Pt(e){return 1e3*Ft(e)+e.millisecond}function Ft(e){return 3600*e.hour+60*e.minute+e.second}function It(e){return e.millisecond*Ge+e.microsecond*We+e.nanosecond}function Lt(e){let[t,n]=De(e,Ye);return[Rt(n),t]}function Rt(e){let[t,n]=De(e,Ge),[r,i]=De(n,We);return zt(t,r,i)}function zt(e,t=0,n=0){let[r,i]=De(e,36e5),[a,o]=De(i,6e4),[s,c]=De(o,1e3);return{hour:r,minute:a,second:s,millisecond:c,microsecond:t,nanosecond:n}}function Bt(e){let[t,n]=Ee(e,$e);return[Number(t),Number(n)]}function Vt(e){return Ut(e)+BigInt(O(e))}function Ht(e){return Wt(e)+Pt(e)}function Ut(e){return BigInt(Gt(e))*E}function Wt(e){return 864e5*Gt(e)}function Gt(e){return Kt(e.year,e.month,e.day)}function Kt(e,t=1,n=1){let r=t-1;return e+=Math.floor(r/12),t=Oe(r,12),Date.UTC(e%400-400,t,0)/864e5+146097*(ke(e,400)+1)+n}function qt(e){let[t,n]=Ee(e,E);return{...Yt(Number(t)),...Rt(Number(n))}}function Jt(e,t=0,n=0){let[r,i]=De(e,864e5);return{...Yt(r),...zt(i,t,n)}}function Yt(e){let t=new Date(864e5*Oe(e,146097));return{year:t.getUTCFullYear()+400*Math.floor(e/146097),month:t.getUTCMonth()+1,day:t.getUTCDate()}}function Xt(e,t){return Math.trunc((t-e)/864e5)}function Zt(e){return[e,0]}function Qt(e,t){if(!t)return{year:1972,month:e}}function $t(e,t,n){return{year:e,month:t,day:n}}function en(e,t){switch(t){case 2:return nn(e)?29:28;case 4:case 6:case 9:case 11:return 30}return 31}function tn(e){return nn(e)?366:365}function nn(e){return e%4==0&&(e%100!=0||e%400==0)}function rn(e,t,n){return e+=ke(n,12),(t+=Ae(n,12))<1?(e--,t+=12):t>12&&(e++,t-=12),{year:e,month:t}}function an(e,t,n,r){return 12*(n-e)+r-t}function on(e){return Oe(Kt(e.year,e.month,e.day)+4,7)||7}function sn(e){return Kt(e.year,e.month,e.day)-Kt(e.year)+1}function cn(e){let t=e.year,n=Math.floor((sn(e)-on(e)+10)/7),r=ln(t);return n<1?n=r=ln(--t):n>r&&(n=1,r=ln(++t)),{weekOfYear:n,yearOfWeek:t,Ie:r}}function ln(e){let t=on({year:e,month:1,day:1});return t===4||t===3&&nn(e)?53:52}function un({year:e}){return e<1?{era:`bce`,eraYear:1-e}:{era:`ce`,eraYear:e}}function dn(e){return fn(e),jt(e)}function fn(e){return mn(e,1),e}function pn(e){return he(ot,e,mn(e))}function mn(e,t){let{year:n}=e,r=ae(e,`month`,1,12,t);return{year:n,month:r,day:ae(e,`day`,1,en(n,r),t)}}function k(e,t){return e?e.ie(t):t}function hn(e,t,n){return e?e.O(t,n):Zt(n)}function gn(e,t){return e===0?un(t):e?e.h(t):{}}function _n(e,t,n,r){return e?e.je(t,n,r):$t(t,n,r)}function vn(e,t){return e?e.k(t):12}function yn(e,t,n){return e?e.p(t,n):en(t,n)}function bn(e,t){let{year:n,month:r}=k(e,t),[i,a]=hn(e,n,r);return Re(i,a)}function xn(e,t){let{year:n}=k(e,t);return e?e.u(n):nn(n)}function Sn(e,t){let{year:n}=k(e,t);return vn(e,n)}function Cn(e,t){let{year:n,month:r}=k(e,t);return yn(e,n,r)}function wn(e,t){let{year:n}=k(e,t);return e?e.j(n):tn(n)}function Tn(e,t){if(!e)return sn(t);let{year:n}=k(e,t),r=_n(e,n,1,1);return Gt(t)-Gt(r)+1}function En(e,t){return e===void 0?cn(t).weekOfYear:void 0}function Dn(e,t){return e===void 0?cn(t).yearOfWeek:void 0}const A=He.map(e=>e+`s`),On=pe(A),kn=C(A),An=A.slice(0,6),jn=A.slice(6),Mn=jn.slice(1),Nn=A.reduce((e,t,n)=>(e[t]=n,e),{}),j=fe(A,0),Pn=fe(An,0),Fn=S(ge,A);function In(e,t){return t??b(m(e)),t}const M=S(Ln,`string`);function Ln(e,t,n=e){return typeof t!==e&&x(p(n,t)),t}function Rn(e,t=`number`){return Number.isInteger(e)||b(((e,t)=>`Non-integer ${e}: ${t}`)(t,e)),e||0}function zn(e){return typeof e==`symbol`&&x(`Cannot convert Symbol to string`),String(e)}function Bn(e,t){return d(e)?String(e):M(e,t)}function Vn(e){return typeof e==`boolean`?BigInt(e?1:0):typeof e==`string`?BigInt(e):(typeof e!=`bigint`&&x(`Invalid bigint: ${e}`),e)}function Hn(e,t){return Rn(o(e,t),t)}function Un(e,t){return typeof e==`string`?((e,t)=>{let n=Object.create(null);return n[e]=t,n})(t,e):f(e)}const Wn=`smallestUnit`,Gn={constrain:0,reject:1},Kn={compatible:0,reject:1,earlier:2,later:3},qn={reject:0,use:1,prefer:2,ignore:3},Jn={auto:0,never:1,critical:2,always:3},Yn={auto:0,never:1,critical:2},Xn={auto:0,never:1},Zn={floor:0,halfFloor:1,ceil:2,halfCeil:3,trunc:4,halfTrunc:5,expand:6,halfExpand:7,halfEven:8},Qn=[Math.floor,e=>Me(e)?Math.floor(e):Math.round(e),Math.ceil,e=>Me(e)?Math.ceil(e):Math.round(e),Math.trunc,e=>Me(e)?Math.trunc(e)||0:Math.round(e),e=>e<0?Math.floor(e):Math.ceil(e),e=>Math.sign(e)*Math.round(Math.abs(e))||0,e=>Me(e)?(e=Math.trunc(e)||0)+e%2:Math.round(e)],$n={previous:-1,next:1};function er(e){let t=e.roundingIncrement;return t===void 0?1:s(t,`roundingIncrement`)}function tr(e){let t=e.fractionalSecondDigits;if(t!==void 0){if(typeof t!=`number`){if(zn(t)===`auto`)return;b(p(`fractionalSecondDigits`,t))}t=oe(`fractionalSecondDigits`,Math.floor(t),0,9,1)}return t}function nr(e,t,n=0,r){let i=t[e];if(i===void 0)return r?n:void 0;if(i=zn(i),i===`auto`)return r?n:null;let a=Ve[i];return a===void 0&&(a=Nn[i]),a===void 0&&b(g(e,i,Ve)),a}function rr(e,t,n,r=0){let i=n[e];if(i===void 0)return r;let a=zn(i),o=t[a];return o===void 0&&b(g(e,a,t)),o}const ir=S(nr,Wn),ar=S(nr,`largestUnit`),or=S(nr,`unit`),sr=S(rr,`overflow`,Gn),cr=S(rr,`disambiguation`,Kn),lr=S(rr,`offset`,qn),ur=S(rr,`calendarName`,Jn),dr=S(rr,`timeZoneName`,Yn),fr=S(rr,`offset`,Xn),pr=S(rr,`roundingMode`,Zn),mr=S(rr,`direction`,$n);function hr(e,t,n,r){let i=r?Ye:Xe[t+1];if(i){let n=Xe[t];i%((e=oe(`roundingIncrement`,e,1,i/n-(r?0:1),1))*n)&&b(p(`roundingIncrement`,e))}else e=oe(`roundingIncrement`,e,1,n?10**9:1,1);return e}function gr(e,t,n,r){return t!=null&&oe(e,t,n,r,1,He),t}function _r(e,t){t>e&&b(`smallestUnit > largestUnit`)}function vr(e,t,n,r=9,i=0,o=4){t=a(t);let s=ar(t,i),c=er(t),l=pr(t,o),u=ir(t,i,1);return s=gr(`largestUnit`,s,i,r),u=gr(Wn,u,i,r),s==null?s=Math.max(n,u):_r(s,u),c=hr(c,u,1),e&&(l=(e=>e<4?(e+2)%4:e)(l)),[s,u,c,l]}function yr(e,t=6,n){let r=er(e=Un(e,Wn)),i=pr(e,7),a=ir(e);return a=In(Wn,a),a=gr(Wn,a,0,t),r=hr(r,a,void 0,n),[a,r,i]}function N(e,t){return me(ot,e,me(D,t))}function P(e){return e===void 0?0:sr(f(e))}function br(e,t=0){e=a(e);let n=cr(e),r=lr(e,t);return[sr(e),r,n]}const xr=BigInt(1e8)*E,Sr=BigInt(-1e8)*E,Cr=Sr-E,wr=-3261848;function Tr(e){let t=12*e.year+e.month;return(t<wr||t>3309129)&&b(`Out-of-bounds date`),e}function F(e,t=1){return Dr(Ut(e),t),e}function Er(e){let t=Ut(e);return Dr(t),t!==Cr||O(e)||b(`Out-of-bounds date`),e}function Dr(e,t=1){(e<(t?Cr:Sr)||e>xr)&&b(`Out-of-bounds date`)}function Or(e){return(e<Sr||e>xr)&&b(`Out-of-bounds date`),e}function kr(e,t){return Or(Ut(e)+BigInt(O(e)-t))}function Ar(e){return{epochNanoseconds:e}}function jr(e,t,n){return{calendar:n,timeZone:t,epochNanoseconds:e}}function Mr(e,t){return me(D,e,I(e,t))}function I(e,t){return me(ot,e,{calendar:t})}function Nr(e){return me(D,e)}function L(e){return me(A,e,{sign:ta(e)})}function Pr(e){return t=e.epochNanoseconds,Number(Te(t,Qe));var t}function Fr(e){return e.epochNanoseconds}function Ir(e,t,n){let r=ua(t),[i,a]=((e,t)=>{let n=t((e=Un(e,`unit`)).relativeTo),r=or(e);return r=In(`unit`,r),[r,n]})(n,e);if(!a&&qi(Math.max(i,r),a))return Rr(t,i);if(a||b(`Missing relativeTo`),!t.sign&&qi(i,a))return 0;let o=Vi(a),s=o.G(o.i,t);Wi(o,s);let c=o.re(o.i,s,i);return qi(i,a)?Rr(c,i):Lr(c,o.V(s),i,o)}function Lr(e,t,n,r){let i=ta(e)||1,a=zr(Fn(n,e),n,i,r,t),o=a.ae,s=a.de,c=Number(s-o),l=Number(t-o);return a.ye[A[n]]+l/c*i}function Rr(e,t){return nt(ia(e),Xe[t])}function zr(e,t,n,r,i){let a=A[t],o=e,s=0,c=Br(o,a,n,r);return i&&!((e,t,n,r)=>r>0?T(t,e)<=0&&T(e,n)<=0:T(n,e)<=0&&T(e,t)<=0)(i,c.ae,c.de,Math.sign(n))&&(o={...e,[a]:e[a]+n},s=1,c=Br(o,a,n,r)),{...c,ye:o,He:s}}function Br(e,t,n,r){let i={...e,[t]:e[t]+n};return{ae:Hi(r,e),de:Hi(r,i),Ae:i}}function Vr(e,t,n){let r=n-t,i=e-t;if(!i)return 0;let a=i<0n?-i:i,o=r<0n?-r:r,s=T(i,0n)===T(r,0n)?1:-1;return T(a,o)<=0?a===o?s:je(T(2n*a,o),s):Number(i)/Number(r)}function Hr(e,t,n,r){let{epochNanoseconds:i}=e,{timeZone:a,calendar:o}=e;if(t===0&&n===1)return{epochNanoseconds:i,timeZone:a,calendar:o};if(t===6){let t=N(R(e),At),n=N(vi(t,1),At),o=ui(a,t),s=ui(a,n);i=ni(Vr(i,o,s),r)?s:o}else{let o=R(e),s=o.offsetNanoseconds;i=ci(a,Gr(o,Jr(t,n),r),s,2,0,1)}return{epochNanoseconds:i,timeZone:a,calendar:o}}function Ur(e){let{timeZone:t}=e,n=N(R(e),At),r=N(vi(n,1),At),i=ui(t,n);return nt(ui(t,r)-i,Je)}function Wr(e){let{timeZone:t,calendar:n}=e;return jr(ui(t,N(R(e),At)),t,n)}function Gr(e,t,n){let[r,i]=Kr(e,t,n),a=N(vi(e,i),r);return Er(a),a}function Kr(e,t,n){return Lt(ti(O(e),t,n))}function qr(e){return ti(e,qe,7)}function Jr(e,t){return Xe[e]*t}function Yr(e,t){return BigInt(Xe[e])*BigInt(t)}function Xr(e,t,n){let r=Math.min(ua(e),6);return sa(Qr(ia(e),BigInt(t),n),r)}function Zr(e,t,n,r,i,a,o){if(r===0&&i===1)return e;let s=ta(e)||1,[c,l,u]=(qi(r,o.i)?Ui(o.i)&&r<6&&n>=6?ii:ri:ai)(s,e,t,n,r,i,a,o);return u&&r!==7&&(c=((e,t,n,r,i,a)=>{for(let o=r+1;o<=n;o++){if(o===7&&n!==7)continue;let r=Fn(o,e);r[A[o]]+=i;let s=T(t,Hi(a,r));if(s&&s!==i)break;e=r}return e})(c,l,n,Math.max(6,r),s,o)),c}function Qr(e,t,n){return ei(e,t,n,e/t%2n)}function $r(e,t,n){let[r,i]=Ee(e,E),a=r*E;return a+ei(i,t,n,(a/t+i/t)%2n)}function ei(e,t,n,r){let i=e/t,a=e%t,o=0;a&&(o=je(T(2n*(a<0n?-a:a),t),Math.sign(Number(a))));let s=ni(Number(r)+o,n);return(i-r+BigInt(s))*t}function ti(e,t,n){return ni(e/t,n)*t}function ni(e,t){return Qn[t](e)}function ri(e,t,n,r,i,a,o){let s=ia(t),c=Qr(s,Yr(i,a),o),l=c-s,u=Math.sign(Number(c/E)-Number(s/E))===e,d=sa(c,Math.min(r,6));return[{...t,...d},n+l,u]}function ii(e,t,n,r,i,a,o,s){let c=Number(aa(t)),l=Jr(i,a),u=ti(c,l,o),d=zr({...t,...Pn},6,e,s,n),f=d.ae,p=d.de,m=u-Number(p-f),h=0;m&&Math.sign(m)!==e?n=f+BigInt(u):(h+=e,u=ti(m,l,o),n=p+BigInt(u));let g=ca(u);return[{...t,...g,days:t.days+h},n,!!h]}function ai(e,t,n,r,i,a,o,s){let c=A[i],l=Fn(i,t);i===7&&(t={...t,weeks:t.weeks+Math.trunc(t.days/7)}),l[c]=ke(t[c],a)*a;let u=zr(l,i,a*e,s,n),d=u.ae,f=u.de,p=Vr(n,d,f),m=u.ye[c],h=u.Ae[c],g=ti(m+p*e*a,a,o),_=g===h;return l[c]=g,[l,_?f:d,u.He||_]}function oi(e,t){return e.timeZone.U(e.epochNanoseconds,(e=>{let t=mr(Un(e,`direction`),0);return t||b(p(`direction`,t)),t})(t))}const R=se(si,WeakMap);function si(e){let{epochNanoseconds:t,timeZone:n}=e,r=n.C(t);return{...qt(t+BigInt(r)),offsetNanoseconds:r}}function ci(e,t,n,r=0,i=0,a,o){if(n!==void 0&&r===1&&(r===1||o))return kr(t,n);r!==2&&r!==0||F(t,0);let s=e.R(t);if(n!==void 0&&r!==3){let e=((e,t,n,r)=>{let i=Vt(t);r&&(n=qr(n));for(let t of e){let e=Number(i-t);if(r&&(e=qr(e)),e===n)return t}})(s,t,n,a);if(e!==void 0)return e;r===0&&b(`Invalid TimeZone offset`)}return o?Vt(t):li(e,t,i,s)}function li(e,t,n=0,r=e.R(t)){if(r.length===1)return r[0];if(n===1&&b(`Ambiguous offset`),r.length)return r[n===3?1:0];let i=Vt(t),a=((e,t)=>{let n=e.C(t-E);return(e=>(e>864e11&&b(`Out-of-bounds TimeZone gap`),e))(e.C(t+E)-n)})(e,i),o=qt(i+BigInt(a*(n===2?-1:1)));return(r=e.R(o))[n===2?0:r.length-1]}function ui(e,t){let n=e.R(t);if(n.length)return n[0];let r=Vt(t)-E;return e.U(r,1)}function di(e,t,n,r,i){let a=P(i);return r.sign&&ua(r)<8&&b(`Cannot use small units`),gi(t,yi(t,F(gi(t,n)),e?z(r):r,a))}function fi(e,t){return Or(e+(la(n=t)&&b(`Cannot use large units`),aa(n)));var n}function pi(e,t,n){let{calendar:r,epochNanoseconds:i,timeZone:a}=e,o=aa(t),s=i;if(la(t)){let i=R(e);s=li(a,N(hi(r,i,{...t,...Pn},n),i))+o}else s+=o,P(n);return{...e,epochNanoseconds:Or(s)}}function mi(e,t,n,r){let[i,a]=_i(t,n),o=N(hi(e,t,{...n,...Pn,days:n.days+a},r),i);return Er(o),o}function hi(e,t,n,r){if(n.years||n.months||n.weeks)return yi(e,t,n,P(r));P(r);let i=n.days+Number(aa(n)/E);return i?F(vi(t,i)):t}function gi(e,t){return vi(t,1-k(e,t).day)}function _i(e,t){let n=aa(t),r=Number(n/E),i=Number(n%E),[a,o]=Lt(O(e)+i);return[a,r+o]}function vi(e,t){return t?Yt(Gt(e)+t):e}function yi(e,t,n,r){let{years:i,months:a,weeks:o,days:s}=n,c;if(s+=Number(aa(n)/E),i||a)c=bi(e,t,i,a,r);else{if(!o&&!s)return t;c=t}return(o||s)&&(c=vi(c,7*o+s)),F(c)}function bi(e,t,n,r,i){let{year:a,month:o,day:s}=k(e,t);if(n){let[t,r]=hn(e,a,o);a+=n,o=xi(e,t,r,e?e.q(a):void 0,i),o=oe(`month`,o,1,vn(e,a),i)}if(r){let t=e?e.N(a,o,r):rn(a,o,r);({year:a,month:o}=t)}return s=oe(`day`,s,1,yn(e,a,o),i),_n(e,a,o,s)}function xi(e,t,n,r,i){if(n){let n=e?e.m:void 0;return r!==void 0&&(n<0||r===t+1)?r:(i===1&&b(v),n<0?-n:t)}return ze(t,0,r)}function Si(e,t){return Fe(e)!==Fe(t)&&b(`Mismatching Calendars`),e}function Ci(e,t){return e.o!==t.o&&b(`Mismatching TimeZones`),e}function wi(e){return e.timeZone.id}function Ti(e,t,n,r){let[i,a,o,s]=vr(e,r,3,5),c=Ri(t.epochNanoseconds,n.epochNanoseconds,i,a,o,s);return L(e?z(c):c)}function Ei(e,t,n,r,i){let[a,o,s,c]=vr(e,i,5),l=n.epochNanoseconds,u=r.epochNanoseconds,d;return T(u,l)?a<6?d=Ri(l,u,a,o,s,c):(d=Mi(Ci(n.timeZone,r.timeZone),t,n,r,a),d=Zr(d,u,a,o,s,c,Bi(n,Fr,pi))):d=j,L(e?z(d):d)}function Di(e,t,n,r,i){let[a,o,s,c]=vr(e,i,6),l=Vt(n),u=Vt(r),d=T(u,l),f;return d?a<=6?f=Ri(l,u,a,o,s,c):(f=Pi(t,n,r,d,a),f=Zr(f,u,a,o,s,c,Bi(n,Vt,S(mi,t)))):f=j,L(e?z(f):f)}function Oi(e,t,n,r,i){let[a,o,s,c]=vr(e,i,6,9,6);return Ai(e,t,n,r,a,o,s,c)}function ki(e,t,n,r,i){let[a,o,s,c]=vr(e,i,9,9,8),l=gi(t,n),u=gi(t,r);return Ii(l,u)?Ai(e,t,F(l),F(u),a,o,s,c,8):L(j)}function Ai(e,t,n,r,i,a,o,s,c=6){let l=Ut(n),u=Ut(r),d;return T(u,l)?i===6?d=Ri(l,u,i,a,o,s):(d=Fi(t,n,r,i),a===c&&o===1||(d=Zr(d,u,i,a,o,s,Bi(n,Ut,S(hi,t))))):d=j,L(e?z(d):d)}function ji(e,t,n,r){let[i,a,o,s]=vr(e,r,5,5),c=ti(O(n)-O(t),Jr(a,o),s),l={...j,...ca(c,i)};return L(e?z(l):l)}function Mi(e,t,n,r,i){let a=T(r.epochNanoseconds,n.epochNanoseconds);if(!a)return j;if(i<6)return{...j,...sa(r.epochNanoseconds-n.epochNanoseconds,i)};if(!Ii(R(n),R(r)))return{...j,...sa(r.epochNanoseconds-n.epochNanoseconds,5)};let[o,s,c]=Li(e,n,r,a);return{...i===6?{...j,days:zi(o,s)}:Fi(t,o,s,i),...ca(c)}}function Ni(e,t,n,r){let i=Vt(t),a=Vt(n),o=T(a,i);return o?r<=6?{...j,...sa(a-i,r)}:Pi(e,t,n,o,r):j}function Pi(e,t,n,r,i){let a=n,o=O(n)-O(t);return Math.sign(o)===-r&&(a=vi(n,-r),o+=864e11*r),{...Fi(e,t,a,i),...ca(o)}}function Fi(e,t,n,r){if(r<=7){let e=zi(t,n);return r===7?{...j,weeks:ke(e,7),days:Ae(e,7)}:{...j,days:e}}let i=k(e,t),a=k(e,n);if(r===8){let{year:r,month:o,day:s}=i,{year:c,month:l,day:u}=a,d=Math.sign(w(c,r)||w(l,o)||zi(t,n)),f=0,p=0;if(d){f=e?e.ne(r,o,c,l):an(r,o,c,l);let i=bi(e,t,0,f,0);d*w(s,u)>0&&(f-=d,i=bi(e,t,0,f,0)),p=zi(i,n)}return{...j,months:f,days:p}}let{year:o,month:s,day:c}=i,{year:l,month:u,day:d}=a,f=l-o,p=u-s,m=d-c;if(f||p){let t=Math.sign(f||p),n=yn(e,l,u),r=0;if(Math.sign(d-c)===-t){let i=n,a=e?e.N(l,u,-t):rn(l,u,-t);({year:l,month:u}=a),f=l-o,p=u-s,n=yn(e,l,u),r=t<0?-i:n}if(m=d-Math.min(c,n)+r,f){let[n,r]=hn(e,o,s),[i,a]=hn(e,l,u),c=e?e.m:void 0;if(p=c!==void 0&&r&&!a&&(c<0?t>0&&i===-c:t<0&&i===n)?0:i-n||Number(a)-Number(r),Math.sign(p)===-t){let i=t<0&&-vn(e,l);l-=t,f=l-o,p=u-xi(e,n,r,e?e.q(l):void 0,0)+(i||vn(e,l))}else if(e){let t=xi(e,n,r,e.q(l),0);p=e.ne(l,t,l,u)}}}return{...j,years:f,months:p,days:m}}function Ii(e,t){return w(e.year,t.year)||w(e.month,t.month)||w(e.day,t.day)}function Li(e,t,n,r){let i=R(t),a=R(n),o=n.epochNanoseconds,s=0,c=O(a)-O(i);Math.sign(c)===-r&&s++;let l=s+(r>0?1:0);for(;s<=l;s++){let t=vi(a,s*-r),n=li(e,N(t,i));if(T(o,n)!==-r)return[i,t,Number(o-n)]}}function Ri(e,t,n,r,i,a){return{...j,...sa(Qr(t-e,Yr(r,i),a),n)}}function zi(e,t){return Gt(t)-Gt(e)}function Bi(e,t,n){return{i:e,V:t,G:n}}function Vi(e){let{calendar:t}=e;if(Ui(e)){let{timeZone:n}=e;return{i:e,V:Fr,G:pi,re:S(Mi,n,t)}}return{i:Gi(e),V:Vt,G:S(mi,t),re:S(Ni,t)}}function Hi(e,t){return e.V(e.G(e.i,t))}function Ui(e){return`timeZone`in e}function Wi(e,t){Ui(e.i)||(Ki(e.i),Ki(t))}function Gi(e){return N(e,`hour`in e?e:At)}function Ki(e){Er(Gi(e))}function qi(e,t){return e<=6-(t&&Ui(t)?1:0)}function Ji(e,t,n){let r={};for(let i=t;i>=0;i--){let t=Xe[i];r[n[i]]=ke(e,t),e=Ae(e,t)}return r}const Yi=2**53;function Xi(e,t,n,r,i){let o=e(a(i).relativeTo),s=Math.max(ua(n),ua(r));if(qi(s,o))return Zi(t,n,r,s);o||b(`Missing relativeTo`),t&&(r=z(r));let c=Vi(o),l=c.G(c.i,n),u=c.G(l,r);return L(c.re(c.i,u,s))}function Zi(e,t,n,r){return L(na(((e,t,n,r)=>{let i=ia(e)+ia(t)*BigInt(r?-1:1);return Number.isFinite(Number(i/E))||b(`Out-of-bounds date`),{...j,...sa(i,n)}})(t,n,r,e)))}function Qi(e,t,n){let r=ua(t),[i,a,o,s,c]=((e,t,n)=>{e=Un(e,Wn);let r=ar(e),i=n(e.relativeTo),a=er(e),o=pr(e,7),s=ir(e);return r===void 0&&s===void 0&&b(`Required smallestUnit or largestUnit`),s??=0,r??=Math.max(s,t),_r(r,s),a=hr(a,s,1),a>1&&s>5&&r!==s&&b(`For calendar units with roundingIncrement > 1, use largestUnit = smallestUnit`),[r,s,a,o,i]})(n,r,e);if(!c&&Math.max(r,i)<=6)return L(na(((e,t,n,r,i)=>{let a=Qr(ia(e),Yr(n,r),i);return{...j,...sa(a,t)}})(t,i,a,o,s)));let l=c&&Ui(c)&&i>=6&&a<6;if(!t.sign&&!l)return t;c||b(`Missing relativeTo`);let u=Vi(c),d=u.G(u.i,t);Wi(u,d);let f=u.re(u.i,d,i);return f=Zr(f,u.V(d),i,a,o,s,u),L(f)}function $i(e){return e.sign===-1?ea(e):e}function ea(e){return L(z(e))}function z(e){let t={};for(let n of A)t[n]=-1*e[n]||0;return t}function ta(e,t=A){let n=0;for(let r of t){let t=Math.sign(e[r]);t&&(n&&n!==t&&b(`Cannot mix duration signs`),n=t)}return n}function na(e){for(let t of Mn)oe(t,e[t],-4294967295,4294967295,1);let t=ia(e);return ra(Number(t/$e)),e}function ra(e){Number.isSafeInteger(e)||b(`Out-of-bounds duration`)}function ia(e){return BigInt(e.days)*E+aa(e)}function aa(e){return BigInt(e.hours)*tt+BigInt(e.minutes)*et+oa(e)}function oa(e){return BigInt(e.seconds)*$e+BigInt(e.milliseconds)*Qe+BigInt(e.microseconds)*Ze+BigInt(e.nanoseconds)}function sa(e,t=6){let n=Number(e/E),r=Number(e%E),i=Xe[t],a=t<=3?Number(e/BigInt(i)):Ye/i*n+ke(r,i);Number.isFinite(a)||b(`Out-of-bounds date`),t<=3&&Math.abs(a)/(Ke/Xe[t])>=Yi&&b(`Out-of-bounds date`);let o=Ji(r,t,A);return o[A[t]]=a,o}function ca(e,t=5){return Ji(e,t,A)}function la(e){return!!ta(e,jn)}function ua(e){let t=9;for(;t>0&&!e[A[t]];t--);return t}function da(e,t){return T(e.epochNanoseconds,t.epochNanoseconds)}function fa(e,t){return T(e.epochNanoseconds,t.epochNanoseconds)}function pa(e,t,n,r){let i=e(a(r).relativeTo),o=Math.max(ua(t),ua(n));if(he(A,t,n))return 0;if(qi(o,i))return T(ia(t),ia(n));i||b(`Missing relativeTo`);let s=Vi(i);return T(Hi(s,t),Hi(s,n))}function ma(e,t){return ha(e,t)||ga(e,t)}function ha(e,t){return w(Gt(e),Gt(t))}function ga(e,t){return w(O(e),O(t))}function _a(e,t){return!da(e,t)}function va(e,t){return!fa(e,t)&&e.timeZone.o===t.timeZone.o&&e.calendar===t.calendar}function ya(e,t){return!ma(e,t)&&e.calendar===t.calendar}function ba(e,t){return!ha(e,t)&&e.calendar===t.calendar}function xa(e,t){return!ha(e,t)&&e.calendar===t.calendar}function Sa(e,t){return!ha(e,t)&&e.calendar===t.calendar}function Ca(e,t){return!ga(e,t)}function wa(e){return e===0?Ne:e?e.l:void 0}function B(e,t,n=t){return wa(e)?n:t}function Ta(e,t){let n=e||void 0,r=wa(e),{era:i,eraYear:a,year:o}=t;if(o!==void 0&&(o=s(o,`year`)),a!==void 0&&(a=s(a,`eraYear`)),i!==void 0||a!==void 0){i!==void 0&&a!==void 0||x(`Mismatching era/eraYear`),r||b(`Forbidden era/eraYear`);let e=Pe(i),t=r[e];t===void 0&&b((e=>`Invalid era: ${e}`)(i));let s=n?.te?n.te(a,e,t):Oa(a,t);o!==void 0&&o!==s&&b(`Mismatching year/eraYear`),o=s}else o===void 0&&x(_(r));return o}function Ea(e,t,n,r,i){let{month:a,monthCode:o}=t;if(o!==void 0){let t=((e,t,n,r,i=Le(t))=>{let a=e?e.q(n):void 0,[o,s]=i,c=ze(o,s,a);if(s){let t=e?e.m:void 0;t===void 0&&b(v),t>0?(c>t&&b(v),a!==c&&(r===1&&b(v),c=ze(o,0,a))):(c!==-t&&b(v),a===void 0&&r===1&&b(v))}return c})(e,o,n,r,i);a!==void 0&&a!==t&&b(`Mismatching month/monthCode`),a=t,r=1}else a===void 0&&x(`Missing month/monthCode`);return oe(`month`,a,1,vn(e,n),r)}function Da(e,t,n,r,i){return ae(t,`day`,1,yn(e,r,n),i)}function Oa(e,t){return(t+e)*(Math.sign(t)||1)||0}function ka(e,t){return Nt(me(D,{...At,...e}),t)}const Aa=ye(`([+-])(\\d{2})(?::?(\\d{2})(?::?(\\d{2})(?:[.,](\\d{1,9}))?)?)?`);function ja(e){let t=Ma(e);return t===void 0&&b(ne(e)),t}function Ma(e,t){let n=Aa.exec(e);if(n&&(e=>(e=>{e[0]!==`T`&&e[0]!==`t`||(e=e.slice(1));let t=e.search(/[.,]/),n=t<0?e:e.slice(0,t),r=n.split(`:`);return r.length===1?/^(?:\d{2}|\d{4}|\d{6})$/i.test(n):(r.length===2||r.length===3)&&r.every(e=>e.length===2&&/^\d{2}$/i.test(e))})(e.slice(1)))(n[0]))return((e,t)=>{let n=e[4]||e[5];return t&&n&&b(re(n)),r=(Se(e[2])*Je+Se(e[3])*qe+Se(e[4])*Ke+be(e[5]||``))*xe(e[1]),Math.abs(r)>=864e11&&b(`Out-of-bounds offset`),r;var r})(n,t)}const Na={era:Bn,month:c,monthCode(e,t=`monthCode`){return((e,t)=>{if(typeof e==`string`)return e;if(e&&typeof e==`object`){let n=e.toString;if(typeof n==`function`)return M(n.call(e),t)}return M(e,t)})(e,t)},day:c},Pa=fe(D,s),Fa=fe(A,Hn),Ia={offset(e){return ja(Bn(e))}},La=Object.assign({},Na,Pa),Ra=Object.assign({},La,Ia);function V(e,t,n,r,i=!r){let a={},o=0;for(let i of t){let t=e[i];if(t!==void 0){o=1;let e=n[i];e&&(t=e(t,i)),a[i]=t}else r&&r.includes(i)&&x(m(i))}return i&&!o&&x(h(t)),a}function za(e,t=At,n){let r=N(e,t);return Er(r),Mr(r,n)}function Ba(e,t,n){return Ha(e,t,Wa(e,t),P(n))}function Va(e,t,n){let r=Wa(e,t),i=n();return[Ha(e,t,r,i[0]),...i]}function Ha(e,t,n,r){let i=n[1],a=Ea(e,t,i,r,n[0]);return I(F(_n(e,i,a,Da(e,t,a,i,r))),e)}function Ua(e){if(e.monthCode!==void 0)return Le(e.monthCode)}function Wa(e,t){let n=wa(e);return t.year!==void 0||t.era!==void 0&&t.eraYear!==void 0||x(_(n)),t.monthCode===void 0&&t.month===void 0&&x(`Missing month/monthCode`),t.day===void 0&&x(m(`day`)),[Ua(t),Ta(e,t)]}function Ga(e,t,n){let r=wa(e);t.year!==void 0||t.era!==void 0&&t.eraYear!==void 0||x(_(r)),t.monthCode===void 0&&t.month===void 0&&x(`Missing month/monthCode`);let i=Ua(t),a=Ta(e,t);return I(Tr(_n(e,a,Ea(e,t,a,P(n),i),1)),e)}function Ka(e,t,n){let r=e===void 0,i=wa(e);t.day===void 0&&x(m(`day`)),r||t.month===void 0||t.year!==void 0||t.era!==void 0&&t.eraYear!==void 0||x(_(i));let a=Ua(t),o=t.eraYear!==void 0||t.year!==void 0?Ta(e,t):void 0,s=P(n),c,l,u;if(o===void 0&&r&&(o=1972),o!==void 0){r||F(_n(e,o,1,1));let n=Ea(e,t,o,s,a);c=Da(e,t,n,o,s),[l,u]=hn(e,o,n)}else{t.monthCode===void 0&&x(`Missing month/monthCode`),[l,u]=a;let n=e?e.ge:1972;if(n!==void 0)c=Da(e,t,Ea(e,t,n,s,a),n,s);else{let n=s===0&&e?e.ke?.(l,u,t.day):void 0;c=n===void 0?t.day:n}}u&&((e&&e.Z?.[l])??1/0)<t.day&&(s===1&&b(v),u=0,c=ie(t.day,1,(e&&e.X)??1/0));let d=e?e.v(l,!!u,c):Qt(l,!!u);for(;!d&&s===0&&c>1;)c--,d=e?e.v(l,!!u,c):Qt(l,!!u);d||b(`Cannot guess year`);let{year:f,month:p}=d;return I(F(_n(e,f,p,c)),e)}const qa=Intl.DateTimeFormat;function Ja(e,t){t<-864e13&&b(`Out-of-bounds date`);let n=e.formatToParts(t),r={};for(let e of n)r[e.type]=e.value;return r}const Ya={El_Aaiun:17,Tucuman:12,Tirane:11,Riga:10,Simferopol:9,Vienna:9,Tunis:8,Boa_Vista:6,Fortaleza:6,Maceio:6,Noronha:6,Recife:6,Gaza:6,Hebron:6,DeNoronha:6},Xa=-388152e4;function Za(e,t=4){let n=tr(e);return[pr(e,4),...eo(gr(Wn,ir(e),0,t),n)]}function Qa(e){return ur(a(e))}function $a(e,t){return Za(a(e),t)}function eo(e,t){return e==null?[t===void 0?1:10**(9-t),t]:[Xe[e],e<4?9-3*e:-1]}function to(e,t,n){let[r,i,o,s]=(e=>{let t=tr(e=a(e)),n=pr(e,4),r=ir(e);return[e.timeZone,n,...eo(gr(Wn,r,0,4),t)]})(n),c=r!==void 0;return((e,t,n,r,i,a)=>{n=$r(n,BigInt(i),r);let o=t.C(n);return mo(qt(n+BigInt(o)),a)+(e?yo(qr(o)):`Z`)})(c,H(c?e(r):`UTC`),t.epochNanoseconds,i,o,s)}function no(e,t){let n=(e=>{e=a(e);let t=ur(e),n=tr(e),r=fr(e),i=pr(e,4),o=ir(e);return[t,dr(e),r,i,...eo(gr(Wn,o,0,4),n)]})(t);return((e,t,n,r,i,a,o,s,c,l)=>{r=$r(r,BigInt(c),s);let u=n.C(r);return mo(qt(r+BigInt(u)),l)+yo(qr(u),o)+bo(t,a)+xo(e,i)})(e.calendar,e.timeZone.id,e.timeZone,e.epochNanoseconds,...n)}function ro(e,t){let n=(e=>(e=a(e),[ur(e),...Za(e)]))(t);return((e,t,n,r,i,a)=>mo(Gr(t,i,r),a)+xo(e,n))(e.calendar,e,...n)}function io(e,t){return n=e.calendar,r=e,i=Qa(t),ho(r)+xo(n,i);var n,r,i}function ao(e,t){return so(e.calendar,go,e,Qa(t))}function oo(e,t){return so(e.calendar,_o,e,Qa(t))}function so(e,t,n,r){return r===1?e===void 0?t(n):ho(n):r>1||r===0&&e!==void 0?ho(n)+So(Fe(e),r===2):t(n)}function co(e,t){return((e,t,n,r)=>vo(Kr(e,n,t)[0],r))(e,...$a(t))}function lo(e,t){let[n,r,i]=$a(t,3);return r>1&&na(e={...e,...Xr(e,r,n)}),uo(e,i)}function uo(e,t){let{sign:n}=e,r=n===-1?z(e):e,{hours:i,minutes:a}=r,o=oa(r),s=Number(o/$e),c=Number(o%$e);ra(s);let l=wo(c,t),u=t>=0||!n||l;return(n<0?`-`:``)+`P`+fo({Y:po(r.years),M:po(r.months),W:po(r.weeks),D:po(r.days)})+(i||a||s||u?`T`+fo({H:po(i),M:po(a),S:po(s,u)+l}):``)}function fo(e){let t=[];for(let n in e){let r=e[n];r&&t.push(r,n)}return t.join(``)}function po(e,t){if(!e&&!t)return``;let n=Object.create(null);return n.useGrouping=0,e.toLocaleString(`fullwide`,n)}function mo(e,t){return ho(e)+`T`+vo(e,t)}function ho(e){return go(e)+`-`+we(e.day)}function go(e){let{year:t}=e;return(t<0||t>9999?To(t)+Ce(6,Math.abs(t)):Ce(4,t))+`-`+we(e.month)}function _o(e){return we(e.month)+`-`+we(e.day)}function vo(e,t){let n=[we(e.hour),we(e.minute)];return t!==-1&&n.push(we(e.second)+((e,t,n,r)=>wo(e*Ge+t*We+n,r))(e.millisecond,e.microsecond,e.nanosecond,t)),n.join(`:`)}function yo(e,t=0){if(t===1)return``;let[n,r]=De(Math.abs(e),Je),[i,a]=De(r,qe),[o,s]=De(a,Ke);return To(e)+we(n)+`:`+we(i)+(o||s?`:`+we(o)+wo(s):``)}function bo(e,t){return t===1?``:`[`+(t===2?`!`:``)+e+`]`}function xo(e,t){return t>1||t===0&&e!==void 0?So(Fe(e),t===2):``}function So(e,t){return`[`+(t?`!`:``)+`u-ca=`+e+`]`}const Co=/0+$/;function wo(e,t){let n=Ce(9,e);return n=t===void 0?n.replace(Co,``):n.slice(0,t),n?`.`+n:``}function To(e){return e<0?`-`:`+`}const Eo=/^(AC|AE|AG|AR|AS|BE|BS|CA|CN|CS|CT|EA|EC|IE|IS|JS|MI|NE|NS|PL|PN|PR|PS|SS|VS)T$/,Do=/[^\w\/:+-]+/;function Oo(e){return ko(M(e))}function ko(e){return Ao(e).id}function Ao(e){let t=e.toUpperCase(),n=(e=>{let t=Ma(e,1);if(t!==void 0)return{id:yo(t),_:t,o:t}})(t);return n?{kind:`fixed`,...n}:jo(t===`UTC`?`UTC`:(e=>(Do.test(e)&&b(te(e)),Eo.test(e)&&b(`Forbidden ICU TimeZone`),e.toLowerCase().split(`/`).map((e,t)=>(e.length<=3||/\d/.test(e))&&!/etc|yap/.test(e)?e.toUpperCase():e.replace(/baja|dumont|[a-z]+/g,(e,n)=>e.length<=2&&!t||e===`in`||e===`chat`?e.toUpperCase():e.length>2||!n?ve(e).replace(/island|noronha|murdo|rivadavia|urville/,ve):e)).join(`/`)))(e))}const jo=se(e=>{if(e===`UTC`)return{kind:`utc`,id:e,o:e};let t=Mo(e.toUpperCase());return{kind:`named`,id:e,format:t,o:t.resolvedOptions().timeZone}}),Mo=se(e=>new qa(`en-u-hc-h23`,{calendar:`iso8601`,timeZone:e,era:`short`,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`}));function H(e){let t=Ao(e);return No(t.id,t)}const No=se((e,t)=>t.kind===`named`?new Fo(e,t.o,t.format):new Po(e,t.o,t.kind===`fixed`?t._:0));var Po=class{constructor(e,t,n){this.id=e,this.o=t,this._=n}C(){return this._}R(e){return[kr(e,this._)]}U(){}},Fo=class{constructor(e,t,n){this.id=e,this.o=t,this.qe=((e,t)=>{let n=se(e),r=se(Lo),i=86400*t;function a(e){let[t,a]=Ro(e,i),s=zo(t),c=zo(a),l=n(s),u=n(c);return l===u?l:o(r(s,c),l,u,e)}function o(t,n,r,i){let a,o;for(;(i===void 0||(a=i<t[0]?n:i>=t[1]?r:void 0)===void 0)&&(o=t[1]-t[0]);){let n=t[0]+Math.floor(o/2);e(n)===r?t[1]=n:t[0]=n+1}return a}return{Ee(e){let t=a(e-86400),n=a(e+86400),r=e-t,i=e-n;if(t===n)return[r];let o=a(r);return o===a(i)?[e-o]:t>n?[r,i]:[]},De:a,U:function e(t,a){if(a>0&&t>=864e10)return;if(a<0){if(t<=Xa)return;let n=Io()+94867200;if(t>n)return e(n,-1)}let[s,c]=Ro(a>0?Math.max(t,Xa):t,i),l=i*a,u=a>0?Math.max(t,Io())+94867200:Xa,d=()=>a<0?c>u:s<u;for(;d();){let e=zo(s),i=zo(c),u=n(e),d=n(i);if(u!==d){let n=r(e,i);o(n,u,d);let s=n[0];if((w(s,t)||1)===a)return s}s+=l,c+=l}}}})((e=>t=>{let n=Ja(e,1e3*t);return 86400*Kt((e=>{let t=e.relatedYear;if(t!==void 0)return parseInt(t);let n=parseInt(e.year);return e.era!==void 0&&Pe(e.era)===`bce`?1-n:n})(n),parseInt(n.month),parseInt(n.day))+3600*parseInt(n.hour)+60*parseInt(n.minute)+parseInt(n.second)-t})(n),(e=>Ya[e.split(`/`).pop()]||60)(e))}C(e){return this.qe.De((e=>Bt(e)[0])(e))*Ke}R(e){let t=86400*Gt(e)+Ft(e),n=It(e);return this.qe.Ee(t).map(e=>Or(BigInt(e)*$e+BigInt(n)))}U(e,t){let[n,r]=Bt(e),i=this.qe.U(n+(t>0||r?1:0),t);if(i!==void 0)return BigInt(i)*$e}};function Io(){return Math.floor(Date.now()/1e3)}function Lo(e,t){return[e,t]}function Ro(e,t){let n=Math.floor(e/t)*t;return[n,n+t]}function zo(e){return ie(e,-1e10,864e10)}function Bo(e,t,n){let r=V(n,B(t,Et,Dt),Ra,[],0);if(r.timeZone!==void 0){let n=Ba(t,r),i=ka(r),a=H(e(r.timeZone));return{epochNanoseconds:ci(a,N(n,i),r.offset),timeZone:a,calendar:t}}return Ba(t,r)}function Vo(e,t,n,r){let i=V(n,B(t,Et,Dt),Ra,ct,0),a=e(i.timeZone),[o,s,c,l]=Va(t,i,()=>br(r)),u=ka(i,s),d=H(a);return jr(ci(d,N(o,u),i.offset,c,l),d,t)}function Ho(e,t,n){let r=V(t,B(e,St,Ct),La,[],0),[i,a]=Va(e,r,()=>[P(n)]);return za(i,ka(r,a),e)}function Uo(e,t,n,r=[]){return Ba(e,V(t,B(e,bt,xt),Na,r),n)}function Wo(e,t,n,r){return Ga(e,V(t,B(e,ht,gt),Na,r),n)}function Go(e,t,n,r){let i=V(n,B(e,bt,xt),Na,at,0);return t&&i.month!==void 0&&i.monthCode===void 0&&i.year===void 0&&(i.year=1972),Ka(e,i,r)}function Ko(e,t){return ka(V(e,pt,Pa,[],1),P(t))}function qo(e){let t=V(e,kn,Fa);return L(na({...j,...t}))}function Jo(e){b(ne(e))}function Yo(e){let t=Cs(e=Bn(e)),n;return t||Jo(e),t.F?n=0:t.offset?n=ja(t.offset):Jo(e),t.timeZoneId&&Ma(t.timeZoneId,1),dn(t),Ar(kr(t,n))}function Xo(e,t){let n=Cs(M(e));return n||Jo(e),n.timeZoneId?ds(n,t,void 0):(n.F&&Jo(e),ps(n,t))}function Zo(e,t,n){let r=Cs(M(e));return r&&r.timeZoneId||Jo(e),ds(r,t,n)}function Qo(e,t){let n=Cs(M(e));return n&&!n.F||Jo(e),fs(n,t)}function $o(e,t){let n=cs(ss(M(e)),void 0,t);return I(n,n.calendar)}function es(e,t){let n=ws(M(e));if(n)return ts(n),I(Tr(fn(n)),t(n.calendarId));let r=cs(ss(e),ls,t),{calendar:i}=r;return I(gi(i,r),i)}function ts(e){e.calendarId!==`iso8601`&&b(re(e.calendarId))}function ns(e,t){let n=Ts(M(e));if(n)return ts(n),I(fn(n),t(n.calendarId));let r=cs(ss(e),us,t),{calendar:i}=r,{year:a,month:o,day:s}=k(i,r),[c,l]=hn(i,a,o),{year:u,month:d}=((e,t,n,r)=>{let i=e?e.v(t,n,r):Qt(t,n);return i||b(`Cannot guess year`),i})(i,c,l,s);return I(F(_n(i,u,d,s)),i)}function rs(e){let t=(e=>{let t=Es(e);return t?(ks(t[13]),Ds(t,1)):void 0})(e=M(e)),n;return t||(t=Cs(e),t?(t.fe||Jo(e),t.F&&b(re(`Z`)),ts(t)):Jo(e)),(n=ws(e))&&pn(n)&&Jo(e),(n=Ts(e))&&pn(n)&&Jo(e),Nr(jt(t))}function is(e){let t=(e=>{let t=Ss.exec(e);return t?(e=>{let t=0,n=0,r=0,i={years:a(e[2]),months:a(e[3]),weeks:a(e[4]),days:a(e[5]),hours:a(e[6],e[7],5),minutes:a(e[8],e[9],4),seconds:a(e[10],e[11],3),...Ji(r,2,A)};return t||b(h(A)),xe(e[1])<0&&(i=z(i)),i;function a(e,i,a){let o=0,s=0;return a&&([o,r]=De(r,Xe[a])),e!==void 0&&(n&&b(re(e)),s=(e=>{let t=parseInt(e);return Number.isFinite(t)||b(re(e)),t})(e),t=1,i&&(r=be(i)*(Xe[a]/Ke),n=1)),o+s}})(t):void 0})(M(e));return t||Jo(e),L(na(t))}function as(e){let t=Cs(e)||ws(e)||Ts(e);if(t)return t.calendarId;let n=Es(e);return n?ks(n[13]).calendarId:e}function os(e){let t=Cs(e);return t&&(t.timeZoneId||t.F&&`UTC`||t.offset)||e}function ss(e){let t=Cs(e);return t&&!t.F||Jo(e),t}function cs(e,t,n){return t&&e.calendarId===`iso8601`?(fn(e),e.fe&&jt(e),ps(t(e),n)):e.fe?fs(e,n):ps(e,n)}function ls(e){let t=12*e.year+e.month===wr?20:1;return{...e,day:t}}function us(e){return{...e,year:1972}}function ds(e,t,n){let r=H(ko(e.timeZoneId)),i;if(dn(e),e.fe){let t=e.offset?ja(e.offset):void 0,[,o,s]=br(n);i=ci(r,e,t,o,s,!(r._||e.offset===void 0||(a=e.offset,a.replace(/\D/g,``).length>4)),e.F)}else br(n),i=ui(r,e);var a;return Or(i),jr(i,r,t(e.calendarId))}function fs(e,t){return dn(e),Er(e),{...N(e,e),calendar:t(e.calendarId)}}function ps(e,t){return fn(e),F(e),{calendar:t(e.calendarId),year:e.year,month:e.month,day:e.day}}function ms(e){return`(\\d{2})(?:(:?)(\\d{2})(?:\\${e}(\\d{2})(?:[.,](\\d{1,9}))?)?)?`}function hs(e){return`([+-])`+ms(e)}const gs=`(?:(?:([+-])(\\d{6}))|(\\d{4}))(-?)(\\d{2})\\4(\\d{2})(?:[T ]`+ms(8)+`(Z|`+hs(15)+`)?)?`,_s=ye(`(?:(?:([+-])(\\d{6}))|(\\d{4}))-?(\\d{2})((?:\\[(!?)([^\\]]*)\\]){0,9})`),vs=ye(`(?:--)?(\\d{2})-?(\\d{2})((?:\\[(!?)([^\\]]*)\\]){0,9})`),ys=ye(gs+`((?:\\[(!?)([^\\]]*)\\]){0,9})`),bs=ye(`T?`+ms(2)+`(${hs(9)})?((?:\\[(!?)([^\\]]*)\\]){0,9})`),xs=RegExp(`\\[(!?)([^\\]]*)\\]`,`g`),Ss=ye(`([+-])?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)?)?`);function Cs(e){let t=ys.exec(e);return t?(e=>{let t=e[12],n=(t||``).toUpperCase()===`Z`;return{year:Os(e),month:parseInt(e[5]),day:parseInt(e[6]),...Ds(e,7),...ks(e[19]),fe:!!e[7],F:n,offset:n?void 0:t}})(t):void 0}function ws(e){let t=_s.exec(e);if(t)return(e=>({year:Os(e),month:parseInt(e[4]),day:1,...ks(e[5])}))(t)}function Ts(e){let t=vs.exec(e);return t?(e=>({year:1972,month:parseInt(e[1]),day:parseInt(e[2]),...ks(e[3])}))(t):void 0}function Es(e){let t=bs.exec(e);if(t)return t[6]&&ja(t[6]),t}function Ds(e,t){let n=Se(e[t+3]);return{...Lt(be(e[t+4]||``))[0],hour:Se(e[t]),minute:Se(e[t+2]),second:n===60?59:n}}function Os(e){let t=xe(e[1]),n=parseInt(e[2]||e[3]);return t<0&&!n&&b(re(-0)),t*n}function ks(e){let t,n,r=[];return e.replace(xs,(e,i,a)=>{let o=!!i,[s,c]=a.split(`=`).reverse();return c?c===`u-ca`?(r.push(s.toLowerCase()),t||=o):(o||/[A-Z]/.test(c))&&b(re(e)):(n&&b(re(e)),n=s),``}),r.length>1&&t&&b(re(e)),{timeZoneId:n,calendarId:r[0]||`iso8601`}}function As(e,t,n){let r=Object.assign(Object.create(null),t);return js(r,n,dt),wa(e)&&(js(r,n,ut),e&&e.le&&js(r,n,ft,lt)),r}function js(e,t,n,r){let i=0,a=[];for(let e of n)t[e]===void 0?a.push(e):i=1;if(Object.assign(e,t),i)for(let t of r||a)delete e[t]}function Ms(e,t,n){let{calendar:r,timeZone:i}=e,a=B(r,wt,Tt),o=R(e),{year:s,month:c,day:l}=k(r,o),u={year:s,monthCode:zs(r,s,c),day:l,hour:o.hour,minute:o.minute,second:o.second,millisecond:o.millisecond,microsecond:o.microsecond,nanosecond:o.nanosecond,offset:o.offsetNanoseconds},d=V(t,a,Ra),f=As(r,u,d),p={...u,...d},[m,h,g,_]=Va(r,f,()=>br(n,2));return jr(ci(i,N(m,Nt(p,h)),p.offset,g,_),i,r)}function Ns(e,t,n){let{calendar:r}=e,i=B(r,St,Ct),{year:a,month:o,day:s}=k(r,e),c={year:a,monthCode:zs(r,a,o),day:s,hour:e.hour,minute:e.minute,second:e.second,millisecond:e.millisecond,microsecond:e.microsecond,nanosecond:e.nanosecond},l=V(t,i,La),u=As(r,c,l),d={...c,...l},[f,p]=Va(r,u,()=>[P(n)]);return za(f,Nt(d,p),r)}function Ps(e,t,n){let{calendar:r}=e,i=B(r,bt,xt),{year:a,month:o,day:s}=k(r,e);return Ba(r,As(r,{year:a,monthCode:zs(r,a,o),day:s},V(t,i,Na)),n)}function Fs(e,t,n){let{calendar:r}=e,i=B(r,ht,gt),{year:a,month:o}=k(r,e);return Ga(r,As(r,{year:a,monthCode:zs(r,a,o)},V(t,i,Na)),n)}function Is(e,t,n){let{calendar:r}=e,i=B(r,bt,xt),{year:a,month:o,day:s}=k(r,e);return Ka(r,As(r,{monthCode:zs(r,a,o),day:s},V(t,i,Na)),n)}function Ls(e,t,n){return((e,t,n)=>ka({...me(pt,e),...V(t,pt,Pa)},P(n)))(e,t,n)}function Rs(e,t){return L((n=e,r=t,na({...n,...V(r,kn,Fa)})));var n,r}function zs(e,t,n){let[r,i]=hn(e,t,n);return Re(r,i)}function Bs(e,t,n){return jr(e.epochNanoseconds,t,n)}function Vs(e){return Ar(e.epochNanoseconds)}function Hs(e){return Mr(R(e),e.calendar)}function Us(e){return I(R(e),e.calendar)}function Ws(e){return Nr(R(e))}function Gs(e,t,n){return jr(Or(((e,t,n)=>li(e,t,(e=>cr(a(e)))(n)))(t,e,n)),t,e.calendar)}function Ks(e,t,n,r){let i=e(r.timeZone),a=r.plainTime,o=a===void 0?void 0:t(a),s=H(i),c;return c=o?li(s,N(n,o)):ui(s,N(n,At)),jr(c,s,n.calendar)}function qs(e,t,n){return Zs(e,me(B(e,_t,vt),t),V(f(n),at,Na,[]))}function Js(e,t,n){let r=B(e,it,mt);return Zs(e,me(yt,t),V(f(n),r,Na,[]))}function Ys(e,t){return Ka(e,V(t,yt,Na))}function Xs(e,t,n){return Ga(e,V(t,B(e,_t,vt),Na),n)}function Zs(e,t,n){let r=B(e,Ot,kt),i=As(e,t,n);return i=V(i,r,Na,[]),Ba(e,i)}function Qs(e){return Ar(Or(BigInt(Hn(e))*Qe))}function $s(e){return Ar(Or(Vn(e)))}function ec(e){return e.timeZone=`UTC`,[`full`,`long`].includes(e.timeStyle)&&(e.timeStyle=`medium`),e}function tc(e,t){return e.timeZone!==void 0&&x(`Cannot specify TimeZone`),e.timeZone=t,e}function nc(e,t,n){let r=e.resolvedOptions().calendar;!n&&t.calendar===void 0||Fe(t.calendar)===r||b(`Mismatching Calendars`)}function rc(e,t,n,r,i){let a=new Set(e),o=new Set(t),s=new Set(n);return(e,t)=>{let n=((e,t,n,r)=>{let i={dateStyle:void 0,timeStyle:void 0,me:{},pe:{},xe:{},oe:0,ue:0};for(let a of Object.keys(e)){let o=e[a];o===void 0||r.has(a)||(t.has(a)?a===`dateStyle`?i.dateStyle=o:a===`timeStyle`?i.timeStyle=o:i.me[a]=o:a===`era`?i.pe[a]=o:n.has(a)?a===`dateStyle`||a===`timeStyle`?i.ue=1:i.oe=1:i.xe[a]=o)}return i})(e,a,o,s),c=n.dateStyle!==void 0,l=n.timeStyle!==void 0,u=c||l,d=Object.keys(n.me).length>0,f=n.oe||n.ue,p=d||c||l,m=Object.keys(n.pe).length>0,h=d||m||n.oe;(!t&&f||t&&f&&!p||u&&h)&&x(`Invalid formatting options`);let g={};return u||p||Object.assign(g,r),Object.assign(g,n.me,n.pe,n.xe),c&&(i?Object.assign(g,i[n.dateStyle]):g.dateStyle=n.dateStyle),l&&(g.timeStyle=n.timeStyle),g}}const ic={year:`numeric`,month:`numeric`,day:`numeric`},ac={hour:`numeric`,minute:`numeric`,second:`numeric`},oc=Object.assign({},ic,ac),sc=Object.assign({},oc,{timeZoneName:`short`}),cc={year:`numeric`,month:`numeric`},lc={month:`numeric`,day:`numeric`},uc=[`weekday`,`year`,`month`,`day`,`dateStyle`],dc=[`dayPeriod`,`hour`,`minute`,`second`,`fractionalSecondDigits`,`timeStyle`],fc=uc.concat(dc),pc=[`weekday`,`day`].concat(dc),mc=[`weekday`,`year`].concat(dc),hc=rc(fc,[],[],oc),gc=rc(fc,[],[],sc),_c=rc(fc,[],[`timeZoneName`],oc),vc=rc(uc,dc,[`timeZoneName`],ic),yc=rc(dc,uc,[`timeZoneName`,`era`],ac),bc=rc([`year`,`month`,`dateStyle`],pc,[`timeZoneName`],cc,{full:{year:`numeric`,month:`long`},long:{year:`numeric`,month:`long`},medium:{year:`numeric`,month:`short`},short:{year:`2-digit`,month:`numeric`}}),xc=rc([`month`,`day`,`dateStyle`],mc,[`timeZoneName`,`era`],lc,{full:{month:`long`,day:`numeric`},long:{month:`long`,day:`numeric`},medium:{month:`short`,day:`numeric`},short:{month:`numeric`,day:`numeric`}});function Sc(e,t){let{timeZone:n}=e,r=R(e),{offsetNanoseconds:i}=r,a=t||At,o;return o=t?ci(n,N(r,a),i,2):ui(n,N(r,a)),jr(o,n,e.calendar)}function Cc(e){let t=wc(),n=e.C(t);return qt(t+BigInt(n))}function wc(){return BigInt(Date.now())*Qe}function Tc(){return new qa().resolvedOptions().timeZone}const Ec=`PlainYearMonth`,Dc=`PlainMonthDay`,Oc=`PlainDate`,kc=`PlainDateTime`,Ac=`PlainTime`,jc=`ZonedDateTime`,Mc=`Instant`,Nc=`Duration`;function Pc(e,t,n,...r){Object.defineProperties(t,ce(e)),Object.defineProperties(t.prototype,ue(`Temporal.`+e));for(let e of r)Fc(t.prototype,n,e);return t}function Fc(e,t,n){Object.defineProperties(e,de(e=>({get(){return e(t(this))},configurable:1}),n))}const Ic=_e.name===`noop`?e=>{Object.defineProperty(e,`_str_`,{value:e.toJSON()})}:_e;function Lc(){x(`Invalid calling context`)}function Rc(){x(`Cannot use valueOf`)}const zc={era(e){return gn(e.calendar,e).era},eraYear(e){return gn(e.calendar,e).eraYear},year(e){return k(e.calendar,e).year},month(e){return k(e.calendar,e).month},monthCode(e){return bn(e.calendar,e)}},Bc={era(e){return gn(e.calendar,e).era},eraYear(e){return gn(e.calendar,e).eraYear},year(e){return k(e.calendar,e).year},month(e){return k(e.calendar,e).month},monthCode(e){return bn(e.calendar,e)},day(e){return k(e.calendar,e).day}},Vc={monthCode(e){return bn(e.calendar,e)},day(e){return k(e.calendar,e).day}},Hc={daysInMonth(e){return Cn(e.calendar,e)},daysInYear(e){return wn(e.calendar,e)},monthsInYear(e){return Sn(e.calendar,e)},inLeapYear(e){return xn(e.calendar,e)}},Uc={dayOfWeek(e){return on(e)},dayOfYear(e){return Tn(e.calendar,e)},weekOfYear(e){return En(e.calendar,e)},yearOfWeek(e){return Dn(e.calendar,e)},daysInWeek(){return 7},daysInMonth(e){return Cn(e.calendar,e)},daysInYear(e){return wn(e.calendar,e)},monthsInYear(e){return Sn(e.calendar,e)},inLeapYear(e){return xn(e.calendar,e)}};function Wc(e){return pe(Object.keys(e))}Wc(Hc),Wc(Uc);function Gc(e){let t=e.ve||0;function n(e){return e-t}function r(e){return e+t}return{l:e.l,ge:1972+t,le:e.le,ie(e){return{...e,year:r(e.year)}},je(e,t,r){return $t(n(e),t,r)},se(e,t,r){return Kt(n(e),t,r)*Ue},O(e,t){return Zt(t)},v(e,t){let n=Qt(e,t);return n&&{year:r(n.year),month:n.month}},u(e){return nn(n(e))},k(){return 12},p(e,t){return en(n(e),t)},j(e){return tn(n(e))},q(){},h(t){return e.h?.(t,r(t.year))||{}},N(e,t,i){let a=rn(n(e),t,i);return{year:r(a.year),month:a.month}},ne(e,t,r,i){return an(n(e),t,n(r),i)}}}function Kc(e,t){let n=qc(e);return{m:t.m,Z:t.Z,X:t.X,ie:n.he,je:S(Yc,n),se:S(Xc,n),O:S(Zc,n,t.m),v:S(il,n,t.m,t.Ce),u:S($c,n,t.m),k:S(nl,n),p:S(tl,n),j:S(el,n),q:S(Qc,n,t.m),h:S(rl,n),N:S(al,n),ne:S(ol,n)}}function qc(e){let t=(e=>new qa(`en-u-hc-h23`,{calendar:e,timeZone:`UTC`,era:`short`,year:`numeric`,month:`short`,day:`numeric`}))(e);function n(e){return{...Jc(n=Ja(t,e)),month:0,Fe:n.month,day:parseInt(n.day)};var n}let r=(e=>{let t=e(0).year-1970;return se(function(n){let r=Kt(n-t)*Ue,i,a=0,o=[],s=[];do r+=400*Ue;while((i=e(r)).year<=n);do r+=(1-i.day)*Ue,i.year===n&&(o.push(r),s.push(i.Fe)),r-=Ue,(++a>500||r<-864e13)&&b();while((i=e(r)).year>=n);return{$:o.reverse(),we:s.reverse()}})})(n);return{he:((e,t)=>se(n=>{let r=Wt(n),i=e(r);return{...i,month:sl(t,i.year,r)}},WeakMap))(n,r),K:r}}function Jc(e){return{era:void 0,eraYear:void 0,year:parseInt(e.relatedYear||e.year)}}function Yc(e,t,n,r){return Jt(Xc(e,t,n,r))}function Xc(e,t,n=1,r=1){return e.K(t).$[n-1]+(r-1)*Ue}function Zc(e,t,n,r){let i=Qc(e,t,n);return[Be(r,i),i===r]}function Qc(e,t,n){if(t===void 0)return;let r=e.K(n).we;if(r.length<=12)return;if(t<0)return-t;for(let e=1;e<r.length;e++)if(r[e]===r[e-1])return e+1;for(let e=0;e<r.length;e++)if(/bis$/i.test(r[e]))return e+1;let i=e.K(n-1).we;for(let e=0;e<r.length;e++)if(r[e]!==i[e])return e+1}function $c(e,t,n){if(t!==void 0)return nl(e,n)>12;let r=el(e,n);return r>el(e,n-1)||r>el(e,n+1)}function el(e,t){return Xt(Xc(e,t),Xc(e,t+1))}function tl(e,t,n){let{$:r}=e.K(t),i=n+1,a=r;return i>r.length&&(i=1,a=e.K(t+1).$),Xt(r[n-1],a[i-1])}function nl(e,t){return e.K(t).$.length}function rl(e,t){let n=e.he(t);return{era:n.era,eraYear:n.eraYear}}function il(e,t,n,r,i,a){let o=n?.(r,i,a)||1972,{year:s,month:c,day:l}=e.he({year:o,month:12,day:31}),u=Qc(e,t,s),d=Be(c,u),f=c===u;(w(r,d)||w(Number(i),Number(f))||w(a,l))===1&&s--;for(let n=0;n<100;n++){let o=s-n,c=Qc(e,t,o),l=ze(r,i,c);if(i===(l===c)&&a<=tl(e,o,l))return{year:o,month:l}}}function al(e,t,n,r){if(r)if(Number.isSafeInteger(n+=r)||b(`Out-of-bounds date`),r<0)for(;n<1;)n+=nl(e,--t);else{let r;for(;n>(r=nl(e,t));)n-=r,t++}return{year:t,month:n}}function ol(e,t,n,r,i){let a=w(t,r)||w(n,i);if(!a)return 0;if(t===r)return i-n;if(a<0){let a=nl(e,t)-n+i;for(let n=t+1;n<r;n++)a+=nl(e,n);return a}return-ol(e,r,i,t,n)}function sl(e,t,n){let{$:r}=e(t);for(let e=r.length-1;e>=0;e--)if(n>=r[e])return e+1;b()}const cl=2440588;function ll(e){let t=e.J(2441683),n=se(t=>e.J(Gt(t)+2440588),WeakMap);function r(t,n){let r=e.q?.(t);return[Be(n,r),n===r]}return{l:e.l,m:e.m,Z:e.Z,X:e.X,ge:e.ge,te:e.te,ke:e.ke,ie:n,je(t,n,r){return Yt(e.L(t,n,r)-2440588)},se(t,n=1,r=1){return(e.L(t,n,r)-2440588)*Ue},O(t,n){return(e.O||r)(t,n)},v(n,i,a){return e.v?.(n,i,a)||((n,i,a)=>{i=!!i;let o=e.ge||t.year,[s,c]=r(t.year,t.month);(w(n,s)||w(Number(i),Number(c))||w(a,t.day))===1&&o--;for(let t=0;t<100;t++)for(let r of[o-t,o+t]){let t=e.q?.(r),o=ze(n,i,t);if(o<=e.k(r)&&i===(o===t)&&a<=e.p(r,o))return{year:r,month:o}}})(n,i,a)},u:e.u,k:e.k,p:e.p,j:e.j,q:e.q||_e,h(t){let r=n(t);return e.h?e.h(r):{era:r.era,eraYear:r.eraYear}},N(t,n,r){return((e,t,n,r)=>{if(r)if(Number.isSafeInteger(n+=r)||b(`Out-of-bounds date`),r<0)for(;n<1;)n+=e(--t);else{let r;for(;n>(r=e(t));)n-=r,t++}return{year:t,month:n}})(e.k,t,n,r)},ne(t,n,r,i){return ul(e.k,t,n,r,i)}}}function ul(e,t,n,r,i){let a=w(t,r)||w(n,i);if(!a)return 0;if(t===r)return i-n;if(a<0){let a=e(t)-n+i;for(let n=t+1;n<r;n++)a+=e(n);return a}return-ul(e,r,i,t,n)}const dl={be:0},fl={m:13,Z:{1:0,2:29,8:29,9:29,10:29,11:29,12:0},X:30,Ce(e,t,n){if(t)switch(e){case 1:return 1651;case 2:return n<30?1947:1765;case 3:return n<30?1966:1955;case 4:return n<30?1963:1944;case 5:return n<30?1971:1952;case 6:return n<30?1960:1941;case 7:return n<30?1968:1938;case 8:return n<30?1957:1718;case 9:return 2014;case 10:return 1984;case 11:return n<29?2033:2034;case 12:return 1890}return 1972}};function pl(e){return Kc(e,fl)}const ml={am:0},hl={am:0,aa:0},gl={aa:0};function _l(e,t,n=0,r=0){return ll({l:t,te(e,t,n){return t===`aa`&&r?e-5500:Oa(e,n)},ke(e,t,n){return ie(n,1,t||e!==13?30:6)},J(t){let[r,i,a]=((e,t)=>{let n=Math.floor((4*(t-e)+3)/1461),r=1+Math.floor((t-vl(e,n,1,1))/30);return[n,r,t+1-vl(e,n,r,1)]})(e,t);return{year:r+n,month:i,day:a}},L(t,r,i){return vl(e,t-n,r,i)},p(e,t){return((e,t)=>t%13==0?yl(e)+5:30)(e-n,t)},j(e){return 365+yl(e-n)},k(){return 13},u(e){return this.j(e)>365},h({year:e}){return n?{era:`aa`,eraYear:e}:r&&e<=0?{era:`aa`,eraYear:e+5500}:{era:`am`,eraYear:e}}})}function vl(e,t,n,r){return e+365*t+Math.floor(t/4)+30*(n-1)+r-1}function yl(e){return Math.floor(Oe(e,4)/3)}const bl={am:0};function xl(e){return Oe(7*e+1,19)<7}function Sl(e){let t=Math.floor((235*e-234)/19),n=29*t+Math.floor((12084+13753*t)/25920);return Oe(3*(n+1),7)<3&&(n+=1),n}function Cl(e){return Sl(e)+(e=>{let t=Sl(e-1),n=Sl(e);return Sl(e+1)-n===356?2:n-t===382?1:0})(e)}function wl(e){return Cl(e+1)-Cl(e)}function Tl(e,t){let n=t>=6&&!xl(e)?t+1:t;if(n===4||n===7||n===9||n===11||n===13)return 29;let r=(e=>{let t=wl(e);return t>380&&(t-=30),t===353?0:t===354?1:2})(e);return n===2?r===2?30:29:n===3?r===0?29:30:n===6?xl(e)?30:0:30}const El={shaka:0},Dl=[1392,1390,1391,1392,1391,1392,1389,1392,1392,1390,1391,1390];function Ol(e,t,n){return ll({l:{bh:-1,ah:0},J:e,L:t,p(e,t){return n&&Ml(e)?tl(n,e,t):((e,t)=>29+t%2+(t===12&&jl(e)?1:0))(e,t)},j(e){return n&&Ml(e)?el(n,e):jl(e)?355:354},k(){return 12},u(e){return this.j(e)>354},v(e,t,r){let i=n&&!t&&r===30&&Dl[e-1];return n&&i?{year:i,month:e}:void 0},h({year:e}){return e<1?{era:`bh`,eraYear:1-e}:{era:`ah`,eraYear:e}}})}function kl(e,t,n,r){return r+Math.ceil(29.5*(n-1))+354*(t-1)+Math.floor((3+11*t)/30)+e-1}function Al(e,t){let n=Math.floor((30*(t-e)+10646)/10631),r=Math.min(12,Math.ceil((t-(29+kl(e,n,1,1)))/29.5)+1);return{year:n,month:r,day:t-kl(e,n,r,1)+1}}function jl(e){return Oe(14+11*e,30)<11}function Ml(e){return e>=1300&&e<=1600}function Nl(e,t){let n=t-1948440;if(n<460322||n>=566987)return Al(1948440,t);let{year:r,month:i,day:a}=e.he(Yt(t-cl));return{year:r,month:i,day:a}}function Pl(e,t,n,r){return Ml(t)?Xc(e,t,n,r)/Ue+cl:kl(1948440,t,n,r)}const Fl=Object.assign({},Ne,{meiji:1867,taisho:1911,showa:1925,heisei:1988,reiwa:2018});function Il(e){let t=Gt(e),n=t>=18017?`reiwa`:t>=6947?`heisei`:t>=-15713?`showa`:t>=-20974?`taisho`:t>=-35428?`meiji`:void 0;return n?{era:n,eraYear:e.year-Fl[n]}:un(e)}const Ll={ap:0},Rl=[0,31,62,93,124,155,186,216,246,276,306,336];function zl(e){return Oe(25*e+11,33)<8}const Bl={broc:-1,roc:0},Vl=[`buddhist`,()=>Gc({ve:543,l:dl,h(e,t){return{era:`be`,eraYear:t}}})],Hl=[`chinese`,pl],Ul=[`coptic`,()=>_l(1824665,ml)],Wl=[`dangi`,pl],Gl=new Map([Vl,Hl,Ul,Wl,[`ethiopic`,()=>_l(1723856,hl,0,1)],[`ethioaa`,()=>_l(1723856,gl,5500)],[`hebrew`,()=>ll({l:bl,m:-6,J(e){let t=e-347997,n=Math.floor((25920*t/765433*19+234)/235)+1,r=Cl(n),i=Math.floor(t-r);for(;i<1;)n--,r=Cl(n),i=Math.floor(t-r);let a=1,o=0;for(;o<i;)o+=Tl(n,a),a++;return a--,o-=Tl(n,a),{year:n,month:a,day:i-o}},L(e,t,n){let r=Cl(e);for(let n=1;n<t;n++)r+=Tl(e,n);return r+n+347997},p:Tl,j:wl,k(e){return xl(e)?13:12},u:xl,q(e){return xl(e)?6:void 0},O(e,t){return xl(e)&&t===6?[5,1]:[t-(xl(e)&&t>6?1:0),0]},v(e,t,n){return t&&e===5&&n<=30?{year:5730,month:6}:void 0},h({year:e}){return{era:`am`,eraYear:e}}})],[`indian`,function(){return ll({l:El,J(e){let t=Yt(e-cl),n=t.year-78,r=e-(Kt(t.year,1,1)+cl),i;if(r<80?(n--,i=nn(t.year-1)?31:30,r+=i+155+90+10):(i=nn(t.year)?31:30,r-=80),r<i)return{year:n,month:1,day:r+1};let a=r-i;return a<155?{year:n,month:Math.floor(a/31)+2,day:a%31+1}:(a-=155,{year:n,month:Math.floor(a/30)+7,day:a%30+1})},L(e,t,n){let r=e+78,i,a;return nn(r)?(i=31,a=Kt(r,3,21)+cl):(i=30,a=Kt(r,3,22)+cl),t===1||(a+=i+31*Math.min(t-2,5),t>=8&&(a+=30*(t-7))),a+n-1},p(e,t){return t===1&&nn(e+78)||t>=2&&t<=6?31:30},j(e){return nn(e+78)?366:365},k(){return 12},u(e){return this.j(e)>365},h({year:e}){return{era:`shaka`,eraYear:e}}})}],[`japanese`,()=>Gc({l:Fl,le:1,h:Il})],[`islamic-civil`,()=>Ol(S(Al,1948440),S(kl,1948440))],[`islamic-tbla`,()=>Ol(S(Al,1948439),S(kl,1948439))],[`islamic-umalqura`,e=>{let t=qc(e);return Ol(S(Nl,t),S(Pl,t),t)}],[`persian`,()=>ll({l:Ll,J(e){let t=e-1948320,n=1+Math.floor((33*t+3)/12053),r=t-(365*(n-1)+Math.floor((8*n+21)/33)),i=Math.floor(r<216?r/31:(r-6)/30);return{year:n,month:i+1,day:r-Rl[i]+1}},L(e,t,n){return 1948319+365*(e-1)+Math.floor((8*e+21)/33)+Rl[t-1]+n},p(e,t){return t<=6?31:t<=11||zl(e)?30:29},j(e){return zl(e)?366:365},k(){return 12},u:zl,h({year:e}){return{era:`ap`,eraYear:e}}})],[`roc`,()=>Gc({ve:-1911,l:Bl,h(e,t){return t<1?{era:`broc`,eraYear:1-t}:{era:`roc`,eraYear:t}}})]]),Kl={islamic:1,"islamic-rgsa":1},ql={"ethiopic-amete-alem":`ethioaa`,islamicc:`islamic-civil`},Jl=se((e,t)=>{let n=t(e);return n.id=e,n});function Yl(e){let t=Xl(e);return t||b(ee(e)),Jl(...t)}function Xl(e){Kl[e]&&b(ee(e));let t=ql[e]||e,n=Gl.get(t);return n&&[t,n]}function Zl(e){let t=M(e).toLowerCase();return t===`iso8601`?void 0:t===`gregory`?0:Yl(t)}function Ql(e=`iso8601`){return Zl(e)}const $l=new WeakMap,eu=Pc(jc,class{constructor(e,t,n=void 0){let r=Or(Vn(e)),i=H(Oo(t)),a=Ql(n);iu(this,jr(r,i,a))}static from(e,t=void 0){return U(ru(e,t))}static compare(e,t){return fa(ru(e),ru(t))}get calendarId(){return Fe(W(this).calendar)}get timeZoneId(){return W(this).timeZone.id}get epochMilliseconds(){return Pr(W(this))}get epochNanoseconds(){return Fr(W(this))}get offset(){return yo(R(W(this)).offsetNanoseconds)}get offsetNanoseconds(){return R(W(this)).offsetNanoseconds}get hoursInDay(){return Ur(W(this))}with(e,t=void 0){return U(Ms(W(this),ku(e),t))}withCalendar(e){return U({...W(this),calendar:Qu(e)})}withTimeZone(e){return U({...W(this),timeZone:H(au(e))})}withPlainTime(e=void 0){return U(Sc(W(this),Iu(e)))}add(e,t=void 0){return U(pi(W(this),Y(e),t))}subtract(e,t=void 0){return U(pi(W(this),z(Y(e)),t))}until(e,t=void 0){let n=W(this),r=ru(e);return q(L(Ei(0,Si(n.calendar,r.calendar),n,r,t)))}since(e,t=void 0){let n=W(this),r=ru(e);return q(L(Ei(1,Si(n.calendar,r.calendar),n,r,t)))}round(e){let t=W(this),[n,r,i]=yr(e);return U(Hr(t,n,r,i))}startOfDay(){return U(Wr(W(this)))}equals(e){return va(W(this),ru(e))}toInstant(){return cu(Vs(W(this)))}toPlainDateTime(){return Bu(Hs(W(this)))}toPlainDate(){return Ku(Us(W(this)))}toPlainTime(){return Mu(Ws(W(this)))}toLocaleString(e=void 0,t={}){let n=W(this),r=new qa(e,tc(gc(t),wi(n)));return nc(r,n),r.format(Pr(n))}toString(e=void 0){return no(W(this),e)}toJSON(){return no(W(this))}getTimeZoneTransition(e){let t=W(this),n=oi(t,e);return n?U({...t,epochNanoseconds:n}):null}valueOf(){return Rc()}},tu,Bc,Uc,rt);function U(e){return iu(Object.create(eu.prototype),e)}function W(e){return nu(e)||Lc()}function tu(e){let t=W(e);return{...R(t),calendar:t.calendar}}function nu(e){return $l.get(e)}function ru(e,t){if(y(e)){let n=nu(e);return n?(br(t),n):Vo(au,Xu(e),e,t)}return Zo(e,Zl,t)}function iu(e,t){return $l.set(e,t),Ic(e),e}function au(e){if(y(e)){let t=nu(e);return t||x(te(e)),t.timeZone.id}return(e=>ko(os(M(e))))(e)}const ou=new WeakMap,su=Pc(Mc,class{constructor(e){let t=Or(Vn(e));pu(this,Ar(t))}static from(e){return cu(du(e))}static fromEpochMilliseconds(e){return cu(Qs(e))}static fromEpochNanoseconds(e){return cu($s(e))}static compare(e,t){return da(du(e),du(t))}get epochMilliseconds(){return Pr(lu(this))}get epochNanoseconds(){return Fr(lu(this))}add(e){return cu(Ar(fi(lu(this).epochNanoseconds,Y(e))))}subtract(e){return cu(Ar(fi(lu(this).epochNanoseconds,z(Y(e)))))}until(e,t=void 0){return q(Ti(0,lu(this),du(e),t))}since(e,t=void 0){return q(Ti(1,lu(this),du(e),t))}round(e){let t=lu(this),[n,r,i]=yr(e,5,1);return cu(Ar($r(t.epochNanoseconds,Yr(n,r),i)))}equals(e){return _a(lu(this),du(e))}toZonedDateTimeISO(e){return U(Bs(lu(this),H(au(e))))}toLocaleString(e=void 0,t={}){let n=lu(this);return new qa(e,hc(t)).format(Pr(n))}toString(e=void 0){return to(au,lu(this),e)}toJSON(){return to(au,lu(this))}valueOf(){return Rc()}});function cu(e){return pu(Object.create(su.prototype),e)}function lu(e){return uu(e)||Lc()}function uu(e){return ou.get(e)}function du(e){if(y(e)){let t=uu(e);if(t)return t;let n=nu(e);if(n)return Ar(n.epochNanoseconds)}return Yo(e)}const{toTemporalInstant:fu}={toTemporalInstant(){let e=Date.prototype.valueOf.call(this);return cu(Ar(BigInt(Rn(e))*Qe))}};function pu(e,t){return ou.set(e,t),Ic(e),e}const mu=new WeakMap,hu=Pc(Dc,class{constructor(e,t,n=void 0,r){let i=s(e),a=s(t),o=Ql(n),c=F(fn({year:s(r??1972),month:i,day:a}));bu(this,I(c,o))}static from(e,t=void 0){return gu(yu(e,t))}get calendarId(){return Fe(_u(this).calendar)}with(e,t=void 0){return gu(Is(_u(this),ku(e),t))}equals(e){return Sa(_u(this),yu(e))}toPlainDate(e){return Ku(Js(_u(this).calendar,this,e))}toLocaleString(e=void 0,t={}){let n=_u(this),r=new qa(e,ec(xc(t)));return nc(r,n,1),r.format(Wt(n))}toString(e=void 0){return oo(_u(this),e)}toJSON(){return oo(_u(this))}valueOf(){return Rc()}},_u,Vc);function gu(e){return bu(Object.create(hu.prototype),e)}function _u(e){return vu(e)||Lc()}function vu(e){return mu.get(e)}function yu(e,t){if(y(e)){let n=vu(e);if(n)return P(t),n;let r=Zu(e);return Go(r===void 0?void 0:r,r===void 0,e,t)}let n=ns(e,Zl);return P(t),n}function bu(e,t){return mu.set(e,t),Ic(e),e}const xu=new WeakMap,Su=Pc(Ec,class{constructor(e,t,n=void 0,r){let i=s(e),a=s(t),o=Ql(n),c=Tr(fn({year:i,month:a,day:s(r??1)}));Du(this,I(c,o))}static from(e,t=void 0){return Cu(Eu(e,t))}static compare(e,t){return ha(Eu(e),Eu(t))}get calendarId(){return Fe(wu(this).calendar)}with(e,t=void 0){return Cu(Fs(wu(this),ku(e),t))}add(e,t=void 0){let n=wu(this);return Cu(I(di(0,n.calendar,n,Y(e),t),n.calendar))}subtract(e,t=void 0){let n=wu(this);return Cu(I(di(1,n.calendar,n,Y(e),t),n.calendar))}until(e,t=void 0){let n=wu(this),r=Eu(e);return q(ki(0,Si(n.calendar,r.calendar),n,r,t))}since(e,t=void 0){let n=wu(this),r=Eu(e);return q(ki(1,Si(n.calendar,r.calendar),n,r,t))}equals(e){return xa(wu(this),Eu(e))}toPlainDate(e){return Ku(qs(wu(this).calendar,this,e))}toLocaleString(e=void 0,t={}){let n=wu(this),r=new qa(e,ec(bc(t)));return nc(r,n,1),r.format(Wt(n))}toString(e=void 0){return ao(wu(this),e)}toJSON(){return ao(wu(this))}valueOf(){return Rc()}},wu,zc,Hc);function Cu(e){return Du(Object.create(Su.prototype),e)}function wu(e){return Tu(e)||Lc()}function Tu(e){return xu.get(e)}function Eu(e,t){if(y(e)){let n=Tu(e);return n?(P(t),n):Wo(Xu(e),e,t)}let n=es(e,Zl);return P(t),n}function Du(e,t){return xu.set(e,t),Ic(e),e}function Ou(e){if(!y(e))return;let t=uu(e);return t?[Mc,t]:(t=nu(e),t?[jc,t]:(t=Vu(e),t?[kc,t]:(t=qu(e),t?[Oc,t]:(t=Pu(e),t?[Ac,t]:(t=Tu(e),t?[Ec,t]:(t=vu(e),t?[Dc,t]:(t=td(e),t?[Nc,t]:void 0)))))))}function ku(e){return(Ou(e)||e.calendar!==void 0||e.timeZone!==void 0)&&x(`Invalid bag`),e}const Au=new WeakMap,ju=Pc(Ac,class{constructor(e=0,t=0,n=0,r=0,i=0,a=0){Lu(this,jt(de(s,{hour:e,minute:t,second:n,millisecond:r,microsecond:i,nanosecond:a})))}static from(e,t=void 0){return Mu(Fu(e,t))}static compare(e,t){return ga(Fu(e),Fu(t))}with(e,t=void 0){return Mu(Ls(Nu(this),ku(e),t))}add(e){return Mu(_i(Nu(this),Y(e))[0])}subtract(e){return Mu(_i(Nu(this),z(Y(e)))[0])}until(e,t=void 0){return q(ji(0,Nu(this),Fu(e),t))}since(e,t=void 0){return q(ji(1,Nu(this),Fu(e),t))}round(e){let t=Nu(this),[n,r,i]=yr(e,5);return Mu(Kr(t,Jr(n,r),i)[0])}equals(e){return Ca(Nu(this),Fu(e))}toLocaleString(e=void 0,t={}){let n=Nu(this);return new qa(e,ec(yc(t))).format(Pt(n))}toString(e=void 0){return co(Nu(this),e)}toJSON(){return co(Nu(this))}valueOf(){return Rc()}},Nu,rt);function Mu(e){return Lu(Object.create(ju.prototype),e)}function Nu(e){return Pu(e)||Lc()}function Pu(e){return Au.get(e)}function Fu(e,t){if(y(e)){let n=Pu(e);if(n)return P(t),n;let r=Vu(e);if(r)return P(t),Nr(r);let i=nu(e);return i?(P(t),Ws(i)):Ko(e,t)}let n=rs(e);return P(t),n}function Iu(e){return e===void 0?void 0:Fu(e)}function Lu(e,t){return Au.set(e,t),Ic(e),e}const Ru=new WeakMap,zu=Pc(kc,class{constructor(e,t,n,r=0,i=0,a=0,o=0,c=0,l=0,u=void 0){let d=Er(dn(de(s,{year:e,month:t,day:n,hour:r,minute:i,second:a,millisecond:o,microsecond:c,nanosecond:l}))),f=Ql(u);Uu(this,Mr(d,f))}static from(e,t=void 0){return Bu(Hu(e,t))}static compare(e,t){return ma(Hu(e),Hu(t))}get calendarId(){return Fe(G(this).calendar)}with(e,t=void 0){return Bu(Ns(G(this),ku(e),t))}withCalendar(e){return Bu(Mr(G(this),Qu(e)))}withPlainTime(e=void 0){let t=G(this);return Bu(za(t,Iu(e),t.calendar))}add(e,t=void 0){let n=G(this);return Bu(Mr(mi(n.calendar,n,Y(e),t),n.calendar))}subtract(e,t=void 0){let n=G(this);return Bu(Mr(mi(n.calendar,n,z(Y(e)),t),n.calendar))}until(e,t=void 0){let n=G(this),r=Hu(e);return q(Di(0,Si(n.calendar,r.calendar),n,r,t))}since(e,t=void 0){let n=G(this),r=Hu(e);return q(Di(1,Si(n.calendar,r.calendar),n,r,t))}round(e){let t=G(this),[n,r,i]=yr(e);return Bu(Mr(Gr(t,Jr(n,r),i),t.calendar))}equals(e){return ya(G(this),Hu(e))}toZonedDateTime(e,t=void 0){return U(Gs(G(this),H(au(e)),t))}toPlainDate(){let e=G(this);return Ku(I(e,e.calendar))}toPlainTime(){return Mu(Nr(G(this)))}toLocaleString(e=void 0,t={}){let n=G(this),r=new qa(e,ec(_c(t)));return nc(r,n),r.format(Ht(n))}toString(e=void 0){return ro(G(this),e)}toJSON(){return ro(G(this))}valueOf(){return Rc()}},G,Bc,Uc,rt);function Bu(e){return Uu(Object.create(zu.prototype),e)}function G(e){return Vu(e)||Lc()}function Vu(e){return Ru.get(e)}function Hu(e,t){if(y(e)){let n=Vu(e);if(n)return P(t),n;let r=qu(e);if(r)return P(t),Mr(N(r,At),r.calendar);let i=nu(e);return i?(P(t),Hs(i)):Ho(Xu(e),e,t)}let n=Qo(e,Zl);return P(t),n}function Uu(e,t){return Ru.set(e,t),Ic(e),e}const Wu=new WeakMap,Gu=Pc(Oc,class{constructor(e,t,n,r=void 0){let i=F(fn(de(s,{year:e,month:t,day:n}))),a=Ql(r);Yu(this,I(i,a))}static from(e,t=void 0){return Ku(Ju(e,t))}static compare(e,t){return ha(Ju(e),Ju(t))}get calendarId(){return Fe(K(this).calendar)}with(e,t=void 0){return Ku(Ps(K(this),ku(e),t))}withCalendar(e){return Ku(I(K(this),Qu(e)))}add(e,t=void 0){let n=K(this);return Ku(I(hi(n.calendar,n,Y(e),t),n.calendar))}subtract(e,t=void 0){let n=K(this);return Ku(I(hi(n.calendar,n,z(Y(e)),t),n.calendar))}until(e,t=void 0){let n=K(this),r=Ju(e);return q(Oi(0,Si(n.calendar,r.calendar),n,r,t))}since(e,t=void 0){let n=K(this),r=Ju(e);return q(Oi(1,Si(n.calendar,r.calendar),n,r,t))}equals(e){return ba(K(this),Ju(e))}toZonedDateTime(e){let t=y(e)?{timeZone:e.timeZone,plainTime:e.plainTime}:{timeZone:e};return U(Ks(au,Fu,K(this),t))}toPlainDateTime(e=void 0){let t=K(this);return Bu(za(t,Iu(e),t.calendar))}toPlainYearMonth(){return Cu(Xs(K(this).calendar,this))}toPlainMonthDay(){return gu(Ys(K(this).calendar,this))}toLocaleString(e=void 0,t={}){let n=K(this),r=new qa(e,ec(vc(t)));return nc(r,n),r.format(Wt(n))}toString(e=void 0){return io(K(this),e)}toJSON(){return io(K(this))}valueOf(){return Rc()}},K,Bc,Uc);function Ku(e){return Yu(Object.create(Gu.prototype),e)}function K(e){return qu(e)||Lc()}function qu(e){return Wu.get(e)}function Ju(e,t){if(y(e)){let n=qu(e);if(n)return P(t),n;let r=Vu(e);if(r)return P(t),I(r,r.calendar);let i=nu(e);return i?(P(t),Us(i)):Uo(Xu(e),e,t)}let n=$o(e,Zl);return P(t),n}function Yu(e,t){return Wu.set(e,t),Ic(e),e}function Xu(e){let t=Zu(e);return t===void 0?void 0:t}function Zu(e){let{calendar:t}=e;if(t!==void 0)return Qu(t)}function Qu(e){if(y(e)){let t=qu(e)||Vu(e)||nu(e)||vu(e)||Tu(e);return t||x(ee(e)),t.calendar}return(e=>Zl(as(M(e))))(e)}const $u=new WeakMap,ed=Pc(Nc,class{constructor(e=0,t=0,n=0,r=0,i=0,a=0,o=0,s=0,c=0,l=0){let u=na(de(Hn,{years:e,months:t,weeks:n,days:r,hours:i,minutes:a,seconds:o,milliseconds:s,microseconds:c,nanoseconds:l}));rd(this,L(u))}static from(e){return q(Y(e))}static compare(e,t,n=void 0){return pa(nd,Y(e),Y(t),n)}get sign(){return J(this).sign}get blank(){return!J(this).sign}with(e){return q(Rs(J(this),e))}negated(){return q(ea(J(this)))}abs(){return q($i(J(this)))}add(e,t=void 0){return q(Xi(nd,0,J(this),Y(e),t))}subtract(e,t=void 0){return q(Xi(nd,1,J(this),Y(e),t))}round(e){return q(Qi(nd,J(this),e))}total(e){return Ir(nd,J(this),e)}toLocaleString(e=void 0,t){let n=J(this);return Intl.DurationFormat?new Intl.DurationFormat(e,t).format(n):lo(n,t)}toString(e=void 0){return lo(J(this),e)}toJSON(){return lo(J(this))}valueOf(){return Rc()}},J,On);function q(e){return rd(Object.create(ed.prototype),e)}function J(e){return td(e)||Lc()}function td(e){return $u.get(e)}function Y(e){return y(e)?td(e)||qo(e):is(e)}function nd(e){if(e!==void 0){if(y(e)){let t=nu(e);if(t)return t;let n=qu(e);if(n)return n;let r=Vu(e);return r?I(r,r.calendar):Bo(au,Xu(e),e)}return Xo(e,Zl)}}function rd(e,t){return $u.set(e,t),Ic(e),e}const id=Object.defineProperties({},{...ue(`Temporal.Now`),...le({timeZoneId(){return Tc()},instant(){return cu(Ar(wc()))},zonedDateTimeISO(e=Tc()){let t=H(au(e));return U(jr(wc(),t))},plainDateTimeISO(e=Tc()){return Bu(Mr(Cc(H(au(e)))))},plainDateISO(e=Tc()){return Ku(I(Cc(H(au(e)))))},plainTimeISO(e=Tc()){return Mu(Nr(Cc(H(au(e)))))}})}),ad=Object.defineProperties({},{...ue(`Temporal`),...le({PlainYearMonth:Su,PlainMonthDay:hu,PlainDate:Gu,PlainTime:ju,PlainDateTime:zu,ZonedDateTime:eu,Instant:su,Duration:ed,Now:id})}),X=globalThis.Temporal??ad,od=X!==ad,sd=1e3,cd=864e5;15*cd;const ld=400*cd,ud=30*36e5;function dd(e){if(e===`UTC`||e===`Etc/UTC`||e===`Etc/GMT`)return 0;let t=/^([+-])(\d{2}):?(\d{2})(?::?(\d{2}))?$/.exec(e);return t?(t[1]===`-`?-1:1)*((Number(t[2])*60+Number(t[3]))*60+Number(t[4]??0))*sd:null}var fd=class{constructor(e){this.tzid=e,this.transitions=[],this.offsets=[],this.coverStart=0,this.coverEnd=0,this.covered=!1,this.fixedOffsetMs=dd(e)}formatter(){return this.dtf??=new Intl.DateTimeFormat(`en-US`,{timeZone:this.tzid,hourCycle:`h23`,era:`short`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}exactOffsetMs(e){let t=this.formatter().formatToParts(e),n=0,r=!1,i=1,a=1,o=0,s=0,c=0;for(let e of t)switch(e.type){case`year`:n=Number(e.value);break;case`era`:r=e.value===`BC`||e.value===`B`;break;case`month`:i=Number(e.value);break;case`day`:a=Number(e.value);break;case`hour`:o=Number(e.value)%24;break;case`minute`:s=Number(e.value);break;case`second`:c=Number(e.value);break}r&&(n=1-n);let l=new Date(0);return l.setUTCFullYear(n,i-1,a),l.setUTCHours(o,s,c,0),l.getTime()-Math.floor(e/sd)*sd}ensureCoverage(e,t){if(this.fixedOffsetMs!==null||this.covered&&e>=this.coverStart&&t<=this.coverEnd)return;let n=Math.min(e,this.covered?this.coverStart:e)-ld,r=Math.max(t,this.covered?this.coverEnd:t)+ld;if(this.covered){let e=Math.max(r-n,2*(this.coverEnd-this.coverStart));n<this.coverStart&&(n=Math.min(n,r-e)),r>this.coverEnd&&(r=Math.max(r,n+e))}this.rebuild(n,r)}rebuild(e,t){let n=[],r=[this.exactOffsetMs(e)],i=e,a=r[0];for(;i<t;){let e=Math.min(i+1296e6,t);if(this.exactOffsetMs(e)===a){i=e;continue}let o=i,s=e;for(;s-o>sd;){let e=o+Math.floor((s-o)/2/sd)*sd;e<=o&&(e=o+sd),this.exactOffsetMs(e)===a?o=e:s=e}let c=this.exactOffsetMs(s);n.push(s),r.push(c),i=s,a=c}this.transitions=n,this.offsets=r,this.coverStart=e,this.coverEnd=t,this.covered=!0}offsetMsAt(e){if(this.fixedOffsetMs!==null)return this.fixedOffsetMs;this.ensureCoverage(e,e);let t=this.transitions,n=0,r=t.length;for(;n<r;){let i=n+r>>1;t[i]<=e?n=i+1:r=i}return this.offsets[n]}epochMsForWall(e){if(this.fixedOffsetMs!==null)return{epochMs:e-this.fixedOffsetMs,pushed:!1};this.ensureCoverage(e-ud,e+ud);let t=this.offsetMsAt(e-ud),n=e-t;if(this.offsetMsAt(n)===t)return{epochMs:n,pushed:!1};let r=this.offsetMsAt(e+ud),i=e-r;return this.offsetMsAt(i)===r?{epochMs:i,pushed:!1}:{epochMs:n,pushed:!0}}timeOfDayMayHitGap(e,t,n){if(this.fixedOffsetMs!==null)return!1;this.ensureCoverage(t,n);for(let r=0;r<this.transitions.length;r++){let i=this.transitions[r];if(i<t||i>n)continue;let a=this.offsets[r],o=this.offsets[r+1]-a;if(o<=0)continue;let s=e-((i+a)%cd+cd)%cd;if(s>=0?s<o:s+cd<o)return!0}return!1}};const pd=new Map;function md(e){let t=pd.get(e);return t||(t=new fd(e),pd.set(e,t)),t}const hd=[`YEARLY`,`MONTHLY`,`WEEKLY`,`DAILY`,`HOURLY`,`MINUTELY`,`SECONDLY`],gd=[`MO`,`TU`,`WE`,`TH`,`FR`,`SA`,`SU`],Z={MO:1,TU:2,WE:3,TH:4,FR:5,SA:6,SU:7},_d=new Set(hd),vd=new Set(gd),yd=RegExp(`^([+-]?\\d{1,2})?(${gd.join(`|`)})$`),bd=RegExp(`(${gd.join(`|`)})$`),xd=1e3,Sd=60*xd,Cd=60*Sd,Q=24*Cd,wd=7*Q,Td=[31,28,31,30,31,30,31,31,30,31,30,31],Ed=[0,3,2,5,0,3,5,1,4,6,2,4],Dd=BigInt(1e6),Od=BigInt(1e9),kd=BigInt(60)*Od,Ad=BigInt(60)*kd,jd=BigInt(24)*Ad,Md=BigInt(7)*jd,Nd=864e13;function Pd(e,t){let n=Math.abs(e),r=Math.abs(t);for(;r!==0;){let e=n%r;n=r,r=e}return n}function Fd(e){let t=0;for(let n of e??[])t|=1<<n-1;return t}function Id(e,t){return e===0||(e&1<<t-1)!=0}function Ld(e,t){let n=e/t;return e%t<0n?n-1n:n}function Rd(e,t){return-Ld(-e,t)}function zd(e){return Number.isSafeInteger(e)&&e>=-Nd&&e<=Nd}function Bd(e,t,n){let r=e-(t<=2?1:0),i=Math.floor(r/400),a=r-i*400,o=t+(t>2?-3:9),s=Math.floor((153*o+2)/5)+n-1,c=a*365+Math.floor(a/4)-Math.floor(a/100)+s;return i*146097+c-719468}function Vd(e){return((e+3)%7+7)%7+1}function $(e,t){return(e-1+t%7+7)%7+1}function Hd(e){let t=e.toUpperCase().match(bd)?.[1];return!t||!vd.has(t)?null:t}function Ud(e){let t=e.toUpperCase().match(yd);if(!t)return null;let n=t[1]?parseInt(t[1],10):0,r=t[2];return!r||!vd.has(r)?null:{ord:n,weekday:r}}function Wd(e){return typeof e==`object`&&!!e&&typeof e.timeZoneId==`string`&&typeof e.toString==`function`}function Gd(e){let t=e.epochNanoseconds;return typeof t==`bigint`?t:void 0}function Kd(e,t){if(!Wd(e))throw Error(`${t} must be a ZonedDateTime`);try{let t=Gd(e);if(t!==void 0){let n=e.calendarId;return new X.ZonedDateTime(t,e.timeZoneId,typeof n==`string`?n:`iso8601`)}return X.ZonedDateTime.from(e.toString())}catch{throw Error(`${t} must be a ZonedDateTime`)}}function qd(e,t){if(e instanceof Date){let t=e.getTime();return Number.isFinite(t)||e.toISOString(),BigInt(t)*Dd}if(!Wd(e))throw Error(`${t} must be a ZonedDateTime`);return Gd(e)??Kd(e,t).epochNanoseconds}function Jd(e,t){if(e?.length)return e.map(e=>Kd(e,t))}function Yd(e){return typeof e.rruleString==`string`}function Xd(e,t){let n=[...e??[],...Jd(t,`Manual date`)??[]];return n.length>0?n:void 0}function Zd(e){return e.replace(/\r?\n[ \t]/g,``)}function Qd(e,t,n){let r=n===`DATE`||!e.includes(`T`),i=`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`;if(r)return X.PlainDate.from(i).toZonedDateTime({timeZone:t});if(e.endsWith(`Z`)){let n=`${i}T${e.slice(9,15)}Z`;return X.Instant.from(n).toZonedDateTimeISO(t||`UTC`)}else{let n=`${i}T${e.slice(9)}`;return X.PlainDateTime.from(n).toZonedDateTime(t)}}function $d(e,t,n){let r=[];for(let i of e){let e=ef(i,t);if(!e)continue;let a=e.tzid||n,o=e.value.split(`,`);r.push(...o.map(t=>Qd(t,a,e.valueType)))}return r}function ef(e,t){let n=e.indexOf(`:`);if(n===-1)return null;let r=e.slice(0,n),i=e.slice(n+1),[a,...o]=r.split(`;`);if(a?.toUpperCase()!==t)return null;let s,c;for(let e of o){let t=e.indexOf(`=`);if(t===-1)continue;let n=e.slice(0,t).toUpperCase(),r=e.slice(t+1);n===`VALUE`?s=r.toUpperCase():n===`TZID`&&(c=r)}return{valueType:s,tzid:c,value:i}}function tf(e,t,n){let r=e.trim();if(n&&!/^[+-]?\d+$/.test(r))throw Error(`Invalid ${t} value: ${e}`);return parseInt(r,10)}function nf(e,t=!1,n=!1,r=`number`){let i=e.split(`,`).map(e=>tf(e,r,n));return t?i.sort((e,t)=>e-t):i}function rf(e,t=!1){return e.split(`,`).map(e=>{let n=e.trim();if(/^\d+L$/i.test(n))return n.toUpperCase();let r=tf(n,`BYMONTH`,t);return Number.isFinite(r)?r:n})}function af(e,t,n,r=!1){let i=Zd(e).trim(),a,o=t,s=`DATE-TIME`,c=!1,l=!1,u,d=[],f=[];if(/^DTSTART/im.test(i)){let e=i.split(/\s+/),n=e.find(e=>e.match(/^DTSTART/i)),r=e.find(e=>e.match(/^RRULE:/i)),p=e.filter(e=>e.match(/^EXDATE/i)),m=e.filter(e=>e.match(/^RDATE/i)),h=ef(n,`DTSTART`);if(!h)throw Error(`Invalid DTSTART in ICS snippet`);let{valueType:g,tzid:_,value:v}=h;s=(g||(v?.includes(`T`)?`DATE-TIME`:`DATE`)).toUpperCase()===`DATE`?`DATE`:`DATE-TIME`,c=!!_,l=!!v?.endsWith(`Z`),a=Qd(v,_??t??o??`UTC`,s),o=_??a.timeZoneId??t??o??`UTC`,u=r,d=$d(p,`EXDATE`,o??`UTC`),f=$d(m,`RDATE`,o??`UTC`)}else a=n?Kd(n,`dtstart`):void 0,u=i,a&&(o=a.timeZoneId,s=`DATE-TIME`,c=!0,l=a.timeZoneId===`UTC`);let p=u?u.replace(/^RRULE:/i,``).split(`;`):[],m={dtstart:a,tzid:o,exDate:d.length>0?d:void 0,rDate:f.length>0?f:void 0},h;for(let e of p){let[t,n]=e.split(`=`);if(t)switch(t.toUpperCase()){case`RSCALE`:n&&(m.rscale=n.toUpperCase(),h&&!m.skip&&(m.skip=h,h=void 0));break;case`SKIP`:{let e=(n||``).toUpperCase();if(![`OMIT`,`BACKWARD`,`FORWARD`].includes(e))throw Error(`Invalid SKIP value: ${n}`);m.rscale?m.skip=e:h=e;break}case`FREQ`:m.freq=n.toUpperCase();break;case`INTERVAL`:m.interval=tf(n,`INTERVAL`,r);break;case`COUNT`:m.count=tf(n,`COUNT`,r);break;case`UNTIL`:{let e=n.includes(`T`);if(s===`DATE`){if(e)throw Error(`UNTIL rule part MUST have the same value type as DTSTART`);m.until=Qd(n,o||`UTC`,`DATE`);break}if(!e){if(r)throw Error(`UNTIL rule part MUST have the same value type as DTSTART`);let e=Qd(n,o||`UTC`,`DATE`).with({hour:23,minute:59,second:59,millisecond:0,microsecond:0,nanosecond:0});m.until=c||l?e.withTimeZone(`UTC`):e;break}if((c||l)&&!n.endsWith(`Z`))throw Error(`UNTIL rule part MUST always be specified as a date with UTC time`);m.until=Qd(n,o||`UTC`,`DATE-TIME`);break}case`BYHOUR`:m.byHour=nf(n,!0,r,`BYHOUR`);break;case`BYMINUTE`:m.byMinute=nf(n,!0,r,`BYMINUTE`);break;case`BYSECOND`:m.bySecond=nf(n,!0,r,`BYSECOND`);break;case`BYDAY`:m.byDay=n.split(`,`).map(e=>e.toUpperCase());break;case`BYMONTH`:m.byMonth=rf(n,r);break;case`BYMONTHDAY`:m.byMonthDay=nf(n,!1,r,`BYMONTHDAY`);break;case`BYYEARDAY`:m.byYearDay=nf(n,!1,r,`BYYEARDAY`);break;case`BYWEEKNO`:m.byWeekNo=nf(n,!1,r,`BYWEEKNO`);break;case`BYSETPOS`:m.bySetPos=nf(n,!1,r,`BYSETPOS`);break;case`WKST`:m.wkst=n?.toUpperCase();break}}if(h&&!m.rscale)throw Error(`SKIP MUST NOT be present unless RSCALE is present`);return h&&m.rscale&&!m.skip&&(m.skip=h),m}var of=class e{static{this.rscaleCalendarSupport={}}static normalizeToPolyfill(e){return Kd(e,`Date`)}toPublicDate(e){if(!e)return null;let t=this.outputTemporal?.ZonedDateTime;if(!t||t===X.ZonedDateTime)return e;if(this.outputConstructorFastPathAvailable!==!1)try{let n=new t(e.epochNanoseconds,e.timeZoneId,e.calendarId);return this.outputConstructorFastPathAvailable=!0,n}catch{this.outputConstructorFastPathAvailable=!1}return t.from(e.toString())}toPublicDates(e){return!this.outputTemporal||this.outputTemporal.ZonedDateTime===X.ZonedDateTime?e:e.map(e=>this.toPublicDate(e))}constructor(t){this.outputTemporal=t.temporal;let n;if(Yd(t)){let r=af(t.rruleString,t.tzid,t.dtstart,t.strict??!1);if(!r.dtstart)throw Error(`dtstart is required - provide it either in rruleString or as a separate parameter`);let i=e.normalizeToPolyfill(r.dtstart);this.tzid=r.tzid??t.tzid??`UTC`,this.originalDtstart=i,n={...r,dtstart:i,rDate:Xd(r.rDate,t.rDate),exDate:Xd(r.exDate,t.exDate),count:t.count??r.count,until:t.until?e.normalizeToPolyfill(t.until):r.until,strict:t.strict,maxIterations:t.maxIterations,maxCandidateEvaluations:t.maxCandidateEvaluations,includeDtstart:t.includeDtstart,cache:t.cache,temporal:t.temporal,tzid:this.tzid}}else{let e=Kd(t.dtstart,`Manual dtstart`);n={...t,dtstart:e,until:t.until?Kd(t.until,`Manual until`):void 0,rDate:Jd(t.rDate,`Manual rDate`),exDate:Jd(t.exDate,`Manual exDate`)},n.tzid=n.tzid||e.timeZoneId,this.tzid=n.tzid,this.originalDtstart=e}if(!n.freq)throw Error(`RRULE must include FREQ`);if(n.interval=n.interval??1,n.interval<=0)throw Error(`Cannot create RRule: interval must be greater than 0`);if(this.opts=this.sanitizeOpts(n),this.maxIterations=n.maxIterations??1e4,this.maxCandidateEvaluations=n.maxCandidateEvaluations??1e6,!Number.isSafeInteger(this.maxCandidateEvaluations)||this.maxCandidateEvaluations<=0)throw Error(`maxCandidateEvaluations must be a positive safe integer`);this.includeDtstart=n.includeDtstart??!1,this.parsedByDayTokens=this.buildParsedByDayTokens(this.opts.byDay),this.simpleByDayIsoDays=this.buildByDayIsoDays(this.parsedByDayTokens,!1),this.allByDayIsoDays=this.buildByDayIsoDays(this.parsedByDayTokens,!0),this.hasOrdinalByDay=this.parsedByDayTokens?.some(e=>e.ord!==0)??!1,this.canUseEpochMillisecondsPrecisionFlag=this.originalDtstart.microsecond===0&&this.originalDtstart.nanosecond===0&&(!this.opts.until||this.opts.until.microsecond===0&&this.opts.until.nanosecond===0),this.timeSlotOffsetsMs=this.buildTimeSlotOffsetsMs(),this.hasUniqueTimeSlotOffsets=this.timeSlotOffsetsMs===void 0||new Set(this.timeSlotOffsetsMs).size===this.timeSlotOffsetsMs.length,this.numericByMonths=this.opts.byMonth?.filter(e=>typeof e==`number`)}buildParsedByDayTokens(e){if(!e?.length)return;let t=e.map(e=>{let t=Ud(e);return t?{ord:t.ord,weekday:t.weekday,isoDay:Z[t.weekday]}:null}).filter(e=>e!==null);return t.length>0?t:void 0}buildByDayIsoDays(e,t){if(!e?.length)return;let n=e.filter(e=>t||e.ord===0).map(e=>e.isoDay);if(n.length)return[...new Set(n)].sort((e,t)=>e-t)}sanitizeNumericArray(e,t,n,r=!1,i=!1){if(!e)return;let a=[],o=new Set;for(let i of e)Number.isInteger(i)&&i>=t&&i<=n&&(r||i!==0)&&!o.has(i)&&(o.add(i),a.push(i));if(a.length!==0)return i?a.sort((e,t)=>e-t):a}sanitizeByDay(e){let t=[],n=new Set;for(let r of e??[]){if(!r||typeof r!=`string`)continue;let e=r.toUpperCase(),i=Ud(e);if(!i||i.ord===0&&/^[+-]?\d/.test(e))throw Error(`Invalid BYDAY value: ${r}`);n.has(e)||(n.add(e),t.push(e))}return t.length>0?t:void 0}enforceStrictRfc(e){if(!e.strict)return;let t=e.freq;if(e.count!==void 0&&e.until!==void 0)throw Error(`COUNT and UNTIL MUST NOT occur in the same recurrence rule`);if(e.byWeekNo&&t!==`YEARLY`)throw Error(`BYWEEKNO MUST NOT be used unless FREQ=YEARLY`);if(e.byYearDay&&[`DAILY`,`WEEKLY`,`MONTHLY`].includes(t))throw Error(`BYYEARDAY MUST NOT be used when FREQ is DAILY, WEEKLY, or MONTHLY`);if(e.byMonthDay&&t===`WEEKLY`)throw Error(`BYMONTHDAY MUST NOT be used when FREQ is WEEKLY`);let n=(e.byDay??[]).some(e=>/^[+-]?\d/.test(e));if(n&&![`MONTHLY`,`YEARLY`].includes(t))throw Error(`BYDAY with numeric value MUST NOT be used unless FREQ is MONTHLY or YEARLY`);if(n&&t===`YEARLY`&&e.byWeekNo)throw Error(`BYDAY with numeric value MUST NOT be used with FREQ=YEARLY when BYWEEKNO is present`);let r=!!(e.byDay||e.byMonth||e.byMonthDay||e.byYearDay||e.byWeekNo||e.byHour||e.byMinute||e.bySecond);if(e.bySetPos&&!r)throw Error(`BYSETPOS MUST be used with another BYxxx rule part`)}sanitizeOpts(e){if(!_d.has(e.freq))throw Error(`Invalid FREQ value: ${e.freq}`);if(e.byDay=this.sanitizeByDay(e.byDay),e.wkst){let t=e.wkst.toUpperCase();if(!vd.has(t))throw Error(`Invalid WKST value: ${e.wkst}`);e.wkst=t}if(e.byMonth){let t=e.byMonth.filter(e=>typeof e==`number`),n=e.byMonth.filter(e=>typeof e==`string`).map(e=>e.toUpperCase()),r=this.sanitizeNumericArray(t,1,12,!1,!1)??[],i=[...new Set([...r,...n])];e.byMonth=i.length>0?i:void 0}if(e.rscale&&!e.skip&&(e.skip=`OMIT`),e.byMonthDay=this.sanitizeNumericArray(e.byMonthDay,-31,31,!1,!1),e.byYearDay=this.sanitizeNumericArray(e.byYearDay,-366,366,!1,!1),e.byWeekNo=this.sanitizeNumericArray(e.byWeekNo,-53,53,!1,!1),e.byHour=this.sanitizeNumericArray(e.byHour,0,23,!0,!0),e.byMinute=this.sanitizeNumericArray(e.byMinute,0,59,!0,!0),e.bySecond=this.sanitizeNumericArray(e.bySecond,0,59,!0,!0),e.bySetPos){if(e.bySetPos.some(e=>e===0))throw Error(`bySetPos may not contain 0`);e.bySetPos=this.sanitizeNumericArray(e.bySetPos,-1/0,1/0,!1,!1)}return this.enforceStrictRfc(e),e}rawAdvance(e){let{freq:t,interval:n}=this.opts;switch(t){case`DAILY`:return e.add({days:n});case`WEEKLY`:return e.add({weeks:n});case`MONTHLY`:return e.add({months:n});case`YEARLY`:return e.add({years:n});case`HOURLY`:{let t=e.hour,r=e.add({hours:n});return r.hour===t&&n===1&&(r=r.add({hours:n})),r}case`MINUTELY`:return e.add({minutes:n});case`SECONDLY`:return e.add({seconds:n});default:throw Error(`Unsupported FREQ: ${t}`)}}expandByTime(e){if(!this.opts.byHour&&!this.opts.byMinute&&!this.opts.bySecond)return[e];let t=this.opts.byHour??[e.hour],n=this.opts.byMinute??[e.minute],r=this.opts.bySecond??[e.second];if(t.length===1&&n.length===1&&r.length===1){let i=t[0],a=n[0],o=r[0];return i===e.hour&&a===e.minute&&o===e.second?[e]:[e.with({hour:i,minute:a,second:o})]}let i=[];for(let a of t)for(let t of n)for(let n of r)i.push(e.with({hour:a,minute:t,second:n}));return i.sort((e,t)=>X.ZonedDateTime.compare(e,t))}localDateKey(e){return`${e.calendarId}:${e.year}:${e.month}:${e.day}`}sortedUniqueDateCandidates(e){let t=new Map;for(let n of e){let e=this.localDateKey(n);t.has(e)||t.set(e,n)}return[...t.values()].sort((e,t)=>X.ZonedDateTime.compare(e,t))}timeOfDayNanoseconds(e){return((e.hour*60*60+e.minute*60+e.second)*1e3+e.millisecond)*1e6+e.microsecond*1e3+e.nanosecond}timeSlotNanoseconds(e,t,n,r){return((t*60*60+n*60+r)*1e3+e.millisecond)*1e6+e.microsecond*1e3+e.nanosecond}needsSortedTimeFallback(e){try{let t=e.startOfDay();return t.add({days:1}).startOfDay().epochNanoseconds-t.epochNanoseconds!==BigInt(864e11)}catch{return!0}}createCandidateWorkBudget(){return{evaluated:0,seenOccurrences:new Set}}recordCandidateEvaluation(e){if(e.evaluated+=1,e.evaluated>this.maxCandidateEvaluations)throw Error(`Maximum candidate evaluations (${this.maxCandidateEvaluations}) exceeded in all()`)}visitTimeSlots(e,t,n,r,i,a=this.createCandidateWorkBudget()){let o=this.opts.byHour??[e.hour],s=this.opts.byMinute??[e.minute],c=this.opts.bySecond??[e.second];if(this.needsSortedTimeFallback(e)){let l=[];for(let t of o)for(let n of s)for(let o of c){this.recordCandidateEvaluation(a);let s=t===e.hour&&n===e.minute&&o===e.second?e:e.with({hour:t,minute:n,second:o});r&&X.ZonedDateTime.compare(s,r)<0||i&&X.ZonedDateTime.compare(s,i)>0||l.push(s)}l.sort((e,t)=>X.ZonedDateTime.compare(e,t));let u,d=t===1?0:l.length-1,f=t===1?l.length:-1;for(let e=d;e!==f;e+=t){let t=l[e];if(t.epochNanoseconds!==u&&(u=t.epochNanoseconds,!n(t)))return!1}return!0}let l=r?this.timeOfDayNanoseconds(r):void 0,u=i?this.timeOfDayNanoseconds(i):void 0,d=t===1?0:o.length-1,f=t===1?o.length:-1;for(let r=d;r!==f;r+=t){let i=o[r],d=t===1?0:s.length-1,f=t===1?s.length:-1;for(let r=d;r!==f;r+=t){let o=s[r],d=t===1?0:c.length-1,f=t===1?c.length:-1;for(let r=d;r!==f;r+=t){let t=c[r],s=this.timeSlotNanoseconds(e,i,o,t);if(!(l!==void 0&&s<l)&&!(u!==void 0&&s>u)&&(this.recordCandidateEvaluation(a),!n(i===e.hour&&o===e.minute&&t===e.second?e:e.with({hour:i,minute:o,second:t}))))return!1}}}return!0}visitDateTimeCandidates(e,t,n,r,i,a=this.createCandidateWorkBudget()){let o=this.sortedUniqueDateCandidates(e),s=r?.withTimeZone(this.tzid),c=i?.withTimeZone(this.tzid),l=s?.toPlainDate(),u=c?.toPlainDate(),d=t===1?0:o.length-1,f=t===1?o.length:-1,p;for(let e=d;e!==f;e+=t){let r=o[e],i=r.toPlainDate();if(l&&X.PlainDate.compare(i,l)<0||u&&X.PlainDate.compare(i,u)>0)continue;let d=l&&X.PlainDate.compare(i,l)===0,f=u&&X.PlainDate.compare(i,u)===0;if(!this.visitTimeSlots(r,t,e=>e.epochNanoseconds===p?!0:(p=e.epochNanoseconds,n(e)),d?s:void 0,f?c:void 0,a))return!1}return!0}visitPeriodCandidates(e,t,n,r,i=this.createCandidateWorkBudget()){let a=this.opts.bySetPos;if(!a?.length)return this.visitDateTimeCandidates(e,1,t,n,r,i);let o=new Set(a.filter(e=>e>0)),s=new Set(a.filter(e=>e<0).map(e=>-e)),c=new Map;if(o.size>0){let t=0;for(let e of o)t=Math.max(t,e);let n=0;this.visitDateTimeCandidates(e,1,e=>(n+=1,o.has(n)&&c.set(e.epochNanoseconds,e),n<t),void 0,void 0,i)}if(s.size>0){let t=0;for(let e of s)t=Math.max(t,e);let n=0;this.visitDateTimeCandidates(e,-1,e=>(n+=1,s.has(n)&&c.set(e.epochNanoseconds,e),n<t),void 0,void 0,i)}let l=[...c.values()].sort((e,t)=>X.ZonedDateTime.compare(e,t));for(let e of l)if(!(n&&X.ZonedDateTime.compare(e,n)<0)&&!(r&&X.ZonedDateTime.compare(e,r)>0)&&!t(e))return!1;return!0}nextCandidateSameDate(e){let{freq:t,interval:n=1,byHour:r,byMinute:i,bySecond:a}=this.opts;if(t===`HOURLY`&&r&&r.length===1)return this.applyTimeOverride(e.add({days:n}));if(t===`MINUTELY`&&i&&i.length===1)return this.applyTimeOverride(e.add({hours:n}));if(a&&a.length>1){let t=a.indexOf(e.second);if(t!==-1&&t<a.length-1)return e.with({second:a[t+1]})}if(t===`MINUTELY`&&r&&r.length>1&&!i){let t=e.add({minutes:n});if(r.includes(t.hour))return t.with({second:a?a[0]:e.second});let i=r.find(t=>t>e.hour)||r[0];return i&&i>e.hour?e.with({hour:i,minute:0,second:a?a[0]:e.second}):this.applyTimeOverride(e.add({days:1}))}if(t===`SECONDLY`){let t=e;if(a&&a.length>0){let e=a.find(e=>e>t.second);if(e!==void 0)return t.with({second:e});t=t.with({second:a[0]}).add({minutes:1})}else t=t.add({seconds:n});if(i&&i.length>0&&(!i.includes(t.minute)||t.minute===e.minute&&t.second<e.second)){let e=i.find(e=>e>t.minute);if(e!==void 0)return t.with({minute:e,second:a?a[0]:0});t=t.with({minute:i[0],second:a?a[0]:0}).add({hours:1})}if(r&&r.length>0&&(!r.includes(t.hour)||t.hour===e.hour&&t.minute<e.minute)){let e=r.find(e=>e>t.hour);if(e!==void 0)return t.with({hour:e,minute:i?i[0]:0,second:a?a[0]:0});t=t.with({hour:r[0],minute:i?i[0]:0,second:a?a[0]:0}).add({days:1})}return t}if(i&&i.length>1){let o=i.indexOf(e.minute);if(o!==-1&&o<i.length-1)return e.with({minute:i[o+1],second:a?a[0]:e.second});if(t===`MINUTELY`&&o===i.length-1){if(r&&r.length>0){let t=r.indexOf(e.hour);return t!==-1&&t<r.length-1?e.with({hour:r[t+1],minute:i[0],second:a?a[0]:e.second}):this.applyTimeOverride(e.add({days:1}))}return e.add({hours:n}).with({minute:i[0],second:a?a[0]:e.second})}}if(r&&r.length>1){let t=r.indexOf(e.hour);if(t!==-1&&t<r.length-1)return e.with({hour:r[t+1],minute:i?i[0]:e.minute,second:a?a[0]:e.second})}return t===`HOURLY`&&r&&r.length>1?this.applyTimeOverride(e.add({days:1})):this.applyTimeOverride(this.rawAdvance(e))}applyTimeOverride(e){let{byHour:t,byMinute:n,bySecond:r}=this.opts;if(!t&&!n&&!r)return e;let i={};return t&&(i.hour=t[0]),n&&(i.minute=n[0]),r&&(i.second=r[0]),e.with(i)}computeFirst(){let e=this.originalDtstart;if(this.opts.byWeekNo?.length&&[`DAILY`,`HOURLY`,`MINUTELY`,`SECONDLY`].includes(this.opts.freq)){let t=this.opts.byWeekNo[0],n=e.year;for(;n<=e.year+10;){let r=e.with({year:n,month:1,day:1}),i=e.with({year:n,month:12,day:31}),a=!1;if(t>0){let e=52;(r.dayOfWeek===4||i.dayOfWeek===4)&&(e=53),a=t<=e}else{let e=52;(r.dayOfWeek===4||i.dayOfWeek===4)&&(e=53),a=-t<=e}if(a){let n=r.add({days:(4-r.dayOfWeek+7)%7}),a;if(t>0)a=n.subtract({days:3}).add({weeks:t-1});else{let e=r.dayOfWeek===4||i.dayOfWeek===4?53:52;a=n.subtract({days:3}).add({weeks:e+t})}if(this.opts.byDay?.length){let t=Z,n=this.opts.byDay.map(e=>Hd(e)).filter(e=>e!==null).map(e=>t[e]).filter(Boolean);if(n.length){let t=n.map(e=>{let t=(e-a.dayOfWeek+7)%7;return a.add({days:t})}).sort((e,t)=>X.ZonedDateTime.compare(e,t))[0];if(t&&X.ZonedDateTime.compare(t,this.originalDtstart)>=0){e=t;break}}}else if(X.ZonedDateTime.compare(a,this.originalDtstart)>=0){e=a;break}}n++}}if(this.opts.byDay?.length&&!this.opts.byWeekNo){let t=Z;if(this.opts.byDay.some(e=>/^[+-]?\d/.test(e))&&this.opts.byMonth&&(this.opts.freq===`MINUTELY`||this.opts.freq===`SECONDLY`)){let t=this.opts.byMonth.filter(e=>typeof e==`number`).sort((e,t)=>e-t),n=!1;for(let r=e.year;r<=e.year+10&&!n;r++)for(let i of t){if(r===e.year&&i<e.month)continue;let t=e.with({year:r,month:i,day:1}),a=this.generateMonthlyOccurrences(t);for(let t of a)if(X.ZonedDateTime.compare(t,e)>=0){e=t.toPlainDate().equals(e.toPlainDate())?t:this.applyTimeOverride(t.with({hour:0,minute:0,second:0})),n=!0;break}if(n)break}}else{let n,r=this.opts.byDay.map(e=>Hd(e)).filter(e=>e!==null);n=[`DAILY`,`HOURLY`,`MINUTELY`,`SECONDLY`].includes(this.opts.freq)&&r.length===this.opts.byDay.length?r.map(n=>(t[n]-e.dayOfWeek+7)%7):r.map(n=>(t[n]-e.dayOfWeek+7)%7),n.length&&(e=e.add({days:Math.min(...n)}))}}let{byHour:t,byMinute:n,bySecond:r}=this.opts;if(this.opts.freq===`HOURLY`&&!t&&X.ZonedDateTime.compare(e.with({hour:0,minute:0,second:0,microsecond:0,nanosecond:0}),this.originalDtstart)>0&&(e=e.with({hour:0,minute:0,second:0,microsecond:0,nanosecond:0})),this.opts.freq===`MINUTELY`&&!n&&X.ZonedDateTime.compare(e.with({hour:0,minute:0,second:0,microsecond:0,nanosecond:0}),this.originalDtstart)>0&&(e=e.with({hour:0,minute:0,second:0,microsecond:0,nanosecond:0})),this.opts.freq===`SECONDLY`&&this.opts.byWeekNo?.length&&!r&&X.ZonedDateTime.compare(e.with({hour:0,minute:0,second:0,microsecond:0,nanosecond:0}),this.originalDtstart)>0&&(e=e.with({hour:0,minute:0,second:0,microsecond:0,nanosecond:0})),t||n||r){let t=this.expandByTime(e);for(let e of t)if(X.ZonedDateTime.compare(e,this.originalDtstart)>=0)return e;e=this.applyTimeOverride(this.rawAdvance(e))}return e}matchesByDay(e){let{byDay:t,freq:n}=this.opts;if(!t)return!0;if(!this.hasOrdinalByDay)return this.simpleByDayIsoDays?.includes(e.dayOfWeek)??!1;for(let t of this.parsedByDayTokens??[]){if(n===`DAILY`&&e.dayOfWeek===t.isoDay)return!0;if(t.ord===0){if(e.dayOfWeek===t.isoDay)return!0;continue}let r=e.month,i=e.with({day:1}),a=[];for(;i.month===r;)i.dayOfWeek===t.isoDay&&a.push(i.day),i=i.add({days:1});if(a[t.ord>0?t.ord-1:a.length+t.ord]===e.day)return!0}return!1}matchesByMonth(e){let{byMonth:t}=this.opts;if(!t)return!0;let n=t.filter(e=>typeof e==`number`);return n.length===0?!0:n.includes(e.month)}matchesNumericConstraint(e,t,n){return t.some(t=>e===(t>0?t:n+t+1))}matchesByMonthDay(e){let{byMonthDay:t}=this.opts;if(!t)return!0;let n=e.with({day:1}).add({months:1}).subtract({days:1}).day;return this.matchesNumericConstraint(e.day,t,n)}matchesByHour(e){let{byHour:t}=this.opts;if(!t||t.includes(e.hour))return!0;for(let n of t)if(e.with({hour:n}).hour===e.hour)return!0;return!1}matchesByMinute(e){let{byMinute:t}=this.opts;return t?t.includes(e.minute):!0}matchesBySecond(e){let{bySecond:t}=this.opts;return t?t.includes(e.second):!0}matchesAll(e){return this.matchesByMonth(e)&&this.matchesByWeekNo(e)&&this.matchesByYearDay(e)&&this.matchesByMonthDay(e)&&this.matchesByDay(e)&&this.matchesByHour(e)&&this.matchesByMinute(e)&&this.matchesBySecond(e)}matchesByYearDay(e){let{byYearDay:t}=this.opts;if(!t)return!0;let n=e.dayOfYear,r=e.with({month:12,day:31}).dayOfYear;return this.matchesNumericConstraint(n,t,r)}getIsoWeekInfo(e){let t=e.add({days:4-e.dayOfWeek}),n=t.year,r=e.with({year:n,month:1,day:1}),i=r.add({days:(4-r.dayOfWeek+7)%7}),a=t.toPlainDate().since(i.toPlainDate()).days;return{week:Math.floor(a/7)+1,year:n}}matchesByWeekNo(e){let{byWeekNo:t}=this.opts;if(!t)return!0;let{week:n,year:r}=this.getIsoWeekInfo(e),i=e.with({year:r,month:1,day:1}),a=i.inLeapYear,o=i.dayOfWeek===4||a&&i.dayOfWeek===3?53:52;return t.some(e=>e>0?n===e:n===o+e+1)}hasPossibleYearDayWeekNoCombination(){if(!this.opts.byYearDay||!this.opts.byWeekNo)return!0;let e=this.originalDtstart.with({year:2e3,month:1,day:1,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});for(let t=0;t<400;t++){let t=e.daysInYear;for(let n of this.opts.byYearDay){let r=n>0?n:t+n+1;if(r>=1&&r<=t&&this.matchesByWeekNo(e.add({days:r-1})))return!0}e=e.add({years:1})}return!1}options(){let{dtstart:e,until:t,rDate:n,exDate:r,temporal:i,...a}=this.cloneOptions();return{...a,...this.outputTemporal?{temporal:this.outputTemporal}:{},dtstart:this.toPublicDate(e),until:t?this.toPublicDate(t):void 0,rDate:n?this.toPublicDates(n):void 0,exDate:r?this.toPublicDates(r):void 0}}cloneOptions(){let{byHour:e,byMinute:t,bySecond:n,byDay:r,byMonth:i,byMonthDay:a,byYearDay:o,byWeekNo:s,bySetPos:c,rDate:l,exDate:u,...d}=this.opts;return{...d,byHour:e?[...e]:void 0,byMinute:t?[...t]:void 0,bySecond:n?[...n]:void 0,byDay:r?[...r]:void 0,byMonth:i?[...i]:void 0,byMonthDay:a?[...a]:void 0,byYearDay:o?[...o]:void 0,byWeekNo:s?[...s]:void 0,bySetPos:c?[...c]:void 0,rDate:l?[...l]:void 0,exDate:u?[...u]:void 0}}cloneUpdateOptions(e){let t={};return Object.prototype.hasOwnProperty.call(e,`byHour`)&&(t.byHour=Array.isArray(e.byHour)?[...e.byHour]:e.byHour),Object.prototype.hasOwnProperty.call(e,`byMinute`)&&(t.byMinute=Array.isArray(e.byMinute)?[...e.byMinute]:e.byMinute),Object.prototype.hasOwnProperty.call(e,`bySecond`)&&(t.bySecond=Array.isArray(e.bySecond)?[...e.bySecond]:e.bySecond),Object.prototype.hasOwnProperty.call(e,`byDay`)&&(t.byDay=Array.isArray(e.byDay)?[...e.byDay]:e.byDay),Object.prototype.hasOwnProperty.call(e,`byMonth`)&&(t.byMonth=Array.isArray(e.byMonth)?[...e.byMonth]:e.byMonth),Object.prototype.hasOwnProperty.call(e,`byMonthDay`)&&(t.byMonthDay=Array.isArray(e.byMonthDay)?[...e.byMonthDay]:e.byMonthDay),Object.prototype.hasOwnProperty.call(e,`byYearDay`)&&(t.byYearDay=Array.isArray(e.byYearDay)?[...e.byYearDay]:e.byYearDay),Object.prototype.hasOwnProperty.call(e,`byWeekNo`)&&(t.byWeekNo=Array.isArray(e.byWeekNo)?[...e.byWeekNo]:e.byWeekNo),Object.prototype.hasOwnProperty.call(e,`bySetPos`)&&(t.bySetPos=Array.isArray(e.bySetPos)?[...e.bySetPos]:e.bySetPos),Object.prototype.hasOwnProperty.call(e,`rDate`)&&(t.rDate=Array.isArray(e.rDate)?[...e.rDate]:e.rDate),Object.prototype.hasOwnProperty.call(e,`exDate`)&&(t.exDate=Array.isArray(e.exDate)?[...e.exDate]:e.exDate),t}with(t){return new e({...this.cloneOptions(),...t,...this.cloneUpdateOptions(t),tzid:t.tzid??this.opts.tzid,dtstart:t.dtstart??this.opts.dtstart})}addDtstartIfNeeded(e,t){if(this.includeDtstart&&!this.matchesAll(this.originalDtstart)){if(t&&this.isExcluded(this.originalDtstart))return!0;if(t&&!t(this.originalDtstart,e.length)||(e.push(this.originalDtstart),this.shouldBreakForCountLimit(e.length)))return!1}return!0}canUseUtcLinearFastPath(e){if(e||this.tzid!==`UTC`||this.opts.rscale||this.opts.rDate||this.opts.exDate||this.opts.byMonth||this.opts.byMonthDay||this.opts.byYearDay||this.opts.byWeekNo||this.opts.bySetPos)return!1;switch(this.opts.freq){case`DAILY`:return!this.hasOrdinalByDay&&(!this.opts.byHour||this.canUseEpochMillisecondsPrecisionFlag)&&(!this.opts.byMinute||this.canUseEpochMillisecondsPrecisionFlag)&&(!this.opts.bySecond||this.canUseEpochMillisecondsPrecisionFlag);case`HOURLY`:case`MINUTELY`:case`SECONDLY`:return!this.opts.byDay&&!this.opts.byHour&&!this.opts.byMinute&&!this.opts.bySecond;default:return!1}}canUseUtcWeeklyFastPath(e){return!e&&this.tzid===`UTC`&&this.opts.freq===`WEEKLY`&&!this.opts.rscale&&!this.opts.rDate&&!this.opts.exDate&&!this.opts.byMonth&&!this.opts.byMonthDay&&!this.opts.byYearDay&&!this.opts.byWeekNo&&!this.opts.bySetPos&&(!this.opts.byHour||this.canUseEpochMillisecondsPrecisionFlag)&&(!this.opts.byMinute||this.canUseEpochMillisecondsPrecisionFlag)&&(!this.opts.bySecond||this.canUseEpochMillisecondsPrecisionFlag)&&!this.hasOrdinalByDay}canUseUtcMonthlyFastPath(e){return!e&&this.tzid===`UTC`&&this.opts.freq===`MONTHLY`&&!this.opts.rscale&&!this.opts.rDate&&!this.opts.exDate&&!this.opts.byYearDay&&!this.opts.byWeekNo&&this.canUseEpochMillisecondsPrecisionFlag&&this.hasSingleExpandedTimeSlot()&&!!(this.opts.byDay||this.opts.byMonthDay)}utcZdtFromEpochNanoseconds(e){return new X.ZonedDateTime(e,`UTC`)}utcZdtFromEpochMilliseconds(e){return new X.ZonedDateTime(BigInt(e)*Dd,`UTC`)}canUseUtcEpochMillisecondsPrecision(){return this.canUseEpochMillisecondsPrecisionFlag}buildTimeSlotOffsetsMs(){if(!this.canUseEpochMillisecondsPrecisionFlag)return;let e=this.opts.byHour??[this.originalDtstart.hour],t=this.opts.byMinute??[this.originalDtstart.minute],n=this.opts.bySecond??[this.originalDtstart.second],r=this.originalDtstart.millisecond,i=[];for(let a of e)for(let e of t)for(let t of n)i.push(((a*60+e)*60+t)*xd+r);return i}createNumericQueryPlan(e,t,n,r){let i=n(0),a=n(t-1);if(!i||!a||!zd(i.epochMilliseconds)||!zd(a.epochMilliseconds)||i.epochMilliseconds>a.epochMilliseconds)return null;let o=(e,t,i)=>{if(r)return Math.max(0,Math.min(i,r(e,t)));let a=0,o=i;for(;a<o;){let r=a+Math.floor((o-a)/2),i=n(r);if(!i){o=r;continue}let s=BigInt(i.epochMilliseconds)*Dd;(t?s>e:s>=e)?o=r:a=r+1}return a},s=this.opts.until?.epochNanoseconds,c=s===void 0?t:o(s,!0,t);return{kind:e,count:c,maximumCount:t,select:e=>!Number.isSafeInteger(e)||e<0||e>=t?null:n(e),lowerBound:(e,t)=>o(e,t,c)}}buildFixedStepNumericQueryPlan(e){let t;switch(this.opts.freq){case`HOURLY`:t=Cd;break;case`MINUTELY`:t=Sd;break;case`SECONDLY`:t=xd;break;default:return null}if(![`UTC`,`Etc/UTC`,`Etc/GMT`].includes(this.tzid)&&!/^[-+]\d{2}:?\d{2}(?::?\d{2})?$/.test(this.tzid)&&this.opts.freq===`HOURLY`&&this.opts.interval===1)return null;let n=this.originalDtstart.epochMilliseconds,r=t*this.opts.interval;if(!Number.isSafeInteger(r)||r<=0)return null;let i=e=>{let t=n+e*r;return zd(t)?{epochMilliseconds:t,periodIndex:e,occurrenceIndex:e}:null},a=BigInt(n)*Dd,o=BigInt(r)*Dd,s=BigInt(e);return this.createNumericQueryPlan(`fixed-step`,e,i,(t,n)=>{let r=t-a,i=n?Ld(r,o)+1n:Rd(r,o);return i<=0n?0:i>=s?e:Number(i)})}resolveNumericWallMilliseconds(e){if(!zd(e))return null;if(this.tzid===`UTC`)return e;let t=this.getZoneResolver().epochMsForWall(e);return t.pushed||!zd(t.epochMs)?null:t.epochMs}numericQueryGapHazard(e,t){if(this.tzid===`UTC`)return!1;let n=this.originalDtstart.epochMilliseconds;return 200*366*Q,t-n>632448e7?!0:this.getZoneResolver().timeOfDayMayHitGap(e,n-Q,t+Q)}buildDailyNumericQueryPlan(e){let t=this.opts.interval,n=this.originalDtstart.epochMilliseconds,r=this.tzid===`UTC`?n:this.wallMsOf(this.originalDtstart),i=Math.floor(r/Q),a=Vd(i),o=Fd(this.simpleByDayIsoDays);if(!(this.opts.byHour||this.opts.byMinute||this.opts.bySecond)){let n=r-i*Q,s=this.simpleByDayIsoDays?.length?this.findFirstMatchingDailyStep(a,t,this.simpleByDayIsoDays):0;if(s===null)return null;let c=7/Pd(t,7),l=[];for(let e=0;e<c;e++)Id(o,$(a,(s+e)*t))&&l.push(e);if(l.length===0)return null;let u=this.createNumericQueryPlan(`daily`,e,e=>{let n=Math.floor(e/l.length),i=e%l.length,a=n*c+l[i],o=(s+a)*t;if(!Number.isSafeInteger(a)||!Number.isSafeInteger(o))return null;let u=r+o*Q,d=this.resolveNumericWallMilliseconds(u);return d===null?null:{epochMilliseconds:d,periodIndex:a,occurrenceIndex:e}}),d=u?.select(e-1);return d&&this.numericQueryGapHazard(n,d.epochMilliseconds)?null:u}let s=this.timeSlotOffsetsMs;if(!s?.length||!this.hasUniqueTimeSlotOffsets)return null;let c=this.simpleByDayIsoDays?.length?this.findFirstMatchingDailyStep(a,1,this.simpleByDayIsoDays):0;if(c===null)return null;let l=i+c,u=$(a,c),d=7/Pd(t,7),f=[];if(Id(o,u))for(let e of s){let t=this.resolveNumericWallMilliseconds(l*Q+e);if(t===null)return null;t>=n&&f.push({epochMilliseconds:t,periodIndex:0,occurrenceIndex:f.length})}let p=[];for(let e=0;e<d;e++)if(Id(o,$(u,(1+e)*t)))for(let t of s)p.push({periodOffset:e,timeSlotOffset:t});if(f.length===0&&p.length===0)return null;let m=this.createNumericQueryPlan(`daily`,e,e=>{if(e<f.length)return{...f[e],occurrenceIndex:e};if(p.length===0)return null;let n=e-f.length,r=Math.floor(n/p.length),a=p[n%p.length],o=1+r*d+a.periodOffset,s=c+o*t;if(!Number.isSafeInteger(o)||!Number.isSafeInteger(s))return null;let l=(i+s)*Q+a.timeSlotOffset,u=this.resolveNumericWallMilliseconds(l);return u===null?null:{epochMilliseconds:u,periodIndex:o,occurrenceIndex:e}}),h=m?.select(e-1);return h&&s.some(e=>this.numericQueryGapHazard(e,h.epochMilliseconds))?null:m}buildWeeklyNumericQueryPlan(e){let t=this.timeSlotOffsetsMs;if(!t?.length||!this.hasUniqueTimeSlotOffsets)return null;let n=this.originalDtstart.epochMilliseconds,r=this.tzid===`UTC`?n:this.wallMsOf(this.originalDtstart),i=Math.floor(r/Q),a=Vd(i),o=Z[Hd(this.opts.wkst||`MO`)??`MO`]??1,s=(this.opts.byDay?[...this.allByDayIsoDays??[]]:[a]).map(e=>(e-o+7)%7).sort((e,t)=>e-t);if(s.length===0)return null;let c=i-(a-o+7)%7,l=s.flatMap(e=>t.map(t=>({dayOffset:e,timeSlotOffset:t}))),u=[];for(let e of l){let t=(c+e.dayOffset)*Q+e.timeSlotOffset,r=this.resolveNumericWallMilliseconds(t);if(r===null)return null;r>=n&&u.push({epochMilliseconds:r,periodIndex:0,occurrenceIndex:u.length})}let d=this.createNumericQueryPlan(`weekly`,e,e=>{if(e<u.length)return{...u[e],occurrenceIndex:e};let t=e-u.length,n=1+Math.floor(t/l.length),r=l[t%l.length],i=n*this.opts.interval*7;if(!Number.isSafeInteger(n)||!Number.isSafeInteger(i))return null;let a=(c+i+r.dayOffset)*Q+r.timeSlotOffset,o=this.resolveNumericWallMilliseconds(a);return o===null?null:{epochMilliseconds:o,periodIndex:n,occurrenceIndex:e}}),f=d?.select(e-1);return f&&t.some(e=>this.numericQueryGapHazard(e,f.epochMilliseconds))?null:d}buildMonthlyNumericQueryPlan(e){let t=this.opts.interval,n=this.timeSlotOffsetsMs;if(!n?.length||!this.hasUniqueTimeSlotOffsets||this.opts.byMonth?.some(e=>typeof e!=`number`)||this.opts.bySetPos&&new Set(this.opts.bySetPos).size!==this.opts.bySetPos.length)return null;let r=this.originalDtstart.epochMilliseconds,i=this.originalDtstart.year*12+(this.originalDtstart.month-1),a=e=>{let n=e*t,r=i+n;if(!Number.isSafeInteger(n)||!Number.isSafeInteger(r))return null;let{year:a,month:o}=this.monthIndexToYearMonth(r);return this.generateMonthlyOccurrenceEpochsUtc(a,o)},o=a(0);if(!o)return null;let s=[];for(let e of o){let t=this.resolveNumericWallMilliseconds(e);if(t===null)return null;t>=r&&s.push({epochMilliseconds:t,periodIndex:0,occurrenceIndex:s.length})}let c=4800/Pd(t,4800),l=Math.max(0,e-s.length),u=[0];for(let e=0;e<c&&u.at(-1)<l;e++){let t=a(1+e);if(!t)return null;u.push(u[e]+t.length)}let d=u.length-1===c,f=u.at(-1);if(f===0&&s.length<e)return null;let p=this.createNumericQueryPlan(`monthly`,e,e=>{if(e<s.length)return{...s[e],occurrenceIndex:e};if(f===0)return null;let t=e-s.length,n=d?Math.floor(t/f):0,r=d?t%f:t;if(r>=f)return null;let i=1,o=u.length-1;for(;i<o;){let e=i+Math.floor((o-i)/2);u[e]>r?o=e:i=e+1}let l=i-1,p=1+n*c+l;if(!Number.isSafeInteger(p))return null;let m=a(p);if(!m)return null;let h=m[r-u[l]];if(h===void 0)return null;let g=this.resolveNumericWallMilliseconds(h);return g===null?null:{epochMilliseconds:g,periodIndex:p,occurrenceIndex:e}}),m=p?.select(e-1);return m&&n.some(e=>this.numericQueryGapHazard(e,m.epochMilliseconds))?null:p}generateYearlyOccurrenceEpochsUtc(e,t=!0){let n=this.timeSlotOffsetsMs;if(!n?.length)return[];let r=!!(this.opts.byDay||this.opts.byMonthDay),i=!!this.numericByMonths?.length&&!r,a=this.numericByMonths?.length?[...this.numericByMonths].sort((e,t)=>e-t):r?[1,2,3,4,5,6,7,8,9,10,11,12]:[this.originalDtstart.month],o=[];if(this.hasOrdinalByDay&&!this.numericByMonths?.length){let t=this.isGregorianLeapYear(e)?366:365,n=this.gregorianIsoDayOfWeek(e,1,1),r=$(n,t-1),i=new Set;for(let e of this.parsedByDayTokens??[]){if(e.ord===0)continue;let a=e.ord>0?1+(e.isoDay-n+7)%7+7*(e.ord-1):t-(r-e.isoDay+7)%7+7*(e.ord+1);a>=1&&a<=t&&i.add(a)}for(let t of[...i].sort((e,t)=>e-t)){let n=t,r=1;for(;n>this.daysInGregorianMonth(e,r);)n-=this.daysInGregorianMonth(e,r),r+=1;o.push({month:r,day:n})}}else for(let t of a){let n;n=i?[Math.min(this.originalDtstart.day,this.daysInGregorianMonth(e,t))]:r?this.generateMonthlyOccurrenceDaysUtc(e,t):[this.originalDtstart.day];for(let e of n)o.push({month:t,day:e})}let s=[];for(let{month:t,day:r}of o){let i=Bd(e,t,r)*Q;if(!zd(i))return[];for(let e of n)s.push(i+e)}if(s.sort((e,t)=>e-t),!t||!this.opts.bySetPos?.length)return s;let c=this.applyBySetPosToSortedList(s).sort((e,t)=>e-t);return c.filter((e,t)=>t===0||e!==c[t-1])}yearlyCandidateEvaluationCountUtc(e){let t=this.generateYearlyOccurrenceEpochsUtc(e,!1).length,n=this.opts.bySetPos;if(!n?.length)return t;let r=0,i=0;for(let e of n)e>0?r=Math.max(r,e):i=Math.max(i,-e);return Math.min(t,r)+Math.min(t,i)}buildYearlyNumericQueryPlan(e){let t=this.opts.interval,n=this.timeSlotOffsetsMs;if(!n?.length||!this.hasUniqueTimeSlotOffsets||this.opts.byMonth?.some(e=>typeof e!=`number`)||this.opts.byYearDay||this.opts.byWeekNo)return null;let r=!!(this.opts.byDay||this.opts.byMonthDay),i=!!this.opts.byMonth&&!r,a=!this.opts.byMonth&&!r;if(a&&this.originalDtstart.month===2&&this.originalDtstart.day===29||a&&n.length!==1||i&&(n.length!==1||this.opts.bySetPos)||this.hasOrdinalByDay&&!this.numericByMonths?.length&&(this.opts.byMonthDay||this.parsedByDayTokens?.some(e=>e.ord===0)))return null;let o=this.originalDtstart.epochMilliseconds,s=this.originalDtstart.year,c=e=>{let n=e*t,r=s+n;return!Number.isSafeInteger(n)||!Number.isSafeInteger(r)?null:this.generateYearlyOccurrenceEpochsUtc(r)},l=c(0);if(!l)return null;let u=[];for(let e of l){let t=this.resolveNumericWallMilliseconds(e);if(t===null)return null;t>=o&&u.push({epochMilliseconds:t,periodIndex:0,occurrenceIndex:u.length})}let d=400/Pd(t,400),f=Math.max(0,e-u.length),p=[0],m=[0];for(let e=0;e<d&&p.at(-1)<f;e++){let n=c(1+e);if(!n)return null;p.push(p[e]+n.length);let r=s+(1+e)*t;m.push(m[e]+this.yearlyCandidateEvaluationCountUtc(r))}let h=p.length-1===d,g=p.at(-1);if(g===0&&u.length<e)return null;if(r){let e=this.yearlyCandidateEvaluationCountUtc(s);if(h&&f>0){let t=Math.floor(f/g),n=f%g;if(e+=t*m.at(-1),n>0){let t=1;for(;p[t]<n;)t+=1;e+=m[t]}}else e+=m.at(-1);if(e>this.maxCandidateEvaluations)return null}let _=this.createNumericQueryPlan(`yearly`,e,e=>{if(e<u.length)return{...u[e],occurrenceIndex:e};if(g===0)return null;let t=e-u.length,n=h?Math.floor(t/g):0,r=h?t%g:t;if(r>=g)return null;let i=1,a=p.length-1;for(;i<a;){let e=i+Math.floor((a-i)/2);p[e]>r?a=e:i=e+1}let o=i-1,s=1+n*d+o;if(!Number.isSafeInteger(s))return null;let l=c(s);if(!l)return null;let f=l[r-p[o]];if(f===void 0)return null;let m=this.resolveNumericWallMilliseconds(f);return m===null?null:{epochMilliseconds:m,periodIndex:s,occurrenceIndex:e}}),v=_?.select(e-1);return v&&n.some(e=>this.numericQueryGapHazard(e,v.epochMilliseconds))?null:_}buildNumericQueryPlan(){let e=this.opts.count,t=this.opts.interval;if(e===void 0||!Number.isSafeInteger(e)||e<=0||!Number.isSafeInteger(t)||t<=0||!Number.isSafeInteger(this.maxIterations)||this.maxIterations<=0||this.includeDtstart||this.opts.rscale!==void 0||!this.canUseEpochMillisecondsPrecisionFlag||this.originalDtstart.timeZoneId!==this.tzid||![`iso8601`,`gregory`].includes(this.originalDtstart.calendarId))return null;let n=!!(this.opts.byMonth||this.opts.byMonthDay||this.opts.byYearDay||this.opts.byWeekNo||this.opts.bySetPos);switch(this.opts.freq){case`HOURLY`:case`MINUTELY`:case`SECONDLY`:return n||this.opts.byDay||this.opts.byHour||this.opts.byMinute||this.opts.bySecond?null:this.buildFixedStepNumericQueryPlan(e);case`DAILY`:return n||this.hasOrdinalByDay||!this.hasUniqueTimeSlotOffsets?null:this.buildDailyNumericQueryPlan(e);case`WEEKLY`:return n||this.hasOrdinalByDay||!this.hasUniqueTimeSlotOffsets?null:this.buildWeeklyNumericQueryPlan(e);case`MONTHLY`:return this.opts.byYearDay||this.opts.byWeekNo||!(this.opts.byDay||this.opts.byMonthDay)||!this.hasUniqueTimeSlotOffsets?null:this.buildMonthlyNumericQueryPlan(e);case`YEARLY`:return this.buildYearlyNumericQueryPlan(e);default:return null}}getNumericQueryPlan(){if(this.numericQueryPlanCache!==void 0)return this.numericQueryPlanCache;try{this.numericQueryPlanCache=this.buildNumericQueryPlan()}catch{this.numericQueryPlanCache=null}return this.numericQueryPlanCache}findFirstMatchingDailyStep(e,t,n){let r=e;for(let e=0;e<7;e++){if(n.includes(r))return e;r=$(r,t)}return null}allUtcFastPath(e){if(this.canUseUtcLinearFastPath(e))switch(this.opts.freq){case`DAILY`:return this.opts.byHour||this.opts.byMinute||this.opts.bySecond?this.hasUniqueTimeSlotOffsets?this._allUtcDailyExpanded():null:this._allUtcDailySimple();case`HOURLY`:return this._allUtcFixedStepSimple(Ad*BigInt(this.opts.interval));case`MINUTELY`:return this._allUtcFixedStepSimple(kd*BigInt(this.opts.interval));case`SECONDLY`:return this._allUtcFixedStepSimple(Od*BigInt(this.opts.interval))}return this.canUseUtcMonthlyFastPath(e)?this._allUtcMonthlyByDayOrMonthDay():this.canUseUtcWeeklyFastPath(e)?this.opts.byHour||this.opts.byMinute||this.opts.bySecond?this.hasUniqueTimeSlotOffsets?this._allUtcWeeklyExpanded():null:this._allUtcWeeklySimple():null}_allUtcFixedStepSimple(e){let t=[];if(!this.addDtstartIfNeeded(t))return t;let n=0;if(this.canUseUtcEpochMillisecondsPrecision()){let r=this.originalDtstart.epochMilliseconds,i=Number(e/Dd),a=this.opts.until?.epochMilliseconds;for(;;){if(++n>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);if(a!==void 0&&r>a||(t.push(this.utcZdtFromEpochMilliseconds(r)),this.shouldBreakForCountLimit(t.length)))break;r+=i}return t}let r=this.originalDtstart.epochNanoseconds,i=this.opts.until?.epochNanoseconds;for(;;){if(++n>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);if(i!==void 0&&r>i||(t.push(this.utcZdtFromEpochNanoseconds(r)),this.shouldBreakForCountLimit(t.length)))break;r+=e}return t}_allUtcDailySimple(){let e=[];if(!this.addDtstartIfNeeded(e))return e;let t=this.opts.interval,n=this.simpleByDayIsoDays,r=0;if(this.canUseUtcEpochMillisecondsPrecision()){let i=t*Q,a=this.opts.until?.epochMilliseconds,o=this.originalDtstart.epochMilliseconds,s=this.originalDtstart.dayOfWeek;if(n?.length){let r=this.findFirstMatchingDailyStep(s,t,n);if(r===null)return e;o+=r*i,s=$(s,r*t)}for(;;){if(++r>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);if(a!==void 0&&o>a||(!n||n.includes(s))&&(e.push(this.utcZdtFromEpochMilliseconds(o)),this.shouldBreakForCountLimit(e.length)))break;o+=i,s=$(s,t)}return e}let i=BigInt(t)*jd,a=this.opts.until?.epochNanoseconds,o=this.originalDtstart.epochNanoseconds,s=this.originalDtstart.dayOfWeek;if(n?.length){let r=this.findFirstMatchingDailyStep(s,t,n);if(r===null)return e;o+=BigInt(r)*i,s=$(s,r*t)}for(;;){if(++r>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);if(a!==void 0&&o>a||(!n||n.includes(s))&&(e.push(this.utcZdtFromEpochNanoseconds(o)),this.shouldBreakForCountLimit(e.length)))break;o+=i,s=$(s,t)}return e}_allUtcDailyExpanded(){let e=[];if(!this.addDtstartIfNeeded(e))return e;let t=this.timeSlotOffsetsMs,n=this.originalDtstart.epochMilliseconds,r=this.opts.until?.epochMilliseconds,i=this.opts.interval,a=this.simpleByDayIsoDays,o=Math.floor(n/Q),s=this.originalDtstart.dayOfWeek;if(a?.length){let t=this.findFirstMatchingDailyStep(s,1,a);if(t===null)return e;o+=t,s=$(s,t)}let c=0;for(;;){if(++c>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);if(!a||a.includes(s)){let i=o*Q;for(let a of t){let t=i+a;if(!(t<n)&&(r!==void 0&&t>r||(e.push(this.utcZdtFromEpochMilliseconds(t)),this.shouldBreakForCountLimit(e.length))))return e}}o+=i,s=$(s,i)}}_allUtcWeeklySimple(){let e=[];if(!this.addDtstartIfNeeded(e))return e;let t=this.originalDtstart,n=Z[Hd(this.opts.wkst||`MO`)??`MO`]??1,r=(this.opts.byDay?[...this.allByDayIsoDays??[]]:[t.dayOfWeek]).map(e=>(e-n+7)%7).sort((e,t)=>e-t),i=(t.dayOfWeek-n+7)%7,a=0;if(this.canUseUtcEpochMillisecondsPrecision()){let n=t.epochMilliseconds,o=this.opts.until?.epochMilliseconds,s=this.opts.interval*wd,c=n-i*Q;for(;;){if(++a>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);for(let t of r){let r=c+t*Q;if(!(r<n)&&(o!==void 0&&r>o||(e.push(this.utcZdtFromEpochMilliseconds(r)),this.shouldBreakForCountLimit(e.length))))return e}c+=s}}let o=t.epochNanoseconds,s=this.opts.until?.epochNanoseconds,c=BigInt(this.opts.interval)*Md,l=o-BigInt(i)*jd;for(;;){if(++a>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);for(let t of r){let n=l+BigInt(t)*jd;if(!(n<o)&&(s!==void 0&&n>s||(e.push(this.utcZdtFromEpochNanoseconds(n)),this.shouldBreakForCountLimit(e.length))))return e}l+=c}}_allUtcWeeklyExpanded(){let e=[];if(!this.addDtstartIfNeeded(e))return e;let t=this.originalDtstart,n=t.epochMilliseconds,r=Math.floor(n/Q),i=this.opts.until?.epochMilliseconds,a=this.timeSlotOffsetsMs,o=Z[Hd(this.opts.wkst||`MO`)??`MO`]??1,s=(this.opts.byDay?[...this.allByDayIsoDays??[]]:[t.dayOfWeek]).map(e=>(e-o+7)%7).sort((e,t)=>e-t),c=(t.dayOfWeek-o+7)%7,l=this.opts.interval*7,u=r-c,d=0;for(;;){if(++d>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);for(let t of s){let r=(u+t)*Q;for(let t of a){let a=r+t;if(!(a<n)&&(i!==void 0&&a>i||(e.push(this.utcZdtFromEpochMilliseconds(a)),this.shouldBreakForCountLimit(e.length))))return e}}u+=l}}hasSingleExpandedTimeSlot(){if(this.timeSlotOffsetsMs)return this.timeSlotOffsetsMs.length===1;let e=this.opts.byHour??[this.originalDtstart.hour],t=this.opts.byMinute??[this.originalDtstart.minute],n=this.opts.bySecond??[this.originalDtstart.second];return e.length===1&&t.length===1&&n.length===1}buildMonthlyOccurrenceOnDay(e,t){let n=e.day===t?e:e.with({day:t});return this.applyTimeOverride(n)}applyBySetPosToSortedList(e){let{bySetPos:t}=this.opts;if(!t||!t.length||e.length===0)return e;let n=[],r=e.length;for(let i of t){let t=i>0?i-1:r+i;t>=0&&t<r&&n.push(e[t])}return n}generateMonthlyOccurrenceDays(e){let{byDay:t,byMonth:n,byMonthDay:r}=this.opts,i=e.day===1?e:e.with({day:1});if(n&&!n.includes(e.month))return[];let a=i.add({months:1}).subtract({days:1}).day,o=[];if(r&&r.length>0&&(o=r.map(e=>e>0?e:a+e+1).filter(e=>e>=1&&e<=a),o=[...new Set(o)].sort((e,t)=>e-t)),!t&&r&&r.length>0)return o;if(!t)return[e.day];let s=this.parsedByDayTokens;if(!s?.length)return[];let c=i.dayOfWeek,l=(c-1+a-1)%7+1,u=new Set;for(let{ord:e,isoDay:t}of s)if(e===0){let e=1+(t-c+7)%7;for(;e<=a;)u.add(e),e+=7}else{let n;n=e>0?1+(t-c+7)%7+7*(e-1):a-(l-t+7)%7+7*(e+1),n>=1&&n<=a&&u.add(n)}let d=[...u].sort((e,t)=>e-t);if(r&&r.length>0){if(o.length===0)return[];let e=new Set(o);d=d.filter(t=>e.has(t))}return d}isGregorianLeapYear(e){return e%4==0&&(e%100!=0||e%400==0)}daysInGregorianMonth(e,t){return t===2&&this.isGregorianLeapYear(e)?29:Td[t-1]}gregorianIsoDayOfWeek(e,t,n){let r=e;t<3&&--r;let i=((r+Math.floor(r/4)-Math.floor(r/100)+Math.floor(r/400)+Ed[t-1]+n)%7+7)%7;return i===0?7:i}monthIndexToYearMonth(e){let t=Math.floor(e/12);return{year:t,month:e-t*12+1}}generateMonthlyOccurrenceDaysUtc(e,t){if(this.numericByMonths&&this.numericByMonths.length>0&&!this.numericByMonths.includes(t))return[];let n=this.opts.byMonthDay,r=this.opts.byDay,i=this.daysInGregorianMonth(e,t),a=[];if(n&&n.length>0&&(a=n.map(e=>e>0?e:i+e+1).filter(e=>e>=1&&e<=i),a=[...new Set(a)].sort((e,t)=>e-t)),!r&&n&&n.length>0)return a;if(!r){let e=this.originalDtstart.day;return e>=1&&e<=i?[e]:[]}let o=this.parsedByDayTokens;if(!o?.length)return[];let s=this.gregorianIsoDayOfWeek(e,t,1),c=$(s,i-1),l=new Set;for(let{ord:e,isoDay:t}of o)if(e===0){let e=1+(t-s+7)%7;for(;e<=i;)l.add(e),e+=7}else{let n;n=e>0?1+(t-s+7)%7+7*(e-1):i-(c-t+7)%7+7*(e+1),n>=1&&n<=i&&l.add(n)}let u=[...l].sort((e,t)=>e-t);if(n&&n.length>0){if(a.length===0)return[];let e=new Set(a);u=u.filter(t=>e.has(t))}return u}generateMonthlyOccurrenceEpochsUtc(e,t){let n=this.generateMonthlyOccurrenceDaysUtc(e,t);if(n.length===0)return[];let r=Bd(e,t,1)*Q;if(!zd(r))return[];let i=this.timeSlotOffsetsMs??[0];if(this.opts.bySetPos&&this.opts.bySetPos.length>0){if(i.length===1){let e=this.applyBySetPosToSortedList(n).sort((e,t)=>e-t),t=i[0];return e.map(e=>r+(e-1)*Q+t)}let e=[];for(let t of n){let n=r+(t-1)*Q;for(let t of i)e.push(n+t)}return this.applyBySetPosToSortedList(e).sort((e,t)=>e-t)}let a=[];for(let e of n){let t=r+(e-1)*Q;for(let e of i)a.push(t+e)}return a}_allUtcMonthlyByDayOrMonthDay(){let e=[],t=this.originalDtstart.epochMilliseconds,n=this.opts.until?.epochMilliseconds,r=0;if(!this.addDtstartIfNeeded(e))return e;let i=this.originalDtstart.year*12+(this.originalDtstart.month-1);for(;;){if(++r>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);let{year:a,month:o}=this.monthIndexToYearMonth(i),s=this.generateMonthlyOccurrenceEpochsUtc(a,o);for(let r of s)if(!(r<t)&&(n!==void 0&&r>n||(e.push(this.utcZdtFromEpochMilliseconds(r)),this.shouldBreakForCountLimit(e.length))))return e;i+=this.opts.interval}}getZoneResolver(){return this.zoneResolver??=md(this.tzid)}zdtFromEpochMs(e){if(od)return new X.ZonedDateTime(BigInt(e)*Dd,this.tzid);let t=this.emitAnchorZdt;return t?t.add({milliseconds:e-t.epochMilliseconds}):(t=this.emitAnchorZdt=new X.ZonedDateTime(BigInt(e)*Dd,this.tzid),t)}wallMsOf(e){return e.epochMilliseconds+e.offsetNanoseconds/1e6}canUseTzEpochFastPaths(e){if(e||this.tzid===`UTC`||this.opts.rscale||this.opts.rDate||this.opts.exDate||!this.canUseEpochMillisecondsPrecisionFlag)return!1;let t=this.originalDtstart.calendarId;return t===`iso8601`||t===`gregory`}tzFastPathGapHazard(e){let t=this.originalDtstart.epochMilliseconds,n;if(this.opts.until)n=this.opts.until.epochMilliseconds;else if(this.opts.count!==void 0){let e=this.opts.count*this.opts.interval,r;switch(this.opts.freq){case`DAILY`:r=e*7*Q;break;case`WEEKLY`:r=e*wd;break;default:r=e*(this.numericByMonths?.length?Math.ceil(12/this.numericByMonths.length):1)*31*Q;break}n=t+r+30*Q}else return!0;return 150*366*Q,n-t>474336e7?!0:this.getZoneResolver().timeOfDayMayHitGap(e,t-Q,n+Q)}allTzEpochFastPath(e){if(!this.canUseTzEpochFastPaths(e))return null;let t=!this.opts.byMonth&&!this.opts.byMonthDay&&!this.opts.byYearDay&&!this.opts.byWeekNo&&!this.opts.bySetPos;if(t)switch(this.opts.freq){case`DAILY`:if(!this.hasOrdinalByDay)return this.opts.byHour||this.opts.byMinute||this.opts.bySecond?this.hasUniqueTimeSlotOffsets?this._allTzDailyExpanded():null:this._allTzDailySimple();break;case`HOURLY`:case`MINUTELY`:case`SECONDLY`:if(!this.opts.byDay&&!this.opts.byHour&&!this.opts.byMinute&&!this.opts.bySecond){let e=this.opts.freq===`HOURLY`?Cd:this.opts.freq===`MINUTELY`?Sd:xd;return this._allTzFixedStepSimple(e*this.opts.interval)}break}return this.opts.freq===`MONTHLY`&&!this.opts.byYearDay&&!this.opts.byWeekNo&&this.hasSingleExpandedTimeSlot()&&(this.opts.byDay||this.opts.byMonthDay)?this._allTzMonthlyByDayOrMonthDay():this.opts.freq===`WEEKLY`&&t&&!this.hasOrdinalByDay&&this.hasUniqueTimeSlotOffsets?this.opts.byHour||this.opts.byMinute||this.opts.bySecond?this._allTzWeeklyExpanded():this._allTzWeeklySimple():null}_allTzDailySimple(){let e=[];if(!this.addDtstartIfNeeded(e))return e;let t=this.getZoneResolver(),n=this.wallMsOf(this.originalDtstart),r=Math.floor(n/Q),i=n-r*Q;if(this.tzFastPathGapHazard(i))return null;let a=this.opts.interval,o=this.simpleByDayIsoDays,s=this.opts.until?.epochMilliseconds,c=Vd(r);if(o?.length){let t=this.findFirstMatchingDailyStep(c,a,o);if(t===null)return e;r+=t*a,c=$(c,t*a)}let l=0;for(;;){if(++l>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);if(!o||o.includes(c)){let n=t.epochMsForWall(r*Q+i);if(n.pushed)return null;if(s!==void 0&&n.epochMs>s||(e.push(this.zdtFromEpochMs(n.epochMs)),this.shouldBreakForCountLimit(e.length)))break}r+=a,c=$(c,a)}return e}_allTzDailyExpanded(){let e=[];if(!this.addDtstartIfNeeded(e))return e;let t=this.getZoneResolver(),n=this.originalDtstart.epochMilliseconds,r=this.wallMsOf(this.originalDtstart),i=this.timeSlotOffsetsMs;for(let e of i)if(this.tzFastPathGapHazard(e))return null;let a=this.opts.interval,o=this.simpleByDayIsoDays,s=this.opts.until?.epochMilliseconds,c=Math.floor(r/Q),l=Vd(c);if(o?.length){let t=this.findFirstMatchingDailyStep(l,1,o);if(t===null)return e;c+=t,l=$(l,t)}let u=0;for(;;){if(++u>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);if(!o||o.includes(l)){let r=c*Q;for(let a of i){let i=t.epochMsForWall(r+a);if(i.pushed)return null;if(!(i.epochMs<n)&&(s!==void 0&&i.epochMs>s||(e.push(this.zdtFromEpochMs(i.epochMs)),this.shouldBreakForCountLimit(e.length))))return e}}c+=a,l=$(l,a)}}_allTzFixedStepSimple(e){let t=[];if(!this.addDtstartIfNeeded(t))return t;let n=this.getZoneResolver(),r=this.opts.until?.epochMilliseconds,i=this.opts.freq===`HOURLY`&&this.opts.interval===1,a=e=>{let t=e+n.offsetMsAt(e);return Math.floor((t%Q+Q)%Q/Cd)},o=this.originalDtstart.epochMilliseconds,s=0;for(;;){if(++s>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);if(r!==void 0&&o>r||(t.push(this.zdtFromEpochMs(o)),this.shouldBreakForCountLimit(t.length)))break;let n=o+e;i&&a(n)===a(o)&&(n+=e),o=n}return t}_allTzWeeklySimple(){let e=[];if(!this.addDtstartIfNeeded(e))return e;let t=this.getZoneResolver(),n=this.originalDtstart,r=n.epochMilliseconds,i=this.wallMsOf(n),a=Math.floor(i/Q),o=i-a*Q;if(this.tzFastPathGapHazard(o))return null;let s=Vd(a),c=Z[Hd(this.opts.wkst||`MO`)??`MO`]??1,l=(this.opts.byDay?[...this.allByDayIsoDays??[]]:[s]).map(e=>(e-c+7)%7).sort((e,t)=>e-t),u=(s-c+7)%7,d=this.opts.until?.epochMilliseconds,f=this.opts.interval*7,p=a-u,m=0;for(;;){if(++m>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);for(let n of l){let i=t.epochMsForWall((p+n)*Q+o);if(i.pushed)return null;if(!(i.epochMs<r)&&(d!==void 0&&i.epochMs>d||(e.push(this.zdtFromEpochMs(i.epochMs)),this.shouldBreakForCountLimit(e.length))))return e}p+=f}}_allTzWeeklyExpanded(){let e=[];if(!this.addDtstartIfNeeded(e))return e;let t=this.getZoneResolver(),n=this.originalDtstart,r=n.epochMilliseconds,i=this.wallMsOf(n),a=Math.floor(i/Q),o=this.timeSlotOffsetsMs;for(let e of o)if(this.tzFastPathGapHazard(e))return null;let s=Vd(a),c=Z[Hd(this.opts.wkst||`MO`)??`MO`]??1,l=(this.opts.byDay?[...this.allByDayIsoDays??[]]:[s]).map(e=>(e-c+7)%7).sort((e,t)=>e-t),u=(s-c+7)%7,d=this.opts.until?.epochMilliseconds,f=this.opts.interval*7,p=a-u,m=0;for(;;){if(++m>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);for(let n of l){let i=(p+n)*Q;for(let n of o){let a=t.epochMsForWall(i+n);if(a.pushed)return null;if(!(a.epochMs<r)&&(d!==void 0&&a.epochMs>d||(e.push(this.zdtFromEpochMs(a.epochMs)),this.shouldBreakForCountLimit(e.length))))return e}}p+=f}}_allTzMonthlyByDayOrMonthDay(){let e=[];if(!this.addDtstartIfNeeded(e))return e;let t=this.getZoneResolver(),n=this.originalDtstart.epochMilliseconds,r=this.opts.until?.epochMilliseconds,i=(this.wallMsOf(this.originalDtstart)%Q+Q)%Q;if(this.tzFastPathGapHazard(i))return null;let a=this.originalDtstart.year*12+(this.originalDtstart.month-1),o=0;for(;;){if(++o>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);let{year:i,month:s}=this.monthIndexToYearMonth(a);for(let a of this.generateMonthlyOccurrenceEpochsUtc(i,s)){let i=t.epochMsForWall(a);if(i.pushed)return null;if(!(i.epochMs<n)&&(r!==void 0&&i.epochMs>r||(e.push(this.zdtFromEpochMs(i.epochMs)),this.shouldBreakForCountLimit(e.length))))return e}a+=this.opts.interval}}processOccurrences(e,t,n,r,i){for(let a of e)if(!this.processOccurrence(a,t,n,r,i))return{shouldBreak:!0};return{shouldBreak:!1}}processOccurrence(e,t,n,r,i,a){if(a){if(a.seenOccurrences.size===0&&t.length>0)for(let e of t)a.seenOccurrences.add(e.epochNanoseconds);if(a.seenOccurrences.has(e.epochNanoseconds))return!0;a.seenOccurrences.add(e.epochNanoseconds)}return X.ZonedDateTime.compare(e,n)<0?!0:this.opts.until&&X.ZonedDateTime.compare(e,this.opts.until)>0?!1:i&&!i(e)||r&&this.isExcluded(e)?!0:r&&!r(e,t.length)?!1:(t.push(e),!this.shouldBreakForCountLimit(t.length))}_allMonthlyByDayOrMonthDay(e,t){let n=[],r=this.createCandidateWorkBudget(),i=0,a=this.originalDtstart;if(!this.addDtstartIfNeeded(n,e))return this.applyCountLimitAndMergeRDates(n,e);let o=a.with({day:1});for(;;){if(++i>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);if(!this.visitPeriodCandidates(this.generateMonthlyDateCandidates(o),t=>this.processOccurrence(t,n,a,e,void 0,r),t??a,this.opts.until,r))break;try{o=o.add({months:this.opts.interval})}catch{break}if(this.opts.until){let e=this.opts.until.withTimeZone(this.tzid);if(o.year*12+o.month>e.year*12+e.month)break}}return this.applyCountLimitAndMergeRDates(n,e)}_allWeekly(e,t){let n=[],r=this.createCandidateWorkBudget(),i=0,a=this.originalDtstart;if(!this.addDtstartIfNeeded(n,e))return this.applyCountLimitAndMergeRDates(n,e);let o=Z,s=this.opts.byDay?[...this.allByDayIsoDays??[]]:this.opts.byMonthDay&&this.opts.byMonthDay.length>0?[...Object.values(o)]:[a.dayOfWeek],c=o[Hd(this.opts.wkst||`MO`)??`MO`]??1,l=(a.dayOfWeek-c+7)%7,u=a.subtract({days:l});for(;;){if(++i>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);let o=s.map(e=>{let t=(e-c+7)%7;return u.add({days:t})});if(!this.visitPeriodCandidates(o,t=>this.processOccurrence(t,n,a,e,e=>this.matchesByMonth(e)&&this.matchesByMonthDay(e),r),t??a,this.opts.until,r))break;try{u=u.add({weeks:this.opts.interval})}catch{break}if(this.opts.until){let e=this.opts.until.withTimeZone(this.tzid);if(X.PlainDate.compare(u.toPlainDate(),e.toPlainDate())>0)break}}return this.applyCountLimitAndMergeRDates(n,e)}_allMonthlyByMonth(e){let t=[],n=0,r=this.originalDtstart;if(!this.addDtstartIfNeeded(t,e))return this.applyCountLimitAndMergeRDates(t,e);let i=this.opts.byMonth.filter(e=>typeof e==`number`).sort((e,t)=>e-t),a=0,o=i.findIndex(e=>e>=r.month);for(o===-1&&(o=0,a=1);;){if(++n>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);let s=o+a,c=i[s%i.length],l=Math.floor(s/i.length),u=r.with({year:r.year+l,month:c});if(this.opts.until&&X.ZonedDateTime.compare(u,this.opts.until)>0)break;if(X.ZonedDateTime.compare(u,r)>=0){if(e&&this.isExcluded(u))continue;if(e&&!e(u,t.length)||(t.push(u),this.shouldBreakForCountLimit(t.length)))break}a++}return this.applyCountLimitAndMergeRDates(t,e)}_allYearlyByMonth(e){let t=[],n=0,r=this.originalDtstart;if(!this.addDtstartIfNeeded(t,e))return this.applyCountLimitAndMergeRDates(t,e);let i=this.opts.byMonth.filter(e=>typeof e==`number`).sort((e,t)=>e-t),a=0;for(;;){if(++n>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);let o=r.year+a*this.opts.interval;for(let n of i){let i=r.with({year:o,month:n});if(i=this.applyTimeOverride(i),!(X.ZonedDateTime.compare(i,r)<0)&&(this.opts.until&&X.ZonedDateTime.compare(i,this.opts.until)>0||!(e&&this.isExcluded(i))&&(e&&!e(i,t.length)||(t.push(i),this.shouldBreakForCountLimit(t.length)))))return this.applyCountLimitAndMergeRDates(t,e)}a++}}_allYearlyComplex(e,t){let n=[],r=this.createCandidateWorkBudget(),i=0,a=this.originalDtstart;if(!this.addDtstartIfNeeded(n,e)||this.opts.until&&X.ZonedDateTime.compare(this.opts.until,a)<0)return this.applyCountLimitAndMergeRDates(n,e);let o=a.with({month:1,day:1}),s=this.opts.until?this.opts.until.withTimeZone(this.tzid).year+(this.opts.byWeekNo?1:0):void 0;for(;;){if(++i>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);let c=this.generateYearlyDateCandidates(o);if(!this.visitPeriodCandidates(c,t=>this.processOccurrence(t,n,a,e,void 0,r),t??a,this.opts.until,r))break;let l=this.opts.freq===`WEEKLY`?1:this.opts.interval;try{o=o.add({years:l})}catch{break}if(s!==void 0&&o.year>s)break}return this.applyCountLimitAndMergeRDates(n,e)}_allMinutelySecondlyComplex(e){let t=[],n=0;if(!this.addDtstartIfNeeded(t,e))return this.applyCountLimitAndMergeRDates(t,e);let r=this.computeFirst();for(;;){if(++n>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);if(this.opts.until&&X.ZonedDateTime.compare(r,this.opts.until)>0)break;if(this.matchesAll(r)){if(e&&this.isExcluded(r)){r=this.nextCandidateSameDate(r);continue}if(e&&!e(r,t.length)||(t.push(r),this.shouldBreakForCountLimit(t.length)))break;r=this.nextCandidateSameDate(r)}else r=this.findNextValidDate(r)}return this.applyCountLimitAndMergeRDates(t,e)}_allMonthlyByWeekNo(e,t){let n=[],r=this.createCandidateWorkBudget(),i=0,a=this.originalDtstart;if(!this.addDtstartIfNeeded(n,e))return this.applyCountLimitAndMergeRDates(n,e);let o=a,s=[...this.opts.byWeekNo].sort((e,t)=>e-t),c=this.opts.interval,l=0,u=-1;outer_loop:for(;!this.shouldBreakForCountLimit(n.length);){if(++i>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);let d=o.year;if(d!==u&&o.month>=a.month){u=d;for(let i of s)if(!this.visitDateTimeCandidates(this.generateDateCandidatesForWeekInYear(d,i),1,t=>this.processOccurrence(t,n,a,e,void 0,r),t??a,this.opts.until,r))break outer_loop}if(l+=c,o=a.add({months:l}),this.opts.until&&X.ZonedDateTime.compare(o,this.opts.until)>0)break}return this.applyCountLimitAndMergeRDates(n,e)}_allMonthlyByYearDay(e,t){let n=[],r=this.createCandidateWorkBudget(),i=0,a=this.originalDtstart;if(!this.addDtstartIfNeeded(n,e))return this.applyCountLimitAndMergeRDates(n,e);let o=a.year,s=[...this.opts.byYearDay].sort((e,t)=>e-t),c=this.opts.interval,l=a.year*12+a.month;outer_loop:for(;!this.shouldBreakForCountLimit(n.length);){if(++i>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);let u=a.with({year:o,month:1,day:1}),d=u.with({month:12,day:31}).dayOfYear,f=[];for(let e of s){let t=e>0?e:d+e+1;t<=0||t>d||f.push(u.add({days:t-1}))}if(!this.visitDateTimeCandidates(f,1,t=>(t.year*12+t.month-l)%c!==0||!this.matchesByMonth(t)?!0:this.processOccurrence(t,n,a,e,void 0,r),t??a,this.opts.until,r))break outer_loop;if(o++,this.opts.until&&o>this.opts.until.year+2)break;if(!this.opts.until&&this.opts.count){let e=Math.ceil(this.opts.count/(this.opts.byYearDay.length||1))*c+5;if(o>a.year+e)break}}return this.applyCountLimitAndMergeRDates(n,e)}_allDailyMinutelyHourlyWithBySetPos(e){let t=[],n=0,r=this.originalDtstart;if(!this.addDtstartIfNeeded(t,e))return this.applyCountLimitAndMergeRDates(t,e);let i,a;switch(this.opts.freq){case`MINUTELY`:i=r.with({second:0,microsecond:0,nanosecond:0}),a={minutes:this.opts.interval};break;case`HOURLY`:i=r.with({minute:0,second:0,microsecond:0,nanosecond:0}),a={hours:this.opts.interval};break;case`DAILY`:i=r.with({hour:0,minute:0,second:0,microsecond:0,nanosecond:0}),a={days:this.opts.interval};break;default:return this.applyCountLimitAndMergeRDates(t,e)}for(;;){if(++n>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);let o=this.expandByTime(i);o=o.filter(e=>this.matchesAll(e)),o=this.applyBySetPos(o);let{shouldBreak:s}=this.processOccurrences(o,t,r,e);if(s||(i=i.add(a),this.opts.until&&X.ZonedDateTime.compare(i,this.opts.until)>0))break}return this.applyCountLimitAndMergeRDates(t,e)}_allFallback(e){let t=[],n=0,r=this.computeFirst();if(this.includeDtstart&&X.ZonedDateTime.compare(r,this.originalDtstart)>0&&!(e&&this.isExcluded(this.originalDtstart))&&(e&&!e(this.originalDtstart,t.length)||(t.push(this.originalDtstart),this.shouldBreakForCountLimit(t.length))))return this.applyCountLimitAndMergeRDates(t,e);for(;;){if(++n>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);if(this.opts.until&&X.ZonedDateTime.compare(r,this.opts.until)>0||this.matchesAll(r)&&!(e&&this.isExcluded(r))&&(e&&!e(r,t.length)||(t.push(r),this.shouldBreakForCountLimit(t.length))))break;r=this.nextCandidateSameDate(r)}return this.applyCountLimitAndMergeRDates(t,e)}all(e){if(e){let t=[];return this.allInternal((n,r)=>{let i=this.toPublicDate(n);return e(i,r)?(t.push(i),!0):!1}),t}return!e&&this.opts.cache!==!1?(this.allResultCache||=this.allInternal(),this.publicAllResultCache||=this.toPublicDates(this.allResultCache),this.publicAllResultCache.slice()):this.toPublicDates(this.allInternal())}allInternal(e,t){if(this.opts.count===void 0&&!this.opts.until&&!e)throw Error(`all() requires iterator when no COUNT/UNTIL`);if(e&&(this.opts.rDate||this.opts.exDate))return this.iterateRecurrenceSet(e);if(this.opts.count===0)return this.applyCountLimitAndMergeRDates([],e);if(this.opts.until&&X.ZonedDateTime.compare(this.opts.until,this.originalDtstart)<0){let t=[];return this.addDtstartIfNeeded(t,e),this.applyCountLimitAndMergeRDates(t,e)}if(this.opts.rscale&&[`CHINESE`,`HEBREW`,`INDIAN`].includes(this.opts.rscale)&&([`YEARLY`,`MONTHLY`,`WEEKLY`].includes(this.opts.freq)||this.opts.byYearDay||this.opts.byWeekNo||this.opts.byMonthDay&&this.opts.byMonthDay.length>0))return this._allRscaleNonGregorian(e,t);if(this.opts.byWeekNo&&this.opts.byYearDay&&!this.hasPossibleYearDayWeekNoCombination()){let t=[];return this.addDtstartIfNeeded(t,e),this.applyCountLimitAndMergeRDates(t,e)}return this.allUtcFastPath(e)||this.allTzEpochFastPath(e)||(this.opts.freq===`MONTHLY`&&(this.opts.byDay||this.opts.byMonthDay)&&!this.opts.byWeekNo?this._allMonthlyByDayOrMonthDay(e,t):this.opts.freq===`WEEKLY`&&!(this.opts.byYearDay&&this.opts.byYearDay.length>0)&&!(this.opts.byWeekNo&&this.opts.byWeekNo.length>0)?this._allWeekly(e,t):this.opts.freq===`MONTHLY`&&this.opts.byMonth&&!this.opts.byDay&&!this.opts.byMonthDay&&!this.opts.byYearDay?this._allMonthlyByMonth(e):this.opts.freq===`YEARLY`&&this.opts.byMonth&&!this.opts.byDay&&!this.opts.byMonthDay&&!this.opts.byYearDay&&!this.opts.byWeekNo?this._allYearlyByMonth(e):this.opts.freq===`YEARLY`&&(this.opts.byDay||this.opts.byMonthDay||this.opts.byYearDay||this.opts.byWeekNo)||this.opts.freq===`WEEKLY`&&this.opts.byYearDay&&this.opts.byYearDay.length>0||this.opts.freq===`WEEKLY`&&this.opts.byWeekNo&&this.opts.byWeekNo.length>0?this._allYearlyComplex(e,t):(this.opts.freq===`MINUTELY`||this.opts.freq===`SECONDLY`)&&(this.opts.byMonth||this.opts.byWeekNo||this.opts.byYearDay||this.opts.byMonthDay||this.opts.byDay)?this._allMinutelySecondlyComplex(e):this.opts.freq===`MONTHLY`&&this.opts.byWeekNo&&this.opts.byWeekNo.length>0?this._allMonthlyByWeekNo(e,t):this.opts.freq===`MONTHLY`&&this.opts.byYearDay&&this.opts.byYearDay.length>0&&!this.opts.byDay&&!this.opts.byMonthDay?this._allMonthlyByYearDay(e,t):this.opts.rscale&&this.opts.freq===`MONTHLY`&&!this.opts.byDay&&!this.opts.byMonthDay&&!this.opts.byWeekNo&&!this.opts.byYearDay?this._allMonthlyRscaleSimple(e):(this.opts.freq===`MINUTELY`||this.opts.freq===`HOURLY`||this.opts.freq===`DAILY`)&&this.opts.bySetPos?this._allDailyMinutelyHourlyWithBySetPos(e):this._allFallback(e))}_allMonthlyRscaleSimple(e){let t=[],n=0,r=this.originalDtstart,i=this.opts.interval??1,a=r.day;if(!this.addDtstartIfNeeded(t,e))return this.applyCountLimitAndMergeRDates(t,e);let o=r.with({day:1});for(;;){if(++n>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);let s=o.add({months:1}).subtract({days:1}).day,c=null;if(a<=s)c=o.with({day:a});else{let e=this.opts.skip||`OMIT`;c=e===`BACKWARD`?o.with({day:s}):e===`FORWARD`?o.add({months:1}).with({day:1}):null}if(c&&(c=c.with({hour:r.hour,minute:r.minute,second:r.second}),!(e&&this.isExcluded(c))&&X.ZonedDateTime.compare(c,r)>=0))if(!e||e(c,t.length)){if(t.push(c),this.shouldBreakForCountLimit(t.length))break}else break;if(o=o.add({months:i}),this.opts.until&&X.ZonedDateTime.compare(o,this.opts.until)>0)break}return this.applyCountLimitAndMergeRDates(t,e)}mergeAndDeduplicateRDates(e){this.opts.rDate&&e.push(...this.opts.rDate);let t=e.map(e=>e.epochNanoseconds),n=!0;for(let e=1;e<t.length;e++)if(t[e-1]>t[e]){n=!1;break}n||(e=e.map((e,t)=>t).sort((e,n)=>t[e]<t[n]?-1:t[e]>t[n]?1:0).map(t=>e[t]),t.sort((e,t)=>e<t?-1:e>t?1:0));let r=[];for(let n=0;n<e.length;n++)(n===0||t[n]!==t[n-1])&&r.push(e[n]);return r}isExcluded(e){return this.isExcludedEpoch(e.epochNanoseconds)}isExcludedEpoch(e){return!this.opts.exDate||this.opts.exDate.length===0?!1:(this.exDateEpochNs===void 0&&(this.exDateEpochNs=new Set(this.opts.exDate.map(e=>e.epochNanoseconds))),this.exDateEpochNs.has(e))}getNumericRDates(){if(this.numericRDatesCache)return this.numericRDatesCache;let e=[...this.opts.rDate??[]].sort((e,t)=>e.epochNanoseconds<t.epochNanoseconds?-1:e.epochNanoseconds>t.epochNanoseconds?1:0),t=[],n;for(let r of e)r.epochNanoseconds!==n&&(n=r.epochNanoseconds,this.isExcludedEpoch(n)||t.push(r));return this.numericRDatesCache=t}numericRDateLowerBound(e,t){let n=this.getNumericRDates(),r=0,i=n.length;for(;r<i;){let a=r+Math.floor((i-r)/2),o=n[a].epochNanoseconds;(t?o>e:o>=e)?i=a:r=a+1}return r}excludeExDates(e){return!this.opts.exDate||this.opts.exDate.length===0?e:e.filter(e=>!this.isExcluded(e))}applyCountLimitAndMergeRDates(e,t){let n=this.opts.count===void 0?e:e.slice(0,Math.max(this.opts.count,0)),r=this.mergeAndDeduplicateRDates(n),i=this.excludeExDates(r);return!t||!this.opts.rDate&&!this.opts.exDate?i:this.applyIterator(i,t)}iterateRecurrenceSet(t){let n=[],r=[...this.opts.rDate??[]].sort((e,t)=>X.ZonedDateTime.compare(e,t)),i=0,a,o=!1,s=e=>{let r=e.epochNanoseconds;return a===r||(a=r,this.isExcluded(e))?!0:t(e,n.length)?(n.push(e),!0):(o=!0,!1)},c=e=>{for(;i<r.length&&r[i].epochNanoseconds<e;)if(!s(r[i++]))return!1;return!0},l=e=>{if(!c(e.epochNanoseconds)||!s(e))return!1;for(;i<r.length&&r[i].epochNanoseconds===e.epochNanoseconds;)i++;return!0};for((this.opts.count===void 0||this.opts.count>0)&&new e({...this.cloneOptions(),rDate:void 0,exDate:void 0,cache:!1}).allInternal(l);!o&&i<r.length&&s(r[i++]););return n}applyIterator(e,t){let n=[];for(let r of e){if(!t(r,n.length))break;n.push(r)}return n}shouldBreakForCountLimit(e){return this.opts.count===void 0?!1:e>=this.opts.count}hasTimeOfDayBetween(e,t){if(X.PlainTime.compare(e,t)>=0)return!1;let n=this.originalDtstart,r=this.opts.byHour??[n.hour],i=this.opts.byMinute??[n.minute],a=this.opts.bySecond??[n.second];for(let o of r)for(let r of i)for(let i of a){let a=X.PlainTime.from({hour:o,minute:r,second:i,millisecond:n.millisecond,microsecond:n.microsecond,nanosecond:n.nanosecond});if(X.PlainTime.compare(a,e)>=0&&X.PlainTime.compare(a,t)<0)return!0}return!1}assertNumericCandidateReachable(e){if(e&&e.periodIndex>=this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`)}numericExhaustionCandidate(e){return e.count<e.maximumCount?e.select(e.count):e.count>0?e.select(e.count-1):null}tryNumericNext(e,t){let n=this.getNumericQueryPlan();if(!n)return{handled:!1};let r=n.lowerBound(e,!t);if(!this.opts.rDate&&!this.opts.exDate){if(r>=n.count)return this.assertNumericCandidateReachable(this.numericExhaustionCandidate(n)),{handled:!0,value:null};let e=n.select(r);return e?(this.assertNumericCandidateReachable(e),{handled:!0,value:this.zdtFromEpochMs(e.epochMilliseconds)}):{handled:!1}}let i=this.getNumericRDates()[this.numericRDateLowerBound(e,!t)];for(;r<n.count;){let e=n.select(r);if(!e)return{handled:!1};let t=BigInt(e.epochMilliseconds)*Dd;if(this.assertNumericCandidateReachable(e),i&&i.epochNanoseconds<t)return{handled:!0,value:i};if(!this.isExcludedEpoch(t))return{handled:!0,value:this.zdtFromEpochMs(e.epochMilliseconds)};r+=1}let a=this.numericExhaustionCandidate(n);return this.assertNumericCandidateReachable(a),{handled:!0,value:i??null}}tryNumericPrevious(e,t){let n=this.getNumericQueryPlan();if(!n)return{handled:!1};let r=n.lowerBound(e,t),i=r<n.count?n.select(r):this.numericExhaustionCandidate(n);this.assertNumericCandidateReachable(i);let a=r-1;if(!this.opts.rDate&&!this.opts.exDate){if(a<0)return{handled:!0,value:null};let e=n.select(a);return e?{handled:!0,value:this.zdtFromEpochMs(e.epochMilliseconds)}:{handled:!1}}let o=null;for(;a>=0;){let e=n.select(a);if(!e)return{handled:!1};if(!this.isExcludedEpoch(BigInt(e.epochMilliseconds)*Dd)){o=e;break}--a}let s=this.getNumericRDates(),c=this.numericRDateLowerBound(e,t)-1,l=c>=0?s[c]:null;return!o||l&&l.epochNanoseconds>BigInt(o.epochMilliseconds)*Dd?{handled:!0,value:l}:{handled:!0,value:this.zdtFromEpochMs(o.epochMilliseconds)}}tryNumericBetween(e,t,n){if(e>t)return{handled:!1};let r=this.getNumericQueryPlan();if(!r)return{handled:!1};let i=r.lowerBound(e,!n),a=r.lowerBound(t,n),o=r.lowerBound(t,!0),s=o<r.count?r.select(o):this.numericExhaustionCandidate(r);if(this.assertNumericCandidateReachable(s),i>=a&&!this.opts.rDate)return{handled:!0,value:[]};if(!this.opts.rDate&&!this.opts.exDate){let e=Array(a-i);for(let t=i;t<a;t++){let n=r.select(t);if(!n)return{handled:!1};e[t-i]=this.zdtFromEpochMs(n.epochMilliseconds)}return{handled:!0,value:e}}let c=[];for(let e=i;e<a;e++){let t=r.select(e);if(!t)return{handled:!1};let n=BigInt(t.epochMilliseconds)*Dd;this.isExcludedEpoch(n)||c.push(this.zdtFromEpochMs(t.epochMilliseconds))}let l=this.getNumericRDates(),u=this.numericRDateLowerBound(e,!n),d=this.numericRDateLowerBound(t,n),f=[],p=0,m=u;for(;p<c.length||m<d;){let e=c[p],t=l[m];!t||e&&e.epochNanoseconds<=t.epochNanoseconds?(f.push(e),p+=1,t&&t.epochNanoseconds===e.epochNanoseconds&&(m+=1)):(f.push(t),m+=1)}return{handled:!0,value:f}}between(t,n,r=!1){let i=qd(t,`after`),a=qd(n,`before`),o=this.tryNumericBetween(i,a,r);if(o.handled)return this.toPublicDates(o.value);let s=new X.ZonedDateTime(i,this.tzid),c=new X.ZonedDateTime(a,this.tzid),l={...this.opts};(!l.until||X.ZonedDateTime.compare(c,l.until)<0)&&(l.until=c),l.count===void 0&&(l.dtstart=this.jumpAlignedDtstart(s));let u=new e({...l,strict:l.count===void 0?l.strict:!1,temporal:this.outputTemporal}).allInternal(void 0,l.count===void 0?s:void 0);return this.toPublicDates(u.filter(e=>{let t=r?e.epochNanoseconds>=i:e.epochNanoseconds>i,n=r?e.epochNanoseconds<=a:e.epochNanoseconds<a;return t&&n}))}jumpAlignedDtstart(t){let n=this.opts.interval??1,r=t.withPlainTime(this.originalDtstart.toPlainTime()),i;switch(this.opts.freq){case`YEARLY`:i=`years`;break;case`MONTHLY`:i=`months`;break;case`WEEKLY`:i=`weeks`;break;case`DAILY`:i=`days`;break;case`HOURLY`:i=`hours`;break;case`MINUTELY`:i=`minutes`;break;default:i=`seconds`}let a=e.normalizeToPolyfill(this.opts.dtstart),o=e.normalizeToPolyfill(t).withTimeZone(a.timeZoneId),s=e.normalizeToPolyfill(r.withPlainTime(this.originalDtstart.toPlainTime())).withTimeZone(a.timeZoneId),c=[`hours`,`minutes`,`seconds`].includes(i)?o:s,l=a.until(c,{largestUnit:i})[i],u=Math.floor(l/n),d=e=>{switch(i){case`years`:return{years:e};case`months`:return{months:e};case`weeks`:return{weeks:e};case`days`:return{days:e};case`hours`:return{hours:e};case`minutes`:return{minutes:e};default:return{seconds:e}}},f=e.normalizeToPolyfill(this.opts.dtstart.add(d(u*n)));u>0&&[`years`,`months`,`weeks`,`days`].includes(i)&&f.toPlainDate().equals(o.toPlainDate())&&X.ZonedDateTime.compare(f,o)>0&&this.hasTimeOfDayBetween(o.toPlainTime(),f.toPlainTime())&&(--u,f=e.normalizeToPolyfill(this.opts.dtstart.add(d(u*n))));let p=e.normalizeToPolyfill(this.opts.dtstart);return X.ZonedDateTime.compare(f,p)<0&&(f=p),f}matches(e){let t=qd(e,`date`);return this.nextInternal(t,!0)?.epochNanoseconds===t}occursOn(e){let t=X.PlainDate.from(e.toString()).toZonedDateTime({timeZone:this.tzid,plainTime:X.PlainTime.from(`00:00`)}),n=t.add({days:1}),r=this.nextInternal(t.epochNanoseconds,!0);return r!==null&&r.epochNanoseconds<n.epochNanoseconds}nextInternal(e,t){let n=this.tryNumericNext(e,t);if(n.handled)return n.value;let r=null,i=n=>{n.allInternal(n=>(t?n.epochNanoseconds>=e:n.epochNanoseconds>e)?((!r||n.epochNanoseconds<r.epochNanoseconds)&&(r=n),!1):!0)};return this.opts.count===void 0?i(this.ruleFromAlignedDtstart(new X.ZonedDateTime(e,this.tzid))):i(this),r}next(e=new Date,t=!1){return this.toPublicDate(this.nextInternal(qd(e,`after`),t))}ruleFromAlignedDtstart(t){let n=this.jumpAlignedDtstart(t);return n.epochNanoseconds===this.originalDtstart.epochNanoseconds?this:new e({...this.opts,temporal:this.outputTemporal,dtstart:n,includeDtstart:!1})}previous(e=new Date,t=!1){let n=qd(e,`before`),r=this.tryNumericPrevious(n,t);if(r.handled)return this.toPublicDate(r.value);let i=e=>{let r=null;return e.allInternal(e=>(t?e.epochNanoseconds>n:e.epochNanoseconds>=n)?!1:(r=e,!0)),r};if(this.opts.count!==void 0)return this.toPublicDate(i(this));let a=new X.ZonedDateTime(n,this.tzid),o=this.opts.until&&X.ZonedDateTime.compare(this.opts.until,a)<0?this.opts.until:a,s=this.opts.interval??1;for(let e=0;e<16;e++){let t=e===0?o:o.subtract(this.freqDuration(s*4**e)),n=this.ruleFromAlignedDtstart(t),r=i(n);if(r||n===this)return this.toPublicDate(r)}return this.toPublicDate(i(this))}freqDuration(e){switch(this.opts.freq){case`YEARLY`:return{years:e};case`MONTHLY`:return{months:e};case`WEEKLY`:return{weeks:e};case`DAILY`:return{days:e};case`HOURLY`:return{hours:e};case`MINUTELY`:return{minutes:e};default:return{seconds:e}}}toString(){let e=this.originalDtstart.toString({smallestUnit:`second`}).replace(/[-:]/g,``),t=`DTSTART;TZID=${this.tzid}:${e.slice(0,15)}`,n=[],{freq:r,interval:i,count:a,until:o,byHour:s,byMinute:c,bySecond:l,byDay:u,byMonth:d,byMonthDay:f,bySetPos:p,byWeekNo:m,byYearDay:h,wkst:g,rDate:_,exDate:v}=this.opts;this.opts.rscale&&n.push(`RSCALE=${this.opts.rscale}`),this.opts.rscale&&this.opts.skip&&n.push(`SKIP=${this.opts.skip}`),n.push(`FREQ=${r}`),i!==1&&n.push(`INTERVAL=${i}`),a!==void 0&&n.push(`COUNT=${a}`),o&&n.push(`UNTIL=${this.formatIcsDateTime(o)}`),s&&n.push(`BYHOUR=${s.join(`,`)}`),c&&n.push(`BYMINUTE=${c.join(`,`)}`),l&&n.push(`BYSECOND=${l.join(`,`)}`),u&&n.push(`BYDAY=${u.join(`,`)}`),d&&n.push(`BYMONTH=${d.join(`,`)}`),f&&n.push(`BYMONTHDAY=${f.join(`,`)}`),p&&n.push(`BYSETPOS=${p.join(`,`)}`),m&&n.push(`BYWEEKNO=${m.join(`,`)}`),h&&n.push(`BYYEARDAY=${h.join(`,`)}`),g&&n.push(`WKST=${g}`);let ee=[t,`RRULE:${n.join(`;`)}`];return _&&ee.push(`RDATE:${this.joinDates(_)}`),v&&ee.push(`EXDATE:${this.joinDates(v)}`),ee.join(`
|
|
2
|
+
`)}formatIcsDateTime(e){return e.toInstant().toString().replace(/[-:]/g,``).slice(0,15)+`Z`}joinDates(e){return e.map(e=>this.formatIcsDateTime(e))}generateMonthlyDateCandidates(e){let t=e.day===1?e:e.with({day:1});if(!this.opts.byDay&&!this.opts.byMonthDay)return[e];let n=this.generateMonthlyOccurrenceDays(t);return n.length===0?[]:n.map(e=>t.with({day:e}))}generateMonthlyOccurrences(e){return this.generateMonthlyDateCandidates(e).flatMap(e=>this.expandByTime(e))}generateYearlyDateCandidates(e){let t=this.opts.byMonth?this.opts.byMonth.filter(e=>typeof e==`number`).sort((e,t)=>e-t):this.opts.byMonthDay||this.opts.byDay?[1,2,3,4,5,6,7,8,9,10,11,12]:[this.originalDtstart.month],n=[];if(this.opts.byDay&&this.opts.byDay.some(e=>/^[+-]?\d/.test(e))&&!this.opts.byMonth){let t=Z;for(let r of this.opts.byDay){let i=Ud(r);if(!i||i.ord===0)continue;let a=i.ord,o=t[i.weekday],s;if(a>0){let t=e.with({month:1,day:1}),n=(o-t.dayOfWeek+7)%7;s=t.add({days:n+7*(a-1)})}else{let t=e.with({month:12,day:31}),n=(t.dayOfWeek-o+7)%7;s=t.subtract({days:n+7*(-a-1)})}n.push(s)}}else if(!this.opts.byYearDay&&!this.opts.byWeekNo){n=[];for(let r of t){let t=e.with({month:r,day:1}),i=this.generateMonthlyDateCandidates(t);if(i.length===0&&this.opts.rscale&&this.opts.byMonthDay&&this.opts.byMonthDay.length>0){let e=t.add({months:1}).subtract({days:1}).day,r=this.opts.byMonthDay[0],i=r>0?r:e+r+1;if(i>e||i<=0){let r=this.opts.skip||`OMIT`;if(r===`BACKWARD`)n.push(t.with({day:e}));else if(r===`FORWARD`){let e=t.add({months:1}).with({day:1});n.push(e)}}}else n.push(...i)}}if(this.opts.byYearDay){let t=e.with({month:12,day:31}).dayOfYear;for(let r of this.opts.byYearDay){let i=r>0?r:t+r+1;if(i<=0||i>t)continue;let a=this.opts.freq===`MINUTELY`?e.with({month:1,day:1,hour:0,minute:0,second:0,millisecond:0}).add({days:i-1}):e.with({month:1,day:1}).add({days:i-1});(!this.opts.byMonth||this.opts.byMonth.includes(a.month))&&n.push(a)}}if(this.opts.byWeekNo){let{lastWeek:t,firstWeekStart:r,tokens:i}=this.isoWeekByDay(e);for(let e of this.opts.byWeekNo){if(e>0&&e>t||e<0&&-e>t)continue;let a=e>0?e-1:t+e,o=r.add({weeks:a});n.push(...this.addByDayDates(i,o))}}return this.sortedUniqueDateCandidates(n)}addByDayDates(e,t){let n=Z,r=n[this.opts.wkst||`MO`],i=[];for(let a of e){if(!a)continue;let e=n[a],o=t.add({days:(e-r+7)%7});(!this.opts.byMonth||this.opts.byMonth.includes(o.month))&&i.push(o)}return this.sortedUniqueDateCandidates(i)}findNextValidValue(e,t,n){return t.find(t=>n(t,e)>0)||null}findNextValidDate(e){if(this.opts.byWeekNo&&this.opts.byYearDay){let t=e.with({month:1,day:1,hour:0,minute:0,second:0,millisecond:0}),n=this.opts.byYearDay.map(e=>{let n=t.with({month:12,day:31}).dayOfYear;return e>0?e:n+e+1});for(let e of n){let n=t.add({days:e-1});if(this.matchesByWeekNo(n))break}}if(this.opts.byMonth){let t=this.opts.byMonth.filter(e=>typeof e==`number`);if(t.length&&!t.includes(e.month)){let n=[...t].sort((e,t)=>e-t),r=this.findNextValidValue(e.month,n,(e,t)=>e-t);return e=r?e.with({month:r,day:1,hour:0,minute:0,second:0}):e.add({years:1}).with({month:n[0],day:1,hour:0,minute:0,second:0}),e=this.applyTimeOverride(e),e}}if(this.opts.byWeekNo&&!this.matchesByWeekNo(e))return e=e.add({weeks:1}).with({hour:0,minute:0,second:0}),e=this.applyTimeOverride(e),e;if(this.opts.byYearDay&&!this.matchesByYearDay(e)){let t=[...this.opts.byYearDay].sort((e,t)=>e-t),n=e.dayOfYear,r=e.with({month:12,day:31}).dayOfYear,i=t.find(e=>(e>0?e:r+e+1)>n);if(i){let t=i>0?i:r+i+1;e=this.opts.freq===`MINUTELY`||this.opts.freq===`SECONDLY`?e.with({month:1,day:1,hour:0,minute:0,second:0,millisecond:0}).add({days:t-1}):e.with({month:1,day:1}).add({days:t-1})}else{let n=e.add({years:1}),r=n.with({month:12,day:31}).dayOfYear,i=t[0];if(i!==void 0){let t=i>0?i:r+i+1;e=this.opts.freq===`MINUTELY`||this.opts.freq===`SECONDLY`?n.with({month:1,day:1,hour:0,minute:0,second:0,millisecond:0}).add({days:t-1}):n.with({month:1,day:1}).add({days:t-1})}}return e=this.applyTimeOverride(e),e}if(this.opts.byMonthDay&&!this.matchesByMonthDay(e)){let t=[...this.opts.byMonthDay].sort((e,t)=>e-t),n=e.with({day:1}).add({months:1}).subtract({days:1}).day,r=e.day,i=t.map(e=>e>0?e:n+e+1).filter(e=>e>0&&e<=n).sort((e,t)=>e-t),a=this.findNextValidValue(r,i,(e,t)=>e-t);if(a)e=e.with({day:a,hour:0,minute:0,second:0});else{let n=e.add({months:1}).with({day:1}),r=n.add({months:1}).subtract({days:1}).day,i=t[0];if(i!==void 0){let t=i>0?i:r+i+1;e=n.with({day:Math.max(1,Math.min(t,r)),hour:0,minute:0,second:0})}else e=e.add({months:1}).with({day:1,hour:0,minute:0,second:0})}return e=this.applyTimeOverride(e),e}if(this.opts.byDay&&!this.matchesByDay(e)){let t=this.allByDayIsoDays;if(!t?.length)return this.applyTimeOverride(e.add({days:1}).with({hour:0,minute:0,second:0}));let n=this.findNextValidValue(e.dayOfWeek,t,(e,t)=>e-t);if(n){let t=(n-e.dayOfWeek+7)%7;e=e.add({days:t}).with({hour:0,minute:0,second:0})}else{let n=(t[0]-e.dayOfWeek+7)%7;e=e.add({days:n+7}).with({hour:0,minute:0,second:0})}return e=this.applyTimeOverride(e),e}switch(this.opts.freq){case`SECONDLY`:case`MINUTELY`:e=e.add({days:1}).with({hour:0,minute:0,second:0});break;case`HOURLY`:e=e.add({days:1}).with({hour:0,minute:0,second:0});break;case`DAILY`:case`WEEKLY`:e=e.add({months:1}).with({day:1,hour:0,minute:0,second:0});break;case`MONTHLY`:case`YEARLY`:e=e.add({years:1}).with({month:1,day:1,hour:0,minute:0,second:0});break}return this.applyTimeOverride(e)}applyBySetPos(e){let{bySetPos:t}=this.opts;if(!t||!t.length)return e;let n=[...e].sort((e,t)=>X.ZonedDateTime.compare(e,t));return this.applyBySetPosToSortedList(n).sort((e,t)=>X.ZonedDateTime.compare(e,t))}isoWeekByDay(e){let t=Z,n=t[this.opts.wkst||`MO`],r=e.with({month:1,day:1}),i=e.with({month:1,day:4}),a=(i.dayOfWeek-n+7)%7,o=i.subtract({days:a}),s=r.inLeapYear;return{lastWeek:r.dayOfWeek===4||s&&r.dayOfWeek===3?53:52,firstWeekStart:o,tokens:this.opts.byDay?.length?this.opts.byDay.map(e=>Hd(e)).filter(e=>e!==null):[Object.entries(t).find(([,e])=>e===this.originalDtstart.dayOfWeek)[0]]}}generateDateCandidatesForWeekInYear(e,t){let n=[],r=this.originalDtstart.with({year:e,month:1,day:1}),{lastWeek:i,firstWeekStart:a,tokens:o}=this.isoWeekByDay(r);if(t>0&&t>i||t<0&&-t>i)return n;let s=t>0?t-1:i+t,c=a.add({weeks:s});return n.push(...this.addByDayDates(o,c)),this.sortedUniqueDateCandidates(n)}getRscaleCalendarId(){return{GREGORIAN:`gregory`,CHINESE:`chinese`,HEBREW:`hebrew`,INDIAN:`indian`}[this.opts.rscale?.toUpperCase()||``]||null}assertRscaleCalendarSupported(t){if(t===`gregory`||t===`iso8601`)return;let n=e.rscaleCalendarSupport[t];if(n===!0)return;if(n===!1)throw Error(`RSCALE=${this.opts.rscale} is not supported by the current Temporal/Intl implementation`);let r=!0;try{let e=ad.ZonedDateTime.from(`2000-01-01T00:00:00+00:00[UTC]`).withCalendar(t);e.year,e.monthCode,e.day}catch{r=!1}if(e.rscaleCalendarSupport[t]=r,!r)throw Error(`RSCALE=${this.opts.rscale} is not supported by the current Temporal/Intl implementation`)}pad2(e){return String(e).padStart(2,`0`)}monthMatchesToken(e,t){if(typeof t==`number`)return e===`M${this.pad2(t)}`;if(/^\d+L$/i.test(t)){let n=parseInt(t,10);return e===`M${this.pad2(n)}L`}return!1}monthsOfYear(e,t){let n=[];for(let r=1;r<=20;r++)try{let i=ad.PlainDate.from({calendar:e,year:t,month:r,day:1});n.push(i)}catch{break}return n}startOfYear(e,t){return ad.PlainDate.from({calendar:e,year:t,month:1,day:1})}endOfYear(e,t){return this.startOfYear(e,t+1).subtract({days:1})}rscaleFirstWeekStart(e,t,n){let r=ad.PlainDate.from({calendar:e,year:t,month:1,day:4}),i=(r.dayOfWeek-n+7)%7;return r.subtract({days:i})}rscaleLastWeekCount(e,t,n){let r=this.rscaleFirstWeekStart(e,t,n),i=this.endOfYear(e,t).since(r).days;return Math.floor(i/7)+1}lastDayOfMonth(e){return e.with({day:1}).add({months:1}).subtract({days:1}).day}toRscaleZdt(e){return ad.ZonedDateTime.from(e.toString())}buildZdtFromPlainDate(e){let t=this.originalDtstart,n=e.withCalendar(`iso8601`),r=ad.PlainDateTime.from({year:n.year,month:n.month,day:n.day,hour:t.hour,minute:t.minute,second:t.second});return new X.ZonedDateTime(r.toZonedDateTime(this.tzid).epochNanoseconds,this.tzid)}rscaleMatchesByYearDay(e,t){let n=this.opts.byYearDay;if(!n||n.length===0)return!0;let r=this.endOfYear(e,t.year).dayOfYear;return n.some(e=>e>0?t.dayOfYear===e:t.dayOfYear===r+e+1)}rscaleMatchesByWeekNo(e,t){let n=this.opts.byWeekNo;if(!n||n.length===0)return!0;let r=Z[this.opts.wkst||`MO`],i=t.subtract({days:(t.dayOfWeek-r+7)%7}).add({days:(4-r+7)%7}).year,a=this.rscaleFirstWeekStart(e,i,r),o=this.rscaleLastWeekCount(e,i,r),s=Math.floor(t.since(a).days/7)+1;return n.some(e=>e>0?s===e:s===o+e+1)}rscaleMatchesByMonth(e,t){let n=this.opts.byMonth;return!n||n.length===0?!0:n.some(e=>this.monthMatchesToken(t.monthCode,e))}rscaleMatchesByMonthDay(e){let t=this.opts.byMonthDay;if(!t||t.length===0)return!0;let n=e.with({day:1}).add({months:1}).subtract({days:1}).day,r=e.day;return t.some(e=>e>0?r===e:r===n+e+1)}rscaleMatchesByDayBasic(e){let t=this.opts.byDay;if(!t||t.length===0)return!0;let n=Z,r=t.map(e=>Hd(e)).filter(e=>e!==null);return r.length===0?!0:r.some(t=>n[t]===e.dayOfWeek)}rscaleDateMatches(e,t){return this.rscaleMatchesByMonth(e,t)&&this.rscaleMatchesByYearDay(e,t)&&this.rscaleMatchesByWeekNo(e,t)&&this.rscaleMatchesByMonthDay(t)&&this.rscaleMatchesByDayBasic(t)}applySkipForDay(e,t,n,r){let i=this.lastDayOfMonth(n),a=this.opts.skip||`OMIT`;return r>=1&&r<=i?n.with({day:r}):a===`BACKWARD`?n.with({day:i}):a===`FORWARD`?n.add({months:1}).with({day:1}):null}generateMonthlyOccurrencesRscale(e,t,n){let r=[],i=this.opts.byMonthDay,a=this.opts.byDay;if(!a&&!i){let i=this.toRscaleZdt(this.originalDtstart).withCalendar(e).day,a=this.applySkipForDay(e,t,n,i);return a&&r.push(this.buildZdtFromPlainDate(a)),r}let o=e=>{r.push(this.buildZdtFromPlainDate(e))},s=this.lastDayOfMonth(n),c=e=>e>0?e:s+e+1;if(i&&i.length>0)for(let r of i){let i=c(r),a=this.applySkipForDay(e,t,n,i);a&&o(a)}if(a&&a.length>0){let e=Z,t={},r=n;for(;r.month===n.month&&r.year===n.year;){let e=r.dayOfWeek;(t[e]||=[]).push(r),r=r.add({days:1})}for(let n of a){let r=Ud(n);if(!r)continue;let i=r.ord,a=t[e[r.weekday]]||[];if(a.length!==0)if(i===0)for(let e of a)o(e);else{let e=a[i>0?i-1:a.length+i];e&&o(e)}}}return this.applyBySetPos(r).sort((e,t)=>X.ZonedDateTime.compare(e,t))}_allRscaleNonGregorian(e,t){let n=this.getRscaleCalendarId();if(!n)return this._allFallback(e);this.assertRscaleCalendarSupported(n);let r=[],i=this.createCandidateWorkBudget(),a=0,o=this.originalDtstart,s=this.toRscaleZdt(o).withCalendar(n),c=this.opts.interval??1;if(!this.addDtstartIfNeeded(r,e))return this.applyCountLimitAndMergeRDates(r,e);if(this.opts.freq===`YEARLY`){let l=0;for(;;){if(++a>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);let u=s.year+l*c,d=[],f=this.opts.byMonth,p=this.monthsOfYear(n,u),m=Z,h=m[this.opts.wkst||`MO`];if(this.opts.byWeekNo&&this.opts.byWeekNo.length>0){let e=this.rscaleFirstWeekStart(n,u,h),t=this.rscaleLastWeekCount(n,u,h),r=this.opts.byDay?.length?this.opts.byDay.map(e=>Hd(e)).filter(e=>e!==null):[Object.entries(m).find(([,e])=>e===this.originalDtstart.dayOfWeek)[0]];for(let i of this.opts.byWeekNo){let a=i>0?i-1:t+i;if(a<0||a>=t)continue;let o=e.add({weeks:a});for(let e of r){let t=m[e],r=o.add({days:(t-h+7)%7});if(!(f&&f.length>0&&!f.some(e=>this.monthMatchesToken(r.monthCode,e)))){if(this.opts.byYearDay&&this.opts.byYearDay.length>0){let e=this.endOfYear(n,u).dayOfYear;if(!this.opts.byYearDay.some(t=>{let n=t>0?t:e+t+1;return r.dayOfYear===n}))continue}d.push(this.buildZdtFromPlainDate(r))}}}}else if(this.opts.byYearDay&&this.opts.byYearDay.length>0){let e=this.startOfYear(n,u),t=this.endOfYear(n,u).dayOfYear;for(let n of this.opts.byYearDay){let r=n>0?n:t+n+1;if(r<1||r>t)continue;let i=e.add({days:r-1});f&&f.length>0&&!f.some(e=>this.monthMatchesToken(i.monthCode,e))||d.push(this.buildZdtFromPlainDate(i))}}else if(!f||f.length===0)try{let e=ad.PlainDate.from({calendar:n,year:u,monthCode:s.monthCode,day:s.day});d.push(this.buildZdtFromPlainDate(e))}catch{let e=this.opts.skip||`OMIT`;if(e===`FORWARD`||e===`BACKWARD`){let t=s.with({year:u}),n=e===`BACKWARD`?t.subtract({days:1}):t;d.push(new X.ZonedDateTime(n.epochNanoseconds,this.tzid))}}else{let e=p.filter(e=>f.some(t=>this.monthMatchesToken(e.monthCode,t)));for(let t of e)d.push(...this.generateMonthlyOccurrencesRscale(n,u,t))}if(d.length>0&&!this.visitDateTimeCandidates(d,1,t=>this.processOccurrence(t,r,o,e,void 0,i),t??o,this.opts.until,i)||(l++,this.opts.until&&u>this.toRscaleZdt(this.opts.until).withCalendar(n).year))break}return this.applyCountLimitAndMergeRDates(r,e)}if(this.opts.freq===`WEEKLY`){let c=Z,l=c[this.opts.wkst||`MO`],u=this.opts.byDay?.length?this.opts.byDay.map(e=>Hd(e)).filter(e=>e!==null):[Object.entries(c).find(([,e])=>e===this.originalDtstart.dayOfWeek)[0]],d=s.toPlainDate().subtract({days:(s.dayOfWeek-l+7)%7});for(;;){if(++a>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);let s=[];for(let e of u){let t=c[e],r=d.add({days:(t-l+7)%7});if(X.ZonedDateTime.compare(this.buildZdtFromPlainDate(r),this.originalDtstart)<0)continue;if(this.opts.byWeekNo&&this.opts.byWeekNo.length>0){let e=d.add({days:(4-l+7)%7}).year,t=this.rscaleFirstWeekStart(n,e,l),i=this.rscaleLastWeekCount(n,e,l),a=Math.floor(r.since(t).days/7)+1;if(!this.opts.byWeekNo.some(e=>e>0?a===e:a===i+e+1))continue}if(this.opts.byYearDay&&this.opts.byYearDay.length>0){let e=this.endOfYear(n,r.year).dayOfYear;if(!this.opts.byYearDay.some(t=>t>0?r.dayOfYear===t:r.dayOfYear===e+t+1))continue}let i=this.opts.byMonth;i&&i.length>0&&!i.some(e=>this.monthMatchesToken(r.monthCode,e))||s.push(this.buildZdtFromPlainDate(r))}if(s.length&&!this.visitDateTimeCandidates(s,1,t=>this.processOccurrence(t,r,o,e,void 0,i),t??o,this.opts.until,i))return this.applyCountLimitAndMergeRDates(r,e);if(d=d.add({weeks:this.opts.interval??1}),this.opts.until){let e=this.buildZdtFromPlainDate(d.add({days:6}));if(X.ZonedDateTime.compare(e,this.opts.until)>0)break}}return this.applyCountLimitAndMergeRDates(r,e)}if(this.opts.freq===`MONTHLY`){let c=s.toPlainDate().with({day:1});for(;;){if(++a>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);let s=c.year,l=c,u=!0,d=this.opts.byMonth;if(d&&d.length>0&&(u=d.some(e=>this.monthMatchesToken(l.monthCode,e))),u){let a=this.generateMonthlyOccurrencesRscale(n,s,l);if(!this.visitDateTimeCandidates(a,1,t=>this.processOccurrence(t,r,o,e,void 0,i),t??o,this.opts.until,i))break}if(c=c.add({months:this.opts.interval??1}),this.opts.until){let e=this.buildZdtFromPlainDate(c);if(X.ZonedDateTime.compare(e,this.opts.until)>0)break}}return this.applyCountLimitAndMergeRDates(r,e)}if(this.opts.freq===`DAILY`){let c=s.toPlainDate();for(;;){if(++a>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);if(this.rscaleDateMatches(n,c)){let n=this.buildZdtFromPlainDate(c);if(!this.visitPeriodCandidates([n],t=>this.processOccurrence(t,r,o,e,void 0,i),t??o,this.opts.until,i))break}if(c=c.add({days:this.opts.interval??1}),this.opts.until){let e=this.buildZdtFromPlainDate(c);if(X.ZonedDateTime.compare(e,this.opts.until)>0)break}}return this.applyCountLimitAndMergeRDates(r,e)}if(this.opts.freq===`HOURLY`||this.opts.freq===`MINUTELY`){this.opts.freq;let c=this.opts.freq===`HOURLY`?36e5:6e4,l=this.opts.interval??1,u=s.toPlainDate(),d=this.originalDtstart.toInstant().epochMilliseconds;for(;;){if(++a>this.maxIterations)throw Error(`Maximum iterations (${this.maxIterations}) exceeded in all()`);if(this.rscaleDateMatches(n,u)){let n=this.buildZdtFromPlainDate(u);if(!this.visitDateTimeCandidates([n],1,t=>{let n=t.toInstant().epochMilliseconds-d;return Math.floor(n/c)%l===0?this.processOccurrence(t,r,o,e,void 0,i):!0},t??o,this.opts.until,i))break}if(u=u.add({days:1}),this.opts.until){let e=this.buildZdtFromPlainDate(u);if(X.ZonedDateTime.compare(e,this.opts.until)>0)break}}return this.applyCountLimitAndMergeRDates(r,e)}return this._allFallback(e)}};export{Z as i,hd as n,gd as r,of as t};
|