@resulticks/trustsignal-wa-hsm 0.6.0 → 0.7.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 +118 -94
- package/dist/resulticks-trustsignal-wa-hsm.cjs.js +27 -22
- package/dist/resulticks-trustsignal-wa-hsm.es.js +1161 -1148
- package/dist/style.css +1 -1
- package/package.json +2 -4
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { jsx as e, jsxs as r, Fragment as ce } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
const ze = async (a, s = {}) => {
|
|
2
|
+
import X, { forwardRef as Ie, createElement as ke, useRef as Te, useEffect as le, useState as B, useMemo as Se, useCallback as Ne, createContext as Be } from "react";
|
|
3
|
+
const Oe = async (a, s = {}) => {
|
|
5
4
|
try {
|
|
6
|
-
return await
|
|
7
|
-
} catch (
|
|
8
|
-
return console.error("API Error:",
|
|
5
|
+
return await Pe(a.apiKey);
|
|
6
|
+
} catch (n) {
|
|
7
|
+
return console.error("API Error:", n), {
|
|
9
8
|
status: "error",
|
|
10
|
-
message:
|
|
9
|
+
message: n instanceof Error ? n.message : "Failed to fetch templates"
|
|
11
10
|
};
|
|
12
11
|
}
|
|
13
|
-
},
|
|
12
|
+
}, Pe = async (a) => {
|
|
14
13
|
const s = await fetch(
|
|
15
14
|
"https://wpapi.trustsignal.io/api/v1/template?page=1&limit=100",
|
|
16
15
|
{
|
|
@@ -23,28 +22,28 @@ const ze = async (a, s = {}) => {
|
|
|
23
22
|
);
|
|
24
23
|
if (!s.ok)
|
|
25
24
|
throw new Error(`HTTP error! status: ${s.status}`);
|
|
26
|
-
const
|
|
27
|
-
if (!
|
|
28
|
-
throw new Error(
|
|
25
|
+
const n = await s.json();
|
|
26
|
+
if (!n.success)
|
|
27
|
+
throw new Error(n.message || "Failed to fetch templates");
|
|
29
28
|
return {
|
|
30
29
|
status: "success",
|
|
31
|
-
data:
|
|
32
|
-
id:
|
|
33
|
-
name:
|
|
34
|
-
category:
|
|
35
|
-
language:
|
|
36
|
-
type:
|
|
37
|
-
body:
|
|
38
|
-
status:
|
|
39
|
-
creation_time: new Date(
|
|
40
|
-
updation_time: new Date(
|
|
41
|
-
medialist:
|
|
42
|
-
shortlink:
|
|
30
|
+
data: n.templates.map((c) => ({
|
|
31
|
+
id: c.id,
|
|
32
|
+
name: c.name,
|
|
33
|
+
category: c.category,
|
|
34
|
+
language: c.lang,
|
|
35
|
+
type: c.temptype || "TEXT",
|
|
36
|
+
body: c.temp_var_data || "",
|
|
37
|
+
status: c.status,
|
|
38
|
+
creation_time: new Date(c.created_at).getTime(),
|
|
39
|
+
updation_time: new Date(c.modified_at).getTime(),
|
|
40
|
+
medialist: c.medialist,
|
|
41
|
+
shortlink: c.shortlink
|
|
43
42
|
})),
|
|
44
43
|
meta: {
|
|
45
|
-
total:
|
|
46
|
-
page:
|
|
47
|
-
limit:
|
|
44
|
+
total: n.totalrecords,
|
|
45
|
+
page: n.page,
|
|
46
|
+
limit: n.limit
|
|
48
47
|
}
|
|
49
48
|
};
|
|
50
49
|
};
|
|
@@ -54,7 +53,7 @@ const ze = async (a, s = {}) => {
|
|
|
54
53
|
* This source code is licensed under the ISC license.
|
|
55
54
|
* See the LICENSE file in the root directory of this source tree.
|
|
56
55
|
*/
|
|
57
|
-
var
|
|
56
|
+
var ze = {
|
|
58
57
|
xmlns: "http://www.w3.org/2000/svg",
|
|
59
58
|
width: 24,
|
|
60
59
|
height: 24,
|
|
@@ -71,35 +70,35 @@ var _e = {
|
|
|
71
70
|
* This source code is licensed under the ISC license.
|
|
72
71
|
* See the LICENSE file in the root directory of this source tree.
|
|
73
72
|
*/
|
|
74
|
-
const
|
|
75
|
-
const
|
|
73
|
+
const De = (a) => a.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase().trim(), q = (a, s) => {
|
|
74
|
+
const n = Ie(
|
|
76
75
|
({
|
|
77
|
-
color:
|
|
78
|
-
size:
|
|
79
|
-
strokeWidth:
|
|
76
|
+
color: i = "currentColor",
|
|
77
|
+
size: c = 24,
|
|
78
|
+
strokeWidth: o = 2,
|
|
80
79
|
absoluteStrokeWidth: l,
|
|
81
|
-
className:
|
|
82
|
-
children:
|
|
83
|
-
...
|
|
84
|
-
},
|
|
80
|
+
className: v = "",
|
|
81
|
+
children: g,
|
|
82
|
+
...h
|
|
83
|
+
}, k) => ke(
|
|
85
84
|
"svg",
|
|
86
85
|
{
|
|
87
|
-
ref:
|
|
88
|
-
...
|
|
89
|
-
width:
|
|
90
|
-
height:
|
|
91
|
-
stroke:
|
|
92
|
-
strokeWidth: l ? Number(
|
|
93
|
-
className: ["lucide", `lucide-${
|
|
94
|
-
...
|
|
86
|
+
ref: k,
|
|
87
|
+
...ze,
|
|
88
|
+
width: c,
|
|
89
|
+
height: c,
|
|
90
|
+
stroke: i,
|
|
91
|
+
strokeWidth: l ? Number(o) * 24 / Number(c) : o,
|
|
92
|
+
className: ["lucide", `lucide-${De(a)}`, v].join(" "),
|
|
93
|
+
...h
|
|
95
94
|
},
|
|
96
95
|
[
|
|
97
|
-
...s.map(([
|
|
98
|
-
...Array.isArray(
|
|
96
|
+
...s.map(([V, d]) => ke(V, d)),
|
|
97
|
+
...Array.isArray(g) ? g : [g]
|
|
99
98
|
]
|
|
100
99
|
)
|
|
101
100
|
);
|
|
102
|
-
return
|
|
101
|
+
return n.displayName = `${a}`, n;
|
|
103
102
|
};
|
|
104
103
|
/**
|
|
105
104
|
* @license lucide-react v0.344.0 - ISC
|
|
@@ -107,7 +106,7 @@ const Fe = (a) => a.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase().trim(),
|
|
|
107
106
|
* This source code is licensed under the ISC license.
|
|
108
107
|
* See the LICENSE file in the root directory of this source tree.
|
|
109
108
|
*/
|
|
110
|
-
const fe =
|
|
109
|
+
const fe = q("AlertCircle", [
|
|
111
110
|
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
112
111
|
["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
|
|
113
112
|
["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
|
|
@@ -118,7 +117,7 @@ const fe = $("AlertCircle", [
|
|
|
118
117
|
* This source code is licensed under the ISC license.
|
|
119
118
|
* See the LICENSE file in the root directory of this source tree.
|
|
120
119
|
*/
|
|
121
|
-
const
|
|
120
|
+
const _e = q("ArrowRight", [
|
|
122
121
|
["path", { d: "M5 12h14", key: "1ays0h" }],
|
|
123
122
|
["path", { d: "m12 5 7 7-7 7", key: "xquz4c" }]
|
|
124
123
|
]);
|
|
@@ -128,7 +127,16 @@ const qe = $("ArrowRight", [
|
|
|
128
127
|
* This source code is licensed under the ISC license.
|
|
129
128
|
* See the LICENSE file in the root directory of this source tree.
|
|
130
129
|
*/
|
|
131
|
-
const
|
|
130
|
+
const Fe = q("ChevronLeft", [
|
|
131
|
+
["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]
|
|
132
|
+
]);
|
|
133
|
+
/**
|
|
134
|
+
* @license lucide-react v0.344.0 - ISC
|
|
135
|
+
*
|
|
136
|
+
* This source code is licensed under the ISC license.
|
|
137
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
138
|
+
*/
|
|
139
|
+
const qe = q("ExternalLink", [
|
|
132
140
|
["path", { d: "M15 3h6v6", key: "1q9fwt" }],
|
|
133
141
|
["path", { d: "M10 14 21 3", key: "gplh6r" }],
|
|
134
142
|
["path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6", key: "a6xqqp" }]
|
|
@@ -139,7 +147,7 @@ const He = $("ExternalLink", [
|
|
|
139
147
|
* This source code is licensed under the ISC license.
|
|
140
148
|
* See the LICENSE file in the root directory of this source tree.
|
|
141
149
|
*/
|
|
142
|
-
const
|
|
150
|
+
const He = q("FileText", [
|
|
143
151
|
["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z", key: "1rqfz7" }],
|
|
144
152
|
["path", { d: "M14 2v4a2 2 0 0 0 2 2h4", key: "tnqrlb" }],
|
|
145
153
|
["path", { d: "M10 9H8", key: "b1mrlr" }],
|
|
@@ -152,7 +160,7 @@ const $e = $("FileText", [
|
|
|
152
160
|
* This source code is licensed under the ISC license.
|
|
153
161
|
* See the LICENSE file in the root directory of this source tree.
|
|
154
162
|
*/
|
|
155
|
-
const
|
|
163
|
+
const $e = q("FileVideo", [
|
|
156
164
|
["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z", key: "1rqfz7" }],
|
|
157
165
|
["path", { d: "M14 2v4a2 2 0 0 0 2 2h4", key: "tnqrlb" }],
|
|
158
166
|
["path", { d: "m10 11 5 3-5 3v-6Z", key: "7ntvm4" }]
|
|
@@ -163,7 +171,7 @@ const Ge = $("FileVideo", [
|
|
|
163
171
|
* This source code is licensed under the ISC license.
|
|
164
172
|
* See the LICENSE file in the root directory of this source tree.
|
|
165
173
|
*/
|
|
166
|
-
const
|
|
174
|
+
const Ge = q("Link", [
|
|
167
175
|
["path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71", key: "1cjeqo" }],
|
|
168
176
|
["path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71", key: "19qd67" }]
|
|
169
177
|
]);
|
|
@@ -173,7 +181,7 @@ const We = $("Link", [
|
|
|
173
181
|
* This source code is licensed under the ISC license.
|
|
174
182
|
* See the LICENSE file in the root directory of this source tree.
|
|
175
183
|
*/
|
|
176
|
-
const me =
|
|
184
|
+
const me = q("MessageCircle", [
|
|
177
185
|
["path", { d: "M7.9 20A9 9 0 1 0 4 16.1L2 22Z", key: "vv11sd" }]
|
|
178
186
|
]);
|
|
179
187
|
/**
|
|
@@ -182,7 +190,7 @@ const me = $("MessageCircle", [
|
|
|
182
190
|
* This source code is licensed under the ISC license.
|
|
183
191
|
* See the LICENSE file in the root directory of this source tree.
|
|
184
192
|
*/
|
|
185
|
-
const
|
|
193
|
+
const We = q("Pencil", [
|
|
186
194
|
["path", { d: "M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z", key: "5qss01" }],
|
|
187
195
|
["path", { d: "m15 5 4 4", key: "1mk7zo" }]
|
|
188
196
|
]);
|
|
@@ -192,7 +200,7 @@ const Ke = $("Pencil", [
|
|
|
192
200
|
* This source code is licensed under the ISC license.
|
|
193
201
|
* See the LICENSE file in the root directory of this source tree.
|
|
194
202
|
*/
|
|
195
|
-
const
|
|
203
|
+
const Ve = q("Phone", [
|
|
196
204
|
[
|
|
197
205
|
"path",
|
|
198
206
|
{
|
|
@@ -207,7 +215,7 @@ const Ue = $("Phone", [
|
|
|
207
215
|
* This source code is licensed under the ISC license.
|
|
208
216
|
* See the LICENSE file in the root directory of this source tree.
|
|
209
217
|
*/
|
|
210
|
-
const
|
|
218
|
+
const he = q("Plus", [
|
|
211
219
|
["path", { d: "M5 12h14", key: "1ays0h" }],
|
|
212
220
|
["path", { d: "M12 5v14", key: "s699le" }]
|
|
213
221
|
]);
|
|
@@ -217,7 +225,7 @@ const Ae = $("Plus", [
|
|
|
217
225
|
* This source code is licensed under the ISC license.
|
|
218
226
|
* See the LICENSE file in the root directory of this source tree.
|
|
219
227
|
*/
|
|
220
|
-
const
|
|
228
|
+
const Ke = q("Reply", [
|
|
221
229
|
["polyline", { points: "9 17 4 12 9 7", key: "hvgpf2" }],
|
|
222
230
|
["path", { d: "M20 18v-2a4 4 0 0 0-4-4H4", key: "5vmcpk" }]
|
|
223
231
|
]);
|
|
@@ -227,7 +235,7 @@ const Je = $("Reply", [
|
|
|
227
235
|
* This source code is licensed under the ISC license.
|
|
228
236
|
* See the LICENSE file in the root directory of this source tree.
|
|
229
237
|
*/
|
|
230
|
-
const
|
|
238
|
+
const ue = q("Smile", [
|
|
231
239
|
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
232
240
|
["path", { d: "M8 14s1.5 2 4 2 4-2 4-2", key: "1y1vjs" }],
|
|
233
241
|
["line", { x1: "9", x2: "9.01", y1: "9", y2: "9", key: "yxxnd0" }],
|
|
@@ -239,7 +247,7 @@ const he = $("Smile", [
|
|
|
239
247
|
* This source code is licensed under the ISC license.
|
|
240
248
|
* See the LICENSE file in the root directory of this source tree.
|
|
241
249
|
*/
|
|
242
|
-
const
|
|
250
|
+
const Je = q("Trash2", [
|
|
243
251
|
["path", { d: "M3 6h18", key: "d0wm0j" }],
|
|
244
252
|
["path", { d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6", key: "4alrt4" }],
|
|
245
253
|
["path", { d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2", key: "v07s0e" }],
|
|
@@ -252,7 +260,7 @@ const Xe = $("Trash2", [
|
|
|
252
260
|
* This source code is licensed under the ISC license.
|
|
253
261
|
* See the LICENSE file in the root directory of this source tree.
|
|
254
262
|
*/
|
|
255
|
-
const
|
|
263
|
+
const Xe = q("Upload", [
|
|
256
264
|
["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }],
|
|
257
265
|
["polyline", { points: "17 8 12 3 7 8", key: "t8dd8p" }],
|
|
258
266
|
["line", { x1: "12", x2: "12", y1: "3", y2: "15", key: "widbto" }]
|
|
@@ -263,7 +271,7 @@ const Ye = $("Upload", [
|
|
|
263
271
|
* This source code is licensed under the ISC license.
|
|
264
272
|
* See the LICENSE file in the root directory of this source tree.
|
|
265
273
|
*/
|
|
266
|
-
const
|
|
274
|
+
const Ye = q("Workflow", [
|
|
267
275
|
["rect", { width: "8", height: "8", x: "3", y: "3", rx: "2", key: "by2w9f" }],
|
|
268
276
|
["path", { d: "M7 11v4a2 2 0 0 0 2 2h4", key: "xkn7yn" }],
|
|
269
277
|
["rect", { width: "8", height: "8", x: "13", y: "13", rx: "2", key: "1cgmvn" }]
|
|
@@ -274,22 +282,22 @@ const Qe = $("Workflow", [
|
|
|
274
282
|
* This source code is licensed under the ISC license.
|
|
275
283
|
* See the LICENSE file in the root directory of this source tree.
|
|
276
284
|
*/
|
|
277
|
-
const re =
|
|
285
|
+
const re = q("X", [
|
|
278
286
|
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
279
287
|
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
280
288
|
]);
|
|
281
|
-
function te({ isOpen: a, onClose: s, title:
|
|
282
|
-
const
|
|
289
|
+
function te({ isOpen: a, onClose: s, title: n, children: i }) {
|
|
290
|
+
const c = Te(null);
|
|
283
291
|
return le(() => {
|
|
284
|
-
const
|
|
285
|
-
|
|
292
|
+
const o = (l) => {
|
|
293
|
+
c.current && !c.current.contains(l.target) && s();
|
|
286
294
|
};
|
|
287
|
-
return a && document.addEventListener("mousedown",
|
|
288
|
-
document.removeEventListener("mousedown",
|
|
295
|
+
return a && document.addEventListener("mousedown", o), () => {
|
|
296
|
+
document.removeEventListener("mousedown", o);
|
|
289
297
|
};
|
|
290
|
-
}, [a, s]), a ? /* @__PURE__ */ e("div", { className: "rsp-fixed rsp-inset-0 rsp-bg-black rsp-bg-opacity-50 rsp-flex rsp-items-center rsp-justify-center rsp-p-4 rsp-z-50", children: /* @__PURE__ */ r("div", { ref:
|
|
298
|
+
}, [a, s]), a ? /* @__PURE__ */ e("div", { className: "rsp-fixed rsp-inset-0 rsp-bg-black rsp-bg-opacity-50 rsp-flex rsp-items-center rsp-justify-center rsp-p-4 rsp-z-50", children: /* @__PURE__ */ r("div", { ref: c, className: "rsp-bg-white rsp-rounded-lg rsp-shadow-xl rsp-w-full rsp-max-w-[600px] rsp-animate-modal-appear", style: { backgroundColor: "#f5f7fc" }, children: [
|
|
291
299
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-justify-between rsp-px-6 rsp-py-4 rsp-border-b", children: [
|
|
292
|
-
/* @__PURE__ */ e("h2", { className: "rsp-text-lg rsp-font-semibold rsp-text-gray-900 rsp-text-center rsp-w-full rsp-break-words rsp-break-all rsp-whitespace-pre-wrap", children:
|
|
300
|
+
/* @__PURE__ */ e("h2", { className: "rsp-text-lg rsp-font-semibold rsp-text-gray-900 rsp-text-center rsp-w-full rsp-break-words rsp-break-all rsp-whitespace-pre-wrap", children: n }),
|
|
293
301
|
/* @__PURE__ */ e(
|
|
294
302
|
"button",
|
|
295
303
|
{
|
|
@@ -299,72 +307,82 @@ function te({ isOpen: a, onClose: s, title: i, children: n }) {
|
|
|
299
307
|
}
|
|
300
308
|
)
|
|
301
309
|
] }),
|
|
302
|
-
/* @__PURE__ */ e("div", { className: "rsp-px-6 rsp-py-4 rsp-overflow-y-auto rsp-max-h-[70vh] rsp-break-words rsp-whitespace-pre-wrap", children:
|
|
310
|
+
/* @__PURE__ */ e("div", { className: "rsp-px-6 rsp-py-4 rsp-overflow-y-auto rsp-max-h-[70vh] rsp-break-words rsp-whitespace-pre-wrap", children: i })
|
|
303
311
|
] }) }) : null;
|
|
304
312
|
}
|
|
305
|
-
function
|
|
306
|
-
const
|
|
307
|
-
const
|
|
308
|
-
return
|
|
313
|
+
function Ta({ onCreateTemplate: a, onEditTemplate: s }) {
|
|
314
|
+
const [n, i] = B([]), [c, o] = B(!0), [l, v] = B(null), [g, h] = B(null), [k, V] = B({ isOpen: !1 }), [d, N] = B(() => {
|
|
315
|
+
const u = localStorage.getItem("account");
|
|
316
|
+
return u ? JSON.parse(u) : {
|
|
309
317
|
apiKey: ""
|
|
310
318
|
};
|
|
311
|
-
}), [
|
|
319
|
+
}), [M, b] = B(""), [y, t] = B("all"), [x, p] = B("all"), [w] = B("all"), [A, R] = B(1), f = 20, [C, U] = B({ isOpen: !1 });
|
|
312
320
|
le(() => {
|
|
313
321
|
(async () => {
|
|
314
322
|
try {
|
|
315
|
-
if (
|
|
316
|
-
|
|
323
|
+
if (v(null), o(!0), i([]), !d.apiKey) {
|
|
324
|
+
v("Please enter your TrustSignal API key"), o(!1);
|
|
317
325
|
return;
|
|
318
326
|
}
|
|
319
|
-
const
|
|
327
|
+
const T = await Oe(d, {
|
|
320
328
|
limit: 1e3
|
|
321
329
|
});
|
|
322
|
-
if (
|
|
323
|
-
throw new Error(
|
|
324
|
-
i(
|
|
325
|
-
} catch (
|
|
326
|
-
|
|
330
|
+
if (T.status === "error")
|
|
331
|
+
throw new Error(T.message);
|
|
332
|
+
i(T.data);
|
|
333
|
+
} catch (T) {
|
|
334
|
+
v(T instanceof Error ? T.message : "Failed to fetch templates"), i([]);
|
|
327
335
|
} finally {
|
|
328
|
-
|
|
336
|
+
o(!1);
|
|
329
337
|
}
|
|
330
338
|
})();
|
|
331
|
-
}, [
|
|
332
|
-
const
|
|
333
|
-
const { name:
|
|
334
|
-
...
|
|
335
|
-
[
|
|
339
|
+
}, [d]);
|
|
340
|
+
const O = (u) => {
|
|
341
|
+
const { name: T, value: D } = u.target, K = {
|
|
342
|
+
...d,
|
|
343
|
+
[T]: D
|
|
336
344
|
};
|
|
337
|
-
|
|
338
|
-
},
|
|
339
|
-
|
|
345
|
+
N(K), localStorage.setItem("account", JSON.stringify(K));
|
|
346
|
+
}, P = (u, T) => {
|
|
347
|
+
U({
|
|
340
348
|
isOpen: !0,
|
|
341
|
-
url:
|
|
342
|
-
templateName:
|
|
349
|
+
url: u,
|
|
350
|
+
templateName: T
|
|
343
351
|
});
|
|
344
|
-
},
|
|
345
|
-
|
|
346
|
-
},
|
|
352
|
+
}, H = () => {
|
|
353
|
+
U({ isOpen: !1 });
|
|
354
|
+
}, m = async (u) => {
|
|
347
355
|
try {
|
|
348
|
-
const
|
|
349
|
-
if (!
|
|
350
|
-
|
|
356
|
+
const T = localStorage.getItem("account"), D = T ? JSON.parse(T) : { apiKey: "" };
|
|
357
|
+
if (!D.apiKey) {
|
|
358
|
+
v("Please enter your TrustSignal API key");
|
|
351
359
|
return;
|
|
352
360
|
}
|
|
353
|
-
|
|
354
|
-
const { deleteTemplateById:
|
|
355
|
-
if (!
|
|
356
|
-
i((
|
|
357
|
-
} catch (
|
|
358
|
-
|
|
361
|
+
h(u);
|
|
362
|
+
const { deleteTemplateById: K } = await import("./delete-BgBYMUw2.js"), L = await K(D.apiKey, u);
|
|
363
|
+
if (!L.success) throw new Error(L.message || "Delete failed");
|
|
364
|
+
i((Y) => Y.filter((_) => _.id !== u)), V({ isOpen: !1 });
|
|
365
|
+
} catch (T) {
|
|
366
|
+
v(T instanceof Error ? T.message : "Failed to delete template");
|
|
359
367
|
} finally {
|
|
360
|
-
|
|
368
|
+
h(null);
|
|
361
369
|
}
|
|
362
|
-
},
|
|
363
|
-
const
|
|
364
|
-
return
|
|
365
|
-
}),
|
|
366
|
-
return
|
|
367
|
-
/* @__PURE__ */
|
|
370
|
+
}, E = n.filter((u) => {
|
|
371
|
+
const T = M.trim(), D = T.toLowerCase(), K = T === "" || u.id.toString().includes(T) || u.name.toLowerCase().includes(D), L = y === "all" || u.status.toLowerCase() === y.toLowerCase(), Y = x === "all" || u.category.toLowerCase() === x.toLowerCase(), _ = w === "all" || u.language.toLowerCase().startsWith(w.toLowerCase());
|
|
372
|
+
return K && L && Y && _;
|
|
373
|
+
}), S = Math.ceil(E.length / f), j = (A - 1) * f, I = j + f, z = E.slice(j, I);
|
|
374
|
+
return c ? /* @__PURE__ */ e("div", { className: "rsp-flex rsp-items-center rsp-justify-center rsp-min-h-screen", children: /* @__PURE__ */ e("div", { className: "rsp-text-lg rsp-text-gray-600", children: "Loading templates..." }) }) : /* @__PURE__ */ r("div", { className: "rsp-container rsp-mx-auto rsp-px-4 rsp-py-8 rsp-bg-[#f5f7fc] rsp-rounded-lg rsp-shadow-sm", children: [
|
|
375
|
+
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-justify-between rsp-items-center rsp-mb-6", children: [
|
|
376
|
+
/* @__PURE__ */ e("h1", { className: "rsp-text-2xl rsp-font-bold", children: "Whatsapp HSM Templates" }),
|
|
377
|
+
/* @__PURE__ */ e(
|
|
378
|
+
"button",
|
|
379
|
+
{
|
|
380
|
+
onClick: () => a == null ? void 0 : a(),
|
|
381
|
+
className: "rsp-bg-blue-600 rsp-text-white rsp-p-1 rsp-rounded-full hover:rsp-bg-blue-700 rsp-flex rsp-items-center rsp-gap-2",
|
|
382
|
+
children: /* @__PURE__ */ e(he, { className: "rsp-w-6 rsp-h-6" })
|
|
383
|
+
}
|
|
384
|
+
)
|
|
385
|
+
] }),
|
|
368
386
|
/* @__PURE__ */ e("div", { className: " rsp-p-4 rsp-pl-0 rsp-rounded-lg rsp-shadow-sm rsp-mb-6", children: /* @__PURE__ */ r("div", { children: [
|
|
369
387
|
/* @__PURE__ */ e("label", { className: "rsp-block rsp-text-sm rsp-font-medium rsp-text-gray-700 rsp-mb-1", children: "TrustSignal API Key" }),
|
|
370
388
|
/* @__PURE__ */ r("div", { className: "rsp-relative", children: [
|
|
@@ -373,8 +391,8 @@ function Va() {
|
|
|
373
391
|
{
|
|
374
392
|
type: "password",
|
|
375
393
|
name: "apiKey",
|
|
376
|
-
value:
|
|
377
|
-
onChange:
|
|
394
|
+
value: d.apiKey,
|
|
395
|
+
onChange: O,
|
|
378
396
|
className: "rsp-w-full rsp-px-0 rsp-py-2 rsp-border-0 rsp-border-b rsp-border-gray-300 rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-transparent",
|
|
379
397
|
placeholder: "Enter your TrustSignal API key"
|
|
380
398
|
}
|
|
@@ -382,17 +400,17 @@ function Va() {
|
|
|
382
400
|
/* @__PURE__ */ e("div", { className: "rsp-absolute rsp-bottom-0 rsp-left-0 rsp-w-4 rsp-h-0.5 rsp-bg-red-500" })
|
|
383
401
|
] })
|
|
384
402
|
] }) }),
|
|
385
|
-
|
|
403
|
+
l && /* @__PURE__ */ e("div", { className: "rsp-bg-red-50 rsp-border-l-4 rsp-border-red-500 rsp-p-4 rsp-mb-6", children: /* @__PURE__ */ r("div", { className: "rsp-flex", children: [
|
|
386
404
|
/* @__PURE__ */ e("div", { className: "rsp-flex-shrink-0", children: /* @__PURE__ */ e(fe, { className: "rsp-h-5 rsp-w-5 rsp-text-red-400" }) }),
|
|
387
|
-
/* @__PURE__ */ e("div", { className: "rsp-ml-3", children: /* @__PURE__ */ e("p", { className: "rsp-text-sm rsp-text-red-700", children:
|
|
405
|
+
/* @__PURE__ */ e("div", { className: "rsp-ml-3", children: /* @__PURE__ */ e("p", { className: "rsp-text-sm rsp-text-red-700", children: l }) })
|
|
388
406
|
] }) }),
|
|
389
407
|
/* @__PURE__ */ e("div", { className: "rsp-mb-6", children: /* @__PURE__ */ e("div", { className: "rsp-relative", children: /* @__PURE__ */ e(
|
|
390
408
|
"input",
|
|
391
409
|
{
|
|
392
410
|
type: "text",
|
|
393
411
|
placeholder: "Search by name or ID...",
|
|
394
|
-
value:
|
|
395
|
-
onChange: (
|
|
412
|
+
value: M,
|
|
413
|
+
onChange: (u) => b(u.target.value),
|
|
396
414
|
className: "rsp-w-full rsp-px-0 rsp-py-3 rsp-border-0 rsp-border-b rsp-border-gray-300 rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-transparent"
|
|
397
415
|
}
|
|
398
416
|
) }) }),
|
|
@@ -405,10 +423,10 @@ function Va() {
|
|
|
405
423
|
/* @__PURE__ */ e("div", { className: "rsp-flex rsp-items-center", children: /* @__PURE__ */ r(
|
|
406
424
|
"select",
|
|
407
425
|
{
|
|
408
|
-
value:
|
|
409
|
-
onChange: (
|
|
426
|
+
value: x,
|
|
427
|
+
onChange: (u) => p(u.target.value),
|
|
410
428
|
className: "rsp-cursor-pointer rsp-ml-2 rsp-bg-transparent rsp-text-white rsp-border-0 rsp-text-sm focus:rsp-outline-none ",
|
|
411
|
-
onClick: (
|
|
429
|
+
onClick: (u) => u.stopPropagation(),
|
|
412
430
|
children: [
|
|
413
431
|
/* @__PURE__ */ e("option", { value: "all", className: "rsp-text-gray-900", children: "All" }),
|
|
414
432
|
/* @__PURE__ */ e("option", { value: "utility", className: "rsp-text-gray-900", children: "Utility" }),
|
|
@@ -424,10 +442,10 @@ function Va() {
|
|
|
424
442
|
/* @__PURE__ */ e("div", { className: "rsp-flex rsp-items-center", children: /* @__PURE__ */ r(
|
|
425
443
|
"select",
|
|
426
444
|
{
|
|
427
|
-
value:
|
|
428
|
-
onChange: (
|
|
445
|
+
value: y,
|
|
446
|
+
onChange: (u) => t(u.target.value),
|
|
429
447
|
className: "rsp-cursor-pointer rsp-ml-2 rsp-bg-transparent rsp-text-white rsp-border-0 rsp-text-sm focus:rsp-outline-none",
|
|
430
|
-
onClick: (
|
|
448
|
+
onClick: (u) => u.stopPropagation(),
|
|
431
449
|
children: [
|
|
432
450
|
/* @__PURE__ */ e("option", { value: "all", className: "rsp-text-gray-900", children: "All" }),
|
|
433
451
|
/* @__PURE__ */ e("option", { value: "pending", className: "rsp-text-gray-900", children: "Pending" }),
|
|
@@ -442,24 +460,24 @@ function Va() {
|
|
|
442
460
|
/* @__PURE__ */ e("th", { className: "rsp-px-6 rsp-py-3 rsp-text-left rsp-text-sm rsp-font-medium", children: "Media" }),
|
|
443
461
|
/* @__PURE__ */ e("th", { className: "rsp-px-6 rsp-py-3 rsp-text-left rsp-text-sm rsp-font-medium", children: "Actions" })
|
|
444
462
|
] }) }),
|
|
445
|
-
/* @__PURE__ */ e("tbody", { children:
|
|
463
|
+
/* @__PURE__ */ e("tbody", { children: z.length > 0 ? z.map((u, T) => /* @__PURE__ */ r(
|
|
446
464
|
"tr",
|
|
447
465
|
{
|
|
448
|
-
className: `rsp-border-b rsp-border-gray-200 ${
|
|
466
|
+
className: `rsp-border-b rsp-border-gray-200 ${T % 2 === 0 ? "rsp-bg-white" : "rsp-bg-blue-50"} hover:rsp-bg-blue-100 rsp-transition-colors`,
|
|
449
467
|
children: [
|
|
450
|
-
/* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-900", children:
|
|
451
|
-
/* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-900 rsp-font-medium", children:
|
|
452
|
-
/* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-700 rsp-capitalize", children:
|
|
453
|
-
/* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-700", children:
|
|
454
|
-
/* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-700", children:
|
|
468
|
+
/* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-900", children: u.id }),
|
|
469
|
+
/* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-900 rsp-font-medium", children: u.name }),
|
|
470
|
+
/* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-700 rsp-capitalize", children: u.category }),
|
|
471
|
+
/* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-700", children: u.language }),
|
|
472
|
+
/* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-700", children: u.type }),
|
|
455
473
|
/* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4", children: /* @__PURE__ */ e("span", { className: `rsp-inline-flex rsp-px-3 rsp-py-1 rsp-rounded-full rsp-text-xs rsp-font-medium
|
|
456
|
-
${
|
|
457
|
-
/* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-700", children:
|
|
458
|
-
/* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-700", children:
|
|
459
|
-
/* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-700", children:
|
|
474
|
+
${u.status.toLowerCase() === "approved" ? "rsp-bg-green-100 rsp-text-green-800" : u.status.toLowerCase() === "rejected" ? "rsp-bg-red-100 rsp-text-red-800" : "rsp-bg-yellow-100 rsp-text-yellow-800"}`, children: u.status }) }),
|
|
475
|
+
/* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-700", children: u.creation_time ? new Date(u.creation_time).toLocaleDateString() : "N/A" }),
|
|
476
|
+
/* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-700", children: u.updation_time ? new Date(u.updation_time).toLocaleDateString() : "N/A" }),
|
|
477
|
+
/* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-700", children: u.medialist && typeof u.medialist == "object" && "header" in u.medialist && u.medialist.header ? /* @__PURE__ */ r(
|
|
460
478
|
"button",
|
|
461
479
|
{
|
|
462
|
-
onClick: () =>
|
|
480
|
+
onClick: () => P(String(u.medialist.header || ""), u.name),
|
|
463
481
|
className: "rsp-inline-flex rsp-items-center rsp-px-3 rsp-py-1 rsp-rounded rsp-text-xs rsp-font-medium rsp-bg-blue-100 rsp-text-blue-800 hover:rsp-bg-blue-200 rsp-transition-colors",
|
|
464
482
|
children: [
|
|
465
483
|
/* @__PURE__ */ r("svg", { className: "rsp-w-3 rsp-h-3 rsp-mr-1", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: [
|
|
@@ -474,59 +492,59 @@ function Va() {
|
|
|
474
492
|
/* @__PURE__ */ e(
|
|
475
493
|
"button",
|
|
476
494
|
{
|
|
477
|
-
onClick: () =>
|
|
495
|
+
onClick: () => s == null ? void 0 : s(String(u.id)),
|
|
478
496
|
className: "rsp-inline-flex rsp-items-center rsp-justify-center rsp-w-8 rsp-h-8 rsp-rounded rsp-bg-blue-600 rsp-text-white hover:rsp-bg-blue-700 rsp-transition-colors",
|
|
479
497
|
title: "Update",
|
|
480
|
-
children: /* @__PURE__ */ e(
|
|
498
|
+
children: /* @__PURE__ */ e(We, { className: "rsp-w-4 rsp-h-4" })
|
|
481
499
|
}
|
|
482
500
|
),
|
|
483
501
|
/* @__PURE__ */ e(
|
|
484
502
|
"button",
|
|
485
503
|
{
|
|
486
|
-
onClick: () =>
|
|
487
|
-
disabled:
|
|
488
|
-
className: `rsp-inline-flex rsp-items-center rsp-justify-center rsp-w-8 rsp-h-8 rsp-rounded rsp-text-white rsp-transition-colors ${
|
|
489
|
-
title:
|
|
490
|
-
children: /* @__PURE__ */ e(
|
|
504
|
+
onClick: () => V({ isOpen: !0, templateId: String(u.id), templateName: u.name }),
|
|
505
|
+
disabled: g === u.id,
|
|
506
|
+
className: `rsp-inline-flex rsp-items-center rsp-justify-center rsp-w-8 rsp-h-8 rsp-rounded rsp-text-white rsp-transition-colors ${g === u.id ? "rsp-bg-red-400" : "rsp-bg-red-600 hover:rsp-bg-red-700"}`,
|
|
507
|
+
title: g === u.id ? "Deleting..." : "Delete",
|
|
508
|
+
children: /* @__PURE__ */ e(Je, { className: "rsp-w-4 rsp-h-4" })
|
|
491
509
|
}
|
|
492
510
|
)
|
|
493
511
|
] }) })
|
|
494
512
|
]
|
|
495
513
|
},
|
|
496
|
-
|
|
514
|
+
u.id
|
|
497
515
|
)) : /* @__PURE__ */ e("tr", { children: /* @__PURE__ */ e("td", { colSpan: 9, className: "rsp-px-6 rsp-py-8 rsp-text-center rsp-text-gray-500", children: "No templates found" }) }) })
|
|
498
516
|
] }) }) }),
|
|
499
|
-
|
|
517
|
+
z.length > 0 && /* @__PURE__ */ r("div", { className: "rsp-flex rsp-justify-between rsp-items-center rsp-mt-6 rsp-px-6 rsp-py-4 rsp-bg-white rsp-rounded-lg rsp-shadow-sm rsp-border rsp-border-gray-200", children: [
|
|
500
518
|
/* @__PURE__ */ r("div", { className: "rsp-text-sm rsp-text-gray-700", children: [
|
|
501
519
|
"Showing ",
|
|
502
|
-
/* @__PURE__ */ e("span", { className: "rsp-font-medium", children:
|
|
520
|
+
/* @__PURE__ */ e("span", { className: "rsp-font-medium", children: j + 1 }),
|
|
503
521
|
" to ",
|
|
504
|
-
/* @__PURE__ */ e("span", { className: "rsp-font-medium", children: Math.min(
|
|
522
|
+
/* @__PURE__ */ e("span", { className: "rsp-font-medium", children: Math.min(I, E.length) }),
|
|
505
523
|
" of ",
|
|
506
|
-
/* @__PURE__ */ e("span", { className: "rsp-font-medium", children:
|
|
524
|
+
/* @__PURE__ */ e("span", { className: "rsp-font-medium", children: E.length }),
|
|
507
525
|
" results"
|
|
508
526
|
] }),
|
|
509
527
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-gap-2", children: [
|
|
510
528
|
/* @__PURE__ */ e(
|
|
511
529
|
"button",
|
|
512
530
|
{
|
|
513
|
-
onClick: () =>
|
|
514
|
-
disabled:
|
|
531
|
+
onClick: () => R((u) => Math.max(u - 1, 1)),
|
|
532
|
+
disabled: A === 1,
|
|
515
533
|
className: "rsp-px-4 rsp-py-2 rsp-text-sm rsp-font-medium rsp-text-gray-700 rsp-bg-white rsp-border rsp-border-gray-300 rsp-rounded-md hover:rsp-bg-gray-50 disabled:rsp-opacity-50 disabled:rsp-cursor-not-allowed rsp-transition-colors",
|
|
516
534
|
children: "Previous"
|
|
517
535
|
}
|
|
518
536
|
),
|
|
519
537
|
/* @__PURE__ */ r("span", { className: "rsp-px-4 rsp-py-2 rsp-text-sm rsp-font-medium rsp-text-gray-700", children: [
|
|
520
538
|
"Page ",
|
|
521
|
-
|
|
539
|
+
A,
|
|
522
540
|
" of ",
|
|
523
|
-
|
|
541
|
+
S
|
|
524
542
|
] }),
|
|
525
543
|
/* @__PURE__ */ e(
|
|
526
544
|
"button",
|
|
527
545
|
{
|
|
528
|
-
onClick: () =>
|
|
529
|
-
disabled:
|
|
546
|
+
onClick: () => R((u) => Math.min(u + 1, S)),
|
|
547
|
+
disabled: A === S,
|
|
530
548
|
className: "rsp-px-4 rsp-py-2 rsp-text-sm rsp-font-medium rsp-text-gray-700 rsp-bg-white rsp-border rsp-border-gray-300 rsp-rounded-md hover:rsp-bg-gray-50 disabled:rsp-opacity-50 disabled:rsp-cursor-not-allowed rsp-transition-colors",
|
|
531
549
|
children: "Next"
|
|
532
550
|
}
|
|
@@ -536,30 +554,30 @@ function Va() {
|
|
|
536
554
|
/* @__PURE__ */ e(
|
|
537
555
|
te,
|
|
538
556
|
{
|
|
539
|
-
isOpen:
|
|
540
|
-
onClose:
|
|
541
|
-
title: `Media - ${
|
|
557
|
+
isOpen: C.isOpen,
|
|
558
|
+
onClose: H,
|
|
559
|
+
title: `Media - ${C.templateName || "Template"}`,
|
|
542
560
|
children: /* @__PURE__ */ r("div", { className: "rsp-space-y-4", children: [
|
|
543
|
-
|
|
561
|
+
C.url && /* @__PURE__ */ r("div", { className: "rsp-text-center", children: [
|
|
544
562
|
/* @__PURE__ */ r("div", { className: "rsp-relative rsp-bg-gray-50 rsp-rounded-lg rsp-p-4 rsp-min-h-[200px] rsp-flex rsp-items-center rsp-justify-center", children: [
|
|
545
563
|
/* @__PURE__ */ e(
|
|
546
564
|
"img",
|
|
547
565
|
{
|
|
548
|
-
src:
|
|
566
|
+
src: C.url,
|
|
549
567
|
alt: "Template media",
|
|
550
568
|
className: "rsp-max-w-full rsp-max-h-[400px] rsp-mx-auto rsp-rounded-lg rsp-shadow-md rsp-object-contain",
|
|
551
|
-
onLoad: (
|
|
552
|
-
const
|
|
553
|
-
|
|
569
|
+
onLoad: (u) => {
|
|
570
|
+
const T = u.currentTarget.parentElement, D = T == null ? void 0 : T.querySelector(".loading-placeholder");
|
|
571
|
+
D && (D.style.display = "none");
|
|
554
572
|
},
|
|
555
|
-
onError: (
|
|
556
|
-
|
|
557
|
-
const
|
|
558
|
-
|
|
573
|
+
onError: (u) => {
|
|
574
|
+
u.currentTarget.style.display = "none";
|
|
575
|
+
const T = u.currentTarget.parentElement, D = T == null ? void 0 : T.querySelector(".error-placeholder");
|
|
576
|
+
D && (D.style.display = "block");
|
|
559
577
|
}
|
|
560
578
|
}
|
|
561
579
|
),
|
|
562
|
-
|
|
580
|
+
c && /* @__PURE__ */ e("div", { className: "loading-placeholder rsp-absolute rsp-inset-0 rsp-flex rsp-items-center rsp-justify-center", children: /* @__PURE__ */ e("div", { className: "rsp-text-gray-500 rsp-text-sm", children: "Loading media..." }) }),
|
|
563
581
|
/* @__PURE__ */ r("div", { className: "error-placeholder rsp-absolute rsp-inset-0 rsp-flex rsp-flex-col rsp-items-center rsp-justify-center", style: { display: "none" }, children: [
|
|
564
582
|
/* @__PURE__ */ e("svg", { className: "rsp-w-[100%] rsp-h-12 rsp-text-gray-400 rsp-m-2", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" }) }),
|
|
565
583
|
/* @__PURE__ */ e("p", { className: "rsp-text-gray-500 rsp-text-sm rsp-mb-2", children: "Load media on new tab" })
|
|
@@ -567,13 +585,13 @@ function Va() {
|
|
|
567
585
|
] }),
|
|
568
586
|
/* @__PURE__ */ r("div", { className: "rsp-mt-4 rsp-p-3 rsp-bg-gray-50 rsp-rounded-lg", children: [
|
|
569
587
|
/* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-600 rsp-mb-1", children: "Media URL:" }),
|
|
570
|
-
/* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-800 rsp-break-all rsp-font-mono", children:
|
|
588
|
+
/* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-800 rsp-break-all rsp-font-mono", children: C.url })
|
|
571
589
|
] })
|
|
572
590
|
] }),
|
|
573
591
|
/* @__PURE__ */ e("div", { className: "rsp-flex rsp-justify-end rsp-pt-4", children: /* @__PURE__ */ r(
|
|
574
592
|
"a",
|
|
575
593
|
{
|
|
576
|
-
href:
|
|
594
|
+
href: C.url,
|
|
577
595
|
target: "_blank",
|
|
578
596
|
rel: "noopener noreferrer",
|
|
579
597
|
className: "rsp-inline-flex rsp-items-center rsp-px-4 rsp-py-2 rsp-bg-blue-600 rsp-text-white rsp-text-sm rsp-font-medium rsp-rounded-md hover:rsp-bg-blue-700 rsp-transition-colors",
|
|
@@ -589,21 +607,21 @@ function Va() {
|
|
|
589
607
|
/* @__PURE__ */ e(
|
|
590
608
|
te,
|
|
591
609
|
{
|
|
592
|
-
isOpen:
|
|
593
|
-
onClose: () =>
|
|
610
|
+
isOpen: k.isOpen,
|
|
611
|
+
onClose: () => V({ isOpen: !1 }),
|
|
594
612
|
title: "Delete Template",
|
|
595
613
|
children: /* @__PURE__ */ r("div", { className: "rsp-space-y-4", children: [
|
|
596
614
|
/* @__PURE__ */ r("p", { className: "rsp-text-sm rsp-text-gray-700", children: [
|
|
597
615
|
"Are you sure you want to delete the template ",
|
|
598
|
-
/* @__PURE__ */ e("span", { className: "rsp-font-medium", children:
|
|
616
|
+
/* @__PURE__ */ e("span", { className: "rsp-font-medium", children: k.templateName }),
|
|
599
617
|
"?"
|
|
600
618
|
] }),
|
|
601
619
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-justify-end rsp-gap-3", children: [
|
|
602
|
-
/* @__PURE__ */ e("button", { onClick: () =>
|
|
620
|
+
/* @__PURE__ */ e("button", { onClick: () => V({ isOpen: !1 }), className: "rsp-px-4 rsp-py-2 rsp-text-sm rsp-font-medium rsp-text-gray-700 rsp-bg-white rsp-border rsp-border-gray-300 rsp-rounded-md hover:rsp-bg-gray-50", children: "Cancel" }),
|
|
603
621
|
/* @__PURE__ */ e(
|
|
604
622
|
"button",
|
|
605
623
|
{
|
|
606
|
-
onClick: () =>
|
|
624
|
+
onClick: () => k.templateId && m(k.templateId),
|
|
607
625
|
className: "rsp-px-4 rsp-py-2 rsp-text-sm rsp-font-medium rsp-text-white rsp-bg-red-600 rsp-rounded-md hover:rsp-bg-red-700",
|
|
608
626
|
children: "Delete"
|
|
609
627
|
}
|
|
@@ -614,370 +632,370 @@ function Va() {
|
|
|
614
632
|
)
|
|
615
633
|
] });
|
|
616
634
|
}
|
|
617
|
-
const
|
|
618
|
-
var
|
|
635
|
+
const Qe = async (a, s) => {
|
|
636
|
+
var n, i, c, o, l, v, g;
|
|
619
637
|
try {
|
|
620
638
|
console.log("Creating template with data:", s);
|
|
621
|
-
const
|
|
622
|
-
let
|
|
623
|
-
|
|
624
|
-
const
|
|
639
|
+
const h = s.language, k = s.headerType === "MEDIA" && s.mediaType === "DOCUMENT", V = s.type === "CAROUSEL";
|
|
640
|
+
let d = "";
|
|
641
|
+
k ? d = Ue(s, h) : V ? d = Ae(s, h) : d = je(s, h), console.log("Raw JSON string being sent:", d);
|
|
642
|
+
const N = {
|
|
625
643
|
method: "POST",
|
|
626
644
|
headers: {
|
|
627
645
|
"Content-Type": "application/json"
|
|
628
646
|
},
|
|
629
|
-
body:
|
|
647
|
+
body: d,
|
|
630
648
|
redirect: "follow"
|
|
631
649
|
};
|
|
632
650
|
console.log(
|
|
633
651
|
"Making request to:",
|
|
634
652
|
`https://wpapi.trustsignal.io/api/v1/template?api_key=${a}`
|
|
635
|
-
), console.log("Request options:",
|
|
653
|
+
), console.log("Request options:", N);
|
|
636
654
|
const M = await fetch(
|
|
637
655
|
`https://wpapi.trustsignal.io/api/v1/template?api_key=${a}`,
|
|
638
|
-
|
|
656
|
+
N
|
|
639
657
|
);
|
|
640
658
|
console.log("Response status:", M.status), console.log(
|
|
641
659
|
"Response headers:",
|
|
642
660
|
Object.fromEntries(M.headers.entries())
|
|
643
661
|
);
|
|
644
|
-
const
|
|
645
|
-
console.log("Raw response:",
|
|
646
|
-
const
|
|
647
|
-
if (console.log("Parsed response:",
|
|
648
|
-
throw new Error(
|
|
662
|
+
const b = await M.text();
|
|
663
|
+
console.log("Raw response:", b);
|
|
664
|
+
const y = JSON.parse(b);
|
|
665
|
+
if (console.log("Parsed response:", y), !y.success)
|
|
666
|
+
throw new Error(y.message || "Template creation failed");
|
|
649
667
|
return {
|
|
650
668
|
status: "success",
|
|
651
669
|
message: "Template created successfully",
|
|
652
670
|
data: {
|
|
653
|
-
template:
|
|
671
|
+
template: y.template,
|
|
654
672
|
details: [
|
|
655
673
|
{
|
|
656
|
-
template_name: ((
|
|
657
|
-
template_id: ((
|
|
658
|
-
meta_tid: (
|
|
659
|
-
status: (
|
|
660
|
-
quality: (l =
|
|
661
|
-
temp_route: (
|
|
662
|
-
temptype: (
|
|
674
|
+
template_name: ((n = y.template) == null ? void 0 : n.name) || s.name,
|
|
675
|
+
template_id: ((i = y.template) == null ? void 0 : i.id) || "unknown",
|
|
676
|
+
meta_tid: (c = y.template) == null ? void 0 : c.meta_tid,
|
|
677
|
+
status: (o = y.template) == null ? void 0 : o.status,
|
|
678
|
+
quality: (l = y.template) == null ? void 0 : l.quality,
|
|
679
|
+
temp_route: (v = y.template) == null ? void 0 : v.temp_route,
|
|
680
|
+
temptype: (g = y.template) == null ? void 0 : g.temptype
|
|
663
681
|
}
|
|
664
682
|
]
|
|
665
683
|
}
|
|
666
684
|
};
|
|
667
|
-
} catch (
|
|
668
|
-
return console.error("TrustSignal API Error:",
|
|
685
|
+
} catch (h) {
|
|
686
|
+
return console.error("TrustSignal API Error:", h), {
|
|
669
687
|
status: "error",
|
|
670
|
-
message:
|
|
688
|
+
message: h instanceof Error ? h.message : "Failed to create template"
|
|
671
689
|
};
|
|
672
690
|
}
|
|
673
691
|
};
|
|
674
|
-
function
|
|
675
|
-
const s = a.language,
|
|
676
|
-
return
|
|
692
|
+
function Ze(a) {
|
|
693
|
+
const s = a.language, n = a.headerType === "MEDIA" && a.mediaType === "DOCUMENT", i = a.type === "CAROUSEL";
|
|
694
|
+
return n ? Ue(a, s) : i ? Ae(a, s) : je(a, s);
|
|
677
695
|
}
|
|
678
|
-
const
|
|
679
|
-
var
|
|
680
|
-
const
|
|
696
|
+
const Ue = (a, s) => {
|
|
697
|
+
var o, l;
|
|
698
|
+
const n = {
|
|
681
699
|
name: a.name,
|
|
682
700
|
lang: s,
|
|
683
701
|
category: a.category,
|
|
684
702
|
components: []
|
|
685
703
|
// Components should be an array
|
|
686
704
|
};
|
|
687
|
-
a.headerType === "MEDIA" && a.mediaUrl && (
|
|
705
|
+
a.headerType === "MEDIA" && a.mediaUrl && (n.media = {
|
|
688
706
|
header: a.mediaUrl
|
|
689
|
-
},
|
|
707
|
+
}, n.components.push({
|
|
690
708
|
type: "HEADER",
|
|
691
709
|
format: "DOCUMENT"
|
|
692
710
|
}));
|
|
693
|
-
const
|
|
711
|
+
const i = ee(a.body), c = {
|
|
694
712
|
type: "BODY",
|
|
695
713
|
text: a.body
|
|
696
714
|
};
|
|
697
|
-
if (
|
|
698
|
-
const
|
|
699
|
-
|
|
700
|
-
body_text: [
|
|
715
|
+
if (i.length > 0 && ((o = a.sampleContent) != null && o.bodyVariables)) {
|
|
716
|
+
const v = ge(a, i);
|
|
717
|
+
c.example = {
|
|
718
|
+
body_text: [v]
|
|
701
719
|
// This creates the required nested array
|
|
702
720
|
};
|
|
703
721
|
}
|
|
704
|
-
if (
|
|
722
|
+
if (n.components.push(c), (l = a.footer) != null && l.trim() && n.components.push({
|
|
705
723
|
type: "FOOTER",
|
|
706
724
|
text: a.footer
|
|
707
725
|
}), a.buttons && a.buttons.length > 0) {
|
|
708
|
-
const
|
|
709
|
-
var
|
|
710
|
-
const
|
|
711
|
-
type:
|
|
712
|
-
text:
|
|
726
|
+
const v = a.buttons.map((g) => {
|
|
727
|
+
var k;
|
|
728
|
+
const h = {
|
|
729
|
+
type: g.type === "CALL" ? "PHONE_NUMBER" : g.type,
|
|
730
|
+
text: g.text
|
|
713
731
|
};
|
|
714
|
-
if (
|
|
715
|
-
const
|
|
716
|
-
if (
|
|
717
|
-
const
|
|
718
|
-
({ number:
|
|
719
|
-
var M,
|
|
720
|
-
return ((
|
|
732
|
+
if (g.type === "URL" && g.value && (h.url = g.value, g.urlType === "dynamic" && g.value.includes("{{"))) {
|
|
733
|
+
const V = ee(g.value);
|
|
734
|
+
if (V.length > 0 && ((k = a.sampleContent) != null && k.buttonVariables)) {
|
|
735
|
+
const d = V.map(
|
|
736
|
+
({ number: N }) => {
|
|
737
|
+
var M, b;
|
|
738
|
+
return ((b = (M = a.sampleContent) == null ? void 0 : M.buttonVariables) == null ? void 0 : b[N]) || `sample${N}`;
|
|
721
739
|
}
|
|
722
740
|
);
|
|
723
|
-
|
|
741
|
+
h.example = d;
|
|
724
742
|
}
|
|
725
743
|
}
|
|
726
|
-
return (
|
|
744
|
+
return (g.type === "CALL" || g.type === "PHONE_NUMBER") && g.value && (h.phone_number = be(g.value)), h;
|
|
727
745
|
});
|
|
728
|
-
|
|
746
|
+
n.components.push({
|
|
729
747
|
type: "BUTTONS",
|
|
730
|
-
buttons:
|
|
748
|
+
buttons: v
|
|
731
749
|
});
|
|
732
750
|
}
|
|
733
|
-
return JSON.stringify(
|
|
734
|
-
},
|
|
735
|
-
var l,
|
|
736
|
-
const
|
|
751
|
+
return JSON.stringify(n);
|
|
752
|
+
}, Ae = (a, s) => {
|
|
753
|
+
var l, v, g;
|
|
754
|
+
const n = {
|
|
737
755
|
name: a.name,
|
|
738
756
|
lang: s,
|
|
739
757
|
category: a.category,
|
|
740
758
|
shortlink: a.enableClickTracking ? "1" : "0",
|
|
741
759
|
components: []
|
|
742
760
|
};
|
|
743
|
-
(l = a.carousel) != null && l.cards.length && (
|
|
744
|
-
|
|
761
|
+
(l = a.carousel) != null && l.cards.length && (n.media = {}, a.carousel.cards.forEach((h, k) => {
|
|
762
|
+
h.mediaUrl && (n.media[`card${k}header`] = h.mediaUrl);
|
|
745
763
|
}));
|
|
746
|
-
const
|
|
764
|
+
const i = [], c = ee(a.body), o = {
|
|
747
765
|
type: "BODY",
|
|
748
766
|
text: a.body,
|
|
749
|
-
...
|
|
767
|
+
...c.length > 0 && ((v = a.sampleContent) == null ? void 0 : v.bodyVariables) && {
|
|
750
768
|
example: {
|
|
751
|
-
body_text: [
|
|
769
|
+
body_text: [ge(a, c)]
|
|
752
770
|
}
|
|
753
771
|
}
|
|
754
772
|
};
|
|
755
|
-
if (
|
|
756
|
-
const
|
|
773
|
+
if (i.push(o), (g = a.carousel) != null && g.cards.length) {
|
|
774
|
+
const h = {
|
|
757
775
|
type: "CAROUSEL",
|
|
758
|
-
cards: a.carousel.cards.map((
|
|
759
|
-
var
|
|
776
|
+
cards: a.carousel.cards.map((k) => {
|
|
777
|
+
var V;
|
|
760
778
|
return {
|
|
761
779
|
components: [
|
|
762
780
|
{
|
|
763
781
|
type: "HEADER",
|
|
764
|
-
format: ((
|
|
782
|
+
format: ((V = a.carousel) == null ? void 0 : V.type) || "IMAGE"
|
|
765
783
|
},
|
|
766
784
|
{
|
|
767
785
|
type: "BODY",
|
|
768
|
-
text:
|
|
769
|
-
...ee(
|
|
786
|
+
text: k.body,
|
|
787
|
+
...ee(k.body).length > 0 && {
|
|
770
788
|
example: {
|
|
771
|
-
body_text: [
|
|
789
|
+
body_text: [ea(k)]
|
|
772
790
|
}
|
|
773
791
|
}
|
|
774
792
|
},
|
|
775
|
-
...
|
|
793
|
+
...k.buttons.length > 0 ? [{
|
|
776
794
|
type: "BUTTONS",
|
|
777
|
-
buttons:
|
|
795
|
+
buttons: k.buttons.map((d) => {
|
|
778
796
|
var M;
|
|
779
|
-
const
|
|
780
|
-
type:
|
|
781
|
-
text:
|
|
797
|
+
const N = {
|
|
798
|
+
type: d.type === "CALL" ? "PHONE_NUMBER" : d.type,
|
|
799
|
+
text: d.text
|
|
782
800
|
};
|
|
783
|
-
if (
|
|
784
|
-
const
|
|
785
|
-
if (
|
|
786
|
-
const
|
|
787
|
-
|
|
801
|
+
if (d.type === "URL" && d.value && (N.url = d.value, d.urlType === "dynamic" && d.value.includes("{{"))) {
|
|
802
|
+
const b = ee(d.value);
|
|
803
|
+
if (b.length > 0) {
|
|
804
|
+
const y = ((M = k == null ? void 0 : k.sampleContent) == null ? void 0 : M.buttonVariables) || {}, t = b.map(({ number: x }) => y[x] || `sample${x}`);
|
|
805
|
+
N.example = t;
|
|
788
806
|
}
|
|
789
807
|
}
|
|
790
|
-
return (
|
|
808
|
+
return (d.type === "CALL" || d.type === "PHONE_NUMBER") && d.value && (N.phone_number = be(d.value)), console.log("Carousel card button data:", N), N;
|
|
791
809
|
})
|
|
792
810
|
}] : []
|
|
793
811
|
]
|
|
794
812
|
};
|
|
795
813
|
})
|
|
796
814
|
};
|
|
797
|
-
|
|
815
|
+
i.push(h);
|
|
798
816
|
}
|
|
799
|
-
return
|
|
800
|
-
},
|
|
801
|
-
var
|
|
802
|
-
const s = ee(a.body || ""),
|
|
803
|
-
return s.map(({ number:
|
|
804
|
-
},
|
|
805
|
-
var l,
|
|
806
|
-
const
|
|
817
|
+
return n.components = i, JSON.stringify(n);
|
|
818
|
+
}, ea = (a) => {
|
|
819
|
+
var i;
|
|
820
|
+
const s = ee(a.body || ""), n = ((i = a == null ? void 0 : a.sampleContent) == null ? void 0 : i.bodyVariables) || {};
|
|
821
|
+
return s.map(({ number: c }) => n[c] || `Sample ${c}`);
|
|
822
|
+
}, je = (a, s) => {
|
|
823
|
+
var l, v;
|
|
824
|
+
const n = {
|
|
807
825
|
name: a.name,
|
|
808
826
|
lang: s,
|
|
809
827
|
category: a.category,
|
|
810
828
|
shortlink: a.enableClickTracking ? "1" : "0",
|
|
811
829
|
components: []
|
|
812
830
|
};
|
|
813
|
-
a.headerType === "MEDIA" && a.mediaUrl && a.mediaType !== "DOCUMENT" && (
|
|
831
|
+
a.headerType === "MEDIA" && a.mediaUrl && a.mediaType !== "DOCUMENT" && (n.media = {
|
|
814
832
|
header: a.mediaUrl
|
|
815
833
|
});
|
|
816
|
-
const
|
|
834
|
+
const i = [];
|
|
817
835
|
if (a.type !== "CAROUSEL") {
|
|
818
836
|
if (a.headerType === "TEXT" && a.headerText) {
|
|
819
|
-
const
|
|
837
|
+
const g = ee(a.headerText), h = {
|
|
820
838
|
type: "HEADER",
|
|
821
839
|
format: "TEXT",
|
|
822
840
|
text: a.headerText,
|
|
823
|
-
...
|
|
841
|
+
...g.length > 0 && ((l = a.sampleContent) == null ? void 0 : l.headerVariables) && {
|
|
824
842
|
example: {
|
|
825
|
-
header_text:
|
|
843
|
+
header_text: aa(a, g)
|
|
826
844
|
}
|
|
827
845
|
}
|
|
828
846
|
};
|
|
829
|
-
|
|
847
|
+
i.push(h);
|
|
830
848
|
} else if (a.headerType === "MEDIA") {
|
|
831
|
-
const
|
|
849
|
+
const g = {
|
|
832
850
|
type: "HEADER",
|
|
833
851
|
format: a.mediaType || "IMAGE"
|
|
834
852
|
};
|
|
835
|
-
|
|
853
|
+
i.push(g);
|
|
836
854
|
}
|
|
837
855
|
}
|
|
838
|
-
const
|
|
856
|
+
const c = ee(a.body), o = {
|
|
839
857
|
type: "BODY",
|
|
840
858
|
text: a.body,
|
|
841
|
-
...
|
|
859
|
+
...c.length > 0 && ((v = a.sampleContent) == null ? void 0 : v.bodyVariables) && {
|
|
842
860
|
example: {
|
|
843
|
-
body_text: [
|
|
861
|
+
body_text: [ge(a, c)]
|
|
844
862
|
}
|
|
845
863
|
}
|
|
846
864
|
};
|
|
847
|
-
if (
|
|
865
|
+
if (i.push(o), a.footer && a.type !== "CAROUSEL" && i.push({
|
|
848
866
|
type: "FOOTER",
|
|
849
867
|
text: a.footer
|
|
850
868
|
}), a.buttons.length > 0) {
|
|
851
|
-
const
|
|
852
|
-
var
|
|
853
|
-
const
|
|
854
|
-
type:
|
|
855
|
-
text:
|
|
869
|
+
const g = a.buttons.map((h) => {
|
|
870
|
+
var V;
|
|
871
|
+
const k = {
|
|
872
|
+
type: h.type === "CALL" ? "PHONE_NUMBER" : h.type,
|
|
873
|
+
text: h.text
|
|
856
874
|
};
|
|
857
|
-
if (
|
|
858
|
-
const
|
|
859
|
-
if (
|
|
860
|
-
const
|
|
875
|
+
if (h.type === "URL" && h.value && (k.url = h.value, h.urlType === "dynamic" && h.value.includes("{{"))) {
|
|
876
|
+
const d = ee(h.value);
|
|
877
|
+
if (d.length > 0 && ((V = a.sampleContent) != null && V.buttonVariables)) {
|
|
878
|
+
const N = d.map(
|
|
861
879
|
({ number: M }) => {
|
|
862
|
-
var
|
|
863
|
-
return ((
|
|
880
|
+
var b, y;
|
|
881
|
+
return ((y = (b = a.sampleContent) == null ? void 0 : b.buttonVariables) == null ? void 0 : y[M]) || `sample${M}`;
|
|
864
882
|
}
|
|
865
883
|
);
|
|
866
|
-
|
|
884
|
+
k.example = N;
|
|
867
885
|
}
|
|
868
886
|
}
|
|
869
|
-
return (
|
|
887
|
+
return (h.type === "CALL" || h.type === "PHONE_NUMBER") && h.value && (k.phone_number = be(h.value)), k;
|
|
870
888
|
});
|
|
871
|
-
|
|
889
|
+
i.push({
|
|
872
890
|
type: "BUTTONS",
|
|
873
|
-
buttons:
|
|
891
|
+
buttons: g
|
|
874
892
|
});
|
|
875
893
|
}
|
|
876
|
-
return
|
|
877
|
-
}, ee = (a) => (a.match(/\{\{(\d+)\}\}/g) || []).map((
|
|
878
|
-
variable:
|
|
879
|
-
number:
|
|
880
|
-
})),
|
|
881
|
-
({ number:
|
|
882
|
-
var
|
|
883
|
-
return ((
|
|
894
|
+
return n.components = i, JSON.stringify(n);
|
|
895
|
+
}, ee = (a) => (a.match(/\{\{(\d+)\}\}/g) || []).map((n) => ({
|
|
896
|
+
variable: n.replace(/[{}]/g, ""),
|
|
897
|
+
number: n.replace(/[{}]/g, "")
|
|
898
|
+
})), be = (a) => a.startsWith("+") ? a : `+${a}`, aa = (a, s) => s.map(
|
|
899
|
+
({ number: n }) => {
|
|
900
|
+
var i, c;
|
|
901
|
+
return ((c = (i = a.sampleContent) == null ? void 0 : i.headerVariables) == null ? void 0 : c[n]) || `Sample ${n}`;
|
|
884
902
|
}
|
|
885
|
-
),
|
|
886
|
-
({ number:
|
|
887
|
-
var
|
|
888
|
-
return ((
|
|
903
|
+
), ge = (a, s) => s.map(
|
|
904
|
+
({ number: n }) => {
|
|
905
|
+
var i, c;
|
|
906
|
+
return ((c = (i = a.sampleContent) == null ? void 0 : i.bodyVariables) == null ? void 0 : c[n]) || `Sample ${n}`;
|
|
889
907
|
}
|
|
890
|
-
),
|
|
908
|
+
), ra = async (a, s) => {
|
|
891
909
|
try {
|
|
892
910
|
if (!s.name || !s.body)
|
|
893
911
|
throw new Error("Missing required template fields: name and body are required");
|
|
894
912
|
if (!a.apiKey)
|
|
895
913
|
throw new Error("Missing TrustSignal API key");
|
|
896
|
-
return await
|
|
914
|
+
return await Qe(
|
|
897
915
|
a.apiKey,
|
|
898
916
|
s
|
|
899
917
|
);
|
|
900
|
-
} catch (
|
|
901
|
-
return console.error("API Error:",
|
|
918
|
+
} catch (n) {
|
|
919
|
+
return console.error("API Error:", n), {
|
|
902
920
|
status: "error",
|
|
903
|
-
message:
|
|
921
|
+
message: n instanceof Error ? n.message : "An unexpected error occurred while creating the template"
|
|
904
922
|
};
|
|
905
923
|
}
|
|
906
924
|
};
|
|
907
|
-
async function
|
|
908
|
-
const
|
|
925
|
+
async function sa(a, s, n) {
|
|
926
|
+
const i = Ze(n), o = {
|
|
909
927
|
method: "POST",
|
|
910
928
|
headers: { "Content-Type": "application/json" },
|
|
911
|
-
body:
|
|
929
|
+
body: i,
|
|
912
930
|
redirect: "follow"
|
|
913
|
-
}, l = `https://wpapi.trustsignal.io/v1/user-templates/update/${encodeURIComponent(s)}?api_key=${encodeURIComponent(a)}`,
|
|
914
|
-
if (!
|
|
915
|
-
return { success: !1, message: `Update failed (${
|
|
931
|
+
}, l = `https://wpapi.trustsignal.io/v1/user-templates/update/${encodeURIComponent(s)}?api_key=${encodeURIComponent(a)}`, v = await fetch(l, o), g = await v.text();
|
|
932
|
+
if (!v.ok)
|
|
933
|
+
return { success: !1, message: `Update failed (${v.status}): ${g}`, raw: i };
|
|
916
934
|
try {
|
|
917
|
-
const
|
|
918
|
-
return { success: !!((
|
|
935
|
+
const h = JSON.parse(g);
|
|
936
|
+
return { success: !!((h == null ? void 0 : h.success) ?? !0), message: h == null ? void 0 : h.message, raw: i };
|
|
919
937
|
} catch {
|
|
920
|
-
return { success: !0, raw:
|
|
938
|
+
return { success: !0, raw: i };
|
|
921
939
|
}
|
|
922
940
|
}
|
|
923
|
-
async function
|
|
924
|
-
var
|
|
925
|
-
const
|
|
926
|
-
if (!
|
|
927
|
-
throw new Error(`Failed to fetch template ${s}: ${
|
|
928
|
-
const
|
|
941
|
+
async function na(a, s) {
|
|
942
|
+
var v;
|
|
943
|
+
const n = `https://wpapi.trustsignal.io/api/v1/template/${encodeURIComponent(s)}?api_key=${encodeURIComponent(a)}`, i = await fetch(n, { method: "GET", redirect: "follow" });
|
|
944
|
+
if (!i.ok)
|
|
945
|
+
throw new Error(`Failed to fetch template ${s}: ${i.status}`);
|
|
946
|
+
const c = await i.text(), o = JSON.parse(c), l = o.template || ((v = o.data) == null ? void 0 : v.template) || o;
|
|
929
947
|
if (!l)
|
|
930
948
|
throw new Error("Invalid template details response");
|
|
931
|
-
return
|
|
949
|
+
return ia(l);
|
|
932
950
|
}
|
|
933
|
-
function
|
|
934
|
-
var
|
|
951
|
+
function ia(a) {
|
|
952
|
+
var k, V;
|
|
935
953
|
const s = {
|
|
936
954
|
headerVariables: {},
|
|
937
955
|
bodyVariables: {},
|
|
938
956
|
buttonVariables: {}
|
|
939
957
|
};
|
|
940
|
-
let
|
|
941
|
-
const
|
|
958
|
+
let n = "NONE", i = "", c, o, l = "", v = "";
|
|
959
|
+
const g = [];
|
|
942
960
|
if (a.jsonstruct)
|
|
943
961
|
try {
|
|
944
|
-
const
|
|
945
|
-
if (
|
|
946
|
-
const
|
|
947
|
-
|
|
962
|
+
const d = JSON.parse(a.jsonstruct);
|
|
963
|
+
if (d != null && d.header) {
|
|
964
|
+
const N = d.header.format;
|
|
965
|
+
N && N !== "TEXT" ? (n = "MEDIA", c = N, o = d.header.url || ((k = a.medialist) == null ? void 0 : k.header)) : N === "TEXT" && (n = "TEXT", i = d.header.text || "");
|
|
948
966
|
}
|
|
949
|
-
if (
|
|
950
|
-
for (const
|
|
951
|
-
if (!
|
|
967
|
+
if (d != null && d.body && (l = d.body.text || ""), (V = d == null ? void 0 : d.buttons) != null && V.buttons && Array.isArray(d.buttons.buttons))
|
|
968
|
+
for (const N of d.buttons.buttons) {
|
|
969
|
+
if (!N || !N.type || !N.text) continue;
|
|
952
970
|
const M = {
|
|
953
971
|
id: de(),
|
|
954
|
-
type:
|
|
955
|
-
text:
|
|
972
|
+
type: N.type === "PHONE_NUMBER" ? "PHONE_NUMBER" : N.type,
|
|
973
|
+
text: N.text
|
|
956
974
|
};
|
|
957
|
-
|
|
958
|
-
s.buttonVariables[
|
|
959
|
-
}), M.urlType = "dynamic") : M.urlType = "static"), (
|
|
975
|
+
N.type === "URL" && (M.value = N.url, typeof N.url == "string" && N.url.includes("{{") && Array.isArray(N.example) ? (Ce(N.url).forEach((y, t) => {
|
|
976
|
+
s.buttonVariables[y] = N.example[t] ?? "";
|
|
977
|
+
}), M.urlType = "dynamic") : M.urlType = "static"), (N.type === "CALL" || N.type === "PHONE_NUMBER") && (M.value = N.phone_number || ""), g.push(M);
|
|
960
978
|
}
|
|
961
|
-
if (
|
|
962
|
-
const
|
|
963
|
-
|
|
964
|
-
const
|
|
965
|
-
return
|
|
979
|
+
if (d != null && d.carousel) {
|
|
980
|
+
const N = Object.keys(d.carousel).filter((x) => /^card\d+$/.test(x));
|
|
981
|
+
N.sort((x, p) => {
|
|
982
|
+
const w = parseInt(x.replace("card", ""), 10), A = parseInt(p.replace("card", ""), 10);
|
|
983
|
+
return w - A;
|
|
966
984
|
});
|
|
967
|
-
const M =
|
|
968
|
-
const
|
|
969
|
-
for (const
|
|
970
|
-
if (!
|
|
971
|
-
const S = { id: de(), type:
|
|
972
|
-
|
|
973
|
-
}), S.urlType = "dynamic") : S.urlType = "static"), (
|
|
985
|
+
const M = N.map((x) => {
|
|
986
|
+
const p = d.carousel[x] || {}, w = p.header || {}, A = p.body || {}, R = p.buttons && Array.isArray(p.buttons.buttons) ? p.buttons.buttons : [], f = w.format, C = f === "IMAGE" || f === "VIDEO" || f === "DOCUMENT" ? f : void 0, O = `card${x.replace("card", "")}header`, P = w.url || (a.medialist ? a.medialist[O] : void 0), H = A.text || "", m = [];
|
|
987
|
+
for (const E of R) {
|
|
988
|
+
if (!E || !E.type || !E.text) continue;
|
|
989
|
+
const S = { id: de(), type: E.type === "PHONE_NUMBER" ? "PHONE_NUMBER" : E.type, text: E.text };
|
|
990
|
+
E.type === "URL" && (S.value = E.url, typeof E.url == "string" && E.url.includes("{{") && Array.isArray(E.example) ? (Ce(E.url).forEach((I, z) => {
|
|
991
|
+
}), S.urlType = "dynamic") : S.urlType = "static"), (E.type === "CALL" || E.type === "PHONE_NUMBER") && (S.value = E.phone_number || ""), m.push(S);
|
|
974
992
|
}
|
|
975
993
|
return {
|
|
976
994
|
id: de(),
|
|
977
|
-
headerType:
|
|
978
|
-
mediaType:
|
|
979
|
-
mediaUrl:
|
|
980
|
-
body:
|
|
995
|
+
headerType: C ? "MEDIA" : "NONE",
|
|
996
|
+
mediaType: C,
|
|
997
|
+
mediaUrl: P,
|
|
998
|
+
body: H,
|
|
981
999
|
buttons: m,
|
|
982
1000
|
sampleContent: {
|
|
983
1001
|
headerVariables: {},
|
|
@@ -986,11 +1004,11 @@ function la(a) {
|
|
|
986
1004
|
}
|
|
987
1005
|
};
|
|
988
1006
|
});
|
|
989
|
-
let
|
|
990
|
-
const
|
|
991
|
-
(
|
|
992
|
-
const
|
|
993
|
-
type:
|
|
1007
|
+
let b = "IMAGE";
|
|
1008
|
+
const y = M[0];
|
|
1009
|
+
(y == null ? void 0 : y.mediaType) === "VIDEO" && (b = "VIDEO");
|
|
1010
|
+
const t = {
|
|
1011
|
+
type: b,
|
|
994
1012
|
cards: M
|
|
995
1013
|
};
|
|
996
1014
|
return {
|
|
@@ -1002,14 +1020,14 @@ function la(a) {
|
|
|
1002
1020
|
headerType: "NONE",
|
|
1003
1021
|
headerText: "",
|
|
1004
1022
|
body: l,
|
|
1005
|
-
footer:
|
|
1023
|
+
footer: v,
|
|
1006
1024
|
buttons: [],
|
|
1007
1025
|
sampleContent: s,
|
|
1008
|
-
carousel:
|
|
1026
|
+
carousel: t
|
|
1009
1027
|
};
|
|
1010
1028
|
}
|
|
1011
|
-
} catch (
|
|
1012
|
-
console.warn("Failed to parse jsonstruct; falling back",
|
|
1029
|
+
} catch (d) {
|
|
1030
|
+
console.warn("Failed to parse jsonstruct; falling back", d);
|
|
1013
1031
|
}
|
|
1014
1032
|
return {
|
|
1015
1033
|
name: a.name,
|
|
@@ -1017,25 +1035,25 @@ function la(a) {
|
|
|
1017
1035
|
type: "BASIC",
|
|
1018
1036
|
language: a.lang || "en",
|
|
1019
1037
|
enableClickTracking: !1,
|
|
1020
|
-
headerType:
|
|
1021
|
-
headerText:
|
|
1022
|
-
mediaType:
|
|
1023
|
-
mediaUrl:
|
|
1038
|
+
headerType: n,
|
|
1039
|
+
headerText: i,
|
|
1040
|
+
mediaType: c,
|
|
1041
|
+
mediaUrl: o,
|
|
1024
1042
|
body: l,
|
|
1025
|
-
footer:
|
|
1026
|
-
buttons:
|
|
1043
|
+
footer: v,
|
|
1044
|
+
buttons: g,
|
|
1027
1045
|
sampleContent: s
|
|
1028
1046
|
};
|
|
1029
1047
|
}
|
|
1030
1048
|
function Ce(a) {
|
|
1031
1049
|
if (!a) return [];
|
|
1032
1050
|
const s = a.match(/\{\{(\d+)\}\}/g) || [];
|
|
1033
|
-
return [...new Set(s.map((
|
|
1051
|
+
return [...new Set(s.map((n) => n.replace(/[{}]/g, "")))];
|
|
1034
1052
|
}
|
|
1035
1053
|
function de() {
|
|
1036
1054
|
return typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : "id-" + Math.random().toString(36).slice(2);
|
|
1037
1055
|
}
|
|
1038
|
-
const
|
|
1056
|
+
const la = [
|
|
1039
1057
|
{ value: "af", label: "Afrikaans" },
|
|
1040
1058
|
{ value: "sq", label: "Albanian" },
|
|
1041
1059
|
{ value: "ar", label: "Arabic" },
|
|
@@ -1101,118 +1119,118 @@ const ta = [
|
|
|
1101
1119
|
{ value: "ur", label: "Urdu" },
|
|
1102
1120
|
{ value: "uz", label: "Uzbek" },
|
|
1103
1121
|
{ value: "vi", label: "Vietnamese" }
|
|
1104
|
-
],
|
|
1122
|
+
], ta = [
|
|
1105
1123
|
{ value: "NONE", label: "None" },
|
|
1106
1124
|
{ value: "TEXT", label: "Text" },
|
|
1107
1125
|
{ value: "MEDIA", label: "Media" }
|
|
1108
|
-
],
|
|
1126
|
+
], ca = [
|
|
1109
1127
|
{ value: "IMAGE", label: "Image" },
|
|
1110
1128
|
{ value: "VIDEO", label: "Video" },
|
|
1111
1129
|
{ value: "DOCUMENT", label: "Document" }
|
|
1112
|
-
],
|
|
1113
|
-
function
|
|
1114
|
-
var
|
|
1115
|
-
const [
|
|
1116
|
-
const
|
|
1117
|
-
if (!
|
|
1118
|
-
const
|
|
1119
|
-
const
|
|
1120
|
-
return
|
|
1130
|
+
], ma = 5 * 1024 * 1024, da = 16 * 1024 * 1024, xa = 100 * 1024 * 1024, xe = ["jpg", "jpeg", "png"], pe = ["mp4", "3gpp"], oe = ["pdf", "docx", "xlsx", "pptx", "txt"];
|
|
1131
|
+
function pa({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
1132
|
+
var A, R;
|
|
1133
|
+
const [i, c] = X.useState(null), [o, l] = X.useState(!1), [v, g] = X.useState(null), [h, k] = X.useState(null), V = () => {
|
|
1134
|
+
const C = (a.headerText || "").match(/{{\d+}}/g);
|
|
1135
|
+
if (!C) return 0;
|
|
1136
|
+
const U = C.map((O) => {
|
|
1137
|
+
const P = O.match(/{{(\d+)}}/);
|
|
1138
|
+
return P ? parseInt(P[1], 10) : 0;
|
|
1121
1139
|
});
|
|
1122
|
-
return
|
|
1123
|
-
},
|
|
1124
|
-
const
|
|
1125
|
-
if (
|
|
1126
|
-
const O =
|
|
1140
|
+
return U.length > 0 ? Math.max(...U) : 0;
|
|
1141
|
+
}, d = () => {
|
|
1142
|
+
const U = `{{${V() + 1}}}`;
|
|
1143
|
+
if (v && a.headerText.length + U.length <= 60) {
|
|
1144
|
+
const O = v.selectionStart || a.headerText.length, P = a.headerText.substring(0, O), H = a.headerText.substring(O), m = P + U + H;
|
|
1127
1145
|
s({ ...a, headerText: m }), setTimeout(() => {
|
|
1128
|
-
if (
|
|
1129
|
-
const
|
|
1130
|
-
|
|
1146
|
+
if (v) {
|
|
1147
|
+
const E = O + U.length;
|
|
1148
|
+
v.setSelectionRange(E, E), v.focus();
|
|
1131
1149
|
}
|
|
1132
1150
|
}, 0);
|
|
1133
1151
|
}
|
|
1134
|
-
},
|
|
1135
|
-
s((
|
|
1136
|
-
...
|
|
1137
|
-
headerType:
|
|
1138
|
-
headerText:
|
|
1139
|
-
mediaType:
|
|
1140
|
-
mediaUrl:
|
|
1141
|
-
})),
|
|
1142
|
-
}, M = (
|
|
1143
|
-
var
|
|
1144
|
-
return ((
|
|
1145
|
-
},
|
|
1146
|
-
const
|
|
1147
|
-
switch (
|
|
1152
|
+
}, N = (f) => {
|
|
1153
|
+
s((C) => ({
|
|
1154
|
+
...C,
|
|
1155
|
+
headerType: f,
|
|
1156
|
+
headerText: f === "TEXT" ? C.headerText : "",
|
|
1157
|
+
mediaType: f === "MEDIA" ? C.mediaType || "IMAGE" : void 0,
|
|
1158
|
+
mediaUrl: f === "MEDIA" ? C.mediaUrl : void 0
|
|
1159
|
+
})), f !== "MEDIA" && (c(null), k(null));
|
|
1160
|
+
}, M = (f) => {
|
|
1161
|
+
var C;
|
|
1162
|
+
return ((C = f.split("?")[0].split(".").pop()) == null ? void 0 : C.toLowerCase()) || "";
|
|
1163
|
+
}, b = (f, C) => {
|
|
1164
|
+
const U = M(f.name);
|
|
1165
|
+
switch (C) {
|
|
1148
1166
|
case "IMAGE":
|
|
1149
|
-
if (!xe.includes(
|
|
1150
|
-
if (
|
|
1167
|
+
if (!xe.includes(U)) return "Invalid format. Only JPG, JPEG, PNG are allowed.";
|
|
1168
|
+
if (f.size > ma) return "File is too large. Max size is 5 MB.";
|
|
1151
1169
|
break;
|
|
1152
1170
|
case "VIDEO":
|
|
1153
|
-
if (!pe.includes(
|
|
1154
|
-
if (
|
|
1171
|
+
if (!pe.includes(U)) return "Invalid format. Only MP4, 3GPP are allowed.";
|
|
1172
|
+
if (f.size > da) return "File is too large. Max size is 16 MB.";
|
|
1155
1173
|
break;
|
|
1156
1174
|
case "DOCUMENT":
|
|
1157
|
-
if (!oe.includes(
|
|
1158
|
-
if (
|
|
1175
|
+
if (!oe.includes(U)) return "Invalid format. Allowed types: PDF, DOCX, XLSX, PPTX, TXT.";
|
|
1176
|
+
if (f.size > xa) return "File is too large. Max size is 100 MB.";
|
|
1159
1177
|
break;
|
|
1160
1178
|
default:
|
|
1161
1179
|
return "Invalid media type.";
|
|
1162
1180
|
}
|
|
1163
1181
|
return null;
|
|
1164
|
-
},
|
|
1165
|
-
if (!
|
|
1166
|
-
const
|
|
1167
|
-
switch (
|
|
1182
|
+
}, y = (f, C) => {
|
|
1183
|
+
if (!f) return null;
|
|
1184
|
+
const U = M(f);
|
|
1185
|
+
switch (C) {
|
|
1168
1186
|
case "IMAGE":
|
|
1169
|
-
if (!xe.includes(
|
|
1187
|
+
if (!xe.includes(U)) return "URL does not point to a valid image (JPG, JPEG, PNG).";
|
|
1170
1188
|
break;
|
|
1171
1189
|
case "VIDEO":
|
|
1172
|
-
if (!pe.includes(
|
|
1190
|
+
if (!pe.includes(U)) return "URL does not point to a valid video (MP4, 3GPP).";
|
|
1173
1191
|
break;
|
|
1174
1192
|
case "DOCUMENT":
|
|
1175
|
-
if (!oe.includes(
|
|
1193
|
+
if (!oe.includes(U)) return "URL does not point to a valid document.";
|
|
1176
1194
|
break;
|
|
1177
1195
|
}
|
|
1178
1196
|
return null;
|
|
1179
|
-
},
|
|
1180
|
-
|
|
1181
|
-
},
|
|
1197
|
+
}, t = () => {
|
|
1198
|
+
c(null), s({ ...a, mediaUrl: "" }), k(null);
|
|
1199
|
+
}, x = async (f) => {
|
|
1182
1200
|
var O;
|
|
1183
|
-
const
|
|
1184
|
-
if (!
|
|
1185
|
-
|
|
1186
|
-
const
|
|
1187
|
-
if (
|
|
1188
|
-
|
|
1201
|
+
const C = (O = f.target.files) == null ? void 0 : O[0];
|
|
1202
|
+
if (!C || !a.mediaType) return;
|
|
1203
|
+
k(null);
|
|
1204
|
+
const U = b(C, a.mediaType);
|
|
1205
|
+
if (U) {
|
|
1206
|
+
k(U);
|
|
1189
1207
|
return;
|
|
1190
1208
|
}
|
|
1191
|
-
l(!0),
|
|
1209
|
+
l(!0), c(C);
|
|
1192
1210
|
try {
|
|
1193
|
-
const
|
|
1194
|
-
s({ ...a, mediaUrl:
|
|
1195
|
-
} catch (
|
|
1196
|
-
console.error("File upload failed:",
|
|
1197
|
-
const
|
|
1198
|
-
|
|
1211
|
+
const P = await n(C);
|
|
1212
|
+
s({ ...a, mediaUrl: P });
|
|
1213
|
+
} catch (P) {
|
|
1214
|
+
console.error("File upload failed:", P), t();
|
|
1215
|
+
const H = P instanceof Error ? P.message : "File upload failed. Please try again.";
|
|
1216
|
+
k(H);
|
|
1199
1217
|
} finally {
|
|
1200
1218
|
l(!1);
|
|
1201
1219
|
}
|
|
1202
|
-
},
|
|
1203
|
-
const
|
|
1204
|
-
if (
|
|
1205
|
-
const
|
|
1206
|
-
|
|
1220
|
+
}, p = (f) => {
|
|
1221
|
+
const C = f.target.value;
|
|
1222
|
+
if (c(null), s({ ...a, mediaUrl: C }), a.mediaType) {
|
|
1223
|
+
const U = y(C, a.mediaType);
|
|
1224
|
+
k(U);
|
|
1207
1225
|
}
|
|
1208
|
-
},
|
|
1226
|
+
}, w = () => {
|
|
1209
1227
|
switch (a.mediaType) {
|
|
1210
1228
|
case "IMAGE":
|
|
1211
|
-
return xe.map((
|
|
1229
|
+
return xe.map((f) => `.${f}`).join(",");
|
|
1212
1230
|
case "VIDEO":
|
|
1213
|
-
return pe.map((
|
|
1231
|
+
return pe.map((f) => `.${f}`).join(",");
|
|
1214
1232
|
case "DOCUMENT":
|
|
1215
|
-
return oe.map((
|
|
1233
|
+
return oe.map((f) => `.${f}`).join(",");
|
|
1216
1234
|
default:
|
|
1217
1235
|
return "*/*";
|
|
1218
1236
|
}
|
|
@@ -1225,9 +1243,9 @@ function oa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
1225
1243
|
"select",
|
|
1226
1244
|
{
|
|
1227
1245
|
value: a.headerType,
|
|
1228
|
-
onChange: (
|
|
1246
|
+
onChange: (f) => N(f.target.value),
|
|
1229
1247
|
className: "rsp-w-full rsp-px-0 rsp-py-2 rsp-border-0 rsp-border-b rsp-border-gray-300 rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-transparent rsp-appearance-none",
|
|
1230
|
-
children:
|
|
1248
|
+
children: ta.map((f) => /* @__PURE__ */ e("option", { value: f.value, children: f.label }, f.value))
|
|
1231
1249
|
}
|
|
1232
1250
|
),
|
|
1233
1251
|
/* @__PURE__ */ e("div", { className: "rsp-absolute rsp-inset-y-0 rsp-right-0 rsp-flex rsp-items-center rsp-px-2 rsp-pointer-events-none", children: /* @__PURE__ */ e("svg", { className: "rsp-w-4 rsp-h-4 rsp-text-gray-400", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" }) }) }),
|
|
@@ -1239,10 +1257,10 @@ function oa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
1239
1257
|
/* @__PURE__ */ e("div", { className: "rsp-relative", children: /* @__PURE__ */ e(
|
|
1240
1258
|
"input",
|
|
1241
1259
|
{
|
|
1242
|
-
ref:
|
|
1260
|
+
ref: g,
|
|
1243
1261
|
type: "text",
|
|
1244
1262
|
value: a.headerText,
|
|
1245
|
-
onChange: (
|
|
1263
|
+
onChange: (f) => s({ ...a, headerText: f.target.value }),
|
|
1246
1264
|
maxLength: 60,
|
|
1247
1265
|
className: "rsp-w-full rsp-px-0 rsp-py-2 rsp-border-0 rsp-border-b rsp-border-gray-300 rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-transparent",
|
|
1248
1266
|
placeholder: "Add a 60 character title to your message"
|
|
@@ -1252,7 +1270,7 @@ function oa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
1252
1270
|
/* @__PURE__ */ e(
|
|
1253
1271
|
"button",
|
|
1254
1272
|
{
|
|
1255
|
-
onClick:
|
|
1273
|
+
onClick: d,
|
|
1256
1274
|
className: "rsp-px-2 rsp-py-1 rsp-text-xs hover:rsp-bg-gray-100 rsp-rounded rsp-text-gray-500 rsp-flex rsp-items-center rsp-gap-1",
|
|
1257
1275
|
title: "Add variable to header",
|
|
1258
1276
|
children: /* @__PURE__ */ e("svg", { className: "rsp-w-4 rsp-h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" }) })
|
|
@@ -1264,30 +1282,30 @@ function oa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
1264
1282
|
] })
|
|
1265
1283
|
] }),
|
|
1266
1284
|
(() => {
|
|
1267
|
-
const
|
|
1268
|
-
return
|
|
1285
|
+
const f = [...new Set((a.headerText.match(/\{\{(\d+)\}\}/g) || []).map((C) => C.replace(/[{}]/g, "")))];
|
|
1286
|
+
return f.length === 0 ? null : /* @__PURE__ */ r("div", { className: "rsp-mt-3", children: [
|
|
1269
1287
|
/* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-font-medium rsp-text-gray-600 rsp-mb-2", children: "Sample Values" }),
|
|
1270
|
-
/* @__PURE__ */ e("div", { className: "rsp-grid rsp-grid-cols-3 rsp-gap-2", children:
|
|
1271
|
-
var
|
|
1288
|
+
/* @__PURE__ */ e("div", { className: "rsp-grid rsp-grid-cols-3 rsp-gap-2", children: f.map((C) => {
|
|
1289
|
+
var U, O;
|
|
1272
1290
|
return /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2", children: [
|
|
1273
1291
|
/* @__PURE__ */ r("label", { className: "rsp-text-xs rsp-text-gray-500 rsp-whitespace-nowrap", children: [
|
|
1274
|
-
`{{${
|
|
1292
|
+
`{{${C}}}`,
|
|
1275
1293
|
":"
|
|
1276
1294
|
] }),
|
|
1277
1295
|
/* @__PURE__ */ e(
|
|
1278
1296
|
"input",
|
|
1279
1297
|
{
|
|
1280
1298
|
type: "text",
|
|
1281
|
-
value: ((O = (
|
|
1282
|
-
onChange: (
|
|
1283
|
-
var m,
|
|
1284
|
-
const
|
|
1299
|
+
value: ((O = (U = a.sampleContent) == null ? void 0 : U.headerVariables) == null ? void 0 : O[C]) || "",
|
|
1300
|
+
onChange: (P) => {
|
|
1301
|
+
var m, E, S;
|
|
1302
|
+
const H = {
|
|
1285
1303
|
...a.sampleContent,
|
|
1286
|
-
headerVariables: { ...(m = a.sampleContent) == null ? void 0 : m.headerVariables, [
|
|
1287
|
-
bodyVariables: ((
|
|
1304
|
+
headerVariables: { ...(m = a.sampleContent) == null ? void 0 : m.headerVariables, [C]: P.target.value },
|
|
1305
|
+
bodyVariables: ((E = a.sampleContent) == null ? void 0 : E.bodyVariables) || {},
|
|
1288
1306
|
buttonVariables: ((S = a.sampleContent) == null ? void 0 : S.buttonVariables) || {}
|
|
1289
1307
|
};
|
|
1290
|
-
s({ ...a, sampleContent:
|
|
1308
|
+
s({ ...a, sampleContent: H });
|
|
1291
1309
|
},
|
|
1292
1310
|
className: "rsp-flex-1 rsp-px-2 rsp-py-1 rsp-border rsp-border-gray-300 rsp-rounded rsp-text-xs focus:rsp-outline-none focus:rsp-border-blue-500",
|
|
1293
1311
|
placeholder: "Sample"
|
|
@@ -1298,11 +1316,11 @@ function oa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
1298
1316
|
{
|
|
1299
1317
|
type: "button",
|
|
1300
1318
|
onClick: () => {
|
|
1301
|
-
var
|
|
1302
|
-
const
|
|
1319
|
+
var E, S, j;
|
|
1320
|
+
const P = new RegExp(`\\{\\{${C}\\}\\}`, "g"), H = (a.headerText || "").replace(P, ""), m = Object.fromEntries(Object.entries(((E = a.sampleContent) == null ? void 0 : E.headerVariables) || {}).filter(([I]) => I !== C));
|
|
1303
1321
|
s({
|
|
1304
1322
|
...a,
|
|
1305
|
-
headerText:
|
|
1323
|
+
headerText: H,
|
|
1306
1324
|
sampleContent: {
|
|
1307
1325
|
...a.sampleContent,
|
|
1308
1326
|
headerVariables: m,
|
|
@@ -1316,7 +1334,7 @@ function oa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
1316
1334
|
children: "×"
|
|
1317
1335
|
}
|
|
1318
1336
|
)
|
|
1319
|
-
] }, `header-sample-${
|
|
1337
|
+
] }, `header-sample-${C}`);
|
|
1320
1338
|
}) })
|
|
1321
1339
|
] });
|
|
1322
1340
|
})()
|
|
@@ -1329,15 +1347,15 @@ function oa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
1329
1347
|
"select",
|
|
1330
1348
|
{
|
|
1331
1349
|
value: a.mediaType || "IMAGE",
|
|
1332
|
-
onChange: (
|
|
1333
|
-
s((
|
|
1334
|
-
...
|
|
1335
|
-
mediaType:
|
|
1350
|
+
onChange: (f) => {
|
|
1351
|
+
s((C) => ({
|
|
1352
|
+
...C,
|
|
1353
|
+
mediaType: f.target.value,
|
|
1336
1354
|
mediaUrl: ""
|
|
1337
|
-
})),
|
|
1355
|
+
})), c(null), k(null);
|
|
1338
1356
|
},
|
|
1339
1357
|
className: "rsp-w-full rsp-px-0 rsp-py-2 rsp-border-0 rsp-border-b rsp-border-gray-300 rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-transparent rsp-appearance-none",
|
|
1340
|
-
children:
|
|
1358
|
+
children: ca.map((f) => /* @__PURE__ */ e("option", { value: f.value, children: f.label }, f.value))
|
|
1341
1359
|
}
|
|
1342
1360
|
),
|
|
1343
1361
|
/* @__PURE__ */ e("div", { className: "rsp-absolute rsp-inset-y-0 rsp-right-0 rsp-flex rsp-items-center rsp-px-2 rsp-pointer-events-none", children: /* @__PURE__ */ e("svg", { className: "rsp-w-4 rsp-h-4 rsp-text-gray-400", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" }) }) })
|
|
@@ -1353,32 +1371,32 @@ function oa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
1353
1371
|
src: a.mediaUrl,
|
|
1354
1372
|
alt: "Preview",
|
|
1355
1373
|
className: "rsp-w-12 rsp-h-12 rsp-object-cover rsp-rounded",
|
|
1356
|
-
onError: (
|
|
1357
|
-
|
|
1374
|
+
onError: (f) => {
|
|
1375
|
+
f.currentTarget.style.display = "none", h || k("Could not load image preview from URL.");
|
|
1358
1376
|
},
|
|
1359
1377
|
onLoad: () => {
|
|
1360
|
-
|
|
1378
|
+
h != null && h.includes("Could not load") && k(null);
|
|
1361
1379
|
}
|
|
1362
1380
|
}
|
|
1363
1381
|
),
|
|
1364
|
-
a.mediaType === "VIDEO" && /* @__PURE__ */ e("div", { className: "rsp-w-12 rsp-h-12 rsp-bg-gray-200 rsp-rounded rsp-flex rsp-items-center rsp-justify-center flex-shrink-0", children: /* @__PURE__ */ e(
|
|
1365
|
-
a.mediaType === "DOCUMENT" && /* @__PURE__ */ e("div", { className: "rsp-w-12 rsp-h-12 rsp-bg-gray-200 rsp-rounded rsp-flex rsp-items-center rsp-justify-center flex-shrink-0", children: /* @__PURE__ */ e(
|
|
1382
|
+
a.mediaType === "VIDEO" && /* @__PURE__ */ e("div", { className: "rsp-w-12 rsp-h-12 rsp-bg-gray-200 rsp-rounded rsp-flex rsp-items-center rsp-justify-center flex-shrink-0", children: /* @__PURE__ */ e($e, { className: "rsp-w-6 rsp-h-6 rsp-text-gray-500" }) }),
|
|
1383
|
+
a.mediaType === "DOCUMENT" && /* @__PURE__ */ e("div", { className: "rsp-w-12 rsp-h-12 rsp-bg-gray-200 rsp-rounded rsp-flex rsp-items-center rsp-justify-center flex-shrink-0", children: /* @__PURE__ */ e(He, { className: "rsp-w-6 rsp-h-6 rsp-text-gray-500" }) }),
|
|
1366
1384
|
/* @__PURE__ */ r("div", { className: "overflow-hidden", children: [
|
|
1367
|
-
/* @__PURE__ */ e("p", { className: "rsp-text-sm rsp-font-medium rsp-text-gray-900 rsp-truncate", children:
|
|
1368
|
-
|
|
1385
|
+
/* @__PURE__ */ e("p", { className: "rsp-text-sm rsp-font-medium rsp-text-gray-900 rsp-truncate", children: i ? i.name : a.mediaUrl }),
|
|
1386
|
+
i && /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-500", children: `${(i.size / 1024 / 1024).toFixed(2)} MB` })
|
|
1369
1387
|
] })
|
|
1370
1388
|
] }),
|
|
1371
|
-
/* @__PURE__ */ e("button", { onClick:
|
|
1389
|
+
/* @__PURE__ */ e("button", { onClick: t, className: "rsp-p-1 rsp-text-gray-400 hover:rsp-text-red-500 rsp-transition-colors flex-shrink-0", children: /* @__PURE__ */ e(re, { className: "rsp-w-4 rsp-h-4" }) })
|
|
1372
1390
|
] }) : /* @__PURE__ */ r("div", { children: [
|
|
1373
|
-
/* @__PURE__ */ e("input", { type: "file", accept:
|
|
1391
|
+
/* @__PURE__ */ e("input", { type: "file", accept: w(), onChange: x, className: "rsp-hidden", id: "media-upload", disabled: o }),
|
|
1374
1392
|
/* @__PURE__ */ r(
|
|
1375
1393
|
"label",
|
|
1376
1394
|
{
|
|
1377
1395
|
htmlFor: "media-upload",
|
|
1378
|
-
className: `rsp-w-full rsp-px-4 rsp-py-3 rsp-border-2 rsp-border-dashed rsp-border-gray-300 rsp-rounded-md rsp-flex rsp-flex-col rsp-items-center rsp-justify-center rsp-cursor-pointer rsp-transition-colors hover:rsp-border-gray-400 hover:rsp-bg-gray-50 ${
|
|
1396
|
+
className: `rsp-w-full rsp-px-4 rsp-py-3 rsp-border-2 rsp-border-dashed rsp-border-gray-300 rsp-rounded-md rsp-flex rsp-flex-col rsp-items-center rsp-justify-center rsp-cursor-pointer rsp-transition-colors hover:rsp-border-gray-400 hover:rsp-bg-gray-50 ${o ? "rsp-opacity-50 rsp-cursor-not-allowed" : ""}`,
|
|
1379
1397
|
children: [
|
|
1380
|
-
/* @__PURE__ */ e(
|
|
1381
|
-
/* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-text-gray-600", children:
|
|
1398
|
+
/* @__PURE__ */ e(Xe, { className: "rsp-w-6 rsp-h-6 rsp-text-gray-400 rsp-mb-2" }),
|
|
1399
|
+
/* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-text-gray-600", children: o ? "Uploading..." : `Upload ${((A = a.mediaType) == null ? void 0 : A.toLowerCase()) || "file"}` }),
|
|
1382
1400
|
/* @__PURE__ */ r("span", { className: "rsp-text-xs rsp-text-gray-400 rsp-mt-1", children: [
|
|
1383
1401
|
a.mediaType === "IMAGE" && "JPG, PNG up to 5MB",
|
|
1384
1402
|
a.mediaType === "VIDEO" && "MP4, 3GPP up to 16MB",
|
|
@@ -1388,9 +1406,9 @@ function oa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
1388
1406
|
}
|
|
1389
1407
|
)
|
|
1390
1408
|
] }),
|
|
1391
|
-
|
|
1409
|
+
h && /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2 rsp-text-xs rsp-text-red-600", children: [
|
|
1392
1410
|
/* @__PURE__ */ e(fe, { className: "rsp-w-4 rsp-h-4" }),
|
|
1393
|
-
/* @__PURE__ */ e("span", { children:
|
|
1411
|
+
/* @__PURE__ */ e("span", { children: h })
|
|
1394
1412
|
] }),
|
|
1395
1413
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center", children: [
|
|
1396
1414
|
/* @__PURE__ */ e("div", { className: "rsp-flex-1 rsp-border-t rsp-border-gray-300" }),
|
|
@@ -1402,9 +1420,9 @@ function oa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
1402
1420
|
{
|
|
1403
1421
|
type: "url",
|
|
1404
1422
|
value: a.mediaUrl || "",
|
|
1405
|
-
onChange:
|
|
1423
|
+
onChange: p,
|
|
1406
1424
|
className: "rsp-w-full rsp-px-0 rsp-py-2 rsp-border-0 rsp-border-b rsp-border-gray-300 rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-transparent",
|
|
1407
|
-
placeholder: `Enter ${(
|
|
1425
|
+
placeholder: `Enter ${(R = a.mediaType) == null ? void 0 : R.toLowerCase()} URL`
|
|
1408
1426
|
}
|
|
1409
1427
|
) })
|
|
1410
1428
|
] })
|
|
@@ -3210,54 +3228,54 @@ const Ee = [
|
|
|
3210
3228
|
{ name: "south-africa", hexadecimal: "🇿🇦" },
|
|
3211
3229
|
{ name: "zambia", hexadecimal: "🇿🇲" },
|
|
3212
3230
|
{ name: "zimbabwe", hexadecimal: "🇿🇼" }
|
|
3213
|
-
],
|
|
3231
|
+
], oa = ({
|
|
3214
3232
|
emojis: a,
|
|
3215
3233
|
onSelect: s,
|
|
3216
|
-
onClose:
|
|
3234
|
+
onClose: n
|
|
3217
3235
|
}) => {
|
|
3218
|
-
const [
|
|
3219
|
-
const
|
|
3220
|
-
M + Math.ceil(
|
|
3221
|
-
Math.ceil(a.length /
|
|
3236
|
+
const [i, c] = B({ start: 0, end: 80 }), o = 8, l = 40, v = 400, g = Ne((d) => {
|
|
3237
|
+
const N = d.currentTarget.scrollTop, M = Math.floor(N / l), b = Math.min(
|
|
3238
|
+
M + Math.ceil(v / l) + 2,
|
|
3239
|
+
Math.ceil(a.length / o)
|
|
3222
3240
|
);
|
|
3223
|
-
|
|
3224
|
-
start: M *
|
|
3225
|
-
end:
|
|
3241
|
+
c({
|
|
3242
|
+
start: M * o,
|
|
3243
|
+
end: b * o
|
|
3226
3244
|
});
|
|
3227
|
-
}, [a.length, l,
|
|
3228
|
-
const
|
|
3229
|
-
if (!
|
|
3230
|
-
const M =
|
|
3231
|
-
const
|
|
3232
|
-
return parseInt(
|
|
3245
|
+
}, [a.length, l, v, o]), h = Ne((d) => {
|
|
3246
|
+
const N = d.match(/&#x([0-9A-Fa-f]+);/g);
|
|
3247
|
+
if (!N) return "";
|
|
3248
|
+
const M = N.map((b) => {
|
|
3249
|
+
const y = b.replace(/&#x|;/g, "");
|
|
3250
|
+
return parseInt(y, 16);
|
|
3233
3251
|
});
|
|
3234
3252
|
return String.fromCodePoint(...M);
|
|
3235
|
-
}, []),
|
|
3253
|
+
}, []), k = Math.ceil(a.length / o) * l, V = a.slice(i.start, i.end);
|
|
3236
3254
|
return /* @__PURE__ */ e(
|
|
3237
3255
|
"div",
|
|
3238
3256
|
{
|
|
3239
3257
|
className: "rsp-h-[400px] rsp-overflow-y-auto rsp-relative",
|
|
3240
|
-
onScroll:
|
|
3241
|
-
children: /* @__PURE__ */ e("div", { style: { height:
|
|
3258
|
+
onScroll: g,
|
|
3259
|
+
children: /* @__PURE__ */ e("div", { style: { height: k }, className: "rsp-relative", children: /* @__PURE__ */ e(
|
|
3242
3260
|
"div",
|
|
3243
3261
|
{
|
|
3244
3262
|
className: "rsp-absolute rsp-w-full rsp-grid rsp-grid-cols-8 rsp-gap-1",
|
|
3245
3263
|
style: {
|
|
3246
|
-
top: Math.floor(
|
|
3264
|
+
top: Math.floor(i.start / o) * l,
|
|
3247
3265
|
transform: "translateY(0px)"
|
|
3248
3266
|
},
|
|
3249
|
-
children:
|
|
3250
|
-
const M =
|
|
3267
|
+
children: V.map((d, N) => {
|
|
3268
|
+
const M = i.start + N;
|
|
3251
3269
|
return /* @__PURE__ */ e(
|
|
3252
3270
|
"button",
|
|
3253
3271
|
{
|
|
3254
3272
|
onClick: () => {
|
|
3255
|
-
s(
|
|
3273
|
+
s(h(d.hexadecimal));
|
|
3256
3274
|
},
|
|
3257
3275
|
className: "rsp-w-10 rsp-h-10 rsp-flex rsp-items-center rsp-justify-center rsp-text-xl hover:rsp-bg-gray-100 rsp-rounded rsp-transition-colors",
|
|
3258
|
-
title:
|
|
3276
|
+
title: d.name,
|
|
3259
3277
|
style: { height: l },
|
|
3260
|
-
children:
|
|
3278
|
+
children: h(d.hexadecimal)
|
|
3261
3279
|
},
|
|
3262
3280
|
M
|
|
3263
3281
|
);
|
|
@@ -3267,12 +3285,12 @@ const Ee = [
|
|
|
3267
3285
|
}
|
|
3268
3286
|
);
|
|
3269
3287
|
};
|
|
3270
|
-
function
|
|
3271
|
-
const [
|
|
3272
|
-
(l) => l.name.toLowerCase().includes(
|
|
3273
|
-
) : Ee, [
|
|
3274
|
-
return
|
|
3275
|
-
a ||
|
|
3288
|
+
function ye({ isOpen: a, onClose: s, onSelect: n }) {
|
|
3289
|
+
const [i, c] = B(""), o = Se(() => i ? Ee.filter(
|
|
3290
|
+
(l) => l.name.toLowerCase().includes(i.toLowerCase())
|
|
3291
|
+
) : Ee, [i]);
|
|
3292
|
+
return X.useEffect(() => {
|
|
3293
|
+
a || c("");
|
|
3276
3294
|
}, [a]), /* @__PURE__ */ e(te, { isOpen: a, onClose: s, title: "Select Emoji", children: /* @__PURE__ */ r("div", { className: "rsp-space-y-4", children: [
|
|
3277
3295
|
/* @__PURE__ */ r("div", { className: "rsp-relative", children: [
|
|
3278
3296
|
/* @__PURE__ */ e(
|
|
@@ -3280,15 +3298,15 @@ function ge({ isOpen: a, onClose: s, onSelect: i }) {
|
|
|
3280
3298
|
{
|
|
3281
3299
|
type: "text",
|
|
3282
3300
|
placeholder: "Search emojis...",
|
|
3283
|
-
value:
|
|
3284
|
-
onChange: (l) =>
|
|
3301
|
+
value: i,
|
|
3302
|
+
onChange: (l) => c(l.target.value),
|
|
3285
3303
|
className: "rsp-w-full rsp-px-3 rsp-py-2 rsp-border rsp-border-gray-300 rsp-rounded-md rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500"
|
|
3286
3304
|
}
|
|
3287
3305
|
),
|
|
3288
|
-
|
|
3306
|
+
i && /* @__PURE__ */ e(
|
|
3289
3307
|
"button",
|
|
3290
3308
|
{
|
|
3291
|
-
onClick: () =>
|
|
3309
|
+
onClick: () => c(""),
|
|
3292
3310
|
className: "rsp-absolute rsp-right-2 rsp-top-1/2 rsp-transform -rsp-translate-y-1/2 rsp-text-gray-400 hover:rsp-text-gray-600",
|
|
3293
3311
|
children: "×"
|
|
3294
3312
|
}
|
|
@@ -3298,7 +3316,7 @@ function ge({ isOpen: a, onClose: s, onSelect: i }) {
|
|
|
3298
3316
|
"button",
|
|
3299
3317
|
{
|
|
3300
3318
|
onClick: () => {
|
|
3301
|
-
|
|
3319
|
+
n(l);
|
|
3302
3320
|
},
|
|
3303
3321
|
className: "rsp-w-8 rsp-h-8 rsp-flex rsp-items-center rsp-justify-center rsp-text-lg hover:rsp-bg-gray-100 rsp-rounded rsp-transition-colors",
|
|
3304
3322
|
children: l
|
|
@@ -3306,74 +3324,74 @@ function ge({ isOpen: a, onClose: s, onSelect: i }) {
|
|
|
3306
3324
|
l
|
|
3307
3325
|
)) }),
|
|
3308
3326
|
/* @__PURE__ */ r("div", { className: "rsp-text-sm rsp-text-gray-500", children: [
|
|
3309
|
-
|
|
3327
|
+
o.length,
|
|
3310
3328
|
" emojis found"
|
|
3311
3329
|
] }),
|
|
3312
3330
|
/* @__PURE__ */ e(
|
|
3313
|
-
|
|
3331
|
+
oa,
|
|
3314
3332
|
{
|
|
3315
|
-
emojis:
|
|
3316
|
-
onSelect:
|
|
3333
|
+
emojis: o,
|
|
3334
|
+
onSelect: n,
|
|
3317
3335
|
onClose: s
|
|
3318
3336
|
}
|
|
3319
3337
|
)
|
|
3320
3338
|
] }) });
|
|
3321
3339
|
}
|
|
3322
|
-
function
|
|
3323
|
-
const [
|
|
3324
|
-
const
|
|
3325
|
-
if (!
|
|
3326
|
-
const
|
|
3327
|
-
const
|
|
3328
|
-
return
|
|
3340
|
+
function fa({ template: a, setTemplate: s }) {
|
|
3341
|
+
const [n, i] = B(!1), [c, o] = B(null), [l, v] = B(null), [g, h] = B(null), [k, V] = B(!1), d = () => {
|
|
3342
|
+
const t = (a.body || "").match(/{{\d+}}/g);
|
|
3343
|
+
if (!t) return 0;
|
|
3344
|
+
const x = t.map((p) => {
|
|
3345
|
+
const w = p.match(/{{(\d+)}}/);
|
|
3346
|
+
return w ? parseInt(w[1], 10) : 0;
|
|
3329
3347
|
});
|
|
3330
|
-
return
|
|
3331
|
-
},
|
|
3332
|
-
const
|
|
3333
|
-
if (l && a.body.length +
|
|
3334
|
-
const
|
|
3348
|
+
return x.length > 0 ? Math.max(...x) : 0;
|
|
3349
|
+
}, N = () => {
|
|
3350
|
+
const x = `{{${d() + 1}}}`;
|
|
3351
|
+
if (l && a.body.length + x.length <= 1024) {
|
|
3352
|
+
const p = l.selectionStart || a.body.length, w = a.body.substring(0, p), A = a.body.substring(p), R = w + x + A;
|
|
3335
3353
|
s({
|
|
3336
3354
|
...a,
|
|
3337
|
-
body:
|
|
3355
|
+
body: R
|
|
3338
3356
|
}), setTimeout(() => {
|
|
3339
3357
|
if (l) {
|
|
3340
|
-
const
|
|
3341
|
-
l.setSelectionRange(
|
|
3358
|
+
const f = p + x.length;
|
|
3359
|
+
l.setSelectionRange(f, f), l.focus();
|
|
3342
3360
|
}
|
|
3343
3361
|
}, 0);
|
|
3344
3362
|
}
|
|
3345
3363
|
}, M = () => {
|
|
3346
|
-
|
|
3364
|
+
o("body"), i(!0), setTimeout(() => {
|
|
3347
3365
|
l && l.focus();
|
|
3348
3366
|
}, 0);
|
|
3349
|
-
},
|
|
3350
|
-
if (
|
|
3367
|
+
}, b = (y) => {
|
|
3368
|
+
if (c === "body") {
|
|
3351
3369
|
if (!l) return;
|
|
3352
|
-
const
|
|
3353
|
-
if (
|
|
3354
|
-
const
|
|
3370
|
+
const t = l.selectionStart || a.body.length, x = 1024, p = a.body;
|
|
3371
|
+
if (p.length + y.length <= x) {
|
|
3372
|
+
const w = p.substring(0, t), A = p.substring(t), R = w + y + A;
|
|
3355
3373
|
s({
|
|
3356
3374
|
...a,
|
|
3357
|
-
body:
|
|
3375
|
+
body: R
|
|
3358
3376
|
}), setTimeout(() => {
|
|
3359
3377
|
if (l) {
|
|
3360
|
-
const
|
|
3361
|
-
l.setSelectionRange(
|
|
3378
|
+
const f = t + y.length;
|
|
3379
|
+
l.setSelectionRange(f, f), l.focus();
|
|
3362
3380
|
}
|
|
3363
3381
|
}, 0);
|
|
3364
3382
|
}
|
|
3365
|
-
} else if (
|
|
3366
|
-
if (!
|
|
3367
|
-
const
|
|
3368
|
-
if (
|
|
3369
|
-
const
|
|
3383
|
+
} else if (c === "footer") {
|
|
3384
|
+
if (!g) return;
|
|
3385
|
+
const t = g.selectionStart || a.footer.length, x = 60, p = a.footer;
|
|
3386
|
+
if (p.length + y.length <= x) {
|
|
3387
|
+
const w = p.substring(0, t), A = p.substring(t), R = w + y + A;
|
|
3370
3388
|
s({
|
|
3371
3389
|
...a,
|
|
3372
|
-
footer:
|
|
3390
|
+
footer: R
|
|
3373
3391
|
}), setTimeout(() => {
|
|
3374
|
-
if (
|
|
3375
|
-
const
|
|
3376
|
-
|
|
3392
|
+
if (g) {
|
|
3393
|
+
const f = t + y.length;
|
|
3394
|
+
g.setSelectionRange(f, f), g.focus();
|
|
3377
3395
|
}
|
|
3378
3396
|
}, 0);
|
|
3379
3397
|
}
|
|
@@ -3385,24 +3403,24 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3385
3403
|
/* @__PURE__ */ e("div", { className: "rsp-relative", children: /* @__PURE__ */ e(
|
|
3386
3404
|
"textarea",
|
|
3387
3405
|
{
|
|
3388
|
-
ref:
|
|
3406
|
+
ref: v,
|
|
3389
3407
|
value: a.body,
|
|
3390
|
-
onChange: (
|
|
3408
|
+
onChange: (y) => s({ ...a, body: y.target.value }),
|
|
3391
3409
|
maxLength: 1024,
|
|
3392
3410
|
rows: 6,
|
|
3393
3411
|
className: "rsp-w-full rsp-px-3 rsp-py-2 rsp-border rsp-border-gray-300 rsp-rounded-md rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-white rsp-resize-none rsp-shadow-sm",
|
|
3394
3412
|
placeholder: "Enter the text for your message",
|
|
3395
|
-
onFocus: () =>
|
|
3396
|
-
onBlur: () =>
|
|
3413
|
+
onFocus: () => o("body"),
|
|
3414
|
+
onBlur: () => V(!0)
|
|
3397
3415
|
}
|
|
3398
3416
|
) }),
|
|
3399
|
-
!a.body &&
|
|
3417
|
+
!a.body && k && /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-red-600 rsp-mt-1", children: "Body is required." }),
|
|
3400
3418
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-justify-between rsp-mt-2", children: [
|
|
3401
3419
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2", children: [
|
|
3402
3420
|
/* @__PURE__ */ e(
|
|
3403
3421
|
"button",
|
|
3404
3422
|
{
|
|
3405
|
-
onClick:
|
|
3423
|
+
onClick: N,
|
|
3406
3424
|
className: "rsp-p-1 rsp-text-gray-500 hover:rsp-text-gray-700 hover:rsp-bg-gray-100 rsp-rounded",
|
|
3407
3425
|
title: "Add Variable",
|
|
3408
3426
|
children: /* @__PURE__ */ e("svg", { className: "rsp-w-4 rsp-h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" }) })
|
|
@@ -3414,7 +3432,7 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3414
3432
|
onClick: M,
|
|
3415
3433
|
className: "rsp-p-1 rsp-text-gray-500 hover:rsp-text-gray-700 hover:rsp-bg-gray-100 rsp-rounded",
|
|
3416
3434
|
title: "Add emoji",
|
|
3417
|
-
children: /* @__PURE__ */ e(
|
|
3435
|
+
children: /* @__PURE__ */ e(ue, { className: "rsp-w-4 rsp-h-4" })
|
|
3418
3436
|
}
|
|
3419
3437
|
)
|
|
3420
3438
|
] }),
|
|
@@ -3424,15 +3442,15 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3424
3442
|
] }) })
|
|
3425
3443
|
] }),
|
|
3426
3444
|
(() => {
|
|
3427
|
-
const
|
|
3428
|
-
return
|
|
3445
|
+
const y = a.body.match(/\{\{(\d+)\}\}/g) || [], t = [...new Set(y.map((x) => x.replace(/[{}]/g, "")))];
|
|
3446
|
+
return t.length === 0 ? null : /* @__PURE__ */ r("div", { className: "rsp-mt-3", children: [
|
|
3429
3447
|
/* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-font-medium rsp-text-gray-600 rsp-mb-2", children: "Sample Values" }),
|
|
3430
|
-
/* @__PURE__ */ e("div", { className: "rsp-grid rsp-grid-cols-3 rsp-gap-2", children:
|
|
3431
|
-
var
|
|
3448
|
+
/* @__PURE__ */ e("div", { className: "rsp-grid rsp-grid-cols-3 rsp-gap-2", children: t.map((x) => {
|
|
3449
|
+
var p, w;
|
|
3432
3450
|
return /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2", children: [
|
|
3433
3451
|
/* @__PURE__ */ r("label", { className: "rsp-text-xs rsp-text-gray-500 rsp-whitespace-nowrap", children: [
|
|
3434
3452
|
"{{",
|
|
3435
|
-
|
|
3453
|
+
x,
|
|
3436
3454
|
"}}",
|
|
3437
3455
|
":"
|
|
3438
3456
|
] }),
|
|
@@ -3440,21 +3458,21 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3440
3458
|
"input",
|
|
3441
3459
|
{
|
|
3442
3460
|
type: "text",
|
|
3443
|
-
value: ((
|
|
3444
|
-
onChange: (
|
|
3445
|
-
var
|
|
3446
|
-
const
|
|
3461
|
+
value: ((w = (p = a.sampleContent) == null ? void 0 : p.bodyVariables) == null ? void 0 : w[x]) || "",
|
|
3462
|
+
onChange: (A) => {
|
|
3463
|
+
var f, C, U;
|
|
3464
|
+
const R = {
|
|
3447
3465
|
...a.sampleContent,
|
|
3448
3466
|
bodyVariables: {
|
|
3449
|
-
...(
|
|
3450
|
-
[
|
|
3467
|
+
...(f = a.sampleContent) == null ? void 0 : f.bodyVariables,
|
|
3468
|
+
[x]: A.target.value
|
|
3451
3469
|
},
|
|
3452
|
-
headerVariables: ((
|
|
3453
|
-
buttonVariables: ((
|
|
3470
|
+
headerVariables: ((C = a.sampleContent) == null ? void 0 : C.headerVariables) || {},
|
|
3471
|
+
buttonVariables: ((U = a.sampleContent) == null ? void 0 : U.buttonVariables) || {}
|
|
3454
3472
|
};
|
|
3455
3473
|
s({
|
|
3456
3474
|
...a,
|
|
3457
|
-
sampleContent:
|
|
3475
|
+
sampleContent: R
|
|
3458
3476
|
});
|
|
3459
3477
|
},
|
|
3460
3478
|
className: "rsp-flex-1 rsp-px-2 rsp-py-1 rsp-border rsp-border-gray-300 rsp-rounded rsp-text-xs focus:rsp-outline-none focus:rsp-border-blue-500",
|
|
@@ -3466,15 +3484,15 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3466
3484
|
{
|
|
3467
3485
|
type: "button",
|
|
3468
3486
|
onClick: () => {
|
|
3469
|
-
var
|
|
3470
|
-
const
|
|
3487
|
+
var C, U, O;
|
|
3488
|
+
const A = new RegExp(`\\{\\{${x}\\}\\}`, "g"), R = (a.body || "").replace(A, ""), f = Object.fromEntries(Object.entries(((C = a.sampleContent) == null ? void 0 : C.bodyVariables) || {}).filter(([P]) => P !== x));
|
|
3471
3489
|
s({
|
|
3472
3490
|
...a,
|
|
3473
|
-
body:
|
|
3491
|
+
body: R,
|
|
3474
3492
|
sampleContent: {
|
|
3475
3493
|
...a.sampleContent,
|
|
3476
|
-
bodyVariables:
|
|
3477
|
-
headerVariables: ((
|
|
3494
|
+
bodyVariables: f,
|
|
3495
|
+
headerVariables: ((U = a.sampleContent) == null ? void 0 : U.headerVariables) || {},
|
|
3478
3496
|
buttonVariables: ((O = a.sampleContent) == null ? void 0 : O.buttonVariables) || {}
|
|
3479
3497
|
}
|
|
3480
3498
|
});
|
|
@@ -3484,7 +3502,7 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3484
3502
|
children: "×"
|
|
3485
3503
|
}
|
|
3486
3504
|
)
|
|
3487
|
-
] }, `body-sample-${
|
|
3505
|
+
] }, `body-sample-${x}`);
|
|
3488
3506
|
}) })
|
|
3489
3507
|
] });
|
|
3490
3508
|
})()
|
|
@@ -3494,14 +3512,14 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3494
3512
|
/* @__PURE__ */ e("div", { className: "rsp-relative", children: /* @__PURE__ */ e(
|
|
3495
3513
|
"input",
|
|
3496
3514
|
{
|
|
3497
|
-
ref:
|
|
3515
|
+
ref: h,
|
|
3498
3516
|
type: "text",
|
|
3499
3517
|
value: a.footer,
|
|
3500
|
-
onChange: (
|
|
3518
|
+
onChange: (y) => s({ ...a, footer: y.target.value }),
|
|
3501
3519
|
maxLength: 60,
|
|
3502
3520
|
className: "rsp-w-full rsp-px-0 rsp-py-2 rsp-border-0 rsp-border-b rsp-border-gray-300 rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-transparent",
|
|
3503
3521
|
placeholder: "Footer Text",
|
|
3504
|
-
onFocus: () =>
|
|
3522
|
+
onFocus: () => o("footer")
|
|
3505
3523
|
}
|
|
3506
3524
|
) }),
|
|
3507
3525
|
/* @__PURE__ */ r("p", { className: "rsp-text-xs rsp-text-gray-500 rsp-mt-1", children: [
|
|
@@ -3510,95 +3528,95 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3510
3528
|
] })
|
|
3511
3529
|
] }),
|
|
3512
3530
|
/* @__PURE__ */ e(
|
|
3513
|
-
|
|
3531
|
+
ye,
|
|
3514
3532
|
{
|
|
3515
|
-
isOpen:
|
|
3516
|
-
onClose: () =>
|
|
3517
|
-
onSelect:
|
|
3533
|
+
isOpen: n,
|
|
3534
|
+
onClose: () => i(!1),
|
|
3535
|
+
onSelect: b
|
|
3518
3536
|
}
|
|
3519
3537
|
)
|
|
3520
3538
|
] });
|
|
3521
3539
|
}
|
|
3522
|
-
function
|
|
3523
|
-
var
|
|
3524
|
-
const [
|
|
3540
|
+
function ha({ template: a, setTemplate: s }) {
|
|
3541
|
+
var y;
|
|
3542
|
+
const [n, i] = B(null), [c, o] = B(!1), [l, v] = B({
|
|
3525
3543
|
text: "",
|
|
3526
3544
|
value: "",
|
|
3527
3545
|
urlType: "static"
|
|
3528
|
-
}),
|
|
3529
|
-
quickReply: a.buttons.filter((
|
|
3530
|
-
url: a.buttons.filter((
|
|
3531
|
-
call: a.buttons.filter((
|
|
3532
|
-
flow: a.buttons.filter((
|
|
3533
|
-
},
|
|
3534
|
-
|
|
3535
|
-
},
|
|
3546
|
+
}), h = {
|
|
3547
|
+
quickReply: a.buttons.filter((t) => t.type === "QUICK_REPLY").length,
|
|
3548
|
+
url: a.buttons.filter((t) => t.type === "URL").length,
|
|
3549
|
+
call: a.buttons.filter((t) => t.type === "CALL").length,
|
|
3550
|
+
flow: a.buttons.filter((t) => t.type === "FLOW").length
|
|
3551
|
+
}, k = () => {
|
|
3552
|
+
v({ text: "", value: "", urlType: "static" }), i(null), o(!1);
|
|
3553
|
+
}, V = (t) => {
|
|
3536
3554
|
if (!l.text.trim()) return;
|
|
3537
|
-
let
|
|
3538
|
-
|
|
3539
|
-
const
|
|
3555
|
+
let x = t === "QUICK_REPLY" ? l.text : l.value;
|
|
3556
|
+
t === "CALL" && x && !x.startsWith("+") && (x = "+" + x);
|
|
3557
|
+
const p = {
|
|
3540
3558
|
id: Math.random().toString(36).substr(2, 9),
|
|
3541
|
-
type:
|
|
3559
|
+
type: t,
|
|
3542
3560
|
text: l.text,
|
|
3543
|
-
value:
|
|
3544
|
-
urlType:
|
|
3561
|
+
value: x,
|
|
3562
|
+
urlType: t === "URL" ? l.urlType : void 0
|
|
3545
3563
|
};
|
|
3546
3564
|
s({
|
|
3547
3565
|
...a,
|
|
3548
|
-
buttons: [...a.buttons,
|
|
3549
|
-
}),
|
|
3550
|
-
},
|
|
3566
|
+
buttons: [...a.buttons, p]
|
|
3567
|
+
}), k();
|
|
3568
|
+
}, d = (t) => {
|
|
3551
3569
|
s({
|
|
3552
3570
|
...a,
|
|
3553
|
-
buttons: a.buttons.filter((
|
|
3571
|
+
buttons: a.buttons.filter((x) => x.id !== t)
|
|
3554
3572
|
});
|
|
3555
|
-
},
|
|
3556
|
-
const
|
|
3557
|
-
let
|
|
3558
|
-
|
|
3573
|
+
}, N = (t, x, p) => {
|
|
3574
|
+
const w = a.buttons.find((f) => f.id === t), A = x === "text" ? 25 : x === "value" && (w == null ? void 0 : w.type) === "URL" ? 2e3 : 20;
|
|
3575
|
+
let R = p.slice(0, A);
|
|
3576
|
+
x === "value" && (w == null ? void 0 : w.type) === "CALL" && R && !R.startsWith("+") && (R = "+" + R), s({
|
|
3559
3577
|
...a,
|
|
3560
3578
|
buttons: a.buttons.map(
|
|
3561
|
-
(
|
|
3579
|
+
(f) => f.id === t ? { ...f, [x]: R } : f
|
|
3562
3580
|
)
|
|
3563
3581
|
});
|
|
3564
3582
|
}, M = () => {
|
|
3565
|
-
const
|
|
3566
|
-
...a.buttons.filter((
|
|
3583
|
+
const x = [
|
|
3584
|
+
...a.buttons.filter((w) => w.type === "URL" && w.urlType === "dynamic").map((w) => w.value || ""),
|
|
3567
3585
|
l.value
|
|
3568
3586
|
// Include current form input
|
|
3569
3587
|
].join(" ").match(/{{\d+}}/g);
|
|
3570
|
-
if (!
|
|
3571
|
-
const
|
|
3572
|
-
const
|
|
3573
|
-
return
|
|
3588
|
+
if (!x) return 0;
|
|
3589
|
+
const p = x.map((w) => {
|
|
3590
|
+
const A = w.match(/{{(\d+)}}/);
|
|
3591
|
+
return A ? parseInt(A[1], 10) : 0;
|
|
3574
3592
|
});
|
|
3575
|
-
return
|
|
3576
|
-
},
|
|
3593
|
+
return p.length > 0 ? Math.max(...p) : 0;
|
|
3594
|
+
}, b = [
|
|
3577
3595
|
{
|
|
3578
3596
|
type: "QUICK_REPLY",
|
|
3579
3597
|
icon: me,
|
|
3580
3598
|
label: "Quick Reply",
|
|
3581
3599
|
description: "Add quick response options",
|
|
3582
3600
|
limit: 10,
|
|
3583
|
-
current:
|
|
3601
|
+
current: h.quickReply,
|
|
3584
3602
|
color: "blue"
|
|
3585
3603
|
},
|
|
3586
3604
|
{
|
|
3587
3605
|
type: "URL",
|
|
3588
|
-
icon:
|
|
3606
|
+
icon: qe,
|
|
3589
3607
|
label: "Web URL",
|
|
3590
3608
|
description: "Link to websites or pages",
|
|
3591
3609
|
limit: 2,
|
|
3592
|
-
current:
|
|
3610
|
+
current: h.url,
|
|
3593
3611
|
color: "green"
|
|
3594
3612
|
},
|
|
3595
3613
|
{
|
|
3596
3614
|
type: "CALL",
|
|
3597
|
-
icon:
|
|
3615
|
+
icon: Ve,
|
|
3598
3616
|
label: "Call Button",
|
|
3599
3617
|
description: "Add phone number to call",
|
|
3600
3618
|
limit: 1,
|
|
3601
|
-
current:
|
|
3619
|
+
current: h.call,
|
|
3602
3620
|
color: "purple"
|
|
3603
3621
|
}
|
|
3604
3622
|
// {
|
|
@@ -3623,45 +3641,45 @@ function ua({ template: a, setTemplate: s }) {
|
|
|
3623
3641
|
/* @__PURE__ */ e("div", { className: "rsp-flex-shrink-0", children: /* @__PURE__ */ e("svg", { className: "rsp-h-5 rsp-w-5 rsp-text-blue-400", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ e("path", { fillRule: "evenodd", d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z", clipRule: "evenodd" }) }) }),
|
|
3624
3642
|
/* @__PURE__ */ e("div", { className: "rsp-ml-3", children: /* @__PURE__ */ e("p", { className: "rsp-text-sm rsp-text-blue-700", children: "We recommend adding the marketing opt-out button. This can help reduce blocks from customers and increase your quality rating." }) })
|
|
3625
3643
|
] }) }),
|
|
3626
|
-
!
|
|
3627
|
-
const
|
|
3644
|
+
!n && /* @__PURE__ */ e("div", { className: "rsp-grid rsp-grid-cols-1 md:rsp-grid-cols-2 rsp-gap-4", children: b.map((t) => {
|
|
3645
|
+
const x = t.icon, p = t.current >= t.limit;
|
|
3628
3646
|
return /* @__PURE__ */ e(
|
|
3629
3647
|
"button",
|
|
3630
3648
|
{
|
|
3631
|
-
onClick: () => !
|
|
3632
|
-
disabled:
|
|
3633
|
-
className: `rsp-p-4 rsp-border-2 rsp-rounded-xl rsp-text-left rsp-transition-all rsp-duration-200 ${
|
|
3649
|
+
onClick: () => !p && i(t.type),
|
|
3650
|
+
disabled: p,
|
|
3651
|
+
className: `rsp-p-4 rsp-border-2 rsp-rounded-xl rsp-text-left rsp-transition-all rsp-duration-200 ${p ? "rsp-border-gray-200 rsp-bg-gray-50 rsp-text-gray-400 rsp-cursor-not-allowed rsp-opacity-60" : "rsp-cursor-pointer rsp-transform rsp-shadow-sm hover:rsp-shadow-md"}`,
|
|
3634
3652
|
children: /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-start rsp-justify-between", children: [
|
|
3635
3653
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-3", children: [
|
|
3636
|
-
/* @__PURE__ */ e("div", { className: `rsp-p-2 rsp-rounded-lg ${
|
|
3654
|
+
/* @__PURE__ */ e("div", { className: `rsp-p-2 rsp-rounded-lg ${p ? "rsp-bg-gray-200" : "rsp-bg-white rsp-shadow-sm"}`, children: /* @__PURE__ */ e(x, { className: "rsp-w-5 rsp-h-5" }) }),
|
|
3637
3655
|
/* @__PURE__ */ r("div", { children: [
|
|
3638
|
-
/* @__PURE__ */ e("h4", { className: "rsp-font-semibold rsp-text-sm", children:
|
|
3639
|
-
/* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-opacity-80 rsp-mt-1", children:
|
|
3656
|
+
/* @__PURE__ */ e("h4", { className: "rsp-font-semibold rsp-text-sm", children: t.label }),
|
|
3657
|
+
/* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-opacity-80 rsp-mt-1", children: t.description })
|
|
3640
3658
|
] })
|
|
3641
3659
|
] }),
|
|
3642
3660
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2", children: [
|
|
3643
3661
|
/* @__PURE__ */ r("span", { className: "rsp-text-xs rsp-font-medium rsp-px-2 rsp-py-1 rsp-rounded-full rsp-bg-white rsp-bg-opacity-70", children: [
|
|
3644
|
-
|
|
3662
|
+
t.current,
|
|
3645
3663
|
"/",
|
|
3646
|
-
|
|
3664
|
+
t.limit
|
|
3647
3665
|
] }),
|
|
3648
|
-
!
|
|
3666
|
+
!p && /* @__PURE__ */ e(he, { className: "rsp-w-4 rsp-h-4" })
|
|
3649
3667
|
] })
|
|
3650
3668
|
] })
|
|
3651
3669
|
},
|
|
3652
|
-
|
|
3670
|
+
t.type
|
|
3653
3671
|
);
|
|
3654
3672
|
}) }),
|
|
3655
|
-
|
|
3673
|
+
n && /* @__PURE__ */ r("div", { className: "rsp-bg-gradient-to-br rsp-from-gray-50 rsp-to-gray-100 rsp-border rsp-border-gray-200 rsp-rounded-xl rsp-p-6 rsp-shadow-sm", children: [
|
|
3656
3674
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-justify-between rsp-mb-4", children: [
|
|
3657
3675
|
/* @__PURE__ */ r("h4", { className: "rsp-text-lg rsp-font-semibold rsp-text-gray-900", children: [
|
|
3658
3676
|
"Add ",
|
|
3659
|
-
(
|
|
3677
|
+
(y = b.find((t) => t.type === n)) == null ? void 0 : y.label
|
|
3660
3678
|
] }),
|
|
3661
3679
|
/* @__PURE__ */ e(
|
|
3662
3680
|
"button",
|
|
3663
3681
|
{
|
|
3664
|
-
onClick:
|
|
3682
|
+
onClick: k,
|
|
3665
3683
|
className: "rsp-p-2 rsp-text-gray-400 hover:rsp-text-gray-600 hover:rsp-bg-white rsp-rounded-lg rsp-transition-colors",
|
|
3666
3684
|
children: /* @__PURE__ */ e(re, { className: "rsp-w-5 rsp-h-5" })
|
|
3667
3685
|
}
|
|
@@ -3676,7 +3694,7 @@ function ua({ template: a, setTemplate: s }) {
|
|
|
3676
3694
|
{
|
|
3677
3695
|
type: "text",
|
|
3678
3696
|
value: l.text,
|
|
3679
|
-
onChange: (
|
|
3697
|
+
onChange: (t) => v({ ...l, text: t.target.value.slice(0, 25) }),
|
|
3680
3698
|
className: "rsp-w-full rsp-px-4 rsp-py-3 rsp-border rsp-border-gray-300 rsp-rounded-lg rsp-bg-white rsp-text-sm focus:rsp-outline-none focus:rsp-ring-2 focus:rsp-ring-blue-500 focus:rsp-border-transparent rsp-shadow-sm",
|
|
3681
3699
|
placeholder: "Enter button text (max 25 characters)",
|
|
3682
3700
|
maxLength: 25
|
|
@@ -3688,9 +3706,9 @@ function ua({ template: a, setTemplate: s }) {
|
|
|
3688
3706
|
] })
|
|
3689
3707
|
] })
|
|
3690
3708
|
] }),
|
|
3691
|
-
|
|
3692
|
-
/* @__PURE__ */ e("label", { className: "rsp-block rsp-text-sm rsp-font-medium rsp-text-gray-700 rsp-mb-2", children:
|
|
3693
|
-
|
|
3709
|
+
n !== "QUICK_REPLY" && /* @__PURE__ */ r("div", { children: [
|
|
3710
|
+
/* @__PURE__ */ e("label", { className: "rsp-block rsp-text-sm rsp-font-medium rsp-text-gray-700 rsp-mb-2", children: n === "URL" ? "Website URL" : n === "CALL" ? "Phone Number" : "Flow ID" }),
|
|
3711
|
+
n === "URL" && /* @__PURE__ */ r("div", { className: "rsp-mb-3", children: [
|
|
3694
3712
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-gap-4", children: [
|
|
3695
3713
|
/* @__PURE__ */ r("label", { className: "rsp-flex rsp-items-center rsp-cursor-pointer", children: [
|
|
3696
3714
|
/* @__PURE__ */ e(
|
|
@@ -3698,7 +3716,7 @@ function ua({ template: a, setTemplate: s }) {
|
|
|
3698
3716
|
{
|
|
3699
3717
|
type: "radio",
|
|
3700
3718
|
checked: l.urlType === "static",
|
|
3701
|
-
onChange: () =>
|
|
3719
|
+
onChange: () => v({ ...l, urlType: "static" }),
|
|
3702
3720
|
className: "rsp-mr-2 rsp-text-blue-600"
|
|
3703
3721
|
}
|
|
3704
3722
|
),
|
|
@@ -3710,7 +3728,7 @@ function ua({ template: a, setTemplate: s }) {
|
|
|
3710
3728
|
{
|
|
3711
3729
|
type: "radio",
|
|
3712
3730
|
checked: l.urlType === "dynamic",
|
|
3713
|
-
onChange: () =>
|
|
3731
|
+
onChange: () => v({ ...l, urlType: "dynamic" }),
|
|
3714
3732
|
className: "rsp-mr-2 rsp-text-blue-600"
|
|
3715
3733
|
}
|
|
3716
3734
|
),
|
|
@@ -3731,32 +3749,32 @@ function ua({ template: a, setTemplate: s }) {
|
|
|
3731
3749
|
/* @__PURE__ */ e(
|
|
3732
3750
|
"input",
|
|
3733
3751
|
{
|
|
3734
|
-
type:
|
|
3752
|
+
type: n === "CALL" ? "tel" : n === "URL" ? "url" : "text",
|
|
3735
3753
|
value: l.value,
|
|
3736
|
-
onChange: (
|
|
3737
|
-
const
|
|
3738
|
-
|
|
3754
|
+
onChange: (t) => {
|
|
3755
|
+
const x = n === "URL" ? 2e3 : 20;
|
|
3756
|
+
v({ ...l, value: t.target.value.slice(0, x) });
|
|
3739
3757
|
},
|
|
3740
3758
|
className: "rsp-w-full rsp-px-4 rsp-py-3 rsp-border rsp-border-gray-300 rsp-rounded-lg rsp-bg-white rsp-text-sm focus:rsp-outline-none focus:rsp-ring-2 focus:rsp-ring-blue-500 focus:rsp-border-transparent rsp-shadow-sm",
|
|
3741
|
-
placeholder:
|
|
3742
|
-
maxLength:
|
|
3759
|
+
placeholder: n === "URL" ? l.urlType === "dynamic" ? "https://example.com/order/{{1}}?user={{2}}" : "https://example.com" : n === "CALL" ? "+1234567890" : "Flow ID",
|
|
3760
|
+
maxLength: n === "URL" ? 2e3 : 20
|
|
3743
3761
|
}
|
|
3744
3762
|
),
|
|
3745
3763
|
/* @__PURE__ */ r("span", { className: "rsp-absolute rsp-right-3 rsp-top-1/2 rsp-transform -rsp-translate-y-1/2 rsp-text-xs rsp-text-gray-400", children: [
|
|
3746
3764
|
l.value.length,
|
|
3747
3765
|
"/",
|
|
3748
|
-
|
|
3766
|
+
n === "URL" ? 2e3 : 20
|
|
3749
3767
|
] })
|
|
3750
3768
|
] }),
|
|
3751
|
-
|
|
3769
|
+
n === "URL" && l.urlType === "dynamic" && /* @__PURE__ */ r("div", { className: "rsp-mt-3", children: [
|
|
3752
3770
|
/* @__PURE__ */ e("div", { className: "rsp-flex rsp-items-center rsp-gap-2 rsp-mb-2", children: /* @__PURE__ */ e(
|
|
3753
3771
|
"button",
|
|
3754
3772
|
{
|
|
3755
3773
|
type: "button",
|
|
3756
3774
|
onClick: () => {
|
|
3757
3775
|
if ((l.value.match(/\{\{(\d+)\}\}/g) || []).length >= 3) return;
|
|
3758
|
-
const
|
|
3759
|
-
|
|
3776
|
+
const p = M() + 1, w = l.value + `{{${p}}}`;
|
|
3777
|
+
v({ ...l, value: w }), o(!0);
|
|
3760
3778
|
},
|
|
3761
3779
|
disabled: (l.value.match(/\{\{(\d+)\}\}/g) || []).length >= 3,
|
|
3762
3780
|
className: "rsp-px-2 rsp-py-2 rsp-text-xs rsp-bg-gray-300 hover:rsp-bg-gray-200 rsp-rounded rsp-text-gray-700 disabled:rsp-bg-gray-200 disabled:rsp-text-gray-500",
|
|
@@ -3764,41 +3782,41 @@ function ua({ template: a, setTemplate: s }) {
|
|
|
3764
3782
|
}
|
|
3765
3783
|
) }),
|
|
3766
3784
|
(l.value.match(/\{\{(\d+)\}\}/g) || []).length >= 3 && /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-500 rsp-mt-1", children: "Maximum 3 variables allowed." }),
|
|
3767
|
-
|
|
3785
|
+
c && /* @__PURE__ */ r("div", { className: "rsp-mt-4 rsp-p-4 rsp-bg-gray-50 rsp-rounded-lg rsp-border", children: [
|
|
3768
3786
|
/* @__PURE__ */ e("h4", { className: "rsp-text-sm rsp-font-medium rsp-text-gray-700 rsp-mb-3", children: "Sample Values for URL Variables" }),
|
|
3769
3787
|
/* @__PURE__ */ e("div", { className: "rsp-space-y-3", children: (() => {
|
|
3770
|
-
const
|
|
3771
|
-
return [...new Set(
|
|
3772
|
-
var
|
|
3788
|
+
const t = l.value.match(/\{\{(\d+)\}\}/g) || [];
|
|
3789
|
+
return [...new Set(t.map((p) => p.replace(/[{}]/g, "")))].map((p) => {
|
|
3790
|
+
var w, A;
|
|
3773
3791
|
return /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2", children: [
|
|
3774
3792
|
/* @__PURE__ */ r("label", { className: "rsp-text-sm rsp-text-gray-600 rsp-whitespace-nowrap", children: [
|
|
3775
3793
|
"Variable {{",
|
|
3776
|
-
|
|
3794
|
+
p,
|
|
3777
3795
|
"}}"
|
|
3778
3796
|
] }),
|
|
3779
3797
|
/* @__PURE__ */ e(
|
|
3780
3798
|
"input",
|
|
3781
3799
|
{
|
|
3782
3800
|
type: "text",
|
|
3783
|
-
value: ((
|
|
3784
|
-
onChange: (
|
|
3785
|
-
var
|
|
3786
|
-
const
|
|
3801
|
+
value: ((A = (w = a.sampleContent) == null ? void 0 : w.buttonVariables) == null ? void 0 : A[p]) || "",
|
|
3802
|
+
onChange: (R) => {
|
|
3803
|
+
var C, U, O;
|
|
3804
|
+
const f = {
|
|
3787
3805
|
...a.sampleContent,
|
|
3788
|
-
headerVariables: ((
|
|
3789
|
-
bodyVariables: ((
|
|
3806
|
+
headerVariables: ((C = a.sampleContent) == null ? void 0 : C.headerVariables) || {},
|
|
3807
|
+
bodyVariables: ((U = a.sampleContent) == null ? void 0 : U.bodyVariables) || {},
|
|
3790
3808
|
buttonVariables: {
|
|
3791
3809
|
...(O = a.sampleContent) == null ? void 0 : O.buttonVariables,
|
|
3792
|
-
[
|
|
3810
|
+
[p]: R.target.value
|
|
3793
3811
|
}
|
|
3794
3812
|
};
|
|
3795
3813
|
s({
|
|
3796
3814
|
...a,
|
|
3797
|
-
sampleContent:
|
|
3815
|
+
sampleContent: f
|
|
3798
3816
|
});
|
|
3799
3817
|
},
|
|
3800
3818
|
className: "rsp-flex-1 rsp-px-3 rsp-py-2 rsp-border rsp-border-gray-300 rsp-rounded-md rsp-text-sm focus:rsp-outline-none focus:rsp-ring-1 focus:rsp-ring-blue-500 focus:rsp-border-blue-500",
|
|
3801
|
-
placeholder: `Sample value (e.g., ${
|
|
3819
|
+
placeholder: `Sample value (e.g., ${p === "1" ? "order123" : "user456"})`
|
|
3802
3820
|
}
|
|
3803
3821
|
),
|
|
3804
3822
|
/* @__PURE__ */ e(
|
|
@@ -3806,17 +3824,17 @@ function ua({ template: a, setTemplate: s }) {
|
|
|
3806
3824
|
{
|
|
3807
3825
|
type: "button",
|
|
3808
3826
|
onClick: () => {
|
|
3809
|
-
var
|
|
3810
|
-
const
|
|
3811
|
-
|
|
3812
|
-
const
|
|
3827
|
+
var U, O, P;
|
|
3828
|
+
const R = new RegExp(`\\{\\{${p}\\}\\}`, "g"), f = (l.value || "").replace(R, "");
|
|
3829
|
+
v({ ...l, value: f });
|
|
3830
|
+
const C = Object.fromEntries(Object.entries(((U = a.sampleContent) == null ? void 0 : U.buttonVariables) || {}).filter(([H]) => H !== p));
|
|
3813
3831
|
s({
|
|
3814
3832
|
...a,
|
|
3815
3833
|
sampleContent: {
|
|
3816
3834
|
...a.sampleContent,
|
|
3817
3835
|
headerVariables: ((O = a.sampleContent) == null ? void 0 : O.headerVariables) || {},
|
|
3818
|
-
bodyVariables: ((
|
|
3819
|
-
buttonVariables:
|
|
3836
|
+
bodyVariables: ((P = a.sampleContent) == null ? void 0 : P.bodyVariables) || {},
|
|
3837
|
+
buttonVariables: C
|
|
3820
3838
|
}
|
|
3821
3839
|
});
|
|
3822
3840
|
},
|
|
@@ -3825,16 +3843,16 @@ function ua({ template: a, setTemplate: s }) {
|
|
|
3825
3843
|
children: "×"
|
|
3826
3844
|
}
|
|
3827
3845
|
)
|
|
3828
|
-
] }, `sample-${
|
|
3846
|
+
] }, `sample-${p}`);
|
|
3829
3847
|
});
|
|
3830
3848
|
})() }),
|
|
3831
3849
|
/* @__PURE__ */ r("div", { className: "rsp-mt-4 rsp-p-3 rsp-bg-white rsp-rounded-lg rsp-border", children: [
|
|
3832
3850
|
/* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-font-medium rsp-text-gray-700 rsp-mb-1", children: "Preview URL:" }),
|
|
3833
3851
|
/* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-600 rsp-font-mono rsp-break-all", children: l.value.replace(
|
|
3834
3852
|
/\{\{(\d+)\}\}/g,
|
|
3835
|
-
(
|
|
3836
|
-
var
|
|
3837
|
-
return ((
|
|
3853
|
+
(t, x) => {
|
|
3854
|
+
var p, w;
|
|
3855
|
+
return ((w = (p = a.sampleContent) == null ? void 0 : p.buttonVariables) == null ? void 0 : w[x]) || `[${t}]`;
|
|
3838
3856
|
}
|
|
3839
3857
|
) })
|
|
3840
3858
|
] }),
|
|
@@ -3842,7 +3860,7 @@ function ua({ template: a, setTemplate: s }) {
|
|
|
3842
3860
|
"button",
|
|
3843
3861
|
{
|
|
3844
3862
|
type: "button",
|
|
3845
|
-
onClick: () =>
|
|
3863
|
+
onClick: () => o(!1),
|
|
3846
3864
|
className: "rsp-px-3 rsp-py-1 rsp-text-xs rsp-text-gray-500 hover:rsp-text-gray-700",
|
|
3847
3865
|
children: "Close"
|
|
3848
3866
|
}
|
|
@@ -3854,8 +3872,8 @@ function ua({ template: a, setTemplate: s }) {
|
|
|
3854
3872
|
/* @__PURE__ */ e(
|
|
3855
3873
|
"button",
|
|
3856
3874
|
{
|
|
3857
|
-
onClick: () =>
|
|
3858
|
-
disabled: !l.text.trim() ||
|
|
3875
|
+
onClick: () => V(n),
|
|
3876
|
+
disabled: !l.text.trim() || n !== "QUICK_REPLY" && !l.value.trim(),
|
|
3859
3877
|
className: "rsp-flex-1 rsp-bg-blue-600 rsp-text-white rsp-py-3 rsp-px-4 rsp-rounded-lg rsp-font-medium rsp-text-sm rsp-transition-colors hover:rsp-bg-blue-700 disabled:rsp-opacity-50 disabled:rsp-cursor-not-allowed rsp-shadow-sm",
|
|
3860
3878
|
children: "Add Button"
|
|
3861
3879
|
}
|
|
@@ -3863,7 +3881,7 @@ function ua({ template: a, setTemplate: s }) {
|
|
|
3863
3881
|
/* @__PURE__ */ e(
|
|
3864
3882
|
"button",
|
|
3865
3883
|
{
|
|
3866
|
-
onClick:
|
|
3884
|
+
onClick: k,
|
|
3867
3885
|
className: "rsp-px-4 rsp-py-3 rsp-text-gray-600 rsp-bg-white rsp-border rsp-border-gray-300 rsp-rounded-lg rsp-font-medium rsp-text-sm rsp-transition-colors hover:rsp-bg-gray-50 rsp-shadow-sm",
|
|
3868
3886
|
children: "Cancel"
|
|
3869
3887
|
}
|
|
@@ -3873,17 +3891,17 @@ function ua({ template: a, setTemplate: s }) {
|
|
|
3873
3891
|
] }),
|
|
3874
3892
|
a.buttons.length > 0 && /* @__PURE__ */ r("div", { className: "rsp-space-y-4", children: [
|
|
3875
3893
|
/* @__PURE__ */ e("h4", { className: "rsp-text-md rsp-font-semibold rsp-text-gray-900", children: "Added Buttons" }),
|
|
3876
|
-
/* @__PURE__ */ e("div", { className: "rsp-space-y-3", children: a.buttons.map((
|
|
3877
|
-
const
|
|
3894
|
+
/* @__PURE__ */ e("div", { className: "rsp-space-y-3", children: a.buttons.map((t) => {
|
|
3895
|
+
const x = b.find((w) => w.type === t.type), p = (x == null ? void 0 : x.icon) || me;
|
|
3878
3896
|
return /* @__PURE__ */ e("div", { className: "rsp-bg-white rsp-border rsp-border-gray-200 rsp-rounded-lg rsp-p-4 rsp-shadow-sm", children: /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-start rsp-gap-3", children: [
|
|
3879
|
-
/* @__PURE__ */ e("div", { className: "rsp-p-2 rsp-bg-gray-50 rsp-rounded-lg", children: /* @__PURE__ */ e(
|
|
3897
|
+
/* @__PURE__ */ e("div", { className: "rsp-p-2 rsp-bg-gray-50 rsp-rounded-lg", children: /* @__PURE__ */ e(p, { className: "rsp-w-4 rsp-h-4 rsp-text-gray-600" }) }),
|
|
3880
3898
|
/* @__PURE__ */ r("div", { className: "rsp-flex-1 rsp-space-y-3", children: [
|
|
3881
3899
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-justify-between", children: [
|
|
3882
|
-
/* @__PURE__ */ e("span", { className: "rsp-text-xs rsp-font-medium rsp-text-gray-500 rsp-uppercase rsp-tracking-wider", children:
|
|
3900
|
+
/* @__PURE__ */ e("span", { className: "rsp-text-xs rsp-font-medium rsp-text-gray-500 rsp-uppercase rsp-tracking-wider", children: t.type.replace("_", " ") }),
|
|
3883
3901
|
/* @__PURE__ */ e(
|
|
3884
3902
|
"button",
|
|
3885
3903
|
{
|
|
3886
|
-
onClick: () =>
|
|
3904
|
+
onClick: () => d(t.id),
|
|
3887
3905
|
className: "rsp-p-1 rsp-text-red-400 hover:rsp-text-red-600 hover:rsp-bg-red-50 rsp-rounded rsp-transition-colors",
|
|
3888
3906
|
children: /* @__PURE__ */ e(re, { className: "rsp-w-4 rsp-h-4" })
|
|
3889
3907
|
}
|
|
@@ -3897,44 +3915,44 @@ function ua({ template: a, setTemplate: s }) {
|
|
|
3897
3915
|
"input",
|
|
3898
3916
|
{
|
|
3899
3917
|
type: "text",
|
|
3900
|
-
value:
|
|
3901
|
-
onChange: (
|
|
3918
|
+
value: t.text,
|
|
3919
|
+
onChange: (w) => N(t.id, "text", w.target.value),
|
|
3902
3920
|
maxLength: 25,
|
|
3903
3921
|
className: "rsp-w-full rsp-px-3 rsp-py-2 rsp-border rsp-border-gray-300 rsp-rounded-md rsp-text-sm focus:rsp-outline-none focus:rsp-ring-1 focus:rsp-ring-blue-500 focus:rsp-border-blue-500"
|
|
3904
3922
|
}
|
|
3905
3923
|
),
|
|
3906
3924
|
/* @__PURE__ */ r("span", { className: "rsp-absolute rsp-right-2 rsp-top-1/2 rsp-transform -rsp-translate-y-1/2 rsp-text-xs rsp-text-gray-400", children: [
|
|
3907
|
-
|
|
3925
|
+
t.text.length,
|
|
3908
3926
|
"/25"
|
|
3909
3927
|
] })
|
|
3910
3928
|
] })
|
|
3911
3929
|
] }),
|
|
3912
|
-
|
|
3913
|
-
/* @__PURE__ */ e("label", { className: "rsp-block rsp-text-xs rsp-font-medium rsp-text-gray-600 rsp-mb-1", children:
|
|
3930
|
+
t.type !== "QUICK_REPLY" && /* @__PURE__ */ r("div", { children: [
|
|
3931
|
+
/* @__PURE__ */ e("label", { className: "rsp-block rsp-text-xs rsp-font-medium rsp-text-gray-600 rsp-mb-1", children: t.type === "URL" ? "Website URL" : t.type === "CALL" ? "Phone Number" : "Flow ID" }),
|
|
3914
3932
|
/* @__PURE__ */ r("div", { className: "rsp-relative", children: [
|
|
3915
3933
|
/* @__PURE__ */ e(
|
|
3916
3934
|
"input",
|
|
3917
3935
|
{
|
|
3918
|
-
type:
|
|
3919
|
-
value:
|
|
3920
|
-
onChange: (
|
|
3921
|
-
maxLength:
|
|
3936
|
+
type: t.type === "CALL" ? "tel" : t.type === "URL" ? "url" : "text",
|
|
3937
|
+
value: t.value || "",
|
|
3938
|
+
onChange: (w) => N(t.id, "value", w.target.value),
|
|
3939
|
+
maxLength: t.type === "URL" ? 2e3 : 20,
|
|
3922
3940
|
className: "rsp-w-full rsp-px-3 rsp-py-2 rsp-border rsp-border-gray-300 rsp-rounded-md rsp-text-sm focus:rsp-outline-none focus:rsp-ring-1 focus:rsp-ring-blue-500 focus:rsp-border-blue-500"
|
|
3923
3941
|
}
|
|
3924
3942
|
),
|
|
3925
3943
|
/* @__PURE__ */ r("span", { className: "rsp-absolute rsp-right-2 rsp-top-1/2 rsp-transform -rsp-translate-y-1/2 rsp-text-xs rsp-text-gray-400", children: [
|
|
3926
|
-
(
|
|
3944
|
+
(t.value || "").length,
|
|
3927
3945
|
"/",
|
|
3928
|
-
|
|
3946
|
+
t.type === "URL" ? 2e3 : 20
|
|
3929
3947
|
] })
|
|
3930
3948
|
] })
|
|
3931
3949
|
] })
|
|
3932
3950
|
] })
|
|
3933
3951
|
] })
|
|
3934
|
-
] }) },
|
|
3952
|
+
] }) }, t.id);
|
|
3935
3953
|
}) })
|
|
3936
3954
|
] }),
|
|
3937
|
-
a.buttons.length === 0 && !
|
|
3955
|
+
a.buttons.length === 0 && !n && /* @__PURE__ */ r("div", { className: "rsp-text-center rsp-py-12 rsp-bg-gray-50 rsp-rounded-xl rsp-border-2 rsp-border-dashed rsp-border-gray-300", children: [
|
|
3938
3956
|
/* @__PURE__ */ e("div", { className: "rsp-w-16 rsp-h-16 rsp-bg-white rsp-rounded-full rsp-flex rsp-items-center rsp-justify-center rsp-mx-auto rsp-mb-4 rsp-shadow-sm", children: /* @__PURE__ */ e(me, { className: "rsp-w-8 rsp-h-8 rsp-text-gray-400" }) }),
|
|
3939
3957
|
/* @__PURE__ */ e("h3", { className: "rsp-text-lg rsp-font-medium rsp-text-gray-900 rsp-mb-2", children: "No buttons added yet" }),
|
|
3940
3958
|
/* @__PURE__ */ e("p", { className: "rsp-text-gray-500 rsp-text-sm rsp-mb-4", children: "Add interactive buttons to make your message more engaging" }),
|
|
@@ -3942,32 +3960,32 @@ function ua({ template: a, setTemplate: s }) {
|
|
|
3942
3960
|
] })
|
|
3943
3961
|
] });
|
|
3944
3962
|
}
|
|
3945
|
-
const
|
|
3963
|
+
const ua = async (a) => {
|
|
3946
3964
|
try {
|
|
3947
3965
|
if (!a)
|
|
3948
3966
|
throw new Error("No file provided");
|
|
3949
3967
|
const s = 100 * 1024 * 1024;
|
|
3950
3968
|
if (a.size > s)
|
|
3951
3969
|
throw new Error(`File size too large. Maximum allowed size is ${s / (1024 * 1024)}MB`);
|
|
3952
|
-
const
|
|
3953
|
-
|
|
3954
|
-
const
|
|
3970
|
+
const n = new FormData();
|
|
3971
|
+
n.append("file", a), console.log("Uploading file:", a.name, "Size:", a.size, "Type:", a.type);
|
|
3972
|
+
const i = await fetch("https://wiz.resul.io/Communication/UploadDocuments", {
|
|
3955
3973
|
method: "POST",
|
|
3956
|
-
body:
|
|
3974
|
+
body: n
|
|
3957
3975
|
});
|
|
3958
|
-
console.log("Upload response status:",
|
|
3959
|
-
const
|
|
3960
|
-
console.log("Raw upload response:",
|
|
3961
|
-
let
|
|
3976
|
+
console.log("Upload response status:", i.status), console.log("Upload response headers:", Object.fromEntries(i.headers.entries()));
|
|
3977
|
+
const c = await i.text();
|
|
3978
|
+
console.log("Raw upload response:", c);
|
|
3979
|
+
let o;
|
|
3962
3980
|
try {
|
|
3963
|
-
|
|
3981
|
+
o = JSON.parse(c);
|
|
3964
3982
|
} catch (l) {
|
|
3965
3983
|
throw console.error("Failed to parse upload response:", l), new Error("Invalid response from upload server");
|
|
3966
3984
|
}
|
|
3967
|
-
if (console.log("Parsed upload response:",
|
|
3968
|
-
throw new Error(
|
|
3969
|
-
if (
|
|
3970
|
-
const l =
|
|
3985
|
+
if (console.log("Parsed upload response:", o), console.log("Upload status:", o.status), console.log("Upload message:", o.message), console.log("Upload data:", o.data), !o.status)
|
|
3986
|
+
throw new Error(o.message || "Upload failed");
|
|
3987
|
+
if (o.data && Array.isArray(o.data) && o.data.length > 0) {
|
|
3988
|
+
const l = o.data[0];
|
|
3971
3989
|
if (l.url)
|
|
3972
3990
|
return console.log("File uploaded successfully:", {
|
|
3973
3991
|
url: l.url,
|
|
@@ -3981,19 +3999,19 @@ const ba = async (a) => {
|
|
|
3981
3999
|
} catch (s) {
|
|
3982
4000
|
throw console.error("File upload error:", s), s instanceof Error ? s : new Error("Unknown error occurred during file upload");
|
|
3983
4001
|
}
|
|
3984
|
-
},
|
|
3985
|
-
const
|
|
4002
|
+
}, ba = (a, s) => {
|
|
4003
|
+
const i = a.name.toLowerCase().split(".").pop();
|
|
3986
4004
|
switch (s) {
|
|
3987
4005
|
case "IMAGE":
|
|
3988
|
-
return ["jpg", "jpeg", "png", "gif", "bmp", "tiff", "svg"].includes(
|
|
4006
|
+
return ["jpg", "jpeg", "png", "gif", "bmp", "tiff", "svg"].includes(i || "");
|
|
3989
4007
|
case "VIDEO":
|
|
3990
|
-
return ["mp4", "mov", "avi", "3gpp"].includes(
|
|
4008
|
+
return ["mp4", "mov", "avi", "3gpp"].includes(i || "");
|
|
3991
4009
|
case "DOCUMENT":
|
|
3992
|
-
return ["pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "txt"].includes(
|
|
4010
|
+
return ["pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "txt"].includes(i || "");
|
|
3993
4011
|
default:
|
|
3994
4012
|
return !1;
|
|
3995
4013
|
}
|
|
3996
|
-
},
|
|
4014
|
+
}, ga = (a) => {
|
|
3997
4015
|
switch (a) {
|
|
3998
4016
|
case "IMAGE":
|
|
3999
4017
|
return 5 * 1024 * 1024;
|
|
@@ -4005,14 +4023,14 @@ const ba = async (a) => {
|
|
|
4005
4023
|
return 10 * 1024 * 1024;
|
|
4006
4024
|
}
|
|
4007
4025
|
};
|
|
4008
|
-
function
|
|
4009
|
-
var
|
|
4010
|
-
const [
|
|
4011
|
-
var
|
|
4026
|
+
function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
4027
|
+
var C, U, O, P, H;
|
|
4028
|
+
const [i, c] = X.useState({}), [, o] = X.useState({}), [l, v] = X.useState({ open: !1, message: "" }), [g, h] = X.useState(!1), [k, V] = X.useState(null), d = X.useRef({}), N = () => {
|
|
4029
|
+
var E;
|
|
4012
4030
|
const m = {
|
|
4013
4031
|
id: Math.random().toString(36).substr(2, 9),
|
|
4014
4032
|
headerType: "MEDIA",
|
|
4015
|
-
mediaType: ((
|
|
4033
|
+
mediaType: ((E = a.carousel) == null ? void 0 : E.type) === "VIDEO" ? "VIDEO" : "IMAGE",
|
|
4016
4034
|
body: "",
|
|
4017
4035
|
buttons: []
|
|
4018
4036
|
};
|
|
@@ -4027,121 +4045,121 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4027
4045
|
};
|
|
4028
4046
|
});
|
|
4029
4047
|
}, M = (m) => {
|
|
4030
|
-
s((
|
|
4031
|
-
...
|
|
4048
|
+
s((E) => ({
|
|
4049
|
+
...E,
|
|
4032
4050
|
carousel: {
|
|
4033
|
-
...
|
|
4034
|
-
cards:
|
|
4051
|
+
...E.carousel,
|
|
4052
|
+
cards: E.carousel.cards.filter((S) => S.id !== m)
|
|
4035
4053
|
}
|
|
4036
4054
|
}));
|
|
4037
|
-
},
|
|
4055
|
+
}, b = (m, E, S) => {
|
|
4038
4056
|
s((j) => ({
|
|
4039
4057
|
...j,
|
|
4040
4058
|
carousel: {
|
|
4041
4059
|
...j.carousel,
|
|
4042
4060
|
cards: j.carousel.cards.map(
|
|
4043
|
-
(I) => I.id === m ? { ...I, [
|
|
4061
|
+
(I) => I.id === m ? { ...I, [E]: S } : I
|
|
4044
4062
|
)
|
|
4045
4063
|
}
|
|
4046
4064
|
}));
|
|
4047
|
-
},
|
|
4048
|
-
s((
|
|
4049
|
-
const j = ((
|
|
4065
|
+
}, y = (m) => {
|
|
4066
|
+
s((E) => {
|
|
4067
|
+
const j = ((E.carousel || { type: m, cards: [] }).cards || []).map((I) => ({
|
|
4050
4068
|
...I,
|
|
4051
4069
|
mediaType: m,
|
|
4052
4070
|
mediaUrl: ""
|
|
4053
4071
|
}));
|
|
4054
4072
|
return {
|
|
4055
|
-
...
|
|
4073
|
+
...E,
|
|
4056
4074
|
carousel: {
|
|
4057
4075
|
type: m,
|
|
4058
4076
|
cards: j
|
|
4059
4077
|
}
|
|
4060
4078
|
};
|
|
4061
4079
|
});
|
|
4062
|
-
},
|
|
4063
|
-
var
|
|
4064
|
-
const S = (
|
|
4080
|
+
}, t = (m, E) => {
|
|
4081
|
+
var D;
|
|
4082
|
+
const S = (D = a.carousel) == null ? void 0 : D.cards.find((K) => K.id === m);
|
|
4065
4083
|
if (!S) return;
|
|
4066
|
-
const
|
|
4067
|
-
|
|
4068
|
-
},
|
|
4069
|
-
var
|
|
4070
|
-
if (!
|
|
4071
|
-
const
|
|
4084
|
+
const z = `{{${p(m) + 1}}}`, T = S[E] + z;
|
|
4085
|
+
b(m, E, T);
|
|
4086
|
+
}, x = (m) => {
|
|
4087
|
+
var T;
|
|
4088
|
+
if (!k) return;
|
|
4089
|
+
const E = d.current[k], S = (T = a.carousel) == null ? void 0 : T.cards.find((D) => D.id === k);
|
|
4072
4090
|
if (!S) return;
|
|
4073
|
-
const j =
|
|
4074
|
-
|
|
4075
|
-
const
|
|
4076
|
-
if (
|
|
4077
|
-
const
|
|
4078
|
-
|
|
4091
|
+
const j = E && typeof E.selectionStart == "number" ? E.selectionStart : S.body.length, I = S.body.substring(0, j), z = S.body.substring(j), u = I + m + z;
|
|
4092
|
+
b(k, "body", u), setTimeout(() => {
|
|
4093
|
+
const D = d.current[k];
|
|
4094
|
+
if (D) {
|
|
4095
|
+
const K = j + m.length;
|
|
4096
|
+
D.setSelectionRange(K, K), D.focus();
|
|
4079
4097
|
}
|
|
4080
|
-
}, 0),
|
|
4081
|
-
},
|
|
4082
|
-
var
|
|
4083
|
-
const
|
|
4084
|
-
if (!
|
|
4085
|
-
const j = (
|
|
4098
|
+
}, 0), h(!1);
|
|
4099
|
+
}, p = (m) => {
|
|
4100
|
+
var z;
|
|
4101
|
+
const E = (z = a.carousel) == null ? void 0 : z.cards.find((u) => u.id === m);
|
|
4102
|
+
if (!E) return 0;
|
|
4103
|
+
const j = (E.body || "").match(/\{\{(\d+)\}\}/g);
|
|
4086
4104
|
if (!j) return 0;
|
|
4087
|
-
const I = j.map((
|
|
4088
|
-
const
|
|
4089
|
-
return
|
|
4105
|
+
const I = j.map((u) => {
|
|
4106
|
+
const T = u.match(/{{(\d+)}}/);
|
|
4107
|
+
return T ? parseInt(T[1], 10) : 0;
|
|
4090
4108
|
});
|
|
4091
4109
|
return I.length > 0 ? Math.max(...I) : 0;
|
|
4092
|
-
},
|
|
4110
|
+
}, w = (m, E) => {
|
|
4093
4111
|
var I;
|
|
4094
|
-
const S = (I = a.carousel) == null ? void 0 : I.cards.find((
|
|
4112
|
+
const S = (I = a.carousel) == null ? void 0 : I.cards.find((z) => z.id === m);
|
|
4095
4113
|
if (!S || S.buttons.length >= 2) return;
|
|
4096
4114
|
const j = {
|
|
4097
4115
|
id: Math.random().toString(36).substr(2, 9),
|
|
4098
|
-
type:
|
|
4116
|
+
type: E,
|
|
4099
4117
|
text: "",
|
|
4100
4118
|
value: "",
|
|
4101
4119
|
urlType: "static"
|
|
4102
4120
|
};
|
|
4103
|
-
|
|
4104
|
-
},
|
|
4105
|
-
var
|
|
4106
|
-
const I = (
|
|
4121
|
+
b(m, "buttons", [...S.buttons, j]);
|
|
4122
|
+
}, A = (m, E, S, j) => {
|
|
4123
|
+
var u;
|
|
4124
|
+
const I = (u = a.carousel) == null ? void 0 : u.cards.find((T) => T.id === m);
|
|
4107
4125
|
if (!I) return;
|
|
4108
|
-
const
|
|
4109
|
-
(
|
|
4126
|
+
const z = I.buttons.map(
|
|
4127
|
+
(T) => T.id === E ? { ...T, [S]: j } : T
|
|
4110
4128
|
);
|
|
4111
|
-
|
|
4112
|
-
},
|
|
4129
|
+
b(m, "buttons", z);
|
|
4130
|
+
}, R = (m, E) => {
|
|
4113
4131
|
var I;
|
|
4114
|
-
const S = (I = a.carousel) == null ? void 0 : I.cards.find((
|
|
4132
|
+
const S = (I = a.carousel) == null ? void 0 : I.cards.find((z) => z.id === m);
|
|
4115
4133
|
if (!S) return;
|
|
4116
|
-
const j = S.buttons.filter((
|
|
4117
|
-
|
|
4118
|
-
},
|
|
4134
|
+
const j = S.buttons.filter((z) => z.id !== E);
|
|
4135
|
+
b(m, "buttons", j);
|
|
4136
|
+
}, f = async (m, E) => {
|
|
4119
4137
|
var S;
|
|
4120
4138
|
try {
|
|
4121
|
-
|
|
4139
|
+
c((u) => ({ ...u, [m]: !0 })), o((u) => ({ ...u, [m]: !1 }));
|
|
4122
4140
|
const j = ((S = a.carousel) == null ? void 0 : S.type) === "VIDEO" ? "VIDEO" : "IMAGE";
|
|
4123
|
-
if (!
|
|
4141
|
+
if (!ba(E, j))
|
|
4124
4142
|
throw new Error(`Invalid file type. Expected ${j.toLowerCase()} file.`);
|
|
4125
|
-
const I =
|
|
4126
|
-
if (
|
|
4127
|
-
const
|
|
4128
|
-
throw new Error(`File size too large. Maximum allowed size is ${
|
|
4143
|
+
const I = ga(j);
|
|
4144
|
+
if (E.size > I) {
|
|
4145
|
+
const u = I / 1048576;
|
|
4146
|
+
throw new Error(`File size too large. Maximum allowed size is ${u}MB.`);
|
|
4129
4147
|
}
|
|
4130
|
-
const
|
|
4131
|
-
|
|
4148
|
+
const z = await n(E);
|
|
4149
|
+
b(m, "mediaUrl", z);
|
|
4132
4150
|
} catch (j) {
|
|
4133
|
-
console.error("File upload failed:", j),
|
|
4151
|
+
console.error("File upload failed:", j), v({ open: !0, message: j instanceof Error ? j.message : "File upload failed" });
|
|
4134
4152
|
} finally {
|
|
4135
|
-
|
|
4153
|
+
c((j) => ({ ...j, [m]: !1 }));
|
|
4136
4154
|
}
|
|
4137
4155
|
};
|
|
4138
4156
|
return /* @__PURE__ */ r("div", { className: "rsp-space-y-6", children: [
|
|
4139
4157
|
l.open && /* @__PURE__ */ r("div", { className: "rsp-fixed rsp-inset-0 rsp-z-50 rsp-flex rsp-items-center rsp-justify-center", children: [
|
|
4140
|
-
/* @__PURE__ */ e("div", { className: "rsp-absolute rsp-inset-0 rsp-bg-black rsp-bg-opacity-40", onClick: () =>
|
|
4158
|
+
/* @__PURE__ */ e("div", { className: "rsp-absolute rsp-inset-0 rsp-bg-black rsp-bg-opacity-40", onClick: () => v({ open: !1, message: "" }) }),
|
|
4141
4159
|
/* @__PURE__ */ r("div", { className: "rsp-relative rsp-z-10 rsp-bg-white rsp-rounded-lg rsp-shadow-lg rsp-w-full rsp-max-w-md rsp-p-5", children: [
|
|
4142
4160
|
/* @__PURE__ */ e("div", { className: "rsp-mb-3 rsp-text-lg rsp-font-semibold rsp-text-gray-900", children: "Upload Error" }),
|
|
4143
4161
|
/* @__PURE__ */ e("div", { className: "rsp-text-sm rsp-text-gray-700 rsp-break-words rsp-whitespace-pre-wrap", children: l.message }),
|
|
4144
|
-
/* @__PURE__ */ e("div", { className: "rsp-flex rsp-justify-end rsp-mt-4", children: /* @__PURE__ */ e("button", { onClick: () =>
|
|
4162
|
+
/* @__PURE__ */ e("div", { className: "rsp-flex rsp-justify-end rsp-mt-4", children: /* @__PURE__ */ e("button", { onClick: () => v({ open: !1, message: "" }), className: "rsp-px-4 rsp-py-2 rsp-text-sm rsp-font-medium rsp-text-white rsp-bg-blue-600 rsp-rounded-md hover:rsp-bg-blue-700", children: "OK" }) })
|
|
4145
4163
|
] })
|
|
4146
4164
|
] }),
|
|
4147
4165
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-justify-between", children: [
|
|
@@ -4149,17 +4167,17 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4149
4167
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-4", children: [
|
|
4150
4168
|
/* @__PURE__ */ r("span", { className: "rsp-text-sm rsp-text-gray-500", children: [
|
|
4151
4169
|
"Total Cards: ",
|
|
4152
|
-
((
|
|
4170
|
+
((C = a.carousel) == null ? void 0 : C.cards.length) || 0,
|
|
4153
4171
|
"/10"
|
|
4154
4172
|
] }),
|
|
4155
4173
|
/* @__PURE__ */ r(
|
|
4156
4174
|
"button",
|
|
4157
4175
|
{
|
|
4158
|
-
onClick:
|
|
4159
|
-
disabled: (((
|
|
4176
|
+
onClick: N,
|
|
4177
|
+
disabled: (((U = a.carousel) == null ? void 0 : U.cards.length) || 0) >= 10,
|
|
4160
4178
|
className: "rsp-px-4 rsp-py-2 rsp-bg-blue-600 rsp-text-white rsp-rounded-md hover:rsp-bg-blue-700 disabled:rsp-bg-gray-400 disabled:rsp-cursor-not-allowed rsp-text-sm rsp-font-medium",
|
|
4161
4179
|
children: [
|
|
4162
|
-
/* @__PURE__ */ e(
|
|
4180
|
+
/* @__PURE__ */ e(he, { className: "rsp-w-4 rsp-h-4 rsp-inline rsp-mr-2" }),
|
|
4163
4181
|
"Add Card"
|
|
4164
4182
|
]
|
|
4165
4183
|
}
|
|
@@ -4177,7 +4195,7 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4177
4195
|
name: "carouselType",
|
|
4178
4196
|
value: "IMAGE",
|
|
4179
4197
|
checked: ((O = a.carousel) == null ? void 0 : O.type) === "IMAGE",
|
|
4180
|
-
onChange: (m) =>
|
|
4198
|
+
onChange: (m) => y(m.target.value),
|
|
4181
4199
|
className: "rsp-mr-2"
|
|
4182
4200
|
}
|
|
4183
4201
|
),
|
|
@@ -4190,8 +4208,8 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4190
4208
|
type: "radio",
|
|
4191
4209
|
name: "carouselType",
|
|
4192
4210
|
value: "VIDEO",
|
|
4193
|
-
checked: ((
|
|
4194
|
-
onChange: (m) =>
|
|
4211
|
+
checked: ((P = a.carousel) == null ? void 0 : P.type) === "VIDEO",
|
|
4212
|
+
onChange: (m) => y(m.target.value),
|
|
4195
4213
|
className: "rsp-mr-2"
|
|
4196
4214
|
}
|
|
4197
4215
|
),
|
|
@@ -4199,15 +4217,15 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4199
4217
|
] })
|
|
4200
4218
|
] })
|
|
4201
4219
|
] }),
|
|
4202
|
-
/* @__PURE__ */ e("div", { className: "rsp-space-y-6", children: (
|
|
4203
|
-
var S, j, I,
|
|
4220
|
+
/* @__PURE__ */ e("div", { className: "rsp-space-y-6", children: (H = a.carousel) == null ? void 0 : H.cards.map((m, E) => {
|
|
4221
|
+
var S, j, I, z, u, T, D, K;
|
|
4204
4222
|
return /* @__PURE__ */ r("div", { className: "rsp-bg-white rsp-rounded-xl rsp-border-2 rsp-border-gray-200 rsp-overflow-hidden rsp-shadow-lg rsp-transition-all hover:rsp-shadow-xl hover:rsp-border-blue-300", children: [
|
|
4205
4223
|
/* @__PURE__ */ r("div", { className: "rsp-bg-gradient-to-r rsp-from-blue-50 rsp-to-blue-100 rsp-px-5 rsp-py-3 rsp-flex rsp-items-center rsp-justify-between rsp-border-b rsp-border-gray-200", children: [
|
|
4206
4224
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-3", children: [
|
|
4207
|
-
/* @__PURE__ */ e("div", { className: "rsp-w-8 rsp-h-8 rsp-bg-blue-500 rsp-text-white rsp-rounded-full rsp-flex rsp-items-center rsp-justify-center rsp-font-bold rsp-text-sm rsp-shadow-md", children:
|
|
4225
|
+
/* @__PURE__ */ e("div", { className: "rsp-w-8 rsp-h-8 rsp-bg-blue-500 rsp-text-white rsp-rounded-full rsp-flex rsp-items-center rsp-justify-center rsp-font-bold rsp-text-sm rsp-shadow-md", children: E + 1 }),
|
|
4208
4226
|
/* @__PURE__ */ r("h4", { className: "rsp-text-base rsp-font-semibold rsp-text-gray-800", children: [
|
|
4209
4227
|
"Card ",
|
|
4210
|
-
|
|
4228
|
+
E + 1
|
|
4211
4229
|
] })
|
|
4212
4230
|
] }),
|
|
4213
4231
|
/* @__PURE__ */ e(
|
|
@@ -4233,10 +4251,10 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4233
4251
|
"img",
|
|
4234
4252
|
{
|
|
4235
4253
|
src: m.mediaUrl,
|
|
4236
|
-
alt: `Card ${
|
|
4254
|
+
alt: `Card ${E + 1}`,
|
|
4237
4255
|
className: "rsp-w-full rsp-h-48 rsp-object-cover rsp-rounded-lg rsp-shadow-md",
|
|
4238
|
-
onLoad: () =>
|
|
4239
|
-
onError: () =>
|
|
4256
|
+
onLoad: () => o((L) => ({ ...L, [m.id]: !0 })),
|
|
4257
|
+
onError: () => o((L) => ({ ...L, [m.id]: !1 }))
|
|
4240
4258
|
}
|
|
4241
4259
|
) : /* @__PURE__ */ e(
|
|
4242
4260
|
"video",
|
|
@@ -4244,53 +4262,53 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4244
4262
|
src: m.mediaUrl,
|
|
4245
4263
|
className: "rsp-w-full rsp-h-48 rsp-object-cover rsp-rounded-lg rsp-shadow-md",
|
|
4246
4264
|
controls: !0,
|
|
4247
|
-
onLoadedData: () =>
|
|
4248
|
-
onError: () =>
|
|
4265
|
+
onLoadedData: () => o((L) => ({ ...L, [m.id]: !0 })),
|
|
4266
|
+
onError: () => o((L) => ({ ...L, [m.id]: !1 }))
|
|
4249
4267
|
}
|
|
4250
4268
|
),
|
|
4251
4269
|
/* @__PURE__ */ e(
|
|
4252
4270
|
"button",
|
|
4253
4271
|
{
|
|
4254
|
-
onClick: () =>
|
|
4272
|
+
onClick: () => b(m.id, "mediaUrl", ""),
|
|
4255
4273
|
className: "rsp-absolute rsp-top-2 rsp-right-2 rsp-p-2 rsp-bg-red-500 rsp-text-white rsp-rounded-full hover:rsp-bg-red-600 rsp-shadow-lg rsp-opacity-0 group-hover:rsp-opacity-100 rsp-transition-opacity",
|
|
4256
4274
|
title: "Remove media",
|
|
4257
4275
|
children: /* @__PURE__ */ e(re, { className: "rsp-w-4 rsp-h-4" })
|
|
4258
4276
|
}
|
|
4259
4277
|
),
|
|
4260
|
-
/* @__PURE__ */ e("div", { className: "rsp-absolute rsp-bottom-2 rsp-left-2 rsp-bg-black rsp-bg-opacity-60 rsp-text-white rsp-text-xs rsp-px-2 rsp-py-1 rsp-rounded rsp-backdrop-blur-sm", children: ((
|
|
4278
|
+
/* @__PURE__ */ e("div", { className: "rsp-absolute rsp-bottom-2 rsp-left-2 rsp-bg-black rsp-bg-opacity-60 rsp-text-white rsp-text-xs rsp-px-2 rsp-py-1 rsp-rounded rsp-backdrop-blur-sm", children: ((z = a.carousel) == null ? void 0 : z.type) === "VIDEO" ? "📹 Video" : "🖼️ Image" })
|
|
4261
4279
|
] }) : /* @__PURE__ */ r("div", { children: [
|
|
4262
|
-
/* @__PURE__ */ e("div", { className: "rsp-w-20 rsp-h-20 rsp-mx-auto rsp-mb-4 rsp-bg-gradient-to-br rsp-from-blue-100 rsp-to-blue-200 rsp-rounded-xl rsp-flex rsp-items-center rsp-justify-center rsp-shadow-md", children: /* @__PURE__ */ e("svg", { className: "rsp-w-10 rsp-h-10 rsp-text-blue-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: ((
|
|
4280
|
+
/* @__PURE__ */ e("div", { className: "rsp-w-20 rsp-h-20 rsp-mx-auto rsp-mb-4 rsp-bg-gradient-to-br rsp-from-blue-100 rsp-to-blue-200 rsp-rounded-xl rsp-flex rsp-items-center rsp-justify-center rsp-shadow-md", children: /* @__PURE__ */ e("svg", { className: "rsp-w-10 rsp-h-10 rsp-text-blue-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: ((u = a.carousel) == null ? void 0 : u.type) === "VIDEO" ? /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z" }) : /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" }) }) }),
|
|
4263
4281
|
/* @__PURE__ */ e(
|
|
4264
4282
|
"input",
|
|
4265
4283
|
{
|
|
4266
4284
|
type: "file",
|
|
4267
|
-
accept: ((
|
|
4268
|
-
onChange: (
|
|
4269
|
-
var
|
|
4270
|
-
const Y = (
|
|
4271
|
-
Y && !
|
|
4285
|
+
accept: ((T = a.carousel) == null ? void 0 : T.type) === "VIDEO" ? "video/*" : "image/*",
|
|
4286
|
+
onChange: (L) => {
|
|
4287
|
+
var _;
|
|
4288
|
+
const Y = (_ = L.target.files) == null ? void 0 : _[0];
|
|
4289
|
+
Y && !i[m.id] && f(m.id, Y);
|
|
4272
4290
|
},
|
|
4273
4291
|
className: "rsp-hidden",
|
|
4274
4292
|
id: `file-upload-${m.id}`,
|
|
4275
|
-
disabled: !!
|
|
4293
|
+
disabled: !!i[m.id]
|
|
4276
4294
|
}
|
|
4277
4295
|
),
|
|
4278
4296
|
/* @__PURE__ */ r(
|
|
4279
4297
|
"label",
|
|
4280
4298
|
{
|
|
4281
4299
|
htmlFor: `file-upload-${m.id}`,
|
|
4282
|
-
className: `rsp-inline-flex rsp-items-center rsp-gap-2 rsp-px-5 rsp-py-2.5 rsp-border rsp-border-blue-300 rsp-rounded-lg rsp-shadow-sm rsp-text-sm rsp-font-semibold rsp-text-blue-600 rsp-bg-white rsp-transition-colors ${
|
|
4283
|
-
"aria-disabled": !!
|
|
4300
|
+
className: `rsp-inline-flex rsp-items-center rsp-gap-2 rsp-px-5 rsp-py-2.5 rsp-border rsp-border-blue-300 rsp-rounded-lg rsp-shadow-sm rsp-text-sm rsp-font-semibold rsp-text-blue-600 rsp-bg-white rsp-transition-colors ${i[m.id] ? "rsp-opacity-50 rsp-cursor-not-allowed" : "hover:rsp-bg-blue-50 rsp-cursor-pointer"}`,
|
|
4301
|
+
"aria-disabled": !!i[m.id],
|
|
4284
4302
|
children: [
|
|
4285
4303
|
/* @__PURE__ */ e("svg", { className: "rsp-w-4 rsp-h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" }) }),
|
|
4286
4304
|
"Upload ",
|
|
4287
|
-
((
|
|
4305
|
+
((D = a.carousel) == null ? void 0 : D.type) === "VIDEO" ? "Video" : "Image"
|
|
4288
4306
|
]
|
|
4289
4307
|
}
|
|
4290
4308
|
),
|
|
4291
|
-
/* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-500 rsp-mt-3 rsp-px-2", children: ((
|
|
4309
|
+
/* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-500 rsp-mt-3 rsp-px-2", children: ((K = a.carousel) == null ? void 0 : K.type) === "VIDEO" ? "📹 MP4, MOV, AVI (Max 16MB)" : "🖼️ PNG, JPG, GIF, TIFF, SVG, BMP (Max 5MB)" })
|
|
4292
4310
|
] }),
|
|
4293
|
-
|
|
4311
|
+
i[m.id] && /* @__PURE__ */ e("div", { className: "rsp-absolute rsp-inset-0 rsp-bg-black rsp-bg-opacity-30 rsp-flex rsp-items-center rsp-justify-center", children: /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2 rsp-bg-white rsp-px-3 rsp-py-2 rsp-rounded-md rsp-shadow", children: [
|
|
4294
4312
|
/* @__PURE__ */ r("svg", { className: "rsp-w-4 rsp-h-4 rsp-animate-spin", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", children: [
|
|
4295
4313
|
/* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "10", strokeOpacity: "0.25", strokeWidth: "4" }),
|
|
4296
4314
|
/* @__PURE__ */ e("path", { d: "M22 12a10 10 0 00-10-10", strokeWidth: "4" })
|
|
@@ -4309,11 +4327,11 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4309
4327
|
/* @__PURE__ */ e("div", { className: "rsp-relative", children: /* @__PURE__ */ e(
|
|
4310
4328
|
"textarea",
|
|
4311
4329
|
{
|
|
4312
|
-
ref: (
|
|
4313
|
-
|
|
4330
|
+
ref: (L) => {
|
|
4331
|
+
d.current[m.id] = L;
|
|
4314
4332
|
},
|
|
4315
4333
|
value: m.body,
|
|
4316
|
-
onChange: (
|
|
4334
|
+
onChange: (L) => b(m.id, "body", L.target.value),
|
|
4317
4335
|
maxLength: 160,
|
|
4318
4336
|
rows: 4,
|
|
4319
4337
|
className: "rsp-w-full rsp-px-4 rsp-py-3 rsp-border-2 rsp-border-gray-200 rsp-rounded-lg rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-400 rsp-bg-white rsp-resize-none rsp-shadow-sm rsp-transition-colors",
|
|
@@ -4325,7 +4343,7 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4325
4343
|
/* @__PURE__ */ e(
|
|
4326
4344
|
"button",
|
|
4327
4345
|
{
|
|
4328
|
-
onClick: () =>
|
|
4346
|
+
onClick: () => t(m.id, "body"),
|
|
4329
4347
|
className: "rsp-p-1.5 rsp-text-gray-500 hover:rsp-text-blue-600 hover:rsp-bg-blue-50 rsp-rounded rsp-transition-colors",
|
|
4330
4348
|
title: "Add Variable",
|
|
4331
4349
|
children: /* @__PURE__ */ e("svg", { className: "rsp-w-4 rsp-h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" }) })
|
|
@@ -4335,11 +4353,11 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4335
4353
|
"button",
|
|
4336
4354
|
{
|
|
4337
4355
|
onClick: () => {
|
|
4338
|
-
|
|
4356
|
+
V(m.id), h(!0);
|
|
4339
4357
|
},
|
|
4340
4358
|
className: "rsp-p-1.5 rsp-text-gray-500 hover:rsp-text-blue-600 hover:rsp-bg-blue-50 rsp-rounded rsp-transition-colors",
|
|
4341
4359
|
title: "Add Emoji",
|
|
4342
|
-
children: /* @__PURE__ */ e(
|
|
4360
|
+
children: /* @__PURE__ */ e(ue, { className: "rsp-w-4 rsp-h-4" })
|
|
4343
4361
|
}
|
|
4344
4362
|
)
|
|
4345
4363
|
] }),
|
|
@@ -4349,15 +4367,15 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4349
4367
|
] })
|
|
4350
4368
|
] }),
|
|
4351
4369
|
(() => {
|
|
4352
|
-
const
|
|
4370
|
+
const L = m.body.match(/\{\{(\d+)\}\}/g) || [], Y = [...new Set(L.map((_) => _.replace(/[{}]/g, "")))];
|
|
4353
4371
|
return Y.length === 0 ? null : /* @__PURE__ */ r("div", { className: "rsp-mt-3 rsp-p-3 rsp-bg-blue-50 rsp-rounded-lg rsp-border rsp-border-blue-200", children: [
|
|
4354
4372
|
/* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-font-semibold rsp-text-blue-800 rsp-mb-2", children: "Sample Values for This Card" }),
|
|
4355
|
-
/* @__PURE__ */ e("div", { className: "rsp-grid rsp-grid-cols-1 rsp-gap-2", children: Y.map((
|
|
4373
|
+
/* @__PURE__ */ e("div", { className: "rsp-grid rsp-grid-cols-1 rsp-gap-2", children: Y.map((_) => {
|
|
4356
4374
|
var ie, G;
|
|
4357
4375
|
return /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2", children: [
|
|
4358
4376
|
/* @__PURE__ */ r("label", { className: "rsp-text-xs rsp-text-gray-700 rsp-font-medium rsp-whitespace-nowrap", children: [
|
|
4359
4377
|
"{{",
|
|
4360
|
-
|
|
4378
|
+
_,
|
|
4361
4379
|
"}}",
|
|
4362
4380
|
":"
|
|
4363
4381
|
] }),
|
|
@@ -4365,22 +4383,22 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4365
4383
|
"input",
|
|
4366
4384
|
{
|
|
4367
4385
|
type: "text",
|
|
4368
|
-
value: ((G = (ie = m.sampleContent) == null ? void 0 : ie.bodyVariables) == null ? void 0 : G[
|
|
4386
|
+
value: ((G = (ie = m.sampleContent) == null ? void 0 : ie.bodyVariables) == null ? void 0 : G[_]) || "",
|
|
4369
4387
|
onChange: (se) => {
|
|
4370
4388
|
const ae = se.target.value;
|
|
4371
|
-
s((
|
|
4372
|
-
...
|
|
4389
|
+
s((J) => ({
|
|
4390
|
+
...J,
|
|
4373
4391
|
carousel: {
|
|
4374
|
-
...
|
|
4375
|
-
cards:
|
|
4376
|
-
var
|
|
4392
|
+
...J.carousel,
|
|
4393
|
+
cards: J.carousel.cards.map((F) => {
|
|
4394
|
+
var $, W, Z;
|
|
4377
4395
|
return F.id !== m.id ? F : {
|
|
4378
4396
|
...F,
|
|
4379
4397
|
sampleContent: {
|
|
4380
|
-
headerVariables: ((
|
|
4398
|
+
headerVariables: (($ = F.sampleContent) == null ? void 0 : $.headerVariables) || {},
|
|
4381
4399
|
bodyVariables: {
|
|
4382
4400
|
...((W = F.sampleContent) == null ? void 0 : W.bodyVariables) || {},
|
|
4383
|
-
[
|
|
4401
|
+
[_]: ae
|
|
4384
4402
|
},
|
|
4385
4403
|
buttonVariables: ((Z = F.sampleContent) == null ? void 0 : Z.buttonVariables) || {}
|
|
4386
4404
|
}
|
|
@@ -4398,15 +4416,15 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4398
4416
|
{
|
|
4399
4417
|
type: "button",
|
|
4400
4418
|
onClick: () => {
|
|
4401
|
-
const se = new RegExp(`\\{\\{${
|
|
4402
|
-
s((
|
|
4403
|
-
...
|
|
4419
|
+
const se = new RegExp(`\\{\\{${_}\\}\\}`, "g"), ae = (m.body || "").replace(se, "");
|
|
4420
|
+
s((J) => ({
|
|
4421
|
+
...J,
|
|
4404
4422
|
carousel: {
|
|
4405
|
-
...
|
|
4406
|
-
cards:
|
|
4407
|
-
var
|
|
4423
|
+
...J.carousel,
|
|
4424
|
+
cards: J.carousel.cards.map((F) => {
|
|
4425
|
+
var $, W, Z;
|
|
4408
4426
|
if (F.id !== m.id) return F;
|
|
4409
|
-
const Q = Object.fromEntries(Object.entries(((
|
|
4427
|
+
const Q = Object.fromEntries(Object.entries((($ = F.sampleContent) == null ? void 0 : $.bodyVariables) || {}).filter(([ne]) => ne !== _));
|
|
4410
4428
|
return {
|
|
4411
4429
|
...F,
|
|
4412
4430
|
body: ae,
|
|
@@ -4425,7 +4443,7 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4425
4443
|
children: "×"
|
|
4426
4444
|
}
|
|
4427
4445
|
)
|
|
4428
|
-
] }, `card-${m.id}-sample-${
|
|
4446
|
+
] }, `card-${m.id}-sample-${_}`);
|
|
4429
4447
|
}) })
|
|
4430
4448
|
] });
|
|
4431
4449
|
})()
|
|
@@ -4444,7 +4462,7 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4444
4462
|
/* @__PURE__ */ r(
|
|
4445
4463
|
"button",
|
|
4446
4464
|
{
|
|
4447
|
-
onClick: () =>
|
|
4465
|
+
onClick: () => w(m.id, "QUICK_REPLY"),
|
|
4448
4466
|
className: "rsp-flex rsp-flex-col rsp-items-center rsp-gap-2 rsp-px-3 rsp-py-4 rsp-border-2 rsp-border-gray-200 rsp-rounded-lg rsp-text-sm rsp-font-medium rsp-text-gray-700 hover:rsp-border-blue-400 hover:rsp-bg-blue-50 rsp-transition-all rsp-shadow-sm",
|
|
4449
4467
|
children: [
|
|
4450
4468
|
/* @__PURE__ */ e("svg", { className: "rsp-w-6 rsp-h-6 rsp-text-blue-500", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z" }) }),
|
|
@@ -4455,7 +4473,7 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4455
4473
|
/* @__PURE__ */ r(
|
|
4456
4474
|
"button",
|
|
4457
4475
|
{
|
|
4458
|
-
onClick: () =>
|
|
4476
|
+
onClick: () => w(m.id, "URL"),
|
|
4459
4477
|
className: "rsp-flex rsp-flex-col rsp-items-center rsp-gap-2 rsp-px-3 rsp-py-4 rsp-border-2 rsp-border-gray-200 rsp-rounded-lg rsp-text-sm rsp-font-medium rsp-text-gray-700 hover:rsp-border-blue-400 hover:rsp-bg-blue-50 rsp-transition-all rsp-shadow-sm",
|
|
4460
4478
|
children: [
|
|
4461
4479
|
/* @__PURE__ */ e("svg", { className: "rsp-w-6 rsp-h-6 rsp-text-blue-500", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" }) }),
|
|
@@ -4466,7 +4484,7 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4466
4484
|
/* @__PURE__ */ r(
|
|
4467
4485
|
"button",
|
|
4468
4486
|
{
|
|
4469
|
-
onClick: () =>
|
|
4487
|
+
onClick: () => w(m.id, "PHONE_NUMBER"),
|
|
4470
4488
|
className: "rsp-flex rsp-flex-col rsp-items-center rsp-gap-2 rsp-px-3 rsp-py-4 rsp-border-2 rsp-border-gray-200 rsp-rounded-lg rsp-text-sm rsp-font-medium rsp-text-gray-700 hover:rsp-border-blue-400 hover:rsp-bg-blue-50 rsp-transition-all rsp-shadow-sm",
|
|
4471
4489
|
children: [
|
|
4472
4490
|
/* @__PURE__ */ e("svg", { className: "rsp-w-6 rsp-h-6 rsp-text-blue-500", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z" }) }),
|
|
@@ -4481,16 +4499,16 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4481
4499
|
/* @__PURE__ */ e("svg", { className: "rsp-w-4 rsp-h-4 rsp-text-green-500", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
|
|
4482
4500
|
"Configured Buttons"
|
|
4483
4501
|
] }),
|
|
4484
|
-
m.buttons.map((
|
|
4502
|
+
m.buttons.map((L, Y) => /* @__PURE__ */ r("div", { className: "rsp-p-4 rsp-border-2 rsp-border-blue-200 rsp-rounded-lg rsp-bg-gradient-to-br rsp-from-blue-50 rsp-to-white rsp-shadow-sm", children: [
|
|
4485
4503
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-justify-between rsp-mb-3", children: [
|
|
4486
4504
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2", children: [
|
|
4487
4505
|
/* @__PURE__ */ e("div", { className: "rsp-w-6 rsp-h-6 rsp-bg-blue-500 rsp-text-white rsp-rounded rsp-flex rsp-items-center rsp-justify-center rsp-text-xs rsp-font-bold", children: Y + 1 }),
|
|
4488
|
-
/* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-font-semibold rsp-text-gray-800", children:
|
|
4506
|
+
/* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-font-semibold rsp-text-gray-800", children: L.type === "QUICK_REPLY" ? "Quick Reply" : L.type === "URL" ? "Website" : "Phone" })
|
|
4489
4507
|
] }),
|
|
4490
4508
|
/* @__PURE__ */ e(
|
|
4491
4509
|
"button",
|
|
4492
4510
|
{
|
|
4493
|
-
onClick: () =>
|
|
4511
|
+
onClick: () => R(m.id, L.id),
|
|
4494
4512
|
className: "rsp-p-1 rsp-text-gray-400 hover:rsp-text-red-500 hover:rsp-bg-red-50 rsp-rounded rsp-transition-colors",
|
|
4495
4513
|
title: "Remove button",
|
|
4496
4514
|
children: /* @__PURE__ */ e(re, { className: "rsp-w-4 rsp-h-4" })
|
|
@@ -4504,15 +4522,15 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4504
4522
|
"input",
|
|
4505
4523
|
{
|
|
4506
4524
|
type: "text",
|
|
4507
|
-
value:
|
|
4508
|
-
onChange: (
|
|
4509
|
-
placeholder: `Enter Button Text (Max ${
|
|
4510
|
-
maxLength:
|
|
4525
|
+
value: L.text,
|
|
4526
|
+
onChange: (_) => A(m.id, L.id, "text", _.target.value),
|
|
4527
|
+
placeholder: `Enter Button Text (Max ${L.type === "QUICK_REPLY" ? "25" : "20"} characters)`,
|
|
4528
|
+
maxLength: L.type === "QUICK_REPLY" ? 25 : 20,
|
|
4511
4529
|
className: "rsp-w-full rsp-px-3 rsp-py-2 rsp-border rsp-border-gray-300 rsp-rounded-md rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-white"
|
|
4512
4530
|
}
|
|
4513
4531
|
)
|
|
4514
4532
|
] }),
|
|
4515
|
-
|
|
4533
|
+
L.type === "URL" && /* @__PURE__ */ r("div", { className: "rsp-space-y-3", children: [
|
|
4516
4534
|
/* @__PURE__ */ r("div", { children: [
|
|
4517
4535
|
/* @__PURE__ */ e("label", { className: "rsp-block rsp-text-xs rsp-font-medium rsp-text-gray-600 rsp-mb-2", children: "URL Type" }),
|
|
4518
4536
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-gap-4", children: [
|
|
@@ -4521,8 +4539,8 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4521
4539
|
"input",
|
|
4522
4540
|
{
|
|
4523
4541
|
type: "radio",
|
|
4524
|
-
checked:
|
|
4525
|
-
onChange: () =>
|
|
4542
|
+
checked: L.urlType !== "dynamic",
|
|
4543
|
+
onChange: () => A(m.id, L.id, "urlType", "static"),
|
|
4526
4544
|
className: "rsp-mr-2 rsp-text-blue-600"
|
|
4527
4545
|
}
|
|
4528
4546
|
),
|
|
@@ -4533,8 +4551,8 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4533
4551
|
"input",
|
|
4534
4552
|
{
|
|
4535
4553
|
type: "radio",
|
|
4536
|
-
checked:
|
|
4537
|
-
onChange: () =>
|
|
4554
|
+
checked: L.urlType === "dynamic",
|
|
4555
|
+
onChange: () => A(m.id, L.id, "urlType", "dynamic"),
|
|
4538
4556
|
className: "rsp-mr-2 rsp-text-blue-600"
|
|
4539
4557
|
}
|
|
4540
4558
|
),
|
|
@@ -4548,14 +4566,14 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4548
4566
|
"input",
|
|
4549
4567
|
{
|
|
4550
4568
|
type: "text",
|
|
4551
|
-
value:
|
|
4552
|
-
onChange: (
|
|
4553
|
-
placeholder:
|
|
4569
|
+
value: L.value || "",
|
|
4570
|
+
onChange: (_) => A(m.id, L.id, "value", _.target.value),
|
|
4571
|
+
placeholder: L.urlType === "dynamic" ? "https://example.com/order/{{1}}" : "https://example.com",
|
|
4554
4572
|
className: "rsp-w-full rsp-px-3 rsp-py-2 rsp-border rsp-border-gray-300 rsp-rounded-md rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-white"
|
|
4555
4573
|
}
|
|
4556
4574
|
)
|
|
4557
4575
|
] }),
|
|
4558
|
-
|
|
4576
|
+
L.urlType === "dynamic" && /* @__PURE__ */ r("div", { className: "rsp-space-y-2", children: [
|
|
4559
4577
|
/* @__PURE__ */ e("div", { className: "rsp-p-2 rsp-bg-blue-50 rsp-rounded rsp-border rsp-border-blue-200", children: /* @__PURE__ */ r("p", { className: "rsp-text-xs rsp-text-blue-700", children: [
|
|
4560
4578
|
/* @__PURE__ */ e("strong", { children: "Tip:" }),
|
|
4561
4579
|
" Use ",
|
|
@@ -4574,22 +4592,22 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4574
4592
|
{
|
|
4575
4593
|
type: "button",
|
|
4576
4594
|
onClick: () => {
|
|
4577
|
-
if (((
|
|
4578
|
-
const G = ((
|
|
4595
|
+
if (((L.value || "").match(/\{\{(\d+)\}\}/g) || []).length >= 3) return;
|
|
4596
|
+
const G = ((L.value || "").match(/\{\{(\d+)\}\}/g) || []).map((F) => {
|
|
4579
4597
|
const Q = F.match(/{{(\d+)}}/);
|
|
4580
4598
|
return Q ? parseInt(Q[1], 10) : 0;
|
|
4581
|
-
}), ae = (G.length > 0 ? Math.max(...G) : 0) + 1,
|
|
4582
|
-
|
|
4599
|
+
}), ae = (G.length > 0 ? Math.max(...G) : 0) + 1, J = (L.value || "") + `{{${ae}}}`;
|
|
4600
|
+
A(m.id, L.id, "value", J);
|
|
4583
4601
|
},
|
|
4584
|
-
disabled: ((
|
|
4602
|
+
disabled: ((L.value || "").match(/\{\{(\d+)\}\}/g) || []).length >= 3,
|
|
4585
4603
|
className: "rsp-px-3 rsp-py-1.5 rsp-text-xs rsp-bg-blue-500 hover:rsp-bg-blue-600 rsp-text-white rsp-rounded disabled:rsp-bg-gray-300 disabled:rsp-cursor-not-allowed rsp-transition-colors",
|
|
4586
4604
|
children: "+ Add Variable"
|
|
4587
4605
|
}
|
|
4588
4606
|
),
|
|
4589
|
-
((
|
|
4607
|
+
((L.value || "").match(/\{\{(\d+)\}\}/g) || []).length >= 3 && /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-500 rsp-mt-1", children: "Maximum 3 variables allowed" })
|
|
4590
4608
|
] }),
|
|
4591
4609
|
(() => {
|
|
4592
|
-
const
|
|
4610
|
+
const _ = (L.value || "").match(/\{\{(\d+)\}\}/g) || [], ie = [...new Set(_.map((G) => G.replace(/[{}]/g, "")))];
|
|
4593
4611
|
return ie.length === 0 ? null : /* @__PURE__ */ r("div", { className: "rsp-p-3 rsp-bg-gray-50 rsp-rounded-lg rsp-border rsp-border-gray-200", children: [
|
|
4594
4612
|
/* @__PURE__ */ e("h4", { className: "rsp-text-xs rsp-font-semibold rsp-text-gray-700 rsp-mb-2", children: "Sample Values for URL Variables" }),
|
|
4595
4613
|
/* @__PURE__ */ e("div", { className: "rsp-space-y-2", children: ie.map((G) => {
|
|
@@ -4606,21 +4624,21 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4606
4624
|
{
|
|
4607
4625
|
type: "text",
|
|
4608
4626
|
value: ((ae = (se = m.sampleContent) == null ? void 0 : se.buttonVariables) == null ? void 0 : ae[G]) || "",
|
|
4609
|
-
onChange: (
|
|
4610
|
-
const F =
|
|
4627
|
+
onChange: (J) => {
|
|
4628
|
+
const F = J.target.value;
|
|
4611
4629
|
s((Q) => ({
|
|
4612
4630
|
...Q,
|
|
4613
4631
|
carousel: {
|
|
4614
4632
|
...Q.carousel,
|
|
4615
|
-
cards: Q.carousel.cards.map((
|
|
4633
|
+
cards: Q.carousel.cards.map(($) => {
|
|
4616
4634
|
var W, Z, ne;
|
|
4617
|
-
return
|
|
4618
|
-
|
|
4635
|
+
return $.id !== m.id ? $ : {
|
|
4636
|
+
...$,
|
|
4619
4637
|
sampleContent: {
|
|
4620
|
-
headerVariables: ((W =
|
|
4621
|
-
bodyVariables: ((Z =
|
|
4638
|
+
headerVariables: ((W = $.sampleContent) == null ? void 0 : W.headerVariables) || {},
|
|
4639
|
+
bodyVariables: ((Z = $.sampleContent) == null ? void 0 : Z.bodyVariables) || {},
|
|
4622
4640
|
buttonVariables: {
|
|
4623
|
-
...((ne =
|
|
4641
|
+
...((ne = $.sampleContent) == null ? void 0 : ne.buttonVariables) || {},
|
|
4624
4642
|
[G]: F
|
|
4625
4643
|
}
|
|
4626
4644
|
}
|
|
@@ -4638,20 +4656,20 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4638
4656
|
{
|
|
4639
4657
|
type: "button",
|
|
4640
4658
|
onClick: () => {
|
|
4641
|
-
const
|
|
4642
|
-
|
|
4643
|
-
|
|
4659
|
+
const J = L.value || "", F = new RegExp(`\\{\\{${G}\\}\\}`, "g"), Q = J.replace(F, "");
|
|
4660
|
+
A(m.id, L.id, "value", Q), s(($) => ({
|
|
4661
|
+
...$,
|
|
4644
4662
|
carousel: {
|
|
4645
|
-
|
|
4646
|
-
cards:
|
|
4647
|
-
var ne,
|
|
4663
|
+
...$.carousel,
|
|
4664
|
+
cards: $.carousel.cards.map((W) => {
|
|
4665
|
+
var ne, we, ve;
|
|
4648
4666
|
if (W.id !== m.id) return W;
|
|
4649
|
-
const Z = Object.fromEntries(Object.entries(((ne = W.sampleContent) == null ? void 0 : ne.buttonVariables) || {}).filter(([
|
|
4667
|
+
const Z = Object.fromEntries(Object.entries(((ne = W.sampleContent) == null ? void 0 : ne.buttonVariables) || {}).filter(([Re]) => Re !== G));
|
|
4650
4668
|
return {
|
|
4651
4669
|
...W,
|
|
4652
4670
|
sampleContent: {
|
|
4653
|
-
headerVariables: ((
|
|
4654
|
-
bodyVariables: ((
|
|
4671
|
+
headerVariables: ((we = W.sampleContent) == null ? void 0 : we.headerVariables) || {},
|
|
4672
|
+
bodyVariables: ((ve = W.sampleContent) == null ? void 0 : ve.bodyVariables) || {},
|
|
4655
4673
|
buttonVariables: Z
|
|
4656
4674
|
}
|
|
4657
4675
|
};
|
|
@@ -4664,27 +4682,27 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4664
4682
|
children: "×"
|
|
4665
4683
|
}
|
|
4666
4684
|
)
|
|
4667
|
-
] }, `button-${
|
|
4685
|
+
] }, `button-${L.id}-sample-${G}`);
|
|
4668
4686
|
}) })
|
|
4669
4687
|
] });
|
|
4670
4688
|
})()
|
|
4671
4689
|
] })
|
|
4672
4690
|
] }),
|
|
4673
|
-
|
|
4691
|
+
L.type === "PHONE_NUMBER" && /* @__PURE__ */ r("div", { children: [
|
|
4674
4692
|
/* @__PURE__ */ e("label", { className: "rsp-block rsp-text-xs rsp-font-medium rsp-text-gray-600 rsp-mb-1", children: "Phone Number" }),
|
|
4675
4693
|
/* @__PURE__ */ e(
|
|
4676
4694
|
"input",
|
|
4677
4695
|
{
|
|
4678
4696
|
type: "text",
|
|
4679
|
-
value:
|
|
4680
|
-
onChange: (
|
|
4697
|
+
value: L.value || "",
|
|
4698
|
+
onChange: (_) => A(m.id, L.id, "value", _.target.value),
|
|
4681
4699
|
placeholder: "+1234567890",
|
|
4682
4700
|
className: "rsp-w-full rsp-px-3 rsp-py-2 rsp-border rsp-border-gray-300 rsp-rounded-md rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-white"
|
|
4683
4701
|
}
|
|
4684
4702
|
)
|
|
4685
4703
|
] })
|
|
4686
4704
|
] })
|
|
4687
|
-
] },
|
|
4705
|
+
] }, L.id))
|
|
4688
4706
|
] })
|
|
4689
4707
|
] })
|
|
4690
4708
|
] }) })
|
|
@@ -4705,11 +4723,11 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4705
4723
|
] })
|
|
4706
4724
|
] }) }),
|
|
4707
4725
|
/* @__PURE__ */ e(
|
|
4708
|
-
|
|
4726
|
+
ye,
|
|
4709
4727
|
{
|
|
4710
|
-
isOpen:
|
|
4711
|
-
onClose: () =>
|
|
4712
|
-
onSelect:
|
|
4728
|
+
isOpen: g,
|
|
4729
|
+
onClose: () => h(!1),
|
|
4730
|
+
onSelect: x
|
|
4713
4731
|
}
|
|
4714
4732
|
)
|
|
4715
4733
|
] });
|
|
@@ -4717,40 +4735,40 @@ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
|
|
|
4717
4735
|
const Me = async (a) => {
|
|
4718
4736
|
try {
|
|
4719
4737
|
console.log(`Starting file upload: ${a.name}`);
|
|
4720
|
-
const s = await
|
|
4738
|
+
const s = await ua(a);
|
|
4721
4739
|
return console.log(`File uploaded successfully: ${s}`), s;
|
|
4722
4740
|
} catch (s) {
|
|
4723
4741
|
throw console.error("Upload failed in parent:", s), s;
|
|
4724
4742
|
}
|
|
4725
|
-
},
|
|
4726
|
-
const
|
|
4727
|
-
if (!
|
|
4728
|
-
const
|
|
4729
|
-
const
|
|
4730
|
-
return
|
|
4743
|
+
}, wa = (a) => {
|
|
4744
|
+
const n = (a.body || "").match(/\{\{(\d+)\}\}/g);
|
|
4745
|
+
if (!n) return 0;
|
|
4746
|
+
const i = n.map((c) => {
|
|
4747
|
+
const o = c.match(/{{(\d+)}}/);
|
|
4748
|
+
return o ? parseInt(o[1], 10) : 0;
|
|
4731
4749
|
});
|
|
4732
|
-
return
|
|
4750
|
+
return i.length > 0 ? Math.max(...i) : 0;
|
|
4733
4751
|
};
|
|
4734
|
-
function
|
|
4735
|
-
const [
|
|
4736
|
-
|
|
4737
|
-
|
|
4752
|
+
function va({ template: a, setTemplate: s }) {
|
|
4753
|
+
const [n, i] = X.useState(!1), c = X.useRef(null), o = () => {
|
|
4754
|
+
i(!0), setTimeout(() => {
|
|
4755
|
+
c.current && c.current.focus();
|
|
4738
4756
|
}, 0);
|
|
4739
|
-
}, l = (
|
|
4740
|
-
const
|
|
4741
|
-
s({ ...a, body:
|
|
4742
|
-
if (
|
|
4743
|
-
const M =
|
|
4744
|
-
|
|
4757
|
+
}, l = (v) => {
|
|
4758
|
+
const g = c.current, h = a.body, k = g && typeof g.selectionStart == "number" ? g.selectionStart : h.length, V = h.substring(0, k), d = h.substring(k), N = V + v + d;
|
|
4759
|
+
s({ ...a, body: N }), setTimeout(() => {
|
|
4760
|
+
if (c.current) {
|
|
4761
|
+
const M = k + v.length;
|
|
4762
|
+
c.current.setSelectionRange(M, M), c.current.focus();
|
|
4745
4763
|
}
|
|
4746
|
-
}, 0),
|
|
4764
|
+
}, 0), i(!1);
|
|
4747
4765
|
};
|
|
4748
4766
|
return /* @__PURE__ */ r("div", { className: "rsp-space-y-6", children: [
|
|
4749
4767
|
a.type !== "CAROUSEL" && /* @__PURE__ */ r("div", { className: "rsp-space-y-6", children: [
|
|
4750
4768
|
/* @__PURE__ */ e("h2", { className: "rsp-text-lg rsp-font-semibold rsp-text-gray-900", children: "Message Content" }),
|
|
4751
4769
|
/* @__PURE__ */ r("div", { className: "rsp-space-y-6", children: [
|
|
4752
|
-
/* @__PURE__ */ e(
|
|
4753
|
-
/* @__PURE__ */ e(
|
|
4770
|
+
/* @__PURE__ */ e(pa, { template: a, setTemplate: s, onFileUpload: Me }),
|
|
4771
|
+
/* @__PURE__ */ e(fa, { template: a, setTemplate: s })
|
|
4754
4772
|
] })
|
|
4755
4773
|
] }),
|
|
4756
4774
|
a.type === "CAROUSEL" && /* @__PURE__ */ r("div", { className: "rsp-space-y-6", children: [
|
|
@@ -4763,9 +4781,9 @@ function ka({ template: a, setTemplate: s }) {
|
|
|
4763
4781
|
/* @__PURE__ */ e("div", { className: "rsp-relative", children: /* @__PURE__ */ e(
|
|
4764
4782
|
"textarea",
|
|
4765
4783
|
{
|
|
4766
|
-
ref:
|
|
4784
|
+
ref: c,
|
|
4767
4785
|
value: a.body,
|
|
4768
|
-
onChange: (
|
|
4786
|
+
onChange: (v) => s({ ...a, body: v.target.value }),
|
|
4769
4787
|
maxLength: 1024,
|
|
4770
4788
|
rows: 4,
|
|
4771
4789
|
className: "rsp-w-full rsp-px-3 rsp-py-2 rsp-border rsp-border-gray-300 rsp-rounded-md rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-white rsp-resize-none",
|
|
@@ -4779,8 +4797,8 @@ function ka({ template: a, setTemplate: s }) {
|
|
|
4779
4797
|
"button",
|
|
4780
4798
|
{
|
|
4781
4799
|
onClick: () => {
|
|
4782
|
-
const
|
|
4783
|
-
s({ ...a, body: a.body +
|
|
4800
|
+
const h = `{{${wa(a) + 1}}}`;
|
|
4801
|
+
s({ ...a, body: a.body + h });
|
|
4784
4802
|
},
|
|
4785
4803
|
className: "rsp-p-1 rsp-text-gray-500 hover:rsp-text-gray-700 hover:rsp-bg-gray-100 rsp-rounded",
|
|
4786
4804
|
title: "Add Variable",
|
|
@@ -4790,10 +4808,10 @@ function ka({ template: a, setTemplate: s }) {
|
|
|
4790
4808
|
/* @__PURE__ */ e(
|
|
4791
4809
|
"button",
|
|
4792
4810
|
{
|
|
4793
|
-
onClick:
|
|
4811
|
+
onClick: o,
|
|
4794
4812
|
className: "rsp-p-1 rsp-text-gray-500 hover:rsp-text-gray-700 hover:rsp-bg-gray-100 rsp-rounded",
|
|
4795
4813
|
title: "Add emoji",
|
|
4796
|
-
children: /* @__PURE__ */ e(
|
|
4814
|
+
children: /* @__PURE__ */ e(ue, { className: "rsp-w-4 rsp-h-4" })
|
|
4797
4815
|
}
|
|
4798
4816
|
)
|
|
4799
4817
|
] }),
|
|
@@ -4803,15 +4821,15 @@ function ka({ template: a, setTemplate: s }) {
|
|
|
4803
4821
|
] })
|
|
4804
4822
|
] }),
|
|
4805
4823
|
(() => {
|
|
4806
|
-
const
|
|
4807
|
-
return
|
|
4824
|
+
const v = a.body.match(/\{\{(\d+)\}\}/g) || [], g = [...new Set(v.map((h) => h.replace(/[{}]/g, "")))];
|
|
4825
|
+
return g.length === 0 ? null : /* @__PURE__ */ r("div", { className: "rsp-mt-3", children: [
|
|
4808
4826
|
/* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-font-medium rsp-text-gray-600 rsp-mb-2", children: "Sample Values" }),
|
|
4809
|
-
/* @__PURE__ */ e("div", { className: "rsp-grid rsp-grid-cols-3 rsp-gap-2", children:
|
|
4810
|
-
var
|
|
4827
|
+
/* @__PURE__ */ e("div", { className: "rsp-grid rsp-grid-cols-3 rsp-gap-2", children: g.map((h) => {
|
|
4828
|
+
var k, V;
|
|
4811
4829
|
return /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2", children: [
|
|
4812
4830
|
/* @__PURE__ */ r("label", { className: "rsp-text-xs rsp-text-gray-500 rsp-whitespace-nowrap", children: [
|
|
4813
4831
|
"{{",
|
|
4814
|
-
|
|
4832
|
+
h,
|
|
4815
4833
|
"}}",
|
|
4816
4834
|
":"
|
|
4817
4835
|
] }),
|
|
@@ -4819,19 +4837,19 @@ function ka({ template: a, setTemplate: s }) {
|
|
|
4819
4837
|
"input",
|
|
4820
4838
|
{
|
|
4821
4839
|
type: "text",
|
|
4822
|
-
value: ((
|
|
4823
|
-
onChange: (
|
|
4824
|
-
var M,
|
|
4825
|
-
const
|
|
4840
|
+
value: ((V = (k = a.sampleContent) == null ? void 0 : k.bodyVariables) == null ? void 0 : V[h]) || "",
|
|
4841
|
+
onChange: (d) => {
|
|
4842
|
+
var M, b, y;
|
|
4843
|
+
const N = {
|
|
4826
4844
|
...a.sampleContent,
|
|
4827
4845
|
headerVariables: ((M = a.sampleContent) == null ? void 0 : M.headerVariables) || {},
|
|
4828
4846
|
bodyVariables: {
|
|
4829
|
-
...(
|
|
4830
|
-
[
|
|
4847
|
+
...(b = a.sampleContent) == null ? void 0 : b.bodyVariables,
|
|
4848
|
+
[h]: d.target.value
|
|
4831
4849
|
},
|
|
4832
|
-
buttonVariables: ((
|
|
4850
|
+
buttonVariables: ((y = a.sampleContent) == null ? void 0 : y.buttonVariables) || {}
|
|
4833
4851
|
};
|
|
4834
|
-
s({ ...a, sampleContent:
|
|
4852
|
+
s({ ...a, sampleContent: N });
|
|
4835
4853
|
},
|
|
4836
4854
|
className: "rsp-flex-1 rsp-px-2 rsp-py-1 rsp-border rsp-border-gray-300 rsp-rounded rsp-text-xs focus:rsp-outline-none focus:rsp-border-blue-500",
|
|
4837
4855
|
placeholder: "Sample"
|
|
@@ -4842,16 +4860,16 @@ function ka({ template: a, setTemplate: s }) {
|
|
|
4842
4860
|
{
|
|
4843
4861
|
type: "button",
|
|
4844
4862
|
onClick: () => {
|
|
4845
|
-
var
|
|
4846
|
-
const
|
|
4863
|
+
var b, y, t;
|
|
4864
|
+
const d = new RegExp(`\\{\\{${h}\\}\\}`, "g"), N = (a.body || "").replace(d, ""), M = Object.fromEntries(Object.entries(((b = a.sampleContent) == null ? void 0 : b.bodyVariables) || {}).filter(([x]) => x !== h));
|
|
4847
4865
|
s({
|
|
4848
4866
|
...a,
|
|
4849
|
-
body:
|
|
4867
|
+
body: N,
|
|
4850
4868
|
sampleContent: {
|
|
4851
4869
|
...a.sampleContent,
|
|
4852
4870
|
bodyVariables: M,
|
|
4853
|
-
headerVariables: ((
|
|
4854
|
-
buttonVariables: ((
|
|
4871
|
+
headerVariables: ((y = a.sampleContent) == null ? void 0 : y.headerVariables) || {},
|
|
4872
|
+
buttonVariables: ((t = a.sampleContent) == null ? void 0 : t.buttonVariables) || {}
|
|
4855
4873
|
}
|
|
4856
4874
|
});
|
|
4857
4875
|
},
|
|
@@ -4860,14 +4878,14 @@ function ka({ template: a, setTemplate: s }) {
|
|
|
4860
4878
|
children: "×"
|
|
4861
4879
|
}
|
|
4862
4880
|
)
|
|
4863
|
-
] }, `global-body-sample-${
|
|
4881
|
+
] }, `global-body-sample-${h}`);
|
|
4864
4882
|
}) })
|
|
4865
4883
|
] });
|
|
4866
4884
|
})()
|
|
4867
4885
|
] }) })
|
|
4868
4886
|
] }),
|
|
4869
4887
|
a.type === "CAROUSEL" && /* @__PURE__ */ e("div", { className: "rsp-space-y-6", children: /* @__PURE__ */ e(
|
|
4870
|
-
|
|
4888
|
+
ya,
|
|
4871
4889
|
{
|
|
4872
4890
|
template: a,
|
|
4873
4891
|
setTemplate: s,
|
|
@@ -4875,62 +4893,62 @@ function ka({ template: a, setTemplate: s }) {
|
|
|
4875
4893
|
}
|
|
4876
4894
|
) }),
|
|
4877
4895
|
a.type !== "CAROUSEL" && /* @__PURE__ */ e("div", { className: "rsp-space-y-6", children: /* @__PURE__ */ e(
|
|
4878
|
-
|
|
4896
|
+
ha,
|
|
4879
4897
|
{
|
|
4880
4898
|
template: a,
|
|
4881
4899
|
setTemplate: s
|
|
4882
4900
|
}
|
|
4883
4901
|
) }),
|
|
4884
4902
|
/* @__PURE__ */ e(
|
|
4885
|
-
|
|
4903
|
+
ye,
|
|
4886
4904
|
{
|
|
4887
|
-
isOpen:
|
|
4888
|
-
onClose: () =>
|
|
4905
|
+
isOpen: n,
|
|
4906
|
+
onClose: () => i(!1),
|
|
4889
4907
|
onSelect: l
|
|
4890
4908
|
}
|
|
4891
4909
|
)
|
|
4892
4910
|
] });
|
|
4893
4911
|
}
|
|
4894
|
-
function
|
|
4912
|
+
function ka({ type: a }) {
|
|
4895
4913
|
switch (a) {
|
|
4896
4914
|
case "QUICK_REPLY":
|
|
4897
|
-
return /* @__PURE__ */ e(
|
|
4915
|
+
return /* @__PURE__ */ e(Ke, { className: "w-4 h-4" });
|
|
4898
4916
|
case "URL":
|
|
4899
|
-
return /* @__PURE__ */ e(
|
|
4917
|
+
return /* @__PURE__ */ e(Ge, { className: "w-4 h-4" });
|
|
4900
4918
|
case "CALL":
|
|
4901
|
-
return /* @__PURE__ */ e(
|
|
4919
|
+
return /* @__PURE__ */ e(Ve, { className: "w-4 h-4" });
|
|
4902
4920
|
case "FLOW":
|
|
4903
|
-
return /* @__PURE__ */ e(
|
|
4921
|
+
return /* @__PURE__ */ e(Ye, { className: "w-4 h-4" });
|
|
4904
4922
|
default:
|
|
4905
4923
|
return null;
|
|
4906
4924
|
}
|
|
4907
4925
|
}
|
|
4908
|
-
function
|
|
4909
|
-
const
|
|
4910
|
-
s &&
|
|
4926
|
+
function Na({ buttons: a, flowButtonText: s, onShowAllOptions: n }) {
|
|
4927
|
+
const i = [...a];
|
|
4928
|
+
s && i.push({
|
|
4911
4929
|
id: "flow-button",
|
|
4912
4930
|
type: "QUICK_REPLY",
|
|
4913
4931
|
text: s
|
|
4914
4932
|
});
|
|
4915
|
-
const
|
|
4933
|
+
const c = i.slice(0, 2);
|
|
4916
4934
|
return /* @__PURE__ */ r("div", { className: "rsp-divide-y rsp-divide-gray-200", children: [
|
|
4917
|
-
|
|
4935
|
+
c.map((o) => /* @__PURE__ */ r(
|
|
4918
4936
|
"button",
|
|
4919
4937
|
{
|
|
4920
4938
|
className: "rsp-w-full rsp-py-4 rsp-text-[#128C7E] rsp-text-[15px] rsp-font-medium rsp-bg-white hover:rsp-bg-gray-50 rsp-flex rsp-items-center rsp-gap-3 rsp-px-4 rsp-transition-colors",
|
|
4921
4939
|
style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' },
|
|
4922
4940
|
children: [
|
|
4923
|
-
/* @__PURE__ */ e("div", { className: "rsp-text-[#128C7E]", children: /* @__PURE__ */ e(
|
|
4924
|
-
/* @__PURE__ */ e("span", { className: "rsp-flex-1 rsp-text-left rsp-break-words rsp-break-all rsp-whitespace-pre-wrap", children:
|
|
4925
|
-
|
|
4941
|
+
/* @__PURE__ */ e("div", { className: "rsp-text-[#128C7E]", children: /* @__PURE__ */ e(ka, { type: o.type }) }),
|
|
4942
|
+
/* @__PURE__ */ e("span", { className: "rsp-flex-1 rsp-text-left rsp-break-words rsp-break-all rsp-whitespace-pre-wrap", children: o.text }),
|
|
4943
|
+
o.id === "flow-button" && /* @__PURE__ */ e(_e, { className: "rsp-w-5 rsp-h-5 rsp-text-[#128C7E] rsp-ml-auto" })
|
|
4926
4944
|
]
|
|
4927
4945
|
},
|
|
4928
|
-
|
|
4946
|
+
o.id
|
|
4929
4947
|
)),
|
|
4930
|
-
|
|
4948
|
+
i.length > 2 && /* @__PURE__ */ r(
|
|
4931
4949
|
"button",
|
|
4932
4950
|
{
|
|
4933
|
-
onClick:
|
|
4951
|
+
onClick: n,
|
|
4934
4952
|
className: "rsp-w-full rsp-py-4 rsp-text-[#128C7E] rsp-text-[15px] rsp-font-medium rsp-bg-white hover:rsp-bg-gray-50 rsp-flex rsp-items-center rsp-justify-center rsp-transition-colors",
|
|
4935
4953
|
style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' },
|
|
4936
4954
|
children: [
|
|
@@ -4941,25 +4959,25 @@ function Ca({ buttons: a, flowButtonText: s, onShowAllOptions: i }) {
|
|
|
4941
4959
|
)
|
|
4942
4960
|
] });
|
|
4943
4961
|
}
|
|
4944
|
-
function
|
|
4945
|
-
var
|
|
4946
|
-
const [s,
|
|
4962
|
+
function Ca({ template: a }) {
|
|
4963
|
+
var V, d, N, M;
|
|
4964
|
+
const [s, n] = B(!1), [i, c] = B(0), o = (V = a.carousel) != null && V.cards ? a.carousel.cards.length : 0;
|
|
4947
4965
|
le(() => {
|
|
4948
|
-
a.type === "CAROUSEL" &&
|
|
4949
|
-
}, [
|
|
4950
|
-
const l = (
|
|
4951
|
-
var
|
|
4952
|
-
return ((
|
|
4953
|
-
}) : "",
|
|
4954
|
-
var
|
|
4955
|
-
return ((
|
|
4956
|
-
}) : "",
|
|
4957
|
-
var
|
|
4958
|
-
const
|
|
4959
|
-
if (!
|
|
4960
|
-
const
|
|
4961
|
-
return
|
|
4962
|
-
},
|
|
4966
|
+
a.type === "CAROUSEL" && o > 0 ? i >= o && c(0) : c(0);
|
|
4967
|
+
}, [o, a.type]);
|
|
4968
|
+
const l = (b) => b ? b.replace(/\{\{(\d+)\}\}/g, (y, t) => {
|
|
4969
|
+
var x, p;
|
|
4970
|
+
return ((p = (x = a.sampleContent) == null ? void 0 : x.headerVariables) == null ? void 0 : p[t]) || `[Variable ${t}]`;
|
|
4971
|
+
}) : "", v = (b) => b ? b.replace(/\{\{(\d+)\}\}/g, (y, t) => {
|
|
4972
|
+
var x, p;
|
|
4973
|
+
return ((p = (x = a.sampleContent) == null ? void 0 : x.bodyVariables) == null ? void 0 : p[t]) || `[Variable ${t}]`;
|
|
4974
|
+
}) : "", g = (b) => {
|
|
4975
|
+
var x;
|
|
4976
|
+
const y = (b == null ? void 0 : b.body) ?? "";
|
|
4977
|
+
if (!y) return "";
|
|
4978
|
+
const t = ((x = b == null ? void 0 : b.sampleContent) == null ? void 0 : x.bodyVariables) ?? {};
|
|
4979
|
+
return y.replace(/\{\{(\d+)\}\}/g, (p, w) => t[w] || `[Variable ${w}]`);
|
|
4980
|
+
}, h = a.headerType !== "NONE" || a.body || a.footer || a.buttons.length > 0 || a.type === "CAROUSEL" && ((d = a.carousel) == null ? void 0 : d.cards.length), k = a.headerText || a.body || a.footer;
|
|
4963
4981
|
return /* @__PURE__ */ r("div", { className: "rsp-bg-white rsp-rounded-lg rsp-shadow-sm rsp-border rsp-border-gray-200", children: [
|
|
4964
4982
|
/* @__PURE__ */ r("div", { className: "rsp-p-4 rsp-border-b rsp-border-gray-200", children: [
|
|
4965
4983
|
/* @__PURE__ */ e("h3", { className: "rsp-text-lg rsp-font-semibold rsp-text-gray-900", children: "Preview" }),
|
|
@@ -5006,7 +5024,7 @@ function Ea({ template: a }) {
|
|
|
5006
5024
|
] }),
|
|
5007
5025
|
/* @__PURE__ */ r("div", { className: "rsp-absolute rsp-top-[105px] rsp-left-0 rsp-right-0 rsp-bottom-[60px] rsp-bg-gradient-to-b rsp-from-[#E8E2DB] rsp-via-[#E5DDD5] rsp-to-[#DDD5CC] rsp-overflow-y-auto", children: [
|
|
5008
5026
|
/* @__PURE__ */ e("div", { className: "rsp-absolute rsp-inset-0 rsp-opacity-[0.03]", style: { backgroundImage: `url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23000000' fill-opacity='0.08'%3E%3Cpath d='M40 40c0-4.4-3.6-8-8-8s-8 3.6-8 8 3.6 8 8 8 8-3.6 8-8zm0-32c0-4.4-3.6-8-8-8s-8 3.6-8 8 3.6 8 8 8 8-3.6 8-8zm32 32c0-4.4-3.6-8-8-8s-8 3.6-8 8 3.6 8 8 8 8-3.6 8-8z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E")` } }),
|
|
5009
|
-
/* @__PURE__ */ e("div", { className: "rsp-relative rsp-px-4 rsp-py-4", children:
|
|
5027
|
+
/* @__PURE__ */ e("div", { className: "rsp-relative rsp-px-4 rsp-py-4", children: h ? /* @__PURE__ */ r("div", { className: "rsp-flex rsp-flex-col rsp-items-start", children: [
|
|
5010
5028
|
a.headerType === "MEDIA" && a.mediaUrl && /* @__PURE__ */ r("div", { className: "rsp-max-w-[220px] rsp-w-auto rsp-rounded-xl rsp-overflow-hidden rsp-shadow-md rsp-mb-1.5 rsp-animate-slide-up rsp-border rsp-border-gray-200", children: [
|
|
5011
5029
|
a.mediaType === "IMAGE" && /* @__PURE__ */ e(
|
|
5012
5030
|
"img",
|
|
@@ -5014,8 +5032,8 @@ function Ea({ template: a }) {
|
|
|
5014
5032
|
src: a.mediaUrl,
|
|
5015
5033
|
alt: "Header media",
|
|
5016
5034
|
className: "rsp-w-full rsp-max-h-[150px] rsp-object-cover rsp-block",
|
|
5017
|
-
onError: (
|
|
5018
|
-
|
|
5035
|
+
onError: (b) => {
|
|
5036
|
+
b.currentTarget.style.display = "none";
|
|
5019
5037
|
}
|
|
5020
5038
|
}
|
|
5021
5039
|
),
|
|
@@ -5031,29 +5049,29 @@ function Ea({ template: a }) {
|
|
|
5031
5049
|
] })
|
|
5032
5050
|
] }) })
|
|
5033
5051
|
] }),
|
|
5034
|
-
|
|
5052
|
+
k && /* @__PURE__ */ e("div", { className: "rsp-flex rsp-justify-start rsp-mb-1.5", children: /* @__PURE__ */ r("div", { className: "rsp-bg-gradient-to-b rsp-from-white rsp-to-[#fafafa] rsp-rounded-[12px] rsp-max-w-[220px] rsp-shadow-[0_2px_8px_rgba(0,0,0,0.08)] rsp-relative rsp-border rsp-border-gray-100 rsp-animate-slide-up", children: [
|
|
5035
5053
|
a.headerType === "TEXT" && a.headerText && /* @__PURE__ */ e("div", { className: "rsp-px-4 rsp-pt-3 rsp-pb-2", children: /* @__PURE__ */ e("div", { className: "rsp-text-[15px] rsp-font-semibold rsp-text-[#111b21] rsp-leading-[1.3] rsp-tracking-normal rsp-break-words", style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' }, children: l(a.headerText) }) }),
|
|
5036
|
-
a.body && /* @__PURE__ */ e("div", { className: "rsp-px-4 rsp-py-2", children: /* @__PURE__ */ e("div", { className: "rsp-text-[14px] rsp-text-[#111b21] rsp-leading-[1.4] rsp-whitespace-pre-wrap rsp-tracking-normal rsp-break-words", style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' }, children:
|
|
5054
|
+
a.body && /* @__PURE__ */ e("div", { className: "rsp-px-4 rsp-py-2", children: /* @__PURE__ */ e("div", { className: "rsp-text-[14px] rsp-text-[#111b21] rsp-leading-[1.4] rsp-whitespace-pre-wrap rsp-tracking-normal rsp-break-words", style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' }, children: v(a.body) }) }),
|
|
5037
5055
|
a.footer && /* @__PURE__ */ e("div", { className: "rsp-px-4 rsp-pb-2", children: /* @__PURE__ */ e("div", { className: "rsp-text-[12px] rsp-text-[#667781] rsp-pt-2 rsp-border-t rsp-border-gray-100 rsp-break-words rsp-break-all rsp-whitespace-pre-wrap", style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' }, children: a.footer }) }),
|
|
5038
5056
|
/* @__PURE__ */ e("div", { className: "rsp-px-4 rsp-pb-2 rsp-text-right", children: /* @__PURE__ */ r("div", { className: "rsp-text-[11px] rsp-text-[#667781] rsp-flex rsp-items-center rsp-justify-end rsp-gap-1 rsp-opacity-80", style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' }, children: [
|
|
5039
5057
|
"9:41 AM",
|
|
5040
5058
|
/* @__PURE__ */ e("svg", { className: "rsp-w-3 rsp-h-3 rsp-text-[#53bdeb]", viewBox: "0 0 16 15", fill: "currentColor", children: /* @__PURE__ */ e("path", { d: "M15.01 3.316l-.478-.372a.365.365 0 0 0-.51.063L8.666 9.879a.32.32 0 0 1-.484.033l-.358-.325a.319.319 0 0 0-.484.032l-.378.483a.418.418 0 0 0 .036.541l1.32 1.266c.143.14.361.125.484-.033l6.272-8.048a.366.366 0 0 0-.064-.512zm-4.1 0l-.478-.372a.365.365 0 0 0-.51.063L4.566 9.879a.32.32 0 0 1-.484.033L1.891 7.769a.319.319 0 0 0-.484.032l-.378.483a.418.418 0 0 0 .036.541l3.61 3.463c.143.14.361.125.484-.033l6.272-8.048a.365.365 0 0 0-.064-.512z" }) })
|
|
5041
5059
|
] }) })
|
|
5042
5060
|
] }) }),
|
|
5043
|
-
a.type === "CAROUSEL" && (((M = (
|
|
5061
|
+
a.type === "CAROUSEL" && (((M = (N = a.carousel) == null ? void 0 : N.cards) == null ? void 0 : M.length) || 0) > 0 && /* @__PURE__ */ e("div", { className: "rsp-flex rsp-justify-start rsp-mb-1.5", children: /* @__PURE__ */ e("div", { className: "rsp-w-[220px] rsp-animate-slide-up", children: /* @__PURE__ */ e("div", { className: "rsp-bg-gradient-to-b rsp-from-white rsp-to-[#fafafa] rsp-rounded-[12px] rsp-overflow-hidden rsp-shadow-[0_2px_8px_rgba(0,0,0,0.08)] rsp-border rsp-border-gray-100 rsp-relative rsp-min-h-[280px] rsp-flex rsp-flex-col", children: /* @__PURE__ */ r("div", { className: "rsp-relative rsp-flex-1 rsp-flex rsp-flex-col", children: [
|
|
5044
5062
|
(() => {
|
|
5045
|
-
var
|
|
5046
|
-
const
|
|
5063
|
+
var y, t;
|
|
5064
|
+
const b = a.carousel && a.carousel.cards.length > 0 ? a.carousel.cards[i] || a.carousel.cards[0] : void 0;
|
|
5047
5065
|
return /* @__PURE__ */ r("div", { className: "rsp-flex rsp-flex-col rsp-h-full", children: [
|
|
5048
|
-
/* @__PURE__ */ e("div", { className: "rsp-relative rsp-w-full rsp-h-[140px] rsp-bg-gray-100 rsp-group rsp-flex-shrink-0", children:
|
|
5049
|
-
((
|
|
5066
|
+
/* @__PURE__ */ e("div", { className: "rsp-relative rsp-w-full rsp-h-[140px] rsp-bg-gray-100 rsp-group rsp-flex-shrink-0", children: b && b.mediaUrl ? /* @__PURE__ */ r(ce, { children: [
|
|
5067
|
+
((y = a.carousel) == null ? void 0 : y.type) === "IMAGE" ? /* @__PURE__ */ e(
|
|
5050
5068
|
"img",
|
|
5051
5069
|
{
|
|
5052
|
-
src:
|
|
5070
|
+
src: b.mediaUrl,
|
|
5053
5071
|
alt: "Carousel card",
|
|
5054
5072
|
className: "rsp-w-full rsp-h-full rsp-object-cover",
|
|
5055
|
-
onError: (
|
|
5056
|
-
|
|
5073
|
+
onError: (x) => {
|
|
5074
|
+
x.currentTarget.style.display = "none";
|
|
5057
5075
|
}
|
|
5058
5076
|
}
|
|
5059
5077
|
) : /* @__PURE__ */ e("div", { className: "rsp-relative rsp-w-full rsp-h-full rsp-bg-gradient-to-br rsp-from-gray-800 rsp-to-gray-900 rsp-flex rsp-items-center rsp-justify-center", children: /* @__PURE__ */ e("div", { className: "rsp-w-10 rsp-h-10 rsp-bg-black rsp-bg-opacity-70 rsp-rounded-full rsp-flex rsp-items-center rsp-justify-center rsp-shadow-lg", children: /* @__PURE__ */ e("div", { className: "rsp-w-0 rsp-h-0 rsp-border-l-[6px] rsp-border-l-white rsp-border-t-[5px] rsp-border-t-transparent rsp-border-b-[5px] rsp-border-b-transparent rsp-ml-1" }) }) }),
|
|
@@ -5061,8 +5079,8 @@ function Ea({ template: a }) {
|
|
|
5061
5079
|
/* @__PURE__ */ e(
|
|
5062
5080
|
"button",
|
|
5063
5081
|
{
|
|
5064
|
-
onClick: () =>
|
|
5065
|
-
(
|
|
5082
|
+
onClick: () => c(
|
|
5083
|
+
(x) => x > 0 ? x - 1 : a.carousel.cards.length - 1
|
|
5066
5084
|
),
|
|
5067
5085
|
className: "rsp-absolute rsp-left-1 rsp-top-1/2 rsp-transform -rsp-translate-y-1/2 rsp-z-20 rsp-w-6 rsp-h-6 rsp-bg-black rsp-bg-opacity-50 rsp-rounded-full rsp-flex rsp-items-center rsp-justify-center rsp-text-white hover:rsp-bg-opacity-80 rsp-transition-all rsp-opacity-0 group-hover:rsp-opacity-100",
|
|
5068
5086
|
children: /* @__PURE__ */ e("svg", { className: "rsp-w-4 rsp-h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 19l-7-7 7-7" }) })
|
|
@@ -5071,8 +5089,8 @@ function Ea({ template: a }) {
|
|
|
5071
5089
|
/* @__PURE__ */ e(
|
|
5072
5090
|
"button",
|
|
5073
5091
|
{
|
|
5074
|
-
onClick: () =>
|
|
5075
|
-
(
|
|
5092
|
+
onClick: () => c(
|
|
5093
|
+
(x) => x < a.carousel.cards.length - 1 ? x + 1 : 0
|
|
5076
5094
|
),
|
|
5077
5095
|
className: "rsp-absolute rsp-right-1 rsp-top-1/2 rsp-transform -rsp-translate-y-1/2 rsp-z-20 rsp-w-6 rsp-h-6 rsp-bg-black rsp-bg-opacity-50 rsp-rounded-full rsp-flex rsp-items-center rsp-justify-center rsp-text-white hover:rsp-bg-opacity-80 rsp-transition-all rsp-opacity-0 group-hover:rsp-opacity-100",
|
|
5078
5096
|
children: /* @__PURE__ */ e("svg", { className: "rsp-w-4 rsp-h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5l7 7-7 7" }) })
|
|
@@ -5080,44 +5098,44 @@ function Ea({ template: a }) {
|
|
|
5080
5098
|
)
|
|
5081
5099
|
] }),
|
|
5082
5100
|
/* @__PURE__ */ r("div", { className: "rsp-absolute rsp-top-2 rsp-right-2 rsp-bg-black rsp-bg-opacity-60 rsp-text-white rsp-text-[10px] rsp-px-2 rsp-py-0.5 rsp-rounded-full rsp-backdrop-blur-sm", style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' }, children: [
|
|
5083
|
-
|
|
5101
|
+
i + 1,
|
|
5084
5102
|
"/",
|
|
5085
5103
|
a.carousel ? a.carousel.cards.length : 0
|
|
5086
5104
|
] })
|
|
5087
5105
|
] }) : /* @__PURE__ */ e("div", { className: "rsp-w-full rsp-h-full rsp-flex rsp-items-center rsp-justify-center", children: /* @__PURE__ */ r("div", { className: "rsp-text-center", children: [
|
|
5088
|
-
/* @__PURE__ */ e("svg", { className: "rsp-w-12 rsp-h-12 rsp-mx-auto rsp-text-gray-400 rsp-mb-2", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: ((
|
|
5106
|
+
/* @__PURE__ */ e("svg", { className: "rsp-w-12 rsp-h-12 rsp-mx-auto rsp-text-gray-400 rsp-mb-2", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: ((t = a.carousel) == null ? void 0 : t.type) === "VIDEO" ? /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z" }) : /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" }) }),
|
|
5089
5107
|
/* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-500", style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' }, children: "No media" })
|
|
5090
5108
|
] }) }) }),
|
|
5091
|
-
/* @__PURE__ */ e("div", { className: "rsp-px-4 rsp-py-3 rsp-flex-1 rsp-flex rsp-items-start", children: /* @__PURE__ */ e("p", { className: "rsp-text-[13px] rsp-text-[#111b21] rsp-leading-[1.4] rsp-line-clamp-3", style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' }, children:
|
|
5092
|
-
/* @__PURE__ */ e("div", { className: "rsp-border-t rsp-border-gray-100 rsp-mt-auto", children:
|
|
5109
|
+
/* @__PURE__ */ e("div", { className: "rsp-px-4 rsp-py-3 rsp-flex-1 rsp-flex rsp-items-start", children: /* @__PURE__ */ e("p", { className: "rsp-text-[13px] rsp-text-[#111b21] rsp-leading-[1.4] rsp-line-clamp-3", style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' }, children: b ? g(b) : "Card body text..." }) }),
|
|
5110
|
+
/* @__PURE__ */ e("div", { className: "rsp-border-t rsp-border-gray-100 rsp-mt-auto", children: b && b.buttons.length > 0 ? /* @__PURE__ */ e(ce, { children: b.buttons.map((x, p) => /* @__PURE__ */ e(
|
|
5093
5111
|
"div",
|
|
5094
5112
|
{
|
|
5095
|
-
className: `rsp-px-4 rsp-py-3 rsp-text-center rsp-text-[14px] rsp-text-[#128C7E] rsp-font-medium rsp-break-words rsp-whitespace-pre-wrap ${
|
|
5113
|
+
className: `rsp-px-4 rsp-py-3 rsp-text-center rsp-text-[14px] rsp-text-[#128C7E] rsp-font-medium rsp-break-words rsp-whitespace-pre-wrap ${p < b.buttons.length - 1 ? "rsp-border-b rsp-border-gray-100" : ""}`,
|
|
5096
5114
|
style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' },
|
|
5097
5115
|
children: /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-justify-center rsp-gap-2", children: [
|
|
5098
|
-
|
|
5099
|
-
(
|
|
5100
|
-
/* @__PURE__ */ e("span", { className: "rsp-inline-block rsp-max-w-[180px] rsp-break-words rsp-break-all rsp-whitespace-pre-wrap rsp-text-center", children:
|
|
5116
|
+
x.type === "URL" && /* @__PURE__ */ e("svg", { className: "rsp-w-4 rsp-h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" }) }),
|
|
5117
|
+
(x.type === "CALL" || x.type === "PHONE_NUMBER") && /* @__PURE__ */ e("svg", { className: "rsp-w-4 rsp-h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z" }) }),
|
|
5118
|
+
/* @__PURE__ */ e("span", { className: "rsp-inline-block rsp-max-w-[180px] rsp-break-words rsp-break-all rsp-whitespace-pre-wrap rsp-text-center", children: x.text })
|
|
5101
5119
|
] })
|
|
5102
5120
|
},
|
|
5103
|
-
|
|
5121
|
+
x.id
|
|
5104
5122
|
)) }) : /* @__PURE__ */ e("div", { className: "rsp-px-4 rsp-py-3 rsp-text-center rsp-text-xs rsp-text-gray-400", style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' }, children: "No buttons" }) })
|
|
5105
5123
|
] });
|
|
5106
5124
|
})(),
|
|
5107
|
-
a.carousel && a.carousel.cards.length > 1 && /* @__PURE__ */ e("div", { className: "rsp-flex rsp-items-center rsp-justify-center rsp-gap-1.5 rsp-py-3 rsp-bg-white rsp-border-t rsp-border-gray-100", children: a.carousel && a.carousel.cards.map((
|
|
5125
|
+
a.carousel && a.carousel.cards.length > 1 && /* @__PURE__ */ e("div", { className: "rsp-flex rsp-items-center rsp-justify-center rsp-gap-1.5 rsp-py-3 rsp-bg-white rsp-border-t rsp-border-gray-100", children: a.carousel && a.carousel.cards.map((b, y) => /* @__PURE__ */ e(
|
|
5108
5126
|
"button",
|
|
5109
5127
|
{
|
|
5110
|
-
onClick: () =>
|
|
5111
|
-
className: `rsp-w-2 rsp-h-2 rsp-rounded-full rsp-transition-all ${
|
|
5128
|
+
onClick: () => c(y),
|
|
5129
|
+
className: `rsp-w-2 rsp-h-2 rsp-rounded-full rsp-transition-all ${y === i ? "rsp-bg-[#128C7E] rsp-w-6" : "rsp-bg-gray-300 hover:rsp-bg-gray-400"}`
|
|
5112
5130
|
},
|
|
5113
|
-
|
|
5131
|
+
y
|
|
5114
5132
|
)) })
|
|
5115
5133
|
] }) }) }) }),
|
|
5116
5134
|
a.buttons.length > 0 && /* @__PURE__ */ e("div", { className: "rsp-flex rsp-justify-start", children: /* @__PURE__ */ e("div", { className: "rsp-bg-gradient-to-b rsp-from-white rsp-to-[#fafafa] rsp-rounded-[12px] rsp-overflow-hidden rsp-shadow-[0_2px_8px_rgba(0,0,0,0.08)] rsp-max-w-[220px] rsp-w-full rsp-border rsp-border-gray-100 rsp-animate-slide-up", children: /* @__PURE__ */ e(
|
|
5117
|
-
|
|
5135
|
+
Na,
|
|
5118
5136
|
{
|
|
5119
5137
|
buttons: a.buttons,
|
|
5120
|
-
onShowAllOptions: () =>
|
|
5138
|
+
onShowAllOptions: () => n(!0)
|
|
5121
5139
|
}
|
|
5122
5140
|
) }) })
|
|
5123
5141
|
] }) : /* @__PURE__ */ e("div", { className: "rsp-flex rsp-items-center rsp-justify-center rsp-h-[300px]", children: /* @__PURE__ */ r("div", { className: "rsp-text-center rsp-text-gray-500 rsp-animate-fade-in", children: [
|
|
@@ -5137,19 +5155,19 @@ function Ea({ template: a }) {
|
|
|
5137
5155
|
className: "rsp-w-full rsp-bg-[#F0F2F5] rsp-rounded-t-2xl rsp-shadow-lg rsp-animate-slide-up",
|
|
5138
5156
|
children: [
|
|
5139
5157
|
/* @__PURE__ */ e("div", { className: "rsp-p-4 rsp-border-b rsp-border-gray-300", children: /* @__PURE__ */ e("h4", { className: "rsp-font-bold rsp-text-center rsp-text-gray-800 rsp-text-md", children: a.body || "Options" }) }),
|
|
5140
|
-
/* @__PURE__ */ e("div", { className: "rsp-max-h-[250px] rsp-overflow-y-auto", children: a.buttons.map((
|
|
5158
|
+
/* @__PURE__ */ e("div", { className: "rsp-max-h-[250px] rsp-overflow-y-auto", children: a.buttons.map((b, y) => /* @__PURE__ */ e(
|
|
5141
5159
|
"div",
|
|
5142
5160
|
{
|
|
5143
|
-
className: `rsp-p-4 rsp-text-center rsp-text-[15px] rsp-text-[#128C7E] rsp-font-medium ${
|
|
5161
|
+
className: `rsp-p-4 rsp-text-center rsp-text-[15px] rsp-text-[#128C7E] rsp-font-medium ${y < a.buttons.length - 1 ? "rsp-border-b rsp-border-gray-300" : ""}`,
|
|
5144
5162
|
style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' },
|
|
5145
|
-
children:
|
|
5163
|
+
children: b.text
|
|
5146
5164
|
},
|
|
5147
|
-
|
|
5165
|
+
b.id
|
|
5148
5166
|
)) }),
|
|
5149
5167
|
/* @__PURE__ */ e(
|
|
5150
5168
|
"div",
|
|
5151
5169
|
{
|
|
5152
|
-
onClick: () =>
|
|
5170
|
+
onClick: () => n(!1),
|
|
5153
5171
|
className: "rsp-mt-2 rsp-p-4 rsp-text-center rsp-font-bold rsp-text-[#128C7E] rsp-bg-white rsp-cursor-pointer rsp-shadow-inner",
|
|
5154
5172
|
style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' },
|
|
5155
5173
|
children: "Close"
|
|
@@ -5163,7 +5181,7 @@ function Ea({ template: a }) {
|
|
|
5163
5181
|
] }) }) })
|
|
5164
5182
|
] });
|
|
5165
5183
|
}
|
|
5166
|
-
const
|
|
5184
|
+
const Le = {
|
|
5167
5185
|
name: "",
|
|
5168
5186
|
category: "MARKETING",
|
|
5169
5187
|
type: "BASIC",
|
|
@@ -5175,108 +5193,106 @@ const Te = {
|
|
|
5175
5193
|
footer: "",
|
|
5176
5194
|
buttons: []
|
|
5177
5195
|
};
|
|
5178
|
-
function
|
|
5179
|
-
var
|
|
5180
|
-
const
|
|
5196
|
+
function Sa({ editId: a, onCancel: s }) {
|
|
5197
|
+
var y, t, x;
|
|
5198
|
+
const [n, i] = B(Le), [c, o] = B(!0), [l, v] = B(!1), [g, h] = B(!1), [k, V] = B(null), [d, N] = B({
|
|
5181
5199
|
isOpen: !1
|
|
5182
5200
|
});
|
|
5183
|
-
|
|
5201
|
+
B({
|
|
5184
5202
|
isOpen: !1
|
|
5185
5203
|
}), le(() => {
|
|
5186
|
-
if (
|
|
5187
|
-
const
|
|
5188
|
-
|
|
5204
|
+
if (k) {
|
|
5205
|
+
const p = setTimeout(() => {
|
|
5206
|
+
V(null);
|
|
5189
5207
|
}, 5e3);
|
|
5190
|
-
return () => clearTimeout(
|
|
5208
|
+
return () => clearTimeout(p);
|
|
5191
5209
|
}
|
|
5192
|
-
}, [
|
|
5193
|
-
const
|
|
5194
|
-
var
|
|
5210
|
+
}, [k]);
|
|
5211
|
+
const M = async () => {
|
|
5212
|
+
var p, w, A;
|
|
5195
5213
|
try {
|
|
5196
|
-
if (
|
|
5214
|
+
if (h(!0), V(null), !n.name || !n.body)
|
|
5197
5215
|
throw new Error("Template name and body are required");
|
|
5198
|
-
const
|
|
5199
|
-
if (!
|
|
5216
|
+
const R = localStorage.getItem("account"), f = R ? JSON.parse(R) : { apiKey: "" };
|
|
5217
|
+
if (!f.apiKey)
|
|
5200
5218
|
throw new Error("Please set your API key in the dashboard first");
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
R = {
|
|
5219
|
+
let C;
|
|
5220
|
+
if (a) {
|
|
5221
|
+
const U = await sa(f.apiKey, a, n);
|
|
5222
|
+
if (!U.success)
|
|
5223
|
+
throw new Error(U.message || "Update failed");
|
|
5224
|
+
C = {
|
|
5208
5225
|
status: "success",
|
|
5209
|
-
data: { details: [{ template_name: n.name, template_id:
|
|
5226
|
+
data: { details: [{ template_name: n.name, template_id: a }] }
|
|
5210
5227
|
};
|
|
5211
|
-
} else if (
|
|
5212
|
-
throw new Error(
|
|
5213
|
-
if (
|
|
5214
|
-
throw new Error(
|
|
5215
|
-
|
|
5228
|
+
} else if (C = await ra(f, n), C.status === "error")
|
|
5229
|
+
throw new Error(C.message);
|
|
5230
|
+
if (C.status === "error")
|
|
5231
|
+
throw new Error(C.message);
|
|
5232
|
+
N({
|
|
5216
5233
|
isOpen: !0,
|
|
5217
|
-
templateName: (
|
|
5218
|
-
templateId: (
|
|
5219
|
-
template: (
|
|
5220
|
-
}),
|
|
5221
|
-
} catch (
|
|
5222
|
-
|
|
5234
|
+
templateName: (p = C.data) == null ? void 0 : p.details[0].template_name,
|
|
5235
|
+
templateId: (w = C.data) == null ? void 0 : w.details[0].template_id,
|
|
5236
|
+
template: (A = C.data) == null ? void 0 : A.template
|
|
5237
|
+
}), i(Le);
|
|
5238
|
+
} catch (R) {
|
|
5239
|
+
V(R instanceof Error ? R.message : "An error occurred while creating the template");
|
|
5223
5240
|
} finally {
|
|
5224
|
-
|
|
5241
|
+
h(!1);
|
|
5225
5242
|
}
|
|
5226
5243
|
};
|
|
5227
5244
|
le(() => {
|
|
5228
|
-
|
|
5229
|
-
if (!V) return;
|
|
5245
|
+
if (!a) return;
|
|
5230
5246
|
(async () => {
|
|
5231
5247
|
try {
|
|
5232
|
-
const
|
|
5233
|
-
if (!
|
|
5248
|
+
const w = localStorage.getItem("account"), A = w ? JSON.parse(w) : { apiKey: "" };
|
|
5249
|
+
if (!A.apiKey)
|
|
5234
5250
|
throw new Error("Please set your API key in the dashboard first");
|
|
5235
|
-
const
|
|
5236
|
-
|
|
5237
|
-
} catch (
|
|
5238
|
-
console.error("Failed to load template for edit",
|
|
5239
|
-
} finally {
|
|
5251
|
+
const R = await na(A.apiKey, a);
|
|
5252
|
+
i((f) => ({ ...f, ...R }));
|
|
5253
|
+
} catch (w) {
|
|
5254
|
+
console.error("Failed to load template for edit", w), V(w instanceof Error ? w.message : "Failed to load template");
|
|
5240
5255
|
}
|
|
5241
5256
|
})();
|
|
5242
|
-
}, []);
|
|
5243
|
-
const
|
|
5244
|
-
|
|
5257
|
+
}, [a]);
|
|
5258
|
+
const b = () => {
|
|
5259
|
+
N({ isOpen: !1 }), s && s();
|
|
5245
5260
|
};
|
|
5246
5261
|
return /* @__PURE__ */ r("div", { className: "rsp-min-h-screen rsp-bg-[#f5f7fc] rsp-rounded-lg rsp-shadow-sm", children: [
|
|
5247
5262
|
/* @__PURE__ */ r("div", { className: "rsp-max-w-[1200px] rsp-mx-auto rsp-px-6 rsp-h-full", children: [
|
|
5248
5263
|
/* @__PURE__ */ e("div", { className: "rsp-py-6 rsp-border-b rsp-border-gray-200", children: /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-justify-between", children: [
|
|
5249
|
-
/* @__PURE__ */ e("h1", { className: "rsp-text-2xl rsp-font-semibold rsp-text-[#0043ff]", children: "Add Template" }),
|
|
5264
|
+
/* @__PURE__ */ e("h1", { className: "rsp-text-2xl rsp-font-semibold rsp-text-[#0043ff]", children: a ? "Edit Template" : "Add Template" }),
|
|
5250
5265
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-3", children: [
|
|
5251
|
-
/* @__PURE__ */ e(
|
|
5252
|
-
"button",
|
|
5253
|
-
{
|
|
5254
|
-
onClick: () => {
|
|
5255
|
-
a ? a() : s ? i("/") : window.history.length > 1 && window.history.back();
|
|
5256
|
-
},
|
|
5257
|
-
className: "rsp-px-4 rsp-py-2 rsp-text-sm rsp-font-medium rsp-text-gray-700 rsp-bg-white rsp-border rsp-border-gray-300 rsp-rounded-md hover:rsp-bg-gray-50 rsp-transition-colors",
|
|
5258
|
-
children: "Cancel"
|
|
5259
|
-
}
|
|
5260
|
-
),
|
|
5261
5266
|
/* @__PURE__ */ r(
|
|
5262
5267
|
"button",
|
|
5263
5268
|
{
|
|
5264
|
-
onClick: () =>
|
|
5269
|
+
onClick: () => o(!c),
|
|
5265
5270
|
className: `rsp-flex rsp-items-center rsp-gap-2 rsp-px-4 rsp-py-2 rsp-rounded-md rsp-text-sm rsp-font-medium rsp-transition-colors
|
|
5266
|
-
${
|
|
5271
|
+
${c ? "rsp-bg-blue-100 rsp-text-blue-700 rsp-border rsp-border-blue-200" : "rsp-bg-gray-100 rsp-text-gray-700 rsp-border rsp-border-gray-200"}`,
|
|
5267
5272
|
children: [
|
|
5268
5273
|
/* @__PURE__ */ r("svg", { className: "rsp-w-4 rsp-h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: [
|
|
5269
5274
|
/* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z" }),
|
|
5270
5275
|
/* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" })
|
|
5271
5276
|
] }),
|
|
5272
|
-
|
|
5277
|
+
c ? "Hide Preview" : "Show Preview"
|
|
5278
|
+
]
|
|
5279
|
+
}
|
|
5280
|
+
),
|
|
5281
|
+
/* @__PURE__ */ r(
|
|
5282
|
+
"button",
|
|
5283
|
+
{
|
|
5284
|
+
onClick: () => s == null ? void 0 : s(),
|
|
5285
|
+
className: "rsp-flex rsp-items-center rsp-gap-1 rsp-text-sm rsp-font-medium rsp-text-[#0043ff] hover:rsp-text-[#0033cc] rsp-transition-colors rsp-bg-transparent rsp-border-0 rsp-cursor-pointer",
|
|
5286
|
+
children: [
|
|
5287
|
+
/* @__PURE__ */ e(Fe, { className: "rsp-w-5 rsp-h-5 rsp-relative rsp-left-[6px]" }),
|
|
5288
|
+
"Back"
|
|
5273
5289
|
]
|
|
5274
5290
|
}
|
|
5275
5291
|
)
|
|
5276
5292
|
] })
|
|
5277
5293
|
] }) }),
|
|
5278
|
-
/* @__PURE__ */ r("div", { className: `rsp-py-8 ${
|
|
5279
|
-
/* @__PURE__ */ r("div", { className: `rsp-space-y-8 ${
|
|
5294
|
+
/* @__PURE__ */ r("div", { className: `rsp-py-8 ${c ? "rsp-grid xl:rsp-grid-cols-[1fr,400px] rsp-gap-8" : ""}`, children: [
|
|
5295
|
+
/* @__PURE__ */ r("div", { className: `rsp-space-y-8 ${c ? "" : "rsp-max-w-4xl rsp-mx-auto"}`, children: [
|
|
5280
5296
|
/* @__PURE__ */ r("div", { className: "rsp-bg-white rsp-p-6 rsp-rounded-lg rsp-shadow-sm rsp-space-y-6", children: [
|
|
5281
5297
|
/* @__PURE__ */ r("div", { children: [
|
|
5282
5298
|
/* @__PURE__ */ r("label", { className: "rsp-block rsp-text-sm rsp-font-medium rsp-text-gray-700 rsp-mb-2", children: [
|
|
@@ -5289,15 +5305,15 @@ function Ua({ onCancel: a }) {
|
|
|
5289
5305
|
{
|
|
5290
5306
|
type: "text",
|
|
5291
5307
|
value: n.name,
|
|
5292
|
-
onChange: (
|
|
5293
|
-
onBlur: () =>
|
|
5308
|
+
onChange: (p) => i({ ...n, name: p.target.value.replace(/\s/g, "_").replace(/[^a-zA-Z0-9_]/g, "").replace(/_+/g, "_") }),
|
|
5309
|
+
onBlur: () => v(!0),
|
|
5294
5310
|
className: "rsp-w-full rsp-px-0 rsp-py-2 rsp-border-0 rsp-border-b rsp-border-gray-300 rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-transparent",
|
|
5295
5311
|
placeholder: "Template name cannot Have capital letters and space"
|
|
5296
5312
|
}
|
|
5297
5313
|
),
|
|
5298
5314
|
/* @__PURE__ */ e("div", { className: "rsp-absolute rsp-bottom-0 rsp-left-0 rsp-w-4 rsp-h-0.5 rsp-bg-red-500" })
|
|
5299
5315
|
] }),
|
|
5300
|
-
!n.name &&
|
|
5316
|
+
!n.name && l && /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-red-600 rsp-mt-1", children: "Template name is required." }),
|
|
5301
5317
|
/* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-500 rsp-mt-1", children: "Template name cannot Have capital letters and space" })
|
|
5302
5318
|
] }),
|
|
5303
5319
|
/* @__PURE__ */ r("div", { className: "rsp-grid rsp-grid-cols-2 rsp-gap-6", children: [
|
|
@@ -5308,7 +5324,7 @@ function Ua({ onCancel: a }) {
|
|
|
5308
5324
|
"select",
|
|
5309
5325
|
{
|
|
5310
5326
|
value: n.category,
|
|
5311
|
-
onChange: (
|
|
5327
|
+
onChange: (p) => i({ ...n, category: p.target.value }),
|
|
5312
5328
|
className: "rsp-w-full rsp-px-0 rsp-py-2 rsp-border-0 rsp-border-b rsp-border-gray-300 rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-transparent rsp-appearance-none",
|
|
5313
5329
|
children: [
|
|
5314
5330
|
/* @__PURE__ */ e("option", { value: "MARKETING", children: "Marketing" }),
|
|
@@ -5328,9 +5344,9 @@ function Ua({ onCancel: a }) {
|
|
|
5328
5344
|
"select",
|
|
5329
5345
|
{
|
|
5330
5346
|
value: n.language,
|
|
5331
|
-
onChange: (
|
|
5347
|
+
onChange: (p) => i({ ...n, language: p.target.value }),
|
|
5332
5348
|
className: "rsp-w-full rsp-px-0 rsp-py-2 rsp-border-0 rsp-border-b rsp-border-gray-300 rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-transparent rsp-appearance-none",
|
|
5333
|
-
children:
|
|
5349
|
+
children: la.map((p) => /* @__PURE__ */ e("option", { value: p.value, children: p.label }, p.value))
|
|
5334
5350
|
}
|
|
5335
5351
|
),
|
|
5336
5352
|
/* @__PURE__ */ e("div", { className: "rsp-absolute rsp-inset-y-0 rsp-right-0 rsp-flex rsp-items-center rsp-px-2 rsp-pointer-events-none", children: /* @__PURE__ */ e("svg", { className: "rsp-w-4 rsp-h-4 rsp-text-gray-400", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" }) }) }),
|
|
@@ -5346,11 +5362,11 @@ function Ua({ onCancel: a }) {
|
|
|
5346
5362
|
"select",
|
|
5347
5363
|
{
|
|
5348
5364
|
value: n.type,
|
|
5349
|
-
onChange: (
|
|
5350
|
-
const
|
|
5351
|
-
|
|
5365
|
+
onChange: (p) => {
|
|
5366
|
+
const w = p.target.value;
|
|
5367
|
+
w === "CAROUSEL" && !n.carousel ? i({
|
|
5352
5368
|
...n,
|
|
5353
|
-
type:
|
|
5369
|
+
type: w,
|
|
5354
5370
|
carousel: {
|
|
5355
5371
|
type: "IMAGE",
|
|
5356
5372
|
cards: [{
|
|
@@ -5362,7 +5378,7 @@ function Ua({ onCancel: a }) {
|
|
|
5362
5378
|
buttons: []
|
|
5363
5379
|
}]
|
|
5364
5380
|
}
|
|
5365
|
-
}) :
|
|
5381
|
+
}) : i({ ...n, type: w });
|
|
5366
5382
|
},
|
|
5367
5383
|
className: "rsp-w-full rsp-px-0 rsp-py-2 rsp-border-0 rsp-border-b rsp-border-gray-300 rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-transparent rsp-appearance-none",
|
|
5368
5384
|
children: [
|
|
@@ -5382,7 +5398,7 @@ function Ua({ onCancel: a }) {
|
|
|
5382
5398
|
"select",
|
|
5383
5399
|
{
|
|
5384
5400
|
value: n.enableClickTracking.toString(),
|
|
5385
|
-
onChange: (
|
|
5401
|
+
onChange: (p) => i({ ...n, enableClickTracking: p.target.value === "true" }),
|
|
5386
5402
|
className: "rsp-w-full rsp-px-0 rsp-py-2 rsp-border-0 rsp-border-b rsp-border-gray-300 rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-transparent rsp-appearance-none",
|
|
5387
5403
|
children: [
|
|
5388
5404
|
/* @__PURE__ */ e("option", { value: "false", children: "False" }),
|
|
@@ -5395,18 +5411,18 @@ function Ua({ onCancel: a }) {
|
|
|
5395
5411
|
] })
|
|
5396
5412
|
] })
|
|
5397
5413
|
] }),
|
|
5398
|
-
/* @__PURE__ */ e("div", { className: "rsp-bg-white rsp-p-6 rsp-rounded-lg rsp-shadow-sm", children: /* @__PURE__ */ e(
|
|
5414
|
+
/* @__PURE__ */ e("div", { className: "rsp-bg-white rsp-p-6 rsp-rounded-lg rsp-shadow-sm", children: /* @__PURE__ */ e(va, { template: n, setTemplate: i }) }),
|
|
5399
5415
|
/* @__PURE__ */ r("div", { className: "rsp-bg-white rsp-p-6 rsp-rounded-lg rsp-shadow-sm rsp-pt-6 rsp-border-t rsp-border-gray-200", children: [
|
|
5400
|
-
|
|
5416
|
+
k && /* @__PURE__ */ r("div", { className: "rsp-mb-4 rsp-flex rsp-items-start rsp-gap-3 rsp-p-4 rsp-rounded-lg rsp-bg-red-50 rsp-border-l-4 rsp-border-l-red-500 rsp-relative rsp-animate-fade-in", children: [
|
|
5401
5417
|
/* @__PURE__ */ e(fe, { className: "rsp-w-5 rsp-h-5 rsp-text-red-500 rsp-flex-shrink-0 rsp-mt-0.5" }),
|
|
5402
5418
|
/* @__PURE__ */ r("div", { children: [
|
|
5403
5419
|
/* @__PURE__ */ e("h3", { className: "rsp-text-sm rsp-font-medium rsp-text-red-800", children: "Error" }),
|
|
5404
|
-
/* @__PURE__ */ e("p", { className: "rsp-mt-1 rsp-text-sm rsp-text-red-700", children:
|
|
5420
|
+
/* @__PURE__ */ e("p", { className: "rsp-mt-1 rsp-text-sm rsp-text-red-700", children: k })
|
|
5405
5421
|
] }),
|
|
5406
5422
|
/* @__PURE__ */ e(
|
|
5407
5423
|
"button",
|
|
5408
5424
|
{
|
|
5409
|
-
onClick: () =>
|
|
5425
|
+
onClick: () => V(null),
|
|
5410
5426
|
className: "rsp-absolute rsp-top-2 rsp-right-2 rsp-p-1 hover:rsp-bg-red-100 rsp-rounded-full",
|
|
5411
5427
|
children: /* @__PURE__ */ e(re, { className: "rsp-w-4 rsp-h-4 rsp-text-red-500" })
|
|
5412
5428
|
}
|
|
@@ -5415,53 +5431,50 @@ function Ua({ onCancel: a }) {
|
|
|
5415
5431
|
/* @__PURE__ */ e("div", { className: "rsp-flex rsp-gap-4", children: /* @__PURE__ */ e(
|
|
5416
5432
|
"button",
|
|
5417
5433
|
{
|
|
5418
|
-
onClick:
|
|
5419
|
-
disabled:
|
|
5434
|
+
onClick: M,
|
|
5435
|
+
disabled: g,
|
|
5420
5436
|
className: `rsp-flex-1 rsp-py-3 rsp-px-6 rsp-rounded-md rsp-transition-colors rsp-text-white rsp-font-medium rsp-text-sm
|
|
5421
|
-
${
|
|
5422
|
-
children:
|
|
5423
|
-
const u = new URLSearchParams(window.location.search).get("edit");
|
|
5424
|
-
return o ? u ? "Resubmitting for Approval..." : "Submitting for Approval..." : u ? "Resubmit for Approval" : "Submit for Approval";
|
|
5425
|
-
})()
|
|
5437
|
+
${g ? "rsp-bg-blue-600 rsp-cursor-not-allowed" : "rsp-bg-blue-600 hover:rsp-bg-blue-700 active:rsp-bg-blue-800"}`,
|
|
5438
|
+
children: g ? a ? "Resubmitting for Approval..." : "Submitting for Approval..." : a ? "Resubmit for Approval" : "Submit for Approval"
|
|
5426
5439
|
}
|
|
5427
5440
|
) })
|
|
5428
5441
|
] })
|
|
5429
5442
|
] }),
|
|
5430
|
-
|
|
5443
|
+
c && /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e("div", { className: "rsp-sticky rsp-top-4", children: /* @__PURE__ */ e(Ca, { template: n }) }) })
|
|
5431
5444
|
] })
|
|
5432
5445
|
] }),
|
|
5433
5446
|
/* @__PURE__ */ e(
|
|
5434
5447
|
te,
|
|
5435
5448
|
{
|
|
5436
|
-
isOpen:
|
|
5437
|
-
onClose:
|
|
5449
|
+
isOpen: d.isOpen,
|
|
5450
|
+
onClose: b,
|
|
5438
5451
|
title: "Success",
|
|
5439
5452
|
children: /* @__PURE__ */ r("div", { className: "rsp-space-y-4", children: [
|
|
5440
5453
|
/* @__PURE__ */ e("div", { className: "rsp-text-center", children: /* @__PURE__ */ e("p", { className: "rsp-text-green-600 rsp-font-medium rsp-mb-4", children: "Template created successfully!" }) }),
|
|
5441
|
-
|
|
5454
|
+
d.templateId && /* @__PURE__ */ r("div", { className: "rsp-bg-gray-50 rsp-p-4 rsp-rounded-lg rsp-space-y-2", children: [
|
|
5442
5455
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-justify-between", children: [
|
|
5443
5456
|
/* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-text-gray-600", children: "Template Name:" }),
|
|
5444
|
-
/* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-font-medium", children:
|
|
5457
|
+
/* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-font-medium", children: d.templateName })
|
|
5445
5458
|
] }),
|
|
5446
5459
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-justify-between", children: [
|
|
5447
5460
|
/* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-text-gray-600", children: "Template ID:" }),
|
|
5448
|
-
/* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-font-medium rsp-font-mono", children:
|
|
5461
|
+
/* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-font-medium rsp-font-mono", children: d.templateId })
|
|
5449
5462
|
] }),
|
|
5450
|
-
((
|
|
5463
|
+
((y = d.template) == null ? void 0 : y.meta_tid) && /* @__PURE__ */ r("div", { className: "rsp-flex rsp-justify-between", children: [
|
|
5451
5464
|
/* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-text-gray-600", children: "Meta TID:" }),
|
|
5452
|
-
/* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-font-medium rsp-font-mono", children:
|
|
5465
|
+
/* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-font-medium rsp-font-mono", children: d.template.meta_tid })
|
|
5453
5466
|
] }),
|
|
5454
|
-
((
|
|
5467
|
+
((t = d.template) == null ? void 0 : t.status) && /* @__PURE__ */ r("div", { className: "rsp-flex rsp-justify-between", children: [
|
|
5455
5468
|
/* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-text-gray-600", children: "Status:" }),
|
|
5456
5469
|
/* @__PURE__ */ e("span", { className: `rsp-text-sm rsp-font-medium rsp-capitalize ${// @ts-ignore
|
|
5457
|
-
|
|
5470
|
+
d.template.status === "pending" ? "rsp-text-yellow-600" : (
|
|
5458
5471
|
// @ts-ignore
|
|
5459
|
-
|
|
5460
|
-
)}`, children:
|
|
5472
|
+
d.template.status === "approved" ? "rsp-text-green-600" : "rsp-text-red-600"
|
|
5473
|
+
)}`, children: d.template.status })
|
|
5461
5474
|
] }),
|
|
5462
|
-
((
|
|
5475
|
+
((x = d.template) == null ? void 0 : x.quality) && /* @__PURE__ */ r("div", { className: "rsp-flex rsp-justify-between", children: [
|
|
5463
5476
|
/* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-text-gray-600", children: "Quality:" }),
|
|
5464
|
-
/* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-font-medium rsp-capitalize", children:
|
|
5477
|
+
/* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-font-medium rsp-capitalize", children: d.template.quality })
|
|
5465
5478
|
] })
|
|
5466
5479
|
] })
|
|
5467
5480
|
] })
|
|
@@ -5469,43 +5482,43 @@ function Ua({ onCancel: a }) {
|
|
|
5469
5482
|
)
|
|
5470
5483
|
] });
|
|
5471
5484
|
}
|
|
5472
|
-
const
|
|
5473
|
-
function
|
|
5474
|
-
const
|
|
5485
|
+
const Ea = Be({});
|
|
5486
|
+
function Va({ apiKey: a, pConfig: s, children: n }) {
|
|
5487
|
+
const i = Se(
|
|
5475
5488
|
() => ({ apiKey: a, resulMeta: s }),
|
|
5476
5489
|
[a, s]
|
|
5477
|
-
),
|
|
5490
|
+
), c = Te(null);
|
|
5478
5491
|
return le(() => {
|
|
5479
5492
|
if (typeof window > "u" || a === void 0 && !s)
|
|
5480
5493
|
return;
|
|
5481
|
-
let
|
|
5494
|
+
let o = {};
|
|
5482
5495
|
try {
|
|
5483
|
-
const
|
|
5484
|
-
|
|
5485
|
-
} catch (
|
|
5496
|
+
const g = localStorage.getItem("account");
|
|
5497
|
+
g && (o = JSON.parse(g));
|
|
5498
|
+
} catch (g) {
|
|
5486
5499
|
console.error(
|
|
5487
5500
|
"TrustSignalProvider: Failed to read account from storage",
|
|
5488
|
-
|
|
5501
|
+
g
|
|
5489
5502
|
);
|
|
5490
5503
|
}
|
|
5491
5504
|
const l = {
|
|
5492
|
-
...
|
|
5505
|
+
...o,
|
|
5493
5506
|
...a !== void 0 ? { apiKey: a } : {},
|
|
5494
5507
|
...s ? { resulMeta: s } : {}
|
|
5495
|
-
},
|
|
5496
|
-
if (
|
|
5508
|
+
}, v = JSON.stringify(l);
|
|
5509
|
+
if (v !== c.current)
|
|
5497
5510
|
try {
|
|
5498
|
-
localStorage.setItem("account",
|
|
5499
|
-
} catch (
|
|
5511
|
+
localStorage.setItem("account", v), c.current = v;
|
|
5512
|
+
} catch (g) {
|
|
5500
5513
|
console.error(
|
|
5501
5514
|
"TrustSignalProvider: Failed to persist account to storage",
|
|
5502
|
-
|
|
5515
|
+
g
|
|
5503
5516
|
);
|
|
5504
5517
|
}
|
|
5505
|
-
}, [a, s]), /* @__PURE__ */ e(
|
|
5518
|
+
}, [a, s]), /* @__PURE__ */ e(Ea.Provider, { value: i, children: n });
|
|
5506
5519
|
}
|
|
5507
5520
|
export {
|
|
5508
|
-
|
|
5509
|
-
|
|
5510
|
-
|
|
5521
|
+
Sa as CreateTemplate,
|
|
5522
|
+
Ta as Dashboard,
|
|
5523
|
+
Va as TrustSignalProvider
|
|
5511
5524
|
};
|