ode-explorer 1.3.2-dev.202401091744 → 1.3.2-dev.202401101530

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index2.js CHANGED
@@ -1,228 +1,163 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
7
- import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
8
- import { useState, useRef, useEffect, Suspense, lazy, Fragment } from "react";
9
- import { useScrollToTop, useOdeClient, IconButton, useToast, useUser, LoadingScreen, FormControl, Input, SearchButton, Dropdown, useToggle, TreeView, Button, useXitiTrackPageLoad, isActionAvailable, AppHeader, Breadcrumb, Grid } from "@edifice-ui/react";
10
- import { ArrowLeft, Filter, Delete, Plus } from "@edifice-ui/icons";
11
- import { useTranslation } from "react-i18next";
12
- import { odeServices, FOLDER, APP } from "edifice-ts-client";
13
- import { t } from "i18next";
14
- import { create } from "zustand";
15
- import { useQuery, useInfiniteQuery, useQueryClient, useMutation } from "@tanstack/react-query";
16
- const searchContext = async (searchParams) => {
17
- const search = await odeServices.resource(searchParams.app).searchContext(searchParams);
1
+ var fe = Object.defineProperty;
2
+ var pe = (e, s, t) => s in e ? fe(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t;
3
+ var $ = (e, s, t) => (pe(e, typeof s != "symbol" ? s + "" : s, t), t);
4
+ import { jsx as l, jsxs as C, Fragment as ae } from "react/jsx-runtime";
5
+ import { useState as ce, useRef as me, useEffect as U, lazy as b, Suspense as v, Fragment as ye } from "react";
6
+ import { useScrollToTop as ge, useOdeClient as M, IconButton as Ie, useToast as q, useUser as Se, LoadingScreen as A, FormControl as we, Input as xe, SearchButton as De, Dropdown as j, useToggle as be, TreeView as Te, Button as Fe, useXitiTrackPageLoad as Ce, isActionAvailable as oe, AppHeader as Ne, Breadcrumb as Re, Grid as ee } from "@edifice-ui/react";
7
+ import { ArrowLeft as Pe, Filter as Ae, Delete as Ee, Plus as Qe } from "@edifice-ui/icons";
8
+ import { useTranslation as z } from "react-i18next";
9
+ import { odeServices as N, FOLDER as F, APP as se } from "edifice-ts-client";
10
+ import { t as D } from "i18next";
11
+ import { create as ve } from "zustand";
12
+ import { useQuery as qe, useInfiniteQuery as Oe, useQueryClient as O, useMutation as L } from "@tanstack/react-query";
13
+ const le = async (e) => {
14
+ const s = await N.resource(e.app).searchContext(e);
18
15
  return {
19
- ...search,
20
- folders: search.folders.filter((folder) => !folder.trashed)
16
+ ...s,
17
+ folders: s.folders.filter((t) => !t.trashed)
21
18
  };
22
- };
23
- const createFolder = async ({
24
- searchParams,
25
- name,
26
- parentId
19
+ }, Le = async ({
20
+ searchParams: e,
21
+ name: s,
22
+ parentId: t
27
23
  }) => {
28
- const createFolderParameters = {
29
- name,
30
- parentId,
31
- app: searchParams.app,
32
- type: searchParams.types[0]
24
+ const r = {
25
+ name: s,
26
+ parentId: t,
27
+ app: e.app,
28
+ type: e.types[0]
33
29
  };
34
- return await odeServices.resource(searchParams.app).createFolder(createFolderParameters);
35
- };
36
- const updateFolder = async ({
37
- folderId,
38
- searchParams,
39
- parentId,
40
- name
30
+ return await N.resource(e.app).createFolder(r);
31
+ }, ke = async ({
32
+ folderId: e,
33
+ searchParams: s,
34
+ parentId: t,
35
+ name: r
41
36
  }) => {
42
- const updateFolderParameters = {
43
- folderId,
44
- name,
45
- parentId,
46
- app: searchParams.app,
47
- type: searchParams.types[0]
37
+ const n = {
38
+ folderId: e,
39
+ name: r,
40
+ parentId: t,
41
+ app: s.app,
42
+ type: s.types[0]
48
43
  };
49
- return await odeServices.resource(searchParams.app).updateFolder(updateFolderParameters);
50
- };
51
- const trashAll = async ({
52
- searchParams,
53
- resourceIds,
54
- useAssetIds,
55
- folderIds
44
+ return await N.resource(s.app).updateFolder(n);
45
+ }, Ue = async ({
46
+ searchParams: e,
47
+ resourceIds: s,
48
+ useAssetIds: t,
49
+ folderIds: r
56
50
  }) => {
57
- const trashParameters = {
58
- application: searchParams.app,
59
- resourceType: searchParams.types[0],
60
- resourceIds,
61
- folderIds
51
+ const n = {
52
+ application: e.app,
53
+ resourceType: e.types[0],
54
+ resourceIds: s,
55
+ folderIds: r
62
56
  };
63
- return await odeServices.resource(searchParams.app).trashAll(trashParameters, useAssetIds);
64
- };
65
- const deleteAll = async ({
66
- searchParams,
67
- resourceIds,
68
- useAssetIds,
69
- folderIds
57
+ return await N.resource(e.app).trashAll(n, t);
58
+ }, Me = async ({
59
+ searchParams: e,
60
+ resourceIds: s,
61
+ useAssetIds: t,
62
+ folderIds: r
70
63
  }) => {
71
- const deleteParameters = {
72
- application: searchParams.app,
73
- resourceType: searchParams.types[0],
74
- resourceIds,
75
- folderIds
64
+ const n = {
65
+ application: e.app,
66
+ resourceType: e.types[0],
67
+ resourceIds: s,
68
+ folderIds: r
76
69
  };
77
- return await odeServices.resource(searchParams.app).deleteAll(deleteParameters, useAssetIds);
78
- };
79
- const restoreAll = async ({
80
- searchParams,
81
- resourceIds,
82
- folderIds,
83
- useAssetIds
70
+ return await N.resource(e.app).deleteAll(n, t);
71
+ }, Be = async ({
72
+ searchParams: e,
73
+ resourceIds: s,
74
+ folderIds: t,
75
+ useAssetIds: r
84
76
  }) => {
85
- const trashParameters = {
86
- application: searchParams.app,
87
- resourceType: searchParams.types[0],
88
- resourceIds,
89
- folderIds
77
+ const n = {
78
+ application: e.app,
79
+ resourceType: e.types[0],
80
+ resourceIds: s,
81
+ folderIds: t
90
82
  };
91
- return await odeServices.resource(searchParams.app).restoreAll(trashParameters, useAssetIds);
92
- };
93
- const moveToFolder = async ({
94
- searchParams,
95
- resourceIds,
96
- folderId,
97
- folderIds,
98
- useAssetIds
83
+ return await N.resource(e.app).restoreAll(n, r);
84
+ }, Ke = async ({
85
+ searchParams: e,
86
+ resourceIds: s,
87
+ folderId: t,
88
+ folderIds: r,
89
+ useAssetIds: n
99
90
  }) => {
100
- const moveParameters = {
101
- application: searchParams.app,
102
- folderId,
103
- resourceIds,
104
- folderIds
91
+ const i = {
92
+ application: e.app,
93
+ folderId: t,
94
+ resourceIds: s,
95
+ folderIds: r
105
96
  };
106
- return await odeServices.resource(searchParams.app).moveToFolder(moveParameters, useAssetIds);
107
- };
108
- const shareResource = async ({
109
- app,
110
- resourceId,
111
- rights
112
- }) => {
113
- return await odeServices.share().saveRights(app, resourceId, rights);
114
- };
115
- const updateResource = async ({
116
- app,
117
- params
118
- }) => {
119
- return await odeServices.resource(app).update(params);
120
- };
121
- const sessionHasWorkflowRights = async (actionRights) => {
122
- return await odeServices.rights().sessionHasWorkflowRights(actionRights);
123
- };
124
- const goToResource = ({
125
- searchParams,
126
- assetId
127
- }) => {
128
- return odeServices.resource(searchParams.app).gotoView(assetId);
129
- };
130
- const createResource = ({
131
- searchParams,
132
- params
133
- }) => {
134
- const result = odeServices.resource(searchParams.app).create(params);
135
- return result;
136
- };
137
- const printResource = ({
138
- searchParams,
139
- assetId
140
- }) => {
141
- const result = odeServices.resource(searchParams.app).gotoPrint(assetId);
142
- return result;
143
- };
144
- function arrayUnique(array) {
145
- return array.filter((item, index) => array.indexOf(item) === index);
97
+ return await N.resource(e.app).moveToFolder(i, n);
98
+ }, $e = async ({
99
+ app: e,
100
+ resourceId: s,
101
+ rights: t
102
+ }) => await N.share().saveRights(e, s, t), je = async ({
103
+ app: e,
104
+ params: s
105
+ }) => await N.resource(e).update(s), ze = async (e) => await N.rights().sessionHasWorkflowRights(e), Ve = ({
106
+ searchParams: e,
107
+ assetId: s
108
+ }) => N.resource(e.app).gotoView(s), _e = ({
109
+ searchParams: e,
110
+ params: s
111
+ }) => N.resource(e.app).create(s), He = ({
112
+ searchParams: e,
113
+ assetId: s
114
+ }) => N.resource(e.app).gotoPrint(s);
115
+ function te(e) {
116
+ return e.filter((s, t) => e.indexOf(s) === t);
146
117
  }
147
- function findNodeById(id, data) {
148
- var _a, _b;
149
- let res;
150
- if ((data == null ? void 0 : data.id) === id) {
151
- return data;
152
- }
153
- if ((_a = data == null ? void 0 : data.children) == null ? void 0 : _a.length) {
154
- (_b = data == null ? void 0 : data.children) == null ? void 0 : _b.every((childNode) => {
155
- res = findNodeById(id, childNode);
156
- return res === void 0;
157
- });
158
- }
159
- return res;
118
+ function _(e, s) {
119
+ var r, n;
120
+ let t;
121
+ return (s == null ? void 0 : s.id) === e ? s : ((r = s == null ? void 0 : s.children) != null && r.length && ((n = s == null ? void 0 : s.children) == null || n.every((i) => (t = _(e, i), t === void 0))), t);
160
122
  }
161
- function getAncestors(folderId, treeData) {
162
- var _a;
163
- const findItem = findNodeById(folderId, treeData);
164
- if ((_a = findItem == null ? void 0 : findItem.folder) == null ? void 0 : _a.ancestors) {
165
- const nodes = (findItem == null ? void 0 : findItem.folder.ancestors) || [];
166
- return [...nodes, folderId];
167
- } else if (folderId === FOLDER.BIN) {
168
- return [FOLDER.BIN];
169
- } else {
170
- return [FOLDER.DEFAULT];
171
- }
123
+ function We(e, s) {
124
+ var r;
125
+ const t = _(e, s);
126
+ return (r = t == null ? void 0 : t.folder) != null && r.ancestors ? [...(t == null ? void 0 : t.folder.ancestors) || [], e] : e === F.BIN ? [F.BIN] : [F.DEFAULT];
172
127
  }
173
- function hasChildren(folderId, data) {
174
- if (data.id === folderId && data.children) {
175
- return data.children.length > 0;
176
- }
177
- if (data.children) {
178
- return data.children.some((child) => hasChildren(data.id, child));
179
- }
180
- return false;
128
+ function ie(e, s) {
129
+ return s.id === e && s.children ? s.children.length > 0 : s.children ? s.children.some((t) => ie(s.id, t)) : !1;
181
130
  }
182
- function modifyNode(data, callback) {
183
- const root = doModify(data, callback) || data;
184
- return root;
131
+ function H(e, s) {
132
+ return de(e, s) || e;
185
133
  }
186
- function doModify(current, callback, parent) {
187
- var _a;
188
- const result = callback(current, parent);
189
- if ((_a = result == null ? void 0 : result.children) == null ? void 0 : _a.length) {
190
- const children = [];
191
- for (const child of (result == null ? void 0 : result.children) || []) {
192
- const res = doModify(child, callback, result);
193
- if (res) {
194
- children.push(res);
195
- }
134
+ function de(e, s, t) {
135
+ var n;
136
+ const r = s(e, t);
137
+ if ((n = r == null ? void 0 : r.children) != null && n.length) {
138
+ const i = [];
139
+ for (const o of (r == null ? void 0 : r.children) || []) {
140
+ const d = de(o, s, r);
141
+ d && i.push(d);
196
142
  }
197
143
  return {
198
- ...result,
199
- children
144
+ ...r,
145
+ children: i
200
146
  };
201
147
  }
202
- return result;
148
+ return r;
203
149
  }
204
- class TreeNodeFolderWrapper {
205
- constructor(folder) {
206
- __publicField(this, "id");
207
- __publicField(this, "name");
208
- __publicField(this, "childNumber");
209
- __publicField(this, "section", false);
210
- __publicField(this, "children", []);
211
- this.folder = folder;
212
- this.id = folder.id;
213
- this.name = folder.name;
214
- this.childNumber = folder.childNumber;
150
+ class X {
151
+ constructor(s) {
152
+ $(this, "id");
153
+ $(this, "name");
154
+ $(this, "childNumber");
155
+ $(this, "section", !1);
156
+ $(this, "children", []);
157
+ this.folder = s, this.id = s.id, this.name = s.name, this.childNumber = s.childNumber;
215
158
  }
216
159
  }
217
- const wrapTreeNode = (treeNode, folders, parentId) => {
218
- return modifyNode(treeNode, (node) => {
219
- if (node.id === parentId) {
220
- node.children = folders == null ? void 0 : folders.map((e) => new TreeNodeFolderWrapper(e));
221
- }
222
- return node;
223
- });
224
- };
225
- const useStoreContext = create()((set, get) => ({
160
+ const ue = (e, s, t) => H(e, (r) => (r.id === t && (r.children = s == null ? void 0 : s.map((n) => new X(n))), r)), S = ve()((e, s) => ({
226
161
  config: null,
227
162
  searchConfig: {
228
163
  minLength: 1
@@ -244,12 +179,12 @@ const useStoreContext = create()((set, get) => ({
244
179
  pageSize: 48,
245
180
  maxIdx: 0
246
181
  },
247
- trashed: false
182
+ trashed: !1
248
183
  },
249
184
  treeData: {
250
- id: FOLDER.DEFAULT,
251
- name: t("explorer.filters.mine"),
252
- section: true,
185
+ id: F.DEFAULT,
186
+ name: D("explorer.filters.mine"),
187
+ section: !0,
253
188
  children: []
254
189
  },
255
190
  selectedNodesIds: ["default"],
@@ -260,1564 +195,1138 @@ const useStoreContext = create()((set, get) => ({
260
195
  selectedResources: [],
261
196
  folderIds: [],
262
197
  resourceIds: [],
263
- resourceIsTrash: false,
264
- resourceActionDisable: false,
198
+ resourceIsTrash: !1,
199
+ resourceActionDisable: !1,
265
200
  status: void 0,
266
201
  updaters: {
267
- setConfig: (config) => set({
268
- config
202
+ setConfig: (t) => e({
203
+ config: t
269
204
  }),
270
- setSearchConfig: (searchConfig) => set((state) => ({
205
+ setSearchConfig: (t) => e((r) => ({
271
206
  searchConfig: {
272
- ...state.searchConfig,
273
- ...searchConfig
207
+ ...r.searchConfig,
208
+ ...t
274
209
  }
275
210
  })),
276
- setTreeData: (treeData) => set(() => ({
277
- treeData
211
+ setTreeData: (t) => e(() => ({
212
+ treeData: t
278
213
  })),
279
- setSearchParams: (searchParams) => {
280
- set((state) => {
214
+ setSearchParams: (t) => {
215
+ e((r) => {
281
216
  const {
282
- searchParams: previousSearchParams
283
- } = state;
284
- if (previousSearchParams.search !== searchParams.search) {
285
- if (searchParams.search) {
286
- return {
287
- ...state,
288
- selectedFolders: [],
289
- selectedNodesIds: [],
290
- selectedResources: [],
291
- currentFolder: void 0,
292
- searchParams: {
293
- ...previousSearchParams,
294
- ...searchParams,
295
- trashed: false,
296
- filters: {
297
- ...previousSearchParams.filters,
298
- folder: void 0
299
- }
300
- }
301
- };
302
- } else {
303
- return {
304
- ...state,
305
- selectedFolders: [],
306
- selectedNodesIds: ["default"],
307
- selectedResources: [],
308
- currentFolder: {
309
- id: "default"
310
- },
311
- searchParams: {
312
- ...previousSearchParams,
313
- ...searchParams,
314
- trashed: false,
315
- filters: {
316
- ...previousSearchParams.filters
317
- }
318
- }
319
- };
217
+ searchParams: n
218
+ } = r;
219
+ return n.search !== t.search ? t.search ? {
220
+ ...r,
221
+ selectedFolders: [],
222
+ selectedNodesIds: [],
223
+ selectedResources: [],
224
+ currentFolder: void 0,
225
+ searchParams: {
226
+ ...n,
227
+ ...t,
228
+ trashed: !1,
229
+ filters: {
230
+ ...n.filters,
231
+ folder: void 0
232
+ }
320
233
  }
321
- } else {
322
- return {
323
- searchParams: {
324
- ...previousSearchParams,
325
- ...searchParams
234
+ } : {
235
+ ...r,
236
+ selectedFolders: [],
237
+ selectedNodesIds: ["default"],
238
+ selectedResources: [],
239
+ currentFolder: {
240
+ id: "default"
241
+ },
242
+ searchParams: {
243
+ ...n,
244
+ ...t,
245
+ trashed: !1,
246
+ filters: {
247
+ ...n.filters
326
248
  }
327
- };
328
- }
249
+ }
250
+ } : {
251
+ searchParams: {
252
+ ...n,
253
+ ...t
254
+ }
255
+ };
329
256
  });
330
257
  },
331
- setSelectedFolders: (selectedFolders) => set(() => ({
332
- selectedFolders
258
+ setSelectedFolders: (t) => e(() => ({
259
+ selectedFolders: t
333
260
  })),
334
- setSelectedResources: (selectedResources) => set(() => ({
335
- selectedResources
261
+ setSelectedResources: (t) => e(() => ({
262
+ selectedResources: t
336
263
  })),
337
- setFolderIds: (folderIds) => set(() => ({
338
- folderIds
264
+ setFolderIds: (t) => e(() => ({
265
+ folderIds: t
339
266
  })),
340
- setResourceIds: (resourceIds) => set(() => ({
341
- resourceIds
267
+ setResourceIds: (t) => e(() => ({
268
+ resourceIds: t
342
269
  })),
343
- setResourceIsTrash: (resourceIsTrash) => set(() => ({
344
- resourceIsTrash
270
+ setResourceIsTrash: (t) => e(() => ({
271
+ resourceIsTrash: t
345
272
  })),
346
- setResourceActionDisable: (resourceActionDisable) => set(() => ({
347
- resourceActionDisable
273
+ setResourceActionDisable: (t) => e(() => ({
274
+ resourceActionDisable: t
348
275
  })),
349
- setCurrentFolder: (currentFolder) => set(() => ({
350
- currentFolder
276
+ setCurrentFolder: (t) => e(() => ({
277
+ currentFolder: t
351
278
  })),
352
- clearSelectedItems: () => set(() => ({
279
+ clearSelectedItems: () => e(() => ({
353
280
  selectedFolders: [],
354
281
  selectedResources: []
355
282
  })),
356
- clearSelectedIds: () => set(() => ({
283
+ clearSelectedIds: () => e(() => ({
357
284
  resourceIds: [],
358
285
  folderIds: []
359
286
  })),
360
- openResource: (resource) => {
287
+ openResource: (t) => {
361
288
  try {
362
289
  const {
363
- searchParams
364
- } = get();
365
- goToResource({
366
- searchParams,
367
- assetId: resource.assetId
290
+ searchParams: r
291
+ } = s();
292
+ Ve({
293
+ searchParams: r,
294
+ assetId: t.assetId
368
295
  });
369
- } catch (error) {
370
- console.error("explorer open failed: ", error);
296
+ } catch (r) {
297
+ console.error("explorer open failed: ", r);
371
298
  }
372
299
  },
373
300
  printSelectedResource: () => {
374
301
  try {
375
302
  const {
376
- searchParams,
377
- selectedResources,
378
- resourceIds
379
- } = get();
380
- if (selectedResources.length !== 1) {
303
+ searchParams: t,
304
+ selectedResources: r,
305
+ resourceIds: n
306
+ } = s();
307
+ if (r.length !== 1)
381
308
  throw new Error("Cannot open more than 1 resource");
382
- }
383
- const item = selectedResources.find((resource) => resource.id === resourceIds[0]);
384
- printResource({
385
- searchParams,
386
- assetId: item.assetId
309
+ const i = r.find((o) => o.id === n[0]);
310
+ He({
311
+ searchParams: t,
312
+ assetId: i.assetId
387
313
  });
388
- } catch (error) {
389
- console.error("explorer print failed: ", error);
314
+ } catch (t) {
315
+ console.error("explorer print failed: ", t);
390
316
  }
391
317
  },
392
318
  openFolder: ({
393
- folderId,
394
- folder
319
+ folderId: t,
320
+ folder: r
395
321
  }) => {
396
322
  const {
397
- searchParams,
398
- treeData
399
- } = get();
400
- const previousId = searchParams.filters.folder;
401
- const ancestors = getAncestors(folderId, treeData);
402
- const selectedNodesIds = arrayUnique([...ancestors, folderId]);
403
- if (previousId === folderId)
404
- return;
405
- set((state) => {
406
- return {
407
- ...state,
408
- // reset selection when changing folder
409
- folderIds: [],
410
- resourceIds: [],
411
- selectedNodesIds,
412
- currentFolder: folder || {
413
- id: folderId
323
+ searchParams: n,
324
+ treeData: i
325
+ } = s(), o = n.filters.folder, d = We(t, i), u = te([...d, t]);
326
+ o !== t && e((h) => ({
327
+ ...h,
328
+ // reset selection when changing folder
329
+ folderIds: [],
330
+ resourceIds: [],
331
+ selectedNodesIds: u,
332
+ currentFolder: r || {
333
+ id: t
334
+ },
335
+ searchParams: {
336
+ ...n,
337
+ search: void 0,
338
+ filters: {
339
+ ...n.filters,
340
+ folder: t
414
341
  },
415
- searchParams: {
416
- ...searchParams,
417
- search: void 0,
418
- filters: {
419
- ...searchParams.filters,
420
- folder: folderId
421
- },
422
- trashed: folderId === FOLDER.BIN
423
- }
424
- };
425
- });
342
+ trashed: t === F.BIN
343
+ }
344
+ }));
426
345
  },
427
- foldTreeItem: () => set((state) => ({
428
- ...state,
346
+ foldTreeItem: () => e((t) => ({
347
+ ...t,
429
348
  status: "fold"
430
349
  })),
431
- unfoldTreeItem: async (folderId, queryClient) => {
350
+ unfoldTreeItem: async (t, r) => {
432
351
  const {
433
- treeData,
434
- searchParams
435
- } = get();
436
- set((state) => ({
437
- ...state,
352
+ treeData: n,
353
+ searchParams: i
354
+ } = s();
355
+ if (e((o) => ({
356
+ ...o,
438
357
  status: "unfold"
439
- }));
440
- if (!hasChildren(folderId, treeData)) {
441
- await queryClient.prefetchInfiniteQuery({
358
+ })), !ie(t, n)) {
359
+ await r.prefetchInfiniteQuery({
442
360
  queryKey: ["prefetchContext", {
443
- folderId,
444
- trashed: false
361
+ folderId: t,
362
+ trashed: !1
445
363
  }],
446
- queryFn: async () => await searchContext({
447
- ...searchParams,
364
+ queryFn: async () => await le({
365
+ ...i,
448
366
  filters: {
449
- ...searchParams.filters,
450
- folder: folderId
367
+ ...i.filters,
368
+ folder: t
451
369
  }
452
370
  })
453
371
  });
454
- const data = queryClient.getQueryData(["prefetchContext", {
455
- folderId,
456
- trashed: false
372
+ const o = r.getQueryData(["prefetchContext", {
373
+ folderId: t,
374
+ trashed: !1
457
375
  }]);
458
- set((state) => {
459
- var _a;
376
+ e((d) => {
377
+ var u;
460
378
  return {
461
- ...state,
462
- treeData: wrapTreeNode(treeData, (_a = data == null ? void 0 : data.pages[0]) == null ? void 0 : _a.folders, folderId || FOLDER.DEFAULT)
379
+ ...d,
380
+ treeData: ue(n, (u = o == null ? void 0 : o.pages[0]) == null ? void 0 : u.folders, t || F.DEFAULT)
463
381
  };
464
382
  });
465
383
  }
466
384
  },
467
- selectTreeItem: (folderId) => {
468
- const {
469
- treeData
470
- } = get();
385
+ selectTreeItem: (t) => {
471
386
  const {
472
- openFolder
473
- } = get().updaters;
474
- const folder = findNodeById(folderId, treeData);
475
- const goToTop = useScrollToTop();
476
- goToTop();
477
- set((state) => ({
478
- ...state,
387
+ treeData: r
388
+ } = s(), {
389
+ openFolder: n
390
+ } = s().updaters, i = _(t, r);
391
+ ge()(), e((d) => ({
392
+ ...d,
479
393
  searchParams: {
480
- ...state.searchParams,
394
+ ...d.searchParams,
481
395
  search: void 0
482
396
  },
483
397
  status: "select",
484
398
  selectedResources: []
485
- }));
486
- openFolder({
487
- folder,
488
- folderId
399
+ })), n({
400
+ folder: i,
401
+ folderId: t
489
402
  });
490
403
  },
491
404
  gotoPreviousFolder: () => {
492
405
  const {
493
- selectedNodesIds,
494
- treeData
495
- } = get();
496
- const {
497
- openFolder
498
- } = get().updaters;
499
- const selectedNodesIdsLength = selectedNodesIds.length;
500
- if (selectedNodesIdsLength < 2) {
501
- return void 0;
502
- }
503
- const previousFolder = findNodeById(selectedNodesIds[selectedNodesIdsLength - 2], treeData);
504
- openFolder({
505
- folder: previousFolder,
506
- folderId: (previousFolder == null ? void 0 : previousFolder.id) || FOLDER.DEFAULT
406
+ selectedNodesIds: t,
407
+ treeData: r
408
+ } = s(), {
409
+ openFolder: n
410
+ } = s().updaters, i = t.length;
411
+ if (i < 2)
412
+ return;
413
+ const o = _(t[i - 2], r);
414
+ n({
415
+ folder: o,
416
+ folderId: (o == null ? void 0 : o.id) || F.DEFAULT
507
417
  });
508
418
  },
509
- goToTrash: () => set((state) => ({
510
- ...state,
419
+ goToTrash: () => e((t) => ({
420
+ ...t,
511
421
  selectedNodesIds: [],
512
422
  selectedResources: [],
513
423
  resourceIds: [],
514
424
  folderIds: [],
515
425
  status: "select",
516
426
  searchParams: {
517
- ...state.searchParams,
427
+ ...t.searchParams,
518
428
  search: void 0,
519
429
  filters: {
520
- folder: FOLDER.BIN
430
+ folder: F.BIN
521
431
  },
522
- trashed: true
432
+ trashed: !0
523
433
  },
524
434
  currentFolder: {
525
- id: FOLDER.BIN
435
+ id: F.BIN
526
436
  }
527
437
  }))
528
438
  }
529
- }));
530
- const useSearchParams = () => useStoreContext((state) => state.searchParams);
531
- const useSelectedNodesIds = () => useStoreContext((state) => state.selectedNodesIds);
532
- const useTreeData = () => useStoreContext((state) => state.treeData);
533
- const useSelectedFolders = () => useStoreContext((state) => state.selectedFolders);
534
- const useSelectedResources = () => useStoreContext((state) => state.selectedResources);
535
- const useSearchConfig = () => useStoreContext((state) => state.searchConfig);
536
- const useFolderIds = () => useStoreContext((state) => state.folderIds);
537
- const useResourceIds = () => useStoreContext((state) => state.resourceIds);
538
- const useResourceAssetIds = () => useStoreContext((state) => state.selectedResources.map((r) => r.assetId));
539
- const useResourceWithoutIds = () => useStoreContext((state) => state.selectedResources.filter((r) => r.assetId === r.id));
540
- const useCurrentFolder = () => useStoreContext((state) => state.currentFolder);
541
- const useStoreActions = () => useStoreContext((state) => state.updaters);
542
- const useIsTrash = () => {
543
- const currentFolder = useCurrentFolder();
544
- return (currentFolder == null ? void 0 : currentFolder.id) === FOLDER.BIN;
545
- };
546
- const useResourceIsTrash = () => {
547
- return useStoreContext((state) => state.resourceIsTrash);
548
- };
549
- const useResourceActionDisable = () => {
550
- return useStoreContext((state) => state.resourceActionDisable);
551
- };
552
- const useIsRoot = () => {
553
- const currentFolder = useCurrentFolder();
554
- return (currentFolder == null ? void 0 : currentFolder.id) === "default";
555
- };
556
- const useHasSelectedNodes = () => {
557
- const selectedNodesIds = useSelectedNodesIds();
558
- return selectedNodesIds.length > 1;
559
- };
560
- const useTreeStatus = () => useStoreContext((state) => state.status);
561
- const useSearchForm = () => {
562
- const searchParams = useSearchParams();
563
- const [inputSearch, setInputSearch] = useState("");
564
- const searchConfig = useSearchConfig();
565
- const status = useTreeStatus();
566
- const formRef = useRef(null);
567
- const {
568
- setSearchParams
569
- } = useStoreActions();
570
- const handleInputSearchChange = (event) => {
571
- const newText = event.target.value;
572
- setInputSearch(newText.toString());
573
- };
574
- const handleKeyPress = (event) => {
575
- if (event.key === "Enter" || event.key === "Return") {
576
- event.preventDefault();
577
- setSearchParams({
578
- search: inputSearch ? inputSearch : void 0
579
- });
580
- }
581
- };
582
- const handleSearchSubmit = (e) => {
583
- e.preventDefault();
584
- setSearchParams({
585
- search: inputSearch ? inputSearch : void 0
439
+ })), T = () => S((e) => e.searchParams), re = () => S((e) => e.selectedNodesIds), V = () => S((e) => e.treeData), Ms = () => S((e) => e.selectedFolders), Bs = () => S((e) => e.selectedResources), Xe = () => S((e) => e.searchConfig), G = () => S((e) => e.folderIds), Z = () => S((e) => e.resourceIds), J = () => S((e) => e.selectedResources.map((s) => s.assetId)), Y = () => S((e) => e.selectedResources.filter((s) => s.assetId === s.id)), W = () => S((e) => e.currentFolder), x = () => S((e) => e.updaters), ne = () => {
440
+ const e = W();
441
+ return (e == null ? void 0 : e.id) === F.BIN;
442
+ }, Ge = () => S((e) => e.resourceIsTrash), Ze = () => S((e) => e.resourceActionDisable), Je = () => {
443
+ const e = W();
444
+ return (e == null ? void 0 : e.id) === "default";
445
+ }, Ye = () => re().length > 1, es = () => S((e) => e.status), he = () => {
446
+ const e = T(), [s, t] = ce(""), r = Xe(), n = es(), i = me(null), {
447
+ setSearchParams: o
448
+ } = x(), d = (c) => {
449
+ const f = c.target.value;
450
+ t(f.toString());
451
+ }, u = (c) => {
452
+ (c.key === "Enter" || c.key === "Return") && (c.preventDefault(), o({
453
+ search: s || void 0
454
+ }));
455
+ }, h = (c) => {
456
+ c.preventDefault(), o({
457
+ search: s || void 0
586
458
  });
587
459
  };
588
- useEffect(() => {
589
- const shouldUpdateSearch = inputSearch.length == 0 || inputSearch.length >= searchConfig.minLength;
590
- const searchPartial = shouldUpdateSearch ? {
591
- search: inputSearch ? inputSearch : void 0
460
+ return U(() => {
461
+ const f = s.length == 0 || s.length >= r.minLength ? {
462
+ search: s || void 0
592
463
  } : {};
593
- setSearchParams({
594
- ...searchParams,
595
- ...searchPartial
464
+ o({
465
+ ...e,
466
+ ...f
596
467
  });
597
- }, [inputSearch, searchConfig.minLength]);
598
- useEffect(() => {
599
- if (status === "select")
600
- setInputSearch("");
601
- }, [status]);
602
- useEffect(() => {
603
- setInputSearch(() => {
604
- var _a;
605
- return ((_a = searchParams.search) == null ? void 0 : _a.toString()) ?? "";
468
+ }, [s, r.minLength]), U(() => {
469
+ n === "select" && t("");
470
+ }, [n]), U(() => {
471
+ t(() => {
472
+ var c;
473
+ return ((c = e.search) == null ? void 0 : c.toString()) ?? "";
606
474
  });
607
- }, [searchParams]);
608
- return {
609
- formRef,
610
- inputSearch,
611
- handleInputSearchChange,
612
- handleKeyPress,
613
- handleSearchSubmit
475
+ }, [e]), {
476
+ formRef: i,
477
+ inputSearch: s,
478
+ handleInputSearchChange: d,
479
+ handleKeyPress: u,
480
+ handleSearchSubmit: h
614
481
  };
615
482
  };
616
- function ExplorerBreadcrumb() {
483
+ function ss() {
617
484
  const {
618
- appCode
619
- } = useOdeClient();
620
- const {
621
- gotoPreviousFolder
622
- } = useStoreActions();
623
- const {
624
- t: t2
625
- } = useTranslation();
626
- const {
627
- inputSearch
628
- } = useSearchForm();
629
- const selectedNodesIds = useSelectedNodesIds();
630
- const isTrashFolder = useIsTrash();
631
- const currentFolder = useCurrentFolder();
632
- const trashName = t2("explorer.tree.trash");
633
- const searchName = t2("explorer.tree.search");
634
- const rootName = t2("explorer.filters.mine", {
635
- ns: appCode
636
- });
637
- const previousName = (currentFolder == null ? void 0 : currentFolder.name) || rootName;
638
- return /* @__PURE__ */ jsx("div", { className: "py-16", children: selectedNodesIds.length > 1 && !isTrashFolder ? /* @__PURE__ */ jsxs("div", { className: "d-flex align-items-center gap-8", children: [
639
- /* @__PURE__ */ jsx(IconButton, { icon: /* @__PURE__ */ jsx(ArrowLeft, {}), variant: "ghost", color: "tertiary", "aria-label": t2("back"), className: "ms-n16", onClick: gotoPreviousFolder }),
640
- /* @__PURE__ */ jsx("p", { className: "body py-8 text-truncate", children: /* @__PURE__ */ jsx("strong", { children: previousName }) })
641
- ] }) : /* @__PURE__ */ jsx("h2", { className: "body py-8 fw-bold", children: inputSearch.length !== 0 ? searchName : !isTrashFolder ? rootName : trashName }) });
485
+ appCode: e
486
+ } = M(), {
487
+ gotoPreviousFolder: s
488
+ } = x(), {
489
+ t
490
+ } = z(), {
491
+ inputSearch: r
492
+ } = he(), n = re(), i = ne(), o = W(), d = t("explorer.tree.trash"), u = t("explorer.tree.search"), h = t("explorer.filters.mine", {
493
+ ns: e
494
+ }), c = (o == null ? void 0 : o.name) || h;
495
+ return /* @__PURE__ */ l("div", { className: "py-16", children: n.length > 1 && !i ? /* @__PURE__ */ C("div", { className: "d-flex align-items-center gap-8", children: [
496
+ /* @__PURE__ */ l(Ie, { icon: /* @__PURE__ */ l(Pe, {}), variant: "ghost", color: "tertiary", "aria-label": t("back"), className: "ms-n16", onClick: s }),
497
+ /* @__PURE__ */ l("p", { className: "body py-8 text-truncate", children: /* @__PURE__ */ l("strong", { children: c }) })
498
+ ] }) : /* @__PURE__ */ l("h2", { className: "body py-8 fw-bold", children: r.length !== 0 ? u : i ? d : h }) });
642
499
  }
643
- const useDisableModal = () => {
644
- const isActionDisableModalOpen = useResourceActionDisable();
645
- const {
646
- clearSelectedIds,
647
- setResourceActionDisable,
648
- clearSelectedItems
649
- } = useStoreActions();
650
- const onActionDisableCancel = () => {
651
- clearSelectedIds();
652
- clearSelectedItems();
653
- setResourceActionDisable(false);
654
- };
500
+ const ts = () => {
501
+ const e = Ze(), {
502
+ clearSelectedIds: s,
503
+ setResourceActionDisable: t,
504
+ clearSelectedItems: r
505
+ } = x();
655
506
  return {
656
- isActionDisableModalOpen,
657
- onActionDisableCancel
658
- };
659
- };
660
- const useTrashModal = () => {
661
- const isTrashedModalOpen = useResourceIsTrash();
662
- const {
663
- clearSelectedIds,
664
- setResourceIsTrash,
665
- clearSelectedItems
666
- } = useStoreActions();
667
- const onTrashedCancel = () => {
668
- clearSelectedIds();
669
- clearSelectedItems();
670
- setResourceIsTrash(false);
507
+ isActionDisableModalOpen: e,
508
+ onActionDisableCancel: () => {
509
+ s(), r(), t(!1);
510
+ }
671
511
  };
512
+ }, rs = () => {
513
+ const e = Ge(), {
514
+ clearSelectedIds: s,
515
+ setResourceIsTrash: t,
516
+ clearSelectedItems: r
517
+ } = x();
672
518
  return {
673
- isTrashedModalOpen,
674
- onTrashedCancel
519
+ isTrashedModalOpen: e,
520
+ onTrashedCancel: () => {
521
+ s(), r(), t(!1);
522
+ }
675
523
  };
676
524
  };
677
- function addNode(treeData, {
678
- parentId,
679
- newFolder
525
+ function ns(e, {
526
+ parentId: s,
527
+ newFolder: t
680
528
  }) {
681
- return modifyNode(treeData, (node) => {
682
- var _a;
683
- if (node.id === parentId) {
684
- const parentAncestors = [...((_a = node.folder) == null ? void 0 : _a.ancestors) || []];
685
- const ancestors = arrayUnique([...parentAncestors, node.id]);
686
- const newNode = {
687
- ...node,
688
- children: [...node.children || [], new TreeNodeFolderWrapper({
689
- ...newFolder,
690
- ancestors
529
+ return H(e, (r) => {
530
+ var n;
531
+ if (r.id === s) {
532
+ const i = [...((n = r.folder) == null ? void 0 : n.ancestors) || []], o = te([...i, r.id]);
533
+ return {
534
+ ...r,
535
+ children: [...r.children || [], new X({
536
+ ...t,
537
+ ancestors: o
691
538
  })]
692
539
  };
693
- return newNode;
694
- } else {
695
- return node;
696
- }
540
+ } else
541
+ return r;
697
542
  });
698
543
  }
699
- function deleteNode(treeData, {
700
- folders
544
+ function os(e, {
545
+ folders: s
701
546
  }) {
702
- return modifyNode(treeData, (node) => {
703
- if (folders.includes(node.id)) {
704
- return void 0;
705
- } else {
706
- return node;
707
- }
547
+ return H(e, (t) => {
548
+ if (!s.includes(t.id))
549
+ return t;
708
550
  });
709
551
  }
710
- function moveNode(treeData, {
711
- destinationId,
712
- folders
552
+ function as(e, {
553
+ destinationId: s,
554
+ folders: t
713
555
  }) {
714
- return modifyNode(treeData, (node, parent) => {
715
- var _a, _b;
716
- if (destinationId === node.id) {
717
- const parentAncestors = [...((_a = node.folder) == null ? void 0 : _a.ancestors) || []];
718
- const ancestors = arrayUnique([...parentAncestors, node.id]);
719
- const newChildren = [...node.children || []];
720
- const childrenIds = ((_b = node.children) == null ? void 0 : _b.map((child) => child.id)) || [];
721
- for (const folder of folders) {
722
- if (!childrenIds.includes(folder)) {
723
- const item = findNodeById(folder, treeData);
724
- item && newChildren.push({
725
- ...item,
556
+ return H(e, (r, n) => {
557
+ var i, o;
558
+ if (s === r.id) {
559
+ const d = [...((i = r.folder) == null ? void 0 : i.ancestors) || []], u = te([...d, r.id]), h = [...r.children || []], c = ((o = r.children) == null ? void 0 : o.map((a) => a.id)) || [];
560
+ for (const a of t)
561
+ if (!c.includes(a)) {
562
+ const m = _(a, e);
563
+ m && h.push({
564
+ ...m,
726
565
  folder: {
727
- ...item == null ? void 0 : item.folder,
728
- ancestors
566
+ ...m == null ? void 0 : m.folder,
567
+ ancestors: u
729
568
  }
730
569
  });
731
570
  }
732
- }
733
- const newNode = {
734
- ...node,
735
- children: newChildren
571
+ return {
572
+ ...r,
573
+ children: h
736
574
  };
737
- return newNode;
738
- } else if (folders.includes(node.id) && destinationId !== (parent == null ? void 0 : parent.id)) {
739
- return void 0;
740
- } else {
741
- return node;
742
- }
575
+ } else
576
+ return t.includes(r.id) && s !== (n == null ? void 0 : n.id) ? void 0 : r;
743
577
  });
744
578
  }
745
- function updateNode(treeData, {
746
- folderId,
747
- newFolder
579
+ function cs(e, {
580
+ folderId: s,
581
+ newFolder: t
748
582
  }) {
749
- return modifyNode(treeData, (node) => {
750
- if (node.id === folderId) {
751
- return new TreeNodeFolderWrapper(newFolder);
752
- } else {
753
- return node;
754
- }
755
- });
583
+ return H(e, (r) => r.id === s ? new X(t) : r);
756
584
  }
757
- const useActions = () => {
758
- const config = useStoreContext((state) => state.config);
759
- return useQuery({
585
+ const ls = () => {
586
+ const e = S((s) => s.config);
587
+ return qe({
760
588
  queryKey: ["actions"],
761
589
  queryFn: async () => {
762
- const actionRights = config.actions.map((action) => action.workflow);
763
- const availableRights = await sessionHasWorkflowRights(actionRights);
764
- return availableRights;
590
+ const s = e == null ? void 0 : e.actions.map((r) => r.workflow);
591
+ return await ze(s);
765
592
  },
766
- select: (data) => {
767
- return config.actions.map((action) => ({
768
- ...action,
769
- available: data[action.workflow]
770
- }));
771
- },
772
- staleTime: Infinity,
773
- enabled: !!config
593
+ select: (s) => e == null ? void 0 : e.actions.map((t) => ({
594
+ ...t,
595
+ available: s[t.workflow]
596
+ })),
597
+ staleTime: 1 / 0,
598
+ enabled: !!e
774
599
  });
775
- };
776
- const useSearchContext = () => {
777
- const config = useStoreContext((state) => state.config);
778
- const searchParams = useSearchParams();
779
- const {
780
- filters,
781
- trashed,
782
- search
783
- } = searchParams;
784
- const queryKey = ["context", {
785
- folderId: filters.folder,
786
- filters,
787
- trashed,
788
- search
600
+ }, is = () => {
601
+ const e = S((o) => o.config), s = T(), {
602
+ filters: t,
603
+ trashed: r,
604
+ search: n
605
+ } = s, i = ["context", {
606
+ folderId: t.folder,
607
+ filters: t,
608
+ trashed: r,
609
+ search: n
789
610
  }];
790
- return useInfiniteQuery({
791
- queryKey,
611
+ return Oe({
612
+ queryKey: i,
792
613
  queryFn: async ({
793
- pageParam
794
- }) => {
795
- return await searchContext({
796
- ...searchParams,
797
- app: config == null ? void 0 : config.app,
798
- types: config == null ? void 0 : config.types,
799
- pagination: {
800
- ...searchParams.pagination,
801
- startIdx: pageParam
802
- }
803
- });
804
- },
614
+ pageParam: o
615
+ }) => await le({
616
+ ...s,
617
+ app: e == null ? void 0 : e.app,
618
+ types: e == null ? void 0 : e.types,
619
+ pagination: {
620
+ ...s.pagination,
621
+ startIdx: o
622
+ }
623
+ }),
805
624
  initialPageParam: 0,
806
- enabled: !!config,
807
- retry: false,
808
- getNextPageParam: (lastPage) => {
809
- return lastPage.pagination.startIdx + lastPage.pagination.pageSize;
810
- }
625
+ enabled: !!e,
626
+ retry: !1,
627
+ getNextPageParam: (o) => o.pagination.startIdx + o.pagination.pageSize
811
628
  });
812
- };
813
- const useTrash = () => {
814
- const toast = useToast();
815
- const queryClient = useQueryClient();
816
- const searchParams = useSearchParams();
817
- const treeData = useTreeData();
818
- const folderIds = useFolderIds();
819
- const assetIds = useResourceAssetIds();
820
- const resourceRealIds = useResourceIds();
821
- const useAssetIds = useResourceWithoutIds().length > 0;
822
- const resourceIds = useAssetIds ? assetIds : resourceRealIds;
823
- const {
824
- clearSelectedItems,
825
- clearSelectedIds,
826
- setTreeData,
827
- setSearchParams
828
- } = useStoreActions();
829
- const {
830
- filters,
831
- trashed
832
- } = searchParams;
833
- const queryKey = ["context", {
834
- folderId: filters.folder,
835
- filters,
836
- trashed
629
+ }, Ks = () => {
630
+ const e = q(), s = O(), t = T(), r = V(), n = G(), i = J(), o = Z(), d = Y().length > 0, u = d ? i : o, {
631
+ clearSelectedItems: h,
632
+ clearSelectedIds: c,
633
+ setTreeData: f,
634
+ setSearchParams: a
635
+ } = x(), {
636
+ filters: m,
637
+ trashed: p
638
+ } = t, g = ["context", {
639
+ folderId: m.folder,
640
+ filters: m,
641
+ trashed: p
837
642
  }];
838
- return useMutation({
839
- mutationFn: async () => await trashAll({
840
- searchParams,
841
- folderIds,
842
- resourceIds,
843
- useAssetIds
643
+ return L({
644
+ mutationFn: async () => await Ue({
645
+ searchParams: t,
646
+ folderIds: n,
647
+ resourceIds: u,
648
+ useAssetIds: d
844
649
  }),
845
- onError(error) {
846
- if (typeof error === "string")
847
- toast.error(t(error));
650
+ onError(y) {
651
+ typeof y == "string" && e.error(D(y));
848
652
  },
849
- onSuccess: async (data) => {
850
- await queryClient.cancelQueries({
851
- queryKey
852
- });
853
- const previousData = queryClient.getQueryData(queryKey);
854
- if (previousData) {
855
- toast.success(t("explorer.trash.title"));
856
- return queryClient.setQueryData(queryKey, (prev) => {
857
- var _a;
858
- if (prev) {
859
- const newData = {
860
- ...prev,
861
- pages: prev == null ? void 0 : prev.pages.map((page) => {
862
- var _a2;
653
+ onSuccess: async (y) => {
654
+ if (await s.cancelQueries({
655
+ queryKey: g
656
+ }), s.getQueryData(g))
657
+ return e.success(D("explorer.trash.title")), s.setQueryData(g, (w) => {
658
+ var E;
659
+ if (w) {
660
+ const k = {
661
+ ...w,
662
+ pages: w == null ? void 0 : w.pages.map((R) => {
663
+ var P;
863
664
  return {
864
- ...page,
865
- folders: page.folders.filter((folder) => !folderIds.includes(folder.id)),
665
+ ...R,
666
+ folders: R.folders.filter((Q) => !n.includes(Q.id)),
866
667
  pagination: {
867
- ...page.pagination,
668
+ ...R.pagination,
868
669
  // @ts-ignore
869
- maxIdx: ((_a2 = page == null ? void 0 : page.pagination) == null ? void 0 : _a2.maxIdx) - data.resources.length
670
+ maxIdx: ((P = R == null ? void 0 : R.pagination) == null ? void 0 : P.maxIdx) - y.resources.length
870
671
  },
871
- resources: page.resources.filter((resource) => {
872
- if (useAssetIds) {
873
- return !assetIds.includes(resource.assetId);
874
- } else {
875
- return !resourceIds.includes(resource.id);
876
- }
877
- })
672
+ resources: R.resources.filter((Q) => d ? !i.includes(Q.assetId) : !u.includes(Q.id))
878
673
  };
879
674
  })
880
- };
881
- const update = deleteNode(treeData, {
882
- folders: folderIds
675
+ }, B = os(r, {
676
+ folders: n
883
677
  });
884
- setTreeData(update);
885
- setSearchParams({
886
- ...searchParams,
678
+ return f(B), a({
679
+ ...t,
887
680
  pagination: {
888
- ...searchParams.pagination,
681
+ ...t.pagination,
889
682
  // @ts-ignore
890
- maxIdx: ((_a = searchParams.pagination) == null ? void 0 : _a.maxIdx) - data.resources.length
683
+ maxIdx: ((E = t.pagination) == null ? void 0 : E.maxIdx) - y.resources.length
891
684
  }
892
- });
893
- return newData;
685
+ }), k;
894
686
  }
895
- return void 0;
896
687
  });
897
- }
898
688
  },
899
689
  onSettled: () => {
900
- clearSelectedItems();
901
- clearSelectedIds();
690
+ h(), c();
902
691
  }
903
692
  });
904
- };
905
- const useRestore = () => {
906
- const toast = useToast();
907
- const queryClient = useQueryClient();
908
- const searchParams = useSearchParams();
909
- const folderIds = useFolderIds();
910
- const assetIds = useResourceAssetIds();
911
- const resourceRealIds = useResourceIds();
912
- const useAssetIds = useResourceWithoutIds().length > 0;
913
- const resourceIds = useAssetIds ? assetIds : resourceRealIds;
914
- const {
915
- setFolderIds,
916
- setResourceIds,
917
- setSelectedResources,
918
- setSelectedFolders
919
- } = useStoreActions();
920
- const {
921
- filters,
922
- trashed
923
- } = searchParams;
924
- const queryKey = ["context", {
925
- folderId: filters.folder,
926
- filters,
927
- trashed
693
+ }, $s = () => {
694
+ const e = q(), s = O(), t = T(), r = G(), n = J(), i = Z(), o = Y().length > 0, d = o ? n : i, {
695
+ setFolderIds: u,
696
+ setResourceIds: h,
697
+ setSelectedResources: c,
698
+ setSelectedFolders: f
699
+ } = x(), {
700
+ filters: a,
701
+ trashed: m
702
+ } = t, p = ["context", {
703
+ folderId: a.folder,
704
+ filters: a,
705
+ trashed: m
928
706
  }];
929
- return useMutation({
930
- mutationFn: async () => await restoreAll({
931
- searchParams,
932
- folderIds,
933
- resourceIds,
934
- useAssetIds
707
+ return L({
708
+ mutationFn: async () => await Be({
709
+ searchParams: t,
710
+ folderIds: r,
711
+ resourceIds: d,
712
+ useAssetIds: o
935
713
  }),
936
- onError(error) {
937
- if (typeof error === "string")
938
- toast.error(t(error));
714
+ onError(g) {
715
+ typeof g == "string" && e.error(D(g));
939
716
  },
940
717
  onSuccess: async () => {
941
- await queryClient.cancelQueries({
942
- queryKey
943
- });
944
- const previousData = queryClient.getQueryData(queryKey);
945
- if (previousData) {
946
- toast.success(t("explorer.trash.toast"));
947
- return queryClient.setQueryData(queryKey, (prev) => {
948
- if (prev) {
718
+ if (await s.cancelQueries({
719
+ queryKey: p
720
+ }), s.getQueryData(p))
721
+ return e.success(D("explorer.trash.toast")), s.setQueryData(p, (y) => {
722
+ if (y)
949
723
  return {
950
- ...prev,
951
- pages: prev == null ? void 0 : prev.pages.map((page) => {
952
- return {
953
- ...page,
954
- folders: page.folders.filter((folder) => !folderIds.includes(folder.id)),
955
- resources: page.resources.filter((resource) => {
956
- if (useAssetIds) {
957
- return !assetIds.includes(resource.assetId);
958
- } else {
959
- return !resourceIds.includes(resource.id);
960
- }
961
- })
962
- };
963
- })
724
+ ...y,
725
+ pages: y == null ? void 0 : y.pages.map((I) => ({
726
+ ...I,
727
+ folders: I.folders.filter((w) => !r.includes(w.id)),
728
+ resources: I.resources.filter((w) => o ? !n.includes(w.assetId) : !d.includes(w.id))
729
+ }))
964
730
  };
965
- }
966
- return void 0;
967
731
  });
968
- }
969
732
  },
970
733
  onSettled: () => {
971
- setResourceIds([]);
972
- setSelectedResources([]);
973
- setFolderIds([]);
974
- setSelectedFolders([]);
734
+ h([]), c([]), u([]), f([]);
975
735
  }
976
736
  });
977
- };
978
- const useDelete = () => {
979
- const toast = useToast();
980
- const queryClient = useQueryClient();
981
- const searchParams = useSearchParams();
982
- const folderIds = useFolderIds();
983
- const assetIds = useResourceAssetIds();
984
- const resourceRealIds = useResourceIds();
985
- const useAssetIds = useResourceWithoutIds().length > 0;
986
- const resourceIds = useAssetIds ? assetIds : resourceRealIds;
987
- const {
988
- clearSelectedItems,
989
- clearSelectedIds
990
- } = useStoreActions();
991
- const {
992
- filters,
993
- trashed
994
- } = searchParams;
995
- const queryKey = ["context", {
996
- folderId: filters.folder,
997
- filters,
998
- trashed
737
+ }, js = () => {
738
+ const e = q(), s = O(), t = T(), r = G(), n = J(), i = Z(), o = Y().length > 0, d = o ? n : i, {
739
+ clearSelectedItems: u,
740
+ clearSelectedIds: h
741
+ } = x(), {
742
+ filters: c,
743
+ trashed: f
744
+ } = t, a = ["context", {
745
+ folderId: c.folder,
746
+ filters: c,
747
+ trashed: f
999
748
  }];
1000
- return useMutation({
1001
- mutationFn: async () => await deleteAll({
1002
- searchParams,
1003
- folderIds,
1004
- resourceIds,
1005
- useAssetIds
749
+ return L({
750
+ mutationFn: async () => await Me({
751
+ searchParams: t,
752
+ folderIds: r,
753
+ resourceIds: d,
754
+ useAssetIds: o
1006
755
  }),
1007
- onError(error) {
1008
- if (typeof error === "string")
1009
- toast.error(t(error));
756
+ onError(m) {
757
+ typeof m == "string" && e.error(D(m));
1010
758
  },
1011
759
  onSuccess: async () => {
1012
- await queryClient.cancelQueries({
1013
- queryKey
1014
- });
1015
- const previousData = queryClient.getQueryData(queryKey);
1016
- if (previousData) {
1017
- toast.success(t("explorer.removed.from.trash"));
1018
- return queryClient.setQueryData(queryKey, (prev) => {
1019
- if (prev) {
1020
- const newData = {
1021
- ...prev,
1022
- pages: prev == null ? void 0 : prev.pages.map((page) => {
1023
- return {
1024
- ...page,
1025
- folders: page.folders.filter((folder) => !folderIds.includes(folder.id)),
1026
- resources: page.resources.filter((resource) => {
1027
- if (useAssetIds) {
1028
- return !assetIds.includes(resource.assetId);
1029
- } else {
1030
- return !resourceIds.includes(resource.id);
1031
- }
1032
- })
1033
- };
1034
- })
760
+ if (await s.cancelQueries({
761
+ queryKey: a
762
+ }), s.getQueryData(a))
763
+ return e.success(D("explorer.removed.from.trash")), s.setQueryData(a, (p) => {
764
+ if (p)
765
+ return {
766
+ ...p,
767
+ pages: p == null ? void 0 : p.pages.map((y) => ({
768
+ ...y,
769
+ folders: y.folders.filter((I) => !r.includes(I.id)),
770
+ resources: y.resources.filter((I) => o ? !n.includes(I.assetId) : !d.includes(I.id))
771
+ }))
1035
772
  };
1036
- return newData;
1037
- }
1038
- return void 0;
1039
773
  });
1040
- }
1041
774
  },
1042
775
  onSettled: () => {
1043
- clearSelectedItems();
1044
- clearSelectedIds();
776
+ u(), h();
1045
777
  }
1046
778
  });
1047
- };
1048
- const useMoveItem = () => {
1049
- const toast = useToast();
1050
- const queryClient = useQueryClient();
1051
- const searchParams = useSearchParams();
1052
- const treeData = useTreeData();
1053
- const folderIds = useFolderIds();
1054
- const assetIds = useResourceAssetIds();
1055
- const resourceRealIds = useResourceIds();
1056
- const useAssetIds = useResourceWithoutIds().length > 0;
1057
- const resourceIds = useAssetIds ? assetIds : resourceRealIds;
1058
- const {
1059
- clearSelectedIds,
1060
- clearSelectedItems,
1061
- setTreeData,
1062
- setSearchParams
1063
- } = useStoreActions();
1064
- const {
1065
- filters,
1066
- trashed
1067
- } = searchParams;
1068
- const queryKey = ["context", {
1069
- folderId: filters.folder,
1070
- filters,
1071
- trashed
779
+ }, zs = () => {
780
+ const e = q(), s = O(), t = T(), r = V(), n = G(), i = J(), o = Z(), d = Y().length > 0, u = d ? i : o, {
781
+ clearSelectedIds: h,
782
+ clearSelectedItems: c,
783
+ setTreeData: f,
784
+ setSearchParams: a
785
+ } = x(), {
786
+ filters: m,
787
+ trashed: p
788
+ } = t, g = ["context", {
789
+ folderId: m.folder,
790
+ filters: m,
791
+ trashed: p
1072
792
  }];
1073
- return useMutation({
1074
- mutationFn: async (folderId) => await moveToFolder({
1075
- searchParams,
1076
- folderId,
1077
- folderIds,
1078
- resourceIds,
1079
- useAssetIds
793
+ return L({
794
+ mutationFn: async (y) => await Ke({
795
+ searchParams: t,
796
+ folderId: y,
797
+ folderIds: n,
798
+ resourceIds: u,
799
+ useAssetIds: d
1080
800
  }),
1081
- onError(error) {
1082
- if (typeof error === "string")
1083
- toast.error(t(error));
801
+ onError(y) {
802
+ typeof y == "string" && e.error(D(y));
1084
803
  },
1085
- onSuccess: async (data, variables) => {
1086
- const previousData = queryClient.getQueryData(queryKey);
1087
- if (previousData) {
1088
- return queryClient.setQueryData(queryKey, (prev) => {
1089
- var _a;
1090
- if (prev) {
1091
- const update = moveNode(treeData, {
1092
- destinationId: variables,
1093
- folders: folderIds
1094
- });
1095
- const newData = {
1096
- ...prev,
1097
- pages: prev == null ? void 0 : prev.pages.map((page) => {
1098
- var _a2;
804
+ onSuccess: async (y, I) => {
805
+ if (s.getQueryData(g))
806
+ return s.setQueryData(g, (E) => {
807
+ var k;
808
+ if (E) {
809
+ const B = as(r, {
810
+ destinationId: I,
811
+ folders: n
812
+ }), R = {
813
+ ...E,
814
+ pages: E == null ? void 0 : E.pages.map((P) => {
815
+ var Q;
1099
816
  return {
1100
- ...page,
1101
- folders: page.folders.filter((folder) => !folderIds.includes(folder.id)),
817
+ ...P,
818
+ folders: P.folders.filter((K) => !n.includes(K.id)),
1102
819
  pagination: {
1103
- ...page.pagination,
820
+ ...P.pagination,
1104
821
  // @ts-ignore
1105
- maxIdx: ((_a2 = page.pagination) == null ? void 0 : _a2.maxIdx) - data.resources.length
822
+ maxIdx: ((Q = P.pagination) == null ? void 0 : Q.maxIdx) - y.resources.length
1106
823
  },
1107
- resources: page.resources.filter((resource) => {
1108
- if (useAssetIds) {
1109
- return !assetIds.includes(resource.assetId);
1110
- } else {
1111
- return !resourceIds.includes(resource.id);
1112
- }
1113
- })
824
+ resources: P.resources.filter((K) => d ? !i.includes(K.assetId) : !u.includes(K.id))
1114
825
  };
1115
826
  })
1116
827
  };
1117
- setTreeData(update);
1118
- setSearchParams({
1119
- ...searchParams,
828
+ return f(B), a({
829
+ ...t,
1120
830
  pagination: {
1121
- ...searchParams.pagination,
831
+ ...t.pagination,
1122
832
  // @ts-ignore
1123
- maxIdx: ((_a = searchParams.pagination) == null ? void 0 : _a.maxIdx) - data.resources.length
833
+ maxIdx: ((k = t.pagination) == null ? void 0 : k.maxIdx) - y.resources.length
1124
834
  }
1125
- });
1126
- return newData;
835
+ }), R;
1127
836
  }
1128
- return void 0;
1129
837
  });
1130
- }
1131
838
  },
1132
839
  onSettled: () => {
1133
- clearSelectedItems();
1134
- clearSelectedIds();
840
+ c(), h();
1135
841
  }
1136
842
  });
1137
- };
1138
- const useCreateFolder = () => {
1139
- const toast = useToast();
1140
- const queryClient = useQueryClient();
1141
- const searchParams = useSearchParams();
1142
- const treeData = useTreeData();
1143
- const {
1144
- setTreeData
1145
- } = useStoreActions();
1146
- const {
1147
- filters,
1148
- trashed
1149
- } = searchParams;
1150
- const queryKey = ["context", {
1151
- folderId: filters.folder,
1152
- filters,
1153
- trashed
843
+ }, Vs = () => {
844
+ const e = q(), s = O(), t = T(), r = V(), {
845
+ setTreeData: n
846
+ } = x(), {
847
+ filters: i,
848
+ trashed: o
849
+ } = t, d = ["context", {
850
+ folderId: i.folder,
851
+ filters: i,
852
+ trashed: o
1154
853
  }];
1155
- return useMutation({
854
+ return L({
1156
855
  mutationFn: async ({
1157
- name,
1158
- parentId
1159
- }) => await createFolder({
1160
- searchParams,
1161
- name,
1162
- parentId
856
+ name: u,
857
+ parentId: h
858
+ }) => await Le({
859
+ searchParams: t,
860
+ name: u,
861
+ parentId: h
1163
862
  }),
1164
- onError(error) {
1165
- if (typeof error === "string")
1166
- toast.error(t(error));
863
+ onError(u) {
864
+ typeof u == "string" && e.error(D(u));
1167
865
  },
1168
- onSuccess: async (data, variables) => {
1169
- await queryClient.cancelQueries({
1170
- queryKey
866
+ onSuccess: async (u, h) => {
867
+ await s.cancelQueries({
868
+ queryKey: d
1171
869
  });
1172
- const previousData = queryClient.getQueryData(queryKey);
1173
- const newFolder = {
1174
- ...data,
1175
- parentId: variables.parentId,
870
+ const c = s.getQueryData(d), f = {
871
+ ...u,
872
+ parentId: h.parentId,
1176
873
  children: [],
1177
- rights: [`creator:${data == null ? void 0 : data.creator_id}`]
874
+ rights: [`creator:${u == null ? void 0 : u.creator_id}`]
1178
875
  };
1179
- if (previousData) {
1180
- return queryClient.setQueryData(queryKey, (prev) => {
1181
- if (prev) {
1182
- const newData = {
1183
- ...prev,
1184
- pages: prev == null ? void 0 : prev.pages.map((page) => {
1185
- return {
1186
- ...page,
1187
- folders: [...page.folders, newFolder]
1188
- };
1189
- })
1190
- };
1191
- const update = addNode(treeData, {
1192
- parentId: variables.parentId,
1193
- newFolder
876
+ if (c)
877
+ return s.setQueryData(d, (a) => {
878
+ if (a) {
879
+ const m = {
880
+ ...a,
881
+ pages: a == null ? void 0 : a.pages.map((g) => ({
882
+ ...g,
883
+ folders: [...g.folders, f]
884
+ }))
885
+ }, p = ns(r, {
886
+ parentId: h.parentId,
887
+ newFolder: f
1194
888
  });
1195
- setTreeData(update);
1196
- return newData;
889
+ return n(p), m;
1197
890
  }
1198
- return void 0;
1199
891
  });
1200
- }
1201
892
  }
1202
893
  });
1203
- };
1204
- const useUpdatefolder = () => {
1205
- const toast = useToast();
1206
- const queryClient = useQueryClient();
1207
- const searchParams = useSearchParams();
1208
- const treeData = useTreeData();
1209
- const {
1210
- setFolderIds,
1211
- setSelectedFolders,
1212
- setTreeData
1213
- } = useStoreActions();
1214
- const {
1215
- filters,
1216
- trashed
1217
- } = searchParams;
1218
- const queryKey = ["context", {
1219
- folderId: filters.folder,
1220
- filters,
1221
- trashed
894
+ }, _s = () => {
895
+ const e = q(), s = O(), t = T(), r = V(), {
896
+ setFolderIds: n,
897
+ setSelectedFolders: i,
898
+ setTreeData: o
899
+ } = x(), {
900
+ filters: d,
901
+ trashed: u
902
+ } = t, h = ["context", {
903
+ folderId: d.folder,
904
+ filters: d,
905
+ trashed: u
1222
906
  }];
1223
- return useMutation({
907
+ return L({
1224
908
  mutationFn: async ({
1225
- folderId,
1226
- name,
1227
- parentId
1228
- }) => await updateFolder({
1229
- searchParams,
1230
- folderId,
1231
- parentId,
1232
- name
909
+ folderId: c,
910
+ name: f,
911
+ parentId: a
912
+ }) => await ke({
913
+ searchParams: t,
914
+ folderId: c,
915
+ parentId: a,
916
+ name: f
1233
917
  }),
1234
- onError(error) {
1235
- if (typeof error === "string")
1236
- toast.error(t(error));
918
+ onError(c) {
919
+ typeof c == "string" && e.error(D(c));
1237
920
  },
1238
- onSuccess: async (data, variables) => {
1239
- await queryClient.cancelQueries({
1240
- queryKey
1241
- });
1242
- const previousData = queryClient.getQueryData(queryKey);
1243
- if (previousData) {
1244
- return queryClient.setQueryData(queryKey, (prev) => {
1245
- if (prev) {
1246
- const newData = {
1247
- ...prev,
1248
- pages: prev == null ? void 0 : prev.pages.map((page) => {
1249
- return {
1250
- ...page,
1251
- folders: page.folders.map((folder) => {
1252
- if (folder.id === data.id) {
1253
- return {
1254
- ...data,
1255
- parentId: variables.parentId,
1256
- rights: folder.rights
1257
- };
1258
- } else {
1259
- return folder;
1260
- }
1261
- })
1262
- };
1263
- })
1264
- };
1265
- const update = updateNode(treeData, {
1266
- folderId: variables.folderId,
1267
- newFolder: data
921
+ onSuccess: async (c, f) => {
922
+ if (await s.cancelQueries({
923
+ queryKey: h
924
+ }), s.getQueryData(h))
925
+ return s.setQueryData(h, (m) => {
926
+ if (m) {
927
+ const p = {
928
+ ...m,
929
+ pages: m == null ? void 0 : m.pages.map((y) => ({
930
+ ...y,
931
+ folders: y.folders.map((I) => I.id === c.id ? {
932
+ ...c,
933
+ parentId: f.parentId,
934
+ rights: I.rights
935
+ } : I)
936
+ }))
937
+ }, g = cs(r, {
938
+ folderId: f.folderId,
939
+ newFolder: c
1268
940
  });
1269
- setTreeData(update);
1270
- return newData;
941
+ return o(g), p;
1271
942
  }
1272
- return void 0;
1273
943
  });
1274
- }
1275
944
  },
1276
945
  onSettled: () => {
1277
- setFolderIds([]);
1278
- setSelectedFolders([]);
946
+ n([]), i([]);
1279
947
  }
1280
948
  });
1281
- };
1282
- const useShareResource = () => {
1283
- const toast = useToast();
1284
- const queryClient = useQueryClient();
1285
- const searchParams = useSearchParams();
1286
- const {
1287
- setResourceIds,
1288
- setSelectedResources
1289
- } = useStoreActions();
1290
- const {
1291
- filters,
1292
- trashed,
1293
- app
1294
- } = searchParams;
1295
- const queryKey = ["context", {
1296
- folderId: filters.folder,
1297
- filters,
1298
- trashed
949
+ }, Hs = () => {
950
+ const e = q(), s = O(), t = T(), {
951
+ setResourceIds: r,
952
+ setSelectedResources: n
953
+ } = x(), {
954
+ filters: i,
955
+ trashed: o,
956
+ app: d
957
+ } = t, u = ["context", {
958
+ folderId: i.folder,
959
+ filters: i,
960
+ trashed: o
1299
961
  }];
1300
- return useMutation({
962
+ return L({
1301
963
  mutationFn: async ({
1302
- resourceId,
1303
- rights
1304
- }) => await shareResource({
1305
- app,
1306
- resourceId,
1307
- rights
964
+ resourceId: h,
965
+ rights: c
966
+ }) => await $e({
967
+ app: d,
968
+ resourceId: h,
969
+ rights: c
1308
970
  }),
1309
- onError(error) {
1310
- if (typeof error === "string")
1311
- toast.error(t("explorer.shared.status.error"));
971
+ onError(h) {
972
+ typeof h == "string" && e.error(D("explorer.shared.status.error"));
1312
973
  },
1313
- onSuccess: async (_data, variables) => {
1314
- await queryClient.cancelQueries({
1315
- queryKey
1316
- });
1317
- const previousData = queryClient.getQueryData(queryKey);
1318
- if (previousData) {
1319
- toast.success(t("explorer.shared.status.saved"));
1320
- return queryClient.setQueryData(queryKey, (prev) => {
1321
- if (prev) {
974
+ onSuccess: async (h, c) => {
975
+ if (await s.cancelQueries({
976
+ queryKey: u
977
+ }), s.getQueryData(u))
978
+ return e.success(D("explorer.shared.status.saved")), s.setQueryData(u, (a) => {
979
+ if (a)
1322
980
  return {
1323
- ...prev,
1324
- pages: prev == null ? void 0 : prev.pages.map((page) => {
1325
- return {
1326
- ...page,
1327
- resources: page.resources.map((resource) => {
1328
- if (resource.assetId === (variables == null ? void 0 : variables.resourceId)) {
1329
- let rights = [`creator:${resource.creatorId}`];
1330
- if ((variables == null ? void 0 : variables.rights.length) >= 1) {
1331
- rights = [...rights, ...variables.rights.flatMap((right) => {
1332
- return right.actions.map((action) => {
1333
- return `${right.type}:${right.id}:${action.id}`;
1334
- });
1335
- })];
1336
- }
1337
- return {
1338
- ...resource,
1339
- rights
1340
- };
1341
- } else {
1342
- return resource;
1343
- }
1344
- })
1345
- };
1346
- })
981
+ ...a,
982
+ pages: a == null ? void 0 : a.pages.map((m) => ({
983
+ ...m,
984
+ resources: m.resources.map((p) => {
985
+ if (p.assetId === (c == null ? void 0 : c.resourceId)) {
986
+ let g = [`creator:${p.creatorId}`];
987
+ return (c == null ? void 0 : c.rights.length) >= 1 && (g = [...g, ...c.rights.flatMap((y) => y.actions.map((I) => `${y.type}:${y.id}:${I.id}`))]), {
988
+ ...p,
989
+ rights: g
990
+ };
991
+ } else
992
+ return p;
993
+ })
994
+ }))
1347
995
  };
1348
- }
1349
- return void 0;
1350
996
  });
1351
- }
1352
997
  },
1353
998
  onSettled: () => {
1354
- setResourceIds([]);
1355
- setSelectedResources([]);
999
+ r([]), n([]);
1356
1000
  }
1357
1001
  });
1358
- };
1359
- const useUpdateResource = () => {
1360
- const toast = useToast();
1361
- const queryClient = useQueryClient();
1362
- const searchParams = useSearchParams();
1363
- const {
1364
- filters,
1365
- trashed,
1366
- app
1367
- } = searchParams;
1368
- const queryKey = ["context", {
1369
- folderId: filters.folder,
1370
- filters,
1371
- trashed
1002
+ }, Ws = () => {
1003
+ const e = q(), s = O(), t = T(), {
1004
+ filters: r,
1005
+ trashed: n,
1006
+ app: i
1007
+ } = t, o = ["context", {
1008
+ folderId: r.folder,
1009
+ filters: r,
1010
+ trashed: n
1372
1011
  }];
1373
- return useMutation({
1374
- mutationFn: async (params) => await updateResource({
1375
- app,
1376
- params
1012
+ return L({
1013
+ mutationFn: async (d) => await je({
1014
+ app: i,
1015
+ params: d
1377
1016
  }),
1378
- onError(error) {
1379
- if (typeof error === "string")
1380
- toast.error(t(error));
1017
+ onError(d) {
1018
+ typeof d == "string" && e.error(D(d));
1381
1019
  },
1382
- onSuccess: async (_data, variables) => {
1383
- await queryClient.cancelQueries({
1384
- queryKey
1385
- });
1386
- const previousData = queryClient.getQueryData(queryKey);
1387
- if (previousData) {
1388
- return queryClient.setQueryData(queryKey, (prev) => {
1389
- if (prev) {
1020
+ onSuccess: async (d, u) => {
1021
+ if (await s.cancelQueries({
1022
+ queryKey: o
1023
+ }), s.getQueryData(o))
1024
+ return s.setQueryData(o, (c) => {
1025
+ if (c)
1390
1026
  return {
1391
- ...prev,
1392
- pages: prev == null ? void 0 : prev.pages.map((page) => {
1393
- return {
1394
- ...page,
1395
- resources: page.resources.map((resource) => {
1396
- if (resource.assetId === (variables == null ? void 0 : variables.entId)) {
1397
- const {
1398
- name,
1399
- thumbnail,
1400
- public: pub,
1401
- description,
1402
- slug,
1403
- ...others
1404
- } = variables;
1405
- return {
1406
- ...resource,
1407
- ...others,
1408
- // add any custom field
1409
- name,
1410
- thumbnail: typeof thumbnail === "string" ? thumbnail : URL.createObjectURL(thumbnail),
1411
- public: pub,
1412
- description,
1413
- slug
1414
- };
1415
- } else {
1416
- return resource;
1417
- }
1418
- })
1419
- };
1420
- })
1027
+ ...c,
1028
+ pages: c == null ? void 0 : c.pages.map((f) => ({
1029
+ ...f,
1030
+ resources: f.resources.map((a) => {
1031
+ if (a.assetId === (u == null ? void 0 : u.entId)) {
1032
+ const {
1033
+ name: m,
1034
+ thumbnail: p,
1035
+ public: g,
1036
+ description: y,
1037
+ slug: I,
1038
+ ...w
1039
+ } = u;
1040
+ return {
1041
+ ...a,
1042
+ ...w,
1043
+ // add any custom field
1044
+ name: m,
1045
+ thumbnail: typeof p == "string" ? p : URL.createObjectURL(p),
1046
+ public: g,
1047
+ description: y,
1048
+ slug: I
1049
+ };
1050
+ } else
1051
+ return a;
1052
+ })
1053
+ }))
1421
1054
  };
1422
- }
1423
- return void 0;
1424
1055
  });
1425
- }
1426
1056
  }
1427
1057
  });
1428
- };
1429
- const useCreateResource = () => {
1430
- const toast = useToast();
1431
- const queryClient = useQueryClient();
1432
- const searchParams = useSearchParams();
1433
- const {
1434
- user
1435
- } = useUser();
1436
- const {
1437
- appCode: application
1438
- } = useOdeClient();
1439
- const queryKey = ["context", {
1440
- folderId: searchParams.filters.folder,
1441
- filters: searchParams.filters,
1442
- trashed: searchParams.trashed
1058
+ }, Xs = () => {
1059
+ const e = q(), s = O(), t = T(), {
1060
+ user: r
1061
+ } = Se(), {
1062
+ appCode: n
1063
+ } = M(), i = ["context", {
1064
+ folderId: t.filters.folder,
1065
+ filters: t.filters,
1066
+ trashed: t.trashed
1443
1067
  }];
1444
- return useMutation({
1445
- mutationFn: async (params) => await createResource({
1446
- searchParams,
1447
- params
1068
+ return L({
1069
+ mutationFn: async (o) => await _e({
1070
+ searchParams: t,
1071
+ params: o
1448
1072
  }),
1449
- onError(error) {
1450
- if (typeof error === "string")
1451
- toast.error(t(error));
1073
+ onError(o) {
1074
+ typeof o == "string" && e.error(D(o));
1452
1075
  },
1453
- onSuccess: async (data, variables) => {
1454
- var _a, _b, _c;
1455
- await queryClient.cancelQueries({
1456
- queryKey
1076
+ onSuccess: async (o, d) => {
1077
+ var f, a, m;
1078
+ await s.cancelQueries({
1079
+ queryKey: i
1457
1080
  });
1458
- const previousData = queryClient.getQueryData(queryKey);
1459
- const {
1460
- thumbnail
1461
- } = variables;
1462
- const newResource = {
1463
- ...variables,
1464
- thumbnail: thumbnail ? URL.createObjectURL(thumbnail) : "",
1465
- application,
1466
- assetId: data._id || data.entId || "",
1467
- id: data._id || data.entId || "",
1468
- creatorId: user == null ? void 0 : user.userId,
1469
- creatorName: user == null ? void 0 : user.username,
1081
+ const u = s.getQueryData(i), {
1082
+ thumbnail: h
1083
+ } = d, c = {
1084
+ ...d,
1085
+ thumbnail: h ? URL.createObjectURL(h) : "",
1086
+ application: n,
1087
+ assetId: o._id || o.entId || "",
1088
+ id: o._id || o.entId || "",
1089
+ creatorId: r == null ? void 0 : r.userId,
1090
+ creatorName: r == null ? void 0 : r.username,
1470
1091
  createdAt: Date.now(),
1471
- slug: variables.slug || "",
1472
- modifiedAt: ((_a = data.modified) == null ? void 0 : _a.$date) || "",
1473
- modifierId: ((_b = data.author) == null ? void 0 : _b.userId) || "",
1474
- modifierName: ((_c = data.author) == null ? void 0 : _c.username) || "",
1092
+ slug: d.slug || "",
1093
+ modifiedAt: ((f = o.modified) == null ? void 0 : f.$date) || "",
1094
+ modifierId: ((a = o.author) == null ? void 0 : a.userId) || "",
1095
+ modifierName: ((m = o.author) == null ? void 0 : m.username) || "",
1475
1096
  updatedAt: Date.now(),
1476
- trashed: false,
1477
- rights: [`creator:${user == null ? void 0 : user.userId}`]
1097
+ trashed: !1,
1098
+ rights: [`creator:${r == null ? void 0 : r.userId}`]
1478
1099
  };
1479
- if (previousData) {
1480
- return queryClient.setQueryData(queryKey, (prev) => {
1481
- if (prev) {
1100
+ if (u)
1101
+ return s.setQueryData(i, (p) => {
1102
+ if (p)
1482
1103
  return {
1483
- ...prev,
1484
- pages: prev == null ? void 0 : prev.pages.map((page) => {
1485
- return {
1486
- ...page,
1487
- resources: [newResource, ...page.resources]
1488
- };
1489
- })
1104
+ ...p,
1105
+ pages: p == null ? void 0 : p.pages.map((g) => ({
1106
+ ...g,
1107
+ resources: [c, ...g.resources]
1108
+ }))
1490
1109
  };
1491
- }
1492
- return void 0;
1493
1110
  });
1494
- }
1495
1111
  }
1496
1112
  });
1497
- };
1498
- const EmptyScreenApp = /* @__PURE__ */ lazy(async () => await import("./EmptyScreenApp.js"));
1499
- const EmptyScreenSearch = /* @__PURE__ */ lazy(async () => await import("./EmptyScreenSearch.js"));
1500
- const EmptyScreenError = /* @__PURE__ */ lazy(async () => await import("./EmptyScreenError.js"));
1501
- const EmptyScreenNoContentInFolder = /* @__PURE__ */ lazy(async () => await import("./EmptyScreenNoContentInFolder.js"));
1502
- const EmptyScreenTrash = /* @__PURE__ */ lazy(async () => await import("./EmptyScreenTrash.js"));
1503
- const FoldersList = /* @__PURE__ */ lazy(async () => await import("./FoldersList.js"));
1504
- const ResourcesList = /* @__PURE__ */ lazy(async () => await import("./ResourcesList.js"));
1505
- const List = () => {
1506
- const isRoot = useIsRoot();
1507
- const isTrashFolder = useIsTrash();
1508
- const hasSelectedNodes = useHasSelectedNodes();
1509
- const searchParams = useSearchParams();
1510
- const currentFolder = useCurrentFolder();
1511
- const treeData = useTreeData();
1512
- const toast = useToast();
1513
- const {
1514
- appCode
1515
- } = useOdeClient();
1516
- const {
1517
- t: t2
1518
- } = useTranslation();
1519
- const {
1520
- setSearchParams,
1521
- setSearchConfig,
1522
- setTreeData
1523
- } = useStoreActions();
1524
- const {
1525
- data,
1526
- isError,
1527
- error,
1528
- isLoading,
1529
- isFetching,
1530
- fetchNextPage
1531
- } = useSearchContext();
1532
- const hasNoFolders = (data == null ? void 0 : data.pages[0].folders.length) === 0;
1533
- const hasNoResources = (data == null ? void 0 : data.pages[0].resources.length) === 0;
1534
- const hasNoData = hasNoFolders && hasNoResources;
1535
- useEffect(() => {
1536
- var _a, _b, _c;
1537
- if (data) {
1538
- const folders = [...((_a = data == null ? void 0 : data.pages[0]) == null ? void 0 : _a.folders) ?? []];
1539
- if ((_b = data == null ? void 0 : data.pages[0]) == null ? void 0 : _b.searchConfig) {
1540
- setSearchConfig(data.pages[0].searchConfig);
1541
- }
1542
- if (!searchParams.search) {
1543
- if ((currentFolder == null ? void 0 : currentFolder.id) === "default") {
1544
- setTreeData({
1545
- id: FOLDER.DEFAULT,
1546
- section: true,
1547
- children: folders.map((folder) => new TreeNodeFolderWrapper(folder)),
1548
- name: t2("explorer.filters.mine", {
1549
- ns: appCode
1550
- })
1551
- });
1552
- } else {
1553
- setTreeData(wrapTreeNode(treeData, folders, searchParams.filters.folder || FOLDER.DEFAULT));
1554
- }
1555
- }
1556
- setSearchParams({
1557
- ...searchParams,
1558
- pagination: (_c = data == null ? void 0 : data.pages[(data == null ? void 0 : data.pages.length) - 1]) == null ? void 0 : _c.pagination
1113
+ }, ds = /* @__PURE__ */ b(async () => await import("./EmptyScreenApp.js")), us = /* @__PURE__ */ b(async () => await import("./EmptyScreenSearch.js")), hs = /* @__PURE__ */ b(async () => await import("./EmptyScreenError.js")), fs = /* @__PURE__ */ b(async () => await import("./EmptyScreenNoContentInFolder.js")), ps = /* @__PURE__ */ b(async () => await import("./EmptyScreenTrash.js")), ms = /* @__PURE__ */ b(async () => await import("./FoldersList.js")), ys = /* @__PURE__ */ b(async () => await import("./ResourcesList.js")), gs = () => {
1114
+ const e = Je(), s = ne(), t = Ye(), r = T(), n = W(), i = V(), o = q(), {
1115
+ appCode: d
1116
+ } = M(), {
1117
+ t: u
1118
+ } = z(), {
1119
+ setSearchParams: h,
1120
+ setSearchConfig: c,
1121
+ setTreeData: f
1122
+ } = x(), {
1123
+ data: a,
1124
+ isError: m,
1125
+ error: p,
1126
+ isLoading: g,
1127
+ isFetching: y,
1128
+ fetchNextPage: I
1129
+ } = is(), w = (a == null ? void 0 : a.pages[0].folders.length) === 0, E = (a == null ? void 0 : a.pages[0].resources.length) === 0, k = w && E;
1130
+ return U(() => {
1131
+ var B, R, P;
1132
+ if (a) {
1133
+ const Q = [...((B = a == null ? void 0 : a.pages[0]) == null ? void 0 : B.folders) ?? []];
1134
+ (R = a == null ? void 0 : a.pages[0]) != null && R.searchConfig && c(a.pages[0].searchConfig), r.search || ((n == null ? void 0 : n.id) === "default" ? f({
1135
+ id: F.DEFAULT,
1136
+ section: !0,
1137
+ children: Q.map((K) => new X(K)),
1138
+ name: u("explorer.filters.mine", {
1139
+ ns: d
1140
+ })
1141
+ }) : f(ue(i, Q, r.filters.folder || F.DEFAULT))), h({
1142
+ ...r,
1143
+ pagination: (P = a == null ? void 0 : a.pages[(a == null ? void 0 : a.pages.length) - 1]) == null ? void 0 : P.pagination
1559
1144
  });
1560
1145
  }
1561
- }, [data]);
1562
- useEffect(() => {
1563
- if (error && typeof error === "string") {
1564
- toast.error(t2(error));
1565
- }
1566
- }, [error]);
1567
- if (isLoading)
1568
- return /* @__PURE__ */ jsx(LoadingScreen, {});
1569
- if (isError) {
1570
- return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingScreen, {}), children: /* @__PURE__ */ jsx(EmptyScreenError, {}) });
1571
- }
1572
- if (searchParams.search && hasNoData) {
1573
- return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingScreen, {}), children: /* @__PURE__ */ jsx(EmptyScreenSearch, {}) });
1574
- }
1575
- if (isRoot && hasNoData) {
1576
- return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingScreen, {}), children: /* @__PURE__ */ jsx(EmptyScreenApp, {}) });
1577
- }
1578
- if (hasSelectedNodes && hasNoData && !isTrashFolder) {
1579
- return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingScreen, {}), children: /* @__PURE__ */ jsx(EmptyScreenNoContentInFolder, {}) });
1580
- }
1581
- if (isTrashFolder && (data == null ? void 0 : data.pages[0].resources.length) === 0) {
1582
- return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingScreen, {}), children: /* @__PURE__ */ jsx(EmptyScreenTrash, {}) });
1583
- }
1584
- return /* @__PURE__ */ jsxs(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingScreen, {}), children: [
1585
- /* @__PURE__ */ jsx(FoldersList, { data, isFetching }),
1586
- /* @__PURE__ */ jsx(ResourcesList, { data, isFetching, fetchNextPage })
1146
+ }, [a]), U(() => {
1147
+ p && typeof p == "string" && o.error(u(p));
1148
+ }, [p]), g ? /* @__PURE__ */ l(A, {}) : m ? /* @__PURE__ */ l(v, { fallback: /* @__PURE__ */ l(A, {}), children: /* @__PURE__ */ l(hs, {}) }) : r.search && k ? /* @__PURE__ */ l(v, { fallback: /* @__PURE__ */ l(A, {}), children: /* @__PURE__ */ l(us, {}) }) : e && k ? /* @__PURE__ */ l(v, { fallback: /* @__PURE__ */ l(A, {}), children: /* @__PURE__ */ l(ds, {}) }) : t && k && !s ? /* @__PURE__ */ l(v, { fallback: /* @__PURE__ */ l(A, {}), children: /* @__PURE__ */ l(fs, {}) }) : s && (a == null ? void 0 : a.pages[0].resources.length) === 0 ? /* @__PURE__ */ l(v, { fallback: /* @__PURE__ */ l(A, {}), children: /* @__PURE__ */ l(ps, {}) }) : /* @__PURE__ */ C(v, { fallback: /* @__PURE__ */ l(A, {}), children: [
1149
+ /* @__PURE__ */ l(ms, { data: a, isFetching: y }),
1150
+ /* @__PURE__ */ l(ys, { data: a, isFetching: y, fetchNextPage: I })
1587
1151
  ] });
1588
- };
1589
- const useSelectedFilters = () => {
1152
+ }, Is = () => {
1590
1153
  const {
1591
- appCode,
1592
- currentApp
1593
- } = useOdeClient();
1594
- const {
1595
- t: t2
1596
- } = useTranslation();
1597
- const [selectedFilters, setSelectedFilters] = useState("");
1598
- const handleOnSelectFilter = (value) => {
1599
- if (value === "0") {
1600
- setSelectedFilters("");
1154
+ appCode: e,
1155
+ currentApp: s
1156
+ } = M(), {
1157
+ t
1158
+ } = z(), [r, n] = ce(""), i = (c) => {
1159
+ if (c === "0") {
1160
+ n("");
1601
1161
  return;
1602
1162
  }
1603
- setSelectedFilters(value);
1604
- };
1605
- const currentFolder = useCurrentFolder();
1606
- const searchParams = useSearchParams();
1607
- const {
1608
- setSearchParams
1609
- } = useStoreActions();
1610
- useEffect(() => {
1611
- const isOwnerSelected = () => {
1612
- return selectedFilters.includes("1") ? true : void 0;
1613
- };
1614
- const isSharedSelected = () => {
1615
- return selectedFilters.includes("2") ? true : void 0;
1616
- };
1617
- const isPublicSelected = () => {
1618
- return selectedFilters.includes("7") ? true : void 0;
1619
- };
1620
- setSearchParams({
1621
- ...searchParams,
1163
+ n(c);
1164
+ }, o = W(), d = T(), {
1165
+ setSearchParams: u
1166
+ } = x();
1167
+ U(() => {
1168
+ const c = () => r.includes("1") ? !0 : void 0, f = () => r.includes("2") ? !0 : void 0, a = () => r.includes("7") ? !0 : void 0;
1169
+ u({
1170
+ ...d,
1622
1171
  filters: {
1623
- owner: isOwnerSelected(),
1624
- public: isPublicSelected(),
1625
- shared: isSharedSelected(),
1626
- folder: currentFolder ? currentFolder.id : "default"
1172
+ owner: c(),
1173
+ public: a(),
1174
+ shared: f(),
1175
+ folder: o ? o.id : "default"
1627
1176
  }
1628
1177
  });
1629
- }, [currentFolder, setSearchParams, selectedFilters]);
1630
- const options = [{
1631
- label: t2("explorer.filter.all", {
1632
- ns: appCode
1178
+ }, [o, u, r]);
1179
+ const h = [{
1180
+ label: t("explorer.filter.all", {
1181
+ ns: e
1633
1182
  }),
1634
1183
  value: "0"
1635
1184
  }, {
1636
- label: t2("explorer.filter.owner", {
1637
- ns: appCode
1185
+ label: t("explorer.filter.owner", {
1186
+ ns: e
1638
1187
  }),
1639
1188
  value: "1"
1640
1189
  }, {
1641
- label: t2("explorer.filter.shared", {
1642
- ns: appCode
1190
+ label: t("explorer.filter.shared", {
1191
+ ns: e
1643
1192
  }),
1644
1193
  value: "2"
1645
- }, ...(currentApp == null ? void 0 : currentApp.displayName) == APP.EXERCIZER ? [{
1194
+ }, ...(s == null ? void 0 : s.displayName) == se.EXERCIZER ? [{
1646
1195
  label: "Exercices interactifs",
1647
1196
  value: "3"
1648
- }] : [], ...(currentApp == null ? void 0 : currentApp.displayName) == APP.EXERCIZER ? [{
1197
+ }] : [], ...(s == null ? void 0 : s.displayName) == se.EXERCIZER ? [{
1649
1198
  label: "Exercices à rendre",
1650
1199
  value: "4"
1651
- }] : [], ...(currentApp == null ? void 0 : currentApp.displayName) == "pages" ? [{
1200
+ }] : [], ...(s == null ? void 0 : s.displayName) == "pages" ? [{
1652
1201
  label: "Projets publics",
1653
1202
  value: "5"
1654
- }] : [], ...(currentApp == null ? void 0 : currentApp.displayName) == "pages" ? [{
1203
+ }] : [], ...(s == null ? void 0 : s.displayName) == "pages" ? [{
1655
1204
  label: "Projets internes",
1656
1205
  value: "6"
1657
- }] : [], ...(currentApp == null ? void 0 : currentApp.displayName) == APP.BLOG ? [{
1658
- label: t2("explorer.filter.public", {
1659
- ns: appCode
1206
+ }] : [], ...(s == null ? void 0 : s.displayName) == se.BLOG ? [{
1207
+ label: t("explorer.filter.public", {
1208
+ ns: e
1660
1209
  }),
1661
1210
  value: "7"
1662
1211
  }] : []];
1663
1212
  return {
1664
- selectedFilters,
1665
- options,
1666
- handleOnSelectFilter
1213
+ selectedFilters: r,
1214
+ options: h,
1215
+ handleOnSelectFilter: i
1667
1216
  };
1668
- };
1669
- const SearchForm = () => {
1670
- const {
1671
- appCode
1672
- } = useOdeClient();
1673
- const {
1674
- t: t2
1675
- } = useTranslation();
1676
- const {
1677
- selectedFilters,
1678
- options,
1679
- handleOnSelectFilter
1680
- } = useSelectedFilters();
1217
+ }, Ss = () => {
1681
1218
  const {
1682
- formRef,
1683
- inputSearch,
1684
- handleInputSearchChange,
1685
- handleKeyPress,
1686
- handleSearchSubmit
1687
- } = useSearchForm();
1688
- const count = selectedFilters.length > 0 ? selectedFilters.length : void 0;
1689
- return /* @__PURE__ */ jsxs("form", { noValidate: true, className: "bg-light p-16 ps-24 ms-n16 ms-lg-n24 me-n16 position-relative z-3 d-flex gap-8", ref: formRef, children: [
1690
- /* @__PURE__ */ jsxs(FormControl, { id: "search", className: "input-group", children: [
1691
- /* @__PURE__ */ jsx(Input, { type: "search", placeholder: t2("explorer.label.search", {
1692
- ns: appCode
1693
- }), size: "lg", noValidationIcon: true, value: inputSearch, onChange: handleInputSearchChange, onKeyDown: handleKeyPress }),
1694
- /* @__PURE__ */ jsx(SearchButton, { type: "submit", "aria-label": t2("explorer.label.search", {
1695
- ns: appCode
1696
- }), onClick: handleSearchSubmit })
1219
+ appCode: e
1220
+ } = M(), {
1221
+ t: s
1222
+ } = z(), {
1223
+ selectedFilters: t,
1224
+ options: r,
1225
+ handleOnSelectFilter: n
1226
+ } = Is(), {
1227
+ formRef: i,
1228
+ inputSearch: o,
1229
+ handleInputSearchChange: d,
1230
+ handleKeyPress: u,
1231
+ handleSearchSubmit: h
1232
+ } = he(), c = t.length > 0 ? t.length : void 0;
1233
+ return /* @__PURE__ */ C("form", { noValidate: !0, className: "bg-light p-16 ps-24 ms-n16 ms-lg-n24 me-n16 position-relative z-3 d-flex gap-8", ref: i, children: [
1234
+ /* @__PURE__ */ C(we, { id: "search", className: "input-group", children: [
1235
+ /* @__PURE__ */ l(xe, { type: "search", placeholder: s("explorer.label.search", {
1236
+ ns: e
1237
+ }), size: "lg", noValidationIcon: !0, value: o, onChange: d, onKeyDown: u }),
1238
+ /* @__PURE__ */ l(De, { type: "submit", "aria-label": s("explorer.label.search", {
1239
+ ns: e
1240
+ }), onClick: h })
1697
1241
  ] }),
1698
- /* @__PURE__ */ jsxs(Dropdown, { placement: "bottom-end", children: [
1699
- /* @__PURE__ */ jsx(Dropdown.Trigger, { label: t2("explorer.filters"), icon: /* @__PURE__ */ jsx(Filter, { width: 20 }), variant: "ghost", badgeContent: count }),
1700
- /* @__PURE__ */ jsx(Dropdown.Menu, { children: options.map((option) => {
1701
- if (option.value === "0") {
1702
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1703
- /* @__PURE__ */ jsx(Dropdown.RadioItem, { value: option.value, model: selectedFilters, onChange: () => handleOnSelectFilter(option.value), children: option.label }),
1704
- /* @__PURE__ */ jsx(Dropdown.Separator, {})
1705
- ] }, "0");
1706
- }
1707
- return /* @__PURE__ */ jsx(Dropdown.RadioItem, { value: option.value, model: selectedFilters, onChange: () => handleOnSelectFilter(option.value), children: option.label }, option.value);
1708
- }) })
1242
+ /* @__PURE__ */ C(j, { placement: "bottom-end", children: [
1243
+ /* @__PURE__ */ l(j.Trigger, { label: s("explorer.filters"), icon: /* @__PURE__ */ l(Ae, { width: 20 }), variant: "ghost", badgeContent: c }),
1244
+ /* @__PURE__ */ l(j.Menu, { children: r.map((f) => f.value === "0" ? /* @__PURE__ */ C(ye, { children: [
1245
+ /* @__PURE__ */ l(j.RadioItem, { value: f.value, model: t, onChange: () => n(f.value), children: f.label }),
1246
+ /* @__PURE__ */ l(j.Separator, {})
1247
+ ] }, "0") : /* @__PURE__ */ l(j.RadioItem, { value: f.value, model: t, onChange: () => n(f.value), children: f.label }, f.value)) })
1709
1248
  ] })
1710
1249
  ] });
1711
- };
1712
- const TrashButton = ({
1713
- id,
1714
- selected,
1715
- onSelect
1250
+ }, ws = ({
1251
+ id: e,
1252
+ selected: s,
1253
+ onSelect: t
1716
1254
  }) => {
1717
1255
  const {
1718
- t: t2
1719
- } = useTranslation();
1720
- return /* @__PURE__ */ jsx("div", { className: "treeview", children: /* @__PURE__ */ jsx("ul", { role: "tree", className: "m-0 p-0", children: /* @__PURE__ */ jsx("li", { id, role: "treeitem", "aria-selected": selected, children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("div", { className: "action-container", children: /* @__PURE__ */ jsx("div", { onClick: onSelect, role: "button", tabIndex: 0, children: /* @__PURE__ */ jsxs("div", { className: "d-flex align-items-center gap-8 py-8 ps-24", children: [
1721
- /* @__PURE__ */ jsx(Delete, { width: "20", height: "20" }),
1722
- /* @__PURE__ */ jsx("span", { children: t2("explorer.tree.trash") })
1256
+ t: r
1257
+ } = z();
1258
+ return /* @__PURE__ */ l("div", { className: "treeview", children: /* @__PURE__ */ l("ul", { role: "tree", className: "m-0 p-0", children: /* @__PURE__ */ l("li", { id: e, role: "treeitem", "aria-selected": s, children: /* @__PURE__ */ l("div", { children: /* @__PURE__ */ l("div", { className: "action-container", children: /* @__PURE__ */ l("div", { onClick: t, role: "button", tabIndex: 0, children: /* @__PURE__ */ C("div", { className: "d-flex align-items-center gap-8 py-8 ps-24", children: [
1259
+ /* @__PURE__ */ l(Ee, { width: "20", height: "20" }),
1260
+ /* @__PURE__ */ l("span", { children: r("explorer.tree.trash") })
1723
1261
  ] }) }) }) }) }) }) });
1724
- };
1725
- const CreateFolderModal = /* @__PURE__ */ lazy(async () => await import("./FolderModal.js"));
1726
- const TreeViewContainer = () => {
1727
- const queryclient = useQueryClient();
1728
- const [isModalOpen, toggle] = useToggle();
1729
- const treeData = useTreeData();
1730
- const isTrashFolder = useIsTrash();
1731
- const selectedNodesIds = useSelectedNodesIds();
1732
- const {
1733
- appCode
1734
- } = useOdeClient();
1735
- const {
1736
- t: t2
1737
- } = useTranslation(["common", appCode]);
1738
- const {
1739
- goToTrash,
1740
- selectTreeItem,
1741
- unfoldTreeItem,
1742
- foldTreeItem,
1743
- clearSelectedItems,
1744
- clearSelectedIds
1745
- } = useStoreActions();
1746
- const handleTreeItemUnfold = async (folderId) => {
1747
- await unfoldTreeItem(folderId, queryclient);
1748
- };
1749
- const handleOnFolderCreate = () => {
1750
- clearSelectedItems();
1751
- clearSelectedIds();
1752
- toggle();
1262
+ }, xs = /* @__PURE__ */ b(async () => await import("./FolderModal.js")), Ds = () => {
1263
+ const e = O(), [s, t] = be(), r = V(), n = ne(), i = re(), {
1264
+ appCode: o
1265
+ } = M(), {
1266
+ t: d
1267
+ } = z(["common", o]), {
1268
+ goToTrash: u,
1269
+ selectTreeItem: h,
1270
+ unfoldTreeItem: c,
1271
+ foldTreeItem: f,
1272
+ clearSelectedItems: a,
1273
+ clearSelectedIds: m
1274
+ } = x(), p = async (y) => {
1275
+ await c(y, e);
1276
+ }, g = () => {
1277
+ a(), m(), t();
1753
1278
  };
1754
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
1755
- /* @__PURE__ */ jsx(TreeView, { data: treeData, selectedNodesIds, onTreeItemSelect: selectTreeItem, onTreeItemFold: foldTreeItem, onTreeItemUnfold: handleTreeItemUnfold }),
1756
- /* @__PURE__ */ jsx(TrashButton, { id: FOLDER.BIN, selected: isTrashFolder, onSelect: goToTrash }),
1757
- /* @__PURE__ */ jsx("div", { className: "d-grid my-16", children: /* @__PURE__ */ jsx(Button, { disabled: isTrashFolder, type: "button", color: "primary", variant: "outline", leftIcon: /* @__PURE__ */ jsx(Plus, {}), onClick: handleOnFolderCreate, children: t2("explorer.folder.new") }) }),
1758
- /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingScreen, {}), children: isModalOpen && /* @__PURE__ */ jsx(CreateFolderModal, { edit: false, isOpen: isModalOpen, onSuccess: toggle, onCancel: toggle }) })
1279
+ return /* @__PURE__ */ C(ae, { children: [
1280
+ /* @__PURE__ */ l(Te, { data: r, selectedNodesIds: i, onTreeItemSelect: h, onTreeItemFold: f, onTreeItemUnfold: p }),
1281
+ /* @__PURE__ */ l(ws, { id: F.BIN, selected: n, onSelect: u }),
1282
+ /* @__PURE__ */ l("div", { className: "d-grid my-16", children: /* @__PURE__ */ l(Fe, { disabled: n, type: "button", color: "primary", variant: "outline", leftIcon: /* @__PURE__ */ l(Qe, {}), onClick: g, children: d("explorer.folder.new") }) }),
1283
+ /* @__PURE__ */ l(v, { fallback: /* @__PURE__ */ l(A, {}), children: s && /* @__PURE__ */ l(xs, { edit: !1, isOpen: s, onSuccess: t, onCancel: t }) })
1759
1284
  ] });
1760
1285
  };
1761
- const style = "";
1762
- const OnboardingModal = /* @__PURE__ */ lazy(async () => {
1763
- const module = await import("@edifice-ui/react");
1764
- return {
1765
- default: module.OnboardingModal
1766
- };
1767
- });
1768
- const AppAction = /* @__PURE__ */ lazy(async () => await import("./AppAction.js"));
1769
- const Library = /* @__PURE__ */ lazy(async () => await import("./Library.js"));
1770
- const ActionBar = /* @__PURE__ */ lazy(async () => await import("./ActionBarContainer.js"));
1771
- const ActionResourceDisableModal = /* @__PURE__ */ lazy(async () => await import("./DisableModal.js"));
1772
- const TrashedResourceModal = /* @__PURE__ */ lazy(async () => await import("./TrashModal.js"));
1773
- const Explorer = ({
1774
- config
1286
+ const bs = /* @__PURE__ */ b(async () => ({
1287
+ default: (await import("@edifice-ui/react")).OnboardingModal
1288
+ })), Ts = /* @__PURE__ */ b(async () => await import("./AppAction.js")), Fs = /* @__PURE__ */ b(async () => await import("./Library.js")), Cs = /* @__PURE__ */ b(async () => await import("./ActionBarContainer.js")), Ns = /* @__PURE__ */ b(async () => await import("./DisableModal.js")), Rs = /* @__PURE__ */ b(async () => await import("./TrashModal.js")), Gs = ({
1289
+ config: e
1775
1290
  }) => {
1776
- const searchParams = useSearchParams();
1777
- const {
1778
- setConfig,
1779
- setSearchParams
1780
- } = useStoreActions();
1781
- useEffect(() => {
1782
- setConfig(config || {});
1783
- setSearchParams({
1784
- ...searchParams,
1785
- app: config.app,
1786
- types: config.types
1291
+ const s = T(), {
1292
+ setConfig: t,
1293
+ setSearchParams: r
1294
+ } = x();
1295
+ U(() => {
1296
+ t(e || {}), r({
1297
+ ...s,
1298
+ app: e.app,
1299
+ types: e.types
1787
1300
  });
1788
- }, [config]);
1789
- const {
1790
- currentApp
1791
- } = useOdeClient();
1792
- const {
1793
- data: actions
1794
- } = useActions();
1795
- const {
1796
- isTrashedModalOpen,
1797
- onTrashedCancel
1798
- } = useTrashModal();
1301
+ }, [e]);
1799
1302
  const {
1800
- isActionDisableModalOpen,
1801
- onActionDisableCancel
1802
- } = useDisableModal();
1803
- useXitiTrackPageLoad();
1804
- const canPublish = isActionAvailable("publish", actions);
1805
- const canCreate = isActionAvailable("create", actions);
1806
- return config && /* @__PURE__ */ jsxs(Fragment$1, { children: [
1807
- /* @__PURE__ */ jsx(AppHeader, { render: () => canCreate ? /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingScreen, {}), children: /* @__PURE__ */ jsx(AppAction, {}) }) : null, children: /* @__PURE__ */ jsx(Breadcrumb, { app: currentApp }) }),
1808
- /* @__PURE__ */ jsxs(Grid, { className: "flex-grow-1", children: [
1809
- /* @__PURE__ */ jsx(Grid.Col, { sm: "3", lg: "2", xl: "3", className: "border-end pt-16 pe-16 d-none d-lg-block", as: "aside", children: /* @__PURE__ */ jsxs(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingScreen, {}), children: [
1810
- /* @__PURE__ */ jsx(TreeViewContainer, {}),
1811
- canPublish && /* @__PURE__ */ jsx(Library, {})
1303
+ currentApp: n
1304
+ } = M(), {
1305
+ data: i
1306
+ } = ls(), {
1307
+ isTrashedModalOpen: o,
1308
+ onTrashedCancel: d
1309
+ } = rs(), {
1310
+ isActionDisableModalOpen: u,
1311
+ onActionDisableCancel: h
1312
+ } = ts();
1313
+ Ce();
1314
+ const c = oe("publish", i), f = oe("create", i);
1315
+ return e && /* @__PURE__ */ C(ae, { children: [
1316
+ /* @__PURE__ */ l(Ne, { render: () => f ? /* @__PURE__ */ l(v, { fallback: /* @__PURE__ */ l(A, {}), children: /* @__PURE__ */ l(Ts, {}) }) : null, children: /* @__PURE__ */ l(Re, { app: n }) }),
1317
+ /* @__PURE__ */ C(ee, { className: "flex-grow-1", children: [
1318
+ /* @__PURE__ */ l(ee.Col, { sm: "3", lg: "2", xl: "3", className: "border-end pt-16 pe-16 d-none d-lg-block", as: "aside", children: /* @__PURE__ */ C(v, { fallback: /* @__PURE__ */ l(A, {}), children: [
1319
+ /* @__PURE__ */ l(Ds, {}),
1320
+ c && /* @__PURE__ */ l(Fs, {})
1812
1321
  ] }) }),
1813
- /* @__PURE__ */ jsxs(Grid.Col, { sm: "4", md: "8", lg: "6", xl: "9", children: [
1814
- /* @__PURE__ */ jsx(SearchForm, {}),
1815
- /* @__PURE__ */ jsx(ExplorerBreadcrumb, {}),
1816
- /* @__PURE__ */ jsx(List, {})
1322
+ /* @__PURE__ */ C(ee.Col, { sm: "4", md: "8", lg: "6", xl: "9", children: [
1323
+ /* @__PURE__ */ l(Ss, {}),
1324
+ /* @__PURE__ */ l(ss, {}),
1325
+ /* @__PURE__ */ l(gs, {})
1817
1326
  ] }),
1818
- /* @__PURE__ */ jsxs(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingScreen, {}), children: [
1819
- /* @__PURE__ */ jsx(ActionBar, {}),
1820
- /* @__PURE__ */ jsx(OnboardingModal, { id: "showOnboardingTrash", items: [{
1327
+ /* @__PURE__ */ C(v, { fallback: /* @__PURE__ */ l(A, {}), children: [
1328
+ /* @__PURE__ */ l(Cs, {}),
1329
+ /* @__PURE__ */ l(bs, { id: "showOnboardingTrash", items: [{
1821
1330
  src: "onboarding/illu-trash-menu.svg",
1822
1331
  alt: "explorer.modal.onboarding.trash.screen1.alt",
1823
1332
  text: "explorer.modal.onboarding.trash.screen1.title"
@@ -1835,33 +1344,33 @@ const Explorer = ({
1835
1344
  nextText: "explorer.modal.onboarding.trash.next",
1836
1345
  closeText: "explorer.modal.onboarding.trash.close"
1837
1346
  } }),
1838
- isTrashedModalOpen && /* @__PURE__ */ jsx(TrashedResourceModal, { isOpen: isTrashedModalOpen, onCancel: onTrashedCancel }),
1839
- isActionDisableModalOpen && /* @__PURE__ */ jsx(ActionResourceDisableModal, { isOpen: isActionDisableModalOpen, onCancel: onActionDisableCancel })
1347
+ o && /* @__PURE__ */ l(Rs, { isOpen: o, onCancel: d }),
1348
+ u && /* @__PURE__ */ l(Ns, { isOpen: u, onCancel: h })
1840
1349
  ] })
1841
1350
  ] })
1842
1351
  ] });
1843
1352
  };
1844
1353
  export {
1845
- Explorer as E,
1846
- useActions as a,
1847
- useCurrentFolder as b,
1848
- useCreateResource as c,
1849
- useIsTrash as d,
1850
- useStoreContext as e,
1851
- useResourceIds as f,
1852
- useSelectedResources as g,
1853
- useSelectedFolders as h,
1854
- useFolderIds as i,
1855
- useRestore as j,
1856
- useResourceIsTrash as k,
1857
- useShareResource as l,
1858
- useUpdateResource as m,
1859
- useSearchParams as n,
1860
- useCreateFolder as o,
1861
- useUpdatefolder as p,
1862
- useDelete as q,
1863
- useTrash as r,
1864
- useMoveItem as s,
1865
- useTreeData as t,
1866
- useStoreActions as u
1354
+ Gs as E,
1355
+ ls as a,
1356
+ W as b,
1357
+ Xs as c,
1358
+ ne as d,
1359
+ S as e,
1360
+ Z as f,
1361
+ Bs as g,
1362
+ Ms as h,
1363
+ G as i,
1364
+ $s as j,
1365
+ Ge as k,
1366
+ Hs as l,
1367
+ Ws as m,
1368
+ T as n,
1369
+ Vs as o,
1370
+ _s as p,
1371
+ js as q,
1372
+ Ks as r,
1373
+ zs as s,
1374
+ V as t,
1375
+ x as u
1867
1376
  };