@resulticks/trustsignal-wa-hsm 0.12.0 → 0.13.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.
@@ -364,7 +364,7 @@ function lr({ onCreateTemplate: a, onEditTemplate: s }) {
364
364
  return m ? JSON.parse(m) : {
365
365
  apiKey: ""
366
366
  };
367
- }), { resulMeta: p } = fa(), [k, M] = R(!1);
367
+ }), { resulMeta: p } = fa(), [N, M] = R(!1);
368
368
  me(() => {
369
369
  if (!p) return;
370
370
  (async () => {
@@ -403,10 +403,10 @@ function lr({ onCreateTemplate: a, onEditTemplate: s }) {
403
403
  const [w, y] = R(() => {
404
404
  const m = localStorage.getItem("account"), j = m ? JSON.parse(m).apiKey : "";
405
405
  return fe(j);
406
- }), [d, u] = R(!1), [b, N] = R(null), [U, I] = R(null), [g, C] = R({ isOpen: !1 }), L = Te(null), [O, D] = R(""), [K, o] = R("all"), [T, S] = R("all"), [A, B] = R("all"), [z, F] = R(1), H = 20;
406
+ }), [d, u] = R(!1), [b, k] = R(null), [S, I] = R(null), [g, C] = R({ isOpen: !1 }), L = Te(null), [O, D] = R(""), [K, o] = R("all"), [T, A] = R("all"), [U, B] = R("all"), [z, F] = R(1), H = 20;
407
407
  me(() => {
408
408
  F(1);
409
- }, [O, K, T, A]);
409
+ }, [O, K, T, U]);
410
410
  const [J, ne] = R({ isOpen: !1 });
411
411
  me(() => {
412
412
  (async () => {
@@ -418,7 +418,7 @@ function lr({ onCreateTemplate: a, onEditTemplate: s }) {
418
418
  }), L.current = null), y(!1), u(!1);
419
419
  return;
420
420
  }
421
- u(!0), N(null);
421
+ u(!0), k(null);
422
422
  try {
423
423
  const $ = await Re(v, {
424
424
  limit: 1
@@ -441,7 +441,7 @@ function lr({ onCreateTemplate: a, onEditTemplate: s }) {
441
441
  t(Array.isArray(ae.data) ? ae.data : []);
442
442
  }), L.current = j, y(!1);
443
443
  } catch ($) {
444
- N($ instanceof Error ? $.message : "Failed to fetch templates"), L.current || c(() => {
444
+ k($ instanceof Error ? $.message : "Failed to fetch templates"), L.current || c(() => {
445
445
  t([]);
446
446
  }), L.current = null, y(!1);
447
447
  } finally {
@@ -466,7 +466,7 @@ function lr({ onCreateTemplate: a, onEditTemplate: s }) {
466
466
  try {
467
467
  const j = localStorage.getItem("account"), G = j ? JSON.parse(j) : { apiKey: "" };
468
468
  if (!G.apiKey) {
469
- N("Please enter your TrustSignal API key");
469
+ k("Please enter your TrustSignal API key");
470
470
  return;
471
471
  }
472
472
  I(String(m));
@@ -474,12 +474,12 @@ function lr({ onCreateTemplate: a, onEditTemplate: s }) {
474
474
  if (!ee.success) throw new Error(ee.message || "Delete failed");
475
475
  t((ae) => ae.filter((pe) => String(pe.id) !== String(m))), C({ isOpen: !1 });
476
476
  } catch (j) {
477
- N(j instanceof Error ? j.message : "Failed to delete template");
477
+ k(j instanceof Error ? j.message : "Failed to delete template");
478
478
  } finally {
479
479
  I(null);
480
480
  }
481
481
  }, q = n.filter((m) => {
482
- const j = O.trim(), G = j.toLowerCase(), $ = m.id != null ? String(m.id) : "", ee = m.name ? String(m.name).toLowerCase() : "", ae = j === "" || $.includes(j) || ee.includes(G), pe = K === "all" || String(m.status || "").toLowerCase() === K.toLowerCase(), Xe = T === "all" || String(m.category || "").toLowerCase() === T.toLowerCase(), Je = A === "all" || String(m.language || "").toLowerCase() === A.toLowerCase();
482
+ const j = O.trim(), G = j.toLowerCase(), $ = m.id != null ? String(m.id) : "", ee = m.name ? String(m.name).toLowerCase() : "", ae = j === "" || $.includes(j) || ee.includes(G), pe = K === "all" || String(m.status || "").toLowerCase() === K.toLowerCase(), Xe = T === "all" || String(m.category || "").toLowerCase() === T.toLowerCase(), Je = U === "all" || String(m.language || "").toLowerCase() === U.toLowerCase();
483
483
  return ae && pe && Xe && Je;
484
484
  }), ce = Array.from(new Set(n.map((m) => m.language).filter(Boolean))).sort(), ie = Array.from(new Set(n.map((m) => m.category).filter(Boolean))).sort(), Q = Array.from(new Set(n.map((m) => m.status).filter(Boolean))).sort(), _ = Math.max(1, Math.ceil(q.length / H)), Z = (z - 1) * H, X = Z + H, W = q.slice(Z, X);
485
485
  return /* @__PURE__ */ r("div", { className: "rsp-container rsp-mx-auto rsp-px-4 rsp-py-1 rsp-bg-[#f5f7fc] rsp-rounded-lg rsp-shadow-sm", children: [
@@ -547,7 +547,7 @@ function lr({ onCreateTemplate: a, onEditTemplate: s }) {
547
547
  "select",
548
548
  {
549
549
  value: T,
550
- onChange: (m) => S(m.target.value),
550
+ onChange: (m) => A(m.target.value),
551
551
  className: "rsp-pr-7 rsp-pl-2 rsp-py-1 rsp-border rsp-border-white rsp-border-opacity-30 rsp-rounded-md rsp-text-sm rsp-bg-blue-400 rsp-bg-opacity-30 rsp-appearance-none rsp-h-auto rsp-leading-normal focus:rsp-outline-none focus:rsp-border-opacity-60 focus:rsp-bg-opacity-50 rsp-cursor-pointer rsp-text-white hover:rsp-bg-opacity-40 hover:rsp-border-opacity-50 rsp-transition-all",
552
552
  onClick: (m) => m.stopPropagation(),
553
553
  children: [
@@ -565,7 +565,7 @@ function lr({ onCreateTemplate: a, onEditTemplate: s }) {
565
565
  /* @__PURE__ */ r(
566
566
  "select",
567
567
  {
568
- value: A,
568
+ value: U,
569
569
  onChange: (m) => B(m.target.value),
570
570
  className: "rsp-pr-7 rsp-pl-2 rsp-py-1 rsp-border rsp-border-white rsp-border-opacity-30 rsp-rounded-md rsp-text-sm rsp-bg-blue-400 rsp-bg-opacity-30 rsp-appearance-none rsp-h-auto rsp-leading-normal focus:rsp-outline-none focus:rsp-border-opacity-60 focus:rsp-bg-opacity-50 rsp-cursor-pointer rsp-text-white hover:rsp-bg-opacity-40 hover:rsp-border-opacity-50 rsp-transition-all",
571
571
  onClick: (m) => m.stopPropagation(),
@@ -650,9 +650,9 @@ function lr({ onCreateTemplate: a, onEditTemplate: s }) {
650
650
  "button",
651
651
  {
652
652
  onClick: () => C({ isOpen: !0, templateId: String(m.id), templateName: m.name }),
653
- disabled: U === String(m.id),
654
- className: `rsp-inline-flex rsp-items-center rsp-justify-center rsp-w-8 rsp-h-8 rsp-rounded rsp-text-white rsp-transition-colors ${U === String(m.id) ? "rsp-bg-red-400" : "rsp-bg-red-600 hover:rsp-bg-red-700"}`,
655
- title: U === String(m.id) ? "Deleting..." : "Delete",
653
+ disabled: S === String(m.id),
654
+ className: `rsp-inline-flex rsp-items-center rsp-justify-center rsp-w-8 rsp-h-8 rsp-rounded rsp-text-white rsp-transition-colors ${S === String(m.id) ? "rsp-bg-red-400" : "rsp-bg-red-600 hover:rsp-bg-red-700"}`,
655
+ title: S === String(m.id) ? "Deleting..." : "Delete",
656
656
  children: /* @__PURE__ */ e(ma, { className: "rsp-w-4 rsp-h-4" })
657
657
  }
658
658
  )
@@ -724,8 +724,8 @@ function lr({ onCreateTemplate: a, onEditTemplate: s }) {
724
724
  }
725
725
  }
726
726
  ),
727
- k && /* @__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..." }) }),
728
- !k && // If image failed to load, show an error placeholder (we can't detect exact failure here without refs, but onError sets mediaLoading false)
727
+ 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..." }) }),
728
+ !N && // If image failed to load, show an error placeholder (we can't detect exact failure here without refs, but onError sets mediaLoading false)
729
729
  /* @__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: [
730
730
  /* @__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" }) }),
731
731
  /* @__PURE__ */ e("p", { className: "rsp-text-gray-500 rsp-text-sm rsp-mb-2", children: "Load media on new tab" })
@@ -787,7 +787,7 @@ const ha = async (a, s) => {
787
787
  const x = s.language, v = s.headerType === "MEDIA" && s.mediaType === "DOCUMENT", V = s.type === "CAROUSEL";
788
788
  let p = "";
789
789
  v ? p = He(s, x) : V ? p = qe(s, x) : p = We(s, x), console.log("Raw JSON string being sent:", p);
790
- const k = {
790
+ const N = {
791
791
  method: "POST",
792
792
  headers: {
793
793
  "Content-Type": "application/json"
@@ -798,10 +798,10 @@ const ha = async (a, s) => {
798
798
  console.log(
799
799
  "Making request to:",
800
800
  `https://wpapi.trustsignal.io/api/v1/template?api_key=${a}`
801
- ), console.log("Request options:", k);
801
+ ), console.log("Request options:", N);
802
802
  const M = await fetch(
803
803
  `https://wpapi.trustsignal.io/api/v1/template?api_key=${a}`,
804
- k
804
+ N
805
805
  );
806
806
  console.log("Response status:", M.status), console.log(
807
807
  "Response headers:",
@@ -886,9 +886,9 @@ const He = (a, s) => {
886
886
  const V = de(h.value);
887
887
  if (V.length > 0 && ((v = a.sampleContent) != null && v.buttonVariables)) {
888
888
  const p = V.map(
889
- ({ number: k }) => {
889
+ ({ number: N }) => {
890
890
  var M, w;
891
- return ((w = (M = a.sampleContent) == null ? void 0 : M.buttonVariables) == null ? void 0 : w[k]) || `sample${k}`;
891
+ return ((w = (M = a.sampleContent) == null ? void 0 : M.buttonVariables) == null ? void 0 : w[N]) || `sample${N}`;
892
892
  }
893
893
  );
894
894
  x.example = p;
@@ -947,18 +947,18 @@ const He = (a, s) => {
947
947
  type: "BUTTONS",
948
948
  buttons: v.buttons.map((p) => {
949
949
  var M;
950
- const k = {
950
+ const N = {
951
951
  type: p.type === "CALL" ? "PHONE_NUMBER" : p.type,
952
952
  text: p.text
953
953
  };
954
- if (p.type === "URL" && p.value && (k.url = p.value, p.urlType === "dynamic" && p.value.includes("{{"))) {
954
+ if (p.type === "URL" && p.value && (N.url = p.value, p.urlType === "dynamic" && p.value.includes("{{"))) {
955
955
  const w = de(p.value);
956
956
  if (w.length > 0) {
957
957
  const y = ((M = v == null ? void 0 : v.sampleContent) == null ? void 0 : M.buttonVariables) || {}, d = w.map(({ number: u }) => y[u] || `sample${u}`);
958
- k.example = d;
958
+ N.example = d;
959
959
  }
960
960
  }
961
- return (p.type === "CALL" || p.type === "PHONE_NUMBER") && p.value && (k.phone_number = Se(p.value)), console.log("Carousel card button data:", k), k;
961
+ return (p.type === "CALL" || p.type === "PHONE_NUMBER") && p.value && (N.phone_number = Se(p.value)), console.log("Carousel card button data:", N), N;
962
962
  })
963
963
  }] : []
964
964
  ]
@@ -1028,13 +1028,13 @@ const He = (a, s) => {
1028
1028
  if (x.type === "URL" && x.value && (v.url = x.value, x.urlType === "dynamic" && x.value.includes("{{"))) {
1029
1029
  const p = de(x.value);
1030
1030
  if (p.length > 0 && ((V = a.sampleContent) != null && V.buttonVariables)) {
1031
- const k = p.map(
1031
+ const N = p.map(
1032
1032
  ({ number: M }) => {
1033
1033
  var w, y;
1034
1034
  return ((y = (w = a.sampleContent) == null ? void 0 : w.buttonVariables) == null ? void 0 : y[M]) || `sample${M}`;
1035
1035
  }
1036
1036
  );
1037
- v.example = k;
1037
+ v.example = N;
1038
1038
  }
1039
1039
  }
1040
1040
  return (x.type === "CALL" || x.type === "PHONE_NUMBER") && x.value && (v.phone_number = Se(x.value)), v;
@@ -1312,34 +1312,34 @@ function Oa(a) {
1312
1312
  try {
1313
1313
  const p = JSON.parse(a.jsonstruct);
1314
1314
  if (p != null && p.header) {
1315
- const k = p.header.format;
1316
- k && k !== "TEXT" ? (n = "MEDIA", i = k, c = p.header.url || ((v = a.medialist) == null ? void 0 : v.header)) : k === "TEXT" && (n = "TEXT", t = p.header.text || "");
1315
+ const N = p.header.format;
1316
+ N && N !== "TEXT" ? (n = "MEDIA", i = N, c = p.header.url || ((v = a.medialist) == null ? void 0 : v.header)) : N === "TEXT" && (n = "TEXT", t = p.header.text || "");
1317
1317
  }
1318
1318
  if (p != null && p.body && (l = p.body.text || ""), (V = p == null ? void 0 : p.buttons) != null && V.buttons && Array.isArray(p.buttons.buttons))
1319
- for (const k of p.buttons.buttons) {
1320
- if (!k || !k.type || !k.text) continue;
1319
+ for (const N of p.buttons.buttons) {
1320
+ if (!N || !N.type || !N.text) continue;
1321
1321
  const M = {
1322
1322
  id: we(),
1323
- type: k.type === "PHONE_NUMBER" ? "PHONE_NUMBER" : k.type,
1324
- text: k.text
1323
+ type: N.type === "PHONE_NUMBER" ? "PHONE_NUMBER" : N.type,
1324
+ text: N.text
1325
1325
  };
1326
- k.type === "URL" && (M.value = k.url, typeof k.url == "string" && k.url.includes("{{") && Array.isArray(k.example) ? (Oe(k.url).forEach((y, d) => {
1327
- s.buttonVariables[y] = k.example[d] ?? "";
1328
- }), M.urlType = "dynamic") : M.urlType = "static"), (k.type === "CALL" || k.type === "PHONE_NUMBER") && (M.value = k.phone_number || ""), h.push(M);
1326
+ N.type === "URL" && (M.value = N.url, typeof N.url == "string" && N.url.includes("{{") && Array.isArray(N.example) ? (Oe(N.url).forEach((y, d) => {
1327
+ s.buttonVariables[y] = N.example[d] ?? "";
1328
+ }), M.urlType = "dynamic") : M.urlType = "static"), (N.type === "CALL" || N.type === "PHONE_NUMBER") && (M.value = N.phone_number || ""), h.push(M);
1329
1329
  }
1330
1330
  if (p != null && p.carousel) {
1331
- const k = Object.keys(p.carousel).filter((u) => /^card\d+$/.test(u));
1332
- k.sort((u, b) => {
1333
- const N = parseInt(u.replace("card", ""), 10), U = parseInt(b.replace("card", ""), 10);
1334
- return N - U;
1331
+ const N = Object.keys(p.carousel).filter((u) => /^card\d+$/.test(u));
1332
+ N.sort((u, b) => {
1333
+ const k = parseInt(u.replace("card", ""), 10), S = parseInt(b.replace("card", ""), 10);
1334
+ return k - S;
1335
1335
  });
1336
- const M = k.map((u) => {
1337
- const b = p.carousel[u] || {}, N = b.header || {}, U = b.body || {}, I = b.buttons && Array.isArray(b.buttons.buttons) ? b.buttons.buttons : [], g = N.format, C = g === "IMAGE" || g === "VIDEO" || g === "DOCUMENT" ? g : void 0, O = `card${u.replace("card", "")}header`, D = N.url || (a.medialist && typeof a.medialist == "object" && O in a.medialist ? a.medialist[O] : void 0), K = U.text || "", o = [];
1336
+ const M = N.map((u) => {
1337
+ const b = p.carousel[u] || {}, k = b.header || {}, S = b.body || {}, I = b.buttons && Array.isArray(b.buttons.buttons) ? b.buttons.buttons : [], g = k.format, C = g === "IMAGE" || g === "VIDEO" || g === "DOCUMENT" ? g : void 0, O = `card${u.replace("card", "")}header`, D = k.url || (a.medialist && typeof a.medialist == "object" && O in a.medialist ? a.medialist[O] : void 0), K = S.text || "", o = [];
1338
1338
  for (const T of I) {
1339
1339
  if (!T || !T.type || !T.text) continue;
1340
- const S = { id: we(), type: T.type === "PHONE_NUMBER" ? "PHONE_NUMBER" : T.type, text: T.text };
1341
- T.type === "URL" && (S.value = T.url, typeof T.url == "string" && T.url.includes("{{") && Array.isArray(T.example) ? (Oe(T.url).forEach((B, z) => {
1342
- }), S.urlType = "dynamic") : S.urlType = "static"), (T.type === "CALL" || T.type === "PHONE_NUMBER") && (S.value = T.phone_number || ""), o.push(S);
1340
+ const A = { id: we(), type: T.type === "PHONE_NUMBER" ? "PHONE_NUMBER" : T.type, text: T.text };
1341
+ T.type === "URL" && (A.value = T.url, typeof T.url == "string" && T.url.includes("{{") && Array.isArray(T.example) ? (Oe(T.url).forEach((B, z) => {
1342
+ }), A.urlType = "dynamic") : A.urlType = "static"), (T.type === "CALL" || T.type === "PHONE_NUMBER") && (A.value = T.phone_number || ""), o.push(A);
1343
1343
  }
1344
1344
  return {
1345
1345
  id: we(),
@@ -1480,7 +1480,7 @@ const Pa = [
1480
1480
  { value: "DOCUMENT", label: "Document" }
1481
1481
  ], _a = 5 * 1024 * 1024, Fa = 16 * 1024 * 1024, $a = 100 * 1024 * 1024, ve = ["jpg", "jpeg", "png"], ke = ["mp4", "3gpp"], Ne = ["pdf", "docx", "xlsx", "pptx", "txt"];
1482
1482
  function Ha({ template: a, setTemplate: s, onFileUpload: n }) {
1483
- var U, I;
1483
+ var S, I;
1484
1484
  const [t, i] = re.useState(null), [c, l] = re.useState(!1), [f, h] = re.useState(null), [x, v] = re.useState(null), V = () => {
1485
1485
  const C = (a.headerText || "").match(/{{\d+}}/g);
1486
1486
  if (!C) return 0;
@@ -1500,7 +1500,7 @@ function Ha({ template: a, setTemplate: s, onFileUpload: n }) {
1500
1500
  }
1501
1501
  }, 0);
1502
1502
  }
1503
- }, k = (g) => {
1503
+ }, N = (g) => {
1504
1504
  s((C) => ({
1505
1505
  ...C,
1506
1506
  headerType: g,
@@ -1574,7 +1574,7 @@ function Ha({ template: a, setTemplate: s, onFileUpload: n }) {
1574
1574
  const L = y(C, a.mediaType);
1575
1575
  v(L);
1576
1576
  }
1577
- }, N = () => {
1577
+ }, k = () => {
1578
1578
  switch (a.mediaType) {
1579
1579
  case "IMAGE":
1580
1580
  return ve.map((g) => `.${g}`).join(",");
@@ -1594,7 +1594,7 @@ function Ha({ template: a, setTemplate: s, onFileUpload: n }) {
1594
1594
  "select",
1595
1595
  {
1596
1596
  value: a.headerType,
1597
- onChange: (g) => k(g.target.value),
1597
+ onChange: (g) => N(g.target.value),
1598
1598
  className: "rsp-w-full rsp-px-0 rsp-border-0 rsp-border-b rsp-border-gray-300 rsp-text-sm rsp-bg-transparent rsp-appearance-none rsp-h-10 rsp-leading-10 focus:rsp-outline-none focus:rsp-border-blue-500",
1599
1599
  children: Da.map((g) => /* @__PURE__ */ e("option", { value: g.value, children: g.label }, g.value))
1600
1600
  }
@@ -1649,12 +1649,12 @@ function Ha({ template: a, setTemplate: s, onFileUpload: n }) {
1649
1649
  type: "text",
1650
1650
  value: ((O = (L = a.sampleContent) == null ? void 0 : L.headerVariables) == null ? void 0 : O[C]) || "",
1651
1651
  onChange: (D) => {
1652
- var o, T, S;
1652
+ var o, T, A;
1653
1653
  const K = {
1654
1654
  ...a.sampleContent,
1655
1655
  headerVariables: { ...(o = a.sampleContent) == null ? void 0 : o.headerVariables, [C]: D.target.value },
1656
1656
  bodyVariables: ((T = a.sampleContent) == null ? void 0 : T.bodyVariables) || {},
1657
- buttonVariables: ((S = a.sampleContent) == null ? void 0 : S.buttonVariables) || {}
1657
+ buttonVariables: ((A = a.sampleContent) == null ? void 0 : A.buttonVariables) || {}
1658
1658
  };
1659
1659
  s({ ...a, sampleContent: K });
1660
1660
  },
@@ -1667,7 +1667,7 @@ function Ha({ template: a, setTemplate: s, onFileUpload: n }) {
1667
1667
  {
1668
1668
  type: "button",
1669
1669
  onClick: () => {
1670
- var T, S, A;
1670
+ var T, A, U;
1671
1671
  const D = new RegExp(`\\{\\{${C}\\}\\}`, "g"), K = (a.headerText || "").replace(D, ""), o = Object.fromEntries(Object.entries(((T = a.sampleContent) == null ? void 0 : T.headerVariables) || {}).filter(([B]) => B !== C));
1672
1672
  s({
1673
1673
  ...a,
@@ -1675,8 +1675,8 @@ function Ha({ template: a, setTemplate: s, onFileUpload: n }) {
1675
1675
  sampleContent: {
1676
1676
  ...a.sampleContent,
1677
1677
  headerVariables: o,
1678
- bodyVariables: ((S = a.sampleContent) == null ? void 0 : S.bodyVariables) || {},
1679
- buttonVariables: ((A = a.sampleContent) == null ? void 0 : A.buttonVariables) || {}
1678
+ bodyVariables: ((A = a.sampleContent) == null ? void 0 : A.bodyVariables) || {},
1679
+ buttonVariables: ((U = a.sampleContent) == null ? void 0 : U.buttonVariables) || {}
1680
1680
  }
1681
1681
  });
1682
1682
  },
@@ -1739,7 +1739,7 @@ function Ha({ template: a, setTemplate: s, onFileUpload: n }) {
1739
1739
  ] }),
1740
1740
  /* @__PURE__ */ e("button", { onClick: d, className: "rsp-p-1 rsp-text-gray-400 hover:rsp-text-red-500 rsp-transition-colors flex-shrink-0", children: /* @__PURE__ */ e(te, { className: "rsp-w-4 rsp-h-4" }) })
1741
1741
  ] }) : /* @__PURE__ */ r("div", { children: [
1742
- /* @__PURE__ */ e("input", { type: "file", accept: N(), onChange: u, className: "rsp-hidden", id: "media-upload", disabled: c }),
1742
+ /* @__PURE__ */ e("input", { type: "file", accept: k(), onChange: u, className: "rsp-hidden", id: "media-upload", disabled: c }),
1743
1743
  /* @__PURE__ */ r(
1744
1744
  "label",
1745
1745
  {
@@ -1747,7 +1747,7 @@ function Ha({ template: a, setTemplate: s, onFileUpload: n }) {
1747
1747
  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 ${c ? "rsp-opacity-50 rsp-cursor-not-allowed" : ""}`,
1748
1748
  children: [
1749
1749
  /* @__PURE__ */ e(pa, { className: "rsp-w-6 rsp-h-6 rsp-text-gray-400 rsp-mb-2" }),
1750
- /* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-text-gray-600", children: c ? "Uploading..." : `Upload ${((U = a.mediaType) == null ? void 0 : U.toLowerCase()) || "file"}` }),
1750
+ /* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-text-gray-600", children: c ? "Uploading..." : `Upload ${((S = a.mediaType) == null ? void 0 : S.toLowerCase()) || "file"}` }),
1751
1751
  /* @__PURE__ */ r("span", { className: "rsp-text-xs rsp-text-gray-400 rsp-mt-1", children: [
1752
1752
  a.mediaType === "IMAGE" && "JPG, PNG up to 5MB",
1753
1753
  a.mediaType === "VIDEO" && "MP4, 3GPP up to 16MB",
@@ -3585,7 +3585,7 @@ const Pe = [
3585
3585
  onClose: n
3586
3586
  }) => {
3587
3587
  const [t, i] = R({ start: 0, end: 80 }), c = 8, l = 40, f = 400, h = je((p) => {
3588
- const k = p.currentTarget.scrollTop, M = Math.floor(k / l), w = Math.min(
3588
+ const N = p.currentTarget.scrollTop, M = Math.floor(N / l), w = Math.min(
3589
3589
  M + Math.ceil(f / l) + 2,
3590
3590
  Math.ceil(a.length / c)
3591
3591
  );
@@ -3594,9 +3594,9 @@ const Pe = [
3594
3594
  end: w * c
3595
3595
  });
3596
3596
  }, [a.length, l, f, c]), x = je((p) => {
3597
- const k = p.match(/&#x([0-9A-Fa-f]+);/g);
3598
- if (!k) return "";
3599
- const M = k.map((w) => {
3597
+ const N = p.match(/&#x([0-9A-Fa-f]+);/g);
3598
+ if (!N) return "";
3599
+ const M = N.map((w) => {
3600
3600
  const y = w.replace(/&#x|;/g, "");
3601
3601
  return parseInt(y, 16);
3602
3602
  });
@@ -3615,8 +3615,8 @@ const Pe = [
3615
3615
  top: Math.floor(t.start / c) * l,
3616
3616
  transform: "translateY(0px)"
3617
3617
  },
3618
- children: V.map((p, k) => {
3619
- const M = t.start + k;
3618
+ children: V.map((p, N) => {
3619
+ const M = t.start + N;
3620
3620
  return /* @__PURE__ */ e(
3621
3621
  "button",
3622
3622
  {
@@ -3700,14 +3700,14 @@ function Wa({ template: a, setTemplate: s }) {
3700
3700
  const d = (a.body || "").match(/{{\d+}}/g);
3701
3701
  if (!d) return 0;
3702
3702
  const u = d.map((b) => {
3703
- const N = b.match(/{{(\d+)}}/);
3704
- return N ? parseInt(N[1], 10) : 0;
3703
+ const k = b.match(/{{(\d+)}}/);
3704
+ return k ? parseInt(k[1], 10) : 0;
3705
3705
  });
3706
3706
  return u.length > 0 ? Math.max(...u) : 0;
3707
- }, k = () => {
3707
+ }, N = () => {
3708
3708
  const u = `{{${p() + 1}}}`;
3709
3709
  if (l && a.body.length + u.length <= 1024) {
3710
- const b = l.selectionStart || a.body.length, N = a.body.substring(0, b), U = a.body.substring(b), I = N + u + U;
3710
+ const b = l.selectionStart || a.body.length, k = a.body.substring(0, b), S = a.body.substring(b), I = k + u + S;
3711
3711
  s({
3712
3712
  ...a,
3713
3713
  body: I
@@ -3727,7 +3727,7 @@ function Wa({ template: a, setTemplate: s }) {
3727
3727
  if (!l) return;
3728
3728
  const d = l.selectionStart || a.body.length, u = 1024, b = a.body;
3729
3729
  if (b.length + y.length <= u) {
3730
- const N = b.substring(0, d), U = b.substring(d), I = N + y + U;
3730
+ const k = b.substring(0, d), S = b.substring(d), I = k + y + S;
3731
3731
  s({
3732
3732
  ...a,
3733
3733
  body: I
@@ -3742,7 +3742,7 @@ function Wa({ template: a, setTemplate: s }) {
3742
3742
  if (!h) return;
3743
3743
  const d = h.selectionStart || a.footer.length, u = 60, b = a.footer;
3744
3744
  if (b.length + y.length <= u) {
3745
- const N = b.substring(0, d), U = b.substring(d), I = N + y + U;
3745
+ const k = b.substring(0, d), S = b.substring(d), I = k + y + S;
3746
3746
  s({
3747
3747
  ...a,
3748
3748
  footer: I
@@ -3778,7 +3778,7 @@ function Wa({ template: a, setTemplate: s }) {
3778
3778
  /* @__PURE__ */ e(
3779
3779
  "button",
3780
3780
  {
3781
- onClick: k,
3781
+ onClick: N,
3782
3782
  className: "rsp-p-1 rsp-text-gray-500 hover:rsp-text-gray-700 hover:rsp-bg-gray-100 rsp-rounded",
3783
3783
  title: "Add Variable",
3784
3784
  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" }) })
@@ -3841,7 +3841,7 @@ function Wa({ template: a, setTemplate: s }) {
3841
3841
  return d.length === 0 ? null : /* @__PURE__ */ r("div", { className: "rsp-mt-3", children: [
3842
3842
  /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-font-medium rsp-text-gray-600 rsp-mb-2", children: "Sample Values" }),
3843
3843
  /* @__PURE__ */ e("div", { className: "rsp-grid rsp-grid-cols-3 rsp-gap-2", children: d.map((u) => {
3844
- var b, N;
3844
+ var b, k;
3845
3845
  return /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2", children: [
3846
3846
  /* @__PURE__ */ r("label", { className: "rsp-text-xs rsp-text-gray-500 rsp-whitespace-nowrap", children: [
3847
3847
  "{{",
@@ -3853,14 +3853,14 @@ function Wa({ template: a, setTemplate: s }) {
3853
3853
  "input",
3854
3854
  {
3855
3855
  type: "text",
3856
- value: ((N = (b = a.sampleContent) == null ? void 0 : b.bodyVariables) == null ? void 0 : N[u]) || "",
3857
- onChange: (U) => {
3856
+ value: ((k = (b = a.sampleContent) == null ? void 0 : b.bodyVariables) == null ? void 0 : k[u]) || "",
3857
+ onChange: (S) => {
3858
3858
  var g, C, L;
3859
3859
  const I = {
3860
3860
  ...a.sampleContent,
3861
3861
  bodyVariables: {
3862
3862
  ...(g = a.sampleContent) == null ? void 0 : g.bodyVariables,
3863
- [u]: U.target.value
3863
+ [u]: S.target.value
3864
3864
  },
3865
3865
  headerVariables: ((C = a.sampleContent) == null ? void 0 : C.headerVariables) || {},
3866
3866
  buttonVariables: ((L = a.sampleContent) == null ? void 0 : L.buttonVariables) || {}
@@ -3880,7 +3880,7 @@ function Wa({ template: a, setTemplate: s }) {
3880
3880
  type: "button",
3881
3881
  onClick: () => {
3882
3882
  var C, L, O;
3883
- const U = new RegExp(`\\{\\{${u}\\}\\}`, "g"), I = (a.body || "").replace(U, ""), g = Object.fromEntries(Object.entries(((C = a.sampleContent) == null ? void 0 : C.bodyVariables) || {}).filter(([D]) => D !== u));
3883
+ const S = new RegExp(`\\{\\{${u}\\}\\}`, "g"), I = (a.body || "").replace(S, ""), g = Object.fromEntries(Object.entries(((C = a.sampleContent) == null ? void 0 : C.bodyVariables) || {}).filter(([D]) => D !== u));
3884
3884
  s({
3885
3885
  ...a,
3886
3886
  body: I,
@@ -3965,10 +3965,10 @@ function Ga({ template: a, setTemplate: s }) {
3965
3965
  ...a,
3966
3966
  buttons: a.buttons.filter((u) => u.id !== d)
3967
3967
  });
3968
- }, k = (d, u, b) => {
3969
- const N = a.buttons.find((g) => g.id === d), U = u === "text" ? 25 : u === "value" && (N == null ? void 0 : N.type) === "URL" ? 2e3 : 20;
3970
- let I = b.slice(0, U);
3971
- u === "value" && (N == null ? void 0 : N.type) === "CALL" && I && !I.startsWith("+") && (I = "+" + I), s({
3968
+ }, N = (d, u, b) => {
3969
+ const k = a.buttons.find((g) => g.id === d), S = u === "text" ? 25 : u === "value" && (k == null ? void 0 : k.type) === "URL" ? 2e3 : 20;
3970
+ let I = b.slice(0, S);
3971
+ u === "value" && (k == null ? void 0 : k.type) === "CALL" && I && !I.startsWith("+") && (I = "+" + I), s({
3972
3972
  ...a,
3973
3973
  buttons: a.buttons.map(
3974
3974
  (g) => g.id === d ? { ...g, [u]: I } : g
@@ -3976,14 +3976,14 @@ function Ga({ template: a, setTemplate: s }) {
3976
3976
  });
3977
3977
  }, M = () => {
3978
3978
  const u = [
3979
- ...a.buttons.filter((N) => N.type === "URL" && N.urlType === "dynamic").map((N) => N.value || ""),
3979
+ ...a.buttons.filter((k) => k.type === "URL" && k.urlType === "dynamic").map((k) => k.value || ""),
3980
3980
  l.value
3981
3981
  // Include current form input
3982
3982
  ].join(" ").match(/{{\d+}}/g);
3983
3983
  if (!u) return 0;
3984
- const b = u.map((N) => {
3985
- const U = N.match(/{{(\d+)}}/);
3986
- return U ? parseInt(U[1], 10) : 0;
3984
+ const b = u.map((k) => {
3985
+ const S = k.match(/{{(\d+)}}/);
3986
+ return S ? parseInt(S[1], 10) : 0;
3987
3987
  });
3988
3988
  return b.length > 0 ? Math.max(...b) : 0;
3989
3989
  }, w = [
@@ -4153,7 +4153,7 @@ function Ga({ template: a, setTemplate: s }) {
4153
4153
  "Use placeholders like: ",
4154
4154
  /* @__PURE__ */ e("code", { className: "rsp-bg-blue-100 rsp-px-1 rsp-rounded", children: "https://example.com/order/{{1}}" })
4155
4155
  ] }),
4156
- /* @__PURE__ */ e("li", { children: "Maximum 3 placeholders per URL ({{1}}, {{2}}, {{3}})" }),
4156
+ /* @__PURE__ */ e("li", { children: "Maximum 1 placeholder per URL ({{1}})" }),
4157
4157
  /* @__PURE__ */ e("li", { children: "Only HTTPS URLs are allowed" }),
4158
4158
  /* @__PURE__ */ e("li", { children: "WhatsApp verifies only the domain" })
4159
4159
  ] })
@@ -4170,7 +4170,7 @@ function Ga({ template: a, setTemplate: s }) {
4170
4170
  f({ ...l, value: d.target.value.slice(0, u) });
4171
4171
  },
4172
4172
  className: "rsp-w-full rsp-px-3 rsp-py-4 rsp-border-2 rsp-border-gray-200 rsp-rounded-lg rsp-bg-white rsp-text-sm rsp-text-gray-900 placeholder:rsp-text-gray-400 focus:rsp-outline-none focus:rsp-ring-2 focus:rsp-ring-blue-500 focus:rsp-border-blue-500 rsp-shadow-sm rsp-transition-all",
4173
- placeholder: n === "URL" ? l.urlType === "dynamic" ? "https://example.com/order/{{1}}?user={{2}}" : "https://example.com" : n === "CALL" ? "+1234567890" : "Flow ID",
4173
+ placeholder: n === "URL" ? l.urlType === "dynamic" ? "https://example.com/order/{{1}}" : "https://example.com" : n === "CALL" ? "+1234567890" : "Flow ID",
4174
4174
  maxLength: n === "URL" ? 2e3 : 20
4175
4175
  }
4176
4176
  ),
@@ -4186,11 +4186,11 @@ function Ga({ template: a, setTemplate: s }) {
4186
4186
  {
4187
4187
  type: "button",
4188
4188
  onClick: () => {
4189
- if ((l.value.match(/\{\{(\d+)\}\}/g) || []).length >= 3) return;
4190
- const b = M() + 1, N = l.value + `{{${b}}}`;
4191
- f({ ...l, value: N }), c(!0);
4189
+ if ((l.value.match(/\{\{(\d+)\}\}/g) || []).length >= 1) return;
4190
+ const b = M() + 1, k = l.value + `{{${b}}}`;
4191
+ f({ ...l, value: k }), c(!0);
4192
4192
  },
4193
- disabled: (l.value.match(/\{\{(\d+)\}\}/g) || []).length >= 3,
4193
+ disabled: (l.value.match(/\{\{(\d+)\}\}/g) || []).length >= 1,
4194
4194
  className: "rsp-px-4 rsp-py-2 rsp-text-xs rsp-font-semibold rsp-bg-blue-100 hover:rsp-bg-blue-200 rsp-rounded-lg rsp-text-blue-700 disabled:rsp-bg-gray-200 disabled:rsp-text-gray-500 disabled:rsp-cursor-not-allowed rsp-transition-all rsp-shadow-sm hover:rsp-shadow-md rsp-flex rsp-items-center rsp-gap-1.5",
4195
4195
  children: [
4196
4196
  /* @__PURE__ */ e("svg", { className: "rsp-w-3.5 rsp-h-3.5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 4v16m8-8H4" }) }),
@@ -4198,7 +4198,7 @@ function Ga({ template: a, setTemplate: s }) {
4198
4198
  ]
4199
4199
  }
4200
4200
  ) }),
4201
- (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." }),
4201
+ (l.value.match(/\{\{(\d+)\}\}/g) || []).length >= 1 && /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-500 rsp-mt-1", children: "Maximum 1 variable allowed." }),
4202
4202
  i && /* @__PURE__ */ r("div", { className: "rsp-mt-4 rsp-p-5 rsp-bg-gradient-to-br rsp-from-blue-50 rsp-to-indigo-50 rsp-rounded-xl rsp-border-2 rsp-border-blue-200 rsp-shadow-sm", children: [
4203
4203
  /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-justify-between rsp-mb-4", children: [
4204
4204
  /* @__PURE__ */ r("h4", { className: "rsp-text-sm rsp-font-semibold rsp-text-blue-900 rsp-flex rsp-items-center rsp-gap-2", children: [
@@ -4218,7 +4218,7 @@ function Ga({ template: a, setTemplate: s }) {
4218
4218
  /* @__PURE__ */ e("div", { className: "rsp-space-y-3", children: (() => {
4219
4219
  const d = l.value.match(/\{\{(\d+)\}\}/g) || [];
4220
4220
  return [...new Set(d.map((b) => b.replace(/[{}]/g, "")))].map((b) => {
4221
- var N, U;
4221
+ var k, S;
4222
4222
  return /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-3", children: [
4223
4223
  /* @__PURE__ */ r("label", { className: "rsp-text-sm rsp-font-semibold rsp-text-blue-800 rsp-whitespace-nowrap rsp-bg-blue-100 rsp-px-3 rsp-py-2 rsp-rounded-lg rsp-min-w-[100px]", children: [
4224
4224
  "{{",
@@ -4229,7 +4229,7 @@ function Ga({ template: a, setTemplate: s }) {
4229
4229
  "input",
4230
4230
  {
4231
4231
  type: "text",
4232
- value: ((U = (N = a.sampleContent) == null ? void 0 : N.buttonVariables) == null ? void 0 : U[b]) || "",
4232
+ value: ((S = (k = a.sampleContent) == null ? void 0 : k.buttonVariables) == null ? void 0 : S[b]) || "",
4233
4233
  onChange: (I) => {
4234
4234
  var C, L, O;
4235
4235
  const g = {
@@ -4288,8 +4288,8 @@ function Ga({ template: a, setTemplate: s }) {
4288
4288
  /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-700 rsp-font-mono rsp-break-all rsp-bg-gray-50 rsp-p-2 rsp-rounded rsp-border rsp-border-gray-200", children: l.value.replace(
4289
4289
  /\{\{(\d+)\}\}/g,
4290
4290
  (d, u) => {
4291
- var b, N;
4292
- return ((N = (b = a.sampleContent) == null ? void 0 : b.buttonVariables) == null ? void 0 : N[u]) || `[${d}]`;
4291
+ var b, k;
4292
+ return ((k = (b = a.sampleContent) == null ? void 0 : b.buttonVariables) == null ? void 0 : k[u]) || `[${d}]`;
4293
4293
  }
4294
4294
  ) })
4295
4295
  ] })
@@ -4327,7 +4327,7 @@ function Ga({ template: a, setTemplate: s }) {
4327
4327
  ] })
4328
4328
  ] }),
4329
4329
  /* @__PURE__ */ e("div", { className: "rsp-space-y-3", children: a.buttons.map((d) => {
4330
- const u = w.find((N) => N.type === d.type), b = (u == null ? void 0 : u.icon) || ye;
4330
+ const u = w.find((k) => k.type === d.type), b = (u == null ? void 0 : u.icon) || ye;
4331
4331
  return /* @__PURE__ */ e("div", { className: "rsp-bg-white rsp-border-2 rsp-border-gray-200 rsp-rounded-xl rsp-p-5 rsp-shadow-sm hover:rsp-shadow-md hover:rsp-border-gray-300 rsp-transition-all", children: /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-start rsp-gap-4", children: [
4332
4332
  /* @__PURE__ */ e("div", { className: "rsp-p-3 rsp-bg-gradient-to-br rsp-from-blue-50 rsp-to-blue-100 rsp-rounded-xl rsp-shadow-sm", children: /* @__PURE__ */ e(b, { className: "rsp-w-5 rsp-h-5 rsp-text-blue-600" }) }),
4333
4333
  /* @__PURE__ */ r("div", { className: "rsp-flex-1 rsp-space-y-4", children: [
@@ -4352,7 +4352,7 @@ function Ga({ template: a, setTemplate: s }) {
4352
4352
  {
4353
4353
  type: "text",
4354
4354
  value: d.text,
4355
- onChange: (N) => k(d.id, "text", N.target.value),
4355
+ onChange: (k) => N(d.id, "text", k.target.value),
4356
4356
  maxLength: 25,
4357
4357
  className: "rsp-w-full rsp-px-3 rsp-py-4 rsp-border-2 rsp-border-gray-200 rsp-rounded-lg rsp-text-sm rsp-text-gray-900 placeholder:rsp-text-gray-400 focus:rsp-outline-none focus:rsp-ring-2 focus:rsp-ring-blue-500 focus:rsp-border-blue-500 rsp-shadow-sm rsp-transition-all rsp-bg-white"
4358
4358
  }
@@ -4371,7 +4371,7 @@ function Ga({ template: a, setTemplate: s }) {
4371
4371
  {
4372
4372
  type: d.type === "CALL" ? "tel" : d.type === "URL" ? "url" : "text",
4373
4373
  value: d.value || "",
4374
- onChange: (N) => k(d.id, "value", N.target.value),
4374
+ onChange: (k) => N(d.id, "value", k.target.value),
4375
4375
  maxLength: d.type === "URL" ? 2e3 : 20,
4376
4376
  className: "rsp-w-full rsp-px-3 rsp-py-2 rsp-border-2 rsp-border-gray-200 rsp-rounded-lg rsp-text-sm rsp-text-gray-900 placeholder:rsp-text-gray-400 focus:rsp-outline-none focus:rsp-ring-2 focus:rsp-ring-blue-500 focus:rsp-border-blue-500 rsp-shadow-sm rsp-transition-all rsp-bg-white"
4377
4377
  }
@@ -4461,7 +4461,7 @@ const Ka = async (a) => {
4461
4461
  };
4462
4462
  function Ya({ template: a, setTemplate: s, onFileUpload: n }) {
4463
4463
  var C, L, O, D, K;
4464
- const [t, i] = re.useState({}), [, c] = re.useState({}), [l, f] = re.useState({ open: !1, message: "" }), [h, x] = re.useState(!1), [v, V] = re.useState(null), p = re.useRef({}), k = () => {
4464
+ const [t, i] = re.useState({}), [, c] = re.useState({}), [l, f] = re.useState({ open: !1, message: "" }), [h, x] = re.useState(!1), [v, V] = re.useState(null), p = re.useRef({}), N = () => {
4465
4465
  var T;
4466
4466
  const o = {
4467
4467
  id: Math.random().toString(36).substr(2, 9),
@@ -4470,12 +4470,12 @@ function Ya({ template: a, setTemplate: s, onFileUpload: n }) {
4470
4470
  body: "",
4471
4471
  buttons: []
4472
4472
  };
4473
- s((S) => {
4474
- var A, B;
4473
+ s((A) => {
4474
+ var U, B;
4475
4475
  return {
4476
- ...S,
4476
+ ...A,
4477
4477
  carousel: {
4478
- type: ((A = a.carousel) == null ? void 0 : A.type) || "IMAGE",
4478
+ type: ((U = a.carousel) == null ? void 0 : U.type) || "IMAGE",
4479
4479
  cards: [...((B = a.carousel) == null ? void 0 : B.cards) || [], o]
4480
4480
  }
4481
4481
  };
@@ -4485,22 +4485,22 @@ function Ya({ template: a, setTemplate: s, onFileUpload: n }) {
4485
4485
  ...T,
4486
4486
  carousel: {
4487
4487
  ...T.carousel,
4488
- cards: T.carousel.cards.filter((S) => S.id !== o)
4488
+ cards: T.carousel.cards.filter((A) => A.id !== o)
4489
4489
  }
4490
4490
  }));
4491
- }, w = (o, T, S) => {
4492
- s((A) => ({
4493
- ...A,
4491
+ }, w = (o, T, A) => {
4492
+ s((U) => ({
4493
+ ...U,
4494
4494
  carousel: {
4495
- ...A.carousel,
4496
- cards: A.carousel.cards.map(
4497
- (B) => B.id === o ? { ...B, [T]: S } : B
4495
+ ...U.carousel,
4496
+ cards: U.carousel.cards.map(
4497
+ (B) => B.id === o ? { ...B, [T]: A } : B
4498
4498
  )
4499
4499
  }
4500
4500
  }));
4501
4501
  }, y = (o) => {
4502
4502
  s((T) => {
4503
- const A = ((T.carousel || { type: o, cards: [] }).cards || []).map((B) => ({
4503
+ const U = ((T.carousel || { type: o, cards: [] }).cards || []).map((B) => ({
4504
4504
  ...B,
4505
4505
  mediaType: o,
4506
4506
  mediaUrl: ""
@@ -4509,26 +4509,26 @@ function Ya({ template: a, setTemplate: s, onFileUpload: n }) {
4509
4509
  ...T,
4510
4510
  carousel: {
4511
4511
  type: o,
4512
- cards: A
4512
+ cards: U
4513
4513
  }
4514
4514
  };
4515
4515
  });
4516
4516
  }, d = (o, T) => {
4517
4517
  var J;
4518
- const S = (J = a.carousel) == null ? void 0 : J.cards.find((ne) => ne.id === o);
4519
- if (!S) return;
4520
- const z = `{{${b(o) + 1}}}`, H = S[T] + z;
4518
+ const A = (J = a.carousel) == null ? void 0 : J.cards.find((ne) => ne.id === o);
4519
+ if (!A) return;
4520
+ const z = `{{${b(o) + 1}}}`, H = A[T] + z;
4521
4521
  w(o, T, H);
4522
4522
  }, u = (o) => {
4523
4523
  var H;
4524
4524
  if (!v) return;
4525
- const T = p.current[v], S = (H = a.carousel) == null ? void 0 : H.cards.find((J) => J.id === v);
4526
- if (!S) return;
4527
- const A = T && typeof T.selectionStart == "number" ? T.selectionStart : S.body.length, B = S.body.substring(0, A), z = S.body.substring(A), F = B + o + z;
4525
+ const T = p.current[v], A = (H = a.carousel) == null ? void 0 : H.cards.find((J) => J.id === v);
4526
+ if (!A) return;
4527
+ const U = T && typeof T.selectionStart == "number" ? T.selectionStart : A.body.length, B = A.body.substring(0, U), z = A.body.substring(U), F = B + o + z;
4528
4528
  w(v, "body", F), setTimeout(() => {
4529
4529
  const J = p.current[v];
4530
4530
  if (J) {
4531
- const ne = A + o.length;
4531
+ const ne = U + o.length;
4532
4532
  J.setSelectionRange(ne, ne), J.focus();
4533
4533
  }
4534
4534
  }, 0), x(!1);
@@ -4536,57 +4536,57 @@ function Ya({ template: a, setTemplate: s, onFileUpload: n }) {
4536
4536
  var z;
4537
4537
  const T = (z = a.carousel) == null ? void 0 : z.cards.find((F) => F.id === o);
4538
4538
  if (!T) return 0;
4539
- const A = (T.body || "").match(/\{\{(\d+)\}\}/g);
4540
- if (!A) return 0;
4541
- const B = A.map((F) => {
4539
+ const U = (T.body || "").match(/\{\{(\d+)\}\}/g);
4540
+ if (!U) return 0;
4541
+ const B = U.map((F) => {
4542
4542
  const H = F.match(/{{(\d+)}}/);
4543
4543
  return H ? parseInt(H[1], 10) : 0;
4544
4544
  });
4545
4545
  return B.length > 0 ? Math.max(...B) : 0;
4546
- }, N = (o, T) => {
4546
+ }, k = (o, T) => {
4547
4547
  var B;
4548
- const S = (B = a.carousel) == null ? void 0 : B.cards.find((z) => z.id === o);
4549
- if (!S || S.buttons.length >= 2) return;
4550
- const A = {
4548
+ const A = (B = a.carousel) == null ? void 0 : B.cards.find((z) => z.id === o);
4549
+ if (!A || A.buttons.length >= 2) return;
4550
+ const U = {
4551
4551
  id: Math.random().toString(36).substr(2, 9),
4552
4552
  type: T,
4553
4553
  text: "",
4554
4554
  value: "",
4555
4555
  urlType: "static"
4556
4556
  };
4557
- w(o, "buttons", [...S.buttons, A]);
4558
- }, U = (o, T, S, A) => {
4557
+ w(o, "buttons", [...A.buttons, U]);
4558
+ }, S = (o, T, A, U) => {
4559
4559
  var F;
4560
4560
  const B = (F = a.carousel) == null ? void 0 : F.cards.find((H) => H.id === o);
4561
4561
  if (!B) return;
4562
4562
  const z = B.buttons.map(
4563
- (H) => H.id === T ? { ...H, [S]: A } : H
4563
+ (H) => H.id === T ? { ...H, [A]: U } : H
4564
4564
  );
4565
4565
  w(o, "buttons", z);
4566
4566
  }, I = (o, T) => {
4567
4567
  var B;
4568
- const S = (B = a.carousel) == null ? void 0 : B.cards.find((z) => z.id === o);
4569
- if (!S) return;
4570
- const A = S.buttons.filter((z) => z.id !== T);
4571
- w(o, "buttons", A);
4568
+ const A = (B = a.carousel) == null ? void 0 : B.cards.find((z) => z.id === o);
4569
+ if (!A) return;
4570
+ const U = A.buttons.filter((z) => z.id !== T);
4571
+ w(o, "buttons", U);
4572
4572
  }, g = async (o, T) => {
4573
- var S;
4573
+ var A;
4574
4574
  try {
4575
4575
  i((F) => ({ ...F, [o]: !0 })), c((F) => ({ ...F, [o]: !1 }));
4576
- const A = ((S = a.carousel) == null ? void 0 : S.type) === "VIDEO" ? "VIDEO" : "IMAGE";
4577
- if (!Xa(T, A))
4578
- throw new Error(`Invalid file type. Expected ${A.toLowerCase()} file.`);
4579
- const B = Ja(A);
4576
+ const U = ((A = a.carousel) == null ? void 0 : A.type) === "VIDEO" ? "VIDEO" : "IMAGE";
4577
+ if (!Xa(T, U))
4578
+ throw new Error(`Invalid file type. Expected ${U.toLowerCase()} file.`);
4579
+ const B = Ja(U);
4580
4580
  if (T.size > B) {
4581
4581
  const F = B / 1048576;
4582
4582
  throw new Error(`File size too large. Maximum allowed size is ${F}MB.`);
4583
4583
  }
4584
4584
  const z = await n(T);
4585
4585
  w(o, "mediaUrl", z);
4586
- } catch (A) {
4587
- console.error("File upload failed:", A), f({ open: !0, message: A instanceof Error ? A.message : "File upload failed" });
4586
+ } catch (U) {
4587
+ console.error("File upload failed:", U), f({ open: !0, message: U instanceof Error ? U.message : "File upload failed" });
4588
4588
  } finally {
4589
- i((A) => ({ ...A, [o]: !1 }));
4589
+ i((U) => ({ ...U, [o]: !1 }));
4590
4590
  }
4591
4591
  };
4592
4592
  return /* @__PURE__ */ r("div", { className: "rsp-space-y-6", children: [
@@ -4609,7 +4609,7 @@ function Ya({ template: a, setTemplate: s, onFileUpload: n }) {
4609
4609
  /* @__PURE__ */ r(
4610
4610
  "button",
4611
4611
  {
4612
- onClick: k,
4612
+ onClick: N,
4613
4613
  disabled: (((L = a.carousel) == null ? void 0 : L.cards.length) || 0) >= 10,
4614
4614
  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",
4615
4615
  children: [
@@ -4654,7 +4654,7 @@ function Ya({ template: a, setTemplate: s, onFileUpload: n }) {
4654
4654
  ] })
4655
4655
  ] }),
4656
4656
  /* @__PURE__ */ e("div", { className: "rsp-space-y-6", children: (K = a.carousel) == null ? void 0 : K.cards.map((o, T) => {
4657
- var S, A, B, z, F, H, J, ne;
4657
+ var A, U, B, z, F, H, J, ne;
4658
4658
  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: [
4659
4659
  /* @__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: [
4660
4660
  /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-3", children: [
@@ -4677,8 +4677,8 @@ function Ya({ template: a, setTemplate: s, onFileUpload: n }) {
4677
4677
  /* @__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: [
4678
4678
  /* @__PURE__ */ r("div", { children: [
4679
4679
  /* @__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: [
4680
- /* @__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" }) }),
4681
- ((A = a.carousel) == null ? void 0 : A.type) === "VIDEO" ? "Video" : "Image",
4680
+ /* @__PURE__ */ e("svg", { className: "rsp-w-4 rsp-h-4 rsp-text-blue-500", 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" }) }),
4681
+ ((U = a.carousel) == null ? void 0 : U.type) === "VIDEO" ? "Video" : "Image",
4682
4682
  " Upload"
4683
4683
  ] }),
4684
4684
  /* @__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: [
@@ -4937,7 +4937,7 @@ function Ya({ template: a, setTemplate: s, onFileUpload: n }) {
4937
4937
  /* @__PURE__ */ r(
4938
4938
  "button",
4939
4939
  {
4940
- onClick: () => N(o.id, "QUICK_REPLY"),
4940
+ onClick: () => k(o.id, "QUICK_REPLY"),
4941
4941
  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",
4942
4942
  children: [
4943
4943
  /* @__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" }) }),
@@ -4948,7 +4948,7 @@ function Ya({ template: a, setTemplate: s, onFileUpload: n }) {
4948
4948
  /* @__PURE__ */ r(
4949
4949
  "button",
4950
4950
  {
4951
- onClick: () => N(o.id, "URL"),
4951
+ onClick: () => k(o.id, "URL"),
4952
4952
  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",
4953
4953
  children: [
4954
4954
  /* @__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" }) }),
@@ -4959,7 +4959,7 @@ function Ya({ template: a, setTemplate: s, onFileUpload: n }) {
4959
4959
  /* @__PURE__ */ r(
4960
4960
  "button",
4961
4961
  {
4962
- onClick: () => N(o.id, "PHONE_NUMBER"),
4962
+ onClick: () => k(o.id, "PHONE_NUMBER"),
4963
4963
  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",
4964
4964
  children: [
4965
4965
  /* @__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" }) }),
@@ -4998,7 +4998,7 @@ function Ya({ template: a, setTemplate: s, onFileUpload: n }) {
4998
4998
  {
4999
4999
  type: "text",
5000
5000
  value: E.text,
5001
- onChange: (P) => U(o.id, E.id, "text", P.target.value),
5001
+ onChange: (P) => S(o.id, E.id, "text", P.target.value),
5002
5002
  placeholder: `Enter Button Text (Max ${E.type === "QUICK_REPLY" ? "25" : "20"} characters)`,
5003
5003
  maxLength: E.type === "QUICK_REPLY" ? 25 : 20,
5004
5004
  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"
@@ -5015,7 +5015,7 @@ function Ya({ template: a, setTemplate: s, onFileUpload: n }) {
5015
5015
  {
5016
5016
  type: "radio",
5017
5017
  checked: E.urlType !== "dynamic",
5018
- onChange: () => U(o.id, E.id, "urlType", "static"),
5018
+ onChange: () => S(o.id, E.id, "urlType", "static"),
5019
5019
  className: "rsp-mr-2 rsp-text-blue-600"
5020
5020
  }
5021
5021
  ),
@@ -5027,7 +5027,7 @@ function Ya({ template: a, setTemplate: s, onFileUpload: n }) {
5027
5027
  {
5028
5028
  type: "radio",
5029
5029
  checked: E.urlType === "dynamic",
5030
- onChange: () => U(o.id, E.id, "urlType", "dynamic"),
5030
+ onChange: () => S(o.id, E.id, "urlType", "dynamic"),
5031
5031
  className: "rsp-mr-2 rsp-text-blue-600"
5032
5032
  }
5033
5033
  ),
@@ -5042,7 +5042,7 @@ function Ya({ template: a, setTemplate: s, onFileUpload: n }) {
5042
5042
  {
5043
5043
  type: "text",
5044
5044
  value: E.value || "",
5045
- onChange: (P) => U(o.id, E.id, "value", P.target.value),
5045
+ onChange: (P) => S(o.id, E.id, "value", P.target.value),
5046
5046
  placeholder: E.urlType === "dynamic" ? "https://example.com/order/{{1}}" : "https://example.com",
5047
5047
  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"
5048
5048
  }
@@ -5067,19 +5067,19 @@ function Ya({ template: a, setTemplate: s, onFileUpload: n }) {
5067
5067
  {
5068
5068
  type: "button",
5069
5069
  onClick: () => {
5070
- if (((E.value || "").match(/\{\{(\d+)\}\}/g) || []).length >= 3) return;
5070
+ if (((E.value || "").match(/\{\{(\d+)\}\}/g) || []).length >= 1) return;
5071
5071
  const q = ((E.value || "").match(/\{\{(\d+)\}\}/g) || []).map((_) => {
5072
5072
  const Z = _.match(/{{(\d+)}}/);
5073
5073
  return Z ? parseInt(Z[1], 10) : 0;
5074
5074
  }), ie = (q.length > 0 ? Math.max(...q) : 0) + 1, Q = (E.value || "") + `{{${ie}}}`;
5075
- U(o.id, E.id, "value", Q);
5075
+ S(o.id, E.id, "value", Q);
5076
5076
  },
5077
- disabled: ((E.value || "").match(/\{\{(\d+)\}\}/g) || []).length >= 3,
5077
+ disabled: ((E.value || "").match(/\{\{(\d+)\}\}/g) || []).length >= 1,
5078
5078
  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",
5079
5079
  children: "+ Add Variable"
5080
5080
  }
5081
5081
  ),
5082
- ((E.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" })
5082
+ ((E.value || "").match(/\{\{(\d+)\}\}/g) || []).length >= 1 && /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-500 rsp-mt-1", children: "Maximum 1 variable allowed" })
5083
5083
  ] }),
5084
5084
  (() => {
5085
5085
  const P = (E.value || "").match(/\{\{(\d+)\}\}/g) || [], oe = [...new Set(P.map((q) => q.replace(/[{}]/g, "")))];
@@ -5132,7 +5132,7 @@ function Ya({ template: a, setTemplate: s, onFileUpload: n }) {
5132
5132
  type: "button",
5133
5133
  onClick: () => {
5134
5134
  const Q = E.value || "", _ = new RegExp(`\\{\\{${q}\\}\\}`, "g"), Z = Q.replace(_, "");
5135
- U(o.id, E.id, "value", Z), s((X) => ({
5135
+ S(o.id, E.id, "value", Z), s((X) => ({
5136
5136
  ...X,
5137
5137
  carousel: {
5138
5138
  ...X.carousel,
@@ -5170,7 +5170,7 @@ function Ya({ template: a, setTemplate: s, onFileUpload: n }) {
5170
5170
  {
5171
5171
  type: "text",
5172
5172
  value: E.value || "",
5173
- onChange: (P) => U(o.id, E.id, "value", P.target.value),
5173
+ onChange: (P) => S(o.id, E.id, "value", P.target.value),
5174
5174
  placeholder: "+1234567890",
5175
5175
  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"
5176
5176
  }
@@ -5230,8 +5230,8 @@ function Za({ template: a, setTemplate: s }) {
5230
5230
  i.current && i.current.focus();
5231
5231
  }, 0);
5232
5232
  }, l = (f) => {
5233
- const h = i.current, x = a.body, v = h && typeof h.selectionStart == "number" ? h.selectionStart : x.length, V = x.substring(0, v), p = x.substring(v), k = V + f + p;
5234
- s({ ...a, body: k }), setTimeout(() => {
5233
+ const h = i.current, x = a.body, v = h && typeof h.selectionStart == "number" ? h.selectionStart : x.length, V = x.substring(0, v), p = x.substring(v), N = V + f + p;
5234
+ s({ ...a, body: N }), setTimeout(() => {
5235
5235
  if (i.current) {
5236
5236
  const M = v + f.length;
5237
5237
  i.current.setSelectionRange(M, M), i.current.focus();
@@ -5352,7 +5352,7 @@ function Za({ template: a, setTemplate: s }) {
5352
5352
  value: ((V = (v = a.sampleContent) == null ? void 0 : v.bodyVariables) == null ? void 0 : V[x]) || "",
5353
5353
  onChange: (p) => {
5354
5354
  var M, w, y;
5355
- const k = {
5355
+ const N = {
5356
5356
  ...a.sampleContent,
5357
5357
  headerVariables: ((M = a.sampleContent) == null ? void 0 : M.headerVariables) || {},
5358
5358
  bodyVariables: {
@@ -5361,7 +5361,7 @@ function Za({ template: a, setTemplate: s }) {
5361
5361
  },
5362
5362
  buttonVariables: ((y = a.sampleContent) == null ? void 0 : y.buttonVariables) || {}
5363
5363
  };
5364
- s({ ...a, sampleContent: k });
5364
+ s({ ...a, sampleContent: N });
5365
5365
  },
5366
5366
  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",
5367
5367
  placeholder: "Sample"
@@ -5373,10 +5373,10 @@ function Za({ template: a, setTemplate: s }) {
5373
5373
  type: "button",
5374
5374
  onClick: () => {
5375
5375
  var w, y, d;
5376
- const p = new RegExp(`\\{\\{${x}\\}\\}`, "g"), k = (a.body || "").replace(p, ""), M = Object.fromEntries(Object.entries(((w = a.sampleContent) == null ? void 0 : w.bodyVariables) || {}).filter(([u]) => u !== x));
5376
+ const p = new RegExp(`\\{\\{${x}\\}\\}`, "g"), N = (a.body || "").replace(p, ""), M = Object.fromEntries(Object.entries(((w = a.sampleContent) == null ? void 0 : w.bodyVariables) || {}).filter(([u]) => u !== x));
5377
5377
  s({
5378
5378
  ...a,
5379
- body: k,
5379
+ body: N,
5380
5380
  sampleContent: {
5381
5381
  ...a.sampleContent,
5382
5382
  bodyVariables: M,
@@ -5545,7 +5545,7 @@ const rr = (a) => {
5545
5545
  }), /* @__PURE__ */ e(he, { children: i });
5546
5546
  };
5547
5547
  function sr({ template: a }) {
5548
- var V, p, k, M;
5548
+ var V, p, N, M;
5549
5549
  const [s, n] = R(!1), [t, i] = R(0), c = (V = a.carousel) != null && V.cards ? a.carousel.cards.length : 0;
5550
5550
  me(() => {
5551
5551
  a.type === "CAROUSEL" && c > 0 ? t >= c && i(0) : i(0);
@@ -5650,7 +5650,7 @@ function sr({ template: a }) {
5650
5650
  /* @__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" }) })
5651
5651
  ] }) })
5652
5652
  ] }) }),
5653
- a.type === "CAROUSEL" && (((M = (k = a.carousel) == null ? void 0 : k.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: [
5653
+ a.type === "CAROUSEL" && (((M = (N = a.carousel) == null ? void 0 : N.cards) == null ? void 0 : M.length) || 0) > 0 && /* @__PURE__ */ e("div", { className: "rsp-flex rsp-justify-start rsp-mb-1.5", children: /* @__PURE__ */ e("div", { className: "rsp-w-[220px] rsp-animate-slide-up", children: /* @__PURE__ */ e("div", { className: "rsp-bg-gradient-to-b rsp-from-white rsp-to-[#fafafa] rsp-rounded-[12px] rsp-overflow-hidden rsp-shadow-[0_2px_8px_rgba(0,0,0,0.08)] rsp-border rsp-border-gray-100 rsp-relative rsp-min-h-[280px] rsp-flex rsp-flex-col", children: /* @__PURE__ */ r("div", { className: "rsp-relative rsp-flex-1 rsp-flex rsp-flex-col", children: [
5654
5654
  (() => {
5655
5655
  var y, d;
5656
5656
  const w = a.carousel && a.carousel.cards.length > 0 ? a.carousel.cards[t] || a.carousel.cards[0] : void 0;
@@ -5780,7 +5780,7 @@ const ze = {
5780
5780
  };
5781
5781
  function cr({ editId: a, onCancel: s }) {
5782
5782
  var y, d, u;
5783
- const [n, t] = R(ze), [i, c] = R(!0), [l, f] = R(!1), [h, x] = R(!1), [v, V] = R(null), [p, k] = R({
5783
+ const [n, t] = R(ze), [i, c] = R(!0), [l, f] = R(!1), [h, x] = R(!1), [v, V] = R(null), [p, N] = R({
5784
5784
  isOpen: !1
5785
5785
  });
5786
5786
  R({
@@ -5794,7 +5794,7 @@ function cr({ editId: a, onCancel: s }) {
5794
5794
  }
5795
5795
  }, [v]);
5796
5796
  const M = async () => {
5797
- var b, N, U;
5797
+ var b, k, S;
5798
5798
  try {
5799
5799
  if (x(!0), V(null), !n.name || !n.body)
5800
5800
  throw new Error("Template name and body are required");
@@ -5820,11 +5820,11 @@ function cr({ editId: a, onCancel: s }) {
5820
5820
  throw new Error(C.message);
5821
5821
  if (C.status === "error")
5822
5822
  throw new Error(C.message);
5823
- k({
5823
+ N({
5824
5824
  isOpen: !0,
5825
5825
  templateName: (b = C.data) == null ? void 0 : b.details[0].template_name,
5826
- templateId: (N = C.data) == null ? void 0 : N.details[0].template_id,
5827
- template: (U = C.data) == null ? void 0 : U.template
5826
+ templateId: (k = C.data) == null ? void 0 : k.details[0].template_id,
5827
+ template: (S = C.data) == null ? void 0 : S.template
5828
5828
  }), t(ze);
5829
5829
  } catch (I) {
5830
5830
  V(I instanceof Error ? I.message : "An error occurred while creating the template");
@@ -5836,18 +5836,18 @@ function cr({ editId: a, onCancel: s }) {
5836
5836
  if (!a) return;
5837
5837
  (async () => {
5838
5838
  try {
5839
- const N = localStorage.getItem("account"), U = N ? JSON.parse(N) : { apiKey: "" };
5840
- if (!U.apiKey)
5839
+ const k = localStorage.getItem("account"), S = k ? JSON.parse(k) : { apiKey: "" };
5840
+ if (!S.apiKey)
5841
5841
  throw new Error("Please set your API key in the dashboard first");
5842
- const I = await Ba(U.apiKey, a);
5842
+ const I = await Ba(S.apiKey, a);
5843
5843
  t((g) => ({ ...g, ...I }));
5844
- } catch (N) {
5845
- console.error("Failed to load template for edit", N), V(N instanceof Error ? N.message : "Failed to load template");
5844
+ } catch (k) {
5845
+ console.error("Failed to load template for edit", k), V(k instanceof Error ? k.message : "Failed to load template");
5846
5846
  }
5847
5847
  })();
5848
5848
  }, [a]);
5849
5849
  const w = () => {
5850
- k({ isOpen: !1 }), s && s();
5850
+ N({ isOpen: !1 }), s && s();
5851
5851
  };
5852
5852
  return /* @__PURE__ */ r("div", { className: "rsp-min-h-screen rsp-bg-[#f5f7fc] rsp-rounded-lg rsp-shadow-sm", children: [
5853
5853
  /* @__PURE__ */ r("div", { className: "rsp-max-w-[1200px] rsp-mx-auto rsp-px-6 rsp-h-full", children: [
@@ -5941,10 +5941,18 @@ function cr({ editId: a, onCancel: s }) {
5941
5941
  {
5942
5942
  value: n.type,
5943
5943
  onChange: (b) => {
5944
- const N = b.target.value;
5945
- N === "CAROUSEL" && !n.carousel ? t({
5946
- ...n,
5947
- type: N,
5944
+ const k = b.target.value, S = n.type;
5945
+ k !== S && t(k === "CAROUSEL" ? {
5946
+ name: n.name,
5947
+ category: n.category,
5948
+ type: k,
5949
+ language: n.language,
5950
+ enableClickTracking: n.enableClickTracking,
5951
+ headerType: "NONE",
5952
+ headerText: "",
5953
+ body: "",
5954
+ footer: "",
5955
+ buttons: [],
5948
5956
  carousel: {
5949
5957
  type: "IMAGE",
5950
5958
  cards: [{
@@ -5956,7 +5964,18 @@ function cr({ editId: a, onCancel: s }) {
5956
5964
  buttons: []
5957
5965
  }]
5958
5966
  }
5959
- }) : t({ ...n, type: N });
5967
+ } : {
5968
+ name: n.name,
5969
+ category: n.category,
5970
+ type: k,
5971
+ language: n.language,
5972
+ enableClickTracking: n.enableClickTracking,
5973
+ headerType: "NONE",
5974
+ headerText: "",
5975
+ body: "",
5976
+ footer: "",
5977
+ buttons: []
5978
+ });
5960
5979
  },
5961
5980
  className: "rsp-w-full rsp-px-0 rsp-border-0 rsp-border-b rsp-border-gray-300 rsp-text-sm rsp-bg-transparent rsp-appearance-none rsp-h-10 rsp-leading-10 focus:rsp-outline-none focus:rsp-border-blue-500",
5962
5981
  children: [