@webx-ui/module-inbox 0.7.0 → 0.8.1

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.
@@ -0,0 +1,786 @@
1
+ import { defineComponent as K, useModel as Q, computed as y, openBlock as v, createBlock as W, unref as e, withCtx as t, createVNode as l, isRef as A, createTextVNode as V, toDisplayString as x, createCommentVNode as T, mergeModels as ae, createElementBlock as L, createElementVNode as E, ref as q, onMounted as ce, Fragment as se, renderList as fe, reactive as be, watch as ve } from "vue";
2
+ import { useRouter as ue, useRoute as xe } from "vue-router";
3
+ import { useTranslate as G, useAdmin as ne, WxRelationsField as ye, useErrorText as _e, WxScreenHead as ge } from "@webx-ui/module-admin";
4
+ import { WxCard as N, WxFormItem as C, WxSwitch as de, WxInputNumber as ie, WxSelect as le, WxText as I, WxAlert as oe, WxAction as H, WxTable as he, toast as P, WxInput as R, WxSpace as Ve, WxButton as te, WxIcon as ke, WxLink as we, confirm as $e, useLocales as Ue, localizedValue as We, WxSkeleton as ze, WxBadge as Fe, WxTabs as Se, WxTab as O, WxActionBar as Ce } from "@webx-ui/core";
5
+ import { o as B, u as re, _ as X, a as Te, c as pe, F as Ae } from "./index-BQj2UlUS.js";
6
+ const Be = /* @__PURE__ */ K({
7
+ __name: "FormAntispam",
8
+ props: /* @__PURE__ */ ae({
9
+ site: {}
10
+ }, {
11
+ modelValue: { required: !0 },
12
+ modelModifiers: {}
13
+ }),
14
+ emits: ["update:modelValue"],
15
+ setup(m) {
16
+ const d = Q(m, "modelValue"), i = m, n = G("webx-inbox"), k = B(d, "antispam.honeypot", !0), s = B(d, "antispam.min_seconds", 3), $ = B(d, "antispam.throttle", 5), o = B(d, "antispam.captcha", "off"), z = y(() => [
17
+ { value: "off", label: n("panel.captcha-off") },
18
+ { value: "recaptcha", label: n("panel.captcha-recaptcha") },
19
+ { value: "turnstile", label: n("panel.captcha-turnstile") }
20
+ ]), a = y(() => {
21
+ const _ = o.value;
22
+ return _ !== "recaptcha" && _ !== "turnstile" ? null : { provider: _, site: i.site?.[_] ?? null };
23
+ }), p = y(() => {
24
+ const _ = a.value?.site;
25
+ return _ ? n(`panel.captcha-${a.value.provider}-${_.type}`) : null;
26
+ });
27
+ return (_, c) => (v(), W(e(N), null, {
28
+ default: t(() => [
29
+ l(e(C), {
30
+ help: e(n)("panel.honeypot-help")
31
+ }, {
32
+ default: t(() => [
33
+ l(e(de), {
34
+ modelValue: e(k),
35
+ "onUpdate:modelValue": c[0] || (c[0] = (f) => A(k) ? k.value = f : null),
36
+ label: e(n)("panel.honeypot")
37
+ }, null, 8, ["modelValue", "label"])
38
+ ]),
39
+ _: 1
40
+ }, 8, ["help"]),
41
+ l(e(C), {
42
+ label: e(n)("panel.min-seconds"),
43
+ help: e(n)("panel.min-seconds-help")
44
+ }, {
45
+ default: t(() => [
46
+ l(e(ie), {
47
+ modelValue: e(s),
48
+ "onUpdate:modelValue": c[1] || (c[1] = (f) => A(s) ? s.value = f : null),
49
+ min: 0,
50
+ max: 120
51
+ }, null, 8, ["modelValue"])
52
+ ]),
53
+ _: 1
54
+ }, 8, ["label", "help"]),
55
+ l(e(C), {
56
+ label: e(n)("panel.throttle"),
57
+ help: e(n)("panel.throttle-help")
58
+ }, {
59
+ default: t(() => [
60
+ l(e(ie), {
61
+ modelValue: e($),
62
+ "onUpdate:modelValue": c[2] || (c[2] = (f) => A($) ? $.value = f : null),
63
+ min: 0,
64
+ max: 120
65
+ }, null, 8, ["modelValue"])
66
+ ]),
67
+ _: 1
68
+ }, 8, ["label", "help"]),
69
+ l(e(C), {
70
+ label: e(n)("panel.captcha"),
71
+ help: e(n)("panel.captcha-keys")
72
+ }, {
73
+ default: t(() => [
74
+ l(e(le), {
75
+ modelValue: e(o),
76
+ "onUpdate:modelValue": c[3] || (c[3] = (f) => A(o) ? o.value = f : null),
77
+ options: z.value
78
+ }, null, 8, ["modelValue", "options"])
79
+ ]),
80
+ _: 1
81
+ }, 8, ["label", "help"]),
82
+ p.value ? (v(), W(e(I), {
83
+ key: 0,
84
+ size: "sm",
85
+ tone: "muted"
86
+ }, {
87
+ default: t(() => [
88
+ V(x(p.value), 1)
89
+ ]),
90
+ _: 1
91
+ })) : T("", !0),
92
+ a.value?.site && !a.value.site.configured ? (v(), W(e(oe), {
93
+ key: 1,
94
+ type: "warning",
95
+ variant: "soft",
96
+ closable: !1,
97
+ description: e(n)("panel.captcha-unconfigured")
98
+ }, null, 8, ["description"])) : T("", !0)
99
+ ]),
100
+ _: 1
101
+ }));
102
+ }
103
+ }), Ie = { class: "wx-inbox-embed" }, Ne = { class: "wx-inbox-embed__snippet" }, Ee = { class: "wx-inbox-embed__snippet" }, Me = { class: "wx-inbox-embed__snippet" }, qe = /* @__PURE__ */ K({
104
+ __name: "FormEmbed",
105
+ props: {
106
+ form: {},
107
+ slug: {},
108
+ fields: {}
109
+ },
110
+ setup(m) {
111
+ const d = m;
112
+ re();
113
+ const i = G("webx-inbox"), n = ne(), k = y(
114
+ () => n.state.manifest?.modules.some((c) => c.id === "blocks") ?? !1
115
+ ), s = y(() => `<x-webx-inbox::form slug="${d.slug}" />`), $ = y(
116
+ () => k.value ? s.value : `{{-- resources/views/blocks/contact.blade.php --}}
117
+ <x-webx-inbox::form slug="${d.slug}" />`
118
+ ), o = y(
119
+ () => d.fields.find((c) => c.type === "hidden" && c.is_enabled)?.key ?? "page"
120
+ ), z = y(
121
+ () => `<x-webx-inbox::form slug="${d.slug}" :values="['${o.value}' => url()->current()]" />
122
+ <x-webx-inbox::form slug="${d.slug}" placement="footer" />`
123
+ ), a = y(() => [
124
+ { key: "key", label: i("fields.name") },
125
+ { key: "title", label: i("fields.title") },
126
+ { key: "type", label: i("fields.type"), hideBelow: 520 }
127
+ ]), p = y(() => d.fields.filter((c) => c.is_enabled));
128
+ async function _(c) {
129
+ try {
130
+ await navigator.clipboard.writeText(c), P.success(i("panel.copied"));
131
+ } catch {
132
+ }
133
+ }
134
+ return (c, f) => (v(), L("div", Ie, [
135
+ l(e(N), {
136
+ title: e(i)("panel.embed-blade")
137
+ }, {
138
+ default: t(() => [
139
+ l(e(I), {
140
+ size: "sm",
141
+ tone: "muted"
142
+ }, {
143
+ default: t(() => [
144
+ V(x(e(i)("panel.embed-blade-help")), 1)
145
+ ]),
146
+ _: 1
147
+ }),
148
+ E("div", Ne, [
149
+ E("code", null, x(s.value), 1),
150
+ l(e(H), {
151
+ icon: "copy",
152
+ title: e(i)("panel.copy"),
153
+ onClick: f[0] || (f[0] = (r) => _(s.value))
154
+ }, null, 8, ["title"])
155
+ ])
156
+ ]),
157
+ _: 1
158
+ }, 8, ["title"]),
159
+ l(e(N), {
160
+ title: e(i)("panel.embed-block")
161
+ }, {
162
+ default: t(() => [
163
+ l(e(I), {
164
+ size: "sm",
165
+ tone: "muted"
166
+ }, {
167
+ default: t(() => [
168
+ V(x(e(i)(k.value ? "panel.embed-block-panel-help" : "panel.embed-block-help")), 1)
169
+ ]),
170
+ _: 1
171
+ }),
172
+ E("div", Ee, [
173
+ E("code", null, x($.value), 1),
174
+ l(e(H), {
175
+ icon: "copy",
176
+ title: e(i)("panel.copy"),
177
+ onClick: f[1] || (f[1] = (r) => _($.value))
178
+ }, null, 8, ["title"])
179
+ ])
180
+ ]),
181
+ _: 1
182
+ }, 8, ["title"]),
183
+ l(e(N), {
184
+ title: e(i)("panel.embed-extras")
185
+ }, {
186
+ default: t(() => [
187
+ l(e(I), {
188
+ size: "sm",
189
+ tone: "muted"
190
+ }, {
191
+ default: t(() => [
192
+ V(x(e(i)("panel.embed-extras-help")), 1)
193
+ ]),
194
+ _: 1
195
+ }),
196
+ E("div", Me, [
197
+ E("code", null, x(z.value), 1),
198
+ l(e(H), {
199
+ icon: "copy",
200
+ title: e(i)("panel.copy"),
201
+ onClick: f[2] || (f[2] = (r) => _(z.value))
202
+ }, null, 8, ["title"])
203
+ ])
204
+ ]),
205
+ _: 1
206
+ }, 8, ["title"]),
207
+ l(e(N), {
208
+ title: e(i)("panel.embed-names")
209
+ }, {
210
+ default: t(() => [
211
+ l(e(I), {
212
+ size: "sm",
213
+ tone: "muted"
214
+ }, {
215
+ default: t(() => [
216
+ V(x(e(i)("panel.embed-names-help")), 1)
217
+ ]),
218
+ _: 1
219
+ }),
220
+ l(e(he), {
221
+ data: p.value,
222
+ columns: a.value,
223
+ "row-key": "id",
224
+ flush: "",
225
+ "empty-text": e(i)("fields.no-fields")
226
+ }, {
227
+ "cell-key": t(({ row: r }) => [
228
+ l(e(I), {
229
+ mono: "",
230
+ size: "sm"
231
+ }, {
232
+ default: t(() => [
233
+ V("fields[" + x(r.key) + "]", 1)
234
+ ]),
235
+ _: 2
236
+ }, 1024)
237
+ ]),
238
+ "cell-title": t(({ row: r }) => [
239
+ V(x(Object.values(r.title)[0] ?? r.key), 1)
240
+ ]),
241
+ "cell-type": t(({ row: r }) => [
242
+ V(x(e(i)(`fields.type-${r.type}`)), 1)
243
+ ]),
244
+ _: 1
245
+ }, 8, ["data", "columns", "empty-text"])
246
+ ]),
247
+ _: 1
248
+ }, 8, ["title"])
249
+ ]));
250
+ }
251
+ }), Le = /* @__PURE__ */ X(qe, [["__scopeId", "data-v-7f9788ed"]]), Re = { class: "wx-inbox-general" }, De = /* @__PURE__ */ K({
252
+ __name: "FormGeneral",
253
+ props: /* @__PURE__ */ ae({
254
+ errors: {}
255
+ }, {
256
+ settings: { required: !0 },
257
+ settingsModifiers: {},
258
+ options: { required: !0 },
259
+ optionsModifiers: {}
260
+ }),
261
+ emits: ["update:settings", "update:options"],
262
+ setup(m) {
263
+ const d = Q(
264
+ m,
265
+ "settings"
266
+ ), i = Q(m, "options"), n = G("webx-inbox"), k = B(i, "thank-you.heading", {}), s = B(i, "thank-you.text", {}), $ = B(i, "design.submit-text", {}), o = B(i, "redirect", "");
267
+ return (z, a) => (v(), L("div", Re, [
268
+ l(e(N), null, {
269
+ default: t(() => [
270
+ l(e(C), {
271
+ label: e(n)("panel.title"),
272
+ error: m.errors.title?.[0],
273
+ required: ""
274
+ }, {
275
+ default: t(() => [
276
+ l(e(R), {
277
+ modelValue: d.value.title,
278
+ "onUpdate:modelValue": a[0] || (a[0] = (p) => d.value.title = p),
279
+ localized: ""
280
+ }, null, 8, ["modelValue"])
281
+ ]),
282
+ _: 1
283
+ }, 8, ["label", "error"]),
284
+ l(e(C), {
285
+ label: e(n)("panel.slug"),
286
+ help: e(n)("panel.slug-help"),
287
+ error: m.errors.slug?.[0],
288
+ required: ""
289
+ }, {
290
+ default: t(() => [
291
+ l(e(R), {
292
+ modelValue: d.value.slug,
293
+ "onUpdate:modelValue": a[1] || (a[1] = (p) => d.value.slug = p),
294
+ placeholder: "contact"
295
+ }, null, 8, ["modelValue"])
296
+ ]),
297
+ _: 1
298
+ }, 8, ["label", "help", "error"]),
299
+ l(e(C), {
300
+ help: e(n)("panel.is-enabled-help")
301
+ }, {
302
+ default: t(() => [
303
+ l(e(de), {
304
+ modelValue: d.value.is_enabled,
305
+ "onUpdate:modelValue": a[2] || (a[2] = (p) => d.value.is_enabled = p),
306
+ label: e(n)("panel.is-enabled")
307
+ }, null, 8, ["modelValue", "label"])
308
+ ]),
309
+ _: 1
310
+ }, 8, ["help"])
311
+ ]),
312
+ _: 1
313
+ }),
314
+ l(e(N), {
315
+ title: e(n)("panel.after-sending")
316
+ }, {
317
+ default: t(() => [
318
+ l(e(C), {
319
+ label: e(n)("panel.submit-text")
320
+ }, {
321
+ default: t(() => [
322
+ l(e(R), {
323
+ modelValue: e($),
324
+ "onUpdate:modelValue": a[3] || (a[3] = (p) => A($) ? $.value = p : null),
325
+ localized: ""
326
+ }, null, 8, ["modelValue"])
327
+ ]),
328
+ _: 1
329
+ }, 8, ["label"]),
330
+ l(e(C), {
331
+ label: e(n)("panel.thank-you-heading")
332
+ }, {
333
+ default: t(() => [
334
+ l(e(R), {
335
+ modelValue: e(k),
336
+ "onUpdate:modelValue": a[4] || (a[4] = (p) => A(k) ? k.value = p : null),
337
+ localized: ""
338
+ }, null, 8, ["modelValue"])
339
+ ]),
340
+ _: 1
341
+ }, 8, ["label"]),
342
+ l(e(C), {
343
+ label: e(n)("panel.thank-you-text")
344
+ }, {
345
+ default: t(() => [
346
+ l(Te, {
347
+ modelValue: e(s),
348
+ "onUpdate:modelValue": a[5] || (a[5] = (p) => A(s) ? s.value = p : null)
349
+ }, null, 8, ["modelValue"])
350
+ ]),
351
+ _: 1
352
+ }, 8, ["label"]),
353
+ l(e(C), {
354
+ label: e(n)("panel.redirect"),
355
+ help: e(n)("panel.redirect-help")
356
+ }, {
357
+ default: t(() => [
358
+ l(e(R), {
359
+ modelValue: e(o),
360
+ "onUpdate:modelValue": a[6] || (a[6] = (p) => A(o) ? o.value = p : null),
361
+ placeholder: "/thank-you"
362
+ }, null, 8, ["modelValue"])
363
+ ]),
364
+ _: 1
365
+ }, 8, ["label", "help"])
366
+ ]),
367
+ _: 1
368
+ }, 8, ["title"])
369
+ ]));
370
+ }
371
+ }), Oe = /* @__PURE__ */ X(De, [["__scopeId", "data-v-1932aefe"]]), Pe = /^[^\s@]+@[^\s@]+$/;
372
+ function J(m) {
373
+ return "admin_id" in m;
374
+ }
375
+ function me(m, d = []) {
376
+ return J(m) ? d.find(
377
+ (n) => n.type === "admin" && n.admin_id === m.admin_id
378
+ )?.problem ?? null : Pe.test((m.email ?? "").trim()) ? null : "invalid_email";
379
+ }
380
+ function Ke(m, d = []) {
381
+ return (m ?? []).some((i) => me(i, d) === null);
382
+ }
383
+ const Ge = { class: "wx-inbox-notifications" }, je = { class: "wx-inbox-recipients" }, He = { class: "wx-inbox-recipients__row" }, Je = { class: "wx-inbox-channels" }, Qe = /* @__PURE__ */ K({
384
+ __name: "FormNotifications",
385
+ props: /* @__PURE__ */ ae({
386
+ fields: {},
387
+ errors: {},
388
+ reported: {},
389
+ notifications: { type: Boolean }
390
+ }, {
391
+ modelValue: { required: !0 },
392
+ modelModifiers: {}
393
+ }),
394
+ emits: ["update:modelValue"],
395
+ setup(m) {
396
+ const d = m, i = Q(m, "modelValue"), n = ne(), k = pe(n), s = G("webx-inbox"), $ = q([]), o = B(i, "recipients", []), z = B(i, "email_field", ""), a = B(i, "notify_channels", []), p = ue(), _ = y(() => n.can("notifications.manage")), c = y(() => `${n.basePath}/notifications`.replace(/\/{2,}/g, "/"));
397
+ function f(u) {
398
+ u.metaKey || u.ctrlKey || u.shiftKey || u.button !== 0 || (u.preventDefault(), p.push("/notifications"));
399
+ }
400
+ ce(async () => {
401
+ try {
402
+ $.value = await k.recipients();
403
+ } catch {
404
+ }
405
+ });
406
+ const r = y(
407
+ () => $.value.map((u) => ({ value: u.id, label: `${u.name} · ${u.email}` }))
408
+ ), F = y(() => [
409
+ { value: "", label: s("panel.no-email-field") },
410
+ ...d.fields.filter((u) => u.type === "email").map((u) => ({ value: u.key, label: u.key }))
411
+ ]);
412
+ function Y(u) {
413
+ if (!J(u)) return null;
414
+ const b = me(u, d.reported);
415
+ return b === null ? null : s(`panel.recipient-${b}`);
416
+ }
417
+ function D(u) {
418
+ o.value = [...o.value, u];
419
+ }
420
+ async function Z(u) {
421
+ const b = o.value[u];
422
+ b !== void 0 && (J(b) || (b.email ?? "").trim() !== "") && !await $e({
423
+ title: s("panel.remove-recipient-title"),
424
+ message: s("panel.remove-recipient-text"),
425
+ confirmText: s("panel.remove"),
426
+ cancelText: s("panel.cancel"),
427
+ tone: "danger"
428
+ }) || (o.value = o.value.filter((S, M) => M !== u));
429
+ }
430
+ function ee(u, b) {
431
+ o.value = o.value.map((g, S) => S === u ? { admin_id: b } : g);
432
+ }
433
+ function j(u, b) {
434
+ o.value = o.value.map((g, S) => S === u ? { email: b } : g);
435
+ }
436
+ return (u, b) => (v(), L("div", Ge, [
437
+ l(e(N), {
438
+ title: e(s)("panel.recipients")
439
+ }, {
440
+ default: t(() => [
441
+ l(e(I), {
442
+ size: "sm",
443
+ tone: "muted"
444
+ }, {
445
+ default: t(() => [
446
+ V(x(e(s)("panel.recipients-help")), 1)
447
+ ]),
448
+ _: 1
449
+ }),
450
+ m.errors["options.recipients"] ? (v(), W(e(oe), {
451
+ key: 0,
452
+ type: "danger",
453
+ variant: "soft",
454
+ description: m.errors["options.recipients"]?.[0]
455
+ }, null, 8, ["description"])) : T("", !0),
456
+ E("div", je, [
457
+ e(o).length === 0 ? (v(), W(e(I), {
458
+ key: 0,
459
+ size: "sm",
460
+ tone: "placeholder"
461
+ }, {
462
+ default: t(() => [
463
+ V(x(e(s)("panel.no-recipients")), 1)
464
+ ]),
465
+ _: 1
466
+ })) : T("", !0),
467
+ (v(!0), L(se, null, fe(e(o), (g, S) => (v(), L("div", {
468
+ key: S,
469
+ class: "wx-inbox-recipients__item"
470
+ }, [
471
+ E("div", He, [
472
+ e(J)(g) ? (v(), W(e(le), {
473
+ key: 0,
474
+ "model-value": g.admin_id,
475
+ options: r.value,
476
+ "onUpdate:modelValue": (M) => ee(S, Number(M))
477
+ }, null, 8, ["model-value", "options", "onUpdate:modelValue"])) : (v(), W(e(R), {
478
+ key: 1,
479
+ "model-value": g.email,
480
+ type: "email",
481
+ placeholder: "sales@example.com",
482
+ "onUpdate:modelValue": (M) => j(S, String(M))
483
+ }, null, 8, ["model-value", "onUpdate:modelValue"])),
484
+ l(e(H), {
485
+ icon: "trash",
486
+ tone: "danger",
487
+ title: e(s)("panel.remove"),
488
+ onClick: (M) => Z(S)
489
+ }, null, 8, ["title", "onClick"])
490
+ ]),
491
+ Y(g) ? (v(), W(e(I), {
492
+ key: 0,
493
+ size: "sm",
494
+ tone: "danger"
495
+ }, {
496
+ default: t(() => [
497
+ V(x(Y(g)), 1)
498
+ ]),
499
+ _: 2
500
+ }, 1024)) : T("", !0)
501
+ ]))), 128))
502
+ ]),
503
+ l(e(Ve), { size: "sm" }, {
504
+ default: t(() => [
505
+ l(e(te), {
506
+ variant: "outline",
507
+ icon: "user",
508
+ disabled: r.value.length === 0,
509
+ onClick: b[0] || (b[0] = (g) => D({ admin_id: Number(r.value[0]?.value) }))
510
+ }, {
511
+ default: t(() => [
512
+ V(x(e(s)("panel.add-admin")), 1)
513
+ ]),
514
+ _: 1
515
+ }, 8, ["disabled"]),
516
+ l(e(te), {
517
+ variant: "outline",
518
+ onClick: b[1] || (b[1] = (g) => D({ email: "" }))
519
+ }, {
520
+ icon: t(() => [
521
+ l(e(ke), { name: "mail" })
522
+ ]),
523
+ default: t(() => [
524
+ V(" " + x(e(s)("panel.add-email")), 1)
525
+ ]),
526
+ _: 1
527
+ })
528
+ ]),
529
+ _: 1
530
+ }),
531
+ l(e(C), {
532
+ label: e(s)("panel.email-field"),
533
+ help: e(s)("panel.email-field-help"),
534
+ error: m.errors["options.email_field"]?.[0]
535
+ }, {
536
+ default: t(() => [
537
+ l(e(le), {
538
+ modelValue: e(z),
539
+ "onUpdate:modelValue": b[2] || (b[2] = (g) => A(z) ? z.value = g : null),
540
+ options: F.value
541
+ }, null, 8, ["modelValue", "options"])
542
+ ]),
543
+ _: 1
544
+ }, 8, ["label", "help", "error"])
545
+ ]),
546
+ _: 1
547
+ }, 8, ["title"]),
548
+ d.notifications ? (v(), W(e(N), {
549
+ key: 0,
550
+ title: e(s)("panel.notify-through")
551
+ }, {
552
+ default: t(() => [
553
+ l(e(I), {
554
+ size: "sm",
555
+ tone: "muted"
556
+ }, {
557
+ default: t(() => [
558
+ V(x(e(s)("panel.notify-through-help")), 1)
559
+ ]),
560
+ _: 1
561
+ }),
562
+ E("div", Je, [
563
+ l(e(ye), {
564
+ modelValue: e(a),
565
+ "onUpdate:modelValue": b[3] || (b[3] = (g) => A(a) ? a.value = g : null),
566
+ target: "notify-inbox-submission",
567
+ sortable: !1,
568
+ "add-text": e(s)("panel.pick-channels"),
569
+ "empty-text": e(s)("panel.no-channels")
570
+ }, null, 8, ["modelValue", "add-text", "empty-text"]),
571
+ _.value ? (v(), W(e(we), {
572
+ key: 0,
573
+ href: c.value,
574
+ size: "sm",
575
+ onClick: f
576
+ }, {
577
+ default: t(() => [
578
+ V(x(e(s)("panel.set-up-channels")), 1)
579
+ ]),
580
+ _: 1
581
+ }, 8, ["href"])) : T("", !0)
582
+ ])
583
+ ]),
584
+ _: 1
585
+ }, 8, ["title"])) : T("", !0)
586
+ ]));
587
+ }
588
+ }), Xe = /* @__PURE__ */ X(Qe, [["__scopeId", "data-v-ee478a8e"]]), Ye = { class: "wx-inbox-editor" }, Ze = /* @__PURE__ */ K({
589
+ __name: "FormEditorPage",
590
+ props: {
591
+ base: { default: "/inbox" }
592
+ },
593
+ setup(m) {
594
+ const d = m, i = ne(), n = pe(i), k = xe(), s = ue(), $ = Ue();
595
+ re();
596
+ const o = G("webx-inbox"), z = _e(), a = q(null), p = q([]), _ = q(!0), c = q(!1), f = q({});
597
+ let r = be({
598
+ slug: "",
599
+ title: {},
600
+ is_enabled: !0
601
+ });
602
+ const F = q({}), D = q(["general", "fields", "notifications", "antispam", "embed"].includes(String(k.query.tab)) ? String(k.query.tab) : "general"), Z = y(
603
+ () => r.is_enabled && !Ke(F.value.recipients, a.value?.recipients) && !ee.value
604
+ ), ee = y(() => {
605
+ if (a.value?.notifications !== !0) return !1;
606
+ const w = a.value.channels ?? [];
607
+ return (F.value.notify_channels ?? []).some(
608
+ (h) => w.find((U) => U.id === h)?.sends ?? !0
609
+ );
610
+ }), j = y(() => i.can("inbox.manage")), u = y(() => Number(k.params.id)), b = y(
611
+ () => a.value === null ? "" : We(r.title, $.active.value, r.slug)
612
+ ), g = y(() => `${d.base}?form=${u.value}`);
613
+ async function S() {
614
+ _.value = !0;
615
+ try {
616
+ const w = await n.form(u.value);
617
+ a.value = w, p.value = w.fields ?? [], r.slug = w.slug, r.title = { ...w.title }, r.is_enabled = w.is_enabled, F.value = { ...w.options };
618
+ } catch (w) {
619
+ P.danger(z(w)), s.replace(d.base);
620
+ } finally {
621
+ _.value = !1;
622
+ }
623
+ }
624
+ ve(u, () => {
625
+ S();
626
+ }, { immediate: !0 });
627
+ async function M() {
628
+ c.value = !0, f.value = {};
629
+ try {
630
+ const w = await n.saveForm(u.value, {
631
+ slug: r.slug.trim(),
632
+ title: r.title,
633
+ is_enabled: r.is_enabled,
634
+ options: F.value
635
+ });
636
+ a.value = w, P.success(o("panel.saved"));
637
+ } catch (w) {
638
+ const h = w.body;
639
+ h?.errors ? (f.value = h.errors, P.danger(o("panel.failed"))) : P.danger(z(w));
640
+ } finally {
641
+ c.value = !1;
642
+ }
643
+ }
644
+ return (w, h) => (v(), L("div", Ye, [
645
+ _.value ? (v(), W(e(N), { key: 0 }, {
646
+ default: t(() => [
647
+ l(e(ze), {
648
+ title: "",
649
+ rows: 8
650
+ })
651
+ ]),
652
+ _: 1
653
+ })) : a.value ? (v(), L(se, { key: 1 }, [
654
+ l(e(ge), {
655
+ class: "wx-inbox-editor__head",
656
+ title: b.value,
657
+ subtitle: a.value.slug,
658
+ back: g.value,
659
+ "back-label": e(o)("panel.forms")
660
+ }, {
661
+ "title-after": t(() => [
662
+ e(r).is_enabled ? T("", !0) : (v(), W(e(Fe), {
663
+ key: 0,
664
+ type: "default"
665
+ }, {
666
+ default: t(() => [
667
+ V(x(e(o)("panel.off")), 1)
668
+ ]),
669
+ _: 1
670
+ }))
671
+ ]),
672
+ _: 1
673
+ }, 8, ["title", "subtitle", "back", "back-label"]),
674
+ Z.value ? (v(), W(e(oe), {
675
+ key: 0,
676
+ class: "wx-inbox-editor__silent",
677
+ type: "warning",
678
+ variant: "soft",
679
+ closable: !1,
680
+ title: e(o)("panel.notifies-nobody"),
681
+ description: e(o)("panel.notifies-nobody-text")
682
+ }, null, 8, ["title", "description"])) : T("", !0),
683
+ l(e(Se), {
684
+ modelValue: D.value,
685
+ "onUpdate:modelValue": h[5] || (h[5] = (U) => D.value = U),
686
+ class: "wx-inbox-editor__tabs",
687
+ "keep-alive": ""
688
+ }, {
689
+ default: t(() => [
690
+ l(e(O), {
691
+ value: "general",
692
+ label: e(o)("panel.tab-general")
693
+ }, {
694
+ default: t(() => [
695
+ l(Oe, {
696
+ settings: e(r),
697
+ "onUpdate:settings": h[0] || (h[0] = (U) => A(r) ? r.value = U : r = U),
698
+ options: F.value,
699
+ "onUpdate:options": h[1] || (h[1] = (U) => F.value = U),
700
+ errors: f.value
701
+ }, null, 8, ["settings", "options", "errors"])
702
+ ]),
703
+ _: 1
704
+ }, 8, ["label"]),
705
+ l(e(O), {
706
+ value: "fields",
707
+ label: e(o)("panel.tab-fields")
708
+ }, {
709
+ default: t(() => [
710
+ l(Ae, {
711
+ modelValue: p.value,
712
+ "onUpdate:modelValue": h[2] || (h[2] = (U) => p.value = U),
713
+ form: a.value,
714
+ "can-manage": j.value
715
+ }, null, 8, ["modelValue", "form", "can-manage"])
716
+ ]),
717
+ _: 1
718
+ }, 8, ["label"]),
719
+ l(e(O), {
720
+ value: "notifications",
721
+ label: e(o)("panel.tab-notifications")
722
+ }, {
723
+ default: t(() => [
724
+ l(Xe, {
725
+ modelValue: F.value,
726
+ "onUpdate:modelValue": h[3] || (h[3] = (U) => F.value = U),
727
+ fields: p.value,
728
+ errors: f.value,
729
+ reported: a.value.recipients,
730
+ notifications: a.value.notifications
731
+ }, null, 8, ["modelValue", "fields", "errors", "reported", "notifications"])
732
+ ]),
733
+ _: 1
734
+ }, 8, ["label"]),
735
+ l(e(O), {
736
+ value: "antispam",
737
+ label: e(o)("panel.tab-antispam")
738
+ }, {
739
+ default: t(() => [
740
+ l(Be, {
741
+ modelValue: F.value,
742
+ "onUpdate:modelValue": h[4] || (h[4] = (U) => F.value = U),
743
+ site: a.value.captcha
744
+ }, null, 8, ["modelValue", "site"])
745
+ ]),
746
+ _: 1
747
+ }, 8, ["label"]),
748
+ l(e(O), {
749
+ value: "embed",
750
+ label: e(o)("panel.tab-embed")
751
+ }, {
752
+ default: t(() => [
753
+ l(Le, {
754
+ form: a.value,
755
+ slug: e(r).slug,
756
+ fields: p.value
757
+ }, null, 8, ["form", "slug", "fields"])
758
+ ]),
759
+ _: 1
760
+ }, 8, ["label"])
761
+ ]),
762
+ _: 1
763
+ }, 8, ["modelValue"]),
764
+ j.value ? (v(), W(e(Ce), { key: 1 }, {
765
+ default: t(() => [
766
+ l(e(te), {
767
+ type: "primary",
768
+ loading: c.value,
769
+ onClick: M
770
+ }, {
771
+ default: t(() => [
772
+ V(x(e(o)("panel.save")), 1)
773
+ ]),
774
+ _: 1
775
+ }, 8, ["loading"])
776
+ ]),
777
+ _: 1
778
+ })) : T("", !0)
779
+ ], 64)) : T("", !0)
780
+ ]));
781
+ }
782
+ }), ol = /* @__PURE__ */ X(Ze, [["__scopeId", "data-v-4e3d1a4c"]]);
783
+ export {
784
+ ol as default
785
+ };
786
+ //# sourceMappingURL=FormEditorPage-BoHzlFfz.js.map