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