@coolms/ui-react 0.1.0-alpha.2 → 0.1.0-alpha.21

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