@chaibuilder/sdk 4.0.0-beta.44 → 4.0.0-beta.46
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/{2SSKDMRQ-BrCeJE2w.js → 2SSKDMRQ-B6pWs8Zk.js} +2 -2
- package/dist/{2SSKDMRQ-BKWkM_6d.cjs → 2SSKDMRQ-B7Va8HeK.cjs} +1 -1
- package/dist/{AP7HFJJL-CskLuLc8.js → AP7HFJJL-CNIRZpP-.js} +1 -1
- package/dist/{AP7HFJJL-vt0XlZqG.cjs → AP7HFJJL-Xv13XYXE.cjs} +1 -1
- package/dist/{IconPicker-BJ6a_dl-.js → IconPicker-CGtjTiWr.js} +1 -1
- package/dist/{WDYDFRGG-BN61b01J.js → WDYDFRGG-5Lwxhw_-.js} +2 -2
- package/dist/{WDYDFRGG-Nw-WmjVB.cjs → WDYDFRGG-zZ8jN8rF.cjs} +1 -1
- package/dist/{actions-registery-CMKfEXxX.js → actions-registery-B1VeX52Y.js} +1565 -1529
- package/dist/{actions-registery-CqhNZFV3.cjs → actions-registery-BQ31lpix.cjs} +19 -19
- package/dist/actions.cjs +1 -1
- package/dist/actions.d.ts +132 -0
- package/dist/actions.js +7 -6
- package/dist/{active-in-another-tab-DHTYNRjQ.cjs → active-in-another-tab-C8FXtXk5.cjs} +1 -1
- package/dist/{active-in-another-tab-CZHN4gdI.js → active-in-another-tab-HtM97aRN.js} +4 -4
- package/dist/{add-new-language-page-DUm56cDk.cjs → add-new-language-page-gbvPI58M.cjs} +1 -1
- package/dist/{add-new-language-page-J0FxQGri.js → add-new-language-page-x88_n8EW.js} +3 -3
- package/dist/{add-new-page-B4dH-sG6.js → add-new-page-BMSePgKl.js} +2 -2
- package/dist/{add-new-page-D0H-HGrE.cjs → add-new-page-CPB4yhqv.cjs} +1 -1
- package/dist/{ai-panel-default-lang-BHzxr8XE.cjs → ai-panel-default-lang-DKGh1pbz.cjs} +2 -2
- package/dist/{ai-panel-default-lang-DrKTSHgh.js → ai-panel-default-lang-Dav6FRUY.js} +10 -10
- package/dist/{ai-panel-other-lang-CMs97ftp.js → ai-panel-other-lang-CdFx2x23.js} +14 -14
- package/dist/{ai-panel-other-lang-B6cRPiU9.cjs → ai-panel-other-lang-DdDn2I8h.cjs} +1 -1
- package/dist/ai-prompt-input-B8SFfk6N.cjs +1 -0
- package/dist/ai-prompt-input-bleYNRnH.js +650 -0
- package/dist/{ai-translation-prompt-Ddum5Ge5.cjs → ai-translation-prompt-DGrNA2Od.cjs} +1 -1
- package/dist/{ai-translation-prompt-BfJry6ZR.js → ai-translation-prompt-DvHdOZ6t.js} +1 -1
- package/dist/{change-password-modal-C4ngPnKd.js → change-password-modal-C9afEHLW.js} +4 -4
- package/dist/{change-password-modal-UTKwQzI4.cjs → change-password-modal-bce5bF3K.cjs} +1 -1
- package/dist/{code-editor-LNL_FEZ0.js → code-editor-BfGHceIq.js} +1 -1
- package/dist/{continue-editing-in-this-client-rjJy4-cq.cjs → continue-editing-in-this-client-4bvChAL-.cjs} +1 -1
- package/dist/{continue-editing-in-this-client-CuBlXJb6.js → continue-editing-in-this-client-BFptv8tA.js} +2 -2
- package/dist/core.js +18 -18
- package/dist/{css-import-modal-ChRsUOVa.js → css-import-modal-CEQccCmc.js} +1 -1
- package/dist/{delete-page-BegGYX7_.js → delete-page-8h4dNP7d.js} +2 -2
- package/dist/{delete-page-BaJ0oesv.cjs → delete-page-BOxoMgyl.cjs} +1 -1
- package/dist/{design-token-usage-Bgphgz_u.js → design-token-usage-CVPBTF21.js} +8 -8
- package/dist/{digital-asset-manager-BPy9RYlx.js → digital-asset-manager-83B0Y6L-.js} +3 -3
- package/dist/{digital-asset-manager-uzOuwVMR.cjs → digital-asset-manager-JtBK07Ob.cjs} +1 -1
- package/dist/{duplicate-page-n6osptll.js → duplicate-page-DIa59iDe.js} +12 -12
- package/dist/{duplicate-page-BofwxP4t.cjs → duplicate-page-DVqC24Rd.cjs} +1 -1
- package/dist/{dynamic-page-selector-6EWhAHX0.js → dynamic-page-selector-C9vYslOg.js} +12 -12
- package/dist/{dynamic-page-selector-CVI1LwdD.cjs → dynamic-page-selector-YRCRqWlz.cjs} +1 -1
- package/dist/{image-editor-D1euq0rl.js → image-editor-CzxSXo-u.js} +1 -1
- package/dist/index-DXBHjFwY.cjs +5 -0
- package/dist/{index-fxuo68Am.js → index-DlTEPwjW.js} +1344 -1289
- package/dist/{index-fThd1uce.js → index-RwAuF_BE.js} +39 -39
- package/dist/{json-diff-viewer-B2Q7bs-U.cjs → json-diff-viewer-Bpsk0toO.cjs} +1 -1
- package/dist/{json-diff-viewer-C0kg3Rss.js → json-diff-viewer-is2P3TOV.js} +6 -6
- package/dist/{lang-panel-MB00AgoJ.cjs → lang-panel-BI5OFsBY.cjs} +1 -1
- package/dist/{lang-panel-DgDlmKaN.js → lang-panel-DwiCJRs9.js} +22 -22
- package/dist/{manage-design-tokens-nTmzLQyq.js → manage-design-tokens-D2Oz-jVp.js} +2 -2
- package/dist/{manage-design-tokens-modal-ayqKkRLc.js → manage-design-tokens-modal-ZR8PuhWC.js} +2 -2
- package/dist/{mark-as-template-BARMivkY.js → mark-as-template-C0Z2P_UF.js} +2 -2
- package/dist/{mark-as-template-CProQdMy.cjs → mark-as-template-muKJE1gk.cjs} +1 -1
- package/dist/{models-D95ZYr_x.js → models-BCu-p_QK.js} +4 -4
- package/dist/{models-5gOsRC56.cjs → models-D0RH2u4C.cjs} +1 -1
- package/dist/{nested-path-selector-content-DxW18z33.js → nested-path-selector-content-Ct80kFX-.js} +1 -1
- package/dist/{no-language-page-content-CB_UK8pU.js → no-language-page-content-BekrmPc5.js} +4 -4
- package/dist/{no-language-page-content-C2Q-PlyR.cjs → no-language-page-content-zn3891M8.cjs} +1 -1
- package/dist/{no-language-page-dialog-DsZDAaRd.js → no-language-page-dialog-dHlAqLlU.js} +2 -2
- package/dist/{no-language-page-dialog-B7SNu92-.cjs → no-language-page-dialog-wEXIlBuQ.cjs} +1 -1
- package/dist/{page-creator-CulX1J10.js → page-creator-6L7ehzhL.js} +4 -4
- package/dist/page-creator-CN2phGn5.cjs +1 -0
- package/dist/{page-lock-DbH7spVl.js → page-lock-C--D8qD7.js} +2 -2
- package/dist/{page-lock-BQr6vqz-.cjs → page-lock-DllloCJE.cjs} +1 -1
- package/dist/{page-locked-dialog-BgaqVH5J.js → page-locked-dialog-BD8LHbdC.js} +15 -15
- package/dist/{page-locked-dialog-B3ZmWOt_.cjs → page-locked-dialog-DzB8p0wl.cjs} +1 -1
- package/dist/{page-manager-new-ydVnl9s6.cjs → page-manager-new-DyjhsvPx.cjs} +1 -1
- package/dist/{page-manager-new-DNBm5H5A.js → page-manager-new-uFcGaZZY.js} +29 -29
- package/dist/{page-manager-search-and-filter-jYP_ub36.js → page-manager-search-and-filter-DK883UmG.js} +26 -26
- package/dist/{page-manager-search-and-filter-BhBT7qY0.cjs → page-manager-search-and-filter-zfR5i_GU.cjs} +1 -1
- package/dist/{page-revisions-content-ZOroDtgV.cjs → page-revisions-content-Bi2ehMnj.cjs} +1 -1
- package/dist/{page-revisions-content-YGYK8pv9.js → page-revisions-content-D3rIJj9X.js} +24 -24
- package/dist/pages.cjs +1 -1
- package/dist/pages.d.ts +2 -0
- package/dist/pages.js +24 -23
- package/dist/{publish-pages-content-Du3LgWM2.cjs → publish-pages-content-BQUHNRCX.cjs} +1 -1
- package/dist/{publish-pages-content-BgdFWGKT.js → publish-pages-content-ByPf4lvE.js} +23 -23
- package/dist/{rte-widget-modal-B7wA8UGi.js → rte-widget-modal-Tj_pS3ql.js} +1 -1
- package/dist/{save-to-lib-hHRxVrjy.js → save-to-lib-CcUqS0s1.js} +62 -62
- package/dist/{save-to-lib-Dxisxuo9.cjs → save-to-lib-Cyeqcelv.cjs} +1 -1
- package/dist/{selected-block-display-5hDghITH.cjs → selected-block-display-Benbb_OW.cjs} +1 -1
- package/dist/{selected-block-display-BNX9ZuNH.js → selected-block-display-C6LxDm0H.js} +11 -11
- package/dist/{seo-panel-CBEV-Nds.js → seo-panel-1U9Q0Ato.js} +25 -25
- package/dist/{seo-panel-C1DEkfcC.cjs → seo-panel-CCuvQpwV.cjs} +1 -1
- package/dist/{shared-json-ld-4o0YbV25.js → shared-json-ld-DbzUITto.js} +46 -46
- package/dist/{shared-json-ld-DuXm_88W.cjs → shared-json-ld-bj77fq_b.cjs} +1 -1
- package/dist/{slug-input-DE-a4dMb.js → slug-input-P-CLfUrw.js} +1 -1
- package/dist/supabase-actions.cjs +1 -1
- package/dist/supabase-actions.d.ts +4 -7
- package/dist/supabase-actions.js +1 -1
- package/dist/{take-over-request-WL-btbiZ.js → take-over-request-Bwj_2nPR.js} +5 -5
- package/dist/{take-over-request-DR4RC8TT.cjs → take-over-request-R3HRgShm.cjs} +1 -1
- package/dist/{translation-warning-modal-Cef9OsyI.js → translation-warning-modal-BdkToZwn.js} +1 -1
- package/dist/{unmark-as-template-Dexn_9W7.cjs → unmark-as-template-BG882c_S.cjs} +1 -1
- package/dist/{unmark-as-template-D-5cQ61Q.js → unmark-as-template-DHDMooLZ.js} +2 -2
- package/dist/{unpublish-page-C-7RnGgj.js → unpublish-page-C4e_gIX8.js} +2 -2
- package/dist/{unpublish-page-C14PYuLT.cjs → unpublish-page-DudJ1znF.cjs} +1 -1
- package/dist/{unpublished-partials-modal-O0E8HViJ.js → unpublished-partials-modal-p_0N6V23.js} +1 -1
- package/dist/{web-preview-DOJ6E273.js → web-preview-BA08d7DN.js} +1 -1
- package/dist/{web-preview-CgKfKkdH.cjs → web-preview-MG0HZxgA.cjs} +1 -1
- package/package.json +1 -1
- package/dist/ai-panel-content-BV5Hzsso.js +0 -62
- package/dist/ai-panel-content-D0ugQDEu.cjs +0 -1
- package/dist/ai-prompt-input-MPIh7805.cjs +0 -1
- package/dist/ai-prompt-input-__vuJNRC.js +0 -652
- package/dist/index-Dh-fEHei.cjs +0 -5
- package/dist/page-creator-CnyQu1Te.cjs +0 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { jsxs as n, jsx as t, Fragment as $ } from "react/jsx-runtime";
|
|
2
2
|
import { B as L } from "./register-chai-top-bar-D6GjnauV.js";
|
|
3
|
-
import { e as K, f as Q, g as J, o as V, q as W } from "./index-
|
|
4
|
-
import {
|
|
5
|
-
import { LanguageSelector as ae } from "./page-manager-search-and-filter-
|
|
3
|
+
import { e as K, f as Q, g as J, o as V, q as W } from "./index-RwAuF_BE.js";
|
|
4
|
+
import { ao as X, ap as Y, A as I, ay as O, az as Z, i as ee, k as te, am as se, T as U, aA as le } from "./index-DlTEPwjW.js";
|
|
5
|
+
import { LanguageSelector as ae } from "./page-manager-search-and-filter-DK883UmG.js";
|
|
6
6
|
import { useQuery as ne } from "@tanstack/react-query";
|
|
7
|
-
import { find as
|
|
8
|
-
import { Lock as de, GlobeIcon as ue, File as
|
|
9
|
-
import { useState as
|
|
7
|
+
import { find as F, filter as a, map as b, keys as re, get as G, includes as C, orderBy as N, isEmpty as oe, uniq as B, first as ce, concat as ie } from "lodash-es";
|
|
8
|
+
import { Lock as de, GlobeIcon as ue, File as me, Edit as he } from "lucide-react";
|
|
9
|
+
import { useState as D, useCallback as ge, useMemo as p, useEffect as j, startTransition as q } from "react";
|
|
10
10
|
const pe = () => {
|
|
11
11
|
const s = X(), d = Y();
|
|
12
12
|
return ne({
|
|
13
13
|
queryKey: [I.GET_CHANGES],
|
|
14
14
|
queryFn: async () => d(s, { action: I.GET_CHANGES })
|
|
15
15
|
});
|
|
16
|
-
}, fe = ({ page: s, selectedPages: d, handleCheckboxChange: k, getPageType: f, hasSlug:
|
|
16
|
+
}, fe = ({ page: s, selectedPages: d, handleCheckboxChange: k, getPageType: f, hasSlug: m, currentOwnerId: r }) => {
|
|
17
17
|
const u = O(), { data: i } = se(r), o = r === u ? null : i == null ? void 0 : i.name;
|
|
18
18
|
return /* @__PURE__ */ n("tr", { className: "group relative border-b last:border-b-0 hover:bg-gray-50", children: [
|
|
19
19
|
/* @__PURE__ */ n(
|
|
@@ -34,7 +34,7 @@ const pe = () => {
|
|
|
34
34
|
}
|
|
35
35
|
),
|
|
36
36
|
" ",
|
|
37
|
-
|
|
37
|
+
m(s.pageType) ? /* @__PURE__ */ t(me, { className: "h-4 w-4" }) : /* @__PURE__ */ t(ue, { className: "h-4 w-4" }),
|
|
38
38
|
/* @__PURE__ */ t(U, { content: s.name, side: "top", showTooltip: s.name.length > 25, children: /* @__PURE__ */ t("span", { className: "max-w-[200px] truncate font-medium text-black", children: s.name }) }),
|
|
39
39
|
s.slug && /* @__PURE__ */ t(U, { content: s.slug, side: "top", showTooltip: s.slug.length > 25, children: /* @__PURE__ */ t("span", { className: "max-w-[200px] truncate font-mono text-xs text-muted-foreground", children: s.slug }) })
|
|
40
40
|
]
|
|
@@ -43,7 +43,7 @@ const pe = () => {
|
|
|
43
43
|
/* @__PURE__ */ t("td", { className: "px-2", children: f(s == null ? void 0 : s.pageType) }),
|
|
44
44
|
/* @__PURE__ */ t("td", { className: "px-4 text-right", children: ce(s.changes) || "" }),
|
|
45
45
|
/* @__PURE__ */ t($, { children: o && /* @__PURE__ */ n("button", { className: "absolute right-0 top-0 flex h-full items-center gap-x-1 rounded bg-red-50 px-2 py-0.5 text-xs font-light text-red-500 opacity-0 group-hover:opacity-100", children: [
|
|
46
|
-
/* @__PURE__ */ t(
|
|
46
|
+
/* @__PURE__ */ t(he, { size: 12, className: "stroke-[3]" }),
|
|
47
47
|
" ",
|
|
48
48
|
/* @__PURE__ */ t("span", { className: "font-medium", children: o }),
|
|
49
49
|
" is editing this page"
|
|
@@ -55,13 +55,13 @@ const pe = () => {
|
|
|
55
55
|
isPending: d,
|
|
56
56
|
publishPage: k
|
|
57
57
|
}) => {
|
|
58
|
-
const f = O(), { pageToUser:
|
|
58
|
+
const f = O(), { pageToUser: m } = Z(), [r, u] = D([]), i = ee(), [o, x] = D(i), { data: T, isFetching: v } = pe(), { data: g } = te(), w = ge((e) => {
|
|
59
59
|
var l;
|
|
60
|
-
return (l =
|
|
60
|
+
return (l = F(g, { key: e })) == null ? void 0 : l.hasSlug;
|
|
61
61
|
}, [g]), y = p(
|
|
62
62
|
() => a(g, (e) => !w(e.key)).map((e) => e.key),
|
|
63
63
|
[w, g]
|
|
64
|
-
), E =
|
|
64
|
+
), E = B(b(T, "lang")).filter(Boolean), c = p(
|
|
65
65
|
() => a(T, (e) => e.pageType === "theme" || e.pageType === "design_tokens" ? !1 : o === i ? e.lang === o || e.lang === "" : e.lang === o),
|
|
66
66
|
[T, o, i]
|
|
67
67
|
), S = p(
|
|
@@ -71,20 +71,20 @@ const pe = () => {
|
|
|
71
71
|
() => a(c, (e) => y.includes(e.pageType)),
|
|
72
72
|
[c, y]
|
|
73
73
|
);
|
|
74
|
-
|
|
74
|
+
j(() => {
|
|
75
75
|
const e = b(a(c, { online: !0 }), "id");
|
|
76
|
-
|
|
77
|
-
}, [c]),
|
|
78
|
-
const e = a(re(
|
|
79
|
-
|
|
80
|
-
}, [
|
|
76
|
+
q(() => u(e));
|
|
77
|
+
}, [c]), j(() => {
|
|
78
|
+
const e = a(re(m), (l) => G(m, [l, "userId"]) !== f);
|
|
79
|
+
q(() => u((l) => a(l, (h) => !C(e, h))));
|
|
80
|
+
}, [m, f]);
|
|
81
81
|
const A = r.length === (c == null ? void 0 : c.length), _ = (e) => {
|
|
82
|
-
u((l) => C(l, e) ? a(l, (
|
|
82
|
+
u((l) => C(l, e) ? a(l, (h) => h !== e) : ie(l, e));
|
|
83
83
|
}, z = () => {
|
|
84
84
|
u(A ? [] : b(c, "id"));
|
|
85
85
|
}, H = () => {
|
|
86
86
|
k(
|
|
87
|
-
{ ids:
|
|
87
|
+
{ ids: B(r) },
|
|
88
88
|
{
|
|
89
89
|
onSuccess: () => {
|
|
90
90
|
s(), le("CENTER_CENTER"), x(i);
|
|
@@ -93,14 +93,14 @@ const pe = () => {
|
|
|
93
93
|
);
|
|
94
94
|
}, M = (e) => {
|
|
95
95
|
if (e === "theme") return "Theme";
|
|
96
|
-
const l =
|
|
96
|
+
const l = F(g, { key: e });
|
|
97
97
|
return l ? l == null ? void 0 : l.name : e;
|
|
98
98
|
}, R = p(() => {
|
|
99
99
|
const e = [
|
|
100
100
|
{ label: "Updated", top: "pt-2" },
|
|
101
101
|
...N(a(S, { online: !0 }), "pageType"),
|
|
102
102
|
...N(a(P, { online: !0 }), "pageType")
|
|
103
|
-
].filter((
|
|
103
|
+
].filter((h) => h.pageType !== "theme" && h.pageType !== "design_tokens"), l = [
|
|
104
104
|
{ label: "Offline", top: "pt-6" },
|
|
105
105
|
...N(a(S, { online: !1 }), "pageType"),
|
|
106
106
|
...N(a(P, { online: !1 }), "pageType")
|
|
@@ -157,7 +157,7 @@ const pe = () => {
|
|
|
157
157
|
handleCheckboxChange: _,
|
|
158
158
|
getPageType: M,
|
|
159
159
|
hasSlug: w,
|
|
160
|
-
currentOwnerId:
|
|
160
|
+
currentOwnerId: G(m, [(e == null ? void 0 : e.primaryPage) || (e == null ? void 0 : e.id), "userId"])
|
|
161
161
|
}
|
|
162
162
|
)
|
|
163
163
|
) })
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as e, jsxs as l } from "react/jsx-runtime";
|
|
2
|
-
import { h as D, D as N, e as S, f as j, g as v, N as w } from "./index-
|
|
2
|
+
import { h as D, D as N, e as S, f as j, g as v, N as w } from "./index-RwAuF_BE.js";
|
|
3
3
|
import { B } from "./register-chai-top-bar-D6GjnauV.js";
|
|
4
4
|
const M = ({
|
|
5
5
|
isOpen: f,
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
1
|
+
import { jsx as e, jsxs as o } from "react/jsx-runtime";
|
|
2
2
|
import { B as b, z as L } from "./register-chai-top-bar-D6GjnauV.js";
|
|
3
|
-
import { aF as ne, c as M, X as
|
|
4
|
-
import {
|
|
3
|
+
import { aF as ne, c as M, X as oe, Y as ie, P as le, aG as ce, ax as de, aH as ue, p as P } from "./index-RwAuF_BE.js";
|
|
4
|
+
import { ao as D, ap as G, A as _, av as me } from "./index-DlTEPwjW.js";
|
|
5
5
|
import { useQuery as K, useMutation as A, useQueryClient as pe } from "@tanstack/react-query";
|
|
6
6
|
import { useSetAtom as fe } from "jotai";
|
|
7
7
|
import { toast as N } from "sonner";
|
|
8
8
|
import { Trash2 as Y, Plus as he, ImageIcon as ge, X as be, AlertCircle as ye } from "lucide-react";
|
|
9
|
-
import { useState as h, useRef as V, useMemo as S, useEffect as
|
|
9
|
+
import { useState as h, useRef as V, useMemo as S, useEffect as w, useCallback as ke } from "react";
|
|
10
10
|
import { c as ve } from "./image-compression-DPFITwOL.js";
|
|
11
11
|
import { isEmpty as Ne, set as Be, has as Ce } from "lodash-es";
|
|
12
|
-
const
|
|
13
|
-
const a = D(),
|
|
12
|
+
const Ie = (r) => {
|
|
13
|
+
const a = D(), i = G();
|
|
14
14
|
return A({
|
|
15
|
-
mutationFn: async (t) =>
|
|
15
|
+
mutationFn: async (t) => i(a, {
|
|
16
16
|
action: _.UPSERT_LIBRARY_ITEM,
|
|
17
17
|
data: t
|
|
18
18
|
}),
|
|
@@ -25,8 +25,8 @@ const we = (r) => {
|
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
-
},
|
|
29
|
-
const a = D(),
|
|
28
|
+
}, we = (r) => {
|
|
29
|
+
const a = D(), i = G();
|
|
30
30
|
return K({
|
|
31
31
|
staleTime: "static",
|
|
32
32
|
queryKey: [_.GET_LIBRARY_ITEM, r],
|
|
@@ -35,7 +35,7 @@ const we = (r) => {
|
|
|
35
35
|
queryFn: async () => {
|
|
36
36
|
if (!r) return null;
|
|
37
37
|
try {
|
|
38
|
-
return await
|
|
38
|
+
return await i(a, {
|
|
39
39
|
action: _.GET_LIBRARY_ITEM,
|
|
40
40
|
data: { id: r }
|
|
41
41
|
});
|
|
@@ -46,9 +46,9 @@ const we = (r) => {
|
|
|
46
46
|
retry: !1
|
|
47
47
|
});
|
|
48
48
|
}, Ee = (r) => {
|
|
49
|
-
const a = D(),
|
|
49
|
+
const a = D(), i = G(), t = fe(ne);
|
|
50
50
|
return A({
|
|
51
|
-
mutationFn: async (l) =>
|
|
51
|
+
mutationFn: async (l) => i(a, {
|
|
52
52
|
action: _.DELETE_LIBRARY_ITEM,
|
|
53
53
|
data: { id: l }
|
|
54
54
|
}),
|
|
@@ -69,7 +69,7 @@ const we = (r) => {
|
|
|
69
69
|
}, xe = ({
|
|
70
70
|
blockId: r,
|
|
71
71
|
libBlockId: a,
|
|
72
|
-
isOpen:
|
|
72
|
+
isOpen: i,
|
|
73
73
|
onClose: t,
|
|
74
74
|
blockName: l,
|
|
75
75
|
trigger: m
|
|
@@ -77,8 +77,8 @@ const we = (r) => {
|
|
|
77
77
|
const [u, c] = h(!1), d = M(), y = Ee(() => {
|
|
78
78
|
d([r], { _libBlockId: void 0 }), N.success("Block deleted successfully"), c(!1), t();
|
|
79
79
|
});
|
|
80
|
-
return /* @__PURE__ */
|
|
81
|
-
/* @__PURE__ */ e(
|
|
80
|
+
return /* @__PURE__ */ o(oe, { open: i, onOpenChange: (p) => !p && t(), children: [
|
|
81
|
+
/* @__PURE__ */ e(ie, { asChild: !0, children: m || /* @__PURE__ */ o(b, { type: "button", variant: "destructive", size: "sm", onClick: (p) => p.preventDefault(), disabled: u, children: [
|
|
82
82
|
/* @__PURE__ */ e(Y, { className: "mr-2 h-4 w-4" }),
|
|
83
83
|
"Delete"
|
|
84
84
|
] }) }),
|
|
@@ -88,11 +88,11 @@ const we = (r) => {
|
|
|
88
88
|
className: "z-[9999] w-72 p-4",
|
|
89
89
|
sideOffset: 5,
|
|
90
90
|
align: "center",
|
|
91
|
-
children: /* @__PURE__ */
|
|
91
|
+
children: /* @__PURE__ */ o("div", { className: "space-y-3", children: [
|
|
92
92
|
/* @__PURE__ */ e("h4", { className: "font-medium", children: "Delete Block" }),
|
|
93
|
-
/* @__PURE__ */
|
|
93
|
+
/* @__PURE__ */ o("p", { className: "text-sm", children: [
|
|
94
94
|
"Are you sure you want to delete the block",
|
|
95
|
-
/* @__PURE__ */
|
|
95
|
+
/* @__PURE__ */ o("span", { className: "font-medium", children: [
|
|
96
96
|
' "',
|
|
97
97
|
l,
|
|
98
98
|
'"'
|
|
@@ -100,7 +100,7 @@ const we = (r) => {
|
|
|
100
100
|
"?"
|
|
101
101
|
] }),
|
|
102
102
|
/* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: "This block will be permanently removed from the library. This action cannot be undone." }),
|
|
103
|
-
/* @__PURE__ */
|
|
103
|
+
/* @__PURE__ */ o("div", { className: "flex justify-end gap-2 pt-2", children: [
|
|
104
104
|
/* @__PURE__ */ e(b, { type: "button", variant: "outline", size: "sm", onClick: t, disabled: u, children: "Cancel" }),
|
|
105
105
|
/* @__PURE__ */ e(b, { type: "button", variant: "destructive", size: "sm", onClick: () => {
|
|
106
106
|
c(!0), y.mutate(a);
|
|
@@ -113,7 +113,7 @@ const we = (r) => {
|
|
|
113
113
|
}, Pe = ({
|
|
114
114
|
blockId: r,
|
|
115
115
|
libBlockId: a,
|
|
116
|
-
blockName:
|
|
116
|
+
blockName: i,
|
|
117
117
|
size: t = "sm",
|
|
118
118
|
className: l = "",
|
|
119
119
|
close: m
|
|
@@ -128,8 +128,8 @@ const we = (r) => {
|
|
|
128
128
|
onClose: () => {
|
|
129
129
|
c(!1), m();
|
|
130
130
|
},
|
|
131
|
-
blockName:
|
|
132
|
-
trigger: /* @__PURE__ */
|
|
131
|
+
blockName: i,
|
|
132
|
+
trigger: /* @__PURE__ */ o(
|
|
133
133
|
b,
|
|
134
134
|
{
|
|
135
135
|
type: "button",
|
|
@@ -146,7 +146,7 @@ const we = (r) => {
|
|
|
146
146
|
}
|
|
147
147
|
);
|
|
148
148
|
}, Le = () => {
|
|
149
|
-
const r = D(), a = G(),
|
|
149
|
+
const r = D(), a = G(), i = pe(), {
|
|
150
150
|
data: t = [],
|
|
151
151
|
isLoading: l,
|
|
152
152
|
error: m
|
|
@@ -173,7 +173,7 @@ const we = (r) => {
|
|
|
173
173
|
});
|
|
174
174
|
},
|
|
175
175
|
onSuccess: () => {
|
|
176
|
-
|
|
176
|
+
i.invalidateQueries({
|
|
177
177
|
queryKey: ["library-groups"]
|
|
178
178
|
}), N.success("Group created successfully");
|
|
179
179
|
},
|
|
@@ -191,7 +191,7 @@ const we = (r) => {
|
|
|
191
191
|
isCreating: c
|
|
192
192
|
};
|
|
193
193
|
}, _e = ({ value: r, onChange: a }) => {
|
|
194
|
-
const [
|
|
194
|
+
const [i, t] = h(!1), [l, m] = h(""), u = V(null), { groups: c } = Le(), [d, y] = h([
|
|
195
195
|
{ id: "hero", name: "Hero" },
|
|
196
196
|
{ id: "feature", name: "Feature" },
|
|
197
197
|
{ id: "footer", name: "Footer" },
|
|
@@ -231,15 +231,15 @@ const we = (r) => {
|
|
|
231
231
|
const B = { id: s, name: s };
|
|
232
232
|
y((E) => [...E, B]), a(B.id), m(""), t(!1);
|
|
233
233
|
};
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}, [
|
|
234
|
+
w(() => {
|
|
235
|
+
i && u.current && u.current.focus();
|
|
236
|
+
}, [i]);
|
|
237
237
|
const p = (s) => {
|
|
238
238
|
s.key === "Enter" && (s.preventDefault(), g());
|
|
239
239
|
};
|
|
240
|
-
return
|
|
240
|
+
return w(() => {
|
|
241
241
|
r && !f.some((s) => s.id === r) && a("");
|
|
242
|
-
}, [r, f, a]),
|
|
242
|
+
}, [r, f, a]), i ? /* @__PURE__ */ o("div", { className: "space-y-2", children: [
|
|
243
243
|
/* @__PURE__ */ e(
|
|
244
244
|
L,
|
|
245
245
|
{
|
|
@@ -250,12 +250,12 @@ const we = (r) => {
|
|
|
250
250
|
onKeyDown: p
|
|
251
251
|
}
|
|
252
252
|
),
|
|
253
|
-
/* @__PURE__ */
|
|
253
|
+
/* @__PURE__ */ o("div", { className: "flex justify-end gap-2", children: [
|
|
254
254
|
/* @__PURE__ */ e(b, { variant: "outline", size: "sm", onClick: () => t(!1), children: "Cancel" }),
|
|
255
255
|
/* @__PURE__ */ e(b, { size: "sm", onClick: g, children: "Create" })
|
|
256
256
|
] })
|
|
257
|
-
] }) : /* @__PURE__ */
|
|
258
|
-
/* @__PURE__ */
|
|
257
|
+
] }) : /* @__PURE__ */ o("div", { className: "flex gap-2", children: [
|
|
258
|
+
/* @__PURE__ */ o(
|
|
259
259
|
"select",
|
|
260
260
|
{
|
|
261
261
|
className: "w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
@@ -271,7 +271,7 @@ const we = (r) => {
|
|
|
271
271
|
/* @__PURE__ */ e(b, { type: "button", size: "icon", variant: "outline", onClick: () => t(!0), children: /* @__PURE__ */ e(he, { className: "h-4 w-4" }) })
|
|
272
272
|
] });
|
|
273
273
|
}, De = ({ value: r, onChange: a }) => {
|
|
274
|
-
const [
|
|
274
|
+
const [i, t] = h(!1), l = V(null), m = ke(
|
|
275
275
|
async (d) => {
|
|
276
276
|
var f;
|
|
277
277
|
const y = (f = d.target.files) == null ? void 0 : f[0];
|
|
@@ -292,16 +292,16 @@ const we = (r) => {
|
|
|
292
292
|
},
|
|
293
293
|
[a]
|
|
294
294
|
);
|
|
295
|
-
return /* @__PURE__ */
|
|
296
|
-
/* @__PURE__ */
|
|
295
|
+
return /* @__PURE__ */ o("div", { className: "space-y-2", children: [
|
|
296
|
+
/* @__PURE__ */ o("div", { className: "flex items-center gap-2", children: [
|
|
297
297
|
/* @__PURE__ */ e(L, { type: "file", ref: l, onChange: m, accept: "image/*", className: "hidden" }),
|
|
298
298
|
/* @__PURE__ */ e(b, { type: "button", variant: "outline", onClick: () => {
|
|
299
299
|
var d;
|
|
300
300
|
(d = l.current) == null || d.click();
|
|
301
|
-
}, disabled:
|
|
301
|
+
}, disabled: i, className: "w-full", children: i ? /* @__PURE__ */ o("span", { className: "flex items-center gap-2", children: [
|
|
302
302
|
/* @__PURE__ */ e("div", { className: "h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" }),
|
|
303
303
|
"Uploading..."
|
|
304
|
-
] }) : /* @__PURE__ */
|
|
304
|
+
] }) : /* @__PURE__ */ o("span", { className: "flex items-center gap-2", children: [
|
|
305
305
|
/* @__PURE__ */ e(ge, { className: "h-4 w-4" }),
|
|
306
306
|
"Select image"
|
|
307
307
|
] }) }),
|
|
@@ -312,7 +312,7 @@ const we = (r) => {
|
|
|
312
312
|
r && /* @__PURE__ */ e("div", { className: "aspect-video h-[200px] max-h-[200px] overflow-hidden rounded-md border", children: /* @__PURE__ */ e("img", { src: r, alt: "Preview", className: "h-full w-full object-contain" }) })
|
|
313
313
|
] });
|
|
314
314
|
}, Me = (r) => {
|
|
315
|
-
const { blocks: a, close:
|
|
315
|
+
const { blocks: a, close: i, blockId: t } = r, { getPartialBlocks: l } = ce(), m = a.find((n) => n._id === t), u = m == null ? void 0 : m._libBlockId, c = !!u, d = S(() => a.some((n) => n._type === "PartialBlock" || n._type === "GlobalBlock"), [a]), y = S(() => {
|
|
316
316
|
let n = [];
|
|
317
317
|
for (const k of a)
|
|
318
318
|
if (k._type === "PartialBlock" || k._type === "GlobalBlock") {
|
|
@@ -322,25 +322,25 @@ const we = (r) => {
|
|
|
322
322
|
n.push(k);
|
|
323
323
|
return n;
|
|
324
324
|
}, [a, l]), [f, g] = h(""), [p, s] = h(""), [B, E] = h(""), [x, U] = h(""), [C, W] = h({}), [Q, $] = h(!1), [H, q] = h(c), [X, J] = h(!1), { hasPermission: Z } = de(), ee = Z(me.DELETE_LIBRARY_BLOCK), O = M(), te = () => {
|
|
325
|
-
O([t], { _libBlockId: void 0 }), N.success("Block delinked from library"),
|
|
325
|
+
O([t], { _libBlockId: void 0 }), N.success("Block delinked from library"), i();
|
|
326
326
|
}, {
|
|
327
|
-
data:
|
|
327
|
+
data: I,
|
|
328
328
|
isLoading: F,
|
|
329
329
|
isError: j
|
|
330
|
-
} =
|
|
331
|
-
|
|
330
|
+
} = we(u);
|
|
331
|
+
w(() => {
|
|
332
332
|
j && c && (J(!0), q(!1));
|
|
333
|
-
}, [j, c]),
|
|
334
|
-
|
|
335
|
-
}, [
|
|
333
|
+
}, [j, c]), w(() => {
|
|
334
|
+
I && !F && (g(I.name || ""), s(I.group || ""), E(I.description || ""), U(I.preview || ""), q(!1));
|
|
335
|
+
}, [I, F]), w(() => {
|
|
336
336
|
const n = f.trim().length >= 2, k = p.trim() !== "";
|
|
337
337
|
$(n && k);
|
|
338
338
|
}, [f, p]);
|
|
339
339
|
const re = () => {
|
|
340
340
|
const n = {};
|
|
341
341
|
return f.trim() ? f.length < 2 && (n.name = "Name must be at least 2 characters") : n.name = "Name is required", p || (n.group = "Group is required"), W(n), Object.keys(n).length === 0;
|
|
342
|
-
}, { resetLibrary: ae } = ue({ id: "" }), z =
|
|
343
|
-
c || O([t], { _libBlockId: n.id }), N.success(`Block ${c ? "updated" : "saved"} successfully`), ae(n.library),
|
|
342
|
+
}, { resetLibrary: ae } = ue({ id: "" }), z = Ie((n) => {
|
|
343
|
+
c || O([t], { _libBlockId: n.id }), N.success(`Block ${c ? "updated" : "saved"} successfully`), ae(n.library), i();
|
|
344
344
|
}), se = async (n) => {
|
|
345
345
|
if (n.preventDefault(), !re()) return;
|
|
346
346
|
const k = y.map((v) => (Ce(v, "_libBlockId") && delete v._libBlockId, v));
|
|
@@ -355,23 +355,23 @@ const we = (r) => {
|
|
|
355
355
|
...c ? { id: u } : {}
|
|
356
356
|
});
|
|
357
357
|
}, T = z.isPending;
|
|
358
|
-
return H || F ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center p-8", children: /* @__PURE__ */ e("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" }) }) : X ? /* @__PURE__ */
|
|
358
|
+
return H || F ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center p-8", children: /* @__PURE__ */ e("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" }) }) : X ? /* @__PURE__ */ o("div", { className: "space-y-4 p-6", children: [
|
|
359
359
|
/* @__PURE__ */ e("div", { className: "font-medium text-destructive", children: "Block Not Found" }),
|
|
360
360
|
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: "This block could not be found on the server. It may have been deleted." }),
|
|
361
|
-
/* @__PURE__ */
|
|
362
|
-
/* @__PURE__ */ e(b, { type: "button", variant: "outline", onClick:
|
|
361
|
+
/* @__PURE__ */ o("div", { className: "flex justify-end gap-2 pt-4", children: [
|
|
362
|
+
/* @__PURE__ */ e(b, { type: "button", variant: "outline", onClick: i, children: "Cancel" }),
|
|
363
363
|
/* @__PURE__ */ e(b, { onClick: te, variant: "destructive", children: "Delink Block" })
|
|
364
364
|
] })
|
|
365
|
-
] }) : /* @__PURE__ */
|
|
366
|
-
d && /* @__PURE__ */
|
|
365
|
+
] }) : /* @__PURE__ */ o("div", { children: [
|
|
366
|
+
d && /* @__PURE__ */ o("div", { className: "mb-4 flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-destructive", children: [
|
|
367
367
|
/* @__PURE__ */ e(ye, { className: "mt-0.5 h-5 w-5 flex-shrink-0" }),
|
|
368
|
-
/* @__PURE__ */
|
|
368
|
+
/* @__PURE__ */ o("div", { children: [
|
|
369
369
|
/* @__PURE__ */ e("p", { className: "font-medium", children: "Partial Blocks Detected" }),
|
|
370
370
|
/* @__PURE__ */ e("p", { className: "mt-1 text-xs", children: "This block contains one or more Partial Blocks. Partial blocks will be merged into the library block" })
|
|
371
371
|
] })
|
|
372
372
|
] }),
|
|
373
|
-
/* @__PURE__ */
|
|
374
|
-
/* @__PURE__ */
|
|
373
|
+
/* @__PURE__ */ o("form", { onSubmit: se, className: "space-y-4", children: [
|
|
374
|
+
/* @__PURE__ */ o("div", { className: "space-y-2", children: [
|
|
375
375
|
/* @__PURE__ */ e(P, { htmlFor: "name", className: C.name ? "text-destructive" : "", children: "Name" }),
|
|
376
376
|
/* @__PURE__ */ e(
|
|
377
377
|
L,
|
|
@@ -385,12 +385,12 @@ const we = (r) => {
|
|
|
385
385
|
),
|
|
386
386
|
C.name && /* @__PURE__ */ e("p", { className: "text-xs text-destructive", children: C.name })
|
|
387
387
|
] }),
|
|
388
|
-
/* @__PURE__ */
|
|
388
|
+
/* @__PURE__ */ o("div", { className: "space-y-2", children: [
|
|
389
389
|
/* @__PURE__ */ e(P, { htmlFor: "group", className: C.group ? "text-destructive" : "", children: "Group" }),
|
|
390
390
|
/* @__PURE__ */ e(_e, { value: p, onChange: s }),
|
|
391
391
|
C.group && /* @__PURE__ */ e("p", { className: "text-xs text-destructive", children: C.group })
|
|
392
392
|
] }),
|
|
393
|
-
/* @__PURE__ */
|
|
393
|
+
/* @__PURE__ */ o("div", { className: "space-y-2", children: [
|
|
394
394
|
/* @__PURE__ */ e(P, { htmlFor: "description", children: "Description (optional)" }),
|
|
395
395
|
/* @__PURE__ */ e(
|
|
396
396
|
L,
|
|
@@ -403,11 +403,11 @@ const we = (r) => {
|
|
|
403
403
|
}
|
|
404
404
|
)
|
|
405
405
|
] }),
|
|
406
|
-
/* @__PURE__ */
|
|
406
|
+
/* @__PURE__ */ o("div", { className: "space-y-2", children: [
|
|
407
407
|
/* @__PURE__ */ e(P, { htmlFor: "previewImage", children: "Preview Image (optional)" }),
|
|
408
408
|
/* @__PURE__ */ e(De, { value: x, onChange: U })
|
|
409
409
|
] }),
|
|
410
|
-
/* @__PURE__ */
|
|
410
|
+
/* @__PURE__ */ o("div", { className: "flex justify-end gap-2 pt-2", children: [
|
|
411
411
|
c && ee && /* @__PURE__ */ e(
|
|
412
412
|
Pe,
|
|
413
413
|
{
|
|
@@ -415,10 +415,10 @@ const we = (r) => {
|
|
|
415
415
|
libBlockId: u,
|
|
416
416
|
blockName: f,
|
|
417
417
|
className: "mr-auto",
|
|
418
|
-
close:
|
|
418
|
+
close: i
|
|
419
419
|
}
|
|
420
420
|
),
|
|
421
|
-
/* @__PURE__ */ e(b, { type: "button", variant: "outline", onClick:
|
|
421
|
+
/* @__PURE__ */ e(b, { type: "button", variant: "outline", onClick: i, disabled: T, children: "Cancel" }),
|
|
422
422
|
/* @__PURE__ */ e(b, { type: "submit", disabled: T || !Q, children: T ? "Saving..." : c ? "Update Block" : "Save Block" })
|
|
423
423
|
] })
|
|
424
424
|
] })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("./register-chai-top-bar-DyW9GPzV.cjs"),x=require("./index-DrzR7vXl.cjs"),b=require("./index-Dh-fEHei.cjs"),C=require("@tanstack/react-query"),X=require("jotai"),j=require("sonner"),E=require("lucide-react"),i=require("react"),J=require("./image-compression-UaU7Bwqe.cjs"),R=require("lodash-es"),Z=s=>{const r=b.useApiUrl(),l=b.useFetch();return C.useMutation({mutationFn:async t=>l(r,{action:b.ACTIONS.UPSERT_LIBRARY_ITEM,data:t}),onSuccess:t=>{s?s(t):j.toast.success("Block saved successfully")},onError:t=>{console.error("Error saving block:",t),j.toast.error("Failed to save block",{description:t instanceof Error?t.message:"Unknown error"})}})},ee=s=>{const r=b.useApiUrl(),l=b.useFetch();return C.useQuery({staleTime:"static",queryKey:[b.ACTIONS.GET_LIBRARY_ITEM,s],enabled:!!s,queryFn:async()=>{if(!s)return null;try{return await l(r,{action:b.ACTIONS.GET_LIBRARY_ITEM,data:{id:s}})}catch(t){throw console.error(t),new Error("The block could not be found on the server. It may have been deleted.")}},retry:!1})},te=s=>{const r=b.useApiUrl(),l=b.useFetch(),t=X.useSetAtom(x.libraryBlocksAtom);return C.useMutation({mutationFn:async c=>l(r,{action:b.ACTIONS.DELETE_LIBRARY_ITEM,data:{id:c}}),onSuccess:()=>{t(c=>{const m={...c};return Object.keys(m).forEach(u=>{m[u]={loading:"idle",blocks:[],error:!1}}),m}),s?s():j.toast.success("Block deleted successfully")},onError:c=>{console.error("Error deleting block:",c),j.toast.error("Failed to delete block",{description:c instanceof Error?c.message:"Unknown error"})}})},se=({blockId:s,libBlockId:r,isOpen:l,onClose:t,blockName:c,trigger:m})=>{const[u,o]=i.useState(!1),d=x.useUpdateBlocksPropsRealtime(),y=te(()=>{d([s],{_libBlockId:void 0}),j.toast.success("Block deleted successfully"),o(!1),t()}),h=()=>{o(!0),y.mutate(r)},g=e.jsxs(p.Button,{type:"button",variant:"destructive",size:"sm",onClick:f=>f.preventDefault(),disabled:u,children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]});return e.jsxs(x.Popover,{open:l,onOpenChange:f=>!f&&t(),children:[e.jsx(x.PopoverTrigger,{asChild:!0,children:m||g}),e.jsx(x.PopoverContent,{className:"z-[9999] w-72 p-4",sideOffset:5,align:"center",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-medium",children:"Delete Block"}),e.jsxs("p",{className:"text-sm",children:["Are you sure you want to delete the block",e.jsxs("span",{className:"font-medium",children:[' "',c,'"']}),"?"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This block will be permanently removed from the library. This action cannot be undone."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(p.Button,{type:"button",variant:"outline",size:"sm",onClick:t,disabled:u,children:"Cancel"}),e.jsx(p.Button,{type:"button",variant:"destructive",size:"sm",onClick:h,disabled:u,children:u?"Deleting...":"Delete"})]})]})})]})},re=({blockId:s,libBlockId:r,blockName:l,size:t="sm",className:c="",close:m})=>{const[u,o]=i.useState(!1);return e.jsx(se,{blockId:s,libBlockId:r,isOpen:u,onClose:()=>{o(!1),m()},blockName:l,trigger:e.jsxs(p.Button,{type:"button",variant:"destructive",size:t,className:c,onClick:()=>o(!0),children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})})},ne=()=>{const s=b.useApiUrl(),r=b.useFetch(),l=C.useQueryClient(),{data:t=[],isLoading:c,error:m}=C.useQuery({queryKey:["library-groups"],staleTime:"static",placeholderData:[],queryFn:async()=>{try{return await r(s,{action:"GET_LIBRARY_GROUPS"})||[]}catch(d){return console.error("Error fetching library groups:",d),[]}}}),{mutateAsync:u,isPending:o}=C.useMutation({mutationFn:async d=>{if(!d.trim())throw new Error("Group name is required");return r(s,{action:"CREATE_BLOCK_GROUP",data:{name:d}})},onSuccess:()=>{l.invalidateQueries({queryKey:["library-groups"]}),j.toast.success("Group created successfully")},onError:d=>{console.error("Error creating group:",d),j.toast.error("Failed to create group",{description:d instanceof Error?d.message:"Unknown error"})}});return{groups:t,isLoading:c,error:m,createGroup:u,isCreating:o}},ae=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),[c,m]=i.useState(""),u=i.useRef(null),{groups:o}=ne(),[d,y]=i.useState([{id:"hero",name:"Hero"},{id:"feature",name:"Feature"},{id:"footer",name:"Footer"},{id:"content",name:"Content"},{id:"testimonial",name:"Testimonial"},{id:"pricing",name:"Pricing"},{id:"login",name:"Login"},{id:"logos",name:"Logos"},{id:"about",name:"About"},{id:"banner",name:"Banner"},{id:"blog",name:"Blog"},{id:"careers",name:"Careers"},{id:"casestudy",name:"Casestudy"},{id:"changelog",name:"Changelog"},{id:"compare",name:"Compare"},{id:"contact",name:"Contact"},{id:"cta",name:"Cta"},{id:"faq",name:"Faq"},{id:"gallery",name:"Gallery"},{id:"integration",name:"Integration"},{id:"list",name:"List"},{id:"navbar",name:"Navbar"},{id:"product",name:"Product"},{id:"signup",name:"Signup"},{id:"stats",name:"Stats"},{id:"team",name:"Team"},{id:"timeline",name:"Timeline"}]),h=i.useMemo(()=>[...o,...d.filter(n=>!o.some(B=>B.id===n.id))],[o,d]),g=()=>{const n=c.trim();if(!n)return;const B={id:n,name:n};y(w=>[...w,B]),r(B.id),m(""),t(!1)};i.useEffect(()=>{l&&u.current&&u.current.focus()},[l]);const f=n=>{n.key==="Enter"&&(n.preventDefault(),g())};return i.useEffect(()=>{s&&!h.some(n=>n.id===s)&&r("")},[s,h,r]),l?e.jsxs("div",{className:"space-y-2",children:[e.jsx(p.Input,{ref:u,placeholder:"Enter new group name",value:c,onChange:n=>m(n.target.value),onKeyDown:f}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(p.Button,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(p.Button,{size:"sm",onClick:g,children:"Create"})]})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",value:s,onChange:n=>r(n.target.value),children:[e.jsx("option",{value:"",children:"Select a group"}),o.length>0&&e.jsx("optgroup",{label:"Library Groups",children:o.map(n=>e.jsx("option",{value:n.id,children:n.name},`lib-${n.id}`))}),d.length>0&&e.jsx("optgroup",{label:"Predefined Groups",children:d.filter(n=>!o.some(B=>B.id===n.id)).map(n=>e.jsx("option",{value:n.id,children:n.name},`local-${n.id}`))})]}),e.jsx(p.Button,{type:"button",size:"icon",variant:"outline",onClick:()=>t(!0),children:e.jsx(E.Plus,{className:"h-4 w-4"})})]})},oe=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),c=i.useRef(null),m=i.useCallback(async d=>{var h;const y=(h=d.target.files)==null?void 0:h[0];if(y)try{t(!0);let g=y;y.type.startsWith("image/")&&(g=await J.compressImageIfNeeded(y));const f=new FileReader;f.onloadend=()=>{r(f.result),t(!1)},f.readAsDataURL(g)}catch(g){console.error("Error reading file:",g),t(!1),j.toast.error("Failed to process image",{description:g instanceof Error?g.message:"Unknown error"})}},[r]),u=()=>{r(""),c.current&&(c.current.value="")},o=()=>{var d;(d=c.current)==null||d.click()};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p.Input,{type:"file",ref:c,onChange:m,accept:"image/*",className:"hidden"}),e.jsx(p.Button,{type:"button",variant:"outline",onClick:o,disabled:l,className:"w-full",children:l?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Uploading..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(E.ImageIcon,{className:"h-4 w-4"}),"Select image"]})}),s&&e.jsx(p.Button,{type:"button",variant:"outline",size:"icon",onClick:u,children:e.jsx(E.X,{className:"h-4 w-4"})})]}),s&&e.jsx("div",{className:"aspect-video h-[200px] max-h-[200px] overflow-hidden rounded-md border",children:e.jsx("img",{src:s,alt:"Preview",className:"h-full w-full object-contain"})})]})},ie=s=>{const{blocks:r,close:l,blockId:t}=s,{getPartialBlocks:c}=x.usePartialBlocksStore(),m=r.find(a=>a._id===t),u=m==null?void 0:m._libBlockId,o=!!u,d=i.useMemo(()=>r.some(a=>a._type==="PartialBlock"||a._type==="GlobalBlock"),[r]),y=i.useMemo(()=>{let a=[];for(const k of r)if(k._type==="PartialBlock"||k._type==="GlobalBlock"){let v=c(k.partialBlockId);k._parent&&(v==null?void 0:v.length)>0&&(v=v.map(T=>(R.isEmpty(T._parent)&&R.set(T,"_parent",k._parent),T))),a=[...a,...v]}else a.push(k);return a},[r,c]),[h,g]=i.useState(""),[f,n]=i.useState(""),[B,w]=i.useState(""),[S,_]=i.useState(""),[N,U]=i.useState({}),[q,M]=i.useState(!1),[O,F]=i.useState(o),[z,K]=i.useState(!1),{hasPermission:Y}=x.usePermissions(),Q=Y(b.PAGES_PERMISSIONS.DELETE_LIBRARY_BLOCK),D=x.useUpdateBlocksPropsRealtime(),V=()=>{D([t],{_libBlockId:void 0}),j.toast.success("Block delinked from library"),l()},{data:I,isLoading:P,isError:G}=ee(u);i.useEffect(()=>{G&&o&&(K(!0),F(!1))},[G,o]),i.useEffect(()=>{I&&!P&&(g(I.name||""),n(I.group||""),w(I.description||""),_(I.preview||""),F(!1))},[I,P]),i.useEffect(()=>{const a=h.trim().length>=2,k=f.trim()!=="";M(a&&k)},[h,f]);const W=()=>{const a={};return h.trim()?h.length<2&&(a.name="Name must be at least 2 characters"):a.name="Name is required",f||(a.group="Group is required"),U(a),Object.keys(a).length===0},{resetLibrary:$}=x.useLibraryBlocks({id:""}),A=Z(a=>{o||D([t],{_libBlockId:a.id}),j.toast.success(`Block ${o?"updated":"saved"} successfully`),$(a.library),l()}),H=async a=>{if(a.preventDefault(),!W())return;const k=y.map(v=>(R.has(v,"_libBlockId")&&delete v._libBlockId,v));A.mutate({name:h.trim(),group:f,blocks:k,description:B.trim(),...S&&S.startsWith("data:")?{previewImage:S}:{},...o?{id:u}:{}})},L=A.isPending;return O||P?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):z?e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsx("div",{className:"font-medium text-destructive",children:"Block Not Found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This block could not be found on the server. It may have been deleted."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(p.Button,{type:"button",variant:"outline",onClick:l,children:"Cancel"}),e.jsx(p.Button,{onClick:V,variant:"destructive",children:"Delink Block"})]})]}):e.jsxs("div",{children:[d&&e.jsxs("div",{className:"mb-4 flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-destructive",children:[e.jsx(E.AlertCircle,{className:"mt-0.5 h-5 w-5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Partial Blocks Detected"}),e.jsx("p",{className:"mt-1 text-xs",children:"This block contains one or more Partial Blocks. Partial blocks will be merged into the library block"})]})]}),e.jsxs("form",{onSubmit:H,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"name",className:N.name?"text-destructive":"",children:"Name"}),e.jsx(p.Input,{id:"name",placeholder:"Enter block name",value:h,onChange:a=>g(a.target.value),className:N.name?"border-destructive":""}),N.name&&e.jsx("p",{className:"text-xs text-destructive",children:N.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"group",className:N.group?"text-destructive":"",children:"Group"}),e.jsx(ae,{value:f,onChange:n}),N.group&&e.jsx("p",{className:"text-xs text-destructive",children:N.group})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(p.Input,{id:"description",placeholder:"Enter a brief description",className:"resize-none",value:B,onChange:a=>w(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"previewImage",children:"Preview Image (optional)"}),e.jsx(oe,{value:S,onChange:_})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o&&Q&&e.jsx(re,{blockId:t,libBlockId:u,blockName:h,className:"mr-auto",close:l}),e.jsx(p.Button,{type:"button",variant:"outline",onClick:l,disabled:L,children:"Cancel"}),e.jsx(p.Button,{type:"submit",disabled:L||!q,children:L?"Saving...":o?"Update Block":"Save Block"})]})]})]})};exports.default=ie;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("./register-chai-top-bar-DyW9GPzV.cjs"),x=require("./index-DrzR7vXl.cjs"),b=require("./index-DXBHjFwY.cjs"),C=require("@tanstack/react-query"),X=require("jotai"),j=require("sonner"),E=require("lucide-react"),i=require("react"),J=require("./image-compression-UaU7Bwqe.cjs"),R=require("lodash-es"),Z=s=>{const r=b.useApiUrl(),l=b.useFetch();return C.useMutation({mutationFn:async t=>l(r,{action:b.ACTIONS.UPSERT_LIBRARY_ITEM,data:t}),onSuccess:t=>{s?s(t):j.toast.success("Block saved successfully")},onError:t=>{console.error("Error saving block:",t),j.toast.error("Failed to save block",{description:t instanceof Error?t.message:"Unknown error"})}})},ee=s=>{const r=b.useApiUrl(),l=b.useFetch();return C.useQuery({staleTime:"static",queryKey:[b.ACTIONS.GET_LIBRARY_ITEM,s],enabled:!!s,queryFn:async()=>{if(!s)return null;try{return await l(r,{action:b.ACTIONS.GET_LIBRARY_ITEM,data:{id:s}})}catch(t){throw console.error(t),new Error("The block could not be found on the server. It may have been deleted.")}},retry:!1})},te=s=>{const r=b.useApiUrl(),l=b.useFetch(),t=X.useSetAtom(x.libraryBlocksAtom);return C.useMutation({mutationFn:async c=>l(r,{action:b.ACTIONS.DELETE_LIBRARY_ITEM,data:{id:c}}),onSuccess:()=>{t(c=>{const m={...c};return Object.keys(m).forEach(u=>{m[u]={loading:"idle",blocks:[],error:!1}}),m}),s?s():j.toast.success("Block deleted successfully")},onError:c=>{console.error("Error deleting block:",c),j.toast.error("Failed to delete block",{description:c instanceof Error?c.message:"Unknown error"})}})},se=({blockId:s,libBlockId:r,isOpen:l,onClose:t,blockName:c,trigger:m})=>{const[u,o]=i.useState(!1),d=x.useUpdateBlocksPropsRealtime(),y=te(()=>{d([s],{_libBlockId:void 0}),j.toast.success("Block deleted successfully"),o(!1),t()}),h=()=>{o(!0),y.mutate(r)},g=e.jsxs(p.Button,{type:"button",variant:"destructive",size:"sm",onClick:f=>f.preventDefault(),disabled:u,children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]});return e.jsxs(x.Popover,{open:l,onOpenChange:f=>!f&&t(),children:[e.jsx(x.PopoverTrigger,{asChild:!0,children:m||g}),e.jsx(x.PopoverContent,{className:"z-[9999] w-72 p-4",sideOffset:5,align:"center",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-medium",children:"Delete Block"}),e.jsxs("p",{className:"text-sm",children:["Are you sure you want to delete the block",e.jsxs("span",{className:"font-medium",children:[' "',c,'"']}),"?"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This block will be permanently removed from the library. This action cannot be undone."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(p.Button,{type:"button",variant:"outline",size:"sm",onClick:t,disabled:u,children:"Cancel"}),e.jsx(p.Button,{type:"button",variant:"destructive",size:"sm",onClick:h,disabled:u,children:u?"Deleting...":"Delete"})]})]})})]})},re=({blockId:s,libBlockId:r,blockName:l,size:t="sm",className:c="",close:m})=>{const[u,o]=i.useState(!1);return e.jsx(se,{blockId:s,libBlockId:r,isOpen:u,onClose:()=>{o(!1),m()},blockName:l,trigger:e.jsxs(p.Button,{type:"button",variant:"destructive",size:t,className:c,onClick:()=>o(!0),children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})})},ne=()=>{const s=b.useApiUrl(),r=b.useFetch(),l=C.useQueryClient(),{data:t=[],isLoading:c,error:m}=C.useQuery({queryKey:["library-groups"],staleTime:"static",placeholderData:[],queryFn:async()=>{try{return await r(s,{action:"GET_LIBRARY_GROUPS"})||[]}catch(d){return console.error("Error fetching library groups:",d),[]}}}),{mutateAsync:u,isPending:o}=C.useMutation({mutationFn:async d=>{if(!d.trim())throw new Error("Group name is required");return r(s,{action:"CREATE_BLOCK_GROUP",data:{name:d}})},onSuccess:()=>{l.invalidateQueries({queryKey:["library-groups"]}),j.toast.success("Group created successfully")},onError:d=>{console.error("Error creating group:",d),j.toast.error("Failed to create group",{description:d instanceof Error?d.message:"Unknown error"})}});return{groups:t,isLoading:c,error:m,createGroup:u,isCreating:o}},ae=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),[c,m]=i.useState(""),u=i.useRef(null),{groups:o}=ne(),[d,y]=i.useState([{id:"hero",name:"Hero"},{id:"feature",name:"Feature"},{id:"footer",name:"Footer"},{id:"content",name:"Content"},{id:"testimonial",name:"Testimonial"},{id:"pricing",name:"Pricing"},{id:"login",name:"Login"},{id:"logos",name:"Logos"},{id:"about",name:"About"},{id:"banner",name:"Banner"},{id:"blog",name:"Blog"},{id:"careers",name:"Careers"},{id:"casestudy",name:"Casestudy"},{id:"changelog",name:"Changelog"},{id:"compare",name:"Compare"},{id:"contact",name:"Contact"},{id:"cta",name:"Cta"},{id:"faq",name:"Faq"},{id:"gallery",name:"Gallery"},{id:"integration",name:"Integration"},{id:"list",name:"List"},{id:"navbar",name:"Navbar"},{id:"product",name:"Product"},{id:"signup",name:"Signup"},{id:"stats",name:"Stats"},{id:"team",name:"Team"},{id:"timeline",name:"Timeline"}]),h=i.useMemo(()=>[...o,...d.filter(n=>!o.some(B=>B.id===n.id))],[o,d]),g=()=>{const n=c.trim();if(!n)return;const B={id:n,name:n};y(w=>[...w,B]),r(B.id),m(""),t(!1)};i.useEffect(()=>{l&&u.current&&u.current.focus()},[l]);const f=n=>{n.key==="Enter"&&(n.preventDefault(),g())};return i.useEffect(()=>{s&&!h.some(n=>n.id===s)&&r("")},[s,h,r]),l?e.jsxs("div",{className:"space-y-2",children:[e.jsx(p.Input,{ref:u,placeholder:"Enter new group name",value:c,onChange:n=>m(n.target.value),onKeyDown:f}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(p.Button,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(p.Button,{size:"sm",onClick:g,children:"Create"})]})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",value:s,onChange:n=>r(n.target.value),children:[e.jsx("option",{value:"",children:"Select a group"}),o.length>0&&e.jsx("optgroup",{label:"Library Groups",children:o.map(n=>e.jsx("option",{value:n.id,children:n.name},`lib-${n.id}`))}),d.length>0&&e.jsx("optgroup",{label:"Predefined Groups",children:d.filter(n=>!o.some(B=>B.id===n.id)).map(n=>e.jsx("option",{value:n.id,children:n.name},`local-${n.id}`))})]}),e.jsx(p.Button,{type:"button",size:"icon",variant:"outline",onClick:()=>t(!0),children:e.jsx(E.Plus,{className:"h-4 w-4"})})]})},oe=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),c=i.useRef(null),m=i.useCallback(async d=>{var h;const y=(h=d.target.files)==null?void 0:h[0];if(y)try{t(!0);let g=y;y.type.startsWith("image/")&&(g=await J.compressImageIfNeeded(y));const f=new FileReader;f.onloadend=()=>{r(f.result),t(!1)},f.readAsDataURL(g)}catch(g){console.error("Error reading file:",g),t(!1),j.toast.error("Failed to process image",{description:g instanceof Error?g.message:"Unknown error"})}},[r]),u=()=>{r(""),c.current&&(c.current.value="")},o=()=>{var d;(d=c.current)==null||d.click()};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p.Input,{type:"file",ref:c,onChange:m,accept:"image/*",className:"hidden"}),e.jsx(p.Button,{type:"button",variant:"outline",onClick:o,disabled:l,className:"w-full",children:l?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Uploading..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(E.ImageIcon,{className:"h-4 w-4"}),"Select image"]})}),s&&e.jsx(p.Button,{type:"button",variant:"outline",size:"icon",onClick:u,children:e.jsx(E.X,{className:"h-4 w-4"})})]}),s&&e.jsx("div",{className:"aspect-video h-[200px] max-h-[200px] overflow-hidden rounded-md border",children:e.jsx("img",{src:s,alt:"Preview",className:"h-full w-full object-contain"})})]})},ie=s=>{const{blocks:r,close:l,blockId:t}=s,{getPartialBlocks:c}=x.usePartialBlocksStore(),m=r.find(a=>a._id===t),u=m==null?void 0:m._libBlockId,o=!!u,d=i.useMemo(()=>r.some(a=>a._type==="PartialBlock"||a._type==="GlobalBlock"),[r]),y=i.useMemo(()=>{let a=[];for(const k of r)if(k._type==="PartialBlock"||k._type==="GlobalBlock"){let v=c(k.partialBlockId);k._parent&&(v==null?void 0:v.length)>0&&(v=v.map(T=>(R.isEmpty(T._parent)&&R.set(T,"_parent",k._parent),T))),a=[...a,...v]}else a.push(k);return a},[r,c]),[h,g]=i.useState(""),[f,n]=i.useState(""),[B,w]=i.useState(""),[S,_]=i.useState(""),[N,U]=i.useState({}),[q,M]=i.useState(!1),[O,F]=i.useState(o),[z,K]=i.useState(!1),{hasPermission:Y}=x.usePermissions(),Q=Y(b.PAGES_PERMISSIONS.DELETE_LIBRARY_BLOCK),D=x.useUpdateBlocksPropsRealtime(),V=()=>{D([t],{_libBlockId:void 0}),j.toast.success("Block delinked from library"),l()},{data:I,isLoading:P,isError:G}=ee(u);i.useEffect(()=>{G&&o&&(K(!0),F(!1))},[G,o]),i.useEffect(()=>{I&&!P&&(g(I.name||""),n(I.group||""),w(I.description||""),_(I.preview||""),F(!1))},[I,P]),i.useEffect(()=>{const a=h.trim().length>=2,k=f.trim()!=="";M(a&&k)},[h,f]);const W=()=>{const a={};return h.trim()?h.length<2&&(a.name="Name must be at least 2 characters"):a.name="Name is required",f||(a.group="Group is required"),U(a),Object.keys(a).length===0},{resetLibrary:$}=x.useLibraryBlocks({id:""}),A=Z(a=>{o||D([t],{_libBlockId:a.id}),j.toast.success(`Block ${o?"updated":"saved"} successfully`),$(a.library),l()}),H=async a=>{if(a.preventDefault(),!W())return;const k=y.map(v=>(R.has(v,"_libBlockId")&&delete v._libBlockId,v));A.mutate({name:h.trim(),group:f,blocks:k,description:B.trim(),...S&&S.startsWith("data:")?{previewImage:S}:{},...o?{id:u}:{}})},L=A.isPending;return O||P?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):z?e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsx("div",{className:"font-medium text-destructive",children:"Block Not Found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This block could not be found on the server. It may have been deleted."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(p.Button,{type:"button",variant:"outline",onClick:l,children:"Cancel"}),e.jsx(p.Button,{onClick:V,variant:"destructive",children:"Delink Block"})]})]}):e.jsxs("div",{children:[d&&e.jsxs("div",{className:"mb-4 flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-destructive",children:[e.jsx(E.AlertCircle,{className:"mt-0.5 h-5 w-5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Partial Blocks Detected"}),e.jsx("p",{className:"mt-1 text-xs",children:"This block contains one or more Partial Blocks. Partial blocks will be merged into the library block"})]})]}),e.jsxs("form",{onSubmit:H,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"name",className:N.name?"text-destructive":"",children:"Name"}),e.jsx(p.Input,{id:"name",placeholder:"Enter block name",value:h,onChange:a=>g(a.target.value),className:N.name?"border-destructive":""}),N.name&&e.jsx("p",{className:"text-xs text-destructive",children:N.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"group",className:N.group?"text-destructive":"",children:"Group"}),e.jsx(ae,{value:f,onChange:n}),N.group&&e.jsx("p",{className:"text-xs text-destructive",children:N.group})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(p.Input,{id:"description",placeholder:"Enter a brief description",className:"resize-none",value:B,onChange:a=>w(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"previewImage",children:"Preview Image (optional)"}),e.jsx(oe,{value:S,onChange:_})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o&&Q&&e.jsx(re,{blockId:t,libBlockId:u,blockName:h,className:"mr-auto",close:l}),e.jsx(p.Button,{type:"button",variant:"outline",onClick:l,disabled:L,children:"Cancel"}),e.jsx(p.Button,{type:"submit",disabled:L||!q,children:L?"Saving...":o?"Update Block":"Save Block"})]})]})]})};exports.default=ie;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const o=require("react/jsx-runtime"),r=require("./register-chai-top-bar-DyW9GPzV.cjs"),m=require("lucide-react"),i=require("react"),p=require("use-stick-to-bottom"),T=require("streamdown");require("@radix-ui/react-slot");const P=require("class-variance-authority"),_=require("./index-DrzR7vXl.cjs");require("clsx");require("tailwind-merge");const z=require("@radix-ui/react-tooltip"),j=require("@radix-ui/react-use-controllable-state"),B=require("@radix-ui/react-collapsible"),D=require("framer-motion"),f=require("./index-
|
|
1
|
+
"use strict";const o=require("react/jsx-runtime"),r=require("./register-chai-top-bar-DyW9GPzV.cjs"),m=require("lucide-react"),i=require("react"),p=require("use-stick-to-bottom"),T=require("streamdown");require("@radix-ui/react-slot");const P=require("class-variance-authority"),_=require("./index-DrzR7vXl.cjs");require("clsx");require("tailwind-merge");const z=require("@radix-ui/react-tooltip"),j=require("@radix-ui/react-use-controllable-state"),B=require("@radix-ui/react-collapsible"),D=require("framer-motion"),f=require("./index-DXBHjFwY.cjs"),I=require("react-i18next");function h(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const L=h(i),S=h(z),b=h(B),G=({className:e,...t})=>o.jsx(p.StickToBottom,{className:r.cn("relative flex-1 overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...t}),$=({className:e,...t})=>o.jsx(p.StickToBottom.Content,{className:r.cn("flex flex-col gap-8 p-4",e),...t}),F=({className:e,title:t="No messages yet",description:s="Start a conversation to see messages here",icon:n,children:a,...l})=>o.jsx("div",{className:r.cn("flex size-full flex-col items-center justify-center gap-3 p-8 text-center",e),...l,children:a??o.jsxs(o.Fragment,{children:[n&&o.jsx("div",{className:"text-muted-foreground",children:n}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("h3",{className:"text-sm font-medium",children:t}),s&&o.jsx("p",{className:"text-sm text-muted-foreground",children:s})]})]})}),Q=({className:e,...t})=>{const{isAtBottom:s,scrollToBottom:n}=p.useStickToBottomContext(),a=i.useCallback(()=>{n()},[n]);return!s&&o.jsx(r.Button,{className:r.cn("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full",e),onClick:a,size:"icon",type:"button",variant:"outline",...t,children:o.jsx(m.ArrowDownIcon,{className:"size-4"})})};P.cva("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}});const V=L.forwardRef(({className:e,sideOffset:t=4,...s},n)=>o.jsx(S.Content,{ref:n,sideOffset:t,className:r.cn("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",e),...s}));V.displayName=S.Content.displayName;const K=({className:e,from:t,...s})=>o.jsx("div",{className:r.cn("group flex w-full max-w-[80%] flex-col gap-2",t==="user"?"is-user ml-auto justify-end":"is-assistant",e),...s}),Y=({children:e,className:t,...s})=>o.jsx("div",{className:r.cn("is-user:dark flex w-fit flex-col gap-2 overflow-hidden text-sm","group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground",t),...s,children:e});i.createContext(null);const w=i.memo(({className:e,...t})=>o.jsx(T.Streamdown,{className:r.cn("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t}),(e,t)=>e.children===t.children);w.displayName="MessageResponse";const J=b.Root,X=b.CollapsibleTrigger,H=b.CollapsibleContent,W=({children:e,as:t="p",className:s,duration:n=2,spread:a=2})=>{const l=D.motion.create(t),g=i.useMemo(()=>((e==null?void 0:e.length)??0)*a,[e,a]);return o.jsx(l,{animate:{backgroundPosition:"0% center"},className:r.cn("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",s),initial:{backgroundPosition:"100% center"},style:{"--spread":`${g}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:n,ease:"linear"},children:e})},E=i.memo(W),R=i.createContext(null),Z=()=>{const e=i.useContext(R);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},ee=1e3,te=1e3,y=i.memo(({className:e,isStreaming:t=!1,open:s,defaultOpen:n=!0,onOpenChange:a,duration:l,children:g,...U})=>{const[c,d]=j.useControllableState({prop:s,defaultProp:n,onChange:a}),[M,v]=j.useControllableState({prop:l,defaultProp:void 0}),[N,q]=i.useState(!1),[u,C]=i.useState(null);i.useEffect(()=>{t?u===null&&C(Date.now()):u!==null&&(v(Math.ceil((Date.now()-u)/te)),C(null))},[t,u,v]),i.useEffect(()=>{if(n&&!t&&c&&!N){const x=setTimeout(()=>{d(!1),q(!0)},ee);return()=>clearTimeout(x)}},[t,c,n,d,N]);const O=x=>{d(x)};return o.jsx(R.Provider,{value:{isStreaming:t,isOpen:c,setIsOpen:d,duration:M},children:o.jsx(J,{className:r.cn("not-prose mb-4",e),onOpenChange:O,open:c,...U,children:g})})}),oe=(e,t)=>e||t===0?o.jsx(E,{duration:1,children:"Thinking..."}):t===void 0?o.jsx("p",{children:"Thought for a few seconds"}):o.jsxs("p",{children:["Thought for ",t," seconds"]}),A=i.memo(({className:e,children:t,...s})=>{const{isStreaming:n,isOpen:a,duration:l}=Z();return o.jsx(X,{className:r.cn("flex w-full items-center gap-2 text-sm text-muted-foreground transition-colors hover:text-foreground",e),...s,children:t??o.jsxs(o.Fragment,{children:[o.jsx(m.BrainIcon,{className:"size-4"}),oe(n,l),o.jsx(m.ChevronDownIcon,{className:r.cn("size-4 transition-transform",a?"rotate-180":"rotate-0")})]})})}),k=i.memo(({className:e,children:t,...s})=>o.jsx(H,{className:r.cn("mt-4 text-sm","text-muted-foreground outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2",e),...s,children:o.jsx(T.Streamdown,{...s,children:t})}));y.displayName="Reasoning";A.displayName="ReasoningTrigger";k.displayName="ReasoningContent";const se=({className:e,content:t,isLoading:s=!1,...n})=>o.jsx("div",{className:r.cn("is-assistant flex w-full max-w-[80%] flex-col gap-2",e),...n,children:o.jsx("div",{className:"flex w-fit flex-col gap-2 overflow-hidden text-sm",children:o.jsx("div",{className:"flex items-center gap-2 rounded-lg border border-muted-foreground/20 bg-muted/50 p-3",children:o.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[s&&o.jsx(E,{duration:1.5,children:t}),!s&&o.jsx("div",{className:"text-xs text-muted-foreground",children:t})]})})})});function ne({userInput:e,language:t="en",currentHtml:s}){const n=f.LANGUAGES[t]||"English";return s&&s.trim().length>0?`
|
|
2
2
|
MODE: EDIT
|
|
3
3
|
CURRENT HTML:
|
|
4
4
|
${s}
|