@telia-ace/knowledge-widget-types-grid 1.0.54-next.0 → 1.1.1-rc.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.
@@ -0,0 +1,787 @@
1
+ var Rt = Object.defineProperty;
2
+ var Mt = (r, t, e) => t in r ? Rt(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var k = (r, t, e) => (Mt(r, typeof t != "symbol" ? t + "" : t, e), e);
4
+ import { J as Tt, K as Ct, M as U, N as Dt, O as nt, _ as At, P as Y, Q as Z, T as ut, U as It, V as $t, X as _t, k as ft, j as Bt, c as Nt, Y as dt, Z as rt, $ as it, a0 as Ut, L as Ft, a1 as st, a2 as Q, a3 as lt, a4 as et, a5 as jt, r as Wt, a6 as Kt, a7 as z, a8 as J, a9 as Vt } from "./index-f6d7c0ea.mjs";
5
+ import { aa as xe, ab as Le } from "./index-f6d7c0ea.mjs";
6
+ import { c as Yt } from "./create-params-4e652cc7.mjs";
7
+ import "react/jsx-runtime";
8
+ import "react";
9
+ import "react-dom";
10
+ var zt = function(r, t, e, n, s, a, c, p) {
11
+ if (process.env.NODE_ENV !== "production" && t === void 0)
12
+ throw new Error("invariant requires an error message argument");
13
+ if (!r) {
14
+ var h;
15
+ if (t === void 0)
16
+ h = new Error(
17
+ "Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings."
18
+ );
19
+ else {
20
+ var d = [e, n, s, a, c, p], b = 0;
21
+ h = new Error(
22
+ t.replace(/%s/g, function() {
23
+ return d[b++];
24
+ })
25
+ ), h.name = "Invariant Violation";
26
+ }
27
+ throw h.framesToPop = 1, h;
28
+ }
29
+ }, qt = zt;
30
+ const Gt = /* @__PURE__ */ Tt(qt);
31
+ var Qt = function(t) {
32
+ return t.charAt(0) === "/" ? t : "/" + t;
33
+ }, Ot = function(t, e) {
34
+ return new RegExp("^" + e + "(\\/|\\?|#|$)", "i").test(t);
35
+ }, Jt = function(t, e) {
36
+ return Ot(t, e) ? t.substr(e.length) : t;
37
+ }, Xt = function(t) {
38
+ return t.charAt(t.length - 1) === "/" ? t.slice(0, -1) : t;
39
+ }, Zt = function(t) {
40
+ var e = t || "/", n = "", s = "", a = e.indexOf("#");
41
+ a !== -1 && (s = e.substr(a), e = e.substr(0, a));
42
+ var c = e.indexOf("?");
43
+ return c !== -1 && (n = e.substr(c), e = e.substr(0, c)), {
44
+ pathname: e,
45
+ search: n === "?" ? "" : n,
46
+ hash: s === "#" ? "" : s
47
+ };
48
+ }, Et = function(t) {
49
+ var e = t.pathname, n = t.search, s = t.hash, a = e || "/";
50
+ return n && n !== "?" && (a += n.charAt(0) === "?" ? n : "?" + n), s && s !== "#" && (a += s.charAt(0) === "#" ? s : "#" + s), a;
51
+ }, te = Object.assign || function(r) {
52
+ for (var t = 1; t < arguments.length; t++) {
53
+ var e = arguments[t];
54
+ for (var n in e)
55
+ Object.prototype.hasOwnProperty.call(e, n) && (r[n] = e[n]);
56
+ }
57
+ return r;
58
+ }, q = function(t, e, n, s) {
59
+ var a = void 0;
60
+ typeof t == "string" ? (a = Zt(t), a.state = e) : (a = te({}, t), a.pathname === void 0 && (a.pathname = ""), a.search ? a.search.charAt(0) !== "?" && (a.search = "?" + a.search) : a.search = "", a.hash ? a.hash.charAt(0) !== "#" && (a.hash = "#" + a.hash) : a.hash = "", e !== void 0 && a.state === void 0 && (a.state = e));
61
+ try {
62
+ a.pathname = decodeURI(a.pathname);
63
+ } catch (c) {
64
+ throw c instanceof URIError ? new URIError('Pathname "' + a.pathname + '" could not be decoded. This is likely caused by an invalid percent-encoding.') : c;
65
+ }
66
+ return n && (a.key = n), s ? a.pathname ? a.pathname.charAt(0) !== "/" && (a.pathname = Ct(a.pathname, s.pathname)) : a.pathname = s.pathname : a.pathname || (a.pathname = "/"), a;
67
+ }, kt = function() {
68
+ var t = null, e = function(h) {
69
+ return U(t == null, "A history supports only one prompt at a time"), t = h, function() {
70
+ t === h && (t = null);
71
+ };
72
+ }, n = function(h, d, b, v) {
73
+ if (t != null) {
74
+ var C = typeof t == "function" ? t(h, d) : t;
75
+ typeof C == "string" ? typeof b == "function" ? b(C, v) : (U(!1, "A history needs a getUserConfirmation function in order to use a prompt message"), v(!0)) : v(C !== !1);
76
+ } else
77
+ v(!0);
78
+ }, s = [], a = function(h) {
79
+ var d = !0, b = function() {
80
+ d && h.apply(void 0, arguments);
81
+ };
82
+ return s.push(b), function() {
83
+ d = !1, s = s.filter(function(v) {
84
+ return v !== b;
85
+ });
86
+ };
87
+ }, c = function() {
88
+ for (var h = arguments.length, d = Array(h), b = 0; b < h; b++)
89
+ d[b] = arguments[b];
90
+ s.forEach(function(v) {
91
+ return v.apply(void 0, d);
92
+ });
93
+ };
94
+ return {
95
+ setPrompt: e,
96
+ confirmTransitionTo: n,
97
+ appendListener: a,
98
+ notifyListeners: c
99
+ };
100
+ }, ee = !!(typeof window < "u" && window.document && window.document.createElement), pt = function(t, e, n) {
101
+ return t.addEventListener ? t.addEventListener(e, n, !1) : t.attachEvent("on" + e, n);
102
+ }, gt = function(t, e, n) {
103
+ return t.removeEventListener ? t.removeEventListener(e, n, !1) : t.detachEvent("on" + e, n);
104
+ }, ne = function(t, e) {
105
+ return e(window.confirm(t));
106
+ }, ae = function() {
107
+ var t = window.navigator.userAgent;
108
+ 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;
109
+ }, re = function() {
110
+ return window.navigator.userAgent.indexOf("Trident") === -1;
111
+ }, ie = function(t) {
112
+ return t.state === void 0 && navigator.userAgent.indexOf("CriOS") === -1;
113
+ }, mt = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(r) {
114
+ return typeof r;
115
+ } : function(r) {
116
+ return r && typeof Symbol == "function" && r.constructor === Symbol && r !== Symbol.prototype ? "symbol" : typeof r;
117
+ }, se = Object.assign || function(r) {
118
+ for (var t = 1; t < arguments.length; t++) {
119
+ var e = arguments[t];
120
+ for (var n in e)
121
+ Object.prototype.hasOwnProperty.call(e, n) && (r[n] = e[n]);
122
+ }
123
+ return r;
124
+ }, vt = "popstate", yt = "hashchange", wt = function() {
125
+ try {
126
+ return window.history.state || {};
127
+ } catch {
128
+ return {};
129
+ }
130
+ }, oe = function() {
131
+ var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
132
+ Gt(ee, "Browser history needs a DOM");
133
+ var e = window.history, n = ae(), s = !re(), a = t.forceRefresh, c = a === void 0 ? !1 : a, p = t.getUserConfirmation, h = p === void 0 ? ne : p, d = t.keyLength, b = d === void 0 ? 6 : d, v = t.basename ? Xt(Qt(t.basename)) : "", C = function(i) {
134
+ var l = i || {}, y = l.key, g = l.state, H = window.location, P = H.pathname, M = H.search, N = H.hash, T = P + M + N;
135
+ return U(!v || Ot(T, v), 'You are attempting to use a basename on a page whose URL path does not begin with the basename. Expected path "' + T + '" to begin with "' + v + '".'), v && (T = Jt(T, v)), q(T, g, y);
136
+ }, F = function() {
137
+ return Math.random().toString(36).substr(2, b);
138
+ }, D = kt(), B = function(i) {
139
+ se(f, i), f.length = e.length, D.notifyListeners(f.location, f.action);
140
+ }, R = function(i) {
141
+ ie(i) || W(C(i.state));
142
+ }, I = function() {
143
+ W(C(wt()));
144
+ }, j = !1, W = function(i) {
145
+ if (j)
146
+ j = !1, B();
147
+ else {
148
+ var l = "POP";
149
+ D.confirmTransitionTo(i, l, h, function(y) {
150
+ y ? B({ action: l, location: i }) : X(i);
151
+ });
152
+ }
153
+ }, X = function(i) {
154
+ var l = f.location, y = A.indexOf(l.key);
155
+ y === -1 && (y = 0);
156
+ var g = A.indexOf(i.key);
157
+ g === -1 && (g = 0);
158
+ var H = y - g;
159
+ H && (j = !0, S(H));
160
+ }, G = C(wt()), A = [G.key], m = function(i) {
161
+ return v + Et(i);
162
+ }, x = function(i, l) {
163
+ U(!((typeof i > "u" ? "undefined" : mt(i)) === "object" && i.state !== void 0 && l !== 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");
164
+ var y = "PUSH", g = q(i, l, F(), f.location);
165
+ D.confirmTransitionTo(g, y, h, function(H) {
166
+ if (H) {
167
+ var P = m(g), M = g.key, N = g.state;
168
+ if (n)
169
+ if (e.pushState({ key: M, state: N }, null, P), c)
170
+ window.location.href = P;
171
+ else {
172
+ var T = A.indexOf(f.location.key), tt = A.slice(0, T === -1 ? 0 : T + 1);
173
+ tt.push(g.key), A = tt, B({ action: y, location: g });
174
+ }
175
+ else
176
+ U(N === void 0, "Browser history cannot push state in browsers that do not support HTML5 history"), window.location.href = P;
177
+ }
178
+ });
179
+ }, w = function(i, l) {
180
+ U(!((typeof i > "u" ? "undefined" : mt(i)) === "object" && i.state !== void 0 && l !== 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");
181
+ var y = "REPLACE", g = q(i, l, F(), f.location);
182
+ D.confirmTransitionTo(g, y, h, function(H) {
183
+ if (H) {
184
+ var P = m(g), M = g.key, N = g.state;
185
+ if (n)
186
+ if (e.replaceState({ key: M, state: N }, null, P), c)
187
+ window.location.replace(P);
188
+ else {
189
+ var T = A.indexOf(f.location.key);
190
+ T !== -1 && (A[T] = g.key), B({ action: y, location: g });
191
+ }
192
+ else
193
+ U(N === void 0, "Browser history cannot replace state in browsers that do not support HTML5 history"), window.location.replace(P);
194
+ }
195
+ });
196
+ }, S = function(i) {
197
+ e.go(i);
198
+ }, E = function() {
199
+ return S(-1);
200
+ }, L = function() {
201
+ return S(1);
202
+ }, $ = 0, V = function(i) {
203
+ $ += i, $ === 1 ? (pt(window, vt, R), s && pt(window, yt, I)) : $ === 0 && (gt(window, vt, R), s && gt(window, yt, I));
204
+ }, _ = !1, O = function() {
205
+ var i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !1, l = D.setPrompt(i);
206
+ return _ || (V(1), _ = !0), function() {
207
+ return _ && (_ = !1, V(-1)), l();
208
+ };
209
+ }, u = function(i) {
210
+ var l = D.appendListener(i);
211
+ return V(1), function() {
212
+ V(-1), l();
213
+ };
214
+ }, f = {
215
+ length: e.length,
216
+ action: "POP",
217
+ location: G,
218
+ createHref: m,
219
+ push: x,
220
+ replace: w,
221
+ go: S,
222
+ goBack: E,
223
+ goForward: L,
224
+ block: O,
225
+ listen: u
226
+ };
227
+ return f;
228
+ }, Pt = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(r) {
229
+ return typeof r;
230
+ } : function(r) {
231
+ return r && typeof Symbol == "function" && r.constructor === Symbol && r !== Symbol.prototype ? "symbol" : typeof r;
232
+ }, ce = Object.assign || function(r) {
233
+ for (var t = 1; t < arguments.length; t++) {
234
+ var e = arguments[t];
235
+ for (var n in e)
236
+ Object.prototype.hasOwnProperty.call(e, n) && (r[n] = e[n]);
237
+ }
238
+ return r;
239
+ }, bt = function(t, e, n) {
240
+ return Math.min(Math.max(t, e), n);
241
+ }, he = function() {
242
+ var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, e = t.getUserConfirmation, n = t.initialEntries, s = n === void 0 ? ["/"] : n, a = t.initialIndex, c = a === void 0 ? 0 : a, p = t.keyLength, h = p === void 0 ? 6 : p, d = kt(), b = function(w) {
243
+ ce(m, w), m.length = m.entries.length, d.notifyListeners(m.location, m.action);
244
+ }, v = function() {
245
+ return Math.random().toString(36).substr(2, h);
246
+ }, C = bt(c, 0, s.length - 1), F = s.map(function(x) {
247
+ return typeof x == "string" ? q(x, void 0, v()) : q(x, void 0, x.key || v());
248
+ }), D = Et, B = function(w, S) {
249
+ U(!((typeof w > "u" ? "undefined" : Pt(w)) === "object" && w.state !== void 0 && S !== 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");
250
+ var E = "PUSH", L = q(w, S, v(), m.location);
251
+ d.confirmTransitionTo(L, E, e, function($) {
252
+ if ($) {
253
+ var V = m.index, _ = V + 1, O = m.entries.slice(0);
254
+ O.length > _ ? O.splice(_, O.length - _, L) : O.push(L), b({
255
+ action: E,
256
+ location: L,
257
+ index: _,
258
+ entries: O
259
+ });
260
+ }
261
+ });
262
+ }, R = function(w, S) {
263
+ U(!((typeof w > "u" ? "undefined" : Pt(w)) === "object" && w.state !== void 0 && S !== 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");
264
+ var E = "REPLACE", L = q(w, S, v(), m.location);
265
+ d.confirmTransitionTo(L, E, e, function($) {
266
+ $ && (m.entries[m.index] = L, b({ action: E, location: L }));
267
+ });
268
+ }, I = function(w) {
269
+ var S = bt(m.index + w, 0, m.entries.length - 1), E = "POP", L = m.entries[S];
270
+ d.confirmTransitionTo(L, E, e, function($) {
271
+ $ ? b({
272
+ action: E,
273
+ location: L,
274
+ index: S
275
+ }) : b();
276
+ });
277
+ }, j = function() {
278
+ return I(-1);
279
+ }, W = function() {
280
+ return I(1);
281
+ }, X = function(w) {
282
+ var S = m.index + w;
283
+ return S >= 0 && S < m.entries.length;
284
+ }, G = function() {
285
+ var w = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !1;
286
+ return d.setPrompt(w);
287
+ }, A = function(w) {
288
+ return d.appendListener(w);
289
+ }, m = {
290
+ length: F.length,
291
+ action: "POP",
292
+ location: F[C],
293
+ index: C,
294
+ entries: F,
295
+ createHref: D,
296
+ push: B,
297
+ replace: R,
298
+ go: I,
299
+ goBack: j,
300
+ goForward: W,
301
+ canGo: X,
302
+ block: G,
303
+ listen: A
304
+ };
305
+ return m;
306
+ };
307
+ const St = "hashchange", ue = {
308
+ hashbang: {
309
+ encodePath: (r) => r.charAt(0) === "!" ? r : "!/" + ut(r),
310
+ decodePath: (r) => r.charAt(0) === "!" ? r.substr(1) : r
311
+ },
312
+ noslash: {
313
+ encodePath: ut,
314
+ decodePath: nt
315
+ },
316
+ slash: {
317
+ encodePath: nt,
318
+ decodePath: nt
319
+ }
320
+ }, K = () => {
321
+ const r = window.location.href, t = r.indexOf("#");
322
+ return t === -1 ? "" : r.substring(t + 1);
323
+ }, xt = (r) => window.location.hash = r, Lt = (r) => {
324
+ const t = window.location.href.indexOf("#");
325
+ window.location.replace(
326
+ window.location.href.slice(0, t >= 0 ? t : 0) + "#" + r
327
+ );
328
+ }, at = (r = "") => {
329
+ const t = r.replace(";", "?"), e = [
330
+ { from: /\;+/gi, to: "&" },
331
+ { from: /:+/gi, to: "=" }
332
+ ];
333
+ let n = t;
334
+ return e.forEach(({ to: s, from: a }) => {
335
+ n = n.replace(a, s);
336
+ }), n;
337
+ }, fe = (r = {}) => {
338
+ const t = window.history, { getUserConfirmation: e = It, hashType: n = "slash" } = r, s = r.basename ? Dt(nt(r.basename)) : "", { encodePath: a } = ue[n], c = () => {
339
+ const u = K(), f = b(u);
340
+ return Z(f, at);
341
+ }, p = r.transitionManager || At(), h = (u) => {
342
+ Object.assign(O, u), O.length = t.length, p.notifyListeners(
343
+ O.location,
344
+ O.action,
345
+ r.widgetName
346
+ );
347
+ };
348
+ let d = !1;
349
+ const b = (u) => {
350
+ const f = (l) => {
351
+ function y(g, H) {
352
+ const P = {};
353
+ let M;
354
+ for (; M = H.exec(g); )
355
+ P[M[1]] = M[2];
356
+ return P;
357
+ }
358
+ return y(l, /([^#?&=]+)=([^&#]*)(?!.*?\#)/gi) || null;
359
+ }, o = "humany-" + r.widgetName;
360
+ return f(u)[o];
361
+ }, v = () => {
362
+ const u = c(), f = O.location;
363
+ !d && $t(f, u) || C(u);
364
+ }, C = (u) => {
365
+ if (d)
366
+ d = !1, h();
367
+ else {
368
+ const f = "POP";
369
+ p.confirmTransitionTo(
370
+ u,
371
+ f,
372
+ e,
373
+ (o) => {
374
+ o ? h({ action: f, location: u }) : F(u);
375
+ }
376
+ );
377
+ }
378
+ }, F = (u) => {
379
+ const f = O.location;
380
+ let o = R.lastIndexOf(Y(f));
381
+ o === -1 && (o = 0);
382
+ let i = R.lastIndexOf(Y(u));
383
+ i === -1 && (i = 0);
384
+ const l = o - i;
385
+ l && (d = !0, m(l));
386
+ }, D = K(), B = a(D);
387
+ D !== B && Lt(B);
388
+ let R = [];
389
+ const I = c();
390
+ I.pathname !== null && R.push(Y(I));
391
+ const j = (u = "") => {
392
+ const f = [
393
+ { from: /\?+/gi, to: ";" },
394
+ { from: /\&amp;+/gi, to: ";" },
395
+ { from: /\&+/gi, to: ";" },
396
+ { from: /=+/gi, to: ":" }
397
+ ];
398
+ let o = u;
399
+ return f.forEach(({ to: i, from: l }) => {
400
+ o = o.replace(l, i);
401
+ }), o;
402
+ }, W = (u, f, o) => {
403
+ let i = "", l = !1;
404
+ return u.split("&").forEach((g) => {
405
+ const H = g.split("="), P = H[0], M = H[1];
406
+ if (P === f) {
407
+ if (l = !0, o === null)
408
+ return;
409
+ i.length > 0 && (i += "&"), typeof o < "u" ? i += P + "=" + o : i += P;
410
+ } else
411
+ P && (i.length > 0 && (i += "&"), i += P + "=" + M);
412
+ }), !l && o !== null && (i.length > 0 && (i += "&"), typeof o < "u" ? i += f + "=" + o : i += f), i;
413
+ }, X = (u) => {
414
+ const f = u.pathname, o = j(u.search), i = f + (o ? `;${o}` : ""), y = `humany-${r.widgetName}`, g = K();
415
+ return `#${W(g, y, i).replace(
416
+ ";;",
417
+ ";"
418
+ )}`;
419
+ }, G = (u, f) => {
420
+ const o = "PUSH", i = Z(u, at), l = i.pathname, y = j(i.search), g = l + (y ? `${y}` : ""), P = `humany-${r.widgetName}`, M = K(), N = W(M, P, g);
421
+ p.confirmTransitionTo(
422
+ i,
423
+ o,
424
+ e,
425
+ (T) => {
426
+ if (!T)
427
+ return;
428
+ const tt = Y(i), ot = a(N);
429
+ if (K() !== ot) {
430
+ xt(ot);
431
+ const ct = R.lastIndexOf(Y(O.location)), ht = R.slice(
432
+ 0,
433
+ ct === -1 ? 0 : ct + 1
434
+ );
435
+ ht.push(tt), R = ht, h({ action: o, location: i });
436
+ } else
437
+ h();
438
+ }
439
+ );
440
+ }, A = (u, f) => {
441
+ const o = "REPLACE", i = Z(u, at);
442
+ p.confirmTransitionTo(
443
+ i,
444
+ o,
445
+ e,
446
+ (l) => {
447
+ if (!l)
448
+ return;
449
+ const y = Y(i), g = a(s + y);
450
+ K() !== g && Lt(g);
451
+ const P = R.indexOf(Y(O.location));
452
+ P !== -1 && (R[P] = y), h({ action: o, location: i });
453
+ }
454
+ );
455
+ }, m = (u) => {
456
+ t.go(u);
457
+ }, x = () => m(-1), w = () => m(1);
458
+ let S = 0;
459
+ const E = (u) => {
460
+ S += u, S === 1 ? window.addEventListener(St, v) : S === 0 && window.removeEventListener(St, v);
461
+ };
462
+ let L = !1;
463
+ const O = {
464
+ createHref: X,
465
+ createLocation: Z,
466
+ push: G,
467
+ replace: A,
468
+ go: m,
469
+ goBack: x,
470
+ goForward: w,
471
+ block: (u = !1) => {
472
+ const f = p.setPrompt(u);
473
+ return L || (E(1), L = !0), () => (L && (L = !1, E(-1)), f());
474
+ },
475
+ listen: (u) => {
476
+ const f = p.appendListener(u);
477
+ return E(1), () => {
478
+ E(-1), f();
479
+ };
480
+ },
481
+ stop: () => {
482
+ const u = K(), f = W(
483
+ u,
484
+ `humany-${r.widgetName}`,
485
+ null
486
+ ), o = a(f);
487
+ xt(o);
488
+ },
489
+ length: t.length,
490
+ action: "POP",
491
+ location: I
492
+ };
493
+ return O;
494
+ }, de = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
495
+ __proto__: null,
496
+ decodeSearch: at,
497
+ default: fe,
498
+ getHashPath: K
499
+ }, Symbol.toStringTag, { value: "Module" })), Ht = "routeData";
500
+ class Pe {
501
+ constructor(t, e) {
502
+ k(this, "settings");
503
+ k(this, "routes");
504
+ k(this, "steps", []);
505
+ k(this, "location");
506
+ k(this, "history");
507
+ k(this, "widget");
508
+ k(this, "match");
509
+ k(this, "currentRoute");
510
+ k(this, "historyListenSubscription", () => {
511
+ });
512
+ k(this, "initialized");
513
+ k(this, "sticky", !1);
514
+ k(this, "storageWriter", null);
515
+ k(this, "storageMedium");
516
+ this.container = t, this.widget = t.get("$widget");
517
+ const { routes: n, ...s } = e;
518
+ this.settings = { ...s, ...t.get("routingSettings") }, this.sticky = _t(this.settings), this.storageMedium = this.sticky ? ft.Local : ft.Session, Bt(t, Ht, Nt.Necessary, {
519
+ medium: this.storageMedium
520
+ }).then((a) => this.storageWriter = a), this.routes = n;
521
+ }
522
+ initialize() {
523
+ return this.initialized = this.initialized || this.createHistory().then((t) => {
524
+ this.history = t, this.location = t.location, this.historyListenSubscription = t.listen(
525
+ (e, n, s) => this.handleLocationChange(e, s)
526
+ );
527
+ });
528
+ }
529
+ setMatch(t) {
530
+ if (this.match = t, this.location) {
531
+ const e = this.getRouteData(), n = {
532
+ routeData: e,
533
+ location: this.location
534
+ }, s = this.steps[0], a = e.name === (s == null ? void 0 : s.routeData.name), c = dt(
535
+ e.params,
536
+ (s == null ? void 0 : s.routeData.params) || {}
537
+ );
538
+ (!a || !c) && (this.widget.events.dispatch("router:change", { next: n, previous: s }), this.steps.unshift(n), this.storageWriter && this.storageWriter(n.routeData), this.widget.events.dispatch("router:changed", {
539
+ previous: s,
540
+ current: n
541
+ }));
542
+ }
543
+ }
544
+ onRouteChange(t) {
545
+ return this.widget.events.subscribe("router:change", t);
546
+ }
547
+ isSticky() {
548
+ return this.sticky;
549
+ }
550
+ /**
551
+ * Generate a formatted path from string
552
+ * @param routeName Name of route to generate path for
553
+ * @param params Optional: route params
554
+ */
555
+ generate(t, e = {}) {
556
+ const n = rt(t, this.routes);
557
+ if (!n || !this.history)
558
+ throw `No route found for ${t}`;
559
+ const s = it(e, n.path);
560
+ if (!s)
561
+ throw `Unable to generate path for "${t}".`;
562
+ const a = Z(s, this.settings.decodeSearch);
563
+ let c = this.history.createHref(a);
564
+ const { mode: p, basePath: h } = this.settings;
565
+ return p === "browser" && h && (c = c.replace(h, "")), c.charAt(0) !== "/" && (c = `/${c}`), c;
566
+ }
567
+ /**
568
+ * Navigate to path
569
+ * @param routeName Route to navigate to
570
+ * @param params Optional: route params
571
+ */
572
+ navigate(t, e = {}) {
573
+ const n = rt(t, this.routes);
574
+ if (!n || !this.history)
575
+ return;
576
+ const s = it(e, n.path);
577
+ if (!s)
578
+ return;
579
+ const a = this.getRouteData(), c = a && a.name === t && Ut(a.params, e);
580
+ if (this.steps[0] && c)
581
+ return;
582
+ const { decodeSearch: h } = this.settings, d = h ? h(s) : s;
583
+ this.widget.events.dispatch("router:navigate", {
584
+ decodedPath: d
585
+ }), d.charAt(0) !== "/" ? this.history.push(`/${d}`) : this.history.push(d);
586
+ }
587
+ /**
588
+ * Return true or false depending
589
+ * on whether it is possible to navigate backwards
590
+ */
591
+ hasBack() {
592
+ if (this.steps.length > 1)
593
+ return !0;
594
+ const t = this.getRouteData(this.settings.initialPath), e = this.getRouteData(), n = e.name === t.name, s = dt(e.params, t.params);
595
+ return !n || !s;
596
+ }
597
+ /**
598
+ * Navigate to previous route
599
+ */
600
+ goBack(t = 1) {
601
+ if (this.steps.length < 2) {
602
+ const e = this.getRouteData(this.settings.initialPath);
603
+ e && e.name && (this.navigate(e.name, e.params), this.steps = []);
604
+ } else {
605
+ const e = t >= this.steps.length ? this.steps.length - 1 : t, { routeData: n } = this.steps[e];
606
+ this.steps = [...this.steps.slice(e + 1)], this.navigate(n.name, Yt(n.params));
607
+ }
608
+ }
609
+ /**
610
+ * Navigate to next route
611
+ */
612
+ goForward() {
613
+ this.history && this.history.goForward();
614
+ }
615
+ /**
616
+ * Get the current location
617
+ */
618
+ current() {
619
+ return this.location;
620
+ }
621
+ /**
622
+ * Get the initial route. If the defined initial route does not exist,
623
+ * return the first defined route
624
+ */
625
+ getInitialRoute() {
626
+ const { name: t } = this.getRouteData(this.settings.initialPath), e = this.routes.find((n) => n.name === t);
627
+ return e || (this.routes.length > 0 ? this.routes[0] : (process.env.NODE_ENV !== "production" && Ft.warn("Unable to get initial route as no routes are defined."), null));
628
+ }
629
+ getRouteData(t) {
630
+ const e = st(this.container);
631
+ if (t) {
632
+ const n = Q(t, this.routes);
633
+ return n ? {
634
+ params: lt(
635
+ et(t, n.path)
636
+ ),
637
+ name: n.name
638
+ } : e || {
639
+ name: "",
640
+ params: {}
641
+ };
642
+ }
643
+ if (this.location) {
644
+ const { pathname: n, search: s } = this.location;
645
+ if (this.currentRoute = this.currentRoute || Q(n, this.routes), this.currentRoute) {
646
+ const { path: a, name: c } = this.currentRoute;
647
+ this.match || (this.match = {
648
+ params: et(n, a),
649
+ isExact: !0,
650
+ path: a,
651
+ url: n
652
+ });
653
+ const p = lt({
654
+ ...this.match.params,
655
+ ...s.length > 0 && jt(s)
656
+ });
657
+ return {
658
+ name: c,
659
+ params: p
660
+ };
661
+ }
662
+ }
663
+ return e || {
664
+ name: "",
665
+ params: {}
666
+ };
667
+ }
668
+ dispose() {
669
+ return this.historyListenSubscription(), this.stop();
670
+ }
671
+ /**
672
+ * Setup and load the initial route based on router configuration
673
+ */
674
+ setupInitialRoute() {
675
+ return Wt(
676
+ this.container,
677
+ Ht,
678
+ this.storageMedium
679
+ ).then((t) => {
680
+ if (!this.location || !this.history)
681
+ return;
682
+ const { initialPath: e, mode: n } = this.settings;
683
+ switch ((() => {
684
+ const a = Kt(this.container);
685
+ return n === z.browser || a ? J.path : n === z.memory && t ? J.storage : J.initialPath;
686
+ })()) {
687
+ case J.initialPath: {
688
+ const a = this.getRouteData(e);
689
+ return a && a.name ? this.navigate(a.name, a.params) : void 0;
690
+ }
691
+ case J.path: {
692
+ const { pathname: a } = this.location;
693
+ if (this.currentRoute = Q(a, this.routes), this.currentRoute) {
694
+ const { path: p } = this.currentRoute;
695
+ return this.setMatch({
696
+ params: et(a, p),
697
+ isExact: !0,
698
+ path: p,
699
+ url: a
700
+ });
701
+ }
702
+ const c = st(this.container);
703
+ return c ? this.setMatch({
704
+ params: {},
705
+ isExact: !0,
706
+ path: c.name,
707
+ url: a
708
+ }) : void 0;
709
+ }
710
+ case J.storage: {
711
+ const { pathname: a } = this.location;
712
+ this.currentRoute = Q(a, this.routes);
713
+ const { name: c = "", params: p = {} } = t || {}, h = rt(c, this.routes);
714
+ if (h) {
715
+ const d = it(p, h.path);
716
+ if (d)
717
+ return this.history.push(d), this.location = { ...this.location, pathname: d }, this.currentRoute = Q(d, this.routes), this.setMatch({
718
+ params: p,
719
+ isExact: !0,
720
+ path: h.path,
721
+ url: d
722
+ });
723
+ }
724
+ return;
725
+ }
726
+ }
727
+ });
728
+ }
729
+ start() {
730
+ return this.setupInitialRoute();
731
+ }
732
+ stop() {
733
+ return this.history && (this.settings.mode === z.scopedHash && this.history.stop(), this.steps = [], this.storageWriter) ? this.storageWriter() : Promise.resolve();
734
+ }
735
+ handleLocationChange(t, e) {
736
+ const { pathname: n } = t, { mode: s } = this.settings;
737
+ if (n.indexOf("?") > -1 || n.indexOf(";") > -1 || s === z.scopedHash && e !== this.widget.name)
738
+ return;
739
+ this.location = t, this.currentRoute = Q(n, this.routes);
740
+ const a = st(this.container);
741
+ if (this.currentRoute) {
742
+ const { path: c } = this.currentRoute;
743
+ this.setMatch({
744
+ params: et(n, c),
745
+ isExact: !0,
746
+ path: c,
747
+ url: n
748
+ });
749
+ } else
750
+ a && this.setMatch({
751
+ params: {},
752
+ isExact: !0,
753
+ path: a.name,
754
+ url: n
755
+ });
756
+ }
757
+ createHistory() {
758
+ return new Promise((t) => {
759
+ const { mode: e, basePath: n } = this.settings;
760
+ if (e === z.scopedHash) {
761
+ const s = this.widget.name, a = Vt(this.container);
762
+ return Promise.resolve().then(() => de).then((c) => {
763
+ const p = c.default({
764
+ widgetName: s,
765
+ transitionManager: a,
766
+ hashType: "noslash"
767
+ });
768
+ return t(p);
769
+ });
770
+ }
771
+ if (e === z.memory)
772
+ return t(he());
773
+ if (e === z.browser)
774
+ return t(oe({ basename: n }));
775
+ throw "RoutingService: History could not be created.";
776
+ });
777
+ }
778
+ }
779
+ export {
780
+ z as HistoryMode,
781
+ Pe as RoutingService,
782
+ fe as createHashHistory,
783
+ xe as getScopedHashDOMLocation,
784
+ Le as getSpecificWidgetPath,
785
+ et as matchParams,
786
+ Kt as onWidgetUrl
787
+ };