@emaarco/bpmn-js-data-simulation 0.1.0 → 0.2.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 (117) hide show
  1. package/dist/domain/GatewayRouter.d.ts +11 -0
  2. package/dist/domain/GatewayRouter.d.ts.map +1 -0
  3. package/dist/domain/ScenarioError.d.ts +4 -0
  4. package/dist/domain/ScenarioError.d.ts.map +1 -0
  5. package/dist/domain/ScenarioParser.d.ts +7 -0
  6. package/dist/domain/ScenarioParser.d.ts.map +1 -0
  7. package/dist/domain/StartFieldCodec.d.ts +7 -0
  8. package/dist/domain/StartFieldCodec.d.ts.map +1 -0
  9. package/dist/domain/StartFieldDeriver.d.ts +7 -0
  10. package/dist/domain/StartFieldDeriver.d.ts.map +1 -0
  11. package/dist/domain/model.d.ts +32 -0
  12. package/dist/domain/model.d.ts.map +1 -1
  13. package/dist/engines/EngineRegistry.d.ts +6 -0
  14. package/dist/engines/EngineRegistry.d.ts.map +1 -0
  15. package/dist/engines/camunda7/Camunda7Engine.d.ts +17 -0
  16. package/dist/engines/camunda7/Camunda7Engine.d.ts.map +1 -0
  17. package/dist/engines/camunda7/juel/JuelError.d.ts +4 -0
  18. package/dist/engines/camunda7/juel/JuelError.d.ts.map +1 -0
  19. package/dist/engines/camunda7/juel/JuelEvaluator.d.ts +18 -0
  20. package/dist/engines/camunda7/juel/JuelEvaluator.d.ts.map +1 -0
  21. package/dist/engines/camunda7/juel/JuelLexer.d.ts +6 -0
  22. package/dist/engines/camunda7/juel/JuelLexer.d.ts.map +1 -0
  23. package/dist/engines/camunda7/juel/JuelParser.d.ts +19 -0
  24. package/dist/engines/camunda7/juel/JuelParser.d.ts.map +1 -0
  25. package/dist/engines/camunda7/juel/JuelTemplate.d.ts +11 -0
  26. package/dist/engines/camunda7/juel/JuelTemplate.d.ts.map +1 -0
  27. package/dist/engines/camunda7/juel/juelSyntax.d.ts +34 -0
  28. package/dist/engines/camunda7/juel/juelSyntax.d.ts.map +1 -0
  29. package/dist/engines/engines.d.ts +5 -0
  30. package/dist/engines/engines.d.ts.map +1 -0
  31. package/dist/engines/zeebe/ZeebeEngine.d.ts +21 -0
  32. package/dist/engines/zeebe/ZeebeEngine.d.ts.map +1 -0
  33. package/dist/index.cjs +1875 -1741
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.ts +10 -6
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +1870 -1737
  38. package/dist/index.js.map +1 -1
  39. package/dist/integration/DataGateways.d.ts +2 -1
  40. package/dist/integration/DataGateways.d.ts.map +1 -1
  41. package/dist/integration/DataSimulation.d.ts +2 -1
  42. package/dist/integration/DataSimulation.d.ts.map +1 -1
  43. package/dist/integration/DataSimulationOverlays.d.ts.map +1 -1
  44. package/dist/integration/DataSimulationPanel.d.ts +3 -0
  45. package/dist/integration/DataSimulationPanel.d.ts.map +1 -1
  46. package/dist/integration/DataSimulationToggle.d.ts +8 -0
  47. package/dist/integration/DataSimulationToggle.d.ts.map +1 -1
  48. package/dist/integration/DataStartForm.d.ts +5 -4
  49. package/dist/integration/DataStartForm.d.ts.map +1 -1
  50. package/dist/integration/IoMappings.d.ts +11 -0
  51. package/dist/integration/IoMappings.d.ts.map +1 -0
  52. package/dist/integration/VariableUsageCollector.d.ts +11 -0
  53. package/dist/integration/VariableUsageCollector.d.ts.map +1 -0
  54. package/dist/integration/behaviors/DataContextPads.d.ts +5 -0
  55. package/dist/integration/behaviors/DataContextPads.d.ts.map +1 -1
  56. package/dist/integration/behaviors/DataGatewayBehaviors.d.ts +2 -0
  57. package/dist/integration/behaviors/DataGatewayBehaviors.d.ts.map +1 -1
  58. package/dist/integration/behaviors/DataGatewaySettings.d.ts +2 -0
  59. package/dist/integration/behaviors/DataGatewaySettings.d.ts.map +1 -1
  60. package/dist/integration/tokenSimulation.d.ts +0 -3
  61. package/dist/integration/tokenSimulation.d.ts.map +1 -1
  62. package/dist/simulation/DataSimulationStore.d.ts +2 -2
  63. package/dist/simulation/DataSimulationStore.d.ts.map +1 -1
  64. package/dist/simulation/GatewayDecisionView.d.ts +10 -0
  65. package/dist/simulation/GatewayDecisionView.d.ts.map +1 -0
  66. package/dist/ui/DecisionCard.d.ts +8 -0
  67. package/dist/ui/DecisionCard.d.ts.map +1 -0
  68. package/dist/ui/OutcomeBadge.d.ts +6 -0
  69. package/dist/ui/OutcomeBadge.d.ts.map +1 -0
  70. package/dist/ui/SimpleStartForm.d.ts +15 -2
  71. package/dist/ui/SimpleStartForm.d.ts.map +1 -1
  72. package/dist/ui/SimpleStartFormRenderer.d.ts +6 -0
  73. package/dist/ui/SimpleStartFormRenderer.d.ts.map +1 -0
  74. package/dist/ui/StartDialog.d.ts +28 -4
  75. package/dist/ui/StartDialog.d.ts.map +1 -1
  76. package/dist/ui/VariablesPanel.d.ts +4 -0
  77. package/dist/ui/VariablesPanel.d.ts.map +1 -1
  78. package/dist/ui/startForm.d.ts +1 -2
  79. package/dist/ui/startForm.d.ts.map +1 -1
  80. package/dist/utils/badgePosition.d.ts +10 -0
  81. package/dist/utils/badgePosition.d.ts.map +1 -0
  82. package/dist/utils/diagramElements.d.ts +7 -0
  83. package/dist/utils/diagramElements.d.ts.map +1 -0
  84. package/dist/utils/dom.d.ts.map +1 -0
  85. package/dist/{engines → utils}/moddle.d.ts +1 -1
  86. package/dist/{engines → utils}/moddle.d.ts.map +1 -1
  87. package/dist/utils/objects.d.ts +3 -0
  88. package/dist/utils/objects.d.ts.map +1 -0
  89. package/dist/utils/popoverPlacement.d.ts.map +1 -0
  90. package/dist/utils/shadow.d.ts.map +1 -0
  91. package/dist/utils/variables.d.ts +5 -0
  92. package/dist/utils/variables.d.ts.map +1 -0
  93. package/package.json +9 -9
  94. package/dist/domain/routing.d.ts +0 -4
  95. package/dist/domain/routing.d.ts.map +0 -1
  96. package/dist/domain/scenario.d.ts +0 -13
  97. package/dist/domain/scenario.d.ts.map +0 -1
  98. package/dist/domain/startFields.d.ts +0 -31
  99. package/dist/domain/startFields.d.ts.map +0 -1
  100. package/dist/domain/variables.d.ts +0 -4
  101. package/dist/domain/variables.d.ts.map +0 -1
  102. package/dist/engines/camunda7/camunda7Engine.d.ts +0 -3
  103. package/dist/engines/camunda7/camunda7Engine.d.ts.map +0 -1
  104. package/dist/engines/camunda7/juel.d.ts +0 -32
  105. package/dist/engines/camunda7/juel.d.ts.map +0 -1
  106. package/dist/engines/index.d.ts +0 -7
  107. package/dist/engines/index.d.ts.map +0 -1
  108. package/dist/engines/zeebe/zeebeEngine.d.ts +0 -3
  109. package/dist/engines/zeebe/zeebeEngine.d.ts.map +0 -1
  110. package/dist/ui/dom.d.ts.map +0 -1
  111. package/dist/ui/overlayContent.d.ts +0 -5
  112. package/dist/ui/overlayContent.d.ts.map +0 -1
  113. package/dist/ui/popoverPlacement.d.ts.map +0 -1
  114. package/dist/ui/shadow.d.ts.map +0 -1
  115. /package/dist/{ui → utils}/dom.d.ts +0 -0
  116. /package/dist/{ui → utils}/popoverPlacement.d.ts +0 -0
  117. /package/dist/{ui → utils}/shadow.d.ts +0 -0
package/dist/index.cjs CHANGED
@@ -4,1962 +4,2096 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var feelin = require('feelin');
6
6
 
7
- function routeGateway(kind, outgoing, evaluateCondition) {
8
- const conditional = outgoing.filter(flow => !flow.isDefault);
9
- const defaultFlow = outgoing.find(flow => flow.isDefault);
7
+ class GatewayRouter {
8
+ route(kind, outgoing, evaluateCondition) {
9
+ const conditional = outgoing.filter((flow) => !flow.isDefault);
10
+ const defaultFlow = outgoing.find((flow) => flow.isDefault);
10
11
  const evaluations = [];
11
12
  for (const flow of conditional) {
12
- const alreadyDecided = kind === 'exclusive' && evaluations.some(isDecisive);
13
- evaluations.push(alreadyDecided ? { flow, outcome: 'skipped' } : evaluateFlow(flow, evaluateCondition));
13
+ const alreadyDecided = kind === "exclusive" && evaluations.some((evaluation) => this.isDecisive(evaluation));
14
+ evaluations.push(alreadyDecided ? { flow, outcome: "skipped" } : this.evaluateFlow(flow, evaluateCondition));
14
15
  }
15
- const failed = evaluations.find(evaluation => evaluation.outcome === 'error');
16
+ const failed = evaluations.find((evaluation) => evaluation.outcome === "error");
16
17
  if (failed) {
17
- return stuck(evaluations, defaultFlow, `Condition of "${failed.flow.name ?? failed.flow.id}" failed: ${failed.reason}`);
18
+ return this.stuck(
19
+ evaluations,
20
+ defaultFlow,
21
+ `Condition of "${failed.flow.name ?? failed.flow.id}" failed: ${failed.reason}`
22
+ );
18
23
  }
19
- const taken = evaluations.filter(evaluation => evaluation.outcome === 'taken');
24
+ const taken = evaluations.filter((evaluation) => evaluation.outcome === "taken");
20
25
  if (taken.length) {
21
- return withDefault(evaluations, defaultFlow, 'not-taken', taken.map(evaluation => evaluation.flow.id));
26
+ return this.withDefault(
27
+ evaluations,
28
+ defaultFlow,
29
+ "not-taken",
30
+ taken.map((evaluation) => evaluation.flow.id)
31
+ );
22
32
  }
23
33
  if (defaultFlow) {
24
- return withDefault(evaluations, defaultFlow, 'taken', [defaultFlow.id]);
34
+ return this.withDefault(evaluations, defaultFlow, "taken", [defaultFlow.id]);
25
35
  }
26
- return stuck(evaluations, defaultFlow, 'No condition is true and there is no default flow');
27
- }
28
- function evaluateFlow(flow, evaluateCondition) {
29
- if (flow.expression === undefined) {
30
- return { flow, outcome: 'error', reason: 'Missing condition' };
36
+ return this.stuck(evaluations, defaultFlow, "No condition is true and there is no default flow");
37
+ }
38
+ evaluateFlow(flow, evaluateCondition) {
39
+ if (flow.expression === void 0) {
40
+ return { flow, outcome: "error", reason: "Missing condition" };
31
41
  }
32
42
  const evaluation = evaluateCondition(flow.expression);
33
43
  if (!evaluation.ok) {
34
- return { flow, outcome: 'error', reason: evaluation.reason };
35
- }
36
- if (typeof evaluation.value !== 'boolean') {
37
- return {
38
- flow,
39
- outcome: 'error',
40
- value: evaluation.value,
41
- reason: `Expected a boolean but got ${describe(evaluation.value)}`,
42
- };
43
- }
44
- return { flow, outcome: evaluation.value ? 'taken' : 'not-taken', value: evaluation.value };
45
- }
46
- function isDecisive(evaluation) {
47
- return evaluation.outcome === 'taken' || evaluation.outcome === 'error';
48
- }
49
- function withDefault(evaluations, defaultFlow, defaultOutcome, takenFlowIds) {
44
+ return { flow, outcome: "error", reason: evaluation.reason };
45
+ }
46
+ if (typeof evaluation.value !== "boolean") {
47
+ return {
48
+ flow,
49
+ outcome: "error",
50
+ value: evaluation.value,
51
+ reason: `Expected a boolean but got ${this.describe(evaluation.value)}`
52
+ };
53
+ }
54
+ return { flow, outcome: evaluation.value ? "taken" : "not-taken", value: evaluation.value };
55
+ }
56
+ isDecisive(evaluation) {
57
+ return evaluation.outcome === "taken" || evaluation.outcome === "error";
58
+ }
59
+ withDefault(evaluations, defaultFlow, defaultOutcome, takenFlowIds) {
50
60
  const flows = defaultFlow ? [...evaluations, { flow: defaultFlow, outcome: defaultOutcome }] : evaluations;
51
61
  return { flows, takenFlowIds };
52
- }
53
- function stuck(evaluations, defaultFlow, stuckReason) {
54
- return { ...withDefault(evaluations, defaultFlow, 'skipped', []), stuckReason };
55
- }
56
- function describe(value) {
57
- if (value === null || value === undefined)
58
- return 'null';
62
+ }
63
+ stuck(evaluations, defaultFlow, stuckReason) {
64
+ return { ...this.withDefault(evaluations, defaultFlow, "skipped", []), stuckReason };
65
+ }
66
+ describe(value) {
67
+ if (value === null || value === void 0) return "null";
59
68
  return `${typeof value} ${JSON.stringify(value)}`;
69
+ }
70
+ }
71
+
72
+ class ScenarioError extends Error {
73
+ constructor() {
74
+ super(...arguments);
75
+ this.name = "ScenarioError";
76
+ }
60
77
  }
61
78
 
62
79
  function setVariable(variables, path, value) {
63
- const [head, ...rest] = path.split('.');
64
- if (!rest.length) {
65
- return { ...variables, [head]: value };
66
- }
67
- const nested = variables[head];
68
- const nestedVariables = isVariables(nested) ? nested : {};
69
- return { ...variables, [head]: setVariable(nestedVariables, rest.join('.'), value) };
80
+ const [head, ...rest] = path.split(".");
81
+ if (!rest.length) {
82
+ return { ...variables, [head]: value };
83
+ }
84
+ const nested = variables[head];
85
+ const nestedVariables = isVariables(nested) ? nested : {};
86
+ return { ...variables, [head]: setVariable(nestedVariables, rest.join("."), value) };
70
87
  }
71
88
  function isVariables(value) {
72
- return typeof value === 'object' && value !== null && !Array.isArray(value);
89
+ return typeof value === "object" && value !== null && !Array.isArray(value);
73
90
  }
74
-
75
- class ScenarioError extends Error {
76
- constructor() {
77
- super(...arguments);
78
- this.name = 'ScenarioError';
79
- }
91
+ function withoutKeys(variables, keys) {
92
+ return Object.fromEntries(Object.entries(variables).filter(([key]) => !keys.includes(key)));
80
93
  }
81
- function parseScenarios(input) {
94
+
95
+ class ScenarioParser {
96
+ parse(input) {
82
97
  const list = isVariables(input) ? input.scenarios : input;
83
98
  if (!Array.isArray(list)) {
84
- throw new ScenarioError('Expected an array of scenarios or an object with a "scenarios" array');
99
+ throw new ScenarioError('Expected an array of scenarios or an object with a "scenarios" array');
85
100
  }
86
- const scenarios = list.map(parseScenario);
87
- assertUniqueIds(scenarios);
101
+ const scenarios = list.map((raw, index) => this.parseScenario(raw, index));
102
+ this.assertUniqueIds(scenarios);
88
103
  return scenarios;
89
- }
90
- function parseScenario(raw, index) {
104
+ }
105
+ parseScenario(raw, index) {
91
106
  if (!isVariables(raw)) {
92
- throw new ScenarioError(`Scenario #${index + 1} must be an object`);
107
+ throw new ScenarioError(`Scenario #${index + 1} must be an object`);
93
108
  }
94
109
  const { id, name, description, variables = {}, taskResults = {} } = raw;
95
- const label = typeof id === 'string' ? `"${id}"` : `#${index + 1}`;
96
- if (typeof id !== 'string' || !id) {
97
- throw new ScenarioError(`Scenario ${label} needs a non-empty string "id"`);
110
+ const label = typeof id === "string" ? `"${id}"` : `#${index + 1}`;
111
+ if (typeof id !== "string" || !id) {
112
+ throw new ScenarioError(`Scenario ${label} needs a non-empty string "id"`);
98
113
  }
99
- if (name !== undefined && typeof name !== 'string') {
100
- throw new ScenarioError(`Scenario ${label}: "name" must be a string`);
114
+ if (name !== void 0 && typeof name !== "string") {
115
+ throw new ScenarioError(`Scenario ${label}: "name" must be a string`);
101
116
  }
102
- if (description !== undefined && typeof description !== 'string') {
103
- throw new ScenarioError(`Scenario ${label}: "description" must be a string`);
117
+ if (description !== void 0 && typeof description !== "string") {
118
+ throw new ScenarioError(`Scenario ${label}: "description" must be a string`);
104
119
  }
105
120
  if (!isVariables(variables)) {
106
- throw new ScenarioError(`Scenario ${label}: "variables" must be an object`);
121
+ throw new ScenarioError(`Scenario ${label}: "variables" must be an object`);
107
122
  }
108
123
  if (!isVariables(taskResults) || !Object.values(taskResults).every(isVariables)) {
109
- throw new ScenarioError(`Scenario ${label}: "taskResults" must map element ids to objects`);
124
+ throw new ScenarioError(`Scenario ${label}: "taskResults" must map element ids to objects`);
110
125
  }
111
126
  return {
112
- id,
113
- name: name ?? id,
114
- ...(description === undefined ? {} : { description }),
115
- variables,
116
- taskResults: taskResults,
127
+ id,
128
+ name: name ?? id,
129
+ ...description === void 0 ? {} : { description },
130
+ variables,
131
+ taskResults
117
132
  };
118
- }
119
- function assertUniqueIds(scenarios) {
120
- const seen = new Set();
133
+ }
134
+ assertUniqueIds(scenarios) {
135
+ const seen = /* @__PURE__ */ new Set();
121
136
  for (const { id } of scenarios) {
122
- if (seen.has(id)) {
123
- throw new ScenarioError(`Duplicate scenario id "${id}"`);
124
- }
125
- seen.add(id);
137
+ if (seen.has(id)) {
138
+ throw new ScenarioError(`Duplicate scenario id "${id}"`);
139
+ }
140
+ seen.add(id);
126
141
  }
142
+ }
127
143
  }
128
144
 
129
- function deriveStartFields(usages, { examples = [], taskResultNames = [] } = {}) {
130
- const written = new Set([...usages.flatMap(usage => usage.outputTargets.map(topLevelName)), ...taskResultNames]);
131
- const usedBy = new Map();
132
- for (const usage of usages) {
133
- const localNames = new Set(usage.inputTargets.map(topLevelName));
134
- for (const name of [...usage.conditionReads, ...usage.inputReads, ...usage.outputReads]) {
135
- if (written.has(name) || localNames.has(name))
136
- continue;
137
- if (!usedBy.has(name))
138
- usedBy.set(name, new Set());
139
- usedBy.get(name).add(usage.elementName);
140
- }
141
- }
142
- return [...usedBy.entries()].map(([name, elements]) => ({
143
- name,
144
- type: inferType(examples.map(example => example[name]).find(value => value !== undefined)),
145
- usedBy: [...elements],
146
- }));
147
- }
148
- function parseFieldValue(field, raw) {
149
- if (typeof raw === 'boolean')
150
- return { ok: true, value: raw };
145
+ class StartFieldCodec {
146
+ parse(field, raw) {
147
+ if (typeof raw === "boolean") return { ok: true, value: raw };
151
148
  const text = raw.trim();
152
- if (!text)
153
- return { ok: true, value: undefined };
149
+ if (!text) return { ok: true, value: void 0 };
154
150
  switch (field.type) {
155
- case 'number': {
156
- const value = Number(text);
157
- return Number.isNaN(value) ? { ok: false, reason: `${field.name} must be a number` } : { ok: true, value };
151
+ case "number": {
152
+ const value = Number(text);
153
+ return Number.isNaN(value) ? { ok: false, reason: `${field.name} must be a number` } : { ok: true, value };
154
+ }
155
+ case "json":
156
+ try {
157
+ return { ok: true, value: JSON.parse(text) };
158
+ } catch {
159
+ return { ok: false, reason: `${field.name} must be valid JSON` };
160
+ }
161
+ case "auto":
162
+ try {
163
+ return { ok: true, value: JSON.parse(text) };
164
+ } catch {
165
+ return { ok: true, value: raw };
158
166
  }
159
- case 'json':
160
- try {
161
- return { ok: true, value: JSON.parse(text) };
162
- }
163
- catch {
164
- return { ok: false, reason: `${field.name} must be valid JSON` };
165
- }
166
- case 'auto':
167
- try {
168
- return { ok: true, value: JSON.parse(text) };
169
- }
170
- catch {
171
- return { ok: true, value: raw };
172
- }
173
- default:
174
- return { ok: true, value: raw };
167
+ default:
168
+ return { ok: true, value: raw };
175
169
  }
176
- }
177
- function formatFieldValue(field, value) {
178
- if (field.type === 'boolean')
179
- return value === true;
180
- if (value === undefined || value === null)
181
- return '';
182
- if (typeof value === 'string' && field.type !== 'json')
183
- return value;
184
- return field.type === 'number' ? String(value) : JSON.stringify(value);
185
- }
186
- function applyFieldValues(base, values) {
170
+ }
171
+ format(field, value) {
172
+ if (field.type === "boolean") return value === true;
173
+ if (value === void 0 || value === null) return "";
174
+ if (typeof value === "string" && field.type !== "json") return value;
175
+ return field.type === "number" ? String(value) : JSON.stringify(value);
176
+ }
177
+ apply(base, values) {
187
178
  const variables = { ...base };
188
179
  for (const [name, value] of Object.entries(values)) {
189
- if (value === undefined)
190
- delete variables[name];
191
- else
192
- variables[name] = value;
180
+ if (value === void 0) delete variables[name];
181
+ else variables[name] = value;
193
182
  }
194
183
  return variables;
195
- }
196
- function topLevelName(path) {
197
- return path.split('.')[0];
198
- }
199
- function inferType(example) {
200
- if (typeof example === 'number')
201
- return 'number';
202
- if (typeof example === 'boolean')
203
- return 'boolean';
204
- if (typeof example === 'string')
205
- return 'text';
206
- if (Array.isArray(example) || isVariables(example))
207
- return 'json';
208
- return 'auto';
184
+ }
209
185
  }
210
186
 
211
187
  function findExtension(element, type) {
212
- const extensionElements = element.extensionElements;
213
- return extensionElements?.values?.find(value => value.$type === type);
188
+ const extensionElements = element.extensionElements;
189
+ return extensionElements?.values?.find((value) => value.$type === type);
214
190
  }
215
191
  function listProperty(element, property) {
216
- const value = element?.[property];
217
- return Array.isArray(value) ? value : [];
192
+ const value = element?.[property];
193
+ return Array.isArray(value) ? value : [];
218
194
  }
219
195
  function readConditionExpression(sequenceFlow) {
220
- const condition = sequenceFlow.conditionExpression;
221
- if (!condition)
222
- return undefined;
223
- return {
224
- body: typeof condition.body === 'string' ? condition.body : undefined,
225
- language: typeof condition.language === 'string' ? condition.language : undefined,
226
- };
196
+ const condition = sequenceFlow.conditionExpression;
197
+ if (!condition) return void 0;
198
+ return {
199
+ body: typeof condition.body === "string" ? condition.body : void 0,
200
+ language: typeof condition.language === "string" ? condition.language : void 0
201
+ };
227
202
  }
228
203
 
229
204
  class JuelError extends Error {
230
- constructor() {
231
- super(...arguments);
232
- this.name = 'JuelError';
233
- }
234
- }
235
- const KEYWORD_OPERATORS = {
236
- and: '&&',
237
- or: '||',
238
- not: '!',
239
- eq: '==',
240
- ne: '!=',
241
- lt: '<',
242
- gt: '>',
243
- le: '<=',
244
- ge: '>=',
245
- div: '/',
246
- mod: '%',
247
- empty: 'empty',
248
- };
249
- const SYMBOL_OPERATORS = [
250
- '==',
251
- '!=',
252
- '<=',
253
- '>=',
254
- '&&',
255
- '||',
256
- '<',
257
- '>',
258
- '!',
259
- '+',
260
- '-',
261
- '*',
262
- '/',
263
- '%',
264
- '(',
265
- ')',
266
- '[',
267
- ']',
268
- '.',
269
- '?',
270
- ':',
271
- ];
272
- function parseJuelTemplate(text) {
273
- const parts = [];
274
- let cursor = 0;
275
- while (cursor < text.length) {
276
- const start = findExpressionStart(text, cursor);
277
- if (start === -1) {
278
- parts.push(text.slice(cursor));
279
- break;
280
- }
281
- if (start > cursor)
282
- parts.push(text.slice(cursor, start));
283
- const end = findExpressionEnd(text, start + 2);
284
- parts.push(parseJuelExpression(text.slice(start + 2, end)));
285
- cursor = end + 1;
286
- }
287
- return parts;
288
- }
289
- function evaluateJuelTemplate(template, variables) {
290
- if (template.length === 1 && typeof template[0] !== 'string') {
291
- return evaluateNode(template[0], variables);
292
- }
293
- return template
294
- .map(part => (typeof part === 'string' ? part : coerceToString(evaluateNode(part, variables))))
295
- .join('');
205
+ constructor() {
206
+ super(...arguments);
207
+ this.name = "JuelError";
208
+ }
296
209
  }
297
- function readJuelVariableNames(template) {
298
- const names = new Set();
299
- const visit = (node) => {
300
- if (node.type === 'identifier')
301
- names.add(node.name);
302
- if (node.type === 'member') {
303
- visit(node.object);
304
- visit(node.property);
305
- }
306
- if (node.type === 'unary')
307
- visit(node.operand);
308
- if (node.type === 'binary') {
309
- visit(node.left);
310
- visit(node.right);
311
- }
312
- if (node.type === 'conditional') {
313
- visit(node.test);
314
- visit(node.consequent);
315
- visit(node.alternate);
316
- }
317
- };
318
- template.forEach(part => typeof part !== 'string' && visit(part));
319
- return [...names];
320
- }
321
- function findExpressionStart(text, from) {
322
- const dollar = text.indexOf('${', from);
323
- const hash = text.indexOf('#{', from);
324
- if (dollar === -1)
325
- return hash;
326
- if (hash === -1)
327
- return dollar;
328
- return Math.min(dollar, hash);
329
- }
330
- function findExpressionEnd(text, from) {
331
- let quote = null;
332
- for (let index = from; index < text.length; index++) {
333
- const char = text[index];
334
- if (quote) {
335
- if (char === '\\')
336
- index++;
337
- else if (char === quote)
338
- quote = null;
339
- }
340
- else if (char === "'" || char === '"') {
341
- quote = char;
342
- }
343
- else if (char === '}') {
344
- return index;
345
- }
346
- }
347
- throw new JuelError('Unterminated expression, missing "}"');
348
- }
349
- function parseJuelExpression(source) {
350
- const parser = new Parser(tokenize(source));
351
- const node = parser.parseExpression();
352
- parser.expectEnd();
353
- return node;
354
- }
355
- function tokenize(source) {
356
- const tokens = [];
357
- let index = 0;
358
- while (index < source.length) {
359
- const char = source[index];
360
- if (/\s/.test(char)) {
361
- index++;
362
- }
363
- else if (/[0-9]/.test(char) || (char === '.' && /[0-9]/.test(source[index + 1] ?? ''))) {
364
- const match = /^[0-9]*\.?[0-9]+(?:[eE][+-]?[0-9]+)?/.exec(source.slice(index));
365
- tokens.push({ kind: 'number', text: match[0], value: Number(match[0]) });
366
- index += match[0].length;
367
- }
368
- else if (char === "'" || char === '"') {
369
- const { value, length } = readString(source, index);
370
- tokens.push({ kind: 'string', text: source.slice(index, index + length), value });
371
- index += length;
372
- }
373
- else if (/[A-Za-z_$]/.test(char)) {
374
- const match = /^[A-Za-z_$][A-Za-z0-9_$]*/.exec(source.slice(index));
375
- const word = match[0];
376
- const keywordOperator = hasOwn(KEYWORD_OPERATORS, word) ? KEYWORD_OPERATORS[word] : undefined;
377
- tokens.push(keywordOperator ? { kind: 'operator', text: keywordOperator } : { kind: 'identifier', text: word });
378
- index += word.length;
379
- }
380
- else {
381
- const operator = SYMBOL_OPERATORS.find(candidate => source.startsWith(candidate, index));
382
- if (!operator)
383
- throw new JuelError(`Unexpected character "${char}"`);
384
- tokens.push({ kind: 'operator', text: operator });
385
- index += operator.length;
386
- }
387
- }
388
- return tokens;
389
- }
390
- function readString(source, start) {
391
- const quote = source[start];
392
- let value = '';
393
- for (let index = start + 1; index < source.length; index++) {
394
- const char = source[index];
395
- if (char === '\\') {
396
- value += source[index + 1] ?? '';
397
- index++;
398
- }
399
- else if (char === quote) {
400
- return { value, length: index - start + 1 };
401
- }
402
- else {
403
- value += char;
404
- }
405
- }
406
- throw new JuelError('Unterminated string literal');
407
- }
408
- class Parser {
409
- constructor(tokens) {
410
- this.tokens = tokens;
411
- this.position = 0;
412
- }
413
- parseExpression() {
414
- const test = this.parseBinary(0);
415
- if (!this.accept('?'))
416
- return test;
417
- const consequent = this.parseExpression();
418
- this.expect(':');
419
- const alternate = this.parseExpression();
420
- return { type: 'conditional', test, consequent, alternate };
421
- }
422
- expectEnd() {
423
- const token = this.peek();
424
- if (token)
425
- throw new JuelError(`Unexpected "${token.text}"`);
426
- }
427
- parseBinary(level) {
428
- if (level === Parser.PRECEDENCE.length)
429
- return this.parseUnary();
430
- let left = this.parseBinary(level + 1);
431
- let operator = this.acceptAny(Parser.PRECEDENCE[level]);
432
- while (operator) {
433
- const right = this.parseBinary(level + 1);
434
- left = { type: 'binary', operator, left, right };
435
- operator = this.acceptAny(Parser.PRECEDENCE[level]);
436
- }
437
- return left;
438
- }
439
- parseUnary() {
440
- const operator = this.acceptAny(['!', '-', 'empty']);
441
- if (operator)
442
- return { type: 'unary', operator, operand: this.parseUnary() };
443
- return this.parseMember();
444
- }
445
- parseMember() {
446
- let node = this.parsePrimary();
447
- for (;;) {
448
- if (this.accept('.')) {
449
- const property = this.next();
450
- if (property?.kind !== 'identifier')
451
- throw new JuelError('Expected a property name after "."');
452
- node = { type: 'member', object: node, property: { type: 'literal', value: property.text } };
453
- }
454
- else if (this.accept('[')) {
455
- node = { type: 'member', object: node, property: this.parseExpression() };
456
- this.expect(']');
457
- }
458
- else if (this.peek()?.text === '(') {
459
- throw new JuelError('Method calls are not supported');
460
- }
461
- else {
462
- return node;
463
- }
464
- }
465
- }
466
- parsePrimary() {
467
- const token = this.next();
468
- if (!token)
469
- throw new JuelError('Unexpected end of expression');
470
- if (token.kind === 'number' || token.kind === 'string')
471
- return { type: 'literal', value: token.value };
472
- if (token.kind === 'identifier')
473
- return identifierOrLiteral(token.text);
474
- if (token.text === '(') {
475
- const node = this.parseExpression();
476
- this.expect(')');
477
- return node;
478
- }
479
- throw new JuelError(`Unexpected "${token.text}"`);
480
- }
481
- peek() {
482
- return this.tokens[this.position];
483
- }
484
- next() {
485
- return this.tokens[this.position++];
486
- }
487
- accept(text) {
488
- if (this.peek()?.kind !== 'operator' || this.peek()?.text !== text)
489
- return false;
490
- this.position++;
491
- return true;
492
- }
493
- acceptAny(operators) {
494
- return operators.find(operator => this.accept(operator));
495
- }
496
- expect(text) {
497
- if (!this.accept(text))
498
- throw new JuelError(`Expected "${text}"`);
499
- }
210
+
211
+ function hasOwn(object, key) {
212
+ return Object.prototype.hasOwnProperty.call(object, key);
500
213
  }
501
- Parser.PRECEDENCE = [
502
- ['||'],
503
- ['&&'],
504
- ['==', '!='],
505
- ['<', '>', '<=', '>='],
506
- ['+', '-'],
507
- ['*', '/', '%'],
508
- ];
509
- function identifierOrLiteral(name) {
510
- if (name === 'true')
511
- return { type: 'literal', value: true };
512
- if (name === 'false')
513
- return { type: 'literal', value: false };
514
- if (name === 'null')
515
- return { type: 'literal', value: null };
516
- return { type: 'identifier', name };
214
+ function deepEqual(left, right) {
215
+ if (left === right) return true;
216
+ if (typeof left !== "object" || typeof right !== "object" || left === null || right === null) return false;
217
+ if (Array.isArray(left) !== Array.isArray(right)) return false;
218
+ const leftKeys = Object.keys(left);
219
+ const rightKeys = Object.keys(right);
220
+ return leftKeys.length === rightKeys.length && leftKeys.every(
221
+ (key) => hasOwn(right, key) && deepEqual(left[key], right[key])
222
+ );
517
223
  }
518
- function evaluateNode(node, variables) {
224
+
225
+ class JuelEvaluator {
226
+ constructor(variables) {
227
+ this.variables = variables;
228
+ }
229
+ evaluate(node) {
519
230
  switch (node.type) {
520
- case 'literal':
521
- return node.value;
522
- case 'identifier':
523
- if (!hasOwn(variables, node.name))
524
- throw new JuelError(`Unknown property used in expression: ${node.name}`);
525
- return variables[node.name];
526
- case 'member':
527
- return readMember(evaluateNode(node.object, variables), evaluateNode(node.property, variables));
528
- case 'unary':
529
- return evaluateUnary(node.operator, evaluateNode(node.operand, variables));
530
- case 'conditional':
531
- return coerceToBoolean(evaluateNode(node.test, variables))
532
- ? evaluateNode(node.consequent, variables)
533
- : evaluateNode(node.alternate, variables);
534
- case 'binary':
535
- return evaluateBinary(node, variables);
536
- }
537
- }
538
- function readMember(object, property) {
539
- if (object === null || object === undefined)
540
- return null;
231
+ case "literal":
232
+ return node.value;
233
+ case "identifier":
234
+ if (!hasOwn(this.variables, node.name)) {
235
+ throw new JuelError(`Unknown property used in expression: ${node.name}`);
236
+ }
237
+ return this.variables[node.name];
238
+ case "member":
239
+ return this.readMember(this.evaluate(node.object), this.evaluate(node.property));
240
+ case "unary":
241
+ return this.evaluateUnary(node.operator, this.evaluate(node.operand));
242
+ case "conditional":
243
+ return this.coerceToBoolean(this.evaluate(node.test)) ? this.evaluate(node.consequent) : this.evaluate(node.alternate);
244
+ case "binary":
245
+ return this.evaluateBinary(node);
246
+ }
247
+ }
248
+ coerceToString(value) {
249
+ if (value === null || value === void 0) return "";
250
+ return typeof value === "object" ? JSON.stringify(value) : String(value);
251
+ }
252
+ readMember(object, property) {
253
+ if (object === null || object === void 0) return null;
541
254
  const key = Array.isArray(object) ? Number(property) : String(property);
542
- return hasOwn(object, key) ? (object[key] ?? null) : null;
543
- }
544
- function hasOwn(object, key) {
545
- return Object.prototype.hasOwnProperty.call(object, key);
546
- }
547
- function evaluateUnary(operator, operand) {
548
- if (operator === '!')
549
- return !coerceToBoolean(operand);
550
- if (operator === '-')
551
- return -coerceToNumber(operand);
552
- return isEmpty(operand);
553
- }
554
- function evaluateBinary(node, variables) {
255
+ return hasOwn(object, key) ? object[key] ?? null : null;
256
+ }
257
+ evaluateUnary(operator, operand) {
258
+ if (operator === "!") return !this.coerceToBoolean(operand);
259
+ if (operator === "-") return -this.coerceToNumber(operand);
260
+ return this.isEmpty(operand);
261
+ }
262
+ evaluateBinary(node) {
555
263
  const { operator } = node;
556
- if (operator === '&&') {
557
- return coerceToBoolean(evaluateNode(node.left, variables)) && coerceToBoolean(evaluateNode(node.right, variables));
264
+ if (operator === "&&") {
265
+ return this.coerceToBoolean(this.evaluate(node.left)) && this.coerceToBoolean(this.evaluate(node.right));
558
266
  }
559
- if (operator === '||') {
560
- return coerceToBoolean(evaluateNode(node.left, variables)) || coerceToBoolean(evaluateNode(node.right, variables));
267
+ if (operator === "||") {
268
+ return this.coerceToBoolean(this.evaluate(node.left)) || this.coerceToBoolean(this.evaluate(node.right));
561
269
  }
562
- const left = evaluateNode(node.left, variables);
563
- const right = evaluateNode(node.right, variables);
270
+ const left = this.evaluate(node.left);
271
+ const right = this.evaluate(node.right);
272
+ const eitherIsNull = this.isNull(left) || this.isNull(right);
273
+ const bothAreNull = this.isNull(left) && this.isNull(right);
564
274
  switch (operator) {
565
- case '==':
566
- return areEqual(left, right);
567
- case '!=':
568
- return !areEqual(left, right);
569
- case '<':
570
- return isNull(left) || isNull(right) ? false : compare(left, right) < 0;
571
- case '>':
572
- return isNull(left) || isNull(right) ? false : compare(left, right) > 0;
573
- case '<=':
574
- return isNull(left) || isNull(right) ? isNull(left) && isNull(right) : compare(left, right) <= 0;
575
- case '>=':
576
- return isNull(left) || isNull(right) ? isNull(left) && isNull(right) : compare(left, right) >= 0;
577
- case '+':
578
- return coerceToNumber(left) + coerceToNumber(right);
579
- case '-':
580
- return coerceToNumber(left) - coerceToNumber(right);
581
- case '*':
582
- return coerceToNumber(left) * coerceToNumber(right);
583
- case '/':
584
- return coerceToNumber(left) / coerceToNumber(right);
585
- default:
586
- return coerceToNumber(left) % coerceToNumber(right);
587
- }
588
- }
589
- function isNull(value) {
590
- return value === null || value === undefined;
591
- }
592
- function areEqual(left, right) {
593
- if (left === right)
594
- return true;
595
- if (isNull(left) || isNull(right))
596
- return isNull(left) && isNull(right);
597
- if (typeof left === 'number' || typeof right === 'number')
598
- return coerceToNumber(left) === coerceToNumber(right);
599
- if (typeof left === 'boolean' || typeof right === 'boolean')
600
- return coerceToBoolean(left) === coerceToBoolean(right);
601
- if (typeof left === 'object' || typeof right === 'object')
602
- return deepEqual(left, right);
275
+ case "==":
276
+ return this.areEqual(left, right);
277
+ case "!=":
278
+ return !this.areEqual(left, right);
279
+ case "<":
280
+ return eitherIsNull ? false : this.compare(left, right) < 0;
281
+ case ">":
282
+ return eitherIsNull ? false : this.compare(left, right) > 0;
283
+ case "<=":
284
+ return eitherIsNull ? bothAreNull : this.compare(left, right) <= 0;
285
+ case ">=":
286
+ return eitherIsNull ? bothAreNull : this.compare(left, right) >= 0;
287
+ case "+":
288
+ return this.coerceToNumber(left) + this.coerceToNumber(right);
289
+ case "-":
290
+ return this.coerceToNumber(left) - this.coerceToNumber(right);
291
+ case "*":
292
+ return this.coerceToNumber(left) * this.coerceToNumber(right);
293
+ case "/":
294
+ return this.coerceToNumber(left) / this.coerceToNumber(right);
295
+ default:
296
+ return this.coerceToNumber(left) % this.coerceToNumber(right);
297
+ }
298
+ }
299
+ isNull(value) {
300
+ return value === null || value === void 0;
301
+ }
302
+ areEqual(left, right) {
303
+ if (left === right) return true;
304
+ if (this.isNull(left) || this.isNull(right)) return this.isNull(left) && this.isNull(right);
305
+ if (typeof left === "number" || typeof right === "number") {
306
+ return this.coerceToNumber(left) === this.coerceToNumber(right);
307
+ }
308
+ if (typeof left === "boolean" || typeof right === "boolean") {
309
+ return this.coerceToBoolean(left) === this.coerceToBoolean(right);
310
+ }
311
+ if (typeof left === "object" || typeof right === "object") return deepEqual(left, right);
603
312
  return String(left) === String(right);
604
- }
605
- function deepEqual(left, right) {
606
- if (left === right)
607
- return true;
608
- if (typeof left !== 'object' || typeof right !== 'object' || left === null || right === null)
609
- return false;
610
- if (Array.isArray(left) !== Array.isArray(right))
611
- return false;
612
- const leftKeys = Object.keys(left);
613
- const rightKeys = Object.keys(right);
614
- return (leftKeys.length === rightKeys.length &&
615
- leftKeys.every(key => hasOwn(right, key) &&
616
- deepEqual(left[key], right[key])));
617
- }
618
- function compare(left, right) {
619
- if (typeof left === 'string' && typeof right === 'string')
620
- return left < right ? -1 : left > right ? 1 : 0;
621
- return coerceToNumber(left) - coerceToNumber(right);
622
- }
623
- function coerceToNumber(value) {
624
- if (value === null || value === undefined || value === '')
625
- return 0;
626
- const number = typeof value === 'number' ? value : Number(value);
627
- if (typeof value === 'boolean' || Number.isNaN(number)) {
628
- throw new JuelError(`Cannot coerce ${JSON.stringify(value)} to a number`);
313
+ }
314
+ compare(left, right) {
315
+ if (typeof left === "string" && typeof right === "string") return left < right ? -1 : left > right ? 1 : 0;
316
+ return this.coerceToNumber(left) - this.coerceToNumber(right);
317
+ }
318
+ coerceToNumber(value) {
319
+ if (value === null || value === void 0 || value === "") return 0;
320
+ const number = typeof value === "number" ? value : Number(value);
321
+ if (typeof value === "boolean" || Number.isNaN(number)) {
322
+ throw new JuelError(`Cannot coerce ${JSON.stringify(value)} to a number`);
629
323
  }
630
324
  return number;
631
- }
632
- function coerceToBoolean(value) {
633
- if (typeof value === 'boolean')
634
- return value;
635
- if (value === null || value === undefined || value === '')
636
- return false;
637
- if (typeof value === 'string')
638
- return value.toLowerCase() === 'true';
325
+ }
326
+ coerceToBoolean(value) {
327
+ if (typeof value === "boolean") return value;
328
+ if (value === null || value === void 0 || value === "") return false;
329
+ if (typeof value === "string") return value.toLowerCase() === "true";
639
330
  throw new JuelError(`Cannot coerce ${JSON.stringify(value)} to a boolean`);
640
- }
641
- function coerceToString(value) {
642
- if (value === null || value === undefined)
643
- return '';
644
- return typeof value === 'object' ? JSON.stringify(value) : String(value);
645
- }
646
- function isEmpty(value) {
647
- if (value === null || value === undefined || value === '')
648
- return true;
649
- if (Array.isArray(value))
650
- return value.length === 0;
651
- if (typeof value === 'object')
652
- return Object.keys(value).length === 0;
331
+ }
332
+ isEmpty(value) {
333
+ if (value === null || value === void 0 || value === "") return true;
334
+ if (Array.isArray(value)) return value.length === 0;
335
+ if (typeof value === "object") return Object.keys(value).length === 0;
653
336
  return false;
337
+ }
654
338
  }
655
339
 
656
- const camunda7Engine = {
657
- id: 'camunda7',
658
- label: 'Camunda 7',
659
- expressionLanguage: 'JUEL',
660
- taskResultPropagation: 'always',
661
- writeVariable: (variables, target, value) => ({ ...variables, [target]: value }),
662
- readInputMappings: element => readMappings$1(element, 'inputParameters'),
663
- readOutputMappings: element => readMappings$1(element, 'outputParameters'),
664
- readCondition,
665
- canEvaluate,
666
- evaluate: evaluateCamundaExpression,
667
- readVariableNames: readVariableNames$1,
340
+ const KEYWORD_OPERATORS = {
341
+ and: "&&",
342
+ or: "||",
343
+ not: "!",
344
+ eq: "==",
345
+ ne: "!=",
346
+ lt: "<",
347
+ gt: ">",
348
+ le: "<=",
349
+ ge: ">=",
350
+ div: "/",
351
+ mod: "%",
352
+ empty: "empty"
668
353
  };
669
- function readMappings$1(element, property) {
670
- const inputOutput = findExtension(element, 'camunda:InputOutput');
671
- return listProperty(inputOutput, property)
672
- .filter(parameter => typeof parameter.name === 'string' && parameter.name && !parameter.definition)
673
- .map(parameter => ({
674
- source: typeof parameter.value === 'string' ? parameter.value : '',
675
- target: parameter.name,
676
- }));
354
+ const SYMBOL_OPERATORS = [
355
+ "==",
356
+ "!=",
357
+ "<=",
358
+ ">=",
359
+ "&&",
360
+ "||",
361
+ "<",
362
+ ">",
363
+ "!",
364
+ "+",
365
+ "-",
366
+ "*",
367
+ "/",
368
+ "%",
369
+ "(",
370
+ ")",
371
+ "[",
372
+ "]",
373
+ ".",
374
+ "?",
375
+ ":"
376
+ ];
377
+ const BINARY_PRECEDENCE = [
378
+ ["||"],
379
+ ["&&"],
380
+ ["==", "!="],
381
+ ["<", ">", "<=", ">="],
382
+ ["+", "-"],
383
+ ["*", "/", "%"]
384
+ ];
385
+
386
+ class JuelLexer {
387
+ tokenize(source) {
388
+ const tokens = [];
389
+ let index = 0;
390
+ while (index < source.length) {
391
+ const char = source[index];
392
+ if (/\s/.test(char)) {
393
+ index++;
394
+ } else if (/[0-9]/.test(char) || char === "." && /[0-9]/.test(source[index + 1] ?? "")) {
395
+ const match = /^[0-9]*\.?[0-9]+(?:[eE][+-]?[0-9]+)?/.exec(source.slice(index));
396
+ tokens.push({ kind: "number", text: match[0], value: Number(match[0]) });
397
+ index += match[0].length;
398
+ } else if (char === "'" || char === '"') {
399
+ const { value, length } = this.readString(source, index);
400
+ tokens.push({ kind: "string", text: source.slice(index, index + length), value });
401
+ index += length;
402
+ } else if (/[A-Za-z_$]/.test(char)) {
403
+ const match = /^[A-Za-z_$][A-Za-z0-9_$]*/.exec(source.slice(index));
404
+ const word = match[0];
405
+ const keywordOperator = hasOwn(KEYWORD_OPERATORS, word) ? KEYWORD_OPERATORS[word] : void 0;
406
+ tokens.push(keywordOperator ? { kind: "operator", text: keywordOperator } : { kind: "identifier", text: word });
407
+ index += word.length;
408
+ } else {
409
+ const operator = SYMBOL_OPERATORS.find((candidate) => source.startsWith(candidate, index));
410
+ if (!operator) throw new JuelError(`Unexpected character "${char}"`);
411
+ tokens.push({ kind: "operator", text: operator });
412
+ index += operator.length;
413
+ }
414
+ }
415
+ return tokens;
416
+ }
417
+ readString(source, start) {
418
+ const quote = source[start];
419
+ let value = "";
420
+ for (let index = start + 1; index < source.length; index++) {
421
+ const char = source[index];
422
+ if (char === "\\") {
423
+ value += source[index + 1] ?? "";
424
+ index++;
425
+ } else if (char === quote) {
426
+ return { value, length: index - start + 1 };
427
+ } else {
428
+ value += char;
429
+ }
430
+ }
431
+ throw new JuelError("Unterminated string literal");
432
+ }
677
433
  }
678
- function readCondition(sequenceFlow) {
679
- const condition = readConditionExpression(sequenceFlow);
680
- const isJuel = !condition?.language || condition.language.toLowerCase() === 'juel';
681
- return isJuel ? condition?.body?.trim() || undefined : undefined;
434
+
435
+ class JuelParser {
436
+ constructor(source) {
437
+ this.position = 0;
438
+ this.tokens = new JuelLexer().tokenize(source);
439
+ }
440
+ parse() {
441
+ const node = this.parseExpression();
442
+ const token = this.peek();
443
+ if (token) throw new JuelError(`Unexpected "${token.text}"`);
444
+ return node;
445
+ }
446
+ parseExpression() {
447
+ const test = this.parseBinary(0);
448
+ if (!this.accept("?")) return test;
449
+ const consequent = this.parseExpression();
450
+ this.expect(":");
451
+ const alternate = this.parseExpression();
452
+ return { type: "conditional", test, consequent, alternate };
453
+ }
454
+ parseBinary(level) {
455
+ if (level === BINARY_PRECEDENCE.length) return this.parseUnary();
456
+ let left = this.parseBinary(level + 1);
457
+ let operator = this.acceptAny(BINARY_PRECEDENCE[level]);
458
+ while (operator) {
459
+ const right = this.parseBinary(level + 1);
460
+ left = { type: "binary", operator, left, right };
461
+ operator = this.acceptAny(BINARY_PRECEDENCE[level]);
462
+ }
463
+ return left;
464
+ }
465
+ parseUnary() {
466
+ const operator = this.acceptAny(["!", "-", "empty"]);
467
+ if (operator) return { type: "unary", operator, operand: this.parseUnary() };
468
+ return this.parseMember();
469
+ }
470
+ parseMember() {
471
+ let node = this.parsePrimary();
472
+ for (; ; ) {
473
+ if (this.accept(".")) {
474
+ const property = this.next();
475
+ if (property?.kind !== "identifier") throw new JuelError('Expected a property name after "."');
476
+ node = { type: "member", object: node, property: { type: "literal", value: property.text } };
477
+ } else if (this.accept("[")) {
478
+ node = { type: "member", object: node, property: this.parseExpression() };
479
+ this.expect("]");
480
+ } else if (this.peek()?.text === "(") {
481
+ throw new JuelError("Method calls are not supported");
482
+ } else {
483
+ return node;
484
+ }
485
+ }
486
+ }
487
+ parsePrimary() {
488
+ const token = this.next();
489
+ if (!token) throw new JuelError("Unexpected end of expression");
490
+ if (token.kind === "number" || token.kind === "string") return { type: "literal", value: token.value };
491
+ if (token.kind === "identifier") return this.identifierOrLiteral(token.text);
492
+ if (token.text === "(") {
493
+ const node = this.parseExpression();
494
+ this.expect(")");
495
+ return node;
496
+ }
497
+ throw new JuelError(`Unexpected "${token.text}"`);
498
+ }
499
+ identifierOrLiteral(name) {
500
+ if (name === "true") return { type: "literal", value: true };
501
+ if (name === "false") return { type: "literal", value: false };
502
+ if (name === "null") return { type: "literal", value: null };
503
+ return { type: "identifier", name };
504
+ }
505
+ peek() {
506
+ return this.tokens[this.position];
507
+ }
508
+ next() {
509
+ return this.tokens[this.position++];
510
+ }
511
+ accept(text) {
512
+ if (this.peek()?.kind !== "operator" || this.peek()?.text !== text) return false;
513
+ this.position++;
514
+ return true;
515
+ }
516
+ acceptAny(operators) {
517
+ return operators.find((operator) => this.accept(operator));
518
+ }
519
+ expect(text) {
520
+ if (!this.accept(text)) throw new JuelError(`Expected "${text}"`);
521
+ }
682
522
  }
683
- function canEvaluate(expression) {
684
- try {
685
- parseJuelTemplate(expression);
686
- return true;
687
- }
688
- catch {
689
- return false;
523
+
524
+ class JuelTemplate {
525
+ constructor(parts) {
526
+ this.parts = parts;
527
+ }
528
+ static parse(text) {
529
+ const parts = [];
530
+ let cursor = 0;
531
+ while (cursor < text.length) {
532
+ const start = JuelTemplate.findExpressionStart(text, cursor);
533
+ if (start === -1) {
534
+ parts.push(text.slice(cursor));
535
+ break;
536
+ }
537
+ if (start > cursor) parts.push(text.slice(cursor, start));
538
+ const end = JuelTemplate.findExpressionEnd(text, start + 2);
539
+ parts.push(new JuelParser(text.slice(start + 2, end)).parse());
540
+ cursor = end + 1;
541
+ }
542
+ return new JuelTemplate(parts);
543
+ }
544
+ evaluate(variables) {
545
+ const evaluator = new JuelEvaluator(variables);
546
+ const [onlyPart] = this.parts;
547
+ if (this.parts.length === 1 && typeof onlyPart !== "string") {
548
+ return evaluator.evaluate(onlyPart);
549
+ }
550
+ return this.parts.map((part) => typeof part === "string" ? part : evaluator.coerceToString(evaluator.evaluate(part))).join("");
551
+ }
552
+ variableNames() {
553
+ const names = /* @__PURE__ */ new Set();
554
+ const visit = (node) => {
555
+ if (node.type === "identifier") names.add(node.name);
556
+ if (node.type === "member") {
557
+ visit(node.object);
558
+ visit(node.property);
559
+ }
560
+ if (node.type === "unary") visit(node.operand);
561
+ if (node.type === "binary") {
562
+ visit(node.left);
563
+ visit(node.right);
564
+ }
565
+ if (node.type === "conditional") {
566
+ visit(node.test);
567
+ visit(node.consequent);
568
+ visit(node.alternate);
569
+ }
570
+ };
571
+ this.parts.forEach((part) => typeof part !== "string" && visit(part));
572
+ return [...names];
573
+ }
574
+ static findExpressionStart(text, from) {
575
+ const dollar = text.indexOf("${", from);
576
+ const hash = text.indexOf("#{", from);
577
+ if (dollar === -1) return hash;
578
+ if (hash === -1) return dollar;
579
+ return Math.min(dollar, hash);
580
+ }
581
+ static findExpressionEnd(text, from) {
582
+ let quote = null;
583
+ for (let index = from; index < text.length; index++) {
584
+ const char = text[index];
585
+ if (quote) {
586
+ if (char === "\\") index++;
587
+ else if (char === quote) quote = null;
588
+ } else if (char === "'" || char === '"') {
589
+ quote = char;
590
+ } else if (char === "}") {
591
+ return index;
592
+ }
690
593
  }
594
+ throw new JuelError('Unterminated expression, missing "}"');
595
+ }
691
596
  }
692
- function readVariableNames$1(expression) {
597
+
598
+ class Camunda7Engine {
599
+ constructor() {
600
+ this.id = "camunda7";
601
+ this.label = "Camunda 7";
602
+ this.expressionLanguage = "JUEL";
603
+ this.taskResultPropagation = "always";
604
+ }
605
+ writeVariable(variables, target, value) {
606
+ return { ...variables, [target]: value };
607
+ }
608
+ readInputMappings(element) {
609
+ return this.readMappings(element, "inputParameters");
610
+ }
611
+ readOutputMappings(element) {
612
+ return this.readMappings(element, "outputParameters");
613
+ }
614
+ readCondition(sequenceFlow) {
615
+ const condition = readConditionExpression(sequenceFlow);
616
+ const isJuel = !condition?.language || condition.language.toLowerCase() === "juel";
617
+ return isJuel ? condition?.body?.trim() || void 0 : void 0;
618
+ }
619
+ canEvaluate(expression) {
693
620
  try {
694
- return readJuelVariableNames(parseJuelTemplate(expression));
695
- }
696
- catch {
697
- return [];
621
+ JuelTemplate.parse(expression);
622
+ return true;
623
+ } catch {
624
+ return false;
698
625
  }
699
- }
700
- function evaluateCamundaExpression(expression, variables) {
626
+ }
627
+ evaluate(expression, variables) {
701
628
  if (!expression) {
702
- return { ok: true, value: null };
629
+ return { ok: true, value: null };
703
630
  }
704
631
  try {
705
- return { ok: true, value: evaluateJuelTemplate(parseJuelTemplate(expression), variables) };
706
- }
707
- catch (error) {
708
- return { ok: false, reason: error.message };
632
+ return { ok: true, value: JuelTemplate.parse(expression).evaluate(variables) };
633
+ } catch (error) {
634
+ return { ok: false, reason: error.message };
709
635
  }
636
+ }
637
+ readVariableNames(expression) {
638
+ try {
639
+ return JuelTemplate.parse(expression).variableNames();
640
+ } catch {
641
+ return [];
642
+ }
643
+ }
644
+ readMappings(element, property) {
645
+ const inputOutput = findExtension(element, "camunda:InputOutput");
646
+ return listProperty(inputOutput, property).filter((parameter) => typeof parameter.name === "string" && parameter.name && !parameter.definition).map((parameter) => ({
647
+ source: typeof parameter.value === "string" ? parameter.value : "",
648
+ target: parameter.name
649
+ }));
650
+ }
710
651
  }
711
652
 
712
- const EXPRESSION_PREFIX = '=';
713
- const zeebeEngine = {
714
- id: 'zeebe',
715
- label: 'Zeebe',
716
- expressionLanguage: 'FEEL',
717
- taskResultPropagation: 'without-output-mappings',
718
- writeVariable: setVariable,
719
- readInputMappings: element => readMappings(element, 'inputParameters'),
720
- readOutputMappings: element => readMappings(element, 'outputParameters'),
721
- readCondition: sequenceFlow => readConditionExpression(sequenceFlow)?.body?.trim() || undefined,
722
- canEvaluate: expression => isFeel(expression) && parsesAsFeel(expression),
723
- evaluate: evaluateZeebeExpression,
724
- readVariableNames,
725
- };
726
- function readMappings(element, property) {
727
- const ioMapping = findExtension(element, 'zeebe:IoMapping');
728
- return listProperty(ioMapping, property)
729
- .filter(parameter => typeof parameter.target === 'string' && parameter.target)
730
- .map(parameter => ({ source: String(parameter.source ?? ''), target: parameter.target }));
731
- }
732
- function evaluateZeebeExpression(expression, variables) {
733
- if (!isFeel(expression)) {
734
- return { ok: true, value: expression };
653
+ const EXPRESSION_PREFIX = "=";
654
+ class ZeebeEngine {
655
+ constructor() {
656
+ this.id = "zeebe";
657
+ this.label = "Zeebe";
658
+ this.expressionLanguage = "FEEL";
659
+ this.taskResultPropagation = "without-output-mappings";
660
+ }
661
+ writeVariable(variables, target, value) {
662
+ return setVariable(variables, target, value);
663
+ }
664
+ readInputMappings(element) {
665
+ return this.readMappings(element, "inputParameters");
666
+ }
667
+ readOutputMappings(element) {
668
+ return this.readMappings(element, "outputParameters");
669
+ }
670
+ readCondition(sequenceFlow) {
671
+ return readConditionExpression(sequenceFlow)?.body?.trim() || void 0;
672
+ }
673
+ canEvaluate(expression) {
674
+ return this.isFeel(expression) && this.parsesAsFeel(expression);
675
+ }
676
+ evaluate(expression, variables) {
677
+ if (!this.isFeel(expression)) {
678
+ return { ok: true, value: expression };
735
679
  }
736
680
  try {
737
- const { value, warnings } = feelin.evaluate(feelBody(expression), variables);
738
- const missingVariable = warnings.find(warning => warning.type === 'NO_VARIABLE_FOUND');
739
- if (value === null && missingVariable) {
740
- return { ok: false, reason: missingVariable.message };
741
- }
742
- return { ok: true, value: toVariableValue(value) };
743
- }
744
- catch (error) {
745
- return { ok: false, reason: `Invalid FEEL: ${error.message}` };
746
- }
747
- }
748
- function readVariableNames(expression) {
749
- if (!isFeel(expression))
750
- return [];
751
- const body = feelBody(expression);
752
- const read = new Set();
753
- const bound = new Set();
754
- feelin.parseExpression(body, {}, undefined).iterate({
755
- enter(node) {
756
- const text = body.slice(node.from, node.to);
757
- if (node.name === 'Name')
758
- bound.add(text);
759
- if (node.name !== 'VariableName')
760
- return;
761
- const isCallee = node.node.parent?.name === 'FunctionInvocation' && node.node.prevSibling === null;
762
- if (!isCallee)
763
- read.add(text);
764
- },
681
+ const { value, warnings } = feelin.evaluate(this.feelBody(expression), variables);
682
+ const missingVariable = warnings.find((warning) => warning.type === "NO_VARIABLE_FOUND");
683
+ if (value === null && missingVariable) {
684
+ return { ok: false, reason: missingVariable.message };
685
+ }
686
+ return { ok: true, value: this.toVariableValue(value) };
687
+ } catch (error) {
688
+ return { ok: false, reason: `Invalid FEEL: ${error.message}` };
689
+ }
690
+ }
691
+ readVariableNames(expression) {
692
+ if (!this.isFeel(expression)) return [];
693
+ const body = this.feelBody(expression);
694
+ const read = /* @__PURE__ */ new Set();
695
+ const bound = /* @__PURE__ */ new Set();
696
+ feelin.parseExpression(body, {}, void 0).iterate({
697
+ enter(node) {
698
+ const text = body.slice(node.from, node.to);
699
+ if (node.name === "Name") bound.add(text);
700
+ if (node.name !== "VariableName") return;
701
+ const isCallee = node.node.parent?.name === "FunctionInvocation" && node.node.prevSibling === null;
702
+ if (!isCallee) read.add(text);
703
+ }
765
704
  });
766
- return [...read].filter(name => !bound.has(name));
767
- }
768
- function toVariableValue(value) {
769
- if (value === undefined)
770
- return null;
771
- return typeof value === 'object' && value !== null ? JSON.parse(JSON.stringify(value)) : value;
772
- }
773
- function parsesAsFeel(expression) {
705
+ return [...read].filter((name) => !bound.has(name));
706
+ }
707
+ readMappings(element, property) {
708
+ const ioMapping = findExtension(element, "zeebe:IoMapping");
709
+ return listProperty(ioMapping, property).filter((parameter) => typeof parameter.target === "string" && parameter.target).map((parameter) => ({ source: String(parameter.source ?? ""), target: parameter.target }));
710
+ }
711
+ toVariableValue(value) {
712
+ if (value === void 0) return null;
713
+ return typeof value === "object" && value !== null ? JSON.parse(JSON.stringify(value)) : value;
714
+ }
715
+ parsesAsFeel(expression) {
774
716
  try {
775
- feelin.evaluate(feelBody(expression), {});
776
- return true;
777
- }
778
- catch {
779
- return false;
717
+ feelin.evaluate(this.feelBody(expression), {});
718
+ return true;
719
+ } catch {
720
+ return false;
780
721
  }
781
- }
782
- function isFeel(expression) {
722
+ }
723
+ isFeel(expression) {
783
724
  return expression.trimStart().startsWith(EXPRESSION_PREFIX);
784
- }
785
- function feelBody(expression) {
725
+ }
726
+ feelBody(expression) {
786
727
  return expression.trimStart().slice(EXPRESSION_PREFIX.length);
728
+ }
787
729
  }
788
730
 
789
- const ENGINES = {
790
- zeebe: zeebeEngine,
791
- camunda7: camunda7Engine,
792
- };
793
- function resolveEngine(engine) {
794
- if (typeof engine !== 'string')
795
- return engine;
796
- const adapter = ENGINES[engine];
731
+ const zeebeEngine = new ZeebeEngine();
732
+ const camunda7Engine = new Camunda7Engine();
733
+
734
+ class EngineRegistry {
735
+ constructor() {
736
+ this.engines = {
737
+ zeebe: zeebeEngine,
738
+ camunda7: camunda7Engine
739
+ };
740
+ }
741
+ resolve(engine) {
742
+ if (typeof engine !== "string") return engine;
743
+ const adapter = this.engines[engine];
797
744
  if (!adapter) {
798
- throw new Error(`Unknown engine "${engine}", expected one of: ${Object.keys(ENGINES).join(', ')}`);
745
+ throw new Error(`Unknown engine "${engine}", expected one of: ${Object.keys(this.engines).join(", ")}`);
799
746
  }
800
747
  return adapter;
748
+ }
801
749
  }
802
750
 
803
751
  class DataSimulationStore {
804
- constructor() {
805
- this.engineLabel = '';
806
- this.expressionLanguage = '';
807
- this.scenarios = [];
808
- this.selectedScenarioId = null;
809
- this.startVariables = {};
810
- this.instances = new Map();
811
- this.selectedInstanceId = null;
812
- this.log = [];
813
- this.nextLogId = 1;
814
- this.listeners = new Set();
815
- }
816
- setEngine(label, expressionLanguage) {
817
- this.engineLabel = label;
818
- this.expressionLanguage = expressionLanguage;
819
- this.emit();
820
- }
821
- setScenarios(scenarios) {
822
- this.scenarios = scenarios;
823
- this.selectScenario(scenarios[0]?.id ?? null);
824
- }
825
- selectScenario(scenarioId) {
826
- const scenario = this.scenarios.find(candidate => candidate.id === scenarioId);
827
- this.selectedScenarioId = scenario?.id ?? null;
828
- this.startVariables = scenario ? structuredClone(scenario.variables) : {};
829
- this.emit();
830
- }
831
- setStartVariables(variables) {
832
- this.startVariables = structuredClone(variables);
833
- this.emit();
834
- }
835
- startInstance(id, processName) {
836
- this.instances.set(id, {
837
- id,
838
- number: this.instances.size + 1,
839
- processName,
840
- scenarioId: this.selectedScenarioId,
841
- status: 'running',
842
- variables: structuredClone(this.startVariables),
843
- waiting: [],
844
- });
845
- this.selectedInstanceId = id;
846
- this.emit();
847
- }
848
- selectInstance(instanceId) {
849
- if (!this.instances.has(instanceId))
850
- return;
851
- this.selectedInstanceId = instanceId;
852
- this.emit();
853
- }
854
- completeInstance(id) {
855
- this.updateInstance(id, instance => ({ ...instance, status: 'completed', waiting: [] }));
856
- }
857
- hasInstance(id) {
858
- return this.instances.has(id);
859
- }
860
- getTaskResult(instanceId, elementId) {
861
- const scenarioId = this.instances.get(instanceId)?.scenarioId;
862
- return this.scenarios.find(scenario => scenario.id === scenarioId)?.taskResults[elementId];
863
- }
864
- getVariables(instanceId) {
865
- return this.instances.get(instanceId)?.variables ?? {};
866
- }
867
- setVariables(instanceId, variables) {
868
- this.updateInstance(instanceId, instance => ({ ...instance, variables: structuredClone(variables) }));
869
- }
870
- addWaiting(instanceId, waiting) {
871
- this.updateInstance(instanceId, instance => ({ ...instance, waiting: [...instance.waiting, waiting] }));
872
- }
873
- removeWaiting(scopeId) {
874
- const instance = [...this.instances.values()].find(candidate => candidate.waiting.some(waiting => waiting.scopeId === scopeId));
875
- if (!instance)
876
- return;
877
- this.updateInstance(instance.id, current => ({
878
- ...current,
879
- waiting: current.waiting.filter(waiting => waiting.scopeId !== scopeId),
880
- }));
881
- }
882
- record(entry) {
883
- this.log = [...this.log, { ...entry, id: this.nextLogId++ }];
884
- this.emit();
885
- }
886
- reset() {
887
- this.instances.clear();
888
- this.selectedInstanceId = null;
889
- this.log = [];
890
- this.emit();
891
- }
892
- getSnapshot() {
893
- return {
894
- engineLabel: this.engineLabel,
895
- expressionLanguage: this.expressionLanguage,
896
- scenarios: this.scenarios,
897
- selectedScenarioId: this.selectedScenarioId,
898
- startVariables: this.startVariables,
899
- instances: [...this.instances.values()].map(withStatus),
900
- selectedInstanceId: this.selectedInstanceId,
901
- log: this.log,
902
- };
903
- }
904
- subscribe(listener) {
905
- this.listeners.add(listener);
906
- return () => this.listeners.delete(listener);
907
- }
908
- updateInstance(id, update) {
909
- const instance = this.instances.get(id);
910
- if (!instance)
911
- return;
912
- this.instances.set(id, update(instance));
913
- this.emit();
914
- }
915
- emit() {
916
- const snapshot = this.getSnapshot();
917
- for (const listener of [...this.listeners])
918
- listener(snapshot);
919
- }
920
- }
921
- function withStatus(instance) {
922
- if (instance.status === 'completed')
923
- return instance;
924
- return { ...instance, status: instance.waiting.length ? 'waiting' : 'running' };
752
+ constructor() {
753
+ this.engineLabel = "";
754
+ this.expressionLanguage = "";
755
+ this.scenarios = [];
756
+ this.selectedScenarioId = null;
757
+ this.startVariables = {};
758
+ this.instances = /* @__PURE__ */ new Map();
759
+ this.selectedInstanceId = null;
760
+ this.log = [];
761
+ this.nextLogId = 1;
762
+ this.listeners = /* @__PURE__ */ new Set();
763
+ }
764
+ setEngine(label, expressionLanguage) {
765
+ this.engineLabel = label;
766
+ this.expressionLanguage = expressionLanguage;
767
+ this.emit();
768
+ }
769
+ setScenarios(scenarios) {
770
+ this.scenarios = scenarios;
771
+ this.selectScenario(scenarios[0]?.id ?? null);
772
+ }
773
+ selectScenario(scenarioId) {
774
+ const scenario = this.scenarios.find((candidate) => candidate.id === scenarioId);
775
+ this.selectedScenarioId = scenario?.id ?? null;
776
+ this.startVariables = scenario ? structuredClone(scenario.variables) : {};
777
+ this.emit();
778
+ }
779
+ setStartVariables(variables) {
780
+ this.startVariables = structuredClone(variables);
781
+ this.emit();
782
+ }
783
+ startInstance(id, processName) {
784
+ this.instances.set(id, {
785
+ id,
786
+ number: this.instances.size + 1,
787
+ processName,
788
+ scenarioId: this.selectedScenarioId,
789
+ status: "running",
790
+ variables: structuredClone(this.startVariables),
791
+ waiting: []
792
+ });
793
+ this.selectedInstanceId = id;
794
+ this.emit();
795
+ }
796
+ selectInstance(instanceId) {
797
+ if (!this.instances.has(instanceId)) return;
798
+ this.selectedInstanceId = instanceId;
799
+ this.emit();
800
+ }
801
+ completeInstance(id) {
802
+ this.updateInstance(id, (instance) => ({ ...instance, status: "completed", waiting: [] }));
803
+ }
804
+ hasInstance(id) {
805
+ return this.instances.has(id);
806
+ }
807
+ getTaskResult(instanceId, elementId) {
808
+ const scenarioId = this.instances.get(instanceId)?.scenarioId;
809
+ return this.scenarios.find((scenario) => scenario.id === scenarioId)?.taskResults[elementId];
810
+ }
811
+ getVariables(instanceId) {
812
+ return this.instances.get(instanceId)?.variables ?? {};
813
+ }
814
+ setVariables(instanceId, variables) {
815
+ this.updateInstance(instanceId, (instance) => ({ ...instance, variables: structuredClone(variables) }));
816
+ }
817
+ addWaiting(instanceId, waiting) {
818
+ this.updateInstance(instanceId, (instance) => ({ ...instance, waiting: [...instance.waiting, waiting] }));
819
+ }
820
+ removeWaiting(scopeId) {
821
+ const instance = [...this.instances.values()].find(
822
+ (candidate) => candidate.waiting.some((waiting) => waiting.scopeId === scopeId)
823
+ );
824
+ if (!instance) return;
825
+ this.updateInstance(instance.id, (current) => ({
826
+ ...current,
827
+ waiting: current.waiting.filter((waiting) => waiting.scopeId !== scopeId)
828
+ }));
829
+ }
830
+ record(entry) {
831
+ this.log = [...this.log, { ...entry, id: this.nextLogId++ }];
832
+ this.emit();
833
+ }
834
+ reset() {
835
+ this.instances.clear();
836
+ this.selectedInstanceId = null;
837
+ this.log = [];
838
+ this.emit();
839
+ }
840
+ getSnapshot() {
841
+ return {
842
+ engineLabel: this.engineLabel,
843
+ expressionLanguage: this.expressionLanguage,
844
+ scenarios: this.scenarios,
845
+ selectedScenarioId: this.selectedScenarioId,
846
+ startVariables: this.startVariables,
847
+ instances: [...this.instances.values()].map((instance) => this.withStatus(instance)),
848
+ selectedInstanceId: this.selectedInstanceId,
849
+ log: this.log
850
+ };
851
+ }
852
+ subscribe(listener) {
853
+ this.listeners.add(listener);
854
+ return () => this.listeners.delete(listener);
855
+ }
856
+ updateInstance(id, update) {
857
+ const instance = this.instances.get(id);
858
+ if (!instance) return;
859
+ this.instances.set(id, update(instance));
860
+ this.emit();
861
+ }
862
+ emit() {
863
+ const snapshot = this.getSnapshot();
864
+ for (const listener of [...this.listeners]) listener(snapshot);
865
+ }
866
+ withStatus(instance) {
867
+ if (instance.status === "completed") return instance;
868
+ return { ...instance, status: instance.waiting.length ? "waiting" : "running" };
869
+ }
925
870
  }
926
871
 
927
872
  function h(tag, attributes = {}, ...children) {
928
- const element = document.createElement(tag);
929
- for (const [name, value] of Object.entries(attributes)) {
930
- if (name === 'className')
931
- element.className = value;
932
- else
933
- element.setAttribute(name, value);
934
- }
935
- for (const child of children) {
936
- if (child)
937
- element.append(child);
938
- }
939
- return element;
873
+ const element = document.createElement(tag);
874
+ for (const [name, value] of Object.entries(attributes)) {
875
+ if (name === "className") element.className = value;
876
+ else element.setAttribute(name, value);
877
+ }
878
+ for (const child of children) {
879
+ if (child) element.append(child);
880
+ }
881
+ return element;
940
882
  }
941
883
  function formatValue(value) {
942
- if (value === undefined)
943
- return 'undefined';
944
- return JSON.stringify(value) ?? String(value);
884
+ if (value === void 0) return "undefined";
885
+ return JSON.stringify(value) ?? String(value);
945
886
  }
946
887
 
947
- const simpleStartFormRenderer = {
948
- render(container, fields, values) {
949
- const inputs = new Map();
950
- const form = h('div', { className: 'bds-form' });
951
- for (const field of fields) {
952
- const input = createInput(field);
953
- inputs.set(field.name, input);
954
- form.append(renderField(field, input));
955
- }
956
- for (const field of fields)
957
- writeInput(inputs.get(field.name), formatFieldValue(field, values[field.name]));
958
- container.append(form);
959
- return {
960
- readValues() {
961
- const result = {};
962
- for (const field of fields) {
963
- const input = inputs.get(field.name);
964
- const parsed = parseFieldValue(field, input.type === 'checkbox' ? input.checked : input.value);
965
- if (!parsed.ok)
966
- return parsed;
967
- result[field.name] = parsed.value;
968
- }
969
- return { ok: true, values: result };
970
- },
971
- focus() {
972
- inputs.values().next().value?.focus();
973
- },
974
- destroy() {
975
- form.remove();
976
- },
977
- };
978
- },
979
- };
980
- function renderField(field, input) {
888
+ class SimpleStartForm {
889
+ constructor(container, fields, values) {
890
+ this.fields = fields;
891
+ this.codec = new StartFieldCodec();
892
+ this.inputs = /* @__PURE__ */ new Map();
893
+ this.form = h("div", { className: "bds-form" });
894
+ for (const field of fields) {
895
+ const input = this.createInput(field);
896
+ this.inputs.set(field.name, input);
897
+ this.form.append(this.renderField(field, input));
898
+ }
899
+ for (const field of fields)
900
+ this.writeInput(this.inputs.get(field.name), this.codec.format(field, values[field.name]));
901
+ container.append(this.form);
902
+ }
903
+ readValues() {
904
+ const result = {};
905
+ for (const field of this.fields) {
906
+ const input = this.inputs.get(field.name);
907
+ const parsed = this.codec.parse(
908
+ field,
909
+ input.type === "checkbox" ? input.checked : input.value
910
+ );
911
+ if (!parsed.ok) return parsed;
912
+ result[field.name] = parsed.value;
913
+ }
914
+ return { ok: true, values: result };
915
+ }
916
+ focus() {
917
+ this.inputs.values().next().value?.focus();
918
+ }
919
+ destroy() {
920
+ this.form.remove();
921
+ }
922
+ renderField(field, input) {
981
923
  const id = `bds-field-${field.name}`;
982
924
  input.id = id;
983
- const hint = h('span', { className: 'bds-field-hint' }, `Used by ${field.usedBy.join(', ')}`);
984
- if (field.type === 'boolean') {
985
- return h('div', { className: 'bds-field bds-field--checkbox' }, h('label', { className: 'bds-checkbox', for: id }, input, h('span', { className: 'bds-field-name' }, field.name)), hint);
986
- }
987
- return h('div', { className: 'bds-field' }, h('label', { className: 'bds-field-name', for: id }, field.name), input, hint);
925
+ const hint = h("span", { className: "bds-field-hint" }, `Used by ${field.usedBy.join(", ")}`);
926
+ if (field.type === "boolean") {
927
+ return h(
928
+ "div",
929
+ { className: "bds-field bds-field--checkbox" },
930
+ h(
931
+ "label",
932
+ { className: "bds-checkbox", for: id },
933
+ input,
934
+ h("span", { className: "bds-field-name" }, field.name)
935
+ ),
936
+ hint
937
+ );
938
+ }
939
+ return h(
940
+ "div",
941
+ { className: "bds-field" },
942
+ h("label", { className: "bds-field-name", for: id }, field.name),
943
+ input,
944
+ hint
945
+ );
946
+ }
947
+ createInput(field) {
948
+ if (field.type === "boolean") return h("input", { type: "checkbox", name: field.name });
949
+ if (field.type === "json") {
950
+ return h("textarea", { className: "bds-input bds-json", name: field.name, rows: "2", spellcheck: "false" });
951
+ }
952
+ const type = field.type === "number" ? "number" : "text";
953
+ return h("input", { className: "bds-input", type, name: field.name, step: "any", autocomplete: "off" });
954
+ }
955
+ writeInput(input, value) {
956
+ if (typeof value === "boolean") input.checked = value;
957
+ else input.value = value;
958
+ }
988
959
  }
989
- function createInput(field) {
990
- if (field.type === 'boolean')
991
- return h('input', { type: 'checkbox', name: field.name });
992
- if (field.type === 'json') {
993
- return h('textarea', { className: 'bds-input bds-json', name: field.name, rows: '2', spellcheck: 'false' });
994
- }
995
- const type = field.type === 'number' ? 'number' : 'text';
996
- return h('input', { className: 'bds-input', type, name: field.name, step: 'any', autocomplete: 'off' });
997
- }
998
- function writeInput(input, value) {
999
- if (typeof value === 'boolean')
1000
- input.checked = value;
1001
- else
1002
- input.value = value;
960
+
961
+ class SimpleStartFormRenderer {
962
+ render(container, fields, values) {
963
+ return new SimpleStartForm(container, fields, values);
964
+ }
1003
965
  }
1004
966
 
1005
- const FLOW_CHOICE_TYPES = ['bpmn:ExclusiveGateway', 'bpmn:InclusiveGateway'];
1006
- const TRIGGER_TYPE = 'bpmn:Event';
967
+ const FLOW_CHOICE_TYPES = ["bpmn:ExclusiveGateway", "bpmn:InclusiveGateway"];
968
+ const TRIGGER_TYPE = "bpmn:Event";
1007
969
  class DataContextPads {
1008
- constructor(contextPads, dataGateways, startForm, dataSimulation) {
1009
- for (const { handler, type } of contextPads._handlers) {
1010
- if (FLOW_CHOICE_TYPES.includes(type))
1011
- hideOnDataDrivenGateways(handler, dataGateways);
1012
- if (type === TRIGGER_TYPE)
1013
- openStartFormOnProcessStart(handler, startForm, dataSimulation);
1014
- }
1015
- }
1016
- }
1017
- DataContextPads.$inject = ['contextPads', 'dataGateways', 'dataStartForm', 'dataSimulation'];
1018
- function hideOnDataDrivenGateways(handler, dataGateways) {
970
+ constructor(contextPads, dataGateways, startForm, dataSimulation) {
971
+ this.dataGateways = dataGateways;
972
+ this.startForm = startForm;
973
+ this.dataSimulation = dataSimulation;
974
+ for (const { handler, type } of contextPads._handlers) {
975
+ if (FLOW_CHOICE_TYPES.includes(type)) this.hideOnDataDrivenGateways(handler);
976
+ if (type === TRIGGER_TYPE) this.openStartFormOnProcessStart(handler);
977
+ }
978
+ }
979
+ hideOnDataDrivenGateways(handler) {
1019
980
  const createContextPads = handler.createContextPads.bind(handler);
1020
- handler.createContextPads = element => (dataGateways.isDataDriven(element) ? undefined : createContextPads(element));
1021
- }
1022
- function openStartFormOnProcessStart(handler, startForm, dataSimulation) {
981
+ handler.createContextPads = (element) => this.dataGateways.isDataDriven(element) ? void 0 : createContextPads(element);
982
+ }
983
+ openStartFormOnProcessStart(handler) {
1023
984
  const createContextPads = handler.createContextPads.bind(handler);
1024
- handler.createContextPads = element => {
1025
- const pads = createContextPads(element);
1026
- if (!dataSimulation.isEnabled() || !startForm.isProcessStart(element))
1027
- return pads;
1028
- return []
1029
- .concat(pads)
1030
- .map(pad => pad?.action
1031
- ? { ...pad, action: (contexts) => startForm.open(element, () => pad.action(contexts)) }
1032
- : pad);
985
+ handler.createContextPads = (element) => {
986
+ const pads = createContextPads(element);
987
+ if (!this.dataSimulation.isEnabled() || !this.startForm.isProcessStart(element)) return pads;
988
+ return [].concat(pads).map(
989
+ (pad) => pad?.action ? { ...pad, action: (contexts) => this.startForm.open(element, () => pad.action(contexts)) } : pad
990
+ );
1033
991
  };
992
+ }
1034
993
  }
994
+ DataContextPads.$inject = ["contextPads", "dataGateways", "dataStartForm", "dataSimulation"];
1035
995
 
1036
996
  class DataGatewayBehaviors {
1037
- constructor(exclusive, inclusive, dataGateways) {
1038
- routeByData(exclusive, 'exclusive', dataGateways);
1039
- routeByData(inclusive, 'inclusive', dataGateways);
1040
- }
1041
- }
1042
- DataGatewayBehaviors.$inject = ['exclusiveGatewayBehavior', 'inclusiveGatewayBehavior', 'dataGateways'];
1043
- function routeByData(behavior, kind, dataGateways) {
997
+ constructor(exclusive, inclusive, dataGateways) {
998
+ this.dataGateways = dataGateways;
999
+ this.routeByData(exclusive, "exclusive");
1000
+ this.routeByData(inclusive, "inclusive");
1001
+ }
1002
+ routeByData(behavior, kind) {
1044
1003
  const exitByClick = behavior.exit.bind(behavior);
1045
- behavior.exit = context => {
1046
- if (dataGateways.isDataDriven(context.element)) {
1047
- dataGateways.exit(context, kind);
1048
- }
1049
- else {
1050
- dataGateways.recordClickDecision(context, kind);
1051
- exitByClick(context);
1052
- }
1004
+ behavior.exit = (context) => {
1005
+ if (this.dataGateways.isDataDriven(context.element)) {
1006
+ this.dataGateways.exit(context, kind);
1007
+ } else {
1008
+ this.dataGateways.recordClickDecision(context, kind);
1009
+ exitByClick(context);
1010
+ }
1053
1011
  };
1012
+ }
1054
1013
  }
1014
+ DataGatewayBehaviors.$inject = ["exclusiveGatewayBehavior", "inclusiveGatewayBehavior", "dataGateways"];
1055
1015
 
1056
1016
  class DataGatewaySettings {
1057
- constructor(exclusive, inclusive, dataGateways) {
1058
- const onlyForClickGateways = (method) => {
1059
- return (gateway, ...rest) => {
1060
- if (!dataGateways.isDataDriven(gateway))
1061
- method(gateway, ...rest);
1062
- };
1063
- };
1064
- exclusive.setSequenceFlow = onlyForClickGateways(exclusive.setSequenceFlow.bind(exclusive));
1065
- inclusive._setGatewayDefaults = onlyForClickGateways(inclusive._setGatewayDefaults.bind(inclusive));
1066
- inclusive.toggleSequenceFlow = onlyForClickGateways(inclusive.toggleSequenceFlow.bind(inclusive));
1067
- }
1017
+ constructor(exclusive, inclusive, dataGateways) {
1018
+ this.dataGateways = dataGateways;
1019
+ exclusive.setSequenceFlow = this.onlyForClickGateways(exclusive.setSequenceFlow.bind(exclusive));
1020
+ inclusive._setGatewayDefaults = this.onlyForClickGateways(inclusive._setGatewayDefaults.bind(inclusive));
1021
+ inclusive.toggleSequenceFlow = this.onlyForClickGateways(inclusive.toggleSequenceFlow.bind(inclusive));
1022
+ }
1023
+ onlyForClickGateways(method) {
1024
+ return (gateway, ...rest) => {
1025
+ if (!this.dataGateways.isDataDriven(gateway)) method(gateway, ...rest);
1026
+ };
1027
+ }
1068
1028
  }
1069
- DataGatewaySettings.$inject = ['exclusiveGatewaySettings', 'inclusiveGatewaySettings', 'dataGateways'];
1029
+ DataGatewaySettings.$inject = ["exclusiveGatewaySettings", "inclusiveGatewaySettings", "dataGateways"];
1070
1030
 
1071
- const TOGGLE_MODE_EVENT = 'tokenSimulation.toggleMode';
1072
- const RESET_SIMULATION_EVENT = 'tokenSimulation.resetSimulation';
1073
- const SCOPE_CREATE_EVENT = 'tokenSimulation.simulator.createScope';
1074
- const SCOPE_DESTROYED_EVENT = 'tokenSimulation.simulator.destroyScope';
1075
- const TRACE_EVENT = 'tokenSimulation.simulator.trace';
1076
- const DATA_TOGGLE_EVENT = 'dataSimulation.toggle';
1077
1031
  function findProcessInstance(scope) {
1078
- let current = scope;
1079
- while (current.parent)
1080
- current = current.parent;
1081
- return current;
1032
+ let current = scope;
1033
+ while (current.parent) current = current.parent;
1034
+ return current;
1082
1035
  }
1083
1036
  function elementName(element) {
1084
- const name = element.businessObject.name;
1085
- return typeof name === 'string' && name.trim() ? name.trim() : element.id;
1037
+ const name = element.businessObject.name;
1038
+ return typeof name === "string" && name.trim() ? name.trim() : element.id;
1086
1039
  }
1087
1040
  function is(element, type) {
1088
- const businessObject = element.businessObject;
1089
- return typeof businessObject?.$instanceOf === 'function' && businessObject.$instanceOf(type);
1041
+ const businessObject = element.businessObject;
1042
+ return typeof businessObject?.$instanceOf === "function" && businessObject.$instanceOf(type);
1043
+ }
1044
+ function isGateway(element) {
1045
+ return element.type === "bpmn:ExclusiveGateway" || element.type === "bpmn:InclusiveGateway";
1046
+ }
1047
+ function gatewayOf(element) {
1048
+ if (isGateway(element)) return element.id;
1049
+ if (element.type === "bpmn:SequenceFlow" && element.source && isGateway(element.source)) return element.source.id;
1050
+ return void 0;
1090
1051
  }
1091
1052
 
1092
1053
  class DataGateways {
1093
- constructor(dataSimulation, store, simulator) {
1094
- this.dataSimulation = dataSimulation;
1095
- this.store = store;
1096
- this.simulator = simulator;
1097
- }
1098
- isDataDriven(gateway) {
1099
- const engine = this.dataSimulation.getEngine();
1100
- const outgoing = this.outgoingFlows(gateway);
1101
- return (this.dataSimulation.isEnabled() &&
1102
- outgoing.length > 1 &&
1103
- outgoing
1104
- .filter(flow => !flow.isDefault)
1105
- .every(flow => flow.expression !== undefined && engine.canEvaluate(flow.expression)));
1106
- }
1107
- exit(context, kind) {
1108
- const { element: gateway, scope } = context;
1109
- const decision = this.decide(gateway, scope, kind);
1110
- if (decision.stuckReason) {
1111
- this.waitForRetry(gateway, scope);
1112
- return;
1113
- }
1114
- for (const flowId of decision.takenFlowIds) {
1115
- const flow = this.sequenceFlows(gateway).find(candidate => candidate.id === flowId);
1116
- this.simulator.enter({ element: flow, scope: scope.parent });
1117
- }
1118
- }
1119
- recordClickDecision(context, kind) {
1120
- if (!this.dataSimulation.isEnabled())
1121
- return;
1122
- const { element: gateway, scope } = context;
1123
- const { activeOutgoing } = this.simulator.getConfig(gateway);
1124
- const chosen = [].concat(activeOutgoing ?? []);
1125
- const outgoing = this.outgoingFlows(gateway);
1126
- if (outgoing.length < 2 || !chosen.length)
1127
- return;
1128
- const flows = outgoing.map(flow => chosen.some(candidate => candidate.id === flow.id)
1129
- ? { flow, outcome: 'taken', reason: 'Chosen by click' }
1130
- : { flow, outcome: 'skipped', reason: 'Not chosen by click' });
1131
- const decision = {
1132
- flows,
1133
- takenFlowIds: flows.filter(flow => flow.outcome === 'taken').map(flow => flow.flow.id),
1134
- };
1135
- this.record(gateway, scope, kind, 'click', decision, []);
1136
- }
1137
- decide(gateway, scope, kind) {
1138
- const engine = this.dataSimulation.getEngine();
1139
- const variables = this.dataSimulation.getVariables(scope);
1140
- const outgoing = this.outgoingFlows(gateway);
1141
- const decision = routeGateway(kind, outgoing, expression => engine.evaluate(expression, variables));
1142
- const names = outgoing.flatMap(flow => (flow.expression ? engine.readVariableNames(flow.expression) : []));
1143
- const inputs = [...new Set(names)].map(name => ({ name, value: structuredClone(variables[name]) }));
1144
- this.record(gateway, scope, kind, 'data', decision, inputs);
1145
- return decision;
1146
- }
1147
- record(gateway, scope, gatewayKind, chosenBy, decision, inputs) {
1054
+ constructor(dataSimulation, store, simulator) {
1055
+ this.dataSimulation = dataSimulation;
1056
+ this.store = store;
1057
+ this.simulator = simulator;
1058
+ this.router = new GatewayRouter();
1059
+ }
1060
+ isDataDriven(gateway) {
1061
+ const engine = this.dataSimulation.getEngine();
1062
+ const outgoing = this.outgoingFlows(gateway);
1063
+ return this.dataSimulation.isEnabled() && outgoing.length > 1 && outgoing.filter((flow) => !flow.isDefault).every((flow) => flow.expression !== void 0 && engine.canEvaluate(flow.expression));
1064
+ }
1065
+ exit(context, kind) {
1066
+ const { element: gateway, scope } = context;
1067
+ const decision = this.decide(gateway, scope, kind);
1068
+ if (decision.stuckReason) {
1069
+ this.waitForRetry(gateway, scope);
1070
+ return;
1071
+ }
1072
+ for (const flowId of decision.takenFlowIds) {
1073
+ const flow = this.sequenceFlows(gateway).find((candidate) => candidate.id === flowId);
1074
+ this.simulator.enter({ element: flow, scope: scope.parent });
1075
+ }
1076
+ }
1077
+ recordClickDecision(context, kind) {
1078
+ if (!this.dataSimulation.isEnabled()) return;
1079
+ const { element: gateway, scope } = context;
1080
+ const { activeOutgoing } = this.simulator.getConfig(gateway);
1081
+ const chosen = [].concat(activeOutgoing ?? []);
1082
+ const outgoing = this.outgoingFlows(gateway);
1083
+ if (outgoing.length < 2 || !chosen.length) return;
1084
+ const flows = outgoing.map(
1085
+ (flow) => chosen.some((candidate) => candidate.id === flow.id) ? { flow, outcome: "taken", reason: "Chosen by click" } : { flow, outcome: "skipped", reason: "Not chosen by click" }
1086
+ );
1087
+ const decision = {
1088
+ flows,
1089
+ takenFlowIds: flows.filter((flow) => flow.outcome === "taken").map((flow) => flow.flow.id)
1090
+ };
1091
+ this.record(gateway, scope, kind, "click", decision, []);
1092
+ }
1093
+ decide(gateway, scope, kind) {
1094
+ const engine = this.dataSimulation.getEngine();
1095
+ const variables = this.dataSimulation.getVariables(scope);
1096
+ const outgoing = this.outgoingFlows(gateway);
1097
+ const decision = this.router.route(kind, outgoing, (expression) => engine.evaluate(expression, variables));
1098
+ const names = outgoing.flatMap((flow) => flow.expression ? engine.readVariableNames(flow.expression) : []);
1099
+ const inputs = [...new Set(names)].map((name) => ({ name, value: structuredClone(variables[name]) }));
1100
+ this.record(gateway, scope, kind, "data", decision, inputs);
1101
+ return decision;
1102
+ }
1103
+ record(gateway, scope, gatewayKind, chosenBy, decision, inputs) {
1104
+ this.store.record({
1105
+ kind: "decision",
1106
+ instanceId: findProcessInstance(scope).id,
1107
+ elementId: gateway.id,
1108
+ elementName: elementName(gateway),
1109
+ gatewayKind,
1110
+ chosenBy,
1111
+ decision,
1112
+ inputs
1113
+ });
1114
+ }
1115
+ waitForRetry(gateway, scope) {
1116
+ const waitingScope = this.simulator.createScope({ element: gateway, parent: scope.parent, initiator: scope }).start();
1117
+ this.store.addWaiting(findProcessInstance(scope).id, {
1118
+ scopeId: waitingScope.id,
1119
+ gatewayId: gateway.id,
1120
+ gatewayName: elementName(gateway)
1121
+ });
1122
+ const retry = { element: gateway, type: "continue", interrupting: false, boundary: false };
1123
+ const subscription = this.simulator.subscribe(waitingScope, retry, (initiator) => {
1124
+ subscription.remove();
1125
+ this.store.removeWaiting(waitingScope.id);
1126
+ this.simulator.exit({ element: gateway, scope: waitingScope, initiator });
1127
+ });
1128
+ }
1129
+ outgoingFlows(gateway) {
1130
+ const engine = this.dataSimulation.getEngine();
1131
+ const defaultFlow = gateway.businessObject.default;
1132
+ return this.sequenceFlows(gateway).map((flow) => {
1133
+ const name = flow.businessObject.name;
1134
+ return {
1135
+ id: flow.id,
1136
+ ...typeof name === "string" && name ? { name } : {},
1137
+ expression: engine.readCondition(flow.businessObject),
1138
+ isDefault: flow.businessObject === defaultFlow
1139
+ };
1140
+ });
1141
+ }
1142
+ sequenceFlows(gateway) {
1143
+ return (gateway.outgoing ?? []).filter((flow) => is(flow, "bpmn:SequenceFlow"));
1144
+ }
1145
+ }
1146
+ DataGateways.$inject = ["dataSimulation", "dataSimulationStore", "simulator"];
1147
+
1148
+ class IoMappings {
1149
+ constructor(engine, store) {
1150
+ this.engine = engine;
1151
+ this.store = store;
1152
+ }
1153
+ apply(element, instanceId) {
1154
+ const inputs = this.engine.readInputMappings(element.businessObject);
1155
+ const outputs = this.engine.readOutputMappings(element.businessObject);
1156
+ const taskResult = this.store.getTaskResult(instanceId, element.id);
1157
+ if (!inputs.length && !outputs.length && !taskResult) return;
1158
+ const processVariables = this.store.getVariables(instanceId);
1159
+ const localVariables = this.evaluate(element, instanceId, inputs, {}, (current) => ({
1160
+ ...processVariables,
1161
+ ...current
1162
+ }));
1163
+ const context = { ...processVariables, ...localVariables, ...taskResult };
1164
+ const propagatesTaskResult = taskResult && (this.engine.taskResultPropagation === "always" || !outputs.length);
1165
+ const withTaskResult = propagatesTaskResult ? { ...processVariables, ...withoutKeys(taskResult, Object.keys(localVariables)) } : processVariables;
1166
+ this.store.setVariables(
1167
+ instanceId,
1168
+ this.evaluate(element, instanceId, outputs, withTaskResult, () => context)
1169
+ );
1170
+ }
1171
+ evaluate(element, instanceId, mappings, target, contextOf) {
1172
+ let result = target;
1173
+ for (const mapping of mappings) {
1174
+ const evaluation = this.engine.evaluate(mapping.source, contextOf(result));
1175
+ if (evaluation.ok) {
1176
+ result = this.engine.writeVariable(result, mapping.target, evaluation.value);
1177
+ } else {
1148
1178
  this.store.record({
1149
- kind: 'decision',
1150
- instanceId: findProcessInstance(scope).id,
1151
- elementId: gateway.id,
1152
- elementName: elementName(gateway),
1153
- gatewayKind,
1154
- chosenBy,
1155
- decision,
1156
- inputs,
1157
- });
1158
- }
1159
- waitForRetry(gateway, scope) {
1160
- const waitingScope = this.simulator
1161
- .createScope({ element: gateway, parent: scope.parent, initiator: scope })
1162
- .start();
1163
- this.store.addWaiting(findProcessInstance(scope).id, {
1164
- scopeId: waitingScope.id,
1165
- gatewayId: gateway.id,
1166
- gatewayName: elementName(gateway),
1167
- });
1168
- const retry = { element: gateway, type: 'continue', interrupting: false, boundary: false };
1169
- const subscription = this.simulator.subscribe(waitingScope, retry, initiator => {
1170
- subscription.remove();
1171
- this.store.removeWaiting(waitingScope.id);
1172
- this.simulator.exit({ element: gateway, scope: waitingScope, initiator });
1173
- });
1174
- }
1175
- outgoingFlows(gateway) {
1176
- const engine = this.dataSimulation.getEngine();
1177
- const defaultFlow = gateway.businessObject.default;
1178
- return this.sequenceFlows(gateway).map(flow => {
1179
- const name = flow.businessObject.name;
1180
- return {
1181
- id: flow.id,
1182
- ...(typeof name === 'string' && name ? { name } : {}),
1183
- expression: engine.readCondition(flow.businessObject),
1184
- isDefault: flow.businessObject === defaultFlow,
1185
- };
1179
+ kind: "mapping-issue",
1180
+ instanceId,
1181
+ elementId: element.id,
1182
+ elementName: elementName(element),
1183
+ target: mapping.target,
1184
+ reason: evaluation.reason
1186
1185
  });
1186
+ }
1187
1187
  }
1188
- sequenceFlows(gateway) {
1189
- return (gateway.outgoing ?? []).filter(flow => is(flow, 'bpmn:SequenceFlow'));
1190
- }
1188
+ return result;
1189
+ }
1191
1190
  }
1192
- DataGateways.$inject = ['dataSimulation', 'dataSimulationStore', 'simulator'];
1191
+
1192
+ const TOGGLE_MODE_EVENT = "tokenSimulation.toggleMode";
1193
+ const RESET_SIMULATION_EVENT = "tokenSimulation.resetSimulation";
1194
+ const SCOPE_CREATE_EVENT = "tokenSimulation.simulator.createScope";
1195
+ const SCOPE_DESTROYED_EVENT = "tokenSimulation.simulator.destroyScope";
1196
+ const TRACE_EVENT = "tokenSimulation.simulator.trace";
1197
+ const DATA_TOGGLE_EVENT = "dataSimulation.toggle";
1193
1198
 
1194
1199
  class DataSimulation {
1195
- constructor(config, eventBus, store) {
1196
- this.eventBus = eventBus;
1197
- this.store = store;
1198
- this.engine = resolveEngine(config?.engine ?? 'zeebe');
1199
- this.enabled = config?.enabled ?? true;
1200
- this.store.setEngine(this.engine.label, this.engine.expressionLanguage);
1201
- if (config?.scenarios !== undefined)
1202
- this.setScenarios(config.scenarios);
1203
- eventBus.on(SCOPE_CREATE_EVENT, ({ scope }) => this.onScopeCreated(scope));
1204
- eventBus.on(SCOPE_DESTROYED_EVENT, ({ scope }) => {
1205
- this.store.completeInstance(scope.id);
1206
- this.store.removeWaiting(scope.id);
1207
- });
1208
- eventBus.on(TRACE_EVENT, (event) => {
1209
- if (event.action === 'exit')
1210
- this.applyMappings(event.element, event.scope);
1211
- });
1212
- eventBus.on([RESET_SIMULATION_EVENT, TOGGLE_MODE_EVENT], () => this.store.reset());
1213
- }
1214
- getEngine() {
1215
- return this.engine;
1216
- }
1217
- isEnabled() {
1218
- return this.enabled;
1219
- }
1220
- setEnabled(enabled) {
1221
- if (enabled === this.enabled)
1222
- return;
1223
- this.enabled = enabled;
1224
- this.store.reset();
1225
- this.eventBus.fire(DATA_TOGGLE_EVENT, { enabled });
1226
- }
1227
- setScenarios(input) {
1228
- this.store.setScenarios(parseScenarios(input));
1229
- }
1230
- selectScenario(scenarioId) {
1231
- this.store.selectScenario(scenarioId);
1232
- }
1233
- setStartVariables(variables) {
1234
- this.store.setStartVariables(variables);
1235
- }
1236
- selectInstance(instanceId) {
1237
- this.store.selectInstance(instanceId);
1238
- }
1239
- setInstanceVariables(instanceId, variables) {
1240
- this.store.setVariables(instanceId, variables);
1241
- }
1242
- getVariables(scope) {
1243
- return this.store.getVariables(findProcessInstance(scope).id);
1244
- }
1245
- getSnapshot() {
1246
- return this.store.getSnapshot();
1247
- }
1248
- subscribe(listener) {
1249
- return this.store.subscribe(listener);
1250
- }
1251
- onScopeCreated(scope) {
1252
- if (!this.enabled || scope.parent || (!is(scope.element, 'bpmn:Process') && !is(scope.element, 'bpmn:Participant')))
1253
- return;
1254
- this.store.startInstance(scope.id, elementName(scope.element));
1255
- }
1256
- applyMappings(element, scope) {
1257
- if (!is(element, 'bpmn:FlowNode') || scope.failed || scope.canceled)
1258
- return;
1259
- const instanceId = findProcessInstance(scope).id;
1260
- if (!this.store.hasInstance(instanceId))
1261
- return;
1262
- const inputs = this.engine.readInputMappings(element.businessObject);
1263
- const outputs = this.engine.readOutputMappings(element.businessObject);
1264
- const taskResult = this.store.getTaskResult(instanceId, element.id);
1265
- if (!inputs.length && !outputs.length && !taskResult)
1266
- return;
1267
- const processVariables = this.store.getVariables(instanceId);
1268
- const localVariables = this.evaluateMappings(element, instanceId, inputs, {}, current => ({
1269
- ...processVariables,
1270
- ...current,
1271
- }));
1272
- const context = { ...processVariables, ...localVariables, ...taskResult };
1273
- const propagatesTaskResult = taskResult && (this.engine.taskResultPropagation === 'always' || !outputs.length);
1274
- const withTaskResult = propagatesTaskResult
1275
- ? { ...processVariables, ...withoutKeys(taskResult, Object.keys(localVariables)) }
1276
- : processVariables;
1277
- this.store.setVariables(instanceId, this.evaluateMappings(element, instanceId, outputs, withTaskResult, () => context));
1200
+ constructor(config, eventBus, store) {
1201
+ this.eventBus = eventBus;
1202
+ this.store = store;
1203
+ this.scenarioParser = new ScenarioParser();
1204
+ this.engine = new EngineRegistry().resolve(config?.engine ?? "zeebe");
1205
+ this.ioMappings = new IoMappings(this.engine, store);
1206
+ this.enabled = config?.enabled ?? true;
1207
+ this.store.setEngine(this.engine.label, this.engine.expressionLanguage);
1208
+ if (config?.scenarios !== void 0) this.setScenarios(config.scenarios);
1209
+ eventBus.on(SCOPE_CREATE_EVENT, ({ scope }) => this.onScopeCreated(scope));
1210
+ eventBus.on(SCOPE_DESTROYED_EVENT, ({ scope }) => {
1211
+ this.store.completeInstance(scope.id);
1212
+ this.store.removeWaiting(scope.id);
1213
+ });
1214
+ eventBus.on(TRACE_EVENT, (event) => {
1215
+ if (event.action === "exit") this.applyMappings(event.element, event.scope);
1216
+ });
1217
+ eventBus.on([RESET_SIMULATION_EVENT, TOGGLE_MODE_EVENT], () => this.store.reset());
1218
+ }
1219
+ getEngine() {
1220
+ return this.engine;
1221
+ }
1222
+ isEnabled() {
1223
+ return this.enabled;
1224
+ }
1225
+ setEnabled(enabled) {
1226
+ if (enabled === this.enabled) return;
1227
+ this.enabled = enabled;
1228
+ this.store.reset();
1229
+ this.eventBus.fire(DATA_TOGGLE_EVENT, { enabled });
1230
+ }
1231
+ setScenarios(input) {
1232
+ this.store.setScenarios(this.scenarioParser.parse(input));
1233
+ }
1234
+ selectScenario(scenarioId) {
1235
+ this.store.selectScenario(scenarioId);
1236
+ }
1237
+ setStartVariables(variables) {
1238
+ this.store.setStartVariables(variables);
1239
+ }
1240
+ selectInstance(instanceId) {
1241
+ this.store.selectInstance(instanceId);
1242
+ }
1243
+ setInstanceVariables(instanceId, variables) {
1244
+ this.store.setVariables(instanceId, variables);
1245
+ }
1246
+ getVariables(scope) {
1247
+ return this.store.getVariables(findProcessInstance(scope).id);
1248
+ }
1249
+ getSnapshot() {
1250
+ return this.store.getSnapshot();
1251
+ }
1252
+ subscribe(listener) {
1253
+ return this.store.subscribe(listener);
1254
+ }
1255
+ onScopeCreated(scope) {
1256
+ if (!this.enabled || scope.parent || !is(scope.element, "bpmn:Process") && !is(scope.element, "bpmn:Participant"))
1257
+ return;
1258
+ this.store.startInstance(scope.id, elementName(scope.element));
1259
+ }
1260
+ applyMappings(element, scope) {
1261
+ if (!is(element, "bpmn:FlowNode") || scope.failed || scope.canceled) return;
1262
+ const instanceId = findProcessInstance(scope).id;
1263
+ if (this.store.hasInstance(instanceId)) this.ioMappings.apply(element, instanceId);
1264
+ }
1265
+ }
1266
+ DataSimulation.$inject = ["config.dataSimulation", "eventBus", "dataSimulationStore"];
1267
+
1268
+ class GatewayDecisionView {
1269
+ constructor(snapshot) {
1270
+ this.snapshot = snapshot;
1271
+ this.decisions = this.latestDecisionPerGateway();
1272
+ const shownPerGateway = new Map(this.decisions.map((entry) => [entry.elementId, entry]));
1273
+ for (const entry of this.latestStuckDecisionPerGateway()) shownPerGateway.set(entry.elementId, entry);
1274
+ this.shown = [...shownPerGateway.values()];
1275
+ }
1276
+ latestDecisionPerGateway() {
1277
+ const { log, selectedInstanceId } = this.snapshot;
1278
+ const latest = /* @__PURE__ */ new Map();
1279
+ for (const entry of log) {
1280
+ if (entry.kind === "decision" && entry.instanceId === selectedInstanceId) latest.set(entry.elementId, entry);
1278
1281
  }
1279
- evaluateMappings(element, instanceId, mappings, target, contextOf) {
1280
- let result = target;
1281
- for (const mapping of mappings) {
1282
- const evaluation = this.engine.evaluate(mapping.source, contextOf(result));
1283
- if (evaluation.ok) {
1284
- result = this.engine.writeVariable(result, mapping.target, evaluation.value);
1285
- }
1286
- else {
1287
- this.store.record({
1288
- kind: 'mapping-issue',
1289
- instanceId,
1290
- elementId: element.id,
1291
- elementName: elementName(element),
1292
- target: mapping.target,
1293
- reason: evaluation.reason,
1294
- });
1295
- }
1296
- }
1297
- return result;
1282
+ return [...latest.values()];
1283
+ }
1284
+ latestStuckDecisionPerGateway() {
1285
+ const { instances, log } = this.snapshot;
1286
+ const latest = /* @__PURE__ */ new Map();
1287
+ for (const instance of instances) {
1288
+ for (const { gatewayId } of instance.waiting) {
1289
+ const decision = [...log].reverse().find(
1290
+ (entry) => entry.kind === "decision" && entry.instanceId === instance.id && entry.elementId === gatewayId
1291
+ );
1292
+ if (decision && (latest.get(gatewayId)?.id ?? 0) < decision.id) latest.set(gatewayId, decision);
1293
+ }
1298
1294
  }
1299
- }
1300
- DataSimulation.$inject = ['config.dataSimulation', 'eventBus', 'dataSimulationStore'];
1301
- function withoutKeys(variables, keys) {
1302
- return Object.fromEntries(Object.entries(variables).filter(([key]) => !keys.includes(key)));
1295
+ return [...latest.values()];
1296
+ }
1303
1297
  }
1304
1298
 
1305
1299
  const OUTCOME_LABELS = {
1306
- taken: { symbol: '✓', title: 'Taken' },
1307
- 'not-taken': { symbol: '✗', title: 'Condition is false' },
1308
- error: { symbol: '!', title: 'Condition could not be evaluated' },
1309
- skipped: { symbol: '–', title: 'Not evaluated' },
1300
+ taken: { symbol: "\u2713", title: "Taken" },
1301
+ "not-taken": { symbol: "\u2717", title: "Condition is false" },
1302
+ error: { symbol: "!", title: "Condition could not be evaluated" },
1303
+ skipped: { symbol: "\u2013", title: "Not evaluated" }
1310
1304
  };
1311
1305
  const DEFAULT_FLOW_TITLES = {
1312
- taken: 'Default flow taken, no condition is true',
1313
- 'not-taken': 'Default flow not needed',
1306
+ taken: "Default flow taken, no condition is true",
1307
+ "not-taken": "Default flow not needed"
1314
1308
  };
1315
- function createOutcomeBadge(outcome, detail, isDefault = false) {
1316
- const { symbol } = OUTCOME_LABELS[outcome];
1317
- const title = (isDefault && DEFAULT_FLOW_TITLES[outcome]) || OUTCOME_LABELS[outcome].title;
1318
- const badge = document.createElement('span');
1319
- badge.className = `bds-outcome bds-outcome--${outcome}`;
1320
- badge.textContent = symbol;
1321
- badge.title = detail ? `${title}: ${detail}` : title;
1322
- return badge;
1309
+ class OutcomeBadge {
1310
+ constructor(outcome, detail, isDefault = false) {
1311
+ this.element = document.createElement("span");
1312
+ const title = isDefault && DEFAULT_FLOW_TITLES[outcome] || OUTCOME_LABELS[outcome].title;
1313
+ this.element.className = `bds-outcome bds-outcome--${outcome}`;
1314
+ this.element.textContent = OUTCOME_LABELS[outcome].symbol;
1315
+ this.element.title = detail ? `${title}: ${detail}` : title;
1316
+ }
1323
1317
  }
1324
- function createDecisionCard({ elementName, gatewayKind, chosenBy, decision, inputs }, onClose) {
1325
- const closeButton = onClose
1326
- ? h('button', { className: 'bds-icon-button bds-decision-close', type: 'button', 'aria-label': 'Close' }, '×')
1327
- : null;
1328
- closeButton?.addEventListener('click', onClose);
1329
- return h('div', { className: `bds-decision${decision.stuckReason ? ' bds-decision--stuck' : ''}`, role: 'note' }, h('div', { className: 'bds-decision-title' }, h('span', {}, elementName), h('span', { className: 'bds-tag' }, chosenBy === 'click' ? `${gatewayKind} · by click` : gatewayKind), closeButton), decision.stuckReason
1330
- ? h('p', { className: 'bds-error' }, `${decision.stuckReason}. Change the variables in Process Data, then press ▶ on the gateway.`)
1331
- : null, h('ul', { className: 'bds-flows' }, ...decision.flows.map(({ flow, outcome, reason }) => h('li', { className: `bds-flow bds-flow--${outcome}` }, createOutcomeBadge(outcome, reason, flow.isDefault), h('span', { className: 'bds-flow-name' }, flow.name ?? flow.id), flow.isDefault
1332
- ? h('span', { className: 'bds-tag' }, 'default')
1333
- : flow.expression && h('code', {}, flow.expression)))), inputs.length ? createInputList(inputs) : null);
1318
+
1319
+ class DecisionCard {
1320
+ constructor({ elementName, gatewayKind, chosenBy, decision, inputs }, onClose) {
1321
+ this.element = h(
1322
+ "div",
1323
+ { className: `bds-decision${decision.stuckReason ? " bds-decision--stuck" : ""}`, role: "note" },
1324
+ h(
1325
+ "div",
1326
+ { className: "bds-decision-title" },
1327
+ h("span", {}, elementName),
1328
+ h("span", { className: "bds-tag" }, chosenBy === "click" ? `${gatewayKind} \xB7 by click` : gatewayKind),
1329
+ onClose ? this.closeButton(onClose) : null
1330
+ ),
1331
+ decision.stuckReason ? h(
1332
+ "p",
1333
+ { className: "bds-error" },
1334
+ `${decision.stuckReason}. Change the variables in Process Data, then press \u25B6 on the gateway.`
1335
+ ) : null,
1336
+ h(
1337
+ "ul",
1338
+ { className: "bds-flows" },
1339
+ ...decision.flows.map(
1340
+ ({ flow, outcome, reason }) => h(
1341
+ "li",
1342
+ { className: `bds-flow bds-flow--${outcome}` },
1343
+ new OutcomeBadge(outcome, reason, flow.isDefault).element,
1344
+ h("span", { className: "bds-flow-name" }, flow.name ?? flow.id),
1345
+ flow.isDefault ? h("span", { className: "bds-tag" }, "default") : flow.expression && h("code", {}, flow.expression)
1346
+ )
1347
+ )
1348
+ ),
1349
+ inputs.length ? this.inputList(inputs) : null
1350
+ );
1351
+ }
1352
+ closeButton(onClose) {
1353
+ const button = h(
1354
+ "button",
1355
+ { className: "bds-icon-button bds-decision-close", type: "button", "aria-label": "Close" },
1356
+ "\xD7"
1357
+ );
1358
+ button.addEventListener("click", onClose);
1359
+ return button;
1360
+ }
1361
+ inputList(inputs) {
1362
+ return h(
1363
+ "dl",
1364
+ { className: "bds-decision-inputs" },
1365
+ ...inputs.flatMap(({ name, value }) => [
1366
+ h("dt", {}, name),
1367
+ h(
1368
+ "dd",
1369
+ {},
1370
+ value === void 0 ? h("span", { className: "bds-hint" }, "not set") : h("code", {}, formatValue(value))
1371
+ )
1372
+ ])
1373
+ );
1374
+ }
1334
1375
  }
1335
- function createInputList(inputs) {
1336
- return h('dl', { className: 'bds-decision-inputs' }, ...inputs.flatMap(({ name, value }) => [
1337
- h('dt', {}, name),
1338
- h('dd', {}, value === undefined ? h('span', { className: 'bds-hint' }, 'not set') : h('code', {}, formatValue(value))),
1339
- ]));
1376
+
1377
+ function badgePosition(waypoints, distanceFromStart) {
1378
+ const [start, next] = waypoints;
1379
+ const length = Math.hypot(next.x - start.x, next.y - start.y) || 1;
1380
+ const distance = Math.min(distanceFromStart, length / 2);
1381
+ const x = start.x + (next.x - start.x) / length * distance;
1382
+ const y = start.y + (next.y - start.y) / length * distance;
1383
+ const minX = Math.min(...waypoints.map((point) => point.x));
1384
+ const minY = Math.min(...waypoints.map((point) => point.y));
1385
+ return { left: x - minX, top: y - minY };
1340
1386
  }
1341
1387
 
1342
1388
  const GAP$1 = 12;
1343
1389
  const MARGIN = 8;
1344
1390
  function placePopover(anchor, popover, bounds) {
1345
- const below = anchor.y + anchor.height + GAP$1;
1346
- const above = anchor.y - GAP$1 - popover.height;
1347
- const fitsBelow = below + popover.height <= bounds.height - MARGIN;
1348
- const fitsAbove = above >= MARGIN;
1349
- const height = Math.min(popover.height, bounds.height - 2 * MARGIN);
1350
- return {
1351
- left: clamp(anchor.x + anchor.width / 2 - popover.width / 2, MARGIN, bounds.width - popover.width - MARGIN),
1352
- top: fitsBelow ? below : fitsAbove ? above : clamp(below, MARGIN, bounds.height - height - MARGIN),
1353
- maxHeight: height < popover.height ? height : undefined,
1354
- hidden: !isInView(anchor, bounds),
1355
- };
1391
+ const below = anchor.y + anchor.height + GAP$1;
1392
+ const above = anchor.y - GAP$1 - popover.height;
1393
+ const fitsBelow = below + popover.height <= bounds.height - MARGIN;
1394
+ const fitsAbove = above >= MARGIN;
1395
+ const height = Math.min(popover.height, bounds.height - 2 * MARGIN);
1396
+ return {
1397
+ left: clamp(anchor.x + anchor.width / 2 - popover.width / 2, MARGIN, bounds.width - popover.width - MARGIN),
1398
+ top: fitsBelow ? below : fitsAbove ? above : clamp(below, MARGIN, bounds.height - height - MARGIN),
1399
+ maxHeight: height < popover.height ? height : void 0,
1400
+ hidden: !isInView(anchor, bounds)
1401
+ };
1356
1402
  }
1357
1403
  function clamp(value, min, max) {
1358
- return Math.max(min, Math.min(value, max));
1404
+ return Math.max(min, Math.min(value, max));
1359
1405
  }
1360
1406
  function isInView(anchor, bounds) {
1361
- return (anchor.x + anchor.width > 0 && anchor.x < bounds.width && anchor.y + anchor.height > 0 && anchor.y < bounds.height);
1407
+ return anchor.x + anchor.width > 0 && anchor.x < bounds.width && anchor.y + anchor.height > 0 && anchor.y < bounds.height;
1362
1408
  }
1363
1409
 
1364
1410
  var componentStyles = ":host {\n all: initial;\n display: contents;\n}\n\n.bds-panel {\n position: absolute;\n top: 30%;\n right: 20px;\n bottom: 50px;\n z-index: 10000;\n display: flex;\n flex-direction: column;\n width: 300px;\n overflow: hidden;\n font-family: var(--bds-font);\n font-size: 13px;\n color: var(--bds-ink);\n background: var(--token-simulation-control-background, #f1f2f4);\n border-radius: var(--surface-border-radius, 4px);\n}\n\n.bds-panel[hidden] {\n display: none;\n}\n\n.bds-panel-header {\n display: flex;\n flex: 0 0 auto;\n align-items: center;\n gap: var(--bds-space-2);\n box-sizing: border-box;\n height: 30px;\n padding: 6px 8px;\n font-size: 16px;\n color: var(--token-simulation-control-surface, #fff);\n background: var(--token-simulation-primary, #0067cc);\n}\n\n.bds-panel-heading {\n flex: 1;\n margin: 0;\n font: inherit;\n text-align: center;\n}\n\n.bds-panel-close {\n display: inline-flex;\n align-items: center;\n padding: 0;\n color: inherit;\n background: none;\n border: none;\n cursor: pointer;\n}\n\n.bds-variables-icon svg,\n.bds-panel-close svg {\n width: 1em;\n height: 1em;\n fill: none;\n stroke: currentColor;\n stroke-width: 1.6;\n stroke-linecap: round;\n stroke-linejoin: round;\n}\n\n.bds-variables-icon {\n display: inline-flex;\n align-items: center;\n}\n\n.bds-panel-body {\n display: flex;\n flex: 1;\n flex-direction: column;\n gap: var(--bds-space-2);\n margin: 7px 3px 7px 12px;\n padding: 5px 9px 5px 0;\n overflow-y: auto;\n}\n\n.bds-panel-engine {\n margin: 0;\n}\n\n.bds-panel .bds-section {\n padding: var(--bds-space-2);\n background: var(--token-simulation-control-surface, #fff);\n border-radius: var(--surface-border-radius, 4px);\n}\n\n.bds-panel-title {\n margin: 0;\n font-size: 14px;\n font-weight: 600;\n}\n\n.bds-engine {\n padding: 2px 8px;\n font-size: 11px;\n font-weight: 600;\n color: var(--bds-accent-ink);\n background: var(--bds-accent-soft);\n border-radius: var(--bds-radius-pill);\n}\n\n.bds-icon-button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n margin-left: auto;\n width: 26px;\n height: 26px;\n padding: 0;\n color: var(--bds-muted);\n background: transparent;\n border: 1px solid transparent;\n border-radius: var(--bds-radius-sm);\n cursor: pointer;\n}\n\n.bds-icon-button svg {\n width: 16px;\n height: 16px;\n fill: none;\n stroke: currentColor;\n stroke-width: 1.5;\n stroke-linecap: round;\n stroke-linejoin: round;\n transition: transform var(--bds-motion-fast) var(--bds-ease);\n}\n\n.bds-icon-button:hover {\n color: var(--bds-accent-ink);\n background: var(--bds-accent-soft);\n}\n\n.bds-section {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-1);\n}\n\n.bds-section[hidden] {\n display: none;\n}\n\n.bds-section-title,\n.bds-label {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-1);\n margin: 0;\n font-size: 12px;\n font-weight: 600;\n letter-spacing: 0.01em;\n color: var(--bds-muted);\n}\n\n.bds-section-title {\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n}\n\n.bds-hint {\n margin: 0;\n font-size: 12px;\n color: var(--bds-muted);\n}\n\n.bds-hint[hidden],\n.bds-error[hidden] {\n display: none;\n}\n\n.bds-error {\n margin: 0;\n font-size: 12px;\n color: var(--bds-danger);\n}\n\n.bds-input {\n box-sizing: border-box;\n width: 100%;\n padding: 6px 10px;\n font-family: inherit;\n font-size: 13px;\n font-weight: 400;\n color: var(--bds-ink);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-sm);\n transition:\n border-color var(--bds-motion-fast) var(--bds-ease),\n box-shadow var(--bds-motion-fast) var(--bds-ease);\n}\n\n.bds-input:focus,\n.bds-input:focus-visible {\n outline: none;\n border-color: var(--bds-accent);\n box-shadow: 0 0 0 3px var(--bds-accent-soft);\n}\n\n.bds-input--invalid,\n.bds-input--invalid:focus {\n border-color: var(--bds-danger);\n box-shadow: 0 0 0 3px var(--bds-danger-soft);\n}\n\n.bds-json {\n min-height: 72px;\n font-family: var(--bds-font-mono);\n font-size: 12px;\n line-height: 1.5;\n resize: vertical;\n}\n\n.bds-instance-select[hidden] {\n display: none;\n}\n\n.bds-instance-select {\n padding: 4px 8px;\n font-size: 12px;\n}\n\n.bds-actions {\n display: flex;\n justify-content: flex-end;\n gap: var(--bds-space-2);\n margin-top: var(--bds-space-2);\n}\n\n.bds-button {\n padding: 5px 12px;\n font-family: inherit;\n font-size: 12px;\n font-weight: 600;\n color: var(--bds-ink);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-sm);\n box-shadow: var(--bds-shadow-1);\n cursor: pointer;\n transition:\n background var(--bds-motion-fast) var(--bds-ease),\n border-color var(--bds-motion-fast) var(--bds-ease),\n color var(--bds-motion-fast) var(--bds-ease);\n}\n\n.bds-button:hover {\n color: var(--bds-accent-ink);\n border-color: var(--bds-accent);\n background: var(--bds-accent-soft);\n}\n\n.bds-button--primary {\n color: var(--bds-on-accent);\n background: var(--bds-accent);\n border-color: var(--bds-accent);\n}\n\n.bds-button--primary:hover {\n color: var(--bds-on-accent);\n background: var(--bds-accent-ink);\n}\n\n.bds-button:focus-visible,\n.bds-icon-button:focus-visible {\n outline: none;\n box-shadow: 0 0 0 3px var(--bds-accent-soft);\n}\n\n.bds-status {\n margin: 0 0 var(--bds-space-1);\n font-size: 12px;\n font-weight: 600;\n}\n\n.bds-status--running {\n color: var(--bds-accent-ink);\n}\n\n.bds-status--completed {\n color: var(--bds-success);\n}\n\n.bds-status--waiting {\n color: var(--bds-danger);\n}\n\n.bds-variables {\n width: 100%;\n border-collapse: collapse;\n}\n\n.bds-variables th,\n.bds-variables td {\n padding: 4px 0;\n text-align: left;\n vertical-align: top;\n border-bottom: 1px solid var(--bds-line);\n}\n\n.bds-variables tr:last-child th,\n.bds-variables tr:last-child td {\n border-bottom: none;\n}\n\n.bds-variables th {\n width: 1%;\n padding-right: var(--bds-space-3);\n font-weight: 500;\n white-space: nowrap;\n}\n\n.bds-variables code,\n.bds-flow code {\n font-family: var(--bds-font-mono);\n font-size: 12px;\n overflow-wrap: anywhere;\n}\n\n.bds-log {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-2);\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.bds-log-entry {\n padding: var(--bds-space-2);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-sm);\n}\n\n.bds-log-entry--issue {\n border-color: var(--bds-danger-soft);\n background: linear-gradient(var(--bds-danger-soft), var(--bds-danger-soft)), var(--bds-surface);\n}\n\n.bds-log-title {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--bds-space-2);\n margin-bottom: var(--bds-space-1);\n font-weight: 600;\n}\n\n.bds-tag {\n padding: 1px 6px;\n font-size: 11px;\n font-weight: 500;\n color: var(--bds-muted);\n background: var(--bds-code-bg);\n border-radius: var(--bds-radius-pill);\n}\n\n.bds-flows {\n display: flex;\n flex-direction: column;\n gap: 2px;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.bds-flow {\n display: grid;\n grid-template-columns: 18px 1fr;\n align-items: center;\n column-gap: var(--bds-space-2);\n row-gap: 2px;\n}\n\n.bds-flow code,\n.bds-flow .bds-tag {\n grid-column: 2;\n justify-self: start;\n}\n\n.bds-flow code {\n padding: 1px 4px;\n color: var(--bds-muted);\n background: var(--bds-code-bg);\n border-radius: 4px;\n}\n\n.bds-flow--skipped,\n.bds-flow--not-taken {\n color: var(--bds-muted);\n}\n\n.bds-outcome {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n width: 18px;\n height: 18px;\n font-family: var(--bds-font);\n font-size: 11px;\n font-weight: 700;\n line-height: 1;\n border-radius: var(--bds-radius-pill);\n border: 1px solid transparent;\n cursor: default;\n}\n\n.bds-outcome--taken {\n color: var(--bds-on-accent);\n background: var(--bds-success);\n}\n\n.bds-outcome--not-taken {\n color: var(--bds-muted);\n background: var(--bds-surface);\n border-color: var(--bds-line);\n}\n\n.bds-outcome--error {\n color: var(--bds-on-accent);\n background: var(--bds-danger);\n}\n\n.bds-outcome--skipped {\n color: var(--bds-muted);\n background: var(--bds-code-bg);\n}\n\n.bds-outcome--on-flow {\n display: flex;\n box-shadow: var(--bds-shadow-1);\n transform: translate(-50%, -50%);\n}\n\n.bds-popover {\n position: absolute;\n z-index: 100;\n overflow-y: auto;\n}\n\n.bds-popover[hidden] {\n display: none;\n}\n\n.bds-decision {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-2);\n box-sizing: border-box;\n width: 300px;\n padding: 12px;\n font-family: var(--bds-font);\n font-size: 12px;\n line-height: 1.4;\n color: var(--bds-ink);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-md);\n box-shadow: var(--bds-shadow-3);\n}\n\n.bds-decision--stuck {\n border-color: var(--bds-danger);\n}\n\n.bds-decision-title {\n display: flex;\n align-items: center;\n gap: var(--bds-space-2);\n font-size: 13px;\n font-weight: 600;\n}\n\n.bds-decision-title .bds-tag {\n margin-left: auto;\n}\n\n.bds-decision-close {\n margin-left: 0;\n width: 22px;\n height: 22px;\n font-size: 16px;\n line-height: 1;\n}\n\n.bds-decision-inputs {\n display: grid;\n grid-template-columns: auto 1fr;\n gap: 2px var(--bds-space-3);\n margin: 0;\n padding-top: var(--bds-space-2);\n border-top: 1px solid var(--bds-line);\n}\n\n.bds-decision-inputs dt {\n font-family: var(--bds-font-mono);\n color: var(--bds-muted);\n}\n\n.bds-decision-inputs dd {\n margin: 0;\n overflow-wrap: anywhere;\n}\n\n.bds-decision-inputs code {\n font-family: var(--bds-font-mono);\n}\n\n.bds-dialog-backdrop {\n position: fixed;\n inset: 0;\n z-index: 10010;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: var(--bds-space-3);\n background: rgba(29, 29, 29, 0.24);\n}\n\n.bds-dialog {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-3);\n box-sizing: border-box;\n width: 420px;\n max-width: 100%;\n max-height: 100%;\n margin: 0;\n padding: 20px;\n font-family: var(--bds-font);\n font-size: 13px;\n color: var(--bds-ink);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-lg);\n box-shadow: var(--bds-shadow-3);\n}\n\n.bds-dialog-content {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-3);\n min-height: 0;\n overflow-y: auto;\n}\n\n.bds-dialog-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--bds-space-2);\n}\n\n.bds-dialog .bds-actions {\n margin-top: 0;\n}\n\n.bds-form {\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n\n.bds-field {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-1);\n}\n\n.bds-field-name {\n font-family: var(--bds-font-mono);\n font-size: 12px;\n font-weight: 600;\n}\n\n.bds-field-hint {\n font-size: 11px;\n color: var(--bds-muted);\n}\n\n.bds-checkbox {\n display: inline-flex;\n align-items: center;\n gap: var(--bds-space-2);\n cursor: pointer;\n}\n\n.bds-checkbox input {\n width: 16px;\n height: 16px;\n margin: 0;\n accent-color: var(--bds-accent);\n}\n\n@media (prefers-reduced-motion: reduce) {\n * {\n transition-duration: 0.001ms !important;\n }\n}\n\n.bds-form .bds-json {\n min-height: 0;\n}\n";
1365
1411
 
1366
1412
  let sharedSheet;
1367
1413
  function inShadow(...children) {
1368
- const host = h('div', { className: 'bds-host' });
1369
- const root = host.attachShadow({ mode: 'open' });
1370
- adoptComponentStyles(root);
1371
- root.append(...children);
1372
- return host;
1414
+ const host = h("div", { className: "bds-host" });
1415
+ const root = host.attachShadow({ mode: "open" });
1416
+ adoptComponentStyles(root);
1417
+ root.append(...children);
1418
+ return host;
1373
1419
  }
1374
1420
  function adoptComponentStyles(root) {
1375
- if ('adoptedStyleSheets' in root && 'replaceSync' in CSSStyleSheet.prototype) {
1376
- sharedSheet ?? (sharedSheet = createSheet());
1377
- root.adoptedStyleSheets = [sharedSheet];
1378
- }
1379
- else {
1380
- root.append(h('style', {}, componentStyles));
1381
- }
1421
+ if ("adoptedStyleSheets" in root && "replaceSync" in CSSStyleSheet.prototype) {
1422
+ sharedSheet ?? (sharedSheet = createSheet());
1423
+ root.adoptedStyleSheets = [sharedSheet];
1424
+ } else {
1425
+ root.append(h("style", {}, componentStyles));
1426
+ }
1382
1427
  }
1383
1428
  function createSheet() {
1384
- const sheet = new CSSStyleSheet();
1385
- sheet.replaceSync(componentStyles);
1386
- return sheet;
1429
+ const sheet = new CSSStyleSheet();
1430
+ sheet.replaceSync(componentStyles);
1431
+ return sheet;
1387
1432
  }
1388
1433
 
1389
- const OUTCOME_OVERLAY = 'bds-flow-outcome';
1390
- const DECIDED_MARKER = 'bds-gateway--decided';
1391
- const STUCK_MARKER = 'bds-gateway--stuck';
1434
+ const OUTCOME_OVERLAY = "bds-flow-outcome";
1435
+ const DECIDED_MARKER = "bds-gateway--decided";
1436
+ const STUCK_MARKER = "bds-gateway--stuck";
1392
1437
  const BADGE_DISTANCE = 38;
1393
1438
  const BADGE_MIN_SCALE = 1;
1394
1439
  class DataSimulationOverlays {
1395
- constructor(eventBus, overlays, elementRegistry, canvas, dataSimulation) {
1396
- this.overlays = overlays;
1397
- this.elementRegistry = elementRegistry;
1398
- this.canvas = canvas;
1399
- this.pinnedGatewayIds = new Set();
1400
- this.markedGateways = [];
1401
- this.popovers = [];
1402
- this.popoverLayer = inShadow();
1403
- this.renderedState = '';
1404
- this.snapshot = dataSimulation.getSnapshot();
1405
- const unsubscribe = dataSimulation.subscribe(snapshot => {
1406
- this.snapshot = snapshot;
1407
- this.render();
1408
- });
1409
- eventBus.on('element.hover', ({ element }) => {
1410
- this.hoveredGatewayId = gatewayOf(element);
1411
- this.render();
1412
- });
1413
- eventBus.on('element.click', ({ element }) => {
1414
- if (!isGateway(element))
1415
- return;
1416
- if (!this.pinnedGatewayIds.delete(element.id))
1417
- this.pinnedGatewayIds.add(element.id);
1418
- this.render();
1419
- });
1420
- eventBus.on(['canvas.viewbox.changed', 'canvas.resized'], () => this.placePopovers());
1421
- canvas.getContainer().append(this.popoverLayer);
1422
- eventBus.on('diagram.destroy', () => {
1423
- unsubscribe();
1424
- this.popoverLayer.remove();
1425
- });
1426
- }
1427
- render() {
1428
- const decisions = latestDecisionPerGateway(this.snapshot);
1429
- const shownPerGateway = new Map(decisions.map(entry => [entry.elementId, entry]));
1430
- for (const entry of latestStuckDecisionPerGateway(this.snapshot))
1431
- shownPerGateway.set(entry.elementId, entry);
1432
- const shown = [...shownPerGateway.values()];
1433
- const cards = shown.filter(({ elementId }) => elementId === this.hoveredGatewayId || this.pinnedGatewayIds.has(elementId));
1434
- const state = JSON.stringify([
1435
- decisions.map(entry => entry.id),
1436
- shown.map(entry => entry.id),
1437
- cards.map(entry => [entry.id, this.pinnedGatewayIds.has(entry.elementId)]),
1438
- ]);
1439
- if (state === this.renderedState)
1440
- return;
1441
- this.renderedState = state;
1442
- this.overlays.remove({ type: OUTCOME_OVERLAY });
1443
- this.unmarkGateways();
1444
- for (const entry of decisions)
1445
- this.showOutcomes(entry.decision);
1446
- for (const entry of shown)
1447
- this.markGateway(entry);
1448
- this.showCards(cards);
1449
- }
1450
- markGateway({ elementId, decision }) {
1451
- const gateway = this.elementRegistry.get(elementId);
1452
- if (!gateway)
1453
- return;
1454
- this.canvas.addMarker(gateway, decision.stuckReason ? STUCK_MARKER : DECIDED_MARKER);
1455
- this.markedGateways.push(gateway);
1456
- }
1457
- unmarkGateways() {
1458
- for (const gateway of this.markedGateways) {
1459
- this.canvas.removeMarker(gateway, DECIDED_MARKER);
1460
- this.canvas.removeMarker(gateway, STUCK_MARKER);
1461
- }
1462
- this.markedGateways = [];
1463
- }
1464
- showOutcomes(decision) {
1465
- for (const { flow, outcome, reason } of decision.flows) {
1466
- const connection = this.elementRegistry.get(flow.id);
1467
- if (!connection?.waypoints)
1468
- continue;
1469
- const badge = createOutcomeBadge(outcome, reason, flow.isDefault);
1470
- badge.classList.add('bds-outcome--on-flow');
1471
- this.overlays.add(connection, OUTCOME_OVERLAY, {
1472
- position: badgePosition(connection.waypoints),
1473
- scale: { min: BADGE_MIN_SCALE },
1474
- html: inShadow(badge),
1475
- });
1476
- }
1477
- }
1478
- showCards(entries) {
1479
- this.popovers = entries.flatMap(entry => {
1480
- const gateway = this.elementRegistry.get(entry.elementId);
1481
- if (!gateway)
1482
- return [];
1483
- const close = () => {
1484
- this.pinnedGatewayIds.delete(entry.elementId);
1485
- this.render();
1486
- };
1487
- const card = createDecisionCard(entry, this.pinnedGatewayIds.has(entry.elementId) ? close : undefined);
1488
- card.classList.add('bds-popover');
1489
- card.dataset.elementId = entry.elementId;
1490
- return [{ gateway, card }];
1491
- });
1492
- this.popoverLayer.shadowRoot.replaceChildren(...this.popovers.map(({ card }) => card));
1493
- this.placePopovers();
1494
- }
1495
- placePopovers() {
1496
- const container = this.canvas.getContainer();
1497
- const bounds = { width: container.clientWidth, height: container.clientHeight };
1498
- for (const { gateway, card } of this.popovers) {
1499
- card.style.maxHeight = '';
1500
- const { left, top, maxHeight, hidden } = placePopover(this.canvas.getAbsoluteBBox(gateway), { width: card.offsetWidth, height: card.offsetHeight }, bounds);
1501
- card.hidden = hidden;
1502
- card.style.left = `${left}px`;
1503
- card.style.top = `${top}px`;
1504
- card.style.maxHeight = maxHeight === undefined ? '' : `${maxHeight}px`;
1505
- }
1506
- }
1507
- }
1508
- DataSimulationOverlays.$inject = ['eventBus', 'overlays', 'elementRegistry', 'canvas', 'dataSimulation'];
1509
- function isGateway(element) {
1510
- return element.type === 'bpmn:ExclusiveGateway' || element.type === 'bpmn:InclusiveGateway';
1511
- }
1512
- function gatewayOf(element) {
1513
- if (isGateway(element))
1514
- return element.id;
1515
- if (element.type === 'bpmn:SequenceFlow' && element.source && isGateway(element.source))
1516
- return element.source.id;
1517
- return undefined;
1518
- }
1519
- function latestDecisionPerGateway({ log, selectedInstanceId }) {
1520
- const latest = new Map();
1521
- for (const entry of log) {
1522
- if (entry.kind === 'decision' && entry.instanceId === selectedInstanceId)
1523
- latest.set(entry.elementId, entry);
1524
- }
1525
- return [...latest.values()];
1526
- }
1527
- function latestStuckDecisionPerGateway({ instances, log }) {
1528
- const latest = new Map();
1529
- for (const instance of instances) {
1530
- for (const { gatewayId } of instance.waiting) {
1531
- const decision = [...log]
1532
- .reverse()
1533
- .find((entry) => entry.kind === 'decision' && entry.instanceId === instance.id && entry.elementId === gatewayId);
1534
- if (decision && (latest.get(gatewayId)?.id ?? 0) < decision.id)
1535
- latest.set(gatewayId, decision);
1536
- }
1537
- }
1538
- return [...latest.values()];
1539
- }
1540
- function badgePosition(waypoints) {
1541
- const [start, next] = waypoints;
1542
- const length = Math.hypot(next.x - start.x, next.y - start.y) || 1;
1543
- const distance = Math.min(BADGE_DISTANCE, length / 2);
1544
- const x = start.x + ((next.x - start.x) / length) * distance;
1545
- const y = start.y + ((next.y - start.y) / length) * distance;
1546
- const minX = Math.min(...waypoints.map(point => point.x));
1547
- const minY = Math.min(...waypoints.map(point => point.y));
1548
- return { left: x - minX, top: y - minY };
1549
- }
1440
+ constructor(eventBus, overlays, elementRegistry, canvas, dataSimulation) {
1441
+ this.overlays = overlays;
1442
+ this.elementRegistry = elementRegistry;
1443
+ this.canvas = canvas;
1444
+ this.pinnedGatewayIds = /* @__PURE__ */ new Set();
1445
+ this.markedGateways = [];
1446
+ this.popovers = [];
1447
+ this.popoverLayer = inShadow();
1448
+ this.renderedState = "";
1449
+ this.snapshot = dataSimulation.getSnapshot();
1450
+ const unsubscribe = dataSimulation.subscribe((snapshot) => {
1451
+ this.snapshot = snapshot;
1452
+ this.render();
1453
+ });
1454
+ eventBus.on("element.hover", ({ element }) => {
1455
+ this.hoveredGatewayId = gatewayOf(element);
1456
+ this.render();
1457
+ });
1458
+ eventBus.on("element.click", ({ element }) => {
1459
+ if (!isGateway(element)) return;
1460
+ if (!this.pinnedGatewayIds.delete(element.id)) this.pinnedGatewayIds.add(element.id);
1461
+ this.render();
1462
+ });
1463
+ eventBus.on(["canvas.viewbox.changed", "canvas.resized"], () => this.placePopovers());
1464
+ canvas.getContainer().append(this.popoverLayer);
1465
+ eventBus.on("diagram.destroy", () => {
1466
+ unsubscribe();
1467
+ this.popoverLayer.remove();
1468
+ });
1469
+ }
1470
+ render() {
1471
+ const { decisions, shown } = new GatewayDecisionView(this.snapshot);
1472
+ const cards = shown.filter(
1473
+ ({ elementId }) => elementId === this.hoveredGatewayId || this.pinnedGatewayIds.has(elementId)
1474
+ );
1475
+ const state = JSON.stringify([
1476
+ decisions.map((entry) => entry.id),
1477
+ shown.map((entry) => entry.id),
1478
+ cards.map((entry) => [entry.id, this.pinnedGatewayIds.has(entry.elementId)])
1479
+ ]);
1480
+ if (state === this.renderedState) return;
1481
+ this.renderedState = state;
1482
+ this.overlays.remove({ type: OUTCOME_OVERLAY });
1483
+ this.unmarkGateways();
1484
+ for (const entry of decisions) this.showOutcomes(entry.decision);
1485
+ for (const entry of shown) this.markGateway(entry);
1486
+ this.showCards(cards);
1487
+ }
1488
+ markGateway({ elementId, decision }) {
1489
+ const gateway = this.elementRegistry.get(elementId);
1490
+ if (!gateway) return;
1491
+ this.canvas.addMarker(gateway, decision.stuckReason ? STUCK_MARKER : DECIDED_MARKER);
1492
+ this.markedGateways.push(gateway);
1493
+ }
1494
+ unmarkGateways() {
1495
+ for (const gateway of this.markedGateways) {
1496
+ this.canvas.removeMarker(gateway, DECIDED_MARKER);
1497
+ this.canvas.removeMarker(gateway, STUCK_MARKER);
1498
+ }
1499
+ this.markedGateways = [];
1500
+ }
1501
+ showOutcomes(decision) {
1502
+ for (const { flow, outcome, reason } of decision.flows) {
1503
+ const connection = this.elementRegistry.get(flow.id);
1504
+ if (!connection?.waypoints) continue;
1505
+ const badge = new OutcomeBadge(outcome, reason, flow.isDefault).element;
1506
+ badge.classList.add("bds-outcome--on-flow");
1507
+ this.overlays.add(connection, OUTCOME_OVERLAY, {
1508
+ position: badgePosition(connection.waypoints, BADGE_DISTANCE),
1509
+ scale: { min: BADGE_MIN_SCALE },
1510
+ html: inShadow(badge)
1511
+ });
1512
+ }
1513
+ }
1514
+ showCards(entries) {
1515
+ this.popovers = entries.flatMap((entry) => {
1516
+ const gateway = this.elementRegistry.get(entry.elementId);
1517
+ if (!gateway) return [];
1518
+ const close = () => {
1519
+ this.pinnedGatewayIds.delete(entry.elementId);
1520
+ this.render();
1521
+ };
1522
+ const card = new DecisionCard(entry, this.pinnedGatewayIds.has(entry.elementId) ? close : void 0).element;
1523
+ card.classList.add("bds-popover");
1524
+ card.dataset.elementId = entry.elementId;
1525
+ return [{ gateway, card }];
1526
+ });
1527
+ this.popoverLayer.shadowRoot.replaceChildren(...this.popovers.map(({ card }) => card));
1528
+ this.placePopovers();
1529
+ }
1530
+ placePopovers() {
1531
+ const container = this.canvas.getContainer();
1532
+ const bounds = { width: container.clientWidth, height: container.clientHeight };
1533
+ for (const { gateway, card } of this.popovers) {
1534
+ card.style.maxHeight = "";
1535
+ const { left, top, maxHeight, hidden } = placePopover(
1536
+ this.canvas.getAbsoluteBBox(gateway),
1537
+ { width: card.offsetWidth, height: card.offsetHeight },
1538
+ bounds
1539
+ );
1540
+ card.hidden = hidden;
1541
+ card.style.left = `${left}px`;
1542
+ card.style.top = `${top}px`;
1543
+ card.style.maxHeight = maxHeight === void 0 ? "" : `${maxHeight}px`;
1544
+ }
1545
+ }
1546
+ }
1547
+ DataSimulationOverlays.$inject = ["eventBus", "overlays", "elementRegistry", "canvas", "dataSimulation"];
1550
1548
 
1551
1549
  const VARIABLES_ICON = '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M5.5 2.5C4 2.5 4 3.5 4 5v1c0 1-.8 2-2 2 1.2 0 2 1 2 2v1c0 1.5 0 2.5 1.5 2.5M10.5 2.5c1.5 0 1.5 1 1.5 2.5v1c0 1 .8 2 2 2-1.2 0-2 1-2 2v1c0 1.5 0 2.5-1.5 2.5" /></svg>';
1552
1550
  const CLOSE_ICON = '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 4l8 8M12 4l-8 8" /></svg>';
1553
1551
  class VariablesPanel {
1554
- constructor(actions) {
1555
- this.actions = actions;
1556
- this.paletteEntry = h('button', {
1557
- className: 'bts-entry bds-palette-entry',
1558
- type: 'button',
1559
- title: 'Toggle Process Data',
1560
- 'aria-label': 'Toggle Process Data',
1561
- });
1562
- this.engineBadge = h('span', { className: 'bds-engine' });
1563
- this.closeButton = h('button', { className: 'bds-panel-close', type: 'button', 'aria-label': 'Close' });
1564
- this.instanceTitle = h('h3', { className: 'bds-section-title' }, 'Instance');
1565
- this.instancePicker = h('select', {
1566
- className: 'bds-input bds-instance-select',
1567
- 'aria-label': 'Process instance',
1568
- });
1569
- this.instanceBody = h('div', { className: 'bds-instance-body' });
1570
- this.issueList = h('ol', { className: 'bds-log' });
1571
- this.issueSection = h('section', { className: 'bds-section bds-issues' }, h('h3', { className: 'bds-section-title' }, 'Issues'), this.issueList);
1572
- this.shownInstances = '';
1573
- this.paletteEntry.innerHTML = `<span class="bts-icon bds-variables-icon">${VARIABLES_ICON}</span>`;
1574
- this.closeButton.innerHTML = CLOSE_ICON;
1575
- const icon = h('span', { className: 'bds-variables-icon' });
1576
- icon.innerHTML = VARIABLES_ICON;
1577
- this.element = h('aside', { className: 'bds-panel', 'aria-label': 'Process Data' }, h('header', { className: 'bds-panel-header' }, icon, h('h2', { className: 'bds-panel-heading' }, 'Process Data'), this.closeButton), h('div', { className: 'bds-panel-body' }, h('p', { className: 'bds-panel-engine' }, this.engineBadge), h('section', { className: 'bds-section bds-instance' }, this.instanceTitle, this.instanceBody), this.issueSection));
1578
- this.paletteEntry.addEventListener('click', () => this.toggle());
1579
- this.closeButton.addEventListener('click', () => this.toggle(false));
1580
- this.instancePicker.addEventListener('change', () => this.actions.selectInstance(this.instancePicker.value));
1581
- this.toggle(false);
1582
- }
1583
- toggle(shown = this.element.hidden === true) {
1584
- this.element.hidden = !shown;
1585
- this.paletteEntry.classList.toggle('active', shown);
1586
- }
1587
- render(snapshot) {
1588
- this.snapshot = snapshot;
1589
- this.engineBadge.textContent = `${snapshot.engineLabel} · ${snapshot.expressionLanguage}`;
1590
- this.renderInstance(snapshot);
1591
- this.renderIssues(snapshot);
1592
- }
1593
- renderInstance({ instances, selectedInstanceId, scenarios }) {
1594
- const editedInstance = instances.find(candidate => candidate.id === this.editingInstanceId);
1595
- if (editedInstance && editedInstance.status !== 'completed' && editedInstance.id !== selectedInstanceId) {
1596
- this.actions.selectInstance(editedInstance.id);
1597
- return;
1598
- }
1599
- const instance = instances.find(candidate => candidate.id === selectedInstanceId);
1600
- this.renderInstancePicker(instances, selectedInstanceId, scenarios);
1601
- if (this.editingInstanceId && this.editingInstanceId === instance?.id && instance.status !== 'completed')
1602
- return;
1603
- this.editingInstanceId = undefined;
1604
- this.instanceBody.replaceChildren(instance
1605
- ? this.instanceView(instance)
1606
- : h('p', { className: 'bds-hint' }, 'Press ▶ on a start event to start a process instance.'));
1607
- }
1608
- renderInstancePicker(instances, selectedInstanceId, scenarios) {
1609
- const signature = JSON.stringify(instances.map(instance => [instance.id, instance.status]));
1610
- if (signature !== this.shownInstances) {
1611
- this.shownInstances = signature;
1612
- this.instancePicker.replaceChildren(...instances.map(instance => {
1613
- const scenarioName = scenarios.find(scenario => scenario.id === instance.scenarioId)?.name ?? 'no scenario';
1614
- return h('option', { value: instance.id }, `#${instance.number} ${scenarioName} (${instance.status})`);
1615
- }));
1616
- }
1617
- this.instancePicker.value = selectedInstanceId ?? '';
1618
- this.instancePicker.hidden = instances.length < 2;
1619
- if (!this.instancePicker.isConnected)
1620
- this.instanceTitle.after(this.instancePicker);
1621
- }
1622
- instanceView(instance) {
1623
- const scenarioName = this.snapshot?.scenarios.find(scenario => scenario.id === instance.scenarioId)?.name;
1624
- const entries = Object.entries(instance.variables);
1625
- const editButton = h('button', { className: 'bds-button', type: 'button' }, 'Edit');
1626
- editButton.addEventListener('click', () => this.editInstance(instance));
1627
- return h('div', {}, h('p', { className: `bds-status bds-status--${instance.status}` }, describeStatus(instance)), scenarioName ? h('p', { className: 'bds-hint' }, `Scenario: ${scenarioName}`) : null, entries.length
1628
- ? h('table', { className: 'bds-variables' }, h('tbody', {}, ...entries.map(([name, value]) => h('tr', {}, h('th', { scope: 'row' }, name), h('td', {}, h('code', {}, formatValue(value)))))))
1629
- : h('p', { className: 'bds-hint' }, 'No variables yet.'), h('p', { className: 'bds-hint' }, 'Hover a gateway to see why it took its flow, click it to keep the card open.'), instance.status !== 'completed' ? h('div', { className: 'bds-actions' }, editButton) : null);
1630
- }
1631
- editInstance(instance) {
1632
- this.editingInstanceId = instance.id;
1633
- const editor = h('textarea', {
1634
- className: 'bds-input bds-json bds-instance-editor',
1635
- spellcheck: 'false',
1636
- rows: '8',
1637
- 'aria-label': 'Instance variables (JSON)',
1638
- });
1639
- editor.value = JSON.stringify(instance.variables, null, 2);
1640
- const error = h('p', { className: 'bds-error', role: 'alert' });
1641
- showError(error, editor, '');
1642
- const applyButton = h('button', { className: 'bds-button bds-button--primary', type: 'button' }, 'Apply');
1643
- const cancelButton = h('button', { className: 'bds-button', type: 'button' }, 'Cancel');
1644
- applyButton.addEventListener('click', () => {
1645
- const parsed = parseVariables(editor.value);
1646
- if (typeof parsed === 'string') {
1647
- showError(error, editor, parsed);
1648
- return;
1649
- }
1650
- this.editingInstanceId = undefined;
1651
- this.actions.setInstanceVariables(instance.id, parsed);
1652
- });
1653
- cancelButton.addEventListener('click', () => {
1654
- this.editingInstanceId = undefined;
1655
- if (this.snapshot)
1656
- this.renderInstance(this.snapshot);
1657
- });
1658
- this.instanceBody.replaceChildren(editor, error, h('div', { className: 'bds-actions' }, cancelButton, applyButton));
1659
- editor.focus();
1660
- }
1661
- renderIssues({ log, selectedInstanceId }) {
1662
- const issues = log.filter((entry) => entry.kind === 'mapping-issue' && entry.instanceId === selectedInstanceId);
1663
- this.issueSection.hidden = !issues.length;
1664
- this.issueList.replaceChildren(...issues.slice().reverse().map(renderMappingIssue));
1665
- }
1666
- }
1667
- function describeStatus({ processName, status, waiting }) {
1668
- if (status !== 'waiting')
1669
- return `${processName} · ${status}`;
1670
- return `${processName} · waiting at ${waiting.map(gateway => gateway.gatewayName).join(', ')}`;
1671
- }
1672
- function showError(error, input, message) {
1552
+ constructor(actions) {
1553
+ this.actions = actions;
1554
+ this.paletteEntry = h("button", {
1555
+ className: "bts-entry bds-palette-entry",
1556
+ type: "button",
1557
+ title: "Toggle Process Data",
1558
+ "aria-label": "Toggle Process Data"
1559
+ });
1560
+ this.engineBadge = h("span", { className: "bds-engine" });
1561
+ this.closeButton = h("button", { className: "bds-panel-close", type: "button", "aria-label": "Close" });
1562
+ this.instanceTitle = h("h3", { className: "bds-section-title" }, "Instance");
1563
+ this.instancePicker = h("select", {
1564
+ className: "bds-input bds-instance-select",
1565
+ "aria-label": "Process instance"
1566
+ });
1567
+ this.instanceBody = h("div", { className: "bds-instance-body" });
1568
+ this.issueList = h("ol", { className: "bds-log" });
1569
+ this.issueSection = h(
1570
+ "section",
1571
+ { className: "bds-section bds-issues" },
1572
+ h("h3", { className: "bds-section-title" }, "Issues"),
1573
+ this.issueList
1574
+ );
1575
+ this.shownInstances = "";
1576
+ this.paletteEntry.innerHTML = `<span class="bts-icon bds-variables-icon">${VARIABLES_ICON}</span>`;
1577
+ this.closeButton.innerHTML = CLOSE_ICON;
1578
+ const icon = h("span", { className: "bds-variables-icon" });
1579
+ icon.innerHTML = VARIABLES_ICON;
1580
+ this.element = h(
1581
+ "aside",
1582
+ { className: "bds-panel", "aria-label": "Process Data" },
1583
+ h(
1584
+ "header",
1585
+ { className: "bds-panel-header" },
1586
+ icon,
1587
+ h("h2", { className: "bds-panel-heading" }, "Process Data"),
1588
+ this.closeButton
1589
+ ),
1590
+ h(
1591
+ "div",
1592
+ { className: "bds-panel-body" },
1593
+ h("p", { className: "bds-panel-engine" }, this.engineBadge),
1594
+ h("section", { className: "bds-section bds-instance" }, this.instanceTitle, this.instanceBody),
1595
+ this.issueSection
1596
+ )
1597
+ );
1598
+ this.paletteEntry.addEventListener("click", () => this.toggle());
1599
+ this.closeButton.addEventListener("click", () => this.toggle(false));
1600
+ this.instancePicker.addEventListener("change", () => this.actions.selectInstance(this.instancePicker.value));
1601
+ this.toggle(false);
1602
+ }
1603
+ toggle(shown = this.element.hidden === true) {
1604
+ this.element.hidden = !shown;
1605
+ this.paletteEntry.classList.toggle("active", shown);
1606
+ }
1607
+ render(snapshot) {
1608
+ this.snapshot = snapshot;
1609
+ this.engineBadge.textContent = `${snapshot.engineLabel} \xB7 ${snapshot.expressionLanguage}`;
1610
+ this.renderInstance(snapshot);
1611
+ this.renderIssues(snapshot);
1612
+ }
1613
+ renderInstance({ instances, selectedInstanceId, scenarios }) {
1614
+ const editedInstance = instances.find((candidate) => candidate.id === this.editingInstanceId);
1615
+ if (editedInstance && editedInstance.status !== "completed" && editedInstance.id !== selectedInstanceId) {
1616
+ this.actions.selectInstance(editedInstance.id);
1617
+ return;
1618
+ }
1619
+ const instance = instances.find((candidate) => candidate.id === selectedInstanceId);
1620
+ this.renderInstancePicker(instances, selectedInstanceId, scenarios);
1621
+ if (this.editingInstanceId && this.editingInstanceId === instance?.id && instance.status !== "completed") return;
1622
+ this.editingInstanceId = void 0;
1623
+ this.instanceBody.replaceChildren(
1624
+ instance ? this.instanceView(instance) : h("p", { className: "bds-hint" }, "Press \u25B6 on a start event to start a process instance.")
1625
+ );
1626
+ }
1627
+ renderInstancePicker(instances, selectedInstanceId, scenarios) {
1628
+ const signature = JSON.stringify(instances.map((instance) => [instance.id, instance.status]));
1629
+ if (signature !== this.shownInstances) {
1630
+ this.shownInstances = signature;
1631
+ this.instancePicker.replaceChildren(
1632
+ ...instances.map((instance) => {
1633
+ const scenarioName = scenarios.find((scenario) => scenario.id === instance.scenarioId)?.name ?? "no scenario";
1634
+ return h("option", { value: instance.id }, `#${instance.number} ${scenarioName} (${instance.status})`);
1635
+ })
1636
+ );
1637
+ }
1638
+ this.instancePicker.value = selectedInstanceId ?? "";
1639
+ this.instancePicker.hidden = instances.length < 2;
1640
+ if (!this.instancePicker.isConnected) this.instanceTitle.after(this.instancePicker);
1641
+ }
1642
+ instanceView(instance) {
1643
+ const scenarioName = this.snapshot?.scenarios.find((scenario) => scenario.id === instance.scenarioId)?.name;
1644
+ const entries = Object.entries(instance.variables);
1645
+ const editButton = h("button", { className: "bds-button", type: "button" }, "Edit");
1646
+ editButton.addEventListener("click", () => this.editInstance(instance));
1647
+ return h(
1648
+ "div",
1649
+ {},
1650
+ h("p", { className: `bds-status bds-status--${instance.status}` }, this.describeStatus(instance)),
1651
+ scenarioName ? h("p", { className: "bds-hint" }, `Scenario: ${scenarioName}`) : null,
1652
+ entries.length ? h(
1653
+ "table",
1654
+ { className: "bds-variables" },
1655
+ h(
1656
+ "tbody",
1657
+ {},
1658
+ ...entries.map(
1659
+ ([name, value]) => h("tr", {}, h("th", { scope: "row" }, name), h("td", {}, h("code", {}, formatValue(value))))
1660
+ )
1661
+ )
1662
+ ) : h("p", { className: "bds-hint" }, "No variables yet."),
1663
+ h("p", { className: "bds-hint" }, "Hover a gateway to see why it took its flow, click it to keep the card open."),
1664
+ instance.status !== "completed" ? h("div", { className: "bds-actions" }, editButton) : null
1665
+ );
1666
+ }
1667
+ editInstance(instance) {
1668
+ this.editingInstanceId = instance.id;
1669
+ const editor = h("textarea", {
1670
+ className: "bds-input bds-json bds-instance-editor",
1671
+ spellcheck: "false",
1672
+ rows: "8",
1673
+ "aria-label": "Instance variables (JSON)"
1674
+ });
1675
+ editor.value = JSON.stringify(instance.variables, null, 2);
1676
+ const error = h("p", { className: "bds-error", role: "alert" });
1677
+ this.showError(error, editor, "");
1678
+ const applyButton = h("button", { className: "bds-button bds-button--primary", type: "button" }, "Apply");
1679
+ const cancelButton = h("button", { className: "bds-button", type: "button" }, "Cancel");
1680
+ applyButton.addEventListener("click", () => {
1681
+ const parsed = this.parseVariables(editor.value);
1682
+ if (typeof parsed === "string") {
1683
+ this.showError(error, editor, parsed);
1684
+ return;
1685
+ }
1686
+ this.editingInstanceId = void 0;
1687
+ this.actions.setInstanceVariables(instance.id, parsed);
1688
+ });
1689
+ cancelButton.addEventListener("click", () => {
1690
+ this.editingInstanceId = void 0;
1691
+ if (this.snapshot) this.renderInstance(this.snapshot);
1692
+ });
1693
+ this.instanceBody.replaceChildren(editor, error, h("div", { className: "bds-actions" }, cancelButton, applyButton));
1694
+ editor.focus();
1695
+ }
1696
+ renderIssues({ log, selectedInstanceId }) {
1697
+ const issues = log.filter(
1698
+ (entry) => entry.kind === "mapping-issue" && entry.instanceId === selectedInstanceId
1699
+ );
1700
+ this.issueSection.hidden = !issues.length;
1701
+ this.issueList.replaceChildren(
1702
+ ...issues.slice().reverse().map((issue) => this.renderMappingIssue(issue))
1703
+ );
1704
+ }
1705
+ describeStatus({ processName, status, waiting }) {
1706
+ if (status !== "waiting") return `${processName} \xB7 ${status}`;
1707
+ return `${processName} \xB7 waiting at ${waiting.map((gateway) => gateway.gatewayName).join(", ")}`;
1708
+ }
1709
+ showError(error, input, message) {
1673
1710
  error.textContent = message;
1674
1711
  error.hidden = !message;
1675
- input.classList.toggle('bds-input--invalid', Boolean(message));
1676
- }
1677
- function renderMappingIssue({ elementName, target, reason }) {
1678
- return h('li', { className: 'bds-log-entry bds-log-entry--issue' }, h('div', { className: 'bds-log-title' }, elementName, h('span', { className: 'bds-tag' }, 'mapping')), h('p', { className: 'bds-error' }, `${target}: ${reason}`));
1679
- }
1680
- function parseVariables(text) {
1712
+ input.classList.toggle("bds-input--invalid", Boolean(message));
1713
+ }
1714
+ renderMappingIssue({ elementName, target, reason }) {
1715
+ return h(
1716
+ "li",
1717
+ { className: "bds-log-entry bds-log-entry--issue" },
1718
+ h("div", { className: "bds-log-title" }, elementName, h("span", { className: "bds-tag" }, "mapping")),
1719
+ h("p", { className: "bds-error" }, `${target}: ${reason}`)
1720
+ );
1721
+ }
1722
+ parseVariables(text) {
1681
1723
  try {
1682
- const value = JSON.parse(text || '{}');
1683
- return isVariables(value) ? value : 'Variables must be a JSON object';
1684
- }
1685
- catch (error) {
1686
- return `Invalid JSON: ${error.message}`;
1724
+ const value = JSON.parse(text || "{}");
1725
+ return isVariables(value) ? value : "Variables must be a JSON object";
1726
+ } catch (error) {
1727
+ return `Invalid JSON: ${error.message}`;
1687
1728
  }
1729
+ }
1688
1730
  }
1689
1731
 
1690
1732
  const PALETTE_INDEX = 4;
1691
1733
  class DataSimulationPanel {
1692
- constructor(eventBus, canvas, palette, dataSimulation) {
1693
- const panel = new VariablesPanel({
1694
- selectInstance: instanceId => dataSimulation.selectInstance(instanceId),
1695
- setInstanceVariables: (instanceId, variables) => dataSimulation.setInstanceVariables(instanceId, variables),
1696
- });
1697
- panel.render(dataSimulation.getSnapshot());
1698
- const host = inShadow(panel.element);
1699
- canvas.getContainer().append(host);
1700
- palette.addEntry(panel.paletteEntry, PALETTE_INDEX);
1701
- const showPaletteEntry = () => {
1702
- panel.paletteEntry.hidden = !dataSimulation.isEnabled();
1703
- };
1704
- showPaletteEntry();
1705
- const unsubscribe = dataSimulation.subscribe(snapshot => panel.render(snapshot));
1706
- eventBus.on(TOGGLE_MODE_EVENT, () => panel.toggle(false));
1707
- eventBus.on(DATA_TOGGLE_EVENT, showPaletteEntry);
1708
- eventBus.on('diagram.destroy', () => {
1709
- unsubscribe();
1710
- host.remove();
1711
- panel.paletteEntry.remove();
1712
- });
1713
- }
1734
+ constructor(eventBus, canvas, palette, dataSimulation) {
1735
+ this.dataSimulation = dataSimulation;
1736
+ this.panel = new VariablesPanel({
1737
+ selectInstance: (instanceId) => dataSimulation.selectInstance(instanceId),
1738
+ setInstanceVariables: (instanceId, variables) => dataSimulation.setInstanceVariables(instanceId, variables)
1739
+ });
1740
+ this.panel.render(dataSimulation.getSnapshot());
1741
+ const host = inShadow(this.panel.element);
1742
+ canvas.getContainer().append(host);
1743
+ palette.addEntry(this.panel.paletteEntry, PALETTE_INDEX);
1744
+ this.showPaletteEntry();
1745
+ const unsubscribe = dataSimulation.subscribe((snapshot) => this.panel.render(snapshot));
1746
+ eventBus.on(TOGGLE_MODE_EVENT, () => this.panel.toggle(false));
1747
+ eventBus.on(DATA_TOGGLE_EVENT, () => this.showPaletteEntry());
1748
+ eventBus.on("diagram.destroy", () => {
1749
+ unsubscribe();
1750
+ host.remove();
1751
+ this.panel.paletteEntry.remove();
1752
+ });
1753
+ }
1754
+ showPaletteEntry() {
1755
+ this.panel.paletteEntry.hidden = !this.dataSimulation.isEnabled();
1756
+ }
1714
1757
  }
1715
- DataSimulationPanel.$inject = ['eventBus', 'canvas', 'tokenSimulationPalette', 'dataSimulation'];
1758
+ DataSimulationPanel.$inject = ["eventBus", "canvas", "tokenSimulationPalette", "dataSimulation"];
1716
1759
 
1717
- const LABEL = 'Data Simulation';
1760
+ const LABEL = "Data Simulation";
1718
1761
  const GAP = 8;
1719
1762
  const TOGGLE_ON = '<svg viewBox="0 0 26 14" aria-hidden="true"><rect x="1" y="1" width="24" height="12" rx="6" /><circle cx="18" cy="7" r="3.5" /></svg>';
1720
1763
  const TOGGLE_OFF = '<svg viewBox="0 0 26 14" aria-hidden="true"><rect x="1" y="1" width="24" height="12" rx="6" /><circle cx="8" cy="7" r="3.5" /></svg>';
1721
1764
  class DataSimulationToggle {
1722
- constructor(eventBus, canvas, toggleMode, dataSimulation) {
1723
- let simulating = false;
1724
- const button = h('button', { className: 'bds-data-toggle', type: 'button' });
1725
- const render = () => {
1726
- const enabled = dataSimulation.isEnabled();
1727
- button.innerHTML = `${LABEL} <span class="bds-data-toggle-icon">${enabled ? TOGGLE_ON : TOGGLE_OFF}</span>`;
1728
- button.classList.toggle('active', enabled);
1729
- button.setAttribute('aria-pressed', String(enabled));
1730
- };
1731
- let tokenToggleObserver;
1732
- const placeNextToTokenSimulationToggle = () => {
1733
- const container = canvas.getContainer();
1734
- const tokenToggle = container.querySelector('.bts-toggle-mode');
1735
- if (!tokenToggle)
1736
- return;
1737
- const containerBox = container.getBoundingClientRect();
1738
- const toggleBox = tokenToggle.getBoundingClientRect();
1739
- const scale = containerBox.width / container.offsetWidth || 1;
1740
- button.style.fontSize = getComputedStyle(tokenToggle).fontSize;
1741
- button.style.left = `${(toggleBox.right - containerBox.left) / scale + GAP}px`;
1742
- button.style.top = `${(toggleBox.top + toggleBox.height / 2 - containerBox.top) / scale - button.offsetHeight / 2}px`;
1743
- if (!tokenToggleObserver && typeof ResizeObserver === 'function') {
1744
- tokenToggleObserver = new ResizeObserver(placeNextToTokenSimulationToggle);
1745
- tokenToggleObserver.observe(tokenToggle);
1746
- }
1747
- };
1748
- render();
1749
- canvas.getContainer().append(button);
1750
- button.addEventListener('click', () => dataSimulation.setEnabled(!dataSimulation.isEnabled()));
1751
- eventBus.on(TOGGLE_MODE_EVENT, ({ active }) => {
1752
- simulating = active;
1753
- if (active)
1754
- placeNextToTokenSimulationToggle();
1755
- });
1756
- eventBus.on(DATA_TOGGLE_EVENT, () => {
1757
- render();
1758
- if (!simulating)
1759
- return;
1760
- toggleMode.toggleMode(false);
1761
- toggleMode.toggleMode(true);
1762
- });
1763
- eventBus.on('diagram.destroy', () => {
1764
- tokenToggleObserver?.disconnect();
1765
- button.remove();
1766
- });
1765
+ constructor(eventBus, canvas, toggleMode, dataSimulation) {
1766
+ this.canvas = canvas;
1767
+ this.dataSimulation = dataSimulation;
1768
+ this.button = h("button", { className: "bds-data-toggle", type: "button" });
1769
+ this.simulating = false;
1770
+ this.render();
1771
+ canvas.getContainer().append(this.button);
1772
+ this.button.addEventListener("click", () => dataSimulation.setEnabled(!dataSimulation.isEnabled()));
1773
+ eventBus.on(TOGGLE_MODE_EVENT, ({ active }) => {
1774
+ this.simulating = active;
1775
+ if (active) this.placeNextToTokenSimulationToggle();
1776
+ });
1777
+ eventBus.on(DATA_TOGGLE_EVENT, () => {
1778
+ this.render();
1779
+ if (!this.simulating) return;
1780
+ toggleMode.toggleMode(false);
1781
+ toggleMode.toggleMode(true);
1782
+ });
1783
+ eventBus.on("diagram.destroy", () => {
1784
+ this.tokenToggleObserver?.disconnect();
1785
+ this.button.remove();
1786
+ });
1787
+ }
1788
+ render() {
1789
+ const enabled = this.dataSimulation.isEnabled();
1790
+ this.button.innerHTML = `${LABEL} <span class="bds-data-toggle-icon">${enabled ? TOGGLE_ON : TOGGLE_OFF}</span>`;
1791
+ this.button.classList.toggle("active", enabled);
1792
+ this.button.setAttribute("aria-pressed", String(enabled));
1793
+ }
1794
+ placeNextToTokenSimulationToggle() {
1795
+ const container = this.canvas.getContainer();
1796
+ const tokenToggle = container.querySelector(".bts-toggle-mode");
1797
+ if (!tokenToggle) return;
1798
+ const containerBox = container.getBoundingClientRect();
1799
+ const toggleBox = tokenToggle.getBoundingClientRect();
1800
+ const scale = containerBox.width / container.offsetWidth || 1;
1801
+ this.button.style.fontSize = getComputedStyle(tokenToggle).fontSize;
1802
+ this.button.style.left = `${(toggleBox.right - containerBox.left) / scale + GAP}px`;
1803
+ this.button.style.top = `${(toggleBox.top + toggleBox.height / 2 - containerBox.top) / scale - this.button.offsetHeight / 2}px`;
1804
+ this.observeTokenToggle(tokenToggle);
1805
+ }
1806
+ observeTokenToggle(tokenToggle) {
1807
+ if (this.tokenToggleObserver || typeof ResizeObserver !== "function") return;
1808
+ this.tokenToggleObserver = new ResizeObserver(() => this.placeNextToTokenSimulationToggle());
1809
+ this.tokenToggleObserver.observe(tokenToggle);
1810
+ }
1811
+ }
1812
+ DataSimulationToggle.$inject = ["eventBus", "canvas", "toggleMode", "dataSimulation"];
1813
+
1814
+ class StartFieldDeriver {
1815
+ derive(usages, { examples = [], taskResultNames = [] } = {}) {
1816
+ const written = /* @__PURE__ */ new Set([
1817
+ ...usages.flatMap((usage) => usage.outputTargets.map((target) => this.topLevelName(target))),
1818
+ ...taskResultNames
1819
+ ]);
1820
+ const usedBy = /* @__PURE__ */ new Map();
1821
+ for (const usage of usages) {
1822
+ const localNames = new Set(usage.inputTargets.map((target) => this.topLevelName(target)));
1823
+ for (const name of [...usage.conditionReads, ...usage.inputReads, ...usage.outputReads]) {
1824
+ if (written.has(name) || localNames.has(name)) continue;
1825
+ if (!usedBy.has(name)) usedBy.set(name, /* @__PURE__ */ new Set());
1826
+ usedBy.get(name).add(usage.elementName);
1827
+ }
1767
1828
  }
1829
+ return [...usedBy.entries()].map(([name, elements]) => ({
1830
+ name,
1831
+ type: this.inferType(examples.map((example) => example[name]).find((value) => value !== void 0)),
1832
+ usedBy: [...elements]
1833
+ }));
1834
+ }
1835
+ topLevelName(path) {
1836
+ return path.split(".")[0];
1837
+ }
1838
+ inferType(example) {
1839
+ if (typeof example === "number") return "number";
1840
+ if (typeof example === "boolean") return "boolean";
1841
+ if (typeof example === "string") return "text";
1842
+ if (Array.isArray(example) || isVariables(example)) return "json";
1843
+ return "auto";
1844
+ }
1768
1845
  }
1769
- DataSimulationToggle.$inject = ['eventBus', 'canvas', 'toggleMode', 'dataSimulation'];
1770
1846
 
1771
- const NO_SCENARIO = '';
1772
- function openStartDialog(container, options) {
1773
- const { scenarios, renderer } = options;
1774
- let baseVariables = options.startVariables;
1775
- const scenarioSelect = h('select', { className: 'bds-input bds-scenario-select', 'aria-label': 'Scenario' });
1776
- scenarioSelect.append(h('option', { value: NO_SCENARIO }, 'No scenario'), ...scenarios.map(scenario => h('option', { value: scenario.id }, scenario.name)));
1777
- scenarioSelect.value = options.selectedScenarioId ?? NO_SCENARIO;
1778
- const scenarioDescription = h('p', { className: 'bds-hint' });
1779
- const formContainer = h('div', { className: 'bds-dialog-form' });
1780
- const noFieldsHint = h('p', { className: 'bds-hint' }, 'The process reads no start variables.');
1781
- const error = h('p', { className: 'bds-error', role: 'alert' });
1782
- error.hidden = true;
1783
- const cancelButton = h('button', { className: 'bds-button', type: 'button' }, 'Cancel');
1784
- const startButton = h('button', { className: 'bds-button bds-button--primary', type: 'submit' }, 'Start instance');
1785
- const titleId = `bds-start-title-${Math.random().toString(36).slice(2)}`;
1786
- const form = h('form', { className: 'bds-dialog', role: 'dialog', 'aria-modal': 'true', 'aria-labelledby': titleId }, h('header', { className: 'bds-dialog-header' }, h('h2', { className: 'bds-panel-title', id: titleId }, `Start “${options.processName}”`), h('span', { className: 'bds-engine' }, options.engineLabel)), h('div', { className: 'bds-dialog-content' }, scenarios.length
1787
- ? h('section', { className: 'bds-section' }, h('label', { className: 'bds-label' }, 'Scenario', scenarioSelect), scenarioDescription)
1788
- : null, h('section', { className: 'bds-section' }, h('h3', { className: 'bds-section-title' }, 'Start variables'), formContainer, noFieldsHint), error), h('footer', { className: 'bds-actions' }, cancelButton, startButton));
1789
- const backdrop = h('div', { className: 'bds-dialog-backdrop' }, form);
1790
- const selectedScenarioId = () => scenarioSelect.value || null;
1791
- let fields = [];
1792
- const renderForm = () => {
1793
- fields = options.fieldsFor(selectedScenarioId());
1794
- noFieldsHint.hidden = fields.length > 0;
1795
- return renderer.render(formContainer, fields, baseVariables);
1796
- };
1797
- let rendered = renderForm();
1798
- const close = () => {
1799
- rendered.destroy();
1800
- backdrop.remove();
1801
- };
1802
- const showScenarioDescription = () => {
1803
- const description = scenarios.find(scenario => scenario.id === scenarioSelect.value)?.description ?? '';
1804
- scenarioDescription.textContent = description;
1805
- scenarioDescription.hidden = !description;
1806
- };
1807
- scenarioSelect.addEventListener('change', () => {
1808
- baseVariables = scenarios.find(scenario => scenario.id === scenarioSelect.value)?.variables ?? {};
1809
- rendered.destroy();
1810
- rendered = renderForm();
1811
- showScenarioDescription();
1847
+ const NO_SCENARIO = "";
1848
+ class StartDialog {
1849
+ constructor(options) {
1850
+ this.options = options;
1851
+ this.codec = new StartFieldCodec();
1852
+ this.scenarioSelect = h("select", {
1853
+ className: "bds-input bds-scenario-select",
1854
+ "aria-label": "Scenario"
1812
1855
  });
1813
- cancelButton.addEventListener('click', close);
1814
- backdrop.addEventListener('mousedown', event => {
1815
- if (event.target === backdrop)
1816
- close();
1856
+ this.scenarioDescription = h("p", { className: "bds-hint" });
1857
+ this.formContainer = h("div", { className: "bds-dialog-form" });
1858
+ this.noFieldsHint = h("p", { className: "bds-hint" }, "The process reads no start variables.");
1859
+ this.error = h("p", { className: "bds-error", role: "alert" });
1860
+ this.cancelButton = h("button", { className: "bds-button", type: "button" }, "Cancel");
1861
+ this.startButton = h(
1862
+ "button",
1863
+ { className: "bds-button bds-button--primary", type: "submit" },
1864
+ "Start instance"
1865
+ );
1866
+ this.fields = [];
1867
+ this.baseVariables = options.startVariables;
1868
+ this.scenarioSelect.append(
1869
+ h("option", { value: NO_SCENARIO }, "No scenario"),
1870
+ ...options.scenarios.map((scenario) => h("option", { value: scenario.id }, scenario.name))
1871
+ );
1872
+ this.scenarioSelect.value = options.selectedScenarioId ?? NO_SCENARIO;
1873
+ this.error.hidden = true;
1874
+ this.form = this.createForm();
1875
+ this.backdrop = h("div", { className: "bds-dialog-backdrop" }, this.form);
1876
+ this.rendered = this.renderForm();
1877
+ this.listen();
1878
+ }
1879
+ open(container) {
1880
+ this.showScenarioDescription();
1881
+ container.append(this.backdrop);
1882
+ if (this.fields.length) this.rendered.focus();
1883
+ else this.startButton.focus();
1884
+ }
1885
+ close() {
1886
+ this.rendered.destroy();
1887
+ this.backdrop.remove();
1888
+ }
1889
+ createForm() {
1890
+ const titleId = `bds-start-title-${Math.random().toString(36).slice(2)}`;
1891
+ return h(
1892
+ "form",
1893
+ { className: "bds-dialog", role: "dialog", "aria-modal": "true", "aria-labelledby": titleId },
1894
+ h(
1895
+ "header",
1896
+ { className: "bds-dialog-header" },
1897
+ h("h2", { className: "bds-panel-title", id: titleId }, `Start \u201C${this.options.processName}\u201D`),
1898
+ h("span", { className: "bds-engine" }, this.options.engineLabel)
1899
+ ),
1900
+ h(
1901
+ "div",
1902
+ { className: "bds-dialog-content" },
1903
+ this.options.scenarios.length ? h(
1904
+ "section",
1905
+ { className: "bds-section" },
1906
+ h("label", { className: "bds-label" }, "Scenario", this.scenarioSelect),
1907
+ this.scenarioDescription
1908
+ ) : null,
1909
+ h(
1910
+ "section",
1911
+ { className: "bds-section" },
1912
+ h("h3", { className: "bds-section-title" }, "Start variables"),
1913
+ this.formContainer,
1914
+ this.noFieldsHint
1915
+ ),
1916
+ this.error
1917
+ ),
1918
+ h("footer", { className: "bds-actions" }, this.cancelButton, this.startButton)
1919
+ );
1920
+ }
1921
+ listen() {
1922
+ this.scenarioSelect.addEventListener("change", () => this.switchScenario());
1923
+ this.cancelButton.addEventListener("click", () => this.close());
1924
+ this.backdrop.addEventListener("mousedown", (event) => {
1925
+ if (event.target === this.backdrop) this.close();
1817
1926
  });
1818
- backdrop.addEventListener('keydown', event => {
1819
- event.stopPropagation();
1820
- if (event.key === 'Escape')
1821
- close();
1927
+ this.backdrop.addEventListener("keydown", (event) => {
1928
+ event.stopPropagation();
1929
+ if (event.key === "Escape") this.close();
1822
1930
  });
1823
- form.addEventListener('submit', event => {
1824
- event.preventDefault();
1825
- const values = rendered.readValues();
1826
- if (!values.ok) {
1827
- error.textContent = values.reason;
1828
- error.hidden = false;
1829
- return;
1830
- }
1831
- close();
1832
- options.onStart(selectedScenarioId(), applyFieldValues(baseVariables, values.values));
1931
+ this.form.addEventListener("submit", (event) => {
1932
+ event.preventDefault();
1933
+ this.submit();
1833
1934
  });
1834
- showScenarioDescription();
1835
- container.append(backdrop);
1836
- if (fields.length)
1837
- rendered.focus();
1838
- else
1839
- startButton.focus();
1840
- return close;
1935
+ }
1936
+ selectedScenarioId() {
1937
+ return this.scenarioSelect.value || null;
1938
+ }
1939
+ selectedScenario() {
1940
+ return this.options.scenarios.find((scenario) => scenario.id === this.scenarioSelect.value);
1941
+ }
1942
+ renderForm() {
1943
+ this.fields = this.options.fieldsFor(this.selectedScenarioId());
1944
+ this.noFieldsHint.hidden = this.fields.length > 0;
1945
+ return this.options.renderer.render(this.formContainer, this.fields, this.baseVariables);
1946
+ }
1947
+ switchScenario() {
1948
+ this.baseVariables = this.selectedScenario()?.variables ?? {};
1949
+ this.rendered.destroy();
1950
+ this.rendered = this.renderForm();
1951
+ this.showScenarioDescription();
1952
+ }
1953
+ showScenarioDescription() {
1954
+ const description = this.selectedScenario()?.description ?? "";
1955
+ this.scenarioDescription.textContent = description;
1956
+ this.scenarioDescription.hidden = !description;
1957
+ }
1958
+ submit() {
1959
+ const values = this.rendered.readValues();
1960
+ if (!values.ok) {
1961
+ this.error.textContent = values.reason;
1962
+ this.error.hidden = false;
1963
+ return;
1964
+ }
1965
+ this.close();
1966
+ this.options.onStart(this.selectedScenarioId(), this.codec.apply(this.baseVariables, values.values));
1967
+ }
1841
1968
  }
1842
1969
 
1843
- class DataStartForm {
1844
- constructor(config, eventBus, dataSimulation, store) {
1845
- this.dataSimulation = dataSimulation;
1846
- this.store = store;
1847
- this.renderer = config?.startFormRenderer ?? simpleStartFormRenderer;
1848
- eventBus.on(TOGGLE_MODE_EVENT, () => this.closeDialog?.());
1849
- eventBus.on('diagram.destroy', () => {
1850
- this.closeDialog?.();
1851
- this.dialogHost?.remove();
1852
- });
1853
- }
1854
- isProcessStart(element) {
1855
- return (is(element, 'bpmn:StartEvent') &&
1856
- Boolean(element.parent) &&
1857
- (is(element.parent, 'bpmn:Process') || is(element.parent, 'bpmn:Participant')));
1858
- }
1859
- fieldsFor(startEvent, scenarioId) {
1860
- const snapshot = this.store.getSnapshot();
1861
- const examples = [snapshot.startVariables, ...snapshot.scenarios.map(scenario => scenario.variables)];
1862
- const taskResults = snapshot.scenarios.find(scenario => scenario.id === scenarioId)?.taskResults ?? {};
1863
- const taskResultNames = Object.values(taskResults).flatMap(result => Object.keys(result));
1864
- return deriveStartFields(this.collectUsages(startEvent.parent), { examples, taskResultNames });
1865
- }
1866
- open(startEvent, start) {
1867
- this.closeDialog?.();
1868
- const snapshot = this.store.getSnapshot();
1869
- this.dialogHost ?? (this.dialogHost = document.body.appendChild(inShadow()));
1870
- const close = openStartDialog(this.dialogHost.shadowRoot, {
1871
- processName: elementName(startEvent.parent),
1872
- engineLabel: `${snapshot.engineLabel} · ${snapshot.expressionLanguage}`,
1873
- scenarios: snapshot.scenarios,
1874
- selectedScenarioId: snapshot.selectedScenarioId,
1875
- startVariables: snapshot.startVariables,
1876
- fieldsFor: scenarioId => this.fieldsFor(startEvent, scenarioId),
1877
- renderer: this.renderer,
1878
- onStart: (scenarioId, variables) => {
1879
- this.closeDialog = undefined;
1880
- this.store.selectScenario(scenarioId);
1881
- this.store.setStartVariables(variables);
1882
- start();
1883
- },
1884
- });
1885
- this.closeDialog = () => {
1886
- close();
1887
- this.closeDialog = undefined;
1888
- };
1889
- }
1890
- collectUsages(container) {
1891
- const engine = this.dataSimulation.getEngine();
1892
- const usages = [];
1893
- const visit = (element) => {
1894
- if (element.type === 'label')
1895
- return;
1896
- const businessObject = element.businessObject;
1897
- if (is(element, 'bpmn:SequenceFlow')) {
1898
- const condition = engine.readCondition(businessObject);
1899
- if (condition)
1900
- usages.push(usage(element, { conditionReads: engine.readVariableNames(condition) }));
1901
- }
1902
- else if (is(element, 'bpmn:FlowNode')) {
1903
- const inputs = engine.readInputMappings(businessObject);
1904
- const outputs = engine.readOutputMappings(businessObject);
1905
- usages.push(usage(element, {
1906
- inputReads: inputs.flatMap(mapping => engine.readVariableNames(mapping.source)),
1907
- inputTargets: inputs.map(mapping => mapping.target),
1908
- outputReads: outputs.flatMap(mapping => engine.readVariableNames(mapping.source)),
1909
- outputTargets: outputs.map(mapping => mapping.target),
1910
- }));
1911
- }
1912
- element.children?.forEach(visit);
1913
- };
1914
- container.children?.forEach(visit);
1915
- return usages;
1916
- }
1917
- }
1918
- DataStartForm.$inject = ['config.dataSimulation', 'eventBus', 'dataSimulation', 'dataSimulationStore'];
1919
- function usage(element, reads) {
1920
- const target = is(element, 'bpmn:SequenceFlow') ? (element.source ?? element) : element;
1970
+ class VariableUsageCollector {
1971
+ constructor(engine) {
1972
+ this.engine = engine;
1973
+ }
1974
+ collect(container) {
1975
+ const usages = [];
1976
+ const visit = (element) => {
1977
+ if (element.type === "label") return;
1978
+ const usage = this.usageOf(element);
1979
+ if (usage) usages.push(usage);
1980
+ element.children?.forEach(visit);
1981
+ };
1982
+ container.children?.forEach(visit);
1983
+ return usages;
1984
+ }
1985
+ usageOf(element) {
1986
+ const businessObject = element.businessObject;
1987
+ if (is(element, "bpmn:SequenceFlow")) {
1988
+ const condition = this.engine.readCondition(businessObject);
1989
+ if (!condition) return void 0;
1990
+ return this.usage(element.source ?? element, { conditionReads: this.engine.readVariableNames(condition) });
1991
+ }
1992
+ if (!is(element, "bpmn:FlowNode")) return void 0;
1993
+ const inputs = this.engine.readInputMappings(businessObject);
1994
+ const outputs = this.engine.readOutputMappings(businessObject);
1995
+ return this.usage(element, {
1996
+ inputReads: inputs.flatMap((mapping) => this.engine.readVariableNames(mapping.source)),
1997
+ inputTargets: inputs.map((mapping) => mapping.target),
1998
+ outputReads: outputs.flatMap((mapping) => this.engine.readVariableNames(mapping.source)),
1999
+ outputTargets: outputs.map((mapping) => mapping.target)
2000
+ });
2001
+ }
2002
+ usage(element, reads) {
1921
2003
  return {
1922
- elementName: elementName(target),
1923
- conditionReads: [],
1924
- inputReads: [],
1925
- inputTargets: [],
1926
- outputReads: [],
1927
- outputTargets: [],
1928
- ...reads,
2004
+ elementName: elementName(element),
2005
+ conditionReads: [],
2006
+ inputReads: [],
2007
+ inputTargets: [],
2008
+ outputReads: [],
2009
+ outputTargets: [],
2010
+ ...reads
1929
2011
  };
2012
+ }
1930
2013
  }
1931
2014
 
2015
+ class DataStartForm {
2016
+ constructor(config, eventBus, dataSimulation, store) {
2017
+ this.store = store;
2018
+ this.fieldDeriver = new StartFieldDeriver();
2019
+ this.renderer = config?.startFormRenderer ?? new SimpleStartFormRenderer();
2020
+ this.usageCollector = new VariableUsageCollector(dataSimulation.getEngine());
2021
+ eventBus.on(TOGGLE_MODE_EVENT, () => this.closeDialog());
2022
+ eventBus.on("diagram.destroy", () => {
2023
+ this.closeDialog();
2024
+ this.dialogHost?.remove();
2025
+ });
2026
+ }
2027
+ isProcessStart(element) {
2028
+ return is(element, "bpmn:StartEvent") && Boolean(element.parent) && (is(element.parent, "bpmn:Process") || is(element.parent, "bpmn:Participant"));
2029
+ }
2030
+ fieldsFor(startEvent, scenarioId) {
2031
+ const snapshot = this.store.getSnapshot();
2032
+ const examples = [snapshot.startVariables, ...snapshot.scenarios.map((scenario) => scenario.variables)];
2033
+ const taskResults = snapshot.scenarios.find((scenario) => scenario.id === scenarioId)?.taskResults ?? {};
2034
+ const taskResultNames = Object.values(taskResults).flatMap((result) => Object.keys(result));
2035
+ return this.fieldDeriver.derive(this.usageCollector.collect(startEvent.parent), { examples, taskResultNames });
2036
+ }
2037
+ open(startEvent, start) {
2038
+ this.closeDialog();
2039
+ const snapshot = this.store.getSnapshot();
2040
+ this.dialogHost ?? (this.dialogHost = document.body.appendChild(inShadow()));
2041
+ this.dialog = new StartDialog({
2042
+ processName: elementName(startEvent.parent),
2043
+ engineLabel: `${snapshot.engineLabel} \xB7 ${snapshot.expressionLanguage}`,
2044
+ scenarios: snapshot.scenarios,
2045
+ selectedScenarioId: snapshot.selectedScenarioId,
2046
+ startVariables: snapshot.startVariables,
2047
+ fieldsFor: (scenarioId) => this.fieldsFor(startEvent, scenarioId),
2048
+ renderer: this.renderer,
2049
+ onStart: (scenarioId, variables) => {
2050
+ this.dialog = void 0;
2051
+ this.store.selectScenario(scenarioId);
2052
+ this.store.setStartVariables(variables);
2053
+ start();
2054
+ }
2055
+ });
2056
+ this.dialog.open(this.dialogHost.shadowRoot);
2057
+ }
2058
+ closeDialog() {
2059
+ this.dialog?.close();
2060
+ this.dialog = void 0;
2061
+ }
2062
+ }
2063
+ DataStartForm.$inject = ["config.dataSimulation", "eventBus", "dataSimulation", "dataSimulationStore"];
2064
+
1932
2065
  const DataSimulationModule = {
1933
- __init__: [
1934
- 'dataSimulation',
1935
- 'dataSimulationOverlays',
1936
- 'dataSimulationPanel',
1937
- 'dataSimulationToggle',
1938
- 'dataGatewayBehaviors',
1939
- 'dataGatewaySettings',
1940
- 'dataContextPads',
1941
- ],
1942
- dataSimulationStore: ['type', DataSimulationStore],
1943
- dataSimulation: ['type', DataSimulation],
1944
- dataSimulationOverlays: ['type', DataSimulationOverlays],
1945
- dataSimulationPanel: ['type', DataSimulationPanel],
1946
- dataSimulationToggle: ['type', DataSimulationToggle],
1947
- dataGateways: ['type', DataGateways],
1948
- dataStartForm: ['type', DataStartForm],
1949
- dataGatewayBehaviors: ['type', DataGatewayBehaviors],
1950
- dataGatewaySettings: ['type', DataGatewaySettings],
1951
- dataContextPads: ['type', DataContextPads],
2066
+ __init__: [
2067
+ "dataSimulation",
2068
+ "dataSimulationOverlays",
2069
+ "dataSimulationPanel",
2070
+ "dataSimulationToggle",
2071
+ "dataGatewayBehaviors",
2072
+ "dataGatewaySettings",
2073
+ "dataContextPads"
2074
+ ],
2075
+ dataSimulationStore: ["type", DataSimulationStore],
2076
+ dataSimulation: ["type", DataSimulation],
2077
+ dataSimulationOverlays: ["type", DataSimulationOverlays],
2078
+ dataSimulationPanel: ["type", DataSimulationPanel],
2079
+ dataSimulationToggle: ["type", DataSimulationToggle],
2080
+ dataGateways: ["type", DataGateways],
2081
+ dataStartForm: ["type", DataStartForm],
2082
+ dataGatewayBehaviors: ["type", DataGatewayBehaviors],
2083
+ dataGatewaySettings: ["type", DataGatewaySettings],
2084
+ dataContextPads: ["type", DataContextPads]
1952
2085
  };
1953
2086
 
2087
+ exports.Camunda7Engine = Camunda7Engine;
1954
2088
  exports.DataSimulationStore = DataSimulationStore;
2089
+ exports.EngineRegistry = EngineRegistry;
2090
+ exports.GatewayRouter = GatewayRouter;
1955
2091
  exports.ScenarioError = ScenarioError;
2092
+ exports.ScenarioParser = ScenarioParser;
2093
+ exports.SimpleStartFormRenderer = SimpleStartFormRenderer;
2094
+ exports.StartFieldCodec = StartFieldCodec;
2095
+ exports.ZeebeEngine = ZeebeEngine;
1956
2096
  exports.camunda7Engine = camunda7Engine;
1957
2097
  exports.default = DataSimulationModule;
1958
- exports.formatFieldValue = formatFieldValue;
1959
- exports.parseFieldValue = parseFieldValue;
1960
- exports.parseScenarios = parseScenarios;
1961
- exports.resolveEngine = resolveEngine;
1962
- exports.routeGateway = routeGateway;
1963
- exports.simpleStartFormRenderer = simpleStartFormRenderer;
1964
2098
  exports.zeebeEngine = zeebeEngine;
1965
2099
  //# sourceMappingURL=index.cjs.map