react-animated-select 0.7.5 → 0.7.7

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/index.es.js CHANGED
@@ -1,11 +1,11 @@
1
1
  "use client";
2
- import { jsx as O, jsxs as q } from "react/jsx-runtime";
3
- import { createContext as we, useState as U, useRef as F, useInsertionEffect as yt, isValidElement as xe, cloneElement as bt, useMemo as _, useLayoutEffect as ne, useEffect as oe, useCallback as K, useContext as B, useEffectEvent as ot, Children as it, useSyncExternalStore as re, memo as se, Fragment as at, Component as vt, useId as wt, useImperativeHandle as xt, useReducer as Ot } from "react";
4
- import { flushSync as St, createPortal as Et } from "react-dom";
5
- import './index.css';const Y = we(null), ce = we(null), de = we(null), kt = (e, t) => {
2
+ import { jsx as M, jsxs as ee } from "react/jsx-runtime";
3
+ import { createContext as Ae, useState as Q, useRef as G, useInsertionEffect as Ft, isValidElement as Ne, cloneElement as Ht, useMemo as Z, useLayoutEffect as X, useEffect as J, useCallback as Y, useContext as V, useEffectEvent as yt, Children as vt, useSyncExternalStore as ce, memo as ie, Fragment as wt, Component as Pt, useReducer as Vt, useId as zt, useImperativeHandle as Wt } from "react";
4
+ import { flushSync as et, createPortal as qt } from "react-dom";
5
+ import './index.css';const ne = Ae(null), ue = Ae(null), fe = Ae(null), Gt = (e, t) => {
6
6
  const n = typeof t == "function" ? t(e) : t;
7
7
  return n === e ? e : Object.keys(n).some((s) => !Object.is(n[s], e[s])) ? { ...e, ...n } : e;
8
- }, Me = (e) => {
8
+ }, xt = (e) => {
9
9
  let t = e;
10
10
  const n = /* @__PURE__ */ new Set();
11
11
  return {
@@ -15,31 +15,31 @@ import './index.css';const Y = we(null), ce = we(null), de = we(null), kt = (e,
15
15
  },
16
16
  subscribe: (r) => (n.add(r), () => n.delete(r))
17
17
  };
18
- }, Re = (e) => {
19
- const t = F(e);
20
- yt(() => {
18
+ }, _e = (e) => {
19
+ const t = G(e);
20
+ Ft(() => {
21
21
  t.current = e;
22
22
  });
23
- const [n] = U(() => Object.fromEntries(
23
+ const [n] = Q(() => Object.fromEntries(
24
24
  Object.keys(e).map((r) => [r, (...s) => t.current[r](...s)])
25
25
  ));
26
26
  return n;
27
- }, lt = (e, t) => {
28
- const [n, r] = U(e);
27
+ }, Ot = (e, t) => {
28
+ const [n, r] = Q(e);
29
29
  return n === e || t(n, e) ? n : (r(e), e);
30
- }, Ct = (e, t) => e === t || !!e && !!t && Object.keys(e).length === Object.keys(t).length && Object.keys(e).every((n) => Object.is(e[n], t[n])), Ie = (e, t, n = 0) => {
30
+ }, Kt = (e, t) => e === t || !!e && !!t && Object.keys(e).length === Object.keys(t).length && Object.keys(e).every((n) => Object.is(e[n], t[n])), Te = (e, t, n = 0) => {
31
31
  if (Object.is(e, t)) return !0;
32
32
  if (n > 12 || typeof e != "object" || typeof t != "object" || e === null || t === null || Array.isArray(e) !== Array.isArray(t)) return !1;
33
- if (e.$$typeof || t.$$typeof) return e.$$typeof === t.$$typeof && e.type === t.type && e.key === t.key && Ie(e.props, t.props, n + 1);
33
+ if (e.$$typeof || t.$$typeof) return e.$$typeof === t.$$typeof && e.type === t.type && e.key === t.key && Te(e.props, t.props, n + 1);
34
34
  const r = Object.keys(e);
35
- return r.length === Object.keys(t).length && r.every((s) => Object.hasOwn(t, s) && Ie(e[s], t[s], n + 1));
36
- }, Tt = /* @__PURE__ */ new Set(["style", "texts", "icons", "attrs"]), Mt = (e, t) => {
35
+ return r.length === Object.keys(t).length && r.every((s) => Object.hasOwn(t, s) && Te(e[s], t[s], n + 1));
36
+ }, _t = /* @__PURE__ */ new Set(["style", "texts", "icons", "attrs"]), Ut = (e, t) => {
37
37
  const n = Object.keys(t);
38
38
  return n.length === Object.keys(e).length && n.every(
39
- (r) => Tt.has(r) ? Ct(e[r], t[r]) : Object.is(e[r], t[r])
39
+ (r) => _t.has(r) ? Kt(e[r], t[r]) : Object.is(e[r], t[r])
40
40
  );
41
- }, It = (e) => lt(e, Mt), Ne = (e) => lt(e, Ie), he = {
42
- XMark: ({ className: e = "", ...t }) => /* @__PURE__ */ O(
41
+ }, Yt = (e) => Ot(e, Ut), ze = (e) => Ot(e, Te), Se = {
42
+ XMark: ({ className: e = "", ...t }) => /* @__PURE__ */ M(
43
43
  "svg",
44
44
  {
45
45
  className: e,
@@ -49,10 +49,10 @@ import './index.css';const Y = we(null), ce = we(null), de = we(null), kt = (e,
49
49
  height: "1em",
50
50
  width: "1em",
51
51
  ...t,
52
- children: /* @__PURE__ */ O("path", { d: "M310.6 361.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L160 301.3 54.6 406.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L114.7 256 9.4 150.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 210.7 265.4 105.4c12.5-12.5 32.8-12.5 45.3 0s12.5 32.8 0 45.3L205.3 256l105.3 105.4z" })
52
+ children: /* @__PURE__ */ M("path", { d: "M310.6 361.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L160 301.3 54.6 406.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L114.7 256 9.4 150.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 210.7 265.4 105.4c12.5-12.5 32.8-12.5 45.3 0s12.5 32.8 0 45.3L205.3 256l105.3 105.4z" })
53
53
  }
54
54
  ),
55
- ArrowUp: ({ className: e = "", ...t }) => /* @__PURE__ */ O(
55
+ ArrowUp: ({ className: e = "", ...t }) => /* @__PURE__ */ M(
56
56
  "svg",
57
57
  {
58
58
  className: e,
@@ -62,10 +62,10 @@ import './index.css';const Y = we(null), ce = we(null), de = we(null), kt = (e,
62
62
  height: "1em",
63
63
  width: "1em",
64
64
  ...t,
65
- children: /* @__PURE__ */ O("path", { d: "M34.9 289.5l175.9-175.8c9.4-9.4 24.6-9.4 33.9 0L420.1 289.5c15.1 15.1 4.4 41-17 41H51.9c-21.4 0-32.1-25.9-17-41z" })
65
+ children: /* @__PURE__ */ M("path", { d: "M34.9 289.5l175.9-175.8c9.4-9.4 24.6-9.4 33.9 0L420.1 289.5c15.1 15.1 4.4 41-17 41H51.9c-21.4 0-32.1-25.9-17-41z" })
66
66
  }
67
67
  ),
68
- Checkmark: ({ className: e = "", ...t }) => /* @__PURE__ */ O(
68
+ Checkmark: ({ className: e = "", ...t }) => /* @__PURE__ */ M(
69
69
  "svg",
70
70
  {
71
71
  className: e,
@@ -75,10 +75,10 @@ import './index.css';const Y = we(null), ce = we(null), de = we(null), kt = (e,
75
75
  height: "1em",
76
76
  width: "1em",
77
77
  ...t,
78
- children: /* @__PURE__ */ O("path", { d: "M20.285 6.708a1 1 0 0 0-1.414-1.416l-9.192 9.192-4.243-4.244a1 1 0 1 0-1.414 1.416l5 5a1 1 0 0 0 1.414 0l9.849-9.948z" })
78
+ children: /* @__PURE__ */ M("path", { d: "M20.285 6.708a1 1 0 0 0-1.414-1.416l-9.192 9.192-4.243-4.244a1 1 0 1 0-1.414 1.416l5 5a1 1 0 0 0 1.414 0l9.849-9.948z" })
79
79
  }
80
80
  )
81
- }, ae = (e, t) => {
81
+ }, he = (e, t) => {
82
82
  if (!e) return null;
83
83
  const n = (r = {}) => ({
84
84
  ...t,
@@ -88,360 +88,378 @@ import './index.css';const Y = we(null), ce = we(null), de = we(null), kt = (e,
88
88
  ...r?.style
89
89
  }
90
90
  });
91
- return typeof e == "string" ? /* @__PURE__ */ O("img", { src: e, ...n(), className: ue("rac-icon", t?.className), alt: "" }) : xe(e) ? bt(e, n(e.props)) : typeof e == "function" || typeof e == "object" && e.$$typeof ? /* @__PURE__ */ O(e, { ...n() }) : null;
92
- }, Oe = (e, t) => `${e}-${String(t).replace(/[^A-Za-z0-9-]/gu, (n) => `_${n.codePointAt(0).toString(36)}_`)}`, X = (e) => e ? "" : void 0, ue = (e, t) => t ? `${e} ${t}` : e, Ve = (e, t, n) => e.jsx || (t && "original" in e ? t(e.original, { selected: n, disabled: !!e.disabled }) : null), Be = /* @__PURE__ */ q("span", { className: "rac-dots", "aria-hidden": "true", children: [
93
- /* @__PURE__ */ O("i", {}),
94
- /* @__PURE__ */ O("i", {}),
95
- /* @__PURE__ */ O("i", {})
96
- ] }), Nt = (() => {
91
+ return typeof e == "string" ? /* @__PURE__ */ M("img", { src: e, ...n(), className: me("rac-icon", t?.className), alt: "" }) : Ne(e) ? Ht(e, n(e.props)) : typeof e == "function" || typeof e == "object" && e.$$typeof ? /* @__PURE__ */ M(e, { ...n() }) : null;
92
+ }, De = (e, t) => `${e}-${String(t).replace(/[^A-Za-z0-9-]/gu, (n) => `_${n.codePointAt(0).toString(36)}_`)}`, re = (e) => e ? "" : void 0, me = (e, t) => t ? `${e} ${t}` : e, Ue = (e, t, n) => e.jsx || (t && "original" in e ? t(e.original, { selected: n, disabled: !!e.disabled }) : null), Ye = /* @__PURE__ */ ee("span", { className: "rac-dots", "aria-hidden": "true", children: [
93
+ /* @__PURE__ */ M("i", {}),
94
+ /* @__PURE__ */ M("i", {}),
95
+ /* @__PURE__ */ M("i", {})
96
+ ] }), Xt = (() => {
97
97
  try {
98
98
  return process.env.NODE_ENV !== "production";
99
99
  } catch {
100
100
  return !1;
101
101
  }
102
- })(), ze = /* @__PURE__ */ new Set(), le = (e, t) => {
103
- !Nt || ze.has(e) || (ze.add(e), console.warn(`[react-animated-select] ${t}`));
104
- }, Q = (e) => {
102
+ })(), tt = /* @__PURE__ */ new Set(), le = (e, t) => {
103
+ !Xt || tt.has(e) || (tt.add(e), console.warn(`[react-animated-select] ${t}`));
104
+ }, oe = (e) => {
105
105
  e?.stopPropagation(), e?.preventDefault();
106
- }, At = { index: -1, fallback: -1, ready: !1 }, ye = ({ index: e, fallback: t }) => e === -1 ? t : e, $t = 10, Lt = 500, Dt = /* @__PURE__ */ new Set(["ArrowDown", "ArrowUp", "PageDown", "PageUp", "Home", "End"]), jt = (e, t) => _(() => {
106
+ }, Et = (e, t) => {
107
+ e?.currentTarget.contains(document.activeElement) && t.current?.focus();
108
+ }, Jt = { index: -1, fallback: -1, ready: !1 }, Ie = ({ index: e, fallback: t }) => e === -1 ? t : e, Zt = 10, Qt = 500, en = /* @__PURE__ */ new Set(["ArrowDown", "ArrowUp", "PageDown", "PageUp", "Home", "End"]), tn = (e, t) => Z(() => {
107
109
  const n = new Set(e.map((s) => s.group).filter(Boolean)), r = (s) => !!s && !s.disabled && !s.loading && (s.groupHeader ? n.has(s.name) : !s.group || t.has(s.group));
108
- return { reach: r, list: e.flatMap((s, c) => r(s) ? [c] : []) };
109
- }, [e, t]), Pt = (e, t, n, r) => {
110
+ return { reach: r, list: e.flatMap((s, o) => r(s) ? [o] : []) };
111
+ }, [e, t]), nn = (e, t, n, r) => {
110
112
  const s = e.length - 1;
111
113
  if (s < 0) return -1;
112
114
  if (n === "Home") return e[0];
113
115
  if (n === "End") return e[s];
114
- const c = n === "ArrowUp" || n === "PageUp" ? -1 : 1, i = e.indexOf(t);
115
- if (i === -1) return e[c > 0 ? 0 : s];
116
- const a = i + c * (n.startsWith("Page") ? $t : 1);
116
+ const o = n === "ArrowUp" || n === "PageUp" ? -1 : 1, i = e.indexOf(t);
117
+ if (i === -1) return e[o > 0 ? 0 : s];
118
+ const a = i + o * (n.startsWith("Page") ? Zt : 1);
117
119
  return a >= 0 && a <= s ? e[a] : n.startsWith("Page") || r ? e[a < 0 ? 0 : s] : e[(a + e.length) % e.length];
118
- }, Rt = (e, t, n, r) => {
119
- const s = [...r].every((o) => o === r[0]), c = s ? r[0] : r, i = t.filter((o) => "original" in e[o]), a = Math.max(i.indexOf(n) + (s ? 1 : 0), 0);
120
- for (let o = 0; o < i.length; o++) {
121
- const p = i[(a + o) % i.length];
122
- if (String(e[p].name).toLowerCase().startsWith(c)) return p;
120
+ }, rn = (e, t, n, r) => {
121
+ const s = [...r].every((l) => l === r[0]), o = s ? r[0] : r, i = t.filter((l) => "original" in e[l]), a = Math.max(i.indexOf(n) + (s ? 1 : 0), 0);
122
+ for (let l = 0; l < i.length; l++) {
123
+ const b = i[(a + l) % i.length];
124
+ if (String(e[b].name).toLowerCase().startsWith(o)) return b;
123
125
  }
124
126
  return -1;
125
127
  };
126
- function Vt({ props: e, state: t, setState: n, normalizedOptions: r, expandedGroups: s, selected: c, selectedIDs: i, visibility: a, setVisibility: o, modelActions: p, loadMoreOnce: l, highlightStore: g }) {
127
- const { disabled: y, multiple: h, hasMore: S, loadButton: w, loadOffset: f, loadAhead: m, icons: D, onFocus: L, onBlur: C } = e, { selectOption: j, clear: M, removeOption: u } = p, { deleting: x } = t, { reach: E, list: $ } = jt(r, s), k = F({ lastWindowFocusTime: 0, justFocused: !1, focusTimeout: null, query: "", queryTimeout: null }), V = _(() => {
128
- const d = new Set(h ? i.map((T) => T.id) : c ? [c.id] : []), v = d.size ? r.findIndex((T) => d.has(T.id) && E(T)) : -1;
129
- return v !== -1 ? v : $.find((T) => !r[T].groupHeader) ?? $[0] ?? -1;
130
- }, [r, c, i, h, E, $]), I = (d) => {
131
- !w && a && S && d >= r.length - m && l();
128
+ function sn({ props: e, state: t, setState: n, normalizedOptions: r, expandedGroups: s, selected: o, selectedIDs: i, visibility: a, setVisibility: l, modelActions: b, loadMoreOnce: u, highlightStore: x }) {
129
+ const { disabled: d, multiple: c, hasMore: y, loadButton: w, loadOffset: p, loadAhead: f, icons: v, onFocus: A, onBlur: T, onKeyDown: H } = e, { selectOption: C, clear: g, removeOption: k } = b, { deleting: D } = t, { reach: R, list: I } = tn(r, s), B = G({ lastWindowFocusTime: 0, justFocused: !1, focusTimeout: null, query: "", queryTimeout: null }), m = Z(() => {
130
+ const h = new Set(c ? i.map((E) => E.id) : o ? [o.id] : []), O = h.size ? r.findIndex((E) => h.has(E.id) && R(E)) : -1;
131
+ return O !== -1 ? O : I.find((E) => !r[E].groupHeader) ?? I[0] ?? -1;
132
+ }, [r, o, i, c, R, I]), L = (h) => {
133
+ !w && a && y && h >= r.length - f && u();
132
134
  };
133
- ne(() => {
134
- const { index: d } = g.get();
135
- g.set({ fallback: V, index: d !== -1 && E(r[d]) ? d : -1 }), I(ye(g.get()));
136
- }), oe(() => {
137
- const d = k.current, v = () => d.lastWindowFocusTime = Date.now();
138
- return window.addEventListener("focus", v), () => {
139
- window.removeEventListener("focus", v), clearTimeout(d.focusTimeout), clearTimeout(d.queryTimeout);
135
+ X(() => {
136
+ const { index: h } = x.get();
137
+ x.set({ fallback: m, index: h !== -1 && R(r[h]) ? h : -1 }), L(Ie(x.get()));
138
+ }), J(() => {
139
+ const h = B.current, O = () => h.lastWindowFocusTime = Date.now();
140
+ return window.addEventListener("focus", O), () => {
141
+ window.removeEventListener("focus", O), clearTimeout(h.focusTimeout), clearTimeout(h.queryTimeout);
140
142
  };
141
143
  }, []);
142
- const A = (d) => {
143
- g.set({ index: d }), I(d);
144
- }, b = (d, v) => {
145
- const T = k.current;
146
- clearTimeout(T.queryTimeout), T.queryTimeout = setTimeout(() => T.query = "", Lt), T.query += d.toLowerCase();
147
- const H = Rt(r, $, v, T.query);
148
- H !== -1 && A(H), a || o(!0);
144
+ const S = (h) => {
145
+ x.set({ index: h }), L(h);
146
+ }, F = (h, O) => {
147
+ const E = B.current;
148
+ clearTimeout(E.queryTimeout), E.queryTimeout = setTimeout(() => E.query = "", Qt), E.query += h.toLowerCase();
149
+ const $ = rn(r, I, O, E.query);
150
+ $ !== -1 && S($), a || l(!0);
149
151
  };
150
- return Re({
151
- highlight: A,
152
- handleListScroll: (d) => {
152
+ return _e({
153
+ highlight: S,
154
+ handleListScroll: (h) => {
153
155
  if (w) return;
154
- const { scrollTop: v, scrollHeight: T, clientHeight: H } = d.currentTarget;
155
- T - v <= H + f && l();
156
+ const { scrollTop: O, scrollHeight: E, clientHeight: $ } = h.currentTarget;
157
+ E - O <= $ + p && u();
156
158
  },
157
- handleBlur: (d) => {
158
- const v = d.relatedTarget?.closest(".rac-options");
159
- d.currentTarget.contains(d.relatedTarget) || v || (C?.(d), x && n({ deleting: !1 }), a && o(!1));
159
+ handleBlur: (h) => {
160
+ const O = h.relatedTarget?.closest(".rac-options");
161
+ h.currentTarget.contains(h.relatedTarget) || O || (T?.(h), D && n({ deleting: !1 }), a && l(!1));
160
162
  },
161
163
  // [DOC: select-behavior]
162
- handleFocus: (d) => {
163
- d.currentTarget.contains(d.relatedTarget) || L?.(d), !(y || x || document.hidden || Date.now() - k.current.lastWindowFocusTime < 100) && (a || (clearTimeout(k.current.focusTimeout), k.current.focusTimeout = setTimeout(() => k.current.justFocused = !1, 200), k.current.justFocused = !0, o(!0)));
164
+ handleFocus: (h) => {
165
+ const O = h.currentTarget.contains(h.relatedTarget);
166
+ O || A?.(h), !(O || h.target !== h.currentTarget || a || d || D || document.hidden || Date.now() - B.current.lastWindowFocusTime < 100) && (clearTimeout(B.current.focusTimeout), B.current.focusTimeout = setTimeout(() => B.current.justFocused = !1, 200), B.current.justFocused = !0, l(!0));
164
167
  },
165
- toggleVisibility: (d) => {
166
- if (x) {
167
- Q(d), n({ deleting: !1 });
168
+ toggleVisibility: (h) => {
169
+ if (D) {
170
+ oe(h), n({ deleting: !1 });
168
171
  return;
169
172
  }
170
- y || k.current.justFocused || o(!a);
173
+ d || B.current.justFocused || l(!a);
171
174
  },
172
- handleKeyDown: (d) => {
173
- if (y || d.nativeEvent?.isComposing) return;
174
- const { key: v } = d, T = ye(g.get());
175
- if (v.length === 1 && !d.ctrlKey && !d.metaKey && !d.altKey && (v !== " " || k.current.query)) {
176
- d.preventDefault(), b(v, T);
175
+ handleKeyDown: (h) => {
176
+ if (H?.(h), h.defaultPrevented || d || h.nativeEvent?.isComposing) return;
177
+ const { key: O } = h;
178
+ if (h.target !== h.currentTarget && (O === "Enter" || O.length === 1)) return;
179
+ const E = Ie(x.get());
180
+ if (O.length === 1 && !h.ctrlKey && !h.metaKey && !h.altKey && (O !== " " || B.current.query)) {
181
+ h.preventDefault(), F(O, E);
177
182
  return;
178
183
  }
179
- if (Dt.has(v)) {
180
- d.preventDefault(), (a || v === "Home" || v === "End") && A(Pt($, T, v, !w && S)), a || o(!0);
184
+ if (en.has(O)) {
185
+ h.preventDefault(), (a || O === "Home" || O === "End") && S(nn(I, E, O, !w && y)), a || l(!0);
181
186
  return;
182
187
  }
183
- switch (v) {
188
+ switch (O) {
184
189
  case "Enter":
185
190
  case " ":
186
- d.preventDefault(), a ? T !== -1 && r[T] && (A(T), j(r[T], d)) : o(!0);
191
+ h.preventDefault(), a ? E !== -1 && r[E] && (S(E), C(r[E], h)) : l(!0);
187
192
  break;
188
193
  // [DOC: select-behavior]
189
194
  case "Escape":
190
- if (x) n({ deleting: !1 });
191
- else if (a) o(!1);
195
+ if (D) n({ deleting: !1 });
196
+ else if (a) l(!1);
192
197
  else break;
193
- Q(d);
198
+ oe(h);
194
199
  break;
195
200
  case "Tab":
196
- a && o(!1);
201
+ a && l(!1);
197
202
  break;
198
203
  // [DOC: select-behavior]
199
204
  case "Backspace":
200
205
  case "Delete": {
201
- const H = i.at(-1);
202
- if (h && v === "Backspace" && D.remove && H) u(H.id);
203
- else if (D.clear && (c || H)) M();
206
+ const $ = i.at(-1);
207
+ if (c && O === "Backspace" && v.remove && $) k($.id);
208
+ else if (v.clear && (o || $)) g();
204
209
  else break;
205
- d.preventDefault();
210
+ h.preventDefault();
206
211
  break;
207
212
  }
208
213
  }
209
214
  }
210
215
  });
211
216
  }
212
- const Bt = ["group", "disabled", "options", "items", "children"], He = ["name", "label", "id", "value"], ge = (e) => e != null && e !== "", ct = (e) => e !== null && typeof e == "object" && !Array.isArray(e), Se = (e) => ct(e) && [Object.prototype, null].includes(Object.getPrototypeOf(e)), Ht = (e) => {
217
+ const on = ["group", "disabled", "options", "items", "children"], Xe = ["name", "label", "id", "value"], Oe = (e) => e != null && e !== "", St = (e) => e !== null && typeof e == "object" && !Array.isArray(e), Le = (e) => St(e) && [Object.prototype, null].includes(Object.getPrototypeOf(e)), an = (e) => {
213
218
  try {
214
219
  const t = String(e);
215
220
  return t.startsWith("[object ") ? null : t;
216
221
  } catch {
217
222
  return null;
218
223
  }
219
- }, Fe = (e, t = !1) => {
224
+ }, Je = (e, t = !1) => {
220
225
  if (t && typeof e.group == "string") return e.group;
221
- const n = He.find((c) => ge(e[c]));
226
+ const n = Xe.find((o) => Oe(e[o]));
222
227
  if (n) return String(e[n]);
223
- const r = !Se(e) && Ht(e);
228
+ const r = !Le(e) && an(e);
224
229
  if (r) return r;
225
- const s = Object.entries(e).find(([c, i]) => !Bt.includes(c) && ge(i));
230
+ const s = Object.entries(e).find(([o, i]) => !on.includes(o) && Oe(i));
226
231
  return s ? String(s[1]) : null;
227
- }, Ft = (e) => Se(e) && ("options" in e || "group" in e && !He.some((t) => t in e)), Ke = (e, t, n, r, s, { emptyOption: c, invalidOption: i, disabledOption: a }) => {
228
- const o = `${n}-${t}`;
232
+ }, cn = (e) => Le(e) && ("options" in e || "group" in e && !Xe.some((t) => t in e)), nt = (e, t, n, r, s, { emptyOption: o, invalidOption: i, disabledOption: a }) => {
233
+ const l = `${n}-${t}`;
229
234
  if (e == null || e === "")
230
- return { id: o, userId: null, name: c, raw: e, disabled: !0, type: "normal", group: r, groupDisabled: s };
235
+ return { id: l, userId: null, name: o, raw: e, disabled: !0, type: "normal", group: r, groupDisabled: s };
231
236
  if (typeof e == "function")
232
- return { id: o, userId: null, name: i, raw: e, disabled: !0, invalid: !0, type: "normal", group: r };
233
- if (ct(e)) {
234
- const p = s || e.disabled === !0, l = e.value !== void 0 ? e.value : e.id !== void 0 ? e.id : e, g = Fe(e) || (p ? a : c);
237
+ return { id: l, userId: null, name: i, raw: e, disabled: !0, invalid: !0, type: "normal", group: r };
238
+ if (St(e)) {
239
+ const b = s || e.disabled === !0, u = e.value !== void 0 ? e.value : e.id !== void 0 ? e.id : e, x = Je(e) || (b ? a : o);
235
240
  return {
236
- id: o,
241
+ id: l,
237
242
  userId: e.id ?? e.value ?? e.name ?? e.label,
238
- name: g,
239
- raw: l,
243
+ name: x,
244
+ raw: u,
240
245
  original: e,
241
- disabled: p || g === c,
242
- type: typeof l == "boolean" ? "boolean" : "normal",
246
+ disabled: b || x === o,
247
+ type: typeof u == "boolean" ? "boolean" : "normal",
243
248
  group: r || e.group || null,
244
249
  groupDisabled: s
245
250
  };
246
251
  }
247
- return { id: o, userId: e, name: String(e), raw: e, original: e, disabled: s, type: typeof e == "boolean" ? "boolean" : "normal", group: r };
248
- }, Gt = ({
252
+ return { id: l, userId: e, name: String(e), raw: e, original: e, disabled: s, type: typeof e == "boolean" ? "boolean" : "normal", group: r };
253
+ }, ln = ({
249
254
  options: e,
250
255
  jsxOptions: t,
251
256
  childrenFirst: n,
252
257
  hasMore: r,
253
258
  loadButton: s,
254
- loadPending: c,
259
+ loadPending: o,
255
260
  loadingTitle: i,
256
261
  emptyOption: a,
257
- invalidOption: o,
258
- disabledOption: p,
259
- emptyGroup: l
262
+ invalidOption: l,
263
+ disabledOption: b,
264
+ emptyGroup: u
260
265
  }) => {
261
- const g = { emptyOption: a, invalidOption: o, disabledOption: p }, y = /* @__PURE__ */ new Map(), h = [], S = /* @__PURE__ */ new Set(), w = (u) => {
262
- let x = u;
263
- for (let E = 1; S.has(x); E++) x = `${u}~${E}`;
264
- return S.add(x), x;
265
- }, f = t.map((u, x) => {
266
- if (u.isGroupMarker) return { ...u, type: "group-marker" };
267
- const E = !u.label && !ge(u.userId) && !ge(u.value) && !u.hasJsx;
266
+ const x = { emptyOption: a, invalidOption: l, disabledOption: b }, d = /* @__PURE__ */ new Map(), c = [], y = /* @__PURE__ */ new Set(), w = (g) => {
267
+ let k = g;
268
+ for (let D = 1; y.has(k); D++) k = `${g}~${D}`;
269
+ return y.add(k), k;
270
+ }, p = t.map((g, k) => {
271
+ if (g.isGroupMarker) return { ...g, type: "group-marker" };
272
+ const D = !g.label && !Oe(g.userId) && !Oe(g.value) && !g.hasJsx;
268
273
  return {
269
- ...u,
270
- id: w(`jsx-${u.id}`),
271
- index: x,
272
- userId: u.userId,
273
- raw: u.value,
274
- original: u.value,
275
- name: u.label || (ge(u.value) ? String(u.value) : a),
276
- disabled: !!u.disabled || E,
277
- type: typeof u.value == "boolean" ? "boolean" : "normal",
278
- group: u.group || null
274
+ ...g,
275
+ id: w(`jsx-${g.id}`),
276
+ index: k,
277
+ userId: g.userId,
278
+ raw: g.value,
279
+ original: g.value,
280
+ name: g.label || (Oe(g.value) ? String(g.value) : a),
281
+ disabled: !!g.disabled || D,
282
+ type: typeof g.value == "boolean" ? "boolean" : "normal",
283
+ group: g.group || null
279
284
  };
280
285
  });
281
- let m = 0;
282
- const D = (u, x = null, E = !1, $ = "0") => {
283
- Array.isArray(u) || (u = [u]), u.forEach((k, V) => {
284
- const I = `${$}-${V}`;
285
- if (Ft(k)) {
286
- const A = Fe(k, !0) || l;
287
- y.has(A) || y.set(A, { disabled: !!k.disabled, items: [] }), k.options ? D(k.options, A, E || !!k.disabled, I) : h.push({ id: `empty-${A}-${I}`, name: A, group: A, isPlaceholder: !0, type: "group-marker", index: m++ });
288
- } else Se(k) && !He.some((A) => A in k) && !k.group ? Object.values(k).forEach((A, b) => h.push({ ...Ke(A, `${I}-${b}`, "default", x, E, g), index: m++ })) : h.push({ ...Ke(k, I, "default", x, E, g), index: m++ });
286
+ let f = 0;
287
+ const v = (g, k = null, D = !1, R = "0") => {
288
+ Array.isArray(g) || (g = [g]), g.forEach((I, B) => {
289
+ const m = `${R}-${B}`;
290
+ if (cn(I)) {
291
+ const L = Je(I, !0) || u;
292
+ d.has(L) || d.set(L, { disabled: !!I.disabled, items: [] }), I.options ? v(I.options, L, D || !!I.disabled, m) : c.push({ id: `empty-${L}-${m}`, name: L, group: L, isPlaceholder: !0, type: "group-marker", index: f++ });
293
+ } else Le(I) && !Xe.some((L) => L in I) && !I.group ? Object.values(I).forEach((L, S) => c.push({ ...nt(L, `${m}-${S}`, "default", k, D, x), index: f++ })) : c.push({ ...nt(I, m, "default", k, D, x), index: f++ });
289
294
  });
290
295
  };
291
- D(e);
292
- const L = n ? [...f, ...h] : [...h, ...f], C = [], j = /* @__PURE__ */ new Set();
293
- L.forEach((u) => {
294
- if (!u.group) {
295
- C.push({ type: "item", data: u });
296
+ v(e);
297
+ const A = n ? [...p, ...c] : [...c, ...p], T = [], H = /* @__PURE__ */ new Set();
298
+ A.forEach((g) => {
299
+ if (!g.group) {
300
+ T.push({ type: "item", data: g });
296
301
  return;
297
302
  }
298
- j.has(u.group) || (j.add(u.group), C.push({ type: "group", name: u.group })), y.has(u.group) || y.set(u.group, { items: [] });
299
- const x = y.get(u.group);
300
- u.isGroupMarker ? (x.className = u.className, x.style = u.style, u.disabled && (x.disabled = !0)) : u.isPlaceholder || x.items.push(u);
303
+ H.has(g.group) || (H.add(g.group), T.push({ type: "group", name: g.group })), d.has(g.group) || d.set(g.group, { items: [] });
304
+ const k = d.get(g.group);
305
+ g.isGroupMarker ? (k.className = g.className, k.style = g.style, g.disabled && (k.disabled = !0)) : g.isPlaceholder || k.items.push(g);
301
306
  });
302
- const M = [];
303
- return C.forEach((u) => {
304
- if (u.type === "item") {
305
- M.push(u.data);
307
+ const C = [];
308
+ return T.forEach((g) => {
309
+ if (g.type === "item") {
310
+ C.push(g.data);
306
311
  return;
307
312
  }
308
- const x = y.get(u.name);
309
- M.push({
310
- className: x?.className || "",
311
- id: `group-header-${u.name}`,
312
- disabled: !!x?.disabled,
313
- style: x?.style || {},
313
+ const k = d.get(g.name);
314
+ C.push({
315
+ className: k?.className || "",
316
+ id: `group-header-${g.name}`,
317
+ disabled: !!k?.disabled,
318
+ style: k?.style || {},
314
319
  groupHeader: !0,
315
- name: u.name,
320
+ name: g.name,
316
321
  type: "group"
317
- }), x?.items.forEach((E) => M.push(E));
318
- }), r && s && M.push({ id: "special-load-more-id", name: i, loadMore: !0, loading: c, type: "special" }), M;
319
- }, Rn = (e) => {
322
+ }), k?.items.forEach((D) => C.push(D));
323
+ }), r && s && C.push({ id: "special-load-more-id", name: i, loadMore: !0, loading: o, type: "special" }), C;
324
+ }, fr = (e) => {
320
325
  const t = () => null;
321
326
  return t.racKind = "define", t.racRender = e, t.displayName = `defineOption(${e.name || "anonymous"})`, t;
322
- }, qe = { selected: null, selectedIDs: [] }, fe = (e) => {
327
+ }, rt = { selected: null, selectedIDs: [] }, ye = (e) => {
323
328
  try {
324
329
  return JSON.stringify(e);
325
330
  } catch {
326
331
  return;
327
332
  }
328
- }, dt = (e, t) => e === t || e !== e && t !== t, be = (e) => typeof e == "object" && e !== null, Wt = (e, t) => dt(e, t) || be(e) && be(t) && fe(e) !== void 0 && fe(e) === fe(t), zt = (e, t, n, r) => {
329
- if (e == null || Array.isArray(e) && e.length === 0) return qe;
330
- const s = r.length ? new Map(t.map((l) => [l.id, l])) : null, c = s ? [...r.map((l) => s.get(l)).filter(Boolean), ...t] : t, i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map(), o = (l) => "original" in l && !i.has(l.id), p = (l) => {
331
- const g = be(l);
332
- let y = c.find((m) => o(m) && dt(m.original, l));
333
- const h = g ? fe(l) : void 0;
334
- if (!y && h !== void 0 && (y = c.find((m) => o(m) && be(m.original) && fe(m.original) === h)), y)
335
- return i.add(y.id), y;
336
- const S = String(g ? l.id || l.value || h || "object" : l), w = (a.get(S) ?? -1) + 1;
337
- a.set(S, w);
338
- const f = `virtual-${S}-${w}`;
339
- return g ? { id: f, name: Fe(l) || String(l.id || "Selected Object"), raw: l.value ?? l.id ?? l, original: l, userId: l.id ?? l.value ?? null, virtual: !0 } : { id: f, name: String(l), raw: l, original: l, userId: l, virtual: !0 };
333
+ }, kt = (e, t) => e === t || e !== e && t !== t, Me = (e) => typeof e == "object" && e !== null, dn = (e, t) => kt(e, t) || Me(e) && Me(t) && ye(e) !== void 0 && ye(e) === ye(t), st = (e, t, n, r) => {
334
+ if (e == null || Array.isArray(e) && e.length === 0) return rt;
335
+ const s = r.length ? new Map(t.map((u) => [u.id, u])) : null, o = s ? [...r.map((u) => s.get(u)).filter(Boolean), ...t] : t, i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map(), l = (u) => "original" in u && !i.has(u.id), b = (u) => {
336
+ const x = Me(u);
337
+ let d = o.find((f) => l(f) && kt(f.original, u));
338
+ const c = x ? ye(u) : void 0;
339
+ if (!d && c !== void 0 && (d = o.find((f) => l(f) && Me(f.original) && ye(f.original) === c)), d)
340
+ return i.add(d.id), d;
341
+ const y = String(x ? u.id || u.value || c || "object" : u), w = (a.get(y) ?? -1) + 1;
342
+ a.set(y, w);
343
+ const p = `virtual-${y}-${w}`;
344
+ return x ? { id: p, name: Je(u) || String(u.id || "Selected Object"), raw: u.value ?? u.id ?? u, original: u, userId: u.id ?? u.value ?? null, virtual: !0 } : { id: p, name: String(u), raw: u, original: u, userId: u, virtual: !0 };
340
345
  };
341
- return n ? { selected: null, selectedIDs: (Array.isArray(e) ? e : [e]).map(p) } : { selected: p(Array.isArray(e) ? e[0] : e), selectedIDs: qe.selectedIDs };
342
- }, _e = {
346
+ return n ? { selected: null, selectedIDs: (Array.isArray(e) ? e : [e]).map(b) } : { selected: b(Array.isArray(e) ? e[0] : e), selectedIDs: rt.selectedIDs };
347
+ }, ot = {
343
348
  x: ["width", "marginLeft", "marginRight", "paddingLeft", "paddingRight", "borderLeftWidth", "borderRightWidth"],
344
349
  y: ["height", "marginTop", "marginBottom", "paddingTop", "paddingBottom", "borderTopWidth", "borderBottomWidth"]
345
- }, Kt = { x: { minWidth: "0px", maxWidth: "none" }, y: { minHeight: "0px", maxHeight: "none" } }, ut = we(null);
346
- let Ae = null;
347
- const qt = () => Ae ??= (queueMicrotask(() => {
348
- Ae = null;
350
+ }, un = { x: { minWidth: "0px", maxWidth: "none" }, y: { minHeight: "0px", maxHeight: "none" } }, Ct = Ae(null);
351
+ let We = null;
352
+ const fn = () => We ??= (queueMicrotask(() => {
353
+ We = null;
349
354
  }), {});
350
- function ie({
355
+ function de({
351
356
  as: e = "div",
352
357
  axis: t = "y",
353
358
  fade: n = !1,
354
359
  in: r,
355
360
  unmountOnExit: s = !0,
356
- easing: c,
361
+ easing: o,
357
362
  duration: i,
358
363
  group: a,
359
- nodeRef: o,
360
- onEntered: p,
361
- onExited: l,
362
- ...g
364
+ nodeRef: l,
365
+ onEntered: b,
366
+ onExited: u,
367
+ ...x
363
368
  }) {
364
- const y = B(Y), h = B(ut), S = r === void 0 && !!h, w = S ? h.present : !!r, f = i ?? y?.duration ?? 300, m = c ?? y?.easing ?? "ease", D = F(null), L = o ?? D, C = F(null), j = F(!1), M = F({ restart: () => {
365
- } }), [u] = U(() => S && h.appear ? !w : w), x = F(u), [E, $] = U(!w);
366
- w && E && $(!1);
367
- const k = ot(() => {
368
- if (a?.delete(M.current), w) {
369
- C.current = null, p?.();
369
+ const d = V(ne), c = V(Ct), y = r === void 0 && !!c, w = y ? c.present : !!r, p = i ?? (d?.duration ?? 300) / (y && c.swap ? 2 : 1), f = o ?? d?.easing ?? "ease", v = G(null), A = l ?? v, T = G(null), H = G(!1), C = G({ restart: () => {
370
+ } }), [g] = Q(() => y && c.appear ? !w : w), k = G(g), [D, R] = Q(!w);
371
+ w && D && R(!1);
372
+ const I = yt(() => {
373
+ if (a?.delete(C.current), w) {
374
+ T.current?.cancel(), T.current = null, b?.();
370
375
  return;
371
376
  }
372
- l?.(), S && h.onExited(), s && (C.current = null, $(!0));
377
+ u?.(), y && c.onExited(), s && (T.current = null, R(!0));
373
378
  });
374
- return ne(() => {
375
- const I = L.current;
376
- if (!I) return;
377
- const A = n ? [..._e[t], "opacity"] : _e[t], b = { overflow: "hidden", textOverflow: "clip", ...Kt[t] }, d = { ...Object.fromEntries(A.map((P) => [P, P === "opacity" ? 0 : "0px"])), ...b }, v = () => {
378
- const P = getComputedStyle(I);
379
- return { ...Object.fromEntries(A.map((G) => [G, P[G]])), ...b };
380
- }, T = (P, G) => {
381
- const ee = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches, z = C.current = I.animate([P, G], { duration: ee ? 0 : f, easing: m, fill: x.current ? "backwards" : "both" });
379
+ return X(() => {
380
+ const m = A.current;
381
+ if (!m) return;
382
+ const L = n ? [...ot[t], "opacity"] : ot[t], S = { overflow: "hidden", textOverflow: "clip", ...un[t] }, F = { ...Object.fromEntries(L.map((N) => [N, N === "opacity" ? 0 : "0px"])), ...S }, h = () => {
383
+ const { overflow: N } = m.style;
384
+ m.style.overflow = "hidden";
385
+ const P = getComputedStyle(m), _ = { ...Object.fromEntries(L.map((z) => [z, P[z]])), ...S };
386
+ return m.style.overflow = N, _;
387
+ }, O = (N, P) => {
388
+ const _ = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches, z = T.current = m.animate([N, P], { duration: _ ? 0 : p, easing: f, fill: k.current ? "backwards" : "both" });
382
389
  if (z.onfinish = () => {
383
- C.current === z && j.current && k();
384
- }, M.current.frames = [P, G], !a) return;
385
- const R = z.timeline?.currentTime;
386
- R != null && (z.startTime = R, z.currentTime = 0), M.current.batch = qt(), a.add(M.current);
387
- }, H = () => {
388
- const [P, G] = M.current.frames, ee = C.current.effect.getComputedTiming().progress ?? 0, z = (R) => parseFloat(P[R]) + (parseFloat(G[R]) - parseFloat(P[R])) * ee;
389
- return { ...Object.fromEntries(A.map((R) => [R, R === "opacity" ? z(R) : `${z(R)}px`])), ...b };
390
+ T.current === z && H.current && I();
391
+ }, C.current.frames = [N, P], !a) return;
392
+ const W = z.timeline?.currentTime;
393
+ W != null && (z.startTime = W, z.currentTime = 0), C.current.batch = fn(), a.add(C.current);
394
+ }, E = () => {
395
+ const [N, P] = C.current.frames, _ = T.current.effect.getComputedTiming().progress ?? 0, z = (W) => parseFloat(N[W]) + (parseFloat(P[W]) - parseFloat(N[W])) * _;
396
+ return { ...Object.fromEntries(L.map((W) => [W, W === "opacity" ? z(W) : `${z(W)}px`])), ...S };
390
397
  };
391
- if (M.current.restart = (P) => {
392
- const G = C.current;
393
- if (G?.playState !== "running" || !P && M.current.batch === Ae) return;
394
- const ee = H();
395
- G.cancel(), T(ee, x.current ? v() : d);
396
- }, x.current === w) {
397
- !w && !C.current && I.animate && (C.current = I.animate([d, d], { fill: "forwards" }));
398
+ if (C.current.restart = (N) => {
399
+ const P = T.current;
400
+ if (P?.playState !== "running" || !N && C.current.batch === We) return;
401
+ const _ = E();
402
+ P.cancel(), O(_, k.current ? h() : F);
403
+ }, k.current === w) {
404
+ !w && !T.current && m.animate && (T.current = m.animate([F, F], { fill: "forwards" }));
398
405
  return;
399
406
  }
400
- x.current = w;
401
- const J = C.current;
402
- if (J?.playState === "running") {
407
+ k.current = w;
408
+ const $ = T.current;
409
+ if ($?.playState === "running") {
403
410
  if (!a) {
404
- J.reverse();
411
+ $.reverse();
405
412
  return;
406
413
  }
407
- M.current.restart(!0);
414
+ C.current.restart(!0);
408
415
  } else {
409
- if (J?.cancel(), !I.animate) {
410
- k();
416
+ if ($?.cancel(), !m.animate) {
417
+ I();
411
418
  return;
412
419
  }
413
- w ? T(d, v()) : T(v(), d);
420
+ w ? O(F, h()) : O(h(), F);
414
421
  }
415
- a?.forEach((P) => P !== M.current && P.restart());
416
- }, [w, t, n, f, m, L, a]), ne(() => {
417
- const I = M.current;
418
- return j.current = !0, C.current?.playState === "running" && a?.add(I), () => {
419
- j.current = !1, a?.delete(I);
422
+ a?.forEach((N) => N !== C.current && N.restart());
423
+ }, [w, t, n, p, f, A, a]), X(() => {
424
+ const m = C.current;
425
+ return H.current = !0, T.current?.playState === "running" && a?.add(m), () => {
426
+ H.current = !1, a?.delete(m);
420
427
  };
421
- }, [a]), E && s ? null : /* @__PURE__ */ O(e, { ref: L, ...g });
428
+ }, [a]), D && s ? null : /* @__PURE__ */ M(e, { ref: A, ...x });
422
429
  }
423
- const _t = ({ id: e, present: t, appear: n, onExited: r, children: s }) => {
424
- const c = _(() => ({ present: t, appear: n, onExited: () => r(e) }), [e, t, n, r]);
425
- return /* @__PURE__ */ O(ut.Provider, { value: c, children: s });
426
- }, Ue = (e, t, n = !0) => {
427
- const r = it.toArray(t).filter(xe), s = new Set(r.map((o) => o.key)), c = new Map(e.map((o) => [o.key, o])), i = r.map((o) => ({ key: o.key, el: o, present: !0, appear: c.get(o.key)?.appear ?? n }));
428
- let a = 0;
429
- return e.forEach((o) => {
430
- s.has(o.key) ? o.present && (a = i.findIndex((p) => p.key === o.key) + 1) : i.splice(a++, 0, o.present ? { ...o, present: !1 } : o);
431
- }), { children: t, list: i };
432
- };
433
- function $e({ children: e, hold: t = !1 }) {
434
- const [n, r] = U(() => ({ ...Ue([], e, !1), hold: t }));
435
- let s = n;
436
- s.children !== e && (s = { ...s, ...Ue(s.list, e) }), s.hold !== t && (s = { ...s, hold: t, list: t ? s.list : s.list.filter((i) => i.present) }), s !== n && r(s);
437
- const c = K((i) => r(
438
- (a) => !a.hold && a.list.some((o) => o.key === i && !o.present) ? { ...a, list: a.list.filter((o) => o.key !== i) } : a
430
+ const pn = ({ id: e, present: t, appear: n, swap: r, onExited: s, children: o }) => {
431
+ const i = Z(() => ({ present: t, appear: n, swap: r, onExited: () => s(e) }), [e, t, n, r, s]);
432
+ return /* @__PURE__ */ M(Ct.Provider, { value: i, children: o });
433
+ }, it = (e, t, n, r = !0) => {
434
+ const s = vt.toArray(t).filter(Ne), o = new Set(s.map((d) => d.key)), i = new Map(e.map((d) => [d.key, d])), a = s.map((d) => ({ key: d.key, el: d, present: !0, appear: i.get(d.key)?.appear ?? r }));
435
+ let l = 0;
436
+ const b = /* @__PURE__ */ new Set();
437
+ e.forEach((d) => {
438
+ if (o.has(d.key))
439
+ d.present && (l = a.findIndex((c) => c.key === d.key) + 1);
440
+ else if (!d.pending) {
441
+ const c = d.present ? { ...d, present: !1, swap: !1 } : d;
442
+ d.present && b.add(c), a.splice(l++, 0, c);
443
+ }
444
+ });
445
+ const u = (d) => d.present && (i.get(d.key)?.pending ?? !i.has(d.key)), x = n && (b.size > 0 || e.some((d) => d.pending)) && a.some((d) => !d.present) && a.some(u);
446
+ return { children: t, list: x ? a.map((d) => b.has(d) ? { ...d, swap: !0 } : u(d) ? { ...d, pending: !0, swap: !0 } : d) : a };
447
+ }, at = (e) => e.some((t) => !t.present) ? e : e.map((t) => t.pending ? { ...t, pending: !1 } : t);
448
+ function qe({ children: e, hold: t = !1, wait: n = !1 }) {
449
+ const [r, s] = Q(() => ({ ...it([], e, n, !1), hold: t }));
450
+ let o = r;
451
+ o.children !== e && (o = { ...o, ...it(o.list, e, n) }), o.hold !== t && (o = { ...o, hold: t, list: t ? o.list : at(o.list.filter((a) => a.present)) }), o !== r && s(o);
452
+ const i = Y((a) => s(
453
+ (l) => !l.hold && l.list.some((b) => b.key === a && !b.present) ? { ...l, list: at(l.list.filter((b) => b.key !== a)) } : l
439
454
  ), []);
440
- return n.list.map(
441
- ({ key: i, el: a, present: o, appear: p }) => /* @__PURE__ */ O(_t, { id: i, present: o, appear: p, onExited: c, children: a }, i)
455
+ return r.list.map(
456
+ ({ key: a, el: l, present: b, appear: u, pending: x, swap: d = !1 }) => !x && /* @__PURE__ */ M(pn, { id: a, present: b, appear: u, swap: d, onExited: i, children: l }, a)
442
457
  );
443
458
  }
444
- const ft = "rac-chip-slot", Le = "rac-flip", Ge = [], Ut = 0.25, Yt = { hoverId: null, swipedId: null, held: !1, breaks: Ge }, De = () => window.matchMedia?.("(prefers-reduced-motion: reduce)").matches, ve = (e) => Array.from(e.children).filter((t) => t.classList.contains(ft)), Ye = (e) => Array.from(e.children).some((t) => t.getAnimations?.().some((n) => n.constructor === Animation && n.id !== Le && n.playState === "running")), Jt = (e, t) => e.length === t.length && e.every((n, r) => n === t[r]), Xt = (e) => {
459
+ const Tt = "rac-chip-slot", $e = "rac-flip", Ze = "rac-resize", Qe = [], ct = { overflow: "hidden", textOverflow: "clip", boxSizing: "border-box", minWidth: "0px", maxWidth: "none", minHeight: "0px", maxHeight: "none" }, It = "(prefers-reduced-motion: reduce)", xe = () => !!window.matchMedia?.(It).matches, gn = (e) => {
460
+ const t = window.matchMedia?.(It);
461
+ return t?.addEventListener("change", e), () => t?.removeEventListener("change", e);
462
+ }, Ee = (e) => Array.from(e.children).filter((t) => t.classList.contains(Tt)), je = (e) => e.firstElementChild?.firstElementChild, Mt = (e, t) => !!e?.getAnimations?.().some((n) => n.constructor === Animation && t(n)), $t = (e, t) => Mt(e, (n) => n.playState === "running" && t(n)), At = (e) => Ee(e).some((t) => $t(je(t), (n) => n.id === Ze)), Re = (e) => Array.from(e.children).some((t) => $t(t, (n) => n.id !== $e)) || At(e), hn = (e, t) => e.length === t.length && e.every((n, r) => n === t[r]), mn = (e) => {
445
463
  const t = [];
446
464
  let n = -1 / 0;
447
465
  for (const r of e) {
@@ -449,138 +467,186 @@ const ft = "rac-chip-slot", Le = "rac-flip", Ge = [], Ut = 0.25, Yt = { hoverId:
449
467
  s.top >= n - 1 && (t.push([]), n = s.bottom), t.at(-1).push(r), n = Math.max(n, s.bottom);
450
468
  }
451
469
  return t;
452
- }, gt = (e, t, n, r) => {
453
- const s = e.cloneNode(!0), { height: c, paddingInlineEnd: i } = getComputedStyle(e);
454
- s.style.cssText = `visibility: hidden; pointer-events: none; height: ${c}; min-height: 0; padding-inline-end: calc(${i} + ${n}px)`, s.querySelectorAll(`:scope > :not(.${ft})`).forEach((l) => l.remove()), r && ve(s).forEach((l) => r.has(l.dataset.id) || l.remove()), n && s.querySelectorAll(".rac-chip-del").forEach((l) => l.remove());
455
- const a = ve(s), o = new Map(a.map((l, g) => [l.dataset.id, g]));
456
- t?.slice(1).forEach((l, g) => {
457
- const y = Math.min(...l.map((S) => o.get(S) ?? 1 / 0)), h = Math.max(...t[g].map((S) => o.get(S) ?? -1).filter((S) => S < y));
458
- h >= 0 && a[h].after(Object.assign(document.createElement("div"), { className: "rac-spacer" }));
459
- }), e.style.position = "absolute", e.after(s), s.getAnimations?.({ subtree: !0 }).forEach((l) => l.effect?.getComputedTiming().endTime < 1 / 0 && l.finish());
460
- const p = Xt(a).map((l) => l.map((g) => g.dataset.id));
461
- return s.remove(), e.style.position = "", p;
462
- }, pt = (e, t) => {
463
- const n = t ? t.slice(0, -1).map((s) => s.at(-1)) : Ge, { breaks: r } = e.get();
464
- return Jt(r, n) ? r : n;
465
- }, Je = (e, t, n, r) => pt(e, r && n.length ? gt(t, null, r, new Set(n.map((s) => s.id))) : null), Xe = (e, t, n) => {
466
- n.rows = gt(t, n.rows, n.reserve), e.set({ held: !0, breaks: pt(e, n.rows) });
467
- }, Ze = (e, t, n, r) => {
470
+ }, Nt = (e, t, n, r, s) => {
471
+ const o = e.cloneNode(!0), { height: i, paddingInlineEnd: a } = getComputedStyle(e), l = s ? "" : `height: ${i}; min-height: 0;`;
472
+ o.style.cssText = `visibility: hidden; pointer-events: none; ${l} padding-inline-end: calc(${a} + ${n}px)`, o.querySelectorAll(`:scope > :not(.${Tt})`).forEach((c) => c.remove()), r && Ee(o).forEach((c) => r.has(c.dataset.id) || c.remove()), n && o.querySelectorAll(".rac-chip-del").forEach((c) => c.remove());
473
+ const b = Ee(o);
474
+ b.forEach((c) => s?.has(c.dataset.id) && Object.assign(je(c)?.style ?? {}, { minWidth: s.get(c.dataset.id), boxSizing: "border-box" }));
475
+ const u = new Map(b.map((c, y) => [c.dataset.id, y]));
476
+ t?.slice(1).forEach((c, y) => {
477
+ const w = Math.min(...c.map((f) => u.get(f) ?? 1 / 0)), p = Math.max(...t[y].map((f) => u.get(f) ?? -1).filter((f) => f < w));
478
+ p >= 0 && b[p].after(Object.assign(document.createElement("div"), { className: "rac-spacer" }));
479
+ }), e.style.position = "absolute", e.after(o), o.getAnimations?.({ subtree: !0 }).forEach((c) => c.effect?.getComputedTiming().endTime < 1 / 0 && c.finish());
480
+ const x = mn(b).map((c) => c.map((y) => y.dataset.id)), d = o.offsetHeight;
481
+ return o.remove(), e.style.position = "", { rows: x, fit: d };
482
+ }, Dt = (e, t) => {
483
+ const n = t ? t.slice(0, -1).map((s) => s.at(-1)) : Qe, { breaks: r } = e.get();
484
+ return hn(r, n) ? r : n;
485
+ }, lt = (e, t, n, r) => Dt(e, r && n.length ? Nt(t, null, r, new Set(n.map((s) => s.id))).rows : null), ke = (e, t, n) => {
486
+ const { rows: r, fit: s } = Nt(t, n.rows, n.reserve, null, n.floor);
487
+ Object.assign(n, { rows: r, fit: n.floor ? s : null }), e.set({ held: !0, breaks: Dt(e, r) });
488
+ }, bn = (e, t) => new Map(Ee(e).map((n) => {
489
+ const { left: r, top: s } = n.getBoundingClientRect(), o = t && je(n);
490
+ return [n, { left: r, top: s, label: o ? Lt(o) : null }];
491
+ })), dt = (e, t, n, r) => {
468
492
  if (!e.animate) return;
469
- e.getAnimations().forEach((a) => a.id === Le && a.cancel());
470
- const s = e.getBoundingClientRect(), c = t.left - s.left, i = t.top - s.top;
471
- (Math.abs(c) > 0.5 || Math.abs(i) > 0.5) && e.animate([{ transform: `translate(${c}px, ${i}px)` }, { transform: "none" }], { id: Le, duration: n, easing: r });
472
- }, Zt = (e, t, n, r, s) => {
493
+ e.getAnimations().forEach((a) => a.id === $e && a.cancel());
494
+ const s = e.getBoundingClientRect(), o = t.left - s.left, i = t.top - s.top;
495
+ (Math.abs(o) > 0.5 || Math.abs(i) > 0.5) && e.animate([{ transform: `translate(${o}px, ${i}px)` }, { transform: "none" }], { id: $e, duration: n, easing: r });
496
+ }, Lt = (e) => {
497
+ const t = getComputedStyle(e), n = (...r) => `${r.reduce((s, o) => s + parseFloat(t[o]), 0)}px`;
498
+ return t.boxSizing === "border-box" ? { width: t.width, height: t.height } : {
499
+ width: n("width", "paddingLeft", "paddingRight", "borderLeftWidth", "borderRightWidth"),
500
+ height: n("height", "paddingTop", "paddingBottom", "borderTopWidth", "borderBottomWidth")
501
+ };
502
+ }, yn = (e) => {
503
+ const t = [];
504
+ e.forEach(({ label: r }, s) => {
505
+ const o = r && s.isConnected && je(s);
506
+ !o?.animate || Mt(s, (i) => i.id !== $e) || (o.getAnimations().forEach((i) => i.id === Ze && i.cancel()), t.push({ id: s.dataset.id, el: o, from: r }));
507
+ });
508
+ const n = (r, s) => Math.abs(parseFloat(r) - parseFloat(s)) > 0.5;
509
+ return t.map((r) => ({ ...r, to: Lt(r.el) })).filter(({ from: r, to: s }) => n(r.width, s.width) || n(r.height, s.height));
510
+ }, vn = (e, t, n, r) => e.forEach(({ el: s, from: o, to: i }) => {
511
+ s.animate([{ ...ct, ...o }, { ...ct, ...i }], { id: Ze, duration: t, easing: n }).onfinish = r;
512
+ }), Be = (e, t, n, r, s, o) => {
473
513
  if (!e || n === t.value) return;
474
- const c = getComputedStyle(e), i = t.anim ? c.height : t.root;
475
- t.anim?.cancel(), t.root = c.height;
476
- const a = !t.value || i === t.root || !e.animate || De();
477
- if (t.value = n, t.anim = null, a) return;
478
- const o = { overflow: "hidden", alignItems: "flex-start" }, p = t.anim = e.animate([{ ...o, height: i }, { ...o, height: t.root }], { duration: r, easing: s });
479
- p.onfinish = () => {
480
- t.anim === p && (t.anim = null);
514
+ const i = getComputedStyle(e), a = t.anim ? i.height : t.root;
515
+ t.anim?.cancel(), o && Object.assign(o.style, { height: `${n}px`, boxSizing: "border-box" }), t.root = i.height, o && Object.assign(o.style, { height: "", boxSizing: "" });
516
+ const l = !t.value || a === t.root || !e.animate || xe();
517
+ if (t.value = n, t.anim = null, l) return;
518
+ const b = { overflow: "hidden", alignItems: "flex-start" }, u = t.anim = e.animate([{ ...b, height: a }, { ...b, height: t.root }], { duration: r, easing: s });
519
+ u.onfinish = () => {
520
+ t.anim === u && (t.anim = null);
481
521
  };
482
- };
483
- function Qt(e) {
484
- const { selectRef: t, duration: n, easing: r, multiple: s, deleteInline: c, deleteAlways: i, icons: a } = B(Y), { selectedIDs: o, deleting: p, visibility: l, active: g } = B(de), { setDeleting: y, setVisibility: h } = B(ce), [S, w] = U(0), [f] = U(() => Me(Yt)), [m] = U(() => /* @__PURE__ */ new Set()), D = re(f.subscribe, () => f.get().held, () => !1), L = re(f.subscribe, () => f.get().breaks, () => Ge), C = F({ rows: null, reserve: 0, chips: e }), j = F(null), M = F({ value: 0, root: "", anim: null }), u = F(null), x = F(null), E = c && !i && !p && !!a.remove, $ = E ? S + Ut : 0, k = s && E && !S, V = ot((b) => {
485
- const d = u.current, v = C.current;
486
- d && (b && f.get().held && Xe(f, d, v), Zt(t.current, M.current, d.offsetHeight, n, r), f.get().held || f.set({ breaks: Je(f, d, v.chips, v.reserve) }));
522
+ }, wn = 0.25, xn = { hoverId: null, swipedId: null, held: !1, breaks: Qe };
523
+ function On(e) {
524
+ const { selectRef: t, duration: n, easing: r, multiple: s, deleteInline: o, deleteAlways: i, icons: a, valueAsOption: l, renderOption: b } = V(ne), { selectedIDs: u, deleting: x, visibility: d, active: c } = V(fe), { setDeleting: y, setVisibility: w } = V(ue), [p, f] = Q(0), [v] = Q(() => xt(xn)), [A] = Q(() => /* @__PURE__ */ new Set()), T = ce(v.subscribe, () => v.get().held, () => !1), H = ce(v.subscribe, () => v.get().breaks, () => Qe), C = ce(gn, xe, () => !1), g = G({ rows: null, reserve: 0, chips: e, swap: !1, duration: n, easing: r }), k = G(null), D = G({ value: 0, root: "", anim: null }), R = G(null), I = G(null), B = o && !i && !x && !!a.remove, m = B ? p + wn : 0, L = s && B && !p && e.length > 0, S = l ? b ? 2 : 1 : 0, F = yt((E, $) => {
525
+ const N = R.current, P = g.current;
526
+ if (!N) return;
527
+ const _ = At(N);
528
+ if (_ && $) return;
529
+ E && v.get().held && ke(v, N, P);
530
+ const z = P.swap ? P.duration / 2 : P.duration;
531
+ _ ? P.fit != null && Be(t.current, D.current, P.fit, z, P.easing, N) : ($ || D.current.value) && Be(t.current, D.current, N.offsetHeight, z, P.easing), v.get().held || v.set({ breaks: lt(v, N, P.chips, P.reserve) });
487
532
  });
488
- ne(() => {
489
- const b = C.current, d = u.current, v = b.chips !== e;
490
- Object.assign(b, { chips: e, reserve: $ }), v && d && Ye(d) && Xe(f, d, b), V(!v);
491
- }, [e, $, f]), ne(() => {
492
- const b = () => V(!0), d = typeof ResizeObserver > "u" ? null : new ResizeObserver(b);
493
- return d?.observe(u.current), document.fonts?.addEventListener("loadingdone", b), () => {
494
- d?.disconnect(), document.fonts?.removeEventListener("loadingdone", b);
533
+ X(() => {
534
+ Object.assign(g.current, { duration: n, easing: r });
535
+ }, [n, r]), X(() => {
536
+ const E = g.current, $ = R.current, N = E.chips !== e;
537
+ Object.assign(E, { chips: e, reserve: m }), N && $ && Re($) && ke(v, $, E), F(!N);
538
+ }, [e, m, v]), X(() => {
539
+ const E = () => F(!0, !0), $ = typeof ResizeObserver > "u" ? null : new ResizeObserver(E);
540
+ return $ ? $.observe(R.current) : E(), document.fonts?.addEventListener("loadingdone", E), () => {
541
+ $?.disconnect(), document.fonts?.removeEventListener("loadingdone", E);
495
542
  };
496
543
  }, []);
497
- const I = K(() => {
498
- const b = u.current;
499
- if (!b || !f.get().held || Ye(b)) return;
500
- const d = ve(b), v = d.map((H) => H.getBoundingClientRect()), T = Je(f, b, C.current.chips, C.current.reserve);
501
- C.current.rows = null, St(() => f.set({ held: !1, breaks: T })), De() || d.forEach((H, J) => H.isConnected && Ze(H, v[J], n, r));
502
- }, [f, n, r]), A = K(() => {
503
- u.current && (j.current = new Map(ve(u.current).map((b) => [b, b.getBoundingClientRect()])));
544
+ const h = Y(() => {
545
+ const E = R.current;
546
+ if (!E || !v.get().held || Re(E)) return;
547
+ const $ = g.current, N = Ee(E), P = N.map((z) => z.getBoundingClientRect()), _ = lt(v, E, $.chips, $.reserve);
548
+ Object.assign($, { rows: null, floor: null, fit: null }), et(() => v.set({ held: !1, breaks: _ })), $.swap = Re(E), $.swap && et(() => ke(v, E, $)), xe() || N.forEach((z, W) => z.isConnected && dt(z, P[W], $.swap ? n / 2 : n, r));
549
+ }, [v, n, r]), O = Y((E) => {
550
+ R.current && (k.current = bn(R.current, E));
504
551
  }, []);
505
- return ne(() => {
506
- const b = j.current;
507
- !b || L !== f.get().breaks || (j.current = null, De() || b.forEach((d, v) => v.isConnected && Ze(v, d, n, r)));
508
- }, [L, e, f, n, r]), oe(() => () => M.current.anim?.cancel(), []), oe(() => {
509
- p && l && h(!1), p && (!o.length || !g) && y(!1), f.set({ hoverId: null, ...!g && { swipedId: null } });
510
- }, [o.length, p, l, g, y, h, f]), ne(() => {
511
- const b = x.current;
512
- if (!k || !b) return;
513
- const d = getComputedStyle(b);
514
- w(b.getBoundingClientRect().width + parseFloat(d.marginLeft) + parseFloat(d.marginRight));
515
- }, [k]), { chipStore: f, delGroup: m, valueRef: u, delIconRef: x, probe: k, settle: I, held: D, snapshot: A };
552
+ return X(() => {
553
+ const E = R.current, $ = g.current;
554
+ if (!E || !k.current || !n || xe()) return;
555
+ const N = yn(k.current);
556
+ N.length && ($.floor = new Map(N.map(({ id: P, from: _ }) => [P, _.width])), ke(v, E, $), Be(t.current, D.current, $.fit, n, r, E), vn(N, n, r, () => {
557
+ h(), F(!1, !0);
558
+ }));
559
+ }, [S, v, n, r, t, h]), X(() => {
560
+ const E = k.current;
561
+ !E || H !== v.get().breaks || (k.current = null, xe() || E.forEach(($, N) => N.isConnected && dt(N, $, n, r)));
562
+ }, [H, e, S, v, n, r]), J(() => () => D.current.anim?.cancel(), []), J(() => {
563
+ x && d && w(!1), x && (!u.length || !c) && y(!1), v.set({ hoverId: null, ...!c && { swipedId: null } });
564
+ }, [u.length, x, d, c, y, w, v]), X(() => {
565
+ const E = I.current;
566
+ if (!L || !E) return;
567
+ const $ = getComputedStyle(E);
568
+ f(E.getBoundingClientRect().width + parseFloat($.marginLeft) + parseFloat($.marginRight));
569
+ }, [L]), { chipStore: v, delGroup: A, valueRef: R, delIconRef: I, probe: L, settle: h, held: T, snapshot: O, look: S, wait: n > 0 && !C };
516
570
  }
517
- const Qe = 1, et = 2, en = 600, tn = 10, tt = 30, nn = se(function({ element: t, deleting: n, locked: r, chipStore: s, delGroup: c }) {
518
- const { selectRef: i, deleteInline: a, deleteAlways: o, icons: p, texts: l, valueAsOption: g, renderOption: y } = B(Y), h = !!p.remove, { setVisibility: S, setDeleting: w, removeOption: f } = B(ce), m = F({ longPressTimer: null, longPress: !1, x: 0, y: 0 }), D = re(s.subscribe, () => {
519
- const { hoverId: b, swipedId: d } = s.get();
520
- return (b === t.id ? Qe : 0) | (d === t.id ? et : 0);
521
- }, () => 0), L = !!(D & Qe), C = !!(D & et), j = K((b) => {
522
- const { clientX: d, clientY: v } = b.touches[0];
523
- Object.assign(m.current, { x: d, y: v, longPress: !1 }), clearTimeout(m.current.longPressTimer), h && (m.current.longPressTimer = setTimeout(() => {
524
- w(!0), m.current.longPress = !0, i.current?.focus(), S(!1), window.navigator.vibrate?.(50);
525
- }, en));
526
- }, [h, w, S, i]), M = K((b) => {
527
- const { clientX: d, clientY: v } = b.touches[0], T = m.current.x - d;
528
- Math.hypot(T, m.current.y - v) > tn && clearTimeout(m.current.longPressTimer), T > tt && !C ? s.set({ hoverId: null, swipedId: t.id }) : T < -tt && C && s.set({ swipedId: null });
529
- }, [t.id, C, s]), u = K(() => clearTimeout(m.current.longPressTimer), []), x = K(() => s.set({ hoverId: t.id, swipedId: null }), [t.id, s]), E = K(() => {
571
+ const ut = 1, ft = 2, En = 600, Sn = 10, pt = 30, kn = ie(function({ element: t, deleting: n, locked: r, chipStore: s, delGroup: o }) {
572
+ const { selectRef: i, deleteInline: a, deleteAlways: l, icons: b, texts: u, valueAsOption: x, renderOption: d } = V(ne), c = !!b.remove, { setVisibility: y, setDeleting: w, removeOption: p } = V(ue), f = G({ longPressTimer: null, longPress: !1, x: 0, y: 0 }), v = ce(s.subscribe, () => {
573
+ const { hoverId: S, swipedId: F } = s.get();
574
+ return (S === t.id ? ut : 0) | (F === t.id ? ft : 0);
575
+ }, () => 0), A = !!(v & ut), T = !!(v & ft), H = Y((S) => {
576
+ const { clientX: F, clientY: h } = S.touches[0];
577
+ Object.assign(f.current, { x: F, y: h, longPress: !1 }), clearTimeout(f.current.longPressTimer), c && (f.current.longPressTimer = setTimeout(() => {
578
+ w(!0), f.current.longPress = !0, i.current?.focus(), y(!1), window.navigator.vibrate?.(50);
579
+ }, En));
580
+ }, [c, w, y, i]), C = Y((S) => {
581
+ const { clientX: F, clientY: h } = S.touches[0], O = f.current.x - F;
582
+ Math.hypot(O, f.current.y - h) > Sn && clearTimeout(f.current.longPressTimer), O > pt && !T ? s.set({ hoverId: null, swipedId: t.id }) : O < -pt && T && s.set({ swipedId: null });
583
+ }, [t.id, T, s]), g = Y((S) => {
584
+ clearTimeout(f.current.longPressTimer), f.current.longPress && S.cancelable && S.preventDefault(), f.current.longPress = !1;
585
+ }, []), k = Y(() => s.set({ hoverId: t.id, swipedId: null }), [t.id, s]), D = Y(() => {
530
586
  s.get().hoverId === t.id && s.set({ hoverId: null });
531
587
  }, [t.id, s]);
532
- oe(() => () => clearTimeout(m.current.longPressTimer), []);
533
- const $ = g ? Ve(t, y, !0) : null, k = $ ? /* @__PURE__ */ O("div", { className: "rac-option-jsx", children: $ }) : /* @__PURE__ */ O("span", { className: "rac-chip-text", children: t.name || l.emptyOption }), V = K((b) => {
534
- s.set({ swipedId: null }), f(t.id), Q(b);
535
- }, [t.id, f, s]), I = K((b) => {
536
- Q(b), m.current.longPress ? m.current.longPress = !1 : n && V(b);
537
- }, [n, V]), A = h && (o || !r && (L || C || n));
538
- return /* @__PURE__ */ q(
588
+ J(() => () => clearTimeout(f.current.longPressTimer), []);
589
+ const R = x ? Ue(t, d, !0) : null, I = R ? /* @__PURE__ */ M("div", { className: "rac-option-jsx", children: R }) : /* @__PURE__ */ M("span", { className: "rac-chip-text", children: t.name || u.emptyOption }), B = Y((S) => {
590
+ s.set({ swipedId: null }), Et(S, i), p(t.id), oe(S);
591
+ }, [t.id, p, s, i]), m = Y((S) => {
592
+ oe(S), n && B(S);
593
+ }, [n, B]), L = c && (l || !r && (A || T || n));
594
+ return /* @__PURE__ */ ee(
539
595
  "div",
540
596
  {
541
- className: ue("rac-chip", $ && t.className),
542
- style: $ ? t.style : void 0,
543
- ...!r && { onTouchStart: j, onTouchMove: M, onTouchEnd: u, onTouchCancel: u, onMouseEnter: x, onMouseLeave: E, onClick: I },
597
+ className: me("rac-chip", R && t.className),
598
+ style: R ? t.style : void 0,
599
+ ...!r && { onTouchStart: H, onTouchMove: C, onTouchEnd: g, onTouchCancel: g, onMouseEnter: k, onMouseLeave: D, onClick: m },
544
600
  children: [
545
- k,
546
- /* @__PURE__ */ O(
547
- ie,
601
+ I,
602
+ /* @__PURE__ */ M(
603
+ de,
548
604
  {
549
- "aria-label": `${l.remove} ${t.name ?? ""}`.trim(),
550
- group: a && !o && !n ? c : void 0,
551
- onMouseDown: Q,
552
- onClick: V,
605
+ "aria-label": `${u.remove} ${t.name ?? ""}`.trim(),
606
+ group: a && !l && !n ? o : void 0,
607
+ onMouseDown: oe,
608
+ onClick: B,
553
609
  className: "rac-chip-del",
554
610
  disabled: r,
555
611
  tabIndex: -1,
556
612
  type: "button",
557
- in: A,
613
+ in: L,
558
614
  as: "button",
559
615
  axis: "x",
560
- children: ae(p.remove)
616
+ children: he(b.remove)
561
617
  }
562
618
  )
563
619
  ]
564
620
  }
565
621
  );
566
- }), rn = se(function({ element: t, chipStore: n, settle: r, ...s }) {
567
- const c = re(n.subscribe, () => n.get().breaks.includes(t.id), () => !1);
568
- return /* @__PURE__ */ q(at, { children: [
569
- /* @__PURE__ */ O(ie, { className: "rac-chip-slot", onEntered: r, onExited: r, unmountOnExit: !1, "data-id": t.id, axis: "x", fade: !0, children: /* @__PURE__ */ O(nn, { element: t, chipStore: n, ...s }) }),
570
- c && /* @__PURE__ */ O("div", { className: "rac-spacer" })
622
+ }), Cn = ie(function({ element: t, chipStore: n, settle: r, ...s }) {
623
+ const o = ce(n.subscribe, () => n.get().breaks.includes(t.id), () => !1);
624
+ return /* @__PURE__ */ ee(wt, { children: [
625
+ /* @__PURE__ */ M(de, { className: "rac-chip-slot", onEntered: r, onExited: r, unmountOnExit: !1, "data-id": t.id, axis: "x", fade: !0, children: /* @__PURE__ */ M(kn, { element: t, chipStore: n, ...s }) }),
626
+ o && /* @__PURE__ */ M("div", { className: "rac-spacer" })
571
627
  ] });
572
- }), sn = { position: "absolute", visibility: "hidden", pointerEvents: "none" }, je = [], on = () => {
573
- }, an = (e) => e == null ? "" : typeof e == "object" ? fe(e) ?? "" : String(e), ln = se(function() {
574
- const { selectRef: t, multiple: n, name: r, required: s } = B(Y), { selected: c, selectedIDs: i, disabled: a } = B(de);
575
- if (!r && !s) return null;
576
- const o = (n ? i : c ? [c] : je).map((g) => an(g.original)), p = o.length ? o : n && !s ? je : [""], l = () => t.current?.focus();
577
- return p.map(
578
- (g, y) => /* @__PURE__ */ O("input", { className: "rac-input", name: r, value: g, required: s && !y, disabled: a, tabIndex: -1, "aria-hidden": "true", onChange: on, onFocus: l }, y)
628
+ }), Tn = { position: "absolute", visibility: "hidden", pointerEvents: "none" }, jt = [], In = () => {
629
+ }, Mn = (e) => e == null ? "" : typeof e == "object" ? ye(e) ?? "" : String(e), $n = ie(function() {
630
+ const { selectRef: t, multiple: n, name: r, form: s, required: o } = V(ne), { selected: i, selectedIDs: a, disabled: l, fieldsetDisabled: b } = V(fe), { reset: u, markInvalid: x } = V(ue), d = G(null);
631
+ J(() => {
632
+ const f = d.current?.getRootNode();
633
+ let v;
634
+ const A = (T) => {
635
+ T.target === d.current?.form && (clearTimeout(v), v = setTimeout(() => T.defaultPrevented || u()));
636
+ };
637
+ return f?.addEventListener("reset", A, !0), () => {
638
+ clearTimeout(v), f?.removeEventListener("reset", A, !0);
639
+ };
640
+ }, [u]);
641
+ const c = n ? a : i ? [i] : jt, y = !o && (!r || n && !c.length), w = y || !c.length ? [""] : c.map((f) => Mn(f.original)), p = () => t.current?.focus();
642
+ return w.map(
643
+ (f, v) => /* @__PURE__ */ M("input", { className: "rac-input", ref: v ? void 0 : d, name: y ? void 0 : r, form: s, value: f, hidden: y, required: o && !v, disabled: l && !b, tabIndex: -1, "aria-hidden": "true", autoComplete: "off", onChange: In, onInvalid: x, onFocus: p }, v)
579
644
  );
580
645
  });
581
- class cn extends vt {
646
+ class An extends Pt {
582
647
  getSnapshotBeforeUpdate(t) {
583
- return t.chips !== this.props.chips && this.props.take(), null;
648
+ const n = t.look !== this.props.look;
649
+ return (n || t.chips !== this.props.chips) && this.props.take(n), null;
584
650
  }
585
651
  componentDidUpdate() {
586
652
  }
@@ -588,403 +654,529 @@ class cn extends vt {
588
654
  return null;
589
655
  }
590
656
  }
591
- const nt = (e, t) => {
592
- const n = new Set(e.map((i) => i.id)), r = new Map(t.map(([i, a]) => [a.id, i])), s = t.filter(([, i]) => !n.has(i.id)), c = new Set(t.map(([i]) => i));
657
+ const gt = (e, t) => {
658
+ const n = new Set(e.map((i) => i.id)), r = new Map(t.map(([i, a]) => [a.id, i])), s = t.filter(([, i]) => !n.has(i.id)), o = new Set(t.map(([i]) => i));
593
659
  return e.map((i) => {
594
660
  if (r.has(i.id)) return [r.get(i.id), i];
595
- const a = s.findIndex(([, p]) => Wt(p.original, i.original));
661
+ const a = s.findIndex(([, b]) => dn(b.original, i.original));
596
662
  if (a >= 0) return [s.splice(a, 1)[0][0], i];
597
- let o = i.id;
598
- for (; c.has(o); ) o += "~";
599
- return c.add(o), [o, i];
663
+ let l = i.id;
664
+ for (; o.has(l); ) l += "~";
665
+ return o.add(l), [l, i];
600
666
  });
601
- }, dn = (e) => {
602
- const [t, n] = U(() => ({ chips: e, keyed: nt(e, []) }));
667
+ }, Nn = (e) => {
668
+ const [t, n] = Q(() => ({ chips: e, keyed: gt(e, []) }));
603
669
  if (t.chips === e) return t.keyed;
604
- const r = nt(e, t.keyed);
670
+ const r = gt(e, t.keyed);
605
671
  return n({ chips: e, keyed: r }), r;
606
- }, un = se(function() {
607
- const { selectedText: t, icons: n, valueAsOption: r, renderOption: s } = B(Y), { selectedIDs: c, title: i, valueOption: a, hasActualValue: o, loading: p, error: l, deleting: g, active: y } = B(de), h = c.length > 0 && !t, S = h ? c : je, { chipStore: w, delGroup: f, valueRef: m, delIconRef: D, probe: L, settle: C, held: j, snapshot: M } = Qt(S), u = dn(S), [x] = U(() => /* @__PURE__ */ new Set()), E = r && a ? Ve(a, s, !0) : null, $ = p && !l && !o, k = `${E ? a.id : i}${$ ? "-loading" : ""}`, V = a?.type === "boolean" ? String(a.raw) : void 0;
608
- return /* @__PURE__ */ q("div", { className: "rac-value", ref: m, children: [
609
- /* @__PURE__ */ O(cn, { chips: S, take: M }),
610
- /* @__PURE__ */ O($e, { children: !h && /* @__PURE__ */ q(ie, { axis: "x", fade: !0, group: x, className: ue("rac-title", E && a.className), style: E ? a.style : void 0, "data-bool": V, onEntered: C, onExited: C, children: [
611
- E ? /* @__PURE__ */ O("div", { className: "rac-option-jsx", children: E }) : i,
612
- $ && Be
613
- ] }, k) }),
614
- /* @__PURE__ */ O($e, { hold: j, children: u.map(
615
- ([I, A]) => /* @__PURE__ */ O(
616
- rn,
672
+ }, Dn = ie(function() {
673
+ const { selectedText: t, icons: n, valueAsOption: r, renderOption: s } = V(ne), { selectedIDs: o, title: i, valueOption: a, hasActualValue: l, loading: b, error: u, deleting: x, active: d } = V(fe), c = o.length > 0 && !t, y = c ? o : jt, { chipStore: w, delGroup: p, valueRef: f, delIconRef: v, probe: A, settle: T, held: H, snapshot: C, look: g, wait: k } = On(y), D = Nn(y), [R] = Q(() => /* @__PURE__ */ new Set()), I = r && a ? Ue(a, s, !0) : null, B = b && !u && !l, m = `${I ? a.id : i}${B ? "-loading" : ""}`, L = a?.type === "boolean" ? String(a.raw) : void 0;
674
+ return /* @__PURE__ */ ee("div", { className: "rac-value", ref: f, children: [
675
+ /* @__PURE__ */ M(An, { chips: y, look: g, take: C }),
676
+ /* @__PURE__ */ M(qe, { children: !c && /* @__PURE__ */ ee(de, { axis: "x", fade: !0, group: R, className: me("rac-title", I && a.className), style: I ? a.style : void 0, "data-bool": L, onEntered: T, onExited: T, children: [
677
+ I ? /* @__PURE__ */ M("div", { className: "rac-option-jsx", children: I }) : i,
678
+ B && Ye
679
+ ] }, m) }),
680
+ /* @__PURE__ */ M(qe, { hold: H, wait: k, children: D.map(
681
+ ([S, F]) => /* @__PURE__ */ M(
682
+ Cn,
617
683
  {
618
- element: A,
619
- deleting: g,
620
- locked: !y,
684
+ element: F,
685
+ deleting: x,
686
+ locked: !d,
621
687
  chipStore: w,
622
- delGroup: f,
623
- settle: C
688
+ delGroup: p,
689
+ settle: T
624
690
  },
625
- I
691
+ S
626
692
  )
627
693
  ) }),
628
- L && /* @__PURE__ */ O("button", { type: "button", className: "rac-chip-del", tabIndex: -1, "aria-hidden": "true", ref: D, style: sn, children: ae(n.remove) })
694
+ A && /* @__PURE__ */ M("button", { type: "button", className: "rac-chip-del", tabIndex: -1, "aria-hidden": "true", ref: v, style: Tn, children: he(n.remove) })
629
695
  ] });
630
- }), fn = se(function() {
631
- const { selectRef: t, selectId: n, highlightStore: r, positionStore: s, className: c, style: i, duration: a, easing: o, deleteInline: p, icons: l, texts: g, placeholder: y, id: h, required: S, attrs: w } = B(Y), { visibility: f, active: m, hasActualValue: D, deleting: L, loading: C, loadPending: j, error: M, normalizedOptions: u } = B(de), { handleBlur: x, handleFocus: E, handleKeyDown: $, toggleVisibility: k, clear: V } = B(ce), I = re(s.subscribe, () => s.get().upward, () => !1), A = re(r.subscribe, () => {
632
- const v = f ? u[ye(r.get())] : null;
633
- return v ? Oe(n, v.id) : void 0;
696
+ }), Ln = ie(function() {
697
+ const { selectRef: t, selectId: n, highlightStore: r, className: s, style: o, duration: i, easing: a, deleteInline: l, icons: b, texts: u, placeholder: x, id: d, required: c, popup: y, attrs: w } = V(ne), { visibility: p, active: f, hasActualValue: v, deleting: A, loading: T, loadPending: H, error: C, invalid: g, normalizedOptions: k } = V(fe), { handleBlur: D, handleFocus: R, handleKeyDown: I, toggleVisibility: B, clear: m } = V(ue), L = ce(r.subscribe, () => {
698
+ const O = p ? k[Ie(r.get())] : null;
699
+ return O ? De(n, O.id) : void 0;
634
700
  }, () => {
635
- }), b = !!l.clear && D && m && !L, d = !!l.arrow && m && !L;
636
- return /* @__PURE__ */ q(
701
+ }), S = !!b.clear && v && f && !A, F = !!b.arrow && f && !A && y, h = y ? { role: "combobox", "aria-haspopup": "listbox", "aria-controls": `${n}-listbox`, "aria-expanded": p, "aria-activedescendant": L, "aria-required": c || void 0 } : { role: "group" };
702
+ return /* @__PURE__ */ ee(
637
703
  "div",
638
704
  {
639
705
  ...w,
640
- id: h,
706
+ id: d,
641
707
  ref: t,
642
- style: { "--rac-duration": `${a}ms`, "--rac-ease": o, ...i },
643
- className: ue("rac-select", c),
644
- ...m && {
645
- onKeyDown: $,
646
- onFocus: E,
647
- onClick: k,
648
- onBlur: x
708
+ style: { "--rac-duration": `${i}ms`, "--rac-ease": a, ...o },
709
+ className: me("rac-select", s),
710
+ ...f && {
711
+ onKeyDown: I,
712
+ onFocus: R,
713
+ onClick: B,
714
+ onBlur: D
649
715
  },
650
- "aria-disabled": !m,
651
- "aria-activedescendant": A,
652
- "aria-controls": `${n}-listbox`,
653
- tabIndex: m ? 0 : -1,
654
- "aria-expanded": f,
655
- "aria-busy": C || j || void 0,
656
- "aria-label": w["aria-label"] ?? (w["aria-labelledby"] ? void 0 : y),
657
- "aria-required": S || void 0,
658
- "aria-haspopup": "listbox",
659
- role: "combobox",
660
- "data-placement": I ? "top" : "bottom",
661
- "data-inline-delete": X(p),
662
- "data-empty": X(!D),
663
- "data-deleting": X(L),
664
- "data-error": X(M),
716
+ ...h,
717
+ "aria-disabled": !f,
718
+ tabIndex: f ? 0 : -1,
719
+ "aria-busy": T || H || void 0,
720
+ "aria-label": w["aria-label"] ?? (w["aria-labelledby"] ? void 0 : x),
721
+ "aria-invalid": g || w["aria-invalid"],
722
+ "aria-describedby": [w["aria-describedby"], C && `${n}-error`].filter(Boolean).join(" ") || void 0,
723
+ "data-inline-delete": re(l),
724
+ "data-empty": re(!v),
725
+ "data-deleting": re(A),
726
+ "data-error": re(C),
727
+ "data-invalid": re(g),
665
728
  children: [
666
- /* @__PURE__ */ O(un, {}),
667
- /* @__PURE__ */ q($e, { children: [
668
- b && /* @__PURE__ */ O(ie, { as: "button", type: "button", axis: "x", className: "rac-clear", tabIndex: -1, "aria-label": g.clear, onMouseDown: Q, onClick: V, children: ae(l.clear) }, "clear"),
669
- d && /* @__PURE__ */ O(ie, { axis: "x", className: "rac-arrow", "aria-hidden": "true", children: ae(l.arrow) }, "arrow")
729
+ /* @__PURE__ */ M(Dn, {}),
730
+ /* @__PURE__ */ ee(qe, { children: [
731
+ S && /* @__PURE__ */ M(de, { as: "button", type: "button", axis: "x", className: "rac-clear", tabIndex: -1, "aria-label": u.clear, onMouseDown: oe, onClick: (O) => {
732
+ Et(O, t), m(O);
733
+ }, children: he(b.clear) }, "clear"),
734
+ F && /* @__PURE__ */ M(de, { axis: "x", className: "rac-arrow", "aria-hidden": "true", children: he(b.arrow) }, "arrow")
670
735
  ] }),
671
- /* @__PURE__ */ O(ln, {})
736
+ /* @__PURE__ */ M($n, {})
672
737
  ]
673
738
  }
674
739
  );
675
- }), ke = 0, gn = 1, rt = 2, ht = (e) => {
676
- const { highlightStore: t } = B(Y), n = F(null), r = re(t.subscribe, () => {
740
+ }), Fe = 0, jn = 1, ht = 2, Rt = (e) => {
741
+ const { highlightStore: t } = V(ne), n = G(null), r = ce(t.subscribe, () => {
677
742
  const s = t.get();
678
- return ye(s) !== e ? ke : s.ready ? rt : gn;
679
- }, () => ke);
680
- return ne(() => {
681
- r === rt && n.current?.scrollIntoView?.({ block: "nearest" });
682
- }, [r]), [n, r !== ke];
683
- }, pn = se(function({ option: t, index: n, open: r, hasChildren: s }) {
684
- const { selectId: c, icons: i } = B(Y), { selectOption: a, highlight: o } = B(ce), [p, l] = ht(n), g = s && !t.disabled;
685
- return /* @__PURE__ */ q(
743
+ return Ie(s) !== e ? Fe : s.ready ? ht : jn;
744
+ }, () => Fe);
745
+ return X(() => {
746
+ r === ht && n.current?.scrollIntoView?.({ block: "nearest" });
747
+ }, [r]), [n, r !== Fe];
748
+ }, Bt = (e, t) => `${De(e, t.id)}_l`, Rn = ie(function({ option: t, index: n, open: r, hasChildren: s }) {
749
+ const { selectId: o, icons: i, texts: a } = V(ne), { selectOption: l, highlight: b } = V(ue), [u, x] = Rt(n), d = s && !t.disabled;
750
+ return /* @__PURE__ */ ee(
686
751
  "div",
687
752
  {
688
- className: ue("rac-group", t.className),
689
- onMouseEnter: () => g && o(n),
690
- onClick: (y) => a(t, y),
691
- "data-highlighted": X(l),
692
- "data-disabled": X(t.disabled),
693
- id: Oe(c, t.id),
694
- "data-open": X(r),
753
+ className: me("rac-group", t.className),
754
+ onMouseEnter: () => d && b(n),
755
+ onClick: (c) => l(t, c),
756
+ "aria-label": d ? `${t.name}, ${r ? a.groupOpen : a.groupClosed}` : void 0,
757
+ "aria-disabled": !d || void 0,
758
+ "data-highlighted": re(x),
759
+ "data-disabled": re(t.disabled),
760
+ id: De(o, t.id),
761
+ "data-open": re(r),
762
+ "aria-selected": "false",
695
763
  style: t.style,
696
- ref: p,
764
+ role: "option",
765
+ ref: u,
697
766
  children: [
698
- /* @__PURE__ */ O("span", { className: "rac-group-text", children: t.name }),
699
- /* @__PURE__ */ O(ie, { axis: "x", in: s && !t.disabled, className: "rac-group-arrow", "aria-hidden": "true", children: ae(i.arrow) })
767
+ /* @__PURE__ */ M("span", { className: "rac-group-text", id: Bt(o, t), children: t.name }),
768
+ /* @__PURE__ */ M(de, { axis: "x", in: s && !t.disabled, className: "rac-group-arrow", "aria-hidden": "true", children: he(i.arrow) })
700
769
  ]
701
770
  }
702
771
  );
703
- }), hn = se(function({ option: t, index: n, isSelected: r, showCheckbox: s }) {
704
- const { selectId: c, icons: i, renderOption: a } = B(Y), { selectOption: o, highlight: p } = B(ce), [l, g] = ht(n), y = !t.disabled && !t.loading, h = Ve(t, a, r);
705
- return /* @__PURE__ */ q(
772
+ }), Bn = ie(function({ option: t, index: n, isSelected: r, showCheckbox: s }) {
773
+ const { selectId: o, icons: i, renderOption: a } = V(ne), { selectOption: l, highlight: b } = V(ue), [u, x] = Rt(n), d = !t.disabled && !t.loading, c = Ue(t, a, r);
774
+ return /* @__PURE__ */ ee(
706
775
  "div",
707
776
  {
708
- className: ue("rac-option", t.className),
709
- onMouseEnter: () => y && p(n),
710
- onClick: (S) => !t.loading && o(t, S),
777
+ className: me("rac-option", t.className),
778
+ onMouseEnter: () => d && b(n),
779
+ onClick: (y) => !t.loading && l(t, y),
711
780
  "aria-disabled": t.disabled || t.loading,
712
- "data-invalid": X(t.invalid),
781
+ "data-invalid": re(t.invalid),
713
782
  "data-bool": typeof t.raw == "boolean" ? String(t.raw) : void 0,
714
- "data-highlighted": X(g),
715
- "data-loading": X(t.loading),
716
- id: Oe(c, t.id),
783
+ "data-highlighted": re(x),
784
+ "data-loading": re(t.loading),
785
+ id: De(o, t.id),
717
786
  "aria-selected": r,
718
787
  style: t.style,
719
788
  role: "option",
720
- ref: l,
789
+ ref: u,
721
790
  children: [
722
- h ? /* @__PURE__ */ O("div", { className: "rac-option-jsx", children: h }) : /* @__PURE__ */ O("span", { className: "rac-option-text", children: t.name }),
723
- t.loading && Be,
724
- s && /* @__PURE__ */ q("div", { className: "rac-check", "data-default": X(!i.checkbox), children: [
725
- ae(i.check, { className: "rac-checkmark" }),
726
- ae(i.checkbox, { className: "rac-check-icon" })
791
+ c ? /* @__PURE__ */ M("div", { className: "rac-option-jsx", children: c }) : /* @__PURE__ */ M("span", { className: "rac-option-text", children: t.name }),
792
+ t.loading && Ye,
793
+ s && /* @__PURE__ */ ee("div", { className: "rac-check", "data-default": re(!i.checkbox), children: [
794
+ he(i.check, { className: "rac-checkmark" }),
795
+ he(i.checkbox, { className: "rac-check-icon" })
727
796
  ] })
728
797
  ]
729
798
  }
730
799
  );
731
- }), mn = se(function() {
732
- const { selectId: t, multiple: n } = B(Y), { normalizedOptions: r, selected: s, selectedIDs: c, expandedGroups: i } = B(de), a = s?.id;
733
- return _(() => {
734
- const o = new Set(c.map((f) => f.id)), p = r.reduce((f, m) => (m.group && (f[m.group] = (f[m.group] || 0) + 1), f), {}), l = [];
735
- let g = [], y = null, h = null;
736
- const S = () => {
737
- y !== null && g.length && l.push(
738
- /* @__PURE__ */ O(ie, { axis: "y", in: i.has(y), className: "rac-group-items", role: "group", "aria-labelledby": h, children: g }, `slide-${y}`)
739
- ), g = [];
740
- }, w = (f, m) => /* @__PURE__ */ O(
741
- hn,
800
+ }), Fn = ie(function() {
801
+ const { selectId: t, multiple: n } = V(ne), { normalizedOptions: r, selected: s, selectedIDs: o, expandedGroups: i } = V(fe), a = s?.id;
802
+ return Z(() => {
803
+ const l = new Set(o.map((p) => p.id)), b = r.reduce((p, f) => (f.group && (p[f.group] = (p[f.group] || 0) + 1), p), {}), u = [];
804
+ let x = [], d = null, c = null;
805
+ const y = () => {
806
+ d !== null && x.length && u.push(
807
+ /* @__PURE__ */ M(de, { axis: "y", in: i.has(d), className: "rac-group-items", role: "group", "aria-labelledby": c, children: x }, `slide-${d}`)
808
+ ), x = [];
809
+ }, w = (p, f) => /* @__PURE__ */ M(
810
+ Bn,
742
811
  {
743
- isSelected: o.has(f.id) || a === f.id,
744
- showCheckbox: n && !f.disabled,
745
- option: f,
746
- index: m
812
+ isSelected: l.has(p.id) || a === p.id,
813
+ showCheckbox: n && !p.disabled && "original" in p,
814
+ option: p,
815
+ index: f
747
816
  },
748
- f.id
817
+ p.id
749
818
  );
750
- return r.forEach((f, m) => {
751
- f.groupHeader ? (S(), y = f.name, h = Oe(t, f.id), l.push(
752
- /* @__PURE__ */ O(
753
- pn,
819
+ return r.forEach((p, f) => {
820
+ p.groupHeader ? (y(), d = p.name, c = Bt(t, p), u.push(
821
+ /* @__PURE__ */ M(
822
+ Rn,
754
823
  {
755
- hasChildren: p[f.name] > 0,
756
- open: i.has(f.name),
757
- option: f,
758
- index: m
824
+ hasChildren: b[p.name] > 0,
825
+ open: i.has(p.name),
826
+ option: p,
827
+ index: f
759
828
  },
760
- f.id
829
+ p.id
761
830
  )
762
- )) : f.group ? g.push(w(f, m)) : (S(), y = null, l.push(w(f, m)));
763
- }), S(), l;
764
- }, [r, a, c, i, n, t]);
765
- }), yn = (e = {}) => Object.fromEntries(Object.entries(e).filter(([t]) => t.startsWith("--"))), bn = (e, t, n, r) => {
766
- const s = e.getBoundingClientRect(), c = getComputedStyle(e), i = s.left - parseFloat(c.marginLeft) - t.left, a = n ? s.bottom + parseFloat(c.marginBottom) - t.top + r : s.top - parseFloat(c.marginTop) - t.bottom - r;
831
+ )) : p.group ? x.push(w(p, f)) : (y(), d = null, u.push(w(p, f)));
832
+ }), y(), u;
833
+ }, [r, a, o, i, n, t]);
834
+ }), Hn = (e, t, n, r) => {
835
+ const s = e.getBoundingClientRect(), o = getComputedStyle(e), i = s.left - parseFloat(o.marginLeft) - t.left, a = n ? s.bottom + parseFloat(o.marginBottom) - t.top + r : s.top - parseFloat(o.marginTop) - t.bottom - r;
767
836
  Math.abs(i) > 0.5 && (e.style.left = `${t.left - i}px`), Math.abs(a) > 0.5 && (e.style[n ? "bottom" : "top"] = `${parseFloat(e.style[n ? "bottom" : "top"]) + (n ? a : -a)}px`);
768
- }, vn = ({ selectRef: e, panelRef: t, open: n, offset: r, store: s }) => {
769
- const c = F(0), i = K((o) => {
770
- const p = e.current;
771
- if (!p) return;
772
- const l = n && o ? o.scrollHeight : 0;
773
- l && (c.current = l), c.current || (c.current = parseFloat(getComputedStyle(p).getPropertyValue("--rac-list-max-height")) || 250);
774
- const g = p.getBoundingClientRect(), y = window.innerHeight - g.bottom, h = y < c.current && g.top > y;
775
- s.set({ upward: h }), !(!n || !o) && (o.style.width = `${g.width}px`, o.style.left = `${g.left}px`, o.style.top = h ? "auto" : `${g.bottom + r}px`, o.style.bottom = h ? `${window.innerHeight - g.top + r}px` : "auto", bn(o, g, h, r));
776
- }, [e, n, r, s]), a = K((o) => {
777
- o && i(o.parentElement);
778
- }, [i]);
779
- return ne(() => {
780
- const o = () => i(t.current);
781
- o(), window.addEventListener("resize", o);
782
- const p = [() => window.removeEventListener("resize", o)];
783
- if (n) {
784
- if (window.addEventListener("scroll", o, { capture: !0, passive: !0 }), p.push(() => window.removeEventListener("scroll", o, { capture: !0 })), typeof ResizeObserver < "u") {
785
- const l = new ResizeObserver(o);
786
- e.current && l.observe(e.current), t.current && l.observe(t.current), p.push(() => l.disconnect());
787
- }
788
- } else if (typeof IntersectionObserver < "u") {
789
- const l = new IntersectionObserver(o, { threshold: [0, 0.25, 0.5, 0.75, 1] });
790
- e.current && l.observe(e.current), p.push(() => l.disconnect());
837
+ }, Pn = (e, t) => {
838
+ e && e.dataset.placement !== (t ? "top" : "bottom") && (e.dataset.placement = t ? "top" : "bottom");
839
+ }, He = () => typeof IntersectionObserver < "u", mt = (e, t, n = window.innerHeight - e.bottom) => n < t && e.top > n, Vn = ({ selectRef: e, panelRef: t, open: n, frozen: r, offset: s, onFlip: o }) => {
840
+ const i = G(0), a = G(r), l = G(o);
841
+ X(() => {
842
+ a.current = r, l.current = o;
843
+ });
844
+ const b = Y((c) => [e.current, t.current].forEach((y) => Pn(y, c)), [e, t]), u = Y((c) => {
845
+ const y = e.current;
846
+ if (!y || !c) return;
847
+ c.scrollHeight && (i.current = c.scrollHeight);
848
+ const w = y.getBoundingClientRect(), p = c.dataset.placement, f = i.current, v = p === "top" ? w.top - s >= f : window.innerHeight - w.bottom - s >= f;
849
+ let A = p && (a.current || v) ? p === "top" : mt(w, f);
850
+ p && A !== (p === "top") && (l.current?.(), A = p === "top"), b(A), c.style.width = `${w.width}px`, c.style.left = `${w.left + window.scrollX}px`, c.style.top = A ? "auto" : `${w.bottom + window.scrollY + s}px`, c.style.bottom = A ? `${window.innerHeight - w.top - window.scrollY + s}px` : "auto", Hn(c, w, A, s);
851
+ }, [e, s, b]), x = Y((c) => {
852
+ c && u(c.parentElement);
853
+ }, [u]), d = Y((c) => {
854
+ c?.removeAttribute("data-placement"), u(c);
855
+ }, [u]);
856
+ return J(() => {
857
+ const c = e.current;
858
+ if (n || !c || !He()) return;
859
+ i.current ||= parseFloat(getComputedStyle(c).getPropertyValue("--rac-list-max-height")) || 250;
860
+ const y = { fits: !0, lower: !1 }, w = (f, v, A) => {
861
+ const T = new IntersectionObserver(([{ boundingClientRect: H, rootBounds: C }]) => {
862
+ C && (A(H, C), b(!y.fits && y.lower));
863
+ }, { rootMargin: f, threshold: v });
864
+ return T.observe(c), T;
865
+ }, p = [
866
+ w(`0px 0px ${-i.current}px 0px`, [0, 1], (f, v) => {
867
+ y.fits = f.bottom <= v.bottom;
868
+ }),
869
+ w("0px 0px -50% 0px", [0, 0.5, 1], (f, v) => {
870
+ y.lower = f.top + f.bottom > 2 * v.bottom;
871
+ })
872
+ ];
873
+ return () => p.forEach((f) => f.disconnect());
874
+ }, [n, e, b]), X(() => {
875
+ const c = e.current;
876
+ if (!n || !c) return;
877
+ const y = c.ownerDocument, w = t.current;
878
+ let p = 0, f = 0, v = "", A = null;
879
+ const T = () => {
880
+ const m = c.getBoundingClientRect(), L = t.current?.getBoundingClientRect() ?? m, S = mt(m, i.current), F = i.current + s;
881
+ return [m.left - L.left, S ? m.top - L.bottom : m.bottom - L.top, m.width, window.innerHeight, t.current?.scrollHeight, S, m.top >= F, window.innerHeight - m.bottom >= F].join();
882
+ }, H = () => {
883
+ if (A?.disconnect(), !He()) return;
884
+ const m = c.getBoundingClientRect(), { clientWidth: L, clientHeight: S } = y.documentElement, F = [m.top, L - m.right, S - m.bottom, m.left].map((O) => `${-Math.floor(O)}px`).join(" ");
885
+ let h = !1;
886
+ A = new IntersectionObserver(([O]) => {
887
+ h && O.intersectionRatio < 1 && k(), h = O.intersectionRatio === 1;
888
+ }, { root: y, rootMargin: F, threshold: 1 }), A.observe(c);
889
+ }, C = () => T() === v ? !1 : (u(t.current), v = T(), !0), g = () => {
890
+ if (p = 0, C()) f = 0;
891
+ else if (++f > 1) return H();
892
+ p = requestAnimationFrame(g);
893
+ }, k = () => {
894
+ f = 0, p ||= requestAnimationFrame(g);
895
+ };
896
+ t.current?.removeAttribute("data-offscreen"), u(t.current), v = T(), H(), window.addEventListener("scroll", k, { capture: !0, passive: !0 }), window.addEventListener("resize", k);
897
+ const D = typeof ResizeObserver < "u" && new ResizeObserver(k);
898
+ D && [c, t.current].forEach((m) => m && D.observe(m));
899
+ const R = ({ target: m }) => !c.contains(m) && !t.current?.contains(m), I = typeof MutationObserver < "u" && new MutationObserver((m) => {
900
+ m.some(R) && C() && k();
901
+ });
902
+ I && I.observe(y.body, { subtree: !0, childList: !0, attributes: !0, characterData: !0 });
903
+ const B = He() && new IntersectionObserver(([{ isIntersecting: m, boundingClientRect: L, rootBounds: S }]) => {
904
+ const F = !m && !!S && L.bottom > S.top && L.top < S.bottom && L.right > S.left && L.left < S.right;
905
+ t.current?.toggleAttribute("data-offscreen", F);
906
+ });
907
+ return B && B.observe(c), () => {
908
+ cancelAnimationFrame(p), window.removeEventListener("scroll", k, { capture: !0 }), window.removeEventListener("resize", k);
909
+ for (const m of [D, I, B, A]) m && m.disconnect();
910
+ w?.removeAttribute("data-placement");
911
+ };
912
+ }, [n, u, s, e, t]), [x, d];
913
+ }, zn = (e = {}) => Object.fromEntries(Object.entries(e).filter(([t]) => t.startsWith("--"))), Wn = (e) => (typeof e == "function" ? e() : e) || document.body, qn = () => () => {
914
+ }, Gn = ie(function() {
915
+ const { selectRef: t, selectId: n, multiple: r, offset: s, duration: o, easing: i, animateOpacity: a, keepMounted: l, optionsClassName: b, style: u, container: x, hasMore: d, loadButton: c, texts: y, popup: w } = V(ne), { visibility: p, normalizedOptions: f, loading: v, error: A } = V(fe), { handleListScroll: T, setListReady: H } = V(ue), C = p && f.length > 0, g = ce(qn, () => !0, () => !1), [k, D] = Q(!1);
916
+ C && g && !k && D(!0);
917
+ const [R, I] = Q(null), B = Y(() => I((O) => O || "out"), []), m = G(null), [L, S] = Vn({ selectRef: t, panelRef: m, open: k, frozen: !C || R === "out", offset: s, onFlip: B }), F = () => {
918
+ if (R === "out" && C) {
919
+ S(m.current), I("in");
920
+ return;
791
921
  }
792
- return () => p.forEach((l) => l());
793
- }, [n, i, e, t]), [re(s.subscribe, () => s.get().upward, () => !1), a];
794
- }, wn = (e) => (typeof e == "function" ? e() : e) || document.body, xn = () => () => {
795
- }, On = se(function() {
796
- const { selectRef: t, selectId: n, positionStore: r, multiple: s, offset: c, duration: i, easing: a, animateOpacity: o, keepMounted: p, optionsClassName: l, style: g, container: y, hasMore: h, loadButton: S, texts: w } = B(Y), { visibility: f, normalizedOptions: m, loading: D, error: L } = B(de), { handleListScroll: C, setListReady: j } = B(ce), M = f && m.length > 0, u = re(xn, () => !0, () => !1), x = F(null), [E, $] = vn({ selectRef: t, panelRef: x, open: f && u, offset: c, store: r }), k = K(() => j(!0), [j]);
797
- return u ? Et(
798
- /* @__PURE__ */ O(
799
- ie,
922
+ I(null), D(!1);
923
+ }, h = () => {
924
+ I(null), H(!0);
925
+ };
926
+ return !g || !w ? null : qt(
927
+ /* @__PURE__ */ M(
928
+ de,
800
929
  {
801
930
  axis: "y",
802
- fade: o,
803
- in: M,
804
- nodeRef: x,
805
- unmountOnExit: !p,
806
- onEntered: k,
807
- onMouseDown: (V) => V.preventDefault(),
808
- className: ue("rac-options", l),
809
- "data-placement": E ? "top" : "bottom",
810
- style: { ...yn(g), "--rac-duration": `${i}ms`, "--rac-ease": a, pointerEvents: M ? "auto" : "none", position: "fixed" },
811
- children: /* @__PURE__ */ q(
931
+ fade: a,
932
+ in: C && R !== "out",
933
+ duration: R ? o / 2 : void 0,
934
+ nodeRef: m,
935
+ unmountOnExit: !l && !(R && C),
936
+ onEntered: h,
937
+ onExited: F,
938
+ onMouseDown: (O) => O.preventDefault(),
939
+ className: me("rac-options", b),
940
+ style: { ...zn(u), "--rac-duration": `${o}ms`, "--rac-ease": i, pointerEvents: C ? "auto" : "none", position: "absolute" },
941
+ children: /* @__PURE__ */ ee(
812
942
  "div",
813
943
  {
814
- onScroll: C,
944
+ onScroll: T,
815
945
  className: "rac-list",
816
- "aria-multiselectable": s,
946
+ "aria-multiselectable": r,
817
947
  id: `${n}-listbox`,
818
- "aria-label": w.list,
948
+ "aria-label": y.list,
819
949
  role: "listbox",
820
950
  tabIndex: "-1",
821
- ref: $,
951
+ ref: L,
822
952
  children: [
823
- /* @__PURE__ */ O(mn, {}),
824
- L ? /* @__PURE__ */ O("div", { className: "rac-option", "data-error": "", children: /* @__PURE__ */ O("span", { className: "rac-option-text", children: w.error }) }) : (D || !S && h) && /* @__PURE__ */ q("div", { className: "rac-option", "data-loading": "", children: [
825
- /* @__PURE__ */ O("span", { className: "rac-option-text", children: D ? w.loading : w.loadingMore }),
826
- Be
953
+ /* @__PURE__ */ M(Fn, {}),
954
+ A ? /* @__PURE__ */ M("div", { className: "rac-option", "data-error": "", children: /* @__PURE__ */ M("span", { className: "rac-option-text", children: y.error }) }) : (v || !c && d) && /* @__PURE__ */ ee("div", { className: "rac-option", "data-loading": "", children: [
955
+ /* @__PURE__ */ M("span", { className: "rac-option-text", children: v ? y.loading : y.loadingMore }),
956
+ Ye
827
957
  ] })
828
958
  ]
829
959
  }
830
960
  )
831
961
  }
832
962
  ),
833
- wn(y)
834
- ) : null;
835
- }), mt = [];
836
- function Sn({ props: e, jsxOptions: t, state: n, setState: r, setVisibility: s, loadMoreOnce: c }) {
837
- const { onChange: i, disabled: a, loading: o, error: p, multiple: l, childrenFirst: g, groupsClosed: y, hasMore: h, loadButton: S, placeholder: w, selectedText: f, texts: m } = e, { disabledOption: D, emptyOption: L, invalidOption: C, emptyGroup: j } = m, { loadPending: M, internalValue: u, toggledGroups: x, picked: E } = n, $ = Ne(e.options), k = Ne(e.value), V = k !== void 0, I = V ? k : u, A = M ? m.loadingMore : m.loadMore, b = _(() => Gt({
838
- options: $,
963
+ Wn(x)
964
+ );
965
+ }), Kn = 250, _n = 5e3, Un = [], Yn = () => () => {
966
+ }, be = (e, t) => typeof e == "function" ? e(t) : String(e ?? "").replace(/\{(n|label)\}/g, () => t), Xn = (e, t, n, r) => {
967
+ const s = [];
968
+ if (e.picked.length && !t.picked.length) s.push(be(n.cleared));
969
+ else if (r) {
970
+ const o = new Set(t.picked.map((l) => l.id)), i = new Set(e.picked.map((l) => l.id)), a = e.picked.filter((l) => !o.has(l.id));
971
+ a.length && s.push(be(n.removed, a.map((l) => l.name).join(", "))), t.picked.some((l) => !i.has(l.id)) && s.push(be(n.selected, t.picked.length));
972
+ }
973
+ return t.open && e.count && t.count > e.count && s.push(be(n.loaded, t.count - e.count)), t.error && !e.error && s.push(be(n.error)), s.filter(Boolean).join(". ");
974
+ }, Jn = ie(function() {
975
+ const { selectRef: t, selectId: n, multiple: r, texts: s } = V(ne), { selected: o, selectedIDs: i, normalizedOptions: a, visibility: l, deleting: b, error: u } = V(fe), x = ce(Yn, () => !0, () => !1), [d, c] = Q(""), y = G({ base: null, timer: 0, wipe: 0, latest: null }), w = Z(() => a.reduce((p, f) => "original" in f ? p + 1 : p, 0), [a]);
976
+ return J(() => {
977
+ const p = r ? i : o ? [o] : Un;
978
+ y.current.latest = { snap: { picked: p, count: w, open: l, error: !!u }, texts: s, multiple: r, deleting: b };
979
+ }), J(() => {
980
+ const p = y.current, { snap: f, deleting: v } = p.latest;
981
+ if (!p.base || !p.timer && !v && !t.current?.contains(document.activeElement)) {
982
+ p.base = f;
983
+ return;
984
+ }
985
+ clearTimeout(p.timer), p.timer = setTimeout(() => {
986
+ p.timer = 0;
987
+ const { snap: A, texts: T, multiple: H } = p.latest, C = Xn(p.base, A, T, H);
988
+ p.base = A, C && (c((g) => g === C ? `${C} ` : C), clearTimeout(p.wipe), p.wipe = setTimeout(() => c(""), _n));
989
+ }, Kn);
990
+ }, [o, i, w, u, t]), J(() => {
991
+ const p = y.current;
992
+ return () => {
993
+ clearTimeout(p.timer), clearTimeout(p.wipe);
994
+ };
995
+ }, []), x ? /* @__PURE__ */ ee("div", { className: "rac-live", children: [
996
+ /* @__PURE__ */ M("div", { "aria-live": "polite", "aria-atomic": "true", children: d }),
997
+ u && /* @__PURE__ */ M("div", { id: `${n}-error`, children: be(s.error) })
998
+ ] }) : null;
999
+ }), Ge = [];
1000
+ function Zn({ props: e, jsxOptions: t, state: n, setState: r, setVisibility: s, loadMoreOnce: o }) {
1001
+ const { onChange: i, disabled: a, loading: l, error: b, multiple: u, childrenFirst: x, groupsClosed: d, hasMore: c, loadButton: y, placeholder: w, selectedText: p, texts: f } = e, { disabledOption: v, emptyOption: A, invalidOption: T, emptyGroup: H } = f, { loadPending: C, internalValue: g, toggledGroups: k, picked: D } = n, R = ze(e.options), I = ze(e.value), B = I !== void 0, m = B ? I : g, L = C ? f.loadingMore : f.loadMore, S = Z(() => ln({
1002
+ options: R,
839
1003
  jsxOptions: t,
840
- childrenFirst: g,
841
- hasMore: h,
842
- loadButton: S,
843
- loadPending: M,
844
- loadingTitle: A,
845
- emptyOption: L,
846
- invalidOption: C,
847
- disabledOption: D,
848
- emptyGroup: j
849
- }), [$, t, g, h, S, M, A, L, C, D, j]), d = _(() => new Set(
850
- b.filter((N) => N.groupHeader && !N.disabled && y === x.has(N.name)).map((N) => N.name)
851
- ), [b, x, y]), { selected: v, selectedIDs: T } = _(() => zt(I, b, l, E), [I, b, l, E]), H = b.length > 0, J = !a && H, P = I != null && !(Array.isArray(I) && !I.length) && !(Se(I) && !Object.keys(I).length), G = P && f ? null : v, ee = _(() => P && f ? f : v ? v.name : p ? m.error : o ? m.loading : a ? m.disabled : H ? w : m.empty, [p, o, a, P, f, v, H, w, m]), z = (N) => r((W) => {
852
- const te = new Set(W.toggledGroups);
853
- return te.has(N) ? te.delete(N) : te.add(N), { toggledGroups: te };
854
- }), R = (N, W, te) => {
855
- r(V ? { picked: te } : { internalValue: N, picked: te }), i?.(N, W);
856
- }, pe = (N) => R(N.map((W) => W.original), N.map((W) => W.userId), N.map((W) => W.id)), We = Re({
1004
+ childrenFirst: x,
1005
+ hasMore: c,
1006
+ loadButton: y,
1007
+ loadPending: C,
1008
+ loadingTitle: L,
1009
+ emptyOption: A,
1010
+ invalidOption: T,
1011
+ disabledOption: v,
1012
+ emptyGroup: H
1013
+ }), [R, t, x, c, y, C, L, A, T, v, H]), F = Z(() => new Set(
1014
+ S.filter((j) => j.groupHeader && !j.disabled && d === k.has(j.name)).map((j) => j.name)
1015
+ ), [S, k, d]), { selected: h, selectedIDs: O } = Z(() => st(m, S, u, D), [m, S, u, D]), E = S.length > 0, $ = !a && E, N = m != null && !(Array.isArray(m) && !m.length) && !(Le(m) && !Object.keys(m).length), P = N && p ? null : h, _ = Z(() => N && p ? p : h ? h.name : b ? f.error : l ? f.loading : a ? f.disabled : E ? w : f.empty, [b, l, a, N, p, h, E, w, f]), z = (j) => r((K) => {
1016
+ const U = new Set(K.toggledGroups);
1017
+ return U.has(j) ? U.delete(j) : U.add(j), { toggledGroups: U };
1018
+ }), W = (j, K, U) => {
1019
+ r(B ? { picked: U } : { internalValue: j, picked: U }), i?.(j, K);
1020
+ }, ve = (j) => W(j.map((K) => K.original), j.map((K) => K.userId), j.map((K) => K.id)), we = _e({
857
1021
  toggleGroup: z,
858
- selectOption: (N, W) => {
859
- if (N.groupHeader) {
860
- Q(W), N.disabled || z(N.name);
1022
+ selectOption: (j, K) => {
1023
+ if (j.groupHeader) {
1024
+ oe(K), j.disabled || z(j.name);
861
1025
  return;
862
1026
  }
863
- if (N.disabled || N.loadMore) {
864
- Q(W), N.loadMore && !N.loading && c();
1027
+ if (j.disabled || j.loadMore) {
1028
+ oe(K), j.loadMore && !j.loading && o();
865
1029
  return;
866
1030
  }
867
- if (l) {
868
- Q(W);
869
- const te = T.some((Ee) => Ee.id === N.id);
870
- pe(te ? T.filter((Ee) => Ee.id !== N.id) : [...T, N]);
1031
+ if (u) {
1032
+ oe(K);
1033
+ const U = O.some((pe) => pe.id === j.id);
1034
+ ve(U ? O.filter((pe) => pe.id !== j.id) : [...O, j]);
871
1035
  return;
872
1036
  }
873
- v?.id !== N.id && R(N.original, N.userId, [N.id]), s(!1);
1037
+ h?.id !== j.id && W(j.original, j.userId, [j.id]), s(!1);
874
1038
  },
875
- clear: (N) => {
876
- Q(N), R(l ? [] : null, l ? [] : null, mt);
1039
+ clear: (j) => {
1040
+ oe(j), W(u ? [] : null, u ? [] : null, Ge);
877
1041
  },
878
- removeOption: (N) => pe(T.filter((W) => W.id !== N))
1042
+ removeOption: (j) => ve(O.filter((K) => K.id !== j)),
1043
+ // [DOC: form-field]
1044
+ reset: () => {
1045
+ r({ deleting: !1, invalid: !1 }), s(!1);
1046
+ const j = u ? [] : null, K = e.defaultValue ?? j, { selected: U, selectedIDs: pe } = st(K, S, u, Ge), q = u ? pe : U ? [U] : [], te = u ? O : h ? [h] : [];
1047
+ Te(m ?? j, K) && q.length === te.length && q.every((ae, ge) => ae.id === te[ge].id) || W(K, u ? q.map((ae) => ae.userId) : U?.userId ?? null, q.map((ae) => ae.id));
1048
+ }
879
1049
  });
880
- return { normalizedOptions: b, expandedGroups: d, selected: v, selectedIDs: T, hasOptions: H, active: J, hasActualValue: P, title: ee, valueOption: G, actions: We };
1050
+ return { normalizedOptions: S, expandedGroups: F, selected: h, selectedIDs: O, hasOptions: E, active: $, hasActualValue: N, title: _, valueOption: P, actions: we };
881
1051
  }
882
- const En = (e) => ({
1052
+ const Qn = (e) => ({
883
1053
  internalVisibility: !1,
884
1054
  deleting: !1,
885
1055
  loadPending: !1,
886
1056
  toggledGroups: /* @__PURE__ */ new Set(),
887
1057
  internalValue: e.defaultValue,
888
- picked: mt
1058
+ picked: Ge,
1059
+ fieldsetDisabled: !1,
1060
+ invalid: !1
889
1061
  });
890
- function kn(e, t) {
891
- const { ref: n, open: r, onOpenChange: s, hasMore: c, loadMore: i, loadButton: a, error: o, disabled: p, loading: l } = e, g = wt(), y = _(() => g.replace(/:/g, ""), [g]), h = F(null);
892
- xt(n, () => h.current);
893
- const [S, w] = Ot(kt, e, En), { internalVisibility: f, deleting: m, loadPending: D } = S, [L] = U(() => Me(At)), [C] = U(() => Me({ upward: !1 })), j = r !== void 0, M = j ? !!r : f, u = F(!1), x = F(!1), E = Re({
1062
+ function er(e, t) {
1063
+ const [n, r] = Vt(Gt, e, Qn), { internalVisibility: s, deleting: o, loadPending: i, fieldsetDisabled: a } = n, l = Z(() => a && !e.disabled ? { ...e, disabled: !0 } : e, [e, a]), { ref: b, open: u, onOpenChange: x, popup: d, hasMore: c, loadMore: y, loadButton: w, error: p, disabled: f, loading: v, required: A, texts: T } = l, H = zt(), C = Z(() => H.replace(/:/g, ""), [H]), g = G(null);
1064
+ Wt(b, () => g.current), X(() => {
1065
+ const q = g.current?.querySelector(".rac-input");
1066
+ if (!q) return;
1067
+ const te = () => r({ fieldsetDisabled: !e.disabled && q.matches(":disabled") });
1068
+ te();
1069
+ const ae = new MutationObserver(te);
1070
+ for (let ge = q.parentElement; ge; ge = ge.parentElement) ge.tagName === "FIELDSET" && ae.observe(ge, { attributeFilter: ["disabled"] });
1071
+ return () => ae.disconnect();
1072
+ }, [e.disabled]);
1073
+ const [k] = Q(() => xt(Jt)), D = u !== void 0, R = D ? !!u : s, I = G(!1), B = G(!1), m = _e({
894
1074
  // [DOC: select-store]
895
- setVisibility: (R) => {
896
- R !== M && (j || w({ internalVisibility: R }), s?.(R));
1075
+ setVisibility: (q) => {
1076
+ q === R || q && !d || (D || r({ internalVisibility: q }), x?.(q));
897
1077
  },
898
1078
  // [DOC: select-store]
899
1079
  loadMoreOnce: () => {
900
- if (!c || u.current) return;
901
- if (!i) return le("no loadMore", "`hasMore` is set, but there is no `loadMore` to call.");
902
- u.current = !0, w({ loadPending: !0 });
903
- const R = () => w({ loadPending: !1 });
1080
+ if (!c || I.current) return;
1081
+ if (!y) return le("no loadMore", "`hasMore` is set, but there is no `loadMore` to call.");
1082
+ I.current = !0, r({ loadPending: !0 });
1083
+ const q = () => r({ loadPending: !1 });
904
1084
  try {
905
- i()?.then?.(R, R);
906
- } catch (pe) {
907
- u.current = !1, R(), (globalThis.reportError ?? console.error)(pe);
1085
+ y()?.then?.(q, q);
1086
+ } catch (te) {
1087
+ I.current = !1, q(), (globalThis.reportError ?? console.error)(te);
908
1088
  }
909
1089
  },
910
- setListReady: (R) => L.set({ ready: R }),
911
- setDeleting: (R) => w({ deleting: R })
912
- }), $ = Sn({ props: e, jsxOptions: t, state: S, setState: w, setVisibility: E.setVisibility, loadMoreOnce: E.loadMoreOnce }), { normalizedOptions: k, expandedGroups: V, selected: I, selectedIDs: A, hasOptions: b, active: d, hasActualValue: v, title: T, valueOption: H, actions: J } = $, P = d && M, G = Vt({
913
- props: e,
914
- state: S,
915
- setState: w,
916
- normalizedOptions: k,
917
- expandedGroups: V,
918
- selected: I,
919
- selectedIDs: A,
920
- visibility: P,
921
- highlightStore: L,
922
- setVisibility: E.setVisibility,
923
- loadMoreOnce: E.loadMoreOnce,
924
- modelActions: J
1090
+ setListReady: (q) => k.set({ ready: q }),
1091
+ setDeleting: (q) => r({ deleting: q }),
1092
+ // [DOC: form-field]
1093
+ markInvalid: () => r({ invalid: !0 })
1094
+ }), L = Zn({ props: l, jsxOptions: t, state: n, setState: r, setVisibility: m.setVisibility, loadMoreOnce: m.loadMoreOnce }), { normalizedOptions: S, expandedGroups: F, selected: h, selectedIDs: O, hasOptions: E, active: $, hasActualValue: N, title: P, valueOption: _, actions: z } = L, W = $ && R && d, ve = sn({
1095
+ props: l,
1096
+ state: n,
1097
+ setState: r,
1098
+ normalizedOptions: S,
1099
+ expandedGroups: F,
1100
+ selected: h,
1101
+ selectedIDs: O,
1102
+ visibility: W,
1103
+ highlightStore: k,
1104
+ setVisibility: m.setVisibility,
1105
+ loadMoreOnce: m.loadMoreOnce,
1106
+ modelActions: z
925
1107
  });
926
- oe(() => {
927
- w({ loadPending: !1 });
928
- }, [k.length, c, a]), oe(() => {
929
- D || (u.current = !1);
930
- }, [D]), oe(() => {
931
- P && h.current && document.activeElement !== h.current && h.current.focus(), P || L.set({ index: -1, ready: !1 });
932
- }, [P, L]), oe(() => {
933
- x.current && !d && E.setVisibility(!1), x.current = d;
934
- }, [d, E]);
935
- const ee = _(() => ({ ...E, ...J, ...G }), [E, J, G]), z = _(() => ({
936
- visibility: P,
937
- deleting: m,
938
- loadPending: D,
939
- expandedGroups: V,
940
- selectedIDs: A,
941
- normalizedOptions: k,
942
- selected: I,
943
- hasOptions: b,
944
- active: d,
945
- hasActualValue: v,
946
- title: T,
947
- valueOption: H,
948
- disabled: p,
949
- loading: l,
950
- error: o
951
- }), [P, m, D, V, A, k, I, b, d, v, T, H, p, l, o]);
952
- return { selectId: y, selectRef: h, highlightStore: L, positionStore: C, state: z, actions: ee };
1108
+ J(() => {
1109
+ r({ loadPending: !1 });
1110
+ }, [S.length, c, w]), J(() => {
1111
+ i || (I.current = !1);
1112
+ }, [i]), J(() => {
1113
+ W && g.current && document.activeElement !== g.current && g.current.focus(), W || k.set({ index: -1, ready: !1 });
1114
+ }, [W, k]), J(() => {
1115
+ B.current && !$ && m.setVisibility(!1), B.current = $;
1116
+ }, [$, m]);
1117
+ const we = G(null), j = l.value !== void 0;
1118
+ J(() => {
1119
+ const q = { value: j, open: D };
1120
+ for (const te in q) we.current && we.current[te] !== q[te] && le(`switch ${te}`, `\`${te}\` switched between controlled and uncontrolled (\`undefined\`) after mount. Pick one mode for the lifetime of the Select, like a React input${te === "value" ? "; clear a controlled value with `null` or `[]`" : ""}.`);
1121
+ we.current = q;
1122
+ }, [j, D]), X(() => {
1123
+ g.current?.querySelector(".rac-input")?.setCustomValidity(A && !N && T.required || "");
1124
+ }, [A, N, T.required]);
1125
+ const K = n.invalid && A && !N && !f, U = Z(() => ({ ...m, ...z, ...ve }), [m, z, ve]), pe = Z(() => ({
1126
+ visibility: W,
1127
+ deleting: o,
1128
+ loadPending: i,
1129
+ expandedGroups: F,
1130
+ selectedIDs: O,
1131
+ normalizedOptions: S,
1132
+ selected: h,
1133
+ hasOptions: E,
1134
+ active: $,
1135
+ hasActualValue: N,
1136
+ title: P,
1137
+ valueOption: _,
1138
+ disabled: f,
1139
+ fieldsetDisabled: a,
1140
+ invalid: K,
1141
+ loading: v,
1142
+ error: p
1143
+ }), [W, o, i, F, O, S, h, E, $, N, P, _, f, a, K, v, p]);
1144
+ return { selectId: C, selectRef: g, highlightStore: k, state: pe, actions: U };
953
1145
  }
954
- const Cn = {}, Z = (e) => e != null && e !== "", Pe = (e) => e ? typeof e == "string" || typeof e == "number" ? String(e) : Array.isArray(e) ? e.map(Pe).join(" ").replace(/\s+/g, " ").trim() : xe(e) ? Pe(e.props.children) : "" : "", Tn = ({ name: e, label: t, id: n, value: r, className: s, style: c, children: i, disabled: a, group: o }, p, l) => {
955
- const g = Pe(i), y = r !== void 0 ? r : g;
956
- return i != null && !g && !Z(t) && !Z(e) && !Z(n) && !Z(r) && le("no text", "<Option> has content but no text to show in the title or chips. Add a `label` (or `value`), or enable `valueAsOption`."), {
957
- id: Z(n) ? String(n) : p,
958
- userId: Z(n) ? n : y,
959
- value: y,
960
- label: Z(t) ? String(t) : Z(e) ? String(e) : g || (Z(n) ? String(n) : ""),
1146
+ const tr = {}, se = (e) => e != null && e !== "", Ke = (e) => e ? typeof e == "string" || typeof e == "number" ? String(e) : Array.isArray(e) ? e.map(Ke).join(" ").replace(/\s+/g, " ").trim() : Ne(e) ? Ke(e.props.children) : "" : "", nr = ({ name: e, label: t, id: n, value: r, className: s, style: o, children: i, disabled: a, group: l }, b, u) => {
1147
+ const x = Ke(i), d = r !== void 0 ? r : x;
1148
+ return i != null && !x && !se(t) && !se(e) && !se(n) && !se(r) && le("no text", "<Option> has content but no text to show in the title or chips. Add a `label` (or `value`), or enable `valueAsOption`."), {
1149
+ id: se(n) ? String(n) : b,
1150
+ userId: se(n) ? n : d,
1151
+ value: d,
1152
+ label: se(t) ? String(t) : se(e) ? String(e) : x || (se(n) ? String(n) : ""),
961
1153
  jsx: i,
962
1154
  hasJsx: i != null,
963
1155
  className: s,
964
- style: c,
1156
+ style: o,
965
1157
  disabled: !!a,
966
- group: o || l || null
1158
+ group: l || u || null
967
1159
  };
968
- }, Mn = ({ name: e, label: t, value: n, id: r, disabled: s, className: c = "", style: i = Cn }, a) => {
969
- const o = e ?? t ?? r ?? n;
970
- return { disabled: !!s, isGroupMarker: !0, group: Z(o) ? String(o) : a, className: c, style: i };
971
- }, In = (e) => `<${typeof e == "string" ? e : e?.displayName || e?.name || "Component"}>`, me = (e, t, n = null, r = "o", s = []) => (it.toArray(e).forEach((c) => {
972
- if (!xe(c)) {
973
- le("text", `Text inside <Select> or <OptGroup> is ignored ("${String(c).slice(0, 30)}"). Wrap it in <Option>.`);
1160
+ }, rr = ({ name: e, label: t, value: n, id: r, disabled: s, className: o = "", style: i = tr }, a) => {
1161
+ const l = e ?? t ?? r ?? n;
1162
+ return { disabled: !!s, isGroupMarker: !0, group: se(l) ? String(l) : a, className: o, style: i };
1163
+ }, sr = (e) => `<${typeof e == "string" ? e : e?.displayName || e?.name || "Component"}>`, Ce = (e, t, n = null, r = "o", s = []) => (vt.toArray(e).forEach((o) => {
1164
+ if (!Ne(o)) {
1165
+ le("text", `Text inside <Select> or <OptGroup> is ignored ("${String(o).slice(0, 30)}"). Wrap it in <Option>.`);
974
1166
  return;
975
1167
  }
976
- const i = `${r}-${String(c.key).slice(1).replace(/[:$]/g, (o) => o === ":" ? "-" : "k").replace(/[^\p{L}\p{N}-]/gu, "")}`, a = c.type?.racKind;
977
- if (c.type === at) me(c.props.children, t, n, i, s);
978
- else if (a === "option") s.push(Tn(c.props, i, n));
979
- else if (a === "define") me(c.type.racRender(c.props), t, n, i, s);
1168
+ const i = `${r}-${String(o.key).slice(1).replace(/[:$]/g, (l) => l === ":" ? "-" : "k").replace(/[^\p{L}\p{N}-]/gu, "")}`, a = o.type?.racKind;
1169
+ if (o.type === wt) Ce(o.props.children, t, n, i, s);
1170
+ else if (a === "option") s.push(nr(o.props, i, n));
1171
+ else if (a === "define") Ce(o.type.racRender(o.props), t, n, i, s);
980
1172
  else if (a === "group") {
981
- const o = Mn(c.props, t);
982
- s.push(o), me(c.props.children, t, o.group, i, s);
1173
+ const l = rr(o.props, t);
1174
+ s.push(l), Ce(o.props.children, t, l.group, i, s);
983
1175
  } else {
984
- const o = In(c.type);
985
- le(`child ${o}`, `${o} inside <Select> is ignored: only <Option/>, <OptGroup/> and defineOption() components are read. Put custom content inside <Option>, or wrap the component with defineOption().`);
1176
+ const l = sr(o.type);
1177
+ le(`child ${l}`, `${l} inside <Select> is ignored: only <Option/>, <OptGroup/> and defineOption() components are read. Put custom content inside <Option>, or wrap the component with defineOption().`);
986
1178
  }
987
- }), s), Nn = /* @__PURE__ */ new Set(["ref", "options", "value", "defaultValue", "onChange", "children", "loadMore", "open", "onOpenChange", "onFocus", "onBlur", "childrenFirst", "groupsClosed", "disabled", "loading", "error"]), An = /^(aria|data)-/, Ce = {
1179
+ }), s), or = /* @__PURE__ */ new Set(["ref", "options", "value", "defaultValue", "onChange", "children", "loadMore", "open", "onOpenChange", "onFocus", "onBlur", "onKeyDown", "childrenFirst", "groupsClosed", "disabled", "loading", "error"]), ir = /^(aria|data)-/, Pe = {
988
1180
  options: [],
989
1181
  value: void 0,
990
1182
  defaultValue: void 0,
@@ -997,10 +1189,13 @@ const Cn = {}, Z = (e) => e != null && e !== "", Pe = (e) => e ? typeof e == "st
997
1189
  error: !1,
998
1190
  open: void 0,
999
1191
  onOpenChange: void 0,
1192
+ popup: !0,
1000
1193
  onFocus: void 0,
1001
1194
  onBlur: void 0,
1195
+ onKeyDown: void 0,
1002
1196
  id: void 0,
1003
1197
  name: void 0,
1198
+ form: void 0,
1004
1199
  required: !1,
1005
1200
  hasMore: !1,
1006
1201
  loadMore: void 0,
@@ -1022,11 +1217,18 @@ const Cn = {}, Z = (e) => e != null && e !== "", Pe = (e) => e ? typeof e == "st
1022
1217
  invalidOption: "Invalid option",
1023
1218
  disabledOption: "Disabled option",
1024
1219
  emptyGroup: "Empty group",
1025
- list: "Options"
1220
+ groupOpen: "expanded",
1221
+ groupClosed: "collapsed",
1222
+ list: "Options",
1223
+ required: void 0,
1224
+ removed: "Removed {label}",
1225
+ cleared: "Selection cleared",
1226
+ selected: "{n} selected",
1227
+ loaded: "{n} more options loaded"
1026
1228
  },
1027
1229
  renderOption: void 0,
1028
1230
  valueAsOption: !1,
1029
- icons: { arrow: he.ArrowUp, clear: he.XMark, remove: he.XMark, check: he.Checkmark, checkbox: void 0 },
1231
+ icons: { arrow: Se.ArrowUp, clear: Se.XMark, remove: Se.XMark, check: Se.Checkmark, checkbox: void 0 },
1030
1232
  deleteInline: !1,
1031
1233
  deleteAlways: !1,
1032
1234
  className: "",
@@ -1038,7 +1240,7 @@ const Cn = {}, Z = (e) => e != null && e !== "", Pe = (e) => e ? typeof e == "st
1038
1240
  offset: 1,
1039
1241
  animateOpacity: !0,
1040
1242
  keepMounted: !1
1041
- }, st = {
1243
+ }, bt = {
1042
1244
  visibility: "open",
1043
1245
  setVisibility: "onOpenChange",
1044
1246
  ownBehavior: "open without onOpenChange",
@@ -1062,35 +1264,36 @@ const Cn = {}, Z = (e) => e != null && e !== "", Pe = (e) => e ? typeof e == "st
1062
1264
  emptyOption: "texts.emptyOption",
1063
1265
  invalidOption: "texts.invalidOption",
1064
1266
  disabledOption: "texts.disabledOption"
1065
- }, Te = (e, t) => {
1267
+ }, Ve = (e, t) => {
1066
1268
  const n = { ...e };
1067
1269
  for (const r in t) t[r] !== void 0 && (n[r] = t[r]);
1068
1270
  return n;
1069
1271
  };
1070
- function Vn(e) {
1071
- for (const h in e) h in st && le(`renamed ${h}`, `The \`${h}\` prop was removed. Use \`${st[h]}\`.`);
1272
+ function pr(e) {
1273
+ for (const d in e) d in bt && le(`renamed ${d}`, `The \`${d}\` prop was removed. Use \`${bt[d]}\`.`);
1072
1274
  e.value !== void 0 && !e.onChange && le("read-only value", "`value` is set without `onChange`, so the Select is read-only. Pass `onChange`, or `defaultValue` instead of `value`.");
1073
- const t = Te(Ce, e);
1074
- t.texts = Te(Ce.texts, e.texts), t.icons = Te(Ce.icons, e.icons);
1075
- const n = t.texts.emptyGroup, r = Ne(_(() => me(t.children, n), [t.children, n])), { selectId: s, selectRef: c, highlightStore: i, positionStore: a, state: o, actions: p } = kn(t, r), l = {}, g = {};
1076
- for (const h in t) Nn.has(h) || ((An.test(h) ? g : l)[h] = t[h]);
1077
- const y = It({ ...l, attrs: g, selectId: s, selectRef: c, highlightStore: i, positionStore: a });
1078
- return /* @__PURE__ */ O(Y.Provider, { value: y, children: /* @__PURE__ */ O(ce.Provider, { value: p, children: /* @__PURE__ */ q(de.Provider, { value: o, children: [
1079
- /* @__PURE__ */ O(fn, {}),
1080
- /* @__PURE__ */ O(On, {})
1275
+ const t = Ve(Pe, e);
1276
+ t.texts = Ve(Pe.texts, e.texts), t.icons = Ve(Pe.icons, e.icons);
1277
+ const n = t.texts.emptyGroup, r = ze(Z(() => Ce(t.children, n), [t.children, n])), { selectId: s, selectRef: o, highlightStore: i, state: a, actions: l } = er(t, r), b = {}, u = {};
1278
+ for (const d in t) or.has(d) || ((ir.test(d) ? u : b)[d] = t[d]);
1279
+ const x = Yt({ ...b, attrs: u, selectId: s, selectRef: o, highlightStore: i });
1280
+ return /* @__PURE__ */ M(ne.Provider, { value: x, children: /* @__PURE__ */ M(ue.Provider, { value: l, children: /* @__PURE__ */ ee(fe.Provider, { value: a, children: [
1281
+ /* @__PURE__ */ M(Ln, {}),
1282
+ /* @__PURE__ */ M(Gn, {}),
1283
+ /* @__PURE__ */ M(Jn, {})
1081
1284
  ] }) }) });
1082
1285
  }
1083
- function $n() {
1286
+ function ar() {
1084
1287
  return le("option outside", "<Option/> was rendered outside <Select>, or inside a component that <Select> cannot read. Use it as a direct child, or wrap the component with defineOption()."), null;
1085
1288
  }
1086
- $n.racKind = "option";
1087
- function Ln() {
1289
+ ar.racKind = "option";
1290
+ function cr() {
1088
1291
  return null;
1089
1292
  }
1090
- Ln.racKind = "group";
1293
+ cr.racKind = "group";
1091
1294
  export {
1092
- Ln as OptGroup,
1093
- $n as Option,
1094
- Vn as Select,
1095
- Rn as defineOption
1295
+ cr as OptGroup,
1296
+ ar as Option,
1297
+ pr as Select,
1298
+ fr as defineOption
1096
1299
  };