@chaibuilder/sdk 4.0.0-beta.1 → 4.0.0-beta.3
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/README.md +27 -20
- package/dist/2SSKDMRQ-BnsZi3K3.cjs +1 -0
- package/dist/2SSKDMRQ-CnSDkQcy.js +42 -0
- package/dist/AP7HFJJL-B31839PG.cjs +1228 -0
- package/dist/AP7HFJJL-CymCmW14.js +9214 -0
- package/dist/IconPicker-B1rWC-Ex.js +59 -0
- package/dist/IconPicker-DREyo007.cjs +1 -0
- package/dist/WDYDFRGG-BUVnbAci.js +33 -0
- package/dist/WDYDFRGG-BxhOCHc3.cjs +1 -0
- package/dist/_commonjsHelpers-C6fGbg64.js +6 -0
- package/dist/_commonjsHelpers-DwGv2jUC.cjs +1 -0
- package/dist/actions-registery-CZ1w0NKa.js +15545 -0
- package/dist/actions-registery-YnFmU21O.cjs +418 -0
- package/dist/actions.cjs +1 -0
- package/dist/actions.d.ts +3202 -0
- package/dist/actions.js +216 -0
- package/dist/active-in-another-tab-B47YjQGN.cjs +1 -0
- package/dist/active-in-another-tab-CyjngVA6.js +34 -0
- package/dist/add-new-language-page-88xzrUy8.cjs +1 -0
- package/dist/add-new-language-page-WmlCnytQ.js +401 -0
- package/dist/add-new-page-VW2wAYZp.js +31 -0
- package/dist/add-new-page-soZ8GAkN.cjs +1 -0
- package/dist/ai-panel-content-7zCil042.cjs +1 -0
- package/dist/ai-panel-content-D_o7Q_A-.js +61 -0
- package/dist/ai-panel-default-lang-COYaxNwn.cjs +3 -0
- package/dist/ai-panel-default-lang-DnElspF0.js +341 -0
- package/dist/ai-panel-other-lang-CkynNlAU.cjs +1 -0
- package/dist/ai-panel-other-lang-Dp0E9_Hx.js +162 -0
- package/dist/ai-prompt-input-Bhc0ds7X.js +655 -0
- package/dist/ai-prompt-input-CThbVp0_.cjs +1 -0
- package/dist/ai-translation-prompt-C2kJQFDX.cjs +1 -0
- package/dist/ai-translation-prompt-CZ55HQmo.js +28 -0
- package/dist/apply-binding-6iwlED02.js +833 -0
- package/dist/apply-binding-KKp5PnpZ.cjs +1 -0
- package/dist/code-display-BnqzqzoP.cjs +1 -0
- package/dist/{code-display-337R7Dev.js → code-display-DhD_RBcg.js} +1 -1
- package/dist/code-editor-DRIAnNbb.js +50 -0
- package/dist/code-editor-o3___nu2.cjs +1 -0
- package/dist/common-functions-B3a4xKt_.cjs +1 -0
- package/dist/common-functions-D2lMFR6K.js +13 -0
- package/dist/continue-editing-in-this-client-CS2aQ7yY.js +24 -0
- package/dist/continue-editing-in-this-client-CtMYsk-A.cjs +1 -0
- package/dist/core-BoRDjj4h.cjs +1 -0
- package/dist/core-yvI6kCyw.js +56 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +51 -383
- package/dist/core.js +39 -106
- package/dist/{css-import-modal-DA2L6kwP.js → css-import-modal-Byg6wV0O.js} +36 -36
- package/dist/css-import-modal-CyqkXWCO.cjs +13 -0
- package/dist/delete-design-token-BRZZiWtQ.js +40 -0
- package/dist/delete-design-token-DkVs1oBf.cjs +1 -0
- package/dist/delete-page-BzyX9TN-.js +70 -0
- package/dist/delete-page-DxX7PFIE.cjs +1 -0
- package/dist/design-token-usage-CAHzEGgJ.cjs +1 -0
- package/dist/design-token-usage-xQs6SlaJ.js +113 -0
- package/dist/digital-asset-manager--uO8Agia.cjs +1 -0
- package/dist/digital-asset-manager-DbtwzxRz.js +876 -0
- package/dist/duplicate-page-BR7Dlo9d.js +133 -0
- package/dist/duplicate-page-CaNAbXwV.cjs +1 -0
- package/dist/dynamic-page-selector-Cb5r_W8s.js +85 -0
- package/dist/dynamic-page-selector-Cxk_gjni.cjs +1 -0
- package/dist/fonts-B-Xt29pe.cjs +1 -0
- package/dist/fonts-DRly3Wzd.js +78 -0
- package/dist/{get-chai-builder-tailwind-config-C6MHaUM0.cjs → get-chai-builder-tailwind-config-B9rCyiQo.cjs} +1 -1
- package/dist/{get-chai-builder-tailwind-config-BqaIvg8p.js → get-chai-builder-tailwind-config-DjoVOuAf.js} +13 -10
- package/dist/{get-chai-builder-theme-D0IsUvK4.js → get-chai-builder-theme-BYtp20KD.js} +4 -4
- package/dist/get-chai-builder-theme-Dl72X7cz.cjs +1 -0
- package/dist/get-seo-defaults-9zHebckY.js +65 -0
- package/dist/get-seo-defaults-Cw7vFt-B.cjs +1 -0
- package/dist/image-compression-DZ9WMmyn.cjs +1 -0
- package/dist/image-compression-DsZ1oqpb.js +37 -0
- package/dist/image-editor-DV8kUKhl.js +108 -0
- package/dist/image-editor-G-K28aTS.cjs +1 -0
- package/dist/index-B-rSiAp_.cjs +1 -0
- package/dist/index-Ct7ElCGK.js +19069 -0
- package/dist/index-DF5DEvqb.cjs +160 -0
- package/dist/index-Dxfyt4d4.js +39 -0
- package/dist/index-WQwzsC7A.cjs +5 -0
- package/dist/index-ZuacEL1j.js +4732 -0
- package/dist/json-diff-viewer-D7z4zNvv.cjs +8 -0
- package/dist/json-diff-viewer-krslPepD.js +258 -0
- package/dist/lang-panel-BwIewMyw.js +215 -0
- package/dist/lang-panel-DT96k1xg.cjs +1 -0
- package/dist/manage-design-tokens-Caz_20VK.js +240 -0
- package/dist/manage-design-tokens-CrmLe7UT.cjs +1 -0
- package/dist/mark-as-template-D295ZQtU.js +156 -0
- package/dist/mark-as-template-W3LmpiqN.cjs +1 -0
- package/dist/models-5gOsRC56.cjs +1 -0
- package/dist/models-D95ZYr_x.js +70 -0
- package/dist/nested-path-selector-content-CKYYK-C5.js +87 -0
- package/dist/nested-path-selector-content-CoS_d3dc.cjs +1 -0
- package/dist/no-language-page-content-BvqRBP6y.js +42 -0
- package/dist/no-language-page-content-DkfeMl90.cjs +1 -0
- package/dist/no-language-page-dialog-BcEoqyQB.cjs +1 -0
- package/dist/no-language-page-dialog-PjNqTUpl.js +10 -0
- package/dist/page-creator-C4gc5NSC.cjs +1 -0
- package/dist/page-creator-DiOITEMw.js +795 -0
- package/dist/page-lock-BdYmCks0.cjs +1 -0
- package/dist/page-lock-Bfbs6RgL.js +30 -0
- package/dist/page-locked-dialog-B1FAtK92.cjs +1 -0
- package/dist/page-locked-dialog-B6MKTRfY.js +133 -0
- package/dist/page-manager-new-CHDueBDk.cjs +1 -0
- package/dist/page-manager-new-CzX22g2n.js +394 -0
- package/dist/page-manager-search-and-filter-CM0UMb6U.js +201 -0
- package/dist/page-manager-search-and-filter-DkkRIH86.cjs +1 -0
- package/dist/page-revisions-content-ChY-4f2V.cjs +1 -0
- package/dist/page-revisions-content-NH9JK4Ey.js +445 -0
- package/dist/pages.cjs +1 -0
- package/dist/pages.d.ts +491 -0
- package/dist/pages.js +27 -0
- package/dist/plugin-3ZKK6RXm.js +245 -0
- package/dist/plugin-C6rgJDNQ.cjs +22 -0
- package/dist/publish-pages-content-D9aixMN5.js +178 -0
- package/dist/publish-pages-content-x-JuSFJ9.cjs +1 -0
- package/dist/register-partial-type-BjtdfKHE.js +36 -0
- package/dist/register-partial-type-ig9fUWIJ.cjs +1 -0
- package/dist/render.cjs +2 -2
- package/dist/render.d.ts +26 -13
- package/dist/render.js +130 -124
- package/dist/rte-widget-modal-BaHIuEjF.cjs +1 -0
- package/dist/rte-widget-modal-DOJEXLIf.js +38 -0
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.d.ts +306 -7
- package/dist/runtime.js +44 -1
- package/dist/save-to-lib-Cgpxw8-g.cjs +1 -0
- package/dist/save-to-lib-eiOc_SSN.js +422 -0
- package/dist/sdk.css +1 -1
- package/dist/selected-block-display-BgRY82CT.cjs +16 -0
- package/dist/selected-block-display-CBFePS19.js +319 -0
- package/dist/seo-panel-C1-iMOR1.js +798 -0
- package/dist/seo-panel-DfAb8U7W.cjs +2 -0
- package/dist/shared-json-ld-B4PxAM_0.js +565 -0
- package/dist/shared-json-ld-DzG398hr.cjs +1 -0
- package/dist/slug-input-AwNJs9im.js +86 -0
- package/dist/slug-input-C_ijLQ_X.cjs +1 -0
- package/dist/supabase-actions.cjs +1 -0
- package/dist/supabase-actions.d.ts +284 -0
- package/dist/supabase-actions.js +524 -0
- package/dist/take-over-request-BNxcjY2j.cjs +1 -0
- package/dist/take-over-request-C4FeDtN_.js +63 -0
- package/dist/theme-panel-footer-Cq9pljro.cjs +1 -0
- package/dist/theme-panel-footer-uBQqSJXm.js +25 -0
- package/dist/translation-warning-modal-B64YqlbI.js +26 -0
- package/dist/translation-warning-modal-BZAcwM2_.cjs +1 -0
- package/dist/unmark-as-template-CZ9sQp_P.js +39 -0
- package/dist/unmark-as-template-EVvk0vmp.cjs +1 -0
- package/dist/unpublish-page-D4VwOlxc.js +27 -0
- package/dist/unpublish-page-bdSmwAVQ.cjs +1 -0
- package/dist/use-page-expand-manager-B6XTvk0E.cjs +1 -0
- package/dist/use-page-expand-manager-Cf4MUEJw.js +85 -0
- package/dist/{tailwind.cjs → utils.cjs} +1 -1
- package/dist/{tailwind.d.ts → utils.d.ts} +12 -11
- package/dist/utils.js +7 -0
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.d.ts +0 -6
- package/dist/web-blocks.js +248 -241
- package/dist/web-preview-Cio70gk5.cjs +1 -0
- package/dist/web-preview-Djy6WIyj.js +73 -0
- package/package.json +175 -105
- package/dist/IconPicker-CGWn9C4u.cjs +0 -1
- package/dist/IconPicker-QvxJ-4Ez.js +0 -64
- package/dist/apply-binding-DCno1xQL.js +0 -711
- package/dist/apply-binding-DvHNFLQD.cjs +0 -1
- package/dist/code-display-BZ1x7SqI.cjs +0 -1
- package/dist/code-editor-B28LoECM.cjs +0 -1
- package/dist/code-editor-CfG2FhJ-.js +0 -58
- package/dist/common-functions-BGzDsf1z.js +0 -14
- package/dist/common-functions-BZmyleS1.cjs +0 -1
- package/dist/css-import-modal-CENUYvcl.cjs +0 -13
- package/dist/get-chai-builder-theme-Ck_Z4Q-M.cjs +0 -1
- package/dist/index-CaGNHF7f.js +0 -12209
- package/dist/index-Gn6pJt2v.cjs +0 -166
- package/dist/mockServiceWorker.js +0 -307
- package/dist/plugin-B5627hMN.js +0 -195
- package/dist/plugin-UxTRfDum.cjs +0 -22
- package/dist/rte-widget-modal-DL739qeQ.cjs +0 -1
- package/dist/rte-widget-modal-Dte0od04.js +0 -41
- package/dist/tailwind.js +0 -7
- package/dist/tooltip-A4qGk781.cjs +0 -1
- package/dist/tooltip-tLiIOgjq.js +0 -1067
- package/dist/ui.cjs +0 -1
- package/dist/ui.d.ts +0 -415
- package/dist/ui.js +0 -129
- package/dist/vite.svg +0 -1
|
@@ -0,0 +1,876 @@
|
|
|
1
|
+
import { jsxs as r, jsx as e, Fragment as H } from "react/jsx-runtime";
|
|
2
|
+
import { B as p, I as me, L as V, T as Fe, aw as _, w as q, x as P, y as G, D as Ue, d as Le, e as $e, f as Me, p as _e, q as qe, aj as Pe } from "./index-Ct7ElCGK.js";
|
|
3
|
+
import { f as Ge, c as Oe } from "./image-compression-DsZ1oqpb.js";
|
|
4
|
+
import { find as Be, merge as Ke, pick as Y, first as Qe, isEmpty as Re } from "lodash-es";
|
|
5
|
+
import { ChevronLeft as ue, ChevronRight as We, Loader as B, AlertCircle as Ve, Copy as he, Pencil as He, Link as Xe, Search as Ze, RefreshCwIcon as Je, Archive as Ye, Film as et, ImageIcon as tt, Edit as it, Trash2 as at, Check as lt, Upload as rt, AlertTriangle as nt } from "lucide-react";
|
|
6
|
+
import fe, { useState as y, useMemo as pe, useEffect as O, useCallback as M, Suspense as st } from "react";
|
|
7
|
+
import { useDropzone as ct } from "react-dropzone";
|
|
8
|
+
import { ErrorBoundary as ot } from "react-error-boundary";
|
|
9
|
+
import { useTranslation as ee } from "react-i18next";
|
|
10
|
+
import { toast as A } from "sonner";
|
|
11
|
+
import { useQueryClient as te, useMutation as ie, useQuery as ge } from "@tanstack/react-query";
|
|
12
|
+
import { ar as K, as as Q, A as b } from "./index-ZuacEL1j.js";
|
|
13
|
+
import { c as xe } from "./common-functions-D2lMFR6K.js";
|
|
14
|
+
const dt = () => {
|
|
15
|
+
const s = K(), n = te(), h = Q();
|
|
16
|
+
return ie({
|
|
17
|
+
mutationFn: async (a) => {
|
|
18
|
+
const c = a.map(async (l) => h(s, {
|
|
19
|
+
action: b.UPLOAD_ASSET,
|
|
20
|
+
data: l
|
|
21
|
+
}));
|
|
22
|
+
return await Promise.all(c);
|
|
23
|
+
},
|
|
24
|
+
onSuccess: (a) => {
|
|
25
|
+
var c;
|
|
26
|
+
if (a != null && a.some((i) => i.error))
|
|
27
|
+
throw new Error(((c = a == null ? void 0 : a.find((i) => i.error)) == null ? void 0 : c.error) || "Failed to upload asset");
|
|
28
|
+
{
|
|
29
|
+
n.invalidateQueries({
|
|
30
|
+
queryKey: [b.GET_ASSETS]
|
|
31
|
+
});
|
|
32
|
+
const i = a == null ? void 0 : a.length;
|
|
33
|
+
A.success(`${i === 1 ? "Asset" : i + " Assets"} uploaded successfully`);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
onError: () => {
|
|
37
|
+
A.error("Failed to upload asset");
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}, mt = () => {
|
|
41
|
+
const s = K(), n = te(), h = Q();
|
|
42
|
+
return ie({
|
|
43
|
+
mutationFn: async (a) => h(s, {
|
|
44
|
+
action: b.DELETE_ASSET,
|
|
45
|
+
data: { id: a }
|
|
46
|
+
}),
|
|
47
|
+
onSuccess: (a) => {
|
|
48
|
+
if (a != null && a.error)
|
|
49
|
+
throw new Error(a == null ? void 0 : a.error);
|
|
50
|
+
n.invalidateQueries({
|
|
51
|
+
queryKey: [b.GET_ASSETS]
|
|
52
|
+
}), A.success("Asset deleted successfully");
|
|
53
|
+
},
|
|
54
|
+
onError: () => {
|
|
55
|
+
A.error("Failed to delete asset");
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}, ut = () => {
|
|
59
|
+
const s = K(), n = te(), h = Q();
|
|
60
|
+
return ie({
|
|
61
|
+
mutationFn: async (a) => h(s, {
|
|
62
|
+
action: b.UPDATE_ASSET,
|
|
63
|
+
data: a
|
|
64
|
+
}),
|
|
65
|
+
onSuccess: (a) => {
|
|
66
|
+
if (a != null && a.error)
|
|
67
|
+
throw new Error(a == null ? void 0 : a.error);
|
|
68
|
+
n.invalidateQueries({
|
|
69
|
+
queryKey: [b.GET_ASSETS]
|
|
70
|
+
}), a != null && a.id && n.invalidateQueries({
|
|
71
|
+
queryKey: [b.GET_ASSET, a.id]
|
|
72
|
+
}), A.success("Asset updated successfully");
|
|
73
|
+
},
|
|
74
|
+
onError: () => {
|
|
75
|
+
A.error("Failed to update asset");
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
function ht({
|
|
80
|
+
currentPage: s,
|
|
81
|
+
totalPages: n,
|
|
82
|
+
onPageChange: h,
|
|
83
|
+
pageRangeDisplayed: a = 3,
|
|
84
|
+
showPageInput: c = !0,
|
|
85
|
+
className: i = ""
|
|
86
|
+
}) {
|
|
87
|
+
const [l, I] = y(String(s)), N = pe(() => {
|
|
88
|
+
const o = Math.floor(a / 2);
|
|
89
|
+
let m = Math.max(1, s - o), d = Math.min(n, s + o);
|
|
90
|
+
d - m + 1 < a && (m === 1 ? d = Math.min(n, m + a - 1) : d === n && (m = Math.max(1, d - a + 1)));
|
|
91
|
+
const f = [];
|
|
92
|
+
m > 1 && (f.push(1), m > 2 && f.push("..."));
|
|
93
|
+
for (let v = m; v <= d; v++)
|
|
94
|
+
f.push(v);
|
|
95
|
+
return d < n && (d < n - 1 && f.push("..."), f.push(n)), f;
|
|
96
|
+
}, [s, n, a]), x = (o) => {
|
|
97
|
+
o !== s && o >= 1 && o <= n && (h(o), I(String(o)));
|
|
98
|
+
}, g = () => {
|
|
99
|
+
s > 1 && x(s - 1);
|
|
100
|
+
}, w = () => {
|
|
101
|
+
s < n && x(s + 1);
|
|
102
|
+
}, C = () => {
|
|
103
|
+
const o = Number(l);
|
|
104
|
+
!isNaN(o) && o >= 1 && o <= n && x(o);
|
|
105
|
+
}, S = (o) => {
|
|
106
|
+
o.key === "Enter" && C();
|
|
107
|
+
};
|
|
108
|
+
return n <= 1 ? null : /* @__PURE__ */ r("div", { className: `flex flex-wrap items-center justify-center gap-3 ${i}`, children: [
|
|
109
|
+
/* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
110
|
+
/* @__PURE__ */ r(
|
|
111
|
+
p,
|
|
112
|
+
{
|
|
113
|
+
variant: "outline",
|
|
114
|
+
size: "sm",
|
|
115
|
+
onClick: g,
|
|
116
|
+
disabled: s === 1,
|
|
117
|
+
className: "px-2 py-1 text-sm hover:bg-gray-50",
|
|
118
|
+
children: [
|
|
119
|
+
/* @__PURE__ */ e(ue, { className: "h-4 w-4" }),
|
|
120
|
+
"Previous"
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
),
|
|
124
|
+
/* @__PURE__ */ e("div", { className: "flex items-center gap-2", children: N.map((o, m) => {
|
|
125
|
+
if (o === "...")
|
|
126
|
+
return /* @__PURE__ */ e("span", { className: "px-2 text-muted-foreground", children: "..." }, `ellipsis-${m}`);
|
|
127
|
+
const d = o, f = d === s;
|
|
128
|
+
return /* @__PURE__ */ e(
|
|
129
|
+
p,
|
|
130
|
+
{
|
|
131
|
+
variant: f ? "default" : "outline",
|
|
132
|
+
size: "sm",
|
|
133
|
+
onClick: () => x(d),
|
|
134
|
+
className: f ? "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",
|
|
135
|
+
children: d
|
|
136
|
+
},
|
|
137
|
+
d
|
|
138
|
+
);
|
|
139
|
+
}) }),
|
|
140
|
+
/* @__PURE__ */ r(
|
|
141
|
+
p,
|
|
142
|
+
{
|
|
143
|
+
variant: "outline",
|
|
144
|
+
size: "sm",
|
|
145
|
+
onClick: w,
|
|
146
|
+
disabled: s === n,
|
|
147
|
+
className: "px-2 py-1 text-sm hover:bg-gray-50",
|
|
148
|
+
children: [
|
|
149
|
+
"Next",
|
|
150
|
+
/* @__PURE__ */ e(We, { className: "h-4 w-4" })
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
)
|
|
154
|
+
] }),
|
|
155
|
+
c && /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
156
|
+
/* @__PURE__ */ e("span", { className: "text-sm text-muted-foreground", children: "Go to" }),
|
|
157
|
+
/* @__PURE__ */ e(
|
|
158
|
+
me,
|
|
159
|
+
{
|
|
160
|
+
type: "number",
|
|
161
|
+
min: 1,
|
|
162
|
+
max: n,
|
|
163
|
+
value: l,
|
|
164
|
+
onChange: (o) => {
|
|
165
|
+
const m = o.target.value.replace(/[^\d]/g, "");
|
|
166
|
+
I(m);
|
|
167
|
+
},
|
|
168
|
+
onKeyDown: S,
|
|
169
|
+
className: "h-8 w-16 px-2 py-1"
|
|
170
|
+
}
|
|
171
|
+
),
|
|
172
|
+
/* @__PURE__ */ e(
|
|
173
|
+
p,
|
|
174
|
+
{
|
|
175
|
+
variant: "outline",
|
|
176
|
+
size: "sm",
|
|
177
|
+
onClick: C,
|
|
178
|
+
disabled: l === "" || Number(l) < 1 || Number(l) > n,
|
|
179
|
+
children: "Go"
|
|
180
|
+
}
|
|
181
|
+
)
|
|
182
|
+
] })
|
|
183
|
+
] });
|
|
184
|
+
}
|
|
185
|
+
const ft = (s = {}) => {
|
|
186
|
+
const n = K(), h = Q(), { search: a, page: c = 1, limit: i = 30 } = s;
|
|
187
|
+
return ge({
|
|
188
|
+
queryKey: [b.GET_ASSETS, a, c, i],
|
|
189
|
+
queryFn: async () => {
|
|
190
|
+
const l = await h(n, {
|
|
191
|
+
action: b.GET_ASSETS,
|
|
192
|
+
data: {
|
|
193
|
+
search: a,
|
|
194
|
+
page: c,
|
|
195
|
+
limit: i
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
return l.page = c, l.limit = i, l;
|
|
199
|
+
},
|
|
200
|
+
staleTime: 1 / 0,
|
|
201
|
+
retry: 1
|
|
202
|
+
});
|
|
203
|
+
}, pt = (s) => {
|
|
204
|
+
const n = K(), h = Q();
|
|
205
|
+
return ge({
|
|
206
|
+
queryKey: [b.GET_ASSET, s],
|
|
207
|
+
queryFn: async () => s ? await h(n, {
|
|
208
|
+
action: b.GET_ASSET,
|
|
209
|
+
data: { id: s }
|
|
210
|
+
}) : null,
|
|
211
|
+
staleTime: 1 / 0,
|
|
212
|
+
retry: 1
|
|
213
|
+
});
|
|
214
|
+
};
|
|
215
|
+
function gt(s) {
|
|
216
|
+
const n = isNaN(s) ? 0 : typeof s == "number" ? s : parseInt(s);
|
|
217
|
+
return n ? n < 1024 ? `${n.toFixed(2)} B` : n < 1024 * 1024 ? `${(n / 1024).toFixed(2)} KB` : `${(n / (1024 * 1024)).toFixed(2)} MB` : "0 B";
|
|
218
|
+
}
|
|
219
|
+
function oe(s) {
|
|
220
|
+
if (!s) return "N/A";
|
|
221
|
+
const n = new Date(s);
|
|
222
|
+
return new Intl.DateTimeFormat("en-US", {
|
|
223
|
+
month: "short",
|
|
224
|
+
day: "numeric",
|
|
225
|
+
year: "numeric",
|
|
226
|
+
hour: "2-digit",
|
|
227
|
+
minute: "2-digit"
|
|
228
|
+
}).format(n);
|
|
229
|
+
}
|
|
230
|
+
function de(s, n) {
|
|
231
|
+
let h = s, a = n == null ? void 0 : n.description;
|
|
232
|
+
return (!a || typeof a != "string") && (a = ""), (!h || typeof h != "string") && (h = ""), h !== a;
|
|
233
|
+
}
|
|
234
|
+
const xt = ({ assetId: s, onBack: n, onEdit: h, onSave: a, isSaving: c }) => {
|
|
235
|
+
var o, m;
|
|
236
|
+
const { t: i } = ee(), { data: l, isLoading: I, isError: N } = pt(s || ""), [x, g] = y(""), [w, C] = y(!1);
|
|
237
|
+
O(() => {
|
|
238
|
+
const d = new Image();
|
|
239
|
+
return d.src = (l == null ? void 0 : l.url) || "", d.onload = () => C(!0), () => {
|
|
240
|
+
d.onload = null;
|
|
241
|
+
};
|
|
242
|
+
}, [l]);
|
|
243
|
+
const S = async (d, f) => {
|
|
244
|
+
try {
|
|
245
|
+
await navigator.clipboard.writeText(d), A.success(i("{{type}} copied to clipboard", { type: f }));
|
|
246
|
+
} catch (v) {
|
|
247
|
+
A.error(i("Failed to copy {{type}}", { type: f }), {
|
|
248
|
+
description: v == null ? void 0 : v.message
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
return fe.useEffect(() => {
|
|
253
|
+
l != null && l.description && g(l.description);
|
|
254
|
+
}, [l]), I || !w ? /* @__PURE__ */ e("div", { className: "flex flex-1 items-center justify-center", children: /* @__PURE__ */ e(B, { className: "h-8 w-8 animate-spin" }) }) : N || !(l != null && l.id) ? /* @__PURE__ */ e("div", { className: "flex flex-1 items-center justify-center", children: /* @__PURE__ */ r("div", { className: "mx-auto max-w-md p-6 text-center", children: [
|
|
255
|
+
/* @__PURE__ */ e("div", { className: "mb-4 flex justify-center", children: /* @__PURE__ */ e(Ve, { className: "h-12 w-12 text-gray-400" }) }),
|
|
256
|
+
/* @__PURE__ */ e("h3", { className: "mb-2 text-lg font-medium text-gray-900", children: i("No Asset Found") }),
|
|
257
|
+
/* @__PURE__ */ e("p", { className: "mb-6 text-sm text-gray-500", children: i(N ? "There was an error loading the asset. Please try again later." : "The asset you're looking for doesn't exist or has been removed.") }),
|
|
258
|
+
/* @__PURE__ */ r("div", { className: "flex justify-center gap-4", children: [
|
|
259
|
+
/* @__PURE__ */ e(p, { variant: "outline", onClick: n, children: i("Back to Assets") }),
|
|
260
|
+
N && /* @__PURE__ */ e(p, { variant: "default", onClick: () => window.location.reload(), children: i("Try Again") })
|
|
261
|
+
] })
|
|
262
|
+
] }) }) : /* @__PURE__ */ r("div", { className: "flex flex-1 flex-col gap-y-4 overflow-hidden", children: [
|
|
263
|
+
/* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
|
|
264
|
+
/* @__PURE__ */ r(p, { variant: "outline", size: "sm", onClick: n, disabled: c, children: [
|
|
265
|
+
/* @__PURE__ */ e(ue, { className: "h-4 w-4" }),
|
|
266
|
+
i("Back to Assets")
|
|
267
|
+
] }),
|
|
268
|
+
/* @__PURE__ */ r("div", { className: "flex gap-2", children: [
|
|
269
|
+
/* @__PURE__ */ e(p, { variant: "outline", onClick: n, disabled: c, children: i("Cancel") }),
|
|
270
|
+
/* @__PURE__ */ r(p, { variant: "outline", onClick: () => S(l.url, i("Asset URL")), disabled: c, children: [
|
|
271
|
+
/* @__PURE__ */ e(he, { className: "mr-2 h-4 w-4" }),
|
|
272
|
+
i("Copy URL")
|
|
273
|
+
] }),
|
|
274
|
+
/* @__PURE__ */ r(p, { variant: "default", onClick: () => h(l), disabled: c, children: [
|
|
275
|
+
/* @__PURE__ */ e(He, { className: "h-4 w-4" }),
|
|
276
|
+
i("Edit Image")
|
|
277
|
+
] })
|
|
278
|
+
] })
|
|
279
|
+
] }),
|
|
280
|
+
/* @__PURE__ */ r("div", { className: "grid flex-1 grid-cols-2 items-start gap-6 overflow-hidden", children: [
|
|
281
|
+
/* @__PURE__ */ e("div", { className: "relative flex h-[calc(80vh-200px)] w-full items-start justify-center", children: /* @__PURE__ */ e(
|
|
282
|
+
"img",
|
|
283
|
+
{
|
|
284
|
+
src: l.url,
|
|
285
|
+
alt: l.name,
|
|
286
|
+
className: "h-full max-h-max w-full max-w-max rounded-lg object-contain"
|
|
287
|
+
}
|
|
288
|
+
) }),
|
|
289
|
+
/* @__PURE__ */ r("div", { className: "space-y-6", children: [
|
|
290
|
+
/* @__PURE__ */ r("div", { className: "grid gap-3 rounded-md border bg-gray-100 pt-2", children: [
|
|
291
|
+
/* @__PURE__ */ e(V, { className: "w-full text-center", children: i("Details") }),
|
|
292
|
+
/* @__PURE__ */ e("div", { className: "grid grid-cols-1 gap-2 rounded-md border bg-white p-2 text-sm", children: [
|
|
293
|
+
{ label: i("File Name"), value: l.name },
|
|
294
|
+
{ label: i("Type"), value: l.type, capitalize: !0 },
|
|
295
|
+
{
|
|
296
|
+
label: i("Format"),
|
|
297
|
+
value: ((o = l.metadata) == null ? void 0 : o.format) || l.type,
|
|
298
|
+
capitalize: !0
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
label: i("Size"),
|
|
302
|
+
value: gt(l.size)
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
label: i("Dimensions"),
|
|
306
|
+
value: `${l.width || 0} × ${l.height || 0}`
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
label: i("Created"),
|
|
310
|
+
value: oe(l.createdAt)
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
label: i("Updated"),
|
|
314
|
+
value: oe(((m = l.metadata) == null ? void 0 : m.updatedAt) || (l == null ? void 0 : l.updatedAt) || l.createdAt)
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
label: i("URL"),
|
|
318
|
+
value: l.url,
|
|
319
|
+
copyable: !0
|
|
320
|
+
}
|
|
321
|
+
].map((d) => /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
322
|
+
/* @__PURE__ */ e(V, { className: "w-1/4 w-max px-2 text-left font-normal text-gray-700", children: d.label }),
|
|
323
|
+
":",
|
|
324
|
+
/* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
325
|
+
/* @__PURE__ */ e(
|
|
326
|
+
"div",
|
|
327
|
+
{
|
|
328
|
+
className: "w-max text-left font-medium text-gray-900" + (d.capitalize ? " capitalize" : ""),
|
|
329
|
+
children: d.value
|
|
330
|
+
}
|
|
331
|
+
),
|
|
332
|
+
d.copyable && /* @__PURE__ */ e(
|
|
333
|
+
p,
|
|
334
|
+
{
|
|
335
|
+
variant: "ghost",
|
|
336
|
+
size: "icon",
|
|
337
|
+
className: "h-6 w-6",
|
|
338
|
+
onClick: () => S(d.value, d.label),
|
|
339
|
+
children: /* @__PURE__ */ e(Xe, { className: "h-3 w-3" })
|
|
340
|
+
}
|
|
341
|
+
)
|
|
342
|
+
] })
|
|
343
|
+
] }, d.label)) })
|
|
344
|
+
] }),
|
|
345
|
+
l.usedOn && l.usedOn.length > 0 && /* @__PURE__ */ r("div", { className: "grid gap-3", children: [
|
|
346
|
+
/* @__PURE__ */ e(V, { children: i("Used On") }),
|
|
347
|
+
/* @__PURE__ */ e("div", { className: "grid grid-cols-1 gap-2 rounded-md border p-2 text-sm", children: l.usedOn.map((d, f) => /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
348
|
+
/* @__PURE__ */ e("div", { className: "w-max text-left font-medium text-gray-900", children: d.name }),
|
|
349
|
+
/* @__PURE__ */ r("div", { className: "text-gray-500", children: [
|
|
350
|
+
"(",
|
|
351
|
+
d.slug,
|
|
352
|
+
")"
|
|
353
|
+
] })
|
|
354
|
+
] }, f)) })
|
|
355
|
+
] }),
|
|
356
|
+
/* @__PURE__ */ r("div", { className: "relative grid gap-3 rounded-md border bg-gray-100 pt-2", children: [
|
|
357
|
+
/* @__PURE__ */ e(V, { className: "w-full text-center", children: i("Description") }),
|
|
358
|
+
/* @__PURE__ */ e(
|
|
359
|
+
Fe,
|
|
360
|
+
{
|
|
361
|
+
id: "description",
|
|
362
|
+
value: x,
|
|
363
|
+
placeholder: i("Enter a description for the asset"),
|
|
364
|
+
onChange: (d) => g(d.target.value),
|
|
365
|
+
rows: 3,
|
|
366
|
+
disabled: c,
|
|
367
|
+
className: "bg-white hover:border-black/40"
|
|
368
|
+
}
|
|
369
|
+
),
|
|
370
|
+
/* @__PURE__ */ e("div", { className: "absolute right-2 top-1.5 flex items-start justify-end", children: /* @__PURE__ */ e(
|
|
371
|
+
"button",
|
|
372
|
+
{
|
|
373
|
+
type: "button",
|
|
374
|
+
onClick: () => a(x),
|
|
375
|
+
disabled: c || !de(x, l),
|
|
376
|
+
className: `rounded-md bg-blue-500 px-3 py-0 py-0.5 text-sm text-white ${c || !de(x, l) ? "cursor-not-allowed opacity-50" : ""}`,
|
|
377
|
+
children: c ? /* @__PURE__ */ r(H, { children: [
|
|
378
|
+
/* @__PURE__ */ e(B, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
379
|
+
i("Saving...")
|
|
380
|
+
] }) : i("Save")
|
|
381
|
+
}
|
|
382
|
+
) })
|
|
383
|
+
] })
|
|
384
|
+
] })
|
|
385
|
+
] })
|
|
386
|
+
] });
|
|
387
|
+
}, vt = fe.lazy(() => import("./image-editor-DV8kUKhl.js")), yt = 25 * 1024 * 1024, Nt = ({ isUpdatingAsset: s, allowedTypes: n, uploadAssets: h, isUploadingAsset: a, onUploaded: c }) => {
|
|
388
|
+
const { t: i } = ee(), [l, I] = y(() => {
|
|
389
|
+
const o = localStorage.getItem("chai_optimize_images");
|
|
390
|
+
return o !== null ? o === "true" : !0;
|
|
391
|
+
});
|
|
392
|
+
O(() => {
|
|
393
|
+
localStorage.setItem("chai_optimize_images", l.toString());
|
|
394
|
+
}, [l]);
|
|
395
|
+
const N = s || a, x = M(
|
|
396
|
+
async (o) => {
|
|
397
|
+
try {
|
|
398
|
+
const m = o;
|
|
399
|
+
if (!m.every((E) => E.type.startsWith("image/")))
|
|
400
|
+
return A.error(i("Invalid file type. Please upload a valid file.")), Promise.reject(new Error("Invalid file type"));
|
|
401
|
+
const d = m.map(async (E) => {
|
|
402
|
+
let j = E;
|
|
403
|
+
return E.type.startsWith("image/") && (j = await Oe(E)), new Promise((X, F) => {
|
|
404
|
+
const U = new FileReader();
|
|
405
|
+
U.readAsDataURL(j), U.onload = async () => {
|
|
406
|
+
X({
|
|
407
|
+
file: U.result,
|
|
408
|
+
folderId: void 0,
|
|
409
|
+
name: E.name,
|
|
410
|
+
optimize: l
|
|
411
|
+
});
|
|
412
|
+
}, U.onerror = () => F(null);
|
|
413
|
+
});
|
|
414
|
+
}), f = await Promise.all(d), v = await h(f);
|
|
415
|
+
return (v == null ? void 0 : v.length) === 1 && c(v[0]), v;
|
|
416
|
+
} catch (m) {
|
|
417
|
+
return Promise.reject(m);
|
|
418
|
+
}
|
|
419
|
+
},
|
|
420
|
+
[h, l, c, i]
|
|
421
|
+
), g = (o) => {
|
|
422
|
+
const m = [];
|
|
423
|
+
let d = 0;
|
|
424
|
+
return o.forEach((f) => {
|
|
425
|
+
f.size > yt ? d++ : m.push(f);
|
|
426
|
+
}), d > 0 && A.error(
|
|
427
|
+
`${d === 1 && o.length === 1 ? i("File") : d + i(d === 1 ? " file" : " files")} ${i("exceed the maximum size limit of 10MB.")}`
|
|
428
|
+
), Re(m) ? [] : x(m);
|
|
429
|
+
}, { getRootProps: w, getInputProps: C, isDragActive: S } = ct({
|
|
430
|
+
onDrop: g,
|
|
431
|
+
accept: {
|
|
432
|
+
"image/*": n.includes("image") ? [] : []
|
|
433
|
+
},
|
|
434
|
+
disabled: s || a,
|
|
435
|
+
multiple: !0
|
|
436
|
+
});
|
|
437
|
+
return /* @__PURE__ */ e(
|
|
438
|
+
"div",
|
|
439
|
+
{
|
|
440
|
+
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 ${N ? "pointer-events-none bg-gray-100 opacity-90" : "bg-gray-100 hover:border-black/50 hover:bg-gray-100"}`,
|
|
441
|
+
children: /* @__PURE__ */ r(
|
|
442
|
+
"div",
|
|
443
|
+
{
|
|
444
|
+
...w(),
|
|
445
|
+
className: xe(
|
|
446
|
+
"flex h-max w-full cursor-pointer flex-col justify-center rounded-lg text-center",
|
|
447
|
+
N ? "items-start" : "items-center",
|
|
448
|
+
S ? "border-primary bg-primary/5" : "border-muted-foreground/20"
|
|
449
|
+
),
|
|
450
|
+
children: [
|
|
451
|
+
/* @__PURE__ */ e("input", { ...C() }),
|
|
452
|
+
N ? /* @__PURE__ */ e("div", { className: "flex flex-col items-center px-6", children: /* @__PURE__ */ r("div", { className: "flex items-center justify-center gap-2 leading-tight", children: [
|
|
453
|
+
/* @__PURE__ */ e("div", { className: "flex items-center justify-center rounded-full bg-indigo-100 p-2", children: /* @__PURE__ */ e(B, { className: "h-4 w-4 animate-spin text-indigo-500" }) }),
|
|
454
|
+
/* @__PURE__ */ r("div", { className: "text-left", children: [
|
|
455
|
+
/* @__PURE__ */ e("div", { className: "font-medium", children: i(s ? "Updating file..." : "Uploading file...") }),
|
|
456
|
+
/* @__PURE__ */ r("div", { className: "text-xs font-light text-muted-foreground", children: [
|
|
457
|
+
i("Please wait while we"),
|
|
458
|
+
" ",
|
|
459
|
+
i(s ? "update" : "upload"),
|
|
460
|
+
" ",
|
|
461
|
+
i("your file...")
|
|
462
|
+
] })
|
|
463
|
+
] })
|
|
464
|
+
] }) }) : /* @__PURE__ */ r("div", { className: "flex w-full items-center justify-between px-6", children: [
|
|
465
|
+
/* @__PURE__ */ e("div", { className: "flex flex-col items-center", children: /* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-2 leading-tight", children: [
|
|
466
|
+
/* @__PURE__ */ e(
|
|
467
|
+
"div",
|
|
468
|
+
{
|
|
469
|
+
className: "flex items-center justify-center rounded-full border border-indigo-500 bg-indigo-100 p-2",
|
|
470
|
+
children: /* @__PURE__ */ e(rt, { className: "h-4 w-4 text-indigo-500" })
|
|
471
|
+
}
|
|
472
|
+
),
|
|
473
|
+
/* @__PURE__ */ r("div", { className: "text-left", children: [
|
|
474
|
+
/* @__PURE__ */ r("div", { className: "font-medium", children: [
|
|
475
|
+
i("Drop your file here or"),
|
|
476
|
+
" ",
|
|
477
|
+
/* @__PURE__ */ e("span", { className: "cursor-pointer text-indigo-500 hover:underline", children: i("browse") })
|
|
478
|
+
] }),
|
|
479
|
+
/* @__PURE__ */ e("div", { className: "text-xs font-light text-muted-foreground", children: /* @__PURE__ */ r("span", { className: "", children: [
|
|
480
|
+
i("Accepted file types:"),
|
|
481
|
+
" ",
|
|
482
|
+
/* @__PURE__ */ e("span", { className: "capitalize text-indigo-400", children: n.join(", ") })
|
|
483
|
+
] }) })
|
|
484
|
+
] })
|
|
485
|
+
] }) }),
|
|
486
|
+
/* @__PURE__ */ r("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
|
|
487
|
+
/* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
488
|
+
/* @__PURE__ */ r("span", { className: "text-xs", children: [
|
|
489
|
+
i("Optimization:"),
|
|
490
|
+
" ",
|
|
491
|
+
/* @__PURE__ */ e("span", { className: l ? "text-indigo-600" : "text-gray-400", children: i(l ? "On" : "Off") })
|
|
492
|
+
] }),
|
|
493
|
+
/* @__PURE__ */ e(
|
|
494
|
+
Pe,
|
|
495
|
+
{
|
|
496
|
+
checked: l,
|
|
497
|
+
onCheckedChange: (o) => {
|
|
498
|
+
I(o);
|
|
499
|
+
},
|
|
500
|
+
onClick: (o) => {
|
|
501
|
+
o.stopPropagation();
|
|
502
|
+
},
|
|
503
|
+
className: "data-[state=checked]:bg-indigo-500"
|
|
504
|
+
}
|
|
505
|
+
)
|
|
506
|
+
] }),
|
|
507
|
+
/* @__PURE__ */ e(_, { children: /* @__PURE__ */ r(q, { children: [
|
|
508
|
+
/* @__PURE__ */ e(P, { asChild: !0, children: /* @__PURE__ */ e(
|
|
509
|
+
"span",
|
|
510
|
+
{
|
|
511
|
+
className: `flex cursor-help items-center text-amber-500 ${l ? "invisible" : ""}`,
|
|
512
|
+
children: /* @__PURE__ */ e(nt, { className: "mr-1 h-4 w-4" })
|
|
513
|
+
}
|
|
514
|
+
) }),
|
|
515
|
+
/* @__PURE__ */ e(G, { side: "top", children: /* @__PURE__ */ e("p", { className: "text-xs text-white", children: i("Warning: Unoptimized images may affect performance and page load times") }) })
|
|
516
|
+
] }) })
|
|
517
|
+
] })
|
|
518
|
+
] })
|
|
519
|
+
]
|
|
520
|
+
}
|
|
521
|
+
)
|
|
522
|
+
}
|
|
523
|
+
);
|
|
524
|
+
};
|
|
525
|
+
function Ut({ close: s, onSelect: n, mode: h = "image", assetId: a }) {
|
|
526
|
+
const { t: c } = ee(), i = !1, l = 10, I = pe(() => [h], [h]), [N, x] = y(null), [g, w] = y(null), [C, S] = y(null), [o, m] = y({ show: !1, file: "" }), [d, f] = y(!1), [v, E] = y(a ? "details" : "grid"), [j, X] = y(""), [F, U] = y(""), [R, Z] = y(1), [ae] = y(30), [k, J] = y([]);
|
|
527
|
+
O(() => {
|
|
528
|
+
a && (x(a), E("details"));
|
|
529
|
+
}, [a]), O(() => {
|
|
530
|
+
const t = setTimeout(() => {
|
|
531
|
+
X(F), Z(1);
|
|
532
|
+
}, 300);
|
|
533
|
+
return () => clearTimeout(t);
|
|
534
|
+
}, [F]);
|
|
535
|
+
const {
|
|
536
|
+
data: L,
|
|
537
|
+
isLoading: W,
|
|
538
|
+
refetch: ve
|
|
539
|
+
} = ft({
|
|
540
|
+
search: j.toLowerCase().trim(),
|
|
541
|
+
page: R,
|
|
542
|
+
limit: ae
|
|
543
|
+
}), D = (L == null ? void 0 : L.assets) || [], ye = (L == null ? void 0 : L.total) || 0, T = Math.ceil(ye / ae);
|
|
544
|
+
O(() => {
|
|
545
|
+
W || T <= 0 || Z((t) => t > T ? T : t < 1 ? 1 : t);
|
|
546
|
+
}, [W, T]);
|
|
547
|
+
const Ne = (D == null ? void 0 : D.length) > 0, { mutate: we } = mt(), { mutateAsync: le, isPending: be } = dt(), { mutateAsync: re, isPending: Ae } = ut(), ne = M(
|
|
548
|
+
(t) => {
|
|
549
|
+
const u = Math.min(Math.max(1, t), Math.max(1, T));
|
|
550
|
+
u !== R && Z(u);
|
|
551
|
+
},
|
|
552
|
+
[T, R]
|
|
553
|
+
), Ce = (t) => {
|
|
554
|
+
U(t.target.value);
|
|
555
|
+
}, Se = M(
|
|
556
|
+
(t) => {
|
|
557
|
+
J((u) => Be(u, { id: t.id }) ? [] : [t]);
|
|
558
|
+
},
|
|
559
|
+
[i]
|
|
560
|
+
), Ee = M(() => {
|
|
561
|
+
J([]);
|
|
562
|
+
}, []), se = (t) => {
|
|
563
|
+
(t == null ? void 0 : t.length) !== 0 && (n(Y(Qe(t || k), ["id", "url", "width", "height", "description"])), s());
|
|
564
|
+
}, ke = async (t) => {
|
|
565
|
+
w(t);
|
|
566
|
+
}, Ie = async () => {
|
|
567
|
+
g && (S(g == null ? void 0 : g.id), await we(g.id, {
|
|
568
|
+
onSuccess: () => {
|
|
569
|
+
S(null), w(null);
|
|
570
|
+
},
|
|
571
|
+
onError: () => {
|
|
572
|
+
S(null);
|
|
573
|
+
}
|
|
574
|
+
}), w(null));
|
|
575
|
+
}, Te = (t) => {
|
|
576
|
+
x(t.id), E("details");
|
|
577
|
+
}, ze = async (t, u) => {
|
|
578
|
+
try {
|
|
579
|
+
const $ = localStorage.getItem("chai_optimize_images") !== "false";
|
|
580
|
+
if (u) {
|
|
581
|
+
const z = await le([
|
|
582
|
+
{
|
|
583
|
+
file: t,
|
|
584
|
+
folderId: void 0,
|
|
585
|
+
name: o.name || "",
|
|
586
|
+
optimize: $
|
|
587
|
+
}
|
|
588
|
+
]);
|
|
589
|
+
if ((z == null ? void 0 : z.length) > 0) {
|
|
590
|
+
const ce = z[0];
|
|
591
|
+
n({
|
|
592
|
+
...Y(ce, ["id", "width", "height", "description"]),
|
|
593
|
+
url: ce.url
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
} else {
|
|
597
|
+
const z = await re({
|
|
598
|
+
id: o.id || "",
|
|
599
|
+
file: t
|
|
600
|
+
});
|
|
601
|
+
z && n({
|
|
602
|
+
...Y(z, ["id", "width", "height", "description"]),
|
|
603
|
+
url: z.url
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
m({ show: !1, file: "" }), s();
|
|
607
|
+
} catch ($) {
|
|
608
|
+
console.error(c("Error saving edited image:"), $);
|
|
609
|
+
}
|
|
610
|
+
}, De = M((t) => {
|
|
611
|
+
J([t]);
|
|
612
|
+
}, []), je = M(
|
|
613
|
+
(t) => {
|
|
614
|
+
ne(t);
|
|
615
|
+
},
|
|
616
|
+
[ne]
|
|
617
|
+
);
|
|
618
|
+
return /* @__PURE__ */ r(H, { children: [
|
|
619
|
+
/* @__PURE__ */ r("div", { className: "flex h-[80vh] max-h-[1232px] w-[80vw] max-w-[1232px] flex-col space-y-4", children: [
|
|
620
|
+
/* @__PURE__ */ e("h1", { className: "text-lg font-medium", children: c("Digital Asset Manager") }),
|
|
621
|
+
v === "grid" ? /* @__PURE__ */ r(H, { children: [
|
|
622
|
+
/* @__PURE__ */ e(
|
|
623
|
+
Nt,
|
|
624
|
+
{
|
|
625
|
+
maxFileSize: l,
|
|
626
|
+
allowedTypes: I,
|
|
627
|
+
uploadAssets: le,
|
|
628
|
+
isUpdatingAsset: Ae,
|
|
629
|
+
isUploadingAsset: be,
|
|
630
|
+
onUploaded: De
|
|
631
|
+
}
|
|
632
|
+
),
|
|
633
|
+
/* @__PURE__ */ r("div", { className: "relative flex flex-1 flex-col gap-y-3 overflow-hidden rounded-lg border p-2", children: [
|
|
634
|
+
/* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-3", children: [
|
|
635
|
+
/* @__PURE__ */ r("div", { className: "relative w-1/2", children: [
|
|
636
|
+
/* @__PURE__ */ e(
|
|
637
|
+
Ze,
|
|
638
|
+
{
|
|
639
|
+
strokeWidth: 3,
|
|
640
|
+
className: `absolute left-2 top-2.5 h-4 w-4 text-muted-foreground ${F.length > 0 ? "text-indigo-800" : ""}`
|
|
641
|
+
}
|
|
642
|
+
),
|
|
643
|
+
/* @__PURE__ */ e(
|
|
644
|
+
me,
|
|
645
|
+
{
|
|
646
|
+
placeholder: c("Search assets..."),
|
|
647
|
+
onChange: Ce,
|
|
648
|
+
value: F,
|
|
649
|
+
className: "pl-8"
|
|
650
|
+
}
|
|
651
|
+
)
|
|
652
|
+
] }),
|
|
653
|
+
/* @__PURE__ */ r("div", { className: "flex items-center gap-x-2", children: [
|
|
654
|
+
k.length > 0 ? /* @__PURE__ */ e("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
655
|
+
k.length > 0 && /* @__PURE__ */ e(H, { children: /* @__PURE__ */ e(
|
|
656
|
+
p,
|
|
657
|
+
{
|
|
658
|
+
variant: "outline",
|
|
659
|
+
size: "sm",
|
|
660
|
+
onClick: () => Ee(),
|
|
661
|
+
title: c("Clear selection"),
|
|
662
|
+
children: c("Clear")
|
|
663
|
+
}
|
|
664
|
+
) }),
|
|
665
|
+
/* @__PURE__ */ e(
|
|
666
|
+
p,
|
|
667
|
+
{
|
|
668
|
+
size: "sm",
|
|
669
|
+
onClick: () => se(k),
|
|
670
|
+
disabled: k.length === 0,
|
|
671
|
+
children: c("Select Asset")
|
|
672
|
+
}
|
|
673
|
+
)
|
|
674
|
+
] }) }) : null,
|
|
675
|
+
/* @__PURE__ */ e(p, { variant: "ghost", size: "icon", onClick: () => ve(), children: /* @__PURE__ */ e(Je, { className: "h-4 w-4" }) })
|
|
676
|
+
] })
|
|
677
|
+
] }),
|
|
678
|
+
/* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto pb-[66px]", children: W ? /* @__PURE__ */ r("div", { className: "columns-1 gap-3 space-y-3 sm:columns-3 md:columns-5", children: [
|
|
679
|
+
/* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
|
|
680
|
+
/* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
|
|
681
|
+
/* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
|
|
682
|
+
/* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
|
|
683
|
+
/* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
|
|
684
|
+
/* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
|
|
685
|
+
/* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
|
|
686
|
+
/* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
|
|
687
|
+
/* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" }),
|
|
688
|
+
/* @__PURE__ */ e("div", { className: "h-64 w-full animate-pulse rounded bg-gray-200" })
|
|
689
|
+
] }) : !W && !Ne ? /* @__PURE__ */ r("div", { className: "flex h-full flex-col items-center justify-center rounded-lg border", children: [
|
|
690
|
+
/* @__PURE__ */ e("div", { className: "text-muted-foreground", children: /* @__PURE__ */ e(Ye, { className: "h-9 w-9 text-indigo-500" }) }),
|
|
691
|
+
/* @__PURE__ */ e("div", { className: "text-lg text-muted-foreground", children: c("No assets found") }),
|
|
692
|
+
/* @__PURE__ */ e("div", { className: "text-sm text-muted-foreground", children: j.length > 0 ? c("No assets found for your search: {{query}}", { query: j }) : c("Start uploading assets to get started") }),
|
|
693
|
+
/* @__PURE__ */ e("br", {})
|
|
694
|
+
] }) : /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-3 p-1", children: D == null ? void 0 : D.map((t) => /* @__PURE__ */ r(
|
|
695
|
+
"div",
|
|
696
|
+
{
|
|
697
|
+
className: xe(
|
|
698
|
+
"group relative flex max-h-[180px] max-w-[180px] cursor-pointer flex-col justify-between overflow-hidden rounded-lg border-2 transition-all",
|
|
699
|
+
k.some((u) => u.id === t.id) ? "border-blue-500" : "hover:border-black/90",
|
|
700
|
+
C && (g == null ? void 0 : g.id) === t.id ? "pointer-events-none opacity-50" : "",
|
|
701
|
+
C === t.id ? "pointer-events-none opacity-50" : ""
|
|
702
|
+
),
|
|
703
|
+
onClick: () => Se(t),
|
|
704
|
+
onDoubleClick: () => se([t]),
|
|
705
|
+
children: [
|
|
706
|
+
/* @__PURE__ */ r("div", { className: "aspect-square relative overflow-hidden", children: [
|
|
707
|
+
C === t.id ? /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center bg-black/50", children: /* @__PURE__ */ e(B, { className: "h-8 w-8 animate-spin text-white" }) }) : null,
|
|
708
|
+
t.type === "image" ? /* @__PURE__ */ e(
|
|
709
|
+
"img",
|
|
710
|
+
{
|
|
711
|
+
src: `${t.thumbnailUrl || "/placeholder.svg"}?v=${(t == null ? void 0 : t.updatedAt) || t.createdAt}`,
|
|
712
|
+
alt: t.name,
|
|
713
|
+
className: `h-full min-h-[80px] w-full object-contain ${k.some((u) => u.id === t.id) ? "" : "group-hover:blur group-hover:contrast-50"}`
|
|
714
|
+
}
|
|
715
|
+
) : /* @__PURE__ */ r("div", { className: "flex h-full items-center justify-center", children: [
|
|
716
|
+
/* @__PURE__ */ e(et, { className: "h-12 w-12 text-muted-foreground" }),
|
|
717
|
+
t.thumbnailUrl && /* @__PURE__ */ e(
|
|
718
|
+
"img",
|
|
719
|
+
{
|
|
720
|
+
src: `${t.thumbnailUrl || "/placeholder.svg"}?v=${(t == null ? void 0 : t.updatedAt) || t.createdAt}`,
|
|
721
|
+
alt: t.name,
|
|
722
|
+
className: "absolute inset-0 h-full w-full object-cover"
|
|
723
|
+
}
|
|
724
|
+
)
|
|
725
|
+
] })
|
|
726
|
+
] }),
|
|
727
|
+
/* @__PURE__ */ r("div", { className: "flex items-end justify-between border-t-[1px] border-black/10 bg-white px-2 py-1", children: [
|
|
728
|
+
/* @__PURE__ */ e("div", { className: "truncate text-xs leading-tight", title: t.name, children: t.name }),
|
|
729
|
+
/* @__PURE__ */ e("div", { className: "flex items-center justify-between whitespace-nowrap text-[9px] font-light text-muted-foreground", children: /* @__PURE__ */ e("span", { children: Ge((t == null ? void 0 : t.size) || 0) }) })
|
|
730
|
+
] }),
|
|
731
|
+
!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__ */ r("div", { className: "grid grid-cols-4 gap-2 p-2", children: [
|
|
732
|
+
/* @__PURE__ */ e(_, { children: /* @__PURE__ */ r(q, { children: [
|
|
733
|
+
/* @__PURE__ */ e(P, { asChild: !0, children: /* @__PURE__ */ e(
|
|
734
|
+
p,
|
|
735
|
+
{
|
|
736
|
+
variant: "secondary",
|
|
737
|
+
size: "icon",
|
|
738
|
+
className: "h-8 w-8 rounded-full",
|
|
739
|
+
onClick: (u) => {
|
|
740
|
+
u.stopPropagation(), Te(t);
|
|
741
|
+
},
|
|
742
|
+
children: /* @__PURE__ */ e(tt, { className: "h-4 w-4" })
|
|
743
|
+
}
|
|
744
|
+
) }),
|
|
745
|
+
/* @__PURE__ */ e(G, { children: /* @__PURE__ */ e("p", { children: c("View Details") }) })
|
|
746
|
+
] }) }),
|
|
747
|
+
/* @__PURE__ */ e(_, { children: /* @__PURE__ */ r(q, { children: [
|
|
748
|
+
/* @__PURE__ */ e(P, { asChild: !0, children: /* @__PURE__ */ e(
|
|
749
|
+
p,
|
|
750
|
+
{
|
|
751
|
+
variant: "secondary",
|
|
752
|
+
size: "icon",
|
|
753
|
+
className: "h-8 w-8 rounded-full",
|
|
754
|
+
onClick: (u) => {
|
|
755
|
+
u.stopPropagation(), navigator.clipboard.writeText(t.url), A.success(c("Asset URL copied to clipboard"));
|
|
756
|
+
},
|
|
757
|
+
children: /* @__PURE__ */ e(he, { className: "h-4 w-4" })
|
|
758
|
+
}
|
|
759
|
+
) }),
|
|
760
|
+
/* @__PURE__ */ e(G, { children: /* @__PURE__ */ e("p", { children: c("Copy URL") }) })
|
|
761
|
+
] }) }),
|
|
762
|
+
/* @__PURE__ */ e(_, { children: /* @__PURE__ */ r(q, { children: [
|
|
763
|
+
/* @__PURE__ */ e(P, { asChild: !0, children: /* @__PURE__ */ e(
|
|
764
|
+
p,
|
|
765
|
+
{
|
|
766
|
+
variant: "secondary",
|
|
767
|
+
size: "icon",
|
|
768
|
+
className: "h-8 w-8 rounded-full",
|
|
769
|
+
onClick: (u) => {
|
|
770
|
+
u.stopPropagation(), m({
|
|
771
|
+
id: t.id,
|
|
772
|
+
show: !0,
|
|
773
|
+
file: t.url,
|
|
774
|
+
name: t.name
|
|
775
|
+
});
|
|
776
|
+
},
|
|
777
|
+
children: /* @__PURE__ */ e(it, { className: "h-4 w-4" })
|
|
778
|
+
}
|
|
779
|
+
) }),
|
|
780
|
+
/* @__PURE__ */ e(G, { children: /* @__PURE__ */ e("p", { children: c("Edit Image") }) })
|
|
781
|
+
] }) }),
|
|
782
|
+
/* @__PURE__ */ e(_, { children: /* @__PURE__ */ r(q, { children: [
|
|
783
|
+
/* @__PURE__ */ e(P, { asChild: !0, children: /* @__PURE__ */ e(
|
|
784
|
+
p,
|
|
785
|
+
{
|
|
786
|
+
variant: "destructive",
|
|
787
|
+
size: "icon",
|
|
788
|
+
className: "h-8 w-8 rounded-full",
|
|
789
|
+
onClick: (u) => {
|
|
790
|
+
u.stopPropagation(), ke(t);
|
|
791
|
+
},
|
|
792
|
+
children: /* @__PURE__ */ e(at, { className: "h-4 w-4" })
|
|
793
|
+
}
|
|
794
|
+
) }),
|
|
795
|
+
/* @__PURE__ */ e(G, { children: /* @__PURE__ */ e("p", { children: c("Delete Asset") }) })
|
|
796
|
+
] }) })
|
|
797
|
+
] }) }),
|
|
798
|
+
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(lt, { className: "h-3 w-3 text-white", strokeWidth: 5 }) })
|
|
799
|
+
]
|
|
800
|
+
},
|
|
801
|
+
t.id
|
|
802
|
+
)) }) }),
|
|
803
|
+
T > 1 && /* @__PURE__ */ e("div", { className: "absolute bottom-0 left-0 right-0 border-t bg-white p-4", children: /* @__PURE__ */ e(ot, { fallback: /* @__PURE__ */ e("div", { className: "text-red-500", children: c("Error loading pagination") }), children: /* @__PURE__ */ e(
|
|
804
|
+
ht,
|
|
805
|
+
{
|
|
806
|
+
currentPage: R,
|
|
807
|
+
totalPages: T,
|
|
808
|
+
onPageChange: je,
|
|
809
|
+
pageRangeDisplayed: 3,
|
|
810
|
+
showPageInput: !0
|
|
811
|
+
}
|
|
812
|
+
) }) })
|
|
813
|
+
] })
|
|
814
|
+
] }) : /* @__PURE__ */ e(
|
|
815
|
+
xt,
|
|
816
|
+
{
|
|
817
|
+
assetId: N || a || "",
|
|
818
|
+
onBack: () => {
|
|
819
|
+
E("grid"), x(null);
|
|
820
|
+
},
|
|
821
|
+
onEdit: (t) => {
|
|
822
|
+
m({
|
|
823
|
+
id: t.id,
|
|
824
|
+
show: !0,
|
|
825
|
+
file: t.url,
|
|
826
|
+
name: t.name
|
|
827
|
+
});
|
|
828
|
+
},
|
|
829
|
+
onSave: async (t) => {
|
|
830
|
+
if (N) {
|
|
831
|
+
f(!0);
|
|
832
|
+
try {
|
|
833
|
+
const u = D.find(($) => $.id === N);
|
|
834
|
+
u && await re(Ke(u, { description: t }));
|
|
835
|
+
} finally {
|
|
836
|
+
f(!1);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
},
|
|
840
|
+
isSaving: d
|
|
841
|
+
}
|
|
842
|
+
)
|
|
843
|
+
] }),
|
|
844
|
+
o.show && /* @__PURE__ */ e(
|
|
845
|
+
st,
|
|
846
|
+
{
|
|
847
|
+
fallback: /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ e(B, { className: "h-8 w-8 animate-spin" }) }),
|
|
848
|
+
children: /* @__PURE__ */ e(
|
|
849
|
+
vt,
|
|
850
|
+
{
|
|
851
|
+
imageUrl: o.file,
|
|
852
|
+
onSave: ze,
|
|
853
|
+
onClose: () => m({ show: !1, file: "" }),
|
|
854
|
+
defaultSavedImageName: o.name,
|
|
855
|
+
isEditing: !!o.id
|
|
856
|
+
}
|
|
857
|
+
)
|
|
858
|
+
}
|
|
859
|
+
),
|
|
860
|
+
g && /* @__PURE__ */ e(Ue, { open: !!g, onOpenChange: () => w(null), children: /* @__PURE__ */ r(Le, { children: [
|
|
861
|
+
/* @__PURE__ */ r($e, { children: [
|
|
862
|
+
/* @__PURE__ */ e(Me, { children: c("Delete Asset") }),
|
|
863
|
+
/* @__PURE__ */ e(_e, { children: c('Are you sure you want to delete "{{name}}"? This action cannot be undone.', {
|
|
864
|
+
name: g.name
|
|
865
|
+
}) })
|
|
866
|
+
] }),
|
|
867
|
+
/* @__PURE__ */ r(qe, { className: "gap-2 sm:gap-0", children: [
|
|
868
|
+
/* @__PURE__ */ e(p, { variant: "outline", onClick: () => w(null), children: c("Cancel") }),
|
|
869
|
+
/* @__PURE__ */ e(p, { variant: "destructive", onClick: Ie, children: c("Delete") })
|
|
870
|
+
] })
|
|
871
|
+
] }) })
|
|
872
|
+
] });
|
|
873
|
+
}
|
|
874
|
+
export {
|
|
875
|
+
Ut as default
|
|
876
|
+
};
|