neramjs 0.0.0-stage → 0.1.0

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.
@@ -0,0 +1,2 @@
1
+ /*! neramjs v0.1.0 | MIT | github.com/varksh05/neramjs */
2
+ function H(t,e,n,r=0,s=0,i=0,a=0){if(t>=100)return Date.UTC(t,e,n,r,s,i,a);let o=new Date(0);return o.setUTCFullYear(t,e,n),o.setUTCHours(r,s,i,a),o.getTime()}function ye(t){return H(t.y,t.M,t.D,t.h,t.m,t.s,t.ms)}var Te=/^([+-])(\d{2}):?(\d{2})$/;function _(t){if(t==="Z"||t==="z")return 0;let e=Te.exec(t)??/^([+-])(\d{2})$/.exec(t);if(!e)return;let n=Number(e[2]),r=Number(e[3]??0);if(n>23||r>59)return;let s=n*60+r;return e[1]==="-"?-s:s}function W(t,e=":"){let n=t<0?"-":"+",r=Math.abs(t);return`${n}${String(Math.floor(r/60)).padStart(2,"0")}${e}${String(r%60).padStart(2,"0")}`}function ve(t){return Te.test(t)}var rt={"Asia/Calcutta":"Asia/Kolkata","Asia/Saigon":"Asia/Ho_Chi_Minh","Asia/Katmandu":"Asia/Kathmandu","Asia/Rangoon":"Asia/Yangon","Europe/Kiev":"Europe/Kyiv","Atlantic/Faeroe":"Atlantic/Faroe","America/Godthab":"America/Nuuk","Pacific/Enderbury":"Pacific/Kanton","Pacific/Truk":"Pacific/Chuuk","Pacific/Ponape":"Pacific/Pohnpei","Africa/Asmera":"Africa/Asmara","America/Buenos_Aires":"America/Argentina/Buenos_Aires","America/Catamarca":"America/Argentina/Catamarca","America/Cordoba":"America/Argentina/Cordoba","America/Jujuy":"America/Argentina/Jujuy","America/Mendoza":"America/Argentina/Mendoza","America/Indianapolis":"America/Indiana/Indianapolis","America/Louisville":"America/Kentucky/Louisville"};function st(t){try{return new Intl.DateTimeFormat("en-US",{timeZone:t}),!0}catch{return!1}}function Ue(t){let e=rt[t];return e&&st(e)?e:t}var ke=new Map;function F(t){if(t==null||t==="local")return"local";if(typeof t!="string"||t.trim()==="")throw new RangeError(`neram: unknown time zone ${JSON.stringify(t)}`);let e=ke.get(t);if(e)return e;let n,r=t.toUpperCase();if(r==="UTC"||r==="Z"||r==="GMT"||r==="ETC/UTC"||r==="ETC/GMT")n="UTC";else{let s=_(t);if(s!==void 0)n=s===0?"UTC":W(s);else try{let i=new Intl.DateTimeFormat("en-US",{timeZone:t}).resolvedOptions().timeZone;n=Ue(i.toLowerCase()===t.toLowerCase()?i:t)}catch{throw new RangeError(`neram: unknown time zone "${t}"`)}}return ke.set(t,n),n}var Se=new Map;function it(t){let e=Se.get(t);return e||(e=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),Se.set(t,e)),e}function ae(t,e){let n=it(e).formatToParts(new Date(t)),r=0,s=0,i=0,a=0,o=0,u=0,m=!1;for(let c of n)switch(c.type){case"year":r=Number(c.value);break;case"month":s=Number(c.value)-1;break;case"day":i=Number(c.value);break;case"hour":a=Number(c.value)%24;break;case"minute":o=Number(c.value);break;case"second":u=Number(c.value);break;case"era":m=/^b/i.test(c.value);break}m&&(r=1-r);let l=t-(t%1e3+1e3)%1e3;return Math.round((H(r,s,i,a,o,u)-l)/6e4)}var oe=864e5,at=5e4,Ie=-1e9,Oe=new Map;function ot(t,e){let n=Oe.get(e);n||(n=new Map,Oe.set(e,n));let r=Math.floor(t/oe),s=n.get(r);if(s!==void 0)return s===Ie?ae(t,e):s;let i=ae(r*oe,e),a=ae(r*oe+oe-1e3,e);return n.size>=at&&n.clear(),n.set(r,i===a?i:Ie),i===a?i:ae(t,e)}var ge=new Map;function R(t,e){if(e==="UTC")return 0;if(e==="local")return-new Date(t).getTimezoneOffset()||0;let n=ge.get(e);return n===void 0&&!ge.has(e)&&(n=_(e),ge.set(e,n)),n!==void 0?n:ot(t,e)}function B(t,e){if(e==="local"&&t.y>=100)return new Date(t.y,t.M,t.D,t.h,t.m,t.s,t.ms).getTime();let n=ye(t);if(e==="UTC")return n;let r=_(e);if(r!==void 0)return n-r*6e4;let s=R(n-864e5,e),i=R(n+864e5,e),a=new Set([R(n,e),s,i]),o=[];for(let u of a)R(n-u*6e4,e)===u&&o.push(u);return o.length?n-Math.max(...o)*6e4:n-s*6e4}function ut(t){let e=Math.floor(t/864e5),n=t-e*864e5,r=Ae(e),s=Math.floor(n/36e5);n-=s*36e5;let i=Math.floor(n/6e4);n-=i*6e4;let a=Math.floor(n/1e3);return{y:r.y,M:r.M,D:r.D,h:s,m:i,s:a,ms:n-a*1e3,dow:r.dow}}function xe(t,e){return ut(t+e*6e4)}function q(){return Ue(new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC")}function ue(t){return t%4===0&&t%100!==0||t%400===0}function Ae(t){let e=t+719468,n=Math.floor(e/146097),r=e-n*146097,s=Math.floor((r-Math.floor(r/1460)+Math.floor(r/36524)-Math.floor(r/146096))/365),i=r-(365*s+Math.floor(s/4)-Math.floor(s/100)),a=Math.floor((5*i+2)/153),o=i-Math.floor((153*a+2)/5)+1,u=a<10?a+2:a-10;return{y:s+n*400+(u<=1?1:0),M:u,D:o,dow:(t%7+7+4)%7}}var mt=[31,28,31,30,31,30,31,31,30,31,30,31];function C(t,e){return e===1&&ue(t)?29:mt[e]}function ct(t){return ue(t)?366:365}function G(t,e,n){return Math.round((H(t,e,n)-H(t,0,1))/864e5)+1}function Ye(t,e,n){return new Date(H(t,e,n)).getUTCDay()}function I(t,e,n,r,s){let i=G(t,e,n),a=(Ye(t,e,n)-r+7)%7,o=i-a,u=(Ye(t,0,1)-r+7)%7,m=7-u>=s?1-u:8-u;return o<m?I(t-1,11,31,r,s):o+6-ct(t)>=s?{week:1,year:t+1}:{week:Math.floor((o-m)/7)+1,year:t}}function Le(t,e,n){for(let r=31;r>24;r--){let s=I(t,11,r,e,n);if(s.year===t)return s.week}return 52}var pe={normalizeSpaces:!0},lt=/[\u00a0\u2007\u2009\u202f]/g;function O(t){return pe.normalizeSpaces?t.replace(lt," "):t}var me=Intl,Re=new Map;function $e(t,e="en",n="conjunction",r="long"){if(me.ListFormat){let i=`${e}|${n}|${r}`,a=Re.get(i);return a||(a=new me.ListFormat(e,{type:n,style:r}),Re.set(i,a)),O(a.format(t))}if(t.length<=1)return t.join("");if(n==="unit")return t.join(", ");let s=n==="disjunction"?"or":"and";return t.length===2?`${t[0]} ${s} ${t[1]}`:`${t.slice(0,-1).join(", ")}, ${s} ${t.at(-1)}`}var Ce=new Map;function Q(t,e,n,r="long"){let s=`${n}|${e}|${r}`,i=Ce.get(s);if(i===void 0){try{i=new Intl.NumberFormat(n,{style:"unit",unit:e,unitDisplay:r})}catch{i=null}Ce.set(s,i)}return i?O(i.format(t)):`${t} ${e}${Math.abs(t)===1?"":"s"}`}var Ee=new Map;function We(t,e,n,r,s){if(me.RelativeTimeFormat){let o=`${n}|${r}|${s}`,u=Ee.get(o);return u||(u=new me.RelativeTimeFormat(n,{style:r,numeric:s}),Ee.set(o,u)),O(u.format(t,e))}if(s==="auto"){if(t===0)return e==="day"?"today":"now";if(e==="day"&&t===1)return"tomorrow";if(e==="day"&&t===-1)return"yesterday"}let i=Math.abs(t),a=`${i} ${e}${i===1?"":"s"}`;return t<0||Object.is(t,-0)?`${a} ago`:`in ${a}`}var Fe={ms:"millisecond",s:"second",m:"minute",h:"hour",d:"day",D:"date",w:"week",W:"isoWeek",M:"month",Q:"quarter",y:"year"},Pe=new Set(["millisecond","second","minute","hour","day","date","week","isoWeek","month","quarter","year"]);function N(t){if(t==null)return;if(Fe[t])return Fe[t];if(Pe.has(t))return t;let e=t.toLowerCase().replace(/s$/,"");if(e==="isoweek")return"isoWeek";if(Pe.has(e))return e;throw new RangeError(`neram: unknown unit "${t}"`)}var T=1e3,v=60*T,U=60*v,k=24*U,X=7*k,De=365.2425*k,ee=De/12,ce={millisecond:1,second:T,minute:v,hour:U};function le(t,e){let n=Math.abs(t),r=t<0?-1:1,s=a=>r*Math.round(a);if(n<45*T)return{value:s(n/T),unit:"second"};if(n<45*v)return{value:s(n/v),unit:"minute"};if(n<22*U)return{value:s(n/U),unit:"hour"};if(n<26*k)return{value:s(n/k),unit:"day"};let i=e!==void 0?Math.abs(e):n/ee;return i<10.5?{value:s(Math.max(1,i)),unit:"month"}:{value:s(Math.max(1,i/12)),unit:"year"}}function te(t,e,n,r={}){let s=r.style??"long";return r.withoutSuffix?Q(Math.abs(t),e,n,s):We(t,e,n,s,r.numeric??"auto")}var E=["years","months","weeks","days","hours","minutes","seconds","milliseconds"],de="Invalid Duration",ze={years:De,months:ee,weeks:X,days:k,hours:U,minutes:v,seconds:T,milliseconds:1},dt=/^([+-])?P(?:(-?[\d.,]+)Y)?(?:(-?[\d.,]+)M)?(?:(-?[\d.,]+)W)?(?:(-?[\d.,]+)D)?(?:T(?:(-?[\d.,]+)H)?(?:(-?[\d.,]+)M)?(?:(-?[\d.,]+)S)?)?$/i;function he(t){if(E.includes(t))return t;switch(N(t)){case"year":return"years";case"quarter":throw new RangeError("neram: use months for quarter durations");case"month":return"months";case"week":case"isoWeek":return"weeks";case"day":case"date":return"days";case"hour":return"hours";case"minute":return"minutes";case"second":return"seconds";default:return"milliseconds"}}var P=class t{#e;constructor(e,n="milliseconds"){let r={years:0,months:0,weeks:0,days:0,hours:0,minutes:0,seconds:0,milliseconds:0};if(e instanceof t)Object.assign(r,e.toObject());else if(typeof e=="number")r[he(n)]=e;else if(typeof e=="string"){let s=dt.exec(e.trim());if(!s||e.trim().toUpperCase()==="P"||/T$/i.test(e.trim()))throw new RangeError(`neram: invalid ISO 8601 duration "${e}"`);let i=s[1]==="-"?-1:1;E.forEach((o,u)=>{if(o==="milliseconds")return;let m=s[u+2];m&&(r[o]=i*Number(m.replace(",",".")))});let a=Math.trunc(r.seconds);r.milliseconds=Math.round((r.seconds-a)*1e3),r.seconds=a}else if(e)for(let[s,i]of Object.entries(e))i!=null&&(r[he(s)]+=i);this.#e=r}isValid(){return E.every(e=>Number.isFinite(this.#e[e]))}get years(){return this.#e.years}get months(){return this.#e.months}get weeks(){return this.#e.weeks}get days(){return this.#e.days}get hours(){return this.#e.hours}get minutes(){return this.#e.minutes}get seconds(){return this.#e.seconds}get milliseconds(){return this.#e.milliseconds}get(e){return this.#e[he(e)]}as(e){return this.valueOf()/ze[he(e)]}asMilliseconds(){return this.as("milliseconds")}asSeconds(){return this.as("seconds")}asMinutes(){return this.as("minutes")}asHours(){return this.as("hours")}asDays(){return this.as("days")}asWeeks(){return this.as("weeks")}asMonths(){return this.as("months")}asYears(){return this.as("years")}valueOf(){if(!this.isValid())return NaN;let e=0;for(let n of E)e+=this.#e[n]*ze[n];return e}add(e,n){let r=e instanceof t?e:new t(e,n),s={};for(let i of E)s[i]=this.#e[i]+r.get(i);return new t(s)}subtract(e,n){let r=e instanceof t?e:new t(e,n);return this.add(r.negate())}negate(){let e={};for(let n of E)e[n]=-this.#e[n]||0;return new t(e)}abs(){return this.valueOf()<0?this.negate():this}sign(){let e=this.valueOf();return e===0?0:e<0?-1:1}isZero(){return E.every(e=>this.#e[e]===0)}normalize(){if(!this.isValid())return this;let e=this.#e,n=e.weeks*X+e.days*k+e.hours*U+e.minutes*v+e.seconds*T+e.milliseconds,r=e.years*12+e.months,s=n<0?-1:1,i=Math.abs(n),a=d=>{let g=Math.floor(i/d);return i-=g*d,s*g||0},o=a(k),u=a(U),m=a(v),l=a(T),c=s*Math.round(i)||0;return new t({years:Math.trunc(r/12)||0,months:r%12||0,days:o,hours:u,minutes:m,seconds:l,milliseconds:c})}humanize(e=!1,n="en"){if(!this.isValid())return de;let r=typeof e=="object"?e:{withoutSuffix:!e},s=this.#e.years*12+this.#e.months,i=this.valueOf()-s*ee,{value:a,unit:o}=le(this.valueOf(),i===0&&s!==0?s:void 0);return te(a,o,r.locale??n,{numeric:"always",...r})}toLocaleString(e="en",n="long"){if(!this.isValid())return de;let r=Intl.DurationFormat;if(r)return O(new r(e,{style:n}).format(this.toObject()));let s=n==="digital"?"narrow":n,i=E.filter(a=>this.#e[a]!==0).map(a=>Q(this.#e[a],a.slice(0,-1),e,s));return i.length?$e(i,e,"unit",s):Q(0,"second",e,s)}format(e="HH:mm:ss"){if(!this.isValid())return de;let n=this.abs().normalize(),r=(i,a=2)=>String(i).padStart(a,"0"),s=e.replace(/\[([^\]]*)\]|YYYY|Y|MM|M|DD|D|HH|H|mm|m|ss|s|SSS/g,(i,a)=>{if(a!==void 0)return a;switch(i){case"Y":return String(n.years);case"YYYY":return r(n.years,4);case"M":return String(n.months);case"MM":return r(n.months);case"D":return String(n.days);case"DD":return r(n.days);case"H":return String(n.hours);case"HH":return r(n.hours);case"m":return String(n.minutes);case"mm":return r(n.minutes);case"s":return String(n.seconds);case"ss":return r(n.seconds);default:return r(n.milliseconds,3)}});return this.sign()<0?`-${s}`:s}toISOString(){if(!this.isValid())throw new RangeError("neram: invalid duration");let e={...this.#e};e.days+=e.weeks*7;let n=[e.years,e.months,e.days,e.hours,e.minutes,e.seconds+e.milliseconds/1e3],r=n.every(u=>u<=0)&&n.some(u=>u<0),s=r?-1:1,i=u=>String(Math.round(s*u*1e3)/1e3),a="";e.years&&(a+=`${i(e.years)}Y`),e.months&&(a+=`${i(e.months)}M`),e.days&&(a+=`${i(e.days)}D`);let o="";return e.hours&&(o+=`${i(e.hours)}H`),e.minutes&&(o+=`${i(e.minutes)}M`),(e.seconds||e.milliseconds)&&(o+=`${i(e.seconds+e.milliseconds/1e3)}S`),!a&&!o?"PT0S":`${r?"-":""}P${a}${o?`T${o}`:""}`}toJSON(){return this.isValid()?this.toISOString():null}toString(){return this.isValid()?this.toISOString():de}toObject(){return{...this.#e}}};function z(t,e){return new P(t,e)}function ne(t){return t instanceof P}var ht={...Z(5,"MV"),...Z(6,"AF BH DJ DZ EG IQ IR JO KW LY OM QA SD SY"),...Z(0,"AG AS BD BR BS BT BW BZ CA CO DM DO ET GT GU HK HN ID IL IN IS JM JP KE KH KR LA MH MM MO MT MX MZ NI NP PA PE PH PK PR PT PY SA SG SV TH TT TW UM US VE VI WS YE ZA ZW")},ft={...Z([5],"IR"),...Z([0],"IN UG"),...Z([4,5],"AF"),...Z([5,6],"BH DZ EG IL IQ JO KW LY OM QA SA SD SY YE")},bt=new Set("AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL RE RU SE SJ SK SM VA".split(" ")),gt=["sun","mon","tue","wed","thu","fri","sat"];function Z(t,e){return Object.fromEntries(e.split(" ").map(n=>[n,t]))}function yt(t){try{let e=new Intl.Locale(t);return e.region??(typeof e.maximize=="function"?e.maximize().region:void 0)}catch{return/^[a-z]{2,3}[-_]([A-Z]{2})\b/i.exec(t)?.[1].toUpperCase()}}function Ze(t){let e=yt(t)??"001",n=ht[e]??1,r=/-u(?:-[a-z0-9]{2,8})*?-fw-([a-z]{3})\b/i.exec(t);if(r){let s=gt.indexOf(r[1].toLowerCase());s>=0&&(n=s)}return{firstDay:n,minimalDays:bt.has(e)?4:1,weekend:ft[e]??[6,0]}}var Ve=new Map;function V(t){try{return Intl.getCanonicalLocales(t)[0]??"en"}catch{throw new RangeError(`neram: invalid locale "${t}"`)}}function pt(t){return Ze(t)}function S(t){let e=Ve.get(t);if(e)return e;let n=w=>new Intl.DateTimeFormat(t,{...w,timeZone:"UTC"}),r=w=>{let M=n(w);return{format:L=>O(M.format(L)),formatToParts:L=>M.formatToParts(L).map(ie=>({...ie,value:O(ie.value)}))}},s=r({month:"long"}),i=r({month:"short"}),a=r({month:"long",day:"numeric"}),o=[],u=[];for(let w=0;w<12;w++){let M=Date.UTC(2021,w,15),L=a.formatToParts(M).find(ie=>ie.type==="month")?.value;o.push(L??s.format(M)),u.push(i.format(M).replace(/\.$/,""))}let m=r({weekday:"long"}),l=r({weekday:"short"}),c=r({weekday:"narrow"}),d=t.toLowerCase().startsWith("en"),g=[],h=[],f=[];for(let w=0;w<7;w++){let M=Date.UTC(2021,0,3+w);g.push(m.format(M));let L=l.format(M).replace(/\.$/,"");h.push(L),f.push(d?L.slice(0,2):c.format(M))}let b=r({hour:"numeric",hour12:!0}),D=w=>b.formatToParts(w).find(M=>M.type==="dayPeriod")?.value,J=[D(Date.UTC(2021,0,1,9))??"AM",D(Date.UTC(2021,0,1,15))??"PM"];return e={months:o,monthsShort:u,weekdays:g,weekdaysShort:h,weekdaysMin:f,meridiem:J,week:pt(t)},Ve.set(t,e),e}var je=new Map,Dt={one:"st",two:"nd",few:"rd",other:"th"};function fe(t,e){if(!e.toLowerCase().startsWith("en"))return`${t}.`;let n=je.get(e);return n||(n=new Intl.PluralRules(e,{type:"ordinal"}),je.set(e,n)),`${t}${Dt[n.select(t)]??"th"}`}var He=new Map;function we(t){let e=He.get(t);if(e)return e;let n=S(t),r=(a,o)=>u=>u===void 0?a.slice():a[o(u)],s=a=>a.month(),i=a=>a.day();return e=Object.freeze({name:t,firstDayOfWeek:()=>n.week.firstDay,months:r(n.months,s),monthsShort:r(n.monthsShort,s),weekdays:r(n.weekdays,i),weekdaysShort:r(n.weekdaysShort,i),weekdaysMin:r(n.weekdaysMin,i),meridiem:(a,o,u)=>{let m=n.meridiem[a<12?0:1];return u?m.toLocaleLowerCase(t):m},ordinal:a=>fe(a,t),week:()=>({...n.week,weekend:n.week.weekend.slice()})}),He.set(t,e),e}var wt=/\[([^\]]*)\]|LTS|LT|LLLL|LLL|LL|L|llll|lll|ll|l|YYYY|YY|GGGG|gggg|MMMM|MMM|MM|M|Qo|Q|DDDD|DDD|Do|DD|D|dddd|ddd|dd|d|E|HH|H|hh|h|kk|k|mm|m|ss|s|S{1,9}|A|a|ZZ|Z|X|x|WW|W|ww|w|zzz|z/g,y=(t,e=2)=>{let n=String(Math.abs(t)).padStart(e,"0");return t<0?`-${n}`:n},_e={LT:{timeStyle:"short"},LTS:{timeStyle:"medium"},L:{year:"numeric",month:"2-digit",day:"2-digit"},LL:{dateStyle:"long"},LLL:{dateStyle:"long",timeStyle:"short"},LLLL:{dateStyle:"full",timeStyle:"short"},l:{year:"numeric",month:"numeric",day:"numeric"},ll:{dateStyle:"medium"},lll:{dateStyle:"medium",timeStyle:"short"},llll:{weekday:"short",year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}};function Be(t,e){let{wall:n,locale:r}=t,s,i=()=>s??=S(r),a=()=>I(n.y,n.M,n.D,1,4),o=()=>I(n.y,n.M,n.D,t.weekStart,i().week.minimalDays),u=n.h%12||12,m=d=>{if(_e[d])return t.intl(_e[d]);switch(d){case"YYYY":return n.y>=0&&n.y<=9999?y(n.y,4):(n.y<0?"-":"+")+y(Math.abs(n.y),6);case"YY":return y((n.y%100+100)%100);case"GGGG":return y(a().year,4);case"gggg":return y(o().year,4);case"M":return String(n.M+1);case"MM":return y(n.M+1);case"MMM":return i().monthsShort[n.M];case"MMMM":return i().months[n.M];case"Q":return String(Math.floor(n.M/3)+1);case"Qo":return fe(Math.floor(n.M/3)+1,r);case"D":return String(n.D);case"DD":return y(n.D);case"Do":return fe(n.D,r);case"DDD":return String(G(n.y,n.M,n.D));case"DDDD":return y(G(n.y,n.M,n.D),3);case"d":return String(n.dow);case"E":return String(n.dow||7);case"dd":return i().weekdaysMin[n.dow];case"ddd":return i().weekdaysShort[n.dow];case"dddd":return i().weekdays[n.dow];case"H":return String(n.h);case"HH":return y(n.h);case"h":return String(u);case"hh":return y(u);case"k":return String(n.h||24);case"kk":return y(n.h||24);case"m":return String(n.m);case"mm":return y(n.m);case"s":return String(n.s);case"ss":return y(n.s);case"A":return i().meridiem[n.h<12?0:1];case"a":return i().meridiem[n.h<12?0:1].toLowerCase();case"Z":return W(t.offset);case"ZZ":return W(t.offset,"");case"X":return String(Math.floor(t.ms/1e3));case"x":return String(t.ms);case"W":return String(a().week);case"WW":return y(a().week);case"w":return String(o().week);case"ww":return y(o().week);case"z":return t.intl({timeZoneName:"short"}).split(/,?\s/).pop()??"";case"zzz":return Nt(t);default:return y(n.ms,3).padEnd(d.length,"0").slice(0,d.length)}},l=Mt(e),c=l[0];for(let d=1;d<l.length;d+=2)c+=m(l[d])+l[d+1];return c}var be=new Map;function Mt(t){let e=be.get(t);if(e)return e;e=[];let n="",r=0;for(let s of t.matchAll(wt))n+=t.slice(r,s.index),r=s.index+s[0].length,s[1]!==void 0?n+=s[1]:(e.push(n,s[0]),n="");return e.push(n+t.slice(r)),be.size>500&&be.clear(),be.set(t,e),e}function Nt(t){let e=t.intl({year:"numeric",timeZoneName:"long"}),n=t.intl({year:"numeric"});return e.replace(n,"").replace(/^[\s,]+|[\s,]+$/g,"")}var $={kind:"epoch",ms:NaN},kt=/^([+-]\d{6}|\d{4})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[T\s](\d{2})(?::?(\d{2})(?::?(\d{2})(?:[.,](\d{1,9}))?)?)?)?\s*(Z|[+-]\d{2}(?::?\d{2})?)?(?:\[!?([^\]=]+)\])?(?:\[[^\]]*\])*$/i;function Me(t){return t.M>=0&&t.M<=11&&t.D>=1&&t.D<=C(t.y,t.M)&&t.h>=0&&(t.h<24||t.h===24&&t.m===0&&t.s===0&&t.ms===0)&&t.m>=0&&t.m<60&&t.s>=0&&t.s<61&&t.ms>=0&&t.ms<1e3}function x(t,e){let n=t.charCodeAt(e)-48,r=t.charCodeAt(e+1)-48;return n>=0&&n<=9&&r>=0&&r<=9?n*10+r:-1}function St(t){let e=t.length;if(e<10||t.charCodeAt(4)!==45||t.charCodeAt(7)!==45)return;let n=x(t,0),r=x(t,2),s=x(t,5),i=x(t,8);if(n<0||r<0||s<0||i<0)return;let a=0,o=0,u=0,m=0,l,c=10;if(c<e){let g=t.charCodeAt(c);if(g!==84&&g!==116&&g!==32||e<16||t.charCodeAt(13)!==58||(a=x(t,11),o=x(t,14),a<0||o<0))return;if(c=16,t.charCodeAt(c)===58){if(u=x(t,17),u<0)return;if(c=19,t.charCodeAt(c)===46){let h=c+1,f=0,b=0;for(;h<e;h++){let D=t.charCodeAt(h)-48;if(D<0||D>9)break;b<3&&(f=f*10+D),b++}if(b===0||b>9)return;m=b===1?f*100:b===2?f*10:f,c=h}}if(c<e){let h=t.charCodeAt(c);if((h===90||h===122)&&c===e-1)l=0,c++;else if((h===43||h===45)&&e-c===6&&t.charCodeAt(c+3)===58){let f=x(t,c+1),b=x(t,c+4);if(f<0||b<0)return;if(f>23||b>59)return $;l=(h===45?-1:1)*(f*60+b),c=e}else return}}let d={y:n*100+r,M:s-1,D:i,h:a,m:o,s:u,ms:m};return Me(d)?(d.s===60&&(d.s=59),{kind:"wall",wall:d,offset:l}):$}function It(t){let e=St(t);if(e)return e;let n=kt.exec(t.trim());if(!n)return;let r={y:Number(n[1]),M:n[2]?Number(n[2])-1:0,D:n[3]?Number(n[3]):1,h:n[4]?Number(n[4]):0,m:n[5]?Number(n[5]):0,s:n[6]?Number(n[6]):0,ms:n[7]?Math.floor(+`0.${n[7]}`*1e3):0};if(!Me(r))return $;r.s===60&&(r.s=59);let s=n[8]?_(n[8].replace(/^([+-]\d{2})$/,"$1:00")):void 0;return n[8]&&s===void 0?$:{kind:"wall",wall:r,offset:s,zone:n[9]}}function Ke(t){let e=It(t);if(e)return e;let n=Date.parse(t);return Number.isNaN(n)?$:{kind:"epoch",ms:n}}var Ot=/\[([^\]]*)\]|YYYY|YY|MMMM|MMM|MM|M|Do|DD|D|dddd|ddd|dd|HH|H|hh|h|kk|k|mm|m|ss|s|S{1,3}|A|a|ZZ|Z|X|x/g;function K(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ge(t){return`(${[...t].sort((e,n)=>n.length-e.length).map(K).join("|")})`}var j=t=>(e,n)=>{n[t]=Number(e)};function Je(t,e,n){let r=S(n),s=[],i="",a=0;for(let d of e.matchAll(Ot)){i+=K(e.slice(a,d.index)).replace(/\s+/g,"\\s+"),a=d.index+d[0].length;let g=d[0];if(d[1]!==void 0){i+=K(d[1]);continue}switch(g){case"YYYY":i+="([+-]?\\d{4,6})",s.push(j("y"));break;case"YY":i+="(\\d{2})",s.push((h,f)=>{let b=Number(h);f.y=b+(b>68?1900:2e3)});break;case"MMMM":case"MMM":{i+=Ge([...r.months,...r.monthsShort]),s.push((h,f)=>{let b=h.toLowerCase(),D=r.months.findIndex(J=>J.toLowerCase()===b);D<0&&(D=r.monthsShort.findIndex(J=>J.toLowerCase()===b)),f.M=D+1});break}case"MM":case"M":i+=g==="MM"?"(\\d{2})":"(\\d{1,2})",s.push(j("M"));break;case"Do":i+="(\\d{1,2})(?:st|nd|rd|th|\\.)?",s.push(j("D"));break;case"DD":case"D":i+=g==="DD"?"(\\d{2})":"(\\d{1,2})",s.push(j("D"));break;case"dddd":case"ddd":case"dd":i+=Ge([...r.weekdays,...r.weekdaysShort,...r.weekdaysMin]),s.push(()=>{});break;case"HH":case"H":case"hh":case"h":case"kk":case"k":i+=g.length===2?"(\\d{2})":"(\\d{1,2})",s.push(g[0]==="k"?(h,f)=>{f.h=Number(h)%24}:j("h"));break;case"mm":case"m":i+=g==="mm"?"(\\d{2})":"(\\d{1,2})",s.push(j("m"));break;case"ss":case"s":i+=g==="ss"?"(\\d{2})":"(\\d{1,2})",s.push(j("s"));break;case"A":case"a":i+=`(${K(r.meridiem[0])}|${K(r.meridiem[1])}|am|pm|a\\.m\\.|p\\.m\\.)`,s.push((h,f)=>{let b=h.toLowerCase();f.pm=b===r.meridiem[1].toLowerCase()||b.startsWith("p")});break;case"ZZ":case"Z":i+="(Z|[+-]\\d{2}:?\\d{2})",s.push((h,f)=>{f.offset=_(h)??NaN});break;case"X":i+="(-?\\d+(?:\\.\\d+)?)",s.push((h,f)=>{f.epoch=Number(h)*1e3});break;case"x":i+="(-?\\d+)",s.push((h,f)=>{f.epoch=Number(h)});break;default:i+=`(\\d{1,${g.length}})`,s.push((h,f)=>{f.ms=Math.round(+`0.${h}`*1e3)})}}i+=K(e.slice(a)).replace(/\s+/g,"\\s+");let o=new RegExp(`^\\s*${i}\\s*$`,"i").exec(t);if(!o)return $;let u={};if(s.forEach((d,g)=>d(o[g+1],u)),u.epoch!==void 0)return{kind:"epoch",ms:u.epoch};let m=u.h??0;if(u.pm!==void 0){if(m<1||m>12)return $;u.pm&&m<12&&(m+=12),!u.pm&&m===12&&(m=0)}let l=new Date,c={y:u.y??l.getFullYear(),M:u.M!==void 0?u.M-1:u.y!==void 0?0:l.getMonth(),D:u.D??1,h:m,m:u.m??0,s:u.s??0,ms:u.ms??0};return Me(c)?{kind:"wall",wall:c,offset:u.offset}:$}var p={locale:"en",zone:"local",normalizeSpaces:!0},qe=new Map,Y=class t{#e;#t;#n;#l;#d;#b;constructor(e,n,r,s){this.#e=Number.isFinite(e)&&Math.abs(e)<=864e13?e:NaN,this.#t=n,this.#n=r,this.#l=s}#r(e,n=this.#t,r=this.#n,s=this.#l){return new t(e,n,r,s)}#u(){return this.#b??=this.isValid()?R(this.#e,this.#t):NaN}#s(){return this.#d||(this.#d=this.isValid()?xe(this.#e,this.#u()):{y:NaN,M:NaN,D:NaN,h:NaN,m:NaN,s:NaN,ms:NaN,dow:NaN}),this.#d}#i(e){return this.#r(B(e,this.#t))}#m(){return this.#l??p.weekStart??S(this.#n).week.firstDay}#c(e){let n=this.#s(),r=n.y*12+n.M+Xe(e),s=Math.floor(r/12),i=r-s*12;return this.#i({...n,y:s,M:i,D:Math.min(n.D,C(s,i))})}#o(e){let n=this.#s();return this.#i({...n,D:n.D+Xe(e)})}#f(e,n=this.#n){if(!this.isValid())return"Invalid Date";let r=ve(this.#t),s=this.#t==="local"?void 0:r?"UTC":this.#t,i=`${n}|${s}|${JSON.stringify(e)}`,a=qe.get(i);a||(a=new Intl.DateTimeFormat(n,{...e,timeZone:s}),qe.set(i,a));let o=O(a.format(r?this.#e+this.#u()*6e4:this.#e));return r&&e.timeZoneName?o.replace(/UTC|GMT/,`GMT${W(this.#u())}`):o}isValid(){return!Number.isNaN(this.#e)}clone(){return this}get(e){let n=this.#s();switch(N(e)){case"year":return n.y;case"quarter":return Math.floor(n.M/3)+1;case"month":return n.M;case"week":return this.week();case"isoWeek":return this.isoWeek();case"date":return n.D;case"day":return n.dow;case"hour":return n.h;case"minute":return n.m;case"second":return n.s;default:return n.ms}}set(e,n){if(!this.isValid())return this;if(typeof e=="object"){let i=this,a=["year","month","date","day","hour","minute","second","millisecond"];for(let o of a){let u=e[o];u!==void 0&&(i=i.set(o,u))}return i}let r=n,s={...this.#s()};switch(N(e)){case"year":return this.#i({...s,y:r,D:Math.min(s.D,C(r,s.M))});case"quarter":return this.#c((r-(Math.floor(s.M/3)+1))*3);case"month":{let i=s.y+Math.floor(r/12),a=(r%12+12)%12;return this.#i({...s,y:i,M:a,D:Math.min(s.D,C(i,a))})}case"week":return this.#o((r-this.week())*7);case"isoWeek":return this.#o((r-this.isoWeek())*7);case"date":return this.#i({...s,D:r});case"day":return this.#o(r-s.dow);case"hour":return this.#i({...s,h:r});case"minute":return this.#i({...s,m:r});case"second":return this.#i({...s,s:r});default:return this.#i({...s,ms:r})}}year(e){return e===void 0?this.get("year"):this.set("year",e)}month(e){return e===void 0?this.get("month"):this.set("month",e)}date(e){return e===void 0?this.get("date"):this.set("date",e)}day(e){return e===void 0?this.get("day"):this.set("day",e)}hour(e){return e===void 0?this.get("hour"):this.set("hour",e)}minute(e){return e===void 0?this.get("minute"):this.set("minute",e)}second(e){return e===void 0?this.get("second"):this.set("second",e)}millisecond(e){return e===void 0?this.get("millisecond"):this.set("millisecond",e)}quarter(e){return e===void 0?this.get("quarter"):this.set("quarter",e)}dayOfYear(e){let n=this.#s(),r=G(n.y,n.M,n.D);return e===void 0?r:this.#o(e-r)}isoWeekday(e){let n=this.#s().dow||7;return e===void 0?n:this.#o(e-n)}weekday(e){let n=(this.#s().dow-this.#m()+7)%7;return e===void 0?n:this.#o(e-n)}week(){let e=this.#s();return I(e.y,e.M,e.D,this.#m(),S(this.#n).week.minimalDays).week}weekYear(){let e=this.#s();return I(e.y,e.M,e.D,this.#m(),S(this.#n).week.minimalDays).year}isoWeek(){let e=this.#s();return I(e.y,e.M,e.D,1,4).week}isoWeekYear(){let e=this.#s();return I(e.y,e.M,e.D,1,4).year}isoWeeksInYear(){return Le(this.year(),1,4)}daysInMonth(){let e=this.#s();return C(e.y,e.M)}isLeapYear(){return ue(this.year())}add(e,n){if(!this.isValid())return this;if(typeof e!="number"){let s=ne(e)?e:z(e);if(!s.isValid())return this.#r(NaN);let i=s.toObject(),a=this;(i.years||i.months)&&(a=a.#c(i.years*12+i.months)),(i.weeks||i.days)&&(a=a.#o(i.weeks*7+i.days));let o=i.hours*36e5+i.minutes*6e4+i.seconds*1e3+i.milliseconds;return o?a.#r(a.#e+o):a}let r=N(n??"millisecond");switch(r){case"year":return this.#c(e*12);case"quarter":return this.#c(e*3);case"month":return this.#c(e);case"week":case"isoWeek":return this.#o(e*7);case"day":case"date":return this.#o(e);default:return this.#r(this.#e+e*(ce[r]??1))}}subtract(e,n){return typeof e=="number"?this.add(-e,n):this.add((ne(e)?e:z(e)).negate())}startOf(e){if(!this.isValid())return this;let n=N(e),r={...this.#s()},s={h:0,m:0,s:0,ms:0};switch(n){case"year":return this.#i({...r,...s,M:0,D:1});case"quarter":return this.#i({...r,...s,M:Math.floor(r.M/3)*3,D:1});case"month":return this.#i({...r,...s,D:1});case"week":return this.#i({...r,...s,D:r.D-(r.dow-this.#m()+7)%7});case"isoWeek":return this.#i({...r,...s,D:r.D-(r.dow+6)%7});case"day":case"date":return this.#i({...r,...s});case"hour":return this.#r(this.#e-(r.m*6e4+r.s*1e3+r.ms));case"minute":return this.#r(this.#e-(r.s*1e3+r.ms));case"second":return this.#r(this.#e-r.ms);default:return this}}endOf(e){let n=N(e);return n==="millisecond"?this:this.startOf(n).add(1,n==="date"?"day":n).subtract(1,"millisecond")}round(e){if(!this.isValid())return this;let n=N(e),r=this.startOf(n),s=r.add(1,n==="date"?"day":n);return this.#e-r.#e<s.#e-this.#e?r:s}clamp(e,n){let r=this.#a(e),s=this.#a(n);return this.#e<r.#e?r.tz(this.#t):this.#e>s.#e?s.tz(this.#t):this}tz(e,n=!1){let r=F(e);return this.isValid()?n?this.#r(B(this.#s(),r),r):this.#r(this.#e,r):this.#r(NaN,r)}utc(e=!1){return this.tz("UTC",e)}local(e=!1){return this.tz("local",e)}timezone(){return this.#t==="local"?q():this.#t}isUTC(){return this.#t==="UTC"}isLocal(){return this.#t==="local"}utcOffset(e,n=!1){if(e===void 0)return this.#u();let r;if(typeof e=="string"){r=F(e)==="UTC"?0:Number.NaN;let s=/^([+-])(\d{2}):?(\d{2})$/.exec(e);s&&(r=(s[1]==="-"?-1:1)*(Number(s[2])*60+Number(s[3])))}else r=Math.abs(e)<16?e*60:e;if(Number.isNaN(r))throw new RangeError(`neram: invalid offset "${e}"`);return this.tz(r===0?"UTC":W(r),n)}isDST(){if(!this.isValid())return!1;let e=this.year(),n=R(Date.UTC(e,0,1),this.#t),r=R(Date.UTC(e,6,1),this.#t);return n!==r&&this.#u()===Math.max(n,r)}localeData(){return we(this.#n)}locale(e){return e===void 0?this.#n:this.#r(this.#e,this.#t,V(e))}weekStart(e){return e===void 0?this.#m():this.#r(this.#e,this.#t,this.#n,e)}format(e="YYYY-MM-DDTHH:mm:ssZ"){return this.isValid()?Be({wall:this.#s(),ms:this.#e,offset:this.#u(),locale:this.#n,weekStart:this.#m(),intl:n=>this.#f(n)},e):"Invalid Date"}toLocaleString(e={dateStyle:"medium",timeStyle:"medium"},n){return this.#f(e,n?V(n):this.#n)}from(e,n={}){if(!this.isValid())return"Invalid Date";let r=this.#a(e);if(!r.isValid())return"Invalid Date";let s=this.#e-r.#e,{value:i,unit:a}=le(s,this.diff(r,"month",!0));return te(i,a,n.locale??this.#n,n)}fromNow(e={}){return this.from(this.#r(Date.now()),e)}to(e,n={}){return this.isValid()?this.#a(e).locale(this.#n).from(this,n):"Invalid Date"}toNow(e={}){return this.to(this.#r(Date.now()),e)}calendar(e,n={}){if(!this.isValid())return"Invalid Date";let r=(e===void 0?this.#r(Date.now()):this.#a(e)).tz(this.#t),s=this.startOf("day").diff(r.startOf("day"),"day"),i=this.#n.toLowerCase().startsWith("en"),a=i?" at ":" ",o=this.format("LT"),u=l=>l.charAt(0).toLocaleUpperCase(this.#n)+l.slice(1);if(Math.abs(s)<=1)return u(te(s,"day",this.#n))+a+o;let m=S(this.#n).weekdays[this.day()];return s>1&&s<7?u(m)+a+o:s<-1&&s>-7?(i?`Last ${m}`:u(m))+a+o:this.format(n.sameElse??"L")}#a(e){return e instanceof t?e:se(e,{zone:this.#t,locale:this.#n})}diff(e,n="millisecond",r=!1){let s=this.#a(e);if(!this.isValid()||!s.isValid())return NaN;let i=N(n),a=this.#e+this.#u()*6e4-(s.#e+s.#u()*6e4),o;switch(i){case"year":o=re(this,s)/12;break;case"quarter":o=re(this,s)/3;break;case"month":o=re(this,s);break;case"week":case"isoWeek":o=a/X;break;case"day":case"date":o=a/k;break;default:o=(this.#e-s.#e)/(ce[i]??1)}return r?o:Math.trunc(o)||0}durationTo(e){let n=this.#a(e);if(!this.isValid()||!n.isValid())return z(NaN);let r=n.#e<this.#e?-1:1,[s,i]=r>0?[this,n]:[n,this],a=Math.trunc(re(i,s));s=s.add(a,"month");let o=Math.trunc(i.diff(s,"day"));s=s.add(o,"day");let u=i.#e-s.#e;return z({months:r*a,days:r*o,milliseconds:r*u}).normalize()}isBefore(e,n){let r=this.#a(e);return n?this.endOf(n).#e<r.#e:this.#e<r.#e}isAfter(e,n){let r=this.#a(e);return n?this.startOf(n).#e>r.#e:this.#e>r.#e}isSame(e,n){let r=this.#a(e);return n?this.startOf(n).#e<=r.#e&&r.#e<=this.endOf(n).#e:this.#e===r.#e}isSameOrBefore(e,n){return this.isSame(e,n)||this.isBefore(e,n)}isSameOrAfter(e,n){return this.isSame(e,n)||this.isAfter(e,n)}isBetween(e,n,r,s="()"){let[i,a]=[this.#a(e),this.#a(n)].sort((m,l)=>m.#e-l.#e),o=s[0]==="["?this.isSameOrAfter(i,r):this.isAfter(i,r),u=s[1]==="]"?this.isSameOrBefore(a,r):this.isBefore(a,r);return o&&u}isToday(){return this.isSame(this.#r(Date.now()),"day")}isTomorrow(){return this.isSame(this.#r(Date.now()).add(1,"day"),"day")}isYesterday(){return this.isSame(this.#r(Date.now()).subtract(1,"day"),"day")}isPast(){return this.#e<Date.now()}isFuture(){return this.#e>Date.now()}isWeekend(e){return(e===void 0?S(this.#n).week.weekend:Ne(e)).includes(this.day())}isBusinessDay(e={}){return this.isWeekend(e.weekend)?!1:e.holidays?.length?!this.#h(e).has(this.format("YYYY-MM-DD")):!0}addBusinessDays(e,n={}){if(!Number.isInteger(e))throw new RangeError(`neram: business days must be a whole number, got ${e}`);n.weekend!==void 0&&Ne(n.weekend);let r=this.#h(n);if(!this.isValid())return this;let s=e<0?-1:1,i=Math.abs(e),a=this;for(;i>0;)a=a.#o(s),!a.isWeekend(n.weekend)&&!r.has(a.format("YYYY-MM-DD"))&&i--;return a}subtractBusinessDays(e,n={}){return this.addBusinessDays(-e,n)}businessDaysUntil(e,n={}){n.weekend!==void 0&&Ne(n.weekend);let r=this.#a(e);if(!this.isValid()||!r.isValid())return NaN;let s=r.tz(this.#t).startOf("day"),i=this.startOf("day"),a=s.#e<i.#e?-1:1,o=this.#h(n),u=0;for(;a>0?i.#e<s.#e:i.#e>s.#e;)i=i.#o(a),!i.isWeekend(n.weekend)&&!o.has(i.format("YYYY-MM-DD"))&&(u+=a);return u}#h(e){return new Set((e.holidays??[]).map(n=>{let r=this.#a(n);if(!r.isValid())throw new RangeError(`neram: invalid holiday ${JSON.stringify(n)}`);return r.tz(this.#t).format("YYYY-MM-DD")}))}valueOf(){return this.#e}unix(){return Math.floor(this.#e/1e3)}toDate(){return new Date(this.#e)}toISOString(){return new Date(this.#e).toISOString()}toZonedISOString(){if(!this.isValid())return"Invalid Date";let e=this.#s().ms?".SSS":"";return`${this.format(`YYYY-MM-DDTHH:mm:ss${e}Z`)}[${this.timezone()}]`}toTemporal(){let e=globalThis.Temporal;if(!e)throw new Error("neram: Temporal is not available in this runtime");return e.ZonedDateTime.from(this.toZonedISOString())}toJSON(){return this.isValid()?this.toISOString():null}toString(){return this.isValid()?new Date(this.#e).toUTCString():"Invalid Date"}toObject(){let e=this.#s();return{year:e.y,month:e.M,date:e.D,hour:e.h,minute:e.m,second:e.s,millisecond:e.ms}}toArray(){let e=this.#s();return[e.y,e.M,e.D,e.h,e.m,e.s,e.ms]}[Symbol.toPrimitive](e){return e==="number"?this.#e:this.toString()}get[Symbol.toStringTag](){return"Neram"}};function re(t,e){if(t.date()<e.date())return-re(e,t);let n=(e.year()-t.year())*12+(e.month()-t.month()),r=t.add(n,"month").valueOf(),s=e.valueOf()-r<0,i=t.add(n+(s?-1:1),"month").valueOf();return-(n+(e.valueOf()-r)/(s?r-i:i-r))||0}function Qe(t,e,n){if(t.kind==="epoch")return{ms:t.ms,zone:e};let r=e;return t.zone&&!n&&(r=F(t.zone)),t.offset!==void 0?{ms:ye(t.wall)-t.offset*6e4,zone:r}:{ms:B(t.wall,r),zone:r}}function Tt(t){return typeof t=="object"&&t!==null&&typeof t.epochMilliseconds=="number"}function A(t,e,n,r){let s={};typeof e=="string"||Array.isArray(e)?s.format=e:e&&(s={...e}),typeof n=="boolean"?s.strict=n:typeof n=="string"&&(s.locale=n),typeof r=="boolean"&&(s.strict=r);let i=s.locale?V(s.locale):p.locale,a=s.utc===!0||s.zone!==void 0,o=F(s.utc?"UTC":s.zone??p.zone),u=s.weekStart;if(t instanceof Y){let l=t;return a&&(l=l.tz(o)),s.locale&&(l=l.locale(i)),u!==void 0&&(l=l.weekStart(u)),l}let m;if(t===void 0)m=Date.now();else if(t===null)m=NaN;else if(t instanceof Date)m=t.getTime();else if(typeof t=="number")m=t;else if(typeof t=="string"){let l=s.format===void 0?void 0:Array.isArray(s.format)?s.format:[s.format];if(!l)({ms:m,zone:o}=Qe(Ke(t),o,a));else{m=NaN;for(let c of l){let d=Qe(Je(t,c,i),o,a);if(!Number.isNaN(d.ms)&&!(s.strict&&new Y(d.ms,d.zone,i,u).format(c)!==t.trim())){({ms:m,zone:o}=d);break}}}}else if(Array.isArray(t)){let[l=new Date().getFullYear(),c=0,d=1,g=0,h=0,f=0,b=0]=t,D={y:l,M:c,D:d,h:g,m:h,s:f,ms:b};m=t.length>=1&&t.length<=7&&et(D)?B(D,o):NaN}else if(Tt(t))m=t.epochMilliseconds,t.timeZoneId&&!a&&(o=F(t.timeZoneId));else if(typeof t=="object"){let l=Ut(t),c=l&&{y:l.year??new Date().getFullYear(),M:l.month??0,D:l.date??1,h:l.hour??0,m:l.minute??0,s:l.second??0,ms:l.millisecond??0};m=c&&et(c)?B(c,o):NaN}else m=NaN;return new Y(m,o,i,u)}function Xe(t){return t<0?-Math.round(-t):Math.round(t)}function Ne(t){if(!Array.isArray(t)||t.some(e=>!Number.isInteger(e)||e<0||e>6))throw new RangeError(`neram: weekend must list weekday numbers 0-6 (0 = Sunday), got ${JSON.stringify(t)}`);if(new Set(t).size===7)throw new RangeError("neram: weekend cannot include every day of the week");return t}var vt={year:"year",years:"year",y:"year",month:"month",months:"month",M:"month",date:"date",dates:"date",D:"date",d:"date",day:"date",days:"date",hour:"hour",hours:"hour",h:"hour",minute:"minute",minutes:"minute",m:"minute",second:"second",seconds:"second",s:"second",millisecond:"millisecond",milliseconds:"millisecond",ms:"millisecond"};function Ut(t){let e={},n=!1;for(let[r,s]of Object.entries(t)){if(s===void 0)continue;let i=vt[r];if(!i||typeof s!="number"||e[i]!==void 0)return;e[i]=s,n=!0}return n?e:void 0}function et(t){return[t.y,t.M,t.D,t.h,t.m,t.s,t.ms].every(Number.isInteger)?t.M>=0&&t.M<=11&&t.D>=1&&t.D<=C(t.y,t.M)&&t.h>=0&&t.h<=23&&t.m>=0&&t.m<=59&&t.s>=0&&t.s<=59&&t.ms>=0&&t.ms<=999:!1}var tt=new Set;function nt(t){return(t.length===1&&Array.isArray(t[0])&&typeof t[0][0]!="number"?t[0]:t).map(e=>A(e)).filter(e=>e.isValid())}var se=Object.assign(A,{utc(t,e,n){return A(t,{format:e,strict:n,utc:!0})},tz(t,e,n){return A(t,{format:n,zone:e})},unix(t){return A(t*1e3)},now(){return A()},duration:z,isDuration:ne,Duration:P,Neram:Y,isNeram(t){return t instanceof Y},min(...t){let e=nt(t);return e.length?e.reduce((n,r)=>r.valueOf()<n.valueOf()?r:n):null},max(...t){let e=nt(t);return e.length?e.reduce((n,r)=>r.valueOf()>n.valueOf()?r:n):null},sort(t){return t.map(e=>A(e)).sort((e,n)=>e.valueOf()-n.valueOf())},range(t,e,n={}){let r=N(n.unit??"day"),s=n.step??1;if(typeof s!="number"||!Number.isFinite(s)||s<=0)throw new RangeError(`neram: range step must be a positive number, got ${String(s)}`);if(!(r in ce)&&!Number.isInteger(s))throw new RangeError(`neram: range step must be a whole number of ${r}s, got ${s}`);let i=n.limit??1e5;if(!Number.isInteger(i)||i<0)throw new RangeError(`neram: range limit must be a whole number, got ${i}`);let a=A(t),o=A(e);if(!a.isValid()||!o.isValid())return[];let u=s*(o.valueOf()<a.valueOf()?-1:1),m=[];for(let l=0;;l++){let c=a.add(u*l,r);if((u>0?c.valueOf()>o.valueOf():c.valueOf()<o.valueOf())||n.exclusive&&c.valueOf()===o.valueOf())break;if(m.length===i)throw new RangeError(`neram: range has more than ${i} dates; use a larger step or pass { limit }`);m.push(c)}return m},locale(t){return t!==void 0&&(p.locale=V(t)),p.locale},localeData(t){return we(t?V(t):p.locale)},environment(){let t=globalThis.process?.versions??{},e=Intl,n=!0;try{new Intl.NumberFormat("en",{style:"unit",unit:"hour"})}catch{n=!1}return{zone:q(),defaultZone:p.zone==="local"?q():p.zone,locale:p.locale,runtimeLocale:new Intl.DateTimeFormat().resolvedOptions().locale,icu:t.icu,cldr:t.cldr,tzdata:t.tz,features:{relativeTimeFormat:typeof e.RelativeTimeFormat=="function",listFormat:typeof e.ListFormat=="function",durationFormat:typeof e.DurationFormat=="function",supportedValuesOf:typeof e.supportedValuesOf=="function",unitFormat:n}}},guess(){return q()},zones(){let t=Intl.supportedValuesOf;return t?t("timeZone"):[]},config(t={}){return t.locale!==void 0&&(p.locale=V(t.locale)),t.zone!==void 0&&(p.zone=F(t.zone)),"weekStart"in t&&(p.weekStart=t.weekStart),t.normalizeSpaces!==void 0&&(pe.normalizeSpaces=p.normalizeSpaces=t.normalizeSpaces),{...p}},extend(t,e){return tt.has(t)||(t(e,Y,se),tt.add(t)),se}});export{P as Duration,Y as Neram,se as default,z as duration,ne as isDuration,se as neram};
@@ -0,0 +1,3 @@
1
+ /*! neramjs v0.1.0 | MIT | github.com/varksh05/neramjs */
2
+ "use strict";(()=>{var Ut=Object.defineProperty;var $t=(r,e)=>{for(var t in e)Ut(r,t,{get:e[t],enumerable:!0})};function M(r,e,t,n=0,s=0,i=0,a=0){if(r>=100)return Date.UTC(r,e,t,n,s,i,a);let u=new Date(0);return u.setUTCFullYear(r,e,t),u.setUTCHours(n,s,i,a),u.getTime()}function We(r){return M(r.y,r.M,r.D,r.h,r.m,r.s,r.ms)}var Xe=/^([+-])(\d{2}):?(\d{2})$/;function se(r){if(r==="Z"||r==="z")return 0;let e=Xe.exec(r)??/^([+-])(\d{2})$/.exec(r);if(!e)return;let t=Number(e[2]),n=Number(e[3]??0);if(t>23||n>59)return;let s=t*60+n;return e[1]==="-"?-s:s}function Q(r,e=":"){let t=r<0?"-":"+",n=Math.abs(r);return`${t}${String(Math.floor(n/60)).padStart(2,"0")}${e}${String(n%60).padStart(2,"0")}`}function Qe(r){return Xe.test(r)}var Ct={"Asia/Calcutta":"Asia/Kolkata","Asia/Saigon":"Asia/Ho_Chi_Minh","Asia/Katmandu":"Asia/Kathmandu","Asia/Rangoon":"Asia/Yangon","Europe/Kiev":"Europe/Kyiv","Atlantic/Faeroe":"Atlantic/Faroe","America/Godthab":"America/Nuuk","Pacific/Enderbury":"Pacific/Kanton","Pacific/Truk":"Pacific/Chuuk","Pacific/Ponape":"Pacific/Pohnpei","Africa/Asmera":"Africa/Asmara","America/Buenos_Aires":"America/Argentina/Buenos_Aires","America/Catamarca":"America/Argentina/Catamarca","America/Cordoba":"America/Argentina/Cordoba","America/Jujuy":"America/Argentina/Jujuy","America/Mendoza":"America/Argentina/Mendoza","America/Indianapolis":"America/Indiana/Indianapolis","America/Louisville":"America/Kentucky/Louisville"};function Wt(r){try{return new Intl.DateTimeFormat("en-US",{timeZone:r}),!0}catch{return!1}}function et(r){let e=Ct[r];return e&&Wt(e)?e:r}var Ge=new Map;function x(r){if(r==null||r==="local")return"local";if(typeof r!="string"||r.trim()==="")throw new RangeError(`neram: unknown time zone ${JSON.stringify(r)}`);let e=Ge.get(r);if(e)return e;let t,n=r.toUpperCase();if(n==="UTC"||n==="Z"||n==="GMT"||n==="ETC/UTC"||n==="ETC/GMT")t="UTC";else{let s=se(r);if(s!==void 0)t=s===0?"UTC":Q(s);else try{let i=new Intl.DateTimeFormat("en-US",{timeZone:r}).resolvedOptions().timeZone;t=et(i.toLowerCase()===r.toLowerCase()?i:r)}catch{throw new RangeError(`neram: unknown time zone "${r}"`)}}return Ge.set(r,t),t}var _e=new Map;function Lt(r){let e=_e.get(r);return e||(e=new Intl.DateTimeFormat("en-US",{timeZone:r,hourCycle:"h23",era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),_e.set(r,e)),e}function Me(r,e){let t=Lt(e).formatToParts(new Date(r)),n=0,s=0,i=0,a=0,u=0,o=0,l=!1;for(let d of t)switch(d.type){case"year":n=Number(d.value);break;case"month":s=Number(d.value)-1;break;case"day":i=Number(d.value);break;case"hour":a=Number(d.value)%24;break;case"minute":u=Number(d.value);break;case"second":o=Number(d.value);break;case"era":l=/^b/i.test(d.value);break}l&&(n=1-n);let m=r-(r%1e3+1e3)%1e3;return Math.round((M(n,s,i,a,u,o)-m)/6e4)}var ke=864e5,zt=5e4,Je=-1e9,Ke=new Map;function Ft(r,e){let t=Ke.get(e);t||(t=new Map,Ke.set(e,t));let n=Math.floor(r/ke),s=t.get(n);if(s!==void 0)return s===Je?Me(r,e):s;let i=Me(n*ke,e),a=Me(n*ke+ke-1e3,e);return t.size>=zt&&t.clear(),t.set(n,i===a?i:Je),i===a?i:Me(r,e)}var Ce=new Map;function G(r,e){if(e==="UTC")return 0;if(e==="local")return-new Date(r).getTimezoneOffset()||0;let t=Ce.get(e);return t===void 0&&!Ce.has(e)&&(t=se(e),Ce.set(e,t)),t!==void 0?t:Ft(r,e)}function C(r,e){if(e==="local"&&r.y>=100)return new Date(r.y,r.M,r.D,r.h,r.m,r.s,r.ms).getTime();let t=We(r);if(e==="UTC")return t;let n=se(e);if(n!==void 0)return t-n*6e4;let s=G(t-864e5,e),i=G(t+864e5,e),a=new Set([G(t,e),s,i]),u=[];for(let o of a)G(t-o*6e4,e)===o&&u.push(o);return u.length?t-Math.max(...u)*6e4:t-s*6e4}function ie(r){let e=Math.floor(r/864e5),t=r-e*864e5,n=Ne(e),s=Math.floor(t/36e5);t-=s*36e5;let i=Math.floor(t/6e4);t-=i*6e4;let a=Math.floor(t/1e3);return{y:n.y,M:n.M,D:n.D,h:s,m:i,s:a,ms:t-a*1e3,dow:n.dow}}function tt(r,e){return ie(r+e*6e4)}function ce(){return et(new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC")}function Se(r){return r%4===0&&r%100!==0||r%400===0}function Ne(r){let e=r+719468,t=Math.floor(e/146097),n=e-t*146097,s=Math.floor((n-Math.floor(n/1460)+Math.floor(n/36524)-Math.floor(n/146096))/365),i=n-(365*s+Math.floor(s/4)-Math.floor(s/100)),a=Math.floor((5*i+2)/153),u=i-Math.floor((153*a+2)/5)+1,o=a<10?a+2:a-10;return{y:s+t*400+(o<=1?1:0),M:o,D:u,dow:(r%7+7+4)%7}}var Pt=[31,28,31,30,31,30,31,31,30,31,30,31];function S(r,e){return e===1&&Se(r)?29:Pt[e]}function Oe(r){return Se(r)?366:365}function z(r,e,t){return Math.round((M(r,e,t)-M(r,0,1))/864e5)+1}function nt(r,e,t){return new Date(M(r,e,t)).getUTCDay()}function v(r,e,t,n,s){let i=z(r,e,t),a=(nt(r,e,t)-n+7)%7,u=i-a,o=(nt(r,0,1)-n+7)%7,l=7-o>=s?1-o:8-o;return u<l?v(r-1,11,31,n,s):u+6-Oe(r)>=s?{week:1,year:r+1}:{week:Math.floor((u-l)/7)+1,year:r}}function Ie(r,e,t){for(let n=31;n>24;n--){let s=v(r,11,n,e,t);if(s.year===r)return s.week}return 52}var Le={normalizeSpaces:!0},Ht=/[\u00a0\u2007\u2009\u202f]/g;function W(r){return Le.normalizeSpaces?r.replace(Ht," "):r}var Te=Intl,rt=new Map;function le(r,e="en",t="conjunction",n="long"){if(Te.ListFormat){let i=`${e}|${t}|${n}`,a=rt.get(i);return a||(a=new Te.ListFormat(e,{type:t,style:n}),rt.set(i,a)),W(a.format(r))}if(r.length<=1)return r.join("");if(t==="unit")return r.join(", ");let s=t==="disjunction"?"or":"and";return r.length===2?`${r[0]} ${s} ${r[1]}`:`${r.slice(0,-1).join(", ")}, ${s} ${r.at(-1)}`}var st=new Map;function de(r,e,t,n="long"){let s=`${t}|${e}|${n}`,i=st.get(s);if(i===void 0){try{i=new Intl.NumberFormat(t,{style:"unit",unit:e,unitDisplay:n})}catch{i=null}st.set(s,i)}return i?W(i.format(r)):`${r} ${e}${Math.abs(r)===1?"":"s"}`}var it=new Map;function at(r,e,t,n,s){if(Te.RelativeTimeFormat){let u=`${t}|${n}|${s}`,o=it.get(u);return o||(o=new Te.RelativeTimeFormat(t,{style:n,numeric:s}),it.set(u,o)),W(o.format(r,e))}if(s==="auto"){if(r===0)return e==="day"?"today":"now";if(e==="day"&&r===1)return"tomorrow";if(e==="day"&&r===-1)return"yesterday"}let i=Math.abs(r),a=`${i} ${e}${i===1?"":"s"}`;return r<0||Object.is(r,-0)?`${a} ago`:`in ${a}`}var ot={ms:"millisecond",s:"second",m:"minute",h:"hour",d:"day",D:"date",w:"week",W:"isoWeek",M:"month",Q:"quarter",y:"year"},ut=new Set(["millisecond","second","minute","hour","day","date","week","isoWeek","month","quarter","year"]);function Y(r){if(r==null)return;if(ot[r])return ot[r];if(ut.has(r))return r;let e=r.toLowerCase().replace(/s$/,"");if(e==="isoweek")return"isoWeek";if(ut.has(e))return e;throw new RangeError(`neram: unknown unit "${r}"`)}var F=1e3,P=60*F,H=60*P,E=24*H,fe=7*E,ze=365.2425*E,he=ze/12,Re={millisecond:1,second:F,minute:P,hour:H};function ve(r,e){let t=Math.abs(r),n=r<0?-1:1,s=a=>n*Math.round(a);if(t<45*F)return{value:s(t/F),unit:"second"};if(t<45*P)return{value:s(t/P),unit:"minute"};if(t<22*H)return{value:s(t/H),unit:"hour"};if(t<26*E)return{value:s(t/E),unit:"day"};let i=e!==void 0?Math.abs(e):t/he;return i<10.5?{value:s(Math.max(1,i)),unit:"month"}:{value:s(Math.max(1,i/12)),unit:"year"}}function ye(r,e,t,n={}){let s=n.style??"long";return n.withoutSuffix?de(Math.abs(r),e,t,s):at(r,e,t,s,n.numeric??"auto")}var _=["years","months","weeks","days","hours","minutes","seconds","milliseconds"],Ae="Invalid Duration",mt={years:ze,months:he,weeks:fe,days:E,hours:H,minutes:P,seconds:F,milliseconds:1},Zt=/^([+-])?P(?:(-?[\d.,]+)Y)?(?:(-?[\d.,]+)M)?(?:(-?[\d.,]+)W)?(?:(-?[\d.,]+)D)?(?:T(?:(-?[\d.,]+)H)?(?:(-?[\d.,]+)M)?(?:(-?[\d.,]+)S)?)?$/i;function xe(r){if(_.includes(r))return r;switch(Y(r)){case"year":return"years";case"quarter":throw new RangeError("neram: use months for quarter durations");case"month":return"months";case"week":case"isoWeek":return"weeks";case"day":case"date":return"days";case"hour":return"hours";case"minute":return"minutes";case"second":return"seconds";default:return"milliseconds"}}var Z=class r{#e;constructor(e,t="milliseconds"){let n={years:0,months:0,weeks:0,days:0,hours:0,minutes:0,seconds:0,milliseconds:0};if(e instanceof r)Object.assign(n,e.toObject());else if(typeof e=="number")n[xe(t)]=e;else if(typeof e=="string"){let s=Zt.exec(e.trim());if(!s||e.trim().toUpperCase()==="P"||/T$/i.test(e.trim()))throw new RangeError(`neram: invalid ISO 8601 duration "${e}"`);let i=s[1]==="-"?-1:1;_.forEach((u,o)=>{if(u==="milliseconds")return;let l=s[o+2];l&&(n[u]=i*Number(l.replace(",",".")))});let a=Math.trunc(n.seconds);n.milliseconds=Math.round((n.seconds-a)*1e3),n.seconds=a}else if(e)for(let[s,i]of Object.entries(e))i!=null&&(n[xe(s)]+=i);this.#e=n}isValid(){return _.every(e=>Number.isFinite(this.#e[e]))}get years(){return this.#e.years}get months(){return this.#e.months}get weeks(){return this.#e.weeks}get days(){return this.#e.days}get hours(){return this.#e.hours}get minutes(){return this.#e.minutes}get seconds(){return this.#e.seconds}get milliseconds(){return this.#e.milliseconds}get(e){return this.#e[xe(e)]}as(e){return this.valueOf()/mt[xe(e)]}asMilliseconds(){return this.as("milliseconds")}asSeconds(){return this.as("seconds")}asMinutes(){return this.as("minutes")}asHours(){return this.as("hours")}asDays(){return this.as("days")}asWeeks(){return this.as("weeks")}asMonths(){return this.as("months")}asYears(){return this.as("years")}valueOf(){if(!this.isValid())return NaN;let e=0;for(let t of _)e+=this.#e[t]*mt[t];return e}add(e,t){let n=e instanceof r?e:new r(e,t),s={};for(let i of _)s[i]=this.#e[i]+n.get(i);return new r(s)}subtract(e,t){let n=e instanceof r?e:new r(e,t);return this.add(n.negate())}negate(){let e={};for(let t of _)e[t]=-this.#e[t]||0;return new r(e)}abs(){return this.valueOf()<0?this.negate():this}sign(){let e=this.valueOf();return e===0?0:e<0?-1:1}isZero(){return _.every(e=>this.#e[e]===0)}normalize(){if(!this.isValid())return this;let e=this.#e,t=e.weeks*fe+e.days*E+e.hours*H+e.minutes*P+e.seconds*F+e.milliseconds,n=e.years*12+e.months,s=t<0?-1:1,i=Math.abs(t),a=c=>{let f=Math.floor(i/c);return i-=f*c,s*f||0},u=a(E),o=a(H),l=a(P),m=a(F),d=s*Math.round(i)||0;return new r({years:Math.trunc(n/12)||0,months:n%12||0,days:u,hours:o,minutes:l,seconds:m,milliseconds:d})}humanize(e=!1,t="en"){if(!this.isValid())return Ae;let n=typeof e=="object"?e:{withoutSuffix:!e},s=this.#e.years*12+this.#e.months,i=this.valueOf()-s*he,{value:a,unit:u}=ve(this.valueOf(),i===0&&s!==0?s:void 0);return ye(a,u,n.locale??t,{numeric:"always",...n})}toLocaleString(e="en",t="long"){if(!this.isValid())return Ae;let n=Intl.DurationFormat;if(n)return W(new n(e,{style:t}).format(this.toObject()));let s=t==="digital"?"narrow":t,i=_.filter(a=>this.#e[a]!==0).map(a=>de(this.#e[a],a.slice(0,-1),e,s));return i.length?le(i,e,"unit",s):de(0,"second",e,s)}format(e="HH:mm:ss"){if(!this.isValid())return Ae;let t=this.abs().normalize(),n=(i,a=2)=>String(i).padStart(a,"0"),s=e.replace(/\[([^\]]*)\]|YYYY|Y|MM|M|DD|D|HH|H|mm|m|ss|s|SSS/g,(i,a)=>{if(a!==void 0)return a;switch(i){case"Y":return String(t.years);case"YYYY":return n(t.years,4);case"M":return String(t.months);case"MM":return n(t.months);case"D":return String(t.days);case"DD":return n(t.days);case"H":return String(t.hours);case"HH":return n(t.hours);case"m":return String(t.minutes);case"mm":return n(t.minutes);case"s":return String(t.seconds);case"ss":return n(t.seconds);default:return n(t.milliseconds,3)}});return this.sign()<0?`-${s}`:s}toISOString(){if(!this.isValid())throw new RangeError("neram: invalid duration");let e={...this.#e};e.days+=e.weeks*7;let t=[e.years,e.months,e.days,e.hours,e.minutes,e.seconds+e.milliseconds/1e3],n=t.every(o=>o<=0)&&t.some(o=>o<0),s=n?-1:1,i=o=>String(Math.round(s*o*1e3)/1e3),a="";e.years&&(a+=`${i(e.years)}Y`),e.months&&(a+=`${i(e.months)}M`),e.days&&(a+=`${i(e.days)}D`);let u="";return e.hours&&(u+=`${i(e.hours)}H`),e.minutes&&(u+=`${i(e.minutes)}M`),(e.seconds||e.milliseconds)&&(u+=`${i(e.seconds+e.milliseconds/1e3)}S`),!a&&!u?"PT0S":`${n?"-":""}P${a}${u?`T${u}`:""}`}toJSON(){return this.isValid()?this.toISOString():null}toString(){return this.isValid()?this.toISOString():Ae}toObject(){return{...this.#e}}};function q(r,e){return new Z(r,e)}function be(r){return r instanceof Z}var qt={...ee(5,"MV"),...ee(6,"AF BH DJ DZ EG IQ IR JO KW LY OM QA SD SY"),...ee(0,"AG AS BD BR BS BT BW BZ CA CO DM DO ET GT GU HK HN ID IL IN IS JM JP KE KH KR LA MH MM MO MT MX MZ NI NP PA PE PH PK PR PT PY SA SG SV TH TT TW UM US VE VI WS YE ZA ZW")},Bt={...ee([5],"IR"),...ee([0],"IN UG"),...ee([4,5],"AF"),...ee([5,6],"BH DZ EG IL IQ JO KW LY OM QA SA SD SY YE")},jt=new Set("AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL RE RU SE SJ SK SM VA".split(" ")),Vt=["sun","mon","tue","wed","thu","fri","sat"];function ee(r,e){return Object.fromEntries(e.split(" ").map(t=>[t,r]))}function Gt(r){try{let e=new Intl.Locale(r);return e.region??(typeof e.maximize=="function"?e.maximize().region:void 0)}catch{return/^[a-z]{2,3}[-_]([A-Z]{2})\b/i.exec(r)?.[1].toUpperCase()}}function ct(r){let e=Gt(r)??"001",t=qt[e]??1,n=/-u(?:-[a-z0-9]{2,8})*?-fw-([a-z]{3})\b/i.exec(r);if(n){let s=Vt.indexOf(n[1].toLowerCase());s>=0&&(t=s)}return{firstDay:t,minimalDays:jt.has(e)?4:1,weekend:Bt[e]??[6,0]}}var lt=new Map;function te(r){try{return Intl.getCanonicalLocales(r)[0]??"en"}catch{throw new RangeError(`neram: invalid locale "${r}"`)}}function _t(r){return ct(r)}function I(r){let e=lt.get(r);if(e)return e;let t=w=>new Intl.DateTimeFormat(r,{...w,timeZone:"UTC"}),n=w=>{let k=t(w);return{format:T=>W(k.format(T)),formatToParts:T=>k.formatToParts(T).map(R=>({...R,value:W(R.value)}))}},s=n({month:"long"}),i=n({month:"short"}),a=n({month:"long",day:"numeric"}),u=[],o=[];for(let w=0;w<12;w++){let k=Date.UTC(2021,w,15),T=a.formatToParts(k).find(R=>R.type==="month")?.value;u.push(T??s.format(k)),o.push(i.format(k).replace(/\.$/,""))}let l=n({weekday:"long"}),m=n({weekday:"short"}),d=n({weekday:"narrow"}),c=r.toLowerCase().startsWith("en"),f=[],h=[],y=[];for(let w=0;w<7;w++){let k=Date.UTC(2021,0,3+w);f.push(l.format(k));let T=m.format(k).replace(/\.$/,"");h.push(T),y.push(c?T.slice(0,2):d.format(k))}let b=n({hour:"numeric",hour12:!0}),p=w=>b.formatToParts(w).find(k=>k.type==="dayPeriod")?.value,D=[p(Date.UTC(2021,0,1,9))??"AM",p(Date.UTC(2021,0,1,15))??"PM"];return e={months:u,monthsShort:o,weekdays:f,weekdaysShort:h,weekdaysMin:y,meridiem:D,week:_t(r)},lt.set(r,e),e}var dt=new Map,Jt={one:"st",two:"nd",few:"rd",other:"th"};function U(r,e){if(!e.toLowerCase().startsWith("en"))return`${r}.`;let t=dt.get(e);return t||(t=new Intl.PluralRules(e,{type:"ordinal"}),dt.set(e,t)),`${r}${Jt[t.select(r)]??"th"}`}var ft=new Map;function Fe(r){let e=ft.get(r);if(e)return e;let t=I(r),n=(a,u)=>o=>o===void 0?a.slice():a[u(o)],s=a=>a.month(),i=a=>a.day();return e=Object.freeze({name:r,firstDayOfWeek:()=>t.week.firstDay,months:n(t.months,s),monthsShort:n(t.monthsShort,s),weekdays:n(t.weekdays,i),weekdaysShort:n(t.weekdaysShort,i),weekdaysMin:n(t.weekdaysMin,i),meridiem:(a,u,o)=>{let l=t.meridiem[a<12?0:1];return o?l.toLocaleLowerCase(r):l},ordinal:a=>U(a,r),week:()=>({...t.week,weekend:t.week.weekend.slice()})}),ft.set(r,e),e}var Kt=/\[([^\]]*)\]|LTS|LT|LLLL|LLL|LL|L|llll|lll|ll|l|YYYY|YY|GGGG|gggg|MMMM|MMM|MM|M|Qo|Q|DDDD|DDD|Do|DD|D|dddd|ddd|dd|d|E|HH|H|hh|h|kk|k|mm|m|ss|s|S{1,9}|A|a|ZZ|Z|X|x|WW|W|ww|w|zzz|z/g,N=(r,e=2)=>{let t=String(Math.abs(r)).padStart(e,"0");return r<0?`-${t}`:t},ht={LT:{timeStyle:"short"},LTS:{timeStyle:"medium"},L:{year:"numeric",month:"2-digit",day:"2-digit"},LL:{dateStyle:"long"},LLL:{dateStyle:"long",timeStyle:"short"},LLLL:{dateStyle:"full",timeStyle:"short"},l:{year:"numeric",month:"numeric",day:"numeric"},ll:{dateStyle:"medium"},lll:{dateStyle:"medium",timeStyle:"short"},llll:{weekday:"short",year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}};function yt(r,e){let{wall:t,locale:n}=r,s,i=()=>s??=I(n),a=()=>v(t.y,t.M,t.D,1,4),u=()=>v(t.y,t.M,t.D,r.weekStart,i().week.minimalDays),o=t.h%12||12,l=c=>{if(ht[c])return r.intl(ht[c]);switch(c){case"YYYY":return t.y>=0&&t.y<=9999?N(t.y,4):(t.y<0?"-":"+")+N(Math.abs(t.y),6);case"YY":return N((t.y%100+100)%100);case"GGGG":return N(a().year,4);case"gggg":return N(u().year,4);case"M":return String(t.M+1);case"MM":return N(t.M+1);case"MMM":return i().monthsShort[t.M];case"MMMM":return i().months[t.M];case"Q":return String(Math.floor(t.M/3)+1);case"Qo":return U(Math.floor(t.M/3)+1,n);case"D":return String(t.D);case"DD":return N(t.D);case"Do":return U(t.D,n);case"DDD":return String(z(t.y,t.M,t.D));case"DDDD":return N(z(t.y,t.M,t.D),3);case"d":return String(t.dow);case"E":return String(t.dow||7);case"dd":return i().weekdaysMin[t.dow];case"ddd":return i().weekdaysShort[t.dow];case"dddd":return i().weekdays[t.dow];case"H":return String(t.h);case"HH":return N(t.h);case"h":return String(o);case"hh":return N(o);case"k":return String(t.h||24);case"kk":return N(t.h||24);case"m":return String(t.m);case"mm":return N(t.m);case"s":return String(t.s);case"ss":return N(t.s);case"A":return i().meridiem[t.h<12?0:1];case"a":return i().meridiem[t.h<12?0:1].toLowerCase();case"Z":return Q(r.offset);case"ZZ":return Q(r.offset,"");case"X":return String(Math.floor(r.ms/1e3));case"x":return String(r.ms);case"W":return String(a().week);case"WW":return N(a().week);case"w":return String(u().week);case"ww":return N(u().week);case"z":return r.intl({timeZoneName:"short"}).split(/,?\s/).pop()??"";case"zzz":return Qt(r);default:return N(t.ms,3).padEnd(c.length,"0").slice(0,c.length)}},m=Xt(e),d=m[0];for(let c=1;c<m.length;c+=2)d+=l(m[c])+m[c+1];return d}var Ye=new Map;function Xt(r){let e=Ye.get(r);if(e)return e;e=[];let t="",n=0;for(let s of r.matchAll(Kt))t+=r.slice(n,s.index),n=s.index+s[0].length,s[1]!==void 0?t+=s[1]:(e.push(t,s[0]),t="");return e.push(t+r.slice(n)),Ye.size>500&&Ye.clear(),Ye.set(r,e),e}function Qt(r){let e=r.intl({year:"numeric",timeZoneName:"long"}),t=r.intl({year:"numeric"});return e.replace(t,"").replace(/^[\s,]+|[\s,]+$/g,"")}var J={kind:"epoch",ms:NaN},en=/^([+-]\d{6}|\d{4})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[T\s](\d{2})(?::?(\d{2})(?::?(\d{2})(?:[.,](\d{1,9}))?)?)?)?\s*(Z|[+-]\d{2}(?::?\d{2})?)?(?:\[!?([^\]=]+)\])?(?:\[[^\]]*\])*$/i;function Pe(r){return r.M>=0&&r.M<=11&&r.D>=1&&r.D<=S(r.y,r.M)&&r.h>=0&&(r.h<24||r.h===24&&r.m===0&&r.s===0&&r.ms===0)&&r.m>=0&&r.m<60&&r.s>=0&&r.s<61&&r.ms>=0&&r.ms<1e3}function B(r,e){let t=r.charCodeAt(e)-48,n=r.charCodeAt(e+1)-48;return t>=0&&t<=9&&n>=0&&n<=9?t*10+n:-1}function tn(r){let e=r.length;if(e<10||r.charCodeAt(4)!==45||r.charCodeAt(7)!==45)return;let t=B(r,0),n=B(r,2),s=B(r,5),i=B(r,8);if(t<0||n<0||s<0||i<0)return;let a=0,u=0,o=0,l=0,m,d=10;if(d<e){let f=r.charCodeAt(d);if(f!==84&&f!==116&&f!==32||e<16||r.charCodeAt(13)!==58||(a=B(r,11),u=B(r,14),a<0||u<0))return;if(d=16,r.charCodeAt(d)===58){if(o=B(r,17),o<0)return;if(d=19,r.charCodeAt(d)===46){let h=d+1,y=0,b=0;for(;h<e;h++){let p=r.charCodeAt(h)-48;if(p<0||p>9)break;b<3&&(y=y*10+p),b++}if(b===0||b>9)return;l=b===1?y*100:b===2?y*10:y,d=h}}if(d<e){let h=r.charCodeAt(d);if((h===90||h===122)&&d===e-1)m=0,d++;else if((h===43||h===45)&&e-d===6&&r.charCodeAt(d+3)===58){let y=B(r,d+1),b=B(r,d+4);if(y<0||b<0)return;if(y>23||b>59)return J;m=(h===45?-1:1)*(y*60+b),d=e}else return}}let c={y:t*100+n,M:s-1,D:i,h:a,m:u,s:o,ms:l};return Pe(c)?(c.s===60&&(c.s=59),{kind:"wall",wall:c,offset:m}):J}function nn(r){let e=tn(r);if(e)return e;let t=en.exec(r.trim());if(!t)return;let n={y:Number(t[1]),M:t[2]?Number(t[2])-1:0,D:t[3]?Number(t[3]):1,h:t[4]?Number(t[4]):0,m:t[5]?Number(t[5]):0,s:t[6]?Number(t[6]):0,ms:t[7]?Math.floor(+`0.${t[7]}`*1e3):0};if(!Pe(n))return J;n.s===60&&(n.s=59);let s=t[8]?se(t[8].replace(/^([+-]\d{2})$/,"$1:00")):void 0;return t[8]&&s===void 0?J:{kind:"wall",wall:n,offset:s,zone:t[9]}}function pt(r){let e=nn(r);if(e)return e;let t=Date.parse(r);return Number.isNaN(t)?J:{kind:"epoch",ms:t}}var rn=/\[([^\]]*)\]|YYYY|YY|MMMM|MMM|MM|M|Do|DD|D|dddd|ddd|dd|HH|H|hh|h|kk|k|mm|m|ss|s|S{1,3}|A|a|ZZ|Z|X|x/g;function ae(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function bt(r){return`(${[...r].sort((e,t)=>t.length-e.length).map(ae).join("|")})`}var ne=r=>(e,t)=>{t[r]=Number(e)};function gt(r,e,t){let n=I(t),s=[],i="",a=0;for(let c of e.matchAll(rn)){i+=ae(e.slice(a,c.index)).replace(/\s+/g,"\\s+"),a=c.index+c[0].length;let f=c[0];if(c[1]!==void 0){i+=ae(c[1]);continue}switch(f){case"YYYY":i+="([+-]?\\d{4,6})",s.push(ne("y"));break;case"YY":i+="(\\d{2})",s.push((h,y)=>{let b=Number(h);y.y=b+(b>68?1900:2e3)});break;case"MMMM":case"MMM":{i+=bt([...n.months,...n.monthsShort]),s.push((h,y)=>{let b=h.toLowerCase(),p=n.months.findIndex(D=>D.toLowerCase()===b);p<0&&(p=n.monthsShort.findIndex(D=>D.toLowerCase()===b)),y.M=p+1});break}case"MM":case"M":i+=f==="MM"?"(\\d{2})":"(\\d{1,2})",s.push(ne("M"));break;case"Do":i+="(\\d{1,2})(?:st|nd|rd|th|\\.)?",s.push(ne("D"));break;case"DD":case"D":i+=f==="DD"?"(\\d{2})":"(\\d{1,2})",s.push(ne("D"));break;case"dddd":case"ddd":case"dd":i+=bt([...n.weekdays,...n.weekdaysShort,...n.weekdaysMin]),s.push(()=>{});break;case"HH":case"H":case"hh":case"h":case"kk":case"k":i+=f.length===2?"(\\d{2})":"(\\d{1,2})",s.push(f[0]==="k"?(h,y)=>{y.h=Number(h)%24}:ne("h"));break;case"mm":case"m":i+=f==="mm"?"(\\d{2})":"(\\d{1,2})",s.push(ne("m"));break;case"ss":case"s":i+=f==="ss"?"(\\d{2})":"(\\d{1,2})",s.push(ne("s"));break;case"A":case"a":i+=`(${ae(n.meridiem[0])}|${ae(n.meridiem[1])}|am|pm|a\\.m\\.|p\\.m\\.)`,s.push((h,y)=>{let b=h.toLowerCase();y.pm=b===n.meridiem[1].toLowerCase()||b.startsWith("p")});break;case"ZZ":case"Z":i+="(Z|[+-]\\d{2}:?\\d{2})",s.push((h,y)=>{y.offset=se(h)??NaN});break;case"X":i+="(-?\\d+(?:\\.\\d+)?)",s.push((h,y)=>{y.epoch=Number(h)*1e3});break;case"x":i+="(-?\\d+)",s.push((h,y)=>{y.epoch=Number(h)});break;default:i+=`(\\d{1,${f.length}})`,s.push((h,y)=>{y.ms=Math.round(+`0.${h}`*1e3)})}}i+=ae(e.slice(a)).replace(/\s+/g,"\\s+");let u=new RegExp(`^\\s*${i}\\s*$`,"i").exec(r);if(!u)return J;let o={};if(s.forEach((c,f)=>c(u[f+1],o)),o.epoch!==void 0)return{kind:"epoch",ms:o.epoch};let l=o.h??0;if(o.pm!==void 0){if(l<1||l>12)return J;o.pm&&l<12&&(l+=12),!o.pm&&l===12&&(l=0)}let m=new Date,d={y:o.y??m.getFullYear(),M:o.M!==void 0?o.M-1:o.y!==void 0?0:m.getMonth(),D:o.D??1,h:l,m:o.m??0,s:o.s??0,ms:o.ms??0};return Pe(d)?{kind:"wall",wall:d,offset:o.offset}:J}var O={locale:"en",zone:"local",normalizeSpaces:!0},wt=new Map,$=class r{#e;#n;#r;#o;#c;#u;constructor(e,t,n,s){this.#e=Number.isFinite(e)&&Math.abs(e)<=864e13?e:NaN,this.#n=t,this.#r=n,this.#o=s}#t(e,t=this.#n,n=this.#r,s=this.#o){return new r(e,t,n,s)}#a(){return this.#u??=this.isValid()?G(this.#e,this.#n):NaN}#s(){return this.#c||(this.#c=this.isValid()?tt(this.#e,this.#a()):{y:NaN,M:NaN,D:NaN,h:NaN,m:NaN,s:NaN,ms:NaN,dow:NaN}),this.#c}#i(e){return this.#t(C(e,this.#n))}#d(){return this.#o??O.weekStart??I(this.#r).week.firstDay}#f(e){let t=this.#s(),n=t.y*12+t.M+Mt(e),s=Math.floor(n/12),i=n-s*12;return this.#i({...t,y:s,M:i,D:Math.min(t.D,S(s,i))})}#l(e){let t=this.#s();return this.#i({...t,D:t.D+Mt(e)})}#h(e,t=this.#r){if(!this.isValid())return"Invalid Date";let n=Qe(this.#n),s=this.#n==="local"?void 0:n?"UTC":this.#n,i=`${t}|${s}|${JSON.stringify(e)}`,a=wt.get(i);a||(a=new Intl.DateTimeFormat(t,{...e,timeZone:s}),wt.set(i,a));let u=W(a.format(n?this.#e+this.#a()*6e4:this.#e));return n&&e.timeZoneName?u.replace(/UTC|GMT/,`GMT${Q(this.#a())}`):u}isValid(){return!Number.isNaN(this.#e)}clone(){return this}get(e){let t=this.#s();switch(Y(e)){case"year":return t.y;case"quarter":return Math.floor(t.M/3)+1;case"month":return t.M;case"week":return this.week();case"isoWeek":return this.isoWeek();case"date":return t.D;case"day":return t.dow;case"hour":return t.h;case"minute":return t.m;case"second":return t.s;default:return t.ms}}set(e,t){if(!this.isValid())return this;if(typeof e=="object"){let i=this,a=["year","month","date","day","hour","minute","second","millisecond"];for(let u of a){let o=e[u];o!==void 0&&(i=i.set(u,o))}return i}let n=t,s={...this.#s()};switch(Y(e)){case"year":return this.#i({...s,y:n,D:Math.min(s.D,S(n,s.M))});case"quarter":return this.#f((n-(Math.floor(s.M/3)+1))*3);case"month":{let i=s.y+Math.floor(n/12),a=(n%12+12)%12;return this.#i({...s,y:i,M:a,D:Math.min(s.D,S(i,a))})}case"week":return this.#l((n-this.week())*7);case"isoWeek":return this.#l((n-this.isoWeek())*7);case"date":return this.#i({...s,D:n});case"day":return this.#l(n-s.dow);case"hour":return this.#i({...s,h:n});case"minute":return this.#i({...s,m:n});case"second":return this.#i({...s,s:n});default:return this.#i({...s,ms:n})}}year(e){return e===void 0?this.get("year"):this.set("year",e)}month(e){return e===void 0?this.get("month"):this.set("month",e)}date(e){return e===void 0?this.get("date"):this.set("date",e)}day(e){return e===void 0?this.get("day"):this.set("day",e)}hour(e){return e===void 0?this.get("hour"):this.set("hour",e)}minute(e){return e===void 0?this.get("minute"):this.set("minute",e)}second(e){return e===void 0?this.get("second"):this.set("second",e)}millisecond(e){return e===void 0?this.get("millisecond"):this.set("millisecond",e)}quarter(e){return e===void 0?this.get("quarter"):this.set("quarter",e)}dayOfYear(e){let t=this.#s(),n=z(t.y,t.M,t.D);return e===void 0?n:this.#l(e-n)}isoWeekday(e){let t=this.#s().dow||7;return e===void 0?t:this.#l(e-t)}weekday(e){let t=(this.#s().dow-this.#d()+7)%7;return e===void 0?t:this.#l(e-t)}week(){let e=this.#s();return v(e.y,e.M,e.D,this.#d(),I(this.#r).week.minimalDays).week}weekYear(){let e=this.#s();return v(e.y,e.M,e.D,this.#d(),I(this.#r).week.minimalDays).year}isoWeek(){let e=this.#s();return v(e.y,e.M,e.D,1,4).week}isoWeekYear(){let e=this.#s();return v(e.y,e.M,e.D,1,4).year}isoWeeksInYear(){return Ie(this.year(),1,4)}daysInMonth(){let e=this.#s();return S(e.y,e.M)}isLeapYear(){return Se(this.year())}add(e,t){if(!this.isValid())return this;if(typeof e!="number"){let s=be(e)?e:q(e);if(!s.isValid())return this.#t(NaN);let i=s.toObject(),a=this;(i.years||i.months)&&(a=a.#f(i.years*12+i.months)),(i.weeks||i.days)&&(a=a.#l(i.weeks*7+i.days));let u=i.hours*36e5+i.minutes*6e4+i.seconds*1e3+i.milliseconds;return u?a.#t(a.#e+u):a}let n=Y(t??"millisecond");switch(n){case"year":return this.#f(e*12);case"quarter":return this.#f(e*3);case"month":return this.#f(e);case"week":case"isoWeek":return this.#l(e*7);case"day":case"date":return this.#l(e);default:return this.#t(this.#e+e*(Re[n]??1))}}subtract(e,t){return typeof e=="number"?this.add(-e,t):this.add((be(e)?e:q(e)).negate())}startOf(e){if(!this.isValid())return this;let t=Y(e),n={...this.#s()},s={h:0,m:0,s:0,ms:0};switch(t){case"year":return this.#i({...n,...s,M:0,D:1});case"quarter":return this.#i({...n,...s,M:Math.floor(n.M/3)*3,D:1});case"month":return this.#i({...n,...s,D:1});case"week":return this.#i({...n,...s,D:n.D-(n.dow-this.#d()+7)%7});case"isoWeek":return this.#i({...n,...s,D:n.D-(n.dow+6)%7});case"day":case"date":return this.#i({...n,...s});case"hour":return this.#t(this.#e-(n.m*6e4+n.s*1e3+n.ms));case"minute":return this.#t(this.#e-(n.s*1e3+n.ms));case"second":return this.#t(this.#e-n.ms);default:return this}}endOf(e){let t=Y(e);return t==="millisecond"?this:this.startOf(t).add(1,t==="date"?"day":t).subtract(1,"millisecond")}round(e){if(!this.isValid())return this;let t=Y(e),n=this.startOf(t),s=n.add(1,t==="date"?"day":t);return this.#e-n.#e<s.#e-this.#e?n:s}clamp(e,t){let n=this.#m(e),s=this.#m(t);return this.#e<n.#e?n.tz(this.#n):this.#e>s.#e?s.tz(this.#n):this}tz(e,t=!1){let n=x(e);return this.isValid()?t?this.#t(C(this.#s(),n),n):this.#t(this.#e,n):this.#t(NaN,n)}utc(e=!1){return this.tz("UTC",e)}local(e=!1){return this.tz("local",e)}timezone(){return this.#n==="local"?ce():this.#n}isUTC(){return this.#n==="UTC"}isLocal(){return this.#n==="local"}utcOffset(e,t=!1){if(e===void 0)return this.#a();let n;if(typeof e=="string"){n=x(e)==="UTC"?0:Number.NaN;let s=/^([+-])(\d{2}):?(\d{2})$/.exec(e);s&&(n=(s[1]==="-"?-1:1)*(Number(s[2])*60+Number(s[3])))}else n=Math.abs(e)<16?e*60:e;if(Number.isNaN(n))throw new RangeError(`neram: invalid offset "${e}"`);return this.tz(n===0?"UTC":Q(n),t)}isDST(){if(!this.isValid())return!1;let e=this.year(),t=G(Date.UTC(e,0,1),this.#n),n=G(Date.UTC(e,6,1),this.#n);return t!==n&&this.#a()===Math.max(t,n)}localeData(){return Fe(this.#r)}locale(e){return e===void 0?this.#r:this.#t(this.#e,this.#n,te(e))}weekStart(e){return e===void 0?this.#d():this.#t(this.#e,this.#n,this.#r,e)}format(e="YYYY-MM-DDTHH:mm:ssZ"){return this.isValid()?yt({wall:this.#s(),ms:this.#e,offset:this.#a(),locale:this.#r,weekStart:this.#d(),intl:t=>this.#h(t)},e):"Invalid Date"}toLocaleString(e={dateStyle:"medium",timeStyle:"medium"},t){return this.#h(e,t?te(t):this.#r)}from(e,t={}){if(!this.isValid())return"Invalid Date";let n=this.#m(e);if(!n.isValid())return"Invalid Date";let s=this.#e-n.#e,{value:i,unit:a}=ve(s,this.diff(n,"month",!0));return ye(i,a,t.locale??this.#r,t)}fromNow(e={}){return this.from(this.#t(Date.now()),e)}to(e,t={}){return this.isValid()?this.#m(e).locale(this.#r).from(this,t):"Invalid Date"}toNow(e={}){return this.to(this.#t(Date.now()),e)}calendar(e,t={}){if(!this.isValid())return"Invalid Date";let n=(e===void 0?this.#t(Date.now()):this.#m(e)).tz(this.#n),s=this.startOf("day").diff(n.startOf("day"),"day"),i=this.#r.toLowerCase().startsWith("en"),a=i?" at ":" ",u=this.format("LT"),o=m=>m.charAt(0).toLocaleUpperCase(this.#r)+m.slice(1);if(Math.abs(s)<=1)return o(ye(s,"day",this.#r))+a+u;let l=I(this.#r).weekdays[this.day()];return s>1&&s<7?o(l)+a+u:s<-1&&s>-7?(i?`Last ${l}`:o(l))+a+u:this.format(t.sameElse??"L")}#m(e){return e instanceof r?e:g(e,{zone:this.#n,locale:this.#r})}diff(e,t="millisecond",n=!1){let s=this.#m(e);if(!this.isValid()||!s.isValid())return NaN;let i=Y(t),a=this.#e+this.#a()*6e4-(s.#e+s.#a()*6e4),u;switch(i){case"year":u=pe(this,s)/12;break;case"quarter":u=pe(this,s)/3;break;case"month":u=pe(this,s);break;case"week":case"isoWeek":u=a/fe;break;case"day":case"date":u=a/E;break;default:u=(this.#e-s.#e)/(Re[i]??1)}return n?u:Math.trunc(u)||0}durationTo(e){let t=this.#m(e);if(!this.isValid()||!t.isValid())return q(NaN);let n=t.#e<this.#e?-1:1,[s,i]=n>0?[this,t]:[t,this],a=Math.trunc(pe(i,s));s=s.add(a,"month");let u=Math.trunc(i.diff(s,"day"));s=s.add(u,"day");let o=i.#e-s.#e;return q({months:n*a,days:n*u,milliseconds:n*o}).normalize()}isBefore(e,t){let n=this.#m(e);return t?this.endOf(t).#e<n.#e:this.#e<n.#e}isAfter(e,t){let n=this.#m(e);return t?this.startOf(t).#e>n.#e:this.#e>n.#e}isSame(e,t){let n=this.#m(e);return t?this.startOf(t).#e<=n.#e&&n.#e<=this.endOf(t).#e:this.#e===n.#e}isSameOrBefore(e,t){return this.isSame(e,t)||this.isBefore(e,t)}isSameOrAfter(e,t){return this.isSame(e,t)||this.isAfter(e,t)}isBetween(e,t,n,s="()"){let[i,a]=[this.#m(e),this.#m(t)].sort((l,m)=>l.#e-m.#e),u=s[0]==="["?this.isSameOrAfter(i,n):this.isAfter(i,n),o=s[1]==="]"?this.isSameOrBefore(a,n):this.isBefore(a,n);return u&&o}isToday(){return this.isSame(this.#t(Date.now()),"day")}isTomorrow(){return this.isSame(this.#t(Date.now()).add(1,"day"),"day")}isYesterday(){return this.isSame(this.#t(Date.now()).subtract(1,"day"),"day")}isPast(){return this.#e<Date.now()}isFuture(){return this.#e>Date.now()}isWeekend(e){return(e===void 0?I(this.#r).week.weekend:He(e)).includes(this.day())}isBusinessDay(e={}){return this.isWeekend(e.weekend)?!1:e.holidays?.length?!this.#y(e).has(this.format("YYYY-MM-DD")):!0}addBusinessDays(e,t={}){if(!Number.isInteger(e))throw new RangeError(`neram: business days must be a whole number, got ${e}`);t.weekend!==void 0&&He(t.weekend);let n=this.#y(t);if(!this.isValid())return this;let s=e<0?-1:1,i=Math.abs(e),a=this;for(;i>0;)a=a.#l(s),!a.isWeekend(t.weekend)&&!n.has(a.format("YYYY-MM-DD"))&&i--;return a}subtractBusinessDays(e,t={}){return this.addBusinessDays(-e,t)}businessDaysUntil(e,t={}){t.weekend!==void 0&&He(t.weekend);let n=this.#m(e);if(!this.isValid()||!n.isValid())return NaN;let s=n.tz(this.#n).startOf("day"),i=this.startOf("day"),a=s.#e<i.#e?-1:1,u=this.#y(t),o=0;for(;a>0?i.#e<s.#e:i.#e>s.#e;)i=i.#l(a),!i.isWeekend(t.weekend)&&!u.has(i.format("YYYY-MM-DD"))&&(o+=a);return o}#y(e){return new Set((e.holidays??[]).map(t=>{let n=this.#m(t);if(!n.isValid())throw new RangeError(`neram: invalid holiday ${JSON.stringify(t)}`);return n.tz(this.#n).format("YYYY-MM-DD")}))}valueOf(){return this.#e}unix(){return Math.floor(this.#e/1e3)}toDate(){return new Date(this.#e)}toISOString(){return new Date(this.#e).toISOString()}toZonedISOString(){if(!this.isValid())return"Invalid Date";let e=this.#s().ms?".SSS":"";return`${this.format(`YYYY-MM-DDTHH:mm:ss${e}Z`)}[${this.timezone()}]`}toTemporal(){let e=globalThis.Temporal;if(!e)throw new Error("neram: Temporal is not available in this runtime");return e.ZonedDateTime.from(this.toZonedISOString())}toJSON(){return this.isValid()?this.toISOString():null}toString(){return this.isValid()?new Date(this.#e).toUTCString():"Invalid Date"}toObject(){let e=this.#s();return{year:e.y,month:e.M,date:e.D,hour:e.h,minute:e.m,second:e.s,millisecond:e.ms}}toArray(){let e=this.#s();return[e.y,e.M,e.D,e.h,e.m,e.s,e.ms]}[Symbol.toPrimitive](e){return e==="number"?this.#e:this.toString()}get[Symbol.toStringTag](){return"Neram"}};function pe(r,e){if(r.date()<e.date())return-pe(e,r);let t=(e.year()-r.year())*12+(e.month()-r.month()),n=r.add(t,"month").valueOf(),s=e.valueOf()-n<0,i=r.add(t+(s?-1:1),"month").valueOf();return-(t+(e.valueOf()-n)/(s?n-i:i-n))||0}function Dt(r,e,t){if(r.kind==="epoch")return{ms:r.ms,zone:e};let n=e;return r.zone&&!t&&(n=x(r.zone)),r.offset!==void 0?{ms:We(r.wall)-r.offset*6e4,zone:n}:{ms:C(r.wall,n),zone:n}}function sn(r){return typeof r=="object"&&r!==null&&typeof r.epochMilliseconds=="number"}function j(r,e,t,n){let s={};typeof e=="string"||Array.isArray(e)?s.format=e:e&&(s={...e}),typeof t=="boolean"?s.strict=t:typeof t=="string"&&(s.locale=t),typeof n=="boolean"&&(s.strict=n);let i=s.locale?te(s.locale):O.locale,a=s.utc===!0||s.zone!==void 0,u=x(s.utc?"UTC":s.zone??O.zone),o=s.weekStart;if(r instanceof $){let m=r;return a&&(m=m.tz(u)),s.locale&&(m=m.locale(i)),o!==void 0&&(m=m.weekStart(o)),m}let l;if(r===void 0)l=Date.now();else if(r===null)l=NaN;else if(r instanceof Date)l=r.getTime();else if(typeof r=="number")l=r;else if(typeof r=="string"){let m=s.format===void 0?void 0:Array.isArray(s.format)?s.format:[s.format];if(!m)({ms:l,zone:u}=Dt(pt(r),u,a));else{l=NaN;for(let d of m){let c=Dt(gt(r,d,i),u,a);if(!Number.isNaN(c.ms)&&!(s.strict&&new $(c.ms,c.zone,i,o).format(d)!==r.trim())){({ms:l,zone:u}=c);break}}}}else if(Array.isArray(r)){let[m=new Date().getFullYear(),d=0,c=1,f=0,h=0,y=0,b=0]=r,p={y:m,M:d,D:c,h:f,m:h,s:y,ms:b};l=r.length>=1&&r.length<=7&&kt(p)?C(p,u):NaN}else if(sn(r))l=r.epochMilliseconds,r.timeZoneId&&!a&&(u=x(r.timeZoneId));else if(typeof r=="object"){let m=on(r),d=m&&{y:m.year??new Date().getFullYear(),M:m.month??0,D:m.date??1,h:m.hour??0,m:m.minute??0,s:m.second??0,ms:m.millisecond??0};l=d&&kt(d)?C(d,u):NaN}else l=NaN;return new $(l,u,i,o)}function Mt(r){return r<0?-Math.round(-r):Math.round(r)}function He(r){if(!Array.isArray(r)||r.some(e=>!Number.isInteger(e)||e<0||e>6))throw new RangeError(`neram: weekend must list weekday numbers 0-6 (0 = Sunday), got ${JSON.stringify(r)}`);if(new Set(r).size===7)throw new RangeError("neram: weekend cannot include every day of the week");return r}var an={year:"year",years:"year",y:"year",month:"month",months:"month",M:"month",date:"date",dates:"date",D:"date",d:"date",day:"date",days:"date",hour:"hour",hours:"hour",h:"hour",minute:"minute",minutes:"minute",m:"minute",second:"second",seconds:"second",s:"second",millisecond:"millisecond",milliseconds:"millisecond",ms:"millisecond"};function on(r){let e={},t=!1;for(let[n,s]of Object.entries(r)){if(s===void 0)continue;let i=an[n];if(!i||typeof s!="number"||e[i]!==void 0)return;e[i]=s,t=!0}return t?e:void 0}function kt(r){return[r.y,r.M,r.D,r.h,r.m,r.s,r.ms].every(Number.isInteger)?r.M>=0&&r.M<=11&&r.D>=1&&r.D<=S(r.y,r.M)&&r.h>=0&&r.h<=23&&r.m>=0&&r.m<=59&&r.s>=0&&r.s<=59&&r.ms>=0&&r.ms<=999:!1}var Nt=new Set;function St(r){return(r.length===1&&Array.isArray(r[0])&&typeof r[0][0]!="number"?r[0]:r).map(e=>j(e)).filter(e=>e.isValid())}var g=Object.assign(j,{utc(r,e,t){return j(r,{format:e,strict:t,utc:!0})},tz(r,e,t){return j(r,{format:t,zone:e})},unix(r){return j(r*1e3)},now(){return j()},duration:q,isDuration:be,Duration:Z,Neram:$,isNeram(r){return r instanceof $},min(...r){let e=St(r);return e.length?e.reduce((t,n)=>n.valueOf()<t.valueOf()?n:t):null},max(...r){let e=St(r);return e.length?e.reduce((t,n)=>n.valueOf()>t.valueOf()?n:t):null},sort(r){return r.map(e=>j(e)).sort((e,t)=>e.valueOf()-t.valueOf())},range(r,e,t={}){let n=Y(t.unit??"day"),s=t.step??1;if(typeof s!="number"||!Number.isFinite(s)||s<=0)throw new RangeError(`neram: range step must be a positive number, got ${String(s)}`);if(!(n in Re)&&!Number.isInteger(s))throw new RangeError(`neram: range step must be a whole number of ${n}s, got ${s}`);let i=t.limit??1e5;if(!Number.isInteger(i)||i<0)throw new RangeError(`neram: range limit must be a whole number, got ${i}`);let a=j(r),u=j(e);if(!a.isValid()||!u.isValid())return[];let o=s*(u.valueOf()<a.valueOf()?-1:1),l=[];for(let m=0;;m++){let d=a.add(o*m,n);if((o>0?d.valueOf()>u.valueOf():d.valueOf()<u.valueOf())||t.exclusive&&d.valueOf()===u.valueOf())break;if(l.length===i)throw new RangeError(`neram: range has more than ${i} dates; use a larger step or pass { limit }`);l.push(d)}return l},locale(r){return r!==void 0&&(O.locale=te(r)),O.locale},localeData(r){return Fe(r?te(r):O.locale)},environment(){let r=globalThis.process?.versions??{},e=Intl,t=!0;try{new Intl.NumberFormat("en",{style:"unit",unit:"hour"})}catch{t=!1}return{zone:ce(),defaultZone:O.zone==="local"?ce():O.zone,locale:O.locale,runtimeLocale:new Intl.DateTimeFormat().resolvedOptions().locale,icu:r.icu,cldr:r.cldr,tzdata:r.tz,features:{relativeTimeFormat:typeof e.RelativeTimeFormat=="function",listFormat:typeof e.ListFormat=="function",durationFormat:typeof e.DurationFormat=="function",supportedValuesOf:typeof e.supportedValuesOf=="function",unitFormat:t}}},guess(){return ce()},zones(){let r=Intl.supportedValuesOf;return r?r("timeZone"):[]},config(r={}){return r.locale!==void 0&&(O.locale=te(r.locale)),r.zone!==void 0&&(O.zone=x(r.zone)),"weekStart"in r&&(O.weekStart=r.weekStart),r.normalizeSpaces!==void 0&&(Le.normalizeSpaces=O.normalizeSpaces=r.normalizeSpaces),{...O}},extend(r,e){return Nt.has(r)||(r(e,$,g),Nt.add(r)),g}});var Ve={};$t(Ve,{Cron:()=>De,RRule:()=>ue,Schedule:()=>K,cron:()=>Et,parseRRule:()=>je,rrule:()=>At});var un=400*366*864e5,K=class{coerce(e){let t=g(e,{zone:this.tz}).valueOf();if(Number.isNaN(t))throw new RangeError(`neram: invalid date ${JSON.stringify(e)}`);return t}out(e,t){let n=g(e,{zone:this.tz});if(typeof t=="function")return t(n);let s=()=>n.format(this.allDay?"YYYY-MM-DD":"YYYY-MM-DDTHH:mm:ss"),i;switch(t??"neram"){case"neram":i=n;break;case"date":i=n.toDate();break;case"epoch":i=e;break;case"unix":i=Math.floor(e/1e3);break;case"iso":i=n.toISOString();break;case"zoned":i=n.toZonedISOString();break;case"local":i=s();break;case"record":i={utc:n.toISOString(),local:s(),tz:n.timezone(),epoch:e,allDay:this.allDay};break;default:throw new RangeError(`neram: unknown output format "${String(t)}"`)}return i}all(e={}){if(Ze("limit",e.limit),e.limit===void 0&&this.isInfinite())throw new RangeError("neram: this schedule never ends; pass { limit } or use between()");let t=[];for(let n of this.iterate(this.startMs())){if(e.limit!==void 0&&t.length>=e.limit)break;t.push(this.out(n,e.as))}return t}between(e,t,n={}){Ze("limit",n.limit);let s=n.inclusive??!0,i=this.coerce(e),a=this.coerce(t),u=[];for(let o of this.iterate(i)){if(o>a||!s&&o===a)break;if(!(!s&&o===i)){if(n.limit!==void 0&&u.length>=n.limit)break;u.push(this.out(o,n.as))}}return u}after(e,t={}){let n=e===void 0?Date.now():this.coerce(e);for(let s of this.iterate(n))if(!(s===n&&!t.inclusive))return this.out(s,t.as);return null}before(e,t={}){let n=e===void 0?Date.now():this.coerce(e),s=Math.max(this.startMs(),n-un),i=7*864e5;for(;;){let a=Math.max(s,n-i),u;for(let o of this.iterate(a)){if(o>n||o===n&&!t.inclusive)break;u=o}if(u!==void 0)return this.out(u,t.as);if(a<=s)return null;i*=8}}take(e,t={}){Ze("take(n)",e);let n=t.from===void 0?Date.now():this.coerce(t.from),s=[];if(e===0)return s;for(let i of this.iterate(n))if(i!==n&&(s.push(this.out(i,t.as)),s.length>=e))break;return s}includes(e){let t=this.coerce(e);for(let n of this.iterate(t))return n===t;return!1}instances(e,t,n){let s=q(n.duration);if(!s.isValid()||s.valueOf()<0)throw new RangeError("neram: instances() needs a duration of zero or more");let i=this.coerce(e),a=this.coerce(t),u=Math.abs(s.asMilliseconds())+2*864e5,o=[];for(let l of this.iterate(i-u)){if(l>=a)break;let d=g(l,{zone:this.tz}).add(s);d.valueOf()<=i&&l<i||o.push({start:this.out(l,n.as),end:this.out(d.valueOf(),n.as)})}return o}*[Symbol.iterator](){for(let e of this.iterate(this.startMs()))yield g(e,{zone:this.tz})}};function Ze(r,e){if(e!==void 0&&(!Number.isInteger(e)||e<0))throw new RangeError(`neram: ${r} must be a whole number of zero or more, got ${String(e)}`)}var Ee=["yearly","monthly","weekly","daily","hourly","minutely","secondly"],Ot=new Set(["freq","dtstart","tz","allDay","interval","count","until","wkst","byMonth","byWeekNo","byYearDay","byMonthDay","byDay","byHour","byMinute","bySecond","bySetPos","rdate","exdate"]),L=0,oe=1,Ue=2,qe=3,ge=4,It=5,Tt=6,re=["SU","MO","TU","WE","TH","FR","SA"],we=864e5,Rt=[0,0,0,0,36e5,6e4,1e3],X=(r,e,t,n,s=!0)=>{if(r===void 0)return;let i=(Array.isArray(r)?r:[r]).map(Number);for(let a of i)if(!Number.isInteger(a)||Math.abs(a)>n||t>=0&&a<t||!s&&a===0||t<0&&a<t)throw new RangeError(`neram: ${e} value ${a} is out of range`);return i.length?[...new Set(i)].sort((a,u)=>a-u):void 0};function mn(r){if(typeof r=="object"){let n=re.indexOf(r.day.toUpperCase());if(n<0)throw new RangeError(`neram: invalid weekday "${r.day}"`);return{w:n,n:r.n??0}}let e=/^([+-]?\d{1,2})?(MO|TU|WE|TH|FR|SA|SU)$/i.exec(r.trim());if(!e)throw new RangeError(`neram: invalid BYDAY "${r}"`);let t=e[1]?Number(e[1]):0;if(Math.abs(t)>53)throw new RangeError(`neram: invalid BYDAY "${r}"`);return{w:re.indexOf(e[2].toUpperCase()),n:t}}var A=(r,e,t)=>Math.floor(M(r,e,t)/we),$e=Ne;function vt(r){let e=ie(r);return{y:e.y,M:e.M,D:e.D,h:e.h,m:e.m,s:e.s,ms:0}}var cn=r=>typeof r=="string"&&/^\d{4}-?\d{2}-?\d{2}$/.test(r.trim()),ue=class r extends K{tz;allDay;#e;#n;#r;#o;#c;#u;#t;constructor(e){super();for(let p of Object.keys(e))if(!Ot.has(p)){let D=[...Ot].find(w=>w.toLowerCase()===p.toLowerCase());throw new RangeError(`neram: unknown rrule option "${p}"${D?`; did you mean "${D}"?`:""}`)}let t=Ee.indexOf(String(e.freq).toLowerCase());if(t<0)throw new RangeError(`neram: invalid freq "${e.freq}"`);if(e.dtstart===void 0||e.dtstart===null)throw new RangeError("neram: dtstart is required");let n=e.tz?g(e.dtstart,{zone:e.tz}):g(e.dtstart);if(!n.isValid())throw new RangeError(`neram: invalid dtstart ${JSON.stringify(e.dtstart)}`);this.tz=x(e.tz??n.timezone()),this.allDay=e.allDay??!1,n=n.tz(this.tz).millisecond(0),this.allDay&&(n=n.startOf("day"));let[s,i,a,u,o,l]=n.toArray();this.#c={y:s,M:i,D:a,h:u,m:o,s:l,dow:n.day()},this.#r=M(s,i,a,u,o,l),this.#o=n.valueOf();let m=e.interval??1;if(!Number.isInteger(m)||m<1)throw new RangeError("neram: interval must be a positive integer");if(e.count!==void 0&&(!Number.isInteger(e.count)||e.count<1))throw new RangeError("neram: count must be a positive integer");if(e.count!==void 0&&e.until!==void 0&&e.until!==null)throw new RangeError("neram: use count or until, not both (RFC 5545)");let d=1;if(e.wkst&&(d=re.indexOf(e.wkst.toUpperCase()),d<0))throw new RangeError(`neram: invalid wkst "${e.wkst}"`);let c;if(e.until!==void 0&&e.until!==null){let p=g(e.until,{zone:this.tz});if(!p.isValid())throw new RangeError(`neram: invalid until ${JSON.stringify(e.until)}`);c=(this.allDay||cn(e.until)?p.endOf("day"):p).valueOf()}let f=e.byDay===void 0?void 0:(Array.isArray(e.byDay)?e.byDay:[e.byDay]).map(mn);if(f?.some(p=>p.n!==0)){if(t!==oe&&t!==L)throw new RangeError(`neram: byDay with a number ("1MO", "-1FR") needs freq 'monthly' or 'yearly'`);if(t===L&&e.byWeekNo!==void 0)throw new RangeError("neram: byDay with a number cannot be combined with byWeekNo (RFC 5545)")}this.#e={freq:t,interval:m,count:e.count,untilMs:c,wkst:d,wkstGiven:e.wkst!==void 0,byMonth:X(e.byMonth,"byMonth",1,12),byWeekNo:X(e.byWeekNo,"byWeekNo",-53,53,!1),byYearDay:X(e.byYearDay,"byYearDay",-366,366,!1),byMonthDay:X(e.byMonthDay,"byMonthDay",-31,31,!1),byDay:f?.length?f:void 0,byHour:X(e.byHour,"byHour",0,23),byMinute:X(e.byMinute,"byMinute",0,59),bySecond:X(e.bySecond,"bySecond",0,60),bySetPos:X(e.bySetPos,"bySetPos",-366,366,!1)};let h={...this.#e},y=!h.byWeekNo&&!h.byYearDay&&!h.byMonthDay&&!h.byDay;t===L&&y?(h.byMonth??=[i+1],h.byMonthDay=[a]):t===oe&&y?h.byMonthDay=[a]:t===Ue&&!h.byDay&&!h.byMonthDay&&!h.byYearDay&&(h.byDay=[{w:this.#c.dow,n:0}]),this.allDay?(h.byHour=[0],h.byMinute=[0],h.bySecond=[0]):(t<ge&&(h.byHour??=[u]),t<It&&(h.byMinute??=[o]),t<Tt&&(h.bySecond??=[l])),this.#n=h;let b=p=>{let D=g(p,{zone:this.tz});if(!D.isValid())throw new RangeError(`neram: invalid date ${JSON.stringify(p)}`);return(this.allDay?D.startOf("day"):D.millisecond(0)).valueOf()};this.#u=new Set((e.exdate??[]).map(b)),this.#t=[...new Set((e.rdate??[]).map(b))].sort((p,D)=>p-D)}isInfinite(){return this.#e.count===void 0&&this.#e.untilMs===void 0}startMs(){return Math.min(this.#o,this.#t[0]??1/0)}get freq(){return Ee[this.#e.freq]}get dtstart(){return g(this.#o,{zone:this.tz})}#a(e,t){let n=this.#n,{y:s,M:i,D:a,dow:u}=$e(e);if(n.byMonth&&!n.byMonth.includes(i+1))return!1;if(n.byWeekNo){let o=v(s,i,a,n.wkst,4);if(n.freq===L&&o.year!==t)return!1;let l=Ie(o.year,n.wkst,4);if(!n.byWeekNo.some(m=>(m>0?m:l+m+1)===o.week))return!1}if(n.byYearDay){let o=z(s,i,a),l=Oe(s);if(!n.byYearDay.some(m=>(m>0?m:l+m+1)===o))return!1}if(n.byMonthDay){let o=S(s,i);if(!n.byMonthDay.some(l=>(l>0?l:o+l+1)===a))return!1}if(n.byDay){let o=n.freq===oe||n.freq===L&&!!n.byMonth,l=n.freq===L&&!n.byMonth,m=!1;for(let d of n.byDay){if(d.w!==u)continue;if(d.n===0||!o&&!l){m=!0;break}let c,f;if(o)c=Math.floor((a-1)/7)+1,f=-(Math.floor((S(s,i)-a)/7)+1);else{let h=z(s,i,a);c=Math.floor((h-1)/7)+1,f=-(Math.floor((Oe(s)-h)/7)+1)}if(d.n===c||d.n===f){m=!0;break}}if(!m)return!1}return!0}#s(){let e=this.#n,t=[];for(let n of e.byHour)for(let s of e.byMinute)for(let i of e.bySecond)t.push(n*36e5+s*6e4+i*1e3);return t.sort((n,s)=>n-s)}#i(e,t){let n=this.#n,s=this.#c,i=n.interval,a,u,o;if(n.freq>=ge){let m=Rt[n.freq],d=this.#r-(this.#r%m+m)%m,c=d+e*i*m,f=Math.floor(c/we);o=$e(f).y;let h=p=>Math.ceil((p-d)/(i*m));if(!this.#a(f,o))return{year:o,walls:[],skipTo:h((f+1)*we)};let y=vt(c);if(n.byHour&&!n.byHour.includes(y.h))return n.freq===ge?{year:o,walls:[]}:{year:o,walls:[],skipTo:h((Math.floor(c/36e5)+1)*36e5)};if(n.freq===Tt&&n.byMinute&&!n.byMinute.includes(y.m))return{year:o,walls:[],skipTo:h((Math.floor(c/6e4)+1)*6e4)};let b=[];if(n.freq===ge)for(let p of n.byMinute??[s.m])for(let D of n.bySecond??[s.s])b.push(c+p*6e4+D*1e3);else if(n.freq===It){if(n.byMinute&&!n.byMinute.includes(y.m))return{year:o,walls:[]};for(let p of n.bySecond??[s.s])b.push(c+p*1e3)}else(!n.bySecond||n.bySecond.includes(y.s))&&b.push(c);return{year:o,walls:b.sort((p,D)=>p-D)}}switch(n.freq){case L:o=s.y+e*i,a=n.byWeekNo?A(o-1,11,25):A(o,0,1),u=n.byWeekNo?A(o+1,0,7):A(o,11,31);break;case oe:{let m=s.y*12+s.M+e*i;o=Math.floor(m/12);let d=m-o*12;a=A(o,d,1),u=A(o,d,S(o,d));break}case Ue:{a=A(s.y,s.M,s.D)-(s.dow-n.wkst+7)%7+e*i*7,u=a+6,o=$e(a).y;break}default:a=u=A(s.y,s.M,s.D)+e*i,o=$e(a).y}let l=[];for(let m=a;m<=u;m++)if(this.#a(m,o))for(let d of t)l.push(m*we+d);return{year:o,walls:l}}#d(e){let t=this.#n,n=this.#c,s=g(e-2*we,{zone:this.tz}),[i,a,u,o,l,m]=s.toArray(),d=t.interval,c;switch(t.freq){case L:c=Math.floor((i-n.y)/d)-1;break;case oe:c=Math.floor((i*12+a-(n.y*12+n.M))/d)-1;break;case Ue:{let f=A(n.y,n.M,n.D)-(n.dow-t.wkst+7)%7;c=Math.floor((A(i,a,u)-f)/(7*d))-1;break}case qe:c=Math.floor((A(i,a,u)-A(n.y,n.M,n.D))/d)-1;break;default:{let f=Rt[t.freq],h=this.#r-(this.#r%f+f)%f;c=Math.floor((M(i,a,u,o,l,m)-h)/(d*f))-1}}return Math.max(0,c)}*#f(e){let t=this.#n,n=t.freq<ge?this.#s():[],s=t.count===void 0&&Number.isFinite(e)&&e>this.#o,i=s?this.#d(e):0,a=s?g(e,{zone:this.tz}).year():this.#c.y,u=0,o=-1/0;for(;;i++){let l=this.#i(i,n);if(l.year>9999||l.year>a+400)return;if(l.skipTo!==void 0){i=l.skipTo-1;continue}let m=l.walls;if(t.bySetPos&&m.length){let d=m.length;m=[...new Set(t.bySetPos.map(c=>m[c>0?c-1:d+c]).filter(c=>c!==void 0))].sort((c,f)=>c-f)}for(let d of m){if(d<this.#r)continue;let c=C(vt(d),this.tz);if(t.untilMs!==void 0&&c>t.untilMs)return;if(!(c<=o)&&(o=c,a=l.year,u++,c>=e&&(yield c),t.count!==void 0&&u>=t.count))return}}}*iterate(e){let t=this.#t.filter(a=>a>=e),n=0,s=-1/0,i=a=>a===s||this.#u.has(a)?!1:(s=a,!0);for(let a of this.#f(e)){for(;n<t.length&&t[n]<=a;)i(t[n])&&(yield t[n]),n++;i(a)&&(yield a)}for(;n<t.length;n++)i(t[n])&&(yield t[n])}#l(e){let t=g(e,{zone:this.tz});return this.allDay?t.format("YYYYMMDD"):this.tz==="UTC"?t.format("YYYYMMDD[T]HHmmss[Z]"):t.format("YYYYMMDD[T]HHmmss")}#h(e,t){let n=this.allDay?";VALUE=DATE":this.tz==="UTC"?"":`;TZID=${this.tz}`;return`${e}${n}:${t.map(s=>this.#l(s)).join(",")}`}rruleString(){let e=this.#e,t=[`FREQ=${Ee[e.freq].toUpperCase()}`];if(e.interval!==1&&t.push(`INTERVAL=${e.interval}`),e.count!==void 0&&t.push(`COUNT=${e.count}`),e.untilMs!==void 0){let s=g(e.untilMs,{zone:this.allDay?this.tz:"UTC"});t.push(`UNTIL=${this.allDay?s.format("YYYYMMDD"):s.format("YYYYMMDD[T]HHmmss[Z]")}`)}e.wkstGiven&&t.push(`WKST=${re[e.wkst]}`);let n=(s,i)=>i&&t.push(`${s}=${i.join(",")}`);return n("BYMONTH",e.byMonth),n("BYWEEKNO",e.byWeekNo),n("BYYEARDAY",e.byYearDay),n("BYMONTHDAY",e.byMonthDay),n("BYDAY",e.byDay?.map(s=>`${s.n||""}${re[s.w]}`)),n("BYHOUR",e.byHour),n("BYMINUTE",e.byMinute),n("BYSECOND",e.bySecond),n("BYSETPOS",e.bySetPos),t.join(";")}toString(){let e=[this.#h("DTSTART",[this.#o]),`RRULE:${this.rruleString()}`];return this.#t.length&&e.push(this.#h("RDATE",this.#t)),this.#u.size&&e.push(this.#h("EXDATE",[...this.#u].sort((t,n)=>t-n))),e.join(`
3
+ `)}toJSON(){let e=this.#e,t=s=>{let i=g(s,{zone:this.tz});return this.allDay?i.format("YYYY-MM-DD"):i.toZonedISOString()},n={freq:Ee[e.freq],dtstart:t(this.#o),tz:this.tz};this.allDay&&(n.allDay=!0),e.interval!==1&&(n.interval=e.interval),e.count!==void 0&&(n.count=e.count),e.untilMs!==void 0&&(n.until=t(e.untilMs)),e.wkstGiven&&(n.wkst=re[e.wkst]);for(let s of["byMonth","byWeekNo","byYearDay","byMonthDay","byHour","byMinute","bySecond","bySetPos"])e[s]&&(n[s]=[...e[s]]);return e.byDay&&(n.byDay=e.byDay.map(s=>`${s.n||""}${re[s.w]}`)),this.#t.length&&(n.rdate=this.#t.map(t)),this.#u.size&&(n.exdate=[...this.#u].sort((s,i)=>s-i).map(t)),n}with(e){let t=this.toJSON();return"until"in e&&delete t.count,"count"in e&&delete t.until,new r({...t,...e})}toText(e="en"){let t=this.#e,n=I(e),s=c=>le(c,"en"),i=["year","month","week","day","hour","minute","second"][t.freq],a={1:"first",2:"second",3:"third",4:"fourth",5:"fifth",[-1]:"last",[-2]:"second-to-last"},u=t.interval===1?`every ${i}`:`every ${t.interval} ${i}s`;t.freq===qe&&t.byDay&&t.byDay.every(c=>!c.n)&&t.byDay.map(f=>f.w).sort().join()==="1,2,3,4,5"&&t.interval===1&&(u="every weekday"),t.byMonth&&(u+=` in ${s(t.byMonth.map(c=>n.months[c-1]))}`);let o=!t.byWeekNo&&!t.byYearDay&&!t.byMonthDay&&!t.byDay,l=this.#c;o&&t.freq===L&&!t.byMonth?u+=` on ${n.months[l.M]} ${l.D}`:o&&t.freq===L?u+=` on the ${U(l.D,"en")}`:o&&t.freq===oe?u+=` on the ${U(l.D,"en")}`:t.freq===Ue&&!t.byDay&&!t.byMonthDay&&!t.byYearDay&&(u+=` on ${n.weekdays[l.dow]}`),t.byWeekNo&&(u+=` in week ${s(t.byWeekNo.map(String))}`),t.byYearDay&&(u+=` on day ${s(t.byYearDay.map(String))} of the year`),t.byMonthDay&&(u+=` on the ${s(t.byMonthDay.map(c=>c===-1?"last day":c<0?`${U(-c,"en")}-to-last day`:U(c,"en")))}`);let m=t.byDay&&t.byDay.every(c=>!c.n),d=m&&t.byDay.map(c=>c.w).sort().join()==="1,2,3,4,5";if(t.bySetPos&&m&&!t.byMonthDay){let c=d?"weekday":le(t.byDay.map(f=>n.weekdays[f.w]),"en","disjunction");u+=` on the ${s(t.bySetPos.map(f=>a[f]??U(f,"en")))} ${c}`}else{if(t.byDay&&u!=="every weekday"){let c=t.byDay.map(f=>(f.n?`${a[f.n]??U(Math.abs(f.n),"en")+(f.n<0?" last":"")} `:"")+n.weekdays[f.w]);u+=`${t.byMonthDay?" if it is":" on"} ${t.byDay.some(f=>f.n)?"the ":""}${s(c)}`}t.bySetPos&&(u+=` (occurrence ${s(t.bySetPos.map(String))} of each ${i})`)}if(!this.allDay&&t.freq<=qe){let c=this.#n,f=this.#s().slice(0,6).map(h=>{let y=M(2e3,0,1)+h;return g(y,{zone:"UTC",locale:e}).format(c.bySecond.some(b=>b)?"LTS":"LT")});u+=` at ${s(f)}`}return t.untilMs!==void 0&&(u+=` until ${g(t.untilMs,{zone:this.tz,locale:e}).format("LL")}`),t.count!==void 0&&(u+=`, ${t.count} time${t.count===1?"":"s"}`),u}},ln=/^(\d{4})(\d{2})(\d{2})(?:T(\d{2})(\d{2})(\d{2})(Z)?)?$/i;function Be(r,e){let t=ln.exec(r.trim());if(!t)throw new RangeError(`neram: invalid iCalendar date "${r}"`);let n=!t[4],s=n?`${t[1]}-${t[2]}-${t[3]}`:`${t[1]}-${t[2]}-${t[3]}T${t[4]}:${t[5]}:${t[6]}`,i=!!t[7];return{value:i?g(`${s}Z`,{zone:e??"UTC"}):g(s,{zone:e??"UTC"}),dateOnly:n,utc:i}}function je(r,e={}){let t=r.replace(/\r?\n[ \t]/g,"").split(/\r?\n|\\n/).map(m=>m.trim()).filter(Boolean),n={},s=e.tz,i=!1,a=[],u=[],o=[];for(let m of t){let d=m.indexOf(":"),c=d<0||/^FREQ=/i.test(m),f=c?"RRULE":m.slice(0,d),h=c?m:m.slice(d+1),[y,...b]=f.split(";"),p={};for(let w of b){let k=w.indexOf("=");p[w.slice(0,k).toUpperCase()]=w.slice(k+1).replace(/^"|"$/g,"")}let D=y.toUpperCase();if(D==="RRULE"){if(i)throw new RangeError("neram: only one RRULE per rule is supported; use several rules for more");i=!0;for(let w of h.split(";").filter(Boolean)){let k=w.indexOf("=");if(k<1)throw new RangeError(`neram: invalid RRULE part "${w}"`);let T=w.slice(0,k).toUpperCase(),R=w.slice(k+1),V=()=>R.split(",").map(Number);switch(T){case"FREQ":n.freq=R.toLowerCase();break;case"INTERVAL":n.interval=Number(R);break;case"COUNT":n.count=Number(R);break;case"UNTIL":n.until=R;break;case"WKST":n.wkst=R.toUpperCase();break;case"BYMONTH":n.byMonth=V();break;case"BYWEEKNO":n.byWeekNo=V();break;case"BYYEARDAY":n.byYearDay=V();break;case"BYMONTHDAY":n.byMonthDay=V();break;case"BYDAY":n.byDay=R.split(",");break;case"BYHOUR":n.byHour=V();break;case"BYMINUTE":n.byMinute=V();break;case"BYSECOND":n.bySecond=V();break;case"BYSETPOS":n.bySetPos=V();break;default:if(T.startsWith("X-"))break;throw new RangeError(`neram: unsupported RRULE part "${T}"`)}}}else(D==="DTSTART"||D==="RDATE"||D==="EXDATE")&&o.push({name:D,params:p,values:h.split(",")})}for(let m of o){if(m.name!=="DTSTART")continue;m.params.TZID&&(s??=m.params.TZID);let d=Be(m.values[0],s);d.utc&&!s&&(s="UTC"),n.dtstart=d.value,(d.dateOnly||m.params.VALUE?.toUpperCase()==="DATE")&&(n.allDay=!0)}for(let m of o){if(m.name==="DTSTART")continue;let d=m.params.TZID??s;for(let c of m.values)(m.name==="RDATE"?a:u).push(Be(c,d).value)}if(typeof n.until=="string"){let m=Be(n.until,s);n.until=m.dateOnly?m.value.format("YYYY-MM-DD"):m.value}if(!i&&!e.freq)throw new RangeError("neram: no RRULE found");if(i&&n.freq===void 0&&!e.freq)throw new RangeError("neram: RRULE has no FREQ");let l={...n,...e};if(s&&(l.tz=s),(a.length||e.rdate)&&(l.rdate=[...a,...e.rdate??[]]),(u.length||e.exdate)&&(l.exdate=[...u,...e.exdate??[]]),l.dtstart===void 0)throw new RangeError("neram: no DTSTART; pass { dtstart } as the second argument");return l}function At(r,e={}){return typeof r=="string"?new ue(je(r,e)):new ue({...r,...e})}var dn={"@yearly":"0 0 1 1 *","@annually":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *"},Yt=["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"],xt=["SUN","MON","TUE","WED","THU","FRI","SAT"];function me(r,e,t,n,s){let i=new Set,a=r.startsWith("*")||r==="?",u=o=>{let l=o.toUpperCase(),m=s?s.indexOf(l):-1,d=m>=0?m+(s===Yt?1:0):Number(o);if(!/^\d+$/.test(o)&&m<0)throw new RangeError(`neram: invalid cron ${e} "${o}"`);return d};for(let o of r.split(",")){if(!o)throw new RangeError(`neram: empty item in cron ${e}`);let[l,m]=o.split("/"),d=m===void 0?1:Number(m);if(!Number.isInteger(d)||d<1)throw new RangeError(`neram: invalid cron step "${o}"`);let c,f;if(l==="*"||l==="?")c=t,f=n;else if(l.includes("-")){let[y,b]=l.split("-");c=u(y),f=u(b)}else c=u(l),f=m===void 0?c:n;let h=y=>{if(y<t||y>n)throw new RangeError(`neram: cron ${e} value ${y} is out of range ${t}-${n}`)};if(h(c),h(f),c<=f)for(let y=c;y<=f;y+=d)i.add(y);else{let y=n-t+1,b=(f-c+y)%y;for(let p=0;p<=b;p+=d)i.add(t+(c-t+p)%y)}}return{values:i,any:a}}var De=class extends K{tz;allDay=!1;expression;hasSeconds;#e;#n;#r;#o;#c;#u;#t={last:[],nearestWeekday:[],lastWeekday:!1};#a={nth:[],last:[]};#s;#i;constructor(e,t={}){super(),this.expression=e.trim(),this.tz=x(t.tz??g().timezone());let s=(dn[this.expression.toLowerCase()]??this.expression).split(/\s+/);if(s.length!==5&&s.length!==6)throw new RangeError(`neram: cron needs 5 or 6 fields, got ${s.length} in "${e}"`);this.hasSeconds=s.length===6;let[i,a,u,o,l,m]=this.hasSeconds?s:["0",...s];this.#e=me(i,"second",0,59),this.#n=me(a,"minute",0,59),this.#r=me(u,"hour",0,23),this.#c=me(l,"month",1,12,Yt);let d=[];for(let f of o.split(",")){let h=f.toUpperCase(),y;if(h==="L")this.#t.last.push(0);else if(y=/^L-(\d+)$/.exec(h)){if(Number(y[1])>30)throw new RangeError(`neram: invalid cron day of month "${f}" (L-n needs n from 0 to 30)`);this.#t.last.push(Number(y[1]))}else if(h==="LW")this.#t.lastWeekday=!0;else if(y=/^(\d+)W$/.exec(h)){let b=Number(y[1]);if(b<1||b>31)throw new RangeError(`neram: invalid cron day of month "${f}" (nW needs n from 1 to 31)`);this.#t.nearestWeekday.push(b)}else d.push(f)}this.#o=d.length?me(d.join(","),"day of month",1,31):{values:new Set,any:!1},d.length!==o.split(",").length&&(this.#o.any=!1);let c=[];for(let f of m.split(",")){let h=f.toUpperCase(),y=p=>{let D=xt.indexOf(p),w=D>=0?D:Number(p);if(!Number.isInteger(w)||w<0||w>7)throw new RangeError(`neram: invalid cron weekday "${p}"`);return w%7},b;(b=/^(\w+)#([1-5])$/.exec(h))?this.#a.nth.push([y(b[1]),Number(b[2])]):(b=/^(\w+)L$/.exec(h))?this.#a.last.push(y(b[1])):c.push(f)}this.#u=c.length?me(c.join(","),"day of week",0,7,xt):{values:new Set,any:!1},c.length!==m.split(",").length&&(this.#u.any=!1),this.#u.values.delete(7)&&this.#u.values.add(0),this.#s=t.start===void 0?void 0:this.coerce(t.start),this.#i=t.end===void 0?void 0:this.coerce(t.end)}isInfinite(){return this.#i===void 0}startMs(){return this.#s??Date.now()}#d(e,t,n){let s=(Math.floor(M(e,t,n)/864e5)%7+11)%7,i=S(e,t),a=()=>{if(this.#o.values.has(n)||this.#t.last.some(l=>n===i-l))return!0;let o=l=>{let m=Math.min(l,i),d=new Date(M(e,t,m)).getUTCDay();return d===6?m=m===1?3:m-1:d===0&&(m=m===i?m-2:m+1),m};if(this.#t.nearestWeekday.some(l=>n===o(l)))return!0;if(this.#t.lastWeekday){let l=i;for(;[0,6].includes(new Date(M(e,t,l)).getUTCDay());)l--;if(n===l)return!0}return!1},u=()=>this.#u.values.has(s)||this.#a.nth.some(([o,l])=>o===s&&Math.floor((n-1)/7)+1===l)||this.#a.last.some(o=>o===s&&n+7>i);return this.#o.any||this.#u.any?a()&&u():a()||u()}#f(e){let t=new Date(e).getUTCFullYear()+400;for(;;){let{y:n,M:s,D:i,h:a,m:u,s:o}=ie(e);if(n>t||n>9999)return null;if(!this.#c.values.has(s+1)){e=M(n,s+1,1);continue}if(!this.#d(n,s,i)){e=M(n,s,i+1);continue}if(!this.#r.values.has(a)){e=M(n,s,i,a+1);continue}if(!this.#n.values.has(u)){e=M(n,s,i,a,u+1);continue}if(!this.#e.values.has(o)){e=M(n,s,i,a,u,o+1);continue}return e}}*iterate(e){let t=e;this.#s!==void 0&&(t=Math.max(t,this.#s)),Number.isFinite(t)||(t=Date.now());let n=this.hasSeconds?1e3:6e4,s=g(t,{zone:this.tz}),[i,a,u,o,l,m,d]=s.toArray(),c=M(i,a,u,o,l,this.hasSeconds?m:0);(d>0||!this.hasSeconds&&(m>0||d>0))&&(c+=n);let f=-1/0;for(;;){let h=this.#f(c);if(h===null)return;let y=C(ie(h),this.tz);if(c=h+n,!(y<t||y<=f)){if(this.#i!==void 0&&y>this.#i)return;f=y,yield y}}}toString(){return this.expression}toJSON(){return{expression:this.expression,tz:this.tz}}};function Et(r,e={}){return new De(r,e)}Object.assign(g,{Neram:$,Duration:Z,recur:{...Ve}});globalThis.neram=g;})();
@@ -0,0 +1,14 @@
1
+ import { type Wall } from './zone.ts';
2
+ /** What a string parses into, before a time zone turns it into an instant. */
3
+ export type Parsed = {
4
+ kind: 'epoch';
5
+ ms: number;
6
+ } | {
7
+ kind: 'wall';
8
+ wall: Wall;
9
+ offset?: number;
10
+ zone?: string;
11
+ };
12
+ export declare function parseISO(str: string): Parsed | undefined;
13
+ export declare function parseString(str: string): Parsed;
14
+ export declare function parseFormat(input: string, format: string, locale: string): Parsed;
package/dist/parse.js ADDED
@@ -0,0 +1,278 @@
1
+ import { daysInMonth } from './calendar.js';
2
+ import { localeData } from './locale.js';
3
+ import { parseOffset } from './zone.js';
4
+ const INVALID = { kind: 'epoch', ms: NaN };
5
+ // ISO 8601 / RFC 3339 / RFC 9557 (Temporal): 2026-12-04T10:30:00.123+05:30[Asia/Kolkata]
6
+ const ISO_RE = /^([+-]\d{6}|\d{4})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[T\s](\d{2})(?::?(\d{2})(?::?(\d{2})(?:[.,](\d{1,9}))?)?)?)?\s*(Z|[+-]\d{2}(?::?\d{2})?)?(?:\[!?([^\]=]+)\])?(?:\[[^\]]*\])*$/i;
7
+ function validWall(w) {
8
+ return (w.M >= 0 && w.M <= 11 &&
9
+ w.D >= 1 && w.D <= daysInMonth(w.y, w.M) &&
10
+ w.h >= 0 && (w.h < 24 || (w.h === 24 && w.m === 0 && w.s === 0 && w.ms === 0)) &&
11
+ w.m >= 0 && w.m < 60 &&
12
+ w.s >= 0 && w.s < 61 &&
13
+ w.ms >= 0 && w.ms < 1000);
14
+ }
15
+ /** Two ASCII digits at i as a number, or -1. */
16
+ function d2(s, i) {
17
+ const a = s.charCodeAt(i) - 48;
18
+ const b = s.charCodeAt(i + 1) - 48;
19
+ return a >= 0 && a <= 9 && b >= 0 && b <= 9 ? a * 10 + b : -1;
20
+ }
21
+ /**
22
+ * Hand-written parser for the shapes apps send most: 2026-12-04, 2026-12-04T09:00,
23
+ * 2026-12-04T09:00:00, with optional .fraction and Z or ±HH:mm. About 4x faster than the regex;
24
+ * anything else returns undefined and goes to the full parser.
25
+ */
26
+ function fastISO(s) {
27
+ const len = s.length;
28
+ if (len < 10 || s.charCodeAt(4) !== 45 || s.charCodeAt(7) !== 45)
29
+ return undefined;
30
+ const yHi = d2(s, 0);
31
+ const yLo = d2(s, 2);
32
+ const M = d2(s, 5);
33
+ const D = d2(s, 8);
34
+ if (yHi < 0 || yLo < 0 || M < 0 || D < 0)
35
+ return undefined;
36
+ let h = 0, m = 0, sec = 0, ms = 0;
37
+ let offset;
38
+ let i = 10;
39
+ if (i < len) {
40
+ const t = s.charCodeAt(i);
41
+ if ((t !== 84 && t !== 116 && t !== 32) || len < 16 || s.charCodeAt(13) !== 58)
42
+ return undefined; // T t space, ':'
43
+ h = d2(s, 11);
44
+ m = d2(s, 14);
45
+ if (h < 0 || m < 0)
46
+ return undefined;
47
+ i = 16;
48
+ if (s.charCodeAt(i) === 58) {
49
+ sec = d2(s, 17);
50
+ if (sec < 0)
51
+ return undefined;
52
+ i = 19;
53
+ if (s.charCodeAt(i) === 46) { // '.'
54
+ let j = i + 1;
55
+ let frac = 0;
56
+ let digits = 0;
57
+ for (; j < len; j++) {
58
+ const c = s.charCodeAt(j) - 48;
59
+ if (c < 0 || c > 9)
60
+ break;
61
+ if (digits < 3)
62
+ frac = frac * 10 + c;
63
+ digits++;
64
+ }
65
+ if (digits === 0 || digits > 9)
66
+ return undefined;
67
+ ms = digits === 1 ? frac * 100 : digits === 2 ? frac * 10 : frac;
68
+ i = j;
69
+ }
70
+ }
71
+ if (i < len) {
72
+ const c = s.charCodeAt(i);
73
+ if ((c === 90 || c === 122) && i === len - 1) { // Z z
74
+ offset = 0;
75
+ i++;
76
+ }
77
+ else if ((c === 43 || c === 45) && len - i === 6 && s.charCodeAt(i + 3) === 58) { // +HH:mm / -HH:mm
78
+ const oh = d2(s, i + 1);
79
+ const om = d2(s, i + 4);
80
+ if (oh < 0 || om < 0)
81
+ return undefined;
82
+ if (oh > 23 || om > 59)
83
+ return INVALID;
84
+ offset = (c === 45 ? -1 : 1) * (oh * 60 + om);
85
+ i = len;
86
+ }
87
+ else {
88
+ return undefined;
89
+ }
90
+ }
91
+ }
92
+ const wall = { y: yHi * 100 + yLo, M: M - 1, D, h, m, s: sec, ms };
93
+ if (!validWall(wall))
94
+ return INVALID;
95
+ if (wall.s === 60)
96
+ wall.s = 59;
97
+ return { kind: 'wall', wall, offset };
98
+ }
99
+ export function parseISO(str) {
100
+ const fast = fastISO(str);
101
+ if (fast)
102
+ return fast;
103
+ const m = ISO_RE.exec(str.trim());
104
+ if (!m)
105
+ return undefined;
106
+ const wall = {
107
+ y: Number(m[1]),
108
+ M: m[2] ? Number(m[2]) - 1 : 0,
109
+ D: m[3] ? Number(m[3]) : 1,
110
+ h: m[4] ? Number(m[4]) : 0,
111
+ m: m[5] ? Number(m[5]) : 0,
112
+ s: m[6] ? Number(m[6]) : 0,
113
+ ms: m[7] ? Math.floor(Number(`0.${m[7]}`) * 1000) : 0,
114
+ };
115
+ if (!validWall(wall))
116
+ return INVALID;
117
+ if (wall.s === 60)
118
+ wall.s = 59; // leap second: clamp
119
+ const offset = m[8] ? parseOffset(m[8].replace(/^([+-]\d{2})$/, '$1:00')) : undefined;
120
+ if (m[8] && offset === undefined)
121
+ return INVALID;
122
+ return { kind: 'wall', wall, offset, zone: m[9] };
123
+ }
124
+ export function parseString(str) {
125
+ const iso = parseISO(str);
126
+ if (iso)
127
+ return iso;
128
+ const native = Date.parse(str);
129
+ return Number.isNaN(native) ? INVALID : { kind: 'epoch', ms: native };
130
+ }
131
+ // ---------------------------------------------------------------------------
132
+ // Custom formats: neram('04/12/2026 3:15 PM', 'DD/MM/YYYY h:mm A')
133
+ // ---------------------------------------------------------------------------
134
+ const PARSE_TOKEN = /\[([^\]]*)\]|YYYY|YY|MMMM|MMM|MM|M|Do|DD|D|dddd|ddd|dd|HH|H|hh|h|kk|k|mm|m|ss|s|S{1,3}|A|a|ZZ|Z|X|x/g;
135
+ function escapeRe(s) {
136
+ return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
137
+ }
138
+ function namesRe(names) {
139
+ return `(${[...names].sort((a, b) => b.length - a.length).map(escapeRe).join('|')})`;
140
+ }
141
+ const num = (k) => (v, a) => {
142
+ ;
143
+ a[k] = Number(v);
144
+ };
145
+ export function parseFormat(input, format, locale) {
146
+ const ld = localeData(locale);
147
+ const setters = [];
148
+ let pattern = '';
149
+ let last = 0;
150
+ for (const match of format.matchAll(PARSE_TOKEN)) {
151
+ pattern += escapeRe(format.slice(last, match.index)).replace(/\s+/g, '\\s+');
152
+ last = match.index + match[0].length;
153
+ const tok = match[0];
154
+ if (match[1] !== undefined) {
155
+ pattern += escapeRe(match[1]);
156
+ continue;
157
+ }
158
+ switch (tok) {
159
+ case 'YYYY':
160
+ pattern += '([+-]?\\d{4,6})';
161
+ setters.push(num('y'));
162
+ break;
163
+ case 'YY':
164
+ pattern += '(\\d{2})';
165
+ setters.push((v, a) => {
166
+ const n = Number(v);
167
+ a.y = n + (n > 68 ? 1900 : 2000);
168
+ });
169
+ break;
170
+ case 'MMMM':
171
+ case 'MMM': {
172
+ pattern += namesRe([...ld.months, ...ld.monthsShort]);
173
+ setters.push((v, a) => {
174
+ const lv = v.toLowerCase();
175
+ let i = ld.months.findIndex((n) => n.toLowerCase() === lv);
176
+ if (i < 0)
177
+ i = ld.monthsShort.findIndex((n) => n.toLowerCase() === lv);
178
+ a.M = i + 1;
179
+ });
180
+ break;
181
+ }
182
+ case 'MM':
183
+ case 'M':
184
+ pattern += tok === 'MM' ? '(\\d{2})' : '(\\d{1,2})';
185
+ setters.push(num('M'));
186
+ break;
187
+ case 'Do':
188
+ pattern += '(\\d{1,2})(?:st|nd|rd|th|\\.)?';
189
+ setters.push(num('D'));
190
+ break;
191
+ case 'DD':
192
+ case 'D':
193
+ pattern += tok === 'DD' ? '(\\d{2})' : '(\\d{1,2})';
194
+ setters.push(num('D'));
195
+ break;
196
+ case 'dddd':
197
+ case 'ddd':
198
+ case 'dd':
199
+ pattern += namesRe([...ld.weekdays, ...ld.weekdaysShort, ...ld.weekdaysMin]);
200
+ setters.push(() => { });
201
+ break;
202
+ case 'HH':
203
+ case 'H':
204
+ case 'hh':
205
+ case 'h':
206
+ case 'kk':
207
+ case 'k':
208
+ pattern += tok.length === 2 ? '(\\d{2})' : '(\\d{1,2})';
209
+ setters.push(tok[0] === 'k' ? (v, a) => { a.h = Number(v) % 24; } : num('h'));
210
+ break;
211
+ case 'mm':
212
+ case 'm':
213
+ pattern += tok === 'mm' ? '(\\d{2})' : '(\\d{1,2})';
214
+ setters.push(num('m'));
215
+ break;
216
+ case 'ss':
217
+ case 's':
218
+ pattern += tok === 'ss' ? '(\\d{2})' : '(\\d{1,2})';
219
+ setters.push(num('s'));
220
+ break;
221
+ case 'A':
222
+ case 'a':
223
+ pattern += `(${escapeRe(ld.meridiem[0])}|${escapeRe(ld.meridiem[1])}|am|pm|a\\.m\\.|p\\.m\\.)`;
224
+ setters.push((v, a) => {
225
+ const lv = v.toLowerCase();
226
+ a.pm = lv === ld.meridiem[1].toLowerCase() || lv.startsWith('p');
227
+ });
228
+ break;
229
+ case 'ZZ':
230
+ case 'Z':
231
+ pattern += '(Z|[+-]\\d{2}:?\\d{2})';
232
+ setters.push((v, a) => { a.offset = parseOffset(v) ?? NaN; });
233
+ break;
234
+ case 'X':
235
+ pattern += '(-?\\d+(?:\\.\\d+)?)';
236
+ setters.push((v, a) => { a.epoch = Number(v) * 1000; });
237
+ break;
238
+ case 'x':
239
+ pattern += '(-?\\d+)';
240
+ setters.push((v, a) => { a.epoch = Number(v); });
241
+ break;
242
+ default:
243
+ // S, SS, SSS — fractional seconds
244
+ pattern += `(\\d{1,${tok.length}})`;
245
+ setters.push((v, a) => { a.ms = Math.round(Number(`0.${v}`) * 1000); });
246
+ }
247
+ }
248
+ pattern += escapeRe(format.slice(last)).replace(/\s+/g, '\\s+');
249
+ const m = new RegExp(`^\\s*${pattern}\\s*$`, 'i').exec(input);
250
+ if (!m)
251
+ return INVALID;
252
+ const acc = {};
253
+ setters.forEach((set, i) => set(m[i + 1], acc));
254
+ if (acc.epoch !== undefined)
255
+ return { kind: 'epoch', ms: acc.epoch };
256
+ let h = acc.h ?? 0;
257
+ if (acc.pm !== undefined) {
258
+ if (h < 1 || h > 12)
259
+ return INVALID;
260
+ if (acc.pm && h < 12)
261
+ h += 12;
262
+ if (!acc.pm && h === 12)
263
+ h = 0;
264
+ }
265
+ const now = new Date();
266
+ const wall = {
267
+ y: acc.y ?? now.getFullYear(),
268
+ M: acc.M !== undefined ? acc.M - 1 : acc.y !== undefined ? 0 : now.getMonth(),
269
+ D: acc.D ?? 1,
270
+ h,
271
+ m: acc.m ?? 0,
272
+ s: acc.s ?? 0,
273
+ ms: acc.ms ?? 0,
274
+ };
275
+ if (!validWall(wall))
276
+ return INVALID;
277
+ return { kind: 'wall', wall, offset: acc.offset };
278
+ }
@@ -0,0 +1,41 @@
1
+ import { type NeramInput } from '../neram.ts';
2
+ import { Schedule } from './schedule.ts';
3
+ export interface CronOptions {
4
+ /** Zone the expression is read in. Default: neram's default zone (local). */
5
+ tz?: string;
6
+ /** Ignore occurrences before this. Also where all() starts (default: now). */
7
+ start?: NeramInput;
8
+ /** Last allowed occurrence (inclusive). */
9
+ end?: NeramInput;
10
+ }
11
+ /**
12
+ * A cron schedule. 5 fields (minute hour day-of-month month day-of-week) or 6 with seconds first.
13
+ * Supports * , - / names (JAN, MON), 7 = Sunday, @daily-style macros, and Quartz extras:
14
+ * L (last day), L-2, 15W (nearest weekday), LW, 5L (last Friday), 5#3 (third Friday).
15
+ * When both day-of-month and day-of-week are set, either may match (standard cron).
16
+ *
17
+ * Times are wall-clock times in `tz`: a time skipped by DST runs at the shifted time
18
+ * (02:30 → 03:30), and a time repeated by DST runs once.
19
+ */
20
+ export declare class Cron extends Schedule {
21
+ #private;
22
+ readonly tz: string;
23
+ readonly allDay = false;
24
+ readonly expression: string;
25
+ readonly hasSeconds: boolean;
26
+ constructor(expression: string, opts?: CronOptions);
27
+ isInfinite(): boolean;
28
+ protected startMs(): number;
29
+ protected iterate(fromMs: number): Generator<number>;
30
+ toString(): string;
31
+ toJSON(): {
32
+ expression: string;
33
+ tz: string;
34
+ };
35
+ }
36
+ /**
37
+ * Create a cron schedule.
38
+ * cron('0 9 * * MON-FRI', { tz: 'Asia/Kolkata' }).take(5, { as: 'iso' })
39
+ * cron('0 0 L * *', { tz: 'Europe/London' }).after()
40
+ */
41
+ export declare function cron(expression: string, opts?: CronOptions): Cron;