@telia-ace/knowledge-widget-bot-provider 0.0.24 → 1.1.1-rc.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.
Files changed (54) hide show
  1. package/contact-method-a18f6436.mjs +896 -0
  2. package/contact-method-a9506b8c.js +99 -0
  3. package/contact-method-list-814eb03f.mjs +97 -0
  4. package/contact-method-list-b5815c14.js +28 -0
  5. package/feedback-list-04b512a4.mjs +80 -0
  6. package/feedback-list-e7973adc.js +25 -0
  7. package/index-07363705.js +1214 -0
  8. package/index-373df3a5.js +6 -0
  9. package/index-5c9c2abf.mjs +883 -0
  10. package/index-cc31f772.mjs +10810 -0
  11. package/index.js +1 -0
  12. package/index.mjs +7 -0
  13. package/no-good-alternative-2d562ff9.mjs +53 -0
  14. package/no-good-alternative-d31e7d52.js +15 -0
  15. package/notification-list-291a2001.mjs +1449 -0
  16. package/notification-list-876b3f3d.js +546 -0
  17. package/notification-list-9fca63ae.mjs +53 -0
  18. package/notification-list-f9c4cafe.js +8 -0
  19. package/package.json +20 -42
  20. package/styles-15c941d4.js +4 -0
  21. package/{dist/styles.a00306c5.js → styles-ad5c7069.mjs} +3 -4
  22. package/use-dispatch-951d7a5c.js +1 -0
  23. package/use-dispatch-97d3af39.mjs +24 -0
  24. package/{dist/utils.d.ts → utils.d.ts} +1 -1
  25. package/LICENSE.txt +0 -6
  26. package/README.md +0 -12
  27. package/dist/contact-method-list.4fcc98f1.js +0 -128
  28. package/dist/contact-method-list.4fcc98f1.js.map +0 -1
  29. package/dist/contact-method.4e96a7d4.js +0 -136
  30. package/dist/contact-method.4e96a7d4.js.map +0 -1
  31. package/dist/feedback-list.ff7e22da.js +0 -77
  32. package/dist/feedback-list.ff7e22da.js.map +0 -1
  33. package/dist/index.483ca2e8.js +0 -795
  34. package/dist/index.483ca2e8.js.map +0 -1
  35. package/dist/index.js +0 -9
  36. package/dist/index.js.map +0 -1
  37. package/dist/no-good-alternative.e9155cb9.js +0 -50
  38. package/dist/no-good-alternative.e9155cb9.js.map +0 -1
  39. package/dist/notification-list.7fd5ba2b.js +0 -67
  40. package/dist/notification-list.7fd5ba2b.js.map +0 -1
  41. package/dist/styles.a00306c5.js.map +0 -1
  42. /package/{dist/entry-handler.d.ts → entry-handler.d.ts} +0 -0
  43. /package/{dist/http-client.d.ts → http-client.d.ts} +0 -0
  44. /package/{dist/index.d.ts → index.d.ts} +0 -0
  45. /package/{dist/plugin.d.ts → plugin.d.ts} +0 -0
  46. /package/{dist/provider.d.ts → provider.d.ts} +0 -0
  47. /package/{dist/store.d.ts → store.d.ts} +0 -0
  48. /package/{dist/types.d.ts → types.d.ts} +0 -0
  49. /package/{dist/ui → ui}/contact-method-list.d.ts +0 -0
  50. /package/{dist/ui → ui}/contact-method.d.ts +0 -0
  51. /package/{dist/ui → ui}/feedback-list.d.ts +0 -0
  52. /package/{dist/ui → ui}/no-good-alternative.d.ts +0 -0
  53. /package/{dist/ui → ui}/notification-list.d.ts +0 -0
  54. /package/{dist/ui → ui}/styles.d.ts +0 -0
@@ -0,0 +1,896 @@
1
+ var oe = Object.defineProperty;
2
+ var re = (n, e, t) => e in n ? oe(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var q = (n, e, t) => (re(n, typeof e != "symbol" ? e + "" : e, t), t);
4
+ import { jsx as v, jsxs as V } from "react/jsx-runtime";
5
+ import { u as Y, a as ae, C as ce, n as L, P as de, h as Z, c as j, H as le, g as ue, b as ee, l as he, S as ge, L as fe, T as me, d as be, I as ye, i as pe, e as te, F as H, W as K, f as Ce, j as ve, k as W } from "./index-cc31f772.mjs";
6
+ import { u as we, c as ke, f as Me, r as Ne } from "./notification-list-291a2001.mjs";
7
+ import { useState as ne, useEffect as Q, useContext as xe, Suspense as Se, useRef as $e, useCallback as Re } from "react";
8
+ import "react-dom";
9
+ import { a as Ae, u as Le } from "./use-dispatch-97d3af39.mjs";
10
+ const G = (n, e) => {
11
+ let t = !0;
12
+ return Object.keys(n).length !== Object.keys(e).length || Object.keys(n).some((i) => !Object.keys(e).some((c) => i === c)) ? !1 : (Object.keys(n).forEach((i) => {
13
+ if (t) {
14
+ const o = typeof n[i] > "u" ? "" : n[i], c = typeof e[i] > "u" ? "" : e[i];
15
+ t = o.toString() === c.toString();
16
+ }
17
+ }), t);
18
+ }, Ie = (n, e) => {
19
+ const t = Ae(), s = Y(), [i, o] = ne(void 0), c = ae(), r = n || t.type || "";
20
+ return Q(() => {
21
+ if (r) {
22
+ let a;
23
+ return (e || s).getAsync("componentResolver").then((l) => {
24
+ if (c.current) {
25
+ const h = l.getComponent(r);
26
+ o(h);
27
+ }
28
+ a = l.registerResolver(r, (h) => {
29
+ c.current && o(h);
30
+ });
31
+ }), () => {
32
+ a && a();
33
+ };
34
+ }
35
+ }, [c, r, e, s]), i;
36
+ }, qe = () => xe(ce);
37
+ var B = /* @__PURE__ */ ((n) => (n.guide = "guide", n.link = "link", n.default = "default", n))(B || {});
38
+ L(de)`
39
+ ${(n) => {
40
+ var e;
41
+ return Z(n)(
42
+ "h1",
43
+ j`
44
+ font-weight: normal;
45
+ font-size: ${(e = n.theme.fonts) == null ? void 0 : e.medium};
46
+ `
47
+ );
48
+ }}
49
+ `;
50
+ const Oe = L(le)`
51
+ ${ue}
52
+ font-weight: 300;
53
+ line-height: 1.5em;
54
+ button:focus-visible {
55
+ ${ee};
56
+ }
57
+
58
+ a:focus-visible {
59
+ ${he};
60
+ }
61
+ `, ie = (n) => {
62
+ const e = Ie(n.clientName), {
63
+ params: { contactCategory: t, guideCategory: s, phrase: i }
64
+ } = we();
65
+ if (typeof e > "u")
66
+ return null;
67
+ if (e === null)
68
+ return process.env.NODE_ENV !== "production" ? /* @__PURE__ */ v(
69
+ Ge,
70
+ {
71
+ title: `client-name: ${n.clientName}, id: ${n.id}`,
72
+ className: "humany-non-resolved-contact-method",
73
+ children: /* @__PURE__ */ v(me, { variant: "h5", children: "Non resolved Contact Method type" })
74
+ }
75
+ ) : null;
76
+ const o = (c = {}) => {
77
+ const r = { ...n, ...c }, {
78
+ id: a,
79
+ title: l,
80
+ clientName: h,
81
+ symbol: g,
82
+ inline: m,
83
+ onClick: w = () => {
84
+ },
85
+ description: u,
86
+ htmlParseInstruction: b,
87
+ className: d,
88
+ disabled: f,
89
+ guideId: C,
90
+ dispatch: k = () => {
91
+ },
92
+ expanded: y
93
+ } = r, M = m ? {
94
+ onKeyDown: (p) => {
95
+ p.key && p.key === "Enter" && (w(p, r), p.defaultPrevented || !y && k("expand", a));
96
+ },
97
+ onClick: (p) => {
98
+ w(p, r), p.defaultPrevented || !y && k("expand", a);
99
+ }
100
+ } : {
101
+ onClick: (p) => w(p, r),
102
+ routeName: "contact-method",
103
+ params: ke({
104
+ contactCategory: t,
105
+ guideId: C,
106
+ guideCategory: s,
107
+ phrase: i,
108
+ contactMethod: a,
109
+ uriName: Me(l)
110
+ })
111
+ };
112
+ return /* @__PURE__ */ V(
113
+ Ee,
114
+ {
115
+ title: l,
116
+ "aria-label": l,
117
+ className: d,
118
+ disabled: f,
119
+ description: u,
120
+ "data-client-name": h,
121
+ ...c,
122
+ ...M,
123
+ children: [
124
+ g && /* @__PURE__ */ v(be, { symbol: g }),
125
+ u ? /* @__PURE__ */ V("div", { className: "humany-contact-link-rich-content", children: [
126
+ /* @__PURE__ */ v(D, { children: l }),
127
+ /* @__PURE__ */ v(
128
+ Oe,
129
+ {
130
+ html: u,
131
+ htmlParseInstruction: b
132
+ }
133
+ )
134
+ ] }) : /* @__PURE__ */ v(D, { children: l })
135
+ ]
136
+ }
137
+ );
138
+ };
139
+ return n.expanded ? /* @__PURE__ */ v(Se, { fallback: null, children: /* @__PURE__ */ v(e, { ...n, renderDefault: o }) }) : o();
140
+ }, Te = (n) => {
141
+ var e, t, s, i, o, c, r, a;
142
+ return j`
143
+ display: flex;
144
+ padding: ${(e = n.theme.sizes) == null ? void 0 : e.large};
145
+ ${n.description ? "" : "align-items: center;"}
146
+ text-decoration: none;
147
+ span {
148
+ display: inline-block;
149
+ color: ${(t = n.theme.colors) == null ? void 0 : t.text};
150
+ }
151
+ i {
152
+ font-size: ${(s = n.theme.fonts) == null ? void 0 : s.large};
153
+ margin: 0 ${(i = n.theme.sizes) == null ? void 0 : i.large} 0 0;
154
+ min-height: ${(o = n.theme.fonts) == null ? void 0 : o.large};
155
+ min-width: ${(c = n.theme.fonts) == null ? void 0 : c.large};
156
+ line-height: ${(r = n.theme.fonts) == null ? void 0 : r.large};
157
+ display: inline-block;
158
+ vertical-align: bottom;
159
+ color: ${(a = n.theme.colors) == null ? void 0 : a.text};
160
+ }
161
+ `;
162
+ }, D = L(ge)`
163
+ line-height: ${(n) => {
164
+ var e;
165
+ return (e = n.theme.fonts) == null ? void 0 : e.large;
166
+ }};
167
+ `, Ee = L(fe)`
168
+ ${(n) => Te(n)}
169
+
170
+ &:focus-visible {
171
+ ${ee};
172
+ }
173
+ `, Ge = L.div`
174
+ text-align: center;
175
+ display: block;
176
+ ${(n) => {
177
+ var e, t;
178
+ return typeof ((e = n.theme.colors) == null ? void 0 : e.warning) < "u" && `color: ${(t = n.theme.colors) == null ? void 0 : t.warning};`;
179
+ }}
180
+ `, Be = (n) => {
181
+ var e, t, s;
182
+ return j`
183
+ ${pe(n)}
184
+
185
+ > div {
186
+ padding: ${(e = n.theme.sizes) == null ? void 0 : e.large};
187
+
188
+ ${Z(n)(
189
+ "h1",
190
+ j`
191
+ margin: 0;
192
+ `
193
+ )}
194
+ }
195
+
196
+ > ul {
197
+ &:not(:first-child) {
198
+ border-top: ${n.theme.border};
199
+ }
200
+
201
+ > li {
202
+ margin: 0;
203
+ white-space: normal;
204
+
205
+ > a {
206
+ overflow: hidden;
207
+ }
208
+
209
+ &:first-child > a {
210
+ border-radius: ${`${n.theme.borderRadius} ${n.theme.borderRadius} 0 0`};
211
+ }
212
+
213
+ &:last-child:not(:first-child) > a {
214
+ border-radius: ${`0 0 ${n.theme.borderRadius} ${n.theme.borderRadius}`};
215
+ }
216
+
217
+ &:not(:last-child) {
218
+ border-bottom: ${n.theme.border};
219
+ }
220
+
221
+ > div {
222
+ padding: ${(t = n.theme.sizes) == null ? void 0 : t.large};
223
+ }
224
+ }
225
+ }
226
+
227
+ @media (hover: hover) {
228
+ a:hover {
229
+ background-color: ${(s = n.theme.colors) == null ? void 0 : s.accent};
230
+ }
231
+ }
232
+ `;
233
+ }, je = L(ye)`
234
+ ${(n) => Be(n)}
235
+ `, Xe = ({
236
+ contactMethods: n,
237
+ children: e,
238
+ guideId: t,
239
+ dispatch: s,
240
+ className: i = "",
241
+ itemRenderer: o,
242
+ action: c = () => {
243
+ },
244
+ header: r = ""
245
+ }) => n.length ? /* @__PURE__ */ v(
246
+ je,
247
+ {
248
+ header: r,
249
+ className: te(i, "humany-contact-list"),
250
+ items: n,
251
+ renderItem: o ? (a) => /* @__PURE__ */ v("li", { "data-contact-method": a.id, children: o(a, { action: c, dispatch: s, guideId: t }) }, a.id) : (a) => /* @__PURE__ */ v("li", { "data-contact-method": a.id, children: /* @__PURE__ */ v(
252
+ ie,
253
+ {
254
+ ...a,
255
+ action: c,
256
+ dispatch: s,
257
+ guideId: t
258
+ }
259
+ ) }, a.id),
260
+ children: e
261
+ }
262
+ ) : null, J = (n) => import("./index-5c9c2abf.mjs").then(({ ServiceClient: e, ServiceProxy: t }) => n.get("settings").then((s) => {
263
+ const { name: i, events: o } = n.get("$widget"), {
264
+ data: { projection: c = "", site: r = "current", forceHttps: a = !1 }
265
+ } = s, l = new t(c, { credentials: "same-origin" }), h = new e(
266
+ l,
267
+ {
268
+ funnel: i.replace("_contact-method", "").replace("_contact", ""),
269
+ site: Ue(r, a)
270
+ },
271
+ null,
272
+ n
273
+ );
274
+ return o.subscribe("widget:settings-updated", (g, { data: m }) => {
275
+ m && m.projection !== c && h.proxy.setBaseUrl(m.projection);
276
+ }), h;
277
+ })), Ue = (n, e) => () => {
278
+ const t = (i) => {
279
+ const o = document.createElement("a");
280
+ return o.href = i, o;
281
+ };
282
+ let s = window.location;
283
+ return n === "referrer" && document.referrer && (s = t(document.referrer)), [e ? "https:" : "", "//", s.host, s.pathname].join("");
284
+ }, A = (n) => {
285
+ if (n) {
286
+ const { Type: e, Content: t } = n;
287
+ if (e && t)
288
+ return { type: e, content: t };
289
+ }
290
+ }, _ = (n) => n.map((e) => {
291
+ const t = {
292
+ id: e.Id.toString(),
293
+ title: e.Name,
294
+ symbol: A(e.DefaultIcon),
295
+ activeSymbol: e.ActiveIcon && A(e.ActiveIcon),
296
+ description: e.Description || e.Attributes && e.Attributes.description || "",
297
+ matches: e.GuidesCount
298
+ };
299
+ return e.Children && e.Children.length && (t.items = _(e.Children)), t;
300
+ }), $ = (n, e) => n.filter(({ Type: t }) => t === e).map(({ Id: t, Title: s, Body: i }) => ({
301
+ id: t.toString(),
302
+ title: s,
303
+ body: i
304
+ })), P = (n) => n.map(({ Id: e, Title: t, DefaultIcon: s, ListNotices: i, Notices: o }) => ({
305
+ id: e.toString(),
306
+ title: t,
307
+ symbol: A(s),
308
+ defaultHeaderOptions: {
309
+ visible: !!i.length
310
+ },
311
+ notifications: (i || []).concat(o || []).map(({ Id: c, Title: r, Body: a, Type: l, Modified: h }) => ({
312
+ id: c.toString(),
313
+ title: r,
314
+ body: a,
315
+ modified: h,
316
+ expandable: l === "listNotice"
317
+ }))
318
+ })), z = ({
319
+ Id: n,
320
+ Title: e,
321
+ DefaultIcon: t,
322
+ Exits: [s],
323
+ ExitType: i,
324
+ ConfirmationText: o,
325
+ ExpandFormAutomatically: c,
326
+ Form: r,
327
+ Description: a
328
+ }, l) => {
329
+ const { Adapter: h } = s || { Adapter: {} }, { ClientName: g = "", Settings: m = {}, CustomClientName: w = "" } = h, u = {
330
+ id: n.toString(),
331
+ title: e,
332
+ description: a,
333
+ symbol: A(t),
334
+ clientName: g === "custom.adapter" ? w : g,
335
+ expanded: !0,
336
+ inline: !0,
337
+ body: {}
338
+ };
339
+ if (g.indexOf("phone") > -1 || g.indexOf("freetext") > -1) {
340
+ const { displayTextBeforeClick: b, textBeforeClick: d } = m;
341
+ b === "true" && (u.expanded = !1, u.title = d), g.indexOf("phone.text") > -1 ? u.body.phoneNumber = m.phoneNumber : u.body.freetext = m.freetext;
342
+ }
343
+ return (g.indexOf("chat.popup") > -1 || g.indexOf("link") > -1 || g === "custom.adapter" && i === "custom") && (u.body = m, u.body.confirmationFallback = o), g.indexOf("ace") > -1 && (u.body = m), r && r.HasValueComponents && (l ? u.body.form = H.fromLegacyForm(n.toString(), r, l).get() : u.body.form = H.fromLegacyForm(n.toString(), r).get(), c || (u.expanded = u.inline = !1)), u;
344
+ }, O = (n = []) => n.map(({ Id: e, Title: t, TotalMatches: s, Symbol: i, DefaultIcon: o, ActiveIcon: c }) => ({
345
+ id: e.toString(),
346
+ title: t,
347
+ matches: s,
348
+ symbol: A(o || i),
349
+ defaultIcon: A(o),
350
+ activeIcon: A(c)
351
+ })), F = (n) => n.map(({ Id: e, Title: t, Tags: s, FirstPublishedDate: i, Modified: o }) => ({
352
+ id: e.toString(),
353
+ title: t,
354
+ tags: O(s),
355
+ published: i,
356
+ modified: o
357
+ })), Pe = (n, e) => {
358
+ switch (n) {
359
+ case S.MatchByCategory:
360
+ case S.Match: {
361
+ const t = {
362
+ guides: [],
363
+ matches: 0,
364
+ topNotifications: [],
365
+ middleNotifications: [],
366
+ bottomNotifications: [],
367
+ notificationLists: [],
368
+ tags: [],
369
+ byCategory: []
370
+ }, {
371
+ Matches: s,
372
+ TotalMatches: i,
373
+ Notices: o,
374
+ NoticeLists: c,
375
+ Tags: r,
376
+ ByCategory: a
377
+ } = e;
378
+ return t.guides = F(s), t.matches = i, t.byCategory = (a || []).map(({ Id: l, Matches: h, TotalMatches: g }) => ({
379
+ id: l,
380
+ guides: F(h),
381
+ matches: g
382
+ })), t.tags = O(r), t.notificationLists = P(c || []), t.topNotifications = $(o || [], "noticeRowTop"), t.middleNotifications = $(o || [], "noticeRowMiddle"), t.bottomNotifications = $(o || [], "footerNotice"), t;
383
+ }
384
+ case S.Categories: {
385
+ const { Children: t, GuidesCountTotal: s } = e;
386
+ return {
387
+ categories: _(t || []),
388
+ matches: s
389
+ };
390
+ }
391
+ case S.Guide: {
392
+ const {
393
+ Id: t,
394
+ Title: s,
395
+ Body: i,
396
+ Related: o,
397
+ Options: c,
398
+ ConnectionId: r,
399
+ ContactMethods: a,
400
+ EnableFeedback: l,
401
+ HandoverExists: h,
402
+ FirstPublishedDate: g,
403
+ Modified: m,
404
+ ModifiedByDisplayName: w,
405
+ FirstPublishedByDisplayName: u,
406
+ Categories: b,
407
+ Tags: d,
408
+ SeoMetaDescription: f,
409
+ SeoAllowIndex: C,
410
+ Perspectives: k,
411
+ PerspectiveKey: y,
412
+ Translations: M
413
+ } = e, p = y || Object.values(k).find((N) => N === r) || k.Default || null, U = {
414
+ guide: {
415
+ id: t.toString(),
416
+ title: s,
417
+ body: i,
418
+ modified: m,
419
+ published: g,
420
+ modifiedBy: w,
421
+ publishedBy: u,
422
+ connection: r,
423
+ categories: b,
424
+ hasHandover: h,
425
+ allowFeedback: l,
426
+ seoMetaDescription: f,
427
+ seoAllowIndex: C,
428
+ perspectives: k,
429
+ perspective: p,
430
+ translations: Object.keys(M || {}).reduce((N, R) => (N[R] = M[R].toString(), N), {})
431
+ },
432
+ related: F(o || []),
433
+ dialog: [],
434
+ contactMethods: (a || []).map((N) => z(N)),
435
+ tags: O(d)
436
+ };
437
+ return (c || []).forEach(({ CanAccess: N, Description: R, ConnectionId: E, Properties: x }) => {
438
+ if (!N)
439
+ return;
440
+ const I = {
441
+ id: t.toString(),
442
+ title: R,
443
+ connection: E,
444
+ connectionKey: x.ConnectionKey,
445
+ type: B.default,
446
+ parent: {
447
+ id: t.toString(),
448
+ title: s,
449
+ tags: O(d)
450
+ }
451
+ };
452
+ if (x.Type === "Guide" || x.Type === "Link")
453
+ switch (x.Id && (I.id = x.Id.toString()), x.Uri && (I.href = x.Uri), x.Target && (I.target = x.Target), x.Type) {
454
+ case "Guide":
455
+ I.type = B.guide;
456
+ break;
457
+ case "Link":
458
+ I.type = B.link;
459
+ break;
460
+ }
461
+ U.dialog.push(I);
462
+ }), U;
463
+ }
464
+ case S.Contacts: {
465
+ const { Children: t, Matches: s, Notices: i, NoticeLists: o } = e;
466
+ return {
467
+ contactMethods: (s || []).map((r) => z(r)),
468
+ categories: _(t || []),
469
+ topNotifications: $(i || [], "noticeRowTop"),
470
+ middleNotifications: $(i || [], "noticeRowMiddle"),
471
+ bottomNotifications: $(i || [], "footerNotice"),
472
+ notificationLists: P(o || [])
473
+ };
474
+ }
475
+ case S.ContactMethod: {
476
+ const { ContactMethod: t } = e;
477
+ return z(t || {});
478
+ }
479
+ case S.Tags:
480
+ case S.TagsOnGuides:
481
+ return O(e || []);
482
+ case S.Notifications: {
483
+ const { Notices: t, NoticeLists: s } = e;
484
+ return {
485
+ topNotifications: $(t || [], "noticeRowTop"),
486
+ middleNotifications: $(t || [], "noticeRowMiddle"),
487
+ bottomNotifications: $(t || [], "footerNotice"),
488
+ notificationLists: P(s || [])
489
+ };
490
+ }
491
+ default:
492
+ return {};
493
+ }
494
+ };
495
+ var se = /* @__PURE__ */ ((n) => (n.Guide = "guide", n.Guides = "guides", n.GuidesByCategory = "guides-by-category", n.RowNotifications = "row-notices", n.NotificationLists = "notification-lists", n.GuideCategories = "guide-categories", n.ContactMethodCategories = "contact-method-categories", n.ContactMethod = "contact-method", n.ContactMethods = "contact-methods", n.Tags = "tags", n.TagsOnGuides = "tagsonguides", n))(se || {}), S = /* @__PURE__ */ ((n) => (n.Match = "match", n.Categories = "categories", n.Guide = "guide", n.Contacts = "contacts", n.ContactMethod = "contact-method", n.MatchByCategory = "match-by-category", n.Tags = "tags", n.TagsOnGuides = "tagsonguides", n.Notifications = "notifications", n))(S || {});
496
+ const X = (n) => {
497
+ switch (n) {
498
+ case "guides":
499
+ return "match";
500
+ case "guides-by-category":
501
+ return "match-by-category";
502
+ case "guide":
503
+ return "guide";
504
+ case "guide-categories":
505
+ return "categories";
506
+ case "contact-method-categories":
507
+ case "contact-methods":
508
+ return "contacts";
509
+ case "contact-method":
510
+ return "contact-method";
511
+ case "tags":
512
+ return "tags";
513
+ case "tagsonguides":
514
+ return "tagsonguides";
515
+ case "notification-lists":
516
+ case "row-notices":
517
+ return "notifications";
518
+ default:
519
+ throw "error";
520
+ }
521
+ }, ze = async (n) => {
522
+ const { invoke: e } = n.get("$widget");
523
+ return await e("renderState") === K.hidden;
524
+ };
525
+ class T {
526
+ constructor(e, t) {
527
+ q(this, "queries", /* @__PURE__ */ new Map());
528
+ q(this, "lastTake", 0);
529
+ q(this, "events");
530
+ q(this, "getUnresolvedQueries", () => {
531
+ let e = 0;
532
+ return this.queries.forEach((t, s) => {
533
+ t.some((o) => !o.resolved) && (e = 1);
534
+ }), e;
535
+ });
536
+ this.container = e, this.matchingClient = t, this.events = e.get("$widget").events, this.events.subscribe(
537
+ "widget:settings-updated",
538
+ () => this.queries = /* @__PURE__ */ new Map()
539
+ ), this.events.subscribe(
540
+ "widget:render-state-changed",
541
+ (s, { next: i, previous: o }) => {
542
+ o === K.hidden && i === K.open && this.fetchAllUnresolvedQueries();
543
+ }
544
+ );
545
+ }
546
+ static getInstance(e, t = "dataClient") {
547
+ return Ce(this)(() => e.getAsync(t).then(async (s) => {
548
+ let i = await e.getAsync("matchingClient");
549
+ i || (i = await J(e), e.registerAsync("matchingClient", () => i));
550
+ let o = s;
551
+ return o || (o = new T(e, i), e.registerAsync(t, () => o)), o;
552
+ }));
553
+ }
554
+ fetch(e, t, s) {
555
+ return new Promise((i, o) => {
556
+ t.take && (this.lastTake = +(t.take || 0)), Ne(t);
557
+ const c = X(e);
558
+ let r = this.queries.get(c) || [], a = r.find((l) => G(l.params, t)) || null;
559
+ if (a && (s != null && s.noCache)) {
560
+ const l = r.findIndex(
561
+ (h) => G(h.params, t)
562
+ );
563
+ r = [...r.slice(0, l), ...r.slice(l + 1)], a = null;
564
+ }
565
+ if (a) {
566
+ const l = r.indexOf(a);
567
+ if (a.resolved ? (this.events.dispatch("data-client:fetched", {
568
+ params: t,
569
+ type: c,
570
+ response: a.data,
571
+ unresolvedQueries: this.getUnresolvedQueries()
572
+ }), this.track(a.data, c, a.error), a.data && a.error ? o({ error: a.error }) : i(a.data)) : a.resolvers.push({ resolve: i, reject: o }), r.splice(l, 1), r.push(a), this.queries.set(c, r), !a.loading && !a.resolved)
573
+ return this.runQuery(c, t);
574
+ } else
575
+ return r.push({
576
+ params: t,
577
+ resolved: !1,
578
+ loading: !0,
579
+ data: {},
580
+ resolvers: [{ resolve: i, reject: o }]
581
+ }), this.queries.set(c, r), this.runQuery(c, t);
582
+ }).then((i) => ve(i));
583
+ }
584
+ // query the cached data
585
+ read(e, t) {
586
+ const { select: s } = t, i = X(e);
587
+ return (this.queries.get(i) || []).reduce((r, a) => {
588
+ if (typeof s == "function") {
589
+ const l = s(a.data);
590
+ l && r.push(l);
591
+ } else
592
+ r.push(a.data);
593
+ return r;
594
+ }, []);
595
+ }
596
+ feedback(e, t, s) {
597
+ return this.matchingClient.giveFeedback(e, t, s);
598
+ }
599
+ setLoadingStatus(e, t, s) {
600
+ const i = this.queries.get(e) || [], o = i.find((c) => G(c.params, t));
601
+ o && (o.loading = s), this.queries.set(e, i);
602
+ }
603
+ async runQuery(e, t) {
604
+ const {
605
+ searchPhrase: s = "",
606
+ categories: i = "0",
607
+ contactMethodCategoryId: o = "0",
608
+ contactMethodId: c = "0",
609
+ tagId: r = void 0,
610
+ take: a = 5,
611
+ connection: l = "",
612
+ guideId: h,
613
+ expandCategories: g = "descendants",
614
+ currentCategory: m,
615
+ sorting: w = "popularity-descending",
616
+ guideIds: u = []
617
+ } = t, b = s.toString().trim();
618
+ if (await ze(this.container))
619
+ return Promise.resolve();
620
+ switch (e) {
621
+ case "match": {
622
+ const d = (f) => {
623
+ const [C, k] = f.split("-");
624
+ return {
625
+ type: (/* @__PURE__ */ new Map([
626
+ ["popularity", "popularity"],
627
+ ["alphabetic", "title"],
628
+ ["modified", "lastModified"],
629
+ ["published", "firstPublished"]
630
+ ])).get(C),
631
+ direction: k
632
+ };
633
+ };
634
+ return u.length ? this.matchingClient.customRequest("guides", "POST", {
635
+ configuration: { ids: u, take: +a }
636
+ }).then(
637
+ (f) => f && this.handleResponse(f, e, t)
638
+ ) : this.matchingClient.match(b, {
639
+ categories: i === "0" ? [] : Array.isArray(i) ? i : [+i],
640
+ take: +a,
641
+ tags: r,
642
+ sorting: d(w),
643
+ ids: u
644
+ }).then(
645
+ (f) => f && this.handleResponse(f, e, t)
646
+ );
647
+ }
648
+ case "match-by-category":
649
+ return this.matchingClient.match(b, {
650
+ groupByCategory: !0,
651
+ categories: i === "0" ? [] : Array.isArray(i) ? i : [+i],
652
+ take: +a,
653
+ tags: r
654
+ }).then(
655
+ (d) => d && this.handleResponse(d, e, t)
656
+ );
657
+ case "guide":
658
+ return this.matchingClient.getGuide(h, { connectionId: l }).then((d) => {
659
+ d && this.handleResponse(d, e, t);
660
+ }).catch((d) => {
661
+ const f = {
662
+ message: "Something went wrong.",
663
+ status: d.status || 400
664
+ };
665
+ f.status === 404 && (f.message = "The guide could not be found."), this.handleResponse({}, e, t, f);
666
+ });
667
+ case "categories":
668
+ return this.matchingClient.getCategories({
669
+ phrase: b,
670
+ expand: g,
671
+ tags: r
672
+ }).then(
673
+ (d) => d && this.handleResponse(d, e, t)
674
+ );
675
+ case "contacts":
676
+ return h ? this.matchingClient.contactMethods(+h, { phrase: b }).then(
677
+ (d) => d && this.handleResponse(d, e, t)
678
+ ) : this.matchingClient.contacts(+o, { phrase: b }).then(
679
+ (d) => d && this.handleResponse(d, e, t)
680
+ );
681
+ case "contact-method":
682
+ return this.matchingClient.getContactMethod(+c, { guideId: h, currentCategory: m }).then(
683
+ (d) => d && this.handleResponse(d, e, t)
684
+ );
685
+ case "tags":
686
+ return this.matchingClient.customRequest("tags", "GET", {
687
+ configuration: {
688
+ take: 999999,
689
+ phrase: b,
690
+ categories: i === "0" ? [] : Array.isArray(i) ? i : [+i]
691
+ }
692
+ }).then(
693
+ (d) => d && this.handleResponse(d, e, t)
694
+ );
695
+ case "tagsonguides":
696
+ return this.matchingClient.customRequest("tagsonguides", "GET", {
697
+ configuration: {
698
+ take: 999999,
699
+ phrase: b,
700
+ categories: i === "0" ? [] : Array.isArray(i) ? i : [+i],
701
+ tags: r
702
+ }
703
+ }).then(
704
+ (d) => d && this.handleResponse(d, e, t)
705
+ );
706
+ case "notifications":
707
+ return this.matchingClient.customRequest("notices", "GET", {
708
+ configuration: {
709
+ phrase: b,
710
+ categories: i === "0" ? [] : Array.isArray(i) ? i : [+i]
711
+ }
712
+ }).then(
713
+ (d) => d && this.handleResponse(d, e, t)
714
+ );
715
+ }
716
+ }
717
+ handleResponse(e = {}, t, s, i) {
718
+ const o = this.queries.get(t) || [], c = o.find((r) => G(r.params, s));
719
+ if (c) {
720
+ const r = i || Pe(t, e);
721
+ this.track(r, t, i), c.resolvers.forEach((l) => {
722
+ i ? l.reject({ error: r }) : l.resolve(r);
723
+ });
724
+ const a = o.indexOf(c);
725
+ a > -1 && o.splice(a, 1), o.push({
726
+ ...c,
727
+ error: i,
728
+ resolvers: [],
729
+ data: r,
730
+ resolved: !0
731
+ }), this.setLoadingStatus(t, s, !1), this.queries.set(t, o), i || this.events.dispatch("data-client:fetched", {
732
+ type: t,
733
+ params: s,
734
+ response: r,
735
+ unresolvedQueries: this.getUnresolvedQueries()
736
+ });
737
+ }
738
+ }
739
+ fetchAllUnresolvedQueries() {
740
+ for (const [e, t] of this.queries)
741
+ t.filter((s) => !s.resolved).forEach((s) => {
742
+ this.runQuery(e, s.params);
743
+ });
744
+ }
745
+ track(e = {}, t, s) {
746
+ const i = this.container.get("$widget");
747
+ i && !s ? i.events.dispatch("tracking:service-client-response", {
748
+ type: t,
749
+ data: e
750
+ }) : i && i.events.dispatch("tracking:service-client-error", {
751
+ type: t,
752
+ error: s
753
+ });
754
+ }
755
+ static create(e) {
756
+ return e.getAsync("matchingClient").then(async (t) => {
757
+ if (t)
758
+ return new T(e, t);
759
+ const s = await J(e);
760
+ return e.registerAsync("matchingClient", () => s), new T(e, s);
761
+ });
762
+ }
763
+ getClient() {
764
+ return this.matchingClient;
765
+ }
766
+ }
767
+ const Fe = ({
768
+ contactMethodId: n,
769
+ guideId: e,
770
+ groupId: t,
771
+ className: s
772
+ }) => {
773
+ var g, m, w;
774
+ const [i, o] = ne(), c = Y(), r = Le(), a = $e(!0), l = qe();
775
+ Q(() => {
776
+ const { events: u } = c.get("$widget"), b = u.subscribe(
777
+ "bot-provider:form-submitted",
778
+ async (f, C) => {
779
+ var R;
780
+ if (((R = C.form.meta) == null ? void 0 : R.groupId) !== t || C.id !== i.id)
781
+ return;
782
+ l && (C.form.meta || (C.form.meta = {}), C.form.meta.conversation = l);
783
+ const k = await c.getAsync(
784
+ "contactMethods"
785
+ ), y = {
786
+ ...i,
787
+ body: {
788
+ ...i.body,
789
+ form: C.form
790
+ }
791
+ }, { errors: M, valid: p, errorTypes: U } = await k.validate(
792
+ y
793
+ );
794
+ if (!p) {
795
+ const E = new H(i.body.form);
796
+ o(void 0), E.setValidationErrors(M), y.body = {
797
+ ...y.body,
798
+ form: E.get()
799
+ }, o({ ...y });
800
+ return;
801
+ }
802
+ const N = await k.submit(y);
803
+ y.confirmation = N, o(y);
804
+ }
805
+ ), d = u.subscribe(
806
+ "bot-provider:evaluate",
807
+ async (f, C) => {
808
+ if (C.id !== n)
809
+ return;
810
+ const y = await (await c.getAsync(
811
+ "contactMethods"
812
+ )).evaluate(i);
813
+ let M = {
814
+ ...i,
815
+ body: {
816
+ ...i.body,
817
+ form: y
818
+ }
819
+ };
820
+ const p = W(M, {
821
+ submit: "Submit",
822
+ errors: {},
823
+ meta: { groupId: t }
824
+ });
825
+ M = {
826
+ ...M,
827
+ body: p
828
+ }, o(M);
829
+ }
830
+ );
831
+ return () => {
832
+ b(), d();
833
+ };
834
+ }, [c, i, o, l]);
835
+ const h = Re(
836
+ async (u) => {
837
+ const d = await (await T.getInstance(c)).fetch(
838
+ se.ContactMethod,
839
+ {
840
+ contactMethodId: u,
841
+ guideId: e
842
+ },
843
+ { noCache: !0 }
844
+ ), f = W(d, {
845
+ submit: "Submit",
846
+ errors: {},
847
+ meta: { groupId: t }
848
+ });
849
+ if (d.body = f, d.body.guideId = e, !a.current)
850
+ return null;
851
+ o(d);
852
+ },
853
+ // eslint-disable-next-line react-hooks/exhaustive-deps
854
+ [a]
855
+ );
856
+ return Q(() => (h(n), () => {
857
+ a.current = !1;
858
+ }), [n, h]), i ? /* @__PURE__ */ v(
859
+ He,
860
+ {
861
+ ...i,
862
+ body: {
863
+ ...i.body,
864
+ form: i.body.form ? {
865
+ ...i.body.form,
866
+ data: (g = i.body.form) == null ? void 0 : g.data,
867
+ layout: { ...i.body.form.layout },
868
+ meta: (m = i.body.form) == null ? void 0 : m.meta,
869
+ schema: (w = i.body.form) == null ? void 0 : w.schema
870
+ } : void 0,
871
+ guideId: i.body.guideId
872
+ },
873
+ inline: !0,
874
+ expanded: !0,
875
+ dispatch: r,
876
+ className: te("humany-bot-contact-method", s)
877
+ }
878
+ ) : null;
879
+ }, He = L(ie)`
880
+ padding: ${(n) => {
881
+ var e;
882
+ return (e = n.theme.sizes) == null ? void 0 : e.normal;
883
+ }} ${(n) => {
884
+ var e;
885
+ return (e = n.theme.sizes) == null ? void 0 : e.medium;
886
+ }};
887
+ `, Ye = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
888
+ __proto__: null,
889
+ default: Fe
890
+ }, Symbol.toStringTag, { value: "Module" }));
891
+ export {
892
+ Xe as C,
893
+ Fe as a,
894
+ ie as b,
895
+ Ye as c
896
+ };