import{dP as D,dQ as p}from"./index-BKr2rJhV.js";import{r as d}from"./vendor-react-wBh_31cN.js";function F(t,e){const r=U(t);let a;if(r.date){const s=w(r.date,2);a=h(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=C(r.time),isNaN(o)))return new Date(NaN);if(r.timezone){if(c=x(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+-].*)$/},g=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,T=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,I=/^([+-])(\d{2})(?::?(\d{2}))?$/;function U(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 w(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 h(t,e){if(e===null)return new Date(NaN);const n=t.match(g);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 R(e,c,s)?Y(e,c,s):new Date(NaN);{const u=new Date(0);return!y(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 C(t){const e=t.match(T);if(!e)return NaN;const n=m(e[1]),r=m(e[2]),a=m(e[3]);return v(n,r,a)?n*D+r*p+a*1e3:NaN}function m(t){return t&&parseFloat(t.replace(",","."))||0}function x(t){if(t==="Z")return 0;const e=t.match(I);if(!e)return 0;const n=e[1]==="+"?-1:1,r=parseInt(e[2]),a=e[3]&&parseInt(e[3])||0;return M(r,a)?n*(r*D+a*p):NaN}function Y(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 k=[31,null,31,30,31,30,31,31,30,31,30,31];function N(t){return t%400===0||t%4===0&&t%100!==0}function y(t,e,n){return e>=0&&e<=11&&n>=1&&n<=(k[e]||(N(t)?29:28))}function z(t,e){return e>=1&&e<=(N(t)?366:365)}function R(t,e,n){return e>=1&&e<=53&&n>=0&&n<=6}function v(t,e,n){return t===24?e===0&&n===0:n>=0&&n<60&&e>=0&&e<60&&t>=0&&t<25}function M(t,e){return e>=0&&e<=59}const S=(t,e)=>{const n=d.useRef(null);d.useEffect(()=>{n.current=t}),d.useEffect(()=>{const a=setInterval(()=>{typeof n.current=="function"&&n.current()},e);return()=>clearInterval(a)},[e])};export{F as p,S as u};
