@telia-ace/widget-runtime-flamingo 1.0.4 → 1.0.6

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,3777 +0,0 @@
1
- var Hn = Object.defineProperty, Vn = Object.defineProperties;
2
- var Bn = Object.getOwnPropertyDescriptors;
3
- var xe = Object.getOwnPropertySymbols;
4
- var Un = Object.prototype.hasOwnProperty, Wn = Object.prototype.propertyIsEnumerable;
5
- var $e = (n, t, e) => t in n ? Hn(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, dt = (n, t) => {
6
- for (var e in t || (t = {}))
7
- Un.call(t, e) && $e(n, e, t[e]);
8
- if (xe)
9
- for (var e of xe(t))
10
- Wn.call(t, e) && $e(n, e, t[e]);
11
- return n;
12
- }, Pe = (n, t) => Vn(n, Bn(t));
13
- var Zt = (n, t, e) => new Promise((r, s) => {
14
- var i = (c) => {
15
- try {
16
- a(e.next(c));
17
- } catch (h) {
18
- s(h);
19
- }
20
- }, o = (c) => {
21
- try {
22
- a(e.throw(c));
23
- } catch (h) {
24
- s(h);
25
- }
26
- }, a = (c) => c.done ? r(c.value) : Promise.resolve(c.value).then(i, o);
27
- a((e = e.apply(n, t)).next());
28
- });
29
- const Xt = (n, t, e, ...r) => {
30
- const s = `[${n.get("$environment").name || "webprovisions"}] ${e}`;
31
- switch (t) {
32
- case "info":
33
- console.info(s, ...r);
34
- break;
35
- case "warning":
36
- console.warn(s, ...r);
37
- break;
38
- case "error":
39
- console.error(s, ...r);
40
- break;
41
- }
42
- }, zn = (n) => {
43
- const t = n.container || n;
44
- return {
45
- info: (e, ...r) => Xt(t, "info", e, ...r),
46
- warn: (e, ...r) => Xt(t, "warning", e, ...r),
47
- error: (e, ...r) => Xt(t, "error", e, ...r)
48
- };
49
- };
50
- var Tt = /* @__PURE__ */ ((n) => (n.Implementation = "implementation", n.Widget = "widget", n))(Tt || {}), at = /* @__PURE__ */ ((n) => (n.Pre = "pre", n.Post = "post", n))(at || {});
51
- const Fn = (n, t, e, r) => {
52
- try {
53
- const s = new t(e, r);
54
- return {
55
- name: n,
56
- invoke: (i, o) => {
57
- let a;
58
- return s[i] && (a = s[i].call(s, o)), Promise.resolve(a);
59
- },
60
- getInstance: () => s
61
- };
62
- } catch (s) {
63
- if (s.message && s.message.indexOf("is not a constructor") >= 0)
64
- return {
65
- name: n,
66
- invoke: (i) => {
67
- let o;
68
- return i === "initialize" && (o = t(e, r)), Promise.resolve(o);
69
- },
70
- getInstance: () => t
71
- };
72
- throw s;
73
- }
74
- };
75
- function Se(n, t) {
76
- return typeof n == "undefined" ? t : n;
77
- }
78
- let Jn = class {
79
- constructor(t = {}) {
80
- this.part = t;
81
- }
82
- createCommand(t, e, r) {
83
- let s;
84
- typeof e == "function" ? s = {
85
- scope: Tt.Widget,
86
- stage: at.Post,
87
- defaultArgs: void 0,
88
- handlerResolver: e
89
- } : s = {
90
- scope: Se(e.scope, Tt.Widget),
91
- stage: Se(e.stage, at.Post),
92
- defaultArgs: e.defaultArgs,
93
- handlerResolver: r
94
- };
95
- let i = this.part;
96
- const o = t.split(".");
97
- return o.forEach((a, c) => {
98
- c === o.length - 1 ? i[a] || (i[a] = () => s) : i = this.part[a] = this.part[a] || {};
99
- }), this;
100
- }
101
- get() {
102
- return this.part;
103
- }
104
- };
105
- const fe = (n) => {
106
- const t = new Jn({});
107
- return n(t), t.get();
108
- };
109
- fe((n) => {
110
- n.createCommand(
111
- "types.register",
112
- { scope: Tt.Implementation, stage: at.Pre },
113
- (t) => (e, r) => {
114
- t.container.get("$types")[e] = r;
115
- }
116
- ).createCommand(
117
- "type",
118
- { stage: at.Pre },
119
- (t) => (e) => {
120
- t.container.register("$type", e);
121
- }
122
- ).createCommand(
123
- "settings",
124
- { stage: at.Pre, defaultArgs: [null] },
125
- (t) => (e) => {
126
- t.events.dispatch(
127
- "settings:change",
128
- e,
129
- { bubbles: !0 }
130
- ), t.container.register("$settings", e);
131
- }
132
- ).createCommand(
133
- "plugin",
134
- { stage: at.Pre },
135
- (t) => (e, r, s) => {
136
- const { container: i } = t;
137
- let o = null, a = e, c = r;
138
- typeof e == "string" && (o = e, a = r, c = s);
139
- const h = (u) => {
140
- const { transformPluginSettings: l } = t.container.get("$environmentOptions"), d = l ? l(
141
- c || {},
142
- o,
143
- t.container,
144
- a
145
- ) : r;
146
- try {
147
- const f = Fn(
148
- o,
149
- a,
150
- i,
151
- d
152
- );
153
- i.get("$plugins").push(f), u && f.invoke("initialize", null);
154
- } catch (f) {
155
- zn(t).warn("Error when initializing plugin", f);
156
- }
157
- };
158
- t.container.get("$instance") ? h(!0) : t.events.subscribeOnce("widget:instance-created", () => h(!1));
159
- }
160
- ).createCommand(
161
- "container.register",
162
- (t) => (e, r) => {
163
- t.container.register(e, r);
164
- }
165
- ).createCommand(
166
- "container.registerAsync",
167
- (t) => (e, r) => {
168
- t.container.registerAsync(e, r);
169
- }
170
- ).createCommand(
171
- "container.registerFactory",
172
- (t) => (e, r) => {
173
- t.container.registerFactory(e, r);
174
- }
175
- ).createCommand(
176
- "container.touch",
177
- (t) => (e, r) => {
178
- t.container.touch(e, r);
179
- }
180
- ).createCommand(
181
- "csp",
182
- {},
183
- (t) => (e) => {
184
- t.container.register("csp", e);
185
- }
186
- );
187
- });
188
- var nn = /* @__PURE__ */ ((n) => (n.Activating = "activating", n.Loading = "loading", n.Activated = "activated", n.Deactivating = "deactivating", n.Deactivated = "deactivated", n))(nn || {});
189
- let Kn = class {
190
- /**
191
- * Creates a new `Widget` instance.
192
- * @param container The `Container` instance to base the widget upon.
193
- */
194
- constructor(t) {
195
- this.container = t, this.widget = t.get("$widget"), this.settings = t.get("$settings"), this.events = this.widget.events, this.widget.events.subscribe("settings:change", (e, r) => {
196
- this.settings = r;
197
- });
198
- }
199
- };
200
- var Ce = Object.getOwnPropertySymbols, qn = Object.prototype.hasOwnProperty, Yn = Object.prototype.propertyIsEnumerable, Gn = (n, t) => {
201
- var e = {};
202
- for (var r in n)
203
- qn.call(n, r) && t.indexOf(r) < 0 && (e[r] = n[r]);
204
- if (n != null && Ce)
205
- for (var r of Ce(n))
206
- t.indexOf(r) < 0 && Yn.call(n, r) && (e[r] = n[r]);
207
- return e;
208
- };
209
- function Qn(n = {}) {
210
- const t = n, {
211
- phrase: e = "",
212
- category: r,
213
- guideCategory: s,
214
- contactCategory: i,
215
- take: o,
216
- connectionKey: a,
217
- accordion: c,
218
- id: h,
219
- uriName: u,
220
- sorting: l,
221
- tag: d,
222
- tagId: f,
223
- tagTitle: g
224
- } = t, E = Gn(t, [
225
- "phrase",
226
- "category",
227
- "guideCategory",
228
- "contactCategory",
229
- "take",
230
- "connectionKey",
231
- "accordion",
232
- "id",
233
- "uriName",
234
- "sorting",
235
- "tag",
236
- "tagId",
237
- "tagTitle"
238
- ]), p = {};
239
- return Object.keys(E).forEach((C) => {
240
- typeof n[C] == "string" && (p[C] = n[C]);
241
- }), typeof e == "string" && e.length && (p.phrase = e), e === null && (p.phrase = e), typeof s == "string" && s !== "0" && (p.guideCategory = s), typeof s == "number" && s !== 0 && (p.guideCategory = s), typeof s == "object" && s !== null && (typeof s.id == "string" && s.id !== "0" && (p.guideCategory = s.id), typeof s.id == "number" && s.id !== 0 && (p.guideCategory = s.id)), typeof i == "string" && i !== "0" && (p.contactCategory = i), typeof i == "number" && i !== 0 && (p.contactCategory = i), typeof i == "object" && i !== null && (typeof i.id == "string" && i.id !== "0" && (p.contactCategory = i.id), typeof i.id == "number" && i.id !== 0 && (p.contactCategory = i.id)), typeof r == "string" && r !== "0" && (p.category = r), typeof r == "number" && r !== 0 && (p.category = r), typeof r == "object" && r !== null && (typeof r.id == "string" && r.id !== "0" && (p.category = r.id), typeof r.id == "number" && r.id !== 0 && (p.category = r.id)), h && (p.id = h), u && (+p.category || +p.guideCategory || +p.guide || +p.contactCategory || +p.contactMethod) && (p.uriName = u), a && (p.connectionKey = a), o && (p.take = o), l && (p.sorting = l), typeof c == "string" && c.length > 0 && (p.accordion = c), typeof d == "string" && d !== "0" && (p.tag = d), typeof d == "number" && d !== 0 && (p.tag = d), Array.isArray(d) && d.length && (p.tag = d), (typeof f == "string" || typeof f == "number") && (p.tagId = f), typeof g == "string" && (p.tagTitle = g), typeof p.tag == "string" && (p.tag = p.tag.split(",")), p;
242
- }
243
- const Ft = (n, t, ...e) => typeof t == "string" ? n(`[humany] ${t}`, ...e) : n(t, ...e), bt = class {
244
- constructor() {
245
- this.keys = [], this.log = (t, ...e) => this.lookup(t, () => bt.log(...e)), this.warn = (t, ...e) => this.lookup(t, () => bt.warn(...e)), this.error = (t, ...e) => this.lookup(t, () => bt.error(...e)), this.info = (t, ...e) => this.lookup(t, () => bt.info(...e));
246
- }
247
- lookup(t, e) {
248
- this.keys.indexOf(t) === -1 && (this.keys.push(t), e());
249
- }
250
- };
251
- let R = bt;
252
- R.log = (...n) => Ft(console.log, ...n);
253
- R.warn = (...n) => Ft(console.warn, ...n);
254
- R.error = (...n) => Ft(console.error, ...n);
255
- R.info = (...n) => Ft(console.info, ...n);
256
- const rn = (n) => {
257
- let t = {}, e, r;
258
- if (typeof n != "object" || n === null)
259
- return n;
260
- t = Array.isArray(n) ? [] : {};
261
- for (r in n)
262
- e = n[r], t[r] = typeof e == "object" && e !== null ? rn(e) : e;
263
- return t;
264
- }, Zn = rn;
265
- function ke(n) {
266
- let t = 0;
267
- if (n.length === 0)
268
- return t.toString();
269
- for (let e = 0; e < n.length; e++) {
270
- const r = n.charCodeAt(e);
271
- t = (t << 5) - t + r, t = t & t;
272
- }
273
- return t.toString();
274
- }
275
- let Xn = class {
276
- constructor(t, e) {
277
- this.lockWarningTime = t, this.lockErrorTime = e, this.tasks = [], this.current = Promise.resolve(), this.next = this.next.bind(this);
278
- }
279
- add(t, e, r, s) {
280
- this.tasks.push({ task: t, resolve: e, reject: r, done: s }), this.next();
281
- }
282
- next() {
283
- this.current = this.current.then(() => {
284
- const t = this.tasks.shift();
285
- if (t) {
286
- let e;
287
- const r = setTimeout(() => {
288
- process.env.NODE_ENV !== "production" && R.warn(
289
- `A lock has exceeded ${this.lockWarningTime} ms. Waiting additional ${this.lockErrorTime} ms before rejecting the task.`,
290
- t
291
- ), e = setTimeout(() => {
292
- t.reject("lock timeout exceeded");
293
- }, this.lockErrorTime);
294
- }, this.lockWarningTime), s = Promise.resolve(t.task()).then((i) => (clearTimeout(r), clearTimeout(e), i));
295
- return Promise.resolve(s).then(this.next).then(
296
- () => s.then((i) => {
297
- t.done(), t.resolve(i);
298
- })
299
- ).catch((i) => (t.done(), t.reject(i), this.next()));
300
- }
301
- return Promise.resolve();
302
- });
303
- }
304
- };
305
- const St = /* @__PURE__ */ new WeakMap();
306
- function G(n, t = 5e3, e = 1e3) {
307
- return St.has(n) || St.set(n, new Xn(t, e)), (r) => new Promise((s, i) => {
308
- const o = St.get(n);
309
- o.add(r, s, i, () => {
310
- o.tasks.length || St.delete(n);
311
- });
312
- });
313
- }
314
- const tr = (n, t) => {
315
- const e = () => t.querySelectorAll("[data-loading=true]").length > 0, r = (() => {
316
- let s = !1;
317
- return () => {
318
- s || (n.get("$widget").events.dispatch("widget:data-loaded", {
319
- element: t
320
- }), s = !0);
321
- };
322
- })();
323
- if (!e())
324
- return r();
325
- new MutationObserver((s, i) => {
326
- s.find(
327
- (o) => o.type === "attributes" && o.attributeName === "data-loading"
328
- ) && !e() && (i.disconnect(), r());
329
- }).observe(t, {
330
- attributes: !0,
331
- childList: !0,
332
- subtree: !0
333
- });
334
- }, er = (n, t) => {
335
- n.get("$widget").container.getAsync("components").then((e) => {
336
- e.events.subscribeOnce("components:component-model-initialized", () => {
337
- let r = e.nodes.visible.reduce(
338
- (i, o) => (!o.name || !o.type || o.type === "view" || o.type === "root" || o.attributes.layout.size === "none" || t.querySelector(`[data-name="${o.name}"]`) || i.push(o.name), i),
339
- []
340
- ), s = !1;
341
- new MutationObserver((i, o) => {
342
- i.forEach((a) => {
343
- if (a.addedNodes) {
344
- const c = Array.from(
345
- a.addedNodes
346
- ).reduce((h, u) => {
347
- const l = u.getAttribute && u.getAttribute("data-name");
348
- return l && r.indexOf(l) > -1 && h.push(l), h;
349
- }, []);
350
- r = r.filter((h) => c.indexOf(h) === -1), !s && r.length === 0 && (s = !0, tr(n, t), o.disconnect());
351
- }
352
- });
353
- }).observe(t, {
354
- attributes: !1,
355
- characterData: !1,
356
- childList: !0,
357
- subtree: !0,
358
- attributeOldValue: !1,
359
- characterDataOldValue: !1
360
- });
361
- });
362
- });
363
- }, nr = er, rr = (n = {}) => (Object.keys(n).forEach((t) => {
364
- (n[t] === null || typeof n[t] == "undefined") && delete n[t];
365
- }), n), lt = rr, Ae = (n, t) => {
366
- let e = !0;
367
- return Object.keys(n).length !== Object.keys(t).length || Object.keys(n).some((r) => !Object.keys(t).some((s) => r === s)) ? !1 : (Object.keys(n).forEach((r) => {
368
- if (e) {
369
- const s = typeof n[r] == "undefined" ? "" : n[r], i = typeof t[r] == "undefined" ? "" : t[r];
370
- e = s.toString() === i.toString();
371
- }
372
- }), e);
373
- }, nt = () => Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
374
- function Pt() {
375
- return nt() + nt() + "-" + nt() + "-" + nt() + "-" + nt() + "-" + nt() + nt() + nt();
376
- }
377
- var sr = Object.defineProperty, ir = Object.defineProperties, or = Object.getOwnPropertyDescriptors, Ne = Object.getOwnPropertySymbols, ar = Object.prototype.hasOwnProperty, cr = Object.prototype.propertyIsEnumerable, Le = (n, t, e) => t in n ? sr(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, hr = (n, t) => {
378
- for (var e in t || (t = {}))
379
- ar.call(t, e) && Le(n, e, t[e]);
380
- if (Ne)
381
- for (var e of Ne(t))
382
- cr.call(t, e) && Le(n, e, t[e]);
383
- return n;
384
- }, ur = (n, t) => ir(n, or(t));
385
- class lr {
386
- constructor(t) {
387
- const { events: e } = t.get("$widget");
388
- this.events = e.createChild(this);
389
- }
390
- action(t, e, r) {
391
- this.events.dispatch("data:action", { action: e, value: r, target: t }, { bubbles: !0 });
392
- }
393
- subscribe(t, e) {
394
- return this.events.subscribe(
395
- "data:action",
396
- (r, { action: s, value: i, target: o }) => t === o && e(t, s, i)
397
- );
398
- }
399
- }
400
- const sn = (n) => {
401
- const t = [];
402
- return [
403
- (e, r) => {
404
- t.push(n.subscribe(e, r));
405
- },
406
- () => {
407
- t.forEach((e) => {
408
- e();
409
- });
410
- }
411
- ];
412
- };
413
- let yt = class {
414
- constructor(t, e = []) {
415
- this.platform = t, this.rules = e;
416
- }
417
- match(t) {
418
- return this.rules.every((e) => !(e.id && e.id !== t.id || e.type && e.type !== t.type));
419
- }
420
- ofType(t) {
421
- return this.rules.push({ type: t }), this;
422
- }
423
- withId(t) {
424
- return this.rules.push({ id: t }), this;
425
- }
426
- select() {
427
- return new dr(this.platform, this);
428
- }
429
- };
430
- class ge {
431
- constructor(t, e, r) {
432
- this.platform = t, this.node = e, this.actions = new Jt(
433
- t,
434
- new yt(t).withId(e.id),
435
- r
436
- );
437
- const [s, i] = sn(this.platform.events);
438
- this.subscribe = s, this.unsubscribe = i;
439
- }
440
- properties(t) {
441
- return t && this.node.touchProperties((e) => t(e)), this.node.attributes.properties;
442
- }
443
- context(t) {
444
- return t && this.subscribe("components:context-changed", (e, { node: r }) => {
445
- r === this.node && t(this.node.attributes.context);
446
- }), this.node.attributes.context;
447
- }
448
- layout(t) {
449
- return t && this.subscribe("components:layout-changed", (e, { node: r }) => {
450
- r === this.node && t(this.node.attributes.layout);
451
- }), this.node.attributes.layout;
452
- }
453
- writeProperties(t, e) {
454
- this.node.writeProperties(t, e);
455
- }
456
- writeContext(t, e) {
457
- this.node.writeProperties(t, e);
458
- }
459
- writeLayout(t, e) {
460
- this.node.writeLayout(t, e);
461
- }
462
- dispose() {
463
- this.unsubscribe(), this.actions.dispose();
464
- }
465
- }
466
- class dr {
467
- constructor(t, e, r = !0) {
468
- this.platform = t, this.target = e, this.clearOnDispose = r, this.removes = [], this.actions = new Jt(this.platform, this.target);
469
- }
470
- writeProperties(t, e) {
471
- this.removes.push(
472
- this.platform.write({
473
- options: e,
474
- attributes: { properties: t },
475
- target: this.target,
476
- removable: this.clearOnDispose
477
- })
478
- );
479
- }
480
- writeContext(t, e) {
481
- this.removes.push(
482
- this.platform.write({
483
- options: e,
484
- attributes: { context: t },
485
- target: this.target,
486
- removable: this.clearOnDispose
487
- })
488
- );
489
- }
490
- writeLayout(t, e) {
491
- this.removes.push(
492
- this.platform.write({
493
- options: e,
494
- attributes: { layout: t },
495
- target: this.target,
496
- removable: this.clearOnDispose
497
- })
498
- );
499
- }
500
- dispose() {
501
- this.removes.forEach((t) => {
502
- t();
503
- }), this.actions.dispose();
504
- }
505
- }
506
- const pr = (n, t, e) => {
507
- const r = n.concat(), s = (i, o, a) => {
508
- let c = !0;
509
- if (r.length) {
510
- const h = r.shift(), u = (l, d) => (c = !1, s(l, Object.assign({}, o, d), a));
511
- return Promise.resolve(h(i, u, a)).then((l) => ur(hr({}, l), {
512
- cancelled: c
513
- }));
514
- }
515
- return Promise.resolve({ data: i, cancelled: !1, options: o });
516
- };
517
- return s(t, {}, e);
518
- };
519
- let Jt = class {
520
- constructor(t, e, r) {
521
- this.platform = t, this.target = e, this.ns = r, this.subscriptions = [], this.create = this.create.bind(this);
522
- }
523
- create(t, e = () => {
524
- }) {
525
- const r = {
526
- key: t,
527
- fn: e,
528
- target: this.target,
529
- ns: this.ns
530
- };
531
- this.platform.actionsState.handlers.push(r);
532
- const s = () => {
533
- const i = this.platform.actionsState.handlers.indexOf(r);
534
- i > -1 && this.platform.actionsState.handlers.splice(i, 1);
535
- };
536
- return this.subscriptions.push(s), s;
537
- }
538
- dispatch(t, e) {
539
- const r = this.platform.nodes.all.concat(
540
- this.platform.nodes.detached
541
- ), s = {}, i = this.platform.actionsState.handlers.filter(
542
- (o) => o.key === t && (!o.ns || !this.ns || o.ns === this.ns)
543
- );
544
- return Promise.all(
545
- i.map((o) => {
546
- const a = r.filter(
547
- (h) => o.target.match(h) && this.target.match(h)
548
- ), c = this.platform.actionsState.watchers.filter((h) => h.key === t && (!h.ns || !this.ns || h.ns === this.ns) && a.some((u) => h.target.match(u))).map((h) => h.fn);
549
- return Promise.all(
550
- a.map((h) => {
551
- const u = new ge(
552
- this.platform,
553
- h,
554
- this.ns
555
- );
556
- return pr(c, e, u).then((l) => {
557
- const { data: d = {}, options: f, cancelled: g } = l;
558
- return Promise.resolve(
559
- g ? {} : o.fn(d, f, u)
560
- ).then((E) => {
561
- s[h.id] = E;
562
- });
563
- });
564
- })
565
- );
566
- })
567
- ).then(() => s);
568
- }
569
- watch(t, e) {
570
- let r = t, s = this.ns;
571
- const i = t.split(".");
572
- i.length > 1 && (s = i[0], r = i.splice(1).join("."));
573
- const o = {
574
- fn: e,
575
- target: this.target,
576
- key: r,
577
- ns: s
578
- };
579
- this.platform.actionsState.watchers.push(o);
580
- const a = () => {
581
- const c = this.platform.actionsState.watchers.indexOf(o);
582
- c > -1 && this.platform.actionsState.watchers.splice(c, 1);
583
- };
584
- return this.subscriptions.push(a), a;
585
- }
586
- dispose() {
587
- this.subscriptions.forEach((t) => t());
588
- }
589
- };
590
- fe((n) => {
591
- n.createCommand("components", (t) => (e) => {
592
- t.events.subscribeOnce("components:platform-created", (r, { platform: s }) => {
593
- e.handlers && e.handlers.forEach(([i, o]) => {
594
- s.addComponentHandler(i, o);
595
- });
596
- });
597
- });
598
- });
599
- let le = class {
600
- constructor(t, e) {
601
- this.events = t, this.tags = [], this.children = {}, this.changesets = [], this.mountCount = 0, this.id = Pt(), this.type = e, this.attributes = {
602
- context: {},
603
- properties: {},
604
- layout: {},
605
- tags: []
606
- }, this.writeLayout({ size: "full", indent: 0 });
607
- }
608
- mount(t, e) {
609
- let r = t.get("mounted-nodes");
610
- return r || (r = /* @__PURE__ */ new Map(), t.register("mounted-nodes", r)), r.has(this) ? (process.env.NODE_ENV !== "production" && R.error("Trying to mount an already mounted component node.", this), () => {
611
- }) : (this.events.dispatch("components:node-mounted", { node: this }), this.mountCount === 0 && (this.mountCount = this.mountCount + 1, this.events.dispatch("components:node-enter", { node: this })), () => {
612
- r.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 });
613
- });
614
- }
615
- appendChild(t, e = "default") {
616
- if (t.parent) {
617
- if (t.parent === this)
618
- return;
619
- t.parent.removeChild(t);
620
- }
621
- t.parent = this, this.children[e] || (this.children[e] = []), this.children[e].push(t), this.events.dispatch("components:node-appended", { node: t });
622
- }
623
- prependChild(t, e = "default") {
624
- if (t.parent) {
625
- if (t.parent === this)
626
- return;
627
- t.parent.removeChild(t);
628
- }
629
- t.parent = this, this.children[e] || (this.children[e] = []), this.children[e].unshift(t), this.events.dispatch("components:node-appended", { node: t });
630
- }
631
- touchProperties(t, e = {}, r) {
632
- const s = [{ properties: t }, e];
633
- return this.changesets.push(s), this.events.dispatch("components:set-properties", { node: this }), () => {
634
- if (r) {
635
- const i = this.changesets.indexOf(s);
636
- i > -1 && (this.changesets.splice(i, 1), this.events.dispatch("components:set-properties", { node: this }));
637
- }
638
- };
639
- }
640
- writeProperties(t, e = {}, r) {
641
- const s = [{ properties: t }, e];
642
- return this.changesets.push(s), this.events.dispatch("components:set-properties", { node: this }), () => {
643
- if (r) {
644
- const i = this.changesets.indexOf(s);
645
- i > -1 && (this.changesets.splice(i, 1), this.events.dispatch("components:set-properties", { node: this }));
646
- }
647
- };
648
- }
649
- writeLayout(t, e = {}, r) {
650
- const s = [{ layout: t }, e];
651
- return this.changesets.push(s), this.events.dispatch("components:set-layout", { node: this }), () => {
652
- if (!r)
653
- return;
654
- const i = this.changesets.indexOf(s);
655
- i > -1 && (this.changesets.splice(i, 1), this.events.dispatch("components:set-layout", { node: this }));
656
- };
657
- }
658
- writeContext(t, e = {}, r) {
659
- const s = [{ context: t }, e];
660
- return this.changesets.push(s), this.events.dispatch("components:set-context", { node: this }), () => {
661
- if (!r)
662
- return;
663
- const i = this.changesets.indexOf(s);
664
- i > -1 && (this.changesets.splice(i, 1), this.events.dispatch("components:set-context", { node: this }));
665
- };
666
- }
667
- getChildren(t = "default") {
668
- const e = this.children[t] || [];
669
- return e.reduce((r, s, i) => {
670
- const { order: o = i } = s.attributes.layout;
671
- return r[o] ? r.splice(o, 0, s) : r[o] = s, r;
672
- }, Array(e.length));
673
- }
674
- remove() {
675
- this.parent && this.parent.removeChild(this);
676
- }
677
- removeChild(t) {
678
- Object.keys(this.children).forEach((e) => {
679
- const r = this.children[e], s = r.indexOf(t);
680
- s > -1 && (r.splice(s, 1), this.events.dispatch("components:node-removed", { node: t, parentNode: this }));
681
- }), delete t.parent;
682
- }
683
- };
684
- const on = (n, t, e) => {
685
- for (let r = 0, s = n.length; r < s && e(n[r]) !== !0; r++) {
686
- const i = t[n[r].id] || "default", o = n[r].getChildren(i);
687
- on(o, t, e);
688
- }
689
- }, Kt = (n, t, e) => {
690
- if (e(n) !== !0) {
691
- const r = t[n.id] || "default", s = n.children[r];
692
- on(s, t, e);
693
- }
694
- }, Mt = (n, t) => {
695
- const e = [];
696
- return Kt(n, t, (r) => {
697
- e.push(r);
698
- }), e;
699
- }, an = (n, t, e) => {
700
- let r;
701
- return Kt(n, t, (s) => {
702
- if (e(s))
703
- return r = s, !0;
704
- }), r;
705
- };
706
- let fr = class {
707
- constructor(t, e, r) {
708
- this.root = t, this.switches = e, this.all = [], this.visible = [], this.detached = [], r.subscribe("components:node-appended", (s, i) => {
709
- this.all.push(i.node), this.visible = Mt(t, e);
710
- }), r.subscribe("components:node-removed", (s, i) => {
711
- let o = this.all.indexOf(i.node);
712
- o > -1 && this.all.splice(o, 1), o = this.visible.indexOf(i.node), o > -1 && this.visible.splice(o, 1), this.visible = Mt(t, e);
713
- }), r.subscribe("components:node-switched", (s, i) => {
714
- this.visible = Mt(t, e);
715
- });
716
- }
717
- query(t = {}) {
718
- const e = [];
719
- return Kt(this.root, this.switches, (r) => {
720
- Object.keys(t).every((s) => t[s] === r[s]) && e.push(r);
721
- }), e;
722
- }
723
- get(t) {
724
- return an(this.root, this.switches, (e) => e.id === t) || this.detached.find((e) => e.id === t);
725
- }
726
- }, gr = class {
727
- constructor() {
728
- this.handlers = /* @__PURE__ */ new Map();
729
- }
730
- add(t, e) {
731
- this.handlers.set(t, e);
732
- }
733
- get(t) {
734
- return this.handlers.get(t);
735
- }
736
- };
737
- const mr = (n) => {
738
- let t = n, e = 0;
739
- for (; t.parent; )
740
- e = e + 1, t = t.parent;
741
- return e;
742
- }, yr = (n) => n.map(([t, e]) => [mr(t), t, e]).sort(([t], [e]) => t - e).map(([, t, e]) => [t, e]), te = (n) => n instanceof Date ? !1 : n && typeof n == "object" && !Array.isArray(n), Q = (n, ...t) => {
743
- if (!t.length)
744
- return n;
745
- const e = t.shift();
746
- if (te(n) && te(e))
747
- for (const r in e)
748
- te(e[r]) ? (n[r] || Object.assign(n, { [r]: {} }), Q(n[r], e[r])) : Object.assign(n, { [r]: e[r] });
749
- return Q(n, ...t);
750
- }, vr = (n, t) => !n || n === "all" ? !0 : n.some((e) => t.indexOf(e) > -1), br = (n, t) => {
751
- let e = [], r = [], s;
752
- const i = () => {
753
- process.env.NODE_ENV !== "production" && console.time("state-processor.flush");
754
- const a = /* @__PURE__ */ new Map(), c = yr(e.map((u, l) => [u, r[l]])), h = (u, l) => {
755
- var d;
756
- const f = a.get(u) || {}, g = l.context && !f.context, E = l.properties && !f.properties, p = l.layout && !f.layout;
757
- a.set(u, {
758
- context: f.context || g,
759
- properties: f.properties || E,
760
- layout: f.layout || p
761
- }), E && (u.attributes.properties = {}), p && (u.attributes.layout = {}), g && (u.attributes.context = Q({}, (d = u.parent) == null ? void 0 : d.attributes.context));
762
- const C = [], T = [], U = [];
763
- if (u.changesets.forEach((_) => {
764
- const [D, H] = _;
765
- vr(H.breakpoints, n.breakpoints) && (E && (typeof D.properties == "function" ? C.push(
766
- D.properties
767
- ) : Q(u.attributes.properties, D.properties)), p && (typeof D.layout == "function" ? T.push(D.layout) : Q(u.attributes.layout, D.layout)), g && (typeof D.context == "function" ? U.push(D.context) : Q(u.attributes.context, D.context)));
768
- }), C.forEach((_) => {
769
- Q(u.attributes.properties, _(u.attributes.properties));
770
- }), T.forEach((_) => {
771
- Q(u.attributes.layout, _(u.attributes.layout));
772
- }), U.forEach((_) => {
773
- Q(u.attributes.context, _(u.attributes.context));
774
- }), g || l.recursive) {
775
- const _ = n.getBranch(u), D = l.recursive ? l : {
776
- context: !!g
777
- };
778
- u.getChildren(_).forEach((H) => {
779
- h(H, D);
780
- });
781
- }
782
- };
783
- process.env.NODE_ENV !== "production" && console.timeEnd("state-processor.flush"), c.forEach(([u, l]) => {
784
- h(u, l);
785
- }), e = [], r = [], t(a);
786
- }, o = () => {
787
- clearTimeout(s), s = setTimeout(i, 0);
788
- };
789
- return (a, c) => {
790
- const h = e.indexOf(a);
791
- if (h > -1) {
792
- const u = r[h];
793
- return c.context && (u.context = !0), c.properties && (u.properties = !0), c.layout && (u.layout = !0), c.recursive && (u.recursive = !0), o();
794
- }
795
- return e.push(a), r.push(c), o();
796
- };
797
- };
798
- let qt = class {
799
- constructor(t, e = {}) {
800
- this.providers = e, this.breakpoints = [], this.actionsState = { handlers: [], watchers: [] }, this.switches = {}, this.changesets = [], this.subscriptions = [], this.customComponentHandler = new gr(), this.events = t.events.createChild(this);
801
- const r = new le(this.events, "root");
802
- r.name = `root-${t.name}`, this.nodes = new fr(r, this.switches, this.events);
803
- const s = this.processNode = br(this, (i) => {
804
- const o = Array.from(i.keys());
805
- process.env.NODE_ENV !== "production" && console.info(`STATE PROCESSOR: ${o.length} node(s) processed:
806
- ${o.map(
807
- (a) => `${a.name || "<no name>"} (${a.id})
808
- `
809
- )}`), o.forEach((a) => {
810
- const c = i.get(a);
811
- 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 });
812
- }), this.events.dispatch("components:component-model-initialized", {}, { bubbles: !0 });
813
- });
814
- Promise.all(
815
- Object.keys(e).map((i) => e[i].load(this))
816
- ), this.subscriptions.push(
817
- this.events.subscribe(
818
- "components:node-appended",
819
- (i, o) => {
820
- const { node: a } = o;
821
- this.changesets.forEach((c) => {
822
- const { changeset: h, target: u, removes: l } = c, [d, f] = h;
823
- u.match(o.node) && (d.properties && l.push(a.writeProperties(d.properties, f)), d.context && l.push(a.writeContext(d.context, f)), d.layout && l.push(a.writeLayout(d.layout, f)));
824
- });
825
- }
826
- )
827
- ), this.subscriptions.push(
828
- this.events.subscribe(
829
- "components:node-appended",
830
- (i, o) => {
831
- s(o.node, { properties: !0, context: !0 });
832
- }
833
- )
834
- ), this.subscriptions.push(
835
- this.events.subscribe(
836
- "components:set-properties",
837
- (i, o) => {
838
- s(o.node, { properties: !0 });
839
- }
840
- )
841
- ), this.subscriptions.push(
842
- this.events.subscribe(
843
- "components:set-context",
844
- (i, o) => {
845
- s(o.node, { properties: !0, context: !0 });
846
- }
847
- )
848
- ), this.subscriptions.push(
849
- this.events.subscribe(
850
- "components:set-indent",
851
- (i, o) => {
852
- s(o.node, { layout: !0 });
853
- }
854
- )
855
- ), this.subscriptions.push(
856
- this.events.subscribe(
857
- "components:set-layout",
858
- (i, o) => {
859
- s(o.node, { layout: !0 });
860
- }
861
- )
862
- ), this.subscriptions.push(
863
- this.events.subscribe("components:node-switched", (i, { node: o, branch: a }) => {
864
- s(o, {
865
- layout: !0,
866
- recursive: !0,
867
- properties: !0,
868
- context: !0
869
- });
870
- })
871
- ), this.subscriptions.push(
872
- this.events.subscribe("components:node-removed", (i, { parentNode: o }) => {
873
- s(o, { properties: !0 });
874
- })
875
- ), this.events.parent && this.events.parent.dispatch("components:platform-created", { platform: this });
876
- }
877
- static getInstance(t) {
878
- return t.getAsync("components");
879
- }
880
- addBreakpoint(t) {
881
- this.breakpoints.indexOf(t) === -1 && (this.breakpoints.push(t), this.processNode(this.nodes.root, {
882
- context: !0,
883
- properties: !0,
884
- layout: !0,
885
- recursive: !0
886
- }));
887
- }
888
- removeBreakpoint(t) {
889
- const e = this.breakpoints.indexOf(t);
890
- e > -1 && (this.breakpoints.splice(e, 1), this.processNode(this.nodes.root, {
891
- context: !0,
892
- properties: !0,
893
- layout: !0,
894
- recursive: !0
895
- }));
896
- }
897
- setSwitch(t, e) {
898
- this.switches[t.id] = e, this.events.dispatch("components:node-switched", { node: t, branch: e });
899
- }
900
- getBranch(t) {
901
- return this.switches[t.id];
902
- }
903
- /**
904
- * Creates a `ComponentNode` of the specified type.
905
- * @param type Type of node.
906
- */
907
- createNode(t, e = {}) {
908
- const r = new le(this.events, t);
909
- return e.detached && this.nodes.detached.push(r), r;
910
- }
911
- components() {
912
- return new yt(this);
913
- }
914
- actions(t, e) {
915
- return new Jt(this, t, e);
916
- }
917
- write(t) {
918
- const { provider: e, target: r, attributes: s, options: i = {}, removable: o } = t, a = t.key || Pt(), c = { changeset: [s, i], target: r, removes: [] };
919
- if (e) {
920
- const h = this.providers[e];
921
- h.write(a, r, s, i), c.removes.push(() => {
922
- h.remove(a);
923
- });
924
- }
925
- return this.changesets.push(c), this.nodes.all.forEach((h) => {
926
- if (r.match(h)) {
927
- let u = () => {
928
- };
929
- s.properties && (u = h.writeProperties(s.properties, i, o)), s.context && (u = h.writeContext(s.context, i, o)), s.layout && (u = h.writeContext(s.layout, i, o)), c.removes.push(u);
930
- }
931
- }), () => {
932
- if (o) {
933
- c.removes.forEach((u) => u());
934
- const h = this.changesets.indexOf(c);
935
- h > -1 && this.changesets.splice(h, 1);
936
- }
937
- };
938
- }
939
- addComponentHandler(t, e) {
940
- this.customComponentHandler.add(t, e);
941
- }
942
- getComponentHandler(t) {
943
- return this.customComponentHandler.get(t);
944
- }
945
- dispose() {
946
- this.subscriptions.forEach((t) => t());
947
- }
948
- };
949
- const wr = (n) => {
950
- if (Array.isArray(n)) {
951
- const [t, ...e] = n;
952
- return {
953
- definitionId: t,
954
- overrides: e
955
- };
956
- }
957
- return {
958
- definitionId: n,
959
- overrides: []
960
- };
961
- }, Ht = (n, t, e, r, s, i) => {
962
- e.forEach((o) => {
963
- const a = wr(o), c = r[a.definitionId];
964
- if (a.definitionId === "view") {
965
- const h = n.createNode("view");
966
- h.name = "view", Object.keys(s).forEach((u) => {
967
- const l = s[u];
968
- Ht(n, h, [l.entry], r, s, u);
969
- }), t.appendChild(h), a.overrides.forEach((u) => {
970
- u.properties && h.writeProperties(u.properties, {
971
- breakpoints: u.breakpoints
972
- }), u.context && h.writeContext(u.context, { breakpoints: u.breakpoints }), u.layout && h.writeLayout(u.layout, { breakpoints: u.breakpoints });
973
- });
974
- } else if (n.getComponentHandler(c.type)) {
975
- const h = n.getComponentHandler(c.type);
976
- h && h(a, {
977
- platform: n,
978
- node: t,
979
- references: e,
980
- definitions: r,
981
- views: s,
982
- branch: i
983
- });
984
- } else {
985
- const h = r[a.definitionId];
986
- if (process.env.NODE_ENV !== "production" && !h) {
987
- R.error(
988
- `No definition found for component type '${a.definitionId}'.`
989
- );
990
- return;
991
- }
992
- const u = n.createNode(h.type);
993
- u.name = a.definitionId, u.tags = h.tags || [], h.properties && u.writeProperties(h.properties), h.context && u.writeContext(h.context), h.layout && u.writeLayout(h.layout), t.appendChild(u, i), a.overrides.forEach((l) => {
994
- const d = { breakpoints: l.breakpoints };
995
- l.properties && u.writeProperties(l.properties, d), l.context && u.writeContext(l.context, d), l.layout && u.writeLayout(l.layout, d);
996
- }), h.children && Ht(n, u, h.children, r, s);
997
- }
998
- });
999
- }, cn = (n, t) => {
1000
- const { entry: e, components: r, breakpoints: s, views: i } = t, o = [];
1001
- return Object.keys(s).forEach((a) => {
1002
- const c = s[a], h = window.matchMedia(c);
1003
- h.matches && n.breakpoints.push(a);
1004
- const u = (l) => {
1005
- l.matches ? n.addBreakpoint(a) : n.removeBreakpoint(a);
1006
- };
1007
- h.addListener(u), o.push(() => h.removeListener(u));
1008
- }), Ht(n, n.nodes.root, [e], r, i), () => o.forEach((a) => {
1009
- a();
1010
- });
1011
- }, Or = (n, t) => ({
1012
- id: n.id,
1013
- type: n.type,
1014
- name: n.name,
1015
- branch: t || "default"
1016
- }), hn = (n, t, e, r = Pt(), s = {}) => n.getAsync("components").then((i) => {
1017
- let o;
1018
- if (typeof t == "string") {
1019
- const h = new yt(i);
1020
- h.ofType(t), o = h;
1021
- } else
1022
- o = t;
1023
- const a = {}, c = (h) => {
1024
- const u = a[h.id];
1025
- return u ? Promise.resolve(u.controller) : qt.getInstance(n).then((l) => new ge(l, h, r));
1026
- };
1027
- i.events.subscribe(
1028
- "components:node-enter",
1029
- (h, { node: u }) => {
1030
- o.match(u) && c(u).then((l) => {
1031
- Promise.resolve(e(l)).then((d) => {
1032
- a[u.id] = {
1033
- dispose: d,
1034
- controller: l
1035
- };
1036
- });
1037
- });
1038
- }
1039
- ), i.events.subscribe(
1040
- "components:node-exit",
1041
- (h, { node: u }) => {
1042
- const l = a[u.id];
1043
- l && (l.dispose && l.dispose(), s.reuseController || (l.controller.dispose(), delete a[u.id]));
1044
- }
1045
- );
1046
- });
1047
- class Er {
1048
- constructor(t) {
1049
- this.aliases = /* @__PURE__ */ new Map(), this.components = /* @__PURE__ */ new Map(), this.logger = new R();
1050
- const { events: e } = t.get("$widget");
1051
- this.events = e;
1052
- }
1053
- getComponent(t) {
1054
- const e = this.aliases.get(t), r = this.components.get(e || t) || null;
1055
- return process.env.NODE_ENV !== "production" && (r || this.logger.warn(
1056
- e || t,
1057
- `Unable to resolve component: "${e || t}". You most likely forgot to register the required plugin for: ${e || t}.`
1058
- )), r;
1059
- }
1060
- registerComponent(t, e) {
1061
- return this.components.set(t, e), this.events.dispatch("component-resolver:resolve", t), () => {
1062
- this.components.delete(t);
1063
- };
1064
- }
1065
- registerResolver(t, e) {
1066
- return this.events.subscribe("component-resolver:resolve", (r, s) => {
1067
- if (s === t) {
1068
- const i = this.getComponent(t);
1069
- e(i);
1070
- }
1071
- });
1072
- }
1073
- registerAlias(t, e) {
1074
- return this.aliases.set(t, e), this.events.dispatch("component-resolver:resolve", t), () => {
1075
- this.aliases.delete(t);
1076
- };
1077
- }
1078
- }
1079
- var z = /* @__PURE__ */ ((n) => (n.open = "open", n.closed = "closed", n.hidden = "hidden", n))(z || {});
1080
- const me = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1081
- __proto__: null,
1082
- ActionResolver: lr,
1083
- ActionsController: Jt,
1084
- ComponentNode: le,
1085
- ComponentNodeController: ge,
1086
- ComponentPlatform: qt,
1087
- ComponentQuery: yt,
1088
- ComponentResolver: Er,
1089
- WidgetRenderState: z,
1090
- asDescriptor: Or,
1091
- createChildren: Ht,
1092
- createComponentModel: cn,
1093
- createEventSubscriber: sn,
1094
- extendComponent: hn,
1095
- findComponent: an,
1096
- findVisibleComponents: Mt,
1097
- traverseComponents: Kt
1098
- }, Symbol.toStringTag, { value: "Module" }));
1099
- function un(n) {
1100
- return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
1101
- }
1102
- var ln = function() {
1103
- };
1104
- process.env.NODE_ENV !== "production" && (ln = function(n, t, e) {
1105
- var r = arguments.length;
1106
- e = new Array(r > 2 ? r - 2 : 0);
1107
- for (var s = 2; s < r; s++)
1108
- e[s - 2] = arguments[s];
1109
- if (t === void 0)
1110
- throw new Error(
1111
- "`warning(condition, format, ...args)` requires a warning message argument"
1112
- );
1113
- if (t.length < 10 || /^[s\W]*$/.test(t))
1114
- throw new Error(
1115
- "The warning format should be able to uniquely identify this warning. Please, use a more descriptive format than: " + t
1116
- );
1117
- if (!n) {
1118
- var i = 0, o = "Warning: " + t.replace(/%s/g, function() {
1119
- return e[i++];
1120
- });
1121
- typeof console != "undefined" && console.error(o);
1122
- try {
1123
- throw new Error(o);
1124
- } catch (a) {
1125
- }
1126
- }
1127
- });
1128
- var xr = ln;
1129
- const Z = /* @__PURE__ */ un(xr);
1130
- var $r = function(n, t, e, r, s, i, o, a) {
1131
- if (process.env.NODE_ENV !== "production" && t === void 0)
1132
- throw new Error("invariant requires an error message argument");
1133
- if (!n) {
1134
- var c;
1135
- if (t === void 0)
1136
- c = new Error(
1137
- "Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings."
1138
- );
1139
- else {
1140
- var h = [e, r, s, i, o, a], u = 0;
1141
- c = new Error(
1142
- t.replace(/%s/g, function() {
1143
- return h[u++];
1144
- })
1145
- ), c.name = "Invariant Violation";
1146
- }
1147
- throw c.framesToPop = 1, c;
1148
- }
1149
- }, Pr = $r;
1150
- const Sr = /* @__PURE__ */ un(Pr);
1151
- function Ct(n) {
1152
- return n.charAt(0) === "/";
1153
- }
1154
- function ee(n, t) {
1155
- for (var e = t, r = e + 1, s = n.length; r < s; e += 1, r += 1)
1156
- n[e] = n[r];
1157
- n.pop();
1158
- }
1159
- function Cr(n) {
1160
- var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "", e = n && n.split("/") || [], r = t && t.split("/") || [], s = n && Ct(n), i = t && Ct(t), o = s || i;
1161
- if (n && Ct(n) ? r = e : e.length && (r.pop(), r = r.concat(e)), !r.length)
1162
- return "/";
1163
- var a = void 0;
1164
- if (r.length) {
1165
- var c = r[r.length - 1];
1166
- a = c === "." || c === ".." || c === "";
1167
- } else
1168
- a = !1;
1169
- for (var h = 0, u = r.length; u >= 0; u--) {
1170
- var l = r[u];
1171
- l === "." ? ee(r, u) : l === ".." ? (ee(r, u), h++) : h && (ee(r, u), h--);
1172
- }
1173
- if (!o)
1174
- for (; h--; h)
1175
- r.unshift("..");
1176
- o && r[0] !== "" && (!r[0] || !Ct(r[0])) && r.unshift("");
1177
- var d = r.join("/");
1178
- return a && d.substr(-1) !== "/" && (d += "/"), d;
1179
- }
1180
- var kr = function(t) {
1181
- return t.charAt(0) === "/" ? t : "/" + t;
1182
- }, dn = function(t, e) {
1183
- return new RegExp("^" + e + "(\\/|\\?|#|$)", "i").test(t);
1184
- }, Ar = function(t, e) {
1185
- return dn(t, e) ? t.substr(e.length) : t;
1186
- }, Nr = function(t) {
1187
- return t.charAt(t.length - 1) === "/" ? t.slice(0, -1) : t;
1188
- }, Lr = function(t) {
1189
- var e = t || "/", r = "", s = "", i = e.indexOf("#");
1190
- i !== -1 && (s = e.substr(i), e = e.substr(0, i));
1191
- var o = e.indexOf("?");
1192
- return o !== -1 && (r = e.substr(o), e = e.substr(0, o)), {
1193
- pathname: e,
1194
- search: r === "?" ? "" : r,
1195
- hash: s === "#" ? "" : s
1196
- };
1197
- }, pn = function(t) {
1198
- var e = t.pathname, r = t.search, s = t.hash, i = e || "/";
1199
- return r && r !== "?" && (i += r.charAt(0) === "?" ? r : "?" + r), s && s !== "#" && (i += s.charAt(0) === "#" ? s : "#" + s), i;
1200
- }, Mr = Object.assign || function(n) {
1201
- for (var t = 1; t < arguments.length; t++) {
1202
- var e = arguments[t];
1203
- for (var r in e)
1204
- Object.prototype.hasOwnProperty.call(e, r) && (n[r] = e[r]);
1205
- }
1206
- return n;
1207
- }, ct = function(t, e, r, s) {
1208
- var i = void 0;
1209
- typeof t == "string" ? (i = Lr(t), i.state = e) : (i = Mr({}, t), i.pathname === void 0 && (i.pathname = ""), i.search ? i.search.charAt(0) !== "?" && (i.search = "?" + i.search) : i.search = "", i.hash ? i.hash.charAt(0) !== "#" && (i.hash = "#" + i.hash) : i.hash = "", e !== void 0 && i.state === void 0 && (i.state = e));
1210
- try {
1211
- i.pathname = decodeURI(i.pathname);
1212
- } catch (o) {
1213
- throw o instanceof URIError ? new URIError('Pathname "' + i.pathname + '" could not be decoded. This is likely caused by an invalid percent-encoding.') : o;
1214
- }
1215
- return r && (i.key = r), s ? i.pathname ? i.pathname.charAt(0) !== "/" && (i.pathname = Cr(i.pathname, s.pathname)) : i.pathname = s.pathname : i.pathname || (i.pathname = "/"), i;
1216
- }, fn = function() {
1217
- var t = null, e = function(c) {
1218
- return Z(t == null, "A history supports only one prompt at a time"), t = c, function() {
1219
- t === c && (t = null);
1220
- };
1221
- }, r = function(c, h, u, l) {
1222
- if (t != null) {
1223
- var d = typeof t == "function" ? t(c, h) : t;
1224
- typeof d == "string" ? typeof u == "function" ? u(d, l) : (Z(!1, "A history needs a getUserConfirmation function in order to use a prompt message"), l(!0)) : l(d !== !1);
1225
- } else
1226
- l(!0);
1227
- }, s = [], i = function(c) {
1228
- var h = !0, u = function() {
1229
- h && c.apply(void 0, arguments);
1230
- };
1231
- return s.push(u), function() {
1232
- h = !1, s = s.filter(function(l) {
1233
- return l !== u;
1234
- });
1235
- };
1236
- }, o = function() {
1237
- for (var c = arguments.length, h = Array(c), u = 0; u < c; u++)
1238
- h[u] = arguments[u];
1239
- s.forEach(function(l) {
1240
- return l.apply(void 0, h);
1241
- });
1242
- };
1243
- return {
1244
- setPrompt: e,
1245
- confirmTransitionTo: r,
1246
- appendListener: i,
1247
- notifyListeners: o
1248
- };
1249
- }, Dr = !!(typeof window != "undefined" && window.document && window.document.createElement), Me = function(t, e, r) {
1250
- return t.addEventListener ? t.addEventListener(e, r, !1) : t.attachEvent("on" + e, r);
1251
- }, De = function(t, e, r) {
1252
- return t.removeEventListener ? t.removeEventListener(e, r, !1) : t.detachEvent("on" + e, r);
1253
- }, jr = function(t, e) {
1254
- return e(window.confirm(t));
1255
- }, _r = function() {
1256
- var t = window.navigator.userAgent;
1257
- return (t.indexOf("Android 2.") !== -1 || t.indexOf("Android 4.0") !== -1) && t.indexOf("Mobile Safari") !== -1 && t.indexOf("Chrome") === -1 && t.indexOf("Windows Phone") === -1 ? !1 : window.history && "pushState" in window.history;
1258
- }, Ir = function() {
1259
- return window.navigator.userAgent.indexOf("Trident") === -1;
1260
- }, Rr = function(t) {
1261
- return t.state === void 0 && navigator.userAgent.indexOf("CriOS") === -1;
1262
- }, je = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
1263
- return typeof n;
1264
- } : function(n) {
1265
- return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
1266
- }, Tr = Object.assign || function(n) {
1267
- for (var t = 1; t < arguments.length; t++) {
1268
- var e = arguments[t];
1269
- for (var r in e)
1270
- Object.prototype.hasOwnProperty.call(e, r) && (n[r] = e[r]);
1271
- }
1272
- return n;
1273
- }, _e = "popstate", Ie = "hashchange", Re = function() {
1274
- try {
1275
- return window.history.state || {};
1276
- } catch (t) {
1277
- return {};
1278
- }
1279
- }, Hr = function() {
1280
- var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1281
- Sr(Dr, "Browser history needs a DOM");
1282
- var e = window.history, r = _r(), s = !Ir(), i = t.forceRefresh, o = i === void 0 ? !1 : i, a = t.getUserConfirmation, c = a === void 0 ? jr : a, h = t.keyLength, u = h === void 0 ? 6 : h, l = t.basename ? Nr(kr(t.basename)) : "", d = function(y) {
1283
- var O = y || {}, L = O.key, M = O.state, F = window.location, J = F.pathname, et = F.search, Y = F.hash, W = J + et + Y;
1284
- return Z(!l || dn(W, l), 'You are attempting to use a basename on a page whose URL path does not begin with the basename. Expected path "' + W + '" to begin with "' + l + '".'), l && (W = Ar(W, l)), ct(W, M, L);
1285
- }, f = function() {
1286
- return Math.random().toString(36).substr(2, u);
1287
- }, g = fn(), E = function(y) {
1288
- Tr(P, y), P.length = e.length, g.notifyListeners(P.location, P.action);
1289
- }, p = function(y) {
1290
- Rr(y) || U(d(y.state));
1291
- }, C = function() {
1292
- U(d(Re()));
1293
- }, T = !1, U = function(y) {
1294
- if (T)
1295
- T = !1, E();
1296
- else {
1297
- var O = "POP";
1298
- g.confirmTransitionTo(y, O, c, function(L) {
1299
- L ? E({ action: O, location: y }) : _(y);
1300
- });
1301
- }
1302
- }, _ = function(y) {
1303
- var O = P.location, L = H.indexOf(O.key);
1304
- L === -1 && (L = 0);
1305
- var M = H.indexOf(y.key);
1306
- M === -1 && (M = 0);
1307
- var F = L - M;
1308
- F && (T = !0, j(F));
1309
- }, D = d(Re()), H = [D.key], x = function(y) {
1310
- return l + pn(y);
1311
- }, N = function(y, O) {
1312
- Z(!((typeof y == "undefined" ? "undefined" : je(y)) === "object" && y.state !== void 0 && O !== void 0), "You should avoid providing a 2nd state argument to push when the 1st argument is a location-like object that already has state; it is ignored");
1313
- var L = "PUSH", M = ct(y, O, f(), P.location);
1314
- g.confirmTransitionTo(M, L, c, function(F) {
1315
- if (F) {
1316
- var J = x(M), et = M.key, Y = M.state;
1317
- if (r)
1318
- if (e.pushState({ key: et, state: Y }, null, J), o)
1319
- window.location.href = J;
1320
- else {
1321
- var W = H.indexOf(P.location.key), Ee = H.slice(0, W === -1 ? 0 : W + 1);
1322
- Ee.push(M.key), H = Ee, E({ action: L, location: M });
1323
- }
1324
- else
1325
- Z(Y === void 0, "Browser history cannot push state in browsers that do not support HTML5 history"), window.location.href = J;
1326
- }
1327
- });
1328
- }, A = function(y, O) {
1329
- Z(!((typeof y == "undefined" ? "undefined" : je(y)) === "object" && y.state !== void 0 && O !== void 0), "You should avoid providing a 2nd state argument to replace when the 1st argument is a location-like object that already has state; it is ignored");
1330
- var L = "REPLACE", M = ct(y, O, f(), P.location);
1331
- g.confirmTransitionTo(M, L, c, function(F) {
1332
- if (F) {
1333
- var J = x(M), et = M.key, Y = M.state;
1334
- if (r)
1335
- if (e.replaceState({ key: et, state: Y }, null, J), o)
1336
- window.location.replace(J);
1337
- else {
1338
- var W = H.indexOf(P.location.key);
1339
- W !== -1 && (H[W] = M.key), E({ action: L, location: M });
1340
- }
1341
- else
1342
- Z(Y === void 0, "Browser history cannot replace state in browsers that do not support HTML5 history"), window.location.replace(J);
1343
- }
1344
- });
1345
- }, j = function(y) {
1346
- e.go(y);
1347
- }, B = function() {
1348
- return j(-1);
1349
- }, V = function() {
1350
- return j(1);
1351
- }, I = 0, m = function(y) {
1352
- I += y, I === 1 ? (Me(window, _e, p), s && Me(window, Ie, C)) : I === 0 && (De(window, _e, p), s && De(window, Ie, C));
1353
- }, b = !1, v = function() {
1354
- var y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !1, O = g.setPrompt(y);
1355
- return b || (m(1), b = !0), function() {
1356
- return b && (b = !1, m(-1)), O();
1357
- };
1358
- }, w = function(y) {
1359
- var O = g.appendListener(y);
1360
- return m(1), function() {
1361
- m(-1), O();
1362
- };
1363
- }, P = {
1364
- length: e.length,
1365
- action: "POP",
1366
- location: D,
1367
- createHref: x,
1368
- push: N,
1369
- replace: A,
1370
- go: j,
1371
- goBack: B,
1372
- goForward: V,
1373
- block: v,
1374
- listen: w
1375
- };
1376
- return P;
1377
- }, Te = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
1378
- return typeof n;
1379
- } : function(n) {
1380
- return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
1381
- }, Vr = Object.assign || function(n) {
1382
- for (var t = 1; t < arguments.length; t++) {
1383
- var e = arguments[t];
1384
- for (var r in e)
1385
- Object.prototype.hasOwnProperty.call(e, r) && (n[r] = e[r]);
1386
- }
1387
- return n;
1388
- }, He = function(t, e, r) {
1389
- return Math.min(Math.max(t, e), r);
1390
- }, Br = function() {
1391
- var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, e = t.getUserConfirmation, r = t.initialEntries, s = r === void 0 ? ["/"] : r, i = t.initialIndex, o = i === void 0 ? 0 : i, a = t.keyLength, c = a === void 0 ? 6 : a, h = fn(), u = function(A) {
1392
- Vr(x, A), x.length = x.entries.length, h.notifyListeners(x.location, x.action);
1393
- }, l = function() {
1394
- return Math.random().toString(36).substr(2, c);
1395
- }, d = He(o, 0, s.length - 1), f = s.map(function(N) {
1396
- return typeof N == "string" ? ct(N, void 0, l()) : ct(N, void 0, N.key || l());
1397
- }), g = pn, E = function(A, j) {
1398
- Z(!((typeof A == "undefined" ? "undefined" : Te(A)) === "object" && A.state !== void 0 && j !== void 0), "You should avoid providing a 2nd state argument to push when the 1st argument is a location-like object that already has state; it is ignored");
1399
- var B = "PUSH", V = ct(A, j, l(), x.location);
1400
- h.confirmTransitionTo(V, B, e, function(I) {
1401
- if (I) {
1402
- var m = x.index, b = m + 1, v = x.entries.slice(0);
1403
- v.length > b ? v.splice(b, v.length - b, V) : v.push(V), u({
1404
- action: B,
1405
- location: V,
1406
- index: b,
1407
- entries: v
1408
- });
1409
- }
1410
- });
1411
- }, p = function(A, j) {
1412
- Z(!((typeof A == "undefined" ? "undefined" : Te(A)) === "object" && A.state !== void 0 && j !== void 0), "You should avoid providing a 2nd state argument to replace when the 1st argument is a location-like object that already has state; it is ignored");
1413
- var B = "REPLACE", V = ct(A, j, l(), x.location);
1414
- h.confirmTransitionTo(V, B, e, function(I) {
1415
- I && (x.entries[x.index] = V, u({ action: B, location: V }));
1416
- });
1417
- }, C = function(A) {
1418
- var j = He(x.index + A, 0, x.entries.length - 1), B = "POP", V = x.entries[j];
1419
- h.confirmTransitionTo(V, B, e, function(I) {
1420
- I ? u({
1421
- action: B,
1422
- location: V,
1423
- index: j
1424
- }) : u();
1425
- });
1426
- }, T = function() {
1427
- return C(-1);
1428
- }, U = function() {
1429
- return C(1);
1430
- }, _ = function(A) {
1431
- var j = x.index + A;
1432
- return j >= 0 && j < x.entries.length;
1433
- }, D = function() {
1434
- var A = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !1;
1435
- return h.setPrompt(A);
1436
- }, H = function(A) {
1437
- return h.appendListener(A);
1438
- }, x = {
1439
- length: f.length,
1440
- action: "POP",
1441
- location: f[d],
1442
- index: d,
1443
- entries: f,
1444
- createHref: g,
1445
- push: E,
1446
- replace: p,
1447
- go: C,
1448
- goBack: T,
1449
- goForward: U,
1450
- canGo: _,
1451
- block: D,
1452
- listen: H
1453
- };
1454
- return x;
1455
- }, Ur = Object.defineProperty, Ve = Object.getOwnPropertySymbols, Wr = Object.prototype.hasOwnProperty, zr = Object.prototype.propertyIsEnumerable, Be = (n, t, e) => t in n ? Ur(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, pt = (n, t) => {
1456
- for (var e in t || (t = {}))
1457
- Wr.call(t, e) && Be(n, e, t[e]);
1458
- if (Ve)
1459
- for (var e of Ve(t))
1460
- zr.call(t, e) && Be(n, e, t[e]);
1461
- return n;
1462
- }, kt = (n, t, e) => new Promise((r, s) => {
1463
- var i = (c) => {
1464
- try {
1465
- a(e.next(c));
1466
- } catch (h) {
1467
- s(h);
1468
- }
1469
- }, o = (c) => {
1470
- try {
1471
- a(e.throw(c));
1472
- } catch (h) {
1473
- s(h);
1474
- }
1475
- }, a = (c) => c.done ? r(c.value) : Promise.resolve(c.value).then(i, o);
1476
- a((e = e.apply(n, t)).next());
1477
- }), S = /* @__PURE__ */ ((n) => (n.Cookie = "cookie", n.Local = "local", n.Session = "session", n))(S || {}), vt = /* @__PURE__ */ ((n) => (n.Tenant = "tenant", n.Implementation = "implementation", n.Widget = "widget", n))(vt || {}), k = /* @__PURE__ */ ((n) => (n.Necessary = "necessary", n.Functional = "functional", n.Analytical = "analytical", n.Marketing = "marketing", n))(k || {});
1478
- const X = (n, t, e, r = {}) => Ue(n, e).then((s) => (process.env.NODE_ENV !== "production" && s && R.warn(
1479
- `createStorageWriter: Attempted to create storage writer using unallowed category.
1480
- Key: ${t}
1481
- Category: ${JSON.stringify(e)}
1482
- Options: ${JSON.stringify(r)}`
1483
- ), (i) => (be(n), Ue(n, e).then((o) => {
1484
- if (o) {
1485
- process.env.NODE_ENV !== "production" && R.warn(
1486
- `storageWriter: Attempted to write to storage using unallowed category.
1487
- Key: ${t}
1488
- Category: ${JSON.stringify(e)}
1489
- Value: ${JSON.stringify(i)}
1490
- Options: ${JSON.stringify(r)}`
1491
- );
1492
- return;
1493
- }
1494
- const {
1495
- scope: a = vt.Widget,
1496
- medium: c = S.Session,
1497
- duration: h
1498
- } = r, u = Jr();
1499
- return u[a][t] = ve(i, e, h), c === S.Cookie ? Gr(n, u) : Zr(n, c, u);
1500
- })))), q = (n, t, e = S.Session) => (be(n), typeof t == "undefined" ? (process.env.NODE_ENV !== "production" && R.warn("readStorage: Undefined key passed when reading storage. ", t, e), Promise.resolve(void 0)) : e === S.Cookie ? Yr(n).then((r) => Bt(r, t)) : Qr(n, e).then((r) => Bt(r, t))), mt = (n) => !!Object.entries(n).filter(([t, e]) => typeof e != "undefined").length, ne = (n) => Object.entries(n).filter(([t, e]) => typeof e != "undefined").forEach(([t, { value: e }]) => {
1501
- typeof e == "undefined" && delete n[t];
1502
- }), gn = (n, t) => {
1503
- const e = {
1504
- tenant: pt(pt({}, n.tenant), t.tenant),
1505
- implementation: pt(pt({}, n.implementation), t.implementation),
1506
- widget: pt(pt({}, n.widget), t.widget)
1507
- };
1508
- return ne(e.tenant), ne(e.implementation), ne(e.widget), e;
1509
- }, Fr = (n) => Object.entries(n).reduce((t, e) => {
1510
- const [r, s] = e;
1511
- return Object.entries(s).forEach((i) => {
1512
- const [o, { expiration: a }] = i;
1513
- a && t.push(a);
1514
- }), t;
1515
- }, []).slice().sort((t, e) => new Date(e).valueOf() - new Date(t).valueOf()).shift() || Gt(), Yt = (n) => {
1516
- const {
1517
- name: t,
1518
- implementation: { name: e, tenant: r }
1519
- } = n.get("$widget");
1520
- return [
1521
- `humany_${r}`,
1522
- `humany_${ke(r + e)}`,
1523
- `humany_${ke(r + e + t)}`
1524
- ];
1525
- }, re = (n) => {
1526
- const t = new RegExp(`(?:^|;)\\s?${n}=(.*?)(?:;|$)`, "i"), e = document.cookie.match(t);
1527
- return e && e[1] && JSON.parse(e[1]) || void 0;
1528
- }, se = (n, t, e) => {
1529
- const r = `${n}=${JSON.stringify(t).trim()}`, s = `expires=${new Date(e).toUTCString()}`, i = "path=/", o = "SameSite=None;Secure";
1530
- return document.cookie = `${r}; ${s}; ${i}; ${o}`;
1531
- }, ye = (n) => {
1532
- const [t, e, r] = Yt(n), s = re(t) || {}, i = re(e) || {}, o = re(r) || {};
1533
- return {
1534
- tenant: s,
1535
- implementation: i,
1536
- widget: o
1537
- };
1538
- }, mn = (n, t) => {
1539
- const e = ye(n), r = gn(e, t), [s, i, o] = Yt(n), { tenant: a, implementation: c, widget: h } = r, u = Fr(t), l = Gt({ days: -1 });
1540
- se(s, a, mt(a) ? u : l), se(
1541
- i,
1542
- c,
1543
- mt(c) ? u : l
1544
- ), se(o, h, mt(h) ? u : l);
1545
- }, Vt = (n, t) => {
1546
- const [e, r, s] = Yt(n), i = t.getItem(e) || "{}", o = t.getItem(r) || "{}", a = t.getItem(s) || "{}";
1547
- return {
1548
- tenant: JSON.parse(i),
1549
- implementation: JSON.parse(o),
1550
- widget: JSON.parse(a)
1551
- };
1552
- }, de = (n, t, e) => {
1553
- const r = Vt(n, t), s = gn(r, e), [i, o, a] = Yt(n), { tenant: c, implementation: h, widget: u } = s;
1554
- mt(c) ? t.setItem(i, JSON.stringify(c)) : t.removeItem(i), mt(h) ? t.setItem(o, JSON.stringify(h)) : t.removeItem(o), mt(u) ? t.setItem(a, JSON.stringify(u)) : t.removeItem(a);
1555
- }, Jr = () => ({ tenant: {}, implementation: {}, widget: {} }), Kr = (n) => n ? !!n && /* @__PURE__ */ new Date() > new Date(n) : !1, Bt = (n, t) => {
1556
- const e = n.widget[t] || n.implementation[t] || n.tenant[t];
1557
- return e == null ? void 0 : e.value;
1558
- }, ve = (n, t, e) => e ? {
1559
- value: n,
1560
- category: t,
1561
- expiration: typeof e == "object" ? Gt(e) : e
1562
- } : {
1563
- value: n,
1564
- category: t
1565
- }, Dt = (n, t) => {
1566
- const e = Zn(n);
1567
- return Object.entries(e).forEach(([r, s]) => {
1568
- Object.entries(s).forEach(([i, o]) => {
1569
- const { expiration: a, category: c } = o;
1570
- (Kr(a) || qr(t, c)) && (s[i] = ve(void 0, c, a));
1571
- });
1572
- }), e;
1573
- }, Ue = (n, t) => q(n, "storagePolicy", S.Cookie).then(
1574
- (e = [k.Necessary]) => !!t && e.indexOf(t) === -1
1575
- ), qr = (n = [k.Necessary], t) => !!t && n.indexOf(t) === -1, be = (n) => {
1576
- const t = ye(n), e = Vt(n, window.localStorage), r = Vt(n, sessionStorage), s = Bt(t, "storagePolicy"), [i, o, a] = [
1577
- t,
1578
- e,
1579
- r
1580
- ].map((c) => Dt(c, s));
1581
- mn(n, i), de(n, window.localStorage, o), de(n, window.sessionStorage, a);
1582
- }, Gt = (n = { days: 30 }) => {
1583
- const { days: t = 0, hours: e = 0, minutes: r = 0, seconds: s = 0 } = n, i = /* @__PURE__ */ new Date();
1584
- return i.setTime(i.getTime() + e * 60 * 60 * 1e3), i.setTime(i.getTime() + t * 24 * 60 * 60 * 1e3), i.setTime(i.getTime() + r * 60 * 1e3), i.setTime(i.getTime() + s * 1e3), i.toISOString();
1585
- }, Yr = (n) => G(document)(() => ye(n)), Gr = (n, t) => G(document)(() => mn(n, t)), Qr = (n, t) => {
1586
- const e = t === S.Local ? window.localStorage : window.sessionStorage;
1587
- return G(e)(() => Vt(n, e));
1588
- }, Zr = (n, t, e) => {
1589
- const r = t === S.Local ? window.localStorage : window.sessionStorage;
1590
- return G(r)(() => de(n, r, e));
1591
- };
1592
- class jt {
1593
- constructor() {
1594
- this.memory = {
1595
- tenant: {},
1596
- implementation: {},
1597
- widget: {}
1598
- };
1599
- }
1600
- setItem(t, e) {
1601
- return kt(this, arguments, function* (r, s, i = {}) {
1602
- return G(this)(() => {
1603
- const o = Dt(this.memory, [k.Necessary]), { scope: a = vt.Tenant, expiration: c } = i;
1604
- o[a][r] = ve(
1605
- s,
1606
- k.Necessary,
1607
- (c == null ? void 0 : c.toISOString()) || Gt()
1608
- ), this.memory = o, process.env.NODE_ENV !== "production" && R.warn(
1609
- `StorageProvider: StorageProvider is deprecated, use createStorageWriter and readStorage instead, value stored temporarily in memory.
1610
- Key: ${r}
1611
- Value: ${JSON.stringify(s)}
1612
- Options: ${JSON.stringify(i)}
1613
- Memory: ${JSON.stringify(o)}`
1614
- );
1615
- });
1616
- });
1617
- }
1618
- getItem(t) {
1619
- return kt(this, null, function* () {
1620
- return G(this)(() => {
1621
- const e = Dt(this.memory, [k.Necessary]);
1622
- process.env.NODE_ENV !== "production" && R.warn(
1623
- `StorageProvider: StorageProvider is deprecated, use createStorageWriter and readStorage instead, value fetched from legacy memory storage.
1624
- Key: ${t}
1625
- Memory: ${JSON.stringify(e)}`
1626
- );
1627
- const r = Bt(e, t);
1628
- return this.memory = e, r;
1629
- });
1630
- });
1631
- }
1632
- removeItem(t) {
1633
- return kt(this, null, function* () {
1634
- return G(this)(() => {
1635
- const e = Dt(this.memory, [k.Necessary]);
1636
- delete e.tenant[t], delete e.implementation[t], delete e.widget[t], this.memory = e, process.env.NODE_ENV !== "production" && R.warn(
1637
- `StorageProvider: StorageProvider is deprecated, use createStorageWriter and readStorage instead, value removed from memory.
1638
- Key: ${t}
1639
- Memory: ${JSON.stringify(e)}`
1640
- );
1641
- });
1642
- });
1643
- }
1644
- clear() {
1645
- return kt(this, null, function* () {
1646
- return Promise.resolve();
1647
- });
1648
- }
1649
- }
1650
- let Xr = class {
1651
- constructor() {
1652
- this.cookies = new jt(), this.session = new jt(), this.local = new jt();
1653
- }
1654
- };
1655
- const ie = (n, t, e, ...r) => {
1656
- const s = `[${n.get("$environment").name || "webprovisions"}] ${e}`;
1657
- switch (t) {
1658
- case "info":
1659
- console.info(s, ...r);
1660
- break;
1661
- case "warning":
1662
- console.warn(s, ...r);
1663
- break;
1664
- case "error":
1665
- console.error(s, ...r);
1666
- break;
1667
- }
1668
- }, ts = (n) => {
1669
- const t = n.container || n;
1670
- return {
1671
- info: (e, ...r) => ie(t, "info", e, ...r),
1672
- warn: (e, ...r) => ie(t, "warning", e, ...r),
1673
- error: (e, ...r) => ie(t, "error", e, ...r)
1674
- };
1675
- };
1676
- var Ut = /* @__PURE__ */ ((n) => (n.Implementation = "implementation", n.Widget = "widget", n))(Ut || {}), ht = /* @__PURE__ */ ((n) => (n.Pre = "pre", n.Post = "post", n))(ht || {});
1677
- const es = (n, t, e, r) => {
1678
- try {
1679
- const s = new t(e, r);
1680
- return {
1681
- name: n,
1682
- invoke: (i, o) => {
1683
- let a;
1684
- return s[i] && (a = s[i].call(s, o)), Promise.resolve(a);
1685
- },
1686
- getInstance: () => s
1687
- };
1688
- } catch (s) {
1689
- if (s.message && s.message.indexOf("is not a constructor") >= 0)
1690
- return {
1691
- name: n,
1692
- invoke: (i) => {
1693
- let o;
1694
- return i === "initialize" && (o = t(e, r)), Promise.resolve(o);
1695
- },
1696
- getInstance: () => t
1697
- };
1698
- throw s;
1699
- }
1700
- };
1701
- function We(n, t) {
1702
- return typeof n == "undefined" ? t : n;
1703
- }
1704
- let ns = class {
1705
- constructor(t = {}) {
1706
- this.part = t;
1707
- }
1708
- createCommand(t, e, r) {
1709
- let s;
1710
- typeof e == "function" ? s = {
1711
- scope: Ut.Widget,
1712
- stage: ht.Post,
1713
- defaultArgs: void 0,
1714
- handlerResolver: e
1715
- } : s = {
1716
- scope: We(e.scope, Ut.Widget),
1717
- stage: We(e.stage, ht.Post),
1718
- defaultArgs: e.defaultArgs,
1719
- handlerResolver: r
1720
- };
1721
- let i = this.part;
1722
- const o = t.split(".");
1723
- return o.forEach((a, c) => {
1724
- c === o.length - 1 ? i[a] || (i[a] = () => s) : i = this.part[a] = this.part[a] || {};
1725
- }), this;
1726
- }
1727
- get() {
1728
- return this.part;
1729
- }
1730
- };
1731
- const yn = (n) => {
1732
- const t = new ns({});
1733
- return n(t), t.get();
1734
- };
1735
- yn((n) => {
1736
- n.createCommand(
1737
- "types.register",
1738
- { scope: Ut.Implementation, stage: ht.Pre },
1739
- (t) => (e, r) => {
1740
- t.container.get("$types")[e] = r;
1741
- }
1742
- ).createCommand(
1743
- "type",
1744
- { stage: ht.Pre },
1745
- (t) => (e) => {
1746
- t.container.register("$type", e);
1747
- }
1748
- ).createCommand(
1749
- "settings",
1750
- { stage: ht.Pre, defaultArgs: [null] },
1751
- (t) => (e) => {
1752
- t.events.dispatch(
1753
- "settings:change",
1754
- e,
1755
- { bubbles: !0 }
1756
- ), t.container.register("$settings", e);
1757
- }
1758
- ).createCommand(
1759
- "plugin",
1760
- { stage: ht.Pre },
1761
- (t) => (e, r, s) => {
1762
- const { container: i } = t;
1763
- let o = null, a = e, c = r;
1764
- typeof e == "string" && (o = e, a = r, c = s);
1765
- const h = (u) => {
1766
- const { transformPluginSettings: l } = t.container.get("$environmentOptions"), d = l ? l(
1767
- c || {},
1768
- o,
1769
- t.container,
1770
- a
1771
- ) : r;
1772
- try {
1773
- const f = es(
1774
- o,
1775
- a,
1776
- i,
1777
- d
1778
- );
1779
- i.get("$plugins").push(f), u && f.invoke("initialize", null);
1780
- } catch (f) {
1781
- ts(t).warn("Error when initializing plugin", f);
1782
- }
1783
- };
1784
- t.container.get("$instance") ? h(!0) : t.events.subscribeOnce("widget:instance-created", () => h(!1));
1785
- }
1786
- ).createCommand(
1787
- "container.register",
1788
- (t) => (e, r) => {
1789
- t.container.register(e, r);
1790
- }
1791
- ).createCommand(
1792
- "container.registerAsync",
1793
- (t) => (e, r) => {
1794
- t.container.registerAsync(e, r);
1795
- }
1796
- ).createCommand(
1797
- "container.registerFactory",
1798
- (t) => (e, r) => {
1799
- t.container.registerFactory(e, r);
1800
- }
1801
- ).createCommand(
1802
- "container.touch",
1803
- (t) => (e, r) => {
1804
- t.container.touch(e, r);
1805
- }
1806
- ).createCommand(
1807
- "csp",
1808
- {},
1809
- (t) => (e) => {
1810
- t.container.register("csp", e);
1811
- }
1812
- );
1813
- });
1814
- yn((n) => {
1815
- n.createCommand("storage", (t) => (e = {}) => {
1816
- const { consent: r } = e;
1817
- if (typeof r != "undefined") {
1818
- if (typeof r != "number" && typeof r != "string" && !Array.isArray(r)) {
1819
- process.env.NODE_ENV !== "production" && R.warn(
1820
- `storagePolicyConfigurationApi: passed consent is not valid. Consent either has to be a number, a string, an array of strings or an array of numbers.
1821
- Passed consent: ${JSON.stringify(r)}`
1822
- );
1823
- return;
1824
- }
1825
- if (Array.isArray(r) && !r.every(
1826
- (i) => typeof i == "number" || typeof i == "string"
1827
- )) {
1828
- process.env.NODE_ENV !== "production" && R.warn(
1829
- `storagePolicyConfigurationApi: passed consent is not valid. Consent either has to be a number, a string, an array of strings or an array of numbers.
1830
- Passed consent: ${JSON.stringify(r)}`
1831
- );
1832
- return;
1833
- }
1834
- const s = [
1835
- k.Necessary,
1836
- k.Functional,
1837
- k.Analytical,
1838
- k.Marketing
1839
- ].filter((i, o, a) => typeof r == "number" ? r > o : typeof r == "string" ? a.indexOf(r) + 1 > o : Array.isArray(r) ? r.findIndex((c) => c === o + 1 || c === i) > -1 : !0);
1840
- return s.indexOf(k.Necessary) === -1 && (process.env.NODE_ENV !== "production" && R.warn(
1841
- `storagePolicyConfigurationApi: passed consent does not include category: '${k.Necessary}'. Consent has to atleast include the '${k.Necessary}' category.
1842
- Passed consent: ${JSON.stringify(r)}`
1843
- ), s.unshift(k.Necessary)), X(
1844
- t.container,
1845
- "storagePolicy",
1846
- k.Necessary,
1847
- {
1848
- medium: S.Cookie,
1849
- scope: vt.Tenant,
1850
- duration: { days: 365 }
1851
- }
1852
- ).then((i) => i(s)).then(() => {
1853
- be(t.container), t.events.dispatch("storage:policy-changed", s);
1854
- });
1855
- }
1856
- });
1857
- });
1858
- const rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1859
- __proto__: null,
1860
- StorageCategory: k,
1861
- StorageMedium: S,
1862
- StorageProvider: Xr,
1863
- StorageScope: vt,
1864
- StorageService: jt,
1865
- createStorageWriter: X,
1866
- readStorage: q
1867
- }, Symbol.toStringTag, { value: "Module" }));
1868
- var ss = Object.defineProperty, is = Object.defineProperties, os = Object.getOwnPropertyDescriptors, Wt = Object.getOwnPropertySymbols, vn = Object.prototype.hasOwnProperty, bn = Object.prototype.propertyIsEnumerable, ze = (n, t, e) => t in n ? ss(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, gt = (n, t) => {
1869
- for (var e in t || (t = {}))
1870
- vn.call(t, e) && ze(n, e, t[e]);
1871
- if (Wt)
1872
- for (var e of Wt(t))
1873
- bn.call(t, e) && ze(n, e, t[e]);
1874
- return n;
1875
- }, wn = (n, t) => is(n, os(t)), as = (n, t) => {
1876
- var e = {};
1877
- for (var r in n)
1878
- vn.call(n, r) && t.indexOf(r) < 0 && (e[r] = n[r]);
1879
- if (n != null && Wt)
1880
- for (var r of Wt(n))
1881
- t.indexOf(r) < 0 && bn.call(n, r) && (e[r] = n[r]);
1882
- return e;
1883
- };
1884
- function On(n) {
1885
- if (n.__esModule)
1886
- return n;
1887
- var t = n.default;
1888
- if (typeof t == "function") {
1889
- var e = function r() {
1890
- if (this instanceof r) {
1891
- var s = [null];
1892
- s.push.apply(s, arguments);
1893
- var i = Function.bind.apply(t, s);
1894
- return new i();
1895
- }
1896
- return t.apply(this, arguments);
1897
- };
1898
- e.prototype = t.prototype;
1899
- } else
1900
- e = {};
1901
- return Object.defineProperty(e, "__esModule", { value: !0 }), Object.keys(n).forEach(function(r) {
1902
- var s = Object.getOwnPropertyDescriptor(n, r);
1903
- Object.defineProperty(e, r, s.get ? s : {
1904
- enumerable: !0,
1905
- get: function() {
1906
- return n[r];
1907
- }
1908
- });
1909
- }), e;
1910
- }
1911
- var En = function() {
1912
- };
1913
- process.env.NODE_ENV !== "production" && (En = function(n, t, e) {
1914
- var r = arguments.length;
1915
- e = new Array(r > 2 ? r - 2 : 0);
1916
- for (var s = 2; s < r; s++)
1917
- e[s - 2] = arguments[s];
1918
- if (t === void 0)
1919
- throw new Error(
1920
- "`warning(condition, format, ...args)` requires a warning message argument"
1921
- );
1922
- if (t.length < 10 || /^[s\W]*$/.test(t))
1923
- throw new Error(
1924
- "The warning format should be able to uniquely identify this warning. Please, use a more descriptive format than: " + t
1925
- );
1926
- if (!n) {
1927
- var i = 0, o = "Warning: " + t.replace(/%s/g, function() {
1928
- return e[i++];
1929
- });
1930
- typeof console != "undefined" && console.error(o);
1931
- try {
1932
- throw new Error(o);
1933
- } catch (a) {
1934
- }
1935
- }
1936
- });
1937
- var cs = En, hs = cs, Fe = us(hs);
1938
- function us(n) {
1939
- return n && n.__esModule ? n : { default: n };
1940
- }
1941
- var ls = function() {
1942
- var n = null, t = function(o) {
1943
- return (0, Fe.default)(n == null, "A history supports only one prompt at a time"), n = o, function() {
1944
- n === o && (n = null);
1945
- };
1946
- }, e = function(o, a, c, h) {
1947
- if (n != null) {
1948
- var u = typeof n == "function" ? n(o, a) : n;
1949
- typeof u == "string" ? typeof c == "function" ? c(u, h) : ((0, Fe.default)(!1, "A history needs a getUserConfirmation function in order to use a prompt message"), h(!0)) : h(u !== !1);
1950
- } else
1951
- h(!0);
1952
- }, r = [], s = function(o) {
1953
- var a = !0, c = function() {
1954
- a && o.apply(void 0, arguments);
1955
- };
1956
- return r.push(c), function() {
1957
- a = !1, r = r.filter(function(h) {
1958
- return h !== c;
1959
- });
1960
- };
1961
- }, i = function() {
1962
- for (var o = arguments.length, a = Array(o), c = 0; c < o; c++)
1963
- a[c] = arguments[c];
1964
- r.forEach(function(h) {
1965
- return h.apply(void 0, a);
1966
- });
1967
- };
1968
- return {
1969
- setPrompt: t,
1970
- confirmTransitionTo: e,
1971
- appendListener: s,
1972
- notifyListeners: i
1973
- };
1974
- }, xn = ls, $n;
1975
- $n = function(n, t) {
1976
- return t(window.confirm(n));
1977
- };
1978
- function At(n) {
1979
- return n.charAt(0) === "/";
1980
- }
1981
- function oe(n, t) {
1982
- for (var e = t, r = e + 1, s = n.length; r < s; e += 1, r += 1)
1983
- n[e] = n[r];
1984
- n.pop();
1985
- }
1986
- function ds(n) {
1987
- var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "", e = n && n.split("/") || [], r = t && t.split("/") || [], s = n && At(n), i = t && At(t), o = s || i;
1988
- if (n && At(n) ? r = e : e.length && (r.pop(), r = r.concat(e)), !r.length)
1989
- return "/";
1990
- var a = void 0;
1991
- if (r.length) {
1992
- var c = r[r.length - 1];
1993
- a = c === "." || c === ".." || c === "";
1994
- } else
1995
- a = !1;
1996
- for (var h = 0, u = r.length; u >= 0; u--) {
1997
- var l = r[u];
1998
- l === "." ? oe(r, u) : l === ".." ? (oe(r, u), h++) : h && (oe(r, u), h--);
1999
- }
2000
- if (!o)
2001
- for (; h--; h)
2002
- r.unshift("..");
2003
- o && r[0] !== "" && (!r[0] || !At(r[0])) && r.unshift("");
2004
- var d = r.join("/");
2005
- return a && d.substr(-1) !== "/" && (d += "/"), d;
2006
- }
2007
- const ps = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2008
- __proto__: null,
2009
- default: ds
2010
- }, Symbol.toStringTag, { value: "Module" })), fs = /* @__PURE__ */ On(ps);
2011
- var Je = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
2012
- return typeof n;
2013
- } : function(n) {
2014
- return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
2015
- };
2016
- function _t(n, t) {
2017
- if (n === t)
2018
- return !0;
2019
- if (n == null || t == null)
2020
- return !1;
2021
- if (Array.isArray(n))
2022
- return Array.isArray(t) && n.length === t.length && n.every(function(c, h) {
2023
- return _t(c, t[h]);
2024
- });
2025
- var e = typeof n == "undefined" ? "undefined" : Je(n), r = typeof t == "undefined" ? "undefined" : Je(t);
2026
- if (e !== r)
2027
- return !1;
2028
- if (e === "object") {
2029
- var s = n.valueOf(), i = t.valueOf();
2030
- if (s !== n || i !== t)
2031
- return _t(s, i);
2032
- var o = Object.keys(n), a = Object.keys(t);
2033
- return o.length !== a.length ? !1 : o.every(function(c) {
2034
- return _t(n[c], t[c]);
2035
- });
2036
- }
2037
- return !1;
2038
- }
2039
- const gs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2040
- __proto__: null,
2041
- default: _t
2042
- }, Symbol.toStringTag, { value: "Module" })), ms = /* @__PURE__ */ On(gs);
2043
- var tt = {}, rt, Pn, pe, xt;
2044
- tt.__esModule = !0;
2045
- xt = tt.addLeadingSlash = function(n) {
2046
- return n.charAt(0) === "/" ? n : "/" + n;
2047
- };
2048
- pe = tt.stripLeadingSlash = function(n) {
2049
- return n.charAt(0) === "/" ? n.substr(1) : n;
2050
- };
2051
- var ys = tt.hasBasename = function(n, t) {
2052
- return new RegExp("^" + t + "(\\/|\\?|#|$)", "i").test(n);
2053
- };
2054
- tt.stripBasename = function(n, t) {
2055
- return ys(n, t) ? n.substr(t.length) : n;
2056
- };
2057
- Pn = tt.stripTrailingSlash = function(n) {
2058
- return n.charAt(n.length - 1) === "/" ? n.slice(0, -1) : n;
2059
- };
2060
- tt.parsePath = function(n) {
2061
- var t = n || "/", e = "", r = "", s = t.indexOf("#");
2062
- s !== -1 && (r = t.substr(s), t = t.substr(0, s));
2063
- var i = t.indexOf("?");
2064
- return i !== -1 && (e = t.substr(i), t = t.substr(0, i)), {
2065
- pathname: t,
2066
- search: e === "?" ? "" : e,
2067
- hash: r === "#" ? "" : r
2068
- };
2069
- };
2070
- rt = tt.createPath = function(n) {
2071
- var t = n.pathname, e = n.search, r = n.hash, s = t || "/";
2072
- return e && e !== "?" && (s += e.charAt(0) === "?" ? e : "?" + e), r && r !== "#" && (s += r.charAt(0) === "#" ? r : "#" + r), s;
2073
- };
2074
- var Qt, Sn = Qt = void 0, vs = Object.assign || function(n) {
2075
- for (var t = 1; t < arguments.length; t++) {
2076
- var e = arguments[t];
2077
- for (var r in e)
2078
- Object.prototype.hasOwnProperty.call(e, r) && (n[r] = e[r]);
2079
- }
2080
- return n;
2081
- }, bs = fs, ws = Cn(bs), Os = ms, Es = Cn(Os), xs = tt;
2082
- function Cn(n) {
2083
- return n && n.__esModule ? n : { default: n };
2084
- }
2085
- Qt = function(n, t, e, r) {
2086
- var s = void 0;
2087
- typeof n == "string" ? (s = (0, xs.parsePath)(n), s.state = t) : (s = vs({}, n), s.pathname === void 0 && (s.pathname = ""), s.search ? s.search.charAt(0) !== "?" && (s.search = "?" + s.search) : s.search = "", s.hash ? s.hash.charAt(0) !== "#" && (s.hash = "#" + s.hash) : s.hash = "", t !== void 0 && s.state === void 0 && (s.state = t));
2088
- try {
2089
- s.pathname = decodeURI(s.pathname);
2090
- } catch (i) {
2091
- throw i instanceof URIError ? new URIError('Pathname "' + s.pathname + '" could not be decoded. This is likely caused by an invalid percent-encoding.') : i;
2092
- }
2093
- return e && (s.key = e), r ? s.pathname ? s.pathname.charAt(0) !== "/" && (s.pathname = (0, ws.default)(s.pathname, r.pathname)) : s.pathname = r.pathname : s.pathname || (s.pathname = "/"), s;
2094
- };
2095
- Sn = function(n, t) {
2096
- return n.pathname === t.pathname && n.search === t.search && n.hash === t.hash && n.key === t.key && (0, Es.default)(n.state, t.state);
2097
- };
2098
- const kn = "/", An = "./", $s = new RegExp(
2099
- [
2100
- // Match escaped characters that would otherwise appear in future matches.
2101
- // This allows the user to escape special characters that won't transform.
2102
- "(\\\\.)",
2103
- // Match Express-style parameters and un-named parameters with a prefix
2104
- // and optional suffixes. Matches appear as:
2105
- //
2106
- // "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?"]
2107
- // "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined]
2108
- "(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"
2109
- ].join("|"),
2110
- "g"
2111
- ), Nn = (n, t) => {
2112
- const e = [];
2113
- let r = 0, s = 0, i = "";
2114
- const o = t && t.delimiter || kn, a = t && t.delimiters || An;
2115
- let c = !1, h;
2116
- for (; (h = $s.exec(n)) !== null; ) {
2117
- const u = h[0], l = h[1], d = h.index;
2118
- if (i += n.slice(s, d), s = d + u.length, l) {
2119
- i += l[1], c = !0;
2120
- continue;
2121
- }
2122
- let f = "";
2123
- const g = n[s], E = h[2], p = h[3], C = h[4], T = h[5];
2124
- if (!c && i.length) {
2125
- const N = i.length - 1;
2126
- a.indexOf(i[N]) > -1 && (f = i[N], i = i.slice(0, N));
2127
- }
2128
- i && (e.push(i), i = "", c = !1);
2129
- const U = f !== "" && g !== void 0 && g !== f, _ = T === "+" || T === "*", D = T === "?" || T === "*", H = f || o, x = p || C;
2130
- e.push({
2131
- delimiter: H,
2132
- optional: D,
2133
- repeat: _,
2134
- partial: U,
2135
- name: E || r++,
2136
- // tslint:disable-line:no-increment-decrement
2137
- prefix: f,
2138
- pattern: x ? Cs(x) : "[^" + wt(H) + "]+?"
2139
- });
2140
- }
2141
- return (i || s < n.length) && e.push(i + n.substr(s)), e;
2142
- }, Ps = (n, t) => Ss(Nn(n, t)), Ss = (n) => {
2143
- const t = new Array(n.length);
2144
- for (let e = 0; e < n.length; e++)
2145
- typeof n[e] == "object" && (t[e] = new RegExp("^(?:" + n[e].pattern + ")$"));
2146
- return function(e, r) {
2147
- let s = "";
2148
- const i = r && r.encode || encodeURIComponent;
2149
- for (let o = 0; o < n.length; o++) {
2150
- const a = n[o];
2151
- if (typeof a == "string") {
2152
- s += a;
2153
- continue;
2154
- }
2155
- const c = e ? e[a.name] : void 0;
2156
- let h;
2157
- if (Array.isArray(c)) {
2158
- if (!a.repeat)
2159
- throw new TypeError(
2160
- 'Expected "' + a.name + '" to not repeat, but got array'
2161
- );
2162
- if (c.length === 0) {
2163
- if (a.optional)
2164
- continue;
2165
- throw new TypeError('Expected "' + a.name + '" to not be empty');
2166
- }
2167
- for (let u = 0; u < c.length; u++) {
2168
- if (h = i(c[u], a), !t[o].test(h))
2169
- throw new TypeError(
2170
- 'Expected all "' + a.name + '" to match "' + a.pattern + '"'
2171
- );
2172
- s += (u === 0 ? a.prefix : a.delimiter) + h;
2173
- }
2174
- continue;
2175
- }
2176
- if (typeof c == "string" || typeof c == "number" || typeof c == "boolean") {
2177
- if (h = i(String(c), a), !t[o].test(h))
2178
- throw new TypeError(
2179
- 'Expected "' + a.name + '" to match "' + a.pattern + '", but got "' + h + '"'
2180
- );
2181
- s += a.prefix + h;
2182
- continue;
2183
- }
2184
- if (a.optional) {
2185
- a.partial && (s += a.prefix);
2186
- continue;
2187
- }
2188
- throw new TypeError(
2189
- 'Expected "' + a.name + '" to be ' + (a.repeat ? "an array" : "a string")
2190
- );
2191
- }
2192
- return s;
2193
- };
2194
- }, wt = (n) => n.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1"), Cs = (n) => n.replace(/([=!:$/()])/g, "\\$1"), Ln = (n) => n && n.sensitive ? "" : "i", ks = (n, t) => {
2195
- if (!t)
2196
- return n;
2197
- const e = n.source.match(/\((?!\?)/g);
2198
- if (e)
2199
- for (let r = 0; r < e.length; r++)
2200
- t.push({
2201
- name: r,
2202
- prefix: "",
2203
- delimiter: "",
2204
- optional: !1,
2205
- repeat: !1,
2206
- partial: !1,
2207
- pattern: ""
2208
- });
2209
- return n;
2210
- }, As = (n, t, e) => {
2211
- const r = [];
2212
- for (let s = 0; s < n.length; s++)
2213
- r.push(Mn(n[s], t, e).source);
2214
- return new RegExp("(?:" + r.join("|") + ")", Ln(e));
2215
- }, Ns = (n, t, e) => Ls(Nn(n, e), t, e), Ls = (n, t, e) => {
2216
- e = e || {};
2217
- const r = e.strict, s = e.end !== !1, i = wt(e.delimiter || kn), o = e.delimiters || An, a = [].concat(e.endsWith || []).map(wt).concat("$").join("|");
2218
- let c = "", h = !1;
2219
- for (let u = 0; u < n.length; u++) {
2220
- const l = n[u];
2221
- if (typeof l == "string")
2222
- c += wt(l), h = u === n.length - 1 && o.indexOf(l[l.length - 1]) > -1;
2223
- else {
2224
- const d = wt(l.prefix), f = l.repeat ? "(?:" + l.pattern + ")(?:" + d + "(?:" + l.pattern + "))*" : l.pattern;
2225
- t && t.push(l), l.optional ? l.partial ? c += d + "(" + f + ")?" : c += "(?:" + d + "(" + f + "))?" : c += d + "(" + f + ")";
2226
- }
2227
- }
2228
- return s ? (r || (c += "(?:" + i + ")?"), c += a === "$" ? "$" : "(?=" + a + ")") : (r || (c += "(?:" + i + "(?=" + a + "))?"), h || (c += "(?=" + i + "|" + a + ")")), new RegExp("^" + c, Ln(e));
2229
- }, Mn = (n, t, e) => n instanceof RegExp ? ks(n, t || []) : Array.isArray(n) ? As(n, t, e) : Ns(n, t, e), zt = Mn;
2230
- var K = /* @__PURE__ */ ((n) => (n.scopedHash = "scopedHash", n.hash = "hash", n.browser = "browser", n.memory = "memory", n))(K || {}), ot = /* @__PURE__ */ ((n) => (n.storage = "storage", n.path = "path", n.initialPath = "initial", n))(ot || {});
2231
- const Ot = (n, t) => {
2232
- const e = [], r = zt(t, e).exec(n);
2233
- if (!r)
2234
- return {};
2235
- const [s, ...i] = r;
2236
- return e.reduce((o, a, c) => (o[a.name] = i[c], o), {});
2237
- }, Ms = (n) => Object.keys(n).reduce((t, e) => {
2238
- const r = typeof n[e] == "string" ? n[e].replace("&", "%20") : n[e];
2239
- let s = `${e}=${r}`;
2240
- return t.length > 1 && (s = "&".concat(s)), t.concat(s);
2241
- }, "?"), ae = (n, t) => {
2242
- const e = t.find((r) => r.name === n);
2243
- if (!e) {
2244
- process.env.NODE_ENV !== "production" && R.warn(`Unable to find route with specified name: ${n}`);
2245
- return;
2246
- }
2247
- return e;
2248
- }, Dn = (n) => n.length ? n.slice(1).split("&").map((t) => t.split("=")).reduce((t, e) => {
2249
- const [r, s] = e.map(encodeURI).map(decodeURIComponent);
2250
- return wn(gt({}, t), { [r]: decodeURIComponent(s).replace("%20", "&") });
2251
- }, {}) : {}, Ds = (n, t) => {
2252
- const e = t.map((r) => It(n, r)).reduce(
2253
- (r, s) => {
2254
- if (s === null)
2255
- return r;
2256
- const i = s.split("?")[1];
2257
- let o = 0;
2258
- if (i) {
2259
- const a = Dn(`?${i}`);
2260
- o = Object.keys(a).length;
2261
- }
2262
- return !r.path || r.count && o < r.count ? {
2263
- count: o,
2264
- path: s
2265
- } : r;
2266
- },
2267
- { count: void 0, path: void 0 }
2268
- );
2269
- return e ? e.path : t[0];
2270
- }, It = (n, t) => {
2271
- const e = lt(n);
2272
- if (Array.isArray(t)) {
2273
- const c = Ds(e, t);
2274
- if (!c)
2275
- throw new Error("Unable to match path.");
2276
- return c;
2277
- }
2278
- const r = Ps(t);
2279
- let s = t;
2280
- try {
2281
- s = r(e);
2282
- } catch (c) {
2283
- return null;
2284
- }
2285
- const i = [];
2286
- zt(t, i);
2287
- const o = Object.keys(e).reduce((c, h) => (i.find((u) => u.name === h) || c.push(h), c), []), a = {};
2288
- return o.forEach((c) => a[c] = e[c]), Object.keys(a).forEach((c) => a[c] === null && delete a[c]), Object.keys(a).length > 0 ? `${s}${Ms(a)}` : s;
2289
- }, ft = (n, t) => {
2290
- let e = n;
2291
- return e.indexOf("?") > -1 && (e = e.substring(0, e.indexOf("?"))), e.indexOf(";") > -1 && (e = e.substring(0, e.indexOf(";"))), e === "" && (e = "/"), t.reduce((r, s) => {
2292
- if (Array.isArray(s.path))
2293
- return s.path.reduce((o, a) => zt(a, []).exec(e || "") && !o ? e : o, void 0) && !r ? s : r;
2294
- if (!s.path)
2295
- return r;
2296
- const i = [];
2297
- return zt(s.path, i).exec(e || "") && !r ? s : r;
2298
- }, void 0);
2299
- }, js = (n) => {
2300
- let t = n.get("historyTransitionManager");
2301
- return t || (t = xn(), n.parent && n.parent.register("historyTransitionManager", t)), t;
2302
- }, Et = (n, t = null) => n ? Qt(t ? t(n) : n) : {
2303
- pathname: "",
2304
- search: "",
2305
- hash: ""
2306
- }, _s = (n, t) => {
2307
- if (lt(n), lt(t), Object.keys(n).length !== Object.keys(t).length)
2308
- return !1;
2309
- if (Object.keys(n).length === 0 && Object.keys(t).length === 0)
2310
- return !0;
2311
- let e = !0;
2312
- return Object.keys(t).forEach((r) => {
2313
- t[r] !== n[r] && (e = !1);
2314
- }), e;
2315
- }, Is = (n) => {
2316
- if (typeof n.mode == "string") {
2317
- if (n.mode === K.memory)
2318
- return !0;
2319
- } else if (n.mode[1]) {
2320
- const [t, { sticky: e }] = n.mode;
2321
- if (t === K.memory)
2322
- return typeof e == "undefined" ? !0 : e;
2323
- }
2324
- return !1;
2325
- }, ce = (n) => {
2326
- const { views: t } = n.get("$settings"), e = Object.keys(t).reduce((r, s) => typeof t[s].path == "undefined" ? s : r, void 0);
2327
- return e ? {
2328
- name: e,
2329
- params: {}
2330
- } : null;
2331
- }, Ke = "hashchange", Rs = {
2332
- hashbang: {
2333
- encodePath: (n) => n.charAt(0) === "!" ? n : "!/" + pe(n),
2334
- decodePath: (n) => n.charAt(0) === "!" ? n.substr(1) : n
2335
- },
2336
- noslash: {
2337
- encodePath: pe,
2338
- decodePath: xt
2339
- },
2340
- slash: {
2341
- encodePath: xt,
2342
- decodePath: xt
2343
- }
2344
- }, st = () => {
2345
- const n = window.location.href, t = n.indexOf("#");
2346
- return t === -1 ? "" : n.substring(t + 1);
2347
- }, qe = (n) => window.location.hash = n, Ye = (n) => {
2348
- const t = window.location.href.indexOf("#");
2349
- window.location.replace(
2350
- window.location.href.slice(0, t >= 0 ? t : 0) + "#" + n
2351
- );
2352
- }, Rt = (n = "") => {
2353
- const t = n.replace(";", "?"), e = [
2354
- { from: /\;+/gi, to: "&" },
2355
- { from: /:+/gi, to: "=" }
2356
- ];
2357
- let r = t;
2358
- return e.forEach(({ to: s, from: i }) => {
2359
- r = r.replace(i, s);
2360
- }), r;
2361
- }, Ts = (n = {}) => {
2362
- const t = window.history, { getUserConfirmation: e = $n, hashType: r = "slash" } = n, s = n.basename ? Pn(xt(n.basename)) : "", { encodePath: i } = Rs[r], o = () => {
2363
- const m = st(), b = u(m);
2364
- return Et(b, Rt);
2365
- }, a = n.transitionManager || xn(), c = (m) => {
2366
- Object.assign(I, m), I.length = t.length, a.notifyListeners(I.location, I.action, n.widgetName);
2367
- };
2368
- let h = !1;
2369
- const u = (m) => {
2370
- const b = (w) => {
2371
- function P($, y) {
2372
- const O = {};
2373
- let L;
2374
- for (; L = y.exec($); )
2375
- O[L[1]] = L[2];
2376
- return O;
2377
- }
2378
- return P(w, /([^#?&=]+)=([^&#]*)(?!.*?\#)/gi) || null;
2379
- }, v = "humany-" + n.widgetName;
2380
- return b(m)[v];
2381
- }, l = () => {
2382
- const m = o(), b = I.location;
2383
- !h && Sn(b, m) || d(m);
2384
- }, d = (m) => {
2385
- if (h)
2386
- h = !1, c();
2387
- else {
2388
- const b = "POP";
2389
- a.confirmTransitionTo(
2390
- m,
2391
- b,
2392
- e,
2393
- (v) => {
2394
- v ? c({ action: b, location: m }) : f(m);
2395
- }
2396
- );
2397
- }
2398
- }, f = (m) => {
2399
- const b = I.location;
2400
- let v = p.lastIndexOf(rt(b));
2401
- v === -1 && (v = 0);
2402
- let w = p.lastIndexOf(rt(m));
2403
- w === -1 && (w = 0);
2404
- const P = v - w;
2405
- P && (h = !0, x(P));
2406
- }, g = st(), E = i(g);
2407
- g !== E && Ye(E);
2408
- let p = [];
2409
- const C = o();
2410
- C.pathname !== null && p.push(rt(C));
2411
- const T = (m = "") => {
2412
- const b = [
2413
- { from: /\?+/gi, to: ";" },
2414
- { from: /\&amp;+/gi, to: ";" },
2415
- { from: /\&+/gi, to: ";" },
2416
- { from: /=+/gi, to: ":" }
2417
- ];
2418
- let v = m;
2419
- return b.forEach(({ to: w, from: P }) => {
2420
- v = v.replace(P, w);
2421
- }), v;
2422
- }, U = (m, b, v) => {
2423
- let w = "", P = !1;
2424
- return m.split("&").forEach(($) => {
2425
- const y = $.split("="), O = y[0], L = y[1];
2426
- if (O === b) {
2427
- if (P = !0, v === null)
2428
- return;
2429
- w.length > 0 && (w += "&"), typeof v != "undefined" ? w += O + "=" + v : w += O;
2430
- } else
2431
- O && (w.length > 0 && (w += "&"), w += O + "=" + L);
2432
- }), !P && v !== null && (w.length > 0 && (w += "&"), typeof v != "undefined" ? w += b + "=" + v : w += b), w;
2433
- }, _ = (m) => {
2434
- const b = m.pathname, v = T(m.search), w = b + (v ? `;${v}` : ""), P = `humany-${n.widgetName}`, $ = st();
2435
- return `#${U($, P, w).replace(";;", ";")}`;
2436
- }, D = (m, b) => {
2437
- const v = "PUSH", w = Et(m, Rt), P = w.pathname, $ = T(w.search), y = P + ($ ? `${$}` : ""), O = `humany-${n.widgetName}`, L = st(), M = U(L, O, y);
2438
- a.confirmTransitionTo(w, v, e, (F) => {
2439
- if (!F)
2440
- return;
2441
- const J = rt(w), et = i(M);
2442
- if (st() !== et) {
2443
- qe(et);
2444
- const Y = p.lastIndexOf(rt(I.location)), W = p.slice(0, Y === -1 ? 0 : Y + 1);
2445
- W.push(J), p = W, c({ action: v, location: w });
2446
- } else
2447
- c();
2448
- });
2449
- }, H = (m, b) => {
2450
- const v = "REPLACE", w = Et(m, Rt);
2451
- a.confirmTransitionTo(w, v, e, (P) => {
2452
- if (!P)
2453
- return;
2454
- const $ = rt(w), y = i(s + $);
2455
- st() !== y && Ye(y);
2456
- const O = p.indexOf(rt(I.location));
2457
- O !== -1 && (p[O] = $), c({ action: v, location: w });
2458
- });
2459
- }, x = (m) => {
2460
- t.go(m);
2461
- }, N = () => x(-1), A = () => x(1);
2462
- let j = 0;
2463
- const B = (m) => {
2464
- j += m, j === 1 ? window.addEventListener(Ke, l) : j === 0 && window.removeEventListener(Ke, l);
2465
- };
2466
- let V = !1;
2467
- const I = {
2468
- createHref: _,
2469
- createLocation: Et,
2470
- push: D,
2471
- replace: H,
2472
- go: x,
2473
- goBack: N,
2474
- goForward: A,
2475
- block: (m = !1) => {
2476
- const b = a.setPrompt(m);
2477
- return V || (B(1), V = !0), () => (V && (V = !1, B(-1)), b());
2478
- },
2479
- listen: (m) => {
2480
- const b = a.appendListener(m);
2481
- return B(1), () => {
2482
- B(-1), b();
2483
- };
2484
- },
2485
- stop: () => {
2486
- const m = st(), b = U(m, `humany-${n.widgetName}`, null), v = i(b);
2487
- qe(v);
2488
- },
2489
- length: t.length,
2490
- action: "POP",
2491
- location: C
2492
- };
2493
- return I;
2494
- }, jn = Ts, Hs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2495
- __proto__: null,
2496
- decodeSearch: Rt,
2497
- default: jn,
2498
- getHashPath: st
2499
- }, Symbol.toStringTag, { value: "Module" })), Vs = (n, t) => {
2500
- const e = (s) => {
2501
- function i(o, a) {
2502
- const c = {};
2503
- let h;
2504
- for (; h = a.exec(o); )
2505
- c[h[1]] = h[2];
2506
- return c;
2507
- }
2508
- return i(s, /([^#?&=]+)=([^&#]*)(?!.*?\#)/gi) || null;
2509
- }, r = `humany-${t}`;
2510
- return e(n)[r];
2511
- }, Bs = () => {
2512
- const n = window.location.href, t = n.indexOf("#");
2513
- return t === -1 ? "" : n.substring(t + 1);
2514
- }, Us = (n = "") => {
2515
- const t = n.replace(";", "?"), e = [
2516
- { from: /\;+/gi, to: "&" },
2517
- { from: /:+/gi, to: "=" }
2518
- ];
2519
- let r = t;
2520
- return e.forEach(({ to: s, from: i }) => {
2521
- r = r.replace(i, s);
2522
- }), r;
2523
- }, Ws = (n, t = null) => n ? Qt(t ? t(n) : n) : {
2524
- pathname: "",
2525
- search: "",
2526
- hash: ""
2527
- }, _n = (n) => {
2528
- const t = Bs(), e = Vs(t, n);
2529
- return Ws(e, Us);
2530
- }, we = (n) => {
2531
- const { name: t } = n.get("$widget");
2532
- return !!_n(t).pathname;
2533
- };
2534
- fe((n) => {
2535
- n.createCommand("routing", (t) => (e) => {
2536
- const r = {
2537
- mode: e.mode
2538
- };
2539
- e.basePath && (r.basePath = e.basePath), t.container.register("routingSettings", r);
2540
- });
2541
- });
2542
- const Ge = "routeData";
2543
- class zs {
2544
- constructor(t, e) {
2545
- this.container = t, this.steps = [], this.historyListenSubscription = () => {
2546
- }, this.sticky = !1, this.storageWriter = null, this.widget = t.get("$widget");
2547
- const r = e, { routes: s } = r, i = as(r, ["routes"]);
2548
- this.settings = gt(gt({}, i), t.get("routingSettings")), this.sticky = Is(this.settings), this.storageMedium = this.sticky ? S.Local : S.Session, X(t, Ge, k.Necessary, {
2549
- medium: this.storageMedium
2550
- }).then((o) => this.storageWriter = o), this.routes = s;
2551
- }
2552
- initialize() {
2553
- return this.initialized = this.initialized || this.createHistory().then((t) => {
2554
- this.history = t, this.location = t.location, this.historyListenSubscription = t.listen(
2555
- (e, r, s) => this.handleLocationChange(e, s)
2556
- );
2557
- });
2558
- }
2559
- setMatch(t) {
2560
- if (this.match = t, this.location) {
2561
- const e = this.getRouteData(), r = {
2562
- routeData: e,
2563
- location: this.location
2564
- }, s = this.steps[0], i = e.name === (s == null ? void 0 : s.routeData.name), o = Ae(
2565
- e.params,
2566
- (s == null ? void 0 : s.routeData.params) || {}
2567
- );
2568
- (!i || !o) && (this.widget.events.dispatch("router:change", { next: r, previous: s }), this.steps.unshift(r), this.storageWriter && this.storageWriter(r.routeData), this.widget.events.dispatch("router:changed", { previous: s, current: r }));
2569
- }
2570
- }
2571
- onRouteChange(t) {
2572
- return this.widget.events.subscribe("router:change", t);
2573
- }
2574
- isSticky() {
2575
- return this.sticky;
2576
- }
2577
- /**
2578
- * Generate a formatted path from string
2579
- * @param routeName Name of route to generate path for
2580
- * @param params Optional: route params
2581
- */
2582
- generate(t, e = {}) {
2583
- const r = ae(t, this.routes);
2584
- if (!r || !this.history)
2585
- throw `No route found for ${t}`;
2586
- const s = It(e, r.path);
2587
- if (!s)
2588
- throw `Unable to generate path for "${t}".`;
2589
- const i = Et(s, this.settings.decodeSearch);
2590
- let o = this.history.createHref(i);
2591
- const { mode: a, basePath: c } = this.settings;
2592
- return a === "browser" && c && (o = o.replace(c, "")), o.charAt(0) !== "/" && (o = `/${o}`), o;
2593
- }
2594
- /**
2595
- * Navigate to path
2596
- * @param routeName Route to navigate to
2597
- * @param params Optional: route params
2598
- */
2599
- navigate(t, e = {}) {
2600
- const r = ae(t, this.routes);
2601
- if (!r || !this.history)
2602
- return;
2603
- const s = It(e, r.path);
2604
- if (!s)
2605
- return;
2606
- const i = this.getRouteData(), o = i && i.name === t && _s(i.params, e);
2607
- if (this.steps[0] && o)
2608
- return;
2609
- const { decodeSearch: a } = this.settings, c = a ? a(s) : s;
2610
- this.widget.events.dispatch("router:navigate", {
2611
- decodedPath: c
2612
- }), c.charAt(0) !== "/" ? this.history.push(`/${c}`) : this.history.push(c);
2613
- }
2614
- /**
2615
- * Return true or false depending
2616
- * on whether it is possible to navigate backwards
2617
- */
2618
- hasBack() {
2619
- if (this.steps.length > 1)
2620
- return !0;
2621
- const t = this.getRouteData(this.settings.initialPath), e = this.getRouteData(), r = e.name === t.name, s = Ae(e.params, t.params);
2622
- return !r || !s;
2623
- }
2624
- /**
2625
- * Navigate to previous route
2626
- */
2627
- goBack(t = 1) {
2628
- if (this.steps.length < 2) {
2629
- const e = this.getRouteData(this.settings.initialPath);
2630
- e && e.name && (this.navigate(e.name, e.params), this.steps = []);
2631
- } else {
2632
- const e = t >= this.steps.length ? this.steps.length - 1 : t, { routeData: r } = this.steps[e];
2633
- this.steps = [...this.steps.slice(e + 1)], this.navigate(r.name, Qn(r.params));
2634
- }
2635
- }
2636
- /**
2637
- * Navigate to next route
2638
- */
2639
- goForward() {
2640
- this.history && this.history.goForward();
2641
- }
2642
- /**
2643
- * Get the current location
2644
- */
2645
- current() {
2646
- return this.location;
2647
- }
2648
- /**
2649
- * Get the initial route. If the defined initial route does not exist,
2650
- * return the first defined route
2651
- */
2652
- getInitialRoute() {
2653
- const { name: t } = this.getRouteData(this.settings.initialPath);
2654
- return this.routes.find((r) => r.name === t) || (this.routes.length > 0 ? this.routes[0] : (process.env.NODE_ENV !== "production" && R.warn("Unable to get initial route as no routes are defined."), null));
2655
- }
2656
- getRouteData(t) {
2657
- const e = ce(this.container);
2658
- if (t) {
2659
- const r = ft(t, this.routes);
2660
- return r ? {
2661
- params: lt(Ot(t, r.path)),
2662
- name: r.name
2663
- } : e || {
2664
- name: "",
2665
- params: {}
2666
- };
2667
- }
2668
- if (this.location) {
2669
- const { pathname: r, search: s } = this.location;
2670
- if (this.currentRoute = this.currentRoute || ft(r, this.routes), this.currentRoute) {
2671
- const { path: i, name: o } = this.currentRoute;
2672
- this.match || (this.match = {
2673
- params: Ot(r, i),
2674
- isExact: !0,
2675
- path: i,
2676
- url: r
2677
- });
2678
- const a = lt(gt(gt({}, this.match.params), s.length > 0 && Dn(s)));
2679
- return {
2680
- name: o,
2681
- params: a
2682
- };
2683
- }
2684
- }
2685
- return e || {
2686
- name: "",
2687
- params: {}
2688
- };
2689
- }
2690
- dispose() {
2691
- return this.historyListenSubscription(), this.stop();
2692
- }
2693
- /**
2694
- * Setup and load the initial route based on router configuration
2695
- */
2696
- setupInitialRoute() {
2697
- return q(this.container, Ge, this.storageMedium).then(
2698
- (t) => {
2699
- if (!this.location || !this.history)
2700
- return;
2701
- const { initialPath: e, mode: r } = this.settings;
2702
- switch ((() => {
2703
- const s = we(this.container);
2704
- return r === K.browser || s ? ot.path : r === K.memory && t ? ot.storage : ot.initialPath;
2705
- })()) {
2706
- case ot.initialPath: {
2707
- const s = this.getRouteData(e);
2708
- return s && s.name ? this.navigate(s.name, s.params) : void 0;
2709
- }
2710
- case ot.path: {
2711
- const { pathname: s } = this.location;
2712
- if (this.currentRoute = ft(s, this.routes), this.currentRoute) {
2713
- const { path: o } = this.currentRoute;
2714
- return this.setMatch({
2715
- params: Ot(s, o),
2716
- isExact: !0,
2717
- path: o,
2718
- url: s
2719
- });
2720
- }
2721
- const i = ce(this.container);
2722
- return i ? this.setMatch({
2723
- params: {},
2724
- isExact: !0,
2725
- path: i.name,
2726
- url: s
2727
- }) : void 0;
2728
- }
2729
- case ot.storage: {
2730
- const { pathname: s } = this.location;
2731
- this.currentRoute = ft(s, this.routes);
2732
- const { name: i = "", params: o = {} } = t || {}, a = ae(i, this.routes);
2733
- if (a) {
2734
- const c = It(o, a.path);
2735
- if (c)
2736
- return this.history.push(c), this.location = wn(gt({}, this.location), { pathname: c }), this.currentRoute = ft(c, this.routes), this.setMatch({
2737
- params: o,
2738
- isExact: !0,
2739
- path: a.path,
2740
- url: c
2741
- });
2742
- }
2743
- return;
2744
- }
2745
- }
2746
- }
2747
- );
2748
- }
2749
- start() {
2750
- return this.setupInitialRoute();
2751
- }
2752
- stop() {
2753
- return this.history && (this.settings.mode === K.scopedHash && this.history.stop(), this.steps = [], this.storageWriter) ? this.storageWriter() : Promise.resolve();
2754
- }
2755
- handleLocationChange(t, e) {
2756
- const { pathname: r } = t, { mode: s } = this.settings;
2757
- if (r.indexOf("?") > -1 || r.indexOf(";") > -1 || s === K.scopedHash && e !== this.widget.name)
2758
- return;
2759
- this.location = t, this.currentRoute = ft(r, this.routes);
2760
- const i = ce(this.container);
2761
- if (this.currentRoute) {
2762
- const { path: o } = this.currentRoute;
2763
- this.setMatch({
2764
- params: Ot(r, o),
2765
- isExact: !0,
2766
- path: o,
2767
- url: r
2768
- });
2769
- } else
2770
- i && this.setMatch({
2771
- params: {},
2772
- isExact: !0,
2773
- path: i.name,
2774
- url: r
2775
- });
2776
- }
2777
- createHistory() {
2778
- return new Promise((t) => {
2779
- const { mode: e, basePath: r } = this.settings;
2780
- if (e === K.scopedHash) {
2781
- const s = this.widget.name, i = js(this.container);
2782
- return Promise.resolve().then(() => Hs).then((o) => {
2783
- const a = o.default({
2784
- widgetName: s,
2785
- transitionManager: i,
2786
- hashType: "noslash"
2787
- });
2788
- return t(a);
2789
- });
2790
- }
2791
- if (e === K.memory)
2792
- return t(Br());
2793
- if (e === K.browser)
2794
- return t(Hr({ basename: r }));
2795
- throw "RoutingService: History could not be created.";
2796
- });
2797
- }
2798
- }
2799
- const Fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2800
- __proto__: null,
2801
- HistoryMode: K,
2802
- RoutingService: zs,
2803
- createHashHistory: jn,
2804
- getScopedHashDOMLocation: _n,
2805
- matchParams: Ot,
2806
- onWidgetUrl: we
2807
- }, Symbol.toStringTag, { value: "Module" })), he = (n, t, e, ...r) => {
2808
- const s = `[${n.get("$environment").name || "webprovisions"}] ${e}`;
2809
- switch (t) {
2810
- case "info":
2811
- console.info(s, ...r);
2812
- break;
2813
- case "warning":
2814
- console.warn(s, ...r);
2815
- break;
2816
- case "error":
2817
- console.error(s, ...r);
2818
- break;
2819
- }
2820
- }, Js = (n) => {
2821
- const t = n.container || n;
2822
- return {
2823
- info: (e, ...r) => he(t, "info", e, ...r),
2824
- warn: (e, ...r) => he(t, "warning", e, ...r),
2825
- error: (e, ...r) => he(t, "error", e, ...r)
2826
- };
2827
- };
2828
- var $t = /* @__PURE__ */ ((n) => (n.Implementation = "implementation", n.Widget = "widget", n))($t || {}), it = /* @__PURE__ */ ((n) => (n.Pre = "pre", n.Post = "post", n))(it || {});
2829
- const Ks = (n, t, e, r) => {
2830
- try {
2831
- const s = new t(e, r);
2832
- return {
2833
- name: n,
2834
- invoke: (i, o) => {
2835
- let a;
2836
- return s[i] && (a = s[i].call(s, o)), Promise.resolve(a);
2837
- },
2838
- getInstance: () => s
2839
- };
2840
- } catch (s) {
2841
- if (s.message && s.message.indexOf("is not a constructor") >= 0)
2842
- return {
2843
- name: n,
2844
- invoke: (i) => {
2845
- let o;
2846
- return i === "initialize" && (o = t(e, r)), Promise.resolve(o);
2847
- },
2848
- getInstance: () => t
2849
- };
2850
- throw s;
2851
- }
2852
- };
2853
- function Qe(n, t) {
2854
- return typeof n == "undefined" ? t : n;
2855
- }
2856
- class qs {
2857
- constructor(t = {}) {
2858
- this.part = t;
2859
- }
2860
- createCommand(t, e, r) {
2861
- let s;
2862
- typeof e == "function" ? s = {
2863
- scope: $t.Widget,
2864
- stage: it.Post,
2865
- defaultArgs: void 0,
2866
- handlerResolver: e
2867
- } : s = {
2868
- scope: Qe(e.scope, $t.Widget),
2869
- stage: Qe(e.stage, it.Post),
2870
- defaultArgs: e.defaultArgs,
2871
- handlerResolver: r
2872
- };
2873
- let i = this.part;
2874
- const o = t.split(".");
2875
- return o.forEach((a, c) => {
2876
- c === o.length - 1 ? i[a] || (i[a] = () => s) : i = this.part[a] = this.part[a] || {};
2877
- }), this;
2878
- }
2879
- get() {
2880
- return this.part;
2881
- }
2882
- }
2883
- const In = (n) => {
2884
- const t = new qs({});
2885
- return n(t), t.get();
2886
- };
2887
- In((n) => {
2888
- n.createCommand(
2889
- "types.register",
2890
- { scope: $t.Implementation, stage: it.Pre },
2891
- (t) => (e, r) => {
2892
- t.container.get("$types")[e] = r;
2893
- }
2894
- ).createCommand(
2895
- "type",
2896
- { stage: it.Pre },
2897
- (t) => (e) => {
2898
- t.container.register("$type", e);
2899
- }
2900
- ).createCommand(
2901
- "settings",
2902
- { stage: it.Pre, defaultArgs: [null] },
2903
- (t) => (e) => {
2904
- t.events.dispatch(
2905
- "settings:change",
2906
- e,
2907
- { bubbles: !0 }
2908
- ), t.container.register("$settings", e);
2909
- }
2910
- ).createCommand(
2911
- "plugin",
2912
- { stage: it.Pre },
2913
- (t) => (e, r, s) => {
2914
- const { container: i } = t;
2915
- let o = null, a = e, c = r;
2916
- typeof e == "string" && (o = e, a = r, c = s);
2917
- const h = (u) => {
2918
- const { transformPluginSettings: l } = t.container.get("$environmentOptions"), d = l ? l(
2919
- c || {},
2920
- o,
2921
- t.container,
2922
- a
2923
- ) : r;
2924
- try {
2925
- const f = Ks(
2926
- o,
2927
- a,
2928
- i,
2929
- d
2930
- );
2931
- i.get("$plugins").push(f), u && f.invoke("initialize", null);
2932
- } catch (f) {
2933
- Js(t).warn("Error when initializing plugin", f);
2934
- }
2935
- };
2936
- t.container.get("$instance") ? h(!0) : t.events.subscribeOnce("widget:instance-created", () => h(!1));
2937
- }
2938
- ).createCommand(
2939
- "container.register",
2940
- (t) => (e, r) => {
2941
- t.container.register(e, r);
2942
- }
2943
- ).createCommand(
2944
- "container.registerAsync",
2945
- (t) => (e, r) => {
2946
- t.container.registerAsync(e, r);
2947
- }
2948
- ).createCommand(
2949
- "container.registerFactory",
2950
- (t) => (e, r) => {
2951
- t.container.registerFactory(e, r);
2952
- }
2953
- ).createCommand(
2954
- "container.touch",
2955
- (t) => (e, r) => {
2956
- t.container.touch(e, r);
2957
- }
2958
- ).createCommand(
2959
- "csp",
2960
- {},
2961
- (t) => (e) => {
2962
- t.container.register("csp", e);
2963
- }
2964
- );
2965
- });
2966
- function Ys(n) {
2967
- const t = {};
2968
- return [].filter.call(n.attributes, (e) => /^data-/.test(e.name)).map((e) => e.name).forEach((e) => t[e.substr(5)] = n.getAttribute(e)), t;
2969
- }
2970
- const Ze = (n, t, e) => {
2971
- const r = Ys(n);
2972
- e({
2973
- sourceDOMElement: n,
2974
- eventType: t,
2975
- data: r
2976
- });
2977
- };
2978
- function Xe(n, t, e) {
2979
- n.forEach((r) => {
2980
- r.dataset.attached !== "true" && (t === "load" ? Ze(r, t, e) : r.addEventListener(t, (s) => {
2981
- s.preventDefault(), Ze(r, t, e);
2982
- }), r.dataset.monitored = "true");
2983
- });
2984
- }
2985
- function Gs(n, t, e) {
2986
- const r = n.container.get("bootstrapping.monitor");
2987
- r && r.events.subscribe("bootstrap:trigger-elements-updated", (i, o) => {
2988
- Xe(
2989
- o.triggerElements,
2990
- t,
2991
- e
2992
- );
2993
- });
2994
- const s = n.container.get("triggerElements");
2995
- s && Xe(
2996
- s,
2997
- t,
2998
- e
2999
- );
3000
- }
3001
- In((n) => {
3002
- n.createCommand(
3003
- "ready",
3004
- { scope: $t.Implementation, stage: it.Pre },
3005
- (t) => (e) => {
3006
- const { container: r } = t, s = r.owner;
3007
- r.get("bootstrapping").ready ? e(s) : s.events.subscribeOnce("bootstrap:ready", () => {
3008
- e(s);
3009
- });
3010
- }
3011
- );
3012
- });
3013
- const Qs = (n) => {
3014
- if (n) {
3015
- const { type: t, content: e } = n;
3016
- switch (t) {
3017
- case "FontAwesome":
3018
- return `<i class="humany-icon fa fa-${e}"></i>`;
3019
- case "Uri":
3020
- return `<i class="humany-icon humany-custom-icon" style="background: url(${e}) no-repeat center center;background-size: contain;"></i>`;
3021
- default:
3022
- return "";
3023
- }
3024
- }
3025
- }, Zs = (n) => {
3026
- const t = (s, i) => {
3027
- s && (i ? s.classList.add("humany-tabbing") : s.classList.remove("humany-tabbing"));
3028
- }, e = (s) => {
3029
- s.key === "Tab" ? t(n, !0) : s.key === "Enter" && document.activeElement && document.activeElement.classList.contains("humany-trigger") || t(n, !1);
3030
- }, r = (s) => {
3031
- document.activeElement && document.activeElement.classList.contains("humany-trigger") && document.activeElement.classList.contains("humany-tabbing") || t(n, !1);
3032
- };
3033
- return document.addEventListener("keydown", e), document.addEventListener("click", r), () => {
3034
- document.removeEventListener("keydown", e), document.removeEventListener("click", r);
3035
- };
3036
- };
3037
- function Xs(n, t) {
3038
- const {
3039
- symbol: e,
3040
- widgetName: r,
3041
- label: s = "",
3042
- ariaLabel: i = "",
3043
- tooltip: o = ""
3044
- } = t;
3045
- n.classList.add("humany-trigger"), n.classList.add(`humany_${r}`), s.length && n.classList.add("humany-has-text"), i.length && !n.getAttribute("aria-label") && n.setAttribute("aria-label", i), i.length && !n.getAttribute("tabindex") && n.setAttribute("tabindex", "0"), o.length && !n.getAttribute("title") && n.setAttribute("title", o);
3046
- const a = Qs(e) || "";
3047
- return n.innerHTML = `${a}
3048
- <span class="humany-close">
3049
- <svg width="18" height="9" viewBox="0 0 18 9" fill="none" xmlns="http://www.w3.org/2000/svg">
3050
- <path d="M9 9C8.81794 9.00045 8.63759 8.96634 8.46939 8.89965C8.3012 8.83295 8.14851 8.735 8.02015 8.61145L0.194523 1.12367C0.068294 0.99862 -0.00155266 0.831133 2.61958e-05 0.657285C0.00160506 0.483436 0.0744832 0.317136 0.202964 0.194202C0.331445 0.0712675 0.505249 0.00153576 0.686941 2.50649e-05C0.868634 -0.00148563 1.04368 0.0653456 1.17437 0.186125L9 7.6739L16.8256 0.186125C16.9563 0.0653456 17.1314 -0.00148563 17.3131 2.50649e-05C17.4948 0.00153576 17.6686 0.0712675 17.797 0.194202C17.9255 0.317136 17.9984 0.483436 18 0.657285C18.0016 0.831133 17.9317 0.99862 17.8055 1.12367L9.97985 8.61145C9.85149 8.735 9.6988 8.83295 9.53061 8.89965C9.36241 8.96634 9.18206 9.00045 9 9Z" fill="white"/>
3051
- </svg>
3052
- </span>
3053
- <span class="humany-loader">
3054
- <svg viewBox="25 25 50 50">
3055
- <circle
3056
- cx="50"
3057
- cy="50"
3058
- r="20"
3059
- fill="none"
3060
- stroke="#000"
3061
- stroke-width="2"
3062
- stroke-miterlimit="10" />
3063
- </svg>
3064
- </span>
3065
- ${s.length ? `<span>${s}</span>` : ""}`, setTimeout(
3066
- () => n && n.classList.add("humany-rendered")
3067
- ), Zs(n);
3068
- }
3069
- function ti(n, t) {
3070
- n instanceof HTMLElement ? (t && n.setAttribute("title", t), n.classList.remove("humany-active"), n.classList.remove("humany-loading")) : n instanceof Array && n.forEach((e) => {
3071
- t && e.setAttribute("title", t), e.classList.remove("humany-active"), e.classList.remove("humany-loading");
3072
- });
3073
- }
3074
- function ei(n) {
3075
- n instanceof HTMLElement ? (n.classList.remove("humany-active"), n.classList.add("humany-loading")) : n instanceof Array && n.forEach((t) => {
3076
- t.classList.remove("humany-active"), t.classList.add("humany-loading");
3077
- });
3078
- }
3079
- function Rn(n, t) {
3080
- n instanceof HTMLElement ? (t && n.setAttribute("title", t), n.classList.add("humany-active"), n.classList.remove("humany-loading")) : n instanceof Array && n.forEach((e) => {
3081
- t && e.setAttribute("title", t), e.classList.add("humany-active"), e.classList.remove("humany-loading");
3082
- });
3083
- }
3084
- var ut = /* @__PURE__ */ ((n) => (n.Inline = "inline", n.Link = "link", n.Badge = "badge", n.Unsupported = "unsupported", n))(ut || {});
3085
- const ni = (n, t) => n && t ? "both" : n ? "widgetDOM" : t ? "triggerDOM" : "none", Tn = (n) => n ? typeof n == "boolean" && n ? "link" : typeof n == "object" && !Array.isArray(n) ? "badge" : "unsupported" : "inline", ri = (n, t, e, r, s = !1) => {
3086
- var h, u;
3087
- const i = ni(
3088
- t,
3089
- e
3090
- ), o = Tn(r), a = {
3091
- widgetDOMElement: t ? t.cloneNode(!0) : void 0,
3092
- triggerDOMElement: e ? e.cloneNode(!0) : void 0
3093
- }, c = {
3094
- triggerType: o,
3095
- cachedOriginals: a,
3096
- widgetDOMElement: document.createElement("div")
3097
- };
3098
- switch (i) {
3099
- case "both": {
3100
- c.widgetDOMElement = t || document.createElement("div"), o !== "inline" && (c.triggerDOMElement = e);
3101
- break;
3102
- }
3103
- case "widgetDOM": {
3104
- if (c.widgetDOMElement = t || document.createElement("div"), o !== "inline") {
3105
- const l = document.body.appendChild(document.createElement("a"));
3106
- o === "link" && (l.innerText = n), c.triggerDOMElement = l;
3107
- }
3108
- break;
3109
- }
3110
- case "triggerDOM": {
3111
- const l = document.createElement("div");
3112
- c.widgetDOMElement = l, o === "inline" ? (l.id = (e == null ? void 0 : e.id) || "", s ? (l.style.display = "none", (h = e == null ? void 0 : e.parentNode) == null || h.appendChild(l), c.callback = () => {
3113
- var d;
3114
- (d = e == null ? void 0 : e.parentNode) == null || d.replaceChild(
3115
- l,
3116
- e
3117
- ), l.style.display = (e == null ? void 0 : e.style.display) || "block";
3118
- }) : (u = e == null ? void 0 : e.parentNode) == null || u.replaceChild(
3119
- l,
3120
- e
3121
- ), c.cachedOriginals.widgetDOMElement = e, c.cachedOriginals.triggerDOMElement = void 0) : (c.widgetDOMElement = document.body.appendChild(l), c.triggerDOMElement = e);
3122
- break;
3123
- }
3124
- case "none": {
3125
- const l = document.body.appendChild(document.createElement("div"));
3126
- if (c.widgetDOMElement = l, o !== "inline") {
3127
- const d = document.body.appendChild(document.createElement("a"));
3128
- o === "link" && (d.innerText = n), c.triggerDOMElement = d;
3129
- }
3130
- break;
3131
- }
3132
- }
3133
- return c;
3134
- }, si = "modals";
3135
- class ii {
3136
- constructor(t, e) {
3137
- this.options = e, this.unsubscribe = [], this.container = t.createChild(this), this.container.register("widgetDOMElement", this.options.widgetDOMElement), this.container.register(
3138
- "triggerDOMElement",
3139
- this.options.triggerDOMElement
3140
- );
3141
- const r = this.container.get("$widget");
3142
- this.options.widgetDOMElement.classList.add("humany-widget"), this.options.widgetDOMElement.classList.add(`humany_${r.name}`);
3143
- const s = t.get("widgetDOMElements") || [];
3144
- t.register("widgetDOMElements", [
3145
- ...s,
3146
- this.options.widgetDOMElement
3147
- ]);
3148
- }
3149
- /**
3150
- * Renders the view outlet to the DOM.
3151
- */
3152
- render() {
3153
- const { widgetDOMElement: t, triggerDOMElement: e } = this.options, r = this.container.get("$widget");
3154
- return t.getAttribute("data-rendered") === "true" ? Promise.resolve() : (e && this.options.triggerType === ut.Badge && ei(e), import("./render-301f6791.js").then((s) => s.default(this.container, t)).then(() => {
3155
- if (t.setAttribute("data-rendered", "true"), e && this.options.triggerType === ut.Badge) {
3156
- const i = this.options.triggerOptions.openTooltip;
3157
- Rn(e, i);
3158
- }
3159
- nr(this.container, t);
3160
- const s = this.container.get("$environment").widgets.all();
3161
- q(
3162
- this.container,
3163
- si,
3164
- S.Session
3165
- ).then((i) => {
3166
- i && i.forEach((o) => {
3167
- s.find(
3168
- (a) => a.name === o.name && a.state === "activated"
3169
- ) && r.events.dispatch("widget:modal-opened", o);
3170
- });
3171
- });
3172
- }));
3173
- }
3174
- renderBadge(t) {
3175
- const { triggerDOMElement: e } = this.options;
3176
- if (!e)
3177
- return;
3178
- e.getAttribute("role") || e.setAttribute("role", "button");
3179
- const { name: r } = this.container.get("$widget"), { label: s, symbol: i, ariaLabel: o, closedTooltip: a, openTooltip: c } = t, h = { closedTooltip: a, openTooltip: c };
3180
- this.options.triggerOptions = h;
3181
- const u = Xs(e, {
3182
- label: s,
3183
- symbol: i,
3184
- ariaLabel: o,
3185
- widgetName: r,
3186
- tooltip: a
3187
- });
3188
- this.unsubscribe.push(u);
3189
- }
3190
- dispose() {
3191
- return Zt(this, null, function* () {
3192
- var r, s, i, o;
3193
- const { triggerDOMElement: t, widgetDOMElement: e } = this.options;
3194
- this.options.cachedOriginals.widgetDOMElement && e && ((r = e.parentNode) == null || r.replaceChild(
3195
- this.options.cachedOriginals.widgetDOMElement,
3196
- e
3197
- )), this.options.cachedOriginals.triggerDOMElement && t && ((s = t.parentNode) == null || s.replaceChild(
3198
- this.options.cachedOriginals.triggerDOMElement,
3199
- t
3200
- )), this.unsubscribe.forEach((a) => {
3201
- a();
3202
- }), (i = e.parentNode) == null || i.removeChild(e), (o = t == null ? void 0 : t.parentNode) == null || o.removeChild(t);
3203
- });
3204
- }
3205
- }
3206
- const Nt = "changesets", oi = (n) => {
3207
- const t = { tags: n.tags };
3208
- return n.context && typeof n.context != "function" && (t.context = n.context), n.properties && typeof n.properties != "function" && (t.properties = n.properties), n.layout && typeof n.layout != "function" && (t.layout = n.layout), t;
3209
- };
3210
- class Oe {
3211
- constructor(t, e) {
3212
- this.container = t, this.storageWriter = e;
3213
- }
3214
- static create(t) {
3215
- return X(
3216
- t,
3217
- Nt,
3218
- k.Necessary,
3219
- {
3220
- medium: S.Local
3221
- }
3222
- ).then(
3223
- (e) => new Oe(t, e)
3224
- );
3225
- }
3226
- write(t, e, r, s) {
3227
- return G(this)(() => q(
3228
- this.container,
3229
- Nt,
3230
- S.Local
3231
- ).then((i = {}) => {
3232
- const { keys: o = [], items: a = {} } = i, c = o.indexOf(t);
3233
- return c > -1 && o.splice(c, 1), o.push(t), a[t] = {
3234
- options: s,
3235
- attributes: oi(r),
3236
- rules: e.rules
3237
- }, this.storageWriter({ keys: o, items: a });
3238
- }));
3239
- }
3240
- remove(t) {
3241
- return G(this)(() => q(
3242
- this.container,
3243
- Nt,
3244
- S.Local
3245
- ).then((e = {}) => {
3246
- const { keys: r = [], items: s = {} } = e, i = r.indexOf(t);
3247
- if (i > -1)
3248
- return r.splice(i, 1), delete s[t], this.storageWriter(e);
3249
- }));
3250
- }
3251
- load(t) {
3252
- return G(this)(() => q(
3253
- this.container,
3254
- Nt,
3255
- S.Local
3256
- ).then((e = {}) => {
3257
- const { keys: r = [], items: s = {} } = e;
3258
- r.forEach((i) => {
3259
- const o = s[i];
3260
- if (o) {
3261
- const { rules: a, attributes: c, options: h } = o;
3262
- t.write({
3263
- attributes: c,
3264
- options: h,
3265
- target: new yt(t, a)
3266
- });
3267
- }
3268
- });
3269
- }));
3270
- }
3271
- }
3272
- const ai = (n) => {
3273
- const { container: t } = n;
3274
- return Oe.create(t).then(
3275
- (e) => {
3276
- const r = t.get("$settings"), s = { localStorage: e }, i = new qt(n, s), o = cn(i, r);
3277
- return n.events.subscribe(
3278
- "widget:state-change",
3279
- (a, c) => {
3280
- c.state === nn.Deactivating && o();
3281
- }
3282
- ), i;
3283
- }
3284
- );
3285
- }, ci = (n) => Promise.resolve().then(() => Fs).then(
3286
- ({ RoutingService: t, HistoryMode: e }) => n.get("settings").then((r) => {
3287
- const {
3288
- routing: {
3289
- initialPath: s = "/",
3290
- mode: i = e.scopedHash,
3291
- basePath: o
3292
- },
3293
- views: a
3294
- } = r;
3295
- return new t(n, {
3296
- initialPath: s,
3297
- mode: i,
3298
- routes: Object.keys(a).map((h) => ({
3299
- name: h,
3300
- path: a[h].path
3301
- })),
3302
- basePath: o
3303
- });
3304
- })
3305
- ), hi = (n) => Promise.resolve().then(() => rs).then(({ StorageProvider: t }) => new t()), ui = (n) => Promise.resolve().then(() => me).then(({ ActionResolver: t }) => new t(n)), li = (n) => Promise.resolve().then(() => me).then(({ ComponentResolver: t }) => new t(n)), di = (n) => Promise.resolve().then(() => me).then(() => ai(n.get("$widget"))), ue = "$settings", Lt = "open", tn = "activeStickyWidget";
3306
- class Ai extends Kn {
3307
- constructor(t) {
3308
- super(t), this.outlets = /* @__PURE__ */ new Map(), this.activated = void 0, this.subs = [], this.handleBootstrapping = (e) => {
3309
- const r = {
3310
- triggerDOMElement: e.sourceDOMElement,
3311
- withRenderState: "storage"
3312
- /* Storage */
3313
- };
3314
- this.container.get("settings").then((s) => {
3315
- const { activate: i } = s;
3316
- (typeof i == "undefined" || i === null || i === !0) && (this.activated = (this.activated || this.widget.activate()).then(
3317
- () => this.attach(r)
3318
- ));
3319
- });
3320
- }, this.container.registerAsync(
3321
- "storage",
3322
- () => hi(this.container)
3323
- ), this.container.registerFactory("settings", () => q(
3324
- this.container,
3325
- ue,
3326
- S.Local
3327
- ).then((e = {}) => dt(dt({}, this.container.get("$settings")), e))), Gs(this, "load", this.handleBootstrapping), this.container.registerAsync(
3328
- "componentResolver",
3329
- () => li(this.container)
3330
- ), this.container.registerAsync(
3331
- "router",
3332
- () => ci(this.container)
3333
- ), this.container.registerAsync(
3334
- "actionResolver",
3335
- () => ui(this.container)
3336
- ), this.container.register("matchMedia", window.matchMedia), this.container.registerAsync(
3337
- "components",
3338
- () => di(this.container)
3339
- );
3340
- }
3341
- initialize() {
3342
- const t = this.container.getManyAsync(
3343
- "actionResolver",
3344
- "router",
3345
- "components"
3346
- ), e = this.container.get("csp");
3347
- return e && (window.webprovisionsEnvironmentVariables || (window.webprovisionsEnvironmentVariables = {}), window.webprovisionsEnvironmentVariables.cspNonce = e.nonce), Promise.all([t, this.container.get("settings")]).then(
3348
- ([{ actionResolver: r, router: s, components: i }, o]) => {
3349
- var h;
3350
- r.subscribe(
3351
- this.widget.name,
3352
- (u, l, d) => this.onAction(l, d)
3353
- );
3354
- const a = (u) => {
3355
- i.nodes.query({ type: "view" }).forEach((l) => {
3356
- i.setSwitch(l, u);
3357
- });
3358
- }, c = ((h = s.getInitialRoute()) == null ? void 0 : h.name) || "index";
3359
- return a(c), this.events.subscribe("widget:data-loaded", (u, { element: l }) => {
3360
- this.widget.container.get("seoConfiguration") && this.events.dispatch("widget:preloaded-replaced", {
3361
- element: l
3362
- });
3363
- }), this.events.subscribe(
3364
- "router:change",
3365
- (u, { previous: l = { routeData: {} }, next: d = { routeData: {} } }) => {
3366
- const { routeData: f } = l, { routeData: g } = d, E = Object.keys(o.views).reduce(
3367
- (p, C) => typeof o.views[C].path == "undefined" ? C : p,
3368
- ""
3369
- );
3370
- !g.name && E ? a(E) : a(g.name), lt(f && f.params), lt(g && g.params), this.container.getAsync("actionResolver").then((p) => {
3371
- p.action(this.widget.name, "routeChange", {
3372
- next: g,
3373
- previous: f
3374
- });
3375
- });
3376
- }
3377
- ), s.initialize();
3378
- }
3379
- );
3380
- }
3381
- attach(t = {}) {
3382
- return this.container.get("settings").then(({ trigger: e }) => {
3383
- var d, f;
3384
- const {
3385
- widgetDOMElement: r,
3386
- key: s = Pt(),
3387
- triggerDOMElement: i,
3388
- withRenderState: o
3389
- } = t, c = Tn(e) === ut.Inline && ((i == null ? void 0 : i.childElementCount) || 0) > 0, h = ri(
3390
- this.widget.name,
3391
- r,
3392
- i,
3393
- e,
3394
- c
3395
- );
3396
- this.outlets.size < 1 && !o && this.setRenderState("unset");
3397
- const u = () => {
3398
- const g = () => E.querySelectorAll("[data-loading=true]").length === 0, [E] = this.widget.container.get("widgetDOMElements"), p = (U, _) => {
3399
- g() && (h.callback && h.callback(), _.disconnect());
3400
- }, C = {
3401
- attributes: !0,
3402
- subtree: !0,
3403
- childList: !0
3404
- };
3405
- g() && h.callback && h.callback(), new MutationObserver(p).observe(E, C);
3406
- };
3407
- c && this.widget.container.getAsync("dataClient").then(({ events: g }) => {
3408
- g.subscribe(
3409
- "data-client:fetched",
3410
- (E, p) => {
3411
- p.unresolvedQueries === 0 && u();
3412
- }
3413
- );
3414
- });
3415
- const l = this.getOrCreateViewOutlet(s, h);
3416
- if (this.outlets.set(s, l), this.widget.events.dispatch("widget:attached", {}, { bubbles: !0 }), h.triggerType === ut.Badge && e && ((d = h.triggerDOMElement) == null || d.setAttribute(
3417
- "aria-expanded",
3418
- "false"
3419
- ), l == null || l.renderBadge(e)), h.triggerType !== ut.Inline && ((f = h.triggerDOMElement) == null || f.addEventListener(
3420
- "click",
3421
- (g) => {
3422
- g.preventDefault(), this.container.get("settings").then(({ trigger: E }) => {
3423
- l.render().then(() => this.renderState()).then((p) => E && E.action && E.action === "hide" ? p === z.open ? this.hide() : this.open() : p === z.open ? this.close() : this.open());
3424
- });
3425
- }
3426
- )), this.outlets.size > 1)
3427
- return this.renderState().then((g) => {
3428
- this.triggerStateIfApplicable(g);
3429
- });
3430
- if (o)
3431
- return o === "storage" ? this.renderState().then((g) => {
3432
- if (h.triggerType === ut.Inline) {
3433
- this.triggerStateIfApplicable("open");
3434
- return;
3435
- }
3436
- this.triggerStateIfApplicable(g);
3437
- }) : this.triggerStateIfApplicable(o);
3438
- });
3439
- }
3440
- detach(t) {
3441
- if (t) {
3442
- if (this.outlets.has(t)) {
3443
- const e = this.outlets.get(t);
3444
- e == null || e.dispose(), this.outlets.delete(t);
3445
- return;
3446
- }
3447
- process.env.NODE_ENV !== "production" && console.warn(`detach(): Could not find View Outlet with key ${t}`);
3448
- return;
3449
- }
3450
- this.outlets.forEach((e) => {
3451
- e.dispose();
3452
- }), this.outlets.clear();
3453
- }
3454
- triggerStateIfApplicable(t) {
3455
- return this.container.getAsync("router").then((e) => {
3456
- switch (t) {
3457
- case "closed":
3458
- this.close();
3459
- break;
3460
- case "open":
3461
- this.open();
3462
- break;
3463
- case "hidden":
3464
- this.hide(), e.start();
3465
- break;
3466
- default:
3467
- return;
3468
- }
3469
- });
3470
- }
3471
- getOrCreateViewOutlet(t, e) {
3472
- return this.outlets.has(t) ? this.outlets.get(t) : new ii(this.container, e);
3473
- }
3474
- render(t = {}) {
3475
- if (process.env.NODE_ENV !== "production" && console.warn(
3476
- "widget.render() is deprecated. Use widget.attach() instead."
3477
- ), t.open) {
3478
- const e = Pe(dt({}, t), {
3479
- withRenderState: "open"
3480
- /* Open */
3481
- });
3482
- return this.attach(e);
3483
- }
3484
- return this.attach(t);
3485
- }
3486
- activate(t) {
3487
- t != null && t.override && this.setSettings(() => t.override), t != null && t.apiNotificationPriorityBy && this.container.register(
3488
- "apiNotificationPriorityBy",
3489
- t.apiNotificationPriorityBy
3490
- );
3491
- }
3492
- setSettings(t) {
3493
- return Promise.all([
3494
- this.container.get("settings"),
3495
- X(
3496
- this.container,
3497
- ue,
3498
- k.Necessary,
3499
- {
3500
- medium: S.Local
3501
- }
3502
- )
3503
- ]).then(([e, r]) => Promise.resolve(t(e)).then((s) => r(s).then(() => {
3504
- const i = dt(dt({}, e), s);
3505
- return this.widget.events.dispatch("widget:settings-updated", i), i;
3506
- })));
3507
- }
3508
- clearSettings() {
3509
- return X(
3510
- this.container,
3511
- ue,
3512
- k.Necessary,
3513
- { medium: S.Local }
3514
- ).then((t) => t()).then(() => this.container.get("settings")).then((t) => {
3515
- this.widget.events.dispatch("widget:settings-updated", t);
3516
- });
3517
- }
3518
- action({ action: t, value: e }) {
3519
- return this.container.getAsync("actionResolver").then((r) => {
3520
- r.action(this.widget.name, t, e);
3521
- });
3522
- }
3523
- renderState() {
3524
- if (we(this.container))
3525
- return Promise.resolve(z.open);
3526
- const t = () => q(
3527
- this.container,
3528
- Lt,
3529
- S.Session
3530
- ).then((r = z.closed) => r), e = () => q(
3531
- this.container,
3532
- Lt,
3533
- S.Session
3534
- ).then((r = z.closed) => r);
3535
- return this.container.getAsync("router").then((r) => r.isSticky() ? e().then((s) => s === z.open ? s : t()) : t());
3536
- }
3537
- hide() {
3538
- return this.outlets.size < 1 ? (process.env.NODE_ENV !== "production" && console.warn(
3539
- "hide(): No-op as no view outlets are registered. Invoke the attach() command first."
3540
- ), Promise.resolve()) : (this.outlets.forEach((t) => t.render()), this.action({ action: "hide" }).then(() => {
3541
- this.setTriggerState(!1);
3542
- }));
3543
- }
3544
- open() {
3545
- return this.outlets.size < 1 ? (process.env.NODE_ENV !== "production" && console.warn(
3546
- "open(): No-op as no view outlets are registered. Invoke the attach() command first."
3547
- ), Promise.resolve()) : (this.outlets.forEach((t) => t.render()), this.action({ action: "open" }).then(() => (this.widget.events.dispatch("tracking:widget-rendered", {}), this.onOpen())));
3548
- }
3549
- close() {
3550
- return this.outlets.size < 1 ? (process.env.NODE_ENV !== "production" && console.warn(
3551
- "close(): No-op as no view outlets are registered. Invoke the attach() command first."
3552
- ), Promise.resolve()) : this.action({ action: "close" }).then(() => this.onClose());
3553
- }
3554
- show() {
3555
- return process.env.NODE_ENV !== "production" && console.warn(
3556
- "show(): Command is deprecated and will be removed in the future. Use open() instead."
3557
- ), this.open();
3558
- }
3559
- onAction(t, e) {
3560
- switch (t) {
3561
- case "close":
3562
- case "open":
3563
- case "hide":
3564
- const r = t === "open" ? z.open : t === "close" ? z.closed : z.hidden;
3565
- return this.setRenderState(r).then(() => {
3566
- this.setTriggerState(r === z.open), r !== z.hidden ? r === z.open ? this.onOpen() : this.onClose() : this.outlets.forEach(
3567
- (s) => {
3568
- var i;
3569
- return (i = s.options.triggerDOMElement) == null ? void 0 : i.setAttribute(
3570
- "aria-expanded",
3571
- "false"
3572
- );
3573
- }
3574
- );
3575
- });
3576
- }
3577
- }
3578
- setRenderState(t) {
3579
- const { invoke: e, events: r } = this.container.get("$widget");
3580
- return Promise.all([
3581
- X(
3582
- this.container,
3583
- Lt,
3584
- k.Necessary,
3585
- {
3586
- medium: S.Session
3587
- }
3588
- ),
3589
- X(
3590
- this.container,
3591
- Lt,
3592
- k.Necessary,
3593
- {
3594
- medium: S.Local,
3595
- duration: { minutes: 5 }
3596
- }
3597
- ),
3598
- this.container.getAsync("router"),
3599
- e("renderState")
3600
- ]).then(
3601
- ([s, i, o, a]) => {
3602
- t === "unset" || !t ? (i(), s()) : (o.isSticky() && i(t), s(t)), r.dispatch("widget:render-state-changed", {
3603
- previous: a,
3604
- next: t
3605
- });
3606
- }
3607
- );
3608
- }
3609
- onOpen() {
3610
- return this.container.getAsync("router").then((t) => (this.outlets.forEach(
3611
- (e) => {
3612
- var r;
3613
- return (r = e.options.triggerDOMElement) == null ? void 0 : r.setAttribute(
3614
- "aria-expanded",
3615
- "true"
3616
- );
3617
- }
3618
- ), t.start()));
3619
- }
3620
- onClose() {
3621
- const t = this.container.getManyAsync(
3622
- "router",
3623
- "components"
3624
- );
3625
- return (() => this.container.get("settings").then((r) => {
3626
- const { activate: s } = this.container.get("$settings");
3627
- return r.activate !== s ? this.setSettings(() => Promise.resolve({ activate: s })) : Promise.resolve();
3628
- }))().then(() => t).then(
3629
- ({
3630
- router: r,
3631
- components: s
3632
- }) => {
3633
- const i = s.nodes.visible;
3634
- return this.outlets.forEach(
3635
- (o) => {
3636
- var a;
3637
- return (a = o.options.triggerDOMElement) == null ? void 0 : a.setAttribute(
3638
- "aria-expanded",
3639
- "false"
3640
- );
3641
- }
3642
- ), i.filter(
3643
- (o) => o.attributes.properties.animation && o.attributes.properties.animation !== "none"
3644
- ).length ? new Promise((o) => {
3645
- setTimeout(() => {
3646
- o(r);
3647
- }, 200);
3648
- }) : Promise.resolve(r);
3649
- }
3650
- ).then((r) => r.stop());
3651
- }
3652
- setTriggerState(t) {
3653
- this.outlets.forEach((e) => {
3654
- const {
3655
- options: { triggerDOMElement: r, triggerOptions: s }
3656
- } = e, { openTooltip: i, closedTooltip: o } = s || {};
3657
- r && (t ? Rn(r, i) : ti(r, o));
3658
- });
3659
- }
3660
- deactivate() {
3661
- this.subs.forEach((e) => e());
3662
- const t = [];
3663
- return this.outlets.forEach((e) => t.push(e.dispose())), q(
3664
- this.container,
3665
- tn,
3666
- S.Local
3667
- ).then((e) => e === this.widget.name ? X(
3668
- this.container,
3669
- tn,
3670
- k.Necessary,
3671
- {
3672
- medium: S.Local,
3673
- scope: vt.Implementation
3674
- }
3675
- ).then((r) => r()).then(() => Promise.all(t)) : Promise.all(t));
3676
- }
3677
- }
3678
- /**
3679
- * @license
3680
- * Copyright 2021 Google LLC
3681
- * SPDX-License-Identifier: BSD-3-Clause
3682
- */
3683
- let pi = class extends Event {
3684
- constructor(t, e, r) {
3685
- super("context-request", { bubbles: !0, composed: !0 }), this.context = t, this.callback = e, this.subscribe = r != null && r;
3686
- }
3687
- };
3688
- /**
3689
- * @license
3690
- * Copyright 2021 Google LLC
3691
- * SPDX-License-Identifier: BSD-3-Clause
3692
- */
3693
- /**
3694
- * @license
3695
- * Copyright 2021 Google LLC
3696
- * SPDX-License-Identifier: BSD-3-Clause
3697
- */
3698
- class en {
3699
- constructor(t, e, r, s) {
3700
- var i;
3701
- if (this.subscribe = !1, this.provided = !1, this.value = void 0, this.t = (o, a) => {
3702
- 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;
3703
- }, this.host = t, e.context !== void 0) {
3704
- const o = e;
3705
- this.context = o.context, this.callback = o.callback, this.subscribe = (i = o.subscribe) !== null && i !== void 0 && i;
3706
- } else
3707
- this.context = e, this.callback = r, this.subscribe = s != null && s;
3708
- this.host.addController(this);
3709
- }
3710
- hostConnected() {
3711
- this.dispatchRequest();
3712
- }
3713
- hostDisconnected() {
3714
- this.unsubscribe && (this.unsubscribe(), this.unsubscribe = void 0);
3715
- }
3716
- dispatchRequest() {
3717
- this.host.dispatchEvent(new pi(this.context, this.t, this.subscribe));
3718
- }
3719
- }
3720
- const Li = "children", fi = "descriptor", gi = "container", Mi = "context", Di = "layout", ji = "properties";
3721
- class _i {
3722
- constructor(t) {
3723
- (this.host = t).addController(this), new en(
3724
- t,
3725
- gi,
3726
- (e) => {
3727
- this._container = e, this.host.requestUpdate();
3728
- },
3729
- !0
3730
- ), new en(
3731
- t,
3732
- fi,
3733
- (e) => {
3734
- this._descriptor = e, this.host.requestUpdate();
3735
- },
3736
- !0
3737
- );
3738
- }
3739
- hostConnected() {
3740
- }
3741
- hostDisconnected() {
3742
- }
3743
- dispatch(t, e) {
3744
- return Zt(this, null, function* () {
3745
- if (!this._container || !this._descriptor)
3746
- return;
3747
- const r = yield qt.getInstance(
3748
- this._container
3749
- ), s = new yt(r).withId(
3750
- this._descriptor.id
3751
- );
3752
- yield r.actions(
3753
- s,
3754
- this._descriptor.type || Pt()
3755
- ).dispatch(t, e);
3756
- });
3757
- }
3758
- }
3759
- const Ii = (n, t, e, r, s) => n.getAsync("componentResolver").then((i) => (i.registerComponent(t, e), hn(n, t, r || (() => {
3760
- }), t, s)));
3761
- export {
3762
- _i as A,
3763
- Or as E,
3764
- Ai as W,
3765
- en as a,
3766
- Mi as b,
3767
- Li as c,
3768
- fi as d,
3769
- qt as e,
3770
- gi as f,
3771
- Ii as g,
3772
- Di as l,
3773
- z as m,
3774
- ji as p,
3775
- pi as s
3776
- };
3777
- //# sourceMappingURL=index-8c63c0e1.js.map