eligius 2.3.2 → 3.0.0

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 (92) hide show
  1. package/README.md +158 -33
  2. package/dist/configuration-api.d.mts +6095 -0
  3. package/dist/configuration-api.mjs +3876 -0
  4. package/dist/configuration-api.mjs.map +1 -0
  5. package/dist/index.d.mts +4075 -1392
  6. package/dist/index.mjs +10421 -4820
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/metadata.d.mts +1040 -281
  9. package/dist/metadata.mjs +541 -277
  10. package/dist/metadata.mjs.map +1 -1
  11. package/dist/{chunk-w6R9maHv.mjs → rolldown-runtime-BOlb2svz.mjs} +1 -0
  12. package/jsonschema/eligius-configuration.json +120 -9
  13. package/jsonschema/operations/add-class.json +2 -7
  14. package/jsonschema/operations/add-controller-to-element.json +4 -3
  15. package/jsonschema/operations/add-globals-to-operation.json +40 -0
  16. package/jsonschema/operations/animate-with-class.json +8 -8
  17. package/jsonschema/operations/animate.json +10 -9
  18. package/jsonschema/operations/announce-to-screen-reader.json +2 -2
  19. package/jsonschema/operations/break-for-each.json +27 -0
  20. package/jsonschema/operations/broadcast-event.json +2 -2
  21. package/jsonschema/operations/calc.json +16 -3
  22. package/jsonschema/operations/clear-element.json +5 -14
  23. package/jsonschema/operations/clear-operation-data.json +3 -4
  24. package/jsonschema/operations/clear-storage.json +48 -0
  25. package/jsonschema/operations/compare-date.json +2 -2
  26. package/jsonschema/operations/concatenate-strings.json +2 -2
  27. package/jsonschema/operations/continue-for-each.json +27 -0
  28. package/jsonschema/operations/create-element.json +21 -5
  29. package/jsonschema/operations/custom-function.json +2 -2
  30. package/jsonschema/operations/end-action.json +5 -13
  31. package/jsonschema/operations/end-for-each.json +27 -0
  32. package/jsonschema/operations/end-when.json +27 -0
  33. package/jsonschema/operations/extend-controller.json +9 -7
  34. package/jsonschema/operations/filter-array.json +4 -12
  35. package/jsonschema/operations/find-in-array.json +4 -12
  36. package/jsonschema/operations/for-each.json +2 -3
  37. package/jsonschema/operations/format-date.json +2 -17
  38. package/jsonschema/operations/format-text.json +15 -7
  39. package/jsonschema/operations/get-attributes-from-element.json +9 -8
  40. package/jsonschema/operations/get-controller-from-element.json +2 -7
  41. package/jsonschema/operations/get-controller-instance.json +18 -5
  42. package/jsonschema/operations/get-current-time.json +3 -4
  43. package/jsonschema/operations/get-element-dimensions.json +4 -12
  44. package/jsonschema/operations/get-focused-element.json +3 -4
  45. package/jsonschema/operations/get-form-data.json +4 -12
  46. package/jsonschema/operations/get-import.json +2 -2
  47. package/jsonschema/operations/get-query-params.json +12 -5
  48. package/jsonschema/operations/get-scroll-position.json +3 -4
  49. package/jsonschema/operations/get-text-content.json +4 -12
  50. package/jsonschema/operations/http-delete.json +11 -3
  51. package/jsonschema/operations/http-post.json +11 -3
  52. package/jsonschema/operations/http-put.json +11 -3
  53. package/jsonschema/operations/invoke-object-method.json +2 -6
  54. package/jsonschema/operations/is-element-in-viewport.json +4 -12
  55. package/jsonschema/operations/load-from-storage.json +12 -3
  56. package/jsonschema/operations/load-json.json +5 -5
  57. package/jsonschema/operations/log.json +4 -7
  58. package/jsonschema/operations/map-array.json +2 -7
  59. package/jsonschema/operations/math.json +18 -3
  60. package/jsonschema/operations/otherwise.json +27 -0
  61. package/jsonschema/operations/remove-class.json +2 -7
  62. package/jsonschema/operations/remove-controller-from-element.json +2 -7
  63. package/jsonschema/operations/remove-element.json +5 -14
  64. package/jsonschema/operations/remove-properties-from-operation-data.json +2 -2
  65. package/jsonschema/operations/reparent-element.json +2 -7
  66. package/jsonschema/operations/replace-string.json +2 -6
  67. package/jsonschema/operations/replace-text.json +2 -6
  68. package/jsonschema/operations/request-action.json +2 -2
  69. package/jsonschema/operations/save-to-storage.json +12 -3
  70. package/jsonschema/operations/scroll-to-element.json +23 -13
  71. package/jsonschema/operations/scroll-to-position.json +12 -3
  72. package/jsonschema/operations/select-element.json +2 -2
  73. package/jsonschema/operations/set-data.json +8 -3
  74. package/jsonschema/operations/set-element-attributes.json +10 -9
  75. package/jsonschema/operations/set-element-content.json +5 -15
  76. package/jsonschema/operations/set-focus.json +5 -14
  77. package/jsonschema/operations/set-form-value.json +2 -7
  78. package/jsonschema/operations/set-global-data.json +2 -2
  79. package/jsonschema/operations/{set.json → set-operation-data.json} +12 -7
  80. package/jsonschema/operations/set-style.json +3 -8
  81. package/jsonschema/operations/set-variable.json +3 -5
  82. package/jsonschema/operations/sort-array.json +14 -13
  83. package/jsonschema/operations/split-string.json +2 -6
  84. package/jsonschema/operations/start-action.json +4 -12
  85. package/jsonschema/operations/substring-text.json +2 -6
  86. package/jsonschema/operations/toggle-class.json +2 -7
  87. package/jsonschema/operations/toggle-element.json +5 -14
  88. package/jsonschema/operations/toggle-form-element.json +2 -7
  89. package/jsonschema/operations/validate-form.json +41 -13
  90. package/jsonschema/operations/wait.json +2 -2
  91. package/jsonschema/operations/when.json +2 -2
  92. package/package.json +49 -24
@@ -0,0 +1,3876 @@
1
+
2
+ import { t as __exportAll } from "./rolldown-runtime-BOlb2svz.mjs";
3
+ import { isDefined } from "ts-is-present";
4
+ import { v4 } from "uuid";
5
+
6
+ //#region src/util/guards/is-plain-object.ts
7
+ const functionToString = Function.prototype.toString;
8
+ /** Source text of `Object`, the same in every realm */
9
+ const objectConstructorSource = functionToString.call(Object);
10
+ /**
11
+ * Returns true for plain data objects: object literals, parsed JSON objects
12
+ * and `Object.create(null)` objects, also when they were created in another
13
+ * realm (an iframe, a worker, the realm `fetch` parses JSON in). Returns false
14
+ * for arrays, class instances, `Date`, `Map`, DOM nodes, jQuery objects and
15
+ * objects that inherit from another object.
16
+ *
17
+ * @param value - Any value
18
+ * @returns Whether `value` is a plain data object
19
+ */
20
+ function isPlainObject$1(value) {
21
+ if (value === null || typeof value !== "object") return false;
22
+ const prototype = Object.getPrototypeOf(value);
23
+ if (prototype === null || prototype === Object.prototype) return true;
24
+ if (Object.getPrototypeOf(prototype) !== null) return false;
25
+ const objectConstructor = Object.hasOwn(prototype, "constructor") ? prototype.constructor : void 0;
26
+ return typeof objectConstructor === "function" && functionToString.call(objectConstructor) === objectConstructorSource;
27
+ }
28
+
29
+ //#endregion
30
+ //#region src/operation/helper/deep-copy.ts
31
+ const copyFunction = typeof structuredClone !== "undefined" ? structuredClone : (original) => JSON.parse(JSON.stringify(original));
32
+ /**
33
+ * Deep copies the given value.
34
+ *
35
+ * Arrays and plain objects are copied recursively (cycles are preserved). Date, RegExp,
36
+ * Map, Set, Error, ArrayBuffer and typed array values are copied with `structuredClone`.
37
+ *
38
+ * Everything else is kept by reference:
39
+ * - functions, so function-valued operation data (such as `mapArray`'s `mapFunction` or
40
+ * `sortArray`'s `sortComparator`, supplied through the TypeScript fluent API) survives
41
+ * the copy;
42
+ * - jQuery instances and DOM nodes;
43
+ * - class instances (controllers, actions, the eventbus and other objects whose prototype
44
+ * is not `Object.prototype` or `null`). `structuredClone` would either throw on them or
45
+ * return a plain object without their methods.
46
+ *
47
+ * @param original The value to copy.
48
+ * @returns The copy.
49
+ */
50
+ function deepCopy(original) {
51
+ if (isDefined(original)) return copyValue(original, /* @__PURE__ */ new WeakMap());
52
+ return original;
53
+ }
54
+ function copyValue(value, seen) {
55
+ if (value === null || typeof value !== "object") return value;
56
+ if (isReferenceOnly(value)) return value;
57
+ if (seen.has(value)) return seen.get(value);
58
+ if (Array.isArray(value)) {
59
+ const copy = new Array(value.length);
60
+ seen.set(value, copy);
61
+ value.forEach((item, index) => {
62
+ copy[index] = copyValue(item, seen);
63
+ });
64
+ return copy;
65
+ }
66
+ if (isPlainObject$1(value)) {
67
+ const copy = {};
68
+ seen.set(value, copy);
69
+ for (const key of Object.keys(value)) Object.defineProperty(copy, key, {
70
+ value: copyValue(value[key], seen),
71
+ writable: true,
72
+ enumerable: true,
73
+ configurable: true
74
+ });
75
+ return copy;
76
+ }
77
+ if (!isStructuredCloneable(value)) return value;
78
+ const copy = copyFunction(value);
79
+ seen.set(value, copy);
80
+ return copy;
81
+ }
82
+ function isReferenceOnly(value) {
83
+ return typeof value.jquery === "string" || typeof Node !== "undefined" && value instanceof Node;
84
+ }
85
+ /**
86
+ * Built-in value types that `structuredClone` copies faithfully.
87
+ */
88
+ function isStructuredCloneable(value) {
89
+ return cloneableTags.has(Object.prototype.toString.call(value)) || ArrayBuffer.isView(value);
90
+ }
91
+ const cloneableTags = /* @__PURE__ */ new Set([
92
+ "[object Date]",
93
+ "[object RegExp]",
94
+ "[object Map]",
95
+ "[object Set]",
96
+ "[object Error]",
97
+ "[object ArrayBuffer]"
98
+ ]);
99
+
100
+ //#endregion
101
+ //#region src/operation/metadata/add-class.ts
102
+ function addClass() {
103
+ return {
104
+ description: `This operation adds the specified class name to the specified selected element.`,
105
+ category: `DOM`,
106
+ dependentProperties: ["selectedElement"],
107
+ properties: { className: {
108
+ type: "ParameterType:className",
109
+ required: true,
110
+ erased: true
111
+ } }
112
+ };
113
+ }
114
+
115
+ //#endregion
116
+ //#region src/operation/metadata/add-controller-to-element.ts
117
+ function addControllerToElement() {
118
+ return {
119
+ description: `This operation adds the specified controller instance to the given selected element.
120
+
121
+ The controller is registered on the element only once \`init\` and a synchronous \`attach\`
122
+ have succeeded. When \`attach\` returns a promise, the controller is registered before
123
+ that promise settles (so detaching the element can still reach it) and is removed from
124
+ the element again when the promise rejects.`,
125
+ category: `Controller`,
126
+ dependentProperties: ["selectedElement", "controllerInstance"]
127
+ };
128
+ }
129
+
130
+ //#endregion
131
+ //#region src/operation/metadata/add-globals-to-operation.ts
132
+ function addGlobalsToOperation() {
133
+ return {
134
+ description: `This operation adds the specified global property names to the current operation data.
135
+ It finally removes the \`globalProperties\` property from the current operation data.
136
+
137
+ Plain data is copied, so changing it does not change the global store. jQuery objects, DOM
138
+ nodes, functions and class instances (such as controllers) are added by reference.`,
139
+ category: `Data`,
140
+ properties: { globalProperties: {
141
+ type: "ParameterType:array",
142
+ itemType: "ParameterType:string",
143
+ required: true,
144
+ erased: true
145
+ } }
146
+ };
147
+ }
148
+
149
+ //#endregion
150
+ //#region src/operation/metadata/animate-with-class.ts
151
+ function animateWithClass() {
152
+ return {
153
+ description: `This operation adds the specified class name to the specified selected element and assumes that this
154
+ class triggers an animation on the selected element. It then waits for this animation to complete
155
+ before it resolves.
156
+
157
+ The class must put the animation on the selected element itself: \`animationend\` events that bubble up
158
+ from descendants are ignored, and with several selected elements the operation waits for all of them.
159
+ Set \`includeDescendants\` to true for a class that only animates descendants; the operation then resolves
160
+ on the first \`animationend\` from the element or its subtree.
161
+
162
+ The operation resolves immediately when the selection is empty, or when the class gives none of the
163
+ selected elements a CSS animation (for example under \`prefers-reduced-motion: reduce\`). When an
164
+ \`animationend\` event never arrives, for example because the element was hidden or removed while
165
+ animating, it resolves shortly after the longest computed animation should have ended. An infinite
166
+ animation is waited for until it is ended by an \`animationend\` event.`,
167
+ category: `Animation`,
168
+ dependentProperties: ["selectedElement"],
169
+ properties: {
170
+ className: {
171
+ type: "ParameterType:className",
172
+ required: true,
173
+ erased: true
174
+ },
175
+ removeClass: {
176
+ type: "ParameterType:boolean",
177
+ erased: true
178
+ },
179
+ includeDescendants: {
180
+ type: "ParameterType:boolean",
181
+ erased: true
182
+ }
183
+ }
184
+ };
185
+ }
186
+
187
+ //#endregion
188
+ //#region src/operation/metadata/animate.ts
189
+ function animate() {
190
+ return {
191
+ description: `This operation animates the specified selected element with the given [jQuery animation](https://api.jquery.com/animate/) properties, duration and easing.
192
+ It resolves after the animation completes, or immediately when the selected element set is empty.`,
193
+ category: `Animation`,
194
+ dependentProperties: ["selectedElement"],
195
+ properties: {
196
+ animationEasing: {
197
+ type: "ParameterType:string",
198
+ erased: true
199
+ },
200
+ animationProperties: {
201
+ type: "ParameterType:object",
202
+ required: true,
203
+ erased: true
204
+ },
205
+ animationDuration: {
206
+ type: "ParameterType:number",
207
+ required: true,
208
+ erased: true
209
+ }
210
+ }
211
+ };
212
+ }
213
+
214
+ //#endregion
215
+ //#region src/operation/metadata/announce-to-screen-reader.ts
216
+ function announceToScreenReader() {
217
+ return {
218
+ description: `Announces a message to screen readers using an ARIA live region.
219
+
220
+ The live region (\`#aria-live-region\`) is created empty on first use. The region is emptied
221
+ and the message is written 100 milliseconds later, so that a new region
222
+ and a message repeated verbatim are both announced. The message is removed again after 5 seconds.
223
+ A newer announcement replaces a pending one.
224
+
225
+ The operation returns at once and does not wait for the message to be written.`,
226
+ category: `Accessibility`,
227
+ properties: {
228
+ message: {
229
+ type: "ParameterType:string",
230
+ required: true,
231
+ erased: true
232
+ },
233
+ priority: {
234
+ type: [{ value: "polite" }, { value: "assertive" }],
235
+ erased: true
236
+ }
237
+ }
238
+ };
239
+ }
240
+
241
+ //#endregion
242
+ //#region src/operation/metadata/break-for-each.ts
243
+ function breakForEach() {
244
+ return {
245
+ description: `This operation should only be used within a loop, so between a {@link forEach} and {@link endForEach}
246
+ operation. This operation immediately moves to the loop end index, effectively stopping the loop.
247
+
248
+ It can be placed inside a \`when\`/\`otherwise\`/\`endWhen\` block within the loop, to break conditionally.`,
249
+ category: `Control Flow`
250
+ };
251
+ }
252
+
253
+ //#endregion
254
+ //#region src/operation/metadata/broadcast-event.ts
255
+ function broadcastEvent() {
256
+ return {
257
+ description: `This operation broadcasts the given event through the eventbus, along with the
258
+ event arguments and optional event topic.`,
259
+ category: `Utility`,
260
+ properties: {
261
+ eventArgs: {
262
+ type: "ParameterType:array",
263
+ required: true,
264
+ erased: true
265
+ },
266
+ eventTopic: {
267
+ type: "ParameterType:eventTopic",
268
+ erased: true
269
+ },
270
+ eventName: {
271
+ type: "ParameterType:eventName",
272
+ required: true,
273
+ erased: true
274
+ }
275
+ }
276
+ };
277
+ }
278
+
279
+ //#endregion
280
+ //#region src/operation/metadata/calc.ts
281
+ function calc() {
282
+ return {
283
+ description: `This operation calculates the given left and right hand operands using the specified operator.
284
+
285
+ \`left\`, \`right\` and \`operator\` may be property chains (\`$operationdata.\`, \`$globaldata.\`,
286
+ \`$scope.\`). Only these three inputs are resolved; the rest of the operation data is left as
287
+ it is.`,
288
+ category: `Utility`,
289
+ properties: {
290
+ left: {
291
+ type: "ParameterType:number",
292
+ required: true,
293
+ erased: true
294
+ },
295
+ right: {
296
+ type: "ParameterType:number",
297
+ required: true,
298
+ erased: true
299
+ },
300
+ operator: {
301
+ type: [
302
+ { value: "+" },
303
+ { value: "-" },
304
+ { value: "*" },
305
+ { value: "/" },
306
+ { value: "%" },
307
+ { value: "**" }
308
+ ],
309
+ required: true,
310
+ erased: true
311
+ }
312
+ },
313
+ outputProperties: { calculationResult: { type: "ParameterType:number" } }
314
+ };
315
+ }
316
+
317
+ //#endregion
318
+ //#region src/operation/metadata/clear-element.ts
319
+ function clearElement() {
320
+ return {
321
+ description: `This operation removes all of the children from the given selected element.
322
+
323
+ Controllers attached to the removed children or their descendants (by \`addControllerToElement\`)
324
+ are detached first. Controllers on the selected element itself stay attached.`,
325
+ category: `DOM`,
326
+ dependentProperties: ["selectedElement"]
327
+ };
328
+ }
329
+
330
+ //#endregion
331
+ //#region src/operation/metadata/clear-operation-data.ts
332
+ function clearOperationData() {
333
+ return {
334
+ description: `This operation removes all of the properties on the current operation date.
335
+ Or, if the \`properties\` property is set only removes the properties defined by that list.`,
336
+ category: `Data`,
337
+ properties: { properties: {
338
+ type: "ParameterType:array",
339
+ itemType: "ParameterType:string",
340
+ erased: true
341
+ } }
342
+ };
343
+ }
344
+
345
+ //#endregion
346
+ //#region src/operation/metadata/clear-storage.ts
347
+ function clearStorage() {
348
+ return {
349
+ description: `Clears data from browser storage (localStorage or sessionStorage).
350
+
351
+ If \`key\` is provided, removes only that key. If \`key\` is omitted, clears all storage.
352
+ A \`key\` that is present but empty, blank or not a string is rejected, so a value resolved
353
+ from missing data never wipes the whole storage.`,
354
+ category: `Data`,
355
+ properties: {
356
+ key: {
357
+ type: "ParameterType:string",
358
+ erased: true
359
+ },
360
+ storageType: {
361
+ type: [{ value: "local" }, { value: "session" }],
362
+ required: true,
363
+ erased: true
364
+ }
365
+ }
366
+ };
367
+ }
368
+
369
+ //#endregion
370
+ //#region src/operation/metadata/compare-date.ts
371
+ function compareDate() {
372
+ return {
373
+ description: `Compares two dates.
374
+ comparison: -1 (before), 0 (equal), 1 (after)`,
375
+ category: `Date`,
376
+ properties: {
377
+ date1: {
378
+ type: "ParameterType:string|ParameterType:number|ParameterType:Date",
379
+ required: true,
380
+ erased: true
381
+ },
382
+ date2: {
383
+ type: "ParameterType:string|ParameterType:number|ParameterType:Date",
384
+ required: true,
385
+ erased: true
386
+ }
387
+ },
388
+ outputProperties: {
389
+ comparison: { type: "ParameterType:number" },
390
+ isEqual: { type: "ParameterType:boolean" },
391
+ isBefore: { type: "ParameterType:boolean" },
392
+ isAfter: { type: "ParameterType:boolean" }
393
+ }
394
+ };
395
+ }
396
+
397
+ //#endregion
398
+ //#region src/operation/metadata/concatenate-strings.ts
399
+ function concatenateStrings() {
400
+ return {
401
+ description: `Concatenates multiple strings with an optional separator.`,
402
+ category: `String`,
403
+ properties: {
404
+ strings: {
405
+ type: "ParameterType:array",
406
+ itemType: "ParameterType:string",
407
+ required: true,
408
+ erased: true
409
+ },
410
+ separator: {
411
+ type: "ParameterType:string",
412
+ erased: true
413
+ }
414
+ },
415
+ outputProperties: { result: { type: "ParameterType:string" } }
416
+ };
417
+ }
418
+
419
+ //#endregion
420
+ //#region src/operation/metadata/continue-for-each.ts
421
+ function continueForEach() {
422
+ return {
423
+ description: `This operation should only be used within a loop, so between a {@link forEach} and {@link endForEach}
424
+ operation. This operation immediately moves to the next loop index, effectively canceling the rest
425
+ of the operations in the current iteration.
426
+
427
+ It can be placed inside a \`when\`/\`otherwise\`/\`endWhen\` block within the loop, to continue conditionally.`,
428
+ category: `Control Flow`
429
+ };
430
+ }
431
+
432
+ //#endregion
433
+ //#region src/operation/metadata/create-element.ts
434
+ function createElement() {
435
+ return {
436
+ description: `This operation creates the DOM element described by the given elementName and attributes and assigns
437
+ the instance to the \`template\` property on the current operation data.
438
+
439
+ The element is built with DOM APIs: attribute values are set with \`.attr()\` and \`text\` is set as
440
+ text content, so neither is parsed as HTML.
441
+
442
+ Values may be resolved from user data, so nothing that runs script is created: \`script\`
443
+ elements, event handler (\`on*\`) and \`srcdoc\` attributes, and \`javascript:\` or \`vbscript:\`
444
+ URLs in URL attributes such as \`href\`, \`src\` and \`formaction\` are refused.`,
445
+ category: `DOM`,
446
+ properties: {
447
+ elementName: {
448
+ type: "ParameterType:htmlElementName",
449
+ required: true,
450
+ erased: true
451
+ },
452
+ text: {
453
+ type: "ParameterType:string",
454
+ erased: true
455
+ },
456
+ attributes: {
457
+ type: "ParameterType:object",
458
+ erased: true
459
+ }
460
+ },
461
+ outputProperties: { template: { type: "ParameterType:object" } }
462
+ };
463
+ }
464
+
465
+ //#endregion
466
+ //#region src/operation/metadata/custom-function.ts
467
+ function customFunction() {
468
+ return {
469
+ description: `This operation retrieves a custom function defined by the given system name
470
+ and invokes it with the current operation data and eventbus.
471
+
472
+ The function is looked up with the \`request-function\` event, which the
473
+ \`EngineFactory\` answers from its resource importer. Register the function
474
+ with the \`EligiusResourceImporter\` constructor:
475
+ \`new EligiusResourceImporter({functions: {myFunction}})\`.
476
+
477
+ The function is called with the current operation data as its argument, and with \`this\`
478
+ set to a view of the operation scope. Reading a property from \`this\` returns it from the
479
+ innermost scope that has it, so inside a \`when\` block in a loop \`this.currentItem\`,
480
+ \`this.loopIndex\` and \`this.variables\` return the loop's and the action's values, the same
481
+ as \`$scope.\` chains. Assigning to \`this\` (for example \`this.newIndex\`) writes to the scope the
482
+ operation runs in.`,
483
+ category: `Utility`,
484
+ properties: { systemName: {
485
+ type: "ParameterType:systemName",
486
+ required: true,
487
+ erased: true
488
+ } }
489
+ };
490
+ }
491
+
492
+ //#endregion
493
+ //#region src/operation/metadata/end-action.ts
494
+ function endAction() {
495
+ return {
496
+ description: `This operation invokes the {@link EndableAction}.end method on the specified action instance.
497
+
498
+ The action receives its own copy of the current operation data merged with the action
499
+ operation data. Whatever the action's end operations add, change or remove in that copy stays
500
+ with the action: once it has completed, this operation continues with the operation data it
501
+ had before, without the \`actionOperationData\` property.`,
502
+ category: `Action`,
503
+ dependentProperties: ["actionInstance"],
504
+ properties: { actionOperationData: {
505
+ type: "ParameterType:object",
506
+ erased: true
507
+ } }
508
+ };
509
+ }
510
+
511
+ //#endregion
512
+ //#region src/operation/metadata/end-for-each.ts
513
+ function endForEach() {
514
+ return {
515
+ description: `This operation checks if the current loop should end or start the next iteration.`,
516
+ category: `Control Flow`
517
+ };
518
+ }
519
+
520
+ //#endregion
521
+ //#region src/operation/metadata/end-when.ts
522
+ function endWhen() {
523
+ return {
524
+ description: `This operation cleans up after the {@link when}/{@link otherwise}/{@link endWhen} control flow ends.`,
525
+ category: `Control Flow`
526
+ };
527
+ }
528
+
529
+ //#endregion
530
+ //#region src/operation/metadata/extend-controller.ts
531
+ function extendController() {
532
+ return {
533
+ description: `Extends the current controller with given extension.
534
+
535
+ The extension's own properties are copied onto the controller instance.`,
536
+ category: `Controller`,
537
+ dependentProperties: ["controllerInstance"],
538
+ properties: { controllerExtension: {
539
+ type: "ParameterType:object",
540
+ required: true,
541
+ erased: true
542
+ } }
543
+ };
544
+ }
545
+
546
+ //#endregion
547
+ //#region src/operation/metadata/filter-array.ts
548
+ function filterArray() {
549
+ return {
550
+ description: `Filters an array based on property equality or custom predicate function.
551
+
552
+ Operates on arrayData passed from previous operations.
553
+ Supports two filtering modes:
554
+ 1. Property equality: \`filterProperty\` and \`filterValue\` to filter by property match
555
+ 2. Custom predicate: \`filterPredicate\` function for complex filtering logic`,
556
+ category: `Array`,
557
+ dependentProperties: ["arrayData"],
558
+ properties: {
559
+ filterProperty: {
560
+ type: "ParameterType:string",
561
+ erased: true
562
+ },
563
+ filterValue: {
564
+ type: "ParameterType:object",
565
+ erased: true
566
+ },
567
+ filterPredicate: {
568
+ type: "ParameterType:function",
569
+ erased: true
570
+ }
571
+ },
572
+ outputProperties: { filteredArray: { type: "ParameterType:array" } }
573
+ };
574
+ }
575
+
576
+ //#endregion
577
+ //#region src/operation/metadata/find-in-array.ts
578
+ function findInArray() {
579
+ return {
580
+ description: `Finds the first element in an array matching criteria.
581
+
582
+ Operates on arrayData passed from previous operations.
583
+ Supports two search modes:
584
+ 1. Property equality: \`findProperty\` and \`findValue\` to find by property match
585
+ 2. Custom predicate: \`findPredicate\` function for complex search logic
586
+
587
+ Returns \`undefined\` for \`foundItem\` and \`-1\` for \`foundIndex\` if no match found.`,
588
+ category: `Array`,
589
+ dependentProperties: ["arrayData"],
590
+ properties: {
591
+ findProperty: {
592
+ type: "ParameterType:string",
593
+ erased: true
594
+ },
595
+ findValue: {
596
+ type: "ParameterType:object",
597
+ erased: true
598
+ },
599
+ findPredicate: {
600
+ type: "ParameterType:function",
601
+ erased: true
602
+ }
603
+ },
604
+ outputProperties: {
605
+ foundItem: { type: "ParameterType:object" },
606
+ foundIndex: { type: "ParameterType:number" }
607
+ }
608
+ };
609
+ }
610
+
611
+ //#endregion
612
+ //#region src/operation/metadata/for-each.ts
613
+ function forEach() {
614
+ return {
615
+ description: `This operation iterates over the given collection.
616
+
617
+ Each iteration the current item from the specified collection is
618
+ assigned to the {@link IOperationScope.currentItem |currentItem} property on the {@link IOperationScope |operation scope}.
619
+
620
+ At the start of the loop, the associated {@link endForEach} operation is determined and when
621
+ the last iteration is completed the flow control is set to the index of that operation.
622
+
623
+ The {@link continueForEach |continue} and {@link breakForEach |break} operations can be used to control the
624
+ loop iterations.
625
+
626
+ The collection is resolved once, when the loop starts, and the loop iterates over a snapshot
627
+ of it. Changing, replacing or removing the source collection inside the loop body does not
628
+ change the items or the number of iterations of the running loop.`,
629
+ category: `Control Flow`,
630
+ properties: { collection: {
631
+ type: "ParameterType:array|ParameterType:string",
632
+ required: true
633
+ } }
634
+ };
635
+ }
636
+
637
+ //#endregion
638
+ //#region src/operation/metadata/format-date.ts
639
+ function formatDate() {
640
+ return {
641
+ description: `Formats a date with a simple token pattern, in the local time zone.
642
+
643
+ Supported tokens (every occurrence is replaced, other characters are kept as is):
644
+ - \`YYYY\`: four digit year
645
+ - \`MM\`: month, 01-12
646
+ - \`DD\`: day of the month, 01-31
647
+ - \`HH\`: hours, 00-23
648
+ - \`mm\`: minutes, 00-59
649
+ - \`ss\`: seconds, 00-59`,
650
+ category: `Date`,
651
+ dependentProperties: ["date"],
652
+ properties: { format: {
653
+ type: "ParameterType:string",
654
+ required: true,
655
+ erased: true
656
+ } },
657
+ outputProperties: { formattedDate: { type: "ParameterType:string" } }
658
+ };
659
+ }
660
+
661
+ //#endregion
662
+ //#region src/operation/metadata/format-text.ts
663
+ function formatText() {
664
+ return {
665
+ description: `Transforms text using format operations: uppercase, lowercase, capitalize, titlecase, or trim.
666
+
667
+ Operates on textContent passed from previous operations (e.g., getTextContent).
668
+
669
+ Transformations:
670
+ - \`uppercase\`: Convert all characters to uppercase
671
+ - \`lowercase\`: Convert all characters to lowercase
672
+ - \`capitalize\`: Capitalize only the first letter
673
+ - \`titlecase\`: Capitalize first letter of each word
674
+ - \`trim\`: Remove leading and trailing whitespace`,
675
+ category: `Text`,
676
+ dependentProperties: ["textContent"],
677
+ properties: { transformation: {
678
+ type: [
679
+ { value: "uppercase" },
680
+ { value: "lowercase" },
681
+ { value: "capitalize" },
682
+ { value: "titlecase" },
683
+ { value: "trim" }
684
+ ],
685
+ required: true,
686
+ erased: true
687
+ } },
688
+ outputProperties: { formattedText: { type: "ParameterType:string" } }
689
+ };
690
+ }
691
+
692
+ //#endregion
693
+ //#region src/operation/metadata/get-attributes-from-element.ts
694
+ function getAttributesFromElement() {
695
+ return {
696
+ description: `This operation retrieves the values for the specified attribute names from the given selected element.`,
697
+ category: `DOM`,
698
+ dependentProperties: ["selectedElement"],
699
+ properties: { attributeNames: {
700
+ type: "ParameterType:array",
701
+ itemType: "ParameterType:string",
702
+ required: true,
703
+ erased: true
704
+ } },
705
+ outputProperties: { attributeValues: { type: "ParameterType:object" } }
706
+ };
707
+ }
708
+
709
+ //#endregion
710
+ //#region src/operation/metadata/get-controller-from-element.ts
711
+ function getControllerFromElement() {
712
+ return {
713
+ description: `This operation retrieves the controller instance with the specified name that is assigned to the given selected element.`,
714
+ category: `Controller`,
715
+ dependentProperties: ["selectedElement"],
716
+ properties: { controllerName: {
717
+ type: "ParameterType:controllerName",
718
+ required: true,
719
+ erased: true
720
+ } },
721
+ outputProperties: { controllerInstance: { type: "ParameterType:object" } }
722
+ };
723
+ }
724
+
725
+ //#endregion
726
+ //#region src/operation/metadata/get-controller-instance.ts
727
+ function getControllerInstance() {
728
+ return {
729
+ description: `This operation retrieves an instance of the given controller name.
730
+ It assigns this instance to the \`controllerInstance\` property on the current operation data`,
731
+ category: `Controller`,
732
+ properties: { systemName: {
733
+ type: "ParameterType:controllerName",
734
+ required: true,
735
+ erased: true
736
+ } },
737
+ outputProperties: { controllerInstance: { type: "ParameterType:object" } }
738
+ };
739
+ }
740
+
741
+ //#endregion
742
+ //#region src/operation/metadata/get-current-time.ts
743
+ function getCurrentTime() {
744
+ return {
745
+ description: `Gets the current time as timestamp and Date object.`,
746
+ category: `Date`,
747
+ outputProperties: {
748
+ timestamp: { type: "ParameterType:number" },
749
+ date: { type: "ParameterType:Date" }
750
+ }
751
+ };
752
+ }
753
+
754
+ //#endregion
755
+ //#region src/operation/metadata/get-element-dimensions.ts
756
+ function getElementDimensions() {
757
+ return {
758
+ description: `This operation calculates the width and height of the given selected element.
759
+ It assigns this struct to the dimensions property on the current operation data.
760
+ Optionally the width and height can be modified using the given modifier string.
761
+
762
+ The modifier string is formatted in the following way:
763
+
764
+ <operator><amount><optional-side><optional-precentage>|<ratio-definition>
765
+
766
+ Where the ratio modifier is formatted in the following way:
767
+ <side>[ar=<ratio-left>-<ratio-right>]
768
+
769
+ For example, this modifier '+100h|w[ar=8-1]' will modifiy the dimensions like this:
770
+ it will add a value of 100 to the height and modify the width by a ratio of 8 to 1 relative to the height.`,
771
+ category: `DOM`,
772
+ dependentProperties: ["selectedElement"],
773
+ properties: { modifier: {
774
+ type: "ParameterType:dimensionsModifier",
775
+ erased: true
776
+ } },
777
+ outputProperties: { dimensions: { type: "ParameterType:object" } }
778
+ };
779
+ }
780
+
781
+ //#endregion
782
+ //#region src/operation/metadata/get-focused-element.ts
783
+ function getFocusedElement() {
784
+ return {
785
+ description: `Gets the currently focused element.`,
786
+ category: `Focus`,
787
+ outputProperties: { focusedElement: { type: "ParameterType:jQuery" } }
788
+ };
789
+ }
790
+
791
+ //#endregion
792
+ //#region src/operation/metadata/get-form-data.ts
793
+ function getFormData() {
794
+ return {
795
+ description: `Extracts all input, select, and textarea values from form element into operation data.
796
+
797
+ This operation reads form field values and returns them as an object with field names as keys.
798
+ Only processes form elements that are enabled and not hidden. Handles checkboxes, radio buttons,
799
+ select elements, textareas, and text inputs.`,
800
+ category: `Form`,
801
+ dependentProperties: ["selectedElement"],
802
+ outputProperties: { formData: { type: "ParameterType:object" } }
803
+ };
804
+ }
805
+
806
+ //#endregion
807
+ //#region src/operation/metadata/get-import.ts
808
+ function getImport() {
809
+ return {
810
+ description: `This operation retrieves the import specified by the given \`systemName\` and
811
+ assigns it to the \`importedInstance\` property on the current operaton date.
812
+
813
+ The import is looked up with the \`request-function\` event, which the
814
+ \`EngineFactory\` answers from its resource importer. Functions, templates
815
+ and JSON registered with the \`EligiusResourceImporter\` constructor
816
+ (\`new EligiusResourceImporter({json: {settings}})\`) can be imported this
817
+ way, as can every built-in operation, controller and provider export.`,
818
+ category: `Utility`,
819
+ properties: { systemName: {
820
+ type: "ParameterType:systemName",
821
+ required: true,
822
+ erased: true
823
+ } },
824
+ outputProperties: { importedInstance: { type: "ParameterType:object" } }
825
+ };
826
+ }
827
+
828
+ //#endregion
829
+ //#region src/operation/metadata/get-query-params.ts
830
+ function getQueryParams() {
831
+ return {
832
+ description: `This operation retrieves the current query parameters from the browser's address bar and places
833
+ them on the returned operation data.`,
834
+ category: `Utility`,
835
+ properties: { defaultValues: {
836
+ type: "ParameterType:object",
837
+ erased: true
838
+ } },
839
+ outputProperties: { queryParams: { type: "ParameterType:object" } }
840
+ };
841
+ }
842
+
843
+ //#endregion
844
+ //#region src/operation/metadata/get-scroll-position.ts
845
+ function getScrollPosition() {
846
+ return {
847
+ description: `Gets the current scroll position of the viewport.
848
+
849
+ Returns x (horizontal) and y (vertical) scroll positions in pixels.
850
+ Uses cross-browser compatible methods to retrieve scroll position.`,
851
+ category: `Scroll`,
852
+ outputProperties: {
853
+ scrollX: { type: "ParameterType:number" },
854
+ scrollY: { type: "ParameterType:number" }
855
+ }
856
+ };
857
+ }
858
+
859
+ //#endregion
860
+ //#region src/operation/metadata/get-text-content.ts
861
+ function getTextContent() {
862
+ return {
863
+ description: `Extracts text content from element, stripping all HTML markup.
864
+
865
+ Uses jQuery's \`.text()\` method which is XSS-safe and returns only the text content
866
+ without any HTML tags. Preserves whitespace and text from nested elements.`,
867
+ category: `Text`,
868
+ dependentProperties: ["selectedElement"],
869
+ outputProperties: { textContent: { type: "ParameterType:string" } }
870
+ };
871
+ }
872
+
873
+ //#endregion
874
+ //#region src/operation/metadata/http-delete.ts
875
+ function httpDelete() {
876
+ return {
877
+ description: `Performs an HTTP DELETE request to the specified URL.`,
878
+ category: `HTTP`,
879
+ properties: {
880
+ url: {
881
+ type: "ParameterType:string",
882
+ required: true,
883
+ erased: true
884
+ },
885
+ headers: {
886
+ type: "ParameterType:object",
887
+ erased: true
888
+ }
889
+ },
890
+ outputProperties: {
891
+ response: { type: "ParameterType:object" },
892
+ status: { type: "ParameterType:number" }
893
+ }
894
+ };
895
+ }
896
+
897
+ //#endregion
898
+ //#region src/operation/metadata/http-post.ts
899
+ function httpPost() {
900
+ return {
901
+ description: `Performs an HTTP POST request to the specified URL.
902
+
903
+ The body is sent as JSON with \`Content-Type: application/json\`, unless the caller's headers set
904
+ another content type (header names are case-insensitive). With a non-JSON content type, a string
905
+ body is sent as is; other bodies are still JSON encoded.`,
906
+ category: `HTTP`,
907
+ properties: {
908
+ url: {
909
+ type: "ParameterType:string",
910
+ required: true,
911
+ erased: true
912
+ },
913
+ body: {
914
+ type: "ParameterType:object",
915
+ erased: true
916
+ },
917
+ headers: {
918
+ type: "ParameterType:object",
919
+ erased: true
920
+ }
921
+ },
922
+ outputProperties: {
923
+ response: { type: "ParameterType:object" },
924
+ status: { type: "ParameterType:number" }
925
+ }
926
+ };
927
+ }
928
+
929
+ //#endregion
930
+ //#region src/operation/metadata/http-put.ts
931
+ function httpPut() {
932
+ return {
933
+ description: `Performs an HTTP PUT request to the specified URL.
934
+
935
+ The body is sent as JSON with \`Content-Type: application/json\`, unless the caller's headers set
936
+ another content type (header names are case-insensitive). With a non-JSON content type, a string
937
+ body is sent as is; other bodies are still JSON encoded.`,
938
+ category: `HTTP`,
939
+ properties: {
940
+ url: {
941
+ type: "ParameterType:string",
942
+ required: true,
943
+ erased: true
944
+ },
945
+ body: {
946
+ type: "ParameterType:object",
947
+ erased: true
948
+ },
949
+ headers: {
950
+ type: "ParameterType:object",
951
+ erased: true
952
+ }
953
+ },
954
+ outputProperties: {
955
+ response: { type: "ParameterType:object" },
956
+ status: { type: "ParameterType:number" }
957
+ }
958
+ };
959
+ }
960
+
961
+ //#endregion
962
+ //#region src/operation/metadata/invoke-object-method.ts
963
+ function invokeObjectMethod() {
964
+ return {
965
+ description: `This operation invokes the specified method on the given object with the given optional arguments
966
+ and assigns the result to the \`methodResult\` operationdata property. When the method returns a
967
+ promise, the operation waits for it and assigns the resolved value.
968
+
969
+ The operation only calls application code: methods of controllers, of other instances of
970
+ application classes, and of plain objects. It refuses, and throws for:
971
+ - an \`instance\` that is a function, the global object (\`window\`), a document, a DOM node,
972
+ a jQuery object, or any other built-in or host object (arrays, maps, promises, \`location\`,
973
+ storage, ...);
974
+ - a method that is a built-in (native) function, such as \`eval\`, \`Function\`, \`setTimeout\`,
975
+ \`setInterval\`, \`document.write\`, \`Reflect.apply\` or a bound function, or a jQuery function;
976
+ - the method names \`constructor\`, \`__proto__\` and \`prototype\`;
977
+ - arguments that are such functions.
978
+
979
+ These checks stop configuration from reaching the platform's code-executing functions through
980
+ this operation. They cannot vouch for what an application method does with its arguments, so
981
+ only expose methods that are safe to call with configured data.`,
982
+ category: `Utility`,
983
+ dependentProperties: ["instance"],
984
+ properties: {
985
+ methodName: {
986
+ type: "ParameterType:string",
987
+ required: true,
988
+ erased: true
989
+ },
990
+ methodArguments: {
991
+ type: "ParameterType:array",
992
+ erased: true
993
+ }
994
+ },
995
+ outputProperties: { methodResult: { type: "ParameterType:object" } }
996
+ };
997
+ }
998
+
999
+ //#endregion
1000
+ //#region src/operation/metadata/is-element-in-viewport.ts
1001
+ function isElementInViewport() {
1002
+ return {
1003
+ description: `Checks if an element is currently visible within the viewport.
1004
+
1005
+ Uses \`getBoundingClientRect()\` to determine if the element is within the viewport boundaries.`,
1006
+ category: `DOM`,
1007
+ dependentProperties: ["selectedElement"],
1008
+ outputProperties: { isInViewport: { type: "ParameterType:boolean" } }
1009
+ };
1010
+ }
1011
+
1012
+ //#endregion
1013
+ //#region src/operation/metadata/load-from-storage.ts
1014
+ function loadFromStorage() {
1015
+ return {
1016
+ description: `Loads data from browser storage (localStorage or sessionStorage).
1017
+
1018
+ Deserializes the stored JSON value. Returns \`null\` if key doesn't exist.
1019
+ When \`storageType\` is omitted, localStorage is used.`,
1020
+ category: `Data`,
1021
+ properties: {
1022
+ key: {
1023
+ type: "ParameterType:string",
1024
+ required: true,
1025
+ erased: true
1026
+ },
1027
+ storageType: {
1028
+ type: [{ value: "local" }, { value: "session" }],
1029
+ required: true,
1030
+ erased: true
1031
+ }
1032
+ },
1033
+ outputProperties: { loadedValue: { type: "ParameterType:object" } }
1034
+ };
1035
+ }
1036
+
1037
+ //#endregion
1038
+ //#region src/operation/metadata/load-json.ts
1039
+ function loadJson() {
1040
+ return {
1041
+ description: `This operation loads a JSON file from the specified url and assigns it to the json
1042
+ property on the current operation data.
1043
+
1044
+ If the cache property is set to true and a cached value already exists, a copy of it is assigned
1045
+ instead of re-retrieving it from the url. Mutating the returned json never changes the cache.
1046
+
1047
+ The cache is shared by every engine. It is emptied when the last live engine created by
1048
+ \`EngineFactory\` is destroyed; call {@link clearJsonCache} to empty it earlier.`,
1049
+ category: `Utility`,
1050
+ properties: {
1051
+ url: {
1052
+ type: "ParameterType:string",
1053
+ required: true,
1054
+ erased: true
1055
+ },
1056
+ cache: {
1057
+ type: "ParameterType:boolean",
1058
+ erased: true
1059
+ }
1060
+ },
1061
+ outputProperties: { json: { type: "ParameterType:object" } }
1062
+ };
1063
+ }
1064
+
1065
+ //#endregion
1066
+ //#region src/operation/metadata/log.ts
1067
+ function log() {
1068
+ return {
1069
+ description: `This operation logs the specified value, or, when no logValue property has been assigned
1070
+ it will log the current operation data, global data and scope to the console`,
1071
+ category: `Utility`,
1072
+ properties: {
1073
+ logValue: {
1074
+ type: "ParameterType:object|ParameterType:string|ParameterType:number|ParameterType:boolean|ParameterType:array",
1075
+ erased: true
1076
+ },
1077
+ logName: {
1078
+ type: "ParameterType:string",
1079
+ erased: true
1080
+ }
1081
+ }
1082
+ };
1083
+ }
1084
+
1085
+ //#endregion
1086
+ //#region src/operation/metadata/map-array.ts
1087
+ function mapArray() {
1088
+ return {
1089
+ description: `Transforms each element of an array using a mapping function.
1090
+
1091
+ Operates on arrayData passed from previous operations.
1092
+ The mapFunction receives each item and optionally its index.`,
1093
+ category: `Array`,
1094
+ dependentProperties: ["arrayData"],
1095
+ properties: { mapFunction: {
1096
+ type: "ParameterType:function",
1097
+ required: true,
1098
+ erased: true
1099
+ } },
1100
+ outputProperties: { mappedArray: { type: "ParameterType:array" } }
1101
+ };
1102
+ }
1103
+
1104
+ //#endregion
1105
+ //#region src/operation/metadata/math.ts
1106
+ function math() {
1107
+ return {
1108
+ description: `This operation performs the given math function with the specified arguments.
1109
+
1110
+ \`args\` and \`functionName\` may contain property chains (\`$operationdata.\`, \`$globaldata.\`,
1111
+ \`$scope.\`). Only these two inputs are resolved; the rest of the operation data is left as it
1112
+ is. Arguments that name a Math constant (such as \`'PI'\`) are replaced by its value.`,
1113
+ category: `Utility`,
1114
+ properties: {
1115
+ args: {
1116
+ type: "ParameterType:array",
1117
+ required: true,
1118
+ erased: true
1119
+ },
1120
+ functionName: {
1121
+ type: "ParameterType:mathfunction",
1122
+ required: true,
1123
+ erased: true
1124
+ }
1125
+ },
1126
+ outputProperties: { mathResult: { type: "ParameterType:number" } }
1127
+ };
1128
+ }
1129
+
1130
+ //#endregion
1131
+ //#region src/operation/metadata/otherwise.ts
1132
+ function otherwise() {
1133
+ return {
1134
+ description: `If the preceeding {@link when} operation evaluates to \`true\` subsequent operations will
1135
+ be skipped until an {@link endWhen} operation is encountered.`,
1136
+ category: `Control Flow`
1137
+ };
1138
+ }
1139
+
1140
+ //#endregion
1141
+ //#region src/operation/metadata/remove-class.ts
1142
+ function removeClass() {
1143
+ return {
1144
+ description: `This operation removes the spcified class name from the given selected element.`,
1145
+ category: `DOM`,
1146
+ dependentProperties: ["selectedElement"],
1147
+ properties: { className: {
1148
+ type: "ParameterType:className",
1149
+ required: true,
1150
+ erased: true
1151
+ } }
1152
+ };
1153
+ }
1154
+
1155
+ //#endregion
1156
+ //#region src/operation/metadata/remove-controller-from-element.ts
1157
+ function removeControllerFromElement() {
1158
+ return {
1159
+ description: `This operation removes the controller with the specified name from the given selected element.`,
1160
+ category: `Controller`,
1161
+ dependentProperties: ["selectedElement"],
1162
+ properties: { controllerName: {
1163
+ type: "ParameterType:controllerName",
1164
+ required: true,
1165
+ erased: true
1166
+ } }
1167
+ };
1168
+ }
1169
+
1170
+ //#endregion
1171
+ //#region src/operation/metadata/remove-element.ts
1172
+ function removeElement() {
1173
+ return {
1174
+ description: `This operation removes the given selected element from the DOM.
1175
+
1176
+ Controllers attached to the element or its descendants (by \`addControllerToElement\`) are
1177
+ detached first, so their eventbus and window listeners do not outlive the element.`,
1178
+ category: `DOM`,
1179
+ dependentProperties: ["selectedElement"]
1180
+ };
1181
+ }
1182
+
1183
+ //#endregion
1184
+ //#region src/operation/metadata/remove-properties-from-operation-data.ts
1185
+ function removePropertiesFromOperationData() {
1186
+ return {
1187
+ description: `This operation removes the given list of properties from the current operation data.
1188
+ It will also remove the property \`propertyNames\` from the result.`,
1189
+ category: `Data`,
1190
+ properties: { propertyNames: {
1191
+ type: "ParameterType:array",
1192
+ itemType: "ParameterType:string",
1193
+ required: true,
1194
+ erased: true
1195
+ } }
1196
+ };
1197
+ }
1198
+
1199
+ //#endregion
1200
+ //#region src/operation/metadata/reparent-element.ts
1201
+ function reparentElement() {
1202
+ return {
1203
+ description: `This operation moves the given selected element to the new parent that is defined
1204
+ by the specified \`newParentSelector\`. jQuery data, event handlers and attached controllers
1205
+ are preserved.
1206
+
1207
+ The selector is resolved inside the engine root (the root itself included), the same way
1208
+ \`selectElement\` resolves its selector, and must match exactly one element. HTML strings are
1209
+ not accepted.`,
1210
+ category: `DOM`,
1211
+ dependentProperties: ["selectedElement"],
1212
+ properties: { newParentSelector: {
1213
+ type: "ParameterType:selector",
1214
+ required: true,
1215
+ erased: true
1216
+ } }
1217
+ };
1218
+ }
1219
+
1220
+ //#endregion
1221
+ //#region src/operation/metadata/replace-string.ts
1222
+ function replaceString() {
1223
+ return {
1224
+ description: `Replaces occurrences of a pattern in a string (alias for replaceText for string context).
1225
+
1226
+ Like replaceText, a string pattern replaces every occurrence and inserts the replacement
1227
+ literally (\`$&\`, \`$1\` and similar are not expanded). A RegExp pattern follows
1228
+ \`String.prototype.replace\`: only a global RegExp replaces every match, and \`$\` patterns
1229
+ in the replacement are expanded. Unlike replaceText, the result is written to \`result\`
1230
+ and \`textContent\` is left unchanged.`,
1231
+ category: `String`,
1232
+ dependentProperties: ["textContent"],
1233
+ properties: {
1234
+ pattern: {
1235
+ type: "ParameterType:string|ParameterType:RegExp",
1236
+ required: true,
1237
+ erased: true
1238
+ },
1239
+ replacement: {
1240
+ type: "ParameterType:string",
1241
+ required: true,
1242
+ erased: true
1243
+ }
1244
+ },
1245
+ outputProperties: { result: { type: "ParameterType:string" } }
1246
+ };
1247
+ }
1248
+
1249
+ //#endregion
1250
+ //#region src/operation/metadata/replace-text.ts
1251
+ function replaceText() {
1252
+ return {
1253
+ description: `Finds and replaces text using literal string or regex pattern.
1254
+
1255
+ Operates on textContent passed from previous operations (e.g., getTextContent).
1256
+ Supports regex patterns with global flag for multiple replacements.
1257
+ Updates textContent with replaced text and sets replacementCount.
1258
+
1259
+ A string pattern replaces every occurrence and inserts the replacement literally.`,
1260
+ category: `Text`,
1261
+ dependentProperties: ["textContent"],
1262
+ properties: {
1263
+ searchPattern: {
1264
+ type: "ParameterType:string|ParameterType:RegExp",
1265
+ required: true,
1266
+ erased: true
1267
+ },
1268
+ replacement: {
1269
+ type: "ParameterType:string",
1270
+ required: true,
1271
+ erased: true
1272
+ }
1273
+ },
1274
+ outputProperties: { replacementCount: { type: "ParameterType:number" } }
1275
+ };
1276
+ }
1277
+
1278
+ //#endregion
1279
+ //#region src/operation/metadata/request-action.ts
1280
+ function requestAction() {
1281
+ return {
1282
+ description: `This operation requests an action instance with the specified name and assigns it
1283
+ to the \`actionInstance\` property on the current operation data.`,
1284
+ category: `Action`,
1285
+ properties: { systemName: {
1286
+ type: "ParameterType:actionName",
1287
+ required: true,
1288
+ erased: true
1289
+ } },
1290
+ outputProperties: { actionInstance: { type: "ParameterType:object" } }
1291
+ };
1292
+ }
1293
+
1294
+ //#endregion
1295
+ //#region src/operation/metadata/save-to-storage.ts
1296
+ function saveToStorage() {
1297
+ return {
1298
+ description: `Saves data to browser storage (localStorage or sessionStorage).
1299
+
1300
+ Serializes the value as JSON before storing. Supports any JSON-serializable data type.
1301
+ Use \`null\` to store an empty value; \`undefined\` cannot be stored as JSON and is rejected.
1302
+ When \`storageType\` is omitted, localStorage is used.`,
1303
+ category: `Data`,
1304
+ properties: {
1305
+ key: {
1306
+ type: "ParameterType:string",
1307
+ required: true,
1308
+ erased: true
1309
+ },
1310
+ value: {
1311
+ type: "ParameterType:object",
1312
+ required: true,
1313
+ erased: true
1314
+ },
1315
+ storageType: {
1316
+ type: [{ value: "local" }, { value: "session" }],
1317
+ required: true,
1318
+ erased: true
1319
+ }
1320
+ }
1321
+ };
1322
+ }
1323
+
1324
+ //#endregion
1325
+ //#region src/operation/metadata/scroll-to-element.ts
1326
+ function scrollToElement() {
1327
+ return {
1328
+ description: `Scrolls the viewport to bring the selected element into view.
1329
+
1330
+ Uses the browser's \`scrollIntoView\` API with configurable behavior.`,
1331
+ category: `Scroll`,
1332
+ dependentProperties: ["selectedElement"],
1333
+ properties: {
1334
+ behavior: {
1335
+ type: [{ value: "auto" }, { value: "smooth" }],
1336
+ erased: true
1337
+ },
1338
+ block: {
1339
+ type: [
1340
+ { value: "start" },
1341
+ { value: "center" },
1342
+ { value: "end" },
1343
+ { value: "nearest" }
1344
+ ],
1345
+ erased: true
1346
+ },
1347
+ inline: {
1348
+ type: [
1349
+ { value: "start" },
1350
+ { value: "center" },
1351
+ { value: "end" },
1352
+ { value: "nearest" }
1353
+ ],
1354
+ erased: true
1355
+ }
1356
+ }
1357
+ };
1358
+ }
1359
+
1360
+ //#endregion
1361
+ //#region src/operation/metadata/scroll-to-position.ts
1362
+ function scrollToPosition() {
1363
+ return {
1364
+ description: `Scrolls the viewport to a specific x,y coordinate position.
1365
+
1366
+ Uses the browser's \`window.scrollTo\` API with configurable behavior.`,
1367
+ category: `Scroll`,
1368
+ properties: {
1369
+ x: {
1370
+ type: "ParameterType:number",
1371
+ required: true,
1372
+ erased: true
1373
+ },
1374
+ y: {
1375
+ type: "ParameterType:number",
1376
+ required: true,
1377
+ erased: true
1378
+ },
1379
+ behavior: {
1380
+ type: [{ value: "auto" }, { value: "smooth" }],
1381
+ erased: true
1382
+ }
1383
+ }
1384
+ };
1385
+ }
1386
+
1387
+ //#endregion
1388
+ //#region src/operation/metadata/select-element.ts
1389
+ function selectElement() {
1390
+ return {
1391
+ description: `This operation selects one or more elements using the specified selector.
1392
+
1393
+ If \`useSelectedElementAsRoot\` is set to true and a valid DOM element is assigned
1394
+ to the current operation data's \`selectedElement\` property
1395
+ then the element will be looked for only in the descendant elements of this DOM element.`,
1396
+ category: `DOM`,
1397
+ properties: {
1398
+ selector: {
1399
+ type: "ParameterType:selector",
1400
+ required: true,
1401
+ erased: true
1402
+ },
1403
+ useSelectedElementAsRoot: {
1404
+ type: "ParameterType:boolean",
1405
+ erased: true
1406
+ }
1407
+ },
1408
+ outputProperties: { selectedElement: { type: "ParameterType:object" } }
1409
+ };
1410
+ }
1411
+
1412
+ //#endregion
1413
+ //#region src/operation/metadata/set-data.ts
1414
+ function setData() {
1415
+ return {
1416
+ description: `This operation assigns the specified properties to the specified data targets.`,
1417
+ category: `Data`,
1418
+ properties: { properties: {
1419
+ type: "ParameterType:object",
1420
+ required: true,
1421
+ erased: true
1422
+ } }
1423
+ };
1424
+ }
1425
+
1426
+ //#endregion
1427
+ //#region src/operation/metadata/set-element-attributes.ts
1428
+ function setElementAttributes() {
1429
+ return {
1430
+ description: `This operation sets the specified set of attributes on the given selected element.
1431
+
1432
+ Event handler (\`on*\`) and \`srcdoc\` attributes, and \`javascript:\` or \`vbscript:\` URLs in URL
1433
+ attributes such as \`href\`, \`src\` and \`formaction\`, are refused, the same as in \`createElement\`.`,
1434
+ category: `DOM`,
1435
+ dependentProperties: ["selectedElement"],
1436
+ properties: { attributes: {
1437
+ type: "ParameterType:object",
1438
+ required: true,
1439
+ erased: true
1440
+ } }
1441
+ };
1442
+ }
1443
+
1444
+ //#endregion
1445
+ //#region src/operation/metadata/set-element-content.ts
1446
+ function setElementContent() {
1447
+ return {
1448
+ description: `This operation sets the specified content defined by the value assigned to the template property
1449
+ to the given selected element.
1450
+
1451
+ When the \`insertionType\` is set to \`overwrite\` the contents of the selected element are replaced
1452
+ by the given template.
1453
+ When set to \`append\` the new content will be inserted after the current content.
1454
+ When set to \`prepend\` the new content will be inserted before the current content.
1455
+
1456
+ With \`overwrite\`, controllers attached to the replaced content (by \`addControllerToElement\`) are
1457
+ detached first. Controllers on the selected element itself stay attached.
1458
+
1459
+ The template is inserted as HTML: a string template is parsed by jQuery, which also runs the
1460
+ scripts and inline event handlers it contains. Only use string templates from the configuration
1461
+ or the resource importer; build content from user data with \`createElement\`, whose \`text\` is
1462
+ never parsed as HTML.`,
1463
+ category: `DOM`,
1464
+ dependentProperties: ["selectedElement"],
1465
+ properties: {
1466
+ template: {
1467
+ type: "ParameterType:string|ParameterType:Element|ParameterType:Text|ParameterType:Comment|ParameterType:Document|ParameterType:DocumentFragment",
1468
+ erased: true
1469
+ },
1470
+ insertionType: {
1471
+ type: [
1472
+ { value: "overwrite" },
1473
+ { value: "append" },
1474
+ { value: "prepend" }
1475
+ ],
1476
+ erased: true
1477
+ }
1478
+ }
1479
+ };
1480
+ }
1481
+
1482
+ //#endregion
1483
+ //#region src/operation/metadata/set-focus.ts
1484
+ function setFocus() {
1485
+ return {
1486
+ description: `Sets focus to the selected element.`,
1487
+ category: `Focus`,
1488
+ dependentProperties: ["selectedElement"]
1489
+ };
1490
+ }
1491
+
1492
+ //#endregion
1493
+ //#region src/operation/metadata/set-form-value.ts
1494
+ function setFormValue() {
1495
+ return {
1496
+ description: `Sets the value of an input, select, or textarea element.
1497
+
1498
+ Handles different input types appropriately:
1499
+ - Text inputs, textareas, selects: sets value directly
1500
+ - Checkboxes: sets checked property for boolean values
1501
+ - Radio buttons: sets checked property for boolean values
1502
+ - Number inputs: converts to string`,
1503
+ category: `Form`,
1504
+ dependentProperties: ["selectedElement"],
1505
+ properties: { value: {
1506
+ type: "ParameterType:string|ParameterType:number|ParameterType:boolean",
1507
+ required: true,
1508
+ erased: true
1509
+ } }
1510
+ };
1511
+ }
1512
+
1513
+ //#endregion
1514
+ //#region src/operation/metadata/set-global-data.ts
1515
+ function setGlobalData() {
1516
+ return {
1517
+ description: `This operation copies the specified properties from the operationData to the global data.
1518
+
1519
+ Plain data is stored as a deep copy, so changing the operation data afterwards does not change
1520
+ the global data. jQuery objects, DOM nodes, functions and class instances (such as controllers)
1521
+ are stored by reference.`,
1522
+ category: `Data`,
1523
+ properties: { propertyNames: {
1524
+ type: "ParameterType:array",
1525
+ itemType: "ParameterType:string",
1526
+ required: true,
1527
+ erased: true
1528
+ } }
1529
+ };
1530
+ }
1531
+
1532
+ //#endregion
1533
+ //#region src/operation/metadata/set-operation-data.ts
1534
+ function setOperationData() {
1535
+ return {
1536
+ description: `This operation assigns the specified properties to the current operation data.
1537
+ When override is set to true the properties replace the current operation data entirely.`,
1538
+ category: `Data`,
1539
+ properties: {
1540
+ override: {
1541
+ type: "ParameterType:boolean",
1542
+ erased: true
1543
+ },
1544
+ properties: {
1545
+ type: "ParameterType:object",
1546
+ required: true,
1547
+ erased: true
1548
+ }
1549
+ }
1550
+ };
1551
+ }
1552
+
1553
+ //#endregion
1554
+ //#region src/operation/metadata/set-style.ts
1555
+ function setStyle() {
1556
+ return {
1557
+ description: `This operation assigns the specified CSS style properties to the
1558
+ given selected element.`,
1559
+ category: `DOM`,
1560
+ dependentProperties: ["selectedElement"],
1561
+ properties: { properties: {
1562
+ type: "ParameterType:cssProperties",
1563
+ required: true,
1564
+ erased: true
1565
+ } }
1566
+ };
1567
+ }
1568
+
1569
+ //#endregion
1570
+ //#region src/operation/metadata/set-variable.ts
1571
+ function setVariable() {
1572
+ return {
1573
+ description: `This operation sets a variable with the specified name on the scope with the specified value.
1574
+
1575
+ Variables belong to the action: a variable set inside a \`when\` or \`forEach\` block is the
1576
+ same variable outside it, so it keeps its value after \`endWhen\` or \`endForEach\`, and
1577
+ variables set before the block can be read and changed inside it. Read variables with
1578
+ \`$scope.variables.<name>\`.`,
1579
+ category: `Data`,
1580
+ properties: {
1581
+ name: {
1582
+ type: "ParameterType:string",
1583
+ required: true,
1584
+ erased: true
1585
+ },
1586
+ value: {
1587
+ type: "ParameterType:object|ParameterType:string|ParameterType:number|ParameterType:boolean|ParameterType:array",
1588
+ required: true,
1589
+ erased: true
1590
+ }
1591
+ }
1592
+ };
1593
+ }
1594
+
1595
+ //#endregion
1596
+ //#region src/operation/metadata/sort-array.ts
1597
+ function sortArray() {
1598
+ return {
1599
+ description: `Sorts an array by property, natural order, or custom comparator function.
1600
+
1601
+ Operates on arrayData passed from previous operations.
1602
+ Supports three sorting modes:
1603
+ 1. Property sort: \`sortProperty\` and \`sortOrder\` to sort objects by property
1604
+ 2. Natural sort: \`sortOrder\` alone for primitive arrays
1605
+ 3. Custom comparator: \`sortComparator\` function for complex sorting logic`,
1606
+ category: `Array`,
1607
+ dependentProperties: ["arrayData"],
1608
+ properties: {
1609
+ sortProperty: {
1610
+ type: "ParameterType:string",
1611
+ erased: true
1612
+ },
1613
+ sortOrder: {
1614
+ type: [{ value: "asc" }, { value: "desc" }],
1615
+ erased: true
1616
+ },
1617
+ sortComparator: {
1618
+ type: "ParameterType:function",
1619
+ erased: true
1620
+ }
1621
+ },
1622
+ outputProperties: { sortedArray: { type: "ParameterType:array" } }
1623
+ };
1624
+ }
1625
+
1626
+ //#endregion
1627
+ //#region src/operation/metadata/split-string.ts
1628
+ function splitString() {
1629
+ return {
1630
+ description: `Splits a string into an array by delimiter (string or regex).`,
1631
+ category: `String`,
1632
+ dependentProperties: ["textContent"],
1633
+ properties: {
1634
+ delimiter: {
1635
+ type: "ParameterType:string|ParameterType:RegExp",
1636
+ required: true,
1637
+ erased: true
1638
+ },
1639
+ limit: {
1640
+ type: "ParameterType:number",
1641
+ erased: true
1642
+ }
1643
+ },
1644
+ outputProperties: { resultArray: {
1645
+ type: "ParameterType:array",
1646
+ itemType: "ParameterType:string"
1647
+ } }
1648
+ };
1649
+ }
1650
+
1651
+ //#endregion
1652
+ //#region src/operation/metadata/start-action.ts
1653
+ function startAction() {
1654
+ return {
1655
+ description: `This operation starts the specified action instance using the given action operation data.
1656
+
1657
+ The action receives its own copy of the current operation data merged with the action
1658
+ operation data. Whatever the action's operations add, change or remove in that copy stays
1659
+ with the action: once it has completed, this operation continues with the operation data it
1660
+ had before, plus \`actionInstance\`, without the \`actionOperationData\` property.`,
1661
+ category: `Action`,
1662
+ dependentProperties: ["actionInstance"],
1663
+ properties: { actionOperationData: {
1664
+ type: "ParameterType:object",
1665
+ erased: true
1666
+ } }
1667
+ };
1668
+ }
1669
+
1670
+ //#endregion
1671
+ //#region src/operation/metadata/substring-text.ts
1672
+ function substringText() {
1673
+ return {
1674
+ description: `Extracts a substring from text between start and end indices.`,
1675
+ category: `Text`,
1676
+ dependentProperties: ["textContent"],
1677
+ properties: {
1678
+ start: {
1679
+ type: "ParameterType:number",
1680
+ required: true,
1681
+ erased: true
1682
+ },
1683
+ end: {
1684
+ type: "ParameterType:number",
1685
+ erased: true
1686
+ }
1687
+ },
1688
+ outputProperties: { substring: { type: "ParameterType:string" } }
1689
+ };
1690
+ }
1691
+
1692
+ //#endregion
1693
+ //#region src/operation/metadata/toggle-class.ts
1694
+ function toggleClass() {
1695
+ return {
1696
+ description: `This operation toggles the specfied class name on the given selected element.
1697
+
1698
+ Meaning, if the specified class name exists on the given element it will be removed,
1699
+ otherwise it will be added.`,
1700
+ category: `DOM`,
1701
+ dependentProperties: ["selectedElement"],
1702
+ properties: { className: {
1703
+ type: "ParameterType:className",
1704
+ required: true,
1705
+ erased: true
1706
+ } }
1707
+ };
1708
+ }
1709
+
1710
+ //#endregion
1711
+ //#region src/operation/metadata/toggle-element.ts
1712
+ function toggleElement() {
1713
+ return {
1714
+ description: `This operation toggles the visibility of the given selected element.
1715
+
1716
+ Meaning, if the element is hidden, it will be made visible, otherwise
1717
+ it will be hidden.`,
1718
+ category: `DOM`,
1719
+ dependentProperties: ["selectedElement"]
1720
+ };
1721
+ }
1722
+
1723
+ //#endregion
1724
+ //#region src/operation/metadata/toggle-form-element.ts
1725
+ function toggleFormElement() {
1726
+ return {
1727
+ description: `Enables or disables form input elements (inputs, selects, textareas, buttons).
1728
+
1729
+ Sets the \`disabled\` property on the element. When \`enabled\` is true, removes the disabled
1730
+ attribute; when false, adds the disabled attribute.`,
1731
+ category: `Form`,
1732
+ dependentProperties: ["selectedElement"],
1733
+ properties: { enabled: {
1734
+ type: "ParameterType:boolean",
1735
+ required: true,
1736
+ erased: true
1737
+ } }
1738
+ };
1739
+ }
1740
+
1741
+ //#endregion
1742
+ //#region src/operation/metadata/validate-form.ts
1743
+ function validateForm() {
1744
+ return {
1745
+ description: `Validates form fields against HTML5 validation and custom rules.
1746
+
1747
+ Uses HTML5 validation API (checkValidity()) for native validation, and supports
1748
+ custom validation rules for: required, minLength, maxLength, pattern (regex), and email format.
1749
+
1750
+ Checkboxes and radio buttons are validated once per name: \`required\` passes when at least one
1751
+ of them is checked, and the string rules do not apply to them. For a \`<select multiple>\`,
1752
+ \`required\`, \`minLength\` and \`maxLength\` count the selected options, and \`pattern\` and \`email\`
1753
+ apply to each selected value.`,
1754
+ category: `Form`,
1755
+ dependentProperties: ["selectedElement"],
1756
+ properties: { validationRules: {
1757
+ type: "ParameterType:object",
1758
+ erased: true
1759
+ } },
1760
+ outputProperties: {
1761
+ validationErrors: { type: "ParameterType:object" },
1762
+ isValid: { type: "ParameterType:boolean" }
1763
+ }
1764
+ };
1765
+ }
1766
+
1767
+ //#endregion
1768
+ //#region src/operation/metadata/wait.ts
1769
+ function wait() {
1770
+ return {
1771
+ description: `This operation waits for the specified amount of milliseconds.`,
1772
+ category: `Utility`,
1773
+ properties: { milliseconds: {
1774
+ type: "ParameterType:number",
1775
+ required: true,
1776
+ erased: true
1777
+ } }
1778
+ };
1779
+ }
1780
+
1781
+ //#endregion
1782
+ //#region src/operation/metadata/when.ts
1783
+ function when() {
1784
+ return {
1785
+ description: `When the given expression evaluates to false, subsequent operations will be skipped
1786
+ until an {@link endWhen} or {@link otherwise} operation is encountered.
1787
+
1788
+ Practically, this means an \`if\` or \`if\`/\`else\` statement control flow implementation in a list of operations.
1789
+
1790
+ The expression is passed in as a formatted string. An operand can be one of:
1791
+
1792
+ 'constant': for a constant string (operators and parentheses inside the quotes are text)
1793
+ 100: for a constant number (the whole operand must be numeric, \`10px\` is invalid)
1794
+ true, false, null: for a boolean or null constant
1795
+ $operationData.foo: for an operation data value
1796
+ $globaldata.foo: for a global data value
1797
+ $scope.loopIndex: for a scope value
1798
+ $scope.variables.foo: for a variable set with \`setVariable\`
1799
+
1800
+ Any other operand is an error, so a misspelled chain prefix fails instead of being compared
1801
+ as a string.
1802
+
1803
+ Operands are combined with these operators, from highest to lowest precedence:
1804
+
1805
+ \`!\`: negation
1806
+ \`==\`, \`!=\`, \`>\`, \`<\`, \`>=\`, \`<=\`: comparison (\`==\` and \`!=\` compare strictly, without type
1807
+ conversion; comparisons do not chain, so write \`0<$scope.loopIndex && $scope.loopIndex<5\`)
1808
+ \`&&\`: and
1809
+ \`||\`: or
1810
+
1811
+ Parentheses group. A bare operand is true when its value is truthy, so \`'false'\` and \`'0'\`
1812
+ are true and \`0\`, \`''\`, \`null\` and a missing value are false. \`!\`, \`&&\` and \`||\` always
1813
+ produce \`true\` or \`false\`. \`!\` binds tighter than a comparison: \`!$operationdata.a==1\`
1814
+ compares \`!$operationdata.a\` with 1, write \`!($operationdata.a==1)\` to negate the comparison.
1815
+ \`&&\` and \`||\` short-circuit: when the left side decides the result, the right side is not
1816
+ resolved, so \`$operationdata.user && $operationdata.user.name=='John'\` does not fail when
1817
+ \`user\` is missing.
1818
+
1819
+ Arithmetic (\`+\`, \`-\`, \`*\`, \`/\`) is not supported: \`-\` is a valid character in a property
1820
+ chain, so \`$operationdata.a-1\` would be ambiguous. Nothing in the expression is executed as
1821
+ code, and property chains are resolved with the usual prototype-pollution and global-object
1822
+ guards.`,
1823
+ category: `Control Flow`,
1824
+ properties: { expression: {
1825
+ type: "ParameterType:expression",
1826
+ required: true,
1827
+ erased: true
1828
+ } }
1829
+ };
1830
+ }
1831
+
1832
+ //#endregion
1833
+ //#region src/operation/metadata/index.ts
1834
+ var metadata_exports$1 = /* @__PURE__ */ __exportAll({
1835
+ addClass: () => addClass,
1836
+ addControllerToElement: () => addControllerToElement,
1837
+ addGlobalsToOperation: () => addGlobalsToOperation,
1838
+ animate: () => animate,
1839
+ animateWithClass: () => animateWithClass,
1840
+ announceToScreenReader: () => announceToScreenReader,
1841
+ breakForEach: () => breakForEach,
1842
+ broadcastEvent: () => broadcastEvent,
1843
+ calc: () => calc,
1844
+ clearElement: () => clearElement,
1845
+ clearOperationData: () => clearOperationData,
1846
+ clearStorage: () => clearStorage,
1847
+ compareDate: () => compareDate,
1848
+ concatenateStrings: () => concatenateStrings,
1849
+ continueForEach: () => continueForEach,
1850
+ createElement: () => createElement,
1851
+ customFunction: () => customFunction,
1852
+ endAction: () => endAction,
1853
+ endForEach: () => endForEach,
1854
+ endWhen: () => endWhen,
1855
+ extendController: () => extendController,
1856
+ filterArray: () => filterArray,
1857
+ findInArray: () => findInArray,
1858
+ forEach: () => forEach,
1859
+ formatDate: () => formatDate,
1860
+ formatText: () => formatText,
1861
+ getAttributesFromElement: () => getAttributesFromElement,
1862
+ getControllerFromElement: () => getControllerFromElement,
1863
+ getControllerInstance: () => getControllerInstance,
1864
+ getCurrentTime: () => getCurrentTime,
1865
+ getElementDimensions: () => getElementDimensions,
1866
+ getFocusedElement: () => getFocusedElement,
1867
+ getFormData: () => getFormData,
1868
+ getImport: () => getImport,
1869
+ getQueryParams: () => getQueryParams,
1870
+ getScrollPosition: () => getScrollPosition,
1871
+ getTextContent: () => getTextContent,
1872
+ httpDelete: () => httpDelete,
1873
+ httpPost: () => httpPost,
1874
+ httpPut: () => httpPut,
1875
+ invokeObjectMethod: () => invokeObjectMethod,
1876
+ isElementInViewport: () => isElementInViewport,
1877
+ loadFromStorage: () => loadFromStorage,
1878
+ loadJson: () => loadJson,
1879
+ log: () => log,
1880
+ mapArray: () => mapArray,
1881
+ math: () => math,
1882
+ otherwise: () => otherwise,
1883
+ removeClass: () => removeClass,
1884
+ removeControllerFromElement: () => removeControllerFromElement,
1885
+ removeElement: () => removeElement,
1886
+ removePropertiesFromOperationData: () => removePropertiesFromOperationData,
1887
+ reparentElement: () => reparentElement,
1888
+ replaceString: () => replaceString,
1889
+ replaceText: () => replaceText,
1890
+ requestAction: () => requestAction,
1891
+ saveToStorage: () => saveToStorage,
1892
+ scrollToElement: () => scrollToElement,
1893
+ scrollToPosition: () => scrollToPosition,
1894
+ selectElement: () => selectElement,
1895
+ setData: () => setData,
1896
+ setElementAttributes: () => setElementAttributes,
1897
+ setElementContent: () => setElementContent,
1898
+ setFocus: () => setFocus,
1899
+ setFormValue: () => setFormValue,
1900
+ setGlobalData: () => setGlobalData,
1901
+ setOperationData: () => setOperationData,
1902
+ setStyle: () => setStyle,
1903
+ setVariable: () => setVariable,
1904
+ sortArray: () => sortArray,
1905
+ splitString: () => splitString,
1906
+ startAction: () => startAction,
1907
+ substringText: () => substringText,
1908
+ toggleClass: () => toggleClass,
1909
+ toggleElement: () => toggleElement,
1910
+ toggleFormElement: () => toggleFormElement,
1911
+ validateForm: () => validateForm,
1912
+ wait: () => wait,
1913
+ when: () => when
1914
+ });
1915
+
1916
+ //#endregion
1917
+ //#region src/util/find-closest-names.ts
1918
+ /**
1919
+ * Returns the known names closest to `name`, for "did you mean" hints in error
1920
+ * messages. Matching ignores case and uses the Levenshtein edit distance; only
1921
+ * names within `max(2, floor(name.length / 3))` edits are returned, closest
1922
+ * first.
1923
+ *
1924
+ * @param name - The unknown name, as written in the configuration
1925
+ * @param knownNames - The names that are registered
1926
+ * @param max - The maximum number of suggestions to return
1927
+ * @returns Up to `max` known names, closest first; empty when none is close
1928
+ */
1929
+ function findClosestNames(name, knownNames, max = 3) {
1930
+ const lowerName = name.toLowerCase();
1931
+ const maxDistance = Math.max(2, Math.floor(name.length / 3));
1932
+ return knownNames.map((knownName) => ({
1933
+ knownName,
1934
+ distance: levenshtein(lowerName, knownName.toLowerCase())
1935
+ })).filter(({ distance }) => distance <= maxDistance).sort((a, b) => a.distance - b.distance).slice(0, max).map(({ knownName }) => knownName);
1936
+ }
1937
+ /**
1938
+ * Formats suggestions from {@link findClosestNames} as a sentence.
1939
+ *
1940
+ * @param suggestions - The suggested names
1941
+ * @returns `Did you mean 'a', 'b'?`, or an empty string when there are no suggestions
1942
+ */
1943
+ function formatDidYouMean(suggestions) {
1944
+ if (!suggestions.length) return "";
1945
+ return `Did you mean ${suggestions.map((name) => `'${name}'`).join(", ")}?`;
1946
+ }
1947
+ function levenshtein(a, b) {
1948
+ let previous = Array.from({ length: b.length + 1 }, (_, i) => i);
1949
+ for (let i = 1; i <= a.length; i++) {
1950
+ const current = [i];
1951
+ for (let j = 1; j <= b.length; j++) {
1952
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
1953
+ current[j] = Math.min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + cost);
1954
+ }
1955
+ previous = current;
1956
+ }
1957
+ return previous[b.length];
1958
+ }
1959
+
1960
+ //#endregion
1961
+ //#region src/configuration/api/operation-lookup.ts
1962
+ /**
1963
+ * Operation names are validated against the generated operation metadata, not
1964
+ * against the operation implementations. The metadata is plain data, so the
1965
+ * fluent configuration API can be loaded in a DOM-less context (Node build
1966
+ * tools such as the Eligian compiler), where importing the implementations
1967
+ * would evaluate jQuery and throw.
1968
+ *
1969
+ * @param name the operation system name to check
1970
+ * @returns `true` when `name` is a built-in operation
1971
+ */
1972
+ function isKnownOperationName(name) {
1973
+ return Object.hasOwn(metadata_exports$1, name);
1974
+ }
1975
+ /**
1976
+ * Throws when the given name is neither the system name of a built-in
1977
+ * operation nor one of the given custom operation names.
1978
+ *
1979
+ * @param name the operation system name to check
1980
+ * @param customOperationNames the custom operation names that are accepted as
1981
+ * well (the `ConfigurationFactory`'s `customOperations` option)
1982
+ * @throws Error when no operation with the given name exists. The message
1983
+ * suggests the closest built-in and custom names, and explains how to declare
1984
+ * a custom operation.
1985
+ */
1986
+ function assertKnownOperationName(name, customOperationNames) {
1987
+ if (isKnownOperationName(name) || customOperationNames?.has(name)) return;
1988
+ const knownNames = [...Object.keys(metadata_exports$1), ...customOperationNames ?? []];
1989
+ const didYouMean = formatDidYouMean(findClosestNames(String(name), knownNames));
1990
+ throw Error(`Unknown operation: ${name}. ${didYouMean ? `${didYouMean} ` : ""}To add a custom operation, declare its name in the ConfigurationFactory options: new ConfigurationFactory(undefined, {customOperations: ['myOperation']}).`);
1991
+ }
1992
+ /**
1993
+ * Maps operation functions to their system names, for the `...ByType` methods
1994
+ * of the fluent API. The map is filled by `register-operation-types.ts`, which
1995
+ * the browser entry point (`eligius`) loads. The DOM-free entry point
1996
+ * (`eligius/configuration-api`) does not load the operation implementations,
1997
+ * so the map stays empty there.
1998
+ *
1999
+ * The lookup is by function identity, not by `Function.name`, so it keeps
2000
+ * working when a minifier renames the operation functions.
2001
+ */
2002
+ const operationNamesByType = /* @__PURE__ */ new Map();
2003
+ /**
2004
+ * Returns the system name of the given operation function.
2005
+ *
2006
+ * @param operationType the operation function
2007
+ * @param methodName the fluent API method that asks, used in the error message
2008
+ * @param nameBasedMethodName the method that takes a system name instead
2009
+ * @returns the system name of the operation
2010
+ * @throws Error when the operation function is not known
2011
+ */
2012
+ function getOperationNameByType(operationType, methodName, nameBasedMethodName) {
2013
+ const name = operationNamesByType.get(operationType);
2014
+ if (name) return name;
2015
+ if (operationNamesByType.size === 0) throw new Error(`${methodName}: the operation implementations are not loaded, so an operation function cannot be mapped to its name. Import the fluent API from the main 'eligius' entry, or call ${nameBasedMethodName}('<operationName>', ...) with the operation's system name.`);
2016
+ throw new Error(`Operation class not found: ${String(operationType)}`);
2017
+ }
2018
+
2019
+ //#endregion
2020
+ //#region src/configuration/api/sync-in-place.ts
2021
+ /**
2022
+ * Keys that are never copied into the target. Assigning `__proto__` through the
2023
+ * inherited accessor would replace a prototype (or, when the existing value is
2024
+ * read through it, write onto `Object.prototype`), and `constructor` and
2025
+ * `prototype` are the other two entry points of prototype pollution.
2026
+ */
2027
+ const UNSAFE_KEYS = /* @__PURE__ */ new Set([
2028
+ "__proto__",
2029
+ "constructor",
2030
+ "prototype"
2031
+ ]);
2032
+ /**
2033
+ * Makes `target` structurally equal to `source` while keeping the identity of
2034
+ * the objects and arrays inside `target` wherever possible.
2035
+ *
2036
+ * The fluent configuration API hands out editors that hold references to
2037
+ * objects inside the factory's configuration (an action, an operation, the
2038
+ * timeline provider settings). Replacing those objects with copies would
2039
+ * detach the editors, so updates are applied in place instead:
2040
+ *
2041
+ * - Plain objects are updated key by key; keys missing from `source` are removed.
2042
+ * - Array entries are matched by their string `id` when both sides have one,
2043
+ * otherwise by position. Matched entries are synced recursively and reused.
2044
+ * - Everything else is assigned from `source`.
2045
+ * - The keys `__proto__`, `constructor` and `prototype` are skipped at every
2046
+ * nesting level, also inside values that are inserted as they are, so data
2047
+ * from `JSON.parse` cannot pollute `Object.prototype`.
2048
+ *
2049
+ * `source` should be a value the caller owns (for example a deep copy), because
2050
+ * unmatched values from it are inserted into `target` as they are (after their
2051
+ * unsafe keys have been removed).
2052
+ *
2053
+ * @param target - The object to update in place
2054
+ * @param source - The desired state
2055
+ */
2056
+ function syncInPlace(target, source) {
2057
+ if (target === source) return;
2058
+ removeUnsafeKeys(source, /* @__PURE__ */ new WeakSet());
2059
+ if (Array.isArray(target) && Array.isArray(source)) {
2060
+ syncArray(target, source);
2061
+ return;
2062
+ }
2063
+ syncObject(target, source);
2064
+ }
2065
+ /**
2066
+ * Deletes the unsafe own keys from every plain object and array reachable from
2067
+ * `value`. Deleting an own `__proto__` data property is safe, it does not go
2068
+ * through the inherited accessor.
2069
+ */
2070
+ function removeUnsafeKeys(value, seen) {
2071
+ if (value === null || typeof value !== "object" || seen.has(value)) return;
2072
+ seen.add(value);
2073
+ if (Array.isArray(value)) {
2074
+ for (const item of value) removeUnsafeKeys(item, seen);
2075
+ return;
2076
+ }
2077
+ if (!isPlainObject(value)) return;
2078
+ for (const key of Object.keys(value)) if (UNSAFE_KEYS.has(key)) delete value[key];
2079
+ else removeUnsafeKeys(value[key], seen);
2080
+ }
2081
+ function syncObject(target, source) {
2082
+ for (const key of Object.keys(target)) if (!Object.hasOwn(source, key)) delete target[key];
2083
+ for (const key of Object.keys(source)) {
2084
+ if (UNSAFE_KEYS.has(key)) continue;
2085
+ target[key] = syncValue(Object.hasOwn(target, key) ? target[key] : void 0, source[key]);
2086
+ }
2087
+ }
2088
+ function syncArray(target, source) {
2089
+ const byId = /* @__PURE__ */ new Map();
2090
+ for (const item of target) {
2091
+ const id = idOf(item);
2092
+ if (id !== void 0) byId.set(id, item);
2093
+ }
2094
+ const next = source.map((item, index) => {
2095
+ const id = idOf(item);
2096
+ const match = id !== void 0 ? byId.get(id) : target[index];
2097
+ if (id !== void 0 && match !== void 0) byId.delete(id);
2098
+ return syncValue(match, item);
2099
+ });
2100
+ target.length = 0;
2101
+ target.push(...next);
2102
+ }
2103
+ function syncValue(existing, incoming) {
2104
+ if (Array.isArray(existing) && Array.isArray(incoming)) {
2105
+ syncArray(existing, incoming);
2106
+ return existing;
2107
+ }
2108
+ if (isPlainObject(existing) && isPlainObject(incoming)) {
2109
+ if (idOf(existing) !== idOf(incoming)) return incoming;
2110
+ syncObject(existing, incoming);
2111
+ return existing;
2112
+ }
2113
+ return incoming;
2114
+ }
2115
+ function idOf(value) {
2116
+ if (isPlainObject(value) && typeof value.id === "string") return value.id;
2117
+ }
2118
+ function isPlainObject(value) {
2119
+ if (value === null || typeof value !== "object") return false;
2120
+ if (value === Object.prototype) return false;
2121
+ const proto = Object.getPrototypeOf(value);
2122
+ return proto === Object.prototype || proto === null;
2123
+ }
2124
+
2125
+ //#endregion
2126
+ //#region src/configuration/api/action-creator-factory.ts
2127
+ /**
2128
+ *
2129
+ * Container factory capable of creating the different kinds of actions.
2130
+ * For each type of action a dedicated factory will be returned.
2131
+ *
2132
+ */
2133
+ var ActionCreatorFactory = class {
2134
+ configurationfactory;
2135
+ constructor(configurationfactory) {
2136
+ this.configurationfactory = configurationfactory;
2137
+ }
2138
+ /**
2139
+ *
2140
+ * Starts the creation of an action in the `actions` list with the specified name
2141
+ *
2142
+ * @param name
2143
+ * @returns
2144
+ */
2145
+ createAction(name) {
2146
+ const creator = new EndableActionCreator(name, this);
2147
+ this.configurationfactory.addAction(creator.actionConfig);
2148
+ return creator;
2149
+ }
2150
+ /**
2151
+ *
2152
+ * Starts the creation of an action in the `initActions` list with the specified name
2153
+ *
2154
+ * @param name
2155
+ * @returns
2156
+ */
2157
+ createInitAction(name) {
2158
+ const creator = new EndableActionCreator(name, this);
2159
+ this.configurationfactory.addInitAction(creator.actionConfig);
2160
+ return creator;
2161
+ }
2162
+ /**
2163
+ *
2164
+ * Starts the creation of an action in the `eventActions` list with the specified name
2165
+ *
2166
+ * @param name
2167
+ * @param eventName the event that starts the action. Without it the action can
2168
+ * only be started by name (for example by a `DOMEventListenerController`).
2169
+ * @param eventTopic optional topic of the event
2170
+ * @returns
2171
+ */
2172
+ createEventAction(name, eventName, eventTopic) {
2173
+ const creator = new ActionCreator(name, this);
2174
+ const config = creator.actionConfig;
2175
+ if (eventName !== void 0) config.eventName = eventName;
2176
+ if (eventTopic !== void 0) config.eventTopic = eventTopic;
2177
+ this.configurationfactory.addEventAction(creator.actionConfig);
2178
+ return creator;
2179
+ }
2180
+ /**
2181
+ *
2182
+ * Starts the creation of an action in the `timelineActions` list with the specified name and uri
2183
+ *
2184
+ * @param uri
2185
+ * @param name
2186
+ * @returns
2187
+ */
2188
+ createTimelineAction(uri, name) {
2189
+ const creator = new TimelineActionCreator(name, this);
2190
+ this.configurationfactory.addTimelineAction(uri, creator.actionConfig);
2191
+ return creator;
2192
+ }
2193
+ /**
2194
+ *
2195
+ * Returns the fluent scope back to the `Configurationfactory`
2196
+ *
2197
+ * @returns
2198
+ */
2199
+ end() {
2200
+ return this.configurationfactory;
2201
+ }
2202
+ };
2203
+ /**
2204
+ *
2205
+ * A factory that assists in creating an action
2206
+ *
2207
+ */
2208
+ var ActionCreator = class {
2209
+ factory;
2210
+ actionConfig;
2211
+ /**
2212
+ *
2213
+ * Initializes an action configuration with the given name
2214
+ *
2215
+ * @param name
2216
+ * @param factory
2217
+ */
2218
+ constructor(name, factory) {
2219
+ this.factory = factory;
2220
+ this.actionConfig = {
2221
+ name: name ?? "",
2222
+ id: v4(),
2223
+ startOperations: []
2224
+ };
2225
+ }
2226
+ /**
2227
+ *
2228
+ * The unique id of the action
2229
+ *
2230
+ * @returns
2231
+ */
2232
+ getId() {
2233
+ return this.actionConfig.id;
2234
+ }
2235
+ /**
2236
+ *
2237
+ * Sets the name of the action
2238
+ *
2239
+ * @param name
2240
+ * @returns
2241
+ * @throws Error when the action is in `actions` or `eventActions` and another
2242
+ * action in those lists already has the name
2243
+ */
2244
+ setName(name) {
2245
+ this.factory.end?.()?.assertUniqueActionName?.(name, this.actionConfig);
2246
+ this.actionConfig.name = name;
2247
+ return this;
2248
+ }
2249
+ /**
2250
+ *
2251
+ * Passes a copy of the internal state of the `ActionCreator` to the given callback.
2252
+ * When the callback returns a configuration, it replaces the action configuration
2253
+ * in the `ConfigurationFactory`.
2254
+ *
2255
+ * @param callBack
2256
+ * @returns
2257
+ */
2258
+ getConfiguration(callBack) {
2259
+ const copy = deepCopy(this.actionConfig);
2260
+ const newConfig = callBack.call(this, copy);
2261
+ if (newConfig) syncInPlace(this.actionConfig, deepCopy(newConfig));
2262
+ return this;
2263
+ }
2264
+ /**
2265
+ *
2266
+ * Adds the operation data for a start operation specified by the given type
2267
+ *
2268
+ * @param operationClass
2269
+ * @param operationData
2270
+ * @returns
2271
+ * @throws Error when the function is not an operation, or when the operation
2272
+ * implementations are not loaded (the DOM-free `eligius/configuration-api` entry)
2273
+ */
2274
+ addStartOperationByType(operationClass, operationData) {
2275
+ return this.addStartOperation(getOperationNameByType(operationClass, "addStartOperationByType", "addStartOperation"), operationData);
2276
+ }
2277
+ /**
2278
+ *
2279
+ * Adds the operation data for a start operation specified by the given system name.
2280
+ * The operation data is copied, so later changes to the given object do not
2281
+ * affect the configuration.
2282
+ *
2283
+ * @param systemName a built-in operation name, or a name from the factory's
2284
+ * `customOperations` option
2285
+ * @param operationData
2286
+ * @returns
2287
+ * @throws Error when `systemName` is neither a built-in nor a declared custom operation
2288
+ */
2289
+ addStartOperation(systemName, operationData) {
2290
+ assertKnownOperationName(systemName, this._customOperationNames());
2291
+ const { startOperations } = this.actionConfig;
2292
+ startOperations.push({
2293
+ id: v4(),
2294
+ systemName,
2295
+ operationData: deepCopy(operationData)
2296
+ });
2297
+ return this;
2298
+ }
2299
+ /**
2300
+ *
2301
+ * Returns the fluent scope back to the `ActionCreatorFactory`
2302
+ *
2303
+ * @returns
2304
+ */
2305
+ next() {
2306
+ return this.factory;
2307
+ }
2308
+ /**
2309
+ * The custom operation names of the `ConfigurationFactory`. Optional calls:
2310
+ * a creator may be constructed with a stand-in factory.
2311
+ */
2312
+ _customOperationNames() {
2313
+ return this.factory.end?.()?.customOperationNames;
2314
+ }
2315
+ };
2316
+ /**
2317
+ *
2318
+ * A factory that assists in creating an endable action
2319
+ *
2320
+ */
2321
+ var EndableActionCreator = class extends ActionCreator {
2322
+ constructor(name, factory) {
2323
+ super(name, factory);
2324
+ this.actionConfig.endOperations = [];
2325
+ }
2326
+ /**
2327
+ *
2328
+ * Adds the operation data for an end operation specified by the given type
2329
+ *
2330
+ * @param operationClass
2331
+ * @param operationData
2332
+ * @returns
2333
+ * @throws Error when the function is not an operation, or when the operation
2334
+ * implementations are not loaded (the DOM-free `eligius/configuration-api` entry)
2335
+ */
2336
+ addEndOperationByType(operationClass, operationData) {
2337
+ return this.addEndOperation(getOperationNameByType(operationClass, "addEndOperationByType", "addEndOperation"), operationData);
2338
+ }
2339
+ /**
2340
+ *
2341
+ * Adds the operation data for an end operation specified by the given system name.
2342
+ * The operation data is copied, so later changes to the given object do not
2343
+ * affect the configuration.
2344
+ *
2345
+ * @param systemName a built-in operation name, or a name from the factory's
2346
+ * `customOperations` option
2347
+ * @param operationData
2348
+ * @returns
2349
+ * @throws Error when `systemName` is neither a built-in nor a declared custom operation
2350
+ */
2351
+ addEndOperation(systemName, operationData) {
2352
+ assertKnownOperationName(systemName, this._customOperationNames());
2353
+ let { endOperations } = this.actionConfig;
2354
+ if (!endOperations) endOperations = this.actionConfig.endOperations = [];
2355
+ endOperations.push({
2356
+ id: v4(),
2357
+ systemName,
2358
+ operationData: deepCopy(operationData)
2359
+ });
2360
+ return this;
2361
+ }
2362
+ };
2363
+ /**
2364
+ *
2365
+ * A factory that assists in creating a timeline action
2366
+ *
2367
+ */
2368
+ var TimelineActionCreator = class extends EndableActionCreator {
2369
+ /**
2370
+ *
2371
+ * Sets the duration specified by the given start and optional end positions
2372
+ *
2373
+ * @param start
2374
+ * @param end
2375
+ * @returns
2376
+ * @throws Error when `end` is given and lower than `start`
2377
+ */
2378
+ addDuration(start, end) {
2379
+ if (end !== void 0 && start > end) throw new Error(`addDuration: start (${start}) cannot be higher than end (${end})`);
2380
+ this.actionConfig.duration = { start };
2381
+ if (end !== void 0) this.actionConfig.duration.end = end;
2382
+ return this;
2383
+ }
2384
+ };
2385
+
2386
+ //#endregion
2387
+ //#region src/configuration/api/action-editor.ts
2388
+ function array_move(arr, old_index, new_index) {
2389
+ if (new_index >= arr.length) new_index = 0;
2390
+ else if (new_index < 0) new_index = arr.length - 1;
2391
+ arr.splice(new_index, 0, arr.splice(old_index, 1)[0]);
2392
+ }
2393
+ /**
2394
+ *
2395
+ * A factory that assists in editing an action.
2396
+ *
2397
+ * The editor works directly on the action configuration that the `ConfigurationFactory` holds,
2398
+ * so every edit is reflected in the factory's configuration.
2399
+ *
2400
+ */
2401
+ var ActionEditor = class {
2402
+ actionConfig;
2403
+ configurationFactory;
2404
+ constructor(actionConfig, configurationFactory) {
2405
+ this.actionConfig = actionConfig;
2406
+ this.configurationFactory = configurationFactory;
2407
+ }
2408
+ /**
2409
+ * Called by the `OperationEditor` after it has changed an operation.
2410
+ * Operations are edited in place, so there is nothing left to synchronize.
2411
+ */
2412
+ updateConfiguration() {}
2413
+ /**
2414
+ *
2415
+ * Passes a copy of the current action configuration to the given callback.
2416
+ * When the callback returns a configuration, it replaces the action configuration
2417
+ * in the factory.
2418
+ *
2419
+ * @param callBack
2420
+ * @returns
2421
+ */
2422
+ getConfiguration(callBack) {
2423
+ const copy = deepCopy(this.actionConfig);
2424
+ const newConfig = callBack.call(this, copy);
2425
+ if (newConfig) syncInPlace(this.actionConfig, deepCopy(newConfig));
2426
+ return this;
2427
+ }
2428
+ /**
2429
+ *
2430
+ * Sets the action name
2431
+ *
2432
+ * @param name
2433
+ * @returns
2434
+ * @throws Error when the action is in `actions` or `eventActions` and another
2435
+ * action in those lists already has the name
2436
+ */
2437
+ setName(name) {
2438
+ this.configurationFactory.assertUniqueActionName?.(name, this.actionConfig);
2439
+ this.actionConfig.name = name;
2440
+ return this;
2441
+ }
2442
+ /**
2443
+ *
2444
+ * Gets the action name
2445
+ *
2446
+ * @returns
2447
+ */
2448
+ getName() {
2449
+ return this.actionConfig.name;
2450
+ }
2451
+ /**
2452
+ *
2453
+ * Adds the operation data for a start operation specified by the given type
2454
+ *
2455
+ * @param operationClass
2456
+ * @param operationData
2457
+ * @returns
2458
+ * @throws Error when the function is not an operation, or when the operation
2459
+ * implementations are not loaded (the DOM-free `eligius/configuration-api` entry)
2460
+ */
2461
+ addStartOperationByType(operationClass, operationData) {
2462
+ return this.addStartOperation(getOperationNameByType(operationClass, "addStartOperationByType", "addStartOperation"), operationData);
2463
+ }
2464
+ /**
2465
+ *
2466
+ * Adds the operation data for a start operation specified by the given system name.
2467
+ * The operation data is copied, so later changes to the given object do not
2468
+ * affect the configuration.
2469
+ *
2470
+ * @param systemName a built-in operation name, or a name from the factory's
2471
+ * `customOperations` option
2472
+ * @param operationData
2473
+ * @param id
2474
+ * @returns
2475
+ * @throws Error when `systemName` is neither a built-in nor a declared custom operation
2476
+ */
2477
+ addStartOperation(systemName, operationData, id = v4()) {
2478
+ assertKnownOperationName(systemName, this.getCustomOperationNames());
2479
+ const startOperations = this.actionConfig.startOperations ? this.actionConfig.startOperations.slice() : [];
2480
+ const newConfig = {
2481
+ id,
2482
+ systemName,
2483
+ operationData: deepCopy(operationData)
2484
+ };
2485
+ startOperations.push(newConfig);
2486
+ this.actionConfig.startOperations = startOperations;
2487
+ return new OperationEditor(newConfig, this);
2488
+ }
2489
+ /**
2490
+ *
2491
+ * Starts an editor for the start operation associated with the given id
2492
+ *
2493
+ * @param id
2494
+ * @returns
2495
+ */
2496
+ editStartOperation(id) {
2497
+ const { startOperations } = this.actionConfig;
2498
+ const operation = startOperations.find((o) => o.id === id);
2499
+ if (isDefined(operation)) return new OperationEditor(operation, this);
2500
+ throw new Error(`start operation not found for id ${id}`);
2501
+ }
2502
+ /**
2503
+ *
2504
+ * Removes the start operation associated with the given id
2505
+ *
2506
+ * @param id
2507
+ * @returns
2508
+ */
2509
+ removeStartOperation(id) {
2510
+ const startOperations = this.actionConfig.startOperations ? this.actionConfig.startOperations.slice() : [];
2511
+ const operation = startOperations.find((o) => o.id === id);
2512
+ if (!operation) throw new Error(`start operation not found for id ${id}`);
2513
+ const idx = startOperations.indexOf(operation);
2514
+ if (idx > -1) {
2515
+ startOperations.splice(idx, 1);
2516
+ this.actionConfig.startOperations = startOperations;
2517
+ }
2518
+ return this;
2519
+ }
2520
+ /**
2521
+ *
2522
+ * Moves the start operation associated with the given id in the given direction
2523
+ *
2524
+ * @param id
2525
+ * @param direction
2526
+ * @returns
2527
+ */
2528
+ moveStartOperation(id, direction) {
2529
+ const startOperations = this.actionConfig.startOperations ? this.actionConfig.startOperations.slice() : [];
2530
+ const operation = startOperations.find((o) => o.id === id);
2531
+ if (!operation) throw new Error(`start operation not found for id ${id}`);
2532
+ const idx = startOperations.indexOf(operation);
2533
+ if (idx > -1) {
2534
+ array_move(startOperations, idx, direction === "up" ? idx + 1 : idx - 1);
2535
+ this.actionConfig.startOperations = startOperations;
2536
+ }
2537
+ return this;
2538
+ }
2539
+ /**
2540
+ *
2541
+ * Return the fluent scopt to the `ConfigurationFactory`
2542
+ *
2543
+ * @returns
2544
+ */
2545
+ next() {
2546
+ return this.configurationFactory;
2547
+ }
2548
+ /**
2549
+ * Returns the custom operation names that the `ConfigurationFactory` accepts
2550
+ * besides the built-in operations (its `customOperations` option).
2551
+ *
2552
+ * @returns the custom operation names, or `undefined` when the editor has no factory
2553
+ */
2554
+ getCustomOperationNames() {
2555
+ return this.configurationFactory?.customOperationNames;
2556
+ }
2557
+ };
2558
+ /**
2559
+ *
2560
+ * A factory that assists in editing an endable action
2561
+ *
2562
+ */
2563
+ var EndableActionEditor = class extends ActionEditor {
2564
+ /**
2565
+ *
2566
+ * Adds the operation data for a end operation specified by the given type
2567
+ *
2568
+ * @param operationClass
2569
+ * @param operationData
2570
+ * @returns
2571
+ * @throws Error when the function is not an operation, or when the operation
2572
+ * implementations are not loaded (the DOM-free `eligius/configuration-api` entry)
2573
+ */
2574
+ addEndOperationByType(operationClass, operationData) {
2575
+ return this.addEndOperation(getOperationNameByType(operationClass, "addEndOperationByType", "addEndOperation"), operationData);
2576
+ }
2577
+ /**
2578
+ *
2579
+ * Adds the operation data for an end operation specified by the given system name.
2580
+ * The operation data is copied, so later changes to the given object do not
2581
+ * affect the configuration.
2582
+ *
2583
+ * @param systemName a built-in operation name, or a name from the factory's
2584
+ * `customOperations` option
2585
+ * @param operationData
2586
+ * @returns
2587
+ * @throws Error when `systemName` is neither a built-in nor a declared custom operation
2588
+ */
2589
+ addEndOperation(systemName, operationData) {
2590
+ assertKnownOperationName(systemName, this.getCustomOperationNames());
2591
+ const endOperations = this.actionConfig.endOperations ? this.actionConfig.endOperations.slice() : [];
2592
+ const newConfig = {
2593
+ id: v4(),
2594
+ systemName,
2595
+ operationData: deepCopy(operationData)
2596
+ };
2597
+ endOperations.push(newConfig);
2598
+ this.actionConfig.endOperations = endOperations;
2599
+ return new OperationEditor(newConfig, this);
2600
+ }
2601
+ /**
2602
+ *
2603
+ * Starts an editor for the end operation associated with the given id
2604
+ *
2605
+ * @param id
2606
+ * @returns
2607
+ */
2608
+ editEndOperation(id) {
2609
+ const { endOperations } = this.actionConfig;
2610
+ const operationConfig = endOperations.find((o) => o.id === id);
2611
+ if (isDefined(operationConfig)) return new OperationEditor(operationConfig, this);
2612
+ throw new Error(`operation not found for id ${id}`);
2613
+ }
2614
+ /**
2615
+ *
2616
+ * Removes the end operation associated with the given id
2617
+ *
2618
+ * @param id
2619
+ * @returns
2620
+ */
2621
+ removeEndOperation(id) {
2622
+ const endOperations = this.actionConfig.endOperations ? this.actionConfig.endOperations.slice() : [];
2623
+ const operation = endOperations.find((o) => o.id === id);
2624
+ if (!isDefined(operation)) throw new Error(`operation not found for id ${id}`);
2625
+ const idx = endOperations.indexOf(operation);
2626
+ if (idx > -1) {
2627
+ endOperations.splice(idx, 1);
2628
+ this.actionConfig.endOperations = endOperations;
2629
+ }
2630
+ return this;
2631
+ }
2632
+ /**
2633
+ *
2634
+ * Moves the end operation associated with the given id in the specified direction
2635
+ *
2636
+ * @param id
2637
+ * @param direction
2638
+ * @returns
2639
+ */
2640
+ moveEndOperation(id, direction) {
2641
+ const endOperations = this.actionConfig.endOperations ? this.actionConfig.endOperations.slice() : [];
2642
+ const operation = endOperations.find((o) => o.id === id);
2643
+ if (!isDefined(operation)) throw new Error(`operation not found for id ${id}`);
2644
+ const idx = endOperations.indexOf(operation);
2645
+ if (idx > -1) {
2646
+ array_move(endOperations, idx, direction === "up" ? idx + 1 : idx - 1);
2647
+ this.actionConfig.endOperations = endOperations;
2648
+ }
2649
+ return this;
2650
+ }
2651
+ };
2652
+ /**
2653
+ *
2654
+ * A factory that assists in editing a timeline action
2655
+ *
2656
+ */
2657
+ var TimelineActionEditor = class extends EndableActionEditor {
2658
+ /**
2659
+ *
2660
+ * Sets the duration specified by the given start and optional end positions
2661
+ *
2662
+ * @param start
2663
+ * @param end
2664
+ * @returns
2665
+ */
2666
+ setDuration(start, end) {
2667
+ if (end !== void 0 && start > end) throw Error("start position cannot be higher than end position");
2668
+ const duration = { start };
2669
+ if (end !== void 0) duration.end = end;
2670
+ this.actionConfig.duration = duration;
2671
+ return this;
2672
+ }
2673
+ };
2674
+ /**
2675
+ *
2676
+ * A factory that assists in editing an operation
2677
+ *
2678
+ */
2679
+ var OperationEditor = class {
2680
+ operationConfig;
2681
+ actionEditor;
2682
+ constructor(operationConfig, actionEditor) {
2683
+ this.operationConfig = operationConfig;
2684
+ this.actionEditor = actionEditor;
2685
+ }
2686
+ /**
2687
+ *
2688
+ * Invokes the given callback with a copy of the internal state of the factory
2689
+ *
2690
+ * @param callBack
2691
+ * @returns
2692
+ */
2693
+ getConfiguration(callBack) {
2694
+ const copy = deepCopy(this.operationConfig);
2695
+ const newConfig = callBack.call(this, copy);
2696
+ if (newConfig) syncInPlace(this.operationConfig, deepCopy(newConfig));
2697
+ return this;
2698
+ }
2699
+ /**
2700
+ *
2701
+ * Gets the system name
2702
+ *
2703
+ * @returns
2704
+ */
2705
+ getSystemName() {
2706
+ return this.operationConfig.systemName;
2707
+ }
2708
+ /**
2709
+ *
2710
+ * Sets the system name
2711
+ *
2712
+ * @param systemName a built-in operation name, or a name from the factory's
2713
+ * `customOperations` option
2714
+ * @returns
2715
+ * @throws Error when `systemName` is neither a built-in nor a declared custom operation
2716
+ */
2717
+ setSystemName(systemName) {
2718
+ assertKnownOperationName(systemName, this.actionEditor.getCustomOperationNames?.());
2719
+ this.operationConfig.systemName = systemName;
2720
+ this.actionEditor.updateConfiguration();
2721
+ return this;
2722
+ }
2723
+ /**
2724
+ *
2725
+ * Sets the operation data. The operation data is copied, so later changes to
2726
+ * the given object do not affect the configuration.
2727
+ *
2728
+ * @param operationData
2729
+ * @returns
2730
+ */
2731
+ setOperationData(operationData) {
2732
+ this.operationConfig.operationData = deepCopy(operationData);
2733
+ this.actionEditor.updateConfiguration();
2734
+ return this;
2735
+ }
2736
+ /**
2737
+ *
2738
+ * Sets the value on the current `operationData` with the given key
2739
+ *
2740
+ * @param key
2741
+ * @param value
2742
+ * @returns
2743
+ */
2744
+ setOperationDataItem(key, value) {
2745
+ return this.setOperationData({
2746
+ ...this.operationConfig.operationData ?? {},
2747
+ [key]: value
2748
+ });
2749
+ }
2750
+ /**
2751
+ *
2752
+ * returns all of the defined property names on the current `operationData`
2753
+ *
2754
+ * @returns
2755
+ */
2756
+ getOperationDataKeys() {
2757
+ const { operationData } = this.operationConfig;
2758
+ return operationData ? Object.keys(operationData) : [];
2759
+ }
2760
+ /**
2761
+ *
2762
+ * Gets the value of the given key on the current `operationData`
2763
+ *
2764
+ * @param key
2765
+ * @returns
2766
+ */
2767
+ getOperationDataValue(key) {
2768
+ const { operationData } = this.operationConfig;
2769
+ return operationData?.[key];
2770
+ }
2771
+ /**
2772
+ *
2773
+ * Returns the fluent scope back to the action editor
2774
+ *
2775
+ * @returns
2776
+ */
2777
+ next() {
2778
+ return this.actionEditor;
2779
+ }
2780
+ };
2781
+
2782
+ //#endregion
2783
+ //#region src/configuration/api/timeline-provider-settings-editor.ts
2784
+ /**
2785
+ * Default position source system names for convenience methods.
2786
+ */
2787
+ const DEFAULT_POSITION_SOURCES = {
2788
+ raf: "RafPositionSource",
2789
+ scroll: "ScrollPositionSource",
2790
+ video: "VideoPositionSource"
2791
+ };
2792
+ /**
2793
+ * Default container provider system name.
2794
+ */
2795
+ const DEFAULT_CONTAINER_PROVIDER = "DomContainerProvider";
2796
+ /**
2797
+ * Default playlist system name.
2798
+ */
2799
+ const DEFAULT_PLAYLIST = "SimplePlaylist";
2800
+ var TimelineProvidersSettingsEditor = class {
2801
+ providersSettings;
2802
+ configurationFactory;
2803
+ constructor(providersSettings, configurationFactory) {
2804
+ this.providersSettings = providersSettings;
2805
+ this.configurationFactory = configurationFactory;
2806
+ }
2807
+ /**
2808
+ * Adds a new provider for the specified timeline type.
2809
+ *
2810
+ * @param timelineType - The timeline type (e.g., 'animation', 'mediaplayer')
2811
+ * @param positionSourceSystemName - System name of the position source class (default: 'RafPositionSource')
2812
+ * @returns A TimelineProviderSettingsEditor for further configuration
2813
+ */
2814
+ addProvider(timelineType, positionSourceSystemName = "RafPositionSource") {
2815
+ if (this.providersSettings[timelineType]) throw new Error(`Settings for a '${timelineType}' provider already exist`);
2816
+ const settings = { positionSource: { systemName: positionSourceSystemName } };
2817
+ this.providersSettings[timelineType] = settings;
2818
+ return new TimelineProviderSettingsEditor(settings, this, this.configurationFactory);
2819
+ }
2820
+ editProvider(timelineType) {
2821
+ if (!this.providersSettings[timelineType]) throw new Error(`No settings for a '${timelineType}' provider exist yet`);
2822
+ return new TimelineProviderSettingsEditor(this.providersSettings[timelineType], this, this.configurationFactory);
2823
+ }
2824
+ next() {
2825
+ return this.configurationFactory;
2826
+ }
2827
+ };
2828
+ var TimelineProviderSettingsEditor = class {
2829
+ providerSettings;
2830
+ providersSettingsEditor;
2831
+ configurationFactory;
2832
+ constructor(providerSettings, providersSettingsEditor, configurationFactory) {
2833
+ this.providerSettings = providerSettings;
2834
+ this.providersSettingsEditor = providersSettingsEditor;
2835
+ this.configurationFactory = configurationFactory;
2836
+ }
2837
+ /**
2838
+ * Sets the position source configuration with full config object.
2839
+ * @param config - Position source configuration with systemName and options
2840
+ */
2841
+ setPositionSource(config) {
2842
+ this.providerSettings.positionSource = config;
2843
+ return this;
2844
+ }
2845
+ /**
2846
+ * Sets the position source by system name with optional configuration.
2847
+ * @param systemName - The position source class name (e.g., 'RafPositionSource')
2848
+ * @param options - Additional options passed to the position source constructor
2849
+ */
2850
+ setPositionSourceByName(systemName, options) {
2851
+ this.providerSettings.positionSource = {
2852
+ systemName,
2853
+ ...options
2854
+ };
2855
+ return this;
2856
+ }
2857
+ /**
2858
+ * Convenience method to set position source using shorthand type names.
2859
+ * @param type - Shorthand type ('raf', 'scroll', 'video')
2860
+ * @param options - Type-specific options (`sources` and `poster` for video)
2861
+ * @deprecated Use setPositionSourceByName for explicit control
2862
+ */
2863
+ setPositionSourceType(type, options) {
2864
+ const systemName = DEFAULT_POSITION_SOURCES[type];
2865
+ if (!systemName) throw new Error(`Unknown position source type: ${type}`);
2866
+ this.providerSettings.positionSource = {
2867
+ systemName,
2868
+ ...options
2869
+ };
2870
+ return this;
2871
+ }
2872
+ /**
2873
+ * Sets the container provider configuration by selector.
2874
+ * Uses DomContainerProvider by default.
2875
+ * @param selector - CSS selector for the container element
2876
+ */
2877
+ setContainer(selector) {
2878
+ this.providerSettings.container = {
2879
+ systemName: DEFAULT_CONTAINER_PROVIDER,
2880
+ selector
2881
+ };
2882
+ return this;
2883
+ }
2884
+ /**
2885
+ * Sets the container provider configuration with full config object.
2886
+ * @param config - Container provider configuration with systemName
2887
+ */
2888
+ setContainerConfig(config) {
2889
+ this.providerSettings.container = config;
2890
+ return this;
2891
+ }
2892
+ /**
2893
+ * Sets the container provider by system name with options.
2894
+ * @param systemName - The container provider class name
2895
+ * @param options - Additional options passed to the container provider constructor
2896
+ */
2897
+ setContainerByName(systemName, options) {
2898
+ this.providerSettings.container = {
2899
+ systemName,
2900
+ ...options
2901
+ };
2902
+ return this;
2903
+ }
2904
+ /**
2905
+ * Sets the playlist configuration.
2906
+ * Uses SimplePlaylist by default.
2907
+ * @param items - Array of playlist items
2908
+ * @param identifierKey - Key used to identify items (default: 'uri')
2909
+ */
2910
+ setPlaylist(items, identifierKey = "uri") {
2911
+ this.providerSettings.playlist = {
2912
+ systemName: DEFAULT_PLAYLIST,
2913
+ items,
2914
+ identifierKey
2915
+ };
2916
+ return this;
2917
+ }
2918
+ /**
2919
+ * Sets the playlist configuration with full config object.
2920
+ * @param config - Playlist configuration with systemName
2921
+ */
2922
+ setPlaylistConfig(config) {
2923
+ this.providerSettings.playlist = config;
2924
+ return this;
2925
+ }
2926
+ /**
2927
+ * Sets the playlist by system name with options.
2928
+ * @param systemName - The playlist class name
2929
+ * @param options - Additional options including items and identifierKey
2930
+ */
2931
+ setPlaylistByName(systemName, options) {
2932
+ this.providerSettings.playlist = {
2933
+ systemName,
2934
+ ...options
2935
+ };
2936
+ return this;
2937
+ }
2938
+ next() {
2939
+ return this.providersSettingsEditor;
2940
+ }
2941
+ end() {
2942
+ return this.configurationFactory;
2943
+ }
2944
+ };
2945
+
2946
+ //#endregion
2947
+ //#region src/util/merge-if-missing.ts
2948
+ /**
2949
+ *
2950
+ * Merges the properties of the target object into the source object, only the properties that do not exist yet on the source.
2951
+ *
2952
+ * This function is pure, so it returns a new instance that reflects the merging of the two objects.
2953
+ *
2954
+ * The merge is shallow.
2955
+ *
2956
+ * @param target
2957
+ * @param source
2958
+ * @returns
2959
+ */
2960
+ const mergeIfMissing = (target, source) => Object.entries(source).reduce((acc, [key, value]) => key in acc ? acc : {
2961
+ ...acc,
2962
+ [key]: value
2963
+ }, target);
2964
+
2965
+ //#endregion
2966
+ //#region src/configuration/api/configuration-factory.ts
2967
+ /**
2968
+ * Action names must be unique across these lists.
2969
+ */
2970
+ const UNIQUE_NAME_LISTS = ["actions", "eventActions"];
2971
+ function toCustomOperationNames(customOperations) {
2972
+ if (customOperations === void 0) return /* @__PURE__ */ new Set();
2973
+ if (!Array.isArray(customOperations)) throw new Error("ConfigurationFactory: options.customOperations must be an array of operation names.");
2974
+ for (const [index, name] of customOperations.entries()) if (typeof name !== "string" || !name.length) throw new Error(`ConfigurationFactory: options.customOperations[${index}] must be a non-empty string.`);
2975
+ return new Set(customOperations);
2976
+ }
2977
+ /**
2978
+ * This class offers a fluent, extensible and strongly typed DSL for creating Eligius configurations.
2979
+ *
2980
+ * @example Building a configuration using the factory
2981
+ * To initialize a basic configuration to start off of:
2982
+ * ```ts
2983
+ * const factory = new ConfigurationFactory()
2984
+ * .init("en-US") // Define the default language
2985
+ * .addLanguage("en-US", "English") // Add English as a supported language
2986
+ * .addLanguage("nl-NL", "Nederlands") // Add Dutch as a supported language
2987
+ * .setLayoutTemplate("<div class=\"main.container\"></div>") // Add the main container for the presentation
2988
+ * .setContainerSelector("#ct-container") // Selector for the element in the body that will contain the presentation
2989
+ * .addTimeline( // Add a first timeline
2990
+ * 'timeline-1', // Give it a name
2991
+ * "animation", // This is RAF based timeline
2992
+ * 200, // The duration of the timeline in seconds
2993
+ * false, // The presentation does NOT play in a loop
2994
+ * ".timeline-container" // The element within the main layout (defined by the layoutTemplate) in which the timeline will be rendered
2995
+ * )
2996
+ * .editTimelineProviderSettings() // Add a timeline provider
2997
+ * .addProvider("animation", "RafPositionSource") // Timelines of type 'animation' get their time from requestAnimationFrame
2998
+ * .setContainer(".timeline-container") // The element the timeline renders into
2999
+ * .end(); // This finally returns the ConfigurationFactory instance
3000
+ * ```
3001
+ *
3002
+ * Then to add an init action:
3003
+ * ```ts
3004
+ * factory
3005
+ * .createInitAction("GetUserName")
3006
+ * .addStartOperationByType(getQueryParams, {
3007
+ * defaultValues: { username: "guest" },
3008
+ * })
3009
+ * .addStartOperationByType(setGlobalData, { properties: ["queryParams"] });
3010
+ * ```
3011
+ *
3012
+ * After that, add a timeline action:
3013
+ * ```ts
3014
+ * factory.createTimelineAction("timeline-1", "AddIntroContainer")
3015
+ * .addDuration(0, 10)
3016
+ * .addStartOperationByType(selectElement, { selector: ".timeline-container" })
3017
+ * .addStartOperationByType(setElementContent, {
3018
+ * template: '<div class="intro-text"></div>',
3019
+ * })
3020
+ * .addEndOperationByType(selectElement, { selector: ".intro-text" })
3021
+ * .addEndOperationByType(removeElement, {});
3022
+ * ```
3023
+ *
3024
+ * It also possible to extend the factory with specialized creation methods for the particular
3025
+ * configuration you are building:
3026
+ * ```ts
3027
+ * function addImage(this: ConfigurationFactory, actionName: string, imageSrc: string, imageId: string) {
3028
+ * this.createInitAction(actionName)
3029
+ * .addStartOperationByType(selectElement, { selector: ".timeline-container" })
3030
+ * .addStartOperationByType(createElement, { elementName: 'img', attributes: {src: imageSrc, id: imageId} })
3031
+ * .addStartOperationByType(setElementContent, { insertionType: "append" })
3032
+ * .addEndOperationByType(selectElement, { selector: `#${imageId}` })
3033
+ * .addEndOperationByType(removeElement, {});
3034
+ * }
3035
+ *
3036
+ * const customFactory = ConfigurationFactory.extend(factory, "addImage", addImage);
3037
+ *
3038
+ * customFactory.addImage("MyImageActionName", "my-image.png", "my-image-id");
3039
+ * ```
3040
+ *
3041
+ * Finally, retrieve the configuration and save it:
3042
+ * ```ts
3043
+ * import fs from "node:fs";
3044
+ *
3045
+ * const configuration = customFactory.getConfiguration();
3046
+ *
3047
+ * fs.writeFileSync("/my/path/configuration.json", JSON.stringify(configuration), {encoding:'utf-8'})
3048
+ * ```
3049
+ *
3050
+ * In plain Node (build tools, code generators) import the factory from `eligius/configuration-api`.
3051
+ * That entry does not load jQuery or the other DOM dependencies. It supports every method except the
3052
+ * `...ByType` ones, which need the operation implementations; use the name based methods there:
3053
+ * ```ts
3054
+ * import {ConfigurationFactory} from 'eligius/configuration-api';
3055
+ *
3056
+ * factory.createAction('MyAction').addStartOperation('selectElement', {selector: '#app'});
3057
+ * ```
3058
+ *
3059
+ * The `ConfigurationFactory` can also be used to edit an existing configuration. In this case, simply
3060
+ * pass the JSON configuration to the `ConfigurationFactory`'s constructor:
3061
+ * ```ts
3062
+ * import myConfiguration from './my-configuration.json';
3063
+ *
3064
+ * const factory = new ConfigurationFactory(myConfiguration);
3065
+ *
3066
+ * factory.editInitAction("existingActionName")
3067
+ * .removeEndOperation("475fd0ab-5755-4e60-8f7c-e1988a109678");
3068
+ * ```
3069
+ */
3070
+ var ConfigurationFactory = class ConfigurationFactory {
3071
+ configuration;
3072
+ actionCreatorFactory;
3073
+ /**
3074
+ * The custom operation names this factory accepts besides the built-in
3075
+ * operations, from the `customOperations` option.
3076
+ */
3077
+ customOperationNames;
3078
+ /**
3079
+ * Constructs a new `ConfigurationFactory`
3080
+ * @param configuration an optional existing configuration that will be used as a starting point
3081
+ * @param options optional settings, see {@link IConfigurationFactoryOptions}
3082
+ * @throws Error when `options.customOperations` is not an array of non-empty strings
3083
+ *
3084
+ * @example Accepting a custom operation
3085
+ * ```ts
3086
+ * const factory = new ConfigurationFactory(undefined, {customOperations: ['trackEvent']});
3087
+ * factory.createAction('Track').addStartOperation('trackEvent', {category: 'intro'});
3088
+ * ```
3089
+ */
3090
+ constructor(configuration = {}, options = {}) {
3091
+ this.configuration = configuration;
3092
+ this.customOperationNames = toCustomOperationNames(options?.customOperations);
3093
+ this.actionCreatorFactory = new ActionCreatorFactory(this);
3094
+ }
3095
+ /**
3096
+ * Add specialized method to a factory
3097
+ *
3098
+ * @param factory
3099
+ * @param extensionMethodName
3100
+ * @param extensionMethod
3101
+ * @returns
3102
+ */
3103
+ static extend(factory, extensionMethodName, extensionMethod) {
3104
+ return Object.defineProperty(factory, extensionMethodName, {
3105
+ value: function(...args) {
3106
+ return extensionMethod.apply(this, args);
3107
+ },
3108
+ writable: true,
3109
+ configurable: true
3110
+ });
3111
+ }
3112
+ /**
3113
+ * Add specialized methods to a factory
3114
+ *
3115
+ * @param factory
3116
+ * @param extensions
3117
+ * @returns
3118
+ */
3119
+ static extendMultiple(factory, extensions) {
3120
+ return Object.entries(extensions).reduce((acc, [name, method]) => ConfigurationFactory.extend(acc, name, method), factory);
3121
+ }
3122
+ /**
3123
+ * Initialize the configuration with a minimal shape.
3124
+ *
3125
+ * It assigns an ID, sets the engine to `EligiusEngine`, default the containerSelector `[data-ct-container=true]`
3126
+ * and initializes all of the list properties with empty arrays.
3127
+ * @param defaultLanguage
3128
+ * @returns
3129
+ */
3130
+ init(defaultLanguage) {
3131
+ const newConfiguration = {
3132
+ id: v4(),
3133
+ engine: { systemName: "EligiusEngine" },
3134
+ containerSelector: "[data-ct-container=true]",
3135
+ cssFiles: [],
3136
+ timelineProviderSettings: {},
3137
+ language: defaultLanguage,
3138
+ availableLanguages: [],
3139
+ layoutTemplate: "",
3140
+ initActions: [],
3141
+ actions: [],
3142
+ timelines: []
3143
+ };
3144
+ this.configuration = mergeIfMissing(this.configuration, newConfiguration);
3145
+ return this;
3146
+ }
3147
+ /**
3148
+ * Assigns the engine system name
3149
+ * @param systemName
3150
+ * @returns
3151
+ */
3152
+ setEngine(systemName) {
3153
+ this.configuration.engine.systemName = systemName;
3154
+ return this;
3155
+ }
3156
+ /**
3157
+ * Assigns a string representation of the HTML layout template for the engine.
3158
+ *
3159
+ * @param layoutTemplate
3160
+ * @returns
3161
+ */
3162
+ setLayoutTemplate(layoutTemplate) {
3163
+ this.configuration.layoutTemplate = layoutTemplate;
3164
+ return this;
3165
+ }
3166
+ /**
3167
+ *
3168
+ * Assigns the default language
3169
+ *
3170
+ * @param defaultLanguage
3171
+ * @returns
3172
+ */
3173
+ setDefaultLanguage(defaultLanguage) {
3174
+ this.configuration.language = defaultLanguage;
3175
+ return this;
3176
+ }
3177
+ /**
3178
+ *
3179
+ * Assign the css selector that specifies the DOM location where the engine renders its output
3180
+ *
3181
+ * @param selector
3182
+ * @returns
3183
+ */
3184
+ setContainerSelector(selector) {
3185
+ this.configuration.containerSelector = selector;
3186
+ return this;
3187
+ }
3188
+ /**
3189
+ *
3190
+ * Starts an editing process for the timeline provider settings.
3191
+ *
3192
+ * @returns
3193
+ */
3194
+ editTimelineProviderSettings() {
3195
+ this.configuration.timelineProviderSettings ??= {};
3196
+ return new TimelineProvidersSettingsEditor(this.configuration.timelineProviderSettings, this);
3197
+ }
3198
+ /**
3199
+ *
3200
+ * Return a copy of the current state of the configuration
3201
+ *
3202
+ * @param callBack the callback receives a copy of the configuration and can return a changed version. The changes are applied to the factory's configuration in place, so editors that are still open keep working.
3203
+ * @returns
3204
+ */
3205
+ getConfiguration(callBack) {
3206
+ const copy = deepCopy(this.configuration);
3207
+ if (callBack) {
3208
+ const newConfig = callBack.call(this, copy);
3209
+ syncInPlace(this.configuration, deepCopy(newConfig));
3210
+ }
3211
+ return copy;
3212
+ }
3213
+ /**
3214
+ *
3215
+ * Adds a language to the `availableLanguages` list.
3216
+ * The label represents the name of the language.
3217
+ *
3218
+ * An error is thrown if a language with the given language code already exists
3219
+ *
3220
+ * @example
3221
+ * factory.addLanguage('en-GB', 'English');
3222
+ *
3223
+ * @param languageCode The given alnguage code
3224
+ * @param languageLabel The human readable name of the language
3225
+ * @returns
3226
+ */
3227
+ addLanguage(languageCode, languageLabel) {
3228
+ const languages = this._initializeCollection(this.configuration, "availableLanguages");
3229
+ if (languages.find((lang) => lang.languageCode === languageCode)) throw new Error(`Language code '${languageCode}' already exists`);
3230
+ languages.push({
3231
+ id: v4(),
3232
+ languageCode,
3233
+ label: languageLabel
3234
+ });
3235
+ return this;
3236
+ }
3237
+ _internalAddAction(collectionName, action) {
3238
+ if (UNIQUE_NAME_LISTS.includes(collectionName)) this._assertActionNameFree(action.name, action);
3239
+ this._initializeCollection(this.configuration, collectionName)?.push(action);
3240
+ }
3241
+ /**
3242
+ * Throws when the given action is in `actions` or `eventActions` and another
3243
+ * action in those lists already has the given name. Action names must be
3244
+ * unique across those two lists, the rule the `ConfigurationResolver`
3245
+ * enforces, so the fluent API reports a duplicate where it is made instead of
3246
+ * when the engine is created. Init actions and timeline actions are not
3247
+ * checked.
3248
+ *
3249
+ * Called by the action creators and editors before they rename an action.
3250
+ *
3251
+ * @param name the new action name
3252
+ * @param action the action that gets the name
3253
+ * @throws Error when the name is already taken
3254
+ */
3255
+ assertUniqueActionName(name, action) {
3256
+ if (UNIQUE_NAME_LISTS.some((listName) => this.configuration[listName]?.includes(action))) this._assertActionNameFree(name, action);
3257
+ }
3258
+ _assertActionNameFree(name, action) {
3259
+ if (!name) return;
3260
+ if (UNIQUE_NAME_LISTS.some((listName) => this.configuration[listName]?.some((other) => other !== action && other.name === name))) throw new Error(`Action name '${name}' already exists in actions or eventActions. Action names must be unique across actions and eventActions.`);
3261
+ }
3262
+ _initializeCollection(parent, name) {
3263
+ if (!parent[name]) parent[name] = [];
3264
+ return parent[name];
3265
+ }
3266
+ /**
3267
+ *
3268
+ * Adds the specified action to the `actions` list.
3269
+ *
3270
+ * @param action
3271
+ */
3272
+ addAction(action) {
3273
+ this._internalAddAction("actions", action);
3274
+ }
3275
+ /**
3276
+ *
3277
+ * Adds the specified action to the `initActions` list
3278
+ *
3279
+ * @param action
3280
+ */
3281
+ addInitAction(action) {
3282
+ this._internalAddAction("initActions", action);
3283
+ }
3284
+ /**
3285
+ *
3286
+ * Adds the specified action to the `eventActions` list
3287
+ *
3288
+ * @param action
3289
+ */
3290
+ addEventAction(action) {
3291
+ this._internalAddAction("eventActions", action);
3292
+ }
3293
+ /**
3294
+ *
3295
+ * Adds the given actions to `timelineActions` list that is associated with the specified uri
3296
+ *
3297
+ * @param uri
3298
+ * @param action
3299
+ */
3300
+ addTimelineAction(uri, action) {
3301
+ const timeline = this.getTimeline(uri);
3302
+ if (timeline) this._initializeCollection(timeline, "timelineActions").push(action);
3303
+ else throw Error(`No timeline found for uri '${uri}'`);
3304
+ }
3305
+ /**
3306
+ *
3307
+ * Starts the creation of a new action with the specified name that gets added to the `actions` list
3308
+ *
3309
+ * @param name
3310
+ * @returns
3311
+ */
3312
+ createAction(name) {
3313
+ return this.actionCreatorFactory.createAction(name);
3314
+ }
3315
+ /**
3316
+ *
3317
+ * Starts the creation of a new action with the specified name that gets added to the `initActions` list
3318
+ *
3319
+ * @param name
3320
+ * @returns
3321
+ */
3322
+ createInitAction(name) {
3323
+ return this.actionCreatorFactory.createInitAction(name);
3324
+ }
3325
+ /**
3326
+ *
3327
+ * Starts the creation of a new action with the specified name that gets added to the `eventActions` list
3328
+ *
3329
+ * @param name
3330
+ * @param eventName the event that starts the action. Without it the action can
3331
+ * only be started by name (for example by a `DOMEventListenerController`).
3332
+ * @param eventTopic optional topic of the event
3333
+ * @returns
3334
+ *
3335
+ * @example
3336
+ * ```ts
3337
+ * factory
3338
+ * .createEventAction('OnLanguageChange', 'language-change')
3339
+ * .addStartOperation('log', {});
3340
+ * ```
3341
+ */
3342
+ createEventAction(name, eventName, eventTopic) {
3343
+ return this.actionCreatorFactory.createEventAction(name, eventName, eventTopic);
3344
+ }
3345
+ /**
3346
+ *
3347
+ * Starts the creation of a new action with the specified name that gets added to the `timelineActions` list that is associated with the specified uri
3348
+ *
3349
+ * @param uri
3350
+ * @param name
3351
+ * @returns
3352
+ */
3353
+ createTimelineAction(uri, name) {
3354
+ return this.actionCreatorFactory.createTimelineAction(uri, name);
3355
+ }
3356
+ /**
3357
+ * Add a timeline with the given data
3358
+ *
3359
+ * @param uri identifier for the timeline
3360
+ * @param type animation or mediaplayer
3361
+ * @param duration the duration of the timeline in seconds
3362
+ * @param isLooped True if the timeline should automatically restart at the end
3363
+ * @param selector css selector for the container where the timeline will be rendered
3364
+ * @returns
3365
+ */
3366
+ addTimeline(uri, type, duration, isLooped, selector) {
3367
+ const timelines = this._initializeCollection(this.configuration, "timelines");
3368
+ if (this.getTimeline(uri)) throw Error(`timeline for uri ${uri} already exists`);
3369
+ const timelineConfig = {
3370
+ id: v4(),
3371
+ type,
3372
+ uri,
3373
+ duration,
3374
+ loop: isLooped,
3375
+ selector,
3376
+ timelineActions: []
3377
+ };
3378
+ timelines.push(timelineConfig);
3379
+ return this;
3380
+ }
3381
+ /**
3382
+ * Gives the timeline its own position source settings, merged over the
3383
+ * settings of its type in `timelineProviderSettings` (see
3384
+ * `ITimelineConfiguration.positionSource`).
3385
+ *
3386
+ * @param uri - URI of the timeline
3387
+ * @param positionSource - The override. Leave out `systemName` to change
3388
+ * single settings of the type's position source, or name another class to
3389
+ * replace it for this timeline. `undefined` removes the override.
3390
+ * @returns The factory
3391
+ * @throws Error when no timeline has the URI
3392
+ *
3393
+ * @example
3394
+ * ```ts
3395
+ * factory
3396
+ * .addTimeline('intro', 'animation', 10, false, '#intro')
3397
+ * .addTimeline('chapter-1', 'animation', 60, false, '#chapter-1')
3398
+ * .setTimelinePositionSource('chapter-1', {
3399
+ * systemName: 'ScrollPositionSource',
3400
+ * selector: '#chapter-1',
3401
+ * });
3402
+ * ```
3403
+ */
3404
+ setTimelinePositionSource(uri, positionSource) {
3405
+ const timeline = this._requireTimeline(uri, "setTimelinePositionSource");
3406
+ if (positionSource === void 0) delete timeline.positionSource;
3407
+ else timeline.positionSource = deepCopy(positionSource);
3408
+ return this;
3409
+ }
3410
+ /**
3411
+ * Gives the timeline its own container provider settings, merged over the
3412
+ * `container` settings of its type in `timelineProviderSettings` (see
3413
+ * `ITimelineConfiguration.containerProvider`).
3414
+ *
3415
+ * @param uri - URI of the timeline
3416
+ * @param containerProvider - The override, for example
3417
+ * `{selector: '#chapter-1'}`. `undefined` removes the override.
3418
+ * @returns The factory
3419
+ * @throws Error when no timeline has the URI
3420
+ */
3421
+ setTimelineContainerProvider(uri, containerProvider) {
3422
+ const timeline = this._requireTimeline(uri, "setTimelineContainerProvider");
3423
+ if (containerProvider === void 0) delete timeline.containerProvider;
3424
+ else timeline.containerProvider = deepCopy(containerProvider);
3425
+ return this;
3426
+ }
3427
+ _requireTimeline(uri, methodName) {
3428
+ const timeline = this.configuration.timelines ? this.getTimeline(uri) : void 0;
3429
+ if (!timeline) throw new Error(`ConfigurationFactory.${methodName}: no timeline found for uri '${uri}'`);
3430
+ return timeline;
3431
+ }
3432
+ /**
3433
+ *
3434
+ * Gets the timeline associated with the specified uri
3435
+ *
3436
+ * @param uri
3437
+ * @returns
3438
+ */
3439
+ getTimeline(uri) {
3440
+ return this.configuration.timelines.find((t) => t.uri === uri);
3441
+ }
3442
+ /**
3443
+ *
3444
+ * Removes the timeline associated with the specified uri
3445
+ *
3446
+ * @param uri
3447
+ * @returns
3448
+ */
3449
+ removeTimeline(uri) {
3450
+ const timelineConfig = this.getTimeline(uri);
3451
+ if (timelineConfig) {
3452
+ const idx = this.configuration.timelines.indexOf(timelineConfig);
3453
+ if (idx > -1) this.configuration.timelines.splice(idx, 1);
3454
+ }
3455
+ return this;
3456
+ }
3457
+ /**
3458
+ *
3459
+ * Starts an editor for the action from the `actions` list associated with the given id
3460
+ *
3461
+ * @param id
3462
+ * @returns
3463
+ */
3464
+ editAction(id) {
3465
+ const actionConfig = this.configuration.actions.find((a) => a.id === id);
3466
+ if (actionConfig) return new EndableActionEditor(actionConfig, this);
3467
+ throw new Error(`Action not found for id ${id}`);
3468
+ }
3469
+ /**
3470
+ *
3471
+ * Starts an editor for the action from the `eventActions` list associated with the given id
3472
+ *
3473
+ * @param id
3474
+ * @returns
3475
+ */
3476
+ editEventAction(id) {
3477
+ const actionConfig = this.configuration.eventActions?.find((a) => a.id === id);
3478
+ if (actionConfig) return new ActionEditor(actionConfig, this);
3479
+ throw new Error(`Event action not found for id ${id}`);
3480
+ }
3481
+ /**
3482
+ *
3483
+ * Starts an editor for the action from the `initActions` list associated with the given id
3484
+ *
3485
+ * @param id
3486
+ * @returns
3487
+ */
3488
+ editInitAction(id) {
3489
+ const actionConfig = this.configuration.initActions.find((a) => a.id === id);
3490
+ if (actionConfig) return new EndableActionEditor(actionConfig, this);
3491
+ throw new Error(`Init action not found for id ${id}`);
3492
+ }
3493
+ /**
3494
+ *
3495
+ * Starts an editor for the action from the `timelineActions` list associated with the given uri and id
3496
+ *
3497
+ * @param uri
3498
+ * @param id
3499
+ * @returns
3500
+ */
3501
+ editTimelineAction(uri, id) {
3502
+ const timeline = this.getTimeline(uri);
3503
+ if (!timeline) throw new Error(`No timeline found for uri '${uri}'`);
3504
+ const actionConfig = timeline.timelineActions.find((a) => a.id === id);
3505
+ if (actionConfig) return new TimelineActionEditor(actionConfig, this);
3506
+ throw new Error(`Timeline action not found for id '${id}' in timeline '${uri}'`);
3507
+ }
3508
+ };
3509
+
3510
+ //#endregion
3511
+ //#region src/controllers/metadata/dom-event-listener-controller.ts
3512
+ function DOMEventListenerController() {
3513
+ return {
3514
+ description: `This controller attaches to the given selected element and adds a DOM event listener for the specified event name that
3515
+ executes the given actions with the given operation data.
3516
+
3517
+ By default the \`start\` operations of the specified actions are executed. To execute the \`end\` operations instead,
3518
+ prefix the action name with \`end:\`.
3519
+
3520
+ The actions run in order, each receiving the operation data the previous one returned. When an action fails, the
3521
+ remaining actions are skipped and the failure is reported through the eventbus's \`reportError\` (an error naming
3522
+ this controller, the action and the DOM event, with the original error as \`cause\`), or logged with
3523
+ \`console.error\` when the eventbus has no \`reportError\`.`,
3524
+ dependentProperties: ["selectedElement"],
3525
+ properties: {
3526
+ eventName: {
3527
+ type: "ParameterType:eventName",
3528
+ required: true
3529
+ },
3530
+ actions: {
3531
+ type: "ParameterType:array",
3532
+ itemType: "ParameterType:string"
3533
+ },
3534
+ actionOperationData: { type: "ParameterType:object" }
3535
+ }
3536
+ };
3537
+ }
3538
+
3539
+ //#endregion
3540
+ //#region src/controllers/metadata/label-controller.ts
3541
+ function LabelController() {
3542
+ return {
3543
+ description: `This controller attaches to the given selected element and renders the text
3544
+ associated with the given translation key.
3545
+
3546
+ Translations may contain simple inline markup. They are passed through
3547
+ \`sanitizeHtml\` before insertion, so \`<br>\`, \`<strong>\`, \`<em>\`,
3548
+ \`<span>\` and http(s)/mailto/relative links render, while scripts, event
3549
+ handlers, \`javascript:\` URLs, images, iframes and SVG are removed.
3550
+
3551
+ The controller listens for the \`language-change\` event and re-renders the text
3552
+ with the new language after such an event.
3553
+
3554
+ Uses the rosetta-based locale system via \`request-translation\` event.`,
3555
+ dependentProperties: ["selectedElement"],
3556
+ properties: {
3557
+ translationKey: {
3558
+ type: "ParameterType:string",
3559
+ required: true
3560
+ },
3561
+ attributeName: { type: "ParameterType:string" }
3562
+ }
3563
+ };
3564
+ }
3565
+
3566
+ //#endregion
3567
+ //#region src/controllers/metadata/lottie-controller.ts
3568
+ function LottieController() {
3569
+ return {
3570
+ description: `This controller renders a [lottie-web](https://github.com/airbnb/lottie-web) animation inside the given selected element.
3571
+
3572
+ The url may encode freeze and end positions like this: my-url/filename[freeze=10,end=21].json
3573
+
3574
+ lottie-web is an optional peer dependency. It is loaded with a dynamic
3575
+ \`import()\` the first time a LottieController attaches, so applications that
3576
+ never use this controller do not need it installed.`,
3577
+ properties: { url: { type: "ParameterType:url" } }
3578
+ };
3579
+ }
3580
+
3581
+ //#endregion
3582
+ //#region src/controllers/metadata/mutation-observer-controller.ts
3583
+ function MutationObserverController() {
3584
+ return {
3585
+ description: `Controller that observes DOM mutations on a selected element and broadcasts events.
3586
+
3587
+ This controller creates a MutationObserver to monitor DOM changes (attributes, child nodes,
3588
+ text content) on a specified element. All detected mutations are broadcasted through the
3589
+ Eligius eventbus, enabling reactive behavior in response to DOM changes.
3590
+
3591
+ The controller follows the standard Eligius lifecycle:
3592
+ - init(): Store configuration metadata
3593
+ - attach(): Create and start the MutationObserver
3594
+ - detach(): Disconnect the observer and clean up resources`,
3595
+ dependentProperties: ["selectedElement"],
3596
+ properties: {
3597
+ observeAttributes: { type: "ParameterType:boolean" },
3598
+ observeChildList: { type: "ParameterType:boolean" },
3599
+ observeCharacterData: { type: "ParameterType:boolean" },
3600
+ observeSubtree: { type: "ParameterType:boolean" },
3601
+ attributeOldValue: { type: "ParameterType:boolean" },
3602
+ characterDataOldValue: { type: "ParameterType:boolean" },
3603
+ attributeFilter: {
3604
+ type: "ParameterType:array",
3605
+ itemType: "ParameterType:string"
3606
+ }
3607
+ }
3608
+ };
3609
+ }
3610
+
3611
+ //#endregion
3612
+ //#region src/controllers/metadata/navigation-controller.ts
3613
+ function NavigationController() {
3614
+ return {
3615
+ description: `Renders a navigation menu in the selected element and keeps it in sync with
3616
+ the active navigation entry.
3617
+
3618
+ Activating a menu item (click, Enter or Space) navigates to its entry:
3619
+ - an entry with a \`timelineUri\` broadcasts \`request-timeline-uri\`
3620
+ [timelineUri, position], which the engine handles by switching timelines;
3621
+ - an entry without one broadcasts the legacy \`request-video-url\`
3622
+ [videoUrlIndex, position], which the engine does not handle.
3623
+
3624
+ With \`autoNext\`, the next entry is started when the active entry's timeline
3625
+ completes (\`timeline-complete\`) or, for legacy entries, on \`video-complete\`.
3626
+ When the engine switches to a timeline that an entry names
3627
+ (\`timeline-current-timeline-change\`), that entry becomes the active one.`,
3628
+ dependentProperties: ["selectedElement"],
3629
+ properties: { json: {
3630
+ type: "ParameterType:object",
3631
+ required: true
3632
+ } }
3633
+ };
3634
+ }
3635
+
3636
+ //#endregion
3637
+ //#region src/controllers/metadata/progressbar-controller.ts
3638
+ function ProgressbarController() {
3639
+ return {
3640
+ description: `This controller renders a progressbar that displays the progress of the current timeline in the given selected element.
3641
+
3642
+ The current progress as a percentage is rendered in the given text element.`,
3643
+ dependentProperties: ["selectedElement", "textElement"]
3644
+ };
3645
+ }
3646
+
3647
+ //#endregion
3648
+ //#region src/controllers/metadata/routing-controller.ts
3649
+ function RoutingController() {
3650
+ return {
3651
+ description: `Keeps the browser history in sync with the navigation entries: each entry
3652
+ gets a \`#/<id>/<position>\` URL, and back/forward navigation requests the
3653
+ entry in the URL.
3654
+
3655
+ Requests go to the engine as \`request-timeline-uri\` for entries with a
3656
+ \`timelineUri\`, and as the legacy \`request-video-url\` otherwise. Before the
3657
+ engine switches timelines (\`before-request-timeline-uri\`, or the legacy
3658
+ \`before-request-video-url\`), the current entry is saved with its position.
3659
+
3660
+ This is a work in progress, do not use this yet please....`,
3661
+ properties: { json: {
3662
+ type: "ParameterType:object",
3663
+ required: true
3664
+ } }
3665
+ };
3666
+ }
3667
+
3668
+ //#endregion
3669
+ //#region src/controllers/metadata/subtitles-controller.ts
3670
+ function SubtitlesController() {
3671
+ return {
3672
+ description: `This controller shows the subtitle whose duration contains the current
3673
+ timeline position in the selected element, in the current language, and
3674
+ re-renders it after a \`language-change\` event.
3675
+
3676
+ The starting language is the locale's current language
3677
+ (\`request-current-language\`); the configured \`language\` is only used when
3678
+ nothing answers that request.
3679
+
3680
+ Subtitle texts may contain simple inline markup. They are passed through
3681
+ \`sanitizeHtml\` before insertion, so \`<br>\`, \`<i>\`, \`<em>\`,
3682
+ \`<strong>\` and \`<span>\` render, while scripts, event handlers,
3683
+ \`javascript:\` URLs, images, iframes and SVG are removed.`,
3684
+ dependentProperties: ["selectedElement"],
3685
+ properties: {
3686
+ language: { type: "ParameterType:languagecode" },
3687
+ subtitleData: { type: "ParameterType:array" }
3688
+ }
3689
+ };
3690
+ }
3691
+
3692
+ //#endregion
3693
+ //#region src/controllers/metadata/index.ts
3694
+ var metadata_exports = /* @__PURE__ */ __exportAll({
3695
+ DOMEventListenerController: () => DOMEventListenerController,
3696
+ LabelController: () => LabelController,
3697
+ LottieController: () => LottieController,
3698
+ MutationObserverController: () => MutationObserverController,
3699
+ NavigationController: () => NavigationController,
3700
+ ProgressbarController: () => ProgressbarController,
3701
+ RoutingController: () => RoutingController,
3702
+ SubtitlesController: () => SubtitlesController
3703
+ });
3704
+
3705
+ //#endregion
3706
+ //#region src/configuration/api/name-providers.ts
3707
+ /**
3708
+ *
3709
+ * Provider for all the available operation names
3710
+ *
3711
+ */
3712
+ var OperationNamesProvider = class {
3713
+ getOperationNames() {
3714
+ return Object.keys(metadata_exports$1);
3715
+ }
3716
+ };
3717
+ /**
3718
+ *
3719
+ * Provider for all the available controller names
3720
+ *
3721
+ */
3722
+ var ControllerNamesProvider = class {
3723
+ getControllerNames() {
3724
+ return Object.keys(metadata_exports);
3725
+ }
3726
+ };
3727
+ /**
3728
+ *
3729
+ * Provider that can retrieve the metadata associated with a given operation name
3730
+ *
3731
+ */
3732
+ var OperationMetadataProvider = class {
3733
+ getOperationMetadata(operationName) {
3734
+ const getMetadata = metadata_exports$1[operationName];
3735
+ if (!getMetadata) throw new Error(`Could not find metadata for operation called ${operationName}`);
3736
+ return getMetadata();
3737
+ }
3738
+ };
3739
+
3740
+ //#endregion
3741
+ //#region src/configuration/api/subtitle-converter.ts
3742
+ /**
3743
+ * This class converts an AVID subtitle file to an `ISubtitle` array.
3744
+ *
3745
+ * Every subtitle gets a unique `id`. The lines of a multi-line caption are
3746
+ * joined with a newline (`\n`), never with HTML.
3747
+ */
3748
+ var SubtitleImporter = class {
3749
+ importSubtitles(rawLines) {
3750
+ const result = [];
3751
+ const lines = [];
3752
+ for (let i = 0, l = rawLines.length; i < l; i++) {
3753
+ const rawLine = this.stripNewlineChars(rawLines[i].toString());
3754
+ if (this.isValidLine(rawLine)) lines.push(rawLine);
3755
+ }
3756
+ let duration;
3757
+ let textLines = [];
3758
+ const flush = () => {
3759
+ if (duration) result.push({
3760
+ id: v4(),
3761
+ duration,
3762
+ text: textLines.join("\n")
3763
+ });
3764
+ duration = void 0;
3765
+ textLines = [];
3766
+ };
3767
+ lines.forEach((line) => {
3768
+ if (line.length === 0) flush();
3769
+ else if (!duration) duration = this.convertDuration(line);
3770
+ else textLines.push(line);
3771
+ });
3772
+ flush();
3773
+ return result;
3774
+ }
3775
+ stripNewlineChars(str) {
3776
+ let res = "";
3777
+ for (let i = 0, l = str.length; i < l; i++) if (str.charCodeAt(i) !== 13 && str.charCodeAt(i) !== 0) res += str.charAt(i);
3778
+ return res;
3779
+ }
3780
+ isValidLine(line) {
3781
+ return !line.startsWith("@") && !line.startsWith("<begin subtitles>") && !line.startsWith("<end subtitles>");
3782
+ }
3783
+ convertDuration(time) {
3784
+ const times = time.split(" ");
3785
+ return {
3786
+ start: this.convertTimeToSeconds(times[0]),
3787
+ end: this.convertTimeToSeconds(times[1])
3788
+ };
3789
+ }
3790
+ convertTimeToSeconds(time) {
3791
+ const parts = time.split(":");
3792
+ return parseInt(parts[0], 10) * 3600 + parseInt(parts[1], 10) * 60 + parseInt(parts[2], 10);
3793
+ }
3794
+ };
3795
+
3796
+ //#endregion
3797
+ //#region src/configuration/api/subtitle-editor.ts
3798
+ /**
3799
+ * Used to edit and add to an {@link ISubtitleCollection}.
3800
+ */
3801
+ var SubtitleEditor = class {
3802
+ collection;
3803
+ constructor(collection = []) {
3804
+ this.collection = collection;
3805
+ }
3806
+ _getLanguage(languageCode) {
3807
+ return this.collection.find((x) => x.languageCode === languageCode);
3808
+ }
3809
+ /**
3810
+ * Adds a new {@link ISubtitleCollection} for the given `languageCode`.
3811
+ *
3812
+ * If collections already exist for existing language codes then a duplicate
3813
+ * of these collections is created with the same duration info but all of the
3814
+ * text is left empty.
3815
+ *
3816
+ * @param languageCode
3817
+ * @returns
3818
+ */
3819
+ addLanguage(languageCode) {
3820
+ if (this._getLanguage(languageCode)) throw new Error(`Language ${languageCode} already exists.`);
3821
+ const newLanguage = this.collection.length ? {
3822
+ ...this.collection[0],
3823
+ languageCode,
3824
+ titles: this.collection[0].titles.map((x) => ({
3825
+ id: v4(),
3826
+ duration: { ...x.duration },
3827
+ text: ""
3828
+ }))
3829
+ } : {
3830
+ languageCode,
3831
+ titles: []
3832
+ };
3833
+ this.collection.push(newLanguage);
3834
+ return this;
3835
+ }
3836
+ /**
3837
+ *
3838
+ * Add a single subtitle line that is associated with the given `languageCode`
3839
+ *
3840
+ * @param languageCode
3841
+ * @param subtitle
3842
+ * @returns
3843
+ */
3844
+ addSubtitle(languageCode, subtitle) {
3845
+ const language = this._getLanguage(languageCode);
3846
+ if (!language) throw new Error(`Language ${languageCode} does not exist.`);
3847
+ language.titles.push(subtitle);
3848
+ return this;
3849
+ }
3850
+ addSubtitles(duration, subtitles) {
3851
+ Object.entries(subtitles).forEach(([languageCode, subtitle]) => this.addSubtitle(languageCode, {
3852
+ id: v4(),
3853
+ duration: { ...duration },
3854
+ text: subtitle
3855
+ }));
3856
+ return this;
3857
+ }
3858
+ setSubtitle(languageCode, subtitle) {
3859
+ const language = this._getLanguage(languageCode);
3860
+ if (!language) throw new Error(`Language ${languageCode} does not exist.`);
3861
+ const titleIdx = language.titles.findIndex((x) => x.id === subtitle.id);
3862
+ if (titleIdx < 0) throw new Error(`Subtitle with id '${subtitle.id}' was not found in language with code ${languageCode}.`);
3863
+ language.titles[titleIdx] = {
3864
+ ...subtitle,
3865
+ duration: { ...subtitle.duration }
3866
+ };
3867
+ return this;
3868
+ }
3869
+ export() {
3870
+ return this.collection;
3871
+ }
3872
+ };
3873
+
3874
+ //#endregion
3875
+ export { ActionCreator, ActionCreatorFactory, ActionEditor, ConfigurationFactory, ControllerNamesProvider, EndableActionCreator, EndableActionEditor, OperationEditor, OperationMetadataProvider, OperationNamesProvider, SubtitleEditor, SubtitleImporter, TimelineActionCreator, TimelineActionEditor, TimelineProviderSettingsEditor, TimelineProvidersSettingsEditor };
3876
+ //# sourceMappingURL=configuration-api.mjs.map