@chaibuilder/pages 0.13.4 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/{2AITGKQY-DpAgk_u8.cjs → 2AITGKQY-BLi5HVHf.cjs} +1 -1
  2. package/dist/{2AITGKQY-Dx_Cte-P.js → 2AITGKQY-iyhQ7kgG.js} +5 -5
  3. package/dist/{NCMVHL6D-B6lv7Umq.cjs → NCMVHL6D-CKYg8-AM.cjs} +1 -1
  4. package/dist/{NCMVHL6D-CT2qHOTS.js → NCMVHL6D-PLvSyK5P.js} +2 -2
  5. package/dist/{ZDWCUMSJ-C1vrgsti.cjs → ZDWCUMSJ-BJZ_Yi-4.cjs} +1 -1
  6. package/dist/{ZDWCUMSJ-W9xywtZH.js → ZDWCUMSJ-CuLkdxY-.js} +1 -1
  7. package/dist/add-new-language-page--ah9yzN3.cjs +1 -0
  8. package/dist/add-new-language-page-WM_Ve2vH.js +390 -0
  9. package/dist/add-new-page-Bs_NXM9x.js +30 -0
  10. package/dist/add-new-page-CnUo6xzd.cjs +1 -0
  11. package/dist/confetti.module-BuUnQuWk.cjs +2 -0
  12. package/dist/confetti.module-DCmCkDyV.js +409 -0
  13. package/dist/delete-page-Cf88UkqJ.cjs +1 -0
  14. package/dist/delete-page-D8xhYESu.js +38 -0
  15. package/dist/digital-asset-manager-BAFTqxsM.js +976 -0
  16. package/dist/digital-asset-manager-D_lcprwY.cjs +1 -0
  17. package/dist/duplicate-page-BX1gOez-.cjs +1 -0
  18. package/dist/duplicate-page-CqXTGmWt.js +120 -0
  19. package/dist/dynamic-page-selector-0TiUnfUg.js +86 -0
  20. package/dist/dynamic-page-selector-9JIQrcq5.cjs +1 -0
  21. package/dist/get-seo-defaults-9zHebckY.js +65 -0
  22. package/dist/get-seo-defaults-Cw7vFt-B.cjs +1 -0
  23. package/dist/image-compression-DZ9WMmyn.cjs +1 -0
  24. package/dist/image-compression-DsZ1oqpb.js +37 -0
  25. package/dist/index-D7kegQ3M.js +5153 -0
  26. package/dist/index-LU0FTfeN.cjs +5 -0
  27. package/dist/index.cjs +1 -1
  28. package/dist/index.d.ts +4 -22
  29. package/dist/index.js +20 -21
  30. package/dist/json-diff-viewer-Be-PVOZN.cjs +8 -0
  31. package/dist/json-diff-viewer-C2GK_BDh.js +258 -0
  32. package/dist/lang-panel-CPFS1ssC.js +218 -0
  33. package/dist/lang-panel-CePltxo2.cjs +1 -0
  34. package/dist/mark-as-template-DeB23sWR.cjs +1 -0
  35. package/dist/mark-as-template-jdwcgRIB.js +146 -0
  36. package/dist/nested-path-selector-content-D_iF9Sm3.cjs +1 -0
  37. package/dist/nested-path-selector-content-DvIL_EoN.js +87 -0
  38. package/dist/no-language-page-content-DUM4KxWu.js +35 -0
  39. package/dist/no-language-page-content-Dsm2H3pc.cjs +1 -0
  40. package/dist/page-creator-BjuYmKfc.js +796 -0
  41. package/dist/page-creator-DG0LwvL1.cjs +1 -0
  42. package/dist/page-lock-request-B9WPmFcd.cjs +1 -0
  43. package/dist/page-lock-request-BceB1S-X.js +64 -0
  44. package/dist/page-locked-by-dialog-2MULM3jh.cjs +1 -0
  45. package/dist/page-locked-by-dialog-BEWfFLSc.js +63 -0
  46. package/dist/page-manager-new-BONZN4c5.cjs +1 -0
  47. package/dist/page-manager-new-DV6A9WFv.js +354 -0
  48. package/dist/page-manager-search-and-filter-3h4URMP_.cjs +1 -0
  49. package/dist/page-manager-search-and-filter-DIiowi9F.js +197 -0
  50. package/dist/page-revisions-content-BIxeZeND.js +446 -0
  51. package/dist/page-revisions-content-CQbt25XX.cjs +1 -0
  52. package/dist/publish-pages-content-CdKHrfys.js +178 -0
  53. package/dist/publish-pages-content-im9dPOBM.cjs +1 -0
  54. package/dist/save-to-lib-DGII9CEP.js +476 -0
  55. package/dist/save-to-lib-DOh-850u.cjs +1 -0
  56. package/dist/seo-panel-2VdpoGSg.cjs +1 -0
  57. package/dist/seo-panel-Bxo4f-a_.js +667 -0
  58. package/dist/shared-json-ld-C1OewNgp.cjs +1 -0
  59. package/dist/shared-json-ld-gbnBFljN.js +337 -0
  60. package/dist/slug-input-BmcGmc_i.js +87 -0
  61. package/dist/slug-input-CfuQV97Z.cjs +1 -0
  62. package/dist/theme-panel-footer-D3SwHqGR.js +25 -0
  63. package/dist/theme-panel-footer-FrY4U8zn.cjs +1 -0
  64. package/dist/translation-warning-modal-DalBhNQy.js +26 -0
  65. package/dist/translation-warning-modal-Kctu12rQ.cjs +1 -0
  66. package/dist/unmark-as-template-CihtTMOb.cjs +1 -0
  67. package/dist/unmark-as-template-UwmCCn0u.js +38 -0
  68. package/dist/unpublish-page-CNwIU6AS.js +26 -0
  69. package/dist/unpublish-page-DzLtZcNw.cjs +1 -0
  70. package/dist/use-page-expand-manager-B7JtHdg5.cjs +1 -0
  71. package/dist/use-page-expand-manager-BCFQnVkT.js +85 -0
  72. package/package.json +1 -1
  73. package/dist/index-C4j31Yhz.js +0 -11471
  74. package/dist/index-DnjETHks.cjs +0 -6
  75. package/dist/page-revisions-content-Gx-Qf_91.cjs +0 -8
  76. package/dist/page-revisions-content-_-Nd4U11.js +0 -712
@@ -0,0 +1,976 @@
1
+ import { jsxs as l, jsx as e, Fragment as Q } from "react/jsx-runtime";
2
+ import { mergeClasses as ce } from "@chaibuilder/sdk";
3
+ import { Button as g, Input as oe, Label as _, Textarea as ze, TooltipProvider as B, Tooltip as M, TooltipTrigger as $, TooltipContent as P, Dialog as De, DialogContent as je, DialogHeader as Fe, DialogTitle as Ue, DialogDescription as Le, DialogFooter as Be, Switch as Me } from "@chaibuilder/sdk/ui";
4
+ import { find as $e, merge as Pe, pick as Oe, first as qe, isEmpty as Ke } from "lodash-es";
5
+ import { ChevronLeft as de, ChevronRight as Ge, Loader as O, AlertCircle as Re, Copy as me, Pencil as _e, Link as Qe, Search as We, RefreshCwIcon as Ve, Archive as He, Film as Xe, ImageIcon as Ze, Edit as Je, Trash2 as Ye, Check as et, Upload as tt, AlertTriangle as it } from "lucide-react";
6
+ import ue, { createContext as rt, Component as at, createElement as le, useState as b, useMemo as he, useEffect as W, useCallback as L, Suspense as lt } from "react";
7
+ import { useDropzone as nt } from "react-dropzone";
8
+ import { toast as A } from "sonner";
9
+ import { f as st, c as ct } from "./image-compression-DsZ1oqpb.js";
10
+ import { useQueryClient as J, useMutation as Y, useQuery as fe } from "@tanstack/react-query";
11
+ import { aI as q, aj as K, A as E } from "./index-D7kegQ3M.js";
12
+ const ot = rt(null), Z = {
13
+ didCatch: !1,
14
+ error: null
15
+ };
16
+ class dt extends at {
17
+ constructor(a) {
18
+ super(a), this.resetErrorBoundary = this.resetErrorBoundary.bind(this), this.state = Z;
19
+ }
20
+ static getDerivedStateFromError(a) {
21
+ return {
22
+ didCatch: !0,
23
+ error: a
24
+ };
25
+ }
26
+ resetErrorBoundary() {
27
+ const {
28
+ error: a
29
+ } = this.state;
30
+ if (a !== null) {
31
+ for (var c, i, o = arguments.length, r = new Array(o), d = 0; d < o; d++)
32
+ r[d] = arguments[d];
33
+ (c = (i = this.props).onReset) === null || c === void 0 || c.call(i, {
34
+ args: r,
35
+ reason: "imperative-api"
36
+ }), this.setState(Z);
37
+ }
38
+ }
39
+ componentDidCatch(a, c) {
40
+ var i, o;
41
+ (i = (o = this.props).onError) === null || i === void 0 || i.call(o, a, c);
42
+ }
43
+ componentDidUpdate(a, c) {
44
+ const {
45
+ didCatch: i
46
+ } = this.state, {
47
+ resetKeys: o
48
+ } = this.props;
49
+ if (i && c.error !== null && mt(a.resetKeys, o)) {
50
+ var r, d;
51
+ (r = (d = this.props).onReset) === null || r === void 0 || r.call(d, {
52
+ next: o,
53
+ prev: a.resetKeys,
54
+ reason: "keys"
55
+ }), this.setState(Z);
56
+ }
57
+ }
58
+ render() {
59
+ const {
60
+ children: a,
61
+ fallbackRender: c,
62
+ FallbackComponent: i,
63
+ fallback: o
64
+ } = this.props, {
65
+ didCatch: r,
66
+ error: d
67
+ } = this.state;
68
+ let v = a;
69
+ if (r) {
70
+ const y = {
71
+ error: d,
72
+ resetErrorBoundary: this.resetErrorBoundary
73
+ };
74
+ if (typeof c == "function")
75
+ v = c(y);
76
+ else if (i)
77
+ v = le(i, y);
78
+ else if (o !== void 0)
79
+ v = o;
80
+ else
81
+ throw d;
82
+ }
83
+ return le(ot.Provider, {
84
+ value: {
85
+ didCatch: r,
86
+ error: d,
87
+ resetErrorBoundary: this.resetErrorBoundary
88
+ }
89
+ }, v);
90
+ }
91
+ }
92
+ function mt() {
93
+ let s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], a = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
94
+ return s.length !== a.length || s.some((c, i) => !Object.is(c, a[i]));
95
+ }
96
+ const ut = () => {
97
+ const s = q(), a = J(), c = K();
98
+ return Y({
99
+ mutationFn: async (i) => {
100
+ const o = i.map(async (d) => c(s, {
101
+ action: E.UPLOAD_ASSET,
102
+ data: d
103
+ }));
104
+ return await Promise.all(o);
105
+ },
106
+ onSuccess: (i) => {
107
+ var o;
108
+ if (i != null && i.some((r) => r.error))
109
+ throw new Error(((o = i == null ? void 0 : i.find((r) => r.error)) == null ? void 0 : o.error) || "Failed to upload asset");
110
+ {
111
+ a.invalidateQueries({
112
+ queryKey: [E.GET_ASSETS]
113
+ });
114
+ const r = i == null ? void 0 : i.length;
115
+ A.success(`${r === 1 ? "Asset" : r + " Assets"} uploaded successfully`);
116
+ }
117
+ },
118
+ onError: () => {
119
+ A.error("Failed to upload asset");
120
+ }
121
+ });
122
+ }, ht = () => {
123
+ const s = q(), a = J(), c = K();
124
+ return Y({
125
+ mutationFn: async (i) => c(s, {
126
+ action: E.DELETE_ASSET,
127
+ data: { id: i }
128
+ }),
129
+ onSuccess: (i) => {
130
+ if (i != null && i.error)
131
+ throw new Error(i == null ? void 0 : i.error);
132
+ a.invalidateQueries({
133
+ queryKey: [E.GET_ASSETS]
134
+ }), A.success("Asset deleted successfully");
135
+ },
136
+ onError: () => {
137
+ A.error("Failed to delete asset");
138
+ }
139
+ });
140
+ }, ft = () => {
141
+ const s = q(), a = J(), c = K();
142
+ return Y({
143
+ mutationFn: async (i) => c(s, {
144
+ action: E.UPDATE_ASSET,
145
+ data: i
146
+ }),
147
+ onSuccess: (i) => {
148
+ if (i != null && i.error)
149
+ throw new Error(i == null ? void 0 : i.error);
150
+ a.invalidateQueries({
151
+ queryKey: [E.GET_ASSETS]
152
+ }), A.success("Asset updated successfully");
153
+ },
154
+ onError: () => {
155
+ A.error("Failed to update asset");
156
+ }
157
+ });
158
+ };
159
+ function pt({
160
+ currentPage: s,
161
+ totalPages: a,
162
+ onPageChange: c,
163
+ pageRangeDisplayed: i = 3,
164
+ showPageInput: o = !0,
165
+ className: r = ""
166
+ }) {
167
+ const [d, v] = b(String(s)), y = he(() => {
168
+ const n = Math.floor(i / 2);
169
+ let m = Math.max(1, s - n), h = Math.min(a, s + n);
170
+ h - m + 1 < i && (m === 1 ? h = Math.min(a, m + i - 1) : h === a && (m = Math.max(1, h - i + 1)));
171
+ const x = [];
172
+ m > 1 && (x.push(1), m > 2 && x.push("..."));
173
+ for (let N = m; N <= h; N++)
174
+ x.push(N);
175
+ return h < a && (h < a - 1 && x.push("..."), x.push(a)), x;
176
+ }, [s, a, i]), p = (n) => {
177
+ n !== s && n >= 1 && n <= a && (c(n), v(String(n)));
178
+ }, w = () => {
179
+ s > 1 && p(s - 1);
180
+ }, S = () => {
181
+ s < a && p(s + 1);
182
+ }, C = () => {
183
+ const n = Number(d);
184
+ !isNaN(n) && n >= 1 && n <= a && p(n);
185
+ }, f = (n) => {
186
+ n.key === "Enter" && C();
187
+ };
188
+ return a <= 1 ? null : /* @__PURE__ */ l("div", { className: `flex flex-wrap items-center justify-center gap-3 ${r}`, children: [
189
+ /* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
190
+ /* @__PURE__ */ l(
191
+ g,
192
+ {
193
+ variant: "outline",
194
+ size: "sm",
195
+ onClick: w,
196
+ disabled: s === 1,
197
+ className: "px-2 py-1 text-sm hover:bg-gray-50",
198
+ children: [
199
+ /* @__PURE__ */ e(de, { className: " h-4 w-4" }),
200
+ "Previous"
201
+ ]
202
+ }
203
+ ),
204
+ /* @__PURE__ */ e("div", { className: "flex items-center gap-2", children: y.map((n, m) => {
205
+ if (n === "...")
206
+ return /* @__PURE__ */ e("span", { className: "px-2 text-muted-foreground", children: "..." }, `ellipsis-${m}`);
207
+ const h = n, x = h === s;
208
+ return /* @__PURE__ */ e(
209
+ g,
210
+ {
211
+ variant: x ? "default" : "outline",
212
+ size: "sm",
213
+ onClick: () => p(h),
214
+ className: x ? "border-blue-600 bg-blue-600 px-3 py-1 text-sm text-white" : "border px-3 py-1 text-sm hover:bg-gray-50 hover:text-black",
215
+ children: h
216
+ },
217
+ h
218
+ );
219
+ }) }),
220
+ /* @__PURE__ */ l(
221
+ g,
222
+ {
223
+ variant: "outline",
224
+ size: "sm",
225
+ onClick: S,
226
+ disabled: s === a,
227
+ className: "px-2 py-1 text-sm hover:bg-gray-50",
228
+ children: [
229
+ "Next",
230
+ /* @__PURE__ */ e(Ge, { className: " h-4 w-4" })
231
+ ]
232
+ }
233
+ )
234
+ ] }),
235
+ o && /* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
236
+ /* @__PURE__ */ e("span", { className: "text-sm text-muted-foreground", children: "Go to" }),
237
+ /* @__PURE__ */ e(
238
+ oe,
239
+ {
240
+ type: "number",
241
+ min: 1,
242
+ max: a,
243
+ value: d,
244
+ onChange: (n) => {
245
+ const m = n.target.value.replace(/[^\d]/g, "");
246
+ v(m);
247
+ },
248
+ onKeyDown: f,
249
+ className: "h-8 w-16 px-2 py-1"
250
+ }
251
+ ),
252
+ /* @__PURE__ */ e(
253
+ g,
254
+ {
255
+ variant: "outline",
256
+ size: "sm",
257
+ onClick: C,
258
+ disabled: d === "" || Number(d) < 1 || Number(d) > a,
259
+ children: "Go"
260
+ }
261
+ )
262
+ ] })
263
+ ] });
264
+ }
265
+ const gt = (s = {}) => {
266
+ const a = q(), c = K(), { search: i, page: o = 1, limit: r = 30 } = s;
267
+ return fe({
268
+ queryKey: [E.GET_ASSETS, i, o, r],
269
+ queryFn: async () => {
270
+ const d = await c(a, {
271
+ action: E.GET_ASSETS,
272
+ data: {
273
+ search: i,
274
+ page: o,
275
+ limit: r
276
+ }
277
+ });
278
+ return d.page = o, d.limit = r, d;
279
+ },
280
+ staleTime: 1 / 0,
281
+ retry: 1
282
+ });
283
+ }, vt = (s) => {
284
+ const a = q(), c = K();
285
+ return fe({
286
+ queryKey: [E.GET_ASSET, s],
287
+ queryFn: async () => s ? await c(a, {
288
+ action: E.GET_ASSET,
289
+ data: { id: s }
290
+ }) : null,
291
+ staleTime: 1 / 0,
292
+ retry: 1
293
+ });
294
+ };
295
+ function xt(s) {
296
+ const a = isNaN(s) ? 0 : typeof s == "number" ? s : parseInt(s);
297
+ return a ? a < 1024 ? `${a.toFixed(2)} B` : a < 1024 * 1024 ? `${(a / 1024).toFixed(2)} KB` : `${(a / (1024 * 1024)).toFixed(2)} MB` : "0 B";
298
+ }
299
+ function ne(s) {
300
+ if (!s) return "N/A";
301
+ const a = new Date(s);
302
+ return new Intl.DateTimeFormat("en-US", {
303
+ month: "short",
304
+ day: "numeric",
305
+ year: "numeric",
306
+ hour: "2-digit",
307
+ minute: "2-digit"
308
+ }).format(a);
309
+ }
310
+ function se(s, a) {
311
+ let c = s, i = a == null ? void 0 : a.description;
312
+ return (!i || typeof i != "string") && (i = ""), (!c || typeof c != "string") && (c = ""), c !== i;
313
+ }
314
+ const yt = ({
315
+ assetId: s,
316
+ onBack: a,
317
+ onEdit: c,
318
+ onSave: i,
319
+ isSaving: o
320
+ }) => {
321
+ var S, C, f;
322
+ const { data: r, isLoading: d, isError: v } = vt(s || ""), [y, p] = b(""), w = async (n, m) => {
323
+ try {
324
+ await navigator.clipboard.writeText(n), A.success(`${m} copied to clipboard`);
325
+ } catch (h) {
326
+ A.error(`Failed to copy ${m}`, {
327
+ description: h == null ? void 0 : h.message
328
+ });
329
+ }
330
+ };
331
+ return ue.useEffect(() => {
332
+ r != null && r.description && p(r.description);
333
+ }, [r]), d ? /* @__PURE__ */ e("div", { className: "flex-1 flex items-center justify-center", children: /* @__PURE__ */ e(O, { className: "h-8 w-8 animate-spin" }) }) : v || !(r != null && r.id) ? /* @__PURE__ */ e("div", { className: "flex-1 flex items-center justify-center", children: /* @__PURE__ */ l("div", { className: "text-center max-w-md mx-auto p-6", children: [
334
+ /* @__PURE__ */ e("div", { className: "flex justify-center mb-4", children: /* @__PURE__ */ e(Re, { className: "h-12 w-12 text-gray-400" }) }),
335
+ /* @__PURE__ */ e("h3", { className: "text-lg font-medium text-gray-900 mb-2", children: "No Asset Found" }),
336
+ /* @__PURE__ */ e("p", { className: "text-sm text-gray-500 mb-6", children: v ? "There was an error loading the asset. Please try again later." : "The asset you're looking for doesn't exist or has been removed." }),
337
+ /* @__PURE__ */ l("div", { className: "flex justify-center gap-4", children: [
338
+ /* @__PURE__ */ e(g, { variant: "outline", onClick: a, children: "Back to Assets" }),
339
+ v && /* @__PURE__ */ e(
340
+ g,
341
+ {
342
+ variant: "default",
343
+ onClick: () => window.location.reload(),
344
+ children: "Try Again"
345
+ }
346
+ )
347
+ ] })
348
+ ] }) }) : /* @__PURE__ */ l("div", { className: "flex-1 flex flex-col gap-y-4 overflow-hidden", children: [
349
+ /* @__PURE__ */ l("div", { className: "flex items-center justify-between", children: [
350
+ /* @__PURE__ */ l(
351
+ g,
352
+ {
353
+ variant: "outline",
354
+ size: "sm",
355
+ onClick: a,
356
+ disabled: o,
357
+ children: [
358
+ /* @__PURE__ */ e(de, { className: "h-4 w-4" }),
359
+ "Back to Assets"
360
+ ]
361
+ }
362
+ ),
363
+ /* @__PURE__ */ l("div", { className: "flex gap-2", children: [
364
+ /* @__PURE__ */ e(g, { variant: "outline", onClick: a, disabled: o, children: "Cancel" }),
365
+ /* @__PURE__ */ l(
366
+ g,
367
+ {
368
+ variant: "outline",
369
+ onClick: () => w(r.url, "Asset URL"),
370
+ disabled: o,
371
+ children: [
372
+ /* @__PURE__ */ e(me, { className: "h-4 w-4 mr-2" }),
373
+ "Copy URL"
374
+ ]
375
+ }
376
+ ),
377
+ /* @__PURE__ */ l(
378
+ g,
379
+ {
380
+ variant: "default",
381
+ onClick: () => c(r),
382
+ disabled: o,
383
+ children: [
384
+ /* @__PURE__ */ e(_e, { className: "h-4 w-4" }),
385
+ "Edit Image"
386
+ ]
387
+ }
388
+ )
389
+ ] })
390
+ ] }),
391
+ /* @__PURE__ */ l("div", { className: "grid grid-cols-2 items-start gap-6 flex-1 overflow-hidden", children: [
392
+ /* @__PURE__ */ e("div", { className: "relative h-[calc(80vh-200px)] w-full flex items-start justify-center", children: /* @__PURE__ */ e(
393
+ "img",
394
+ {
395
+ src: `${r.url}?v=${((S = r.metadata) == null ? void 0 : S.updatedAt) || r.createdAt}`,
396
+ alt: r.name,
397
+ className: "w-full h-full object-contain rounded-lg max-h-max max-w-max"
398
+ }
399
+ ) }),
400
+ /* @__PURE__ */ l("div", { className: "space-y-6", children: [
401
+ /* @__PURE__ */ l("div", { className: "grid gap-3 border rounded-md pt-2 bg-gray-100", children: [
402
+ /* @__PURE__ */ e(_, { className: "w-full text-center", children: "Details" }),
403
+ /* @__PURE__ */ e("div", { className: "grid grid-cols-1 gap-2 text-sm border rounded-md p-2 bg-white", children: [
404
+ { label: "File Name", value: r.name },
405
+ { label: "Type", value: r.type, capitalize: !0 },
406
+ {
407
+ label: "Format",
408
+ value: ((C = r.metadata) == null ? void 0 : C.format) || r.type,
409
+ capitalize: !0
410
+ },
411
+ {
412
+ label: "Size",
413
+ value: xt(r.size)
414
+ },
415
+ {
416
+ label: "Dimensions",
417
+ value: `${r.width || 0} × ${r.height || 0}`
418
+ },
419
+ {
420
+ label: "Created",
421
+ value: ne(r.createdAt)
422
+ },
423
+ {
424
+ label: "Updated",
425
+ value: ne(
426
+ ((f = r.metadata) == null ? void 0 : f.updatedAt) || r.createdAt
427
+ )
428
+ },
429
+ {
430
+ label: "URL",
431
+ value: r.url,
432
+ copyable: !0
433
+ }
434
+ ].map((n) => /* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
435
+ /* @__PURE__ */ e(_, { className: "w-max text-left px-2 w-1/4 font-normal text-gray-700", children: n.label }),
436
+ ":",
437
+ /* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
438
+ /* @__PURE__ */ e(
439
+ "div",
440
+ {
441
+ className: "w-max text-left font-medium text-gray-900" + (n.capitalize ? " capitalize" : ""),
442
+ children: n.value
443
+ }
444
+ ),
445
+ n.copyable && /* @__PURE__ */ e(
446
+ g,
447
+ {
448
+ variant: "ghost",
449
+ size: "icon",
450
+ className: "h-6 w-6",
451
+ onClick: () => w(n.value, n.label),
452
+ children: /* @__PURE__ */ e(Qe, { className: "h-3 w-3" })
453
+ }
454
+ )
455
+ ] })
456
+ ] }, n.label)) })
457
+ ] }),
458
+ r.usedOn && r.usedOn.length > 0 && /* @__PURE__ */ l("div", { className: "grid gap-3", children: [
459
+ /* @__PURE__ */ e(_, { children: "Used On" }),
460
+ /* @__PURE__ */ e("div", { className: "grid grid-cols-1 gap-2 text-sm border rounded-md p-2", children: r.usedOn.map((n, m) => /* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
461
+ /* @__PURE__ */ e("div", { className: "w-max text-left font-medium text-gray-900", children: n.name }),
462
+ /* @__PURE__ */ l("div", { className: "text-gray-500", children: [
463
+ "(",
464
+ n.slug,
465
+ ")"
466
+ ] })
467
+ ] }, m)) })
468
+ ] }),
469
+ /* @__PURE__ */ l("div", { className: "grid gap-3 border rounded-md pt-2 bg-gray-100 relative", children: [
470
+ /* @__PURE__ */ e(_, { className: "w-full text-center", children: "Description" }),
471
+ /* @__PURE__ */ e(
472
+ ze,
473
+ {
474
+ id: "description",
475
+ value: y,
476
+ placeholder: "Enter a description for the asset",
477
+ onChange: (n) => p(n.target.value),
478
+ rows: 3,
479
+ disabled: o,
480
+ className: "hover:border-black/40 bg-white"
481
+ }
482
+ ),
483
+ /* @__PURE__ */ e("div", { className: "flex justify-end items-start absolute top-1.5 right-2", children: /* @__PURE__ */ e(
484
+ "button",
485
+ {
486
+ type: "button",
487
+ onClick: () => i(y),
488
+ disabled: o || !se(y, r),
489
+ className: `py-0 bg-blue-500 text-white px-3 py-0.5 rounded-md text-sm ${o || !se(y, r) ? "opacity-50 cursor-not-allowed" : ""}`,
490
+ children: o ? /* @__PURE__ */ l(Q, { children: [
491
+ /* @__PURE__ */ e(O, { className: "h-4 w-4 mr-2 animate-spin" }),
492
+ "Saving..."
493
+ ] }) : "Save"
494
+ }
495
+ ) })
496
+ ] })
497
+ ] })
498
+ ] })
499
+ ] });
500
+ }, Nt = ue.lazy(() => import("./image-editor-CzFST20j.js")), bt = 25 * 1024 * 1024, wt = ({ isUpdatingAsset: s, allowedTypes: a, uploadAssets: c, isUploadingAsset: i, onUploaded: o }) => {
501
+ const [r, d] = b(() => {
502
+ const f = localStorage.getItem("chai_optimize_images");
503
+ return f !== null ? f === "true" : !0;
504
+ });
505
+ W(() => {
506
+ localStorage.setItem("chai_optimize_images", r.toString());
507
+ }, [r]);
508
+ const v = s || i, y = L(
509
+ async (f) => {
510
+ try {
511
+ const n = f;
512
+ if (!n.every((N) => N.type.startsWith("image/")))
513
+ return A.error("Invalid file type. Please upload a valid file."), Promise.reject(new Error("Invalid file type"));
514
+ const m = n.map(async (N) => {
515
+ let z = N;
516
+ return N.type.startsWith("image/") && (z = await ct(N)), new Promise((V, D) => {
517
+ const j = new FileReader();
518
+ j.readAsDataURL(z), j.onload = async () => {
519
+ V({
520
+ file: j.result,
521
+ folderId: void 0,
522
+ name: N.name,
523
+ optimize: r
524
+ });
525
+ }, j.onerror = () => D(null);
526
+ });
527
+ }), h = await Promise.all(m), x = await c(h);
528
+ return (x == null ? void 0 : x.length) === 1 && o(x[0]), x;
529
+ } catch (n) {
530
+ return Promise.reject(n);
531
+ }
532
+ },
533
+ [c, r, o]
534
+ ), p = (f) => {
535
+ const n = [];
536
+ let m = 0;
537
+ return f.forEach((h) => {
538
+ h.size > bt ? m++ : n.push(h);
539
+ }), m > 0 && A.error(
540
+ `${m === 1 && f.length === 1 ? "File" : m + (m === 1 ? " file" : " files")} exceed the maximum size limit of 10MB.`
541
+ ), Ke(n) ? [] : y(n);
542
+ }, { getRootProps: w, getInputProps: S, isDragActive: C } = nt({
543
+ onDrop: p,
544
+ accept: {
545
+ "image/*": a.includes("image") ? [] : []
546
+ },
547
+ disabled: s || i,
548
+ multiple: !0
549
+ });
550
+ return /* @__PURE__ */ e(
551
+ "div",
552
+ {
553
+ className: `flex h-[60px] w-full flex-col items-center justify-center rounded-lg border-2 border-dashed border-slate-300 p-0 py-2 hover:border-black/50 ${v ? "pointer-events-none bg-gray-100 opacity-90" : "bg-gray-100 hover:border-black/50 hover:bg-gray-100"}`,
554
+ children: /* @__PURE__ */ l(
555
+ "div",
556
+ {
557
+ ...w(),
558
+ className: ce(
559
+ "flex h-max w-full cursor-pointer flex-col justify-center rounded-lg text-center",
560
+ v ? "items-start" : "items-center",
561
+ C ? "border-primary bg-primary/5" : "border-muted-foreground/20"
562
+ ),
563
+ children: [
564
+ /* @__PURE__ */ e("input", { ...S() }),
565
+ v ? /* @__PURE__ */ e("div", { className: "flex flex-col items-center px-6", children: /* @__PURE__ */ l("div", { className: "flex items-center justify-center gap-2 leading-tight", children: [
566
+ /* @__PURE__ */ e("div", { className: "flex items-center justify-center rounded-full bg-indigo-100 p-2", children: /* @__PURE__ */ e(O, { className: "h-4 w-4 animate-spin text-indigo-500" }) }),
567
+ /* @__PURE__ */ l("div", { className: "text-left", children: [
568
+ /* @__PURE__ */ e("div", { className: "font-medium", children: s ? "Updating file..." : "Uploading file..." }),
569
+ /* @__PURE__ */ l("div", { className: "text-xs font-light text-muted-foreground", children: [
570
+ "Please wait while we ",
571
+ s ? "update" : "upload",
572
+ " your file..."
573
+ ] })
574
+ ] })
575
+ ] }) }) : /* @__PURE__ */ l("div", { className: "flex w-full items-center justify-between px-6", children: [
576
+ /* @__PURE__ */ e("div", { className: "flex flex-col items-center", children: /* @__PURE__ */ l("div", { className: "flex items-center justify-between gap-2 leading-tight", children: [
577
+ /* @__PURE__ */ e(
578
+ "div",
579
+ {
580
+ className: "flex items-center justify-center rounded-full border border-indigo-500 bg-indigo-100 p-2",
581
+ children: /* @__PURE__ */ e(tt, { className: "h-4 w-4 text-indigo-500" })
582
+ }
583
+ ),
584
+ /* @__PURE__ */ l("div", { className: "text-left", children: [
585
+ /* @__PURE__ */ l("div", { className: "font-medium", children: [
586
+ "Drop your file here or",
587
+ " ",
588
+ /* @__PURE__ */ e("span", { className: "cursor-pointer text-indigo-500 hover:underline", children: "browse" })
589
+ ] }),
590
+ /* @__PURE__ */ e("div", { className: "text-xs font-light text-muted-foreground", children: /* @__PURE__ */ l("span", { className: "", children: [
591
+ "Accepted file types: ",
592
+ /* @__PURE__ */ e("span", { className: "capitalize text-indigo-400", children: a.join(", ") })
593
+ ] }) })
594
+ ] })
595
+ ] }) }),
596
+ /* @__PURE__ */ l("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
597
+ /* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
598
+ /* @__PURE__ */ l("span", { className: "text-xs", children: [
599
+ "Optimization:",
600
+ " ",
601
+ /* @__PURE__ */ e("span", { className: r ? "text-indigo-600" : "text-gray-400", children: r ? "On" : "Off" })
602
+ ] }),
603
+ /* @__PURE__ */ e(
604
+ Me,
605
+ {
606
+ checked: r,
607
+ onCheckedChange: (f) => {
608
+ d(f);
609
+ },
610
+ onClick: (f) => {
611
+ f.stopPropagation();
612
+ },
613
+ className: "data-[state=checked]:bg-indigo-500"
614
+ }
615
+ )
616
+ ] }),
617
+ /* @__PURE__ */ e(B, { children: /* @__PURE__ */ l(M, { children: [
618
+ /* @__PURE__ */ e($, { asChild: !0, children: /* @__PURE__ */ e(
619
+ "span",
620
+ {
621
+ className: `flex cursor-help items-center text-amber-500 ${r ? "invisible" : ""}`,
622
+ children: /* @__PURE__ */ e(it, { className: "mr-1 h-4 w-4" })
623
+ }
624
+ ) }),
625
+ /* @__PURE__ */ e(P, { side: "top", children: /* @__PURE__ */ l("p", { className: "text-xs text-white", children: [
626
+ "Warning: Unoptimized images may affect ",
627
+ /* @__PURE__ */ e("br", {}),
628
+ " performance and page load times"
629
+ ] }) })
630
+ ] }) })
631
+ ] })
632
+ ] })
633
+ ]
634
+ }
635
+ )
636
+ }
637
+ );
638
+ };
639
+ function Ut({ close: s, onSelect: a, mode: c = "image", assetId: i }) {
640
+ const d = he(() => [c], [c]), [v, y] = b(null), [p, w] = b(null), [S, C] = b(null), [f, n] = b({ show: !1, file: "" }), [m, h] = b(!1), [x, N] = b(i ? "details" : "grid"), [z, V] = b(""), [D, j] = b(""), [G, H] = b(1), [ee] = b(30), [k, X] = b([]);
641
+ W(() => {
642
+ i && (y(i), N("details"));
643
+ }, [i]), W(() => {
644
+ const t = setTimeout(() => {
645
+ V(D), H(1);
646
+ }, 300);
647
+ return () => clearTimeout(t);
648
+ }, [D]);
649
+ const {
650
+ data: F,
651
+ isLoading: R,
652
+ refetch: pe
653
+ } = gt({
654
+ search: z.toLowerCase().trim(),
655
+ page: G,
656
+ limit: ee
657
+ }), T = (F == null ? void 0 : F.assets) || [], ge = (F == null ? void 0 : F.total) || 0, I = Math.ceil(ge / ee);
658
+ W(() => {
659
+ R || I <= 0 || H((t) => t > I ? I : t < 1 ? 1 : t);
660
+ }, [R, I]);
661
+ const ve = (T == null ? void 0 : T.length) > 0, { mutate: xe } = ht(), { mutateAsync: te, isPending: ye } = ut(), { mutate: ie, isPending: Ne } = ft(), re = L(
662
+ (t) => {
663
+ const u = Math.min(Math.max(1, t), Math.max(1, I));
664
+ u !== G && H(u);
665
+ },
666
+ [I, G]
667
+ ), be = (t) => {
668
+ j(t.target.value);
669
+ }, we = L(
670
+ (t) => {
671
+ X((u) => $e(u, { id: t.id }) ? [] : [t]);
672
+ },
673
+ [!1]
674
+ ), Ce = L(() => {
675
+ X([]);
676
+ }, []), ae = (t) => {
677
+ (t == null ? void 0 : t.length) !== 0 && (a(Oe(qe(t || k), ["id", "url", "width", "height", "description"])), s());
678
+ }, Ae = async (t) => {
679
+ w(t);
680
+ }, Se = async () => {
681
+ p && (C(p == null ? void 0 : p.id), await xe(p.id, {
682
+ onSuccess: () => {
683
+ C(null), w(null);
684
+ },
685
+ onError: () => {
686
+ C(null);
687
+ }
688
+ }), w(null));
689
+ }, Ee = (t) => {
690
+ y(t.id), N("details");
691
+ }, ke = async (t, u) => {
692
+ try {
693
+ const U = localStorage.getItem("chai_optimize_images") !== "false";
694
+ u ? (await te([
695
+ {
696
+ file: t,
697
+ folderId: void 0,
698
+ name: f.name || "",
699
+ optimize: U
700
+ }
701
+ ]), n({ show: !1, file: "" })) : (await ie({
702
+ id: f.id || "",
703
+ file: t
704
+ }), n({ show: !1, file: "" }));
705
+ } catch (U) {
706
+ console.error("Error saving edited image:", U);
707
+ }
708
+ }, Ie = L((t) => {
709
+ X([t]);
710
+ }, []), Te = L(
711
+ (t) => {
712
+ re(t);
713
+ },
714
+ [re]
715
+ );
716
+ return /* @__PURE__ */ l(Q, { children: [
717
+ /* @__PURE__ */ l("div", { className: "flex h-[80vh] max-h-[1232px] w-[80vw] max-w-[1232px] flex-col space-y-4", children: [
718
+ /* @__PURE__ */ e("h1", { className: "text-lg font-medium", children: "Digital Asset Manager" }),
719
+ x === "grid" ? /* @__PURE__ */ l(Q, { children: [
720
+ /* @__PURE__ */ e(
721
+ wt,
722
+ {
723
+ maxFileSize: 10,
724
+ allowedTypes: d,
725
+ uploadAssets: te,
726
+ isUpdatingAsset: Ne,
727
+ isUploadingAsset: ye,
728
+ onUploaded: Ie
729
+ }
730
+ ),
731
+ /* @__PURE__ */ l("div", { className: "relative flex flex-1 flex-col gap-y-3 overflow-hidden rounded-lg border p-2", children: [
732
+ /* @__PURE__ */ l("div", { className: "flex items-center justify-between gap-3", children: [
733
+ /* @__PURE__ */ l("div", { className: "relative w-1/2", children: [
734
+ /* @__PURE__ */ e(
735
+ We,
736
+ {
737
+ strokeWidth: 3,
738
+ className: `absolute left-2 top-2.5 h-4 w-4 text-muted-foreground ${D.length > 0 ? "text-indigo-800" : ""}`
739
+ }
740
+ ),
741
+ /* @__PURE__ */ e(
742
+ oe,
743
+ {
744
+ placeholder: "Search assets...",
745
+ onChange: be,
746
+ value: D,
747
+ className: "pl-8"
748
+ }
749
+ )
750
+ ] }),
751
+ /* @__PURE__ */ l("div", { className: "flex items-center gap-x-2", children: [
752
+ k.length > 0 ? /* @__PURE__ */ e("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
753
+ k.length > 0 && /* @__PURE__ */ e(Q, { children: /* @__PURE__ */ e(
754
+ g,
755
+ {
756
+ variant: "outline",
757
+ size: "sm",
758
+ onClick: () => Ce(),
759
+ title: "Clear selection",
760
+ children: "Clear"
761
+ }
762
+ ) }),
763
+ /* @__PURE__ */ e(
764
+ g,
765
+ {
766
+ size: "sm",
767
+ onClick: () => ae(k),
768
+ disabled: k.length === 0,
769
+ children: "Select Asset"
770
+ }
771
+ )
772
+ ] }) }) : null,
773
+ /* @__PURE__ */ e(g, { variant: "ghost", size: "icon", onClick: () => pe(), children: /* @__PURE__ */ e(Ve, { className: "h-4 w-4" }) })
774
+ ] })
775
+ ] }),
776
+ /* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto pb-[66px]", children: R ? /* @__PURE__ */ l("div", { className: "columns-1 gap-3 space-y-3 sm:columns-3 md:columns-5", children: [
777
+ /* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
778
+ /* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
779
+ /* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
780
+ /* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
781
+ /* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
782
+ /* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
783
+ /* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
784
+ /* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
785
+ /* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
786
+ /* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" })
787
+ ] }) : !R && !ve ? /* @__PURE__ */ l("div", { className: "flex h-full flex-col items-center justify-center rounded-lg border", children: [
788
+ /* @__PURE__ */ e("div", { className: "text-muted-foreground", children: /* @__PURE__ */ e(He, { className: "h-9 w-9 text-indigo-500" }) }),
789
+ /* @__PURE__ */ e("div", { className: "text-lg text-muted-foreground", children: "No assets found" }),
790
+ /* @__PURE__ */ e("div", { className: "text-sm text-muted-foreground", children: z.length > 0 ? "No assets found for your search: " + z : "Start uploading assets to get started" }),
791
+ /* @__PURE__ */ e("br", {})
792
+ ] }) : /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-3 p-1", children: T == null ? void 0 : T.map((t) => /* @__PURE__ */ l(
793
+ "div",
794
+ {
795
+ className: ce(
796
+ "group relative flex max-h-[180px] max-w-[180px] cursor-pointer flex-col justify-between overflow-hidden rounded-lg border-2 transition-all",
797
+ k.some((u) => u.id === t.id) ? "border-blue-500" : "hover:border-black/90",
798
+ S && (p == null ? void 0 : p.id) === t.id ? "pointer-events-none opacity-50" : "",
799
+ S === t.id ? "pointer-events-none opacity-50" : ""
800
+ ),
801
+ onClick: () => we(t),
802
+ onDoubleClick: () => ae([t]),
803
+ children: [
804
+ /* @__PURE__ */ l("div", { className: "aspect-square relative overflow-hidden", children: [
805
+ S === t.id ? /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center bg-black/50", children: /* @__PURE__ */ e(O, { className: "h-8 w-8 animate-spin text-white" }) }) : null,
806
+ t.type === "image" ? /* @__PURE__ */ e(
807
+ "img",
808
+ {
809
+ src: `${t.thumbnailUrl || "/placeholder.svg"}?v=${(t == null ? void 0 : t.updatedAt) || t.createdAt}`,
810
+ alt: t.name,
811
+ className: `h-full min-h-[80px] w-full object-contain ${k.some((u) => u.id === t.id) ? "" : "group-hover:blur group-hover:contrast-50"}`
812
+ }
813
+ ) : /* @__PURE__ */ l("div", { className: "flex h-full items-center justify-center", children: [
814
+ /* @__PURE__ */ e(Xe, { className: "h-12 w-12 text-muted-foreground" }),
815
+ t.thumbnailUrl && /* @__PURE__ */ e(
816
+ "img",
817
+ {
818
+ src: `${t.thumbnailUrl || "/placeholder.svg"}?v=${(t == null ? void 0 : t.updatedAt) || t.createdAt}`,
819
+ alt: t.name,
820
+ className: "absolute inset-0 h-full w-full object-cover"
821
+ }
822
+ )
823
+ ] })
824
+ ] }),
825
+ /* @__PURE__ */ l("div", { className: "flex items-end justify-between border-t-[1px] border-black/10 bg-white px-2 py-1", children: [
826
+ /* @__PURE__ */ e("div", { className: "truncate text-xs leading-tight", title: t.name, children: t.name }),
827
+ /* @__PURE__ */ e("div", { className: "flex items-center justify-between whitespace-nowrap text-[9px] font-light text-muted-foreground", children: /* @__PURE__ */ e("span", { children: st((t == null ? void 0 : t.size) || 0) }) })
828
+ ] }),
829
+ !k.some((u) => u.id === t.id) && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center opacity-0 transition-opacity group-hover:opacity-100", children: /* @__PURE__ */ l("div", { className: "grid grid-cols-4 gap-2 p-2", children: [
830
+ /* @__PURE__ */ e(B, { children: /* @__PURE__ */ l(M, { children: [
831
+ /* @__PURE__ */ e($, { asChild: !0, children: /* @__PURE__ */ e(
832
+ g,
833
+ {
834
+ variant: "secondary",
835
+ size: "icon",
836
+ className: "h-8 w-8 rounded-full",
837
+ onClick: (u) => {
838
+ u.stopPropagation(), Ee(t);
839
+ },
840
+ children: /* @__PURE__ */ e(Ze, { className: "h-4 w-4" })
841
+ }
842
+ ) }),
843
+ /* @__PURE__ */ e(P, { children: /* @__PURE__ */ e("p", { children: "View Details" }) })
844
+ ] }) }),
845
+ /* @__PURE__ */ e(B, { children: /* @__PURE__ */ l(M, { children: [
846
+ /* @__PURE__ */ e($, { asChild: !0, children: /* @__PURE__ */ e(
847
+ g,
848
+ {
849
+ variant: "secondary",
850
+ size: "icon",
851
+ className: "h-8 w-8 rounded-full",
852
+ onClick: (u) => {
853
+ u.stopPropagation(), navigator.clipboard.writeText(t.url), A.success("Asset URL copied to clipboard");
854
+ },
855
+ children: /* @__PURE__ */ e(me, { className: "h-4 w-4" })
856
+ }
857
+ ) }),
858
+ /* @__PURE__ */ e(P, { children: /* @__PURE__ */ e("p", { children: "Copy URL" }) })
859
+ ] }) }),
860
+ /* @__PURE__ */ e(B, { children: /* @__PURE__ */ l(M, { children: [
861
+ /* @__PURE__ */ e($, { asChild: !0, children: /* @__PURE__ */ e(
862
+ g,
863
+ {
864
+ variant: "secondary",
865
+ size: "icon",
866
+ className: "h-8 w-8 rounded-full",
867
+ onClick: (u) => {
868
+ u.stopPropagation(), n({
869
+ id: t.id,
870
+ show: !0,
871
+ file: t.url,
872
+ name: t.name
873
+ });
874
+ },
875
+ children: /* @__PURE__ */ e(Je, { className: "h-4 w-4" })
876
+ }
877
+ ) }),
878
+ /* @__PURE__ */ e(P, { children: /* @__PURE__ */ e("p", { children: "Edit Image" }) })
879
+ ] }) }),
880
+ /* @__PURE__ */ e(B, { children: /* @__PURE__ */ l(M, { children: [
881
+ /* @__PURE__ */ e($, { asChild: !0, children: /* @__PURE__ */ e(
882
+ g,
883
+ {
884
+ variant: "destructive",
885
+ size: "icon",
886
+ className: "h-8 w-8 rounded-full",
887
+ onClick: (u) => {
888
+ u.stopPropagation(), Ae(t);
889
+ },
890
+ children: /* @__PURE__ */ e(Ye, { className: "h-4 w-4" })
891
+ }
892
+ ) }),
893
+ /* @__PURE__ */ e(P, { children: /* @__PURE__ */ e("p", { children: "Delete Asset" }) })
894
+ ] }) })
895
+ ] }) }),
896
+ k.some((u) => u.id === t.id) && /* @__PURE__ */ e("div", { className: "absolute right-1 top-1 h-max rounded-full border border-white bg-blue-500 p-1", children: /* @__PURE__ */ e(et, { className: "h-3 w-3 text-white", strokeWidth: 5 }) })
897
+ ]
898
+ },
899
+ t.id
900
+ )) }) }),
901
+ I > 1 && /* @__PURE__ */ e("div", { className: "absolute bottom-0 left-0 right-0 border-t bg-white p-4", children: /* @__PURE__ */ e(dt, { fallback: /* @__PURE__ */ e("div", { className: "text-red-500", children: "Error loading pagination" }), children: /* @__PURE__ */ e(
902
+ pt,
903
+ {
904
+ currentPage: G,
905
+ totalPages: I,
906
+ onPageChange: Te,
907
+ pageRangeDisplayed: 3,
908
+ showPageInput: !0
909
+ }
910
+ ) }) })
911
+ ] })
912
+ ] }) : /* @__PURE__ */ e(
913
+ yt,
914
+ {
915
+ assetId: v || i || "",
916
+ onBack: () => {
917
+ N("grid"), y(null);
918
+ },
919
+ onEdit: (t) => {
920
+ n({
921
+ id: t.id,
922
+ show: !0,
923
+ file: t.url,
924
+ name: t.name
925
+ });
926
+ },
927
+ onSave: async (t) => {
928
+ if (v) {
929
+ h(!0);
930
+ try {
931
+ const u = T.find((U) => U.id === v);
932
+ u && await ie(Pe(u, { description: t }));
933
+ } finally {
934
+ h(!1);
935
+ }
936
+ }
937
+ },
938
+ isSaving: m
939
+ }
940
+ )
941
+ ] }),
942
+ f.show && /* @__PURE__ */ e(
943
+ lt,
944
+ {
945
+ fallback: /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ e(O, { className: "h-8 w-8 animate-spin" }) }),
946
+ children: /* @__PURE__ */ e(
947
+ Nt,
948
+ {
949
+ imageUrl: f.file,
950
+ onSave: ke,
951
+ onClose: () => n({ show: !1, file: "" }),
952
+ defaultSavedImageName: f.name,
953
+ isEditing: !!f.id
954
+ }
955
+ )
956
+ }
957
+ ),
958
+ p && /* @__PURE__ */ e(De, { open: !!p, onOpenChange: () => w(null), children: /* @__PURE__ */ l(je, { children: [
959
+ /* @__PURE__ */ l(Fe, { children: [
960
+ /* @__PURE__ */ e(Ue, { children: "Delete Asset" }),
961
+ /* @__PURE__ */ l(Le, { children: [
962
+ 'Are you sure you want to delete "',
963
+ p.name,
964
+ '"? This action cannot be undone.'
965
+ ] })
966
+ ] }),
967
+ /* @__PURE__ */ l(Be, { className: "gap-2 sm:gap-0", children: [
968
+ /* @__PURE__ */ e(g, { variant: "outline", onClick: () => w(null), children: "Cancel" }),
969
+ /* @__PURE__ */ e(g, { variant: "destructive", onClick: Se, children: "Delete" })
970
+ ] })
971
+ ] }) })
972
+ ] });
973
+ }
974
+ export {
975
+ Ut as default
976
+ };