@reachweb/alpine-calendar 0.1.1 → 0.3.0

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/README.md CHANGED
@@ -1,21 +1,23 @@
1
- # Reach Calendar
1
+ # Alpine Calendar
2
2
 
3
3
  A lightweight, AlpineJS-native calendar component with inline/popup display, input binding with masking, single/multiple/range selection, month/year pickers, birth-date wizard, TailwindCSS 4 theming, and timezone-safe date handling.
4
4
 
5
+ **[Live Demo](https://reachweb.github.io/alpine-calendar/)**
6
+
5
7
  ## Installation
6
8
 
7
9
  ### npm / pnpm
8
10
 
9
11
  ```bash
10
- pnpm add @reachgr/alpine-calendar
12
+ pnpm add @reachweb/alpine-calendar
11
13
  # or
12
- npm install @reachgr/alpine-calendar
14
+ npm install @reachweb/alpine-calendar
13
15
  ```
14
16
 
15
17
  ```js
16
18
  import Alpine from 'alpinejs'
17
- import { calendarPlugin } from '@reachgr/alpine-calendar'
18
- import '@reachgr/alpine-calendar/css'
19
+ import { calendarPlugin } from '@reachweb/alpine-calendar'
20
+ import '@reachweb/alpine-calendar/css'
19
21
 
20
22
  Alpine.plugin(calendarPlugin)
21
23
  Alpine.start()
@@ -24,9 +26,9 @@ Alpine.start()
24
26
  ### CDN (no bundler)
25
27
 
26
28
  ```html
27
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@reachgr/alpine-calendar/dist/alpine-calendar.css">
29
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@reachweb/alpine-calendar/dist/alpine-calendar.css">
28
30
  <script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3/dist/cdn.min.js"></script>
29
- <script src="https://cdn.jsdelivr.net/npm/@reachgr/alpine-calendar/dist/alpine-calendar.cdn.js"></script>
31
+ <script src="https://cdn.jsdelivr.net/npm/@reachweb/alpine-calendar/dist/alpine-calendar.cdn.js"></script>
30
32
  ```
31
33
 
32
34
  The CDN build auto-registers via `alpine:init` — no manual setup needed. Works with Livewire, Statamic, or any server-rendered HTML.
@@ -158,7 +160,7 @@ All options are passed via `x-data="calendar({ ... })"`.
158
160
  | `display` | `'inline' \| 'popup'` | `'inline'` | Inline calendar or popup with input |
159
161
  | `format` | `string` | `'DD/MM/YYYY'` | Date format (tokens: `DD`, `MM`, `YYYY`, `D`, `M`, `YY`) |
160
162
  | `months` | `number` | `1` | Months to display (1=single, 2=dual side-by-side, 3+=scrollable) |
161
- | `firstDay` | `0–6` | `0` | First day of week (0=Sun, 1=Mon, ...) |
163
+ | `firstDay` | `0–6` | `1` | First day of week (0=Sun, 1=Mon, ...) |
162
164
  | `mask` | `boolean` | `true` | Enable input masking |
163
165
  | `value` | `string` | — | Initial value (ISO or formatted string) |
164
166
  | `name` | `string` | `''` | Input name attribute for form submission |
@@ -430,7 +432,7 @@ All classes use the `.rc-` prefix:
430
432
  Set defaults that apply to every calendar instance:
431
433
 
432
434
  ```js
433
- import { calendarPlugin } from '@reachgr/alpine-calendar'
435
+ import { calendarPlugin } from '@reachweb/alpine-calendar'
434
436
 
435
437
  calendarPlugin.defaults({ firstDay: 1, locale: 'el' })
436
438
  Alpine.plugin(calendarPlugin)
@@ -478,7 +480,7 @@ import {
478
480
  presetLastMonth,
479
481
  presetThisYear,
480
482
  presetLastYear,
481
- } from '@reachgr/alpine-calendar'
483
+ } from '@reachweb/alpine-calendar'
482
484
  ```
483
485
 
484
486
  All factories accept an optional `label` and `timezone` parameter. `presetThisWeek` and `presetLastWeek` also accept a `firstDay` (default: 1 = Monday).
@@ -574,7 +576,7 @@ import {
574
576
  presetLastMonth,
575
577
  presetThisYear,
576
578
  presetLastYear,
577
- } from '@reachgr/alpine-calendar'
579
+ } from '@reachweb/alpine-calendar'
578
580
 
579
581
  import type {
580
582
  CalendarConfig,
@@ -592,17 +594,17 @@ import type {
592
594
  ConstraintMessages,
593
595
  InputMask,
594
596
  MaskEventHandlers,
595
- } from '@reachgr/alpine-calendar'
597
+ } from '@reachweb/alpine-calendar'
596
598
  ```
597
599
 
598
600
  ## Livewire Integration
599
601
 
600
602
  ```php
601
603
  @push('styles')
602
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@reachgr/alpine-calendar/dist/alpine-calendar.css">
604
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@reachweb/alpine-calendar/dist/alpine-calendar.css">
603
605
  @endpush
604
606
  @push('scripts')
605
- <script src="https://cdn.jsdelivr.net/npm/@reachgr/alpine-calendar/dist/alpine-calendar.cdn.js"></script>
607
+ <script src="https://cdn.jsdelivr.net/npm/@reachweb/alpine-calendar/dist/alpine-calendar.cdn.js"></script>
606
608
  @endpush
607
609
  ```
608
610
 
@@ -1,2 +1,2 @@
1
- !function(){"use strict";class e{constructor(e,t,s){this.year=e,this.month=t,this.day=s}static today(t){const s=new Date;return t?e.fromNativeDate(s,t):new e(s.getFullYear(),s.getMonth()+1,s.getDate())}static fromNativeDate(t,s){if(s){const i=new Intl.DateTimeFormat("en-US",{timeZone:s,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(t);let a=0,n=0,r=0;for(const e of i)"year"===e.type?a=Number(e.value):"month"===e.type?n=Number(e.value):"day"===e.type&&(r=Number(e.value));return new e(a,n,r)}return new e(t.getFullYear(),t.getMonth()+1,t.getDate())}static fromISO(s){const i=/^(\d{4})-(\d{2})-(\d{2})$/.exec(s);if(!i)return null;const a=Number(i[1]),n=Number(i[2]),r=Number(i[3]);return n<1||n>12||r<1||r>t(a,n)?null:new e(a,n,r)}toNativeDate(){return new Date(this.year,this.month-1,this.day)}toISO(){return`${String(this.year).padStart(4,"0")}-${String(this.month).padStart(2,"0")}-${String(this.day).padStart(2,"0")}`}toKey(){return this.toISO()}isSame(e){return this.year===e.year&&this.month===e.month&&this.day===e.day}isBefore(e){return this.year!==e.year?this.year<e.year:this.month!==e.month?this.month<e.month:this.day<e.day}isAfter(e){return this.year!==e.year?this.year>e.year:this.month!==e.month?this.month>e.month:this.day>e.day}isBetween(e,t){return!this.isBefore(e)&&!this.isAfter(t)}diffDays(e){const t=Date.UTC(this.year,this.month-1,this.day),s=Date.UTC(e.year,e.month-1,e.day);return Math.round((s-t)/864e5)}addDays(t){const s=this.toNativeDate();return s.setDate(s.getDate()+t),e.fromNativeDate(s)}addMonths(s){let i=this.month-1+s;const a=this.year+Math.floor(i/12);i=(i%12+12)%12;const n=t(a,i+1),r=Math.min(this.day,n);return new e(a,i+1,r)}addYears(s){const i=t(this.year+s,this.month),a=Math.min(this.day,i);return new e(this.year+s,this.month,a)}startOfMonth(){return new e(this.year,this.month,1)}endOfMonth(){return new e(this.year,this.month,t(this.year,this.month))}format(e,t){const s=this.toNativeDate();return new Intl.DateTimeFormat(t,e).format(s)}}function t(e,t){return new Date(e,t,0).getDate()}function s(e){const t=new Date(Date.UTC(e.year,e.month-1,e.day)),s=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-s);const i=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-i.getTime())/864e5+1)/7)}function i(e){return{disabledKeys:e.disabledDates?new Set(e.disabledDates.map(e=>e.toKey())):void 0,disabledDays:e.disabledDaysOfWeek?new Set(e.disabledDaysOfWeek):void 0,enabledKeys:e.enabledDates?new Set(e.enabledDates.map(e=>e.toKey())):void 0,enabledDays:e.enabledDaysOfWeek?new Set(e.enabledDaysOfWeek):void 0,disabledMonths:e.disabledMonths?new Set(e.disabledMonths):void 0,enabledMonths:e.enabledMonths?new Set(e.enabledMonths):void 0,disabledYears:e.disabledYears?new Set(e.disabledYears):void 0,enabledYears:e.enabledYears?new Set(e.enabledYears):void 0}}function a(e,t,s,i){if(t&&e.isBefore(t))return!0;if(s&&e.isAfter(s))return!0;if(i.enabledKeys&&i.enabledKeys.has(e.toKey()))return!1;if(i.enabledYears&&!i.enabledYears.has(e.year))return!0;if(i.disabledYears&&i.disabledYears.has(e.year))return!0;if(i.enabledMonths&&!i.enabledMonths.has(e.month))return!0;if(i.disabledMonths&&i.disabledMonths.has(e.month))return!0;const a=void 0!==i.enabledDays||void 0!==i.disabledDays?e.toNativeDate().getDay():-1;return!(!i.enabledDays||i.enabledDays.has(a))||(!(!i.disabledKeys||!i.disabledKeys.has(e.toKey()))||!(!i.disabledDays||!i.disabledDays.has(a)))}function n(e,t){return e.from&&e.to?t.isBetween(e.from,e.to):!!e.recurringMonths&&e.recurringMonths.has(t.month)}function r(e,t){let s;for(const i of e)n(i,t)&&(!s||i.priority>s.priority)&&(s=i);return s}function l(e){const{minDate:t,maxDate:s,rules:n}=e,l=i(e),o=null==n?void 0:n.map((e,t)=>({from:e.from,to:e.to,recurringMonths:e.months?new Set(e.months):void 0,minDate:e.minDate,maxDate:e.maxDate,minRange:e.minRange,maxRange:e.maxRange,sets:i(e),hasMinDate:void 0!==e.minDate,hasMaxDate:void 0!==e.maxDate,priority:e.priority??0,originalIndex:t}));return o&&0!==o.length?e=>{const i=r(o,e);if(!i)return a(e,t,s,l);return a(e,i.hasMinDate?i.minDate:t,i.hasMaxDate?i.maxDate:s,{disabledKeys:void 0!==i.sets.disabledKeys?i.sets.disabledKeys:l.disabledKeys,disabledDays:void 0!==i.sets.disabledDays?i.sets.disabledDays:l.disabledDays,enabledKeys:void 0!==i.sets.enabledKeys?i.sets.enabledKeys:l.enabledKeys,enabledDays:void 0!==i.sets.enabledDays?i.sets.enabledDays:l.enabledDays,disabledMonths:void 0!==i.sets.disabledMonths?i.sets.disabledMonths:l.disabledMonths,enabledMonths:void 0!==i.sets.enabledMonths?i.sets.enabledMonths:l.enabledMonths,disabledYears:void 0!==i.sets.disabledYears?i.sets.disabledYears:l.disabledYears,enabledYears:void 0!==i.sets.enabledYears?i.sets.enabledYears:l.enabledYears})}:e=>a(e,t,s,l)}function o(e){const{minRange:t,maxRange:s,rules:a}=e;if(void 0===t&&void 0===s&&(!a||a.every(e=>void 0===e.minRange&&void 0===e.maxRange)))return()=>!0;const n=null==a?void 0:a.map((e,t)=>({from:e.from,to:e.to,recurringMonths:e.months?new Set(e.months):void 0,minDate:e.minDate,maxDate:e.maxDate,minRange:e.minRange,maxRange:e.maxRange,sets:i(e),hasMinDate:void 0!==e.minDate,hasMaxDate:void 0!==e.maxDate,priority:e.priority??0,originalIndex:t}));return(e,i)=>{let a=t,l=s;if(n){const t=r(n,e);t&&(void 0!==t.minRange&&(a=t.minRange),void 0!==t.maxRange&&(l=t.maxRange))}const o=e.diffDays(i)+1;return!(void 0!==a&&o<a)&&!(void 0!==l&&o>l)}}function d(t){const{minDate:s,maxDate:i}=t,a=t.disabledMonths?new Set(t.disabledMonths):void 0,n=t.enabledMonths?new Set(t.enabledMonths):void 0,r=t.disabledYears?new Set(t.disabledYears):void 0,l=t.enabledYears?new Set(t.enabledYears):void 0;return(t,o)=>{if(s){if(new e(t,o,1).endOfMonth().isBefore(s))return!0}if(i){if(new e(t,o,1).isAfter(i))return!0}return!(!l||l.has(t))||(!(!r||!r.has(t))||(!(!n||n.has(o))||!(!a||!a.has(o))))}}function h(t){const{minDate:s,maxDate:i}=t,a=t.disabledYears?new Set(t.disabledYears):void 0,n=t.enabledYears?new Set(t.enabledYears):void 0;return t=>{if(s){if(new e(t,12,31).isBefore(s))return!0}if(i){if(new e(t,1,1).isAfter(i))return!0}return!(!n||n.has(t))||!(!a||!a.has(t))}}const c={beforeMinDate:"Before the earliest available date",afterMaxDate:"After the latest available date",disabledDate:"This date is not available",disabledDayOfWeek:"This day of the week is not available",disabledMonth:"This month is not available",disabledYear:"This year is not available",notEnabledDate:"This date is not available",notEnabledDayOfWeek:"This day of the week is not available",notEnabledMonth:"This month is not available",notEnabledYear:"This year is not available"};function u(e,t,s,i,a){const n=[];if(t&&e.isBefore(t))return n.push(a.beforeMinDate),n;if(s&&e.isAfter(s))return n.push(a.afterMaxDate),n;if(i.enabledKeys&&i.enabledKeys.has(e.toKey()))return n;if(i.enabledYears&&!i.enabledYears.has(e.year))return n.push(a.notEnabledYear),n;if(i.disabledYears&&i.disabledYears.has(e.year))return n.push(a.disabledYear),n;if(i.enabledMonths&&!i.enabledMonths.has(e.month))return n.push(a.notEnabledMonth),n;if(i.disabledMonths&&i.disabledMonths.has(e.month))return n.push(a.disabledMonth),n;const r=void 0!==i.enabledDays||void 0!==i.disabledDays?e.toNativeDate().getDay():-1;return i.enabledDays&&!i.enabledDays.has(r)&&n.push(a.notEnabledDayOfWeek),i.disabledKeys&&i.disabledKeys.has(e.toKey())&&n.push(a.disabledDate),i.disabledDays&&i.disabledDays.has(r)&&n.push(a.disabledDayOfWeek),n}function m(e,t){const{minDate:s,maxDate:a,rules:n}=e,l={...c,...t},o=i(e),d=null==n?void 0:n.map((e,t)=>({from:e.from,to:e.to,recurringMonths:e.months?new Set(e.months):void 0,minDate:e.minDate,maxDate:e.maxDate,minRange:e.minRange,maxRange:e.maxRange,sets:i(e),hasMinDate:void 0!==e.minDate,hasMaxDate:void 0!==e.maxDate,priority:e.priority??0,originalIndex:t}));return d&&0!==d.length?e=>{const t=r(d,e);if(!t)return u(e,s,a,o,l);return u(e,t.hasMinDate?t.minDate:s,t.hasMaxDate?t.maxDate:a,{disabledKeys:void 0!==t.sets.disabledKeys?t.sets.disabledKeys:o.disabledKeys,disabledDays:void 0!==t.sets.disabledDays?t.sets.disabledDays:o.disabledDays,enabledKeys:void 0!==t.sets.enabledKeys?t.sets.enabledKeys:o.enabledKeys,enabledDays:void 0!==t.sets.enabledDays?t.sets.enabledDays:o.enabledDays,disabledMonths:void 0!==t.sets.disabledMonths?t.sets.disabledMonths:o.disabledMonths,enabledMonths:void 0!==t.sets.enabledMonths?t.sets.enabledMonths:o.enabledMonths,disabledYears:void 0!==t.sets.disabledYears?t.sets.disabledYears:o.disabledYears,enabledYears:void 0!==t.sets.enabledYears?t.sets.enabledYears:o.enabledYears},l)}:e=>u(e,s,a,o,l)}function y(t,i,a=0,n,r){const l=n??e.today(),o=r??(()=>!1),d=new e(t,i,1),h=(d.toNativeDate().getDay()-a+7)%7,c=d.addDays(-h),u=[],m=[];for(let e=0;e<6;e++){const a=[];for(let s=0;s<7;s++){const n=7*e+s,r=c.addDays(n);a.push({date:r,isCurrentMonth:r.month===i&&r.year===t,isToday:r.isSame(l),isDisabled:o(r)})}const n=a[0];n&&m.push(s(n.date)),u.push(a)}return{year:t,month:i,rows:u,weekNumbers:m}}class b{constructor(e){this.selected=null,this.selected=e??null}isSelected(e){return null!==this.selected&&this.selected.isSame(e)}toggle(e){null!==this.selected&&this.selected.isSame(e)?this.selected=null:this.selected=e}clear(){this.selected=null}toArray(){return null!==this.selected?[this.selected]:[]}toValue(){return null!==this.selected?this.selected.toISO():""}getSelected(){return this.selected}}class f{constructor(e){if(this.keys=new Set,e)for(const t of e)this.keys.add(t.toKey())}isSelected(e){return this.keys.has(e.toKey())}toggle(e){const t=e.toKey();this.keys.has(t)?this.keys.delete(t):this.keys.add(t)}clear(){this.keys.clear()}toArray(){return[...this.keys].sort().map(t=>e.fromISO(t))}toValue(){return[...this.keys].sort().join(", ")}get count(){return this.keys.size}}class p{constructor(e,t){this.start=null,this.end=null,this.start=e??null,this.end=t??null}isSelected(e){return!(null===this.start||!this.start.isSame(e))||!(null===this.end||!this.end.isSame(e))}toggle(e){null===this.start?this.start=e:null===this.end?e.isBefore(this.start)?(this.end=this.start,this.start=e):e.isSame(this.start)?this.start=null:this.end=e:(this.start=e,this.end=null)}setRange(e,t){this.start=e,this.end=t}clear(){this.start=null,this.end=null}toArray(){return null===this.start?[]:null===this.end?[this.start]:[this.start,this.end]}toValue(){return null===this.start?"":null===this.end?this.start.toISO():`${this.start.toISO()} – ${this.end.toISO()}`}isInRange(e,t){if(null!==this.start&&null!==this.end)return e.isBetween(this.start,this.end);if(null!==this.start&&void 0!==t){const s=this.start.isBefore(t)?this.start:t,i=this.start.isBefore(t)?t:this.start;return e.isBetween(s,i)}return!1}getStart(){return this.start}getEnd(){return this.end}isPartial(){return null!==this.start&&null===this.end}isComplete(){return null!==this.start&&null!==this.end}}const g={YYYY:e=>String(e.year).padStart(4,"0"),YY:e=>String(e.year%100).padStart(2,"0"),MM:e=>String(e.month).padStart(2,"0"),M:e=>String(e.month),DD:e=>String(e.day).padStart(2,"0"),D:e=>String(e.day)},v=Object.keys(g).sort((e,t)=>t.length-e.length);function D(e,t){let s=t,i="";for(;s.length>0;){let t=!1;for(const a of v)if(s.startsWith(a)){const n=g[a];if(n){i+=n(e),s=s.slice(a.length),t=!0;break}}t||(i+=s[0],s=s.slice(1))}return i}const w={YYYY:{pattern:"(\\d{4})",extract:e=>Number(e)},YY:{pattern:"(\\d{2})",extract:e=>2e3+Number(e)},MM:{pattern:"(\\d{1,2})",extract:e=>Number(e)},M:{pattern:"(\\d{1,2})",extract:e=>Number(e)},DD:{pattern:"(\\d{1,2})",extract:e=>Number(e)},D:{pattern:"(\\d{1,2})",extract:e=>Number(e)}},_=Object.keys(w).sort((e,t)=>t.length-e.length);function x(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function S(s,i){const a=s.trim();if(""===a)return null;const{regex:n,extractors:r}=function(e){let t=e,s="^";const i=[];let a=1;for(;t.length>0;){let e=!1;for(const n of _)if(t.startsWith(n)){const r=w[n];if(r){s+=r.pattern,i.push({token:n,index:a}),a++,t=t.slice(n.length),e=!0;break}}e||(s+=x(t[0]),t=t.slice(1))}return s+="$",{regex:new RegExp(s),extractors:i}}(i),l=n.exec(a);if(!l)return null;let o=0,d=0,h=0;for(const{token:e,index:t}of r){const s=l[t];if(void 0===s)return null;const i=w[e];if(!i)return null;const a=i.extract(s);"YYYY"===e||"YY"===e?o=a:"MM"===e||"M"===e?d=a:"DD"!==e&&"D"!==e||(h=a)}return function(e,s,i){return!(s<1||s>12||i<1||i>t(e,s)||e<1)}(o,d,h)?new e(o,d,h):null}function M(t,s){const i=t.trim();if(""===i)return null;const a=[" – "," — "," - "];for(const n of a){const t=i.indexOf(n);if(-1!==t){const a=i.slice(0,t),r=i.slice(t+n.length),l=S(a,s)??e.fromISO(a.trim()),o=S(r,s)??e.fromISO(r.trim());if(l&&o)return[l,o]}}return null}function k(t,s){const i=t.trim();if(""===i)return[];const a=i.split(","),n=[];for(const r of a){const t=S(r,s)??e.fromISO(r.trim());t&&n.push(t)}return n}const Y={YYYY:4,YY:2,MM:2,M:2,DD:2,D:2},R=Object.keys(Y).sort((e,t)=>t.length-e.length);function O(e){return e.replace(/\D/g,"")}function z(e){let t=0;for(const s of e)s>="0"&&s<="9"&&t++;return t}function I(e,t){let s="",i=0;for(const a of t)if("digit"===a.type){if(i>=e.length)break;s+=e[i],i++}else{if(!(i>0))break;s+=a.char}return s}function $(e,t,s){if(s<=0)return 0;let i=0;for(let a=0;a<e.length&&a<t.length;a++){const n=t[a];if(n&&"digit"===n.type&&(i++,i===s)){let s=a+1;for(;s<t.length&&s<e.length;){const e=t[s];if(!e||"literal"!==e.type)break;s++}return s}}return e.length}function A(e){const t=function(e){const t=[];let s=e;for(;s.length>0;){let e=!1;for(const i of R)if(s.startsWith(i)){const a=Y[i];if(void 0===a)continue;for(let e=0;e<a;e++)t.push({type:"digit",char:"9"});s=s.slice(i.length),e=!0;break}e||(t.push({type:"literal",char:s[0]}),s=s.slice(1))}return t}(e),s=t.filter(e=>"digit"===e.type).length,i=t.map(e=>"digit"===e.type?"9":e.char).join("");return{apply:e=>I(O(e).slice(0,s),t),get pattern(){return i},get format(){return e},get length(){return t.length},get slots(){return t},get maxDigits(){return s}}}function C(e,t){const s=A(t),i=function(e){const{slots:t,maxDigits:s}=e;return{onInput:function(e){const i=e.target,a=i.value,n=i.selectionStart??a.length,r=z(a.slice(0,n)),l=I(O(a).slice(0,s),t);i.value=l;const o=$(l,t,r);i.setSelectionRange(o,o)},onKeyDown:function(e){const s=e.target,i=s.selectionStart??0;if(i===(s.selectionEnd??i)){if("Backspace"===e.key&&i>0){const a=i<=t.length?t[i-1]:void 0;if(a&&"literal"===a.type){e.preventDefault();let a=i-1;for(;a>0;){const e=t[a-1];if(!e||"literal"!==e.type)break;a--}if(a>0){const e=O(s.value),i=z(s.value.slice(0,a));if(i>0){const a=I(e.slice(0,i-1)+e.slice(i),t);s.value=a;const n=$(a,t,i-1);s.setSelectionRange(n,n)}}}}if("Delete"===e.key&&i<s.value.length){const a=i<t.length?t[i]:void 0;if(a&&"literal"===a.type){e.preventDefault();let a=i+1;for(;a<t.length;){const e=t[a];if(!e||"literal"!==e.type)break;a++}if(a<s.value.length){const e=O(s.value),i=z(s.value.slice(0,a)),n=I(e.slice(0,i)+e.slice(i+1),t);s.value=n;const r=$(n,t,i);s.setSelectionRange(r,r)}}}}},onPaste:function(e){var i;e.preventDefault();const a=e.target,n=O((null==(i=e.clipboardData)?void 0:i.getData("text"))??"");if(0===n.length)return;const r=a.selectionStart??0,l=a.selectionEnd??r,o=O(a.value),d=z(a.value.slice(0,r)),h=z(a.value.slice(r,l)),c=I((o.slice(0,d)+n+o.slice(d+h)).slice(0,s),t);a.value=c;const u=Math.min(d+n.length,s),m=$(c,t,u);a.setSelectionRange(m,m)}}}(s);return e.addEventListener("input",i.onInput),e.addEventListener("keydown",i.onKeyDown),e.addEventListener("paste",i.onPaste),e.value&&(e.value=s.apply(e.value)),()=>{e.removeEventListener("input",i.onInput),e.removeEventListener("keydown",i.onKeyDown),e.removeEventListener("paste",i.onPaste)}}function N(e){return Array.from({length:6},(t,s)=>function(e,t){return`<div class="${t?"rc-row rc-row--week-numbers":"rc-row"}" x-show="mg.rows.length > ${e}">\n ${t?`<div class="rc-week-number" x-text="mg.weekNumbers[${e}]"></div>`:""}<template x-for="cell in (mg.rows[${e}] || [])" :key="cell.date.toISO()">\n <div :class="dayClasses(cell)" :id="'day-' + cell.date.toISO()" :aria-selected="isSelected(cell.date)" :aria-disabled="cell.isDisabled" :title="dayTitle(cell)" role="option" tabindex="-1" @click="!cell.isDisabled && selectDate(cell.date)" @mouseenter="hoverDate = cell.date" @mouseleave="hoverDate = null" x-text="cell.date.day"></div>\n </template>\n </div>`}(s,e)).join("\n ")}function E(e){const{display:t,isDualMonth:s,isWizard:i,hasName:a,showWeekNumbers:n,hasPresets:r,isScrollable:l,scrollHeight:o}=e,d="popup"===t,h=i?"rc-calendar rc-calendar--wizard":"rc-calendar",c=i?"Birth date wizard":"Calendar",u=[];d&&u.push(function(e){return`<div class="rc-popup-header">\n ${e?'<span class="rc-popup-header__title" x-text="wizardStepLabel"></span>':'<span class="rc-popup-header__title">Select Date</span>'}\n <button class="rc-popup-header__close" @click="close()" aria-label="Close calendar"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><line x1="4" y1="4" x2="12" y2="12"/><line x1="12" y1="4" x2="4" y2="12"/></svg></button>\n</div>`}(i)),i&&u.push('<div class="rc-wizard-steps">\n <template x-for="step in wizardTotalSteps" :key="step">\n <div class="rc-wizard-step" :class="{ \'rc-wizard-step--active\': wizardStep === step, \'rc-wizard-step--done\': wizardStep > step }"></div>\n </template>\n</div>\n<div class="rc-wizard-label" x-text="wizardStepLabel"></div>\n<template x-if="wizardStep > 1">\n <button class="rc-wizard-back" @click="wizardBack()" aria-label="Go back">&#8249; Back</button>\n</template>'),u.push('<template x-if="view === \'years\'">\n <div class="rc-view-enter">\n <div class="rc-header">\n <button class="rc-header__nav" @click="prev()" :disabled="!canGoPrev" aria-label="Previous decade">&#8249;</button>\n <span class="rc-header__label" x-text="decadeLabel"></span>\n <button class="rc-header__nav" @click="next()" :disabled="!canGoNext" aria-label="Next decade">&#8250;</button>\n </div>\n <div class="rc-year-grid" role="group" :aria-label="decadeLabel">\n <template x-for="cell in yearGrid.flat()" :key="cell.year">\n <div :class="yearClasses(cell)" :aria-disabled="cell.isDisabled" tabindex="-1" @click="!cell.isDisabled && selectYear(cell.year)" x-text="cell.label"></div>\n </template>\n </div>\n </div>\n</template>'),u.push('<template x-if="view === \'months\'">\n <div class="rc-view-enter">\n <div class="rc-header">\n <button class="rc-header__nav" @click="prev()" :disabled="!canGoPrev" aria-label="Previous year">&#8249;</button>\n <button class="rc-header__label" @click="setView(\'years\')" aria-label="Change view" x-text="yearLabel"></button>\n <button class="rc-header__nav" @click="next()" :disabled="!canGoNext" aria-label="Next year">&#8250;</button>\n </div>\n <div class="rc-month-grid" role="group" :aria-label="yearLabel">\n <template x-for="cell in monthGrid.flat()" :key="cell.month">\n <div :class="monthClasses(cell)" :aria-disabled="cell.isDisabled" tabindex="-1" @click="!cell.isDisabled && selectMonth(cell.month)" x-text="cell.label"></div>\n </template>\n </div>\n </div>\n</template>'),l?u.push(function(e,t){return`<template x-if="view === 'days'">\n <div>\n <div class="rc-header rc-header--scroll-sticky">\n <span class="rc-header__label rc-header__label--scroll" x-text="scrollHeaderLabel"></span>\n </div>\n ${e?'<div class="rc-weekdays rc-weekdays--week-numbers">\n <span class="rc-weekday rc-week-label"></span>\n <template x-for="wd in weekdayHeaders" :key="wd">\n <span class="rc-weekday" x-text="wd"></span>\n </template>\n </div>':'<div class="rc-weekdays">\n <template x-for="wd in weekdayHeaders" :key="wd">\n <span class="rc-weekday" x-text="wd"></span>\n </template>\n </div>'}\n <div class="rc-months rc-months--scroll" style="max-height: ${t}px">\n <template x-for="(mg, gi) in grid" :key="mg.year + '-' + mg.month">\n <div :data-month-id="'month-' + mg.year + '-' + mg.month">\n <div class="rc-header rc-header--scroll" x-show="gi > 0">\n <span class="rc-header__label rc-header__label--scroll" x-text="monthYearLabel(gi)"></span>\n </div>\n <div class=${e?'"rc-grid rc-grid--week-numbers"':'"rc-grid"'} role="listbox" :aria-label="monthYearLabel(gi)">\n ${N(e)}\n </div>\n </div>\n </template>\n </div>\n </div>\n</template>`}(n,o)):u.push(function(e,t){return`<template x-if="view === 'days'">\n <div class="rc-months${e?"":" rc-view-enter"}"${e?" :class=\"{ 'rc-months--dual': monthCount === 2 }\"":""}>\n <template x-for="(mg, gi) in grid" :key="mg.year + '-' + mg.month">\n <div>\n <div class="rc-header">\n <button class="rc-header__nav" @click="prev()" :disabled="!canGoPrev" aria-label="Previous month"${e?" :style=\"gi > 0 ? 'visibility:hidden' : ''\"":""}>&#8249;</button>\n <button class="rc-header__label" @click="setView('months')" aria-label="Change view" x-text="monthYearLabel(gi)"></button>\n <button class="rc-header__nav" @click="next()" :disabled="!canGoNext" aria-label="Next month"${e?" :style=\"gi < grid.length - 1 ? 'visibility:hidden' : ''\"":""}>&#8250;</button>\n </div>\n ${t?'<div class="rc-weekdays rc-weekdays--week-numbers">\n <span class="rc-weekday rc-week-label"></span>\n <template x-for="wd in weekdayHeaders" :key="wd">\n <span class="rc-weekday" x-text="wd"></span>\n </template>\n </div>':'<div class="rc-weekdays">\n <template x-for="wd in weekdayHeaders" :key="wd">\n <span class="rc-weekday" x-text="wd"></span>\n </template>\n </div>'}\n <div class="rc-grid-wrapper">\n <div class=${t?'"rc-grid rc-grid--week-numbers"':'"rc-grid"'} :class="{ 'rc-grid--slide-next': _navDirection === 'next', 'rc-grid--slide-prev': _navDirection === 'prev' }" @animationend="_navDirection = ''" role="listbox" :aria-label="monthYearLabel(gi)">\n ${N(t)}\n </div>\n </div>\n </div>\n </template>\n </div>\n</template>`}(s,n)),r&&u.push('<div class="rc-presets" role="group" aria-label="Quick select">\n <template x-for="(preset, pi) in presets" :key="pi">\n <button class="rc-preset" @click="applyPreset(pi)" x-text="preset.label"></button>\n </template>\n</div>'),i&&u.push('<div class="rc-wizard-summary" x-show="wizardSummary" x-transition:enter="transition ease-out duration-200" x-transition:enter-start="opacity-0 transform translate-y-1" x-transition:enter-end="opacity-100 transform translate-y-0" x-text="wizardSummary"></div>'),a&&u.push('<template x-if="inputName">\n <template x-for="val in hiddenInputValues" :key="val">\n <input type="hidden" :name="inputName" :value="val">\n </template>\n</template>');const m=`<div class="${h}" @keydown="handleKeydown($event)" tabindex="0" :aria-activedescendant="focusedDateISO ? 'day-' + focusedDateISO : null" role="application" aria-label="${c}">\n<div class="rc-sr-only" role="status" aria-live="polite" aria-atomic="true" x-text="_statusMessage"></div>\n${u.join("\n")}\n</div>`;return d?`<div x-ref="popup" x-show="isOpen" :style="popupStyle" class="rc-popup-overlay" @click.self="close()" role="dialog" aria-modal="true" :aria-label="popupAriaLabel" x-transition:enter="transition ease-out duration-150" x-transition:enter-start="opacity-0" x-transition:enter-end="opacity-100" x-transition:leave="transition ease-in duration-100" x-transition:leave-start="opacity-100" x-transition:leave-end="opacity-0">\n${m}\n</div>`:m}function T(t){return e.fromISO(t)}function L(t){return t.map(t=>e.fromISO(t)).filter(e=>null!==e)}function K(t,s){const i={};if(t.minDate){const s=e.fromISO(t.minDate);s&&(i.minDate=s)}if(t.maxDate){const s=e.fromISO(t.maxDate);s&&(i.maxDate=s)}if(t.disabledDates&&(i.disabledDates=L(t.disabledDates)),t.disabledDaysOfWeek&&(i.disabledDaysOfWeek=t.disabledDaysOfWeek),t.enabledDates&&(i.enabledDates=L(t.enabledDates)),t.enabledDaysOfWeek&&(i.enabledDaysOfWeek=t.enabledDaysOfWeek),t.disabledMonths&&(i.disabledMonths=t.disabledMonths),t.enabledMonths&&(i.enabledMonths=t.enabledMonths),t.disabledYears&&(i.disabledYears=t.disabledYears),t.enabledYears&&(i.enabledYears=t.enabledYears),void 0!==t.minRange&&(i.minRange=t.minRange),void 0!==t.maxRange&&(i.maxRange=t.maxRange),t.rules){const e=t.rules.map(e=>function(e){const t=e.from?T(e.from):null,s=e.to?T(e.to):null,i=null!==t&&null!==s,a=Array.isArray(e.months)&&e.months.length>0;if(!i&&!a)return null;const n={};if(i&&(n.from=t,n.to=s),a&&(n.months=e.months),void 0!==e.priority&&(n.priority=e.priority),e.minDate){const t=T(e.minDate);t&&(n.minDate=t)}if(e.maxDate){const t=T(e.maxDate);t&&(n.maxDate=t)}return e.disabledDates&&(n.disabledDates=L(e.disabledDates)),e.disabledDaysOfWeek&&(n.disabledDaysOfWeek=e.disabledDaysOfWeek),e.enabledDates&&(n.enabledDates=L(e.enabledDates)),e.enabledDaysOfWeek&&(n.enabledDaysOfWeek=e.enabledDaysOfWeek),e.disabledMonths&&(n.disabledMonths=e.disabledMonths),e.enabledMonths&&(n.enabledMonths=e.enabledMonths),e.disabledYears&&(n.disabledYears=e.disabledYears),e.enabledYears&&(n.enabledYears=e.enabledYears),void 0!==e.minRange&&(n.minRange=e.minRange),void 0!==e.maxRange&&(n.maxRange=e.maxRange),n}(e)).filter(e=>null!==e);e.length>0&&(i.rules=e)}return{isDisabledDate:l(i),isRangeValid:o(i),isMonthDisabled:d(i),isYearDisabled:h(i),getDisabledReasons:m(i,s)}}const V=["minDate","maxDate","disabledDates","disabledDaysOfWeek","enabledDates","enabledDaysOfWeek","disabledMonths","enabledMonths","disabledYears","enabledYears","minRange","maxRange","rules"];function F(e){const t={};for(const s of V)void 0!==e[s]&&(t[s]=e[s]);return t}function W(t={},s){!function(t){const s=e=>console.warn(`[reach-calendar] ${e}`);if(void 0!==t.months&&(t.months<1||!Number.isInteger(t.months))&&s(`months must be a positive integer, got: ${t.months}`),t.wizard&&t.months&&t.months>=3&&s("months >= 3 (scrollable) is not compatible with wizard mode; using months: 1"),void 0!==t.firstDay&&(t.firstDay<0||t.firstDay>6)&&s(`firstDay must be 0-6, got: ${t.firstDay}`),t.minDate&&!e.fromISO(t.minDate)&&s(`invalid minDate: "${t.minDate}"`),t.maxDate&&!e.fromISO(t.maxDate)&&s(`invalid maxDate: "${t.maxDate}"`),t.minDate&&t.maxDate){const i=e.fromISO(t.minDate),a=e.fromISO(t.maxDate);i&&a&&i.isAfter(a)&&s(`minDate "${t.minDate}" is after maxDate "${t.maxDate}"`)}if(void 0!==t.minRange&&void 0!==t.maxRange&&t.minRange>t.maxRange&&s(`minRange (${t.minRange}) exceeds maxRange (${t.maxRange})`),t.wizard&&t.mode&&"single"!==t.mode&&s(`wizard mode is designed for single selection; mode "${t.mode}" may not work as expected`),t.timezone)try{Intl.DateTimeFormat(void 0,{timeZone:t.timezone})}catch{s(`invalid timezone: "${t.timezone}"`)}}(t);const i=t.mode??"single",a=t.display??"inline",n=t.format??"DD/MM/YYYY",r=t.firstDay??0;let l=t.timezone;if(l)try{Intl.DateTimeFormat(void 0,{timeZone:l})}catch{l=void 0}const o=t.wizard??!1,d=t.months??1,h=o&&d>=3?1:d,c=h>=3,u=t.scrollHeight??400,m=!!o,g=!0===o?"full":!1===o?"none":o,v="none"===g?0:"full"===g?3:2,w="full"===g||"year-month"===g?"years":"month-day"===g?"months":"days",_=t.mask??!0,x=t.showWeekNumbers??!1,Y=t.presets??[],R=t.name??"",O=t.inputId??null,z=t.inputRef??"rc-input",I=t.locale,$=t.closeOnSelect??!0,A=t.beforeSelect??null,N=t.constraintMessages,T=K(t,N);const L="multiple"===i?new f:"range"===i?new p:new b;if(t.value)if("single"===i){const s=S(t.value,n)??e.fromISO(t.value);s&&!T.isDisabledDate(s)&&L.toggle(s)}else if("range"===i){const e=M(t.value,n);if(e){let[t,s]=e;if(s.isBefore(t)){const e=t;t=s,s=e}T.isDisabledDate(t)||T.isDisabledDate(s)||!T.isRangeValid(t,s)||(L.toggle(t),L.toggle(s))}}else if("multiple"===i){const e=k(t.value,n);for(const t of e)T.isDisabledDate(t)||L.toggle(t)}const W=e.today(l),B=L.toArray(),G=B.length>0?B[0]:W,P="full"===g||"year-month"===g?new e(W.year-30,W.month,W.day):G;function H(e){const t=e.toArray();if(0===t.length)return"";const s=t[0];return"range"===i&&2===t.length?function(e,t,s){return`${D(e,s)} – ${D(t,s)}`}(s,t[1],n):"multiple"===i?function(e,t){return 0===e.length?"":e.map(e=>D(e,t)).join(", ")}(t,n):D(s,n)}return{mode:i,display:a,format:n,monthCount:h,firstDay:r,wizard:m,wizardMode:g,wizardTotalSteps:v,showWeekNumbers:x,presets:Y,inputName:R,month:P.month,year:P.year,view:m?w:"days",isOpen:"inline"===a,grid:[],monthGrid:[],yearGrid:[],inputValue:H(L),popupStyle:"popup"===a?"position:fixed;inset:0;z-index:50;":"",focusedDate:null,hoverDate:null,wizardStep:m?1:0,_wizardYear:null,_wizardMonth:null,_wizardDay:null,_navDirection:"",_selection:L,_today:W,_constraintConfig:F(t),_isDisabledDate:T.isDisabledDate,_isRangeValid:T.isRangeValid,_isMonthDisabled:T.isMonthDisabled,_isYearDisabled:T.isYearDisabled,_getDisabledReasons:T.getDisabledReasons,_inputEl:null,_detachInput:null,_syncing:!1,_suppressFocusOpen:!1,_Alpine:s??null,_autoRendered:!1,isScrollable:c,_scrollHeight:u,_scrollContainerEl:null,_scrollObserver:null,_scrollVisibleIndex:0,_selectionRev:0,_statusMessage:"",get selectedDates(){return this._selection.toArray()},get formattedValue(){return H(this._selection)},get hiddenInputValues(){return this._selection.toArray().map(e=>e.toISO())},get focusedDateISO(){return this.focusedDate?this.focusedDate.toISO():""},get inputId(){return O},get inputAriaLabel(){return"range"===i?"Select date range":"multiple"===i?"Select dates":m?"Select birth date":"Select date"},get popupAriaLabel(){return m?"Birth date wizard":"range"===i?"Date range picker":"Date picker"},get wizardStepLabel(){return this.wizard?"full"===g?1===this.wizardStep?"Select Year":2===this.wizardStep?"Select Month":"Select Day":"year-month"===g?1===this.wizardStep?"Select Year":"Select Month":"month-day"===g?1===this.wizardStep?"Select Month":"Select Day":"":""},get wizardSummary(){if(!m)return"";const t=[];if(null!==this._wizardYear&&t.push(String(this._wizardYear)),null!==this._wizardMonth){const s=new e(this._wizardYear??this.year,this._wizardMonth,1);t.push(s.format({month:"long"},I))}return null!==this._wizardDay&&t.push(String(this._wizardDay)),t.join(" · ")},get weekdayHeaders(){const e=[],t=new Date(2026,0,4);for(let s=0;s<7;s++){const i=(this.firstDay+s)%7,a=new Date(t);a.setDate(t.getDate()+i),e.push(new Intl.DateTimeFormat(I,{weekday:"short"}).format(a))}return e},init(){var e;const s=this.$el;if(!(null!==s.querySelector(".rc-calendar"))&&!1!==t.template&&(null==(e=this._Alpine)?void 0:e.initTree)){const e=document.createRange().createContextualFragment(E({display:this.display,isDualMonth:2===this.monthCount,isWizard:"none"!==this.wizardMode,hasName:!!this.inputName,showWeekNumbers:this.showWeekNumbers,hasPresets:this.presets.length>0,isScrollable:this.isScrollable,scrollHeight:this._scrollHeight})),t=Array.from(e.children).filter(e=>e instanceof HTMLElement);s.appendChild(e);for(const s of t)this._Alpine.initTree(s);this._autoRendered=!0}this._rebuildGrid(),this._rebuildMonthGrid(),this._rebuildYearGrid(),this.$watch("month",()=>{this._rebuildGrid(),this._emitNavigate(),this._announceNavigation(),this.isScrollable&&this.$nextTick(()=>{this._rebindScrollObserver()})}),this.$watch("year",()=>{this._rebuildGrid(),this._rebuildMonthGrid(),this._rebuildYearGrid(),this._emitNavigate(),this._announceNavigation(),this.isScrollable&&this.$nextTick(()=>{this._rebindScrollObserver()})}),this.$watch("view",()=>{this._emitViewChange(),this._announceViewChange()}),this.$nextTick(()=>{const e=this.$refs;e&&e[z]&&e[z]instanceof HTMLInputElement?this.bindInput(e[z]):"popup"===this.display&&console.warn(`[reach-calendar] Popup mode requires an <input x-ref="${z}"> inside the component container.`),this.isScrollable&&this._initScrollListener()})},destroy(){var e,t;if(this._scrollObserver&&(this._scrollObserver.disconnect(),this._scrollObserver=null),this._scrollContainerEl=null,this._detachInput&&(this._detachInput(),this._detachInput=null),this._inputEl=null,this._autoRendered){const s=this.$el;null==(e=s.querySelector(".rc-popup-overlay"))||e.remove(),null==(t=s.querySelector(".rc-calendar"))||t.remove(),this._autoRendered=!1}},_rebuildGrid(){this.grid=function(e,t,s,i=0,a,n){const r=[];for(let l=0;l<s;l++){let s=t+l,o=e;for(;s>12;)s-=12,o++;r.push(y(o,s,i,a,n))}return r}(this.year,this.month,this.monthCount,this.firstDay,this._today,this._isDisabledDate)},_rebuildMonthGrid(){this.monthGrid=function(t,s,i,a){const n=s??e.today(),r=a??(()=>!1),l=[];for(let o=0;o<3;o++){const s=[];for(let a=0;a<4;a++){const l=4*o+a+1,d=new e(t,l,1);s.push({month:l,year:t,label:d.format({month:"short"},i),isCurrentMonth:n.month===l&&n.year===t,isDisabled:r(t,l)})}l.push(s)}return l}(this.year,this._today,I,this._isMonthDisabled)},_rebuildYearGrid(){this.yearGrid=function(t,s,i){const a=s??e.today(),n=i??(()=>!1),r=12*Math.floor(t/12),l=[];for(let e=0;e<3;e++){const t=[];for(let s=0;s<4;s++){const i=r+4*e+s;t.push({year:i,label:String(i),isCurrentYear:a.year===i,isDisabled:n(i)})}l.push(t)}return l}(this.year,this._today,this._isYearDisabled)},dayGridItems(e){const t=[];for(let s=0;s<e.rows.length;s++){const i=e.rows[s];if(!i||0===i.length)continue;const a=i[0];t.push({isWeekNumber:!0,weekNumber:e.weekNumbers[s]??0,cell:a,key:`wn-${s}`});for(const e of i)t.push({isWeekNumber:!1,weekNumber:0,cell:e,key:e.date.toISO()})}return t},get yearLabel(){return String(this.year)},get decadeLabel(){const e=12*Math.floor(this.year/12);return`${e} – ${e+11}`},get canGoPrev(){if("days"===this.view){if(this.isScrollable)return!1;const t=new e(this.year,this.month,1).addMonths(-1);return!this._isMonthDisabled(t.year,t.month)}if("months"===this.view)return!this._isYearDisabled(this.year-1);if("years"===this.view){const e=12*Math.floor(this.year/12);for(let t=e-12;t<e;t++)if(!this._isYearDisabled(t))return!0;return!1}return!0},get canGoNext(){if("days"===this.view){if(this.isScrollable)return!1;const t=new e(this.year,this.month,1).addMonths(1);return!this._isMonthDisabled(t.year,t.month)}if("months"===this.view)return!this._isYearDisabled(this.year+1);if("years"===this.view){const e=12*Math.floor(this.year/12);for(let t=e+12;t<e+24;t++)if(!this._isYearDisabled(t))return!0;return!1}return!0},yearClasses(e){const t=this.year===e.year&&"months"===this.view;return{"rc-year":!0,"rc-year--current":e.isCurrentYear,"rc-year--selected":t,"rc-year--disabled":e.isDisabled}},monthClasses(e){const t=this.month===e.month&&"days"===this.view;return{"rc-month":!0,"rc-month--current":e.isCurrentMonth,"rc-month--selected":t,"rc-month--disabled":e.isDisabled}},monthYearLabel(t){const s=this.grid[t];if(!s)return"";return new e(s.year,s.month,1).format({month:"long",year:"numeric"},I)},dayClasses(e){this._selectionRev;const t=e.date,s=this.isSelected(t),a=this.isRangeStart(t),n=this.isRangeEnd(t),r=this.isInRange(t,this.hoverDate??void 0),l=!e.isCurrentMonth;let o=!1;return"range"!==i||null===this.hoverDate||e.isDisabled||s||!this._selection.isPartial()||(o=!this.isDateSelectableForRange(t)),{"rc-day":!0,"rc-day--today":e.isToday,"rc-day--selected":s,"rc-day--range-start":a,"rc-day--range-end":n,"rc-day--in-range":r&&!a&&!n,"rc-day--disabled":e.isDisabled,"rc-day--other-month":l,"rc-day--hidden":l&&this.monthCount>1,"rc-day--focused":null!==this.focusedDate&&this.focusedDate.isSame(t),"rc-day--range-invalid":o}},dayTitle(e){return e.isDisabled?this._getDisabledReasons(e.date).join("; "):""},bindInput(e){this._detachInput&&(this._detachInput(),this._detachInput=null),this._inputEl=e,e.value=this.inputValue,_&&(this._detachInput=C(e,n),this.inputValue=e.value);const t=()=>{this._syncing||(this.inputValue=e.value)};e.addEventListener("input",t);const s=()=>this.handleFocus(),i=()=>this.handleBlur();e.addEventListener("focus",s),e.addEventListener("blur",i),"popup"===a&&(e.setAttribute("role","combobox"),e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-expanded",String(this.isOpen)),e.setAttribute("autocomplete","off"),O&&!e.id&&(e.id=O),e.getAttribute("aria-label")||e.setAttribute("aria-label",this.inputAriaLabel));const r=this._detachInput;this._detachInput=()=>{null==r||r(),e.removeEventListener("input",t),e.removeEventListener("focus",s),e.removeEventListener("blur",i),"popup"===a&&(e.removeAttribute("role"),e.removeAttribute("aria-haspopup"),e.removeAttribute("aria-expanded"),e.removeAttribute("autocomplete"))},e.placeholder||(e.placeholder=n.toLowerCase())},handleInput(e){const t=e.target;this.inputValue=t.value},handleFocus(){this._suppressFocusOpen?this._suppressFocusOpen=!1:this.open()},handleBlur(){const t=this._inputEl?this._inputEl.value:this.inputValue;if(!t.trim())return this._selection.toArray().length>0&&(this._selection.clear(),this._selectionRev++,this._emitChange()),void this._syncInputFromSelection();let s=!1;if("single"===i){const i=S(t,n)??e.fromISO(t);i&&!this._isDisabledDate(i)&&(this._selection.clear(),this._selection.toggle(i),this.month=i.month,this.year=i.year,s=!0)}else if("range"===i){const e=M(t,n);if(e){let[t,i]=e;if(i.isBefore(t)){const e=t;t=i,i=e}this._isDisabledDate(t)||this._isDisabledDate(i)||!this._isRangeValid(t,i)||(this._selection.clear(),this._selection.toggle(t),this._selection.toggle(i),this.month=t.month,this.year=t.year,s=!0)}}else if("multiple"===i){const e=k(t,n).filter(e=>!this._isDisabledDate(e));if(e.length>0){this._selection.clear();for(const s of e)this._selection.toggle(s);const t=e[0];this.month=t.month,this.year=t.year,s=!0}}s&&(this._selectionRev++,this._emitChange()),this._syncInputFromSelection()},_syncInputFromSelection(){this._syncing=!0,this.inputValue=this.formattedValue,this._inputEl&&(this._inputEl.value=this.inputValue),this._syncing=!1},_announce(e){this._statusMessage="",this.$nextTick(()=>{this._statusMessage=e})},_announceNavigation(){if("days"===this.view)if(this.monthCount>1&&!this.isScrollable){const e=[];for(let t=0;t<this.grid.length;t++)e.push(this.monthYearLabel(t));this._announce(e.join(" – "))}else this._announce(this.monthYearLabel(0));else"months"===this.view?this._announce("Year: "+this.year):"years"===this.view&&this._announce("Decade: "+this.decadeLabel)},_announceViewChange(){"days"===this.view?this._announce(this.monthYearLabel(0)):"months"===this.view?this._announce("Select month, "+this.year):"years"===this.view&&this._announce("Select year, "+this.decadeLabel)},_emitChange(){this.$dispatch("calendar:change",{value:this._selection.toValue(),dates:this._selection.toArray().map(e=>e.toISO()),formatted:this.formattedValue})},_emitNavigate(){this.$dispatch("calendar:navigate",{year:this.year,month:this.month,view:this.view})},_emitViewChange(){this.$dispatch("calendar:view-change",{view:this.view,year:this.year,month:this.month})},prev(){if(this._navDirection="prev","days"===this.view){if(this.isScrollable)return;const t=new e(this.year,this.month,1).addMonths(-1);this.month=t.month,this.year=t.year}else"months"===this.view?this.year--:"years"===this.view&&(this.year-=12)},next(){if(this._navDirection="next","days"===this.view){if(this.isScrollable)return;const t=new e(this.year,this.month,1).addMonths(1);this.month=t.month,this.year=t.year}else"months"===this.view?this.year++:"years"===this.view&&(this.year+=12)},goToToday(){this.month=this._today.month,this.year=this._today.year,this.view="days"},selectDate(t){const s="string"==typeof t?e.fromISO(t):t;if(!s)return;if(this._isDisabledDate(s))return;if("range"===i){const e=this._selection,t=e.getStart();if(e.isPartial()&&t&&!s.isSame(t)){let e=t,i=s;if(i.isBefore(e)){const t=e;e=i,i=t}if(!this._isRangeValid(e,i))return}}if(A){const e=this._selection.isSelected(s)?"deselect":"select";if(!1===A(s,{mode:i,selectedDates:this._selection.toArray(),action:e}))return}const n=this._selection.isSelected(s),r="range"===i&&this._selection.isPartial();this._selection.toggle(s),m&&(this._wizardDay=s.day),this._selectionRev++,this._emitChange(),this._syncInputFromSelection();const l=s.format({weekday:"long",month:"long",day:"numeric",year:"numeric"},I);if("single"===i)this._announce(l+" selected");else if("multiple"===i){const e=this._selection.toArray().length;n?this._announce(l+" deselected. "+e+" dates selected"):this._announce(l+" selected. "+e+" dates selected")}else if("range"===i){const e=this._selection;if(e.isPartial())this._announce("Range start: "+l+". Select end date");else if(r){const t=e.toArray();if(2===t.length){const e=t[0].format({weekday:"long",month:"long",day:"numeric",year:"numeric"},I),s=t[1].format({weekday:"long",month:"long",day:"numeric",year:"numeric"},I);this._announce("Range: "+e+" to "+s)}}}if($&&"popup"===a&&this.isOpen){("single"===i||"range"===i&&!this._selection.isPartial()||"multiple"===i)&&this.close()}},isSelected(e){return this._selection.isSelected(e)},isInRange(e,t){return"range"===i&&this._selection.isInRange(e,t)},isRangeStart(e){if("range"!==i)return!1;const t=this._selection.getStart();return null!==t&&e.isSame(t)},isRangeEnd(e){if("range"!==i)return!1;const t=this._selection.getEnd();return null!==t&&e.isSame(t)},isDateSelectableForRange(e){if("range"!==i)return!1;if(this._isDisabledDate(e))return!1;const t=this._selection;if(!t.isPartial())return!0;const s=t.getStart();if(!s)return!0;if(e.isSame(s))return!0;let a=s,n=e;if(n.isBefore(a)){const e=a;a=n,n=e}return this._isRangeValid(a,n)},getDisabledReason(t){const s="string"==typeof t?e.fromISO(t):t;return s?this._getDisabledReasons(s):[]},clearSelection(){this._selection.clear(),this._selectionRev++,this._emitChange(),this._syncInputFromSelection(),this._announce("Selection cleared")},setValue(t){this._selection.clear();const s=[];if("string"==typeof t){const i=e.fromISO(t)??S(t,n);i&&!this._isDisabledDate(i)&&s.push(i)}else if(Array.isArray(t))for(const i of t){const t="string"==typeof i?e.fromISO(i)??S(i,n):i;t&&!this._isDisabledDate(t)&&s.push(t)}else t instanceof e&&(this._isDisabledDate(t)||s.push(t));if("range"===i&&2===s.length){let[e,t]=s;if(t.isBefore(e)){const s=e;e=t,t=s}if(!this._isRangeValid(e,t))return this._selectionRev++,this._emitChange(),void this._syncInputFromSelection();this._selection.setRange(e,t)}else for(const e of s)this._selection.toggle(e);const a=this._selection.toArray();if(a.length>0){const e=a[0];this.month=e.month,this.year=e.year}this._selectionRev++,this._emitChange(),this._syncInputFromSelection()},clear(){this.clearSelection()},goTo(e,t){this.year=e,void 0!==t&&(this.month=t),this.view="days",this.isScrollable&&(this._rebuildGrid(),this.$nextTick(()=>{this._rebindScrollObserver(),this._scrollToMonth(e,t??this.month)}))},getSelection(){return[...this._selection.toArray()]},applyPreset(e){const t=this.presets[e];if(!t)return;const[s,a]=t.value();"single"===i?this.setValue(s):this.setValue([s,a]),"popup"===this.display&&$&&this.close()},updateConstraints(e){const t={...this._constraintConfig};for(const i of V)i in e&&(t[i]=e[i]);this._constraintConfig=t;const s=K(t,N);this._isDisabledDate=s.isDisabledDate,this._isRangeValid=s.isRangeValid,this._isMonthDisabled=s.isMonthDisabled,this._isYearDisabled=s.isYearDisabled,this._getDisabledReasons=s.getDisabledReasons,this._rebuildGrid(),this._rebuildMonthGrid(),this._rebuildYearGrid(),this.isScrollable&&this.$nextTick(()=>{this._rebindScrollObserver()})},setView(e){this.view=e},selectMonth(t){if(!this._isMonthDisabled(this.year,t)){if(this.month=t,this._wizardMonth=t,"year-month"===g)return this.wizardStep=v,void this.selectDate(new e(this.year,t,1));this.view="days",m&&(this.wizardStep="month-day"===g?2:3)}},selectYear(e){this._isYearDisabled(e)||(this.year=e,this._wizardYear=e,this.view="months",this.wizard&&(this.wizardStep=2))},wizardBack(){this.wizard&&("full"===g?3===this.wizardStep?(this.wizardStep=2,this.view="months",this._wizardMonth=null,this._wizardDay=null):2===this.wizardStep&&(this.wizardStep=1,this.view="years",this._wizardYear=null,this._wizardMonth=null):"year-month"===g?2===this.wizardStep&&(this.wizardStep=1,this.view="years",this._wizardYear=null,this._wizardMonth=null):"month-day"===g&&2===this.wizardStep&&(this.wizardStep=1,this.view="months",this._wizardMonth=null))},open(){var e;"popup"===this.display&&(m&&(this.wizardStep=1,this.view=w,this._wizardYear=null,this._wizardMonth=null,this._wizardDay=null,"month-day"!==g&&(this.year=this._today.year-30,this._rebuildYearGrid())),this.isOpen=!0,null==(e=this._inputEl)||e.setAttribute("aria-expanded","true"),this.$dispatch("calendar:open"),this.$nextTick(()=>{}))},close(){var e;"popup"===this.display&&(this.isOpen=!1,null==(e=this._inputEl)||e.setAttribute("aria-expanded","false"),this.$dispatch("calendar:close"))},toggle(){this.isOpen?this.close():this.open()},handleKeydown(t){if("Escape"===t.key)return t.preventDefault(),t.stopPropagation(),this.wizard&&this.wizardStep>1?void this.wizardBack():"months"===this.view||"years"===this.view?void(this.view="days"):void("popup"===a&&this.isOpen&&(this.close(),this._inputEl&&(this._suppressFocusOpen=!0,this._inputEl.focus())));if("days"===this.view)switch(t.key){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":case"PageDown":case"PageUp":case"Home":case"End":if(t.preventDefault(),!this.focusedDate){const t=this._selection.toArray();t.length>0?this.focusedDate=t[0]:this.focusedDate=new e(this.year,this.month,1)}return void("ArrowRight"===t.key?this._moveFocus(1):"ArrowLeft"===t.key?this._moveFocus(-1):"ArrowDown"===t.key?this._moveFocus(7):"ArrowUp"===t.key?this._moveFocus(-7):"PageDown"===t.key?this._moveFocusByMonths(t.shiftKey?12:1):"PageUp"===t.key?this._moveFocusByMonths(t.shiftKey?-12:-1):"Home"===t.key?this._setFocusedDate(new e(this.year,this.month,1)):"End"===t.key&&this._setFocusedDate(new e(this.year,this.month,1).endOfMonth()));case"Enter":case" ":return void(this.focusedDate&&(t.preventDefault(),this.selectDate(this.focusedDate)))}},_moveFocus(e){if(!this.focusedDate)return;let t=this.focusedDate.addDays(e),s=0;for(;this._isDisabledDate(t)&&s<31;)t=t.addDays(e>0?1:-1),s++;this._isDisabledDate(t)||this._setFocusedDate(t)},_moveFocusByMonths(e){if(!this.focusedDate)return;const t=this.focusedDate.addMonths(e);this._setFocusedDate(t)},_setFocusedDate(e){this.focusedDate=e,this.isScrollable?this.$nextTick(()=>{this._scrollToMonth(e.year,e.month)}):e.month===this.month&&e.year===this.year||(this.month=e.month,this.year=e.year)},get scrollHeaderLabel(){if(!this.isScrollable)return"";const t=this.grid[this._scrollVisibleIndex];if(!t)return"";return new e(t.year,t.month,1).format({month:"long",year:"numeric"},I)},_initScrollListener(){if("undefined"==typeof IntersectionObserver)return;const e=this.$el.querySelector(".rc-months--scroll");if(!e)return;this._scrollContainerEl=e;const t=e.querySelectorAll("[data-month-id]");if(0===t.length)return;const s=new Map;t.forEach((e,t)=>s.set(e,t));const i=new Set,a=new IntersectionObserver(e=>{for(const t of e){const e=s.get(t.target);void 0!==e&&(t.isIntersecting?i.add(e):i.delete(e))}if(i.size>0){const e=Math.min(...i);this._scrollVisibleIndex!==e&&(this._scrollVisibleIndex=e)}},{root:e,rootMargin:"0px 0px -90% 0px",threshold:0});t.forEach(e=>a.observe(e)),this._scrollObserver=a},_rebindScrollObserver(){this._scrollObserver&&(this._scrollObserver.disconnect(),this._scrollObserver=null),this._initScrollListener()},_scrollToMonth(e,t){if(!this._scrollContainerEl)return;const s=this._scrollContainerEl.querySelector(`[data-month-id="month-${e}-${t}"]`);s&&s.scrollIntoView({behavior:"smooth",block:"start"})}}}let B={};function G(e){e.data("calendar",(t={})=>W({...B,...t},e))}G.defaults=e=>{B={...B,...e}},G.getDefaults=()=>({...B}),G.resetDefaults=()=>{B={}};let P=!1;function H(){P||window.Alpine&&(window.Alpine.plugin(G),P=!0)}window.Alpine&&H(),document.addEventListener("alpine:init",()=>{H()})}();
1
+ !function(){"use strict";class e{constructor(e,t,s){this.year=e,this.month=t,this.day=s}static today(t){const s=new Date;return t?e.fromNativeDate(s,t):new e(s.getFullYear(),s.getMonth()+1,s.getDate())}static fromNativeDate(t,s){if(s){const a=new Intl.DateTimeFormat("en-US",{timeZone:s,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(t);let i=0,n=0,r=0;for(const e of a)"year"===e.type?i=Number(e.value):"month"===e.type?n=Number(e.value):"day"===e.type&&(r=Number(e.value));return new e(i,n,r)}return new e(t.getFullYear(),t.getMonth()+1,t.getDate())}static fromISO(s){const a=/^(\d{4})-(\d{2})-(\d{2})$/.exec(s);if(!a)return null;const i=Number(a[1]),n=Number(a[2]),r=Number(a[3]);return n<1||n>12||r<1||r>t(i,n)?null:new e(i,n,r)}toNativeDate(){return new Date(this.year,this.month-1,this.day)}toISO(){return`${String(this.year).padStart(4,"0")}-${String(this.month).padStart(2,"0")}-${String(this.day).padStart(2,"0")}`}toKey(){return this.toISO()}isSame(e){return this.year===e.year&&this.month===e.month&&this.day===e.day}isBefore(e){return this.year!==e.year?this.year<e.year:this.month!==e.month?this.month<e.month:this.day<e.day}isAfter(e){return this.year!==e.year?this.year>e.year:this.month!==e.month?this.month>e.month:this.day>e.day}isBetween(e,t){return!this.isBefore(e)&&!this.isAfter(t)}diffDays(e){const t=Date.UTC(this.year,this.month-1,this.day),s=Date.UTC(e.year,e.month-1,e.day);return Math.round((s-t)/864e5)}addDays(t){const s=this.toNativeDate();return s.setDate(s.getDate()+t),e.fromNativeDate(s)}addMonths(s){let a=this.month-1+s;const i=this.year+Math.floor(a/12);a=(a%12+12)%12;const n=t(i,a+1),r=Math.min(this.day,n);return new e(i,a+1,r)}addYears(s){const a=t(this.year+s,this.month),i=Math.min(this.day,a);return new e(this.year+s,this.month,i)}startOfMonth(){return new e(this.year,this.month,1)}endOfMonth(){return new e(this.year,this.month,t(this.year,this.month))}format(e,t){const s=this.toNativeDate();return new Intl.DateTimeFormat(t,e).format(s)}}function t(e,t){return new Date(e,t,0).getDate()}function s(e){const t=new Date(Date.UTC(e.year,e.month-1,e.day)),s=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-s);const a=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-a.getTime())/864e5+1)/7)}function a(e){return{disabledKeys:e.disabledDates?new Set(e.disabledDates.map(e=>e.toKey())):void 0,disabledDays:e.disabledDaysOfWeek?new Set(e.disabledDaysOfWeek):void 0,enabledKeys:e.enabledDates?new Set(e.enabledDates.map(e=>e.toKey())):void 0,enabledDays:e.enabledDaysOfWeek?new Set(e.enabledDaysOfWeek):void 0,disabledMonths:e.disabledMonths?new Set(e.disabledMonths):void 0,enabledMonths:e.enabledMonths?new Set(e.enabledMonths):void 0,disabledYears:e.disabledYears?new Set(e.disabledYears):void 0,enabledYears:e.enabledYears?new Set(e.enabledYears):void 0}}function i(e,t,s,a){if(t&&e.isBefore(t))return!0;if(s&&e.isAfter(s))return!0;if(a.enabledKeys&&a.enabledKeys.has(e.toKey()))return!1;if(a.enabledYears&&!a.enabledYears.has(e.year))return!0;if(a.disabledYears&&a.disabledYears.has(e.year))return!0;if(a.enabledMonths&&!a.enabledMonths.has(e.month))return!0;if(a.disabledMonths&&a.disabledMonths.has(e.month))return!0;const i=void 0!==a.enabledDays||void 0!==a.disabledDays?e.toNativeDate().getDay():-1;return!(!a.enabledDays||a.enabledDays.has(i))||(!(!a.disabledKeys||!a.disabledKeys.has(e.toKey()))||!(!a.disabledDays||!a.disabledDays.has(i)))}function n(e,t){return e.from&&e.to?t.isBetween(e.from,e.to):!!e.recurringMonths&&e.recurringMonths.has(t.month)}function r(e,t){let s;for(const a of e)n(a,t)&&(!s||a.priority>s.priority)&&(s=a);return s}function l(e){const{minDate:t,maxDate:s,rules:n}=e,l=a(e),o=null==n?void 0:n.map((e,t)=>({from:e.from,to:e.to,recurringMonths:e.months?new Set(e.months):void 0,minDate:e.minDate,maxDate:e.maxDate,minRange:e.minRange,maxRange:e.maxRange,sets:a(e),hasMinDate:void 0!==e.minDate,hasMaxDate:void 0!==e.maxDate,priority:e.priority??0,originalIndex:t}));return o&&0!==o.length?e=>{const a=r(o,e);if(!a)return i(e,t,s,l);return i(e,a.hasMinDate?a.minDate:t,a.hasMaxDate?a.maxDate:s,{disabledKeys:void 0!==a.sets.disabledKeys?a.sets.disabledKeys:l.disabledKeys,disabledDays:void 0!==a.sets.disabledDays?a.sets.disabledDays:l.disabledDays,enabledKeys:void 0!==a.sets.enabledKeys?a.sets.enabledKeys:l.enabledKeys,enabledDays:void 0!==a.sets.enabledDays?a.sets.enabledDays:l.enabledDays,disabledMonths:void 0!==a.sets.disabledMonths?a.sets.disabledMonths:l.disabledMonths,enabledMonths:void 0!==a.sets.enabledMonths?a.sets.enabledMonths:l.enabledMonths,disabledYears:void 0!==a.sets.disabledYears?a.sets.disabledYears:l.disabledYears,enabledYears:void 0!==a.sets.enabledYears?a.sets.enabledYears:l.enabledYears})}:e=>i(e,t,s,l)}function o(e){const{minRange:t,maxRange:s,rules:i}=e;if(void 0===t&&void 0===s&&(!i||i.every(e=>void 0===e.minRange&&void 0===e.maxRange)))return()=>!0;const n=null==i?void 0:i.map((e,t)=>({from:e.from,to:e.to,recurringMonths:e.months?new Set(e.months):void 0,minDate:e.minDate,maxDate:e.maxDate,minRange:e.minRange,maxRange:e.maxRange,sets:a(e),hasMinDate:void 0!==e.minDate,hasMaxDate:void 0!==e.maxDate,priority:e.priority??0,originalIndex:t}));return(e,a)=>{let i=t,l=s;if(n){const t=r(n,e);t&&(void 0!==t.minRange&&(i=t.minRange),void 0!==t.maxRange&&(l=t.maxRange))}const o=e.diffDays(a)+1;return!(void 0!==i&&o<i)&&!(void 0!==l&&o>l)}}function d(t){const{minDate:s,maxDate:a}=t,i=t.disabledMonths?new Set(t.disabledMonths):void 0,n=t.enabledMonths?new Set(t.enabledMonths):void 0,r=t.disabledYears?new Set(t.disabledYears):void 0,l=t.enabledYears?new Set(t.enabledYears):void 0;return(t,o)=>{if(s){if(new e(t,o,1).endOfMonth().isBefore(s))return!0}if(a){if(new e(t,o,1).isAfter(a))return!0}return!(!l||l.has(t))||(!(!r||!r.has(t))||(!(!n||n.has(o))||!(!i||!i.has(o))))}}function h(t){const{minDate:s,maxDate:a}=t,i=t.disabledYears?new Set(t.disabledYears):void 0,n=t.enabledYears?new Set(t.enabledYears):void 0;return t=>{if(s){if(new e(t,12,31).isBefore(s))return!0}if(a){if(new e(t,1,1).isAfter(a))return!0}return!(!n||n.has(t))||!(!i||!i.has(t))}}const c={beforeMinDate:"Before the earliest available date",afterMaxDate:"After the latest available date",disabledDate:"This date is not available",disabledDayOfWeek:"This day of the week is not available",disabledMonth:"This month is not available",disabledYear:"This year is not available",notEnabledDate:"This date is not available",notEnabledDayOfWeek:"This day of the week is not available",notEnabledMonth:"This month is not available",notEnabledYear:"This year is not available"};function u(e,t,s,a,i){const n=[];if(t&&e.isBefore(t))return n.push(i.beforeMinDate),n;if(s&&e.isAfter(s))return n.push(i.afterMaxDate),n;if(a.enabledKeys&&a.enabledKeys.has(e.toKey()))return n;if(a.enabledYears&&!a.enabledYears.has(e.year))return n.push(i.notEnabledYear),n;if(a.disabledYears&&a.disabledYears.has(e.year))return n.push(i.disabledYear),n;if(a.enabledMonths&&!a.enabledMonths.has(e.month))return n.push(i.notEnabledMonth),n;if(a.disabledMonths&&a.disabledMonths.has(e.month))return n.push(i.disabledMonth),n;const r=void 0!==a.enabledDays||void 0!==a.disabledDays?e.toNativeDate().getDay():-1;return a.enabledDays&&!a.enabledDays.has(r)&&n.push(i.notEnabledDayOfWeek),a.disabledKeys&&a.disabledKeys.has(e.toKey())&&n.push(i.disabledDate),a.disabledDays&&a.disabledDays.has(r)&&n.push(i.disabledDayOfWeek),n}function m(e,t){const{minDate:s,maxDate:i,rules:n}=e,l={...c,...t},o=a(e),d=null==n?void 0:n.map((e,t)=>({from:e.from,to:e.to,recurringMonths:e.months?new Set(e.months):void 0,minDate:e.minDate,maxDate:e.maxDate,minRange:e.minRange,maxRange:e.maxRange,sets:a(e),hasMinDate:void 0!==e.minDate,hasMaxDate:void 0!==e.maxDate,priority:e.priority??0,originalIndex:t}));return d&&0!==d.length?e=>{const t=r(d,e);if(!t)return u(e,s,i,o,l);return u(e,t.hasMinDate?t.minDate:s,t.hasMaxDate?t.maxDate:i,{disabledKeys:void 0!==t.sets.disabledKeys?t.sets.disabledKeys:o.disabledKeys,disabledDays:void 0!==t.sets.disabledDays?t.sets.disabledDays:o.disabledDays,enabledKeys:void 0!==t.sets.enabledKeys?t.sets.enabledKeys:o.enabledKeys,enabledDays:void 0!==t.sets.enabledDays?t.sets.enabledDays:o.enabledDays,disabledMonths:void 0!==t.sets.disabledMonths?t.sets.disabledMonths:o.disabledMonths,enabledMonths:void 0!==t.sets.enabledMonths?t.sets.enabledMonths:o.enabledMonths,disabledYears:void 0!==t.sets.disabledYears?t.sets.disabledYears:o.disabledYears,enabledYears:void 0!==t.sets.enabledYears?t.sets.enabledYears:o.enabledYears},l)}:e=>u(e,s,i,o,l)}function y(t,a,i=1,n,r){const l=n??e.today(),o=r??(()=>!1),d=new e(t,a,1),h=(d.toNativeDate().getDay()-i+7)%7,c=d.addDays(-h),u=[],m=[];for(let e=0;e<6;e++){const i=[];for(let s=0;s<7;s++){const n=7*e+s,r=c.addDays(n);i.push({date:r,isCurrentMonth:r.month===a&&r.year===t,isToday:r.isSame(l),isDisabled:o(r)})}const n=i[0];n&&m.push(s(n.date)),u.push(i)}return{year:t,month:a,rows:u,weekNumbers:m}}class b{constructor(e){this.selected=null,this.selected=e??null}isSelected(e){return null!==this.selected&&this.selected.isSame(e)}toggle(e){null!==this.selected&&this.selected.isSame(e)?this.selected=null:this.selected=e}clear(){this.selected=null}toArray(){return null!==this.selected?[this.selected]:[]}toValue(){return null!==this.selected?this.selected.toISO():""}getSelected(){return this.selected}}class f{constructor(e){if(this.keys=new Set,e)for(const t of e)this.keys.add(t.toKey())}isSelected(e){return this.keys.has(e.toKey())}toggle(e){const t=e.toKey();this.keys.has(t)?this.keys.delete(t):this.keys.add(t)}clear(){this.keys.clear()}toArray(){return[...this.keys].sort().map(t=>e.fromISO(t))}toValue(){return[...this.keys].sort().join(", ")}get count(){return this.keys.size}}class p{constructor(e,t){this.start=null,this.end=null,this.start=e??null,this.end=t??null}isSelected(e){return!(null===this.start||!this.start.isSame(e))||!(null===this.end||!this.end.isSame(e))}toggle(e){null===this.start?this.start=e:null===this.end?e.isBefore(this.start)?(this.end=this.start,this.start=e):e.isSame(this.start)?this.start=null:this.end=e:(this.start=e,this.end=null)}setRange(e,t){this.start=e,this.end=t}clear(){this.start=null,this.end=null}toArray(){return null===this.start?[]:null===this.end?[this.start]:[this.start,this.end]}toValue(){return null===this.start?"":null===this.end?this.start.toISO():`${this.start.toISO()} – ${this.end.toISO()}`}isInRange(e,t){if(null!==this.start&&null!==this.end)return e.isBetween(this.start,this.end);if(null!==this.start&&void 0!==t){const s=this.start.isBefore(t)?this.start:t,a=this.start.isBefore(t)?t:this.start;return e.isBetween(s,a)}return!1}getStart(){return this.start}getEnd(){return this.end}isPartial(){return null!==this.start&&null===this.end}isComplete(){return null!==this.start&&null!==this.end}}const v={YYYY:e=>String(e.year).padStart(4,"0"),YY:e=>String(e.year%100).padStart(2,"0"),MM:e=>String(e.month).padStart(2,"0"),M:e=>String(e.month),DD:e=>String(e.day).padStart(2,"0"),D:e=>String(e.day)},g=Object.keys(v).sort((e,t)=>t.length-e.length);function D(e,t){let s=t,a="";for(;s.length>0;){let t=!1;for(const i of g)if(s.startsWith(i)){const n=v[i];if(n){a+=n(e),s=s.slice(i.length),t=!0;break}}t||(a+=s[0],s=s.slice(1))}return a}const _={YYYY:{pattern:"(\\d{4})",extract:e=>Number(e)},YY:{pattern:"(\\d{2})",extract:e=>2e3+Number(e)},MM:{pattern:"(\\d{1,2})",extract:e=>Number(e)},M:{pattern:"(\\d{1,2})",extract:e=>Number(e)},DD:{pattern:"(\\d{1,2})",extract:e=>Number(e)},D:{pattern:"(\\d{1,2})",extract:e=>Number(e)}},w=Object.keys(_).sort((e,t)=>t.length-e.length);function x(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function S(s,a){const i=s.trim();if(""===i)return null;const{regex:n,extractors:r}=function(e){let t=e,s="^";const a=[];let i=1;for(;t.length>0;){let e=!1;for(const n of w)if(t.startsWith(n)){const r=_[n];if(r){s+=r.pattern,a.push({token:n,index:i}),i++,t=t.slice(n.length),e=!0;break}}e||(s+=x(t[0]),t=t.slice(1))}return s+="$",{regex:new RegExp(s),extractors:a}}(a),l=n.exec(i);if(!l)return null;let o=0,d=0,h=0;for(const{token:e,index:t}of r){const s=l[t];if(void 0===s)return null;const a=_[e];if(!a)return null;const i=a.extract(s);"YYYY"===e||"YY"===e?o=i:"MM"===e||"M"===e?d=i:"DD"!==e&&"D"!==e||(h=i)}return function(e,s,a){return!(s<1||s>12||a<1||a>t(e,s)||e<1)}(o,d,h)?new e(o,d,h):null}function M(t,s){const a=t.trim();if(""===a)return null;const i=[" – "," — "," - "];for(const n of i){const t=a.indexOf(n);if(-1!==t){const i=a.slice(0,t),r=a.slice(t+n.length),l=S(i,s)??e.fromISO(i.trim()),o=S(r,s)??e.fromISO(r.trim());if(l&&o)return[l,o]}}return null}function k(t,s){const a=t.trim();if(""===a)return[];const i=a.split(","),n=[];for(const r of i){const t=S(r,s)??e.fromISO(r.trim());t&&n.push(t)}return n}const Y={YYYY:4,YY:2,MM:2,M:2,DD:2,D:2},R=Object.keys(Y).sort((e,t)=>t.length-e.length);function O(e){return e.replace(/\D/g,"")}function z(e){let t=0;for(const s of e)s>="0"&&s<="9"&&t++;return t}function I(e,t){let s="",a=0;for(const i of t)if("digit"===i.type){if(a>=e.length)break;s+=e[a],a++}else{if(!(a>0))break;s+=i.char}return s}function $(e,t,s){if(s<=0)return 0;let a=0;for(let i=0;i<e.length&&i<t.length;i++){const n=t[i];if(n&&"digit"===n.type&&(a++,a===s)){let s=i+1;for(;s<t.length&&s<e.length;){const e=t[s];if(!e||"literal"!==e.type)break;s++}return s}}return e.length}function E(e){const t=function(e){const t=[];let s=e;for(;s.length>0;){let e=!1;for(const a of R)if(s.startsWith(a)){const i=Y[a];if(void 0===i)continue;for(let e=0;e<i;e++)t.push({type:"digit",char:"9"});s=s.slice(a.length),e=!0;break}e||(t.push({type:"literal",char:s[0]}),s=s.slice(1))}return t}(e),s=t.filter(e=>"digit"===e.type).length,a=t.map(e=>"digit"===e.type?"9":e.char).join("");return{apply:e=>I(O(e).slice(0,s),t),get pattern(){return a},get format(){return e},get length(){return t.length},get slots(){return t},get maxDigits(){return s}}}function A(e,t){const s=E(t),a=function(e){const{slots:t,maxDigits:s}=e;return{onInput:function(e){const a=e.target,i=a.value,n=a.selectionStart??i.length,r=z(i.slice(0,n)),l=I(O(i).slice(0,s),t);a.value=l;const o=$(l,t,r);a.setSelectionRange(o,o)},onKeyDown:function(e){const s=e.target,a=s.selectionStart??0;if(a===(s.selectionEnd??a)){if("Backspace"===e.key&&a>0){const i=a<=t.length?t[a-1]:void 0;if(i&&"literal"===i.type){e.preventDefault();let i=a-1;for(;i>0;){const e=t[i-1];if(!e||"literal"!==e.type)break;i--}if(i>0){const e=O(s.value),a=z(s.value.slice(0,i));if(a>0){const i=I(e.slice(0,a-1)+e.slice(a),t);s.value=i;const n=$(i,t,a-1);s.setSelectionRange(n,n)}}}}if("Delete"===e.key&&a<s.value.length){const i=a<t.length?t[a]:void 0;if(i&&"literal"===i.type){e.preventDefault();let i=a+1;for(;i<t.length;){const e=t[i];if(!e||"literal"!==e.type)break;i++}if(i<s.value.length){const e=O(s.value),a=z(s.value.slice(0,i)),n=I(e.slice(0,a)+e.slice(a+1),t);s.value=n;const r=$(n,t,a);s.setSelectionRange(r,r)}}}}},onPaste:function(e){var a;e.preventDefault();const i=e.target,n=O((null==(a=e.clipboardData)?void 0:a.getData("text"))??"");if(0===n.length)return;const r=i.selectionStart??0,l=i.selectionEnd??r,o=O(i.value),d=z(i.value.slice(0,r)),h=z(i.value.slice(r,l)),c=I((o.slice(0,d)+n+o.slice(d+h)).slice(0,s),t);i.value=c;const u=Math.min(d+n.length,s),m=$(c,t,u);i.setSelectionRange(m,m)}}}(s);return e.addEventListener("input",a.onInput),e.addEventListener("keydown",a.onKeyDown),e.addEventListener("paste",a.onPaste),e.value&&(e.value=s.apply(e.value)),()=>{e.removeEventListener("input",a.onInput),e.removeEventListener("keydown",a.onKeyDown),e.removeEventListener("paste",a.onPaste)}}function C(e){return null==e?()=>{}:"function"==typeof e?e:t=>e[t.toISO()]}function N(e){return Array.from({length:6},(t,s)=>function(e,t){return`<div class="${t?"rc-row rc-row--week-numbers":"rc-row"}" x-show="mg.rows.length > ${e}">\n ${t?`<div class="rc-week-number" x-text="mg.weekNumbers[${e}]"></div>`:""}<template x-for="cell in (mg.rows[${e}] || [])" :key="cell.date.toISO()">\n <div :class="dayClasses(cell)" :style="dayStyle(cell)" :id="'day-' + cell.date.toISO()" :aria-selected="isSelected(cell.date)" :aria-disabled="cell.isDisabled" :title="dayTitle(cell)" role="option" tabindex="-1" @click="!cell.isDisabled && selectDate(cell.date)" @mouseenter="hoverDate = cell.date" @mouseleave="hoverDate = null"><span class="rc-day__number" x-text="cell.date.day"></span><template x-if="dayMeta(cell)?.label"><span class="rc-day__label" x-text="dayMeta(cell).label"></span></template><template x-if="dayMeta(cell)?.availability === 'available' && !dayMeta(cell)?.label"><span class="rc-day__dot" aria-hidden="true"></span></template></div>\n </template>\n </div>`}(s,e)).join("\n ")}function T(e){const{display:t,isDualMonth:s,isWizard:a,hasName:i,showWeekNumbers:n,hasPresets:r,isScrollable:l,scrollHeight:o}=e,d="popup"===t,h=a?"rc-calendar rc-calendar--wizard":"rc-calendar",c=a?"Birth date wizard":"Calendar",u=[];d&&u.push(function(e){return`<div class="rc-popup-header">\n ${e?'<span class="rc-popup-header__title" x-text="wizardStepLabel"></span>':'<span class="rc-popup-header__title">Select Date</span>'}\n <button class="rc-popup-header__close" @click="close()" aria-label="Close calendar"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><line x1="4" y1="4" x2="12" y2="12"/><line x1="12" y1="4" x2="4" y2="12"/></svg></button>\n</div>`}(a)),a&&u.push('<div class="rc-wizard-steps">\n <template x-for="step in wizardTotalSteps" :key="step">\n <div class="rc-wizard-step" :class="{ \'rc-wizard-step--active\': wizardStep === step, \'rc-wizard-step--done\': wizardStep > step }"></div>\n </template>\n</div>\n<div class="rc-wizard-label" x-text="wizardStepLabel"></div>\n<template x-if="wizardStep > 1">\n <button class="rc-wizard-back" @click="wizardBack()" aria-label="Go back">&#8249; Back</button>\n</template>'),u.push('<template x-if="view === \'years\'">\n <div class="rc-view-enter">\n <div class="rc-header">\n <button class="rc-header__nav" @click="prev()" :disabled="!canGoPrev" aria-label="Previous decade">&#8249;</button>\n <span class="rc-header__label" x-text="decadeLabel"></span>\n <button class="rc-header__nav" @click="next()" :disabled="!canGoNext" aria-label="Next decade">&#8250;</button>\n </div>\n <div class="rc-year-grid" role="group" :aria-label="decadeLabel">\n <template x-for="cell in yearGrid.flat()" :key="cell.year">\n <div :class="yearClasses(cell)" :aria-disabled="cell.isDisabled" tabindex="-1" @click="!cell.isDisabled && selectYear(cell.year)" x-text="cell.label"></div>\n </template>\n </div>\n </div>\n</template>'),u.push('<template x-if="view === \'months\'">\n <div class="rc-view-enter">\n <div class="rc-header">\n <button class="rc-header__nav" @click="prev()" :disabled="!canGoPrev" aria-label="Previous year">&#8249;</button>\n <button class="rc-header__label" @click="setView(\'years\')" aria-label="Change view" x-text="yearLabel"></button>\n <button class="rc-header__nav" @click="next()" :disabled="!canGoNext" aria-label="Next year">&#8250;</button>\n </div>\n <div class="rc-month-grid" role="group" :aria-label="yearLabel">\n <template x-for="cell in monthGrid.flat()" :key="cell.month">\n <div :class="monthClasses(cell)" :aria-disabled="cell.isDisabled" tabindex="-1" @click="!cell.isDisabled && selectMonth(cell.month)" x-text="cell.label"></div>\n </template>\n </div>\n </div>\n</template>'),l?u.push(function(e,t){return`<template x-if="view === 'days'">\n <div>\n <div class="rc-header rc-header--scroll-sticky">\n <span class="rc-header__label rc-header__label--scroll" x-text="scrollHeaderLabel"></span>\n </div>\n ${e?'<div class="rc-weekdays rc-weekdays--week-numbers">\n <span class="rc-weekday rc-week-label"></span>\n <template x-for="wd in weekdayHeaders" :key="wd">\n <span class="rc-weekday" x-text="wd"></span>\n </template>\n </div>':'<div class="rc-weekdays">\n <template x-for="wd in weekdayHeaders" :key="wd">\n <span class="rc-weekday" x-text="wd"></span>\n </template>\n </div>'}\n <div class="rc-months rc-months--scroll" style="max-height: ${t}px">\n <template x-for="(mg, gi) in grid" :key="mg.year + '-' + mg.month">\n <div :data-month-id="'month-' + mg.year + '-' + mg.month">\n <div class="rc-header rc-header--scroll" x-show="gi > 0">\n <span class="rc-header__label rc-header__label--scroll" x-text="monthYearLabel(gi)"></span>\n </div>\n <div class=${e?'"rc-grid rc-grid--week-numbers"':'"rc-grid"'} role="listbox" :aria-label="monthYearLabel(gi)">\n ${N(e)}\n </div>\n </div>\n </template>\n </div>\n </div>\n</template>`}(n,o)):u.push(function(e,t){return`<template x-if="view === 'days'">\n <div class="rc-months${e?"":" rc-view-enter"}"${e?" :class=\"{ 'rc-months--dual': monthCount === 2 }\"":""}>\n <template x-for="(mg, gi) in grid" :key="mg.year + '-' + mg.month">\n <div>\n <div class="rc-header">\n <button class="rc-header__nav" @click="prev()" :disabled="!canGoPrev" aria-label="Previous month"${e?" :style=\"gi > 0 ? 'visibility:hidden' : ''\"":""}>&#8249;</button>\n <button class="rc-header__label" @click="setView('months')" aria-label="Change view" x-text="monthYearLabel(gi)"></button>\n <button class="rc-header__nav" @click="next()" :disabled="!canGoNext" aria-label="Next month"${e?" :style=\"gi < grid.length - 1 ? 'visibility:hidden' : ''\"":""}>&#8250;</button>\n </div>\n ${t?'<div class="rc-weekdays rc-weekdays--week-numbers">\n <span class="rc-weekday rc-week-label"></span>\n <template x-for="wd in weekdayHeaders" :key="wd">\n <span class="rc-weekday" x-text="wd"></span>\n </template>\n </div>':'<div class="rc-weekdays">\n <template x-for="wd in weekdayHeaders" :key="wd">\n <span class="rc-weekday" x-text="wd"></span>\n </template>\n </div>'}\n <div class="rc-grid-wrapper">\n <div class=${t?'"rc-grid rc-grid--week-numbers"':'"rc-grid"'} :class="{ 'rc-grid--slide-next': _navDirection === 'next', 'rc-grid--slide-prev': _navDirection === 'prev' }" @animationend="_navDirection = ''" role="listbox" :aria-label="monthYearLabel(gi)">\n ${N(t)}\n </div>\n </div>\n </div>\n </template>\n </div>\n</template>`}(s,n)),r&&u.push('<div class="rc-presets" role="group" aria-label="Quick select">\n <template x-for="(preset, pi) in presets" :key="pi">\n <button class="rc-preset" @click="applyPreset(pi)" x-text="preset.label"></button>\n </template>\n</div>'),a&&u.push('<div class="rc-wizard-summary" x-show="wizardSummary" x-transition:enter="transition ease-out duration-200" x-transition:enter-start="opacity-0 transform translate-y-1" x-transition:enter-end="opacity-100 transform translate-y-0" x-text="wizardSummary"></div>'),i&&u.push('<template x-if="inputName">\n <template x-for="val in hiddenInputValues" :key="val">\n <input type="hidden" :name="inputName" :value="val">\n </template>\n</template>');const m=`<div class="${h}" @keydown="handleKeydown($event)" tabindex="0" :aria-activedescendant="focusedDateISO ? 'day-' + focusedDateISO : null" role="application" aria-label="${c}">\n<div class="rc-sr-only" role="status" aria-live="polite" aria-atomic="true" x-text="_statusMessage"></div>\n${u.join("\n")}\n</div>`;return d?`<div x-ref="popup" x-show="isOpen" :style="popupStyle" class="rc-popup-overlay" @click.self="close()" role="dialog" aria-modal="true" :aria-label="popupAriaLabel" x-transition:enter="transition ease-out duration-150" x-transition:enter-start="opacity-0" x-transition:enter-end="opacity-100" x-transition:leave="transition ease-in duration-100" x-transition:leave-start="opacity-100" x-transition:leave-end="opacity-0">\n${m}\n</div>`:m}function L(t){return e.fromISO(t)}function K(t){return t.map(t=>e.fromISO(t)).filter(e=>null!==e)}function V(t,s){const a={};if(t.minDate){const s=e.fromISO(t.minDate);s&&(a.minDate=s)}if(t.maxDate){const s=e.fromISO(t.maxDate);s&&(a.maxDate=s)}if(t.disabledDates&&(a.disabledDates=K(t.disabledDates)),t.disabledDaysOfWeek&&(a.disabledDaysOfWeek=t.disabledDaysOfWeek),t.enabledDates&&(a.enabledDates=K(t.enabledDates)),t.enabledDaysOfWeek&&(a.enabledDaysOfWeek=t.enabledDaysOfWeek),t.disabledMonths&&(a.disabledMonths=t.disabledMonths),t.enabledMonths&&(a.enabledMonths=t.enabledMonths),t.disabledYears&&(a.disabledYears=t.disabledYears),t.enabledYears&&(a.enabledYears=t.enabledYears),void 0!==t.minRange&&(a.minRange=t.minRange),void 0!==t.maxRange&&(a.maxRange=t.maxRange),t.rules){const e=t.rules.map(e=>function(e){const t=e.from?L(e.from):null,s=e.to?L(e.to):null,a=null!==t&&null!==s,i=Array.isArray(e.months)&&e.months.length>0;if(!a&&!i)return null;const n={};if(a&&(n.from=t,n.to=s),i&&(n.months=e.months),void 0!==e.priority&&(n.priority=e.priority),e.minDate){const t=L(e.minDate);t&&(n.minDate=t)}if(e.maxDate){const t=L(e.maxDate);t&&(n.maxDate=t)}return e.disabledDates&&(n.disabledDates=K(e.disabledDates)),e.disabledDaysOfWeek&&(n.disabledDaysOfWeek=e.disabledDaysOfWeek),e.enabledDates&&(n.enabledDates=K(e.enabledDates)),e.enabledDaysOfWeek&&(n.enabledDaysOfWeek=e.enabledDaysOfWeek),e.disabledMonths&&(n.disabledMonths=e.disabledMonths),e.enabledMonths&&(n.enabledMonths=e.enabledMonths),e.disabledYears&&(n.disabledYears=e.disabledYears),e.enabledYears&&(n.enabledYears=e.enabledYears),void 0!==e.minRange&&(n.minRange=e.minRange),void 0!==e.maxRange&&(n.maxRange=e.maxRange),n}(e)).filter(e=>null!==e);e.length>0&&(a.rules=e)}return{isDisabledDate:l(a),isRangeValid:o(a),isMonthDisabled:d(a),isYearDisabled:h(a),getDisabledReasons:m(a,s)}}const F=["minDate","maxDate","disabledDates","disabledDaysOfWeek","enabledDates","enabledDaysOfWeek","disabledMonths","enabledMonths","disabledYears","enabledYears","minRange","maxRange","rules"];function W(e){const t={};for(const s of F)void 0!==e[s]&&(t[s]=e[s]);return t}function B(t={},s){!function(t){const s=e=>console.warn(`[reach-calendar] ${e}`);if(void 0!==t.months&&(t.months<1||!Number.isInteger(t.months))&&s(`months must be a positive integer, got: ${t.months}`),t.wizard&&t.months&&t.months>=3&&s("months >= 3 (scrollable) is not compatible with wizard mode; using months: 1"),void 0!==t.firstDay&&(t.firstDay<0||t.firstDay>6)&&s(`firstDay must be 0-6, got: ${t.firstDay}`),t.minDate&&!e.fromISO(t.minDate)&&s(`invalid minDate: "${t.minDate}"`),t.maxDate&&!e.fromISO(t.maxDate)&&s(`invalid maxDate: "${t.maxDate}"`),t.minDate&&t.maxDate){const a=e.fromISO(t.minDate),i=e.fromISO(t.maxDate);a&&i&&a.isAfter(i)&&s(`minDate "${t.minDate}" is after maxDate "${t.maxDate}"`)}if(void 0!==t.minRange&&void 0!==t.maxRange&&t.minRange>t.maxRange&&s(`minRange (${t.minRange}) exceeds maxRange (${t.maxRange})`),t.wizard&&t.mode&&"single"!==t.mode&&s(`wizard mode is designed for single selection; mode "${t.mode}" may not work as expected`),t.timezone)try{Intl.DateTimeFormat(void 0,{timeZone:t.timezone})}catch{s(`invalid timezone: "${t.timezone}"`)}}(t);const a=t.mode??"single",i=t.display??"inline",n=t.format??"DD/MM/YYYY",r=t.firstDay??1;let l=t.timezone;if(l)try{Intl.DateTimeFormat(void 0,{timeZone:l})}catch{l=void 0}const o=t.wizard??!1,d=t.months??1,h=o&&d>=3?1:d,c=h>=3,u=t.scrollHeight??400,m=!!o,v=!0===o?"full":!1===o?"none":o,g="none"===v?0:"full"===v?3:2,_="full"===v||"year-month"===v?"years":"month-day"===v?"months":"days",w=t.mask??!0,x=t.showWeekNumbers??!1,Y=t.presets??[],R=t.name??"",O=t.inputId??null,z=t.inputRef??"rc-input",I=t.locale,$=t.closeOnSelect??!0,E=t.beforeSelect??null,N=t.constraintMessages,L=V(t,N),K=C(t.dateMetadata);const B="multiple"===a?new f:"range"===a?new p:new b,G=e=>{var t;return L.isDisabledDate(e)||"unavailable"===(null==(t=K(e))?void 0:t.availability)};if(t.value)if("single"===a){const s=S(t.value,n)??e.fromISO(t.value);s&&!G(s)&&B.toggle(s)}else if("range"===a){const e=M(t.value,n);if(e){let[t,s]=e;if(s.isBefore(t)){const e=t;t=s,s=e}G(t)||G(s)||!L.isRangeValid(t,s)||(B.toggle(t),B.toggle(s))}}else if("multiple"===a){const e=k(t.value,n);for(const t of e)G(t)||B.toggle(t)}const P=e.today(l),H=B.toArray(),U=H.length>0?H[0]:P,j="full"===v||"year-month"===v?new e(P.year-30,P.month,P.day):U;function q(e){const t=e.toArray();if(0===t.length)return"";const s=t[0];return"range"===a&&2===t.length?function(e,t,s){return`${D(e,s)} – ${D(t,s)}`}(s,t[1],n):"multiple"===a?function(e,t){return 0===e.length?"":e.map(e=>D(e,t)).join(", ")}(t,n):D(s,n)}return{mode:a,display:i,format:n,monthCount:h,firstDay:r,wizard:m,wizardMode:v,wizardTotalSteps:g,showWeekNumbers:x,presets:Y,inputName:R,month:j.month,year:j.year,view:m?_:"days",isOpen:"inline"===i,grid:[],monthGrid:[],yearGrid:[],inputValue:q(B),popupStyle:"popup"===i?"position:fixed;inset:0;z-index:50;":"",focusedDate:null,hoverDate:null,wizardStep:m?1:0,_wizardYear:null,_wizardMonth:null,_wizardDay:null,_navDirection:"",_selection:B,_today:P,_constraintConfig:W(t),_isDisabledDate:L.isDisabledDate,_isRangeValid:L.isRangeValid,_isMonthDisabled:L.isMonthDisabled,_isYearDisabled:L.isYearDisabled,_getDisabledReasons:L.getDisabledReasons,_inputEl:null,_detachInput:null,_syncing:!1,_suppressFocusOpen:!1,_Alpine:s??null,_autoRendered:!1,isScrollable:c,_scrollHeight:u,_scrollContainerEl:null,_scrollObserver:null,_scrollVisibleIndex:0,_selectionRev:0,_getDateMeta:K,_metadataRev:0,_isEffectivelyDisabled(e){var t;return!!this._isDisabledDate(e)||"unavailable"===(null==(t=this._getDateMeta(e))?void 0:t.availability)},_statusMessage:"",get selectedDates(){return this._selection.toArray()},get formattedValue(){return q(this._selection)},get hiddenInputValues(){return this._selection.toArray().map(e=>e.toISO())},get focusedDateISO(){return this.focusedDate?this.focusedDate.toISO():""},get inputId(){return O},get inputAriaLabel(){return"range"===a?"Select date range":"multiple"===a?"Select dates":m?"Select birth date":"Select date"},get popupAriaLabel(){return m?"Birth date wizard":"range"===a?"Date range picker":"Date picker"},get wizardStepLabel(){return this.wizard?"full"===v?1===this.wizardStep?"Select Year":2===this.wizardStep?"Select Month":"Select Day":"year-month"===v?1===this.wizardStep?"Select Year":"Select Month":"month-day"===v?1===this.wizardStep?"Select Month":"Select Day":"":""},get wizardSummary(){if(!m)return"";const t=[];if(null!==this._wizardYear&&t.push(String(this._wizardYear)),null!==this._wizardMonth){const s=new e(this._wizardYear??this.year,this._wizardMonth,1);t.push(s.format({month:"long"},I))}return null!==this._wizardDay&&t.push(String(this._wizardDay)),t.join(" · ")},get weekdayHeaders(){const e=[],t=new Date(2026,0,4);for(let s=0;s<7;s++){const a=(this.firstDay+s)%7,i=new Date(t);i.setDate(t.getDate()+a),e.push(new Intl.DateTimeFormat(I,{weekday:"short"}).format(i))}return e},init(){var e;const s=this.$el;if(!(null!==s.querySelector(".rc-calendar"))&&!1!==t.template&&(null==(e=this._Alpine)?void 0:e.initTree)){const e=document.createRange().createContextualFragment(T({display:this.display,isDualMonth:2===this.monthCount,isWizard:"none"!==this.wizardMode,hasName:!!this.inputName,showWeekNumbers:this.showWeekNumbers,hasPresets:this.presets.length>0,isScrollable:this.isScrollable,scrollHeight:this._scrollHeight})),t=Array.from(e.children).filter(e=>e instanceof HTMLElement);s.appendChild(e);for(const s of t)this._Alpine.initTree(s);this._autoRendered=!0}this._rebuildGrid(),this._rebuildMonthGrid(),this._rebuildYearGrid(),this.$watch("month",()=>{this._rebuildGrid(),this._emitNavigate(),this._announceNavigation(),this.isScrollable&&this.$nextTick(()=>{this._rebindScrollObserver()})}),this.$watch("year",()=>{this._rebuildGrid(),this._rebuildMonthGrid(),this._rebuildYearGrid(),this._emitNavigate(),this._announceNavigation(),this.isScrollable&&this.$nextTick(()=>{this._rebindScrollObserver()})}),this.$watch("view",()=>{this._emitViewChange(),this._announceViewChange()}),this.$nextTick(()=>{const e=this.$refs;e&&e[z]&&e[z]instanceof HTMLInputElement?this.bindInput(e[z]):"popup"===this.display&&console.warn(`[reach-calendar] Popup mode requires an <input x-ref="${z}"> inside the component container.`),this.isScrollable&&this._initScrollListener()})},destroy(){var e,t;if(this._scrollObserver&&(this._scrollObserver.disconnect(),this._scrollObserver=null),this._scrollContainerEl=null,this._detachInput&&(this._detachInput(),this._detachInput=null),this._inputEl=null,this._autoRendered){const s=this.$el;null==(e=s.querySelector(".rc-popup-overlay"))||e.remove(),null==(t=s.querySelector(".rc-calendar"))||t.remove(),this._autoRendered=!1}},_rebuildGrid(){this.grid=function(e,t,s,a=1,i,n){const r=[];for(let l=0;l<s;l++){let s=t+l,o=e;for(;s>12;)s-=12,o++;r.push(y(o,s,a,i,n))}return r}(this.year,this.month,this.monthCount,this.firstDay,this._today,e=>this._isEffectivelyDisabled(e))},_rebuildMonthGrid(){this.monthGrid=function(t,s,a,i){const n=s??e.today(),r=i??(()=>!1),l=[];for(let o=0;o<3;o++){const s=[];for(let i=0;i<4;i++){const l=4*o+i+1,d=new e(t,l,1);s.push({month:l,year:t,label:d.format({month:"short"},a),isCurrentMonth:n.month===l&&n.year===t,isDisabled:r(t,l)})}l.push(s)}return l}(this.year,this._today,I,this._isMonthDisabled)},_rebuildYearGrid(){this.yearGrid=function(t,s,a){const i=s??e.today(),n=a??(()=>!1),r=12*Math.floor(t/12),l=[];for(let e=0;e<3;e++){const t=[];for(let s=0;s<4;s++){const a=r+4*e+s;t.push({year:a,label:String(a),isCurrentYear:i.year===a,isDisabled:n(a)})}l.push(t)}return l}(this.year,this._today,this._isYearDisabled)},dayGridItems(e){const t=[];for(let s=0;s<e.rows.length;s++){const a=e.rows[s];if(!a||0===a.length)continue;const i=a[0];t.push({isWeekNumber:!0,weekNumber:e.weekNumbers[s]??0,cell:i,key:`wn-${s}`});for(const e of a)t.push({isWeekNumber:!1,weekNumber:0,cell:e,key:e.date.toISO()})}return t},get yearLabel(){return String(this.year)},get decadeLabel(){const e=12*Math.floor(this.year/12);return`${e} – ${e+11}`},get canGoPrev(){if("days"===this.view){if(this.isScrollable)return!1;const t=new e(this.year,this.month,1).addMonths(-1);return!this._isMonthDisabled(t.year,t.month)}if("months"===this.view)return!this._isYearDisabled(this.year-1);if("years"===this.view){const e=12*Math.floor(this.year/12);for(let t=e-12;t<e;t++)if(!this._isYearDisabled(t))return!0;return!1}return!0},get canGoNext(){if("days"===this.view){if(this.isScrollable)return!1;const t=new e(this.year,this.month,1).addMonths(1);return!this._isMonthDisabled(t.year,t.month)}if("months"===this.view)return!this._isYearDisabled(this.year+1);if("years"===this.view){const e=12*Math.floor(this.year/12);for(let t=e+12;t<e+24;t++)if(!this._isYearDisabled(t))return!0;return!1}return!0},yearClasses(e){const t=this.year===e.year&&"months"===this.view;return{"rc-year":!0,"rc-year--current":e.isCurrentYear,"rc-year--selected":t,"rc-year--disabled":e.isDisabled}},monthClasses(e){const t=this.month===e.month&&"days"===this.view;return{"rc-month":!0,"rc-month--current":e.isCurrentMonth,"rc-month--selected":t,"rc-month--disabled":e.isDisabled}},monthYearLabel(t){const s=this.grid[t];if(!s)return"";return new e(s.year,s.month,1).format({month:"long",year:"numeric"},I)},dayClasses(e){this._selectionRev,this._metadataRev;const t=e.date,s=this.isSelected(t),i=this.isRangeStart(t),n=this.isRangeEnd(t),r=this.isInRange(t,this.hoverDate??void 0),l=!e.isCurrentMonth;let o=!1;"range"!==a||null===this.hoverDate||e.isDisabled||s||!this._selection.isPartial()||(o=!this.isDateSelectableForRange(t));const d=this._getDateMeta(t),h=!!(null==d?void 0:d.label),c="available"===(null==d?void 0:d.availability),u="unavailable"===(null==d?void 0:d.availability),m={"rc-day":!0,"rc-day--today":e.isToday,"rc-day--selected":s,"rc-day--range-start":i,"rc-day--range-end":n,"rc-day--in-range":r&&!i&&!n,"rc-day--disabled":e.isDisabled,"rc-day--other-month":l,"rc-day--hidden":l&&this.monthCount>1,"rc-day--focused":null!==this.focusedDate&&this.focusedDate.isSame(t),"rc-day--range-invalid":o,"rc-day--available":c,"rc-day--unavailable":u,"rc-day--has-label":h};if(null==d?void 0:d.cssClass)for(const a of d.cssClass.split(/\s+/))a&&(m[a]=!0);return m},dayTitle(e){this._metadataRev;const t=this._getDateMeta(e.date),s=[];if(e.isDisabled){const a=this._getDisabledReasons(e.date);a.length>0?s.push(a.join("; ")):"unavailable"===(null==t?void 0:t.availability)&&s.push("Unavailable")}return(null==t?void 0:t.label)&&s.push(t.label),s.join(" — ")},dayMeta(e){return this._metadataRev,this._getDateMeta(e.date)},dayStyle(e){this._metadataRev;const t=this._getDateMeta(e.date);return(null==t?void 0:t.color)?`--color-calendar-day-meta: ${t.color};`:""},bindInput(e){this._detachInput&&(this._detachInput(),this._detachInput=null),this._inputEl=e,e.value=this.inputValue,w&&(this._detachInput=A(e,n),this.inputValue=e.value);const t=()=>{this._syncing||(this.inputValue=e.value)};e.addEventListener("input",t);const s=()=>this.handleFocus(),a=()=>this.handleBlur();e.addEventListener("focus",s),e.addEventListener("blur",a),"popup"===i&&(e.setAttribute("role","combobox"),e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-expanded",String(this.isOpen)),e.setAttribute("autocomplete","off"),O&&!e.id&&(e.id=O),e.getAttribute("aria-label")||e.setAttribute("aria-label",this.inputAriaLabel));const r=this._detachInput;this._detachInput=()=>{null==r||r(),e.removeEventListener("input",t),e.removeEventListener("focus",s),e.removeEventListener("blur",a),"popup"===i&&(e.removeAttribute("role"),e.removeAttribute("aria-haspopup"),e.removeAttribute("aria-expanded"),e.removeAttribute("autocomplete"))},e.placeholder||(e.placeholder=n.toLowerCase())},handleInput(e){const t=e.target;this.inputValue=t.value},handleFocus(){this._suppressFocusOpen?this._suppressFocusOpen=!1:this.open()},handleBlur(){const t=this._inputEl?this._inputEl.value:this.inputValue;if(!t.trim())return this._selection.toArray().length>0&&(this._selection.clear(),this._selectionRev++,this._emitChange()),void this._syncInputFromSelection();let s=!1;if("single"===a){const a=S(t,n)??e.fromISO(t);a&&!this._isEffectivelyDisabled(a)&&(this._selection.clear(),this._selection.toggle(a),this.month=a.month,this.year=a.year,s=!0)}else if("range"===a){const e=M(t,n);if(e){let[t,a]=e;if(a.isBefore(t)){const e=t;t=a,a=e}this._isEffectivelyDisabled(t)||this._isEffectivelyDisabled(a)||!this._isRangeValid(t,a)||(this._selection.clear(),this._selection.toggle(t),this._selection.toggle(a),this.month=t.month,this.year=t.year,s=!0)}}else if("multiple"===a){const e=k(t,n).filter(e=>!this._isEffectivelyDisabled(e));if(e.length>0){this._selection.clear();for(const s of e)this._selection.toggle(s);const t=e[0];this.month=t.month,this.year=t.year,s=!0}}s&&(this._selectionRev++,this._emitChange()),this._syncInputFromSelection()},_syncInputFromSelection(){this._syncing=!0,this.inputValue=this.formattedValue,this._inputEl&&(this._inputEl.value=this.inputValue),this._syncing=!1},_announce(e){this._statusMessage="",this.$nextTick(()=>{this._statusMessage=e})},_announceNavigation(){if("days"===this.view)if(this.monthCount>1&&!this.isScrollable){const e=[];for(let t=0;t<this.grid.length;t++)e.push(this.monthYearLabel(t));this._announce(e.join(" – "))}else this._announce(this.monthYearLabel(0));else"months"===this.view?this._announce("Year: "+this.year):"years"===this.view&&this._announce("Decade: "+this.decadeLabel)},_announceViewChange(){"days"===this.view?this._announce(this.monthYearLabel(0)):"months"===this.view?this._announce("Select month, "+this.year):"years"===this.view&&this._announce("Select year, "+this.decadeLabel)},_emitChange(){this.$dispatch("calendar:change",{value:this._selection.toValue(),dates:this._selection.toArray().map(e=>e.toISO()),formatted:this.formattedValue})},_emitNavigate(){this.$dispatch("calendar:navigate",{year:this.year,month:this.month,view:this.view})},_emitViewChange(){this.$dispatch("calendar:view-change",{view:this.view,year:this.year,month:this.month})},prev(){if(this._navDirection="prev","days"===this.view){if(this.isScrollable)return;const t=new e(this.year,this.month,1).addMonths(-1);this.month=t.month,this.year=t.year}else"months"===this.view?this.year--:"years"===this.view&&(this.year-=12)},next(){if(this._navDirection="next","days"===this.view){if(this.isScrollable)return;const t=new e(this.year,this.month,1).addMonths(1);this.month=t.month,this.year=t.year}else"months"===this.view?this.year++:"years"===this.view&&(this.year+=12)},goToToday(){this.month=this._today.month,this.year=this._today.year,this.view="days"},selectDate(t){const s="string"==typeof t?e.fromISO(t):t;if(!s)return;if(this._isEffectivelyDisabled(s))return;if("range"===a){const e=this._selection,t=e.getStart();if(e.isPartial()&&t&&!s.isSame(t)){let e=t,a=s;if(a.isBefore(e)){const t=e;e=a,a=t}if(!this._isRangeValid(e,a))return}}if(E){const e=this._selection.isSelected(s)?"deselect":"select";if(!1===E(s,{mode:a,selectedDates:this._selection.toArray(),action:e}))return}const n=this._selection.isSelected(s),r="range"===a&&this._selection.isPartial();this._selection.toggle(s),m&&(this._wizardDay=s.day),this._selectionRev++,this._emitChange(),this._syncInputFromSelection();const l=s.format({weekday:"long",month:"long",day:"numeric",year:"numeric"},I);if("single"===a)this._announce(l+" selected");else if("multiple"===a){const e=this._selection.toArray().length;n?this._announce(l+" deselected. "+e+" dates selected"):this._announce(l+" selected. "+e+" dates selected")}else if("range"===a){const e=this._selection;if(e.isPartial())this._announce("Range start: "+l+". Select end date");else if(r){const t=e.toArray();if(2===t.length){const e=t[0].format({weekday:"long",month:"long",day:"numeric",year:"numeric"},I),s=t[1].format({weekday:"long",month:"long",day:"numeric",year:"numeric"},I);this._announce("Range: "+e+" to "+s)}}}if($&&"popup"===i&&this.isOpen){("single"===a||"range"===a&&!this._selection.isPartial()||"multiple"===a)&&this.close()}},isSelected(e){return this._selection.isSelected(e)},isInRange(e,t){return"range"===a&&this._selection.isInRange(e,t)},isRangeStart(e){if("range"!==a)return!1;const t=this._selection.getStart();return null!==t&&e.isSame(t)},isRangeEnd(e){if("range"!==a)return!1;const t=this._selection.getEnd();return null!==t&&e.isSame(t)},isDateSelectableForRange(e){if("range"!==a)return!1;if(this._isEffectivelyDisabled(e))return!1;const t=this._selection;if(!t.isPartial())return!0;const s=t.getStart();if(!s)return!0;if(e.isSame(s))return!0;let i=s,n=e;if(n.isBefore(i)){const e=i;i=n,n=e}return this._isRangeValid(i,n)},getDisabledReason(t){const s="string"==typeof t?e.fromISO(t):t;return s?this._getDisabledReasons(s):[]},clearSelection(){this._selection.clear(),this._selectionRev++,this._emitChange(),this._syncInputFromSelection(),this._announce("Selection cleared")},setValue(t){this._selection.clear();const s=[];if("string"==typeof t){const a=e.fromISO(t)??S(t,n);a&&!this._isEffectivelyDisabled(a)&&s.push(a)}else if(Array.isArray(t))for(const a of t){const t="string"==typeof a?e.fromISO(a)??S(a,n):a;t&&!this._isEffectivelyDisabled(t)&&s.push(t)}else t instanceof e&&(this._isEffectivelyDisabled(t)||s.push(t));if("range"===a&&2===s.length){let[e,t]=s;if(t.isBefore(e)){const s=e;e=t,t=s}if(!this._isRangeValid(e,t))return this._selectionRev++,this._emitChange(),void this._syncInputFromSelection();this._selection.setRange(e,t)}else for(const e of s)this._selection.toggle(e);const i=this._selection.toArray();if(i.length>0){const e=i[0];this.month=e.month,this.year=e.year}this._selectionRev++,this._emitChange(),this._syncInputFromSelection()},clear(){this.clearSelection()},goTo(e,t){this.year=e,void 0!==t&&(this.month=t),this.view="days",this.isScrollable&&(this._rebuildGrid(),this.$nextTick(()=>{this._rebindScrollObserver(),this._scrollToMonth(e,t??this.month)}))},getSelection(){return[...this._selection.toArray()]},applyPreset(e){const t=this.presets[e];if(!t)return;const[s,i]=t.value();"single"===a?this.setValue(s):this.setValue([s,i]),"popup"===this.display&&$&&this.close()},updateConstraints(e){const t={...this._constraintConfig};for(const a of F)a in e&&(t[a]=e[a]);this._constraintConfig=t;const s=V(t,N);this._isDisabledDate=s.isDisabledDate,this._isRangeValid=s.isRangeValid,this._isMonthDisabled=s.isMonthDisabled,this._isYearDisabled=s.isYearDisabled,this._getDisabledReasons=s.getDisabledReasons,this._rebuildGrid(),this._rebuildMonthGrid(),this._rebuildYearGrid(),this.isScrollable&&this.$nextTick(()=>{this._rebindScrollObserver()})},updateDateMetadata(e){this._getDateMeta=C(e),this._metadataRev++,this._rebuildGrid(),this.isScrollable&&this.$nextTick(()=>{this._rebindScrollObserver()})},setView(e){this.view=e},selectMonth(t){if(!this._isMonthDisabled(this.year,t)){if(this.month=t,this._wizardMonth=t,"year-month"===v)return this.wizardStep=g,void this.selectDate(new e(this.year,t,1));this.view="days",m&&(this.wizardStep="month-day"===v?2:3)}},selectYear(e){this._isYearDisabled(e)||(this.year=e,this._wizardYear=e,this.view="months",this.wizard&&(this.wizardStep=2))},wizardBack(){this.wizard&&("full"===v?3===this.wizardStep?(this.wizardStep=2,this.view="months",this._wizardMonth=null,this._wizardDay=null):2===this.wizardStep&&(this.wizardStep=1,this.view="years",this._wizardYear=null,this._wizardMonth=null):"year-month"===v?2===this.wizardStep&&(this.wizardStep=1,this.view="years",this._wizardYear=null,this._wizardMonth=null):"month-day"===v&&2===this.wizardStep&&(this.wizardStep=1,this.view="months",this._wizardMonth=null))},open(){var e;"popup"===this.display&&(m&&(this.wizardStep=1,this.view=_,this._wizardYear=null,this._wizardMonth=null,this._wizardDay=null,"month-day"!==v&&(this.year=this._today.year-30,this._rebuildYearGrid())),this.isOpen=!0,null==(e=this._inputEl)||e.setAttribute("aria-expanded","true"),this.$dispatch("calendar:open"),this.$nextTick(()=>{}))},close(){var e;"popup"===this.display&&(this.isOpen=!1,null==(e=this._inputEl)||e.setAttribute("aria-expanded","false"),this.$dispatch("calendar:close"))},toggle(){this.isOpen?this.close():this.open()},handleKeydown(t){if("Escape"===t.key)return t.preventDefault(),t.stopPropagation(),this.wizard&&this.wizardStep>1?void this.wizardBack():"months"===this.view||"years"===this.view?void(this.view="days"):void("popup"===i&&this.isOpen&&(this.close(),this._inputEl&&(this._suppressFocusOpen=!0,this._inputEl.focus())));if("days"===this.view)switch(t.key){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":case"PageDown":case"PageUp":case"Home":case"End":if(t.preventDefault(),!this.focusedDate){const t=this._selection.toArray();t.length>0?this.focusedDate=t[0]:this.focusedDate=new e(this.year,this.month,1)}return void("ArrowRight"===t.key?this._moveFocus(1):"ArrowLeft"===t.key?this._moveFocus(-1):"ArrowDown"===t.key?this._moveFocus(7):"ArrowUp"===t.key?this._moveFocus(-7):"PageDown"===t.key?this._moveFocusByMonths(t.shiftKey?12:1):"PageUp"===t.key?this._moveFocusByMonths(t.shiftKey?-12:-1):"Home"===t.key?this._setFocusedDate(new e(this.year,this.month,1)):"End"===t.key&&this._setFocusedDate(new e(this.year,this.month,1).endOfMonth()));case"Enter":case" ":return void(this.focusedDate&&(t.preventDefault(),this.selectDate(this.focusedDate)))}},_moveFocus(e){if(!this.focusedDate)return;let t=this.focusedDate.addDays(e),s=0;for(;this._isEffectivelyDisabled(t)&&s<31;)t=t.addDays(e>0?1:-1),s++;this._isEffectivelyDisabled(t)||this._setFocusedDate(t)},_moveFocusByMonths(e){if(!this.focusedDate)return;const t=this.focusedDate.addMonths(e);this._setFocusedDate(t)},_setFocusedDate(e){this.focusedDate=e,this.isScrollable?this.$nextTick(()=>{this._scrollToMonth(e.year,e.month)}):e.month===this.month&&e.year===this.year||(this.month=e.month,this.year=e.year)},get scrollHeaderLabel(){if(!this.isScrollable)return"";const t=this.grid[this._scrollVisibleIndex];if(!t)return"";return new e(t.year,t.month,1).format({month:"long",year:"numeric"},I)},_initScrollListener(){if("undefined"==typeof IntersectionObserver)return;const e=this.$el.querySelector(".rc-months--scroll");if(!e)return;this._scrollContainerEl=e;const t=e.querySelectorAll("[data-month-id]");if(0===t.length)return;const s=new Map;t.forEach((e,t)=>s.set(e,t));const a=new Set,i=new IntersectionObserver(e=>{for(const t of e){const e=s.get(t.target);void 0!==e&&(t.isIntersecting?a.add(e):a.delete(e))}if(a.size>0){const e=Math.min(...a);this._scrollVisibleIndex!==e&&(this._scrollVisibleIndex=e)}},{root:e,rootMargin:"0px 0px -90% 0px",threshold:0});t.forEach(e=>i.observe(e)),this._scrollObserver=i},_rebindScrollObserver(){this._scrollObserver&&(this._scrollObserver.disconnect(),this._scrollObserver=null),this._initScrollListener()},_scrollToMonth(e,t){if(!this._scrollContainerEl)return;const s=this._scrollContainerEl.querySelector(`[data-month-id="month-${e}-${t}"]`);s&&s.scrollIntoView({behavior:"smooth",block:"start"})}}}let G={};function P(e){e.data("calendar",(t={})=>B({...G,...t},e))}P.defaults=e=>{G={...G,...e}},P.getDefaults=()=>({...G}),P.resetDefaults=()=>{G={}};let H=!1;function U(){H||window.Alpine&&(window.Alpine.plugin(P),H=!0)}window.Alpine&&U(),document.addEventListener("alpine:init",()=>{U()})}();
2
2
  //# sourceMappingURL=alpine-calendar.cdn.js.map