@telia-ace/knowledge-data-client-flamingo 1.0.9
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/LICENSE.txt +0 -0
- package/README.md +3 -0
- package/dist/create-serviceclient.d.ts +3 -0
- package/dist/create-serviceclient.d.ts.map +1 -0
- package/dist/data-client.d.ts +94 -0
- package/dist/data-client.d.ts.map +1 -0
- package/dist/index-d70f1e69.js +884 -0
- package/dist/index-d70f1e69.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1769 -0
- package/dist/index.js.map +1 -0
- package/dist/legacy-conversion.d.ts +72 -0
- package/dist/legacy-conversion.d.ts.map +1 -0
- package/package.json +40 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1769 @@
|
|
|
1
|
+
var Be = Object.defineProperty, Fe = Object.defineProperties;
|
|
2
|
+
var We = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var ue = Object.getOwnPropertySymbols;
|
|
4
|
+
var He = Object.prototype.hasOwnProperty, Ve = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var ge = (n, e, t) => e in n ? Be(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, pe = (n, e) => {
|
|
6
|
+
for (var t in e || (e = {}))
|
|
7
|
+
He.call(e, t) && ge(n, t, e[t]);
|
|
8
|
+
if (ue)
|
|
9
|
+
for (var t of ue(e))
|
|
10
|
+
Ve.call(e, t) && ge(n, t, e[t]);
|
|
11
|
+
return n;
|
|
12
|
+
}, me = (n, e) => Fe(n, We(e));
|
|
13
|
+
var S = (n, e, t) => new Promise((i, s) => {
|
|
14
|
+
var r = (c) => {
|
|
15
|
+
try {
|
|
16
|
+
o(t.next(c));
|
|
17
|
+
} catch (h) {
|
|
18
|
+
s(h);
|
|
19
|
+
}
|
|
20
|
+
}, a = (c) => {
|
|
21
|
+
try {
|
|
22
|
+
o(t.throw(c));
|
|
23
|
+
} catch (h) {
|
|
24
|
+
s(h);
|
|
25
|
+
}
|
|
26
|
+
}, o = (c) => c.done ? i(c.value) : Promise.resolve(c.value).then(r, a);
|
|
27
|
+
o((t = t.apply(n, e)).next());
|
|
28
|
+
});
|
|
29
|
+
const Z = (n, e, t, ...i) => {
|
|
30
|
+
const s = `[${n.get("$environment").name || "webprovisions"}] ${t}`;
|
|
31
|
+
switch (e) {
|
|
32
|
+
case "info":
|
|
33
|
+
console.info(s, ...i);
|
|
34
|
+
break;
|
|
35
|
+
case "warning":
|
|
36
|
+
console.warn(s, ...i);
|
|
37
|
+
break;
|
|
38
|
+
case "error":
|
|
39
|
+
console.error(s, ...i);
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
}, Qe = (n) => {
|
|
43
|
+
const e = n.container || n;
|
|
44
|
+
return {
|
|
45
|
+
info: (t, ...i) => Z(e, "info", t, ...i),
|
|
46
|
+
warn: (t, ...i) => Z(e, "warning", t, ...i),
|
|
47
|
+
error: (t, ...i) => Z(e, "error", t, ...i)
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
var D = /* @__PURE__ */ ((n) => (n.Implementation = "implementation", n.Widget = "widget", n))(D || {}), x = /* @__PURE__ */ ((n) => (n.Pre = "pre", n.Post = "post", n))(x || {});
|
|
51
|
+
const Ye = (n, e, t, i) => {
|
|
52
|
+
try {
|
|
53
|
+
const s = new e(t, i);
|
|
54
|
+
return {
|
|
55
|
+
name: n,
|
|
56
|
+
invoke: (r, a) => {
|
|
57
|
+
let o;
|
|
58
|
+
return s[r] && (o = s[r].call(s, a)), Promise.resolve(o);
|
|
59
|
+
},
|
|
60
|
+
getInstance: () => s
|
|
61
|
+
};
|
|
62
|
+
} catch (s) {
|
|
63
|
+
if (s.message && s.message.indexOf("is not a constructor") >= 0)
|
|
64
|
+
return {
|
|
65
|
+
name: n,
|
|
66
|
+
invoke: (r) => {
|
|
67
|
+
let a;
|
|
68
|
+
return r === "initialize" && (a = e(t, i)), Promise.resolve(a);
|
|
69
|
+
},
|
|
70
|
+
getInstance: () => e
|
|
71
|
+
};
|
|
72
|
+
throw s;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
function fe(n, e) {
|
|
76
|
+
return typeof n == "undefined" ? e : n;
|
|
77
|
+
}
|
|
78
|
+
let Ke = class {
|
|
79
|
+
constructor(e = {}) {
|
|
80
|
+
this.part = e;
|
|
81
|
+
}
|
|
82
|
+
createCommand(e, t, i) {
|
|
83
|
+
let s;
|
|
84
|
+
typeof t == "function" ? s = {
|
|
85
|
+
scope: D.Widget,
|
|
86
|
+
stage: x.Post,
|
|
87
|
+
defaultArgs: void 0,
|
|
88
|
+
handlerResolver: t
|
|
89
|
+
} : s = {
|
|
90
|
+
scope: fe(t.scope, D.Widget),
|
|
91
|
+
stage: fe(t.stage, x.Post),
|
|
92
|
+
defaultArgs: t.defaultArgs,
|
|
93
|
+
handlerResolver: i
|
|
94
|
+
};
|
|
95
|
+
let r = this.part;
|
|
96
|
+
const a = e.split(".");
|
|
97
|
+
return a.forEach((o, c) => {
|
|
98
|
+
c === a.length - 1 ? r[o] || (r[o] = () => s) : r = this.part[o] = this.part[o] || {};
|
|
99
|
+
}), this;
|
|
100
|
+
}
|
|
101
|
+
get() {
|
|
102
|
+
return this.part;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
const Me = (n) => {
|
|
106
|
+
const e = new Ke({});
|
|
107
|
+
return n(e), e.get();
|
|
108
|
+
};
|
|
109
|
+
Me((n) => {
|
|
110
|
+
n.createCommand(
|
|
111
|
+
"types.register",
|
|
112
|
+
{ scope: D.Implementation, stage: x.Pre },
|
|
113
|
+
(e) => (t, i) => {
|
|
114
|
+
e.container.get("$types")[t] = i;
|
|
115
|
+
}
|
|
116
|
+
).createCommand(
|
|
117
|
+
"type",
|
|
118
|
+
{ stage: x.Pre },
|
|
119
|
+
(e) => (t) => {
|
|
120
|
+
e.container.register("$type", t);
|
|
121
|
+
}
|
|
122
|
+
).createCommand(
|
|
123
|
+
"settings",
|
|
124
|
+
{ stage: x.Pre, defaultArgs: [null] },
|
|
125
|
+
(e) => (t) => {
|
|
126
|
+
e.events.dispatch(
|
|
127
|
+
"settings:change",
|
|
128
|
+
t,
|
|
129
|
+
{ bubbles: !0 }
|
|
130
|
+
), e.container.register("$settings", t);
|
|
131
|
+
}
|
|
132
|
+
).createCommand(
|
|
133
|
+
"plugin",
|
|
134
|
+
{ stage: x.Pre },
|
|
135
|
+
(e) => (t, i, s) => {
|
|
136
|
+
const { container: r } = e;
|
|
137
|
+
let a = null, o = t, c = i;
|
|
138
|
+
typeof t == "string" && (a = t, o = i, c = s);
|
|
139
|
+
const h = (d) => {
|
|
140
|
+
const { transformPluginSettings: g } = e.container.get("$environmentOptions"), u = g ? g(
|
|
141
|
+
c || {},
|
|
142
|
+
a,
|
|
143
|
+
e.container,
|
|
144
|
+
o
|
|
145
|
+
) : i;
|
|
146
|
+
try {
|
|
147
|
+
const p = Ye(
|
|
148
|
+
a,
|
|
149
|
+
o,
|
|
150
|
+
r,
|
|
151
|
+
u
|
|
152
|
+
);
|
|
153
|
+
r.get("$plugins").push(p), d && p.invoke("initialize", null);
|
|
154
|
+
} catch (p) {
|
|
155
|
+
Qe(e).warn("Error when initializing plugin", p);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
e.container.get("$instance") ? h(!0) : e.events.subscribeOnce("widget:instance-created", () => h(!1));
|
|
159
|
+
}
|
|
160
|
+
).createCommand(
|
|
161
|
+
"container.register",
|
|
162
|
+
(e) => (t, i) => {
|
|
163
|
+
e.container.register(t, i);
|
|
164
|
+
}
|
|
165
|
+
).createCommand(
|
|
166
|
+
"container.registerAsync",
|
|
167
|
+
(e) => (t, i) => {
|
|
168
|
+
e.container.registerAsync(t, i);
|
|
169
|
+
}
|
|
170
|
+
).createCommand(
|
|
171
|
+
"container.registerFactory",
|
|
172
|
+
(e) => (t, i) => {
|
|
173
|
+
e.container.registerFactory(t, i);
|
|
174
|
+
}
|
|
175
|
+
).createCommand(
|
|
176
|
+
"container.touch",
|
|
177
|
+
(e) => (t, i) => {
|
|
178
|
+
e.container.touch(t, i);
|
|
179
|
+
}
|
|
180
|
+
).createCommand(
|
|
181
|
+
"csp",
|
|
182
|
+
{},
|
|
183
|
+
(e) => (t) => {
|
|
184
|
+
e.container.register("csp", t);
|
|
185
|
+
}
|
|
186
|
+
);
|
|
187
|
+
});
|
|
188
|
+
const Ze = Me((n) => {
|
|
189
|
+
n.createCommand(
|
|
190
|
+
"ready",
|
|
191
|
+
{ scope: D.Implementation, stage: x.Pre },
|
|
192
|
+
(e) => (t) => {
|
|
193
|
+
const { container: i } = e, s = i.owner;
|
|
194
|
+
i.get("bootstrapping").ready ? t(s) : s.events.subscribeOnce("bootstrap:ready", () => {
|
|
195
|
+
t(s);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
}), J = /* @__PURE__ */ new WeakMap();
|
|
200
|
+
function R() {
|
|
201
|
+
return (n) => (J.has(n) || J.set(n, {}), J.get(n));
|
|
202
|
+
}
|
|
203
|
+
const X = (n, e, t, ...i) => {
|
|
204
|
+
const s = `[${n.get("$environment").name || "webprovisions"}] ${t}`;
|
|
205
|
+
switch (e) {
|
|
206
|
+
case "info":
|
|
207
|
+
console.info(s, ...i);
|
|
208
|
+
break;
|
|
209
|
+
case "warning":
|
|
210
|
+
console.warn(s, ...i);
|
|
211
|
+
break;
|
|
212
|
+
case "error":
|
|
213
|
+
console.error(s, ...i);
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
}, v = (n) => {
|
|
217
|
+
const e = n.container || n;
|
|
218
|
+
return {
|
|
219
|
+
info: (t, ...i) => X(e, "info", t, ...i),
|
|
220
|
+
warn: (t, ...i) => X(e, "warning", t, ...i),
|
|
221
|
+
error: (t, ...i) => X(e, "error", t, ...i)
|
|
222
|
+
};
|
|
223
|
+
}, m = R(), re = (() => {
|
|
224
|
+
let n = 0;
|
|
225
|
+
return () => ++n;
|
|
226
|
+
})(), oe = (n, e, t) => {
|
|
227
|
+
const i = m(n).touchQueue.get(e);
|
|
228
|
+
i && i.forEach((s) => {
|
|
229
|
+
s(t, n);
|
|
230
|
+
});
|
|
231
|
+
};
|
|
232
|
+
class Je {
|
|
233
|
+
constructor(e, t, i, s) {
|
|
234
|
+
this.key = e, this.factory = t, this.parent = i, this.container = s, this.id = re(), this.resolved = !1, this.constructed = !1, this.async = !0;
|
|
235
|
+
}
|
|
236
|
+
resolve() {
|
|
237
|
+
if (!this.constructed) {
|
|
238
|
+
const e = this.factory(this.parent, this.container);
|
|
239
|
+
return this.constructed = !0, this.value = Promise.resolve(e).then((t) => (this.resolved = !0, oe(this.container, this.key, t), t));
|
|
240
|
+
}
|
|
241
|
+
return this.value;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
class Xe {
|
|
245
|
+
constructor(e, t, i, s) {
|
|
246
|
+
this.key = e, this.value = t, this.parent = i, this.container = s, this.id = re(), this.async = !1, this.resolved = !1, this.constructed = !0, this.resolve = () => (this.resolved = !0, oe(this.container, this.key, this.value), this.value);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
class et {
|
|
250
|
+
constructor(e, t, i, s) {
|
|
251
|
+
this.key = e, this.value = t, this.parent = i, this.container = s, this.id = re(), this.async = !1, this.resolved = !1, this.constructed = !1, this.resolve = () => {
|
|
252
|
+
this.resolved = !0, this.constructed = !0;
|
|
253
|
+
const r = this.value(this.parent, this.container);
|
|
254
|
+
return oe(this.container, this.key, this.value), r;
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
class ae {
|
|
259
|
+
/**
|
|
260
|
+
* Creates a new instance of `Container`.
|
|
261
|
+
* @param owner The object owning this inctance.
|
|
262
|
+
* @param name Optional name for the container.
|
|
263
|
+
* @param parent Parent container this should be a child of.
|
|
264
|
+
*/
|
|
265
|
+
constructor(e, t, i) {
|
|
266
|
+
this.owner = e, this.name = t, this.parent = i, m(this).resolvers = /* @__PURE__ */ new Map(), m(this).touchQueue = /* @__PURE__ */ new Map(), m(this).children = [];
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Deletes an existing resolver by its unique id.
|
|
270
|
+
* @param id Resolver id.
|
|
271
|
+
*/
|
|
272
|
+
delete(e) {
|
|
273
|
+
const t = m(this).resolvers, i = Array.from(t.values()).find((s) => s.id === e);
|
|
274
|
+
return i ? (m(this).touchQueue.delete(i.key), Promise.resolve(t.delete(i.key))) : this.parent ? this.parent.delete(e) : Promise.resolve(!1);
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Clears the `Container` and any child containers by deleteing all registered resolvers.
|
|
278
|
+
*/
|
|
279
|
+
clear() {
|
|
280
|
+
const e = m(this).resolvers, t = Array.from(e.values());
|
|
281
|
+
return Promise.all(t.map((i) => {
|
|
282
|
+
if (i.constructed)
|
|
283
|
+
return Promise.resolve(i.resolve()).then((s) => {
|
|
284
|
+
if (s !== null && typeof s == "object" && typeof s.dispose == "function")
|
|
285
|
+
return s.dispose.call(s, this, i);
|
|
286
|
+
});
|
|
287
|
+
})).then(() => {
|
|
288
|
+
t.forEach((i) => this.delete(i.id)), m(this).children.forEach((i) => i.clear());
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Detaches this `Container` instance from its parent, allowing it to be garbage-collected.
|
|
293
|
+
*/
|
|
294
|
+
detach() {
|
|
295
|
+
if (this.parent) {
|
|
296
|
+
const e = m(this.parent).children, t = e.indexOf(this);
|
|
297
|
+
t > -1 && (e.splice(t, 1), delete this.parent);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Provides a way of touching a value in the `Container` without forcing it to be resolved.
|
|
302
|
+
* @param key Key of the resolved value to touch.
|
|
303
|
+
* @param handler Handler function for touching the resolved value.
|
|
304
|
+
*/
|
|
305
|
+
touch(e, t) {
|
|
306
|
+
const i = m(this).resolvers.get(e);
|
|
307
|
+
if (i && i.constructed)
|
|
308
|
+
Promise.resolve(i.resolve()).then((s) => {
|
|
309
|
+
t(s, this);
|
|
310
|
+
});
|
|
311
|
+
else {
|
|
312
|
+
const s = m(this).touchQueue;
|
|
313
|
+
let r = s.get(e);
|
|
314
|
+
r || (r = [], s.set(e, r)), r.push(t);
|
|
315
|
+
}
|
|
316
|
+
return this.parent && !i ? this.parent.touch(e, t) : Promise.resolve();
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Registers an asynchronous resolver.
|
|
320
|
+
* @param key Key of the resolver.
|
|
321
|
+
* @param factory Value factory.
|
|
322
|
+
*/
|
|
323
|
+
registerAsync(e, t) {
|
|
324
|
+
const i = m(this).resolvers.get(e);
|
|
325
|
+
i && !i.async && process.env.NODE_ENV !== "production" && v(this).warn(`Mismatching resolver type. You are registering an async resolver with a key ('${e}') previously used by a non-async resolver.`);
|
|
326
|
+
const s = new Je(e, t, i, this);
|
|
327
|
+
return m(this).resolvers.set(e, s), s.id;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Registers a factory resolver for constructing the value to be resolved.
|
|
331
|
+
* @param key Key of the resolver.
|
|
332
|
+
* @param factory Value factory.
|
|
333
|
+
*/
|
|
334
|
+
registerFactory(e, t) {
|
|
335
|
+
const i = m(this).resolvers.get(e);
|
|
336
|
+
i && i.async && process.env.NODE_ENV !== "production" && v(this).warn(`Mismatching resolver type. You are registering a non-async resolver with a key ('${e}') previously used by an async resolver.`);
|
|
337
|
+
const s = new et(e, t, i, this);
|
|
338
|
+
return m(this).resolvers.set(e, s), s.id;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Registers an synchronous resolver.
|
|
342
|
+
* @param key Key of the resolver.
|
|
343
|
+
* @param value Value.
|
|
344
|
+
*/
|
|
345
|
+
register(e, t) {
|
|
346
|
+
const i = m(this).resolvers.get(e);
|
|
347
|
+
i && i.async && process.env.NODE_ENV !== "production" && v(this).warn(`Mismatching resolver type. You are registering a non-async resolver with a key ('${e}') previously used by an async resolver.`);
|
|
348
|
+
const s = new Xe(e, t, i, this);
|
|
349
|
+
return m(this).resolvers.set(e, s), s.id;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Gets the value for a synchronous resolver.
|
|
353
|
+
* @param key Key of resolver to get.
|
|
354
|
+
*/
|
|
355
|
+
get(e) {
|
|
356
|
+
const t = m(this).resolvers.get(e);
|
|
357
|
+
if (t)
|
|
358
|
+
return t.async && process.env.NODE_ENV !== "production" && v(this).warn(`You are retrieving an async value (with key '${e}') by the non-async function 'container.get(key)'. This will not be supported in future versions. Use 'container.getAsync(key) instead.'`), t.resolve();
|
|
359
|
+
if (this.parent)
|
|
360
|
+
return this.parent.get(e);
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Gets the value for a asynchronous resolver.
|
|
364
|
+
* @param key Key of resolver to get.
|
|
365
|
+
*/
|
|
366
|
+
getAsync(e) {
|
|
367
|
+
const t = m(this).resolvers.get(e);
|
|
368
|
+
if (t) {
|
|
369
|
+
if (!t.async)
|
|
370
|
+
throw process.env.NODE_ENV !== "production" && v(this).warn(`You are retrieving a non-async value (with key '${e}') by the async function 'container.getAsync(key)'.Use 'container.get(key) instead.'`), "Mismatching resolver type";
|
|
371
|
+
return t.resolve();
|
|
372
|
+
}
|
|
373
|
+
return this.parent ? this.parent.getAsync(e) : Promise.resolve(void 0);
|
|
374
|
+
}
|
|
375
|
+
getMany(...e) {
|
|
376
|
+
const t = {};
|
|
377
|
+
return e.forEach((i) => t[i] = this.get(i)), t;
|
|
378
|
+
}
|
|
379
|
+
getManyAsync(...e) {
|
|
380
|
+
const t = {};
|
|
381
|
+
return Promise.all(e.map((i) => this.getAsync(i).then((s) => t[i] = s))).then(() => t);
|
|
382
|
+
}
|
|
383
|
+
createChild(e, t) {
|
|
384
|
+
const i = new ae(e, t, this);
|
|
385
|
+
return m(this).children.push(i), i;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
class ve {
|
|
389
|
+
/**
|
|
390
|
+
*
|
|
391
|
+
* @param type Type of event.
|
|
392
|
+
* @param target The target of the event, which will handle the default behavour.
|
|
393
|
+
* @param cancelable Whether the event is cancelable by calling preventDefault().
|
|
394
|
+
* @param bubbles Whether the event will bubble up the parent hierarchy.
|
|
395
|
+
*/
|
|
396
|
+
constructor(e, t, i = !1, s = !1) {
|
|
397
|
+
this.type = e, this.target = t, this.cancelable = !!i, this.bubbles = !!s, this.defaultPrevented = !1;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Cancels the default behaviour (if the event is cancelable).
|
|
401
|
+
*/
|
|
402
|
+
preventDefault() {
|
|
403
|
+
this.cancelable && (this.defaultPrevented = !0);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
const $ = R(), ye = (n, e) => [].concat(
|
|
407
|
+
$(n).listenerLookup.get(e.toLowerCase()) || [],
|
|
408
|
+
$(n).listenerLookup.get("*") || []
|
|
409
|
+
), be = (n, e, t, i) => {
|
|
410
|
+
let s, r;
|
|
411
|
+
return e instanceof ve ? (s = e, r = e.type) : (s = new ve(e, n.target, !!t.cancelable, !!t.bubbles), r = e), { event: s, type: r, async: i };
|
|
412
|
+
};
|
|
413
|
+
let tt = class Re {
|
|
414
|
+
/**
|
|
415
|
+
* Creates a new Event Manager instance.
|
|
416
|
+
* @param target The target of events dispatched from this Event Manager instance.
|
|
417
|
+
* @param parent Parent Event Manager instance.
|
|
418
|
+
*/
|
|
419
|
+
constructor(e, t) {
|
|
420
|
+
this.target = e, this.parent = t, $(this).listenerLookup = /* @__PURE__ */ new Map(), $(this).children = [];
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Clears registered event listeners in this `EventManager` as well as in any children.
|
|
424
|
+
*/
|
|
425
|
+
clear() {
|
|
426
|
+
$(this).listenerLookup.clear(), $(this).children.forEach((e) => e.clear());
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Detaches this `EventManager` instance from its parent, allowing it to be garbage-collected.
|
|
430
|
+
*/
|
|
431
|
+
detach() {
|
|
432
|
+
if (this.parent) {
|
|
433
|
+
const e = $(this.parent).children, t = e.indexOf(this);
|
|
434
|
+
t > -1 && e.splice(t, 1);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Creates an event subscription by registering an listener for an event type.
|
|
439
|
+
* @param type Event type to subscribe to.
|
|
440
|
+
* @param listener Listener for the event.
|
|
441
|
+
*/
|
|
442
|
+
subscribe(e, t, i) {
|
|
443
|
+
const s = $(this).listenerLookup, r = e.toLowerCase();
|
|
444
|
+
return s.has(r) || s.set(r, []), s.get(r).push(t), () => this.unsubscribe(e, t);
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Similar to `subscribe()` but immediately removes the subscription after the first call.
|
|
448
|
+
* @param type Event type to subscribe to.
|
|
449
|
+
* @param listener Listener for the event.
|
|
450
|
+
*/
|
|
451
|
+
subscribeOnce(e, t) {
|
|
452
|
+
const i = this.subscribe(e, (s, r) => (i(), t(s, r)));
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Removes a listener for the specified event type.
|
|
456
|
+
* @param type Event type to remove subscription for.
|
|
457
|
+
* @param listener Event listener to remove.
|
|
458
|
+
*/
|
|
459
|
+
unsubscribe(e, t) {
|
|
460
|
+
const i = $(this).listenerLookup.get(e.toLowerCase());
|
|
461
|
+
if (i) {
|
|
462
|
+
const s = i.indexOf(t);
|
|
463
|
+
s > -1 && i.splice(s, 1);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Dispatches an asynchonous event to registered event listeners.
|
|
468
|
+
* @param eventOrType Event type or Event object to dispatch.
|
|
469
|
+
* @param data Optional data to be passed to event listeners.
|
|
470
|
+
* @param options Optional event options used if first parameter is an event type.
|
|
471
|
+
*/
|
|
472
|
+
dispatchAsync(e, t, i = {}) {
|
|
473
|
+
const { event: s, type: r } = be(this, e, i, !0), a = ye(this, r);
|
|
474
|
+
let o = 0;
|
|
475
|
+
const c = a.length;
|
|
476
|
+
let h = Promise.resolve();
|
|
477
|
+
for (o = 0; o < c; o++)
|
|
478
|
+
((d) => {
|
|
479
|
+
h = h.then((g) => g ? Promise.resolve(!0) : Promise.resolve(d(s, t)).then(() => s.defaultPrevented));
|
|
480
|
+
})(a[o]);
|
|
481
|
+
return h.then((d) => !d && s.bubbles && this.parent ? this.parent.dispatchAsync(s, t) : d);
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Dispatches an event to registered event listeners.
|
|
485
|
+
* @param eventOrType Event type or Event object to dispatch.
|
|
486
|
+
* @param data Optional data to be passed to event listeners.
|
|
487
|
+
* @param options Optional event options used if first parameter is an event type.
|
|
488
|
+
*/
|
|
489
|
+
dispatch(e, t, i = {}) {
|
|
490
|
+
const { event: s, type: r } = be(this, e, i, !1), a = ye(this, r);
|
|
491
|
+
let o = 0;
|
|
492
|
+
const c = a.length;
|
|
493
|
+
let h = !1;
|
|
494
|
+
for (o = 0; o < c; o++)
|
|
495
|
+
if (a[o](s, t), s.defaultPrevented) {
|
|
496
|
+
h = !0;
|
|
497
|
+
break;
|
|
498
|
+
}
|
|
499
|
+
return !h && s.bubbles && this.parent && (h = this.parent.dispatch(s, t)), h;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Creates a child instance to the current Event manager.
|
|
503
|
+
*/
|
|
504
|
+
createChild(e) {
|
|
505
|
+
const t = new Re(e, this);
|
|
506
|
+
return $(this).children.push(t), t;
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
const z = (n, e, t) => {
|
|
510
|
+
const i = n.get("$plugins").map((s) => {
|
|
511
|
+
try {
|
|
512
|
+
return s.invoke(e, t);
|
|
513
|
+
} catch (r) {
|
|
514
|
+
v(n).error("An error occured when invoking a plugin.", s, r);
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
return Promise.all(i);
|
|
518
|
+
};
|
|
519
|
+
let nt = class {
|
|
520
|
+
constructor(e) {
|
|
521
|
+
this.widget = e.get("$widget"), this.events = this.widget.events, this.container = this.widget.container, this.initialized = null, this.activated = null, this.initialize = this.initialize.bind(this), this.activate = this.activate.bind(this), this.deactivate = this.deactivate.bind(this), this.invoke = this.invoke.bind(this), this.createInstance();
|
|
522
|
+
}
|
|
523
|
+
createInstance() {
|
|
524
|
+
if (!this.widget.container.get("$instance")) {
|
|
525
|
+
const e = this.widget.container.get("$types"), t = this.widget.container.get("$type");
|
|
526
|
+
!t && v(this).error("Unable to create widget. No type is specified.");
|
|
527
|
+
const i = e[t];
|
|
528
|
+
!i && v(this).error(`Unable to create widget. Type '${t}' is not registered.`), this.widget.events.dispatch("widget:create-instance", {}, { bubbles: !0 });
|
|
529
|
+
try {
|
|
530
|
+
this.widget.container.register(
|
|
531
|
+
"$instance",
|
|
532
|
+
new i(this.container)
|
|
533
|
+
);
|
|
534
|
+
} catch (s) {
|
|
535
|
+
v(this).error("Unable to create widget type.", s);
|
|
536
|
+
}
|
|
537
|
+
this.widget.events.dispatch("widget:instance-created", {}, { bubbles: !0 });
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* The initialization is performed before the widget is activated but after it's configured
|
|
542
|
+
* and thus all required services are available. This hook is a good place to bind events that
|
|
543
|
+
* should trigger activation (e.g. click on "trigger links" or routing events)
|
|
544
|
+
* @param {object} data Custom initialization data passed to the widget.
|
|
545
|
+
*/
|
|
546
|
+
initialize(e) {
|
|
547
|
+
return this.initialized = this.initialized || (() => {
|
|
548
|
+
const t = this.container.get("$instance"), i = t.initialize || (() => {
|
|
549
|
+
});
|
|
550
|
+
return this.initialized = Promise.resolve(i.call(t, e)).then(() => z(this.container, "initialize", e)).then(() => {
|
|
551
|
+
});
|
|
552
|
+
})();
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* The activation is where the widget is actually created and rendered.
|
|
556
|
+
* Activation can be initialized from the outside or from an event originated
|
|
557
|
+
* in the "initialize" hook.
|
|
558
|
+
* @param {object} data Custom activation data passed to the widget.
|
|
559
|
+
*/
|
|
560
|
+
activate(e) {
|
|
561
|
+
return (this.initialized || this.initialize()).then(() => {
|
|
562
|
+
this.activated = this.activated || (() => z(this.container, "activate").then(() => {
|
|
563
|
+
const t = this.container.get("$instance");
|
|
564
|
+
return this.activated = t.activate(e);
|
|
565
|
+
}))();
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
deactivate() {
|
|
569
|
+
const e = this.container.get("$instance"), t = e.deactivate || (() => {
|
|
570
|
+
});
|
|
571
|
+
return z(this.container, "deactivate").then(() => Promise.resolve(t.call(e))).then(() => {
|
|
572
|
+
this.initialized = null, this.activated = null;
|
|
573
|
+
}).then(() => {
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Invokes a command on the widget component.
|
|
578
|
+
* @param command Name of command
|
|
579
|
+
* @param args Command arguments
|
|
580
|
+
*/
|
|
581
|
+
invoke(e, ...t) {
|
|
582
|
+
return z(this.container, "invoke", { command: e, args: t }).then(() => {
|
|
583
|
+
const i = this.container.get("$instance");
|
|
584
|
+
if (i[e])
|
|
585
|
+
return i[e].apply(i, t);
|
|
586
|
+
const s = i.invoke;
|
|
587
|
+
if (s)
|
|
588
|
+
return s.call(i, e, ...t);
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
const M = (n, e) => {
|
|
593
|
+
if (!e)
|
|
594
|
+
return !0;
|
|
595
|
+
if (typeof e == "string") {
|
|
596
|
+
const t = e.split(",");
|
|
597
|
+
for (let i = 0, s = t.length; i < s; i++) {
|
|
598
|
+
const r = t[i].trim();
|
|
599
|
+
if (r === n || r === "*")
|
|
600
|
+
return !0;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
return e instanceof Array ? e.indexOf(n) > -1 : !1;
|
|
604
|
+
}, it = (n, e) => {
|
|
605
|
+
if (typeof e == "function")
|
|
606
|
+
return e(n);
|
|
607
|
+
const t = typeof e == "string" ? ot(e) : e;
|
|
608
|
+
return !(!M(n.implementation.tenant || "", t.tenant || "") || !M(n.implementation.name, t.implementation || "") || !M(n.name, t.widget || "") || !M(n.container.get("$type"), t.type || ""));
|
|
609
|
+
}, st = (n, e) => {
|
|
610
|
+
if (typeof e == "function")
|
|
611
|
+
return e(n);
|
|
612
|
+
const t = typeof e == "string" ? at(e) : e;
|
|
613
|
+
return !(!M(n.tenant || "", t.tenant || "") || !M(n.name, t.implementation || ""));
|
|
614
|
+
}, _e = (n) => (e) => it(e, n), rt = (n) => (e) => st(e, n), E = (n) => n instanceof Array && n.length === 1 ? n[0] : n, ot = (n) => {
|
|
615
|
+
const e = {}, t = n.split(":");
|
|
616
|
+
return t.length === 1 ? e.widget = E(t[0].split(",")) : t.length === 2 ? (e.implementation = E(t[0].split(",")), e.widget = E(t[1].split(","))) : (e.tenant = E(t[0].split(",")), e.implementation = E(t[1].split(",")), e.widget = E(t[2].split(","))), e;
|
|
617
|
+
}, at = (n) => {
|
|
618
|
+
const e = {}, t = n.split(":");
|
|
619
|
+
return t.length === 1 ? e.implementation = E(t[0].split(",")) : (e.tenant = E(t[0].split(",")), e.implementation = E(t[1].split(","))), e;
|
|
620
|
+
}, H = R(), we = (n, e, t) => n.filter((i) => i.stage === e && _e(i.selector)(t));
|
|
621
|
+
function ct(n) {
|
|
622
|
+
const e = n.container.get("$environment");
|
|
623
|
+
let t = H(e).configurationCache;
|
|
624
|
+
t && (t = t.filter((i) => i[0] !== n), H(e).configurationCache = t);
|
|
625
|
+
}
|
|
626
|
+
var V = /* @__PURE__ */ ((n) => (n.Implementation = "implementation", n.Widget = "widget", n))(V || {}), A = /* @__PURE__ */ ((n) => (n.Pre = "pre", n.Post = "post", n))(A || {});
|
|
627
|
+
const Se = (n, e, t) => (Object.keys(e).forEach((i) => {
|
|
628
|
+
const s = e[i];
|
|
629
|
+
if (typeof s == "function") {
|
|
630
|
+
const r = s();
|
|
631
|
+
typeof r.defaultArgs != "undefined" && t(r, ...r.defaultArgs), n[i] = (...a) => {
|
|
632
|
+
const o = Object.assign(
|
|
633
|
+
{},
|
|
634
|
+
r,
|
|
635
|
+
{ handlerResolver: r.handlerResolver.bind({}) }
|
|
636
|
+
);
|
|
637
|
+
return t(o, ...a), n;
|
|
638
|
+
};
|
|
639
|
+
} else
|
|
640
|
+
n[i] = Se(
|
|
641
|
+
{},
|
|
642
|
+
s,
|
|
643
|
+
t
|
|
644
|
+
);
|
|
645
|
+
}), n), ht = (n, e) => {
|
|
646
|
+
switch (e) {
|
|
647
|
+
case "implementation":
|
|
648
|
+
return n.implementation;
|
|
649
|
+
case "widget":
|
|
650
|
+
return n;
|
|
651
|
+
}
|
|
652
|
+
}, ke = (n, e, t, i) => (i.forEach((s) => {
|
|
653
|
+
Se(
|
|
654
|
+
n,
|
|
655
|
+
s,
|
|
656
|
+
(r, ...a) => {
|
|
657
|
+
const o = {
|
|
658
|
+
selector: e,
|
|
659
|
+
stage: r.stage,
|
|
660
|
+
handler: (c) => {
|
|
661
|
+
const h = ht(c, r.scope), d = { container: h.container, events: h.events }, g = r.handlerResolver, u = g(d);
|
|
662
|
+
let p = H(t.environment).configurationCache;
|
|
663
|
+
return p || (p = H(t.environment).configurationCache = []), p.find((b) => b.indexOf(h) > -1 && b.indexOf(g) > -1) ? Promise.resolve() : (p.push([h, g]), Promise.resolve(u(...a)));
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
t.instructions.push(o);
|
|
667
|
+
}
|
|
668
|
+
);
|
|
669
|
+
}), n);
|
|
670
|
+
function lt(n, e) {
|
|
671
|
+
function t(i) {
|
|
672
|
+
return ke(
|
|
673
|
+
{},
|
|
674
|
+
i,
|
|
675
|
+
n,
|
|
676
|
+
e
|
|
677
|
+
);
|
|
678
|
+
}
|
|
679
|
+
return ke(
|
|
680
|
+
t,
|
|
681
|
+
"*",
|
|
682
|
+
n,
|
|
683
|
+
e
|
|
684
|
+
);
|
|
685
|
+
}
|
|
686
|
+
const dt = (n, e, t, i) => {
|
|
687
|
+
try {
|
|
688
|
+
const s = new e(t, i);
|
|
689
|
+
return {
|
|
690
|
+
name: n,
|
|
691
|
+
invoke: (r, a) => {
|
|
692
|
+
let o;
|
|
693
|
+
return s[r] && (o = s[r].call(s, a)), Promise.resolve(o);
|
|
694
|
+
},
|
|
695
|
+
getInstance: () => s
|
|
696
|
+
};
|
|
697
|
+
} catch (s) {
|
|
698
|
+
if (s.message && s.message.indexOf("is not a constructor") >= 0)
|
|
699
|
+
return {
|
|
700
|
+
name: n,
|
|
701
|
+
invoke: (r) => {
|
|
702
|
+
let a;
|
|
703
|
+
return r === "initialize" && (a = e(t, i)), Promise.resolve(a);
|
|
704
|
+
},
|
|
705
|
+
getInstance: () => e
|
|
706
|
+
};
|
|
707
|
+
throw s;
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
function Ce(n, e) {
|
|
711
|
+
return typeof n == "undefined" ? e : n;
|
|
712
|
+
}
|
|
713
|
+
let ut = class {
|
|
714
|
+
constructor(e = {}) {
|
|
715
|
+
this.part = e;
|
|
716
|
+
}
|
|
717
|
+
createCommand(e, t, i) {
|
|
718
|
+
let s;
|
|
719
|
+
typeof t == "function" ? s = {
|
|
720
|
+
scope: V.Widget,
|
|
721
|
+
stage: A.Post,
|
|
722
|
+
defaultArgs: void 0,
|
|
723
|
+
handlerResolver: t
|
|
724
|
+
} : s = {
|
|
725
|
+
scope: Ce(t.scope, V.Widget),
|
|
726
|
+
stage: Ce(t.stage, A.Post),
|
|
727
|
+
defaultArgs: t.defaultArgs,
|
|
728
|
+
handlerResolver: i
|
|
729
|
+
};
|
|
730
|
+
let r = this.part;
|
|
731
|
+
const a = e.split(".");
|
|
732
|
+
return a.forEach((o, c) => {
|
|
733
|
+
c === a.length - 1 ? r[o] || (r[o] = () => s) : r = this.part[o] = this.part[o] || {};
|
|
734
|
+
}), this;
|
|
735
|
+
}
|
|
736
|
+
get() {
|
|
737
|
+
return this.part;
|
|
738
|
+
}
|
|
739
|
+
};
|
|
740
|
+
const Le = (n) => {
|
|
741
|
+
const e = new ut({});
|
|
742
|
+
return n(e), e.get();
|
|
743
|
+
}, gt = Le((n) => {
|
|
744
|
+
n.createCommand(
|
|
745
|
+
"types.register",
|
|
746
|
+
{ scope: V.Implementation, stage: A.Pre },
|
|
747
|
+
(e) => (t, i) => {
|
|
748
|
+
e.container.get("$types")[t] = i;
|
|
749
|
+
}
|
|
750
|
+
).createCommand(
|
|
751
|
+
"type",
|
|
752
|
+
{ stage: A.Pre },
|
|
753
|
+
(e) => (t) => {
|
|
754
|
+
e.container.register("$type", t);
|
|
755
|
+
}
|
|
756
|
+
).createCommand(
|
|
757
|
+
"settings",
|
|
758
|
+
{ stage: A.Pre, defaultArgs: [null] },
|
|
759
|
+
(e) => (t) => {
|
|
760
|
+
e.events.dispatch(
|
|
761
|
+
"settings:change",
|
|
762
|
+
t,
|
|
763
|
+
{ bubbles: !0 }
|
|
764
|
+
), e.container.register("$settings", t);
|
|
765
|
+
}
|
|
766
|
+
).createCommand(
|
|
767
|
+
"plugin",
|
|
768
|
+
{ stage: A.Pre },
|
|
769
|
+
(e) => (t, i, s) => {
|
|
770
|
+
const { container: r } = e;
|
|
771
|
+
let a = null, o = t, c = i;
|
|
772
|
+
typeof t == "string" && (a = t, o = i, c = s);
|
|
773
|
+
const h = (d) => {
|
|
774
|
+
const { transformPluginSettings: g } = e.container.get("$environmentOptions"), u = g ? g(
|
|
775
|
+
c || {},
|
|
776
|
+
a,
|
|
777
|
+
e.container,
|
|
778
|
+
o
|
|
779
|
+
) : i;
|
|
780
|
+
try {
|
|
781
|
+
const p = dt(
|
|
782
|
+
a,
|
|
783
|
+
o,
|
|
784
|
+
r,
|
|
785
|
+
u
|
|
786
|
+
);
|
|
787
|
+
r.get("$plugins").push(p), d && p.invoke("initialize", null);
|
|
788
|
+
} catch (p) {
|
|
789
|
+
v(e).warn("Error when initializing plugin", p);
|
|
790
|
+
}
|
|
791
|
+
};
|
|
792
|
+
e.container.get("$instance") ? h(!0) : e.events.subscribeOnce("widget:instance-created", () => h(!1));
|
|
793
|
+
}
|
|
794
|
+
).createCommand(
|
|
795
|
+
"container.register",
|
|
796
|
+
(e) => (t, i) => {
|
|
797
|
+
e.container.register(t, i);
|
|
798
|
+
}
|
|
799
|
+
).createCommand(
|
|
800
|
+
"container.registerAsync",
|
|
801
|
+
(e) => (t, i) => {
|
|
802
|
+
e.container.registerAsync(t, i);
|
|
803
|
+
}
|
|
804
|
+
).createCommand(
|
|
805
|
+
"container.registerFactory",
|
|
806
|
+
(e) => (t, i) => {
|
|
807
|
+
e.container.registerFactory(t, i);
|
|
808
|
+
}
|
|
809
|
+
).createCommand(
|
|
810
|
+
"container.touch",
|
|
811
|
+
(e) => (t, i) => {
|
|
812
|
+
e.container.touch(t, i);
|
|
813
|
+
}
|
|
814
|
+
).createCommand(
|
|
815
|
+
"csp",
|
|
816
|
+
{},
|
|
817
|
+
(e) => (t) => {
|
|
818
|
+
e.container.register("csp", t);
|
|
819
|
+
}
|
|
820
|
+
);
|
|
821
|
+
}), pt = gt;
|
|
822
|
+
function mt(n, e, t = []) {
|
|
823
|
+
const i = [pt].concat(t), s = lt(
|
|
824
|
+
e,
|
|
825
|
+
i
|
|
826
|
+
);
|
|
827
|
+
n(s, e);
|
|
828
|
+
}
|
|
829
|
+
class ft {
|
|
830
|
+
constructor() {
|
|
831
|
+
this.tasks = [], this.current = Promise.resolve(), this.next = this.next.bind(this);
|
|
832
|
+
}
|
|
833
|
+
add(e, t, i, s) {
|
|
834
|
+
this.tasks.push({ task: e, resolve: t, reject: i, done: s }), this.next();
|
|
835
|
+
}
|
|
836
|
+
next() {
|
|
837
|
+
this.current = this.current.then(() => {
|
|
838
|
+
const e = this.tasks.shift();
|
|
839
|
+
if (e) {
|
|
840
|
+
const t = Promise.resolve(e.task());
|
|
841
|
+
return Promise.resolve(t).then(this.next).then(() => t.then((i) => {
|
|
842
|
+
e.done(), e.resolve(i);
|
|
843
|
+
})).catch((i) => (e.done(), e.reject(i), this.next()));
|
|
844
|
+
}
|
|
845
|
+
return Promise.resolve();
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
const U = /* @__PURE__ */ new WeakMap();
|
|
850
|
+
function vt(n) {
|
|
851
|
+
return U.has(n) || U.set(n, new ft()), (e) => new Promise((t, i) => {
|
|
852
|
+
const s = U.get(n);
|
|
853
|
+
s.add(e, t, i, () => {
|
|
854
|
+
s.tasks.length || U.delete(n);
|
|
855
|
+
});
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
const $e = (n) => typeof n != "undefined", L = (n, e) => {
|
|
859
|
+
n.events.dispatch("widget:state-change", { state: e }, { bubbles: !0 }), n.state = e, n.events.dispatch("widget:state-changed", {}, { bubbles: !0 });
|
|
860
|
+
}, y = R(), yt = (n) => {
|
|
861
|
+
const { container: e, events: t } = n;
|
|
862
|
+
e.get("$controller") || (e.register("$controller", new nt(e)), t.dispatch("widget:controller-created", {}, { bubbles: !0 }));
|
|
863
|
+
};
|
|
864
|
+
let bt = class {
|
|
865
|
+
/**
|
|
866
|
+
* Creates a new `Widget` instance.
|
|
867
|
+
* @param name Name of widget.
|
|
868
|
+
* @param implementation The implementation this instance belongs to.
|
|
869
|
+
* @param configuration Configuration for the widget.
|
|
870
|
+
*/
|
|
871
|
+
constructor(e, t, i) {
|
|
872
|
+
this.state = "deactivated", this.name = e, this.implementation = t, this.container = t.container.createChild(this, e), this.events = t.events.createChild(this), y(this).subscriptions = [], i && t.configure((s) => {
|
|
873
|
+
const r = s(e);
|
|
874
|
+
$e(i.type) && r.type(i.type), $e(i.settings) && r.settings(i.settings), i.plugins && Object.keys(i.plugins).forEach((a) => {
|
|
875
|
+
var o;
|
|
876
|
+
const c = (o = i.plugins) == null ? void 0 : o[a];
|
|
877
|
+
r.plugin(a, c);
|
|
878
|
+
});
|
|
879
|
+
}), this.load = this.load.bind(this), this.activate = this.activate.bind(this), this.invoke = this.invoke.bind(this), this.deactivate = this.deactivate.bind(this);
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* Initializes the widget, if not already initialized, and applies any
|
|
883
|
+
* pending configuration.
|
|
884
|
+
*/
|
|
885
|
+
load() {
|
|
886
|
+
return vt(this)(() => {
|
|
887
|
+
y(this).deactivatedPromise = null;
|
|
888
|
+
const e = this.state === "deactivated";
|
|
889
|
+
e && (L(
|
|
890
|
+
this,
|
|
891
|
+
"activating"
|
|
892
|
+
/* Activating */
|
|
893
|
+
), this.container.register("$widget", this), this.container.register("$controller", null), this.container.register("$plugins", []), this.container.register("$type", null), this.container.register("$instance", null)), L(
|
|
894
|
+
this,
|
|
895
|
+
"loading"
|
|
896
|
+
/* Loading */
|
|
897
|
+
);
|
|
898
|
+
const t = this.implementation.instructions, i = we(t, A.Pre, this);
|
|
899
|
+
return Promise.all(i.map((s) => s.handler(this))).then(() => {
|
|
900
|
+
yt(this);
|
|
901
|
+
const s = we(t, A.Post, this);
|
|
902
|
+
return Promise.all(s.map((r) => r.handler(this))).then(() => {
|
|
903
|
+
e && this.container.get("$controller").initialize();
|
|
904
|
+
});
|
|
905
|
+
}).then(() => (L(
|
|
906
|
+
this,
|
|
907
|
+
"activated"
|
|
908
|
+
/* Activated */
|
|
909
|
+
), this));
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* Activates the widget and makes it ready for receiving commands.
|
|
914
|
+
* @param data Activation data
|
|
915
|
+
*/
|
|
916
|
+
activate(e) {
|
|
917
|
+
y(this).subscriptions.push(
|
|
918
|
+
this.implementation.events.subscribe("implementation:configured", () => {
|
|
919
|
+
[
|
|
920
|
+
"activated",
|
|
921
|
+
"activating",
|
|
922
|
+
"loading"
|
|
923
|
+
/* Loading */
|
|
924
|
+
].indexOf(this.state) > -1 && this.load();
|
|
925
|
+
})
|
|
926
|
+
);
|
|
927
|
+
const t = y(this).activatedPromise;
|
|
928
|
+
return t ? (process.env.NODE_ENV !== "production" && v(this).warn(`Widget '${this.name}' has already been activated. The passed arguments for this activation will be discarded.`, e), t) : y(this).activatedPromise = this.load().then(() => this.container.get("$controller").activate(e));
|
|
929
|
+
}
|
|
930
|
+
/**
|
|
931
|
+
* Invokes a command on a widget. If the widget isn't activate the invocation
|
|
932
|
+
* will be suspended until activation.
|
|
933
|
+
* @param command Command to invoke.
|
|
934
|
+
* @param args Command arguments.
|
|
935
|
+
*/
|
|
936
|
+
invoke(e, ...t) {
|
|
937
|
+
const i = y(this).activatedPromise, s = (r, ...a) => i.then(this.load).then(() => this.container.get("$controller").invoke(r, ...a));
|
|
938
|
+
return i ? s(e, ...t) : (process.env.NODE_ENV !== "production" && v(this).warn("You are invoking a command on a deactivated widget. The invocation will be queued until the widget is activated.", this), new Promise((r) => {
|
|
939
|
+
const a = this.events.subscribe("widget:state-changed", () => {
|
|
940
|
+
this.state === "activated" && (a(), r(s(e, ...t)));
|
|
941
|
+
});
|
|
942
|
+
}));
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* Deactivates the widget by clearing the `Container` and removing any event subscriptions in the
|
|
946
|
+
* `EventManager`.
|
|
947
|
+
*/
|
|
948
|
+
deactivate() {
|
|
949
|
+
return y(this).deactivatedPromise || (this.state === "deactivated" ? Promise.resolve() : (L(
|
|
950
|
+
this,
|
|
951
|
+
"deactivating"
|
|
952
|
+
/* Deactivating */
|
|
953
|
+
), y(this).deactivatedPromise = this.container.get("$controller").deactivate().then(() => (y(this).activatedPromise = null, y(this).subscriptions.forEach((t) => t()), y(this).subscriptions = [], this.container.clear().then(() => {
|
|
954
|
+
this.events.clear(), ct(this), L(
|
|
955
|
+
this,
|
|
956
|
+
"deactivated"
|
|
957
|
+
/* Deactivated */
|
|
958
|
+
);
|
|
959
|
+
})))));
|
|
960
|
+
}
|
|
961
|
+
};
|
|
962
|
+
const Pe = R();
|
|
963
|
+
class wt {
|
|
964
|
+
/**
|
|
965
|
+
* Creates a new Implementation instance.
|
|
966
|
+
* @param configuration Configuration for the implementation.
|
|
967
|
+
* @param environment The parent environment.
|
|
968
|
+
* @param configurationApiExtensions Optional configuration API extensions.
|
|
969
|
+
*/
|
|
970
|
+
constructor(e, t, i = []) {
|
|
971
|
+
this.instructions = [], this.widgets = /* @__PURE__ */ new Map(), this.name = e.name, this.tenant = e.tenant, this.environment = t, this.container = t.container.createChild(this, this.name), this.events = t.events.createChild(this), this.container.register("$types", {}), Pe(this).configurationApiExtensions = i;
|
|
972
|
+
}
|
|
973
|
+
/**
|
|
974
|
+
* Loads all widgets in the implementation.
|
|
975
|
+
*/
|
|
976
|
+
load() {
|
|
977
|
+
const e = Array.from(this.widgets.values());
|
|
978
|
+
return Promise.all(e.map((t) => t.load())).then(() => e);
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* Configures the implementation by adding a configuration callback.
|
|
982
|
+
* @param configFn Callback function for configuration.
|
|
983
|
+
*/
|
|
984
|
+
configure(e) {
|
|
985
|
+
return mt(e, this, Pe(this).configurationApiExtensions), this.events.dispatch(
|
|
986
|
+
"implementation:configured",
|
|
987
|
+
{ implementation: this },
|
|
988
|
+
{ bubbles: !0 }
|
|
989
|
+
), this;
|
|
990
|
+
}
|
|
991
|
+
/**
|
|
992
|
+
* Creates a widget on the implementation and returns its `WidgetData`.
|
|
993
|
+
* @param name Widget name.
|
|
994
|
+
* @param configuration Widget configuration.
|
|
995
|
+
*/
|
|
996
|
+
createWidget(e, t) {
|
|
997
|
+
const i = new bt(e, this, t);
|
|
998
|
+
return this.widgets.set(i.name, i), i;
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
function kt(n, e, t) {
|
|
1002
|
+
const i = new wt(n, e, t);
|
|
1003
|
+
return n.widgets && Object.keys(n.widgets).forEach((s) => {
|
|
1004
|
+
var r;
|
|
1005
|
+
const a = (r = n.widgets) == null ? void 0 : r[s];
|
|
1006
|
+
i.createWidget(s, a);
|
|
1007
|
+
}), i;
|
|
1008
|
+
}
|
|
1009
|
+
let Ee = class je {
|
|
1010
|
+
constructor(e, t) {
|
|
1011
|
+
this.selectorFactory = t, typeof e == "function" ? this.resolver = e : this.resolver = () => e;
|
|
1012
|
+
}
|
|
1013
|
+
append(e) {
|
|
1014
|
+
const t = typeof e == "function" ? e : () => e;
|
|
1015
|
+
return new je(
|
|
1016
|
+
() => this.all().concat(t()),
|
|
1017
|
+
this.selectorFactory
|
|
1018
|
+
);
|
|
1019
|
+
}
|
|
1020
|
+
all() {
|
|
1021
|
+
return this.resolver().concat([]);
|
|
1022
|
+
}
|
|
1023
|
+
query(e) {
|
|
1024
|
+
return this.all().filter(this.selectorFactory(e));
|
|
1025
|
+
}
|
|
1026
|
+
find(e) {
|
|
1027
|
+
const t = this.query(e);
|
|
1028
|
+
if (t.length)
|
|
1029
|
+
return t[0];
|
|
1030
|
+
}
|
|
1031
|
+
};
|
|
1032
|
+
const ce = "#____version____#", ee = R(), Ct = (n) => n.tenant ? `${n.name}:${n.tenant}` : n.name, qe = class {
|
|
1033
|
+
constructor(e, t = [], i = {}) {
|
|
1034
|
+
this.widgets = new Ee(
|
|
1035
|
+
() => {
|
|
1036
|
+
let s = [];
|
|
1037
|
+
return this.implementations.all().forEach((r) => {
|
|
1038
|
+
s = s.concat(Array.from(r.widgets.values()));
|
|
1039
|
+
}), s;
|
|
1040
|
+
},
|
|
1041
|
+
_e
|
|
1042
|
+
), this.implementations = new Ee([], rt), this.name = e, this.container = new ae(this, e), this.events = new tt(this), this.container.register("$version", ce), this.container.register("$environment", this), this.container.register("$environmentOptions", i), ee(this).configurationApiExtensions = t;
|
|
1043
|
+
}
|
|
1044
|
+
/**
|
|
1045
|
+
* Creates an implementation based on the provided configuration.
|
|
1046
|
+
* @param config Implementation configuration.
|
|
1047
|
+
*/
|
|
1048
|
+
createImplementation(e) {
|
|
1049
|
+
const t = Ct(e);
|
|
1050
|
+
let i = this.implementations.find(t);
|
|
1051
|
+
if (i)
|
|
1052
|
+
return process.env.NODE_ENV !== "production" && v(i).warn(`Implementation "${t}" already exist on current environment.`), i;
|
|
1053
|
+
const s = ee(this).configurationApiExtensions;
|
|
1054
|
+
return i = kt(
|
|
1055
|
+
e,
|
|
1056
|
+
this,
|
|
1057
|
+
s
|
|
1058
|
+
), this.implementations = this.implementations.append([i]), this.events.dispatch("implementation:created", { implementation: i }), i;
|
|
1059
|
+
}
|
|
1060
|
+
/**
|
|
1061
|
+
* Patches the Environment instance configuration.
|
|
1062
|
+
* @param configuration Environment configuration.
|
|
1063
|
+
*/
|
|
1064
|
+
patch(e = {}) {
|
|
1065
|
+
const { name: t, configurationApiExtensions: i } = e;
|
|
1066
|
+
typeof t != "undefined" && t !== null && (this.name = t), i && i.forEach(
|
|
1067
|
+
(s) => {
|
|
1068
|
+
ee(this).configurationApiExtensions.push(s);
|
|
1069
|
+
}
|
|
1070
|
+
);
|
|
1071
|
+
}
|
|
1072
|
+
/**
|
|
1073
|
+
* Creates a new Environment instance based on the provided configuration.
|
|
1074
|
+
* @param configuration Environment configuration.
|
|
1075
|
+
*/
|
|
1076
|
+
static create(e = {}) {
|
|
1077
|
+
return new qe(
|
|
1078
|
+
e.name || "",
|
|
1079
|
+
e.configurationApiExtensions,
|
|
1080
|
+
e.options
|
|
1081
|
+
);
|
|
1082
|
+
}
|
|
1083
|
+
};
|
|
1084
|
+
let De = qe;
|
|
1085
|
+
De.version = ce;
|
|
1086
|
+
const Y = (n, e, ...t) => typeof e == "string" ? n(`[humany] ${e}`, ...t) : n(e, ...t), j = class {
|
|
1087
|
+
constructor() {
|
|
1088
|
+
this.keys = [], this.log = (e, ...t) => this.lookup(e, () => j.log(...t)), this.warn = (e, ...t) => this.lookup(e, () => j.warn(...t)), this.error = (e, ...t) => this.lookup(e, () => j.error(...t)), this.info = (e, ...t) => this.lookup(e, () => j.info(...t));
|
|
1089
|
+
}
|
|
1090
|
+
lookup(e, t) {
|
|
1091
|
+
this.keys.indexOf(e) === -1 && (this.keys.push(e), t());
|
|
1092
|
+
}
|
|
1093
|
+
};
|
|
1094
|
+
let G = j;
|
|
1095
|
+
G.log = (...n) => Y(console.log, ...n);
|
|
1096
|
+
G.warn = (...n) => Y(console.warn, ...n);
|
|
1097
|
+
G.error = (...n) => Y(console.error, ...n);
|
|
1098
|
+
G.info = (...n) => Y(console.info, ...n);
|
|
1099
|
+
const Ge = (n) => {
|
|
1100
|
+
let e = {}, t, i;
|
|
1101
|
+
if (typeof n != "object" || n === null)
|
|
1102
|
+
return n;
|
|
1103
|
+
e = Array.isArray(n) ? [] : {};
|
|
1104
|
+
for (i in n)
|
|
1105
|
+
t = n[i], e[i] = typeof t == "object" && t !== null ? Ge(t) : t;
|
|
1106
|
+
return e;
|
|
1107
|
+
}, $t = Ge;
|
|
1108
|
+
class Pt {
|
|
1109
|
+
constructor(e, t) {
|
|
1110
|
+
this.lockWarningTime = e, this.lockErrorTime = t, this.tasks = [], this.current = Promise.resolve(), this.next = this.next.bind(this);
|
|
1111
|
+
}
|
|
1112
|
+
add(e, t, i, s) {
|
|
1113
|
+
this.tasks.push({ task: e, resolve: t, reject: i, done: s }), this.next();
|
|
1114
|
+
}
|
|
1115
|
+
next() {
|
|
1116
|
+
this.current = this.current.then(() => {
|
|
1117
|
+
const e = this.tasks.shift();
|
|
1118
|
+
if (e) {
|
|
1119
|
+
let t;
|
|
1120
|
+
const i = setTimeout(() => {
|
|
1121
|
+
process.env.NODE_ENV !== "production" && G.warn(
|
|
1122
|
+
`A lock has exceeded ${this.lockWarningTime} ms. Waiting additional ${this.lockErrorTime} ms before rejecting the task.`,
|
|
1123
|
+
e
|
|
1124
|
+
), t = setTimeout(() => {
|
|
1125
|
+
e.reject("lock timeout exceeded");
|
|
1126
|
+
}, this.lockErrorTime);
|
|
1127
|
+
}, this.lockWarningTime), s = Promise.resolve(e.task()).then((r) => (clearTimeout(i), clearTimeout(t), r));
|
|
1128
|
+
return Promise.resolve(s).then(this.next).then(
|
|
1129
|
+
() => s.then((r) => {
|
|
1130
|
+
e.done(), e.resolve(r);
|
|
1131
|
+
})
|
|
1132
|
+
).catch((r) => (e.done(), e.reject(r), this.next()));
|
|
1133
|
+
}
|
|
1134
|
+
return Promise.resolve();
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
const B = /* @__PURE__ */ new WeakMap();
|
|
1139
|
+
function Et(n, e = 5e3, t = 1e3) {
|
|
1140
|
+
return B.has(n) || B.set(n, new Pt(e, t)), (i) => new Promise((s, r) => {
|
|
1141
|
+
const a = B.get(n);
|
|
1142
|
+
a.add(i, s, r, () => {
|
|
1143
|
+
a.tasks.length || B.delete(n);
|
|
1144
|
+
});
|
|
1145
|
+
});
|
|
1146
|
+
}
|
|
1147
|
+
const At = (n = {}) => (Object.keys(n).forEach((e) => {
|
|
1148
|
+
(n[e] === null || typeof n[e] == "undefined") && delete n[e];
|
|
1149
|
+
}), n), Nt = At, F = (n, e) => {
|
|
1150
|
+
let t = !0;
|
|
1151
|
+
return Object.keys(n).length !== Object.keys(e).length || Object.keys(n).some((i) => !Object.keys(e).some((s) => i === s)) ? !1 : (Object.keys(n).forEach((i) => {
|
|
1152
|
+
if (t) {
|
|
1153
|
+
const s = typeof n[i] == "undefined" ? "" : n[i], r = typeof e[i] == "undefined" ? "" : e[i];
|
|
1154
|
+
t = s.toString() === r.toString();
|
|
1155
|
+
}
|
|
1156
|
+
}), t);
|
|
1157
|
+
};
|
|
1158
|
+
var xt = Object.defineProperty, Ae = Object.getOwnPropertySymbols, Ot = Object.prototype.hasOwnProperty, It = Object.prototype.propertyIsEnumerable, Ne = (n, e, t) => e in n ? xt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, xe = (n, e) => {
|
|
1159
|
+
for (var t in e || (e = {}))
|
|
1160
|
+
Ot.call(e, t) && Ne(n, t, e[t]);
|
|
1161
|
+
if (Ae)
|
|
1162
|
+
for (var t of Ae(e))
|
|
1163
|
+
It.call(e, t) && Ne(n, t, e[t]);
|
|
1164
|
+
return n;
|
|
1165
|
+
};
|
|
1166
|
+
Le((n) => {
|
|
1167
|
+
n.createCommand("components", (e) => (t) => {
|
|
1168
|
+
e.events.subscribeOnce("components:platform-created", (i, { platform: s }) => {
|
|
1169
|
+
t.handlers && t.handlers.forEach(([r, a]) => {
|
|
1170
|
+
s.addComponentHandler(r, a);
|
|
1171
|
+
});
|
|
1172
|
+
});
|
|
1173
|
+
});
|
|
1174
|
+
});
|
|
1175
|
+
const Mt = "#____version____#", Te = class extends De {
|
|
1176
|
+
constructor(n, e = []) {
|
|
1177
|
+
super(n, e, {
|
|
1178
|
+
transformPluginSettings: (t, i, s) => {
|
|
1179
|
+
const r = s.get("$settings"), a = r.plugins && i ? r.plugins[i] || {} : {};
|
|
1180
|
+
return xe(xe({}, a), t);
|
|
1181
|
+
}
|
|
1182
|
+
});
|
|
1183
|
+
}
|
|
1184
|
+
createImplementation(n) {
|
|
1185
|
+
const e = super.createImplementation(n);
|
|
1186
|
+
return e.bindings = n.bindings, e;
|
|
1187
|
+
}
|
|
1188
|
+
/**
|
|
1189
|
+
* Performs navigation for widgets matching the specified selector by invoking a
|
|
1190
|
+
* 'navigate' command.
|
|
1191
|
+
* @param selector Widget selector matching the widget(s) to perform navigation on.
|
|
1192
|
+
* @param route Route name.
|
|
1193
|
+
* @param params Route params.
|
|
1194
|
+
*/
|
|
1195
|
+
navigate(n, e, t) {
|
|
1196
|
+
this.widgets.query(n).forEach((i) => i.invoke("navigate", { route: e, params: t }));
|
|
1197
|
+
}
|
|
1198
|
+
/**
|
|
1199
|
+
* Creates a runtime based on provided configuration.
|
|
1200
|
+
* @param configuration Runtime configuration.
|
|
1201
|
+
*/
|
|
1202
|
+
static create(n = {}) {
|
|
1203
|
+
const e = [Ze].concat(
|
|
1204
|
+
n.configurationApiExtensions || []
|
|
1205
|
+
);
|
|
1206
|
+
return new Te("humany", e);
|
|
1207
|
+
}
|
|
1208
|
+
/**
|
|
1209
|
+
* Creates a widget runtime based on provided configuration and retains configuration handlers
|
|
1210
|
+
* registered on global context. Use this factory to fully support the default embed script.
|
|
1211
|
+
* Will return any existing widget runtime if available.
|
|
1212
|
+
* @param configuration Runtime configuration.
|
|
1213
|
+
* @param global Object to read configuration handlers from (default: window).
|
|
1214
|
+
*/
|
|
1215
|
+
static createFromGlobal(n, e = {}) {
|
|
1216
|
+
if (this.isRuntime(n))
|
|
1217
|
+
return n.patch(e), n;
|
|
1218
|
+
const t = [], i = n && n._c;
|
|
1219
|
+
i && i.forEach((r) => t.push(r));
|
|
1220
|
+
const s = this.create(e);
|
|
1221
|
+
return s.container.register("$runtimecfg", t), s;
|
|
1222
|
+
}
|
|
1223
|
+
/**
|
|
1224
|
+
* Determines whether the specified object is a valid widget runtime.
|
|
1225
|
+
* @param obj Object to compare.
|
|
1226
|
+
*/
|
|
1227
|
+
static isRuntime(n) {
|
|
1228
|
+
return !!(n && typeof n == "object" && n.container && typeof n.container.get == "function" && n.container.get("$environment") === n && n.container.owner === n);
|
|
1229
|
+
}
|
|
1230
|
+
};
|
|
1231
|
+
let Rt = Te;
|
|
1232
|
+
Rt.version = `${Mt} (${ce})`;
|
|
1233
|
+
var Q = /* @__PURE__ */ ((n) => (n.open = "open", n.closed = "closed", n.hidden = "hidden", n))(Q || {});
|
|
1234
|
+
const Oe = (n) => import("./index-d70f1e69.js").then(
|
|
1235
|
+
({ ServiceClient: e, ServiceProxy: t }) => n.get("settings").then((i) => {
|
|
1236
|
+
const { name: s, events: r } = n.get("$widget"), {
|
|
1237
|
+
data: { projection: a = "", site: o = "current", forceHttps: c = !1 }
|
|
1238
|
+
} = i, h = new t(a, {
|
|
1239
|
+
credentials: "same-origin"
|
|
1240
|
+
}), d = new e(
|
|
1241
|
+
h,
|
|
1242
|
+
{
|
|
1243
|
+
funnel: s.replace("_contact-method", "").replace("_contact", ""),
|
|
1244
|
+
site: _t(o, c)
|
|
1245
|
+
},
|
|
1246
|
+
null,
|
|
1247
|
+
n
|
|
1248
|
+
);
|
|
1249
|
+
return r.subscribe("widget:settings-updated", (g, { data: u }) => {
|
|
1250
|
+
u && u.projection !== a && d.proxy.setBaseUrl(u.projection);
|
|
1251
|
+
}), d;
|
|
1252
|
+
})
|
|
1253
|
+
), _t = (n, e) => () => {
|
|
1254
|
+
const t = (s) => {
|
|
1255
|
+
const r = document.createElement("a");
|
|
1256
|
+
return r.href = s, r;
|
|
1257
|
+
};
|
|
1258
|
+
let i = window.location;
|
|
1259
|
+
return n === "referrer" && document.referrer && (i = t(document.referrer)), [
|
|
1260
|
+
e ? "https:" : "",
|
|
1261
|
+
"//",
|
|
1262
|
+
i.host,
|
|
1263
|
+
i.pathname
|
|
1264
|
+
].join("");
|
|
1265
|
+
}, O = (n) => {
|
|
1266
|
+
if (n) {
|
|
1267
|
+
const { Type: e, Content: t } = n;
|
|
1268
|
+
if (e && t)
|
|
1269
|
+
return { type: e, content: t };
|
|
1270
|
+
}
|
|
1271
|
+
}, se = (n) => n.map((e) => {
|
|
1272
|
+
const t = {
|
|
1273
|
+
id: e.Id.toString(),
|
|
1274
|
+
title: e.Name,
|
|
1275
|
+
symbol: O(e.DefaultIcon),
|
|
1276
|
+
activeSymbol: e.ActiveIcon && O(e.ActiveIcon),
|
|
1277
|
+
description: e.Description || e.Attributes && e.Attributes.description || "",
|
|
1278
|
+
matches: e.GuidesCount
|
|
1279
|
+
};
|
|
1280
|
+
return e.Children && e.Children.length && (t.items = se(e.Children)), t;
|
|
1281
|
+
}), P = (n, e) => n.filter(({ Type: t }) => t === e).map(({ Id: t, Title: i, Body: s }) => ({
|
|
1282
|
+
id: t.toString(),
|
|
1283
|
+
title: i,
|
|
1284
|
+
body: s
|
|
1285
|
+
})), te = (n) => n.map(({ Id: e, Title: t, DefaultIcon: i, ListNotices: s, Notices: r }) => ({
|
|
1286
|
+
id: e.toString(),
|
|
1287
|
+
title: t,
|
|
1288
|
+
symbol: O(i),
|
|
1289
|
+
defaultHeaderOptions: {
|
|
1290
|
+
visible: !!s.length
|
|
1291
|
+
},
|
|
1292
|
+
notifications: (s || []).concat(r || []).map(({ Id: a, Title: o, Body: c, Type: h, Modified: d }) => ({
|
|
1293
|
+
id: a.toString(),
|
|
1294
|
+
title: o,
|
|
1295
|
+
body: c,
|
|
1296
|
+
modified: d,
|
|
1297
|
+
expandable: h === "listNotice"
|
|
1298
|
+
}))
|
|
1299
|
+
})), ne = ({
|
|
1300
|
+
Id: n,
|
|
1301
|
+
Title: e,
|
|
1302
|
+
DefaultIcon: t,
|
|
1303
|
+
Exits: [i],
|
|
1304
|
+
ExitType: s,
|
|
1305
|
+
ConfirmationText: r,
|
|
1306
|
+
Description: a
|
|
1307
|
+
}, o) => {
|
|
1308
|
+
const { Adapter: c } = i || { Adapter: {} }, { ClientName: h = "", Settings: d = {}, CustomClientName: g = "" } = c, u = {
|
|
1309
|
+
id: n.toString(),
|
|
1310
|
+
title: e,
|
|
1311
|
+
description: a,
|
|
1312
|
+
symbol: O(t),
|
|
1313
|
+
clientName: h === "custom.adapter" ? g : h,
|
|
1314
|
+
expanded: !0,
|
|
1315
|
+
inline: !0,
|
|
1316
|
+
body: {}
|
|
1317
|
+
};
|
|
1318
|
+
if (h.indexOf("phone") > -1 || h.indexOf("freetext") > -1) {
|
|
1319
|
+
const { displayTextBeforeClick: p, textBeforeClick: b } = d;
|
|
1320
|
+
p === "true" && (u.expanded = !1, u.title = b), h.indexOf("phone.text") > -1 ? u.body.phoneNumber = d.phoneNumber : u.body.freetext = d.freetext;
|
|
1321
|
+
}
|
|
1322
|
+
return (h.indexOf("chat.popup") > -1 || h.indexOf("link") > -1 || h === "custom.adapter" && s === "custom") && (u.body = d, u.body.confirmationFallback = r), h.indexOf("ace") > -1 && (u.body = d), u;
|
|
1323
|
+
}, q = (n = []) => n.map(
|
|
1324
|
+
({ Id: e, Title: t, TotalMatches: i, Symbol: s, DefaultIcon: r, ActiveIcon: a }) => ({
|
|
1325
|
+
id: e.toString(),
|
|
1326
|
+
title: t,
|
|
1327
|
+
matches: i,
|
|
1328
|
+
symbol: O(r || s),
|
|
1329
|
+
defaultIcon: O(r),
|
|
1330
|
+
activeIcon: O(a)
|
|
1331
|
+
})
|
|
1332
|
+
), ie = (n) => n.map(({ Id: e, Title: t, Tags: i, FirstPublishedDate: s, Modified: r }) => ({
|
|
1333
|
+
id: e.toString(),
|
|
1334
|
+
title: t,
|
|
1335
|
+
tags: q(i),
|
|
1336
|
+
published: s,
|
|
1337
|
+
modified: r
|
|
1338
|
+
})), St = (n, e) => {
|
|
1339
|
+
switch (n) {
|
|
1340
|
+
case C.MatchByCategory:
|
|
1341
|
+
case C.Match: {
|
|
1342
|
+
const t = {
|
|
1343
|
+
guides: [],
|
|
1344
|
+
matches: 0,
|
|
1345
|
+
topNotifications: [],
|
|
1346
|
+
middleNotifications: [],
|
|
1347
|
+
bottomNotifications: [],
|
|
1348
|
+
notificationLists: [],
|
|
1349
|
+
tags: [],
|
|
1350
|
+
byCategory: []
|
|
1351
|
+
}, {
|
|
1352
|
+
Matches: i,
|
|
1353
|
+
TotalMatches: s,
|
|
1354
|
+
Notices: r,
|
|
1355
|
+
NoticeLists: a,
|
|
1356
|
+
Tags: o,
|
|
1357
|
+
ByCategory: c
|
|
1358
|
+
} = e;
|
|
1359
|
+
return t.guides = ie(i), t.matches = s, t.byCategory = (c || []).map(
|
|
1360
|
+
({ Id: h, Matches: d, TotalMatches: g }) => ({
|
|
1361
|
+
id: h,
|
|
1362
|
+
guides: ie(d),
|
|
1363
|
+
matches: g
|
|
1364
|
+
})
|
|
1365
|
+
), t.tags = q(o), t.notificationLists = te(a || []), t.topNotifications = P(r || [], "noticeRowTop"), t.middleNotifications = P(r || [], "noticeRowMiddle"), t.bottomNotifications = P(r || [], "footerNotice"), t;
|
|
1366
|
+
}
|
|
1367
|
+
case C.Categories: {
|
|
1368
|
+
const { Children: t, GuidesCountTotal: i } = e;
|
|
1369
|
+
return {
|
|
1370
|
+
categories: se(t || []),
|
|
1371
|
+
matches: i
|
|
1372
|
+
};
|
|
1373
|
+
}
|
|
1374
|
+
case C.Guide: {
|
|
1375
|
+
const {
|
|
1376
|
+
Id: t,
|
|
1377
|
+
Title: i,
|
|
1378
|
+
Body: s,
|
|
1379
|
+
Related: r,
|
|
1380
|
+
Options: a,
|
|
1381
|
+
ConnectionId: o,
|
|
1382
|
+
ContactMethods: c,
|
|
1383
|
+
EnableFeedback: h,
|
|
1384
|
+
HandoverExists: d,
|
|
1385
|
+
FirstPublishedDate: g,
|
|
1386
|
+
Modified: u,
|
|
1387
|
+
ModifiedByDisplayName: p,
|
|
1388
|
+
FirstPublishedByDisplayName: b,
|
|
1389
|
+
Categories: w,
|
|
1390
|
+
Tags: l,
|
|
1391
|
+
SeoMetaDescription: f,
|
|
1392
|
+
SeoAllowIndex: K,
|
|
1393
|
+
Perspectives: _,
|
|
1394
|
+
PerspectiveKey: he,
|
|
1395
|
+
Translations: le
|
|
1396
|
+
} = e, ze = he || Object.values(_).find(
|
|
1397
|
+
(N) => N === o
|
|
1398
|
+
) || _.Default || null, de = {
|
|
1399
|
+
guide: {
|
|
1400
|
+
id: t.toString(),
|
|
1401
|
+
title: i,
|
|
1402
|
+
body: s,
|
|
1403
|
+
modified: u,
|
|
1404
|
+
published: g,
|
|
1405
|
+
modifiedBy: p,
|
|
1406
|
+
publishedBy: b,
|
|
1407
|
+
connection: o,
|
|
1408
|
+
categories: w,
|
|
1409
|
+
hasHandover: d,
|
|
1410
|
+
allowFeedback: h,
|
|
1411
|
+
seoMetaDescription: f,
|
|
1412
|
+
seoAllowIndex: K,
|
|
1413
|
+
perspectives: _,
|
|
1414
|
+
perspective: ze,
|
|
1415
|
+
translations: Object.keys(le || {}).reduce((N, T) => (N[T] = le[T].toString(), N), {})
|
|
1416
|
+
},
|
|
1417
|
+
related: ie(r || []),
|
|
1418
|
+
dialog: [],
|
|
1419
|
+
contactMethods: (c || []).map(
|
|
1420
|
+
(N) => ne(N)
|
|
1421
|
+
),
|
|
1422
|
+
tags: q(l)
|
|
1423
|
+
};
|
|
1424
|
+
return (a || []).forEach(
|
|
1425
|
+
({ CanAccess: N, Description: T, ConnectionId: Ue, Properties: k }) => {
|
|
1426
|
+
if (!N)
|
|
1427
|
+
return;
|
|
1428
|
+
const I = {
|
|
1429
|
+
id: t.toString(),
|
|
1430
|
+
title: T,
|
|
1431
|
+
connection: Ue,
|
|
1432
|
+
connectionKey: k.ConnectionKey,
|
|
1433
|
+
type: "default",
|
|
1434
|
+
parent: {
|
|
1435
|
+
id: t.toString(),
|
|
1436
|
+
title: i,
|
|
1437
|
+
tags: q(l)
|
|
1438
|
+
}
|
|
1439
|
+
};
|
|
1440
|
+
if (k.Type === "Guide" || k.Type === "Link")
|
|
1441
|
+
switch (k.Id && (I.id = k.Id.toString()), k.Uri && (I.href = k.Uri), k.Target && (I.target = k.Target), k.Type) {
|
|
1442
|
+
case "Guide":
|
|
1443
|
+
I.type = "guide";
|
|
1444
|
+
break;
|
|
1445
|
+
case "Link":
|
|
1446
|
+
I.type = "link";
|
|
1447
|
+
break;
|
|
1448
|
+
}
|
|
1449
|
+
de.dialog.push(I);
|
|
1450
|
+
}
|
|
1451
|
+
), de;
|
|
1452
|
+
}
|
|
1453
|
+
case C.Contacts: {
|
|
1454
|
+
const {
|
|
1455
|
+
Children: t,
|
|
1456
|
+
Matches: i,
|
|
1457
|
+
Notices: s,
|
|
1458
|
+
NoticeLists: r
|
|
1459
|
+
} = e;
|
|
1460
|
+
return {
|
|
1461
|
+
contactMethods: (i || []).map(
|
|
1462
|
+
(o) => ne(o)
|
|
1463
|
+
),
|
|
1464
|
+
categories: se(t || []),
|
|
1465
|
+
topNotifications: P(s || [], "noticeRowTop"),
|
|
1466
|
+
middleNotifications: P(s || [], "noticeRowMiddle"),
|
|
1467
|
+
bottomNotifications: P(s || [], "footerNotice"),
|
|
1468
|
+
notificationLists: te(r || [])
|
|
1469
|
+
};
|
|
1470
|
+
}
|
|
1471
|
+
case C.ContactMethod: {
|
|
1472
|
+
const { ContactMethod: t } = e;
|
|
1473
|
+
return ne(t || {});
|
|
1474
|
+
}
|
|
1475
|
+
case C.Tags:
|
|
1476
|
+
case C.TagsOnGuides:
|
|
1477
|
+
return q(e || []);
|
|
1478
|
+
case C.Notifications: {
|
|
1479
|
+
const { Notices: t, NoticeLists: i } = e;
|
|
1480
|
+
return {
|
|
1481
|
+
topNotifications: P(t || [], "noticeRowTop"),
|
|
1482
|
+
middleNotifications: P(t || [], "noticeRowMiddle"),
|
|
1483
|
+
bottomNotifications: P(t || [], "footerNotice"),
|
|
1484
|
+
notificationLists: te(i || [])
|
|
1485
|
+
};
|
|
1486
|
+
}
|
|
1487
|
+
default:
|
|
1488
|
+
return {};
|
|
1489
|
+
}
|
|
1490
|
+
};
|
|
1491
|
+
var Lt = /* @__PURE__ */ ((n) => (n.Guide = "guide", n.Guides = "guides", n.GuidesByCategory = "guides-by-category", n.RowNotifications = "row-notices", n.NotificationLists = "notification-lists", n.GuideCategories = "guide-categories", n.ContactMethodCategories = "contact-method-categories", n.ContactMethod = "contact-method", n.ContactMethods = "contact-methods", n.Tags = "tags", n.TagsOnGuides = "tagsonguides", n))(Lt || {}), C = /* @__PURE__ */ ((n) => (n.Match = "match", n.Categories = "categories", n.Guide = "guide", n.Contacts = "contacts", n.ContactMethod = "contact-method", n.MatchByCategory = "match-by-category", n.Tags = "tags", n.TagsOnGuides = "tagsonguides", n.Notifications = "notifications", n))(C || {}), jt = /* @__PURE__ */ ((n) => (n.Positive = "Positive", n.Negative = "Negative", n))(jt || {}), qt = /* @__PURE__ */ ((n) => (n.POPULARITY_DESCENDING = "popularity-descending", n.ALPHABETIC_ASCENDING = "alphabetic-ascending", n.ALPHABETIC_DESCENDING = "alphabetic-descending", n.MODIFIED_ASCENDING = "modified-ascending", n.MODIFIED_DESCENDING = "modified-descending", n.PUBLISHED_ASCENDING = "published-ascending", n.PUBLISHED_DESCENDING = "published-descending", n))(qt || {});
|
|
1492
|
+
const Ie = (n) => {
|
|
1493
|
+
switch (n) {
|
|
1494
|
+
case "guides":
|
|
1495
|
+
return "match";
|
|
1496
|
+
case "guides-by-category":
|
|
1497
|
+
return "match-by-category";
|
|
1498
|
+
case "guide":
|
|
1499
|
+
return "guide";
|
|
1500
|
+
case "guide-categories":
|
|
1501
|
+
return "categories";
|
|
1502
|
+
case "contact-method-categories":
|
|
1503
|
+
case "contact-methods":
|
|
1504
|
+
return "contacts";
|
|
1505
|
+
case "contact-method":
|
|
1506
|
+
return "contact-method";
|
|
1507
|
+
case "tags":
|
|
1508
|
+
return "tags";
|
|
1509
|
+
case "tagsonguides":
|
|
1510
|
+
return "tagsonguides";
|
|
1511
|
+
case "notification-lists":
|
|
1512
|
+
case "row-notices":
|
|
1513
|
+
return "notifications";
|
|
1514
|
+
default:
|
|
1515
|
+
throw "error";
|
|
1516
|
+
}
|
|
1517
|
+
}, Dt = (n) => S(void 0, null, function* () {
|
|
1518
|
+
const { invoke: e } = n.get("$widget");
|
|
1519
|
+
return (yield e("renderState")) === Q.hidden;
|
|
1520
|
+
});
|
|
1521
|
+
class W {
|
|
1522
|
+
constructor(e, t) {
|
|
1523
|
+
this.container = e, this.matchingClient = t, this.queries = /* @__PURE__ */ new Map(), this.getUnresolvedQueries = () => {
|
|
1524
|
+
let i = 0;
|
|
1525
|
+
return this.queries.forEach((s, r) => {
|
|
1526
|
+
s.some((o) => !o.resolved) && (i = 1);
|
|
1527
|
+
}), i;
|
|
1528
|
+
}, this.events = e.get("$widget").events, this.events.subscribe(
|
|
1529
|
+
"widget:settings-updated",
|
|
1530
|
+
() => this.queries = /* @__PURE__ */ new Map()
|
|
1531
|
+
), this.events.subscribe(
|
|
1532
|
+
"widget:render-state-changed",
|
|
1533
|
+
(i, { next: s, previous: r }) => {
|
|
1534
|
+
r === Q.hidden && s === Q.open && this.fetchAllUnresolvedQueries();
|
|
1535
|
+
}
|
|
1536
|
+
);
|
|
1537
|
+
}
|
|
1538
|
+
static getInstance(e, t = "dataClient") {
|
|
1539
|
+
return Et(this)(() => e.getAsync(t).then((i) => S(this, null, function* () {
|
|
1540
|
+
let s = yield e.getAsync("matchingClient");
|
|
1541
|
+
s || (s = yield Oe(e), e.registerAsync("matchingClient", () => s));
|
|
1542
|
+
let r = i;
|
|
1543
|
+
return r || (r = new W(e, s), e.registerAsync(t, () => r)), r;
|
|
1544
|
+
})));
|
|
1545
|
+
}
|
|
1546
|
+
fetch(e, t, i) {
|
|
1547
|
+
return new Promise((s, r) => {
|
|
1548
|
+
t.take, Nt(t);
|
|
1549
|
+
const a = Ie(e);
|
|
1550
|
+
let o = this.queries.get(a) || [], c = o.find((h) => F(h.params, t)) || null;
|
|
1551
|
+
if (c && (i != null && i.noCache)) {
|
|
1552
|
+
const h = o.findIndex(
|
|
1553
|
+
(d) => F(d.params, t)
|
|
1554
|
+
);
|
|
1555
|
+
o = [...o.slice(0, h), ...o.slice(h + 1)], c = null;
|
|
1556
|
+
}
|
|
1557
|
+
if (c) {
|
|
1558
|
+
const h = o.indexOf(c);
|
|
1559
|
+
if (c.resolved ? (this.events.dispatch("data-client:fetched", {
|
|
1560
|
+
params: t,
|
|
1561
|
+
type: a,
|
|
1562
|
+
response: c.data,
|
|
1563
|
+
unresolvedQueries: this.getUnresolvedQueries()
|
|
1564
|
+
}), this.track(c.data, a, c.error), c.data && c.error ? r({ error: c.error }) : s(c.data)) : c.resolvers.push({ resolve: s, reject: r }), o.splice(h, 1), o.push(c), this.queries.set(a, o), !c.loading && !c.resolved)
|
|
1565
|
+
return this.runQuery(a, t);
|
|
1566
|
+
} else
|
|
1567
|
+
return o.push({
|
|
1568
|
+
params: t,
|
|
1569
|
+
resolved: !1,
|
|
1570
|
+
loading: !0,
|
|
1571
|
+
data: {},
|
|
1572
|
+
resolvers: [{ resolve: s, reject: r }]
|
|
1573
|
+
}), this.queries.set(a, o), this.runQuery(a, t);
|
|
1574
|
+
}).then((s) => $t(s));
|
|
1575
|
+
}
|
|
1576
|
+
// query the cached data
|
|
1577
|
+
read(e, t) {
|
|
1578
|
+
const { select: i } = t, s = Ie(e);
|
|
1579
|
+
return (this.queries.get(s) || []).reduce((o, c) => {
|
|
1580
|
+
if (typeof i == "function") {
|
|
1581
|
+
const h = i(c.data);
|
|
1582
|
+
h && o.push(h);
|
|
1583
|
+
} else
|
|
1584
|
+
o.push(c.data);
|
|
1585
|
+
return o;
|
|
1586
|
+
}, []);
|
|
1587
|
+
}
|
|
1588
|
+
feedback(e, t, i) {
|
|
1589
|
+
return this.matchingClient.giveFeedback(e, t, i);
|
|
1590
|
+
}
|
|
1591
|
+
setLoadingStatus(e, t, i) {
|
|
1592
|
+
const s = this.queries.get(e) || [], r = s.find((a) => F(a.params, t));
|
|
1593
|
+
r && (r.loading = i), this.queries.set(e, s);
|
|
1594
|
+
}
|
|
1595
|
+
runQuery(e, t) {
|
|
1596
|
+
return S(this, null, function* () {
|
|
1597
|
+
const {
|
|
1598
|
+
searchPhrase: i = "",
|
|
1599
|
+
categories: s = "0",
|
|
1600
|
+
contactMethodCategoryId: r = "0",
|
|
1601
|
+
contactMethodId: a = "0",
|
|
1602
|
+
tagId: o = void 0,
|
|
1603
|
+
take: c = 5,
|
|
1604
|
+
connection: h = "",
|
|
1605
|
+
guideId: d,
|
|
1606
|
+
expandCategories: g = "descendants",
|
|
1607
|
+
currentCategory: u,
|
|
1608
|
+
sorting: p = "popularity-descending",
|
|
1609
|
+
guideIds: b = []
|
|
1610
|
+
} = t, w = i.toString().trim();
|
|
1611
|
+
if (yield Dt(this.container))
|
|
1612
|
+
return Promise.resolve();
|
|
1613
|
+
switch (e) {
|
|
1614
|
+
case "match": {
|
|
1615
|
+
const l = (f) => {
|
|
1616
|
+
const [K, _] = f.split("-");
|
|
1617
|
+
return {
|
|
1618
|
+
type: (/* @__PURE__ */ new Map([
|
|
1619
|
+
["popularity", "popularity"],
|
|
1620
|
+
["alphabetic", "title"],
|
|
1621
|
+
["modified", "lastModified"],
|
|
1622
|
+
["published", "firstPublished"]
|
|
1623
|
+
])).get(K),
|
|
1624
|
+
direction: _
|
|
1625
|
+
};
|
|
1626
|
+
};
|
|
1627
|
+
return b.length ? this.matchingClient.customRequest("guides", "POST", {
|
|
1628
|
+
configuration: { ids: b, take: +c }
|
|
1629
|
+
}).then(
|
|
1630
|
+
(f) => f && this.handleResponse(f, e, t)
|
|
1631
|
+
) : this.matchingClient.match(w, {
|
|
1632
|
+
categories: s === "0" ? [] : Array.isArray(s) ? s : [+s],
|
|
1633
|
+
take: +c,
|
|
1634
|
+
tags: o,
|
|
1635
|
+
sorting: l(p),
|
|
1636
|
+
ids: b
|
|
1637
|
+
}).then(
|
|
1638
|
+
(f) => f && this.handleResponse(f, e, t)
|
|
1639
|
+
);
|
|
1640
|
+
}
|
|
1641
|
+
case "match-by-category":
|
|
1642
|
+
return this.matchingClient.match(w, {
|
|
1643
|
+
groupByCategory: !0,
|
|
1644
|
+
categories: s === "0" ? [] : Array.isArray(s) ? s : [+s],
|
|
1645
|
+
take: +c,
|
|
1646
|
+
tags: o
|
|
1647
|
+
}).then(
|
|
1648
|
+
(l) => l && this.handleResponse(l, e, t)
|
|
1649
|
+
);
|
|
1650
|
+
case "guide":
|
|
1651
|
+
return this.matchingClient.getGuide(d, { connectionId: h }).then((l) => {
|
|
1652
|
+
l && this.handleResponse(l, e, t);
|
|
1653
|
+
}).catch((l) => {
|
|
1654
|
+
const f = {
|
|
1655
|
+
message: "Something went wrong.",
|
|
1656
|
+
status: l.status || 400
|
|
1657
|
+
};
|
|
1658
|
+
f.status === 404 && (f.message = "The guide could not be found."), this.handleResponse({}, e, t, f);
|
|
1659
|
+
});
|
|
1660
|
+
case "categories":
|
|
1661
|
+
return this.matchingClient.getCategories({
|
|
1662
|
+
phrase: w,
|
|
1663
|
+
expand: g,
|
|
1664
|
+
tags: o
|
|
1665
|
+
}).then(
|
|
1666
|
+
(l) => l && this.handleResponse(l, e, t)
|
|
1667
|
+
);
|
|
1668
|
+
case "contacts":
|
|
1669
|
+
return d ? this.matchingClient.contactMethods(+d, { phrase: w }).then(
|
|
1670
|
+
(l) => l && this.handleResponse(l, e, t)
|
|
1671
|
+
) : this.matchingClient.contacts(+r, { phrase: w }).then(
|
|
1672
|
+
(l) => l && this.handleResponse(l, e, t)
|
|
1673
|
+
);
|
|
1674
|
+
case "contact-method":
|
|
1675
|
+
return this.matchingClient.getContactMethod(+a, { guideId: d, currentCategory: u }).then(
|
|
1676
|
+
(l) => l && this.handleResponse(l, e, t)
|
|
1677
|
+
);
|
|
1678
|
+
case "tags":
|
|
1679
|
+
return this.matchingClient.customRequest("tags", "GET", {
|
|
1680
|
+
configuration: {
|
|
1681
|
+
take: 999999,
|
|
1682
|
+
phrase: w,
|
|
1683
|
+
categories: s === "0" ? [] : Array.isArray(s) ? s : [+s]
|
|
1684
|
+
}
|
|
1685
|
+
}).then(
|
|
1686
|
+
(l) => l && this.handleResponse(l, e, t)
|
|
1687
|
+
);
|
|
1688
|
+
case "tagsonguides":
|
|
1689
|
+
return this.matchingClient.customRequest("tagsonguides", "GET", {
|
|
1690
|
+
configuration: {
|
|
1691
|
+
take: 999999,
|
|
1692
|
+
phrase: w,
|
|
1693
|
+
categories: s === "0" ? [] : Array.isArray(s) ? s : [+s],
|
|
1694
|
+
tags: o
|
|
1695
|
+
}
|
|
1696
|
+
}).then(
|
|
1697
|
+
(l) => l && this.handleResponse(l, e, t)
|
|
1698
|
+
);
|
|
1699
|
+
case "notifications":
|
|
1700
|
+
return this.matchingClient.customRequest("notices", "GET", {
|
|
1701
|
+
configuration: {
|
|
1702
|
+
phrase: w,
|
|
1703
|
+
categories: s === "0" ? [] : Array.isArray(s) ? s : [+s]
|
|
1704
|
+
}
|
|
1705
|
+
}).then(
|
|
1706
|
+
(l) => l && this.handleResponse(l, e, t)
|
|
1707
|
+
);
|
|
1708
|
+
}
|
|
1709
|
+
});
|
|
1710
|
+
}
|
|
1711
|
+
handleResponse(e = {}, t, i, s) {
|
|
1712
|
+
const r = this.queries.get(t) || [], a = r.find((o) => F(o.params, i));
|
|
1713
|
+
if (a) {
|
|
1714
|
+
const o = s || St(t, e);
|
|
1715
|
+
this.track(o, t, s), a.resolvers.forEach((h) => {
|
|
1716
|
+
s ? h.reject({ error: o }) : h.resolve(o);
|
|
1717
|
+
});
|
|
1718
|
+
const c = r.indexOf(a);
|
|
1719
|
+
c > -1 && r.splice(c, 1), r.push(me(pe({}, a), {
|
|
1720
|
+
error: s,
|
|
1721
|
+
resolvers: [],
|
|
1722
|
+
data: o,
|
|
1723
|
+
resolved: !0
|
|
1724
|
+
})), this.setLoadingStatus(t, i, !1), this.queries.set(t, r), s || this.events.dispatch("data-client:fetched", {
|
|
1725
|
+
type: t,
|
|
1726
|
+
params: i,
|
|
1727
|
+
response: o,
|
|
1728
|
+
unresolvedQueries: this.getUnresolvedQueries()
|
|
1729
|
+
});
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
fetchAllUnresolvedQueries() {
|
|
1733
|
+
for (const [e, t] of this.queries)
|
|
1734
|
+
t.filter((i) => !i.resolved).forEach((i) => {
|
|
1735
|
+
this.runQuery(e, i.params);
|
|
1736
|
+
});
|
|
1737
|
+
}
|
|
1738
|
+
track(e = {}, t, i) {
|
|
1739
|
+
const s = this.container.get("$widget");
|
|
1740
|
+
s && !i ? s.events.dispatch("tracking:service-client-response", {
|
|
1741
|
+
type: t,
|
|
1742
|
+
data: e
|
|
1743
|
+
}) : s && s.events.dispatch("tracking:service-client-error", {
|
|
1744
|
+
type: t,
|
|
1745
|
+
error: i
|
|
1746
|
+
});
|
|
1747
|
+
}
|
|
1748
|
+
static create(e) {
|
|
1749
|
+
return e.getAsync("matchingClient").then((t) => S(this, null, function* () {
|
|
1750
|
+
if (t)
|
|
1751
|
+
return new W(e, t);
|
|
1752
|
+
const i = yield Oe(e);
|
|
1753
|
+
return e.registerAsync("matchingClient", () => i), new W(e, i);
|
|
1754
|
+
}));
|
|
1755
|
+
}
|
|
1756
|
+
getClient() {
|
|
1757
|
+
return this.matchingClient;
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
export {
|
|
1761
|
+
W as DataClient,
|
|
1762
|
+
Lt as DataType,
|
|
1763
|
+
jt as FeedbackType,
|
|
1764
|
+
C as ServiceClientQueryType,
|
|
1765
|
+
qt as SortingType,
|
|
1766
|
+
Ie as determineServiceClientQueryType,
|
|
1767
|
+
St as formatLegacyData
|
|
1768
|
+
};
|
|
1769
|
+
//# sourceMappingURL=index.js.map
|