@wssto2/vue-core 0.4.7 → 0.4.9

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.
Files changed (36) hide show
  1. package/README.md +2 -1
  2. package/dist/{Activity-CEeZADHC.js → Activity-DqXMzELT.js} +1 -1
  3. package/dist/{Changes-B7TxVDoE.js → Changes-DCaXBsq_.js} +1 -1
  4. package/dist/CollectionPage.vue_vue_type_script_setup_true_lang-DkpFEHUw.js +1569 -0
  5. package/dist/{DataTable.vue_vue_type_script_setup_true_lang-KPm5NrDE.js → DataTable.vue_vue_type_script_setup_true_lang-ChS9ULwk.js} +21 -17
  6. package/dist/{DeadLetters-DwKeKpu6.js → DeadLetters-DBUALYXL.js} +2 -2
  7. package/dist/{General-C43nVs_x.js → General-DfIB1vjc.js} +1 -1
  8. package/dist/{ProfilePage-BXVPsyS8.js → ProfilePage-CWwwAhnr.js} +2 -2
  9. package/dist/{Sessions-9OEiLpje.js → Sessions-DkbKDSEn.js} +1 -1
  10. package/dist/{SettingsPage-CmPy-kpL.js → SettingsPage-BNdeH-_0.js} +1 -1
  11. package/dist/{SignIn-f-HF9B7-.js → SignIn-5ms3eSbU.js} +1 -1
  12. package/dist/{SignInPage-C8zaS_7r.js → SignInPage-BcRFC7oq.js} +1 -1
  13. package/dist/{SignInTable.vue_vue_type_script_setup_true_lang-ALAuc0sI.js → SignInTable.vue_vue_type_script_setup_true_lang-CIv34nRn.js} +1 -1
  14. package/dist/{SignIns-DzKz0Ple.js → SignIns-BmLrfWe8.js} +2 -2
  15. package/dist/{UserRecord-pciJE77m.js → UserRecord-CHBrlCAl.js} +2 -2
  16. package/dist/{UsersList-YRJTY69g.js → UsersList-hOhdxWGr.js} +3 -3
  17. package/dist/collection/CollectionPage.vue.d.ts +2 -0
  18. package/dist/collection/CollectionRows.vue.d.ts +6 -1
  19. package/dist/collection/CollectionTable.vue.d.ts +9 -0
  20. package/dist/collection/CollectionToolbar.vue.d.ts +3 -2
  21. package/dist/collection/DataTable.vue.d.ts +3 -0
  22. package/dist/collection/index.js +3 -3
  23. package/dist/collection/rowInteractions.d.ts +3 -1
  24. package/dist/i18n/index.js +8 -8
  25. package/dist/identity/index.js +1 -1
  26. package/dist/{index-DnYLRcv6.js → index-Cz4LtYKa.js} +2 -2
  27. package/dist/{index-DoowoCS7.js → index-DrZIn13a.js} +10 -10
  28. package/dist/index.d.ts +1 -1
  29. package/dist/index.js +1 -1
  30. package/dist/notifications/index.js +1 -1
  31. package/dist/rowLayout-D1cYQghV.js +663 -0
  32. package/dist/{status-GT-QFBrB.js → status-DJh5qgMg.js} +1 -1
  33. package/dist/styles.css +1 -1
  34. package/package.json +1 -1
  35. package/dist/CollectionPage.vue_vue_type_script_setup_true_lang-DzuvFLj2.js +0 -1546
  36. package/dist/rowLayout-BkQWulan.js +0 -621
@@ -0,0 +1,1569 @@
1
+ import { hasInjectionContext as lt, inject as ot, shallowRef as xe, computed as k, watch as Ve, toValue as Se, ref as ie, getCurrentScope as nt, onScopeDispose as st, defineComponent as be, openBlock as u, createElementBlock as y, createVNode as O, unref as t, createElementVNode as i, toDisplayString as g, Fragment as ee, renderList as le, createCommentVNode as F, createBlock as W, mergeProps as ve, withCtx as q, createTextVNode as G, normalizeClass as ue, useTemplateRef as fe, withModifiers as Ke, withDirectives as Le, vModelText as Fe, nextTick as at, onBeforeUnmount as rt, onMounted as it, renderSlot as ge, useSlots as We, createSlots as Qe, normalizeProps as Xe, guardReactiveProps as Je } from "vue";
2
+ import { routerKey as ct } from "vue-router";
3
+ import { i as qe, a as ut } from "./error-CD7x0Jrz.js";
4
+ import { a as dt, d as Re, o as ft, L as Te, e as je, w as pt, b as vt } from "./http-D_D9YbLH.js";
5
+ import { a as mt } from "./AdaptivePageShell.vue_vue_type_script_setup_true_lang-B7qSUiee.js";
6
+ import { useI18n as he } from "vue-i18n";
7
+ import { _ as ce, u as Ne } from "./Button.vue_vue_type_script_setup_true_lang-CL9Qh5yq.js";
8
+ import { _ as Ge } from "./Tabs.vue_vue_type_script_setup_true_lang-CcMcE38r.js";
9
+ import { u as Pe } from "./format-B8mJm946.js";
10
+ import { _ as I } from "./Icon.vue_vue_type_script_lang-D7oC-d-S.js";
11
+ import { _ as Ae } from "./Banner.vue_vue_type_script_setup_true_lang-DSStj_5z.js";
12
+ import { _ as Ee } from "./EmptyState.vue_vue_type_script_setup_true_lang-50p-Mp8I.js";
13
+ import { u as bt, _ as gt } from "./rowLayout-D1cYQghV.js";
14
+ import { _ as Ye } from "./Menu.vue_vue_type_script_setup_true_lang-uPmxWvds.js";
15
+ import { _ as Ze } from "./Popover.vue_vue_type_script_setup_true_lang-Dx-tDhNE.js";
16
+ import { _ as we } from "./ToneDot.vue_vue_type_script_setup_true_lang-99rNn-L5.js";
17
+ import { _ as ht } from "./NumberField.vue_vue_type_script_setup_true_lang-C7N5nq0P.js";
18
+ import { _ as yt } from "./SelectField.vue_vue_type_script_setup_true_lang-BJoAkBo2.js";
19
+ import { a as _t } from "./mediaQuery-CygcXmFW.js";
20
+ import { _ as xt } from "./Sheet.vue_vue_type_script_setup_true_lang-DgOFV4fa.js";
21
+ import { t as ke } from "./toast-CqSDTWRX.js";
22
+ const re = (s) => s == null || s === "";
23
+ function et(s) {
24
+ if (!s) return [null, null];
25
+ const [e = "", n = ""] = String(s).split(",");
26
+ return [e.trim() || null, n.trim() || null];
27
+ }
28
+ function kt(s, e) {
29
+ const n = re(s) ? "" : String(s), f = re(e) ? "" : String(e);
30
+ return n === "" && f === "" ? null : `${n},${f}`;
31
+ }
32
+ function wt(s, e) {
33
+ const n = re(e) ? null : new Set(String(e).split(",")), f = (s.options ?? []).filter(
34
+ (r) => !s.dependsOn || !n || r.parentValue !== void 0 && n.has(String(r.parentValue))
35
+ ), a = /* @__PURE__ */ new Map();
36
+ for (const r of f) {
37
+ const p = a.get(r.label) ?? { values: [], dot: r.dot }, d = String(r.value);
38
+ p.values.includes(d) || p.values.push(d), a.set(r.label, p);
39
+ }
40
+ return [...a.entries()].map(([r, { values: p, dot: d }]) => ({ label: r, value: p.join(","), ...d ? { dot: d } : {} }));
41
+ }
42
+ function $t(s, e, n) {
43
+ if (re(e)) return null;
44
+ if (s.type === "range") {
45
+ const [a, r] = et(String(e)), p = s.unit ? ` ${s.unit}` : "", d = (b) => `${s.unit ? n.formatNumber(Number(b)) : b}${p}`;
46
+ return a !== null && r !== null ? `${d(a)} – ${d(r)}` : a !== null ? `${n.from.toLowerCase()} ${d(a)}` : r !== null ? `${n.until.toLowerCase()} ${d(r)}` : null;
47
+ }
48
+ const f = new Set(String(e).split(","));
49
+ return (s.options ?? []).find((a) => f.has(String(a.value)))?.label ?? String(e);
50
+ }
51
+ function ze(s, e, n) {
52
+ const f = new Set(s.map((p) => p.key)), a = (p) => s.find((d) => d.dependsOn === p), r = [];
53
+ for (const p of s.filter((d) => !d.dependsOn || !f.has(d.dependsOn))) {
54
+ const d = [];
55
+ for (let S = p; S && !d.includes(S); S = a(S.key)) d.push(S);
56
+ const b = d.map((S) => ({ filter: S, value: $t(S, e[S.key], n) })).filter((S) => S.value !== null);
57
+ b.length !== 0 && r.push({
58
+ key: p.key,
59
+ label: b.length === 1 ? b[0].filter.label : null,
60
+ values: b.map((S) => S.value),
61
+ clears: d.map((S) => S.key)
62
+ });
63
+ }
64
+ return r;
65
+ }
66
+ function Ct(s, e) {
67
+ return s.filter((n) => !re(e[n.key])).length;
68
+ }
69
+ const Ue = /* @__PURE__ */ new WeakMap();
70
+ function St(s, e, n, f) {
71
+ let a = Ue.get(s);
72
+ a || Ue.set(s, a = /* @__PURE__ */ new Map());
73
+ const r = `${n}\0${f}`, p = a.get(r);
74
+ if (p && p.id !== e)
75
+ throw new Error(
76
+ `useCollection("${e}"): the URL state key "${f}" is already used by the list "${p.id}" on this page. Two lists on one page each need their own \`state: { kind: "url", key }\`, or they overwrite each other's state.`
77
+ );
78
+ const d = p ?? { id: e, count: 0 };
79
+ return d.count++, a.set(r, d), () => {
80
+ --d.count <= 0 && a.delete(r);
81
+ };
82
+ }
83
+ const Oe = (s) => s.status === "loaded" || s.status === "refreshing" || s.status === "stale", Me = (s) => s instanceof Error && s.message !== "" ? s.message : String(s);
84
+ function Uo(s, e) {
85
+ const n = `useCollection("${s.id}")`, f = e.state;
86
+ let a = null, r = "", p = "", d = () => {
87
+ };
88
+ if (f.kind === "url") {
89
+ if (a = lt() ? ot(ct, null) : null, !a) throw new Error(`${n}: a URL state needs the application's router. Call it while a component is being set up, with the router installed, or use \`state: { kind: "memory" }\`.`);
90
+ if (!f.key) throw new Error(`${n}: \`state.key\` must not be empty.`);
91
+ p = f.key, r = a.currentRoute.value.path, d = St(a, s.id, r, p);
92
+ }
93
+ const b = e.defaults ? dt({
94
+ ...s,
95
+ query: { ...s.contract, sorts: s.contract.sorts ?? void 0, filters: s.contract.filters ?? void 0, views: s.contract.views ?? void 0 },
96
+ defaults: { ...s.defaults, ...e.defaults }
97
+ }).defaults : s.defaults, S = { search: e.defaults?.search ?? "", filters: e.defaults?.filters ?? {} }, N = e.defaults ? b : void 0, R = (() => {
98
+ if (!a) return b;
99
+ const o = a.currentRoute.value.query[p];
100
+ return Re(s, Array.isArray(o) ? o[0] : o, N) ?? b;
101
+ })(), w = xe(R), $ = xe({ status: "loading" }), P = xe(null), j = xe(null), H = k(() => Oe($.value) ? $.value.value : j.value);
102
+ let A = !1, T = null, Q = 0, M = !1;
103
+ const Y = [];
104
+ a && e.linked && de(a.currentRoute.value.query, e.linked);
105
+ function de(o, v) {
106
+ let L = w.value;
107
+ const K = (X) => {
108
+ const E = o[X], ae = Array.isArray(E) ? E[0] : E;
109
+ return typeof ae == "string" && ae !== "" ? ae : null;
110
+ };
111
+ if (v.view) {
112
+ const X = K(v.view), E = X !== null && (s.contract.views ? s.contract.views.includes(X) : !0);
113
+ X !== null && E && (L = { ...L, view: X, page: 1 }, Y.push(v.view));
114
+ }
115
+ for (const [X, E] of Object.entries(v.params ?? {})) {
116
+ const ae = K(X);
117
+ if (ae === null) continue;
118
+ const U = typeof E == "string" ? E : E.filter, D = typeof E == "string" ? ae : E.value(ae), Z = { ...L.filters };
119
+ D === null || D === "any" || D === "" ? delete Z[U] : Z[U] = String(D), L = { ...L, filters: Z, page: 1 }, Y.push(X);
120
+ }
121
+ if (Y.length > 0) {
122
+ for (const X of v.consume ?? []) X in o && Y.push(X);
123
+ w.value = L;
124
+ }
125
+ }
126
+ async function oe(o) {
127
+ if (A) return;
128
+ T?.abort();
129
+ const v = ++Q, L = T = new AbortController(), K = $.value, X = w.value;
130
+ $.value = o && Oe(K) ? { status: "refreshing", value: K.value } : { status: "loading" };
131
+ try {
132
+ const E = await s.load(X, { signal: L.signal });
133
+ if (v !== Q) return;
134
+ if (E.lastPage >= 1 && X.page > E.lastPage) {
135
+ w.value = { ...X, page: E.lastPage }, te(), oe(!1);
136
+ return;
137
+ }
138
+ P.value = null, j.value = E, $.value = { status: "loaded", value: E };
139
+ } catch (E) {
140
+ if (v !== Q || L.signal.aborted || qe(E)) return;
141
+ P.value = E, $.value = o && Oe(K) ? { status: "stale", value: K.value, error: Me(E) } : { status: "failed", error: Me(E) };
142
+ }
143
+ }
144
+ function C() {
145
+ te(), !(M || A) && (M = !0, queueMicrotask(() => {
146
+ M && (M = !1, oe(!1));
147
+ }));
148
+ }
149
+ function B() {
150
+ return M = !1, oe(!0);
151
+ }
152
+ let V = !1, J = !1, ne = !1;
153
+ function te() {
154
+ !a || V || A || (V = !0, queueMicrotask(() => {
155
+ V = !1, se();
156
+ }));
157
+ }
158
+ async function se() {
159
+ if (a) {
160
+ if (J) {
161
+ ne = !0;
162
+ return;
163
+ }
164
+ J = !0;
165
+ try {
166
+ do {
167
+ ne = !1;
168
+ const o = a.currentRoute.value;
169
+ if (A || o.path !== r) return;
170
+ const v = je(s, w.value, N), L = { ...o.query };
171
+ for (const K of Y.splice(0)) delete L[K];
172
+ o.query[p] === v && Object.keys(L).length === Object.keys(o.query).length || await a.replace({ query: { ...L, [p]: v }, hash: o.hash });
173
+ } while (ne);
174
+ } catch {
175
+ } finally {
176
+ J = !1;
177
+ }
178
+ }
179
+ }
180
+ const h = a ? Ve(
181
+ () => a.currentRoute.value.query[p],
182
+ (o) => {
183
+ const v = a.currentRoute.value;
184
+ if (A || J || v.path !== r) return;
185
+ const L = Array.isArray(o) ? o[0] : o, K = Re(s, L, N) ?? b;
186
+ JSON.stringify(K) !== JSON.stringify(w.value) ? (w.value = K, C()) : te();
187
+ }
188
+ ) : () => {
189
+ }, _ = (o, v = !1) => {
190
+ w.value = { ...w.value, ...o, ...v ? { page: 1 } : {} }, C();
191
+ }, z = (o) => {
192
+ const v = { ...w.value.filters };
193
+ for (const [L, K] of Object.entries(o))
194
+ K == null || re(K) ? delete v[L] : v[L] = String(K);
195
+ return v;
196
+ }, pe = k(
197
+ () => w.value.search !== "" && w.value.search !== S.search || Object.entries(w.value.filters).some(([o, v]) => !re(v) && v !== S.filters[o])
198
+ ), me = k(() => Object.keys(S.filters).filter((o) => !re(S.filters[o]) && w.value.filters[o] === S.filters[o])), ye = k(() => H.value?.rows ?? []), $e = k(() => {
199
+ const o = $.value;
200
+ return o.status === "loading" ? "loading" : o.status === "failed" ? "failed" : o.value.rows.length > 0 ? "rows" : pe.value ? "no-matches" : "empty";
201
+ }), Ce = k(() => {
202
+ const o = new Map((H.value?.views ?? []).map((v) => [v.key, v.count]));
203
+ return (Se(e.views) ?? []).map((v) => o.has(v.key) ? { ...v, count: o.get(v.key) } : v);
204
+ });
205
+ let _e = () => {
206
+ };
207
+ const c = e.savedViews ? l(e.savedViews) : null;
208
+ function m(o) {
209
+ const v = { v: o.state.version, f: o.state.filters, s: o.state.search, w: o.state.view ?? void 0 };
210
+ return vt(s, v, N);
211
+ }
212
+ function l(o) {
213
+ const v = ie([]), L = ie("idle");
214
+ let K = null;
215
+ const X = (U, D) => U.name.localeCompare(D.name), E = k(() => v.value.filter((U) => m(U) !== null));
216
+ _e = () => {
217
+ K?.abort(), v.value = [], L.value = "idle";
218
+ };
219
+ const ae = () => ({
220
+ version: s.stateVersion,
221
+ filters: Object.fromEntries(Object.entries(w.value.filters).filter(([U, D]) => D !== void 0 && !s.contract.sensitive.includes(U))),
222
+ search: w.value.search,
223
+ view: w.value.view
224
+ });
225
+ return {
226
+ items: E,
227
+ status: L,
228
+ async load() {
229
+ K?.abort();
230
+ const U = K = new AbortController();
231
+ L.value = "loading";
232
+ try {
233
+ const D = await o.list(s.id, { signal: U.signal });
234
+ if (U.signal.aborted) return;
235
+ v.value = [...D].sort(X), L.value = "ready";
236
+ } catch (D) {
237
+ if (U.signal.aborted || qe(D)) return;
238
+ L.value = "failed";
239
+ }
240
+ },
241
+ current: ae,
242
+ async save(U, D) {
243
+ const Z = await o.save(s.id, U, { ...ae(), ...D });
244
+ return v.value = [...v.value.filter((tt) => tt.id !== Z.id), Z].sort(X), Z;
245
+ },
246
+ apply(U) {
247
+ const D = m(U);
248
+ D && _({ filters: D.filters, search: D.search, view: U.state.view ? D.view : w.value.view }, !0);
249
+ },
250
+ stageRemoval(U) {
251
+ const D = v.value.find((Z) => Z.id === U) ?? null;
252
+ return v.value = v.value.filter((Z) => Z.id !== U), {
253
+ revert() {
254
+ D && !v.value.some((Z) => Z.id === U) && (v.value = [...v.value, D].sort(X));
255
+ },
256
+ // Saved again under the same name while the toast was up: the server replaced that very row, it must not be deleted now.
257
+ async commit() {
258
+ v.value.some((Z) => Z.id === U) || await o.remove(s.id, U);
259
+ }
260
+ };
261
+ }
262
+ };
263
+ }
264
+ function x() {
265
+ A || (A = !0, T?.abort(), Q++, h(), d());
266
+ }
267
+ return nt() && st(x), ft((o) => {
268
+ T?.abort(), Q++, $.value = { status: "loading" }, j.value = null, P.value = null, _e(), o !== null && C();
269
+ }), C(), {
270
+ id: s.id,
271
+ pageSizes: s.contract.pageSizes,
272
+ searchable: s.contract.search,
273
+ rowKey: (o) => s.key(o),
274
+ state: $,
275
+ query: w,
276
+ page: H,
277
+ rows: ye,
278
+ total: k(() => H.value?.total ?? 0),
279
+ display: $e,
280
+ isFiltered: pe,
281
+ startFilters: me,
282
+ error: P,
283
+ columns: k(() => {
284
+ const o = Se(e.columns) ?? [], v = s.contract.sorts;
285
+ if (v) {
286
+ for (const L of o) if (L.sort !== void 0 && !v.includes(L.sort)) throw new Error(`${n}: column "${L.key}" sorts by "${L.sort}", which is not in the query contract's sorts (${v.join(", ")}).`);
287
+ }
288
+ return o;
289
+ }),
290
+ filters: k(() => Se(e.filters) ?? []),
291
+ views: Ce,
292
+ savedViews: c,
293
+ refresh: B,
294
+ goToPage: (o) => {
295
+ Number.isInteger(o) && o >= 1 && o !== w.value.page && _({ page: o });
296
+ },
297
+ nextPage: () => {
298
+ const o = H.value?.lastPage ?? 0;
299
+ w.value.page < o && _({ page: w.value.page + 1 });
300
+ },
301
+ previousPage: () => {
302
+ w.value.page > 1 && _({ page: w.value.page - 1 });
303
+ },
304
+ setPageSize: (o) => {
305
+ s.contract.pageSizes.includes(o) && o !== w.value.pageSize && _({ pageSize: o }, !0);
306
+ },
307
+ sortBy: (o, v = "asc") => {
308
+ if (s.contract.sorts && !s.contract.sorts.includes(o)) throw new Error(`${n}: "${o}" is not in the query contract's sorts.`);
309
+ _({ sort: o, direction: v });
310
+ },
311
+ toggleSort: (o) => {
312
+ const v = w.value;
313
+ _({ sort: o, direction: v.sort === o && v.direction === "asc" ? "desc" : "asc" });
314
+ },
315
+ search: (o) => _({ search: o }, !0),
316
+ setFilter: (o, v) => _({ filters: z({ [o]: v }) }, !0),
317
+ setFilters: (o) => _({ filters: z(o) }, !0),
318
+ clearFilters: () => _({ filters: {}, search: "" }, !0),
319
+ clearStart: () => {
320
+ me.value.length > 0 && _({ filters: z(Object.fromEntries(me.value.map((o) => [o, null]))) }, !0);
321
+ },
322
+ setView: (o) => _({ view: o }, !0),
323
+ reset: () => {
324
+ w.value = b, C();
325
+ },
326
+ recordLocation: (o) => {
327
+ const v = e.recordRoute?.(o);
328
+ return v ? a ? pt(v, { [Te]: je(s, w.value, N) }) : v : null;
329
+ },
330
+ linkContext: () => a ? { [Te]: je(s, w.value, N) } : {}
331
+ };
332
+ }
333
+ const jt = {
334
+ class: "mx-auto max-w-xl py-8 text-center",
335
+ "data-test": "collection-empty-filtered"
336
+ }, Ot = { class: "mt-3 mb-1 text-headline font-semibold text-content-strong" }, zt = { class: "text-sm text-content-muted" }, Vt = { class: "mt-4 flex flex-wrap justify-center gap-2" }, Lt = {
337
+ key: 0,
338
+ class: "shrink-0 text-content-muted"
339
+ }, Ft = ["title"], Pt = ["aria-label", "onClick"], qt = { class: "mt-5 flex flex-wrap justify-center gap-2" }, Rt = /* @__PURE__ */ be({
340
+ __name: "CollectionEmptyResult",
341
+ props: {
342
+ chips: {},
343
+ lastChip: {}
344
+ },
345
+ emits: ["remove", "clearAll"],
346
+ setup(s, { emit: e }) {
347
+ const n = s, f = e, { t: a } = he();
348
+ return (r, p) => (u(), y("div", jt, [
349
+ O(t(I), {
350
+ name: "filter3",
351
+ size: 32,
352
+ class: "mx-auto text-content-disabled"
353
+ }),
354
+ i("h3", Ot, g(t(a)("core.collection.empty.title")), 1),
355
+ i("p", zt, g(t(a)("core.collection.empty.description")), 1),
356
+ i("ul", Vt, [
357
+ (u(!0), y(ee, null, le(n.chips, (d) => (u(), y("li", {
358
+ key: d.key,
359
+ class: "inline-flex h-7 max-w-full min-w-0 items-center gap-1.5 rounded-control bg-surface-cell pr-0.5 pl-2.5 text-sm shadow-group ring-1 ring-inset ring-border-separator"
360
+ }, [
361
+ d.label ? (u(), y("span", Lt, g(d.label), 1)) : F("", !0),
362
+ i("span", {
363
+ class: "min-w-0 truncate font-medium text-content-strong",
364
+ title: d.values.join(" › ")
365
+ }, g(d.values.join(" › ")), 9, Ft),
366
+ i("button", {
367
+ type: "button",
368
+ class: "shrink-0 cursor-pointer rounded p-1 text-content-disabled hover:bg-fill hover:text-content-strong",
369
+ "aria-label": `${t(a)("core.collection.clear")}: ${d.label ?? d.values.join(" › ")}`,
370
+ onClick: (b) => f("remove", d)
371
+ }, [
372
+ O(t(I), {
373
+ name: "close",
374
+ size: 12
375
+ })
376
+ ], 8, Pt)
377
+ ]))), 128))
378
+ ]),
379
+ i("div", qt, [
380
+ n.lastChip ? (u(), W(ce, ve({ key: 0 }, { "data-test": "collection-empty-remove-last" }, {
381
+ prominence: "secondary",
382
+ size: "sm",
383
+ onClick: p[0] || (p[0] = (d) => f("remove", n.lastChip))
384
+ }), {
385
+ default: q(() => [
386
+ G(g(t(a)("core.collection.empty.remove_last", { filter: n.lastChip.values.join(" › ") })), 1)
387
+ ]),
388
+ _: 1
389
+ }, 16)) : F("", !0),
390
+ O(ce, ve({ "data-test": "collection-empty-clear-all" }, {
391
+ size: "sm",
392
+ onClick: p[1] || (p[1] = (d) => f("clearAll"))
393
+ }), {
394
+ default: q(() => [
395
+ G(g(t(a)("core.collection.empty.clear_all")), 1)
396
+ ]),
397
+ _: 1
398
+ }, 16)
399
+ ])
400
+ ]));
401
+ }
402
+ }), Tt = ["aria-label"], Nt = ["disabled"], At = { class: "sr-only" }, Et = {
403
+ class: "text-subheadline tabular-nums text-content-muted",
404
+ "aria-live": "polite"
405
+ }, Ut = ["disabled"], Mt = { class: "sr-only" }, Bt = {
406
+ key: 1,
407
+ class: "flex select-none flex-col items-center justify-between gap-3 border-t border-border-separator px-4 py-2.5 md:flex-row"
408
+ }, Dt = { class: "flex flex-col items-center gap-x-4 text-footnote tabular-nums text-content-muted md:flex-row" }, It = {
409
+ key: 0,
410
+ "aria-live": "polite"
411
+ }, Ht = { class: "flex items-center" }, Kt = { class: "mr-2" }, Wt = ["value"], Qt = ["value"], Xt = ["aria-label"], Jt = ["disabled"], Gt = { class: "sr-only" }, Yt = {
412
+ key: 0,
413
+ class: "px-1.5 text-content-disabled"
414
+ }, Zt = ["aria-current", "onClick"], el = ["disabled"], tl = { class: "sr-only" }, ll = /* @__PURE__ */ be({
415
+ __name: "CollectionPager",
416
+ props: {
417
+ collection: {},
418
+ compact: { type: Boolean },
419
+ flat: { type: Boolean }
420
+ },
421
+ emits: ["turned"],
422
+ setup(s, { emit: e }) {
423
+ const n = s, f = e, { t: a } = he(), r = Pe(), p = k(() => n.collection.query.value.page), d = k(() => n.collection.page.value?.lastPage ?? 0), b = k(() => n.collection.page.value), S = k(() => {
424
+ if (d.value <= 1) return d.value === 1 ? [1] : [];
425
+ const $ = [1], P = Math.max(2, p.value - 2), j = Math.min(d.value - 1, p.value + 2);
426
+ P > 2 && $.push(null);
427
+ for (let H = P; H <= j; H++) $.push(H);
428
+ return j < d.value - 1 && $.push(null), $.push(d.value), $;
429
+ });
430
+ function N($) {
431
+ $ === 1 ? n.collection.nextPage() : n.collection.previousPage(), f("turned");
432
+ }
433
+ const R = ($) => [
434
+ "hit-target inline-flex h-7 min-w-7 cursor-pointer items-center justify-center rounded-button px-2 transition-colors duration-motion-fast disabled:cursor-not-allowed disabled:opacity-40",
435
+ $ ? "bg-tint font-semibold text-content-on-tint" : "text-content-strong hover:bg-fill disabled:hover:bg-transparent"
436
+ ].join(" ");
437
+ function w($) {
438
+ n.collection.setPageSize(Number($.target.value));
439
+ }
440
+ return ($, P) => n.compact && d.value > 1 ? (u(), y("nav", {
441
+ key: 0,
442
+ "aria-label": t(a)("core.collection.page.label"),
443
+ class: ue(["flex select-none items-center justify-between gap-3 px-1 py-2", n.flat ? "mt-1" : "border-t border-border-separator"]),
444
+ "data-test": "collection-pager-compact"
445
+ }, [
446
+ i("button", {
447
+ type: "button",
448
+ class: "inline-flex size-11 cursor-pointer items-center justify-center rounded-full text-content-link active:bg-fill disabled:cursor-not-allowed disabled:text-content-disabled",
449
+ disabled: p.value <= 1,
450
+ onClick: P[0] || (P[0] = (j) => N(-1))
451
+ }, [
452
+ O(t(I), {
453
+ name: "arrowLeftSLine",
454
+ size: 20
455
+ }),
456
+ i("span", At, g(t(a)("core.collection.page.previous")), 1)
457
+ ], 8, Nt),
458
+ i("span", Et, g(t(a)("core.collection.page.page_of", { current: t(r).number(p.value), total: t(r).number(d.value) })), 1),
459
+ i("button", {
460
+ type: "button",
461
+ class: "inline-flex size-11 cursor-pointer items-center justify-center rounded-full text-content-link active:bg-fill disabled:cursor-not-allowed disabled:text-content-disabled",
462
+ disabled: p.value >= d.value,
463
+ onClick: P[1] || (P[1] = (j) => N(1))
464
+ }, [
465
+ O(t(I), {
466
+ name: "arrowRightSLine",
467
+ size: 20
468
+ }),
469
+ i("span", Mt, g(t(a)("core.collection.page.next")), 1)
470
+ ], 8, Ut)
471
+ ], 10, Tt)) : n.compact ? F("", !0) : (u(), y("div", Bt, [
472
+ i("div", Dt, [
473
+ b.value ? (u(), y("span", It, g(t(a)("core.collection.page.total", { from: t(r).number(b.value.from), to: t(r).number(b.value.to), total: t(r).number(b.value.total) })), 1)) : F("", !0),
474
+ i("label", Ht, [
475
+ i("span", Kt, g(t(a)("core.collection.page.per_page")) + ":", 1),
476
+ i("select", {
477
+ value: n.collection.query.value.pageSize,
478
+ class: "cursor-pointer rounded-control bg-transparent py-0.5 pr-1 font-semibold text-content-strong hover:bg-fill",
479
+ onChange: w
480
+ }, [
481
+ (u(!0), y(ee, null, le(n.collection.pageSizes, (j) => (u(), y("option", {
482
+ key: j,
483
+ value: j
484
+ }, g(j), 9, Qt))), 128))
485
+ ], 40, Wt)
486
+ ])
487
+ ]),
488
+ i("nav", {
489
+ "aria-label": t(a)("core.collection.page.label"),
490
+ class: "flex items-center gap-0.5 text-subheadline tabular-nums"
491
+ }, [
492
+ i("button", {
493
+ type: "button",
494
+ class: ue(R(!1)),
495
+ disabled: p.value <= 1,
496
+ onClick: P[2] || (P[2] = (j) => N(-1))
497
+ }, [
498
+ O(t(I), {
499
+ name: "arrowLeftSLine",
500
+ size: 16
501
+ }),
502
+ i("span", Gt, g(t(a)("core.collection.page.previous")), 1)
503
+ ], 10, Jt),
504
+ (u(!0), y(ee, null, le(S.value, (j, H) => (u(), y(ee, { key: H }, [
505
+ j === null ? (u(), y("span", Yt, "…")) : (u(), y("button", {
506
+ key: 1,
507
+ type: "button",
508
+ class: ue(R(j === p.value)),
509
+ "aria-current": j === p.value ? "page" : void 0,
510
+ onClick: (A) => n.collection.goToPage(j)
511
+ }, g(t(r).number(j)), 11, Zt))
512
+ ], 64))), 128)),
513
+ i("button", {
514
+ type: "button",
515
+ class: ue(R(!1)),
516
+ disabled: p.value >= d.value,
517
+ onClick: P[3] || (P[3] = (j) => N(1))
518
+ }, [
519
+ O(t(I), {
520
+ name: "arrowRightSLine",
521
+ size: 16
522
+ }),
523
+ i("span", tl, g(t(a)("core.collection.page.next")), 1)
524
+ ], 10, el)
525
+ ], 8, Xt)
526
+ ]));
527
+ }
528
+ }), ol = ["onClick"], nl = { class: "max-w-56 truncate" }, sl = { class: "flex flex-col gap-1.5 text-footnote font-medium text-content-muted" }, al = ["placeholder"], rl = { class: "flex items-center justify-between gap-2" }, il = {
529
+ type: "submit",
530
+ class: "cursor-pointer rounded-control bg-tint px-3 py-1.5 text-footnote font-semibold text-content-on-tint"
531
+ }, cl = ["onClick"], ul = { class: "max-w-56 truncate" }, Be = "inline-flex shrink-0 cursor-pointer items-center gap-x-2 rounded-button px-3 py-1.5 text-subheadline transition-colors duration-motion-fast focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus", dl = /* @__PURE__ */ be({
532
+ __name: "CollectionFilterMenu",
533
+ props: {
534
+ filter: {},
535
+ value: {}
536
+ },
537
+ emits: ["update"],
538
+ setup(s, { emit: e }) {
539
+ const n = s, f = e, { t: a } = he(), r = k(() => re(n.value) ? null : String(n.value)), p = k(() => n.filter.options?.find((A) => String(A.value) === r.value) ?? null), d = k(() => [
540
+ ...n.filter.withoutDefaultOption ? [] : [{ id: "__all", label: n.filter.defaultOptionTitle ?? a("core.collection.filters.show_all"), checked: r.value === null, onSelect: () => f("update", null) }],
541
+ ...(n.filter.options ?? []).map((T) => ({
542
+ id: `option-${String(T.value)}`,
543
+ label: T.label,
544
+ icon: T.icon,
545
+ dot: T.dot,
546
+ checked: r.value === String(T.value),
547
+ onSelect: () => f("update", String(T.value))
548
+ }))
549
+ ]), b = k(() => n.filter.type === "text" && r.value ? `${n.filter.label}: ${r.value}` : p.value?.label ?? n.filter.label), S = k(() => r.value !== null), N = k(
550
+ () => S.value ? "bg-tint-soft font-semibold text-content-link" : "bg-surface-cell font-medium text-content-strong ring-1 ring-inset ring-border-separator hover:bg-fill"
551
+ ), R = ie(""), w = fe("popover");
552
+ Ve(r, (A) => R.value = A ?? "", { immediate: !0 });
553
+ function $() {
554
+ const A = R.value.trim();
555
+ f("update", A === "" ? null : A), w.value?.dismiss();
556
+ }
557
+ function P() {
558
+ R.value = "", f("update", null), w.value?.dismiss();
559
+ }
560
+ const j = fe("field");
561
+ async function H() {
562
+ await at(), j.value?.focus();
563
+ }
564
+ return (A, T) => n.filter.type === "text" ? (u(), W(t(Ze), {
565
+ key: 0,
566
+ ref_key: "popover",
567
+ ref: w,
568
+ label: n.filter.label,
569
+ width: "md",
570
+ placement: "bottom-start",
571
+ onPresented: H
572
+ }, {
573
+ trigger: q(({ toggle: Q, attrs: M }) => [
574
+ i("button", ve(M, {
575
+ type: "button",
576
+ class: [Be, N.value],
577
+ onClick: Q
578
+ }), [
579
+ n.filter.icon ? (u(), W(t(I), {
580
+ key: 0,
581
+ name: n.filter.icon,
582
+ size: 16
583
+ }, null, 8, ["name"])) : F("", !0),
584
+ i("span", nl, g(b.value), 1),
585
+ O(t(I), {
586
+ name: "arrowDownSLine",
587
+ size: 16,
588
+ class: "text-content-muted"
589
+ })
590
+ ], 16, ol)
591
+ ]),
592
+ default: q(() => [
593
+ i("form", {
594
+ class: "flex flex-col gap-3",
595
+ onSubmit: Ke($, ["prevent"])
596
+ }, [
597
+ i("label", sl, [
598
+ G(g(n.filter.label) + " ", 1),
599
+ Le(i("input", {
600
+ ref_key: "field",
601
+ ref: j,
602
+ "onUpdate:modelValue": T[0] || (T[0] = (Q) => R.value = Q),
603
+ type: "text",
604
+ autocomplete: "off",
605
+ placeholder: t(a)("core.collection.filters.type_to_filter"),
606
+ class: "rounded-control bg-fill px-2.5 py-1.5 text-body text-content-strong outline-none placeholder:text-content-disabled focus:bg-surface-cell focus:ring-[1.5px] focus:ring-inset focus:ring-border-focus"
607
+ }, null, 8, al), [
608
+ [Fe, R.value]
609
+ ])
610
+ ]),
611
+ i("div", rl, [
612
+ i("button", {
613
+ type: "button",
614
+ class: "cursor-pointer rounded-control px-2 py-1 text-footnote text-content-muted hover:text-content-strong",
615
+ onClick: P
616
+ }, g(t(a)("core.collection.filters.clear")), 1),
617
+ i("button", il, g(t(a)("core.collection.filters.apply")), 1)
618
+ ])
619
+ ], 32)
620
+ ]),
621
+ _: 1
622
+ }, 8, ["label"])) : (u(), W(t(Ye), {
623
+ key: 1,
624
+ items: d.value,
625
+ label: n.filter.label,
626
+ placement: "bottom-start"
627
+ }, {
628
+ trigger: q(({ toggle: Q, attrs: M }) => [
629
+ i("button", ve(M, {
630
+ type: "button",
631
+ class: [Be, N.value],
632
+ onClick: Q
633
+ }), [
634
+ n.filter.icon ? (u(), W(t(I), {
635
+ key: 0,
636
+ name: n.filter.icon,
637
+ size: 16
638
+ }, null, 8, ["name"])) : F("", !0),
639
+ p.value?.dot ? (u(), W(we, {
640
+ key: 1,
641
+ tone: p.value.dot
642
+ }, null, 8, ["tone"])) : F("", !0),
643
+ i("span", ul, g(b.value), 1),
644
+ O(t(I), {
645
+ name: "arrowDownSLine",
646
+ size: 16,
647
+ class: "text-content-muted"
648
+ })
649
+ ], 16, cl)
650
+ ]),
651
+ _: 1
652
+ }, 8, ["items", "label"]));
653
+ }
654
+ }), fl = {
655
+ key: 0,
656
+ "data-test": "filter-drilldown"
657
+ }, pl = { class: "mb-3 text-headline font-semibold" }, vl = ["aria-label"], ml = ["aria-selected", "onClick"], bl = { class: "flex min-w-0 items-center gap-2" }, gl = { class: "min-w-0 truncate" }, hl = {
658
+ key: 0,
659
+ class: "mb-5 border-b border-border-separator pb-5",
660
+ "data-test": "saved-filters"
661
+ }, yl = { class: "mb-2 text-footnote font-medium text-content-muted" }, _l = { class: "flex flex-wrap gap-2" }, xl = ["onClick"], kl = ["aria-label", "title", "onClick"], wl = { class: "space-y-5" }, $l = { key: 0 }, Cl = { class: "mb-1.5 text-footnote font-medium text-content-muted" }, Sl = ["aria-label"], jl = { class: "mb-1.5 text-footnote font-medium text-content-muted" }, Ol = {
662
+ key: 0,
663
+ class: "grid grid-cols-2 gap-3"
664
+ }, zl = ["aria-label"], Vl = { class: "mb-2 text-footnote font-medium text-content-muted" }, Ll = { class: "flex flex-wrap gap-2" }, Fl = ["aria-pressed", "onClick"], Pl = { class: "inline-flex items-center gap-2" }, ql = ["disabled", "onClick"], Rl = { class: "shrink-0 text-subheadline font-medium" }, Tl = { class: "truncate" }, Nl = { class: "flex items-center justify-between gap-2" }, Al = { class: "flex items-center gap-2" }, El = ["title"], Ul = { class: "sm:hidden" }, Ml = { class: "hidden sm:inline" }, Bl = { class: "flex flex-col gap-1.5 text-footnote font-medium text-content-muted" }, Dl = ["placeholder"], Il = {
665
+ key: 0,
666
+ class: "text-footnote text-status-warning-content",
667
+ "data-test": "saved-filter-replace-hint"
668
+ }, Hl = { class: "flex justify-end gap-2" }, Kl = 8, Wl = 18, De = 6e3, Ql = /* @__PURE__ */ be({
669
+ __name: "CollectionFilterPanel",
670
+ props: {
671
+ collection: {},
672
+ filters: {}
673
+ },
674
+ emits: ["touched"],
675
+ setup(s, { expose: e, emit: n }) {
676
+ const f = s, a = n, { t: r } = he(), p = fe("sheet"), d = _t("(max-width: 1023px), (pointer: coarse)"), b = ie({}), S = ie({}), N = ie(null), R = k(() => f.filters.find((c) => c.key === N.value) ?? null);
677
+ function w() {
678
+ const c = {}, m = {};
679
+ for (const l of f.filters) {
680
+ const x = f.collection.query.value.filters[l.key];
681
+ if (c[l.key] = re(x) ? null : String(x), l.type === "range") {
682
+ const [o, v] = et(c[l.key]);
683
+ m[l.key] = { min: o ?? "", max: v ?? "" };
684
+ }
685
+ }
686
+ b.value = c, S.value = m, N.value = null, p.value?.present();
687
+ }
688
+ function $(c, m) {
689
+ const l = re(m) ? null : String(m);
690
+ if (b.value[c] !== l) {
691
+ b.value = { ...b.value, [c]: l };
692
+ for (const x of f.filters.filter((o) => o.dependsOn === c)) $(x.key, null);
693
+ }
694
+ }
695
+ function P() {
696
+ for (const c of f.filters)
697
+ b.value[c.key] = null, c.type === "range" && (S.value[c.key] = { min: "", max: "" });
698
+ }
699
+ const j = (c) => c.replace(/[^\d.,-]/g, "").replace(",", "."), H = (c, m) => {
700
+ const l = S.value[c]?.[m] ?? "", x = l === "" ? Number.NaN : Number(j(l));
701
+ return Number.isNaN(x) ? null : x;
702
+ };
703
+ function A(c, m, l) {
704
+ const x = S.value[c];
705
+ x && (x[m] = l === null ? "" : String(l));
706
+ }
707
+ function T() {
708
+ const c = {};
709
+ for (const m of f.filters) {
710
+ const l = S.value[m.key];
711
+ c[m.key] = m.type === "range" ? kt(l ? j(l.min) : null, l ? j(l.max) : null) : b.value[m.key] ?? null;
712
+ }
713
+ return c;
714
+ }
715
+ function Q() {
716
+ const c = T(), m = Object.keys(c).filter((l) => (f.collection.query.value.filters[l] ?? null) !== c[l]);
717
+ a("touched", m), f.collection.setFilters(c), p.value?.dismiss();
718
+ }
719
+ const M = (c) => wt(c, c.dependsOn ? b.value[c.dependsOn] : null), Y = (c) => c.defaultOptionTitle ?? r("core.collection.filters.show_all");
720
+ function de(c) {
721
+ const m = b.value[c.key];
722
+ return m == null ? Y(c) : M(c).find((l) => l.value === m)?.label ?? m;
723
+ }
724
+ const oe = (c) => [{ value: null, label: Y(c) }, ...M(c)], C = (c) => {
725
+ const m = b.value[c.key];
726
+ return m == null ? void 0 : M(c).find((l) => l.value === m)?.dot;
727
+ }, B = (c) => [
728
+ { value: "", label: Y(c) },
729
+ ...M(c).map((m) => ({ value: String(m.value), label: m.label, dot: m.dot }))
730
+ ], V = (c) => [
731
+ { value: "", label: Y(c) },
732
+ ...(c.options ?? []).map((m) => ({ value: String(m.value), label: m.label }))
733
+ ];
734
+ function J(c) {
735
+ const m = M(c);
736
+ return !c.dependsOn && m.length > 0 && m.length <= Kl && m.every((l) => l.label.length <= Wl);
737
+ }
738
+ const ne = k(() => d.value && R.value !== null), te = k(() => f.collection.savedViews), se = ie(""), h = ie(!1), _ = fe("savePopover");
739
+ function z() {
740
+ const c = new Set(f.filters.map((l) => l.key)), m = {};
741
+ for (const [l, x] of Object.entries(f.collection.query.value.filters))
742
+ !c.has(l) && x !== void 0 && x !== "" && (m[l] = String(x));
743
+ for (const [l, x] of Object.entries(T())) x !== null && (m[l] = x);
744
+ return { filters: m, search: f.collection.query.value.search };
745
+ }
746
+ const pe = k(() => {
747
+ const c = z();
748
+ return Object.keys(c.filters).length > 0 || c.search.trim() !== "";
749
+ }), me = k(() => {
750
+ const c = se.value.trim();
751
+ return c ? te.value?.items.value.find((m) => m.name === c) ?? null : null;
752
+ }), ye = (c, m) => ut(c) && c.message ? c.message : m;
753
+ async function $e() {
754
+ const c = se.value.trim(), m = te.value;
755
+ if (!(!m || !c || h.value || !pe.value)) {
756
+ h.value = !0;
757
+ try {
758
+ const l = await m.save(c, z());
759
+ se.value = "", _.value?.dismiss(), ke.success(r("core.collection.saved.saved_toast", { name: l.name })), m.apply(l), a("touched", []), p.value?.dismiss();
760
+ } catch (l) {
761
+ ke.error(ye(l, r("core.collection.saved.save_failed")));
762
+ } finally {
763
+ h.value = !1;
764
+ }
765
+ }
766
+ }
767
+ function Ce(c) {
768
+ te.value?.apply(c), a("touched", []), p.value?.dismiss();
769
+ }
770
+ function _e(c) {
771
+ const m = te.value;
772
+ if (!m) return;
773
+ const { revert: l, commit: x } = m.stageRemoval(c.id), o = setTimeout(() => {
774
+ x().catch((v) => {
775
+ l(), ke.error(ye(v, r("core.collection.saved.delete_failed")));
776
+ });
777
+ }, De);
778
+ ke.success(r("core.collection.saved.deleted_toast", { name: c.name }), {
779
+ duration: De,
780
+ action: {
781
+ label: r("core.collection.saved.undo"),
782
+ onClick: () => {
783
+ clearTimeout(o), l();
784
+ }
785
+ }
786
+ });
787
+ }
788
+ return e({ present: w }), (c, m) => (u(), W(t(xt), {
789
+ ref_key: "sheet",
790
+ ref: p,
791
+ title: t(r)("core.collection.filters.panel_title"),
792
+ grouped: ne.value
793
+ }, {
794
+ footer: q(() => [
795
+ i("div", Nl, [
796
+ O(ce, {
797
+ prominence: "standard",
798
+ class: "whitespace-nowrap",
799
+ onClick: P
800
+ }, {
801
+ default: q(() => [
802
+ G(g(t(r)("core.collection.filters.reset_all")), 1)
803
+ ]),
804
+ _: 1
805
+ }),
806
+ i("div", Al, [
807
+ te.value ? (u(), W(t(Ze), {
808
+ key: 0,
809
+ ref_key: "savePopover",
810
+ ref: _,
811
+ placement: "top-end",
812
+ label: t(r)("core.collection.saved.save_button")
813
+ }, {
814
+ trigger: q(({ toggle: l, attrs: x }) => [
815
+ i("span", {
816
+ title: pe.value ? void 0 : t(r)("core.collection.saved.nothing_to_save")
817
+ }, [
818
+ O(ce, ve({ ...x, "data-test": "saved-filter-open" }, {
819
+ prominence: "standard",
820
+ icon: "save",
821
+ class: "whitespace-nowrap",
822
+ disabled: !pe.value,
823
+ onClick: l
824
+ }), {
825
+ default: q(() => [
826
+ i("span", Ul, g(t(r)("core.collection.saved.save")), 1),
827
+ i("span", Ml, g(t(r)("core.collection.saved.save_button")), 1)
828
+ ]),
829
+ _: 1
830
+ }, 16, ["disabled", "onClick"])
831
+ ], 8, El)
832
+ ]),
833
+ default: q(() => [
834
+ i("form", {
835
+ class: "flex flex-col gap-3",
836
+ "data-test": "saved-filter-form",
837
+ onSubmit: Ke($e, ["prevent"])
838
+ }, [
839
+ i("label", Bl, [
840
+ G(g(t(r)("core.collection.saved.name_label")) + " ", 1),
841
+ Le(i("input", {
842
+ "onUpdate:modelValue": m[1] || (m[1] = (l) => se.value = l),
843
+ type: "text",
844
+ maxlength: "60",
845
+ autocomplete: "off",
846
+ placeholder: t(r)("core.collection.saved.name_placeholder"),
847
+ class: "rounded-control bg-fill px-2.5 py-1.5 text-body text-content-strong outline-none placeholder:text-content-disabled focus:bg-surface-cell focus:ring-[1.5px] focus:ring-inset focus:ring-border-focus"
848
+ }, null, 8, Dl), [
849
+ [Fe, se.value]
850
+ ])
851
+ ]),
852
+ me.value ? (u(), y("p", Il, g(t(r)("core.collection.saved.replace_hint", { name: me.value.name })), 1)) : F("", !0),
853
+ i("div", Hl, [
854
+ O(ce, {
855
+ size: "sm",
856
+ onClick: m[2] || (m[2] = (l) => _.value?.dismiss())
857
+ }, {
858
+ default: q(() => [
859
+ G(g(t(r)("core.actions.cancel")), 1)
860
+ ]),
861
+ _: 1
862
+ }),
863
+ O(ce, ve({ "data-test": "saved-filter-save" }, {
864
+ type: "submit",
865
+ prominence: "primary",
866
+ size: "sm",
867
+ processing: h.value,
868
+ disabled: !se.value.trim()
869
+ }), {
870
+ default: q(() => [
871
+ G(g(me.value ? t(r)("core.collection.saved.replace") : t(r)("core.collection.saved.save")), 1)
872
+ ]),
873
+ _: 1
874
+ }, 16, ["processing", "disabled"])
875
+ ])
876
+ ], 32)
877
+ ]),
878
+ _: 1
879
+ }, 8, ["label"])) : F("", !0),
880
+ O(ce, {
881
+ prominence: "primary",
882
+ icon: "filter3",
883
+ class: "whitespace-nowrap",
884
+ onClick: Q
885
+ }, {
886
+ default: q(() => [
887
+ G(g(t(r)("core.collection.filters.apply")), 1)
888
+ ]),
889
+ _: 1
890
+ })
891
+ ])
892
+ ])
893
+ ]),
894
+ default: q(() => [
895
+ t(d) && R.value ? (u(), y("div", fl, [
896
+ i("button", {
897
+ type: "button",
898
+ "data-test": "filter-drilldown-back",
899
+ class: "-mx-2 -mt-2 mb-1 inline-flex h-10 cursor-pointer items-center gap-0.5 rounded-control px-2 text-body font-medium text-content-link active:bg-tint-soft",
900
+ onClick: m[0] || (m[0] = (l) => N.value = null)
901
+ }, [
902
+ O(t(I), {
903
+ name: "arrowLeftSLine",
904
+ size: 20
905
+ }),
906
+ G(" " + g(t(r)("core.collection.filters.panel_title")), 1)
907
+ ]),
908
+ i("p", pl, g(R.value.label), 1),
909
+ i("ul", {
910
+ class: "overflow-hidden rounded-group bg-surface-cell shadow-group",
911
+ role: "listbox",
912
+ "aria-label": R.value.label
913
+ }, [
914
+ (u(!0), y(ee, null, le(oe(R.value), (l) => (u(), y("li", {
915
+ key: String(l.value),
916
+ role: "presentation"
917
+ }, [
918
+ i("button", {
919
+ type: "button",
920
+ role: "option",
921
+ "aria-selected": (b.value[R.value.key] ?? null) === l.value,
922
+ class: "flex min-h-11 w-full cursor-pointer items-center justify-between gap-3 px-row-inset text-left text-body active:bg-fill",
923
+ onClick: (x) => {
924
+ $(R.value.key, l.value), N.value = null;
925
+ }
926
+ }, [
927
+ i("span", bl, [
928
+ l.dot ? (u(), W(we, {
929
+ key: 0,
930
+ tone: l.dot
931
+ }, null, 8, ["tone"])) : F("", !0),
932
+ i("span", gl, g(l.label), 1)
933
+ ]),
934
+ (b.value[R.value.key] ?? null) === l.value ? (u(), W(t(I), {
935
+ key: 0,
936
+ name: "checkboxCircleFill",
937
+ size: 18,
938
+ class: "shrink-0 text-content-link"
939
+ })) : F("", !0)
940
+ ], 8, ml)
941
+ ]))), 128))
942
+ ], 8, vl)
943
+ ])) : (u(), y(ee, { key: 1 }, [
944
+ te.value && te.value.items.value.length > 0 ? (u(), y("section", hl, [
945
+ i("p", yl, g(t(r)("core.collection.saved.title")), 1),
946
+ i("div", _l, [
947
+ (u(!0), y(ee, null, le(te.value.items.value, (l) => (u(), y("span", {
948
+ key: l.id,
949
+ class: "inline-flex h-8 items-center rounded-control bg-surface-cell text-subheadline shadow-group ring-1 ring-inset ring-border-separator"
950
+ }, [
951
+ i("button", {
952
+ type: "button",
953
+ "data-test": "saved-filter-apply",
954
+ class: "inline-flex h-full cursor-pointer items-center gap-1.5 rounded-l-control pr-1.5 pl-2.5 font-medium text-content-strong hover:bg-fill",
955
+ onClick: (x) => Ce(l)
956
+ }, [
957
+ O(t(I), {
958
+ name: "starFill",
959
+ size: 12,
960
+ class: "text-status-warning-content"
961
+ }),
962
+ G(" " + g(l.name), 1)
963
+ ], 8, xl),
964
+ i("button", {
965
+ type: "button",
966
+ "data-test": "saved-filter-delete",
967
+ "aria-label": t(r)("core.collection.saved.delete", { name: l.name }),
968
+ title: t(r)("core.collection.saved.delete", { name: l.name }),
969
+ class: "h-full cursor-pointer rounded-r-control px-1.5 text-content-muted hover:bg-fill hover:text-content-destructive",
970
+ onClick: (x) => _e(l)
971
+ }, [
972
+ O(t(I), {
973
+ name: "close",
974
+ size: 12
975
+ })
976
+ ], 8, kl)
977
+ ]))), 128))
978
+ ])
979
+ ])) : F("", !0),
980
+ i("div", wl, [
981
+ (u(!0), y(ee, null, le(f.filters, (l) => (u(), y(ee, {
982
+ key: l.key
983
+ }, [
984
+ l.type === "segmented" ? (u(), y("div", $l, [
985
+ i("p", Cl, g(l.label), 1),
986
+ O(t(Ge), {
987
+ "model-value": b.value[l.key] ?? "",
988
+ tabs: V(l),
989
+ label: l.label,
990
+ stretch: "",
991
+ "onUpdate:modelValue": (x) => $(l.key, x === null ? null : String(x))
992
+ }, null, 8, ["model-value", "tabs", "label", "onUpdate:modelValue"])
993
+ ])) : l.type === "range" ? (u(), y("div", {
994
+ key: 1,
995
+ role: "group",
996
+ "aria-label": l.label
997
+ }, [
998
+ i("p", jl, g(l.label), 1),
999
+ S.value[l.key] ? (u(), y("div", Ol, [
1000
+ (u(), y(ee, null, le(["min", "max"], (x) => O(ht, {
1001
+ key: x,
1002
+ "model-value": H(l.key, x),
1003
+ name: `${l.key}_${x}`,
1004
+ width: "full",
1005
+ decimals: l.decimals ?? 0,
1006
+ suffix: l.unit,
1007
+ label: t(r)(x === "min" ? "core.collection.filters.range_from" : "core.collection.filters.range_until"),
1008
+ "onUpdate:modelValue": (o) => A(l.key, x, o)
1009
+ }, null, 8, ["model-value", "name", "decimals", "suffix", "label", "onUpdate:modelValue"])), 64))
1010
+ ])) : F("", !0)
1011
+ ], 8, Sl)) : t(d) && J(l) ? (u(), y("div", {
1012
+ key: 2,
1013
+ role: "group",
1014
+ "aria-label": l.label,
1015
+ "data-test": "filter-chips"
1016
+ }, [
1017
+ i("p", Vl, g(l.label), 1),
1018
+ i("div", Ll, [
1019
+ (u(!0), y(ee, null, le(oe(l), (x) => (u(), y("button", {
1020
+ key: String(x.value),
1021
+ type: "button",
1022
+ "aria-pressed": (b.value[l.key] ?? null) === x.value,
1023
+ class: ue(["min-h-9 cursor-pointer rounded-full px-3.5 text-subheadline ring-1 ring-inset transition-colors", (b.value[l.key] ?? null) === x.value ? "bg-tint-soft font-semibold text-content-link ring-border-selected" : "bg-surface-cell text-content ring-border-separator active:bg-fill"]),
1024
+ onClick: (o) => $(l.key, x.value)
1025
+ }, [
1026
+ i("span", Pl, [
1027
+ x.dot ? (u(), W(we, {
1028
+ key: 0,
1029
+ tone: x.dot
1030
+ }, null, 8, ["tone"])) : F("", !0),
1031
+ G(g(x.label), 1)
1032
+ ])
1033
+ ], 10, Fl))), 128))
1034
+ ])
1035
+ ], 8, zl)) : t(d) ? (u(), y("button", {
1036
+ key: 3,
1037
+ type: "button",
1038
+ "data-test": "filter-row",
1039
+ disabled: !!l.dependsOn && M(l).length === 0,
1040
+ class: "flex min-h-12 w-full cursor-pointer items-center gap-3 rounded-group bg-surface-cell px-3 text-left ring-1 ring-inset ring-border-separator active:bg-fill disabled:cursor-not-allowed disabled:opacity-50",
1041
+ onClick: (x) => N.value = l.key
1042
+ }, [
1043
+ i("span", Rl, g(l.label), 1),
1044
+ i("span", {
1045
+ class: ue(["flex min-w-0 flex-1 items-center justify-end gap-2 text-subheadline", b.value[l.key] == null ? "text-content-disabled" : "font-medium text-content-link"])
1046
+ }, [
1047
+ C(l) ? (u(), W(we, {
1048
+ key: 0,
1049
+ tone: C(l)
1050
+ }, null, 8, ["tone"])) : F("", !0),
1051
+ i("span", Tl, g(de(l)), 1)
1052
+ ], 2),
1053
+ O(t(I), {
1054
+ name: "arrowRightSLine",
1055
+ size: 18,
1056
+ class: "shrink-0 text-content-muted"
1057
+ })
1058
+ ], 8, ql)) : (u(), W(yt, {
1059
+ key: 4,
1060
+ "model-value": b.value[l.key] ?? "",
1061
+ label: l.label,
1062
+ options: B(l),
1063
+ disabled: !!l.dependsOn && M(l).length === 0,
1064
+ "onUpdate:modelValue": (x) => $(l.key, x === "" ? null : x)
1065
+ }, null, 8, ["model-value", "label", "options", "disabled", "onUpdate:modelValue"]))
1066
+ ], 64))), 128))
1067
+ ])
1068
+ ], 64))
1069
+ ]),
1070
+ _: 1
1071
+ }, 8, ["title", "grouped"]));
1072
+ }
1073
+ }), Xl = { class: "flex flex-col items-start gap-2 lg:flex-row" }, Jl = {
1074
+ key: 0,
1075
+ class: "flex h-9 w-full items-center rounded-control bg-fill px-2.5 text-content-muted transition-colors duration-motion-fast focus-within:outline-2 focus-within:outline-offset-1 focus-within:outline-border-focus lg:w-72 compact:h-10"
1076
+ }, Gl = ["placeholder", "aria-label"], Yl = ["aria-label"], Zl = ["title"], eo = {
1077
+ key: 0,
1078
+ class: "min-w-4.5 rounded-full bg-tint px-1 text-center text-caption font-semibold leading-4.5 text-content-on-tint"
1079
+ }, to = ["onClick"], lo = {
1080
+ key: 0,
1081
+ class: "mt-2.5 flex flex-wrap items-center gap-2",
1082
+ "data-test": "collection-filter-chips"
1083
+ }, oo = {
1084
+ key: 0,
1085
+ class: "shrink-0 opacity-80"
1086
+ }, no = { class: "flex min-w-0 flex-wrap items-center gap-1 font-semibold" }, so = { class: "break-words" }, ao = ["aria-label", "onClick"], Ie = "__search", ro = 3, io = 300, co = /* @__PURE__ */ be({
1087
+ __name: "CollectionToolbar",
1088
+ props: {
1089
+ collection: {},
1090
+ narrow: { type: Boolean },
1091
+ flat: { type: Boolean }
1092
+ },
1093
+ emits: ["touched", "searchKey"],
1094
+ setup(s, { emit: e }) {
1095
+ const n = s, f = e, { t: a } = he(), r = Pe(), p = ie(n.collection.query.value.search), d = fe("field");
1096
+ let b = null;
1097
+ Ve(() => n.collection.query.value.search, (C) => {
1098
+ C !== p.value.trim() && (p.value = C);
1099
+ });
1100
+ function S() {
1101
+ b && clearTimeout(b);
1102
+ const C = p.value;
1103
+ C.length > 0 && C.length < ro || (b = setTimeout(() => {
1104
+ b = null, C !== n.collection.query.value.search && (f("touched", [Ie]), n.collection.search(C));
1105
+ }, io));
1106
+ }
1107
+ function N() {
1108
+ b && clearTimeout(b), p.value = "", f("touched", [Ie]), n.collection.search(""), d.value?.focus();
1109
+ }
1110
+ rt(() => b && clearTimeout(b));
1111
+ const R = (C) => C.placement === "panel" || n.narrow && C.type !== "text", w = k(() => n.collection.filters.value.filter((C) => !R(C))), $ = k(() => n.collection.filters.value.filter(R)), P = k(() => n.collection.query.value.filters), j = k(
1112
+ () => ze($.value, P.value, {
1113
+ formatNumber: (C) => r.number(C),
1114
+ from: a("core.collection.filters.range_from"),
1115
+ until: a("core.collection.filters.range_until")
1116
+ })
1117
+ ), H = k(() => Ct($.value, P.value));
1118
+ function A(C, B) {
1119
+ f("touched", [C]), n.collection.setFilter(C, B);
1120
+ }
1121
+ function T(C) {
1122
+ n.collection.setFilters(Object.fromEntries(C.map((B) => [B, null])));
1123
+ }
1124
+ const Q = fe("panel"), M = fe("panelButton"), Y = (C) => !!C && (typeof C.checkVisibility != "function" || C.checkVisibility());
1125
+ Ne({ key: "/", group: "list", label: () => a("core.shortcuts.focus_search") }, () => {
1126
+ if (!Y(d.value)) return !1;
1127
+ d.value?.focus(), d.value?.select();
1128
+ }), Ne({ key: "f", group: "list", label: () => $.value.length > 0 ? a("core.shortcuts.open_filters") : "" }, () => {
1129
+ if ($.value.length === 0 || !Y(M.value)) return !1;
1130
+ Q.value?.present();
1131
+ });
1132
+ const de = k(() => n.collection.savedViews);
1133
+ it(() => void de.value?.load());
1134
+ const oe = k(
1135
+ () => (de.value?.items.value ?? []).map((C) => ({
1136
+ id: `saved-${C.id}`,
1137
+ label: C.name,
1138
+ icon: "starFill",
1139
+ onSelect: () => {
1140
+ f("touched", []), de.value?.apply(C);
1141
+ }
1142
+ }))
1143
+ );
1144
+ return (C, B) => (u(), y("div", {
1145
+ class: ue([n.flat ? "pb-3" : "border-b border-border-separator px-3 py-2.5", "select-none"]),
1146
+ "data-test": "collection-toolbar"
1147
+ }, [
1148
+ i("div", Xl, [
1149
+ n.collection.searchable ? (u(), y("div", Jl, [
1150
+ O(t(I), {
1151
+ name: "search",
1152
+ size: 16
1153
+ }),
1154
+ Le(i("input", {
1155
+ ref_key: "field",
1156
+ ref: d,
1157
+ "onUpdate:modelValue": B[0] || (B[0] = (V) => p.value = V),
1158
+ type: "text",
1159
+ name: "collection-search",
1160
+ autocomplete: "off",
1161
+ placeholder: t(a)("core.collection.search.placeholder"),
1162
+ "aria-label": t(a)("core.collection.search.label"),
1163
+ class: "peer block min-w-0 flex-1 bg-transparent px-2 py-1.5 text-body text-content-strong outline-0 placeholder:text-content-disabled",
1164
+ onInput: S,
1165
+ onKeydown: B[1] || (B[1] = (V) => f("searchKey", V, t(b) === null && p.value.trim() === n.collection.query.value.search))
1166
+ }, null, 40, Gl), [
1167
+ [Fe, p.value]
1168
+ ]),
1169
+ B[5] || (B[5] = i("kbd", {
1170
+ "aria-hidden": "true",
1171
+ class: "rounded border border-border-separator px-1.5 font-mono text-2xs leading-5 text-content-disabled peer-focus:hidden peer-[:not(:placeholder-shown)]:hidden [@media(pointer:coarse)]:hidden"
1172
+ }, "/", -1)),
1173
+ p.value !== "" ? (u(), y("button", {
1174
+ key: 0,
1175
+ type: "button",
1176
+ "aria-label": t(a)("core.collection.clear"),
1177
+ class: "cursor-pointer rounded-full text-content-disabled hover:text-content-muted",
1178
+ onClick: N
1179
+ }, [
1180
+ O(t(I), {
1181
+ name: "close",
1182
+ size: 16
1183
+ })
1184
+ ], 8, Yl)) : F("", !0)
1185
+ ])) : F("", !0),
1186
+ i("div", {
1187
+ class: ue(["flex min-w-0 flex-1 items-center gap-2", n.narrow ? "w-full flex-nowrap overflow-x-auto [scrollbar-width:none]" : "flex-wrap"])
1188
+ }, [
1189
+ $.value.length > 0 ? (u(), y("button", {
1190
+ key: 0,
1191
+ ref_key: "panelButton",
1192
+ ref: M,
1193
+ type: "button",
1194
+ "data-test": "collection-filter-panel-button",
1195
+ title: `${t(a)("core.collection.filters.panel_button")} (F)`,
1196
+ class: ue(["hit-target inline-flex h-8 shrink-0 cursor-pointer items-center gap-x-1.5 rounded-button px-3 text-subheadline font-semibold transition-colors duration-motion-fast compact:h-9", H.value > 0 ? "bg-tint-soft text-content-link" : "bg-surface-cell text-content-strong shadow-group ring-1 ring-inset ring-border-separator hover:bg-fill"]),
1197
+ onClick: B[2] || (B[2] = (V) => Q.value?.present())
1198
+ }, [
1199
+ O(t(I), {
1200
+ name: "filter3",
1201
+ size: 16
1202
+ }),
1203
+ G(" " + g(t(a)("core.collection.filters.panel_button")) + " ", 1),
1204
+ H.value > 0 ? (u(), y("span", eo, g(H.value), 1)) : F("", !0)
1205
+ ], 10, Zl)) : F("", !0),
1206
+ oe.value.length > 0 ? (u(), W(t(Ye), {
1207
+ key: 1,
1208
+ items: oe.value,
1209
+ label: t(a)("core.collection.saved.menu"),
1210
+ placement: "bottom-start"
1211
+ }, {
1212
+ trigger: q(({ toggle: V, attrs: J }) => [
1213
+ i("button", ve(J, {
1214
+ type: "button",
1215
+ "data-test": "saved-filters-menu",
1216
+ class: "inline-flex shrink-0 cursor-pointer items-center gap-1.5 rounded-button bg-surface-cell px-3 py-1.5 text-subheadline font-semibold text-content-strong shadow-group ring-1 ring-inset ring-border-separator transition-colors hover:bg-fill",
1217
+ onClick: V
1218
+ }), [
1219
+ O(t(I), {
1220
+ name: "starFill",
1221
+ size: 14,
1222
+ class: "text-status-warning-content"
1223
+ }),
1224
+ G(" " + g(t(a)("core.collection.saved.menu")), 1)
1225
+ ], 16, to)
1226
+ ]),
1227
+ _: 1
1228
+ }, 8, ["items", "label"])) : F("", !0),
1229
+ (u(!0), y(ee, null, le(w.value, (V) => (u(), W(dl, {
1230
+ key: V.key,
1231
+ filter: V,
1232
+ value: P.value[V.key],
1233
+ onUpdate: (J) => A(V.key, J)
1234
+ }, null, 8, ["filter", "value", "onUpdate"]))), 128))
1235
+ ], 2),
1236
+ ge(C.$slots, "default")
1237
+ ]),
1238
+ j.value.length > 0 ? (u(), y("div", lo, [
1239
+ (u(!0), y(ee, null, le(j.value, (V) => (u(), y("span", {
1240
+ key: V.key,
1241
+ class: "inline-flex min-h-7 max-w-full items-center gap-1.5 rounded-control bg-tint-soft py-0.5 pr-0.5 pl-2.5 text-subheadline text-content-link"
1242
+ }, [
1243
+ V.label ? (u(), y("span", oo, g(V.label), 1)) : F("", !0),
1244
+ i("span", no, [
1245
+ (u(!0), y(ee, null, le(V.values, (J, ne) => (u(), y(ee, { key: ne }, [
1246
+ ne > 0 ? (u(), W(t(I), {
1247
+ key: 0,
1248
+ name: "arrowRightSLine",
1249
+ size: 12,
1250
+ class: "opacity-60"
1251
+ })) : F("", !0),
1252
+ i("span", so, g(J), 1)
1253
+ ], 64))), 128))
1254
+ ]),
1255
+ i("button", {
1256
+ type: "button",
1257
+ class: "hit-target flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-full hover:bg-tint/15",
1258
+ "aria-label": t(a)("core.collection.clear"),
1259
+ onClick: (J) => T(V.clears)
1260
+ }, [
1261
+ O(t(I), {
1262
+ name: "close",
1263
+ size: 12
1264
+ })
1265
+ ], 8, ao)
1266
+ ]))), 128)),
1267
+ j.value.length > 1 ? (u(), y("button", {
1268
+ key: 0,
1269
+ type: "button",
1270
+ class: "cursor-pointer px-2 text-subheadline text-content-muted hover:text-content-strong hover:underline",
1271
+ onClick: B[3] || (B[3] = (V) => T($.value.map((J) => J.key)))
1272
+ }, g(t(a)("core.collection.filters.reset_all")), 1)) : F("", !0)
1273
+ ])) : F("", !0),
1274
+ $.value.length > 0 ? (u(), W(Ql, {
1275
+ key: 1,
1276
+ ref_key: "panel",
1277
+ ref: Q,
1278
+ collection: n.collection,
1279
+ filters: $.value,
1280
+ onTouched: B[4] || (B[4] = (V) => f("touched", V))
1281
+ }, null, 8, ["collection", "filters"])) : F("", !0)
1282
+ ], 2));
1283
+ }
1284
+ }), uo = ["aria-busy"], fo = {
1285
+ key: 0,
1286
+ class: "mb-3 select-none"
1287
+ }, po = {
1288
+ key: 0,
1289
+ role: "status",
1290
+ "data-test": "collection-refreshing",
1291
+ class: "m-2 flex w-fit max-w-full items-center gap-2 rounded-group bg-fill py-1 pr-3 pl-3 text-footnote text-content-muted"
1292
+ }, vo = {
1293
+ key: 1,
1294
+ class: "m-2",
1295
+ "data-test": "collection-stale"
1296
+ }, mo = { class: "flex flex-wrap items-center justify-between gap-3" }, bo = { class: "flex flex-wrap items-center justify-between gap-3" }, go = { class: "font-semibold" }, He = "__search", ho = /* @__PURE__ */ be({
1297
+ __name: "CollectionTable",
1298
+ props: {
1299
+ collection: {},
1300
+ rowActions: { type: Function, default: void 0 },
1301
+ rowLabel: { type: Function, default: void 0 },
1302
+ rowHeight: { default: void 0 },
1303
+ density: { default: "regular" },
1304
+ viewsPresentation: { default: "segmented" },
1305
+ actionsVisible: { type: Boolean, default: !1 },
1306
+ pick: { type: Function, default: void 0 },
1307
+ pickLabel: { default: void 0 }
1308
+ },
1309
+ setup(s) {
1310
+ const e = s, n = We(), { t: f } = he(), a = Pe(), r = () => Object.keys(n).filter((h) => h !== "toolbar" && h !== "empty"), p = k(() => e.collection.columns.value), { narrow: d, phone: b } = bt(() => p.value), S = k(() => e.collection.rows.value), N = (h) => e.pick ? null : e.collection.recordLocation(h), R = fe("rowsView");
1311
+ function w(h, _) {
1312
+ if (!e.pick || h.isComposing) return;
1313
+ if (h.key === "ArrowDown") {
1314
+ R.value?.focusRows() && h.preventDefault();
1315
+ return;
1316
+ }
1317
+ if (h.key !== "Enter") return;
1318
+ const z = S.value[0];
1319
+ _ && z !== void 0 && S.value.length === 1 && e.collection.total.value <= 1 && e.collection.state.value.status === "loaded" && (h.preventDefault(), e.pick(z));
1320
+ }
1321
+ const $ = k(() => e.collection.query.value.search), P = k(() => e.collection.views.value.map((h) => ({ value: h.key, label: h.label, icon: h.icon, badge: h.count }))), j = ie([]), H = (h) => j.value = [...j.value.filter((_) => !h.includes(_)), ...h], A = () => ({
1322
+ formatNumber: (h) => a.number(h),
1323
+ from: f("core.collection.filters.range_from"),
1324
+ until: f("core.collection.filters.range_until")
1325
+ }), T = k(() => {
1326
+ const h = ze(e.collection.filters.value, e.collection.query.value.filters, A()), _ = e.collection.query.value.search;
1327
+ return _ && h.push({ key: He, label: f("core.collection.empty.search"), values: [_], clears: [] }), h;
1328
+ }), Q = k(() => {
1329
+ const h = e.collection.startFilters.value, _ = Object.fromEntries(h.map((z) => [z, e.collection.query.value.filters[z]]));
1330
+ return ze(e.collection.filters.value, _, A()).map((z) => z.label ? `${z.label}: ${z.values.join(" › ")}` : z.values.join(" › "));
1331
+ }), M = k(() => {
1332
+ for (const h of [...j.value].reverse()) {
1333
+ const _ = T.value.find((z) => z.key === h || z.clears.includes(h));
1334
+ if (_) return _;
1335
+ }
1336
+ return T.value[T.value.length - 1] ?? null;
1337
+ });
1338
+ function Y(h) {
1339
+ j.value = j.value.filter((_) => _ !== h.key && !h.clears.includes(_)), h.key === He ? e.collection.search("") : e.collection.setFilters(Object.fromEntries(h.clears.map((_) => [_, null])));
1340
+ }
1341
+ function de() {
1342
+ j.value = [], e.collection.clearFilters();
1343
+ }
1344
+ const oe = k(() => {
1345
+ const { sort: h, direction: _ } = e.collection.query.value;
1346
+ return h === null ? null : { key: h, direction: _ };
1347
+ }), C = fe("card"), B = () => C.value?.scrollIntoView?.({ block: "start", behavior: "smooth" }), V = k(() => e.collection.display.value === "loading"), J = k(() => e.collection.query.value.pageSize), ne = k(() => e.collection.state.value.status === "refreshing"), te = k(() => e.collection.state.value.status === "stale"), se = k(() => {
1348
+ const h = e.collection.state.value;
1349
+ return h.status === "failed" || h.status === "stale" ? h.error ?? "" : "";
1350
+ });
1351
+ return (h, _) => (u(), y("div", {
1352
+ class: "collection",
1353
+ "aria-busy": V.value || ne.value || void 0,
1354
+ "data-test": "collection"
1355
+ }, [
1356
+ P.value.length > 0 ? (u(), y("div", fo, [
1357
+ O(t(Ge), {
1358
+ "model-value": e.collection.query.value.view,
1359
+ tabs: P.value,
1360
+ presentation: e.viewsPresentation,
1361
+ label: t(f)("core.collection.views_label"),
1362
+ "onUpdate:modelValue": _[0] || (_[0] = (z) => e.collection.setView(z === null ? null : String(z)))
1363
+ }, null, 8, ["model-value", "tabs", "presentation", "label"])
1364
+ ])) : F("", !0),
1365
+ i("div", {
1366
+ ref_key: "card",
1367
+ ref: C,
1368
+ class: ue(["scroll-mt-16", t(b) ? "" : "rounded-group bg-surface-cell shadow-group"])
1369
+ }, [
1370
+ O(co, {
1371
+ collection: e.collection,
1372
+ narrow: t(d),
1373
+ flat: t(b),
1374
+ onTouched: H,
1375
+ onSearchKey: w
1376
+ }, {
1377
+ default: q(() => [
1378
+ ge(h.$slots, "toolbar")
1379
+ ]),
1380
+ _: 3
1381
+ }, 8, ["collection", "narrow", "flat"]),
1382
+ ne.value ? (u(), y("div", po, [
1383
+ O(t(I), {
1384
+ name: "loader4Line",
1385
+ size: 14,
1386
+ class: "animate-spin motion-reduce:animate-none"
1387
+ }),
1388
+ G(" " + g(t(f)("core.state.refreshing")), 1)
1389
+ ])) : F("", !0),
1390
+ te.value ? (u(), y("div", vo, [
1391
+ O(t(Ae), {
1392
+ tone: "warning",
1393
+ role: "alert"
1394
+ }, {
1395
+ default: q(() => [
1396
+ i("div", mo, [
1397
+ i("div", null, [
1398
+ i("p", null, g(se.value), 1),
1399
+ i("p", null, g(t(f)("core.state.stale")), 1)
1400
+ ]),
1401
+ O(ce, {
1402
+ prominence: "secondary",
1403
+ size: "sm",
1404
+ onClick: _[1] || (_[1] = (z) => e.collection.refresh())
1405
+ }, {
1406
+ default: q(() => [
1407
+ G(g(t(f)("core.actions.retry")), 1)
1408
+ ]),
1409
+ _: 1
1410
+ })
1411
+ ])
1412
+ ]),
1413
+ _: 1
1414
+ })
1415
+ ])) : F("", !0),
1416
+ O(gt, {
1417
+ ref_key: "rowsView",
1418
+ ref: R,
1419
+ pick: e.pick,
1420
+ "pick-label": e.pickLabel,
1421
+ columns: p.value,
1422
+ rows: S.value,
1423
+ "row-key": e.collection.rowKey,
1424
+ display: e.collection.display.value,
1425
+ phone: t(b),
1426
+ link: N,
1427
+ search: $.value,
1428
+ sorted: oe.value,
1429
+ "row-actions": e.rowActions,
1430
+ "row-label": e.rowLabel,
1431
+ "row-height": e.rowHeight,
1432
+ density: e.density,
1433
+ "actions-visible": e.actionsVisible,
1434
+ "skeleton-rows": J.value,
1435
+ "reserve-rows": V.value ? J.value : void 0,
1436
+ onSort: _[4] || (_[4] = (z) => e.collection.toggleSort(z))
1437
+ }, Qe({
1438
+ failed: q(() => [
1439
+ O(t(Ae), {
1440
+ tone: "warning",
1441
+ role: "alert"
1442
+ }, {
1443
+ default: q(() => [
1444
+ i("div", bo, [
1445
+ i("div", null, [
1446
+ i("p", go, g(t(f)("core.collection.failed.title")), 1),
1447
+ i("p", null, g(se.value), 1)
1448
+ ]),
1449
+ O(ce, {
1450
+ prominence: "secondary",
1451
+ size: "sm",
1452
+ onClick: _[2] || (_[2] = (z) => e.collection.refresh())
1453
+ }, {
1454
+ default: q(() => [
1455
+ G(g(t(f)("core.actions.retry")), 1)
1456
+ ]),
1457
+ _: 1
1458
+ })
1459
+ ])
1460
+ ]),
1461
+ _: 1
1462
+ })
1463
+ ]),
1464
+ empty: q(() => [
1465
+ e.collection.display.value === "empty" && n.empty ? ge(h.$slots, "empty", {}, void 0, void 0, 0) : e.collection.display.value === "empty" && Q.value.length > 0 ? (u(), W(t(Ee), {
1466
+ key: 1,
1467
+ "data-test": "collection-empty-start",
1468
+ title: t(f)("core.collection.no_data"),
1469
+ description: t(f)("core.collection.empty.start_description", { filters: Q.value.join(", ") }),
1470
+ icon: "filter3"
1471
+ }, {
1472
+ actions: q(() => [
1473
+ O(ce, ve({ "data-test": "collection-empty-show-all" }, {
1474
+ size: "sm",
1475
+ onClick: _[3] || (_[3] = (z) => e.collection.clearStart())
1476
+ }), {
1477
+ default: q(() => [
1478
+ G(g(t(f)("core.collection.empty.show_all")), 1)
1479
+ ]),
1480
+ _: 1
1481
+ }, 16)
1482
+ ]),
1483
+ _: 1
1484
+ }, 8, ["title", "description"])) : e.collection.display.value !== "empty" && T.value.length > 0 ? (u(), W(Rt, {
1485
+ key: 2,
1486
+ chips: T.value,
1487
+ "last-chip": M.value,
1488
+ onRemove: Y,
1489
+ onClearAll: de
1490
+ }, null, 8, ["chips", "last-chip"])) : (u(), W(t(Ee), {
1491
+ key: 3,
1492
+ title: t(f)("core.collection.no_data"),
1493
+ description: t(f)("core.collection.no_results")
1494
+ }, null, 8, ["title", "description"]))
1495
+ ]),
1496
+ _: 2
1497
+ }, [
1498
+ le(r(), (z) => ({
1499
+ name: z,
1500
+ fn: q((pe) => [
1501
+ ge(h.$slots, z, Xe(Je(pe ?? {})))
1502
+ ])
1503
+ }))
1504
+ ]), 1032, ["pick", "pick-label", "columns", "rows", "row-key", "display", "phone", "search", "sorted", "row-actions", "row-label", "row-height", "density", "actions-visible", "skeleton-rows", "reserve-rows"]),
1505
+ O(ll, {
1506
+ collection: e.collection,
1507
+ compact: t(d),
1508
+ flat: t(b),
1509
+ onTurned: B
1510
+ }, null, 8, ["collection", "compact", "flat"])
1511
+ ], 2)
1512
+ ], 8, uo));
1513
+ }
1514
+ }), Mo = /* @__PURE__ */ be({
1515
+ __name: "CollectionPage",
1516
+ props: {
1517
+ collection: {},
1518
+ title: {},
1519
+ description: { default: void 0 },
1520
+ icon: { default: void 0 },
1521
+ actions: { default: () => [] },
1522
+ rowActions: { type: Function, default: void 0 },
1523
+ rowLabel: { type: Function, default: void 0 },
1524
+ rowHeight: { default: void 0 },
1525
+ density: { default: "regular" },
1526
+ viewsPresentation: { default: "segmented" },
1527
+ actionsVisible: { type: Boolean, default: !1 },
1528
+ pick: { type: Function, default: void 0 },
1529
+ pickLabel: { default: void 0 }
1530
+ },
1531
+ setup(s) {
1532
+ const e = s, n = We(), f = () => Object.keys(n).filter((r) => r !== "default"), a = k(() => e.collection.total.value || null);
1533
+ return (r, p) => (u(), W(t(mt), {
1534
+ title: e.title,
1535
+ description: e.description,
1536
+ icon: e.icon,
1537
+ count: a.value,
1538
+ actions: e.actions
1539
+ }, {
1540
+ default: q(() => [
1541
+ O(ho, {
1542
+ collection: e.collection,
1543
+ "row-actions": e.rowActions,
1544
+ "row-label": e.rowLabel,
1545
+ "row-height": e.rowHeight,
1546
+ density: e.density,
1547
+ "views-presentation": e.viewsPresentation,
1548
+ "actions-visible": e.actionsVisible,
1549
+ pick: e.pick,
1550
+ "pick-label": e.pickLabel
1551
+ }, Qe({ _: 2 }, [
1552
+ le(f(), (d) => ({
1553
+ name: d,
1554
+ fn: q((b) => [
1555
+ ge(r.$slots, d, Xe(Je(b ?? {})))
1556
+ ])
1557
+ }))
1558
+ ]), 1032, ["collection", "row-actions", "row-label", "row-height", "density", "views-presentation", "actions-visible", "pick", "pick-label"]),
1559
+ ge(r.$slots, "default")
1560
+ ]),
1561
+ _: 3
1562
+ }, 8, ["title", "description", "icon", "count", "actions"]));
1563
+ }
1564
+ });
1565
+ export {
1566
+ Mo as _,
1567
+ ho as a,
1568
+ Uo as u
1569
+ };