@webx-ui/module-notifications 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,2347 @@
1
+ import { computed as _, provide as vt, inject as ft, ref as V, defineComponent as R, openBlock as d, createBlock as x, unref as e, withCtx as c, createVNode as h, createTextVNode as k, toDisplayString as w, createElementBlock as j, Fragment as B, createElementVNode as E, createCommentVNode as M, isRef as Pe, renderList as Q, onMounted as Ue, onBeforeUnmount as mt, createSlots as ht, useModel as _e, mergeModels as ke, watch as He, withModifiers as Ke } from "vue";
2
+ import { useRoute as st, useRouter as Ee, onBeforeRouteLeave as bt } from "vue-router";
3
+ import { useLocales as Le, localizedValue as Ge, WxCard as yt, WxText as F, WxAlert as L, useModal as Be, WxDialog as De, WxFormItem as ue, WxSelect as ce, WxSpace as pe, WxButton as U, createModal as Ie, confirm as we, WxSkeleton as ot, WxBadge as X, WxActionBar as gt, toast as O, WxLink as wt, WxEmpty as _t, WxCheckbox as kt, WxInput as je, WxAction as rt, WxIcon as de, WxSegmented as xt, WxTable as Je, WxSwitch as Qe, mustacheCompletions as $t, mustacheProblems as Ct, WxCodeEditor as Tt, WxTooltip as St } from "@webx-ui/core";
4
+ import { useAdmin as ne, useTranslate as q, useErrorText as xe, provideHistorySubject as Wt, useBodyKeys as Vt, WxScreenHead as Nt, WxScreen as At, WxSaveState as zt, WxRelationsField as jt, rowMenuWidth as Xe, WxListScreen as Ot, WxRowMenu as Ye, WxDate as Ze } from "@webx-ui/module-admin";
5
+ import Ft from "mustache";
6
+ const Mt = "notifications";
7
+ function Pt(l) {
8
+ const t = new URLSearchParams();
9
+ for (const [s, a] of Object.entries(l))
10
+ a == null || a === "" || t.set(s, typeof a == "boolean" ? a ? "1" : "0" : String(a));
11
+ const i = t.toString();
12
+ return i === "" ? "" : `?${i}`;
13
+ }
14
+ function ve(l) {
15
+ const t = `${l.apiPath}/${Mt}`, i = (a) => a.data, s = (a) => a === null ? t : `${t}/channels/${a}`;
16
+ return {
17
+ meta: () => l.http.get(`${t}/meta`).then(i),
18
+ channels: (a = {}) => {
19
+ const o = new URLSearchParams();
20
+ a.trashed && o.set("trashed", "1"), a.event && o.set("event", a.event);
21
+ const n = o.toString();
22
+ return l.http.get(`${t}/channels${n === "" ? "" : `?${n}`}`);
23
+ },
24
+ get: (a) => l.http.get(`${t}/channels/${a}`).then(i),
25
+ create: (a) => l.http.post(`${t}/channels`, { values: a }).then(i),
26
+ save: (a, o) => l.http.put(`${t}/channels/${a}`, { values: o }).then(i),
27
+ remove: (a) => l.http.delete(`${t}/channels/${a}`).then(() => {
28
+ }),
29
+ restore: (a) => l.http.post(`${t}/channels/${a}/restore`, {}).then(i),
30
+ purge: (a) => l.http.delete(`${t}/channels/${a}/purge`).then(() => {
31
+ }),
32
+ copy: (a, o) => l.http.post(`${t}/channels/${a}/copy`, o ? { name: o } : {}).then(i),
33
+ test: (a, o, n) => l.http.post(`${s(a)}/test`, {
34
+ values: o,
35
+ ...n ? { recipient: n } : {}
36
+ }).then((u) => u.data.results),
37
+ preview: (a, o, n) => l.http.post(`${s(a)}/preview`, { values: o, locale: n }).then(i),
38
+ check: (a, o) => l.http.post(`${t}/check`, { values: o, ...a ? { channel: a } : {} }).then(i),
39
+ findRecipients: ({ provider: a, channel: o, token: n }) => l.http.post(
40
+ `${t}/find-recipients`,
41
+ { provider: a, ...o ? { channel: o } : {}, ...n ? { token: n } : {} }
42
+ ).then(i),
43
+ administrators: () => l.http.get(`${t}/administrators`).then(i),
44
+ deliveries: (a = {}) => l.http.get(`${t}/deliveries${Pt(a)}`),
45
+ retry: (a) => l.http.post(`${t}/deliveries/${a}/retry`, {}).then(i)
46
+ };
47
+ }
48
+ const ut = /* @__PURE__ */ Symbol("wx-notifications-channel");
49
+ function Ut(l, t, i) {
50
+ const s = {
51
+ meta: l,
52
+ values: t,
53
+ id: i,
54
+ provider: _(
55
+ () => l.value?.providers.find((a) => a.key === t.value.provider) ?? null
56
+ ),
57
+ event: _(() => l.value?.events.find((a) => a.key === t.value.event) ?? null)
58
+ };
59
+ return vt(ut, s), s;
60
+ }
61
+ function $e() {
62
+ return ft(ut, null) ?? {
63
+ meta: V(null),
64
+ values: V({}),
65
+ id: V(null),
66
+ provider: _(() => null),
67
+ event: _(() => null)
68
+ };
69
+ }
70
+ const Et = {
71
+ module: {
72
+ title: "Notifications",
73
+ channel: "Channel",
74
+ statuses: {
75
+ queued: "Queued",
76
+ sent: "Sent",
77
+ failed: "Failed",
78
+ skipped: "Skipped"
79
+ },
80
+ reasons: {
81
+ channel_deleted: "The channel is deleted",
82
+ channel_disabled: "The channel is switched off",
83
+ wrong_event: "The channel is for another event",
84
+ provider_missing: "The provider is not installed",
85
+ no_recipients: "The channel has no recipients",
86
+ no_address: "The event brought no address",
87
+ admin_deleted: "The administrator is deleted",
88
+ admin_inactive: "The administrator is switched off"
89
+ }
90
+ },
91
+ screen: {
92
+ "any-event": "Any event"
93
+ },
94
+ panel: {
95
+ channels: "Channels",
96
+ log: "Log",
97
+ bin: "Bin",
98
+ new: "New channel",
99
+ untitled: "Untitled channel",
100
+ "new-title": "New channel",
101
+ "new-help": "The kind is chosen once. An event is optional: with one, the editor knows its variables and only that event offers the channel.",
102
+ "new-provider": "Kind",
103
+ "new-event": "For the event",
104
+ "new-create": "Continue",
105
+ "any-event": "Any event",
106
+ "event-undeclared": "Event not declared",
107
+ "event-undeclared-text": "No installed module declares “:event” any more. The channel works as one for any event.",
108
+ "provider-undeclared": "Provider not installed",
109
+ "provider-undeclared-text": "The provider “:provider” is not installed on the site: the channel sends nothing.",
110
+ unreadable: "The channel's secrets cannot be read: the application key has changed. Enter them again.",
111
+ recipients: "Recipients: :count",
112
+ "never-sent": "Nothing sent yet",
113
+ off: "Off",
114
+ enable: "Enabled",
115
+ enabled: "Switched on.",
116
+ disabled: "Switched off.",
117
+ edit: "Edit",
118
+ copy: "Make a copy",
119
+ copied: "A copy is made, switched off: “:name”.",
120
+ "copied-from": "The secrets were copied from channel #:id. Replace them if this channel needs another bot or server.",
121
+ delete: "Delete",
122
+ "delete-title": "Delete “:title”?",
123
+ "delete-text": "The channel goes to the bin and sends nothing. The modules that chose it keep it, and it comes back to them when it is restored.",
124
+ deleted: "The channel is in the bin.",
125
+ restore: "Restore",
126
+ restored: "The channel is back.",
127
+ purge: "Delete for good",
128
+ "purge-title": "Delete “:title” for good?",
129
+ "purge-text": "The channel disappears from every module that chose it. Its lines in the log stay, without a link to it.",
130
+ purged: "The channel is deleted for good.",
131
+ cancel: "Cancel",
132
+ save: "Save",
133
+ saved: "Saved.",
134
+ "saved-warning": "Saved, but look: :warning",
135
+ "save-failed": "Not saved: look at the fields marked in red.",
136
+ "leave-title": "Leave without saving?",
137
+ "leave-text": "The changes to this channel will be lost.",
138
+ leave: "Leave",
139
+ "empty-channels-text": "A channel is where notifications go and how they read: a Telegram bot and its chats, or e-mail and its addresses.",
140
+ "empty-bin": "The bin is empty",
141
+ environment: "The site runs as “:environment”: notifications are sent all the same. Switch channels off on a copy of the site.",
142
+ "mode-after-response": "The site has no queue worker: notifications are sent right after the page answers, without retries in the background.",
143
+ "secret-set": "Set. Type a new one to replace it.",
144
+ forget: "Forget :field",
145
+ forgotten: ":field will be forgotten on save.",
146
+ check: "Check the connection",
147
+ "check-ok": "Connection works.",
148
+ test: "Send a test",
149
+ "test-title": "Send a test",
150
+ "test-help": "Sent now, past the queue, with the example values of the event — even through a channel that is switched off. What the form has is used, saved or not.",
151
+ "test-to": "To",
152
+ "test-everybody": "Everybody on the list",
153
+ "test-send": "Send",
154
+ "test-sent": "Sent to :recipient.",
155
+ "test-failed": "Not sent to :recipient: :error",
156
+ "test-none": "The channel has no recipients to send a test to.",
157
+ preview: "Preview",
158
+ "preview-help": "The message as it goes out, on the example values of the event.",
159
+ "preview-no-event": "For any event: the variables are empty here.",
160
+ "preview-subject": "Subject",
161
+ "preview-empty": "The message is empty.",
162
+ "preview-truncated": "Longer than :limit characters: Telegram gets it as plain text, cut to fit.",
163
+ "preview-unknown": "Empty in this message: :names.",
164
+ "preview-refused": "The template cannot be drawn:",
165
+ variables: "Variables",
166
+ "variables-help": "A click puts it where the cursor is; type {{ to see them in the editor.",
167
+ "variables-none": "A channel for any event knows no variables. Choose an event to get its list, or type the names it gives.",
168
+ "variable-list": "list of :fields",
169
+ "problem-unclosed": "The section {{#:name}} is not closed: end it with {{/:name}}.",
170
+ "problem-stray": "{{/:name}} closes a section that was never opened.",
171
+ "problem-unknown": "Not a variable of this event: :names.",
172
+ "problem-refused": ":tag is not available in a message template.",
173
+ "problem-broken": "A tag is not closed: end it with }}.",
174
+ "hint-variable": "variable",
175
+ "hint-list": "list",
176
+ "hint-field": "field of :list",
177
+ "hint-section": "shown when :name has a value",
178
+ "hint-inverted": "shown when :name is empty",
179
+ "hint-close": "closes :name",
180
+ "hint-comment": "a comment, never printed",
181
+ "hint-example": "Example: :example",
182
+ "add-chat": "Add a chat",
183
+ "chat-id": "Chat id",
184
+ "chat-label": "Label",
185
+ "find-chats": "Find chats",
186
+ "find-title": "Chats the bot has seen",
187
+ "find-help": "Write to the bot, or add it to a group and write there, then search again.",
188
+ "find-add": "Add the chosen",
189
+ "find-token": "Type the bot token first.",
190
+ "find-added": "Chats added: :count.",
191
+ "chat-private": "Private",
192
+ "chat-group": "Group",
193
+ "chat-supergroup": "Supergroup",
194
+ "chat-channel": "Channel",
195
+ addressee: "From the event: :label",
196
+ "add-admin": "Add an administrator",
197
+ "add-email": "Add an address",
198
+ "admin-unknown": "Administrator #:id",
199
+ remove: "Remove",
200
+ "no-recipients": "No recipients yet.",
201
+ "column-when": "When",
202
+ "column-channel": "Channel",
203
+ "column-recipient": "Recipient",
204
+ "column-status": "Status",
205
+ "column-attempts": "Attempts",
206
+ "all-statuses": "Any status",
207
+ "all-channels": "Any channel",
208
+ "with-tests": "Tests too",
209
+ "test-mark": "Test",
210
+ "cut-mark": "Cut",
211
+ "log-empty": "Nothing sent yet.",
212
+ retry: "Send again",
213
+ retried: "Queued again.",
214
+ "open-subject": "Open",
215
+ "unknown-variables": "Empty variables: :names",
216
+ "channel-gone": "deleted",
217
+ filters: "Filters",
218
+ "pick-channels": "Choose channels",
219
+ "set-up-channels": "Set up channels"
220
+ },
221
+ errors: {
222
+ "template-unclosed": "The section {{#:section}} is not closed: end it with {{/:section}}.",
223
+ "template-unexpected": "{{/:section}} closes a section that was never opened.",
224
+ "template-tag": "The tag {{:tag is not closed: end it with }}.",
225
+ "template-name": "{{:name}} is not a variable name: lowercase letters, digits and _, one dot at most.",
226
+ "template-partial": "Partials ({{>name}}) are not available in a message template.",
227
+ "template-delimiters": "Changing the delimiters ({{=<% %>=}}) is not available in a message template.",
228
+ "template-pragma": "Pragmas and blocks ({{%…}}, {{$…}}) are not available in a message template."
229
+ }
230
+ }, et = /* @__PURE__ */ new WeakSet();
231
+ function H() {
232
+ try {
233
+ const { i18n: l } = ne();
234
+ et.has(l) || (l.defaults("webx-notifications", Et), et.add(l));
235
+ } catch {
236
+ }
237
+ }
238
+ class J extends Error {
239
+ constructor(t, i = {}) {
240
+ super(t), this.key = t, this.replace = i, this.name = "TemplateRefusal";
241
+ }
242
+ key;
243
+ replace;
244
+ }
245
+ const Lt = /^[a-z0-9_]+(\.[a-z0-9_]+)?$/;
246
+ function Bt(l) {
247
+ return l.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
248
+ }
249
+ function tt(l) {
250
+ return l.replace(/[\r\n]+/g, " ");
251
+ }
252
+ function Dt(l) {
253
+ return l === "telegram" ? Bt : (t) => t;
254
+ }
255
+ function It(l) {
256
+ try {
257
+ return Ft.parse(l, ["{{", "}}"]);
258
+ } catch (t) {
259
+ const i = t instanceof Error ? t.message : String(t), s = /section "([^"]*)"/.exec(i)?.[1] ?? "";
260
+ if (i.startsWith("Unopened section"))
261
+ throw new J("template-unexpected", { section: s });
262
+ if (i.startsWith("Unclosed section"))
263
+ throw new J("template-unclosed", { section: s });
264
+ const a = Number(/at (\d+)/.exec(i)?.[1] ?? l.lastIndexOf("{{")), o = l.slice(a).replace(/^\{\{\{?[#^/!&>=]?/, "").trim();
265
+ throw new J("template-tag", { tag: o });
266
+ }
267
+ }
268
+ function ct(l) {
269
+ for (const t of l) {
270
+ const [i, s] = t;
271
+ if (i === ">") throw new J("template-partial");
272
+ if (i === "=") throw new J("template-delimiters");
273
+ if (i === "text" || i === "!") continue;
274
+ const a = s.trim();
275
+ if (a.startsWith("<")) throw new J("template-partial");
276
+ if (a.startsWith("%") || a.startsWith("$")) throw new J("template-pragma");
277
+ if (!Lt.test(a)) throw new J("template-name", { name: a });
278
+ t[4] && ct(t[4]);
279
+ }
280
+ }
281
+ function Rt(l) {
282
+ const t = {};
283
+ for (const [i, s] of Object.entries(l)) {
284
+ if (!i.includes(".")) {
285
+ t[i] = s;
286
+ continue;
287
+ }
288
+ const [a, ...o] = i.split("."), n = a, u = t[n];
289
+ (u === void 0 || I(u)) && (t[n] = { ...I(u) ? u : {}, [o.join(".")]: s });
290
+ }
291
+ return t;
292
+ }
293
+ function I(l) {
294
+ return typeof l == "object" && l !== null && !Array.isArray(l);
295
+ }
296
+ function nt(l) {
297
+ return l == null || l === !1 || l === "" || l === "0" || l === 0 ? !0 : Array.isArray(l) ? l.length === 0 : I(l) ? Object.keys(l).length === 0 : !1;
298
+ }
299
+ function qt(l, t) {
300
+ const [i, ...s] = t.split(".");
301
+ let a;
302
+ for (let o = l.length - 1; o >= 0; o--) {
303
+ const n = l[o];
304
+ if (I(n) && Object.prototype.hasOwnProperty.call(n, i)) {
305
+ a = n[i];
306
+ break;
307
+ }
308
+ }
309
+ for (const o of s) {
310
+ if (a === "" || a === void 0) return a;
311
+ a = I(a) && Object.prototype.hasOwnProperty.call(a, o) ? a[o] : "";
312
+ }
313
+ return a;
314
+ }
315
+ function Ht(l) {
316
+ return typeof l == "string" ? l : typeof l == "number" ? String(l) : l === !0 ? "1" : "";
317
+ }
318
+ function Oe(l, t, i) {
319
+ let s = "";
320
+ for (const a of l) {
321
+ const [o, n] = a;
322
+ if (o === "text") {
323
+ s += n;
324
+ continue;
325
+ }
326
+ if (o === "!") continue;
327
+ const u = qt(t, n.trim());
328
+ if (o === "name" || o === "&") {
329
+ s += I(u) || Array.isArray(u) ? "" : i(Ht(u));
330
+ continue;
331
+ }
332
+ const W = a[4] ?? [];
333
+ if (o === "#" && !nt(u))
334
+ for (const $ of Array.isArray(u) ? u : [u])
335
+ s += Oe(W, [...t, $], i);
336
+ o === "^" && nt(u) && (s += Oe(W, t, i));
337
+ }
338
+ return s;
339
+ }
340
+ function Fe(l, t = [], i = []) {
341
+ for (const s of l) {
342
+ const [a, o] = s;
343
+ if (a === "text" || a === "!") continue;
344
+ const n = o.trim();
345
+ i.push({ name: n, sections: t }), a === "#" && Fe(s[4] ?? [], [...t, n], i), a === "^" && Fe(s[4] ?? [], t, i);
346
+ }
347
+ return i;
348
+ }
349
+ function at(l, t) {
350
+ const [i, ...s] = t.split(".");
351
+ for (const a of [...l].reverse()) {
352
+ if (!I(a) || !Object.prototype.hasOwnProperty.call(a, i)) continue;
353
+ let o = a[i];
354
+ for (const n of s) {
355
+ if (!I(o) || !Object.prototype.hasOwnProperty.call(o, n)) return null;
356
+ o = o[n];
357
+ }
358
+ return o ?? null;
359
+ }
360
+ return null;
361
+ }
362
+ function Kt(l, t, i) {
363
+ const s = [l];
364
+ for (const a of i) {
365
+ const o = at(s, a);
366
+ Array.isArray(o) ? s.push(Object.assign({}, ...o.filter(I))) : I(o) && s.push(o);
367
+ }
368
+ return at(s, t) !== null;
369
+ }
370
+ function Gt(l, t, i) {
371
+ for (const s of [...i].reverse()) {
372
+ const a = l.variables.find((o) => o.name === s);
373
+ if (a && a.fields.length > 0 && a.fields.some((o) => o.name === t))
374
+ return !0;
375
+ }
376
+ return l.variables.some(
377
+ (s) => s.name === t || s.name.endsWith(".*") && t.startsWith(s.name.slice(0, -1))
378
+ );
379
+ }
380
+ function lt(l, t, i, s) {
381
+ const a = It(l);
382
+ ct(a);
383
+ const o = Rt(t), n = /* @__PURE__ */ new Set();
384
+ for (const u of Fe(a))
385
+ !Kt(o, u.name, u.sections) && !s?.(u.name, u.sections) && n.add(u.name);
386
+ return { text: Oe(a, [o], i), unknown: [...n] };
387
+ }
388
+ function Jt(l) {
389
+ const t = {};
390
+ for (const i of l?.variables ?? [])
391
+ i.name.endsWith(".*") || (t[i.name] = i.example);
392
+ return t;
393
+ }
394
+ function Qt(l) {
395
+ return new DOMParser().parseFromString(`<body>${l}</body>`, "text/html").body.textContent ?? "";
396
+ }
397
+ function Xt(l) {
398
+ const t = Dt(l.provider), i = l.event ?? null, s = i === null ? void 0 : ($, S) => Gt(i, $, S), a = lt(l.template, l.values, t, s);
399
+ let o = null, n = a.unknown;
400
+ if (l.hasSubject) {
401
+ const $ = lt(l.subject ?? "", l.values, tt, s);
402
+ o = tt($.text).trim(), n = [.../* @__PURE__ */ new Set([...n, ...$.unknown])];
403
+ }
404
+ const u = l.provider === "telegram" ? Qt(a.text) : a.text, W = l.limit ?? null;
405
+ if (W !== null && [...u].length > W) {
406
+ const $ = `${[...u].slice(0, W - 1).join("")}…`;
407
+ return { subject: o, body: t($), plain: $, truncated: !0, unknown: n };
408
+ }
409
+ return { subject: o, body: a.text, plain: u, truncated: !1, unknown: n };
410
+ }
411
+ const Yt = /* @__PURE__ */ new Set([
412
+ "b",
413
+ "strong",
414
+ "i",
415
+ "em",
416
+ "u",
417
+ "ins",
418
+ "s",
419
+ "strike",
420
+ "del",
421
+ "a",
422
+ "code",
423
+ "pre",
424
+ "blockquote",
425
+ "tg-spoiler",
426
+ "span"
427
+ ]);
428
+ function Me(l, t, i) {
429
+ for (const s of Array.from(l.childNodes)) {
430
+ if (s.nodeType === Node.TEXT_NODE) {
431
+ t.appendChild(i.createTextNode(s.textContent ?? ""));
432
+ continue;
433
+ }
434
+ if (!(s instanceof Element)) continue;
435
+ const a = s.tagName.toLowerCase();
436
+ if (!Yt.has(a) || a === "span" && !s.classList.contains("tg-spoiler")) {
437
+ Me(s, t, i);
438
+ continue;
439
+ }
440
+ const o = i.createElement(a === "tg-spoiler" ? "span" : a);
441
+ if ((a === "tg-spoiler" || a === "span") && (o.className = "tg-spoiler"), a === "a") {
442
+ const n = s.getAttribute("href") ?? "";
443
+ /^(https?:|tg:)/i.test(n) && (o.setAttribute("href", n), o.setAttribute("target", "_blank"), o.setAttribute("rel", "noopener noreferrer"));
444
+ }
445
+ Me(s, o, i), t.appendChild(o);
446
+ }
447
+ }
448
+ function Zt(l) {
449
+ const t = new DOMParser().parseFromString(`<body>${l}</body>`, "text/html"), i = document.implementation.createHTMLDocument(""), s = i.createElement("div");
450
+ return Me(t.body, s, i), s.innerHTML;
451
+ }
452
+ const en = {
453
+ key: 0,
454
+ class: "wx-notifications-preview__chat"
455
+ }, tn = ["innerHTML"], nn = {
456
+ key: 1,
457
+ class: "wx-notifications-preview__bubble"
458
+ }, an = {
459
+ key: 1,
460
+ class: "wx-notifications-preview__letter"
461
+ }, ln = { class: "wx-notifications-preview__subject" }, sn = { class: "wx-notifications-preview__body" }, on = /* @__PURE__ */ R({
462
+ name: "WxNotificationsPreview",
463
+ __name: "MessagePreview",
464
+ setup(l) {
465
+ H();
466
+ const t = q("webx-notifications"), i = $e(), s = Le(), a = _(() => s.active.value || s.list.value[0]?.code || ""), o = _(() => {
467
+ const b = i.provider.value;
468
+ if (b === null) return null;
469
+ const y = i.values.value;
470
+ try {
471
+ return {
472
+ message: Xt({
473
+ provider: b.key,
474
+ template: Ge(y.template, a.value),
475
+ subject: Ge(y.subject, a.value),
476
+ hasSubject: b.subject,
477
+ limit: b.limit,
478
+ values: Jt(i.event.value),
479
+ event: i.event.value
480
+ })
481
+ };
482
+ } catch (A) {
483
+ if (A instanceof J)
484
+ return { refusal: t(`errors.${A.key}`, A.replace) };
485
+ throw A;
486
+ }
487
+ }), n = _(
488
+ () => o.value !== null && "message" in o.value ? o.value.message : null
489
+ ), u = _(
490
+ () => o.value !== null && "refusal" in o.value ? o.value.refusal : null
491
+ ), W = _(
492
+ () => t("panel.preview-unknown", {
493
+ names: (n.value?.unknown ?? []).map((b) => "{{" + b + "}}").join(", ")
494
+ })
495
+ ), $ = _(() => i.provider.value?.key === "telegram"), S = _(
496
+ () => n.value === null || n.value.truncated ? "" : Zt(n.value.body)
497
+ );
498
+ return (b, y) => (d(), x(e(yt), {
499
+ title: e(t)("panel.preview"),
500
+ class: "wx-notifications-preview"
501
+ }, {
502
+ default: c(() => [
503
+ h(e(F), {
504
+ size: "sm",
505
+ tone: "muted"
506
+ }, {
507
+ default: c(() => [
508
+ k(w(e(i).event.value ? e(t)("panel.preview-help") : e(t)("panel.preview-no-event")), 1)
509
+ ]),
510
+ _: 1
511
+ }),
512
+ u.value ? (d(), x(e(L), {
513
+ key: 0,
514
+ type: "danger",
515
+ variant: "soft",
516
+ title: e(t)("panel.preview-refused"),
517
+ description: u.value
518
+ }, null, 8, ["title", "description"])) : n.value ? (d(), j(B, { key: 1 }, [
519
+ $.value ? (d(), j("div", en, [
520
+ n.value.truncated ? (d(), j("div", nn, w(n.value.plain), 1)) : (d(), j("div", {
521
+ key: 0,
522
+ class: "wx-notifications-preview__bubble",
523
+ innerHTML: S.value
524
+ }, null, 8, tn))
525
+ ])) : (d(), j("div", an, [
526
+ E("div", ln, [
527
+ h(e(F), {
528
+ size: "sm",
529
+ tone: "muted"
530
+ }, {
531
+ default: c(() => [
532
+ k(w(e(t)("panel.preview-subject")), 1)
533
+ ]),
534
+ _: 1
535
+ }),
536
+ h(e(F), { weight: "medium" }, {
537
+ default: c(() => [
538
+ k(w(n.value.subject || "—"), 1)
539
+ ]),
540
+ _: 1
541
+ })
542
+ ]),
543
+ E("div", sn, w(n.value.body), 1)
544
+ ])),
545
+ n.value.plain.trim() === "" ? (d(), x(e(F), {
546
+ key: 2,
547
+ size: "sm",
548
+ tone: "muted"
549
+ }, {
550
+ default: c(() => [
551
+ k(w(e(t)("panel.preview-empty")), 1)
552
+ ]),
553
+ _: 1
554
+ })) : M("", !0),
555
+ n.value.truncated ? (d(), x(e(L), {
556
+ key: 3,
557
+ type: "warning",
558
+ variant: "soft",
559
+ description: e(t)("panel.preview-truncated", { limit: String(e(i).provider.value?.limit ?? "") })
560
+ }, null, 8, ["description"])) : M("", !0),
561
+ n.value.unknown.length > 0 && e(i).event.value ? (d(), x(e(F), {
562
+ key: 4,
563
+ size: "sm",
564
+ tone: "muted"
565
+ }, {
566
+ default: c(() => [
567
+ k(w(W.value), 1)
568
+ ]),
569
+ _: 1
570
+ })) : M("", !0)
571
+ ], 64)) : M("", !0)
572
+ ]),
573
+ _: 1
574
+ }, 8, ["title"]));
575
+ }
576
+ }), Y = (l, t) => {
577
+ const i = l.__vccOpts || l;
578
+ for (const [s, a] of t)
579
+ i[s] = a;
580
+ return i;
581
+ }, rn = /* @__PURE__ */ Y(on, [["__scopeId", "data-v-9ca19a74"]]), un = /* @__PURE__ */ R({
582
+ name: "WxNotificationsTestDialog",
583
+ __name: "TestDialog",
584
+ props: {
585
+ channel: { default: null },
586
+ values: {},
587
+ recipients: { default: () => [] }
588
+ },
589
+ setup(l) {
590
+ const t = l, { open: i, dismiss: s } = Be(), a = ve(ne());
591
+ H();
592
+ const o = q("webx-notifications"), n = xe(), u = V(""), W = V(!1), $ = V(null), S = V(null), b = _(() => [
593
+ { value: "", label: o("panel.test-everybody") },
594
+ ...t.recipients
595
+ ]);
596
+ async function y() {
597
+ W.value = !0, S.value = null;
598
+ try {
599
+ $.value = await a.test(t.channel, t.values, u.value === "" ? null : u.value);
600
+ } catch (z) {
601
+ const C = z.body;
602
+ S.value = C?.errors ? Object.values(C.errors).flat().join(" ") : n(z);
603
+ } finally {
604
+ W.value = !1;
605
+ }
606
+ }
607
+ function A(z) {
608
+ const C = z.label ? `${z.label} (${z.recipient})` : z.recipient;
609
+ return z.status === "sent" ? o("panel.test-sent", { recipient: C }) : o("panel.test-failed", {
610
+ recipient: C,
611
+ error: z.error ?? (z.reason ? o(`module.reasons.${z.reason}`) : z.status)
612
+ });
613
+ }
614
+ return (z, C) => (d(), x(e(De), {
615
+ open: e(i),
616
+ "onUpdate:open": C[2] || (C[2] = (p) => Pe(i) ? i.value = p : null),
617
+ title: e(o)("panel.test-title"),
618
+ width: 480
619
+ }, {
620
+ footer: c(() => [
621
+ h(e(pe), { size: "sm" }, {
622
+ default: c(() => [
623
+ h(e(U), {
624
+ variant: "outline",
625
+ onClick: C[1] || (C[1] = (p) => e(s)())
626
+ }, {
627
+ default: c(() => [
628
+ k(w(e(o)("panel.cancel")), 1)
629
+ ]),
630
+ _: 1
631
+ }),
632
+ h(e(U), {
633
+ type: "primary",
634
+ loading: W.value,
635
+ onClick: y
636
+ }, {
637
+ default: c(() => [
638
+ k(w(e(o)("panel.test-send")), 1)
639
+ ]),
640
+ _: 1
641
+ }, 8, ["loading"])
642
+ ]),
643
+ _: 1
644
+ })
645
+ ]),
646
+ default: c(() => [
647
+ h(e(F), {
648
+ size: "sm",
649
+ tone: "muted"
650
+ }, {
651
+ default: c(() => [
652
+ k(w(e(o)("panel.test-help")), 1)
653
+ ]),
654
+ _: 1
655
+ }),
656
+ h(e(ue), {
657
+ label: e(o)("panel.test-to")
658
+ }, {
659
+ default: c(() => [
660
+ h(e(ce), {
661
+ modelValue: u.value,
662
+ "onUpdate:modelValue": C[0] || (C[0] = (p) => u.value = p),
663
+ options: b.value,
664
+ disabled: W.value
665
+ }, null, 8, ["modelValue", "options", "disabled"])
666
+ ]),
667
+ _: 1
668
+ }, 8, ["label"]),
669
+ S.value ? (d(), x(e(L), {
670
+ key: 0,
671
+ type: "danger",
672
+ variant: "soft",
673
+ description: S.value
674
+ }, null, 8, ["description"])) : M("", !0),
675
+ $.value ? (d(), j(B, { key: 1 }, [
676
+ $.value.length === 0 ? (d(), x(e(F), {
677
+ key: 0,
678
+ size: "sm",
679
+ tone: "muted"
680
+ }, {
681
+ default: c(() => [
682
+ k(w(e(o)("panel.test-none")), 1)
683
+ ]),
684
+ _: 1
685
+ })) : M("", !0),
686
+ (d(!0), j(B, null, Q($.value, (p, v) => (d(), x(e(L), {
687
+ key: v,
688
+ type: p.status === "sent" ? "success" : "danger",
689
+ variant: "soft",
690
+ description: A(p)
691
+ }, null, 8, ["type", "description"]))), 128))
692
+ ], 64)) : M("", !0)
693
+ ]),
694
+ _: 1
695
+ }, 8, ["open", "title"]));
696
+ }
697
+ }), cn = { class: "wx-notifications-channel__body" }, dn = /* @__PURE__ */ R({
698
+ __name: "ChannelPage",
699
+ props: {
700
+ base: { default: "/notifications" }
701
+ },
702
+ setup(l) {
703
+ const t = l, i = ne(), s = ve(i), a = st(), o = Ee(), n = Le();
704
+ H();
705
+ const u = q("webx-notifications"), W = xe(), $ = V(
706
+ typeof a.params.id == "string" && a.params.id !== "" ? Number(a.params.id) : null
707
+ ), S = V(null), b = V(null), y = V({}), A = V(""), z = V([]), C = V({}), p = V(!0), v = V(!1), T = V(!1), N = Ut(S, y, $);
708
+ Wt({ id: _(() => b.value?.id ?? null) });
709
+ const P = _(() => i.can("notifications.manage")), fe = _(() => JSON.stringify(y.value)), Z = _(() => A.value !== "" && fe.value !== A.value), Ce = _(() => v.value ? "saving" : Z.value || $.value === null ? "unsaved" : "saved"), me = _(() => {
710
+ const m = typeof y.value.name == "string" ? y.value.name.trim() : "";
711
+ return m !== "" ? m : $.value === null ? u("panel.new") : u("panel.untitled");
712
+ }), he = _(
713
+ () => Array.isArray(y.value.forget) ? y.value.forget : []
714
+ ), be = _(
715
+ () => (N.provider.value?.fields ?? []).filter((m) => m.secret).map((m) => ({
716
+ field: m,
717
+ set: b.value?.credentials_set[m.name] === !0 && !he.value.includes(m.name)
718
+ }))
719
+ ), Te = _(() => [
720
+ { op: "set", target: "provider", props: { disabled: !0 } },
721
+ ...be.value.filter((m) => m.set).map((m) => ({
722
+ op: "set",
723
+ target: m.field.name,
724
+ help: u("panel.secret-set"),
725
+ props: { placeholder: "••••••••" }
726
+ }))
727
+ ]);
728
+ function ye(m) {
729
+ b.value = m.channel, y.value = m.values, A.value = JSON.stringify(m.values), z.value = m.warnings;
730
+ }
731
+ function Se(m) {
732
+ const r = typeof a.query.provider == "string" ? a.query.provider : "email", g = typeof a.query.event == "string" && a.query.event !== "" ? a.query.event : null, f = m.events.find((re) => re.key === g), D = f?.sample[r] ?? f?.sample["*"], Re = n.list.value[0]?.code ?? "en", qe = {};
733
+ for (const re of m.providers.find((pt) => pt.key === r)?.fields ?? [])
734
+ qe[re.name] = re.secret ? "" : re.default ?? "";
735
+ return {
736
+ name: "",
737
+ provider: r,
738
+ event: g,
739
+ enabled: !1,
740
+ recipients: [],
741
+ ...qe,
742
+ template: { [Re]: D?.template ?? "" },
743
+ subject: { [Re]: D?.subject ?? "" }
744
+ };
745
+ }
746
+ const ae = V([]);
747
+ async function ie() {
748
+ p.value = !0;
749
+ try {
750
+ const [m, r] = await Promise.all([
751
+ s.meta(),
752
+ $.value === null ? Promise.resolve(null) : s.get($.value)
753
+ ]);
754
+ if (S.value = m, r === null) {
755
+ const g = Se(m);
756
+ y.value = g, A.value = JSON.stringify(g);
757
+ } else
758
+ ye(r);
759
+ } catch (m) {
760
+ O.danger(W(m)), o.push(t.base);
761
+ } finally {
762
+ p.value = !1;
763
+ }
764
+ y.value.provider === "email" && P.value && s.administrators().then((m) => ae.value = m).catch(() => {
765
+ });
766
+ }
767
+ function K(m) {
768
+ const r = m.body;
769
+ r?.errors ? (C.value = r.errors, O.danger(u("panel.save-failed"))) : O.danger(W(m));
770
+ }
771
+ async function G() {
772
+ if (!(v.value || !P.value)) {
773
+ v.value = !0, C.value = {};
774
+ try {
775
+ const m = $.value === null, r = m ? await s.create(y.value) : await s.save($.value, y.value);
776
+ ye(r), r.warnings.length > 0 ? O.warning(u("panel.saved-warning", { warning: r.warnings.join(" ") })) : O.success(u("panel.saved")), m && ($.value = r.channel.id, o.replace(`${t.base}/channels/${r.channel.id}`));
777
+ } catch (m) {
778
+ K(m);
779
+ } finally {
780
+ v.value = !1;
781
+ }
782
+ }
783
+ }
784
+ async function ee() {
785
+ T.value = !0;
786
+ try {
787
+ const m = await s.check($.value, y.value);
788
+ m.ok ? O.success(m.message || u("panel.check-ok")) : O.warning(m.message);
789
+ } catch (m) {
790
+ K(m);
791
+ } finally {
792
+ T.value = !1;
793
+ }
794
+ }
795
+ const te = Ie(un), le = _(() => (Array.isArray(y.value.recipients) ? y.value.recipients : []).flatMap((r) => {
796
+ if (r.chat_id)
797
+ return [
798
+ { value: r.chat_id, label: r.label ? `${r.label} · ${r.chat_id}` : r.chat_id }
799
+ ];
800
+ if (r.email) return [{ value: r.email, label: r.email }];
801
+ const g = ae.value.find((f) => f.id === r.admin_id);
802
+ return g ? [{ value: g.email, label: `${g.name} · ${g.email}` }] : [];
803
+ }));
804
+ async function We() {
805
+ await te({ channel: $.value, values: y.value, recipients: le.value });
806
+ }
807
+ async function Ve() {
808
+ if ($.value !== null)
809
+ try {
810
+ const m = await s.copy($.value);
811
+ O.success(u("panel.copied", { name: m.channel.name })), o.push(`${t.base}/channels/${m.channel.id}`);
812
+ } catch (m) {
813
+ O.danger(W(m));
814
+ }
815
+ }
816
+ async function Ne() {
817
+ const m = b.value;
818
+ if (!(!m || !await we({
819
+ title: u("panel.delete-title", { title: me.value }),
820
+ message: u("panel.delete-text"),
821
+ confirmText: u("panel.delete"),
822
+ cancelText: u("panel.cancel"),
823
+ tone: "danger"
824
+ })))
825
+ try {
826
+ await s.remove(m.id), O.success(u("panel.deleted")), A.value = fe.value, o.push(t.base);
827
+ } catch (g) {
828
+ O.danger(W(g));
829
+ }
830
+ }
831
+ function Ae(m, r) {
832
+ y.value = { ...y.value, forget: [...he.value, m], [m]: "" }, O.info(u("panel.forgotten", { field: r }));
833
+ }
834
+ function se(m) {
835
+ Z.value && m.preventDefault();
836
+ }
837
+ function ge(m) {
838
+ (m.ctrlKey || m.metaKey) && m.key.toLowerCase() === "s" && (m.preventDefault(), (Z.value || $.value === null) && G());
839
+ }
840
+ Vt(ge), Ue(() => {
841
+ ie(), window.addEventListener("beforeunload", se);
842
+ }), mt(() => {
843
+ window.removeEventListener("beforeunload", se);
844
+ }), bt(async () => !Z.value || !P.value ? !0 : await we({
845
+ title: u("panel.leave-title"),
846
+ message: u("panel.leave-text"),
847
+ confirmText: u("panel.leave"),
848
+ cancelText: u("panel.cancel"),
849
+ tone: "danger"
850
+ }));
851
+ const ze = _(() => {
852
+ if (!P.value) return [];
853
+ const m = [
854
+ {
855
+ key: "check",
856
+ label: u("panel.check"),
857
+ icon: "check-circle",
858
+ loading: T.value,
859
+ run: () => {
860
+ ee();
861
+ }
862
+ },
863
+ { key: "test", label: u("panel.test"), icon: "send", run: () => {
864
+ We();
865
+ } }
866
+ ];
867
+ b.value !== null && m.push({
868
+ key: "copy",
869
+ label: u("panel.copy"),
870
+ icon: "copy",
871
+ menu: !0,
872
+ run: () => {
873
+ Ve();
874
+ }
875
+ });
876
+ for (const r of be.value.filter((g) => g.set))
877
+ m.push({
878
+ key: `forget-${r.field.name}`,
879
+ label: u("panel.forget", { field: r.field.label }),
880
+ icon: "unlock",
881
+ menu: !0,
882
+ run: () => Ae(r.field.name, r.field.label)
883
+ });
884
+ return b.value !== null && m.push({
885
+ key: "delete",
886
+ label: u("panel.delete"),
887
+ icon: "trash",
888
+ danger: !0,
889
+ run: () => {
890
+ Ne();
891
+ }
892
+ }), m;
893
+ }), oe = _(() => S.value?.environment ?? "production");
894
+ return (m, r) => (d(), j("div", {
895
+ class: "wx-notifications-channel",
896
+ onKeydown: ge
897
+ }, [
898
+ p.value ? (d(), x(e(ot), {
899
+ key: 0,
900
+ class: "wx-notifications-channel__ghost",
901
+ title: "",
902
+ rows: 8
903
+ })) : (d(), j(B, { key: 1 }, [
904
+ h(e(Nt), {
905
+ back: t.base,
906
+ "back-label": e(u)("panel.channels"),
907
+ title: me.value,
908
+ subtitle: b.value?.provider_label ?? e(N).provider.value?.label,
909
+ actions: ze.value
910
+ }, ht({ _: 2 }, [
911
+ b.value && !b.value.enabled ? {
912
+ name: "title-after",
913
+ fn: c(() => [
914
+ h(e(X), { dot: "" }, {
915
+ default: c(() => [
916
+ k(w(e(u)("panel.off")), 1)
917
+ ]),
918
+ _: 1
919
+ })
920
+ ]),
921
+ key: "0"
922
+ } : void 0
923
+ ]), 1032, ["back", "back-label", "title", "subtitle", "actions"]),
924
+ oe.value !== "production" ? (d(), x(e(L), {
925
+ key: 0,
926
+ type: "info",
927
+ variant: "soft",
928
+ description: e(u)("panel.environment", { environment: oe.value })
929
+ }, null, 8, ["description"])) : M("", !0),
930
+ S.value?.mode === "after_response" ? (d(), x(e(L), {
931
+ key: 1,
932
+ type: "warning",
933
+ variant: "soft",
934
+ description: e(u)("panel.mode-after-response")
935
+ }, null, 8, ["description"])) : M("", !0),
936
+ b.value && !b.value.provider_declared ? (d(), x(e(L), {
937
+ key: 2,
938
+ type: "danger",
939
+ title: e(u)("panel.provider-undeclared"),
940
+ description: e(u)("panel.provider-undeclared-text", { provider: b.value.provider })
941
+ }, null, 8, ["title", "description"])) : M("", !0),
942
+ b.value && !b.value.event_declared ? (d(), x(e(L), {
943
+ key: 3,
944
+ type: "warning",
945
+ title: e(u)("panel.event-undeclared"),
946
+ description: e(u)("panel.event-undeclared-text", { event: b.value.event ?? "" })
947
+ }, null, 8, ["title", "description"])) : M("", !0),
948
+ b.value && !b.value.credentials_readable ? (d(), x(e(L), {
949
+ key: 4,
950
+ type: "danger",
951
+ description: e(u)("panel.unreadable")
952
+ }, null, 8, ["description"])) : M("", !0),
953
+ b.value?.copied_from ? (d(), x(e(L), {
954
+ key: 5,
955
+ type: "info",
956
+ variant: "soft",
957
+ description: e(u)("panel.copied-from", { id: String(b.value.copied_from) })
958
+ }, null, 8, ["description"])) : M("", !0),
959
+ (d(!0), j(B, null, Q(z.value, (g) => (d(), x(e(L), {
960
+ key: g,
961
+ type: "warning",
962
+ description: g
963
+ }, null, 8, ["description"]))), 128)),
964
+ E("div", cn, [
965
+ h(e(At), {
966
+ modelValue: y.value,
967
+ "onUpdate:modelValue": r[0] || (r[0] = (g) => y.value = g),
968
+ class: "wx-notifications-channel__form",
969
+ name: "notifications.channel",
970
+ errors: C.value,
971
+ patch: Te.value,
972
+ disabled: !P.value || v.value
973
+ }, null, 8, ["modelValue", "errors", "patch", "disabled"]),
974
+ h(rn, { class: "wx-notifications-channel__preview" })
975
+ ]),
976
+ P.value ? (d(), x(e(gt), { key: 6 }, {
977
+ state: c(() => [
978
+ h(e(zt), { state: Ce.value }, null, 8, ["state"])
979
+ ]),
980
+ default: c(() => [
981
+ h(e(U), {
982
+ type: "primary",
983
+ loading: v.value,
984
+ disabled: !Z.value && $.value !== null,
985
+ onClick: G
986
+ }, {
987
+ default: c(() => [
988
+ k(w(e(u)("panel.save")), 1)
989
+ ]),
990
+ _: 1
991
+ }, 8, ["loading", "disabled"])
992
+ ]),
993
+ _: 1
994
+ })) : M("", !0)
995
+ ], 64))
996
+ ], 32));
997
+ }
998
+ }), it = /* @__PURE__ */ Y(dn, [["__scopeId", "data-v-b5c7b69a"]]), pn = { class: "wx-notification-channels" }, vn = /* @__PURE__ */ R({
999
+ name: "WxNotificationChannelsField",
1000
+ __name: "ChannelsField",
1001
+ props: /* @__PURE__ */ ke({
1002
+ event: {},
1003
+ disabled: { type: Boolean, default: !1 },
1004
+ base: { default: "/notifications" },
1005
+ addText: { default: void 0 },
1006
+ emptyText: { default: void 0 }
1007
+ }, {
1008
+ modelValue: { default: () => [] },
1009
+ modelModifiers: {}
1010
+ }),
1011
+ emits: ["update:modelValue"],
1012
+ setup(l) {
1013
+ const t = l, i = _e(l, "modelValue");
1014
+ H();
1015
+ const s = ne(), a = q("webx-notifications"), o = _(() => `notify-${t.event.replace(/[._]/g, "-")}`), n = _(() => s.can("notifications.manage")), u = Ee(), W = _(() => `${s.basePath}${t.base}`.replace(/\/{2,}/g, "/"));
1016
+ function $(S) {
1017
+ S.metaKey || S.ctrlKey || S.shiftKey || S.button !== 0 || (S.preventDefault(), u.push(t.base));
1018
+ }
1019
+ return (S, b) => (d(), j("div", pn, [
1020
+ h(e(jt), {
1021
+ modelValue: i.value,
1022
+ "onUpdate:modelValue": b[0] || (b[0] = (y) => i.value = y),
1023
+ target: o.value,
1024
+ sortable: !1,
1025
+ disabled: t.disabled,
1026
+ "add-text": t.addText ?? e(a)("panel.pick-channels"),
1027
+ "empty-text": t.emptyText
1028
+ }, null, 8, ["modelValue", "target", "disabled", "add-text", "empty-text"]),
1029
+ n.value ? (d(), x(e(wt), {
1030
+ key: 0,
1031
+ href: W.value,
1032
+ size: "sm",
1033
+ onClick: $
1034
+ }, {
1035
+ default: c(() => [
1036
+ k(w(e(a)("panel.set-up-channels")), 1)
1037
+ ]),
1038
+ _: 1
1039
+ }, 8, ["href"])) : M("", !0)
1040
+ ]));
1041
+ }
1042
+ }), fn = /* @__PURE__ */ Y(vn, [["__scopeId", "data-v-e0a57880"]]), mn = {
1043
+ key: 3,
1044
+ class: "wx-notifications-found"
1045
+ }, hn = { class: "wx-notifications-found__text" }, bn = /* @__PURE__ */ R({
1046
+ name: "WxNotificationsFindChats",
1047
+ __name: "FindChatsDialog",
1048
+ props: {
1049
+ channel: { default: null },
1050
+ token: { default: "" },
1051
+ chosen: { default: () => [] }
1052
+ },
1053
+ setup(l) {
1054
+ const t = l, { open: i, resolve: s, dismiss: a } = Be(), o = ve(ne());
1055
+ H();
1056
+ const n = q("webx-notifications"), u = xe(), W = V([]), $ = V(null), S = V(null), b = V(!0), y = V(/* @__PURE__ */ new Set());
1057
+ async function A() {
1058
+ b.value = !0, S.value = null;
1059
+ try {
1060
+ const v = await o.findRecipients({
1061
+ provider: "telegram",
1062
+ channel: t.channel,
1063
+ token: t.token.trim() === "" ? void 0 : t.token.trim()
1064
+ });
1065
+ W.value = v.recipients, $.value = v.hint;
1066
+ } catch (v) {
1067
+ S.value = u(v);
1068
+ } finally {
1069
+ b.value = !1;
1070
+ }
1071
+ }
1072
+ Ue(() => {
1073
+ A();
1074
+ });
1075
+ const z = _(() => W.value.filter((v) => !t.chosen.includes(v.id)));
1076
+ function C(v, T) {
1077
+ const N = new Set(y.value);
1078
+ T ? N.add(v) : N.delete(v), y.value = N;
1079
+ }
1080
+ function p() {
1081
+ s(z.value.filter((v) => y.value.has(v.id)));
1082
+ }
1083
+ return (v, T) => (d(), x(e(De), {
1084
+ open: e(i),
1085
+ "onUpdate:open": T[1] || (T[1] = (N) => Pe(i) ? i.value = N : null),
1086
+ title: e(n)("panel.find-title"),
1087
+ width: 480
1088
+ }, {
1089
+ footer: c(() => [
1090
+ h(e(pe), { size: "sm" }, {
1091
+ default: c(() => [
1092
+ h(e(U), {
1093
+ variant: "outline",
1094
+ disabled: b.value,
1095
+ onClick: A
1096
+ }, {
1097
+ default: c(() => [
1098
+ k(w(e(n)("panel.find-chats")), 1)
1099
+ ]),
1100
+ _: 1
1101
+ }, 8, ["disabled"]),
1102
+ h(e(U), {
1103
+ variant: "outline",
1104
+ onClick: T[0] || (T[0] = (N) => e(a)())
1105
+ }, {
1106
+ default: c(() => [
1107
+ k(w(e(n)("panel.cancel")), 1)
1108
+ ]),
1109
+ _: 1
1110
+ }),
1111
+ h(e(U), {
1112
+ type: "primary",
1113
+ disabled: y.value.size === 0,
1114
+ onClick: p
1115
+ }, {
1116
+ default: c(() => [
1117
+ k(w(e(n)("panel.find-add")), 1)
1118
+ ]),
1119
+ _: 1
1120
+ }, 8, ["disabled"])
1121
+ ]),
1122
+ _: 1
1123
+ })
1124
+ ]),
1125
+ default: c(() => [
1126
+ b.value ? (d(), x(e(ot), {
1127
+ key: 0,
1128
+ rows: 3
1129
+ })) : S.value ? (d(), x(e(L), {
1130
+ key: 1,
1131
+ type: "danger",
1132
+ variant: "soft",
1133
+ description: S.value
1134
+ }, null, 8, ["description"])) : W.value.length === 0 ? (d(), x(e(_t), {
1135
+ key: 2,
1136
+ title: e(n)("panel.find-title"),
1137
+ description: $.value ?? e(n)("panel.find-help")
1138
+ }, null, 8, ["title", "description"])) : (d(), j("ul", mn, [
1139
+ (d(!0), j(B, null, Q(W.value, (N) => (d(), j("li", {
1140
+ key: N.id,
1141
+ class: "wx-notifications-found__row"
1142
+ }, [
1143
+ h(e(kt), {
1144
+ "model-value": t.chosen.includes(N.id) || y.value.has(N.id),
1145
+ disabled: t.chosen.includes(N.id),
1146
+ "onUpdate:modelValue": (P) => C(N.id, P)
1147
+ }, {
1148
+ default: c(() => [
1149
+ E("span", hn, [
1150
+ h(e(F), { truncate: "" }, {
1151
+ default: c(() => [
1152
+ k(w(N.title), 1)
1153
+ ]),
1154
+ _: 2
1155
+ }, 1024),
1156
+ h(e(F), {
1157
+ size: "sm",
1158
+ tone: "muted",
1159
+ mono: "",
1160
+ truncate: ""
1161
+ }, {
1162
+ default: c(() => [
1163
+ k(w([N.id, N.username].filter(Boolean).join(" · ")), 1)
1164
+ ]),
1165
+ _: 2
1166
+ }, 1024)
1167
+ ])
1168
+ ]),
1169
+ _: 2
1170
+ }, 1032, ["model-value", "disabled", "onUpdate:modelValue"]),
1171
+ h(e(X), null, {
1172
+ default: c(() => [
1173
+ k(w(e(n)(`panel.chat-${N.type}`)), 1)
1174
+ ]),
1175
+ _: 2
1176
+ }, 1024)
1177
+ ]))), 128))
1178
+ ]))
1179
+ ]),
1180
+ _: 1
1181
+ }, 8, ["open", "title"]));
1182
+ }
1183
+ }), yn = /* @__PURE__ */ Y(bn, [["__scopeId", "data-v-71616d40"]]);
1184
+ function gn(l) {
1185
+ return (l?.variables ?? []).map((t) => ({
1186
+ name: t.name,
1187
+ label: t.label,
1188
+ example: t.example,
1189
+ fields: t.fields.length > 0 ? t.fields : void 0
1190
+ }));
1191
+ }
1192
+ function wn(l, t = "value") {
1193
+ const i = l.name.endsWith(".*") ? `${l.name.slice(0, -2)}.name` : l.name;
1194
+ if ((l.fields?.length ?? 0) > 0) {
1195
+ const s = (l.fields ?? []).map((a) => `{{${a.name}}}`).join(" ");
1196
+ return `{{#${i}}}
1197
+ ${s}
1198
+ {{/${i}}}`;
1199
+ }
1200
+ return t === "has" ? `{{#${i}}}{{${i}}}{{/${i}}}` : t === "empty" ? `{{^${i}}}{{/${i}}}` : `{{${i}}}`;
1201
+ }
1202
+ function dt(l, t) {
1203
+ return (l?.variables ?? []).filter((i) => i.address === t);
1204
+ }
1205
+ const _n = { class: "wx-notifications-recipients" }, kn = /* @__PURE__ */ R({
1206
+ name: "WxNotificationsChatsField",
1207
+ __name: "ChatsField",
1208
+ props: /* @__PURE__ */ ke({
1209
+ disabled: { type: Boolean, default: !1 }
1210
+ }, {
1211
+ modelValue: { default: () => [] },
1212
+ modelModifiers: {}
1213
+ }),
1214
+ emits: ["update:modelValue"],
1215
+ setup(l) {
1216
+ const t = l, i = _e(l, "modelValue");
1217
+ H();
1218
+ const s = q("webx-notifications"), a = $e(), o = Ie(yn), n = _(() => Array.isArray(i.value) ? i.value : []), u = _(() => dt(a.event.value, "telegram")), W = _(
1219
+ () => u.value.filter((p) => !n.value.some((v) => v.variable === p.name))
1220
+ );
1221
+ function $(p) {
1222
+ return u.value.find((v) => v.name === p)?.label ?? `{{${p}}}`;
1223
+ }
1224
+ function S(p, v) {
1225
+ i.value = n.value.map((T, N) => N === p ? { ...T, ...v } : T);
1226
+ }
1227
+ function b(p) {
1228
+ i.value = [...n.value, p];
1229
+ }
1230
+ function y(p) {
1231
+ i.value = n.value.filter((v, T) => T !== p);
1232
+ }
1233
+ const A = _(() => {
1234
+ const p = a.values.value.token;
1235
+ return typeof p == "string" ? p : "";
1236
+ }), z = _(
1237
+ () => A.value.trim() !== "" || a.id.value !== null && a.values.value.provider === "telegram"
1238
+ );
1239
+ async function C() {
1240
+ if (!z.value) {
1241
+ O.warning(s("panel.find-token"));
1242
+ return;
1243
+ }
1244
+ const p = await o({
1245
+ channel: a.id.value,
1246
+ token: A.value,
1247
+ chosen: n.value.map((v) => v.chat_id ?? "").filter(Boolean)
1248
+ });
1249
+ !p || p.length === 0 || (i.value = [...n.value, ...p.map((v) => ({ chat_id: v.id, label: v.title }))], O.success(s("panel.find-added", { count: String(p.length) })));
1250
+ }
1251
+ return (p, v) => (d(), j("div", _n, [
1252
+ n.value.length === 0 ? (d(), x(e(F), {
1253
+ key: 0,
1254
+ size: "sm",
1255
+ tone: "placeholder"
1256
+ }, {
1257
+ default: c(() => [
1258
+ k(w(e(s)("panel.no-recipients")), 1)
1259
+ ]),
1260
+ _: 1
1261
+ })) : M("", !0),
1262
+ (d(!0), j(B, null, Q(n.value, (T, N) => (d(), j("div", {
1263
+ key: N,
1264
+ class: "wx-notifications-recipients__row"
1265
+ }, [
1266
+ T.variable ? (d(), x(e(X), {
1267
+ key: 0,
1268
+ type: "primary",
1269
+ class: "wx-notifications-recipients__addressee"
1270
+ }, {
1271
+ default: c(() => [
1272
+ k(w(e(s)("panel.addressee", { label: $(T.variable) })), 1)
1273
+ ]),
1274
+ _: 2
1275
+ }, 1024)) : (d(), j(B, { key: 1 }, [
1276
+ h(e(je), {
1277
+ class: "wx-notifications-recipients__id",
1278
+ "model-value": T.chat_id ?? "",
1279
+ placeholder: e(s)("panel.chat-id"),
1280
+ "aria-label": e(s)("panel.chat-id"),
1281
+ disabled: t.disabled,
1282
+ inputmode: "text",
1283
+ "onUpdate:modelValue": (P) => S(N, { chat_id: String(P ?? "") })
1284
+ }, null, 8, ["model-value", "placeholder", "aria-label", "disabled", "onUpdate:modelValue"]),
1285
+ h(e(je), {
1286
+ class: "wx-notifications-recipients__label",
1287
+ "model-value": T.label ?? "",
1288
+ placeholder: e(s)("panel.chat-label"),
1289
+ "aria-label": e(s)("panel.chat-label"),
1290
+ disabled: t.disabled,
1291
+ "onUpdate:modelValue": (P) => S(N, { label: String(P ?? "") })
1292
+ }, null, 8, ["model-value", "placeholder", "aria-label", "disabled", "onUpdate:modelValue"])
1293
+ ], 64)),
1294
+ t.disabled ? M("", !0) : (d(), x(e(rt), {
1295
+ key: 2,
1296
+ icon: "trash",
1297
+ tone: "danger",
1298
+ title: e(s)("panel.remove"),
1299
+ onClick: (P) => y(N)
1300
+ }, null, 8, ["title", "onClick"]))
1301
+ ]))), 128)),
1302
+ t.disabled ? M("", !0) : (d(), x(e(pe), {
1303
+ key: 1,
1304
+ size: "sm",
1305
+ wrap: ""
1306
+ }, {
1307
+ default: c(() => [
1308
+ h(e(U), {
1309
+ variant: "outline",
1310
+ size: "sm",
1311
+ onClick: v[0] || (v[0] = (T) => b({ chat_id: "", label: "" }))
1312
+ }, {
1313
+ icon: c(() => [
1314
+ h(e(de), { name: "plus" })
1315
+ ]),
1316
+ default: c(() => [
1317
+ k(" " + w(e(s)("panel.add-chat")), 1)
1318
+ ]),
1319
+ _: 1
1320
+ }),
1321
+ h(e(U), {
1322
+ variant: "outline",
1323
+ size: "sm",
1324
+ onClick: C
1325
+ }, {
1326
+ icon: c(() => [
1327
+ h(e(de), { name: "search" })
1328
+ ]),
1329
+ default: c(() => [
1330
+ k(" " + w(e(s)("panel.find-chats")), 1)
1331
+ ]),
1332
+ _: 1
1333
+ }),
1334
+ (d(!0), j(B, null, Q(W.value, (T) => (d(), x(e(U), {
1335
+ key: T.name,
1336
+ variant: "outline",
1337
+ size: "sm",
1338
+ onClick: (N) => b({ variable: T.name })
1339
+ }, {
1340
+ default: c(() => [
1341
+ k(w(e(s)("panel.addressee", { label: T.label })), 1)
1342
+ ]),
1343
+ _: 2
1344
+ }, 1032, ["onClick"]))), 128))
1345
+ ]),
1346
+ _: 1
1347
+ }))
1348
+ ]));
1349
+ }
1350
+ }), xn = /* @__PURE__ */ Y(kn, [["__scopeId", "data-v-00cd60ee"]]), $n = { class: "wx-notifications-recipients" }, Cn = /* @__PURE__ */ R({
1351
+ name: "WxNotificationsEmailsField",
1352
+ __name: "EmailsField",
1353
+ props: /* @__PURE__ */ ke({
1354
+ disabled: { type: Boolean, default: !1 }
1355
+ }, {
1356
+ modelValue: { default: () => [] },
1357
+ modelModifiers: {}
1358
+ }),
1359
+ emits: ["update:modelValue"],
1360
+ setup(l) {
1361
+ const t = l, i = _e(l, "modelValue");
1362
+ H();
1363
+ const s = q("webx-notifications"), a = $e(), o = ne(), n = V([]);
1364
+ Ue(async () => {
1365
+ try {
1366
+ n.value = await ve(o).administrators();
1367
+ } catch {
1368
+ }
1369
+ });
1370
+ const u = _(() => Array.isArray(i.value) ? i.value : []), W = _(
1371
+ () => n.value.map((p) => ({ value: p.id, label: `${p.name} · ${p.email}` }))
1372
+ ), $ = _(() => dt(a.event.value, "email")), S = _(
1373
+ () => $.value.filter((p) => !u.value.some((v) => v.variable === p.name))
1374
+ );
1375
+ function b(p) {
1376
+ return $.value.find((v) => v.name === p)?.label ?? `{{${p}}}`;
1377
+ }
1378
+ function y(p, v) {
1379
+ i.value = u.value.map((T, N) => N === p ? v : T);
1380
+ }
1381
+ function A(p) {
1382
+ i.value = [...u.value, p];
1383
+ }
1384
+ function z(p) {
1385
+ i.value = u.value.filter((v, T) => T !== p);
1386
+ }
1387
+ function C(p) {
1388
+ return W.value.some((v) => v.value === p) ? W.value : [...W.value, { value: p, label: s("panel.admin-unknown", { id: String(p) }) }];
1389
+ }
1390
+ return (p, v) => (d(), j("div", $n, [
1391
+ u.value.length === 0 ? (d(), x(e(F), {
1392
+ key: 0,
1393
+ size: "sm",
1394
+ tone: "placeholder"
1395
+ }, {
1396
+ default: c(() => [
1397
+ k(w(e(s)("panel.no-recipients")), 1)
1398
+ ]),
1399
+ _: 1
1400
+ })) : M("", !0),
1401
+ (d(!0), j(B, null, Q(u.value, (T, N) => (d(), j("div", {
1402
+ key: N,
1403
+ class: "wx-notifications-recipients__row"
1404
+ }, [
1405
+ T.variable ? (d(), x(e(X), {
1406
+ key: 0,
1407
+ type: "primary",
1408
+ class: "wx-notifications-recipients__wide"
1409
+ }, {
1410
+ default: c(() => [
1411
+ k(w(e(s)("panel.addressee", { label: b(T.variable) })), 1)
1412
+ ]),
1413
+ _: 2
1414
+ }, 1024)) : T.admin_id !== void 0 ? (d(), x(e(ce), {
1415
+ key: 1,
1416
+ class: "wx-notifications-recipients__wide",
1417
+ "model-value": T.admin_id,
1418
+ options: C(T.admin_id),
1419
+ disabled: t.disabled,
1420
+ "onUpdate:modelValue": (P) => y(N, { admin_id: Number(P) })
1421
+ }, null, 8, ["model-value", "options", "disabled", "onUpdate:modelValue"])) : (d(), x(e(je), {
1422
+ key: 2,
1423
+ class: "wx-notifications-recipients__wide",
1424
+ type: "email",
1425
+ "model-value": T.email ?? "",
1426
+ placeholder: "manager@site.test",
1427
+ disabled: t.disabled,
1428
+ "onUpdate:modelValue": (P) => y(N, { email: String(P ?? "") })
1429
+ }, null, 8, ["model-value", "disabled", "onUpdate:modelValue"])),
1430
+ t.disabled ? M("", !0) : (d(), x(e(rt), {
1431
+ key: 3,
1432
+ icon: "trash",
1433
+ tone: "danger",
1434
+ title: e(s)("panel.remove"),
1435
+ onClick: (P) => z(N)
1436
+ }, null, 8, ["title", "onClick"]))
1437
+ ]))), 128)),
1438
+ t.disabled ? M("", !0) : (d(), x(e(pe), {
1439
+ key: 1,
1440
+ size: "sm",
1441
+ wrap: ""
1442
+ }, {
1443
+ default: c(() => [
1444
+ h(e(U), {
1445
+ variant: "outline",
1446
+ size: "sm",
1447
+ disabled: W.value.length === 0,
1448
+ onClick: v[0] || (v[0] = (T) => A({ admin_id: Number(W.value[0]?.value) }))
1449
+ }, {
1450
+ icon: c(() => [
1451
+ h(e(de), { name: "user" })
1452
+ ]),
1453
+ default: c(() => [
1454
+ k(" " + w(e(s)("panel.add-admin")), 1)
1455
+ ]),
1456
+ _: 1
1457
+ }, 8, ["disabled"]),
1458
+ h(e(U), {
1459
+ variant: "outline",
1460
+ size: "sm",
1461
+ onClick: v[1] || (v[1] = (T) => A({ email: "" }))
1462
+ }, {
1463
+ icon: c(() => [
1464
+ h(e(de), { name: "mail" })
1465
+ ]),
1466
+ default: c(() => [
1467
+ k(" " + w(e(s)("panel.add-email")), 1)
1468
+ ]),
1469
+ _: 1
1470
+ }),
1471
+ (d(!0), j(B, null, Q(S.value, (T) => (d(), x(e(U), {
1472
+ key: T.name,
1473
+ variant: "outline",
1474
+ size: "sm",
1475
+ onClick: (N) => A({ variable: T.name })
1476
+ }, {
1477
+ default: c(() => [
1478
+ k(w(e(s)("panel.addressee", { label: T.label })), 1)
1479
+ ]),
1480
+ _: 2
1481
+ }, 1032, ["onClick"]))), 128))
1482
+ ]),
1483
+ _: 1
1484
+ }))
1485
+ ]));
1486
+ }
1487
+ }), Tn = /* @__PURE__ */ Y(Cn, [["__scopeId", "data-v-ae639366"]]), Sn = /* @__PURE__ */ R({
1488
+ name: "WxNotificationsNewChannel",
1489
+ __name: "NewChannelDialog",
1490
+ props: {
1491
+ meta: {}
1492
+ },
1493
+ setup(l) {
1494
+ const t = l, { open: i, resolve: s, dismiss: a } = Be();
1495
+ H();
1496
+ const o = q("webx-notifications"), n = V(t.meta.providers[0]?.key ?? ""), u = V(null), W = _(
1497
+ () => t.meta.providers.map((b) => ({ value: b.key, label: b.label, icon: b.icon }))
1498
+ ), $ = _(() => [
1499
+ { value: "", label: o("panel.any-event") },
1500
+ ...t.meta.events.map((b) => ({ value: b.key, label: b.label }))
1501
+ ]);
1502
+ function S() {
1503
+ s({ provider: n.value, event: u.value === "" ? null : u.value });
1504
+ }
1505
+ return (b, y) => (d(), x(e(De), {
1506
+ open: e(i),
1507
+ "onUpdate:open": y[3] || (y[3] = (A) => Pe(i) ? i.value = A : null),
1508
+ title: e(o)("panel.new-title"),
1509
+ width: 460
1510
+ }, {
1511
+ footer: c(() => [
1512
+ h(e(pe), { size: "sm" }, {
1513
+ default: c(() => [
1514
+ h(e(U), {
1515
+ variant: "outline",
1516
+ onClick: y[2] || (y[2] = (A) => e(a)())
1517
+ }, {
1518
+ default: c(() => [
1519
+ k(w(e(o)("panel.cancel")), 1)
1520
+ ]),
1521
+ _: 1
1522
+ }),
1523
+ h(e(U), {
1524
+ type: "primary",
1525
+ disabled: n.value === "",
1526
+ onClick: S
1527
+ }, {
1528
+ default: c(() => [
1529
+ k(w(e(o)("panel.new-create")), 1)
1530
+ ]),
1531
+ _: 1
1532
+ }, 8, ["disabled"])
1533
+ ]),
1534
+ _: 1
1535
+ })
1536
+ ]),
1537
+ default: c(() => [
1538
+ h(e(F), {
1539
+ size: "sm",
1540
+ tone: "muted"
1541
+ }, {
1542
+ default: c(() => [
1543
+ k(w(e(o)("panel.new-help")), 1)
1544
+ ]),
1545
+ _: 1
1546
+ }),
1547
+ h(e(ue), {
1548
+ label: e(o)("panel.new-provider")
1549
+ }, {
1550
+ default: c(() => [
1551
+ h(e(xt), {
1552
+ modelValue: n.value,
1553
+ "onUpdate:modelValue": y[0] || (y[0] = (A) => n.value = A),
1554
+ options: W.value
1555
+ }, null, 8, ["modelValue", "options"])
1556
+ ]),
1557
+ _: 1
1558
+ }, 8, ["label"]),
1559
+ h(e(ue), {
1560
+ label: e(o)("panel.new-event")
1561
+ }, {
1562
+ default: c(() => [
1563
+ h(e(ce), {
1564
+ "model-value": u.value ?? "",
1565
+ options: $.value,
1566
+ "onUpdate:modelValue": y[1] || (y[1] = (A) => u.value = A === "" ? null : String(A))
1567
+ }, null, 8, ["model-value", "options"])
1568
+ ]),
1569
+ _: 1
1570
+ }, 8, ["label"])
1571
+ ]),
1572
+ _: 1
1573
+ }, 8, ["open", "title"]));
1574
+ }
1575
+ }), Wn = {
1576
+ key: 0,
1577
+ class: "wx-notifications-list__note"
1578
+ }, Vn = { class: "wx-notifications-list__name" }, Nn = { class: "wx-notifications-list__text" }, An = {
1579
+ key: 0,
1580
+ class: "wx-notifications-list__last"
1581
+ }, zn = { class: "wx-notifications-list__text" }, jn = { class: "wx-notifications-list__last" }, On = { class: "wx-notifications-list__details" }, Fn = /* @__PURE__ */ R({
1582
+ __name: "NotificationsPage",
1583
+ props: {
1584
+ base: { default: "/notifications" }
1585
+ },
1586
+ setup(l) {
1587
+ const t = l, i = ne(), s = ve(i), a = st(), o = Ee();
1588
+ H();
1589
+ const n = q("webx-notifications"), u = xe(), W = _(() => i.can("notifications.manage")), $ = _(
1590
+ () => i.state.manifest?.modules.find((r) => r.id === "notifications")?.title ?? n("module.title")
1591
+ ), S = _({
1592
+ get: () => {
1593
+ const r = a.query.view;
1594
+ return r === "log" || r === "bin" ? r : "";
1595
+ },
1596
+ set: (r) => {
1597
+ o.replace({
1598
+ query: { ...a.query, view: r === "" ? void 0 : r, page: void 0 }
1599
+ });
1600
+ }
1601
+ }), b = V(null), y = V([]), A = V([]), z = V("production"), C = V(!0), p = _(() => [
1602
+ { value: "", label: n("panel.channels"), badge: y.value.length },
1603
+ { value: "log", label: n("panel.log") },
1604
+ { value: "bin", label: n("panel.bin"), badge: A.value.length || void 0 }
1605
+ ]);
1606
+ async function v() {
1607
+ C.value = !0;
1608
+ try {
1609
+ const [r, g] = await Promise.all([s.channels(), s.channels({ trashed: !0 })]);
1610
+ y.value = r.data, A.value = g.data, z.value = r.environment;
1611
+ } catch (r) {
1612
+ O.danger(u(r));
1613
+ } finally {
1614
+ C.value = !1;
1615
+ }
1616
+ }
1617
+ v(), s.meta().then((r) => b.value = r).catch(() => {
1618
+ });
1619
+ const T = Ie(
1620
+ Sn
1621
+ );
1622
+ async function N() {
1623
+ if (b.value === null) return;
1624
+ const r = await T({ meta: b.value });
1625
+ r && o.push({
1626
+ path: `${t.base}/channels/new`,
1627
+ query: { provider: r.provider, ...r.event ? { event: r.event } : {} }
1628
+ });
1629
+ }
1630
+ function P(r) {
1631
+ o.push(`${t.base}/channels/${r.id}`);
1632
+ }
1633
+ async function fe(r, g) {
1634
+ try {
1635
+ const f = await s.save(r.id, { enabled: g });
1636
+ y.value = y.value.map((D) => D.id === r.id ? f.channel : D), O.success(n(g ? "panel.enabled" : "panel.disabled"));
1637
+ } catch (f) {
1638
+ const D = f.body;
1639
+ O.danger(D?.errors ? Object.values(D.errors).flat().join(" ") : u(f));
1640
+ }
1641
+ }
1642
+ async function Z(r) {
1643
+ try {
1644
+ const g = await s.copy(r.id);
1645
+ O.success(n("panel.copied", { name: g.channel.name })), await v();
1646
+ } catch (g) {
1647
+ O.danger(u(g));
1648
+ }
1649
+ }
1650
+ async function Ce(r) {
1651
+ if (await we({
1652
+ title: n("panel.delete-title", { title: r.name }),
1653
+ message: n("panel.delete-text"),
1654
+ confirmText: n("panel.delete"),
1655
+ cancelText: n("panel.cancel"),
1656
+ tone: "danger"
1657
+ }))
1658
+ try {
1659
+ await s.remove(r.id), O.success(n("panel.deleted")), await v();
1660
+ } catch (f) {
1661
+ O.danger(u(f));
1662
+ }
1663
+ }
1664
+ async function me(r) {
1665
+ try {
1666
+ await s.restore(r.id), O.success(n("panel.restored")), await v();
1667
+ } catch (g) {
1668
+ O.danger(u(g));
1669
+ }
1670
+ }
1671
+ async function he(r) {
1672
+ if (await we({
1673
+ title: n("panel.purge-title", { title: r.name }),
1674
+ message: n("panel.purge-text"),
1675
+ confirmText: n("panel.purge"),
1676
+ cancelText: n("panel.cancel"),
1677
+ tone: "danger"
1678
+ }))
1679
+ try {
1680
+ await s.purge(r.id), O.success(n("panel.purged")), await v();
1681
+ } catch (f) {
1682
+ O.danger(u(f));
1683
+ }
1684
+ }
1685
+ function be(r) {
1686
+ return S.value === "bin" ? W.value ? [
1687
+ {
1688
+ key: "restore",
1689
+ label: n("panel.restore"),
1690
+ icon: "refresh",
1691
+ run: () => {
1692
+ me(r);
1693
+ }
1694
+ },
1695
+ {
1696
+ key: "purge",
1697
+ label: n("panel.purge"),
1698
+ icon: "trash",
1699
+ danger: !0,
1700
+ run: () => {
1701
+ he(r);
1702
+ }
1703
+ }
1704
+ ] : [] : [
1705
+ { key: "edit", label: n("panel.edit"), icon: "edit", run: () => P(r) },
1706
+ ...W.value ? [
1707
+ {
1708
+ key: "copy",
1709
+ label: n("panel.copy"),
1710
+ icon: "copy",
1711
+ run: () => {
1712
+ Z(r);
1713
+ }
1714
+ },
1715
+ {
1716
+ key: "delete",
1717
+ label: n("panel.delete"),
1718
+ icon: "trash",
1719
+ danger: !0,
1720
+ run: () => {
1721
+ Ce(r);
1722
+ }
1723
+ }
1724
+ ] : []
1725
+ ];
1726
+ }
1727
+ const Te = _(() => [
1728
+ { key: "name", label: n("module.channel"), minWidth: 160 },
1729
+ { key: "event", label: n("panel.new-event"), width: 200, hideBelow: 720 },
1730
+ { key: "last_delivery", label: n("panel.column-status"), width: 170, hideBelow: 560 },
1731
+ ...S.value === "bin" ? [] : [{ key: "enabled", label: "", width: 64, align: "center" }],
1732
+ { key: "actions", label: "", width: Xe, align: "right" }
1733
+ ]), ye = _(() => S.value === "bin" ? A.value : y.value);
1734
+ function Se(r) {
1735
+ return r.icon ?? (r.provider === "telegram" ? "send" : "mail");
1736
+ }
1737
+ const ae = V(null), ie = V(!1), K = V(""), G = V(""), ee = V(!0), te = V(void 0);
1738
+ async function le(r) {
1739
+ te.value = r ?? te.value, ie.value = !0;
1740
+ try {
1741
+ ae.value = await s.deliveries({
1742
+ page: te.value?.page ?? 1,
1743
+ per_page: te.value?.perPage,
1744
+ status: K.value === "" ? null : K.value,
1745
+ channel: G.value === "" ? null : G.value,
1746
+ tests: ee.value
1747
+ }), z.value = ae.value.environment;
1748
+ } catch (g) {
1749
+ O.danger(u(g));
1750
+ } finally {
1751
+ ie.value = !1;
1752
+ }
1753
+ }
1754
+ He(
1755
+ S,
1756
+ (r) => {
1757
+ r === "log" && le();
1758
+ },
1759
+ { immediate: !0 }
1760
+ ), He(
1761
+ [K, G, ee],
1762
+ () => {
1763
+ le({ ...te.value ?? {}, page: 1 });
1764
+ }
1765
+ );
1766
+ const We = _(
1767
+ () => +(K.value !== "") + +(G.value !== "") + +!ee.value
1768
+ ), Ve = _(() => [
1769
+ { value: "", label: n("panel.all-statuses") },
1770
+ ...["queued", "sent", "failed", "skipped"].map((r) => ({
1771
+ value: r,
1772
+ label: n(`module.statuses.${r}`)
1773
+ }))
1774
+ ]), Ne = _(() => [
1775
+ { value: "", label: n("panel.all-channels") },
1776
+ ...y.value.map((r) => ({ value: r.id, label: r.name }))
1777
+ ]), Ae = _(() => [
1778
+ { key: "created_at", label: n("panel.column-when"), width: 150 },
1779
+ { key: "recipient", label: n("panel.column-recipient"), minWidth: 160 },
1780
+ { key: "channel_name", label: n("panel.column-channel"), width: 180, hideBelow: 760 },
1781
+ { key: "status", label: n("panel.column-status"), width: 140 },
1782
+ { key: "attempts", label: n("panel.column-attempts"), width: 90, align: "right", hideBelow: 900 },
1783
+ { key: "actions", label: "", width: Xe, align: "right" }
1784
+ ]), se = {
1785
+ sent: "success",
1786
+ failed: "danger",
1787
+ queued: "warning",
1788
+ skipped: "default"
1789
+ };
1790
+ async function ge(r) {
1791
+ try {
1792
+ await s.retry(r.id), O.success(n("panel.retried")), await le();
1793
+ } catch (g) {
1794
+ O.danger(u(g));
1795
+ }
1796
+ }
1797
+ function ze(r) {
1798
+ const g = [];
1799
+ return r.subject_url && g.push({
1800
+ key: "open",
1801
+ label: n("panel.open-subject"),
1802
+ icon: "external-link",
1803
+ href: r.subject_url,
1804
+ target: "_self"
1805
+ }), r.channel_id !== null && g.push({
1806
+ key: "channel",
1807
+ label: n("panel.edit"),
1808
+ icon: "edit",
1809
+ run: () => {
1810
+ o.push(`${t.base}/channels/${r.channel_id}`);
1811
+ }
1812
+ }), r.retryable && W.value && g.push({
1813
+ key: "retry",
1814
+ label: n("panel.retry"),
1815
+ icon: "refresh",
1816
+ run: () => {
1817
+ ge(r);
1818
+ }
1819
+ }), g;
1820
+ }
1821
+ function oe(r) {
1822
+ return r.error ? r.error : r.reason ? n(`module.reasons.${r.reason}`) : null;
1823
+ }
1824
+ const m = _(
1825
+ () => W.value ? [
1826
+ {
1827
+ key: "new",
1828
+ label: n("panel.new"),
1829
+ icon: "plus",
1830
+ primary: !0,
1831
+ disabled: b.value === null,
1832
+ run: () => {
1833
+ N();
1834
+ }
1835
+ }
1836
+ ] : []
1837
+ );
1838
+ return (r, g) => (d(), x(e(Ot), {
1839
+ view: S.value,
1840
+ "onUpdate:view": g[6] || (g[6] = (f) => S.value = f),
1841
+ title: $.value,
1842
+ views: p.value,
1843
+ actions: m.value
1844
+ }, {
1845
+ default: c(() => [
1846
+ z.value !== "production" ? (d(), j("div", Wn, [
1847
+ h(e(L), {
1848
+ type: "info",
1849
+ variant: "soft",
1850
+ description: e(n)("panel.environment", { environment: z.value })
1851
+ }, null, 8, ["description"])
1852
+ ])) : M("", !0),
1853
+ S.value !== "log" ? (d(), x(e(Je), {
1854
+ key: 1,
1855
+ data: ye.value,
1856
+ columns: Te.value,
1857
+ "row-key": "id",
1858
+ hover: "",
1859
+ clickable: "",
1860
+ flush: "",
1861
+ layout: "fixed",
1862
+ loading: C.value,
1863
+ "cards-below": 0,
1864
+ pagination: !1,
1865
+ "empty-text": S.value === "bin" ? e(n)("panel.empty-bin") : e(n)("panel.empty-channels-text"),
1866
+ "aria-label": $.value,
1867
+ onRowClick: g[2] || (g[2] = (f) => S.value !== "bin" && P(f))
1868
+ }, {
1869
+ "cell-name": c(({ row: f }) => [
1870
+ E("span", Vn, [
1871
+ h(e(de), {
1872
+ name: Se(f),
1873
+ class: "wx-notifications-list__icon"
1874
+ }, null, 8, ["name"]),
1875
+ E("span", Nn, [
1876
+ h(e(F), {
1877
+ truncate: "",
1878
+ weight: "medium"
1879
+ }, {
1880
+ default: c(() => [
1881
+ k(w(f.name), 1)
1882
+ ]),
1883
+ _: 2
1884
+ }, 1024),
1885
+ h(e(F), {
1886
+ size: "sm",
1887
+ tone: "muted",
1888
+ truncate: ""
1889
+ }, {
1890
+ default: c(() => [
1891
+ k(w(f.provider_label) + " · " + w(e(n)("panel.recipients", { count: String(f.recipients) })), 1)
1892
+ ]),
1893
+ _: 2
1894
+ }, 1024)
1895
+ ])
1896
+ ])
1897
+ ]),
1898
+ "cell-event": c(({ row: f }) => [
1899
+ f.event_declared ? (d(), x(e(F), {
1900
+ key: 1,
1901
+ size: "sm",
1902
+ tone: f.event ? "default" : "muted",
1903
+ truncate: ""
1904
+ }, {
1905
+ default: c(() => [
1906
+ k(w(f.event_label ?? e(n)("panel.any-event")), 1)
1907
+ ]),
1908
+ _: 2
1909
+ }, 1032, ["tone"])) : (d(), x(e(X), {
1910
+ key: 0,
1911
+ type: "warning"
1912
+ }, {
1913
+ default: c(() => [
1914
+ k(w(e(n)("panel.event-undeclared")), 1)
1915
+ ]),
1916
+ _: 1
1917
+ }))
1918
+ ]),
1919
+ "cell-last_delivery": c(({ row: f }) => [
1920
+ f.last_delivery ? (d(), j("span", An, [
1921
+ h(e(X), {
1922
+ type: se[f.last_delivery.status],
1923
+ dot: ""
1924
+ }, {
1925
+ default: c(() => [
1926
+ k(w(e(n)(`module.statuses.${f.last_delivery.status}`)), 1)
1927
+ ]),
1928
+ _: 2
1929
+ }, 1032, ["type"]),
1930
+ h(e(Ze), {
1931
+ value: f.last_delivery.at,
1932
+ class: "wx-notifications-list__when"
1933
+ }, null, 8, ["value"])
1934
+ ])) : (d(), x(e(F), {
1935
+ key: 1,
1936
+ size: "sm",
1937
+ tone: "muted"
1938
+ }, {
1939
+ default: c(() => [
1940
+ k(w(e(n)("panel.never-sent")), 1)
1941
+ ]),
1942
+ _: 1
1943
+ }))
1944
+ ]),
1945
+ "cell-enabled": c(({ row: f }) => [
1946
+ E("span", {
1947
+ onClick: g[0] || (g[0] = Ke(() => {
1948
+ }, ["stop"]))
1949
+ }, [
1950
+ h(e(Qe), {
1951
+ "model-value": f.enabled,
1952
+ disabled: !W.value,
1953
+ "aria-label": e(n)("panel.enable"),
1954
+ size: "sm",
1955
+ "onUpdate:modelValue": (D) => fe(f, !!D)
1956
+ }, null, 8, ["model-value", "disabled", "aria-label", "onUpdate:modelValue"])
1957
+ ])
1958
+ ]),
1959
+ "cell-actions": c(({ row: f }) => [
1960
+ E("span", {
1961
+ onClick: g[1] || (g[1] = Ke(() => {
1962
+ }, ["stop"]))
1963
+ }, [
1964
+ h(e(Ye), {
1965
+ actions: be(f),
1966
+ label: f.name
1967
+ }, null, 8, ["actions", "label"])
1968
+ ])
1969
+ ]),
1970
+ _: 1
1971
+ }, 8, ["data", "columns", "loading", "empty-text", "aria-label"])) : (d(), x(e(Je), {
1972
+ key: 2,
1973
+ data: ae.value,
1974
+ columns: Ae.value,
1975
+ "row-key": "id",
1976
+ hover: "",
1977
+ flush: "",
1978
+ layout: "fixed",
1979
+ expandable: "",
1980
+ loading: ie.value,
1981
+ "cards-below": 0,
1982
+ "filters-count": We.value,
1983
+ "filters-label": e(n)("panel.filters"),
1984
+ "empty-text": e(n)("panel.log-empty"),
1985
+ "aria-label": e(n)("panel.log"),
1986
+ onStateChange: le
1987
+ }, {
1988
+ filters: c(() => [
1989
+ h(e(ue), {
1990
+ label: e(n)("panel.column-status")
1991
+ }, {
1992
+ default: c(() => [
1993
+ h(e(ce), {
1994
+ modelValue: K.value,
1995
+ "onUpdate:modelValue": g[3] || (g[3] = (f) => K.value = f),
1996
+ options: Ve.value,
1997
+ size: "sm"
1998
+ }, null, 8, ["modelValue", "options"])
1999
+ ]),
2000
+ _: 1
2001
+ }, 8, ["label"]),
2002
+ h(e(ue), {
2003
+ label: e(n)("panel.column-channel")
2004
+ }, {
2005
+ default: c(() => [
2006
+ h(e(ce), {
2007
+ modelValue: G.value,
2008
+ "onUpdate:modelValue": g[4] || (g[4] = (f) => G.value = f),
2009
+ options: Ne.value,
2010
+ size: "sm"
2011
+ }, null, 8, ["modelValue", "options"])
2012
+ ]),
2013
+ _: 1
2014
+ }, 8, ["label"]),
2015
+ h(e(Qe), {
2016
+ modelValue: ee.value,
2017
+ "onUpdate:modelValue": g[5] || (g[5] = (f) => ee.value = f),
2018
+ size: "sm"
2019
+ }, {
2020
+ default: c(() => [
2021
+ k(w(e(n)("panel.with-tests")), 1)
2022
+ ]),
2023
+ _: 1
2024
+ }, 8, ["modelValue"])
2025
+ ]),
2026
+ "cell-created_at": c(({ row: f }) => [
2027
+ h(e(Ze), {
2028
+ value: f.sent_at ?? f.created_at
2029
+ }, null, 8, ["value"])
2030
+ ]),
2031
+ "cell-recipient": c(({ row: f }) => [
2032
+ E("span", zn, [
2033
+ h(e(F), { truncate: "" }, {
2034
+ default: c(() => [
2035
+ k(w(f.recipient_label ?? f.recipient), 1)
2036
+ ]),
2037
+ _: 2
2038
+ }, 1024),
2039
+ h(e(F), {
2040
+ size: "sm",
2041
+ tone: "muted",
2042
+ truncate: ""
2043
+ }, {
2044
+ default: c(() => [
2045
+ k(w(f.event_label ?? f.event), 1)
2046
+ ]),
2047
+ _: 2
2048
+ }, 1024)
2049
+ ])
2050
+ ]),
2051
+ "cell-channel_name": c(({ row: f }) => [
2052
+ h(e(F), {
2053
+ size: "sm",
2054
+ truncate: "",
2055
+ tone: f.channel_id === null ? "muted" : "default"
2056
+ }, {
2057
+ default: c(() => [
2058
+ k(w(f.channel_name) + w(f.channel_id === null ? ` (${e(n)("panel.channel-gone")})` : ""), 1)
2059
+ ]),
2060
+ _: 2
2061
+ }, 1032, ["tone"])
2062
+ ]),
2063
+ "cell-status": c(({ row: f }) => [
2064
+ E("span", jn, [
2065
+ h(e(X), {
2066
+ type: se[f.status],
2067
+ dot: ""
2068
+ }, {
2069
+ default: c(() => [
2070
+ k(w(e(n)(`module.statuses.${f.status}`)), 1)
2071
+ ]),
2072
+ _: 2
2073
+ }, 1032, ["type"]),
2074
+ f.is_test ? (d(), x(e(X), { key: 0 }, {
2075
+ default: c(() => [
2076
+ k(w(e(n)("panel.test-mark")), 1)
2077
+ ]),
2078
+ _: 1
2079
+ })) : M("", !0)
2080
+ ])
2081
+ ]),
2082
+ "cell-attempts": c(({ row: f }) => [
2083
+ h(e(F), { size: "sm" }, {
2084
+ default: c(() => [
2085
+ k(w(f.attempts), 1)
2086
+ ]),
2087
+ _: 2
2088
+ }, 1024)
2089
+ ]),
2090
+ "cell-actions": c(({ row: f }) => [
2091
+ h(e(Ye), {
2092
+ actions: ze(f),
2093
+ label: f.recipient
2094
+ }, null, 8, ["actions", "label"])
2095
+ ]),
2096
+ expanded: c(({ row: f }) => [
2097
+ E("div", On, [
2098
+ oe(f) ? (d(), x(e(F), {
2099
+ key: 0,
2100
+ size: "sm",
2101
+ tone: f.status === "failed" ? "danger" : "muted"
2102
+ }, {
2103
+ default: c(() => [
2104
+ k(w(oe(f)), 1)
2105
+ ]),
2106
+ _: 2
2107
+ }, 1032, ["tone"])) : M("", !0),
2108
+ f.unknown_variables.length > 0 ? (d(), x(e(F), {
2109
+ key: 1,
2110
+ size: "sm",
2111
+ tone: "muted"
2112
+ }, {
2113
+ default: c(() => [
2114
+ k(w(e(n)("panel.unknown-variables", { names: f.unknown_variables.join(", ") })), 1)
2115
+ ]),
2116
+ _: 2
2117
+ }, 1024)) : M("", !0),
2118
+ f.truncated ? (d(), x(e(F), {
2119
+ key: 2,
2120
+ size: "sm",
2121
+ tone: "muted"
2122
+ }, {
2123
+ default: c(() => [
2124
+ k(w(e(n)("panel.cut-mark")), 1)
2125
+ ]),
2126
+ _: 1
2127
+ })) : M("", !0),
2128
+ h(e(F), {
2129
+ size: "sm",
2130
+ tone: "muted",
2131
+ mono: ""
2132
+ }, {
2133
+ default: c(() => [
2134
+ k(w(f.recipient), 1)
2135
+ ]),
2136
+ _: 2
2137
+ }, 1024)
2138
+ ])
2139
+ ]),
2140
+ _: 1
2141
+ }, 8, ["data", "columns", "loading", "filters-count", "filters-label", "empty-text", "aria-label"]))
2142
+ ]),
2143
+ _: 1
2144
+ }, 8, ["view", "title", "views", "actions"]));
2145
+ }
2146
+ }), Mn = /* @__PURE__ */ Y(Fn, [["__scopeId", "data-v-69806e68"]]), Pn = { class: "wx-notifications-template" }, Un = { class: "wx-notifications-template__variables" }, En = { class: "wx-notifications-template__chips" }, Ln = { class: "wx-notifications-template__name" }, Bn = /* @__PURE__ */ R({
2147
+ name: "WxNotificationsTemplateField",
2148
+ __name: "TemplateField",
2149
+ props: /* @__PURE__ */ ke({
2150
+ localized: { type: Boolean, default: !1 },
2151
+ disabled: { type: Boolean, default: void 0 },
2152
+ minHeight: { default: "200px" }
2153
+ }, {
2154
+ modelValue: { default: "" },
2155
+ modelModifiers: {}
2156
+ }),
2157
+ emits: ["update:modelValue"],
2158
+ setup(l) {
2159
+ const t = l, i = _e(l, "modelValue");
2160
+ H();
2161
+ const s = q("webx-notifications"), a = $e(), o = Le(), n = V(null), u = _(() => gn(a.event.value)), W = _(
2162
+ () => a.provider.value?.key === "telegram" ? "mustache-html" : "mustache"
2163
+ ), $ = _(
2164
+ () => $t(u.value, {
2165
+ variable: s("panel.hint-variable"),
2166
+ list: s("panel.hint-list"),
2167
+ field: s("panel.hint-field"),
2168
+ section: s("panel.hint-section"),
2169
+ inverted: s("panel.hint-inverted"),
2170
+ close: s("panel.hint-close"),
2171
+ comment: s("panel.hint-comment"),
2172
+ example: s("panel.hint-example")
2173
+ })
2174
+ ), S = _(() => {
2175
+ const C = i.value;
2176
+ if (C == null) return "";
2177
+ if (typeof C == "string") return C;
2178
+ const p = o.active.value || o.list.value[0]?.code || "";
2179
+ return C[p] ?? "";
2180
+ }), b = _(
2181
+ () => Ct(S.value, a.event.value === null ? void 0 : u.value)
2182
+ ), y = _(() => {
2183
+ const C = b.value;
2184
+ return [
2185
+ ...C.unclosed.map((p) => s("panel.problem-unclosed", { name: p })),
2186
+ ...C.stray.map((p) => s("panel.problem-stray", { name: p })),
2187
+ ...C.refused.map((p) => s("panel.problem-refused", { tag: p })),
2188
+ ...C.broken ? [s("panel.problem-broken")] : [],
2189
+ ...C.unknown.length > 0 ? [
2190
+ s("panel.problem-unknown", {
2191
+ names: C.unknown.map((p) => `{{${p}}}`).join(", ")
2192
+ })
2193
+ ] : []
2194
+ ];
2195
+ });
2196
+ function A(C) {
2197
+ if ((C.fields?.length ?? 0) > 0)
2198
+ return s("panel.variable-list", {
2199
+ fields: (C.fields ?? []).map((v) => v.name).join(", ")
2200
+ });
2201
+ const p = C.example;
2202
+ return typeof p == "string" || typeof p == "number" ? String(p) : "";
2203
+ }
2204
+ function z(C) {
2205
+ const p = n.value?.view;
2206
+ if (!p) return;
2207
+ const v = p.state.selection.main;
2208
+ p.dispatch({
2209
+ changes: { from: v.from, to: v.to, insert: C },
2210
+ selection: { anchor: v.from + C.length },
2211
+ scrollIntoView: !0
2212
+ }), p.focus();
2213
+ }
2214
+ return (C, p) => (d(), j("div", Pn, [
2215
+ h(e(Tt), {
2216
+ ref_key: "editor",
2217
+ ref: n,
2218
+ modelValue: i.value,
2219
+ "onUpdate:modelValue": p[0] || (p[0] = (v) => i.value = v),
2220
+ language: W.value,
2221
+ completions: $.value,
2222
+ localized: t.localized,
2223
+ disabled: t.disabled,
2224
+ "line-numbers": !1,
2225
+ "line-wrapping": "",
2226
+ "min-height": t.minHeight
2227
+ }, null, 8, ["modelValue", "language", "completions", "localized", "disabled", "min-height"]),
2228
+ (d(!0), j(B, null, Q(y.value, (v) => (d(), x(e(L), {
2229
+ key: v,
2230
+ type: "warning",
2231
+ variant: "soft",
2232
+ description: v
2233
+ }, null, 8, ["description"]))), 128)),
2234
+ E("div", Un, [
2235
+ h(e(F), {
2236
+ size: "sm",
2237
+ weight: "medium"
2238
+ }, {
2239
+ default: c(() => [
2240
+ k(w(e(s)("panel.variables")), 1)
2241
+ ]),
2242
+ _: 1
2243
+ }),
2244
+ u.value.length === 0 ? (d(), x(e(F), {
2245
+ key: 0,
2246
+ size: "sm",
2247
+ tone: "muted"
2248
+ }, {
2249
+ default: c(() => [
2250
+ k(w(e(s)("panel.variables-none")), 1)
2251
+ ]),
2252
+ _: 1
2253
+ })) : (d(), j(B, { key: 1 }, [
2254
+ h(e(F), {
2255
+ size: "sm",
2256
+ tone: "muted"
2257
+ }, {
2258
+ default: c(() => [
2259
+ k(w(e(s)("panel.variables-help")), 1)
2260
+ ]),
2261
+ _: 1
2262
+ }),
2263
+ E("div", En, [
2264
+ (d(!0), j(B, null, Q(u.value, (v) => (d(), x(e(St), {
2265
+ key: v.name,
2266
+ content: [v.label, A(v)].filter(Boolean).join(" — ")
2267
+ }, {
2268
+ default: c(() => [
2269
+ h(e(U), {
2270
+ size: "sm",
2271
+ variant: "outline",
2272
+ class: "wx-notifications-template__chip",
2273
+ disabled: t.disabled,
2274
+ onClick: (T) => z(e(wn)(v))
2275
+ }, {
2276
+ default: c(() => [
2277
+ E("span", Ln, w((v.fields?.length ?? 0) > 0 ? `#${v.name}` : v.name), 1)
2278
+ ]),
2279
+ _: 2
2280
+ }, 1032, ["disabled", "onClick"])
2281
+ ]),
2282
+ _: 2
2283
+ }, 1032, ["content"]))), 128))
2284
+ ])
2285
+ ], 64))
2286
+ ])
2287
+ ]));
2288
+ }
2289
+ }), Dn = /* @__PURE__ */ Y(Bn, [["__scopeId", "data-v-29c287ae"]]);
2290
+ function Gn(l = {}) {
2291
+ const t = l.path ?? "/notifications";
2292
+ return {
2293
+ id: "notifications",
2294
+ path: t,
2295
+ routes: [
2296
+ { path: t, name: "webx.notifications", component: Mn, props: { base: t } },
2297
+ {
2298
+ path: `${t}/channels/new`,
2299
+ name: "webx.notifications.new",
2300
+ component: it,
2301
+ props: { base: t }
2302
+ },
2303
+ {
2304
+ path: `${t}/channels/:id(\\d+)`,
2305
+ name: "webx.notifications.channel",
2306
+ component: it,
2307
+ props: { base: t }
2308
+ }
2309
+ ],
2310
+ types: {
2311
+ "wx-notifications-template": { component: Dn, kind: "field", wide: !0 },
2312
+ "wx-notifications-chats": { component: xn, kind: "field" },
2313
+ "wx-notifications-emails": { component: Tn, kind: "field" },
2314
+ "wx-notifications-channels": {
2315
+ component: fn,
2316
+ kind: "field",
2317
+ bind: (i) => ({ event: i.props?.event, base: t })
2318
+ }
2319
+ }
2320
+ };
2321
+ }
2322
+ export {
2323
+ Mt as NOTIFICATIONS_API,
2324
+ J as TemplateRefusal,
2325
+ fn as WxNotificationChannelsField,
2326
+ it as WxNotificationsChannelPage,
2327
+ xn as WxNotificationsChatsField,
2328
+ Tn as WxNotificationsEmailsField,
2329
+ Mn as WxNotificationsPage,
2330
+ rn as WxNotificationsPreview,
2331
+ Dn as WxNotificationsTemplateField,
2332
+ dt as addresseesOf,
2333
+ ve as createNotificationsApi,
2334
+ Dt as escapeFor,
2335
+ Bt as escapeHtml,
2336
+ Jt as examplesOf,
2337
+ Gn as notifications,
2338
+ Et as notificationsMessages,
2339
+ Ut as provideChannel,
2340
+ Xt as renderMessage,
2341
+ lt as renderTemplate,
2342
+ wn as snippetOf,
2343
+ Zt as telegramHtml,
2344
+ $e as useChannel,
2345
+ gn as variablesOf
2346
+ };
2347
+ //# sourceMappingURL=index.js.map