@coolms/ui-react 0.1.0-alpha.3 → 0.1.0-alpha.30

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.js CHANGED
@@ -1,408 +1,460 @@
1
- import { jsx as e, jsxs as r, Fragment as b } from "react/jsx-runtime";
2
- import { useId as A, useState as M, useRef as x, useEffect as D, useLayoutEffect as F, useCallback as H } from "react";
3
- import { createPortal as Z } from "react-dom";
4
- function g(...l) {
5
- return l.filter(Boolean).join(" ");
6
- }
7
- function k({ name: l }) {
8
- const n = { width: 16, height: 16, viewBox: "0 0 16 16", "aria-hidden": !0, focusable: !1 };
9
- switch (l) {
1
+ import { jsx as e, jsxs as i, Fragment as M } from "react/jsx-runtime";
2
+ import { useId as Y, useState as E, useRef as I, useEffect as q, useCallback as _e, useMemo as Ke, useContext as Oe, createContext as Ue, useLayoutEffect as Ne } from "react";
3
+ import { createPortal as Ce } from "react-dom";
4
+ function de(n, l) {
5
+ const t = { ...n };
6
+ for (const d of Object.keys(l ?? {})) {
7
+ const c = l == null ? void 0 : l[d];
8
+ c !== void 0 && (t[d] = c);
9
+ }
10
+ return t;
11
+ }
12
+ function T(...n) {
13
+ return n.filter(Boolean).join(" ");
14
+ }
15
+ function U({ name: n }) {
16
+ const l = { width: 16, height: 16, viewBox: "0 0 16 16", "aria-hidden": !0, focusable: !1 };
17
+ switch (n) {
10
18
  case "lock":
11
- return /* @__PURE__ */ e("svg", { ...n, className: "cms-glyph", children: /* @__PURE__ */ e("path", { fill: "currentColor", d: "M5 7V5a3 3 0 1 1 6 0v2h.5A1.5 1.5 0 0 1 13 8.5v5A1.5 1.5 0 0 1 11.5 15h-7A1.5 1.5 0 0 1 3 13.5v-5A1.5 1.5 0 0 1 4.5 7H5Zm1.5 0h3V5a1.5 1.5 0 0 0-3 0v2Z" }) });
19
+ return /* @__PURE__ */ e("svg", { ...l, className: "cms-glyph", children: /* @__PURE__ */ e("path", { fill: "currentColor", d: "M5 7V5a3 3 0 1 1 6 0v2h.5A1.5 1.5 0 0 1 13 8.5v5A1.5 1.5 0 0 1 11.5 15h-7A1.5 1.5 0 0 1 3 13.5v-5A1.5 1.5 0 0 1 4.5 7H5Zm1.5 0h3V5a1.5 1.5 0 0 0-3 0v2Z" }) });
12
20
  case "spinner":
13
- return /* @__PURE__ */ e("svg", { ...n, className: "cms-glyph cms-spinner", children: /* @__PURE__ */ e("circle", { cx: "8", cy: "8", r: "6", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeDasharray: "28", strokeDashoffset: "10" }) });
21
+ return /* @__PURE__ */ e("svg", { ...l, className: "cms-glyph cms-spinner", children: /* @__PURE__ */ e("circle", { cx: "8", cy: "8", r: "6", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeDasharray: "28", strokeDashoffset: "10" }) });
14
22
  case "back":
15
- return /* @__PURE__ */ e("svg", { ...n, className: "cms-glyph", children: /* @__PURE__ */ e("path", { fill: "currentColor", d: "M10.7 2.3a1 1 0 0 1 0 1.4L6.4 8l4.3 4.3a1 1 0 0 1-1.4 1.4l-5-5a1 1 0 0 1 0-1.4l5-5a1 1 0 0 1 1.4 0Z" }) });
23
+ return /* @__PURE__ */ e("svg", { ...l, className: "cms-glyph", children: /* @__PURE__ */ e("path", { fill: "currentColor", d: "M10.7 2.3a1 1 0 0 1 0 1.4L6.4 8l4.3 4.3a1 1 0 0 1-1.4 1.4l-5-5a1 1 0 0 1 0-1.4l5-5a1 1 0 0 1 1.4 0Z" }) });
16
24
  case "close":
17
- return /* @__PURE__ */ e("svg", { ...n, className: "cms-glyph", children: /* @__PURE__ */ e("path", { fill: "currentColor", d: "M3.3 3.3a1 1 0 0 1 1.4 0L8 6.6l3.3-3.3a1 1 0 1 1 1.4 1.4L9.4 8l3.3 3.3a1 1 0 0 1-1.4 1.4L8 9.4l-3.3 3.3a1 1 0 0 1-1.4-1.4L6.6 8 3.3 4.7a1 1 0 0 1 0-1.4Z" }) });
25
+ return /* @__PURE__ */ e("svg", { ...l, className: "cms-glyph", children: /* @__PURE__ */ e("path", { fill: "currentColor", d: "M3.3 3.3a1 1 0 0 1 1.4 0L8 6.6l3.3-3.3a1 1 0 1 1 1.4 1.4L9.4 8l3.3 3.3a1 1 0 0 1-1.4 1.4L8 9.4l-3.3 3.3a1 1 0 0 1-1.4-1.4L6.6 8 3.3 4.7a1 1 0 0 1 0-1.4Z" }) });
18
26
  case "warning":
19
- return /* @__PURE__ */ e("svg", { ...n, className: "cms-glyph", children: /* @__PURE__ */ e("path", { fill: "currentColor", d: "M8.9 1.5a1 1 0 0 0-1.8 0l-6 11A1 1 0 0 0 2 14h12a1 1 0 0 0 .9-1.5l-6-11ZM8 5a1 1 0 0 1 1 1v3a1 1 0 0 1-2 0V6a1 1 0 0 1 1-1Zm0 7.5A1 1 0 1 1 8 10.5a1 1 0 0 1 0 2Z" }) });
27
+ return /* @__PURE__ */ e("svg", { ...l, className: "cms-glyph", children: /* @__PURE__ */ e("path", { fill: "currentColor", d: "M8.9 1.5a1 1 0 0 0-1.8 0l-6 11A1 1 0 0 0 2 14h12a1 1 0 0 0 .9-1.5l-6-11ZM8 5a1 1 0 0 1 1 1v3a1 1 0 0 1-2 0V6a1 1 0 0 1 1-1Zm0 7.5A1 1 0 1 1 8 10.5a1 1 0 0 1 0 2Z" }) });
20
28
  case "check":
21
- return /* @__PURE__ */ e("svg", { ...n, className: "cms-glyph", children: /* @__PURE__ */ e("path", { fill: "currentColor", d: "M13.7 4.3a1 1 0 0 1 0 1.4l-6 6a1 1 0 0 1-1.4 0l-3-3a1 1 0 1 1 1.4-1.4L7 9.6l5.3-5.3a1 1 0 0 1 1.4 0Z" }) });
29
+ return /* @__PURE__ */ e("svg", { ...l, className: "cms-glyph", children: /* @__PURE__ */ e("path", { fill: "currentColor", d: "M13.7 4.3a1 1 0 0 1 0 1.4l-6 6a1 1 0 0 1-1.4 0l-3-3a1 1 0 1 1 1.4-1.4L7 9.6l5.3-5.3a1 1 0 0 1 1.4 0Z" }) });
22
30
  case "info":
23
- return /* @__PURE__ */ e("svg", { ...n, className: "cms-glyph", children: /* @__PURE__ */ e("path", { fill: "currentColor", d: "M8 1a7 7 0 1 1 0 14A7 7 0 0 1 8 1Zm0 5.5a1 1 0 0 0-1 1V11a1 1 0 1 0 2 0V7.5a1 1 0 0 0-1-1ZM8 4a1 1 0 1 0 0 2 1 1 0 0 0 0-2Z" }) });
31
+ return /* @__PURE__ */ e("svg", { ...l, className: "cms-glyph", children: /* @__PURE__ */ e("path", { fill: "currentColor", d: "M8 1a7 7 0 1 1 0 14A7 7 0 0 1 8 1Zm0 5.5a1 1 0 0 0-1 1V11a1 1 0 1 0 2 0V7.5a1 1 0 0 0-1-1ZM8 4a1 1 0 1 0 0 2 1 1 0 0 0 0-2Z" }) });
24
32
  }
25
33
  }
26
- function E({
27
- variant: l = "secondary",
28
- busy: n = !1,
29
- busyLabel: a,
30
- locked: c = !1,
31
- lockedReason: s,
32
- icon: m,
33
- disabled: t,
34
- className: u,
34
+ function te({
35
+ variant: n = "secondary",
36
+ busy: l = !1,
37
+ busyLabel: t,
38
+ locked: d = !1,
39
+ lockedReason: c,
40
+ icon: r,
41
+ disabled: m,
42
+ className: s,
35
43
  children: h,
36
- type: o = "button",
37
- title: i,
38
- ...f
44
+ type: b = "button",
45
+ title: o,
46
+ ...u
39
47
  }) {
40
- const d = !!t || n;
41
- return /* @__PURE__ */ r(
48
+ const a = !!m || l;
49
+ return /* @__PURE__ */ i(
42
50
  "button",
43
51
  {
44
- ...f,
45
- type: o,
46
- className: g("cms-button", `cms-button--${l}`, n && "is-busy", c && "is-locked", u),
47
- disabled: d,
48
- "aria-busy": n || void 0,
49
- title: c ? s ?? i : i,
52
+ ...u,
53
+ type: b,
54
+ className: T("cms-button", `cms-button--${n}`, l && "is-busy", d && "is-locked", s),
55
+ disabled: a,
56
+ "aria-busy": l || void 0,
57
+ title: d ? c ?? o : o,
50
58
  children: [
51
- n ? /* @__PURE__ */ e(k, { name: "spinner" }) : c ? /* @__PURE__ */ e(k, { name: "lock" }) : m,
52
- /* @__PURE__ */ e("span", { className: "cms-button__label", children: n && a !== void 0 ? a : h }),
53
- c && s ? /* @__PURE__ */ r("span", { className: "cms-visually-hidden", children: [
59
+ l ? /* @__PURE__ */ e(U, { name: "spinner" }) : d ? /* @__PURE__ */ e(U, { name: "lock" }) : r,
60
+ /* @__PURE__ */ e("span", { className: "cms-button__label", children: l && t !== void 0 ? t : h }),
61
+ d && c ? /* @__PURE__ */ i("span", { className: "cms-visually-hidden", children: [
54
62
  ", ",
55
- s
63
+ c
56
64
  ] }) : null
57
65
  ]
58
66
  }
59
67
  );
60
68
  }
61
- function I({ id: l, label: n, help: a, error: c, pinned: s, children: m }) {
62
- return /* @__PURE__ */ r("div", { className: g("cms-field", c != null && "is-invalid"), children: [
63
- /* @__PURE__ */ e("label", { className: "cms-field__label", htmlFor: l, children: n }),
64
- m,
65
- s != null ? /* @__PURE__ */ r("p", { className: "cms-field__pinned", id: `${l}-pinned`, children: [
66
- /* @__PURE__ */ e(k, { name: "lock" }),
69
+ function Se({ id: n, label: l, help: t, error: d, pinned: c, children: r }) {
70
+ return /* @__PURE__ */ i("div", { className: T("cms-field", d != null && "is-invalid"), children: [
71
+ /* @__PURE__ */ e("label", { className: "cms-field__label", htmlFor: n, children: l }),
72
+ r,
73
+ c != null ? /* @__PURE__ */ i("p", { className: "cms-field__pinned", id: `${n}-pinned`, children: [
74
+ /* @__PURE__ */ e(U, { name: "lock" }),
67
75
  " ",
68
- s
76
+ c
69
77
  ] }) : null,
70
- c != null ? /* @__PURE__ */ e("p", { className: "cms-field__error", id: `${l}-error`, role: "alert", children: c }) : null,
71
- a != null ? /* @__PURE__ */ e("p", { className: "cms-field__help", id: `${l}-help`, children: a }) : null
78
+ d != null ? /* @__PURE__ */ e("p", { className: "cms-field__error", id: `${n}-error`, role: "alert", children: d }) : null,
79
+ t != null ? /* @__PURE__ */ e("p", { className: "cms-field__help", id: `${n}-help`, children: t }) : null
72
80
  ] });
73
81
  }
74
- function B(l, n) {
75
- const a = [n.error != null && `${l}-error`, n.pinned != null && `${l}-pinned`, n.help != null && `${l}-help`].filter(Boolean).join(" ");
76
- return a === "" ? void 0 : a;
82
+ function Ee(n, l) {
83
+ const t = [l.error != null && `${n}-error`, l.pinned != null && `${n}-pinned`, l.help != null && `${n}-help`].filter(Boolean).join(" ");
84
+ return t === "" ? void 0 : t;
85
+ }
86
+ const ze = /^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2}))?)?$/, Ve = /^(\d{2}):(\d{2})(?::(\d{2}))?$/;
87
+ function Ze(n, l, t) {
88
+ const d = (r, m, s, h = 0, b = 0, o = 0) => {
89
+ const u = new Date(Date.UTC(r, m - 1, s, h, b, o));
90
+ return u.setUTCFullYear(r), u.getUTCFullYear() === r && u.getUTCMonth() === m - 1 && u.getUTCDate() === s && u.getUTCHours() === h && u.getUTCMinutes() === b && u.getUTCSeconds() === o ? u : null;
91
+ }, c = (r) => ({ hour: Number(r[1]), minute: Number(r[2]), second: Number(r[3] ?? 0) });
92
+ try {
93
+ if (n === "time") {
94
+ const m = l.match(Ve);
95
+ if (m === null) return l;
96
+ const s = c(m), h = d(2e3, 1, 1, s.hour, s.minute, s.second);
97
+ return h === null ? l : new Intl.DateTimeFormat(t, { timeStyle: m[3] === void 0 ? "short" : "medium", timeZone: "UTC" }).format(h);
98
+ }
99
+ const r = l.match(ze);
100
+ if (r === null) return l;
101
+ if (n === "date" && r[4] === void 0) {
102
+ const m = d(Number(r[1]), Number(r[2]), Number(r[3]));
103
+ return m === null ? l : new Intl.DateTimeFormat(t, { dateStyle: "medium", timeZone: "UTC" }).format(m);
104
+ }
105
+ if (n === "datetime-local" && r[4] !== void 0) {
106
+ const m = d(Number(r[1]), Number(r[2]), Number(r[3]), Number(r[4]), Number(r[5]), Number(r[6] ?? 0));
107
+ return m === null ? l : new Intl.DateTimeFormat(t, { dateStyle: "medium", timeStyle: r[6] === void 0 ? "short" : "medium", timeZone: "UTC" }).format(m);
108
+ }
109
+ } catch {
110
+ return l;
111
+ }
112
+ return l;
77
113
  }
78
- function ne({ label: l, help: n, error: a, disabled: c, readOnly: s, pinned: m, value: t, onChange: u, placeholder: h, type: o = "text", name: i }) {
79
- const f = A();
80
- return /* @__PURE__ */ e(I, { id: f, label: l, help: n, error: a, pinned: m, children: /* @__PURE__ */ e(
114
+ const We = /* @__PURE__ */ new Set(["date", "time", "datetime-local"]);
115
+ function Rn({ label: n, help: l, error: t, disabled: d, readOnly: c, pinned: r, value: m, onChange: s, placeholder: h, type: b = "text", name: o, locale: u, min: a, max: f, step: p, minLength: _, maxLength: N, required: y }) {
116
+ const x = Y(), C = c === !0 || r != null, S = C && We.has(b), F = b === "number" && (p === "any" || typeof p == "number" && !Number.isInteger(p));
117
+ return /* @__PURE__ */ e(Se, { id: x, label: n, help: l, error: t, pinned: r, children: /* @__PURE__ */ e(
81
118
  "input",
82
119
  {
83
- id: f,
84
- name: i,
85
- type: o,
120
+ id: x,
121
+ name: o,
122
+ type: S ? "text" : b,
86
123
  className: "cms-input",
87
- value: t,
124
+ value: S ? Ze(b, m, u) : m,
125
+ ...S ? { "data-value": m } : {},
126
+ lang: u,
88
127
  placeholder: h,
89
- disabled: c,
90
- readOnly: s || m != null,
91
- "aria-invalid": a != null || void 0,
92
- "aria-describedby": B(f, { help: n, error: a, pinned: m }),
93
- onChange: (d) => u == null ? void 0 : u(d.target.value)
128
+ disabled: d,
129
+ readOnly: C,
130
+ required: y,
131
+ "aria-required": y || void 0,
132
+ min: S ? void 0 : a,
133
+ max: S ? void 0 : f,
134
+ step: S ? void 0 : p,
135
+ minLength: _,
136
+ maxLength: N,
137
+ inputMode: b === "number" ? F ? "decimal" : "numeric" : void 0,
138
+ "aria-invalid": t != null || void 0,
139
+ "aria-describedby": Ee(x, { help: l, error: t, pinned: r }),
140
+ onChange: (R) => s == null ? void 0 : s(R.target.value)
94
141
  }
95
142
  ) });
96
143
  }
97
- function ae({ label: l, help: n, error: a, disabled: c, readOnly: s, value: m, options: t, onChange: u, emptyText: h = "Nothing to choose from yet.", name: o }) {
98
- const i = A(), f = t.length === 0;
99
- return /* @__PURE__ */ e(I, { id: i, label: l, help: f ? h : n, error: a, children: /* @__PURE__ */ e(
100
- "select",
144
+ function Hn({ label: n, help: l, error: t, disabled: d, readOnly: c, pinned: r, value: m, onChange: s, placeholder: h, rows: b = 4, name: o, locale: u, minLength: a, maxLength: f, required: p }) {
145
+ const _ = Y();
146
+ return /* @__PURE__ */ e(Se, { id: _, label: n, help: l, error: t, pinned: r, children: /* @__PURE__ */ e(
147
+ "textarea",
101
148
  {
102
- id: i,
149
+ id: _,
103
150
  name: o,
104
- className: "cms-input cms-select",
151
+ className: "cms-input cms-textarea",
152
+ rows: b,
105
153
  value: m,
106
- disabled: c || f,
107
- "aria-readonly": s || void 0,
108
- "aria-invalid": a != null || void 0,
109
- "aria-describedby": B(i, { help: f ? h : n, error: a }),
110
- onChange: (d) => {
111
- s || u == null || u(d.target.value);
154
+ lang: u,
155
+ placeholder: h,
156
+ disabled: d,
157
+ readOnly: c === !0 || r != null,
158
+ required: p,
159
+ "aria-required": p || void 0,
160
+ minLength: a,
161
+ maxLength: f,
162
+ "aria-invalid": t != null || void 0,
163
+ "aria-describedby": Ee(_, { help: l, error: t, pinned: r }),
164
+ onChange: (N) => s == null ? void 0 : s(N.target.value)
165
+ }
166
+ ) });
167
+ }
168
+ function Kn({ label: n, help: l, error: t, disabled: d, readOnly: c, value: r, options: m, onChange: s, emptyText: h = "Nothing to choose from yet.", name: b }) {
169
+ const o = Y(), u = m.length === 0;
170
+ return /* @__PURE__ */ e(Se, { id: o, label: n, help: u ? h : l, error: t, children: /* @__PURE__ */ e(
171
+ "select",
172
+ {
173
+ id: o,
174
+ name: b,
175
+ className: "cms-input cms-select",
176
+ value: r,
177
+ disabled: d || u,
178
+ "aria-readonly": c || void 0,
179
+ "aria-invalid": t != null || void 0,
180
+ "aria-describedby": Ee(o, { help: u ? h : l, error: t }),
181
+ onChange: (a) => {
182
+ c || s == null || s(a.target.value);
112
183
  },
113
- children: t.map((d) => /* @__PURE__ */ e("option", { value: d.value, disabled: s && d.value !== m, children: d.label }, d.value))
184
+ children: m.map((a) => /* @__PURE__ */ e("option", { value: a.value, disabled: c && a.value !== r, children: a.label }, a.value))
114
185
  }
115
186
  ) });
116
187
  }
117
- function se({ label: l, checked: n, onChange: a, disabled: c, readOnly: s, help: m }) {
118
- const t = A();
119
- return /* @__PURE__ */ r("div", { className: "cms-toggle-row", children: [
188
+ function On({ label: n, checked: l, onChange: t, disabled: d, readOnly: c, help: r }) {
189
+ const m = Y();
190
+ return /* @__PURE__ */ i("div", { className: "cms-toggle-row", children: [
120
191
  /* @__PURE__ */ e(
121
192
  "button",
122
193
  {
123
- id: t,
194
+ id: m,
124
195
  type: "button",
125
196
  role: "switch",
126
- className: g("cms-toggle", n && "is-on"),
127
- "aria-checked": n,
128
- "aria-readonly": s || void 0,
129
- "aria-describedby": m != null ? `${t}-help` : void 0,
130
- disabled: c,
197
+ className: T("cms-toggle", l && "is-on"),
198
+ "aria-checked": l,
199
+ "aria-readonly": c || void 0,
200
+ "aria-describedby": r != null ? `${m}-help` : void 0,
201
+ disabled: d,
131
202
  onClick: () => {
132
- s || a == null || a(!n);
203
+ c || t == null || t(!l);
133
204
  },
134
205
  children: /* @__PURE__ */ e("span", { className: "cms-toggle__thumb" })
135
206
  }
136
207
  ),
137
- /* @__PURE__ */ e("label", { className: "cms-toggle__label", htmlFor: t, children: l }),
138
- m != null ? /* @__PURE__ */ e("p", { className: "cms-field__help", id: `${t}-help`, children: m }) : null
208
+ /* @__PURE__ */ e("label", { className: "cms-toggle__label", htmlFor: m, children: n }),
209
+ r != null ? /* @__PURE__ */ e("p", { className: "cms-field__help", id: `${m}-help`, children: r }) : null
139
210
  ] });
140
211
  }
141
- const R = 150;
142
- function z({ open: l, title: n, onClose: a, dirty: c = !1, onDirtyClose: s, children: m, footer: t }) {
143
- const [u, h] = M(l), [o, i] = M(!1), f = x(null), d = x(null), v = A();
144
- if (D(() => {
145
- if (l) {
146
- d.current = document.activeElement, h(!0), i(!1);
212
+ const je = 150;
213
+ function Be({ open: n, title: l, onClose: t, dirty: d = !1, onDirtyClose: c, children: r, footer: m, closeLabel: s = "Close", initialFocus: h, className: b }) {
214
+ const [o, u] = E(n), [a, f] = E(!1), p = I(null), _ = I(null), N = Y();
215
+ if (q(() => {
216
+ if (n) {
217
+ _.current = document.activeElement, u(!0), f(!1);
147
218
  return;
148
219
  }
149
- if (!u) return;
150
- i(!0);
151
- const p = window.setTimeout(() => {
152
- var N, w;
153
- h(!1), i(!1), (w = (N = d.current) == null ? void 0 : N.focus) == null || w.call(N);
154
- }, R);
155
- return () => window.clearTimeout(p);
156
- }, [l, u]), D(() => {
157
- var p, N;
158
- if (l && u) {
159
- const w = 'input, select, textarea, button, [href], [tabindex]:not([tabindex="-1"])';
160
- (N = ((p = f.current) == null ? void 0 : p.querySelector(`.cms-modal__body :is(${w}), .cms-modal__foot :is(${w})`)) ?? f.current) == null || N.focus();
220
+ if (!o) return;
221
+ f(!0);
222
+ const x = window.setTimeout(() => {
223
+ var C, S;
224
+ u(!1), f(!1), (S = (C = _.current) == null ? void 0 : C.focus) == null || S.call(C);
225
+ }, je);
226
+ return () => window.clearTimeout(x);
227
+ }, [n, o]), q(() => {
228
+ var x, C;
229
+ if (n && o) {
230
+ const S = 'input, select, textarea, button, [href], [tabindex]:not([tabindex="-1"])';
231
+ (C = (h == null ? void 0 : h.current) ?? ((x = p.current) == null ? void 0 : x.querySelector(`.cms-modal__body :is(${S}), .cms-modal__foot :is(${S})`)) ?? p.current) == null || C.focus();
161
232
  }
162
- }, [l, u]), !u) return null;
163
- const _ = () => {
164
- c ? s == null || s() : a();
233
+ }, [n, o, h]), !o) return null;
234
+ const y = () => {
235
+ d ? c == null || c() : t();
165
236
  };
166
- return Z(
167
- /* @__PURE__ */ e("div", { className: g("cms-modal-scrim", o && "is-closing"), onMouseDown: (p) => {
168
- p.target === p.currentTarget && _();
169
- }, children: /* @__PURE__ */ r(
237
+ return Ce(
238
+ /* @__PURE__ */ e("div", { className: T("cms-modal-scrim", a && "is-closing"), onMouseDown: (x) => {
239
+ x.target === x.currentTarget && y();
240
+ }, children: /* @__PURE__ */ i(
170
241
  "div",
171
242
  {
172
- ref: f,
173
- className: g("cms-modal", o && "is-closing", c && "is-dirty"),
243
+ ref: p,
244
+ className: T("cms-modal", b, a && "is-closing", d && "is-dirty"),
174
245
  role: "dialog",
175
246
  "aria-modal": "true",
176
- "aria-labelledby": v,
247
+ "aria-labelledby": N,
177
248
  tabIndex: -1,
178
- onKeyDown: (p) => {
179
- var N;
180
- if (p.key === "Escape")
181
- p.stopPropagation(), _();
182
- else if (p.key === "Tab") {
183
- const w = (N = f.current) == null ? void 0 : N.querySelectorAll('input, select, textarea, button:not([disabled]), [href], [tabindex]:not([tabindex="-1"])');
184
- if (!w || w.length === 0) return;
185
- const L = w[0], T = w[w.length - 1];
186
- p.shiftKey && document.activeElement === L ? (p.preventDefault(), T.focus()) : !p.shiftKey && document.activeElement === T && (p.preventDefault(), L.focus());
249
+ onKeyDown: (x) => {
250
+ var C;
251
+ if (x.key === "Escape")
252
+ x.stopPropagation(), y();
253
+ else if (x.key === "Tab") {
254
+ const S = (C = p.current) == null ? void 0 : C.querySelectorAll('input, select, textarea, button:not([disabled]), [href], [tabindex]:not([tabindex="-1"])');
255
+ if (!S || S.length === 0) return;
256
+ const F = S[0], R = S[S.length - 1];
257
+ x.shiftKey && document.activeElement === F ? (x.preventDefault(), R.focus()) : !x.shiftKey && document.activeElement === R && (x.preventDefault(), F.focus());
187
258
  }
188
259
  },
189
260
  children: [
190
- /* @__PURE__ */ r("header", { className: "cms-modal__head", children: [
191
- /* @__PURE__ */ e("h2", { className: "cms-modal__title", id: v, children: n }),
192
- /* @__PURE__ */ e("button", { type: "button", className: "cms-icon-button", "aria-label": "Close", onClick: _, children: /* @__PURE__ */ e(k, { name: "close" }) })
261
+ /* @__PURE__ */ i("header", { className: "cms-modal__head", children: [
262
+ /* @__PURE__ */ e("h2", { className: "cms-modal__title", id: N, children: l }),
263
+ /* @__PURE__ */ e("button", { type: "button", className: "cms-icon-button", "aria-label": s, onClick: y, children: /* @__PURE__ */ e(U, { name: "close" }) })
193
264
  ] }),
194
- /* @__PURE__ */ e("div", { className: "cms-modal__body", children: m }),
195
- t != null ? /* @__PURE__ */ e("footer", { className: "cms-modal__foot", children: t }) : null
265
+ /* @__PURE__ */ e("div", { className: "cms-modal__body", children: r }),
266
+ m != null ? /* @__PURE__ */ e("footer", { className: "cms-modal__foot", children: m }) : null
196
267
  ]
197
268
  }
198
269
  ) }),
199
270
  document.body
200
271
  );
201
272
  }
202
- function ce({ open: l, title: n, message: a, kind: c = "default", confirmLabel: s, cancelLabel: m, onConfirm: t, onCancel: u }) {
203
- const h = c === "discard-changes";
273
+ function Un({ open: n, title: l, message: t, kind: d = "default", confirmLabel: c, cancelLabel: r, closeLabel: m, onConfirm: s, onCancel: h }) {
274
+ const b = d === "discard-changes";
204
275
  return /* @__PURE__ */ e(
205
- z,
276
+ Be,
206
277
  {
207
- open: l,
208
- title: n,
209
- onClose: u,
210
- footer: /* @__PURE__ */ r(b, { children: [
211
- /* @__PURE__ */ e(E, { onClick: u, children: m ?? (h ? "Keep editing" : "Cancel") }),
212
- /* @__PURE__ */ e(E, { variant: c === "default" ? "primary" : "danger", onClick: t, children: s ?? (h ? "Discard changes" : "Confirm") })
278
+ open: n,
279
+ title: l,
280
+ onClose: h,
281
+ ...m === void 0 ? {} : { closeLabel: m },
282
+ footer: /* @__PURE__ */ i(M, { children: [
283
+ /* @__PURE__ */ e(te, { onClick: h, children: r ?? (b ? "Keep editing" : "Cancel") }),
284
+ /* @__PURE__ */ e(te, { variant: d === "default" ? "primary" : "danger", onClick: s, children: c ?? (b ? "Discard changes" : "Confirm") })
213
285
  ] }),
214
- children: c !== "default" ? /* @__PURE__ */ r("p", { className: "cms-confirm__warning", children: [
215
- /* @__PURE__ */ e(k, { name: "warning" }),
286
+ children: d !== "default" ? /* @__PURE__ */ i("p", { className: "cms-confirm__warning", children: [
287
+ /* @__PURE__ */ e(U, { name: "warning" }),
216
288
  " ",
217
- a
218
- ] }) : /* @__PURE__ */ e("p", { children: a })
289
+ t
290
+ ] }) : /* @__PURE__ */ e("p", { children: t })
219
291
  }
220
292
  );
221
293
  }
222
- function te({ kind: l, message: n, action: a, onDismiss: c }) {
223
- return /* @__PURE__ */ r("div", { className: g("cms-toast", `cms-toast--${l}`), role: l === "error" ? "alert" : "status", children: [
224
- /* @__PURE__ */ e(k, { name: l === "success" ? "check" : l === "error" ? "warning" : "info" }),
225
- /* @__PURE__ */ e("span", { className: "cms-toast__message", children: n }),
226
- a ? /* @__PURE__ */ e(E, { className: "cms-toast__action", onClick: a.onAction, children: a.label }) : null,
227
- c ? /* @__PURE__ */ e("button", { type: "button", className: "cms-icon-button", "aria-label": "Dismiss", onClick: c, children: /* @__PURE__ */ e(k, { name: "close" }) }) : null
294
+ function zn({ kind: n, message: l, action: t, onDismiss: d, dismissLabel: c = "Dismiss" }) {
295
+ return /* @__PURE__ */ i("div", { className: T("cms-toast", `cms-toast--${n}`), role: n === "error" ? "alert" : "status", children: [
296
+ /* @__PURE__ */ e(U, { name: n === "success" ? "check" : n === "error" ? "warning" : "info" }),
297
+ /* @__PURE__ */ e("span", { className: "cms-toast__message", children: l }),
298
+ t ? /* @__PURE__ */ e(te, { className: "cms-toast__action", onClick: t.onAction, children: t.label }) : null,
299
+ d ? /* @__PURE__ */ e("button", { type: "button", className: "cms-icon-button", "aria-label": c, onClick: d, children: /* @__PURE__ */ e(U, { name: "close" }) }) : null
228
300
  ] });
229
301
  }
230
- function re({ children: l }) {
231
- return /* @__PURE__ */ e("div", { className: "cms-toast-region", children: l });
302
+ function Vn({ children: n }) {
303
+ return /* @__PURE__ */ e("div", { className: "cms-toast-region", children: n });
232
304
  }
233
- function P({ what: l, layout: n = "inline" }) {
234
- return /* @__PURE__ */ r("div", { className: g("cms-loading", `cms-loading--${n}`), role: "status", "aria-live": "polite", children: [
235
- /* @__PURE__ */ e(k, { name: "spinner" }),
236
- /* @__PURE__ */ e("span", { children: l })
305
+ function qe({ what: n, layout: l = "inline" }) {
306
+ return /* @__PURE__ */ i("div", { className: T("cms-loading", `cms-loading--${l}`), role: "status", "aria-live": "polite", children: [
307
+ /* @__PURE__ */ e(U, { name: "spinner" }),
308
+ /* @__PURE__ */ e("span", { children: n })
237
309
  ] });
238
310
  }
239
- function V({ title: l, hint: n, action: a }) {
240
- return /* @__PURE__ */ r("div", { className: "cms-empty", children: [
241
- /* @__PURE__ */ e("p", { className: "cms-empty__title", children: l }),
242
- n != null ? /* @__PURE__ */ e("p", { className: "cms-empty__hint", children: n }) : null,
243
- a != null ? /* @__PURE__ */ e("div", { className: "cms-empty__action", children: a }) : null
311
+ function Ye({ title: n, hint: l, action: t }) {
312
+ return /* @__PURE__ */ i("div", { className: "cms-empty", children: [
313
+ /* @__PURE__ */ e("p", { className: "cms-empty__title", children: n }),
314
+ l != null ? /* @__PURE__ */ e("p", { className: "cms-empty__hint", children: l }) : null,
315
+ t != null ? /* @__PURE__ */ e("div", { className: "cms-empty__action", children: t }) : null
244
316
  ] });
245
317
  }
246
- function j({ message: l, onRetry: n }) {
247
- return /* @__PURE__ */ r("div", { className: "cms-error-banner", role: "alert", children: [
248
- /* @__PURE__ */ e(k, { name: "warning" }),
249
- /* @__PURE__ */ e("span", { className: "cms-error-banner__message", children: l }),
250
- n ? /* @__PURE__ */ e(E, { onClick: n, children: "Try again" }) : null
318
+ function Ge({ message: n, onRetry: l, retryLabel: t = "Try again" }) {
319
+ return /* @__PURE__ */ i("div", { className: "cms-error-banner", role: "alert", children: [
320
+ /* @__PURE__ */ e(U, { name: "warning" }),
321
+ /* @__PURE__ */ e("span", { className: "cms-error-banner__message", children: n }),
322
+ l ? /* @__PURE__ */ e(te, { onClick: l, children: t }) : null
251
323
  ] });
252
324
  }
253
- function ie({ title: l, scope: n, actions: a, backLink: c }) {
254
- return /* @__PURE__ */ r("header", { className: "cms-page-header", children: [
255
- c ? /* @__PURE__ */ r(
256
- "a",
257
- {
258
- className: "cms-page-header__back",
259
- href: c.href ?? "#",
260
- onClick: (s) => {
261
- c.onBack && (s.preventDefault(), c.onBack());
262
- },
263
- children: [
264
- /* @__PURE__ */ e(k, { name: "back" }),
265
- " ",
266
- c.label
267
- ]
268
- }
269
- ) : null,
270
- /* @__PURE__ */ r("div", { className: "cms-page-header__row", children: [
271
- /* @__PURE__ */ r("div", { className: "cms-page-header__titles", children: [
272
- /* @__PURE__ */ e("h1", { className: "cms-page-header__title", children: l }),
273
- n != null ? /* @__PURE__ */ e("p", { className: "cms-page-header__scope", children: n }) : null
274
- ] }),
275
- a != null ? /* @__PURE__ */ e("div", { className: "cms-page-header__actions", children: a }) : null
276
- ] })
277
- ] });
278
- }
279
- function oe({ tabs: l, active: n, onSelect: a, label: c }) {
280
- const s = x([]), m = (t, u) => {
281
- var f;
282
- const h = l.length - 1, o = t.key === "ArrowRight" ? u === h ? 0 : u + 1 : t.key === "ArrowLeft" ? u === 0 ? h : u - 1 : t.key === "Home" ? 0 : t.key === "End" ? h : null;
283
- if (o === null) return;
284
- t.preventDefault();
285
- const i = l[o];
286
- i && (a(i.id), (f = s.current[o]) == null || f.focus());
287
- };
288
- return /* @__PURE__ */ e("div", { className: "cms-tabs", role: "tablist", "aria-label": c, children: l.map((t, u) => {
289
- const h = t.id === n;
290
- return /* @__PURE__ */ r(
291
- "button",
292
- {
293
- ref: (o) => {
294
- s.current[u] = o;
295
- },
296
- type: "button",
297
- role: "tab",
298
- className: g("cms-tab", h && "is-active"),
299
- "aria-selected": h,
300
- tabIndex: h ? 0 : -1,
301
- onClick: () => a(t.id),
302
- onKeyDown: (o) => m(o, u),
303
- children: [
304
- t.label,
305
- t.count !== void 0 ? /* @__PURE__ */ e("span", { className: "cms-tab__count", children: t.count }) : null
306
- ]
307
- },
308
- t.id
309
- );
310
- }) });
311
- }
312
- function q(l) {
313
- var c;
314
- const n = l.trim().split(/\s+/).filter(Boolean);
315
- return (n.length > 1 ? [n[0][0], n[n.length - 1][0]] : [(c = n[0]) == null ? void 0 : c[0]]).filter(Boolean).join("").toUpperCase();
316
- }
317
- function U(l) {
318
- let n = 0;
319
- for (const a of l.trim().toLowerCase())
320
- n = n * 31 + (a.codePointAt(0) ?? 0) >>> 0;
321
- return n % 6 + 1;
322
- }
323
- function $({ name: l, pictureUrl: n, presence: a, size: c = 32 }) {
324
- return /* @__PURE__ */ r(
325
- "span",
326
- {
327
- className: `cms-avatar cms-avatar--tint-${U(l)}`,
328
- style: { width: c, height: c, fontSize: Math.round(c * 0.4) },
329
- role: "img",
330
- "aria-label": a ? `${l}, ${a}` : l,
331
- children: [
332
- n ? /* @__PURE__ */ e("img", { src: n, alt: "", className: "cms-avatar__picture" }) : /* @__PURE__ */ e("span", { "aria-hidden": "true", children: q(l) }),
333
- a ? /* @__PURE__ */ e("span", { className: g("cms-avatar__presence", `is-${a}`), "aria-hidden": "true" }) : null
334
- ]
335
- }
336
- );
337
- }
338
- const K = {
339
- mail: /* @__PURE__ */ r(b, { children: [
325
+ const Fe = {
326
+ mail: /* @__PURE__ */ i(M, { children: [
340
327
  /* @__PURE__ */ e("rect", { x: "3", y: "5", width: "18", height: "14", rx: "2" }),
341
328
  /* @__PURE__ */ e("path", { d: "m3 7 9 6 9-6" })
342
329
  ] }),
330
+ // A gear: a ring with eight short teeth, the hole in its middle.
331
+ settings: /* @__PURE__ */ i(M, { children: [
332
+ /* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "3" }),
333
+ /* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "7" }),
334
+ /* @__PURE__ */ e("path", { d: "M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9 7 7M17 17l2.1 2.1M4.9 19.1 7 17M17 7l2.1-2.1" })
335
+ ] }),
336
+ // The envelope with its flap open above it: a message read, or the message itself again.
337
+ "mail-open": /* @__PURE__ */ i(M, { children: [
338
+ /* @__PURE__ */ e("path", { d: "M3 10v9a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-9" }),
339
+ /* @__PURE__ */ e("path", { d: "m3 10 9-6 9 6" }),
340
+ /* @__PURE__ */ e("path", { d: "m3 10 9 6 9-6" })
341
+ ] }),
342
+ // A clipboard: copy what is shown.
343
+ copy: /* @__PURE__ */ i(M, { children: [
344
+ /* @__PURE__ */ e("rect", { x: "6", y: "4", width: "12", height: "17", rx: "2" }),
345
+ /* @__PURE__ */ e("path", { d: "M9 4V3h6v1" }),
346
+ /* @__PURE__ */ e("path", { d: "M9 10h6M9 14h6M9 18h3" })
347
+ ] }),
343
348
  chat: /* @__PURE__ */ e("path", { d: "M4 12a8 8 0 1 1 4 6.9L4 20l1.1-4A8 8 0 0 1 4 12Z" }),
344
349
  phone: /* @__PURE__ */ e("path", { d: "M5 3h3l2 5-2.5 1.5a11 11 0 0 0 7 7L16 14l5 2v3a2 2 0 0 1-2 2A16 16 0 0 1 3 5a2 2 0 0 1 2-2Z" }),
345
- calendar: /* @__PURE__ */ r(b, { children: [
350
+ calendar: /* @__PURE__ */ i(M, { children: [
346
351
  /* @__PURE__ */ e("rect", { x: "3", y: "5", width: "18", height: "16", rx: "2" }),
347
352
  /* @__PURE__ */ e("path", { d: "M3 10h18M8 3v4M16 3v4" })
348
353
  ] }),
349
- file: /* @__PURE__ */ r(b, { children: [
354
+ file: /* @__PURE__ */ i(M, { children: [
350
355
  /* @__PURE__ */ e("path", { d: "M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9Z" }),
351
356
  /* @__PURE__ */ e("path", { d: "M14 3v6h6M8 13h8M8 17h6" })
352
357
  ] }),
353
- image: /* @__PURE__ */ r(b, { children: [
358
+ // The file, with code's angle brackets in place of its lines: a message's source.
359
+ "file-code": /* @__PURE__ */ i(M, { children: [
360
+ /* @__PURE__ */ e("path", { d: "M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9Z" }),
361
+ /* @__PURE__ */ e("path", { d: "M14 3v6h6" }),
362
+ /* @__PURE__ */ e("path", { d: "m10 12-2 2.5 2 2.5M14 12l2 2.5-2 2.5" })
363
+ ] }),
364
+ image: /* @__PURE__ */ i(M, { children: [
354
365
  /* @__PURE__ */ e("rect", { x: "3", y: "4", width: "18", height: "16", rx: "2" }),
355
366
  /* @__PURE__ */ e("circle", { cx: "9", cy: "10", r: "2" }),
356
367
  /* @__PURE__ */ e("path", { d: "m21 17-5-5-9 8" })
357
368
  ] }),
358
- search: /* @__PURE__ */ r(b, { children: [
369
+ search: /* @__PURE__ */ i(M, { children: [
359
370
  /* @__PURE__ */ e("circle", { cx: "11", cy: "11", r: "7" }),
360
371
  /* @__PURE__ */ e("path", { d: "m20 20-4-4" })
361
372
  ] }),
362
- bell: /* @__PURE__ */ r(b, { children: [
373
+ bell: /* @__PURE__ */ i(M, { children: [
363
374
  /* @__PURE__ */ e("path", { d: "M6 9a6 6 0 1 1 12 0c0 6 2 8 2 8H4s2-2 2-8Z" }),
364
375
  /* @__PURE__ */ e("path", { d: "M10 20a2 2 0 0 0 4 0" })
365
376
  ] }),
366
- pencil: /* @__PURE__ */ r(b, { children: [
377
+ pencil: /* @__PURE__ */ i(M, { children: [
367
378
  /* @__PURE__ */ e("path", { d: "M4 20h4L19 9l-4-4L4 16Z" }),
368
379
  /* @__PURE__ */ e("path", { d: "m13 7 4 4" })
369
380
  ] }),
381
+ download: /* @__PURE__ */ i(M, { children: [
382
+ /* @__PURE__ */ e("path", { d: "M12 4v11" }),
383
+ /* @__PURE__ */ e("path", { d: "m7 11 5 5 5-5" }),
384
+ /* @__PURE__ */ e("path", { d: "M4 20h16" })
385
+ ] }),
386
+ // Download's arrow turned up, from the line: a file sent up.
387
+ upload: /* @__PURE__ */ i(M, { children: [
388
+ /* @__PURE__ */ e("path", { d: "M12 20V9" }),
389
+ /* @__PURE__ */ e("path", { d: "m7 13 5-5 5 5" }),
390
+ /* @__PURE__ */ e("path", { d: "M4 4h16" })
391
+ ] }),
392
+ print: /* @__PURE__ */ i(M, { children: [
393
+ /* @__PURE__ */ e("path", { d: "M7 8V4h10v4" }),
394
+ /* @__PURE__ */ e("rect", { x: "3", y: "8", width: "18", height: "8", rx: "2" }),
395
+ /* @__PURE__ */ e("path", { d: "M7 14h10v6H7Z" })
396
+ ] }),
397
+ "open-separately": /* @__PURE__ */ i(M, { children: [
398
+ /* @__PURE__ */ e("path", { d: "M14 4h6v6" }),
399
+ /* @__PURE__ */ e("path", { d: "m20 4-9 9" }),
400
+ /* @__PURE__ */ e("path", { d: "M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5" })
401
+ ] }),
370
402
  star: /* @__PURE__ */ e("path", { d: "m12 3 2.8 5.8 6.2.9-4.5 4.4 1 6.2L12 17.4l-5.5 2.9 1-6.2L3 9.7l6.2-.9Z" }),
371
- send: /* @__PURE__ */ r(b, { children: [
403
+ send: /* @__PURE__ */ i(M, { children: [
372
404
  /* @__PURE__ */ e("path", { d: "M21 3 10 14" }),
373
405
  /* @__PURE__ */ e("path", { d: "M21 3 14 21l-4-7-7-4Z" })
374
406
  ] }),
375
- inbox: /* @__PURE__ */ r(b, { children: [
407
+ inbox: /* @__PURE__ */ i(M, { children: [
376
408
  /* @__PURE__ */ e("path", { d: "M3 13h5l1 3h6l1-3h5" }),
377
409
  /* @__PURE__ */ e("path", { d: "M5 5h14l2 8v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-6Z" })
378
410
  ] }),
379
- archive: /* @__PURE__ */ r(b, { children: [
411
+ archive: /* @__PURE__ */ i(M, { children: [
380
412
  /* @__PURE__ */ e("rect", { x: "3", y: "4", width: "18", height: "5", rx: "1" }),
381
413
  /* @__PURE__ */ e("path", { d: "M5 9v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V9M10 13h4" })
382
414
  ] }),
383
- trash: /* @__PURE__ */ r(b, { children: [
415
+ trash: /* @__PURE__ */ i(M, { children: [
384
416
  /* @__PURE__ */ e("path", { d: "M4 7h16M10 11v6M14 11v6" }),
385
417
  /* @__PURE__ */ e("path", { d: "M6 7l1 13a2 2 0 0 0 2 1h6a2 2 0 0 0 2-1l1-13M9 7V4h6v3" })
386
418
  ] }),
387
419
  paperclip: /* @__PURE__ */ e("path", { d: "m20 11-8.5 8.5a5 5 0 0 1-7-7L13 4a3.5 3.5 0 0 1 5 5l-8.5 8.5a2 2 0 0 1-3-3L14 7" }),
388
- mic: /* @__PURE__ */ r(b, { children: [
420
+ mic: /* @__PURE__ */ i(M, { children: [
389
421
  /* @__PURE__ */ e("rect", { x: "9", y: "3", width: "6", height: "11", rx: "3" }),
390
422
  /* @__PURE__ */ e("path", { d: "M5 11a7 7 0 0 0 14 0M12 18v3" })
391
423
  ] }),
392
- speaker: /* @__PURE__ */ r(b, { children: [
424
+ speaker: /* @__PURE__ */ i(M, { children: [
393
425
  /* @__PURE__ */ e("path", { d: "M4 9h4l5-4v14l-5-4H4Z" }),
394
426
  /* @__PURE__ */ e("path", { d: "M16 9a4 4 0 0 1 0 6M19 6a8 8 0 0 1 0 12" })
395
427
  ] }),
396
- "user-plus": /* @__PURE__ */ r(b, { children: [
428
+ "user-plus": /* @__PURE__ */ i(M, { children: [
397
429
  /* @__PURE__ */ e("circle", { cx: "10", cy: "8", r: "4" }),
398
430
  /* @__PURE__ */ e("path", { d: "M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6" })
399
431
  ] }),
432
+ // A person, nothing more: one whose account is gone.
433
+ user: /* @__PURE__ */ i(M, { children: [
434
+ /* @__PURE__ */ e("circle", { cx: "12", cy: "8", r: "4" }),
435
+ /* @__PURE__ */ e("path", { d: "M4 21a8 8 0 0 1 16 0" })
436
+ ] }),
437
+ // A person with a tick: someone allowed.
438
+ "user-check": /* @__PURE__ */ i(M, { children: [
439
+ /* @__PURE__ */ e("circle", { cx: "10", cy: "8", r: "4" }),
440
+ /* @__PURE__ */ e("path", { d: "M3 21a7 7 0 0 1 14 0M16 11l2 2 4-4" })
441
+ ] }),
442
+ // A person with a cross: someone no longer allowed.
443
+ "user-x": /* @__PURE__ */ i(M, { children: [
444
+ /* @__PURE__ */ e("circle", { cx: "10", cy: "8", r: "4" }),
445
+ /* @__PURE__ */ e("path", { d: "M3 21a7 7 0 0 1 14 0M17 8l4 4M21 8l-4 4" })
446
+ ] }),
447
+ // Two people: the members of a group.
448
+ users: /* @__PURE__ */ i(M, { children: [
449
+ /* @__PURE__ */ e("circle", { cx: "9", cy: "8", r: "3.5" }),
450
+ /* @__PURE__ */ e("path", { d: "M2.5 20a6.5 6.5 0 0 1 13 0M16 4.6a3.5 3.5 0 0 1 0 6.8M18 14a6.5 6.5 0 0 1 3.5 6" })
451
+ ] }),
400
452
  "phone-off": /* @__PURE__ */ e("path", { d: "M3 14c5-5 13-5 18 0l-2 3-4-1v-3a10 10 0 0 0-6 0v3l-4 1Z" }),
401
- video: /* @__PURE__ */ r(b, { children: [
453
+ video: /* @__PURE__ */ i(M, { children: [
402
454
  /* @__PURE__ */ e("rect", { x: "3", y: "6", width: "13", height: "12", rx: "2" }),
403
455
  /* @__PURE__ */ e("path", { d: "m16 10 5-3v10l-5-3" })
404
456
  ] }),
405
- info: /* @__PURE__ */ r(b, { children: [
457
+ info: /* @__PURE__ */ i(M, { children: [
406
458
  /* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "9" }),
407
459
  /* @__PURE__ */ e("path", { d: "M12 11v6M12 7.5v.5" })
408
460
  ] }),
@@ -410,61 +462,821 @@ const K = {
410
462
  "chevron-left": /* @__PURE__ */ e("path", { d: "m15 18-6-6 6-6" }),
411
463
  plus: /* @__PURE__ */ e("path", { d: "M12 5v14M5 12h14" }),
412
464
  folder: /* @__PURE__ */ e("path", { d: "M3 6a2 2 0 0 1 2-2h4l2 3h8a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z" }),
465
+ // The folder with a plus inside: a new folder.
466
+ "folder-plus": /* @__PURE__ */ i(M, { children: [
467
+ /* @__PURE__ */ e("path", { d: "M3 6a2 2 0 0 1 2-2h4l2 3h8a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z" }),
468
+ /* @__PURE__ */ e("path", { d: "M12 10.5v6M9 13.5h6" })
469
+ ] }),
470
+ // The folder with a cross inside: a folder removed.
471
+ "folder-x": /* @__PURE__ */ i(M, { children: [
472
+ /* @__PURE__ */ e("path", { d: "M3 6a2 2 0 0 1 2-2h4l2 3h8a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z" }),
473
+ /* @__PURE__ */ e("path", { d: "m9.5 11 5 5M14.5 11l-5 5" })
474
+ ] }),
413
475
  check: /* @__PURE__ */ e("path", { d: "m5 12 5 5 9-10" }),
414
- server: /* @__PURE__ */ r(b, { children: [
476
+ server: /* @__PURE__ */ i(M, { children: [
415
477
  /* @__PURE__ */ e("rect", { x: "3", y: "4", width: "18", height: "7", rx: "2" }),
416
478
  /* @__PURE__ */ e("rect", { x: "3", y: "13", width: "18", height: "7", rx: "2" }),
417
479
  /* @__PURE__ */ e("path", { d: "M7 7.5h.5M7 16.5h.5" })
418
480
  ] }),
419
481
  reply: /* @__PURE__ */ e("path", { d: "M10 8 4 13l6 5M4 13h11a5 5 0 0 1 5 5" }),
420
- more: /* @__PURE__ */ e("path", { d: "M5 12h.5M12 12h.5M19 12h.5" })
482
+ // Reply's mirror: the arrow leaves to the right.
483
+ forward: /* @__PURE__ */ e("path", { d: "m14 8 6 5-6 5M20 13H9a5 5 0 0 0-5 5" }),
484
+ refresh: /* @__PURE__ */ e("path", { d: "M20 11a8 8 0 1 0-2.3 5.7M20 5v6h-6" }),
485
+ more: /* @__PURE__ */ e("path", { d: "M5 12h.5M12 12h.5M19 12h.5" }),
486
+ important: /* @__PURE__ */ e("path", { d: "M4 6h11l5 6-5 6H4l4-6-4-6Z" })
421
487
  };
422
- function y({ name: l, size: n = 20, label: a }) {
488
+ function A({ name: n, size: l = 20, label: t }) {
423
489
  return /* @__PURE__ */ e(
424
490
  "svg",
425
491
  {
426
492
  className: "cms-icon",
427
- width: n,
428
- height: n,
493
+ width: l,
494
+ height: l,
429
495
  viewBox: "0 0 24 24",
430
496
  fill: "none",
431
497
  stroke: "currentColor",
432
- strokeWidth: l === "more" ? 3 : 1.75,
498
+ strokeWidth: n === "more" ? 3 : 1.75,
433
499
  strokeLinecap: "round",
434
500
  strokeLinejoin: "round",
435
501
  focusable: !1,
436
- ...a ? { role: "img", "aria-label": a } : { "aria-hidden": !0 },
437
- children: K[l]
502
+ ...t ? { role: "img", "aria-label": t } : { "aria-hidden": !0 },
503
+ children: Fe[n]
504
+ }
505
+ );
506
+ }
507
+ const Zn = Object.keys(Fe), Te = {
508
+ reply: "reply",
509
+ "reply-all": "reply",
510
+ forward: "forward",
511
+ envelope: "mail",
512
+ "envelope-open": "mail-open",
513
+ star: "star",
514
+ "star-fill": "star",
515
+ "folder-symlink": "folder",
516
+ folder: "folder",
517
+ trash: "trash",
518
+ archive: "archive",
519
+ "arrow-clockwise": "refresh",
520
+ download: "download",
521
+ printer: "print",
522
+ "file-earmark-code": "file-code",
523
+ clipboard: "copy",
524
+ "three-dots": "more",
525
+ pencil: "pencil",
526
+ trash3: "trash",
527
+ "folder-plus": "folder-plus",
528
+ "folder-x": "folder-x",
529
+ image: "image",
530
+ "person-check": "user-check",
531
+ "person-x": "user-x",
532
+ "arrow-left": "chevron-left",
533
+ "pencil-square": "pencil",
534
+ "plus-lg": "plus",
535
+ gear: "settings",
536
+ upload: "upload",
537
+ "cloud-upload": "upload",
538
+ people: "users",
539
+ "file-earmark-word": "file",
540
+ "file-earmark-spreadsheet": "file",
541
+ "file-earmark-text": "file",
542
+ folder2: "folder",
543
+ "folder2-open": "folder",
544
+ "chat-dots": "chat",
545
+ images: "image",
546
+ paperclip: "paperclip"
547
+ };
548
+ function ce(n) {
549
+ return Object.prototype.hasOwnProperty.call(Te, n) ? Te[n] : null;
550
+ }
551
+ function Xe() {
552
+ try {
553
+ return process.env.NODE_ENV !== "production";
554
+ } catch {
555
+ return !1;
556
+ }
557
+ }
558
+ const Le = /* @__PURE__ */ new Set();
559
+ function Je({ name: n, size: l = 18 }) {
560
+ if (n === "") return null;
561
+ const t = ce(n);
562
+ return t !== null ? /* @__PURE__ */ e(A, { name: t, size: l }) : (!Le.has(n) && Xe() && (Le.add(n), console.warn(`@coolms/ui-react: no icon for the server's icon name "${n}"; its space is kept empty`)), /* @__PURE__ */ e("span", { className: "cms-icon cms-icon--blank", style: { width: l, height: l }, "aria-hidden": "true", "data-icon-name": n }));
563
+ }
564
+ const ke = 300;
565
+ function Qe() {
566
+ if (typeof window > "u" || typeof getComputedStyle != "function") return ke;
567
+ const n = getComputedStyle(document.documentElement).getPropertyValue("--cms-state-delay").trim(), l = n.endsWith("ms") ? Number.parseFloat(n) : n.endsWith("s") ? Number.parseFloat(n) * 1e3 : Number.NaN;
568
+ return Number.isFinite(l) && l >= 0 ? l : ke;
569
+ }
570
+ function en() {
571
+ return /* @__PURE__ */ i("svg", { className: "cms-state__spinner", viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
572
+ /* @__PURE__ */ e("circle", { className: "cms-state__track", cx: "12", cy: "12", r: "10", fill: "none" }),
573
+ /* @__PURE__ */ e("circle", { className: "cms-state__arc", cx: "12", cy: "12", r: "10", fill: "none", pathLength: "100", strokeDasharray: "28 72" })
574
+ ] });
575
+ }
576
+ function le({ kind: n, title: l, description: t, action: d, placement: c = "block", icon: r }) {
577
+ const [m, s] = E(n !== "loading");
578
+ return q(() => {
579
+ if (n !== "loading") {
580
+ s(!0);
581
+ return;
582
+ }
583
+ s(!1);
584
+ const h = window.setTimeout(() => s(!0), Qe());
585
+ return () => window.clearTimeout(h);
586
+ }, [n]), /* @__PURE__ */ i(
587
+ "div",
588
+ {
589
+ className: T("cms-state", `cms-state--${n}`, `cms-state--${c}`, !m && "is-waiting"),
590
+ role: "status",
591
+ "aria-live": "polite",
592
+ "data-kind": n,
593
+ children: [
594
+ n === "loading" ? /* @__PURE__ */ e(en, {}) : null,
595
+ n === "error" || n === "denied" ? /* @__PURE__ */ e(U, { name: n === "error" ? "warning" : "lock" }) : null,
596
+ n === "empty" && r !== void 0 && ce(r) !== null ? /* @__PURE__ */ e("span", { className: "cms-state__icon", "aria-hidden": "true", children: /* @__PURE__ */ e(Je, { name: r, size: c === "page" ? 32 : 24 }) }) : null,
597
+ /* @__PURE__ */ i("span", { className: "cms-state__text", children: [
598
+ /* @__PURE__ */ e("span", { className: "cms-state__title", children: l }),
599
+ t !== void 0 ? /* @__PURE__ */ e("span", { className: "cms-state__description", children: t }) : null
600
+ ] }),
601
+ d !== void 0 && n !== "denied" ? /* @__PURE__ */ e(te, { className: "cms-state__action", onClick: d.onAction, children: d.label }) : null
602
+ ]
603
+ }
604
+ );
605
+ }
606
+ const nn = 'input, select, textarea, button:not([disabled]), iframe, [href], [tabindex]:not([tabindex="-1"])', ln = 60;
607
+ function tn(n) {
608
+ return n instanceof Element && n.closest('input, select, textarea, [contenteditable="true"], [data-viewer-keys]') !== null;
609
+ }
610
+ function an(n) {
611
+ return n instanceof Element && n.closest("[data-viewer-gestures]") !== null;
612
+ }
613
+ function sn(n) {
614
+ return n.getClientRects().length > 0;
615
+ }
616
+ function Wn(n) {
617
+ const { name: l, badge: t, closeLabel: d, onClose: c, actions: r = [], moreLabel: m = "More", edit: s, editing: h, state: b, siblings: o, bar: u, thumbnails: a, strip: f, onZoom: p, children: _ } = n, N = I(null), y = I(null), x = Y(), [C, S] = E(!1), F = I(null);
618
+ q(() => {
619
+ var Z;
620
+ const w = document.activeElement, B = document.body.style.overflow;
621
+ return document.body.style.overflow = "hidden", (Z = y.current) == null || Z.focus(), () => {
622
+ var z;
623
+ document.body.style.overflow = B, (z = w == null ? void 0 : w.focus) == null || z.call(w);
624
+ };
625
+ }, []);
626
+ const R = () => {
627
+ h != null && h.dirty ? h.onDirtyClose() : c();
628
+ }, Q = (w) => {
629
+ const B = w.touches.length === 1 ? w.touches[0] : void 0;
630
+ F.current = B === void 0 || h !== void 0 || an(w.target) ? null : { x: B.clientX, y: B.clientY };
631
+ }, G = (w) => {
632
+ var H, W;
633
+ const B = F.current, Z = w.changedTouches[0];
634
+ if (F.current = null, B === null || Z === void 0) return;
635
+ const z = Z.clientX - B.x;
636
+ Math.abs(z) < ln || Math.abs(z) < Math.abs(Z.clientY - B.y) || (z > 0 ? (H = o == null ? void 0 : o.onPrevious) == null || H.call(o) : (W = o == null ? void 0 : o.onNext) == null || W.call(o));
637
+ };
638
+ return Ce(
639
+ /* @__PURE__ */ i(
640
+ "div",
641
+ {
642
+ ref: N,
643
+ className: T("cms-viewer", h !== void 0 && "is-editing"),
644
+ role: "dialog",
645
+ "aria-modal": "true",
646
+ "aria-labelledby": x,
647
+ tabIndex: -1,
648
+ onKeyDown: (w) => {
649
+ var B, Z, z;
650
+ if (w.key === "Escape") {
651
+ if (h !== void 0) return;
652
+ w.stopPropagation(), C ? S(!1) : c();
653
+ } else if (w.key === "Tab") {
654
+ const H = Array.from(((B = N.current) == null ? void 0 : B.querySelectorAll(nn)) ?? []).filter(sn);
655
+ if (H.length === 0) return;
656
+ const W = H[0], j = H[H.length - 1];
657
+ w.shiftKey && document.activeElement === W ? (w.preventDefault(), j.focus()) : !w.shiftKey && document.activeElement === j && (w.preventDefault(), W.focus());
658
+ } else h === void 0 && !tn(w.target) && !w.ctrlKey && !w.metaKey && !w.altKey && (w.key === "ArrowLeft" ? (Z = o == null ? void 0 : o.onPrevious) == null || Z.call(o) : w.key === "ArrowRight" ? (z = o == null ? void 0 : o.onNext) == null || z.call(o) : w.key === "+" || w.key === "=" ? p == null || p("in") : w.key === "-" ? p == null || p("out") : w.key === "0" && (p == null || p("reset")));
659
+ },
660
+ children: [
661
+ o !== void 0 ? /* @__PURE__ */ e("span", { className: "cms-visually-hidden", role: "status", children: `${l}, ${o.position}` }) : null,
662
+ /* @__PURE__ */ i("header", { className: "cms-viewer__top", children: [
663
+ /* @__PURE__ */ e("button", { ref: y, type: "button", className: "cms-viewer__icon", "aria-label": d, onClick: R, children: /* @__PURE__ */ e(U, { name: "close" }) }),
664
+ /* @__PURE__ */ e("span", { className: "cms-viewer__badge", children: t }),
665
+ /* @__PURE__ */ e("h2", { className: "cms-viewer__name", id: x, title: l, children: l }),
666
+ o !== void 0 ? /* @__PURE__ */ e("span", { className: "cms-viewer__position", children: o.position }) : null,
667
+ /* @__PURE__ */ e("span", { className: "cms-viewer__space" }),
668
+ h !== void 0 ? /* @__PURE__ */ i(M, { children: [
669
+ /* @__PURE__ */ e("span", { className: "cms-viewer__status", role: "status", children: h.status }),
670
+ /* @__PURE__ */ e("button", { type: "button", className: "cms-viewer__button cms-viewer__button--edit", onClick: h.onDone, children: h.doneLabel })
671
+ ] }) : /* @__PURE__ */ i(M, { children: [
672
+ /* @__PURE__ */ e("span", { className: "cms-viewer__actions", children: r.map((w) => /* @__PURE__ */ i("button", { type: "button", className: "cms-viewer__button", onClick: w.onSelect, children: [
673
+ w.icon,
674
+ w.label
675
+ ] }, w.label)) }),
676
+ s !== void 0 ? /* @__PURE__ */ i("button", { type: "button", className: "cms-viewer__button cms-viewer__button--edit", "aria-label": s.label, onClick: s.onEdit, children: [
677
+ s.icon,
678
+ /* @__PURE__ */ e("span", { className: "cms-viewer__wide", children: s.label })
679
+ ] }) : null,
680
+ r.length > 0 ? /* @__PURE__ */ i("span", { className: "cms-viewer__more", children: [
681
+ /* @__PURE__ */ e("button", { type: "button", className: "cms-viewer__icon", "aria-label": m, "aria-expanded": C, onClick: () => S((w) => !w), children: /* @__PURE__ */ e(A, { name: "more" }) }),
682
+ C ? /* @__PURE__ */ e("span", { className: "cms-viewer__menu", children: r.map((w) => /* @__PURE__ */ i(
683
+ "button",
684
+ {
685
+ type: "button",
686
+ className: "cms-viewer__button",
687
+ onClick: () => {
688
+ S(!1), w.onSelect();
689
+ },
690
+ children: [
691
+ w.icon,
692
+ w.label
693
+ ]
694
+ },
695
+ w.label
696
+ )) }) : null
697
+ ] }) : null
698
+ ] })
699
+ ] }),
700
+ /* @__PURE__ */ i("div", { className: "cms-viewer__body", children: [
701
+ a != null && h === void 0 ? /* @__PURE__ */ e("nav", { className: "cms-viewer__thumbnails", children: a }) : null,
702
+ /* @__PURE__ */ i("div", { className: "cms-viewer__content", onTouchStart: Q, onTouchEnd: G, children: [
703
+ (h == null ? void 0 : h.conflict) !== void 0 ? /* @__PURE__ */ i("div", { className: "cms-viewer__conflict", role: "alert", children: [
704
+ /* @__PURE__ */ e("p", { className: "cms-viewer__conflict-text", children: h.conflict.message }),
705
+ /* @__PURE__ */ e("button", { type: "button", className: "cms-viewer__button", onClick: h.conflict.onOverwrite, children: h.conflict.overwriteLabel }),
706
+ /* @__PURE__ */ e("button", { type: "button", className: "cms-viewer__button cms-viewer__button--edit", onClick: h.conflict.onKeepBoth, children: h.conflict.keepBothLabel })
707
+ ] }) : null,
708
+ b === void 0 ? _ : /* @__PURE__ */ e(rn, { state: b }),
709
+ h === void 0 && (o != null && o.onPrevious) ? /* @__PURE__ */ e("button", { type: "button", className: "cms-viewer__side cms-viewer__side--previous", "aria-label": o.previousLabel, title: o.previousLabel, onClick: o.onPrevious, children: /* @__PURE__ */ e(U, { name: "back" }) }) : null,
710
+ h === void 0 && (o != null && o.onNext) ? /* @__PURE__ */ e("button", { type: "button", className: "cms-viewer__side cms-viewer__side--next", "aria-label": o.nextLabel, title: o.nextLabel, onClick: o.onNext, children: /* @__PURE__ */ e(U, { name: "back" }) }) : null,
711
+ h === void 0 && o !== void 0 ? /* @__PURE__ */ e("div", { className: "cms-viewer__dots", "aria-hidden": "true", children: Array.from({ length: Math.min(o.total, 7) }, (w, B) => /* @__PURE__ */ e("i", { className: B === Math.min(o.index, 6) ? "is-current" : void 0 }, B)) }) : null
712
+ ] })
713
+ ] }),
714
+ h === void 0 && f != null ? /* @__PURE__ */ e("div", { className: "cms-viewer__strip", children: f }) : null,
715
+ u != null ? /* @__PURE__ */ e("footer", { className: "cms-viewer__bar", children: u }) : null
716
+ ]
717
+ }
718
+ ),
719
+ document.body
720
+ );
721
+ }
722
+ function rn({ state: n }) {
723
+ switch (n.kind) {
724
+ case "loading":
725
+ return /* @__PURE__ */ e(le, { kind: "loading", title: n.title, placement: "page" });
726
+ case "error":
727
+ return /* @__PURE__ */ e(
728
+ le,
729
+ {
730
+ kind: "error",
731
+ title: n.title,
732
+ ...n.description === void 0 ? {} : { description: n.description },
733
+ ...n.retry === void 0 ? {} : { action: { label: n.retry.label, onAction: n.retry.onRetry } },
734
+ placement: "page"
735
+ }
736
+ );
737
+ case "no-preview":
738
+ return /* @__PURE__ */ e(
739
+ le,
740
+ {
741
+ kind: "empty",
742
+ title: n.title,
743
+ ...n.description === void 0 ? {} : { description: n.description },
744
+ action: { label: n.download.label, onAction: n.download.onDownload },
745
+ placement: "page"
746
+ }
747
+ );
748
+ }
749
+ }
750
+ class cn extends Error {
751
+ constructor(l = "denied") {
752
+ super(l), this.name = "FilePickerDenied";
753
+ }
754
+ }
755
+ class on extends Error {
756
+ constructor(l = "restart") {
757
+ super(l), this.name = "FilePickerRestart";
758
+ }
759
+ }
760
+ const we = (n, l) => `${n}
761
+ ${l}`, dn = (n, l) => n === "" ? l : `${n}/${l}`, un = 48;
762
+ function jn(n) {
763
+ var he, ne;
764
+ const { open: l, spaces: t, list: d, disabledReason: c, budget: r, formatSize: m, labels: s, onConfirm: h, onCancel: b } = n, [o, u] = E(((he = t[0]) == null ? void 0 : he.id) ?? ""), [a, f] = E(""), [p, _] = E({ status: "loading" }), [N, y] = E(0), [x, C] = E(/* @__PURE__ */ new Map()), [S, F] = E(0), [R, Q] = E(!1), G = I(null), w = I(!1);
765
+ q(() => {
766
+ w.current = !1;
767
+ }, [l, o, a]);
768
+ const B = Y();
769
+ q(() => {
770
+ var v;
771
+ l && (u(((v = t[0]) == null ? void 0 : v.id) ?? ""), f(""), C(/* @__PURE__ */ new Map()), Q(!1));
772
+ }, [l]), q(() => {
773
+ if (!l || o === "") return;
774
+ let v = !0;
775
+ return _({ status: "loading" }), F(0), d(o, a).then(
776
+ (k) => v && _({ status: "ready", entries: k.entries, next: k.next ?? null, paging: !1 }),
777
+ (k) => v && _({ status: k instanceof cn ? "denied" : "error" })
778
+ ), () => {
779
+ v = !1;
780
+ };
781
+ }, [l, o, a, d, N]);
782
+ const Z = _e(() => {
783
+ if (p.status !== "ready" || p.next === null || p.paging) return;
784
+ const v = p.next, k = p.entries;
785
+ _({ ...p, paging: !0 }), d(o, a, v).then(
786
+ ($) => {
787
+ w.current = !1, _({ status: "ready", entries: [...k, ...$.entries], next: $.next ?? null, paging: !1 });
788
+ },
789
+ ($) => {
790
+ if (!($ instanceof on)) {
791
+ _({ status: "ready", entries: k, next: v, paging: !1 });
792
+ return;
793
+ }
794
+ if (w.current) {
795
+ _({ status: "error" });
796
+ return;
797
+ }
798
+ w.current = !0, y((K) => K + 1);
799
+ }
800
+ );
801
+ }, [p, d, o, a]), z = _e((v) => {
802
+ var k;
803
+ return ((k = r == null ? void 0 : r.cost) == null ? void 0 : k.call(r, v)) ?? v.size ?? 0;
804
+ }, [r]), H = Ke(() => [...x.values()], [x]), W = H.reduce((v, k) => v + (k.size ?? 0), 0), j = r === void 0 ? null : r.limitBytes - r.usedBytes - H.reduce((v, k) => v + z(k), 0), ie = j !== null && j < 0, ue = (v) => {
805
+ if (v.kind !== "file") return null;
806
+ const k = c == null ? void 0 : c(v);
807
+ return k || (j !== null && !x.has(we(o, v.id)) && z(v) > j ? s.overBudget : null);
808
+ }, g = (v) => {
809
+ const k = we(o, v.id);
810
+ !x.has(k) && ue(v) !== null || C(($) => {
811
+ const K = new Map($);
812
+ return K.has(k) ? K.delete(k) : K.set(k, { ...v, space: o, path: a }), K;
813
+ });
814
+ }, D = (v) => f(dn(a, v.name)), V = () => f(a.includes("/") ? a.slice(0, a.lastIndexOf("/")) : ""), ee = (v) => C((k) => {
815
+ const $ = new Map(k);
816
+ return $.delete(v), $;
817
+ }), L = p.status === "ready" ? p.entries : [], X = (v) => {
818
+ const k = L[S];
819
+ if (v.key === "ArrowDown" || v.key === "ArrowUp" || v.key === "Home" || v.key === "End") {
820
+ v.preventDefault();
821
+ const $ = L.length - 1, K = v.key === "Home" ? 0 : v.key === "End" ? $ : Math.min($, Math.max(0, S + (v.key === "ArrowDown" ? 1 : -1)));
822
+ F(K), K >= $ - 1 && Z();
823
+ } else v.key === "Enter" && (k == null ? void 0 : k.kind) === "folder" ? (v.preventDefault(), D(k)) : v.key === " " && (k == null ? void 0 : k.kind) === "file" ? (v.preventDefault(), g(k)) : v.key === "Backspace" && a !== "" && (v.preventDefault(), V());
824
+ }, oe = a === "" ? [] : a.split("/"), ye = ((ne = t.find((v) => v.id === o)) == null ? void 0 : ne.name) ?? "", me = (v) => `${B}-entry-${String(v)}`;
825
+ return /* @__PURE__ */ i(
826
+ Be,
827
+ {
828
+ open: l,
829
+ title: s.title,
830
+ onClose: b,
831
+ closeLabel: s.close,
832
+ initialFocus: G,
833
+ className: "cms-file-picker",
834
+ footer: /* @__PURE__ */ i("div", { className: "cms-file-picker__foot", children: [
835
+ /* @__PURE__ */ i("div", { className: "cms-file-picker__summary", "aria-live": "polite", children: [
836
+ H.length > 0 ? /* @__PURE__ */ e("span", { children: s.total(H.length, m(W)) }) : null,
837
+ r !== void 0 && j !== null ? /* @__PURE__ */ e("span", { className: T(ie && "is-over"), children: ie ? s.overBudget : s.left(m(Math.max(0, j)), m(r.limitBytes)) }) : null
838
+ ] }),
839
+ /* @__PURE__ */ i("div", { className: "cms-file-picker__actions", children: [
840
+ /* @__PURE__ */ e(te, { variant: "secondary", onClick: b, children: s.cancel }),
841
+ /* @__PURE__ */ e(te, { variant: "primary", disabled: H.length === 0 || ie, onClick: () => h(H), children: s.confirm(H.length) })
842
+ ] })
843
+ ] }),
844
+ children: [
845
+ /* @__PURE__ */ i("div", { className: "cms-file-picker__top", children: [
846
+ t.length > 1 ? /* @__PURE__ */ i("label", { className: "cms-file-picker__space", children: [
847
+ /* @__PURE__ */ e("span", { className: "cms-visually-hidden", children: s.space }),
848
+ /* @__PURE__ */ e("select", { className: "cms-input cms-select", value: o, onChange: (v) => {
849
+ u(v.target.value), f("");
850
+ }, children: t.map((v) => /* @__PURE__ */ e("option", { value: v.id, children: v.name }, v.id)) })
851
+ ] }) : null,
852
+ /* @__PURE__ */ i("nav", { className: "cms-file-picker__path", "aria-label": s.path, children: [
853
+ /* @__PURE__ */ e("button", { type: "button", className: "cms-icon-button", "aria-label": s.up, disabled: a === "", onClick: V, children: /* @__PURE__ */ e(A, { name: "chevron-left" }) }),
854
+ /* @__PURE__ */ i("ol", { children: [
855
+ /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e("button", { type: "button", className: "cms-file-picker__crumb", "aria-current": a === "" ? "location" : void 0, onClick: () => f(""), children: ye }) }),
856
+ oe.map((v, k) => {
857
+ const $ = oe.slice(0, k + 1).join("/");
858
+ return /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e("button", { type: "button", className: "cms-file-picker__crumb", "aria-current": $ === a ? "location" : void 0, onClick: () => f($), children: v }) }, $);
859
+ })
860
+ ] })
861
+ ] }),
862
+ H.length > 0 ? /* @__PURE__ */ e("button", { type: "button", className: "cms-file-picker__chip", "aria-expanded": R, onClick: () => Q((v) => !v), children: s.selected(H.length) }) : null
863
+ ] }),
864
+ R && H.length > 0 ? /* @__PURE__ */ i("div", { className: "cms-file-picker__chosen", children: [
865
+ /* @__PURE__ */ e("ul", { children: [...x.entries()].map(([v, k]) => /* @__PURE__ */ i("li", { children: [
866
+ /* @__PURE__ */ e("span", { className: "cms-file-picker__name", children: k.name }),
867
+ /* @__PURE__ */ e("button", { type: "button", className: "cms-icon-button", "aria-label": s.remove(k.name), onClick: () => ee(v), children: /* @__PURE__ */ e(U, { name: "close" }) })
868
+ ] }, v)) }),
869
+ /* @__PURE__ */ e(te, { variant: "secondary", onClick: () => {
870
+ C(/* @__PURE__ */ new Map()), Q(!1);
871
+ }, children: s.clear })
872
+ ] }) : null,
873
+ /* @__PURE__ */ i("div", { className: "cms-file-picker__list", onScroll: (v) => {
874
+ const k = v.currentTarget;
875
+ k.scrollTop + k.clientHeight >= k.scrollHeight - un && Z();
876
+ }, children: [
877
+ p.status === "loading" ? /* @__PURE__ */ e(le, { kind: "loading", title: s.loading, placement: "block" }) : null,
878
+ p.status === "error" ? /* @__PURE__ */ e(le, { kind: "error", title: s.error, placement: "block", action: { label: s.retry, onAction: () => {
879
+ w.current = !1, y((v) => v + 1);
880
+ } } }) : null,
881
+ p.status === "denied" ? /* @__PURE__ */ e(le, { kind: "denied", title: s.denied, placement: "block" }) : null,
882
+ p.status === "ready" && L.length === 0 ? /* @__PURE__ */ e(le, { kind: "empty", title: s.empty, placement: "block" }) : null,
883
+ /* @__PURE__ */ i(
884
+ "div",
885
+ {
886
+ ref: G,
887
+ role: "listbox",
888
+ "aria-multiselectable": "true",
889
+ "aria-label": s.files,
890
+ "aria-activedescendant": L.length > 0 ? me(S) : void 0,
891
+ tabIndex: 0,
892
+ className: "cms-file-picker__entries",
893
+ hidden: p.status !== "ready" || L.length === 0,
894
+ onKeyDown: X,
895
+ children: [
896
+ L.map((v, k) => {
897
+ const $ = v.kind === "file" && x.has(we(o, v.id)), K = ue(v);
898
+ return /* @__PURE__ */ i(
899
+ "div",
900
+ {
901
+ id: me(k),
902
+ role: "option",
903
+ "aria-selected": v.kind === "file" ? $ : void 0,
904
+ "aria-disabled": K !== null || void 0,
905
+ className: T("cms-file-picker__entry", k === S && "is-active", $ && "is-ticked", K !== null && "is-disabled"),
906
+ onClick: () => {
907
+ F(k), v.kind === "folder" ? D(v) : g(v);
908
+ },
909
+ children: [
910
+ /* @__PURE__ */ e("span", { className: "cms-file-picker__tick", "aria-hidden": "true", children: $ ? /* @__PURE__ */ e(A, { name: "check" }) : null }),
911
+ /* @__PURE__ */ e(A, { name: v.kind === "folder" ? "folder" : "file" }),
912
+ /* @__PURE__ */ i("span", { className: "cms-file-picker__text", children: [
913
+ /* @__PURE__ */ e("span", { className: "cms-file-picker__name", children: v.name }),
914
+ K !== null ? /* @__PURE__ */ e("span", { className: "cms-file-picker__reason", children: K }) : null
915
+ ] }),
916
+ v.kind === "file" && v.size != null ? /* @__PURE__ */ e("span", { className: "cms-file-picker__size", children: m(v.size) }) : null
917
+ ]
918
+ },
919
+ v.id
920
+ );
921
+ }),
922
+ p.status === "ready" && p.paging ? /* @__PURE__ */ e("div", { className: "cms-file-picker__paging", children: /* @__PURE__ */ e(le, { kind: "loading", title: s.loading, placement: "inline" }) }) : null
923
+ ]
924
+ }
925
+ )
926
+ ] })
927
+ ]
928
+ }
929
+ );
930
+ }
931
+ const xe = 64;
932
+ function mn(n, l) {
933
+ for (let t = n instanceof Element ? n : null; t !== null; t = t.parentElement) {
934
+ if (t instanceof HTMLElement && t.scrollTop > 0) return !1;
935
+ if (t === l) return !0;
936
+ }
937
+ return l.scrollTop <= 0;
938
+ }
939
+ function hn(n, l) {
940
+ const [t, d] = E(0), c = I(l);
941
+ return c.current = l, q(() => {
942
+ const r = n.current;
943
+ if (r === null) return;
944
+ let m = null, s = 0;
945
+ const h = (u) => {
946
+ m = mn(u.target, r) && u.touches.length === 1 ? u.touches[0].clientY : null, s = 0;
947
+ }, b = (u) => {
948
+ if (m === null || c.current === null) return;
949
+ const a = u.touches[0].clientY - m;
950
+ if (a <= 0) {
951
+ m = null, d(0);
952
+ return;
953
+ }
954
+ u.cancelable && u.preventDefault(), s = Math.min(a * 0.6, xe * 1.5), d(s);
955
+ }, o = () => {
956
+ var u;
957
+ m !== null && s >= xe && ((u = c.current) == null || u.call(c)), m = null, s = 0, d(0);
958
+ };
959
+ return r.addEventListener("touchstart", h, { passive: !0 }), r.addEventListener("touchmove", b, { passive: !1 }), r.addEventListener("touchend", o), r.addEventListener("touchcancel", o), () => {
960
+ r.removeEventListener("touchstart", h), r.removeEventListener("touchmove", b), r.removeEventListener("touchend", o), r.removeEventListener("touchcancel", o);
961
+ };
962
+ }, [n]), t;
963
+ }
964
+ const Re = Ue(null);
965
+ function fn() {
966
+ return Oe(Re);
967
+ }
968
+ function qn({ label: n, rows: l, error: t, onRetry: d, loadingText: c = "Loading", emptyTitle: r = "Nothing here yet", emptyHint: m, selected: s, onOpen: h, onRowMenu: b }) {
969
+ const o = I([]), u = fn();
970
+ if (t != null) return /* @__PURE__ */ e(Ge, { message: t, onRetry: d });
971
+ if (l === null) return /* @__PURE__ */ e(qe, { what: c, layout: "block" });
972
+ if (l.length === 0) return /* @__PURE__ */ e(Ye, { title: r, hint: m });
973
+ const a = (f, p, _) => {
974
+ var N;
975
+ if (f.key === "ArrowDown" || f.key === "ArrowUp")
976
+ f.preventDefault(), (N = o.current[Math.min(l.length - 1, Math.max(0, p + (f.key === "ArrowDown" ? 1 : -1)))]) == null || N.focus();
977
+ else if (f.key === "Enter")
978
+ h == null || h(_);
979
+ else if ((f.key === "ContextMenu" || f.shiftKey && f.key === "F10") && b) {
980
+ f.preventDefault();
981
+ const y = f.currentTarget.getBoundingClientRect();
982
+ b(_, { x: y.left + 16, y: y.bottom });
983
+ }
984
+ };
985
+ return /* @__PURE__ */ i(M, { children: [
986
+ u !== null && (u.distance > 0 || u.refreshing) ? /* @__PURE__ */ i("div", { className: "cms-list__pull", role: "status", style: { height: u.refreshing ? void 0 : u.distance }, "data-ready": u.distance >= xe ? "" : void 0, children: [
987
+ u.refreshing ? /* @__PURE__ */ e(U, { name: "spinner" }) : null,
988
+ u.text != null ? /* @__PURE__ */ e("span", { className: "cms-list__pull-text", children: u.text }) : null
989
+ ] }) : null,
990
+ /* @__PURE__ */ e("ul", { className: "cms-list", role: "listbox", "aria-label": n, children: l.map((f, p) => {
991
+ const _ = f.id === s;
992
+ return /* @__PURE__ */ i(
993
+ "li",
994
+ {
995
+ ref: (N) => {
996
+ o.current[p] = N;
997
+ },
998
+ role: "option",
999
+ "aria-selected": _,
1000
+ tabIndex: _ || s == null && p === 0 ? 0 : -1,
1001
+ className: T("cms-list__row", _ && "is-selected"),
1002
+ onClick: () => h == null ? void 0 : h(f.id),
1003
+ onKeyDown: (N) => a(N, p, f.id),
1004
+ onContextMenu: b ? (N) => {
1005
+ N.preventDefault(), b(f.id, { x: N.clientX, y: N.clientY });
1006
+ } : void 0,
1007
+ children: [
1008
+ f.lead != null ? /* @__PURE__ */ e("span", { className: "cms-list__lead", children: f.lead }) : null,
1009
+ /* @__PURE__ */ i("span", { className: "cms-list__text", children: [
1010
+ /* @__PURE__ */ e("span", { className: T("cms-list__primary", f.unread === !0 && "is-unread"), children: f.primary }),
1011
+ f.secondary != null ? /* @__PURE__ */ e("span", { className: "cms-list__secondary", children: f.secondary }) : null
1012
+ ] }),
1013
+ f.meta != null || f.count !== void 0 ? /* @__PURE__ */ i("span", { className: "cms-list__end", children: [
1014
+ f.meta != null ? /* @__PURE__ */ e("span", { className: "cms-list__meta", children: f.meta }) : null,
1015
+ f.count !== void 0 && f.count > 0 ? /* @__PURE__ */ e("span", { className: "cms-badge cms-list__count", children: f.count }) : null
1016
+ ] }) : null
1017
+ ]
1018
+ },
1019
+ f.id
1020
+ );
1021
+ }) })
1022
+ ] });
1023
+ }
1024
+ function ve({ at: n, items: l, onClose: t, label: d = "Actions", focus: c = "first" }) {
1025
+ const r = I(null), m = I(null), s = Y(), [h, b] = E(n), o = l.filter((a) => a.offer.offered);
1026
+ if (Ne(() => {
1027
+ if (!n) return;
1028
+ const a = r.current, f = (a == null ? void 0 : a.offsetWidth) ?? 0, p = (a == null ? void 0 : a.offsetHeight) ?? 0;
1029
+ b({ x: Math.max(0, Math.min(n.x, window.innerWidth - f)), y: Math.max(0, Math.min(n.y, window.innerHeight - p)) });
1030
+ }, [n]), q(() => {
1031
+ var p, _;
1032
+ if (!n) return;
1033
+ m.current = document.activeElement;
1034
+ const a = Array.from(((p = r.current) == null ? void 0 : p.querySelectorAll('[role="menuitem"]:not([aria-disabled="true"])')) ?? []);
1035
+ (_ = c === "last" ? a[a.length - 1] : a[0]) == null || _.focus();
1036
+ const f = (N) => {
1037
+ var y;
1038
+ (y = r.current) != null && y.contains(N.target) || t();
1039
+ };
1040
+ return document.addEventListener("mousedown", f), () => {
1041
+ var N, y;
1042
+ document.removeEventListener("mousedown", f), (y = (N = m.current) == null ? void 0 : N.focus) == null || y.call(N);
1043
+ };
1044
+ }, [n, t, c]), !n || o.length === 0) return null;
1045
+ const u = (a) => {
1046
+ var _, N;
1047
+ const f = Array.from(((_ = r.current) == null ? void 0 : _.querySelectorAll('[role="menuitem"]')) ?? []), p = f.indexOf(document.activeElement);
1048
+ if (a.key === "Escape" || a.key === "Tab")
1049
+ a.preventDefault(), t();
1050
+ else if (a.key === "ArrowDown" || a.key === "ArrowUp") {
1051
+ a.preventDefault();
1052
+ const y = a.key === "ArrowDown" ? 1 : -1;
1053
+ (N = f[(p + y + f.length) % f.length]) == null || N.focus();
1054
+ }
1055
+ };
1056
+ return Ce(
1057
+ /* @__PURE__ */ e(
1058
+ "div",
1059
+ {
1060
+ ref: r,
1061
+ className: "cms-menu",
1062
+ role: "menu",
1063
+ "aria-label": d,
1064
+ style: { left: (h ?? n).x, top: (h ?? n).y },
1065
+ onKeyDown: u,
1066
+ onContextMenu: (a) => a.preventDefault(),
1067
+ children: o.map((a) => {
1068
+ const f = a.offer.refusal !== void 0;
1069
+ return /* @__PURE__ */ i(
1070
+ "div",
1071
+ {
1072
+ role: "menuitem",
1073
+ tabIndex: -1,
1074
+ "aria-disabled": f || void 0,
1075
+ "aria-describedby": f ? `${s}-${a.id}` : void 0,
1076
+ title: f ? a.offer.refusal : void 0,
1077
+ className: T("cms-menu__item", a.danger && "is-danger", a.offer.locked && "is-locked", f && "is-refused"),
1078
+ onClick: () => {
1079
+ f || (t(), a.onSelect());
1080
+ },
1081
+ onKeyDown: (p) => {
1082
+ (p.key === "Enter" || p.key === " ") && !f && (p.preventDefault(), t(), a.onSelect());
1083
+ },
1084
+ children: [
1085
+ a.offer.locked ? /* @__PURE__ */ e(U, { name: "lock" }) : null,
1086
+ /* @__PURE__ */ e("span", { className: "cms-menu__label", children: a.label }),
1087
+ f ? /* @__PURE__ */ e("span", { id: `${s}-${a.id}`, className: "cms-menu__refusal", children: a.offer.refusal }) : null
1088
+ ]
1089
+ },
1090
+ a.id
1091
+ );
1092
+ })
1093
+ }
1094
+ ),
1095
+ document.body
1096
+ );
1097
+ }
1098
+ function Yn({ title: n, icon: l, primary: t, more: d = [], moreLabel: c, context: r, fullWidth: m = !1 }) {
1099
+ var p, _, N;
1100
+ const [s, h] = E(null), b = Y(), o = d.filter((y) => y.offer.offered), u = (p = t == null ? void 0 : t.offer) == null ? void 0 : p.refusal, a = t !== void 0 && (((_ = t.offer) == null ? void 0 : _.offered) === !1 || u !== void 0), f = (y, x) => {
1101
+ const C = x.getBoundingClientRect();
1102
+ h((s == null ? void 0 : s.which) === y ? null : { which: y, x: C.left, y: C.bottom + 4 });
1103
+ };
1104
+ return /* @__PURE__ */ i("header", { className: `cms-section-header${m ? " cms-section-header--full" : ""}`, children: [
1105
+ /* @__PURE__ */ i("div", { className: "cms-section-header__row", "data-row": "1", children: [
1106
+ l !== void 0 ? /* @__PURE__ */ e(A, { name: l }) : null,
1107
+ /* @__PURE__ */ e("h1", { className: "cms-section-header__title", title: n, children: n }),
1108
+ /* @__PURE__ */ i("div", { className: "cms-section-header__actions", children: [
1109
+ t !== void 0 && ((N = t.offer) == null ? void 0 : N.offered) !== !1 ? /* @__PURE__ */ i("span", { className: `cms-section-header__primary${"menu" in t ? " cms-section-header__primary--split" : ""}`, children: [
1110
+ /* @__PURE__ */ i(
1111
+ "button",
1112
+ {
1113
+ type: "button",
1114
+ className: "cms-button cms-button--primary",
1115
+ "data-action": "primary",
1116
+ "aria-disabled": a ? "true" : void 0,
1117
+ "aria-describedby": u !== void 0 ? b : void 0,
1118
+ title: u,
1119
+ onClick: () => {
1120
+ a || t.onPress();
1121
+ },
1122
+ children: [
1123
+ /* @__PURE__ */ e(A, { name: t.icon }),
1124
+ " ",
1125
+ /* @__PURE__ */ e("span", { children: t.label })
1126
+ ]
1127
+ }
1128
+ ),
1129
+ "menu" in t ? /* @__PURE__ */ e(
1130
+ "button",
1131
+ {
1132
+ type: "button",
1133
+ className: "cms-button cms-button--primary cms-section-header__split",
1134
+ "data-action": "primary-menu",
1135
+ "aria-haspopup": "menu",
1136
+ "aria-expanded": (s == null ? void 0 : s.which) === "primary",
1137
+ "aria-label": t.menuLabel,
1138
+ onClick: (y) => f("primary", y.currentTarget),
1139
+ children: /* @__PURE__ */ e(A, { name: "chevron-down" })
1140
+ }
1141
+ ) : null,
1142
+ u !== void 0 ? /* @__PURE__ */ e("span", { id: b, className: "cms-visually-hidden", children: u }) : null
1143
+ ] }) : null,
1144
+ o.length > 0 ? /* @__PURE__ */ e(
1145
+ "button",
1146
+ {
1147
+ type: "button",
1148
+ className: "cms-section-header__more",
1149
+ "data-action": "more",
1150
+ "aria-haspopup": "menu",
1151
+ "aria-expanded": (s == null ? void 0 : s.which) === "more",
1152
+ "aria-label": c,
1153
+ title: c,
1154
+ onClick: (y) => f("more", y.currentTarget),
1155
+ children: /* @__PURE__ */ e(A, { name: "more" })
1156
+ }
1157
+ ) : null
1158
+ ] })
1159
+ ] }),
1160
+ r != null ? /* @__PURE__ */ e("div", { className: "cms-section-header__context", "data-row": "2", children: r }) : null,
1161
+ t !== void 0 && "menu" in t ? /* @__PURE__ */ e(ve, { at: (s == null ? void 0 : s.which) === "primary" ? s : null, items: t.menu, onClose: () => h(null), label: t.menuLabel }) : null,
1162
+ /* @__PURE__ */ e(ve, { at: (s == null ? void 0 : s.which) === "more" ? s : null, items: d, onClose: () => h(null), label: c })
1163
+ ] });
1164
+ }
1165
+ function Gn({ title: n, scope: l, actions: t, backLink: d }) {
1166
+ return /* @__PURE__ */ i("header", { className: "cms-page-header", children: [
1167
+ d ? /* @__PURE__ */ i(
1168
+ "a",
1169
+ {
1170
+ className: "cms-page-header__back",
1171
+ href: d.href ?? "#",
1172
+ onClick: (c) => {
1173
+ d.onBack && (c.preventDefault(), d.onBack());
1174
+ },
1175
+ children: [
1176
+ /* @__PURE__ */ e(U, { name: "back" }),
1177
+ " ",
1178
+ d.label
1179
+ ]
1180
+ }
1181
+ ) : null,
1182
+ /* @__PURE__ */ i("div", { className: "cms-page-header__row", children: [
1183
+ /* @__PURE__ */ i("div", { className: "cms-page-header__titles", children: [
1184
+ /* @__PURE__ */ e("h1", { className: "cms-page-header__title", children: n }),
1185
+ l != null ? /* @__PURE__ */ e("p", { className: "cms-page-header__scope", children: l }) : null
1186
+ ] }),
1187
+ t != null ? /* @__PURE__ */ e("div", { className: "cms-page-header__actions", children: t }) : null
1188
+ ] })
1189
+ ] });
1190
+ }
1191
+ function Xn({ tabs: n, active: l, onSelect: t, label: d }) {
1192
+ const c = I([]), r = (m, s) => {
1193
+ var u;
1194
+ const h = n.length - 1, b = m.key === "ArrowRight" ? s === h ? 0 : s + 1 : m.key === "ArrowLeft" ? s === 0 ? h : s - 1 : m.key === "Home" ? 0 : m.key === "End" ? h : null;
1195
+ if (b === null) return;
1196
+ m.preventDefault();
1197
+ const o = n[b];
1198
+ o && (t(o.id), (u = c.current[b]) == null || u.focus());
1199
+ };
1200
+ return /* @__PURE__ */ e("div", { className: "cms-tabs", role: "tablist", "aria-label": d, children: n.map((m, s) => {
1201
+ const h = m.id === l;
1202
+ return /* @__PURE__ */ i(
1203
+ "button",
1204
+ {
1205
+ ref: (b) => {
1206
+ c.current[s] = b;
1207
+ },
1208
+ type: "button",
1209
+ role: "tab",
1210
+ className: T("cms-tab", h && "is-active"),
1211
+ "aria-selected": h,
1212
+ tabIndex: h ? 0 : -1,
1213
+ onClick: () => t(m.id),
1214
+ onKeyDown: (b) => r(b, s),
1215
+ children: [
1216
+ m.label,
1217
+ m.count !== void 0 ? /* @__PURE__ */ e("span", { className: "cms-tab__count", children: m.count }) : null
1218
+ ]
1219
+ },
1220
+ m.id
1221
+ );
1222
+ }) });
1223
+ }
1224
+ function pn(n) {
1225
+ const l = n.trim().replace(/\s+via\s+\S.*$/, "").split(/\s+/).filter(Boolean), t = (c) => {
1226
+ var r;
1227
+ return (r = c == null ? void 0 : c.match(/[\p{L}\p{N}]/u)) == null ? void 0 : r[0];
1228
+ };
1229
+ return (l.length > 1 ? [t(l[0]), t(l[l.length - 1])] : [t(l[0])]).filter(Boolean).join("").toUpperCase();
1230
+ }
1231
+ function bn(n) {
1232
+ let l = 0;
1233
+ for (const t of n.trim().toLowerCase())
1234
+ l = l * 31 + (t.codePointAt(0) ?? 0) >>> 0;
1235
+ return l % 6 + 1;
1236
+ }
1237
+ function ge({ name: n, pictureUrl: l, presence: t, connection: d, deleted: c = !1, size: r = 32 }) {
1238
+ const m = d !== void 0 ? `is-${d.state === "offline" ? "disconnected" : d.state}` : t === void 0 ? null : `is-${t === "busy" ? "away" : t}`, s = d !== void 0 ? `${n}, ${d.label}` : t ? `${n}, ${t}` : n;
1239
+ return /* @__PURE__ */ i(
1240
+ "span",
1241
+ {
1242
+ className: T("cms-avatar", c ? "cms-avatar--deleted" : `cms-avatar--tint-${bn(n)}`),
1243
+ style: { width: r, height: r, fontSize: Math.round(r * 0.4) },
1244
+ role: "img",
1245
+ "aria-label": s,
1246
+ ...d === void 0 ? {} : { title: d.label },
1247
+ children: [
1248
+ c ? /* @__PURE__ */ e(A, { name: "user", size: Math.round(r * 0.6) }) : l ? /* @__PURE__ */ e("img", { src: l, alt: "", className: "cms-avatar__picture" }) : /* @__PURE__ */ e("span", { "aria-hidden": "true", children: pn(n) }),
1249
+ m === null ? null : /* @__PURE__ */ e("span", { className: T("cms-avatar__presence", m), "aria-hidden": "true" })
1250
+ ]
438
1251
  }
439
1252
  );
440
1253
  }
441
- const de = Object.keys(K);
442
- function W({ count: l, label: n, max: a = 99 }) {
443
- return l <= 0 ? null : /* @__PURE__ */ r("span", { className: "cms-badge", children: [
444
- /* @__PURE__ */ e("span", { "aria-hidden": "true", children: l > a ? `${a}+` : l }),
445
- /* @__PURE__ */ e("span", { className: "cms-visually-hidden", children: n })
1254
+ function _n({ count: n, label: l, max: t = 99 }) {
1255
+ return n <= 0 ? null : /* @__PURE__ */ i("span", { className: "cms-badge", children: [
1256
+ /* @__PURE__ */ e("span", { "aria-hidden": "true", children: n > t ? `${t}+` : n }),
1257
+ /* @__PURE__ */ e("span", { className: "cms-visually-hidden", children: l })
446
1258
  ] });
447
1259
  }
448
- function me({ product: l, mark: n, rail: a, active: c, onNavigate: s, server: m, search: t, account: u, children: h }) {
449
- return /* @__PURE__ */ r("div", { className: "cms-shell", children: [
450
- /* @__PURE__ */ r("nav", { className: "cms-shell__rail", "aria-label": "Sections", children: [
451
- /* @__PURE__ */ e("span", { className: "cms-shell__mark", "aria-hidden": "true", children: n }),
452
- /* @__PURE__ */ e("ul", { className: "cms-shell__items", children: a.map((o) => {
453
- const i = o.id === c;
454
- return /* @__PURE__ */ e("li", { children: /* @__PURE__ */ r(
1260
+ function Jn({ product: n, mark: l, rail: t, active: d, onNavigate: c, server: r, search: m, account: s, children: h, railLabel: b = "Sections" }) {
1261
+ return /* @__PURE__ */ i("div", { className: "cms-shell", children: [
1262
+ /* @__PURE__ */ i("nav", { className: "cms-shell__rail", "aria-label": b, children: [
1263
+ /* @__PURE__ */ e("span", { className: "cms-shell__mark", "aria-hidden": "true", children: l }),
1264
+ /* @__PURE__ */ e("ul", { className: "cms-shell__items", children: t.map((o) => {
1265
+ const u = o.id === d;
1266
+ return /* @__PURE__ */ e("li", { children: /* @__PURE__ */ i(
455
1267
  "a",
456
1268
  {
457
1269
  href: o.href,
458
- className: g("cms-shell__item", i && "is-active"),
459
- "aria-current": i ? "page" : void 0,
1270
+ className: T("cms-shell__item", u && "is-active"),
1271
+ "aria-current": u ? "page" : void 0,
460
1272
  title: o.label,
461
- onClick: (f) => {
462
- s && (f.preventDefault(), s(o.id));
1273
+ onClick: (a) => {
1274
+ c && (a.preventDefault(), c(o.id));
463
1275
  },
464
1276
  children: [
465
- /* @__PURE__ */ r("span", { className: "cms-shell__icon", children: [
466
- /* @__PURE__ */ e(y, { name: o.icon, size: 22 }),
467
- o.badge ? /* @__PURE__ */ e(W, { count: o.badge.count, label: o.badge.label }) : null
1277
+ /* @__PURE__ */ i("span", { className: "cms-shell__icon", children: [
1278
+ /* @__PURE__ */ e(A, { name: o.icon, size: 22 }),
1279
+ o.badge ? /* @__PURE__ */ e(_n, { count: o.badge.count, label: o.badge.label }) : null
468
1280
  ] }),
469
1281
  /* @__PURE__ */ e("span", { className: "cms-shell__label", children: o.label })
470
1282
  ]
@@ -472,517 +1284,954 @@ function me({ product: l, mark: n, rail: a, active: c, onNavigate: s, server: m,
472
1284
  ) }, o.id);
473
1285
  }) })
474
1286
  ] }),
475
- /* @__PURE__ */ r("header", { className: "cms-shell__top", children: [
476
- /* @__PURE__ */ e("span", { className: "cms-shell__product", children: l }),
477
- m != null ? /* @__PURE__ */ e("div", { className: "cms-shell__server", children: m }) : null,
478
- t != null ? /* @__PURE__ */ e("div", { className: "cms-shell__search", children: t }) : null,
479
- u != null ? /* @__PURE__ */ e("div", { className: "cms-shell__account", children: u }) : null
1287
+ /* @__PURE__ */ i("header", { className: "cms-shell__top", children: [
1288
+ /* @__PURE__ */ e("span", { className: "cms-shell__product", children: n }),
1289
+ r != null ? /* @__PURE__ */ e("div", { className: "cms-shell__server", children: r }) : null,
1290
+ m != null ? /* @__PURE__ */ e("div", { className: "cms-shell__search", children: m }) : null,
1291
+ s != null ? /* @__PURE__ */ e("div", { className: "cms-shell__account", children: s }) : null
480
1292
  ] }),
481
1293
  /* @__PURE__ */ e("main", { className: "cms-shell__main", children: h })
482
1294
  ] });
483
1295
  }
484
- function ue({ label: l, placeholder: n, value: a, onChange: c, onSearch: s }) {
485
- return /* @__PURE__ */ r(
1296
+ function Qn({ label: n, placeholder: l, value: t, onChange: d, onSearch: c }) {
1297
+ return /* @__PURE__ */ i(
486
1298
  "form",
487
1299
  {
488
1300
  role: "search",
489
1301
  className: "cms-search",
490
- onSubmit: (m) => {
491
- m.preventDefault(), s == null || s(a);
1302
+ onSubmit: (r) => {
1303
+ r.preventDefault(), c == null || c(t);
492
1304
  },
493
1305
  children: [
494
- /* @__PURE__ */ e(y, { name: "search", size: 18 }),
1306
+ /* @__PURE__ */ e(A, { name: "search", size: 18 }),
495
1307
  /* @__PURE__ */ e(
496
1308
  "input",
497
1309
  {
498
1310
  className: "cms-search__input",
499
1311
  type: "search",
500
- "aria-label": l,
501
- placeholder: n,
502
- value: a,
503
- onChange: (m) => c(m.target.value)
1312
+ "aria-label": n,
1313
+ placeholder: l,
1314
+ value: t,
1315
+ onChange: (r) => d(r.target.value)
504
1316
  }
505
1317
  )
506
1318
  ]
507
1319
  }
508
1320
  );
509
1321
  }
510
- function he({ options: l, value: n, onChange: a, label: c }) {
511
- const s = x([]), m = (t, u) => {
512
- var f;
513
- const h = l.length - 1, o = t.key === "ArrowRight" || t.key === "ArrowDown" ? u === h ? 0 : u + 1 : t.key === "ArrowLeft" || t.key === "ArrowUp" ? u === 0 ? h : u - 1 : null;
514
- if (o === null) return;
515
- t.preventDefault();
516
- const i = l[o];
517
- i && (a(i.id), (f = s.current[o]) == null || f.focus());
1322
+ function vn({ options: n, value: l, onChange: t, label: d }) {
1323
+ const c = I([]), r = I(null), [m, s] = E({ start: !1, end: !1 }), h = () => {
1324
+ const u = r.current;
1325
+ if (u === null) return;
1326
+ const a = Math.abs(u.scrollLeft), f = a > 1, p = a + u.clientWidth < u.scrollWidth - 1;
1327
+ s((_) => _.start === f && _.end === p ? _ : { start: f, end: p });
1328
+ };
1329
+ Ne(() => {
1330
+ h();
1331
+ const u = r.current;
1332
+ if (u === null || typeof ResizeObserver > "u") return;
1333
+ const a = new ResizeObserver(h);
1334
+ a.observe(u);
1335
+ for (const f of c.current) f !== null && a.observe(f);
1336
+ return () => a.disconnect();
1337
+ }, [n]);
1338
+ const b = (u) => {
1339
+ var a, f;
1340
+ return (f = (a = c.current[u]) == null ? void 0 : a.scrollIntoView) == null ? void 0 : f.call(a, { block: "nearest", inline: "nearest" });
1341
+ }, o = (u, a) => {
1342
+ var N;
1343
+ const f = n.length - 1, p = u.key === "ArrowRight" || u.key === "ArrowDown" ? a === f ? 0 : a + 1 : u.key === "ArrowLeft" || u.key === "ArrowUp" ? a === 0 ? f : a - 1 : null;
1344
+ if (p === null) return;
1345
+ u.preventDefault();
1346
+ const _ = n[p];
1347
+ _ && (t(_.id), (N = c.current[p]) == null || N.focus(), b(p));
518
1348
  };
519
- return /* @__PURE__ */ e("div", { className: "cms-chips", role: "radiogroup", "aria-label": c, children: l.map((t, u) => {
520
- const h = t.id === n;
521
- return /* @__PURE__ */ r(
1349
+ return /* @__PURE__ */ e("div", { ref: r, className: T("cms-chips", m.start && "is-past-start", m.end && "is-past-end"), role: "radiogroup", "aria-label": d, onScroll: h, "data-scrolls-sideways": "", children: n.map((u, a) => {
1350
+ const f = u.id === l;
1351
+ return /* @__PURE__ */ i(
522
1352
  "button",
523
1353
  {
524
- ref: (o) => {
525
- s.current[u] = o;
1354
+ ref: (p) => {
1355
+ c.current[a] = p;
526
1356
  },
527
1357
  type: "button",
528
1358
  role: "radio",
529
- "aria-checked": h,
530
- tabIndex: h ? 0 : -1,
531
- className: g("cms-chip", h && "is-on"),
532
- onClick: () => a(t.id),
533
- onKeyDown: (o) => m(o, u),
1359
+ "aria-checked": f,
1360
+ tabIndex: f ? 0 : -1,
1361
+ className: T("cms-chip", f && "is-on"),
1362
+ onClick: () => {
1363
+ t(u.id), b(a);
1364
+ },
1365
+ onKeyDown: (p) => o(p, a),
534
1366
  children: [
535
- h ? /* @__PURE__ */ e(y, { name: "check", size: 16 }) : null,
536
- t.label
1367
+ f ? /* @__PURE__ */ e(A, { name: "check", size: 16 }) : null,
1368
+ u.label
537
1369
  ]
538
1370
  },
539
- t.id
1371
+ u.id
540
1372
  );
541
1373
  }) });
542
1374
  }
543
- function fe({ panes: l, active: n, back: a }) {
544
- const c = Math.min(Math.max(n ?? l.length - 1, 0), l.length - 1);
545
- return /* @__PURE__ */ e("div", { className: g("cms-panes", l.length === 3 ? "cms-panes--three" : "cms-panes--two"), "data-active": c, children: l.map((s, m) => /* @__PURE__ */ r("section", { className: "cms-panes__pane", "aria-label": s.label, "data-offset": c - m, children: [
546
- m === c && a ? /* @__PURE__ */ r("a", { className: "cms-panes__back", href: a.href, children: [
547
- /* @__PURE__ */ e(y, { name: "chevron-left", size: 18 }),
548
- a.label
549
- ] }) : null,
550
- s.content
551
- ] }, s.label)) });
1375
+ const De = 16;
1376
+ function gn(n, l, t) {
1377
+ const d = n.map((r) => Math.min(Math.max(r.width, r.min), r.max));
1378
+ let c = d.reduce((r, m) => r + m, 0) + t - l;
1379
+ for (let r = d.length - 1; r >= 0 && c > 0; r -= 1) {
1380
+ const m = Math.min(c, d[r] - n[r].min);
1381
+ d[r] = d[r] - m, c -= m;
1382
+ }
1383
+ return d;
552
1384
  }
553
- function pe({ from: l, subject: n, preview: a, time: c, unread: s, hasAttachment: m, selected: t, onOpen: u }) {
554
- return /* @__PURE__ */ r(
555
- "button",
1385
+ function Nn({ index: n, size: l, shown: t, others: d, room: c, lastMin: r, onResize: m }) {
1386
+ const s = Math.max(l.min, Math.min(l.max, c > 0 ? c - d - r : l.max)), h = (u) => Math.round(Math.min(Math.max(u, l.min), s)), b = I(null), o = (u, a) => m == null ? void 0 : m(n, h(u), a);
1387
+ return /* @__PURE__ */ e(
1388
+ "div",
556
1389
  {
557
- type: "button",
558
- className: g("cms-mail-row", s && "is-unread", t && "is-selected"),
559
- "aria-current": t ? "true" : void 0,
560
- onClick: u,
1390
+ role: "separator",
1391
+ tabIndex: 0,
1392
+ "aria-orientation": "vertical",
1393
+ "aria-label": l.label,
1394
+ "aria-valuenow": t,
1395
+ "aria-valuemin": l.min,
1396
+ "aria-valuemax": s,
1397
+ className: "cms-panes__splitter",
1398
+ style: { "--split-at": `var(--split-pane-end-${String(n)})` },
1399
+ onPointerDown: (u) => {
1400
+ var a, f, p;
1401
+ u.button > 0 || (u.preventDefault(), (f = (a = u.currentTarget).setPointerCapture) == null || f.call(a, u.pointerId), b.current = { x: u.clientX, from: t, last: t }, (p = u.currentTarget.closest(".cms-panes")) == null || p.classList.add("is-resizing"));
1402
+ },
1403
+ onPointerMove: (u) => {
1404
+ const a = b.current;
1405
+ a === null || !Number.isFinite(u.clientX) || (a.last = h(a.from + u.clientX - a.x), o(a.last, !1));
1406
+ },
1407
+ onPointerUp: (u) => {
1408
+ var f;
1409
+ const a = b.current;
1410
+ a !== null && (b.current = null, (f = u.currentTarget.closest(".cms-panes")) == null || f.classList.remove("is-resizing"), o(a.last, !0));
1411
+ },
1412
+ onPointerCancel: (u) => {
1413
+ var f;
1414
+ const a = b.current;
1415
+ b.current = null, (f = u.currentTarget.closest(".cms-panes")) == null || f.classList.remove("is-resizing"), a !== null && o(a.last, !0);
1416
+ },
1417
+ onDoubleClick: () => o(l.reset, !0),
1418
+ onKeyDown: (u) => {
1419
+ const a = u.key === "ArrowLeft" ? t - De : u.key === "ArrowRight" ? t + De : u.key === "Home" ? l.min : u.key === "End" ? s : u.key === "Enter" ? l.reset : null;
1420
+ a !== null && (u.preventDefault(), o(a, !0));
1421
+ }
1422
+ }
1423
+ );
1424
+ }
1425
+ function el({ panes: n, active: l, back: t, sizes: d, lastMin: c = 360, onResize: r }) {
1426
+ const m = Math.min(Math.max(l ?? n.length - 1, 0), n.length - 1), s = I(null), [h, b] = E(0), o = (d ?? []).slice(0, n.length - 1), u = o.length === n.length - 1 && o.every((p) => p !== void 0);
1427
+ Ne(() => {
1428
+ const p = s.current;
1429
+ if (p === null || !u) return;
1430
+ const _ = () => b(p.clientWidth);
1431
+ if (_(), typeof ResizeObserver > "u") return;
1432
+ const N = new ResizeObserver(_);
1433
+ return N.observe(p), () => N.disconnect();
1434
+ }, [u]);
1435
+ const a = u ? gn(o, h > 0 ? h : Number.POSITIVE_INFINITY, c) : [], f = u ? Object.fromEntries(a.flatMap((p, _) => [
1436
+ [`--split-pane-${String(_)}`, `${String(p)}px`],
1437
+ [`--split-pane-end-${String(_)}`, `${String(a.slice(0, _ + 1).reduce((N, y) => N + y, 0))}px`]
1438
+ ])) : void 0;
1439
+ return /* @__PURE__ */ i(
1440
+ "div",
1441
+ {
1442
+ ref: s,
1443
+ className: T("cms-panes", n.length === 3 ? "cms-panes--three" : "cms-panes--two", u && "cms-panes--sized"),
1444
+ "data-active": m,
1445
+ style: f,
561
1446
  children: [
562
- /* @__PURE__ */ e($, { name: l, size: 40 }),
563
- /* @__PURE__ */ r("span", { className: "cms-mail-row__body", children: [
564
- /* @__PURE__ */ r("span", { className: "cms-mail-row__line", children: [
565
- /* @__PURE__ */ e("span", { className: "cms-mail-row__from", children: l }),
566
- m ? /* @__PURE__ */ e(y, { name: "paperclip", size: 16, label: "Has an attachment" }) : null,
567
- /* @__PURE__ */ e("span", { className: "cms-mail-row__time", children: c })
568
- ] }),
569
- /* @__PURE__ */ r("span", { className: "cms-mail-row__line", children: [
570
- /* @__PURE__ */ e("span", { className: "cms-mail-row__subject", children: n }),
571
- s ? /* @__PURE__ */ e("span", { className: "cms-mail-row__dot", role: "img", "aria-label": "Unread" }) : null
572
- ] }),
573
- /* @__PURE__ */ e("span", { className: "cms-mail-row__preview", children: a })
574
- ] })
1447
+ n.map((p, _) => /* @__PURE__ */ i("section", { className: "cms-panes__pane", "aria-label": p.label, "data-offset": m - _, children: [
1448
+ _ === m && t ? /* @__PURE__ */ i("a", { className: "cms-panes__back", href: t.href, children: [
1449
+ /* @__PURE__ */ e(A, { name: "chevron-left", size: 18 }),
1450
+ t.label
1451
+ ] }) : null,
1452
+ p.content
1453
+ ] }, p.label)),
1454
+ u ? o.map((p, _) => /* @__PURE__ */ e(
1455
+ Nn,
1456
+ {
1457
+ index: _,
1458
+ size: p,
1459
+ shown: a[_],
1460
+ others: a.reduce((N, y, x) => x === _ ? N : N + y, 0),
1461
+ room: h,
1462
+ lastMin: c,
1463
+ onResize: r
1464
+ },
1465
+ p.label
1466
+ )) : null
575
1467
  ]
576
1468
  }
577
1469
  );
578
1470
  }
579
- function _e({ direction: l, children: n, time: a, read: c }) {
580
- return /* @__PURE__ */ r("div", { className: g("cms-bubble", `cms-bubble--${l}`), children: [
581
- /* @__PURE__ */ e("div", { className: "cms-bubble__text", children: n }),
582
- /* @__PURE__ */ r("div", { className: "cms-bubble__meta", children: [
1471
+ const yn = { attachment: "Has an attachment", unread: "Unread" };
1472
+ function nl({ from: n, subject: l, preview: t, time: d, unread: c, hasAttachment: r, selected: m, onOpen: s, check: h, selecting: b, labels: o }) {
1473
+ const u = de(yn, o), a = /* @__PURE__ */ e(ge, { name: n, size: 40 });
1474
+ return /* @__PURE__ */ i("div", { className: T("cms-mail-row", c && "is-unread", m && "is-selected", b && "is-selecting", (h == null ? void 0 : h.checked) && "is-checked"), children: [
1475
+ h !== void 0 ? /* @__PURE__ */ i("span", { className: "cms-mail-row__lead", children: [
583
1476
  a,
584
- l === "out" && c ? /* @__PURE__ */ e(b, { children: " · Read" }) : null
1477
+ /* @__PURE__ */ e(
1478
+ "input",
1479
+ {
1480
+ type: "checkbox",
1481
+ className: "cms-mail-row__check",
1482
+ checked: h.checked,
1483
+ disabled: h.disabled,
1484
+ "aria-disabled": h.pending ? "true" : void 0,
1485
+ "aria-busy": h.pending ? "true" : void 0,
1486
+ "aria-label": h.label,
1487
+ onChange: () => {
1488
+ },
1489
+ onClick: (f) => {
1490
+ if (f.stopPropagation(), h.pending) {
1491
+ f.preventDefault();
1492
+ return;
1493
+ }
1494
+ h.onCheck({ shift: f.shiftKey, toggle: f.ctrlKey || f.metaKey });
1495
+ }
1496
+ }
1497
+ )
1498
+ ] }) : null,
1499
+ /* @__PURE__ */ i(
1500
+ "button",
1501
+ {
1502
+ type: "button",
1503
+ className: "cms-mail-row__open",
1504
+ "aria-current": m ? "true" : void 0,
1505
+ onClick: s,
1506
+ children: [
1507
+ h === void 0 ? a : null,
1508
+ /* @__PURE__ */ i("span", { className: "cms-mail-row__body", children: [
1509
+ /* @__PURE__ */ i("span", { className: "cms-mail-row__line", children: [
1510
+ /* @__PURE__ */ e("span", { className: "cms-mail-row__from", children: n }),
1511
+ r ? /* @__PURE__ */ e(A, { name: "paperclip", size: 16, label: u.attachment }) : null,
1512
+ /* @__PURE__ */ e("span", { className: "cms-mail-row__time", children: d })
1513
+ ] }),
1514
+ /* @__PURE__ */ i("span", { className: "cms-mail-row__line", children: [
1515
+ /* @__PURE__ */ e("span", { className: "cms-mail-row__subject", children: l }),
1516
+ c ? /* @__PURE__ */ e("span", { className: "cms-mail-row__dot", role: "img", "aria-label": u.unread }) : null
1517
+ ] }),
1518
+ /* @__PURE__ */ e("span", { className: "cms-mail-row__preview", children: t })
1519
+ ] })
1520
+ ]
1521
+ }
1522
+ )
1523
+ ] });
1524
+ }
1525
+ function ll({ direction: n, children: l, time: t, read: d, readLabel: c = "Read" }) {
1526
+ return /* @__PURE__ */ i("div", { className: T("cms-bubble", `cms-bubble--${n}`), children: [
1527
+ /* @__PURE__ */ e("div", { className: "cms-bubble__text", children: l }),
1528
+ /* @__PURE__ */ i("div", { className: "cms-bubble__meta", children: [
1529
+ t,
1530
+ n === "out" && d ? /* @__PURE__ */ i(M, { children: [
1531
+ " · ",
1532
+ c
1533
+ ] }) : null
585
1534
  ] })
586
1535
  ] });
587
1536
  }
588
- function be({ label: l, value: n, onChange: a, onSend: c, onAttach: s, placeholder: m, variant: t = "chat", sendLabel: u = "Send" }) {
589
- const h = A(), o = n.trim() === "", i = (d) => {
590
- d.preventDefault(), o || c();
591
- }, f = s ? /* @__PURE__ */ e("button", { type: "button", className: "cms-icon-button cms-composer__attach", "aria-label": "Attach a file", onClick: s, children: /* @__PURE__ */ e(y, { name: "paperclip" }) }) : null;
592
- return /* @__PURE__ */ r("form", { className: g("cms-composer", `cms-composer--${t}`), onSubmit: i, children: [
593
- /* @__PURE__ */ e("label", { htmlFor: h, className: t === "reply" ? "cms-composer__title" : "cms-visually-hidden", children: l }),
594
- t === "chat" ? f : null,
1537
+ function tl({ label: n, value: l, onChange: t, onSend: d, onAttach: c, placeholder: r, variant: m = "chat", sendLabel: s = "Send", attachLabel: h = "Attach a file", leading: b, canSend: o }) {
1538
+ const u = Y(), a = o ?? l.trim() !== "", f = (_) => {
1539
+ _.preventDefault(), a && d();
1540
+ }, p = c ? /* @__PURE__ */ e("button", { type: "button", className: "cms-icon-button cms-composer__attach", "aria-label": h, onClick: c, children: /* @__PURE__ */ e(A, { name: "paperclip" }) }) : null;
1541
+ return /* @__PURE__ */ i("form", { className: T("cms-composer", `cms-composer--${m}`), onSubmit: f, children: [
1542
+ /* @__PURE__ */ e("label", { htmlFor: u, className: m === "reply" ? "cms-composer__title" : "cms-visually-hidden", children: n }),
1543
+ m === "chat" ? p : null,
595
1544
  /* @__PURE__ */ e(
596
1545
  "textarea",
597
1546
  {
598
- id: h,
1547
+ id: u,
599
1548
  className: "cms-composer__input",
600
- rows: t === "reply" ? 3 : 1,
601
- placeholder: m,
602
- value: n,
603
- onChange: (d) => a(d.target.value),
604
- onKeyDown: (d) => {
605
- t === "chat" && d.key === "Enter" && !d.shiftKey && (d.preventDefault(), o || c());
1549
+ rows: m === "reply" ? 3 : 1,
1550
+ placeholder: r,
1551
+ value: l,
1552
+ onChange: (_) => t(_.target.value),
1553
+ onKeyDown: (_) => {
1554
+ _.nativeEvent.isComposing || _.keyCode === 229 || m === "chat" && _.key === "Enter" && !_.shiftKey && (_.preventDefault(), a && d());
606
1555
  }
607
1556
  }
608
1557
  ),
609
- t === "reply" ? f : null,
610
- t === "chat" ? /* @__PURE__ */ e("button", { type: "submit", className: "cms-composer__send-round", "aria-label": u, disabled: o, children: /* @__PURE__ */ e(y, { name: "send" }) }) : /* @__PURE__ */ r("button", { type: "submit", className: "cms-button cms-button--chrome cms-composer__send", disabled: o, children: [
611
- u,
1558
+ m === "reply" && b !== void 0 ? /* @__PURE__ */ e("div", { className: "cms-composer__leading", children: b }) : null,
1559
+ m === "reply" ? p : null,
1560
+ m === "chat" ? /* @__PURE__ */ e("button", { type: "submit", className: "cms-composer__send-round", "aria-label": s, disabled: !a, children: /* @__PURE__ */ e(A, { name: "send" }) }) : /* @__PURE__ */ i("button", { type: "submit", className: "cms-button cms-button--chrome cms-composer__send", disabled: !a, children: [
1561
+ s,
612
1562
  " ",
613
- /* @__PURE__ */ e(y, { name: "send", size: 18 })
1563
+ /* @__PURE__ */ e(A, { name: "send", size: 18 })
614
1564
  ] })
615
1565
  ] });
616
1566
  }
617
- function ve({ name: l, media: n, onAccept: a, onDecline: c }) {
618
- const s = n === "video" ? "Incoming video call" : "Incoming audio call";
619
- return /* @__PURE__ */ r("div", { className: "cms-call-incoming", role: "alertdialog", "aria-label": `${s} from ${l}`, children: [
620
- /* @__PURE__ */ e("span", { className: "cms-call-incoming__ring", "aria-hidden": "true", children: /* @__PURE__ */ e($, { name: l, size: 112 }) }),
621
- /* @__PURE__ */ e("p", { className: "cms-call-incoming__name", children: l }),
622
- /* @__PURE__ */ e("p", { className: "cms-call-incoming__what", children: s }),
623
- /* @__PURE__ */ r("div", { className: "cms-call-incoming__actions", children: [
624
- /* @__PURE__ */ e(C, { icon: "phone-off", label: "Decline", tone: "hang-up", onClick: c }),
625
- /* @__PURE__ */ e(C, { icon: "phone", label: "Accept", tone: "accept", onClick: a })
1567
+ const Ae = {
1568
+ incomingAudio: "Incoming audio call",
1569
+ incomingVideo: "Incoming video call",
1570
+ incomingFrom: (n, l) => `${n} from ${l}`,
1571
+ accept: "Accept",
1572
+ decline: "Decline",
1573
+ callWith: (n) => `Call with ${n}`,
1574
+ callTime: (n) => `Call time ${n}`,
1575
+ goodConnection: "Good connection",
1576
+ poorConnection: "Poor connection",
1577
+ you: "You",
1578
+ speaking: "Speaking",
1579
+ mute: "Mute",
1580
+ unmute: "Unmute",
1581
+ speaker: "Speaker",
1582
+ addPerson: "Add person",
1583
+ chat: "Chat",
1584
+ hangUp: "Hang up",
1585
+ onCallWith: (n) => `On a call with ${n}`,
1586
+ returnToCall: "Return to call"
1587
+ };
1588
+ function al({ name: n, media: l, onAccept: t, onDecline: d, labels: c }) {
1589
+ const r = de(Ae, c), m = l === "video" ? r.incomingVideo : r.incomingAudio;
1590
+ return /* @__PURE__ */ i("div", { className: "cms-call-incoming", role: "alertdialog", "aria-label": r.incomingFrom(m, n), children: [
1591
+ /* @__PURE__ */ e("span", { className: "cms-call-incoming__ring", "aria-hidden": "true", children: /* @__PURE__ */ e(ge, { name: n, size: 112 }) }),
1592
+ /* @__PURE__ */ e("p", { className: "cms-call-incoming__name", children: n }),
1593
+ /* @__PURE__ */ e("p", { className: "cms-call-incoming__what", children: m }),
1594
+ /* @__PURE__ */ i("div", { className: "cms-call-incoming__actions", children: [
1595
+ /* @__PURE__ */ e(se, { icon: "phone-off", label: r.decline, tone: "hang-up", onClick: d }),
1596
+ /* @__PURE__ */ e(se, { icon: "phone", label: r.accept, tone: "accept", onClick: t })
626
1597
  ] })
627
1598
  ] });
628
1599
  }
629
- function C({ icon: l, label: n, onClick: a, tone: c = "plain", pressed: s }) {
630
- return /* @__PURE__ */ r(
1600
+ function se({ icon: n, label: l, onClick: t, tone: d = "plain", pressed: c }) {
1601
+ return /* @__PURE__ */ i(
631
1602
  "button",
632
1603
  {
633
1604
  type: "button",
634
- className: g("cms-call-button", `cms-call-button--${c}`, s && "is-pressed"),
635
- "aria-pressed": s,
636
- onClick: a,
1605
+ className: T("cms-call-button", `cms-call-button--${d}`, c && "is-pressed"),
1606
+ "aria-pressed": c,
1607
+ onClick: t,
637
1608
  children: [
638
- /* @__PURE__ */ e("span", { className: "cms-call-button__disc", children: /* @__PURE__ */ e(y, { name: l, size: 24 }) }),
639
- /* @__PURE__ */ e("span", { className: "cms-call-button__label", children: n })
1609
+ /* @__PURE__ */ e("span", { className: "cms-call-button__disc", children: /* @__PURE__ */ e(A, { name: n, size: 24 }) }),
1610
+ /* @__PURE__ */ e("span", { className: "cms-call-button__label", children: l })
640
1611
  ]
641
1612
  }
642
1613
  );
643
1614
  }
644
- function ge({ name: l, duration: n, connection: a, you: c, muted: s, speaker: m, onToggleMute: t, onToggleSpeaker: u, onAddPerson: h, onChat: o, onHangUp: i }) {
645
- return /* @__PURE__ */ r("section", { className: "cms-call-panel", "aria-label": `Call with ${l}`, children: [
646
- /* @__PURE__ */ r("div", { className: "cms-call-panel__head", children: [
647
- /* @__PURE__ */ e($, { name: l, size: 64 }),
648
- /* @__PURE__ */ r("div", { className: "cms-call-panel__who", children: [
649
- /* @__PURE__ */ e("p", { className: "cms-call-panel__name", children: l }),
650
- /* @__PURE__ */ e("p", { className: "cms-call-panel__time", "aria-label": `Call time ${n}`, children: n })
1615
+ function sl({ name: n, duration: l, connection: t, you: d, muted: c, speaker: r, onToggleMute: m, onToggleSpeaker: s, onAddPerson: h, onChat: b, onHangUp: o, labels: u }) {
1616
+ const a = de(Ae, u);
1617
+ return /* @__PURE__ */ i("section", { className: "cms-call-panel", "aria-label": a.callWith(n), children: [
1618
+ /* @__PURE__ */ i("div", { className: "cms-call-panel__head", children: [
1619
+ /* @__PURE__ */ e(ge, { name: n, size: 64 }),
1620
+ /* @__PURE__ */ i("div", { className: "cms-call-panel__who", children: [
1621
+ /* @__PURE__ */ e("p", { className: "cms-call-panel__name", children: n }),
1622
+ /* @__PURE__ */ e("p", { className: "cms-call-panel__time", "aria-label": a.callTime(l), children: l })
651
1623
  ] }),
652
- /* @__PURE__ */ e("span", { className: g("cms-pill", a === "good" ? "cms-pill--success" : "cms-pill--warning"), children: a === "good" ? "Good connection" : "Poor connection" })
1624
+ /* @__PURE__ */ e("span", { className: T("cms-pill", t === "good" ? "cms-pill--success" : "cms-pill--warning"), children: t === "good" ? a.goodConnection : a.poorConnection })
653
1625
  ] }),
654
- /* @__PURE__ */ r("div", { className: "cms-call-panel__you", children: [
655
- /* @__PURE__ */ e($, { name: c.name, size: 36 }),
656
- /* @__PURE__ */ e("span", { children: "You" }),
657
- c.speaking ? /* @__PURE__ */ e("span", { className: "cms-call-panel__level", role: "img", "aria-label": "Speaking" }) : null
1626
+ /* @__PURE__ */ i("div", { className: "cms-call-panel__you", children: [
1627
+ /* @__PURE__ */ e(ge, { name: d.name, size: 36 }),
1628
+ /* @__PURE__ */ e("span", { children: a.you }),
1629
+ d.speaking ? /* @__PURE__ */ e("span", { className: "cms-call-panel__level", role: "img", "aria-label": a.speaking }) : null
658
1630
  ] }),
659
- /* @__PURE__ */ r("div", { className: "cms-call-panel__controls", children: [
660
- /* @__PURE__ */ e(C, { icon: "mic", label: s ? "Unmute" : "Mute", pressed: s, onClick: t }),
661
- /* @__PURE__ */ e(C, { icon: "speaker", label: "Speaker", pressed: m, onClick: u }),
662
- h ? /* @__PURE__ */ e(C, { icon: "user-plus", label: "Add person", onClick: h }) : null,
663
- o ? /* @__PURE__ */ e(C, { icon: "chat", label: "Chat", onClick: o }) : null,
664
- /* @__PURE__ */ e(C, { icon: "phone-off", label: "Hang up", tone: "hang-up", onClick: i })
1631
+ /* @__PURE__ */ i("div", { className: "cms-call-panel__controls", children: [
1632
+ /* @__PURE__ */ e(se, { icon: "mic", label: c ? a.unmute : a.mute, pressed: c, onClick: m }),
1633
+ /* @__PURE__ */ e(se, { icon: "speaker", label: a.speaker, pressed: r, onClick: s }),
1634
+ h ? /* @__PURE__ */ e(se, { icon: "user-plus", label: a.addPerson, onClick: h }) : null,
1635
+ b ? /* @__PURE__ */ e(se, { icon: "chat", label: a.chat, onClick: b }) : null,
1636
+ /* @__PURE__ */ e(se, { icon: "phone-off", label: a.hangUp, tone: "hang-up", onClick: o })
665
1637
  ] })
666
1638
  ] });
667
1639
  }
668
- function Ne({ name: l, duration: n, muted: a, onToggleMute: c, onReturn: s, onHangUp: m }) {
669
- return /* @__PURE__ */ r("section", { className: "cms-call-bar", "aria-label": `Call with ${l}`, children: [
1640
+ function rl({ name: n, duration: l, muted: t, onToggleMute: d, onReturn: c, onHangUp: r, labels: m }) {
1641
+ const s = de(Ae, m);
1642
+ return /* @__PURE__ */ i("section", { className: "cms-call-bar", "aria-label": s.callWith(n), children: [
670
1643
  /* @__PURE__ */ e("span", { className: "cms-call-bar__live", "aria-hidden": "true" }),
671
- /* @__PURE__ */ r("span", { className: "cms-call-bar__name", children: [
672
- "On a call with ",
673
- l
674
- ] }),
675
- /* @__PURE__ */ e("span", { className: "cms-call-bar__time", children: n }),
676
- /* @__PURE__ */ r("span", { className: "cms-call-bar__actions", children: [
677
- /* @__PURE__ */ e("button", { type: "button", className: "cms-call-bar__icon", "aria-label": a ? "Unmute" : "Mute", "aria-pressed": a, onClick: c, children: /* @__PURE__ */ e(y, { name: "mic" }) }),
678
- /* @__PURE__ */ e("button", { type: "button", className: "cms-button cms-button--primary", onClick: s, children: "Return to call" }),
679
- /* @__PURE__ */ e("button", { type: "button", className: "cms-call-bar__icon cms-call-bar__icon--hang-up", "aria-label": "Hang up", onClick: m, children: /* @__PURE__ */ e(y, { name: "phone-off" }) })
1644
+ /* @__PURE__ */ e("span", { className: "cms-call-bar__name", children: s.onCallWith(n) }),
1645
+ /* @__PURE__ */ e("span", { className: "cms-call-bar__time", children: l }),
1646
+ /* @__PURE__ */ i("span", { className: "cms-call-bar__actions", children: [
1647
+ /* @__PURE__ */ e("button", { type: "button", className: "cms-call-bar__icon", "aria-label": t ? s.unmute : s.mute, "aria-pressed": t, onClick: d, children: /* @__PURE__ */ e(A, { name: "mic" }) }),
1648
+ /* @__PURE__ */ e("button", { type: "button", className: "cms-button cms-button--primary", onClick: c, children: s.returnToCall }),
1649
+ /* @__PURE__ */ e("button", { type: "button", className: "cms-call-bar__icon cms-call-bar__icon--hang-up", "aria-label": s.hangUp, onClick: r, children: /* @__PURE__ */ e(A, { name: "phone-off" }) })
680
1650
  ] })
681
1651
  ] });
682
1652
  }
683
- function ye({ mark: l, product: n, headline: a, lead: c, features: s = [], children: m }) {
684
- return /* @__PURE__ */ r("div", { className: "cms-signin", children: [
685
- /* @__PURE__ */ r("aside", { className: "cms-signin__brand", children: [
686
- /* @__PURE__ */ r("p", { className: "cms-signin__logo", children: [
687
- /* @__PURE__ */ e("span", { className: "cms-signin__mark", "aria-hidden": "true", children: l }),
688
- n
1653
+ function cl({ mark: n, product: l, headline: t, lead: d, features: c = [], children: r }) {
1654
+ return /* @__PURE__ */ i("div", { className: "cms-signin", children: [
1655
+ /* @__PURE__ */ i("aside", { className: "cms-signin__brand", children: [
1656
+ /* @__PURE__ */ i("p", { className: "cms-signin__logo", children: [
1657
+ /* @__PURE__ */ e("span", { className: "cms-signin__mark", "aria-hidden": "true", children: n }),
1658
+ l
689
1659
  ] }),
690
- /* @__PURE__ */ r("div", { className: "cms-signin__pitch", children: [
691
- /* @__PURE__ */ e("p", { className: "cms-signin__headline", children: a }),
692
- /* @__PURE__ */ e("p", { className: "cms-signin__lead", children: c }),
693
- s.length ? /* @__PURE__ */ e("ul", { className: "cms-signin__features", children: s.map((t) => /* @__PURE__ */ r("li", { children: [
694
- /* @__PURE__ */ e(y, { name: t.icon, size: 18 }),
695
- t.label
696
- ] }, t.label)) }) : null
1660
+ /* @__PURE__ */ i("div", { className: "cms-signin__pitch", children: [
1661
+ /* @__PURE__ */ e("p", { className: "cms-signin__headline", children: t }),
1662
+ /* @__PURE__ */ e("p", { className: "cms-signin__lead", children: d }),
1663
+ c.length ? /* @__PURE__ */ e("ul", { className: "cms-signin__features", children: c.map((m) => /* @__PURE__ */ i("li", { children: [
1664
+ /* @__PURE__ */ e(A, { name: m.icon, size: 18 }),
1665
+ m.label
1666
+ ] }, m.label)) }) : null
697
1667
  ] })
698
1668
  ] }),
699
- /* @__PURE__ */ e("main", { className: "cms-signin__form", children: m })
1669
+ /* @__PURE__ */ e("main", { className: "cms-signin__form", children: r })
700
1670
  ] });
701
1671
  }
702
- function we({ server: l, onSubmit: n, forgotHref: a, createHref: c, error: s, busy: m }) {
703
- const t = A(), [u, h] = M(""), [o, i] = M(""), [f, d] = M(!1);
704
- return /* @__PURE__ */ r("form", { className: "cms-signin-form", onSubmit: (_) => {
705
- _.preventDefault(), n(u, o);
706
- }, "aria-describedby": s ? `${t}-error` : void 0, children: [
707
- /* @__PURE__ */ e("h1", { className: "cms-signin-form__title", children: "Sign in" }),
708
- /* @__PURE__ */ r("p", { className: "cms-signin-form__server", children: [
709
- /* @__PURE__ */ e(y, { name: "server", size: 18 }),
710
- l
1672
+ const wn = {
1673
+ title: "Sign in",
1674
+ identifier: "Email or username",
1675
+ identifierPlaceholder: "name@example.com",
1676
+ password: "Password",
1677
+ show: "Show",
1678
+ hide: "Hide",
1679
+ forgot: "Forgot password?",
1680
+ submit: "Sign in",
1681
+ newHere: "New here?",
1682
+ create: "Create an account"
1683
+ };
1684
+ function il({ server: n, onSubmit: l, forgotHref: t, createHref: d, error: c, busy: r, labels: m }) {
1685
+ const s = de(wn, m), h = Y(), [b, o] = E(""), [u, a] = E(""), [f, p] = E(!1);
1686
+ return /* @__PURE__ */ i("form", { className: "cms-signin-form", onSubmit: (N) => {
1687
+ N.preventDefault(), l(b, u);
1688
+ }, "aria-describedby": c ? `${h}-error` : void 0, children: [
1689
+ /* @__PURE__ */ e("h1", { className: "cms-signin-form__title", children: s.title }),
1690
+ /* @__PURE__ */ i("p", { className: "cms-signin-form__server", children: [
1691
+ /* @__PURE__ */ e(A, { name: "server", size: 18 }),
1692
+ n
711
1693
  ] }),
712
- /* @__PURE__ */ e("label", { className: "cms-signin-form__label", htmlFor: `${t}-identifier`, children: "Email or username" }),
1694
+ /* @__PURE__ */ e("label", { className: "cms-signin-form__label", htmlFor: `${h}-identifier`, children: s.identifier }),
713
1695
  /* @__PURE__ */ e(
714
1696
  "input",
715
1697
  {
716
- id: `${t}-identifier`,
717
- className: "cms-field",
1698
+ id: `${h}-identifier`,
1699
+ className: "cms-signin-form__input",
718
1700
  type: "text",
719
1701
  autoComplete: "username",
720
- placeholder: "name@example.com",
721
- value: u,
722
- onChange: (_) => h(_.target.value),
1702
+ placeholder: s.identifierPlaceholder,
1703
+ value: b,
1704
+ onChange: (N) => o(N.target.value),
723
1705
  required: !0
724
1706
  }
725
1707
  ),
726
- /* @__PURE__ */ e("label", { className: "cms-signin-form__label", htmlFor: `${t}-password`, children: "Password" }),
727
- /* @__PURE__ */ r("span", { className: "cms-signin-form__password", children: [
1708
+ /* @__PURE__ */ e("label", { className: "cms-signin-form__label", htmlFor: `${h}-password`, children: s.password }),
1709
+ /* @__PURE__ */ i("span", { className: "cms-signin-form__password", children: [
728
1710
  /* @__PURE__ */ e(
729
1711
  "input",
730
1712
  {
731
- id: `${t}-password`,
732
- className: "cms-field",
1713
+ id: `${h}-password`,
1714
+ className: "cms-signin-form__input",
733
1715
  type: f ? "text" : "password",
734
1716
  autoComplete: "current-password",
735
- value: o,
736
- onChange: (_) => i(_.target.value),
1717
+ value: u,
1718
+ onChange: (N) => a(N.target.value),
737
1719
  required: !0
738
1720
  }
739
1721
  ),
740
- /* @__PURE__ */ e("button", { type: "button", className: "cms-signin-form__show", "aria-pressed": f, onClick: () => d((_) => !_), children: f ? "Hide" : "Show" })
1722
+ /* @__PURE__ */ e("button", { type: "button", className: "cms-signin-form__show", "aria-pressed": f, onClick: () => p((N) => !N), children: f ? s.hide : s.show })
741
1723
  ] }),
742
- a ? /* @__PURE__ */ e("a", { className: "cms-signin-form__forgot", href: a, children: "Forgot password?" }) : null,
743
- s ? /* @__PURE__ */ e("p", { id: `${t}-error`, className: "cms-signin-form__error", role: "alert", children: s }) : null,
744
- /* @__PURE__ */ e("button", { type: "submit", className: "cms-button cms-button--chrome cms-signin-form__submit", disabled: m, "aria-busy": m || void 0, children: "Sign in" }),
745
- c ? /* @__PURE__ */ r(b, { children: [
746
- /* @__PURE__ */ e("p", { className: "cms-signin-form__or", children: /* @__PURE__ */ e("span", { children: "New here?" }) }),
747
- /* @__PURE__ */ e("a", { className: "cms-button cms-signin-form__create", href: c, children: "Create an account" })
1724
+ t ? /* @__PURE__ */ e("a", { className: "cms-signin-form__forgot", href: t, children: s.forgot }) : null,
1725
+ c ? /* @__PURE__ */ e("p", { id: `${h}-error`, className: "cms-signin-form__error", role: "alert", children: c }) : null,
1726
+ /* @__PURE__ */ e("button", { type: "submit", className: "cms-button cms-button--chrome cms-signin-form__submit", disabled: r, "aria-busy": r || void 0, children: s.submit }),
1727
+ d ? /* @__PURE__ */ i(M, { children: [
1728
+ /* @__PURE__ */ e("p", { className: "cms-signin-form__or", children: /* @__PURE__ */ e("span", { children: s.newHere }) }),
1729
+ /* @__PURE__ */ e("a", { className: "cms-button cms-signin-form__create", href: d, children: s.create })
748
1730
  ] }) : null
749
1731
  ] });
750
1732
  }
751
- function ke({ label: l, rows: n, error: a, onRetry: c, loadingText: s = "Loading", emptyTitle: m = "Nothing here yet", emptyHint: t, selected: u, onOpen: h, onRowMenu: o }) {
752
- const i = x([]);
753
- if (a != null) return /* @__PURE__ */ e(j, { message: a, onRetry: c });
754
- if (n === null) return /* @__PURE__ */ e(P, { what: s, layout: "block" });
755
- if (n.length === 0) return /* @__PURE__ */ e(V, { title: m, hint: t });
756
- const f = (d, v, _) => {
757
- var p;
758
- if (d.key === "ArrowDown" || d.key === "ArrowUp")
759
- d.preventDefault(), (p = i.current[Math.min(n.length - 1, Math.max(0, v + (d.key === "ArrowDown" ? 1 : -1)))]) == null || p.focus();
760
- else if (d.key === "Enter")
761
- h == null || h(_);
762
- else if ((d.key === "ContextMenu" || d.shiftKey && d.key === "F10") && o) {
763
- d.preventDefault();
764
- const N = d.currentTarget.getBoundingClientRect();
765
- o(_, { x: N.left + 16, y: N.bottom });
1733
+ const $e = { bare: /* @__PURE__ */ new Set(), hidden: /* @__PURE__ */ new Set() }, Pe = (n, l) => n.size === l.size && [...n].every((t) => l.has(t));
1734
+ function kn(n) {
1735
+ const l = /* @__PURE__ */ new Map();
1736
+ for (const t of n) l.set(t.group, [...l.get(t.group) ?? [], t]);
1737
+ return [...l.values()];
1738
+ }
1739
+ function xn(n) {
1740
+ const l = /* @__PURE__ */ new Map();
1741
+ for (const t of n) t.overflow !== void 0 && t.overflow !== 0 && l.set(t.overflow, [...l.get(t.overflow) ?? [], t.id]);
1742
+ return [...l.entries()].sort(([t], [d]) => t - d).map(([, t]) => t);
1743
+ }
1744
+ function ol({ label: n, actions: l, onAction: t, status: d, moreLabel: c, leading: r }) {
1745
+ const m = I(null), s = I(null), [h, b] = E($e), [o, u] = E(null), [a, f] = E("first"), [p, _] = E(null), [N, y] = E(null), x = kn(l), C = xn(l), S = x.flat(), F = S.filter((g) => g.overflow === 0), R = S.filter((g) => g.overflow !== 0), Q = JSON.stringify([l.map((g) => [g.id, g.label, g.icon, g.group, g.overflow ?? null]), d ?? "", r !== void 0]), G = _e(() => {
1746
+ const g = m.current, D = s.current;
1747
+ if (g === null || D === null) return;
1748
+ const V = getComputedStyle(g), ee = parseFloat(V.columnGap || "0") || 0, L = g.clientWidth - (parseFloat(V.paddingLeft) || 0) - (parseFloat(V.paddingRight) || 0), X = (P) => {
1749
+ var O;
1750
+ return ((O = D.querySelector(P)) == null ? void 0 : O.getBoundingClientRect().width) ?? 0;
1751
+ }, oe = X('[data-measure="leading"]'), ye = X('[data-measure="separator"]'), me = X('[data-measure="more"]'), he = (P, O) => X(`[data-measure="${O ? "full" : "icon"}"][data-measure-action="${CSS.escape(P)}"]`), ne = (P, O) => {
1752
+ const J = /* @__PURE__ */ new Set([...F.map((ae) => ae.id), ...O]), re = x.map((ae) => ae.filter((pe) => !J.has(pe.id))).filter((ae) => ae.length > 0), fe = re.flat(), He = fe.length + (re.length - 1) + (J.size > 0 ? 1 : 0) + (oe > 0 ? 1 : 0);
1753
+ return oe + fe.reduce((ae, pe) => ae + he(pe.id, !P.has(pe.id)), 0) + ye * Math.max(0, re.length - 1) + (J.size > 0 ? me : 0) + ee * Math.max(0, He - 1);
1754
+ }, v = R.filter((P) => !C.some((O) => O.includes(P.id))).map((P) => P.id), k = [...C, ...[...v].reverse().map((P) => [P])];
1755
+ let $ = null;
1756
+ if (ne(/* @__PURE__ */ new Set(), /* @__PURE__ */ new Set()) <= L) $ = $e;
1757
+ else {
1758
+ const P = /* @__PURE__ */ new Set();
1759
+ for (const O of k) {
1760
+ for (const J of O) P.add(J);
1761
+ if (ne(P, /* @__PURE__ */ new Set()) <= L) {
1762
+ $ = { bare: P, hidden: /* @__PURE__ */ new Set() };
1763
+ break;
1764
+ }
1765
+ }
766
1766
  }
1767
+ if ($ === null) {
1768
+ const P = new Set(R.map((J) => J.id)), O = /* @__PURE__ */ new Set();
1769
+ for (const J of C) {
1770
+ for (const re of J) R.some((fe) => fe.id === re) && O.add(re);
1771
+ if (O.size >= 2 && ne(P, O) <= L) break;
1772
+ }
1773
+ if (ne(P, O) > L) {
1774
+ for (const J of [...v].reverse())
1775
+ if (O.add(J), ne(P, O) <= L) break;
1776
+ }
1777
+ $ = { bare: P, hidden: O };
1778
+ }
1779
+ const K = $;
1780
+ b((P) => Pe(P.bare, K.bare) && Pe(P.hidden, K.hidden) ? P : K);
1781
+ }, [Q]);
1782
+ Ne(G, [G]), q(() => {
1783
+ const g = m.current;
1784
+ if (g === null || typeof ResizeObserver > "u") return;
1785
+ const D = new ResizeObserver(() => G());
1786
+ return D.observe(g), () => D.disconnect();
1787
+ }, [G]);
1788
+ const w = /* @__PURE__ */ new Set([...F.map((g) => g.id), ...h.hidden]), Z = x.map((g) => g.filter((D) => !w.has(D.id))).filter((g) => g.length > 0).flat(), z = [
1789
+ ...F,
1790
+ ...C.flat().map((g) => S.find((D) => D.id === g)).filter((g) => g !== void 0 && h.hidden.has(g.id)),
1791
+ // The pinned that a row too narrow for them sent behind ..., in the row's order.
1792
+ ...R.filter((g) => h.hidden.has(g.id) && !C.some((D) => D.includes(g.id)))
1793
+ ], H = new Set(R.filter((g) => !C.some((D) => D.includes(g.id))).map((g) => g.id)), W = [...Z.map((g) => g.id), ...z.length > 0 ? ["more"] : []], j = p !== null && W.includes(p) ? p : W[0] ?? null, ie = (g) => {
1794
+ var L, X;
1795
+ const D = W.indexOf(j ?? "");
1796
+ let V = null;
1797
+ if (g.key === "ArrowRight" ? V = Math.min(W.length - 1, D + 1) : g.key === "ArrowLeft" ? V = Math.max(0, D - 1) : g.key === "Home" ? V = 0 : g.key === "End" ? V = W.length - 1 : g.key === "Escape" && y(j), V === null) return;
1798
+ g.preventDefault();
1799
+ const ee = W[V] ?? null;
1800
+ _(ee), (X = (L = m.current) == null ? void 0 : L.querySelector(`[data-stop="${CSS.escape(ee ?? "")}"]`)) == null || X.focus();
1801
+ }, ue = z.map((g) => ({
1802
+ id: g.id,
1803
+ label: /* @__PURE__ */ i(M, { children: [
1804
+ /* @__PURE__ */ e(be, { name: g.icon }),
1805
+ g.label
1806
+ ] }),
1807
+ offer: g.disabled ? { offered: !0, locked: !1, refusal: g.reason ?? "" } : { offered: !0, locked: !1 },
1808
+ ...g.danger ? { danger: !0 } : {},
1809
+ onSelect: () => {
1810
+ !g.disabled && !g.busy && t(g.id);
1811
+ }
1812
+ }));
1813
+ return /* @__PURE__ */ i(
1814
+ "div",
1815
+ {
1816
+ ref: m,
1817
+ role: "toolbar",
1818
+ "aria-label": n,
1819
+ className: T(
1820
+ "cms-pane-toolbar",
1821
+ R.length > 0 && h.bare.size >= R.length && "cms-pane-toolbar--labels-hidden",
1822
+ h.bare.size > 0 && h.bare.size < R.length && "cms-pane-toolbar--labels-partly-hidden"
1823
+ ),
1824
+ onKeyDown: ie,
1825
+ children: [
1826
+ r !== void 0 ? /* @__PURE__ */ e("div", { className: "cms-pane-toolbar__leading", children: r }) : null,
1827
+ x.map((g, D) => {
1828
+ const V = g.filter((L) => !w.has(L.id)), ee = x.slice(0, D).some((L) => L.some((X) => !w.has(X.id)));
1829
+ return /* @__PURE__ */ i("div", { className: "cms-pane-toolbar__group-wrap", children: [
1830
+ V.length > 0 && ee ? /* @__PURE__ */ e("span", { className: "cms-pane-toolbar__separator", role: "separator", "aria-orientation": "vertical" }) : null,
1831
+ /* @__PURE__ */ e("div", { className: "cms-pane-toolbar__group", hidden: V.length === 0, children: g.map((L) => /* @__PURE__ */ e(
1832
+ Mn,
1833
+ {
1834
+ action: L,
1835
+ labels: !h.bare.has(L.id),
1836
+ overflowed: w.has(L.id),
1837
+ pinned: H.has(L.id),
1838
+ tabbable: j === L.id,
1839
+ tipOff: N === L.id,
1840
+ onChoose: () => t(L.id),
1841
+ onFocus: () => {
1842
+ _(L.id), y(null);
1843
+ }
1844
+ },
1845
+ L.id
1846
+ )) })
1847
+ ] }, D);
1848
+ }),
1849
+ z.length > 0 ? /* @__PURE__ */ e(
1850
+ "button",
1851
+ {
1852
+ type: "button",
1853
+ className: "cms-icon-button cms-pane-toolbar__more",
1854
+ "data-stop": "more",
1855
+ "aria-label": c,
1856
+ title: c,
1857
+ "aria-haspopup": "menu",
1858
+ "aria-expanded": o !== null,
1859
+ tabIndex: j === "more" ? 0 : -1,
1860
+ onFocus: () => _("more"),
1861
+ onClick: (g) => {
1862
+ const D = g.currentTarget.getBoundingClientRect();
1863
+ f("first"), u(o === null ? { x: D.left, y: D.bottom } : null);
1864
+ },
1865
+ onKeyDown: (g) => {
1866
+ if (g.key === "ArrowDown" || g.key === "ArrowUp") {
1867
+ g.preventDefault(), g.stopPropagation();
1868
+ const D = g.currentTarget.getBoundingClientRect();
1869
+ f(g.key === "ArrowUp" ? "last" : "first"), u({ x: D.left, y: D.bottom });
1870
+ }
1871
+ },
1872
+ children: /* @__PURE__ */ e(A, { name: "more" })
1873
+ }
1874
+ ) : null,
1875
+ d !== void 0 ? /* @__PURE__ */ e("span", { className: "cms-pane-toolbar__status", title: d, children: d }) : null,
1876
+ /* @__PURE__ */ e(ve, { at: o, items: ue, onClose: () => u(null), label: c, focus: a }),
1877
+ /* @__PURE__ */ i("div", { ref: s, className: "cms-pane-toolbar__measure", "aria-hidden": "true", children: [
1878
+ r !== void 0 ? /* @__PURE__ */ e("div", { "data-measure": "leading", children: r }) : null,
1879
+ /* @__PURE__ */ e("span", { "data-measure": "separator", className: "cms-pane-toolbar__separator" }),
1880
+ /* @__PURE__ */ e("span", { "data-measure": "more", className: "cms-icon-button cms-pane-toolbar__more", children: /* @__PURE__ */ e(A, { name: "more" }) }),
1881
+ S.map((g) => /* @__PURE__ */ i("span", { children: [
1882
+ /* @__PURE__ */ i("span", { "data-measure": "full", "data-measure-action": g.id, className: "cms-pane-toolbar__action", children: [
1883
+ /* @__PURE__ */ e(be, { name: g.icon }),
1884
+ /* @__PURE__ */ e("span", { className: "cms-pane-toolbar__label", children: g.label })
1885
+ ] }),
1886
+ /* @__PURE__ */ e("span", { "data-measure": "icon", "data-measure-action": g.id, className: T("cms-pane-toolbar__action", ce(g.icon) !== null && "cms-pane-toolbar__action--bare"), children: ce(g.icon) !== null ? /* @__PURE__ */ e(be, { name: g.icon }) : /* @__PURE__ */ e("span", { className: "cms-pane-toolbar__label", children: g.label }) })
1887
+ ] }, g.id))
1888
+ ] })
1889
+ ]
1890
+ }
1891
+ );
1892
+ }
1893
+ function Mn({ action: n, labels: l, overflowed: t, pinned: d, tabbable: c, tipOff: r, onChoose: m, onFocus: s }) {
1894
+ const [h, b] = E(!1);
1895
+ q(() => {
1896
+ if (!n.busy) {
1897
+ b(!1);
1898
+ return;
1899
+ }
1900
+ const y = setTimeout(() => b(!0), ke);
1901
+ return () => clearTimeout(y);
1902
+ }, [n.busy]);
1903
+ const o = ce(n.icon) === null, u = l || o, a = n.disabled && n.reason ? n.reason : null, f = a ?? (u ? null : n.label), p = Y(), [_, N] = E(!1);
1904
+ return /* @__PURE__ */ i(
1905
+ "button",
1906
+ {
1907
+ type: "button",
1908
+ className: T("cms-pane-toolbar__action", !u && "cms-pane-toolbar__action--bare", o && "cms-pane-toolbar__action--text", n.danger && "is-danger"),
1909
+ "data-action": n.id,
1910
+ "data-stop": n.id,
1911
+ ...t ? { "data-overflowed": "" } : {},
1912
+ ...d ? { "data-pinned": "" } : {},
1913
+ hidden: t,
1914
+ "aria-label": n.label,
1915
+ "aria-disabled": n.disabled || void 0,
1916
+ "aria-busy": n.busy || void 0,
1917
+ ...a === null ? {} : { "aria-describedby": p },
1918
+ ..._ && a !== null ? { "data-reason-shown": "" } : {},
1919
+ tabIndex: c ? 0 : -1,
1920
+ onFocus: s,
1921
+ onBlur: () => N(!1),
1922
+ onKeyDown: (y) => {
1923
+ y.key === "Escape" && N(!1);
1924
+ },
1925
+ onClick: () => {
1926
+ a !== null ? N(!0) : !n.disabled && !n.busy && m();
1927
+ },
1928
+ children: [
1929
+ h ? /* @__PURE__ */ e(U, { name: "spinner" }) : /* @__PURE__ */ e(be, { name: n.icon }),
1930
+ u ? /* @__PURE__ */ e("span", { className: "cms-pane-toolbar__label", "aria-hidden": "true", children: n.label }) : null,
1931
+ a !== null || f !== null && !r ? /* @__PURE__ */ e("span", { className: "cms-pane-toolbar__tip", role: "tooltip", id: p, children: f }) : null
1932
+ ]
1933
+ }
1934
+ );
1935
+ }
1936
+ function be({ name: n }) {
1937
+ const l = ce(n);
1938
+ return l === null ? null : /* @__PURE__ */ e(A, { name: l, size: 18 });
1939
+ }
1940
+ function dl({ title: n, body: l = null, time: t = null, unread: d, unreadLabel: c, expandLabel: r, collapseLabel: m, action: s = null, onRead: h, leading: b }) {
1941
+ const [o, u] = E(!1), a = Y(), f = () => {
1942
+ d && h();
1943
+ }, p = (s == null ? void 0 : s.presentation) === "row" && s.onAction !== void 0, _ = (s == null ? void 0 : s.presentation) === "button" && s.onAction !== void 0 ? s : null, N = () => {
1944
+ var y;
1945
+ f(), p && ((y = s.onAction) == null || y.call(s));
767
1946
  };
768
- return /* @__PURE__ */ e("ul", { className: "cms-list", role: "listbox", "aria-label": l, children: n.map((d, v) => {
769
- const _ = d.id === u;
770
- return /* @__PURE__ */ r(
771
- "li",
1947
+ return /* @__PURE__ */ i("article", { className: T("cms-notification", d && "is-unread", o && "is-expanded", p && "is-row-action"), "data-state": d ? "unread" : "read", children: [
1948
+ /* @__PURE__ */ i(
1949
+ "div",
772
1950
  {
773
- ref: (p) => {
774
- i.current[v] = p;
1951
+ className: "cms-notification__row",
1952
+ role: "button",
1953
+ tabIndex: 0,
1954
+ "aria-describedby": l === null ? void 0 : a,
1955
+ onClick: N,
1956
+ onKeyDown: (y) => {
1957
+ y.target !== y.currentTarget || y.key !== "Enter" && y.key !== " " || (y.preventDefault(), N());
775
1958
  },
776
- role: "option",
777
- "aria-selected": _,
778
- tabIndex: _ || u == null && v === 0 ? 0 : -1,
779
- className: g("cms-list__row", _ && "is-selected"),
780
- onClick: () => h == null ? void 0 : h(d.id),
781
- onKeyDown: (p) => f(p, v, d.id),
782
- onContextMenu: o ? (p) => {
783
- p.preventDefault(), o(d.id, { x: p.clientX, y: p.clientY });
784
- } : void 0,
785
1959
  children: [
786
- d.lead != null ? /* @__PURE__ */ e("span", { className: "cms-list__lead", children: d.lead }) : null,
787
- /* @__PURE__ */ r("span", { className: "cms-list__text", children: [
788
- /* @__PURE__ */ e("span", { className: "cms-list__primary", children: d.primary }),
789
- d.secondary != null ? /* @__PURE__ */ e("span", { className: "cms-list__secondary", children: d.secondary }) : null
1960
+ b != null ? /* @__PURE__ */ e("span", { className: "cms-notification__leading", children: b }) : null,
1961
+ /* @__PURE__ */ i("span", { className: "cms-notification__text", children: [
1962
+ /* @__PURE__ */ i("span", { className: "cms-notification__head", children: [
1963
+ /* @__PURE__ */ i("span", { className: "cms-notification__title", children: [
1964
+ d ? /* @__PURE__ */ i("span", { className: "cms-visually-hidden", children: [
1965
+ c,
1966
+ " "
1967
+ ] }) : null,
1968
+ n
1969
+ ] }),
1970
+ t !== null ? /* @__PURE__ */ e("span", { className: "cms-notification__time", children: t }) : null
1971
+ ] }),
1972
+ l !== null && l !== "" ? /* @__PURE__ */ e("span", { className: "cms-notification__body", id: a, children: l }) : null
790
1973
  ] }),
791
- d.meta != null ? /* @__PURE__ */ e("span", { className: "cms-list__meta", children: d.meta }) : null
1974
+ d ? /* @__PURE__ */ e("span", { className: "cms-notification__dot", "aria-hidden": "true" }) : null
792
1975
  ]
793
- },
794
- d.id
795
- );
796
- }) });
797
- }
798
- function Me({ at: l, items: n, onClose: a, label: c = "Actions" }) {
799
- const s = x(null), m = x(null), [t, u] = M(l), h = n.filter((i) => i.offer.offered);
800
- if (F(() => {
801
- if (!l) return;
802
- const i = s.current, f = (i == null ? void 0 : i.offsetWidth) ?? 0, d = (i == null ? void 0 : i.offsetHeight) ?? 0;
803
- u({ x: Math.max(0, Math.min(l.x, window.innerWidth - f)), y: Math.max(0, Math.min(l.y, window.innerHeight - d)) });
804
- }, [l]), D(() => {
805
- var f, d;
806
- if (!l) return;
807
- m.current = document.activeElement, (d = (f = s.current) == null ? void 0 : f.querySelector('[role="menuitem"]:not([aria-disabled="true"])')) == null || d.focus();
808
- const i = (v) => {
809
- var _;
810
- (_ = s.current) != null && _.contains(v.target) || a();
811
- };
812
- return document.addEventListener("mousedown", i), () => {
813
- var v, _;
814
- document.removeEventListener("mousedown", i), (_ = (v = m.current) == null ? void 0 : v.focus) == null || _.call(v);
815
- };
816
- }, [l, a]), !l || h.length === 0) return null;
817
- const o = (i) => {
818
- var v, _;
819
- const f = Array.from(((v = s.current) == null ? void 0 : v.querySelectorAll('[role="menuitem"]')) ?? []), d = f.indexOf(document.activeElement);
820
- if (i.key === "Escape" || i.key === "Tab")
821
- i.preventDefault(), a();
822
- else if (i.key === "ArrowDown" || i.key === "ArrowUp") {
823
- i.preventDefault();
824
- const p = i.key === "ArrowDown" ? 1 : -1;
825
- (_ = f[(d + p + f.length) % f.length]) == null || _.focus();
826
- }
827
- };
828
- return Z(
829
- /* @__PURE__ */ e(
830
- "div",
831
- {
832
- ref: s,
833
- className: "cms-menu",
834
- role: "menu",
835
- "aria-label": c,
836
- style: { left: (t ?? l).x, top: (t ?? l).y },
837
- onKeyDown: o,
838
- onContextMenu: (i) => i.preventDefault(),
839
- children: h.map((i) => {
840
- const f = i.offer.refusal !== void 0;
841
- return /* @__PURE__ */ r(
842
- "div",
843
- {
844
- role: "menuitem",
845
- tabIndex: -1,
846
- "aria-disabled": f || void 0,
847
- title: f ? i.offer.refusal : void 0,
848
- className: g("cms-menu__item", i.danger && "is-danger", i.offer.locked && "is-locked", f && "is-refused"),
849
- onClick: () => {
850
- f || (a(), i.onSelect());
851
- },
852
- onKeyDown: (d) => {
853
- (d.key === "Enter" || d.key === " ") && !f && (d.preventDefault(), a(), i.onSelect());
854
- },
855
- children: [
856
- i.offer.locked ? /* @__PURE__ */ e(k, { name: "lock" }) : null,
857
- /* @__PURE__ */ e("span", { className: "cms-menu__label", children: i.label }),
858
- f ? /* @__PURE__ */ e("span", { className: "cms-menu__refusal", children: i.offer.refusal }) : null
859
- ]
860
- },
861
- i.id
862
- );
863
- })
864
1976
  }
865
1977
  ),
866
- document.body
867
- );
1978
+ l !== null && l !== "" ? /* @__PURE__ */ e(
1979
+ "button",
1980
+ {
1981
+ type: "button",
1982
+ className: "cms-notification__chevron",
1983
+ "aria-expanded": o,
1984
+ "aria-controls": a,
1985
+ "aria-label": o ? m : r,
1986
+ title: o ? m : r,
1987
+ onClick: () => {
1988
+ o || f(), u((y) => !y);
1989
+ },
1990
+ children: /* @__PURE__ */ e(A, { name: "chevron-down", size: 18 })
1991
+ }
1992
+ ) : null,
1993
+ _ !== null ? /* @__PURE__ */ e(
1994
+ "button",
1995
+ {
1996
+ type: "button",
1997
+ className: "cms-button cms-notification__action",
1998
+ onClick: () => {
1999
+ var y;
2000
+ f(), (y = _.onAction) == null || y.call(_);
2001
+ },
2002
+ children: _.label
2003
+ }
2004
+ ) : null
2005
+ ] });
868
2006
  }
869
- function G(l) {
870
- return l === "allowed" || l === "elevate" || l === "denied";
2007
+ function Cn(n) {
2008
+ return n === "allowed" || n === "elevate" || n === "denied";
871
2009
  }
872
- function xe(l, n) {
873
- if (!G(l))
874
- return n.showRefused ? { offered: !0, locked: !1, refusal: "not available: the server gave an answer this app does not know", unknown: !0 } : { offered: !1, locked: !1, unknown: !0 };
875
- switch (l) {
2010
+ function ul(n, l) {
2011
+ if (!Cn(n))
2012
+ return l.showRefused ? { offered: !0, locked: !1, refusal: "not available: the server gave an answer this app does not know", unknown: !0 } : { offered: !1, locked: !1, unknown: !0 };
2013
+ switch (n) {
876
2014
  case "allowed":
877
2015
  return { offered: !0, locked: !1 };
878
2016
  case "elevate":
879
- return n.elevates ? { offered: !0, locked: !0 } : { offered: !1, locked: !1 };
2017
+ return l.elevates ? { offered: !0, locked: !0 } : { offered: !1, locked: !1 };
880
2018
  case "denied":
881
- return n.showRefused ? { offered: !0, locked: !1, refusal: n.refusal ?? "not allowed" } : { offered: !1, locked: !1 };
2019
+ return l.showRefused ? { offered: !0, locked: !1, refusal: l.refusal ?? "not allowed" } : { offered: !1, locked: !1 };
882
2020
  }
883
2021
  }
884
- function X(l, n) {
885
- if (!l) return;
886
- if (typeof l.get == "function") return l.get(n) ?? void 0;
887
- const a = l, c = Object.keys(a).find((s) => s.toLowerCase() === n.toLowerCase());
888
- return c === void 0 ? void 0 : a[c];
889
- }
890
- function Y(l) {
891
- if (l && typeof l == "object") {
892
- const n = l;
893
- if (typeof n.detail == "string" && n.detail !== "") return n.detail;
894
- if (typeof n.title == "string" && n.title !== "") return n.title;
2022
+ function Sn(n, l) {
2023
+ if (!n) return;
2024
+ if (typeof n.get == "function") return n.get(l) ?? void 0;
2025
+ const t = n, d = Object.keys(t).find((c) => c.toLowerCase() === l.toLowerCase());
2026
+ return d === void 0 ? void 0 : t[d];
2027
+ }
2028
+ function En(n) {
2029
+ if (n && typeof n == "object") {
2030
+ const l = n;
2031
+ if (typeof l.detail == "string" && l.detail !== "") return l.detail;
2032
+ if (typeof l.title == "string" && l.title !== "") return l.title;
895
2033
  }
896
2034
  }
897
- function Ce(l, n, a, c) {
898
- if (l !== 403) return { kind: "none" };
899
- const s = Y(a);
900
- return X(n, "X-Elevation-Required") !== void 0 ? c.elevates ? { kind: "elevation-required", message: s ?? "This needs an elevated session." } : { kind: "refused", message: "This can only be done in the admin, in an elevated session." } : { kind: "refused", message: s ?? "The server refused this." };
901
- }
902
- const S = "coolms-kit:reread";
903
- function Ae() {
904
- window.dispatchEvent(new Event(S));
905
- }
906
- function De(l) {
907
- const [n, a] = M(void 0), [c, s] = M(void 0), [m, t] = M(!0), u = x(l);
908
- u.current = l;
909
- const h = x(0), o = H(() => {
910
- const i = ++h.current;
911
- t(!0), u.current().then(
912
- (f) => {
913
- i === h.current && (a(f), s(void 0), t(!1));
2035
+ function ml(n, l, t, d) {
2036
+ if (n !== 403) return { kind: "none" };
2037
+ const c = En(t);
2038
+ return Sn(l, "X-Elevation-Required") !== void 0 ? d.elevates ? { kind: "elevation-required", message: c ?? "This needs an elevated session." } : { kind: "refused", message: "This can only be done in the admin, in an elevated session." } : { kind: "refused", message: c ?? "The server refused this." };
2039
+ }
2040
+ const Me = "coolms-kit:reread";
2041
+ function hl() {
2042
+ window.dispatchEvent(new Event(Me));
2043
+ }
2044
+ function fl(n) {
2045
+ const [l, t] = E(void 0), [d, c] = E(void 0), [r, m] = E(!0), s = I(n);
2046
+ s.current = n;
2047
+ const h = I(0), b = _e(() => {
2048
+ const o = ++h.current;
2049
+ m(!0), s.current().then(
2050
+ (u) => {
2051
+ o === h.current && (t(u), c(void 0), m(!1));
914
2052
  },
915
- (f) => {
916
- i === h.current && (s(f), t(!1));
2053
+ (u) => {
2054
+ o === h.current && (c(u), m(!1));
917
2055
  }
918
2056
  );
919
2057
  }, []);
920
- return D(() => {
921
- o();
922
- const i = () => o();
923
- return window.addEventListener("focus", i), window.addEventListener(S, i), () => {
924
- window.removeEventListener("focus", i), window.removeEventListener(S, i);
2058
+ return q(() => {
2059
+ b();
2060
+ const o = () => b();
2061
+ return window.addEventListener("focus", o), window.addEventListener(Me, o), () => {
2062
+ window.removeEventListener("focus", o), window.removeEventListener(Me, o);
925
2063
  };
926
- }, [o]), { value: n, error: c, loading: m, reread: o };
2064
+ }, [b]), { value: l, error: d, loading: r, reread: b };
927
2065
  }
928
- function Ee(l) {
929
- return l === 412 ? { conflict: !0, message: "Someone changed this since you opened it. Nothing was saved; read it again to see the change." } : { conflict: !1 };
2066
+ function pl(n) {
2067
+ return n === 412 ? { conflict: !0, message: "Someone changed this since you opened it. Nothing was saved; read it again to see the change." } : { conflict: !1 };
930
2068
  }
931
- const Q = "/errors/client-update-required";
932
- function J(l, n) {
933
- const a = l.split(".").map((s) => Number.parseInt(s, 10) || 0), c = n.split(".").map((s) => Number.parseInt(s, 10) || 0);
934
- for (let s = 0; s < Math.max(a.length, c.length); s++) {
935
- const m = a[s] ?? 0, t = c[s] ?? 0;
936
- if (m !== t) return m < t;
2069
+ const An = "/errors/client-update-required";
2070
+ function Tn(n, l) {
2071
+ const t = n.split(".").map((c) => Number.parseInt(c, 10) || 0), d = l.split(".").map((c) => Number.parseInt(c, 10) || 0);
2072
+ for (let c = 0; c < Math.max(t.length, d.length); c++) {
2073
+ const r = t[c] ?? 0, m = d[c] ?? 0;
2074
+ if (r !== m) return r < m;
937
2075
  }
938
2076
  return !1;
939
2077
  }
940
- function $e(l) {
941
- return l.problemType !== void 0 && l.problemType.endsWith(Q) ? !0 : l.minimumVersion !== void 0 && J(l.version, l.minimumVersion);
2078
+ function bl(n) {
2079
+ return n.problemType !== void 0 && n.problemType.endsWith(An) ? !0 : n.minimumVersion !== void 0 && Tn(n.version, n.minimumVersion);
2080
+ }
2081
+ const Ie = 4, Ln = 48, Dn = 800, $n = /* @__PURE__ */ new Set(["ArrowDown", "ArrowUp", "PageDown", "PageUp", "Home", "End", " "]);
2082
+ function Pn(n, l) {
2083
+ const [t, d] = E(!1);
2084
+ return q(() => {
2085
+ const c = n.current;
2086
+ if (c === null || !l) {
2087
+ d(!1);
2088
+ return;
2089
+ }
2090
+ const r = /* @__PURE__ */ new WeakMap();
2091
+ let m = Number.NEGATIVE_INFINITY, s = null;
2092
+ const h = (a) => {
2093
+ m = performance.now(), s = a.target;
2094
+ }, b = (a) => {
2095
+ const f = a.target;
2096
+ !(f instanceof HTMLElement && (f.isContentEditable || f.closest("input, textarea, select") !== null)) && $n.has(a.key) && h(a);
2097
+ }, o = (a) => {
2098
+ const f = a.target;
2099
+ if (!(f instanceof HTMLElement)) return;
2100
+ const p = f.scrollTop, _ = r.get(f) ?? 0;
2101
+ if (r.set(f, p), p <= 0) {
2102
+ d(!1);
2103
+ return;
2104
+ }
2105
+ performance.now() - m > Dn || !(s === c || s === document.body || s instanceof Node && f.contains(s)) || (p < _ - Ie ? d(!1) : p > _ + Ie && p > Ln && d(!0));
2106
+ }, u = [["wheel", h], ["touchmove", h], ["pointerdown", h], ["keydown", b]];
2107
+ for (const [a, f] of u) c.addEventListener(a, f, { capture: !0, passive: !0 });
2108
+ return c.addEventListener("scroll", o, { capture: !0, passive: !0 }), () => {
2109
+ for (const [a, f] of u) c.removeEventListener(a, f, { capture: !0 });
2110
+ c.removeEventListener("scroll", o, { capture: !0 });
2111
+ };
2112
+ }, [n, l]), [t, d];
2113
+ }
2114
+ function _l({ title: n, back: l, navigation: t, search: d, searching: c, globals: r, filters: m, primary: s, onRefresh: h, pullText: b, barHidden: o, children: u }) {
2115
+ const a = I(null), f = I(null), [p, _] = E(!1), [N, y] = E(null), C = hn(f, h === void 0 ? null : () => {
2116
+ p || (_(!0), h().finally(() => _(!1)));
2117
+ }), S = h === void 0 ? null : { distance: C, refreshing: p, text: b ?? null }, F = c !== void 0 || C > 0 || p, [R, Q] = Pn(a, o === void 0 && !F), G = !F && (o ?? R);
2118
+ return /* @__PURE__ */ i(
2119
+ "div",
2120
+ {
2121
+ ref: a,
2122
+ className: T("cms-screen", s !== void 0 && "cms-screen--with-primary"),
2123
+ "data-bar-hidden": G ? "" : void 0,
2124
+ onFocus: (w) => {
2125
+ G && w.target instanceof Element && w.target.closest(".cms-screen__bar, .cms-screen__filters") !== null && Q(!1);
2126
+ },
2127
+ children: [
2128
+ c !== void 0 ? /* @__PURE__ */ i("header", { className: "cms-screen__bar cms-screen__bar--searching", children: [
2129
+ /* @__PURE__ */ e("button", { type: "button", className: "cms-icon-button cms-screen__icon", "aria-label": c.closeLabel, title: c.closeLabel, onClick: c.onClose, children: /* @__PURE__ */ e(A, { name: "chevron-left" }) }),
2130
+ /* @__PURE__ */ e("div", { className: "cms-screen__search", children: c.field })
2131
+ ] }) : /* @__PURE__ */ i("header", { className: "cms-screen__bar", children: [
2132
+ /* @__PURE__ */ e("div", { className: "cms-screen__leading", children: l !== void 0 ? l.href !== void 0 ? /* @__PURE__ */ i("a", { className: "cms-screen__back", href: l.href, onClick: l.onBack, children: [
2133
+ /* @__PURE__ */ e(A, { name: "chevron-left" }),
2134
+ /* @__PURE__ */ e("span", { className: "cms-screen__back-name", children: l.label })
2135
+ ] }) : /* @__PURE__ */ i("button", { type: "button", className: "cms-screen__back", onClick: l.onBack, children: [
2136
+ /* @__PURE__ */ e(A, { name: "chevron-left" }),
2137
+ /* @__PURE__ */ e("span", { className: "cms-screen__back-name", children: l.label })
2138
+ ] }) : t }),
2139
+ /* @__PURE__ */ e("h1", { className: "cms-screen__title", title: n, children: n }),
2140
+ /* @__PURE__ */ i("div", { className: "cms-screen__trailing", children: [
2141
+ d !== void 0 ? /* @__PURE__ */ e("button", { type: "button", className: "cms-icon-button cms-screen__icon", "aria-label": d.label, title: d.label, onClick: d.onOpen, children: /* @__PURE__ */ e(A, { name: "search" }) }) : null,
2142
+ r
2143
+ ] })
2144
+ ] }),
2145
+ m !== void 0 ? /* @__PURE__ */ e("div", { className: "cms-screen__filters", children: /* @__PURE__ */ e(vn, { label: m.label, options: m.options, value: m.selected, onChange: m.onSelect }) }) : null,
2146
+ /* @__PURE__ */ e("div", { ref: f, className: "cms-screen__content", "data-pulling": C > 0 ? "" : void 0, "data-refreshing": p ? "" : void 0, children: /* @__PURE__ */ e(Re.Provider, { value: S, children: u }) }),
2147
+ s !== void 0 ? /* @__PURE__ */ e(
2148
+ "button",
2149
+ {
2150
+ type: "button",
2151
+ className: "cms-button cms-button--primary cms-screen__primary",
2152
+ "aria-label": s.label,
2153
+ title: s.label,
2154
+ ..."menu" in s ? { "aria-haspopup": "menu", "aria-expanded": N !== null } : {},
2155
+ onClick: (w) => {
2156
+ if ("menu" in s) {
2157
+ const B = w.currentTarget.getBoundingClientRect();
2158
+ y(N === null ? { x: B.left, y: B.top } : null);
2159
+ } else
2160
+ s.onPress();
2161
+ },
2162
+ children: /* @__PURE__ */ e(A, { name: s.icon, size: 24 })
2163
+ }
2164
+ ) : null,
2165
+ s !== void 0 && "menu" in s ? /* @__PURE__ */ e(ve, { at: N, items: s.menu, onClose: () => y(null), label: s.label }) : null
2166
+ ]
2167
+ }
2168
+ );
942
2169
  }
943
2170
  export {
944
- me as AppShell,
945
- $ as Avatar,
946
- W as Badge,
947
- E as Button,
948
- Q as CLIENT_UPDATE_REQUIRED,
949
- Ne as CallBar,
950
- ge as CallPanel,
951
- _e as ChatBubble,
952
- be as Composer,
953
- ce as ConfirmDialog,
954
- Me as ContextMenu,
955
- V as EmptyState,
956
- j as ErrorBanner,
957
- he as FilterChips,
958
- de as ICON_NAMES,
959
- y as Icon,
960
- ve as IncomingCall,
961
- ke as List,
962
- P as Loading,
963
- R as MODAL_CLOSE_MS,
964
- pe as MailRow,
965
- z as Modal,
966
- ie as PageHeader,
967
- ue as SearchField,
968
- ae as Select,
969
- we as SignInForm,
970
- ye as SignInLayout,
971
- fe as SplitPanes,
972
- oe as TabStrip,
973
- ne as TextField,
974
- te as Toast,
975
- re as ToastRegion,
976
- se as Toggle,
977
- q as initialsOf,
978
- G as isCapability,
979
- $e as needsClientUpdate,
980
- xe as offerFor,
981
- Ee as readConflict,
982
- Ce as readRefusal,
983
- Y as refusalText,
984
- Ae as rereadAll,
985
- U as tintOf,
986
- De as useReread,
987
- J as versionBelow
2171
+ Jn as AppShell,
2172
+ ge as Avatar,
2173
+ Te as BOOTSTRAP_ICONS,
2174
+ _n as Badge,
2175
+ te as Button,
2176
+ Ae as CALL_LABELS,
2177
+ An as CLIENT_UPDATE_REQUIRED,
2178
+ rl as CallBar,
2179
+ sl as CallPanel,
2180
+ ll as ChatBubble,
2181
+ tl as Composer,
2182
+ Un as ConfirmDialog,
2183
+ ve as ContextMenu,
2184
+ Ye as EmptyState,
2185
+ Ge as ErrorBanner,
2186
+ jn as FilePicker,
2187
+ cn as FilePickerDenied,
2188
+ on as FilePickerRestart,
2189
+ Wn as FileViewer,
2190
+ vn as FilterChips,
2191
+ Zn as ICON_NAMES,
2192
+ A as Icon,
2193
+ al as IncomingCall,
2194
+ qn as List,
2195
+ qe as Loading,
2196
+ yn as MAIL_ROW_LABELS,
2197
+ je as MODAL_CLOSE_MS,
2198
+ nl as MailRow,
2199
+ Be as Modal,
2200
+ Je as NamedIcon,
2201
+ dl as Notification,
2202
+ xe as PULL_AT,
2203
+ Gn as PageHeader,
2204
+ ol as PaneToolbar,
2205
+ wn as SIGN_IN_LABELS,
2206
+ ke as STATE_DELAY_MS,
2207
+ _l as ScreenShell,
2208
+ Qn as SearchField,
2209
+ Yn as SectionHeader,
2210
+ Kn as Select,
2211
+ il as SignInForm,
2212
+ cl as SignInLayout,
2213
+ el as SplitPanes,
2214
+ le as State,
2215
+ Xn as TabStrip,
2216
+ Hn as TextArea,
2217
+ Rn as TextField,
2218
+ zn as Toast,
2219
+ Vn as ToastRegion,
2220
+ On as Toggle,
2221
+ gn as fitPanes,
2222
+ ce as iconForName,
2223
+ pn as initialsOf,
2224
+ Cn as isCapability,
2225
+ bl as needsClientUpdate,
2226
+ ul as offerFor,
2227
+ pl as readConflict,
2228
+ ml as readRefusal,
2229
+ En as refusalText,
2230
+ hl as rereadAll,
2231
+ bn as tintOf,
2232
+ hn as usePull,
2233
+ fn as usePullState,
2234
+ fl as useReread,
2235
+ Tn as versionBelow,
2236
+ Ze as writtenOut
988
2237
  };