import{t as m,c as D,m as N,b as g}from"./format-KhiMdRwp.js";function T(t,e){const n=m(t);return isNaN(e)?D(t,NaN):(e&&n.setDate(n.getDate()+e),n)}function S(t,e){const n=m(t);if(isNaN(e))return D(t,NaN);if(!e)return n;const r=n.getDate(),a=D(t,n.getTime());a.setMonth(n.getMonth()+e+1,0);const i=a.getDate();return r>=i?a:(n.setFullYear(a.getFullYear(),a.getMonth(),r),n)}function $(t,e){const n=e*7;return T(t,n)}function _(t,e){const r=M(t);let a;if(r.date){const s=y(r.date,2);a=C(s.restDateString,s.year)}if(!a||isNaN(a.getTime()))return new Date(NaN);const i=a.getTime();let o=0,c;if(r.time&&(o=I(r.time),isNaN(o)))return new Date(NaN);if(r.timezone){if(c=Y(r.timezone),isNaN(c))return new Date(NaN)}else{const s=new Date(i+o),u=new Date(0);return u.setFullYear(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate()),u.setHours(s.getUTCHours(),s.getUTCMinutes(),s.getUTCSeconds(),s.getUTCMilliseconds()),u}return new Date(i+o+c)}const f={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},h=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,U=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,w=/^([+-])(\d{2})(?::?(\d{2}))?$/;function M(t){const e={},n=t.split(f.dateTimeDelimiter);let r;if(n.length>2)return e;if(/:/.test(n[0])?r=n[0]:(e.date=n[0],r=n[1],f.timeZoneDelimiter.test(e.date)&&(e.date=t.split(f.timeZoneDelimiter)[0],r=t.substr(e.date.length,t.length))),r){const a=f.timezone.exec(r);a?(e.time=r.replace(a[1],""),e.timezone=a[1]):e.time=r}return e}function y(t,e){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+e)+"})|(\\d{2}|[+-]\\d{"+(2+e)+"})$)"),r=t.match(n);if(!r)return{year:NaN,restDateString:""};const a=r[1]?parseInt(r[1]):null,i=r[2]?parseInt(r[2]):null;return{year:i===null?a:i*100,restDateString:t.slice((r[1]||r[2]).length)}}function C(t,e){if(e===null)return new Date(NaN);const n=t.match(h);if(!n)return new Date(NaN);const r=!!n[4],a=l(n[1]),i=l(n[2])-1,o=l(n[3]),c=l(n[4]),s=l(n[5])-1;if(r)return k(e,c,s)?x(e,c,s):new Date(NaN);{const u=new Date(0);return!O(e,i,o)||!z(e,a)?new Date(NaN):(u.setUTCFullYear(e,i,Math.max(a,o)),u)}}function l(t){return t?parseInt(t):1}function I(t){const e=t.match(U);if(!e)return NaN;const n=d(e[1]),r=d(e[2]),a=d(e[3]);return W(n,r,a)?n*N+r*g+a*1e3:NaN}function d(t){return t&&parseFloat(t.replace(",","."))||0}function Y(t){if(t==="Z")return 0;const e=t.match(w);if(!e)return 0;const n=e[1]==="+"?-1:1,r=parseInt(e[2]),a=e[3]&&parseInt(e[3])||0;return Z(r,a)?n*(r*N+a*g):NaN}function x(t,e,n){const r=new Date(0);r.setUTCFullYear(t,0,4);const a=r.getUTCDay()||7,i=(e-1)*7+n+1-a;return r.setUTCDate(r.getUTCDate()+i),r}const F=[31,null,31,30,31,30,31,31,30,31,30,31];function p(t){return t%400===0||t%4===0&&t%100!==0}function O(t,e,n){return e>=0&&e<=11&&n>=1&&n<=(F[e]||(p(t)?29:28))}function z(t,e){return e>=1&&e<=(p(t)?366:365)}function k(t,e,n){return e>=1&&e<=53&&n>=0&&n<=6}function W(t,e,n){return t===24?e===0&&n===0:n>=0&&n<60&&e>=0&&e<60&&t>=0&&t<25}function Z(t,e){return e>=0&&e<=59}export{T as a,S as b,$ as c,_ as p};
//# sourceMappingURL=parseISO-7GFRGhFN.js.map
