@chaibuilder/pages 0.4.6-beta.2 → 0.4.6-beta.4

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.
@@ -1,260 +1,262 @@
1
- import { jsxs as a, Fragment as j, jsx as e } from "react/jsx-runtime";
2
- import W, { useState as T, useCallback as C, useMemo as ne, useRef as oe, useEffect as ce, Suspense as Y } from "react";
3
- import { mergeClasses as O } from "@chaibuilder/sdk";
4
- import { Tabs as de, TabsList as ue, TabsTrigger as H, Button as v, TabsContent as V, Input as me, Card as he, CardContent as pe } from "@chaibuilder/sdk/ui";
5
- import { debounce as fe, find as ge, merge as ve } from "lodash-es";
6
- import { Search as xe, Film as ye, ImageIcon as Ne, Edit as Se, Trash2 as we, Loader2 as _, Upload as Ae } from "lucide-react";
7
- import { useDropzone as be } from "react-dropzone";
8
- import { useQueryClient as B, useMutation as Q, useInfiniteQuery as Ee } from "@tanstack/react-query";
9
- import { toast as N } from "sonner";
10
- import { W as z, X as M, Y as f, Z as Ce } from "./index-Ci9oNrDB.js";
11
- const Te = () => {
12
- const l = z(), n = B(), o = M();
13
- return Q({
1
+ import { jsxs as a, Fragment as B, jsx as e } from "react/jsx-runtime";
2
+ import W, { useState as S, useCallback as A, useMemo as re, useRef as oe, Suspense as O } from "react";
3
+ import { mergeClasses as Y } from "@chaibuilder/sdk";
4
+ import { Tabs as ce, TabsList as de, TabsTrigger as $, Button as f, TabsContent as H, Input as ue, Card as me, CardContent as he, Dialog as ge, DialogContent as pe, DialogHeader as fe, DialogTitle as ye, DialogDescription as ve, DialogFooter as xe } from "@chaibuilder/sdk/ui";
5
+ import { debounce as Ne, find as Ae, merge as we } from "lodash-es";
6
+ import { Search as Se, Film as be, ImageIcon as Ce, Edit as Ee, Trash2 as Te, Loader2 as V, Upload as De } from "lucide-react";
7
+ import { useDropzone as Pe } from "react-dropzone";
8
+ import { useQueryClient as Q, useMutation as R, useQuery as Ue } from "@tanstack/react-query";
9
+ import { toast as b } from "sonner";
10
+ import { W as z, X as F, Y as y, Z as ze } from "./index-D_vvEddR.js";
11
+ const Fe = () => {
12
+ const t = z(), r = Q(), o = F();
13
+ return R({
14
14
  mutationFn: async ({
15
- file: r,
16
- folderId: c,
17
- name: t
18
- }) => o(l, {
19
- action: f.UPLOAD_ASSET,
20
- data: { file: r, folderId: c, name: t }
15
+ file: i,
16
+ folderId: d,
17
+ name: u
18
+ }) => o(t, {
19
+ action: y.UPLOAD_ASSET,
20
+ data: { file: i, folderId: d, name: u }
21
21
  }),
22
22
  onSuccess: () => {
23
- n.invalidateQueries({
24
- queryKey: [f.GET_ASSETS]
25
- }), N.success("Asset uploaded successfully");
23
+ r.invalidateQueries({
24
+ queryKey: [y.GET_ASSETS]
25
+ }), b.success("Asset uploaded successfully");
26
26
  },
27
27
  onError: () => {
28
- N.error("Failed to upload asset");
28
+ b.error("Failed to upload asset");
29
29
  }
30
30
  });
31
- }, Ue = () => {
32
- const l = z(), n = B(), o = M();
33
- return Q({
34
- mutationFn: async (r) => o(l, {
35
- action: f.DELETE_ASSET,
36
- data: { id: r }
31
+ }, Me = () => {
32
+ const t = z(), r = Q(), o = F();
33
+ return R({
34
+ mutationFn: async (i) => o(t, {
35
+ action: y.DELETE_ASSET,
36
+ data: { id: i }
37
37
  }),
38
38
  onSuccess: () => {
39
- n.invalidateQueries({
40
- queryKey: [f.GET_ASSETS]
41
- }), N.success("Asset deleted successfully");
39
+ r.invalidateQueries({
40
+ queryKey: [y.GET_ASSETS]
41
+ }), b.success("Asset deleted successfully");
42
42
  },
43
43
  onError: () => {
44
- N.error("Failed to delete asset");
44
+ b.error("Failed to delete asset");
45
45
  }
46
46
  });
47
- }, Fe = () => {
48
- const l = z(), n = B(), o = M();
49
- return Q({
50
- mutationFn: async (r) => o(l, {
51
- action: f.UPDATE_ASSET,
52
- data: r
47
+ }, Ie = () => {
48
+ const t = z(), r = Q(), o = F();
49
+ return R({
50
+ mutationFn: async (i) => o(t, {
51
+ action: y.UPDATE_ASSET,
52
+ data: i
53
53
  }),
54
54
  onSuccess: () => {
55
- n.invalidateQueries({
56
- queryKey: [f.GET_ASSETS]
57
- }), N.success("Asset updated successfully");
55
+ r.invalidateQueries({
56
+ queryKey: [y.GET_ASSETS]
57
+ }), b.success("Asset updated successfully");
58
58
  },
59
59
  onError: () => {
60
- N.error("Failed to update asset");
60
+ b.error("Failed to update asset");
61
61
  }
62
62
  });
63
- }, ze = (l = {}) => {
64
- const n = z(), o = M(), { search: r, limit: c = 10 } = l;
65
- return Ee({
66
- queryKey: [Ce, f.GET_ASSETS, { search: r, limit: c }],
67
- queryFn: async ({ pageParam: t = 1 }) => (await o(n, {
68
- action: f.GET_ASSETS,
63
+ }, ke = (t = {}) => {
64
+ const r = z(), o = F(), { search: i, page: d = 1, limit: u = 10 } = t;
65
+ return Ue({
66
+ queryKey: [ze, y.GET_ASSETS, i, d, u],
67
+ queryFn: async () => (await o(r, {
68
+ action: y.GET_ASSETS,
69
69
  data: {
70
- search: r,
71
- page: t,
72
- limit: c
70
+ search: i,
71
+ page: d,
72
+ limit: u
73
73
  }
74
74
  })).data,
75
- initialPageParam: 1,
76
- getNextPageParam: (t) => ((t == null ? void 0 : t.page) ?? 0) * ((t == null ? void 0 : t.pageSize) ?? 0) < ((t == null ? void 0 : t.total) ?? 0) ? (t.page ?? 0) + 1 : void 0,
77
- getPreviousPageParam: (t) => (t.page ?? 0) > 1 ? (t.page ?? 0) - 1 : void 0,
78
75
  retry: 1
79
76
  });
80
77
  };
81
- function Me() {
82
- const [n, o] = T([]), [r, c] = T({
78
+ function qe() {
79
+ const [r, o] = S([]), [i, d] = S({
83
80
  query: "",
81
+ page: 1,
84
82
  pageSize: 10
85
- }), t = fe(() => r.query, 300)(), {
86
- data: d,
87
- isLoading: S,
88
- fetchNextPage: w,
89
- hasNextPage: u,
90
- isFetchingNextPage: g
91
- } = ze({
92
- search: (t == null ? void 0 : t.toLowerCase().trim()) || "",
93
- limit: r.pageSize
94
- }), D = (d == null ? void 0 : d.pages.flatMap((p) => p.assets)) || [], { mutate: x, isPaused: h } = Fe(), { mutate: A, isPending: y } = Te(), { mutate: b, isPending: U } = Ue(), I = C(() => {
95
- u && !g && w();
96
- }, [w, u, g]), E = C((p) => {
97
- c((m) => ({
98
- ...m,
99
- query: p
83
+ }), u = Ne(() => i.query, 300)(), { data: n, isLoading: C } = ke({
84
+ search: (u == null ? void 0 : u.toLowerCase().trim()) || "",
85
+ page: i.page,
86
+ limit: i.pageSize
87
+ }), v = n ? Math.ceil(n.total / n.pageSize) : 0, c = (n == null ? void 0 : n.page) || 1, g = c < v, m = c > 1, { mutate: E, isPending: M } = Ie(), { mutate: w, isPending: p } = Fe(), { mutate: T, isPending: D } = Me(), x = A(
88
+ (h) => {
89
+ h >= 1 && h <= v && d((N) => ({
90
+ ...N,
91
+ page: h
92
+ }));
93
+ },
94
+ [v]
95
+ ), I = A(() => {
96
+ g && x(c + 1);
97
+ }, [c, g, x]), k = A(() => {
98
+ m && x(c - 1);
99
+ }, [c, m, x]), q = A((h) => {
100
+ d((N) => ({
101
+ ...N,
102
+ query: h,
103
+ page: 1
104
+ // Reset to first page on new search
100
105
  }));
101
- }, []), k = C(
102
- (p) => {
103
- o((m) => ge(m, { id: p.id }) ? [] : [p]);
106
+ }, []), P = A(
107
+ (h) => {
108
+ o((N) => Ae(N, { id: h.id }) ? [] : [h]);
104
109
  },
105
110
  [!1]
106
- ), q = C(() => {
111
+ ), j = A(() => {
107
112
  o([]);
108
113
  }, []);
109
114
  return {
110
115
  // Data
111
- query: (r == null ? void 0 : r.query) || "",
112
- selectedAssets: n,
113
- assets: D,
114
- hasNextPage: u,
115
- isFetchingNextPage: g,
116
+ query: (i == null ? void 0 : i.query) || "",
117
+ selectedAssets: r,
118
+ assets: (n == null ? void 0 : n.assets) || [],
119
+ currentPage: c,
120
+ totalPages: v,
121
+ hasNextPage: g,
122
+ hasPreviousPage: m,
116
123
  // Mutations
117
- uploadAsset: A,
118
- updateAsset: x,
119
- deleteAsset: b,
120
- loadMoreAssets: I,
121
- updateSearchQuery: E,
122
- clearSelectedAssets: q,
123
- updateSelectedAssets: k,
124
+ uploadAsset: w,
125
+ updateAsset: E,
126
+ deleteAsset: T,
127
+ goToPage: x,
128
+ nextPage: I,
129
+ previousPage: k,
130
+ updateSearchQuery: q,
131
+ clearSelectedAssets: j,
132
+ updateSelectedAssets: P,
124
133
  // Loading
125
- isLoadingAssets: S,
126
- isUploadingAsset: y,
127
- isUpdatingAsset: h,
128
- isDeletingAsset: U
134
+ isLoadingAssets: C,
135
+ isUploadingAsset: p,
136
+ isUpdatingAsset: M,
137
+ isDeletingAsset: D
129
138
  };
130
139
  }
131
- const De = W.lazy(() => import("./asset-metadata-editor-CEFwXx62.js")), Ie = W.lazy(() => import("./image-editor-BQ6_F-iv.js"));
132
- function Oe({
133
- close: l,
134
- onSelect: n,
140
+ const je = W.lazy(() => import("./asset-metadata-editor-r5vYHUfm.js")), _e = W.lazy(() => import("./image-editor-CwVua57o.js"));
141
+ function Xe({
142
+ close: t,
143
+ onSelect: r,
135
144
  mode: o = "image"
136
145
  }) {
137
- const c = ne(() => [o], [o]), [t, d] = T("browse"), [S, w] = T(null), [u, g] = T({ show: !1, file: "", name: "" }), {
146
+ const d = re(() => [o], [o]), [u, n] = S("browse"), [C, v] = S(null), [c, g] = S(null), [m, E] = S({ show: !1, file: "" }), {
138
147
  // Data
139
- query: D,
140
- assets: x,
141
- selectedAssets: h,
142
- hasNextPage: A,
143
- isFetchingNextPage: y,
148
+ query: M,
149
+ assets: w,
150
+ selectedAssets: p,
144
151
  // Mutations
145
- uploadAsset: b,
146
- updateAsset: U,
147
- deleteAsset: I,
148
- loadMoreAssets: E,
149
- updateSearchQuery: k,
150
- clearSelectedAssets: q,
151
- updateSelectedAssets: p,
152
+ uploadAsset: T,
153
+ updateAsset: D,
154
+ deleteAsset: x,
155
+ updateSearchQuery: I,
156
+ clearSelectedAssets: k,
157
+ updateSelectedAssets: q,
152
158
  // Loading
153
- isLoadingAssets: m,
154
- isUploadingAsset: R,
155
- isUpdatingAsset: X
159
+ isLoadingAssets: P,
160
+ isUploadingAsset: j,
161
+ isUpdatingAsset: h
156
162
  // isDeletingAsset,
157
- } = Me(), G = oe(null);
158
- ce(() => {
159
- const s = G.current;
160
- if (!s) return;
161
- const i = () => {
162
- s.scrollHeight - s.scrollTop <= s.clientHeight * 1.5 && !m && A && !y && E();
163
- };
164
- return s.addEventListener("scroll", i), () => s.removeEventListener("scroll", i);
165
- }, [m, E, A, y]);
166
- const Z = C(
167
- async (s) => new Promise((i, L) => {
168
- const K = s[0], F = new FileReader();
169
- F.readAsDataURL(K), F.onload = async () => {
170
- const P = await b({
171
- file: F.result,
163
+ } = qe(), N = oe(null), K = A(
164
+ async (s) => new Promise((l, _) => {
165
+ const G = s[0], U = new FileReader();
166
+ U.readAsDataURL(G), U.onload = async () => {
167
+ const L = await T({
168
+ file: U.result,
172
169
  folderId: null,
173
- name: K.name
170
+ name: G.name
174
171
  });
175
- d("browse"), i(P);
176
- }, F.onerror = (P) => L(P);
172
+ n("browse"), l(L);
173
+ }, U.onerror = (L) => _(L);
177
174
  }),
178
- [b]
179
- ), { getRootProps: J, getInputProps: $, isDragActive: ee } = be({
180
- onDrop: Z,
175
+ [T]
176
+ ), { getRootProps: X, getInputProps: Z, isDragActive: J } = Pe({
177
+ onDrop: K,
181
178
  accept: {
182
- "image/*": c.includes("image") ? [] : [],
183
- "video/*": c.includes("video") ? [] : []
179
+ "image/*": d.includes("image") ? [] : [],
180
+ "video/*": d.includes("video") ? [] : []
184
181
  },
185
182
  maxSize: 10 * 1024 * 1024
186
- }), se = () => {
187
- n([h[0].url]), l();
188
- }, ae = async (s) => {
189
- await I(s.id);
183
+ }), ee = () => {
184
+ r([p[0].url]), t();
185
+ }, se = async (s) => {
186
+ g(s);
187
+ }, ae = async () => {
188
+ c && (await x(c.id), g(null));
190
189
  }, te = (s) => {
191
- w(s);
192
- }, le = async (s, i) => {
193
- await U(ve(s, i)), l();
190
+ v(s);
191
+ }, le = async (s, l) => {
192
+ await D(we(s, l)), t();
194
193
  }, ie = (s) => {
195
- k(s.target.value);
196
- }, re = async (s, i) => {
194
+ I(s.target.value);
195
+ }, ne = async (s, l) => {
197
196
  try {
198
- i ? await b({
197
+ l ? await T({
199
198
  file: s,
200
199
  folderId: null,
201
- name: u.name
202
- }) : await U({ id: u.id, file: s }), g({ show: !1, file: "", name: "" }), d("browse");
203
- } catch (L) {
204
- console.error("Error saving edited image:", L);
200
+ name: m.name || ""
201
+ }) : await D({
202
+ id: m.id || "",
203
+ file: s
204
+ }), E({ show: !1, file: "" }), n("browse");
205
+ } catch (_) {
206
+ console.error("Error saving edited image:", _);
205
207
  }
206
208
  };
207
- return /* @__PURE__ */ a(j, { children: [
209
+ return /* @__PURE__ */ a(B, { children: [
208
210
  /* @__PURE__ */ a("div", { className: "min-w-[700px] min-h-[600px] w-[900px] max-w-[900px]", children: [
209
211
  /* @__PURE__ */ e("h1", { className: "text-lg font-medium pb-4", children: "Digital Asset Manager" }),
210
212
  /* @__PURE__ */ a(
211
- de,
213
+ ce,
212
214
  {
213
- value: t,
214
- onValueChange: (s) => d(s),
215
+ value: u,
216
+ onValueChange: (s) => n(s),
215
217
  className: "flex-1 flex flex-col h-full",
216
218
  children: [
217
219
  /* @__PURE__ */ a("div", { className: "flex justify-between items-center mb-2", children: [
218
- /* @__PURE__ */ a(ue, { children: [
219
- /* @__PURE__ */ e(H, { value: "browse", children: "Browse Assets" }),
220
- /* @__PURE__ */ e(H, { value: "upload", children: "Upload" })
220
+ /* @__PURE__ */ a(de, { children: [
221
+ /* @__PURE__ */ e($, { value: "browse", children: "Browse Assets" }),
222
+ /* @__PURE__ */ e($, { value: "upload", children: "Upload" })
221
223
  ] }),
222
224
  /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
223
- h.length > 0 && /* @__PURE__ */ e(j, { children: /* @__PURE__ */ e(
224
- v,
225
+ p.length > 0 && /* @__PURE__ */ e(B, { children: /* @__PURE__ */ e(
226
+ f,
225
227
  {
226
228
  variant: "outline",
227
229
  size: "sm",
228
- onClick: () => q(),
230
+ onClick: () => k(),
229
231
  title: "Clear selection",
230
232
  children: "Clear"
231
233
  }
232
234
  ) }),
233
235
  /* @__PURE__ */ e(
234
- v,
236
+ f,
235
237
  {
236
238
  size: "sm",
237
- onClick: se,
238
- disabled: h.length === 0,
239
+ onClick: ee,
240
+ disabled: p.length === 0,
239
241
  children: "Select Asset"
240
242
  }
241
243
  )
242
244
  ] })
243
245
  ] }),
244
- /* @__PURE__ */ a(V, { value: "browse", className: "flex-1 flex flex-col", children: [
246
+ /* @__PURE__ */ a(H, { value: "browse", className: "flex-1 flex flex-col", children: [
245
247
  /* @__PURE__ */ e("div", { className: "flex items-center gap-2 mb-2", children: /* @__PURE__ */ a("div", { className: "relative w-full", children: [
246
- /* @__PURE__ */ e(xe, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
248
+ /* @__PURE__ */ e(Se, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
247
249
  /* @__PURE__ */ e(
248
- me,
250
+ ue,
249
251
  {
250
252
  placeholder: "Search assets...",
251
- value: D,
253
+ value: M,
252
254
  onChange: ie,
253
255
  className: "pl-8"
254
256
  }
255
257
  )
256
258
  ] }) }),
257
- m && x.length === 0 ? /* @__PURE__ */ a("div", { className: "grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-2 overflow-y-auto max-h-[550px] p-1", children: [
259
+ P && w.length === 0 ? /* @__PURE__ */ a("div", { className: "grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-2 overflow-y-auto max-h-[550px] p-1", children: [
258
260
  /* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
259
261
  /* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
260
262
  /* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
@@ -265,37 +267,37 @@ function Oe({
265
267
  /* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
266
268
  /* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
267
269
  /* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" })
268
- ] }) : x.length === 0 ? /* @__PURE__ */ a("div", { className: "flex flex-col items-center justify-center h-full text-center p-12 h-[380px]", children: [
270
+ ] }) : w.length === 0 ? /* @__PURE__ */ a("div", { className: "flex flex-col items-center justify-center h-full text-center p-12 h-[380px]", children: [
269
271
  /* @__PURE__ */ a("div", { className: "text-muted-foreground mb-2", children: [
270
272
  /* @__PURE__ */ e("h3", { className: "text-gray-800 font-medium", children: "No assets to display" }),
271
273
  /* @__PURE__ */ e("p", { className: "text-sm", children: "You haven't uploaded any assets yet. Start by uploading your first asset." })
272
274
  ] }),
273
- /* @__PURE__ */ e("div", { className: "flex gap-2 pt-4", children: /* @__PURE__ */ e(v, { size: "lg", onClick: () => d("upload"), children: "Upload Assets" }) })
275
+ /* @__PURE__ */ e("div", { className: "flex gap-2 pt-4", children: /* @__PURE__ */ e(f, { size: "lg", onClick: () => n("upload"), children: "Upload Assets" }) })
274
276
  ] }) : /* @__PURE__ */ a(
275
277
  "div",
276
278
  {
277
- ref: G,
279
+ ref: N,
278
280
  className: "grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-2 overflow-y-auto max-h-[550px] p-1",
279
281
  children: [
280
- x.map((s) => /* @__PURE__ */ e(
281
- he,
282
+ w.map((s) => /* @__PURE__ */ e(
283
+ me,
282
284
  {
283
- className: O(
285
+ className: Y(
284
286
  "cursor-pointer overflow-hidden transition-all",
285
- h.some((i) => i.id === s.id) ? "ring-2 ring-primary" : "hover:ring-2 hover:ring-primary/20"
287
+ p.some((l) => l.id === s.id) ? "ring-2 ring-primary" : "hover:ring-2 hover:ring-primary/20"
286
288
  ),
287
- onClick: () => p(s),
288
- children: /* @__PURE__ */ a(pe, { className: "p-0 relative group", children: [
289
+ onClick: () => q(s),
290
+ children: /* @__PURE__ */ a(he, { className: "p-0 relative group", children: [
289
291
  /* @__PURE__ */ a("div", { className: "aspect-square relative overflow-hidden bg-muted", children: [
290
292
  s.type === "image" ? /* @__PURE__ */ e(
291
293
  "img",
292
294
  {
293
- src: s.url || "/placeholder.svg",
295
+ src: s.thumbnailUrl || "/placeholder.svg",
294
296
  alt: s.name,
295
297
  className: "object-cover w-full h-full"
296
298
  }
297
299
  ) : /* @__PURE__ */ a("div", { className: "flex items-center justify-center h-full", children: [
298
- /* @__PURE__ */ e(ye, { className: "h-12 w-12 text-muted-foreground" }),
300
+ /* @__PURE__ */ e(be, { className: "h-12 w-12 text-muted-foreground" }),
299
301
  s.thumbnailUrl && /* @__PURE__ */ e(
300
302
  "img",
301
303
  {
@@ -307,53 +309,53 @@ function Oe({
307
309
  ] }),
308
310
  /* @__PURE__ */ a("div", { className: "absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2", children: [
309
311
  /* @__PURE__ */ e(
310
- v,
312
+ f,
311
313
  {
312
314
  variant: "secondary",
313
315
  size: "icon",
314
316
  className: "h-8 w-8",
315
- onClick: (i) => {
316
- i.stopPropagation(), te(s);
317
+ onClick: (l) => {
318
+ l.stopPropagation(), te(s);
317
319
  },
318
- children: /* @__PURE__ */ e(Ne, { className: "h-4 w-4" })
320
+ children: /* @__PURE__ */ e(Ce, { className: "h-4 w-4" })
319
321
  }
320
322
  ),
321
323
  /* @__PURE__ */ e(
322
- v,
324
+ f,
323
325
  {
324
326
  variant: "secondary",
325
327
  size: "icon",
326
328
  className: "h-8 w-8",
327
- onClick: (i) => {
328
- i.stopPropagation(), g({
329
+ onClick: (l) => {
330
+ l.stopPropagation(), E({
329
331
  id: s.id,
330
332
  show: !0,
331
333
  file: s.url,
332
334
  name: s.name
333
335
  });
334
336
  },
335
- children: /* @__PURE__ */ e(Se, { className: "h-4 w-4" })
337
+ children: /* @__PURE__ */ e(Ee, { className: "h-4 w-4" })
336
338
  }
337
339
  ),
338
340
  /* @__PURE__ */ e(
339
- v,
341
+ f,
340
342
  {
341
343
  variant: "destructive",
342
344
  size: "icon",
343
345
  className: "h-8 w-8",
344
- onClick: (i) => {
345
- i.stopPropagation(), ae(s);
346
+ onClick: (l) => {
347
+ l.stopPropagation(), se(s);
346
348
  },
347
- children: /* @__PURE__ */ e(we, { className: "h-4 w-4" })
349
+ children: /* @__PURE__ */ e(Te, { className: "h-4 w-4" })
348
350
  }
349
351
  )
350
352
  ] }),
351
- h.some((i) => i.id === s.id) && /* @__PURE__ */ e("div", { className: "absolute top-2 left-2", children: /* @__PURE__ */ e(
353
+ p.some((l) => l.id === s.id) && /* @__PURE__ */ e("div", { className: "absolute top-2 left-2", children: /* @__PURE__ */ e(
352
354
  "input",
353
355
  {
354
356
  type: "checkbox",
355
- checked: h.some(
356
- (i) => i.id === s.id
357
+ checked: p.some(
358
+ (l) => l.id === s.id
357
359
  ),
358
360
  readOnly: !0,
359
361
  className: "rounded-full"
@@ -370,54 +372,41 @@ function Oe({
370
372
  }
371
373
  ),
372
374
  /* @__PURE__ */ a("div", { className: "text-xs text-muted-foreground flex items-center justify-between", children: [
373
- /* @__PURE__ */ e("span", { children: ke((s == null ? void 0 : s.size) || 0) }),
374
- /* @__PURE__ */ e("span", { children: qe(s.createdAt) })
375
+ /* @__PURE__ */ e("span", { children: Le((s == null ? void 0 : s.size) || 0) }),
376
+ /* @__PURE__ */ e("span", { children: Be(s.createdAt) })
375
377
  ] })
376
378
  ] })
377
379
  ] })
378
380
  },
379
381
  s.id
380
382
  )),
381
- m && x.length > 0 && /* @__PURE__ */ e("div", { className: "col-span-full flex justify-center py-4", children: /* @__PURE__ */ e(_, { className: "h-6 w-6 animate-spin text-muted-foreground" }) }),
382
- !m && A && /* @__PURE__ */ e("div", { className: "col-span-full flex justify-center py-4", children: /* @__PURE__ */ a(
383
- v,
384
- {
385
- variant: "outline",
386
- onClick: () => E(),
387
- disabled: y,
388
- className: "flex items-center gap-2",
389
- children: [
390
- y ? /* @__PURE__ */ e(_, { className: "h-4 w-4 animate-spin" }) : null,
391
- "Load More"
392
- ]
393
- }
394
- ) })
383
+ P && w.length > 0 && /* @__PURE__ */ e("div", { className: "col-span-full flex justify-center py-4", children: /* @__PURE__ */ e(V, { className: "h-6 w-6 animate-spin text-muted-foreground" }) })
395
384
  ]
396
385
  }
397
386
  )
398
387
  ] }),
399
- /* @__PURE__ */ e(V, { value: "upload", className: "flex-1 ", children: /* @__PURE__ */ a(
388
+ /* @__PURE__ */ e(H, { value: "upload", className: "flex-1 ", children: /* @__PURE__ */ a(
400
389
  "div",
401
390
  {
402
- ...J(),
403
- className: O(
391
+ ...X(),
392
+ className: Y(
404
393
  "border-2 border-dashed rounded-lg h-[380px] flex flex-col items-center justify-center text-center cursor-pointer hover:bg-gray-50",
405
- ee ? "border-primary bg-primary/5" : "border-muted-foreground/20"
394
+ J ? "border-primary bg-primary/5" : "border-muted-foreground/20"
406
395
  ),
407
396
  children: [
408
- /* @__PURE__ */ e("input", { ...$() }),
409
- X || R ? /* @__PURE__ */ a("div", { className: "flex flex-col items-center", children: [
410
- /* @__PURE__ */ e(_, { className: "h-12 w-12 text-primary animate-spin mb-4" }),
397
+ /* @__PURE__ */ e("input", { ...Z() }),
398
+ h || j ? /* @__PURE__ */ a("div", { className: "flex flex-col items-center", children: [
399
+ /* @__PURE__ */ e(V, { className: "h-12 w-12 text-primary animate-spin mb-4" }),
411
400
  /* @__PURE__ */ e("h3", { className: "text-lg font-medium mb-1", children: "Uploading files..." }),
412
401
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: "Please wait while your files are being processed." })
413
- ] }) : /* @__PURE__ */ a(j, { children: [
414
- /* @__PURE__ */ e(Ae, { className: "h-12 w-12 text-muted-foreground mb-4" }),
402
+ ] }) : /* @__PURE__ */ a(B, { children: [
403
+ /* @__PURE__ */ e(De, { className: "h-12 w-12 text-muted-foreground mb-4" }),
415
404
  /* @__PURE__ */ e("h3", { className: "text-lg font-medium mb-1", children: "Drag & drop files here" }),
416
405
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground mb-4", children: "or click to browse your files" }),
417
406
  /* @__PURE__ */ a("div", { className: "text-xs text-muted-foreground", children: [
418
407
  /* @__PURE__ */ a("p", { children: [
419
408
  "Accepted file types: ",
420
- c.join(", ")
409
+ d.join(", ")
421
410
  ] }),
422
411
  /* @__PURE__ */ a("p", { children: [
423
412
  "Maximum file size: ",
@@ -433,39 +422,60 @@ function Oe({
433
422
  }
434
423
  )
435
424
  ] }),
436
- S && /* @__PURE__ */ e(Y, { fallback: /* @__PURE__ */ e("div", { children: "Loading..." }), children: /* @__PURE__ */ e(
437
- De,
425
+ C && /* @__PURE__ */ e(O, { fallback: /* @__PURE__ */ e("div", { children: "Loading..." }), children: /* @__PURE__ */ e(
426
+ je,
438
427
  {
439
- asset: S,
440
- onSave: (s) => le(S, s),
428
+ asset: C,
429
+ onSave: (s) => le(C, s),
441
430
  onCancel: () => {
442
- w(null);
431
+ v(null);
443
432
  }
444
433
  }
445
434
  ) }),
446
- u.show && /* @__PURE__ */ e(Y, { fallback: /* @__PURE__ */ e("div", { children: "Loading..." }), children: /* @__PURE__ */ e(
447
- Ie,
435
+ m.show && /* @__PURE__ */ e(O, { fallback: /* @__PURE__ */ e("div", { children: "Loading..." }), children: /* @__PURE__ */ e(
436
+ _e,
437
+ {
438
+ imageUrl: m.file,
439
+ onSave: ne,
440
+ onClose: () => E({ show: !1, file: "" }),
441
+ defaultSavedImageName: m.name,
442
+ isEditing: !!m.id
443
+ }
444
+ ) }),
445
+ c && /* @__PURE__ */ e(
446
+ ge,
448
447
  {
449
- imageUrl: u.file,
450
- onSave: re,
451
- onClose: () => g({ show: !1, file: "", name: "" }),
452
- defaultSavedImageName: u.name,
453
- isEditing: !!u.id
448
+ open: !!c,
449
+ onOpenChange: () => g(null),
450
+ children: /* @__PURE__ */ a(pe, { children: [
451
+ /* @__PURE__ */ a(fe, { children: [
452
+ /* @__PURE__ */ e(ye, { children: "Delete Asset" }),
453
+ /* @__PURE__ */ a(ve, { children: [
454
+ 'Are you sure you want to delete "',
455
+ c.name,
456
+ '"? This action cannot be undone.'
457
+ ] })
458
+ ] }),
459
+ /* @__PURE__ */ a(xe, { className: "gap-2 sm:gap-0", children: [
460
+ /* @__PURE__ */ e(f, { variant: "outline", onClick: () => g(null), children: "Cancel" }),
461
+ /* @__PURE__ */ e(f, { variant: "destructive", onClick: ae, children: "Delete" })
462
+ ] })
463
+ ] })
454
464
  }
455
- ) })
465
+ )
456
466
  ] });
457
467
  }
458
- function ke(l) {
459
- return l < 1024 ? l + " B" : l < 1024 * 1024 ? (l / 1024).toFixed(1) + " KB" : l < 1024 * 1024 * 1024 ? (l / (1024 * 1024)).toFixed(1) + " MB" : (l / (1024 * 1024 * 1024)).toFixed(1) + " GB";
468
+ function Le(t) {
469
+ return t < 1024 ? `${t.toFixed(2)} KB` : `${(t / 1024).toFixed(2)} MB`;
460
470
  }
461
- function qe(l) {
462
- const n = new Date(l);
471
+ function Be(t) {
472
+ const r = new Date(t);
463
473
  return new Intl.DateTimeFormat("en-US", {
464
474
  month: "short",
465
475
  day: "numeric",
466
476
  year: "numeric"
467
- }).format(n);
477
+ }).format(r);
468
478
  }
469
479
  export {
470
- Oe as default
480
+ Xe as default
471
481
  };