@rcarls/rc-common 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/rc-common.js CHANGED
@@ -1,11 +1,11 @@
1
- import { nothing as x } from "lit";
2
- import { PartType as P } from "lit/directive.js";
3
- import { directive as E, AsyncDirective as L } from "lit/async-directive.js";
4
- import { state as A } from "lit/decorators.js";
5
- let C = 0;
1
+ import { nothing as y } from "lit";
2
+ import { PartType as w } from "lit/directive.js";
3
+ import { directive as x, AsyncDirective as E } from "lit/async-directive.js";
4
+ import { state as P } from "lit/decorators.js";
5
+ let k = 0;
6
6
  class U {
7
7
  constructor(t, e) {
8
- this._activeItem = null, this._activeIndex = -1, this._itemCounter = 0, this._opts = e, this._instanceId = `rc-adc-${++C}`, t.addController(this);
8
+ this._activeItem = null, this._activeIndex = -1, this._itemCounter = 0, this._opts = e, this._instanceId = `rc-adc-${++k}`, t.addController(this);
9
9
  }
10
10
  hostConnected() {
11
11
  }
@@ -28,13 +28,13 @@ class U {
28
28
  const e = this._opts.items();
29
29
  if (e.length === 0) return;
30
30
  const i = this._opts.wrap ?? !0;
31
- let n = this._activeIndex < 0 ? t > 0 ? -1 : e.length : this._activeIndex;
32
- const s = e.length;
31
+ let s = this._activeIndex < 0 ? t > 0 ? -1 : e.length : this._activeIndex;
32
+ const n = e.length;
33
33
  let o = 0;
34
34
  do
35
- if (n += t, i ? n = (n % s + s) % s : n = Math.max(0, Math.min(s - 1, n)), o++, !this._isSkipped(e[n])) break;
36
- while (o < s);
37
- this._setActive(e[n] ?? null, n);
35
+ if (s += t, i ? s = (s % n + n) % n : s = Math.max(0, Math.min(n - 1, s)), o++, !this._isSkipped(e[s])) break;
36
+ while (o < n);
37
+ this._setActive(e[s] ?? null, s);
38
38
  }
39
39
  /** Move the virtual cursor to the first non-skipped item. */
40
40
  navigateToFirst() {
@@ -86,9 +86,224 @@ class U {
86
86
  }
87
87
  }
88
88
  }
89
- class I extends L {
89
+ class V {
90
+ constructor(t, e) {
91
+ this._ul = null, this._options = [], this._liElements = [], this._createLi = null, this._createOption = null, this._selectedValues = /* @__PURE__ */ new Set(), this._filterText = "", this._filterStrategy = "contains", this._checkmark = !1, this._optionsInitialized = !1, this._onPointerDown = (i) => {
92
+ const s = i.target;
93
+ if (!s) return;
94
+ const n = s.closest("li[data-value]");
95
+ if (!n || n.getAttribute("role") !== "option" || n.parentElement !== this._ul) return;
96
+ i.preventDefault();
97
+ const o = this.optionForElement(n);
98
+ o && this._onActivate(o);
99
+ }, this._host = t, this._idPrefix = e.idPrefix, this._onInitFromDom = e.onInitFromDom, this._onActivate = e.onActivate, t.addController(this);
100
+ }
101
+ hostConnected() {
102
+ this._host.addEventListener("pointerdown", this._onPointerDown), this._optionsInitialized || this._bootstrapFromDom();
103
+ }
104
+ hostDisconnected() {
105
+ this._host.removeEventListener("pointerdown", this._onPointerDown);
106
+ }
107
+ // -- Accessors --
108
+ get allOptions() {
109
+ return this._options;
110
+ }
111
+ get selectedValues() {
112
+ return [...this._selectedValues];
113
+ }
114
+ get filterText() {
115
+ return this._filterText;
116
+ }
117
+ isSelected(t) {
118
+ return this._selectedValues.has(t);
119
+ }
120
+ optionForElement(t) {
121
+ if (t === this._createLi)
122
+ return this._createOption;
123
+ const e = this._liElements.indexOf(t);
124
+ return e === -1 ? null : this._options[e] ?? null;
125
+ }
126
+ /**
127
+ * Navigable option elements: visible (not `[hidden]`) and not `aria-disabled`.
128
+ * Includes the create option when set. Consumed by `ActiveDescendantController`.
129
+ */
130
+ get navigableItems() {
131
+ const t = [];
132
+ for (let e = 0; e < this._liElements.length; e++) {
133
+ const i = this._liElements[e];
134
+ this._options[e]?.disabled || i.hidden || t.push(i);
135
+ }
136
+ return this._createLi !== null && t.push(this._createLi), t;
137
+ }
138
+ set checkmark(t) {
139
+ this._checkmark !== t && (this._checkmark = t, this._syncCheckmarks());
140
+ }
141
+ // -- Mutation methods --
142
+ /** Replace the full option list. Sets the controller as authoritative, preventing DOM bootstrap. */
143
+ setOptions(t) {
144
+ this._optionsInitialized = !0, this._options = [...t], this._ensureContainer(), this._syncOptionsToDom();
145
+ }
146
+ /** Append a single option without replacing the list. */
147
+ appendOption(t) {
148
+ this._optionsInitialized = !0, this._options = [...this._options, t], this._ensureContainer();
149
+ const e = this._createLiElement(t, this._options.length - 1);
150
+ this._liElements.push(e), this._createLi ? this._ul.insertBefore(e, this._createLi) : this._ul.appendChild(e), this._applyFilterToLi(e, t);
151
+ }
152
+ /** Update `aria-selected` on all option elements to match `values`. */
153
+ setSelectedValues(t) {
154
+ const e = new Set(
155
+ this._options.filter((i) => i.kind === "action").map((i) => i.value)
156
+ );
157
+ this._createOption && e.add(this._createOption.value), this._selectedValues = new Set(t.filter((i) => !e.has(i))), this._syncSelectedToDom();
158
+ }
159
+ /**
160
+ * Apply a filter — sets `[hidden]` on non-matching `<li>` elements.
161
+ * The strategy is stored and re-used when options change.
162
+ */
163
+ filterOptions(t, e = "contains") {
164
+ this._filterText = t, this._filterStrategy = e, this._syncFilterToDom();
165
+ }
166
+ /** Remove `[hidden]` from all option elements. */
167
+ clearFilter() {
168
+ this._filterText = "", this._syncFilterToDom();
169
+ }
170
+ /**
171
+ * Show or hide the synthetic "Create" option at the end of the list.
172
+ * Pass `null` to remove it.
173
+ */
174
+ setCreateOption(t) {
175
+ if (t === null) {
176
+ this._createLi?.remove(), this._createLi = null, this._createOption = null;
177
+ return;
178
+ }
179
+ const e = t.trim();
180
+ if (this._createOption = {
181
+ kind: "action",
182
+ action: "create",
183
+ value: `create:${e}`,
184
+ label: `Create "${e}"`,
185
+ data: { text: e }
186
+ }, !this._createLi) {
187
+ this._ensureContainer();
188
+ const i = document.createElement("li");
189
+ i.setAttribute("id", `${this._idPrefix}-create`), i.setAttribute("role", "option"), i.setAttribute("aria-selected", "false"), i.setAttribute("part", "option create-option"), this._checkmark && this._ensureCheckmark(i), this._ul.appendChild(i), this._createLi = i;
190
+ }
191
+ this._createLi.setAttribute("data-value", this._createOption.value), this._createLi.setAttribute("data-kind", "action"), this._createLi.setAttribute("data-action", this._createOption.action), this._setLabelText(this._createLi, this._createOption.label);
192
+ }
193
+ // -- Private: DOM management --
194
+ _ensureContainer() {
195
+ if (this._ul) return this._ul;
196
+ let t = this._host.querySelector(":scope > ul");
197
+ return t || (t = document.createElement("ul"), this._host.appendChild(t)), t.setAttribute("role", "presentation"), t.setAttribute("aria-hidden", "true"), this._ul = t, t;
198
+ }
199
+ _bootstrapFromDom() {
200
+ const t = this._host.querySelector(":scope > ul");
201
+ if (!t) return;
202
+ this._ul = t, t.setAttribute("role", "presentation"), t.setAttribute("aria-hidden", "true");
203
+ const e = Array.from(t.querySelectorAll(":scope > li"));
204
+ if (e.length === 0) return;
205
+ const i = [];
206
+ for (let s = 0; s < e.length; s++) {
207
+ const n = e[s], o = n.getAttribute("data-value") ?? n.getAttribute("value") ?? n.textContent?.trim() ?? "", a = n.textContent?.trim() ?? "", l = n.hasAttribute("disabled") || n.getAttribute("aria-disabled") === "true";
208
+ i.push({ value: o, label: a, disabled: l }), n.setAttribute("role", "option"), n.setAttribute("id", `${this._idPrefix}-${s}`), n.setAttribute("part", "option"), n.setAttribute("data-value", o), n.setAttribute("aria-selected", this._selectedValues.has(o) ? "true" : "false"), n.setAttribute("aria-disabled", l ? "true" : "false"), this._checkmark && this._ensureCheckmark(n);
209
+ }
210
+ this._options = i, this._liElements = e, this._onInitFromDom?.(i);
211
+ }
212
+ _syncOptionsToDom() {
213
+ const t = this._ensureContainer();
214
+ for (const e of this._liElements) e.remove();
215
+ this._liElements = [];
216
+ for (let e = 0; e < this._options.length; e++) {
217
+ const i = this._createLiElement(this._options[e], e);
218
+ this._liElements.push(i), t.appendChild(i);
219
+ }
220
+ this._createLi && t.appendChild(this._createLi), this._syncFilterToDom();
221
+ }
222
+ _createLiElement(t, e) {
223
+ const i = document.createElement("li");
224
+ return i.setAttribute("role", "option"), i.setAttribute("id", `${this._idPrefix}-${e}`), i.setAttribute("part", "option"), i.setAttribute("data-value", t.value), i.setAttribute("data-kind", t.kind ?? "option"), t.kind === "action" ? i.setAttribute("data-action", t.action) : i.removeAttribute("data-action"), i.setAttribute("aria-selected", this._selectedValues.has(t.value) ? "true" : "false"), i.setAttribute("aria-disabled", t.disabled ? "true" : "false"), this._checkmark && this._ensureCheckmark(i), this._setLabelText(i, t.label), i;
225
+ }
226
+ _setLabelText(t, e) {
227
+ for (const i of t.childNodes)
228
+ if (i.nodeType === Node.TEXT_NODE) {
229
+ i.textContent = e;
230
+ return;
231
+ }
232
+ t.appendChild(document.createTextNode(e));
233
+ }
234
+ _ensureCheckmark(t) {
235
+ if (t.querySelector('[part="option-checkmark"]')) return;
236
+ const e = document.createElement("span");
237
+ e.setAttribute("part", "option-checkmark"), e.setAttribute("aria-hidden", "true"), e.textContent = "✓", t.insertBefore(e, t.firstChild);
238
+ }
239
+ _removeCheckmark(t) {
240
+ t.querySelector('[part="option-checkmark"]')?.remove();
241
+ }
242
+ _syncCheckmarks() {
243
+ const t = this._createLi ? [...this._liElements, this._createLi] : [...this._liElements];
244
+ for (const e of t)
245
+ this._checkmark ? this._ensureCheckmark(e) : this._removeCheckmark(e);
246
+ }
247
+ _syncSelectedToDom() {
248
+ for (let t = 0; t < this._liElements.length; t++) {
249
+ const e = this._options[t];
250
+ e && this._liElements[t].setAttribute(
251
+ "aria-selected",
252
+ this._selectedValues.has(e.value) ? "true" : "false"
253
+ );
254
+ }
255
+ }
256
+ _syncFilterToDom() {
257
+ for (let t = 0; t < this._liElements.length; t++) {
258
+ const e = this._options[t];
259
+ e && this._applyFilterToLi(this._liElements[t], e);
260
+ }
261
+ }
262
+ _applyFilterToLi(t, e) {
263
+ t.hidden = !this._isVisible(e);
264
+ }
265
+ _isVisible(t) {
266
+ if (!this._filterText) return !0;
267
+ const e = t.label.toLowerCase(), i = this._filterText.toLowerCase();
268
+ return typeof this._filterStrategy == "function" ? this._filterStrategy(e, i) : this._filterStrategy === "contains" ? e.includes(i) : e.startsWith(i);
269
+ }
270
+ }
271
+ class T extends E {
272
+ constructor(t) {
273
+ if (super(t), this._options = {}, this._isPointerFocus = !1, this._onPointerdown = () => {
274
+ this._isPointerFocus = !0, this._target?.removeAttribute("data-interaction-mode");
275
+ }, this._onFocusin = () => {
276
+ this._isPointerFocus ? this._isPointerFocus = !1 : this._target?.setAttribute("data-interaction-mode", "keyboard");
277
+ }, this._onKeydown = () => {
278
+ this._target?.setAttribute("data-interaction-mode", "keyboard");
279
+ }, t.type !== w.ELEMENT)
280
+ throw new Error("The `keyInteraction` directive must be used on an element.");
281
+ }
282
+ get _target() {
283
+ return this._options.attributeTarget ?? this._element?.deref();
284
+ }
285
+ _init() {
286
+ const t = this._element?.deref();
287
+ t instanceof HTMLElement && (t.addEventListener("pointerdown", this._onPointerdown, { capture: !0 }), t.addEventListener("focusin", this._onFocusin), t.addEventListener("keydown", this._onKeydown));
288
+ }
289
+ render(t) {
290
+ return y;
291
+ }
292
+ update(t, [e]) {
293
+ this.isConnected && this._element?.deref() === void 0 && (this._element = new WeakRef(t.element), this._init()), this._options = e ?? {};
294
+ }
295
+ disconnected() {
296
+ const t = this._element?.deref();
297
+ t instanceof HTMLElement && (t.removeEventListener("pointerdown", this._onPointerdown, { capture: !0 }), t.removeEventListener("focusin", this._onFocusin), t.removeEventListener("keydown", this._onKeydown));
298
+ }
299
+ reconnected() {
300
+ this._init();
301
+ }
302
+ }
303
+ const Y = x(T);
304
+ class M extends E {
90
305
  constructor(t) {
91
- if (super(t), this._options = {}, t.type !== P.ELEMENT)
306
+ if (super(t), this._options = {}, t.type !== w.ELEMENT)
92
307
  throw new Error(
93
308
  "The `keyNavigation` directive must be used on an element."
94
309
  );
@@ -106,6 +321,8 @@ class I extends L {
106
321
  case "toolbar":
107
322
  case "menubar":
108
323
  return this._element?.deref()?.ariaOrientation === "vertical" ? "vertical" : "horizontal";
324
+ case "separator":
325
+ return this._element?.deref()?.ariaOrientation === "vertical" ? "horizontal" : "vertical";
109
326
  default:
110
327
  return this._element?.deref()?.ariaOrientation === "horizontal" ? "horizontal" : "vertical";
111
328
  }
@@ -125,44 +342,38 @@ class I extends L {
125
342
  }
126
343
  }
127
344
  _onKeydown(t) {
128
- const e = this._normalizeKey(t.key), i = this.navigationAxis, n = this._element?.deref(), s = i === "horizontal" && n != null && getComputedStyle(n).direction === "rtl", o = i === "horizontal" ? s ? "ArrowLeft" : "ArrowRight" : "ArrowDown", a = i === "horizontal" ? s ? "ArrowRight" : "ArrowLeft" : "ArrowUp", d = i === "horizontal" ? "ArrowDown" : "ArrowRight", l = i === "horizontal" ? "ArrowUp" : "ArrowLeft";
345
+ const e = this._normalizeKey(t.key), i = this.navigationAxis, s = this._element?.deref(), n = i === "horizontal" && s != null && getComputedStyle(s).direction === "rtl", o = i === "horizontal" ? n ? "ArrowLeft" : "ArrowRight" : "ArrowDown", a = i === "horizontal" ? n ? "ArrowRight" : "ArrowLeft" : "ArrowUp", l = i === "horizontal" ? "ArrowDown" : "ArrowRight", c = i === "horizontal" ? "ArrowUp" : "ArrowLeft";
129
346
  let h;
130
- this._options.handleNavAxis !== !1 && (e === o ? h = "next" : e === a ? h = "prev" : e === "Home" ? h = "start" : e === "End" && (h = "end")), !h && this._options.handleOpenAxis && (e === d ? h = "open-to-first" : e === l && (h = "open-to-last")), h || (e === "Enter" ? h = this._options.handleActivate ? "activate" : "toggle" : e === " " && this._options.handleActivate ? h = "activate" : e === "Escape" && this._options.handleEscape ? h = "escape" : e === "Tab" && this._options.useInteractionModeAttr && this._element?.deref()?.setAttribute("data-interaction-mode", "keyboard")), h != null && (this._callback(h), this._options.useInteractionModeAttr && this._element?.deref()?.setAttribute("data-interaction-mode", "keyboard"), t.stopPropagation(), t.preventDefault());
131
- }
132
- _onMouseClick(t) {
133
- this._options.useInteractionModeAttr && this._element?.deref()?.removeAttribute("data-interaction-mode");
347
+ this._options.handleNavAxis !== !1 && (e === o ? h = t.shiftKey ? "next-large" : "next" : e === a ? h = t.shiftKey ? "prev-large" : "prev" : e === "Home" ? h = "start" : e === "End" && (h = "end")), !h && this._options.handleOpenAxis && (e === l ? h = "open-to-first" : e === c && (h = "open-to-last")), h || (e === "Enter" ? h = this._options.handleActivate ? "activate" : "toggle" : e === " " && this._options.handleActivate ? h = "activate" : e === "Escape" && this._options.handleEscape && (h = "escape")), h != null && (this._callback(h), t.stopPropagation(), t.preventDefault());
134
348
  }
135
349
  _init() {
136
350
  const t = this._element?.deref();
137
- t != null && t instanceof HTMLElement && (this._keyDownHandle = this._onKeydown.bind(this), this._mouseClickHandle = this._onMouseClick.bind(this), t.addEventListener("keydown", this._keyDownHandle), t.addEventListener("click", this._mouseClickHandle));
351
+ t != null && t instanceof HTMLElement && (this._keyDownHandle = this._onKeydown.bind(this), t.addEventListener("keydown", this._keyDownHandle));
138
352
  }
139
353
  /**
140
354
  * @param _cb - Callback function invoked with the navigation action
141
- * @param _options - Options object or deprecated boolean for useInteractionModeAttr
355
+ * @param _options - Options object or deprecated boolean (deprecated).
142
356
  * @deprecated Passing a boolean as the second parameter is deprecated.
143
- * Use an options object instead: `{ useInteractionModeAttr: true }`
357
+ * Use an options object instead.
144
358
  */
145
359
  render(t, e) {
146
- return x;
360
+ return y;
147
361
  }
148
362
  update(t, [e, i]) {
149
- this.isConnected && this._element?.deref() === void 0 && (this._element = new WeakRef(t.element), this._init()), this._callback = e.bind(t.options?.host ?? t.element), typeof i == "boolean" ? this._options = { useInteractionModeAttr: i } : this._options = {
150
- useInteractionModeAttr: !0,
151
- ...i
152
- };
363
+ this.isConnected && this._element?.deref() === void 0 && (this._element = new WeakRef(t.element), this._init()), this._callback = e.bind(t.options?.host ?? t.element), typeof i == "boolean" ? this._options = {} : this._options = { ...i };
153
364
  }
154
365
  disconnected() {
155
366
  const t = this._element?.deref();
156
- t != null && t instanceof HTMLElement && (t.removeEventListener("keydown", this._keyDownHandle), t.removeEventListener("click", this._mouseClickHandle));
367
+ t != null && t instanceof HTMLElement && t.removeEventListener("keydown", this._keyDownHandle);
157
368
  }
158
369
  reconnected() {
159
370
  this._init();
160
371
  }
161
372
  }
162
- const K = E(I);
163
- class H extends L {
373
+ const X = x(M);
374
+ class D extends E {
164
375
  constructor(t) {
165
- if (super(t), this._activePointerId = null, t.type !== P.ELEMENT)
376
+ if (super(t), this._activePointerId = null, t.type !== w.ELEMENT)
166
377
  throw new Error("The `mouseMove` directive must be used on an element.");
167
378
  this._pointerDownHandle = this._onPointerDown.bind(this), this._pointerMoveHandle = this._onPointerMove.bind(this), this._pointerEndHandle = this._onPointerEnd.bind(this);
168
379
  }
@@ -207,7 +418,7 @@ class H extends L {
207
418
  }
208
419
  /** Render no DOM; this directive only wires pointer listeners. */
209
420
  render(t) {
210
- return x;
421
+ return y;
211
422
  }
212
423
  update(t, [e]) {
213
424
  if (this._callback = e.bind(t.options?.host ?? t.element), !this.isConnected || !(t.element instanceof HTMLElement)) return;
@@ -222,8 +433,8 @@ class H extends L {
222
433
  this._init();
223
434
  }
224
435
  }
225
- const O = E(H);
226
- class N {
436
+ const j = x(D);
437
+ class q {
227
438
  constructor(t, e) {
228
439
  this._dragging = !1, this._startX = 0, this._startY = 0, this._startLeft = 0, this._startTop = 0, this._opts = { axis: "both", step: 4, disabled: !1, handle: null, bounds: "viewport", ...e }, this._onPointerDown = this._handlePointerDown.bind(this), this._onPointerMove = this._handlePointerMove.bind(this), this._onPointerUp = this._handlePointerUp.bind(this), this._onPointerCancel = this._cancelDrag.bind(this), this._onLostPointerCapture = this._handleLostPointerCapture.bind(this), this._onKeyDown = this._handleKeyDown.bind(this), t.addController(this);
229
440
  }
@@ -255,13 +466,13 @@ class N {
255
466
  if (this._opts.disabled || t.target.closest('button, [role="button"], a')) return;
256
467
  const e = this._target(), i = e.getBoundingClientRect();
257
468
  getComputedStyle(e).position === "static" && (e.style.position = "fixed"), e.style.translate = "none", e.style.inset = "auto", e.style.margin = "0", e.style.left = `${i.left}px`, e.style.top = `${i.top}px`, this._startX = t.clientX, this._startY = t.clientY, this._startLeft = i.left, this._startTop = i.top, this._dragging = !0;
258
- const n = this._handle();
259
- n.setPointerCapture(t.pointerId), n.addEventListener("pointermove", this._onPointerMove), n.addEventListener("pointerup", this._onPointerUp), n.addEventListener("pointercancel", this._onPointerCancel), n.addEventListener("lostpointercapture", this._onLostPointerCapture), t.preventDefault();
469
+ const s = this._handle();
470
+ s.setPointerCapture(t.pointerId), s.addEventListener("pointermove", this._onPointerMove), s.addEventListener("pointerup", this._onPointerUp), s.addEventListener("pointercancel", this._onPointerCancel), s.addEventListener("lostpointercapture", this._onLostPointerCapture), t.preventDefault();
260
471
  }
261
472
  _handlePointerMove(t) {
262
473
  if (!this._dragging) return;
263
- const e = this._target(), { axis: i } = this._opts, [n, s, o, a] = this._boundsRect(), d = i !== "y" ? Math.min(Math.max(this._startLeft + t.clientX - this._startX, n), o - e.offsetWidth) : parseFloat(e.style.left) || 0, l = i !== "x" ? Math.min(Math.max(this._startTop + t.clientY - this._startY, s), a - e.offsetHeight) : parseFloat(e.style.top) || 0;
264
- e.style.left = `${d}px`, e.style.top = `${l}px`;
474
+ const e = this._target(), { axis: i } = this._opts, [s, n, o, a] = this._boundsRect(), l = i !== "y" ? Math.min(Math.max(this._startLeft + t.clientX - this._startX, s), o - e.offsetWidth) : parseFloat(e.style.left) || 0, c = i !== "x" ? Math.min(Math.max(this._startTop + t.clientY - this._startY, n), a - e.offsetHeight) : parseFloat(e.style.top) || 0;
475
+ e.style.left = `${l}px`, e.style.top = `${c}px`;
265
476
  }
266
477
  _handlePointerUp(t) {
267
478
  this._cancelDrag();
@@ -278,34 +489,34 @@ class N {
278
489
  _handleKeyDown(t) {
279
490
  if (this._opts.disabled || t.currentTarget !== t.target) return;
280
491
  const { axis: e } = this._opts, i = t.shiftKey ? this._opts.step * 10 : this._opts.step;
281
- let n = 0, s = 0;
492
+ let s = 0, n = 0;
282
493
  switch (t.key) {
283
494
  case "ArrowLeft":
284
495
  if (e === "y") return;
285
- n = -i;
496
+ s = -i;
286
497
  break;
287
498
  case "ArrowRight":
288
499
  if (e === "y") return;
289
- n = i;
500
+ s = i;
290
501
  break;
291
502
  case "ArrowUp":
292
503
  if (e === "x") return;
293
- s = -i;
504
+ n = -i;
294
505
  break;
295
506
  case "ArrowDown":
296
507
  if (e === "x") return;
297
- s = i;
508
+ n = i;
298
509
  break;
299
510
  default:
300
511
  return;
301
512
  }
302
513
  const o = this._target();
303
514
  if (getComputedStyle(o).position === "static") {
304
- const p = o.getBoundingClientRect();
305
- o.style.position = "fixed", o.style.translate = "none", o.style.left = `${p.left}px`, o.style.top = `${p.top}px`;
515
+ const _ = o.getBoundingClientRect();
516
+ o.style.position = "fixed", o.style.translate = "none", o.style.left = `${_.left}px`, o.style.top = `${_.top}px`;
306
517
  }
307
- const [a, d, l, h] = this._boundsRect(), u = parseFloat(o.style.left) || 0, c = parseFloat(o.style.top) || 0;
308
- o.style.left = `${Math.min(Math.max(u + n, a), l - o.offsetWidth)}px`, o.style.top = `${Math.min(Math.max(c + s, d), h - o.offsetHeight)}px`, t.preventDefault(), t.stopPropagation();
518
+ const [a, l, c, h] = this._boundsRect(), p = parseFloat(o.style.left) || 0, d = parseFloat(o.style.top) || 0;
519
+ o.style.left = `${Math.min(Math.max(p + s, a), c - o.offsetWidth)}px`, o.style.top = `${Math.min(Math.max(d + n, l), h - o.offsetHeight)}px`, t.preventDefault(), t.stopPropagation();
309
520
  }
310
521
  _boundsRect() {
311
522
  const { bounds: t } = this._opts;
@@ -314,14 +525,14 @@ class N {
314
525
  if (t === "parent") {
315
526
  const i = this._opts.target.parentElement;
316
527
  if (!i) return [0, 0, window.innerWidth, window.innerHeight];
317
- const n = i.getBoundingClientRect();
318
- return [n.left, n.top, n.right, n.bottom];
528
+ const s = i.getBoundingClientRect();
529
+ return [s.left, s.top, s.right, s.bottom];
319
530
  }
320
531
  const e = t.getBoundingClientRect();
321
532
  return [e.left, e.top, e.right, e.bottom];
322
533
  }
323
534
  }
324
- class Y {
535
+ class G {
325
536
  constructor(t, e) {
326
537
  this._resizing = null, this._startX = 0, this._startY = 0, this._startW = 0, this._startH = 0, this._startLeft = 0, this._startTop = 0, this._effectiveMinW = 0, this._effectiveMinH = 0, this._cornerBtn = null, this._opts = {
327
538
  direction: "none",
@@ -398,24 +609,24 @@ class Y {
398
609
  _detectEdge(t) {
399
610
  const { direction: e, threshold: i } = this._opts;
400
611
  if (e === "none") return null;
401
- const n = this._target().getBoundingClientRect(), s = t.clientX, o = t.clientY, a = s >= n.right - i && s <= n.right + i, d = s >= n.left - i && s <= n.left + i, l = o >= n.bottom - i && o <= n.bottom + i, h = o >= n.top - i && o <= n.top + i, u = s >= n.left && s <= n.right, c = o >= n.top && o <= n.bottom;
612
+ const s = this._target().getBoundingClientRect(), n = t.clientX, o = t.clientY, a = n >= s.right - i && n <= s.right + i, l = n >= s.left - i && n <= s.left + i, c = o >= s.bottom - i && o <= s.bottom + i, h = o >= s.top - i && o <= s.top + i, p = n >= s.left && n <= s.right, d = o >= s.top && o <= s.bottom;
402
613
  if (e === "both") {
403
- if (a && l) return "se";
404
- if (d && l) return "sw";
614
+ if (a && c) return "se";
615
+ if (l && c) return "sw";
405
616
  if (a && h) return "ne";
406
- if (d && h) return "nw";
407
- if (a && c) return "e";
408
- if (d && c) return "w";
409
- if (l && u) return "s";
410
- if (h && u) return "n";
617
+ if (l && h) return "nw";
618
+ if (a && d) return "e";
619
+ if (l && d) return "w";
620
+ if (c && p) return "s";
621
+ if (h && p) return "n";
411
622
  }
412
623
  if (e === "horizontal") {
413
- if (a && c) return "e";
414
- if (d && c) return "w";
624
+ if (a && d) return "e";
625
+ if (l && d) return "w";
415
626
  }
416
627
  if (e === "vertical") {
417
- if (l && u) return "s";
418
- if (h && u) return "n";
628
+ if (c && p) return "s";
629
+ if (h && p) return "n";
419
630
  }
420
631
  return null;
421
632
  }
@@ -438,35 +649,35 @@ class Y {
438
649
  const e = this._detectEdge(t);
439
650
  if (!e) return;
440
651
  t.stopPropagation();
441
- const i = this._target(), n = this._pinPosition(i);
442
- this._startX = t.clientX, this._startY = t.clientY, this._startW = n.width, this._startH = n.height, this._startLeft = n.left, this._startTop = n.top, this._resizing = e;
443
- const s = getComputedStyle(i);
444
- this._effectiveMinW = Math.max(this._opts.minWidth, parseFloat(s.minWidth) || 0), this._effectiveMinH = Math.max(this._opts.minHeight, parseFloat(s.minHeight) || 0), i.setPointerCapture(t.pointerId), t.preventDefault();
652
+ const i = this._target(), s = this._pinPosition(i);
653
+ this._startX = t.clientX, this._startY = t.clientY, this._startW = s.width, this._startH = s.height, this._startLeft = s.left, this._startTop = s.top, this._resizing = e;
654
+ const n = getComputedStyle(i);
655
+ this._effectiveMinW = Math.max(this._opts.minWidth, parseFloat(n.minWidth) || 0), this._effectiveMinH = Math.max(this._opts.minHeight, parseFloat(n.minHeight) || 0), i.setPointerCapture(t.pointerId), t.preventDefault();
445
656
  }
446
657
  _handlePointerMove(t) {
447
658
  if (this._resizing) {
448
- const n = this._target(), [s, o, a, d] = this._boundsRect(), { maxWidth: l, maxHeight: h } = this._opts, u = this._effectiveMinW, c = this._effectiveMinH, p = t.clientX - this._startX, m = t.clientY - this._startY, _ = this._resizing;
449
- if (_ === "e" || _ === "se" || _ === "ne") {
450
- const f = Math.min(l ?? 1 / 0, a - this._startLeft);
451
- n.style.width = `${Math.min(Math.max(this._startW + p, u), f)}px`;
659
+ const s = this._target(), [n, o, a, l] = this._boundsRect(), { maxWidth: c, maxHeight: h } = this._opts, p = this._effectiveMinW, d = this._effectiveMinH, _ = t.clientX - this._startX, m = t.clientY - this._startY, u = this._resizing;
660
+ if (u === "e" || u === "se" || u === "ne") {
661
+ const f = Math.min(c ?? 1 / 0, a - this._startLeft);
662
+ s.style.width = `${Math.min(Math.max(this._startW + _, p), f)}px`;
452
663
  }
453
- if (_ === "w" || _ === "sw" || _ === "nw") {
664
+ if (u === "w" || u === "sw" || u === "nw") {
454
665
  const f = this._startLeft + this._startW, g = Math.min(
455
- Math.max(this._startLeft + p, s, l !== void 0 ? f - l : -1 / 0),
456
- f - u
666
+ Math.max(this._startLeft + _, n, c !== void 0 ? f - c : -1 / 0),
667
+ f - p
457
668
  );
458
- n.style.left = `${g}px`, n.style.width = `${f - g}px`;
669
+ s.style.left = `${g}px`, s.style.width = `${f - g}px`;
459
670
  }
460
- if (_ === "s" || _ === "se" || _ === "sw") {
461
- const f = Math.min(h ?? 1 / 0, d - this._startTop);
462
- n.style.height = `${Math.min(Math.max(this._startH + m, c), f)}px`;
671
+ if (u === "s" || u === "se" || u === "sw") {
672
+ const f = Math.min(h ?? 1 / 0, l - this._startTop);
673
+ s.style.height = `${Math.min(Math.max(this._startH + m, d), f)}px`;
463
674
  }
464
- if (_ === "n" || _ === "ne" || _ === "nw") {
675
+ if (u === "n" || u === "ne" || u === "nw") {
465
676
  const f = this._startTop + this._startH, g = Math.min(
466
677
  Math.max(this._startTop + m, o, h !== void 0 ? f - h : -1 / 0),
467
- f - c
678
+ f - d
468
679
  );
469
- n.style.top = `${g}px`, n.style.height = `${f - g}px`;
680
+ s.style.top = `${g}px`, s.style.height = `${f - g}px`;
470
681
  }
471
682
  return;
472
683
  }
@@ -482,19 +693,19 @@ class Y {
482
693
  }
483
694
  _handleKeyDown(t) {
484
695
  if (this._opts.disabled) return;
485
- const { direction: e } = this._opts, i = t.key === "ArrowRight" || t.key === "ArrowLeft", n = t.key === "ArrowDown" || t.key === "ArrowUp";
486
- if (i && e === "vertical" || n && e === "horizontal" || !i && !n) return;
696
+ const { direction: e } = this._opts, i = t.key === "ArrowRight" || t.key === "ArrowLeft", s = t.key === "ArrowDown" || t.key === "ArrowUp";
697
+ if (i && e === "vertical" || s && e === "horizontal" || !i && !s) return;
487
698
  t.preventDefault(), t.stopPropagation();
488
- const s = this._target(), o = this._pinPosition(s), a = t.shiftKey ? this._opts.step * 10 : this._opts.step, [, , d, l] = this._boundsRect(), { maxWidth: h, maxHeight: u } = this._opts, c = getComputedStyle(s), p = Math.max(this._opts.minWidth, parseFloat(c.minWidth) || 0), m = Math.max(this._opts.minHeight, parseFloat(c.minHeight) || 0);
699
+ const n = this._target(), o = this._pinPosition(n), a = t.shiftKey ? this._opts.step * 10 : this._opts.step, [, , l, c] = this._boundsRect(), { maxWidth: h, maxHeight: p } = this._opts, d = getComputedStyle(n), _ = Math.max(this._opts.minWidth, parseFloat(d.minWidth) || 0), m = Math.max(this._opts.minHeight, parseFloat(d.minHeight) || 0);
489
700
  if (t.key === "ArrowRight") {
490
- const _ = Math.min(h ?? 1 / 0, d - o.left);
491
- s.style.width = `${Math.min(Math.max(s.offsetWidth + a, p), _)}px`;
701
+ const u = Math.min(h ?? 1 / 0, l - o.left);
702
+ n.style.width = `${Math.min(Math.max(n.offsetWidth + a, _), u)}px`;
492
703
  }
493
- if (t.key === "ArrowLeft" && (s.style.width = `${Math.max(s.offsetWidth - a, p)}px`), t.key === "ArrowDown") {
494
- const _ = Math.min(u ?? 1 / 0, l - o.top);
495
- s.style.height = `${Math.min(Math.max(s.offsetHeight + a, m), _)}px`;
704
+ if (t.key === "ArrowLeft" && (n.style.width = `${Math.max(n.offsetWidth - a, _)}px`), t.key === "ArrowDown") {
705
+ const u = Math.min(p ?? 1 / 0, c - o.top);
706
+ n.style.height = `${Math.min(Math.max(n.offsetHeight + a, m), u)}px`;
496
707
  }
497
- t.key === "ArrowUp" && (s.style.height = `${Math.max(s.offsetHeight - a, m)}px`);
708
+ t.key === "ArrowUp" && (n.style.height = `${Math.max(n.offsetHeight - a, m)}px`);
498
709
  }
499
710
  _boundsRect() {
500
711
  const { bounds: t } = this._opts;
@@ -503,8 +714,8 @@ class Y {
503
714
  if (t === "parent") {
504
715
  const i = this._opts.target.parentElement;
505
716
  if (!i) return [0, 0, window.innerWidth, window.innerHeight];
506
- const n = i.getBoundingClientRect();
507
- return [n.left, n.top, n.right, n.bottom];
717
+ const s = i.getBoundingClientRect();
718
+ return [s.left, s.top, s.right, s.bottom];
508
719
  }
509
720
  const e = t.getBoundingClientRect();
510
721
  return [e.left, e.top, e.right, e.bottom];
@@ -539,7 +750,7 @@ function v(r, t) {
539
750
  return `top: auto; bottom: anchor(bottom); left: anchor(right); right: auto; margin-left: ${e};`;
540
751
  }
541
752
  }
542
- const y = {
753
+ const L = {
543
754
  top: "bottom",
544
755
  "top-start": "bottom-start",
545
756
  "top-end": "bottom-end",
@@ -552,7 +763,7 @@ const y = {
552
763
  right: "left",
553
764
  "right-start": "left-start",
554
765
  "right-end": "left-end"
555
- }, k = {
766
+ }, S = {
556
767
  top: "top",
557
768
  "top-start": "top-end",
558
769
  "top-end": "top-start",
@@ -565,15 +776,15 @@ const y = {
565
776
  right: "right",
566
777
  "right-start": "right-end",
567
778
  "right-end": "right-start"
568
- }, M = CSS.supports("position-try-fallbacks: flip-block");
569
- let w = null, b = null;
570
- function T() {
571
- return M ? Promise.resolve(null) : (b || (b = import("./css-anchor-positioning-fn-hFYJeBk4.js").then((r) => (w = r.default, w)).catch(() => null)), b);
779
+ }, C = CSS.supports("position-try-fallbacks: flip-block") && CSS.supports("min-width: anchor-size(width)");
780
+ let A = null, b = null;
781
+ function I() {
782
+ return C ? Promise.resolve(null) : (b || (b = import("./css-anchor-positioning-fn-hFYJeBk4.js").then((r) => (A = r.default, A)).catch(() => null)), b);
572
783
  }
573
- let D = 0;
574
- class X {
784
+ let $ = 0;
785
+ class J {
575
786
  constructor(t, e) {
576
- this._styleEl = null, this._adoptedSheet = null, this._opts = e, this._uid = `rc-anchor-${++D}`, t.addController(this);
787
+ this._styleEl = null, this._adoptedSheet = null, this._opts = e, this._uid = `rc-anchor-${++$}`, t.addController(this);
577
788
  }
578
789
  setOptions(t) {
579
790
  Object.assign(this._opts, t), this._applyAndPolyfill();
@@ -601,10 +812,10 @@ class X {
601
812
  return typeof t == "function" ? t() : t ?? null;
602
813
  }
603
814
  _applyAndPolyfill() {
604
- this._apply(), M || this._applyPolyfillOrFallback();
815
+ this._apply(), C || this._applyPolyfillOrFallback();
605
816
  }
606
817
  async _applyPolyfillOrFallback() {
607
- const t = await T(), e = this._shadowHost();
818
+ const t = await I(), e = this._shadowHost();
608
819
  t ? await t({ roots: e ? [e] : void 0, useAnimationFrame: !1 }) : this._positionFallback();
609
820
  }
610
821
  _apply() {
@@ -614,24 +825,24 @@ class X {
614
825
  }
615
826
  const t = this._anchor(), e = this._floating();
616
827
  if (!t || !e) return;
617
- const i = this._opts.placement ?? "bottom-start", n = this._opts.offset ?? 4, s = this._opts.flip ?? !0, o = `--${this._uid}`, a = this._uid;
828
+ const i = this._opts.placement ?? "bottom-start", s = this._opts.offset ?? 4, n = this._opts.flip ?? !0, o = `--${this._uid}`, a = this._uid;
618
829
  t.style.setProperty("anchor-name", o), e.setAttribute("data-rc-anchor", a);
619
- const d = y[i], l = k[i], h = y[l], u = s ? `
620
- @position-try --${a}-end { ${v(l, n)} }
621
- @position-try --${a}-flip { ${v(d, n)} }
622
- @position-try --${a}-both { ${v(h, n)} }
623
- ` : "", c = s ? `position-try-fallbacks: --${a}-end, --${a}-flip, --${a}-both;` : "", p = `
624
- ${u}
830
+ const l = L[i], c = S[i], h = L[c], p = n ? `
831
+ @position-try --${a}-end { ${v(c, s)} }
832
+ @position-try --${a}-flip { ${v(l, s)} }
833
+ @position-try --${a}-both { ${v(h, s)} }
834
+ ` : "", d = n ? `position-try-fallbacks: --${a}-end, --${a}-flip, --${a}-both;` : "", _ = `
835
+ ${p}
625
836
  [data-rc-anchor="${a}"] {
626
837
  position: fixed;
627
838
  position-anchor: ${o};
628
839
  box-sizing: border-box;
629
840
  min-width: anchor-size(width);
630
- ${v(i, n)}
631
- ${c}
841
+ ${v(i, s)}
842
+ ${d}
632
843
  }
633
844
  `;
634
- this._injectStyles(p);
845
+ this._injectStyles(_);
635
846
  }
636
847
  _injectStyles(t) {
637
848
  const e = this._shadowHost();
@@ -643,24 +854,24 @@ class X {
643
854
  _positionFallback() {
644
855
  const t = this._anchor(), e = this._floating();
645
856
  if (!t || !e) return;
646
- const i = this._opts.placement ?? "bottom-start", n = this._opts.offset ?? 4, s = t.getBoundingClientRect(), o = window.innerWidth, a = window.innerHeight;
647
- e.style.position = "fixed", e.style.boxSizing = "border-box", e.style.minWidth = `${s.width}px`;
648
- const d = i.startsWith("bottom") || i === "bottom", l = a - s.bottom;
649
- d && l < 120 && s.top > l ? (e.style.top = "", e.style.bottom = `${a - s.top + n}px`) : (e.style.bottom = "", e.style.top = `${s.bottom + n}px`);
650
- const u = i.endsWith("-end"), c = e.offsetWidth || parseFloat(getComputedStyle(e).minWidth) || 0;
651
- let p = u ? s.right - c : s.left;
652
- p + c > o - 4 && (p = s.right - c), p = Math.max(4, Math.min(p, o - c - 4)), e.style.left = `${p}px`;
857
+ const i = this._opts.placement ?? "bottom-start", s = this._opts.offset ?? 4, n = t.getBoundingClientRect(), o = window.innerWidth, a = window.innerHeight;
858
+ e.style.position = "fixed", e.style.boxSizing = "border-box", e.style.minWidth = `${n.width}px`;
859
+ const l = i.startsWith("bottom") || i === "bottom", c = a - n.bottom;
860
+ l && c < 120 && n.top > c ? (e.style.top = "", e.style.bottom = `${a - n.top + s}px`) : (e.style.bottom = "", e.style.top = `${n.bottom + s}px`);
861
+ const p = i.endsWith("-end"), d = e.offsetWidth || parseFloat(getComputedStyle(e).minWidth) || 0;
862
+ let _ = p ? n.right - d : n.left;
863
+ _ + d > o - 4 && (_ = n.right - d), _ = Math.max(4, Math.min(_, o - d - 4)), e.style.left = `${_}px`;
653
864
  }
654
865
  _cleanup() {
655
866
  const t = this._anchor(), e = this._floating();
656
867
  t && t.style.removeProperty("anchor-name"), e && e.removeAttribute("data-rc-anchor"), this._styleEl?.remove(), this._styleEl = null;
657
868
  const i = this._shadowHost();
658
869
  i?.shadowRoot && this._adoptedSheet && (i.shadowRoot.adoptedStyleSheets = i.shadowRoot.adoptedStyleSheets.filter(
659
- (n) => n !== this._adoptedSheet
870
+ (s) => s !== this._adoptedSheet
660
871
  ), this._adoptedSheet = null);
661
872
  }
662
873
  }
663
- class j {
874
+ class Q {
664
875
  constructor(t, e) {
665
876
  this._attached = null, this._scrolled = !1, this._onScroll = () => this._evaluate(), this._host = t, this._opts = e, t.addController(this);
666
877
  }
@@ -702,21 +913,141 @@ class j {
702
913
  i !== this._scrolled && (this._scrolled = i, this._opts.onChange?.(i, t), this._host.requestUpdate());
703
914
  }
704
915
  }
705
- function $(r) {
916
+ class Z {
917
+ constructor(t, e) {
918
+ this._attached = null, this._observer = null, this._options = e, t.addController(this);
919
+ }
920
+ setOptions(t) {
921
+ this._detach(), Object.assign(this._options, t), this._attach();
922
+ }
923
+ hostConnected() {
924
+ this._attach();
925
+ }
926
+ hostDisconnected() {
927
+ this._detach();
928
+ }
929
+ _resolveTarget() {
930
+ const { target: t } = this._options;
931
+ return typeof t == "function" ? t() : t ?? null;
932
+ }
933
+ _attach() {
934
+ if (this._options.disabled || this._attached) return;
935
+ const t = this._resolveTarget();
936
+ t && (this._observer ??= new MutationObserver(this._options.callback), this._observer.observe(t, this._options.observerOptions ?? { childList: !0 }), this._attached = t);
937
+ }
938
+ _detach() {
939
+ this._observer?.disconnect(), this._attached = null;
940
+ }
941
+ }
942
+ class tt {
943
+ constructor(t) {
944
+ this._callback = null, this._frame = 0, t?.addController(this);
945
+ }
946
+ get pending() {
947
+ return this._frame !== 0;
948
+ }
949
+ schedule(t) {
950
+ this._callback = t, !this._frame && (this._frame = requestAnimationFrame((e) => {
951
+ const i = this._callback;
952
+ this._frame = 0, this._callback = null, i?.(e);
953
+ }));
954
+ }
955
+ cancel() {
956
+ this._frame && (cancelAnimationFrame(this._frame), this._frame = 0, this._callback = null);
957
+ }
958
+ hostDisconnected() {
959
+ this.cancel();
960
+ }
961
+ }
962
+ class et {
963
+ constructor(t) {
964
+ this._buffer = "", this._timer = 0, this._options = t;
965
+ }
966
+ get buffer() {
967
+ return this._buffer;
968
+ }
969
+ reset() {
970
+ this._buffer = "", this._clearTimer();
971
+ }
972
+ handleKeydown(t) {
973
+ return t.key.length !== 1 || t.altKey || t.ctrlKey || t.metaKey ? !1 : (this.search(t.key), t.preventDefault(), !0);
974
+ }
975
+ search(t) {
976
+ this._buffer += t.toLocaleLowerCase(), this._scheduleReset();
977
+ const e = this._options.items();
978
+ if (!e.length) return null;
979
+ const i = this._options.startIndex?.() ?? 0, s = e.length;
980
+ for (let n = 1; n <= s; n += 1) {
981
+ const o = (i + n) % s, a = e[o];
982
+ if (this._options.text(a).trim().toLocaleLowerCase().startsWith(this._buffer))
983
+ return this._options.onMatch(a, o), a;
984
+ }
985
+ return null;
986
+ }
987
+ _scheduleReset() {
988
+ this._clearTimer(), this._timer = window.setTimeout(() => this.reset(), this._options.timeout ?? 500);
989
+ }
990
+ _clearTimer() {
991
+ this._timer && (window.clearTimeout(this._timer), this._timer = 0);
992
+ }
993
+ }
994
+ function it(r) {
995
+ let t = r.parentElement;
996
+ for (; t && t !== document.documentElement; ) {
997
+ const { overflow: e, overflowY: i } = getComputedStyle(t);
998
+ if (/auto|scroll/.test(i) || /auto|scroll/.test(e)) return t;
999
+ t = t.parentElement;
1000
+ }
1001
+ return document.scrollingElement ?? document.documentElement;
1002
+ }
1003
+ function H(r) {
706
1004
  return r == null || r.hasAttribute("disabled") ? !1 : !!((r instanceof HTMLAnchorElement || r instanceof HTMLAreaElement) && r.hasAttribute("href") || r instanceof HTMLButtonElement || r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement || r instanceof HTMLSelectElement || r.hasAttribute("tabindex") || r.shadowRoot?.delegatesFocus === !0);
707
1005
  }
708
- var S = Object.defineProperty, R = (r, t, e, i) => {
709
- for (var n = void 0, s = r.length - 1, o; s >= 0; s--)
710
- (o = r[s]) && (n = o(t, e, n) || n);
711
- return n && S(t, e, n), n;
1006
+ function F(r, t) {
1007
+ return r.querySelector(t);
1008
+ }
1009
+ function z(r, t) {
1010
+ return Array.from(r.querySelectorAll(t));
1011
+ }
1012
+ function st(r, t) {
1013
+ if (z(r, t.selector).length >= (t.minimum ?? 1)) return !1;
1014
+ const e = t.hostName ?? r.localName, i = t.childDescription ?? t.selector.replace(":scope > ", ""), s = t.message ?? `[${e}] No direct child ${i} found. Place ${i} inside <${e}>.`;
1015
+ return console.warn(s, r), !0;
1016
+ }
1017
+ class nt {
1018
+ constructor(t, e) {
1019
+ this._observer = null, this._child = null, this._host = t, this._options = e, t.addController(this);
1020
+ }
1021
+ get child() {
1022
+ return this._child;
1023
+ }
1024
+ hostConnected() {
1025
+ if (this.sync(), !this._options.observe) return;
1026
+ this._observer ??= new MutationObserver(() => this.sync());
1027
+ const t = this._options.observe === !0 ? { childList: !0 } : this._options.observe;
1028
+ this._observer.observe(this._host, t);
1029
+ }
1030
+ hostDisconnected() {
1031
+ this._observer?.disconnect(), this._child = null;
1032
+ }
1033
+ /** Re-read the child from the host and invoke `onChange` when it changes. */
1034
+ sync() {
1035
+ const t = this._child, e = F(this._host, this._options.selector);
1036
+ return this._child = e, e || this._options.onMissing?.(this._host), e !== t && this._options.onChange?.(e, t), e;
1037
+ }
1038
+ }
1039
+ var R = Object.defineProperty, O = (r, t, e, i) => {
1040
+ for (var s = void 0, n = r.length - 1, o; n >= 0; n--)
1041
+ (o = r[n]) && (s = o(t, e, s) || s);
1042
+ return s && R(t, e, s), s;
712
1043
  };
713
- function V(r) {
1044
+ function ot(r) {
714
1045
  class t extends r {
715
1046
  constructor() {
716
1047
  super(...arguments), this._items = [];
717
1048
  }
718
1049
  get items() {
719
- return this._items.map((i) => i.deref()).filter((i) => $(i));
1050
+ return this._items.map((i) => i.deref()).filter((i) => H(i));
720
1051
  }
721
1052
  get firstItem() {
722
1053
  return this.items.at(0);
@@ -757,15 +1088,15 @@ function V(r) {
757
1088
  return i.assignedElements();
758
1089
  }
759
1090
  _handleItemFocus(i) {
760
- const n = i.composedPath().find(
761
- (s) => this.items.includes(s)
1091
+ const s = i.composedPath().find(
1092
+ (n) => this.items.includes(n)
762
1093
  );
763
- n != null && (this._lastFocused = n, this.items.forEach((s) => s.setAttribute("tabindex", "-1")), n.setAttribute("tabindex", "0"));
1094
+ s != null && (this._lastFocused = s, this.items.forEach((n) => n.setAttribute("tabindex", "-1")), s.setAttribute("tabindex", "0"));
764
1095
  }
765
1096
  _onSlotChange(i) {
766
- const n = this._items;
767
- this._items = this._collectItems(i.currentTarget).map((s) => new WeakRef(s)), queueMicrotask(() => {
768
- this.isConnected && (n.forEach((s) => s.deref()?.removeAttribute("tabindex")), this._initItems());
1097
+ const s = this._items;
1098
+ this._items = this._collectItems(i.currentTarget).map((n) => new WeakRef(n)), queueMicrotask(() => {
1099
+ this.isConnected && (s.forEach((n) => n.deref()?.removeAttribute("tabindex")), this._initItems());
769
1100
  });
770
1101
  }
771
1102
  /**
@@ -778,34 +1109,44 @@ function V(r) {
778
1109
  * first currently-focusable item.
779
1110
  */
780
1111
  _initItems() {
781
- this._items.forEach((n) => n.deref()?.setAttribute("tabindex", "-1"));
1112
+ this._items.forEach((s) => s.deref()?.setAttribute("tabindex", "-1"));
782
1113
  const i = this.items[0];
783
1114
  i && i.setAttribute("tabindex", "0");
784
1115
  }
785
1116
  }
786
- return R([
787
- A()
1117
+ return O([
1118
+ P()
788
1119
  ], t.prototype, "_lastFocused"), t;
789
1120
  }
790
- function q(r, t, e, i) {
791
- const n = Math.min(Math.max(r, t), e);
792
- if (i <= 0) return n;
793
- const s = Math.round((n - t) / i) * i + t;
794
- return Math.min(Math.max(s, t), e);
1121
+ function rt(r, t, e, i) {
1122
+ const s = Math.min(Math.max(r, t), e);
1123
+ if (i <= 0) return s;
1124
+ const n = Math.round((s - t) / i) * i + t;
1125
+ return Math.min(Math.max(n, t), e);
795
1126
  }
796
- function G(r, t, e) {
1127
+ function at(r, t, e) {
797
1128
  return e === t ? 0 : Math.min(Math.max((r - t) / (e - t), 0), 1);
798
1129
  }
799
1130
  export {
800
1131
  U as ActiveDescendantController,
801
- X as AnchorController,
802
- N as DragController,
803
- Y as ResizeController,
804
- V as RovingTabIndexMixin,
805
- j as ScrollObserverController,
806
- $ as isFocusable,
807
- K as keyNavigation,
808
- O as mouseMove,
809
- q as snapToStep,
810
- G as valueToPercent
1132
+ J as AnchorController,
1133
+ q as DragController,
1134
+ V as ItemsCollectionController,
1135
+ Z as MutationObserverController,
1136
+ nt as NativeChildController,
1137
+ tt as RafScheduler,
1138
+ G as ResizeController,
1139
+ ot as RovingTabIndexMixin,
1140
+ Q as ScrollObserverController,
1141
+ et as TypeaheadController,
1142
+ it as findNearestScrollAncestor,
1143
+ F as getDirectChild,
1144
+ z as getDirectChildren,
1145
+ H as isFocusable,
1146
+ Y as keyInteraction,
1147
+ X as keyNavigation,
1148
+ j as mouseMove,
1149
+ rt as snapToStep,
1150
+ at as valueToPercent,
1151
+ st as warnMissingDirectChild
811
1152
  };