@oneclick.dev/cms-core-modules 0.0.124 → 0.0.125

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.
Files changed (149) hide show
  1. package/dist/AppointmentListTable-CWzbwqR-.js +1 -0
  2. package/dist/AppointmentListTable-DoZuBstk.mjs +270 -0
  3. package/dist/ContentEditor-BlNbqkAz.js +324 -0
  4. package/dist/{ContentEditor-DX1bTQKs.mjs → ContentEditor-D754iLJS.mjs} +8074 -27026
  5. package/dist/{Detail-B7pe808q.mjs → Detail-BOxWQ1QQ.mjs} +2 -2
  6. package/dist/{Detail-B_Q7Qkuz.mjs → Detail-BfKW0uZE.mjs} +2 -2
  7. package/dist/Detail-DFVu2F38.mjs +11 -0
  8. package/dist/{Detail-t3tOcy3X.js → Detail-DJea_fCd.js} +1 -1
  9. package/dist/{Detail-CNiLIEh9.js → Detail-DPJacXfm.js} +1 -1
  10. package/dist/Detail-DSLZ7_bM.js +1 -0
  11. package/dist/{Detail-BESGmY7z.js → Detail-DUGThL9Y.js} +1 -1
  12. package/dist/{Detail-DNxAzeCs.mjs → Detail-D_LlEeHu.mjs} +2 -2
  13. package/dist/Overview-0hFXiuYo.js +1 -0
  14. package/dist/Overview-BTx5LF4J.js +1 -0
  15. package/dist/Overview-CCu2PHai.mjs +289 -0
  16. package/dist/Overview-D2u-leeO.js +1 -0
  17. package/dist/Overview-D_2wozCG.mjs +1733 -0
  18. package/dist/Overview-Dffo-zH4.mjs +11 -0
  19. package/dist/{TableCalculationWidget-CrqcLGfU.mjs → TableCalculationWidget-B_LFoOYm.mjs} +3 -3
  20. package/dist/{TableCalculationWidget-CkQPrVUd.js → TableCalculationWidget-CahOIcbk.js} +1 -1
  21. package/dist/TableDataWidget-BwqWFH4A.js +1 -0
  22. package/dist/TableDataWidget-RsVxcDsL.mjs +112 -0
  23. package/dist/TableOverviewCard-BPWCqo56.js +1 -0
  24. package/dist/{TableOverviewCard-Ci0d4o4w.mjs → TableOverviewCard-D667DDag.mjs} +113 -127
  25. package/dist/TableResultView.vue_vue_type_script_setup_true_lang-C3XiOXgb.js +1 -0
  26. package/dist/TableResultView.vue_vue_type_script_setup_true_lang-sp0TLio0.mjs +547 -0
  27. package/dist/{TableRowActionCard-BhdnnPaq.mjs → TableRowActionCard-BPYJ-Kjy.mjs} +95 -101
  28. package/dist/TableRowActionCard-Bnqj1YIe.js +1 -0
  29. package/dist/TableView-CwhZ9YN2.js +4 -0
  30. package/dist/TableView-DX9PKS8N.mjs +9673 -0
  31. package/dist/TemplateBuilder.vue_vue_type_script_setup_true_lang-BgDdzbLe.js +1 -0
  32. package/dist/TemplateBuilder.vue_vue_type_script_setup_true_lang-D85V4nrQ.mjs +2886 -0
  33. package/dist/cms-core-modules.css +1 -1
  34. package/dist/dateRangePresets-CaPVagHY.mjs +453 -0
  35. package/dist/dateRangePresets-gxQCiZ6c.js +1 -0
  36. package/dist/index-6hZ6MYY6.js +1 -0
  37. package/dist/index-BVmmicu3.mjs +14 -0
  38. package/dist/index-ChHD_1Cf.js +144 -0
  39. package/dist/index-CvV4nVWI.js +1 -0
  40. package/dist/index-DH2z0W_w.mjs +19012 -0
  41. package/dist/index-DZKzj48V.mjs +17 -0
  42. package/dist/index.cjs.js +1 -1
  43. package/dist/index.mjs +237 -103
  44. package/dist/orders-C_sz8J9b.js +1 -0
  45. package/dist/{orders-BfTLIm7U.mjs → orders-Cgdggzvx.mjs} +84 -84
  46. package/dist/server-handlers.cjs.js +1 -1
  47. package/dist/server-handlers.mjs +2055 -1123
  48. package/dist/src/appointments/chat-components/AppointmentListTable.vue.d.ts +3 -0
  49. package/dist/src/appointments/index.d.ts +93 -3
  50. package/dist/src/appointments/reservation-summary.d.ts +48 -0
  51. package/dist/src/appointments/server.d.ts +1 -0
  52. package/dist/src/appointments/tools.d.ts +93 -3
  53. package/dist/src/filezone/config.d.ts +31 -0
  54. package/dist/src/filezone/index.d.ts +43 -0
  55. package/dist/src/filezone/index.vue.d.ts +2 -0
  56. package/dist/src/filezone/metadata.d.ts +2 -0
  57. package/dist/src/filezone/pages/Overview.vue.d.ts +4 -0
  58. package/dist/src/filezone/permissions.d.ts +5 -0
  59. package/dist/src/filezone/routes.d.ts +5 -0
  60. package/dist/src/filezone/server.d.ts +36 -0
  61. package/dist/src/index.d.ts +2 -0
  62. package/dist/src/mailTemplates/builder-types.d.ts +40 -0
  63. package/dist/src/mailTemplates/components/BlockRenderer.vue.d.ts +24 -0
  64. package/dist/src/mailTemplates/components/DesignPanel.vue.d.ts +13 -0
  65. package/dist/src/mailTemplates/components/EmailCanvas.vue.d.ts +44 -0
  66. package/dist/src/mailTemplates/components/RichTextEditor.vue.d.ts +10 -0
  67. package/dist/src/mailTemplates/components/RightSidebar.vue.d.ts +18 -0
  68. package/dist/src/mailTemplates/components/SettingsPanel.vue.d.ts +15 -0
  69. package/dist/src/mailTemplates/components/TemplateBuilder.vue.d.ts +2 -0
  70. package/dist/src/mailTemplates/components/TemplateList.vue.d.ts +19 -1
  71. package/dist/src/mailTemplates/components/rich-text.d.ts +6 -0
  72. package/dist/src/mailTemplates/config.d.ts +10 -4
  73. package/dist/src/mailTemplates/defaults.d.ts +10 -0
  74. package/dist/src/mailTemplates/editor-state.d.ts +21 -0
  75. package/dist/src/mailTemplates/index.d.ts +11 -5
  76. package/dist/src/mailTemplates/index.vue.d.ts +2 -4
  77. package/dist/src/mailTemplates/metadata.d.ts +1 -1
  78. package/dist/src/mailTemplates/pages/Detail.vue.d.ts +1 -13
  79. package/dist/src/mailTemplates/pages/Overview.vue.d.ts +1 -13
  80. package/dist/src/mailTemplates/server.d.ts +23 -0
  81. package/dist/src/server-handlers.d.ts +4 -0
  82. package/dist/src/table/badge-filter-utils.d.ts +8 -0
  83. package/dist/src/table/chat-components/TableOverviewCard.vue.d.ts +2 -7
  84. package/dist/src/table/chat-components/TableResultView.vue.d.ts +3 -7
  85. package/dist/src/table/components/TableDisplayCell.vue.d.ts +8 -0
  86. package/dist/src/table/components/columns/BadgeColumnSettings.vue.d.ts +9 -0
  87. package/dist/src/table/components/columns/ColumnColorSelect.vue.d.ts +11 -0
  88. package/dist/src/table/components/columns/ColumnDisplaySettings.vue.d.ts +9 -0
  89. package/dist/src/table/components/columns/ColumnTypeSelect.vue.d.ts +11 -0
  90. package/dist/src/table/components/columns/ColumnValueSourceInput.vue.d.ts +15 -0
  91. package/dist/src/table/components/columns/DialogTableColumnItem.vue.d.ts +8 -11
  92. package/dist/src/table/components/columns/ProgressColumnSettings.vue.d.ts +8 -0
  93. package/dist/src/table/components/stats/StatDialog.vue.d.ts +6 -10
  94. package/dist/src/table/components/stats/Stats.vue.d.ts +9 -15
  95. package/dist/src/table/composables/useTableClock.d.ts +4 -0
  96. package/dist/src/table/display-utils.d.ts +35 -0
  97. package/dist/src/table/row-value.d.ts +1 -0
  98. package/dist/src/table/stat-utils.d.ts +9 -0
  99. package/dist/src/table/tool-utils.d.ts +1 -1
  100. package/dist/src/table/types.d.ts +54 -1
  101. package/dist/src/whatsappBusiness/analytics.d.ts +4 -0
  102. package/dist/src/whatsappBusiness/components/AccountPanel.vue.d.ts +2 -0
  103. package/dist/src/whatsappBusiness/components/InsightsPanel.vue.d.ts +5 -0
  104. package/dist/src/whatsappBusiness/components/TemplateDialog.vue.d.ts +14 -0
  105. package/dist/src/whatsappBusiness/components/TemplatesPanel.vue.d.ts +5 -0
  106. package/dist/src/whatsappBusiness/components/presentation.d.ts +4 -0
  107. package/dist/src/whatsappBusiness/config.d.ts +51 -0
  108. package/dist/src/whatsappBusiness/connection.d.ts +77 -0
  109. package/dist/src/whatsappBusiness/index.d.ts +63 -0
  110. package/dist/src/whatsappBusiness/index.vue.d.ts +5 -0
  111. package/dist/src/whatsappBusiness/metadata.d.ts +2 -0
  112. package/dist/src/whatsappBusiness/pages/Overview.vue.d.ts +2 -0
  113. package/dist/src/whatsappBusiness/permissions.d.ts +5 -0
  114. package/dist/src/whatsappBusiness/provider.d.ts +21 -0
  115. package/dist/src/whatsappBusiness/routes.d.ts +5 -0
  116. package/dist/src/whatsappBusiness/server.d.ts +14 -0
  117. package/dist/src/whatsappBusiness/templates.d.ts +94 -0
  118. package/dist/src/whatsappBusiness/types.d.ts +162 -0
  119. package/dist/{tool-sandbox-DoF1PsyS.js → tool-sandbox-BSkKdH7V.js} +1 -1
  120. package/dist/{tool-sandbox-DdkMLkDK.mjs → tool-sandbox-DU9b1B7v.mjs} +1 -1
  121. package/dist/{types-ibC3-e1N.mjs → types-B5MifmeF.mjs} +339 -273
  122. package/dist/types-D5dgTskW.js +1 -0
  123. package/dist/{useTableAgentTools-D5mzGf3A.js → useTableAgentTools-BrUot49I.js} +1 -1
  124. package/dist/{useTableAgentTools-DcN3kYRL.mjs → useTableAgentTools-r5InEI4p.mjs} +8 -8
  125. package/dist/{vee-validate-zod-BQElPD0m.js → vee-validate-zod-CWZwNTWE.js} +1 -1
  126. package/dist/{vee-validate-zod-CN16K2x9.mjs → vee-validate-zod-D0WaDgDZ.mjs} +1 -1
  127. package/package.json +2 -2
  128. package/src/appointments/tools.ts +52 -2
  129. package/dist/AppointmentListTable-DZJNmTMb.mjs +0 -177
  130. package/dist/AppointmentListTable-Dieu9US_.js +0 -1
  131. package/dist/ContentEditor-BcIUumah.js +0 -467
  132. package/dist/Detail-Byk781b4.mjs +0 -26
  133. package/dist/Detail-mvSGbnFU.js +0 -1
  134. package/dist/Overview-BDlBCUI_.js +0 -1
  135. package/dist/Overview-Su8ZUbMs.mjs +0 -26
  136. package/dist/TableDataWidget-7qvC3Egd.js +0 -1
  137. package/dist/TableDataWidget-DMTSoGRO.mjs +0 -121
  138. package/dist/TableOverviewCard-AFq-puJs.js +0 -1
  139. package/dist/TableResultView.vue_vue_type_script_setup_true_lang-CBn-Oxl9.mjs +0 -534
  140. package/dist/TableResultView.vue_vue_type_script_setup_true_lang-C_Lv-SmJ.js +0 -1
  141. package/dist/TableRowActionCard-IzB6tNN-.js +0 -1
  142. package/dist/TableView-6mdrL3zx.js +0 -4
  143. package/dist/TableView-Du5nOE6R.mjs +0 -8228
  144. package/dist/TemplateList.vue_vue_type_script_setup_true_lang-B_AtWnHa.js +0 -1
  145. package/dist/TemplateList.vue_vue_type_script_setup_true_lang-Cmovy7kk.mjs +0 -40
  146. package/dist/dateRangePresets-B-l5b_wR.mjs +0 -48
  147. package/dist/dateRangePresets-CPWqst_x.js +0 -1
  148. package/dist/orders-DUa2PVoa.js +0 -1
  149. package/dist/types-BMraG1kN.js +0 -1
@@ -0,0 +1,1733 @@
1
+ import { defineComponent as ie, ref as w, computed as de, watch as ge, resolveComponent as i, openBlock as o, createBlock as V, withCtx as s, createVNode as t, createTextVNode as l, toDisplayString as n, createElementBlock as r, unref as c, withModifiers as be, createCommentVNode as k, createElementVNode as e, Fragment as j, renderList as Q, onMounted as me, normalizeClass as xe, onUnmounted as $e } from "vue";
2
+ import { Loader2 as Z, AlertCircle as ee, Plus as _e, Trash2 as Me, Pencil as Ce, ExternalLink as Ae, Search as Se, FileText as ye, ChevronLeft as Re, ChevronRight as Ve, Send as Ue, CheckCheck as Ee, BarChart3 as pe, RefreshCw as Ne, ShieldAlert as Le, Smartphone as ve } from "lucide-vue-next";
3
+ import { useModuleApi as re, useModule as Be, useModulePermissions as Pe, useModuleBreadcrumbs as Ie } from "@oneclick.dev/cms-kit";
4
+ import { t as we } from "./index-RLz1QPrf.mjs";
5
+ function te($, B) {
6
+ const m = $;
7
+ return m?.data?.statusMessage || m?.statusMessage || B;
8
+ }
9
+ function L($) {
10
+ return $ == null || $ === "" ? "Not available" : String($).replaceAll("_", " ").toLowerCase().replace(/^./, (B) => B.toUpperCase());
11
+ }
12
+ function ne($) {
13
+ return typeof $ == "number" && Number.isFinite($) ? new Intl.NumberFormat().format($) : "Not available";
14
+ }
15
+ function fe($, B) {
16
+ if (!$) return "Not available";
17
+ const m = new Date(typeof $ == "number" ? $ * 1e3 : $);
18
+ return Number.isNaN(m.getTime()) ? "Not available" : m.toLocaleDateString(void 0, { dateStyle: "medium", ...B ? { timeZone: B } : {} });
19
+ }
20
+ const De = {
21
+ key: 0,
22
+ role: "status",
23
+ class: "flex items-center justify-center gap-2 py-16 text-sm text-muted-foreground"
24
+ }, ze = { class: "grid min-w-0 gap-6 md:grid-cols-[minmax(0,1.25fr)_minmax(0,1fr)]" }, He = {
25
+ key: 0,
26
+ class: "min-w-0 space-y-4"
27
+ }, Oe = { class: "space-y-2" }, je = { class: "grid grid-cols-2 gap-3" }, qe = { class: "space-y-2" }, Ye = { class: "space-y-2" }, Fe = { class: "space-y-2" }, Qe = {
28
+ key: 0,
29
+ class: "space-y-2"
30
+ }, We = { class: "space-y-2" }, Ke = {
31
+ key: 1,
32
+ class: "space-y-3 rounded-lg border p-3"
33
+ }, Je = { class: "space-y-2" }, Ge = { class: "space-y-3" }, Xe = { class: "flex items-center justify-between gap-2" }, Ze = { class: "text-xs leading-5 text-muted-foreground" }, et = { class: "flex items-center gap-2" }, tt = { class: "space-y-2" }, st = {
34
+ key: 0,
35
+ class: "space-y-2"
36
+ }, at = {
37
+ key: 1,
38
+ class: "space-y-2"
39
+ }, lt = {
40
+ key: 1,
41
+ class: "min-w-0 space-y-5"
42
+ }, ot = { class: "grid grid-cols-2 gap-5 text-sm" }, nt = { class: "mt-1 font-medium" }, dt = { class: "mt-1 font-medium" }, ut = { class: "mt-1 font-medium" }, it = { class: "mt-1 font-medium" }, rt = {
43
+ key: 1,
44
+ class: "rounded-lg border bg-muted/30 p-3 text-sm leading-6 text-muted-foreground"
45
+ }, mt = {
46
+ href: "https://business.facebook.com/wa/manage/message-templates/",
47
+ target: "_blank",
48
+ rel: "noopener noreferrer",
49
+ class: "flex items-center gap-1.5 text-sm underline underline-offset-4"
50
+ }, pt = { class: "min-w-0 self-start rounded-xl border bg-muted/40 p-4" }, ct = { class: "overflow-hidden rounded-lg border bg-background shadow-sm" }, vt = {
51
+ key: 0,
52
+ class: "whitespace-pre-wrap break-words px-4 pt-4 text-sm font-semibold"
53
+ }, ft = {
54
+ key: 1,
55
+ class: "whitespace-pre-wrap break-words p-4 text-sm leading-6"
56
+ }, gt = {
57
+ key: 2,
58
+ class: "whitespace-pre-wrap break-words px-4 pb-4 text-xs text-muted-foreground"
59
+ }, bt = {
60
+ key: 3,
61
+ class: "border-t"
62
+ }, xt = {
63
+ key: 4,
64
+ class: "m-3 rounded border border-dashed p-3 text-sm text-muted-foreground"
65
+ }, _t = {
66
+ key: 1,
67
+ class: "mt-5 rounded-lg border bg-muted/30 p-3 text-sm leading-6 text-muted-foreground"
68
+ }, yt = /* @__PURE__ */ ie({
69
+ __name: "TemplateDialog",
70
+ props: {
71
+ open: { type: Boolean },
72
+ template: {},
73
+ canManage: { type: Boolean }
74
+ },
75
+ emits: ["update:open", "saved"],
76
+ setup($, { emit: B }) {
77
+ const m = $, M = B, S = re(), p = w(null), h = w(!1), u = w(!1), x = w(!1), T = w(""), f = w(d()), C = de(() => [...new Set(Array.from(f.value.bodyText.matchAll(/\{\{(\d+)\}\}/g), (_) => Number(_[1])))].sort((_, a) => _ - a).slice(0, 20)), A = w({}), y = de(() => !p.value && !x.value && (f.value.buttons?.length || 0) < (f.value.buttons?.some((_) => _.type !== "QUICK_REPLY") ? 2 : 3)), P = de(() => h.value ? [
78
+ ...f.value.headerText ? [{ type: "HEADER", format: "TEXT", text: f.value.headerText }] : [],
79
+ { type: "BODY", text: f.value.bodyText || "Your message will appear here." },
80
+ ...f.value.footerText ? [{ type: "FOOTER", text: f.value.footerText }] : [],
81
+ ...f.value.buttons?.length ? [{ type: "BUTTONS", buttons: f.value.buttons }] : []
82
+ ] : p.value?.components || []);
83
+ function d() {
84
+ return { name: "", language: "en_US", category: "UTILITY", headerText: "", headerExample: "", bodyText: "", bodyExamples: [], footerText: "", buttons: [] };
85
+ }
86
+ function J(_) {
87
+ return "Example for {{" + _ + "}}";
88
+ }
89
+ function W(_) {
90
+ f.value = JSON.parse(JSON.stringify(_)), f.value.buttons ||= [], A.value = Object.fromEntries((_.bodyExamples || []).map((a, E) => [E + 1, a]));
91
+ }
92
+ ge(() => [m.open, m.template?.id], async ([_], a, E) => {
93
+ let R = !1;
94
+ if (E(() => {
95
+ R = !0;
96
+ }), !!_ && (u.value = !1, T.value = "", p.value = m.template, h.value = !m.template, W(m.template?.draft || d()), !!m.template)) {
97
+ u.value = !0;
98
+ try {
99
+ const I = await S.get(`/templates/${encodeURIComponent(m.template.id)}`, { query: { name: m.template.name } });
100
+ if (R) return;
101
+ p.value = I, I.draft && W(I.draft);
102
+ } catch (I) {
103
+ R || (T.value = te(I, "The latest template could not be loaded. Reopen it to try again."));
104
+ } finally {
105
+ R || (u.value = !1);
106
+ }
107
+ }
108
+ });
109
+ function K(_, a) {
110
+ if (p.value || x.value) return;
111
+ const E = f.value.buttons?.[_]?.text || "";
112
+ let R = { type: "QUICK_REPLY", text: E };
113
+ a === "URL" && (R = { type: "URL", text: E, url: "" }), a === "PHONE_NUMBER" && (R = { type: "PHONE_NUMBER", text: E, phoneNumber: "" }), f.value.buttons && (f.value.buttons[_] = R);
114
+ }
115
+ function U(_, a) {
116
+ const E = (f.value.buttons || []).filter((R, I) => I !== _);
117
+ return a === "QUICK_REPLY" ? E.every((R) => R.type === "QUICK_REPLY") : E.every((R) => R.type !== "QUICK_REPLY" && R.type !== a);
118
+ }
119
+ function v() {
120
+ if (!y.value) return;
121
+ const _ = f.value.buttons ||= [];
122
+ _.some((a) => a.type === "URL") ? _.push({ type: "PHONE_NUMBER", text: "", phoneNumber: "" }) : _.some((a) => a.type === "PHONE_NUMBER") ? _.push({ type: "URL", text: "", url: "" }) : _.push({ type: "QUICK_REPLY", text: "" });
123
+ }
124
+ async function z() {
125
+ if (!(x.value || !m.canManage || p.value && !p.value.editable)) {
126
+ x.value = !0, T.value = "";
127
+ try {
128
+ const _ = { ...f.value, bodyExamples: C.value.map((E) => A.value[E] || "") };
129
+ if (!(p.value ? await S.patch(`/templates/${encodeURIComponent(p.value.id)}`, { body: _ }) : await S.post("/templates", { body: _ })).success) throw new Error("Mutation unsuccessful");
130
+ we.success("Template submitted to Meta"), M("saved"), M("update:open", !1);
131
+ } catch (_) {
132
+ T.value = te(_, "The template could not be submitted. Review the fields and try again.");
133
+ } finally {
134
+ x.value = !1;
135
+ }
136
+ }
137
+ }
138
+ function q(_) {
139
+ x.value || M("update:open", _);
140
+ }
141
+ return (_, a) => {
142
+ const E = i("ResponsiveModalTitle"), R = i("ResponsiveModalDescription"), I = i("ResponsiveModalHeader"), G = i("AlertTitle"), se = i("AlertDescription"), Y = i("Alert"), H = i("Label"), D = i("Input"), X = i("SelectValue"), ae = i("SelectTrigger"), O = i("SelectItem"), le = i("SelectContent"), oe = i("Select"), ue = i("Textarea"), g = i("Button"), ce = i("ResponsiveModalFooter"), he = i("ResponsiveModalScrollContent"), ke = i("ResponsiveModal");
143
+ return o(), V(ke, {
144
+ open: $.open,
145
+ "onUpdate:open": q
146
+ }, {
147
+ default: s(() => [
148
+ t(he, { class: "sm:max-w-4xl" }, {
149
+ default: s(() => [
150
+ t(I, null, {
151
+ default: s(() => [
152
+ t(E, { class: "break-all" }, {
153
+ default: s(() => [
154
+ l(n(p.value ? p.value.name : "New message template"), 1)
155
+ ]),
156
+ _: 1
157
+ }),
158
+ t(R, null, {
159
+ default: s(() => [
160
+ l(n(h.value ? "Submit a standard text template for Meta approval." : "Review this template and its current approval status."), 1)
161
+ ]),
162
+ _: 1
163
+ })
164
+ ]),
165
+ _: 1
166
+ }),
167
+ u.value ? (o(), r("div", De, [
168
+ t(c(Z), { class: "size-4 animate-spin" }),
169
+ a[9] || (a[9] = l("Loading template…", -1))
170
+ ])) : (o(), r("form", {
171
+ key: 1,
172
+ class: "py-5",
173
+ onSubmit: be(z, ["prevent"])
174
+ }, [
175
+ T.value ? (o(), V(Y, {
176
+ key: 0,
177
+ variant: "destructive",
178
+ class: "mb-5"
179
+ }, {
180
+ default: s(() => [
181
+ t(c(ee)),
182
+ t(G, null, {
183
+ default: s(() => [...a[10] || (a[10] = [
184
+ l("Template unavailable", -1)
185
+ ])]),
186
+ _: 1
187
+ }),
188
+ t(se, null, {
189
+ default: s(() => [
190
+ l(n(T.value), 1)
191
+ ]),
192
+ _: 1
193
+ })
194
+ ]),
195
+ _: 1
196
+ })) : k("", !0),
197
+ e("div", ze, [
198
+ h.value ? (o(), r("div", He, [
199
+ e("div", Oe, [
200
+ t(H, { for: "wa-template-name" }, {
201
+ default: s(() => [...a[11] || (a[11] = [
202
+ l("Name", -1)
203
+ ])]),
204
+ _: 1
205
+ }),
206
+ t(D, {
207
+ id: "wa-template-name",
208
+ modelValue: f.value.name,
209
+ "onUpdate:modelValue": a[0] || (a[0] = (b) => f.value.name = b),
210
+ pattern: "[a-z0-9_]+",
211
+ maxlength: "512",
212
+ placeholder: "appointment_reminder",
213
+ disabled: !!p.value || x.value,
214
+ required: ""
215
+ }, null, 8, ["modelValue", "disabled"]),
216
+ a[12] || (a[12] = e("p", { class: "text-xs text-muted-foreground" }, "Lowercase letters, numbers, and underscores. Existing names cannot change.", -1))
217
+ ]),
218
+ e("div", je, [
219
+ e("div", qe, [
220
+ t(H, { for: "wa-template-language" }, {
221
+ default: s(() => [...a[13] || (a[13] = [
222
+ l("Language code", -1)
223
+ ])]),
224
+ _: 1
225
+ }),
226
+ t(D, {
227
+ id: "wa-template-language",
228
+ modelValue: f.value.language,
229
+ "onUpdate:modelValue": a[1] || (a[1] = (b) => f.value.language = b),
230
+ placeholder: "en_US",
231
+ disabled: !!p.value || x.value,
232
+ required: ""
233
+ }, null, 8, ["modelValue", "disabled"]),
234
+ a[14] || (a[14] = e("p", { class: "text-xs text-muted-foreground" }, "Meta code, e.g. en_US, nl, fr.", -1))
235
+ ]),
236
+ e("div", Ye, [
237
+ t(H, { for: "wa-template-category" }, {
238
+ default: s(() => [...a[15] || (a[15] = [
239
+ l("Category", -1)
240
+ ])]),
241
+ _: 1
242
+ }),
243
+ t(oe, {
244
+ modelValue: f.value.category,
245
+ "onUpdate:modelValue": a[2] || (a[2] = (b) => f.value.category = b),
246
+ disabled: !!p.value || x.value
247
+ }, {
248
+ default: s(() => [
249
+ t(ae, { id: "wa-template-category" }, {
250
+ default: s(() => [
251
+ t(X)
252
+ ]),
253
+ _: 1
254
+ }),
255
+ t(le, null, {
256
+ default: s(() => [
257
+ t(O, { value: "UTILITY" }, {
258
+ default: s(() => [...a[16] || (a[16] = [
259
+ l("Utility", -1)
260
+ ])]),
261
+ _: 1
262
+ }),
263
+ t(O, { value: "MARKETING" }, {
264
+ default: s(() => [...a[17] || (a[17] = [
265
+ l("Marketing", -1)
266
+ ])]),
267
+ _: 1
268
+ })
269
+ ]),
270
+ _: 1
271
+ })
272
+ ]),
273
+ _: 1
274
+ }, 8, ["modelValue", "disabled"])
275
+ ])
276
+ ]),
277
+ e("div", Fe, [
278
+ t(H, { for: "wa-template-header" }, {
279
+ default: s(() => [...a[18] || (a[18] = [
280
+ l("Header ", -1),
281
+ e("span", { class: "font-normal text-muted-foreground" }, "(optional)", -1)
282
+ ])]),
283
+ _: 1
284
+ }),
285
+ t(D, {
286
+ id: "wa-template-header",
287
+ modelValue: f.value.headerText,
288
+ "onUpdate:modelValue": a[3] || (a[3] = (b) => f.value.headerText = b),
289
+ maxlength: "60",
290
+ disabled: x.value
291
+ }, null, 8, ["modelValue", "disabled"])
292
+ ]),
293
+ f.value.headerText?.includes("{{1}}") ? (o(), r("div", Qe, [
294
+ t(H, { for: "wa-template-header-example" }, {
295
+ default: s(() => [...a[19] || (a[19] = [
296
+ l("Header variable example", -1)
297
+ ])]),
298
+ _: 1
299
+ }),
300
+ t(D, {
301
+ id: "wa-template-header-example",
302
+ modelValue: f.value.headerExample,
303
+ "onUpdate:modelValue": a[4] || (a[4] = (b) => f.value.headerExample = b),
304
+ placeholder: "Example for {{1}}",
305
+ disabled: x.value,
306
+ required: ""
307
+ }, null, 8, ["modelValue", "disabled"])
308
+ ])) : k("", !0),
309
+ e("div", We, [
310
+ t(H, { for: "wa-template-body" }, {
311
+ default: s(() => [...a[20] || (a[20] = [
312
+ l("Message", -1)
313
+ ])]),
314
+ _: 1
315
+ }),
316
+ t(ue, {
317
+ id: "wa-template-body",
318
+ modelValue: f.value.bodyText,
319
+ "onUpdate:modelValue": a[5] || (a[5] = (b) => f.value.bodyText = b),
320
+ rows: "6",
321
+ maxlength: "1024",
322
+ placeholder: "Hello {{1}}, your appointment is on {{2}}.",
323
+ disabled: x.value,
324
+ required: ""
325
+ }, null, 8, ["modelValue", "disabled"]),
326
+ a[21] || (a[21] = e("p", { class: "text-xs leading-5 text-muted-foreground" }, [
327
+ l("Use numbered variables such as "),
328
+ e("code", null, "{{1}}"),
329
+ l(" and "),
330
+ e("code", null, "{{2}}"),
331
+ l(", in order. Provide sample values for Meta’s review.")
332
+ ], -1))
333
+ ]),
334
+ C.value.length ? (o(), r("div", Ke, [
335
+ (o(!0), r(j, null, Q(C.value, (b) => (o(), r("div", {
336
+ key: b,
337
+ class: "space-y-2"
338
+ }, [
339
+ t(H, {
340
+ for: `wa-example-${b}`
341
+ }, {
342
+ default: s(() => [
343
+ l(n(J(b)), 1)
344
+ ]),
345
+ _: 2
346
+ }, 1032, ["for"]),
347
+ t(D, {
348
+ id: `wa-example-${b}`,
349
+ modelValue: A.value[b],
350
+ "onUpdate:modelValue": (N) => A.value[b] = N,
351
+ disabled: x.value,
352
+ required: ""
353
+ }, null, 8, ["id", "modelValue", "onUpdate:modelValue", "disabled"])
354
+ ]))), 128)),
355
+ a[22] || (a[22] = e("p", { class: "text-xs text-muted-foreground" }, "Use fictional examples rather than customer details.", -1))
356
+ ])) : k("", !0),
357
+ e("div", Je, [
358
+ t(H, { for: "wa-template-footer" }, {
359
+ default: s(() => [...a[23] || (a[23] = [
360
+ l("Footer ", -1),
361
+ e("span", { class: "font-normal text-muted-foreground" }, "(optional)", -1)
362
+ ])]),
363
+ _: 1
364
+ }),
365
+ t(D, {
366
+ id: "wa-template-footer",
367
+ modelValue: f.value.footerText,
368
+ "onUpdate:modelValue": a[6] || (a[6] = (b) => f.value.footerText = b),
369
+ maxlength: "60",
370
+ disabled: x.value
371
+ }, null, 8, ["modelValue", "disabled"])
372
+ ]),
373
+ e("div", Ge, [
374
+ e("div", Xe, [
375
+ a[25] || (a[25] = e("h3", { class: "text-sm font-medium" }, [
376
+ l("Buttons "),
377
+ e("span", { class: "font-normal text-muted-foreground" }, "(optional)")
378
+ ], -1)),
379
+ t(g, {
380
+ type: "button",
381
+ variant: "outline",
382
+ size: "sm",
383
+ disabled: !y.value,
384
+ onClick: v
385
+ }, {
386
+ default: s(() => [
387
+ t(c(_e), { class: "size-3.5" }),
388
+ a[24] || (a[24] = l("Add", -1))
389
+ ]),
390
+ _: 1
391
+ }, 8, ["disabled"])
392
+ ]),
393
+ e("p", Ze, n(p.value ? "Existing button types and positions are preserved for your automations. Create a new template to change the button structure." : "Up to three quick replies, or one website and one phone button."), 1),
394
+ (o(!0), r(j, null, Q(f.value.buttons, (b, N) => (o(), r("div", {
395
+ key: N,
396
+ class: "space-y-3 rounded-lg border p-3"
397
+ }, [
398
+ e("div", et, [
399
+ t(oe, {
400
+ "model-value": b.type,
401
+ disabled: !!p.value || x.value,
402
+ "onUpdate:modelValue": (F) => K(N, F)
403
+ }, {
404
+ default: s(() => [
405
+ t(ae, {
406
+ "aria-label": `Button ${N + 1} type`
407
+ }, {
408
+ default: s(() => [
409
+ t(X)
410
+ ]),
411
+ _: 1
412
+ }, 8, ["aria-label"]),
413
+ t(le, null, {
414
+ default: s(() => [
415
+ t(O, {
416
+ value: "QUICK_REPLY",
417
+ disabled: !U(N, "QUICK_REPLY")
418
+ }, {
419
+ default: s(() => [...a[26] || (a[26] = [
420
+ l("Quick reply", -1)
421
+ ])]),
422
+ _: 1
423
+ }, 8, ["disabled"]),
424
+ t(O, {
425
+ value: "URL",
426
+ disabled: !U(N, "URL")
427
+ }, {
428
+ default: s(() => [...a[27] || (a[27] = [
429
+ l("Website", -1)
430
+ ])]),
431
+ _: 1
432
+ }, 8, ["disabled"]),
433
+ t(O, {
434
+ value: "PHONE_NUMBER",
435
+ disabled: !U(N, "PHONE_NUMBER")
436
+ }, {
437
+ default: s(() => [...a[28] || (a[28] = [
438
+ l("Phone number", -1)
439
+ ])]),
440
+ _: 1
441
+ }, 8, ["disabled"])
442
+ ]),
443
+ _: 2
444
+ }, 1024)
445
+ ]),
446
+ _: 2
447
+ }, 1032, ["model-value", "disabled", "onUpdate:modelValue"]),
448
+ t(g, {
449
+ type: "button",
450
+ variant: "ghost",
451
+ size: "icon",
452
+ class: "shrink-0",
453
+ "aria-label": `Remove button ${N + 1}`,
454
+ disabled: !!p.value || x.value,
455
+ onClick: (F) => f.value.buttons?.splice(N, 1)
456
+ }, {
457
+ default: s(() => [
458
+ t(c(Me), { class: "size-4" })
459
+ ]),
460
+ _: 1
461
+ }, 8, ["aria-label", "disabled", "onClick"])
462
+ ]),
463
+ e("div", tt, [
464
+ t(H, {
465
+ for: `wa-button-${N}`
466
+ }, {
467
+ default: s(() => [...a[29] || (a[29] = [
468
+ l("Button text", -1)
469
+ ])]),
470
+ _: 1
471
+ }, 8, ["for"]),
472
+ t(D, {
473
+ id: `wa-button-${N}`,
474
+ modelValue: b.text,
475
+ "onUpdate:modelValue": (F) => b.text = F,
476
+ maxlength: "25",
477
+ disabled: x.value,
478
+ required: ""
479
+ }, null, 8, ["id", "modelValue", "onUpdate:modelValue", "disabled"])
480
+ ]),
481
+ b.type === "URL" ? (o(), r("div", st, [
482
+ t(H, {
483
+ for: `wa-button-url-${N}`
484
+ }, {
485
+ default: s(() => [...a[30] || (a[30] = [
486
+ l("Website URL", -1)
487
+ ])]),
488
+ _: 1
489
+ }, 8, ["for"]),
490
+ t(D, {
491
+ id: `wa-button-url-${N}`,
492
+ modelValue: b.url,
493
+ "onUpdate:modelValue": (F) => b.url = F,
494
+ type: "url",
495
+ placeholder: "https://example.com",
496
+ disabled: x.value,
497
+ required: ""
498
+ }, null, 8, ["id", "modelValue", "onUpdate:modelValue", "disabled"]),
499
+ a[31] || (a[31] = e("p", { class: "text-xs text-muted-foreground" }, "Use a fixed HTTPS URL without variables.", -1))
500
+ ])) : k("", !0),
501
+ b.type === "PHONE_NUMBER" ? (o(), r("div", at, [
502
+ t(H, {
503
+ for: `wa-button-phone-${N}`
504
+ }, {
505
+ default: s(() => [...a[32] || (a[32] = [
506
+ l("Phone number", -1)
507
+ ])]),
508
+ _: 1
509
+ }, 8, ["for"]),
510
+ t(D, {
511
+ id: `wa-button-phone-${N}`,
512
+ modelValue: b.phoneNumber,
513
+ "onUpdate:modelValue": (F) => b.phoneNumber = F,
514
+ type: "tel",
515
+ placeholder: "+32470000000",
516
+ disabled: x.value,
517
+ required: ""
518
+ }, null, 8, ["id", "modelValue", "onUpdate:modelValue", "disabled"])
519
+ ])) : k("", !0)
520
+ ]))), 128))
521
+ ])
522
+ ])) : p.value ? (o(), r("div", lt, [
523
+ e("dl", ot, [
524
+ e("div", null, [
525
+ a[33] || (a[33] = e("dt", { class: "text-muted-foreground" }, "Status", -1)),
526
+ e("dd", nt, n(c(L)(p.value.status)), 1)
527
+ ]),
528
+ e("div", null, [
529
+ a[34] || (a[34] = e("dt", { class: "text-muted-foreground" }, "Category", -1)),
530
+ e("dd", dt, n(c(L)(p.value.category)), 1)
531
+ ]),
532
+ e("div", null, [
533
+ a[35] || (a[35] = e("dt", { class: "text-muted-foreground" }, "Language", -1)),
534
+ e("dd", ut, n(p.value.language), 1)
535
+ ]),
536
+ e("div", null, [
537
+ a[36] || (a[36] = e("dt", { class: "text-muted-foreground" }, "Quality", -1)),
538
+ e("dd", it, n(c(L)(p.value.quality)), 1)
539
+ ])
540
+ ]),
541
+ p.value.rejectionReason ? (o(), V(Y, {
542
+ key: 0,
543
+ variant: "destructive"
544
+ }, {
545
+ default: s(() => [
546
+ t(c(ee)),
547
+ t(G, null, {
548
+ default: s(() => [...a[37] || (a[37] = [
549
+ l("Meta review feedback", -1)
550
+ ])]),
551
+ _: 1
552
+ }),
553
+ t(se, null, {
554
+ default: s(() => [
555
+ l(n(p.value.rejectionReason), 1)
556
+ ]),
557
+ _: 1
558
+ })
559
+ ]),
560
+ _: 1
561
+ })) : k("", !0),
562
+ p.value.editable ? k("", !0) : (o(), r("p", rt, n(p.value.editReason || "This template uses a format that must be managed in Meta."), 1)),
563
+ $.canManage && p.value.editable && p.value.draft && !T.value ? (o(), V(g, {
564
+ key: 2,
565
+ type: "button",
566
+ variant: "outline",
567
+ onClick: a[7] || (a[7] = (b) => h.value = !0)
568
+ }, {
569
+ default: s(() => [
570
+ t(c(Ce), { class: "size-4" }),
571
+ a[38] || (a[38] = l("Edit template", -1))
572
+ ]),
573
+ _: 1
574
+ })) : k("", !0),
575
+ e("a", mt, [
576
+ a[39] || (a[39] = l("Open Meta template manager", -1)),
577
+ t(c(Ae), { class: "size-3.5" })
578
+ ])
579
+ ])) : k("", !0),
580
+ e("aside", pt, [
581
+ a[40] || (a[40] = e("h3", { class: "mb-3 text-xs font-medium uppercase tracking-wide text-muted-foreground" }, "Message preview", -1)),
582
+ e("div", ct, [
583
+ (o(!0), r(j, null, Q(P.value, (b, N) => (o(), r(j, { key: N }, [
584
+ b.type === "HEADER" && b.text ? (o(), r("p", vt, n(b.text), 1)) : b.type === "BODY" ? (o(), r("p", ft, n(b.text), 1)) : b.type === "FOOTER" ? (o(), r("p", gt, n(b.text), 1)) : b.type === "BUTTONS" ? (o(), r("div", bt, [
585
+ (o(!0), r(j, null, Q(b.buttons, (F, Te) => (o(), r("p", {
586
+ key: Te,
587
+ class: "break-words border-b px-4 py-3 text-center text-sm last:border-0"
588
+ }, n(F.text || "Button text"), 1))), 128))
589
+ ])) : (o(), r("div", xt, n(c(L)(b.format || b.type)) + " component · preview unavailable", 1))
590
+ ], 64))), 128))
591
+ ]),
592
+ a[41] || (a[41] = e("p", { class: "mt-3 text-xs leading-5 text-muted-foreground" }, "Preview only. Variables are filled by your sending application.", -1))
593
+ ])
594
+ ]),
595
+ h.value ? (o(), r("p", _t, n(p.value ? "Edits are sent to Meta and may affect existing Firebase automations. Keep the same variables and their meaning. Create a new template if its parameters need to change." : "Meta decides approval and may update the category. This template becomes usable after approval."), 1)) : k("", !0),
596
+ t(ce, { class: "mt-5 gap-2" }, {
597
+ default: s(() => [
598
+ t(g, {
599
+ type: "button",
600
+ variant: "outline",
601
+ disabled: x.value,
602
+ onClick: a[8] || (a[8] = (b) => q(!1))
603
+ }, {
604
+ default: s(() => [
605
+ l(n(h.value ? "Cancel" : "Close"), 1)
606
+ ]),
607
+ _: 1
608
+ }, 8, ["disabled"]),
609
+ h.value && $.canManage ? (o(), V(g, {
610
+ key: 0,
611
+ type: "submit",
612
+ disabled: x.value || !f.value.name.trim() || !f.value.bodyText.trim()
613
+ }, {
614
+ default: s(() => [
615
+ x.value ? (o(), V(c(Z), {
616
+ key: 0,
617
+ class: "size-4 animate-spin"
618
+ })) : k("", !0),
619
+ l(n(x.value ? "Submitting…" : "Submit to Meta"), 1)
620
+ ]),
621
+ _: 1
622
+ }, 8, ["disabled"])) : k("", !0)
623
+ ]),
624
+ _: 1
625
+ })
626
+ ], 32))
627
+ ]),
628
+ _: 1
629
+ })
630
+ ]),
631
+ _: 1
632
+ }, 8, ["open"]);
633
+ };
634
+ }
635
+ }), wt = { class: "min-w-0" }, ht = { class: "flex flex-wrap items-start justify-between gap-4" }, kt = { class: "space-y-2" }, Tt = { class: "space-y-2" }, $t = {
636
+ key: 0,
637
+ role: "status",
638
+ class: "mt-6 flex items-center justify-center gap-2 rounded-xl border py-20 text-sm text-muted-foreground"
639
+ }, Mt = {
640
+ key: 2,
641
+ class: "mt-6 rounded-xl border border-dashed px-6 py-16 text-center"
642
+ }, Ct = { class: "mt-3 font-medium" }, At = { class: "mx-auto mt-2 max-w-md text-sm leading-6 text-muted-foreground" }, St = {
643
+ key: 3,
644
+ class: "mt-6 overflow-hidden rounded-xl border"
645
+ }, Rt = ["onClick"], Vt = ["title"], Ut = { class: "mt-1 block truncate text-xs text-muted-foreground sm:hidden" }, Et = { class: "mt-1 hidden text-xs text-muted-foreground sm:block md:hidden" }, Nt = {
646
+ key: 4,
647
+ class: "mt-4 flex flex-wrap items-center justify-between gap-3 text-sm text-muted-foreground"
648
+ }, Lt = { class: "flex gap-2" }, Bt = /* @__PURE__ */ ie({
649
+ __name: "TemplatesPanel",
650
+ props: {
651
+ canManage: { type: Boolean }
652
+ },
653
+ setup($) {
654
+ const B = re(), m = w([]), M = w(!1), S = w(""), p = w(""), h = w("ALL"), u = w(""), x = w("ALL"), T = w(null), f = w(null), C = w([]), A = w(!1), y = w(null);
655
+ async function P(U = T.value) {
656
+ if (M.value) return !1;
657
+ M.value = !0, S.value = "";
658
+ try {
659
+ const v = {};
660
+ U && (v.after = U), u.value && (v.search = u.value), x.value !== "ALL" && (v.status = x.value);
661
+ const z = await B.get("/templates", { query: v });
662
+ return m.value = z.templates, f.value = z.nextCursor, T.value = U, !0;
663
+ } catch (v) {
664
+ return m.value = [], S.value = te(v, "Templates could not be loaded from Meta."), !1;
665
+ } finally {
666
+ M.value = !1;
667
+ }
668
+ }
669
+ async function d() {
670
+ M.value || (u.value = p.value.trim(), x.value = h.value, C.value = [], T.value = null, await P(null));
671
+ }
672
+ async function J() {
673
+ if (!f.value || M.value) return;
674
+ const U = T.value;
675
+ await P(f.value) && C.value.push(U);
676
+ }
677
+ async function W() {
678
+ !C.value.length || M.value || await P(C.value[C.value.length - 1]) && C.value.pop();
679
+ }
680
+ function K(U) {
681
+ y.value = U, A.value = !0;
682
+ }
683
+ return me(() => P(null)), (U, v) => {
684
+ const z = i("Button"), q = i("Label"), _ = i("Input"), a = i("SelectValue"), E = i("SelectTrigger"), R = i("SelectItem"), I = i("SelectContent"), G = i("Select"), se = i("AlertTitle"), Y = i("AlertDescription"), H = i("Alert"), D = i("TableHead"), X = i("TableRow"), ae = i("TableHeader"), O = i("TableCell"), le = i("Badge"), oe = i("TableBody"), ue = i("Table");
685
+ return o(), r("section", wt, [
686
+ e("div", ht, [
687
+ v[7] || (v[7] = e("div", null, [
688
+ e("h2", { class: "text-lg font-semibold" }, "Message templates"),
689
+ e("p", { class: "mt-1 text-sm leading-6 text-muted-foreground" }, "Templates are shared by all numbers in this business account. Changes are submitted to Meta for review.")
690
+ ], -1)),
691
+ $.canManage ? (o(), V(z, {
692
+ key: 0,
693
+ class: "shrink-0",
694
+ onClick: v[0] || (v[0] = (g) => K(null))
695
+ }, {
696
+ default: s(() => [
697
+ t(c(_e), { class: "size-4" }),
698
+ v[6] || (v[6] = l("New template", -1))
699
+ ]),
700
+ _: 1
701
+ })) : k("", !0)
702
+ ]),
703
+ e("form", {
704
+ class: "mt-5 grid items-end gap-3 sm:grid-cols-[minmax(0,1fr)_11rem_auto]",
705
+ onSubmit: be(d, ["prevent"])
706
+ }, [
707
+ e("div", kt, [
708
+ t(q, { for: "wa-template-search" }, {
709
+ default: s(() => [...v[8] || (v[8] = [
710
+ l("Search templates", -1)
711
+ ])]),
712
+ _: 1
713
+ }),
714
+ t(_, {
715
+ id: "wa-template-search",
716
+ modelValue: p.value,
717
+ "onUpdate:modelValue": v[1] || (v[1] = (g) => p.value = g),
718
+ type: "search",
719
+ placeholder: "Search name or message",
720
+ disabled: M.value
721
+ }, null, 8, ["modelValue", "disabled"])
722
+ ]),
723
+ e("div", Tt, [
724
+ t(q, { for: "wa-template-status" }, {
725
+ default: s(() => [...v[9] || (v[9] = [
726
+ l("Status", -1)
727
+ ])]),
728
+ _: 1
729
+ }),
730
+ t(G, {
731
+ modelValue: h.value,
732
+ "onUpdate:modelValue": v[2] || (v[2] = (g) => h.value = g),
733
+ disabled: M.value
734
+ }, {
735
+ default: s(() => [
736
+ t(E, { id: "wa-template-status" }, {
737
+ default: s(() => [
738
+ t(a)
739
+ ]),
740
+ _: 1
741
+ }),
742
+ t(I, null, {
743
+ default: s(() => [
744
+ t(R, { value: "ALL" }, {
745
+ default: s(() => [...v[10] || (v[10] = [
746
+ l("All statuses", -1)
747
+ ])]),
748
+ _: 1
749
+ }),
750
+ (o(), r(j, null, Q(["APPROVED", "PENDING", "REJECTED", "PAUSED", "DISABLED", "IN_APPEAL"], (g) => t(R, {
751
+ key: g,
752
+ value: g
753
+ }, {
754
+ default: s(() => [
755
+ l(n(c(L)(g)), 1)
756
+ ]),
757
+ _: 2
758
+ }, 1032, ["value"])), 64))
759
+ ]),
760
+ _: 1
761
+ })
762
+ ]),
763
+ _: 1
764
+ }, 8, ["modelValue", "disabled"])
765
+ ]),
766
+ t(z, {
767
+ type: "submit",
768
+ variant: "outline",
769
+ disabled: M.value
770
+ }, {
771
+ default: s(() => [
772
+ t(c(Se), { class: "size-4" }),
773
+ v[11] || (v[11] = l("Search", -1))
774
+ ]),
775
+ _: 1
776
+ }, 8, ["disabled"])
777
+ ], 32),
778
+ M.value ? (o(), r("div", $t, [
779
+ t(c(Z), { class: "size-4 animate-spin" }),
780
+ v[12] || (v[12] = l("Loading templates…", -1))
781
+ ])) : S.value ? (o(), V(H, {
782
+ key: 1,
783
+ variant: "destructive",
784
+ class: "mt-6"
785
+ }, {
786
+ default: s(() => [
787
+ t(c(ee)),
788
+ t(se, null, {
789
+ default: s(() => [...v[13] || (v[13] = [
790
+ l("Templates unavailable", -1)
791
+ ])]),
792
+ _: 1
793
+ }),
794
+ t(Y, { class: "space-y-3" }, {
795
+ default: s(() => [
796
+ e("p", null, n(S.value), 1),
797
+ t(z, {
798
+ size: "sm",
799
+ variant: "outline",
800
+ onClick: v[3] || (v[3] = (g) => P())
801
+ }, {
802
+ default: s(() => [...v[14] || (v[14] = [
803
+ l("Try again", -1)
804
+ ])]),
805
+ _: 1
806
+ })
807
+ ]),
808
+ _: 1
809
+ })
810
+ ]),
811
+ _: 1
812
+ })) : m.value.length ? (o(), r("div", St, [
813
+ t(ue, { class: "table-fixed" }, {
814
+ default: s(() => [
815
+ t(ae, null, {
816
+ default: s(() => [
817
+ t(X, null, {
818
+ default: s(() => [
819
+ t(D, null, {
820
+ default: s(() => [...v[15] || (v[15] = [
821
+ l("Template", -1)
822
+ ])]),
823
+ _: 1
824
+ }),
825
+ t(D, { class: "hidden w-36 sm:table-cell" }, {
826
+ default: s(() => [...v[16] || (v[16] = [
827
+ l("Category", -1)
828
+ ])]),
829
+ _: 1
830
+ }),
831
+ t(D, { class: "hidden w-24 md:table-cell" }, {
832
+ default: s(() => [...v[17] || (v[17] = [
833
+ l("Language", -1)
834
+ ])]),
835
+ _: 1
836
+ }),
837
+ t(D, { class: "w-28" }, {
838
+ default: s(() => [...v[18] || (v[18] = [
839
+ l("Status", -1)
840
+ ])]),
841
+ _: 1
842
+ }),
843
+ t(D, { class: "hidden w-32 lg:table-cell" }, {
844
+ default: s(() => [...v[19] || (v[19] = [
845
+ l("Quality", -1)
846
+ ])]),
847
+ _: 1
848
+ })
849
+ ]),
850
+ _: 1
851
+ })
852
+ ]),
853
+ _: 1
854
+ }),
855
+ t(oe, null, {
856
+ default: s(() => [
857
+ (o(!0), r(j, null, Q(m.value, (g) => (o(), V(X, {
858
+ key: g.id
859
+ }, {
860
+ default: s(() => [
861
+ t(O, null, {
862
+ default: s(() => [
863
+ e("button", {
864
+ type: "button",
865
+ class: "w-full rounded text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",
866
+ onClick: (ce) => K(g)
867
+ }, [
868
+ e("span", {
869
+ class: "block truncate font-medium underline-offset-4 hover:underline",
870
+ title: g.name
871
+ }, n(g.name), 9, Vt),
872
+ e("span", Ut, n(c(L)(g.category)) + " · " + n(g.language), 1),
873
+ e("span", Et, n(g.language), 1)
874
+ ], 8, Rt)
875
+ ]),
876
+ _: 2
877
+ }, 1024),
878
+ t(O, { class: "hidden sm:table-cell" }, {
879
+ default: s(() => [
880
+ l(n(c(L)(g.category)), 1)
881
+ ]),
882
+ _: 2
883
+ }, 1024),
884
+ t(O, { class: "hidden md:table-cell" }, {
885
+ default: s(() => [
886
+ l(n(g.language), 1)
887
+ ]),
888
+ _: 2
889
+ }, 1024),
890
+ t(O, null, {
891
+ default: s(() => [
892
+ t(le, {
893
+ variant: "outline",
894
+ class: xe(["max-w-full whitespace-normal break-words", g.status === "APPROVED" ? "text-emerald-700 dark:text-emerald-300" : g.status === "REJECTED" ? "text-destructive" : ""])
895
+ }, {
896
+ default: s(() => [
897
+ l(n(c(L)(g.status)), 1)
898
+ ]),
899
+ _: 2
900
+ }, 1032, ["class"])
901
+ ]),
902
+ _: 2
903
+ }, 1024),
904
+ t(O, { class: "hidden lg:table-cell text-muted-foreground" }, {
905
+ default: s(() => [
906
+ l(n(c(L)(g.quality)), 1)
907
+ ]),
908
+ _: 2
909
+ }, 1024)
910
+ ]),
911
+ _: 2
912
+ }, 1024))), 128))
913
+ ]),
914
+ _: 1
915
+ })
916
+ ]),
917
+ _: 1
918
+ })
919
+ ])) : (o(), r("div", Mt, [
920
+ t(c(ye), { class: "mx-auto size-7 text-muted-foreground" }),
921
+ e("h3", Ct, n(u.value || x.value !== "ALL" ? "No matching templates" : "No message templates yet"), 1),
922
+ e("p", At, n(u.value || x.value !== "ALL" ? "Try a different search or choose another status." : "Create your first text template here, or manage more advanced formats in Meta."), 1)
923
+ ])),
924
+ !S.value && (m.value.length || C.value.length) ? (o(), r("div", Nt, [
925
+ e("p", null, "Page " + n(C.value.length + 1) + " · " + n(m.value.length) + " templates", 1),
926
+ e("div", Lt, [
927
+ t(z, {
928
+ variant: "outline",
929
+ size: "sm",
930
+ disabled: !C.value.length || M.value,
931
+ onClick: W
932
+ }, {
933
+ default: s(() => [
934
+ t(c(Re), { class: "size-4" }),
935
+ v[20] || (v[20] = l("Previous", -1))
936
+ ]),
937
+ _: 1
938
+ }, 8, ["disabled"]),
939
+ t(z, {
940
+ variant: "outline",
941
+ size: "sm",
942
+ disabled: !f.value || M.value,
943
+ onClick: J
944
+ }, {
945
+ default: s(() => [
946
+ v[21] || (v[21] = l("Next", -1)),
947
+ t(c(Ve), { class: "size-4" })
948
+ ]),
949
+ _: 1
950
+ }, 8, ["disabled"])
951
+ ])
952
+ ])) : k("", !0),
953
+ t(yt, {
954
+ open: A.value,
955
+ template: y.value,
956
+ "can-manage": $.canManage,
957
+ "onUpdate:open": v[4] || (v[4] = (g) => A.value = g),
958
+ onSaved: v[5] || (v[5] = (g) => P())
959
+ }, null, 8, ["open", "template", "can-manage"])
960
+ ]);
961
+ };
962
+ }
963
+ }), Pt = { class: "min-w-0 space-y-6" }, It = { class: "flex flex-wrap items-start justify-between gap-4" }, Dt = { class: "w-40 space-y-2" }, zt = {
964
+ key: 0,
965
+ role: "status",
966
+ class: "flex items-center justify-center gap-2 rounded-xl border py-20 text-sm text-muted-foreground"
967
+ }, Ht = { class: "space-y-4" }, Ot = { class: "mt-1 text-sm text-muted-foreground" }, jt = {
968
+ key: 0,
969
+ class: "grid gap-4 sm:grid-cols-2"
970
+ }, qt = { class: "rounded-xl border p-5" }, Yt = { class: "flex items-center justify-between gap-3 text-sm text-muted-foreground" }, Ft = { class: "mt-3 text-3xl font-semibold tracking-tight" }, Qt = { class: "rounded-xl border p-5" }, Wt = { class: "flex items-center justify-between gap-3 text-sm text-muted-foreground" }, Kt = { class: "mt-3 text-3xl font-semibold tracking-tight" }, Jt = {
971
+ key: 1,
972
+ class: "rounded-xl border border-dashed p-5"
973
+ }, Gt = { class: "font-medium" }, Xt = { class: "mt-1 text-sm leading-6 text-muted-foreground" }, Zt = {
974
+ key: 2,
975
+ class: "text-sm text-muted-foreground"
976
+ }, es = { class: "space-y-4 border-t pt-6" }, ts = { class: "flex flex-wrap items-start justify-between gap-3" }, ss = {
977
+ key: 0,
978
+ class: "flex flex-wrap items-center justify-between gap-4 rounded-xl border p-5"
979
+ }, as = {
980
+ key: 1,
981
+ class: "rounded-xl border border-dashed p-6"
982
+ }, ls = { class: "mt-1 text-sm leading-6 text-muted-foreground" }, os = {
983
+ key: 2,
984
+ class: "rounded-xl border border-dashed p-8 text-center"
985
+ }, ns = { class: "mt-1 text-sm leading-6 text-muted-foreground" }, ds = {
986
+ key: 3,
987
+ class: "overflow-hidden rounded-xl border"
988
+ }, us = ["title"], is = { class: "mt-1 text-xs text-muted-foreground" }, rs = {
989
+ key: 4,
990
+ class: "text-sm text-muted-foreground"
991
+ }, ms = /* @__PURE__ */ ie({
992
+ __name: "InsightsPanel",
993
+ props: {
994
+ canManage: { type: Boolean }
995
+ },
996
+ setup($) {
997
+ const B = re(), { config: m } = Be(), M = String(c(m)?.defaultDays || "30"), S = w(["7", "30", "90"].includes(M) ? M : "30"), p = w(null), h = w(!1), u = w(""), x = w(!1), T = w(!1), f = w("");
998
+ let C = 0;
999
+ async function A() {
1000
+ const P = ++C;
1001
+ h.value = !0, u.value = "";
1002
+ try {
1003
+ const d = await B.get("/insights", { query: { days: Number(S.value) } });
1004
+ P === C && (p.value = d);
1005
+ } catch (d) {
1006
+ P === C && (u.value = te(d, "Insights could not be loaded from Meta."));
1007
+ } finally {
1008
+ P === C && (h.value = !1);
1009
+ }
1010
+ }
1011
+ async function y() {
1012
+ if (!T.value) {
1013
+ T.value = !0, f.value = "";
1014
+ try {
1015
+ await B.post("/insights/enable", { body: { confirm: !0 } }), x.value = !1, we.success("Template insights enabled"), await A();
1016
+ } catch (P) {
1017
+ f.value = te(P, "Template insights could not be enabled.");
1018
+ } finally {
1019
+ T.value = !1;
1020
+ }
1021
+ }
1022
+ }
1023
+ return ge(S, A), me(A), $e(() => {
1024
+ C++;
1025
+ }), (P, d) => {
1026
+ const J = i("Label"), W = i("SelectValue"), K = i("SelectTrigger"), U = i("SelectItem"), v = i("SelectContent"), z = i("Select"), q = i("AlertTitle"), _ = i("Button"), a = i("AlertDescription"), E = i("Alert"), R = i("Badge"), I = i("TableHead"), G = i("TableRow"), se = i("TableHeader"), Y = i("TableCell"), H = i("TableBody"), D = i("Table"), X = i("ResponsiveModalTitle"), ae = i("ResponsiveModalDescription"), O = i("ResponsiveModalHeader"), le = i("ResponsiveModalFooter"), oe = i("ResponsiveModalScrollContent"), ue = i("ResponsiveModal");
1027
+ return o(), r("section", Pt, [
1028
+ e("div", It, [
1029
+ d[8] || (d[8] = e("div", null, [
1030
+ e("h2", { class: "text-lg font-semibold" }, "Messaging insights"),
1031
+ e("p", { class: "mt-1 text-sm leading-6 text-muted-foreground" }, "Aggregated activity reported by Meta. Recent results may take time to appear.")
1032
+ ], -1)),
1033
+ e("div", Dt, [
1034
+ t(J, {
1035
+ for: "wa-insights-period",
1036
+ class: "sr-only"
1037
+ }, {
1038
+ default: s(() => [...d[4] || (d[4] = [
1039
+ l("Insights period", -1)
1040
+ ])]),
1041
+ _: 1
1042
+ }),
1043
+ t(z, {
1044
+ modelValue: S.value,
1045
+ "onUpdate:modelValue": d[0] || (d[0] = (g) => S.value = g)
1046
+ }, {
1047
+ default: s(() => [
1048
+ t(K, { id: "wa-insights-period" }, {
1049
+ default: s(() => [
1050
+ t(W)
1051
+ ]),
1052
+ _: 1
1053
+ }),
1054
+ t(v, null, {
1055
+ default: s(() => [
1056
+ t(U, { value: "7" }, {
1057
+ default: s(() => [...d[5] || (d[5] = [
1058
+ l("Last 7 days", -1)
1059
+ ])]),
1060
+ _: 1
1061
+ }),
1062
+ t(U, { value: "30" }, {
1063
+ default: s(() => [...d[6] || (d[6] = [
1064
+ l("Last 30 days", -1)
1065
+ ])]),
1066
+ _: 1
1067
+ }),
1068
+ t(U, { value: "90" }, {
1069
+ default: s(() => [...d[7] || (d[7] = [
1070
+ l("Last 90 days", -1)
1071
+ ])]),
1072
+ _: 1
1073
+ })
1074
+ ]),
1075
+ _: 1
1076
+ })
1077
+ ]),
1078
+ _: 1
1079
+ }, 8, ["modelValue"])
1080
+ ])
1081
+ ]),
1082
+ h.value ? (o(), r("div", zt, [
1083
+ t(c(Z), { class: "size-4 animate-spin" }),
1084
+ d[9] || (d[9] = l("Loading insights…", -1))
1085
+ ])) : u.value ? (o(), V(E, {
1086
+ key: 1,
1087
+ variant: "destructive"
1088
+ }, {
1089
+ default: s(() => [
1090
+ t(c(ee)),
1091
+ t(q, null, {
1092
+ default: s(() => [...d[10] || (d[10] = [
1093
+ l("Insights unavailable", -1)
1094
+ ])]),
1095
+ _: 1
1096
+ }),
1097
+ t(a, { class: "space-y-3" }, {
1098
+ default: s(() => [
1099
+ e("p", null, n(u.value), 1),
1100
+ t(_, {
1101
+ variant: "outline",
1102
+ size: "sm",
1103
+ onClick: A
1104
+ }, {
1105
+ default: s(() => [...d[11] || (d[11] = [
1106
+ l("Try again", -1)
1107
+ ])]),
1108
+ _: 1
1109
+ })
1110
+ ]),
1111
+ _: 1
1112
+ })
1113
+ ]),
1114
+ _: 1
1115
+ })) : p.value ? (o(), r(j, { key: 2 }, [
1116
+ e("section", Ht, [
1117
+ e("div", null, [
1118
+ d[12] || (d[12] = e("h3", { class: "font-medium" }, "Selected phone number", -1)),
1119
+ e("p", Ot, n(p.value.phoneNumber) + " · " + n(c(fe)(p.value.start, "UTC")) + " – " + n(c(fe)(p.value.end - 1, "UTC")) + " · UTC", 1)
1120
+ ]),
1121
+ p.value.messages.state !== "unavailable" && p.value.messages.data ? (o(), r("div", jt, [
1122
+ e("div", qt, [
1123
+ e("p", Yt, [
1124
+ d[13] || (d[13] = l("Messages sent", -1)),
1125
+ t(c(Ue), { class: "size-4" })
1126
+ ]),
1127
+ e("p", Ft, n(c(ne)(p.value.messages.data.sent)), 1)
1128
+ ]),
1129
+ e("div", Qt, [
1130
+ e("p", Wt, [
1131
+ d[14] || (d[14] = l("Messages delivered", -1)),
1132
+ t(c(Ee), { class: "size-4" })
1133
+ ]),
1134
+ e("p", Kt, n(c(ne)(p.value.messages.data.delivered)), 1)
1135
+ ])
1136
+ ])) : (o(), r("div", Jt, [
1137
+ e("p", Gt, "Message volume " + n(p.value.messages.state === "empty" ? "has no data" : "unavailable"), 1),
1138
+ e("p", Xt, n(p.value.messages.reason || "Meta has not returned message volume for this phone and period."), 1)
1139
+ ])),
1140
+ p.value.messages.state === "empty" && p.value.messages.data ? (o(), r("p", Zt, n(p.value.messages.reason || "No message activity was reported for this period."), 1)) : k("", !0)
1141
+ ]),
1142
+ e("section", es, [
1143
+ e("div", ts, [
1144
+ d[16] || (d[16] = e("div", null, [
1145
+ e("h3", { class: "font-medium" }, "Template performance"),
1146
+ e("p", { class: "mt-1 text-sm leading-6 text-muted-foreground" }, "Across all phone numbers in this WhatsApp Business account.")
1147
+ ], -1)),
1148
+ t(R, { variant: "outline" }, {
1149
+ default: s(() => [...d[15] || (d[15] = [
1150
+ l("Account-wide", -1)
1151
+ ])]),
1152
+ _: 1
1153
+ })
1154
+ ]),
1155
+ p.value.enabled !== !0 && p.value.canEnable && $.canManage ? (o(), r("div", ss, [
1156
+ d[18] || (d[18] = e("div", { class: "max-w-xl" }, [
1157
+ e("p", { class: "font-medium" }, "Enable template insights"),
1158
+ e("p", { class: "mt-1 text-sm leading-6 text-muted-foreground" }, "Meta requires an account-level opt-in before sharing template performance. This setting cannot be reversed.")
1159
+ ], -1)),
1160
+ t(_, {
1161
+ variant: "outline",
1162
+ onClick: d[1] || (d[1] = (g) => x.value = !0)
1163
+ }, {
1164
+ default: s(() => [...d[17] || (d[17] = [
1165
+ l("Review and enable", -1)
1166
+ ])]),
1167
+ _: 1
1168
+ })
1169
+ ])) : k("", !0),
1170
+ p.value.templates.state === "unavailable" ? (o(), r("div", as, [
1171
+ t(c(pe), { class: "size-5 text-muted-foreground" }),
1172
+ d[19] || (d[19] = e("h4", { class: "mt-3 font-medium" }, "Template insights unavailable", -1)),
1173
+ e("p", ls, n(p.value.templates.reason || "Meta has not made these metrics available for this account."), 1)
1174
+ ])) : p.value.templates.data?.templates.length ? (o(), r("div", ds, [
1175
+ t(D, null, {
1176
+ default: s(() => [
1177
+ t(se, null, {
1178
+ default: s(() => [
1179
+ t(G, null, {
1180
+ default: s(() => [
1181
+ t(I, { class: "min-w-48" }, {
1182
+ default: s(() => [...d[21] || (d[21] = [
1183
+ l("Template", -1)
1184
+ ])]),
1185
+ _: 1
1186
+ }),
1187
+ t(I, { class: "text-right" }, {
1188
+ default: s(() => [...d[22] || (d[22] = [
1189
+ l("Sent", -1)
1190
+ ])]),
1191
+ _: 1
1192
+ }),
1193
+ t(I, { class: "text-right" }, {
1194
+ default: s(() => [...d[23] || (d[23] = [
1195
+ l("Delivered", -1)
1196
+ ])]),
1197
+ _: 1
1198
+ }),
1199
+ t(I, { class: "text-right" }, {
1200
+ default: s(() => [...d[24] || (d[24] = [
1201
+ l("Read", -1)
1202
+ ])]),
1203
+ _: 1
1204
+ }),
1205
+ t(I, { class: "text-right" }, {
1206
+ default: s(() => [...d[25] || (d[25] = [
1207
+ l("Clicks", -1)
1208
+ ])]),
1209
+ _: 1
1210
+ })
1211
+ ]),
1212
+ _: 1
1213
+ })
1214
+ ]),
1215
+ _: 1
1216
+ }),
1217
+ t(H, null, {
1218
+ default: s(() => [
1219
+ (o(!0), r(j, null, Q(p.value.templates.data.templates, (g) => (o(), V(G, {
1220
+ key: g.id
1221
+ }, {
1222
+ default: s(() => [
1223
+ t(Y, null, {
1224
+ default: s(() => [
1225
+ e("p", {
1226
+ class: "max-w-72 truncate font-medium",
1227
+ title: g.name
1228
+ }, n(g.name), 9, us),
1229
+ e("p", is, n(g.language), 1)
1230
+ ]),
1231
+ _: 2
1232
+ }, 1024),
1233
+ t(Y, { class: "whitespace-nowrap text-right tabular-nums" }, {
1234
+ default: s(() => [
1235
+ l(n(c(ne)(g.sent)), 1)
1236
+ ]),
1237
+ _: 2
1238
+ }, 1024),
1239
+ t(Y, { class: "whitespace-nowrap text-right tabular-nums" }, {
1240
+ default: s(() => [
1241
+ l(n(c(ne)(g.delivered)), 1)
1242
+ ]),
1243
+ _: 2
1244
+ }, 1024),
1245
+ t(Y, { class: "whitespace-nowrap text-right tabular-nums" }, {
1246
+ default: s(() => [
1247
+ l(n(c(ne)(g.read)), 1)
1248
+ ]),
1249
+ _: 2
1250
+ }, 1024),
1251
+ t(Y, { class: "whitespace-nowrap text-right tabular-nums" }, {
1252
+ default: s(() => [
1253
+ l(n(c(ne)(g.clicked)), 1)
1254
+ ]),
1255
+ _: 2
1256
+ }, 1024)
1257
+ ]),
1258
+ _: 2
1259
+ }, 1024))), 128))
1260
+ ]),
1261
+ _: 1
1262
+ })
1263
+ ]),
1264
+ _: 1
1265
+ })
1266
+ ])) : (o(), r("div", os, [
1267
+ t(c(pe), { class: "mx-auto size-6 text-muted-foreground" }),
1268
+ d[20] || (d[20] = e("h4", { class: "mt-3 font-medium" }, "No template performance for this period", -1)),
1269
+ e("p", ns, n(p.value.templates.reason || "Metrics will appear when Meta reports activity for your templates."), 1)
1270
+ ])),
1271
+ p.value.templates.data?.truncated ? (o(), r("p", rs, "Meta returned a limited set of templates. These results do not represent every template in the account.")) : k("", !0),
1272
+ d[26] || (d[26] = e("p", { class: "text-xs leading-5 text-muted-foreground" }, "“Not available” means Meta did not return that metric. Availability depends on template type, account eligibility, and Meta’s reporting rules.", -1))
1273
+ ])
1274
+ ], 64)) : k("", !0),
1275
+ t(ue, {
1276
+ open: x.value,
1277
+ "onUpdate:open": d[3] || (d[3] = (g) => !T.value && (x.value = g))
1278
+ }, {
1279
+ default: s(() => [
1280
+ t(oe, { class: "sm:max-w-lg" }, {
1281
+ default: s(() => [
1282
+ t(O, null, {
1283
+ default: s(() => [
1284
+ t(X, null, {
1285
+ default: s(() => [...d[27] || (d[27] = [
1286
+ l("Enable template insights for this account?", -1)
1287
+ ])]),
1288
+ _: 1
1289
+ }),
1290
+ t(ae, null, {
1291
+ default: s(() => [...d[28] || (d[28] = [
1292
+ l("This opts your entire WhatsApp Business account into Meta’s template performance reporting. Meta does not allow template insights to be disabled after activation.", -1)
1293
+ ])]),
1294
+ _: 1
1295
+ })
1296
+ ]),
1297
+ _: 1
1298
+ }),
1299
+ f.value ? (o(), V(E, {
1300
+ key: 0,
1301
+ variant: "destructive",
1302
+ class: "mt-5"
1303
+ }, {
1304
+ default: s(() => [
1305
+ t(c(ee)),
1306
+ t(q, null, {
1307
+ default: s(() => [...d[29] || (d[29] = [
1308
+ l("Could not enable insights", -1)
1309
+ ])]),
1310
+ _: 1
1311
+ }),
1312
+ t(a, null, {
1313
+ default: s(() => [
1314
+ l(n(f.value), 1)
1315
+ ]),
1316
+ _: 1
1317
+ })
1318
+ ]),
1319
+ _: 1
1320
+ })) : k("", !0),
1321
+ t(le, { class: "mt-5 gap-2" }, {
1322
+ default: s(() => [
1323
+ t(_, {
1324
+ variant: "outline",
1325
+ disabled: T.value,
1326
+ onClick: d[2] || (d[2] = (g) => x.value = !1)
1327
+ }, {
1328
+ default: s(() => [...d[30] || (d[30] = [
1329
+ l("Cancel", -1)
1330
+ ])]),
1331
+ _: 1
1332
+ }, 8, ["disabled"]),
1333
+ t(_, {
1334
+ disabled: T.value,
1335
+ onClick: y
1336
+ }, {
1337
+ default: s(() => [
1338
+ T.value ? (o(), V(c(Z), {
1339
+ key: 0,
1340
+ class: "size-4 animate-spin"
1341
+ })) : k("", !0),
1342
+ d[31] || (d[31] = l("Enable account insights", -1))
1343
+ ]),
1344
+ _: 1
1345
+ }, 8, ["disabled"])
1346
+ ]),
1347
+ _: 1
1348
+ })
1349
+ ]),
1350
+ _: 1
1351
+ })
1352
+ ]),
1353
+ _: 1
1354
+ }, 8, ["open"])
1355
+ ]);
1356
+ };
1357
+ }
1358
+ }), ps = { class: "space-y-5" }, cs = {
1359
+ key: 0,
1360
+ role: "status",
1361
+ class: "flex items-center justify-center gap-2 rounded-xl border py-20 text-sm text-muted-foreground"
1362
+ }, vs = {
1363
+ key: 2,
1364
+ class: "grid gap-5 md:grid-cols-2"
1365
+ }, fs = { class: "min-w-0 rounded-xl border p-5" }, gs = {
1366
+ key: 0,
1367
+ class: "mt-4 space-y-4 text-sm"
1368
+ }, bs = { class: "mt-1 font-medium" }, xs = { class: "mt-1 break-words" }, _s = { class: "grid grid-cols-2 gap-4" }, ys = { class: "mt-1" }, ws = { class: "mt-1 break-words" }, hs = { class: "mt-1 break-all font-mono text-xs" }, ks = {
1369
+ key: 1,
1370
+ class: "mt-3 text-sm leading-6 text-muted-foreground"
1371
+ }, Ts = { class: "min-w-0 rounded-xl border p-5" }, $s = {
1372
+ key: 0,
1373
+ class: "mt-4 grid grid-cols-2 gap-4 text-sm"
1374
+ }, Ms = { class: "col-span-2" }, Cs = { class: "mt-1 break-words font-medium" }, As = { class: "mt-1 break-words" }, Ss = { class: "mt-1 break-words" }, Rs = { class: "mt-1 break-words" }, Vs = { class: "mt-1" }, Us = { class: "col-span-2" }, Es = { class: "mt-1 break-all font-mono text-xs" }, Ns = {
1375
+ key: 1,
1376
+ class: "mt-3 text-sm leading-6 text-muted-foreground"
1377
+ }, Ls = { class: "min-w-0 rounded-xl border p-5" }, Bs = { class: "mt-4 text-sm" }, Ps = { class: "mt-1 font-medium" }, Is = {
1378
+ key: 0,
1379
+ class: "mt-4 divide-y border-t text-sm"
1380
+ }, Ds = { class: "text-muted-foreground" }, zs = {
1381
+ key: 1,
1382
+ class: "mt-3 text-sm leading-6 text-muted-foreground"
1383
+ }, Hs = { class: "min-w-0 rounded-xl border p-5" }, Os = {
1384
+ key: 0,
1385
+ class: "mt-4 space-y-4 text-sm"
1386
+ }, js = { class: "mt-1 whitespace-pre-wrap break-words" }, qs = { key: 0 }, Ys = { class: "mt-1 whitespace-pre-wrap break-words" }, Fs = { class: "mt-1" }, Qs = { class: "mt-1 break-words" }, Ws = { class: "mt-1 whitespace-pre-wrap break-words" }, Ks = { key: 1 }, Js = {
1387
+ key: 1,
1388
+ class: "mt-3 text-sm leading-6 text-muted-foreground"
1389
+ }, Gs = /* @__PURE__ */ ie({
1390
+ __name: "AccountPanel",
1391
+ setup($) {
1392
+ const B = re(), m = w(null), M = w(!1), S = w("");
1393
+ async function p() {
1394
+ M.value = !0, S.value = "";
1395
+ try {
1396
+ m.value = await B.get("/overview");
1397
+ } catch (h) {
1398
+ S.value = te(h, "Account details could not be loaded from Meta.");
1399
+ } finally {
1400
+ M.value = !1;
1401
+ }
1402
+ }
1403
+ return me(p), (h, u) => {
1404
+ const x = i("AlertTitle"), T = i("Button"), f = i("AlertDescription"), C = i("Alert");
1405
+ return o(), r("section", ps, [
1406
+ u[25] || (u[25] = e("div", null, [
1407
+ e("h2", { class: "text-lg font-semibold" }, "Account and phone number"),
1408
+ e("p", { class: "mt-1 text-sm leading-6 text-muted-foreground" }, "Current business information, quality, and sending availability reported by Meta.")
1409
+ ], -1)),
1410
+ M.value ? (o(), r("div", cs, [
1411
+ t(c(Z), { class: "size-4 animate-spin" }),
1412
+ u[0] || (u[0] = l("Loading account details…", -1))
1413
+ ])) : S.value ? (o(), V(C, {
1414
+ key: 1,
1415
+ variant: "destructive"
1416
+ }, {
1417
+ default: s(() => [
1418
+ t(c(ee)),
1419
+ t(x, null, {
1420
+ default: s(() => [...u[1] || (u[1] = [
1421
+ l("Account unavailable", -1)
1422
+ ])]),
1423
+ _: 1
1424
+ }),
1425
+ t(f, { class: "space-y-3" }, {
1426
+ default: s(() => [
1427
+ e("p", null, n(S.value), 1),
1428
+ t(T, {
1429
+ variant: "outline",
1430
+ size: "sm",
1431
+ onClick: p
1432
+ }, {
1433
+ default: s(() => [...u[2] || (u[2] = [
1434
+ l("Try again", -1)
1435
+ ])]),
1436
+ _: 1
1437
+ })
1438
+ ]),
1439
+ _: 1
1440
+ })
1441
+ ]),
1442
+ _: 1
1443
+ })) : m.value ? (o(), r("div", vs, [
1444
+ e("section", fs, [
1445
+ u[8] || (u[8] = e("h3", { class: "font-semibold" }, "Selected phone number", -1)),
1446
+ m.value.phone.data ? (o(), r("dl", gs, [
1447
+ e("div", null, [
1448
+ u[3] || (u[3] = e("dt", { class: "text-muted-foreground" }, "Phone number", -1)),
1449
+ e("dd", bs, n(m.value.phone.data.displayPhoneNumber || "Not available"), 1)
1450
+ ]),
1451
+ e("div", null, [
1452
+ u[4] || (u[4] = e("dt", { class: "text-muted-foreground" }, "Verified name", -1)),
1453
+ e("dd", xs, n(m.value.phone.data.verifiedName || "Not available"), 1)
1454
+ ]),
1455
+ e("div", _s, [
1456
+ e("div", null, [
1457
+ u[5] || (u[5] = e("dt", { class: "text-muted-foreground" }, "Quality rating", -1)),
1458
+ e("dd", ys, n(c(L)(m.value.phone.data.qualityRating)), 1)
1459
+ ]),
1460
+ e("div", null, [
1461
+ u[6] || (u[6] = e("dt", { class: "text-muted-foreground" }, "Verification", -1)),
1462
+ e("dd", ws, n(c(L)(m.value.phone.data.verificationStatus)), 1)
1463
+ ])
1464
+ ]),
1465
+ e("div", null, [
1466
+ u[7] || (u[7] = e("dt", { class: "text-muted-foreground" }, "Phone number ID", -1)),
1467
+ e("dd", hs, n(m.value.phone.data.id), 1)
1468
+ ])
1469
+ ])) : (o(), r("p", ks, n(m.value.phone.reason || "Phone details are not available."), 1))
1470
+ ]),
1471
+ e("section", Ts, [
1472
+ u[15] || (u[15] = e("h3", { class: "font-semibold" }, "Business account", -1)),
1473
+ m.value.account.data ? (o(), r("dl", $s, [
1474
+ e("div", Ms, [
1475
+ u[9] || (u[9] = e("dt", { class: "text-muted-foreground" }, "Name", -1)),
1476
+ e("dd", Cs, n(m.value.account.data.name || "Not available"), 1)
1477
+ ]),
1478
+ e("div", null, [
1479
+ u[10] || (u[10] = e("dt", { class: "text-muted-foreground" }, "Account status", -1)),
1480
+ e("dd", As, n(c(L)(m.value.account.data.status)), 1)
1481
+ ]),
1482
+ e("div", null, [
1483
+ u[11] || (u[11] = e("dt", { class: "text-muted-foreground" }, "Review status", -1)),
1484
+ e("dd", Ss, n(c(L)(m.value.account.data.reviewStatus)), 1)
1485
+ ]),
1486
+ e("div", null, [
1487
+ u[12] || (u[12] = e("dt", { class: "text-muted-foreground" }, "Business verification", -1)),
1488
+ e("dd", Rs, n(c(L)(m.value.account.data.verificationStatus)), 1)
1489
+ ]),
1490
+ e("div", null, [
1491
+ u[13] || (u[13] = e("dt", { class: "text-muted-foreground" }, "Currency", -1)),
1492
+ e("dd", Vs, n(m.value.account.data.currency || "Not available"), 1)
1493
+ ]),
1494
+ e("div", Us, [
1495
+ u[14] || (u[14] = e("dt", { class: "text-muted-foreground" }, "Account ID", -1)),
1496
+ e("dd", Es, n(m.value.account.data.id), 1)
1497
+ ])
1498
+ ])) : (o(), r("p", Ns, n(m.value.account.reason || "Business account details are not available."), 1))
1499
+ ]),
1500
+ e("section", Ls, [
1501
+ u[17] || (u[17] = e("h3", { class: "font-semibold" }, "Sending health", -1)),
1502
+ m.value.health.data ? (o(), r(j, { key: 0 }, [
1503
+ e("dl", Bs, [
1504
+ u[16] || (u[16] = e("dt", { class: "text-muted-foreground" }, "Can send messages", -1)),
1505
+ e("dd", Ps, n(c(L)(m.value.health.data.canSendMessage)), 1)
1506
+ ]),
1507
+ m.value.health.data.entities.length ? (o(), r("ul", Is, [
1508
+ (o(!0), r(j, null, Q(m.value.health.data.entities, (A, y) => (o(), r("li", {
1509
+ key: `${A.id}-${y}`,
1510
+ class: "flex flex-wrap justify-between gap-2 py-3"
1511
+ }, [
1512
+ e("span", Ds, n(c(L)(A.type)), 1),
1513
+ e("span", null, n(c(L)(A.canSendMessage)), 1)
1514
+ ]))), 128))
1515
+ ])) : k("", !0)
1516
+ ], 64)) : (o(), r("p", zs, n(m.value.health.reason || "Meta has not returned sending health for this account."), 1))
1517
+ ]),
1518
+ e("section", Hs, [
1519
+ u[24] || (u[24] = e("h3", { class: "font-semibold" }, "Business profile", -1)),
1520
+ m.value.profile.data ? (o(), r("dl", Os, [
1521
+ e("div", null, [
1522
+ u[18] || (u[18] = e("dt", { class: "text-muted-foreground" }, "About", -1)),
1523
+ e("dd", js, n(m.value.profile.data.about || "Not provided"), 1)
1524
+ ]),
1525
+ m.value.profile.data.description ? (o(), r("div", qs, [
1526
+ u[19] || (u[19] = e("dt", { class: "text-muted-foreground" }, "Description", -1)),
1527
+ e("dd", Ys, n(m.value.profile.data.description), 1)
1528
+ ])) : k("", !0),
1529
+ e("div", null, [
1530
+ u[20] || (u[20] = e("dt", { class: "text-muted-foreground" }, "Industry", -1)),
1531
+ e("dd", Fs, n(c(L)(m.value.profile.data.vertical)), 1)
1532
+ ]),
1533
+ e("div", null, [
1534
+ u[21] || (u[21] = e("dt", { class: "text-muted-foreground" }, "Email", -1)),
1535
+ e("dd", Qs, n(m.value.profile.data.email || "Not provided"), 1)
1536
+ ]),
1537
+ e("div", null, [
1538
+ u[22] || (u[22] = e("dt", { class: "text-muted-foreground" }, "Address", -1)),
1539
+ e("dd", Ws, n(m.value.profile.data.address || "Not provided"), 1)
1540
+ ]),
1541
+ m.value.profile.data.websites.length ? (o(), r("div", Ks, [
1542
+ u[23] || (u[23] = e("dt", { class: "text-muted-foreground" }, "Websites", -1)),
1543
+ (o(!0), r(j, null, Q(m.value.profile.data.websites, (A) => (o(), r("dd", {
1544
+ key: A,
1545
+ class: "mt-1 break-all"
1546
+ }, n(A), 1))), 128))
1547
+ ])) : k("", !0)
1548
+ ])) : (o(), r("p", Js, n(m.value.profile.reason || "The business profile is not available."), 1))
1549
+ ])
1550
+ ])) : k("", !0)
1551
+ ]);
1552
+ };
1553
+ }
1554
+ }), Xs = { class: "mx-auto flex w-full min-w-0 max-w-7xl flex-1 flex-col px-4 py-6 sm:px-6 sm:py-10 lg:px-8" }, Zs = { class: "flex flex-wrap items-start justify-between gap-4" }, ea = { class: "flex flex-wrap items-center gap-3" }, ta = {
1555
+ key: 0,
1556
+ class: "mt-1 text-sm font-medium"
1557
+ }, sa = { class: "ml-2 font-normal text-muted-foreground" }, aa = {
1558
+ key: 0,
1559
+ class: "mt-8 rounded-xl border border-dashed p-8 text-center"
1560
+ }, la = {
1561
+ key: 2,
1562
+ role: "status",
1563
+ class: "flex items-center justify-center gap-2 py-24 text-sm text-muted-foreground"
1564
+ }, oa = {
1565
+ key: 3,
1566
+ class: "mt-8 rounded-xl border border-dashed p-8 text-center sm:p-12"
1567
+ }, ra = /* @__PURE__ */ ie({
1568
+ __name: "Overview",
1569
+ setup($) {
1570
+ const B = re(), { hasPermission: m } = Pe();
1571
+ Ie(() => []);
1572
+ const M = de(() => m("view-whatsapp")), S = de(() => m("manage-whatsapp-templates")), p = de(() => m("manage-whatsapp-insights")), h = w(null), u = w(!1), x = w(""), T = w("templates"), f = w(0);
1573
+ async function C() {
1574
+ if (M.value) {
1575
+ u.value = !0, x.value = "";
1576
+ try {
1577
+ h.value = await B.get("/connection"), f.value++;
1578
+ } catch (A) {
1579
+ x.value = te(A, "The WhatsApp connection could not be loaded.");
1580
+ } finally {
1581
+ u.value = !1;
1582
+ }
1583
+ }
1584
+ }
1585
+ return me(C), (A, y) => {
1586
+ const P = i("Badge"), d = i("Button"), J = i("AlertTitle"), W = i("AlertDescription"), K = i("Alert"), U = i("TabsTrigger"), v = i("TabsList"), z = i("TabsContent"), q = i("Tabs");
1587
+ return o(), r("main", Xs, [
1588
+ e("header", Zs, [
1589
+ e("div", null, [
1590
+ e("div", ea, [
1591
+ y[2] || (y[2] = e("h1", { class: "text-2xl font-semibold tracking-tight sm:text-3xl" }, "WhatsApp Business", -1)),
1592
+ h.value?.connected ? (o(), V(P, {
1593
+ key: 0,
1594
+ variant: "outline",
1595
+ class: "gap-1.5"
1596
+ }, {
1597
+ default: s(() => [...y[1] || (y[1] = [
1598
+ e("span", { class: "size-1.5 rounded-full bg-emerald-500" }, null, -1),
1599
+ l(" Connected ", -1)
1600
+ ])]),
1601
+ _: 1
1602
+ })) : k("", !0)
1603
+ ]),
1604
+ y[3] || (y[3] = e("p", { class: "mt-2 text-sm leading-6 text-muted-foreground" }, " Manage your message templates and follow their performance. ", -1)),
1605
+ h.value?.connected ? (o(), r("p", ta, [
1606
+ l(n(h.value.verifiedName || "Connected business") + " ", 1),
1607
+ e("span", sa, n(h.value.displayPhoneNumber), 1)
1608
+ ])) : k("", !0)
1609
+ ]),
1610
+ M.value ? (o(), V(d, {
1611
+ key: 0,
1612
+ variant: "outline",
1613
+ size: "sm",
1614
+ disabled: u.value,
1615
+ onClick: C
1616
+ }, {
1617
+ default: s(() => [
1618
+ t(c(Ne), {
1619
+ class: xe(["size-4", { "animate-spin": u.value }])
1620
+ }, null, 8, ["class"]),
1621
+ y[4] || (y[4] = l(" Refresh ", -1))
1622
+ ]),
1623
+ _: 1
1624
+ }, 8, ["disabled"])) : k("", !0)
1625
+ ]),
1626
+ M.value ? x.value ? (o(), V(K, {
1627
+ key: 1,
1628
+ variant: "destructive",
1629
+ class: "mt-8"
1630
+ }, {
1631
+ default: s(() => [
1632
+ t(c(ee)),
1633
+ t(J, null, {
1634
+ default: s(() => [...y[7] || (y[7] = [
1635
+ l("Connection unavailable", -1)
1636
+ ])]),
1637
+ _: 1
1638
+ }),
1639
+ t(W, null, {
1640
+ default: s(() => [
1641
+ l(n(x.value), 1)
1642
+ ]),
1643
+ _: 1
1644
+ })
1645
+ ]),
1646
+ _: 1
1647
+ })) : u.value && !h.value ? (o(), r("div", la, [
1648
+ t(c(Z), { class: "size-4 animate-spin" }),
1649
+ y[8] || (y[8] = l(" Loading your connection… ", -1))
1650
+ ])) : h.value && !h.value.connected ? (o(), r("section", oa, [
1651
+ t(c(ve), { class: "mx-auto size-7 text-muted-foreground" }),
1652
+ y[9] || (y[9] = e("h2", { class: "mt-4 font-semibold" }, "Select your WhatsApp integration", -1)),
1653
+ y[10] || (y[10] = e("p", { class: "mx-auto mt-2 max-w-lg text-sm leading-6 text-muted-foreground" }, " Add a WhatsApp Business account in your Studio project integrations, then select it in this module’s settings. A Studio administrator can set this up for you. ", -1))
1654
+ ])) : h.value?.connected ? (o(), V(q, {
1655
+ key: 4,
1656
+ modelValue: T.value,
1657
+ "onUpdate:modelValue": y[0] || (y[0] = (_) => T.value = _),
1658
+ class: "mt-7 min-w-0"
1659
+ }, {
1660
+ default: s(() => [
1661
+ t(v, { class: "mb-5 grid h-auto w-full grid-cols-3 sm:w-auto sm:self-start" }, {
1662
+ default: s(() => [
1663
+ t(U, {
1664
+ value: "templates",
1665
+ class: "gap-2 px-2 py-2 sm:px-4"
1666
+ }, {
1667
+ default: s(() => [
1668
+ t(c(ye), { class: "hidden size-4 sm:block" }),
1669
+ y[11] || (y[11] = l("Templates", -1))
1670
+ ]),
1671
+ _: 1
1672
+ }),
1673
+ t(U, {
1674
+ value: "insights",
1675
+ class: "gap-2 px-2 py-2 sm:px-4"
1676
+ }, {
1677
+ default: s(() => [
1678
+ t(c(pe), { class: "hidden size-4 sm:block" }),
1679
+ y[12] || (y[12] = l("Insights", -1))
1680
+ ]),
1681
+ _: 1
1682
+ }),
1683
+ t(U, {
1684
+ value: "account",
1685
+ class: "gap-2 px-2 py-2 sm:px-4"
1686
+ }, {
1687
+ default: s(() => [
1688
+ t(c(ve), { class: "hidden size-4 sm:block" }),
1689
+ y[13] || (y[13] = l("Account", -1))
1690
+ ]),
1691
+ _: 1
1692
+ })
1693
+ ]),
1694
+ _: 1
1695
+ }),
1696
+ t(z, { value: "templates" }, {
1697
+ default: s(() => [
1698
+ h.value.connected && T.value === "templates" ? (o(), V(Bt, {
1699
+ key: f.value,
1700
+ "can-manage": S.value
1701
+ }, null, 8, ["can-manage"])) : k("", !0)
1702
+ ]),
1703
+ _: 1
1704
+ }),
1705
+ t(z, { value: "insights" }, {
1706
+ default: s(() => [
1707
+ h.value.connected && T.value === "insights" ? (o(), V(ms, {
1708
+ key: f.value,
1709
+ "can-manage": p.value
1710
+ }, null, 8, ["can-manage"])) : k("", !0)
1711
+ ]),
1712
+ _: 1
1713
+ }),
1714
+ t(z, { value: "account" }, {
1715
+ default: s(() => [
1716
+ h.value.connected && T.value === "account" ? (o(), V(Gs, { key: f.value })) : k("", !0)
1717
+ ]),
1718
+ _: 1
1719
+ })
1720
+ ]),
1721
+ _: 1
1722
+ }, 8, ["modelValue"])) : k("", !0) : (o(), r("section", aa, [
1723
+ t(c(Le), { class: "mx-auto size-6 text-muted-foreground" }),
1724
+ y[5] || (y[5] = e("h2", { class: "mt-3 font-medium" }, "You cannot view this WhatsApp account", -1)),
1725
+ y[6] || (y[6] = e("p", { class: "mt-2 text-sm text-muted-foreground" }, "Ask a Studio administrator for the View WhatsApp permission.", -1))
1726
+ ]))
1727
+ ]);
1728
+ };
1729
+ }
1730
+ });
1731
+ export {
1732
+ ra as default
1733
+ };