@telia-ace/widget-core 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.
Files changed (3) hide show
  1. package/index.js +3 -3
  2. package/index.mjs +246 -1444
  3. package/package.json +2 -2
package/index.mjs CHANGED
@@ -1,4 +1,7 @@
1
- class De {
1
+ import { bootstrapImplementation as L, ConfigurationApi as H } from "@webprovisions/bootstrapping";
2
+ import { selectImplementations as B, createConfigurationApi as M, version as V, Environment as j, Implementation as q, Plugin as z, WidgetType as Q } from "@webprovisions/platform";
3
+ import { uuid as E, Logger as O } from "@telia-ace/widget-utilities";
4
+ class at {
2
5
  constructor(t) {
3
6
  const { events: e } = t.get("$widget");
4
7
  this.events = e.createChild(this);
@@ -9,1196 +12,11 @@ class De {
9
12
  subscribe(t, e) {
10
13
  return this.events.subscribe(
11
14
  "data:action",
12
- (s, { action: i, value: r, target: o }) => t === o && e(t, i, r)
15
+ (s, { action: i, value: r, target: c }) => t === c && e(t, i, r)
13
16
  );
14
17
  }
15
18
  }
16
- const j = (n, t, e, ...s) => {
17
- const i = `[${n.get("$environment").name || "webprovisions"}] ${e}`;
18
- switch (t) {
19
- case "info":
20
- console.info(i, ...s);
21
- break;
22
- case "warning":
23
- console.warn(i, ...s);
24
- break;
25
- case "error":
26
- console.error(i, ...s);
27
- break;
28
- }
29
- }, bt = (n) => {
30
- const t = n.container || n;
31
- return {
32
- info: (e, ...s) => j(t, "info", e, ...s),
33
- warn: (e, ...s) => j(t, "warning", e, ...s),
34
- error: (e, ...s) => j(t, "error", e, ...s)
35
- };
36
- }, ct = (n, t) => {
37
- if (!t)
38
- return !0;
39
- if (typeof t == "string") {
40
- const e = t.split(",");
41
- for (let s = 0, i = e.length; s < i; s++) {
42
- const r = e[s].trim();
43
- if (r === n || r === "*")
44
- return !0;
45
- }
46
- }
47
- return t instanceof Array ? t.indexOf(n) > -1 : !1;
48
- }, It = (n, t) => {
49
- if (typeof t == "function")
50
- return t(n);
51
- const e = typeof t == "string" ? Mt(t) : t;
52
- return !(!ct(n.tenant || "", e.tenant || "") || !ct(n.name, e.implementation || ""));
53
- }, Lt = (n) => (t) => It(t, n), q = (n) => n instanceof Array && n.length === 1 ? n[0] : n, Mt = (n) => {
54
- const t = {}, e = n.split(":");
55
- return e.length === 1 ? t.implementation = q(e[0].split(",")) : (t.tenant = q(e[0].split(",")), t.implementation = q(e[1].split(","))), t;
56
- };
57
- var D = /* @__PURE__ */ ((n) => (n.Implementation = "implementation", n.Widget = "widget", n))(D || {}), E = /* @__PURE__ */ ((n) => (n.Pre = "pre", n.Post = "post", n))(E || {});
58
- const St = (n, t, e, s) => {
59
- try {
60
- const i = new t(e, s);
61
- return {
62
- name: n,
63
- invoke: (r, o) => {
64
- let c;
65
- return i[r] && (c = i[r].call(i, o)), Promise.resolve(c);
66
- },
67
- getInstance: () => i
68
- };
69
- } catch (i) {
70
- if (i.message && i.message.indexOf("is not a constructor") >= 0)
71
- return {
72
- name: n,
73
- invoke: (r) => {
74
- let o;
75
- return r === "initialize" && (o = t(e, s)), Promise.resolve(o);
76
- },
77
- getInstance: () => t
78
- };
79
- throw i;
80
- }
81
- };
82
- function at(n, t) {
83
- return typeof n > "u" ? t : n;
84
- }
85
- let zt = class {
86
- constructor(t = {}) {
87
- this.part = t;
88
- }
89
- createCommand(t, e, s) {
90
- let i;
91
- typeof e == "function" ? i = {
92
- scope: D.Widget,
93
- stage: E.Post,
94
- defaultArgs: void 0,
95
- handlerResolver: e
96
- } : i = {
97
- scope: at(e.scope, D.Widget),
98
- stage: at(e.stage, E.Post),
99
- defaultArgs: e.defaultArgs,
100
- handlerResolver: s
101
- };
102
- let r = this.part;
103
- const o = t.split(".");
104
- return o.forEach((c, l) => {
105
- l === o.length - 1 ? r[c] || (r[c] = () => i) : r = this.part[c] = this.part[c] || {};
106
- }), this;
107
- }
108
- get() {
109
- return this.part;
110
- }
111
- };
112
- const yt = (n) => {
113
- const t = new zt({});
114
- return n(t), t.get();
115
- };
116
- yt((n) => {
117
- n.createCommand(
118
- "types.register",
119
- { scope: D.Implementation, stage: E.Pre },
120
- (t) => (e, s) => {
121
- t.container.get("$types")[e] = s;
122
- }
123
- ).createCommand(
124
- "type",
125
- { stage: E.Pre },
126
- (t) => (e) => {
127
- t.container.register("$type", e);
128
- }
129
- ).createCommand(
130
- "settings",
131
- { stage: E.Pre, defaultArgs: [null] },
132
- (t) => (e) => {
133
- t.events.dispatch(
134
- "settings:change",
135
- e,
136
- { bubbles: !0 }
137
- ), t.container.register("$settings", e);
138
- }
139
- ).createCommand(
140
- "plugin",
141
- { stage: E.Pre },
142
- (t) => (e, s, i) => {
143
- const { container: r } = t;
144
- let o = null, c = e, l = s;
145
- typeof e == "string" && (o = e, c = s, l = i);
146
- const h = (a) => {
147
- const { transformPluginSettings: u } = t.container.get("$environmentOptions"), p = u ? u(
148
- l || {},
149
- o,
150
- t.container,
151
- c
152
- ) : s;
153
- try {
154
- const d = St(
155
- o,
156
- c,
157
- r,
158
- p
159
- );
160
- r.get("$plugins").push(d), a && d.invoke("initialize", null);
161
- } catch (d) {
162
- bt(t).warn("Error when initializing plugin", d);
163
- }
164
- };
165
- t.container.get("$instance") ? h(!0) : t.events.subscribeOnce("widget:instance-created", () => h(!1));
166
- }
167
- ).createCommand(
168
- "container.register",
169
- (t) => (e, s) => {
170
- t.container.register(e, s);
171
- }
172
- ).createCommand(
173
- "container.registerAsync",
174
- (t) => (e, s) => {
175
- t.container.registerAsync(e, s);
176
- }
177
- ).createCommand(
178
- "container.registerFactory",
179
- (t) => (e, s) => {
180
- t.container.registerFactory(e, s);
181
- }
182
- ).createCommand(
183
- "container.touch",
184
- (t) => (e, s) => {
185
- t.container.touch(e, s);
186
- }
187
- ).createCommand(
188
- "csp",
189
- {},
190
- (t) => (e) => {
191
- t.container.register("csp", e);
192
- }
193
- );
194
- });
195
- function Tt(n, t, e) {
196
- return Array.from(n.querySelectorAll(
197
- `div[id^="${t}_"], div[id^="${t}:"]`
198
- )).map((s) => {
199
- if (s.id.substr(0, 7) === `${t}_`)
200
- return { widgetName: s.id.substr(7), element: s };
201
- const { 3: i } = s.id.split(":");
202
- return { widgetName: i, element: s };
203
- });
204
- }
205
- const Vt = (n) => {
206
- const t = n.map((e) => e.replace(/\./g, "\\.")).join("|");
207
- return new RegExp("^((http[s]?:)?//)?(" + t + ")/([^\\s]+)");
208
- }, jt = (n) => n.href;
209
- function qt(n, t) {
210
- const e = Vt(t), s = (i) => {
211
- const r = e.exec(jt(i));
212
- return r ? {
213
- element: i,
214
- widget: r[4]
215
- } : null;
216
- };
217
- return Array.from(n.querySelectorAll("a")).map((i) => s(i)).filter((i) => !!i).map((i) => ({
218
- element: i.element,
219
- widgetName: i.widget
220
- }));
221
- }
222
- function wt(n) {
223
- return n.filter((t, e, s) => s.indexOf(t) === e);
224
- }
225
- let Ft = class {
226
- constructor(t) {
227
- this.container = t.container, this.events = t.events;
228
- }
229
- watch(t) {
230
- const e = this.container.get("triggerElements") || [], s = wt(e.concat(t));
231
- this.container.register("triggerElements", s), this.events.dispatch(
232
- "bootstrap:trigger-elements-updated",
233
- { triggerElements: s },
234
- { bubbles: !0 }
235
- );
236
- }
237
- };
238
- function xt(n, ...t) {
239
- return n.implementation.events.subscribe("widget:create-instance", (e, s) => {
240
- if (e.target === n) {
241
- let i = n.container.get("bootstrapping.monitor");
242
- i || (i = new Ft(n), n.container.register("bootstrapping.monitor", i)), i.watch(t);
243
- }
244
- }), n.load();
245
- }
246
- function Ct(n, t = document) {
247
- var e;
248
- const s = n.bindings, i = [].concat(
249
- qt(t, s),
250
- Tt(t, ((e = n.environment) == null ? void 0 : e.name) || "")
251
- ), r = wt(i.map(({ widgetName: o }) => o)).reduce((o, c) => {
252
- const l = n.widgets.get(c);
253
- if (!l)
254
- return process.env.NODE_ENV !== "production" && bt(n).warn(`A trigger element for "${c}" was found but no widget with that name is available on the implementation ("${n.name}"). Make sure this is not a mistake.`), o;
255
- const h = i.filter((a) => a.widgetName === c).map((a) => a.element);
256
- return o.push(xt(l, ...h)), o;
257
- }, []);
258
- return Promise.all(r);
259
- }
260
- function Ht() {
261
- return new Promise((n) => {
262
- document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", () => n()) : n();
263
- });
264
- }
265
- const Wt = (n, t) => {
266
- const e = n;
267
- e.scan = (i) => Ct(e, i), e.bindings = t, e.attach = (i, ...r) => xt(i, ...r);
268
- const { environment: s } = e;
269
- return typeof s.configure > "u" && (s.configure = (i, r) => {
270
- let o, c;
271
- r ? (o = i, c = r) : (o = "*", c = i), s.implementations.query(o).forEach((l) => l.configure(c)), s.events.subscribe("implementation:created", (l, h) => {
272
- const { implementation: a } = h;
273
- Lt(o)(a) && a.configure(c);
274
- });
275
- }), e;
276
- };
277
- function Bt(n, t, e = () => [], s) {
278
- const i = { ready: !1 };
279
- n.container.register("bootstrapping", i);
280
- const r = Wt(n, t);
281
- return Ht().then(() => {
282
- n.configure((...o) => {
283
- e().forEach((c) => c(...o));
284
- });
285
- }).then(() => Ct(r, s())).then(() => (i.ready = !0, n.events.dispatch("bootstrap:ready", {}), r));
286
- }
287
- const Qt = yt((n) => {
288
- n.createCommand(
289
- "ready",
290
- { scope: D.Implementation, stage: E.Pre },
291
- (t) => (e) => {
292
- const { container: s } = t, i = s.owner;
293
- s.get("bootstrapping").ready ? e(i) : i.events.subscribeOnce("bootstrap:ready", () => {
294
- e(i);
295
- });
296
- }
297
- );
298
- }), F = /* @__PURE__ */ new WeakMap();
299
- function A() {
300
- return (n) => (F.has(n) || F.set(n, {}), F.get(n));
301
- }
302
- const H = (n, t, e, ...s) => {
303
- const i = `[${n.get("$environment").name || "webprovisions"}] ${e}`;
304
- switch (t) {
305
- case "info":
306
- console.info(i, ...s);
307
- break;
308
- case "warning":
309
- console.warn(i, ...s);
310
- break;
311
- case "error":
312
- console.error(i, ...s);
313
- break;
314
- }
315
- }, g = (n) => {
316
- const t = n.container || n;
317
- return {
318
- info: (e, ...s) => H(t, "info", e, ...s),
319
- warn: (e, ...s) => H(t, "warning", e, ...s),
320
- error: (e, ...s) => H(t, "error", e, ...s)
321
- };
322
- }, m = A(), U = (() => {
323
- let n = 0;
324
- return () => ++n;
325
- })(), G = (n, t, e) => {
326
- const s = m(n).touchQueue.get(t);
327
- s && s.forEach((i) => {
328
- i(e, n);
329
- });
330
- };
331
- class Yt {
332
- constructor(t, e, s, i) {
333
- this.key = t, this.factory = e, this.parent = s, this.container = i, this.id = U(), this.resolved = !1, this.constructed = !1, this.async = !0;
334
- }
335
- resolve() {
336
- if (!this.constructed) {
337
- const t = this.factory(this.parent, this.container);
338
- return this.constructed = !0, this.value = Promise.resolve(t).then((e) => (this.resolved = !0, G(this.container, this.key, e), e));
339
- }
340
- return this.value;
341
- }
342
- }
343
- class Ut {
344
- constructor(t, e, s, i) {
345
- this.key = t, this.value = e, this.parent = s, this.container = i, this.id = U(), this.async = !1, this.resolved = !1, this.constructed = !0, this.resolve = () => (this.resolved = !0, G(this.container, this.key, this.value), this.value);
346
- }
347
- }
348
- class Gt {
349
- constructor(t, e, s, i) {
350
- this.key = t, this.value = e, this.parent = s, this.container = i, this.id = U(), this.async = !1, this.resolved = !1, this.constructed = !1, this.resolve = () => {
351
- this.resolved = !0, this.constructed = !0;
352
- const r = this.value(this.parent, this.container);
353
- return G(this.container, this.key, this.value), r;
354
- };
355
- }
356
- }
357
- class K {
358
- /**
359
- * Creates a new instance of `Container`.
360
- * @param owner The object owning this inctance.
361
- * @param name Optional name for the container.
362
- * @param parent Parent container this should be a child of.
363
- */
364
- constructor(t, e, s) {
365
- this.owner = t, this.name = e, this.parent = s, m(this).resolvers = /* @__PURE__ */ new Map(), m(this).touchQueue = /* @__PURE__ */ new Map(), m(this).children = [];
366
- }
367
- /**
368
- * Deletes an existing resolver by its unique id.
369
- * @param id Resolver id.
370
- */
371
- delete(t) {
372
- const e = m(this).resolvers, s = Array.from(e.values()).find((i) => i.id === t);
373
- return s ? (m(this).touchQueue.delete(s.key), Promise.resolve(e.delete(s.key))) : this.parent ? this.parent.delete(t) : Promise.resolve(!1);
374
- }
375
- /**
376
- * Clears the `Container` and any child containers by deleteing all registered resolvers.
377
- */
378
- clear() {
379
- const t = m(this).resolvers, e = Array.from(t.values());
380
- return Promise.all(e.map((s) => {
381
- if (s.constructed)
382
- return Promise.resolve(s.resolve()).then((i) => {
383
- if (i !== null && typeof i == "object" && typeof i.dispose == "function")
384
- return i.dispose.call(i, this, s);
385
- });
386
- })).then(() => {
387
- e.forEach((s) => this.delete(s.id)), m(this).children.forEach((s) => s.clear());
388
- });
389
- }
390
- /**
391
- * Detaches this `Container` instance from its parent, allowing it to be garbage-collected.
392
- */
393
- detach() {
394
- if (this.parent) {
395
- const t = m(this.parent).children, e = t.indexOf(this);
396
- e > -1 && (t.splice(e, 1), delete this.parent);
397
- }
398
- }
399
- /**
400
- * Provides a way of touching a value in the `Container` without forcing it to be resolved.
401
- * @param key Key of the resolved value to touch.
402
- * @param handler Handler function for touching the resolved value.
403
- */
404
- touch(t, e) {
405
- const s = m(this).resolvers.get(t);
406
- if (s && s.constructed)
407
- Promise.resolve(s.resolve()).then((i) => {
408
- e(i, this);
409
- });
410
- else {
411
- const i = m(this).touchQueue;
412
- let r = i.get(t);
413
- r || (r = [], i.set(t, r)), r.push(e);
414
- }
415
- return this.parent && !s ? this.parent.touch(t, e) : Promise.resolve();
416
- }
417
- /**
418
- * Registers an asynchronous resolver.
419
- * @param key Key of the resolver.
420
- * @param factory Value factory.
421
- */
422
- registerAsync(t, e) {
423
- const s = m(this).resolvers.get(t);
424
- s && !s.async && process.env.NODE_ENV !== "production" && g(this).warn(`Mismatching resolver type. You are registering an async resolver with a key ('${t}') previously used by a non-async resolver.`);
425
- const i = new Yt(t, e, s, this);
426
- return m(this).resolvers.set(t, i), i.id;
427
- }
428
- /**
429
- * Registers a factory resolver for constructing the value to be resolved.
430
- * @param key Key of the resolver.
431
- * @param factory Value factory.
432
- */
433
- registerFactory(t, e) {
434
- const s = m(this).resolvers.get(t);
435
- s && s.async && process.env.NODE_ENV !== "production" && g(this).warn(`Mismatching resolver type. You are registering a non-async resolver with a key ('${t}') previously used by an async resolver.`);
436
- const i = new Gt(t, e, s, this);
437
- return m(this).resolvers.set(t, i), i.id;
438
- }
439
- /**
440
- * Registers an synchronous resolver.
441
- * @param key Key of the resolver.
442
- * @param value Value.
443
- */
444
- register(t, e) {
445
- const s = m(this).resolvers.get(t);
446
- s && s.async && process.env.NODE_ENV !== "production" && g(this).warn(`Mismatching resolver type. You are registering a non-async resolver with a key ('${t}') previously used by an async resolver.`);
447
- const i = new Ut(t, e, s, this);
448
- return m(this).resolvers.set(t, i), i.id;
449
- }
450
- /**
451
- * Gets the value for a synchronous resolver.
452
- * @param key Key of resolver to get.
453
- */
454
- get(t) {
455
- const e = m(this).resolvers.get(t);
456
- if (e)
457
- return e.async && process.env.NODE_ENV !== "production" && g(this).warn(`You are retrieving an async value (with key '${t}') by the non-async function 'container.get(key)'. This will not be supported in future versions. Use 'container.getAsync(key) instead.'`), e.resolve();
458
- if (this.parent)
459
- return this.parent.get(t);
460
- }
461
- /**
462
- * Gets the value for a asynchronous resolver.
463
- * @param key Key of resolver to get.
464
- */
465
- getAsync(t) {
466
- const e = m(this).resolvers.get(t);
467
- if (e) {
468
- if (!e.async)
469
- throw process.env.NODE_ENV !== "production" && g(this).warn(`You are retrieving a non-async value (with key '${t}') by the async function 'container.getAsync(key)'.Use 'container.get(key) instead.'`), "Mismatching resolver type";
470
- return e.resolve();
471
- }
472
- return this.parent ? this.parent.getAsync(t) : Promise.resolve(void 0);
473
- }
474
- getMany(...t) {
475
- const e = {};
476
- return t.forEach((s) => e[s] = this.get(s)), e;
477
- }
478
- getManyAsync(...t) {
479
- const e = {};
480
- return Promise.all(t.map((s) => this.getAsync(s).then((i) => e[s] = i))).then(() => e);
481
- }
482
- createChild(t, e) {
483
- const s = new K(t, e, this);
484
- return m(this).children.push(s), s;
485
- }
486
- }
487
- class ht {
488
- /**
489
- *
490
- * @param type Type of event.
491
- * @param target The target of the event, which will handle the default behavour.
492
- * @param cancelable Whether the event is cancelable by calling preventDefault().
493
- * @param bubbles Whether the event will bubble up the parent hierarchy.
494
- */
495
- constructor(t, e, s = !1, i = !1) {
496
- this.type = t, this.target = e, this.cancelable = !!s, this.bubbles = !!i, this.defaultPrevented = !1;
497
- }
498
- /**
499
- * Cancels the default behaviour (if the event is cancelable).
500
- */
501
- preventDefault() {
502
- this.cancelable && (this.defaultPrevented = !0);
503
- }
504
- }
505
- const b = A(), ut = (n, t) => [].concat(
506
- b(n).listenerLookup.get(t.toLowerCase()) || [],
507
- b(n).listenerLookup.get("*") || []
508
- ), lt = (n, t, e, s) => {
509
- let i, r;
510
- return t instanceof ht ? (i = t, r = t.type) : (i = new ht(t, n.target, !!e.cancelable, !!e.bubbles), r = t), { event: i, type: r, async: s };
511
- };
512
- class J {
513
- /**
514
- * Creates a new Event Manager instance.
515
- * @param target The target of events dispatched from this Event Manager instance.
516
- * @param parent Parent Event Manager instance.
517
- */
518
- constructor(t, e) {
519
- this.target = t, this.parent = e, b(this).listenerLookup = /* @__PURE__ */ new Map(), b(this).children = [];
520
- }
521
- /**
522
- * Clears registered event listeners in this `EventManager` as well as in any children.
523
- */
524
- clear() {
525
- b(this).listenerLookup.clear(), b(this).children.forEach((t) => t.clear());
526
- }
527
- /**
528
- * Detaches this `EventManager` instance from its parent, allowing it to be garbage-collected.
529
- */
530
- detach() {
531
- if (this.parent) {
532
- const t = b(this.parent).children, e = t.indexOf(this);
533
- e > -1 && t.splice(e, 1);
534
- }
535
- }
536
- /**
537
- * Creates an event subscription by registering an listener for an event type.
538
- * @param type Event type to subscribe to.
539
- * @param listener Listener for the event.
540
- */
541
- subscribe(t, e, s) {
542
- const i = b(this).listenerLookup, r = t.toLowerCase();
543
- return i.has(r) || i.set(r, []), i.get(r).push(e), () => this.unsubscribe(t, e);
544
- }
545
- /**
546
- * Similar to `subscribe()` but immediately removes the subscription after the first call.
547
- * @param type Event type to subscribe to.
548
- * @param listener Listener for the event.
549
- */
550
- subscribeOnce(t, e) {
551
- const s = this.subscribe(t, (i, r) => (s(), e(i, r)));
552
- }
553
- /**
554
- * Removes a listener for the specified event type.
555
- * @param type Event type to remove subscription for.
556
- * @param listener Event listener to remove.
557
- */
558
- unsubscribe(t, e) {
559
- const s = b(this).listenerLookup.get(t.toLowerCase());
560
- if (s) {
561
- const i = s.indexOf(e);
562
- i > -1 && s.splice(i, 1);
563
- }
564
- }
565
- /**
566
- * Dispatches an asynchonous event to registered event listeners.
567
- * @param eventOrType Event type or Event object to dispatch.
568
- * @param data Optional data to be passed to event listeners.
569
- * @param options Optional event options used if first parameter is an event type.
570
- */
571
- dispatchAsync(t, e, s = {}) {
572
- const { event: i, type: r } = lt(this, t, s, !0), o = ut(this, r);
573
- let c = 0;
574
- const l = o.length;
575
- let h = Promise.resolve();
576
- for (c = 0; c < l; c++)
577
- ((a) => {
578
- h = h.then((u) => u ? Promise.resolve(!0) : Promise.resolve(a(i, e)).then(() => i.defaultPrevented));
579
- })(o[c]);
580
- return h.then((a) => !a && i.bubbles && this.parent ? this.parent.dispatchAsync(i, e) : a);
581
- }
582
- /**
583
- * Dispatches an event to registered event listeners.
584
- * @param eventOrType Event type or Event object to dispatch.
585
- * @param data Optional data to be passed to event listeners.
586
- * @param options Optional event options used if first parameter is an event type.
587
- */
588
- dispatch(t, e, s = {}) {
589
- const { event: i, type: r } = lt(this, t, s, !1), o = ut(this, r);
590
- let c = 0;
591
- const l = o.length;
592
- let h = !1;
593
- for (c = 0; c < l; c++)
594
- if (o[c](i, e), i.defaultPrevented) {
595
- h = !0;
596
- break;
597
- }
598
- return !h && i.bubbles && this.parent && (h = this.parent.dispatch(i, e)), h;
599
- }
600
- /**
601
- * Creates a child instance to the current Event manager.
602
- */
603
- createChild(t) {
604
- const e = new J(t, this);
605
- return b(this).children.push(e), e;
606
- }
607
- }
608
- const I = (n, t, e) => {
609
- const s = n.get("$plugins").map((i) => {
610
- try {
611
- return i.invoke(t, e);
612
- } catch (r) {
613
- g(n).error("An error occured when invoking a plugin.", i, r);
614
- }
615
- });
616
- return Promise.all(s);
617
- };
618
- class Kt {
619
- constructor(t) {
620
- this.widget = t.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();
621
- }
622
- createInstance() {
623
- if (!this.widget.container.get("$instance")) {
624
- const t = this.widget.container.get("$types"), e = this.widget.container.get("$type");
625
- !e && g(this).error("Unable to create widget. No type is specified.");
626
- const s = t[e];
627
- !s && g(this).error(`Unable to create widget. Type '${e}' is not registered.`), this.widget.events.dispatch("widget:create-instance", {}, { bubbles: !0 });
628
- try {
629
- this.widget.container.register(
630
- "$instance",
631
- new s(this.container)
632
- );
633
- } catch (i) {
634
- g(this).error("Unable to create widget type.", i);
635
- }
636
- this.widget.events.dispatch("widget:instance-created", {}, { bubbles: !0 });
637
- }
638
- }
639
- /**
640
- * The initialization is performed before the widget is activated but after it's configured
641
- * and thus all required services are available. This hook is a good place to bind events that
642
- * should trigger activation (e.g. click on "trigger links" or routing events)
643
- * @param {object} data Custom initialization data passed to the widget.
644
- */
645
- initialize(t) {
646
- return this.initialized = this.initialized || (() => {
647
- const e = this.container.get("$instance"), s = e.initialize || (() => {
648
- });
649
- return this.initialized = Promise.resolve(s.call(e, t)).then(() => I(this.container, "initialize", t)).then(() => {
650
- });
651
- })();
652
- }
653
- /**
654
- * The activation is where the widget is actually created and rendered.
655
- * Activation can be initialized from the outside or from an event originated
656
- * in the "initialize" hook.
657
- * @param {object} data Custom activation data passed to the widget.
658
- */
659
- activate(t) {
660
- return (this.initialized || this.initialize()).then(() => {
661
- this.activated = this.activated || (() => I(this.container, "activate").then(() => {
662
- const e = this.container.get("$instance");
663
- return this.activated = e.activate(t);
664
- }))();
665
- });
666
- }
667
- deactivate() {
668
- const t = this.container.get("$instance"), e = t.deactivate || (() => {
669
- });
670
- return I(this.container, "deactivate").then(() => Promise.resolve(e.call(t))).then(() => {
671
- this.initialized = null, this.activated = null;
672
- }).then(() => {
673
- });
674
- }
675
- /**
676
- * Invokes a command on the widget component.
677
- * @param command Name of command
678
- * @param args Command arguments
679
- */
680
- invoke(t, ...e) {
681
- return I(this.container, "invoke", { command: t, args: e }).then(() => {
682
- const s = this.container.get("$instance");
683
- if (s[t])
684
- return s[t].apply(s, e);
685
- const i = s.invoke;
686
- if (i)
687
- return i.call(s, t, ...e);
688
- });
689
- }
690
- }
691
- const O = (n, t) => {
692
- if (!t)
693
- return !0;
694
- if (typeof t == "string") {
695
- const e = t.split(",");
696
- for (let s = 0, i = e.length; s < i; s++) {
697
- const r = e[s].trim();
698
- if (r === n || r === "*")
699
- return !0;
700
- }
701
- }
702
- return t instanceof Array ? t.indexOf(n) > -1 : !1;
703
- }, Jt = (n, t) => {
704
- if (typeof t == "function")
705
- return t(n);
706
- const e = typeof t == "string" ? Zt(t) : t;
707
- return !(!O(n.implementation.tenant || "", e.tenant || "") || !O(n.implementation.name, e.implementation || "") || !O(n.name, e.widget || "") || !O(n.container.get("$type"), e.type || ""));
708
- }, Xt = (n, t) => {
709
- if (typeof t == "function")
710
- return t(n);
711
- const e = typeof t == "string" ? te(t) : t;
712
- return !(!O(n.tenant || "", e.tenant || "") || !O(n.name, e.implementation || ""));
713
- }, $t = (n) => (t) => Jt(t, n), kt = (n) => (t) => Xt(t, n), x = (n) => n instanceof Array && n.length === 1 ? n[0] : n, Zt = (n) => {
714
- const t = {}, e = n.split(":");
715
- return e.length === 1 ? t.widget = x(e[0].split(",")) : e.length === 2 ? (t.implementation = x(e[0].split(",")), t.widget = x(e[1].split(","))) : (t.tenant = x(e[0].split(",")), t.implementation = x(e[1].split(",")), t.widget = x(e[2].split(","))), t;
716
- }, te = (n) => {
717
- const t = {}, e = n.split(":");
718
- return e.length === 1 ? t.implementation = x(e[0].split(",")) : (t.tenant = x(e[0].split(",")), t.implementation = x(e[1].split(","))), t;
719
- }, M = A(), pt = (n, t, e) => n.filter((s) => s.stage === t && $t(s.selector)(e));
720
- function ee(n) {
721
- const t = n.container.get("$environment");
722
- let e = M(t).configurationCache;
723
- e && (e = e.filter((s) => s[0] !== n), M(t).configurationCache = e);
724
- }
725
- var S = /* @__PURE__ */ ((n) => (n.Implementation = "implementation", n.Widget = "widget", n))(S || {}), C = /* @__PURE__ */ ((n) => (n.Pre = "pre", n.Post = "post", n))(C || {});
726
- const Et = (n, t, e) => (Object.keys(t).forEach((s) => {
727
- const i = t[s];
728
- if (typeof i == "function") {
729
- const r = i();
730
- typeof r.defaultArgs < "u" && e(r, ...r.defaultArgs), n[s] = (...o) => {
731
- const c = Object.assign(
732
- {},
733
- r,
734
- { handlerResolver: r.handlerResolver.bind({}) }
735
- );
736
- return e(c, ...o), n;
737
- };
738
- } else
739
- n[s] = Et(
740
- {},
741
- i,
742
- e
743
- );
744
- }), n), se = (n, t) => {
745
- switch (t) {
746
- case "implementation":
747
- return n.implementation;
748
- case "widget":
749
- return n;
750
- }
751
- }, dt = (n, t, e, s) => (s.forEach((i) => {
752
- Et(
753
- n,
754
- i,
755
- (r, ...o) => {
756
- const c = {
757
- selector: t,
758
- stage: r.stage,
759
- handler: (l) => {
760
- const h = se(l, r.scope), a = { container: h.container, events: h.events }, u = r.handlerResolver, p = u(a);
761
- let d = M(e.environment).configurationCache;
762
- return d || (d = M(e.environment).configurationCache = []), d.find(($) => $.indexOf(h) > -1 && $.indexOf(u) > -1) ? Promise.resolve() : (d.push([h, u]), Promise.resolve(p(...o)));
763
- }
764
- };
765
- e.instructions.push(c);
766
- }
767
- );
768
- }), n);
769
- function ne(n, t) {
770
- function e(s) {
771
- return dt(
772
- {},
773
- s,
774
- n,
775
- t
776
- );
777
- }
778
- return dt(
779
- e,
780
- "*",
781
- n,
782
- t
783
- );
784
- }
785
- class ie {
786
- constructor(t, e) {
787
- this.container = t, this.settings = e, this.widget = t.get("$widget"), this.events = this.widget.events;
788
- }
789
- }
790
- const re = (n, t, e, s) => {
791
- try {
792
- const i = new t(e, s);
793
- return {
794
- name: n,
795
- invoke: (r, o) => {
796
- let c;
797
- return i[r] && (c = i[r].call(i, o)), Promise.resolve(c);
798
- },
799
- getInstance: () => i
800
- };
801
- } catch (i) {
802
- if (i.message && i.message.indexOf("is not a constructor") >= 0)
803
- return {
804
- name: n,
805
- invoke: (r) => {
806
- let o;
807
- return r === "initialize" && (o = t(e, s)), Promise.resolve(o);
808
- },
809
- getInstance: () => t
810
- };
811
- throw i;
812
- }
813
- };
814
- function mt(n, t) {
815
- return typeof n > "u" ? t : n;
816
- }
817
- class oe {
818
- constructor(t = {}) {
819
- this.part = t;
820
- }
821
- createCommand(t, e, s) {
822
- let i;
823
- typeof e == "function" ? i = {
824
- scope: S.Widget,
825
- stage: C.Post,
826
- defaultArgs: void 0,
827
- handlerResolver: e
828
- } : i = {
829
- scope: mt(e.scope, S.Widget),
830
- stage: mt(e.stage, C.Post),
831
- defaultArgs: e.defaultArgs,
832
- handlerResolver: s
833
- };
834
- let r = this.part;
835
- const o = t.split(".");
836
- return o.forEach((c, l) => {
837
- l === o.length - 1 ? r[c] || (r[c] = () => i) : r = this.part[c] = this.part[c] || {};
838
- }), this;
839
- }
840
- get() {
841
- return this.part;
842
- }
843
- }
844
- const Pt = (n) => {
845
- const t = new oe({});
846
- return n(t), t.get();
847
- }, ce = Pt((n) => {
848
- n.createCommand(
849
- "types.register",
850
- { scope: S.Implementation, stage: C.Pre },
851
- (t) => (e, s) => {
852
- t.container.get("$types")[e] = s;
853
- }
854
- ).createCommand(
855
- "type",
856
- { stage: C.Pre },
857
- (t) => (e) => {
858
- t.container.register("$type", e);
859
- }
860
- ).createCommand(
861
- "settings",
862
- { stage: C.Pre, defaultArgs: [null] },
863
- (t) => (e) => {
864
- t.events.dispatch(
865
- "settings:change",
866
- e,
867
- { bubbles: !0 }
868
- ), t.container.register("$settings", e);
869
- }
870
- ).createCommand(
871
- "plugin",
872
- { stage: C.Pre },
873
- (t) => (e, s, i) => {
874
- const { container: r } = t;
875
- let o = null, c = e, l = s;
876
- typeof e == "string" && (o = e, c = s, l = i);
877
- const h = (a) => {
878
- const { transformPluginSettings: u } = t.container.get("$environmentOptions"), p = u ? u(
879
- l || {},
880
- o,
881
- t.container,
882
- c
883
- ) : s;
884
- try {
885
- const d = re(
886
- o,
887
- c,
888
- r,
889
- p
890
- );
891
- r.get("$plugins").push(d), a && d.invoke("initialize", null);
892
- } catch (d) {
893
- g(t).warn("Error when initializing plugin", d);
894
- }
895
- };
896
- t.container.get("$instance") ? h(!0) : t.events.subscribeOnce("widget:instance-created", () => h(!1));
897
- }
898
- ).createCommand(
899
- "container.register",
900
- (t) => (e, s) => {
901
- t.container.register(e, s);
902
- }
903
- ).createCommand(
904
- "container.registerAsync",
905
- (t) => (e, s) => {
906
- t.container.registerAsync(e, s);
907
- }
908
- ).createCommand(
909
- "container.registerFactory",
910
- (t) => (e, s) => {
911
- t.container.registerFactory(e, s);
912
- }
913
- ).createCommand(
914
- "container.touch",
915
- (t) => (e, s) => {
916
- t.container.touch(e, s);
917
- }
918
- ).createCommand(
919
- "csp",
920
- {},
921
- (t) => (e) => {
922
- t.container.register("csp", e);
923
- }
924
- );
925
- }), ae = ce;
926
- function he(n, t, e = []) {
927
- const s = [ae].concat(e), i = ne(
928
- t,
929
- s
930
- );
931
- n(i, t);
932
- }
933
- class ue {
934
- constructor() {
935
- this.tasks = [], this.current = Promise.resolve(), this.next = this.next.bind(this);
936
- }
937
- add(t, e, s, i) {
938
- this.tasks.push({ task: t, resolve: e, reject: s, done: i }), this.next();
939
- }
940
- next() {
941
- this.current = this.current.then(() => {
942
- const t = this.tasks.shift();
943
- if (t) {
944
- const e = Promise.resolve(t.task());
945
- return Promise.resolve(e).then(this.next).then(() => e.then((s) => {
946
- t.done(), t.resolve(s);
947
- })).catch((s) => (t.done(), t.reject(s), this.next()));
948
- }
949
- return Promise.resolve();
950
- });
951
- }
952
- }
953
- const L = /* @__PURE__ */ new WeakMap();
954
- function le(n) {
955
- return L.has(n) || L.set(n, new ue()), (t) => new Promise((e, s) => {
956
- const i = L.get(n);
957
- i.add(t, e, s, () => {
958
- i.tasks.length || L.delete(n);
959
- });
960
- });
961
- }
962
- const gt = (n) => typeof n < "u", _ = (n, t) => {
963
- n.events.dispatch("widget:state-change", { state: t }, { bubbles: !0 }), n.state = t, n.events.dispatch("widget:state-changed", {}, { bubbles: !0 });
964
- }, v = A(), pe = (n) => {
965
- const { container: t, events: e } = n;
966
- t.get("$controller") || (t.register("$controller", new Kt(t)), e.dispatch("widget:controller-created", {}, { bubbles: !0 }));
967
- };
968
- class de {
969
- /**
970
- * Creates a new `Widget` instance.
971
- * @param name Name of widget.
972
- * @param implementation The implementation this instance belongs to.
973
- * @param configuration Configuration for the widget.
974
- */
975
- constructor(t, e, s) {
976
- this.state = "deactivated", this.name = t, this.implementation = e, this.container = e.container.createChild(this, t), this.events = e.events.createChild(this), v(this).subscriptions = [], s && e.configure((i) => {
977
- const r = i(t);
978
- gt(s.type) && r.type(s.type), gt(s.settings) && r.settings(s.settings), s.plugins && Object.keys(s.plugins).forEach((o) => {
979
- var c;
980
- const l = (c = s.plugins) == null ? void 0 : c[o];
981
- r.plugin(o, l);
982
- });
983
- }), this.load = this.load.bind(this), this.activate = this.activate.bind(this), this.invoke = this.invoke.bind(this), this.deactivate = this.deactivate.bind(this);
984
- }
985
- /**
986
- * Initializes the widget, if not already initialized, and applies any
987
- * pending configuration.
988
- */
989
- load() {
990
- return le(this)(() => {
991
- v(this).deactivatedPromise = null;
992
- const t = this.state === "deactivated";
993
- t && (_(
994
- this,
995
- "activating"
996
- /* Activating */
997
- ), this.container.register("$widget", this), this.container.register("$controller", null), this.container.register("$plugins", []), this.container.register("$type", null), this.container.register("$instance", null)), _(
998
- this,
999
- "loading"
1000
- /* Loading */
1001
- );
1002
- const e = this.implementation.instructions, s = pt(e, C.Pre, this);
1003
- return Promise.all(s.map((i) => i.handler(this))).then(() => {
1004
- pe(this);
1005
- const i = pt(e, C.Post, this);
1006
- return Promise.all(i.map((r) => r.handler(this))).then(() => {
1007
- t && this.container.get("$controller").initialize();
1008
- });
1009
- }).then(() => (_(
1010
- this,
1011
- "activated"
1012
- /* Activated */
1013
- ), this));
1014
- });
1015
- }
1016
- /**
1017
- * Activates the widget and makes it ready for receiving commands.
1018
- * @param data Activation data
1019
- */
1020
- activate(t) {
1021
- v(this).subscriptions.push(
1022
- this.implementation.events.subscribe("implementation:configured", () => {
1023
- [
1024
- "activated",
1025
- "activating",
1026
- "loading"
1027
- /* Loading */
1028
- ].indexOf(this.state) > -1 && this.load();
1029
- })
1030
- );
1031
- const e = v(this).activatedPromise;
1032
- return e ? (process.env.NODE_ENV !== "production" && g(this).warn(`Widget '${this.name}' has already been activated. The passed arguments for this activation will be discarded.`, t), e) : v(this).activatedPromise = this.load().then(() => this.container.get("$controller").activate(t));
1033
- }
1034
- /**
1035
- * Invokes a command on a widget. If the widget isn't activate the invocation
1036
- * will be suspended until activation.
1037
- * @param command Command to invoke.
1038
- * @param args Command arguments.
1039
- */
1040
- invoke(t, ...e) {
1041
- const s = v(this).activatedPromise, i = (r, ...o) => s.then(this.load).then(() => this.container.get("$controller").invoke(r, ...o));
1042
- return s ? i(t, ...e) : (process.env.NODE_ENV !== "production" && g(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) => {
1043
- const o = this.events.subscribe("widget:state-changed", () => {
1044
- this.state === "activated" && (o(), r(i(t, ...e)));
1045
- });
1046
- }));
1047
- }
1048
- /**
1049
- * Deactivates the widget by clearing the `Container` and removing any event subscriptions in the
1050
- * `EventManager`.
1051
- */
1052
- deactivate() {
1053
- return v(this).deactivatedPromise || (this.state === "deactivated" ? Promise.resolve() : (_(
1054
- this,
1055
- "deactivating"
1056
- /* Deactivating */
1057
- ), v(this).deactivatedPromise = this.container.get("$controller").deactivate().then(() => (v(this).activatedPromise = null, v(this).subscriptions.forEach((e) => e()), v(this).subscriptions = [], this.container.clear().then(() => {
1058
- this.events.clear(), ee(this), _(
1059
- this,
1060
- "deactivated"
1061
- /* Deactivated */
1062
- );
1063
- })))));
1064
- }
1065
- }
1066
- class me {
1067
- /**
1068
- * Creates a new `Widget` instance.
1069
- * @param container The `Container` instance to base the widget upon.
1070
- */
1071
- constructor(t) {
1072
- this.container = t, this.widget = t.get("$widget"), this.settings = t.get("$settings"), this.events = this.widget.events, this.widget.events.subscribe("settings:change", (e, s) => {
1073
- this.settings = s;
1074
- });
1075
- }
1076
- }
1077
- const ft = A();
1078
- class Ot {
1079
- /**
1080
- * Creates a new Implementation instance.
1081
- * @param configuration Configuration for the implementation.
1082
- * @param environment The parent environment.
1083
- * @param configurationApiExtensions Optional configuration API extensions.
1084
- */
1085
- constructor(t, e, s = []) {
1086
- this.instructions = [], this.widgets = /* @__PURE__ */ new Map(), this.name = t.name, this.tenant = t.tenant, this.environment = e, this.container = e.container.createChild(this, this.name), this.events = e.events.createChild(this), this.container.register("$types", {}), ft(this).configurationApiExtensions = s;
1087
- }
1088
- /**
1089
- * Loads all widgets in the implementation.
1090
- */
1091
- load() {
1092
- const t = Array.from(this.widgets.values());
1093
- return Promise.all(t.map((e) => e.load())).then(() => t);
1094
- }
1095
- /**
1096
- * Configures the implementation by adding a configuration callback.
1097
- * @param configFn Callback function for configuration.
1098
- */
1099
- configure(t) {
1100
- return he(t, this, ft(this).configurationApiExtensions), this.events.dispatch(
1101
- "implementation:configured",
1102
- { implementation: this },
1103
- { bubbles: !0 }
1104
- ), this;
1105
- }
1106
- /**
1107
- * Creates a widget on the implementation and returns its `WidgetData`.
1108
- * @param name Widget name.
1109
- * @param configuration Widget configuration.
1110
- */
1111
- createWidget(t, e) {
1112
- const s = new de(t, this, e);
1113
- return this.widgets.set(s.name, s), s;
1114
- }
1115
- }
1116
- function ge(n, t, e) {
1117
- const s = new Ot(n, t, e);
1118
- return n.widgets && Object.keys(n.widgets).forEach((i) => {
1119
- var r;
1120
- const o = (r = n.widgets) == null ? void 0 : r[i];
1121
- s.createWidget(i, o);
1122
- }), s;
1123
- }
1124
- class z {
1125
- constructor(t, e) {
1126
- this.selectorFactory = e, typeof t == "function" ? this.resolver = t : this.resolver = () => t;
1127
- }
1128
- append(t) {
1129
- const e = typeof t == "function" ? t : () => t;
1130
- return new z(
1131
- () => this.all().concat(e()),
1132
- this.selectorFactory
1133
- );
1134
- }
1135
- all() {
1136
- return this.resolver().concat([]);
1137
- }
1138
- query(t) {
1139
- return this.all().filter(this.selectorFactory(t));
1140
- }
1141
- find(t) {
1142
- const e = this.query(t);
1143
- if (e.length)
1144
- return e[0];
1145
- }
1146
- }
1147
- const X = "#____version____#", W = A(), fe = (n) => n.tenant ? `${n.name}:${n.tenant}` : n.name, At = class {
1148
- constructor(n, t = [], e = {}) {
1149
- this.widgets = new z(
1150
- () => {
1151
- let s = [];
1152
- return this.implementations.all().forEach((i) => {
1153
- s = s.concat(Array.from(i.widgets.values()));
1154
- }), s;
1155
- },
1156
- $t
1157
- ), this.implementations = new z([], kt), this.name = n, this.container = new K(this, n), this.events = new J(this), this.container.register("$version", X), this.container.register("$environment", this), this.container.register("$environmentOptions", e), W(this).configurationApiExtensions = t;
1158
- }
1159
- /**
1160
- * Creates an implementation based on the provided configuration.
1161
- * @param config Implementation configuration.
1162
- */
1163
- createImplementation(n) {
1164
- const t = fe(n);
1165
- let e = this.implementations.find(t);
1166
- if (e)
1167
- return process.env.NODE_ENV !== "production" && g(e).warn(`Implementation "${t}" already exist on current environment.`), e;
1168
- const s = W(this).configurationApiExtensions;
1169
- return e = ge(
1170
- n,
1171
- this,
1172
- s
1173
- ), this.implementations = this.implementations.append([e]), this.events.dispatch("implementation:created", { implementation: e }), e;
1174
- }
1175
- /**
1176
- * Patches the Environment instance configuration.
1177
- * @param configuration Environment configuration.
1178
- */
1179
- patch(n = {}) {
1180
- const { name: t, configurationApiExtensions: e } = n;
1181
- typeof t < "u" && t !== null && (this.name = t), e && e.forEach(
1182
- (s) => {
1183
- W(this).configurationApiExtensions.push(s);
1184
- }
1185
- );
1186
- }
1187
- /**
1188
- * Creates a new Environment instance based on the provided configuration.
1189
- * @param configuration Environment configuration.
1190
- */
1191
- static create(n = {}) {
1192
- return new At(
1193
- n.name || "",
1194
- n.configurationApiExtensions,
1195
- n.options
1196
- );
1197
- }
1198
- };
1199
- let Nt = At;
1200
- Nt.version = X;
1201
- const Me = (n, t, e = {}) => Bt(
19
+ const pt = (n, t, e = {}) => L(
1202
20
  n,
1203
21
  n.bindings,
1204
22
  () => {
@@ -1206,13 +24,13 @@ const Me = (n, t, e = {}) => Bt(
1206
24
  const r = i[0];
1207
25
  if (typeof r == "function")
1208
26
  return r;
1209
- if (kt(r)(n))
27
+ if (B(r)(n))
1210
28
  return i[1];
1211
29
  }).filter((i) => !!i);
1212
30
  return (t ? [t] : []).concat(s);
1213
31
  },
1214
32
  e.rootElementResolver || (() => document.body)
1215
- ), ve = (n) => {
33
+ ), F = (n) => {
1216
34
  const t = [];
1217
35
  return [
1218
36
  (s, i) => {
@@ -1225,7 +43,7 @@ const Me = (n, t, e = {}) => Bt(
1225
43
  }
1226
44
  ];
1227
45
  };
1228
- class Z {
46
+ class N {
1229
47
  constructor(t, e = []) {
1230
48
  this.platform = t, this.rules = e;
1231
49
  }
@@ -1239,17 +57,17 @@ class Z {
1239
57
  return this.rules.push({ id: t }), this;
1240
58
  }
1241
59
  select() {
1242
- return new be(this.platform, this);
60
+ return new G(this.platform, this);
1243
61
  }
1244
62
  }
1245
- class _t {
63
+ class S {
1246
64
  constructor(t, e, s) {
1247
- this.platform = t, this.node = e, this.actions = new tt(
65
+ this.platform = t, this.node = e, this.actions = new P(
1248
66
  t,
1249
- new Z(t).withId(e.id),
67
+ new N(t).withId(e.id),
1250
68
  s
1251
69
  );
1252
- const [i, r] = ve(this.platform.events);
70
+ const [i, r] = F(this.platform.events);
1253
71
  this.subscribe = i, this.unsubscribe = r;
1254
72
  }
1255
73
  properties(t) {
@@ -1278,9 +96,9 @@ class _t {
1278
96
  this.unsubscribe(), this.actions.dispose();
1279
97
  }
1280
98
  }
1281
- class be {
99
+ class G {
1282
100
  constructor(t, e, s = !0) {
1283
- this.platform = t, this.target = e, this.clearOnDispose = s, this.removes = [], this.actions = new tt(this.platform, this.target);
101
+ this.platform = t, this.target = e, this.clearOnDispose = s, this.removes = [], this.actions = new P(this.platform, this.target);
1284
102
  }
1285
103
  writeProperties(t, e) {
1286
104
  this.removes.push(
@@ -1318,21 +136,21 @@ class be {
1318
136
  }), this.actions.dispose();
1319
137
  }
1320
138
  }
1321
- const ye = (n, t, e) => {
1322
- const s = n.concat(), i = (r, o, c) => {
1323
- let l = !0;
139
+ const K = (n, t, e) => {
140
+ const s = n.concat(), i = (r, c, a) => {
141
+ let u = !0;
1324
142
  if (s.length) {
1325
- const h = s.shift(), a = (u, p) => (l = !1, i(u, Object.assign({}, o, p), c));
1326
- return Promise.resolve(h(r, a, c)).then((u) => ({
1327
- ...u,
1328
- cancelled: l
143
+ const h = s.shift(), o = (p, l) => (u = !1, i(p, Object.assign({}, c, l), a));
144
+ return Promise.resolve(h(r, o, a)).then((p) => ({
145
+ ...p,
146
+ cancelled: u
1329
147
  }));
1330
148
  }
1331
- return Promise.resolve({ data: r, cancelled: !1, options: o });
149
+ return Promise.resolve({ data: r, cancelled: !1, options: c });
1332
150
  };
1333
151
  return i(t, {}, e);
1334
152
  };
1335
- class tt {
153
+ class P {
1336
154
  constructor(t, e, s) {
1337
155
  this.platform = t, this.target = e, this.ns = s, this.subscriptions = [], this.create = this.create.bind(this);
1338
156
  }
@@ -1355,26 +173,26 @@ class tt {
1355
173
  const s = this.platform.nodes.all.concat(
1356
174
  this.platform.nodes.detached
1357
175
  ), i = {}, r = this.platform.actionsState.handlers.filter(
1358
- (o) => o.key === t && (!o.ns || !this.ns || o.ns === this.ns)
176
+ (c) => c.key === t && (!c.ns || !this.ns || c.ns === this.ns)
1359
177
  );
1360
178
  return Promise.all(
1361
- r.map((o) => {
1362
- const c = s.filter(
1363
- (h) => o.target.match(h) && this.target.match(h)
1364
- ), l = this.platform.actionsState.watchers.filter((h) => h.key === t && (!h.ns || !this.ns || h.ns === this.ns) && c.some((a) => h.target.match(a))).map((h) => h.fn);
179
+ r.map((c) => {
180
+ const a = s.filter(
181
+ (h) => c.target.match(h) && this.target.match(h)
182
+ ), u = this.platform.actionsState.watchers.filter((h) => h.key === t && (!h.ns || !this.ns || h.ns === this.ns) && a.some((o) => h.target.match(o))).map((h) => h.fn);
1365
183
  return Promise.all(
1366
- c.map((h) => {
1367
- const a = new _t(
184
+ a.map((h) => {
185
+ const o = new S(
1368
186
  this.platform,
1369
187
  h,
1370
188
  this.ns
1371
189
  );
1372
- return ye(l, e, a).then((u) => {
1373
- const { data: p = {}, options: d, cancelled: $ } = u;
190
+ return K(u, e, o).then((p) => {
191
+ const { data: l = {}, options: d, cancelled: b } = p;
1374
192
  return Promise.resolve(
1375
- $ ? {} : o.fn(p, d, a)
1376
- ).then((N) => {
1377
- i[h.id] = N;
193
+ b ? {} : c.fn(l, d, o)
194
+ ).then((g) => {
195
+ i[h.id] = g;
1378
196
  });
1379
197
  });
1380
198
  })
@@ -1386,51 +204,35 @@ class tt {
1386
204
  let s = t, i = this.ns;
1387
205
  const r = t.split(".");
1388
206
  r.length > 1 && (i = r[0], s = r.splice(1).join("."));
1389
- const o = {
207
+ const c = {
1390
208
  fn: e,
1391
209
  target: this.target,
1392
210
  key: s,
1393
211
  ns: i
1394
212
  };
1395
- this.platform.actionsState.watchers.push(o);
1396
- const c = () => {
1397
- const l = this.platform.actionsState.watchers.indexOf(o);
1398
- l > -1 && this.platform.actionsState.watchers.splice(l, 1);
213
+ this.platform.actionsState.watchers.push(c);
214
+ const a = () => {
215
+ const u = this.platform.actionsState.watchers.indexOf(c);
216
+ u > -1 && this.platform.actionsState.watchers.splice(u, 1);
1399
217
  };
1400
- return this.subscriptions.push(c), c;
218
+ return this.subscriptions.push(a), a;
1401
219
  }
1402
220
  dispose() {
1403
221
  this.subscriptions.forEach((t) => t());
1404
222
  }
1405
223
  }
1406
- const Se = Pt((n) => {
224
+ const ut = M((n) => {
1407
225
  n.createCommand("components", (t) => (e) => {
1408
226
  t.events.subscribeOnce("components:platform-created", (s, { platform: i }) => {
1409
- e.handlers && e.handlers.forEach(([r, o]) => {
1410
- i.addComponentHandler(r, o);
227
+ e.handlers && e.handlers.forEach(([r, c]) => {
228
+ i.addComponentHandler(r, c);
1411
229
  });
1412
230
  });
1413
231
  });
1414
- }), T = (n, t, ...e) => typeof t == "string" ? n(`[humany] ${t}`, ...e) : n(t, ...e), R = class {
1415
- constructor() {
1416
- this.keys = [], this.log = (n, ...t) => this.lookup(n, () => R.log(...t)), this.warn = (n, ...t) => this.lookup(n, () => R.warn(...t)), this.error = (n, ...t) => this.lookup(n, () => R.error(...t)), this.info = (n, ...t) => this.lookup(n, () => R.info(...t));
1417
- }
1418
- lookup(n, t) {
1419
- this.keys.indexOf(n) === -1 && (this.keys.push(n), t());
1420
- }
1421
- };
1422
- let P = R;
1423
- P.log = (...n) => T(console.log, ...n);
1424
- P.warn = (...n) => T(console.warn, ...n);
1425
- P.error = (...n) => T(console.error, ...n);
1426
- P.info = (...n) => T(console.info, ...n);
1427
- const k = () => Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
1428
- function et() {
1429
- return k() + k() + "-" + k() + "-" + k() + "-" + k() + "-" + k() + k() + k();
1430
- }
1431
- class vt {
232
+ });
233
+ class I {
1432
234
  constructor(t, e) {
1433
- this.events = t, this.tags = [], this.children = {}, this.changesets = [], this.mountCount = 0, this.id = et(), this.type = e, this.attributes = {
235
+ this.events = t, this.tags = [], this.children = {}, this.changesets = [], this.mountCount = 0, this.id = E(), this.type = e, this.attributes = {
1434
236
  context: {},
1435
237
  properties: {},
1436
238
  layout: {},
@@ -1439,7 +241,7 @@ class vt {
1439
241
  }
1440
242
  mount(t, e) {
1441
243
  let s = t.get("mounted-nodes");
1442
- return s || (s = /* @__PURE__ */ new Map(), t.register("mounted-nodes", s)), s.has(this) ? (process.env.NODE_ENV !== "production" && P.error(
244
+ return s || (s = /* @__PURE__ */ new Map(), t.register("mounted-nodes", s)), s.has(this) ? (process.env.NODE_ENV !== "production" && O.error(
1443
245
  "Trying to mount an already mounted component node.",
1444
246
  this
1445
247
  ), () => {
@@ -1467,8 +269,8 @@ class vt {
1467
269
  const r = [{ properties: t }, e];
1468
270
  return this.changesets.push(r), this.events.dispatch("components:set-properties", { node: this }), () => {
1469
271
  if (s) {
1470
- const o = this.changesets.indexOf(r);
1471
- o > -1 && (this.changesets.splice(o, 1), this.events.dispatch("components:set-properties", { node: this }));
272
+ const c = this.changesets.indexOf(r);
273
+ c > -1 && (this.changesets.splice(c, 1), this.events.dispatch("components:set-properties", { node: this }));
1472
274
  }
1473
275
  };
1474
276
  }
@@ -1476,8 +278,8 @@ class vt {
1476
278
  const r = [{ properties: t }, e];
1477
279
  return this.changesets.push(r), this.events.dispatch("components:set-properties", { node: this }), () => {
1478
280
  if (s) {
1479
- const o = this.changesets.indexOf(r);
1480
- o > -1 && (this.changesets.splice(o, 1), this.events.dispatch("components:set-properties", { node: this }));
281
+ const c = this.changesets.indexOf(r);
282
+ c > -1 && (this.changesets.splice(c, 1), this.events.dispatch("components:set-properties", { node: this }));
1481
283
  }
1482
284
  };
1483
285
  }
@@ -1486,8 +288,8 @@ class vt {
1486
288
  return this.changesets.push(r), this.events.dispatch("components:set-layout", { node: this }), () => {
1487
289
  if (!s)
1488
290
  return;
1489
- const o = this.changesets.indexOf(r);
1490
- o > -1 && (this.changesets.splice(o, 1), this.events.dispatch("components:set-layout", { node: this }));
291
+ const c = this.changesets.indexOf(r);
292
+ c > -1 && (this.changesets.splice(c, 1), this.events.dispatch("components:set-layout", { node: this }));
1491
293
  };
1492
294
  }
1493
295
  writeContext(t, e = {}, s) {
@@ -1495,15 +297,15 @@ class vt {
1495
297
  return this.changesets.push(r), this.events.dispatch("components:set-context", { node: this }), () => {
1496
298
  if (!s)
1497
299
  return;
1498
- const o = this.changesets.indexOf(r);
1499
- o > -1 && (this.changesets.splice(o, 1), this.events.dispatch("components:set-context", { node: this }));
300
+ const c = this.changesets.indexOf(r);
301
+ c > -1 && (this.changesets.splice(c, 1), this.events.dispatch("components:set-context", { node: this }));
1500
302
  };
1501
303
  }
1502
304
  getChildren(t = "default") {
1503
305
  const e = this.children[t] || [];
1504
306
  return e.reduce((s, i, r) => {
1505
- const { order: o = r } = i.attributes.layout;
1506
- return s[o] ? s.splice(o, 0, i) : s[o] = i, s;
307
+ const { order: c = r } = i.attributes.layout;
308
+ return s[c] ? s.splice(c, 0, i) : s[c] = i, s;
1507
309
  }, Array(e.length));
1508
310
  }
1509
311
  remove() {
@@ -1519,50 +321,50 @@ class vt {
1519
321
  }), delete t.parent;
1520
322
  }
1521
323
  }
1522
- const Rt = (n, t, e) => {
324
+ const D = (n, t, e) => {
1523
325
  for (let s = 0, i = n.length; s < i && e(n[s]) !== !0; s++) {
1524
- const r = t[n[s].id] || "default", o = n[s].getChildren(r);
1525
- Rt(o, t, e);
326
+ const r = t[n[s].id] || "default", c = n[s].getChildren(r);
327
+ D(c, t, e);
1526
328
  }
1527
- }, st = (n, t, e) => {
329
+ }, k = (n, t, e) => {
1528
330
  if (e(n) !== !0) {
1529
331
  const s = t[n.id] || "default", i = n.children[s];
1530
- Rt(i, t, e);
332
+ D(i, t, e);
1531
333
  }
1532
- }, B = (n, t) => {
334
+ }, x = (n, t) => {
1533
335
  const e = [];
1534
- return st(n, t, (s) => {
336
+ return k(n, t, (s) => {
1535
337
  e.push(s);
1536
338
  }), e;
1537
- }, we = (n, t, e) => {
339
+ }, U = (n, t, e) => {
1538
340
  let s;
1539
- return st(n, t, (i) => {
341
+ return k(n, t, (i) => {
1540
342
  if (e(i))
1541
343
  return s = i, !0;
1542
344
  }), s;
1543
345
  };
1544
- class xe {
346
+ class W {
1545
347
  constructor(t, e, s) {
1546
348
  this.root = t, this.switches = e, this.all = [], this.visible = [], this.detached = [], s.subscribe("components:node-appended", (i, r) => {
1547
- this.all.push(r.node), this.visible = B(t, e);
349
+ this.all.push(r.node), this.visible = x(t, e);
1548
350
  }), s.subscribe("components:node-removed", (i, r) => {
1549
- let o = this.all.indexOf(r.node);
1550
- o > -1 && this.all.splice(o, 1), o = this.visible.indexOf(r.node), o > -1 && this.visible.splice(o, 1), this.visible = B(t, e);
351
+ let c = this.all.indexOf(r.node);
352
+ c > -1 && this.all.splice(c, 1), c = this.visible.indexOf(r.node), c > -1 && this.visible.splice(c, 1), this.visible = x(t, e);
1551
353
  }), s.subscribe("components:node-switched", (i, r) => {
1552
- this.visible = B(t, e);
354
+ this.visible = x(t, e);
1553
355
  });
1554
356
  }
1555
357
  query(t = {}) {
1556
358
  const e = [];
1557
- return st(this.root, this.switches, (s) => {
359
+ return k(this.root, this.switches, (s) => {
1558
360
  Object.keys(t).every((r) => t[r] === s[r]) && e.push(s);
1559
361
  }), e;
1560
362
  }
1561
363
  get(t) {
1562
- return we(this.root, this.switches, (e) => e.id === t) || this.detached.find((e) => e.id === t);
364
+ return U(this.root, this.switches, (e) => e.id === t) || this.detached.find((e) => e.id === t);
1563
365
  }
1564
366
  }
1565
- class Ce {
367
+ class Y {
1566
368
  constructor() {
1567
369
  this.handlers = /* @__PURE__ */ new Map();
1568
370
  }
@@ -1573,81 +375,81 @@ class Ce {
1573
375
  return this.handlers.get(t);
1574
376
  }
1575
377
  }
1576
- const $e = (n) => {
378
+ const J = (n) => {
1577
379
  let t = n, e = 0;
1578
380
  for (; t.parent; )
1579
381
  e = e + 1, t = t.parent;
1580
382
  return e;
1581
- }, ke = (n) => n.map(([e, s]) => [$e(e), e, s]).sort(([e], [s]) => e - s).map(([, e, s]) => [e, s]), Q = (n) => n instanceof Date ? !1 : n && typeof n == "object" && !Array.isArray(n), w = (n, ...t) => {
383
+ }, X = (n) => n.map(([e, s]) => [J(e), e, s]).sort(([e], [s]) => e - s).map(([, e, s]) => [e, s]), w = (n) => n instanceof Date ? !1 : n && typeof n == "object" && !Array.isArray(n), v = (n, ...t) => {
1582
384
  if (!t.length)
1583
385
  return n;
1584
386
  const e = t.shift();
1585
- if (Q(n) && Q(e))
387
+ if (w(n) && w(e))
1586
388
  for (const s in e)
1587
- Q(e[s]) ? (n[s] || Object.assign(n, { [s]: {} }), w(n[s], e[s])) : Object.assign(n, { [s]: e[s] });
1588
- return w(n, ...t);
1589
- }, Ee = (n, t) => !n || n === "all" ? !0 : n.some((e) => t.indexOf(e) > -1), Pe = (n, t) => {
389
+ w(e[s]) ? (n[s] || Object.assign(n, { [s]: {} }), v(n[s], e[s])) : Object.assign(n, { [s]: e[s] });
390
+ return v(n, ...t);
391
+ }, Z = (n, t) => !n || n === "all" ? !0 : n.some((e) => t.indexOf(e) > -1), tt = (n, t) => {
1590
392
  let e = [], s = [], i;
1591
393
  const r = () => {
1592
394
  process.env.NODE_ENV !== "production" && console.time("state-processor.flush");
1593
- const c = /* @__PURE__ */ new Map(), l = ke(e.map((a, u) => [a, s[u]])), h = (a, u) => {
1594
- var ot;
1595
- const p = c.get(a) || {}, d = u.context && !p.context, $ = u.properties && !p.properties, N = u.layout && !p.layout;
1596
- c.set(a, {
1597
- context: p.context || d,
1598
- properties: p.properties || $,
1599
- layout: p.layout || N
1600
- }), $ && (a.attributes.properties = {}), N && (a.attributes.layout = {}), d && (a.attributes.context = w({}, (ot = a.parent) == null ? void 0 : ot.attributes.context));
1601
- const nt = [], it = [], rt = [];
1602
- if (a.changesets.forEach((y) => {
1603
- const [f, V] = y;
1604
- Ee(V.breakpoints, n.breakpoints) && ($ && (typeof f.properties == "function" ? nt.push(
395
+ const a = /* @__PURE__ */ new Map(), u = X(e.map((o, p) => [o, s[p]])), h = (o, p) => {
396
+ var T;
397
+ const l = a.get(o) || {}, d = p.context && !l.context, b = p.properties && !l.properties, g = p.layout && !l.layout;
398
+ a.set(o, {
399
+ context: l.context || d,
400
+ properties: l.properties || b,
401
+ layout: l.layout || g
402
+ }), b && (o.attributes.properties = {}), g && (o.attributes.layout = {}), d && (o.attributes.context = v({}, (T = o.parent) == null ? void 0 : T.attributes.context));
403
+ const $ = [], R = [], A = [];
404
+ if (o.changesets.forEach((m) => {
405
+ const [f, y] = m;
406
+ Z(y.breakpoints, n.breakpoints) && (b && (typeof f.properties == "function" ? $.push(
1605
407
  f.properties
1606
- ) : w(a.attributes.properties, f.properties)), N && (typeof f.layout == "function" ? it.push(f.layout) : w(a.attributes.layout, f.layout)), d && (typeof f.context == "function" ? rt.push(f.context) : w(a.attributes.context, f.context)));
1607
- }), nt.forEach((y) => {
1608
- w(a.attributes.properties, y(a.attributes.properties));
1609
- }), it.forEach((y) => {
1610
- w(a.attributes.layout, y(a.attributes.layout));
1611
- }), rt.forEach((y) => {
1612
- w(a.attributes.context, y(a.attributes.context));
1613
- }), d || u.recursive) {
1614
- const y = n.getBranch(a), f = u.recursive ? u : {
408
+ ) : v(o.attributes.properties, f.properties)), g && (typeof f.layout == "function" ? R.push(f.layout) : v(o.attributes.layout, f.layout)), d && (typeof f.context == "function" ? A.push(f.context) : v(o.attributes.context, f.context)));
409
+ }), $.forEach((m) => {
410
+ v(o.attributes.properties, m(o.attributes.properties));
411
+ }), R.forEach((m) => {
412
+ v(o.attributes.layout, m(o.attributes.layout));
413
+ }), A.forEach((m) => {
414
+ v(o.attributes.context, m(o.attributes.context));
415
+ }), d || p.recursive) {
416
+ const m = n.getBranch(o), f = p.recursive ? p : {
1615
417
  context: !!d
1616
418
  };
1617
- a.getChildren(y).forEach((V) => {
1618
- h(V, f);
419
+ o.getChildren(m).forEach((y) => {
420
+ h(y, f);
1619
421
  });
1620
422
  }
1621
423
  };
1622
- process.env.NODE_ENV !== "production" && console.timeEnd("state-processor.flush"), l.forEach(([a, u]) => {
1623
- h(a, u);
1624
- }), e = [], s = [], t(c);
1625
- }, o = () => {
424
+ process.env.NODE_ENV !== "production" && console.timeEnd("state-processor.flush"), u.forEach(([o, p]) => {
425
+ h(o, p);
426
+ }), e = [], s = [], t(a);
427
+ }, c = () => {
1626
428
  clearTimeout(i), i = setTimeout(r, 0);
1627
429
  };
1628
- return (c, l) => {
1629
- const h = e.indexOf(c);
430
+ return (a, u) => {
431
+ const h = e.indexOf(a);
1630
432
  if (h > -1) {
1631
- const a = s[h];
1632
- return l.context && (a.context = !0), l.properties && (a.properties = !0), l.layout && (a.layout = !0), l.recursive && (a.recursive = !0), o();
433
+ const o = s[h];
434
+ return u.context && (o.context = !0), u.properties && (o.properties = !0), u.layout && (o.layout = !0), u.recursive && (o.recursive = !0), c();
1633
435
  }
1634
- return e.push(c), s.push(l), o();
436
+ return e.push(a), s.push(u), c();
1635
437
  };
1636
438
  };
1637
- class Oe {
439
+ class et {
1638
440
  constructor(t, e = {}) {
1639
- this.providers = e, this.breakpoints = [], this.actionsState = { handlers: [], watchers: [] }, this.switches = {}, this.changesets = [], this.subscriptions = [], this.customComponentHandler = new Ce(), this.events = t.events.createChild(this);
1640
- const s = new vt(this.events, "root");
1641
- s.name = `root-${t.name}`, this.nodes = new xe(s, this.switches, this.events);
1642
- const i = this.processNode = Pe(this, (r) => {
1643
- const o = Array.from(r.keys());
1644
- process.env.NODE_ENV !== "production" && console.info(`STATE PROCESSOR: ${o.length} node(s) processed:
1645
- ${o.map(
1646
- (c) => `${c.name || "<no name>"} (${c.id})
441
+ this.providers = e, this.breakpoints = [], this.actionsState = { handlers: [], watchers: [] }, this.switches = {}, this.changesets = [], this.subscriptions = [], this.customComponentHandler = new Y(), this.events = t.events.createChild(this);
442
+ const s = new I(this.events, "root");
443
+ s.name = `root-${t.name}`, this.nodes = new W(s, this.switches, this.events);
444
+ const i = this.processNode = tt(this, (r) => {
445
+ const c = Array.from(r.keys());
446
+ process.env.NODE_ENV !== "production" && console.info(`STATE PROCESSOR: ${c.length} node(s) processed:
447
+ ${c.map(
448
+ (a) => `${a.name || "<no name>"} (${a.id})
1647
449
  `
1648
- )}`), o.forEach((c) => {
1649
- const l = r.get(c);
1650
- c.parent && c.parent.type === "root" && this.events.dispatch("components:root-children-changed", { node: c }), l != null && l.context && this.events.dispatch("components:context-changed", { node: c }), l != null && l.properties && this.events.dispatch("components:properties-changed", { node: c }), l != null && l.layout && this.events.dispatch("components:layout-changed", { node: c });
450
+ )}`), c.forEach((a) => {
451
+ const u = r.get(a);
452
+ a.parent && a.parent.type === "root" && this.events.dispatch("components:root-children-changed", { node: a }), u != null && u.context && this.events.dispatch("components:context-changed", { node: a }), u != null && u.properties && this.events.dispatch("components:properties-changed", { node: a }), u != null && u.layout && this.events.dispatch("components:layout-changed", { node: a });
1651
453
  }), this.events.dispatch("components:component-model-initialized", {}, { bubbles: !0 });
1652
454
  });
1653
455
  Promise.all(
@@ -1655,52 +457,52 @@ ${o.map(
1655
457
  ), this.subscriptions.push(
1656
458
  this.events.subscribe(
1657
459
  "components:node-appended",
1658
- (r, o) => {
1659
- const { node: c } = o;
1660
- this.changesets.forEach((l) => {
1661
- const { changeset: h, target: a, removes: u } = l, [p, d] = h;
1662
- a.match(o.node) && (p.properties && u.push(c.writeProperties(p.properties, d)), p.context && u.push(c.writeContext(p.context, d)), p.layout && u.push(c.writeLayout(p.layout, d)));
460
+ (r, c) => {
461
+ const { node: a } = c;
462
+ this.changesets.forEach((u) => {
463
+ const { changeset: h, target: o, removes: p } = u, [l, d] = h;
464
+ o.match(c.node) && (l.properties && p.push(a.writeProperties(l.properties, d)), l.context && p.push(a.writeContext(l.context, d)), l.layout && p.push(a.writeLayout(l.layout, d)));
1663
465
  });
1664
466
  }
1665
467
  )
1666
468
  ), this.subscriptions.push(
1667
469
  this.events.subscribe(
1668
470
  "components:node-appended",
1669
- (r, o) => {
1670
- i(o.node, { properties: !0, context: !0 });
471
+ (r, c) => {
472
+ i(c.node, { properties: !0, context: !0 });
1671
473
  }
1672
474
  )
1673
475
  ), this.subscriptions.push(
1674
476
  this.events.subscribe(
1675
477
  "components:set-properties",
1676
- (r, o) => {
1677
- i(o.node, { properties: !0 });
478
+ (r, c) => {
479
+ i(c.node, { properties: !0 });
1678
480
  }
1679
481
  )
1680
482
  ), this.subscriptions.push(
1681
483
  this.events.subscribe(
1682
484
  "components:set-context",
1683
- (r, o) => {
1684
- i(o.node, { properties: !0, context: !0 });
485
+ (r, c) => {
486
+ i(c.node, { properties: !0, context: !0 });
1685
487
  }
1686
488
  )
1687
489
  ), this.subscriptions.push(
1688
490
  this.events.subscribe(
1689
491
  "components:set-indent",
1690
- (r, o) => {
1691
- i(o.node, { layout: !0 });
492
+ (r, c) => {
493
+ i(c.node, { layout: !0 });
1692
494
  }
1693
495
  )
1694
496
  ), this.subscriptions.push(
1695
497
  this.events.subscribe(
1696
498
  "components:set-layout",
1697
- (r, o) => {
1698
- i(o.node, { layout: !0 });
499
+ (r, c) => {
500
+ i(c.node, { layout: !0 });
1699
501
  }
1700
502
  )
1701
503
  ), this.subscriptions.push(
1702
- this.events.subscribe("components:node-switched", (r, { node: o, branch: c }) => {
1703
- i(o, {
504
+ this.events.subscribe("components:node-switched", (r, { node: c, branch: a }) => {
505
+ i(c, {
1704
506
  layout: !0,
1705
507
  recursive: !0,
1706
508
  properties: !0,
@@ -1708,8 +510,8 @@ ${o.map(
1708
510
  });
1709
511
  })
1710
512
  ), this.subscriptions.push(
1711
- this.events.subscribe("components:node-removed", (r, { parentNode: o }) => {
1712
- i(o, { properties: !0 });
513
+ this.events.subscribe("components:node-removed", (r, { parentNode: c }) => {
514
+ i(c, { properties: !0 });
1713
515
  })
1714
516
  ), this.events.parent && this.events.parent.dispatch("components:platform-created", { platform: this });
1715
517
  }
@@ -1744,34 +546,34 @@ ${o.map(
1744
546
  * @param type Type of node.
1745
547
  */
1746
548
  createNode(t, e = {}) {
1747
- const s = new vt(this.events, t);
549
+ const s = new I(this.events, t);
1748
550
  return e.detached && this.nodes.detached.push(s), s;
1749
551
  }
1750
552
  components() {
1751
- return new Z(this);
553
+ return new N(this);
1752
554
  }
1753
555
  actions(t, e) {
1754
- return new tt(this, t, e);
556
+ return new P(this, t, e);
1755
557
  }
1756
558
  write(t) {
1757
- const { provider: e, target: s, attributes: i, options: r = {}, removable: o } = t, c = t.key || et(), h = { changeset: [i, r], target: s, removes: [] };
559
+ const { provider: e, target: s, attributes: i, options: r = {}, removable: c } = t, a = t.key || E(), h = { changeset: [i, r], target: s, removes: [] };
1758
560
  if (e) {
1759
- const a = this.providers[e];
1760
- a.write(c, s, i, r), h.removes.push(() => {
1761
- a.remove(c);
561
+ const o = this.providers[e];
562
+ o.write(a, s, i, r), h.removes.push(() => {
563
+ o.remove(a);
1762
564
  });
1763
565
  }
1764
- return this.changesets.push(h), this.nodes.all.forEach((a) => {
1765
- if (s.match(a)) {
1766
- let u = () => {
566
+ return this.changesets.push(h), this.nodes.all.forEach((o) => {
567
+ if (s.match(o)) {
568
+ let p = () => {
1767
569
  };
1768
- i.properties && (u = a.writeProperties(i.properties, r, o)), i.context && (u = a.writeContext(i.context, r, o)), i.layout && (u = a.writeContext(i.layout, r, o)), h.removes.push(u);
570
+ i.properties && (p = o.writeProperties(i.properties, r, c)), i.context && (p = o.writeContext(i.context, r, c)), i.layout && (p = o.writeContext(i.layout, r, c)), h.removes.push(p);
1769
571
  }
1770
572
  }), () => {
1771
- if (o) {
1772
- h.removes.forEach((u) => u());
1773
- const a = this.changesets.indexOf(h);
1774
- a > -1 && this.changesets.splice(a, 1);
573
+ if (c) {
574
+ h.removes.forEach((p) => p());
575
+ const o = this.changesets.indexOf(h);
576
+ o > -1 && this.changesets.splice(o, 1);
1775
577
  }
1776
578
  };
1777
579
  }
@@ -1785,7 +587,7 @@ ${o.map(
1785
587
  this.subscriptions.forEach((t) => t());
1786
588
  }
1787
589
  }
1788
- const Ae = (n) => {
590
+ const st = (n) => {
1789
591
  if (Array.isArray(n)) {
1790
592
  const [t, ...e] = n;
1791
593
  return {
@@ -1797,22 +599,22 @@ const Ae = (n) => {
1797
599
  definitionId: n,
1798
600
  overrides: []
1799
601
  };
1800
- }, Y = (n, t, e, s, i, r) => {
1801
- e.forEach((o) => {
1802
- const c = Ae(o), l = s[c.definitionId];
1803
- if (c.definitionId === "view") {
602
+ }, C = (n, t, e, s, i, r) => {
603
+ e.forEach((c) => {
604
+ const a = st(c), u = s[a.definitionId];
605
+ if (a.definitionId === "view") {
1804
606
  const h = n.createNode("view");
1805
- h.name = "view", Object.keys(i).forEach((a) => {
1806
- const u = i[a];
1807
- Y(n, h, [u.entry], s, i, a);
1808
- }), t.appendChild(h), c.overrides.forEach((a) => {
1809
- a.properties && h.writeProperties(a.properties, {
1810
- breakpoints: a.breakpoints
1811
- }), a.context && h.writeContext(a.context, { breakpoints: a.breakpoints }), a.layout && h.writeLayout(a.layout, { breakpoints: a.breakpoints });
607
+ h.name = "view", Object.keys(i).forEach((o) => {
608
+ const p = i[o];
609
+ C(n, h, [p.entry], s, i, o);
610
+ }), t.appendChild(h), a.overrides.forEach((o) => {
611
+ o.properties && h.writeProperties(o.properties, {
612
+ breakpoints: o.breakpoints
613
+ }), o.context && h.writeContext(o.context, { breakpoints: o.breakpoints }), o.layout && h.writeLayout(o.layout, { breakpoints: o.breakpoints });
1812
614
  });
1813
- } else if (n.getComponentHandler(l.type)) {
1814
- const h = n.getComponentHandler(l.type);
1815
- h && h(c, {
615
+ } else if (n.getComponentHandler(u.type)) {
616
+ const h = n.getComponentHandler(u.type);
617
+ h && h(a, {
1816
618
  platform: n,
1817
619
  node: t,
1818
620
  references: e,
@@ -1821,71 +623,71 @@ const Ae = (n) => {
1821
623
  branch: r
1822
624
  });
1823
625
  } else {
1824
- const h = s[c.definitionId];
626
+ const h = s[a.definitionId];
1825
627
  if (process.env.NODE_ENV !== "production" && !h) {
1826
- P.error(
1827
- `No definition found for component type '${c.definitionId}'.`
628
+ O.error(
629
+ `No definition found for component type '${a.definitionId}'.`
1828
630
  );
1829
631
  return;
1830
632
  }
1831
- const a = n.createNode(h.type);
1832
- a.name = c.definitionId, a.tags = h.tags || [], h.properties && a.writeProperties(h.properties), h.context && a.writeContext(h.context), h.layout && a.writeLayout(h.layout), t.appendChild(a, r), c.overrides.forEach((u) => {
1833
- const p = { breakpoints: u.breakpoints };
1834
- u.properties && a.writeProperties(u.properties, p), u.context && a.writeContext(u.context, p), u.layout && a.writeLayout(u.layout, p);
1835
- }), h.children && Y(n, a, h.children, s, i);
633
+ const o = n.createNode(h.type);
634
+ o.name = a.definitionId, o.tags = h.tags || [], h.properties && o.writeProperties(h.properties), h.context && o.writeContext(h.context), h.layout && o.writeLayout(h.layout), t.appendChild(o, r), a.overrides.forEach((p) => {
635
+ const l = { breakpoints: p.breakpoints };
636
+ p.properties && o.writeProperties(p.properties, l), p.context && o.writeContext(p.context, l), p.layout && o.writeLayout(p.layout, l);
637
+ }), h.children && C(n, o, h.children, s, i);
1836
638
  }
1837
639
  });
1838
- }, ze = (n, t) => {
1839
- const { entry: e, components: s, breakpoints: i, views: r } = t, o = [];
1840
- return Object.keys(i).forEach((c) => {
1841
- const l = i[c], h = window.matchMedia(l);
1842
- h.matches && n.breakpoints.push(c);
1843
- const a = (u) => {
1844
- u.matches ? n.addBreakpoint(c) : n.removeBreakpoint(c);
640
+ }, lt = (n, t) => {
641
+ const { entry: e, components: s, breakpoints: i, views: r } = t, c = [];
642
+ return Object.keys(i).forEach((a) => {
643
+ const u = i[a], h = window.matchMedia(u);
644
+ h.matches && n.breakpoints.push(a);
645
+ const o = (p) => {
646
+ p.matches ? n.addBreakpoint(a) : n.removeBreakpoint(a);
1845
647
  };
1846
- h.addListener(a), o.push(() => h.removeListener(a));
1847
- }), Y(n, n.nodes.root, [e], s, r), () => o.forEach((c) => {
1848
- c();
648
+ h.addListener(o), c.push(() => h.removeListener(o));
649
+ }), C(n, n.nodes.root, [e], s, r), () => c.forEach((a) => {
650
+ a();
1849
651
  });
1850
- }, Te = (n, t) => ({
652
+ }, dt = (n, t) => ({
1851
653
  id: n.id,
1852
654
  type: n.type,
1853
655
  name: n.name,
1854
656
  branch: t || "default"
1855
- }), Ve = (n, t, e, s = et(), i = {}) => n.getAsync("components").then((r) => {
1856
- let o;
657
+ }), ft = (n, t, e, s = E(), i = {}) => n.getAsync("components").then((r) => {
658
+ let c;
1857
659
  if (typeof t == "string") {
1858
- const h = new Z(r);
1859
- h.ofType(t), o = h;
660
+ const h = new N(r);
661
+ h.ofType(t), c = h;
1860
662
  } else
1861
- o = t;
1862
- const c = {}, l = (h) => {
1863
- const a = c[h.id];
1864
- return a ? Promise.resolve(a.controller) : Oe.getInstance(n).then((u) => new _t(u, h, s));
663
+ c = t;
664
+ const a = {}, u = (h) => {
665
+ const o = a[h.id];
666
+ return o ? Promise.resolve(o.controller) : et.getInstance(n).then((p) => new S(p, h, s));
1865
667
  };
1866
668
  r.events.subscribe(
1867
669
  "components:node-enter",
1868
- (h, { node: a }) => {
1869
- o.match(a) && l(a).then((u) => {
1870
- Promise.resolve(e(u)).then((p) => {
1871
- c[a.id] = {
1872
- dispose: p,
1873
- controller: u
670
+ (h, { node: o }) => {
671
+ c.match(o) && u(o).then((p) => {
672
+ Promise.resolve(e(p)).then((l) => {
673
+ a[o.id] = {
674
+ dispose: l,
675
+ controller: p
1874
676
  };
1875
677
  });
1876
678
  });
1877
679
  }
1878
680
  ), r.events.subscribe(
1879
681
  "components:node-exit",
1880
- (h, { node: a }) => {
1881
- const u = c[a.id];
1882
- u && (u.dispose && u.dispose(), i.reuseController || (u.controller.dispose(), delete c[a.id]));
682
+ (h, { node: o }) => {
683
+ const p = a[o.id];
684
+ p && (p.dispose && p.dispose(), i.reuseController || (p.controller.dispose(), delete a[o.id]));
1883
685
  }
1884
686
  );
1885
687
  });
1886
- class je {
688
+ class mt {
1887
689
  constructor(t) {
1888
- this.aliases = /* @__PURE__ */ new Map(), this.components = /* @__PURE__ */ new Map(), this.logger = new P();
690
+ this.aliases = /* @__PURE__ */ new Map(), this.components = /* @__PURE__ */ new Map(), this.logger = new O();
1889
691
  const { events: e } = t.get("$widget");
1890
692
  this.events = e;
1891
693
  }
@@ -1915,7 +717,7 @@ class je {
1915
717
  };
1916
718
  }
1917
719
  }
1918
- const Ne = "#____version____#", Dt = class extends Nt {
720
+ const nt = "#____version____#", _ = class extends j {
1919
721
  constructor(n, t = []) {
1920
722
  super(n, t, {
1921
723
  transformPluginSettings: (e, s, i) => {
@@ -1946,10 +748,10 @@ const Ne = "#____version____#", Dt = class extends Nt {
1946
748
  * @param configuration Runtime configuration.
1947
749
  */
1948
750
  static create(n = {}) {
1949
- const t = [Qt].concat(
751
+ const t = [H].concat(
1950
752
  n.configurationApiExtensions || []
1951
753
  );
1952
- return new Dt("humany", t);
754
+ return new _("humany", t);
1953
755
  }
1954
756
  /**
1955
757
  * Creates a widget runtime based on provided configuration and retains configuration handlers
@@ -1976,46 +778,46 @@ const Ne = "#____version____#", Dt = class extends Nt {
1976
778
  return !!(n && typeof n == "object" && n.container && typeof n.container.get == "function" && n.container.get("$environment") === n && n.container.owner === n);
1977
779
  }
1978
780
  };
1979
- let _e = Dt;
1980
- _e.version = `${Ne} (${X})`;
1981
- class qe extends Ot {
781
+ let it = _;
782
+ it.version = `${nt} (${V})`;
783
+ class vt extends q {
1982
784
  constructor() {
1983
785
  super(...arguments), this.bindings = [];
1984
786
  }
1985
787
  }
1986
- class Fe extends ie {
788
+ class bt extends z {
1987
789
  constructor(t, e) {
1988
790
  super(t, e);
1989
791
  }
1990
792
  }
1991
- var Re = /* @__PURE__ */ ((n) => (n.open = "open", n.closed = "closed", n.hidden = "hidden", n))(Re || {});
1992
- class He extends me {
793
+ var ot = /* @__PURE__ */ ((n) => (n.open = "open", n.closed = "closed", n.hidden = "hidden", n))(ot || {});
794
+ class gt extends Q {
1993
795
  constructor(t) {
1994
796
  super(t);
1995
797
  }
1996
798
  }
1997
799
  export {
1998
- De as ActionResolver,
1999
- tt as ActionsController,
2000
- vt as ComponentNode,
2001
- _t as ComponentNodeController,
2002
- Oe as ComponentPlatform,
2003
- Z as ComponentQuery,
2004
- je as ComponentResolver,
2005
- _e as Environment,
2006
- qe as Implementation,
2007
- Fe as Plugin,
2008
- Re as WidgetRenderState,
2009
- He as WidgetType,
2010
- Te as asDescriptor,
2011
- Me as bootstrap,
2012
- Se as componentConfigurationApi,
2013
- Y as createChildren,
2014
- ze as createComponentModel,
2015
- ve as createEventSubscriber,
2016
- Ve as extendComponent,
2017
- we as findComponent,
2018
- B as findVisibleComponents,
2019
- st as traverseComponents,
2020
- Ne as version
800
+ at as ActionResolver,
801
+ P as ActionsController,
802
+ I as ComponentNode,
803
+ S as ComponentNodeController,
804
+ et as ComponentPlatform,
805
+ N as ComponentQuery,
806
+ mt as ComponentResolver,
807
+ it as Environment,
808
+ vt as Implementation,
809
+ bt as Plugin,
810
+ ot as WidgetRenderState,
811
+ gt as WidgetType,
812
+ dt as asDescriptor,
813
+ pt as bootstrap,
814
+ ut as componentConfigurationApi,
815
+ C as createChildren,
816
+ lt as createComponentModel,
817
+ F as createEventSubscriber,
818
+ ft as extendComponent,
819
+ U as findComponent,
820
+ x as findVisibleComponents,
821
+ k as traverseComponents,
822
+ nt as version
2021
823
  };