@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,524 @@
|
|
|
1
|
+
var D = Object.defineProperty;
|
|
2
|
+
var F = (l, r, e) => r in l ? D(l, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : l[r] = e;
|
|
3
|
+
var y = (l, r, e) => F(l, typeof r != "symbol" ? r + "" : r, e);
|
|
4
|
+
import { g as T, C as f } from "./actions-registery-CZ1w0NKa.js";
|
|
5
|
+
import { isEmpty as $, kebabCase as k, set as b } from "lodash-es";
|
|
6
|
+
import w from "sharp";
|
|
7
|
+
import { z as c } from "zod";
|
|
8
|
+
class A {
|
|
9
|
+
constructor(r, e, t) {
|
|
10
|
+
this.appId = r, this.userId = e, this.supabase = t;
|
|
11
|
+
}
|
|
12
|
+
appendUpdatedAtToUrl(r, e) {
|
|
13
|
+
if ($(r))
|
|
14
|
+
return "";
|
|
15
|
+
const t = new URL(r), o = new Date(e).getTime();
|
|
16
|
+
return t.searchParams.set("t", o.toString()), `${t.origin}${t.pathname}${t.search}${t.hash}`;
|
|
17
|
+
}
|
|
18
|
+
getBufferFromBase64(r) {
|
|
19
|
+
try {
|
|
20
|
+
const e = r.split(",")[1] || r;
|
|
21
|
+
return Buffer.from(e, "base64");
|
|
22
|
+
} catch {
|
|
23
|
+
throw new Error("Invalid base64 string format");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Upload an image file using UPLOAD_TO_STORAGE action
|
|
28
|
+
* Processes, optimizes, and creates thumbnails
|
|
29
|
+
*/
|
|
30
|
+
async uploadImageFile(r, e, t, o) {
|
|
31
|
+
try {
|
|
32
|
+
const s = this.getBufferFromBase64(r), n = await w(s).metadata(), i = ["jpeg", "jpg", "png", "webp", "gif", "svg", "tiff"];
|
|
33
|
+
if (!n.format || !i.includes(n.format.toLowerCase()))
|
|
34
|
+
throw new Error(`Invalid image format: ${n.format || "unknown"}`);
|
|
35
|
+
const u = o ? await w(s).webp({ quality: 100 }).resize({ width: Math.min(n.width || 2e3, 2e3) }).toBuffer() : await w(s).webp({ quality: 100 }).toBuffer();
|
|
36
|
+
let a = u;
|
|
37
|
+
if (o && u.length > 120 * 1024) {
|
|
38
|
+
const O = Math.floor(90 * (122880 / u.length));
|
|
39
|
+
a = await w(s).webp({ quality: O }).resize({ width: Math.min(n.width || 2e3, 2e3) }).toBuffer();
|
|
40
|
+
}
|
|
41
|
+
const d = await w(a).metadata(), m = await w(s).webp({ quality: 70 }).resize({ width: 300 }).toBuffer(), p = t.split("."), h = p.length > 1 ? p.slice(0, -1).join(".") : t, g = `${k(h)}.webp`, _ = `${g}_thumbnail.webp`, I = this.appId, x = e ? `${I}/${e}` : I, U = T("UPLOAD_TO_STORAGE");
|
|
42
|
+
if (!U)
|
|
43
|
+
throw new Error("UPLOAD_TO_STORAGE action not found");
|
|
44
|
+
U.setContext({ appId: this.appId, userId: this.userId });
|
|
45
|
+
const S = await U.execute({
|
|
46
|
+
file: a.toString("base64"),
|
|
47
|
+
fileName: g,
|
|
48
|
+
contentType: "image/webp",
|
|
49
|
+
folder: x
|
|
50
|
+
});
|
|
51
|
+
if (S.error)
|
|
52
|
+
throw new Error(S.error);
|
|
53
|
+
const E = await U.execute({
|
|
54
|
+
file: m.toString("base64"),
|
|
55
|
+
fileName: _,
|
|
56
|
+
contentType: "image/webp",
|
|
57
|
+
folder: x
|
|
58
|
+
});
|
|
59
|
+
if (E.error)
|
|
60
|
+
throw new Error(E.error);
|
|
61
|
+
return {
|
|
62
|
+
url: S.data.url,
|
|
63
|
+
thumbnailUrl: E.data.url,
|
|
64
|
+
size: d.size || a.length,
|
|
65
|
+
width: d.width || 0,
|
|
66
|
+
height: d.height || 0,
|
|
67
|
+
mimeType: "image/webp"
|
|
68
|
+
};
|
|
69
|
+
} catch (s) {
|
|
70
|
+
return console.error("Upload image error:", s), { error: s instanceof Error ? s.message : "Unknown error" };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Upload an SVG file using UPLOAD_TO_STORAGE action
|
|
75
|
+
*/
|
|
76
|
+
async uploadSvgFile(r, e, t) {
|
|
77
|
+
try {
|
|
78
|
+
const o = this.getBufferFromBase64(r);
|
|
79
|
+
let s, n;
|
|
80
|
+
try {
|
|
81
|
+
const g = await w(o).metadata();
|
|
82
|
+
s = g.width, n = g.height;
|
|
83
|
+
} catch {
|
|
84
|
+
}
|
|
85
|
+
const i = t.split("."), u = i.length > 1 ? i.slice(0, -1).join(".") : t, a = `${k(u)}.svg`, d = this.appId, m = e ? `${d}/${e}` : d, p = T("UPLOAD_TO_STORAGE");
|
|
86
|
+
if (!p)
|
|
87
|
+
throw new Error("UPLOAD_TO_STORAGE action not found");
|
|
88
|
+
p.setContext({ appId: this.appId, userId: this.userId });
|
|
89
|
+
const h = await p.execute({
|
|
90
|
+
file: o.toString("base64"),
|
|
91
|
+
fileName: a,
|
|
92
|
+
contentType: "image/svg+xml",
|
|
93
|
+
folder: m
|
|
94
|
+
});
|
|
95
|
+
if (h.error)
|
|
96
|
+
throw new Error(h.error);
|
|
97
|
+
return {
|
|
98
|
+
url: h.data.url,
|
|
99
|
+
thumbnailUrl: h.data.url,
|
|
100
|
+
size: o.length,
|
|
101
|
+
width: s,
|
|
102
|
+
height: n,
|
|
103
|
+
mimeType: "image/svg+xml"
|
|
104
|
+
};
|
|
105
|
+
} catch (o) {
|
|
106
|
+
return console.error("SVG upload error:", o), { error: o instanceof Error ? o.message : "Unknown error" };
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async upload({
|
|
110
|
+
file: r,
|
|
111
|
+
folderId: e,
|
|
112
|
+
name: t,
|
|
113
|
+
optimize: o = !0
|
|
114
|
+
}) {
|
|
115
|
+
var s;
|
|
116
|
+
try {
|
|
117
|
+
const i = t.toLowerCase().endsWith(".svg") || r.includes("data:image/svg+xml") ? await this.uploadSvgFile(r, e, t) : await this.uploadImageFile(r, e, t, o ?? !0);
|
|
118
|
+
if ("error" in i)
|
|
119
|
+
return i;
|
|
120
|
+
const u = {
|
|
121
|
+
name: t,
|
|
122
|
+
app: this.appId,
|
|
123
|
+
url: i.url,
|
|
124
|
+
thumbnailUrl: i.thumbnailUrl,
|
|
125
|
+
size: (s = i.size) == null ? void 0 : s.toString(),
|
|
126
|
+
width: i.width,
|
|
127
|
+
height: i.height,
|
|
128
|
+
format: i.mimeType.split("/")[1],
|
|
129
|
+
folderId: e,
|
|
130
|
+
type: i.mimeType.startsWith("image/") ? "image" : "file",
|
|
131
|
+
createdBy: this.userId,
|
|
132
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
133
|
+
}, { data: a, error: d } = await this.supabase.from("app_assets").insert(u).select("*").single();
|
|
134
|
+
if (d)
|
|
135
|
+
throw new Error(`Failed to store asset in database: ${d.message}`);
|
|
136
|
+
return {
|
|
137
|
+
id: a.id,
|
|
138
|
+
name: a.name,
|
|
139
|
+
type: a.type,
|
|
140
|
+
url: this.appendUpdatedAtToUrl(a.url, a.updatedAt),
|
|
141
|
+
size: a.size,
|
|
142
|
+
thumbnailUrl: this.appendUpdatedAtToUrl(a.thumbnailUrl || "", a.updatedAt),
|
|
143
|
+
width: a.width,
|
|
144
|
+
height: a.height,
|
|
145
|
+
format: a.format,
|
|
146
|
+
folderId: a.folderId,
|
|
147
|
+
createdBy: a.createdBy || "",
|
|
148
|
+
createdAt: a.createdAt,
|
|
149
|
+
updatedAt: a.updatedAt
|
|
150
|
+
};
|
|
151
|
+
} catch (n) {
|
|
152
|
+
return { error: n instanceof Error ? n.message : "Unknown error occurred" };
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
async getAsset({ id: r }) {
|
|
156
|
+
try {
|
|
157
|
+
const { data: e, error: t } = await this.supabase.from("app_assets").select("*").eq("id", r).eq("app", this.appId).single();
|
|
158
|
+
if (t)
|
|
159
|
+
throw new Error(`Failed to fetch asset: ${t.message}`);
|
|
160
|
+
return b(e, "url", this.appendUpdatedAtToUrl(e.url, e.updatedAt)), b(e, "thumbnailUrl", this.appendUpdatedAtToUrl(e.thumbnailUrl || "", e.updatedAt)), e;
|
|
161
|
+
} catch (e) {
|
|
162
|
+
return { error: e instanceof Error ? e.message : "Unknown error occurred" };
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
async getAssets({
|
|
166
|
+
search: r = "",
|
|
167
|
+
page: e = 1,
|
|
168
|
+
limit: t = 20
|
|
169
|
+
} = {}) {
|
|
170
|
+
try {
|
|
171
|
+
const o = (e - 1) * t;
|
|
172
|
+
let s = this.supabase.from("app_assets").select("*", { count: "exact" }).eq("app", this.appId).order("updatedAt", { ascending: !1 });
|
|
173
|
+
r && (s = s.or(`name.ilike.%${r}%,description.ilike.%${r}%`));
|
|
174
|
+
const { data: n, error: i, count: u } = await s.range(o, o + t - 1);
|
|
175
|
+
if (i)
|
|
176
|
+
throw new Error(i.message);
|
|
177
|
+
return {
|
|
178
|
+
assets: n.map((d) => (b(d, "url", this.appendUpdatedAtToUrl(d.url, d.updatedAt)), b(d, "thsupabaseumbnailUrl", this.appendUpdatedAtToUrl(d.thumbnailUrl || "", d.updatedAt)), d)),
|
|
179
|
+
total: u || 0,
|
|
180
|
+
page: e,
|
|
181
|
+
pageSize: t
|
|
182
|
+
};
|
|
183
|
+
} catch (o) {
|
|
184
|
+
throw console.error("Error fetching assets:", o), o;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
async deleteAsset({ id: r }) {
|
|
188
|
+
try {
|
|
189
|
+
const { data: e, error: t } = await this.supabase.from("app_assets").select("*").eq("id", r).eq("app", this.appId).single();
|
|
190
|
+
if (t)
|
|
191
|
+
throw new Error(`Failed to fetch asset: ${t.message}`);
|
|
192
|
+
if (e.url)
|
|
193
|
+
try {
|
|
194
|
+
const n = new URL(e.url).pathname.split("/"), i = n.indexOf("dam-assets");
|
|
195
|
+
if (i !== -1) {
|
|
196
|
+
const u = n.slice(i + 1).join("/"), a = T("DELETE_FROM_STORAGE");
|
|
197
|
+
if (a && (a.setContext({ appId: this.appId, userId: this.userId }), await a.execute({ key: u })), e.thumbnailUrl && e.thumbnailUrl !== e.url) {
|
|
198
|
+
const m = new URL(e.thumbnailUrl).pathname.split("/"), p = m.indexOf("dam-assets");
|
|
199
|
+
if (p !== -1) {
|
|
200
|
+
const h = m.slice(p + 1).join("/");
|
|
201
|
+
a && await a.execute({ key: h });
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
} catch (s) {
|
|
206
|
+
console.warn("Failed to delete from storage, continuing with database deletion:", s);
|
|
207
|
+
}
|
|
208
|
+
const { error: o } = await this.supabase.from("app_assets").delete().eq("id", r);
|
|
209
|
+
if (o)
|
|
210
|
+
throw new Error(`Failed to delete asset: ${o.message}`);
|
|
211
|
+
return { success: !0 };
|
|
212
|
+
} catch (e) {
|
|
213
|
+
return { error: e instanceof Error ? e.message : "Unknown error occurred" };
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
async updateAsset({
|
|
217
|
+
id: r,
|
|
218
|
+
file: e,
|
|
219
|
+
description: t
|
|
220
|
+
}) {
|
|
221
|
+
var o, s;
|
|
222
|
+
try {
|
|
223
|
+
const { data: n, error: i } = await this.supabase.from("app_assets").select("*").eq("id", r).single();
|
|
224
|
+
if (i)
|
|
225
|
+
throw new Error(`Failed to fetch asset: ${i.message}`);
|
|
226
|
+
const u = {};
|
|
227
|
+
if (t !== void 0 && (u.description = t, u.updatedAt = (/* @__PURE__ */ new Date()).toISOString()), e) {
|
|
228
|
+
const p = ((o = n.format) == null ? void 0 : o.toLowerCase()) === "svg" || e.includes("data:image/svg+xml") ? await this.uploadSvgFile(e, n.folderId, n.name) : await this.uploadImageFile(e, n.folderId, n.name, !0);
|
|
229
|
+
if ("error" in p)
|
|
230
|
+
return p;
|
|
231
|
+
u.url = p.url, u.thumbnailUrl = p.thumbnailUrl, u.size = (s = p.size) == null ? void 0 : s.toString(), u.width = p.width, u.height = p.height, u.format = p.mimeType.split("/")[1], u.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
232
|
+
}
|
|
233
|
+
const { data: a, error: d } = await this.supabase.from("app_assets").update(u).eq("id", r).select().single();
|
|
234
|
+
if (d)
|
|
235
|
+
throw new Error(`Failed to update asset: ${d.message}`);
|
|
236
|
+
return b(a, "url", this.appendUpdatedAtToUrl(a.url, a.updatedAt)), b(
|
|
237
|
+
a,
|
|
238
|
+
"thumbnailUrl",
|
|
239
|
+
this.appendUpdatedAtToUrl(a.thumbnailUrl || "", a.updatedAt)
|
|
240
|
+
), a;
|
|
241
|
+
} catch (n) {
|
|
242
|
+
return { error: n instanceof Error ? n.message : "Unknown error occurred" };
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
const v = c.object({
|
|
247
|
+
name: c.string(),
|
|
248
|
+
file: c.string(),
|
|
249
|
+
folderId: c.string().optional().nullable(),
|
|
250
|
+
optimize: c.boolean().optional()
|
|
251
|
+
});
|
|
252
|
+
class B extends f {
|
|
253
|
+
constructor(r) {
|
|
254
|
+
super(), this.supabase = r;
|
|
255
|
+
}
|
|
256
|
+
getValidationSchema() {
|
|
257
|
+
return v;
|
|
258
|
+
}
|
|
259
|
+
async execute(r) {
|
|
260
|
+
try {
|
|
261
|
+
if (!this.context)
|
|
262
|
+
return { error: "Context not set", status: 400 };
|
|
263
|
+
const { appId: e, userId: t } = this.context;
|
|
264
|
+
if (!t)
|
|
265
|
+
return { error: "User ID is required", status: 401 };
|
|
266
|
+
const s = await new A(e, t, this.supabase).upload(r);
|
|
267
|
+
return "error" in s ? { error: s.error, status: 400 } : s;
|
|
268
|
+
} catch (e) {
|
|
269
|
+
return console.error("UPLOAD_ASSET error:", e), { error: e instanceof Error ? e.message : "Unknown error", status: 500 };
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
const G = c.object({
|
|
274
|
+
id: c.string()
|
|
275
|
+
});
|
|
276
|
+
class C extends f {
|
|
277
|
+
constructor(r) {
|
|
278
|
+
super(), this.supabase = r;
|
|
279
|
+
}
|
|
280
|
+
getValidationSchema() {
|
|
281
|
+
return G;
|
|
282
|
+
}
|
|
283
|
+
async execute(r) {
|
|
284
|
+
try {
|
|
285
|
+
if (!this.context)
|
|
286
|
+
return { error: "Context not set", status: 400 };
|
|
287
|
+
const { appId: e, userId: t } = this.context;
|
|
288
|
+
if (!t)
|
|
289
|
+
return { error: "User ID is required", status: 401 };
|
|
290
|
+
const s = await new A(e, t, this.supabase).getAsset(r);
|
|
291
|
+
return "error" in s ? { error: s.error, status: 400 } : s;
|
|
292
|
+
} catch (e) {
|
|
293
|
+
return console.error("GET_ASSET error:", e), { error: e instanceof Error ? e.message : "Unknown error", status: 500 };
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
const L = c.object({
|
|
298
|
+
search: c.string().optional(),
|
|
299
|
+
page: c.number().optional(),
|
|
300
|
+
limit: c.number().optional()
|
|
301
|
+
});
|
|
302
|
+
class j extends f {
|
|
303
|
+
constructor(r) {
|
|
304
|
+
super(), this.supabase = r;
|
|
305
|
+
}
|
|
306
|
+
getValidationSchema() {
|
|
307
|
+
return L;
|
|
308
|
+
}
|
|
309
|
+
async execute(r) {
|
|
310
|
+
try {
|
|
311
|
+
if (!this.context)
|
|
312
|
+
return { error: "Context not set", status: 400 };
|
|
313
|
+
const { appId: e, userId: t } = this.context;
|
|
314
|
+
if (!t)
|
|
315
|
+
return { error: "User ID is required", status: 401 };
|
|
316
|
+
const s = await new A(e, t, this.supabase).getAssets(r);
|
|
317
|
+
return "error" in s ? { error: s.error, status: 400 } : s;
|
|
318
|
+
} catch (e) {
|
|
319
|
+
return console.error("GET_ASSETS error:", e), { error: e instanceof Error ? e.message : "Unknown error", status: 500 };
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
const P = c.object({
|
|
324
|
+
id: c.string()
|
|
325
|
+
});
|
|
326
|
+
class R extends f {
|
|
327
|
+
constructor(r) {
|
|
328
|
+
super(), this.supabase = r;
|
|
329
|
+
}
|
|
330
|
+
getValidationSchema() {
|
|
331
|
+
return P;
|
|
332
|
+
}
|
|
333
|
+
async execute(r) {
|
|
334
|
+
try {
|
|
335
|
+
if (!this.context)
|
|
336
|
+
return { error: "Context not set", status: 400 };
|
|
337
|
+
const { appId: e, userId: t } = this.context;
|
|
338
|
+
if (!t)
|
|
339
|
+
return { error: "User ID is required", status: 401 };
|
|
340
|
+
const s = await new A(e, t, this.supabase).deleteAsset(r);
|
|
341
|
+
return "error" in s ? { error: s.error, status: 400 } : s;
|
|
342
|
+
} catch (e) {
|
|
343
|
+
return console.error("DELETE_ASSET error:", e), { error: e instanceof Error ? e.message : "Unknown error", status: 500 };
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
const q = c.object({
|
|
348
|
+
id: c.string(),
|
|
349
|
+
file: c.string().optional(),
|
|
350
|
+
description: c.string().optional()
|
|
351
|
+
});
|
|
352
|
+
class z extends f {
|
|
353
|
+
constructor(r) {
|
|
354
|
+
super(), this.supabase = r;
|
|
355
|
+
}
|
|
356
|
+
getValidationSchema() {
|
|
357
|
+
return q;
|
|
358
|
+
}
|
|
359
|
+
async execute(r) {
|
|
360
|
+
try {
|
|
361
|
+
if (!this.context)
|
|
362
|
+
return { error: "Context not set", status: 400 };
|
|
363
|
+
const { appId: e, userId: t } = this.context;
|
|
364
|
+
if (!t)
|
|
365
|
+
return { error: "User ID is required", status: 401 };
|
|
366
|
+
const s = await new A(e, t, this.supabase).updateAsset(r);
|
|
367
|
+
return "error" in s ? { error: s.error, status: 400 } : s;
|
|
368
|
+
} catch (e) {
|
|
369
|
+
return console.error("UPDATE_ASSET error:", e), { error: e instanceof Error ? e.message : "Unknown error", status: 500 };
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
const M = c.object({
|
|
374
|
+
userId: c.string()
|
|
375
|
+
});
|
|
376
|
+
class N extends f {
|
|
377
|
+
constructor(r) {
|
|
378
|
+
super(), this.supabase = r;
|
|
379
|
+
}
|
|
380
|
+
getValidationSchema() {
|
|
381
|
+
return M;
|
|
382
|
+
}
|
|
383
|
+
async execute(r) {
|
|
384
|
+
var e, t, o, s, n, i;
|
|
385
|
+
try {
|
|
386
|
+
const { userId: u } = r, { data: a, error: d } = await this.supabase.auth.admin.getUserById(u);
|
|
387
|
+
return d ? {
|
|
388
|
+
data: {
|
|
389
|
+
id: "unknown",
|
|
390
|
+
email: "unknown@chaibuilder.com",
|
|
391
|
+
name: "Unknown",
|
|
392
|
+
avatar: ""
|
|
393
|
+
},
|
|
394
|
+
status: 200
|
|
395
|
+
} : {
|
|
396
|
+
data: {
|
|
397
|
+
id: ((e = a.user) == null ? void 0 : e.id) || "unknown",
|
|
398
|
+
email: ((t = a.user) == null ? void 0 : t.email) || "unknown@chaibuilder.com",
|
|
399
|
+
name: ((s = (o = a.user) == null ? void 0 : o.user_metadata) == null ? void 0 : s.name) || "Unknown",
|
|
400
|
+
avatar: ((i = (n = a.user) == null ? void 0 : n.user_metadata) == null ? void 0 : i.avatar) || ""
|
|
401
|
+
},
|
|
402
|
+
status: 200
|
|
403
|
+
};
|
|
404
|
+
} catch {
|
|
405
|
+
return {
|
|
406
|
+
data: {
|
|
407
|
+
id: "unknown",
|
|
408
|
+
email: "unknown@chaibuilder.com",
|
|
409
|
+
name: "Unknown",
|
|
410
|
+
avatar: ""
|
|
411
|
+
},
|
|
412
|
+
status: 200
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
const V = c.object({
|
|
418
|
+
key: c.string()
|
|
419
|
+
// Storage key/path to delete
|
|
420
|
+
});
|
|
421
|
+
class W extends f {
|
|
422
|
+
constructor(e) {
|
|
423
|
+
super();
|
|
424
|
+
y(this, "bucketName", "dam-assets");
|
|
425
|
+
this.supabase = e;
|
|
426
|
+
}
|
|
427
|
+
getValidationSchema() {
|
|
428
|
+
return V;
|
|
429
|
+
}
|
|
430
|
+
async execute(e) {
|
|
431
|
+
try {
|
|
432
|
+
const { key: t } = e, { error: o } = await this.supabase.storage.from(this.bucketName).remove([t]);
|
|
433
|
+
return o ? {
|
|
434
|
+
error: `Failed to delete from Supabase Storage: ${o.message}`,
|
|
435
|
+
status: 500
|
|
436
|
+
} : {
|
|
437
|
+
data: { success: !0 },
|
|
438
|
+
status: 200
|
|
439
|
+
};
|
|
440
|
+
} catch (t) {
|
|
441
|
+
return console.error("DELETE_FROM_STORAGE error:", t), {
|
|
442
|
+
error: t instanceof Error ? t.message : "Unknown error",
|
|
443
|
+
status: 500
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
const H = c.object({
|
|
449
|
+
file: c.string(),
|
|
450
|
+
// Base64 string
|
|
451
|
+
fileName: c.string(),
|
|
452
|
+
contentType: c.string().optional(),
|
|
453
|
+
folder: c.string().optional(),
|
|
454
|
+
metadata: c.record(c.string(), c.any()).optional()
|
|
455
|
+
});
|
|
456
|
+
class K extends f {
|
|
457
|
+
constructor(e) {
|
|
458
|
+
super();
|
|
459
|
+
y(this, "bucketName", "dam-assets");
|
|
460
|
+
this.supabase = e;
|
|
461
|
+
}
|
|
462
|
+
getValidationSchema() {
|
|
463
|
+
return H;
|
|
464
|
+
}
|
|
465
|
+
async execute(e) {
|
|
466
|
+
try {
|
|
467
|
+
if (!this.context)
|
|
468
|
+
return { error: "Context not set", status: 400 };
|
|
469
|
+
const { appId: t } = this.context, { file: o, fileName: s, contentType: n, folder: i, metadata: u } = e;
|
|
470
|
+
let a;
|
|
471
|
+
if (typeof o == "string") {
|
|
472
|
+
const g = o.split(",")[1] || o;
|
|
473
|
+
a = Buffer.from(g, "base64");
|
|
474
|
+
} else
|
|
475
|
+
a = o;
|
|
476
|
+
const d = i ? `${i}/${s}` : `${t}/${s}`, { data: m, error: p } = await this.supabase.storage.from(this.bucketName).upload(d, a, {
|
|
477
|
+
contentType: n || "application/octet-stream",
|
|
478
|
+
upsert: !0,
|
|
479
|
+
...u && { metadata: u }
|
|
480
|
+
});
|
|
481
|
+
if (p)
|
|
482
|
+
return {
|
|
483
|
+
error: `Failed to upload to Supabase Storage: ${p.message}`,
|
|
484
|
+
status: 500
|
|
485
|
+
};
|
|
486
|
+
const {
|
|
487
|
+
data: { publicUrl: h }
|
|
488
|
+
} = this.supabase.storage.from(this.bucketName).getPublicUrl(d);
|
|
489
|
+
return {
|
|
490
|
+
data: {
|
|
491
|
+
url: h,
|
|
492
|
+
key: m.path,
|
|
493
|
+
size: a.length,
|
|
494
|
+
metadata: u
|
|
495
|
+
},
|
|
496
|
+
status: 200
|
|
497
|
+
};
|
|
498
|
+
} catch (t) {
|
|
499
|
+
return console.error("UPLOAD_TO_STORAGE error:", t), {
|
|
500
|
+
error: t instanceof Error ? t.message : "Unknown error",
|
|
501
|
+
status: 500
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
const ee = (l) => ({
|
|
507
|
+
GET_CHAI_USER: new N(l)
|
|
508
|
+
}), te = (l) => ({
|
|
509
|
+
// Asset management actions
|
|
510
|
+
UPLOAD_ASSET: new B(l),
|
|
511
|
+
GET_ASSET: new C(l),
|
|
512
|
+
GET_ASSETS: new j(l),
|
|
513
|
+
DELETE_ASSET: new R(l),
|
|
514
|
+
UPDATE_ASSET: new z(l),
|
|
515
|
+
// Generic storage actions
|
|
516
|
+
UPLOAD_TO_STORAGE: new K(l),
|
|
517
|
+
DELETE_FROM_STORAGE: new W(l)
|
|
518
|
+
});
|
|
519
|
+
export {
|
|
520
|
+
W as DeleteFromStorageAction,
|
|
521
|
+
ee as SupabaseAuthActions,
|
|
522
|
+
te as SupabaseStorageActions,
|
|
523
|
+
K as UploadToStorageAction
|
|
524
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("./index-DF5DEvqb.cjs"),t=require("./index-WQwzsC7A.cjs"),l=require("lucide-react"),f=require("react"),j=require("react-i18next"),p=()=>{const i=t.useSendRealtimeEvent(),{pageLockMeta:r}=t.usePageLockMeta(),{setPageStatus:d}=t.usePageLockStatus(),{savePageAsync:m}=a.useSavePage(),x=r==null?void 0:r.requestingUserId,{data:s,isFetching:h}=t.useChaiUserInfo(x||""),o=h?"Fetching user...":(s==null?void 0:s.name)||"Current editor",[u,c]=f.useState(!1),g=async()=>{c(!0),await m(),i(t.EVENT.CONTINUE_EDITING_IN_THIS_CLIENT,r),d(t.PAGE_STATUS.CHECKING),setTimeout(()=>c(!1),2e3)},N=()=>{c(!0),i(t.EVENT.TAKE_OVER_REJECTED,r),d(t.PAGE_STATUS.EDITING),setTimeout(()=>c(!1),2e3)},{t:n}=j.useTranslation();return e.jsx(t.BlurContainer,{children:e.jsxs(a.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(a.CardHeader,{className:"space-y-1",children:e.jsxs(a.CardTitle,{className:"flex items-center gap-2 text-xl",children:[e.jsx(l.AlertCircle,{className:"h-8 w-8 rounded-md bg-amber-500/20 p-1.5 text-amber-500"}),n("Take Over Requested")]})}),e.jsxs(a.CardContent,{className:"space-y-4",children:[e.jsxs("div",{className:"relative rounded-md border border-green-500 px-2 pb-2 pt-4",children:[e.jsx("div",{className:"absolute -top-2.5 left-3 w-max rounded-full bg-green-500 px-3 py-1 text-xs font-medium leading-3 text-white",children:"Requested by"}),e.jsxs("div",{className:"flex items-center space-x-4 p-1",children:[s!=null&&s.avatar?e.jsx("img",{src:s.avatar,alt:s.name,className:"h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white"}):e.jsx(l.UserIcon,{className:"h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white"}),e.jsxs("div",{className:"flex-1 space-y-0",children:[e.jsx("div",{className:"truncate font-medium leading-tight text-black",children:o}),(s==null?void 0:s.email)&&e.jsx("p",{className:"truncate text-sm leading-tight text-muted-foreground",children:s.email})]})]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-medium text-gray-700",children:o})," ",n("has requested to")," ",e.jsx("span",{className:"font-medium text-gray-500",children:"take over"})," ",n("editing this page."),"."," ",n("Do you want to allow them to continue?")]})]}),e.jsxs(a.CardFooter,{className:"flex gap-2",children:[e.jsxs(a.Button,{disabled:u,variant:"default",onClick:g,className:"flex-1 gap-2",children:[e.jsx(l.Check,{className:"h-4 w-4"}),n("Accept")]}),e.jsxs(a.Button,{disabled:u,variant:"outline",onClick:N,className:"flex-1 gap-2",children:[e.jsx(l.X,{className:"h-4 w-4"}),n("Reject")]})]})]})})};exports.default=p;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx as a, jsxs as t } from "react/jsx-runtime";
|
|
2
|
+
import { V as N, W as C, X as b, Y as v, Z as E, _ as T, B as d } from "./index-Ct7ElCGK.js";
|
|
3
|
+
import { ao as w, b as I, a as k, ap as y, B as R, E as m, P as u } from "./index-ZuacEL1j.js";
|
|
4
|
+
import { AlertCircle as S, UserIcon as _, Check as A, X as P } from "lucide-react";
|
|
5
|
+
import { useState as q } from "react";
|
|
6
|
+
import { useTranslation as U } from "react-i18next";
|
|
7
|
+
const H = () => {
|
|
8
|
+
const l = w(), { pageLockMeta: r } = I(), { setPageStatus: c } = k(), { savePageAsync: h } = N(), p = r == null ? void 0 : r.requestingUserId, { data: e, isFetching: x } = y(p || ""), i = x ? "Fetching user..." : (e == null ? void 0 : e.name) || "Current editor", [o, n] = q(!1), f = async () => {
|
|
9
|
+
n(!0), await h(), l(m.CONTINUE_EDITING_IN_THIS_CLIENT, r), c(u.CHECKING), setTimeout(() => n(!1), 2e3);
|
|
10
|
+
}, g = () => {
|
|
11
|
+
n(!0), l(m.TAKE_OVER_REJECTED, r), c(u.EDITING), setTimeout(() => n(!1), 2e3);
|
|
12
|
+
}, { t: s } = U();
|
|
13
|
+
return /* @__PURE__ */ a(R, { children: /* @__PURE__ */ t(C, { className: "mx-auto w-full max-w-md", children: [
|
|
14
|
+
/* @__PURE__ */ a(b, { className: "space-y-1", children: /* @__PURE__ */ t(v, { className: "flex items-center gap-2 text-xl", children: [
|
|
15
|
+
/* @__PURE__ */ a(S, { className: "h-8 w-8 rounded-md bg-amber-500/20 p-1.5 text-amber-500" }),
|
|
16
|
+
s("Take Over Requested")
|
|
17
|
+
] }) }),
|
|
18
|
+
/* @__PURE__ */ t(E, { className: "space-y-4", children: [
|
|
19
|
+
/* @__PURE__ */ t("div", { className: "relative rounded-md border border-green-500 px-2 pb-2 pt-4", children: [
|
|
20
|
+
/* @__PURE__ */ a("div", { className: "absolute -top-2.5 left-3 w-max rounded-full bg-green-500 px-3 py-1 text-xs font-medium leading-3 text-white", children: "Requested by" }),
|
|
21
|
+
/* @__PURE__ */ t("div", { className: "flex items-center space-x-4 p-1", children: [
|
|
22
|
+
e != null && e.avatar ? /* @__PURE__ */ a(
|
|
23
|
+
"img",
|
|
24
|
+
{
|
|
25
|
+
src: e.avatar,
|
|
26
|
+
alt: e.name,
|
|
27
|
+
className: "h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white"
|
|
28
|
+
}
|
|
29
|
+
) : /* @__PURE__ */ a(_, { className: "h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white" }),
|
|
30
|
+
/* @__PURE__ */ t("div", { className: "flex-1 space-y-0", children: [
|
|
31
|
+
/* @__PURE__ */ a("div", { className: "truncate font-medium leading-tight text-black", children: i }),
|
|
32
|
+
(e == null ? void 0 : e.email) && /* @__PURE__ */ a("p", { className: "truncate text-sm leading-tight text-muted-foreground", children: e.email })
|
|
33
|
+
] })
|
|
34
|
+
] })
|
|
35
|
+
] }),
|
|
36
|
+
/* @__PURE__ */ t("p", { className: "text-sm text-muted-foreground", children: [
|
|
37
|
+
/* @__PURE__ */ a("span", { className: "font-medium text-gray-700", children: i }),
|
|
38
|
+
" ",
|
|
39
|
+
s("has requested to"),
|
|
40
|
+
" ",
|
|
41
|
+
/* @__PURE__ */ a("span", { className: "font-medium text-gray-500", children: "take over" }),
|
|
42
|
+
" ",
|
|
43
|
+
s("editing this page."),
|
|
44
|
+
".",
|
|
45
|
+
" ",
|
|
46
|
+
s("Do you want to allow them to continue?")
|
|
47
|
+
] })
|
|
48
|
+
] }),
|
|
49
|
+
/* @__PURE__ */ t(T, { className: "flex gap-2", children: [
|
|
50
|
+
/* @__PURE__ */ t(d, { disabled: o, variant: "default", onClick: f, className: "flex-1 gap-2", children: [
|
|
51
|
+
/* @__PURE__ */ a(A, { className: "h-4 w-4" }),
|
|
52
|
+
s("Accept")
|
|
53
|
+
] }),
|
|
54
|
+
/* @__PURE__ */ t(d, { disabled: o, variant: "outline", onClick: g, className: "flex-1 gap-2", children: [
|
|
55
|
+
/* @__PURE__ */ a(P, { className: "h-4 w-4" }),
|
|
56
|
+
s("Reject")
|
|
57
|
+
] })
|
|
58
|
+
] })
|
|
59
|
+
] }) });
|
|
60
|
+
};
|
|
61
|
+
export {
|
|
62
|
+
H as default
|
|
63
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-DF5DEvqb.cjs"),s=require("./index-WQwzsC7A.cjs"),d=require("react-i18next"),h=()=>{const[n]=t.useTheme(),{mutate:c,isPending:i}=s.usePublishPages(),{mutateAsync:a,isPending:o}=s.useUpdateWebsiteSettings(),{t:r}=d.useTranslation(),u=()=>{a({settings:{theme:n}})},l=async()=>{await a({settings:{theme:n}}),c({ids:["THEME"]},{onSuccess:()=>{s.throwConfetti("BOTTOM_RIGHT")}})};return e.jsxs("div",{className:"flex items-center justify-center gap-x-3 border-t bg-white py-3",children:[e.jsx(t.Button,{size:"sm",variant:"outline",disabled:i||o,onClick:u,children:r("Save draft")}),e.jsx(t.Button,{size:"sm",disabled:i||o,onClick:l,children:r("Publish")})]})};exports.default=h;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsxs as c, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { h, B as o } from "./index-Ct7ElCGK.js";
|
|
3
|
+
import { e as d, f as u, t as b } from "./index-ZuacEL1j.js";
|
|
4
|
+
import { useTranslation as f } from "react-i18next";
|
|
5
|
+
const x = () => {
|
|
6
|
+
const [e] = h(), { mutate: r, isPending: s } = d(), { mutateAsync: t, isPending: i } = u(), { t: n } = f(), l = () => {
|
|
7
|
+
t({ settings: { theme: e } });
|
|
8
|
+
}, m = async () => {
|
|
9
|
+
await t({ settings: { theme: e } }), r(
|
|
10
|
+
{ ids: ["THEME"] },
|
|
11
|
+
{
|
|
12
|
+
onSuccess: () => {
|
|
13
|
+
b("BOTTOM_RIGHT");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
return /* @__PURE__ */ c("div", { className: "flex items-center justify-center gap-x-3 border-t bg-white py-3", children: [
|
|
19
|
+
/* @__PURE__ */ a(o, { size: "sm", variant: "outline", disabled: s || i, onClick: l, children: n("Save draft") }),
|
|
20
|
+
/* @__PURE__ */ a(o, { size: "sm", disabled: s || i, onClick: m, children: n("Publish") })
|
|
21
|
+
] });
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
x as default
|
|
25
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as n, jsxs as e } from "react/jsx-runtime";
|
|
2
|
+
import { D as c, d, e as h, f as u, p as g, q as m, B as i } from "./index-Ct7ElCGK.js";
|
|
3
|
+
const b = ({
|
|
4
|
+
isOpen: l,
|
|
5
|
+
onClose: o,
|
|
6
|
+
onContinue: t,
|
|
7
|
+
isPending: a = !1,
|
|
8
|
+
title: s = "Translation Warning",
|
|
9
|
+
description: r = "Some blocks need translations before publishing. Do you want to continue anyway?"
|
|
10
|
+
}) => /* @__PURE__ */ n(c, { open: l, onOpenChange: o, children: l && /* @__PURE__ */ e(d, { className: "sm:max-w-[425px]", children: [
|
|
11
|
+
/* @__PURE__ */ e(h, { children: [
|
|
12
|
+
/* @__PURE__ */ n(u, { children: s }),
|
|
13
|
+
/* @__PURE__ */ n(g, { children: r })
|
|
14
|
+
] }),
|
|
15
|
+
/* @__PURE__ */ e(m, { className: "flex gap-2", children: [
|
|
16
|
+
/* @__PURE__ */ n(i, { variant: "outline", onClick: () => {
|
|
17
|
+
o();
|
|
18
|
+
}, disabled: a, children: "Cancel" }),
|
|
19
|
+
/* @__PURE__ */ n(i, { onClick: () => {
|
|
20
|
+
t();
|
|
21
|
+
}, disabled: a, children: a ? "Publishing..." : "Continue Anyway" })
|
|
22
|
+
] })
|
|
23
|
+
] }) });
|
|
24
|
+
export {
|
|
25
|
+
b as default
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),e=require("./index-DF5DEvqb.cjs"),d=({isOpen:l,onClose:o,onContinue:i,isPending:a=!1,title:t="Translation Warning",description:s="Some blocks need translations before publishing. Do you want to continue anyway?"})=>{const r=()=>{o()},c=()=>{i()};return n.jsx(e.Dialog,{open:l,onOpenChange:o,children:l&&n.jsxs(e.DialogContent,{className:"sm:max-w-[425px]",children:[n.jsxs(e.DialogHeader,{children:[n.jsx(e.DialogTitle,{children:t}),n.jsx(e.DialogDescription,{children:s})]}),n.jsxs(e.DialogFooter,{className:"flex gap-2",children:[n.jsx(e.Button,{variant:"outline",onClick:r,disabled:a,children:"Cancel"}),n.jsx(e.Button,{onClick:c,disabled:a,children:a?"Publishing...":"Continue Anyway"})]})]})})};exports.default=d;
|