@telia-ace/widget-types-grid 1.1.1-rc.2 → 1.1.1-rc.4

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.
package/index.mjs CHANGED
@@ -1,17 +1,1027 @@
1
- import { b as d, a1 as g, a4 as C, a2 as c, a4 as W, a3 as b } from "./index-0d30f3d9.mjs";
2
- import "react/jsx-runtime";
3
- import "@emotion/react";
4
- import "react";
5
- import "@emotion/styled";
6
- import "react-transition-group";
7
- import "react-dom";
8
- import "react-router-dom";
9
- import "react-router";
1
+ var dt = Object.defineProperty;
2
+ var ht = (e, n, t) => n in e ? dt(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
3
+ var M = (e, n, t) => (ht(e, typeof n != "symbol" ? n + "" : n, t), t);
4
+ import { jsx as p } from "react/jsx-runtime";
5
+ import { css as nt, ThemeProvider as pt, useTheme as mt } from "@emotion/react";
6
+ import { asDescriptor as X, ComponentPlatform as ft, createComponentModel as gt, ComponentQuery as bt, WidgetRenderState as C } from "@telia-ace/widget-core";
7
+ import { Grid as it, useRouteData as yt, useRouter as wt, useProperties as st, useContext as Y, useContainer as z, useComponentNode as q, useScroll as ot, transitionComposer as vt, paddedBorderTabStyle as Ct, useComponent as Ot, useComponentDescriptor as Et, filterCssPropsStyle as St, Typography as At, useComponentPlatform as rt, useIsMounted as xt, useColumns as Dt, useLayout as Mt, ComponentNodeContext as Nt, ComponentPropertyContext as Lt, filterCssProps as $t } from "@telia-ace/widget-ui";
8
+ import Q, { useState as _, forwardRef as at, useMemo as Pt, Suspense as kt, useEffect as I } from "react";
9
+ import L from "@emotion/styled";
10
+ import { appendClassNames as j, notifyDataLoaded as Rt, lock as H, removeNullAndUndefinedValues as tt, uuid as Vt } from "@telia-ace/widget-utilities";
11
+ import { TransitionGroup as _t, Transition as It } from "react-transition-group";
12
+ import { Switch as zt, Route as F } from "react-router";
13
+ import { onWidgetUrl as Bt } from "@telia-ace/widget-routing";
14
+ import { readStorage as x, StorageMedium as v, createStorageWriter as P, StorageCategory as k, StorageScope as Tt } from "@telia-ace/widget-services";
15
+ import { supportBootstrapping as jt } from "@webprovisions/bootstrapping";
16
+ import { WidgetState as Gt, WidgetType as Wt } from "@webprovisions/platform";
17
+ var U = /* @__PURE__ */ ((e) => (e.back = "back", e.forth = "forth", e))(U || {});
18
+ const Ht = (e, n, t) => typeof t[e] == "number" && typeof t[n] == "number" && t[e] > t[n] ? "back" : "forth", ct = ({ views: e, location: n, render: t }) => /* @__PURE__ */ p(
19
+ zt,
20
+ {
21
+ location: n && {
22
+ ...n,
23
+ pathname: n.pathname.split("?")[0]
24
+ },
25
+ children: [
26
+ ...Object.keys(e).filter((i) => !!e[i].path),
27
+ ...Object.keys(e).filter((i) => !e[i].path)
28
+ ].map((i) => {
29
+ const { path: s } = e[i];
30
+ return s ? Array.isArray(s) ? s.map((o) => /* @__PURE__ */ p(F, { exact: !0, path: o, render: () => t(i) }, i)) : /* @__PURE__ */ p(F, { exact: !0, path: s, render: () => t(i) }, i) : /* @__PURE__ */ p(F, { render: () => t(i) }, i);
31
+ })
32
+ }
33
+ ), Ft = L.div`
34
+ position: relative;
35
+ width: 100%;
36
+ flex: 1;
37
+ `, Kt = L(it)`
38
+ position: absolute;
39
+ left: 0;
40
+ right: 0;
41
+ ${(e) => !!e.animationCss && e.animationCss}
42
+ ${(e) => !!e.scrollableCss && e.scrollableCss}
43
+ `, Ut = {
44
+ index: 1,
45
+ search: 2,
46
+ browse: 3,
47
+ guide: 4,
48
+ contact: 5,
49
+ "contact-method": 6,
50
+ conversation: 7
51
+ }, Yt = ({ className: e = "", ...n }) => {
52
+ const [t, i] = _("index"), [s, o] = _(
53
+ U.forth
54
+ ), r = yt(), a = wt(), c = st(), m = Y(), u = z(), l = q(), { gap: d = "0" } = m, {
55
+ columns: f = 1,
56
+ animation: b = "none",
57
+ scrollable: h = !1,
58
+ ...g
59
+ } = c, [y, S] = ot(h);
60
+ if (!l || !a)
61
+ return null;
62
+ const { location: R } = a;
63
+ r.name !== t && r.name !== "" && b && (o(
64
+ Ht(t, r.name, Ut)
65
+ ), i(r.name));
66
+ const { views: A } = u.get("$settings");
67
+ if (!Object.keys(A).length)
68
+ return null;
69
+ const O = (w, D, $) => {
70
+ const E = W(D, $), V = l.getChildren(w)[0];
71
+ return /* @__PURE__ */ p(
72
+ Kt,
73
+ {
74
+ ...n,
75
+ ...g,
76
+ scrollableCss: y,
77
+ ref: S,
78
+ columns: f,
79
+ gap: d,
80
+ ...E,
81
+ className: j(e, "humany-view"),
82
+ children: /* @__PURE__ */ p(Z, { id: V.id, branch: "default" })
83
+ }
84
+ );
85
+ }, W = (w, D) => {
86
+ if (b === "slide" || b === "fade")
87
+ return {
88
+ animationCss: vt.composeViewTransition(
89
+ w,
90
+ b,
91
+ D
92
+ ),
93
+ "data-state": w
94
+ };
95
+ };
96
+ return /* @__PURE__ */ p(Ft, { className: "humany-animated-view", children: /* @__PURE__ */ p(
97
+ _t,
98
+ {
99
+ component: null,
100
+ childFactory: (w) => Q.cloneElement(w, { direction: s }),
101
+ children: /* @__PURE__ */ p(
102
+ It,
103
+ {
104
+ timeout: { enter: 500, exit: 500 },
105
+ onEnter: (w) => w == null ? void 0 : w.clientHeight,
106
+ unmountOnExit: !0,
107
+ direction: U.forth,
108
+ children: (w, { direction: D }) => /* @__PURE__ */ p(
109
+ ct,
110
+ {
111
+ views: A,
112
+ location: R,
113
+ render: ($) => O($, w, D)
114
+ }
115
+ )
116
+ },
117
+ t
118
+ )
119
+ }
120
+ ) });
121
+ }, qt = L(it)`
122
+ ${(e) => !!e.scrollableCss && e.scrollableCss}
123
+ `, Qt = ({ className: e = "", ...n }) => {
124
+ const t = st(), i = Y(), s = z(), o = q(), { views: r } = s.get("$settings"), { gap: a = "0" } = i, { columns: c = 1, animation: m = "none", scrollable: u = !1, ...l } = t, [d, f] = ot(u);
125
+ return o ? /* @__PURE__ */ p(
126
+ qt,
127
+ {
128
+ ...n,
129
+ ...l,
130
+ scrollableCss: d,
131
+ ref: f,
132
+ columns: c,
133
+ gap: a,
134
+ className: j(e, "humany-view"),
135
+ children: /* @__PURE__ */ p(
136
+ ct,
137
+ {
138
+ views: r,
139
+ render: (b) => {
140
+ const h = o.getChildren(b)[0];
141
+ return /* @__PURE__ */ p(Z, { id: h.id, node: h, branch: "default" });
142
+ }
143
+ }
144
+ )
145
+ }
146
+ ) : null;
147
+ }, G = (e) => {
148
+ var n, t;
149
+ return nt`
150
+ outline: none;
151
+ box-sizing: border-box;
152
+ * {
153
+ box-sizing: border-box;
154
+ outline: none;
155
+ }
156
+
157
+ grid-column: ${e["data-indent"] ? `${e["data-indent"] + 1} / ${e["data-indent"] + (e["data-width"] || 0) + 1}` : `span ${e["data-width"]}`};
158
+
159
+ ${((n = e.theme.fonts) == null ? void 0 : n.type) && `
160
+ font-family: ${e.theme.fonts.type};
161
+
162
+ input, textarea {
163
+ font-family: ${e.theme.fonts.type};
164
+ }
165
+ `}
166
+
167
+ ${((t = e.theme.fonts) == null ? void 0 : t.base) && `
168
+ font-size: ${e.theme.fonts.base};
169
+ `}
170
+
171
+ &:focus-visible {
172
+ ${Ct(e)};
173
+ }
174
+ `;
175
+ }, Zt = L(Qt)`
176
+ ${(e) => G(e)}
177
+ `, Jt = L(Yt)`
178
+ ${(e) => G(e)}
179
+ `, Xt = L.div`
180
+ text-align: center;
181
+ ${(e) => {
182
+ var n, t, i;
183
+ return typeof ((n = e.theme.colors) == null ? void 0 : n.warning) < "u" && nt`
184
+ color: ${(t = e.theme.colors) == null ? void 0 : t.warning};
185
+ border: 2px dashed ${(i = e.theme.colors) == null ? void 0 : i.warning};
186
+ `;
187
+ }}
188
+ ${(e) => typeof e.theme.borderRadius < "u" && `border-radius: ${e.theme.borderRadius};`}
189
+ ${(e) => G(e)}
190
+ `, te = at(
191
+ ({ className: e = "", children: n, ...t }, i) => {
192
+ const s = Ot(), { name: o, type: r, id: a } = Et(), c = Pt(() => s ? L(s)`
193
+ ${G}
194
+ ${St}
195
+ ` : null, [s]);
196
+ return typeof s > "u" ? null : s === null || c === null ? process.env.NODE_ENV !== "production" ? /* @__PURE__ */ p(
197
+ Xt,
198
+ {
199
+ ...t,
200
+ title: `type: ${r}, definition-id: ${o}, instance-id: ${a}`,
201
+ className: j(e, "humany-non-resolved-component"),
202
+ children: /* @__PURE__ */ p(At, { variant: "h5", children: "Non Resolved Component Type" })
203
+ }
204
+ ) : null : /* @__PURE__ */ p(kt, { fallback: null, children: /* @__PURE__ */ p(
205
+ c,
206
+ {
207
+ ref: i,
208
+ ...t,
209
+ className: j(
210
+ e,
211
+ "humany-component",
212
+ `humany-component-${o}`
213
+ ),
214
+ children: n
215
+ }
216
+ ) });
217
+ }
218
+ ), ee = (e) => {
219
+ const n = q(e), t = rt(), [i, s] = _({}), o = xt();
220
+ return I(() => {
221
+ n && o.current && s(n.attributes.properties);
222
+ }, [n, e, o]), I(() => {
223
+ if (t) {
224
+ const r = t.events.subscribe(
225
+ "components:properties-changed",
226
+ (a, c) => {
227
+ n === c.node && o.current && s(c.node.attributes.properties);
228
+ }
229
+ );
230
+ return () => {
231
+ r();
232
+ };
233
+ }
234
+ }, [t, o, e, n]), i;
235
+ }, ne = (e, n) => n ? !0 : typeof e == "string" ? e === "full" : e > 0, Z = at(
236
+ ({
237
+ className: e = "",
238
+ id: n,
239
+ branch: t,
240
+ node: i,
241
+ ariaLabel: s,
242
+ tabIndex: o,
243
+ context: r,
244
+ ...a
245
+ }, c) => {
246
+ const m = rt(), u = z(), [l, d] = _(), f = Dt(), b = Y(n), h = ee(n), { size: g = "none", indent: y = 0 } = Mt(n), S = ne(g, i);
247
+ if (I(() => {
248
+ if (m) {
249
+ if (n && !i) {
250
+ const E = m.nodes.get(n);
251
+ if (E && (d(X(E, t)), S)) {
252
+ const V = E.mount(u);
253
+ return () => {
254
+ V();
255
+ };
256
+ }
257
+ } else if (i) {
258
+ d(X(i, t));
259
+ const E = i.mount(u);
260
+ return () => {
261
+ E();
262
+ };
263
+ }
264
+ }
265
+ }, [m, n, i, S]), !l || !S)
266
+ return null;
267
+ const R = { ...b, ...r || {} }, {
268
+ cardinal: A,
269
+ fonts: O = {},
270
+ accessibility: W = {},
271
+ ...w
272
+ } = R, D = {
273
+ type: O.type,
274
+ base: O.base || "16px",
275
+ small: O.small || "0.8em",
276
+ normal: O.normal || "1em",
277
+ medium: O.medium || "1.2em",
278
+ large: O.large || "1.6em",
279
+ huge: O.huge || "2.5em"
280
+ }, $ = {
281
+ ...w,
282
+ fonts: D,
283
+ accessibility: {
284
+ ...W
285
+ }
286
+ };
287
+ return typeof A == "number" && ($.sizes = {
288
+ cardinal: A,
289
+ small: `${A}px`,
290
+ normal: `${A * 3}px`,
291
+ medium: `${A * 5}px`,
292
+ large: `${A * 8}px`
293
+ }), /* @__PURE__ */ p(pt, { theme: $, children: /* @__PURE__ */ p(Nt.Provider, { value: l, children: /* @__PURE__ */ p(Lt.Provider, { value: h, children: (() => {
294
+ const E = {
295
+ "data-width": g === "full" ? f : Math.min(g, f),
296
+ "data-indent": y,
297
+ "data-name": l.name,
298
+ "data-node-id": l.id,
299
+ "data-component-type": l.type,
300
+ "aria-label": s,
301
+ tabIndex: o,
302
+ id: l.id,
303
+ role: h && h.role,
304
+ ...a
305
+ };
306
+ switch (l.type) {
307
+ case "view":
308
+ return typeof h.animation == "string" && h.animation !== "none" ? /* @__PURE__ */ p(Jt, { ...E, className: e }) : /* @__PURE__ */ p(Zt, { ...E, className: e });
309
+ default: {
310
+ const V = $t(h);
311
+ return /* @__PURE__ */ p(
312
+ te,
313
+ {
314
+ ref: c,
315
+ ...E,
316
+ ...V,
317
+ className: e
318
+ }
319
+ );
320
+ }
321
+ }
322
+ })() }) }) });
323
+ }
324
+ ), ie = ({ builder: e }) => {
325
+ const n = z(), [t, i] = _(null);
326
+ return I(() => {
327
+ n.getAsync("components").then((s) => e(s).then((o) => {
328
+ i(o);
329
+ }));
330
+ }, []), I(() => () => {
331
+ t && n.getAsync("components").then((s) => {
332
+ s.nodes.detached = s.nodes.detached.filter(
333
+ (o) => o.id !== t.id
334
+ );
335
+ });
336
+ }, [t]), t ? /* @__PURE__ */ p(Z, { id: t.id, node: t, branch: "default" }) : null;
337
+ }, se = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
338
+ __proto__: null,
339
+ default: ie
340
+ }, Symbol.toStringTag, { value: "Module" })), oe = Q.lazy(() => Promise.resolve().then(() => se)), _e = ({ showSearch: e = !1 }) => {
341
+ const n = mt(), t = z();
342
+ return /* @__PURE__ */ p(Q.Suspense, { fallback: null, children: /* @__PURE__ */ p(
343
+ oe,
344
+ {
345
+ builder: (i) => t.get("settings").then((s) => {
346
+ var m;
347
+ const { properties: o, context: r } = Object.keys(s.components).reduce(
348
+ (u, l) => (s.components[l].type === "not-found" && (u.properties = s.components[l].properties, u.context = s.components[l].context), u),
349
+ { properties: {}, context: {} }
350
+ );
351
+ o.showSearch = e;
352
+ const a = i.createNode("area", { detached: !0 });
353
+ if (a.name = "not-found-area", a.writeLayout({
354
+ size: "full"
355
+ }), e) {
356
+ const u = Object.keys(s.components).reduce(
357
+ (d, f) => s.components[f].type === "search" ? s.components[f].properties : d,
358
+ {}
359
+ ), l = i.createNode("search", { detached: !0 });
360
+ l.writeLayout({ size: "full" }), l.writeProperties({
361
+ "css-margin-bottom": ((m = n == null ? void 0 : n.sizes) == null ? void 0 : m.normal) || "15px",
362
+ ...u
363
+ }), a.appendChild(l);
364
+ }
365
+ const c = i.createNode("not-found", { detached: !0 });
366
+ return c.writeLayout({ size: "full" }), c.writeProperties(o), c.writeContext(r), a.appendChild(c), a;
367
+ })
368
+ }
369
+ ) });
370
+ }, re = (e) => {
371
+ if (e) {
372
+ const { type: n, content: t } = e;
373
+ switch (n) {
374
+ case "FontAwesome":
375
+ return `<i class="humany-icon fa fa-${t}"></i>`;
376
+ case "Uri":
377
+ return `<i class="humany-icon humany-custom-icon" style="background: url(${t}) no-repeat center center;background-size: contain;"></i>`;
378
+ default:
379
+ return "";
380
+ }
381
+ }
382
+ }, ae = (e) => {
383
+ const n = (s, o) => {
384
+ s && (o ? s.classList.add("humany-tabbing") : s.classList.remove("humany-tabbing"));
385
+ }, t = (s) => {
386
+ s.key === "Tab" ? n(e, !0) : s.key === "Enter" && document.activeElement && document.activeElement.classList.contains("humany-trigger") || n(e, !1);
387
+ }, i = (s) => {
388
+ document.activeElement && document.activeElement.classList.contains("humany-trigger") && document.activeElement.classList.contains("humany-tabbing") || n(e, !1);
389
+ };
390
+ return document.addEventListener("keydown", t), document.addEventListener("click", i), () => {
391
+ document.removeEventListener("keydown", t), document.removeEventListener("click", i);
392
+ };
393
+ };
394
+ function ce(e, n) {
395
+ const { symbol: t, widgetName: i, label: s = "", ariaLabel: o = "", tooltip: r = "" } = n;
396
+ e.classList.add("humany-trigger"), e.classList.add(`humany_${i}`), s.length && e.classList.add("humany-has-text"), o.length && !e.getAttribute("aria-label") && e.setAttribute("aria-label", o), o.length && !e.getAttribute("tabindex") && e.setAttribute("tabindex", "0"), r.length && !e.getAttribute("title") && e.setAttribute("title", r);
397
+ const a = re(t) || "";
398
+ return e.innerHTML = `${a}
399
+ <span class="humany-close">
400
+ <svg width="18" height="9" viewBox="0 0 18 9" fill="none" xmlns="http://www.w3.org/2000/svg">
401
+ <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"/>
402
+ </svg>
403
+ </span>
404
+ <span class="humany-loader">
405
+ <svg viewBox="25 25 50 50">
406
+ <circle
407
+ cx="50"
408
+ cy="50"
409
+ r="20"
410
+ fill="none"
411
+ stroke="#000"
412
+ stroke-width="2"
413
+ stroke-miterlimit="10" />
414
+ </svg>
415
+ </span>
416
+ ${s.length ? `<span>${s}</span>` : ""}`, setTimeout(() => e && e.classList.add("humany-rendered")), ae(e);
417
+ }
418
+ function le(e, n) {
419
+ e instanceof HTMLElement ? (n && e.setAttribute("title", n), e.classList.remove("humany-active"), e.classList.remove("humany-loading")) : e instanceof Array && e.forEach((t) => {
420
+ n && t.setAttribute("title", n), t.classList.remove("humany-active"), t.classList.remove("humany-loading");
421
+ });
422
+ }
423
+ function ue(e) {
424
+ e instanceof HTMLElement ? (e.classList.remove("humany-active"), e.classList.add("humany-loading")) : e instanceof Array && e.forEach((n) => {
425
+ n.classList.remove("humany-active"), n.classList.add("humany-loading");
426
+ });
427
+ }
428
+ function lt(e, n) {
429
+ e instanceof HTMLElement ? (n && e.setAttribute("title", n), e.classList.add("humany-active"), e.classList.remove("humany-loading")) : e instanceof Array && e.forEach((t) => {
430
+ n && t.setAttribute("title", n), t.classList.add("humany-active"), t.classList.remove("humany-loading");
431
+ });
432
+ }
433
+ var N = /* @__PURE__ */ ((e) => (e.Inline = "inline", e.Link = "link", e.Badge = "badge", e.Unsupported = "unsupported", e))(N || {});
434
+ const de = (e, n) => e && n ? "both" : e ? "widgetDOM" : n ? "triggerDOM" : "none", ut = (e) => e ? typeof e == "boolean" && e ? "link" : typeof e == "object" && !Array.isArray(e) ? "badge" : "unsupported" : "inline", he = (e, n, t, i, s = !1) => {
435
+ var m, u;
436
+ const o = de(
437
+ n,
438
+ t
439
+ ), r = ut(i), a = {
440
+ widgetDOMElement: n ? n.cloneNode(!0) : void 0,
441
+ triggerDOMElement: t ? t.cloneNode(!0) : void 0
442
+ }, c = {
443
+ triggerType: r,
444
+ cachedOriginals: a,
445
+ widgetDOMElement: document.createElement("div")
446
+ };
447
+ switch (o) {
448
+ case "both": {
449
+ c.widgetDOMElement = n || document.createElement("div"), r !== "inline" && (c.triggerDOMElement = t);
450
+ break;
451
+ }
452
+ case "widgetDOM": {
453
+ if (c.widgetDOMElement = n || document.createElement("div"), r !== "inline") {
454
+ const l = document.body.appendChild(
455
+ document.createElement("a")
456
+ );
457
+ r === "link" && (l.innerText = e), c.triggerDOMElement = l;
458
+ }
459
+ break;
460
+ }
461
+ case "triggerDOM": {
462
+ const l = document.createElement("div");
463
+ c.widgetDOMElement = l, r === "inline" ? (l.id = (t == null ? void 0 : t.id) || "", s ? (l.style.display = "none", (m = t == null ? void 0 : t.parentNode) == null || m.appendChild(l), c.callback = () => {
464
+ var d;
465
+ (d = t == null ? void 0 : t.parentNode) == null || d.replaceChild(
466
+ l,
467
+ t
468
+ ), l.style.display = (t == null ? void 0 : t.style.display) || "block";
469
+ }) : (u = t == null ? void 0 : t.parentNode) == null || u.replaceChild(
470
+ l,
471
+ t
472
+ ), c.cachedOriginals.widgetDOMElement = t, c.cachedOriginals.triggerDOMElement = void 0) : (c.widgetDOMElement = document.body.appendChild(l), c.triggerDOMElement = t);
473
+ break;
474
+ }
475
+ case "none": {
476
+ const l = document.body.appendChild(
477
+ document.createElement("div")
478
+ );
479
+ if (c.widgetDOMElement = l, r !== "inline") {
480
+ const d = document.body.appendChild(
481
+ document.createElement("a")
482
+ );
483
+ r === "link" && (d.innerText = e), c.triggerDOMElement = d;
484
+ }
485
+ break;
486
+ }
487
+ }
488
+ return c;
489
+ }, pe = "modals";
490
+ class me {
491
+ constructor(n, t) {
492
+ M(this, "container");
493
+ M(this, "unsubscribe", []);
494
+ this.options = t, this.container = n.createChild(this), this.container.register("widgetDOMElement", this.options.widgetDOMElement), this.container.register("triggerDOMElement", this.options.triggerDOMElement);
495
+ const i = this.container.get("$widget");
496
+ this.options.widgetDOMElement.classList.add("humany-widget"), this.options.widgetDOMElement.classList.add(`humany_${i.name}`);
497
+ const s = n.get("widgetDOMElements") || [];
498
+ n.register("widgetDOMElements", [
499
+ ...s,
500
+ this.options.widgetDOMElement
501
+ ]);
502
+ }
503
+ /**
504
+ * Renders the view outlet to the DOM.
505
+ */
506
+ render() {
507
+ const { widgetDOMElement: n, triggerDOMElement: t } = this.options, i = this.container.get("$widget");
508
+ return n.getAttribute("data-rendered") === "true" ? Promise.resolve() : (t && this.options.triggerType === N.Badge && ue(t), import("./render-9309d354.mjs").then((s) => s.default(this.container, n)).then(() => {
509
+ if (n.setAttribute("data-rendered", "true"), t && this.options.triggerType === N.Badge) {
510
+ const o = this.options.triggerOptions.openTooltip;
511
+ lt(t, o);
512
+ }
513
+ Rt(this.container, n);
514
+ const s = this.container.get("$environment").widgets.all();
515
+ x(
516
+ this.container,
517
+ pe,
518
+ v.Session
519
+ ).then((o) => {
520
+ o && o.forEach((r) => {
521
+ s.find(
522
+ (a) => a.name === r.name && a.state === "activated"
523
+ ) && i.events.dispatch("widget:modal-opened", r);
524
+ });
525
+ });
526
+ }));
527
+ }
528
+ renderBadge(n) {
529
+ const { triggerDOMElement: t } = this.options;
530
+ if (!t)
531
+ return;
532
+ t.getAttribute("role") || t.setAttribute("role", "button");
533
+ const { name: i } = this.container.get("$widget"), { label: s, symbol: o, ariaLabel: r, closedTooltip: a, openTooltip: c } = n, m = { closedTooltip: a, openTooltip: c };
534
+ this.options.triggerOptions = m;
535
+ const u = ce(t, {
536
+ label: s,
537
+ symbol: o,
538
+ ariaLabel: r,
539
+ widgetName: i,
540
+ tooltip: a
541
+ });
542
+ this.unsubscribe.push(u);
543
+ }
544
+ dispose() {
545
+ return import("./unmount-063d8ea3.mjs").then((n) => {
546
+ var s, o, r, a;
547
+ const { triggerDOMElement: t, widgetDOMElement: i } = this.options;
548
+ n.default(i), this.options.cachedOriginals.widgetDOMElement && i && ((s = i.parentNode) == null || s.replaceChild(
549
+ this.options.cachedOriginals.widgetDOMElement,
550
+ i
551
+ )), this.options.cachedOriginals.triggerDOMElement && t && ((o = t.parentNode) == null || o.replaceChild(
552
+ this.options.cachedOriginals.triggerDOMElement,
553
+ t
554
+ )), this.unsubscribe.forEach((c) => {
555
+ c();
556
+ }), (r = i.parentNode) == null || r.removeChild(i), (a = t == null ? void 0 : t.parentNode) == null || a.removeChild(t);
557
+ });
558
+ }
559
+ }
560
+ const B = "changesets", fe = (e) => {
561
+ const n = { tags: e.tags };
562
+ return e.context && typeof e.context != "function" && (n.context = e.context), e.properties && typeof e.properties != "function" && (n.properties = e.properties), e.layout && typeof e.layout != "function" && (n.layout = e.layout), n;
563
+ };
564
+ class J {
565
+ constructor(n, t) {
566
+ this.container = n, this.storageWriter = t;
567
+ }
568
+ static create(n) {
569
+ return P(n, B, k.Necessary, {
570
+ medium: v.Local
571
+ }).then((t) => new J(n, t));
572
+ }
573
+ write(n, t, i, s) {
574
+ return H(this)(() => x(
575
+ this.container,
576
+ B,
577
+ v.Local
578
+ ).then((o = {}) => {
579
+ const { keys: r = [], items: a = {} } = o, c = r.indexOf(n);
580
+ return c > -1 && r.splice(c, 1), r.push(n), a[n] = {
581
+ options: s,
582
+ attributes: fe(i),
583
+ rules: t.rules
584
+ }, this.storageWriter({ keys: r, items: a });
585
+ }));
586
+ }
587
+ remove(n) {
588
+ return H(this)(() => x(
589
+ this.container,
590
+ B,
591
+ v.Local
592
+ ).then((t = {}) => {
593
+ const { keys: i = [], items: s = {} } = t, o = i.indexOf(n);
594
+ if (o > -1)
595
+ return i.splice(o, 1), delete s[n], this.storageWriter(t);
596
+ }));
597
+ }
598
+ load(n) {
599
+ return H(this)(() => x(
600
+ this.container,
601
+ B,
602
+ v.Local
603
+ ).then((t = {}) => {
604
+ const { keys: i = [], items: s = {} } = t;
605
+ i.forEach((o) => {
606
+ const r = s[o];
607
+ if (r) {
608
+ const { rules: a, attributes: c, options: m } = r;
609
+ n.write({
610
+ attributes: c,
611
+ options: m,
612
+ target: new bt(n, a)
613
+ });
614
+ }
615
+ });
616
+ }));
617
+ }
618
+ }
619
+ const ge = (e) => {
620
+ const { container: n } = e;
621
+ return J.create(n).then((t) => {
622
+ const i = n.get("$settings"), s = { localStorage: t }, o = new ft(e, s), r = gt(o, i);
623
+ return e.events.subscribe("widget:state-change", (a, c) => {
624
+ c.state === Gt.Deactivating && r();
625
+ }), o;
626
+ });
627
+ }, be = (e) => import("@telia-ace/widget-routing").then(({ RoutingService: n, HistoryMode: t }) => e.get("settings").then((i) => {
628
+ const {
629
+ routing: { initialPath: s = "/", mode: o = t.scopedHash, basePath: r },
630
+ views: a
631
+ } = i;
632
+ return new n(e, {
633
+ initialPath: s,
634
+ mode: o,
635
+ routes: Object.keys(a).map((m) => ({
636
+ name: m,
637
+ path: a[m].path
638
+ })),
639
+ basePath: r
640
+ });
641
+ })), ye = (e) => import("@telia-ace/widget-services").then(({ StorageProvider: n }) => new n()), we = (e) => import("@telia-ace/widget-core").then(({ ActionResolver: n }) => new n(e)), ve = (e) => import("@telia-ace/widget-core").then(({ ComponentResolver: n }) => new n(e)), Ce = (e) => import("@telia-ace/widget-core").then(({ ComponentPlatform: n, createComponentModel: t }) => ge(e.get("$widget"))), K = "$settings", T = "open", et = "activeStickyWidget";
642
+ class Ie extends Wt {
643
+ constructor(t) {
644
+ super(t);
645
+ M(this, "outlets", /* @__PURE__ */ new Map());
646
+ M(this, "activated");
647
+ M(this, "subs", []);
648
+ M(this, "handleBootstrapping", (t) => {
649
+ const i = {
650
+ triggerDOMElement: t.sourceDOMElement,
651
+ withRenderState: "storage"
652
+ /* Storage */
653
+ };
654
+ this.container.get("settings").then((s) => {
655
+ const { activate: o } = s;
656
+ (typeof o > "u" || o === null || o === !0) && (this.activated = (this.activated || this.widget.activate()).then(
657
+ () => this.attach(i)
658
+ ));
659
+ });
660
+ });
661
+ this.container.registerAsync(
662
+ "storage",
663
+ () => ye(this.container)
664
+ ), this.container.registerFactory("settings", () => x(
665
+ this.container,
666
+ K,
667
+ v.Local
668
+ ).then((i = {}) => ({
669
+ ...this.container.get("$settings"),
670
+ ...i
671
+ }))), jt(this, "load", this.handleBootstrapping), this.container.registerAsync(
672
+ "componentResolver",
673
+ () => ve(this.container)
674
+ ), this.container.registerAsync(
675
+ "router",
676
+ () => be(this.container)
677
+ ), this.container.registerAsync(
678
+ "actionResolver",
679
+ () => we(this.container)
680
+ ), this.container.register("matchMedia", window.matchMedia), this.container.registerAsync(
681
+ "components",
682
+ () => Ce(this.container)
683
+ );
684
+ }
685
+ initialize() {
686
+ const t = this.container.getManyAsync(
687
+ "actionResolver",
688
+ "router",
689
+ "components"
690
+ ), i = this.container.get("csp");
691
+ return i && (window.webprovisionsEnvironmentVariables || (window.webprovisionsEnvironmentVariables = {}), window.webprovisionsEnvironmentVariables.cspNonce = i.nonce), Promise.all([t, this.container.get("settings")]).then(
692
+ ([{ actionResolver: s, router: o, components: r }, a]) => {
693
+ var u;
694
+ s.subscribe(
695
+ this.widget.name,
696
+ (l, d, f) => this.onAction(d, f)
697
+ );
698
+ const c = (l) => {
699
+ r.nodes.query({ type: "view" }).forEach((d) => {
700
+ r.setSwitch(d, l);
701
+ });
702
+ }, m = ((u = o.getInitialRoute()) == null ? void 0 : u.name) || "index";
703
+ return c(m), this.events.subscribe("widget:data-loaded", (l, { element: d }) => {
704
+ this.widget.container.get("seoConfiguration") && this.events.dispatch("widget:preloaded-replaced", {
705
+ element: d
706
+ });
707
+ }), this.events.subscribe(
708
+ "router:change",
709
+ (l, { previous: d = { routeData: {} }, next: f = { routeData: {} } }) => {
710
+ const { routeData: b } = d, { routeData: h } = f, g = Object.keys(a.views).reduce(
711
+ (y, S) => typeof a.views[S].path > "u" ? S : y,
712
+ ""
713
+ );
714
+ !h.name && g ? c(g) : c(h.name), tt(b && b.params), tt(h && h.params), this.container.getAsync("actionResolver").then((y) => {
715
+ y.action(this.widget.name, "routeChange", {
716
+ next: h,
717
+ previous: b
718
+ });
719
+ });
720
+ }
721
+ ), o.initialize();
722
+ }
723
+ );
724
+ }
725
+ attach(t = {}) {
726
+ return this.container.get("settings").then(({ trigger: i }) => {
727
+ var f, b;
728
+ const {
729
+ widgetDOMElement: s,
730
+ key: o = Vt(),
731
+ triggerDOMElement: r,
732
+ withRenderState: a
733
+ } = t, m = ut(i) === N.Inline && ((r == null ? void 0 : r.childElementCount) || 0) > 0, u = he(
734
+ this.widget.name,
735
+ s,
736
+ r,
737
+ i,
738
+ m
739
+ );
740
+ this.outlets.size < 1 && !a && this.setRenderState("unset");
741
+ const l = () => {
742
+ const h = () => g.querySelectorAll("[data-loading=true]").length === 0, [g] = this.widget.container.get("widgetDOMElements"), y = (A, O) => {
743
+ h() && (u.callback && u.callback(), O.disconnect());
744
+ }, S = {
745
+ attributes: !0,
746
+ subtree: !0,
747
+ childList: !0
748
+ };
749
+ h() && u.callback && u.callback(), new MutationObserver(y).observe(g, S);
750
+ };
751
+ m && this.widget.container.getAsync("dataClient").then(({ events: h }) => {
752
+ h.subscribe(
753
+ "data-client:fetched",
754
+ (g, y) => {
755
+ y.unresolvedQueries === 0 && l();
756
+ }
757
+ );
758
+ });
759
+ const d = this.getOrCreateViewOutlet(o, u);
760
+ if (this.outlets.set(o, d), this.widget.events.dispatch("widget:attached", {}, { bubbles: !0 }), u.triggerType === N.Badge && i && ((f = u.triggerDOMElement) == null || f.setAttribute(
761
+ "aria-expanded",
762
+ "false"
763
+ ), d == null || d.renderBadge(i)), u.triggerType !== N.Inline && ((b = u.triggerDOMElement) == null || b.addEventListener(
764
+ "click",
765
+ (h) => {
766
+ h.preventDefault(), this.container.get("settings").then(({ trigger: g }) => {
767
+ d.render().then(() => this.renderState()).then((y) => g && g.action && g.action === "hide" ? y === C.open ? this.hide() : this.open() : y === C.open ? this.close() : this.open());
768
+ });
769
+ }
770
+ )), this.outlets.size > 1)
771
+ return this.renderState().then((h) => {
772
+ this.triggerStateIfApplicable(h);
773
+ });
774
+ if (a)
775
+ return a === "storage" ? this.renderState().then((h) => {
776
+ if (u.triggerType === N.Inline) {
777
+ this.triggerStateIfApplicable("open");
778
+ return;
779
+ }
780
+ this.triggerStateIfApplicable(h);
781
+ }) : this.triggerStateIfApplicable(a);
782
+ });
783
+ }
784
+ detach(t) {
785
+ if (t) {
786
+ if (this.outlets.has(t)) {
787
+ const i = this.outlets.get(t);
788
+ i == null || i.dispose(), this.outlets.delete(t);
789
+ return;
790
+ }
791
+ process.env.NODE_ENV !== "production" && console.warn(`detach(): Could not find View Outlet with key ${t}`);
792
+ return;
793
+ }
794
+ this.outlets.forEach((i) => {
795
+ i.dispose();
796
+ }), this.outlets.clear();
797
+ }
798
+ triggerStateIfApplicable(t) {
799
+ return this.container.getAsync("router").then((i) => {
800
+ switch (t) {
801
+ case "closed":
802
+ this.close();
803
+ break;
804
+ case "open":
805
+ this.open();
806
+ break;
807
+ case "hidden":
808
+ this.hide(), i.start();
809
+ break;
810
+ default:
811
+ return;
812
+ }
813
+ });
814
+ }
815
+ getOrCreateViewOutlet(t, i) {
816
+ return this.outlets.has(t) ? this.outlets.get(t) : new me(this.container, i);
817
+ }
818
+ render(t = {}) {
819
+ if (process.env.NODE_ENV !== "production" && console.warn(
820
+ "widget.render() is deprecated. Use widget.attach() instead."
821
+ ), t.open) {
822
+ const i = {
823
+ ...t,
824
+ withRenderState: "open"
825
+ /* Open */
826
+ };
827
+ return this.attach(i);
828
+ }
829
+ return this.attach(t);
830
+ }
831
+ activate(t) {
832
+ t != null && t.override && this.setSettings(() => t.override), t != null && t.apiNotificationPriorityBy && this.container.register(
833
+ "apiNotificationPriorityBy",
834
+ t.apiNotificationPriorityBy
835
+ );
836
+ }
837
+ setSettings(t) {
838
+ return Promise.all([
839
+ this.container.get("settings"),
840
+ P(
841
+ this.container,
842
+ K,
843
+ k.Necessary,
844
+ {
845
+ medium: v.Local
846
+ }
847
+ )
848
+ ]).then(([i, s]) => Promise.resolve(t(i)).then((o) => s(o).then(() => {
849
+ const r = { ...i, ...o };
850
+ return this.widget.events.dispatch("widget:settings-updated", r), r;
851
+ })));
852
+ }
853
+ clearSettings() {
854
+ return P(
855
+ this.container,
856
+ K,
857
+ k.Necessary,
858
+ { medium: v.Local }
859
+ ).then((t) => t()).then(() => this.container.get("settings")).then((t) => {
860
+ this.widget.events.dispatch("widget:settings-updated", t);
861
+ });
862
+ }
863
+ action({ action: t, value: i }) {
864
+ return this.container.getAsync("actionResolver").then((s) => {
865
+ s.action(this.widget.name, t, i);
866
+ });
867
+ }
868
+ renderState() {
869
+ if (Bt(this.container))
870
+ return Promise.resolve(C.open);
871
+ const t = () => x(
872
+ this.container,
873
+ T,
874
+ v.Session
875
+ ).then((s = C.closed) => s), i = () => x(
876
+ this.container,
877
+ T,
878
+ v.Session
879
+ ).then((s = C.closed) => s);
880
+ return this.container.getAsync("router").then((s) => s.isSticky() ? i().then((o) => o === C.open ? o : t()) : t());
881
+ }
882
+ hide() {
883
+ return this.outlets.size < 1 ? (process.env.NODE_ENV !== "production" && console.warn(
884
+ "hide(): No-op as no view outlets are registered. Invoke the attach() command first."
885
+ ), Promise.resolve()) : (this.outlets.forEach((t) => t.render()), this.action({ action: "hide" }).then(() => {
886
+ this.setTriggerState(!1);
887
+ }));
888
+ }
889
+ open() {
890
+ return this.outlets.size < 1 ? (process.env.NODE_ENV !== "production" && console.warn(
891
+ "open(): No-op as no view outlets are registered. Invoke the attach() command first."
892
+ ), Promise.resolve()) : (this.outlets.forEach((t) => t.render()), this.action({ action: "open" }).then(() => (this.widget.events.dispatch("tracking:widget-rendered", {}), this.onOpen())));
893
+ }
894
+ close() {
895
+ return this.outlets.size < 1 ? (process.env.NODE_ENV !== "production" && console.warn(
896
+ "close(): No-op as no view outlets are registered. Invoke the attach() command first."
897
+ ), Promise.resolve()) : this.action({ action: "close" }).then(() => this.onClose());
898
+ }
899
+ show() {
900
+ return process.env.NODE_ENV !== "production" && console.warn(
901
+ "show(): Command is deprecated and will be removed in the future. Use open() instead."
902
+ ), this.open();
903
+ }
904
+ onAction(t, i) {
905
+ switch (t) {
906
+ case "close":
907
+ case "open":
908
+ case "hide":
909
+ const s = t === "open" ? C.open : t === "close" ? C.closed : C.hidden;
910
+ return this.setRenderState(s).then(() => {
911
+ this.setTriggerState(s === C.open), s !== C.hidden ? s === C.open ? this.onOpen() : this.onClose() : this.outlets.forEach(
912
+ (o) => {
913
+ var r;
914
+ return (r = o.options.triggerDOMElement) == null ? void 0 : r.setAttribute(
915
+ "aria-expanded",
916
+ "false"
917
+ );
918
+ }
919
+ );
920
+ });
921
+ }
922
+ }
923
+ setRenderState(t) {
924
+ const { invoke: i, events: s } = this.container.get("$widget");
925
+ return Promise.all([
926
+ P(
927
+ this.container,
928
+ T,
929
+ k.Necessary,
930
+ {
931
+ medium: v.Session
932
+ }
933
+ ),
934
+ P(
935
+ this.container,
936
+ T,
937
+ k.Necessary,
938
+ {
939
+ medium: v.Local,
940
+ duration: { minutes: 5 }
941
+ }
942
+ ),
943
+ this.container.getAsync("router"),
944
+ i("renderState")
945
+ ]).then(
946
+ ([o, r, a, c]) => {
947
+ t === "unset" || !t ? (r(), o()) : (a.isSticky() && r(t), o(t)), s.dispatch("widget:render-state-changed", {
948
+ previous: c,
949
+ next: t
950
+ });
951
+ }
952
+ );
953
+ }
954
+ onOpen() {
955
+ return this.container.getAsync("router").then((t) => (this.outlets.forEach(
956
+ (i) => {
957
+ var s;
958
+ return (s = i.options.triggerDOMElement) == null ? void 0 : s.setAttribute("aria-expanded", "true");
959
+ }
960
+ ), t.start()));
961
+ }
962
+ onClose() {
963
+ const t = this.container.getManyAsync(
964
+ "router",
965
+ "components"
966
+ );
967
+ return (() => this.container.get("settings").then((s) => {
968
+ const { activate: o } = this.container.get("$settings");
969
+ return s.activate !== o ? this.setSettings(() => Promise.resolve({ activate: o })) : Promise.resolve();
970
+ }))().then(() => t).then(
971
+ ({
972
+ router: s,
973
+ components: o
974
+ }) => {
975
+ const r = o.nodes.visible;
976
+ return this.outlets.forEach(
977
+ (a) => {
978
+ var c;
979
+ return (c = a.options.triggerDOMElement) == null ? void 0 : c.setAttribute(
980
+ "aria-expanded",
981
+ "false"
982
+ );
983
+ }
984
+ ), r.filter(
985
+ (a) => a.attributes.properties.animation && a.attributes.properties.animation !== "none"
986
+ ).length ? new Promise((a) => {
987
+ setTimeout(() => {
988
+ a(s);
989
+ }, 200);
990
+ }) : Promise.resolve(s);
991
+ }
992
+ ).then((s) => s.stop());
993
+ }
994
+ setTriggerState(t) {
995
+ this.outlets.forEach((i) => {
996
+ const {
997
+ options: { triggerDOMElement: s, triggerOptions: o }
998
+ } = i, { openTooltip: r, closedTooltip: a } = o || {};
999
+ s && (t ? lt(s, r) : le(s, a));
1000
+ });
1001
+ }
1002
+ deactivate() {
1003
+ this.subs.forEach((i) => i());
1004
+ const t = [];
1005
+ return this.outlets.forEach((i) => t.push(i.dispose())), x(
1006
+ this.container,
1007
+ et,
1008
+ v.Local
1009
+ ).then((i) => i === this.widget.name ? P(
1010
+ this.container,
1011
+ et,
1012
+ k.Necessary,
1013
+ {
1014
+ medium: v.Local,
1015
+ scope: Tt.Implementation
1016
+ }
1017
+ ).then((s) => s()).then(() => Promise.all(t)) : Promise.all(t));
1018
+ }
1019
+ }
10
1020
  export {
11
- d as Component,
12
- g as DetachedComponent,
13
- C as GridWidget,
14
- c as NotFound,
15
- W as Widget,
16
- b as genericComponentStyling
1021
+ Z as Component,
1022
+ ie as DetachedComponent,
1023
+ Ie as GridWidget,
1024
+ _e as NotFound,
1025
+ Ie as Widget,
1026
+ G as genericComponentStyling
17
1027
  };