@telia-ace/widget-conversation-flamingo 1.0.13 → 1.0.32

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 (68) hide show
  1. package/{dist/agent.d.ts → agent.d.ts} +0 -1
  2. package/components/conversation/conversation.d.ts +20 -0
  3. package/{dist/components → components}/conversation/plugin.d.ts +0 -1
  4. package/{dist/components → components}/conversation/ui/message-list.d.ts +1 -2
  5. package/{dist/components → components}/conversation/ui/message-types/message-type-html.d.ts +1 -2
  6. package/{dist/components → components}/conversation/ui/message-types/message-type-link-list.d.ts +1 -2
  7. package/{dist/components → components}/conversation/ui/message-types/message-type-separator.d.ts +1 -2
  8. package/{dist/components → components}/conversation/ui/message.d.ts +2 -3
  9. package/{dist/components → components}/conversation/utils.d.ts +0 -1
  10. package/conversation-18045ffc.mjs +1884 -0
  11. package/conversation-2a8210a9.js +446 -0
  12. package/{dist/conversation-controller.d.ts → conversation-controller.d.ts} +0 -1
  13. package/{dist/conversation-history.d.ts → conversation-history.d.ts} +0 -1
  14. package/{dist/conversation-platform.d.ts → conversation-platform.d.ts} +2 -6
  15. package/{dist/conversation-provider.d.ts → conversation-provider.d.ts} +0 -1
  16. package/{dist/index-9688347a-02584d39.js → index-17239ac6.mjs} +245 -245
  17. package/index-17fa2121.js +1 -0
  18. package/index-8a04bebb.mjs +3887 -0
  19. package/index-a12a1d3f.js +160 -0
  20. package/{dist/index.d.ts → index.d.ts} +0 -1
  21. package/index.js +1 -0
  22. package/{dist/index.js → index.mjs} +3 -4
  23. package/package.json +6 -48
  24. package/send-1e9780e5.mjs +5 -0
  25. package/send-df47dcea.js +1 -0
  26. package/{dist/store.d.ts → store.d.ts} +0 -1
  27. package/{dist/types.d.ts → types.d.ts} +0 -1
  28. package/{dist/user.d.ts → user.d.ts} +0 -1
  29. package/{dist/utils → utils}/custom-message.d.ts +0 -1
  30. package/{dist/utils → utils}/index.d.ts +0 -1
  31. package/{dist/utils → utils}/open-chat-widget.d.ts +1 -2
  32. package/{dist/utils → utils}/swap-provider.d.ts +0 -1
  33. package/LICENSE.txt +0 -6
  34. package/README.md +0 -490
  35. package/dist/agent.d.ts.map +0 -1
  36. package/dist/components/conversation/conversation.d.ts +0 -26
  37. package/dist/components/conversation/conversation.d.ts.map +0 -1
  38. package/dist/components/conversation/plugin.d.ts.map +0 -1
  39. package/dist/components/conversation/ui/message-list.d.ts.map +0 -1
  40. package/dist/components/conversation/ui/message-types/message-type-html.d.ts.map +0 -1
  41. package/dist/components/conversation/ui/message-types/message-type-link-list.d.ts.map +0 -1
  42. package/dist/components/conversation/ui/message-types/message-type-separator.d.ts.map +0 -1
  43. package/dist/components/conversation/ui/message.d.ts.map +0 -1
  44. package/dist/components/conversation/utils.d.ts.map +0 -1
  45. package/dist/conversation-34a9a242.js +0 -2281
  46. package/dist/conversation-34a9a242.js.map +0 -1
  47. package/dist/conversation-controller.d.ts.map +0 -1
  48. package/dist/conversation-form-adapter.d.ts +0 -7
  49. package/dist/conversation-form-adapter.d.ts.map +0 -1
  50. package/dist/conversation-history.d.ts.map +0 -1
  51. package/dist/conversation-platform.d.ts.map +0 -1
  52. package/dist/conversation-provider.d.ts.map +0 -1
  53. package/dist/index-9688347a-02584d39.js.map +0 -1
  54. package/dist/index-b8cb68ab.js +0 -5670
  55. package/dist/index-b8cb68ab.js.map +0 -1
  56. package/dist/index.d.ts.map +0 -1
  57. package/dist/index.js.map +0 -1
  58. package/dist/resolve-entity-value.d.ts +0 -11
  59. package/dist/resolve-entity-value.d.ts.map +0 -1
  60. package/dist/store.d.ts.map +0 -1
  61. package/dist/types.d.ts.map +0 -1
  62. package/dist/user.d.ts.map +0 -1
  63. package/dist/utils/custom-message.d.ts.map +0 -1
  64. package/dist/utils/index.d.ts.map +0 -1
  65. package/dist/utils/map-actions.d.ts +0 -2
  66. package/dist/utils/map-actions.d.ts.map +0 -1
  67. package/dist/utils/open-chat-widget.d.ts.map +0 -1
  68. package/dist/utils/swap-provider.d.ts.map +0 -1
@@ -0,0 +1,3887 @@
1
+ const Ct = (i, t, e, ...s) => {
2
+ const n = `[${i.get("$environment").name || "webprovisions"}] ${e}`;
3
+ switch (t) {
4
+ case "info":
5
+ console.info(n, ...s);
6
+ break;
7
+ case "warning":
8
+ console.warn(n, ...s);
9
+ break;
10
+ case "error":
11
+ console.error(n, ...s);
12
+ break;
13
+ }
14
+ }, bs = (i) => {
15
+ const t = i.container || i;
16
+ return {
17
+ info: (e, ...s) => Ct(t, "info", e, ...s),
18
+ warn: (e, ...s) => Ct(t, "warning", e, ...s),
19
+ error: (e, ...s) => Ct(t, "error", e, ...s)
20
+ };
21
+ };
22
+ var Z = /* @__PURE__ */ ((i) => (i.Implementation = "implementation", i.Widget = "widget", i))(Z || {}), T = /* @__PURE__ */ ((i) => (i.Pre = "pre", i.Post = "post", i))(T || {});
23
+ const ws = (i, t, e, s) => {
24
+ try {
25
+ const n = new t(e, s);
26
+ return {
27
+ name: i,
28
+ invoke: (r, o) => {
29
+ let a;
30
+ return n[r] && (a = n[r].call(n, o)), Promise.resolve(a);
31
+ },
32
+ getInstance: () => n
33
+ };
34
+ } catch (n) {
35
+ if (n.message && n.message.indexOf("is not a constructor") >= 0)
36
+ return {
37
+ name: i,
38
+ invoke: (r) => {
39
+ let o;
40
+ return r === "initialize" && (o = t(e, s)), Promise.resolve(o);
41
+ },
42
+ getInstance: () => t
43
+ };
44
+ throw n;
45
+ }
46
+ };
47
+ function fe(i, t) {
48
+ return typeof i > "u" ? t : i;
49
+ }
50
+ let _s = class {
51
+ constructor(t = {}) {
52
+ this.part = t;
53
+ }
54
+ createCommand(t, e, s) {
55
+ let n;
56
+ typeof e == "function" ? n = {
57
+ scope: Z.Widget,
58
+ stage: T.Post,
59
+ defaultArgs: void 0,
60
+ handlerResolver: e
61
+ } : n = {
62
+ scope: fe(e.scope, Z.Widget),
63
+ stage: fe(e.stage, T.Post),
64
+ defaultArgs: e.defaultArgs,
65
+ handlerResolver: s
66
+ };
67
+ let r = this.part;
68
+ const o = t.split(".");
69
+ return o.forEach((a, c) => {
70
+ c === o.length - 1 ? r[a] || (r[a] = () => n) : r = this.part[a] = this.part[a] || {};
71
+ }), this;
72
+ }
73
+ get() {
74
+ return this.part;
75
+ }
76
+ };
77
+ const Ke = (i) => {
78
+ const t = new _s({});
79
+ return i(t), t.get();
80
+ };
81
+ Ke((i) => {
82
+ i.createCommand(
83
+ "types.register",
84
+ { scope: Z.Implementation, stage: T.Pre },
85
+ (t) => (e, s) => {
86
+ t.container.get("$types")[e] = s;
87
+ }
88
+ ).createCommand(
89
+ "type",
90
+ { stage: T.Pre },
91
+ (t) => (e) => {
92
+ t.container.register("$type", e);
93
+ }
94
+ ).createCommand(
95
+ "settings",
96
+ { stage: T.Pre, defaultArgs: [null] },
97
+ (t) => (e) => {
98
+ t.events.dispatch(
99
+ "settings:change",
100
+ e,
101
+ { bubbles: !0 }
102
+ ), t.container.register("$settings", e);
103
+ }
104
+ ).createCommand(
105
+ "plugin",
106
+ { stage: T.Pre },
107
+ (t) => (e, s, n) => {
108
+ const { container: r } = t;
109
+ let o = null, a = e, c = s;
110
+ typeof e == "string" && (o = e, a = s, c = n);
111
+ const h = (l) => {
112
+ const { transformPluginSettings: d } = t.container.get("$environmentOptions"), u = d ? d(
113
+ c || {},
114
+ o,
115
+ t.container,
116
+ a
117
+ ) : s;
118
+ try {
119
+ const p = ws(
120
+ o,
121
+ a,
122
+ r,
123
+ u
124
+ );
125
+ r.get("$plugins").push(p), l && p.invoke("initialize", null);
126
+ } catch (p) {
127
+ bs(t).warn("Error when initializing plugin", p);
128
+ }
129
+ };
130
+ t.container.get("$instance") ? h(!0) : t.events.subscribeOnce("widget:instance-created", () => h(!1));
131
+ }
132
+ ).createCommand(
133
+ "container.register",
134
+ (t) => (e, s) => {
135
+ t.container.register(e, s);
136
+ }
137
+ ).createCommand(
138
+ "container.registerAsync",
139
+ (t) => (e, s) => {
140
+ t.container.registerAsync(e, s);
141
+ }
142
+ ).createCommand(
143
+ "container.registerFactory",
144
+ (t) => (e, s) => {
145
+ t.container.registerFactory(e, s);
146
+ }
147
+ ).createCommand(
148
+ "container.touch",
149
+ (t) => (e, s) => {
150
+ t.container.touch(e, s);
151
+ }
152
+ ).createCommand(
153
+ "csp",
154
+ {},
155
+ (t) => (e) => {
156
+ t.container.register("csp", e);
157
+ }
158
+ );
159
+ });
160
+ const As = Ke((i) => {
161
+ i.createCommand(
162
+ "ready",
163
+ { scope: Z.Implementation, stage: T.Pre },
164
+ (t) => (e) => {
165
+ const { container: s } = t, n = s.owner;
166
+ s.get("bootstrapping").ready ? e(n) : n.events.subscribeOnce("bootstrap:ready", () => {
167
+ e(n);
168
+ });
169
+ }
170
+ );
171
+ }), xt = /* @__PURE__ */ new WeakMap();
172
+ function J() {
173
+ return (i) => (xt.has(i) || xt.set(i, {}), xt.get(i));
174
+ }
175
+ const kt = (i, t, e, ...s) => {
176
+ const n = `[${i.get("$environment").name || "webprovisions"}] ${e}`;
177
+ switch (t) {
178
+ case "info":
179
+ console.info(n, ...s);
180
+ break;
181
+ case "warning":
182
+ console.warn(n, ...s);
183
+ break;
184
+ case "error":
185
+ console.error(n, ...s);
186
+ break;
187
+ }
188
+ }, w = (i) => {
189
+ const t = i.container || i;
190
+ return {
191
+ info: (e, ...s) => kt(t, "info", e, ...s),
192
+ warn: (e, ...s) => kt(t, "warning", e, ...s),
193
+ error: (e, ...s) => kt(t, "error", e, ...s)
194
+ };
195
+ }, m = J(), Zt = (() => {
196
+ let i = 0;
197
+ return () => ++i;
198
+ })(), Gt = (i, t, e) => {
199
+ const s = m(i).touchQueue.get(t);
200
+ s && s.forEach((n) => {
201
+ n(e, i);
202
+ });
203
+ };
204
+ let Es = class {
205
+ constructor(t, e, s, n) {
206
+ this.key = t, this.factory = e, this.parent = s, this.container = n, this.id = Zt(), this.resolved = !1, this.constructed = !1, this.async = !0;
207
+ }
208
+ resolve() {
209
+ if (!this.constructed) {
210
+ const t = this.factory(this.parent, this.container);
211
+ return this.constructed = !0, this.value = Promise.resolve(t).then((e) => (this.resolved = !0, Gt(this.container, this.key, e), e));
212
+ }
213
+ return this.value;
214
+ }
215
+ }, Ps = class {
216
+ constructor(t, e, s, n) {
217
+ this.key = t, this.value = e, this.parent = s, this.container = n, this.id = Zt(), this.async = !1, this.resolved = !1, this.constructed = !0, this.resolve = () => (this.resolved = !0, Gt(this.container, this.key, this.value), this.value);
218
+ }
219
+ }, Cs = class {
220
+ constructor(t, e, s, n) {
221
+ this.key = t, this.value = e, this.parent = s, this.container = n, this.id = Zt(), this.async = !1, this.resolved = !1, this.constructed = !1, this.resolve = () => {
222
+ this.resolved = !0, this.constructed = !0;
223
+ const r = this.value(this.parent, this.container);
224
+ return Gt(this.container, this.key, this.value), r;
225
+ };
226
+ }
227
+ }, xs = class Ye {
228
+ /**
229
+ * Creates a new instance of `Container`.
230
+ * @param owner The object owning this inctance.
231
+ * @param name Optional name for the container.
232
+ * @param parent Parent container this should be a child of.
233
+ */
234
+ constructor(t, e, s) {
235
+ this.owner = t, this.name = e, this.parent = s, m(this).resolvers = /* @__PURE__ */ new Map(), m(this).touchQueue = /* @__PURE__ */ new Map(), m(this).children = [];
236
+ }
237
+ /**
238
+ * Deletes an existing resolver by its unique id.
239
+ * @param id Resolver id.
240
+ */
241
+ delete(t) {
242
+ const e = m(this).resolvers, s = Array.from(e.values()).find((n) => n.id === t);
243
+ return s ? (m(this).touchQueue.delete(s.key), Promise.resolve(e.delete(s.key))) : this.parent ? this.parent.delete(t) : Promise.resolve(!1);
244
+ }
245
+ /**
246
+ * Clears the `Container` and any child containers by deleteing all registered resolvers.
247
+ */
248
+ clear() {
249
+ const t = m(this).resolvers, e = Array.from(t.values());
250
+ return Promise.all(e.map((s) => {
251
+ if (s.constructed)
252
+ return Promise.resolve(s.resolve()).then((n) => {
253
+ if (n !== null && typeof n == "object" && typeof n.dispose == "function")
254
+ return n.dispose.call(n, this, s);
255
+ });
256
+ })).then(() => {
257
+ e.forEach((s) => this.delete(s.id)), m(this).children.forEach((s) => s.clear());
258
+ });
259
+ }
260
+ /**
261
+ * Detaches this `Container` instance from its parent, allowing it to be garbage-collected.
262
+ */
263
+ detach() {
264
+ if (this.parent) {
265
+ const t = m(this.parent).children, e = t.indexOf(this);
266
+ e > -1 && (t.splice(e, 1), delete this.parent);
267
+ }
268
+ }
269
+ /**
270
+ * Provides a way of touching a value in the `Container` without forcing it to be resolved.
271
+ * @param key Key of the resolved value to touch.
272
+ * @param handler Handler function for touching the resolved value.
273
+ */
274
+ touch(t, e) {
275
+ const s = m(this).resolvers.get(t);
276
+ if (s && s.constructed)
277
+ Promise.resolve(s.resolve()).then((n) => {
278
+ e(n, this);
279
+ });
280
+ else {
281
+ const n = m(this).touchQueue;
282
+ let r = n.get(t);
283
+ r || (r = [], n.set(t, r)), r.push(e);
284
+ }
285
+ return this.parent && !s ? this.parent.touch(t, e) : Promise.resolve();
286
+ }
287
+ /**
288
+ * Registers an asynchronous resolver.
289
+ * @param key Key of the resolver.
290
+ * @param factory Value factory.
291
+ */
292
+ registerAsync(t, e) {
293
+ const s = m(this).resolvers.get(t);
294
+ s && !s.async && process.env.NODE_ENV !== "production" && w(this).warn(`Mismatching resolver type. You are registering an async resolver with a key ('${t}') previously used by a non-async resolver.`);
295
+ const n = new Es(t, e, s, this);
296
+ return m(this).resolvers.set(t, n), n.id;
297
+ }
298
+ /**
299
+ * Registers a factory resolver for constructing the value to be resolved.
300
+ * @param key Key of the resolver.
301
+ * @param factory Value factory.
302
+ */
303
+ registerFactory(t, e) {
304
+ const s = m(this).resolvers.get(t);
305
+ s && s.async && process.env.NODE_ENV !== "production" && w(this).warn(`Mismatching resolver type. You are registering a non-async resolver with a key ('${t}') previously used by an async resolver.`);
306
+ const n = new Cs(t, e, s, this);
307
+ return m(this).resolvers.set(t, n), n.id;
308
+ }
309
+ /**
310
+ * Registers an synchronous resolver.
311
+ * @param key Key of the resolver.
312
+ * @param value Value.
313
+ */
314
+ register(t, e) {
315
+ const s = m(this).resolvers.get(t);
316
+ s && s.async && process.env.NODE_ENV !== "production" && w(this).warn(`Mismatching resolver type. You are registering a non-async resolver with a key ('${t}') previously used by an async resolver.`);
317
+ const n = new Ps(t, e, s, this);
318
+ return m(this).resolvers.set(t, n), n.id;
319
+ }
320
+ /**
321
+ * Gets the value for a synchronous resolver.
322
+ * @param key Key of resolver to get.
323
+ */
324
+ get(t) {
325
+ const e = m(this).resolvers.get(t);
326
+ if (e)
327
+ return e.async && process.env.NODE_ENV !== "production" && w(this).warn(`You are retrieving an async value (with key '${t}') by the non-async function 'container.get(key)'. This will not be supported in future versions. Use 'container.getAsync(key) instead.'`), e.resolve();
328
+ if (this.parent)
329
+ return this.parent.get(t);
330
+ }
331
+ /**
332
+ * Gets the value for a asynchronous resolver.
333
+ * @param key Key of resolver to get.
334
+ */
335
+ getAsync(t) {
336
+ const e = m(this).resolvers.get(t);
337
+ if (e) {
338
+ if (!e.async)
339
+ throw process.env.NODE_ENV !== "production" && w(this).warn(`You are retrieving a non-async value (with key '${t}') by the async function 'container.getAsync(key)'.Use 'container.get(key) instead.'`), "Mismatching resolver type";
340
+ return e.resolve();
341
+ }
342
+ return this.parent ? this.parent.getAsync(t) : Promise.resolve(void 0);
343
+ }
344
+ getMany(...t) {
345
+ const e = {};
346
+ return t.forEach((s) => e[s] = this.get(s)), e;
347
+ }
348
+ getManyAsync(...t) {
349
+ const e = {};
350
+ return Promise.all(t.map((s) => this.getAsync(s).then((n) => e[s] = n))).then(() => e);
351
+ }
352
+ createChild(t, e) {
353
+ const s = new Ye(t, e, this);
354
+ return m(this).children.push(s), s;
355
+ }
356
+ }, ye = class {
357
+ /**
358
+ *
359
+ * @param type Type of event.
360
+ * @param target The target of the event, which will handle the default behavour.
361
+ * @param cancelable Whether the event is cancelable by calling preventDefault().
362
+ * @param bubbles Whether the event will bubble up the parent hierarchy.
363
+ */
364
+ constructor(t, e, s = !1, n = !1) {
365
+ this.type = t, this.target = e, this.cancelable = !!s, this.bubbles = !!n, this.defaultPrevented = !1;
366
+ }
367
+ /**
368
+ * Cancels the default behaviour (if the event is cancelable).
369
+ */
370
+ preventDefault() {
371
+ this.cancelable && (this.defaultPrevented = !0);
372
+ }
373
+ };
374
+ const P = J(), $e = (i, t) => [].concat(
375
+ P(i).listenerLookup.get(t.toLowerCase()) || [],
376
+ P(i).listenerLookup.get("*") || []
377
+ ), be = (i, t, e, s) => {
378
+ let n, r;
379
+ return t instanceof ye ? (n = t, r = t.type) : (n = new ye(t, i.target, !!e.cancelable, !!e.bubbles), r = t), { event: n, type: r, async: s };
380
+ };
381
+ let ks = class Ze {
382
+ /**
383
+ * Creates a new Event Manager instance.
384
+ * @param target The target of events dispatched from this Event Manager instance.
385
+ * @param parent Parent Event Manager instance.
386
+ */
387
+ constructor(t, e) {
388
+ this.target = t, this.parent = e, P(this).listenerLookup = /* @__PURE__ */ new Map(), P(this).children = [];
389
+ }
390
+ /**
391
+ * Clears registered event listeners in this `EventManager` as well as in any children.
392
+ */
393
+ clear() {
394
+ P(this).listenerLookup.clear(), P(this).children.forEach((t) => t.clear());
395
+ }
396
+ /**
397
+ * Detaches this `EventManager` instance from its parent, allowing it to be garbage-collected.
398
+ */
399
+ detach() {
400
+ if (this.parent) {
401
+ const t = P(this.parent).children, e = t.indexOf(this);
402
+ e > -1 && t.splice(e, 1);
403
+ }
404
+ }
405
+ /**
406
+ * Creates an event subscription by registering an listener for an event type.
407
+ * @param type Event type to subscribe to.
408
+ * @param listener Listener for the event.
409
+ */
410
+ subscribe(t, e, s) {
411
+ const n = P(this).listenerLookup, r = t.toLowerCase();
412
+ return n.has(r) || n.set(r, []), n.get(r).push(e), () => this.unsubscribe(t, e);
413
+ }
414
+ /**
415
+ * Similar to `subscribe()` but immediately removes the subscription after the first call.
416
+ * @param type Event type to subscribe to.
417
+ * @param listener Listener for the event.
418
+ */
419
+ subscribeOnce(t, e) {
420
+ const s = this.subscribe(t, (n, r) => (s(), e(n, r)));
421
+ }
422
+ /**
423
+ * Removes a listener for the specified event type.
424
+ * @param type Event type to remove subscription for.
425
+ * @param listener Event listener to remove.
426
+ */
427
+ unsubscribe(t, e) {
428
+ const s = P(this).listenerLookup.get(t.toLowerCase());
429
+ if (s) {
430
+ const n = s.indexOf(e);
431
+ n > -1 && s.splice(n, 1);
432
+ }
433
+ }
434
+ /**
435
+ * Dispatches an asynchonous event to registered event listeners.
436
+ * @param eventOrType Event type or Event object to dispatch.
437
+ * @param data Optional data to be passed to event listeners.
438
+ * @param options Optional event options used if first parameter is an event type.
439
+ */
440
+ dispatchAsync(t, e, s = {}) {
441
+ const { event: n, type: r } = be(this, t, s, !0), o = $e(this, r);
442
+ let a = 0;
443
+ const c = o.length;
444
+ let h = Promise.resolve();
445
+ for (a = 0; a < c; a++)
446
+ ((l) => {
447
+ h = h.then((d) => d ? Promise.resolve(!0) : Promise.resolve(l(n, e)).then(() => n.defaultPrevented));
448
+ })(o[a]);
449
+ return h.then((l) => !l && n.bubbles && this.parent ? this.parent.dispatchAsync(n, e) : l);
450
+ }
451
+ /**
452
+ * Dispatches an event to registered event listeners.
453
+ * @param eventOrType Event type or Event object to dispatch.
454
+ * @param data Optional data to be passed to event listeners.
455
+ * @param options Optional event options used if first parameter is an event type.
456
+ */
457
+ dispatch(t, e, s = {}) {
458
+ const { event: n, type: r } = be(this, t, s, !1), o = $e(this, r);
459
+ let a = 0;
460
+ const c = o.length;
461
+ let h = !1;
462
+ for (a = 0; a < c; a++)
463
+ if (o[a](n, e), n.defaultPrevented) {
464
+ h = !0;
465
+ break;
466
+ }
467
+ return !h && n.bubbles && this.parent && (h = this.parent.dispatch(n, e)), h;
468
+ }
469
+ /**
470
+ * Creates a child instance to the current Event manager.
471
+ */
472
+ createChild(t) {
473
+ const e = new Ze(t, this);
474
+ return P(this).children.push(e), e;
475
+ }
476
+ };
477
+ const ot = (i, t, e) => {
478
+ const s = i.get("$plugins").map((n) => {
479
+ try {
480
+ return n.invoke(t, e);
481
+ } catch (r) {
482
+ w(i).error("An error occured when invoking a plugin.", n, r);
483
+ }
484
+ });
485
+ return Promise.all(s);
486
+ };
487
+ let Ss = class {
488
+ constructor(t) {
489
+ this.widget = t.get("$widget"), this.events = this.widget.events, this.container = this.widget.container, this.initialized = null, this.activated = null, this.initialize = this.initialize.bind(this), this.activate = this.activate.bind(this), this.deactivate = this.deactivate.bind(this), this.invoke = this.invoke.bind(this), this.createInstance();
490
+ }
491
+ createInstance() {
492
+ if (!this.widget.container.get("$instance")) {
493
+ const t = this.widget.container.get("$types"), e = this.widget.container.get("$type");
494
+ !e && w(this).error("Unable to create widget. No type is specified.");
495
+ const s = t[e];
496
+ !s && w(this).error(`Unable to create widget. Type '${e}' is not registered.`), this.widget.events.dispatch("widget:create-instance", {}, { bubbles: !0 });
497
+ try {
498
+ this.widget.container.register(
499
+ "$instance",
500
+ new s(this.container)
501
+ );
502
+ } catch (n) {
503
+ w(this).error("Unable to create widget type.", n);
504
+ }
505
+ this.widget.events.dispatch("widget:instance-created", {}, { bubbles: !0 });
506
+ }
507
+ }
508
+ /**
509
+ * The initialization is performed before the widget is activated but after it's configured
510
+ * and thus all required services are available. This hook is a good place to bind events that
511
+ * should trigger activation (e.g. click on "trigger links" or routing events)
512
+ * @param {object} data Custom initialization data passed to the widget.
513
+ */
514
+ initialize(t) {
515
+ return this.initialized = this.initialized || (() => {
516
+ const e = this.container.get("$instance"), s = e.initialize || (() => {
517
+ });
518
+ return this.initialized = Promise.resolve(s.call(e, t)).then(() => ot(this.container, "initialize", t)).then(() => {
519
+ });
520
+ })();
521
+ }
522
+ /**
523
+ * The activation is where the widget is actually created and rendered.
524
+ * Activation can be initialized from the outside or from an event originated
525
+ * in the "initialize" hook.
526
+ * @param {object} data Custom activation data passed to the widget.
527
+ */
528
+ activate(t) {
529
+ return (this.initialized || this.initialize()).then(() => {
530
+ this.activated = this.activated || (() => ot(this.container, "activate").then(() => {
531
+ const e = this.container.get("$instance");
532
+ return this.activated = e.activate(t);
533
+ }))();
534
+ });
535
+ }
536
+ deactivate() {
537
+ const t = this.container.get("$instance"), e = t.deactivate || (() => {
538
+ });
539
+ return ot(this.container, "deactivate").then(() => Promise.resolve(e.call(t))).then(() => {
540
+ this.initialized = null, this.activated = null;
541
+ }).then(() => {
542
+ });
543
+ }
544
+ /**
545
+ * Invokes a command on the widget component.
546
+ * @param command Name of command
547
+ * @param args Command arguments
548
+ */
549
+ invoke(t, ...e) {
550
+ return ot(this.container, "invoke", { command: t, args: e }).then(() => {
551
+ const s = this.container.get("$instance");
552
+ if (s[t])
553
+ return s[t].apply(s, e);
554
+ const n = s.invoke;
555
+ if (n)
556
+ return n.call(s, t, ...e);
557
+ });
558
+ }
559
+ };
560
+ const U = (i, t) => {
561
+ if (!t)
562
+ return !0;
563
+ if (typeof t == "string") {
564
+ const e = t.split(",");
565
+ for (let s = 0, n = e.length; s < n; s++) {
566
+ const r = e[s].trim();
567
+ if (r === i || r === "*")
568
+ return !0;
569
+ }
570
+ }
571
+ return t instanceof Array ? t.indexOf(i) > -1 : !1;
572
+ }, Os = (i, t) => {
573
+ if (typeof t == "function")
574
+ return t(i);
575
+ const e = typeof t == "string" ? Is(t) : t;
576
+ return !(!U(i.implementation.tenant || "", e.tenant || "") || !U(i.implementation.name, e.implementation || "") || !U(i.name, e.widget || "") || !U(i.container.get("$type"), e.type || ""));
577
+ }, Ns = (i, t) => {
578
+ if (typeof t == "function")
579
+ return t(i);
580
+ const e = typeof t == "string" ? Ms(t) : t;
581
+ return !(!U(i.tenant || "", e.tenant || "") || !U(i.name, e.implementation || ""));
582
+ }, Ge = (i) => (t) => Os(t, i), Ts = (i) => (t) => Ns(t, i), k = (i) => i instanceof Array && i.length === 1 ? i[0] : i, Is = (i) => {
583
+ const t = {}, e = i.split(":");
584
+ return e.length === 1 ? t.widget = k(e[0].split(",")) : e.length === 2 ? (t.implementation = k(e[0].split(",")), t.widget = k(e[1].split(","))) : (t.tenant = k(e[0].split(",")), t.implementation = k(e[1].split(",")), t.widget = k(e[2].split(","))), t;
585
+ }, Ms = (i) => {
586
+ const t = {}, e = i.split(":");
587
+ return e.length === 1 ? t.implementation = k(e[0].split(",")) : (t.tenant = k(e[0].split(",")), t.implementation = k(e[1].split(","))), t;
588
+ }, ut = J(), we = (i, t, e) => i.filter((s) => s.stage === t && Ge(s.selector)(e));
589
+ function Ds(i) {
590
+ const t = i.container.get("$environment");
591
+ let e = ut(t).configurationCache;
592
+ e && (e = e.filter((s) => s[0] !== i), ut(t).configurationCache = e);
593
+ }
594
+ var pt = /* @__PURE__ */ ((i) => (i.Implementation = "implementation", i.Widget = "widget", i))(pt || {}), S = /* @__PURE__ */ ((i) => (i.Pre = "pre", i.Post = "post", i))(S || {});
595
+ const Xe = (i, t, e) => (Object.keys(t).forEach((s) => {
596
+ const n = t[s];
597
+ if (typeof n == "function") {
598
+ const r = n();
599
+ typeof r.defaultArgs < "u" && e(r, ...r.defaultArgs), i[s] = (...o) => {
600
+ const a = Object.assign(
601
+ {},
602
+ r,
603
+ { handlerResolver: r.handlerResolver.bind({}) }
604
+ );
605
+ return e(a, ...o), i;
606
+ };
607
+ } else
608
+ i[s] = Xe(
609
+ {},
610
+ n,
611
+ e
612
+ );
613
+ }), i), js = (i, t) => {
614
+ switch (t) {
615
+ case "implementation":
616
+ return i.implementation;
617
+ case "widget":
618
+ return i;
619
+ }
620
+ }, _e = (i, t, e, s) => (s.forEach((n) => {
621
+ Xe(
622
+ i,
623
+ n,
624
+ (r, ...o) => {
625
+ const a = {
626
+ selector: t,
627
+ stage: r.stage,
628
+ handler: (c) => {
629
+ const h = js(c, r.scope), l = { container: h.container, events: h.events }, d = r.handlerResolver, u = d(l);
630
+ let p = ut(e.environment).configurationCache;
631
+ return p || (p = ut(e.environment).configurationCache = []), p.find((v) => v.indexOf(h) > -1 && v.indexOf(d) > -1) ? Promise.resolve() : (p.push([h, d]), Promise.resolve(u(...o)));
632
+ }
633
+ };
634
+ e.instructions.push(a);
635
+ }
636
+ );
637
+ }), i);
638
+ function Hs(i, t) {
639
+ function e(s) {
640
+ return _e(
641
+ {},
642
+ s,
643
+ i,
644
+ t
645
+ );
646
+ }
647
+ return _e(
648
+ e,
649
+ "*",
650
+ i,
651
+ t
652
+ );
653
+ }
654
+ const Ls = (i, t, e, s) => {
655
+ try {
656
+ const n = new t(e, s);
657
+ return {
658
+ name: i,
659
+ invoke: (r, o) => {
660
+ let a;
661
+ return n[r] && (a = n[r].call(n, o)), Promise.resolve(a);
662
+ },
663
+ getInstance: () => n
664
+ };
665
+ } catch (n) {
666
+ if (n.message && n.message.indexOf("is not a constructor") >= 0)
667
+ return {
668
+ name: i,
669
+ invoke: (r) => {
670
+ let o;
671
+ return r === "initialize" && (o = t(e, s)), Promise.resolve(o);
672
+ },
673
+ getInstance: () => t
674
+ };
675
+ throw n;
676
+ }
677
+ };
678
+ function Ae(i, t) {
679
+ return typeof i > "u" ? t : i;
680
+ }
681
+ let Rs = class {
682
+ constructor(t = {}) {
683
+ this.part = t;
684
+ }
685
+ createCommand(t, e, s) {
686
+ let n;
687
+ typeof e == "function" ? n = {
688
+ scope: pt.Widget,
689
+ stage: S.Post,
690
+ defaultArgs: void 0,
691
+ handlerResolver: e
692
+ } : n = {
693
+ scope: Ae(e.scope, pt.Widget),
694
+ stage: Ae(e.stage, S.Post),
695
+ defaultArgs: e.defaultArgs,
696
+ handlerResolver: s
697
+ };
698
+ let r = this.part;
699
+ const o = t.split(".");
700
+ return o.forEach((a, c) => {
701
+ c === o.length - 1 ? r[a] || (r[a] = () => n) : r = this.part[a] = this.part[a] || {};
702
+ }), this;
703
+ }
704
+ get() {
705
+ return this.part;
706
+ }
707
+ };
708
+ const ts = (i) => {
709
+ const t = new Rs({});
710
+ return i(t), t.get();
711
+ }, Us = ts((i) => {
712
+ i.createCommand(
713
+ "types.register",
714
+ { scope: pt.Implementation, stage: S.Pre },
715
+ (t) => (e, s) => {
716
+ t.container.get("$types")[e] = s;
717
+ }
718
+ ).createCommand(
719
+ "type",
720
+ { stage: S.Pre },
721
+ (t) => (e) => {
722
+ t.container.register("$type", e);
723
+ }
724
+ ).createCommand(
725
+ "settings",
726
+ { stage: S.Pre, defaultArgs: [null] },
727
+ (t) => (e) => {
728
+ t.events.dispatch(
729
+ "settings:change",
730
+ e,
731
+ { bubbles: !0 }
732
+ ), t.container.register("$settings", e);
733
+ }
734
+ ).createCommand(
735
+ "plugin",
736
+ { stage: S.Pre },
737
+ (t) => (e, s, n) => {
738
+ const { container: r } = t;
739
+ let o = null, a = e, c = s;
740
+ typeof e == "string" && (o = e, a = s, c = n);
741
+ const h = (l) => {
742
+ const { transformPluginSettings: d } = t.container.get("$environmentOptions"), u = d ? d(
743
+ c || {},
744
+ o,
745
+ t.container,
746
+ a
747
+ ) : s;
748
+ try {
749
+ const p = Ls(
750
+ o,
751
+ a,
752
+ r,
753
+ u
754
+ );
755
+ r.get("$plugins").push(p), l && p.invoke("initialize", null);
756
+ } catch (p) {
757
+ w(t).warn("Error when initializing plugin", p);
758
+ }
759
+ };
760
+ t.container.get("$instance") ? h(!0) : t.events.subscribeOnce("widget:instance-created", () => h(!1));
761
+ }
762
+ ).createCommand(
763
+ "container.register",
764
+ (t) => (e, s) => {
765
+ t.container.register(e, s);
766
+ }
767
+ ).createCommand(
768
+ "container.registerAsync",
769
+ (t) => (e, s) => {
770
+ t.container.registerAsync(e, s);
771
+ }
772
+ ).createCommand(
773
+ "container.registerFactory",
774
+ (t) => (e, s) => {
775
+ t.container.registerFactory(e, s);
776
+ }
777
+ ).createCommand(
778
+ "container.touch",
779
+ (t) => (e, s) => {
780
+ t.container.touch(e, s);
781
+ }
782
+ ).createCommand(
783
+ "csp",
784
+ {},
785
+ (t) => (e) => {
786
+ t.container.register("csp", e);
787
+ }
788
+ );
789
+ }), zs = Us;
790
+ function Ws(i, t, e = []) {
791
+ const s = [zs].concat(e), n = Hs(
792
+ t,
793
+ s
794
+ );
795
+ i(n, t);
796
+ }
797
+ let Bs = class {
798
+ constructor() {
799
+ this.tasks = [], this.current = Promise.resolve(), this.next = this.next.bind(this);
800
+ }
801
+ add(t, e, s, n) {
802
+ this.tasks.push({ task: t, resolve: e, reject: s, done: n }), this.next();
803
+ }
804
+ next() {
805
+ this.current = this.current.then(() => {
806
+ const t = this.tasks.shift();
807
+ if (t) {
808
+ const e = Promise.resolve(t.task());
809
+ return Promise.resolve(e).then(this.next).then(() => e.then((s) => {
810
+ t.done(), t.resolve(s);
811
+ })).catch((s) => (t.done(), t.reject(s), this.next()));
812
+ }
813
+ return Promise.resolve();
814
+ });
815
+ }
816
+ };
817
+ const at = /* @__PURE__ */ new WeakMap();
818
+ function Vs(i) {
819
+ return at.has(i) || at.set(i, new Bs()), (t) => new Promise((e, s) => {
820
+ const n = at.get(i);
821
+ n.add(t, e, s, () => {
822
+ n.tasks.length || at.delete(i);
823
+ });
824
+ });
825
+ }
826
+ const Ee = (i) => typeof i < "u", q = (i, t) => {
827
+ i.events.dispatch("widget:state-change", { state: t }, { bubbles: !0 }), i.state = t, i.events.dispatch("widget:state-changed", {}, { bubbles: !0 });
828
+ }, E = J(), Js = (i) => {
829
+ const { container: t, events: e } = i;
830
+ t.get("$controller") || (t.register("$controller", new Ss(t)), e.dispatch("widget:controller-created", {}, { bubbles: !0 }));
831
+ };
832
+ class Fs {
833
+ /**
834
+ * Creates a new `Widget` instance.
835
+ * @param name Name of widget.
836
+ * @param implementation The implementation this instance belongs to.
837
+ * @param configuration Configuration for the widget.
838
+ */
839
+ constructor(t, e, s) {
840
+ this.state = "deactivated", this.name = t, this.implementation = e, this.container = e.container.createChild(this, t), this.events = e.events.createChild(this), E(this).subscriptions = [], s && e.configure((n) => {
841
+ const r = n(t);
842
+ Ee(s.type) && r.type(s.type), Ee(s.settings) && r.settings(s.settings), s.plugins && Object.keys(s.plugins).forEach((o) => {
843
+ var a;
844
+ const c = (a = s.plugins) == null ? void 0 : a[o];
845
+ r.plugin(o, c);
846
+ });
847
+ }), this.load = this.load.bind(this), this.activate = this.activate.bind(this), this.invoke = this.invoke.bind(this), this.deactivate = this.deactivate.bind(this);
848
+ }
849
+ /**
850
+ * Initializes the widget, if not already initialized, and applies any
851
+ * pending configuration.
852
+ */
853
+ load() {
854
+ return Vs(this)(() => {
855
+ E(this).deactivatedPromise = null;
856
+ const t = this.state === "deactivated";
857
+ t && (q(
858
+ this,
859
+ "activating"
860
+ /* Activating */
861
+ ), this.container.register("$widget", this), this.container.register("$controller", null), this.container.register("$plugins", []), this.container.register("$type", null), this.container.register("$instance", null)), q(
862
+ this,
863
+ "loading"
864
+ /* Loading */
865
+ );
866
+ const e = this.implementation.instructions, s = we(e, S.Pre, this);
867
+ return Promise.all(s.map((n) => n.handler(this))).then(() => {
868
+ Js(this);
869
+ const n = we(e, S.Post, this);
870
+ return Promise.all(n.map((r) => r.handler(this))).then(() => {
871
+ t && this.container.get("$controller").initialize();
872
+ });
873
+ }).then(() => (q(
874
+ this,
875
+ "activated"
876
+ /* Activated */
877
+ ), this));
878
+ });
879
+ }
880
+ /**
881
+ * Activates the widget and makes it ready for receiving commands.
882
+ * @param data Activation data
883
+ */
884
+ activate(t) {
885
+ E(this).subscriptions.push(
886
+ this.implementation.events.subscribe("implementation:configured", () => {
887
+ [
888
+ "activated",
889
+ "activating",
890
+ "loading"
891
+ /* Loading */
892
+ ].indexOf(this.state) > -1 && this.load();
893
+ })
894
+ );
895
+ const e = E(this).activatedPromise;
896
+ return e ? (process.env.NODE_ENV !== "production" && w(this).warn(`Widget '${this.name}' has already been activated. The passed arguments for this activation will be discarded.`, t), e) : E(this).activatedPromise = this.load().then(() => this.container.get("$controller").activate(t));
897
+ }
898
+ /**
899
+ * Invokes a command on a widget. If the widget isn't activate the invocation
900
+ * will be suspended until activation.
901
+ * @param command Command to invoke.
902
+ * @param args Command arguments.
903
+ */
904
+ invoke(t, ...e) {
905
+ const s = E(this).activatedPromise, n = (r, ...o) => s.then(this.load).then(() => this.container.get("$controller").invoke(r, ...o));
906
+ return s ? n(t, ...e) : (process.env.NODE_ENV !== "production" && w(this).warn("You are invoking a command on a deactivated widget. The invocation will be queued until the widget is activated.", this), new Promise((r) => {
907
+ const o = this.events.subscribe("widget:state-changed", () => {
908
+ this.state === "activated" && (o(), r(n(t, ...e)));
909
+ });
910
+ }));
911
+ }
912
+ /**
913
+ * Deactivates the widget by clearing the `Container` and removing any event subscriptions in the
914
+ * `EventManager`.
915
+ */
916
+ deactivate() {
917
+ return E(this).deactivatedPromise || (this.state === "deactivated" ? Promise.resolve() : (q(
918
+ this,
919
+ "deactivating"
920
+ /* Deactivating */
921
+ ), E(this).deactivatedPromise = this.container.get("$controller").deactivate().then(() => (E(this).activatedPromise = null, E(this).subscriptions.forEach((e) => e()), E(this).subscriptions = [], this.container.clear().then(() => {
922
+ this.events.clear(), Ds(this), q(
923
+ this,
924
+ "deactivated"
925
+ /* Deactivated */
926
+ );
927
+ })))));
928
+ }
929
+ }
930
+ const Pe = J();
931
+ class qs {
932
+ /**
933
+ * Creates a new Implementation instance.
934
+ * @param configuration Configuration for the implementation.
935
+ * @param environment The parent environment.
936
+ * @param configurationApiExtensions Optional configuration API extensions.
937
+ */
938
+ constructor(t, e, s = []) {
939
+ this.instructions = [], this.widgets = /* @__PURE__ */ new Map(), this.name = t.name, this.tenant = t.tenant, this.environment = e, this.container = e.container.createChild(this, this.name), this.events = e.events.createChild(this), this.container.register("$types", {}), Pe(this).configurationApiExtensions = s;
940
+ }
941
+ /**
942
+ * Loads all widgets in the implementation.
943
+ */
944
+ load() {
945
+ const t = Array.from(this.widgets.values());
946
+ return Promise.all(t.map((e) => e.load())).then(() => t);
947
+ }
948
+ /**
949
+ * Configures the implementation by adding a configuration callback.
950
+ * @param configFn Callback function for configuration.
951
+ */
952
+ configure(t) {
953
+ return Ws(t, this, Pe(this).configurationApiExtensions), this.events.dispatch(
954
+ "implementation:configured",
955
+ { implementation: this },
956
+ { bubbles: !0 }
957
+ ), this;
958
+ }
959
+ /**
960
+ * Creates a widget on the implementation and returns its `WidgetData`.
961
+ * @param name Widget name.
962
+ * @param configuration Widget configuration.
963
+ */
964
+ createWidget(t, e) {
965
+ const s = new Fs(t, this, e);
966
+ return this.widgets.set(s.name, s), s;
967
+ }
968
+ }
969
+ function Qs(i, t, e) {
970
+ const s = new qs(i, t, e);
971
+ return i.widgets && Object.keys(i.widgets).forEach((n) => {
972
+ var r;
973
+ const o = (r = i.widgets) == null ? void 0 : r[n];
974
+ s.createWidget(n, o);
975
+ }), s;
976
+ }
977
+ let Ce = class es {
978
+ constructor(t, e) {
979
+ this.selectorFactory = e, typeof t == "function" ? this.resolver = t : this.resolver = () => t;
980
+ }
981
+ append(t) {
982
+ const e = typeof t == "function" ? t : () => t;
983
+ return new es(
984
+ () => this.all().concat(e()),
985
+ this.selectorFactory
986
+ );
987
+ }
988
+ all() {
989
+ return this.resolver().concat([]);
990
+ }
991
+ query(t) {
992
+ return this.all().filter(this.selectorFactory(t));
993
+ }
994
+ find(t) {
995
+ const e = this.query(t);
996
+ if (e.length)
997
+ return e[0];
998
+ }
999
+ };
1000
+ const Xt = "#____version____#", St = J(), Ks = (i) => i.tenant ? `${i.name}:${i.tenant}` : i.name, ss = class {
1001
+ constructor(t, e = [], s = {}) {
1002
+ this.widgets = new Ce(
1003
+ () => {
1004
+ let n = [];
1005
+ return this.implementations.all().forEach((r) => {
1006
+ n = n.concat(Array.from(r.widgets.values()));
1007
+ }), n;
1008
+ },
1009
+ Ge
1010
+ ), this.implementations = new Ce([], Ts), this.name = t, this.container = new xs(this, t), this.events = new ks(this), this.container.register("$version", Xt), this.container.register("$environment", this), this.container.register("$environmentOptions", s), St(this).configurationApiExtensions = e;
1011
+ }
1012
+ /**
1013
+ * Creates an implementation based on the provided configuration.
1014
+ * @param config Implementation configuration.
1015
+ */
1016
+ createImplementation(t) {
1017
+ const e = Ks(t);
1018
+ let s = this.implementations.find(e);
1019
+ if (s)
1020
+ return process.env.NODE_ENV !== "production" && w(s).warn(`Implementation "${e}" already exist on current environment.`), s;
1021
+ const n = St(this).configurationApiExtensions;
1022
+ return s = Qs(
1023
+ t,
1024
+ this,
1025
+ n
1026
+ ), this.implementations = this.implementations.append([s]), this.events.dispatch("implementation:created", { implementation: s }), s;
1027
+ }
1028
+ /**
1029
+ * Patches the Environment instance configuration.
1030
+ * @param configuration Environment configuration.
1031
+ */
1032
+ patch(t = {}) {
1033
+ const { name: e, configurationApiExtensions: s } = t;
1034
+ typeof e < "u" && e !== null && (this.name = e), s && s.forEach(
1035
+ (n) => {
1036
+ St(this).configurationApiExtensions.push(n);
1037
+ }
1038
+ );
1039
+ }
1040
+ /**
1041
+ * Creates a new Environment instance based on the provided configuration.
1042
+ * @param configuration Environment configuration.
1043
+ */
1044
+ static create(t = {}) {
1045
+ return new ss(
1046
+ t.name || "",
1047
+ t.configurationApiExtensions,
1048
+ t.options
1049
+ );
1050
+ }
1051
+ };
1052
+ let is = ss;
1053
+ is.version = Xt;
1054
+ const yt = (i, t, ...e) => typeof t == "string" ? i(`[humany] ${t}`, ...e) : i(t, ...e), K = class {
1055
+ constructor() {
1056
+ this.keys = [], this.log = (t, ...e) => this.lookup(t, () => K.log(...e)), this.warn = (t, ...e) => this.lookup(t, () => K.warn(...e)), this.error = (t, ...e) => this.lookup(t, () => K.error(...e)), this.info = (t, ...e) => this.lookup(t, () => K.info(...e));
1057
+ }
1058
+ lookup(t, e) {
1059
+ this.keys.indexOf(t) === -1 && (this.keys.push(t), e());
1060
+ }
1061
+ };
1062
+ let _ = K;
1063
+ _.log = (...i) => yt(console.log, ...i);
1064
+ _.warn = (...i) => yt(console.warn, ...i);
1065
+ _.error = (...i) => yt(console.error, ...i);
1066
+ _.info = (...i) => yt(console.info, ...i);
1067
+ const ns = (i) => {
1068
+ let t = {}, e, s;
1069
+ if (typeof i != "object" || i === null)
1070
+ return i;
1071
+ t = Array.isArray(i) ? [] : {};
1072
+ for (s in i)
1073
+ e = i[s], t[s] = typeof e == "object" && e !== null ? ns(e) : e;
1074
+ return t;
1075
+ }, Ys = ns;
1076
+ function xe(i) {
1077
+ let t = 0;
1078
+ if (i.length === 0)
1079
+ return t.toString();
1080
+ for (let e = 0; e < i.length; e++) {
1081
+ const s = i.charCodeAt(e);
1082
+ t = (t << 5) - t + s, t = t & t;
1083
+ }
1084
+ return t.toString();
1085
+ }
1086
+ let Zs = class {
1087
+ constructor(t, e) {
1088
+ this.lockWarningTime = t, this.lockErrorTime = e, this.tasks = [], this.current = Promise.resolve(), this.next = this.next.bind(this);
1089
+ }
1090
+ add(t, e, s, n) {
1091
+ this.tasks.push({ task: t, resolve: e, reject: s, done: n }), this.next();
1092
+ }
1093
+ next() {
1094
+ this.current = this.current.then(() => {
1095
+ const t = this.tasks.shift();
1096
+ if (t) {
1097
+ let e;
1098
+ const s = setTimeout(() => {
1099
+ process.env.NODE_ENV !== "production" && _.warn(
1100
+ `A lock has exceeded ${this.lockWarningTime} ms. Waiting additional ${this.lockErrorTime} ms before rejecting the task.`,
1101
+ t
1102
+ ), e = setTimeout(() => {
1103
+ t.reject("lock timeout exceeded");
1104
+ }, this.lockErrorTime);
1105
+ }, this.lockWarningTime), n = Promise.resolve(t.task()).then((r) => (clearTimeout(s), clearTimeout(e), r));
1106
+ return Promise.resolve(n).then(this.next).then(
1107
+ () => n.then((r) => {
1108
+ t.done(), t.resolve(r);
1109
+ })
1110
+ ).catch((r) => (t.done(), t.reject(r), this.next()));
1111
+ }
1112
+ return Promise.resolve();
1113
+ });
1114
+ }
1115
+ };
1116
+ const ct = /* @__PURE__ */ new WeakMap();
1117
+ function et(i, t = 5e3, e = 1e3) {
1118
+ return ct.has(i) || ct.set(i, new Zs(t, e)), (s) => new Promise((n, r) => {
1119
+ const o = ct.get(i);
1120
+ o.add(s, n, r, () => {
1121
+ o.tasks.length || ct.delete(i);
1122
+ });
1123
+ });
1124
+ }
1125
+ const O = () => Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
1126
+ function st() {
1127
+ return O() + O() + "-" + O() + "-" + O() + "-" + O() + "-" + O() + O() + O();
1128
+ }
1129
+ var Gs = Object.defineProperty, Xs = Object.defineProperties, ti = Object.getOwnPropertyDescriptors, ke = Object.getOwnPropertySymbols, ei = Object.prototype.hasOwnProperty, si = Object.prototype.propertyIsEnumerable, Se = (i, t, e) => t in i ? Gs(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, Bt = (i, t) => {
1130
+ for (var e in t || (t = {}))
1131
+ ei.call(t, e) && Se(i, e, t[e]);
1132
+ if (ke)
1133
+ for (var e of ke(t))
1134
+ si.call(t, e) && Se(i, e, t[e]);
1135
+ return i;
1136
+ }, ii = (i, t) => Xs(i, ti(t));
1137
+ const ni = (i) => {
1138
+ const t = [];
1139
+ return [
1140
+ (e, s) => {
1141
+ t.push(i.subscribe(e, s));
1142
+ },
1143
+ () => {
1144
+ t.forEach((e) => {
1145
+ e();
1146
+ });
1147
+ }
1148
+ ];
1149
+ };
1150
+ let te = class {
1151
+ constructor(t, e = []) {
1152
+ this.platform = t, this.rules = e;
1153
+ }
1154
+ match(t) {
1155
+ return this.rules.every((e) => !(e.id && e.id !== t.id || e.type && e.type !== t.type));
1156
+ }
1157
+ ofType(t) {
1158
+ return this.rules.push({ type: t }), this;
1159
+ }
1160
+ withId(t) {
1161
+ return this.rules.push({ id: t }), this;
1162
+ }
1163
+ select() {
1164
+ return new ri(this.platform, this);
1165
+ }
1166
+ }, rs = class {
1167
+ constructor(t, e, s) {
1168
+ this.platform = t, this.node = e, this.actions = new ee(
1169
+ t,
1170
+ new te(t).withId(e.id),
1171
+ s
1172
+ );
1173
+ const [n, r] = ni(this.platform.events);
1174
+ this.subscribe = n, this.unsubscribe = r;
1175
+ }
1176
+ properties(t) {
1177
+ return t && this.node.touchProperties((e) => t(e)), this.node.attributes.properties;
1178
+ }
1179
+ context(t) {
1180
+ return t && this.subscribe("components:context-changed", (e, { node: s }) => {
1181
+ s === this.node && t(this.node.attributes.context);
1182
+ }), this.node.attributes.context;
1183
+ }
1184
+ layout(t) {
1185
+ return t && this.subscribe("components:layout-changed", (e, { node: s }) => {
1186
+ s === this.node && t(this.node.attributes.layout);
1187
+ }), this.node.attributes.layout;
1188
+ }
1189
+ writeProperties(t, e) {
1190
+ this.node.writeProperties(t, e);
1191
+ }
1192
+ writeContext(t, e) {
1193
+ this.node.writeProperties(t, e);
1194
+ }
1195
+ writeLayout(t, e) {
1196
+ this.node.writeLayout(t, e);
1197
+ }
1198
+ dispose() {
1199
+ this.unsubscribe(), this.actions.dispose();
1200
+ }
1201
+ };
1202
+ class ri {
1203
+ constructor(t, e, s = !0) {
1204
+ this.platform = t, this.target = e, this.clearOnDispose = s, this.removes = [], this.actions = new ee(this.platform, this.target);
1205
+ }
1206
+ writeProperties(t, e) {
1207
+ this.removes.push(
1208
+ this.platform.write({
1209
+ options: e,
1210
+ attributes: { properties: t },
1211
+ target: this.target,
1212
+ removable: this.clearOnDispose
1213
+ })
1214
+ );
1215
+ }
1216
+ writeContext(t, e) {
1217
+ this.removes.push(
1218
+ this.platform.write({
1219
+ options: e,
1220
+ attributes: { context: t },
1221
+ target: this.target,
1222
+ removable: this.clearOnDispose
1223
+ })
1224
+ );
1225
+ }
1226
+ writeLayout(t, e) {
1227
+ this.removes.push(
1228
+ this.platform.write({
1229
+ options: e,
1230
+ attributes: { layout: t },
1231
+ target: this.target,
1232
+ removable: this.clearOnDispose
1233
+ })
1234
+ );
1235
+ }
1236
+ dispose() {
1237
+ this.removes.forEach((t) => {
1238
+ t();
1239
+ }), this.actions.dispose();
1240
+ }
1241
+ }
1242
+ const oi = (i, t, e) => {
1243
+ const s = i.concat(), n = (r, o, a) => {
1244
+ let c = !0;
1245
+ if (s.length) {
1246
+ const h = s.shift(), l = (d, u) => (c = !1, n(d, Object.assign({}, o, u), a));
1247
+ return Promise.resolve(h(r, l, a)).then((d) => ii(Bt({}, d), {
1248
+ cancelled: c
1249
+ }));
1250
+ }
1251
+ return Promise.resolve({ data: r, cancelled: !1, options: o });
1252
+ };
1253
+ return n(t, {}, e);
1254
+ };
1255
+ let ee = class {
1256
+ constructor(t, e, s) {
1257
+ this.platform = t, this.target = e, this.ns = s, this.subscriptions = [], this.create = this.create.bind(this);
1258
+ }
1259
+ create(t, e = () => {
1260
+ }) {
1261
+ const s = {
1262
+ key: t,
1263
+ fn: e,
1264
+ target: this.target,
1265
+ ns: this.ns
1266
+ };
1267
+ this.platform.actionsState.handlers.push(s);
1268
+ const n = () => {
1269
+ const r = this.platform.actionsState.handlers.indexOf(s);
1270
+ r > -1 && this.platform.actionsState.handlers.splice(r, 1);
1271
+ };
1272
+ return this.subscriptions.push(n), n;
1273
+ }
1274
+ dispatch(t, e) {
1275
+ const s = this.platform.nodes.all.concat(
1276
+ this.platform.nodes.detached
1277
+ ), n = {}, r = this.platform.actionsState.handlers.filter(
1278
+ (o) => o.key === t && (!o.ns || !this.ns || o.ns === this.ns)
1279
+ );
1280
+ return Promise.all(
1281
+ r.map((o) => {
1282
+ const a = s.filter(
1283
+ (h) => o.target.match(h) && this.target.match(h)
1284
+ ), c = this.platform.actionsState.watchers.filter((h) => h.key === t && (!h.ns || !this.ns || h.ns === this.ns) && a.some((l) => h.target.match(l))).map((h) => h.fn);
1285
+ return Promise.all(
1286
+ a.map((h) => {
1287
+ const l = new rs(
1288
+ this.platform,
1289
+ h,
1290
+ this.ns
1291
+ );
1292
+ return oi(c, e, l).then((d) => {
1293
+ const { data: u = {}, options: p, cancelled: v } = d;
1294
+ return Promise.resolve(
1295
+ v ? {} : o.fn(u, p, l)
1296
+ ).then((f) => {
1297
+ n[h.id] = f;
1298
+ });
1299
+ });
1300
+ })
1301
+ );
1302
+ })
1303
+ ).then(() => n);
1304
+ }
1305
+ watch(t, e) {
1306
+ let s = t, n = this.ns;
1307
+ const r = t.split(".");
1308
+ r.length > 1 && (n = r[0], s = r.splice(1).join("."));
1309
+ const o = {
1310
+ fn: e,
1311
+ target: this.target,
1312
+ key: s,
1313
+ ns: n
1314
+ };
1315
+ this.platform.actionsState.watchers.push(o);
1316
+ const a = () => {
1317
+ const c = this.platform.actionsState.watchers.indexOf(o);
1318
+ c > -1 && this.platform.actionsState.watchers.splice(c, 1);
1319
+ };
1320
+ return this.subscriptions.push(a), a;
1321
+ }
1322
+ dispose() {
1323
+ this.subscriptions.forEach((t) => t());
1324
+ }
1325
+ };
1326
+ ts((i) => {
1327
+ i.createCommand("components", (t) => (e) => {
1328
+ t.events.subscribeOnce("components:platform-created", (s, { platform: n }) => {
1329
+ e.handlers && e.handlers.forEach(([r, o]) => {
1330
+ n.addComponentHandler(r, o);
1331
+ });
1332
+ });
1333
+ });
1334
+ });
1335
+ let Oe = class {
1336
+ constructor(t, e) {
1337
+ this.events = t, this.tags = [], this.children = {}, this.changesets = [], this.mountCount = 0, this.id = st(), this.type = e, this.attributes = {
1338
+ context: {},
1339
+ properties: {},
1340
+ layout: {},
1341
+ tags: []
1342
+ }, this.writeLayout({ size: "full", indent: 0 });
1343
+ }
1344
+ mount(t, e) {
1345
+ let s = t.get("mounted-nodes");
1346
+ return s || (s = /* @__PURE__ */ new Map(), t.register("mounted-nodes", s)), s.has(this) ? (process.env.NODE_ENV !== "production" && _.error("Trying to mount an already mounted component node.", this), () => {
1347
+ }) : (this.events.dispatch("components:node-mounted", { node: this }), this.mountCount === 0 && (this.mountCount = this.mountCount + 1, this.events.dispatch("components:node-enter", { node: this })), () => {
1348
+ s.delete(this), this.events.dispatch("components:node-unmounted", { node: this }), this.mountCount = this.mountCount - 1, this.mountCount === 0 && this.events.dispatch("components:node-exit", { node: this });
1349
+ });
1350
+ }
1351
+ appendChild(t, e = "default") {
1352
+ if (t.parent) {
1353
+ if (t.parent === this)
1354
+ return;
1355
+ t.parent.removeChild(t);
1356
+ }
1357
+ t.parent = this, this.children[e] || (this.children[e] = []), this.children[e].push(t), this.events.dispatch("components:node-appended", { node: t });
1358
+ }
1359
+ prependChild(t, e = "default") {
1360
+ if (t.parent) {
1361
+ if (t.parent === this)
1362
+ return;
1363
+ t.parent.removeChild(t);
1364
+ }
1365
+ t.parent = this, this.children[e] || (this.children[e] = []), this.children[e].unshift(t), this.events.dispatch("components:node-appended", { node: t });
1366
+ }
1367
+ touchProperties(t, e = {}, s) {
1368
+ const n = [{ properties: t }, e];
1369
+ return this.changesets.push(n), this.events.dispatch("components:set-properties", { node: this }), () => {
1370
+ if (s) {
1371
+ const r = this.changesets.indexOf(n);
1372
+ r > -1 && (this.changesets.splice(r, 1), this.events.dispatch("components:set-properties", { node: this }));
1373
+ }
1374
+ };
1375
+ }
1376
+ writeProperties(t, e = {}, s) {
1377
+ const n = [{ properties: t }, e];
1378
+ return this.changesets.push(n), this.events.dispatch("components:set-properties", { node: this }), () => {
1379
+ if (s) {
1380
+ const r = this.changesets.indexOf(n);
1381
+ r > -1 && (this.changesets.splice(r, 1), this.events.dispatch("components:set-properties", { node: this }));
1382
+ }
1383
+ };
1384
+ }
1385
+ writeLayout(t, e = {}, s) {
1386
+ const n = [{ layout: t }, e];
1387
+ return this.changesets.push(n), this.events.dispatch("components:set-layout", { node: this }), () => {
1388
+ if (!s)
1389
+ return;
1390
+ const r = this.changesets.indexOf(n);
1391
+ r > -1 && (this.changesets.splice(r, 1), this.events.dispatch("components:set-layout", { node: this }));
1392
+ };
1393
+ }
1394
+ writeContext(t, e = {}, s) {
1395
+ const n = [{ context: t }, e];
1396
+ return this.changesets.push(n), this.events.dispatch("components:set-context", { node: this }), () => {
1397
+ if (!s)
1398
+ return;
1399
+ const r = this.changesets.indexOf(n);
1400
+ r > -1 && (this.changesets.splice(r, 1), this.events.dispatch("components:set-context", { node: this }));
1401
+ };
1402
+ }
1403
+ getChildren(t = "default") {
1404
+ const e = this.children[t] || [];
1405
+ return e.reduce((s, n, r) => {
1406
+ const { order: o = r } = n.attributes.layout;
1407
+ return s[o] ? s.splice(o, 0, n) : s[o] = n, s;
1408
+ }, Array(e.length));
1409
+ }
1410
+ remove() {
1411
+ this.parent && this.parent.removeChild(this);
1412
+ }
1413
+ removeChild(t) {
1414
+ Object.keys(this.children).forEach((e) => {
1415
+ const s = this.children[e], n = s.indexOf(t);
1416
+ n > -1 && (s.splice(n, 1), this.events.dispatch("components:node-removed", { node: t, parentNode: this }));
1417
+ }), delete t.parent;
1418
+ }
1419
+ };
1420
+ const os = (i, t, e) => {
1421
+ for (let s = 0, n = i.length; s < n && e(i[s]) !== !0; s++) {
1422
+ const r = t[i[s].id] || "default", o = i[s].getChildren(r);
1423
+ os(o, t, e);
1424
+ }
1425
+ }, se = (i, t, e) => {
1426
+ if (e(i) !== !0) {
1427
+ const s = t[i.id] || "default", n = i.children[s];
1428
+ os(n, t, e);
1429
+ }
1430
+ }, Ot = (i, t) => {
1431
+ const e = [];
1432
+ return se(i, t, (s) => {
1433
+ e.push(s);
1434
+ }), e;
1435
+ }, ai = (i, t, e) => {
1436
+ let s;
1437
+ return se(i, t, (n) => {
1438
+ if (e(n))
1439
+ return s = n, !0;
1440
+ }), s;
1441
+ };
1442
+ class ci {
1443
+ constructor(t, e, s) {
1444
+ this.root = t, this.switches = e, this.all = [], this.visible = [], this.detached = [], s.subscribe("components:node-appended", (n, r) => {
1445
+ this.all.push(r.node), this.visible = Ot(t, e);
1446
+ }), s.subscribe("components:node-removed", (n, r) => {
1447
+ let o = this.all.indexOf(r.node);
1448
+ o > -1 && this.all.splice(o, 1), o = this.visible.indexOf(r.node), o > -1 && this.visible.splice(o, 1), this.visible = Ot(t, e);
1449
+ }), s.subscribe("components:node-switched", (n, r) => {
1450
+ this.visible = Ot(t, e);
1451
+ });
1452
+ }
1453
+ query(t = {}) {
1454
+ const e = [];
1455
+ return se(this.root, this.switches, (s) => {
1456
+ Object.keys(t).every((n) => t[n] === s[n]) && e.push(s);
1457
+ }), e;
1458
+ }
1459
+ get(t) {
1460
+ return ai(this.root, this.switches, (e) => e.id === t) || this.detached.find((e) => e.id === t);
1461
+ }
1462
+ }
1463
+ class hi {
1464
+ constructor() {
1465
+ this.handlers = /* @__PURE__ */ new Map();
1466
+ }
1467
+ add(t, e) {
1468
+ this.handlers.set(t, e);
1469
+ }
1470
+ get(t) {
1471
+ return this.handlers.get(t);
1472
+ }
1473
+ }
1474
+ const li = (i) => {
1475
+ let t = i, e = 0;
1476
+ for (; t.parent; )
1477
+ e = e + 1, t = t.parent;
1478
+ return e;
1479
+ }, di = (i) => i.map(([t, e]) => [li(t), t, e]).sort(([t], [e]) => t - e).map(([, t, e]) => [t, e]), Nt = (i) => i instanceof Date ? !1 : i && typeof i == "object" && !Array.isArray(i), x = (i, ...t) => {
1480
+ if (!t.length)
1481
+ return i;
1482
+ const e = t.shift();
1483
+ if (Nt(i) && Nt(e))
1484
+ for (const s in e)
1485
+ Nt(e[s]) ? (i[s] || Object.assign(i, { [s]: {} }), x(i[s], e[s])) : Object.assign(i, { [s]: e[s] });
1486
+ return x(i, ...t);
1487
+ }, ui = (i, t) => !i || i === "all" ? !0 : i.some((e) => t.indexOf(e) > -1), pi = (i, t) => {
1488
+ let e = [], s = [], n;
1489
+ const r = () => {
1490
+ process.env.NODE_ENV !== "production" && console.time("state-processor.flush");
1491
+ const a = /* @__PURE__ */ new Map(), c = di(e.map((l, d) => [l, s[d]])), h = (l, d) => {
1492
+ var u;
1493
+ const p = a.get(l) || {}, v = d.context && !p.context, f = d.properties && !p.properties, Et = d.layout && !p.layout;
1494
+ a.set(l, {
1495
+ context: p.context || v,
1496
+ properties: p.properties || f,
1497
+ layout: p.layout || Et
1498
+ }), f && (l.attributes.properties = {}), Et && (l.attributes.layout = {}), v && (l.attributes.context = x({}, (u = l.parent) == null ? void 0 : u.attributes.context));
1499
+ const ge = [], me = [], ve = [];
1500
+ if (l.changesets.forEach((C) => {
1501
+ const [A, Pt] = C;
1502
+ ui(Pt.breakpoints, i.breakpoints) && (f && (typeof A.properties == "function" ? ge.push(
1503
+ A.properties
1504
+ ) : x(l.attributes.properties, A.properties)), Et && (typeof A.layout == "function" ? me.push(A.layout) : x(l.attributes.layout, A.layout)), v && (typeof A.context == "function" ? ve.push(A.context) : x(l.attributes.context, A.context)));
1505
+ }), ge.forEach((C) => {
1506
+ x(l.attributes.properties, C(l.attributes.properties));
1507
+ }), me.forEach((C) => {
1508
+ x(l.attributes.layout, C(l.attributes.layout));
1509
+ }), ve.forEach((C) => {
1510
+ x(l.attributes.context, C(l.attributes.context));
1511
+ }), v || d.recursive) {
1512
+ const C = i.getBranch(l), A = d.recursive ? d : {
1513
+ context: !!v
1514
+ };
1515
+ l.getChildren(C).forEach((Pt) => {
1516
+ h(Pt, A);
1517
+ });
1518
+ }
1519
+ };
1520
+ process.env.NODE_ENV !== "production" && console.timeEnd("state-processor.flush"), c.forEach(([l, d]) => {
1521
+ h(l, d);
1522
+ }), e = [], s = [], t(a);
1523
+ }, o = () => {
1524
+ clearTimeout(n), n = setTimeout(r, 0);
1525
+ };
1526
+ return (a, c) => {
1527
+ const h = e.indexOf(a);
1528
+ if (h > -1) {
1529
+ const l = s[h];
1530
+ return c.context && (l.context = !0), c.properties && (l.properties = !0), c.layout && (l.layout = !0), c.recursive && (l.recursive = !0), o();
1531
+ }
1532
+ return e.push(a), s.push(c), o();
1533
+ };
1534
+ };
1535
+ class as {
1536
+ constructor(t, e = {}) {
1537
+ this.providers = e, this.breakpoints = [], this.actionsState = { handlers: [], watchers: [] }, this.switches = {}, this.changesets = [], this.subscriptions = [], this.customComponentHandler = new hi(), this.events = t.events.createChild(this);
1538
+ const s = new Oe(this.events, "root");
1539
+ s.name = `root-${t.name}`, this.nodes = new ci(s, this.switches, this.events);
1540
+ const n = this.processNode = pi(this, (r) => {
1541
+ const o = Array.from(r.keys());
1542
+ process.env.NODE_ENV !== "production" && console.info(`STATE PROCESSOR: ${o.length} node(s) processed:
1543
+ ${o.map(
1544
+ (a) => `${a.name || "<no name>"} (${a.id})
1545
+ `
1546
+ )}`), o.forEach((a) => {
1547
+ const c = r.get(a);
1548
+ a.parent && a.parent.type === "root" && this.events.dispatch("components:root-children-changed", { node: a }), c != null && c.context && this.events.dispatch("components:context-changed", { node: a }), c != null && c.properties && this.events.dispatch("components:properties-changed", { node: a }), c != null && c.layout && this.events.dispatch("components:layout-changed", { node: a });
1549
+ }), this.events.dispatch("components:component-model-initialized", {}, { bubbles: !0 });
1550
+ });
1551
+ Promise.all(
1552
+ Object.keys(e).map((r) => e[r].load(this))
1553
+ ), this.subscriptions.push(
1554
+ this.events.subscribe(
1555
+ "components:node-appended",
1556
+ (r, o) => {
1557
+ const { node: a } = o;
1558
+ this.changesets.forEach((c) => {
1559
+ const { changeset: h, target: l, removes: d } = c, [u, p] = h;
1560
+ l.match(o.node) && (u.properties && d.push(a.writeProperties(u.properties, p)), u.context && d.push(a.writeContext(u.context, p)), u.layout && d.push(a.writeLayout(u.layout, p)));
1561
+ });
1562
+ }
1563
+ )
1564
+ ), this.subscriptions.push(
1565
+ this.events.subscribe(
1566
+ "components:node-appended",
1567
+ (r, o) => {
1568
+ n(o.node, { properties: !0, context: !0 });
1569
+ }
1570
+ )
1571
+ ), this.subscriptions.push(
1572
+ this.events.subscribe(
1573
+ "components:set-properties",
1574
+ (r, o) => {
1575
+ n(o.node, { properties: !0 });
1576
+ }
1577
+ )
1578
+ ), this.subscriptions.push(
1579
+ this.events.subscribe(
1580
+ "components:set-context",
1581
+ (r, o) => {
1582
+ n(o.node, { properties: !0, context: !0 });
1583
+ }
1584
+ )
1585
+ ), this.subscriptions.push(
1586
+ this.events.subscribe(
1587
+ "components:set-indent",
1588
+ (r, o) => {
1589
+ n(o.node, { layout: !0 });
1590
+ }
1591
+ )
1592
+ ), this.subscriptions.push(
1593
+ this.events.subscribe(
1594
+ "components:set-layout",
1595
+ (r, o) => {
1596
+ n(o.node, { layout: !0 });
1597
+ }
1598
+ )
1599
+ ), this.subscriptions.push(
1600
+ this.events.subscribe("components:node-switched", (r, { node: o, branch: a }) => {
1601
+ n(o, {
1602
+ layout: !0,
1603
+ recursive: !0,
1604
+ properties: !0,
1605
+ context: !0
1606
+ });
1607
+ })
1608
+ ), this.subscriptions.push(
1609
+ this.events.subscribe("components:node-removed", (r, { parentNode: o }) => {
1610
+ n(o, { properties: !0 });
1611
+ })
1612
+ ), this.events.parent && this.events.parent.dispatch("components:platform-created", { platform: this });
1613
+ }
1614
+ static getInstance(t) {
1615
+ return t.getAsync("components");
1616
+ }
1617
+ addBreakpoint(t) {
1618
+ this.breakpoints.indexOf(t) === -1 && (this.breakpoints.push(t), this.processNode(this.nodes.root, {
1619
+ context: !0,
1620
+ properties: !0,
1621
+ layout: !0,
1622
+ recursive: !0
1623
+ }));
1624
+ }
1625
+ removeBreakpoint(t) {
1626
+ const e = this.breakpoints.indexOf(t);
1627
+ e > -1 && (this.breakpoints.splice(e, 1), this.processNode(this.nodes.root, {
1628
+ context: !0,
1629
+ properties: !0,
1630
+ layout: !0,
1631
+ recursive: !0
1632
+ }));
1633
+ }
1634
+ setSwitch(t, e) {
1635
+ this.switches[t.id] = e, this.events.dispatch("components:node-switched", { node: t, branch: e });
1636
+ }
1637
+ getBranch(t) {
1638
+ return this.switches[t.id];
1639
+ }
1640
+ /**
1641
+ * Creates a `ComponentNode` of the specified type.
1642
+ * @param type Type of node.
1643
+ */
1644
+ createNode(t, e = {}) {
1645
+ const s = new Oe(this.events, t);
1646
+ return e.detached && this.nodes.detached.push(s), s;
1647
+ }
1648
+ components() {
1649
+ return new te(this);
1650
+ }
1651
+ actions(t, e) {
1652
+ return new ee(this, t, e);
1653
+ }
1654
+ write(t) {
1655
+ const { provider: e, target: s, attributes: n, options: r = {}, removable: o } = t, a = t.key || st(), c = { changeset: [n, r], target: s, removes: [] };
1656
+ if (e) {
1657
+ const h = this.providers[e];
1658
+ h.write(a, s, n, r), c.removes.push(() => {
1659
+ h.remove(a);
1660
+ });
1661
+ }
1662
+ return this.changesets.push(c), this.nodes.all.forEach((h) => {
1663
+ if (s.match(h)) {
1664
+ let l = () => {
1665
+ };
1666
+ n.properties && (l = h.writeProperties(n.properties, r, o)), n.context && (l = h.writeContext(n.context, r, o)), n.layout && (l = h.writeContext(n.layout, r, o)), c.removes.push(l);
1667
+ }
1668
+ }), () => {
1669
+ if (o) {
1670
+ c.removes.forEach((l) => l());
1671
+ const h = this.changesets.indexOf(c);
1672
+ h > -1 && this.changesets.splice(h, 1);
1673
+ }
1674
+ };
1675
+ }
1676
+ addComponentHandler(t, e) {
1677
+ this.customComponentHandler.add(t, e);
1678
+ }
1679
+ getComponentHandler(t) {
1680
+ return this.customComponentHandler.get(t);
1681
+ }
1682
+ dispose() {
1683
+ this.subscriptions.forEach((t) => t());
1684
+ }
1685
+ }
1686
+ const On = (i, t) => ({
1687
+ id: i.id,
1688
+ type: i.type,
1689
+ name: i.name,
1690
+ branch: t || "default"
1691
+ }), gi = (i, t, e, s = st(), n = {}) => i.getAsync("components").then((r) => {
1692
+ let o;
1693
+ if (typeof t == "string") {
1694
+ const h = new te(r);
1695
+ h.ofType(t), o = h;
1696
+ } else
1697
+ o = t;
1698
+ const a = {}, c = (h) => {
1699
+ const l = a[h.id];
1700
+ return l ? Promise.resolve(l.controller) : as.getInstance(i).then((d) => new rs(d, h, s));
1701
+ };
1702
+ r.events.subscribe(
1703
+ "components:node-enter",
1704
+ (h, { node: l }) => {
1705
+ o.match(l) && c(l).then((d) => {
1706
+ Promise.resolve(e(d)).then((u) => {
1707
+ a[l.id] = {
1708
+ dispose: u,
1709
+ controller: d
1710
+ };
1711
+ });
1712
+ });
1713
+ }
1714
+ ), r.events.subscribe(
1715
+ "components:node-exit",
1716
+ (h, { node: l }) => {
1717
+ const d = a[l.id];
1718
+ d && (d.dispose && d.dispose(), n.reuseController || (d.controller.dispose(), delete a[l.id]));
1719
+ }
1720
+ );
1721
+ }), mi = "#____version____#", cs = class extends is {
1722
+ constructor(t, e = []) {
1723
+ super(t, e, {
1724
+ transformPluginSettings: (s, n, r) => {
1725
+ const o = r.get("$settings"), a = o.plugins && n ? o.plugins[n] || {} : {};
1726
+ return Bt(Bt({}, a), s);
1727
+ }
1728
+ });
1729
+ }
1730
+ createImplementation(t) {
1731
+ const e = super.createImplementation(t);
1732
+ return e.bindings = t.bindings, e;
1733
+ }
1734
+ /**
1735
+ * Performs navigation for widgets matching the specified selector by invoking a
1736
+ * 'navigate' command.
1737
+ * @param selector Widget selector matching the widget(s) to perform navigation on.
1738
+ * @param route Route name.
1739
+ * @param params Route params.
1740
+ */
1741
+ navigate(t, e, s) {
1742
+ this.widgets.query(t).forEach((n) => n.invoke("navigate", { route: e, params: s }));
1743
+ }
1744
+ /**
1745
+ * Creates a runtime based on provided configuration.
1746
+ * @param configuration Runtime configuration.
1747
+ */
1748
+ static create(t = {}) {
1749
+ const e = [As].concat(
1750
+ t.configurationApiExtensions || []
1751
+ );
1752
+ return new cs("humany", e);
1753
+ }
1754
+ /**
1755
+ * Creates a widget runtime based on provided configuration and retains configuration handlers
1756
+ * registered on global context. Use this factory to fully support the default embed script.
1757
+ * Will return any existing widget runtime if available.
1758
+ * @param configuration Runtime configuration.
1759
+ * @param global Object to read configuration handlers from (default: window).
1760
+ */
1761
+ static createFromGlobal(t, e = {}) {
1762
+ if (this.isRuntime(t))
1763
+ return t.patch(e), t;
1764
+ const s = [], n = t && t._c;
1765
+ n && n.forEach((o) => s.push(o));
1766
+ const r = this.create(e);
1767
+ return r.container.register("$runtimecfg", s), r;
1768
+ }
1769
+ /**
1770
+ * Determines whether the specified object is a valid widget runtime.
1771
+ * @param obj Object to compare.
1772
+ */
1773
+ static isRuntime(t) {
1774
+ return !!(t && typeof t == "object" && t.container && typeof t.container.get == "function" && t.container.get("$environment") === t && t.container.owner === t);
1775
+ }
1776
+ };
1777
+ let vi = cs;
1778
+ vi.version = `${mi} (${Xt})`;
1779
+ var fi = Object.defineProperty, Ne = Object.getOwnPropertySymbols, yi = Object.prototype.hasOwnProperty, $i = Object.prototype.propertyIsEnumerable, Te = (i, t, e) => t in i ? fi(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, L = (i, t) => {
1780
+ for (var e in t || (t = {}))
1781
+ yi.call(t, e) && Te(i, e, t[e]);
1782
+ if (Ne)
1783
+ for (var e of Ne(t))
1784
+ $i.call(t, e) && Te(i, e, t[e]);
1785
+ return i;
1786
+ }, b = /* @__PURE__ */ ((i) => (i.Cookie = "cookie", i.Local = "local", i.Session = "session", i))(b || {}), $t = /* @__PURE__ */ ((i) => (i.Tenant = "tenant", i.Implementation = "implementation", i.Widget = "widget", i))($t || {}), $ = /* @__PURE__ */ ((i) => (i.Necessary = "necessary", i.Functional = "functional", i.Analytical = "analytical", i.Marketing = "marketing", i))($ || {});
1787
+ const bt = (i, t, e, s = {}) => Ie(i, e).then((n) => (process.env.NODE_ENV !== "production" && n && _.warn(
1788
+ `createStorageWriter: Attempted to create storage writer using unallowed category.
1789
+ Key: ${t}
1790
+ Category: ${JSON.stringify(e)}
1791
+ Options: ${JSON.stringify(s)}`
1792
+ ), (r) => (ne(i), Ie(i, e).then((o) => {
1793
+ if (o) {
1794
+ process.env.NODE_ENV !== "production" && _.warn(
1795
+ `storageWriter: Attempted to write to storage using unallowed category.
1796
+ Key: ${t}
1797
+ Category: ${JSON.stringify(e)}
1798
+ Value: ${JSON.stringify(r)}
1799
+ Options: ${JSON.stringify(s)}`
1800
+ );
1801
+ return;
1802
+ }
1803
+ const {
1804
+ scope: a = $t.Widget,
1805
+ medium: c = b.Session,
1806
+ duration: h
1807
+ } = s, l = wi();
1808
+ return l[a][t] = ds(r, e, h), c === b.Cookie ? Ci(i, l) : ki(i, c, l);
1809
+ })))), z = (i, t, e = b.Session) => (ne(i), typeof t > "u" ? (process.env.NODE_ENV !== "production" && _.warn("readStorage: Undefined key passed when reading storage. ", t, e), Promise.resolve(void 0)) : e === b.Cookie ? Pi(i).then((s) => Jt(s, t)) : xi(i, e).then((s) => Jt(s, t))), W = (i) => !!Object.entries(i).filter(([t, e]) => typeof e < "u").length, Tt = (i) => Object.entries(i).filter(([t, e]) => typeof e < "u").forEach(([t, { value: e }]) => {
1810
+ typeof e > "u" && delete i[t];
1811
+ }), hs = (i, t) => {
1812
+ const e = {
1813
+ tenant: L(L({}, i.tenant), t.tenant),
1814
+ implementation: L(L({}, i.implementation), t.implementation),
1815
+ widget: L(L({}, i.widget), t.widget)
1816
+ };
1817
+ return Tt(e.tenant), Tt(e.implementation), Tt(e.widget), e;
1818
+ }, bi = (i) => Object.entries(i).reduce((t, e) => {
1819
+ const [s, n] = e;
1820
+ return Object.entries(n).forEach((r) => {
1821
+ const [o, { expiration: a }] = r;
1822
+ a && t.push(a);
1823
+ }), t;
1824
+ }, []).slice().sort((t, e) => new Date(e).valueOf() - new Date(t).valueOf()).shift() || re(), wt = (i) => {
1825
+ const {
1826
+ name: t,
1827
+ implementation: { name: e, tenant: s }
1828
+ } = i.get("$widget");
1829
+ return [
1830
+ `humany_${s}`,
1831
+ `humany_${xe(s + e)}`,
1832
+ `humany_${xe(s + e + t)}`
1833
+ ];
1834
+ }, It = (i) => {
1835
+ const t = new RegExp(`(?:^|;)\\s?${i}=(.*?)(?:;|$)`, "i"), e = document.cookie.match(t);
1836
+ return e && e[1] && JSON.parse(e[1]) || void 0;
1837
+ }, Mt = (i, t, e) => {
1838
+ const s = `${i}=${JSON.stringify(t).trim()}`, n = `expires=${new Date(e).toUTCString()}`, r = "path=/", o = "SameSite=None;Secure";
1839
+ return document.cookie = `${s}; ${n}; ${r}; ${o}`;
1840
+ }, ie = (i) => {
1841
+ const [t, e, s] = wt(i), n = It(t) || {}, r = It(e) || {}, o = It(s) || {};
1842
+ return {
1843
+ tenant: n,
1844
+ implementation: r,
1845
+ widget: o
1846
+ };
1847
+ }, ls = (i, t) => {
1848
+ const e = ie(i), s = hs(e, t), [n, r, o] = wt(i), { tenant: a, implementation: c, widget: h } = s, l = bi(t), d = re({ days: -1 });
1849
+ Mt(n, a, W(a) ? l : d), Mt(
1850
+ r,
1851
+ c,
1852
+ W(c) ? l : d
1853
+ ), Mt(o, h, W(h) ? l : d);
1854
+ }, gt = (i, t) => {
1855
+ const [e, s, n] = wt(i), r = t.getItem(e) || "{}", o = t.getItem(s) || "{}", a = t.getItem(n) || "{}";
1856
+ return {
1857
+ tenant: JSON.parse(r),
1858
+ implementation: JSON.parse(o),
1859
+ widget: JSON.parse(a)
1860
+ };
1861
+ }, Vt = (i, t, e) => {
1862
+ const s = gt(i, t), n = hs(s, e), [r, o, a] = wt(i), { tenant: c, implementation: h, widget: l } = n;
1863
+ W(c) ? t.setItem(r, JSON.stringify(c)) : t.removeItem(r), W(h) ? t.setItem(o, JSON.stringify(h)) : t.removeItem(o), W(l) ? t.setItem(a, JSON.stringify(l)) : t.removeItem(a);
1864
+ }, wi = () => ({ tenant: {}, implementation: {}, widget: {} }), _i = (i) => i ? !!i && /* @__PURE__ */ new Date() > new Date(i) : !1, Jt = (i, t) => {
1865
+ const e = i.widget[t] || i.implementation[t] || i.tenant[t];
1866
+ return e == null ? void 0 : e.value;
1867
+ }, ds = (i, t, e) => e ? {
1868
+ value: i,
1869
+ category: t,
1870
+ expiration: typeof e == "object" ? re(e) : e
1871
+ } : {
1872
+ value: i,
1873
+ category: t
1874
+ }, Ai = (i, t) => {
1875
+ const e = Ys(i);
1876
+ return Object.entries(e).forEach(([s, n]) => {
1877
+ Object.entries(n).forEach(([r, o]) => {
1878
+ const { expiration: a, category: c } = o;
1879
+ (_i(a) || Ei(t, c)) && (n[r] = ds(void 0, c, a));
1880
+ });
1881
+ }), e;
1882
+ }, Ie = (i, t) => z(i, "storagePolicy", b.Cookie).then(
1883
+ (e = [$.Necessary]) => !!t && e.indexOf(t) === -1
1884
+ ), Ei = (i = [$.Necessary], t) => !!t && i.indexOf(t) === -1, ne = (i) => {
1885
+ const t = ie(i), e = gt(i, window.localStorage), s = gt(i, sessionStorage), n = Jt(t, "storagePolicy"), [r, o, a] = [
1886
+ t,
1887
+ e,
1888
+ s
1889
+ ].map((c) => Ai(c, n));
1890
+ ls(i, r), Vt(i, window.localStorage, o), Vt(i, window.sessionStorage, a);
1891
+ }, re = (i = { days: 30 }) => {
1892
+ const { days: t = 0, hours: e = 0, minutes: s = 0, seconds: n = 0 } = i, r = /* @__PURE__ */ new Date();
1893
+ return r.setTime(r.getTime() + e * 60 * 60 * 1e3), r.setTime(r.getTime() + t * 24 * 60 * 60 * 1e3), r.setTime(r.getTime() + s * 60 * 1e3), r.setTime(r.getTime() + n * 1e3), r.toISOString();
1894
+ }, Pi = (i) => et(document)(() => ie(i)), Ci = (i, t) => et(document)(() => ls(i, t)), xi = (i, t) => {
1895
+ const e = t === b.Local ? window.localStorage : window.sessionStorage;
1896
+ return et(e)(() => gt(i, e));
1897
+ }, ki = (i, t, e) => {
1898
+ const s = t === b.Local ? window.localStorage : window.sessionStorage;
1899
+ return et(s)(() => Vt(i, s, e));
1900
+ }, Dt = (i, t, e, ...s) => {
1901
+ const n = `[${i.get("$environment").name || "webprovisions"}] ${e}`;
1902
+ switch (t) {
1903
+ case "info":
1904
+ console.info(n, ...s);
1905
+ break;
1906
+ case "warning":
1907
+ console.warn(n, ...s);
1908
+ break;
1909
+ case "error":
1910
+ console.error(n, ...s);
1911
+ break;
1912
+ }
1913
+ }, Si = (i) => {
1914
+ const t = i.container || i;
1915
+ return {
1916
+ info: (e, ...s) => Dt(t, "info", e, ...s),
1917
+ warn: (e, ...s) => Dt(t, "warning", e, ...s),
1918
+ error: (e, ...s) => Dt(t, "error", e, ...s)
1919
+ };
1920
+ };
1921
+ var mt = /* @__PURE__ */ ((i) => (i.Implementation = "implementation", i.Widget = "widget", i))(mt || {}), M = /* @__PURE__ */ ((i) => (i.Pre = "pre", i.Post = "post", i))(M || {});
1922
+ const Oi = (i, t, e, s) => {
1923
+ try {
1924
+ const n = new t(e, s);
1925
+ return {
1926
+ name: i,
1927
+ invoke: (r, o) => {
1928
+ let a;
1929
+ return n[r] && (a = n[r].call(n, o)), Promise.resolve(a);
1930
+ },
1931
+ getInstance: () => n
1932
+ };
1933
+ } catch (n) {
1934
+ if (n.message && n.message.indexOf("is not a constructor") >= 0)
1935
+ return {
1936
+ name: i,
1937
+ invoke: (r) => {
1938
+ let o;
1939
+ return r === "initialize" && (o = t(e, s)), Promise.resolve(o);
1940
+ },
1941
+ getInstance: () => t
1942
+ };
1943
+ throw n;
1944
+ }
1945
+ };
1946
+ function Me(i, t) {
1947
+ return typeof i > "u" ? t : i;
1948
+ }
1949
+ class Ni {
1950
+ constructor(t = {}) {
1951
+ this.part = t;
1952
+ }
1953
+ createCommand(t, e, s) {
1954
+ let n;
1955
+ typeof e == "function" ? n = {
1956
+ scope: mt.Widget,
1957
+ stage: M.Post,
1958
+ defaultArgs: void 0,
1959
+ handlerResolver: e
1960
+ } : n = {
1961
+ scope: Me(e.scope, mt.Widget),
1962
+ stage: Me(e.stage, M.Post),
1963
+ defaultArgs: e.defaultArgs,
1964
+ handlerResolver: s
1965
+ };
1966
+ let r = this.part;
1967
+ const o = t.split(".");
1968
+ return o.forEach((a, c) => {
1969
+ c === o.length - 1 ? r[a] || (r[a] = () => n) : r = this.part[a] = this.part[a] || {};
1970
+ }), this;
1971
+ }
1972
+ get() {
1973
+ return this.part;
1974
+ }
1975
+ }
1976
+ const us = (i) => {
1977
+ const t = new Ni({});
1978
+ return i(t), t.get();
1979
+ };
1980
+ us((i) => {
1981
+ i.createCommand(
1982
+ "types.register",
1983
+ { scope: mt.Implementation, stage: M.Pre },
1984
+ (t) => (e, s) => {
1985
+ t.container.get("$types")[e] = s;
1986
+ }
1987
+ ).createCommand(
1988
+ "type",
1989
+ { stage: M.Pre },
1990
+ (t) => (e) => {
1991
+ t.container.register("$type", e);
1992
+ }
1993
+ ).createCommand(
1994
+ "settings",
1995
+ { stage: M.Pre, defaultArgs: [null] },
1996
+ (t) => (e) => {
1997
+ t.events.dispatch(
1998
+ "settings:change",
1999
+ e,
2000
+ { bubbles: !0 }
2001
+ ), t.container.register("$settings", e);
2002
+ }
2003
+ ).createCommand(
2004
+ "plugin",
2005
+ { stage: M.Pre },
2006
+ (t) => (e, s, n) => {
2007
+ const { container: r } = t;
2008
+ let o = null, a = e, c = s;
2009
+ typeof e == "string" && (o = e, a = s, c = n);
2010
+ const h = (l) => {
2011
+ const { transformPluginSettings: d } = t.container.get("$environmentOptions"), u = d ? d(
2012
+ c || {},
2013
+ o,
2014
+ t.container,
2015
+ a
2016
+ ) : s;
2017
+ try {
2018
+ const p = Oi(
2019
+ o,
2020
+ a,
2021
+ r,
2022
+ u
2023
+ );
2024
+ r.get("$plugins").push(p), l && p.invoke("initialize", null);
2025
+ } catch (p) {
2026
+ Si(t).warn("Error when initializing plugin", p);
2027
+ }
2028
+ };
2029
+ t.container.get("$instance") ? h(!0) : t.events.subscribeOnce("widget:instance-created", () => h(!1));
2030
+ }
2031
+ ).createCommand(
2032
+ "container.register",
2033
+ (t) => (e, s) => {
2034
+ t.container.register(e, s);
2035
+ }
2036
+ ).createCommand(
2037
+ "container.registerAsync",
2038
+ (t) => (e, s) => {
2039
+ t.container.registerAsync(e, s);
2040
+ }
2041
+ ).createCommand(
2042
+ "container.registerFactory",
2043
+ (t) => (e, s) => {
2044
+ t.container.registerFactory(e, s);
2045
+ }
2046
+ ).createCommand(
2047
+ "container.touch",
2048
+ (t) => (e, s) => {
2049
+ t.container.touch(e, s);
2050
+ }
2051
+ ).createCommand(
2052
+ "csp",
2053
+ {},
2054
+ (t) => (e) => {
2055
+ t.container.register("csp", e);
2056
+ }
2057
+ );
2058
+ });
2059
+ us((i) => {
2060
+ i.createCommand("storage", (t) => (e = {}) => {
2061
+ const { consent: s } = e;
2062
+ if (typeof s < "u") {
2063
+ if (typeof s != "number" && typeof s != "string" && !Array.isArray(s)) {
2064
+ process.env.NODE_ENV !== "production" && _.warn(
2065
+ `storagePolicyConfigurationApi: passed consent is not valid. Consent either has to be a number, a string, an array of strings or an array of numbers.
2066
+ Passed consent: ${JSON.stringify(s)}`
2067
+ );
2068
+ return;
2069
+ }
2070
+ if (Array.isArray(s) && !s.every(
2071
+ (r) => typeof r == "number" || typeof r == "string"
2072
+ )) {
2073
+ process.env.NODE_ENV !== "production" && _.warn(
2074
+ `storagePolicyConfigurationApi: passed consent is not valid. Consent either has to be a number, a string, an array of strings or an array of numbers.
2075
+ Passed consent: ${JSON.stringify(s)}`
2076
+ );
2077
+ return;
2078
+ }
2079
+ const n = [
2080
+ $.Necessary,
2081
+ $.Functional,
2082
+ $.Analytical,
2083
+ $.Marketing
2084
+ ].filter((r, o, a) => typeof s == "number" ? s > o : typeof s == "string" ? a.indexOf(s) + 1 > o : Array.isArray(s) ? s.findIndex((c) => c === o + 1 || c === r) > -1 : !0);
2085
+ return n.indexOf($.Necessary) === -1 && (process.env.NODE_ENV !== "production" && _.warn(
2086
+ `storagePolicyConfigurationApi: passed consent does not include category: '${$.Necessary}'. Consent has to atleast include the '${$.Necessary}' category.
2087
+ Passed consent: ${JSON.stringify(s)}`
2088
+ ), n.unshift($.Necessary)), bt(
2089
+ t.container,
2090
+ "storagePolicy",
2091
+ $.Necessary,
2092
+ {
2093
+ medium: b.Cookie,
2094
+ scope: $t.Tenant,
2095
+ duration: { days: 365 }
2096
+ }
2097
+ ).then((r) => r(n)).then(() => {
2098
+ ne(t.container), t.events.dispatch("storage:policy-changed", n);
2099
+ });
2100
+ }
2101
+ });
2102
+ });
2103
+ class Ti {
2104
+ constructor(t) {
2105
+ this.controller = t, this.cache = /* @__PURE__ */ new Map(), this.subscriptions = [];
2106
+ const { events: e } = t.container.get("$widget"), s = e.subscribe("data-client:fetched", (n, r) => {
2107
+ r.type === "contact-method" && this.cache.set(r.response.id, r.response);
2108
+ });
2109
+ this.subscriptions.push(s);
2110
+ }
2111
+ getConversationLogs() {
2112
+ return this.controller.messages.reduce(
2113
+ (e, s) => {
2114
+ const n = _t(s), { content: r, type: o, sender: a, timestamp: c } = n.content, h = this.parseEntry(r, o, a, c);
2115
+ return h && e.push(h), e;
2116
+ },
2117
+ []
2118
+ );
2119
+ }
2120
+ parseEntry(t, e, s, n) {
2121
+ const r = (h) => {
2122
+ let l = [], d = [], u;
2123
+ if (Array.isArray(h)) {
2124
+ const [v, f] = h;
2125
+ u = f;
2126
+ } else
2127
+ u = h;
2128
+ return this.createMessageContent(u).length && (d = [
2129
+ ...d,
2130
+ this.createMessageContent(u)
2131
+ ]), l = [...l, ...this.createMessageOptions(u)], {
2132
+ messagesAsList: d,
2133
+ options: l
2134
+ };
2135
+ };
2136
+ let o = [], a = [];
2137
+ if (Array.isArray(t.items)) {
2138
+ const { items: h } = t;
2139
+ h.forEach((l) => {
2140
+ const d = r(l);
2141
+ o = [...o, ...d.options], a = [...a, ...d.messagesAsList];
2142
+ });
2143
+ } else {
2144
+ const h = r(t);
2145
+ o = [...o, ...h.options], a = [...a, ...h.messagesAsList];
2146
+ }
2147
+ return {
2148
+ options: o,
2149
+ message: a.length ? a.join(`
2150
+ `) : void 0,
2151
+ source: this.createMessageSource(e),
2152
+ alias: this.createAlias(e, s),
2153
+ timestamp: n
2154
+ };
2155
+ }
2156
+ createMessageSource(t) {
2157
+ return t;
2158
+ }
2159
+ createAlias(t, e) {
2160
+ return t === it.System ? "system" : (e == null ? void 0 : e.name) || "Me";
2161
+ }
2162
+ handleContactMethod(t) {
2163
+ if (!this.cache.has(t))
2164
+ return;
2165
+ const e = this.cache.get(t);
2166
+ let s = "";
2167
+ return s = this.appendText(s, `${e.clientName}:`), s = this.appendText(s, e.title), e.description && (s = this.appendText(s, e.title)), s;
2168
+ }
2169
+ getDetails(t, e = !0) {
2170
+ if (!t)
2171
+ return "";
2172
+ const {
2173
+ header: s,
2174
+ title: n,
2175
+ label: r,
2176
+ description: o,
2177
+ text: a,
2178
+ html: c,
2179
+ body: h,
2180
+ contactMethodId: l
2181
+ } = t;
2182
+ let d = "";
2183
+ if (l) {
2184
+ const u = this.handleContactMethod(l.toString());
2185
+ u && (d = this.appendText(d, u, e));
2186
+ }
2187
+ return s && (d = this.appendText(d, s, e)), n && (d = this.appendText(d, n, e)), o && (d = this.appendText(d, o, e)), a && (d = this.appendText(d, a, e)), r && (d = this.appendText(d, r, e)), c && (d = this.appendText(d, c, e)), h && typeof h == "string" && (d = this.appendText(d, h, e)), d;
2188
+ }
2189
+ createMessageContent(t) {
2190
+ let e = "";
2191
+ return e = this.getDetails(t), e;
2192
+ }
2193
+ createMessageOptions(t) {
2194
+ let e = [], s = [];
2195
+ return Array.isArray(t == null ? void 0 : t.actions) ? s = t.actions : typeof (t == null ? void 0 : t.actions) == "object" && (s = Object.entries(t.actions).map(([n, r]) => ({
2196
+ actionKey: n,
2197
+ label: r
2198
+ }))), s.length && (e = s.map((n) => this.getDetails(n, !1))), e;
2199
+ }
2200
+ appendText(t, e, s = !0) {
2201
+ return s && t.length ? `${t}
2202
+ ${e}` : t.length ? `${t} ${e}` : e;
2203
+ }
2204
+ dispose() {
2205
+ this.subscriptions.forEach((t) => {
2206
+ t();
2207
+ });
2208
+ }
2209
+ }
2210
+ class Ft {
2211
+ constructor(t, e) {
2212
+ this.provider = t, this.print = (s, n) => {
2213
+ const r = {
2214
+ name: this.name,
2215
+ avatar: this.avatar,
2216
+ id: this.id
2217
+ }, o = _t(s, n);
2218
+ return this.provider.createEntry(
2219
+ o.key,
2220
+ o.content,
2221
+ it.Agent,
2222
+ r,
2223
+ o.timestamp
2224
+ );
2225
+ }, this.typing = () => this.provider.setTypingState({
2226
+ name: this.name,
2227
+ avatar: this.avatar
2228
+ }), this.id = e.id || st(), this.name = e.name, this.avatar = e.avatar;
2229
+ }
2230
+ update(t) {
2231
+ var n;
2232
+ const { name: e, avatar: s } = t;
2233
+ s === null ? this.avatar = void 0 : s && (this.avatar = s), e === null ? this.name = void 0 : e && (this.name = e), (n = this.provider.controller) == null || n.events.dispatch("conversation:agent-updated", {
2234
+ agent: this
2235
+ });
2236
+ }
2237
+ }
2238
+ class oe {
2239
+ constructor(t, e, s) {
2240
+ this.name = t, this.controller = s, this.subscriptions = [], this.user = s == null ? void 0 : s.user, this.options = {
2241
+ silent: !1
2242
+ };
2243
+ }
2244
+ static create(t, e, s) {
2245
+ return new oe(t, e, s);
2246
+ }
2247
+ createAgent(t = {}) {
2248
+ var e;
2249
+ if (this.controller) {
2250
+ const s = this.controller.getAgentById(t.id), n = s ? new Ft(this, { ...s, ...t }) : new Ft(this, t);
2251
+ return s || (e = this.controller) == null || e.events.dispatch("conversation:agent-created", {
2252
+ agent: n
2253
+ }), n;
2254
+ }
2255
+ }
2256
+ print(t) {
2257
+ var e;
2258
+ return (e = this.controller) == null ? void 0 : e.print(t);
2259
+ }
2260
+ setTypingState(t, e) {
2261
+ var s;
2262
+ return (s = this.controller) == null ? void 0 : s.setTypingState(t, e);
2263
+ }
2264
+ loading() {
2265
+ return this.controller ? this.controller.loader() : () => () => {
2266
+ };
2267
+ }
2268
+ createEntry(t, e, s, n, r) {
2269
+ var o;
2270
+ return (o = this.controller) == null ? void 0 : o.createEntry(t, e, s, n, r);
2271
+ }
2272
+ dispose() {
2273
+ var t;
2274
+ process.env.NODE_ENV !== "production" && console.log(`conversation-provider: dispose (${this.name})`), (t = this.controller) == null || t.disposeProvider(this), this.controller = null, this.subscriptions.forEach((e) => e());
2275
+ }
2276
+ isRehydrated() {
2277
+ var t;
2278
+ return ((t = this.controller) == null ? void 0 : t.isRehydrated()) || Promise.resolve(!1);
2279
+ }
2280
+ getHistory() {
2281
+ var t;
2282
+ return ((t = this.controller) == null ? void 0 : t.getHistory()) || [];
2283
+ }
2284
+ complete() {
2285
+ var t;
2286
+ (t = this.controller) == null || t.onCompleteProvider();
2287
+ }
2288
+ setOptions(t = { silent: !1 }) {
2289
+ this.options = t;
2290
+ }
2291
+ onUnreadMessage(t) {
2292
+ var e;
2293
+ if (this.controller) {
2294
+ const s = (e = this.controller) == null ? void 0 : e.onUnreadMessage(t);
2295
+ return this.subscriptions.push(s), () => {
2296
+ s();
2297
+ };
2298
+ }
2299
+ }
2300
+ onMounted(t) {
2301
+ var e;
2302
+ if (this.controller) {
2303
+ const s = (e = this.controller) == null ? void 0 : e.events.subscribe(
2304
+ "conversation:component-mount-changed",
2305
+ t
2306
+ );
2307
+ return this.subscriptions.push(s), t({}, this.controller.getComponentMountedState()), () => {
2308
+ s();
2309
+ };
2310
+ }
2311
+ }
2312
+ }
2313
+ const ps = (i) => `conversation-${i}`;
2314
+ class Ii {
2315
+ constructor() {
2316
+ this._locking = Promise.resolve(), this._locks = 0;
2317
+ }
2318
+ isLocked() {
2319
+ return this._locks > 0;
2320
+ }
2321
+ lock() {
2322
+ this._locks += 1;
2323
+ let t, e = new Promise(
2324
+ (n) => t = () => {
2325
+ this._locks -= 1, n();
2326
+ }
2327
+ ), s = this._locking.then(() => t);
2328
+ return this._locking = this._locking.then(() => e), s;
2329
+ }
2330
+ }
2331
+ class Mi {
2332
+ constructor(t, e, s) {
2333
+ this.container = t, this.enabled = s, this.locker = new Ii(), this.initialStoredAgents = [], this.sessionStorageKey = ps(e.id), e.onStarted(async () => {
2334
+ if (e.messages.length > 0)
2335
+ return;
2336
+ const { agents: n } = await this.read(), r = [];
2337
+ n && n.forEach((a) => {
2338
+ const c = e.providerIndex(a.providerName), h = c > -1 ? e.registeredProviders[c] : e.createProvider(a.providerName), l = new Ft(h, {
2339
+ name: a.name,
2340
+ avatar: a.avatar,
2341
+ id: a.id
2342
+ });
2343
+ r.push(l);
2344
+ });
2345
+ const { messages: o } = await this.read();
2346
+ o.forEach((a) => {
2347
+ switch (a.type) {
2348
+ case "agent": {
2349
+ const c = r.find((h) => {
2350
+ var l;
2351
+ return h.id === ((l = a.sender) == null ? void 0 : l.id);
2352
+ });
2353
+ c && c.print(a.content.items || a.content, {
2354
+ key: a.key
2355
+ });
2356
+ return;
2357
+ }
2358
+ case "user": {
2359
+ e.user.print(a.content.items || a.content, {
2360
+ key: a.key
2361
+ });
2362
+ return;
2363
+ }
2364
+ case "system":
2365
+ default:
2366
+ e.print(a.content.items || a.content);
2367
+ }
2368
+ });
2369
+ }), e.onMessageCreated(async (n, r) => {
2370
+ this.write(r.message, "messages");
2371
+ }), e.events.subscribe(
2372
+ "conversation:agent-created",
2373
+ async (n, r) => {
2374
+ const o = {
2375
+ id: r.agent.id,
2376
+ name: r.agent.name,
2377
+ avatar: r.agent.avatar,
2378
+ providerName: r.agent.provider.name
2379
+ };
2380
+ await this.write(o, "agents");
2381
+ }
2382
+ ), e.events.subscribe(
2383
+ "conversation:agent-updated",
2384
+ async (n, r) => {
2385
+ const { agents: o } = await this.read();
2386
+ await this.write(
2387
+ [
2388
+ ...o.map((a) => a.id === r.agent.id ? {
2389
+ ...a,
2390
+ name: r.agent.name,
2391
+ avatar: r.agent.avatar
2392
+ } : a)
2393
+ ],
2394
+ "agents",
2395
+ "update"
2396
+ );
2397
+ }
2398
+ );
2399
+ }
2400
+ setInitialData(t) {
2401
+ this.initialStoredAgents = t.agents;
2402
+ }
2403
+ async isRehydrated() {
2404
+ const { messages: t } = await this.read();
2405
+ return t.length > 0;
2406
+ }
2407
+ getStoredAgent(t) {
2408
+ if (this.enabled)
2409
+ return this.initialStoredAgents.find((e) => e.id === t);
2410
+ }
2411
+ async write(t, e, s = "add") {
2412
+ if (!this.enabled)
2413
+ return;
2414
+ const n = await this.locker.lock();
2415
+ return bt(
2416
+ this.container,
2417
+ this.sessionStorageKey,
2418
+ $.Necessary
2419
+ ).then(async (r) => {
2420
+ if (s === "add") {
2421
+ const o = await this.read();
2422
+ if (e === "messages" && o.messages.findIndex((c) => c.key === t.key) > -1) {
2423
+ n();
2424
+ return;
2425
+ }
2426
+ let a = {
2427
+ ...o
2428
+ };
2429
+ return e === "messages" ? a.messages = [...a.messages, t] : e === "agents" && (a.agents = [...a.agents, t]), r({
2430
+ ...o,
2431
+ ...a
2432
+ }).then(() => {
2433
+ n();
2434
+ });
2435
+ }
2436
+ if (s === "update" && e === "agents") {
2437
+ const o = await this.read();
2438
+ return r({
2439
+ ...o,
2440
+ agents: t
2441
+ }).then(() => {
2442
+ n();
2443
+ });
2444
+ }
2445
+ return r(t).then(() => {
2446
+ n();
2447
+ });
2448
+ });
2449
+ }
2450
+ async read() {
2451
+ return z(this.container, this.sessionStorageKey).then((t) => t || {
2452
+ messages: [],
2453
+ agents: []
2454
+ });
2455
+ }
2456
+ }
2457
+ class Di {
2458
+ constructor(t) {
2459
+ this.controller = t, this.print = (e, s) => {
2460
+ const n = _t(e, s);
2461
+ return this.controller.createEntry(
2462
+ n.key,
2463
+ n.content,
2464
+ it.User,
2465
+ void 0,
2466
+ n.timestamp
2467
+ );
2468
+ };
2469
+ }
2470
+ }
2471
+ const qt = async (i, t, e) => {
2472
+ const s = await i.getAsync(
2473
+ "conversation"
2474
+ ), n = await i.getAsync("components"), r = s.controllers.find((o) => o.conversation.id === t);
2475
+ if (r) {
2476
+ const o = [...r.conversation.providers];
2477
+ o.forEach((c) => {
2478
+ r.conversation.setProviderOptions(c, { silent: !0 });
2479
+ }), r.conversation.queueProviders(o), r.conversation.setProviders([e]);
2480
+ const a = n.components().ofType("conversation");
2481
+ n.write({
2482
+ key: "setConversationProvider",
2483
+ attributes: {
2484
+ properties: { providers: [e] }
2485
+ },
2486
+ target: a,
2487
+ provider: "localStorage"
2488
+ });
2489
+ }
2490
+ };
2491
+ class ji {
2492
+ constructor(t) {
2493
+ this.writer = t;
2494
+ }
2495
+ update(t) {
2496
+ const e = this.getNormalizedSettings(t);
2497
+ this.writer(e);
2498
+ }
2499
+ remove() {
2500
+ this.writer(null);
2501
+ }
2502
+ getNormalizedSettings(t) {
2503
+ return typeof t == "string" ? { body: t } : t.length > -1 && typeof t == "object" ? { items: t } : t;
2504
+ }
2505
+ }
2506
+ var it = /* @__PURE__ */ ((i) => (i.User = "user", i.Agent = "agent", i.System = "system", i))(it || {});
2507
+ const _t = (i, t) => {
2508
+ let e, s = (t == null ? void 0 : t.key) || st(), n = Date.now();
2509
+ return Array.isArray(i) && i.length > -1 ? typeof i[0] == "string" ? e = { items: [i] } : e = { items: i } : typeof i == "string" ? e = { body: i } : (i = i || {}, i.type ? e = {
2510
+ ...i
2511
+ } : (e = {
2512
+ body: i.body,
2513
+ actions: i.actions,
2514
+ title: i.title
2515
+ }, i.key && (s = i.key), i.timestamp && (n = i.timestamp), i.form, i.timestamp === null && (n = null))), { content: e, key: s, timestamp: n };
2516
+ }, De = (i, t) => {
2517
+ if (!t)
2518
+ return;
2519
+ const e = JSON.stringify(t), s = i.findIndex((n) => e === JSON.stringify(n));
2520
+ if (s > -1)
2521
+ return i.splice(s, 1);
2522
+ };
2523
+ class Hi {
2524
+ constructor(t, e, s) {
2525
+ this.container = t, this.id = e, this.formHandlers = {}, this.user = new Di(this), this.providers = [], this.active = !1, this.queuedProviders = [], this.registeredProviders = [], this.loaders = 0, this.componentMounted = !1, this.messages = [], this.typingActors = [], this.print = (r) => {
2526
+ const o = _t(r);
2527
+ return this.createEntry(
2528
+ o.key,
2529
+ o.content,
2530
+ "system",
2531
+ void 0,
2532
+ o.timestamp
2533
+ );
2534
+ };
2535
+ const n = t.get("$widget");
2536
+ this.events = n.events.createChild(this), this.store = new Mi(t, this, s.rehydrate), this.conversationHistory = new Ti(this);
2537
+ }
2538
+ setInitialStorage(t) {
2539
+ this.store.setInitialData(t);
2540
+ }
2541
+ setProviders(t) {
2542
+ const e = [], s = [];
2543
+ this.providers.reduce((n, r) => (t.indexOf(r) === -1 && n.push(r), n), []).forEach((n) => {
2544
+ const r = this.providers.indexOf(n);
2545
+ r > -1 && (e.push(n), this.providers.splice(r, 1));
2546
+ }), t.forEach((n) => {
2547
+ this.providers.indexOf(n) === -1 && (s.push(n), this.providers.push(n));
2548
+ }), (s.length || e.length) && this.events.dispatch("conversation:providers-changed", {
2549
+ added: s,
2550
+ removed: e
2551
+ });
2552
+ }
2553
+ createProvider(t) {
2554
+ const e = this.providerIndex(t);
2555
+ if (e > -1)
2556
+ return this.registeredProviders[e];
2557
+ const s = oe.create(t, this.container, this);
2558
+ return this.registeredProviders.push(s), s;
2559
+ }
2560
+ providerIndex(t) {
2561
+ return this.registeredProviders.findIndex((e) => e.name === t);
2562
+ }
2563
+ getAgentById(t) {
2564
+ if (t)
2565
+ return this.store.getStoredAgent(t);
2566
+ }
2567
+ dispose() {
2568
+ this.conversationHistory.dispose(), this.registeredProviders.forEach((t) => t.dispose()), this.messages = [], this.events.dispatch("conversation:controller-disposed", this), this.active = !1;
2569
+ }
2570
+ onDispose(t) {
2571
+ return this.events.subscribe("conversation:controller-disposed", t);
2572
+ }
2573
+ onStarted(t) {
2574
+ return this.events.subscribe("conversation:started", t);
2575
+ }
2576
+ onMessageCreated(t) {
2577
+ return this.events.subscribe("conversation:message-created", t);
2578
+ }
2579
+ isRehydrated() {
2580
+ return this.store.isRehydrated();
2581
+ }
2582
+ disposeProvider(t) {
2583
+ const e = this.providerIndex(t.name);
2584
+ e > -1 && this.registeredProviders.splice(e, 1), this.events.dispatch("conversation:providers-changed", {
2585
+ removed: [t.name]
2586
+ }), this.registeredProviders.length || this.dispose();
2587
+ }
2588
+ onProvidersChange(t) {
2589
+ return this.events.subscribe("conversation:providers-changed", t);
2590
+ }
2591
+ setComponentMountedState(t) {
2592
+ this.componentMounted !== t && (this.componentMounted = t, t && (this.events.dispatch("conversation:unread-message", !1), this.events.dispatch("conversation:started", !0), this.active = !0), this.events.dispatch("conversation:component-mount-changed", t));
2593
+ }
2594
+ setProviderOptions(t, e) {
2595
+ const s = this.providerIndex(t);
2596
+ s > -1 && this.registeredProviders[s].setOptions(e);
2597
+ }
2598
+ changeProvider(t) {
2599
+ this.registeredProviders.find(
2600
+ (s) => s.name === t
2601
+ ) && qt(this.container, this.id, t);
2602
+ }
2603
+ queueProviders(t) {
2604
+ this.queuedProviders = t;
2605
+ }
2606
+ onCompleteProvider() {
2607
+ const t = this.queuedProviders.pop();
2608
+ t && qt(this.container, this.id, t);
2609
+ }
2610
+ getComponentMountedState() {
2611
+ return this.componentMounted;
2612
+ }
2613
+ onUnreadMessage(t) {
2614
+ return this.events.subscribe("conversation:unread-message", t);
2615
+ }
2616
+ createEntry(t, e, s, n, r) {
2617
+ const o = {
2618
+ key: t,
2619
+ content: e,
2620
+ type: s,
2621
+ sender: n || null,
2622
+ timestamp: r || r === null ? r : Date.now()
2623
+ };
2624
+ this.messages.push(o), o.type === "agent" && De(this.typingActors, n);
2625
+ const a = new ji((c) => {
2626
+ if (c !== null) {
2627
+ const { timestamp: h = void 0, ...l } = c;
2628
+ o.content = l, h && (o.timestamp = h);
2629
+ } else {
2630
+ const h = this.messages.indexOf(o);
2631
+ o.content = null, h > -1 && this.messages.splice(h, 1);
2632
+ }
2633
+ this.events.dispatch("conversation:message-updated", { message: o }), this.update();
2634
+ });
2635
+ return this.events.dispatch("conversation:message-created", { message: o }), this.update(), this.componentMounted || this.events.dispatch("conversation:unread-message", !0), a;
2636
+ }
2637
+ update() {
2638
+ this.events.dispatch("conversation:updated", {
2639
+ messages: this.messages,
2640
+ loading: this.loaders > 0,
2641
+ typingActors: this.typingActors
2642
+ });
2643
+ }
2644
+ getMessageStream() {
2645
+ return {
2646
+ messages: this.messages,
2647
+ loading: this.loaders > 0,
2648
+ typingActors: this.typingActors
2649
+ };
2650
+ }
2651
+ setTypingState(t, e) {
2652
+ return this.typingActors.indexOf(t) === -1 && (this.typingActors.push(t), this.update()), () => {
2653
+ De(this.typingActors, t), this.update();
2654
+ };
2655
+ }
2656
+ /**
2657
+ * Displays a loader in the conversation.
2658
+ */
2659
+ loader() {
2660
+ this.loaders = this.loaders + 1;
2661
+ let t = !1;
2662
+ return this.loaders === 1 && this.update(), () => {
2663
+ t || (t = !0, this.loaders = this.loaders - 1, this.loaders === 0 && this.update());
2664
+ };
2665
+ }
2666
+ submitForm(t, e) {
2667
+ this.formHandlers[t] = { ...this.formHandlers[t], submit: e };
2668
+ }
2669
+ validateForm(t, e) {
2670
+ this.formHandlers[t] = { ...this.formHandlers[t], validate: e };
2671
+ }
2672
+ getHistory() {
2673
+ return this.conversationHistory.getConversationLogs();
2674
+ }
2675
+ }
2676
+ const Li = (i, t) => {
2677
+ const e = i.split("_contact");
2678
+ return t.widgets.get(e[0]);
2679
+ }, ae = (i) => {
2680
+ const t = i.get("$widget"), { name: e, implementation: s } = i.get("$widget"), n = e.indexOf("_contact") > -1 ? Li(e, s) : t, { data: r } = i.get("$settings"), { trigger: o } = n.container.get("$settings"), a = `${e.replace("_contact-method", "").replace("_contact", "")}_contact-method`, c = s.widgets.get(a);
2681
+ return c && !o ? { chatWidget: c, mainWidget: n, data: r } : { mainWidget: n, data: r };
2682
+ }, Ri = (i) => {
2683
+ const { chatWidget: t } = ae(i);
2684
+ return !!t;
2685
+ }, je = (i, t, e) => {
2686
+ const {
2687
+ mainWidget: s,
2688
+ data: n,
2689
+ chatWidget: r
2690
+ } = ae(i);
2691
+ return r ? r.state === "activated" ? r.invoke("open").then(() => {
2692
+ r.container.getAsync("conversation").then((o) => {
2693
+ o.navigateToConversationIfActive(t.id);
2694
+ });
2695
+ }) : r.activate().then(() => {
2696
+ const { trigger: o } = r.container.get("$settings");
2697
+ return o.action = "hide", r.invoke("setSettings", () => ({
2698
+ data: n,
2699
+ trigger: o,
2700
+ activate: !0
2701
+ })).then(() => r.container.getAsync("components").then((a) => {
2702
+ const c = a.components().ofType("contact-method");
2703
+ a.write({
2704
+ key: "setContactMethodId",
2705
+ attributes: {
2706
+ properties: {
2707
+ id: t.id,
2708
+ guideId: t.guideId
2709
+ }
2710
+ },
2711
+ target: c,
2712
+ provider: "localStorage"
2713
+ });
2714
+ const h = a.components().ofType("conversation");
2715
+ a.write({
2716
+ key: "setConversationProvider",
2717
+ attributes: {
2718
+ properties: { providers: [t.clientName] }
2719
+ },
2720
+ target: h,
2721
+ provider: "localStorage"
2722
+ });
2723
+ }));
2724
+ }).then(() => r.invoke("attach", {
2725
+ key: "contact-method",
2726
+ triggerDOMElement: e,
2727
+ withRenderState: "open"
2728
+ })).then(() => (bt(
2729
+ r.container,
2730
+ "activeStickyWidget",
2731
+ $.Necessary,
2732
+ {
2733
+ medium: b.Local,
2734
+ scope: $t.Implementation
2735
+ }
2736
+ ).then((o) => o(r.name)), r.container.getAsync("conversation").then((o) => {
2737
+ o.setConversationEndedBehavior(
2738
+ ce.Deactivate
2739
+ );
2740
+ }).then(() => !1))) : !r;
2741
+ }, Ui = (i, t, e = "conversation") => {
2742
+ const { mainWidget: s, chatWidget: n } = ae(i);
2743
+ return s.container.getAsync("conversation").then((r) => {
2744
+ var o;
2745
+ (o = r.setConversationEndedBehavior(ce.Navigate)) == null || o.then(() => {
2746
+ s.container.getAsync("components").then((a) => {
2747
+ const c = a.components().ofType("conversation");
2748
+ a.write({
2749
+ key: "setConversationProvider",
2750
+ attributes: {
2751
+ properties: { providers: [t.clientName] }
2752
+ },
2753
+ target: c,
2754
+ provider: "localStorage"
2755
+ });
2756
+ });
2757
+ });
2758
+ });
2759
+ }, ht = "conversations";
2760
+ var ce = /* @__PURE__ */ ((i) => (i.Deactivate = "deactivate", i.Navigate = "navigate", i.None = "none", i))(ce || {});
2761
+ class he {
2762
+ constructor(t, e) {
2763
+ this.container = t, this.components = e, this.controllers = [], this.providers = [], this.disposeProviders = {}, this.subscriptions = [], this.storageWriter = null, this.buttonQuery = null, this.sessionInfo = null;
2764
+ const s = t.get("$widget");
2765
+ this.events = s.events.createChild(this);
2766
+ }
2767
+ initialize() {
2768
+ bt(
2769
+ this.container,
2770
+ ht,
2771
+ $.Necessary,
2772
+ {
2773
+ medium: b.Local
2774
+ }
2775
+ ).then((t) => this.storageWriter = t), z(
2776
+ this.container,
2777
+ ht,
2778
+ b.Local
2779
+ ).then((t) => {
2780
+ this.buttonQuery = this.components.components().ofType("conversation-return-button"), t && (this.sessionInfo = t, t.id && t.route && this.writeToComponents({ active: !0, alert: { show: !1 } }));
2781
+ }), this.events.subscribe("conversation:ended", (t, e) => {
2782
+ var s;
2783
+ switch ((s = this.sessionInfo) == null ? void 0 : s.conversationEndedBehavior) {
2784
+ case "deactivate":
2785
+ this.container.get("$widget").deactivate();
2786
+ break;
2787
+ }
2788
+ this.writeToComponents({ active: !1 }), this.sessionInfo = null, this.storageWriter && this.storageWriter();
2789
+ });
2790
+ }
2791
+ addSubscription(t) {
2792
+ this.subscriptions.push(t);
2793
+ }
2794
+ static getInstance(t, e = "conversation") {
2795
+ return et(t)(() => t.getAsync(e).then((s) => {
2796
+ let n = s;
2797
+ return n || as.getInstance(t).then((r) => (n = new he(t, r), n.initialize(), t.registerAsync(e, () => n), n));
2798
+ }));
2799
+ }
2800
+ // navigateToConversationIfActive(id: string): Promise<void> {
2801
+ // return readStorage<SessionInfo>(
2802
+ // this.container,
2803
+ // STORAGE_KEY,
2804
+ // StorageMedium.Local
2805
+ // ).then((storedSession) => {
2806
+ // if (storedSession && storedSession.id === id) {
2807
+ // if (storedSession.route) {
2808
+ // const { name, params } = storedSession.route;
2809
+ // this.router?.navigate(name, params);
2810
+ // }
2811
+ // }
2812
+ // });
2813
+ // }
2814
+ setConversationEndedBehavior(t) {
2815
+ return z(
2816
+ this.container,
2817
+ ht,
2818
+ b.Local
2819
+ ).then((e) => {
2820
+ let s = e;
2821
+ return s ? s.conversationEndedBehavior = t : s = { conversationEndedBehavior: t }, this.sessionInfo = s, this.storageWriter && this.storageWriter(this.sessionInfo) || Promise.resolve();
2822
+ });
2823
+ }
2824
+ async createController(t, e) {
2825
+ const s = ps(t), { agents: n } = await z(this.container, s) || { agents: [] }, r = this.controllers.findIndex((a) => a.conversation.id === t);
2826
+ let o;
2827
+ return r > -1 ? o = this.controllers[r].conversation : o = new Hi(this.container, t, e), o.setInitialStorage({ agents: n || [] }), o;
2828
+ }
2829
+ registerProvider(t, e) {
2830
+ const s = {
2831
+ name: t,
2832
+ handler: e
2833
+ };
2834
+ this.providers.push(s), this.controllers.filter(
2835
+ (n) => n.conversation.providers.indexOf(t) > -1
2836
+ ).forEach((n) => {
2837
+ this.invokeHandler(s, n);
2838
+ });
2839
+ }
2840
+ registerController(t, e) {
2841
+ const s = this.controllers.findIndex(
2842
+ (r) => r.conversation.id === t.id
2843
+ );
2844
+ let n;
2845
+ if (s < 0) {
2846
+ n = { conversation: t, component: e }, this.controllers.push(n);
2847
+ const r = (o) => {
2848
+ o && this.providers.filter((a) => o.indexOf(a.name) > -1).forEach((a) => {
2849
+ this.invokeHandler(a, n);
2850
+ });
2851
+ };
2852
+ return this.subscriptions.push(
2853
+ t.onDispose((o, a) => {
2854
+ const c = this.controllers.findIndex(
2855
+ (h) => h.conversation === a
2856
+ );
2857
+ c > -1 && this.controllers.splice(c, 1), this.components.components().ofType("conversation-return-button").select().writeProperties({ active: !1 }), this.events.dispatch("conversation:ended", {}, { bubbles: !0 });
2858
+ })
2859
+ ), this.subscriptions.push(
2860
+ t.onProvidersChange((o, a) => {
2861
+ const {
2862
+ added: c,
2863
+ removed: h = []
2864
+ } = a;
2865
+ h.forEach((l) => {
2866
+ (this.disposeProviders[l] || []).forEach(
2867
+ (d) => {
2868
+ d();
2869
+ }
2870
+ );
2871
+ }), r(c);
2872
+ })
2873
+ ), this.subscriptions.push(
2874
+ t.onStarted((o, a) => {
2875
+ var h;
2876
+ const c = {
2877
+ id: t.id,
2878
+ // route: this.router?.getRouteData(),
2879
+ conversationEndedBehavior: (h = this.sessionInfo) == null ? void 0 : h.conversationEndedBehavior
2880
+ };
2881
+ this.sessionInfo = c, this.storageWriter && this.storageWriter(c), this.writeToComponents({ active: a });
2882
+ })
2883
+ ), this.subscriptions.push(
2884
+ t.onUnreadMessage((o, a) => {
2885
+ this.events.dispatch("conversation:unread-message", a), this.writeToComponents({ alert: { show: a } });
2886
+ })
2887
+ ), r(t.providers), !0;
2888
+ }
2889
+ return n = this.controllers[s], !1;
2890
+ }
2891
+ writeToComponents(t, e = "conversationReturnButtonState") {
2892
+ this.buttonQuery && this.components.write({
2893
+ key: "conversationReturnButtonState",
2894
+ attributes: { properties: t },
2895
+ target: this.buttonQuery,
2896
+ provider: "localStorage"
2897
+ });
2898
+ }
2899
+ invokeHandler(t, e) {
2900
+ const s = t.handler(
2901
+ e.conversation.createProvider(t.name),
2902
+ e.component
2903
+ );
2904
+ s && (this.disposeProviders[t.name] || (this.disposeProviders[t.name] = []), this.disposeProviders[t.name].push(s));
2905
+ }
2906
+ getComponentRoute() {
2907
+ return z(
2908
+ this.container,
2909
+ ht,
2910
+ b.Local
2911
+ ).then((t) => t == null ? void 0 : t.route);
2912
+ }
2913
+ dispose() {
2914
+ Object.keys(this.disposeProviders).forEach((t) => {
2915
+ this.disposeProviders[t].forEach((e) => {
2916
+ e();
2917
+ });
2918
+ }), this.subscriptions.forEach((t) => {
2919
+ t();
2920
+ }), this.controllers = [], this.providers = [];
2921
+ }
2922
+ static async handleContactMethodClick(t, e, s, n) {
2923
+ if (Ri(e)) {
2924
+ t.preventDefault();
2925
+ let r = document.getElementById("humany-dynamic-anchor");
2926
+ r || (r = document.createElement("a"), r.setAttribute("href", "#"), r.id = "humany-dynamic-anchor", document.body.appendChild(r)), je(e, s, r);
2927
+ }
2928
+ je(e, s);
2929
+ }
2930
+ static async handleContactMethodSubmit(t, e) {
2931
+ var s, n;
2932
+ return (n = (s = e == null ? void 0 : e.body.form.meta) == null ? void 0 : s.conversation) != null && n.id ? qt(
2933
+ t,
2934
+ e.body.form.meta.conversation.id,
2935
+ e.clientName
2936
+ ) : Ui(t, e);
2937
+ }
2938
+ }
2939
+ /**
2940
+ * @license
2941
+ * Copyright 2019 Google LLC
2942
+ * SPDX-License-Identifier: BSD-3-Clause
2943
+ */
2944
+ const dt = window, le = dt.ShadowRoot && (dt.ShadyCSS === void 0 || dt.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, de = Symbol(), He = /* @__PURE__ */ new WeakMap();
2945
+ let gs = class {
2946
+ constructor(t, e, s) {
2947
+ if (this._$cssResult$ = !0, s !== de)
2948
+ throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
2949
+ this.cssText = t, this.t = e;
2950
+ }
2951
+ get styleSheet() {
2952
+ let t = this.o;
2953
+ const e = this.t;
2954
+ if (le && t === void 0) {
2955
+ const s = e !== void 0 && e.length === 1;
2956
+ s && (t = He.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), s && He.set(e, t));
2957
+ }
2958
+ return t;
2959
+ }
2960
+ toString() {
2961
+ return this.cssText;
2962
+ }
2963
+ };
2964
+ const zi = (i) => new gs(typeof i == "string" ? i : i + "", void 0, de), Wi = (i, ...t) => {
2965
+ const e = i.length === 1 ? i[0] : t.reduce((s, n, r) => s + ((o) => {
2966
+ if (o._$cssResult$ === !0)
2967
+ return o.cssText;
2968
+ if (typeof o == "number")
2969
+ return o;
2970
+ throw Error("Value passed to 'css' function must be a 'css' function result: " + o + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.");
2971
+ })(n) + i[r + 1], i[0]);
2972
+ return new gs(e, i, de);
2973
+ }, Bi = (i, t) => {
2974
+ le ? i.adoptedStyleSheets = t.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet) : t.forEach((e) => {
2975
+ const s = document.createElement("style"), n = dt.litNonce;
2976
+ n !== void 0 && s.setAttribute("nonce", n), s.textContent = e.cssText, i.appendChild(s);
2977
+ });
2978
+ }, Le = le ? (i) => i : (i) => i instanceof CSSStyleSheet ? ((t) => {
2979
+ let e = "";
2980
+ for (const s of t.cssRules)
2981
+ e += s.cssText;
2982
+ return zi(e);
2983
+ })(i) : i;
2984
+ /**
2985
+ * @license
2986
+ * Copyright 2017 Google LLC
2987
+ * SPDX-License-Identifier: BSD-3-Clause
2988
+ */
2989
+ var jt;
2990
+ const vt = window, Re = vt.trustedTypes, Vi = Re ? Re.emptyScript : "", Ue = vt.reactiveElementPolyfillSupport, Qt = { toAttribute(i, t) {
2991
+ switch (t) {
2992
+ case Boolean:
2993
+ i = i ? Vi : null;
2994
+ break;
2995
+ case Object:
2996
+ case Array:
2997
+ i = i == null ? i : JSON.stringify(i);
2998
+ }
2999
+ return i;
3000
+ }, fromAttribute(i, t) {
3001
+ let e = i;
3002
+ switch (t) {
3003
+ case Boolean:
3004
+ e = i !== null;
3005
+ break;
3006
+ case Number:
3007
+ e = i === null ? null : Number(i);
3008
+ break;
3009
+ case Object:
3010
+ case Array:
3011
+ try {
3012
+ e = JSON.parse(i);
3013
+ } catch {
3014
+ e = null;
3015
+ }
3016
+ }
3017
+ return e;
3018
+ } }, ms = (i, t) => t !== i && (t == t || i == i), Ht = { attribute: !0, type: String, converter: Qt, reflect: !1, hasChanged: ms }, Kt = "finalized";
3019
+ let R = class extends HTMLElement {
3020
+ constructor() {
3021
+ super(), this._$Ei = /* @__PURE__ */ new Map(), this.isUpdatePending = !1, this.hasUpdated = !1, this._$El = null, this._$Eu();
3022
+ }
3023
+ static addInitializer(t) {
3024
+ var e;
3025
+ this.finalize(), ((e = this.h) !== null && e !== void 0 ? e : this.h = []).push(t);
3026
+ }
3027
+ static get observedAttributes() {
3028
+ this.finalize();
3029
+ const t = [];
3030
+ return this.elementProperties.forEach((e, s) => {
3031
+ const n = this._$Ep(s, e);
3032
+ n !== void 0 && (this._$Ev.set(n, s), t.push(n));
3033
+ }), t;
3034
+ }
3035
+ static createProperty(t, e = Ht) {
3036
+ if (e.state && (e.attribute = !1), this.finalize(), this.elementProperties.set(t, e), !e.noAccessor && !this.prototype.hasOwnProperty(t)) {
3037
+ const s = typeof t == "symbol" ? Symbol() : "__" + t, n = this.getPropertyDescriptor(t, s, e);
3038
+ n !== void 0 && Object.defineProperty(this.prototype, t, n);
3039
+ }
3040
+ }
3041
+ static getPropertyDescriptor(t, e, s) {
3042
+ return { get() {
3043
+ return this[e];
3044
+ }, set(n) {
3045
+ const r = this[t];
3046
+ this[e] = n, this.requestUpdate(t, r, s);
3047
+ }, configurable: !0, enumerable: !0 };
3048
+ }
3049
+ static getPropertyOptions(t) {
3050
+ return this.elementProperties.get(t) || Ht;
3051
+ }
3052
+ static finalize() {
3053
+ if (this.hasOwnProperty(Kt))
3054
+ return !1;
3055
+ this[Kt] = !0;
3056
+ const t = Object.getPrototypeOf(this);
3057
+ if (t.finalize(), t.h !== void 0 && (this.h = [...t.h]), this.elementProperties = new Map(t.elementProperties), this._$Ev = /* @__PURE__ */ new Map(), this.hasOwnProperty("properties")) {
3058
+ const e = this.properties, s = [...Object.getOwnPropertyNames(e), ...Object.getOwnPropertySymbols(e)];
3059
+ for (const n of s)
3060
+ this.createProperty(n, e[n]);
3061
+ }
3062
+ return this.elementStyles = this.finalizeStyles(this.styles), !0;
3063
+ }
3064
+ static finalizeStyles(t) {
3065
+ const e = [];
3066
+ if (Array.isArray(t)) {
3067
+ const s = new Set(t.flat(1 / 0).reverse());
3068
+ for (const n of s)
3069
+ e.unshift(Le(n));
3070
+ } else
3071
+ t !== void 0 && e.push(Le(t));
3072
+ return e;
3073
+ }
3074
+ static _$Ep(t, e) {
3075
+ const s = e.attribute;
3076
+ return s === !1 ? void 0 : typeof s == "string" ? s : typeof t == "string" ? t.toLowerCase() : void 0;
3077
+ }
3078
+ _$Eu() {
3079
+ var t;
3080
+ this._$E_ = new Promise((e) => this.enableUpdating = e), this._$AL = /* @__PURE__ */ new Map(), this._$Eg(), this.requestUpdate(), (t = this.constructor.h) === null || t === void 0 || t.forEach((e) => e(this));
3081
+ }
3082
+ addController(t) {
3083
+ var e, s;
3084
+ ((e = this._$ES) !== null && e !== void 0 ? e : this._$ES = []).push(t), this.renderRoot !== void 0 && this.isConnected && ((s = t.hostConnected) === null || s === void 0 || s.call(t));
3085
+ }
3086
+ removeController(t) {
3087
+ var e;
3088
+ (e = this._$ES) === null || e === void 0 || e.splice(this._$ES.indexOf(t) >>> 0, 1);
3089
+ }
3090
+ _$Eg() {
3091
+ this.constructor.elementProperties.forEach((t, e) => {
3092
+ this.hasOwnProperty(e) && (this._$Ei.set(e, this[e]), delete this[e]);
3093
+ });
3094
+ }
3095
+ createRenderRoot() {
3096
+ var t;
3097
+ const e = (t = this.shadowRoot) !== null && t !== void 0 ? t : this.attachShadow(this.constructor.shadowRootOptions);
3098
+ return Bi(e, this.constructor.elementStyles), e;
3099
+ }
3100
+ connectedCallback() {
3101
+ var t;
3102
+ this.renderRoot === void 0 && (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (t = this._$ES) === null || t === void 0 || t.forEach((e) => {
3103
+ var s;
3104
+ return (s = e.hostConnected) === null || s === void 0 ? void 0 : s.call(e);
3105
+ });
3106
+ }
3107
+ enableUpdating(t) {
3108
+ }
3109
+ disconnectedCallback() {
3110
+ var t;
3111
+ (t = this._$ES) === null || t === void 0 || t.forEach((e) => {
3112
+ var s;
3113
+ return (s = e.hostDisconnected) === null || s === void 0 ? void 0 : s.call(e);
3114
+ });
3115
+ }
3116
+ attributeChangedCallback(t, e, s) {
3117
+ this._$AK(t, s);
3118
+ }
3119
+ _$EO(t, e, s = Ht) {
3120
+ var n;
3121
+ const r = this.constructor._$Ep(t, s);
3122
+ if (r !== void 0 && s.reflect === !0) {
3123
+ const o = (((n = s.converter) === null || n === void 0 ? void 0 : n.toAttribute) !== void 0 ? s.converter : Qt).toAttribute(e, s.type);
3124
+ this._$El = t, o == null ? this.removeAttribute(r) : this.setAttribute(r, o), this._$El = null;
3125
+ }
3126
+ }
3127
+ _$AK(t, e) {
3128
+ var s;
3129
+ const n = this.constructor, r = n._$Ev.get(t);
3130
+ if (r !== void 0 && this._$El !== r) {
3131
+ const o = n.getPropertyOptions(r), a = typeof o.converter == "function" ? { fromAttribute: o.converter } : ((s = o.converter) === null || s === void 0 ? void 0 : s.fromAttribute) !== void 0 ? o.converter : Qt;
3132
+ this._$El = r, this[r] = a.fromAttribute(e, o.type), this._$El = null;
3133
+ }
3134
+ }
3135
+ requestUpdate(t, e, s) {
3136
+ let n = !0;
3137
+ t !== void 0 && (((s = s || this.constructor.getPropertyOptions(t)).hasChanged || ms)(this[t], e) ? (this._$AL.has(t) || this._$AL.set(t, e), s.reflect === !0 && this._$El !== t && (this._$EC === void 0 && (this._$EC = /* @__PURE__ */ new Map()), this._$EC.set(t, s))) : n = !1), !this.isUpdatePending && n && (this._$E_ = this._$Ej());
3138
+ }
3139
+ async _$Ej() {
3140
+ this.isUpdatePending = !0;
3141
+ try {
3142
+ await this._$E_;
3143
+ } catch (e) {
3144
+ Promise.reject(e);
3145
+ }
3146
+ const t = this.scheduleUpdate();
3147
+ return t != null && await t, !this.isUpdatePending;
3148
+ }
3149
+ scheduleUpdate() {
3150
+ return this.performUpdate();
3151
+ }
3152
+ performUpdate() {
3153
+ var t;
3154
+ if (!this.isUpdatePending)
3155
+ return;
3156
+ this.hasUpdated, this._$Ei && (this._$Ei.forEach((n, r) => this[r] = n), this._$Ei = void 0);
3157
+ let e = !1;
3158
+ const s = this._$AL;
3159
+ try {
3160
+ e = this.shouldUpdate(s), e ? (this.willUpdate(s), (t = this._$ES) === null || t === void 0 || t.forEach((n) => {
3161
+ var r;
3162
+ return (r = n.hostUpdate) === null || r === void 0 ? void 0 : r.call(n);
3163
+ }), this.update(s)) : this._$Ek();
3164
+ } catch (n) {
3165
+ throw e = !1, this._$Ek(), n;
3166
+ }
3167
+ e && this._$AE(s);
3168
+ }
3169
+ willUpdate(t) {
3170
+ }
3171
+ _$AE(t) {
3172
+ var e;
3173
+ (e = this._$ES) === null || e === void 0 || e.forEach((s) => {
3174
+ var n;
3175
+ return (n = s.hostUpdated) === null || n === void 0 ? void 0 : n.call(s);
3176
+ }), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t);
3177
+ }
3178
+ _$Ek() {
3179
+ this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
3180
+ }
3181
+ get updateComplete() {
3182
+ return this.getUpdateComplete();
3183
+ }
3184
+ getUpdateComplete() {
3185
+ return this._$E_;
3186
+ }
3187
+ shouldUpdate(t) {
3188
+ return !0;
3189
+ }
3190
+ update(t) {
3191
+ this._$EC !== void 0 && (this._$EC.forEach((e, s) => this._$EO(s, this[s], e)), this._$EC = void 0), this._$Ek();
3192
+ }
3193
+ updated(t) {
3194
+ }
3195
+ firstUpdated(t) {
3196
+ }
3197
+ };
3198
+ R[Kt] = !0, R.elementProperties = /* @__PURE__ */ new Map(), R.elementStyles = [], R.shadowRootOptions = { mode: "open" }, Ue == null || Ue({ ReactiveElement: R }), ((jt = vt.reactiveElementVersions) !== null && jt !== void 0 ? jt : vt.reactiveElementVersions = []).push("1.6.3");
3199
+ /**
3200
+ * @license
3201
+ * Copyright 2017 Google LLC
3202
+ * SPDX-License-Identifier: BSD-3-Clause
3203
+ */
3204
+ var Lt;
3205
+ const ft = window, B = ft.trustedTypes, ze = B ? B.createPolicy("lit-html", { createHTML: (i) => i }) : void 0, Yt = "$lit$", N = `lit$${(Math.random() + "").slice(9)}$`, vs = "?" + N, Ji = `<${vs}>`, j = document, G = () => j.createComment(""), X = (i) => i === null || typeof i != "object" && typeof i != "function", fs = Array.isArray, Fi = (i) => fs(i) || typeof (i == null ? void 0 : i[Symbol.iterator]) == "function", Rt = `[
3206
+ \f\r]`, Q = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, We = /-->/g, Be = />/g, I = RegExp(`>|${Rt}(?:([^\\s"'>=/]+)(${Rt}*=${Rt}*(?:[^
3207
+ \f\r"'\`<>=]|("|')|))|$)`, "g"), Ve = /'/g, Je = /"/g, ys = /^(?:script|style|textarea|title)$/i, qi = (i) => (t, ...e) => ({ _$litType$: i, strings: t, values: e }), lt = qi(1), H = Symbol.for("lit-noChange"), g = Symbol.for("lit-nothing"), Fe = /* @__PURE__ */ new WeakMap(), D = j.createTreeWalker(j, 129, null, !1);
3208
+ function $s(i, t) {
3209
+ if (!Array.isArray(i) || !i.hasOwnProperty("raw"))
3210
+ throw Error("invalid template strings array");
3211
+ return ze !== void 0 ? ze.createHTML(t) : t;
3212
+ }
3213
+ const Qi = (i, t) => {
3214
+ const e = i.length - 1, s = [];
3215
+ let n, r = t === 2 ? "<svg>" : "", o = Q;
3216
+ for (let a = 0; a < e; a++) {
3217
+ const c = i[a];
3218
+ let h, l, d = -1, u = 0;
3219
+ for (; u < c.length && (o.lastIndex = u, l = o.exec(c), l !== null); )
3220
+ u = o.lastIndex, o === Q ? l[1] === "!--" ? o = We : l[1] !== void 0 ? o = Be : l[2] !== void 0 ? (ys.test(l[2]) && (n = RegExp("</" + l[2], "g")), o = I) : l[3] !== void 0 && (o = I) : o === I ? l[0] === ">" ? (o = n ?? Q, d = -1) : l[1] === void 0 ? d = -2 : (d = o.lastIndex - l[2].length, h = l[1], o = l[3] === void 0 ? I : l[3] === '"' ? Je : Ve) : o === Je || o === Ve ? o = I : o === We || o === Be ? o = Q : (o = I, n = void 0);
3221
+ const p = o === I && i[a + 1].startsWith("/>") ? " " : "";
3222
+ r += o === Q ? c + Ji : d >= 0 ? (s.push(h), c.slice(0, d) + Yt + c.slice(d) + N + p) : c + N + (d === -2 ? (s.push(void 0), a) : p);
3223
+ }
3224
+ return [$s(i, r + (i[e] || "<?>") + (t === 2 ? "</svg>" : "")), s];
3225
+ };
3226
+ class tt {
3227
+ constructor({ strings: t, _$litType$: e }, s) {
3228
+ let n;
3229
+ this.parts = [];
3230
+ let r = 0, o = 0;
3231
+ const a = t.length - 1, c = this.parts, [h, l] = Qi(t, e);
3232
+ if (this.el = tt.createElement(h, s), D.currentNode = this.el.content, e === 2) {
3233
+ const d = this.el.content, u = d.firstChild;
3234
+ u.remove(), d.append(...u.childNodes);
3235
+ }
3236
+ for (; (n = D.nextNode()) !== null && c.length < a; ) {
3237
+ if (n.nodeType === 1) {
3238
+ if (n.hasAttributes()) {
3239
+ const d = [];
3240
+ for (const u of n.getAttributeNames())
3241
+ if (u.endsWith(Yt) || u.startsWith(N)) {
3242
+ const p = l[o++];
3243
+ if (d.push(u), p !== void 0) {
3244
+ const v = n.getAttribute(p.toLowerCase() + Yt).split(N), f = /([.?@])?(.*)/.exec(p);
3245
+ c.push({ type: 1, index: r, name: f[2], strings: v, ctor: f[1] === "." ? Yi : f[1] === "?" ? Gi : f[1] === "@" ? Xi : At });
3246
+ } else
3247
+ c.push({ type: 6, index: r });
3248
+ }
3249
+ for (const u of d)
3250
+ n.removeAttribute(u);
3251
+ }
3252
+ if (ys.test(n.tagName)) {
3253
+ const d = n.textContent.split(N), u = d.length - 1;
3254
+ if (u > 0) {
3255
+ n.textContent = B ? B.emptyScript : "";
3256
+ for (let p = 0; p < u; p++)
3257
+ n.append(d[p], G()), D.nextNode(), c.push({ type: 2, index: ++r });
3258
+ n.append(d[u], G());
3259
+ }
3260
+ }
3261
+ } else if (n.nodeType === 8)
3262
+ if (n.data === vs)
3263
+ c.push({ type: 2, index: r });
3264
+ else {
3265
+ let d = -1;
3266
+ for (; (d = n.data.indexOf(N, d + 1)) !== -1; )
3267
+ c.push({ type: 7, index: r }), d += N.length - 1;
3268
+ }
3269
+ r++;
3270
+ }
3271
+ }
3272
+ static createElement(t, e) {
3273
+ const s = j.createElement("template");
3274
+ return s.innerHTML = t, s;
3275
+ }
3276
+ }
3277
+ function V(i, t, e = i, s) {
3278
+ var n, r, o, a;
3279
+ if (t === H)
3280
+ return t;
3281
+ let c = s !== void 0 ? (n = e._$Co) === null || n === void 0 ? void 0 : n[s] : e._$Cl;
3282
+ const h = X(t) ? void 0 : t._$litDirective$;
3283
+ return (c == null ? void 0 : c.constructor) !== h && ((r = c == null ? void 0 : c._$AO) === null || r === void 0 || r.call(c, !1), h === void 0 ? c = void 0 : (c = new h(i), c._$AT(i, e, s)), s !== void 0 ? ((o = (a = e)._$Co) !== null && o !== void 0 ? o : a._$Co = [])[s] = c : e._$Cl = c), c !== void 0 && (t = V(i, c._$AS(i, t.values), c, s)), t;
3284
+ }
3285
+ class Ki {
3286
+ constructor(t, e) {
3287
+ this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = e;
3288
+ }
3289
+ get parentNode() {
3290
+ return this._$AM.parentNode;
3291
+ }
3292
+ get _$AU() {
3293
+ return this._$AM._$AU;
3294
+ }
3295
+ u(t) {
3296
+ var e;
3297
+ const { el: { content: s }, parts: n } = this._$AD, r = ((e = t == null ? void 0 : t.creationScope) !== null && e !== void 0 ? e : j).importNode(s, !0);
3298
+ D.currentNode = r;
3299
+ let o = D.nextNode(), a = 0, c = 0, h = n[0];
3300
+ for (; h !== void 0; ) {
3301
+ if (a === h.index) {
3302
+ let l;
3303
+ h.type === 2 ? l = new nt(o, o.nextSibling, this, t) : h.type === 1 ? l = new h.ctor(o, h.name, h.strings, this, t) : h.type === 6 && (l = new tn(o, this, t)), this._$AV.push(l), h = n[++c];
3304
+ }
3305
+ a !== (h == null ? void 0 : h.index) && (o = D.nextNode(), a++);
3306
+ }
3307
+ return D.currentNode = j, r;
3308
+ }
3309
+ v(t) {
3310
+ let e = 0;
3311
+ for (const s of this._$AV)
3312
+ s !== void 0 && (s.strings !== void 0 ? (s._$AI(t, s, e), e += s.strings.length - 2) : s._$AI(t[e])), e++;
3313
+ }
3314
+ }
3315
+ class nt {
3316
+ constructor(t, e, s, n) {
3317
+ var r;
3318
+ this.type = 2, this._$AH = g, this._$AN = void 0, this._$AA = t, this._$AB = e, this._$AM = s, this.options = n, this._$Cp = (r = n == null ? void 0 : n.isConnected) === null || r === void 0 || r;
3319
+ }
3320
+ get _$AU() {
3321
+ var t, e;
3322
+ return (e = (t = this._$AM) === null || t === void 0 ? void 0 : t._$AU) !== null && e !== void 0 ? e : this._$Cp;
3323
+ }
3324
+ get parentNode() {
3325
+ let t = this._$AA.parentNode;
3326
+ const e = this._$AM;
3327
+ return e !== void 0 && (t == null ? void 0 : t.nodeType) === 11 && (t = e.parentNode), t;
3328
+ }
3329
+ get startNode() {
3330
+ return this._$AA;
3331
+ }
3332
+ get endNode() {
3333
+ return this._$AB;
3334
+ }
3335
+ _$AI(t, e = this) {
3336
+ t = V(this, t, e), X(t) ? t === g || t == null || t === "" ? (this._$AH !== g && this._$AR(), this._$AH = g) : t !== this._$AH && t !== H && this._(t) : t._$litType$ !== void 0 ? this.g(t) : t.nodeType !== void 0 ? this.$(t) : Fi(t) ? this.T(t) : this._(t);
3337
+ }
3338
+ k(t) {
3339
+ return this._$AA.parentNode.insertBefore(t, this._$AB);
3340
+ }
3341
+ $(t) {
3342
+ this._$AH !== t && (this._$AR(), this._$AH = this.k(t));
3343
+ }
3344
+ _(t) {
3345
+ this._$AH !== g && X(this._$AH) ? this._$AA.nextSibling.data = t : this.$(j.createTextNode(t)), this._$AH = t;
3346
+ }
3347
+ g(t) {
3348
+ var e;
3349
+ const { values: s, _$litType$: n } = t, r = typeof n == "number" ? this._$AC(t) : (n.el === void 0 && (n.el = tt.createElement($s(n.h, n.h[0]), this.options)), n);
3350
+ if (((e = this._$AH) === null || e === void 0 ? void 0 : e._$AD) === r)
3351
+ this._$AH.v(s);
3352
+ else {
3353
+ const o = new Ki(r, this), a = o.u(this.options);
3354
+ o.v(s), this.$(a), this._$AH = o;
3355
+ }
3356
+ }
3357
+ _$AC(t) {
3358
+ let e = Fe.get(t.strings);
3359
+ return e === void 0 && Fe.set(t.strings, e = new tt(t)), e;
3360
+ }
3361
+ T(t) {
3362
+ fs(this._$AH) || (this._$AH = [], this._$AR());
3363
+ const e = this._$AH;
3364
+ let s, n = 0;
3365
+ for (const r of t)
3366
+ n === e.length ? e.push(s = new nt(this.k(G()), this.k(G()), this, this.options)) : s = e[n], s._$AI(r), n++;
3367
+ n < e.length && (this._$AR(s && s._$AB.nextSibling, n), e.length = n);
3368
+ }
3369
+ _$AR(t = this._$AA.nextSibling, e) {
3370
+ var s;
3371
+ for ((s = this._$AP) === null || s === void 0 || s.call(this, !1, !0, e); t && t !== this._$AB; ) {
3372
+ const n = t.nextSibling;
3373
+ t.remove(), t = n;
3374
+ }
3375
+ }
3376
+ setConnected(t) {
3377
+ var e;
3378
+ this._$AM === void 0 && (this._$Cp = t, (e = this._$AP) === null || e === void 0 || e.call(this, t));
3379
+ }
3380
+ }
3381
+ class At {
3382
+ constructor(t, e, s, n, r) {
3383
+ this.type = 1, this._$AH = g, this._$AN = void 0, this.element = t, this.name = e, this._$AM = n, this.options = r, s.length > 2 || s[0] !== "" || s[1] !== "" ? (this._$AH = Array(s.length - 1).fill(new String()), this.strings = s) : this._$AH = g;
3384
+ }
3385
+ get tagName() {
3386
+ return this.element.tagName;
3387
+ }
3388
+ get _$AU() {
3389
+ return this._$AM._$AU;
3390
+ }
3391
+ _$AI(t, e = this, s, n) {
3392
+ const r = this.strings;
3393
+ let o = !1;
3394
+ if (r === void 0)
3395
+ t = V(this, t, e, 0), o = !X(t) || t !== this._$AH && t !== H, o && (this._$AH = t);
3396
+ else {
3397
+ const a = t;
3398
+ let c, h;
3399
+ for (t = r[0], c = 0; c < r.length - 1; c++)
3400
+ h = V(this, a[s + c], e, c), h === H && (h = this._$AH[c]), o || (o = !X(h) || h !== this._$AH[c]), h === g ? t = g : t !== g && (t += (h ?? "") + r[c + 1]), this._$AH[c] = h;
3401
+ }
3402
+ o && !n && this.j(t);
3403
+ }
3404
+ j(t) {
3405
+ t === g ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
3406
+ }
3407
+ }
3408
+ class Yi extends At {
3409
+ constructor() {
3410
+ super(...arguments), this.type = 3;
3411
+ }
3412
+ j(t) {
3413
+ this.element[this.name] = t === g ? void 0 : t;
3414
+ }
3415
+ }
3416
+ const Zi = B ? B.emptyScript : "";
3417
+ class Gi extends At {
3418
+ constructor() {
3419
+ super(...arguments), this.type = 4;
3420
+ }
3421
+ j(t) {
3422
+ t && t !== g ? this.element.setAttribute(this.name, Zi) : this.element.removeAttribute(this.name);
3423
+ }
3424
+ }
3425
+ class Xi extends At {
3426
+ constructor(t, e, s, n, r) {
3427
+ super(t, e, s, n, r), this.type = 5;
3428
+ }
3429
+ _$AI(t, e = this) {
3430
+ var s;
3431
+ if ((t = (s = V(this, t, e, 0)) !== null && s !== void 0 ? s : g) === H)
3432
+ return;
3433
+ const n = this._$AH, r = t === g && n !== g || t.capture !== n.capture || t.once !== n.once || t.passive !== n.passive, o = t !== g && (n === g || r);
3434
+ r && this.element.removeEventListener(this.name, this, n), o && this.element.addEventListener(this.name, this, t), this._$AH = t;
3435
+ }
3436
+ handleEvent(t) {
3437
+ var e, s;
3438
+ typeof this._$AH == "function" ? this._$AH.call((s = (e = this.options) === null || e === void 0 ? void 0 : e.host) !== null && s !== void 0 ? s : this.element, t) : this._$AH.handleEvent(t);
3439
+ }
3440
+ }
3441
+ class tn {
3442
+ constructor(t, e, s) {
3443
+ this.element = t, this.type = 6, this._$AN = void 0, this._$AM = e, this.options = s;
3444
+ }
3445
+ get _$AU() {
3446
+ return this._$AM._$AU;
3447
+ }
3448
+ _$AI(t) {
3449
+ V(this, t);
3450
+ }
3451
+ }
3452
+ const qe = ft.litHtmlPolyfillSupport;
3453
+ qe == null || qe(tt, nt), ((Lt = ft.litHtmlVersions) !== null && Lt !== void 0 ? Lt : ft.litHtmlVersions = []).push("2.8.0");
3454
+ const en = (i, t, e) => {
3455
+ var s, n;
3456
+ const r = (s = e == null ? void 0 : e.renderBefore) !== null && s !== void 0 ? s : t;
3457
+ let o = r._$litPart$;
3458
+ if (o === void 0) {
3459
+ const a = (n = e == null ? void 0 : e.renderBefore) !== null && n !== void 0 ? n : null;
3460
+ r._$litPart$ = o = new nt(t.insertBefore(G(), a), a, void 0, e ?? {});
3461
+ }
3462
+ return o._$AI(i), o;
3463
+ };
3464
+ /**
3465
+ * @license
3466
+ * Copyright 2017 Google LLC
3467
+ * SPDX-License-Identifier: BSD-3-Clause
3468
+ */
3469
+ var Ut, zt;
3470
+ class Y extends R {
3471
+ constructor() {
3472
+ super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
3473
+ }
3474
+ createRenderRoot() {
3475
+ var t, e;
3476
+ const s = super.createRenderRoot();
3477
+ return (t = (e = this.renderOptions).renderBefore) !== null && t !== void 0 || (e.renderBefore = s.firstChild), s;
3478
+ }
3479
+ update(t) {
3480
+ const e = this.render();
3481
+ this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t), this._$Do = en(e, this.renderRoot, this.renderOptions);
3482
+ }
3483
+ connectedCallback() {
3484
+ var t;
3485
+ super.connectedCallback(), (t = this._$Do) === null || t === void 0 || t.setConnected(!0);
3486
+ }
3487
+ disconnectedCallback() {
3488
+ var t;
3489
+ super.disconnectedCallback(), (t = this._$Do) === null || t === void 0 || t.setConnected(!1);
3490
+ }
3491
+ render() {
3492
+ return H;
3493
+ }
3494
+ }
3495
+ Y.finalized = !0, Y._$litElement$ = !0, (Ut = globalThis.litElementHydrateSupport) === null || Ut === void 0 || Ut.call(globalThis, { LitElement: Y });
3496
+ const Qe = globalThis.litElementPolyfillSupport;
3497
+ Qe == null || Qe({ LitElement: Y });
3498
+ ((zt = globalThis.litElementVersions) !== null && zt !== void 0 ? zt : globalThis.litElementVersions = []).push("3.3.3");
3499
+ /**
3500
+ * @license
3501
+ * Copyright 2017 Google LLC
3502
+ * SPDX-License-Identifier: BSD-3-Clause
3503
+ */
3504
+ const sn = (i, t) => t.kind === "method" && t.descriptor && !("value" in t.descriptor) ? { ...t, finisher(e) {
3505
+ e.createProperty(t.key, i);
3506
+ } } : { kind: "field", key: Symbol(), placement: "own", descriptor: {}, originalKey: t.key, initializer() {
3507
+ typeof t.initializer == "function" && (this[t.key] = t.initializer.call(this));
3508
+ }, finisher(e) {
3509
+ e.createProperty(t.key, i);
3510
+ } }, nn = (i, t, e) => {
3511
+ t.constructor.createProperty(e, i);
3512
+ };
3513
+ function ue(i) {
3514
+ return (t, e) => e !== void 0 ? nn(i, t, e) : sn(i, t);
3515
+ }
3516
+ /**
3517
+ * @license
3518
+ * Copyright 2017 Google LLC
3519
+ * SPDX-License-Identifier: BSD-3-Clause
3520
+ */
3521
+ function pe(i) {
3522
+ return ue({ ...i, state: !0 });
3523
+ }
3524
+ /**
3525
+ * @license
3526
+ * Copyright 2021 Google LLC
3527
+ * SPDX-License-Identifier: BSD-3-Clause
3528
+ */
3529
+ var Wt;
3530
+ ((Wt = window.HTMLSlotElement) === null || Wt === void 0 ? void 0 : Wt.prototype.assignedElements) != null;
3531
+ /**
3532
+ * @license
3533
+ * Copyright 2017 Google LLC
3534
+ * SPDX-License-Identifier: BSD-3-Clause
3535
+ */
3536
+ const rn = { ATTRIBUTE: 1, CHILD: 2, PROPERTY: 3, BOOLEAN_ATTRIBUTE: 4, EVENT: 5, ELEMENT: 6 }, on = (i) => (...t) => ({ _$litDirective$: i, values: t });
3537
+ class an {
3538
+ constructor(t) {
3539
+ }
3540
+ get _$AU() {
3541
+ return this._$AM._$AU;
3542
+ }
3543
+ _$AT(t, e, s) {
3544
+ this._$Ct = t, this._$AM = e, this._$Ci = s;
3545
+ }
3546
+ _$AS(t, e) {
3547
+ return this.update(t, e);
3548
+ }
3549
+ update(t, e) {
3550
+ return this.render(...e);
3551
+ }
3552
+ }
3553
+ /**
3554
+ * @license
3555
+ * Copyright 2018 Google LLC
3556
+ * SPDX-License-Identifier: BSD-3-Clause
3557
+ */
3558
+ const cn = on(class extends an {
3559
+ constructor(i) {
3560
+ var t;
3561
+ if (super(i), i.type !== rn.ATTRIBUTE || i.name !== "class" || ((t = i.strings) === null || t === void 0 ? void 0 : t.length) > 2)
3562
+ throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.");
3563
+ }
3564
+ render(i) {
3565
+ return " " + Object.keys(i).filter((t) => i[t]).join(" ") + " ";
3566
+ }
3567
+ update(i, [t]) {
3568
+ var e, s;
3569
+ if (this.it === void 0) {
3570
+ this.it = /* @__PURE__ */ new Set(), i.strings !== void 0 && (this.nt = new Set(i.strings.join(" ").split(/\s/).filter((r) => r !== "")));
3571
+ for (const r in t)
3572
+ t[r] && !(!((e = this.nt) === null || e === void 0) && e.has(r)) && this.it.add(r);
3573
+ return this.render(t);
3574
+ }
3575
+ const n = i.element.classList;
3576
+ this.it.forEach((r) => {
3577
+ r in t || (n.remove(r), this.it.delete(r));
3578
+ });
3579
+ for (const r in t) {
3580
+ const o = !!t[r];
3581
+ o === this.it.has(r) || !((s = this.nt) === null || s === void 0) && s.has(r) || (o ? (n.add(r), this.it.add(r)) : (n.remove(r), this.it.delete(r)));
3582
+ }
3583
+ return H;
3584
+ }
3585
+ }), y = (i, t, e) => {
3586
+ i && e.style.setProperty(t, i);
3587
+ }, hn = (i, t) => {
3588
+ var e, s, n, r, o, a, c, h, l, d, u;
3589
+ y((e = i.colors) == null ? void 0 : e.primary, "--primary-color", t), y((s = i.colors) == null ? void 0 : s.secondary, "--secondary-color", t), y((n = i.colors) == null ? void 0 : n.text, "--text-color", t), y((r = i.colors) == null ? void 0 : r.link, "--link-color", t), y((o = i.colors) == null ? void 0 : o.gray, "--gray-color", t), y((a = i.colors) == null ? void 0 : a.grayDark, "--gray-dark-color", t), y((c = i.spacing) == null ? void 0 : c.xs, "--spacing-xs", t), y((h = i.spacing) == null ? void 0 : h.sm, "--spacing-sm", t), y((l = i.spacing) == null ? void 0 : l.md, "--spacing-md", t), y((d = i.spacing) == null ? void 0 : d.lg, "--spacing-lg", t), y((u = i.spacing) == null ? void 0 : u.xl, "--spacing-xl", t), y(i.boxShadow, "--box-shadow", t), y(i.borderRadius, "--border-radius", t), y(i.borderRadiusSm, "--border-radius-sm", t), y(i.fontFamily, "--font-family", t);
3590
+ };
3591
+ var ln = Object.defineProperty, dn = Object.getOwnPropertyDescriptor, rt = (i, t, e, s) => {
3592
+ for (var n = s > 1 ? void 0 : s ? dn(t, e) : t, r = i.length - 1, o; r >= 0; r--)
3593
+ (o = i[r]) && (n = (s ? o(t, e, n) : o(n)) || n);
3594
+ return s && n && ln(t, e, n), n;
3595
+ };
3596
+ class F extends Y {
3597
+ constructor() {
3598
+ super(...arguments), this.active = !1, this.loaded = !1;
3599
+ }
3600
+ async connectedCallback() {
3601
+ super.connectedCallback(), this.icon = await this._renderSymbol(this.symbol), this.loaded = !0, this._applyBranding();
3602
+ }
3603
+ _toggleActive() {
3604
+ this.active = !this.active;
3605
+ }
3606
+ _applyBranding() {
3607
+ var s;
3608
+ const t = ((s = this.container) == null ? void 0 : s.get("$settings")) ?? {}, e = t == null ? void 0 : t.components[t == null ? void 0 : t.entry];
3609
+ e && hn(e.context, this);
3610
+ }
3611
+ async _renderSymbol(t) {
3612
+ const e = async (r) => await import("./index-17239ac6.mjs").then((a) => a[r]);
3613
+ if (!t)
3614
+ return g;
3615
+ const { type: s, content: n } = t;
3616
+ switch (s) {
3617
+ case "Telia": {
3618
+ const r = await e(n);
3619
+ return r ? lt`<telia-icon
3620
+ class="trigger-icon"
3621
+ svg=${r.svg}
3622
+ size="lg"
3623
+ ></telia-icon>` : g;
3624
+ }
3625
+ case "FontAwesome":
3626
+ return lt`<i class="trigger-fa-icon fa fa-${n}"></i>`;
3627
+ case "Uri":
3628
+ return lt`<i
3629
+ class="trigger-custom-icon"
3630
+ style="background: url(${n}) no-repeat center center;background-size: contain;"
3631
+ ></i>`;
3632
+ default:
3633
+ return g;
3634
+ }
3635
+ }
3636
+ render() {
3637
+ return lt`<button
3638
+ class=${cn({
3639
+ trigger: !0,
3640
+ active: this.active,
3641
+ rendered: this.loaded
3642
+ })}
3643
+ @click=${this._toggleActive}
3644
+ >
3645
+ ${this.icon}
3646
+ <span class="trigger-close">
3647
+ <svg
3648
+ width="18"
3649
+ height="9"
3650
+ viewBox="0 0 18 9"
3651
+ fill="none"
3652
+ xmlns="http://www.w3.org/2000/svg"
3653
+ >
3654
+ <path
3655
+ d="M9 9C8.81794 9.00045 8.63759 8.96634 8.46939 8.89965C8.3012 8.83295 8.14851 8.735 8.02015 8.61145L0.194523 1.12367C0.068294 0.99862 -0.00155266 0.831133 2.61958e-05 0.657285C0.00160506 0.483436 0.0744832 0.317136 0.202964 0.194202C0.331445 0.0712675 0.505249 0.00153576 0.686941 2.50649e-05C0.868634 -0.00148563 1.04368 0.0653456 1.17437 0.186125L9 7.6739L16.8256 0.186125C16.9563 0.0653456 17.1314 -0.00148563 17.3131 2.50649e-05C17.4948 0.00153576 17.6686 0.0712675 17.797 0.194202C17.9255 0.317136 17.9984 0.483436 18 0.657285C18.0016 0.831133 17.9317 0.99862 17.8055 1.12367L9.97985 8.61145C9.85149 8.735 9.6988 8.83295 9.53061 8.89965C9.36241 8.96634 9.18206 9.00045 9 9Z"
3656
+ fill="white"
3657
+ />
3658
+ </svg>
3659
+ </span>
3660
+ <span class="trigger-loader">
3661
+ <svg viewBox="25 25 50 50">
3662
+ <circle
3663
+ cx="50"
3664
+ cy="50"
3665
+ r="20"
3666
+ fill="none"
3667
+ stroke="#000"
3668
+ stroke-width="2"
3669
+ stroke-miterlimit="10"
3670
+ />
3671
+ </svg>
3672
+ </span>
3673
+ </button>`;
3674
+ }
3675
+ }
3676
+ F.styles = [
3677
+ Wi`
3678
+ :host {
3679
+ --voca-rem-multiplier: 0.625;
3680
+ display: block;
3681
+ box-sizing: border-box;
3682
+ }
3683
+
3684
+ .trigger {
3685
+ position: fixed;
3686
+ transform: scale(0);
3687
+ box-shadow: rgba(0, 0, 0, 0.16) 0px 5px 40px;
3688
+ bottom: 20px;
3689
+ right: 20px;
3690
+ z-index: 5;
3691
+ display: flex;
3692
+ align-items: center;
3693
+ justify-content: center;
3694
+ border: none;
3695
+ line-height: 55px;
3696
+ height: 55px;
3697
+ width: 55px;
3698
+ border-radius: 55px;
3699
+ cursor: pointer;
3700
+ background-color: var(--trigger-bg, var(--primary-color));
3701
+ font-family: Lato;
3702
+ text-decoration: none;
3703
+ border: 3px dashed transparent;
3704
+ box-sizing: border-box;
3705
+ transition: transform 200ms ease-out;
3706
+ }
3707
+ .trigger:hover {
3708
+ transform: scale(1.1) !important;
3709
+ }
3710
+ .trigger.rendered {
3711
+ transform: scale(1);
3712
+ }
3713
+ .trigger.active .trigger-icon {
3714
+ opacity: 0;
3715
+ transform: rotate(-180deg) scale(0);
3716
+ }
3717
+ .trigger.active .trigger-close {
3718
+ opacity: 1;
3719
+ transform: rotate(0deg) scale(1);
3720
+ }
3721
+
3722
+ .trigger-icon {
3723
+ display: inline-block;
3724
+ line-height: inherit;
3725
+ text-align: center;
3726
+ opacity: 1;
3727
+ transform: rotate(0deg) scale(1);
3728
+ transition: opacity 200ms ease-out, transform 200ms ease-out;
3729
+ color: var(--trigger-text-color, #fff);
3730
+ }
3731
+ .trigger-close {
3732
+ opacity: 0;
3733
+ transition: transform 200ms ease-out;
3734
+ transform: rotate(180deg) scale(0);
3735
+ position: absolute;
3736
+ top: 0;
3737
+ bottom: 0;
3738
+ left: 0;
3739
+ right: 0;
3740
+ display: flex;
3741
+ justify-content: center;
3742
+ align-items: center;
3743
+ fill: var(--trigger-text-color, #fff);
3744
+ }
3745
+ `
3746
+ ];
3747
+ rt([
3748
+ ue({ attribute: !1 })
3749
+ ], F.prototype, "symbol", 2);
3750
+ rt([
3751
+ ue({ attribute: !1 })
3752
+ ], F.prototype, "container", 2);
3753
+ rt([
3754
+ pe()
3755
+ ], F.prototype, "active", 2);
3756
+ rt([
3757
+ pe()
3758
+ ], F.prototype, "loaded", 2);
3759
+ rt([
3760
+ pe()
3761
+ ], F.prototype, "icon", 2);
3762
+ const un = (i, t, e, s, n) => i.getAsync("componentResolver").then((r) => (r.registerComponent(t, e), gi(i, t, s || (() => {
3763
+ }), t, n)));
3764
+ console.log("test1232342532422");
3765
+ const pn = (i, t) => i.reduce((e, s, n) => {
3766
+ var o, a;
3767
+ const r = {
3768
+ ...s,
3769
+ content: [{ ...s.content, key: s.key }]
3770
+ };
3771
+ if (e.length > 0 && s.type !== it.System) {
3772
+ const c = e[e.length - 1];
3773
+ if ((!t && t !== 0 || Math.abs(c.timestamp - s.timestamp) < t) && ((o = c.sender) == null ? void 0 : o.name) === ((a = s.sender) == null ? void 0 : a.name) && c.type === s.type)
3774
+ return c.timestamp = s.timestamp, c.content.push({ ...s.content, key: s.key }), e;
3775
+ }
3776
+ return e.push(r), e;
3777
+ }, []), Mn = async (i) => un(
3778
+ i,
3779
+ "conversation",
3780
+ import("./conversation-18045ffc.mjs"),
3781
+ async (t) => {
3782
+ const e = await he.getInstance(i), { rehydrate: s = !1 } = t.properties(), n = "component", r = await e.createController(n, { rehydrate: s }), o = e.registerController(
3783
+ r,
3784
+ t
3785
+ ), a = 3 * 60 * 1e3, c = (d) => {
3786
+ const { providers: u = [] } = d;
3787
+ if (u) {
3788
+ const p = Array.isArray(u) ? u : [u];
3789
+ return r.setProviders(p), p;
3790
+ }
3791
+ };
3792
+ c(
3793
+ t.properties(c)
3794
+ ), r.setComponentMountedState(!0);
3795
+ const h = (d) => {
3796
+ const { loading: u, typingActors: p, messages: v } = d;
3797
+ t.writeProperties({
3798
+ loading: u,
3799
+ typingActors: p,
3800
+ messages: pn(v, a)
3801
+ });
3802
+ };
3803
+ h(r.getMessageStream()), o && (t.writeProperties({
3804
+ conversationControllerId: r.id
3805
+ }), t.actions.create("user-submit", (d, u) => {
3806
+ if (u) {
3807
+ const { preventDefault: p, validationPromise: v } = u;
3808
+ if (p) {
3809
+ v && v().then((f) => {
3810
+ f && r.user.print(f);
3811
+ });
3812
+ return;
3813
+ }
3814
+ }
3815
+ r.user.print(d.text);
3816
+ }), t.actions.create("user-typing", (d, u) => {
3817
+ }), t.actions.create("form", (d, u) => {
3818
+ }), t.actions.create("action", (d, u) => {
3819
+ }), t.actions.create("overlay-mounted", (d, u) => {
3820
+ }), t.actions.create("show-overlay", (d, u) => {
3821
+ t.writeProperties({
3822
+ overlay: { conversation: !1, secondary: !1 }
3823
+ });
3824
+ }), t.actions.create("hide-overlay", (d, u) => {
3825
+ t.writeProperties({
3826
+ overlay: null
3827
+ });
3828
+ }), t.actions.create(
3829
+ "show-overlay-conversation",
3830
+ (d, u) => {
3831
+ t.writeProperties({
3832
+ overlay: { conversation: !0, secondary: !1 }
3833
+ });
3834
+ }
3835
+ ), t.actions.create(
3836
+ "hide-overlay-conversation",
3837
+ (d, u) => {
3838
+ t.writeProperties({
3839
+ overlay: { conversation: !1, secondary: !1 }
3840
+ });
3841
+ }
3842
+ ));
3843
+ const l = r.events.subscribe(
3844
+ "conversation:updated",
3845
+ (d, u) => {
3846
+ h(u);
3847
+ }
3848
+ );
3849
+ return () => {
3850
+ r.setComponentMountedState(!1), l(), r.active || h({ messages: [], typingActors: [], loading: !1 });
3851
+ };
3852
+ },
3853
+ {
3854
+ reuseController: !0
3855
+ }
3856
+ );
3857
+ var gn = /* @__PURE__ */ ((i) => (i.LinkList = "link-list", i.Separator = "separator", i.ButtonList = "button-list", i.ItemList = "item-list", i.Text = "text", i.HTML = "html", i.VideoRequest = "video-request", i))(gn || {});
3858
+ const Dn = async (i, t, e) => {
3859
+ await e;
3860
+ };
3861
+ console.log("tes3t123");
3862
+ export {
3863
+ g as A,
3864
+ it as C,
3865
+ On as E,
3866
+ te as P,
3867
+ H as T,
3868
+ an as a,
3869
+ rn as b,
3870
+ he as c,
3871
+ ce as d,
3872
+ on as e,
3873
+ Mn as f,
3874
+ Hi as g,
3875
+ st as h,
3876
+ Wi as i,
3877
+ ji as j,
3878
+ gn as k,
3879
+ hn as m,
3880
+ ue as n,
3881
+ cn as o,
3882
+ as as p,
3883
+ Dn as r,
3884
+ Y as s,
3885
+ pe as t,
3886
+ lt as x
3887
+ };