@emaarco/bpmn-js-data-simulation 0.1.0 → 0.3.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 (120) hide show
  1. package/README.md +1 -1
  2. package/dist/domain/GatewayRouter.d.ts +11 -0
  3. package/dist/domain/GatewayRouter.d.ts.map +1 -0
  4. package/dist/domain/ScenarioError.d.ts +4 -0
  5. package/dist/domain/ScenarioError.d.ts.map +1 -0
  6. package/dist/domain/ScenarioParser.d.ts +7 -0
  7. package/dist/domain/ScenarioParser.d.ts.map +1 -0
  8. package/dist/domain/StartFieldCodec.d.ts +7 -0
  9. package/dist/domain/StartFieldCodec.d.ts.map +1 -0
  10. package/dist/domain/StartFieldDeriver.d.ts +7 -0
  11. package/dist/domain/StartFieldDeriver.d.ts.map +1 -0
  12. package/dist/domain/model.d.ts +32 -0
  13. package/dist/domain/model.d.ts.map +1 -1
  14. package/dist/engines/EngineRegistry.d.ts +6 -0
  15. package/dist/engines/EngineRegistry.d.ts.map +1 -0
  16. package/dist/engines/camunda7/Camunda7Engine.d.ts +19 -0
  17. package/dist/engines/camunda7/Camunda7Engine.d.ts.map +1 -0
  18. package/dist/engines/camunda7/juel/JuelError.d.ts +4 -0
  19. package/dist/engines/camunda7/juel/JuelError.d.ts.map +1 -0
  20. package/dist/engines/camunda7/juel/JuelEvaluator.d.ts +18 -0
  21. package/dist/engines/camunda7/juel/JuelEvaluator.d.ts.map +1 -0
  22. package/dist/engines/camunda7/juel/JuelLexer.d.ts +6 -0
  23. package/dist/engines/camunda7/juel/JuelLexer.d.ts.map +1 -0
  24. package/dist/engines/camunda7/juel/JuelParser.d.ts +19 -0
  25. package/dist/engines/camunda7/juel/JuelParser.d.ts.map +1 -0
  26. package/dist/engines/camunda7/juel/JuelTemplate.d.ts +11 -0
  27. package/dist/engines/camunda7/juel/JuelTemplate.d.ts.map +1 -0
  28. package/dist/engines/camunda7/juel/juelSyntax.d.ts +34 -0
  29. package/dist/engines/camunda7/juel/juelSyntax.d.ts.map +1 -0
  30. package/dist/engines/engines.d.ts +5 -0
  31. package/dist/engines/engines.d.ts.map +1 -0
  32. package/dist/engines/types.d.ts +4 -2
  33. package/dist/engines/types.d.ts.map +1 -1
  34. package/dist/engines/zeebe/ZeebeEngine.d.ts +23 -0
  35. package/dist/engines/zeebe/ZeebeEngine.d.ts.map +1 -0
  36. package/dist/index.cjs +1873 -1741
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.d.ts +10 -6
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +1868 -1737
  41. package/dist/index.js.map +1 -1
  42. package/dist/integration/DataGateways.d.ts +2 -1
  43. package/dist/integration/DataGateways.d.ts.map +1 -1
  44. package/dist/integration/DataSimulation.d.ts +2 -1
  45. package/dist/integration/DataSimulation.d.ts.map +1 -1
  46. package/dist/integration/DataSimulationOverlays.d.ts.map +1 -1
  47. package/dist/integration/DataSimulationPanel.d.ts +3 -0
  48. package/dist/integration/DataSimulationPanel.d.ts.map +1 -1
  49. package/dist/integration/DataSimulationToggle.d.ts +8 -0
  50. package/dist/integration/DataSimulationToggle.d.ts.map +1 -1
  51. package/dist/integration/DataStartForm.d.ts +5 -4
  52. package/dist/integration/DataStartForm.d.ts.map +1 -1
  53. package/dist/integration/IoMappings.d.ts +11 -0
  54. package/dist/integration/IoMappings.d.ts.map +1 -0
  55. package/dist/integration/VariableUsageCollector.d.ts +11 -0
  56. package/dist/integration/VariableUsageCollector.d.ts.map +1 -0
  57. package/dist/integration/behaviors/DataContextPads.d.ts +5 -0
  58. package/dist/integration/behaviors/DataContextPads.d.ts.map +1 -1
  59. package/dist/integration/behaviors/DataGatewayBehaviors.d.ts +2 -0
  60. package/dist/integration/behaviors/DataGatewayBehaviors.d.ts.map +1 -1
  61. package/dist/integration/behaviors/DataGatewaySettings.d.ts +2 -0
  62. package/dist/integration/behaviors/DataGatewaySettings.d.ts.map +1 -1
  63. package/dist/integration/tokenSimulation.d.ts +0 -3
  64. package/dist/integration/tokenSimulation.d.ts.map +1 -1
  65. package/dist/simulation/DataSimulationStore.d.ts +2 -2
  66. package/dist/simulation/DataSimulationStore.d.ts.map +1 -1
  67. package/dist/simulation/GatewayDecisionView.d.ts +10 -0
  68. package/dist/simulation/GatewayDecisionView.d.ts.map +1 -0
  69. package/dist/ui/DecisionCard.d.ts +8 -0
  70. package/dist/ui/DecisionCard.d.ts.map +1 -0
  71. package/dist/ui/OutcomeBadge.d.ts +6 -0
  72. package/dist/ui/OutcomeBadge.d.ts.map +1 -0
  73. package/dist/ui/SimpleStartForm.d.ts +15 -2
  74. package/dist/ui/SimpleStartForm.d.ts.map +1 -1
  75. package/dist/ui/SimpleStartFormRenderer.d.ts +6 -0
  76. package/dist/ui/SimpleStartFormRenderer.d.ts.map +1 -0
  77. package/dist/ui/StartDialog.d.ts +28 -4
  78. package/dist/ui/StartDialog.d.ts.map +1 -1
  79. package/dist/ui/VariablesPanel.d.ts +4 -0
  80. package/dist/ui/VariablesPanel.d.ts.map +1 -1
  81. package/dist/ui/startForm.d.ts +1 -2
  82. package/dist/ui/startForm.d.ts.map +1 -1
  83. package/dist/utils/badgePosition.d.ts +10 -0
  84. package/dist/utils/badgePosition.d.ts.map +1 -0
  85. package/dist/utils/diagramElements.d.ts +7 -0
  86. package/dist/utils/diagramElements.d.ts.map +1 -0
  87. package/dist/utils/dom.d.ts.map +1 -0
  88. package/dist/{engines → utils}/moddle.d.ts +1 -1
  89. package/dist/{engines → utils}/moddle.d.ts.map +1 -1
  90. package/dist/utils/objects.d.ts +3 -0
  91. package/dist/utils/objects.d.ts.map +1 -0
  92. package/dist/utils/popoverPlacement.d.ts.map +1 -0
  93. package/dist/utils/shadow.d.ts.map +1 -0
  94. package/dist/utils/variables.d.ts +5 -0
  95. package/dist/utils/variables.d.ts.map +1 -0
  96. package/package.json +13 -13
  97. package/dist/domain/routing.d.ts +0 -4
  98. package/dist/domain/routing.d.ts.map +0 -1
  99. package/dist/domain/scenario.d.ts +0 -13
  100. package/dist/domain/scenario.d.ts.map +0 -1
  101. package/dist/domain/startFields.d.ts +0 -31
  102. package/dist/domain/startFields.d.ts.map +0 -1
  103. package/dist/domain/variables.d.ts +0 -4
  104. package/dist/domain/variables.d.ts.map +0 -1
  105. package/dist/engines/camunda7/camunda7Engine.d.ts +0 -3
  106. package/dist/engines/camunda7/camunda7Engine.d.ts.map +0 -1
  107. package/dist/engines/camunda7/juel.d.ts +0 -32
  108. package/dist/engines/camunda7/juel.d.ts.map +0 -1
  109. package/dist/engines/index.d.ts +0 -7
  110. package/dist/engines/index.d.ts.map +0 -1
  111. package/dist/engines/zeebe/zeebeEngine.d.ts +0 -3
  112. package/dist/engines/zeebe/zeebeEngine.d.ts.map +0 -1
  113. package/dist/ui/dom.d.ts.map +0 -1
  114. package/dist/ui/overlayContent.d.ts +0 -5
  115. package/dist/ui/overlayContent.d.ts.map +0 -1
  116. package/dist/ui/popoverPlacement.d.ts.map +0 -1
  117. package/dist/ui/shadow.d.ts.map +0 -1
  118. /package/dist/{ui → utils}/dom.d.ts +0 -0
  119. /package/dist/{ui → utils}/popoverPlacement.d.ts +0 -0
  120. /package/dist/{ui → utils}/shadow.d.ts +0 -0
package/dist/index.cjs CHANGED
@@ -4,1962 +4,2094 @@ 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;
205
+ constructor() {
206
+ super(...arguments);
207
+ this.name = "JuelError";
208
+ }
288
209
  }
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('');
296
- }
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
+ readIoMappings(element) {
609
+ return {
610
+ inputs: this.readMappings(element, "inputParameters"),
611
+ outputs: this.readMappings(element, "outputParameters")
612
+ };
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));
621
+ JuelTemplate.parse(expression);
622
+ return true;
623
+ } catch {
624
+ return false;
695
625
  }
696
- catch {
697
- return [];
698
- }
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
+ readIoMappings(element) {
665
+ return {
666
+ inputs: this.readMappings(element, "inputParameters"),
667
+ outputs: this.readMappings(element, "outputParameters")
668
+ };
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;
717
+ feelin.evaluate(this.feelBody(expression), {});
718
+ return true;
719
+ } catch {
720
+ return false;
777
721
  }
778
- catch {
779
- return false;
780
- }
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);
988
- }
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' });
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
+ }
997
959
  }
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, outputs } = this.engine.readIoMappings(element.businessObject);
1155
+ const taskResult = this.store.getTaskResult(instanceId, element.id);
1156
+ if (!inputs.length && !outputs.length && !taskResult) return;
1157
+ const processVariables = this.store.getVariables(instanceId);
1158
+ const localVariables = this.evaluate(element, instanceId, inputs, {}, (current) => ({
1159
+ ...processVariables,
1160
+ ...current
1161
+ }));
1162
+ const context = { ...processVariables, ...localVariables, ...taskResult };
1163
+ const propagatesTaskResult = taskResult && (this.engine.taskResultPropagation === "always" || !outputs.length);
1164
+ const withTaskResult = propagatesTaskResult ? { ...processVariables, ...withoutKeys(taskResult, Object.keys(localVariables)) } : processVariables;
1165
+ this.store.setVariables(
1166
+ instanceId,
1167
+ this.evaluate(element, instanceId, outputs, withTaskResult, () => context)
1168
+ );
1169
+ }
1170
+ evaluate(element, instanceId, mappings, target, contextOf) {
1171
+ let result = target;
1172
+ for (const mapping of mappings) {
1173
+ const evaluation = this.engine.evaluate(mapping.source, contextOf(result));
1174
+ if (evaluation.ok) {
1175
+ result = this.engine.writeVariable(result, mapping.target, evaluation.value);
1176
+ } else {
1148
1177
  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
- };
1178
+ kind: "mapping-issue",
1179
+ instanceId,
1180
+ elementId: element.id,
1181
+ elementName: elementName(element),
1182
+ target: mapping.target,
1183
+ reason: evaluation.reason
1186
1184
  });
1185
+ }
1187
1186
  }
1188
- sequenceFlows(gateway) {
1189
- return (gateway.outgoing ?? []).filter(flow => is(flow, 'bpmn:SequenceFlow'));
1190
- }
1187
+ return result;
1188
+ }
1191
1189
  }
1192
- DataGateways.$inject = ['dataSimulation', 'dataSimulationStore', 'simulator'];
1190
+
1191
+ const TOGGLE_MODE_EVENT = "tokenSimulation.toggleMode";
1192
+ const RESET_SIMULATION_EVENT = "tokenSimulation.resetSimulation";
1193
+ const SCOPE_CREATE_EVENT = "tokenSimulation.simulator.createScope";
1194
+ const SCOPE_DESTROYED_EVENT = "tokenSimulation.simulator.destroyScope";
1195
+ const TRACE_EVENT = "tokenSimulation.simulator.trace";
1196
+ const DATA_TOGGLE_EVENT = "dataSimulation.toggle";
1193
1197
 
1194
1198
  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));
1199
+ constructor(config, eventBus, store) {
1200
+ this.eventBus = eventBus;
1201
+ this.store = store;
1202
+ this.scenarioParser = new ScenarioParser();
1203
+ this.engine = new EngineRegistry().resolve(config?.engine ?? "zeebe");
1204
+ this.ioMappings = new IoMappings(this.engine, store);
1205
+ this.enabled = config?.enabled ?? true;
1206
+ this.store.setEngine(this.engine.label, this.engine.expressionLanguage);
1207
+ if (config?.scenarios !== void 0) this.setScenarios(config.scenarios);
1208
+ eventBus.on(SCOPE_CREATE_EVENT, ({ scope }) => this.onScopeCreated(scope));
1209
+ eventBus.on(SCOPE_DESTROYED_EVENT, ({ scope }) => {
1210
+ this.store.completeInstance(scope.id);
1211
+ this.store.removeWaiting(scope.id);
1212
+ });
1213
+ eventBus.on(TRACE_EVENT, (event) => {
1214
+ if (event.action === "exit") this.applyMappings(event.element, event.scope);
1215
+ });
1216
+ eventBus.on([RESET_SIMULATION_EVENT, TOGGLE_MODE_EVENT], () => this.store.reset());
1217
+ }
1218
+ getEngine() {
1219
+ return this.engine;
1220
+ }
1221
+ isEnabled() {
1222
+ return this.enabled;
1223
+ }
1224
+ setEnabled(enabled) {
1225
+ if (enabled === this.enabled) return;
1226
+ this.enabled = enabled;
1227
+ this.store.reset();
1228
+ this.eventBus.fire(DATA_TOGGLE_EVENT, { enabled });
1229
+ }
1230
+ setScenarios(input) {
1231
+ this.store.setScenarios(this.scenarioParser.parse(input));
1232
+ }
1233
+ selectScenario(scenarioId) {
1234
+ this.store.selectScenario(scenarioId);
1235
+ }
1236
+ setStartVariables(variables) {
1237
+ this.store.setStartVariables(variables);
1238
+ }
1239
+ selectInstance(instanceId) {
1240
+ this.store.selectInstance(instanceId);
1241
+ }
1242
+ setInstanceVariables(instanceId, variables) {
1243
+ this.store.setVariables(instanceId, variables);
1244
+ }
1245
+ getVariables(scope) {
1246
+ return this.store.getVariables(findProcessInstance(scope).id);
1247
+ }
1248
+ getSnapshot() {
1249
+ return this.store.getSnapshot();
1250
+ }
1251
+ subscribe(listener) {
1252
+ return this.store.subscribe(listener);
1253
+ }
1254
+ onScopeCreated(scope) {
1255
+ if (!this.enabled || scope.parent || !is(scope.element, "bpmn:Process") && !is(scope.element, "bpmn:Participant"))
1256
+ return;
1257
+ this.store.startInstance(scope.id, elementName(scope.element));
1258
+ }
1259
+ applyMappings(element, scope) {
1260
+ if (!is(element, "bpmn:FlowNode") || scope.failed || scope.canceled) return;
1261
+ const instanceId = findProcessInstance(scope).id;
1262
+ if (this.store.hasInstance(instanceId)) this.ioMappings.apply(element, instanceId);
1263
+ }
1264
+ }
1265
+ DataSimulation.$inject = ["config.dataSimulation", "eventBus", "dataSimulationStore"];
1266
+
1267
+ class GatewayDecisionView {
1268
+ constructor(snapshot) {
1269
+ this.snapshot = snapshot;
1270
+ this.decisions = this.latestDecisionPerGateway();
1271
+ const shownPerGateway = new Map(this.decisions.map((entry) => [entry.elementId, entry]));
1272
+ for (const entry of this.latestStuckDecisionPerGateway()) shownPerGateway.set(entry.elementId, entry);
1273
+ this.shown = [...shownPerGateway.values()];
1274
+ }
1275
+ latestDecisionPerGateway() {
1276
+ const { log, selectedInstanceId } = this.snapshot;
1277
+ const latest = /* @__PURE__ */ new Map();
1278
+ for (const entry of log) {
1279
+ if (entry.kind === "decision" && entry.instanceId === selectedInstanceId) latest.set(entry.elementId, entry);
1278
1280
  }
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;
1281
+ return [...latest.values()];
1282
+ }
1283
+ latestStuckDecisionPerGateway() {
1284
+ const { instances, log } = this.snapshot;
1285
+ const latest = /* @__PURE__ */ new Map();
1286
+ for (const instance of instances) {
1287
+ for (const { gatewayId } of instance.waiting) {
1288
+ const decision = [...log].reverse().find(
1289
+ (entry) => entry.kind === "decision" && entry.instanceId === instance.id && entry.elementId === gatewayId
1290
+ );
1291
+ if (decision && (latest.get(gatewayId)?.id ?? 0) < decision.id) latest.set(gatewayId, decision);
1292
+ }
1298
1293
  }
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)));
1294
+ return [...latest.values()];
1295
+ }
1303
1296
  }
1304
1297
 
1305
1298
  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' },
1299
+ taken: { symbol: "\u2713", title: "Taken" },
1300
+ "not-taken": { symbol: "\u2717", title: "Condition is false" },
1301
+ error: { symbol: "!", title: "Condition could not be evaluated" },
1302
+ skipped: { symbol: "\u2013", title: "Not evaluated" }
1310
1303
  };
1311
1304
  const DEFAULT_FLOW_TITLES = {
1312
- taken: 'Default flow taken, no condition is true',
1313
- 'not-taken': 'Default flow not needed',
1305
+ taken: "Default flow taken, no condition is true",
1306
+ "not-taken": "Default flow not needed"
1314
1307
  };
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;
1308
+ class OutcomeBadge {
1309
+ constructor(outcome, detail, isDefault = false) {
1310
+ this.element = document.createElement("span");
1311
+ const title = isDefault && DEFAULT_FLOW_TITLES[outcome] || OUTCOME_LABELS[outcome].title;
1312
+ this.element.className = `bds-outcome bds-outcome--${outcome}`;
1313
+ this.element.textContent = OUTCOME_LABELS[outcome].symbol;
1314
+ this.element.title = detail ? `${title}: ${detail}` : title;
1315
+ }
1323
1316
  }
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);
1317
+
1318
+ class DecisionCard {
1319
+ constructor({ elementName, gatewayKind, chosenBy, decision, inputs }, onClose) {
1320
+ this.element = h(
1321
+ "div",
1322
+ { className: `bds-decision${decision.stuckReason ? " bds-decision--stuck" : ""}`, role: "note" },
1323
+ h(
1324
+ "div",
1325
+ { className: "bds-decision-title" },
1326
+ h("span", {}, elementName),
1327
+ h("span", { className: "bds-tag" }, chosenBy === "click" ? `${gatewayKind} \xB7 by click` : gatewayKind),
1328
+ onClose ? this.closeButton(onClose) : null
1329
+ ),
1330
+ decision.stuckReason ? h(
1331
+ "p",
1332
+ { className: "bds-error" },
1333
+ `${decision.stuckReason}. Change the variables in Process Data, then press \u25B6 on the gateway.`
1334
+ ) : null,
1335
+ h(
1336
+ "ul",
1337
+ { className: "bds-flows" },
1338
+ ...decision.flows.map(
1339
+ ({ flow, outcome, reason }) => h(
1340
+ "li",
1341
+ { className: `bds-flow bds-flow--${outcome}` },
1342
+ new OutcomeBadge(outcome, reason, flow.isDefault).element,
1343
+ h("span", { className: "bds-flow-name" }, flow.name ?? flow.id),
1344
+ flow.isDefault ? h("span", { className: "bds-tag" }, "default") : flow.expression && h("code", {}, flow.expression)
1345
+ )
1346
+ )
1347
+ ),
1348
+ inputs.length ? this.inputList(inputs) : null
1349
+ );
1350
+ }
1351
+ closeButton(onClose) {
1352
+ const button = h(
1353
+ "button",
1354
+ { className: "bds-icon-button bds-decision-close", type: "button", "aria-label": "Close" },
1355
+ "\xD7"
1356
+ );
1357
+ button.addEventListener("click", onClose);
1358
+ return button;
1359
+ }
1360
+ inputList(inputs) {
1361
+ return h(
1362
+ "dl",
1363
+ { className: "bds-decision-inputs" },
1364
+ ...inputs.flatMap(({ name, value }) => [
1365
+ h("dt", {}, name),
1366
+ h(
1367
+ "dd",
1368
+ {},
1369
+ value === void 0 ? h("span", { className: "bds-hint" }, "not set") : h("code", {}, formatValue(value))
1370
+ )
1371
+ ])
1372
+ );
1373
+ }
1334
1374
  }
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
- ]));
1375
+
1376
+ function badgePosition(waypoints, distanceFromStart) {
1377
+ const [start, next] = waypoints;
1378
+ const length = Math.hypot(next.x - start.x, next.y - start.y) || 1;
1379
+ const distance = Math.min(distanceFromStart, length / 2);
1380
+ const x = start.x + (next.x - start.x) / length * distance;
1381
+ const y = start.y + (next.y - start.y) / length * distance;
1382
+ const minX = Math.min(...waypoints.map((point) => point.x));
1383
+ const minY = Math.min(...waypoints.map((point) => point.y));
1384
+ return { left: x - minX, top: y - minY };
1340
1385
  }
1341
1386
 
1342
1387
  const GAP$1 = 12;
1343
1388
  const MARGIN = 8;
1344
1389
  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
- };
1390
+ const below = anchor.y + anchor.height + GAP$1;
1391
+ const above = anchor.y - GAP$1 - popover.height;
1392
+ const fitsBelow = below + popover.height <= bounds.height - MARGIN;
1393
+ const fitsAbove = above >= MARGIN;
1394
+ const height = Math.min(popover.height, bounds.height - 2 * MARGIN);
1395
+ return {
1396
+ left: clamp(anchor.x + anchor.width / 2 - popover.width / 2, MARGIN, bounds.width - popover.width - MARGIN),
1397
+ top: fitsBelow ? below : fitsAbove ? above : clamp(below, MARGIN, bounds.height - height - MARGIN),
1398
+ maxHeight: height < popover.height ? height : void 0,
1399
+ hidden: !isInView(anchor, bounds)
1400
+ };
1356
1401
  }
1357
1402
  function clamp(value, min, max) {
1358
- return Math.max(min, Math.min(value, max));
1403
+ return Math.max(min, Math.min(value, max));
1359
1404
  }
1360
1405
  function isInView(anchor, bounds) {
1361
- return (anchor.x + anchor.width > 0 && anchor.x < bounds.width && anchor.y + anchor.height > 0 && anchor.y < bounds.height);
1406
+ return anchor.x + anchor.width > 0 && anchor.x < bounds.width && anchor.y + anchor.height > 0 && anchor.y < bounds.height;
1362
1407
  }
1363
1408
 
1364
1409
  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
1410
 
1366
1411
  let sharedSheet;
1367
1412
  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;
1413
+ const host = h("div", { className: "bds-host" });
1414
+ const root = host.attachShadow({ mode: "open" });
1415
+ adoptComponentStyles(root);
1416
+ root.append(...children);
1417
+ return host;
1373
1418
  }
1374
1419
  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
- }
1420
+ if ("adoptedStyleSheets" in root && "replaceSync" in CSSStyleSheet.prototype) {
1421
+ sharedSheet ?? (sharedSheet = createSheet());
1422
+ root.adoptedStyleSheets = [sharedSheet];
1423
+ } else {
1424
+ root.append(h("style", {}, componentStyles));
1425
+ }
1382
1426
  }
1383
1427
  function createSheet() {
1384
- const sheet = new CSSStyleSheet();
1385
- sheet.replaceSync(componentStyles);
1386
- return sheet;
1428
+ const sheet = new CSSStyleSheet();
1429
+ sheet.replaceSync(componentStyles);
1430
+ return sheet;
1387
1431
  }
1388
1432
 
1389
- const OUTCOME_OVERLAY = 'bds-flow-outcome';
1390
- const DECIDED_MARKER = 'bds-gateway--decided';
1391
- const STUCK_MARKER = 'bds-gateway--stuck';
1433
+ const OUTCOME_OVERLAY = "bds-flow-outcome";
1434
+ const DECIDED_MARKER = "bds-gateway--decided";
1435
+ const STUCK_MARKER = "bds-gateway--stuck";
1392
1436
  const BADGE_DISTANCE = 38;
1393
1437
  const BADGE_MIN_SCALE = 1;
1394
1438
  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
- }
1439
+ constructor(eventBus, overlays, elementRegistry, canvas, dataSimulation) {
1440
+ this.overlays = overlays;
1441
+ this.elementRegistry = elementRegistry;
1442
+ this.canvas = canvas;
1443
+ this.pinnedGatewayIds = /* @__PURE__ */ new Set();
1444
+ this.markedGateways = [];
1445
+ this.popovers = [];
1446
+ this.popoverLayer = inShadow();
1447
+ this.renderedState = "";
1448
+ this.snapshot = dataSimulation.getSnapshot();
1449
+ const unsubscribe = dataSimulation.subscribe((snapshot) => {
1450
+ this.snapshot = snapshot;
1451
+ this.render();
1452
+ });
1453
+ eventBus.on("element.hover", ({ element }) => {
1454
+ this.hoveredGatewayId = gatewayOf(element);
1455
+ this.render();
1456
+ });
1457
+ eventBus.on("element.click", ({ element }) => {
1458
+ if (!isGateway(element)) return;
1459
+ if (!this.pinnedGatewayIds.delete(element.id)) this.pinnedGatewayIds.add(element.id);
1460
+ this.render();
1461
+ });
1462
+ eventBus.on(["canvas.viewbox.changed", "canvas.resized"], () => this.placePopovers());
1463
+ canvas.getContainer().append(this.popoverLayer);
1464
+ eventBus.on("diagram.destroy", () => {
1465
+ unsubscribe();
1466
+ this.popoverLayer.remove();
1467
+ });
1468
+ }
1469
+ render() {
1470
+ const { decisions, shown } = new GatewayDecisionView(this.snapshot);
1471
+ const cards = shown.filter(
1472
+ ({ elementId }) => elementId === this.hoveredGatewayId || this.pinnedGatewayIds.has(elementId)
1473
+ );
1474
+ const state = JSON.stringify([
1475
+ decisions.map((entry) => entry.id),
1476
+ shown.map((entry) => entry.id),
1477
+ cards.map((entry) => [entry.id, this.pinnedGatewayIds.has(entry.elementId)])
1478
+ ]);
1479
+ if (state === this.renderedState) return;
1480
+ this.renderedState = state;
1481
+ this.overlays.remove({ type: OUTCOME_OVERLAY });
1482
+ this.unmarkGateways();
1483
+ for (const entry of decisions) this.showOutcomes(entry.decision);
1484
+ for (const entry of shown) this.markGateway(entry);
1485
+ this.showCards(cards);
1486
+ }
1487
+ markGateway({ elementId, decision }) {
1488
+ const gateway = this.elementRegistry.get(elementId);
1489
+ if (!gateway) return;
1490
+ this.canvas.addMarker(gateway, decision.stuckReason ? STUCK_MARKER : DECIDED_MARKER);
1491
+ this.markedGateways.push(gateway);
1492
+ }
1493
+ unmarkGateways() {
1494
+ for (const gateway of this.markedGateways) {
1495
+ this.canvas.removeMarker(gateway, DECIDED_MARKER);
1496
+ this.canvas.removeMarker(gateway, STUCK_MARKER);
1497
+ }
1498
+ this.markedGateways = [];
1499
+ }
1500
+ showOutcomes(decision) {
1501
+ for (const { flow, outcome, reason } of decision.flows) {
1502
+ const connection = this.elementRegistry.get(flow.id);
1503
+ if (!connection?.waypoints) continue;
1504
+ const badge = new OutcomeBadge(outcome, reason, flow.isDefault).element;
1505
+ badge.classList.add("bds-outcome--on-flow");
1506
+ this.overlays.add(connection, OUTCOME_OVERLAY, {
1507
+ position: badgePosition(connection.waypoints, BADGE_DISTANCE),
1508
+ scale: { min: BADGE_MIN_SCALE },
1509
+ html: inShadow(badge)
1510
+ });
1511
+ }
1512
+ }
1513
+ showCards(entries) {
1514
+ this.popovers = entries.flatMap((entry) => {
1515
+ const gateway = this.elementRegistry.get(entry.elementId);
1516
+ if (!gateway) return [];
1517
+ const close = () => {
1518
+ this.pinnedGatewayIds.delete(entry.elementId);
1519
+ this.render();
1520
+ };
1521
+ const card = new DecisionCard(entry, this.pinnedGatewayIds.has(entry.elementId) ? close : void 0).element;
1522
+ card.classList.add("bds-popover");
1523
+ card.dataset.elementId = entry.elementId;
1524
+ return [{ gateway, card }];
1525
+ });
1526
+ this.popoverLayer.shadowRoot.replaceChildren(...this.popovers.map(({ card }) => card));
1527
+ this.placePopovers();
1528
+ }
1529
+ placePopovers() {
1530
+ const container = this.canvas.getContainer();
1531
+ const bounds = { width: container.clientWidth, height: container.clientHeight };
1532
+ for (const { gateway, card } of this.popovers) {
1533
+ card.style.maxHeight = "";
1534
+ const { left, top, maxHeight, hidden } = placePopover(
1535
+ this.canvas.getAbsoluteBBox(gateway),
1536
+ { width: card.offsetWidth, height: card.offsetHeight },
1537
+ bounds
1538
+ );
1539
+ card.hidden = hidden;
1540
+ card.style.left = `${left}px`;
1541
+ card.style.top = `${top}px`;
1542
+ card.style.maxHeight = maxHeight === void 0 ? "" : `${maxHeight}px`;
1543
+ }
1544
+ }
1545
+ }
1546
+ DataSimulationOverlays.$inject = ["eventBus", "overlays", "elementRegistry", "canvas", "dataSimulation"];
1550
1547
 
1551
1548
  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
1549
  const CLOSE_ICON = '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 4l8 8M12 4l-8 8" /></svg>';
1553
1550
  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) {
1551
+ constructor(actions) {
1552
+ this.actions = actions;
1553
+ this.paletteEntry = h("button", {
1554
+ className: "bts-entry bds-palette-entry",
1555
+ type: "button",
1556
+ title: "Toggle Process Data",
1557
+ "aria-label": "Toggle Process Data"
1558
+ });
1559
+ this.engineBadge = h("span", { className: "bds-engine" });
1560
+ this.closeButton = h("button", { className: "bds-panel-close", type: "button", "aria-label": "Close" });
1561
+ this.instanceTitle = h("h3", { className: "bds-section-title" }, "Instance");
1562
+ this.instancePicker = h("select", {
1563
+ className: "bds-input bds-instance-select",
1564
+ "aria-label": "Process instance"
1565
+ });
1566
+ this.instanceBody = h("div", { className: "bds-instance-body" });
1567
+ this.issueList = h("ol", { className: "bds-log" });
1568
+ this.issueSection = h(
1569
+ "section",
1570
+ { className: "bds-section bds-issues" },
1571
+ h("h3", { className: "bds-section-title" }, "Issues"),
1572
+ this.issueList
1573
+ );
1574
+ this.shownInstances = "";
1575
+ this.paletteEntry.innerHTML = `<span class="bts-icon bds-variables-icon">${VARIABLES_ICON}</span>`;
1576
+ this.closeButton.innerHTML = CLOSE_ICON;
1577
+ const icon = h("span", { className: "bds-variables-icon" });
1578
+ icon.innerHTML = VARIABLES_ICON;
1579
+ this.element = h(
1580
+ "aside",
1581
+ { className: "bds-panel", "aria-label": "Process Data" },
1582
+ h(
1583
+ "header",
1584
+ { className: "bds-panel-header" },
1585
+ icon,
1586
+ h("h2", { className: "bds-panel-heading" }, "Process Data"),
1587
+ this.closeButton
1588
+ ),
1589
+ h(
1590
+ "div",
1591
+ { className: "bds-panel-body" },
1592
+ h("p", { className: "bds-panel-engine" }, this.engineBadge),
1593
+ h("section", { className: "bds-section bds-instance" }, this.instanceTitle, this.instanceBody),
1594
+ this.issueSection
1595
+ )
1596
+ );
1597
+ this.paletteEntry.addEventListener("click", () => this.toggle());
1598
+ this.closeButton.addEventListener("click", () => this.toggle(false));
1599
+ this.instancePicker.addEventListener("change", () => this.actions.selectInstance(this.instancePicker.value));
1600
+ this.toggle(false);
1601
+ }
1602
+ toggle(shown = this.element.hidden === true) {
1603
+ this.element.hidden = !shown;
1604
+ this.paletteEntry.classList.toggle("active", shown);
1605
+ }
1606
+ render(snapshot) {
1607
+ this.snapshot = snapshot;
1608
+ this.engineBadge.textContent = `${snapshot.engineLabel} \xB7 ${snapshot.expressionLanguage}`;
1609
+ this.renderInstance(snapshot);
1610
+ this.renderIssues(snapshot);
1611
+ }
1612
+ renderInstance({ instances, selectedInstanceId, scenarios }) {
1613
+ const editedInstance = instances.find((candidate) => candidate.id === this.editingInstanceId);
1614
+ if (editedInstance && editedInstance.status !== "completed" && editedInstance.id !== selectedInstanceId) {
1615
+ this.actions.selectInstance(editedInstance.id);
1616
+ return;
1617
+ }
1618
+ const instance = instances.find((candidate) => candidate.id === selectedInstanceId);
1619
+ this.renderInstancePicker(instances, selectedInstanceId, scenarios);
1620
+ if (this.editingInstanceId && this.editingInstanceId === instance?.id && instance.status !== "completed") return;
1621
+ this.editingInstanceId = void 0;
1622
+ this.instanceBody.replaceChildren(
1623
+ instance ? this.instanceView(instance) : h("p", { className: "bds-hint" }, "Press \u25B6 on a start event to start a process instance.")
1624
+ );
1625
+ }
1626
+ renderInstancePicker(instances, selectedInstanceId, scenarios) {
1627
+ const signature = JSON.stringify(instances.map((instance) => [instance.id, instance.status]));
1628
+ if (signature !== this.shownInstances) {
1629
+ this.shownInstances = signature;
1630
+ this.instancePicker.replaceChildren(
1631
+ ...instances.map((instance) => {
1632
+ const scenarioName = scenarios.find((scenario) => scenario.id === instance.scenarioId)?.name ?? "no scenario";
1633
+ return h("option", { value: instance.id }, `#${instance.number} ${scenarioName} (${instance.status})`);
1634
+ })
1635
+ );
1636
+ }
1637
+ this.instancePicker.value = selectedInstanceId ?? "";
1638
+ this.instancePicker.hidden = instances.length < 2;
1639
+ if (!this.instancePicker.isConnected) this.instanceTitle.after(this.instancePicker);
1640
+ }
1641
+ instanceView(instance) {
1642
+ const scenarioName = this.snapshot?.scenarios.find((scenario) => scenario.id === instance.scenarioId)?.name;
1643
+ const entries = Object.entries(instance.variables);
1644
+ const editButton = h("button", { className: "bds-button", type: "button" }, "Edit");
1645
+ editButton.addEventListener("click", () => this.editInstance(instance));
1646
+ return h(
1647
+ "div",
1648
+ {},
1649
+ h("p", { className: `bds-status bds-status--${instance.status}` }, this.describeStatus(instance)),
1650
+ scenarioName ? h("p", { className: "bds-hint" }, `Scenario: ${scenarioName}`) : null,
1651
+ entries.length ? h(
1652
+ "table",
1653
+ { className: "bds-variables" },
1654
+ h(
1655
+ "tbody",
1656
+ {},
1657
+ ...entries.map(
1658
+ ([name, value]) => h("tr", {}, h("th", { scope: "row" }, name), h("td", {}, h("code", {}, formatValue(value))))
1659
+ )
1660
+ )
1661
+ ) : h("p", { className: "bds-hint" }, "No variables yet."),
1662
+ h("p", { className: "bds-hint" }, "Hover a gateway to see why it took its flow, click it to keep the card open."),
1663
+ instance.status !== "completed" ? h("div", { className: "bds-actions" }, editButton) : null
1664
+ );
1665
+ }
1666
+ editInstance(instance) {
1667
+ this.editingInstanceId = instance.id;
1668
+ const editor = h("textarea", {
1669
+ className: "bds-input bds-json bds-instance-editor",
1670
+ spellcheck: "false",
1671
+ rows: "8",
1672
+ "aria-label": "Instance variables (JSON)"
1673
+ });
1674
+ editor.value = JSON.stringify(instance.variables, null, 2);
1675
+ const error = h("p", { className: "bds-error", role: "alert" });
1676
+ this.showError(error, editor, "");
1677
+ const applyButton = h("button", { className: "bds-button bds-button--primary", type: "button" }, "Apply");
1678
+ const cancelButton = h("button", { className: "bds-button", type: "button" }, "Cancel");
1679
+ applyButton.addEventListener("click", () => {
1680
+ const parsed = this.parseVariables(editor.value);
1681
+ if (typeof parsed === "string") {
1682
+ this.showError(error, editor, parsed);
1683
+ return;
1684
+ }
1685
+ this.editingInstanceId = void 0;
1686
+ this.actions.setInstanceVariables(instance.id, parsed);
1687
+ });
1688
+ cancelButton.addEventListener("click", () => {
1689
+ this.editingInstanceId = void 0;
1690
+ if (this.snapshot) this.renderInstance(this.snapshot);
1691
+ });
1692
+ this.instanceBody.replaceChildren(editor, error, h("div", { className: "bds-actions" }, cancelButton, applyButton));
1693
+ editor.focus();
1694
+ }
1695
+ renderIssues({ log, selectedInstanceId }) {
1696
+ const issues = log.filter(
1697
+ (entry) => entry.kind === "mapping-issue" && entry.instanceId === selectedInstanceId
1698
+ );
1699
+ this.issueSection.hidden = !issues.length;
1700
+ this.issueList.replaceChildren(
1701
+ ...issues.slice().reverse().map((issue) => this.renderMappingIssue(issue))
1702
+ );
1703
+ }
1704
+ describeStatus({ processName, status, waiting }) {
1705
+ if (status !== "waiting") return `${processName} \xB7 ${status}`;
1706
+ return `${processName} \xB7 waiting at ${waiting.map((gateway) => gateway.gatewayName).join(", ")}`;
1707
+ }
1708
+ showError(error, input, message) {
1673
1709
  error.textContent = message;
1674
1710
  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) {
1711
+ input.classList.toggle("bds-input--invalid", Boolean(message));
1712
+ }
1713
+ renderMappingIssue({ elementName, target, reason }) {
1714
+ return h(
1715
+ "li",
1716
+ { className: "bds-log-entry bds-log-entry--issue" },
1717
+ h("div", { className: "bds-log-title" }, elementName, h("span", { className: "bds-tag" }, "mapping")),
1718
+ h("p", { className: "bds-error" }, `${target}: ${reason}`)
1719
+ );
1720
+ }
1721
+ parseVariables(text) {
1681
1722
  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}`;
1723
+ const value = JSON.parse(text || "{}");
1724
+ return isVariables(value) ? value : "Variables must be a JSON object";
1725
+ } catch (error) {
1726
+ return `Invalid JSON: ${error.message}`;
1687
1727
  }
1728
+ }
1688
1729
  }
1689
1730
 
1690
1731
  const PALETTE_INDEX = 4;
1691
1732
  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
- }
1733
+ constructor(eventBus, canvas, palette, dataSimulation) {
1734
+ this.dataSimulation = dataSimulation;
1735
+ this.panel = new VariablesPanel({
1736
+ selectInstance: (instanceId) => dataSimulation.selectInstance(instanceId),
1737
+ setInstanceVariables: (instanceId, variables) => dataSimulation.setInstanceVariables(instanceId, variables)
1738
+ });
1739
+ this.panel.render(dataSimulation.getSnapshot());
1740
+ const host = inShadow(this.panel.element);
1741
+ canvas.getContainer().append(host);
1742
+ palette.addEntry(this.panel.paletteEntry, PALETTE_INDEX);
1743
+ this.showPaletteEntry();
1744
+ const unsubscribe = dataSimulation.subscribe((snapshot) => this.panel.render(snapshot));
1745
+ eventBus.on(TOGGLE_MODE_EVENT, () => this.panel.toggle(false));
1746
+ eventBus.on(DATA_TOGGLE_EVENT, () => this.showPaletteEntry());
1747
+ eventBus.on("diagram.destroy", () => {
1748
+ unsubscribe();
1749
+ host.remove();
1750
+ this.panel.paletteEntry.remove();
1751
+ });
1752
+ }
1753
+ showPaletteEntry() {
1754
+ this.panel.paletteEntry.hidden = !this.dataSimulation.isEnabled();
1755
+ }
1714
1756
  }
1715
- DataSimulationPanel.$inject = ['eventBus', 'canvas', 'tokenSimulationPalette', 'dataSimulation'];
1757
+ DataSimulationPanel.$inject = ["eventBus", "canvas", "tokenSimulationPalette", "dataSimulation"];
1716
1758
 
1717
- const LABEL = 'Data Simulation';
1759
+ const LABEL = "Data Simulation";
1718
1760
  const GAP = 8;
1719
1761
  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
1762
  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
1763
  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
- });
1764
+ constructor(eventBus, canvas, toggleMode, dataSimulation) {
1765
+ this.canvas = canvas;
1766
+ this.dataSimulation = dataSimulation;
1767
+ this.button = h("button", { className: "bds-data-toggle", type: "button" });
1768
+ this.simulating = false;
1769
+ this.render();
1770
+ canvas.getContainer().append(this.button);
1771
+ this.button.addEventListener("click", () => dataSimulation.setEnabled(!dataSimulation.isEnabled()));
1772
+ eventBus.on(TOGGLE_MODE_EVENT, ({ active }) => {
1773
+ this.simulating = active;
1774
+ if (active) this.placeNextToTokenSimulationToggle();
1775
+ });
1776
+ eventBus.on(DATA_TOGGLE_EVENT, () => {
1777
+ this.render();
1778
+ if (!this.simulating) return;
1779
+ toggleMode.toggleMode(false);
1780
+ toggleMode.toggleMode(true);
1781
+ });
1782
+ eventBus.on("diagram.destroy", () => {
1783
+ this.tokenToggleObserver?.disconnect();
1784
+ this.button.remove();
1785
+ });
1786
+ }
1787
+ render() {
1788
+ const enabled = this.dataSimulation.isEnabled();
1789
+ this.button.innerHTML = `${LABEL} <span class="bds-data-toggle-icon">${enabled ? TOGGLE_ON : TOGGLE_OFF}</span>`;
1790
+ this.button.classList.toggle("active", enabled);
1791
+ this.button.setAttribute("aria-pressed", String(enabled));
1792
+ }
1793
+ placeNextToTokenSimulationToggle() {
1794
+ const container = this.canvas.getContainer();
1795
+ const tokenToggle = container.querySelector(".bts-toggle-mode");
1796
+ if (!tokenToggle) return;
1797
+ const containerBox = container.getBoundingClientRect();
1798
+ const toggleBox = tokenToggle.getBoundingClientRect();
1799
+ const scale = containerBox.width / container.offsetWidth || 1;
1800
+ this.button.style.fontSize = getComputedStyle(tokenToggle).fontSize;
1801
+ this.button.style.left = `${(toggleBox.right - containerBox.left) / scale + GAP}px`;
1802
+ this.button.style.top = `${(toggleBox.top + toggleBox.height / 2 - containerBox.top) / scale - this.button.offsetHeight / 2}px`;
1803
+ this.observeTokenToggle(tokenToggle);
1804
+ }
1805
+ observeTokenToggle(tokenToggle) {
1806
+ if (this.tokenToggleObserver || typeof ResizeObserver !== "function") return;
1807
+ this.tokenToggleObserver = new ResizeObserver(() => this.placeNextToTokenSimulationToggle());
1808
+ this.tokenToggleObserver.observe(tokenToggle);
1809
+ }
1810
+ }
1811
+ DataSimulationToggle.$inject = ["eventBus", "canvas", "toggleMode", "dataSimulation"];
1812
+
1813
+ class StartFieldDeriver {
1814
+ derive(usages, { examples = [], taskResultNames = [] } = {}) {
1815
+ const written = /* @__PURE__ */ new Set([
1816
+ ...usages.flatMap((usage) => usage.outputTargets.map((target) => this.topLevelName(target))),
1817
+ ...taskResultNames
1818
+ ]);
1819
+ const usedBy = /* @__PURE__ */ new Map();
1820
+ for (const usage of usages) {
1821
+ const localNames = new Set(usage.inputTargets.map((target) => this.topLevelName(target)));
1822
+ for (const name of [...usage.conditionReads, ...usage.inputReads, ...usage.outputReads]) {
1823
+ if (written.has(name) || localNames.has(name)) continue;
1824
+ if (!usedBy.has(name)) usedBy.set(name, /* @__PURE__ */ new Set());
1825
+ usedBy.get(name).add(usage.elementName);
1826
+ }
1767
1827
  }
1828
+ return [...usedBy.entries()].map(([name, elements]) => ({
1829
+ name,
1830
+ type: this.inferType(examples.map((example) => example[name]).find((value) => value !== void 0)),
1831
+ usedBy: [...elements]
1832
+ }));
1833
+ }
1834
+ topLevelName(path) {
1835
+ return path.split(".")[0];
1836
+ }
1837
+ inferType(example) {
1838
+ if (typeof example === "number") return "number";
1839
+ if (typeof example === "boolean") return "boolean";
1840
+ if (typeof example === "string") return "text";
1841
+ if (Array.isArray(example) || isVariables(example)) return "json";
1842
+ return "auto";
1843
+ }
1768
1844
  }
1769
- DataSimulationToggle.$inject = ['eventBus', 'canvas', 'toggleMode', 'dataSimulation'];
1770
1845
 
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();
1846
+ const NO_SCENARIO = "";
1847
+ class StartDialog {
1848
+ constructor(options) {
1849
+ this.options = options;
1850
+ this.codec = new StartFieldCodec();
1851
+ this.scenarioSelect = h("select", {
1852
+ className: "bds-input bds-scenario-select",
1853
+ "aria-label": "Scenario"
1812
1854
  });
1813
- cancelButton.addEventListener('click', close);
1814
- backdrop.addEventListener('mousedown', event => {
1815
- if (event.target === backdrop)
1816
- close();
1855
+ this.scenarioDescription = h("p", { className: "bds-hint" });
1856
+ this.formContainer = h("div", { className: "bds-dialog-form" });
1857
+ this.noFieldsHint = h("p", { className: "bds-hint" }, "The process reads no start variables.");
1858
+ this.error = h("p", { className: "bds-error", role: "alert" });
1859
+ this.cancelButton = h("button", { className: "bds-button", type: "button" }, "Cancel");
1860
+ this.startButton = h(
1861
+ "button",
1862
+ { className: "bds-button bds-button--primary", type: "submit" },
1863
+ "Start instance"
1864
+ );
1865
+ this.fields = [];
1866
+ this.baseVariables = options.startVariables;
1867
+ this.scenarioSelect.append(
1868
+ h("option", { value: NO_SCENARIO }, "No scenario"),
1869
+ ...options.scenarios.map((scenario) => h("option", { value: scenario.id }, scenario.name))
1870
+ );
1871
+ this.scenarioSelect.value = options.selectedScenarioId ?? NO_SCENARIO;
1872
+ this.error.hidden = true;
1873
+ this.form = this.createForm();
1874
+ this.backdrop = h("div", { className: "bds-dialog-backdrop" }, this.form);
1875
+ this.rendered = this.renderForm();
1876
+ this.listen();
1877
+ }
1878
+ open(container) {
1879
+ this.showScenarioDescription();
1880
+ container.append(this.backdrop);
1881
+ if (this.fields.length) this.rendered.focus();
1882
+ else this.startButton.focus();
1883
+ }
1884
+ close() {
1885
+ this.rendered.destroy();
1886
+ this.backdrop.remove();
1887
+ }
1888
+ createForm() {
1889
+ const titleId = `bds-start-title-${Math.random().toString(36).slice(2)}`;
1890
+ return h(
1891
+ "form",
1892
+ { className: "bds-dialog", role: "dialog", "aria-modal": "true", "aria-labelledby": titleId },
1893
+ h(
1894
+ "header",
1895
+ { className: "bds-dialog-header" },
1896
+ h("h2", { className: "bds-panel-title", id: titleId }, `Start \u201C${this.options.processName}\u201D`),
1897
+ h("span", { className: "bds-engine" }, this.options.engineLabel)
1898
+ ),
1899
+ h(
1900
+ "div",
1901
+ { className: "bds-dialog-content" },
1902
+ this.options.scenarios.length ? h(
1903
+ "section",
1904
+ { className: "bds-section" },
1905
+ h("label", { className: "bds-label" }, "Scenario", this.scenarioSelect),
1906
+ this.scenarioDescription
1907
+ ) : null,
1908
+ h(
1909
+ "section",
1910
+ { className: "bds-section" },
1911
+ h("h3", { className: "bds-section-title" }, "Start variables"),
1912
+ this.formContainer,
1913
+ this.noFieldsHint
1914
+ ),
1915
+ this.error
1916
+ ),
1917
+ h("footer", { className: "bds-actions" }, this.cancelButton, this.startButton)
1918
+ );
1919
+ }
1920
+ listen() {
1921
+ this.scenarioSelect.addEventListener("change", () => this.switchScenario());
1922
+ this.cancelButton.addEventListener("click", () => this.close());
1923
+ this.backdrop.addEventListener("mousedown", (event) => {
1924
+ if (event.target === this.backdrop) this.close();
1817
1925
  });
1818
- backdrop.addEventListener('keydown', event => {
1819
- event.stopPropagation();
1820
- if (event.key === 'Escape')
1821
- close();
1926
+ this.backdrop.addEventListener("keydown", (event) => {
1927
+ event.stopPropagation();
1928
+ if (event.key === "Escape") this.close();
1822
1929
  });
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));
1930
+ this.form.addEventListener("submit", (event) => {
1931
+ event.preventDefault();
1932
+ this.submit();
1833
1933
  });
1834
- showScenarioDescription();
1835
- container.append(backdrop);
1836
- if (fields.length)
1837
- rendered.focus();
1838
- else
1839
- startButton.focus();
1840
- return close;
1934
+ }
1935
+ selectedScenarioId() {
1936
+ return this.scenarioSelect.value || null;
1937
+ }
1938
+ selectedScenario() {
1939
+ return this.options.scenarios.find((scenario) => scenario.id === this.scenarioSelect.value);
1940
+ }
1941
+ renderForm() {
1942
+ this.fields = this.options.fieldsFor(this.selectedScenarioId());
1943
+ this.noFieldsHint.hidden = this.fields.length > 0;
1944
+ return this.options.renderer.render(this.formContainer, this.fields, this.baseVariables);
1945
+ }
1946
+ switchScenario() {
1947
+ this.baseVariables = this.selectedScenario()?.variables ?? {};
1948
+ this.rendered.destroy();
1949
+ this.rendered = this.renderForm();
1950
+ this.showScenarioDescription();
1951
+ }
1952
+ showScenarioDescription() {
1953
+ const description = this.selectedScenario()?.description ?? "";
1954
+ this.scenarioDescription.textContent = description;
1955
+ this.scenarioDescription.hidden = !description;
1956
+ }
1957
+ submit() {
1958
+ const values = this.rendered.readValues();
1959
+ if (!values.ok) {
1960
+ this.error.textContent = values.reason;
1961
+ this.error.hidden = false;
1962
+ return;
1963
+ }
1964
+ this.close();
1965
+ this.options.onStart(this.selectedScenarioId(), this.codec.apply(this.baseVariables, values.values));
1966
+ }
1841
1967
  }
1842
1968
 
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;
1969
+ class VariableUsageCollector {
1970
+ constructor(engine) {
1971
+ this.engine = engine;
1972
+ }
1973
+ collect(container) {
1974
+ const usages = [];
1975
+ const visit = (element) => {
1976
+ if (element.type === "label") return;
1977
+ const usage = this.usageOf(element);
1978
+ if (usage) usages.push(usage);
1979
+ element.children?.forEach(visit);
1980
+ };
1981
+ container.children?.forEach(visit);
1982
+ return usages;
1983
+ }
1984
+ usageOf(element) {
1985
+ const businessObject = element.businessObject;
1986
+ if (is(element, "bpmn:SequenceFlow")) {
1987
+ const condition = this.engine.readCondition(businessObject);
1988
+ if (!condition) return void 0;
1989
+ return this.usage(element.source ?? element, { conditionReads: this.engine.readVariableNames(condition) });
1990
+ }
1991
+ if (!is(element, "bpmn:FlowNode")) return void 0;
1992
+ const { inputs, outputs } = this.engine.readIoMappings(businessObject);
1993
+ return this.usage(element, {
1994
+ inputReads: inputs.flatMap((mapping) => this.engine.readVariableNames(mapping.source)),
1995
+ inputTargets: inputs.map((mapping) => mapping.target),
1996
+ outputReads: outputs.flatMap((mapping) => this.engine.readVariableNames(mapping.source)),
1997
+ outputTargets: outputs.map((mapping) => mapping.target)
1998
+ });
1999
+ }
2000
+ usage(element, reads) {
1921
2001
  return {
1922
- elementName: elementName(target),
1923
- conditionReads: [],
1924
- inputReads: [],
1925
- inputTargets: [],
1926
- outputReads: [],
1927
- outputTargets: [],
1928
- ...reads,
2002
+ elementName: elementName(element),
2003
+ conditionReads: [],
2004
+ inputReads: [],
2005
+ inputTargets: [],
2006
+ outputReads: [],
2007
+ outputTargets: [],
2008
+ ...reads
1929
2009
  };
2010
+ }
1930
2011
  }
1931
2012
 
2013
+ class DataStartForm {
2014
+ constructor(config, eventBus, dataSimulation, store) {
2015
+ this.store = store;
2016
+ this.fieldDeriver = new StartFieldDeriver();
2017
+ this.renderer = config?.startFormRenderer ?? new SimpleStartFormRenderer();
2018
+ this.usageCollector = new VariableUsageCollector(dataSimulation.getEngine());
2019
+ eventBus.on(TOGGLE_MODE_EVENT, () => this.closeDialog());
2020
+ eventBus.on("diagram.destroy", () => {
2021
+ this.closeDialog();
2022
+ this.dialogHost?.remove();
2023
+ });
2024
+ }
2025
+ isProcessStart(element) {
2026
+ return is(element, "bpmn:StartEvent") && Boolean(element.parent) && (is(element.parent, "bpmn:Process") || is(element.parent, "bpmn:Participant"));
2027
+ }
2028
+ fieldsFor(startEvent, scenarioId) {
2029
+ const snapshot = this.store.getSnapshot();
2030
+ const examples = [snapshot.startVariables, ...snapshot.scenarios.map((scenario) => scenario.variables)];
2031
+ const taskResults = snapshot.scenarios.find((scenario) => scenario.id === scenarioId)?.taskResults ?? {};
2032
+ const taskResultNames = Object.values(taskResults).flatMap((result) => Object.keys(result));
2033
+ return this.fieldDeriver.derive(this.usageCollector.collect(startEvent.parent), { examples, taskResultNames });
2034
+ }
2035
+ open(startEvent, start) {
2036
+ this.closeDialog();
2037
+ const snapshot = this.store.getSnapshot();
2038
+ this.dialogHost ?? (this.dialogHost = document.body.appendChild(inShadow()));
2039
+ this.dialog = new StartDialog({
2040
+ processName: elementName(startEvent.parent),
2041
+ engineLabel: `${snapshot.engineLabel} \xB7 ${snapshot.expressionLanguage}`,
2042
+ scenarios: snapshot.scenarios,
2043
+ selectedScenarioId: snapshot.selectedScenarioId,
2044
+ startVariables: snapshot.startVariables,
2045
+ fieldsFor: (scenarioId) => this.fieldsFor(startEvent, scenarioId),
2046
+ renderer: this.renderer,
2047
+ onStart: (scenarioId, variables) => {
2048
+ this.dialog = void 0;
2049
+ this.store.selectScenario(scenarioId);
2050
+ this.store.setStartVariables(variables);
2051
+ start();
2052
+ }
2053
+ });
2054
+ this.dialog.open(this.dialogHost.shadowRoot);
2055
+ }
2056
+ closeDialog() {
2057
+ this.dialog?.close();
2058
+ this.dialog = void 0;
2059
+ }
2060
+ }
2061
+ DataStartForm.$inject = ["config.dataSimulation", "eventBus", "dataSimulation", "dataSimulationStore"];
2062
+
1932
2063
  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],
2064
+ __init__: [
2065
+ "dataSimulation",
2066
+ "dataSimulationOverlays",
2067
+ "dataSimulationPanel",
2068
+ "dataSimulationToggle",
2069
+ "dataGatewayBehaviors",
2070
+ "dataGatewaySettings",
2071
+ "dataContextPads"
2072
+ ],
2073
+ dataSimulationStore: ["type", DataSimulationStore],
2074
+ dataSimulation: ["type", DataSimulation],
2075
+ dataSimulationOverlays: ["type", DataSimulationOverlays],
2076
+ dataSimulationPanel: ["type", DataSimulationPanel],
2077
+ dataSimulationToggle: ["type", DataSimulationToggle],
2078
+ dataGateways: ["type", DataGateways],
2079
+ dataStartForm: ["type", DataStartForm],
2080
+ dataGatewayBehaviors: ["type", DataGatewayBehaviors],
2081
+ dataGatewaySettings: ["type", DataGatewaySettings],
2082
+ dataContextPads: ["type", DataContextPads]
1952
2083
  };
1953
2084
 
2085
+ exports.Camunda7Engine = Camunda7Engine;
1954
2086
  exports.DataSimulationStore = DataSimulationStore;
2087
+ exports.EngineRegistry = EngineRegistry;
2088
+ exports.GatewayRouter = GatewayRouter;
1955
2089
  exports.ScenarioError = ScenarioError;
2090
+ exports.ScenarioParser = ScenarioParser;
2091
+ exports.SimpleStartFormRenderer = SimpleStartFormRenderer;
2092
+ exports.StartFieldCodec = StartFieldCodec;
2093
+ exports.ZeebeEngine = ZeebeEngine;
1956
2094
  exports.camunda7Engine = camunda7Engine;
1957
2095
  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
2096
  exports.zeebeEngine = zeebeEngine;
1965
2097
  //# sourceMappingURL=index.cjs.map