cally 0.4.3 → 0.5.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/dist/cally.js CHANGED
@@ -1,4 +1,4 @@
1
- class oe {
1
+ class te {
2
2
  /**
3
3
  * @type {T}
4
4
  */
@@ -20,7 +20,7 @@ class oe {
20
20
  * @param {T} value
21
21
  */
22
22
  set current(t) {
23
- this.#t != t && (this.#t = t, this.#e.forEach((s) => s(t)));
23
+ this.#t != t && (this.#t = t, this.#e.forEach((n) => n(t)));
24
24
  }
25
25
  /**
26
26
  * @type {import("hooks").Ref["on"]}
@@ -29,113 +29,113 @@ class oe {
29
29
  return this.#e.add(t), () => this.#e.delete(t);
30
30
  }
31
31
  }
32
- const Nt = (e) => new oe(e), Q = Symbol.for("atomico.hooks");
33
- globalThis[Q] = globalThis[Q] || {};
34
- let N = globalThis[Q];
35
- const re = Symbol.for("Atomico.suspense"), Pt = Symbol.for("Atomico.effect"), ie = Symbol.for("Atomico.layoutEffect"), Ot = Symbol.for("Atomico.insertionEffect"), O = (e, t, s) => {
36
- const { i: n, hooks: o } = N.c, r = o[n] = o[n] || {};
37
- return r.value = e(r.value), r.effect = t, r.tag = s, N.c.i++, o[n].value;
38
- }, ae = (e) => O((t = Nt(e)) => t), U = () => O((e = Nt(N.c.host)) => e), kt = () => N.c.update, ce = (e, t, s = 0) => {
39
- let n = {}, o = !1;
40
- const r = () => o, i = (l, c) => {
41
- for (const h in n) {
42
- const a = n[h];
43
- a.effect && a.tag === l && (a.value = a.effect(a.value, c));
32
+ const Ct = (e) => new te(e), X = Symbol.for("atomico.hooks");
33
+ globalThis[X] = globalThis[X] || {};
34
+ let N = globalThis[X];
35
+ const ee = Symbol.for("Atomico.suspense"), Pt = Symbol.for("Atomico.effect"), ne = Symbol.for("Atomico.layoutEffect"), Nt = Symbol.for("Atomico.insertionEffect"), k = (e, t, n) => {
36
+ const { i: s, hooks: o } = N.c, r = o[s] = o[s] || {};
37
+ return r.value = e(r.value), r.effect = t, r.tag = n, N.c.i++, o[s].value;
38
+ }, se = (e) => k((t = Ct(e)) => t), $ = () => k((e = Ct(N.c.host)) => e), kt = () => N.c.update, oe = (e, t, n = 0) => {
39
+ let s = {}, o = !1;
40
+ const r = () => o, c = (i, u) => {
41
+ for (const d in s) {
42
+ const l = s[d];
43
+ l.effect && l.tag === i && (l.value = l.effect(l.value, u));
44
44
  }
45
45
  };
46
- return { load: (l) => {
47
- N.c = { host: t, hooks: n, update: e, i: 0, id: s };
48
- let c;
46
+ return { load: (i) => {
47
+ N.c = { host: t, hooks: s, update: e, i: 0, id: n };
48
+ let u;
49
49
  try {
50
- o = !1, c = l();
51
- } catch (h) {
52
- if (h !== re)
53
- throw h;
50
+ o = !1, u = i();
51
+ } catch (d) {
52
+ if (d !== ee)
53
+ throw d;
54
54
  o = !0;
55
55
  } finally {
56
56
  N.c = null;
57
57
  }
58
- return c;
59
- }, cleanEffects: (l) => (i(Ot, l), () => (i(ie, l), () => {
60
- i(Pt, l);
58
+ return u;
59
+ }, cleanEffects: (i) => (c(Nt, i), () => (c(ne, i), () => {
60
+ c(Pt, i);
61
61
  })), isSuspense: r };
62
- }, k = Symbol.for;
63
- function Mt(e, t) {
64
- const s = e.length;
65
- if (s !== t.length)
62
+ }, O = Symbol.for;
63
+ function Ot(e, t) {
64
+ const n = e.length;
65
+ if (n !== t.length)
66
66
  return !1;
67
- for (let n = 0; n < s; n++) {
68
- let o = e[n], r = t[n];
67
+ for (let s = 0; s < n; s++) {
68
+ let o = e[s], r = t[s];
69
69
  if (o !== r)
70
70
  return !1;
71
71
  }
72
72
  return !0;
73
73
  }
74
- const S = (e) => typeof e == "function", R = (e) => typeof e == "object", { isArray: ue } = Array, V = (e, t) => (t ? e instanceof HTMLStyleElement : !0) && "hydrate" in (e?.dataset || {});
74
+ const T = (e) => typeof e == "function", R = (e) => typeof e == "object", { isArray: re } = Array, G = (e, t) => (t ? e instanceof HTMLStyleElement : !0) && "hydrate" in (e?.dataset || {});
75
75
  function At(e, t) {
76
- let s;
77
- const n = (o) => {
76
+ let n;
77
+ const s = (o) => {
78
78
  let { length: r } = o;
79
- for (let i = 0; i < r; i++) {
80
- const f = o[i];
79
+ for (let c = 0; c < r; c++) {
80
+ const f = o[c];
81
81
  if (f && Array.isArray(f))
82
- n(f);
82
+ s(f);
83
83
  else {
84
- const u = typeof f;
85
- if (f == null || u === "function" || u === "boolean")
84
+ const a = typeof f;
85
+ if (f == null || a === "function" || a === "boolean")
86
86
  continue;
87
- u === "string" || u === "number" ? (s == null && (s = ""), s += f) : (s != null && (t(s), s = null), t(f));
87
+ a === "string" || a === "number" ? (n == null && (n = ""), n += f) : (n != null && (t(n), n = null), t(f));
88
88
  }
89
89
  }
90
90
  };
91
- n(e), s != null && t(s);
91
+ s(e), n != null && t(n);
92
92
  }
93
- const Rt = (e, t, s) => (e.addEventListener(t, s), () => e.removeEventListener(t, s));
94
- class Ft {
93
+ const Rt = (e, t, n) => (e.addEventListener(t, n), () => e.removeEventListener(t, n));
94
+ class Mt {
95
95
  /**
96
96
  *
97
97
  * @param {HTMLElement} target
98
98
  * @param {string} message
99
99
  * @param {string} value
100
100
  */
101
- constructor(t, s, n) {
102
- this.message = s, this.target = t, this.value = n;
101
+ constructor(t, n, s) {
102
+ this.message = n, this.target = t, this.value = s;
103
103
  }
104
104
  }
105
- class It extends Ft {
105
+ class Ft extends Mt {
106
106
  }
107
- class le extends Ft {
107
+ class ce extends Mt {
108
108
  }
109
- const Y = "Custom", fe = null, de = { true: 1, "": 1, 1: 1 };
110
- function he(e, t, s, n, o) {
109
+ const _ = "Custom", ie = null, ae = { true: 1, "": 1, 1: 1 };
110
+ function le(e, t, n, s, o) {
111
111
  const {
112
112
  type: r,
113
- reflect: i,
113
+ reflect: c,
114
114
  event: f,
115
- value: u,
116
- attr: l = me(t)
117
- } = s?.name != Y && R(s) && s != fe ? s : { type: s }, c = r?.name === Y && r.map, h = u != null ? r == Function || !S(u) ? () => u : u : null;
115
+ value: a,
116
+ attr: i = ue(t)
117
+ } = n?.name != _ && R(n) && n != ie ? n : { type: n }, u = r?.name === _ && r.map, d = a != null ? r == Function || !T(a) ? () => a : a : null;
118
118
  Object.defineProperty(e, t, {
119
119
  configurable: !0,
120
120
  /**
121
121
  * @this {import("dom").AtomicoThisInternal}
122
122
  * @param {any} newValue
123
123
  */
124
- set(a) {
125
- const d = this[t];
126
- h && r != Boolean && a == null && (a = h());
127
- const { error: y, value: D } = (c ? be : ge)(
124
+ set(l) {
125
+ const m = this[t];
126
+ d && r != Boolean && l == null && (l = d());
127
+ const { error: p, value: y } = (u ? he : me)(
128
128
  r,
129
- a
129
+ l
130
130
  );
131
- if (y && D != null)
132
- throw new It(
131
+ if (p && y != null)
132
+ throw new Ft(
133
133
  this,
134
134
  `The value defined for prop '${t}' must be of type '${r.name}'`,
135
- D
135
+ y
136
136
  );
137
- d != D && (this._props[t] = D ?? void 0, this.update(), f && xt(this, f), this.updated.then(() => {
138
- i && (this._ignoreAttr = l, ye(this, r, l, this[t]), this._ignoreAttr = null);
137
+ m != y && (this._props[t] = y ?? void 0, this.update(), f && It(this, f), this.updated.then(() => {
138
+ c && (this._ignoreAttr = i, fe(this, r, i, this[t]), this._ignoreAttr = null);
139
139
  }));
140
140
  },
141
141
  /**
@@ -144,21 +144,21 @@ function he(e, t, s, n, o) {
144
144
  get() {
145
145
  return this._props[t];
146
146
  }
147
- }), h && (o[t] = h()), n[l] = { prop: t, type: r };
147
+ }), d && (o[t] = d()), s[i] = { prop: t, type: r };
148
148
  }
149
- const xt = (e, { type: t, base: s = CustomEvent, ...n }) => e.dispatchEvent(new s(t, n)), me = (e) => e.replace(/([A-Z])/g, "-$1").toLowerCase(), ye = (e, t, s, n) => n == null || t == Boolean && !n ? e.removeAttribute(s) : e.setAttribute(
150
- s,
151
- t?.name === Y && t?.serialize ? t?.serialize(n) : R(n) ? JSON.stringify(n) : t == Boolean ? "" : n
152
- ), pe = (e, t) => e == Boolean ? !!de[t] : e == Number ? Number(t) : e == String ? t : e == Array || e == Object ? JSON.parse(t) : e.name == Y ? t : (
149
+ const It = (e, { type: t, base: n = CustomEvent, ...s }) => e.dispatchEvent(new n(t, s)), ue = (e) => e.replace(/([A-Z])/g, "-$1").toLowerCase(), fe = (e, t, n, s) => s == null || t == Boolean && !s ? e.removeAttribute(n) : e.setAttribute(
150
+ n,
151
+ t?.name === _ && t?.serialize ? t?.serialize(s) : R(s) ? JSON.stringify(s) : t == Boolean ? "" : s
152
+ ), de = (e, t) => e == Boolean ? !!ae[t] : e == Number ? Number(t) : e == String ? t : e == Array || e == Object ? JSON.parse(t) : e.name == _ ? t : (
153
153
  // TODO: If when defining reflect the prop can also be of type string?
154
154
  new e(t)
155
- ), be = ({ map: e }, t) => {
155
+ ), he = ({ map: e }, t) => {
156
156
  try {
157
157
  return { value: e(t), error: !1 };
158
158
  } catch {
159
159
  return { value: t, error: !0 };
160
160
  }
161
- }, ge = (e, t) => e == null || t == null ? { value: t, error: !1 } : e != String && t === "" ? { value: void 0, error: !1 } : e == Object || e == Array || e == Symbol ? {
161
+ }, me = (e, t) => e == null || t == null ? { value: t, error: !1 } : e != String && t === "" ? { value: void 0, error: !1 } : e == Object || e == Array || e == Symbol ? {
162
162
  value: t,
163
163
  error: {}.toString.call(t) !== `[object ${e.name}]`
164
164
  } : t instanceof e ? {
@@ -168,17 +168,17 @@ const xt = (e, { type: t, base: s = CustomEvent, ...n }) => e.dispatchEvent(new
168
168
  value: t,
169
169
  error: e == Number ? typeof t != "number" ? !0 : Number.isNaN(t) : e == String ? typeof t != "string" : typeof t != "boolean"
170
170
  } : { value: t, error: !0 };
171
- let De = 0;
172
- const we = (e) => {
171
+ let ye = 0;
172
+ const pe = (e) => {
173
173
  const t = (e?.dataset || {})?.hydrate || "";
174
- return t || "c" + De++;
175
- }, $ = (e, t = HTMLElement) => {
176
- const s = {}, n = {}, o = "prototype" in t && t.prototype instanceof Element, r = o ? t : "base" in t ? t.base : HTMLElement, { props: i, styles: f } = o ? e : t;
177
- class u extends r {
174
+ return t || "c" + ye++;
175
+ }, j = (e, t = HTMLElement) => {
176
+ const n = {}, s = {}, o = "prototype" in t && t.prototype instanceof Element, r = o ? t : "base" in t ? t.base : HTMLElement, { props: c, styles: f } = o ? e : t;
177
+ class a extends r {
178
178
  constructor() {
179
179
  super(), this._setup(), this._render = () => e({ ...this._props });
180
- for (const c in n)
181
- this[c] = n[c];
180
+ for (const u in s)
181
+ this[u] = s[u];
182
182
  }
183
183
  /**
184
184
  * @returns {import("core").Sheets[]}
@@ -190,37 +190,37 @@ const we = (e) => {
190
190
  if (this._props)
191
191
  return;
192
192
  this._props = {};
193
- let c, h;
193
+ let u, d;
194
194
  this.mounted = new Promise(
195
- (m) => this.mount = () => {
196
- m(), c != this.parentNode && (h != c ? this.unmounted.then(this.update) : this.update()), c = this.parentNode;
195
+ (E) => this.mount = () => {
196
+ E(), u != this.parentNode && (d != u ? this.unmounted.then(this.update) : this.update()), u = this.parentNode;
197
197
  }
198
198
  ), this.unmounted = new Promise(
199
- (m) => this.unmount = () => {
200
- m(), (c != this.parentNode || !this.isConnected) && (a.cleanEffects(!0)()(), h = this.parentNode, c = null);
199
+ (E) => this.unmount = () => {
200
+ E(), (u != this.parentNode || !this.isConnected) && (l.cleanEffects(!0)()(), d = this.parentNode, u = null);
201
201
  }
202
202
  ), this.symbolId = this.symbolId || Symbol(), this.symbolIdParent = Symbol();
203
- const a = ce(
203
+ const l = oe(
204
204
  () => this.update(),
205
205
  this,
206
- we(this)
206
+ pe(this)
207
207
  );
208
- let d, y = !0;
209
- const D = V(this);
210
- this.update = () => (d || (d = !0, this.updated = (this.updated || this.mounted).then(() => {
208
+ let m, p = !0;
209
+ const y = G(this);
210
+ this.update = () => (m || (m = !0, this.updated = (this.updated || this.mounted).then(() => {
211
211
  try {
212
- const m = a.load(this._render), w = a.cleanEffects();
213
- return m && //@ts-ignore
214
- m.render(this, this.symbolId, D), d = !1, y && !a.isSuspense() && (y = !1, !D && Ee(this)), w();
212
+ const E = l.load(this._render), h = l.cleanEffects();
213
+ return E && //@ts-ignore
214
+ E.render(this, this.symbolId, y), m = !1, p && !l.isSuspense() && (p = !1, !y && be(this)), h();
215
215
  } finally {
216
- d = !1;
216
+ m = !1;
217
217
  }
218
218
  }).then(
219
219
  /**
220
220
  * @param {import("internal/hooks.js").CleanUseEffects} [cleanUseEffect]
221
221
  */
222
- (m) => {
223
- m && m();
222
+ (E) => {
223
+ E && E();
224
224
  }
225
225
  )), this.updated), this.update();
226
226
  }
@@ -236,74 +236,74 @@ const we = (e) => {
236
236
  * @param {(string|null)} oldValue
237
237
  * @param {(string|null)} value
238
238
  */
239
- attributeChangedCallback(c, h, a) {
240
- if (s[c]) {
241
- if (c === this._ignoreAttr || h === a)
239
+ attributeChangedCallback(u, d, l) {
240
+ if (n[u]) {
241
+ if (u === this._ignoreAttr || d === l)
242
242
  return;
243
- const { prop: d, type: y } = s[c];
243
+ const { prop: m, type: p } = n[u];
244
244
  try {
245
- this[d] = pe(y, a);
245
+ this[m] = de(p, l);
246
246
  } catch {
247
- throw new le(
247
+ throw new ce(
248
248
  this,
249
- `The value defined as attr '${c}' cannot be parsed by type '${y.name}'`,
250
- a
249
+ `The value defined as attr '${u}' cannot be parsed by type '${p.name}'`,
250
+ l
251
251
  );
252
252
  }
253
253
  } else
254
- super.attributeChangedCallback(c, h, a);
254
+ super.attributeChangedCallback(u, d, l);
255
255
  }
256
256
  static get props() {
257
- return { ...super.props, ...i };
257
+ return { ...super.props, ...c };
258
258
  }
259
259
  static get observedAttributes() {
260
- const c = super.observedAttributes || [];
261
- for (const h in i)
262
- he(this.prototype, h, i[h], s, n);
263
- return Object.keys(s).concat(c);
260
+ const u = super.observedAttributes || [];
261
+ for (const d in c)
262
+ le(this.prototype, d, c[d], n, s);
263
+ return Object.keys(n).concat(u);
264
264
  }
265
265
  }
266
- return u;
266
+ return a;
267
267
  };
268
- function Ee(e) {
269
- const { styles: t } = e.constructor, { shadowRoot: s } = e;
270
- if (s && t.length) {
271
- const n = [];
268
+ function be(e) {
269
+ const { styles: t } = e.constructor, { shadowRoot: n } = e;
270
+ if (n && t.length) {
271
+ const s = [];
272
272
  At(t, (o) => {
273
- o && (o instanceof Element ? s.appendChild(o.cloneNode(!0)) : n.push(o));
274
- }), n.length && (s.adoptedStyleSheets = n);
273
+ o && (o instanceof Element ? n.appendChild(o.cloneNode(!0)) : s.push(o));
274
+ }), s.length && (n.adoptedStyleSheets = s);
275
275
  }
276
276
  }
277
- const Ut = (e) => (t, s) => {
278
- O(
277
+ const Ut = (e) => (t, n) => {
278
+ k(
279
279
  /**
280
280
  * Clean the effect hook
281
281
  * @type {import("internal/hooks.js").CollectorEffect}
282
282
  */
283
- ([n, o] = []) => ((o || !o) && (o && Mt(o, s) ? n = n || !0 : (S(n) && n(), n = null)), [n, s]),
283
+ ([s, o] = []) => ((o || !o) && (o && Ot(o, n) ? s = s || !0 : (T(s) && s(), s = null)), [s, n]),
284
284
  /**
285
285
  * @returns {any}
286
286
  */
287
- ([n, o], r) => r ? (S(n) && n(), []) : [n || t(), o],
287
+ ([s, o], r) => r ? (T(s) && s(), []) : [s || t(), o],
288
288
  e
289
289
  );
290
- }, j = Ut(Pt), Se = Ut(Ot);
291
- class _t extends Array {
290
+ }, nt = Ut(Pt), ge = Ut(Nt);
291
+ class $t extends Array {
292
292
  /**
293
293
  *
294
294
  * @param {any} initialState
295
295
  * @param {(nextState: any, state:any[], mount: boolean )=>void} mapState
296
296
  */
297
- constructor(t, s) {
298
- let n = !0;
297
+ constructor(t, n) {
298
+ let s = !0;
299
299
  const o = (r) => {
300
300
  try {
301
- s(r, this, n);
301
+ n(r, this, s);
302
302
  } finally {
303
- n = !1;
303
+ s = !1;
304
304
  }
305
305
  };
306
- super(void 0, o, s), o(t);
306
+ super(void 0, o, n), o(t);
307
307
  }
308
308
  /**
309
309
  * The following code allows a mutable approach to useState
@@ -318,45 +318,45 @@ class _t extends Array {
318
318
  // this[2](nextState, this);
319
319
  // }
320
320
  }
321
- const it = (e) => {
321
+ const st = (e) => {
322
322
  const t = kt();
323
- return O(
324
- (s = new _t(e, (n, o, r) => {
325
- n = S(n) ? n(o[0]) : n, n !== o[0] && (o[0] = n, r || t());
326
- })) => s
323
+ return k(
324
+ (n = new $t(e, (s, o, r) => {
325
+ s = T(s) ? s(o[0]) : s, s !== o[0] && (o[0] = s, r || t());
326
+ })) => n
327
327
  );
328
328
  }, P = (e, t) => {
329
- const [s] = O(([n, o, r = 0] = []) => ((!o || o && !Mt(o, t)) && (n = e()), [n, t, r]));
330
- return s;
329
+ const [n] = k(([s, o, r = 0] = []) => ((!o || o && !Ot(o, t)) && (s = e()), [s, t, r]));
330
+ return n;
331
331
  }, Lt = (e) => {
332
- const { current: t } = U();
332
+ const { current: t } = $();
333
333
  if (!(e in t))
334
- throw new It(
334
+ throw new Ft(
335
335
  t,
336
336
  `For useProp("${e}"), the prop does not exist on the host.`,
337
337
  e
338
338
  );
339
- return O(
340
- (s = new _t(t[e], (n, o) => {
341
- n = S(n) ? n(t[e]) : n, t[e] = n;
342
- })) => (s[0] = t[e], s)
339
+ return k(
340
+ (n = new $t(t[e], (s, o) => {
341
+ s = T(s) ? s(t[e]) : s, t[e] = s;
342
+ })) => (n[0] = t[e], n)
343
343
  );
344
- }, v = (e, t = {}) => {
345
- const s = U();
346
- return s[e] || (s[e] = (n = t.detail) => xt(s.current, {
344
+ }, C = (e, t = {}) => {
345
+ const n = $();
346
+ return n[e] || (n[e] = (s = t.detail) => It(n.current, {
347
347
  type: e,
348
348
  ...t,
349
- detail: n
350
- })), s[e];
351
- }, tt = k("atomico/options");
352
- globalThis[tt] = globalThis[tt] || {
349
+ detail: s
350
+ })), n[e];
351
+ }, Q = O("atomico/options");
352
+ globalThis[Q] = globalThis[Q] || {
353
353
  sheet: !!document.adoptedStyleSheets
354
354
  };
355
- const Yt = globalThis[tt], ve = {
355
+ const _t = globalThis[Q], Ee = {
356
356
  checked: 1,
357
357
  value: 1,
358
358
  selected: 1
359
- }, Te = {
359
+ }, De = {
360
360
  list: 1,
361
361
  type: 1,
362
362
  size: 1,
@@ -366,24 +366,24 @@ const Yt = globalThis[tt], ve = {
366
366
  src: 1,
367
367
  href: 1,
368
368
  slot: 1
369
- }, Ce = {
369
+ }, Se = {
370
370
  shadowDom: 1,
371
371
  staticNode: 1,
372
372
  cloneNode: 1,
373
373
  children: 1,
374
374
  key: 1
375
- }, L = {}, et = [];
376
- class nt extends Text {
375
+ }, L = {}, V = [];
376
+ class tt extends Text {
377
377
  }
378
- const Ne = k("atomico/id"), F = k("atomico/type"), J = k("atomico/ref"), $t = k("atomico/vnode"), Pe = () => {
378
+ const we = O("atomico/id"), M = O("atomico/type"), H = O("atomico/ref"), jt = O("atomico/vnode"), ve = () => {
379
379
  };
380
- function Oe(e, t, s) {
381
- return qt(this, e, t, s);
380
+ function Te(e, t, n) {
381
+ return xt(this, e, t, n);
382
382
  }
383
- const jt = (e, t, ...s) => {
384
- const n = t || L;
385
- let { children: o } = n;
386
- if (o = o ?? (s.length ? s : et), e === Pe)
383
+ const Yt = (e, t, ...n) => {
384
+ const s = t || L;
385
+ let { children: o } = s;
386
+ if (o = o ?? (n.length ? n : V), e === ve)
387
387
  return o;
388
388
  const r = e ? e instanceof Node ? 1 : (
389
389
  //@ts-ignore
@@ -391,170 +391,170 @@ const jt = (e, t, ...s) => {
391
391
  ) : 0;
392
392
  if (r === !1 && e instanceof Function)
393
393
  return e(
394
- o != et ? { children: o, ...n } : n
394
+ o != V ? { children: o, ...s } : s
395
395
  );
396
- const i = Yt.render || Oe;
396
+ const c = _t.render || Te;
397
397
  return {
398
- [F]: $t,
398
+ [M]: jt,
399
399
  type: e,
400
- props: n,
400
+ props: s,
401
401
  children: o,
402
- key: n.key,
402
+ key: s.key,
403
403
  // key for lists by keys
404
404
  // define if the node declares its shadowDom
405
- shadow: n.shadowDom,
405
+ shadow: s.shadowDom,
406
406
  // allows renderings to run only once
407
- static: n.staticNode,
407
+ static: s.staticNode,
408
408
  // defines whether the type is a childNode `1` or a constructor `2`
409
409
  raw: r,
410
410
  // defines whether to use the second parameter for document.createElement
411
- is: n.is,
411
+ is: s.is,
412
412
  // clone the node if it comes from a reference
413
- clone: n.cloneNode,
414
- render: i
413
+ clone: s.cloneNode,
414
+ render: c
415
415
  };
416
416
  };
417
- function qt(e, t, s = Ne, n, o) {
417
+ function xt(e, t, n = we, s, o) {
418
418
  let r;
419
- if (t && t[s] && t[s].vnode == e || e[F] != $t)
419
+ if (t && t[n] && t[n].vnode == e || e[M] != jt)
420
420
  return t;
421
- (e || !t) && (o = o || e.type == "svg", r = e.type != "host" && (e.raw == 1 ? (t && e.clone ? t[J] : t) != e.type : e.raw == 2 ? !(t instanceof e.type) : t ? t[J] || t.localName != e.type : !t), r && e.type != null && (e.raw == 1 && e.clone ? (n = !0, t = e.type.cloneNode(!0), t[J] = e.type) : t = e.raw == 1 ? e.type : e.raw == 2 ? new e.type() : o ? document.createElementNS(
421
+ (e || !t) && (o = o || e.type == "svg", r = e.type != "host" && (e.raw == 1 ? (t && e.clone ? t[H] : t) != e.type : e.raw == 2 ? !(t instanceof e.type) : t ? t[H] || t.localName != e.type : !t), r && e.type != null && (e.raw == 1 && e.clone ? (s = !0, t = e.type.cloneNode(!0), t[H] = e.type) : t = e.raw == 1 ? e.type : e.raw == 2 ? new e.type() : o ? document.createElementNS(
422
422
  "http://www.w3.org/2000/svg",
423
423
  e.type
424
424
  ) : document.createElement(
425
425
  e.type,
426
426
  e.is ? { is: e.is } : void 0
427
427
  )));
428
- const i = t[s] ? t[s] : L, { vnode: f = L, cycle: u = 0 } = i;
429
- let { fragment: l, handlers: c } = i;
430
- const { children: h = et, props: a = L } = f;
431
- if (c = r ? {} : c || {}, e.static && !r)
428
+ const c = t[n] ? t[n] : L, { vnode: f = L, cycle: a = 0 } = c;
429
+ let { fragment: i, handlers: u } = c;
430
+ const { children: d = V, props: l = L } = f;
431
+ if (u = r ? {} : u || {}, e.static && !r)
432
432
  return t;
433
433
  if (e.shadow && !t.shadowRoot && // @ts-ignore
434
- t.attachShadow({ mode: "open", ...e.shadow }), e.props != a && Ae(t, a, e.props, c, o), e.children !== h) {
435
- const d = e.shadow ? t.shadowRoot : t;
436
- l = Me(
434
+ t.attachShadow({ mode: "open", ...e.shadow }), e.props != l && Ne(t, l, e.props, u, o), e.children !== d) {
435
+ const m = e.shadow ? t.shadowRoot : t;
436
+ i = Pe(
437
437
  e.children,
438
438
  /**
439
439
  * @todo for hydration use attribute and send childNodes
440
440
  */
441
- l,
442
- d,
443
- s,
441
+ i,
442
+ m,
443
+ n,
444
444
  // add support to foreignObject, children will escape from svg
445
- !u && n,
445
+ !a && s,
446
446
  o && e.type == "foreignObject" ? !1 : o
447
447
  );
448
448
  }
449
- return t[s] = { vnode: e, handlers: c, fragment: l, cycle: u + 1 }, t;
449
+ return t[n] = { vnode: e, handlers: u, fragment: i, cycle: a + 1 }, t;
450
450
  }
451
- function ke(e, t) {
452
- const s = new nt(""), n = new nt("");
451
+ function Ce(e, t) {
452
+ const n = new tt(""), s = new tt("");
453
453
  let o;
454
- if (e[t ? "prepend" : "append"](s), t) {
454
+ if (e[t ? "prepend" : "append"](n), t) {
455
455
  let { lastElementChild: r } = e;
456
456
  for (; r; ) {
457
- const { previousElementSibling: i } = r;
458
- if (V(r, !0) && !V(i, !0)) {
457
+ const { previousElementSibling: c } = r;
458
+ if (G(r, !0) && !G(c, !0)) {
459
459
  o = r;
460
460
  break;
461
461
  }
462
- r = i;
462
+ r = c;
463
463
  }
464
464
  }
465
- return o ? o.before(n) : e.append(n), {
466
- markStart: s,
467
- markEnd: n
465
+ return o ? o.before(s) : e.append(s), {
466
+ markStart: n,
467
+ markEnd: s
468
468
  };
469
469
  }
470
- function Me(e, t, s, n, o, r) {
471
- e = e == null ? null : ue(e) ? e : [e];
472
- const i = t || ke(s, o), { markStart: f, markEnd: u, keyes: l } = i;
473
- let c;
474
- const h = l && /* @__PURE__ */ new Set();
475
- let a = f;
476
- if (e && At(e, (d) => {
477
- if (typeof d == "object" && !d[F])
470
+ function Pe(e, t, n, s, o, r) {
471
+ e = e == null ? null : re(e) ? e : [e];
472
+ const c = t || Ce(n, o), { markStart: f, markEnd: a, keyes: i } = c;
473
+ let u;
474
+ const d = i && /* @__PURE__ */ new Set();
475
+ let l = f;
476
+ if (e && At(e, (m) => {
477
+ if (typeof m == "object" && !m[M])
478
478
  return;
479
- const y = d[F] && d.key, D = l && y != null && l.get(y);
480
- a != u && a === D ? h.delete(a) : a = a == u ? u : a.nextSibling;
481
- const m = l ? D : a;
482
- let w = m;
483
- if (d[F])
484
- w = qt(d, m, n, o, r);
479
+ const p = m[M] && m.key, y = i && p != null && i.get(p);
480
+ l != a && l === y ? d.delete(l) : l = l == a ? a : l.nextSibling;
481
+ const E = i ? y : l;
482
+ let h = E;
483
+ if (m[M])
484
+ h = xt(m, E, s, o, r);
485
485
  else {
486
- const M = d + "";
487
- !(w instanceof Text) || w instanceof nt ? w = new Text(M) : w.data != M && (w.data = M);
486
+ const v = m + "";
487
+ !(h instanceof Text) || h instanceof tt ? h = new Text(v) : h.data != v && (h.data = v);
488
488
  }
489
- w != a && (l && h.delete(w), !m || l ? (s.insertBefore(w, a), l && a != u && h.add(a)) : m == u ? s.insertBefore(w, u) : (s.replaceChild(w, m), a = w)), y != null && (c = c || /* @__PURE__ */ new Map(), c.set(y, w));
490
- }), a = a == u ? u : a.nextSibling, t && a != u)
491
- for (; a != u; ) {
492
- const d = a;
493
- a = a.nextSibling, d.remove();
489
+ h != l && (i && d.delete(h), !E || i ? (n.insertBefore(h, l), i && l != a && d.add(l)) : E == a ? n.insertBefore(h, a) : (n.replaceChild(h, E), l = h)), p != null && (u = u || /* @__PURE__ */ new Map(), u.set(p, h));
490
+ }), l = l == a ? a : l.nextSibling, t && l != a)
491
+ for (; l != a; ) {
492
+ const m = l;
493
+ l = l.nextSibling, m.remove();
494
494
  }
495
- return h && h.forEach((d) => d.remove()), i.keyes = c, i;
495
+ return d && d.forEach((m) => m.remove()), c.keyes = u, c;
496
496
  }
497
- function Ae(e, t, s, n, o) {
497
+ function Ne(e, t, n, s, o) {
498
498
  for (const r in t)
499
- !(r in s) && pt(e, r, t[r], null, o, n);
500
- for (const r in s)
501
- pt(e, r, t[r], s[r], o, n);
499
+ !(r in n) && yt(e, r, t[r], null, o, s);
500
+ for (const r in n)
501
+ yt(e, r, t[r], n[r], o, s);
502
502
  }
503
- function pt(e, t, s, n, o, r) {
504
- if (t = t == "class" && !o ? "className" : t, s = s ?? null, n = n ?? null, t in e && ve[t] && (s = e[t]), !(n === s || Ce[t] || t[0] == "_"))
505
- if (t[0] == "o" && t[1] == "n" && (S(n) || S(s)))
506
- Re(e, t.slice(2), n, r);
503
+ function yt(e, t, n, s, o, r) {
504
+ if (t = t == "class" && !o ? "className" : t, n = n ?? null, s = s ?? null, t in e && Ee[t] && (n = e[t]), !(s === n || Se[t] || t[0] == "_"))
505
+ if (t[0] == "o" && t[1] == "n" && (T(s) || T(n)))
506
+ ke(e, t.slice(2), s, r);
507
507
  else if (t == "ref")
508
- n && (S(n) ? n(e) : n.current = e);
508
+ s && (T(s) ? s(e) : s.current = e);
509
509
  else if (t == "style") {
510
- const { style: i } = e;
511
- s = s || "", n = n || "";
512
- const f = R(s), u = R(n);
510
+ const { style: c } = e;
511
+ n = n || "", s = s || "";
512
+ const f = R(n), a = R(s);
513
513
  if (f)
514
- for (const l in s)
515
- if (u)
516
- !(l in n) && bt(i, l, null);
514
+ for (const i in n)
515
+ if (a)
516
+ !(i in s) && pt(c, i, null);
517
517
  else
518
518
  break;
519
- if (u)
520
- for (const l in n) {
521
- const c = n[l];
522
- f && s[l] === c || bt(i, l, c);
519
+ if (a)
520
+ for (const i in s) {
521
+ const u = s[i];
522
+ f && n[i] === u || pt(c, i, u);
523
523
  }
524
524
  else
525
- i.cssText = n;
525
+ c.cssText = s;
526
526
  } else {
527
- const i = t[0] == "$" ? t.slice(1) : t;
528
- i === t && (!o && !Te[t] && t in e || S(n) || S(s)) ? e[t] = n ?? "" : n == null ? e.removeAttribute(i) : e.setAttribute(
529
- i,
530
- R(n) ? JSON.stringify(n) : n
527
+ const c = t[0] == "$" ? t.slice(1) : t;
528
+ c === t && (!o && !De[t] && t in e || T(s) || T(n)) ? e[t] = s ?? "" : s == null ? e.removeAttribute(c) : e.setAttribute(
529
+ c,
530
+ R(s) ? JSON.stringify(s) : s
531
531
  );
532
532
  }
533
533
  }
534
- function Re(e, t, s, n) {
535
- if (n.handleEvent || (n.handleEvent = (o) => n[o.type].call(e, o)), s) {
536
- if (!n[t]) {
537
- const o = s.capture || s.once || s.passive ? Object.assign({}, s) : null;
538
- e.addEventListener(t, n, o);
534
+ function ke(e, t, n, s) {
535
+ if (s.handleEvent || (s.handleEvent = (o) => s[o.type].call(e, o)), n) {
536
+ if (!s[t]) {
537
+ const o = n.capture || n.once || n.passive ? Object.assign({}, n) : null;
538
+ e.addEventListener(t, s, o);
539
539
  }
540
- n[t] = s;
540
+ s[t] = n;
541
541
  } else
542
- n[t] && (e.removeEventListener(t, n), delete n[t]);
542
+ s[t] && (e.removeEventListener(t, s), delete s[t]);
543
543
  }
544
- function bt(e, t, s) {
545
- let n = "setProperty";
546
- s == null && (n = "removeProperty", s = null), ~t.indexOf("-") ? e[n](t, s) : e[t] = s;
544
+ function pt(e, t, n) {
545
+ let s = "setProperty";
546
+ n == null && (s = "removeProperty", n = null), ~t.indexOf("-") ? e[s](t, n) : e[t] = n;
547
547
  }
548
- const gt = {};
549
- function q(e, ...t) {
550
- const s = (e.raw || e).reduce(
551
- (n, o, r) => n + o + (t[r] || ""),
548
+ const bt = {};
549
+ function Y(e, ...t) {
550
+ const n = (e.raw || e).reduce(
551
+ (s, o, r) => s + o + (t[r] || ""),
552
552
  ""
553
553
  );
554
- return gt[s] = gt[s] || Fe(s);
554
+ return bt[n] = bt[n] || Oe(n);
555
555
  }
556
- function Fe(e) {
557
- if (Yt.sheet) {
556
+ function Oe(e) {
557
+ if (_t.sheet) {
558
558
  const t = new CSSStyleSheet();
559
559
  return t.replaceSync(e), t;
560
560
  } else {
@@ -562,52 +562,52 @@ function Fe(e) {
562
562
  return t.textContent = e, t;
563
563
  }
564
564
  }
565
- const Ie = jt("host", { style: "display: contents" }), Z = k("atomico/context"), xe = (e, t) => {
566
- const s = U();
567
- Se(
565
+ const Ae = Yt("host", { style: "display: contents" }), K = O("atomico/context"), Re = (e, t) => {
566
+ const n = $();
567
+ ge(
568
568
  () => Rt(
569
- s.current,
569
+ n.current,
570
570
  "ConnectContext",
571
571
  /**
572
572
  * @param {CustomEvent<import("context").DetailConnectContext>} event
573
573
  */
574
- (n) => {
575
- e === n.detail.id && (n.stopPropagation(), n.detail.connect(t));
574
+ (s) => {
575
+ e === s.detail.id && (s.stopPropagation(), s.detail.connect(t));
576
576
  }
577
577
  ),
578
578
  [e]
579
579
  );
580
- }, Ue = (e) => {
581
- const t = v("ConnectContext", {
580
+ }, Me = (e) => {
581
+ const t = C("ConnectContext", {
582
582
  bubbles: !0,
583
583
  composed: !0
584
- }), s = () => {
584
+ }), n = () => {
585
585
  let r;
586
586
  return t({
587
587
  id: e,
588
- connect(i) {
589
- r = i;
588
+ connect(c) {
589
+ r = c;
590
590
  }
591
591
  }), r;
592
- }, [n, o] = it(
593
- s
592
+ }, [s, o] = st(
593
+ n
594
594
  );
595
- return j(() => {
596
- n || (e[Z] || (e[Z] = customElements.whenDefined(
595
+ return nt(() => {
596
+ s || (e[K] || (e[K] = customElements.whenDefined(
597
597
  new e().localName
598
- )), e[Z].then(
599
- () => o(s)
598
+ )), e[K].then(
599
+ () => o(n)
600
600
  ));
601
- }, [e]), n;
602
- }, _e = (e) => {
603
- const t = Ue(e), s = kt();
604
- return j(() => {
601
+ }, [e]), s;
602
+ }, Fe = (e) => {
603
+ const t = Me(e), n = kt();
604
+ return nt(() => {
605
605
  if (t)
606
- return Rt(t, "UpdatedValue", s);
606
+ return Rt(t, "UpdatedValue", n);
607
607
  }, [t]), (t || e).value;
608
- }, Le = (e) => {
609
- const t = $(
610
- () => (xe(t, U().current), Ie),
608
+ }, Ie = (e) => {
609
+ const t = j(
610
+ () => (Re(t, $().current), Ae),
611
611
  {
612
612
  props: {
613
613
  value: {
@@ -619,343 +619,254 @@ const Ie = jt("host", { style: "display: contents" }), Z = k("atomico/context"),
619
619
  }
620
620
  );
621
621
  return t.value = e, t;
622
- }, p = (e, t, s) => (t == null ? t = { key: s } : t.key = s, jt(e, t)), I = p, zt = q`*,*:before,*:after{box-sizing:border-box}button{padding:0;touch-action:manipulation}`, Bt = q`.vh{position:absolute;transform:scale(0)}`;
623
- function at() {
624
- return g.from(/* @__PURE__ */ new Date());
625
- }
626
- function ct(e, t = 0) {
627
- const s = e.toDate(), n = s.getUTCDay(), o = (n < t ? 7 : 0) + n - t;
628
- return s.setUTCDate(s.getUTCDate() - o), g.from(s);
629
- }
630
- function Ht(e, t = 0) {
631
- return ct(e, t).add({ days: 6 });
632
- }
633
- function ut(e) {
634
- return g.from(new Date(Date.UTC(e.year, e.month, 0)));
635
- }
636
- function Wt(e, t) {
637
- const s = e.toDate(), n = t.toDate();
638
- return s < n ? -1 : s > n ? 1 : 0;
639
- }
640
- function z(e, t, s) {
641
- return t && g.compare(e, t) < 0 ? t : s && g.compare(e, s) > 0 ? s : e;
642
- }
643
- function st(e, t, s) {
644
- return z(e, t, s) === e;
622
+ }, b = (e, t, n) => (t == null ? t = { key: n } : t.key = n, Yt(e, t)), F = b, Bt = Y`*,*:before,*:after{box-sizing:border-box}button{padding:0;touch-action:manipulation;cursor:pointer;user-select:none}`, zt = Y`.vh{position:absolute;transform:scale(0)}`;
623
+ function ot() {
624
+ return D.from(/* @__PURE__ */ new Date());
645
625
  }
646
- function Ye(e, t) {
647
- const s = { days: 1 }, n = [e];
648
- for (; !e.equals(t); )
649
- e = e.add(s), n.push(e);
650
- return n;
651
- }
652
- function $e(e, t) {
653
- const s = [];
654
- for (let n = 0; n < e.length; n += t)
655
- s.push(e.slice(n, n + t));
656
- return s;
626
+ function rt(e, t = 0) {
627
+ const n = w(e), s = n.getUTCDay(), o = (s < t ? 7 : 0) + s - t;
628
+ return n.setUTCDate(n.getUTCDate() - o), D.from(n);
657
629
  }
658
- function je(e, t = 0) {
659
- const s = ct(e.toPlainDate(), t), n = Ht(ut(e), t);
660
- return $e(Ye(s, n), 7);
630
+ function qt(e, t = 0) {
631
+ return rt(e, t).add({ days: 6 });
661
632
  }
662
- const qe = /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[0-1])$/, Kt = "years", Jt = "months", Zt = "days";
663
- function ze(e) {
664
- if (Kt in e)
665
- return { years: -e.years };
666
- if (Jt in e)
667
- return { months: -e.months };
668
- if (Zt in e)
669
- return { days: -e.days };
670
- throw new TypeError();
633
+ function Ht(e) {
634
+ return D.from(new Date(Date.UTC(e.year, e.month, 0)));
671
635
  }
672
- function Be(e, t) {
673
- return g.from(new Date(Date.UTC(e.year, e.month - 1, t)));
636
+ function x(e, t, n) {
637
+ return t && D.compare(e, t) < 0 ? t : n && D.compare(e, n) > 0 ? n : e;
674
638
  }
675
- function He(e, t) {
676
- const s = new g(t, e.month, 1), n = ut(s), o = e.toDate();
677
- return o.setUTCFullYear(t), z(g.from(o), s, n);
678
- }
679
- function We(e, t) {
680
- const s = new g(e.year, t, 1), n = ut(s), o = e.toDate();
681
- return o.setUTCMonth(t - 1), z(g.from(o), s, n);
639
+ const Ue = { days: 1 };
640
+ function $e(e, t = 0) {
641
+ let n = rt(e.toPlainDate(), t);
642
+ const s = qt(Ht(e), t), o = [];
643
+ for (; D.compare(n, s) < 0; ) {
644
+ const r = [];
645
+ for (let c = 0; c < 7; c++)
646
+ r.push(n), n = n.add(Ue);
647
+ o.push(r);
648
+ }
649
+ return o;
682
650
  }
683
- function Dt(e, t) {
684
- return Zt in t ? Be(e, e.day + t.days) : Jt in t ? We(e, e.month + t.months) : Kt in t ? He(e, e.year + t.years) : e;
651
+ function w(e) {
652
+ return new Date(Date.UTC(e.year, e.month - 1, e.day ?? 1));
685
653
  }
686
- const X = (e, t) => e.toString().padStart(t, "0");
687
- class g {
688
- constructor(t, s, n) {
689
- this.year = t, this.month = s, this.day = n;
654
+ const Le = /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[0-1])$/, J = (e, t) => e.toString().padStart(t, "0");
655
+ class D {
656
+ constructor(t, n, s) {
657
+ this.year = t, this.month = n, this.day = s;
690
658
  }
659
+ // this is an incomplete implementation that only handles arithmetic on a single unit at a time.
660
+ // i didn't want to get into more complex arithmetic since it get tricky fast
661
+ // this is enough to serve my needs and will still be a drop-in replacement when actual Temporal API lands
691
662
  add(t) {
692
- return Dt(this, t);
693
- }
694
- subtract(t) {
695
- return Dt(this, ze(t));
663
+ const n = w(this);
664
+ if ("days" in t)
665
+ return n.setUTCDate(this.day + t.days), D.from(n);
666
+ let { year: s, month: o } = this;
667
+ "months" in t ? (o = this.month + t.months, n.setUTCMonth(o - 1)) : (s = this.year + t.years, n.setUTCFullYear(s));
668
+ const r = D.from(w({ year: s, month: o, day: 1 }));
669
+ return x(D.from(n), r, Ht(r));
696
670
  }
697
671
  toString() {
698
- return `${X(this.year, 4)}-${X(this.month, 2)}-${X(this.day, 2)}`;
699
- }
700
- toDate() {
701
- return new Date(Date.UTC(this.year, this.month - 1, this.day, 0, 0, 0));
672
+ return `${J(this.year, 4)}-${J(this.month, 2)}-${J(this.day, 2)}`;
702
673
  }
703
674
  toPlainYearMonth() {
704
- return new C(this.year, this.month);
675
+ return new B(this.year, this.month);
705
676
  }
706
677
  equals(t) {
707
- return this.year === t.year && this.month === t.month && this.day === t.day;
678
+ return D.compare(this, t) === 0;
708
679
  }
709
- static compare(t, s) {
710
- return Wt(t, s);
680
+ static compare(t, n) {
681
+ return t.year < n.year ? -1 : t.year > n.year ? 1 : t.month < n.month ? -1 : t.month > n.month ? 1 : t.day < n.day ? -1 : t.day > n.day ? 1 : 0;
711
682
  }
712
683
  static from(t) {
713
- return typeof t == "string" ? this.fromString(t) : this.fromDate(t);
714
- }
715
- static fromString(t) {
716
- const s = t.match(qe);
717
- if (!s)
718
- throw new TypeError(t);
719
- const [, n, o, r] = s;
720
- return new g(
721
- parseInt(n, 10),
722
- parseInt(o, 10),
723
- parseInt(r, 10)
724
- );
725
- }
726
- static fromDate(t) {
727
- return new g(
684
+ if (typeof t == "string") {
685
+ const n = t.match(Le);
686
+ if (!n)
687
+ throw new TypeError(t);
688
+ const [, s, o, r] = n;
689
+ return new D(
690
+ parseInt(s, 10),
691
+ parseInt(o, 10),
692
+ parseInt(r, 10)
693
+ );
694
+ }
695
+ return new D(
728
696
  t.getUTCFullYear(),
729
697
  t.getUTCMonth() + 1,
730
698
  t.getUTCDate()
731
699
  );
732
700
  }
733
701
  }
734
- function wt(e) {
735
- return (e.months ?? 0) + (e.years ?? 0) * 12;
736
- }
737
- function Et(e, t) {
738
- const s = e.toDate();
739
- return s.setUTCMonth(s.getUTCMonth() + t), new C(s.getUTCFullYear(), s.getUTCMonth() + 1);
740
- }
741
- class C {
742
- constructor(t, s) {
743
- this.year = t, this.month = s;
702
+ class B {
703
+ constructor(t, n) {
704
+ this.year = t, this.month = n;
744
705
  }
745
706
  add(t) {
746
- return Et(this, wt(t));
747
- }
748
- subtract(t) {
749
- return Et(this, -wt(t));
750
- }
751
- toDate() {
752
- return new Date(Date.UTC(this.year, this.month - 1, 1));
707
+ const n = w(this), s = (t.months ?? 0) + (t.years ?? 0) * 12;
708
+ return n.setUTCMonth(n.getUTCMonth() + s), new B(n.getUTCFullYear(), n.getUTCMonth() + 1);
753
709
  }
754
710
  equals(t) {
755
711
  return this.year === t.year && this.month === t.month;
756
712
  }
757
713
  toPlainDate() {
758
- return new g(this.year, this.month, 1);
759
- }
760
- static compare(t, s) {
761
- const n = t instanceof g ? t.toPlainYearMonth() : t, o = s instanceof g ? s.toPlainYearMonth() : s;
762
- return Wt(n, o);
714
+ return new D(this.year, this.month, 1);
763
715
  }
764
716
  }
765
- function ot(e, t) {
717
+ function et(e, t) {
766
718
  if (t)
767
719
  try {
768
720
  return e.from(t);
769
721
  } catch {
770
722
  }
771
723
  }
772
- function rt(e) {
773
- const [t, s] = Lt(e);
774
- return [P(() => ot(g, t), [t]), (r) => s(r.toString())];
724
+ function I(e) {
725
+ const [t, n] = Lt(e);
726
+ return [P(() => et(D, t), [t]), (r) => n(r.toString())];
775
727
  }
776
- function Ke(e) {
728
+ function _e(e) {
777
729
  if (e) {
778
- const [t, s] = e.split("/"), n = ot(g, t), o = ot(g, s);
779
- if (n && o)
780
- return [n, o];
730
+ const [t, n] = e.split("/"), s = et(D, t), o = et(D, n);
731
+ if (s && o)
732
+ return [s, o];
781
733
  }
782
734
  return [];
783
735
  }
784
- function Je(e, t) {
785
- return `${e}/${t}`;
736
+ function je(e) {
737
+ const [t, n] = Lt(e);
738
+ return [P(() => _e(t), [t]), (r) => n(`${r[0]}/${r[1]}`)];
786
739
  }
787
- function Ze(e) {
788
- const [t, s] = Lt(e);
789
- return [P(() => Ke(t), [t]), (r) => s(Je(r[0], r[1]))];
790
- }
791
- function x(e, t) {
740
+ function U(e, t) {
792
741
  return P(
793
742
  () => new Intl.DateTimeFormat(t, { timeZone: "UTC", ...e }),
794
743
  [t, e]
795
744
  );
796
745
  }
797
- function St(e, t, s) {
798
- const n = x(e, s);
746
+ function gt(e, t, n) {
747
+ const s = U(e, n);
799
748
  return P(() => {
800
749
  const o = [], r = /* @__PURE__ */ new Date();
801
- for (var i = 0; i < 7; i++) {
750
+ for (var c = 0; c < 7; c++) {
802
751
  const f = (r.getDay() - t + 7) % 7;
803
- o[f] = n.format(r), r.setDate(r.getDate() + 1);
752
+ o[f] = s.format(r), r.setDate(r.getDate() + 1);
804
753
  }
805
754
  return o;
806
- }, [t, n]);
807
- }
808
- function Xe(e) {
809
- let t = "";
810
- for (const s in e)
811
- e[s] && (t += ` ${s}`);
812
- return t;
755
+ }, [t, s]);
813
756
  }
814
- const vt = (e) => e.target.matches(":dir(ltr)"), Ge = { month: "long", day: "numeric" }, Qe = { month: "long" }, Ve = { weekday: "narrow" }, tn = { weekday: "long" }, G = { bubbles: !0 };
815
- function en({ props: e, context: t }) {
816
- const { offset: s } = e, { firstDayOfWeek: n, isDateDisallowed: o, min: r, max: i, dateWindow: f, locale: u } = t, l = at(), c = St(tn, n, u), h = St(Ve, n, u), a = x(Ge, u), d = x(Qe, u), { focusedDate: y } = f, D = P(
817
- () => f.start.add({ months: s }),
818
- [f, s]
819
- ), m = P(
820
- () => je(D, n),
821
- [D, n]
822
- ), w = v("focusday", G), M = v("selectday", G), te = v("hoverday", G);
823
- function ft(b) {
824
- w(z(b, r, i));
757
+ const Et = (e, t, n) => x(e, t, n) === e, Dt = (e) => e.target.matches(":dir(ltr)"), Ye = { month: "long", day: "numeric" }, xe = { month: "long" }, Be = { weekday: "narrow" }, ze = { weekday: "long" }, Z = { bubbles: !0 };
758
+ function qe({ props: e, context: t }) {
759
+ const { offset: n } = e, {
760
+ firstDayOfWeek: s,
761
+ isDateDisallowed: o,
762
+ min: r,
763
+ max: c,
764
+ page: f,
765
+ locale: a,
766
+ focusedDate: i
767
+ } = t, u = ot(), d = gt(ze, s, a), l = gt(Be, s, a), m = U(Ye, a), p = U(xe, a), y = P(
768
+ () => f.start.add({ months: n }),
769
+ [f, n]
770
+ ), E = P(
771
+ () => $e(y, s),
772
+ [y, s]
773
+ ), h = C("focusday", Z), v = C("selectday", Z), z = C("hoverday", Z);
774
+ function it(g) {
775
+ h(x(g, r, c));
825
776
  }
826
- function ee(b) {
827
- let E;
828
- switch (b.key) {
777
+ function Xt(g) {
778
+ let S;
779
+ switch (g.key) {
829
780
  case "ArrowRight":
830
- E = y.add({ days: vt(b) ? 1 : -1 });
781
+ S = i.add({ days: Dt(g) ? 1 : -1 });
831
782
  break;
832
783
  case "ArrowLeft":
833
- E = y.add({ days: vt(b) ? -1 : 1 });
784
+ S = i.add({ days: Dt(g) ? -1 : 1 });
834
785
  break;
835
786
  case "ArrowDown":
836
- E = y.add({ days: 7 });
787
+ S = i.add({ days: 7 });
837
788
  break;
838
789
  case "ArrowUp":
839
- E = y.add({ days: -7 });
790
+ S = i.add({ days: -7 });
840
791
  break;
841
792
  case "PageUp":
842
- E = y.add(b.shiftKey ? { years: -1 } : { months: -1 });
793
+ S = i.add(g.shiftKey ? { years: -1 } : { months: -1 });
843
794
  break;
844
795
  case "PageDown":
845
- E = y.add(b.shiftKey ? { years: 1 } : { months: 1 });
796
+ S = i.add(g.shiftKey ? { years: 1 } : { months: 1 });
846
797
  break;
847
798
  case "Home":
848
- E = ct(y, n);
799
+ S = rt(i, s);
849
800
  break;
850
801
  case "End":
851
- E = Ht(y, n);
802
+ S = qt(i, s);
852
803
  break;
853
804
  default:
854
805
  return;
855
806
  }
856
- ft(E), b.preventDefault();
807
+ it(S), g.preventDefault();
857
808
  }
858
- function ne(b) {
859
- const E = D.equals(b), se = b.equals(y), dt = b.equals(l), ht = b.toDate(), _ = o?.(ht), mt = !st(b, r, i);
860
- let A = !1, yt = !1, B = !1, H = !1;
809
+ function Gt(g) {
810
+ const S = y.equals(g);
811
+ if (!S && !t.showOutsideDays)
812
+ return;
813
+ const Qt = g.equals(i), Vt = g.equals(u), at = w(g), q = o?.(at), lt = !Et(g, r, c);
814
+ let ut = "", A;
861
815
  if ("highlightedRange" in t) {
862
- const [W, K] = t.highlightedRange;
863
- yt = !0, B = W?.equals(b) ?? !1, H = K?.equals(b) ?? !1, A = W && K ? st(b, W, K) : !1;
816
+ const [ft, dt] = t.highlightedRange, ht = ft?.equals(g), mt = dt?.equals(g);
817
+ A = Et(g, ft, dt), ut = `${ht ? "range-start" : ""} ${mt ? "range-end" : ""} ${A && !ht && !mt ? "range-inner" : ""}`;
864
818
  } else
865
- "value" in t && (A = t.value?.equals(b) ?? !1);
819
+ A = t.value?.equals(g);
866
820
  return {
867
- part: Xe({
868
- button: !0,
869
- day: !0,
870
- selected: E && A,
871
- today: dt,
872
- disallowed: _,
873
- outside: !E,
874
- "range-start": B,
875
- "range-end": H,
876
- "range-inner": yt && A && !B && !H
877
- }),
878
- tabindex: E && se ? 0 : -1,
879
- disabled: mt,
880
- "aria-disabled": _ ? "true" : void 0,
881
- "aria-pressed": E && A,
882
- "aria-current": dt ? "date" : void 0,
883
- "aria-label": a.format(ht),
884
- onkeydown: ee,
821
+ part: `button day ${S && A ? "selected" : ""} ${ut}`,
822
+ tabindex: S && Qt ? 0 : -1,
823
+ disabled: lt,
824
+ "aria-disabled": q ? "true" : void 0,
825
+ "aria-pressed": S && A,
826
+ "aria-current": Vt ? "date" : void 0,
827
+ "aria-label": m.format(at),
828
+ onkeydown: Xt,
885
829
  onclick() {
886
- _ || M(b), ft(b);
830
+ q || v(g), it(g);
887
831
  },
888
832
  onmouseover() {
889
- !_ && !mt && te(b);
833
+ !q && !lt && z(g);
890
834
  }
891
835
  };
892
836
  }
893
837
  return {
894
- weeks: m,
895
- yearMonth: D,
896
- dayNamesLong: c,
897
- dayNamesShort: h,
898
- monthFormatter: d,
899
- getDayProps: ne
838
+ weeks: E,
839
+ yearMonth: y,
840
+ daysLong: d,
841
+ daysShort: l,
842
+ formatter: p,
843
+ getDayProps: Gt
900
844
  };
901
845
  }
902
- class T {
903
- constructor(t, s, n) {
904
- this.start = t, this.duration = s, this.focusedDate = n, this.end = t.add({ months: s.months - 1 });
905
- }
906
- end;
907
- contains(t) {
908
- return C.compare(t, this.start) >= 0 && C.compare(t, this.end) <= 0;
909
- }
910
- adjust(t) {
911
- const { start: s, duration: n } = this, o = C.compare(s, t) > 0;
912
- let r = new T(s, n, t);
913
- for (; !r.contains(t); )
914
- r = new T(
915
- o ? r.start.subtract(n) : r.start.add(n),
916
- n,
917
- t
918
- );
919
- return r;
920
- }
921
- next() {
922
- return new T(
923
- this.start.add(this.duration),
924
- this.duration,
925
- this.focusedDate.add(this.duration)
926
- );
927
- }
928
- prev() {
929
- return new T(
930
- this.start.subtract(this.duration),
931
- this.duration,
932
- this.focusedDate.subtract(this.duration)
933
- );
934
- }
935
- }
936
- const Tt = at(), lt = Le({
937
- firstDayOfWeek: 0,
846
+ const W = ot(), ct = Ie({
847
+ firstDayOfWeek: 1,
938
848
  isDateDisallowed: () => !1,
939
- dateWindow: new T(Tt.toPlainYearMonth(), { months: 1 }, Tt)
849
+ focusedDate: W,
850
+ page: { start: W.toPlainYearMonth(), end: W.toPlainYearMonth() }
940
851
  });
941
- customElements.define("calendar-month-ctx", lt);
942
- const nn = $(
852
+ customElements.define("calendar-month-ctx", ct);
853
+ const He = j(
943
854
  (e) => {
944
- const t = _e(lt), s = ae(), n = en({ props: e, context: t });
855
+ const t = Fe(ct), n = se(), s = qe({ props: e, context: t });
945
856
  function o() {
946
- s.current.querySelector("button[tabindex='0']")?.focus();
857
+ n.current.querySelector("button[tabindex='0']")?.focus();
947
858
  }
948
- return /* @__PURE__ */ I("host", { shadowDom: !0, focus: o, children: [
949
- /* @__PURE__ */ p("div", { id: "heading", part: "heading", children: n.monthFormatter.format(n.yearMonth.toDate()) }),
950
- /* @__PURE__ */ I("table", { ref: s, "aria-labelledby": "heading", part: "table", children: [
951
- /* @__PURE__ */ p("thead", { children: /* @__PURE__ */ p("tr", { part: "tr head", children: n.dayNamesLong.map((r, i) => /* @__PURE__ */ I("th", { part: "th", scope: "col", children: [
952
- /* @__PURE__ */ p("span", { class: "vh", children: r }),
953
- /* @__PURE__ */ p("span", { "aria-hidden": "true", children: n.dayNamesShort[i] })
859
+ return /* @__PURE__ */ F("host", { shadowDom: !0, focus: o, children: [
860
+ /* @__PURE__ */ b("div", { id: "h", part: "heading", children: s.formatter.format(w(s.yearMonth)) }),
861
+ /* @__PURE__ */ F("table", { ref: n, "aria-labelledby": "h", part: "table", children: [
862
+ /* @__PURE__ */ b("thead", { children: /* @__PURE__ */ b("tr", { part: "tr head", children: s.daysLong.map((r, c) => /* @__PURE__ */ F("th", { part: "th", scope: "col", children: [
863
+ /* @__PURE__ */ b("span", { class: "vh", children: r }),
864
+ /* @__PURE__ */ b("span", { "aria-hidden": "true", children: s.daysShort[c] })
954
865
  ] })) }) }),
955
- /* @__PURE__ */ p("tbody", { children: n.weeks.map((r, i) => /* @__PURE__ */ p("tr", { part: "tr week", children: r.map((f, u) => {
956
- const l = n.yearMonth.equals(f), c = t.showOutsideDays || l;
957
- return /* @__PURE__ */ p("td", { part: "td", children: c && /* @__PURE__ */ p("button", { ...n.getDayProps(f), children: f.day }) }, u);
958
- }) }, i)) })
866
+ /* @__PURE__ */ b("tbody", { children: s.weeks.map((r, c) => /* @__PURE__ */ b("tr", { part: "tr week", children: r.map((f, a) => {
867
+ const i = s.getDayProps(f);
868
+ return /* @__PURE__ */ b("td", { part: "td", children: i && /* @__PURE__ */ b("button", { ...i, children: f.day }) }, a);
869
+ }) }, c)) })
959
870
  ] })
960
871
  ] });
961
872
  },
@@ -967,51 +878,46 @@ const nn = $(
967
878
  }
968
879
  },
969
880
  styles: [
970
- zt,
971
881
  Bt,
972
- q`:host{--color-accent: black;--color-text-on-accent: white;display:flex;flex-direction:column;gap:.25rem;text-align:center;inline-size:fit-content}table{border-collapse:collapse;border-spacing:0;table-layout:fixed;inline-size:max-content;font-size:.875rem}th{font-weight:700;block-size:2.25rem}td{padding-inline:0;padding-block:1px}button{color:inherit;font-size:inherit;background:transparent;border:0;cursor:pointer;font-variant-numeric:tabular-nums;block-size:2.25rem;inline-size:2.25rem}button:hover:where(:not(:disabled)){background:#0000000d}button:is([aria-pressed=true],:focus-visible){background:var(--color-accent);color:var(--color-text-on-accent)}button:focus-visible{outline:1px solid var(--color-text-on-accent);outline-offset:-2px}button:disabled,:host::part(outside),:host::part(disallowed){cursor:default;opacity:.5}`
882
+ zt,
883
+ Y`:host{--color-accent: black;--color-text-on-accent: white;display:flex;flex-direction:column;gap:.25rem;text-align:center;inline-size:fit-content}table{border-collapse:collapse;font-size:.875rem}th{font-weight:700;block-size:2.25rem}td{padding-inline:0}button{color:inherit;font-size:inherit;background:transparent;border:0;font-variant-numeric:tabular-nums;block-size:2.25rem;inline-size:2.25rem}button:hover:where(:not(:disabled)){background:#0000000d}button:is([aria-pressed=true],:focus-visible){background:var(--color-accent);color:var(--color-text-on-accent)}button:focus-visible{outline:1px solid var(--color-text-on-accent);outline-offset:-2px}button:disabled,:host::part(outside),:host::part(disallowed){cursor:default;opacity:.5}`
973
884
  ]
974
885
  }
975
886
  );
976
- customElements.define("calendar-month", nn);
977
- function Xt(e) {
978
- const t = e.dateWindow.start.toDate(), s = e.dateWindow.end.toDate();
979
- return /* @__PURE__ */ I("div", { role: "group", "aria-labelledby": "label", part: "container", children: [
980
- /* @__PURE__ */ p("div", { id: "label", class: "vh", "aria-live": "polite", "aria-atomic": "true", children: e.formatVerbose.formatRange(t, s) }),
981
- /* @__PURE__ */ I("div", { class: "header", part: "header", children: [
982
- /* @__PURE__ */ p(
983
- "button",
984
- {
985
- part: `button previous ${e.previous ? "" : "disabled"}`,
986
- onclick: e.previous,
987
- "aria-disabled": e.previous ? null : "true",
988
- children: /* @__PURE__ */ p("slot", { name: "previous", children: "Previous" })
989
- }
990
- ),
991
- /* @__PURE__ */ p("div", { id: "heading", part: "heading", "aria-hidden": "true", children: e.format.formatRange(t, s) }),
992
- /* @__PURE__ */ p(
993
- "button",
994
- {
995
- part: `button next ${e.next ? "" : "disabled"}`,
996
- onclick: e.next,
997
- "aria-disabled": e.next ? null : "true",
998
- children: /* @__PURE__ */ p("slot", { name: "next", children: "Next" })
999
- }
1000
- )
887
+ customElements.define("calendar-month", He);
888
+ function St(e) {
889
+ return /* @__PURE__ */ b(
890
+ "button",
891
+ {
892
+ part: `button ${e.name} ${e.onclick ? "" : "disabled"}`,
893
+ onclick: e.onclick,
894
+ "aria-disabled": e.onclick ? null : "true",
895
+ children: /* @__PURE__ */ b("slot", { name: e.name, children: e.children })
896
+ }
897
+ );
898
+ }
899
+ function Kt(e) {
900
+ const t = w(e.page.start), n = w(e.page.end);
901
+ return /* @__PURE__ */ F("div", { role: "group", "aria-labelledby": "h", part: "container", children: [
902
+ /* @__PURE__ */ b("div", { id: "h", class: "vh", "aria-live": "polite", "aria-atomic": "true", children: e.formatVerbose.formatRange(t, n) }),
903
+ /* @__PURE__ */ F("div", { part: "header", children: [
904
+ /* @__PURE__ */ b(St, { name: "previous", onclick: e.previous, children: "Previous" }),
905
+ /* @__PURE__ */ b("div", { part: "heading", "aria-hidden": "true", children: e.format.formatRange(t, n) }),
906
+ /* @__PURE__ */ b(St, { name: "next", onclick: e.next, children: "Next" })
1001
907
  ] }),
1002
- /* @__PURE__ */ p(
1003
- lt,
908
+ /* @__PURE__ */ b(
909
+ ct,
1004
910
  {
1005
911
  value: e,
1006
912
  onselectday: e.onSelect,
1007
913
  onfocusday: e.onFocus,
1008
914
  onhoverday: e.onHover,
1009
- children: /* @__PURE__ */ p("slot", {})
915
+ children: /* @__PURE__ */ b("slot", {})
1010
916
  }
1011
917
  )
1012
918
  ] });
1013
919
  }
1014
- const Gt = {
920
+ const Jt = {
1015
921
  value: {
1016
922
  type: String,
1017
923
  value: ""
@@ -1034,7 +940,7 @@ const Gt = {
1034
940
  },
1035
941
  showOutsideDays: {
1036
942
  type: Boolean,
1037
- value: () => !1
943
+ value: !1
1038
944
  },
1039
945
  locale: {
1040
946
  type: String,
@@ -1044,101 +950,129 @@ const Gt = {
1044
950
  months: {
1045
951
  type: Number,
1046
952
  value: 1
953
+ },
954
+ focusedDate: {
955
+ type: String,
956
+ value: () => {
957
+ }
1047
958
  }
1048
- }, Qt = [
1049
- zt,
959
+ }, Zt = [
1050
960
  Bt,
1051
- q`:host{display:block;inline-size:fit-content}[role=group]{display:flex;flex-direction:column;gap:1em}.header{display:flex;align-items:center;justify-content:space-between}#heading{font-weight:700;font-size:1.25em}button{cursor:pointer;user-select:none;display:flex;align-items:center;justify-content:center}button[aria-disabled]{cursor:default;opacity:.4}`
1052
- ], sn = { year: "numeric" }, on = { year: "numeric", month: "long" };
1053
- function Vt({ months: e, locale: t }) {
1054
- const [s] = rt("min"), [n] = rt("max"), o = v("focusday"), r = v("change"), [i, f] = it(() => {
1055
- const m = at(), w = e === 12 ? new C(m.year, 1) : m.toPlainYearMonth();
1056
- return new T(w, { months: e }, m);
1057
- });
1058
- function u(m) {
1059
- f(m), o(m.focusedDate.toDate());
1060
- }
1061
- function l(m) {
1062
- f(i.adjust(m));
961
+ zt,
962
+ Y`:host{display:block;inline-size:fit-content}[role=group]{display:flex;flex-direction:column;gap:1em}:host::part(header){display:flex;align-items:center;justify-content:space-between}:host::part(heading){font-weight:700;font-size:1.25em}button{display:flex;align-items:center;justify-content:center}button[aria-disabled]{cursor:default;opacity:.5}`
963
+ ], Ke = { year: "numeric" }, Je = { year: "numeric", month: "long" };
964
+ function wt(e, t) {
965
+ return (t.year - e.year) * 12 + t.month - e.month;
966
+ }
967
+ const vt = (e, t) => (e = t === 12 ? new B(e.year, 1) : e, {
968
+ start: e,
969
+ end: e.add({ months: t - 1 })
970
+ });
971
+ function Wt({
972
+ months: e,
973
+ locale: t,
974
+ focusedDate: n,
975
+ setFocusedDate: s
976
+ }) {
977
+ const [o] = I("min"), [r] = I("max"), c = C("focusday"), f = C("change"), a = P(
978
+ () => x(n ?? ot(), o, r),
979
+ [n, o, r]
980
+ ), [i, u] = st(
981
+ () => vt(a.toPlainYearMonth(), e)
982
+ ), d = (h) => {
983
+ const v = wt(i.start, h.toPlainYearMonth());
984
+ return v >= 0 && v < e;
985
+ };
986
+ nt(() => {
987
+ let h = i.start;
988
+ if (!d(a)) {
989
+ const v = wt(h, a.toPlainYearMonth()), z = Math.floor(v / e);
990
+ h = h.add({ months: z * e });
991
+ }
992
+ u(vt(h, e));
993
+ }, [a, e]);
994
+ const l = $();
995
+ function m() {
996
+ l.current.querySelectorAll("calendar-month").forEach((h) => h.focus());
1063
997
  }
1064
- const c = U();
1065
- function h() {
1066
- c.current.querySelectorAll("calendar-month").forEach((m) => m.focus());
998
+ function p(h) {
999
+ s(h), c(w(h));
1067
1000
  }
1068
- const a = x(sn, t), d = x(on, t), y = n == null || !i.contains(n), D = s == null || !i.contains(s);
1001
+ const y = U(Ke, t), E = U(Je, t);
1069
1002
  return {
1070
- format: a,
1071
- formatVerbose: d,
1072
- dateWindow: i,
1073
- dispatch: r,
1074
- handleFocus(m) {
1075
- m.stopPropagation(), l(m.detail), o(m.detail.toDate()), setTimeout(h);
1003
+ format: y,
1004
+ formatVerbose: E,
1005
+ page: i,
1006
+ focusedDate: a,
1007
+ dispatch: f,
1008
+ onFocus(h) {
1009
+ h.stopPropagation(), p(h.detail), setTimeout(m);
1076
1010
  },
1077
- setFocusedDate: l,
1078
- min: s,
1079
- max: n,
1080
- next: y ? () => u(i.next()) : void 0,
1081
- previous: D ? () => u(i.prev()) : void 0,
1082
- focus: h
1011
+ min: o,
1012
+ max: r,
1013
+ next: r == null || !d(r) ? () => p(a.add({ months: e })) : void 0,
1014
+ previous: o == null || !d(o) ? () => p(a.add({ months: -e })) : void 0,
1015
+ focus: m
1083
1016
  };
1084
1017
  }
1085
- const rn = $(
1018
+ const Ze = j(
1086
1019
  (e) => {
1087
- const [t, s] = rt("value"), n = Vt(e);
1088
- j(() => {
1089
- t && n.setFocusedDate(t);
1090
- }, [t]);
1091
- function o(r) {
1092
- s(r.detail), n.dispatch();
1020
+ const [t, n] = I("value"), [s = t, o] = I("focusedDate"), r = Wt({
1021
+ ...e,
1022
+ focusedDate: s,
1023
+ setFocusedDate: o
1024
+ });
1025
+ function c(f) {
1026
+ n(f.detail), r.dispatch();
1093
1027
  }
1094
- return /* @__PURE__ */ p("host", { shadowDom: !0, focus: n.focus, children: /* @__PURE__ */ p(
1095
- Xt,
1028
+ return /* @__PURE__ */ b("host", { shadowDom: !0, focus: r.focus, children: /* @__PURE__ */ b(
1029
+ Kt,
1096
1030
  {
1097
1031
  ...e,
1098
- ...n,
1032
+ ...r,
1099
1033
  value: t,
1100
- onFocus: n.handleFocus,
1101
- onSelect: o
1034
+ onSelect: c
1102
1035
  }
1103
1036
  ) });
1104
1037
  },
1105
- { props: Gt, styles: Qt }
1038
+ { props: Jt, styles: Zt }
1106
1039
  );
1107
- customElements.define("calendar-date", rn);
1108
- const Ct = (e, t) => g.compare(e, t) < 0 ? [e, t] : [t, e], an = $(
1040
+ customElements.define("calendar-date", Ze);
1041
+ const Tt = (e, t) => D.compare(e, t) < 0 ? [e, t] : [t, e], We = j(
1109
1042
  (e) => {
1110
- const [t, s] = Ze("value"), n = Vt(e), o = v("rangestart"), r = v("rangeend"), [i, f] = it();
1111
- j(() => {
1112
- t.length && !st(n.dateWindow.focusedDate, t[0], t[1]) && n.setFocusedDate(t[1]);
1113
- }, [t]);
1114
- async function u(a) {
1115
- n.handleFocus(a), l(a);
1043
+ const [t, n] = je("value"), [s = t[0], o] = I("focusedDate"), r = Wt({
1044
+ ...e,
1045
+ focusedDate: s,
1046
+ setFocusedDate: o
1047
+ }), c = C("rangestart"), f = C("rangeend"), [a, i] = st();
1048
+ function u(p) {
1049
+ r.onFocus(p), d(p);
1116
1050
  }
1117
- function l(a) {
1118
- a.stopPropagation(), f((d) => d && { ...d, second: a.detail });
1051
+ function d(p) {
1052
+ p.stopPropagation(), i((y) => y && { ...y, b: p.detail });
1119
1053
  }
1120
- function c(a) {
1121
- const d = a.detail;
1122
- a.stopPropagation(), i ? (s(Ct(i.first, d)), f(void 0), r(d.toDate()), n.dispatch()) : (f({ first: d, second: d }), o(d.toDate()));
1054
+ function l(p) {
1055
+ const y = p.detail;
1056
+ p.stopPropagation(), a ? (n(Tt(a.a, y)), i(void 0), f(w(y)), r.dispatch()) : (i({ a: y, b: y }), c(w(y)));
1123
1057
  }
1124
- const h = i ? Ct(i.first, i.second) : t;
1125
- return /* @__PURE__ */ p("host", { shadowDom: !0, focus: n.focus, children: /* @__PURE__ */ p(
1126
- Xt,
1058
+ const m = a ? Tt(a.a, a.b) : t;
1059
+ return /* @__PURE__ */ b("host", { shadowDom: !0, focus: r.focus, children: /* @__PURE__ */ b(
1060
+ Kt,
1127
1061
  {
1128
1062
  ...e,
1129
- ...n,
1130
- highlightedRange: h,
1063
+ ...r,
1064
+ highlightedRange: m,
1131
1065
  onFocus: u,
1132
- onHover: l,
1133
- onSelect: c
1066
+ onHover: d,
1067
+ onSelect: l
1134
1068
  }
1135
1069
  ) });
1136
1070
  },
1137
- { props: Gt, styles: Qt }
1071
+ { props: Jt, styles: Zt }
1138
1072
  );
1139
- customElements.define("calendar-range", an);
1073
+ customElements.define("calendar-range", We);
1140
1074
  export {
1141
- rn as CalendarDate,
1142
- nn as CalendarMonth,
1143
- an as CalendarRange
1075
+ Ze as CalendarDate,
1076
+ He as CalendarMonth,
1077
+ We as CalendarRange
1144
1078
  };