@gatewaze/admin-embed 0.1.0
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 +42 -0
- package/dist/AiSkillsPicker-dbFhcanE.js +373 -0
- package/dist/ContentAccessPage-D0HRqPFc.js +264 -0
- package/dist/DataTable-fe6yRVpF.js +1984 -0
- package/dist/DetailPageHeader-D_v7924k.js +69 -0
- package/dist/EditionEmail-CyhC8232.js +8382 -0
- package/dist/GuideContent-DBXKCu7r.js +7580 -0
- package/dist/HostMediaTab-BsIBEQ1v.js +440 -0
- package/dist/InboxPage-C8ivCKdx.js +1112 -0
- package/dist/NewsletterCanvasEditor--B06apn3.js +11453 -0
- package/dist/NewsletterSetupWizard-BqV6-fa5.js +347 -0
- package/dist/NewsletterSignup-DRVZIpOs.js +224 -0
- package/dist/Page-D3u8IZ2a.js +14 -0
- package/dist/Toaster-Cde0i6IA.js +18 -0
- package/dist/Tooltip-CqxUlW1d.js +746 -0
- package/dist/_collectionSlug_-B3UN6M-Q.js +308 -0
- package/dist/_collection_-Qz4k_Qjl.js +139 -0
- package/dist/_edition_-DQXwkI_-.js +301 -0
- package/dist/_id_-CtT7rT9f.js +257 -0
- package/dist/_id_-CzScE4Qn.js +1197 -0
- package/dist/_virtual_gatewaze-modules-BeloWlOa.js +991 -0
- package/dist/admin-B0Mmrh_O.js +1239 -0
- package/dist/admin-CcfoK6vD.js +17 -0
- package/dist/admin-embed.js +21844 -0
- package/dist/admin.css +2 -0
- package/dist/block-editor-vXBShAue.js +226 -0
- package/dist/brand-DklYwIeA.js +11 -0
- package/dist/brick-editor-CmBitMMK.js +225 -0
- package/dist/broadcastService-CBqXNt_N.js +190 -0
- package/dist/classnames-uWIYaD6z.js +44 -0
- package/dist/contentAccessService-Cs7tdAo-.js +59 -0
- package/dist/context-jzuubYRz.js +5 -0
- package/dist/createSafeContext-P1pK0sAN.js +17 -0
- package/dist/detail-B8SVFJJr.js +26285 -0
- package/dist/detail-uFBxRbLF.js +2966 -0
- package/dist/dist-DTrOExw8.js +38806 -0
- package/dist/edition-slug-CARO24Bs.js +7 -0
- package/dist/export-edition-html-C_hdXQu5.js +18893 -0
- package/dist/floating-ui.dom-Cyv879E9.js +987 -0
- package/dist/hooks-C377EXJG.js +2974 -0
- package/dist/img/mlops-logo.png +0 -0
- package/dist/img/mlops-logo2.png +0 -0
- package/dist/index.d.ts +105 -0
- package/dist/jsx-runtime-CjozyJt-.js +180 -0
- package/dist/lib-CylJmhlJ.js +828 -0
- package/dist/list-C0cz0aQz.js +451 -0
- package/dist/list-CIVgIGsU.js +166 -0
- package/dist/logo/mlops-alt.png +0 -0
- package/dist/logo/mlops-logo.png +0 -0
- package/dist/new-r4KWpqa6.js +80 -0
- package/dist/outline-DwDYhYcF.js +6538 -0
- package/dist/pages-Ersfxcz7.js +216 -0
- package/dist/preview/12627f.jpg +0 -0
- package/dist/preview/af009d.jpg +0 -0
- package/dist/public-api-LD11kMxh.js +238 -0
- package/dist/react-DB2tPNit.js +933 -0
- package/dist/react-dom-giQNVXng.js +267 -0
- package/dist/registry-4XrV9iNG.js +7 -0
- package/dist/render-BtUWfMUt.js +59634 -0
- package/dist/resolvePeopleByEmail-hivX2l07.js +828 -0
- package/dist/runtime-config.js +10 -0
- package/dist/sends-BkPO6PG2.js +182 -0
- package/dist/server.browser-Pj3QUa7k.js +15227 -0
- package/dist/shim-BCerG8nb.js +6681 -0
- package/dist/sonnerHostBridge-CXuCMM3R.js +665 -0
- package/dist/src-BWDAOzZO.js +799 -0
- package/dist/starter-templates-CFs-QUdF.js +3077 -0
- package/dist/storage-VDSvnkvR.js +39 -0
- package/dist/templateParser-BQ2IsJ6c.js +49 -0
- package/dist/templates-rjQjWsRr.js +253 -0
- package/dist/theme/gatewaze/android-icon-144x144.png +0 -0
- package/dist/theme/gatewaze/android-icon-192x192.png +0 -0
- package/dist/theme/gatewaze/android-icon-36x36.png +0 -0
- package/dist/theme/gatewaze/android-icon-48x48.png +0 -0
- package/dist/theme/gatewaze/android-icon-72x72.png +0 -0
- package/dist/theme/gatewaze/android-icon-96x96.png +0 -0
- package/dist/theme/gatewaze/favicon-144x144.png +0 -0
- package/dist/theme/gatewaze/favicon-16x16.png +0 -0
- package/dist/theme/gatewaze/favicon-192x192.png +0 -0
- package/dist/theme/gatewaze/favicon-32x32.png +0 -0
- package/dist/theme/gatewaze/favicon-96x96.png +0 -0
- package/dist/theme/gatewaze/favicon.ico +0 -0
- package/dist/theme/gatewaze/gatewaze-icon-512.png +0 -0
- package/dist/theme/gatewaze/gatewaze-logo-black.svg +24 -0
- package/dist/theme/gatewaze/gatewaze-logo-white.svg +20 -0
- package/dist/theme/gatewaze/gatewaze-poweredby-black.svg +25 -0
- package/dist/theme/gatewaze/gatewaze-poweredby-white.svg +25 -0
- package/dist/theme/gatewaze/logo_black.svg +24 -0
- package/dist/theme/gatewaze/logo_white.svg +20 -0
- package/dist/theme-D6odw5nx.js +586 -0
- package/dist/ui-DRIo9Krs.js +9747 -0
- package/dist/upload-DMNfZ6FX.js +505 -0
- package/dist/useModuleFeature-DgsFIUpv.js +8 -0
- package/dist/utils-BcVvIjaY.js +36 -0
- package/dist/with-selector-B8eSdVx_.js +100 -0
- package/package.json +33 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { c as e, t } from "./react-DB2tPNit.js";
|
|
2
|
+
import { d as n } from "./shim-BCerG8nb.js";
|
|
3
|
+
import { t as r } from "./jsx-runtime-CjozyJt-.js";
|
|
4
|
+
import { n as i } from "./ui-DRIo9Krs.js";
|
|
5
|
+
import { t as a } from "./DetailPageHeader-D_v7924k.js";
|
|
6
|
+
import { a as o, s } from "./hooks-C377EXJG.js";
|
|
7
|
+
import { n as c } from "./sonnerHostBridge-CXuCMM3R.js";
|
|
8
|
+
import { t as l } from "./outline-DwDYhYcF.js";
|
|
9
|
+
import { t as u } from "./Page-D3u8IZ2a.js";
|
|
10
|
+
import { t as d } from "./templateParser-BQ2IsJ6c.js";
|
|
11
|
+
//#region ../../../gatewaze-modules/modules/newsletters/admin/pages/templates/block-editor.tsx
|
|
12
|
+
var f = /* @__PURE__ */ e(t()), p = l(), m = r();
|
|
13
|
+
function h() {
|
|
14
|
+
let { collectionSlug: e, blockType: t } = s();
|
|
15
|
+
o();
|
|
16
|
+
let [r, l] = (0, f.useState)(null), [h, _] = (0, f.useState)(!0), [v, y] = (0, f.useState)(!1), [b, x] = (0, f.useState)("html"), [S, C] = (0, f.useState)(""), [w, T] = (0, f.useState)(""), [E, D] = (0, f.useState)("{}"), [O, k] = (0, f.useState)(!1);
|
|
17
|
+
(0, f.useEffect)(() => {
|
|
18
|
+
e && t && A();
|
|
19
|
+
}, [e, t]);
|
|
20
|
+
async function A() {
|
|
21
|
+
try {
|
|
22
|
+
let { data: r, error: i } = await n.from("newsletters_template_collections").select("id").eq("slug", e).single();
|
|
23
|
+
if (i) throw i;
|
|
24
|
+
let { data: a, error: o } = await n.from("templates_block_defs").select("id, key, name, description, schema, html, rich_text_template, has_bricks, library_id").eq("library_id", r.id).eq("key", t).single();
|
|
25
|
+
if (o) throw o;
|
|
26
|
+
l(a), C(a.html || ""), T(a.rich_text_template || ""), D(JSON.stringify(a.schema || {}, null, 2)), k(a.has_bricks || !1);
|
|
27
|
+
} catch (e) {
|
|
28
|
+
console.error("Error loading template:", e), c.error("Failed to load block template");
|
|
29
|
+
} finally {
|
|
30
|
+
_(!1);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
let j = (0, f.useCallback)(async () => {
|
|
34
|
+
if (r) {
|
|
35
|
+
y(!0);
|
|
36
|
+
try {
|
|
37
|
+
let e = {};
|
|
38
|
+
try {
|
|
39
|
+
e = JSON.parse(E);
|
|
40
|
+
} catch {
|
|
41
|
+
c.error("Invalid JSON in schema"), y(!1);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
let { error: t } = await n.from("templates_block_defs").update({
|
|
45
|
+
html: S,
|
|
46
|
+
rich_text_template: w || null,
|
|
47
|
+
schema: e,
|
|
48
|
+
has_bricks: O,
|
|
49
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
50
|
+
}).eq("id", r.id);
|
|
51
|
+
if (t) throw t;
|
|
52
|
+
c.success("Block template saved");
|
|
53
|
+
} catch (e) {
|
|
54
|
+
console.error("Error saving template:", e), c.error("Failed to save template");
|
|
55
|
+
} finally {
|
|
56
|
+
y(!1);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}, [
|
|
60
|
+
r,
|
|
61
|
+
S,
|
|
62
|
+
w,
|
|
63
|
+
E,
|
|
64
|
+
O
|
|
65
|
+
]);
|
|
66
|
+
(0, f.useEffect)(() => {
|
|
67
|
+
function e(e) {
|
|
68
|
+
(e.metaKey || e.ctrlKey) && e.key === "s" && (e.preventDefault(), j());
|
|
69
|
+
}
|
|
70
|
+
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
71
|
+
}, [j]);
|
|
72
|
+
function M() {
|
|
73
|
+
let e = b === "rich_text" ? w : S;
|
|
74
|
+
if (!e) return "<p style=\"color:#999\">No template content</p>";
|
|
75
|
+
try {
|
|
76
|
+
let t = g(E);
|
|
77
|
+
return d(e, t);
|
|
78
|
+
} catch (e) {
|
|
79
|
+
return `<pre style="color:red">${e instanceof Error ? e.message : "Render error"}</pre>`;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return h ? /* @__PURE__ */ (0, m.jsx)(u, {
|
|
83
|
+
title: "Block Editor",
|
|
84
|
+
children: /* @__PURE__ */ (0, m.jsx)("div", {
|
|
85
|
+
className: "flex items-center justify-center p-12",
|
|
86
|
+
children: /* @__PURE__ */ (0, m.jsx)(i, {})
|
|
87
|
+
})
|
|
88
|
+
}) : r ? /* @__PURE__ */ (0, m.jsx)(u, {
|
|
89
|
+
title: `Edit: ${r.name}`,
|
|
90
|
+
children: /* @__PURE__ */ (0, m.jsxs)("div", {
|
|
91
|
+
className: "p-6 h-full flex flex-col",
|
|
92
|
+
children: [
|
|
93
|
+
/* @__PURE__ */ (0, m.jsx)(a, {
|
|
94
|
+
title: r.name,
|
|
95
|
+
subtitle: r.block_type,
|
|
96
|
+
backTo: `/newsletters/templates/${e}`,
|
|
97
|
+
badges: [{
|
|
98
|
+
label: r.variant_key,
|
|
99
|
+
color: "blue"
|
|
100
|
+
}],
|
|
101
|
+
actions: /* @__PURE__ */ (0, m.jsxs)(m.Fragment, { children: [/* @__PURE__ */ (0, m.jsxs)("label", {
|
|
102
|
+
className: "flex items-center gap-2 text-sm text-white/70",
|
|
103
|
+
children: [/* @__PURE__ */ (0, m.jsx)("input", {
|
|
104
|
+
type: "checkbox",
|
|
105
|
+
checked: O,
|
|
106
|
+
onChange: (e) => k(e.target.checked),
|
|
107
|
+
className: "rounded"
|
|
108
|
+
}), "Has Bricks"]
|
|
109
|
+
}), /* @__PURE__ */ (0, m.jsx)("button", {
|
|
110
|
+
onClick: j,
|
|
111
|
+
disabled: v,
|
|
112
|
+
className: "px-3 py-1.5 text-sm font-medium rounded-md bg-white/90 backdrop-blur-md border border-white/40 text-gray-900 shadow-sm hover:bg-white transition-colors disabled:opacity-50",
|
|
113
|
+
children: v ? "Saving..." : "Save"
|
|
114
|
+
})] })
|
|
115
|
+
}),
|
|
116
|
+
/* @__PURE__ */ (0, m.jsx)("div", {
|
|
117
|
+
className: "flex gap-1 mb-4 border-b border-[var(--gray-4)]",
|
|
118
|
+
children: [
|
|
119
|
+
{
|
|
120
|
+
id: "html",
|
|
121
|
+
label: "HTML Template"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
id: "rich_text",
|
|
125
|
+
label: "Rich Text Template"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
id: "schema",
|
|
129
|
+
label: "Schema"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
id: "preview",
|
|
133
|
+
label: "Preview"
|
|
134
|
+
}
|
|
135
|
+
].map((e) => /* @__PURE__ */ (0, m.jsxs)("button", {
|
|
136
|
+
onClick: () => x(e.id),
|
|
137
|
+
className: `px-3 py-2 text-sm font-medium border-b-2 transition-colors ${b === e.id ? "border-[var(--accent-9)] text-[var(--accent-11)]" : "border-transparent text-[var(--gray-10)] hover:text-[var(--gray-12)]"}`,
|
|
138
|
+
children: [
|
|
139
|
+
e.id === "preview" && /* @__PURE__ */ (0, m.jsx)(p.EyeIcon, { className: "w-4 h-4 inline mr-1" }),
|
|
140
|
+
e.id === "html" && /* @__PURE__ */ (0, m.jsx)(p.CodeBracketIcon, { className: "w-4 h-4 inline mr-1" }),
|
|
141
|
+
e.label
|
|
142
|
+
]
|
|
143
|
+
}, e.id))
|
|
144
|
+
}),
|
|
145
|
+
/* @__PURE__ */ (0, m.jsxs)("div", {
|
|
146
|
+
className: "flex-1 min-h-0",
|
|
147
|
+
children: [
|
|
148
|
+
b === "html" && /* @__PURE__ */ (0, m.jsx)("textarea", {
|
|
149
|
+
value: S,
|
|
150
|
+
onChange: (e) => C(e.target.value),
|
|
151
|
+
className: "w-full h-full min-h-[500px] px-4 py-3 font-mono text-sm rounded-md border border-[var(--gray-6)] bg-[var(--gray-1)] text-[var(--gray-12)] resize-none focus:outline-none focus:ring-2 focus:ring-[var(--accent-8)]",
|
|
152
|
+
spellCheck: !1
|
|
153
|
+
}),
|
|
154
|
+
b === "rich_text" && /* @__PURE__ */ (0, m.jsx)("textarea", {
|
|
155
|
+
value: w,
|
|
156
|
+
onChange: (e) => T(e.target.value),
|
|
157
|
+
placeholder: "Optional rich text template for Substack/Beehiiv output",
|
|
158
|
+
className: "w-full h-full min-h-[500px] px-4 py-3 font-mono text-sm rounded-md border border-[var(--gray-6)] bg-[var(--gray-1)] text-[var(--gray-12)] resize-none focus:outline-none focus:ring-2 focus:ring-[var(--accent-8)]",
|
|
159
|
+
spellCheck: !1
|
|
160
|
+
}),
|
|
161
|
+
b === "schema" && /* @__PURE__ */ (0, m.jsx)("textarea", {
|
|
162
|
+
value: E,
|
|
163
|
+
onChange: (e) => D(e.target.value),
|
|
164
|
+
className: "w-full h-full min-h-[500px] px-4 py-3 font-mono text-sm rounded-md border border-[var(--gray-6)] bg-[var(--gray-1)] text-[var(--gray-12)] resize-none focus:outline-none focus:ring-2 focus:ring-[var(--accent-8)]",
|
|
165
|
+
spellCheck: !1
|
|
166
|
+
}),
|
|
167
|
+
b === "preview" && /* @__PURE__ */ (0, m.jsx)("div", {
|
|
168
|
+
className: "border border-[var(--gray-6)] rounded-md overflow-hidden h-full min-h-[500px]",
|
|
169
|
+
children: /* @__PURE__ */ (0, m.jsx)("iframe", {
|
|
170
|
+
srcDoc: M(),
|
|
171
|
+
className: "w-full h-full min-h-[500px]",
|
|
172
|
+
sandbox: "allow-same-origin",
|
|
173
|
+
title: "Template Preview"
|
|
174
|
+
})
|
|
175
|
+
})
|
|
176
|
+
]
|
|
177
|
+
})
|
|
178
|
+
]
|
|
179
|
+
})
|
|
180
|
+
}) : /* @__PURE__ */ (0, m.jsx)(u, {
|
|
181
|
+
title: "Block Not Found",
|
|
182
|
+
children: /* @__PURE__ */ (0, m.jsx)("div", {
|
|
183
|
+
className: "p-6 text-center text-[var(--gray-10)]",
|
|
184
|
+
children: "Block template not found"
|
|
185
|
+
})
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
function g(e) {
|
|
189
|
+
try {
|
|
190
|
+
let t = JSON.parse(e), n = {};
|
|
191
|
+
for (let [e, r] of Object.entries(t)) {
|
|
192
|
+
let t = r;
|
|
193
|
+
switch (t.type) {
|
|
194
|
+
case "string":
|
|
195
|
+
case "text":
|
|
196
|
+
case "richtext":
|
|
197
|
+
n[e] = t.placeholder || t.default || `Sample ${e}`;
|
|
198
|
+
break;
|
|
199
|
+
case "url":
|
|
200
|
+
n[e] = t.default || "https://example.com";
|
|
201
|
+
break;
|
|
202
|
+
case "image":
|
|
203
|
+
n[e] = t.default || "https://via.placeholder.com/600x300";
|
|
204
|
+
break;
|
|
205
|
+
case "boolean":
|
|
206
|
+
n[e] = t.default ?? !0;
|
|
207
|
+
break;
|
|
208
|
+
case "number":
|
|
209
|
+
n[e] = t.default ?? 1;
|
|
210
|
+
break;
|
|
211
|
+
case "array":
|
|
212
|
+
n[e] = [g(JSON.stringify(t.items || {})), g(JSON.stringify(t.items || {}))];
|
|
213
|
+
break;
|
|
214
|
+
default: n[e] = `Sample ${e}`;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return n;
|
|
218
|
+
} catch {
|
|
219
|
+
return {
|
|
220
|
+
title: "Sample Title",
|
|
221
|
+
body: "<p>Sample body content</p>"
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
//#endregion
|
|
226
|
+
export { h as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { n as e } from "./react-DB2tPNit.js";
|
|
2
|
+
//#region \0stub:next/link
|
|
3
|
+
var t = /* @__PURE__ */ e(((e, t) => {
|
|
4
|
+
t.exports = {};
|
|
5
|
+
})), n = /* @__PURE__ */ e(((e, t) => {
|
|
6
|
+
t.exports = {};
|
|
7
|
+
})), r = /* @__PURE__ */ e(((e, t) => {
|
|
8
|
+
t.exports = {};
|
|
9
|
+
}));
|
|
10
|
+
//#endregion
|
|
11
|
+
export { n, t as r, r as t };
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { c as e, t } from "./react-DB2tPNit.js";
|
|
2
|
+
import { d as n } from "./shim-BCerG8nb.js";
|
|
3
|
+
import { t as r } from "./jsx-runtime-CjozyJt-.js";
|
|
4
|
+
import { D as i, O as a, n as o } from "./ui-DRIo9Krs.js";
|
|
5
|
+
import { a as s, s as c } from "./hooks-C377EXJG.js";
|
|
6
|
+
import { n as l } from "./sonnerHostBridge-CXuCMM3R.js";
|
|
7
|
+
import { t as u } from "./outline-DwDYhYcF.js";
|
|
8
|
+
import { t as d } from "./Page-D3u8IZ2a.js";
|
|
9
|
+
import { t as f } from "./templateParser-BQ2IsJ6c.js";
|
|
10
|
+
//#region ../../../gatewaze-modules/modules/newsletters/admin/pages/templates/brick-editor.tsx
|
|
11
|
+
var p = /* @__PURE__ */ e(t()), m = u(), h = r();
|
|
12
|
+
function g() {
|
|
13
|
+
let { collectionSlug: e, brickType: t } = c(), r = s(), [u, g] = (0, p.useState)(null), [v, y] = (0, p.useState)(!0), [b, x] = (0, p.useState)(!1), [S, C] = (0, p.useState)("html"), [w, T] = (0, p.useState)(""), [E, D] = (0, p.useState)(""), [O, k] = (0, p.useState)("{}");
|
|
14
|
+
(0, p.useEffect)(() => {
|
|
15
|
+
e && t && A();
|
|
16
|
+
}, [e, t]);
|
|
17
|
+
async function A() {
|
|
18
|
+
try {
|
|
19
|
+
let { data: r, error: i } = await n.from("newsletters_template_collections").select("id").eq("slug", e).single();
|
|
20
|
+
if (i) throw i;
|
|
21
|
+
let { data: a, error: o } = await n.from("templates_brick_defs").select("id, block_def_id, key, name, schema, html, rich_text_template, sort_order, templates_block_defs!inner(library_id)").eq("templates_block_defs.library_id", r.id).eq("key", t).single();
|
|
22
|
+
if (o) throw o;
|
|
23
|
+
g(a), T(a.html || ""), D(a.rich_text_template || ""), k(JSON.stringify(a.schema || {}, null, 2));
|
|
24
|
+
} catch (e) {
|
|
25
|
+
console.error("Error loading template:", e), l.error("Failed to load brick template");
|
|
26
|
+
} finally {
|
|
27
|
+
y(!1);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
let j = (0, p.useCallback)(async () => {
|
|
31
|
+
if (u) {
|
|
32
|
+
x(!0);
|
|
33
|
+
try {
|
|
34
|
+
let e = {};
|
|
35
|
+
try {
|
|
36
|
+
e = JSON.parse(O);
|
|
37
|
+
} catch {
|
|
38
|
+
l.error("Invalid JSON in schema"), x(!1);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
let { error: t } = await n.from("templates_brick_defs").update({
|
|
42
|
+
html: w,
|
|
43
|
+
rich_text_template: E || null,
|
|
44
|
+
schema: e,
|
|
45
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
46
|
+
}).eq("id", u.id);
|
|
47
|
+
if (t) throw t;
|
|
48
|
+
l.success("Brick template saved");
|
|
49
|
+
} catch (e) {
|
|
50
|
+
console.error("Error saving template:", e), l.error("Failed to save template");
|
|
51
|
+
} finally {
|
|
52
|
+
x(!1);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}, [
|
|
56
|
+
u,
|
|
57
|
+
w,
|
|
58
|
+
E,
|
|
59
|
+
O
|
|
60
|
+
]);
|
|
61
|
+
(0, p.useEffect)(() => {
|
|
62
|
+
function e(e) {
|
|
63
|
+
(e.metaKey || e.ctrlKey) && e.key === "s" && (e.preventDefault(), j());
|
|
64
|
+
}
|
|
65
|
+
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
66
|
+
}, [j]);
|
|
67
|
+
function M() {
|
|
68
|
+
let e = S === "rich_text" ? E : w;
|
|
69
|
+
if (!e) return "<p style=\"color:#999\">No template content</p>";
|
|
70
|
+
try {
|
|
71
|
+
let t = _(O);
|
|
72
|
+
return f(e, t);
|
|
73
|
+
} catch (e) {
|
|
74
|
+
return `<pre style="color:red">${e instanceof Error ? e.message : "Render error"}</pre>`;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return v ? /* @__PURE__ */ (0, h.jsx)(d, {
|
|
78
|
+
title: "Brick Editor",
|
|
79
|
+
children: /* @__PURE__ */ (0, h.jsx)("div", {
|
|
80
|
+
className: "flex items-center justify-center p-12",
|
|
81
|
+
children: /* @__PURE__ */ (0, h.jsx)(o, {})
|
|
82
|
+
})
|
|
83
|
+
}) : u ? /* @__PURE__ */ (0, h.jsx)(d, {
|
|
84
|
+
title: `Edit: ${u.name}`,
|
|
85
|
+
children: /* @__PURE__ */ (0, h.jsxs)("div", {
|
|
86
|
+
className: "p-6 h-full flex flex-col",
|
|
87
|
+
children: [
|
|
88
|
+
/* @__PURE__ */ (0, h.jsxs)("div", {
|
|
89
|
+
className: "flex items-center justify-between mb-4",
|
|
90
|
+
children: [/* @__PURE__ */ (0, h.jsxs)("div", {
|
|
91
|
+
className: "flex items-center gap-3",
|
|
92
|
+
children: [/* @__PURE__ */ (0, h.jsx)(i, {
|
|
93
|
+
variant: "ghost",
|
|
94
|
+
size: "sm",
|
|
95
|
+
onClick: () => r(`/newsletters/templates/${e}`),
|
|
96
|
+
children: /* @__PURE__ */ (0, h.jsx)(m.ArrowLeftIcon, { className: "w-4 h-4" })
|
|
97
|
+
}), /* @__PURE__ */ (0, h.jsxs)("div", { children: [/* @__PURE__ */ (0, h.jsx)("h1", {
|
|
98
|
+
className: "text-lg font-semibold text-[var(--gray-12)]",
|
|
99
|
+
children: u.name
|
|
100
|
+
}), /* @__PURE__ */ (0, h.jsxs)("div", {
|
|
101
|
+
className: "flex items-center gap-2 mt-0.5",
|
|
102
|
+
children: [/* @__PURE__ */ (0, h.jsx)("span", {
|
|
103
|
+
className: "text-xs text-[var(--gray-10)]",
|
|
104
|
+
children: u.brick_type
|
|
105
|
+
}), /* @__PURE__ */ (0, h.jsx)(a, {
|
|
106
|
+
variant: "neutral",
|
|
107
|
+
size: "sm",
|
|
108
|
+
children: u.variant_key
|
|
109
|
+
})]
|
|
110
|
+
})] })]
|
|
111
|
+
}), /* @__PURE__ */ (0, h.jsx)(i, {
|
|
112
|
+
variant: "primary",
|
|
113
|
+
onClick: j,
|
|
114
|
+
disabled: b,
|
|
115
|
+
children: b ? "Saving..." : "Save"
|
|
116
|
+
})]
|
|
117
|
+
}),
|
|
118
|
+
/* @__PURE__ */ (0, h.jsx)("div", {
|
|
119
|
+
className: "flex gap-1 mb-4 border-b border-[var(--gray-4)]",
|
|
120
|
+
children: [
|
|
121
|
+
{
|
|
122
|
+
id: "html",
|
|
123
|
+
label: "HTML Template"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
id: "rich_text",
|
|
127
|
+
label: "Rich Text Template"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
id: "schema",
|
|
131
|
+
label: "Schema"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
id: "preview",
|
|
135
|
+
label: "Preview"
|
|
136
|
+
}
|
|
137
|
+
].map((e) => /* @__PURE__ */ (0, h.jsxs)("button", {
|
|
138
|
+
onClick: () => C(e.id),
|
|
139
|
+
className: `px-3 py-2 text-sm font-medium border-b-2 transition-colors ${S === e.id ? "border-[var(--accent-9)] text-[var(--accent-11)]" : "border-transparent text-[var(--gray-10)] hover:text-[var(--gray-12)]"}`,
|
|
140
|
+
children: [
|
|
141
|
+
e.id === "preview" && /* @__PURE__ */ (0, h.jsx)(m.EyeIcon, { className: "w-4 h-4 inline mr-1" }),
|
|
142
|
+
e.id === "html" && /* @__PURE__ */ (0, h.jsx)(m.CodeBracketIcon, { className: "w-4 h-4 inline mr-1" }),
|
|
143
|
+
e.label
|
|
144
|
+
]
|
|
145
|
+
}, e.id))
|
|
146
|
+
}),
|
|
147
|
+
/* @__PURE__ */ (0, h.jsxs)("div", {
|
|
148
|
+
className: "flex-1 min-h-0",
|
|
149
|
+
children: [
|
|
150
|
+
S === "html" && /* @__PURE__ */ (0, h.jsx)("textarea", {
|
|
151
|
+
value: w,
|
|
152
|
+
onChange: (e) => T(e.target.value),
|
|
153
|
+
className: "w-full h-full min-h-[500px] px-4 py-3 font-mono text-sm rounded-md border border-[var(--gray-6)] bg-[var(--gray-1)] text-[var(--gray-12)] resize-none focus:outline-none focus:ring-2 focus:ring-[var(--accent-8)]",
|
|
154
|
+
spellCheck: !1
|
|
155
|
+
}),
|
|
156
|
+
S === "rich_text" && /* @__PURE__ */ (0, h.jsx)("textarea", {
|
|
157
|
+
value: E,
|
|
158
|
+
onChange: (e) => D(e.target.value),
|
|
159
|
+
placeholder: "Optional rich text template for Substack/Beehiiv output",
|
|
160
|
+
className: "w-full h-full min-h-[500px] px-4 py-3 font-mono text-sm rounded-md border border-[var(--gray-6)] bg-[var(--gray-1)] text-[var(--gray-12)] resize-none focus:outline-none focus:ring-2 focus:ring-[var(--accent-8)]",
|
|
161
|
+
spellCheck: !1
|
|
162
|
+
}),
|
|
163
|
+
S === "schema" && /* @__PURE__ */ (0, h.jsx)("textarea", {
|
|
164
|
+
value: O,
|
|
165
|
+
onChange: (e) => k(e.target.value),
|
|
166
|
+
className: "w-full h-full min-h-[500px] px-4 py-3 font-mono text-sm rounded-md border border-[var(--gray-6)] bg-[var(--gray-1)] text-[var(--gray-12)] resize-none focus:outline-none focus:ring-2 focus:ring-[var(--accent-8)]",
|
|
167
|
+
spellCheck: !1
|
|
168
|
+
}),
|
|
169
|
+
S === "preview" && /* @__PURE__ */ (0, h.jsx)("div", {
|
|
170
|
+
className: "border border-[var(--gray-6)] rounded-md overflow-hidden h-full min-h-[500px]",
|
|
171
|
+
children: /* @__PURE__ */ (0, h.jsx)("iframe", {
|
|
172
|
+
srcDoc: M(),
|
|
173
|
+
className: "w-full h-full min-h-[500px]",
|
|
174
|
+
sandbox: "allow-same-origin",
|
|
175
|
+
title: "Template Preview"
|
|
176
|
+
})
|
|
177
|
+
})
|
|
178
|
+
]
|
|
179
|
+
})
|
|
180
|
+
]
|
|
181
|
+
})
|
|
182
|
+
}) : /* @__PURE__ */ (0, h.jsx)(d, {
|
|
183
|
+
title: "Brick Not Found",
|
|
184
|
+
children: /* @__PURE__ */ (0, h.jsx)("div", {
|
|
185
|
+
className: "p-6 text-center text-[var(--gray-10)]",
|
|
186
|
+
children: "Brick template not found"
|
|
187
|
+
})
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
function _(e) {
|
|
191
|
+
try {
|
|
192
|
+
let t = JSON.parse(e), n = {};
|
|
193
|
+
for (let [e, r] of Object.entries(t)) {
|
|
194
|
+
let t = r;
|
|
195
|
+
switch (t.type) {
|
|
196
|
+
case "string":
|
|
197
|
+
case "text":
|
|
198
|
+
case "richtext":
|
|
199
|
+
n[e] = t.placeholder || t.default || `Sample ${e}`;
|
|
200
|
+
break;
|
|
201
|
+
case "url":
|
|
202
|
+
n[e] = t.default || "https://example.com";
|
|
203
|
+
break;
|
|
204
|
+
case "image":
|
|
205
|
+
n[e] = t.default || "https://via.placeholder.com/600x300";
|
|
206
|
+
break;
|
|
207
|
+
case "boolean":
|
|
208
|
+
n[e] = t.default ?? !0;
|
|
209
|
+
break;
|
|
210
|
+
case "number":
|
|
211
|
+
n[e] = t.default ?? 1;
|
|
212
|
+
break;
|
|
213
|
+
default: n[e] = `Sample ${e}`;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return n;
|
|
217
|
+
} catch {
|
|
218
|
+
return {
|
|
219
|
+
title: "Sample Title",
|
|
220
|
+
description: "<p>Sample description</p>"
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
//#endregion
|
|
225
|
+
export { g as default };
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { d as e } from "./shim-BCerG8nb.js";
|
|
2
|
+
//#region ../../../gatewaze-modules/modules/broadcasts/admin/lib/broadcastService.ts
|
|
3
|
+
function t(e) {
|
|
4
|
+
let t = (e.sends ?? []).slice().sort((e, t) => e.created_at < t.created_at ? 1 : -1), n = t.find((e) => e.status === "sending" || e.status === "scheduled" || e.status === "cancelling" || e.status === "paused") ?? t[0] ?? null;
|
|
5
|
+
return {
|
|
6
|
+
status: n?.status ?? "draft",
|
|
7
|
+
latest: n
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
var n = [
|
|
11
|
+
{
|
|
12
|
+
token: "{{event_name}}",
|
|
13
|
+
label: "Event name"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
token: "{{event_date}}",
|
|
17
|
+
label: "Event date"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
token: "{{event_city}}",
|
|
21
|
+
label: "Event city"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
token: "{{event_url}}",
|
|
25
|
+
label: "Event page URL"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
token: "{{event_cfp_url}}",
|
|
29
|
+
label: "Submit-a-talk (CFP) URL"
|
|
30
|
+
}
|
|
31
|
+
];
|
|
32
|
+
async function r() {
|
|
33
|
+
let { data: t, error: n } = await e.from("lists").select("id, name").order("name");
|
|
34
|
+
if (n) throw n;
|
|
35
|
+
return t ?? [];
|
|
36
|
+
}
|
|
37
|
+
async function i() {
|
|
38
|
+
let { data: t, error: n } = await e.from("events").select("id, event_title, event_start").order("event_start", { ascending: !1 }).limit(500);
|
|
39
|
+
if (n) throw n;
|
|
40
|
+
return t ?? [];
|
|
41
|
+
}
|
|
42
|
+
function a(e, t) {
|
|
43
|
+
let n = e.event_slug || e.event_id || "", r = n ? `${t}/events/${n}` : t, i = e.event_start ? new Date(e.event_start).toLocaleDateString(void 0, {
|
|
44
|
+
year: "numeric",
|
|
45
|
+
month: "long",
|
|
46
|
+
day: "numeric"
|
|
47
|
+
}) : "";
|
|
48
|
+
return {
|
|
49
|
+
event_name: e.event_title || "",
|
|
50
|
+
event_date: i,
|
|
51
|
+
event_city: e.event_city || "",
|
|
52
|
+
event_url: r,
|
|
53
|
+
event_cfp_url: n ? `${r}/talks` : r
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function o(e, t) {
|
|
57
|
+
let n = e;
|
|
58
|
+
for (let [e, r] of Object.entries(t)) n = n.replace(RegExp(`\\{\\{\\s*${e}\\s*\\}\\}`, "g"), r);
|
|
59
|
+
return n;
|
|
60
|
+
}
|
|
61
|
+
function s() {
|
|
62
|
+
if (typeof window > "u") return "";
|
|
63
|
+
let e = window.location.hostname.replace("-admin.", "-app.").replace(/^admin\./, "");
|
|
64
|
+
return `${window.location.protocol}//${e}`;
|
|
65
|
+
}
|
|
66
|
+
async function c() {
|
|
67
|
+
try {
|
|
68
|
+
let { data: t } = await e.from("platform_settings").select("value").eq("key", "domain").maybeSingle(), n = (t?.value)?.trim();
|
|
69
|
+
if (n) {
|
|
70
|
+
let e = typeof window < "u" ? window.location.protocol : "https:";
|
|
71
|
+
return /^https?:\/\//i.test(n) ? n.replace(/\/+$/, "") : `${e}//${n.replace(/\/+$/, "")}`;
|
|
72
|
+
}
|
|
73
|
+
} catch {}
|
|
74
|
+
return s();
|
|
75
|
+
}
|
|
76
|
+
async function l() {
|
|
77
|
+
let { data: t, error: n } = await e.from("broadcasts").select("*, sends:broadcast_sends(id, broadcast_id, status, schedule_type, delivery_strategy, scheduled_at, started_at, completed_at, total_recipients, sent_count, failed_count, created_at)").order("created_at", { ascending: !1 });
|
|
78
|
+
if (n) throw n;
|
|
79
|
+
return t ?? [];
|
|
80
|
+
}
|
|
81
|
+
async function u(t) {
|
|
82
|
+
if (t.length === 0) return [];
|
|
83
|
+
let { data: n, error: r } = await e.rpc("broadcast_engagement", { p_broadcast_ids: t });
|
|
84
|
+
if (r) throw r;
|
|
85
|
+
return n ?? [];
|
|
86
|
+
}
|
|
87
|
+
async function d(t) {
|
|
88
|
+
let { data: n, error: r } = await e.from("broadcasts").select("*").eq("id", t).maybeSingle();
|
|
89
|
+
if (r) throw r;
|
|
90
|
+
return n ?? null;
|
|
91
|
+
}
|
|
92
|
+
async function f(t) {
|
|
93
|
+
let { data: n, error: r } = await e.from("broadcasts").insert({
|
|
94
|
+
name: t.name,
|
|
95
|
+
brand: t.brand ?? "default",
|
|
96
|
+
audience_type: t.audience_type ?? "segment",
|
|
97
|
+
segment_id: t.segment_id ?? null,
|
|
98
|
+
list_ids: t.list_ids ?? [],
|
|
99
|
+
subject: t.subject ?? null
|
|
100
|
+
}).select("*").single();
|
|
101
|
+
if (r) throw r;
|
|
102
|
+
return n;
|
|
103
|
+
}
|
|
104
|
+
async function p(t, n) {
|
|
105
|
+
let { data: r, error: i } = await e.from("broadcasts").update(n).eq("id", t).select("*").single();
|
|
106
|
+
if (i) throw i;
|
|
107
|
+
return r;
|
|
108
|
+
}
|
|
109
|
+
async function m(t) {
|
|
110
|
+
let { error: n } = await e.from("broadcasts").delete().eq("id", t);
|
|
111
|
+
if (n) throw n;
|
|
112
|
+
}
|
|
113
|
+
async function h(t, n) {
|
|
114
|
+
let r = await d(t);
|
|
115
|
+
if (!r) throw Error("Broadcast not found");
|
|
116
|
+
if (!r.rendered_html) throw Error("Add content before sending");
|
|
117
|
+
if (!r.category_list_id) throw Error("Select an unsubscribe list before sending");
|
|
118
|
+
let i = r.subject, s = r.rendered_html, l = await c();
|
|
119
|
+
if (r.event_id) {
|
|
120
|
+
let { data: t } = await e.from("events").select("event_title, event_slug, event_id, event_start, event_city").eq("id", r.event_id).maybeSingle();
|
|
121
|
+
if (t) {
|
|
122
|
+
let e = a(t, l);
|
|
123
|
+
i &&= o(i, e), s &&= o(s, e);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
let { data: u, error: f } = await e.from("broadcast_sends").insert({
|
|
127
|
+
broadcast_id: t,
|
|
128
|
+
event_id: r.event_id,
|
|
129
|
+
name: r.name,
|
|
130
|
+
brand: r.brand,
|
|
131
|
+
channel: r.channel,
|
|
132
|
+
audience_type: r.audience_type,
|
|
133
|
+
segment_id: r.segment_id,
|
|
134
|
+
list_ids: r.list_ids,
|
|
135
|
+
category_list_id: r.category_list_id,
|
|
136
|
+
include_prospects: r.include_prospects ?? !1,
|
|
137
|
+
subject: i,
|
|
138
|
+
preheader: r.preheader,
|
|
139
|
+
from_address: r.from_address,
|
|
140
|
+
from_name: r.from_name,
|
|
141
|
+
reply_to: r.reply_to,
|
|
142
|
+
rendered_html: s,
|
|
143
|
+
body_text: r.body_text,
|
|
144
|
+
content_json: r.content_json,
|
|
145
|
+
suppression_topic: "broadcasts",
|
|
146
|
+
status: n.scheduleType === "scheduled" ? "scheduled" : "sending",
|
|
147
|
+
schedule_type: n.scheduleType,
|
|
148
|
+
scheduled_at: n.scheduledAt,
|
|
149
|
+
delivery_strategy: n.deliveryStrategy,
|
|
150
|
+
target_local: n.targetLocal,
|
|
151
|
+
default_timezone: n.defaultTimezone,
|
|
152
|
+
exclude_sent_send_ids: n.excludeSentSendIds.length > 0 ? n.excludeSentSendIds : null,
|
|
153
|
+
total_recipients: 0,
|
|
154
|
+
sent_count: 0,
|
|
155
|
+
failed_count: 0,
|
|
156
|
+
metadata: { portal_base_url: l }
|
|
157
|
+
}).select("id").single();
|
|
158
|
+
if (f) throw f;
|
|
159
|
+
return { id: u.id };
|
|
160
|
+
}
|
|
161
|
+
var g = globalThis.__GATEWAZE_CONFIG__.VITE_API_URL ?? "";
|
|
162
|
+
async function _(t, n) {
|
|
163
|
+
try {
|
|
164
|
+
let { data: r } = await e.auth.getSession(), i = r.session?.access_token, a = {
|
|
165
|
+
"Content-Type": "application/json",
|
|
166
|
+
Accept: "application/json"
|
|
167
|
+
};
|
|
168
|
+
i && (a.Authorization = `Bearer ${i}`);
|
|
169
|
+
let o = await fetch(`${g}/api/admin/modules/broadcasts/segments-ai-build`, {
|
|
170
|
+
method: "POST",
|
|
171
|
+
headers: a,
|
|
172
|
+
body: JSON.stringify({
|
|
173
|
+
prompt: t,
|
|
174
|
+
brand: n?.brand,
|
|
175
|
+
current_definition: n?.currentDefinition ?? void 0
|
|
176
|
+
})
|
|
177
|
+
}), s = await o.json().catch(() => ({}));
|
|
178
|
+
return o.ok ? s : {
|
|
179
|
+
success: !1,
|
|
180
|
+
error: s?.error || `Copilot failed (${o.status})`
|
|
181
|
+
};
|
|
182
|
+
} catch (e) {
|
|
183
|
+
return {
|
|
184
|
+
success: !1,
|
|
185
|
+
error: e instanceof Error ? e.message : "Copilot request failed"
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
//#endregion
|
|
190
|
+
export { f as a, d as c, i as d, p as f, _ as i, l, u as n, h as o, t as r, m as s, n as t, r as u };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { n as e } from "./react-DB2tPNit.js";
|
|
2
|
+
//#region src/utils/dom/injectStylesToHead.ts
|
|
3
|
+
var t = document.head || document.getElementsByTagName("head")[0];
|
|
4
|
+
function n(e) {
|
|
5
|
+
t.appendChild(e);
|
|
6
|
+
}
|
|
7
|
+
function r(e, t) {
|
|
8
|
+
e.styleSheet ? e.styleSheet.cssText = t : e.appendChild(document.createTextNode(t));
|
|
9
|
+
}
|
|
10
|
+
function i() {
|
|
11
|
+
let e = document.createElement("style");
|
|
12
|
+
return e.type = "text/css", e;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region ../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js
|
|
16
|
+
var a = /* @__PURE__ */ e(((e, t) => {
|
|
17
|
+
(function() {
|
|
18
|
+
var e = {}.hasOwnProperty;
|
|
19
|
+
function n() {
|
|
20
|
+
for (var e = "", t = 0; t < arguments.length; t++) {
|
|
21
|
+
var n = arguments[t];
|
|
22
|
+
n && (e = i(e, r(n)));
|
|
23
|
+
}
|
|
24
|
+
return e;
|
|
25
|
+
}
|
|
26
|
+
function r(t) {
|
|
27
|
+
if (typeof t == "string" || typeof t == "number") return t;
|
|
28
|
+
if (typeof t != "object") return "";
|
|
29
|
+
if (Array.isArray(t)) return n.apply(null, t);
|
|
30
|
+
if (t.toString !== Object.prototype.toString && !t.toString.toString().includes("[native code]")) return t.toString();
|
|
31
|
+
var r = "";
|
|
32
|
+
for (var a in t) e.call(t, a) && t[a] && (r = i(r, a));
|
|
33
|
+
return r;
|
|
34
|
+
}
|
|
35
|
+
function i(e, t) {
|
|
36
|
+
return t ? e ? e + " " + t : e + t : e;
|
|
37
|
+
}
|
|
38
|
+
t !== void 0 && t.exports ? (n.default = n, t.exports = n) : typeof define == "function" && typeof define.amd == "object" && define.amd ? define("classnames", [], function() {
|
|
39
|
+
return n;
|
|
40
|
+
}) : window.classNames = n;
|
|
41
|
+
})();
|
|
42
|
+
}));
|
|
43
|
+
//#endregion
|
|
44
|
+
export { i, r as n, n as r, a as t };
|