@deviceinsight/ng-ui-scale-lib 9.14.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.
@@ -0,0 +1,44 @@
1
+ import { at as t, cz as m } from "./ContextBarContext-f745a63a.js";
2
+ import { useState as p } from "react";
3
+ import { Button as d, Icon as u } from "@deviceinsight/ng-ui-basic-components";
4
+ import { ImageUpload as F, FileUpload as x } from "@deviceinsight/ng-ui-components";
5
+ const s = ({ file: e, onRemoveFile: o }) => /* @__PURE__ */ t.jsxs(
6
+ "strong",
7
+ {
8
+ style: {
9
+ display: "flex",
10
+ alignItems: "center",
11
+ justifyContent: "center"
12
+ },
13
+ children: [
14
+ e && e.name,
15
+ /* @__PURE__ */ t.jsx(d, { naked: !0, onClick: o, "data-testid": "delete-file-button", children: /* @__PURE__ */ t.jsx(u, { del: !0 }) })
16
+ ]
17
+ }
18
+ ), U = ({ imagesOnly: e, onChange: o, ...a }) => {
19
+ const [c, l] = p(null), n = (r) => {
20
+ e && l(r.preview), o(r);
21
+ }, i = () => {
22
+ e && l(null), o(null);
23
+ };
24
+ return /* @__PURE__ */ t.jsx(m, { ...a, className: "fileuploadinput", children: e ? /* @__PURE__ */ t.jsx(
25
+ F,
26
+ {
27
+ onRemoveFile: i,
28
+ onSelectFile: n,
29
+ previewComponent: s,
30
+ imageUrl: c,
31
+ accept: "image/*"
32
+ }
33
+ ) : /* @__PURE__ */ t.jsx(
34
+ x,
35
+ {
36
+ onRemoveFile: i,
37
+ onSelectFile: n,
38
+ previewComponent: s
39
+ }
40
+ ) });
41
+ };
42
+ export {
43
+ U as F
44
+ };
@@ -0,0 +1,360 @@
1
+ import { ah as M, at as e, ag as p, cZ as D, c_ as R, bn as G, a6 as Y, b1 as z, cp as Z, c$ as q, aV as _, aN as $ } from "./ContextBarContext-f745a63a.js";
2
+ import { messageBoxError as J, ReactableWithClientSidePagination as ee, ContentHeader as te, RouteTabs as se } from "@deviceinsight/ng-ui-components";
3
+ import { useState as B, useCallback as S, useRef as ie, useEffect as U, useMemo as X, createContext as ae, useContext as ne } from "react";
4
+ import { Modal as le, SpinnerContainer as P, Button as k, Icon as W, useConfirm as oe } from "@deviceinsight/ng-ui-basic-components";
5
+ import { F as re } from "./FileUploadInput-6dc037cb.js";
6
+ import { createPortal as de } from "react-dom";
7
+ import { Link as ce } from "react-router-dom";
8
+ import { g as V } from "./customFileCategories-1b64ed45.js";
9
+ import "@deviceinsight/ng-ui-api-client";
10
+ const Ae = ({ fileType: t, onClose: s, onUpload: l }) => {
11
+ const { t: n } = M(), [u, i] = B(null), [m, A] = B(""), [g, f] = B(!1), h = u && !m, d = async (o) => {
12
+ if (o) {
13
+ f(!0);
14
+ try {
15
+ await l(o, t), s();
16
+ } catch (F) {
17
+ J(F.message), console.error(F), f(!1);
18
+ }
19
+ }
20
+ }, x = (o) => {
21
+ i(o), A(o ? "" : n("assets.detail.files.uploadForm.error.missingFile", {
22
+ defaultValue: "Please select a file"
23
+ }));
24
+ };
25
+ return /* @__PURE__ */ e.jsx(
26
+ le,
27
+ {
28
+ width: 450,
29
+ header: t === "documents" ? /* @__PURE__ */ e.jsx(p, { i18nKey: "assets.detail.files.uploadForm.addDocument", children: "Add document" }) : /* @__PURE__ */ e.jsx(p, { i18nKey: "assets.detail.files.uploadForm.addImage", children: "Add image" }),
30
+ content: /* @__PURE__ */ e.jsx(P, { show: g, children: /* @__PURE__ */ e.jsx(
31
+ re,
32
+ {
33
+ label: /* @__PURE__ */ e.jsx(p, { i18nKey: "assets.detail.files.uploadForm.fileLabel", children: "File to upload" }),
34
+ onChange: x,
35
+ imagesOnly: t === "images",
36
+ error: m,
37
+ required: !0
38
+ }
39
+ ) }),
40
+ footer: /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
41
+ /* @__PURE__ */ e.jsx(
42
+ k,
43
+ {
44
+ onClick: () => d(u),
45
+ primary: !0,
46
+ disabled: !h || g,
47
+ "data-testid": "save-button",
48
+ children: /* @__PURE__ */ e.jsx(p, { i18nKey: "general.actions.save", children: "Save" })
49
+ }
50
+ ),
51
+ /* @__PURE__ */ e.jsx(k, { onClick: s, children: /* @__PURE__ */ e.jsx(p, { i18nKey: "general.actions.cancel", children: "Cancel" }) })
52
+ ] })
53
+ }
54
+ );
55
+ }, ue = ({ contentType: t, loading: s, content: l }) => /* @__PURE__ */ e.jsx("div", { className: "image-preview", children: /* @__PURE__ */ e.jsxs(P, { show: s, children: [
56
+ t === "image/svg+xml" && /* @__PURE__ */ e.jsx(
57
+ "div",
58
+ {
59
+ className: "svg-preview",
60
+ style: {
61
+ backgroundImage: `url("${s || !l ? "" : l}")`
62
+ }
63
+ }
64
+ ),
65
+ t !== "image/svg+xml" && /* @__PURE__ */ e.jsx("img", { src: l, alt: "" })
66
+ ] }) }), me = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAfCAYAAADwbH0HAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH4ggUCDQxnLQ5VQAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAGASURBVEjHvde3UgMxEIBhAUNBdoKCHEo/Aa9BCwWtXw7GBRVDGPKAzzahIaeKmhp+CmSP5izJF/a8rXb3mztJJ51SRgB9qkfRb6AVpdQWMCiNANPANlAKD1SAX/6jKolr9F73bgKF1sCGgSKJh9BWBEBOAbPAE52RCtfog6XvLjDUSpoDnqVwD7rXRo3keeAlLQ7MONB9YNhVlArX6KOl/sCJGsULwGtc3IMedkWNJovAW1Tcgx4BI3EXSCTcgx4Do0m3xBLw7sI96Eli1MCXgQ9L8x0HegqMSX32XHg4zsRQA18BPj3oOTCeyVEGrDrQ746TRxAtATeeJ66KH6kavY4wx3I4UHSgl8BXJrhGm66FBJTFcaAANCxNL8zVK4pHRUVxjdYdczrhqUuOA/kkaCpco4Gl6ArIxZim6LhGa5bkWhw0Fg7kHGgA5FNsRT8OrFnu1fU0aBf81rzUbwI/eqDRHpD58pn4HTAZTljXr7yYwQFT1tfbKVfCQK/+Fv8AJCO91qtSsKIAAAAASUVORK5CYII=", ge = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAnCAYAAADtu3N3AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH4ggUCCsYE1yvpwAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAFTSURBVEjHrdY9S5BhFAbgNykUKUIRE10kGxxsUgQXF2lLGppsCTcdGhprCZxqcNCxKRp0EcTJpaWGwBaDhpCIoJZECIQkTOty8Ajvfs7zAy44D/f5aJrkQweGmgLoEtZxioEs9sL5+4CODLQY0DfcyECzUdovjGagCfzGMaYz0DB+4j/mMlAPPsc/PclAnXgX0MuKLME2LldkaRdXM9BCQN8xmIHuRpYOMZaBxiNLfzFTkSV4WJWlZ9ksvQ3oVTZLawG9wZUM9jygT7iegYYCOsVIxQy/6LvXFbO8F3sBLlWAN7Ef4HwFOIkjnOBOBXgP/6Inb1eAj6LcH1ULdjnAj7hWEZmNkgkbYBfep2d/C+zDlwCfVoC3cBD78kEFOIU/6U3eAu9HBnM3Rgt8XHL9tMCV1l3WXZHBzQC3UodegN3YCXC1otx+fA2wpIeHsdA0TXMGpWMqV6FcS+MAAAAASUVORK5CYII=", fe = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAnCAYAAAACeRhJAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH4ggUCCwH0RU0lQAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAFISURBVEjHrdaxS9VhFAZgja43JUy4uETocBsjwSXvLLnYEjQn4pKb4B6I08XJ1SXK6bo4Oogt3T0QHXTLJMGWFDFI83HwDM7f+Z0/4OF7h++8pwfD6O/JDn5gD0NZaM3dfEVfBqphJ7D17KueRDxYzmIj+BXYXBYbxwWuMJXFpnGNc4xlsQ8R8RjPslg7sF0MZqBedALbRi2D1fEtsE/ZiA0cBPYxizVxGtj7LPYKl/iHySz2Fv/xBy+y2EJEPMLTLLYa2Hc8zkAPsBnYFh5msIF72+JNBloM5CeGS5F3uMEZXpYiLfyNnfW6FHmO3xFpNvPnDgNZKkUeoRvIl8xe2rjXfbVSaCWQ/eI2xnwgJxjNtskFxrP9do3pKhp3vooboF3FVdJBbyn0OZAu6qXIUiAHaJQiM4GcoplZUCdRMxNVVEwre9TeAsA6JS24jJJMAAAAAElFTkSuQmCC", xe = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAdCAYAAACqhkzFAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH4ggUCDYA/1xb7QAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAADlSURBVEjH7dW/CsIwEAbw7ySDjyFOujgJ4jMU3AWp7eJLCE7+2ZzENxB8GmdHV0FBN5f6uVQMIW0aCk45KLSX3I9LCI3AEiRHAGYoj4WInMykKpjcBhA5wJ0t2XAULQF0jedQVqAc4FVEzsZ2PMoKXB16RwADGMAA/gdUJFsAJkZ+WKF2TLKvfWcA9kpELiSbAOaezcTa+xtAKiJP/U+84i+2JBOSHcsFNsjHjvncjGSMgtvui95I9opaIxmRfOXYtHQdLtQL04rWNtTAEq8dN9FamIZucvSuYWmtg6qh9TFj+ZWwD7+x6apgNh+aAAAAAElFTkSuQmCC";
67
+ const he = ({ initialImageNumber: t, items: s, onDownload: l, onClose: n }) => {
68
+ const [u, i] = B(t), [m, A] = B(), [g, f] = B(!1), h = S(() => i((b) => Math.min(s.length - 1, b + 1)), [s]), d = S(() => i((b) => Math.max(0, b - 1)), []), x = ie({});
69
+ U(() => (D.addListener("right", h), D.addListener("left", d), D.addListener("esc", n), () => {
70
+ D.removeListener("right", h), D.removeListener("left", d), D.removeListener("esc", n);
71
+ }), [h, d, n]);
72
+ const o = s[u];
73
+ U(() => {
74
+ const b = x.current[o.key];
75
+ b ? A(R(o.contentType, b)) : (f(!0), l(o).then((w) => {
76
+ f(!1), x.current[o.key] = w, A(R(o.contentType, w));
77
+ }));
78
+ }, [o, l]);
79
+ const F = () => {
80
+ G.saveAs(new Blob([x.current[o.key]]), o.filename);
81
+ }, I = s.length > 0 && u > 0, v = s.length > 0 && u < s.length - 1, { body: y } = document;
82
+ return y ? de(
83
+ /* @__PURE__ */ e.jsxs("div", { className: "di file-previewer", children: [
84
+ /* @__PURE__ */ e.jsx("div", { className: "background" }),
85
+ /* @__PURE__ */ e.jsxs("div", { className: "header", children: [
86
+ /* @__PURE__ */ e.jsx("h1", { className: "filename", children: o.filename }),
87
+ /* @__PURE__ */ e.jsx("button", { className: "btn close", onClick: n, children: /* @__PURE__ */ e.jsx("span", { role: "img", "aria-label": "close", children: /* @__PURE__ */ e.jsx("img", { src: me, alt: "close" }) }) })
88
+ ] }),
89
+ /* @__PURE__ */ e.jsxs("div", { className: "content", children: [
90
+ /* @__PURE__ */ e.jsx("div", { className: "left", children: I && /* @__PURE__ */ e.jsx("button", { className: "btn previous", onClick: d, children: /* @__PURE__ */ e.jsx("span", { role: "img", "aria-label": "previous", children: /* @__PURE__ */ e.jsx("img", { src: ge, alt: "previous" }) }) }) }),
91
+ /* @__PURE__ */ e.jsx("div", { className: "center", children: /* @__PURE__ */ e.jsx(ue, { loading: g, content: m, contentType: o.contentType }) }),
92
+ /* @__PURE__ */ e.jsx("div", { className: "right", children: v && /* @__PURE__ */ e.jsx("button", { className: "btn next", onClick: h, children: /* @__PURE__ */ e.jsx("span", { role: "img", "aria-label": "next", children: /* @__PURE__ */ e.jsx("img", { src: fe, alt: "next" }) }) }) })
93
+ ] }),
94
+ /* @__PURE__ */ e.jsx("div", { className: "footer", children: /* @__PURE__ */ e.jsx("button", { className: "btn download", onClick: F, disabled: g, children: /* @__PURE__ */ e.jsx("span", { role: "img", "aria-label": "close", children: /* @__PURE__ */ e.jsx("img", { src: xe, alt: "download" }) }) }) })
95
+ ] }),
96
+ y
97
+ ) : null;
98
+ };
99
+ var Q = { exports: {} };
100
+ (function(t, s) {
101
+ (function(l) {
102
+ var n = /^(b|B)$/, u = { iec: { bits: ["b", "Kib", "Mib", "Gib", "Tib", "Pib", "Eib", "Zib", "Yib"], bytes: ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"] }, jedec: { bits: ["b", "Kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb"], bytes: ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"] } }, i = { iec: ["", "kibi", "mebi", "gibi", "tebi", "pebi", "exbi", "zebi", "yobi"], jedec: ["", "kilo", "mega", "giga", "tera", "peta", "exa", "zetta", "yotta"] };
103
+ function m(A) {
104
+ var g, f, h, d, x, o, F, I, v, y, b, w, j, C, L, c = 1 < arguments.length && arguments[1] !== void 0 ? arguments[1] : {}, a = [], N = 0, r = void 0, T = void 0;
105
+ if (isNaN(A))
106
+ throw new TypeError("Invalid number");
107
+ return f = c.bits === !0, b = c.unix === !0, g = c.base || 2, y = c.round !== void 0 ? c.round : b ? 1 : 2, o = c.locale !== void 0 ? c.locale : "", F = c.localeOptions || {}, w = c.separator !== void 0 ? c.separator : "", j = c.spacer !== void 0 ? c.spacer : b ? "" : " ", L = c.symbols || {}, C = g === 2 && c.standard || "jedec", v = c.output || "string", d = c.fullform === !0, x = c.fullforms instanceof Array ? c.fullforms : [], r = c.exponent !== void 0 ? c.exponent : -1, h = 2 < g ? 1e3 : 1024, (I = (T = Number(A)) < 0) && (T = -T), (r === -1 || isNaN(r)) && (r = Math.floor(Math.log(T) / Math.log(h))) < 0 && (r = 0), 8 < r && (r = 8), v === "exponent" ? r : (T === 0 ? (a[0] = 0, a[1] = b ? "" : u[C][f ? "bits" : "bytes"][r]) : (N = T / (g === 2 ? Math.pow(2, 10 * r) : Math.pow(1e3, r)), f && h <= (N *= 8) && r < 8 && (N /= h, r++), a[0] = Number(N.toFixed(0 < r ? y : 0)), a[0] === h && r < 8 && c.exponent === void 0 && (a[0] = 1, r++), a[1] = g === 10 && r === 1 ? f ? "kb" : "kB" : u[C][f ? "bits" : "bytes"][r], b && (a[1] = C === "jedec" ? a[1].charAt(0) : 0 < r ? a[1].replace(/B$/, "") : a[1], n.test(a[1]) && (a[0] = Math.floor(a[0]), a[1] = ""))), I && (a[0] = -a[0]), a[1] = L[a[1]] || a[1], o === !0 ? a[0] = a[0].toLocaleString() : 0 < o.length ? a[0] = a[0].toLocaleString(o, F) : 0 < w.length && (a[0] = a[0].toString().replace(".", w)), v === "array" ? a : (d && (a[1] = x[r] ? x[r] : i[C][r] + (f ? "bit" : "byte") + (a[0] === 1 ? "" : "s")), v === "object" ? { value: a[0], symbol: a[1], exponent: r } : a.join(j)));
108
+ }
109
+ m.partial = function(A) {
110
+ return function(g) {
111
+ return m(g, A);
112
+ };
113
+ }, t.exports = m;
114
+ })();
115
+ })(Q);
116
+ var pe = Q.exports;
117
+ const be = /* @__PURE__ */ Y(pe), je = {
118
+ page: 0,
119
+ size: 10,
120
+ sort: {
121
+ property: "creationDate",
122
+ direction: "DESC"
123
+ }
124
+ };
125
+ function Be(t, s, l, n, u) {
126
+ return [
127
+ {
128
+ name: "filename",
129
+ label: /* @__PURE__ */ e.jsx(p, { i18nKey: "assets.detail.files.columns.filename", children: "Filename" }),
130
+ width: "50%",
131
+ sortable: !0,
132
+ filterable: {
133
+ filterType: "text",
134
+ filterFn(i, m) {
135
+ return i.filename.toLowerCase().indexOf(m.toLowerCase()) !== -1;
136
+ }
137
+ },
138
+ render: (i) => /* @__PURE__ */ e.jsxs(ce, { to: "#", onClick: () => s(i), children: [
139
+ i.filename,
140
+ i.context && /* @__PURE__ */ e.jsxs("span", { children: [
141
+ " [",
142
+ i.context === "svgWidget" ? "Svg Widget" : "Asset Image Widget",
143
+ "]"
144
+ ] })
145
+ ] })
146
+ },
147
+ {
148
+ name: "size",
149
+ sortable: !0,
150
+ label: /* @__PURE__ */ e.jsx(p, { i18nKey: "assets.detail.files.columns.size", children: "Size" }),
151
+ width: "20%",
152
+ render: (i) => be(i.size)
153
+ },
154
+ {
155
+ name: "creationDate",
156
+ sortable: !0,
157
+ label: /* @__PURE__ */ e.jsx(p, { i18nKey: "assets.detail.files.columns.lastModificationDate", children: "Last modification date" }),
158
+ width: "20%",
159
+ render: (i) => z(new Date(i.creationDate).getTime())
160
+ },
161
+ {
162
+ name: "deleteAndDownload",
163
+ label: "",
164
+ align: "right",
165
+ render: (i) => /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
166
+ /* @__PURE__ */ e.jsx(k, { onClick: () => l(i), naked: !0, children: /* @__PURE__ */ e.jsx("img", { src: Z, alt: "Download" }) }),
167
+ /* @__PURE__ */ e.jsx(
168
+ "span",
169
+ {
170
+ title: i.context ? u("assets.detail.files.deleteDisabledTooltip", {
171
+ defaultValue: "Cannot be removed because is used by some {{widget}}",
172
+ widget: i.context === "svgWidget" ? "Svg Widget" : "Asset Image Widget"
173
+ }) : void 0,
174
+ children: /* @__PURE__ */ e.jsx(
175
+ k,
176
+ {
177
+ naked: !0,
178
+ disabled: !!i.context,
179
+ onClick: () => n(i),
180
+ "data-testid": "delete-file-button",
181
+ children: /* @__PURE__ */ e.jsx(W, { del: !0 })
182
+ }
183
+ )
184
+ }
185
+ )
186
+ ] })
187
+ }
188
+ ];
189
+ }
190
+ function Fe({ files: t, loading: s, type: l, onFilenameClick: n, onDownload: u, onDelete: i }) {
191
+ const { t: m } = M();
192
+ return /* @__PURE__ */ e.jsx(
193
+ ee,
194
+ {
195
+ columnDefs: Be(l, n, u, i, m),
196
+ uniqueItemKey: (A) => A.key,
197
+ paginationSettings: je,
198
+ items: t,
199
+ isLoading: s
200
+ }
201
+ );
202
+ }
203
+ function K(t, s, l) {
204
+ const n = X(() => q(s, l, t), [s, l, t]), [u, i] = B(!1), [m, A] = B([]);
205
+ U(() => {
206
+ const { promise: d, cancel: x } = _(n.fetchFiles());
207
+ return d.then((o) => {
208
+ A(o), i(!1);
209
+ }).catch((o) => {
210
+ o.isCanceled || i(!1);
211
+ }), x;
212
+ }, [n]);
213
+ async function g(d, x) {
214
+ i(!0);
215
+ try {
216
+ const o = await n.uploadFile(d, x);
217
+ A([...m, o]);
218
+ } finally {
219
+ i(!1);
220
+ }
221
+ }
222
+ async function f(d) {
223
+ i(!0);
224
+ try {
225
+ await n.deleteFile(d.key), A(m.filter((x) => x.key !== d.key));
226
+ } finally {
227
+ i(!1);
228
+ }
229
+ }
230
+ function h(d) {
231
+ return n.fetchFile(d.key);
232
+ }
233
+ return {
234
+ loading: u,
235
+ files: m,
236
+ uploadFile: g,
237
+ deleteFile: f,
238
+ fetchFile: h
239
+ };
240
+ }
241
+ const H = {
242
+ deleteFile: () => {
243
+ },
244
+ files: [],
245
+ uploadFile: () => {
246
+ },
247
+ fetchFile: () => Promise.resolve(new ArrayBuffer(0)),
248
+ loading: !1
249
+ }, O = ae({
250
+ documents: H,
251
+ images: H
252
+ });
253
+ function Ce({ asset: t, assetGroup: s, children: l }) {
254
+ const n = K("documents", t, s), u = K("images", t, s);
255
+ return /* @__PURE__ */ e.jsx(O.Provider, { value: { documents: n, images: u }, children: l });
256
+ }
257
+ function ve(t) {
258
+ const { documents: s, images: l } = ne(O);
259
+ return t === "documents" ? s : l;
260
+ }
261
+ function we(t, s) {
262
+ const l = V().map(({ categoryName: n }) => n);
263
+ return s && l.includes(s) ? t.filter((n) => n.category === s) : t.filter(
264
+ (n) => !n.category || !l.includes(n.category)
265
+ );
266
+ }
267
+ function E({ type: t, category: s }) {
268
+ const { loading: l, files: n, uploadFile: u, deleteFile: i, fetchFile: m } = ve(t), A = X(() => we(n, s), [n, s]), [g, f] = B(!1), [h, d] = B(!1), [x, o] = B(0), { t: F } = M(), I = oe();
269
+ async function v(j) {
270
+ const C = await m(j);
271
+ G.saveAs(new Blob([C]), j.filename);
272
+ }
273
+ function y(j) {
274
+ t === "images" ? (o(A.indexOf(j)), d(!0)) : v(j);
275
+ }
276
+ async function b(j) {
277
+ try {
278
+ await u(j, s);
279
+ } catch (C) {
280
+ console.error(C), J(/* @__PURE__ */ e.jsx(p, { i18nKey: "files.error.unknown", children: "Operation failed" }));
281
+ }
282
+ }
283
+ async function w(j) {
284
+ await I({
285
+ title: F("assets.detail.files.deleteConfirmTitle", { defaultValue: "Delete File" }),
286
+ message: F("assets.detail.files.deleteConfirmMessage", {
287
+ defaultValue: "Do you really want to delete this file?"
288
+ })
289
+ }) && await i(j);
290
+ }
291
+ return /* @__PURE__ */ e.jsxs("div", { children: [
292
+ /* @__PURE__ */ e.jsx(
293
+ Fe,
294
+ {
295
+ files: A,
296
+ loading: l,
297
+ type: t,
298
+ onDownload: v,
299
+ onFilenameClick: y,
300
+ onDelete: w
301
+ }
302
+ ),
303
+ /* @__PURE__ */ e.jsx($, { authorities: ["WRITE_ASSET_OR_ASSET_GROUP_FILE"], children: /* @__PURE__ */ e.jsxs(k, { onClick: () => f(!0), "data-testid": "add-file-button", children: [
304
+ /* @__PURE__ */ e.jsx(W, { add: !0 }),
305
+ t === "images" && /* @__PURE__ */ e.jsx(p, { i18nKey: "assets.detail.files.addImage", children: "Add image" }),
306
+ t === "documents" && /* @__PURE__ */ e.jsx(p, { i18nKey: "assets.detail.files.addFile", children: "Add file" })
307
+ ] }) }),
308
+ g && /* @__PURE__ */ e.jsx(Ae, { fileType: t, onClose: () => f(!1), onUpload: b }),
309
+ h && /* @__PURE__ */ e.jsx(
310
+ he,
311
+ {
312
+ initialImageNumber: x,
313
+ items: A,
314
+ onDownload: m,
315
+ onClose: () => d(!1)
316
+ }
317
+ )
318
+ ] });
319
+ }
320
+ function ye() {
321
+ return [
322
+ {
323
+ path: "documents",
324
+ renderHeading: () => /* @__PURE__ */ e.jsx(p, { i18nKey: "assets.detail.files.tabs.documents", children: "Documents" }),
325
+ renderBody: () => /* @__PURE__ */ e.jsx(E, { type: "documents" })
326
+ },
327
+ ...V().filter(({ type: t }) => t === "documents").map(({ categoryName: t, locizeKey: s, locizeDefaultValue: l }) => ({
328
+ path: t,
329
+ renderHeading: () => /* @__PURE__ */ e.jsx(p, { i18nKey: s, children: l }),
330
+ renderBody: () => /* @__PURE__ */ e.jsx(E, { type: "documents", category: t })
331
+ })),
332
+ {
333
+ path: "images",
334
+ renderHeading: () => /* @__PURE__ */ e.jsx(p, { i18nKey: "assets.detail.files.tabs.images", children: "Images" }),
335
+ renderBody: () => /* @__PURE__ */ e.jsx(E, { type: "images" })
336
+ },
337
+ ...V().filter(({ type: t }) => t === "images").map(({ categoryName: t, locizeKey: s, locizeDefaultValue: l }) => ({
338
+ path: t,
339
+ renderHeading: () => /* @__PURE__ */ e.jsx(p, { i18nKey: s, children: l }),
340
+ renderBody: () => /* @__PURE__ */ e.jsx(E, { type: "images", category: t })
341
+ }))
342
+ ];
343
+ }
344
+ function Le({ asset: t, assetGroup: s }) {
345
+ return /* @__PURE__ */ e.jsxs("div", { children: [
346
+ /* @__PURE__ */ e.jsx(
347
+ te,
348
+ {
349
+ title: {
350
+ id: "assets.detail.files.name",
351
+ defaultValue: "Files"
352
+ }
353
+ }
354
+ ),
355
+ /* @__PURE__ */ e.jsx(Ce, { asset: t, assetGroup: s, children: /* @__PURE__ */ e.jsx(se, { pages: ye() }) })
356
+ ] });
357
+ }
358
+ export {
359
+ Le as default
360
+ };