calkit 0.1.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.
@@ -0,0 +1,1619 @@
1
+ class ne extends HTMLElement {
2
+ constructor() {
3
+ super(), this.attachShadow({ mode: "open" }), this._initialized = !1;
4
+ }
5
+ /** Override in subclass — return array of CSSStyleSheet or CSS strings. */
6
+ static get styles() {
7
+ return [];
8
+ }
9
+ connectedCallback() {
10
+ this._initialized || (this._adoptStyles(), this._initialized = !0), this.render();
11
+ }
12
+ _adoptStyles() {
13
+ const e = this.constructor.styles;
14
+ if (e.length)
15
+ if ("adoptedStyleSheets" in this.shadowRoot)
16
+ this.shadowRoot.adoptedStyleSheets = e.map((a) => {
17
+ if (a instanceof CSSStyleSheet) return a;
18
+ const t = new CSSStyleSheet();
19
+ return t.replaceSync(a), t;
20
+ });
21
+ else
22
+ for (const a of e) {
23
+ const t = document.createElement("style");
24
+ t.textContent = a instanceof CSSStyleSheet ? "" : a, this.shadowRoot.prepend(t);
25
+ }
26
+ }
27
+ /** Subclasses override to update Shadow DOM. */
28
+ render() {
29
+ }
30
+ /** Dispatch a composed, bubbling custom event. */
31
+ emit(e, a = {}) {
32
+ this.dispatchEvent(
33
+ new CustomEvent(e, { detail: a, bubbles: !0, composed: !0 })
34
+ );
35
+ }
36
+ /** Show an inline status banner. */
37
+ showStatus(e, a, t = {}) {
38
+ if (!this._store) return;
39
+ const { autoDismiss: n, dismissible: r = !0 } = t;
40
+ clearTimeout(this._statusTimer), this._store.set({ statusType: e, statusMessage: a, statusDismissible: r }), this.emit("cal:status", { type: e, message: a }), n && n > 0 && (this._statusTimer = setTimeout(() => this.clearStatus(), n));
41
+ }
42
+ /** Clear the status banner. */
43
+ clearStatus() {
44
+ this._store && (clearTimeout(this._statusTimer), this._store.set({ statusType: null, statusMessage: null, statusDismissible: !0 }), this.emit("cal:status", { type: null, message: null }));
45
+ }
46
+ /** Query within shadow root. */
47
+ $(e) {
48
+ return this.shadowRoot.querySelector(e);
49
+ }
50
+ $$(e) {
51
+ return this.shadowRoot.querySelectorAll(e);
52
+ }
53
+ }
54
+ function se(s) {
55
+ let e = { ...s };
56
+ const a = /* @__PURE__ */ new Set();
57
+ return {
58
+ get(t) {
59
+ return e[t];
60
+ },
61
+ set(t) {
62
+ const n = e;
63
+ e = { ...e, ...t };
64
+ let r = !1;
65
+ for (const o of Object.keys(t))
66
+ if (n[o] !== e[o]) {
67
+ r = !0;
68
+ break;
69
+ }
70
+ if (r)
71
+ for (const o of a) o(e, n);
72
+ },
73
+ getState() {
74
+ return e;
75
+ },
76
+ subscribe(t) {
77
+ return a.add(t), () => a.delete(t);
78
+ }
79
+ };
80
+ }
81
+ const I = [
82
+ "January",
83
+ "February",
84
+ "March",
85
+ "April",
86
+ "May",
87
+ "June",
88
+ "July",
89
+ "August",
90
+ "September",
91
+ "October",
92
+ "November",
93
+ "December"
94
+ ], re = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
95
+ function oe(s = 0) {
96
+ const e = [];
97
+ for (let a = 0; a < 7; a++)
98
+ e.push(re[(s + a) % 7]);
99
+ return e;
100
+ }
101
+ function W(s, e) {
102
+ return new Date(s, e + 1, 0).getDate();
103
+ }
104
+ function le(s, e) {
105
+ return new Date(s, e, 1).getDay();
106
+ }
107
+ function m(s) {
108
+ if (typeof s == "string") return s;
109
+ const e = s instanceof Date ? s : new Date(s.year, s.month, s.day), a = e.getFullYear(), t = String(e.getMonth() + 1).padStart(2, "0"), n = String(e.getDate()).padStart(2, "0");
110
+ return `${a}-${t}-${n}`;
111
+ }
112
+ function L(s) {
113
+ if (!s) return null;
114
+ if (s instanceof Date) return s;
115
+ if (typeof s == "string") {
116
+ const [e, a, t] = s.split("-").map(Number);
117
+ return !e || !a || !t ? null : new Date(e, a - 1, t);
118
+ }
119
+ return null;
120
+ }
121
+ function M(s, e) {
122
+ if (!s || !e) return !1;
123
+ const a = L(s), t = L(e);
124
+ return !a || !t ? !1 : a.getFullYear() === t.getFullYear() && a.getMonth() === t.getMonth() && a.getDate() === t.getDate();
125
+ }
126
+ function ie(s, e, a) {
127
+ if (!s || !e || !a) return !1;
128
+ const t = L(s), n = L(e), r = L(a);
129
+ if (!t || !n || !r) return !1;
130
+ const o = t.getTime(), l = Math.min(n.getTime(), r.getTime()), i = Math.max(n.getTime(), r.getTime());
131
+ return o >= l && o <= i;
132
+ }
133
+ function K() {
134
+ return m(/* @__PURE__ */ new Date());
135
+ }
136
+ function z(s, e, a) {
137
+ const t = new Date(s, e + a, 1);
138
+ return { year: t.getFullYear(), month: t.getMonth() };
139
+ }
140
+ function ce(s, e, a = 0) {
141
+ const t = W(s, e), r = (le(s, e) - a + 7) % 7, o = [], l = K(), i = z(s, e, -1), g = W(i.year, i.month);
142
+ for (let d = r - 1; d >= 0; d--) {
143
+ const b = g - d, p = m({ year: i.year, month: i.month, day: b });
144
+ o.push({ year: i.year, month: i.month, day: b, dateString: p, isCurrentMonth: !1, isToday: p === l });
145
+ }
146
+ for (let d = 1; d <= t; d++) {
147
+ const b = m({ year: s, month: e, day: d });
148
+ o.push({ year: s, month: e, day: d, dateString: b, isCurrentMonth: !0, isToday: b === l });
149
+ }
150
+ const h = z(s, e, 1);
151
+ let u = 1;
152
+ for (; o.length < 42; ) {
153
+ const d = m({ year: h.year, month: h.month, day: u });
154
+ o.push({ year: h.year, month: h.month, day: u, dateString: d, isCurrentMonth: !1, isToday: d === l }), u++;
155
+ }
156
+ return o;
157
+ }
158
+ const de = `
159
+ :host {
160
+ /* Light theme (default) */
161
+ --cal-bg: 0 0% 100%;
162
+ --cal-bg-muted: 240 5% 96%;
163
+ --cal-fg: 240 6% 10%;
164
+ --cal-fg-muted: 240 4% 46%;
165
+ --cal-border: 240 6% 90%;
166
+ --cal-accent: 240 6% 10%;
167
+ --cal-accent-fg: 0 0% 100%;
168
+ --cal-accent-subtle: 240 5% 96%;
169
+ --cal-hover: 240 5% 93%;
170
+ --cal-ring: 240 6% 10%;
171
+ --cal-radius: 8px;
172
+ --cal-radius-sm: 6px;
173
+ --cal-cell-size: 36px;
174
+ --cal-transition: 150ms ease;
175
+
176
+ /* Booking color palette (softer / less saturated) */
177
+ --cal-booking-blue-bg: 217 55% 94%;
178
+ --cal-booking-blue-fg: 217 60% 35%;
179
+ --cal-booking-green-bg: 152 45% 93%;
180
+ --cal-booking-green-fg: 152 55% 28%;
181
+ --cal-booking-red-bg: 4 50% 94%;
182
+ --cal-booking-red-fg: 4 55% 40%;
183
+ --cal-booking-orange-bg: 30 55% 93%;
184
+ --cal-booking-orange-fg: 30 60% 35%;
185
+ --cal-booking-gray-bg: 240 8% 94%;
186
+ --cal-booking-gray-fg: 240 8% 38%;
187
+
188
+ /* Booking hover tokens */
189
+ --cal-booking-blue-hover: 217 55% 88%;
190
+ --cal-booking-green-hover: 152 45% 87%;
191
+ --cal-booking-red-hover: 4 50% 88%;
192
+ --cal-booking-orange-hover: 30 55% 87%;
193
+ --cal-booking-gray-hover: 240 8% 88%;
194
+
195
+ /* Scheduler tokens */
196
+ --cal-sched-grid-line: 240 6% 94%;
197
+ --cal-sched-now-line: 4 70% 55%;
198
+ --cal-sched-slot-hover: 240 5% 97%;
199
+ --cal-sched-header-bg: 240 5% 98%;
200
+
201
+ /* Status tokens */
202
+ --cal-status-error-bg: 4 50% 95%;
203
+ --cal-status-error-fg: 4 55% 40%;
204
+ --cal-status-error-border: 4 50% 85%;
205
+ --cal-status-warning-bg: 40 55% 95%;
206
+ --cal-status-warning-fg: 40 60% 35%;
207
+ --cal-status-warning-border: 40 50% 85%;
208
+ --cal-status-info-bg: 217 55% 95%;
209
+ --cal-status-info-fg: 217 60% 35%;
210
+ --cal-status-info-border: 217 50% 85%;
211
+ --cal-status-success-bg: 152 45% 95%;
212
+ --cal-status-success-fg: 152 55% 28%;
213
+ --cal-status-success-border: 152 45% 85%;
214
+ }
215
+
216
+ :host([theme="dark"]) {
217
+ --cal-bg: 240 6% 10%;
218
+ --cal-bg-muted: 240 4% 16%;
219
+ --cal-fg: 0 0% 98%;
220
+ --cal-fg-muted: 240 4% 54%;
221
+ --cal-border: 240 4% 20%;
222
+ --cal-accent: 0 0% 98%;
223
+ --cal-accent-fg: 240 6% 10%;
224
+ --cal-accent-subtle: 240 4% 16%;
225
+ --cal-hover: 240 4% 20%;
226
+ --cal-ring: 0 0% 98%;
227
+
228
+ --cal-booking-blue-bg: 217 50% 25%;
229
+ --cal-booking-blue-fg: 217 80% 75%;
230
+ --cal-booking-green-bg: 142 40% 22%;
231
+ --cal-booking-green-fg: 142 70% 70%;
232
+ --cal-booking-red-bg: 4 45% 25%;
233
+ --cal-booking-red-fg: 4 70% 75%;
234
+ --cal-booking-orange-bg: 30 45% 25%;
235
+ --cal-booking-orange-fg: 30 80% 75%;
236
+ --cal-booking-gray-bg: 240 5% 22%;
237
+ --cal-booking-gray-fg: 240 5% 65%;
238
+
239
+ --cal-booking-blue-hover: 217 50% 30%;
240
+ --cal-booking-green-hover: 142 40% 27%;
241
+ --cal-booking-red-hover: 4 45% 30%;
242
+ --cal-booking-orange-hover: 30 45% 30%;
243
+ --cal-booking-gray-hover: 240 5% 27%;
244
+
245
+ --cal-sched-grid-line: 240 4% 18%;
246
+ --cal-sched-now-line: 4 55% 55%;
247
+ --cal-sched-slot-hover: 240 4% 14%;
248
+ --cal-sched-header-bg: 240 5% 12%;
249
+
250
+ --cal-status-error-bg: 4 45% 20%;
251
+ --cal-status-error-fg: 4 70% 75%;
252
+ --cal-status-error-border: 4 45% 30%;
253
+ --cal-status-warning-bg: 40 45% 20%;
254
+ --cal-status-warning-fg: 40 80% 75%;
255
+ --cal-status-warning-border: 40 45% 30%;
256
+ --cal-status-info-bg: 217 50% 20%;
257
+ --cal-status-info-fg: 217 80% 75%;
258
+ --cal-status-info-border: 217 50% 30%;
259
+ --cal-status-success-bg: 152 40% 18%;
260
+ --cal-status-success-fg: 152 70% 70%;
261
+ --cal-status-success-border: 152 40% 28%;
262
+ }
263
+
264
+ :host([theme="auto"]) {
265
+ --cal-bg: 0 0% 100%;
266
+ --cal-bg-muted: 240 5% 96%;
267
+ --cal-fg: 240 6% 10%;
268
+ --cal-fg-muted: 240 4% 46%;
269
+ --cal-border: 240 6% 90%;
270
+ --cal-accent: 240 6% 10%;
271
+ --cal-accent-fg: 0 0% 100%;
272
+ --cal-accent-subtle: 240 5% 96%;
273
+ --cal-hover: 240 5% 93%;
274
+ --cal-ring: 240 6% 10%;
275
+ }
276
+
277
+ @media (prefers-color-scheme: dark) {
278
+ :host([theme="auto"]) {
279
+ --cal-bg: 240 6% 10%;
280
+ --cal-bg-muted: 240 4% 16%;
281
+ --cal-fg: 0 0% 98%;
282
+ --cal-fg-muted: 240 4% 54%;
283
+ --cal-border: 240 4% 20%;
284
+ --cal-accent: 0 0% 98%;
285
+ --cal-accent-fg: 240 6% 10%;
286
+ --cal-accent-subtle: 240 4% 16%;
287
+ --cal-hover: 240 4% 20%;
288
+ --cal-ring: 0 0% 98%;
289
+
290
+ --cal-booking-blue-bg: 217 50% 25%;
291
+ --cal-booking-blue-fg: 217 80% 75%;
292
+ --cal-booking-green-bg: 142 40% 22%;
293
+ --cal-booking-green-fg: 142 70% 70%;
294
+ --cal-booking-red-bg: 4 45% 25%;
295
+ --cal-booking-red-fg: 4 70% 75%;
296
+ --cal-booking-orange-bg: 30 45% 25%;
297
+ --cal-booking-orange-fg: 30 80% 75%;
298
+ --cal-booking-gray-bg: 240 5% 22%;
299
+ --cal-booking-gray-fg: 240 5% 65%;
300
+
301
+ --cal-booking-blue-hover: 217 50% 30%;
302
+ --cal-booking-green-hover: 142 40% 27%;
303
+ --cal-booking-red-hover: 4 45% 30%;
304
+ --cal-booking-orange-hover: 30 45% 30%;
305
+ --cal-booking-gray-hover: 240 5% 27%;
306
+
307
+ --cal-sched-grid-line: 240 4% 18%;
308
+ --cal-sched-now-line: 4 55% 55%;
309
+ --cal-sched-slot-hover: 240 4% 14%;
310
+ --cal-sched-header-bg: 240 5% 12%;
311
+
312
+ --cal-status-error-bg: 4 45% 20%;
313
+ --cal-status-error-fg: 4 70% 75%;
314
+ --cal-status-error-border: 4 45% 30%;
315
+ --cal-status-warning-bg: 40 45% 20%;
316
+ --cal-status-warning-fg: 40 80% 75%;
317
+ --cal-status-warning-border: 40 45% 30%;
318
+ --cal-status-info-bg: 217 50% 20%;
319
+ --cal-status-info-fg: 217 80% 75%;
320
+ --cal-status-info-border: 217 50% 30%;
321
+ --cal-status-success-bg: 152 40% 18%;
322
+ --cal-status-success-fg: 152 70% 70%;
323
+ --cal-status-success-border: 152 40% 28%;
324
+ }
325
+ }
326
+ `, ge = `
327
+ :host {
328
+ display: inline-block;
329
+ font-family: inherit;
330
+ font-size: 14px;
331
+ line-height: 1.5;
332
+ color: hsl(var(--cal-fg));
333
+ -webkit-font-smoothing: antialiased;
334
+ -moz-osx-font-smoothing: grayscale;
335
+ }
336
+
337
+ :host([display="inline"]) {
338
+ display: inline-block;
339
+ }
340
+
341
+ *,
342
+ *::before,
343
+ *::after {
344
+ box-sizing: border-box;
345
+ }
346
+
347
+ button {
348
+ font: inherit;
349
+ color: inherit;
350
+ background: none;
351
+ border: none;
352
+ padding: 0;
353
+ margin: 0;
354
+ cursor: pointer;
355
+ -webkit-tap-highlight-color: transparent;
356
+ }
357
+
358
+ button:focus-visible {
359
+ outline: 2px solid hsl(var(--cal-ring));
360
+ outline-offset: 2px;
361
+ border-radius: var(--cal-radius-sm);
362
+ }
363
+
364
+ [hidden] {
365
+ display: none !important;
366
+ }
367
+ `, ue = `
368
+ @keyframes cal-fade-in {
369
+ from { opacity: 0; }
370
+ to { opacity: 1; }
371
+ }
372
+
373
+ @keyframes cal-slide-up {
374
+ from {
375
+ opacity: 0;
376
+ transform: translateY(4px);
377
+ }
378
+ to {
379
+ opacity: 1;
380
+ transform: translateY(0);
381
+ }
382
+ }
383
+
384
+ @keyframes cal-slide-left {
385
+ from {
386
+ opacity: 0;
387
+ transform: translateX(16px);
388
+ }
389
+ to {
390
+ opacity: 1;
391
+ transform: translateX(0);
392
+ }
393
+ }
394
+
395
+ @keyframes cal-slide-right {
396
+ from {
397
+ opacity: 0;
398
+ transform: translateX(-16px);
399
+ }
400
+ to {
401
+ opacity: 1;
402
+ transform: translateX(0);
403
+ }
404
+ }
405
+
406
+ .cal-animate-fade { animation: cal-fade-in 150ms cubic-bezier(0.16, 1, 0.3, 1); }
407
+ .cal-animate-slide-up { animation: cal-slide-up 200ms cubic-bezier(0.16, 1, 0.3, 1); }
408
+ .cal-animate-slide-left { animation: cal-slide-left 200ms cubic-bezier(0.16, 1, 0.3, 1); }
409
+ .cal-animate-slide-right { animation: cal-slide-right 200ms cubic-bezier(0.16, 1, 0.3, 1); }
410
+
411
+ @keyframes cal-shimmer {
412
+ 0% { background-position: -200% 0; }
413
+ 100% { background-position: 200% 0; }
414
+ }
415
+
416
+ .cal-skeleton {
417
+ background: linear-gradient(
418
+ 90deg,
419
+ hsl(var(--cal-bg-muted)) 25%,
420
+ hsl(var(--cal-hover)) 50%,
421
+ hsl(var(--cal-bg-muted)) 75%
422
+ );
423
+ background-size: 200% 100%;
424
+ animation: cal-shimmer 1.5s infinite ease-in-out;
425
+ border-radius: 999px;
426
+ }
427
+
428
+ .cal-skeleton--rect {
429
+ border-radius: var(--cal-radius-sm);
430
+ }
431
+ `, X = {
432
+ blue: { bg: "var(--cal-booking-blue-bg)", fg: "var(--cal-booking-blue-fg)", hover: "var(--cal-booking-blue-hover)" },
433
+ green: { bg: "var(--cal-booking-green-bg)", fg: "var(--cal-booking-green-fg)", hover: "var(--cal-booking-green-hover)" },
434
+ red: { bg: "var(--cal-booking-red-bg)", fg: "var(--cal-booking-red-fg)", hover: "var(--cal-booking-red-hover)" },
435
+ orange: { bg: "var(--cal-booking-orange-bg)", fg: "var(--cal-booking-orange-fg)", hover: "var(--cal-booking-orange-hover)" },
436
+ gray: { bg: "var(--cal-booking-gray-bg)", fg: "var(--cal-booking-gray-fg)", hover: "var(--cal-booking-gray-hover)" }
437
+ }, T = "blue";
438
+ function B(s) {
439
+ return X[s] || X[T];
440
+ }
441
+ function he(s, e = [], a = {}, t = null) {
442
+ const n = e.find((p) => p.end === s), r = e.find((p) => p.start === s), o = e.find(
443
+ (p) => p.start < s && p.end > s
444
+ );
445
+ let l = "available", i = null, g = !1, h = null, u = null, d = null;
446
+ n && r ? (l = "half-day", g = !0, h = B(n.color || T), u = B(r.color || T)) : o ? (l = "booked", d = B(o.color || T)) : r && !n ? (l = "checkin-only", u = B(r.color || T)) : n && !r && (l = "checkout-only", h = B(n.color || T));
447
+ const b = a[s];
448
+ if (b && (b.status && (l = b.status), b.label !== void 0 && (i = b.label)), t) {
449
+ const p = t(s);
450
+ p && (p.status && (l = p.status), p.label !== void 0 && (i = p.label));
451
+ }
452
+ return { status: l, label: i, checkoutBooking: n, checkinBooking: r, halfDay: g, colorOut: h, colorIn: u, colorFull: d };
453
+ }
454
+ function pe(s, e, a = []) {
455
+ if (!s || !e) return !0;
456
+ const t = s < e ? s : e, n = s < e ? e : s;
457
+ for (const r of a)
458
+ if (t < r.end && n > r.start)
459
+ return !1;
460
+ return !0;
461
+ }
462
+ function be(s, e, a = []) {
463
+ return !s || !e ? !1 : !pe(s, e, a);
464
+ }
465
+ function fe(s) {
466
+ const {
467
+ year: e,
468
+ month: a,
469
+ firstDay: t = 0,
470
+ selectedDates: n = [],
471
+ rangeStart: r,
472
+ rangeEnd: o,
473
+ hoverDate: l,
474
+ minDate: i,
475
+ maxDate: g,
476
+ disabledDates: h = [],
477
+ mode: u = "single",
478
+ focusedDate: d,
479
+ onSelect: b,
480
+ onHover: p,
481
+ // Booking-specific params
482
+ bookings: C = null,
483
+ dayData: k = null,
484
+ labelFormula: w = null,
485
+ showLabelsOnHover: V = !1
486
+ } = s, S = C !== null, A = document.createElement("div");
487
+ A.setAttribute("role", "grid"), A.classList.add("cal-grid");
488
+ const O = document.createElement("div");
489
+ O.setAttribute("role", "row"), O.classList.add("cal-weekdays");
490
+ for (const _ of oe(t)) {
491
+ const E = document.createElement("div");
492
+ E.setAttribute("role", "columnheader"), E.setAttribute("aria-label", _), E.classList.add("cal-weekday"), E.textContent = _, O.appendChild(E);
493
+ }
494
+ A.appendChild(O);
495
+ const ee = ce(e, a, t), j = u === "range" && r && !o && l || S && r && !o && l ? l : o, te = S ? be(r, l, C) : !1;
496
+ let Y;
497
+ return ee.forEach((_, E) => {
498
+ E % 7 === 0 && (Y = document.createElement("div"), Y.setAttribute("role", "row"), Y.classList.add("cal-row"), A.appendChild(Y));
499
+ const c = document.createElement("button");
500
+ c.setAttribute("role", "gridcell"), c.setAttribute("part", "day"), c.classList.add("cal-day");
501
+ const f = _.dateString;
502
+ c.dataset.date = f;
503
+ const ae = new Date(_.year, _.month, _.day);
504
+ c.setAttribute("aria-label", ae.toLocaleDateString("en-US", {
505
+ weekday: "long",
506
+ year: "numeric",
507
+ month: "long",
508
+ day: "numeric"
509
+ })), _.isCurrentMonth || c.classList.add("cal-day--outside"), _.isToday && c.classList.add("cal-day--today");
510
+ let y = null, $ = !1;
511
+ if (S) {
512
+ y = he(f, C, k || {}, w);
513
+ const { status: v, label: x, halfDay: P, colorOut: F, colorIn: R, colorFull: H } = y;
514
+ if (v === "booked" && (c.classList.add("cal-day--booked"), H && (c.style.setProperty("--booking-bg", `hsl(${H.bg})`), c.style.setProperty("--booking-fg", `hsl(${H.fg})`), c.style.setProperty("--booking-hover", `hsl(${H.hover})`)), $ = !0), v === "blocked" && (c.classList.add("cal-day--blocked"), $ = !0), P && (c.classList.add("cal-day--half-day"), F && c.style.setProperty("--half-day-color-out", `hsl(${F.bg})`), R && c.style.setProperty("--half-day-color-in", `hsl(${R.bg})`), $ = !0), v === "checkout-only" && (c.classList.add("cal-day--checkout-only"), F && c.style.setProperty("--half-day-color-out", `hsl(${F.bg})`)), v === "checkin-only" && (c.classList.add("cal-day--checkin-only"), R && c.style.setProperty("--half-day-color-in", `hsl(${R.bg})`)), V) {
515
+ let D = null;
516
+ if (P && y.checkoutBooking && y.checkinBooking)
517
+ D = `${y.checkoutBooking.label || ""} / ${y.checkinBooking.label || ""}`;
518
+ else if (v === "booked") {
519
+ const N = C.find((J) => J.start <= f && J.end > f);
520
+ N && (D = N.label);
521
+ } else v === "checkout-only" && y.checkoutBooking ? D = y.checkoutBooking.label : v === "checkin-only" && y.checkinBooking && (D = y.checkinBooking.label);
522
+ D && c.setAttribute("data-booking-label", D);
523
+ }
524
+ if (te && r && !o && l) {
525
+ const D = r < l ? r : l, N = r < l ? l : r;
526
+ f >= D && f <= N && c.classList.add("cal-day--invalid-range");
527
+ }
528
+ }
529
+ if (S ? r && o && (M(f, r) || M(f, o)) ? (c.classList.add("cal-day--selected"), c.setAttribute("aria-selected", "true")) : c.setAttribute("aria-selected", "false") : n.some((x) => M(x, f)) ? (c.classList.add("cal-day--selected"), c.setAttribute("aria-selected", "true")) : c.setAttribute("aria-selected", "false"), (u === "range" || S) && r && j) {
530
+ const v = M(f, r), x = M(f, j), P = ie(f, r, j);
531
+ v && c.classList.add("cal-day--range-start"), x && c.classList.add("cal-day--range-end"), P && !v && !x && c.classList.add("cal-day--in-range");
532
+ }
533
+ const G = ve(f, i, g, h) || $;
534
+ if (G && (c.classList.add("cal-day--disabled"), c.disabled = !0, c.setAttribute("aria-disabled", "true")), d && M(f, d) ? c.setAttribute("tabindex", "0") : c.setAttribute("tabindex", "-1"), S && y && y.label != null) {
535
+ c.classList.add("cal-day--with-label");
536
+ const v = document.createElement("span");
537
+ v.classList.add("cal-day__number"), v.textContent = _.day, c.appendChild(v);
538
+ const x = document.createElement("span");
539
+ x.classList.add("cal-day__label"), x.textContent = y.label, c.appendChild(x);
540
+ } else
541
+ c.textContent = _.day;
542
+ G ? S && c.addEventListener("mouseenter", () => p == null ? void 0 : p(f)) : (c.addEventListener("click", () => b == null ? void 0 : b(f)), c.addEventListener("mouseenter", () => p == null ? void 0 : p(f))), Y.appendChild(c);
543
+ }), A.addEventListener("mouseleave", () => p == null ? void 0 : p(null)), A;
544
+ }
545
+ function ve(s, e, a, t) {
546
+ return !!(t.includes(s) || e && s < e || a && s > a);
547
+ }
548
+ const ye = `
549
+ .cal-grid {
550
+ display: flex;
551
+ flex-direction: column;
552
+ gap: 2px;
553
+ }
554
+
555
+ .cal-weekdays {
556
+ display: grid;
557
+ grid-template-columns: repeat(7, var(--cal-cell-size));
558
+ gap: 0;
559
+ margin-bottom: 4px;
560
+ }
561
+
562
+ .cal-weekday {
563
+ display: flex;
564
+ align-items: center;
565
+ justify-content: center;
566
+ height: var(--cal-cell-size);
567
+ font-size: 12px;
568
+ font-weight: 500;
569
+ color: hsl(var(--cal-fg-muted));
570
+ user-select: none;
571
+ }
572
+
573
+ .cal-row {
574
+ display: grid;
575
+ grid-template-columns: repeat(7, var(--cal-cell-size));
576
+ gap: 0;
577
+ }
578
+
579
+ .cal-day {
580
+ display: flex;
581
+ align-items: center;
582
+ justify-content: center;
583
+ width: var(--cal-cell-size);
584
+ height: var(--cal-cell-size);
585
+ font-size: 14px;
586
+ border-radius: var(--cal-radius-sm);
587
+ transition: background var(--cal-transition), color var(--cal-transition);
588
+ position: relative;
589
+ user-select: none;
590
+ }
591
+
592
+ .cal-day:not(.cal-day--disabled):not(.cal-day--selected):not(.cal-day--booked):not(.cal-day--half-day):not(.cal-day--blocked):not(.cal-day--checkout-only):not(.cal-day--checkin-only):hover {
593
+ background: hsl(var(--cal-hover));
594
+ }
595
+
596
+ .cal-day--outside {
597
+ color: hsl(var(--cal-fg-muted));
598
+ opacity: 0.4;
599
+ }
600
+
601
+ .cal-day--today:not(.cal-day--selected):not(.cal-day--booked):not(.cal-day--half-day):not(.cal-day--checkout-only):not(.cal-day--checkin-only) {
602
+ border: 1px solid hsl(var(--cal-border));
603
+ font-weight: 600;
604
+ }
605
+
606
+ .cal-day--selected {
607
+ background: hsl(var(--cal-accent));
608
+ color: hsl(var(--cal-accent-fg));
609
+ font-weight: 600;
610
+ }
611
+
612
+ .cal-day--range-start {
613
+ background: hsl(var(--cal-accent));
614
+ color: hsl(var(--cal-accent-fg));
615
+ font-weight: 600;
616
+ border-radius: var(--cal-radius-sm) 0 0 var(--cal-radius-sm);
617
+ }
618
+
619
+ .cal-day--range-end {
620
+ background: hsl(var(--cal-accent));
621
+ color: hsl(var(--cal-accent-fg));
622
+ font-weight: 600;
623
+ border-radius: 0 var(--cal-radius-sm) var(--cal-radius-sm) 0;
624
+ }
625
+
626
+ .cal-day--range-start.cal-day--range-end {
627
+ border-radius: var(--cal-radius-sm);
628
+ }
629
+
630
+ .cal-day--in-range {
631
+ background: hsl(var(--cal-accent-subtle));
632
+ border-radius: 0;
633
+ }
634
+
635
+ .cal-day--in-range:hover {
636
+ background: hsl(var(--cal-accent-subtle)) !important;
637
+ }
638
+
639
+ .cal-day--disabled {
640
+ opacity: 0.3;
641
+ cursor: not-allowed;
642
+ }
643
+
644
+ /* ── Booking-specific styles ── */
645
+
646
+ /* Booked (fully occupied) */
647
+ .cal-day--booked {
648
+ background: var(--booking-bg, hsl(var(--cal-booking-blue-bg)));
649
+ color: var(--booking-fg, hsl(var(--cal-booking-blue-fg)));
650
+ cursor: not-allowed;
651
+ }
652
+
653
+ .cal-day--booked:hover {
654
+ background: var(--booking-hover, hsl(var(--cal-booking-blue-hover)));
655
+ }
656
+
657
+ /* Blocked */
658
+ .cal-day--blocked {
659
+ background: hsl(var(--cal-bg-muted));
660
+ opacity: 0.4;
661
+ cursor: not-allowed;
662
+ }
663
+
664
+ /* Half-day diagonal (checkout + checkin on same day) */
665
+ .cal-day--half-day {
666
+ background: linear-gradient(135deg,
667
+ var(--half-day-color-out, hsl(var(--cal-booking-blue-bg))) 49.5%,
668
+ hsl(var(--cal-bg)) 49.5%, hsl(var(--cal-bg)) 50.5%,
669
+ var(--half-day-color-in, hsl(var(--cal-booking-green-bg))) 50.5%);
670
+ cursor: not-allowed;
671
+ }
672
+
673
+ /* Checkout-only (last day of a booking — outgoing triangle) */
674
+ .cal-day--checkout-only {
675
+ background: linear-gradient(135deg,
676
+ var(--half-day-color-out, hsl(var(--cal-booking-blue-bg))) 49.5%,
677
+ hsl(var(--cal-bg)) 49.5%);
678
+ }
679
+
680
+ /* Checkin-only (first day of a booking — incoming triangle) */
681
+ .cal-day--checkin-only {
682
+ background: linear-gradient(135deg,
683
+ hsl(var(--cal-bg)) 50.5%,
684
+ var(--half-day-color-in, hsl(var(--cal-booking-blue-bg))) 50.5%);
685
+ }
686
+
687
+ /* Diagonal cells: standard text color for clean contrast */
688
+ .cal-day--half-day,
689
+ .cal-day--checkout-only,
690
+ .cal-day--checkin-only {
691
+ color: hsl(var(--cal-fg));
692
+ }
693
+
694
+ /* ── Diagonal + selection compounds ── */
695
+
696
+ /* Checkout-only — range boundary: accent-subtle fill + refined ring */
697
+ .cal-day--checkout-only.cal-day--range-start,
698
+ .cal-day--checkout-only.cal-day--range-end,
699
+ .cal-day--checkout-only.cal-day--selected {
700
+ background: linear-gradient(135deg,
701
+ var(--half-day-color-out, hsl(var(--cal-booking-blue-bg))) 49.5%,
702
+ hsl(var(--cal-accent-subtle)) 50.5%);
703
+ color: hsl(var(--cal-fg));
704
+ box-shadow: inset 0 0 0 1.5px hsl(var(--cal-accent) / 0.3);
705
+ }
706
+
707
+ /* Checkout-only — in range: accent-subtle fill */
708
+ .cal-day--checkout-only.cal-day--in-range {
709
+ background: linear-gradient(135deg,
710
+ var(--half-day-color-out, hsl(var(--cal-booking-blue-bg))) 49.5%,
711
+ hsl(var(--cal-accent-subtle)) 50.5%);
712
+ }
713
+
714
+ /* Checkin-only — range boundary: accent-subtle fill + refined ring */
715
+ .cal-day--checkin-only.cal-day--range-start,
716
+ .cal-day--checkin-only.cal-day--range-end,
717
+ .cal-day--checkin-only.cal-day--selected {
718
+ background: linear-gradient(135deg,
719
+ hsl(var(--cal-accent-subtle)) 49.5%,
720
+ var(--half-day-color-in, hsl(var(--cal-booking-blue-bg))) 50.5%);
721
+ color: hsl(var(--cal-fg));
722
+ box-shadow: inset 0 0 0 1.5px hsl(var(--cal-accent) / 0.3);
723
+ }
724
+
725
+ /* Checkin-only — in range: accent-subtle fill */
726
+ .cal-day--checkin-only.cal-day--in-range {
727
+ background: linear-gradient(135deg,
728
+ hsl(var(--cal-accent-subtle)) 49.5%,
729
+ var(--half-day-color-in, hsl(var(--cal-booking-blue-bg))) 50.5%);
730
+ }
731
+
732
+ /* Half-day in range — accent-subtle stripe between booking triangles */
733
+ .cal-day--half-day.cal-day--in-range {
734
+ background: linear-gradient(135deg,
735
+ var(--half-day-color-out, hsl(var(--cal-booking-blue-bg))) 49.5%,
736
+ hsl(var(--cal-accent-subtle)) 49.5%, hsl(var(--cal-accent-subtle)) 50.5%,
737
+ var(--half-day-color-in, hsl(var(--cal-booking-green-bg))) 50.5%);
738
+ }
739
+
740
+ /* Invalid range preview (crosses a booking) */
741
+ .cal-day--invalid-range {
742
+ background: hsl(var(--cal-booking-red-bg));
743
+ border-radius: 0;
744
+ }
745
+
746
+ /* Booked/half-day/diagonal cells stay opaque even when disabled */
747
+ .cal-day--disabled.cal-day--booked,
748
+ .cal-day--disabled.cal-day--half-day,
749
+ .cal-day--disabled.cal-day--checkout-only,
750
+ .cal-day--disabled.cal-day--checkin-only {
751
+ opacity: 1;
752
+ }
753
+
754
+ /* Sublabel spans */
755
+ .cal-day__number {
756
+ font-size: 13px;
757
+ font-weight: 500;
758
+ line-height: 1;
759
+ }
760
+
761
+ .cal-day__label {
762
+ font-size: 9px;
763
+ font-weight: 500;
764
+ line-height: 1;
765
+ opacity: 0.8;
766
+ }
767
+
768
+ .cal-day--with-label {
769
+ flex-direction: column;
770
+ gap: 1px;
771
+ }
772
+
773
+ /* CSS Tooltip */
774
+ .cal-day[data-booking-label] {
775
+ overflow: visible;
776
+ }
777
+
778
+ .cal-day[data-booking-label]:hover::after {
779
+ content: attr(data-booking-label);
780
+ position: absolute;
781
+ bottom: calc(100% + 6px);
782
+ left: 50%;
783
+ transform: translateX(-50%);
784
+ padding: 4px 8px;
785
+ font-size: 11px;
786
+ font-weight: 500;
787
+ white-space: nowrap;
788
+ color: hsl(var(--cal-accent-fg));
789
+ background: hsl(var(--cal-accent));
790
+ border-radius: 4px;
791
+ pointer-events: none;
792
+ z-index: 10;
793
+ }
794
+
795
+ .cal-day[data-booking-label]:hover::before {
796
+ content: '';
797
+ position: absolute;
798
+ bottom: calc(100% + 2px);
799
+ left: 50%;
800
+ transform: translateX(-50%);
801
+ border: 4px solid transparent;
802
+ border-top-color: hsl(var(--cal-accent));
803
+ pointer-events: none;
804
+ z-index: 10;
805
+ }
806
+ `, Q = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M10 12L6 8l4-4"/></svg>', Z = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M6 4l4 4-4 4"/></svg>';
807
+ function q({ year: s, month: e, onPrev: a, onNext: t, onTitleClick: n }) {
808
+ const r = document.createElement("div");
809
+ r.classList.add("cal-nav");
810
+ const o = document.createElement("button");
811
+ o.classList.add("cal-nav__btn", "cal-nav__btn--prev"), o.innerHTML = Q, o.setAttribute("aria-label", "Previous month"), o.addEventListener("click", a);
812
+ const l = n ? "button" : "div", i = document.createElement(l);
813
+ i.classList.add("cal-nav__title"), n && (i.classList.add("cal-nav__title--interactive"), i.setAttribute("aria-label", `Select month and year, currently ${I[e]} ${s}`), i.addEventListener("click", n)), i.setAttribute("aria-live", "polite"), i.textContent = `${I[e]} ${s}`;
814
+ const g = document.createElement("button");
815
+ return g.classList.add("cal-nav__btn", "cal-nav__btn--next"), g.innerHTML = Z, g.setAttribute("aria-label", "Next month"), g.addEventListener("click", t), r.appendChild(o), r.appendChild(i), r.appendChild(g), r;
816
+ }
817
+ const me = `
818
+ .cal-nav {
819
+ display: flex;
820
+ align-items: center;
821
+ justify-content: space-between;
822
+ padding: 0 4px;
823
+ margin-bottom: 8px;
824
+ }
825
+
826
+ .cal-nav__btn {
827
+ display: flex;
828
+ align-items: center;
829
+ justify-content: center;
830
+ width: 28px;
831
+ height: 28px;
832
+ border-radius: var(--cal-radius-sm);
833
+ color: hsl(var(--cal-fg));
834
+ transition: background var(--cal-transition);
835
+ }
836
+
837
+ .cal-nav__btn:hover {
838
+ background: hsl(var(--cal-hover));
839
+ }
840
+
841
+ .cal-nav__title {
842
+ font-size: 14px;
843
+ font-weight: 600;
844
+ color: hsl(var(--cal-fg));
845
+ user-select: none;
846
+ }
847
+
848
+ .cal-nav__title--interactive {
849
+ cursor: pointer;
850
+ padding: 2px 8px;
851
+ border-radius: var(--cal-radius-sm);
852
+ transition: background var(--cal-transition);
853
+ }
854
+
855
+ .cal-nav__title--interactive:hover {
856
+ background: hsl(var(--cal-hover));
857
+ }
858
+ `, ke = [
859
+ "Jan",
860
+ "Feb",
861
+ "Mar",
862
+ "Apr",
863
+ "May",
864
+ "Jun",
865
+ "Jul",
866
+ "Aug",
867
+ "Sep",
868
+ "Oct",
869
+ "Nov",
870
+ "Dec"
871
+ ];
872
+ function _e({
873
+ pickerYear: s,
874
+ viewMonth: e,
875
+ viewYear: a,
876
+ onMonthSelect: t,
877
+ onYearPrev: n,
878
+ onYearNext: r,
879
+ onClose: o
880
+ }) {
881
+ const l = document.createElement("div");
882
+ l.classList.add("cal-myp", "cal-animate-fade");
883
+ const i = document.createElement("div");
884
+ i.classList.add("cal-myp__year-nav");
885
+ const g = document.createElement("button");
886
+ g.classList.add("cal-nav__btn"), g.innerHTML = Q, g.setAttribute("aria-label", "Previous year"), g.addEventListener("click", n);
887
+ const h = document.createElement("div");
888
+ h.classList.add("cal-myp__year-label"), h.textContent = s;
889
+ const u = document.createElement("button");
890
+ u.classList.add("cal-nav__btn"), u.innerHTML = Z, u.setAttribute("aria-label", "Next year"), u.addEventListener("click", r), i.appendChild(g), i.appendChild(h), i.appendChild(u), l.appendChild(i);
891
+ const d = document.createElement("div");
892
+ d.classList.add("cal-myp__grid");
893
+ const b = /* @__PURE__ */ new Date(), p = b.getMonth(), C = b.getFullYear();
894
+ for (let k = 0; k < 12; k++) {
895
+ const w = document.createElement("button");
896
+ w.classList.add("cal-myp__cell"), w.textContent = ke[k], k === e && s === a && w.classList.add("cal-myp__cell--active"), k === p && s === C && w.classList.add("cal-myp__cell--today"), w.addEventListener("click", () => t(k, s)), d.appendChild(w);
897
+ }
898
+ return l.appendChild(d), l.addEventListener("keydown", (k) => {
899
+ k.key === "Escape" && (k.stopPropagation(), o());
900
+ }), l;
901
+ }
902
+ const xe = `
903
+ .cal-myp {
904
+ width: calc(7 * var(--cal-cell-size));
905
+ }
906
+
907
+ .cal-myp__year-nav {
908
+ display: flex;
909
+ align-items: center;
910
+ justify-content: space-between;
911
+ padding: 0 4px;
912
+ margin-bottom: 8px;
913
+ }
914
+
915
+ .cal-myp__year-label {
916
+ font-size: 14px;
917
+ font-weight: 600;
918
+ color: hsl(var(--cal-fg));
919
+ user-select: none;
920
+ }
921
+
922
+ .cal-myp__grid {
923
+ display: grid;
924
+ grid-template-columns: repeat(3, 1fr);
925
+ gap: 4px;
926
+ }
927
+
928
+ .cal-myp__cell {
929
+ display: flex;
930
+ align-items: center;
931
+ justify-content: center;
932
+ height: calc(var(--cal-cell-size) * 1.5);
933
+ font-size: 13px;
934
+ font-weight: 500;
935
+ color: hsl(var(--cal-fg));
936
+ border-radius: var(--cal-radius-sm);
937
+ cursor: pointer;
938
+ transition: background var(--cal-transition);
939
+ user-select: none;
940
+ }
941
+
942
+ .cal-myp__cell:hover {
943
+ background: hsl(var(--cal-hover));
944
+ }
945
+
946
+ .cal-myp__cell--active {
947
+ background: hsl(var(--cal-accent));
948
+ color: hsl(var(--cal-accent-fg));
949
+ font-weight: 600;
950
+ }
951
+
952
+ .cal-myp__cell--active:hover {
953
+ background: hsl(var(--cal-accent));
954
+ }
955
+
956
+ .cal-myp__cell--today:not(.cal-myp__cell--active) {
957
+ border: 1px solid hsl(var(--cal-border));
958
+ font-weight: 600;
959
+ }
960
+ `;
961
+ function we() {
962
+ return [
963
+ {
964
+ key: "today",
965
+ label: "Today",
966
+ resolve() {
967
+ const s = K();
968
+ return { start: s, end: s };
969
+ }
970
+ },
971
+ {
972
+ key: "this-week",
973
+ label: "This Week",
974
+ resolve() {
975
+ const s = /* @__PURE__ */ new Date(), e = s.getDay(), a = new Date(s);
976
+ a.setDate(s.getDate() - e);
977
+ const t = new Date(a);
978
+ return t.setDate(a.getDate() + 6), { start: m(a), end: m(t) };
979
+ }
980
+ },
981
+ {
982
+ key: "next-7",
983
+ label: "Next 7 Days",
984
+ resolve() {
985
+ const s = /* @__PURE__ */ new Date(), e = /* @__PURE__ */ new Date();
986
+ return e.setDate(s.getDate() + 6), { start: m(s), end: m(e) };
987
+ }
988
+ },
989
+ {
990
+ key: "next-30",
991
+ label: "Next 30 Days",
992
+ resolve() {
993
+ const s = /* @__PURE__ */ new Date(), e = /* @__PURE__ */ new Date();
994
+ return e.setDate(s.getDate() + 29), { start: m(s), end: m(e) };
995
+ }
996
+ }
997
+ ];
998
+ }
999
+ function De({ presetKeys: s, onSelect: e }) {
1000
+ const a = document.createElement("div");
1001
+ a.classList.add("cal-presets");
1002
+ const t = we(), n = s.map((r) => t.find((o) => o.key === r)).filter(Boolean);
1003
+ for (const r of n) {
1004
+ const o = document.createElement("button");
1005
+ o.classList.add("cal-preset"), o.textContent = r.label, o.addEventListener("click", () => {
1006
+ e == null || e(r.resolve());
1007
+ }), a.appendChild(o);
1008
+ }
1009
+ return a;
1010
+ }
1011
+ const Le = `
1012
+ .cal-presets {
1013
+ display: flex;
1014
+ flex-wrap: wrap;
1015
+ gap: 6px;
1016
+ padding: 8px 4px;
1017
+ border-top: 1px solid hsl(var(--cal-border));
1018
+ margin-top: 8px;
1019
+ }
1020
+
1021
+ .cal-preset {
1022
+ display: inline-flex;
1023
+ align-items: center;
1024
+ height: 28px;
1025
+ padding: 0 10px;
1026
+ font-size: 12px;
1027
+ font-weight: 500;
1028
+ border-radius: 999px;
1029
+ background: hsl(var(--cal-bg-muted));
1030
+ color: hsl(var(--cal-fg));
1031
+ transition: background var(--cal-transition);
1032
+ }
1033
+
1034
+ .cal-preset:hover {
1035
+ background: hsl(var(--cal-hover));
1036
+ }
1037
+ `;
1038
+ function Se({ trigger: s, content: e, onClose: a }) {
1039
+ const t = document.createElement("div");
1040
+ t.classList.add("cal-popover"), t.setAttribute("role", "dialog"), t.setAttribute("aria-modal", "false"), t.style.display = "none", t.appendChild(e);
1041
+ let n = !1;
1042
+ function r() {
1043
+ t.classList.remove("cal-popover--above");
1044
+ const u = s.getBoundingClientRect(), d = t.offsetHeight, b = window.innerHeight - u.bottom, p = u.top;
1045
+ b < d + 8 && p > b ? (t.classList.add("cal-popover--above"), t.style.top = "auto", t.style.bottom = "100%", t.style.marginBottom = "4px", t.style.marginTop = "0") : (t.style.top = "100%", t.style.bottom = "auto", t.style.marginTop = "4px", t.style.marginBottom = "0");
1046
+ }
1047
+ function o() {
1048
+ n || (n = !0, t.style.display = "", t.classList.add("cal-animate-slide-up"), requestAnimationFrame(() => r()), document.addEventListener("click", i, !0), document.addEventListener("keydown", g, !0));
1049
+ }
1050
+ function l() {
1051
+ n && (n = !1, t.style.display = "none", t.classList.remove("cal-animate-slide-up"), document.removeEventListener("click", i, !0), document.removeEventListener("keydown", g, !0), a == null || a());
1052
+ }
1053
+ function i(u) {
1054
+ var b;
1055
+ const d = (b = s.getRootNode()) == null ? void 0 : b.host;
1056
+ d && !d.contains(u.target) && u.target !== d && l();
1057
+ }
1058
+ function g(u) {
1059
+ u.key === "Escape" && (u.stopPropagation(), l());
1060
+ }
1061
+ function h() {
1062
+ n && (n = !1, t.style.display = "none", t.classList.remove("cal-animate-slide-up")), document.removeEventListener("click", i, !0), document.removeEventListener("keydown", g, !0);
1063
+ }
1064
+ return { panel: t, open: o, close: l, destroy: h, get isOpen() {
1065
+ return n;
1066
+ } };
1067
+ }
1068
+ const Ee = `
1069
+ .cal-popover-wrapper {
1070
+ position: relative;
1071
+ display: inline-block;
1072
+ }
1073
+
1074
+ .cal-popover {
1075
+ position: absolute;
1076
+ left: 0;
1077
+ z-index: 50;
1078
+ background: hsl(var(--cal-bg));
1079
+ border: 1px solid hsl(var(--cal-border));
1080
+ border-radius: var(--cal-radius);
1081
+ box-shadow: 0 4px 16px -2px rgba(0, 0, 0, 0.08), 0 2px 6px -2px rgba(0, 0, 0, 0.04);
1082
+ padding: 12px;
1083
+ }
1084
+
1085
+ .cal-trigger {
1086
+ display: inline-flex;
1087
+ align-items: center;
1088
+ gap: 8px;
1089
+ height: 36px;
1090
+ padding: 0 12px;
1091
+ font-size: 14px;
1092
+ border: 1px solid hsl(var(--cal-border));
1093
+ border-radius: var(--cal-radius-sm);
1094
+ background: hsl(var(--cal-bg));
1095
+ color: hsl(var(--cal-fg));
1096
+ cursor: pointer;
1097
+ transition: border-color var(--cal-transition);
1098
+ white-space: nowrap;
1099
+ }
1100
+
1101
+ .cal-trigger:hover {
1102
+ border-color: hsl(var(--cal-fg-muted));
1103
+ }
1104
+
1105
+ .cal-trigger--placeholder {
1106
+ color: hsl(var(--cal-fg-muted));
1107
+ }
1108
+
1109
+ .cal-trigger__icon {
1110
+ display: flex;
1111
+ color: hsl(var(--cal-fg-muted));
1112
+ }
1113
+ `;
1114
+ function Me({ rows: s = 5 } = {}) {
1115
+ const e = document.createElement("div");
1116
+ e.setAttribute("role", "status"), e.setAttribute("aria-label", "Loading..."), e.classList.add("cal-skeleton-calendar-grid");
1117
+ for (let t = 0; t < 7; t++) {
1118
+ const n = document.createElement("div");
1119
+ n.classList.add("cal-skeleton", "cal-skeleton-calendar-grid__header"), e.appendChild(n);
1120
+ }
1121
+ const a = 7 * s;
1122
+ for (let t = 0; t < a; t++) {
1123
+ const n = document.createElement("div");
1124
+ n.classList.add("cal-skeleton", "cal-skeleton-calendar-grid__day"), e.appendChild(n);
1125
+ }
1126
+ return e;
1127
+ }
1128
+ const Ce = `
1129
+ .cal-skeleton-time-grid {
1130
+ display: grid;
1131
+ grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
1132
+ gap: 6px;
1133
+ padding: 4px;
1134
+ }
1135
+
1136
+ .cal-skeleton-time-grid--duration {
1137
+ grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
1138
+ }
1139
+
1140
+ .cal-skeleton-time-grid .cal-skeleton {
1141
+ height: 40px;
1142
+ }
1143
+
1144
+ .cal-skeleton-calendar-grid {
1145
+ display: grid;
1146
+ grid-template-columns: repeat(7, 1fr);
1147
+ gap: 2px;
1148
+ padding: 4px;
1149
+ }
1150
+
1151
+ .cal-skeleton-calendar-grid__header {
1152
+ height: 20px;
1153
+ margin-bottom: 4px;
1154
+ }
1155
+
1156
+ .cal-skeleton-calendar-grid__day {
1157
+ height: var(--cal-cell-size, 36px);
1158
+ aspect-ratio: 1;
1159
+ border-radius: var(--cal-radius-sm) !important;
1160
+ }
1161
+ `, U = {
1162
+ error: '<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><circle cx="7" cy="7" r="6"/><path d="M7 4v3M7 9.5v.01"/></svg>',
1163
+ warning: '<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><path d="M7 1.5L1 12.5h12L7 1.5zM7 6v2.5M7 10.5v.01"/></svg>',
1164
+ info: '<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><circle cx="7" cy="7" r="6"/><path d="M7 6.5V10M7 4.5v.01"/></svg>',
1165
+ success: '<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><circle cx="7" cy="7" r="6"/><path d="M4.5 7l2 2L9.5 5"/></svg>'
1166
+ };
1167
+ function Ae({ type: s = "info", message: e, dismissible: a = !0, onDismiss: t }) {
1168
+ const n = document.createElement("div");
1169
+ n.classList.add("cal-status", `cal-status--${s}`, "cal-animate-slide-up"), n.setAttribute("role", s === "error" ? "alert" : "status"), n.setAttribute("aria-live", s === "error" ? "assertive" : "polite");
1170
+ const r = document.createElement("span");
1171
+ r.classList.add("cal-status__icon"), r.innerHTML = U[s] || U.info, n.appendChild(r);
1172
+ const o = document.createElement("span");
1173
+ if (o.classList.add("cal-status__text"), o.textContent = e, n.appendChild(o), a) {
1174
+ const l = document.createElement("button");
1175
+ l.classList.add("cal-status__close"), l.setAttribute("aria-label", "Dismiss"), l.innerHTML = '<svg width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><path d="M3 3l6 6M9 3l-6 6"/></svg>', l.addEventListener("click", () => t == null ? void 0 : t()), n.appendChild(l);
1176
+ }
1177
+ return n;
1178
+ }
1179
+ const Te = `
1180
+ .cal-status {
1181
+ display: flex;
1182
+ align-items: center;
1183
+ gap: 8px;
1184
+ padding: 8px 12px;
1185
+ border-radius: var(--cal-radius-sm);
1186
+ font-size: 12px;
1187
+ line-height: 1.4;
1188
+ margin-bottom: 8px;
1189
+ }
1190
+
1191
+ .cal-status__icon {
1192
+ flex-shrink: 0;
1193
+ display: flex;
1194
+ }
1195
+
1196
+ .cal-status__text {
1197
+ flex: 1;
1198
+ min-width: 0;
1199
+ }
1200
+
1201
+ .cal-status__close {
1202
+ flex-shrink: 0;
1203
+ display: flex;
1204
+ align-items: center;
1205
+ justify-content: center;
1206
+ width: 20px;
1207
+ height: 20px;
1208
+ border-radius: 4px;
1209
+ cursor: pointer;
1210
+ opacity: 0.7;
1211
+ transition: opacity var(--cal-transition);
1212
+ }
1213
+
1214
+ .cal-status__close:hover {
1215
+ opacity: 1;
1216
+ }
1217
+
1218
+ .cal-status--error {
1219
+ background: hsl(var(--cal-status-error-bg));
1220
+ color: hsl(var(--cal-status-error-fg));
1221
+ border: 1px solid hsl(var(--cal-status-error-border));
1222
+ }
1223
+
1224
+ .cal-status--warning {
1225
+ background: hsl(var(--cal-status-warning-bg));
1226
+ color: hsl(var(--cal-status-warning-fg));
1227
+ border: 1px solid hsl(var(--cal-status-warning-border));
1228
+ }
1229
+
1230
+ .cal-status--info {
1231
+ background: hsl(var(--cal-status-info-bg));
1232
+ color: hsl(var(--cal-status-info-fg));
1233
+ border: 1px solid hsl(var(--cal-status-info-border));
1234
+ }
1235
+
1236
+ .cal-status--success {
1237
+ background: hsl(var(--cal-status-success-bg));
1238
+ color: hsl(var(--cal-status-success-fg));
1239
+ border: 1px solid hsl(var(--cal-status-success-border));
1240
+ }
1241
+ `, Ye = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="3" width="12" height="11" rx="2"/><path d="M5 1v3M11 1v3M2 7h12"/></svg>', Be = `
1242
+ .cal-picker {
1243
+ background: hsl(var(--cal-bg));
1244
+ border-radius: var(--cal-radius);
1245
+ user-select: none;
1246
+ }
1247
+
1248
+ :host([display="inline"]) .cal-picker {
1249
+ border: 1px solid hsl(var(--cal-border));
1250
+ padding: 12px;
1251
+ }
1252
+
1253
+ .cal-months {
1254
+ display: flex;
1255
+ gap: 16px;
1256
+ }
1257
+
1258
+ .cal-month {
1259
+ flex: 0 0 auto;
1260
+ }
1261
+ `;
1262
+ class ze extends ne {
1263
+ static get styles() {
1264
+ return [de, ge, ue, ye, me, xe, Le, Ee, Ce, Te, Be];
1265
+ }
1266
+ static get observedAttributes() {
1267
+ return ["mode", "display", "theme", "value", "min-date", "max-date", "disabled-dates", "first-day", "locale", "presets", "placeholder", "loading"];
1268
+ }
1269
+ constructor() {
1270
+ super();
1271
+ const e = /* @__PURE__ */ new Date();
1272
+ this._store = se({
1273
+ viewYear: e.getFullYear(),
1274
+ viewMonth: e.getMonth(),
1275
+ selectedDates: [],
1276
+ rangeStart: null,
1277
+ rangeEnd: null,
1278
+ hoverDate: null,
1279
+ isOpen: !1,
1280
+ focusedDate: K(),
1281
+ navDirection: null,
1282
+ pickingMonth: !1,
1283
+ pickerYear: e.getFullYear(),
1284
+ statusType: null,
1285
+ statusMessage: null,
1286
+ statusDismissible: !0
1287
+ }), this._popover = null, this._unsubscribe = null, this._rendering = !1;
1288
+ }
1289
+ // -- Attribute getters --
1290
+ get mode() {
1291
+ return this.getAttribute("mode") || "single";
1292
+ }
1293
+ get display() {
1294
+ return this.getAttribute("display") || "inline";
1295
+ }
1296
+ get placeholder() {
1297
+ return this.getAttribute("placeholder") || "Select date";
1298
+ }
1299
+ get firstDay() {
1300
+ return parseInt(this.getAttribute("first-day") || "0", 10);
1301
+ }
1302
+ get minDate() {
1303
+ return this.getAttribute("min-date") || null;
1304
+ }
1305
+ get maxDate() {
1306
+ return this.getAttribute("max-date") || null;
1307
+ }
1308
+ get loading() {
1309
+ return this.hasAttribute("loading");
1310
+ }
1311
+ set loading(e) {
1312
+ e ? this.setAttribute("loading", "") : this.removeAttribute("loading");
1313
+ }
1314
+ get disabledDates() {
1315
+ const e = this.getAttribute("disabled-dates");
1316
+ return e ? e.split(",").map((a) => a.trim()) : [];
1317
+ }
1318
+ get presetKeys() {
1319
+ const e = this.getAttribute("presets");
1320
+ return e ? e.split(",").map((a) => a.trim()) : [];
1321
+ }
1322
+ // -- Value property --
1323
+ get value() {
1324
+ const e = this._store.getState();
1325
+ return this.mode === "range" ? e.rangeStart && e.rangeEnd ? { start: e.rangeStart, end: e.rangeEnd } : null : this.mode === "multi" ? [...e.selectedDates] : e.selectedDates[0] || null;
1326
+ }
1327
+ set value(e) {
1328
+ if (this.mode === "range" && e && typeof e == "object") {
1329
+ const a = typeof e.start == "string" ? e.start : m(e.start), t = typeof e.end == "string" ? e.end : m(e.end);
1330
+ this._store.set({
1331
+ rangeStart: a,
1332
+ rangeEnd: t,
1333
+ selectedDates: [a, t]
1334
+ }), this._navigateToDate(a);
1335
+ } else this.mode === "multi" && Array.isArray(e) ? (this._store.set({ selectedDates: e }), e.length && this._navigateToDate(e[0])) : typeof e == "string" ? (this._store.set({ selectedDates: [e], rangeStart: null, rangeEnd: null }), this._navigateToDate(e)) : this._store.set({ selectedDates: [], rangeStart: null, rangeEnd: null });
1336
+ }
1337
+ _navigateToDate(e) {
1338
+ const a = L(e);
1339
+ a && this._store.set({ viewYear: a.getFullYear(), viewMonth: a.getMonth() });
1340
+ }
1341
+ connectedCallback() {
1342
+ super.connectedCallback(), this._unsubscribe = this._store.subscribe((a, t) => {
1343
+ if (this._rendering) return;
1344
+ a.hoverDate !== t.hoverDate && a.viewYear === t.viewYear && a.viewMonth === t.viewMonth && a.selectedDates === t.selectedDates && a.rangeStart === t.rangeStart && a.rangeEnd === t.rangeEnd && a.isOpen === t.isOpen && a.navDirection === t.navDirection && a.pickingMonth === t.pickingMonth && a.pickerYear === t.pickerYear ? this._updateGridHighlight(a) : this.render();
1345
+ });
1346
+ const e = this.getAttribute("value");
1347
+ if (e)
1348
+ if (this.mode === "range" && e.includes("/")) {
1349
+ const [a, t] = e.split("/");
1350
+ this.value = { start: a, end: t };
1351
+ } else this.mode === "multi" && e.includes(",") ? this.value = e.split(",").map((a) => a.trim()) : this.value = e;
1352
+ }
1353
+ disconnectedCallback() {
1354
+ var e, a;
1355
+ (e = this._unsubscribe) == null || e.call(this), (a = this._popover) == null || a.destroy(), clearTimeout(this._statusTimer);
1356
+ }
1357
+ attributeChangedCallback(e, a, t) {
1358
+ if (a !== t) {
1359
+ if (e === "value" && this._initialized)
1360
+ if (this.mode === "range" && t && t.includes("/")) {
1361
+ const [n, r] = t.split("/");
1362
+ this.value = { start: n, end: r };
1363
+ } else this.mode === "multi" && t && t.includes(",") ? this.value = t.split(",").map((n) => n.trim()) : this.value = t;
1364
+ this._initialized && this.render();
1365
+ }
1366
+ }
1367
+ // -- Selection logic --
1368
+ _handleSelect(e) {
1369
+ const a = this._store.getState();
1370
+ if (this.mode === "single")
1371
+ this._store.set({
1372
+ selectedDates: [e],
1373
+ focusedDate: e
1374
+ }), this.emit("cal:change", { value: e }), this.display === "popover" && this.close();
1375
+ else if (this.mode === "range")
1376
+ if (!a.rangeStart || a.rangeEnd)
1377
+ this._store.set({
1378
+ rangeStart: e,
1379
+ rangeEnd: null,
1380
+ selectedDates: [e],
1381
+ focusedDate: e
1382
+ });
1383
+ else {
1384
+ let t = a.rangeStart, n = e;
1385
+ t > n && ([t, n] = [n, t]), this._store.set({
1386
+ rangeStart: t,
1387
+ rangeEnd: n,
1388
+ selectedDates: [t, n],
1389
+ hoverDate: null,
1390
+ focusedDate: n
1391
+ }), this.emit("cal:change", { value: { start: t, end: n } }), this.display === "popover" && this.close();
1392
+ }
1393
+ else if (this.mode === "multi") {
1394
+ const t = [...a.selectedDates], n = t.findIndex((r) => M(r, e));
1395
+ n >= 0 ? t.splice(n, 1) : t.push(e), t.sort(), this._store.set({ selectedDates: t, focusedDate: e }), this.emit("cal:change", { value: t });
1396
+ }
1397
+ }
1398
+ _handleHover(e) {
1399
+ this.mode === "range" && this._store.set({ hoverDate: e });
1400
+ }
1401
+ _handlePresetSelect({ start: e, end: a }) {
1402
+ this._store.set({
1403
+ rangeStart: e,
1404
+ rangeEnd: a,
1405
+ selectedDates: [e, a],
1406
+ hoverDate: null
1407
+ }), this._navigateToDate(e), this.emit("cal:change", { value: { start: e, end: a } }), this.display === "popover" && this.close();
1408
+ }
1409
+ // -- Navigation --
1410
+ _prevMonth() {
1411
+ const { viewYear: e, viewMonth: a } = this._store.getState(), { year: t, month: n } = z(e, a, -1);
1412
+ this._store.set({ viewYear: t, viewMonth: n, navDirection: "prev" }), this.emit("cal:month-change", { year: t, month: n });
1413
+ }
1414
+ _nextMonth() {
1415
+ const { viewYear: e, viewMonth: a } = this._store.getState(), { year: t, month: n } = z(e, a, 1);
1416
+ this._store.set({ viewYear: t, viewMonth: n, navDirection: "next" }), this.emit("cal:month-change", { year: t, month: n });
1417
+ }
1418
+ // -- Month picker --
1419
+ _toggleMonthPicker() {
1420
+ const e = this._store.getState();
1421
+ this._store.set({
1422
+ pickingMonth: !e.pickingMonth,
1423
+ pickerYear: e.viewYear
1424
+ });
1425
+ }
1426
+ _selectMonthFromPicker(e, a) {
1427
+ this._store.set({
1428
+ viewYear: a,
1429
+ viewMonth: e,
1430
+ pickingMonth: !1
1431
+ }), this.emit("cal:month-change", { year: a, month: e });
1432
+ }
1433
+ // -- Keyboard --
1434
+ _handleKeydown(e) {
1435
+ if (e.key === "Escape" && this._store.get("pickingMonth")) {
1436
+ e.stopPropagation(), this._store.set({ pickingMonth: !1 });
1437
+ return;
1438
+ }
1439
+ const a = this._store.getState(), t = L(a.focusedDate);
1440
+ if (!t) return;
1441
+ let n = null;
1442
+ switch (e.key) {
1443
+ case "ArrowLeft":
1444
+ n = new Date(t), n.setDate(t.getDate() - 1);
1445
+ break;
1446
+ case "ArrowRight":
1447
+ n = new Date(t), n.setDate(t.getDate() + 1);
1448
+ break;
1449
+ case "ArrowUp":
1450
+ n = new Date(t), n.setDate(t.getDate() - 7);
1451
+ break;
1452
+ case "ArrowDown":
1453
+ n = new Date(t), n.setDate(t.getDate() + 7);
1454
+ break;
1455
+ case "Enter":
1456
+ case " ":
1457
+ e.preventDefault(), this._handleSelect(a.focusedDate);
1458
+ return;
1459
+ case "Escape":
1460
+ this.display === "popover" && this.close();
1461
+ return;
1462
+ default:
1463
+ return;
1464
+ }
1465
+ if (n) {
1466
+ e.preventDefault();
1467
+ const r = m(n);
1468
+ n.getMonth() !== a.viewMonth || n.getFullYear() !== a.viewYear ? this._store.set({
1469
+ viewYear: n.getFullYear(),
1470
+ viewMonth: n.getMonth(),
1471
+ focusedDate: r,
1472
+ navDirection: n > t ? "next" : "prev"
1473
+ }) : this._store.set({ focusedDate: r }), requestAnimationFrame(() => {
1474
+ const o = this.$(`[data-date="${r}"]`);
1475
+ o == null || o.focus();
1476
+ });
1477
+ }
1478
+ }
1479
+ // -- Lightweight hover highlight (no DOM rebuild) --
1480
+ _updateGridHighlight(e) {
1481
+ const a = this.$$(".cal-day"), { rangeStart: t, hoverDate: n } = e, r = t && !e.rangeEnd && n ? n : e.rangeEnd;
1482
+ for (const o of a) {
1483
+ const l = o.dataset.date;
1484
+ if (!l || o.classList.contains("cal-day--disabled")) continue;
1485
+ const i = l === t, g = l === r;
1486
+ let h = !1;
1487
+ if (t && r) {
1488
+ const u = t < r ? t : r, d = t < r ? r : t;
1489
+ h = l >= u && l <= d && !i && !g;
1490
+ }
1491
+ o.classList.toggle("cal-day--range-start", i && !!r), o.classList.toggle("cal-day--range-end", g && !!r), o.classList.toggle("cal-day--in-range", h);
1492
+ }
1493
+ }
1494
+ // -- Public API --
1495
+ open() {
1496
+ this._popover && (this._popover.open(), this._store.set({ isOpen: !0 }), this.emit("cal:open"));
1497
+ }
1498
+ close() {
1499
+ this._popover && (this._popover.close(), this._store.set({ isOpen: !1 }), this.emit("cal:close"));
1500
+ }
1501
+ goToMonth(e, a) {
1502
+ this._store.set({ viewYear: a, viewMonth: e });
1503
+ }
1504
+ // -- Render --
1505
+ _renderCalendarContent() {
1506
+ const e = this._store.getState(), a = document.createElement("div");
1507
+ if (a.classList.add("cal-picker"), e.statusType && e.statusMessage && a.appendChild(Ae({
1508
+ type: e.statusType,
1509
+ message: e.statusMessage,
1510
+ dismissible: e.statusDismissible,
1511
+ onDismiss: () => this.clearStatus()
1512
+ })), this.loading) {
1513
+ const o = document.createElement("div");
1514
+ o.classList.add("cal-months");
1515
+ const l = document.createElement("div");
1516
+ return l.classList.add("cal-month"), l.appendChild(Me()), o.appendChild(l), a.appendChild(o), a.addEventListener("keydown", (i) => this._handleKeydown(i)), a;
1517
+ }
1518
+ const t = document.createElement("div");
1519
+ t.classList.add("cal-months");
1520
+ const n = this.mode === "range" && this.hasAttribute("dual"), r = n ? 2 : 1;
1521
+ for (let o = 0; o < r; o++) {
1522
+ const { year: l, month: i } = o === 0 ? { year: e.viewYear, month: e.viewMonth } : z(e.viewYear, e.viewMonth, 1), g = document.createElement("div");
1523
+ if (g.classList.add("cal-month"), o === 0 && g.appendChild(q({
1524
+ year: l,
1525
+ month: i,
1526
+ onPrev: e.pickingMonth ? () => {
1527
+ } : () => this._prevMonth(),
1528
+ onNext: e.pickingMonth ? () => {
1529
+ } : () => {
1530
+ n || this._nextMonth();
1531
+ },
1532
+ onTitleClick: () => this._toggleMonthPicker()
1533
+ })), o === 1 && g.appendChild(q({
1534
+ year: l,
1535
+ month: i,
1536
+ onPrev: () => {
1537
+ },
1538
+ onNext: () => this._nextMonth()
1539
+ })), e.pickingMonth && o === 0) {
1540
+ const h = _e({
1541
+ pickerYear: e.pickerYear,
1542
+ viewMonth: e.viewMonth,
1543
+ viewYear: e.viewYear,
1544
+ onMonthSelect: (u, d) => this._selectMonthFromPicker(u, d),
1545
+ onYearPrev: () => this._store.set({ pickerYear: e.pickerYear - 1 }),
1546
+ onYearNext: () => this._store.set({ pickerYear: e.pickerYear + 1 }),
1547
+ onClose: () => this._store.set({ pickingMonth: !1 })
1548
+ });
1549
+ g.appendChild(h);
1550
+ } else {
1551
+ const h = e.navDirection === "next" ? "cal-animate-slide-left" : e.navDirection === "prev" ? "cal-animate-slide-right" : "", u = fe({
1552
+ year: l,
1553
+ month: i,
1554
+ firstDay: this.firstDay,
1555
+ selectedDates: e.selectedDates,
1556
+ rangeStart: e.rangeStart,
1557
+ rangeEnd: e.rangeEnd,
1558
+ hoverDate: e.hoverDate,
1559
+ minDate: this.minDate,
1560
+ maxDate: this.maxDate,
1561
+ disabledDates: this.disabledDates,
1562
+ mode: this.mode,
1563
+ focusedDate: e.focusedDate,
1564
+ onSelect: (d) => this._handleSelect(d),
1565
+ onHover: (d) => this._handleHover(d)
1566
+ });
1567
+ h && u.classList.add(h), g.appendChild(u);
1568
+ }
1569
+ t.appendChild(g);
1570
+ }
1571
+ return a.appendChild(t), this.mode === "range" && this.presetKeys.length && a.appendChild(De({
1572
+ presetKeys: this.presetKeys,
1573
+ onSelect: (o) => this._handlePresetSelect(o)
1574
+ })), a.addEventListener("keydown", (o) => this._handleKeydown(o)), a;
1575
+ }
1576
+ _formatTriggerText() {
1577
+ const e = this._store.getState();
1578
+ return this.mode === "range" && e.rangeStart && e.rangeEnd ? `${this._formatShortDate(e.rangeStart)} – ${this._formatShortDate(e.rangeEnd)}` : e.selectedDates.length ? this.mode === "multi" ? `${e.selectedDates.length} dates selected` : this._formatShortDate(e.selectedDates[0]) : null;
1579
+ }
1580
+ _formatShortDate(e) {
1581
+ const a = L(e);
1582
+ return a ? `${I[a.getMonth()].slice(0, 3)} ${a.getDate()}, ${a.getFullYear()}` : e;
1583
+ }
1584
+ render() {
1585
+ var t;
1586
+ if (this._rendering) return;
1587
+ this._rendering = !0;
1588
+ const e = this.shadowRoot, a = [...e.childNodes];
1589
+ for (const n of a)
1590
+ n.nodeName !== "STYLE" && !(n instanceof CSSStyleSheet) && e.removeChild(n);
1591
+ if ((t = this._popover) == null || t.destroy(), this._popover = null, this.display === "popover") {
1592
+ const n = document.createElement("div");
1593
+ n.classList.add("cal-popover-wrapper");
1594
+ const r = document.createElement("button");
1595
+ r.classList.add("cal-trigger");
1596
+ const o = document.createElement("span");
1597
+ o.classList.add("cal-trigger__icon"), o.innerHTML = Ye, r.appendChild(o);
1598
+ const l = this._formatTriggerText(), i = document.createElement("span");
1599
+ l ? i.textContent = l : (i.textContent = this.placeholder, i.classList.add("cal-trigger--placeholder")), r.appendChild(i), n.appendChild(r);
1600
+ const g = this._renderCalendarContent(), h = Se({
1601
+ trigger: r,
1602
+ content: g,
1603
+ onClose: () => {
1604
+ this._store.set({ isOpen: !1 }), this.emit("cal:close");
1605
+ }
1606
+ });
1607
+ n.appendChild(h.panel), e.appendChild(n), r.addEventListener("click", (u) => {
1608
+ u.stopPropagation(), h.isOpen ? this.close() : this.open();
1609
+ }), this._popover = h, this._store.get("isOpen") && h.open();
1610
+ } else
1611
+ e.appendChild(this._renderCalendarContent());
1612
+ this._store.set({ navDirection: null }), this._rendering = !1;
1613
+ }
1614
+ }
1615
+ customElements.get("cal-datepicker") || customElements.define("cal-datepicker", ze);
1616
+ export {
1617
+ ze as CalDatepicker
1618
+ };
1619
+ //# sourceMappingURL=datepicker.es.js.map