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