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