@rolldate/mcp 1.0.0 → 1.3.1
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.
- package/AGENTS.md +12 -3
- package/README.md +39 -12
- package/bin/rolldate-mcp.js +2 -2
- package/package.json +6 -3
- package/src/catalog-events.js +241 -0
- package/src/catalog.js +81 -10
- package/src/index.js +121 -97
- package/src/products.js +73 -0
- package/templates/AGENTS.md +12 -3
- package/templates/rolldate-mcp.mdc +17 -4
- package/vendor/rolldate/rolldate.css +394 -151
- package/vendor/rolldate/rolldate.js +1298 -661
- package/vendor/rolldate/rolldate.min.css +1 -1
- package/vendor/rolldate/rolldate.min.js +1 -1
- package/vendor/rolldate-events/rolldate-events.css +1 -0
- package/vendor/rolldate-events/rolldate-events.mjs +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
.RollDate__container{display:flex;flex-direction:column;padding:6px 11px;width:360px;--rd-bg: #323232;--rd-border: #626262;--rd-text-primary: #e6e6e6;--rd-text-secondary: #848685;--rd-text-disabled: #515252;--rd-text-disabled-contrast: #a2a2a2;--rd-header-muted: #848685;--rd-weekday: #f7f7f7;--rd-hover-bg: #3e3e3e;--rd-hover-border: #686868;--rd-accent: #609ef1;--rd-accent-strong: #368cfd;--rd-accent-dark: #1e5093;--rd-accent-muted: #375985;--rd-button-icon: #fff;background:var(--rd-bg);border:1px solid var(--rd-border);box-sizing:border-box;font-family:"Segoe UI",Arial,sans-serif;overscroll-behavior:contain;border-radius:8px}.RollDate__container *{box-sizing:border-box}.RollDate__container.RollDate__theme_dark{--rd-bg: #323232;--rd-border: #626262;--rd-text-primary: #e6e6e6;--rd-text-secondary: #848685;--rd-text-disabled: #515252;--rd-text-disabled-contrast: #a2a2a2;--rd-header-muted: #848685;--rd-weekday: #f7f7f7;--rd-hover-bg: #3e3e3e;--rd-hover-border: #686868;--rd-accent: #609ef1;--rd-accent-strong: #368cfd;--rd-accent-dark: #1e5093;--rd-accent-muted: #375985;--rd-button-icon: #fff}.RollDate__container.RollDate__theme_light{--rd-bg: #ffffff;--rd-border: #d8dde6;--rd-text-primary: #1f2937;--rd-text-secondary: #5f6b7a;--rd-text-disabled: #a1aab8;--rd-text-disabled-contrast: #8c97a8;--rd-header-muted: #9aa3b2;--rd-weekday: #334155;--rd-hover-bg: #f3f6fb;--rd-hover-border: #ccd5e3;--rd-accent: #4f8ff7;--rd-accent-strong: #2d7cff;--rd-accent-dark: #1f5dc1;--rd-accent-muted: #d9e8ff;--rd-button-icon: #334155}.RollDate__container.RollDate__calendar__type--days .RollDate__calendar__header{display:flex}.RollDate__container.RollDate__calendar__type--days .RollDate__calendar__days{display:grid;transform:scale(1, 1);opacity:1;pointer-events:auto}.RollDate__container.RollDate__calendar__type--days .RollDate__header__month{display:inline-flex}.RollDate__container.RollDate__calendar__type--months .RollDate__calendar__months{display:grid;transform:scale(1, 1);opacity:1;pointer-events:auto}.RollDate__container.RollDate__calendar__type--years .RollDate__calendar__years{display:grid;transform:scale(1, 1);opacity:1;pointer-events:auto}.RollDate__container.RollDate__calendar__type--years .RollDate__calendar__switcher{color:var(--rd-header-muted);cursor:default}.RollDate__container.RollDate__calendar__type--years .RollDate__calendar__switcher:hover{background-color:rgba(0,0,0,0)}.RollDate__container.RollDate__calendar__type--years .RollDate__header__year,.RollDate__container.RollDate__calendar__type--years .RollDate__header__month{color:var(--rd-header-muted)}.RollDate__header{flex:0 0 auto;display:flex;align-items:center;margin-bottom:10px;height:36px}.RollDate__header__year,.RollDate__header__month{flex:0 0 auto;display:inline-flex;align-items:center;font-size:14px;font-weight:600;color:var(--rd-text-primary)}.RollDate__header__month{display:none;margin-left:4px}.RollDate__calendar{flex:1 0 auto;display:flex;flex-direction:column;height:283px}.RollDate__calendar__switcher{display:flex;padding:4px 12px;height:30px;cursor:pointer;border-radius:4px;transition:all .3s}.RollDate__calendar__switcher:hover{background:var(--rd-hover-bg)}.RollDate__calendar__header{display:none;flex:0 0 auto;grid-template-columns:repeat(7, 1fr);margin-bottom:8px;color:var(--rd-weekday)}.RollDate__calendar__header__weekday{display:flex;justify-content:center;align-items:center;width:100%;min-width:0;height:24px;font-size:12px}.RollDate__calendar__body{flex:1 0 0;overflow:hidden;touch-action:none}.RollDate__calendar__days{grid-template-columns:repeat(7, 1fr);gap:2px;opacity:0;pointer-events:none;transition:transform .3s,opacity .3s}.RollDate__calendar__months,.RollDate__calendar__years{grid-template-columns:repeat(4, 1fr);gap:4px;opacity:0;pointer-events:none;transition:transform .3s,opacity .3s}.RollDate__calendar__day{display:flex;align-items:center;justify-content:center;height:40px;font-size:14px;color:var(--rd-text-secondary);cursor:pointer;transition:all .3s;border-radius:4px;border:2px solid rgba(0,0,0,0)}.RollDate__calendar__day:hover{border-color:var(--rd-hover-border)}.RollDate__calendar__day--selected{border-color:var(--rd-accent-dark)}.RollDate__calendar__day--selected:hover{border-color:var(--rd-accent-strong)}.RollDate__calendar__day--range-first{border-color:var(--rd-accent-dark);border-right-color:rgba(0,0,0,0)}.RollDate__calendar__day--range-first:hover{border-color:var(--rd-accent-strong);border-right-color:rgba(0,0,0,0)}.RollDate__calendar__day--range-selected{border-color:var(--rd-accent-dark) rgba(0,0,0,0) var(--rd-accent-dark) rgba(0,0,0,0)}.RollDate__calendar__day--range-selected:hover{border-color:var(--rd-accent-strong) rgba(0,0,0,0) var(--rd-accent-strong) rgba(0,0,0,0)}.RollDate__calendar__day--range-last{border-color:var(--rd-accent-dark);border-left-color:rgba(0,0,0,0)}.RollDate__calendar__day--range-last:hover{border-color:var(--rd-accent-strong);border-left-color:rgba(0,0,0,0)}.RollDate__calendar__day--active{color:var(--rd-text-primary)}.RollDate__calendar__day--active.RollDate__calendar__day--disabled{color:var(--rd-text-disabled)}.RollDate__calendar__day--today{background:var(--rd-accent);color:#fff}.RollDate__calendar__day--today:hover{border-color:var(--rd-accent-strong);background:var(--rd-accent-strong)}.RollDate__calendar__day--disabled{color:var(--rd-text-disabled);cursor:default}.RollDate__calendar__day--disabled:hover{border-color:rgba(0,0,0,0)}.RollDate__calendar__day--disabled.RollDate__calendar__day--today{color:var(--rd-text-disabled-contrast);background:var(--rd-accent-muted)}.RollDate__calendar__month,.RollDate__calendar__year{display:flex;align-items:center;justify-content:center;height:67px;font-size:14px;color:var(--rd-text-secondary);cursor:pointer;transition:all .3s;border-radius:4px}.RollDate__calendar__month:hover,.RollDate__calendar__year:hover{border:2px solid var(--rd-hover-border)}.RollDate__calendar__month--active,.RollDate__calendar__year--active{color:var(--rd-text-primary)}.RollDate__calendar__month--current,.RollDate__calendar__year--current{background:var(--rd-accent);color:#fff}.RollDate__calendar__month--current:hover,.RollDate__calendar__year--current:hover{border:2px solid var(--rd-accent-strong);background:var(--rd-accent-strong)}.RollDate__calendar__month--disabled,.RollDate__calendar__year--disabled{color:var(--rd-text-disabled);cursor:default}.RollDate__calendar__month--disabled:hover,.RollDate__calendar__year--disabled:hover{border:none}.RollDate__calendar__month--disabled.RollDate__calendar__month--current{color:var(--rd-text-disabled-contrast);background:var(--rd-accent-muted)}.RollDate__calendar__year--disabled.RollDate__calendar__year--current{color:var(--rd-text-disabled-contrast);background:var(--rd-accent-muted)}.RollDate__calendar__buttons{display:flex;align-items:center;margin-left:auto}.RollDate__calendar__button{display:flex;align-items:center;justify-content:center;margin-left:2px;width:30px;height:30px;border-radius:4px;transition:background-color .3s;background:none;border:none;cursor:pointer}.RollDate__calendar__button:hover{background:var(--rd-hover-bg)}.RollDate__calendar__button svg{width:6px;height:5px;fill:var(--rd-button-icon)}.RollDate__calendar__button[data-direction=next]{transform:rotate(-180deg)}.RollDate__footer{flex:0 0 auto;margin-top:10px;padding-top:10px;border-top:1px solid var(--rd-border);display:flex;flex-direction:column;gap:10px}.RollDate__footer__buttons{display:flex;flex-wrap:wrap;gap:8px;justify-content:flex-end}.RollDate__footer__button{border:1px solid var(--rd-border);background:var(--rd-hover-bg);color:var(--rd-text-primary);border-radius:6px;padding:7px 12px;font-size:12px;font-weight:600;cursor:pointer;transition:background-color .2s,border-color .2s}.RollDate__footer__button:hover{border-color:var(--rd-accent);background:var(--rd-accent-muted)}.RollDate__time{display:flex;flex-direction:row;align-items:center;justify-content:center;gap:10px;padding:4px 0 2px;user-select:none}.RollDate__time__picker{display:flex;align-items:center;justify-content:center;gap:4px;flex:1 1 auto;min-width:0}.RollDate__time__display{flex:0 0 auto;font-size:17px;font-weight:700;font-variant-numeric:tabular-nums;color:var(--rd-text-primary);letter-spacing:.03em;line-height:1;padding:6px 10px;border-left:1px solid var(--rd-border);min-width:4.5em;text-align:center}.RollDate__time__field{flex:0 0 auto;width:auto}.RollDate__time__field--period .RollDate__time__viewport{width:40px}.RollDate__time__column{display:flex;flex-direction:row;align-items:center;gap:2px}.RollDate__time__arrow{display:flex;align-items:center;justify-content:center;width:20px;height:84px;padding:0;border:none;border-radius:4px;background:none;cursor:pointer;flex-shrink:0;transition:opacity .2s}.RollDate__time__arrow svg{width:7px;height:6px;fill:var(--rd-text-secondary);transition:fill .2s}.RollDate__time__arrow:hover svg{fill:var(--rd-text-primary)}.RollDate__time__arrow--prev svg{transform:rotate(-90deg)}.RollDate__time__arrow--next svg{transform:rotate(90deg)}.RollDate__time__viewport{position:relative;width:46px;height:84px;overflow:hidden;border-radius:4px;touch-action:none}.RollDate__time__viewport::before{content:"";position:absolute;left:0;right:0;top:50%;transform:translateY(-50%);height:28px;border:2px solid var(--rd-hover-border);border-radius:4px;background:rgba(0,0,0,0);pointer-events:none;z-index:2;box-sizing:border-box}.RollDate__time__viewport::after{content:"";position:absolute;inset:0;pointer-events:none;z-index:1;background:linear-gradient(to bottom, var(--rd-bg) 0%, transparent 32%, transparent 68%, var(--rd-bg) 100%)}.RollDate__time__list{will-change:transform;position:relative;z-index:0}.RollDate__time__item{height:28px;display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:600;color:var(--rd-text-disabled);transition:color .15s ease,font-size .15s ease}.RollDate__time__item--active{color:var(--rd-text-primary);font-size:15px;font-weight:700}.RollDate__time__sep{font-size:20px;font-weight:700;color:var(--rd-text-primary);line-height:1;padding-bottom:2px;align-self:center;margin-top:0}.RollDate__time--12h{flex-wrap:wrap;gap:6px;padding-top:2px}.RollDate__time--12h .RollDate__time__display{order:-1;width:100%;flex:1 1 100%;border-left:none;padding:0 0 4px;min-width:0;font-size:22px;letter-spacing:.04em}.RollDate__time--12h .RollDate__time__picker{width:100%;flex:1 1 100%;justify-content:center;gap:2px}.RollDate__time--12h .RollDate__time__arrow{width:18px}.RollDate__time--12h .RollDate__time__viewport{width:42px}.RollDate__time--12h .RollDate__time__field--period .RollDate__time__viewport{width:36px}.RollDate__time--12h .RollDate__time__sep{font-size:18px}.RollDate__has-footer .RollDate__calendar{height:260px}.RollDate__has-time .RollDate__calendar{height:258px}.RollDate__has-footer.RollDate__has-time .RollDate__calendar{height:230px}@media(max-width: 380px){.RollDate__container{width:min(100vw - 16px,360px);padding:6px 8px}.RollDate__header{margin-bottom:8px;height:34px}.RollDate__header__year,.RollDate__header__month{font-size:13px}.RollDate__calendar{height:268px}.RollDate__calendar__header{margin-bottom:6px}.RollDate__calendar__header__weekday{height:22px;font-size:11px}.RollDate__calendar__day{height:36px;font-size:13px}.RollDate__calendar__month,.RollDate__calendar__year{height:60px;font-size:13px}.RollDate__calendar__button{width:28px;height:28px}}/*# sourceMappingURL=rolldate.min.css.map */
|
|
1
|
+
.RollDate__container{display:flex;flex-direction:column;padding:6px 11px;width:360px;--rd-time-panel-w: 168px;--rd-time-separator-gap: 11px;--rd-time-item-h: 32px;--rd-time-visible: 3;--rd-bg: #232830;--rd-border: #343b48;--rd-text-primary: #f1f5f9;--rd-text-secondary: #94a3b8;--rd-text-disabled: #4b5563;--rd-text-disabled-contrast: #64748b;--rd-header-muted: #94a3b8;--rd-weekday: #cbd5e1;--rd-hover-bg: #2d3544;--rd-hover-border: #475569;--rd-accent: #60a5fa;--rd-accent-strong: #2563eb;--rd-accent-dark: #1d4ed8;--rd-accent-muted: rgba(37, 99, 235, 0.18);--rd-range: #a78bfa;--rd-range-strong: #7c3aed;--rd-range-muted: #3d3558;--rd-button-icon: #cbd5e1;background:var(--rd-bg);border:1px solid var(--rd-border);box-sizing:border-box;font-family:"Segoe UI",Arial,sans-serif;overscroll-behavior:contain;border-radius:12px}.RollDate__container *{box-sizing:border-box}.RollDate__container.RollDate__theme_main{--rd-bg: #232830;--rd-border: #343b48;--rd-text-primary: #f1f5f9;--rd-text-secondary: #94a3b8;--rd-text-disabled: #4b5563;--rd-text-disabled-contrast: #64748b;--rd-header-muted: #94a3b8;--rd-weekday: #cbd5e1;--rd-hover-bg: #2d3544;--rd-hover-border: #475569;--rd-accent: #60a5fa;--rd-accent-strong: #2563eb;--rd-accent-dark: #1d4ed8;--rd-accent-muted: rgba(37, 99, 235, 0.18);--rd-range: #a78bfa;--rd-range-strong: #7c3aed;--rd-range-muted: #3d3558;--rd-button-icon: #cbd5e1}.RollDate__container.RollDate__theme_dark{--rd-time-item-h: 28px;--rd-bg: #323232;--rd-border: #626262;--rd-text-primary: #e6e6e6;--rd-text-secondary: #848685;--rd-text-disabled: #515252;--rd-text-disabled-contrast: #a2a2a2;--rd-header-muted: #848685;--rd-weekday: #f7f7f7;--rd-hover-bg: #3e3e3e;--rd-hover-border: #686868;--rd-accent: #609ef1;--rd-accent-strong: #368cfd;--rd-accent-dark: #1e5093;--rd-accent-muted: #375985;--rd-range: #a78bfa;--rd-range-strong: #7c3aed;--rd-range-muted: #3d3558;--rd-button-icon: #fff}.RollDate__container.RollDate__theme_dark .RollDate__time__viewport::before{border-color:var(--rd-hover-border);background:var(--rd-hover-bg)}.RollDate__container.RollDate__theme_dark .RollDate__time__item--active{color:var(--rd-text-primary)}.RollDate__container.RollDate__theme_dark .RollDate__time__segment-btn--active{background:var(--rd-hover-border);color:var(--rd-text-primary)}.RollDate__container.RollDate__theme_dark .RollDate__time__segmented{border-color:var(--rd-hover-border);background:var(--rd-hover-bg)}.RollDate__container.RollDate__theme_light{--rd-time-item-h: 28px;--rd-bg: #ffffff;--rd-border: #d8dde6;--rd-text-primary: #1f2937;--rd-text-secondary: #5f6b7a;--rd-text-disabled: #a1aab8;--rd-text-disabled-contrast: #8c97a8;--rd-header-muted: #9aa3b2;--rd-weekday: #334155;--rd-hover-bg: #f3f6fb;--rd-hover-border: #ccd5e3;--rd-accent: #4f8ff7;--rd-accent-strong: #2d7cff;--rd-accent-dark: #1f5dc1;--rd-accent-muted: #d9e8ff;--rd-range: #8b5cf6;--rd-range-strong: #6d28d9;--rd-range-muted: #ede9fe;--rd-button-icon: #334155}.RollDate__container.RollDate__theme_light .RollDate__time__viewport::before{border-color:var(--rd-hover-border);background:var(--rd-hover-bg)}.RollDate__container.RollDate__theme_light .RollDate__time__item--active{color:var(--rd-text-primary)}.RollDate__container.RollDate__theme_light .RollDate__time__segment-btn--active{background:var(--rd-hover-border);color:var(--rd-text-primary)}.RollDate__container.RollDate__theme_light .RollDate__time__segmented{border-color:var(--rd-hover-border);background:var(--rd-hover-bg)}.RollDate__container.RollDate__calendar__type--days .RollDate__calendar__header{display:flex}.RollDate__container.RollDate__calendar__type--days .RollDate__calendar__days{display:grid;transform:scale(1, 1);opacity:1;pointer-events:auto}.RollDate__container.RollDate__calendar__type--days .RollDate__header__month{display:inline-flex}.RollDate__container.RollDate__calendar__type--months .RollDate__calendar__months{display:grid;transform:scale(1, 1);opacity:1;pointer-events:auto}.RollDate__container.RollDate__calendar__type--years .RollDate__calendar__years{display:grid;transform:scale(1, 1);opacity:1;pointer-events:auto}.RollDate__container.RollDate__calendar__type--years .RollDate__calendar__switcher{color:var(--rd-header-muted);cursor:default}.RollDate__container.RollDate__calendar__type--years .RollDate__calendar__switcher:hover{background-color:rgba(0,0,0,0)}.RollDate__container.RollDate__calendar__type--years .RollDate__header__year,.RollDate__container.RollDate__calendar__type--years .RollDate__header__month{color:var(--rd-header-muted)}.RollDate__container.RollDate__has-time .RollDate__time-separator{flex-shrink:0;background:var(--rd-border)}.RollDate__container.RollDate__has-time.RollDate__time-position_right{--rd-time-visible: 5;width:calc(360px + var(--rd-time-separator-gap)*2 + 1px + var(--rd-time-panel-w))}.RollDate__container.RollDate__has-time.RollDate__time-position_right .RollDate__content{flex-direction:row;align-items:stretch}.RollDate__container.RollDate__has-time.RollDate__time-position_right .RollDate__calendar{flex:0 0 338px;width:338px;min-width:338px;max-width:338px}.RollDate__container.RollDate__has-time.RollDate__time-position_right .RollDate__time-separator{flex:0 0 1px;width:1px;margin:0 var(--rd-time-separator-gap);align-self:stretch}.RollDate__container.RollDate__has-time.RollDate__time-position_right .RollDate__time-panel{flex:0 0 var(--rd-time-panel-w);width:var(--rd-time-panel-w);display:flex;align-items:center;justify-content:center;align-self:stretch;padding:8px 6px}.RollDate__container.RollDate__has-time.RollDate__time-position_bottom{--rd-time-visible: 3}.RollDate__container.RollDate__has-time.RollDate__time-position_bottom .RollDate__content{flex-direction:column}.RollDate__container.RollDate__has-time.RollDate__time-position_bottom .RollDate__calendar{flex:1 1 auto;width:auto;min-width:0;max-width:none}.RollDate__container.RollDate__has-time.RollDate__time-position_bottom .RollDate__time-separator{flex:0 0 auto;width:auto;height:1px;margin:var(--rd-time-separator-gap) 0;align-self:stretch}.RollDate__container.RollDate__has-time.RollDate__time-position_bottom .RollDate__time-panel{flex:0 0 auto;width:100%;display:flex;align-items:center;justify-content:center;padding:8px 4px 4px}.RollDate__container.RollDate__has-time.RollDate__time-position_bottom .RollDate__time{flex-direction:row;align-items:center;gap:8px}.RollDate__container.RollDate__has-time.RollDate__time-position_bottom .RollDate__time__period{width:auto;max-width:none}.RollDate__header{flex:0 0 auto;display:flex;align-items:center;margin-bottom:10px;height:36px}.RollDate__header__year,.RollDate__header__month{flex:0 0 auto;display:inline-flex;align-items:center;font-size:14px;font-weight:600;color:var(--rd-text-primary)}.RollDate__header__month{display:none;margin-left:4px}.RollDate__calendar{flex:1 0 auto;display:flex;flex-direction:column;min-width:0}.RollDate__calendar>.RollDate__header{flex:0 0 auto}.RollDate__calendar__switcher{display:flex;padding:4px 12px;height:30px;cursor:pointer;border-radius:4px;transition:all .3s}.RollDate__calendar__switcher:hover{background:var(--rd-hover-bg)}.RollDate__calendar__header{display:none;flex:0 0 auto;grid-template-columns:repeat(7, 1fr);margin-bottom:8px;color:var(--rd-weekday)}.RollDate__calendar__header__weekday{display:flex;justify-content:center;align-items:center;width:100%;min-width:0;height:24px;font-size:12px}.RollDate__calendar__body{flex:0 0 251px;height:251px;min-height:251px;overflow:hidden;touch-action:none}.RollDate__calendar__days{grid-template-columns:repeat(7, 1fr);gap:2px;opacity:0;pointer-events:none;transition:transform .3s,opacity .3s}.RollDate__calendar__months,.RollDate__calendar__years{grid-template-columns:repeat(4, 1fr);gap:4px;opacity:0;pointer-events:none;transition:transform .3s,opacity .3s}.RollDate__calendar__day{display:flex;align-items:center;justify-content:center;height:40px;font-size:14px;color:var(--rd-text-secondary);cursor:pointer;transition:all .3s;border-radius:4px;border:2px solid rgba(0,0,0,0);position:relative}.RollDate__calendar__day:hover{border-color:var(--rd-hover-border)}.RollDate__calendar__day--selected{border-color:var(--rd-accent-dark)}.RollDate__calendar__day--selected:hover{border-color:var(--rd-accent-strong)}.RollDate__calendar__day--range-first,.RollDate__calendar__day--range-last{background:var(--rd-range-strong);color:#fff;border-color:rgba(0,0,0,0);font-weight:600}.RollDate__calendar__day--range-first:hover,.RollDate__calendar__day--range-last:hover{background:var(--rd-range);border-color:rgba(0,0,0,0)}.RollDate__calendar__day--range-first .RollDate__calendar__day-dot:not(.RollDate__calendar__day-dot--custom):not(.RollDate__calendar__day-dot--more),.RollDate__calendar__day--range-last .RollDate__calendar__day-dot:not(.RollDate__calendar__day-dot--custom):not(.RollDate__calendar__day-dot--more){background:#fff}.RollDate__calendar__day--range-selected{background:var(--rd-range-muted);color:var(--rd-text-primary);border-color:rgba(0,0,0,0);border-radius:2px}.RollDate__calendar__day--range-selected:hover{background:var(--rd-range-muted);border-color:rgba(0,0,0,0)}.RollDate__calendar__day--active{color:var(--rd-text-primary)}.RollDate__calendar__day--active.RollDate__calendar__day--disabled{color:var(--rd-text-disabled)}.RollDate__calendar__day--today{background:var(--rd-accent);color:#fff;border-color:rgba(0,0,0,0)}.RollDate__calendar__day--today:hover{border-color:var(--rd-accent-strong);background:var(--rd-accent-strong)}.RollDate__calendar__day--today.RollDate__calendar__day--range-first,.RollDate__calendar__day--today.RollDate__calendar__day--range-last,.RollDate__calendar__day--today.RollDate__calendar__day--range-selected{background:var(--rd-accent);color:#fff}.RollDate__calendar__day--today.RollDate__calendar__day--range-first:hover,.RollDate__calendar__day--today.RollDate__calendar__day--range-last:hover,.RollDate__calendar__day--today.RollDate__calendar__day--range-selected:hover{background:var(--rd-accent-strong);border-color:rgba(0,0,0,0)}.RollDate__calendar__day-dots{position:absolute;bottom:2px;left:50%;transform:translateX(-50%);display:flex;gap:2px;align-items:center;justify-content:center;max-width:calc(100% - 4px);pointer-events:none}.RollDate__calendar__day-dot{width:5px;height:5px;border-radius:50%;background:var(--rd-accent);flex-shrink:0}.RollDate__calendar__day-dot--custom{background:var(--rd-highlight-dot)}.RollDate__calendar__day-dot--compact{width:4px;height:4px}.RollDate__calendar__day-dot--more{width:auto;height:auto;background:none;color:var(--rd-text-secondary);font-size:8px;line-height:1;font-weight:700;padding-left:1px}.RollDate__calendar__day--disabled{color:var(--rd-text-disabled);cursor:default}.RollDate__calendar__day--disabled:hover{border-color:rgba(0,0,0,0)}.RollDate__calendar__day--disabled.RollDate__calendar__day--today{color:var(--rd-text-disabled-contrast);background:var(--rd-accent-muted)}.RollDate__calendar__month,.RollDate__calendar__year{display:flex;align-items:center;justify-content:center;height:59.75px;min-height:59.75px;font-size:14px;color:var(--rd-text-secondary);cursor:pointer;transition:all .3s;border-radius:4px}.RollDate__calendar__month:hover,.RollDate__calendar__year:hover{border:2px solid var(--rd-hover-border)}.RollDate__calendar__month--active,.RollDate__calendar__year--active{color:var(--rd-text-primary)}.RollDate__calendar__month--current,.RollDate__calendar__year--current{background:var(--rd-accent);color:#fff}.RollDate__calendar__month--current:hover,.RollDate__calendar__year--current:hover{border:2px solid var(--rd-accent-strong);background:var(--rd-accent-strong)}.RollDate__calendar__month--disabled,.RollDate__calendar__year--disabled{color:var(--rd-text-disabled);cursor:default}.RollDate__calendar__month--disabled:hover,.RollDate__calendar__year--disabled:hover{border:none}.RollDate__calendar__month--disabled.RollDate__calendar__month--current{color:var(--rd-text-disabled-contrast);background:var(--rd-accent-muted)}.RollDate__calendar__year--disabled.RollDate__calendar__year--current{color:var(--rd-text-disabled-contrast);background:var(--rd-accent-muted)}.RollDate__calendar__buttons{display:flex;align-items:center;margin-left:auto}.RollDate__calendar__button{display:flex;align-items:center;justify-content:center;margin-left:2px;width:30px;height:30px;border-radius:4px;transition:background-color .3s;background:none;border:none;cursor:pointer}.RollDate__calendar__button:hover{background:var(--rd-hover-bg)}.RollDate__calendar__button svg{width:6px;height:5px;fill:var(--rd-button-icon)}.RollDate__calendar__button[data-direction=next]{transform:rotate(-180deg)}.RollDate__presets{flex:0 0 auto;display:flex;flex-wrap:wrap;gap:6px;margin-top:10px;padding-top:10px;border-top:1px solid var(--rd-border)}.RollDate__presets__button{border:1px solid var(--rd-border);background:var(--rd-hover-bg);color:var(--rd-text-primary);border-radius:6px;padding:5px 10px;font-size:11px;font-weight:600;cursor:pointer;transition:background-color .2s,border-color .2s}.RollDate__presets__button:hover{border-color:var(--rd-range);background:var(--rd-range-muted)}.RollDate__content{display:flex;flex-direction:column;flex:1 1 auto;min-height:0}.RollDate__time-panel{flex:0 0 auto}.RollDate__footer{flex:0 0 auto;margin-top:10px;padding-top:10px;border-top:1px solid var(--rd-border);display:flex;flex-direction:column;gap:10px}.RollDate__footer__buttons{display:flex;flex-wrap:wrap;gap:8px;justify-content:flex-end}.RollDate__footer__button{border:1px solid var(--rd-border);background:var(--rd-hover-bg);color:var(--rd-text-primary);border-radius:8px;padding:8px 16px;font-size:12px;font-weight:600;cursor:pointer;transition:background-color .2s,border-color .2s,color .2s}.RollDate__footer__button:hover{border-color:var(--rd-accent);background:var(--rd-accent-muted)}.RollDate__footer__button--secondary{border-color:var(--rd-border);background:var(--rd-hover-bg);color:var(--rd-text-primary)}.RollDate__footer__button--secondary:hover{border-color:var(--rd-hover-border);background:var(--rd-hover-bg);color:var(--rd-text-primary)}.RollDate__footer__button--primary{border-color:rgba(0,0,0,0);background:var(--rd-accent-strong);color:#fff}.RollDate__footer__button--primary:hover{border-color:rgba(0,0,0,0);background:var(--rd-accent);color:#fff}.RollDate__time{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;user-select:none;width:100%}.RollDate__time:not(.RollDate__time--12h) .RollDate__time__period{display:none}.RollDate__time__period{flex:0 0 auto;width:100%;max-width:118px}.RollDate__time__segmented{display:flex;border:1.5px solid var(--rd-accent-strong);border-radius:8px;padding:2px;background:var(--rd-accent-muted);gap:2px;height:var(--rd-time-item-h, 28px);box-sizing:border-box;align-items:stretch;width:100%}.RollDate__time__segment-btn{flex:1 1 0;min-width:40px;border:none;background:rgba(0,0,0,0);color:var(--rd-text-secondary);font-size:12px;font-weight:700;line-height:1;padding:0 6px;border-radius:6px;cursor:pointer;transition:background-color .15s ease,color .15s ease;display:flex;align-items:center;justify-content:center}.RollDate__time__segment-btn--active{background:var(--rd-accent-strong);color:#fff}.RollDate__time__picker{display:flex;align-items:center;justify-content:center;gap:4px;flex:0 0 auto;min-width:0}.RollDate__time__field{flex:0 0 auto;width:auto}.RollDate__time__column{display:flex;flex-direction:column;align-items:center}.RollDate__time__viewport{position:relative;width:52px;height:calc(var(--rd-time-item-h, 28px)*var(--rd-time-visible, 3));overflow:hidden;border-radius:8px;touch-action:none}.RollDate__time__viewport::before{content:"";position:absolute;left:4px;right:4px;top:50%;transform:translateY(-50%);height:var(--rd-time-item-h, 28px);border:1.5px solid var(--rd-accent-strong);border-radius:8px;background:var(--rd-accent-muted);pointer-events:none;z-index:2;box-sizing:border-box}.RollDate__time__viewport::after{content:"";position:absolute;inset:0;pointer-events:none;z-index:4;background:linear-gradient(to bottom, var(--rd-bg) 0%, transparent 28%, transparent 72%, var(--rd-bg) 100%)}.RollDate__time__list{will-change:transform;position:relative;z-index:3}.RollDate__time__item{height:var(--rd-time-item-h, 28px);display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:600;color:var(--rd-text-disabled);cursor:pointer;transition:color .15s ease,opacity .15s ease}.RollDate__time__item--active{color:var(--rd-accent-strong);font-size:15px;font-weight:700}.RollDate__time__sep{font-size:20px;font-weight:700;color:var(--rd-text-secondary);line-height:1;align-self:center;margin-top:0}.RollDate__theme_main .RollDate__calendar__day--today:not(.RollDate__calendar__day--range-first):not(.RollDate__calendar__day--range-last):not(.RollDate__calendar__day--range-selected){background:var(--rd-accent-strong);color:#fff;border-color:rgba(0,0,0,0)}.RollDate__theme_main .RollDate__calendar__day--today:not(.RollDate__calendar__day--range-first):not(.RollDate__calendar__day--range-last):not(.RollDate__calendar__day--range-selected):hover{background:var(--rd-accent);border-color:rgba(0,0,0,0)}@media(max-width: 640px){.RollDate__container{width:min(100vw - 16px,360px);padding:6px 8px;--rd-time-item-h: 28px}.RollDate__container.RollDate__has-time.RollDate__time-position_right,.RollDate__container.RollDate__has-time.RollDate__time-position_bottom{--rd-time-visible: 3;width:min(100vw - 16px,360px)}.RollDate__container.RollDate__has-time.RollDate__time-position_right .RollDate__content,.RollDate__container.RollDate__has-time.RollDate__time-position_bottom .RollDate__content{flex-direction:column}.RollDate__container.RollDate__has-time.RollDate__time-position_right .RollDate__calendar,.RollDate__container.RollDate__has-time.RollDate__time-position_bottom .RollDate__calendar{flex:1 1 auto;width:auto;min-width:0;max-width:none}.RollDate__container.RollDate__has-time.RollDate__time-position_right .RollDate__time-separator,.RollDate__container.RollDate__has-time.RollDate__time-position_bottom .RollDate__time-separator{flex:0 0 auto;width:auto;height:1px;margin:var(--rd-time-separator-gap) 0;align-self:stretch}.RollDate__container.RollDate__has-time.RollDate__time-position_right .RollDate__time-panel,.RollDate__container.RollDate__has-time.RollDate__time-position_bottom .RollDate__time-panel{flex:0 0 auto;width:100%;padding:8px 4px 4px}.RollDate__container.RollDate__has-time.RollDate__time-position_right .RollDate__time,.RollDate__container.RollDate__has-time.RollDate__time-position_bottom .RollDate__time{flex-direction:row;align-items:center;gap:8px}.RollDate__container.RollDate__has-time.RollDate__time-position_right .RollDate__time__period,.RollDate__container.RollDate__has-time.RollDate__time-position_bottom .RollDate__time__period{width:auto;max-width:none}.RollDate__container.RollDate__has-time.RollDate__time-position_right .RollDate__time__viewport,.RollDate__container.RollDate__has-time.RollDate__time-position_bottom .RollDate__time__viewport{width:48px}.RollDate__header{margin-bottom:8px;height:34px}.RollDate__header__year,.RollDate__header__month{font-size:13px}.RollDate__calendar__body{flex:0 0 226px;height:226px;min-height:226px}.RollDate__calendar__header{margin-bottom:6px}.RollDate__calendar__header__weekday{height:22px;font-size:11px}.RollDate__calendar__day{height:36px;font-size:13px}.RollDate__calendar__month,.RollDate__calendar__year{height:53.5px;min-height:53.5px;font-size:13px}.RollDate__calendar__button{width:28px;height:28px}}/*# sourceMappingURL=rolldate.min.css.map */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var RollDate=function(){"use strict";function t(t){return t}function e(t){return 10*Math.floor(t/10)}let s=0,i=null;function a(t=!0){if(!t||"undefined"==typeof window)return;const e="undefined"!=typeof performance?performance.now():Date.now();if(!(e-s<28)){s=e;try{if("undefined"!=typeof navigator&&"function"==typeof navigator.vibrate)return void navigator.vibrate(10)}catch{}!function(){try{const t=window.AudioContext||window.webkitAudioContext;if(!t)return;i||(i=new t),"suspended"===i.state&&i.resume().catch(()=>{});const e=i.currentTime,s=i.createOscillator(),a=i.createGain();s.type="triangle",s.frequency.value=180,a.gain.setValueAtTime(1e-4,e),a.gain.exponentialRampToValueAtTime(.045,e+.008),a.gain.exponentialRampToValueAtTime(1e-4,e+.04),s.connect(a),a.connect(i.destination),s.start(e),s.stop(e+.045)}catch{}}()}}function n(t,e="auto"){if(!t)return null;const s=t.trim();if(!s)return null;if(t instanceof Date)return t;if(/^\d{4}-\d{2}-\d{2}$/.test(s))return new Date(s);if("auto"===e){const t=s.match(/[-/.]/)?.[0]||".",e=s.split(t).map(Number);if(3!==e.length)return null;const[i,a,n]=e;let o,r,l;return i>=1e3?[o,r,l]=[i,a,n]:[l,r,o]=[i,a,n],new Date(o,r-1,l)}const i={"YYYY-MM-DD":/^(\d{4})[-/\.](\d{1,2})[-/\.](\d{1,2})$/,"DD/MM/YYYY":/^(\d{1,2})[-/\.](\d{1,2})[-/\.](\d{4})$/,"MM/DD/YYYY":/^(\d{1,2})[-/\.](\d{1,2})[-/\.](\d{4})$/,"DD.MM.YYYY":/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/,"MM.DD.YYYY":/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/}[e];if(!i)return console.warn(`RollDate: unknown format "${e}". Using auto-detect.`),n(t,"auto");const a=s.match(i);if(!a)return null;let o,r,l;switch(e){case"YYYY-MM-DD":[,o,r,l]=a;break;case"DD/MM/YYYY":case"DD.MM.YYYY":[,l,r,o]=a;break;case"MM/DD/YYYY":case"MM.DD.YYYY":[,r,l,o]=a}return new Date(Number(o),Number(r)-1,Number(l))}function o(t,e){return"string"==typeof t?n(t,e):t}function r(t,e){const s=(t.getDay()-Number(e)+7)%7;return new Date(t.getFullYear(),t.getMonth(),t.getDate()-s)}function l(t,e){const s=(6-t.getDay()+Number(e)+7)%7;return new Date(t.getFullYear(),t.getMonth(),t.getDate()+s)}class h{constructor(t){this.$container=t,this.intersecting=new Map,this.init()}init(){return this.observe=new IntersectionObserver(t=>{t.forEach(t=>{const e=`${t.target.dataset.year}${t.target.dataset?.month?"_"+t.target.dataset.month:""}${t.target.dataset?.day?"_"+t.target.dataset.day:""}`;t.isIntersecting?this.intersecting.set(e,t):this.intersecting.delete(e)})},{threshold:.5})}on(t,e){this.$container.querySelectorAll(`.RollDate__calendar__${t}`).forEach(t=>{e&&e(t),this.observe.observe(t)})}un(){this.intersecting.clear(),this.$container.querySelectorAll(".RollDate__calendar__day, .RollDate__calendar__month, .RollDate__calendar__year").forEach(t=>{this.observe.unobserve(t)})}dominant(){if(0===this.intersecting.size)return null;const t={};let e=[];this.intersecting.forEach(s=>{const i={};e=JSON.parse(s.target.dataset.bind);for(const t of e)i[t]=s.target.dataset[t];const a=Object.values(i).join("-");t[a]=(t[a]||0)+1});const s=Object.keys(t).reduce((e,s)=>t[e]>t[s]?e:s).split("-").map(Number);return Object.fromEntries(e.map((t,e)=>[t,s[e]]))}disconnect(){this.observe?.disconnect()}}class d{up_date=null;down_date=null;current_year;current_month;current_decade;constructor(t){this.options=t,this.current_year=this.options.startDate.getFullYear(),this.current_month=this.options.startDate.getMonth(),this.current_decade=e(this.current_year)}get currentPeriod(){return{year:this.current_year,month:this.current_month,decade:this.current_decade}}setPeriod(t){"year"in t&&(this.current_year=t.year),"month"in t&&(this.current_month=t.month),"decade"in t&&(this.current_decade=t.decade)}getDates(){let t=new Date(this.current_year,this.current_month-3,1),e=new Date(this.current_year,this.current_month+3,0);if(this.options.minDate&&this.options.minDate>t&&(t=new Date(this.options.minDate.getFullYear(),this.options.minDate.getMonth(),1)),this.options.maxDate&&this.options.maxDate<e&&(e=new Date(this.options.maxDate.getFullYear(),this.options.maxDate.getMonth()+1,0)),this.options.minDate&&this.options.maxDate&&this.options.minDate.getFullYear()===this.options.maxDate.getFullYear()&&this.options.minDate.getMonth()===this.options.maxDate.getMonth()){const s=this.options.minDate.getFullYear(),i=this.options.minDate.getMonth();t=new Date(s,i,1),e=new Date(s,i+1,1)}t=r(t,this.options.startWeekFromMonday),e=l(e,this.options.startWeekFromMonday);const s=Math.floor((e-t)/864e5)+1;if(s<42){const i=42-s,a=Math.ceil(i/2),n=Math.floor(i/2);t.setDate(t.getDate()-a),e.setDate(e.getDate()+n),t=r(t,this.options.startWeekFromMonday),e=l(e,this.options.startWeekFromMonday)}this.up_date=new Date(t),this.down_date=new Date(e);const i=[];for(let s=new Date(t);s<=e;s.setDate(s.getDate()+1)){const t=!!this.options.isDateDisabled&&this.options.isDateDisabled(s),e=this.options.minDate&&s<this.options.minDate||this.options.maxDate&&s>this.options.maxDate||t;i.push({date:new Date(s),disabled:e})}return i}getMonthsOrYears(t){let e=this.current_year-("month"===t?5:18),s=this.current_year+("month"===t?5:18);if(this.options.minDate){const t=this.options.minDate.getFullYear();t>e&&(e=t)}if(this.options.maxDate){const t=this.options.maxDate.getFullYear();t<s&&(s=t)}if("month"===t&&this.options.minDate&&this.options.maxDate&&this.options.minDate.getFullYear()===this.options.maxDate.getFullYear()){const t=this.options.minDate.getFullYear();e=t-2,s=t+2}this.up_date=new Date(e,0,1),this.down_date=new Date(s+1,0,0);const i=[];for(let a=e;a<=s;a++)if("month"===t)for(let t=0;t<12;t++){const e=new Date(a,t,1),s=new Date(a,t+1,0);let n=!1;(this.options.minDate&&s<this.options.minDate||this.options.maxDate&&e>this.options.maxDate)&&(n=!0),i.push({date:e,disabled:n})}else{const t=new Date(a,0,1);let e=!1;(this.options.minDate&&a<this.options.minDate.getFullYear()||this.options.maxDate&&a>this.options.maxDate.getFullYear())&&(e=!0),i.push({date:t,disabled:e})}if(i.length<16){let e=s+1;for(;i.length<16;){if("month"===t)for(let t=0;t<12&&i.length<16;t++)i.push({date:new Date(e,t,1),disabled:!0});else i.push({date:new Date(e,0,1),disabled:!0});e++}}return i}}class c{constructor(t){this.$container=t.container,this.$trigger=t.trigger,this.startWeekFromMonday=t.startWeekFromMonday,this.monthsNames=t.monthsNames,this.monthsShortNames=t.monthsShortNames,this.enableTime=Boolean(t.enableTime),this.hasFooter=Boolean(t.enableTime||t.footerButtons&&t.footerButtons.length),this.init()}init(){const t=this.hasFooter?`\n <div class="RollDate__footer">\n ${this.enableTime?'<div class="RollDate__time"></div>':""}\n <div class="RollDate__footer__buttons"></div>\n </div>\n `:"";this.$container.innerHTML=`\n <div class="RollDate__header">\n <div class="RollDate__calendar__switcher">\n <div class="RollDate__header__year"></div>\n <div class="RollDate__header__month"></div>\n </div>\n <div class="RollDate__calendar__buttons">\n <button class="RollDate__calendar__button" data-direction="prev">\n <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 61 55" width="55" height="50">\n <path id="Форма 2" fill-rule="evenodd" class="s0" d="m52.76 54.67l-44.73 0.12c-6.16 0.02-10.02-6.64-6.96-11.98l22.26-38.79c3.07-5.35 10.76-5.37 13.86-0.04l22.47 38.67c3.09 5.33-0.74 12.01-6.9 12.02z"/>\n </svg>\n </button>\n <button class="RollDate__calendar__button" data-direction="next">\n <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 61 55" width="55" height="50">\n <path id="Форма 2" fill-rule="evenodd" class="s0" d="m52.76 54.67l-44.73 0.12c-6.16 0.02-10.02-6.64-6.96-11.98l22.26-38.79c3.07-5.35 10.76-5.37 13.86-0.04l22.47 38.67c3.09 5.33-0.74 12.01-6.9 12.02z" />\n </svg>\n </button>\n </div>\n </div>\n <div class="RollDate__calendar">\n <div class="RollDate__calendar__header">\n ${this.#t()}\n </div>\n <div class="RollDate__calendar__body">\n <div class="RollDate__calendar__scrollblock">\n <div class="RollDate__calendar__days"></div>\n <div class="RollDate__calendar__months"></div>\n <div class="RollDate__calendar__years"></div>\n </div>\n </div>\n </div>\n ${t}\n `,"DIV"===this.$trigger.nodeName||"SPAN"===this.$trigger.nodeName||"SECTION"===this.$trigger.nodeName?this.$trigger.append(this.$container):document.body.append(this.$container)}#t(){const e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];let s="";const i=Number(this.startWeekFromMonday);for(let a=i;a<7+i;a++)s+=`<div class="RollDate__calendar__header__weekday">${t(e[a%7])}</div>`;return s}dates(t,e=[],s="single"){let i="";const a=new Date;for(let n=0;n<t.length;n++){const o=t[n].date,r=t[n].disabled?"RollDate__calendar__day--disabled":"",l=o.toDateString()===a.toDateString();let h="";if("single"===s||"multi"===s){e.some(t=>t.getTime()===o.getTime())&&(h="RollDate__calendar__day--selected")}else if("range"===s&&2===e.length){const[t,s]=e,i=o.getTime();i===t.getTime()?h="RollDate__calendar__day--range-first":i===s.getTime()?h="RollDate__calendar__day--range-last":i>t.getTime()&&i<s.getTime()&&(h="RollDate__calendar__day--range-selected")}i+=`<div class="RollDate__calendar__day ${r} ${l?"RollDate__calendar__day--today":""} ${h}" \n data-bind='["year", "month"]'\n data-year="${o.getFullYear()}"\n data-month="${o.getMonth()}" \n data-day="${o.getDate()}">${o.getDate()}</div>`}return i}months(t){let e="";for(let s=0;s<t.length;s++){const i=new Date(t[s].date),a=t[s].disabled,n=i.getMonth();let o="";i.getFullYear()===(new Date).getFullYear()&&n===(new Date).getMonth()&&(o="RollDate__calendar__month--current"),e+=`<div class="RollDate__calendar__month${a?" RollDate__calendar__month--disabled":""} ${o}" \n data-bind='["year"]'\n data-month="${n}" \n data-year="${i.getFullYear()}"\n data-click="day">\n ${this.monthsShortNames[n]} \n </div>`}return e}years(t){let e="";for(let s=0;s<t.length;s++){const i=new Date(t[s].date),a=t[s].disabled,n=i.getFullYear();let o="";n===(new Date).getFullYear()&&(o="RollDate__calendar__year--current"),e+=`<div class="RollDate__calendar__year${a?" RollDate__calendar__year--disabled":""} ${o}" \n data-bind='["decade"]'\n data-decade="${10*Math.floor(n/10)}"\n data-month="0" \n data-year="${n}"\n data-click="month">\n ${n} \n </div>`}return e}clear(t){t.innerHTML=""}}class u{#e=null;#s=25;#i=75;#a;#n=0;#o;#r;#l;#h;#d;#c=!1;#u=!1;#m=0;#p=!1;#_=0;#D=0;#g=0;#y=null;constructor(t,e={dominant:()=>console.error('Function "dominant" is not found'),updatePeriod:()=>console.error('Function "updatePeriod" is not found')}){this.$body=t,this.$scroll_block=this.$body.querySelector(".RollDate__calendar__scrollblock"),this.dominant=e.dominant,this.updatePeriod=e.updatePeriod,this.offset=0,this.init()}init(){this.#r=this.wheelHandler.bind(this),this.$body.addEventListener("wheel",this.#r,{passive:!1}),this.#l=this.touchStartHandler.bind(this),this.#h=this.touchMoveHandler.bind(this),this.#d=this.touchEndHandler.bind(this),this.$body.addEventListener("touchstart",this.#l,{passive:!0}),this.$body.addEventListener("touchmove",this.#h,{passive:!1}),this.$body.addEventListener("touchend",this.#d,{passive:!0}),this.$body.addEventListener("touchcancel",this.#d,{passive:!0})}wheelHandler(t){t.preventDefault(),t.stopPropagation();const e=.85*t.deltaY,s=Math.abs(e)>50?20:1,i=e/s,a=e>0?"down":"up";this.#c=!0,this.#u=!1;let n=0;const o=()=>{if(n>=s)return this.#c=!1,void(this.#u=!1);this.offset-=i,requestAnimationFrame(()=>{this.dominant(),this.checkEdge(a),n++,o()})};o()}touchStartHandler(t){t.touches&&1===t.touches.length&&(this.#f(),this.#p=!0,this.#_=t.touches[0].clientY,this.#D=performance.now(),this.#g=0,this.#u=!1)}touchMoveHandler(t){if(!this.#p||!t.touches||1!==t.touches.length)return;t.preventDefault();const e=t.touches[0].clientY,s=e-this.#_,i=performance.now(),a=i-this.#D;if(a>0&&a<120){const t=s/a;this.#g=.65*this.#g+.35*t}if(this.#_=e,this.#D=i,Math.abs(s)<1)return;this.offset+=s,this.dominant();const n=s<0?"down":"up";this.checkEdge(n)}touchEndHandler(){this.#p=!1,this.#u=!1;const t=16*this.#g;Math.abs(t)>=.4&&this.#b(t)}#f(){null!==this.#y&&(cancelAnimationFrame(this.#y),this.#y=null)}#b(t){this.#f();const e=()=>{if(Math.abs(t)<.35||this.blocked)return this.#y=null,void(this.#u=!1);this.offset+=t,t*=.92,this.dominant();const s=t<0?"down":"up";if(this.checkEdge(s),this.blocked)return this.#y=null,void(this.#u=!1);this.#y=requestAnimationFrame(e)};this.#y=requestAnimationFrame(e)}apply(){this.$scroll_block.style.transform=`translateY(${this.offset+this.#n}px)`}get offset(){return this.#a}set offset(t){this.#a=t,null!==this.#e&&(t>=0?this.#a=0:t<=this.#e&&(this.#a=this.#e)),this.apply()}get blocked(){return this.#o}set blocked(t){this.#o=t}get minScroll(){return null===this.#e&&this.checkMinScroll(),this.#e??0}checkEdge(t){if(null===this.#e&&this.checkMinScroll(),0===this.#e||this.blocked)return;if(this.#c&&this.#u)return;const e=100*Math.abs(this.offset/this.#e),s=Date.now();if(!(s-this.#m<60))if(e<this.#s){if("up"!==t)return;this.#m=s,this.#u=!0,this.blocked=!0,this.updatePeriod("up")}else if(e>this.#i){if("down"!==t)return;this.#m=s,this.#u=!0,this.blocked=!0,this.updatePeriod("down")}}checkMinScroll(){const t=this.$scroll_block.clientHeight,e=this.$body.clientHeight;this.#e=t>e?-(t-e):0}setBaseOffset(t=0){this.#n=t,this.apply()}resetMinScroll(){this.#e=null}destroy(){this.#f(),this.#r&&this.$body.removeEventListener("wheel",this.#r),this.#l&&this.$body.removeEventListener("touchstart",this.#l),this.#h&&this.$body.removeEventListener("touchmove",this.#h),this.#d&&(this.$body.removeEventListener("touchend",this.#d),this.$body.removeEventListener("touchcancel",this.#d))}}class m{constructor(t){this.ctx=t}#v(t){const e=t instanceof Date?t:new Date(t);return!!(this.ctx.options.minDate&&e<this.ctx.options.minDate)||(!!(this.ctx.options.maxDate&&e>this.ctx.options.maxDate)||"function"==typeof this.ctx.isDateDisabled&&this.ctx.isDateDisabled(e))}update(t){const e=this.ctx.period,s="up"===t;if(s){if("year"===e){if(this.ctx.data.up_date.getFullYear()<=this.ctx.options.minDate.getFullYear())return void(this.ctx.scroll.blocked=!1)}else if(this.ctx.data.up_date<=this.ctx.options.minDate)return void(this.ctx.scroll.blocked=!1)}else if("year"===e){if(this.ctx.data.down_date.getFullYear()>=this.ctx.options.maxDate.getFullYear())return void(this.ctx.scroll.blocked=!1)}else if(this.ctx.data.down_date>=this.ctx.options.maxDate)return void(this.ctx.scroll.blocked=!1);const i={day:{count:35,getNewItems:(t,e)=>{const i=[];if(s){let e=new Date(t);if(e.setDate(t.getDate()-35),e<this.ctx.options.minDate){const t=this.ctx.options.minDate;e=r(new Date(t.getFullYear(),t.getMonth(),1),this.ctx.options.startWeekFromMonday)}for(let s=new Date(e);s<t;s.setDate(s.getDate()+1))i.push({date:new Date(s),disabled:this.#v(s)});return{items:i,newBound:e}}{let t=new Date(e);t.setDate(e.getDate()+35);const s=new Date(e);if(s.setDate(e.getDate()+1),t>this.ctx.options.maxDate){const e=this.ctx.options.maxDate;t=l(new Date(e.getFullYear(),e.getMonth()+1,0),this.ctx.options.startWeekFromMonday)}for(let e=s;e<=t;e.setDate(e.getDate()+1))i.push({date:new Date(e),disabled:this.#v(e)});return{items:i,newBound:t}}},render:t=>this.ctx.render.dates(t,this.ctx.selectedDates,this.ctx.options.selectType),block:this.ctx.dom.$days_block},month:{count:36,ctx:this.ctx,getNewItems:function(t,e){const i=[],a=(t,e)=>{const s=new Date(t,e,1),i=new Date(t,e+1,0);return!!(this.ctx.options.minDate&&i<this.ctx.options.minDate)||!!(this.ctx.options.maxDate&&s>this.ctx.options.maxDate)};if(s){let e=new Date(t);for(let t=0;t<this.count;t++)e.setMonth(e.getMonth()-1),i.unshift({date:new Date(e.getFullYear(),e.getMonth(),1),disabled:a(e.getFullYear(),e.getMonth())});return{items:i,newBound:i.length?i[0].date:t}}{let t=new Date(e);t.setMonth(t.getMonth()+1);for(let e=0;e<this.count;e++)i.push({date:new Date(t.getFullYear(),t.getMonth(),1),disabled:a(t.getFullYear(),t.getMonth())}),t.setMonth(t.getMonth()+1);return{items:i,newBound:i.length?i[i.length-1].date:e}}},render:t=>this.ctx.render.months(t),block:this.ctx.dom.$months_block},year:{count:16,ctx:this.ctx,getNewItems:function(t,e){const i=[];if(s){for(let e=t.getFullYear()-this.count;e<t.getFullYear();e++)e<this.ctx.options.minDate.getFullYear()||i.push({date:new Date(e,0,1),disabled:this.ctx.options.minDate.getFullYear()>e});return{items:i,newBound:i.length?i[0].date:t}}{const t=e.getFullYear()+1;for(let e=t;e<t+this.count&&!(e>this.ctx.options.maxDate.getFullYear());e++)i.push({date:new Date(e,0,1),disabled:this.ctx.options.maxDate.getFullYear()<e});return{items:i,newBound:i.length?i[i.length-1].date:e}}},render:t=>this.ctx.render.years(t),block:this.ctx.dom.$years_block}}[e];if(!i)return;const{items:a,newBound:n}=i.getNewItems(this.ctx.data.up_date,this.ctx.data.down_date);a.length&&i.block.insertAdjacentHTML(s?"afterbegin":"beforeend",i.render(a)),this.ctx.data[`${t}_date`]=n,this.ctx.observe.un();const o="year"===e?Math.min(4,a.length):a.length;this.trim(t,o),this.ctx.observe.on(e),this.ctx.scroll.blocked=!1}trim(t,e){const s=this.ctx.period,i=this.ctx.dom[`$${s}s_block`],a="up"===t,n="year"===s?28:0,o=i.scrollHeight,r=Array.from(i.querySelectorAll(`.RollDate__calendar__${s}`));if(!e||r.length<=2*e)return;if(n&&r.length-e<n)return;a?r.slice(-e).forEach(t=>t.remove()):r.slice(0,e).forEach(t=>t.remove());const l=Array.from(i.querySelectorAll(`.RollDate__calendar__${s}`)),h=l[0],d=l[l.length-1],c=t=>{if(!t)return null;const e=Number(t.dataset.year),i=Number(t.dataset.month)||0,a="day"===s?Number(t.dataset.day):1;return new Date(e,i,a)},u=c(h),m=c(d);u&&(this.ctx.data.up_date=u),m&&(this.ctx.data.down_date=m);const p=o-i.scrollHeight;this.ctx.scroll.checkMinScroll(),a?this.ctx.scroll.offset-=p:this.ctx.scroll.offset+=p}}const p=28,_='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 61 55" width="55" height="50" aria-hidden="true">\n <path fill-rule="evenodd" d="m52.76 54.67l-44.73 0.12c-6.16 0.02-10.02-6.64-6.96-11.98l22.26-38.79c3.07-5.35 10.76-5.37 13.86-0.04l22.47 38.67c3.09 5.33-0.74 12.01-6.9 12.02z"/>\n</svg>';class D{#$=0;#w=0;#T=!1;#M="AM";#S=1;#x=[];#Y=null;constructor(t,e={}){this.root=t,this.#T=Boolean(e.use12Hour),this.#S=Math.max(1,Number(e.minuteStep)||1),this.#$=this.#R(e.hours??0),this.#w=this.#N(e.minutes??0),this.#T&&(this.#M=this.#$>=12?"PM":"AM"),this.onChange=e.onChange||(()=>{}),this.hapticFeedback=!1!==e.hapticFeedback,this.#k()}#R(t){const e=Number(t);return Number.isNaN(e)?0:Math.min(23,Math.max(0,e))}#F(){if(!this.#T)return this.#$;const t=this.#$%12;return 0===t?12:t}#N(t){const e=this.#S,s=Math.round(Number(t)/e)*e;return Math.min(59,Math.max(0,Number.isNaN(s)?0:s))}#k(){const t=this.#T?Array.from({length:12},(t,e)=>e+1):Array.from({length:24},(t,e)=>e),e=[];for(let t=0;t<60;t+=this.#S)e.push(t);this.root.innerHTML=`\n <div class="RollDate__time__picker">\n <div class="RollDate__time__field" data-unit="hour">\n <div class="RollDate__time__column">\n <button type="button" class="RollDate__time__arrow RollDate__time__arrow--prev" data-dir="prev" aria-label="Earlier hour">${_}</button>\n <div class="RollDate__time__viewport">\n <div class="RollDate__time__list"></div>\n </div>\n <button type="button" class="RollDate__time__arrow RollDate__time__arrow--next" data-dir="next" aria-label="Later hour">${_}</button>\n </div>\n </div>\n <span class="RollDate__time__sep">:</span>\n <div class="RollDate__time__field" data-unit="minute">\n <div class="RollDate__time__column">\n <button type="button" class="RollDate__time__arrow RollDate__time__arrow--prev" data-dir="prev" aria-label="Earlier minute">${_}</button>\n <div class="RollDate__time__viewport">\n <div class="RollDate__time__list"></div>\n </div>\n <button type="button" class="RollDate__time__arrow RollDate__time__arrow--next" data-dir="next" aria-label="Later minute">${_}</button>\n </div>\n </div>\n ${this.#T?`\n <div class="RollDate__time__field RollDate__time__field--period" data-unit="period">\n <div class="RollDate__time__column">\n <button type="button" class="RollDate__time__arrow RollDate__time__arrow--prev" data-dir="prev" aria-label="Earlier period">${_}</button>\n <div class="RollDate__time__viewport">\n <div class="RollDate__time__list"></div>\n </div>\n <button type="button" class="RollDate__time__arrow RollDate__time__arrow--next" data-dir="next" aria-label="Later period">${_}</button>\n </div>\n </div>`:""}\n </div>\n <div class="RollDate__time__display" aria-live="polite"></div>\n `,this.#Y=this.root.querySelector(".RollDate__time__display"),this.#T&&this.root.classList.add("RollDate__time--12h"),this.#x.push(this.#H("hour",t,this.#F())),this.#x.push(this.#H("minute",e,this.#w)),this.#T&&this.#x.push(this.#H("period",["AM","PM"],this.#M)),this.#E()}#I(){const t=String(this.#$).padStart(2,"0"),e=String(this.#w).padStart(2,"0");return this.#T?`${String(this.#F()).padStart(2,"0")}:${e} ${this.#M}`:`${t}:${e}`}#E(){this.#Y&&(this.#Y.textContent=this.#I())}#H(t,e,s){const i=this.root.querySelector(`[data-unit="${t}"]`),n=i.querySelector(".RollDate__time__viewport"),o=i.querySelector(".RollDate__time__list");o.innerHTML=e.map(e=>`<div class="RollDate__time__item" data-value="${e}">${"minute"===t?String(e).padStart(2,"0"):String(e)}</div>`).join(""),o.style.paddingTop="28px",o.style.paddingBottom="28px";const r={unit:t,viewport:n,list:o,values:e,offset:0};return r.updateActive=()=>{const t=r.indexFromOffset();r._lastIndex!==t&&(void 0!==r._lastIndex&&a(this.hapticFeedback),r._lastIndex=t),o.querySelectorAll(".RollDate__time__item").forEach((e,s)=>{e.classList.toggle("RollDate__time__item--active",s===t)})},r.indexFromOffset=()=>{const t=Math.round(-r.offset/p);return Math.min(e.length-1,Math.max(0,t))},r.getValue=()=>e[r.indexFromOffset()],r.apply=t=>{o.style.transition=t?"transform 0.2s ease":"none",o.style.transform=`translateY(${r.offset}px)`,r.updateActive()},r.snap=()=>{const t=r.indexFromOffset();r.offset=-t*p,r.apply(!0),this.#L(),this.#E(),this.onChange(this.getTime())},r.scrollToValue=(t,s=!0)=>{const i=e.indexOf(t);i<0||(r.offset=-i*p,r.apply(s))},r.stepBy=t=>{const s=Math.min(e.length-1,Math.max(0,r.indexFromOffset()+t));r.offset=-s*p,r.apply(!0),this.#L(),this.#E(),this.onChange(this.getTime())},r.scrollToValue(s,!1),this.#A(r),this.#C(r),this.#O(i,r),r}#O(t,e){t.querySelector('[data-dir="prev"]')?.addEventListener("click",t=>{t.preventDefault(),e.stepBy(-1)}),t.querySelector('[data-dir="next"]')?.addEventListener("click",t=>{t.preventDefault(),e.stepBy(1)})}#A(t){t.viewport.addEventListener("wheel",e=>{e.preventDefault(),e.stopPropagation(),t.list.style.transition="none",t.offset-=.35*e.deltaY;const s=-(t.values.length-1)*p;t.offset=Math.max(s,Math.min(0,t.offset)),t.list.style.transform=`translateY(${t.offset}px)`,t.updateActive(),clearTimeout(t._snapTimer),t._snapTimer=setTimeout(()=>t.snap(),90)},{passive:!1})}#C(t){let e=0,s=0;t.viewport.addEventListener("touchstart",i=>{i.touches&&1===i.touches.length&&(e=i.touches[0].clientY,s=t.offset,t.list.style.transition="none")},{passive:!0}),t.viewport.addEventListener("touchmove",i=>{if(!i.touches||1!==i.touches.length)return;i.preventDefault(),t.offset=s+(i.touches[0].clientY-e);const a=-(t.values.length-1)*p;t.offset=Math.max(a,Math.min(0,t.offset)),t.list.style.transform=`translateY(${t.offset}px)`,t.updateActive()},{passive:!1}),t.viewport.addEventListener("touchend",()=>t.snap())}#L(){const t=this.#x.find(t=>"hour"===t.unit),e=this.#x.find(t=>"minute"===t.unit),s=this.#x.find(t=>"period"===t.unit),i=t.getValue();this.#w=e.getValue(),this.#T&&s?(this.#M=s.getValue(),"AM"===this.#M?this.#$=12===i?0:i:this.#$=12===i?12:i+12):this.#$=i}getTime(){return{hours:this.#$,minutes:this.#w}}setTime(t,e){this.#$=this.#R(t),this.#w=this.#N(e),this.#T?(this.#M=this.#$>=12?"PM":"AM",this.#x.find(t=>"hour"===t.unit)?.scrollToValue(this.#F()),this.#x.find(t=>"period"===t.unit)?.scrollToValue(this.#M)):this.#x.find(t=>"hour"===t.unit)?.scrollToValue(this.#$),this.#x.find(t=>"minute"===t.unit)?.scrollToValue(this.#w),this.#E()}destroy(){this.#x=[],this.root.innerHTML=""}}class g{static#V=new Set;#P;#q=0;#W=["day","month","year"];#B=[];#z=!0;#j=new Set;#J=null;#U=[];#G(t,e,s){return t instanceof Date&&!Number.isNaN(t.getTime())?t<e?new Date(e):t>s?new Date(s):t:e}#X(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()}#K(t){const e=o(t,this.options.dateFormat);return e instanceof Date&&!Number.isNaN(e.getTime())?new Date(e.getFullYear(),e.getMonth(),e.getDate()):null}#Q(t=[]){const e=new Set;return t.forEach(t=>{const s=this.#K(t);s&&e.add(this.#X(s))}),e}#Z(t){t&&"INPUT"===t.tagName&&(t.setAttribute("autocomplete","off"),t.setAttribute("autocorrect","off"),t.setAttribute("autocapitalize","off"),t.setAttribute("spellcheck","false"))}#tt(t){return this.#j.has(this.#X(t))}#et(){"single"!==this.options.selectType?this.options.selectDate([...this.#B]):this.options.selectDate(this.#B[0]||null)}#st(){const t=this.#B.length;this.#B=this.#B.filter(t=>!this.#tt(t)),t!==this.#B.length&&(this.#et(),this.#it())}#at(t){const e=new Date(t);if(!this.options.enableTime)return e;const s=this.timePicker?.getTime()||{hours:this.options.startDate.getHours(),minutes:this.options.startDate.getMinutes()};return e.setHours(s.hours,s.minutes,0,0),e}#nt(t){const e=function(t,e="YYYY-MM-DD"){if(!t||!(t instanceof Date)||isNaN(t))return"";const s=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),a=String(t.getDate()).padStart(2,"0"),n={YYYY:s,YY:String(s).slice(-2),MM:i,M:t.getMonth()+1,DD:a,D:t.getDate()};return e.replace(/YYYY|YY|MM|M|DD|D/g,t=>n[t]||t)}(t,this.options.dateFormat);if(!this.options.enableTime)return e;return`${e} ${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}#ot(){if(!this.dom.$footer_buttons)return;const t=Array.isArray(this.options.footerButtons)?this.options.footerButtons:[];this.dom.$footer_buttons.innerHTML="",t.forEach(t=>{if(!t?.text)return;const e=document.createElement("button");e.type="button",e.className="RollDate__footer__button",e.textContent=t.text,e.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),this.#rt(t)}),this.dom.$footer_buttons.append(e)})}#rt(t){"today"!==t.action?"clear"!==t.action?"function"==typeof t.onClick&&t.onClick(this):this.clearSelection():this.selectToday()}#lt(){const t=this.options.startDate;this.timePicker=new D(this.dom.$time,{hours:t.getHours(),minutes:t.getMinutes(),use12Hour:this.options.use12Hour,minuteStep:this.options.timeStep,hapticFeedback:!1!==this.options.hapticFeedback,onChange:()=>{this.#B.length&&(this.#B=this.#B.map(t=>this.#at(t)),this.#et(),this.#it())}})}constructor(t,e={}){null==e&&(e={}),this.triggerSelector=e.triggerSelector,Array.isArray(t)?(this.$startInput=document.querySelector(t[0]),this.$endInput=document.querySelector(t[1]),this.$trigger=this.$startInput,this.mode="popup"):(this.$trigger=document.querySelector(t),this.triggerSelector?(this.$openTrigger=document.querySelector(this.triggerSelector),this.mode="popup"):"INPUT"===this.$trigger.tagName?this.mode="popup":this.mode="inline");const s=new Date,i={mode:"auto",theme:"dark",startWeekFromMonday:!0,selectType:"single",monthsNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShortNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekDaysNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],selectDate:t=>console.log(t),onOpen:()=>{},onClose:()=>{},onViewChange:()=>{},onHoverDate:()=>{},disabledDates:[],closeOnSelect:!0,enableTime:!1,use12Hour:!1,timeStep:1,footerButtons:[],hapticFeedback:!0,...e};"default"===i.theme&&(i.theme="dark");const a=i.locale||("undefined"!=typeof navigator?navigator.language:void 0);i.dateFormat=i.dateFormat||function(t){const e=t||("undefined"!=typeof navigator&&navigator.language?navigator.language:"en-US");try{return new Intl.DateTimeFormat(e,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(2023,5,15)).map(t=>"year"===t.type?"YYYY":"month"===t.type?"MM":"day"===t.type?"DD":t.value).join("")}catch{return"MM/DD/YYYY"}}(a);const n={startDate:o(void 0!==e.startDate?e.startDate:s,i.dateFormat),minDate:o(void 0!==e.minDate?e.minDate:new Date(s.getFullYear()-100,s.getMonth(),1),i.dateFormat),maxDate:o(void 0!==e.maxDate?e.maxDate:new Date(s.getFullYear()+100,s.getMonth()+1,0),i.dateFormat)};this.options={...i,...n},this.options.minDate>this.options.maxDate&&console.error("Date Error: maxDate is less than minDate!"),this.options.startDate=this.#G(this.options.startDate,this.options.minDate,this.options.maxDate),this.#j=this.#Q(this.options.disabledDates),this.#tt(this.options.startDate)&&(this.options.startDate=new Date(this.options.minDate)),this.#ht(),g.#V.add(this)}#dt(){for(const t of g.#V)t!==this&&"popup"===t.mode&&t.close()}#ht(){"object"==typeof this.options&&null!==this.options?(this.$container=document.createElement("div"),this.$container.className=`RollDate__container RollDate__calendar__type--days RollDate__theme_${this.options.theme}`,this.#Z(this.$trigger),this.#Z(this.$startInput),this.#Z(this.$endInput),"popup"===this.mode?(document.body.appendChild(this.$container),this.$container.style.display="none"):"DIV"===this.$trigger.nodeName||"SPAN"===this.$trigger.nodeName||"SECTION"===this.$trigger.nodeName?this.$trigger.append(this.$container):document.body.append(this.$container),this.options.enableTime&&this.$container.classList.add("RollDate__has-time"),(this.options.footerButtons?.length||this.options.enableTime)&&this.$container.classList.add("RollDate__has-footer"),this.render=new c({container:this.$container,trigger:this.$trigger,startWeekFromMonday:this.options.startWeekFromMonday,monthsNames:this.options.monthsNames,monthsShortNames:this.options.monthsShortNames,weekDays:this.options.weekDaysNames,enableTime:this.options.enableTime,footerButtons:this.options.footerButtons}),this.dom={$year:this.$container.querySelector(".RollDate__header__year"),$month:this.$container.querySelector(".RollDate__header__month"),$years_block:this.$container.querySelector(".RollDate__calendar__years"),$months_block:this.$container.querySelector(".RollDate__calendar__months"),$days_block:this.$container.querySelector(".RollDate__calendar__days"),$body:this.$container.querySelector(".RollDate__calendar__body"),$type_switcher:this.$container.querySelector(".RollDate__calendar__switcher"),$page_switcher:this.$container.querySelectorAll(".RollDate__calendar__button"),$footer_buttons:this.$container.querySelector(".RollDate__footer__buttons"),$time:this.$container.querySelector(".RollDate__time")},this.#ot(),this.options.enableTime&&this.dom.$time&&this.#lt(),this.virtualizer=new m(this),this.#ct(),this.observe=new h(this.$container),this.data=new d({startDate:this.options.startDate,minDate:this.options.minDate,maxDate:this.options.maxDate,startWeekFromMonday:this.options.startWeekFromMonday,isDateDisabled:t=>this.#tt(t)}),this.#ut(this.#q)):console.error("RollDate: options is not an object!")}#mt(){if("popup"!==this.mode)return;if(window.innerWidth<=380)return this.$container.style.position="fixed",this.$container.style.left="8px",this.$container.style.right="8px",this.$container.style.top="auto",this.$container.style.bottom="8px",this.$container.style.width="auto",this.$container.style.maxHeight="min(80vh, 560px)",void(this.$container.style.zIndex="10000");const t=(this.$endInput?this.$startInput:(this.$openTrigger,this.$trigger)).getBoundingClientRect(),e=window.innerHeight-t.bottom;this.$container.style.top=e<300?t.top+window.scrollY-this.$container.offsetHeight+"px":`${t.bottom+window.scrollY}px`,this.$container.style.left=`${t.left+window.scrollX}px`,this.$container.style.right="auto",this.$container.style.bottom="auto",this.$container.style.width="",this.$container.style.maxHeight="",this.$container.style.position="absolute",this.$container.style.zIndex="10000"}#ut(){if(this.#pt(),this.scroll.blocked=!1,this.observe.un(this.period),this.#_t(this.period),"day"===this.period){const t=this.data.getDates();this.dom.$days_block.innerHTML=this.render.dates(t,this.#B,this.options.selectType)}else{const t=this.data.getMonthsOrYears(this.period);this.dom[`$${this.period}s_block`].innerHTML=this.render[`${this.period}s`](t)}const t={day:`.RollDate__calendar__day[data-year="${this.data.current_year}"][data-month="${this.data.current_month}"]`,month:`.RollDate__calendar__month[data-year="${this.data.current_year}"][data-month="0"]`,year:`.RollDate__calendar__year[data-decade="${this.data.current_decade}"][data-year="${this.data.current_year}"]`};let e=this.$container.querySelector(t[this.period]);if(!e){const t={day:`.RollDate__calendar__day[data-year="${this.data.current_year}"]`,month:`.RollDate__calendar__month[data-year="${this.data.current_year}"]`,year:`.RollDate__calendar__year[data-decade="${this.data.current_decade}"]`};e=this.$container.querySelector(t[this.period])}e&&setTimeout(()=>{const t=this.dom.$body.querySelector(".RollDate__calendar__scrollblock"),s=this.dom.$body.clientHeight,i=t.clientHeight;if(i<=s)return this.scroll.setBaseOffset(s-i),void(this.scroll.offset=0);this.scroll.setBaseOffset(0);const a=t.getBoundingClientRect(),n=-(e.getBoundingClientRect().top-a.top),o=this.scroll.minScroll;this.scroll.offset=Math.max(n,o)},0),this.observe.on(this.period,t=>{JSON.parse(t.dataset.bind).every(e=>Number(t.dataset[e])===this.data[`current_${e}`])&&t.classList.add(`RollDate__calendar__${this.period}--active`)})}#pt(){"year"!==this.period?(this.dom.$year.innerText=this.data.current_year,this.dom.$month.innerText=this.options.monthsNames[this.data.current_month]):this.dom.$year.innerText=Number(this.data.current_decade)+"-"+(Number(this.data.current_decade)+9);this.$container.querySelectorAll(`.RollDate__calendar__${this.period}`).forEach(t=>{for(const e of JSON.parse(t.dataset.bind)){JSON.parse(t.dataset.bind).every(e=>Number(t.dataset[e])===this.data[`current_${e}`])?t.classList.add(`RollDate__calendar__${this.period}--active`):t.classList.remove(`RollDate__calendar__${this.period}--active`)}})}#ct(){if("popup"===this.mode){const t=[];this.triggerSelector?(this.$openTrigger=document.querySelector(this.triggerSelector),t.push(this.$openTrigger)):this.$endInput?t.push(this.$startInput,this.$endInput):t.push(this.$trigger),this.#U=t.filter(Boolean),this.#U.forEach(t=>{t.addEventListener("click",t=>{t.stopPropagation(),this.open()}),"INPUT"===t.tagName&&t.addEventListener("focus",()=>this.open())}),this.#J=t=>{this.$container.contains(t.target)||this.#U.some(e=>e.contains(t.target))||this.close()},document.addEventListener("click",this.#J);(this.$endInput?[this.$startInput,this.$endInput]:[this.$trigger]).forEach(t=>{"INPUT"===t?.tagName&&t.addEventListener("input",t=>{this.#Dt(t.target.value)})})}this.scroll=new u(this.dom.$body,{dominant:()=>{const t=this.observe.dominant();if(t)for(const s of Object.keys(t))if(this.data[`current_${s}`]!==t[s]){(t.hasOwnProperty("year")||t.hasOwnProperty("month"))&&(this.data.current_year=t.year,this.data.current_month=t.month,this.data.current_decade=e(t.year)),t.hasOwnProperty("decade")&&(this.data.current_decade=t.decade),a(!1!==this.options.hapticFeedback),this.#pt();break}},updatePeriod:t=>this.virtualizer.update(t)}),this.dom.$type_switcher.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.#gt(++this.#q)}),this.dom.$body.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation();const s=t.target.closest("[data-click]"),i=t.target.closest("[data-day]");if(s){if(s.classList.contains("RollDate__calendar__month--disabled")||s.classList.contains("RollDate__calendar__year--disabled"))return;this.data.current_month=Number(s.dataset.month),this.data.current_year=Number(s.dataset.year),this.data.current_decade=e(this.data.current_year);const t=s.dataset.click;this.#gt(this.#W.indexOf(t))}if(i){if(i.classList.contains("RollDate__calendar__day--disabled"))return;const t=this.#at(new Date(Number(i.dataset.year),Number(i.dataset.month),Number(i.dataset.day)));if("single"===this.options.selectType&&(this.$container.querySelectorAll("[data-day]").forEach(t=>{t.classList.remove("RollDate__calendar__day--selected")}),i.classList.add("RollDate__calendar__day--selected"),this.#B=[t],this.options.selectDate(t),this.#it(),"popup"===this.mode&&this.options.closeOnSelect&&this.close()),"range"===this.options.selectType){const e=2===this.#B.length&&t.getTime()>=this.#B[0].getTime()&&t.getTime()<=this.#B[1].getTime();if(2!==this.#B.length||e||this.#yt(),0===this.#B.length)this.#B=[t],i.classList.add("RollDate__calendar__day--range-first");else{const e=this.#B[0];t.getTime()>e.getTime()?(this.#B=[e,t],this.$container.querySelectorAll("[data-day]").forEach(s=>{const i=new Date(Number(s.dataset.year),Number(s.dataset.month),Number(s.dataset.day)).getTime();i===e.getTime()?s.classList.add("RollDate__calendar__day--range-first"):i===t.getTime()?s.classList.add("RollDate__calendar__day--range-last"):i>e.getTime()&&i<t.getTime()&&s.classList.add("RollDate__calendar__day--range-selected")})):t.getTime()<e.getTime()&&(this.#B=[t],i.classList.add("RollDate__calendar__day--range-first"),this.$container.querySelector('.RollDate__calendar__day--range-first:not([data-day="'+t.getDate()+'"])')?.classList.remove("RollDate__calendar__day--range-first"))}this.options.selectDate([...this.#B]),this.#it(),"popup"===this.mode&&2===this.#B.length&&this.options.closeOnSelect&&this.close()}if("multi"===this.options.selectType){this.#B.some(e=>e.getTime()===t.getTime())?(this.#B=this.#B.filter(e=>e.getTime()!==t.getTime()),i.classList.remove("RollDate__calendar__day--selected")):(this.#B.push(t),i.classList.add("RollDate__calendar__day--selected")),this.options.selectDate(this.#B),this.#it(),"popup"===this.mode&&this.options.closeOnSelect&&this.close()}}this.scroll.resetMinScroll()}),this.dom.$body.addEventListener("mousemove",t=>{const e=t.target.closest("[data-day]");if(!e)return;if(e.classList.contains("RollDate__calendar__day--disabled"))return;const s=new Date(Number(e.dataset.year),Number(e.dataset.month),Number(e.dataset.day));this.options.onHoverDate(s,{period:this.period,selectedDates:[...this.#B]})}),this.dom.$body.addEventListener("mouseleave",()=>{this.options.onHoverDate(null,{period:this.period,selectedDates:[...this.#B]})}),this.dom.$page_switcher.forEach(t=>{t.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation();const s=t.currentTarget?.dataset?.direction;if("prev"!==s&&"next"!==s)return;const i="prev"===s?-1:1,n=this.options.minDate.getFullYear(),o=this.options.maxDate.getFullYear();if("day"===this.period){const t=new Date(this.data.current_year,this.data.current_month,1),s=new Date(this.data.current_year,this.data.current_month+i,1),a=new Date(this.options.minDate.getFullYear(),this.options.minDate.getMonth(),1),n=new Date(this.options.maxDate.getFullYear(),this.options.maxDate.getMonth(),1);if(s<a||s>n)return;if(s.getTime()===t.getTime())return;this.data.current_year=s.getFullYear(),this.data.current_month=s.getMonth(),this.data.current_decade=e(this.data.current_year)}else if("month"===this.period){const t=this.data.current_year+i;if(t<n||t>o)return;this.data.current_year=t,this.data.current_decade=e(t)}else if("year"===this.period){const t=e(this.data.current_year)+10*i,s=e(n),a=e(o);if(t<s||t>a)return;this.data.current_year=t,this.data.current_decade=t}a(!1!==this.options.hapticFeedback),this.#ut(this.#q)})})}#gt(t){const e=this.period;if(t>2)t=this.period=2;else{this.scroll.resetMinScroll(),this.period=t,this.#ut(this.period);for(const t of this.#W)this.$container.classList.remove("RollDate__calendar__type--"+t+"s");this.$container.classList.add("RollDate__calendar__type--"+this.#W[t]+"s"),this.options.onViewChange({from:e,to:this.period,current:{year:this.data.current_year,month:this.data.current_month,decade:this.data.current_decade}})}}#_t(t){2!==t&&(this.dom.$years_block.innerHTML=""),1!==t&&(this.dom.$months_block.innerHTML=""),0!==t&&(this.dom.$days_block.innerHTML="")}#ft(){requestAnimationFrame(()=>{this.scroll.checkMinScroll();const t=this.options.startDate,e=this.$container.querySelector(`[data-year="${t.getFullYear()}"][data-month="${t.getMonth()}"]`);if(e){const t=this.dom.$body.querySelector(".RollDate__calendar__scrollblock").getBoundingClientRect(),s=-(e.getBoundingClientRect().top-t.top);this.scroll.offset=s}})}get period(){return this.#W[this.#q]}set period(t){this.#q=t}get selectedDates(){return this.#B}setDisabledDates(t=[]){this.options.disabledDates=Array.isArray(t)?t:[],this.#j=this.#Q(this.options.disabledDates),this.#st(),this.#ut(this.#q)}disableDate(t){const e=this.#K(t);e&&(this.#j.add(this.#X(e)),this.options.disabledDates=[...this.#j].map(t=>new Date(t)),this.#st(),this.#ut(this.#q))}enableDate(t){const e=this.#K(t);e&&(this.#j.delete(this.#X(e)),this.options.disabledDates=[...this.#j].map(t=>new Date(t)),this.#ut(this.#q))}isDateDisabled(t){const e=this.#K(t);return!!e&&this.#tt(e)}#yt(){this.#B=[],this.$container.querySelectorAll("[data-day]").forEach(t=>{t.classList.remove("RollDate__calendar__day--range-first","RollDate__calendar__day--range-last","RollDate__calendar__day--range-selected")})}#bt(){this.#B=[],this.$container.querySelectorAll("[data-day].RollDate__calendar__day--selected").forEach(t=>t.classList.remove("RollDate__calendar__day--selected"))}#it(){if("popup"!==this.mode)return;const t=t=>this.#nt(t);if(this.$endInput)this.#B.length>=1?this.$startInput.value=t(this.#B[0]):this.$startInput.value="",2===this.#B.length?this.$endInput.value=t(this.#B[1]):this.$endInput.value="";else{const e=this.$trigger;"INPUT"===e.tagName&&("single"===this.options.selectType&&this.#B.length>0?e.value=t(this.#B[0]):"range"===this.options.selectType?1===this.#B.length?e.value=`${t(this.#B[0])} - `:2===this.#B.length?e.value=`${t(this.#B[0])} - ${t(this.#B[1])}`:e.value="":"multi"===this.options.selectType&&this.#B.length>0?e.value=this.#B.map(t).join(", "):e.value="")}}#Dt(t){if(!t)return this.#B=[],void this.#ut(this.#q);try{if("single"===this.options.selectType){const e=n(t,this.options.dateFormat);e&&!this.#tt(e)&&(this.#B=[e],this.data.current_year=e.getFullYear(),this.data.current_month=e.getMonth(),this.#ut(this.#q))}else if("range"===this.options.selectType){const e=t.split(/\s+-\s+/).map(t=>t.trim()).filter(t=>t).map(t=>n(t,this.options.dateFormat)).filter(t=>!this.#tt(t)).filter(t=>t);e.length>0&&(this.#B=e,e.length>=1&&(this.data.current_year=e[0].getFullYear(),this.data.current_month=e[0].getMonth()),this.#ut(this.#q))}else if("multi"===this.options.selectType){const e=t.split(",").map(t=>t.trim()).filter(t=>t).map(t=>n(t,this.options.dateFormat)).filter(t=>!this.#tt(t)).filter(t=>t);e.length>0&&(this.#B=e,this.data.current_year=e[0].getFullYear(),this.data.current_month=e[0].getMonth(),this.#ut(this.#q))}}catch(e){console.warn("Invalid date format:",t)}}open(){"popup"===this.mode&&this.#dt();const t="none"!==this.$container.style.display;this.$container.style.display="block","popup"===this.mode?(this.#mt(),this.#z?(this.#ft(),this.#z=!1):this.#ut(this.#q)):this.dom?.$body||this.#ut(this.#q),t||this.options.onOpen({period:this.period,selectedDates:[...this.#B]})}close(){const t="none"!==this.$container.style.display;if(this.$container.style.display="none","popup"===this.mode){(this.$endInput?[this.$startInput,this.$endInput]:this.$openTrigger?[this.$openTrigger]:[this.$trigger]).forEach(t=>{t&&"function"==typeof t.blur&&t.blur()})}t&&this.options.onClose({period:this.period,selectedDates:[...this.#B]})}selectToday(){const t=new Date,s=new Date(t.getFullYear(),t.getMonth(),t.getDate());if(this.#tt(s))return;this.data.current_year=t.getFullYear(),this.data.current_month=t.getMonth(),this.data.current_decade=e(t.getFullYear());const i=this.#at(t);if("single"===this.options.selectType)this.#B=[i];else if("range"===this.options.selectType)this.#B=[i];else if("multi"===this.options.selectType){this.#B.some(t=>t.getTime()===i.getTime())||this.#B.push(i)}this.#ut(this.#q),this.#et(),this.#it(),"popup"===this.mode&&this.options.closeOnSelect&&"single"===this.options.selectType&&this.close()}clearSelection(){"range"===this.options.selectType?this.#yt():"multi"===this.options.selectType?this.#bt():this.#B=[],this.#ut(this.#q),this.#et(),this.#it()}destroy(){this.#J&&(document.removeEventListener("click",this.#J),this.#J=null),g.#V.delete(this),this.observe.disconnect(),this.scroll?.destroy(),this.timePicker?.destroy(),this.$container.parentNode&&this.$container.parentNode.removeChild(this.$container)}}return"undefined"!=typeof window&&(window.RollDate=g),g}();
|
|
1
|
+
var RollDate=function(){"use strict";function t(t){return 10*Math.floor(t/10)}let e=0,s=null;function i(t=!0){if(!t||"undefined"==typeof window)return;const i="undefined"!=typeof performance?performance.now():Date.now();if(!(i-e<28)){e=i;try{if("undefined"!=typeof navigator&&"function"==typeof navigator.vibrate)return void navigator.vibrate(10)}catch{}!function(){try{const t=window.AudioContext||window.webkitAudioContext;if(!t)return;s||(s=new t),"suspended"===s.state&&s.resume().catch(()=>{});const e=s.currentTime,i=s.createOscillator(),a=s.createGain();i.type="triangle",i.frequency.value=180,a.gain.setValueAtTime(1e-4,e),a.gain.exponentialRampToValueAtTime(.045,e+.008),a.gain.exponentialRampToValueAtTime(1e-4,e+.04),i.connect(a),a.connect(s.destination),i.start(e),i.stop(e+.045)}catch{}}()}}function a(t,e="auto"){if(!t)return null;const s=t.trim();if(!s)return null;if(t instanceof Date)return t;if(/^\d{4}-\d{2}-\d{2}$/.test(s))return new Date(s);if("auto"===e){const t=s.match(/[-/.]/)?.[0]||".",e=s.split(t).map(Number);if(3!==e.length)return null;const[i,a,n]=e;let o,r,l;return i>=1e3?[o,r,l]=[i,a,n]:[l,r,o]=[i,a,n],new Date(o,r-1,l)}const i={"YYYY-MM-DD":/^(\d{4})[-/\.](\d{1,2})[-/\.](\d{1,2})$/,"DD/MM/YYYY":/^(\d{1,2})[-/\.](\d{1,2})[-/\.](\d{4})$/,"MM/DD/YYYY":/^(\d{1,2})[-/\.](\d{1,2})[-/\.](\d{4})$/,"DD.MM.YYYY":/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/,"MM.DD.YYYY":/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/}[e];if(!i)return console.warn(`RollDate: unknown format "${e}". Using auto-detect.`),a(t,"auto");const n=s.match(i);if(!n)return null;let o,r,l;switch(e){case"YYYY-MM-DD":[,o,r,l]=n;break;case"DD/MM/YYYY":case"DD.MM.YYYY":[,l,r,o]=n;break;case"MM/DD/YYYY":case"MM.DD.YYYY":[,r,l,o]=n}return new Date(Number(o),Number(r)-1,Number(l))}function n(t,e){return"string"==typeof t?a(t,e):t}function o(t,e){const s=(t.getDay()-Number(e)+7)%7;return new Date(t.getFullYear(),t.getMonth(),t.getDate()-s)}function r(t,e){const s=(6-t.getDay()+Number(e)+7)%7;return new Date(t.getFullYear(),t.getMonth(),t.getDate()+s)}class l{constructor(t){this.$container=t,this.intersecting=new Map,this.init()}init(){return this.observe=new IntersectionObserver(t=>{t.forEach(t=>{const e=`${t.target.dataset.year}${t.target.dataset?.month?"_"+t.target.dataset.month:""}${t.target.dataset?.day?"_"+t.target.dataset.day:""}`;t.isIntersecting?this.intersecting.set(e,t):this.intersecting.delete(e)})},{threshold:.5})}on(t,e){this.$container.querySelectorAll(`.RollDate__calendar__${t}`).forEach(t=>{e&&e(t),this.observe.observe(t)})}un(){this.intersecting.clear(),this.$container.querySelectorAll(".RollDate__calendar__day, .RollDate__calendar__month, .RollDate__calendar__year").forEach(t=>{this.observe.unobserve(t)})}dominant(){if(0===this.intersecting.size)return null;const t={};let e=[];this.intersecting.forEach(s=>{const i={};e=JSON.parse(s.target.dataset.bind);for(const t of e)i[t]=s.target.dataset[t];const a=Object.values(i).join("-");t[a]=(t[a]||0)+1});const s=Object.keys(t).reduce((e,s)=>t[e]>t[s]?e:s).split("-").map(Number);return Object.fromEntries(e.map((t,e)=>[t,s[e]]))}disconnect(){this.observe?.disconnect()}}class h{up_date=null;down_date=null;current_year;current_month;current_decade;constructor(e){this.options=e,this.current_year=this.options.startDate.getFullYear(),this.current_month=this.options.startDate.getMonth(),this.current_decade=t(this.current_year)}get currentPeriod(){return{year:this.current_year,month:this.current_month,decade:this.current_decade}}setPeriod(t){"year"in t&&(this.current_year=t.year),"month"in t&&(this.current_month=t.month),"decade"in t&&(this.current_decade=t.decade)}getDates(){let t=new Date(this.current_year,this.current_month-3,1),e=new Date(this.current_year,this.current_month+3,0);if(this.options.minDate&&this.options.minDate>t&&(t=new Date(this.options.minDate.getFullYear(),this.options.minDate.getMonth(),1)),this.options.maxDate&&this.options.maxDate<e&&(e=new Date(this.options.maxDate.getFullYear(),this.options.maxDate.getMonth()+1,0)),this.options.minDate&&this.options.maxDate&&this.options.minDate.getFullYear()===this.options.maxDate.getFullYear()&&this.options.minDate.getMonth()===this.options.maxDate.getMonth()){const s=this.options.minDate.getFullYear(),i=this.options.minDate.getMonth();t=new Date(s,i,1),e=new Date(s,i+1,1)}t=o(t,this.options.startWeekFromMonday),e=r(e,this.options.startWeekFromMonday);const s=Math.floor((e-t)/864e5)+1;if(s<42){const i=42-s,a=Math.ceil(i/2),n=Math.floor(i/2);t.setDate(t.getDate()-a),e.setDate(e.getDate()+n),t=o(t,this.options.startWeekFromMonday),e=r(e,this.options.startWeekFromMonday)}this.up_date=new Date(t),this.down_date=new Date(e);const i=[];for(let s=new Date(t);s<=e;s.setDate(s.getDate()+1)){const t=!!this.options.isDateDisabled&&this.options.isDateDisabled(s),e=this.options.minDate&&s<this.options.minDate||this.options.maxDate&&s>this.options.maxDate||t;i.push({date:new Date(s),disabled:e})}return i}getMonthsOrYears(t){let e=this.current_year-("month"===t?5:18),s=this.current_year+("month"===t?5:18);if(this.options.minDate){const t=this.options.minDate.getFullYear();t>e&&(e=t)}if(this.options.maxDate){const t=this.options.maxDate.getFullYear();t<s&&(s=t)}if("month"===t&&this.options.minDate&&this.options.maxDate&&this.options.minDate.getFullYear()===this.options.maxDate.getFullYear()){const t=this.options.minDate.getFullYear();e=t-2,s=t+2}this.up_date=new Date(e,0,1),this.down_date=new Date(s+1,0,0);const i=[];for(let a=e;a<=s;a++)if("month"===t)for(let t=0;t<12;t++){const e=new Date(a,t,1),s=new Date(a,t+1,0);let n=!1;(this.options.minDate&&s<this.options.minDate||this.options.maxDate&&e>this.options.maxDate)&&(n=!0),i.push({date:e,disabled:n})}else{const t=new Date(a,0,1);let e=!1;(this.options.minDate&&a<this.options.minDate.getFullYear()||this.options.maxDate&&a>this.options.maxDate.getFullYear())&&(e=!0),i.push({date:t,disabled:e})}if(i.length<16){let e=s+1;for(;i.length<16;){if("month"===t)for(let t=0;t<12&&i.length<16;t++)i.push({date:new Date(e,t,1),disabled:!0});else i.push({date:new Date(e,0,1),disabled:!0});e++}}return i}}class d{constructor(t){this.$container=t.container,this.$trigger=t.trigger,this.startWeekFromMonday=t.startWeekFromMonday,this.monthsNames=t.monthsNames,this.monthsShortNames=t.monthsShortNames,this.weekDays=Array.isArray(t.weekDays)&&7===t.weekDays.length?t.weekDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],this.enableTime=Boolean(t.enableTime),this.hasFooter=Boolean(t.footerButtons&&t.footerButtons.length),this.init()}init(){const t=this.enableTime?'<div class="RollDate__time-separator" aria-hidden="true"></div><div class="RollDate__time-panel"><div class="RollDate__time"></div></div>':"",e=this.hasFooter?'\n <div class="RollDate__footer">\n <div class="RollDate__footer__buttons"></div>\n </div>\n ':"";this.$container.innerHTML=`\n <div class="RollDate__content">\n <div class="RollDate__calendar">\n <div class="RollDate__header">\n <div class="RollDate__calendar__switcher">\n <div class="RollDate__header__year"></div>\n <div class="RollDate__header__month"></div>\n </div>\n <div class="RollDate__calendar__buttons">\n <button class="RollDate__calendar__button" data-direction="prev">\n <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 61 55" width="55" height="50">\n <path id="Форма 2" fill-rule="evenodd" class="s0" d="m52.76 54.67l-44.73 0.12c-6.16 0.02-10.02-6.64-6.96-11.98l22.26-38.79c3.07-5.35 10.76-5.37 13.86-0.04l22.47 38.67c3.09 5.33-0.74 12.01-6.9 12.02z"/>\n </svg>\n </button>\n <button class="RollDate__calendar__button" data-direction="next">\n <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 61 55" width="55" height="50">\n <path id="Форма 2" fill-rule="evenodd" class="s0" d="m52.76 54.67l-44.73 0.12c-6.16 0.02-10.02-6.64-6.96-11.98l22.26-38.79c3.07-5.35 10.76-5.37 13.86-0.04l22.47 38.67c3.09 5.33-0.74 12.01-6.9 12.02z" />\n </svg>\n </button>\n </div>\n </div>\n <div class="RollDate__calendar__header">\n ${this.#t()}\n </div>\n <div class="RollDate__calendar__body">\n <div class="RollDate__calendar__scrollblock">\n <div class="RollDate__calendar__days"></div>\n <div class="RollDate__calendar__months"></div>\n <div class="RollDate__calendar__years"></div>\n </div>\n </div>\n </div>\n ${t}\n </div>\n ${e}\n `,"DIV"===this.$trigger.nodeName||"SPAN"===this.$trigger.nodeName||"SECTION"===this.$trigger.nodeName?this.$trigger.append(this.$container):document.body.append(this.$container)}#t(){const t=this.weekDays;let e="";const s=Number(this.startWeekFromMonday);for(let i=s;i<7+s;i++)e+=`<div class="RollDate__calendar__header__weekday">${t[i%7]}</div>`;return e}#e(t=[],e=5){if(!t.length)return"";const s=t.slice(0,e),i=t.length-e,a=s.length>3?"RollDate__calendar__day-dot RollDate__calendar__day-dot--compact":"RollDate__calendar__day-dot";return`<span class="RollDate__calendar__day-dots" aria-hidden="true">${s.map(t=>t?`<span class="${a} RollDate__calendar__day-dot--custom" style="--rd-highlight-dot:${t}"></span>`:`<span class="${a}"></span>`).join("")}${i>0?`<span class="RollDate__calendar__day-dot RollDate__calendar__day-dot--more">+${i}</span>`:""}</span>`}dates(t,e=[],s="single",i=()=>null){let a="";const n=new Date;for(let o=0;o<t.length;o++){const r=t[o].date,l=t[o].disabled?"RollDate__calendar__day--disabled":"",h=i(r),d=h?this.#e(h.colors):"",c=r.toDateString()===n.toDateString();let u="";if("single"===s||"multi"===s){const t=r.getTime();e.some(e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()===t)&&(u="RollDate__calendar__day--selected")}else if("range"===s&&2===e.length){const[t,s]=e,i=r.getTime(),a=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),n=new Date(s.getFullYear(),s.getMonth(),s.getDate()).getTime();i===a?u="RollDate__calendar__day--range-first":i===n?u="RollDate__calendar__day--range-last":i>a&&i<n&&(u="RollDate__calendar__day--range-selected")}a+=`<div class="RollDate__calendar__day ${l} ${c?"RollDate__calendar__day--today":""} ${u}"\n data-bind='["year", "month"]'\n data-year="${r.getFullYear()}"\n data-month="${r.getMonth()}" \n data-day="${r.getDate()}">${r.getDate()}${d}</div>`}return a}months(t){let e="";for(let s=0;s<t.length;s++){const i=new Date(t[s].date),a=t[s].disabled,n=i.getMonth();let o="";i.getFullYear()===(new Date).getFullYear()&&n===(new Date).getMonth()&&(o="RollDate__calendar__month--current"),e+=`<div class="RollDate__calendar__month${a?" RollDate__calendar__month--disabled":""} ${o}" \n data-bind='["year"]'\n data-month="${n}" \n data-year="${i.getFullYear()}"\n data-click="day">\n ${this.monthsShortNames[n]} \n </div>`}return e}years(t){let e="";for(let s=0;s<t.length;s++){const i=new Date(t[s].date),a=t[s].disabled,n=i.getFullYear();let o="";n===(new Date).getFullYear()&&(o="RollDate__calendar__year--current"),e+=`<div class="RollDate__calendar__year${a?" RollDate__calendar__year--disabled":""} ${o}" \n data-bind='["decade"]'\n data-decade="${10*Math.floor(n/10)}"\n data-month="0" \n data-year="${n}"\n data-click="month">\n ${n} \n </div>`}return e}clear(t){t.innerHTML=""}}class c{#s=null;#i=25;#a=75;#n;#o=0;#r;#l;#h;#d;#c;#u=!1;#m=!1;#p=0;#g=!1;#D=0;#_=0;#f=0;#y=0;#b=0;constructor(t,e={dominant:()=>console.error('Function "dominant" is not found'),updatePeriod:()=>console.error('Function "updatePeriod" is not found')}){this.$body=t,this.$scroll_block=this.$body.querySelector(".RollDate__calendar__scrollblock"),this.dominant=e.dominant,this.updatePeriod=e.updatePeriod,this.offset=0,this.init()}init(){this.#l=this.wheelHandler.bind(this),this.$body.addEventListener("wheel",this.#l,{passive:!1}),this.#h=this.touchStartHandler.bind(this),this.#d=this.touchMoveHandler.bind(this),this.#c=this.touchEndHandler.bind(this),this.$body.addEventListener("touchstart",this.#h,{passive:!0}),this.$body.addEventListener("touchmove",this.#d,{passive:!1}),this.$body.addEventListener("touchend",this.#c,{passive:!0}),this.$body.addEventListener("touchcancel",this.#c,{passive:!0})}wheelHandler(t){t.preventDefault(),t.stopPropagation(),this.#v();const e=.85*t.deltaY,s=Math.abs(e)>50?20:1,i=e/s,a=e>0?"down":"up";this.#u=!0,this.#m=!1;let n=0;const o=()=>{if(n>=s)return this.#u=!1,void(this.#m=!1);this.offset-=i,requestAnimationFrame(()=>{this.dominant(),this.checkEdge(a),n++,o()})};o()}touchStartHandler(t){t.touches&&1===t.touches.length&&(this.#v(),this.#g=!0,this.#D=t.touches[0].clientY,this.#_=performance.now(),this.#f=0,this.#m=!1)}touchMoveHandler(t){if(!this.#g||!t.touches||1!==t.touches.length)return;t.preventDefault();const e=t.touches[0].clientY,s=e-this.#D,i=performance.now(),a=i-this.#_;if(a>0&&a<120&&(this.#f=.65*this.#f+s/a*.35),this.#D=e,this.#_=i,Math.abs(s)<1)return;this.offset+=s,this.dominant();const n=s<0?"down":"up";this.checkEdge(n)}touchEndHandler(){this.#g=!1,this.#m=!1;const t=16*this.#f;if(Math.abs(t)<.4)return;let e=t;const s=()=>{if(Math.abs(e)<.35)return void(this.#y=0);const t=this.#n;if(this.offset+=e,this.#n===t)return void(this.#y=0);this.dominant();const i=e<0?"down":"up";this.checkEdge(i),e*=.92,this.#y=requestAnimationFrame(s)};this.#y=requestAnimationFrame(s)}#v(){this.#y&&(cancelAnimationFrame(this.#y),this.#y=0)}#$(){this.#b&&(cancelAnimationFrame(this.#b),this.#b=0,this.blocked=!1)}animateTo(t,e={}){this.#v(),this.#$();const s=e.duration??220,i=this.#n,a=this.minScroll,n=Math.max(Math.min(t,0),a);if(Math.abs(n-i)<1)return this.offset=n,this.dominant(),e.onComplete?.(),Promise.resolve();this.blocked=!0;const o=performance.now();return new Promise(t=>{const a=r=>{const l=Math.min(1,(r-o)/s),h=1-Math.pow(1-l,3);this.offset=i+(n-i)*h,l<1?this.#b=requestAnimationFrame(a):(this.offset=n,this.blocked=!1,this.dominant(),this.#b=0,e.onComplete?.(),t())};this.#b=requestAnimationFrame(a)})}apply(){this.$scroll_block.style.transform=`translateY(${this.offset+this.#o}px)`}get offset(){return this.#n}set offset(t){this.#n=t,null!==this.#s&&(t>=0?this.#n=0:t<=this.#s&&(this.#n=this.#s)),this.apply()}get blocked(){return this.#r}set blocked(t){this.#r=t}get minScroll(){return null===this.#s&&this.checkMinScroll(),this.#s??0}checkEdge(t){if(null===this.#s&&this.checkMinScroll(),0===this.#s||this.blocked)return;if(this.#u&&this.#m)return;const e=100*Math.abs(this.offset/this.#s),s=Date.now();if(!(s-this.#p<60))if(e<this.#i){if("up"!==t)return;this.#p=s,this.#m=!0,this.blocked=!0,this.updatePeriod("up")}else if(e>this.#a){if("down"!==t)return;this.#p=s,this.#m=!0,this.blocked=!0,this.updatePeriod("down")}}checkMinScroll(){const t=this.$scroll_block.clientHeight,e=this.$body.clientHeight;this.#s=t>e?-(t-e):0}setBaseOffset(t=0){this.#o=t,this.apply()}resetMinScroll(){this.#s=null}destroy(){this.#v(),this.#$(),this.#l&&this.$body.removeEventListener("wheel",this.#l),this.#h&&this.$body.removeEventListener("touchstart",this.#h),this.#d&&this.$body.removeEventListener("touchmove",this.#d),this.#c&&(this.$body.removeEventListener("touchend",this.#c),this.$body.removeEventListener("touchcancel",this.#c))}}class u{constructor(t){this.ctx=t}update(t){const e=this.ctx.period,s="up"===t;if(s){if("year"===e){if(this.ctx.data.up_date.getFullYear()<=this.ctx.options.minDate.getFullYear())return void(this.ctx.scroll.blocked=!1)}else if(this.ctx.data.up_date<=this.ctx.options.minDate)return void(this.ctx.scroll.blocked=!1)}else if("year"===e){if(this.ctx.data.down_date.getFullYear()>=this.ctx.options.maxDate.getFullYear())return void(this.ctx.scroll.blocked=!1)}else if(this.ctx.data.down_date>=this.ctx.options.maxDate)return void(this.ctx.scroll.blocked=!1);const i={day:{count:35,getNewItems:(t,e)=>{const i=[];if(s){let e=new Date(t);if(e.setDate(t.getDate()-35),e<this.ctx.options.minDate){const t=this.ctx.options.minDate;e=o(new Date(t.getFullYear(),t.getMonth(),1),this.ctx.options.startWeekFromMonday)}for(let s=new Date(e);s<t;s.setDate(s.getDate()+1))i.push({date:new Date(s),disabled:this.ctx?.options?.minDate>new Date(s)||!1});return{items:i,newBound:e}}{let t=new Date(e);t.setDate(e.getDate()+35);const s=new Date(e);if(s.setDate(e.getDate()+1),t>this.ctx.options.maxDate){const e=this.ctx.options.maxDate;t=r(new Date(e.getFullYear(),e.getMonth()+1,0),this.ctx.options.startWeekFromMonday)}for(let e=s;e<=t;e.setDate(e.getDate()+1))i.push({date:new Date(e),disabled:this.ctx?.options?.maxDate<new Date(e)||!1});return{items:i,newBound:t}}},render:t=>this.ctx.render.dates(t,this.ctx.selectedDates,this.ctx.options.selectType),block:this.ctx.dom.$days_block},month:{count:36,ctx:this.ctx,getNewItems:function(t,e){const i=[],a=(t,e)=>{const s=new Date(t,e,1),i=new Date(t,e+1,0);return!!(this.ctx.options.minDate&&i<this.ctx.options.minDate)||!!(this.ctx.options.maxDate&&s>this.ctx.options.maxDate)};if(s){let e=new Date(t);for(let t=0;t<this.count;t++)e.setMonth(e.getMonth()-1),i.unshift({date:new Date(e.getFullYear(),e.getMonth(),1),disabled:a(e.getFullYear(),e.getMonth())});return{items:i,newBound:i.length?i[0].date:t}}{let t=new Date(e);t.setMonth(t.getMonth()+1);for(let e=0;e<this.count;e++)i.push({date:new Date(t.getFullYear(),t.getMonth(),1),disabled:a(t.getFullYear(),t.getMonth())}),t.setMonth(t.getMonth()+1);return{items:i,newBound:i.length?i[i.length-1].date:e}}},render:t=>this.ctx.render.months(t),block:this.ctx.dom.$months_block},year:{count:16,ctx:this.ctx,getNewItems:function(t,e){const i=[];if(s){for(let e=t.getFullYear()-this.count;e<t.getFullYear();e++)e<this.ctx.options.minDate.getFullYear()||i.push({date:new Date(e,0,1),disabled:this.ctx.options.minDate.getFullYear()>e});return{items:i,newBound:i.length?i[0].date:t}}{const t=e.getFullYear()+1;for(let e=t;e<t+this.count&&!(e>this.ctx.options.maxDate.getFullYear());e++)i.push({date:new Date(e,0,1),disabled:this.ctx.options.maxDate.getFullYear()<e});return{items:i,newBound:i.length?i[i.length-1].date:e}}},render:t=>this.ctx.render.years(t),block:this.ctx.dom.$years_block}}[e];if(!i)return;const{items:a,newBound:n}=i.getNewItems(this.ctx.data.up_date,this.ctx.data.down_date);a.length&&i.block.insertAdjacentHTML(s?"afterbegin":"beforeend",i.render(a)),this.ctx.data[`${t}_date`]=n,this.ctx.observe.un();const l="year"===e?Math.min(4,a.length):a.length;this.trim(t,l),this.ctx.observe.on(e),this.ctx.scroll.blocked=!1}trim(t,e){const s=this.ctx.period,i=this.ctx.dom[`$${s}s_block`],a="up"===t,n="year"===s?28:0,o=i.scrollHeight,r=Array.from(i.querySelectorAll(`.RollDate__calendar__${s}`));if(!e||r.length<=2*e)return;if(n&&r.length-e<n)return;a?r.slice(-e).forEach(t=>t.remove()):r.slice(0,e).forEach(t=>t.remove());const l=Array.from(i.querySelectorAll(`.RollDate__calendar__${s}`)),h=l[0],d=l[l.length-1],c=t=>{if(!t)return null;const e=Number(t.dataset.year),i=Number(t.dataset.month)||0,a="day"===s?Number(t.dataset.day):1;return new Date(e,i,a)},u=c(h),m=c(d);u&&(this.ctx.data.up_date=u),m&&(this.ctx.data.down_date=m);const p=o-i.scrollHeight;this.ctx.scroll.checkMinScroll(),a?this.ctx.scroll.offset-=p:this.ctx.scroll.offset+=p}}class m{#w=0;#M=0;#S=!1;#T="AM";#R=1;#x=[];constructor(t,e={}){this.root=t,this.#S=Boolean(e.use12Hour),this.#R=Math.max(1,Number(e.minuteStep)||1),this.#w=this.#Y(e.hours??0),this.#M=this.#N(e.minutes??0),this.#S&&(this.#T=this.#w>=12?"PM":"AM"),this.onChange=e.onChange||(()=>{}),this.hapticFeedback=!1!==e.hapticFeedback,this.#F()}#Y(t){const e=Number(t);return Number.isNaN(e)?0:Math.min(23,Math.max(0,e))}#k(){if(!this.#S)return this.#w;const t=this.#w%12;return 0===t?12:t}#N(t){const e=this.#R,s=Math.round(Number(t)/e)*e;return Math.min(59,Math.max(0,Number.isNaN(s)?0:s))}#H(t){const e=t.closest(".RollDate__container"),s=e?getComputedStyle(e):getComputedStyle(t),i=parseFloat(s.getPropertyValue("--rd-time-item-h"))||28,a=parseInt(s.getPropertyValue("--rd-time-visible"),10)||3;return{itemH:i,visible:a,pad:Math.floor((a-1)/2)*i}}#F(){this.root.innerHTML='\n <div class="RollDate__time__picker"></div>\n <div class="RollDate__time__period">\n <div class="RollDate__time__segmented RollDate__time__segmented--period" data-role="period">\n <button type="button" class="RollDate__time__segment-btn" data-period="AM">AM</button>\n <button type="button" class="RollDate__time__segment-btn" data-period="PM">PM</button>\n </div>\n </div>\n ',this.#S&&this.root.classList.add("RollDate__time--12h"),this.#I(),this.#A(),this.#E()}#I(){this.root.querySelector('[data-role="period"]')?.addEventListener("click",t=>{const e=t.target.closest("[data-period]");e&&this.#S&&this.#L(e.dataset.period)})}#L(t){if("AM"!==t&&"PM"!==t)return;if(this.#T===t)return;this.#C();const e=this.#T;this.#T=t,"AM"===e&&"PM"===t&&this.#w<12?this.#w+=12:"PM"===e&&"AM"===t&&this.#w>=12&&(this.#w-=12),this.#x.find(t=>"hour"===t.unit)?.scrollToValue(this.#k(),!0),this.#E(),i(this.hapticFeedback),this.#P()}#E(){this.root.classList.toggle("RollDate__time--12h",this.#S),this.root.querySelectorAll("[data-period]").forEach(t=>{const e=t.dataset.period===this.#T;t.classList.toggle("RollDate__time__segment-btn--active",e),t.setAttribute("aria-pressed",e?"true":"false")})}#V(){this.#x.forEach(t=>t._resizeObserver?.disconnect()),this.#x=[]}#A(){this.#V();const t=this.root.querySelector(".RollDate__time__picker");if(!t)return;const e=this.#S?Array.from({length:12},(t,e)=>e+1):Array.from({length:24},(t,e)=>e),s=[];for(let t=0;t<60;t+=this.#R)s.push(t);t.innerHTML='\n <div class="RollDate__time__field" data-unit="hour">\n <div class="RollDate__time__column">\n <div class="RollDate__time__viewport">\n <div class="RollDate__time__list"></div>\n </div>\n </div>\n </div>\n <span class="RollDate__time__sep">:</span>\n <div class="RollDate__time__field" data-unit="minute">\n <div class="RollDate__time__column">\n <div class="RollDate__time__viewport">\n <div class="RollDate__time__list"></div>\n </div>\n </div>\n </div>\n ',this.#x.push(this.#O("hour",e,this.#S?this.#k():this.#w)),this.#x.push(this.#O("minute",s,this.#M))}#P(){this.#C(),this.onChange(this.getTime())}#q(t,e){return"period"===t?e:Number(e)}#O(t,e,s){const a=this.root.querySelector(`[data-unit="${t}"]`),n=a.querySelector(".RollDate__time__viewport"),o=a.querySelector(".RollDate__time__list");o.innerHTML=e.map(e=>`<div class="RollDate__time__item" data-value="${e}">${"minute"===t?String(e).padStart(2,"0"):String(e)}</div>`).join("");const r={unit:t,viewport:n,list:o,values:e,offset:0,getMetrics:()=>this.#H(n)},l=()=>{const{pad:t}=r.getMetrics();o.style.paddingTop=`${t}px`,o.style.paddingBottom=`${t}px`};return l(),r.updateActive=()=>{const t=r.indexFromOffset();r._lastIndex!==t&&(void 0!==r._lastIndex&&(i(this.hapticFeedback),this.#P()),r._lastIndex=t),o.querySelectorAll(".RollDate__time__item").forEach((e,s)=>{e.classList.toggle("RollDate__time__item--active",s===t)})},r.indexFromOffset=()=>{const{itemH:t}=r.getMetrics(),s=Math.round(-r.offset/t);return Math.min(e.length-1,Math.max(0,s))},r.getValue=()=>e[r.indexFromOffset()],r.apply=t=>{o.style.transition=t?"transform 0.2s ease":"none",o.style.transform=`translateY(${r.offset}px)`,r.updateActive()},r.snap=()=>{const{itemH:t}=r.getMetrics(),e=r.indexFromOffset();r.offset=-e*t,r._lastIndex=e,r.apply(!0),this.#P()},r.scrollToValue=(t,s=!0)=>{const{itemH:i}=r.getMetrics(),a=e.indexOf(t);a<0||(r.offset=-a*i,r._lastIndex=a,r.apply(s))},r.scrollToIndex=(t,s=!0)=>{const{itemH:i}=r.getMetrics(),a=Math.min(e.length-1,Math.max(0,t));r.offset=-a*i,r._lastIndex=a,r.apply(s)},r.scrollToValue(s,!1),this.#B(r),this.#W(r),this.#z(r),r._resizeObserver=new ResizeObserver(()=>{l(),r.scrollToIndex(r.indexFromOffset(),!1)}),r._resizeObserver.observe(n),r}#z(t){t.list.addEventListener("click",e=>{const s=e.target.closest(".RollDate__time__item");if(!s)return;const i=this.#q(t.unit,s.dataset.value);t.scrollToValue(i,!0),this.#P()})}#B(t){t.viewport.addEventListener("wheel",e=>{e.preventDefault(),e.stopPropagation();const{itemH:s}=t.getMetrics();t.list.style.transition="none",t.offset-=.35*e.deltaY;const i=-(t.values.length-1)*s;t.offset=Math.max(i,Math.min(0,t.offset)),t.list.style.transform=`translateY(${t.offset}px)`,t.updateActive(),clearTimeout(t._snapTimer),t._snapTimer=setTimeout(()=>t.snap(),90)},{passive:!1})}#W(t){let e=0,s=0;t.viewport.addEventListener("touchstart",i=>{i.touches&&1===i.touches.length&&(e=i.touches[0].clientY,s=t.offset,t.list.style.transition="none")},{passive:!0}),t.viewport.addEventListener("touchmove",i=>{if(!i.touches||1!==i.touches.length)return;i.preventDefault();const{itemH:a}=t.getMetrics();t.offset=s+(i.touches[0].clientY-e);const n=-(t.values.length-1)*a;t.offset=Math.max(n,Math.min(0,t.offset)),t.list.style.transform=`translateY(${t.offset}px)`,t.updateActive()},{passive:!1}),t.viewport.addEventListener("touchend",()=>t.snap())}#C(){const t=this.#x.find(t=>"hour"===t.unit),e=this.#x.find(t=>"minute"===t.unit);if(!t||!e)return;const s=t.getValue();this.#M=e.getValue(),this.#S?"AM"===this.#T?this.#w=12===s?0:s:this.#w=12===s?12:s+12:this.#w=s}getTime(){return{hours:this.#w,minutes:this.#M}}setTime(t,e){this.#w=this.#Y(t),this.#M=this.#N(e),this.#S?(this.#T=this.#w>=12?"PM":"AM",this.#x.find(t=>"hour"===t.unit)?.scrollToValue(this.#k())):this.#x.find(t=>"hour"===t.unit)?.scrollToValue(this.#w),this.#x.find(t=>"minute"===t.unit)?.scrollToValue(this.#M),this.#E()}destroy(){this.#V(),this.root.innerHTML=""}}class p{static#j=new Set;#J;#U=0;#G=!1;#X=["day","month","year"];#K=[];#Q=!0;#Z=new Set;#tt=new Map;#et=null;#st=[];#it(t,e,s){return t instanceof Date&&!Number.isNaN(t.getTime())?t<e?new Date(e):t>s?new Date(s):t:e}#at(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()}#nt(t){if(t instanceof Date&&!Number.isNaN(t.getTime()))return new Date(t.getFullYear(),t.getMonth(),t.getDate());if("string"==typeof t){const e=t.trim();if(!e)return null;const s=e.match(/[-/.]/)?.[0],i=this.options.dateFormat.match(/[-/.]/)?.[0],n=a(e,s&&i&&s!==i?"auto":this.options.dateFormat);if(!(n instanceof Date)||Number.isNaN(n.getTime())){const t=a(e,"auto");return t instanceof Date&&!Number.isNaN(t.getTime())?new Date(t.getFullYear(),t.getMonth(),t.getDate()):null}return new Date(n.getFullYear(),n.getMonth(),n.getDate())}const e=n(t,this.options.dateFormat);return e instanceof Date&&!Number.isNaN(e.getTime())?new Date(e.getFullYear(),e.getMonth(),e.getDate()):null}#ot(t=[]){const e=new Set;return t.forEach(t=>{const s=this.#nt(t);s&&e.add(this.#at(s))}),e}#rt(t=[]){return this.#ot(t)}#lt(t=[]){const e=new Map;return Array.isArray(t)?(t.forEach(t=>{const s=this.#ht(t);if(!s)return;const i=e.get(s.stamp)||[];e.set(s.stamp,i.concat(s.colors))}),e):e}#ht(t){if(null==t)return null;if("string"==typeof t||t instanceof Date){const e=this.#nt(t);return e?{stamp:this.#at(e),colors:[null]}:null}if("object"==typeof t&&null!=t.date){const e=this.#nt(t.date);if(!e)return null;const s=this.#at(e);if(Array.isArray(t.colors)){const e=t.colors.map(t=>null==t||""===t?null:this.#dt(t)).filter(t=>void 0!==t);if(e.length)return{stamp:s,colors:e}}if(null!=t.color&&""!==t.color){const e=this.#dt(t.color);if(e)return{stamp:s,colors:[e]}}return{stamp:s,colors:[null]}}return null}#dt(t){if("string"!=typeof t)return null;const e=t.trim();return e&&(/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)||/^(rgb|rgba|hsl|hsla)\([^)]+\)$/i.test(e)||/^var\(--[\w-]+\)$/.test(e))?e:null}#ct(){return[...this.#tt.entries()].map(([t,e])=>{const s=new Date(t);return 1===e.length&&null===e[0]?s:1===e.length&&e[0]?{date:s,color:e[0]}:{date:s,colors:e}})}#ut(t){t&&"INPUT"===t.tagName&&(t.setAttribute("autocomplete","off"),t.setAttribute("autocorrect","off"),t.setAttribute("autocapitalize","off"),t.setAttribute("spellcheck","false"))}#mt(t){return this.#Z.has(this.#at(t))}#pt(t){return this.#tt.has(this.#at(t))}#gt(t){const e=this.#tt.get(this.#at(t));return e?.length?{colors:e}:null}#Dt(){"single"!==this.options.selectType?this.options.selectDate([...this.#K]):this.options.selectDate(this.#K[0]||null)}#_t(){const t=this.#K.length;this.#K=this.#K.filter(t=>!this.#mt(t)),t!==this.#K.length&&(this.#Dt(),this.#ft())}#yt(t){const e=new Date(t);if(!this.options.enableTime)return e;const s=this.timePicker?.getTime()||{hours:this.options.startDate.getHours(),minutes:this.options.startDate.getMinutes()};return e.setHours(s.hours,s.minutes,0,0),e}#bt(t){const e=function(t,e="YYYY-MM-DD"){if(!t||!(t instanceof Date)||isNaN(t))return"";const s=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),a=String(t.getDate()).padStart(2,"0"),n={YYYY:s,YY:String(s).slice(-2),MM:i,M:t.getMonth()+1,DD:a,D:t.getDate()};return e.replace(/YYYY|YY|MM|M|DD|D/g,t=>n[t]||t)}(t,this.options.dateFormat);if(!this.options.enableTime)return e;return`${e} ${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}#vt(){if(!this.dom.$footer_buttons)return;const t=Array.isArray(this.options.footerButtons)?this.options.footerButtons:[];this.dom.$footer_buttons.innerHTML="",t.forEach(t=>{if(!t?.text)return;const e=document.createElement("button");e.type="button",e.className="RollDate__footer__button","primary"===t.variant?e.classList.add("RollDate__footer__button--primary"):"secondary"===t.variant&&e.classList.add("RollDate__footer__button--secondary"),e.textContent=t.text,e.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),this.#$t(t)}),this.dom.$footer_buttons.append(e)})}#$t(t){"today"!==t.action?"clear"!==t.action?"function"==typeof t.onClick&&t.onClick(this):this.clearSelection():this.selectToday()}#wt(){const t=Array.isArray(this.options.rangePresets)?this.options.rangePresets:[];if("range"!==this.options.selectType||!t.length)return;let e=this.$container.querySelector(".RollDate__presets");if(!e){e=document.createElement("div"),e.className="RollDate__presets";const t=this.$container.querySelector(".RollDate__footer"),s=this.$container.querySelector(".RollDate__calendar");t?t.before(e):s&&s.after(e)}e.innerHTML="",t.forEach(t=>{if(!t?.label||"function"!=typeof t.getRange)return;const s=document.createElement("button");s.type="button",s.className="RollDate__presets__button",s.textContent=t.label,s.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),this.#Mt(t)}),e.append(s)}),e.childElementCount&&this.$container.classList.add("RollDate__has-presets")}#Mt(t){const e=t.getRange(this);if(!Array.isArray(e)||e.length<2)return;const s=e.slice(0,2).map(t=>this.#nt(t)).filter(Boolean).map(t=>this.#it(t,this.options.minDate,this.options.maxDate)).filter(t=>!this.#mt(t));if(s.length<2)return;let[i,a]=s;i>a&&([i,a]=[a,i]),this.#K=[this.#yt(i),this.#yt(a)],this.#Dt(),this.#ft(),this.#St()}#Tt(){const t=this.options.startDate;this.timePicker=new m(this.dom.$time,{hours:t.getHours(),minutes:t.getMinutes(),use12Hour:this.options.use12Hour,minuteStep:this.options.timeStep,hapticFeedback:!1!==this.options.hapticFeedback,onChange:()=>{this.#K.length&&(this.#K=this.#K.map(t=>this.#yt(t)),this.#Dt(),this.#ft())}})}constructor(t,e={}){null==e&&(e={}),this.triggerSelector=e.triggerSelector,Array.isArray(t)?(this.$startInput=document.querySelector(t[0]),this.$endInput=document.querySelector(t[1]),this.$trigger=this.$startInput,this.mode="popup"):(this.$trigger=document.querySelector(t),this.triggerSelector?(this.$openTrigger=document.querySelector(this.triggerSelector),this.mode="popup"):"INPUT"===this.$trigger.tagName?this.mode="popup":this.mode="inline");const s=new Date,i={mode:"auto",theme:"main",startWeekFromMonday:!0,selectType:"single",monthsNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShortNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekDaysNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],selectDate:t=>console.log(t),onOpen:()=>{},onClose:()=>{},onViewChange:()=>{},onHoverDate:()=>{},disabledDates:[],highlightDates:[],closeOnSelect:!0,enableTime:!1,use12Hour:!1,timeStep:1,timePosition:"right",footerButtons:[],rangePresets:[],hapticFeedback:!0,...e};"default"===i.theme&&(i.theme="main");const a=i.locale||("undefined"!=typeof navigator?navigator.language:void 0);i.dateFormat=i.dateFormat||function(t){const e=t||("undefined"!=typeof navigator&&navigator.language?navigator.language:"en-US");try{return new Intl.DateTimeFormat(e,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(2023,5,15)).map(t=>"year"===t.type?"YYYY":"month"===t.type?"MM":"day"===t.type?"DD":t.value).join("")}catch{return"MM/DD/YYYY"}}(a);const o={startDate:n(void 0!==e.startDate?e.startDate:s,i.dateFormat),minDate:n(void 0!==e.minDate?e.minDate:new Date(s.getFullYear()-100,s.getMonth(),1),i.dateFormat),maxDate:n(void 0!==e.maxDate?e.maxDate:new Date(s.getFullYear()+100,s.getMonth()+1,0),i.dateFormat)};this.options={...i,...o},this.options.minDate>this.options.maxDate&&console.error("Date Error: maxDate is less than minDate!"),this.options.startDate=this.#it(this.options.startDate,this.options.minDate,this.options.maxDate),this.#Z=this.#rt(this.options.disabledDates),this.#tt=this.#lt(this.options.highlightDates),this.#mt(this.options.startDate)&&(this.options.startDate=new Date(this.options.minDate)),this.#Rt(),p.#j.add(this)}#xt(){for(const t of p.#j)t!==this&&"popup"===t.mode&&t.close()}#Rt(){if("object"==typeof this.options&&null!==this.options){if(this.$container=document.createElement("div"),this.$container.className=`RollDate__container RollDate__calendar__type--days RollDate__theme_${this.options.theme}`,this.#ut(this.$trigger),this.#ut(this.$startInput),this.#ut(this.$endInput),"popup"===this.mode?(document.body.appendChild(this.$container),this.$container.style.display="none"):"DIV"===this.$trigger.nodeName||"SPAN"===this.$trigger.nodeName||"SECTION"===this.$trigger.nodeName?this.$trigger.append(this.$container):document.body.append(this.$container),this.options.enableTime){this.$container.classList.add("RollDate__has-time");const t="bottom"===this.options.timePosition?"bottom":"right";this.$container.classList.add(`RollDate__time-position_${t}`)}this.options.footerButtons?.length&&this.$container.classList.add("RollDate__has-footer"),this.render=new d({container:this.$container,trigger:this.$trigger,startWeekFromMonday:this.options.startWeekFromMonday,monthsNames:this.options.monthsNames,monthsShortNames:this.options.monthsShortNames,weekDays:this.options.weekDaysNames,enableTime:this.options.enableTime,footerButtons:this.options.footerButtons}),this.dom={$year:this.$container.querySelector(".RollDate__header__year"),$month:this.$container.querySelector(".RollDate__header__month"),$years_block:this.$container.querySelector(".RollDate__calendar__years"),$months_block:this.$container.querySelector(".RollDate__calendar__months"),$days_block:this.$container.querySelector(".RollDate__calendar__days"),$body:this.$container.querySelector(".RollDate__calendar__body"),$type_switcher:this.$container.querySelector(".RollDate__calendar__switcher"),$page_switcher:this.$container.querySelectorAll(".RollDate__calendar__button"),$footer_buttons:this.$container.querySelector(".RollDate__footer__buttons"),$time:this.$container.querySelector(".RollDate__time")},this.#vt(),this.#wt(),this.options.enableTime&&this.dom.$time&&this.#Tt(),this.virtualizer=new u(this),this.#Yt(),this.observe=new l(this.$container),this.data=new h({startDate:this.options.startDate,minDate:this.options.minDate,maxDate:this.options.maxDate,startWeekFromMonday:this.options.startWeekFromMonday,isDateDisabled:t=>this.#mt(t)}),this.#Nt(this.#U)}else console.error("RollDate: options is not an object!")}#Ft(){if("popup"!==this.mode)return;if(window.innerWidth<=380)return this.$container.style.position="fixed",this.$container.style.left="8px",this.$container.style.right="8px",this.$container.style.top="auto",this.$container.style.bottom="8px",this.$container.style.width="auto",this.$container.style.maxHeight="min(80vh, 560px)",void(this.$container.style.zIndex="10000");const t=(this.$endInput?this.$startInput:(this.$openTrigger,this.$trigger)).getBoundingClientRect(),e=window.innerHeight-t.bottom;this.$container.style.top=e<300?t.top+window.scrollY-this.$container.offsetHeight+"px":`${t.bottom+window.scrollY}px`,this.$container.style.left=`${t.left+window.scrollX}px`,this.$container.style.right="auto",this.$container.style.bottom="auto",this.$container.style.width="",this.$container.style.maxHeight="",this.$container.style.position="absolute",this.$container.style.zIndex="10000"}#Nt(t,e){let s={};"object"==typeof t&&null!==t?s=t:("number"==typeof t&&(this.#U=t),"object"==typeof e&&null!==e&&(s=e));const i=!0===s.preserveScroll,a=i?this.scroll.offset:null,n=!0===s.animate&&Number(s.shift),o="function"==typeof s.onScrollComplete?s.onScrollComplete:null,r=()=>{o?.()};if(this.#kt(),this.scroll.blocked=!1,this.observe.un(this.period),this.#Ht(this.period),"day"===this.period){const t=this.data.getDates();this.dom.$days_block.innerHTML=this.render.dates(t,this.#K,this.options.selectType,t=>this.#gt(t))}else{const t=this.data.getMonthsOrYears(this.period);this.dom[`$${this.period}s_block`].innerHTML=this.render[`${this.period}s`](t)}setTimeout(()=>{const t=this.dom.$body.querySelector(".RollDate__calendar__scrollblock"),e=this.dom.$body.clientHeight,o=t.clientHeight;if(o<=e)return this.scroll.setBaseOffset(e-o),this.scroll.offset=0,void r();if(this.scroll.setBaseOffset(0),this.scroll.resetMinScroll(),i&&null!=a)return this.scroll.offset=Math.max(a,this.scroll.minScroll),void r();const l={day:`.RollDate__calendar__day[data-year="${this.data.current_year}"][data-month="${this.data.current_month}"]`,month:`.RollDate__calendar__month[data-year="${this.data.current_year}"][data-month="0"]`,year:`.RollDate__calendar__year[data-decade="${this.data.current_decade}"][data-year="${this.data.current_year}"]`};let h=this.$container.querySelector(l[this.period]);if(!h){const t={day:`.RollDate__calendar__day[data-year="${this.data.current_year}"]`,month:`.RollDate__calendar__month[data-year="${this.data.current_year}"]`,year:`.RollDate__calendar__year[data-decade="${this.data.current_decade}"]`};h=this.$container.querySelector(t[this.period])}if(!h)return void r();const d=t.getBoundingClientRect(),c=-(h.getBoundingClientRect().top-d.top),u=Math.max(c,this.scroll.minScroll);if(n){const t=Math.min(.38*e,140),i=Math.max(Math.min(u+(s.shift>0?t:-t),0),this.scroll.minScroll);return this.scroll.offset=i,void this.scroll.animateTo(u,{onComplete:r})}this.scroll.offset=u,r()},0),this.observe.on(this.period,t=>{JSON.parse(t.dataset.bind).every(e=>Number(t.dataset[e])===this.data[`current_${e}`])&&t.classList.add(`RollDate__calendar__${this.period}--active`)})}#kt(){"year"!==this.period?(this.dom.$year.innerText=this.data.current_year,this.dom.$month.innerText=this.options.monthsNames[this.data.current_month]):this.dom.$year.innerText=Number(this.data.current_decade)+"-"+(Number(this.data.current_decade)+9);this.$container.querySelectorAll(`.RollDate__calendar__${this.period}`).forEach(t=>{for(const e of JSON.parse(t.dataset.bind)){JSON.parse(t.dataset.bind).every(e=>Number(t.dataset[e])===this.data[`current_${e}`])?t.classList.add(`RollDate__calendar__${this.period}--active`):t.classList.remove(`RollDate__calendar__${this.period}--active`)}})}#Yt(){if("popup"===this.mode){const t=[];this.triggerSelector?(this.$openTrigger=document.querySelector(this.triggerSelector),t.push(this.$openTrigger)):this.$endInput?t.push(this.$startInput,this.$endInput):t.push(this.$trigger),this.#st=t.filter(Boolean),this.#st.forEach(t=>{t.addEventListener("click",t=>{t.stopPropagation(),this.open()}),"INPUT"===t.tagName&&t.addEventListener("focus",()=>this.open())}),this.#et=t=>{this.$container.contains(t.target)||this.#st.some(e=>e.contains(t.target))||this.close()},document.addEventListener("click",this.#et);(this.$endInput?[this.$startInput,this.$endInput]:[this.$trigger]).forEach(t=>{"INPUT"===t?.tagName&&t.addEventListener("input",t=>{this.#It(t.target.value)})})}this.scroll=new c(this.dom.$body,{dominant:()=>{const e=this.observe.dominant();if(e)for(const s of Object.keys(e))if(this.data[`current_${s}`]!==e[s]){(e.hasOwnProperty("year")||e.hasOwnProperty("month"))&&(this.data.current_year=e.year,this.data.current_month=e.month,this.data.current_decade=t(e.year)),e.hasOwnProperty("decade")&&(this.data.current_decade=e.decade),i(!1!==this.options.hapticFeedback),this.#kt();break}},updatePeriod:t=>this.virtualizer.update(t)}),this.dom.$type_switcher.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.#At(++this.#U)}),this.dom.$body.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation();const s=e.target.closest("[data-click]"),i=e.target.closest("[data-day]");if(s){if(s.classList.contains("RollDate__calendar__month--disabled")||s.classList.contains("RollDate__calendar__year--disabled"))return;this.data.current_month=Number(s.dataset.month),this.data.current_year=Number(s.dataset.year),this.data.current_decade=t(this.data.current_year);const e=s.dataset.click;this.#At(this.#X.indexOf(e))}if(i){if(i.classList.contains("RollDate__calendar__day--disabled"))return;const t=this.#yt(new Date(Number(i.dataset.year),Number(i.dataset.month),Number(i.dataset.day)));if("single"===this.options.selectType&&(this.$container.querySelectorAll("[data-day]").forEach(t=>{t.classList.remove("RollDate__calendar__day--selected")}),i.classList.add("RollDate__calendar__day--selected"),this.#K=[t],this.options.selectDate(t),this.#ft(),"popup"===this.mode&&this.options.closeOnSelect&&this.close()),"range"===this.options.selectType){const e=this.#at(t),s=2===this.#K.length&&e>=this.#at(this.#K[0])&&e<=this.#at(this.#K[1]);if(2!==this.#K.length||s||this.#Et(),0===this.#K.length)this.#K=[t],i.classList.add("RollDate__calendar__day--range-first");else{const s=this.#K[0],a=this.#at(s);e>a?(this.#K=[s,t],this.$container.querySelectorAll("[data-day]").forEach(t=>{const s=new Date(Number(t.dataset.year),Number(t.dataset.month),Number(t.dataset.day)),i=this.#at(s);i===a?t.classList.add("RollDate__calendar__day--range-first"):i===e?t.classList.add("RollDate__calendar__day--range-last"):i>a&&i<e&&t.classList.add("RollDate__calendar__day--range-selected")})):e<a&&(this.#K=[t],i.classList.add("RollDate__calendar__day--range-first"),this.$container.querySelector('.RollDate__calendar__day--range-first:not([data-day="'+t.getDate()+'"])')?.classList.remove("RollDate__calendar__day--range-first"))}this.options.selectDate([...this.#K]),this.#ft(),"popup"===this.mode&&2===this.#K.length&&this.options.closeOnSelect&&this.close()}if("multi"===this.options.selectType){const e=this.#at(t);this.#K.some(t=>this.#at(t)===e)?(this.#K=this.#K.filter(t=>this.#at(t)!==e),i.classList.remove("RollDate__calendar__day--selected")):(this.#K.push(t),i.classList.add("RollDate__calendar__day--selected")),this.options.selectDate(this.#K),this.#ft(),"popup"===this.mode&&this.options.closeOnSelect&&this.close()}}this.scroll.resetMinScroll()}),this.dom.$body.addEventListener("mousemove",t=>{const e=t.target.closest("[data-day]");if(!e)return;if(e.classList.contains("RollDate__calendar__day--disabled"))return;const s=new Date(Number(e.dataset.year),Number(e.dataset.month),Number(e.dataset.day));this.options.onHoverDate(s,{period:this.period,selectedDates:[...this.#K]})}),this.dom.$body.addEventListener("mouseleave",()=>{this.options.onHoverDate(null,{period:this.period,selectedDates:[...this.#K]})}),this.dom.$page_switcher.forEach(e=>{e.addEventListener("click",e=>{if(e.preventDefault(),e.stopPropagation(),this.#G)return;const s=e.currentTarget?.dataset?.direction;if("prev"!==s&&"next"!==s)return;const a="prev"===s?-1:1,n=this.options.minDate.getFullYear(),o=this.options.maxDate.getFullYear();if("day"===this.period){const e=new Date(this.data.current_year,this.data.current_month,1),s=new Date(this.data.current_year,this.data.current_month+a,1),i=new Date(this.options.minDate.getFullYear(),this.options.minDate.getMonth(),1),n=new Date(this.options.maxDate.getFullYear(),this.options.maxDate.getMonth(),1);if(s<i||s>n)return;if(s.getTime()===e.getTime())return;this.data.current_year=s.getFullYear(),this.data.current_month=s.getMonth(),this.data.current_decade=t(this.data.current_year)}else if("month"===this.period){const e=this.data.current_year+a;if(e<n||e>o)return;this.data.current_year=e,this.data.current_decade=t(e)}else if("year"===this.period){const e=t(this.data.current_year)+10*a,s=t(n),i=t(o);if(e<s||e>i)return;this.data.current_year=e,this.data.current_decade=e}this.#G=!0,i(!1!==this.options.hapticFeedback),this.#Nt(this.#U,{animate:!0,shift:a,onScrollComplete:()=>{this.#G=!1}})})})}#At(t){const e=this.period;if(t>2)t=this.period=2;else{this.scroll.resetMinScroll(),this.period=t,this.#Nt(this.period);for(const t of this.#X)this.$container.classList.remove("RollDate__calendar__type--"+t+"s");this.$container.classList.add("RollDate__calendar__type--"+this.#X[t]+"s"),this.options.onViewChange({from:e,to:this.period,current:{year:this.data.current_year,month:this.data.current_month,decade:this.data.current_decade}})}}#Ht(t){2!==t&&(this.dom.$years_block.innerHTML=""),1!==t&&(this.dom.$months_block.innerHTML=""),0!==t&&(this.dom.$days_block.innerHTML="")}#Lt(){requestAnimationFrame(()=>{this.scroll.checkMinScroll();const t=this.options.startDate,e=this.$container.querySelector(`[data-year="${t.getFullYear()}"][data-month="${t.getMonth()}"]`);if(e){const t=this.dom.$body.querySelector(".RollDate__calendar__scrollblock").getBoundingClientRect(),s=-(e.getBoundingClientRect().top-t.top);this.scroll.offset=s}})}get period(){return this.#X[this.#U]}set period(t){this.#U=t}get selectedDates(){return this.#K}getViewMonth(){return{year:this.data.current_year,month:this.data.current_month}}getViewDate(){const{year:t,month:e}=this.getViewMonth();return new Date(t,e,1)}setDisabledDates(t=[]){this.options.disabledDates=Array.isArray(t)?t:[],this.#Z=this.#rt(this.options.disabledDates),this.#_t(),this.#Nt(this.#U)}disableDate(t){const e=this.#nt(t);e&&(this.#Z.add(this.#at(e)),this.options.disabledDates=[...this.#Z].map(t=>new Date(t)),this.#_t(),this.#Nt(this.#U))}enableDate(t){const e=this.#nt(t);e&&(this.#Z.delete(this.#at(e)),this.options.disabledDates=[...this.#Z].map(t=>new Date(t)),this.#Nt(this.#U))}isDateDisabled(t){const e=this.#nt(t);return!!e&&this.#mt(e)}setHighlightDates(t=[]){this.options.highlightDates=Array.isArray(t)?t:[],this.#tt=this.#lt(this.options.highlightDates),this.#Nt(this.#U)}highlightDate(t,e){const s=this.#nt(t);if(!s)return;const i=this.#at(s),a=this.#tt.get(i)||[],n=null==e||""===e?null:this.#dt(e);null!=e&&""!==e&&void 0===n||(a.push(n??null),this.#tt.set(i,a),this.options.highlightDates=this.#ct(),this.#Nt(this.#U))}unhighlightDate(t,e){const s=this.#nt(t);if(!s)return;const i=this.#at(s),a=this.#tt.get(i);if(a?.length){if(void 0===e)this.#tt.delete(i);else{const t=null==e||""===e?null:this.#dt(e),s=a.findIndex(e=>e===t);if(-1===s)return;a.splice(s,1),a.length?this.#tt.set(i,a):this.#tt.delete(i)}this.options.highlightDates=this.#ct(),this.#Nt(this.#U)}}isDateHighlighted(t){const e=this.#nt(t);return!!e&&this.#pt(e)}getHighlightColors(t){const e=this.#nt(t);return e?[...this.#tt.get(this.#at(e))||[]]:[]}getHighlightColor(t){return this.getHighlightColors(t).find(t=>null!=t)??null}goToDate(e){const s=this.#nt(e);if(!s)return!1;const i=this.#it(s,this.options.minDate,this.options.maxDate);if(this.data.current_year=i.getFullYear(),this.data.current_month=i.getMonth(),this.data.current_decade=t(i.getFullYear()),0!==this.#U){this.#U=0;for(const t of this.#X)this.$container.classList.remove("RollDate__calendar__type--"+t+"s");this.$container.classList.add("RollDate__calendar__type--days")}return this.#Nt(0),!0}getValue(){if("single"===this.options.selectType){const t=this.#K[0];return t?new Date(t.getTime()):null}return this.#K.map(t=>new Date(t.getTime()))}setValue(t){if(null==t||""===t)return this.clearSelection(),!0;if("single"===this.options.selectType){const e=this.#nt(t);if(!e||this.#mt(e))return!1;this.#K=[this.#yt(e)]}else if("range"===this.options.selectType){const e=(Array.isArray(t)?t:[t]).map(t=>this.#nt(t)).filter(Boolean).map(t=>this.#it(t,this.options.minDate,this.options.maxDate)).filter(t=>!this.#mt(t));if(!e.length)return!1;let s=e[0],i=e.length>1?e[1]:e[0];s>i&&([s,i]=[i,s]),this.#K=e.length>1?[this.#yt(s),this.#yt(i)]:[this.#yt(s)]}else{const e=(Array.isArray(t)?t:[t]).map(t=>this.#nt(t)).filter(Boolean).map(t=>this.#it(t,this.options.minDate,this.options.maxDate)).filter(t=>!this.#mt(t)).map(t=>this.#yt(t));if(!e.length)return!1;const s=[],i=new Set;e.forEach(t=>{const e=this.#at(t);i.has(e)||(i.add(e),s.push(t))}),this.#K=s}return this.#Ct(),this.#Dt(),this.#ft(),!0}#Pt(t){return this.#at(new Date(Number(t.dataset.year),Number(t.dataset.month),Number(t.dataset.day)))}#Vt(t){return t instanceof Date?this.$container.querySelector(`.RollDate__calendar__day[data-year="${t.getFullYear()}"][data-month="${t.getMonth()}"][data-day="${t.getDate()}"]`):null}#St(){if(this.$container.querySelectorAll("[data-day]").forEach(t=>{t.classList.remove("RollDate__calendar__day--range-first","RollDate__calendar__day--range-last","RollDate__calendar__day--range-selected")}),!this.#K.length)return;const t=this.#at(this.#K[0]);if(1===this.#K.length)return void this.#Vt(this.#K[0])?.classList.add("RollDate__calendar__day--range-first");const e=this.#at(this.#K[1]);this.$container.querySelectorAll("[data-day]").forEach(s=>{const i=this.#Pt(s);i===t?s.classList.add("RollDate__calendar__day--range-first"):i===e?s.classList.add("RollDate__calendar__day--range-last"):i>t&&i<e&&s.classList.add("RollDate__calendar__day--range-selected")})}#Ot(){this.$container.querySelectorAll("[data-day]").forEach(t=>{t.classList.remove("RollDate__calendar__day--selected")});const t=this.#K[0];t&&this.#Vt(t)?.classList.add("RollDate__calendar__day--selected")}#qt(){const t=new Set(this.#K.map(t=>this.#at(t)));this.$container.querySelectorAll("[data-day]").forEach(e=>{t.has(this.#Pt(e))?e.classList.add("RollDate__calendar__day--selected"):e.classList.remove("RollDate__calendar__day--selected")})}#Ct(){"range"!==this.options.selectType?"multi"!==this.options.selectType?this.#Ot():this.#qt():this.#St()}#Et(){this.#K=[],this.$container.querySelectorAll("[data-day]").forEach(t=>{t.classList.remove("RollDate__calendar__day--range-first","RollDate__calendar__day--range-last","RollDate__calendar__day--range-selected")})}#Bt(){this.#K=[],this.$container.querySelectorAll("[data-day].RollDate__calendar__day--selected").forEach(t=>t.classList.remove("RollDate__calendar__day--selected"))}#ft(){if("popup"!==this.mode)return;const t=t=>this.#bt(t);if(this.$endInput)this.#K.length>=1?this.$startInput.value=t(this.#K[0]):this.$startInput.value="",2===this.#K.length?this.$endInput.value=t(this.#K[1]):this.$endInput.value="";else{const e=this.$trigger;"INPUT"===e.tagName&&("single"===this.options.selectType&&this.#K.length>0?e.value=t(this.#K[0]):"range"===this.options.selectType?1===this.#K.length?e.value=`${t(this.#K[0])} - `:2===this.#K.length?e.value=`${t(this.#K[0])} - ${t(this.#K[1])}`:e.value="":"multi"===this.options.selectType&&this.#K.length>0?e.value=this.#K.map(t).join(", "):e.value="")}}#It(t){if(!t)return this.#K=[],void this.#Nt(this.#U);try{if("single"===this.options.selectType){const e=a(t,this.options.dateFormat);e&&!this.#mt(e)&&(this.#K=[e],this.data.current_year=e.getFullYear(),this.data.current_month=e.getMonth(),this.#Nt(this.#U))}else if("range"===this.options.selectType){const e=t.split(/\s+-\s+/).map(t=>t.trim()).filter(t=>t).map(t=>a(t,this.options.dateFormat)).filter(t=>!this.#mt(t)).filter(t=>t);e.length>0&&(this.#K=e,e.length>=1&&(this.data.current_year=e[0].getFullYear(),this.data.current_month=e[0].getMonth()),this.#Nt(this.#U))}else if("multi"===this.options.selectType){const e=t.split(",").map(t=>t.trim()).filter(t=>t).map(t=>a(t,this.options.dateFormat)).filter(t=>!this.#mt(t)).filter(t=>t);e.length>0&&(this.#K=e,this.data.current_year=e[0].getFullYear(),this.data.current_month=e[0].getMonth(),this.#Nt(this.#U))}}catch(e){console.warn("Invalid date format:",t)}}open(){"popup"===this.mode&&this.#xt();const t="none"!==this.$container.style.display;this.$container.style.display="block","popup"===this.mode?(this.#Ft(),this.#Q?(this.#Lt(),this.#Q=!1):this.#Nt(this.#U)):this.dom?.$body||this.#Nt(this.#U),t||this.options.onOpen({period:this.period,selectedDates:[...this.#K]})}close(){const t="none"!==this.$container.style.display;if(this.$container.style.display="none","popup"===this.mode){(this.$endInput?[this.$startInput,this.$endInput]:this.$openTrigger?[this.$openTrigger]:[this.$trigger]).forEach(t=>{t&&"function"==typeof t.blur&&t.blur()})}t&&this.options.onClose({period:this.period,selectedDates:[...this.#K]})}selectToday(){const e=new Date,s=new Date(e.getFullYear(),e.getMonth(),e.getDate());if(this.#mt(s))return;this.data.current_year=e.getFullYear(),this.data.current_month=e.getMonth(),this.data.current_decade=t(e.getFullYear()),this.options.enableTime&&this.timePicker&&this.timePicker.setTime(e.getHours(),e.getMinutes());const i=this.#yt(e);if("single"===this.options.selectType)this.#K=[i];else if("range"===this.options.selectType)this.#K=[i];else if("multi"===this.options.selectType){const t=this.#at(i);this.#K.some(e=>this.#at(e)===t)||this.#K.push(i)}this.#Nt(this.#U),this.#Dt(),this.#ft(),"popup"===this.mode&&this.options.closeOnSelect&&"single"===this.options.selectType&&this.close()}clearSelection(){"range"===this.options.selectType?this.#Et():"multi"===this.options.selectType?this.#Bt():(this.#K=[],this.$container.querySelectorAll("[data-day].RollDate__calendar__day--selected").forEach(t=>t.classList.remove("RollDate__calendar__day--selected"))),this.#Dt(),this.#ft()}destroy(){this.#et&&(document.removeEventListener("click",this.#et),this.#et=null),p.#j.delete(this),this.observe.disconnect(),this.scroll?.destroy(),this.timePicker?.destroy(),this.$container.parentNode&&this.$container.parentNode.removeChild(this.$container)}}return"undefined"!=typeof window&&(window.RollDate=p),p}();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.rde{--rde-bg:#1e2229;--rde-border:#323844;--rde-text:#eceff4;--rde-muted:#8b95a8;--rde-accent:#609ef1;--rde-surface:#171a20;--rde-hover:#262b35;--rde-event-default:#609ef1;--rde-radius:10px;--rde-font:"Segoe UI",system-ui,sans-serif;--rde-rail-w:52px;background:var(--rde-bg);border:1px solid var(--rde-border);border-radius:12px;box-sizing:border-box;color:var(--rde-text);container-type:inline-size;font-family:var(--rde-font);min-width:0;padding:12px}.rde[data-compact=true]{--rde-rail-w:46px;border-radius:10px;padding:8px}.rde *,.rde :after,.rde :before{box-sizing:border-box}.rde[data-theme=light]{--rde-bg:#fff;--rde-border:#d8dde6;--rde-text:#1f2937;--rde-muted:#64748b;--rde-accent:#2d7cff;--rde-surface:#f5f7fb;--rde-hover:#eef2f8;--rde-event-default:#2d7cff}.rde-header{align-items:center;display:flex;flex-wrap:wrap;gap:10px;margin-bottom:12px}.rde[data-compact=true] .rde-header{align-items:stretch;flex-direction:column;gap:8px;margin-bottom:8px}.rde-nav,.rde-views{display:flex;flex-wrap:wrap;gap:6px}.rde[data-compact=true] .rde-views{display:grid;gap:4px;grid-template-columns:repeat(4,minmax(0,1fr));width:100%}.rde[data-compact=true] .rde-view{font-size:13px;min-height:40px;padding:8px 4px;text-align:center}.rde[data-compact=true] .rde-nav{justify-content:center}.rde[data-compact=true] .rde-btn{font-size:13px;min-height:40px}.rde-title{flex:1 1 auto;font-size:16px;font-weight:650;margin:0;min-width:140px;text-align:center}.rde[data-compact=true] .rde-title{font-size:15px;min-width:0;order:-1;text-align:left}.rde-btn{background:var(--rde-surface);border:1px solid var(--rde-border);border-radius:8px;color:var(--rde-text);cursor:pointer;font-size:13px;padding:6px 10px}.rde-btn.is-active,.rde-btn:hover{border-color:var(--rde-accent)}.rde-btn.is-active{background:color-mix(in srgb,var(--rde-accent) 22%,var(--rde-surface))}.rde-body{min-height:420px;min-width:0;width:100%}.rde-weekdays{display:grid;gap:4px;grid-template-columns:repeat(7,minmax(0,1fr))}.rde-weekday{color:var(--rde-muted);font-size:11px;padding:4px 0 8px;text-align:center}.rde-viewport{background:var(--rde-surface);border:1px solid var(--rde-border);border-radius:var(--rde-radius);height:min(640px,70vh);overflow:hidden;overscroll-behavior:contain;position:relative;touch-action:none}.rde-strip{display:block;transform:translateZ(0);width:100%;will-change:transform}.rde-week-row{box-sizing:border-box;display:grid;gap:4px;grid-template-columns:repeat(7,minmax(0,1fr));padding:0 4px;width:100%}.rde-day{background:transparent;border:1px solid var(--rde-border);border-radius:var(--rde-radius);cursor:pointer;display:flex;flex-direction:column;gap:3px;min-height:96px;min-width:0;outline:none;padding:6px;transition:opacity .5s ease,border-color .5s ease}.rde-day:focus-visible,.rde-day:hover{background:transparent;border-color:var(--rde-accent)}.rde-day--active-month{background:transparent;border-color:color-mix(in srgb,var(--rde-accent) 55%,var(--rde-border));opacity:1}.rde-day--active-month .rde-day__num{color:var(--rde-text)}.rde-day--muted-month{background:transparent;opacity:.42}.rde-day--muted-month .rde-day__num{color:var(--rde-muted)}.rde-day--today{box-shadow:none}.rde-day--today,.rde-day--today.rde-day--active-month{background:transparent;border-color:var(--rde-accent)}.rde-day__num{color:var(--rde-muted);font-size:12px;font-weight:600;transition:color .5s ease}.rde-day--today .rde-day__num{color:var(--rde-accent)}.rde-day__events{display:flex;flex-direction:column;gap:2px;min-height:0}.rde-event{align-items:center;background:color-mix(in srgb,var(--rde-event-color,var(--rde-event-default)) 22%,var(--rde-bg));border:0;border-left:3px solid var(--rde-event-color,var(--rde-event-default));border-radius:5px;color:var(--rde-text);cursor:pointer;display:flex;font-size:11px;gap:4px;line-height:1.2;overflow:hidden;padding:3px 5px;text-align:left;width:100%}.rde-event:hover{filter:brightness(1.08)}.rde-event__time{color:var(--rde-muted);flex-shrink:0;font-variant-numeric:tabular-nums}.rde-event__title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.rde-more{background:transparent;border:0;color:var(--rde-muted);cursor:pointer;font-size:10px;padding:0 2px;text-align:left}.rde-more:hover{color:var(--rde-accent)}.rde-day__compact-events{align-items:center;display:flex;flex-wrap:wrap;gap:3px;justify-content:center;min-height:14px;padding-top:2px}.rde-event-dot{background:var(--rde-event-color,var(--rde-event-default));border:none;border-radius:50%;cursor:pointer;flex-shrink:0;height:7px;padding:0;width:7px}.rde-event-dot:focus-visible,.rde-event-dot:hover{outline:1px solid var(--rde-accent);outline-offset:2px;transform:scale(1.25)}.rde-more-compact{color:var(--rde-muted);font-size:10px;line-height:1;padding-left:1px}.rde[data-compact=true] .rde-week-row{align-items:stretch;gap:2px;overflow:hidden;padding:0 2px}.rde[data-compact=true] .rde-day{border-radius:8px;box-sizing:border-box;gap:2px;height:100%;justify-content:center;min-height:0;padding:3px 2px;width:100%}.rde[data-compact=true] .rde-day__events{align-items:center;display:flex;flex:0 0 auto;justify-content:center;width:100%}.rde[data-compact=true] .rde-day__compact-events{min-height:0;padding-top:0}.rde[data-compact=true] .rde-month .rde-viewport{border-radius:8px}.rde[data-compact=true] .rde-weekday{font-size:11px;padding:2px 0 4px}.rde[data-compact=true] .rde-day__num{font-size:12px;text-align:center}.rde-timegrid--infinite{background:var(--rde-surface);border:1px solid var(--rde-border);border-radius:var(--rde-radius);display:flex;flex-direction:column;height:min(680px,75vh);min-width:0;overflow:hidden;width:100%}.rde-tg-sticky{background:var(--rde-bg);border-bottom:1px solid var(--rde-border);display:grid;flex:0 0 auto;grid-template-columns:var(--rde-rail-w) minmax(0,1fr);z-index:3}.rde-tg-sticky .rde-tg-heads{display:grid;min-width:0}.rde-tg-viewport.rde-viewport{border:0;border-radius:0;flex:1 1 auto;height:auto;min-height:0}.rde-timegrid--x .rde-tg-main{display:flex;flex:1 1 auto;flex-direction:column;min-height:0;min-width:0}.rde-tg-week-top{background:var(--rde-bg);border-bottom:1px solid var(--rde-border);display:grid;flex:0 0 auto;grid-template-columns:var(--rde-rail-w) minmax(0,1fr);z-index:4}.rde-tg-corner-col{border-right:1px solid var(--rde-border)}.rde-tg-corner-col .rde-tg-corner,.rde-tg-corner-spacer{border-bottom:1px solid var(--rde-border)}.rde-tg-heads-viewport{min-width:0;overflow:hidden}.rde-tg-heads-strip{display:flex;flex-direction:row;flex-wrap:nowrap;width:max-content;will-change:transform}.rde-week-head-seg{border-right:1px solid var(--rde-border);flex:0 0 auto;opacity:.42;transition:opacity .5s ease}.rde-week-head-seg.is-active{opacity:1}.rde-week-head-seg .rde-tg-heads{background:var(--rde-bg);border-bottom:1px solid var(--rde-border);display:grid;height:36px;min-width:0;width:100%}.rde-week-head-seg .rde-allday-row{width:100%}.rde-timegrid--x .rde-tg-body-scroll{-webkit-overflow-scrolling:touch;flex:1 1 auto;min-height:0;min-width:0;overflow:hidden auto;overscroll-behavior:contain;touch-action:pan-y}.rde-tg-week-scroll-inner{min-height:100%}.rde-tg-week-grid{display:grid;grid-template-columns:var(--rde-rail-w) minmax(0,1fr);height:100%;min-height:100%}.rde-tg-rail-col{background:var(--rde-bg);border-right:1px solid var(--rde-border)}.rde-tg-rail-col .rde-tg-labels{flex:0 0 auto}.rde-timegrid--x .rde-tg-viewport{border:0;border-radius:0;flex:0 0 auto;height:var(--rde-week-seg-h,100%);min-width:0;touch-action:pan-x pan-y}.rde-strip--x,.rde-strip[data-axis=x]{display:flex;flex-direction:row;flex-wrap:nowrap;height:100%;width:max-content;will-change:transform}.rde-time-seg{background:var(--rde-surface);border-bottom:2px solid color-mix(in srgb,var(--rde-accent) 35%,var(--rde-border));box-sizing:border-box;display:grid;grid-template-columns:52px minmax(0,1fr);overflow:hidden;transition:opacity .5s ease,border-color .5s ease;width:100%}.rde-time-seg:not(.rde-time-seg--x){grid-template-rows:auto minmax(0,1fr)}.rde-time-seg:not(.rde-time-seg--x) .rde-allday-row{grid-column:1/-1;grid-row:1}.rde-time-seg:not(.rde-time-seg--x) .rde-tg-labels{align-self:start;grid-column:1;grid-row:2}.rde-time-seg:not(.rde-time-seg--x) .rde-time-seg__cols{grid-column:2;grid-row:2;min-height:0}.rde-time-seg--x{background:var(--rde-surface);border-bottom:0;border-right:1px solid var(--rde-border);box-shadow:none;display:flex;flex:0 0 auto;flex-direction:column;flex-shrink:0;grid-template-columns:none;min-width:0;opacity:.42;transition:opacity .5s ease,border-color .5s ease}.rde-time-seg--x.is-active{border-right-color:color-mix(in srgb,var(--rde-accent) 55%,var(--rde-border));opacity:1}.rde-time-seg--x .rde-time-seg__cols{flex:1 1 auto;height:100%;min-height:0}.rde-time-seg:not(.rde-time-seg--x):not(.is-active){opacity:.42}.rde-time-seg:not(.rde-time-seg--x).is-active{background:transparent;border-bottom-color:color-mix(in srgb,var(--rde-accent) 70%,var(--rde-border));box-shadow:none;opacity:1}.rde-tg-head{border-right:1px solid var(--rde-border);color:var(--rde-muted);cursor:pointer;font-size:11px;min-width:0;padding:8px 4px;text-align:center;transition:color .5s ease}.rde[data-compact=true] .rde-tg-head{font-size:11px;padding:6px 4px;white-space:nowrap}.rde-time-seg .rde-tg-labels{background:var(--rde-bg);border-right:1px solid var(--rde-border)}.rde-time-seg__cols{display:grid;height:100%;min-width:0;width:100%}.rde-tg-col{background-image:repeating-linear-gradient(to bottom,transparent 0,transparent 47px,color-mix(in srgb,var(--rde-border) 80%,transparent) 47px,color-mix(in srgb,var(--rde-border) 80%,transparent) 48px);border-right:1px solid var(--rde-border);height:100%;min-width:0;position:relative;transition:opacity .5s ease}.rde-tg-col:last-child{border-right:0}.rde-tg-col.is-active,.rde-tg-col.is-active-month{background-color:transparent}.rde-tg-head.is-active,.rde-tg-head.is-active-month{color:var(--rde-text);font-weight:650}.rde-tg-sticky .rde-tg-head{transition:color .5s ease,opacity .5s ease}.rde-timegrid{background:var(--rde-surface);border:1px solid var(--rde-border);border-radius:var(--rde-radius);display:flex;flex-direction:column;min-width:0;overflow:hidden;width:100%}.rde-tg-corner{background:var(--rde-bg);border-right:1px solid var(--rde-border);min-height:36px}.rde-tg-heads{background:var(--rde-bg);min-width:0}.rde-tg-head:last-child{border-right:0}.rde-tg-head.is-today{color:var(--rde-accent);font-weight:700}.rde-tg-labels{background:var(--rde-bg)}.rde-tg-label{align-items:flex-start;border-bottom:1px solid color-mix(in srgb,var(--rde-border) 70%,transparent);color:var(--rde-muted);display:flex;font-size:10px;justify-content:flex-end;padding:2px 6px 0 0}.rde-block{background:color-mix(in srgb,var(--rde-event-color,var(--rde-event-default)) 28%,var(--rde-bg));border:0;border-left:3px solid var(--rde-event-color,var(--rde-event-default));border-radius:6px;box-sizing:border-box;color:var(--rde-text);cursor:pointer;font-size:11px;line-height:1.25;min-width:0;overflow:hidden;padding:4px 6px;position:absolute;text-align:left;z-index:1}.rde-block small,.rde-block__title{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.rde-block small{color:var(--rde-muted);font-size:10px}.rde-block--compact .rde-block__title{font-size:10px}.rde-block:hover{filter:brightness(1.06)}.rde[data-compact=true] .rde-timegrid--infinite{border-radius:8px;height:min(620px,72vh)}.rde[data-compact=true] .rde-allday__chip{font-size:10px;padding:2px 4px}.rde-agenda--scroll .rde-agenda-viewport{-webkit-overflow-scrolling:touch;background:var(--rde-surface);border:1px solid var(--rde-border);border-radius:var(--rde-radius);height:min(640px,70vh);overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain;touch-action:pan-y}.rde-agenda-strip{display:block;width:100%}.rde-agenda-seg{align-items:start;background:var(--rde-surface);border-bottom:1px solid var(--rde-border);box-sizing:border-box;display:grid;gap:8px 16px;grid-template-columns:minmax(120px,168px) minmax(0,1fr);padding:10px 14px 12px;transition:opacity .5s ease;width:100%}.rde-agenda-seg:not(.is-active){opacity:.48}.rde-agenda-seg.is-active{opacity:1}.rde-agenda__day-col{min-width:0;padding-top:2px}.rde-agenda__date{display:flex;flex-direction:column;gap:2px;line-height:1.25;margin:0}.rde-agenda__weekday{color:var(--rde-text);font-size:12px;font-weight:650;text-transform:capitalize}.rde-agenda__date-sep{display:none}.rde-agenda__ymd{color:var(--rde-muted);font-size:11px}.rde-agenda__list{display:flex;flex-direction:column;gap:2px;min-width:0}.rde-agenda__empty{color:var(--rde-muted);font-size:12px;padding:4px 2px}.rde-agenda{display:flex;flex-direction:column;min-width:0}.rde-agenda--empty{color:var(--rde-muted);padding:40px;text-align:center}.rde-agenda__item{align-items:center;background:transparent;border:none;border-left:3px solid var(--rde-event-color,var(--rde-event-default));border-radius:0 4px 4px 0;color:var(--rde-text);cursor:pointer;display:grid;flex-shrink:0;font:inherit;gap:8px 12px;grid-template-columns:88px minmax(0,1fr) auto;margin:0;min-width:0;padding:5px 8px 5px 10px;text-align:left;width:100%}.rde-agenda__item:focus-visible,.rde-agenda__item:hover{background:var(--rde-hover);outline:none}.rde-agenda__time{color:var(--rde-muted);font-size:12px;font-variant-numeric:tabular-nums;white-space:nowrap}.rde-agenda__time--allday{font-size:11px;letter-spacing:.02em;text-transform:uppercase}.rde-agenda__title{font-size:13px;font-weight:600;min-width:0}.rde-agenda__loc,.rde-agenda__title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.rde-agenda__loc{color:var(--rde-muted);font-size:12px;max-width:160px}.rde-agenda__sentinel{height:1px}.rde[data-compact=true] .rde-agenda-seg{box-sizing:border-box;display:flex;flex-direction:column;gap:0;max-width:100%;padding:10px 12px 12px;width:100%}.rde[data-compact=true] .rde-agenda-seg:not(.is-active){opacity:1}.rde[data-compact=true] .rde-agenda__day-col{padding-top:0;width:100%}.rde[data-compact=true] .rde-agenda__date{align-items:baseline;border-bottom:1px solid var(--rde-border);flex-direction:row;flex-wrap:wrap;gap:0;line-height:1.35;margin-bottom:6px;padding-bottom:8px}.rde[data-compact=true] .rde-agenda__date-sep{display:none}.rde[data-compact=true] .rde-agenda__weekday:after{content:",\00a0"}.rde[data-compact=true] .rde-agenda__weekday,.rde[data-compact=true] .rde-agenda__ymd{color:var(--rde-muted);font-size:12px;font-weight:650;text-transform:none}.rde[data-compact=true] .rde-agenda__list{width:100%}.rde[data-compact=true] .rde-agenda__item{align-items:center;background:var(--rde-surface);border:1px solid var(--rde-border);border-left:3px solid var(--rde-event-color,var(--rde-event-default));border-radius:8px;box-sizing:border-box;gap:6px 8px;grid-template-columns:minmax(64px,72px) minmax(0,1fr) auto;grid-template-rows:auto;max-width:100%;padding:8px 10px;width:100%}.rde[data-compact=true] .rde-agenda__time{grid-column:1;grid-row:1;min-width:0;white-space:nowrap}.rde[data-compact=true] .rde-agenda__title{font-size:13px;grid-column:2;grid-row:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.rde[data-compact=true] .rde-agenda__loc{display:block;font-size:11px;grid-column:3;grid-row:1;max-width:88px;overflow:hidden;text-align:right;text-overflow:ellipsis;white-space:nowrap}.rde[data-compact=true] .rde-agenda--scroll .rde-agenda-viewport{border-radius:8px}.rde-allday-row{background:var(--rde-surface);border-bottom:1px solid var(--rde-border);display:grid}.rde-allday-col{border-right:1px solid var(--rde-border);min-width:0;overflow:hidden;padding:2px 4px}.rde-allday-col:last-child{border-right:0}.rde-allday{display:flex;flex-direction:column;gap:2px;height:100%}.rde-allday--empty{min-height:4px}.rde-allday__chip{background:color-mix(in srgb,var(--rde-event-color,var(--rde-event-default)) 18%,var(--rde-surface));border:none;border-left:3px solid var(--rde-event-color,var(--rde-event-default));border-radius:4px;color:var(--rde-text);cursor:pointer;display:block;font-size:11px;font-weight:600;overflow:hidden;padding:2px 6px;text-align:left;text-overflow:ellipsis;white-space:nowrap;width:100%}.rde-allday__chip:hover{filter:brightness(1.08)}.rde-day--disabled{opacity:.42;pointer-events:none}.rde-view[role=tab][aria-selected=true]{background:var(--rde-accent);color:#fff}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function t(){return!1}function e(t){return!1}function s(t){if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new Error("RollDateEvents: invalid Date object");return new Date(t.getTime())}const e=new Date(t);if(Number.isNaN(e.getTime()))throw new Error(`RollDateEvents: invalid date "${t}"`);return e}function i(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function n(t){return new Date(t.getFullYear(),t.getMonth(),1)}function r(t,e){const s=new Date(t);return s.setDate(s.getDate()+e),s}function a(t,e){return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function h(t){return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}function o(t,e){const s=i(t),n=s.getDay();return r(s,-(1===e?(n+6)%7:n))}function l(t,e){return new Intl.DateTimeFormat(e,{hour:"2-digit",minute:"2-digit"}).format(t)}function c(t){return Math.min(23,Math.max(0,Math.floor(t)))}const d=new Set;function u(t,e){"undefined"!=typeof process&&"production"===process.env?.NODE_ENV||d.has(t)||(d.add(t),console.warn(e))}function m(t){if(t.visibleHours){const{start:e,end:s}=t.visibleHours,i=c(e),n=c(s);(i!==e||n!==s||s<=e)&&u("opts-visibleHours",`[RollDateEvents] invalid visibleHours (${JSON.stringify(t.visibleHours)}); expected start < end, hours 0–23.`)}if(t.minDate&&t.maxDate){const n=i(s(t.minDate)),r=(e=s(t.maxDate),new Date(e.getFullYear(),e.getMonth(),e.getDate(),23,59,59,999));n.getTime()>r.getTime()&&u("opts-min-max","[RollDateEvents] minDate is after maxDate; navigation bounds may behave unexpectedly.")}var e}function g(t,e){let i,n;try{i=s(t.start)}catch{u(`ev-start-${String(t.id)}`,`[RollDateEvents] Event "${String(t.id)}" has invalid start date.`),i=new Date}try{n=s(t.end)}catch{u(`ev-end-${String(t.id)}`,`[RollDateEvents] Event "${String(t.id)}" has invalid end date.`),n=new Date(i)}n.getTime()<i.getTime()&&(u(`ev-range-${String(t.id)}`,`[RollDateEvents] Event "${String(t.id)}" has end before start; using start as end.`),n=new Date(i));const r=String(t.id);return e&&(e.has(r)&&u(`ev-dup-${r}`,`[RollDateEvents] duplicate event id "${r}".`),e.add(r)),{...t,start:i,end:n}}class p{constructor(){this.raw=[],this.cached=[],this.byDay=new Map,this.byId=new Map}setEvents(t){this.raw=t.slice(),this.rebuildCache()}getRaw(){return this.raw.slice()}add(t){const e=this.idSet();this.raw.push(t);const s=this.toCached(g(t,e));this.cached.push(s),this.byId.set(String(s.id),s)}update(t,e){const s=String(t),i=this.raw.findIndex(t=>String(t.id)===s);if(-1===i)return!1;const n={...this.raw[i],...e,id:this.raw[i].id};return this.raw[i]=n,this.rebuildCache(),!0}remove(t){const e=this.raw.length;return this.raw=this.raw.filter(e=>String(e.id)!==String(t)),this.raw.length!==e&&(this.rebuildCache(),!0)}idSet(){return new Set(this.raw.map(t=>String(t.id)))}toCached(t){if(!t.recurring)return t;const{recurring:e,...s}=t;return s}rebuildCache(){const t=new Set;let e=!1;this.cached=this.raw.map(s=>(s.recurring&&!e&&(e=!0,u("recurring-lite","[RollDateEvents Lite] recurring events require RollDate Events Pro. Rendering the base occurrence only.")),this.toCached(g(s,t)))),this.byId.clear();for(const t of this.cached)this.byId.set(String(t.id),t)}async prepareRange(t,e){this.byDay.clear();const s=[],i=t.from.getTime(),n=t.to.getTime();for(let t=0;t<this.raw.length;t++){const e=g(this.raw[t]);e.recurring,0;const r=this.cached[t]||this.toCached(e);r.end.getTime()<i||r.start.getTime()>n||this.index(r,s)}return s}prepareRangeSync(t){this.byDay.clear();const e=[],s=t.from.getTime(),i=t.to.getTime();for(const t of this.cached)t.end.getTime()<s||t.start.getTime()>i||this.index(t,e);return e}getById(t){return this.byId.get(t)}forDay(t){return this.byDay.get(h(t))||[]}index(t,e){const s=String(t.occurrenceId||t.id);this.byId.set(s,t),e.push(t);let n=i(t.start);const a=i(t.end);let o=0;for(;n<=a&&o<370;){const e=h(n),s=this.byDay.get(e)||[];s.push(t),this.byDay.set(e,s),n=r(n,1),o++}}}function v(t,e,s){let i=t;return null!=e&&i<e&&(i=e),null!=s&&i>s&&(i=s),i}class y{constructor(t,e,s,i){this.startIndex=0,this.count=0,this.offset=0,this.listening=!1,this.wheelRaf=0,this.settleRaf=0,this.scrollAnimId=0,this.touchDragging=!1,this.touchLast=0,this.touchLastY=0,this.touchLastTime=0,this.touchVelocity=0,this.touchAxisLock=null,this.touchStartX=0,this.touchStartY=0,this.momentumId=0,this.extending=!1,this.onWheel=t=>{t.preventDefault(),t.stopPropagation(),this.cancelScrollAnim();const e="x"===this.axis&&Math.abs(t.deltaX)>Math.abs(t.deltaY);let s,i;s=("y-as-x"===this.wheelMode||"x"===this.axis)&&e?t.deltaX:t.deltaY,s*=.9,i=this.wheelInvert?e?-s:s:e?s:-s,this.nudge(i)},this.onTouchStart=t=>{t.touches&&1===t.touches.length&&(this.cancelMomentum(),this.cancelScrollAnim(),this.touchDragging=!0,this.touchAxisLock=null,this.touchStartX=t.touches[0].clientX,this.touchStartY=t.touches[0].clientY,this.touchLast="x"===this.axis?t.touches[0].clientX:t.touches[0].clientY,this.touchLastY=t.touches[0].clientY,this.touchLastTime=performance.now(),this.touchVelocity=0)},this.onTouchMove=t=>{if(!this.touchDragging||!t.touches||1!==t.touches.length)return;const e=t.touches[0].clientX,s=t.touches[0].clientY;if("x"===this.axis&&null===this.touchAxisLock){const t=Math.abs(e-this.touchStartX),i=Math.abs(s-this.touchStartY);if(!(t>8||i>8))return;this.touchAxisLock=t>=1.2*i?"x":"y"}if("x"===this.axis&&"y"===this.touchAxisLock)return;t.preventDefault();const i="x"===this.axis?e:s,n=i-this.touchLast,r=performance.now(),a=r-this.touchLastTime;a>0&&a<120&&(this.touchVelocity=.65*this.touchVelocity+n/a*.35),this.touchLast=i,this.touchLastY=s,this.touchLastTime=r,Math.abs(n)<1||this.nudge(n)},this.onTouchEnd=()=>{const t="x"===this.axis&&"y"===this.touchAxisLock;if(this.touchDragging=!1,this.touchAxisLock=null,t)return;const e=16*this.touchVelocity;if(Math.abs(e)<.4)return;let s=e;const i=()=>{Math.abs(s)<.35?this.momentumId=0:(this.nudge(s),s*=.92,this.momentumId=requestAnimationFrame(i))};this.momentumId=requestAnimationFrame(i)},this.viewport=t,this.strip=e,this.segmentSize=Math.max(1,s.segmentSize),this.bufferSize=Math.max(4,s.bufferSize),this.prefetch=s.prefetchSegments??2,this.axis=s.axis??"y",this.wheelMode=s.wheelMode??"natural",this.wheelInvert=!0===s.wheelInvert,this.wheelEnabled=!1!==s.wheelEnabled,this.syncTransformEl=s.syncTransformEl,this.minIndex=s.minIndex,this.maxIndex=s.maxIndex,this.handlers=i,this.strip.dataset.axis=this.axis}get state(){return{startIndex:this.startIndex,count:this.count,segmentSize:this.segmentSize,offset:this.offset,axis:this.axis}}setSegmentSize(t){const e=Math.max(1,Math.round(t));if(e===this.segmentSize)return;const s=this.dominantIndex()-this.startIndex;this.segmentSize=e,this.offset=-s*this.segmentSize,this.apply(),this.handlers.onSegmentSize?this.handlers.onSegmentSize(e):this.handlers.paint(this.startIndex,this.count)}reset(t,e={}){this.cancelMomentum(),this.cancelScrollAnim(),this.cancelSettle(),t=v(t,this.minIndex,this.maxIndex);const s=Math.floor(this.bufferSize/2);this.startIndex=t-s,this.count=this.bufferSize;const i=s;if("start"===(e.align??"start"))this.offset=-i*this.segmentSize;else{const t=this.viewSize();this.offset=-i*this.segmentSize+Math.min(.12*t,.25*this.segmentSize)}this.handlers.paint(this.startIndex,this.count),this.apply(),this.handlers.onRangeChange(this.startIndex,this.count),this.handlers.onSettle(t),requestAnimationFrame(()=>this.maybeExtend())}scrollToIndex(t,e={}){this.cancelMomentum(),this.cancelScrollAnim(),this.cancelSettle(),t=v(t,this.minIndex,this.maxIndex);const s=e.align??"start",i=t-this.startIndex;if(i<0||i>=this.count)return void this.reset(t,{align:s});const n=this.offsetForIndex(t,s);if(!(!0===e.animate&&Math.abs(this.offset-n)>1))return this.offset=n,this.apply(),this.maybeExtend(),void this.handlers.onSettle(t);const r=this.offset,a=performance.now(),h=e=>{const s=Math.min(1,(e-a)/320),i=1-(1-s)**3;this.offset=r+(n-r)*i,this.apply(),s<1?this.scrollAnimId=requestAnimationFrame(h):(this.scrollAnimId=0,this.maybeExtend(),this.handlers.onSettle(t))};this.scrollAnimId=requestAnimationFrame(h)}start(){this.listening||(this.listening=!0,this.wheelEnabled&&this.viewport.addEventListener("wheel",this.onWheel,{passive:!1}),this.viewport.addEventListener("touchstart",this.onTouchStart,{passive:!0}),this.viewport.addEventListener("touchmove",this.onTouchMove,{passive:!1}),this.viewport.addEventListener("touchend",this.onTouchEnd,{passive:!0}),this.viewport.addEventListener("touchcancel",this.onTouchEnd,{passive:!0}))}stop(){this.listening=!1,this.cancelMomentum(),this.cancelScrollAnim(),this.cancelSettle(),cancelAnimationFrame(this.wheelRaf),this.wheelEnabled&&this.viewport.removeEventListener("wheel",this.onWheel),this.viewport.removeEventListener("touchstart",this.onTouchStart),this.viewport.removeEventListener("touchmove",this.onTouchMove),this.viewport.removeEventListener("touchend",this.onTouchEnd),this.viewport.removeEventListener("touchcancel",this.onTouchEnd)}nudgeBy(t){this.nudge(t)}refreshBuffer(){this.maybeExtend()}dominantIndex(){const t=this.viewSize(),e=-this.offset+t/2,s=Math.floor(e/this.segmentSize);return this.startIndex+Math.max(0,Math.min(this.count-1,s))}viewSize(){return"x"===this.axis?this.viewport.clientWidth||this.segmentSize:this.viewport.clientHeight||this.segmentSize}offsetForIndex(t,e){const s=t-this.startIndex;if("start"===e)return-s*this.segmentSize;const i=this.viewSize();return-s*this.segmentSize+Math.min(.12*i,.25*this.segmentSize)}cancelSettle(){this.settleRaf&&(cancelAnimationFrame(this.settleRaf),this.settleRaf=0)}cancelScrollAnim(){this.scrollAnimId&&(cancelAnimationFrame(this.scrollAnimId),this.scrollAnimId=0)}apply(){const t="x"===this.axis?`translate3d(${this.offset}px, 0, 0)`:`translate3d(0, ${this.offset}px, 0)`;this.strip.style.transform=t,this.syncTransformEl&&(this.syncTransformEl.style.transform=t)}scheduleSettle(){this.cancelSettle(),this.settleRaf=requestAnimationFrame(()=>{this.settleRaf=0,this.maybeExtend(),this.handlers.onSettle(this.dominantIndex())})}nudge(t){this.offset+=t,this.apply(),this.scheduleSettle()}cancelMomentum(){this.momentumId&&(cancelAnimationFrame(this.momentumId),this.momentumId=0)}canMutate(){const t=this.handlers;return!!(t.insertStart&&t.insertEnd&&t.removeStart&&t.removeEnd)}maybeExtend(){if(this.extending)return;const t=this.viewSize(),e=-this.offset,s=e+t,i=e/this.segmentSize,n=s/this.segmentSize,r=this.canMutate(),a=this.bufferSize+Math.max(4,2*this.prefetch);if(i<.35){if(null!=this.minIndex&&this.startIndex<=this.minIndex)return;const t=Math.min(4,Math.max(2,Math.ceil(this.bufferSize/3)));if(this.extending=!0,this.startIndex-=t,this.count+=t,this.offset-=t*this.segmentSize,r&&this.handlers.insertStart(this.startIndex,t),this.count>a){const t=this.count-this.bufferSize;this.count-=t,r&&this.handlers.removeEnd(t)}return r||this.handlers.paint(this.startIndex,this.count),this.apply(),this.extending=!1,void this.handlers.onRangeChange(this.startIndex,this.count)}if(n>this.count-.35){if(null!=this.maxIndex&&this.startIndex+this.count-1>=this.maxIndex)return;const t=Math.min(4,Math.max(2,Math.ceil(this.bufferSize/3)));this.extending=!0;const e=this.startIndex+this.count;if(this.count+=t,r&&this.handlers.insertEnd(e,t),this.count>a){const t=this.count-this.bufferSize;this.startIndex+=t,this.count-=t,this.offset+=t*this.segmentSize,r&&this.handlers.removeStart(t)}r||this.handlers.paint(this.startIndex,this.count),this.apply(),this.extending=!1,this.handlers.onRangeChange(this.startIndex,this.count)}}}function f(t,e){const s=1===e?new Date(1970,0,5):new Date(1970,0,4),i=o(t,e);return Math.round((i.getTime()-s.getTime())/864e5/7)}function x(t,e){const s=1===e?new Date(1970,0,5):new Date(1970,0,4),i=new Date(s);return i.setDate(s.getDate()+7*t),i}function w(t){const e=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()),s=Date.UTC(1970,0,1);return Math.floor((e-s)/864e5)}function E(t){const e=new Date(1970,0,1);return e.setDate(e.getDate()+t),e}function b(t){return t>0&&t<=640}const S=Math.floor(8);function D(t){const e=Math.max(7,Math.round(t)-16);return Math.floor(e/7)}function M(t,e){const s=Math.max(1,Math.round(t));if(!e){const t=Math.max(280,s);return{segW:t,dayWidth:t/7}}const i=function(t){const e=Math.max(1,Math.round(t)),s=Math.round(e/2.85);return Math.max(110,Math.min(140,s))}(s);return{segW:7*i,dayWidth:i}}function k(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function I(t){return k(t).replace(/'/g,"'")}class ${constructor(){this.name="month",this.host=null,this.monthEl=null,this.stripEl=null,this.ctx=null,this.scroller=null,this.byDay=new Map,this.anchorMonth=-1,this.anchorYear=-1,this.eventsFp="",this.onClick=t=>{if(!this.ctx)return;const e=t.target,s=e.closest("[data-event-id]");if(s?.dataset.eventId){const e=this.ctx.getEvent(s.dataset.eventId);return void(e&&(t.stopPropagation(),this.ctx.onEventClick(e,t)))}const i=e.closest(".rde-more");if(i?.dataset.day){const[e,s,n]=i.dataset.day.split("-").map(Number),r=new Date(e,s-1,n);if(this.ctx.isDateDisabled(r))return;return void this.ctx.onDateClick(r,t)}const n=e.closest("[data-day]");if(n?.dataset.day){const[e,s,i]=n.dataset.day.split("-").map(Number),r=new Date(e,s-1,i);if(this.ctx.isDateDisabled(r))return;this.ctx.onDateClick(r,t)}}}render(t){this.destroy(),this.ctx=t,this.host=t.root,this.indexEvents(t.events),this.eventsFp=this.fingerprint(t.events),this.anchorYear=t.cursor.getFullYear(),this.anchorMonth=t.cursor.getMonth();const e=function(t,e){const s=new Intl.DateTimeFormat(t,{weekday:"short"}),i=new Date(2024,0,7),n=[];for(let t=0;t<7;t++){const a=1===e?t+1:t;n.push(s.format(r(i,a%7)))}return n}(t.locale,t.firstDayOfWeek);this.host.innerHTML=`\n <div class="rde-month rde-month--infinite">\n <div class="rde-weekdays">${e.map(t=>`<div class="rde-weekday">${k(t)}</div>`).join("")}</div>\n <div class="rde-viewport" data-viewport>\n <div class="rde-strip" data-strip></div>\n </div>\n </div>\n `,this.monthEl=this.host.querySelector(".rde-month");const s=this.host.querySelector("[data-viewport]");this.stripEl=this.host.querySelector("[data-strip]"),this.scroller=new y(s,this.stripEl,{segmentSize:this.weekRowPx(),bufferSize:16,prefetchSegments:2,minIndex:t.minWeekIndex,maxIndex:t.maxWeekIndex},{paint:(t,e)=>this.paint(t,e),onSettle:t=>this.onSettle(t),onRangeChange:(t,e)=>this.emitRange(t,e),insertStart:(t,e)=>this.insertRows(t,e,"start"),insertEnd:(t,e)=>this.insertRows(t,e,"end"),removeStart:t=>this.removeRows(t,"start"),removeEnd:t=>this.removeRows(t,"end")});const i=this.monthAnchorWeekIndex();this.scroller.reset(i,{align:"start"}),this.scroller.start(),this.applyMonthHighlight(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.syncWeekRowSegmentSize(!0))}),this.host.addEventListener("click",this.onClick)}applyLayout(t){if(!this.ctx||!this.scroller||!this.stripEl)return;const e=this.ctx.compact;this.ctx={...this.ctx,compact:t.compact,layoutWidth:t.layoutWidth};const s=this.weekRowPx(),i=this.scroller.state.segmentSize;Math.abs(s-i)>=1&&(this.scroller.setSegmentSize(s),this.stripEl.querySelectorAll(".rde-week-row").forEach(t=>{t.style.height=`${s}px`})),requestAnimationFrame(()=>this.syncWeekRowSegmentSize(!1)),e!==t.compact&&this.refreshDayEvents()}syncEvents(t){this.indexEvents(t);const e=this.fingerprint(t);e!==this.eventsFp&&(this.eventsFp=e,this.refreshDayEvents())}goToDate(t,e){if(!this.scroller||!this.ctx)return;const s=this.ctx.firstDayOfWeek,i=n(t),a=f(i,s);this.anchorYear=i.getFullYear(),this.anchorMonth=i.getMonth();const h=x(a-4,s),o=r(x(a+8,s),6);this.ctx.onRangeChange({from:h,to:o}),this.scroller.scrollToIndex(a,{animate:!0===e?.animate,align:"start"}),this.applyMonthHighlight()}destroy(){this.scroller?.stop(),this.scroller=null,this.host?.removeEventListener("click",this.onClick),this.host&&(this.host.innerHTML=""),this.host=null,this.monthEl=null,this.stripEl=null,this.ctx=null}weekRowPx(){const t=!0===this.ctx?.compact,e=this.monthEl?.querySelector("[data-viewport]"),s=e?.clientWidth??0;return function(t,e=0){return t?D(e>0?e:375):108}(t,s>0?s:this.ctx?.layoutWidth??0)}monthAnchorWeekIndex(){return this.ctx?f(n(this.ctx.cursor),this.ctx.firstDayOfWeek):0}syncWeekRowSegmentSize(t=!1){if(!this.scroller||!this.stripEl)return;const e=this.stripEl.querySelector(".rde-week-row");if(!e)return;const s=Math.round(e.getBoundingClientRect().height),i=this.weekRowPx(),n=s>0?s:i;if(n<=0)return;this.stripEl.querySelectorAll(".rde-week-row").forEach(t=>{t.style.height=`${n}px`});Math.abs(n-this.scroller.state.segmentSize)>=1&&this.scroller.setSegmentSize(n),t&&(this.scroller.scrollToIndex(this.monthAnchorWeekIndex(),{align:"start"}),this.applyMonthHighlight()),this.scroller.refreshBuffer()}fingerprint(t){if(!t.length)return"0";const e=t[0],s=t[t.length-1],i=t[t.length>>1];return`${t.length}:${String(e.id)}:${String(i.id)}:${String(s.id)}:${e.start.getTime()}:${s.end.getTime()}`}indexEvents(t){this.byDay=new Map;for(const e of t){let t=new Date(e.start.getFullYear(),e.start.getMonth(),e.start.getDate());const s=new Date(e.end.getFullYear(),e.end.getMonth(),e.end.getDate());let i=0;for(;t<=s&&i<60;){const s=h(t),n=this.byDay.get(s)||[];n.push(e),this.byDay.set(s,n),t=r(t,1),i++}}for(const t of this.byDay.values())t.sort((t,e)=>t.start.getTime()-e.start.getTime())}dayEventsHtml(t){return this.ctx?.compact?this.dayCompactHtml(t):this.dayChipsHtml(t)}dayCompactHtml(t){if(!this.ctx)return"";const e=this.byDay.get(t)||[],{dots:s,more:i}=function(t,e=3){const s=Math.max(0,t),i=Math.min(s,e);return{dots:i,more:Math.max(0,s-i)}}(e.length);return`<div class="rde-day__compact-events" aria-hidden="false">${e.slice(0,s).map(t=>{const e=t.color||"var(--rde-event-default)";return`<button type="button" class="rde-event-dot" data-event-id="${I(String(t.occurrenceId||t.id))}" style="--rde-event-color:${I(e)}" aria-label="${I(t.title)}" title="${I(t.title)}"></button>`}).join("")}${i>0?`<span class="rde-more-compact">+${i}</span>`:""}</div>`}dayChipsHtml(t){if(!this.ctx)return"";const e=this.ctx.eventLimit,s=this.ctx.locale,i=this.byDay.get(t)||[],n=i.slice(0,e),r=i.length-n.length;return n.map(t=>{const e=t.color||"var(--rde-event-default)",i=String(t.occurrenceId||t.id),n=t.allDay?"":`<span class="rde-event__time">${k(l(t.start,s))}</span>`;return`<button type="button" class="rde-event" data-event-id="${I(i)}" style="--rde-event-color:${I(e)}" title="${I(t.title)}">${n}<span class="rde-event__title">${k(t.title)}</span></button>`}).join("")+(r>0?`<button type="button" class="rde-more" data-day="${t}">+${r} more</button>`:"")}refreshDayEvents(){this.stripEl&&this.stripEl.querySelectorAll(".rde-day[data-day]").forEach(t=>{const e=t.dataset.day;if(!e)return;const s=t.querySelector(".rde-day__events");s&&(s.innerHTML=this.dayEventsHtml(e))})}fillEmptyDayEvents(){this.stripEl&&this.stripEl.querySelectorAll(".rde-day[data-day]").forEach(t=>{const e=t.dataset.day;if(!e)return;const s=t.querySelector(".rde-day__events");!s||s.childElementCount>0||(s.innerHTML=this.dayEventsHtml(e))})}weekRowHtml(t){if(!this.ctx)return"";const e=new Date,s=this.anchorYear,i=this.anchorMonth,n=x(t,this.ctx.firstDayOfWeek),o=[`<div class="rde-week-row" data-week="${t}" style="height:${this.weekRowPx()}px">`];for(let t=0;t<7;t++){const l=r(n,t),c=h(l),d=s>=0&&l.getFullYear()===s&&l.getMonth()===i,u=a(l,e);o.push(`<div class="rde-day${d?" rde-day--active-month":" rde-day--muted-month"}${u?" rde-day--today":""}${this.ctx?.isDateDisabled(l)?" rde-day--disabled":""}" data-day="${c}"><div class="rde-day__num">${l.getDate()}</div><div class="rde-day__events">${this.dayEventsHtml(c)}</div></div>`)}return o.push("</div>"),o.join("")}paint(t,e){if(!this.stripEl||!this.ctx)return;const s=[];for(let i=0;i<e;i++)s.push(this.weekRowHtml(t+i));this.stripEl.innerHTML=s.join("")}insertRows(t,e,s){if(!this.stripEl||e<=0)return;const i=Array.from({length:e},(e,s)=>this.weekRowHtml(t+s)).join("");"start"===s?this.stripEl.insertAdjacentHTML("afterbegin",i):this.stripEl.insertAdjacentHTML("beforeend",i)}removeRows(t,e){if(this.stripEl&&!(t<=0))for(let s=0;s<t;s++){const t="start"===e?this.stripEl.firstElementChild:this.stripEl.lastElementChild;t?.remove()}}applyMonthHighlight(){if(!this.stripEl||this.anchorYear<0)return;const t=this.anchorYear,e=this.anchorMonth;this.stripEl.querySelectorAll(".rde-day[data-day]").forEach(s=>{const i=s.dataset.day;if(!i)return;const[n,r]=i.split("-").map(Number),a=n===t&&r-1===e;s.classList.toggle("rde-day--active-month",a),s.classList.toggle("rde-day--muted-month",!a)})}onSettle(t){if(!this.scroller||!this.ctx)return;const e=function(t){for(let e=0;e<7;e++){const s=r(t,e);if(1===s.getDate())return n(s)}return n(r(t,3))}(x(t,this.ctx.firstDayOfWeek)),s=e.getFullYear(),i=e.getMonth();(s!==this.anchorYear||i!==this.anchorMonth)&&(this.anchorYear=s,this.anchorMonth=i,this.ctx.onAnchorChange(e),this.applyMonthHighlight()),this.emitVisibleMonthRange(e)}emitVisibleMonthRange(t){if(!this.ctx)return;const e=n(t),s=r(e,-42),i=r(e,74);this.ctx.onRangeChange({from:s,to:i})}emitRange(t,e){if(!this.ctx)return;const s=x(t,this.ctx.firstDayOfWeek),i=r(x(t+e-1,this.ctx.firstDayOfWeek),6);this.ctx.onRangeChange({from:s,to:i})}}function R(t,e,s,i){const n=new Date(e.getFullYear(),e.getMonth(),e.getDate(),s,0,0,0),r=new Date(e.getFullYear(),e.getMonth(),e.getDate(),i,0,0,0);return function(t){if(!t.length)return[];const e=[];let s=[],i=0;for(const n of t)!s.length||n.top>=i-.5?(s.length&&e.push(s),s=[n],i=n.top+n.height):(s.push(n),i=Math.max(i,n.top+n.height));s.length&&e.push(s);const n=[];for(const t of e)n.push(...T(t));return n}(t.filter(t=>t.start<r&&t.end>n&&!t.allDay).map(t=>{const e=t.start<n?n:t.start,i=t.end>r?r:t.end;return{event:t,top:48*(e.getHours()+e.getMinutes()/60-s),height:Math.max(18,(i.getTime()-e.getTime())/36e5*48),endMs:i.getTime()}}).sort((t,e)=>t.top-e.top||e.height-t.height))}function T(t){const e=[],s=[];for(const i of t){let t=e.findIndex(t=>t<=i.top+.5);-1===t?(t=e.length,e.push(i.top+i.height)):e[t]=i.top+i.height,s.push({event:i.event,dayIndex:0,top:i.top,height:i.height,col:t,colCount:1})}const i=Math.max(1,...s.map(t=>t.col+1));for(const t of s)t.colCount=i;return s}function H(t){const{start:e,end:s}=t.visibleHours,i=[];for(let t=e;t<s;t++)i.push(`<div class="rde-tg-label" style="height:48px">${String(t).padStart(2,"0")}:00</div>`);return`<div class="rde-tg-labels">${i.join("")}</div>`}function A(t,e,s){return e&&s>0?`repeat(${t}, ${Math.round(s)}px)`:`repeat(${t}, minmax(0, 1fr))`}function W(t,e,s,i){const n=new Date;return`<div class="rde-tg-heads" style="grid-template-columns:${A(t.length,e.compact,i)}">${t.map(t=>{const i=new Intl.DateTimeFormat(e.locale,{weekday:"short",day:"numeric",..."day"===s?{month:"short"}:{}}).format(t);return`<div class="rde-tg-head${a(t,n)?" is-today":""}" data-day="${h(t)}">${k(i)}</div>`}).join("")}</div>`}function L(t,e,s,i){const{start:n,end:r}=s.visibleHours,a=R(function(t,e){return t.get(h(e))||[]}(t,e),e,n,r),o=s.compact,c=function(t,e){return e?Math.max(1,Math.floor(t/52)):12}(i,o),d=!o||i>=100;return a.map(t=>{const e=String(t.event.occurrenceId||t.event.id),i=t.event.color||"var(--rde-event-default)";let n=t.col,r=t.colCount;o&&r>c&&(r=c,n=Math.min(n,c-1));const a=100/r,h=n*a,u=l(t.event.start,s.locale),m=d&&t.height>=26?`<small>${k(u)}${t.event.location?" · "+k(t.event.location):""}</small>`:"";return`<button type="button" class="rde-block${t.height<22?" rde-block--compact":""}" data-event-id="${I(e)}" style="--rde-event-color:${I(i)};top:${t.top}px;height:${t.height}px;left:calc(${h}% + 2px);width:calc(${a}% - 4px)" title="${I(t.event.title)}"><span class="rde-block__title">${k(t.event.title)}</span>${m}</button>`}).join("")}class C{constructor(t){this.host=null,this.headsEl=null,this.stripEl=null,this.headsStripEl=null,this.viewportEl=null,this.ctx=null,this.scroller=null,this.events=[],this.byDay=new Map,this.lastAnchorKey="",this.activeIndex=null,this.hoursH=0,this.segH=0,this.segW=0,this.dayWidth=0,this.allDayH=0,this.cols=1,this.resizeObs=null,this.eventsFp="",this.timeScrollEl=null,this.onWeekHostWheel=t=>{if("week"!==this.mode||!this.scroller)return;t.preventDefault(),t.stopPropagation();const e=Math.abs(t.deltaX)>Math.abs(t.deltaY),s=.9*(e?t.deltaX:t.deltaY),i=e?-s:s;this.scroller.nudgeBy(i)},this.onClick=t=>{if(!this.ctx)return;const e=t.target,s=e.closest("[data-event-id]");if(s?.dataset.eventId){const e=this.ctx.getEvent(s.dataset.eventId);return void(e&&(t.stopPropagation(),this.ctx.onEventClick(e,t)))}const i=e.closest("[data-day]");if(i?.dataset.day){const[e,s,n]=i.dataset.day.split("-").map(Number),r=new Date(e,s-1,n);if(this.ctx.isDateDisabled(r))return;this.ctx.onDateClick(r,t)}},this.mode=t}mount(t){this.destroy(),this.ctx=t,this.host=t.root,this.events=t.events,this.indexEvents(t.events),this.eventsFp=this.fingerprint(t.events),this.hoursH=function(t){const{start:e,end:s}=t.visibleHours;return 48*Math.max(1,s-e)}(t),this.cols="week"===this.mode?7:1;const e="week"===this.mode,s=this.hasAllDayEvents();this.allDayH=s?32:0,this.segH=e?this.hoursH:this.hoursH+this.allDayH,this.host.innerHTML=e?`\n <div class="rde-timegrid rde-timegrid--infinite rde-timegrid--week rde-timegrid--x" style="--rde-week-seg-h:${this.segH}px">\n <div class="rde-tg-main">\n <div class="rde-tg-week-top">\n <div class="rde-tg-corner-col">\n <div class="rde-tg-corner" style="height:36px"></div>\n ${this.allDayH?`<div class="rde-tg-corner-spacer" style="height:${this.allDayH}px"></div>`:""}\n </div>\n <div class="rde-tg-heads-viewport">\n <div class="rde-tg-heads-strip" data-heads-strip></div>\n </div>\n </div>\n <div class="rde-tg-body-scroll" data-time-scroll>\n <div class="rde-tg-week-scroll-inner" style="height:${this.segH}px">\n <div class="rde-tg-week-grid">\n <div class="rde-tg-rail-col">\n ${H(t)}\n </div>\n <div class="rde-viewport rde-tg-viewport" data-viewport style="height:${this.segH}px">\n <div class="rde-strip rde-strip--x" data-strip></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n `:'\n <div class="rde-timegrid rde-timegrid--infinite rde-timegrid--day">\n <div class="rde-tg-sticky">\n <div class="rde-tg-corner"></div>\n <div class="rde-tg-heads" data-heads></div>\n </div>\n <div class="rde-viewport rde-tg-viewport" data-viewport>\n <div class="rde-strip" data-strip></div>\n </div>\n </div>\n ',this.headsEl=this.host.querySelector("[data-heads]"),this.headsEl&&(this.dayWidth=this.calcDayWidth(),this.headsEl.style.gridTemplateColumns=A(this.cols,t.compact,this.dayWidth)),this.stripEl=this.host.querySelector("[data-strip]"),this.headsStripEl=e?this.host.querySelector("[data-heads-strip]"):null,this.viewportEl=this.host.querySelector("[data-viewport]"),e&&(this.timeScrollEl=this.host.querySelector("[data-time-scroll]"),this.host.addEventListener("wheel",this.onWeekHostWheel,{passive:!1,capture:!0})),this.updateWeekMetrics();const i=e?{axis:"x",wheelMode:"y-as-x",wheelInvert:!0,wheelEnabled:!1,segmentSize:this.segW,bufferSize:12,prefetchSegments:2,minIndex:t.minWeekIndex,maxIndex:t.maxWeekIndex,syncTransformEl:this.headsStripEl??void 0}:{axis:"y",segmentSize:this.segH,bufferSize:12,prefetchSegments:2,minIndex:t.minDayIndex,maxIndex:t.maxDayIndex};this.scroller=new y(this.viewportEl,this.stripEl,i,{paint:(t,e)=>this.paint(t,e),onSettle:t=>this.onSettle(t),onRangeChange:(t,e)=>this.emitRange(t,e),insertStart:(t,e)=>this.insertSegments(t,e,"start"),insertEnd:(t,e)=>this.insertSegments(t,e,"end"),removeStart:t=>this.removeSegments(t,"start"),removeEnd:t=>this.removeSegments(t,"end"),onSegmentSize:t=>this.applySegmentWidth(t)});const n=e?f(t.cursor,t.firstDayOfWeek):w(t.cursor);this.activeIndex=n,this.scroller.reset(n,{align:"start"}),this.scroller.start(),"day"===this.mode?requestAnimationFrame(()=>{this.syncActiveHighlight(),this.syncDaySegmentHeight()}):requestAnimationFrame(()=>this.syncActiveHighlight()),e&&"undefined"!=typeof ResizeObserver&&(this.resizeObs=new ResizeObserver(()=>{this.onViewportResize()}),this.resizeObs.observe(this.viewportEl)),this.host.addEventListener("click",this.onClick)}applyLayout(t){if(!this.ctx||!this.scroller)return;const e=this.ctx.compact;if(this.ctx={...this.ctx,compact:t.compact,layoutWidth:t.layoutWidth},"week"===this.mode){const s=this.segW;this.updateWeekMetrics(),(Math.abs(this.segW-s)>=2||e!==t.compact)&&(this.scroller.setSegmentSize(this.segW),this.repaintVisible())}else e!==t.compact&&this.repaintVisible()}syncEvents(t){this.events=t,this.indexEvents(t);const e=this.fingerprint(t);e!==this.eventsFp&&(this.eventsFp=e,this.fillEmptyDayBlocks())}fingerprint(t){if(!t.length)return"0";const e=t[0],s=t[t.length-1],i=t[t.length>>1];return`${t.length}:${String(e.id)}:${String(i.id)}:${String(s.id)}:${e.start.getTime()}:${s.end.getTime()}`}indexEvents(t){this.byDay=new Map;for(const e of t){let t=new Date(e.start.getFullYear(),e.start.getMonth(),e.start.getDate());const s=new Date(e.end.getFullYear(),e.end.getMonth(),e.end.getDate());let i=0;for(;t<=s&&i<60;){const s=h(t),n=this.byDay.get(s)||[];n.push(e),this.byDay.set(s,n),t=r(t,1),i++}}}goToDate(t){if(!this.scroller||!this.ctx)return;const e="week"===this.mode?f(t,this.ctx.firstDayOfWeek):w(t);this.activeIndex=e,this.lastAnchorKey="",this.scroller.reset(e,{align:"start"})}destroy(){this.resizeObs?.disconnect(),this.resizeObs=null,this.host?.removeEventListener("wheel",this.onWeekHostWheel,{capture:!0}),this.scroller?.stop(),this.scroller=null,this.host?.removeEventListener("click",this.onClick),this.host&&(this.host.innerHTML=""),this.host=null,this.headsEl=null,this.stripEl=null,this.headsStripEl=null,this.viewportEl=null,this.timeScrollEl=null,this.ctx=null,this.activeIndex=null}calcDayWidth(){return this.viewportEl&&this.ctx?"week"!==this.mode?Math.max(280,this.viewportEl.clientWidth||800):M(this.viewportEl.clientWidth,this.ctx.compact).dayWidth:120}updateWeekMetrics(){if(!this.viewportEl||!this.ctx||"week"!==this.mode)return;const t=this.ctx.compact?46:52,e=this.viewportEl.clientWidth||Math.max(280,(this.ctx.layoutWidth||800)-t),{segW:s,dayWidth:i}=M(e,this.ctx.compact);this.segW=s,this.dayWidth=i}onViewportResize(){if(!this.viewportEl||!this.scroller||!this.ctx||"week"!==this.mode)return;const t=this.segW;this.updateWeekMetrics(),Math.abs(this.segW-t)<2||(this.scroller.setSegmentSize(this.segW),this.ctx.compact?this.repaintVisible():this.applySegmentWidth(this.segW))}syncDaySegmentHeight(){if(!this.scroller||!this.stripEl||"day"!==this.mode)return;const t=this.stripEl.querySelector(".rde-time-seg");if(!t)return;const e=t.offsetHeight;e>0&&Math.abs(e-this.segH)>=2&&(this.segH=e,this.scroller.setSegmentSize(e))}repaintVisible(){if(!this.scroller||!this.stripEl)return;const{startIndex:t,count:e}=this.scroller.state;this.paint(t,e),"day"===this.mode&&requestAnimationFrame(()=>this.syncDaySegmentHeight())}hasAllDayEvents(){return this.events.some(t=>t.allDay)}allDayRowHtml(t){if(!this.ctx||!this.allDayH)return"";const e=A(t.length,this.ctx.compact,this.dayWidth),s=t.map(t=>{const e=function(t,e){const s=h(e);return t.filter(t=>!!t.allDay&&s>=h(t.start)&&s<=h(t.end))}(this.events,t);return`<div class="rde-allday-col" data-day="${h(t)}">${s=e,this.ctx.locale,s.length?`<div class="rde-allday">${s.map(t=>{const e=String(t.occurrenceId||t.id),s=t.color||"var(--rde-event-default)";return`<button type="button" class="rde-allday__chip" data-event-id="${I(e)}" style="--rde-event-color:${I(s)}" title="${I(t.title)}">${k(t.title)}</button>`}).join("")}</div>`:'<div class="rde-allday rde-allday--empty"></div>'}</div>`;var s}).join("");return`<div class="rde-allday-row" style="height:${this.allDayH}px;grid-template-columns:${e}">${s}</div>`}segmentDates(t){if(!this.ctx)return[];if("week"===this.mode){const e=x(t,this.ctx.firstDayOfWeek);return Array.from({length:7},(t,s)=>r(e,s))}return[E(t)]}headSegmentHtml(t){if(!this.ctx)return"";const e=this.segmentDates(t),s=[`<div class="rde-week-head-seg${null!==this.activeIndex&&t===this.activeIndex?" is-active":""}" data-seg="${t}" style="${`width:${this.segW}px;min-width:${this.segW}px;max-width:${this.segW}px`}">`,W(e,this.ctx,this.mode,this.dayWidth)];return this.allDayH&&s.push(this.allDayRowHtml(e)),s.push("</div>"),s.join("")}segmentHtml(t,e){if(!this.ctx)return"";const s="week"===this.mode,i=this.segmentDates(t),n=this.activeIndex,r=null!==n&&t===n,a=A(this.cols,this.ctx.compact&&s,this.dayWidth),o=[`<div class="rde-time-seg${s?" rde-time-seg--x":""}${r?" is-active":""}" data-seg="${t}" style="${s?`width:${this.segW}px;min-width:${this.segW}px;max-width:${this.segW}px;height:${this.segH}px`:`height:${this.segH}px`}">`];s||(this.allDayH&&o.push(this.allDayRowHtml(i)),o.push(H(this.ctx))),o.push(`<div class="rde-time-seg__cols" style="height:${this.hoursH}px;grid-template-columns:${a}">`);for(const t of i){const i=h(t),n=e?L(this.byDay,t,this.ctx,this.dayWidth):"";o.push(`<div class="rde-tg-col${!s&&r?" is-active":""}" data-day="${i}">${n}</div>`)}return o.push("</div></div>"),o.join("")}paint(t,e){if(!this.stripEl||!this.ctx)return;const s=[];for(let i=0;i<e;i++)s.push(this.segmentHtml(t+i,!0));if(this.stripEl.innerHTML=s.join(""),"week"===this.mode&&this.headsStripEl){const s=[];for(let i=0;i<e;i++)s.push(this.headSegmentHtml(t+i));this.headsStripEl.innerHTML=s.join("")}this.syncActiveHighlight()}insertSegments(t,e,s){if(!this.stripEl||e<=0)return;const i=Array.from({length:e},(e,s)=>this.segmentHtml(t+s,!0)).join("");if("start"===s?this.stripEl.insertAdjacentHTML("afterbegin",i):this.stripEl.insertAdjacentHTML("beforeend",i),"week"===this.mode&&this.headsStripEl){const i=Array.from({length:e},(e,s)=>this.headSegmentHtml(t+s)).join("");"start"===s?this.headsStripEl.insertAdjacentHTML("afterbegin",i):this.headsStripEl.insertAdjacentHTML("beforeend",i)}this.syncActiveHighlight()}removeSegments(t,e){if(this.stripEl&&!(t<=0)){for(let s=0;s<t;s++){const t="start"===e?this.stripEl.firstElementChild:this.stripEl.lastElementChild;t?.remove()}if("week"===this.mode&&this.headsStripEl)for(let s=0;s<t;s++){const t="start"===e?this.headsStripEl.firstElementChild:this.headsStripEl.lastElementChild;t?.remove()}}}applySegmentWidth(t){if(this.segW=t,!this.stripEl)return;this.ctx?.compact||((e=>{this.stripEl.querySelectorAll(e).forEach(e=>{e.style.width=`${t}px`,e.style.minWidth=`${t}px`,e.style.maxWidth=`${t}px`})})(".rde-time-seg--x"),this.headsStripEl?.querySelectorAll(".rde-week-head-seg").forEach(e=>{e.style.width=`${t}px`,e.style.minWidth=`${t}px`,e.style.maxWidth=`${t}px`}))}fillEmptyDayBlocks(){this.stripEl&&this.ctx&&this.stripEl.querySelectorAll(".rde-tg-col[data-day]").forEach(t=>{if(t.childElementCount>0)return;const e=t.dataset.day;if(!e)return;const[s,i,n]=e.split("-").map(Number);t.innerHTML=L(this.byDay,new Date(s,i-1,n),this.ctx,this.dayWidth)})}updateHeader(t){this.headsEl&&this.ctx&&(this.headsEl.innerHTML=t.map(t=>{const e=new Intl.DateTimeFormat(this.ctx.locale,{weekday:"short",day:"numeric",..."day"===this.mode?{month:"short"}:{}}).format(t);return`<div class="rde-tg-head${a(t,new Date)?" is-today":""} is-active" data-day="${h(t)}">${k(e)}</div>`}).join(""))}onSettle(t){if(!this.scroller||!this.ctx)return;this.activeIndex=t;const e=this.segmentDates(t);"day"===this.mode&&this.updateHeader(e),this.syncActiveHighlight();const s="week"===this.mode?o(e[0],this.ctx.firstDayOfWeek):e[0],i=h(s);i!==this.lastAnchorKey&&(this.lastAnchorKey=i,this.ctx.onAnchorChange(s))}syncActiveHighlight(){if(!this.stripEl||null===this.activeIndex)return;const t=this.activeIndex;if("week"===this.mode)return this.headsStripEl?.querySelectorAll(".rde-week-head-seg[data-seg]").forEach(e=>{e.classList.toggle("is-active",Number(e.dataset.seg)===t)}),void this.stripEl.querySelectorAll(".rde-time-seg--x[data-seg]").forEach(e=>{e.classList.toggle("is-active",Number(e.dataset.seg)===t)});"day"===this.mode&&this.stripEl.querySelectorAll(".rde-time-seg[data-seg]").forEach(e=>{const s=Number(e.dataset.seg)===t;e.classList.toggle("is-active",s),e.querySelectorAll(".rde-tg-col").forEach(t=>{t.classList.toggle("is-active",s)})})}emitRange(t,e){if(this.ctx)if("week"===this.mode){const s=x(t,this.ctx.firstDayOfWeek),i=r(x(t+e-1,this.ctx.firstDayOfWeek),6);this.ctx.onRangeChange({from:s,to:i})}else{const s=E(t),i=r(E(t+e-1),1);this.ctx.onRangeChange({from:s,to:i})}}}class z{constructor(){this.name="week",this.strip=new C("week")}render(t){this.strip.mount(t)}syncEvents(t){this.strip.syncEvents(t)}goToDate(t){this.strip.goToDate(t)}applyLayout(t){this.strip.applyLayout(t)}destroy(){this.strip.destroy()}}class F{constructor(){this.name="day",this.strip=new C("day")}render(t){this.strip.mount(t)}syncEvents(t){this.strip.syncEvents(t)}goToDate(t){this.strip.goToDate(t)}applyLayout(t){this.strip.applyLayout(t)}destroy(){this.strip.destroy()}}function V(t,e){if(!e.length)return"";const s=e.slice().sort((t,e)=>t.top-e.top);if(s[0].top>t+12)return s[0].dayKey;let i=s[0].dayKey;for(const e of s){if(!(e.top<=t+12))break;i=e.dayKey}return i}function q(t){const e=new Map;for(const s of t){let t=i(s.start);const n=i(s.end);let a=0;for(;t<=n&&a<370;){const i=h(t),n=e.get(i)||[];n.push(s),e.set(i,n),t=r(t,1),a++}}for(const t of e.values())t.sort((t,e)=>t.start.getTime()-e.start.getTime());return e}class N{constructor(){this.name="agenda",this.host=null,this.viewportEl=null,this.stripEl=null,this.ctx=null,this.byDay=new Map,this.lastAnchorKey="",this.lastVisibleKeys=new Set,this.mountedStart=0,this.mountedEnd=0,this.scrollRaf=0,this.extending=!1,this.onScroll=()=>{this.scrollRaf||(this.scrollRaf=requestAnimationFrame(()=>{this.scrollRaf=0,this.maybeExtend(),this.updateAnchorFromScroll()}))},this.onClick=t=>{if(!this.ctx)return;const e=t.target,s=e.closest("[data-event-id]");if(s?.dataset.eventId){const e=this.ctx.getEvent(s.dataset.eventId);return void(e&&this.ctx.onEventClick(e,t))}const i=e.closest("[data-day]");if(i?.dataset.day){const[e,s,n]=i.dataset.day.split("-").map(Number),r=new Date(e,s-1,n);if(this.ctx.isDateDisabled(r))return;this.ctx.onDateClick(r,t)}}}render(t){this.destroy(),this.ctx=t,this.host=t.root,this.indexEvents(t.events),this.host.innerHTML='\n <div class="rde-agenda rde-agenda--scroll">\n <div class="rde-viewport rde-agenda-viewport" data-viewport>\n <div class="rde-agenda-strip" data-strip></div>\n </div>\n </div>\n ',this.viewportEl=this.host.querySelector("[data-viewport]"),this.stripEl=this.host.querySelector("[data-strip]");const e=w(t.cursor);this.mountRange(e-14,e+21),this.emitRange(),this.scrollToDayIndex(e,"auto"),this.updateAnchorFromScroll(),this.viewportEl.addEventListener("scroll",this.onScroll,{passive:!0}),this.host.addEventListener("click",this.onClick)}applyLayout(t){}syncEvents(t){const e=this.captureScrollAnchor();this.mergeEvents(t),this.refreshMountedSegments(),this.stripEl,this.restoreScrollAnchor(e),this.updateAnchorFromScroll()}goToDate(t){const e=w(t);(e<this.mountedStart||e>this.mountedEnd)&&(this.mountRange(e-14,e+21),this.emitRange()),this.scrollToDayIndex(e,"auto"),this.updateAnchorFromScroll()}destroy(){this.scrollRaf&&cancelAnimationFrame(this.scrollRaf),this.viewportEl?.removeEventListener("scroll",this.onScroll),this.host?.removeEventListener("click",this.onClick),this.host&&(this.host.innerHTML=""),this.host=null,this.viewportEl=null,this.stripEl=null,this.ctx=null}indexEvents(t){this.byDay=q(t)}mergeEvents(t){const e=q(t);if(!this.stripEl)return void(this.byDay=e);const s=new Map(this.byDay);for(const[t,i]of e)s.set(t,i);this.stripEl.querySelectorAll(".rde-agenda-seg[data-day]").forEach(t=>{const i=t.dataset.day;i&&(e.has(i)?s.set(i,e.get(i)):s.has(i)||s.set(i,[]))}),this.byDay=s}ensureDayKeys(t,e){for(let s=t;s<=e;s++){const t=h(E(s));this.byDay.has(t)||this.byDay.set(t,[])}}clampIndex(t){if(!this.ctx)return t;const e=this.ctx.minDayIndex,s=this.ctx.maxDayIndex;return null!=e&&t<e?e:null!=s&&t>s?s:t}dateHeaderHtml(t,e){const s=new Intl.DateTimeFormat(e,{weekday:"short"}).format(t),i=new Intl.DateTimeFormat(e,{month:"short",day:"numeric",year:"numeric"}).format(t);return`<div class="rde-agenda__day-col"><div class="rde-agenda__date" role="heading" aria-level="3"><span class="rde-agenda__weekday">${k(s)}</span><span class="rde-agenda__date-sep">, </span><span class="rde-agenda__ymd">${k(i)}</span></div></div>`}eventRowHtml(t,e){const s=String(t.occurrenceId||t.id),i=t.color||"var(--rde-event-default)",n=!0===t.allDay,r=n?"All day":l(t.start,e),a=n?" rde-agenda__time--allday":"",h=t.location?`<span class="rde-agenda__loc">${k(t.location)}</span>`:"";return`<button type="button" class="rde-agenda__item" data-event-id="${I(s)}" style="--rde-event-color:${I(i)}" title="${I(t.title)}"><span class="rde-agenda__time${a}">${k(r)}</span><span class="rde-agenda__title">${k(t.title)}</span>${h}</button>`}eventsBodyHtml(t,e){if(!t.length)return'<div class="rde-agenda__list"><div class="rde-agenda__empty">No events</div></div>';const s=['<div class="rde-agenda__list">'];for(const i of t)s.push(this.eventRowHtml(i,e));return s.push("</div>"),s.join("")}segInnerHtml(t,e,s){const i=function(t,e){return function(t){const e=[],s=[];for(const i of t)i.allDay?e.push(i):s.push(i);const i=(t,e)=>t.title.localeCompare(e.title,void 0,{sensitivity:"base"});return e.sort((t,e)=>i(t,e)),s.sort((t,e)=>{const s=t.start.getTime()-e.start.getTime();return 0!==s?s:i(t,e)}),[...e,...s]}(t.get(e)||[])}(this.byDay,e);return[this.dateHeaderHtml(t,s),this.eventsBodyHtml(i,s)].join("")}daySegHtml(t){if(!this.ctx)return"";const e=this.ctx.locale,s=E(t),i=h(s);return[`<div class="rde-agenda-seg" data-day="${i}" data-day-index="${t}">`,this.segInnerHtml(s,i,e),"</div>"].join("")}mountRange(t,e){if(!this.stripEl||!this.ctx)return;t=this.clampIndex(t),(e=this.clampIndex(e))<t&&(e=t);const s=[];for(let i=t;i<=e;i++)s.push(this.daySegHtml(i));this.stripEl.innerHTML=s.join(""),this.mountedStart=t,this.mountedEnd=e}prependDays(t,e){if(!this.stripEl||e<t)return;this.ensureDayKeys(t,e);const s=Array.from({length:e-t+1},(e,s)=>this.daySegHtml(t+s)).join(""),i=this.viewportEl,n=this.stripEl.scrollHeight;this.stripEl.insertAdjacentHTML("afterbegin",s),this.mountedStart=t,i&&(i.scrollTop+=this.stripEl.scrollHeight-n)}appendDays(t,e){if(!this.stripEl||e<t)return;this.ensureDayKeys(t,e);const s=Array.from({length:e-t+1},(e,s)=>this.daySegHtml(t+s)).join("");this.stripEl.insertAdjacentHTML("beforeend",s),this.mountedEnd=e}trimStart(t){if(!this.stripEl||!this.viewportEl||t<=0)return;const e=this.stripEl.scrollHeight;for(let e=0;e<t;e++)this.stripEl.firstElementChild?.remove();this.viewportEl.scrollTop-=e-this.stripEl.scrollHeight,this.mountedStart+=t}trimEnd(t){if(this.stripEl&&!(t<=0)){for(let e=0;e<t;e++)this.stripEl.lastElementChild?.remove();this.mountedEnd-=t}}refreshMountedSegments(){if(!this.stripEl||!this.ctx)return;const t=this.ctx.locale;this.stripEl.querySelectorAll(".rde-agenda-seg[data-day]").forEach(e=>{const s=e.dataset.day,i=e.dataset.dayIndex;if(!s||null==i)return;const n=E(Number(i));e.innerHTML=this.segInnerHtml(n,s,t)})}scrollToDayIndex(t,e){if(!this.viewportEl||!this.stripEl)return;const s=this.stripEl.querySelector(`[data-day-index="${t}"]`);if(!s)return;const i=this.viewportEl.getBoundingClientRect(),n=s.getBoundingClientRect(),r=this.viewportEl.scrollTop+(n.top-i.top);this.viewportEl.scrollTo({top:r,behavior:e})}maybeExtend(){if(!this.viewportEl||!this.ctx||this.extending)return;const{scrollTop:t,clientHeight:e,scrollHeight:s}=this.viewportEl,i=this.ctx.minDayIndex,n=this.ctx.maxDayIndex,r=this.captureScrollAnchor();if(t<320&&this.mountedStart>(i??-1/0)){this.extending=!0;const t=this.clampIndex(this.mountedStart-14);t<this.mountedStart&&(this.prependDays(t,this.mountedStart-1),this.emitRange(),this.mountedEnd-this.mountedStart>60&&this.trimEnd(14)),this.extending=!1}if(t+e>s-320&&this.mountedEnd<(n??1/0)){this.extending=!0;const t=this.clampIndex(this.mountedEnd+14);t>this.mountedEnd&&(this.appendDays(this.mountedEnd+1,t),this.emitRange(),this.mountedEnd-this.mountedStart>60&&this.trimStart(14)),this.extending=!1}this.stripEl,this.restoreScrollAnchor(r)}applyAgendaHighlight(){if(!this.stripEl)return;const t=this.lastVisibleKeys;this.stripEl.querySelectorAll(".rde-agenda-seg[data-day]").forEach(e=>{e.classList.toggle("is-active",t.has(e.dataset.day??""))})}segmentLayoutRects(){if(!this.stripEl)return[];const t=this.stripEl.querySelectorAll(".rde-agenda-seg[data-day]");return Array.from(t).map(t=>{const e=t.getBoundingClientRect();return{dayKey:t.dataset.day??"",top:e.top,bottom:e.bottom}}).filter(t=>t.dayKey)}captureScrollAnchor(){if(!this.viewportEl)return null;const t=this.viewportEl.getBoundingClientRect(),e=V(t.top,this.segmentLayoutRects());if(!e)return null;const s=this.stripEl?.querySelector(`.rde-agenda-seg[data-day="${e}"]`);if(!s)return null;const i=s.getBoundingClientRect();return{dayKey:e,contentTop:this.viewportEl.scrollTop+(i.top-t.top)}}restoreScrollAnchor(t){if(!t||!this.viewportEl||!this.stripEl)return;const e=this.stripEl.querySelector(`.rde-agenda-seg[data-day="${t.dayKey}"]`);if(!e)return;const s=this.viewportEl.getBoundingClientRect(),i=e.getBoundingClientRect(),n=this.viewportEl.scrollTop+(i.top-s.top),r=t.contentTop-n;Math.abs(r)>.5&&(this.viewportEl.scrollTop+=r)}updateAnchorFromScroll(){if(!this.viewportEl||!this.ctx)return;const t=this.viewportEl.getBoundingClientRect(),e=this.segmentLayoutRects(),s=V(t.top,e);if(s&&s!==this.lastAnchorKey){this.lastAnchorKey=s;const[t,e,n]=s.split("-").map(Number);this.ctx.onAnchorChange(i(new Date(t,e-1,n)))}let n=function(t,e,s,i=20){const n=[];for(const r of s)Math.max(0,Math.min(r.bottom,e)-Math.max(r.top,t))>=i&&n.push(r.dayKey);return n}(t.top,t.bottom,e);!n.length&&s&&(n=[s]),this.lastVisibleKeys=new Set(n),this.applyAgendaHighlight()}emitRange(){if(!this.ctx)return;const t=E(this.mountedStart),e=r(E(this.mountedEnd),1);this.ctx.onRangeChange({from:t,to:e})}}const _={start:9,end:18};let Y=0;class O{constructor(t,e={}){this.store=new p,this.titleEl=null,this.activeView=null,this.proUnlocked=!1,this.renderToken=0,this.layoutWidth=0,this.compact=!1,this.layoutObs=null,this.layoutRaf=0,this.instanceId=++Y,this.bufferedRange=null,this.rangeRaf=0,this.rangeSyncToken=0;const r="string"==typeof t?document.querySelector(t):t;if(!r)throw new Error(`RollDateEvents: element not found (${String(t)})`);this.el=r,this.options={...e},m(this.options),this.viewName=e.defaultView||"month";const a=i(e.defaultDate?s(e.defaultDate):new Date),h=this.clampNavDate(a);this.cursor="month"===this.viewName?n(h):h,this.store.setEvents(e.events||[]),this.views={month:new $,week:new z,day:new F,agenda:new N},this.mount(),this.measureLayout(),this.startLayoutObserver(),this.bootstrapLicense().then(()=>{this.measureLayout(),this.render({remount:!0})})}get currentView(){return this.viewName}get currentDate(){return new Date(this.cursor)}setView(t){this.viewName!==t&&(this.viewName=t,this.bufferedRange=null,this.options.onViewChange?.(t),this.render({remount:!0}))}setDate(t){const e=i(s(t)),r=this.clampNavDate(e),a=this.options.firstDayOfWeek??1;if("month"===this.viewName?this.cursor=n(r):"week"===this.viewName?this.cursor=o(r,a):this.cursor=r,this.activeView?.name===this.viewName&&this.activeView.goToDate)return this.activeView.goToDate(this.cursor),void this.updateTitle();this.render({remount:!0})}setEvents(t){this.store.setEvents(t),this.refreshEvents()}getEvents(){return this.store.getRaw()}addEvent(t){this.store.add(t),this.refreshEvents()}updateEvent(t,e){this.store.update(t,e)&&this.refreshEvents()}removeEvent(t){this.store.remove(t),this.refreshEvents()}today(){this.setDate(this.clampNavDate(i(new Date)))}next(){this.shift(1)}prev(){this.shift(-1)}destroy(){this.layoutRaf&&cancelAnimationFrame(this.layoutRaf),this.layoutObs?.disconnect(),this.layoutObs=null,this.rangeRaf&&cancelAnimationFrame(this.rangeRaf),this.activeView?.destroy(),this.activeView=null,this.root?.remove(),this.el.innerHTML=""}shift(t){const e=this.options.firstDayOfWeek??1;if("month"===this.viewName)this.cursor=this.clampNavDate(function(t,e){const s=new Date(t);return s.setMonth(s.getMonth()+e),s}(n(this.cursor),t));else if("week"===this.viewName){const s=o(r(o(this.cursor,e),7*t),e);this.cursor=this.clampNavDate(s)}else"day"===this.viewName?this.cursor=this.clampNavDate(r(i(this.cursor),t)):this.cursor=this.clampNavDate(r(i(this.cursor),7*t));if(this.activeView?.name===this.viewName&&this.activeView.goToDate)return this.activeView.goToDate(this.cursor),void this.updateTitle();this.render({remount:!0})}boundsMin(){const t=this.options.minDate;return t?i(s(t)):void 0}boundsMax(){const t=this.options.maxDate;return t?i(s(t)):void 0}isDateDisabled(t){return!function(t,e,s){const n=i(t).getTime();return!(e&&n<i(e).getTime()||s&&n>i(s).getTime())}(i(t),this.boundsMin(),this.boundsMax())}clampNavDate(t){const e=this.boundsMin(),s=this.boundsMax();return function(t,e,s){const i=t.getTime();return e&&i<e.getTime()?new Date(e):s&&i>s.getTime()?new Date(s):t}(i(t),e,s)}dayIndexBounds(){const t=this.boundsMin(),e=this.boundsMax();return{minDayIndex:t?w(t):void 0,maxDayIndex:e?w(e):void 0}}weekIndexBounds(){const t=this.options.firstDayOfWeek??1,e=this.boundsMin(),s=this.boundsMax();return{minWeekIndex:e?f(e,t):void 0,maxWeekIndex:s?f(s,t):void 0}}updateTitle(){var t,e;this.titleEl&&(this.titleEl.textContent=(t=this.cursor,e=this.options.locale||"en",new Intl.DateTimeFormat(e,{month:"long",year:"numeric"}).format(t)))}async refreshEvents(){const t=this.paddedRange(this.bufferedRange||this.visibleRange()),e=this.store.prepareRangeSync(t);this.activeView?.syncEvents?this.activeView.syncEvents(e):this.render({remount:!0})}paddedRange(t){const e="month"===this.viewName?28:"week"===this.viewName?21:"agenda"===this.viewName?35:7;return{from:r(t.from,-e),to:r(t.to,e)}}onViewRangeChange(t){this.bufferedRange=t,this.options.onVisibleRangeChange?.(t),this.rangeRaf&&cancelAnimationFrame(this.rangeRaf);const e=++this.rangeSyncToken;this.rangeRaf=requestAnimationFrame(()=>{this.rangeRaf=0,this.flushRangeEvents(e)})}async flushRangeEvents(t){if(t!==this.rangeSyncToken||!this.bufferedRange)return;const e=this.paddedRange(this.bufferedRange),s=this.store.prepareRangeSync(e);t===this.rangeSyncToken&&this.activeView?.syncEvents?.(s)}onViewAnchorChange(t){this.cursor=i(t),this.updateTitle()}async bootstrapLicense(){this.proUnlocked=!1}visibleRange(){if("month"===this.viewName){const t=this.options.firstDayOfWeek??1,e=f(n(this.cursor),t);return{from:x(e-S,t),to:r(x(e+S-1,t),6)}}if("week"===this.viewName){const t=o(this.cursor,this.options.firstDayOfWeek??1);return{from:t,to:r(t,7)}}if("day"===this.viewName){const t=i(this.cursor);return{from:t,to:r(t,1)}}return{from:i(this.cursor),to:r(this.cursor,90)}}resolveTheme(){let t=this.options.theme||"dark";return"auto"===t&&(t=window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark"),t}visibleHours(){const t=this.options.visibleHours||_,e=c(t.start);return{start:e,end:Math.max(e+1,c(t.end))}}mount(){this.el.innerHTML="",this.root=document.createElement("div"),this.root.className="rde",this.root.dataset.theme=this.resolveTheme(),this.root.dataset.edition="lite";const t=!1!==this.options.header,e=`rde-${this.instanceId}-panel`;t?(this.root.innerHTML=`\n <div class="rde-header">\n <div class="rde-nav">\n <button type="button" class="rde-btn" data-action="prev" aria-label="Previous">‹</button>\n <button type="button" class="rde-btn" data-action="today">Today</button>\n <button type="button" class="rde-btn" data-action="next" aria-label="Next">›</button>\n </div>\n <h2 class="rde-title"></h2>\n <div class="rde-views" role="tablist" aria-label="Calendar views">\n <button type="button" role="tab" class="rde-btn rde-view" data-view="month" id="rde-${this.instanceId}-tab-month" aria-controls="${e}">Month</button>\n <button type="button" role="tab" class="rde-btn rde-view" data-view="week" id="rde-${this.instanceId}-tab-week" aria-controls="${e}">Week</button>\n <button type="button" role="tab" class="rde-btn rde-view" data-view="day" id="rde-${this.instanceId}-tab-day" aria-controls="${e}">Day</button>\n <button type="button" role="tab" class="rde-btn rde-view" data-view="agenda" id="rde-${this.instanceId}-tab-agenda" aria-controls="${e}">Agenda</button>\n </div>\n </div>\n <div class="rde-body" id="${e}" role="tabpanel" tabindex="-1"></div>\n `,this.titleEl=this.root.querySelector(".rde-title")):this.root.innerHTML='<div class="rde-body"></div>',this.bodyEl=this.root.querySelector(".rde-body"),this.el.appendChild(this.root),this.root.addEventListener("click",t=>{const e=t.target,s=e.closest("[data-action]")?.dataset.action;"prev"===s&&this.prev(),"next"===s&&this.next(),"today"===s&&this.today();const i=e.closest("[data-view]");i?.dataset.view&&this.setView(i.dataset.view)}),this.root.addEventListener("keydown",t=>{"ArrowLeft"===t.key?(t.preventDefault(),this.prev()):"ArrowRight"===t.key&&(t.preventDefault(),this.next())})}measureLayout(){const t=Math.round(this.root?.clientWidth||this.el.clientWidth||0);this.layoutWidth=t>0?t:800,this.compact=b(this.layoutWidth),this.root&&(this.root.dataset.compact=this.compact?"true":"false")}startLayoutObserver(){"undefined"!=typeof ResizeObserver&&(this.layoutObs=new ResizeObserver(t=>{const e=t[0],s=Math.round(e?.contentRect.width??this.root.clientWidth);s<=0||(this.layoutRaf&&cancelAnimationFrame(this.layoutRaf),this.layoutRaf=requestAnimationFrame(()=>{this.layoutRaf=0,this.onLayoutResize(s)}))}),this.layoutObs.observe(this.root))}onLayoutResize(t){const e=b(t),s=t!==this.layoutWidth||e!==this.compact;this.layoutWidth=t,this.compact=e,this.root.dataset.compact=e?"true":"false",s&&this.activeView&&this.activeView.applyLayout?.({compact:e,layoutWidth:t})}buildViewContext(t){const e=this.dayIndexBounds(),s=this.weekIndexBounds();return{root:this.bodyEl,cursor:this.cursor,locale:this.options.locale||"en",firstDayOfWeek:this.options.firstDayOfWeek??1,theme:this.resolveTheme(),compact:this.compact,layoutWidth:this.layoutWidth,eventLimit:this.options.eventLimit??3,visibleHours:this.visibleHours(),minDate:this.boundsMin(),maxDate:this.boundsMax(),isDateDisabled:t=>this.isDateDisabled(t),minDayIndex:e.minDayIndex,maxDayIndex:e.maxDayIndex,minWeekIndex:s.minWeekIndex,maxWeekIndex:s.maxWeekIndex,events:t,getEvent:t=>this.store.getById(t),onEventClick:(t,e)=>this.options.onEventClick?.(t,e),onDateClick:(t,e)=>{this.isDateDisabled(t)||this.options.onDateClick?.(t,e)},onAnchorChange:t=>this.onViewAnchorChange(t),onRangeChange:t=>{this.onViewRangeChange(t)}}}async render(t={}){const e=++this.renderToken,s=!0===t.remount||!this.activeView||this.activeView.name!==this.viewName,i=this.bufferedRange&&!s?this.bufferedRange:this.visibleRange();s&&(this.bufferedRange=i),this.options.onVisibleRangeChange?.(i);const n=this.store.prepareRangeSync(i);if(e!==this.renderToken)return;this.root.dataset.theme=this.resolveTheme(),this.updateTitle(),this.root.querySelectorAll(".rde-view").forEach(t=>{const e=t,s=e.dataset.view===this.viewName;e.classList.toggle("is-active",s),e.setAttribute("aria-selected",s?"true":"false"),e.tabIndex=s?0:-1});const r=this.buildViewContext(n);s?(this.activeView&&this.activeView.name!==this.viewName&&(this.activeView.destroy(),this.activeView=null),this.activeView=this.views[this.viewName],this.activeView.render(r)):this.activeView?.syncEvents?this.activeView.syncEvents(n):(this.activeView=this.views[this.viewName],this.activeView.render(r))}}"undefined"!=typeof window&&(window.RollDateEvents=O);export{O as RollDateEvents,t as isProBuild,e as isProFeature};
|
|
2
|
+
//# sourceMappingURL=rolldate-events.mjs.map
|