iobroker.javascript
Version:
Rules Engine for ioBroker
2 lines (1 loc) • 33.9 kB
JavaScript
import{X as d,w as re,y as E,Y as g,Z as w,_ as R,$ as j,a0 as S,a1 as ye,i as F,d as B,a2 as L,a3 as Y,a4 as ne,q as $,a5 as q,a6 as H,k as Oe,t as Se,A as Te,x as ae,o as ue,s as Ce,j as Ee,u as Re,a7 as _,e as P,a8 as J,a9 as b,aa as ie,ab as O,f as Ue,ac as ze,E as Qe,ad as Ie,ae as ce,af as se,ag as Ae,ah as je,ai as qe,aj as Xe,ak as Ze,p as Le,W as Ye,g as Je,c as Be,b as Pe,al as Ge,am as V,an as ke,ao as Ne,ap as we,aq as _e,K as We,ar as Ke,as as he,r as Ve,z as oe,at as pe,B as et,v as tt}from"./isSameWeek-DDsSIa_t.js";import{au as Wa,av as Fa,Q as Ha,aw as xa,F as va,ax as $a,ay as ba,I as Ca,G as Ea,D as Ra,H as Ua,R as za,az as Qa,C as Aa,h as ja,m as qa,aA as Xa,a as Za,n as La,l as Ja,aB as Ba,L as Pa,aC as Ga,M as Ka,aD as Va,aE as oa,P as pa,N as eu,O as tu,aF as ru,J as nu,aG as au,aH as uu}from"./isSameWeek-DDsSIa_t.js";function U(r,e,t){const{years:n=0,months:a=0,weeks:u=0,days:c=0,hours:s=0,minutes:f=0,seconds:l=0}=e,i=d(r,t==null?void 0:t.in),h=a||n?re(i,a+n*12):i,m=c||u?E(h,c+u*7):h,D=f+s*60,y=(l+D*60)*1e3;return g((t==null?void 0:t.in)||r,+m+y)}function rt(r,e){return d(r,e==null?void 0:e.in).getDay()===6}function nt(r,e){return d(r,e==null?void 0:e.in).getDay()===0}function Q(r,e){const t=d(r,e==null?void 0:e.in).getDay();return t===0||t===6}function at(r,e,t){const n=d(r,t==null?void 0:t.in),a=Q(n,t);if(isNaN(e))return g(t==null?void 0:t.in,NaN);const u=n.getHours(),c=e<0?-1:1,s=Math.trunc(e/5);n.setDate(n.getDate()+s*7);let f=Math.abs(e%5);for(;f>0;)n.setDate(n.getDate()+c),Q(n,t)||(f-=1);return a&&Q(n,t)&&e!==0&&(rt(n,t)&&n.setDate(n.getDate()+(c<0?2:-1)),nt(n,t)&&n.setDate(n.getDate()+(c<0?1:-2))),n.setHours(u),n}function ut(r,e,t){let n=d(r,t==null?void 0:t.in);const a=w(n,R(n,t)),u=g((t==null?void 0:t.in)||r,0);return u.setFullYear(e,0,4),u.setHours(0,0,0,0),n=R(u),n.setDate(n.getDate()+a),n}function ct(r,e,t){return ut(r,j(r,t)+e,t)}function Fe(r,e,t){return re(r,e*3,t)}function Vt(r,e,t){const[n,a]=[+d(r.start,t==null?void 0:t.in),+d(r.end,t==null?void 0:t.in)].sort((s,f)=>s-f),[u,c]=[+d(e.start,t==null?void 0:t.in),+d(e.end,t==null?void 0:t.in)].sort((s,f)=>s-f);return t!=null&&t.inclusive?n<=c&&u<=a:n<c&&u<a}function st(r,e){let t,n=e==null?void 0:e.in;return r.forEach(a=>{!n&&typeof a=="object"&&(n=g.bind(null,a));const u=d(a,n);(!t||t<u||isNaN(+u))&&(t=u)}),g(n,t||NaN)}function ft(r,e){let t,n=e==null?void 0:e.in;return r.forEach(a=>{!n&&typeof a=="object"&&(n=g.bind(null,a));const u=d(a,n);(!t||t>u||isNaN(+u))&&(t=u)}),g(n,t||NaN)}function ot(r,e,t){const[n,a,u]=S(t==null?void 0:t.in,r,e.start,e.end);return ft([st([n,a],t),u],t)}function lt(r,e){const t=+d(r);if(isNaN(t))return NaN;let n,a;return e.forEach((u,c)=>{const s=d(u);if(isNaN(+s)){n=NaN,a=NaN;return}const f=Math.abs(t-+s);(n==null||f<a)&&(n=c,a=f)}),n}function pt(r,e,t){const[n,...a]=S(t==null?void 0:t.in,r,...e),u=lt(n,a);if(typeof u=="number"&&isNaN(u))return g(n,NaN);if(u!==void 0)return a[u]}function k(r,e){const t=+d(r)-+d(e);return t<0?-1:t>0?1:t}function er(r,e){const t=+d(r)-+d(e);return t>0?-1:t<0?1:t}function T(r){return g(r,Date.now())}function tr(r){const e=Math.trunc(r/ye);return e===0?0:e}function rr(r,e,t){const[n,a]=S(t==null?void 0:t.in,r,e);if(!F(n)||!F(a))return NaN;const u=w(n,a),c=u<0?-1:1,s=Math.trunc(u/7);let f=s*5,l=E(a,s*7);for(;!B(n,l);)f+=Q(l,t)?0:c,l=E(l,c);return f===0?0:f}function dt(r,e,t){const[n,a]=S(t==null?void 0:t.in,r,e);return j(n,t)-j(a,t)}function nr(r,e,t){const[n,a]=S(t==null?void 0:t.in,r,e),u=L(n),c=L(a),s=+u-Y(u),f=+c-Y(c);return Math.round((s-f)/ne)}function o(r,e,t){const[n,a]=S(t==null?void 0:t.in,r,e),u=n.getFullYear()-a.getFullYear(),c=n.getMonth()-a.getMonth();return u*12+c}function me(r,e){const t=d(r,e==null?void 0:e.in);return Math.trunc(t.getMonth()/3)+1}function G(r,e,t){const[n,a]=S(t==null?void 0:t.in,r,e),u=n.getFullYear()-a.getFullYear(),c=me(n)-me(a);return u*4+c}function p(r,e,t){const[n,a]=S(t==null?void 0:t.in,r,e),u=$(n,t),c=$(a,t),s=+u-Y(u),f=+c-Y(c);return Math.round((s-f)/ne)}function Z(r,e,t){const[n,a]=S(t==null?void 0:t.in,r,e);return n.getFullYear()-a.getFullYear()}function He(r,e,t){const[n,a]=S(t==null?void 0:t.in,r,e),u=ge(n,a),c=Math.abs(w(n,a));n.setDate(n.getDate()-u*c);const s=+(ge(n,a)===-u),f=u*(c-s);return f===0?0:f}function ge(r,e){const t=r.getFullYear()-e.getFullYear()||r.getMonth()-e.getMonth()||r.getDate()-e.getDate()||r.getHours()-e.getHours()||r.getMinutes()-e.getMinutes()||r.getSeconds()-e.getSeconds()||r.getMilliseconds()-e.getMilliseconds();return t<0?-1:t>0?1:t}function W(r){return e=>{const n=(r?Math[r]:Math.trunc)(e);return n===0?0:n}}function ee(r,e,t){const[n,a]=S(t==null?void 0:t.in,r,e),u=(+n-+a)/q;return W(t==null?void 0:t.roundingMethod)(u)}function it(r,e,t){return ct(r,-e,t)}function ar(r,e,t){const[n,a]=S(t==null?void 0:t.in,r,e),u=k(n,a),c=Math.abs(dt(n,a,t)),s=it(n,u*c,t),f=+(k(s,a)===-u),l=u*(c-f);return l===0?0:l}function xe(r,e){return+d(r)-+d(e)}function te(r,e,t){const n=xe(r,e)/H;return W(t==null?void 0:t.roundingMethod)(n)}function ht(r,e){const t=d(r,e==null?void 0:e.in);return+Oe(t,e)==+Se(t,e)}function fe(r,e,t){const[n,a,u]=S(t==null?void 0:t.in,r,r,e),c=k(a,u),s=Math.abs(o(a,u));if(s<1)return 0;a.getMonth()===1&&a.getDate()>27&&a.setDate(30),a.setMonth(a.getMonth()-c*s);let f=k(a,u)===-c;ht(n)&&s===1&&k(n,u)===1&&(f=!1);const l=c*(s-+f);return l===0?0:l}function ur(r,e,t){const n=fe(r,e,t)/3;return W(t==null?void 0:t.roundingMethod)(n)}function A(r,e,t){const n=xe(r,e)/1e3;return W(t==null?void 0:t.roundingMethod)(n)}function cr(r,e,t){const n=He(r,e,t)/7;return W(t==null?void 0:t.roundingMethod)(n)}function mt(r,e,t){const[n,a]=S(t==null?void 0:t.in,r,e),u=k(n,a),c=Math.abs(Z(n,a));n.setFullYear(1584),a.setFullYear(1584);const s=k(n,a)===-u,f=u*(c-+s);return f===0?0:f}function N(r,e){const[t,n]=S(r,e.start,e.end);return{start:t,end:n}}function gt(r,e){const{start:t,end:n}=N(e==null?void 0:e.in,r);let a=+t>+n;const u=a?+t:+n,c=a?n:t;c.setHours(0,0,0,0);let s=(e==null?void 0:e.step)??1;if(!s)return[];s<0&&(s=-s,a=!a);const f=[];for(;+c<=u;)f.push(g(t,c)),c.setDate(c.getDate()+s),c.setHours(0,0,0,0);return a?f.reverse():f}function sr(r,e){const{start:t,end:n}=N(e==null?void 0:e.in,r);let a=+t>+n;const u=a?+t:+n,c=a?n:t;c.setMinutes(0,0,0);let s=(e==null?void 0:e.step)??1;if(!s)return[];s<0&&(s=-s,a=!a);const f=[];for(;+c<=u;)f.push(g(t,c)),c.setHours(c.getHours()+s);return a?f.reverse():f}function fr(r,e){const{start:t,end:n}=N(e==null?void 0:e.in,r);t.setSeconds(0,0);let a=+t>+n;const u=a?+t:+n;let c=a?n:t,s=(e==null?void 0:e.step)??1;if(!s)return[];s<0&&(s=-s,a=!a);const f=[];for(;+c<=u;)f.push(g(t,c)),c=Te(c,s);return a?f.reverse():f}function lr(r,e){const{start:t,end:n}=N(e==null?void 0:e.in,r);let a=+t>+n;const u=a?+t:+n,c=a?n:t;c.setHours(0,0,0,0),c.setDate(1);let s=(e==null?void 0:e.step)??1;if(!s)return[];s<0&&(s=-s,a=!a);const f=[];for(;+c<=u;)f.push(g(t,c)),c.setMonth(c.getMonth()+s);return a?f.reverse():f}function C(r,e){const t=d(r,e==null?void 0:e.in),n=t.getMonth(),a=n-n%3;return t.setMonth(a,1),t.setHours(0,0,0,0),t}function dr(r,e){const{start:t,end:n}=N(e==null?void 0:e.in,r);let a=+t>+n;const u=a?+C(t):+C(n);let c=C(a?n:t),s=(e==null?void 0:e.step)??1;if(!s)return[];s<0&&(s=-s,a=!a);const f=[];for(;+c<=u;)f.push(g(t,c)),c=Fe(c,s);return a?f.reverse():f}function ir(r,e){const{start:t,end:n}=N(e==null?void 0:e.in,r);let a=+t>+n;const u=a?$(n,e):$(t,e),c=a?$(t,e):$(n,e);u.setHours(15),c.setHours(15);const s=+c.getTime();let f=u,l=(e==null?void 0:e.step)??1;if(!l)return[];l<0&&(l=-l,a=!a);const i=[];for(;+f<=s;)f.setHours(0),i.push(g(t,f)),f=ae(f,l),f.setHours(15);return a?i.reverse():i}function ve(r,e){const{start:t,end:n}=N(e==null?void 0:e.in,r),a=gt({start:t,end:n},e),u=[];let c=0;for(;c<a.length;){const s=a[c++];Q(s)&&u.push(g(t,s))}return u}function hr(r,e){const t=ue(r,e),n=Se(r,e);return ve({start:t,end:n},e)}function mr(r,e){const t=Ce(r,e),n=Ee(r,e);return ve({start:t,end:n},e)}function gr(r,e){const{start:t,end:n}=N(e==null?void 0:e.in,r);let a=+t>+n;const u=a?+t:+n,c=a?n:t;c.setHours(0,0,0,0),c.setMonth(0,1);let s=(e==null?void 0:e.step)??1;if(!s)return[];s<0&&(s=-s,a=!a);const f=[];for(;+c<=u;)f.push(g(t,c)),c.setFullYear(c.getFullYear()+s);return a?f.reverse():f}function Dr(r,e){const t=d(r,e==null?void 0:e.in),n=t.getFullYear(),a=9+Math.floor(n/10)*10;return t.setFullYear(a,11,31),t.setHours(23,59,59,999),t}function Mr(r,e){const t=d(r,e==null?void 0:e.in);return t.setMinutes(59,59,999),t}function yr(r,e){return Re(r,{...e,weekStartsOn:1})}function Or(r,e){const t=j(r,e),n=g((e==null?void 0:e.in)||r,0);n.setFullYear(t+1,0,4),n.setHours(0,0,0,0);const a=L(n,e);return a.setMilliseconds(a.getMilliseconds()-1),a}function Sr(r,e){const t=d(r,e==null?void 0:e.in);return t.setSeconds(59,999),t}function Tr(r,e){const t=d(r,e==null?void 0:e.in),n=t.getMonth(),a=n-n%3+3;return t.setMonth(a,0),t.setHours(23,59,59,999),t}function Ir(r,e){const t=d(r,e==null?void 0:e.in);return t.setMilliseconds(999),t}function Yr(r){return Oe(Date.now(),r)}function kr(r){const e=T(r==null?void 0:r.in),t=e.getFullYear(),n=e.getMonth(),a=e.getDate(),u=T(r==null?void 0:r.in);return u.setFullYear(t,n,a+1),u.setHours(23,59,59,999),r!=null&&r.in?r.in(u):u}function Nr(r){const e=T(r==null?void 0:r.in),t=g(r==null?void 0:r.in,0);return t.setFullYear(e.getFullYear(),e.getMonth(),e.getDate()-1),t.setHours(23,59,59,999),t}function Dt(r,e,t){const n=_(),a=(t==null?void 0:t.locale)??n.locale??P,u=2520,c=k(r,e);if(isNaN(c))throw new RangeError("Invalid time value");const s=Object.assign({},t,{addSuffix:t==null?void 0:t.addSuffix,comparison:c}),[f,l]=S(t==null?void 0:t.in,...c>0?[e,r]:[r,e]),i=A(l,f),h=(Y(l)-Y(f))/1e3,m=Math.round((i-h)/60);let D;if(m<2)return t!=null&&t.includeSeconds?i<5?a.formatDistance("lessThanXSeconds",5,s):i<10?a.formatDistance("lessThanXSeconds",10,s):i<20?a.formatDistance("lessThanXSeconds",20,s):i<40?a.formatDistance("halfAMinute",0,s):i<60?a.formatDistance("lessThanXMinutes",1,s):a.formatDistance("xMinutes",1,s):m===0?a.formatDistance("lessThanXMinutes",1,s):a.formatDistance("xMinutes",m,s);if(m<45)return a.formatDistance("xMinutes",m,s);if(m<90)return a.formatDistance("aboutXHours",1,s);if(m<J){const M=Math.round(m/60);return a.formatDistance("aboutXHours",M,s)}else{if(m<u)return a.formatDistance("xDays",1,s);if(m<b){const M=Math.round(m/J);return a.formatDistance("xDays",M,s)}else if(m<b*2)return D=Math.round(m/b),a.formatDistance("aboutXMonths",D,s)}if(D=fe(l,f),D<12){const M=Math.round(m/b);return a.formatDistance("xMonths",M,s)}else{const M=D%12,y=Math.trunc(D/12);return M<3?a.formatDistance("aboutXYears",y,s):M<9?a.formatDistance("overXYears",y,s):a.formatDistance("almostXYears",y+1,s)}}function Mt(r,e,t){const n=_(),a=(t==null?void 0:t.locale)??n.locale??P,u=k(r,e);if(isNaN(u))throw new RangeError("Invalid time value");const c=Object.assign({},t,{addSuffix:t==null?void 0:t.addSuffix,comparison:u}),[s,f]=S(t==null?void 0:t.in,...u>0?[e,r]:[r,e]),l=W((t==null?void 0:t.roundingMethod)??"round"),i=f.getTime()-s.getTime(),h=i/H,m=Y(f)-Y(s),D=(i-m)/H,M=t==null?void 0:t.unit;let y;if(M?y=M:h<1?y="second":h<60?y="minute":h<J?y="hour":D<b?y="day":D<ie?y="month":y="year",y==="second"){const I=l(i/1e3);return a.formatDistance("xSeconds",I,c)}else if(y==="minute"){const I=l(h);return a.formatDistance("xMinutes",I,c)}else if(y==="hour"){const I=l(h/60);return a.formatDistance("xHours",I,c)}else if(y==="day"){const I=l(D/J);return a.formatDistance("xDays",I,c)}else if(y==="month"){const I=l(D/b);return I===12&&M!=="month"?a.formatDistance("xYears",1,c):a.formatDistance("xMonths",I,c)}else{const I=l(D/ie);return a.formatDistance("xYears",I,c)}}function wr(r,e){return Dt(r,T(r),e)}function _r(r,e){return Mt(r,T(r),e)}const yt=["years","months","weeks","days","hours","minutes","seconds"];function Wr(r,e){const t=_(),n=(e==null?void 0:e.locale)??t.locale??P,a=(e==null?void 0:e.format)??yt,u=(e==null?void 0:e.zero)??!1,c=(e==null?void 0:e.delimiter)??" ";return n.formatDistance?a.reduce((f,l)=>{const i=`x${l.replace(/(^.)/,m=>m.toUpperCase())}`,h=r[l];return h!==void 0&&(u||r[l])?f.concat(n.formatDistance(i,h)):f},[]).join(c):""}function Fr(r,e){const t=d(r,e==null?void 0:e.in);if(isNaN(+t))throw new RangeError("Invalid time value");const n=(e==null?void 0:e.format)??"extended",a=(e==null?void 0:e.representation)??"complete";let u="",c="";const s=n==="extended"?"-":"",f=n==="extended"?":":"";if(a!=="time"){const l=O(t.getDate(),2),i=O(t.getMonth()+1,2);u=`${O(t.getFullYear(),4)}${s}${i}${s}${l}`}if(a!=="date"){const l=t.getTimezoneOffset();if(l!==0){const y=Math.abs(l),I=O(Math.trunc(y/60),2),be=O(y%60,2);c=`${l<0?"+":"-"}${I}:${be}`}else c="Z";const i=O(t.getHours(),2),h=O(t.getMinutes(),2),m=O(t.getSeconds(),2),D=u===""?"":"T",M=[i,h,m].join(f);u=`${u}${D}${M}${c}`}return u}function Hr(r,e){const t=d(r,e==null?void 0:e.in);if(!F(t))throw new RangeError("Invalid time value");const n=(e==null?void 0:e.format)??"extended",a=(e==null?void 0:e.representation)??"complete";let u="";const c=n==="extended"?"-":"",s=n==="extended"?":":"";if(a!=="time"){const f=O(t.getDate(),2),l=O(t.getMonth()+1,2);u=`${O(t.getFullYear(),4)}${c}${l}${c}${f}`}if(a!=="date"){const f=O(t.getHours(),2),l=O(t.getMinutes(),2),i=O(t.getSeconds(),2);u=`${u}${u===""?"":" "}${f}${s}${l}${s}${i}`}return u}function xr(r){const{years:e=0,months:t=0,days:n=0,hours:a=0,minutes:u=0,seconds:c=0}=r;return`P${e}Y${t}M${n}DT${a}H${u}M${c}S`}function vr(r,e){const t=d(r,e==null?void 0:e.in);if(!F(t))throw new RangeError("Invalid time value");const n=(e==null?void 0:e.fractionDigits)??0,a=O(t.getDate(),2),u=O(t.getMonth()+1,2),c=t.getFullYear(),s=O(t.getHours(),2),f=O(t.getMinutes(),2),l=O(t.getSeconds(),2);let i="";if(n>0){const D=t.getMilliseconds(),M=Math.trunc(D*Math.pow(10,n-3));i="."+O(M,n)}let h="";const m=t.getTimezoneOffset();if(m!==0){const D=Math.abs(m),M=O(Math.trunc(D/60),2),y=O(D%60,2);h=`${m<0?"+":"-"}${M}:${y}`}else h="Z";return`${c}-${u}-${a}T${s}:${f}:${l}${i}${h}`}const Ot=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],St=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function $r(r){const e=d(r);if(!F(e))throw new RangeError("Invalid time value");const t=Ot[e.getUTCDay()],n=O(e.getUTCDate(),2),a=St[e.getUTCMonth()],u=e.getUTCFullYear(),c=O(e.getUTCHours(),2),s=O(e.getUTCMinutes(),2),f=O(e.getUTCSeconds(),2);return`${t}, ${n} ${a} ${u} ${c}:${s}:${f} GMT`}function br(r,e,t){var h,m,D,M;const[n,a]=S(t==null?void 0:t.in,r,e),u=_(),c=(t==null?void 0:t.locale)??u.locale??P,s=(t==null?void 0:t.weekStartsOn)??((m=(h=t==null?void 0:t.locale)==null?void 0:h.options)==null?void 0:m.weekStartsOn)??u.weekStartsOn??((M=(D=u.locale)==null?void 0:D.options)==null?void 0:M.weekStartsOn)??0,f=w(n,a);if(isNaN(f))throw new RangeError("Invalid time value");let l;f<-6?l="other":f<-1?l="lastWeek":f<0?l="yesterday":f<1?l="today":f<2?l="tomorrow":f<7?l="nextWeek":l="other";const i=c.formatRelative(l,n,a,{locale:c,weekStartsOn:s});return Ue(n,i,{locale:c,weekStartsOn:s})}function Cr(r,e){return d(r*1e3,e==null?void 0:e.in)}function le(r,e){return d(r,e==null?void 0:e.in).getDay()}function Tt(r,e){const n=d(r,e==null?void 0:e.in).getFullYear();return n%400===0||n%4===0&&n%100!==0}function Er(r,e){const t=d(r,e==null?void 0:e.in);return Number.isNaN(+t)?NaN:Tt(t)?366:365}function Rr(r,e){const n=d(r,e==null?void 0:e.in).getFullYear();return Math.floor(n/10)*10}function Ur(r,e){const t=R(r,e),a=+R(ae(t,60))-+t;return Math.round(a/ne)}function zr(r,e){const[t,n]=[+d(r.start),+d(r.end)].sort((h,m)=>h-m),[a,u]=[+d(e.start),+d(e.end)].sort((h,m)=>h-m);if(!(t<u&&a<n))return 0;const s=a<t?t:a,f=s-Y(s),l=u>n?n:u,i=l-Y(l);return Math.ceil((i-f)/ze)}function Qr(r){return+d(r)}function Ar(r){return Math.trunc(+d(r)/1e3)}function jr(r,e){var f,l,i,h;const t=_(),n=(e==null?void 0:e.weekStartsOn)??((l=(f=e==null?void 0:e.locale)==null?void 0:f.options)==null?void 0:l.weekStartsOn)??t.weekStartsOn??((h=(i=t.locale)==null?void 0:i.options)==null?void 0:h.weekStartsOn)??0,a=Qe(d(r,e==null?void 0:e.in));if(isNaN(a))return NaN;const u=le(ue(r,e));let c=n-u;c<=0&&(c+=7);const s=a-c;return Math.ceil(s/7)+1}function It(r,e){const t=d(r,e==null?void 0:e.in),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(0,0,0,0),d(t,e==null?void 0:e.in)}function qr(r,e){const t=d(r,e==null?void 0:e.in);return p(It(t,e),ue(t,e),e)+1}function Xr(r){return Math.trunc(r*q)}function Zr(r){return Math.trunc(r*Ie)}function Lr(r){return Math.trunc(r*ce)}function Jr(r,e,t){const[n,a]=S(t==null?void 0:t.in,r,e);if(isNaN(+n))throw new TypeError("Start date is invalid");if(isNaN(+a))throw new TypeError("End date is invalid");if(t!=null&&t.assertPositive&&+n>+a)throw new TypeError("End date must be after start date");return{start:n,end:a}}function Br(r,e){const{start:t,end:n}=N(e==null?void 0:e.in,r),a={},u=mt(n,t);u&&(a.years=u);const c=U(t,{years:a.years}),s=fe(n,c);s&&(a.months=s);const f=U(c,{months:a.months}),l=He(n,f);l&&(a.days=l);const i=U(f,{days:a.days}),h=ee(n,i);h&&(a.hours=h);const m=U(i,{hours:a.hours}),D=te(n,m);D&&(a.minutes=D);const M=U(m,{minutes:a.minutes}),y=A(n,M);return y&&(a.seconds=y),a}function Pr(r,e,t){let n;return Yt(e)?n=e:t=e,new Intl.DateTimeFormat(t==null?void 0:t.locale,n).format(d(r))}function Yt(r){return r!==void 0&&!("locale"in r)}function Gr(r,e,t){let n=0,a;const[u,c]=S(t==null?void 0:t.in,r,e);if(t!=null&&t.unit)a=t==null?void 0:t.unit,a==="second"?n=A(u,c):a==="minute"?n=te(u,c):a==="hour"?n=ee(u,c):a==="day"?n=w(u,c):a==="week"?n=p(u,c):a==="month"?n=o(u,c):a==="quarter"?n=G(u,c):a==="year"&&(n=Z(u,c));else{const f=A(u,c);Math.abs(f)<se?(n=A(u,c),a="second"):Math.abs(f)<ce?(n=te(u,c),a="minute"):Math.abs(f)<Ae&&Math.abs(w(u,c))<1?(n=ee(u,c),a="hour"):Math.abs(f)<je&&(n=w(u,c))&&Math.abs(n)<7?a="day":Math.abs(f)<qe?(n=p(u,c),a="week"):Math.abs(f)<Xe?(n=o(u,c),a="month"):Math.abs(f)<Ze&&G(u,c)<4?(n=G(u,c),a="quarter"):(n=Z(u,c),a="year")}return new Intl.RelativeTimeFormat(t==null?void 0:t.locale,{numeric:"auto",...t}).format(n,a)}function Kr(r,e,t){const n=new Date(r,e,t);return n.getFullYear()===r&&n.getMonth()===e&&n.getDate()===t}function Vr(r,e){return d(r,e==null?void 0:e.in).getDate()===1}function or(r,e){return d(r,e==null?void 0:e.in).getDay()===5}function pr(r){return+d(r)>Date.now()}function en(r,e,t){return F(Le(r,e,new Date,t))}function tn(r,e){return d(r,e==null?void 0:e.in).getDay()===1}function rn(r){return+d(r)<Date.now()}function kt(r,e,t){return Ye(r,e,{...t,weekStartsOn:1})}function nn(r,e,t){const[n,a]=S(t==null?void 0:t.in,r,e);return+R(n)==+R(a)}function De(r,e){const t=d(r,e==null?void 0:e.in);return t.setSeconds(0,0),t}function Nt(r,e){return+De(r)==+De(e)}function wt(r,e,t){const[n,a]=S(t==null?void 0:t.in,r,e);return+C(n)==+C(a)}function Me(r,e){const t=d(r,e==null?void 0:e.in);return t.setMilliseconds(0),t}function _t(r,e){return+Me(r)==+Me(e)}function an(r,e){return Je(d(r,e==null?void 0:e.in),T((e==null?void 0:e.in)||r))}function un(r,e){return kt(g((e==null?void 0:e.in)||r,r),T((e==null?void 0:e.in)||r))}function cn(r){return Nt(r,T(r))}function sn(r,e){return Be(g((e==null?void 0:e.in)||r,r),T((e==null?void 0:e.in)||r))}function fn(r,e){return wt(g((e==null?void 0:e.in)||r,r),T((e==null?void 0:e.in)||r))}function ln(r){return _t(r,T(r))}function dn(r,e){return Ye(g((e==null?void 0:e.in)||r,r),T((e==null?void 0:e.in)||r),e)}function hn(r,e){return Pe(g((e==null?void 0:e.in)||r,r),T((e==null?void 0:e.in)||r))}function mn(r,e){return d(r,e==null?void 0:e.in).getDay()===4}function gn(r,e){return B(g((e==null?void 0:e.in)||r,r),T((e==null?void 0:e.in)||r))}function Dn(r,e){return B(r,E(T((e==null?void 0:e.in)||r),1),e)}function Mn(r,e){return d(r,e==null?void 0:e.in).getDay()===2}function yn(r,e){return d(r,e==null?void 0:e.in).getDay()===3}function de(r,e,t){return E(r,-e,t)}function On(r,e){return B(g((e==null?void 0:e.in)||r,r),de(T((e==null?void 0:e.in)||r),1))}function Sn(r,e){const t=d(r,e==null?void 0:e.in),n=t.getFullYear(),a=9+Math.floor(n/10)*10;return t.setFullYear(a+1,0,0),t.setHours(0,0,0,0),d(t,e==null?void 0:e.in)}function Wt(r,e){var s,f,l,i;const t=_(),n=(e==null?void 0:e.weekStartsOn)??((f=(s=e==null?void 0:e.locale)==null?void 0:s.options)==null?void 0:f.weekStartsOn)??t.weekStartsOn??((i=(l=t.locale)==null?void 0:l.options)==null?void 0:i.weekStartsOn)??0,a=d(r,e==null?void 0:e.in),u=a.getDay(),c=(u<n?-7:0)+6-(u-n);return a.setHours(0,0,0,0),a.setDate(a.getDate()+c),a}function Tn(r,e){return Wt(r,{...e,weekStartsOn:1})}function In(r,e){const t=j(r,e),n=g((e==null?void 0:e.in)||r,0);n.setFullYear(t+1,0,4),n.setHours(0,0,0,0);const a=L(n,e);return a.setDate(a.getDate()-1),a}function Yn(r,e){const t=d(r,e==null?void 0:e.in),n=t.getMonth(),a=n-n%3+3;return t.setMonth(a,0),t.setHours(0,0,0,0),t}function kn(r,e){const t=d(r,e==null?void 0:e.in),n=t.getFullYear();return t.setFullYear(n+1,0,0),t.setHours(0,0,0,0),t}const Ft=/(\w)\1*|''|'(''|[^'])+('|$)|./g,Ht=/^'([^]*?)'?$/,xt=/''/g,vt=/[a-zA-Z]/;function Nn(r,e){const t=d(r);if(!F(t))throw new RangeError("Invalid time value");const n=e.match(Ft);return n?n.map(u=>{if(u==="''")return"'";const c=u[0];if(c==="'")return $t(u);const s=Ge[c];if(s)return s(t,u);if(c.match(vt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+c+"`");return u}).join(""):""}function $t(r){const e=r.match(Ht);return e?e[1].replace(xt,"'"):r}function wn({years:r,months:e,weeks:t,days:n,hours:a,minutes:u,seconds:c}){let s=0;r&&(s+=r*V),e&&(s+=e*(V/12)),t&&(s+=t*7),n&&(s+=n);let f=s*24*60*60;return a&&(f+=a*60*60),u&&(f+=u*60),c&&(f+=c),Math.trunc(f*1e3)}function _n(r){const e=r/q;return Math.trunc(e)}function Wn(r){const e=r/H;return Math.trunc(e)}function Fn(r){const e=r/ke;return Math.trunc(e)}function Hn(r){const e=r/Ie;return Math.trunc(e)}function xn(r){return Math.trunc(r*H)}function vn(r){return Math.trunc(r*se)}function $n(r){const e=r/Ne;return Math.trunc(e)}function bn(r){const e=r/we;return Math.trunc(e)}function x(r,e,t){let n=e-le(r,t);return n<=0&&(n+=7),E(r,n,t)}function Cn(r,e){return x(r,5,e)}function En(r,e){return x(r,1,e)}function Rn(r,e){return x(r,6,e)}function Un(r,e){return x(r,0,e)}function zn(r,e){return x(r,4,e)}function Qn(r,e){return x(r,2,e)}function An(r,e){return x(r,3,e)}function jn(r,e){const t=()=>g(e==null?void 0:e.in,NaN),n=(e==null?void 0:e.additionalDigits)??2,a=Rt(r);let u;if(a.date){const l=Ut(a.date,n);u=zt(l.restDateString,l.year)}if(!u||isNaN(+u))return t();const c=+u;let s=0,f;if(a.time&&(s=Qt(a.time),isNaN(s)))return t();if(a.timezone){if(f=At(a.timezone),isNaN(f))return t()}else{const l=new Date(c+s),i=d(0,e==null?void 0:e.in);return i.setFullYear(l.getUTCFullYear(),l.getUTCMonth(),l.getUTCDate()),i.setHours(l.getUTCHours(),l.getUTCMinutes(),l.getUTCSeconds(),l.getUTCMilliseconds()),i}return d(c+s+f,e==null?void 0:e.in)}const X={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},bt=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,Ct=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,Et=/^([+-])(\d{2})(?::?(\d{2}))?$/;function Rt(r){const e={},t=r.split(X.dateTimeDelimiter);let n;if(t.length>2)return e;if(/:/.test(t[0])?n=t[0]:(e.date=t[0],n=t[1],X.timeZoneDelimiter.test(e.date)&&(e.date=r.split(X.timeZoneDelimiter)[0],n=r.substr(e.date.length,r.length))),n){const a=X.timezone.exec(n);a?(e.time=n.replace(a[1],""),e.timezone=a[1]):e.time=n}return e}function Ut(r,e){const t=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+e)+"})|(\\d{2}|[+-]\\d{"+(2+e)+"})$)"),n=r.match(t);if(!n)return{year:NaN,restDateString:""};const a=n[1]?parseInt(n[1]):null,u=n[2]?parseInt(n[2]):null;return{year:u===null?a:u*100,restDateString:r.slice((n[1]||n[2]).length)}}function zt(r,e){if(e===null)return new Date(NaN);const t=r.match(bt);if(!t)return new Date(NaN);const n=!!t[4],a=z(t[1]),u=z(t[2])-1,c=z(t[3]),s=z(t[4]),f=z(t[5])-1;if(n)return Lt(e,s,f)?jt(e,s,f):new Date(NaN);{const l=new Date(0);return!Xt(e,u,c)||!Zt(e,a)?new Date(NaN):(l.setUTCFullYear(e,u,Math.max(a,c)),l)}}function z(r){return r?parseInt(r):1}function Qt(r){const e=r.match(Ct);if(!e)return NaN;const t=K(e[1]),n=K(e[2]),a=K(e[3]);return Jt(t,n,a)?t*q+n*H+a*1e3:NaN}function K(r){return r&&parseFloat(r.replace(",","."))||0}function At(r){if(r==="Z")return 0;const e=r.match(Et);if(!e)return 0;const t=e[1]==="+"?-1:1,n=parseInt(e[2]),a=e[3]&&parseInt(e[3])||0;return Bt(n,a)?t*(n*q+a*H):NaN}function jt(r,e,t){const n=new Date(0);n.setUTCFullYear(r,0,4);const a=n.getUTCDay()||7,u=(e-1)*7+t+1-a;return n.setUTCDate(n.getUTCDate()+u),n}const qt=[31,null,31,30,31,30,31,31,30,31,30,31];function $e(r){return r%400===0||r%4===0&&r%100!==0}function Xt(r,e,t){return e>=0&&e<=11&&t>=1&&t<=(qt[e]||($e(r)?29:28))}function Zt(r,e){return e>=1&&e<=($e(r)?366:365)}function Lt(r,e,t){return e>=1&&e<=53&&t>=0&&t<=6}function Jt(r,e,t){return r===24?e===0&&t===0:t>=0&&t<60&&e>=0&&e<60&&r>=0&&r<25}function Bt(r,e){return e>=0&&e<=59}function qn(r,e){const t=r.match(/(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2}):(\d{2})(?:\.(\d{0,7}))?(?:Z|(.)(\d{2}):?(\d{2})?)?/);return t?d(Date.UTC(+t[1],+t[2]-1,+t[3],+t[4]-(+t[9]||0)*(t[8]=="-"?-1:1),+t[5]-(+t[10]||0)*(t[8]=="-"?-1:1),+t[6],+((t[7]||"0")+"00").substring(0,3)),e==null?void 0:e.in):d(NaN,e==null?void 0:e.in)}function v(r,e,t){let n=le(r,t)-e;return n<=0&&(n+=7),de(r,n,t)}function Xn(r,e){return v(r,5,e)}function Zn(r,e){return v(r,1,e)}function Ln(r,e){return v(r,6,e)}function Jn(r,e){return v(r,0,e)}function Bn(r,e){return v(r,4,e)}function Pn(r,e){return v(r,2,e)}function Gn(r,e){return v(r,3,e)}function Kn(r){return Math.trunc(r*Ne)}function Vn(r){const e=r/_e;return Math.trunc(e)}function on(r,e){const t=(e==null?void 0:e.nearestTo)??1;if(t<1||t>12)return g((e==null?void 0:e.in)||r,NaN);const n=d(r,e==null?void 0:e.in),a=n.getMinutes()/60,u=n.getSeconds()/60/60,c=n.getMilliseconds()/1e3/60/60,s=n.getHours()+a+u+c,f=(e==null?void 0:e.roundingMethod)??"round",i=W(f)(s/t)*t;return n.setHours(i,0,0,0),n}function pn(r,e){const t=(e==null?void 0:e.nearestTo)??1;if(t<1||t>30)return g(r,NaN);const n=d(r,e==null?void 0:e.in),a=n.getSeconds()/60,u=n.getMilliseconds()/1e3/60,c=n.getMinutes()+a+u,s=(e==null?void 0:e.roundingMethod)??"round",l=W(s)(c/t)*t;return n.setMinutes(l,0,0),n}function ea(r){const e=r/ce;return Math.trunc(e)}function ta(r){return r*ke}function ra(r){const e=r/se;return Math.trunc(e)}function na(r,e,t){let n=d(r,t==null?void 0:t.in);return isNaN(+n)?g((t==null?void 0:t.in)||r,NaN):(e.year!=null&&n.setFullYear(e.year),e.month!=null&&(n=We(n,e.month)),e.date!=null&&n.setDate(e.date),e.hours!=null&&n.setHours(e.hours),e.minutes!=null&&n.setMinutes(e.minutes),e.seconds!=null&&n.setSeconds(e.seconds),e.milliseconds!=null&&n.setMilliseconds(e.milliseconds),n)}function aa(r,e,t){const n=d(r,t==null?void 0:t.in);return n.setMonth(0),n.setDate(e),n}function ua(r){const e={},t=_();for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);for(const n in r)Object.prototype.hasOwnProperty.call(r,n)&&(r[n]===void 0?delete e[n]:e[n]=r[n]);Ke(e)}function ca(r,e,t){const n=d(r,t==null?void 0:t.in),a=Math.trunc(n.getMonth()/3)+1,u=e-a;return We(n,n.getMonth()+u*3)}function sa(r,e,t){var f,l,i,h;const n=_(),a=(t==null?void 0:t.firstWeekContainsDate)??((l=(f=t==null?void 0:t.locale)==null?void 0:f.options)==null?void 0:l.firstWeekContainsDate)??n.firstWeekContainsDate??((h=(i=n.locale)==null?void 0:i.options)==null?void 0:h.firstWeekContainsDate)??1,u=w(d(r,t==null?void 0:t.in),he(r,t),t),c=g((t==null?void 0:t.in)||r,0);c.setFullYear(e,0,a),c.setHours(0,0,0,0);const s=he(c,t);return s.setDate(s.getDate()+u),s}function fa(r,e){const t=d(r,e==null?void 0:e.in),n=t.getFullYear(),a=Math.floor(n/10)*10;return t.setFullYear(a,0,1),t.setHours(0,0,0,0),t}function la(r){return Ve(Date.now(),r)}function da(r){const e=T(r==null?void 0:r.in),t=e.getFullYear(),n=e.getMonth(),a=e.getDate(),u=g(r==null?void 0:r.in,0);return u.setFullYear(t,n,a+1),u.setHours(0,0,0,0),u}function ia(r){const e=T(r==null?void 0:r.in),t=e.getFullYear(),n=e.getMonth(),a=e.getDate(),u=T(r==null?void 0:r.in);return u.setFullYear(t,n,a-1),u.setHours(0,0,0,0),u}function Pt(r,e,t){return re(r,-e,t)}function ha(r,e,t){const{years:n=0,months:a=0,weeks:u=0,days:c=0,hours:s=0,minutes:f=0,seconds:l=0}=e,i=Pt(r,a+n*12,t),h=de(i,c+u*7,t),m=f+s*60,M=(l+m*60)*1e3;return g((t==null?void 0:t.in)||r,+h-M)}function ma(r,e,t){return at(r,-e,t)}function ga(r,e,t){return oe(r,-e,t)}function Da(r,e,t){return pe(r,-e,t)}function Ma(r,e,t){return Te(r,-e,t)}function ya(r,e,t){return Fe(r,-e,t)}function Oa(r,e,t){return et(r,-e,t)}function Sa(r,e,t){return ae(r,-e,t)}function Ta(r,e,t){return tt(r,-e,t)}function Ia(r){return Math.trunc(r*ye)}function Ya(r){return Math.trunc(r*V)}function ka(r){return Math.trunc(r*we)}function Na(r){return Math.trunc(r*_e)}export{U as add,at as addBusinessDays,E as addDays,oe as addHours,ct as addISOWeekYears,pe as addMilliseconds,Te as addMinutes,re as addMonths,Fe as addQuarters,et as addSeconds,ae as addWeeks,tt as addYears,Vt as areIntervalsOverlapping,ot as clamp,lt as closestIndexTo,pt as closestTo,k as compareAsc,er as compareDesc,g as constructFrom,T as constructNow,tr as daysToWeeks,rr as differenceInBusinessDays,w as differenceInCalendarDays,dt as differenceInCalendarISOWeekYears,nr as differenceInCalendarISOWeeks,o as differenceInCalendarMonths,G as differenceInCalendarQuarters,p as differenceInCalendarWeeks,Z as differenceInCalendarYears,He as differenceInDays,ee as differenceInHours,ar as differenceInISOWeekYears,xe as differenceInMilliseconds,te as differenceInMinutes,fe as differenceInMonths,ur as differenceInQuarters,A as differenceInSeconds,cr as differenceInWeeks,mt as differenceInYears,gt as eachDayOfInterval,sr as eachHourOfInterval,fr as eachMinuteOfInterval,lr as eachMonthOfInterval,dr as eachQuarterOfInterval,ir as eachWeekOfInterval,ve as eachWeekendOfInterval,hr as eachWeekendOfMonth,mr as eachWeekendOfYear,gr as eachYearOfInterval,Oe as endOfDay,Dr as endOfDecade,Mr as endOfHour,yr as endOfISOWeek,Or as endOfISOWeekYear,Sr as endOfMinute,Se as endOfMonth,Tr as endOfQuarter,Ir as endOfSecond,Yr as endOfToday,kr as endOfTomorrow,Re as endOfWeek,Ee as endOfYear,Nr as endOfYesterday,Ue as format,Ue as formatDate,Dt as formatDistance,Mt as formatDistanceStrict,wr as formatDistanceToNow,_r as formatDistanceToNowStrict,Wr as formatDuration,Fr as formatISO,Hr as formatISO9075,xr as formatISODuration,vr as formatRFC3339,$r as formatRFC7231,br as formatRelative,Wa as formatters,Cr as fromUnixTime,Qe as getDate,le as getDay,Fa as getDayOfYear,Ha as getDaysInMonth,Er as getDaysInYear,Rr as getDecade,xa as getDefaultOptions,va as getHours,$a as getISODay,ba as getISOWeek,j as getISOWeekYear,Ur as getISOWeeksInYear,Ca as getMilliseconds,Ea as getMinutes,Ra as getMonth,zr as getOverlappingDaysInIntervals,me as getQuarter,Ua as getSeconds,Qr as getTime,Ar as getUnixTime,za as getWeek,jr as getWeekOfMonth,Qa as getWeekYear,qr as getWeeksInMonth,Aa as getYear,Xr as hoursToMilliseconds,Zr as hoursToMinutes,Lr as hoursToSeconds,Jr as interval,Br as intervalToDuration,Pr as intlFormat,Gr as intlFormatDistance,ja as isAfter,qa as isBefore,Xa as isDate,Za as isEqual,Kr as isExists,Vr as isFirstDayOfMonth,or as isFriday,pr as isFuture,ht as isLastDayOfMonth,Tt as isLeapYear,en as isMatch,tn as isMonday,rn as isPast,B as isSameDay,Je as isSameHour,kt as isSameISOWeek,nn as isSameISOWeekYear,Nt as isSameMinute,Be as isSameMonth,wt as isSameQuarter,_t as isSameSecond,Ye as isSameWeek,Pe as isSameYear,rt as isSaturday,nt as isSunday,an as isThisHour,un as isThisISOWeek,cn as isThisMinute,sn as isThisMonth,fn as isThisQuarter,ln as isThisSecond,dn as isThisWeek,hn as isThisYear,mn as isThursday,gn as isToday,Dn as isTomorrow,Mn as isTuesday,F as isValid,yn as isWednesday,Q as isWeekend,La as isWithinInterval,On as isYesterday,Sn as lastDayOfDecade,Tn as lastDayOfISOWeek,In as lastDayOfISOWeekYear,It as lastDayOfMonth,Yn as lastDayOfQuarter,Wt as lastDayOfWeek,kn as lastDayOfYear,Nn as lightFormat,Ge as lightFormatters,Ja as longFormatters,st as max,wn as milliseconds,_n as millisecondsToHours,Wn as millisecondsToMinutes,Fn as millisecondsToSeconds,ft as min,Hn as minutesToHours,xn as minutesToMilliseconds,vn as minutesToSeconds,$n as monthsToQuarters,bn as monthsToYears,x as nextDay,Cn as nextFriday,En as nextMonday,Rn as nextSaturday,Un as nextSunday,zn as nextThursday,Qn as nextTuesday,An as nextWednesday,Le as parse,jn as parseISO,qn as parseJSON,Ba as parsers,v as previousDay,Xn as previousFriday,Zn as previousMonday,Ln as previousSaturday,Jn as previousSunday,Bn as previousThursday,Pn as previousTuesday,Gn as previousWednesday,Kn as quartersToMonths,Vn as quartersToYears,on as roundToNearestHours,pn as roundToNearestMinutes,ea as secondsToHours,ta as secondsToMilliseconds,ra as secondsToMinutes,na as set,Pa as setDate,Ga as setDay,aa as setDayOfYear,ua as setDefaultOptions,Ka as setHours,Va as setISODay,oa as setISOWeek,ut as setISOWeekYear,pa as setMilliseconds,eu as setMinutes,We as setMonth,ca as setQuarter,tu as setSeconds,ru as setWeek,sa as setWeekYear,nu as setYear,Ve as startOfDay,fa as startOfDecade,au as startOfHour,L as startOfISOWeek,R as startOfISOWeekYear,De as startOfMinute,ue as startOfMonth,C as startOfQuarter,Me as startOfSecond,la as startOfToday,da as startOfTomorrow,$ as startOfWeek,he as startOfWeekYear,Ce as startOfYear,ia as startOfYesterday,ha as sub,ma as subBusinessDays,de as subDays,ga as subHours,it as subISOWeekYears,Da as subMilliseconds,Ma as subMinutes,Pt as subMonths,ya as subQuarters,Oa as subSeconds,Sa as subWeeks,Ta as subYears,d as toDate,uu as transpose,Ia as weeksToDays,Ya as yearsToDays,ka as yearsToMonths,Na as yearsToQuarters};