@telia-ace/widget-conversation-flamingo 1.0.2 → 1.0.3

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