@telia-ace/widget-types-grid 0.0.1

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