@telia-ace/knowledge-widget-components-guide-category-dropdown 1.1.1-rc.2 → 1.1.1-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/guide-category-dropdown-2cb0c652.js +105 -0
- package/guide-category-dropdown-db6f2b55.mjs +301 -0
- package/index.js +1 -1
- package/index.mjs +76 -9
- package/package.json +6 -6
- package/guide-category-dropdown-6c4d5ab0.js +0 -105
- package/guide-category-dropdown-e6fca50c.mjs +0 -362
- package/index-373df3a5.js +0 -6
- package/index-5c9c2abf.mjs +0 -883
- package/index-77cc22b1.js +0 -1724
- package/index-a4f978a6.mjs +0 -7241
|
@@ -1,362 +0,0 @@
|
|
|
1
|
-
import { jsx as n, jsxs as b, Fragment as F } from "react/jsx-runtime";
|
|
2
|
-
import { css as k } from "@emotion/react";
|
|
3
|
-
import { E as O, C as G, u as R, a as A, c as C, f as $, l as H, b as P, d as W, B as K, e as U, g as q, h as J, T as I, S as v, i as Q, j as V, k as X, m as B } from "./index-a4f978a6.mjs";
|
|
4
|
-
import { useContext as Y, useState as T, useRef as Z, useCallback as M, useEffect as _ } from "react";
|
|
5
|
-
import "react-dom";
|
|
6
|
-
import "react-transition-group";
|
|
7
|
-
import x from "@emotion/styled";
|
|
8
|
-
import "react-router-dom";
|
|
9
|
-
const ee = (e, t) => e.get("seoConfiguration") ? /* @__PURE__ */ n(O, { ...t }) : null, L = () => Y(G), te = () => {
|
|
10
|
-
const [e, t] = T(!1), d = Z(), u = M(() => t(!0), [t]), s = M(() => t(!1), [t]);
|
|
11
|
-
return R("mouseenter", u, d.current), R("mouseleave", s, d.current), [e, d];
|
|
12
|
-
}, oe = (e, t, d, u, s, o) => {
|
|
13
|
-
const f = A();
|
|
14
|
-
if (!f)
|
|
15
|
-
return {
|
|
16
|
-
routeName: t,
|
|
17
|
-
params: {}
|
|
18
|
-
};
|
|
19
|
-
const { params: g } = f.getRouteData();
|
|
20
|
-
let r = {}, c = [];
|
|
21
|
-
if (u === "tag") {
|
|
22
|
-
const { tag: i, ...p } = g;
|
|
23
|
-
c = i ? i.split(",") : [], r = p;
|
|
24
|
-
} else {
|
|
25
|
-
const { guideCategory: i, uriName: p, ...y } = g;
|
|
26
|
-
c = [i], r = y;
|
|
27
|
-
}
|
|
28
|
-
if (d && (e.id === "0" || c.includes(e.id)) && c.length === 1 && (!s || s.id === "0") && Object.keys(r).length === 0) {
|
|
29
|
-
const i = f.getInitialRoute();
|
|
30
|
-
return {
|
|
31
|
-
routeName: (i == null ? void 0 : i.name) || t,
|
|
32
|
-
params: {}
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
let a = {};
|
|
36
|
-
const m = o ? o.findIndex((i) => i.id === e.id) : -1, l = c.includes(e.id);
|
|
37
|
-
if (u === "tag") {
|
|
38
|
-
const i = c.filter((y) => y !== e.id);
|
|
39
|
-
let p = [];
|
|
40
|
-
e.id === "0" ? p = [] : p = l ? i : [...c, e.id].filter((y) => y !== "0"), a = C({
|
|
41
|
-
...r,
|
|
42
|
-
tag: p
|
|
43
|
-
});
|
|
44
|
-
} else
|
|
45
|
-
o && m > 0 ? a = C({
|
|
46
|
-
...r,
|
|
47
|
-
guideCategory: o[m - 1].id,
|
|
48
|
-
uriName: $(o[m - 1].title)
|
|
49
|
-
}) : s ? a = C({
|
|
50
|
-
...r,
|
|
51
|
-
guideCategory: l ? s.id : e.id,
|
|
52
|
-
uriName: l ? $(s.title) : $(e.title)
|
|
53
|
-
}) : a = C({
|
|
54
|
-
...r,
|
|
55
|
-
uriName: l ? void 0 : $(e.title),
|
|
56
|
-
guideCategory: l ? void 0 : e.id
|
|
57
|
-
});
|
|
58
|
-
return typeof a.tag == "string" && (a.tag = a.tag.split(",")), {
|
|
59
|
-
routeName: t,
|
|
60
|
-
params: {
|
|
61
|
-
...a,
|
|
62
|
-
id: void 0,
|
|
63
|
-
guide: void 0,
|
|
64
|
-
contactMethod: void 0,
|
|
65
|
-
connectionKey: void 0,
|
|
66
|
-
connection: void 0
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
}, ne = x.div`
|
|
70
|
-
${H}
|
|
71
|
-
${P}
|
|
72
|
-
overflow: hidden;
|
|
73
|
-
min-height: 50px;
|
|
74
|
-
${(e) => e["data-toggler-in-focus"] && e.isTabbing && k`
|
|
75
|
-
&& {
|
|
76
|
-
${W(e)}
|
|
77
|
-
}
|
|
78
|
-
`};
|
|
79
|
-
`, ae = x.button`
|
|
80
|
-
background: none;
|
|
81
|
-
border: 0;
|
|
82
|
-
outline: 0;
|
|
83
|
-
display: block;
|
|
84
|
-
cursor: pointer;
|
|
85
|
-
padding: 0;
|
|
86
|
-
font-size: ${(e) => {
|
|
87
|
-
var t;
|
|
88
|
-
return (t = e.theme.fonts) == null ? void 0 : t.normal;
|
|
89
|
-
}};
|
|
90
|
-
text-align: end;
|
|
91
|
-
flex: 1 0 auto;
|
|
92
|
-
svg {
|
|
93
|
-
path,
|
|
94
|
-
line {
|
|
95
|
-
stroke: ${(e) => {
|
|
96
|
-
var t;
|
|
97
|
-
return (t = e.theme.colors) == null ? void 0 : t.text;
|
|
98
|
-
}};
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
`, j = (e) => {
|
|
102
|
-
var t, d, u, s, o, f, g, r;
|
|
103
|
-
return k`
|
|
104
|
-
font-size: ${(t = e.theme.fonts) == null ? void 0 : t.normal};
|
|
105
|
-
text-align: left;
|
|
106
|
-
text-align: left;
|
|
107
|
-
text-decoration: none;
|
|
108
|
-
font-weight: 300;
|
|
109
|
-
display: flex;
|
|
110
|
-
align-items: center;
|
|
111
|
-
padding: ${(d = e.theme.sizes) == null ? void 0 : d.small};
|
|
112
|
-
padding-left: ${(u = e.theme.sizes) == null ? void 0 : u.large};
|
|
113
|
-
cursor: pointer;
|
|
114
|
-
overflow: hidden;
|
|
115
|
-
${e.selected ? k`
|
|
116
|
-
border-left: 2px solid ${(s = e.theme.colors) == null ? void 0 : s.primary};
|
|
117
|
-
color: ${(o = e.theme.colors) == null ? void 0 : o.primary};
|
|
118
|
-
` : k`
|
|
119
|
-
color: ${(f = e.theme.colors) == null ? void 0 : f.text};
|
|
120
|
-
`};
|
|
121
|
-
|
|
122
|
-
span {
|
|
123
|
-
overflow: hidden;
|
|
124
|
-
text-overflow: ellipsis;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
i {
|
|
128
|
-
margin-right: ${(g = e.theme.sizes) == null ? void 0 : g.normal};
|
|
129
|
-
font-size: ${(r = e.theme.fonts) == null ? void 0 : r.medium};
|
|
130
|
-
min-height: 1em;
|
|
131
|
-
min-width: 1em;
|
|
132
|
-
}
|
|
133
|
-
`;
|
|
134
|
-
}, se = x.div`
|
|
135
|
-
${j}
|
|
136
|
-
`, re = x(K)`
|
|
137
|
-
${j}
|
|
138
|
-
&:focus {
|
|
139
|
-
outline: none;
|
|
140
|
-
}
|
|
141
|
-
&:focus-visible {
|
|
142
|
-
span {
|
|
143
|
-
${U};
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
`, ie = x.div`
|
|
147
|
-
display: flex;
|
|
148
|
-
justify-content: space-between;
|
|
149
|
-
padding-right: ${(e) => {
|
|
150
|
-
var t;
|
|
151
|
-
return (t = e.theme.sizes) == null ? void 0 : t.large;
|
|
152
|
-
}};
|
|
153
|
-
min-height: 52px;
|
|
154
|
-
white-space: nowrap;
|
|
155
|
-
|
|
156
|
-
&& {
|
|
157
|
-
font-weight: normal;
|
|
158
|
-
|
|
159
|
-
a {
|
|
160
|
-
font-weight: normal;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
.humany-guide-category-dropdown-item {
|
|
164
|
-
font-weight: normal;
|
|
165
|
-
}
|
|
166
|
-
`, le = x(q)`
|
|
167
|
-
${J}
|
|
168
|
-
display: flex;
|
|
169
|
-
justify-content: center;
|
|
170
|
-
flex-direction: column;
|
|
171
|
-
margin-right: ${(e) => {
|
|
172
|
-
var t;
|
|
173
|
-
return (t = e.theme.sizes) == null ? void 0 : t.medium;
|
|
174
|
-
}};
|
|
175
|
-
margin-left: ${(e) => {
|
|
176
|
-
var t;
|
|
177
|
-
return (t = e.theme.sizes) == null ? void 0 : t.large;
|
|
178
|
-
}};
|
|
179
|
-
margin-bottom: 22px;
|
|
180
|
-
border-left: ${(e) => e.theme.border};
|
|
181
|
-
li {
|
|
182
|
-
margin: 0 0 ${(e) => {
|
|
183
|
-
var t;
|
|
184
|
-
return (t = e.theme.sizes) == null ? void 0 : t.normal;
|
|
185
|
-
}} -2px;
|
|
186
|
-
}
|
|
187
|
-
li:last-child {
|
|
188
|
-
margin: 0 0 0 -2px;
|
|
189
|
-
}
|
|
190
|
-
flex-basis: 100%;
|
|
191
|
-
border-width: 2px;
|
|
192
|
-
`, de = x(I)`
|
|
193
|
-
margin: 0 0 0 ${(e) => {
|
|
194
|
-
var t;
|
|
195
|
-
return (t = e.theme.sizes) == null ? void 0 : t.small;
|
|
196
|
-
}};
|
|
197
|
-
`, h = {
|
|
198
|
-
Wrapper: ne,
|
|
199
|
-
Toggler: ae,
|
|
200
|
-
List: le,
|
|
201
|
-
Item: se,
|
|
202
|
-
Link: re,
|
|
203
|
-
TopItem: ie,
|
|
204
|
-
MatchCount: de
|
|
205
|
-
}, z = ({ matches: e }) => {
|
|
206
|
-
const { showMatchCount: t = !1 } = L();
|
|
207
|
-
return !t || typeof e > "u" ? null : /* @__PURE__ */ b(h.MatchCount, { children: [
|
|
208
|
-
"(",
|
|
209
|
-
e,
|
|
210
|
-
")"
|
|
211
|
-
] });
|
|
212
|
-
}, ce = ({ item: e, guideCategory: t }) => {
|
|
213
|
-
const {
|
|
214
|
-
route: d = "browse",
|
|
215
|
-
categoryAriaLabel: u = "",
|
|
216
|
-
activeCategoryAriaLabel: s = "",
|
|
217
|
-
fallbackOnInitialRoute: o = !1
|
|
218
|
-
} = L(), [f, g] = te(), { id: r, title: c, symbol: a, activeSymbol: m } = e, l = t === r;
|
|
219
|
-
return /* @__PURE__ */ n("li", { ref: g, children: /* @__PURE__ */ b(
|
|
220
|
-
h.Link,
|
|
221
|
-
{
|
|
222
|
-
...oe(e, d, o, "category"),
|
|
223
|
-
"aria-pressed": l,
|
|
224
|
-
"aria-label": (l ? s : u).replace(
|
|
225
|
-
"{{category}}",
|
|
226
|
-
c
|
|
227
|
-
),
|
|
228
|
-
className: "humany-guide-category-dropdown-link",
|
|
229
|
-
"aria-current": l,
|
|
230
|
-
selected: l,
|
|
231
|
-
children: [
|
|
232
|
-
(l || f) && m ? /* @__PURE__ */ n(v, { symbol: m }) : a && /* @__PURE__ */ n(v, { symbol: a }),
|
|
233
|
-
/* @__PURE__ */ n(I, { children: c }),
|
|
234
|
-
/* @__PURE__ */ n(z, { ...e })
|
|
235
|
-
]
|
|
236
|
-
}
|
|
237
|
-
) });
|
|
238
|
-
}, xe = ({ className: e, ...t }) => {
|
|
239
|
-
const d = Q(), [u, s] = T(!1), {
|
|
240
|
-
parent: o,
|
|
241
|
-
route: f = "browse",
|
|
242
|
-
categories: g = [],
|
|
243
|
-
loading: r = !1
|
|
244
|
-
} = L(), c = V(), [a, m] = T(!1), { params: l } = d, i = X(), { guideCategory: p, tag: y, phrase: D, sorting: E } = l;
|
|
245
|
-
if (_(() => {
|
|
246
|
-
a && m(!1);
|
|
247
|
-
}, [p]), r || !o || !g.length)
|
|
248
|
-
return ee(c, {
|
|
249
|
-
...t,
|
|
250
|
-
className: B(e, "humany-guide-category-dropdown")
|
|
251
|
-
});
|
|
252
|
-
const w = g.find((N) => N.id === p) || o, S = w.activeSymbol || w.symbol;
|
|
253
|
-
return /* @__PURE__ */ n(
|
|
254
|
-
h.Wrapper,
|
|
255
|
-
{
|
|
256
|
-
...t,
|
|
257
|
-
"data-loading": !1,
|
|
258
|
-
"data-toggler-in-focus": u,
|
|
259
|
-
"aria-expanded": a,
|
|
260
|
-
isTabbing: i,
|
|
261
|
-
className: B(e, "humany-guide-category-dropdown"),
|
|
262
|
-
children: a ? /* @__PURE__ */ b(F, { children: [
|
|
263
|
-
/* @__PURE__ */ b(h.TopItem, { className: "humany-guide-category-dropdown-top-item", children: [
|
|
264
|
-
/* @__PURE__ */ b(
|
|
265
|
-
h.Link,
|
|
266
|
-
{
|
|
267
|
-
className: "humany-guide-category-dropdown-link",
|
|
268
|
-
routeName: f,
|
|
269
|
-
params: C({
|
|
270
|
-
tag: y,
|
|
271
|
-
phrase: D,
|
|
272
|
-
sorting: E,
|
|
273
|
-
guideCategory: o.id,
|
|
274
|
-
uriName: $(o.title)
|
|
275
|
-
}),
|
|
276
|
-
selected: !1,
|
|
277
|
-
children: [
|
|
278
|
-
o.symbol ? /* @__PURE__ */ n(v, { symbol: o.symbol }) : null,
|
|
279
|
-
/* @__PURE__ */ n(I, { children: o.title }),
|
|
280
|
-
/* @__PURE__ */ n(z, { ...o })
|
|
281
|
-
]
|
|
282
|
-
}
|
|
283
|
-
),
|
|
284
|
-
/* @__PURE__ */ n(
|
|
285
|
-
h.Toggler,
|
|
286
|
-
{
|
|
287
|
-
onBlur: () => s(!1),
|
|
288
|
-
onFocus: () => s(!0),
|
|
289
|
-
className: "humany-guide-category-dropdown-toggler",
|
|
290
|
-
onClick: () => {
|
|
291
|
-
m(!a);
|
|
292
|
-
},
|
|
293
|
-
"aria-expanded": "true",
|
|
294
|
-
"aria-label": w.title,
|
|
295
|
-
children: /* @__PURE__ */ n(
|
|
296
|
-
v,
|
|
297
|
-
{
|
|
298
|
-
size: 18,
|
|
299
|
-
symbol: { type: "Svg", content: "caret-up" }
|
|
300
|
-
}
|
|
301
|
-
)
|
|
302
|
-
}
|
|
303
|
-
)
|
|
304
|
-
] }),
|
|
305
|
-
/* @__PURE__ */ n(
|
|
306
|
-
h.List,
|
|
307
|
-
{
|
|
308
|
-
className: "humany-guide-category-dropdown-open",
|
|
309
|
-
items: g,
|
|
310
|
-
renderItem: (N) => /* @__PURE__ */ n(
|
|
311
|
-
ce,
|
|
312
|
-
{
|
|
313
|
-
item: N,
|
|
314
|
-
guideCategory: p
|
|
315
|
-
},
|
|
316
|
-
N.id
|
|
317
|
-
)
|
|
318
|
-
}
|
|
319
|
-
)
|
|
320
|
-
] }) : /* @__PURE__ */ b(h.TopItem, { className: "humany-guide-category-dropdown-top-item", children: [
|
|
321
|
-
/* @__PURE__ */ b(
|
|
322
|
-
h.Item,
|
|
323
|
-
{
|
|
324
|
-
className: "humany-guide-category-dropdown-item",
|
|
325
|
-
onClick: () => {
|
|
326
|
-
m(!a);
|
|
327
|
-
},
|
|
328
|
-
selected: !1,
|
|
329
|
-
children: [
|
|
330
|
-
S ? /* @__PURE__ */ n(v, { symbol: S }) : null,
|
|
331
|
-
/* @__PURE__ */ n(I, { children: w.title }),
|
|
332
|
-
/* @__PURE__ */ n(z, { ...w })
|
|
333
|
-
]
|
|
334
|
-
}
|
|
335
|
-
),
|
|
336
|
-
/* @__PURE__ */ n(
|
|
337
|
-
h.Toggler,
|
|
338
|
-
{
|
|
339
|
-
onBlur: () => s(!1),
|
|
340
|
-
onFocus: () => s(!0),
|
|
341
|
-
className: "humany-guide-category-dropdown-toggler",
|
|
342
|
-
onClick: () => {
|
|
343
|
-
m(!a);
|
|
344
|
-
},
|
|
345
|
-
"aria-expanded": "false",
|
|
346
|
-
"aria-label": w.title,
|
|
347
|
-
children: /* @__PURE__ */ n(
|
|
348
|
-
v,
|
|
349
|
-
{
|
|
350
|
-
size: 18,
|
|
351
|
-
symbol: { type: "Svg", content: "caret-down" }
|
|
352
|
-
}
|
|
353
|
-
)
|
|
354
|
-
}
|
|
355
|
-
)
|
|
356
|
-
] })
|
|
357
|
-
}
|
|
358
|
-
);
|
|
359
|
-
};
|
|
360
|
-
export {
|
|
361
|
-
xe as default
|
|
362
|
-
};
|
package/index-373df3a5.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var p=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof global<"u"&&global||{},b={searchParams:"URLSearchParams"in p,iterable:"Symbol"in p&&"iterator"in Symbol,blob:"FileReader"in p&&"Blob"in p&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in p,arrayBuffer:"ArrayBuffer"in p};function re(t){return t&&DataView.prototype.isPrototypeOf(t)}if(b.arrayBuffer)var ne=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],se=ArrayBuffer.isView||function(t){return t&&ne.indexOf(Object.prototype.toString.call(t))>-1};function S(t){if(typeof t!="string"&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||t==="")throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function M(t){return typeof t!="string"&&(t=String(t)),t}function G(t){var e={next:function(){var r=t.shift();return{done:r===void 0,value:r}}};return b.iterable&&(e[Symbol.iterator]=function(){return e}),e}function d(t){this.map={},t instanceof d?t.forEach(function(e,r){this.append(r,e)},this):Array.isArray(t)?t.forEach(function(e){if(e.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+e.length);this.append(e[0],e[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}d.prototype.append=function(t,e){t=S(t),e=M(e);var r=this.map[t];this.map[t]=r?r+", "+e:e};d.prototype.delete=function(t){delete this.map[S(t)]};d.prototype.get=function(t){return t=S(t),this.has(t)?this.map[t]:null};d.prototype.has=function(t){return this.map.hasOwnProperty(S(t))};d.prototype.set=function(t,e){this.map[S(t)]=M(e)};d.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)};d.prototype.keys=function(){var t=[];return this.forEach(function(e,r){t.push(r)}),G(t)};d.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),G(t)};d.prototype.entries=function(){var t=[];return this.forEach(function(e,r){t.push([r,e])}),G(t)};b.iterable&&(d.prototype[Symbol.iterator]=d.prototype.entries);function L(t){if(!t._noBody){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}}function W(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function oe(t){var e=new FileReader,r=W(e);return e.readAsArrayBuffer(t),r}function ie(t){var e=new FileReader,r=W(e),n=/charset=([A-Za-z0-9_-]+)/.exec(t.type),o=n?n[1]:"utf-8";return e.readAsText(t,o),r}function ae(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}function V(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function K(){return this.bodyUsed=!1,this._initBody=function(t){this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?typeof t=="string"?this._bodyText=t:b.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:b.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:b.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():b.arrayBuffer&&b.blob&&re(t)?(this._bodyArrayBuffer=V(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):b.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||se(t))?this._bodyArrayBuffer=V(t):this._bodyText=t=Object.prototype.toString.call(t):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof t=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):b.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},b.blob&&(this.blob=function(){var t=L(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=L(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else{if(b.blob)return this.blob().then(oe);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var t=L(this);if(t)return t;if(this._bodyBlob)return ie(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(ae(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},b.formData&&(this.formData=function(){return this.text().then(ue)}),this.json=function(){return this.text().then(JSON.parse)},this}var ce=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function he(t){var e=t.toUpperCase();return ce.indexOf(e)>-1?e:t}function j(t,e){if(!(this instanceof j))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');e=e||{};var r=e.body;if(t instanceof j){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new d(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,!r&&t._bodyInit!=null&&(r=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",(e.headers||!this.headers)&&(this.headers=new d(e.headers)),this.method=he(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal||function(){if("AbortController"in p){var s=new AbortController;return s.signal}}(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&r)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(r),(this.method==="GET"||this.method==="HEAD")&&(e.cache==="no-store"||e.cache==="no-cache")){var n=/([?&])_=[^&]*/;if(n.test(this.url))this.url=this.url.replace(n,"$1_="+new Date().getTime());else{var o=/\?/;this.url+=(o.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}j.prototype.clone=function(){return new j(this,{body:this._bodyInit})};function ue(t){var e=new FormData;return t.trim().split("&").forEach(function(r){if(r){var n=r.split("="),o=n.shift().replace(/\+/g," "),s=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(o),decodeURIComponent(s))}}),e}function fe(t){var e=new d,r=t.replace(/\r?\n[\t ]+/g," ");return r.split("\r").map(function(n){return n.indexOf(`
|
|
2
|
-
`)===0?n.substr(1,n.length):n}).forEach(function(n){var o=n.split(":"),s=o.shift().trim();if(s){var a=o.join(":").trim();try{e.append(s,a)}catch(c){console.warn("Response "+c.message)}}}),e}K.call(j.prototype);function P(t,e){if(!(this instanceof P))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(e||(e={}),this.type="default",this.status=e.status===void 0?200:e.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=e.statusText===void 0?"":""+e.statusText,this.headers=new d(e.headers),this.url=e.url||"",this._initBody(t)}K.call(P.prototype);P.prototype.clone=function(){return new P(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})};P.error=function(){var t=new P(null,{status:200,statusText:""});return t.status=0,t.type="error",t};var le=[301,302,303,307,308];P.redirect=function(t,e){if(le.indexOf(e)===-1)throw new RangeError("Invalid status code");return new P(null,{status:e,headers:{location:t}})};var O=p.DOMException;try{new O}catch{O=function(e,r){this.message=e,this.name=r;var n=Error(e);this.stack=n.stack},O.prototype=Object.create(Error.prototype),O.prototype.constructor=O}function Y(t,e){return new Promise(function(r,n){var o=new j(t,e);if(o.signal&&o.signal.aborted)return n(new O("Aborted","AbortError"));var s=new XMLHttpRequest;function a(){s.abort()}s.onload=function(){var i={statusText:s.statusText,headers:fe(s.getAllResponseHeaders()||"")};o.url.startsWith("file://")&&(s.status<200||s.status>599)?i.status=200:i.status=s.status,i.url="responseURL"in s?s.responseURL:i.headers.get("X-Request-URL");var u="response"in s?s.response:s.responseText;setTimeout(function(){r(new P(u,i))},0)},s.onerror=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},s.ontimeout=function(){setTimeout(function(){n(new TypeError("Network request timed out"))},0)},s.onabort=function(){setTimeout(function(){n(new O("Aborted","AbortError"))},0)};function c(i){try{return i===""&&p.location.href?p.location.href:i}catch{return i}}if(s.open(o.method,c(o.url),!0),o.credentials==="include"?s.withCredentials=!0:o.credentials==="omit"&&(s.withCredentials=!1),"responseType"in s&&(b.blob?s.responseType="blob":b.arrayBuffer&&(s.responseType="arraybuffer")),e&&typeof e.headers=="object"&&!(e.headers instanceof d||p.Headers&&e.headers instanceof p.Headers)){var h=[];Object.getOwnPropertyNames(e.headers).forEach(function(i){h.push(S(i)),s.setRequestHeader(i,M(e.headers[i]))}),o.headers.forEach(function(i,u){h.indexOf(u)===-1&&s.setRequestHeader(u,i)})}else o.headers.forEach(function(i,u){s.setRequestHeader(u,i)});o.signal&&(o.signal.addEventListener("abort",a),s.onreadystatechange=function(){s.readyState===4&&o.signal.removeEventListener("abort",a)}),s.send(typeof o._bodyInit>"u"?null:o._bodyInit)})}Y.polyfill=!0;p.fetch||(p.fetch=Y,p.Headers=d,p.Request=j,p.Response=P);self.fetch.bind(self);const F="functional",U="Humany__parameters";function de(t){const e={};return t&&Object.keys(t).forEach(r=>{const n=t[r];(_(n)==="array"?n:[n]).forEach(o=>{typeof e[r]>"u"&&(e[r]=[]),e[r].push(o)})}),e}class pe{constructor(e,r){this.isLoaded=!!e,this.parameters=de(e),r&&typeof r.get=="function"&&(this.container=r)}getAll(){return this.ensureIsLoaded(),l(!0,{},this.parameters)}add(e,r){this.ensureIsLoaded(),this.parameters[e]||(this.parameters[e]=[]),this.parameters[e].push(r),this.persist()}set(e,r){this.ensureIsLoaded(),this.parameters[e]=[r],this.persist()}remove(e,r){if(this.ensureIsLoaded(),typeof r>"u")delete this.parameters[e];else{const n=this.parameters[e]||[];n.forEach((o,s)=>{o===r&&n.splice(s,1)}),this.parameters[e]=n}this.persist()}clear(){this.ensureIsLoaded(),this.parameters={},this.persist()}persist(){try{R(this.container).indexOf(F)>-1?C(U,this.parameters,1):C(U,"",-1)}catch(e){window.console&&window.console.warn&&window.console.warn("Error occured when persisting parameter bag.",e)}}ensureIsLoaded(){if(!this.isLoaded){try{const e=q(U);this.parameters=e||{},R(this.container).indexOf(F)===-1&&C(U,"",-1)}catch(e){window.console&&window.console.warn&&window.console.warn("Error occured when loading parameter bag.",e)}this.isLoaded=!0}}}function E(){return Math.floor((1+Math.random())*65536).toString(16).substring(1)}function z(){return E()+E()+"-"+E()+"-"+E()+"-"+E()+"-"+E()+E()+E()}const Z="analytical",k="Humany__clientId";let T="";function ye(t){if(R(t).indexOf(Z)===-1)return C(k,"",-1),T.length||(T=z()),T;const e=q(k);return e||(T.length||(T=z()),C(k,T,1)),e||T}function be(){return"Default"}function me(...t){const e=window.location;return[t[0]!==!1?"http:":e.protocol,"//",e.host,e.pathname].join("")}function ge(){}const we={"[object Array]":"array","[object Boolean]":"boolean","[object Date]":"date","[object Function]":"function","[object Number]":"number","[object Object]":"object","[object RegExp]":"regexp","[object String]":"string"};function _(t){return t==null?t+"":typeof t=="object"||typeof t=="function"?we[{}.toString.call(t)]||"object":typeof t}function f(t){return _(t)==="function"}function J(t){let e;if(!t||_(t)!=="object"||t.nodeType)return!1;try{if(t.constructor&&!Object.prototype.hasOwnProperty.call(t,"constructor")&&!Object.prototype.hasOwnProperty.call(t.constructor.prototype,"isPrototypeOf"))return!1}catch{return!1}for(e in t);return e===void 0||Object.prototype.hasOwnProperty.call(t,e)}function l(...t){let e,r,n,o,s,a,c=t[0]||{},h=1;const i=t.length;let u=!1;for(typeof c=="boolean"&&(u=c,c=t[1]||{},h=2),typeof c!="object"&&!f(c)&&(c={});h<i;h++)if((e=t[h])!=null)for(r in e)n=c[r],o=e[r],c!==o&&(u&&o&&(J(o)||(s=_(o)==="array"))?(s?(s=!1,a=n&&_(n)==="array"?n:[]):a=n&&J(n)?n:{},c[r]=l(u,a,o)):o!==void 0&&(c[r]=o));return c}const q=t=>{const e=new RegExp(`(?:^|;)\\s?${t}=(.*?)(?:;|$)`,"i"),r=document.cookie.match(e),n=r&&r[1];if(n){if(t==="Humany__clientId")try{return JSON.parse(n)}catch{const s=JSON.stringify(n);return JSON.parse(s)}return JSON.parse(n)}},C=(t,e,r)=>{const n=JSON.stringify(e).trim().replace(/^"+|"+$/g,""),o=`${t}=${n}`,s=`expires=${ve(r)}`,a="path=/",c="SameSite=None",h="Secure";return document.cookie=`${o}; ${s}; ${a}; ${c}; ${h}`},R=t=>{const e=["necessary"];if(!t)return e;const r=t.get("$widget");if(!r||!r.implementation||!r.implementation.tenant)return e;const{implementation:{tenant:n}}=r,o=q(`humany_${n}`);return!o||!o.storagePolicy||!o.storagePolicy.value||!Array.isArray(o.storagePolicy.value)||!o.storagePolicy.value.length?e:o.storagePolicy.value},ve=(t=1)=>{const e=new Date;return e.setTime(e.getTime()+t*24*60*60*1e3),e.toUTCString()},Pe=(t=["necessary"])=>{t.indexOf(F)===-1&&C(U,"",-1),t.indexOf(Z)===-1&&C(k,"",-1)};function $(t,e,r){if(typeof e>"u"||typeof r>"u")return t;const n=t&&t.indexOf("?")!==-1?"&":"?";return`${t}${n}${encodeURIComponent(e)}=${encodeURIComponent(r)}`}const X="p.";function ee(t,e){let r=t;return Object.keys(e).forEach(n=>{const o=e[n];_(o)==="array"?o.forEach(s=>{r=$(r,`${X}${n}`,s)}):r=$(r,`${X}${n}`,o)}),r}class Q{constructor(e,r){l(!0,this,e,{_client:r})}}class H{constructor(e,r){l(!0,this,e,{_client:r})}}function A(t,e,r,n){const o=[];return t[e].forEach(s=>{const a=new r(s,n),c=s[e],h=_(c);s[e]&&(h==="array"||h==="object")&&(a[e]=A(s,e,r,n)),o.push(a)}),o}class N{constructor(e,r){l(!0,this,e,{_client:r})}}function x(t,e){return f(t)?e?t.call(e):t.call(window):t}function I(t,e,r,n){let o=Promise.resolve(r);for(let s=0,a=t.length;s<a;s++){const c=t[s][e];f(c)&&(o=o.then(()=>c(r,n)))}return o}class Ee{constructor(e,r={}){this.setBaseUrl(e),this.globalOptions=r,this.interceptors=r.interceptors||[]}constructUrl(e){return this.baseUrl+e}setBaseUrl(e){this.baseUrl=e+(e[e.length-1]!=="/"?"/":"")}request(e,r){const n=l(!0,{},this.globalOptions,r);let o=this.constructUrl(e);const s=this.interceptors;return n.credentials==="include"&&(o=$(o,"credentials","true")),new Promise((a,c)=>{I(s,"request",{url:o,options:n}).then(h=>fetch(h.url,h.options).then(i=>({response:i,request:h}))).then(({response:h,request:i})=>{if(h.ok){const u=h;return h.json().then(w=>{I(s,"response",{response:h,json:w,request:i}).then(()=>{n.envelope?a({json:w,response:u}):a(w),I(s,"responseEnd",{response:h,json:w,request:i})})})}else I(s,"responseError",h).then(u=>{f(n.onError)&&n.onError(u),c(u)})}).catch(h=>{I(s,"responseError",h).then(i=>{f(n.onError)&&n.onError(i),c(i)})})})}}const te=Ee;/*!
|
|
3
|
-
* Humany Service Client Library
|
|
4
|
-
* Version: 2.0
|
|
5
|
-
* Copyright 2017, Telia Company AB, http://www.humany.com/
|
|
6
|
-
*/class B{constructor(...e){const r=e[1]||{};if(this.proxy=typeof e[0]=="string"?new te(e[0]):e[0],this.settings=l(!0,{},B.defaults,e[1]||{}),this.parameters=new pe(e[2],e[3]),this.current={phrase:r.phrase},this.guideCache={},this.feedbackTypes={positive:"Positive",negative:"Negative",comment:"Comment"},this.handoverTypes={email:"Email",chat:"Chat",callback:"Callback",phone:"Phone",emailComplementary:"ComplementaryEmail",chatComplementary:"ComplementaryChat",callbackComplementary:"ComplementaryCallback",phoneComplementary:"ComplementaryPhone"},this.subscriptions=[],e[3]&&typeof e[3].get=="function"){this.container=e[3];const n=this.container.get("$widget");n&&n.events&&this.subscriptions.push(n.events.subscribe("storage:policy-changed",(o,s)=>Pe(s)))}}getConfiguration(){return{language:x(this.settings.language,this),client:x(()=>this.settings.client(this.container),this),funnel:x(this.settings.funnel,this),site:x(this.settings.site,this),reader:x(this.settings.reader,this),perspective:x(this.settings.perspective,this)}}customRequest(e,r,n={}){const o=n.configuration||{},s=n.parameters;return e=this.constructPath(e,o,s),this.proxy.request(e,{method:r,body:n.body}).then(a=>(n.success&&n.success(a),a)).catch(a=>(n.error&&n.error(a),a))}constructPath(e,r,n=!0){let o=e;const s=l(this.getConfiguration(),r);if(Object.keys(s).filter(a=>{const c=s[a];return c!==null&&typeof c<"u"}).forEach(a=>o=$(o,a,x(s[a]))),n){const a=n===!0?this.parameters.getAll():n;o=ee(o,a)}return o}match(...e){const r=e[0];let n={},o,s;typeof e[1]=="object"?(n=e[1]||{},o=e[2],s=e[3]):(o=e[1],s=e[2]);function a(y){if(f(o)){const v=this;y=this.settings.useProxyClasses&&y?(()=>(y.Matches=A(y,"Matches",N,v),y))():y,o(y)}return y}function c(y){f(s)&&s(y)}const h=l(!0,this.getConfiguration(),this.settings.paging,n),i={};let u="GET";i.categories=h.categories||h.categoryId,i.language=h.language,i.phrase=r,i.attributes=h.attributes,i.skip=h.skip,i.take=h.take,i.reader=h.reader,i.disableNotices=h.disableNotices,i.tags=h.tags,i.includeCategories=h.includeCategories,i.groupByCategory=h.groupByCategory,n.statisticsDisabled||(u="POST",i.funnel=h.funnel,i.client=h.client,i.site=h.site,this.current.phrase=r);const w="guides";n.sorting&&(i["sorting.type"]=n.sorting.type,i["sorting.direction"]=n.sorting.direction);const m=this.constructPath(w,i);return this.proxy.request(m,{method:u}).then(a.bind(this)).catch(c.bind(this))}getGuide(...e){const r=e[0];let n,o={},s,a;typeof e[1]=="function"?(s=e[1],a=e[2]):typeof e[1]=="object"?(o=e[1]||{},s=e[2],a=e[3]):typeof e[1]=="string"?(n=e[1],typeof e[2]=="function"?(s=e[2],a=e[3]):(o=e[2]||{},s=e[3],a=e[4])):!e[1]&&typeof e[2]=="function"&&(s=e[2],a=e[3]);function c(v){if(f(s)){const g=this.settings.useProxyClasses&&v?new N(v,this):v;this.guideCache[g.Id]=g,s(g)}return v}function h(v){return f(a)&&a(v),Promise.reject(v)}const i=l(!0,this.getConfiguration(),o),u={};let w="GET";u.connectionId=n||i.connectionId,u.perspective=i.perspective,u.reader=i.reader,u.phrase=this.current.phrase,this.parameters.remove("LastGuideId"),this.parameters.add("LastGuideId",r);let m=`guides/${r}`;u.connectionId&&(m+=`/${u.connectionId}`);let y="";return!o.statisticsDisabled&&!u.connectionId?(w="POST",y=this.constructPath(m,l({},this.current,o))):y=this.constructPath(m,l({},this.current,o),!1),this.proxy.request(y,{method:w}).then(c.bind(this)).catch(h.bind(this))}getCategories(...e){let r={},n,o;typeof e[0]=="object"?(r=e[0]||{},n=e[1],o=e[2]):(n=e[0],o=e[1]);function s(i){if(f(n)){const u=this;i=this.settings.useProxyClasses&&i?(()=>(i.Children=A(i,"Children",Q,u),i))():i,n(i)}return i}function a(i){f(o)&&o(i)}let c="categories";r.categoryId&&(c+="/"+r.categoryId);const h=this.constructPath(c,l({},this.current,r));return this.proxy.request(h,{method:"GET"}).then(s.bind(this)).catch(a.bind(this))}answer(...e){const r=e[0],n=e[1];let o={},s,a,c;typeof e[2]=="object"?(o=e[2]||{},s=e[3],a=e[4]):(s=e[2],a=e[3]);const h=!!o.persist;function i(){!h&&c&&this.parameters.remove(c.Condition.ParameterName,c.Condition.Value)}function u(g){if(i(),f(s)){const D=this.settings.useProxyClasses&&g?new N(g,this):g;this.guideCache[D.Id]=D,s(D)}}function w(g){i(),f(a)&&a(g)}const m=this.guideCache[r];m.Options&&m.Options.forEach(g=>{this.parameters.remove(g.Condition.ParameterName,g.Condition.Value),g.ConnectionId===n&&(c=g)}),this.parameters.add(c.Condition.ParameterName,c.Condition.Value);const y=`guides/${r}/${n}`,v=this.constructPath(y,l({},this.current,o));return this.proxy.request(v,{method:"GET"}).then(u.bind(this)).catch(w.bind(this))}giveFeedback(...e){const r=e[0];let n,o,s={},a,c;typeof e[2]=="string"?(n=e[1],o=e[2],typeof e[3]=="object"?(s=e[3]||{},a=e[4],c=e[5]):(a=e[3],c=e[4])):(o=e[1],typeof e[2]=="object"&&(s=e[2]||{},a=e[3],c=e[4]));function h(m){return f(a)&&a(m),m}function i(m){return f(c)&&c(m),m}const u=`guides/${r}${n?"/"+n:""}/feedback`,w=this.constructPath(u,l({},s,{feedbackType:o}));return this.proxy.request(w,{method:"POST"}).then(h.bind(this)).catch(i.bind(this))}completeContactMethod(...e){const r=e[0];let n={},o,s;typeof e[1]=="object"?(n=e[1],o=e[2],s=e[3]):(o=e[1],s=e[2]);function a(u){f(o)&&o(u)}function c(u){f(s)&&s(u)}const h=`contactmethods/${r}/completed`,i=this.constructPath(h,n);return this.proxy.request(i,{method:"PUT"}).then(a.bind(this)).catch(c.bind(this))}getContactMethod(...e){const r=e[0];let n={},o,s;typeof e[1]=="object"?(n=e[1],o=e[2],s=e[3]):(o=e[1],s=e[2]);function a(u){if(f(o))o(u.ContactMethod);else return u}function c(u){if(f(s))s(u);else return u}const h=`contactmethods/${r}`,i=this.constructPath(h,l({},this.current,n));return this.proxy.request(i,{method:"GET"}).then(a.bind(this)).catch(c.bind(this))}contactMethods(...e){let r,n={},o,s;typeof e[0]=="number"?(r=e[0],n=e[1]||{},o=e[2],s=e[3]):typeof e[0]=="object"?(n=e[0]||{},o=e[1],s=e[2]):(o=e[0],s=e[1]);function a(u){return f(o)&&(u=this.settings.useProxyClasses&&u?(()=>(u.Matches=A(u,"Matches",H),u))():u,o(u)),u}function c(u){return f(s)&&s(u),u}const h=r?`guides/${r}/contactmethods`:"contactmethods",i=this.constructPath(h,l({},this.current,n));return this.proxy.request(i,{method:"GET"}).then(a.bind(this)).catch(c.bind(this))}contacts(...e){let r,n={},o,s;typeof e[0]=="number"?(r=e[0],typeof e[1]=="object"?(n=e[1],o=e[2],s=e[3]):(o=e[1],s=e[2])):typeof e[0]=="object"?(n=e[0]||{},o=e[1],s=e[2]):(o=e[0],s=e[1]);function a(i){if(f(o))i&&this.settings.useProxyClasses&&(i.Children&&(i.Children=A(i,"Children",Q)),i.Matches&&(i.Matches=A(i,"Matches",H)),i.Highlighted&&(i.Highlighted=A(i,"Highlighted",H))),o(i);else return i}function c(i){if(f(s))s(i);else return i}const h=this.constructPath(`contacts/${r||""}`,l({},this.current,n));return this.proxy.request(h,{method:"GET"}).then(a.bind(this)).catch(c.bind(this))}getSettings(e){const r=this.constructPath("config",this.current);return this.proxy.request(r,{method:"GET"}).then(e)}getAuthorized(e,r){const n=this.constructPath("interfaceauthorized",this.current);return this.proxy.request(n,{method:"GET",credentials:"include"}).then(e).catch(r)}submitForm(e,r,n,o,s){let a="forms/"+e;return n&&(a+="/"+n),a=this.constructPath("config",l({},this.current,r)),this.proxy.request(a,"POST",r,o,s)}getTab(e,r,n,o){var s=arguments;typeof s[1]=="object"?(r=s[1],n=s[2],o=s[3]):(r={},n=s[1],o=s[2]);const a=`tabs/${e}`;return this.proxy.request(a,{method:"GET"}).then(n).catch(o)}dispose(){this.subscriptions.forEach(e=>e())}}B.feedbackTypes={positive:"Positive",negative:"Negative",comment:"Comment"};B.handoverTypes={email:"Email",chat:"Chat",callback:"Callback",phone:"Phone",emailComplementary:"ComplementaryEmail",chatComplementary:"ComplementaryChat",callbackComplementary:"ComplementaryCallback",phoneComplementary:"ComplementaryPhone"};B.defaults={client:ye,funnel:be,site:me,language:ge,paging:{skip:0,take:10},useProxyClasses:!1};B.version="1.0";const Ce=B;exports.ServiceClient=Ce;exports.ServiceProxy=te;exports.appendParameters=ee;exports.appendQueryString=$;exports.getCookie=q;exports.getStoragePolicyConsent=R;exports.setCookie=C;
|