@sensinum/strapi-plugin-xecp 5.2.0 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +3 -3
  2. package/dist/admin/App-BbgV5mHU.mjs +2809 -0
  3. package/dist/admin/App-OXf6qXjU.js +74 -0
  4. package/dist/admin/TruncatedTypography-B8iYkeNP.js +12 -0
  5. package/dist/admin/{TruncatedTypography-D8gHowDS.mjs → TruncatedTypography-BA_MhPw6.mjs} +4 -4
  6. package/dist/admin/{de-DPIfWiIq.mjs → de-9eabZie2.mjs} +114 -58
  7. package/dist/admin/de-BN51VcbT.js +1 -0
  8. package/dist/admin/en-DI1XKd0e.js +1 -0
  9. package/dist/admin/{en-CCG4TklL.mjs → en-tFIwzuCy.mjs} +114 -58
  10. package/dist/admin/{fr-DnzU_m4o.mjs → fr-BRWFIMrf.mjs} +114 -58
  11. package/dist/admin/fr-lAhQzMjM.js +1 -0
  12. package/dist/admin/index-BU_gTHIE.mjs +110 -0
  13. package/dist/admin/index-C5CJ1Sy4.js +1 -0
  14. package/dist/admin/{index-DTADzNmo.mjs → index-CT94KSzm.mjs} +179 -174
  15. package/dist/admin/index-CmLDGvPV.js +1 -0
  16. package/dist/admin/{index-CwNAiNVu.mjs → index-SQ5frWDn.mjs} +96 -90
  17. package/dist/admin/{index-B2NfpbcT.js → index-ghS-FZ_7.js} +8 -8
  18. package/dist/admin/index.js +1 -1
  19. package/dist/admin/index.mjs +3 -2
  20. package/dist/admin/pl-CSVwN6jF.js +1 -0
  21. package/dist/admin/{pl-F5zNdZs4.mjs → pl-DLMBD4Lc.mjs} +114 -58
  22. package/dist/admin/{queryKeys-rUHP1d6p.mjs → queryKeys-LazhiKSv.mjs} +5 -4
  23. package/dist/admin/queryKeys-Y6_AOyGq.js +1 -0
  24. package/dist/server/index.js +7 -10
  25. package/dist/server/index.mjs +8734 -8533
  26. package/package.json +48 -22
  27. package/dist/admin/App-DCc6Nerz.js +0 -30
  28. package/dist/admin/App-FBmORCnP.mjs +0 -2144
  29. package/dist/admin/TruncatedTypography-CJdWCFOe.js +0 -12
  30. package/dist/admin/de-Dc27qqZI.js +0 -1
  31. package/dist/admin/en-CPGWvai6.js +0 -1
  32. package/dist/admin/fr-uAOzHrhn.js +0 -1
  33. package/dist/admin/index-B21jnMBg.mjs +0 -113
  34. package/dist/admin/index-BHf1dfyp.js +0 -1
  35. package/dist/admin/index-jgDj_iIg.js +0 -1
  36. package/dist/admin/pl-B1KyPSlZ.js +0 -1
  37. package/dist/admin/queryKeys-B_GC_f73.js +0 -1
@@ -0,0 +1,2809 @@
1
+ import { jsx as o, jsxs as u, Fragment as D } from "react/jsx-runtime";
2
+ import { useFetchClient as K, isFetchError as Cn, useRBAC as vn, useQueryParams as In, Page as re, Layouts as ct, Pagination as $e } from "@strapi/strapi/admin";
3
+ import { Link as je, Routes as wn, Route as dt } from "react-router-dom";
4
+ import { U as q, g as d, P as Be } from "./index-BU_gTHIE.mjs";
5
+ import { L as En, P as Tn, S as Mn, a as xn, Q as Ln } from "./queryKeys-LazhiKSv.mjs";
6
+ import { Combobox as kn, ComboboxOption as Rn, Modal as V, Button as k, Flex as b, Typography as S, Tooltip as _, Link as Qe, EmptyStateLayout as ie, Checkbox as Fe, Badge as Se, Table as Ve, Thead as we, Tr as G, Th as O, Tbody as Ee, Td as L, Accordion as se, Divider as Dn, VisuallyHidden as Te, Status as An, Loader as be, ProgressBar as On } from "@strapi/design-system";
7
+ import { Information as Ue, WarningCircle as ue, Check as _n, Key as $n } from "@strapi/icons";
8
+ import { useState as R, useEffect as Me, useRef as Ye, useLayoutEffect as Kn, Fragment as Et, useMemo as Y, createContext as qn, useContext as Nn, useCallback as ut } from "react";
9
+ import { useIntl as v } from "react-intl";
10
+ import fe from "zod";
11
+ import { f as me, A as $, T as B, a as Bn } from "./TruncatedTypography-BA_MhPw6.mjs";
12
+ import { useQuery as X, useQueryClient as he, useMutation as xe } from "@tanstack/react-query";
13
+ import F from "styled-components";
14
+ const Fn = 120 * 1e3, Un = () => {
15
+ const { get: e } = K();
16
+ return X({
17
+ queryKey: [En, "status"],
18
+ staleTime: Fn,
19
+ queryFn: async () => {
20
+ const { data: t } = await e(`/${q}/license/status`);
21
+ return t;
22
+ }
23
+ });
24
+ }, mt = (e, t) => t ? e.find((n) => n.value === t)?.label ?? "" : "", Hn = ({ name: e, onClear: t, onChange: n, options: s, value: r, placeholder: i, disabled: a }) => {
25
+ const [l, c] = R(() => mt(s, r));
26
+ return Me(() => {
27
+ c(mt(s, r));
28
+ }, [r, s]), /* @__PURE__ */ o(
29
+ kn,
30
+ {
31
+ name: e,
32
+ autocomplete: "list",
33
+ onClear: t,
34
+ onChange: n,
35
+ placeholder: i,
36
+ onTextValueChange: c,
37
+ value: r,
38
+ textValue: l,
39
+ disabled: a,
40
+ width: "100%",
41
+ children: s.map(({ key: m, label: h, value: f }) => /* @__PURE__ */ o(Rn, { value: f, children: h }, m))
42
+ }
43
+ );
44
+ }, Gn = "90vh", Wn = F(V.Body)`
45
+ & > [data-orientation] {
46
+ padding: 0;
47
+ }
48
+
49
+ // Content never scrolls sideways here; tables scroll inside their own wrapper.
50
+ & > [data-orientation='horizontal'] {
51
+ display: none;
52
+ }
53
+
54
+ & > [data-orientation='vertical'] > div {
55
+ background-color: ${({ theme: e }) => e.colors.neutral300};
56
+ }
57
+ `, ae = ({
58
+ open: e,
59
+ onClose: t,
60
+ title: n,
61
+ children: s,
62
+ onSubmit: r,
63
+ isConfirmButtonLoading: i = !1,
64
+ confirmButtonText: a,
65
+ isConfirmButtonDisabled: l = !1,
66
+ fillMaxHeight: c = !1,
67
+ secondaryActions: m,
68
+ isCloseDisabled: h = !1,
69
+ scrollResetKey: f
70
+ }) => {
71
+ const { formatMessage: g } = v(), y = Ye(null);
72
+ Kn(() => {
73
+ y.current && (y.current.scrollTop = 0);
74
+ }, [f]);
75
+ const C = !!(r || m);
76
+ return /* @__PURE__ */ o(V.Root, { open: e, onOpenChange: () => !h && t(), children: /* @__PURE__ */ u(V.Content, { style: c ? { height: Gn } : void 0, children: [
77
+ /* @__PURE__ */ o(V.Header, { children: /* @__PURE__ */ o(V.Title, { children: n }) }),
78
+ /* @__PURE__ */ o(Wn, { type: "auto", viewportRef: y, children: s }),
79
+ /* @__PURE__ */ u(V.Footer, { style: C ? void 0 : { justifyContent: "flex-end" }, children: [
80
+ /* @__PURE__ */ o(V.Close, { children: /* @__PURE__ */ o(k, { variant: "tertiary", disabled: h, children: g({ id: d("common.button.close") }) }) }),
81
+ C && /* @__PURE__ */ u(b, { gap: 2, children: [
82
+ m,
83
+ r && /* @__PURE__ */ o(
84
+ k,
85
+ {
86
+ loading: i,
87
+ disabled: l,
88
+ onClick: r,
89
+ children: a || g({ id: d("common.button.submit") })
90
+ }
91
+ )
92
+ ] })
93
+ ] })
94
+ ] }) });
95
+ }, le = {
96
+ all: ["sync"],
97
+ lists: () => [...le.all, "list"],
98
+ list: (e) => [...le.lists(), { uid: e }]
99
+ }, Tt = "entities-comparison", jn = ({ uid: e, page: t = 1, pageSize: n = 10, enabled: s = !0 }) => {
100
+ const { get: r } = K();
101
+ return X({
102
+ queryKey: [Tt, { uid: e, page: t, pageSize: n }],
103
+ queryFn: async () => {
104
+ const { data: i } = await r(
105
+ `/${q}/entity-comparison/${e}?page=${t}&pageSize=${n}`
106
+ );
107
+ return i;
108
+ },
109
+ enabled: !!e && s
110
+ });
111
+ }, Mt = (e) => {
112
+ e.invalidateQueries({ queryKey: [Tt] });
113
+ }, Le = (e, t) => {
114
+ e.invalidateQueries({ queryKey: t ? le.list(t) : le.lists() }), Mt(e);
115
+ }, Qn = () => {
116
+ const { post: e } = K(), t = he();
117
+ return xe({
118
+ mutationFn: async (n) => await e(`/${q}/snapshot/${n}/sync`),
119
+ onSuccess: (n, s) => {
120
+ Le(t, s);
121
+ }
122
+ });
123
+ }, xt = ({ open: e, onClose: t, contentTypeUid: n }) => {
124
+ const { formatMessage: s } = v(), {
125
+ mutate: r,
126
+ isPending: i,
127
+ error: a,
128
+ reset: l
129
+ } = Qn();
130
+ return /* @__PURE__ */ o(
131
+ ae,
132
+ {
133
+ open: e,
134
+ onClose: () => {
135
+ t(), l();
136
+ },
137
+ onSubmit: () => {
138
+ r(n, {
139
+ onSuccess: t
140
+ });
141
+ },
142
+ title: s({
143
+ id: d("homePage.modal.getNewSnapshot.title")
144
+ }),
145
+ confirmButtonText: s({
146
+ id: d("homePage.modal.getNewSnapshot.confirmButtonText")
147
+ }),
148
+ isConfirmButtonDisabled: i || !n,
149
+ isConfirmButtonLoading: i,
150
+ children: /* @__PURE__ */ u(b, { direction: "column", gap: 4, alignItems: "stretch", children: [
151
+ /* @__PURE__ */ o(S, { variant: "omega", children: s({
152
+ id: d("homePage.modal.getNewSnapshot.description")
153
+ }) }),
154
+ a && /* @__PURE__ */ o(S, { variant: "omega", textColor: "danger500", children: me(a, s) })
155
+ ] })
156
+ }
157
+ );
158
+ }, Vn = ({
159
+ contentTypeUid: e,
160
+ selectedPromotionsLength: t,
161
+ syncedAt: n,
162
+ isGetSnapshotDisabled: s = !1,
163
+ hasSnapshot: r,
164
+ clearSelectedPromotions: i,
165
+ canExecute: a,
166
+ privateFields: l = []
167
+ }) => {
168
+ const { formatMessage: c } = v(), [m, h] = R(!1), f = c(
169
+ { id: d("homePage.comparison.privateFields.tooltip") },
170
+ { count: l.length, fields: l.join(", ") }
171
+ );
172
+ return /* @__PURE__ */ u(
173
+ b,
174
+ {
175
+ direction: "row",
176
+ justifyContent: "space-between",
177
+ alignItems: "center",
178
+ marginBottom: 1,
179
+ marginTop: 1,
180
+ children: [
181
+ e && r ? /* @__PURE__ */ u(b, { direction: "row", gap: 3, alignItems: "center", children: [
182
+ /* @__PURE__ */ o(S, { variant: "omega", children: c(
183
+ { id: d("homePage.selectedEntities") },
184
+ { count: t }
185
+ ) }),
186
+ t > 0 && a ? /* @__PURE__ */ o(k, { variant: "secondary", onClick: i, children: c({ id: d("homePage.clearSelectedEntities") }) }) : null
187
+ ] }) : null,
188
+ n ? /* @__PURE__ */ u(b, { direction: "row", gap: 3, alignItems: "center", children: [
189
+ /* @__PURE__ */ u(b, { direction: "row", gap: 1, alignItems: "center", children: [
190
+ /* @__PURE__ */ o(S, { variant: "omega", textColor: "neutral600", children: c(
191
+ { id: d("homePage.lastSync") },
192
+ {
193
+ lastSync: new Date(n).toLocaleString()
194
+ }
195
+ ) }),
196
+ /* @__PURE__ */ o(
197
+ _,
198
+ {
199
+ label: c({ id: d("homePage.comparison.publishedOnlyHint") }),
200
+ children: /* @__PURE__ */ o(
201
+ Ue,
202
+ {
203
+ "aria-label": c({
204
+ id: d("homePage.comparison.publishedOnlyHint")
205
+ })
206
+ }
207
+ )
208
+ }
209
+ )
210
+ ] }),
211
+ l.length > 0 ? /* @__PURE__ */ u(D, { children: [
212
+ /* @__PURE__ */ o(S, { variant: "omega", textColor: "neutral300", "aria-hidden": !0, children: "|" }),
213
+ /* @__PURE__ */ u(b, { direction: "row", gap: 1, alignItems: "center", children: [
214
+ /* @__PURE__ */ o(S, { variant: "omega", textColor: "neutral600", children: c(
215
+ { id: d("homePage.comparison.privateFields.label") },
216
+ { count: l.length }
217
+ ) }),
218
+ /* @__PURE__ */ o(_, { label: f, children: /* @__PURE__ */ o(Ue, { "aria-label": f }) })
219
+ ] })
220
+ ] }) : null,
221
+ a ? /* @__PURE__ */ o(
222
+ k,
223
+ {
224
+ variant: "secondary",
225
+ onClick: () => h(!0),
226
+ disabled: s,
227
+ children: c({
228
+ id: d("homePage.getNewSnapshot")
229
+ })
230
+ }
231
+ ) : null
232
+ ] }) : null,
233
+ a ? /* @__PURE__ */ o(
234
+ xt,
235
+ {
236
+ open: m,
237
+ onClose: () => h(!1),
238
+ contentTypeUid: e
239
+ }
240
+ ) : null
241
+ ]
242
+ }
243
+ );
244
+ }, Yn = ({ canReadSettings: e }) => {
245
+ const { formatMessage: t } = v();
246
+ return /* @__PURE__ */ o(
247
+ $,
248
+ {
249
+ title: t({ id: d("homePage.alert.invalidLicense.title") }),
250
+ variant: "danger",
251
+ description: t({
252
+ id: d(
253
+ e ? "homePage.alert.invalidLicense.description" : "homePage.alert.invalidLicense.readOnlyDescription"
254
+ )
255
+ }),
256
+ action: e ? /* @__PURE__ */ o(b, { children: /* @__PURE__ */ o(Qe, { tag: je, to: "/settings/xecp/about", children: t({ id: d("homePage.alert.invalidLicense.linkText") }) }) }) : void 0
257
+ }
258
+ );
259
+ }, Xn = ({ compareSchemasData: e, errorCompareSchemas: t }) => {
260
+ const { formatMessage: n } = v(), s = e && !e?.isMatch, r = () => n(s ? { id: d("homePage.alert.schemaMismatch.title") } : { id: d("homePage.error") }), i = () => {
261
+ switch (!0) {
262
+ case s:
263
+ return n({ id: d("homePage.alert.schemaMismatch.description") });
264
+ case !!t:
265
+ return t;
266
+ default:
267
+ return n({ id: d("homePage.somethingWentWrong") });
268
+ }
269
+ };
270
+ return /* @__PURE__ */ o($, { title: r(), variant: "danger", children: i() });
271
+ }, Jn = ({
272
+ contentTypeUid: e,
273
+ hasExistingSnapshot: t,
274
+ unconfiguredRelationsError: n,
275
+ isGetSnapshotDisabled: s = !1,
276
+ canExecute: r,
277
+ canReadSettings: i
278
+ }) => {
279
+ const { formatMessage: a } = v(), [l, c] = R(!1);
280
+ return !t && !n ? /* @__PURE__ */ u(D, { children: [
281
+ /* @__PURE__ */ o(
282
+ ie,
283
+ {
284
+ content: a({
285
+ id: d(
286
+ r ? "homePage.alert.noSync.description" : "homePage.alert.noSync.readOnlyDescription"
287
+ )
288
+ }),
289
+ action: r ? /* @__PURE__ */ o(
290
+ k,
291
+ {
292
+ onClick: () => c(!0),
293
+ disabled: s,
294
+ children: a({ id: d("homePage.alert.noSync.linkText") })
295
+ }
296
+ ) : void 0
297
+ }
298
+ ),
299
+ r ? /* @__PURE__ */ o(
300
+ xt,
301
+ {
302
+ open: l,
303
+ onClose: () => c(!1),
304
+ contentTypeUid: e
305
+ }
306
+ ) : null
307
+ ] }) : /* @__PURE__ */ u(D, { children: [
308
+ n ? /* @__PURE__ */ o(
309
+ $,
310
+ {
311
+ title: a({
312
+ id: d("homePage.alert.unconfiguredRelations.title")
313
+ }),
314
+ variant: "danger",
315
+ action: i ? /* @__PURE__ */ o(Qe, { tag: je, to: "/settings/xecp/configuration", children: a({
316
+ id: d("homePage.alert.unconfiguredRelations.linkText")
317
+ }) }) : void 0,
318
+ description: a(
319
+ {
320
+ id: d(
321
+ i ? "homePage.alert.unconfiguredRelations.description" : "homePage.alert.unconfiguredRelations.readOnlyDescription"
322
+ )
323
+ },
324
+ { relations: n.unconfiguredRelations.join(", ") }
325
+ )
326
+ }
327
+ ) : null,
328
+ /* @__PURE__ */ o(ie, { content: a({ id: d("homePage.emptyState") }) })
329
+ ] });
330
+ }, Xe = (e) => [
331
+ e,
332
+ ...e.localizations ?? []
333
+ ], Lt = (e) => (e ?? []).flatMap(Xe), Zn = (e, t) => {
334
+ const n = t?.find((s) => s.documentId === e);
335
+ return n ? Xe(n) : [];
336
+ }, zn = (e) => {
337
+ const t = e[0];
338
+ return t ? {
339
+ ...t,
340
+ localizations: e.slice(1)
341
+ } : null;
342
+ }, ke = (e, t) => {
343
+ if (!t) return e.uniqueKeyValue;
344
+ const n = e?.[t];
345
+ return typeof n == "string" || typeof n == "number" ? String(n) : e.uniqueKeyValue;
346
+ }, Pe = (e) => ({
347
+ documentId: e.documentId,
348
+ locale: e.locale ?? "default"
349
+ }), ce = (e, t) => e.documentId === t.documentId && e.locale === t.locale, Ce = (e, t) => t.some((n) => ce(n, Pe(e))), eo = (e) => [
350
+ ...new Set(e.map((t) => t.documentId))
351
+ ], to = (e, t) => {
352
+ if (e.length === 0)
353
+ return !1;
354
+ const n = e.filter(
355
+ (s) => t.has(s)
356
+ ).length;
357
+ return n === 0 ? !1 : n === e.length ? !0 : "indeterminate";
358
+ }, no = (e, t, n) => {
359
+ const s = new Set(e);
360
+ return n ? s.add(t) : s.delete(t), s;
361
+ }, oo = (e) => e?.draftAndPublish || !1, so = (e, {
362
+ mediaDocumentIds: t,
363
+ publishDocumentIds: n
364
+ }) => e.map((s) => ({
365
+ documentId: s,
366
+ includeMedia: t.has(s),
367
+ publish: n.has(s)
368
+ })), ro = "homePage.missingUniqueKey", ve = {
369
+ single: "homePage.hint.missingUniqueKey.single",
370
+ allLocales: "homePage.hint.missingUniqueKey.allLocales",
371
+ someLocales: "homePage.hint.missingUniqueKey.someLocales"
372
+ }, ee = (e, t) => e !== "up_to_date" && t !== "missing_unique_key", io = (e) => {
373
+ switch (!0) {
374
+ case e.every((t) => t.warning === "missing_unique_key"):
375
+ return "allLocales";
376
+ case e.some((t) => t.warning === "missing_unique_key"):
377
+ return "someLocales";
378
+ default:
379
+ return null;
380
+ }
381
+ }, kt = (e, t, n) => {
382
+ if (!e)
383
+ return "homePage.tooltip.noExecutePermission";
384
+ switch (!0) {
385
+ case t === "up_to_date":
386
+ return "homePage.tooltip.upToDate";
387
+ case n === "missing_unique_key":
388
+ return ve.single;
389
+ default:
390
+ return null;
391
+ }
392
+ }, Rt = (e, t) => {
393
+ if (!e)
394
+ return "homePage.tooltip.noExecutePermission";
395
+ switch (!0) {
396
+ case t.some((n) => ee(n.status, n.warning)):
397
+ return null;
398
+ case t.every((n) => n.status === "up_to_date"):
399
+ return "homePage.tooltip.allEntitiesUpToDate";
400
+ case t.every((n) => n.warning === "missing_unique_key"):
401
+ return ve.allLocales;
402
+ default:
403
+ return ve.someLocales;
404
+ }
405
+ }, He = ({
406
+ checked: e,
407
+ onCheckedChange: t,
408
+ disable: n = !1,
409
+ tooltipLabel: s = ""
410
+ }) => /* @__PURE__ */ o("div", { onClick: (r) => r.stopPropagation(), children: /* @__PURE__ */ o(_, { label: n ? s : "", align: "start", children: /* @__PURE__ */ o(Fe, { checked: e, onCheckedChange: t, disabled: n }) }) }), Je = ({ locale: e }) => {
411
+ const { formatMessage: t } = v();
412
+ return e === "default" ? /* @__PURE__ */ o(Se, { variant: "neutral", children: t({ id: d("homePage.promotionResults.locale.nonLocalized") }) }) : /* @__PURE__ */ o(Se, { variant: "neutral", children: e });
413
+ }, ao = (e) => {
414
+ switch (e) {
415
+ case "new":
416
+ return "homePage.table.status.new";
417
+ case "changed":
418
+ return "homePage.table.status.changed";
419
+ case "up_to_date":
420
+ return "homePage.table.status.upToDate";
421
+ default:
422
+ return "homePage.table.status.new";
423
+ }
424
+ }, lo = (e) => {
425
+ switch (e) {
426
+ case "new":
427
+ return "success";
428
+ case "changed":
429
+ return "danger";
430
+ case "up_to_date":
431
+ return "neutral";
432
+ default:
433
+ return "success";
434
+ }
435
+ }, Dt = ({ status: e }) => {
436
+ const { formatMessage: t } = v();
437
+ return /* @__PURE__ */ o(Se, { variant: lo(e), children: t({
438
+ id: d(ao(e))
439
+ }) });
440
+ }, co = ({ shouldShow: e, message: t, tooltipLabel: n }) => e ? /* @__PURE__ */ o(_, { label: n, align: "start", children: /* @__PURE__ */ u(b, { direction: "row", gap: 1, alignItems: "center", children: [
441
+ /* @__PURE__ */ o(ue, { fill: "warning500", width: 20, height: 20 }),
442
+ /* @__PURE__ */ o(S, { variant: "pi", textColor: "warning500", children: t })
443
+ ] }) }) : null, At = ({ uniqueKey: e, missingUniqueKeyScope: t, maxCharacters: n = 40 }) => {
444
+ const { formatMessage: s } = v();
445
+ if (!t)
446
+ return /* @__PURE__ */ o(
447
+ B,
448
+ {
449
+ maxCharacters: n,
450
+ text: e || "N/A",
451
+ variant: "pi",
452
+ textColor: "neutral600"
453
+ }
454
+ );
455
+ const r = s({
456
+ id: d(ro)
457
+ }), i = s({
458
+ id: d(ve[t])
459
+ }), a = /* @__PURE__ */ o(co, { shouldShow: !0, tooltipLabel: i, message: r });
460
+ return t === "someLocales" && e ? /* @__PURE__ */ u(b, { direction: "row", gap: 2, alignItems: "center", children: [
461
+ /* @__PURE__ */ o(
462
+ B,
463
+ {
464
+ maxCharacters: n,
465
+ text: e,
466
+ variant: "pi",
467
+ textColor: "neutral600"
468
+ }
469
+ ),
470
+ a
471
+ ] }) : a;
472
+ }, Ot = ({
473
+ entryTitle: e,
474
+ uniqueKey: t,
475
+ missingUniqueKeyScope: n,
476
+ locale: s,
477
+ titleMaxCharacters: r = 60,
478
+ checked: i,
479
+ onCheckedChange: a,
480
+ checkboxDisabled: l = !1,
481
+ checkboxTooltipLabel: c,
482
+ status: m
483
+ }) => {
484
+ const h = /* @__PURE__ */ o(
485
+ B,
486
+ {
487
+ maxCharacters: r,
488
+ text: e,
489
+ variant: "omega",
490
+ fontWeight: "semiBold"
491
+ }
492
+ );
493
+ return /* @__PURE__ */ u(D, { children: [
494
+ /* @__PURE__ */ u(b, { direction: "row", gap: 4, alignItems: "center", children: [
495
+ /* @__PURE__ */ o(
496
+ He,
497
+ {
498
+ checked: i,
499
+ onCheckedChange: a,
500
+ disable: l,
501
+ tooltipLabel: c
502
+ }
503
+ ),
504
+ s ? /* @__PURE__ */ u(b, { direction: "row", gap: 2, alignItems: "center", children: [
505
+ /* @__PURE__ */ o(Je, { locale: s }),
506
+ h
507
+ ] }) : h,
508
+ /* @__PURE__ */ o(At, { uniqueKey: t, missingUniqueKeyScope: n })
509
+ ] }),
510
+ /* @__PURE__ */ o(Dt, { status: m })
511
+ ] });
512
+ }, uo = ({
513
+ entryTitle: e,
514
+ uniqueKey: t,
515
+ status: n,
516
+ warning: s,
517
+ locale: r,
518
+ isChecked: i,
519
+ onCheckItemChange: a,
520
+ canExecute: l
521
+ }) => {
522
+ const { formatMessage: c } = v(), m = !l || !ee(n, s), h = kt(l, n, s);
523
+ return /* @__PURE__ */ o(
524
+ b,
525
+ {
526
+ direction: "row",
527
+ justifyContent: "space-between",
528
+ alignItems: "center",
529
+ background: "neutral0",
530
+ style: {
531
+ width: "100%",
532
+ padding: "24px"
533
+ },
534
+ grow: 1,
535
+ gap: 4,
536
+ children: /* @__PURE__ */ o(
537
+ Ot,
538
+ {
539
+ entryTitle: e,
540
+ uniqueKey: t,
541
+ missingUniqueKeyScope: s === "missing_unique_key" ? "single" : null,
542
+ locale: r,
543
+ checked: i,
544
+ onCheckedChange: a,
545
+ checkboxDisabled: m,
546
+ checkboxTooltipLabel: h ? c({ id: d(h) }) : void 0,
547
+ status: n
548
+ }
549
+ )
550
+ }
551
+ );
552
+ }, mo = ({
553
+ isAllCheckedInEntity: e,
554
+ onCheckAllInEntity: t,
555
+ entityWithLocalizations: n,
556
+ selectedPromotions: s,
557
+ onCheckItemChange: r,
558
+ isIndeterminate: i,
559
+ contentTypeMainField: a,
560
+ canExecute: l
561
+ }) => {
562
+ const { formatMessage: c } = v(), m = [
563
+ {
564
+ key: "checkbox"
565
+ },
566
+ {
567
+ key: "locale",
568
+ label: c({ id: d("homePage.table.locale") })
569
+ },
570
+ {
571
+ key: "entryTitle",
572
+ label: c({ id: d("homePage.table.entryTitle") })
573
+ },
574
+ {
575
+ key: "key",
576
+ label: c({ id: d("homePage.table.key") })
577
+ },
578
+ {
579
+ key: "status",
580
+ label: c({ id: d("homePage.table.status") })
581
+ }
582
+ ], h = !n?.some(
583
+ (g) => ee(g.status, g.warning)
584
+ ), f = Rt(
585
+ l,
586
+ n ?? []
587
+ );
588
+ return /* @__PURE__ */ u(Ve, { colCount: m.length, rowCount: n?.length ?? 0, children: [
589
+ /* @__PURE__ */ o(we, { children: /* @__PURE__ */ o(G, { children: m.map((g) => /* @__PURE__ */ o(O, { children: g.key === "checkbox" ? /* @__PURE__ */ o(
590
+ He,
591
+ {
592
+ checked: i ? "indeterminate" : e,
593
+ onCheckedChange: t,
594
+ disable: h || !l,
595
+ tooltipLabel: f ? c({ id: d(f) }) : ""
596
+ }
597
+ ) : /* @__PURE__ */ o(S, { variant: "sigma", children: g.label }) }, g.key)) }) }),
598
+ /* @__PURE__ */ o(Ee, { children: n?.map((g) => {
599
+ const y = !l || !ee(g.status, g.warning), C = kt(
600
+ l,
601
+ g.status,
602
+ g.warning
603
+ );
604
+ return /* @__PURE__ */ u(G, { children: [
605
+ /* @__PURE__ */ o(L, { children: /* @__PURE__ */ o(
606
+ He,
607
+ {
608
+ checked: Ce(g, s),
609
+ onCheckedChange: r(g),
610
+ disable: y,
611
+ tooltipLabel: C ? c({ id: d(C) }) : ""
612
+ }
613
+ ) }),
614
+ /* @__PURE__ */ o(L, { children: g?.locale ? /* @__PURE__ */ o(Je, { locale: g.locale }) : null }),
615
+ /* @__PURE__ */ o(L, { children: /* @__PURE__ */ o(
616
+ B,
617
+ {
618
+ maxCharacters: 50,
619
+ text: ke(g, a) || ""
620
+ }
621
+ ) }),
622
+ /* @__PURE__ */ o(L, { children: /* @__PURE__ */ o(
623
+ At,
624
+ {
625
+ uniqueKey: g?.uniqueKeyValue,
626
+ missingUniqueKeyScope: g?.warning === "missing_unique_key" ? "single" : null
627
+ }
628
+ ) }),
629
+ /* @__PURE__ */ o(L, { children: /* @__PURE__ */ o(Dt, { status: g?.status }) })
630
+ ] }, `${g.documentId}-${g.locale}`);
631
+ }) })
632
+ ] });
633
+ }, ho = F(se.Trigger)`
634
+ width: 100%;
635
+ & > span:first-child {
636
+ width: 100%;
637
+ display: flex;
638
+ justify-content: space-between;
639
+ & > span {
640
+ width: 100%;
641
+ }
642
+ }
643
+ `, go = ({
644
+ uniqueKey: e,
645
+ entityWithLocalizations: t,
646
+ entryTitle: n,
647
+ selectedPromotions: s,
648
+ setSelectedPromotions: r,
649
+ onCheckItemChange: i,
650
+ contentTypeMainField: a,
651
+ onRememberEntityGroup: l,
652
+ canExecute: c
653
+ }) => {
654
+ const { formatMessage: m } = v(), h = t.filter(
655
+ (p) => ee(p.status, p.warning)
656
+ ), f = (p) => {
657
+ r((M) => {
658
+ const Re = h.map(
659
+ (U) => Pe(U)
660
+ ), Q = (U) => t.some(
661
+ (H) => ce(U, Pe(H))
662
+ );
663
+ return p ? (l?.(t), [...M.filter((H) => !Q(H)), ...Re]) : M.filter((U) => !Q(U));
664
+ });
665
+ }, g = t?.some(
666
+ (p) => Ce(p, s)
667
+ ), y = h.length > 0 && h.every(
668
+ (p) => Ce(p, s)
669
+ ), C = h.length === 0, P = Rt(
670
+ c,
671
+ t
672
+ ), I = io(t), T = (() => {
673
+ switch (!0) {
674
+ case t?.some((p) => p?.status === "new"):
675
+ return "new";
676
+ case t?.some((p) => p?.status === "changed"):
677
+ return "changed";
678
+ default:
679
+ return "up_to_date";
680
+ }
681
+ })(), j = g && !y;
682
+ return /* @__PURE__ */ o(se.Root, { style: { width: "100%" }, size: "M", children: /* @__PURE__ */ u(se.Item, { value: `${n}-${e}`, children: [
683
+ /* @__PURE__ */ o(se.Header, { children: /* @__PURE__ */ o(ho, { caretPosition: "right", children: /* @__PURE__ */ o(
684
+ b,
685
+ {
686
+ direction: "row",
687
+ justifyContent: "space-between",
688
+ alignItems: "center",
689
+ style: { width: "100%" },
690
+ grow: 1,
691
+ gap: 4,
692
+ children: /* @__PURE__ */ o(
693
+ Ot,
694
+ {
695
+ entryTitle: n,
696
+ uniqueKey: e,
697
+ missingUniqueKeyScope: I,
698
+ checked: j ? "indeterminate" : y,
699
+ onCheckedChange: f,
700
+ checkboxDisabled: C || !c,
701
+ checkboxTooltipLabel: P ? m({ id: d(P) }) : void 0,
702
+ status: T
703
+ }
704
+ )
705
+ }
706
+ ) }) }),
707
+ /* @__PURE__ */ o(se.Content, { children: /* @__PURE__ */ o(
708
+ mo,
709
+ {
710
+ isAllCheckedInEntity: y,
711
+ onCheckAllInEntity: f,
712
+ entityWithLocalizations: t,
713
+ selectedPromotions: s,
714
+ onCheckItemChange: i,
715
+ isIndeterminate: j,
716
+ contentTypeMainField: a,
717
+ canExecute: c
718
+ }
719
+ ) })
720
+ ] }) });
721
+ }, po = ({
722
+ entities: e,
723
+ contentTypeMainField: t,
724
+ selectedPromotions: n,
725
+ setSelectedPromotions: s,
726
+ onRememberEntityGroup: r,
727
+ canExecute: i
728
+ }) => {
729
+ const a = (c) => (m) => (h) => {
730
+ const f = Pe(m);
731
+ s((g) => h ? g.some((y) => ce(y, f)) ? g : (r?.(c), [...g, f]) : g.filter((y) => !ce(y, f)));
732
+ }, l = (c, m) => {
733
+ const h = ke(c, t), f = c?.uniqueKeyValue || "";
734
+ return m.length > 1 ? /* @__PURE__ */ o(
735
+ go,
736
+ {
737
+ uniqueKey: f,
738
+ contentTypeMainField: t,
739
+ entityWithLocalizations: m,
740
+ entryTitle: h || "",
741
+ selectedPromotions: n,
742
+ setSelectedPromotions: s,
743
+ onCheckItemChange: a(m),
744
+ onRememberEntityGroup: r,
745
+ canExecute: i
746
+ }
747
+ ) : /* @__PURE__ */ o(
748
+ uo,
749
+ {
750
+ entryTitle: h || "",
751
+ uniqueKey: f,
752
+ status: c?.status,
753
+ warning: c?.warning,
754
+ locale: c?.locale,
755
+ isChecked: Ce(c, n),
756
+ onCheckItemChange: a(m)(c),
757
+ canExecute: i
758
+ }
759
+ );
760
+ };
761
+ return /* @__PURE__ */ o("div", { children: e?.map((c, m) => {
762
+ const h = Xe(c);
763
+ return /* @__PURE__ */ u(Et, { children: [
764
+ l(c, h),
765
+ e?.length - 1 > m && /* @__PURE__ */ o(Dn, {})
766
+ ] }, c?.documentId);
767
+ }) });
768
+ }, x = (e) => {
769
+ const { formatMessage: t } = v();
770
+ return (n, s) => t({ id: d(e ? `${e}.${n}` : n) }, s);
771
+ }, fo = () => {
772
+ const { post: e } = K(), t = he();
773
+ return xe({
774
+ mutationFn: async (n) => {
775
+ const { data: s } = await e(
776
+ `/${q}/promotion`,
777
+ n
778
+ );
779
+ return s;
780
+ },
781
+ onSuccess: () => {
782
+ Mt(t);
783
+ }
784
+ });
785
+ }, _t = (e = !0) => {
786
+ const { get: t } = K();
787
+ return X({
788
+ queryKey: [Tn],
789
+ enabled: e,
790
+ queryFn: async () => {
791
+ const { data: n } = await t(
792
+ `/${q}/promotion/promotable-content-types`
793
+ );
794
+ return n.contentTypes;
795
+ }
796
+ });
797
+ }, yo = (e) => {
798
+ const { get: t } = K();
799
+ return X({
800
+ queryKey: [Mn, "related-content-types", e],
801
+ queryFn: async () => {
802
+ const { data: n } = await t(
803
+ `/${q}/promotion/related-content-types`,
804
+ {
805
+ params: {
806
+ contentTypeUid: e
807
+ }
808
+ }
809
+ );
810
+ return n;
811
+ },
812
+ enabled: !!e
813
+ });
814
+ }, bo = (e) => {
815
+ const { data: t, isLoading: n } = _t(), { data: s, isLoading: r } = yo(e), i = Y(
816
+ () => s?.contentTypes ?? [],
817
+ [s]
818
+ ), a = Y(
819
+ () => [...t ?? [], ...i],
820
+ [t, i]
821
+ ), l = t?.find(
822
+ (c) => c.uid === e
823
+ );
824
+ return {
825
+ primaryContentType: l,
826
+ hasDraftAndPublish: oo(l),
827
+ relatedContentTypes: i,
828
+ contentTypes: a,
829
+ isLoading: n || r
830
+ };
831
+ }, ht = (e) => {
832
+ const [t, n] = R(() => /* @__PURE__ */ new Set());
833
+ return { enabledDocumentIds: t, isEnabled: (a) => t.has(a), set: (a, l) => {
834
+ n((c) => no(c, a, l));
835
+ }, setAll: (a) => {
836
+ n(a ? new Set(e) : /* @__PURE__ */ new Set());
837
+ } };
838
+ }, Ge = [
839
+ "entities",
840
+ "relatedEntries",
841
+ "publish",
842
+ "media",
843
+ "embeddedMedia",
844
+ "summary"
845
+ ], gt = (e, t) => Ge.indexOf(e) > Ge.indexOf(t), So = (e) => {
846
+ const [t, n] = R("entities"), [s, r] = R("entities"), i = Ge.filter(
847
+ (f) => f !== "relatedEntries" || e
848
+ ), a = i.indexOf(t), l = i.filter((f) => !gt(f, s)).length - 1;
849
+ return {
850
+ currentStep: t,
851
+ visibleSteps: i,
852
+ stepIndex: a,
853
+ furthestStepIndex: l,
854
+ isSummaryStep: t === "summary",
855
+ goBack: () => n(i[Math.max(a - 1, 0)]),
856
+ goToIndex: (f) => n(i[f]),
857
+ goNext: () => {
858
+ const f = i[a + 1] ?? "summary";
859
+ n(f), r((g) => gt(f, g) ? f : g);
860
+ }
861
+ };
862
+ }, Po = (e, t) => ({
863
+ includeMedia: e.some((n) => n?.includeMedia === !0),
864
+ publishOnTarget: !t || e.some((n) => n?.publish === !0)
865
+ }), Ze = (e) => {
866
+ const t = [];
867
+ for (const { locale: n, outcome: s } of e) {
868
+ const r = t.find((i) => i.outcome === s);
869
+ r ? r.locales.push(n) : t.push({ outcome: s, locales: [n] });
870
+ }
871
+ return t;
872
+ }, $t = (e, t) => Ze(
873
+ e.locales.map((n) => ({
874
+ locale: n,
875
+ outcome: t(e.statusByLocale[n])
876
+ }))
877
+ ), Kt = (e, t) => {
878
+ const n = [...e].sort();
879
+ return !t || !n.includes(t) ? n : [t, ...n.filter((s) => s !== t)];
880
+ }, Co = (e, t) => e.name.localeCompare(t.name), vo = (e, t) => e.title.localeCompare(t.title), Io = (e, t) => {
881
+ const n = /* @__PURE__ */ new Map();
882
+ for (const s of e) {
883
+ if (s.contentTypeUid !== t)
884
+ continue;
885
+ const r = n.get(s.documentId);
886
+ r ? r.push(s) : n.set(s.documentId, [s]);
887
+ }
888
+ return n;
889
+ }, wo = (e, t, n, s) => {
890
+ const r = e in n, i = t.find((l) => l.title !== null)?.title, a = [...new Set(t.flatMap((l) => l.origins))];
891
+ return {
892
+ documentId: e,
893
+ title: (r ? n[e] : i) ?? t[0].uniqueKey,
894
+ uniqueKey: t[0].uniqueKey,
895
+ locales: Kt(
896
+ t.map((l) => l.locale),
897
+ s
898
+ ),
899
+ originsByLocale: Object.fromEntries(
900
+ t.map((l) => [l.locale, l.origins])
901
+ ),
902
+ linkedFrom: a.map((l) => ({ id: l, name: n[l] ?? l })).sort(Co),
903
+ isSelectedEntry: r
904
+ };
905
+ }, Eo = (e, t, n, s) => [...Io(e, t)].map(
906
+ ([r, i]) => wo(r, i, n, s)
907
+ ).sort(vo), qt = (e) => {
908
+ const t = [], n = [];
909
+ for (const s of e)
910
+ (s.isSelectedEntry ? t : n).push(s);
911
+ return { selectedEntriesWithMoreLocales: t, otherRelatedEntries: n };
912
+ }, Nt = (e) => e.reduce((t, n) => t + n.locales.length, 0), Ke = (e, t) => Ze(
913
+ e.locales.map((n) => ({
914
+ locale: n,
915
+ outcome: t(e.originsByLocale[n])
916
+ }))
917
+ ), To = (e, {
918
+ publishDocumentIds: t,
919
+ mediaDocumentIds: n,
920
+ hasDraftAndPublish: s
921
+ }) => Po(
922
+ e.map((r) => ({
923
+ includeMedia: n.has(r),
924
+ publish: t.has(r)
925
+ })),
926
+ s
927
+ ), Mo = ({ contentTypeUid: e, selections: t }) => {
928
+ const { post: n } = K();
929
+ return X({
930
+ queryKey: [xn, e, t],
931
+ queryFn: async ({ signal: s }) => {
932
+ const { data: r } = await n(
933
+ `/${q}/promotion/preview`,
934
+ { contentTypeUid: e, selections: t },
935
+ { signal: s }
936
+ );
937
+ return r;
938
+ },
939
+ enabled: !!e && t.length > 0,
940
+ staleTime: 1 / 0,
941
+ gcTime: 0,
942
+ // Retry once on network errors and 5xx. A 4xx (bad selection, missing content type, sync
943
+ // already running) would fail the same way again, after rerunning discovery on the server.
944
+ retry: (s, r) => s < 1 && !(Cn(r) && r.status !== void 0 && r.status < 500)
945
+ });
946
+ }, xo = ({
947
+ contentTypeUid: e,
948
+ selections: t,
949
+ titles: n,
950
+ defaultLocale: s,
951
+ contentTypeName: r
952
+ }) => {
953
+ const { formatMessage: i } = v(), a = Mo({ contentTypeUid: e, selections: t }), l = Y(
954
+ () => Eo(
955
+ a.data?.entries ?? [],
956
+ e,
957
+ n,
958
+ s
959
+ ),
960
+ [a.data, e, n, s]
961
+ );
962
+ return {
963
+ relatedPrimary: {
964
+ contentTypeName: r,
965
+ entries: l,
966
+ error: a.isError ? me(
967
+ a.error,
968
+ i,
969
+ "homePage.modal.confirmPromotion.relatedPrimary.error.description"
970
+ ) : void 0
971
+ },
972
+ relatedEntriesContentType: l.length > 0 ? r : void 0,
973
+ isLoading: a.isLoading
974
+ };
975
+ }, Lo = (e) => e.filter((t) => ee(t.status, t.warning)).map((t) => t.locale ?? "default"), ko = (e, t) => e.length > 0 && e.every((n) => t.includes(n)), Ro = (e, t, n, s) => {
976
+ const r = /* @__PURE__ */ new Map();
977
+ for (const c of t ?? [])
978
+ r.set(c.documentId, c);
979
+ const i = Lt(t), a = /* @__PURE__ */ new Map();
980
+ for (const c of e) {
981
+ const m = a.get(c.documentId) ?? [];
982
+ m.push(c), a.set(c.documentId, m);
983
+ }
984
+ return [...new Set(e.map((c) => c.documentId))].map((c) => {
985
+ const m = a.get(c) ?? [], f = r.get(c) ?? i.find((I) => I.documentId === c) ?? i.find(
986
+ (I) => m.some(
987
+ (E) => ce(E, {
988
+ documentId: I.documentId,
989
+ locale: I.locale ?? "default"
990
+ })
991
+ )
992
+ ), g = Kt(
993
+ m.map((I) => I.locale),
994
+ s
995
+ ), y = Zn(c, t), C = Lo(y), P = {};
996
+ for (const I of y) {
997
+ const E = I.locale ?? "default";
998
+ g.includes(E) && (P[E] = I.status);
999
+ }
1000
+ return {
1001
+ documentId: c,
1002
+ title: f ? ke(f, n) ?? c : c,
1003
+ locales: g,
1004
+ allLocalesSelected: ko(C, g),
1005
+ uniqueKey: f?.uniqueKeyValue ?? null,
1006
+ statusByLocale: P
1007
+ };
1008
+ });
1009
+ }, Do = (e, { entities: t, mainField: n, defaultLocale: s }) => {
1010
+ const r = Y(() => eo(e), [e]), i = Y(
1011
+ () => Ro(e, t, n, s),
1012
+ [e, t, n, s]
1013
+ ), a = Y(
1014
+ () => Object.fromEntries(
1015
+ i.map((l) => [l.documentId, l.title])
1016
+ ),
1017
+ [i]
1018
+ );
1019
+ return { documentIds: r, entries: i, titles: a };
1020
+ }, Ao = ({
1021
+ selectedPromotions: e,
1022
+ contentTypeUid: t,
1023
+ comparison: n
1024
+ }) => {
1025
+ const { formatMessage: s } = v(), r = bo(t), i = Do(e, n), a = xo({
1026
+ contentTypeUid: t,
1027
+ selections: e,
1028
+ titles: i.titles,
1029
+ defaultLocale: n.defaultLocale,
1030
+ contentTypeName: r.primaryContentType?.displayName
1031
+ }), l = ht(i.documentIds), c = ht(i.documentIds), m = r.hasDraftAndPublish ? c.enabledDocumentIds : new Set(i.documentIds), h = So(a.relatedPrimary.entries.length > 0), [f, g] = R(null), y = fo(), C = r.isLoading || a.isLoading, P = () => {
1032
+ y.reset(), h.goBack();
1033
+ }, I = (T) => {
1034
+ y.reset(), h.goToIndex(T);
1035
+ }, E = () => {
1036
+ if (!h.isSummaryStep) {
1037
+ h.goNext();
1038
+ return;
1039
+ }
1040
+ y.mutate(
1041
+ {
1042
+ selections: e,
1043
+ contentTypeUid: t,
1044
+ documentOptions: so(i.documentIds, {
1045
+ mediaDocumentIds: l.enabledDocumentIds,
1046
+ publishDocumentIds: m
1047
+ })
1048
+ },
1049
+ { onSuccess: g }
1050
+ );
1051
+ };
1052
+ return {
1053
+ comparison: n,
1054
+ contentTypes: r,
1055
+ selection: i,
1056
+ related: a,
1057
+ includeMediaOption: l,
1058
+ publishOption: c,
1059
+ publishDocumentIds: m,
1060
+ steps: {
1061
+ currentStep: h.currentStep,
1062
+ visibleSteps: h.visibleSteps,
1063
+ stepIndex: h.stepIndex,
1064
+ furthestStepIndex: h.furthestStepIndex,
1065
+ isSummaryStep: h.isSummaryStep
1066
+ },
1067
+ promotion: {
1068
+ isPending: y.isPending,
1069
+ error: y.error ? me(
1070
+ y.error,
1071
+ s,
1072
+ "homePage.modal.confirmPromotion.error.description"
1073
+ ) : void 0,
1074
+ result: f
1075
+ },
1076
+ isPreparing: C,
1077
+ isSubmitDisabled: C || y.isPending || !t || e.length === 0,
1078
+ goBack: P,
1079
+ selectStep: I,
1080
+ submit: E
1081
+ };
1082
+ }, Bt = qn(null), Oo = ({
1083
+ children: e,
1084
+ ...t
1085
+ }) => {
1086
+ const n = Ao(t);
1087
+ return /* @__PURE__ */ o(Bt.Provider, { value: n, children: e });
1088
+ }, J = () => {
1089
+ const e = Nn(Bt);
1090
+ if (!e)
1091
+ throw new Error("usePromotionModal is used outside PromotionModalProvider");
1092
+ return e;
1093
+ }, _o = F.ol`
1094
+ display: flex;
1095
+ align-items: center;
1096
+ margin: 0;
1097
+ padding: 0;
1098
+ list-style: none;
1099
+ `, Ft = F(b)`
1100
+ width: ${({ theme: e }) => e.spaces[6]};
1101
+ height: ${({ theme: e }) => e.spaces[6]};
1102
+ border-radius: 50%;
1103
+ background-color: ${({ theme: e, $reached: t }) => t ? e.colors.primary600 : e.colors.neutral150};
1104
+ color: ${({ theme: e, $reached: t }) => t ? e.colors.neutral0 : e.colors.neutral600};
1105
+ box-shadow: ${({ theme: e, $current: t }) => t ? `0 0 0 ${e.spaces[1]} ${e.colors.primary100}` : "none"};
1106
+ `, $o = F.button`
1107
+ display: flex;
1108
+ padding: 0;
1109
+ border: none;
1110
+ border-radius: 50%;
1111
+ background: none;
1112
+ cursor: pointer;
1113
+
1114
+ &:hover ${Ft} {
1115
+ background-color: ${({ theme: e }) => e.colors.primary700};
1116
+ }
1117
+
1118
+ &:focus-visible {
1119
+ outline: 2px solid ${({ theme: e }) => e.colors.primary600};
1120
+ outline-offset: 2px;
1121
+ }
1122
+ `, Ko = F.li`
1123
+ flex: 1;
1124
+ min-width: ${({ theme: e }) => e.spaces[2]};
1125
+ height: 2px;
1126
+ margin: 0 ${({ theme: e }) => e.spaces[2]};
1127
+ background-color: ${({ theme: e, $reached: t }) => t ? e.colors.primary600 : e.colors.neutral200};
1128
+ `, qo = ({ steps: e, currentIndex: t, furthestIndex: n, onStepSelect: s }) => {
1129
+ const { formatMessage: r } = v(), i = e[t];
1130
+ return /* @__PURE__ */ u(b, { direction: "column", gap: 3, alignItems: "stretch", children: [
1131
+ /* @__PURE__ */ o(_o, { children: e.map((a, l) => {
1132
+ const c = l === t, m = l <= n, h = m && !c, f = /* @__PURE__ */ o(
1133
+ Ft,
1134
+ {
1135
+ $reached: m,
1136
+ $current: c,
1137
+ justifyContent: "center",
1138
+ alignItems: "center",
1139
+ "aria-hidden": !0,
1140
+ children: h ? /* @__PURE__ */ o(_n, { width: "1.2rem", height: "1.2rem" }) : /* @__PURE__ */ o(S, { variant: "pi", fontWeight: "bold", textColor: "inherit", children: l + 1 })
1141
+ }
1142
+ ), g = /* @__PURE__ */ o(Te, { children: h ? r(
1143
+ { id: d("homePage.modal.confirmPromotion.steps.completed") },
1144
+ { step: a.label }
1145
+ ) : a.label });
1146
+ return /* @__PURE__ */ u(Et, { children: [
1147
+ l > 0 && /* @__PURE__ */ o(Ko, { "aria-hidden": !0, $reached: m }),
1148
+ /* @__PURE__ */ o("li", { "aria-current": c ? "step" : void 0, children: h && s ? /* @__PURE__ */ o(_, { label: a.label, children: /* @__PURE__ */ u($o, { type: "button", onClick: () => s(l), children: [
1149
+ f,
1150
+ g
1151
+ ] }) }) : /* @__PURE__ */ u(D, { children: [
1152
+ /* @__PURE__ */ o(_, { label: a.label, children: f }),
1153
+ g
1154
+ ] }) })
1155
+ ] }, a.id);
1156
+ }) }),
1157
+ i && /* @__PURE__ */ u(b, { direction: "column", gap: 1, alignItems: "flex-start", children: [
1158
+ /* @__PURE__ */ o(S, { variant: "pi", textColor: "neutral600", children: r(
1159
+ { id: d("homePage.modal.confirmPromotion.steps.progress") },
1160
+ { current: t + 1, total: e.length }
1161
+ ) }),
1162
+ /* @__PURE__ */ o(S, { variant: "delta", tag: "h3", children: i.label })
1163
+ ] })
1164
+ ] });
1165
+ }, w = "homePage.modal.confirmPromotion", oe = "homePage.promotionResults", No = {
1166
+ published: { label: `${w}.publishOutcome.published`, variant: "success" },
1167
+ draft: { label: `${w}.publishOutcome.draft`, variant: "secondary" },
1168
+ modified: {
1169
+ label: `${w}.publishOutcome.modified`,
1170
+ variant: "alternative",
1171
+ tooltip: `${w}.publishOutcome.modifiedTooltip`
1172
+ }
1173
+ }, Bo = {
1174
+ copied: { label: `${w}.mediaOutcome.copied`, variant: "success" },
1175
+ updated: {
1176
+ label: `${w}.mediaOutcome.updated`,
1177
+ variant: "success",
1178
+ tooltip: `${w}.mediaOutcome.updatedTooltip`
1179
+ },
1180
+ kept: {
1181
+ label: `${w}.mediaOutcome.kept`,
1182
+ variant: "neutral",
1183
+ tooltip: `${w}.mediaOutcome.keptTooltip`
1184
+ },
1185
+ noMedia: {
1186
+ label: `${w}.mediaOutcome.noMedia`,
1187
+ variant: "warning",
1188
+ tooltip: `${w}.mediaOutcome.noMediaTooltip`
1189
+ }
1190
+ }, Fo = {
1191
+ copied: {
1192
+ label: `${w}.steps.embeddedMedia.copied`,
1193
+ variant: "success",
1194
+ tooltip: `${w}.steps.embeddedMedia.copiedTooltip`
1195
+ },
1196
+ removed: {
1197
+ label: `${w}.steps.embeddedMedia.removed`,
1198
+ variant: "warning",
1199
+ tooltip: `${w}.steps.embeddedMedia.removedTooltip`
1200
+ }
1201
+ }, Uo = {
1202
+ published: { label: `${w}.relatedContent.status.published`, variant: "success" },
1203
+ alwaysPublished: {
1204
+ label: `${w}.relatedContent.status.alwaysPublished`,
1205
+ variant: "warning",
1206
+ tooltip: `${w}.relatedContent.status.alwaysPublishedTooltip`
1207
+ },
1208
+ follows: {
1209
+ label: `${w}.relatedContent.status.follows`,
1210
+ variant: "neutral",
1211
+ tooltip: `${w}.relatedContent.status.followsTooltip`
1212
+ }
1213
+ }, Ho = {
1214
+ created: { label: `${oe}.result.created`, variant: "success" },
1215
+ updated: { label: `${oe}.result.updated`, variant: "success" },
1216
+ skipped: {
1217
+ label: `${oe}.result.skipped`,
1218
+ variant: "neutral",
1219
+ tooltip: `${oe}.result.skippedTooltip`
1220
+ },
1221
+ failed: { label: `${oe}.result.failed`, variant: "danger" }
1222
+ }, Z = () => {
1223
+ const e = x(), t = (n) => (s) => {
1224
+ const { label: r, variant: i, tooltip: a } = n[s];
1225
+ return { label: e(r), variant: i, tooltip: a && e(a) };
1226
+ };
1227
+ return {
1228
+ publish: t(No),
1229
+ media: t(Bo),
1230
+ embeddedMedia: t(Fo),
1231
+ related: t(Uo),
1232
+ result: t(Ho)
1233
+ };
1234
+ }, ze = (e, t) => e === "new" ? t ? "copied" : "noMedia" : e === void 0 ? t ? "copied" : "kept" : t ? "updated" : "kept", Ut = (e, t) => $t(e, (n) => ze(n, t)), Ht = (e, t) => e.filter((n) => !t.has(n.documentId)), Gt = (e, t) => Ht(e, t).length, Wt = (e, t) => Ht(e, t).filter(
1235
+ (n) => n.locales.some(
1236
+ (s) => ze(n.statusByLocale[s], !1) === "noMedia"
1237
+ )
1238
+ ).length, jt = (e) => e ? "copied" : "removed", Qt = (e, t) => [
1239
+ { outcome: jt(t), locales: e.locales }
1240
+ ], te = ({ children: e }) => /* @__PURE__ */ o(S, { tag: "span", variant: "omega", fontWeight: "bold", textColor: "warning600", children: e }), de = ({ label: e, variant: t, tooltip: n }) => /* @__PURE__ */ o(_, { label: n, children: /* @__PURE__ */ u("span", { style: { display: "inline-flex" }, children: [
1241
+ /* @__PURE__ */ o(An, { variant: t, size: "S", display: "inline-flex", children: /* @__PURE__ */ o(S, { tag: "span", variant: "omega", fontWeight: "bold", children: e }) }),
1242
+ n && /* @__PURE__ */ o(Te, { children: n })
1243
+ ] }) }), pt = 3, et = ({ locales: e }) => {
1244
+ const { formatMessage: t } = v(), n = e.slice(pt), s = n.map(
1245
+ (r) => r === "default" ? t({ id: d("homePage.promotionResults.locale.nonLocalized") }) : r
1246
+ ).join(", ");
1247
+ return /* @__PURE__ */ u(b, { gap: 2, wrap: "wrap", children: [
1248
+ e.slice(0, pt).map((r) => /* @__PURE__ */ o(Je, { locale: r }, r)),
1249
+ n.length > 0 && /* @__PURE__ */ o(_, { label: s, children: /* @__PURE__ */ u("span", { children: [
1250
+ /* @__PURE__ */ o(Se, { variant: "neutral", children: `+${n.length}` }),
1251
+ /* @__PURE__ */ o(Te, { children: s })
1252
+ ] }) })
1253
+ ] });
1254
+ }, z = ({ groups: e, getStatus: t }) => /* @__PURE__ */ o(b, { direction: "column", gap: 1, alignItems: "flex-start", children: e.map(({ outcome: n, locales: s }, r) => (
1255
+ // oxlint-disable-next-line react/no-array-index-key -- keyed by position on purpose, see above
1256
+ /* @__PURE__ */ u(b, { gap: 2, alignItems: "center", wrap: "wrap", children: [
1257
+ /* @__PURE__ */ o(de, { ...t(n) }),
1258
+ e.length > 1 && /* @__PURE__ */ o(et, { locales: s })
1259
+ ] }, r)
1260
+ )) }), tt = () => /* @__PURE__ */ o(S, { variant: "omega", textColor: "neutral600", children: "—" }), Vt = F(Ve)`
1261
+ && {
1262
+ table-layout: fixed;
1263
+ white-space: normal;
1264
+ overflow-wrap: break-word;
1265
+ }
1266
+ `, Go = ({ uniqueKey: e }) => {
1267
+ const { formatMessage: t } = v(), n = t(
1268
+ { id: d("homePage.table.uniqueKeyValue") },
1269
+ { key: e }
1270
+ );
1271
+ return (
1272
+ // Not focusable, see StatusLabel.
1273
+ /* @__PURE__ */ o(_, { label: n, align: "end", children: /* @__PURE__ */ o(b, { tag: "span", "aria-label": n, role: "img", children: /* @__PURE__ */ o($n, { fill: "neutral500", width: "1.4rem", height: "1.4rem", "aria-hidden": !0 }) }) })
1274
+ );
1275
+ }, ge = "25rem", Yt = "6rem", qe = "14rem", Wo = "5rem", Xt = "18rem", We = "18rem", nt = 30, jo = 2, ft = (e) => typeof e == "string" ? /* @__PURE__ */ o(S, { variant: "sigma", children: e }) : e, W = ({
1276
+ rows: e,
1277
+ getRowKey: t,
1278
+ leadingColumn: n,
1279
+ columns: s = []
1280
+ }) => {
1281
+ const { formatMessage: r } = v(), i = (n ? 1 : 0) + s.length;
1282
+ return e.length === 0 ? null : /* @__PURE__ */ u(Vt, { colCount: jo + i, rowCount: e.length, children: [
1283
+ /* @__PURE__ */ o(we, { children: /* @__PURE__ */ u(G, { children: [
1284
+ n && /* @__PURE__ */ o(O, { width: n.width, children: ft(n.header) }),
1285
+ /* @__PURE__ */ o(O, { children: /* @__PURE__ */ o(S, { variant: "sigma", children: r({ id: d("homePage.table.entryTitle") }) }) }),
1286
+ s.map((a, l) => (
1287
+ // oxlint-disable-next-line react/no-array-index-key -- fixed column list
1288
+ /* @__PURE__ */ o(O, { width: a.width, children: ft(a.header) }, l)
1289
+ )),
1290
+ /* @__PURE__ */ o(O, { width: Yt, children: /* @__PURE__ */ o(S, { variant: "sigma", children: r({ id: d("homePage.table.key") }) }) })
1291
+ ] }) }),
1292
+ /* @__PURE__ */ o(Ee, { children: e.map((a) => /* @__PURE__ */ u(G, { children: [
1293
+ n && /* @__PURE__ */ o(L, { children: n.renderCell(a) }),
1294
+ /* @__PURE__ */ o(L, { children: /* @__PURE__ */ o(B, { maxCharacters: 50, text: a.title }) }),
1295
+ s.map((l, c) => (
1296
+ // oxlint-disable-next-line react/no-array-index-key -- fixed column list
1297
+ /* @__PURE__ */ o(L, { children: l.renderCell(a) }, c)
1298
+ )),
1299
+ /* @__PURE__ */ o(L, { children: a.uniqueKey ? /* @__PURE__ */ o(Go, { uniqueKey: a.uniqueKey }) : /* @__PURE__ */ o(tt, {}) })
1300
+ ] }, t(a))) })
1301
+ ] });
1302
+ }, A = ({ title: e, isWarning: t = !1, description: n, children: s }) => /* @__PURE__ */ u(b, { direction: "column", gap: 4, alignItems: "stretch", children: [
1303
+ /* @__PURE__ */ u(b, { direction: "column", gap: 1, alignItems: "stretch", children: [
1304
+ e && /* @__PURE__ */ u(b, { gap: 2, alignItems: "center", children: [
1305
+ t && /* @__PURE__ */ o(ue, { fill: "warning500", width: "1.6rem", height: "1.6rem", "aria-hidden": !0 }),
1306
+ /* @__PURE__ */ o(S, { variant: "epsilon", tag: "h4", children: e })
1307
+ ] }),
1308
+ n && /* @__PURE__ */ o(S, { tag: "div", variant: "omega", textColor: "neutral600", children: n })
1309
+ ] }),
1310
+ s
1311
+ ] }), Qo = "homePage.modal.confirmPromotion.steps.embeddedMedia", Vo = () => {
1312
+ const { selection: e, includeMediaOption: t } = J(), n = Z(), s = x(Qo), r = Gt(e.entries, t.enabledDocumentIds);
1313
+ return /* @__PURE__ */ u(A, { description: s("description"), children: [
1314
+ /* @__PURE__ */ o(
1315
+ W,
1316
+ {
1317
+ rows: e.entries,
1318
+ getRowKey: (i) => i.documentId,
1319
+ columns: [
1320
+ {
1321
+ header: s("statusColumn"),
1322
+ width: ge,
1323
+ renderCell: (i) => /* @__PURE__ */ o(
1324
+ z,
1325
+ {
1326
+ groups: Qt(
1327
+ i,
1328
+ t.isEnabled(i.documentId)
1329
+ ),
1330
+ getStatus: n.embeddedMedia
1331
+ }
1332
+ )
1333
+ }
1334
+ ]
1335
+ }
1336
+ ),
1337
+ r > 0 && /* @__PURE__ */ o(te, { children: s("consequence.removed", { count: r }) }),
1338
+ /* @__PURE__ */ o(b, { direction: "column", gap: 1, alignItems: "flex-start", children: ["files", "links"].map((i) => /* @__PURE__ */ u(S, { variant: "omega", textColor: "neutral600", children: [
1339
+ /* @__PURE__ */ o(S, { tag: "span", variant: "omega", fontWeight: "bold", textColor: "neutral800", children: s(`${i}.label`) }),
1340
+ " ",
1341
+ s(`${i}.text`)
1342
+ ] }, i)) })
1343
+ ] });
1344
+ }, Jt = (e, t) => t?.findLast((n) => n.uid === e)?.displayName ?? e, ot = (e, t) => t ? "published" : e === void 0 || e === "new" ? "draft" : "modified", Zt = (e, t) => $t(e, (n) => ot(n, t)), zt = ({ draftAndPublish: e }, t) => t ? e ? "follows" : "alwaysPublished" : "published", en = "15rem", Yo = 18, ye = 2, tn = ({ items: e }) => {
1345
+ const { formatMessage: t } = v(), n = e.map(({ name: s }) => s);
1346
+ return /* @__PURE__ */ u(b, { direction: "column", alignItems: "flex-start", gap: 1, children: [
1347
+ e.slice(0, ye).map(({ id: s, name: r }) => /* @__PURE__ */ o(
1348
+ B,
1349
+ {
1350
+ variant: "omega",
1351
+ textColor: "neutral600",
1352
+ maxCharacters: Yo,
1353
+ text: r
1354
+ },
1355
+ s
1356
+ )),
1357
+ n.length > ye && /* @__PURE__ */ o(_, { label: n.join(", "), children: /* @__PURE__ */ u(S, { variant: "omega", textColor: "neutral600", children: [
1358
+ t(
1359
+ {
1360
+ id: d("homePage.modal.confirmPromotion.relatedContent.linkedFromMore")
1361
+ },
1362
+ { count: n.length - ye }
1363
+ ),
1364
+ /* @__PURE__ */ o(Te, { children: n.slice(ye).join(", ") })
1365
+ ] }) })
1366
+ ] });
1367
+ }, Xo = "homePage.modal.confirmPromotion.relatedContent", Jo = ({
1368
+ relatedContentTypes: e,
1369
+ contentTypes: t,
1370
+ hasDraftAndPublish: n
1371
+ }) => {
1372
+ const s = Z(), r = x(Xo);
1373
+ return e.length === 0 ? null : /* @__PURE__ */ o(A, { title: r("title"), description: r("description"), children: /* @__PURE__ */ u(Ve, { colCount: 3, rowCount: e.length, children: [
1374
+ /* @__PURE__ */ o(we, { children: /* @__PURE__ */ u(G, { children: [
1375
+ /* @__PURE__ */ o(O, { children: /* @__PURE__ */ o(S, { variant: "sigma", children: r("column.contentType") }) }),
1376
+ /* @__PURE__ */ o(O, { width: en, children: /* @__PURE__ */ o(S, { variant: "sigma", children: r("column.linkedFrom") }) }),
1377
+ /* @__PURE__ */ o(O, { width: "1%", children: /* @__PURE__ */ o(S, { variant: "sigma", children: r("column.status") }) })
1378
+ ] }) }),
1379
+ /* @__PURE__ */ o(Ee, { children: e.map((i) => /* @__PURE__ */ u(G, { children: [
1380
+ /* @__PURE__ */ o(L, { children: /* @__PURE__ */ o(
1381
+ B,
1382
+ {
1383
+ variant: "omega",
1384
+ maxCharacters: nt,
1385
+ text: i.displayName
1386
+ }
1387
+ ) }),
1388
+ /* @__PURE__ */ o(L, { children: /* @__PURE__ */ o(
1389
+ tn,
1390
+ {
1391
+ items: i.linkedFrom.map((a) => ({ id: a, name: Jt(a, t) })).sort((a, l) => a.name.localeCompare(l.name))
1392
+ }
1393
+ ) }),
1394
+ /* @__PURE__ */ o(L, { children: /* @__PURE__ */ o(
1395
+ de,
1396
+ {
1397
+ ...s.related(zt(i, n))
1398
+ }
1399
+ ) })
1400
+ ] }, i.uid)) })
1401
+ ] }) });
1402
+ }, Zo = () => {
1403
+ const { selection: e, contentTypes: t } = J(), { formatMessage: n } = v();
1404
+ return /* @__PURE__ */ u(b, { direction: "column", gap: 8, alignItems: "stretch", children: [
1405
+ /* @__PURE__ */ o(
1406
+ A,
1407
+ {
1408
+ title: n({
1409
+ id: d("homePage.modal.confirmPromotion.steps.entities.selectedTitle")
1410
+ }),
1411
+ description: n({
1412
+ id: d("homePage.modal.confirmPromotion.steps.entities.description")
1413
+ }),
1414
+ children: /* @__PURE__ */ o(
1415
+ W,
1416
+ {
1417
+ rows: e.entries,
1418
+ getRowKey: (s) => s.documentId,
1419
+ columns: [
1420
+ {
1421
+ header: n({ id: d("homePage.table.locale") }),
1422
+ width: ge,
1423
+ renderCell: (s) => s.allLocalesSelected ? /* @__PURE__ */ o(S, { variant: "omega", textColor: "neutral600", children: n({
1424
+ id: d("homePage.modal.confirmPromotion.allLocalesSelected")
1425
+ }) }) : /* @__PURE__ */ o(et, { locales: s.locales })
1426
+ }
1427
+ ]
1428
+ }
1429
+ )
1430
+ }
1431
+ ),
1432
+ /* @__PURE__ */ o(
1433
+ Jo,
1434
+ {
1435
+ relatedContentTypes: t.relatedContentTypes,
1436
+ contentTypes: t.contentTypes,
1437
+ hasDraftAndPublish: t.hasDraftAndPublish
1438
+ }
1439
+ )
1440
+ ] });
1441
+ }, zo = "homePage.modal.confirmPromotion.steps.media", es = (e, t) => {
1442
+ if (e && t)
1443
+ return "relatedWithEntries";
1444
+ if (e)
1445
+ return "related";
1446
+ if (t)
1447
+ return "relatedEntries";
1448
+ }, ts = (e, t) => {
1449
+ const n = x(zo), s = es(
1450
+ e.length > 0,
1451
+ !!t
1452
+ );
1453
+ return s ? n(s, {
1454
+ contentTypes: e.map(({ displayName: r }) => r).join(", "),
1455
+ contentType: t ?? ""
1456
+ }) : void 0;
1457
+ }, nn = ({
1458
+ selectedEntries: e,
1459
+ promotionOption: t,
1460
+ allLabel: n,
1461
+ getRowLabel: s
1462
+ }) => ({
1463
+ header: /* @__PURE__ */ o(
1464
+ Fe,
1465
+ {
1466
+ checked: to(
1467
+ e.map(({ documentId: r }) => r),
1468
+ t.enabledDocumentIds
1469
+ ),
1470
+ onCheckedChange: (r) => t.setAll(r === !0),
1471
+ "aria-label": n
1472
+ }
1473
+ ),
1474
+ width: Wo,
1475
+ renderCell: (r) => /* @__PURE__ */ o(
1476
+ Fe,
1477
+ {
1478
+ checked: t.isEnabled(r.documentId),
1479
+ onCheckedChange: (i) => t.set(r.documentId, i === !0),
1480
+ "aria-label": s(r.title)
1481
+ }
1482
+ )
1483
+ }), ns = "homePage.modal.confirmPromotion", os = () => {
1484
+ const { selection: e, includeMediaOption: t, contentTypes: n, related: s } = J(), r = Z(), i = x(ns), a = ts(
1485
+ n.relatedContentTypes,
1486
+ s.relatedEntriesContentType
1487
+ ), l = t.enabledDocumentIds, c = Wt(e.entries, l);
1488
+ return /* @__PURE__ */ u(A, { description: i("steps.media.description"), children: [
1489
+ /* @__PURE__ */ o(
1490
+ W,
1491
+ {
1492
+ rows: e.entries,
1493
+ getRowKey: (m) => m.documentId,
1494
+ leadingColumn: nn({
1495
+ selectedEntries: e.entries,
1496
+ promotionOption: t,
1497
+ allLabel: i("includeMediaAll"),
1498
+ getRowLabel: (m) => i("includeMediaForDocument", { title: m })
1499
+ }),
1500
+ columns: [
1501
+ {
1502
+ header: i("steps.media.statusColumn"),
1503
+ width: ge,
1504
+ renderCell: (m) => /* @__PURE__ */ o(
1505
+ z,
1506
+ {
1507
+ groups: Ut(
1508
+ m,
1509
+ l.has(m.documentId)
1510
+ ),
1511
+ getStatus: r.media
1512
+ }
1513
+ )
1514
+ }
1515
+ ]
1516
+ }
1517
+ ),
1518
+ c > 0 && /* @__PURE__ */ o(te, { children: i("steps.media.consequence.noMedia", { count: c }) }),
1519
+ /* @__PURE__ */ u(S, { tag: "p", variant: "omega", textColor: "neutral600", children: [
1520
+ a && `${a} `,
1521
+ i("steps.media.embeddedPointer")
1522
+ ] })
1523
+ ] });
1524
+ }, ss = "homePage.modal.confirmPromotion.steps.publish.related", rs = (e, t) => e && t ? "noDraftAndPublishWithEntries" : t ? "noDraftAndPublishEntries" : "noDraftAndPublish", is = (e, t) => {
1525
+ if (e && t)
1526
+ return "followsWithEntries";
1527
+ if (e)
1528
+ return "follows";
1529
+ if (t)
1530
+ return "entries";
1531
+ }, as = (e, t, n) => {
1532
+ const s = x(ss);
1533
+ if (e.length === 0 && !n)
1534
+ return {};
1535
+ if (!t) {
1536
+ const m = rs(
1537
+ e.length > 0,
1538
+ !!n
1539
+ );
1540
+ return {
1541
+ text: s(m, { contentType: n ?? "" })
1542
+ };
1543
+ }
1544
+ const r = (m) => e.filter((h) => zt(h, !0) === m).map(({ displayName: h }) => h), i = r("follows"), a = r("alwaysPublished"), l = {
1545
+ contentTypes: i.join(", "),
1546
+ contentType: n ?? ""
1547
+ }, c = is(i.length > 0, !!n);
1548
+ return {
1549
+ text: c ? s(c, l) : void 0,
1550
+ warning: a.length > 0 ? s("alwaysPublished", {
1551
+ contentTypes: a.join(", "),
1552
+ count: a.length
1553
+ }) : void 0
1554
+ };
1555
+ }, on = ({
1556
+ relatedContentTypes: e,
1557
+ hasDraftAndPublish: t,
1558
+ relatedEntriesContentType: n
1559
+ }) => {
1560
+ const { text: s, warning: r } = as(
1561
+ e,
1562
+ t,
1563
+ n
1564
+ );
1565
+ return !s && !r ? null : /* @__PURE__ */ u(S, { tag: "p", variant: "omega", textColor: "neutral600", children: [
1566
+ s,
1567
+ s && r && " ",
1568
+ r && /* @__PURE__ */ o(te, { children: r })
1569
+ ] });
1570
+ }, ls = "homePage.modal.confirmPromotion", cs = () => {
1571
+ const { selection: e, publishOption: t, publishDocumentIds: n, contentTypes: s, related: r } = J(), i = Z(), a = x(ls);
1572
+ return /* @__PURE__ */ u(
1573
+ A,
1574
+ {
1575
+ description: a(
1576
+ s.hasDraftAndPublish ? "steps.publish.description" : "steps.publish.noDraftAndPublishDescription"
1577
+ ),
1578
+ children: [
1579
+ /* @__PURE__ */ o(
1580
+ W,
1581
+ {
1582
+ rows: e.entries,
1583
+ getRowKey: (l) => l.documentId,
1584
+ leadingColumn: s.hasDraftAndPublish ? nn({
1585
+ selectedEntries: e.entries,
1586
+ promotionOption: t,
1587
+ allLabel: a("publishAll"),
1588
+ getRowLabel: (l) => a("publishForDocument", { title: l })
1589
+ }) : void 0,
1590
+ columns: [
1591
+ {
1592
+ header: a("steps.publish.statusColumn"),
1593
+ width: ge,
1594
+ renderCell: (l) => /* @__PURE__ */ o(
1595
+ z,
1596
+ {
1597
+ groups: Zt(
1598
+ l,
1599
+ n.has(l.documentId)
1600
+ ),
1601
+ getStatus: i.publish
1602
+ }
1603
+ )
1604
+ }
1605
+ ]
1606
+ }
1607
+ ),
1608
+ /* @__PURE__ */ o(
1609
+ on,
1610
+ {
1611
+ relatedContentTypes: s.relatedContentTypes,
1612
+ hasDraftAndPublish: s.hasDraftAndPublish,
1613
+ relatedEntriesContentType: r.relatedEntriesContentType
1614
+ }
1615
+ )
1616
+ ]
1617
+ }
1618
+ );
1619
+ }, ds = "homePage.modal.confirmPromotion.relatedPrimary.extendsSelection", sn = ({ entries: e, columns: t, showWarning: n = !0 }) => {
1620
+ const s = x(ds);
1621
+ return e.length === 0 ? null : /* @__PURE__ */ u(A, { title: s("title"), isWarning: !0, description: s("description"), children: [
1622
+ /* @__PURE__ */ o(
1623
+ W,
1624
+ {
1625
+ rows: e,
1626
+ getRowKey: (r) => r.documentId,
1627
+ columns: t
1628
+ }
1629
+ ),
1630
+ n && /* @__PURE__ */ o(te, { children: s("warning", { count: Nt(e) }) })
1631
+ ] });
1632
+ }, us = "homePage.modal.confirmPromotion.relatedPrimary", rn = ({
1633
+ contentTypeName: e,
1634
+ entries: t,
1635
+ error: n,
1636
+ description: s,
1637
+ columns: r
1638
+ }) => {
1639
+ const i = x(us), a = e ? i("titleWithContentType", { contentType: e }) : i("title");
1640
+ return n ? /* @__PURE__ */ o(A, { title: a, children: /* @__PURE__ */ o($, { variant: "warning", title: i("error.title"), description: n }) }) : t.length === 0 ? null : /* @__PURE__ */ o(A, { title: a, description: s, children: /* @__PURE__ */ o(
1641
+ W,
1642
+ {
1643
+ rows: t,
1644
+ getRowKey: (l) => l.documentId,
1645
+ columns: r
1646
+ }
1647
+ ) });
1648
+ }, ms = "homePage.modal.confirmPromotion", hs = () => {
1649
+ const { related: e } = J(), t = x(ms), n = x("homePage.table"), { selectedEntriesWithMoreLocales: s, otherRelatedEntries: r } = qt(
1650
+ e.relatedPrimary.entries
1651
+ ), i = [
1652
+ {
1653
+ header: t("relatedContent.column.linkedFrom"),
1654
+ width: en,
1655
+ renderCell: (a) => /* @__PURE__ */ o(tn, { items: a.linkedFrom })
1656
+ },
1657
+ {
1658
+ header: n("locale"),
1659
+ width: ge,
1660
+ renderCell: (a) => /* @__PURE__ */ o(et, { locales: a.locales })
1661
+ }
1662
+ ];
1663
+ return /* @__PURE__ */ u(b, { direction: "column", gap: 8, alignItems: "stretch", children: [
1664
+ /* @__PURE__ */ o(sn, { entries: s, columns: i }),
1665
+ /* @__PURE__ */ o(
1666
+ rn,
1667
+ {
1668
+ ...e.relatedPrimary,
1669
+ entries: r,
1670
+ description: t("relatedPrimary.description"),
1671
+ columns: i
1672
+ }
1673
+ )
1674
+ ] });
1675
+ }, gs = ["en", "default"], ps = (e) => {
1676
+ for (const t of gs) {
1677
+ const n = e.find((s) => s.locale === t);
1678
+ if (n?.uniqueKey != null && n.uniqueKey.length > 0)
1679
+ return n.uniqueKey;
1680
+ }
1681
+ return e.find((t) => t.uniqueKey != null && t.uniqueKey.length > 0)?.uniqueKey ?? null;
1682
+ }, yt = (e, t, n) => {
1683
+ if (e.uniqueKey != null && e.uniqueKey.length > 0)
1684
+ return e.uniqueKey;
1685
+ const s = e.documentId ?? e.documentKey, r = Lt(t).find(
1686
+ (i) => i.documentId === s
1687
+ );
1688
+ if (r) {
1689
+ const i = ke(r, n);
1690
+ if (i != null && String(i).length > 0)
1691
+ return String(i);
1692
+ }
1693
+ return s;
1694
+ }, fs = (e) => {
1695
+ if (e.documentId != null && e.documentId.length > 0)
1696
+ return e.documentId;
1697
+ const t = e.steps.find(
1698
+ (s) => s.push.remoteDocumentId != null && s.push.remoteDocumentId.length > 0
1699
+ )?.push.remoteDocumentId;
1700
+ if (t != null && t.length > 0)
1701
+ return t;
1702
+ if (e.uniqueKey != null && e.uniqueKey.length > 0)
1703
+ return e.uniqueKey;
1704
+ const n = e.groupKey.lastIndexOf("::");
1705
+ return n === -1 ? e.groupKey : e.groupKey.slice(0, n);
1706
+ }, ys = {
1707
+ create: "created",
1708
+ update: "updated"
1709
+ }, bs = (e) => e.push.ok ? e.push.skipped || e.action === "skip" ? "skipped" : ys[e.action] : "failed", Ss = (e) => {
1710
+ const t = e[0];
1711
+ return t ? bs(t) : "skipped";
1712
+ }, Ps = (e) => [...e].reverse().find((t) => t.push.ok && t.push.writeStatus)?.push.writeStatus, Cs = (e) => {
1713
+ const t = /* @__PURE__ */ new Map();
1714
+ for (const n of e) {
1715
+ const s = n.snapshotKey, r = t.get(s) ?? [];
1716
+ r.push(n), t.set(s, r);
1717
+ }
1718
+ return Array.from(t.entries()).map(([n, s]) => {
1719
+ const r = s.some((a) => !a.push.ok), i = s[s.length - 1];
1720
+ return {
1721
+ groupKey: n,
1722
+ documentId: i.documentId,
1723
+ locale: i.locale,
1724
+ uniqueKey: i.uniqueKey,
1725
+ outcome: r ? "failed" : Ss(s),
1726
+ writeStatus: Ps(s),
1727
+ steps: s,
1728
+ hasFailure: r
1729
+ };
1730
+ });
1731
+ }, vs = (e) => {
1732
+ const t = Cs(e), n = /* @__PURE__ */ new Map();
1733
+ for (const s of t) {
1734
+ const r = fs(s), i = n.get(r) ?? [];
1735
+ i.push(s), n.set(r, i);
1736
+ }
1737
+ return Array.from(n.entries()).map(([s, r]) => {
1738
+ const i = r.sort(
1739
+ (a, l) => a.locale.localeCompare(l.locale)
1740
+ );
1741
+ return {
1742
+ documentKey: s,
1743
+ documentId: i[0]?.documentId,
1744
+ uniqueKey: ps(i),
1745
+ localeEntries: i
1746
+ };
1747
+ });
1748
+ }, bt = (e) => typeof e == "object" && e !== null && !Array.isArray(e), Is = (e) => e.writeStatus ? ot(e.steps[0]?.comparisonStatus, e.writeStatus === "published") : void 0, ws = (e) => typeof e == "string" ? e.length > 0 ? e : void 0 : bt(e) ? typeof e.message == "string" ? e.message : bt(e.error) && typeof e.error.message == "string" ? e.error.message : JSON.stringify(e) : e == null ? void 0 : String(e), Es = ["failed", "created", "updated", "skipped"], Ts = ["draft", "modified", "published"], St = (e, t) => t.find((n) => e.includes(n)), Ie = (e) => e.result === "failed", Ms = ({ status: e }) => e !== void 0 && e !== "published", Pt = (e, t) => {
1749
+ const n = vs(e).map((s) => {
1750
+ const { localeEntries: r } = s, i = r.map((l) => ({
1751
+ locale: l.locale,
1752
+ result: l.outcome,
1753
+ status: Is(l),
1754
+ reasons: [
1755
+ ...new Set(
1756
+ l.steps.flatMap((c) => {
1757
+ const m = c.push.ok ? void 0 : ws(c.push.error);
1758
+ return m ? [m] : [];
1759
+ })
1760
+ )
1761
+ ]
1762
+ })), a = i.flatMap(({ status: l }) => l ? [l] : []);
1763
+ return {
1764
+ id: s.documentKey,
1765
+ title: t(s),
1766
+ uniqueKey: s.uniqueKey,
1767
+ result: St(
1768
+ i.map(({ result: l }) => l),
1769
+ Es
1770
+ ) ?? "failed",
1771
+ status: St(a, Ts),
1772
+ locales: i,
1773
+ hasUnlinkedRelations: r.some(
1774
+ (l) => l.steps.some((c) => c.hasUnlinkedRelations)
1775
+ )
1776
+ };
1777
+ });
1778
+ return [...n.filter(Ie), ...n.filter((s) => !Ie(s))];
1779
+ }, xs = ({ result: e }) => e === "created" || e === "updated", Ls = (e, t, n) => e === 0 ? "success" : e === n && t === 0 ? "failure" : "partial", ks = (e) => {
1780
+ const t = e.filter(Ie).length, n = e.filter((r) => r.locales.some(xs)).length, s = e.filter(
1781
+ (r) => r.locales.every(({ result: i }) => i === "skipped")
1782
+ ).length;
1783
+ return {
1784
+ outcome: Ls(t, n, e.length),
1785
+ promoted: n,
1786
+ unchanged: s,
1787
+ failed: t,
1788
+ savedAsDraft: e.filter(Ms).length
1789
+ };
1790
+ }, Rs = ["created", "updated", "skipped", "failed"], Ds = ["published", "modified", "draft"], Ct = (e, t) => t.map((n) => ({
1791
+ outcome: n,
1792
+ count: e.filter((s) => s === n).length
1793
+ })).filter(({ count: n }) => n > 0), As = (e) => ({
1794
+ results: Ct(
1795
+ e.map((t) => t.result),
1796
+ Rs
1797
+ ),
1798
+ statuses: Ct(
1799
+ e.flatMap((t) => t.status ? [t.status] : []),
1800
+ Ds
1801
+ )
1802
+ }), vt = ({
1803
+ counts: e,
1804
+ getStatus: t
1805
+ }) => {
1806
+ const { formatMessage: n } = v();
1807
+ return e.length > 0 ? /* @__PURE__ */ o(b, { gap: 2, wrap: "wrap", alignItems: "center", children: e.map(({ outcome: s, count: r }) => {
1808
+ const i = t(s), a = n(
1809
+ { id: d("homePage.promotionResults.countedLabel") },
1810
+ { count: r, label: i.label }
1811
+ );
1812
+ return /* @__PURE__ */ o(de, { ...i, label: a }, s);
1813
+ }) }) : /* @__PURE__ */ o(tt, {});
1814
+ }, Os = "homePage.promotionResults", _s = `calc(${We} + ${Yt})`, $s = ({ rows: e }) => {
1815
+ const t = Z(), n = x(Os);
1816
+ return /* @__PURE__ */ u(Vt, { colCount: 3, rowCount: e.length, children: [
1817
+ /* @__PURE__ */ o(we, { children: /* @__PURE__ */ u(G, { children: [
1818
+ /* @__PURE__ */ o(O, { children: /* @__PURE__ */ o(S, { variant: "sigma", children: n("related.column.contentType") }) }),
1819
+ /* @__PURE__ */ o(O, { width: Xt, children: /* @__PURE__ */ o(S, { variant: "sigma", children: n("column.result") }) }),
1820
+ /* @__PURE__ */ o(O, { width: _s, children: /* @__PURE__ */ o(S, { variant: "sigma", children: n("column.status") }) })
1821
+ ] }) }),
1822
+ /* @__PURE__ */ o(Ee, { children: e.map((s) => /* @__PURE__ */ u(G, { children: [
1823
+ /* @__PURE__ */ o(L, { children: /* @__PURE__ */ o(
1824
+ B,
1825
+ {
1826
+ variant: "omega",
1827
+ maxCharacters: nt,
1828
+ text: s.displayName
1829
+ }
1830
+ ) }),
1831
+ /* @__PURE__ */ o(L, { children: /* @__PURE__ */ o(vt, { counts: s.results, getStatus: t.result }) }),
1832
+ /* @__PURE__ */ o(L, { children: /* @__PURE__ */ o(vt, { counts: s.statuses, getStatus: t.publish }) })
1833
+ ] }, s.uid)) })
1834
+ ] });
1835
+ }, Ks = {
1836
+ info: { Icon: Ue, fill: "neutral500" },
1837
+ warning: { Icon: ue, fill: "warning500" }
1838
+ }, It = ({ variant: e, lines: t }) => {
1839
+ const { Icon: n, fill: s } = Ks[e];
1840
+ return /* @__PURE__ */ o(
1841
+ _,
1842
+ {
1843
+ label: /* @__PURE__ */ o(b, { direction: "column", alignItems: "flex-start", gap: 1, children: t.map((r) => /* @__PURE__ */ o("span", { children: r }, r)) }),
1844
+ children: /* @__PURE__ */ o(b, { tag: "span", role: "img", "aria-label": t.join(". "), children: /* @__PURE__ */ o(n, { fill: s, width: "1.6rem", height: "1.6rem", "aria-hidden": !0 }) })
1845
+ }
1846
+ );
1847
+ }, qs = "homePage.promotionResults", Ns = (e) => {
1848
+ const t = Ze(
1849
+ e.locales.flatMap(
1850
+ ({ locale: s, reasons: r }) => r.map((i) => ({ locale: s, outcome: i }))
1851
+ )
1852
+ ), n = t.length > 1 || t[0]?.locales.length !== e.locales.length;
1853
+ return t.map(
1854
+ ({ outcome: s, locales: r }) => n ? `${r.join(", ")}: ${s}` : s
1855
+ );
1856
+ }, wt = ({
1857
+ rows: e,
1858
+ getContentTypeName: t
1859
+ }) => {
1860
+ const n = Z(), s = x(qs), r = s("result.unlinkedRelations");
1861
+ return /* @__PURE__ */ o(
1862
+ W,
1863
+ {
1864
+ rows: e,
1865
+ getRowKey: (i) => t ? `${t(i)}::${i.id}` : i.id,
1866
+ columns: [
1867
+ {
1868
+ header: s("column.result"),
1869
+ width: Xt,
1870
+ renderCell: (i) => {
1871
+ const a = n.result(i.result), l = i.locales.filter(({ result: m }) => m === i.result).length, c = Ns(i);
1872
+ return /* @__PURE__ */ u(b, { gap: 2, alignItems: "center", children: [
1873
+ /* @__PURE__ */ o(
1874
+ de,
1875
+ {
1876
+ ...a,
1877
+ label: l < i.locales.length ? s("result.localeCount", {
1878
+ label: a.label,
1879
+ count: l,
1880
+ total: i.locales.length
1881
+ }) : a.label
1882
+ }
1883
+ ),
1884
+ c.length > 0 && /* @__PURE__ */ o(It, { variant: "info", lines: c }),
1885
+ i.hasUnlinkedRelations && /* @__PURE__ */ o(It, { variant: "warning", lines: [r] })
1886
+ ] });
1887
+ }
1888
+ },
1889
+ t ? {
1890
+ header: s("related.column.contentType"),
1891
+ width: We,
1892
+ renderCell: (i) => /* @__PURE__ */ o(
1893
+ B,
1894
+ {
1895
+ variant: "omega",
1896
+ maxCharacters: nt,
1897
+ text: t(i)
1898
+ }
1899
+ )
1900
+ } : {
1901
+ header: s("column.status"),
1902
+ width: We,
1903
+ renderCell: (i) => i.status ? /* @__PURE__ */ o(de, { ...n.publish(i.status) }) : /* @__PURE__ */ o(tt, {})
1904
+ }
1905
+ ]
1906
+ }
1907
+ );
1908
+ }, Bs = "homePage.promotionResults", Fs = ({
1909
+ result: e,
1910
+ contentTypes: t,
1911
+ entryTitles: n,
1912
+ comparedEntities: s,
1913
+ contentTypeMainField: r
1914
+ }) => {
1915
+ const i = x(Bs), [a, l] = R(!1), c = Pt(
1916
+ e.entries,
1917
+ (P) => P.documentId && n[P.documentId] || yt(P, s, r)
1918
+ ), m = ks(c), h = e.dependencyResults.filter((P) => P.entries.length > 0).map((P) => {
1919
+ const I = Jt(P.contentTypeUid, t), E = Pt(
1920
+ P.entries,
1921
+ (T) => yt(T, void 0, void 0)
1922
+ ).map((T) => ({ ...T, contentTypeName: I }));
1923
+ return {
1924
+ uid: P.contentTypeUid,
1925
+ displayName: I,
1926
+ entryRows: E,
1927
+ ...As(E)
1928
+ };
1929
+ }), f = h.flatMap(
1930
+ ({ entryRows: P }) => P.filter((I) => Ie(I) || I.hasUnlinkedRelations)
1931
+ ), g = e.mediaSummary, y = [];
1932
+ g && g.uploaded > 0 && y.push(i("media.copied", { count: g.uploaded })), g && g.replaced > 0 && y.push(i("media.updated", { count: g.replaced }));
1933
+ const C = g?.failed ?? 0;
1934
+ return /* @__PURE__ */ u(b, { direction: "column", alignItems: "stretch", gap: 8, children: [
1935
+ /* @__PURE__ */ u(
1936
+ A,
1937
+ {
1938
+ title: i("selected.title"),
1939
+ description: /* @__PURE__ */ u(D, { children: [
1940
+ i("outcome.description", { promoted: m.promoted }),
1941
+ m.unchanged > 0 && ` ${i("outcome.unchanged", { count: m.unchanged })}`
1942
+ ] }),
1943
+ children: [
1944
+ m.outcome !== "success" && /* @__PURE__ */ o(
1945
+ $,
1946
+ {
1947
+ variant: "danger",
1948
+ title: i(`outcome.${m.outcome}.title`),
1949
+ description: i(`outcome.${m.outcome}.description`, {
1950
+ failed: m.failed
1951
+ })
1952
+ }
1953
+ ),
1954
+ e.hasUnlinkedRelations && /* @__PURE__ */ o(
1955
+ $,
1956
+ {
1957
+ variant: "warning",
1958
+ title: i("unlinkedRelations.title"),
1959
+ description: i("unlinkedRelations.description")
1960
+ }
1961
+ ),
1962
+ /* @__PURE__ */ o(wt, { rows: c }),
1963
+ m.savedAsDraft > 0 && /* @__PURE__ */ o(S, { tag: "p", variant: "omega", textColor: "neutral600", children: i("drafts.description", { count: m.savedAsDraft }) }),
1964
+ (y.length > 0 || C > 0) && /* @__PURE__ */ u(S, { tag: "p", variant: "omega", textColor: "neutral600", children: [
1965
+ y.length > 0 && `${y.join(", ")}.`,
1966
+ y.length > 0 && C > 0 && " ",
1967
+ C > 0 && /* @__PURE__ */ o(te, { children: i("media.failed", { count: C }) })
1968
+ ] })
1969
+ ]
1970
+ }
1971
+ ),
1972
+ h.length > 0 && /* @__PURE__ */ u(
1973
+ A,
1974
+ {
1975
+ title: i("related.title"),
1976
+ description: i("related.description"),
1977
+ children: [
1978
+ /* @__PURE__ */ o($s, { rows: h }),
1979
+ f.length > 0 && /* @__PURE__ */ u(D, { children: [
1980
+ /* @__PURE__ */ u(b, { gap: 3, alignItems: "center", wrap: "wrap", children: [
1981
+ /* @__PURE__ */ o(te, { children: i("related.attentionEntries", { count: f.length }) }),
1982
+ /* @__PURE__ */ o(
1983
+ k,
1984
+ {
1985
+ variant: "tertiary",
1986
+ size: "S",
1987
+ "aria-expanded": a,
1988
+ onClick: () => l((P) => !P),
1989
+ children: i(a ? "related.hideEntries" : "related.showEntries")
1990
+ }
1991
+ )
1992
+ ] }),
1993
+ a && /* @__PURE__ */ o(
1994
+ wt,
1995
+ {
1996
+ rows: f,
1997
+ getContentTypeName: (P) => P.contentTypeName
1998
+ }
1999
+ )
2000
+ ] })
2001
+ ]
2002
+ }
2003
+ )
2004
+ ] });
2005
+ }, Us = "homePage.modal.confirmPromotion", Hs = F.ul`
2006
+ margin: 0;
2007
+ padding-inline-start: 2rem;
2008
+ list-style: disc;
2009
+ `, Gs = () => {
2010
+ const { selection: e, related: t, publishDocumentIds: n, includeMediaOption: s, contentTypes: r, promotion: i } = J(), a = s.enabledDocumentIds, l = Z(), c = x(Us), m = Wt(e.entries, a), h = Gt(e.entries, a), { selectedEntriesWithMoreLocales: f, otherRelatedEntries: g } = qt(
2011
+ t.relatedPrimary.entries
2012
+ ), y = Nt(f), C = [
2013
+ m > 0 && c("steps.media.consequence.noMedia", { count: m }),
2014
+ h > 0 && c("steps.embeddedMedia.consequence.removed", { count: h }),
2015
+ y > 0 && c("relatedPrimary.extendsSelection.summaryWarning", { count: y })
2016
+ ].filter((p) => typeof p == "string"), P = (p) => To(p, {
2017
+ publishDocumentIds: n,
2018
+ mediaDocumentIds: a,
2019
+ hasDraftAndPublish: r.hasDraftAndPublish
2020
+ }), I = t.relatedPrimary.entries.length > 0 || !!t.relatedPrimary.error, E = (p) => [
2021
+ {
2022
+ header: c("steps.summary.column.status"),
2023
+ width: qe,
2024
+ renderCell: (M) => /* @__PURE__ */ o(z, { groups: p.publish(M), getStatus: l.publish })
2025
+ },
2026
+ {
2027
+ header: c("steps.summary.column.media"),
2028
+ width: qe,
2029
+ renderCell: (M) => /* @__PURE__ */ o(z, { groups: p.media(M), getStatus: l.media })
2030
+ },
2031
+ {
2032
+ header: c("steps.summary.column.embeddedMedia"),
2033
+ width: qe,
2034
+ renderCell: (M) => /* @__PURE__ */ o(
2035
+ z,
2036
+ {
2037
+ groups: p.embeddedMedia(M),
2038
+ getStatus: l.embeddedMedia
2039
+ }
2040
+ )
2041
+ }
2042
+ ], T = E({
2043
+ publish: (p) => Ke(
2044
+ p,
2045
+ (M) => ot(void 0, P(M).publishOnTarget)
2046
+ ),
2047
+ media: (p) => Ke(
2048
+ p,
2049
+ (M) => ze(void 0, P(M).includeMedia)
2050
+ ),
2051
+ embeddedMedia: (p) => Ke(
2052
+ p,
2053
+ (M) => jt(P(M).includeMedia)
2054
+ )
2055
+ }), j = /* @__PURE__ */ o(
2056
+ W,
2057
+ {
2058
+ rows: e.entries,
2059
+ getRowKey: (p) => p.documentId,
2060
+ columns: E({
2061
+ publish: (p) => Zt(
2062
+ p,
2063
+ n.has(p.documentId)
2064
+ ),
2065
+ media: (p) => Ut(p, a.has(p.documentId)),
2066
+ embeddedMedia: (p) => Qt(
2067
+ p,
2068
+ a.has(p.documentId)
2069
+ )
2070
+ })
2071
+ }
2072
+ );
2073
+ return /* @__PURE__ */ u(A, { description: c("steps.summary.description"), children: [
2074
+ i.error && /* @__PURE__ */ o($, { variant: "danger", title: c("error.title"), description: i.error }),
2075
+ C.length > 0 && /* @__PURE__ */ o(
2076
+ $,
2077
+ {
2078
+ variant: "warning",
2079
+ title: c("steps.summary.warning.title"),
2080
+ description: /* @__PURE__ */ o(Hs, { children: C.map((p) => /* @__PURE__ */ o("li", { children: p }, p)) })
2081
+ }
2082
+ ),
2083
+ /* @__PURE__ */ u(b, { direction: "column", gap: 8, alignItems: "stretch", children: [
2084
+ I ? /* @__PURE__ */ o(A, { title: c("steps.entities.selectedTitle"), children: j }) : j,
2085
+ /* @__PURE__ */ o(
2086
+ sn,
2087
+ {
2088
+ entries: f,
2089
+ columns: T,
2090
+ showWarning: !1
2091
+ }
2092
+ ),
2093
+ /* @__PURE__ */ o(
2094
+ rn,
2095
+ {
2096
+ ...t.relatedPrimary,
2097
+ entries: g,
2098
+ description: c("relatedPrimary.description"),
2099
+ columns: T
2100
+ }
2101
+ )
2102
+ ] }),
2103
+ /* @__PURE__ */ o(
2104
+ on,
2105
+ {
2106
+ relatedContentTypes: r.relatedContentTypes,
2107
+ hasDraftAndPublish: r.hasDraftAndPublish,
2108
+ relatedEntriesContentType: t.relatedEntriesContentType
2109
+ }
2110
+ )
2111
+ ] });
2112
+ }, Ws = (e) => {
2113
+ switch (e) {
2114
+ case "entities":
2115
+ return /* @__PURE__ */ o(Zo, {});
2116
+ case "relatedEntries":
2117
+ return /* @__PURE__ */ o(hs, {});
2118
+ case "publish":
2119
+ return /* @__PURE__ */ o(cs, {});
2120
+ case "media":
2121
+ return /* @__PURE__ */ o(os, {});
2122
+ case "embeddedMedia":
2123
+ return /* @__PURE__ */ o(Vo, {});
2124
+ case "summary":
2125
+ return /* @__PURE__ */ o(Gs, {});
2126
+ }
2127
+ }, js = ({ open: e, onClose: t }) => {
2128
+ const n = x(), {
2129
+ comparison: s,
2130
+ contentTypes: r,
2131
+ selection: i,
2132
+ steps: a,
2133
+ promotion: l,
2134
+ isPreparing: c,
2135
+ isSubmitDisabled: m,
2136
+ goBack: h,
2137
+ selectStep: f,
2138
+ submit: g
2139
+ } = J(), y = (C) => r.primaryContentType ? n(`${C}.titleWithContentType`, {
2140
+ contentType: r.primaryContentType.displayName
2141
+ }) : n(`${C}.title`);
2142
+ return l.result ? /* @__PURE__ */ o(
2143
+ ae,
2144
+ {
2145
+ open: e,
2146
+ onClose: t,
2147
+ title: y("homePage.modal.promotionResults"),
2148
+ fillMaxHeight: !0,
2149
+ scrollResetKey: "results",
2150
+ children: /* @__PURE__ */ o(
2151
+ Fs,
2152
+ {
2153
+ result: l.result,
2154
+ contentTypes: r.contentTypes,
2155
+ entryTitles: i.titles,
2156
+ comparedEntities: s.entities,
2157
+ contentTypeMainField: s.mainField
2158
+ }
2159
+ )
2160
+ }
2161
+ ) : /* @__PURE__ */ o(
2162
+ ae,
2163
+ {
2164
+ open: e,
2165
+ onClose: t,
2166
+ onSubmit: g,
2167
+ secondaryActions: a.stepIndex > 0 && /* @__PURE__ */ o(k, { variant: "tertiary", disabled: l.isPending, onClick: h, children: n("common.button.back") }),
2168
+ isCloseDisabled: l.isPending,
2169
+ title: y("homePage.modal.confirmPromotion"),
2170
+ confirmButtonText: a.isSummaryStep ? n("homePage.modal.confirmPromotion.confirmButtonText", {
2171
+ count: i.documentIds.length
2172
+ }) : n("common.button.next"),
2173
+ isConfirmButtonDisabled: m,
2174
+ isConfirmButtonLoading: l.isPending,
2175
+ fillMaxHeight: !0,
2176
+ scrollResetKey: a.currentStep,
2177
+ children: c ? /* @__PURE__ */ u(b, { gap: 2, alignItems: "center", justifyContent: "center", padding: 8, children: [
2178
+ /* @__PURE__ */ o(be, { small: !0 }),
2179
+ /* @__PURE__ */ o(S, { variant: "omega", children: n("homePage.modal.confirmPromotion.preparing") })
2180
+ ] }) : /* @__PURE__ */ u(b, { direction: "column", gap: 6, alignItems: "stretch", children: [
2181
+ /* @__PURE__ */ o(
2182
+ qo,
2183
+ {
2184
+ steps: a.visibleSteps.map((C) => ({
2185
+ id: C,
2186
+ label: n(`homePage.modal.confirmPromotion.steps.${C}.label`)
2187
+ })),
2188
+ currentIndex: a.stepIndex,
2189
+ furthestIndex: a.furthestStepIndex,
2190
+ onStepSelect: l.isPending ? void 0 : f
2191
+ }
2192
+ ),
2193
+ Ws(a.currentStep)
2194
+ ] })
2195
+ }
2196
+ );
2197
+ }, Qs = ({
2198
+ open: e,
2199
+ onClose: t,
2200
+ selectedPromotions: n,
2201
+ contentTypeUid: s,
2202
+ comparison: r
2203
+ }) => /* @__PURE__ */ o(
2204
+ Oo,
2205
+ {
2206
+ selectedPromotions: n,
2207
+ contentTypeUid: s,
2208
+ comparison: r,
2209
+ children: /* @__PURE__ */ o(js, { open: e, onClose: t })
2210
+ }
2211
+ ), Vs = 2500, Ys = 5e3, Xs = (e) => e === "running" ? Vs : e === "queued" ? Ys : !1, an = (e, t = !0) => {
2212
+ const { get: n } = K(), s = he(), r = Ye(void 0), i = X({
2213
+ queryKey: le.list(e),
2214
+ queryFn: async () => {
2215
+ const { data: a } = await n(`/${q}/snapshot/sync/${e}/status`);
2216
+ return a;
2217
+ },
2218
+ enabled: !!e && t,
2219
+ refetchInterval: (a) => Xs(a.state.data?.status),
2220
+ refetchOnWindowFocus: !0
2221
+ });
2222
+ return Me(() => {
2223
+ if (!e)
2224
+ return;
2225
+ const a = r.current, l = i.data?.status;
2226
+ (a === "running" && l !== "running" || a === "queued" && l === "running") && Le(s, e), r.current = l;
2227
+ }, [i.data?.status, e, s]), i;
2228
+ }, Js = ({
2229
+ syncStatus: e,
2230
+ isSyncInProgressFromComparison: t
2231
+ }) => {
2232
+ const n = e?.status;
2233
+ switch (!0) {
2234
+ case (n === "running" || t):
2235
+ return "in_progress";
2236
+ case n === "queued":
2237
+ return "queued";
2238
+ case n === "cancelled":
2239
+ return "cancelled";
2240
+ case n === "failed":
2241
+ return "failed";
2242
+ default:
2243
+ return "none";
2244
+ }
2245
+ }, Zs = F(On)`
2246
+ background-color: ${({ theme: e }) => e.colors.neutral600};
2247
+ & > div {
2248
+ background-color: ${({ theme: e }) => e.colors.neutral150};
2249
+ }
2250
+ `, Ne = ({ lastProcessedPage: e, totalPages: t }) => {
2251
+ const { formatMessage: n } = v(), s = (r, i) => Math.round(Number(r) / Number(i) * 100);
2252
+ return /* @__PURE__ */ u(b, { direction: "row", gap: 2, alignItems: "center", children: [
2253
+ /* @__PURE__ */ o(S, { variant: "omega", children: n(
2254
+ {
2255
+ id: d("homePage.alert.syncInProgress.progress")
2256
+ },
2257
+ {
2258
+ currentPage: e,
2259
+ totalPages: t
2260
+ }
2261
+ ) }),
2262
+ /* @__PURE__ */ o(Zs, { value: s(e, t) })
2263
+ ] });
2264
+ }, zs = ({
2265
+ view: e,
2266
+ syncStatus: t,
2267
+ onRefresh: n,
2268
+ onCancel: s,
2269
+ onResume: r,
2270
+ canExecute: i
2271
+ }) => {
2272
+ const { formatMessage: a } = v();
2273
+ if (e === "none")
2274
+ return null;
2275
+ const l = Bn(t?.error, a), m = (() => {
2276
+ switch (e) {
2277
+ case "queued":
2278
+ return {
2279
+ title: a({
2280
+ id: d("homePage.alert.syncQueued.title")
2281
+ }),
2282
+ description: /* @__PURE__ */ u(b, { direction: "column", gap: 2, alignItems: "flex-start", children: [
2283
+ /* @__PURE__ */ o(S, { variant: "omega", children: a({
2284
+ id: d("homePage.alert.syncQueued.description")
2285
+ }) }),
2286
+ t?.queuePosition != null ? /* @__PURE__ */ o(S, { variant: "omega", textColor: "neutral600", children: a(
2287
+ { id: d("homePage.alert.syncQueued.position") },
2288
+ { position: t.queuePosition }
2289
+ ) }) : null,
2290
+ t?.queuedAt ? /* @__PURE__ */ o(S, { variant: "omega", textColor: "neutral600", children: a(
2291
+ { id: d("homePage.alert.syncQueued.queuedAt") },
2292
+ { queuedAt: new Date(t.queuedAt).toLocaleString() }
2293
+ ) }) : null
2294
+ ] }),
2295
+ action: /* @__PURE__ */ o(k, { onClick: n, variant: "secondary", children: a({
2296
+ id: d("homePage.alert.syncQueued.linkText")
2297
+ }) }),
2298
+ variant: "default"
2299
+ };
2300
+ case "in_progress":
2301
+ return {
2302
+ title: a({
2303
+ id: d("homePage.alert.syncInProgress.title")
2304
+ }),
2305
+ description: /* @__PURE__ */ u(b, { direction: "column", gap: 2, alignItems: "flex-start", children: [
2306
+ /* @__PURE__ */ o(S, { variant: "omega", children: a({
2307
+ id: d("homePage.alert.syncInProgress.description")
2308
+ }) }),
2309
+ /* @__PURE__ */ o(
2310
+ Ne,
2311
+ {
2312
+ lastProcessedPage: t?.lastProcessedPage ?? 0,
2313
+ totalPages: t?.totalPages ?? 1
2314
+ }
2315
+ )
2316
+ ] }),
2317
+ action: /* @__PURE__ */ u(b, { direction: "row", gap: 2, alignItems: "center", children: [
2318
+ /* @__PURE__ */ o(k, { onClick: n, variant: "secondary", children: a({
2319
+ id: d("homePage.alert.syncInProgress.linkText")
2320
+ }) }),
2321
+ i ? /* @__PURE__ */ o(k, { variant: "danger-light", onClick: s, children: a({
2322
+ id: d("common.button.cancel")
2323
+ }) }) : null
2324
+ ] }),
2325
+ variant: "default"
2326
+ };
2327
+ case "cancelled":
2328
+ return {
2329
+ title: a({
2330
+ id: d("homePage.alert.resumeSync.title")
2331
+ }),
2332
+ description: /* @__PURE__ */ u(b, { direction: "column", gap: 2, alignItems: "flex-start", children: [
2333
+ /* @__PURE__ */ o(S, { variant: "omega", children: a({
2334
+ id: d("homePage.alert.resumeSync.description")
2335
+ }) }),
2336
+ /* @__PURE__ */ o(
2337
+ Ne,
2338
+ {
2339
+ lastProcessedPage: t?.lastProcessedPage ?? 0,
2340
+ totalPages: t?.totalPages ?? 1
2341
+ }
2342
+ )
2343
+ ] }),
2344
+ action: i ? /* @__PURE__ */ o(k, { onClick: r, variant: "secondary", children: a({
2345
+ id: d("homePage.alert.resumeSync.linkText")
2346
+ }) }) : void 0,
2347
+ variant: "warning"
2348
+ };
2349
+ case "failed":
2350
+ return {
2351
+ title: a({
2352
+ id: d("homePage.alert.syncFailed.title")
2353
+ }),
2354
+ description: /* @__PURE__ */ u(b, { direction: "column", gap: 2, alignItems: "flex-start", children: [
2355
+ /* @__PURE__ */ o(S, { variant: "omega", children: a({
2356
+ id: d("homePage.alert.syncFailed.description")
2357
+ }) }),
2358
+ l ? /* @__PURE__ */ o(S, { variant: "omega", textColor: "danger500", children: l }) : null,
2359
+ /* @__PURE__ */ o(
2360
+ Ne,
2361
+ {
2362
+ lastProcessedPage: t?.lastProcessedPage ?? 0,
2363
+ totalPages: t?.totalPages ?? 1
2364
+ }
2365
+ )
2366
+ ] }),
2367
+ action: i ? /* @__PURE__ */ o(k, { onClick: r, variant: "secondary", children: a({
2368
+ id: d("homePage.alert.syncFailed.linkText")
2369
+ }) }) : void 0,
2370
+ variant: "danger"
2371
+ };
2372
+ default:
2373
+ return e;
2374
+ }
2375
+ })();
2376
+ return /* @__PURE__ */ o(
2377
+ $,
2378
+ {
2379
+ title: m?.title,
2380
+ description: m?.description,
2381
+ action: m?.action,
2382
+ variant: m?.variant
2383
+ }
2384
+ );
2385
+ }, er = () => {
2386
+ const { post: e } = K(), t = he();
2387
+ return xe({
2388
+ mutationFn: async () => await e(`/${q}/snapshot/sync/cancel`),
2389
+ onSuccess: () => {
2390
+ Le(t);
2391
+ }
2392
+ });
2393
+ }, tr = ({ open: e, onClose: t }) => {
2394
+ const { formatMessage: n } = v(), {
2395
+ mutate: s,
2396
+ isPending: r,
2397
+ error: i,
2398
+ reset: a
2399
+ } = er(), l = () => {
2400
+ t(), a();
2401
+ };
2402
+ return /* @__PURE__ */ o(
2403
+ ae,
2404
+ {
2405
+ open: e,
2406
+ onClose: l,
2407
+ onSubmit: () => s(void 0, { onSuccess: l }),
2408
+ title: /* @__PURE__ */ u(b, { direction: "row", gap: 2, alignItems: "center", children: [
2409
+ /* @__PURE__ */ o(ue, { fill: "danger500", width: 20, height: 20 }),
2410
+ n({
2411
+ id: d("homePage.modal.cancelSync.title")
2412
+ })
2413
+ ] }),
2414
+ confirmButtonText: n({
2415
+ id: d("homePage.modal.cancelSync.confirmButtonText")
2416
+ }),
2417
+ isConfirmButtonLoading: r,
2418
+ children: /* @__PURE__ */ u(b, { direction: "column", gap: 4, alignItems: "stretch", children: [
2419
+ /* @__PURE__ */ o(S, { variant: "omega", children: n({
2420
+ id: d("homePage.modal.cancelSync.description")
2421
+ }) }),
2422
+ i && /* @__PURE__ */ o(S, { variant: "omega", textColor: "danger500", children: me(i, n) })
2423
+ ] })
2424
+ }
2425
+ );
2426
+ }, nr = () => {
2427
+ const { post: e } = K(), t = he();
2428
+ return xe({
2429
+ mutationFn: async (n) => await e(`/${q}/snapshot/sync/${n}/resume`),
2430
+ onSuccess: () => {
2431
+ Le(t);
2432
+ }
2433
+ });
2434
+ }, or = ({ open: e, onClose: t, jobDocumentId: n }) => {
2435
+ const { formatMessage: s } = v(), {
2436
+ mutate: r,
2437
+ isPending: i,
2438
+ error: a,
2439
+ reset: l
2440
+ } = nr(), c = () => {
2441
+ t(), l();
2442
+ };
2443
+ return /* @__PURE__ */ o(
2444
+ ae,
2445
+ {
2446
+ open: e,
2447
+ onClose: c,
2448
+ onSubmit: () => r(n, { onSuccess: c }),
2449
+ title: s({
2450
+ id: d("homePage.modal.resumeSync.title")
2451
+ }),
2452
+ confirmButtonText: s({
2453
+ id: d("homePage.modal.resumeSync.confirmButtonText")
2454
+ }),
2455
+ isConfirmButtonDisabled: !n,
2456
+ isConfirmButtonLoading: i,
2457
+ children: /* @__PURE__ */ u(b, { direction: "column", gap: 4, alignItems: "stretch", children: [
2458
+ /* @__PURE__ */ o(S, { variant: "omega", children: s({
2459
+ id: d("homePage.modal.resumeSync.description")
2460
+ }) }),
2461
+ a && /* @__PURE__ */ o(S, { variant: "omega", textColor: "danger500", children: me(a, s) })
2462
+ ] })
2463
+ }
2464
+ );
2465
+ }, sr = ({
2466
+ contentTypeUid: e,
2467
+ isSyncInProgressFromComparison: t,
2468
+ canExecute: n,
2469
+ enabled: s = !0
2470
+ }) => {
2471
+ const [r, i] = R(!1), [a, l] = R(!1), { data: c, refetch: m } = an(
2472
+ e,
2473
+ s
2474
+ ), h = Js({
2475
+ syncStatus: c,
2476
+ isSyncInProgressFromComparison: t
2477
+ }), f = c?.jobDocumentId ?? "";
2478
+ return /* @__PURE__ */ u(D, { children: [
2479
+ /* @__PURE__ */ o(
2480
+ zs,
2481
+ {
2482
+ view: h,
2483
+ syncStatus: c,
2484
+ onRefresh: () => m(),
2485
+ onCancel: () => i(!0),
2486
+ onResume: () => l(!0),
2487
+ canExecute: n
2488
+ }
2489
+ ),
2490
+ n ? /* @__PURE__ */ u(D, { children: [
2491
+ /* @__PURE__ */ o(tr, { open: r, onClose: () => i(!1) }),
2492
+ /* @__PURE__ */ o(
2493
+ or,
2494
+ {
2495
+ open: a,
2496
+ onClose: () => l(!1),
2497
+ jobDocumentId: f
2498
+ }
2499
+ )
2500
+ ] }) : null
2501
+ ] });
2502
+ }, rr = (e) => {
2503
+ const { get: t } = K();
2504
+ return X({
2505
+ queryKey: ["compare-schemas"],
2506
+ queryFn: async () => {
2507
+ const { data: n } = await t(`/${q}/compare-schemas`);
2508
+ return n;
2509
+ },
2510
+ enabled: e
2511
+ });
2512
+ }, ir = (e, t) => {
2513
+ const n = new Set((e ?? []).map((r) => r.documentId)), s = [...t.entries()].filter(([r]) => !n.has(r)).map(([, r]) => zn(r)).filter((r) => r != null);
2514
+ return [...e ?? [], ...s];
2515
+ }, ar = (e, t) => {
2516
+ const n = new Set(t.map((r) => r.documentId)), s = /* @__PURE__ */ new Map();
2517
+ for (const [r, i] of e)
2518
+ n.has(r) && s.set(r, i);
2519
+ return s;
2520
+ }, lr = (e, t) => {
2521
+ const n = t[0]?.documentId;
2522
+ if (!n)
2523
+ return e;
2524
+ const s = new Map(e);
2525
+ return s.set(n, t), s;
2526
+ }, cr = (e) => {
2527
+ const [t, n] = R([]), [s, r] = R(() => /* @__PURE__ */ new Map()), i = ut(() => {
2528
+ n([]), r(/* @__PURE__ */ new Map());
2529
+ }, []);
2530
+ Me(() => {
2531
+ r(
2532
+ (c) => ar(c, t)
2533
+ );
2534
+ }, [t]);
2535
+ const a = ut((c) => {
2536
+ r(
2537
+ (m) => lr(m, c)
2538
+ );
2539
+ }, []), l = Y(
2540
+ () => ir(e, s),
2541
+ [e, s]
2542
+ );
2543
+ return {
2544
+ selectedPromotions: t,
2545
+ setSelectedPromotions: n,
2546
+ clear: i,
2547
+ rememberEntityGroup: a,
2548
+ entitiesForPreview: l
2549
+ };
2550
+ }, dr = () => {
2551
+ const { formatMessage: e } = v(), {
2552
+ isLoading: t,
2553
+ allowedActions: { canExecute: n = !1, canRead: s = !1 }
2554
+ } = vn([...Be.promotionExecute, ...Be.settingsRead]), [{ query: r }, i] = In(), a = Ye(!1), l = fe.object({
2555
+ page: fe.coerce.number().optional().default(1),
2556
+ pageSize: fe.coerce.number().optional().default(10),
2557
+ uid: fe.string().optional()
2558
+ }).parse(r), [c, m] = R(!1), { data: h, isLoading: f } = Un(), g = h?.active === !0, y = !f && h?.active === !1, { data: C } = an(l.uid ?? "", g), {
2559
+ data: P,
2560
+ isSuccess: I,
2561
+ isLoading: E
2562
+ } = _t(g), T = I && (P?.length ?? 0) > 0, j = P?.map((N) => ({
2563
+ key: N.uid,
2564
+ value: N.uid,
2565
+ label: N.displayName
2566
+ })) ?? [], {
2567
+ data: p,
2568
+ isLoading: M,
2569
+ error: Re
2570
+ } = jn({
2571
+ uid: l.uid,
2572
+ page: l.page,
2573
+ pageSize: l.pageSize,
2574
+ enabled: g
2575
+ }), {
2576
+ selectedPromotions: Q,
2577
+ setSelectedPromotions: U,
2578
+ clear: H,
2579
+ rememberEntityGroup: ln,
2580
+ entitiesForPreview: cn
2581
+ } = cr(p?.results), dn = (N) => {
2582
+ a.current = !1, i({
2583
+ ...r,
2584
+ page: 1,
2585
+ pageSize: 10,
2586
+ uid: N
2587
+ }), H();
2588
+ }, un = () => {
2589
+ a.current = !0, i({
2590
+ ...r,
2591
+ page: 1,
2592
+ pageSize: 10,
2593
+ uid: void 0
2594
+ }), H();
2595
+ }, mn = () => {
2596
+ m(!1), H();
2597
+ }, {
2598
+ data: De,
2599
+ isLoading: ne,
2600
+ error: st
2601
+ } = rr(g && T), rt = p?.mainField, hn = p?.maxDepthReached, Ae = p?.errors, gn = Ae?.type === "unconfigured_relations" ? Ae : void 0, Oe = Ae?.type === "sync_in_progress", _e = Oe || C?.status === "running", pe = !y && !ne && (!!st || !!De && !De?.isMatch), it = !n || f || y || ne || pe || Oe || C?.status === "running" || C?.status === "queued", pn = !!l.uid && M, fn = () => {
2602
+ switch (!0) {
2603
+ case (E || pn):
2604
+ return /* @__PURE__ */ o(be, {});
2605
+ case (I && !T):
2606
+ return /* @__PURE__ */ o(
2607
+ $,
2608
+ {
2609
+ title: e({
2610
+ id: d("homePage.alert.configurationNeeded.title")
2611
+ }),
2612
+ description: e({
2613
+ id: d(
2614
+ s ? "homePage.alert.configurationNeeded.description" : "homePage.alert.configurationNeeded.readOnlyDescription"
2615
+ )
2616
+ }),
2617
+ action: s ? /* @__PURE__ */ o(Qe, { tag: je, to: "/settings/xecp/configuration", children: e({
2618
+ id: d("homePage.alert.configurationNeeded.linkText")
2619
+ }) }) : void 0,
2620
+ variant: "danger"
2621
+ }
2622
+ );
2623
+ case _e:
2624
+ return /* @__PURE__ */ o(
2625
+ ie,
2626
+ {
2627
+ content: e({
2628
+ id: d("homePage.alert.syncInProgress.contentUnavailable")
2629
+ })
2630
+ }
2631
+ );
2632
+ case (p?.results && p?.results?.length > 0):
2633
+ return /* @__PURE__ */ u(D, { children: [
2634
+ hn && /* @__PURE__ */ o(
2635
+ $,
2636
+ {
2637
+ title: e({
2638
+ id: d("homePage.alert.maxDepthExceeded.title")
2639
+ }),
2640
+ variant: "warning",
2641
+ description: e({
2642
+ id: d("homePage.alert.maxDepthExceeded.description")
2643
+ })
2644
+ }
2645
+ ),
2646
+ /* @__PURE__ */ o(
2647
+ po,
2648
+ {
2649
+ entities: p?.results,
2650
+ contentTypeMainField: rt,
2651
+ selectedPromotions: Q,
2652
+ setSelectedPromotions: U,
2653
+ onRememberEntityGroup: ln,
2654
+ canExecute: n && !y
2655
+ }
2656
+ )
2657
+ ] });
2658
+ case !!Re:
2659
+ return /* @__PURE__ */ o(
2660
+ ie,
2661
+ {
2662
+ icon: /* @__PURE__ */ o(ue, { width: 24, height: 24 }),
2663
+ content: e({ id: d("homePage.errorLoadingEntities") })
2664
+ }
2665
+ );
2666
+ case (p?.results && p?.results?.length === 0):
2667
+ return /* @__PURE__ */ o(
2668
+ Jn,
2669
+ {
2670
+ contentTypeUid: l.uid ?? "",
2671
+ hasExistingSnapshot: p?.snapshot?.exists ?? !1,
2672
+ unconfiguredRelationsError: gn,
2673
+ isGetSnapshotDisabled: it,
2674
+ canExecute: n && !y,
2675
+ canReadSettings: s
2676
+ }
2677
+ );
2678
+ default:
2679
+ return /* @__PURE__ */ o(
2680
+ ie,
2681
+ {
2682
+ content: e({
2683
+ id: d("homePage.youNeedToSelectAContentTypeToSeeTheEntities")
2684
+ })
2685
+ }
2686
+ );
2687
+ }
2688
+ }, at = p?.snapshot?.exists ?? !1, yn = !_e && at && p?.pagination && p?.pagination?.pageCount > 0, bn = !n || f || y || ne || !T || pe || !l.uid || Q.length === 0 || _e, Sn = E || f || ne || y || pe || !T, Pn = () => {
2689
+ switch (!0) {
2690
+ case f:
2691
+ return /* @__PURE__ */ u(b, { gap: 2, alignItems: "center", children: [
2692
+ /* @__PURE__ */ o(be, { small: !0 }),
2693
+ /* @__PURE__ */ o(S, { variant: "omega", children: e({ id: d("homePage.verifyingLicense") }) })
2694
+ ] });
2695
+ case y:
2696
+ return /* @__PURE__ */ o(Yn, { canReadSettings: s });
2697
+ case ne:
2698
+ return /* @__PURE__ */ u(b, { gap: 2, alignItems: "center", children: [
2699
+ /* @__PURE__ */ o(be, { small: !0 }),
2700
+ /* @__PURE__ */ o(S, { variant: "omega", children: e({ id: d("homePage.verifyingSchemas") }) })
2701
+ ] });
2702
+ case pe:
2703
+ return /* @__PURE__ */ o(
2704
+ Xn,
2705
+ {
2706
+ compareSchemasData: De,
2707
+ errorCompareSchemas: st?.message
2708
+ }
2709
+ );
2710
+ default:
2711
+ return null;
2712
+ }
2713
+ }, lt = (
2714
+ // oxlint-disable-next-line react/refs -- the ref only gates a one-off preselect effect
2715
+ a.current || !!l.uid || !T
2716
+ );
2717
+ return Me(() => {
2718
+ if (lt) return;
2719
+ const N = P?.[0]?.uid;
2720
+ N && i({
2721
+ ...r,
2722
+ uid: N,
2723
+ page: 1,
2724
+ pageSize: 10
2725
+ });
2726
+ }, [lt, P, r, i]), t ? /* @__PURE__ */ o(re.Loading, {}) : /* @__PURE__ */ u(D, { children: [
2727
+ /* @__PURE__ */ o(re.Title, { children: e({ id: d("homePage.title") }) }),
2728
+ /* @__PURE__ */ u(re.Main, { children: [
2729
+ /* @__PURE__ */ o(
2730
+ ct.Header,
2731
+ {
2732
+ title: e({ id: d("homePage.title") }),
2733
+ primaryAction: n ? /* @__PURE__ */ o(k, { disabled: bn, onClick: () => m(!0), children: e({ id: d("homePage.promoteContent") }) }) : null
2734
+ }
2735
+ ),
2736
+ /* @__PURE__ */ o(ct.Content, { children: /* @__PURE__ */ u(b, { direction: "column", alignItems: "stretch", gap: 4, children: [
2737
+ Pn(),
2738
+ /* @__PURE__ */ o(b, { children: /* @__PURE__ */ o(
2739
+ Hn,
2740
+ {
2741
+ name: "contentType",
2742
+ placeholder: e({ id: d("homePage.selectContentType") }),
2743
+ onClear: un,
2744
+ onChange: dn,
2745
+ options: j,
2746
+ value: l.uid,
2747
+ disabled: Sn
2748
+ }
2749
+ ) }),
2750
+ l?.uid && !y ? /* @__PURE__ */ u(D, { children: [
2751
+ /* @__PURE__ */ o(
2752
+ sr,
2753
+ {
2754
+ contentTypeUid: l.uid,
2755
+ isSyncInProgressFromComparison: Oe,
2756
+ canExecute: n && !y,
2757
+ enabled: g
2758
+ }
2759
+ ),
2760
+ /* @__PURE__ */ o(
2761
+ Vn,
2762
+ {
2763
+ contentTypeUid: l.uid,
2764
+ selectedPromotionsLength: Q.length,
2765
+ syncedAt: p?.snapshot?.syncedAt ?? null,
2766
+ isGetSnapshotDisabled: it,
2767
+ hasSnapshot: at,
2768
+ clearSelectedPromotions: H,
2769
+ canExecute: n && !y,
2770
+ privateFields: P?.find((N) => N.uid === l.uid)?.privateFields
2771
+ }
2772
+ )
2773
+ ] }) : null,
2774
+ y ? null : fn(),
2775
+ yn && !y ? /* @__PURE__ */ u(
2776
+ $e.Root,
2777
+ {
2778
+ total: p?.pagination?.total || 0,
2779
+ pageCount: p?.pagination?.pageCount || 0,
2780
+ children: [
2781
+ /* @__PURE__ */ o($e.PageSize, {}),
2782
+ /* @__PURE__ */ o($e.Links, {})
2783
+ ]
2784
+ }
2785
+ ) : null
2786
+ ] }) })
2787
+ ] }),
2788
+ n && !y && c ? /* @__PURE__ */ o(
2789
+ Qs,
2790
+ {
2791
+ open: c,
2792
+ onClose: mn,
2793
+ selectedPromotions: Q,
2794
+ contentTypeUid: l.uid ?? "",
2795
+ comparison: {
2796
+ entities: cn,
2797
+ mainField: rt,
2798
+ defaultLocale: p?.defaultLocale
2799
+ }
2800
+ }
2801
+ ) : null
2802
+ ] });
2803
+ }, ur = () => /* @__PURE__ */ o(re.Protect, { permissions: [...Be.promotionRead], children: /* @__PURE__ */ o(dr, {}) }), Er = () => /* @__PURE__ */ o(Ln, { children: /* @__PURE__ */ u(wn, { children: [
2804
+ /* @__PURE__ */ o(dt, { index: !0, element: /* @__PURE__ */ o(ur, {}) }),
2805
+ /* @__PURE__ */ o(dt, { path: "*", element: /* @__PURE__ */ o(re.Error, {}) })
2806
+ ] }) });
2807
+ export {
2808
+ Er as default
2809
+ };