@gemafajarramadhan/dynamic-ui 1.4.64 → 1.4.65

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.
@@ -1,3806 +0,0 @@
1
- import { p as O, U as W, C as T, i as p, a as H, F as Kn, s as on, I as Zn, B as Qn, o as sn, j as Fe, Y as rn, q as mt, k as Be, K as ti, J as Tt, Z as ei, z as ni, H as It, G as ii, L as an, g as cn } from "./DrilldownUtil-esP8Tbvd.js";
2
- import { g as oi } from "./index-CMDDHgYC.js";
3
- const N = "tokenSimulation.toggleMode", ln = "tokenSimulation.playSimulation", un = "tokenSimulation.pauseSimulation", tt = "tokenSimulation.resetSimulation", si = "tokenSimulation.animationCreated", hn = "tokenSimulation.animationSpeedChanged", pn = "tokenSimulation.simulator.elementChanged", Gt = "tokenSimulation.simulator.destroyScope", ri = "tokenSimulation.simulator.scopeChanged", vt = "tokenSimulation.simulator.createScope", Bt = "tokenSimulation.scopeFilterChanged", fn = "tokenSimulation.simulator.trace";
4
- var ai = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path fill="currentColor" d="M12.83 352h262.34A12.82 12.82 0 0 0 288 339.17v-38.34A12.82 12.82 0 0 0 275.17 288H12.83A12.82 12.82 0 0 0 0 300.83v38.34A12.82 12.82 0 0 0 12.83 352zm0-256h262.34A12.82 12.82 0 0 0 288 83.17V44.83A12.82 12.82 0 0 0 275.17 32H12.83A12.82 12.82 0 0 0 0 44.83v38.34A12.82 12.82 0 0 0 12.83 96zM432 160H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0 256H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"/></svg>', ci = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 512"><!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path fill="currentColor" d="M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34z"/></svg>', li = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path fill="currentColor" d="M504 256c0 136.967-111.033 248-248 248S8 392.967 8 256 119.033 8 256 8s248 111.033 248 248zM227.314 387.314l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.249-16.379-6.249-22.628 0L216 308.118l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.249 16.379 6.249 22.628.001z"/></svg>', ui = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path fill="currentColor" d="M384 144c0-44.2-35.8-80-80-80s-80 35.8-80 80c0 36.4 24.3 67.1 57.5 76.8-.6 16.1-4.2 28.5-11 36.9-15.4 19.2-49.3 22.4-85.2 25.7-28.2 2.6-57.4 5.4-81.3 16.9v-144c32.5-10.2 56-40.5 56-76.3 0-44.2-35.8-80-80-80S0 35.8 0 80c0 35.8 23.5 66.1 56 76.3v199.3C23.5 365.9 0 396.2 0 432c0 44.2 35.8 80 80 80s80-35.8 80-80c0-34-21.2-63.1-51.2-74.6 3.1-5.2 7.8-9.8 14.9-13.4 16.2-8.2 40.4-10.4 66.1-12.8 42.2-3.9 90-8.4 118.2-43.4 14-17.4 21.1-39.8 21.6-67.9 31.6-10.8 54.4-40.7 54.4-75.9zM80 64c8.8 0 16 7.2 16 16s-7.2 16-16 16-16-7.2-16-16 7.2-16 16-16zm0 384c-8.8 0-16-7.2-16-16s7.2-16 16-16 16 7.2 16 16-7.2 16-16 16zm224-320c8.8 0 16 7.2 16 16s-7.2 16-16 16-16-7.2-16-16 7.2-16 16-16z"/></svg>', hi = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path fill="currentColor" d="M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"/></svg>', pi = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 192 512"><!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path fill="currentColor" d="M20 424.229h20V279.771H20c-11.046 0-20-8.954-20-20V212c0-11.046 8.954-20 20-20h112c11.046 0 20 8.954 20 20v212.229h20c11.046 0 20 8.954 20 20V492c0 11.046-8.954 20-20 20H20c-11.046 0-20-8.954-20-20v-47.771c0-11.046 8.954-20 20-20zM96 0C56.235 0 24 32.235 24 72s32.235 72 72 72 72-32.235 72-72S135.764 0 96 0z"/></svg>', fi = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path fill="currentColor" d="M144 479H48c-26.5 0-48-21.5-48-48V79c0-26.5 21.5-48 48-48h96c26.5 0 48 21.5 48 48v352c0 26.5-21.5 48-48 48zm304-48V79c0-26.5-21.5-48-48-48h-96c-26.5 0-48 21.5-48 48v352c0 26.5 21.5 48 48 48h96c26.5 0 48-21.5 48-48z"/></svg>', mi = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 580.5 448">
5
- <path fill="currentColor" d="M112 0C85 0 64 22 64 48v196l192-89V48c0-26-22-48-48-48zm256 0c-27 0-48 22-48 48v77l190-89c-5-21-24-36-46-36Zm144 105-192 89v70l192-89zM256 224 64 314v70l192-90zm256 21-192 89v66c0 27 21 48 48 48h96c26 0 48-21 48-48zM256 364 89 442c7 4 14 6 23 6h96c26 0 48-21 48-48z"/>
6
- <rect fill="currentColor" width="63.3" height="618.2" x="311.5" y="-469.4" transform="rotate(65)" rx="10"/>
7
- </svg>
8
- `, di = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!-- Adapted from Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path fill="currentColor" d="M424.4 214.7L72.4 6.6C43.8-10.3 0 6.1 0 47.9V464c0 37.5 40.7 60.1 72.4 41.3l352-208c31.4-18.5 31.5-64.1 0-82.6z"/></svg>', gi = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path fill="currentColor" d="M440.65 12.57l4 82.77A247.16 247.16 0 0 0 255.83 8C134.73 8 33.91 94.92 12.29 209.82A12 12 0 0 0 24.09 224h49.05a12 12 0 0 0 11.67-9.26 175.91 175.91 0 0 1 317-56.94l-101.46-4.86a12 12 0 0 0-12.57 12v47.41a12 12 0 0 0 12 12H500a12 12 0 0 0 12-12V12a12 12 0 0 0-12-12h-47.37a12 12 0 0 0-11.98 12.57zM255.83 432a175.61 175.61 0 0 1-146-77.8l101.8 4.87a12 12 0 0 0 12.57-12v-47.4a12 12 0 0 0-12-12H12a12 12 0 0 0-12 12V500a12 12 0 0 0 12 12h47.35a12 12 0 0 0 12-12.6l-4.15-82.57A247.17 247.17 0 0 0 255.83 504c121.11 0 221.93-86.92 243.55-201.82a12 12 0 0 0-11.8-14.18h-49.05a12 12 0 0 0-11.67 9.26A175.86 175.86 0 0 1 255.83 432z"/></svg>', vi = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path fill="currentColor" d="M288 32C128.94 32 0 160.94 0 320c0 52.8 14.25 102.26 39.06 144.8 5.61 9.62 16.3 15.2 27.44 15.2h443c11.14 0 21.83-5.58 27.44-15.2C561.75 422.26 576 372.8 576 320c0-159.06-128.94-288-288-288zm0 64c14.71 0 26.58 10.13 30.32 23.65-1.11 2.26-2.64 4.23-3.45 6.67l-9.22 27.67c-5.13 3.49-10.97 6.01-17.64 6.01-17.67 0-32-14.33-32-32S270.33 96 288 96zM96 384c-17.67 0-32-14.33-32-32s14.33-32 32-32 32 14.33 32 32-14.33 32-32 32zm48-160c-17.67 0-32-14.33-32-32s14.33-32 32-32 32 14.33 32 32-14.33 32-32 32zm246.77-72.41l-61.33 184C343.13 347.33 352 364.54 352 384c0 11.72-3.38 22.55-8.88 32H232.88c-5.5-9.45-8.88-20.28-8.88-32 0-33.94 26.5-61.43 59.9-63.59l61.34-184.01c4.17-12.56 17.73-19.45 30.36-15.17 12.57 4.19 19.35 17.79 15.17 30.36zm14.66 57.2l15.52-46.55c3.47-1.29 7.13-2.23 11.05-2.23 17.67 0 32 14.33 32 32s-14.33 32-32 32c-11.38-.01-20.89-6.28-26.57-15.22zM480 384c-17.67 0-32-14.33-32-32s14.33-32 32-32 32 14.33 32 32-14.33 32-32 32z"/></svg>', _i = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path fill="currentColor" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z"/></svg>', yi = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 352 512"><!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path fill="currentColor" d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"/></svg>', bi = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path fill="currentColor" d="M384 64H192C85.961 64 0 149.961 0 256s85.961 192 192 192h192c106.039 0 192-85.961 192-192S490.039 64 384 64zM64 256c0-70.741 57.249-128 128-128 70.741 0 128 57.249 128 128 0 70.741-57.249 128-128 128-70.741 0-128-57.249-128-128zm320 128h-48.905c65.217-72.858 65.236-183.12 0-256H384c70.741 0 128 57.249 128 128 0 70.74-57.249 128-128 128z"/></svg>', Ei = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path fill="currentColor" d="M384 64H192C86 64 0 150 0 256s86 192 192 192h192c106 0 192-86 192-192S490 64 384 64zm0 320c-70.8 0-128-57.3-128-128 0-70.8 57.3-128 128-128 70.8 0 128 57.3 128 128 0 70.8-57.3 128-128 128z"/></svg>';
9
- function V(t) {
10
- return function(n = "") {
11
- return `<span class="bts-icon ${n}">${t}</span>`;
12
- };
13
- }
14
- const Je = V(ai), Si = V(ci), be = V(li), wi = V(mi), mn = V(ui), dn = V(hi), gn = V(pi), Ee = V(fi), vn = V(di), Ci = V(gi), Ti = V(vi), Ii = V(_i), Fi = V(yi), _n = V(bi), Bi = V(Ei);
15
- function ie(t, e, n) {
16
- this._eventBus = t, this._canvas = e, this._active = !1, t.on("diagram.init", () => {
17
- this._canvasParent = this._canvas.getContainer().parentNode, this._init();
18
- }), t.on("import.parse.start", () => {
19
- this._active && (this.toggleMode(!1), t.once("import.done", () => {
20
- this.toggleMode(!0);
21
- }));
22
- });
23
- }
24
- ie.prototype._init = function() {
25
- this._container = O(`
26
- <div class="bts-toggle-mode">
27
- Token Simulation <span class="bts-toggle">${_n()}</span>
28
- </div>
29
- `), W.bind(this._container, "click", () => this.toggleMode()), this._canvas.getContainer().appendChild(this._container);
30
- };
31
- ie.prototype.toggleMode = function(t = !this._active) {
32
- t !== this._active && (t ? (this._container.innerHTML = `Token Simulation <span class="bts-toggle">${Bi()}</span>`, T(this._canvasParent).add("simulation")) : (this._container.innerHTML = `Token Simulation <span class="bts-toggle">${_n()}</span>`, T(this._canvasParent).remove("simulation")), this._eventBus.fire(N, {
33
- active: t
34
- }), this._active = t);
35
- };
36
- ie.$inject = ["eventBus", "canvas"];
37
- const xi = {
38
- __init__: [
39
- "toggleMode"
40
- ],
41
- toggleMode: ["type", ie]
42
- }, xe = 1, yn = 2, bn = 4, En = 8, ki = 16, Ai = 32, Mi = 64, Li = 128, Pi = 256, Ri = 512, $i = xe | yn | bn, Oi = xe | En, w = Object.freeze({
43
- ACTIVATED: xe,
44
- RUNNING: yn,
45
- ENDING: bn,
46
- ENDED: En,
47
- DESTROYED: ki,
48
- FAILED: Ai,
49
- TERMINATED: Mi,
50
- CANCELED: Li,
51
- COMPLETED: Pi,
52
- COMPENSABLE: Ri,
53
- ACTIVE: $i,
54
- NOT_DEAD: Oi
55
- }), jt = {};
56
- function pt(t, e) {
57
- throw new Error(`illegal transition: ${t.name} -> ${e}`);
58
- }
59
- function ft(t, e) {
60
- return t === jt ? e : t;
61
- }
62
- class q {
63
- /**
64
- * @param {string} name
65
- * @param {number} traits
66
- * @param {object} [transitions]
67
- * @param {ScopeState} [transitions.start]
68
- * @param {ScopeState} [transitions.cancel]
69
- * @param {ScopeState} [transitions.complete]
70
- * @param {ScopeState} [transitions.destroy]
71
- * @param {ScopeState} [transitions.fail]
72
- * @param {ScopeState} [transitions.terminate]
73
- * @param {ScopeState} [transitions.compensable]
74
- */
75
- constructor(e, n, i = {}) {
76
- this.name = e, this.traits = n, this.setTransitions(i);
77
- }
78
- /**
79
- * @param {object} transitions
80
- * @param {ScopeState} [transitions.start]
81
- * @param {ScopeState} [transitions.cancel]
82
- * @param {ScopeState} [transitions.complete]
83
- * @param {ScopeState} [transitions.destroy]
84
- * @param {ScopeState} [transitions.fail]
85
- * @param {ScopeState} [transitions.terminate]
86
- * @param {ScopeState} [transitions.compensable]
87
- */
88
- setTransitions({
89
- start: e,
90
- cancel: n,
91
- complete: i,
92
- destroy: o,
93
- fail: s,
94
- terminate: r,
95
- compensable: c
96
- }) {
97
- this._start = ft(e, this), this._compensable = ft(c, this), this._cancel = ft(n, this), this._complete = ft(i, this), this._destroy = ft(o, this), this._fail = ft(s, this), this._terminate = ft(r, this);
98
- }
99
- /**
100
- * @param {number} trait
101
- * @return {boolean}
102
- */
103
- hasTrait(e) {
104
- return (this.traits & e) !== 0;
105
- }
106
- /**
107
- * @return {ScopeState}
108
- */
109
- complete() {
110
- return this._complete || pt(this, "complete");
111
- }
112
- /**
113
- * @return {ScopeState}
114
- */
115
- destroy() {
116
- return this._destroy || pt(this, "destroy");
117
- }
118
- /**
119
- * @return {ScopeState}
120
- */
121
- cancel() {
122
- return this._cancel || pt(this, "cancel");
123
- }
124
- /**
125
- * @return {ScopeState}
126
- */
127
- fail() {
128
- return this._fail || pt(this, "fail");
129
- }
130
- /**
131
- * @return {ScopeState}
132
- */
133
- terminate() {
134
- return this._terminate || pt(this, "terminate");
135
- }
136
- /**
137
- * @return {ScopeState}
138
- */
139
- compensable() {
140
- return this._compensable || pt(this, "compensable");
141
- }
142
- /**
143
- * @return {ScopeState}
144
- */
145
- start() {
146
- return this._start || pt(this, "start");
147
- }
148
- }
149
- const oe = new q("failed", w.DESTROYED | w.FAILED), se = new q("terminated", w.DESTROYED | w.TERMINATED | w.COMPLETED), ke = new q("completed", w.DESTROYED | w.COMPLETED), st = new q("terminating", w.ENDING | w.TERMINATED | w.COMPLETED, {
150
- destroy: se
151
- }), xt = new q("canceling", w.ENDING | w.FAILED | w.CANCELED, {
152
- destroy: oe,
153
- complete: jt,
154
- terminate: st
155
- }), Ae = new q("completing", w.ENDING | w.COMPLETED, {
156
- destroy: ke,
157
- cancel: xt,
158
- terminate: st
159
- }), Sn = new q("failing", w.ENDING | w.FAILED, {
160
- cancel: xt,
161
- complete: Ae,
162
- destroy: oe,
163
- terminate: st
164
- }), Me = new q("compensable:completed", w.ENDED | w.COMPLETED), wn = new q("compensable:completing", w.ENDING | w.COMPLETED, {
165
- destroy: Me,
166
- terminate: st,
167
- compensable: jt
168
- }), Cn = new q("compensable:failing", w.ENDING | w.FAILED, {
169
- complete: wn,
170
- terminate: st,
171
- destroy: oe
172
- });
173
- Me.setTransitions({
174
- cancel: xt,
175
- fail: Cn,
176
- destroy: ke,
177
- compensable: jt
178
- });
179
- const Ni = new q("compensable:running", w.RUNNING | w.COMPENSABLE, {
180
- cancel: xt,
181
- complete: wn,
182
- compensable: jt,
183
- destroy: Me,
184
- fail: Cn,
185
- terminate: st
186
- }), Tn = new q("running", w.RUNNING, {
187
- cancel: xt,
188
- complete: Ae,
189
- compensable: Ni,
190
- destroy: se,
191
- fail: Sn,
192
- terminate: st
193
- }), Di = new q("activated", w.ACTIVATED, {
194
- start: Tn,
195
- destroy: se
196
- }), Gi = Object.freeze({
197
- ACTIVATED: Di,
198
- RUNNING: Tn,
199
- CANCELING: xt,
200
- COMPLETING: Ae,
201
- COMPLETED: ke,
202
- FAILING: Sn,
203
- FAILED: oe,
204
- TERMINATING: st,
205
- TERMINATED: se
206
- });
207
- class ji {
208
- /**
209
- * @param {string} id
210
- * @param {Element} element
211
- * @param {Scope} parent
212
- * @param {Scope} initiator
213
- *
214
- * @constructor
215
- */
216
- constructor(e, n, i = null, o = null) {
217
- this.id = e, this.element = n, this.parent = i, this.initiator = o, this.subscriptions = /* @__PURE__ */ new Set(), this.children = [], this.state = Gi.ACTIVATED;
218
- }
219
- /**
220
- * @return {boolean}
221
- */
222
- get running() {
223
- return this.hasTrait(w.RUNNING);
224
- }
225
- /**
226
- * @return {boolean}
227
- */
228
- get destroyed() {
229
- return this.hasTrait(w.DESTROYED);
230
- }
231
- /**
232
- * @return {boolean}
233
- */
234
- get completed() {
235
- return this.hasTrait(w.COMPLETED);
236
- }
237
- /**
238
- * @return {boolean}
239
- */
240
- get canceled() {
241
- return this.hasTrait(w.CANCELED);
242
- }
243
- /**
244
- * @return {boolean}
245
- */
246
- get failed() {
247
- return this.hasTrait(w.FAILED);
248
- }
249
- get active() {
250
- return this.hasTrait(w.ACTIVE);
251
- }
252
- /**
253
- * @param {number} phase
254
- * @return {boolean}
255
- */
256
- hasTrait(e) {
257
- return this.state.hasTrait(e);
258
- }
259
- /**
260
- * Start the scope
261
- *
262
- * @return {Scope}
263
- */
264
- start() {
265
- return this.state = this.state.start(), this;
266
- }
267
- /**
268
- * Make this scope compensable.
269
- *
270
- * @return {Scope}
271
- */
272
- compensable() {
273
- return this.state = this.state.compensable(), this;
274
- }
275
- /**
276
- * @param {Scope} initiator
277
- *
278
- * @return {Scope}
279
- */
280
- fail(e) {
281
- return this.failed || (this.state = this.state.fail(), this.failInitiator = e), this;
282
- }
283
- cancel(e) {
284
- return this.canceled || (this.state = this.state.cancel(), this.cancelInitiator = e), this;
285
- }
286
- /**
287
- * @param {Scope} initiator
288
- *
289
- * @return {Scope}
290
- */
291
- terminate(e) {
292
- return this.state = this.state.terminate(), this.terminateInitiator = e, this;
293
- }
294
- /**
295
- * @return {Scope}
296
- */
297
- complete() {
298
- return this.state = this.state.complete(), this;
299
- }
300
- /**
301
- * Destroy the scope
302
- *
303
- * @param {Scope} initiator
304
- *
305
- * @return {Scope}
306
- */
307
- destroy(e) {
308
- return this.state = this.state.destroy(), this.destroyInitiator = e, this;
309
- }
310
- /**
311
- * @return {number}
312
- */
313
- getTokens() {
314
- return this.children.filter((e) => !e.destroyed).length;
315
- }
316
- /**
317
- * @param {Element} element
318
- *
319
- * @return {number}
320
- */
321
- getTokensByElement(e) {
322
- return this.children.filter((n) => !n.destroyed && n.element === e).length;
323
- }
324
- }
325
- function Ct(t, e) {
326
- const n = [];
327
- for (const i of t)
328
- e(i) && n.push(i);
329
- return n;
330
- }
331
- function Xe(t, e) {
332
- for (const n of t)
333
- if (e(n))
334
- return n;
335
- return null;
336
- }
337
- function Se(t, e) {
338
- const n = ["type", "name", "iref"].every((o) => !(o in t) || t[o] === e[o]), i = !e.ref && (e.type === "error" || e.type === "escalation");
339
- return n && (i || In(t, e));
340
- }
341
- function In(t, e) {
342
- return !("ref" in t) || t.ref === e.ref;
343
- }
344
- function Ht(t) {
345
- return t.filter((e) => p(e, "bpmn:SequenceFlow"));
346
- }
347
- function we(t) {
348
- return p(t, "bpmn:MessageFlow");
349
- }
350
- function rt(t) {
351
- return p(t, "bpmn:SequenceFlow");
352
- }
353
- function Le(t) {
354
- return Pe(t) && ae(t, "bpmn:LinkEventDefinition");
355
- }
356
- function Hi(t) {
357
- return p(t, "bpmn:IntermediateThrowEvent") && ae(t, "bpmn:LinkEventDefinition");
358
- }
359
- function ne(t) {
360
- return Pe(t) && ae(t, "bpmn:CompensateEventDefinition");
361
- }
362
- function Fn(t) {
363
- return p(t, "bpmn:Activity") && t.businessObject.isForCompensation;
364
- }
365
- function Pe(t) {
366
- return (p(t, "bpmn:CatchEvent") || p(t, "bpmn:ReceiveTask")) && !re(t);
367
- }
368
- function ee(t) {
369
- return p(t, "bpmn:BoundaryEvent") && !re(t);
370
- }
371
- function Bn(t) {
372
- return dt(t) && !ae(t);
373
- }
374
- function Re(t) {
375
- return !(re(t) || !Vt(t, [
376
- "bpmn:Activity",
377
- "bpmn:IntermediateCatchEvent",
378
- "bpmn:IntermediateThrowEvent",
379
- "bpmn:Gateway",
380
- "bpmn:EndEvent"
381
- ]) || Le(t) || t.incoming.find(rt) || Fn(t) || ot(t));
382
- }
383
- function dt(t) {
384
- return p(t, "bpmn:StartEvent") && !re(t);
385
- }
386
- function re(t) {
387
- return !!t.labelTarget;
388
- }
389
- function ot(t) {
390
- return H(t).triggeredByEvent;
391
- }
392
- function xn(t) {
393
- return p(t, "bpmn:StartEvent") && H(t).isInterrupting || p(t, "bpmn:BoundaryEvent") && H(t).cancelActivity;
394
- }
395
- function Vt(t, e) {
396
- return e.some((n) => p(t, n));
397
- }
398
- function ae(t, e) {
399
- return on(H(t).eventDefinitions, (n) => e ? p(n, e) : !0);
400
- }
401
- function Ft(t, e) {
402
- return t.children && t.children.length !== 0 ? t.children : p(t, "bpmn:SubProcess") && !t.di.isExpanded ? e.get(Kn(t)).children : [];
403
- }
404
- function kn(t, e, n) {
405
- const i = t.get("scopeIds", !1) || new Zn([32, 36]), o = {}, s = {}, r = new Vi(), c = /* @__PURE__ */ new Set(), m = [], u = /* @__PURE__ */ new Set(), E = /* @__PURE__ */ new Set();
406
- $t("tick", function() {
407
- for (const a of c)
408
- R("elementChanged", {
409
- element: a
410
- });
411
- c.clear();
412
- });
413
- function S(a, d) {
414
- if (m.push([d, a]), m.length !== 1)
415
- return;
416
- let v;
417
- for (; v = m[0]; ) {
418
- const [C, _] = v;
419
- _.destroyed || C(), m.shift();
420
- }
421
- R("tick");
422
- }
423
- function D(a) {
424
- return s[a.type] || r;
425
- }
426
- function G(a) {
427
- const {
428
- element: d,
429
- parentScope: v,
430
- initiator: C = null,
431
- scope: _ = Ye({
432
- element: d,
433
- parent: v,
434
- initiator: C
435
- })
436
- } = a;
437
- return S(_, function() {
438
- _.running || _.start(), U("signal", {
439
- ...a,
440
- scope: _
441
- }), D(d).signal({
442
- ...a,
443
- scope: _
444
- }), _.parent && Z(_.parent);
445
- }), _;
446
- }
447
- function j(a) {
448
- const {
449
- element: d,
450
- scope: v,
451
- initiator: C = v
452
- } = a, _ = Ye({
453
- element: d,
454
- parent: v,
455
- initiator: C
456
- });
457
- return S(_, function() {
458
- _.running || _.start(), U("enter", a), D(d).enter({
459
- ...a,
460
- initiator: C,
461
- scope: _
462
- }), _.parent && Z(_.parent);
463
- }), _;
464
- }
465
- function k(a) {
466
- const {
467
- element: d,
468
- scope: v,
469
- initiator: C = v
470
- } = a;
471
- S(v, function() {
472
- U("exit", a), D(d).exit({
473
- ...a,
474
- initiator: C
475
- }), v.running && v.complete(), Y(v, C), v.parent && Z(v.parent);
476
- });
477
- }
478
- function I(a) {
479
- const {
480
- event: d,
481
- initiator: v,
482
- scope: C
483
- } = a, _ = wt(d), b = C.subscriptions;
484
- let x = Ct(
485
- b,
486
- (A) => Se(_, A.event)
487
- );
488
- if (_.type === "error" || _.type === "escalation") {
489
- const A = Ct(
490
- x,
491
- (ht) => In(_, ht.event)
492
- );
493
- (x.every((ht) => ht.event.boundary) && A.some((ht) => ht.event.boundary) || A.some((ht) => !ht.event.boundary)) && (x = A);
494
- }
495
- const $ = x.filter(
496
- (A) => !A.event.interrupting
497
- ), Ot = x.filter(
498
- (A) => A.event.interrupting
499
- );
500
- if (!Ot.length)
501
- return $.map(
502
- (A) => A.triggerFn(v)
503
- ).flat();
504
- const We = Ot.find((A) => !A.event.boundary) || Ot[0], Xn = Ct(
505
- b,
506
- (A) => A.event.persistent || zi(A.event, We.event)
507
- );
508
- return b.forEach((A) => {
509
- Xn.includes(A) || A.remove();
510
- }), [We.triggerFn(v)].flat().filter((A) => A);
511
- }
512
- function M(a, d, v) {
513
- d = wt(d);
514
- const C = d.element, _ = {
515
- scope: a,
516
- event: d,
517
- element: C,
518
- triggerFn: v,
519
- remove() {
520
- L(_);
521
- }
522
- };
523
- return E.add(_), a.subscriptions.add(_), C && P(C), _;
524
- }
525
- function L(a) {
526
- const {
527
- scope: d,
528
- event: v
529
- } = a;
530
- E.delete(a), d.subscriptions.delete(a), v.element && P(v.element);
531
- }
532
- function Qt(a) {
533
- return p(a, "bpmn:StartEvent") || p(a, "bpmn:IntermediateCatchEvent") || p(a, "bpmn:ReceiveTask") || Yi(a) ? H(a).name || a.id : null;
534
- }
535
- function Pt(a) {
536
- return {
537
- element: a,
538
- interrupting: !1,
539
- boundary: !1,
540
- iref: a.id,
541
- type: "none"
542
- };
543
- }
544
- function wt(a) {
545
- if (!a.businessObject)
546
- return a;
547
- const d = xn(a), v = ee(a), C = Qt(a), _ = {
548
- element: a,
549
- interrupting: d,
550
- boundary: v,
551
- ...C ? { iref: C } : {}
552
- }, b = An(a)[0];
553
- if (!b)
554
- return {
555
- ..._,
556
- type: qi(a) ? "message" : "none"
557
- };
558
- if (p(b, "bpmn:LinkEventDefinition"))
559
- return {
560
- ..._,
561
- type: "link",
562
- name: b.name
563
- };
564
- if (p(b, "bpmn:SignalEventDefinition"))
565
- return {
566
- ..._,
567
- type: "signal",
568
- ref: b.signalRef
569
- };
570
- if (p(b, "bpmn:TimerEventDefinition"))
571
- return {
572
- ..._,
573
- type: "timer"
574
- };
575
- if (p(b, "bpmn:ConditionalEventDefinition"))
576
- return {
577
- ..._,
578
- type: "condition"
579
- };
580
- if (p(b, "bpmn:EscalationEventDefinition"))
581
- return {
582
- ..._,
583
- type: "escalation",
584
- ref: b.escalationRef
585
- };
586
- if (p(b, "bpmn:CancelEventDefinition"))
587
- return {
588
- ..._,
589
- type: "cancel"
590
- };
591
- if (p(b, "bpmn:ErrorEventDefinition"))
592
- return {
593
- ..._,
594
- type: "error",
595
- ref: b.errorRef
596
- };
597
- if (p(b, "bpmn:MessageEventDefinition"))
598
- return {
599
- ..._,
600
- type: "message",
601
- ref: b.messageRef
602
- };
603
- if (p(b, "bpmn:CompensateEventDefinition")) {
604
- let x = b.activityRef && n.get(b.activityRef.id);
605
- return x || (dt(a) && ot(a.parent) ? x = a.parent.parent : ee(a) ? x = a.host : x = a.parent), {
606
- ..._,
607
- type: "compensate",
608
- ref: x,
609
- persistent: !0
610
- };
611
- }
612
- throw new Error("unknown event definition", b);
613
- }
614
- function Rt(a, d = !0) {
615
- const {
616
- element: v,
617
- parent: C,
618
- initiator: _
619
- } = a;
620
- d && U("createScope", {
621
- element: v,
622
- scope: C
623
- });
624
- const b = new ji(i.next(), v, C, _);
625
- return C && C.children.push(b), u.add(b), d && R("createScope", {
626
- scope: b
627
- }), P(v), C && P(C.element), b;
628
- }
629
- function l(a) {
630
- if (typeof a == "function")
631
- return a;
632
- const {
633
- event: d,
634
- element: v,
635
- scope: C
636
- } = a, _ = a.elements || v && [v], b = d && wt(d);
637
- return ((x) => (!b || Se(b, x.event)) && (!_ || _.includes(x.element)) && (!C || C === x.scope));
638
- }
639
- function f(a) {
640
- const d = a === "function" ? a : l(a);
641
- return ((v) => Array.from(v.subscriptions).some(d));
642
- }
643
- function h(a) {
644
- if (typeof a == "function")
645
- return a;
646
- const {
647
- element: d,
648
- waitsOnElement: v,
649
- parent: C,
650
- trait: _ = w.RUNNING,
651
- subscribedTo: b
652
- } = a, x = b ? f(b) : () => !0;
653
- return (($) => (!d || $.element === d) && (!C || $.parent === C) && (!v || $.getTokensByElement(v) > 0) && $.hasTrait(_) && x($));
654
- }
655
- function g(a) {
656
- return Ct(E, l(a));
657
- }
658
- function y(a) {
659
- return Xe(E, l(a));
660
- }
661
- function F(a) {
662
- return Ct(u, h(a));
663
- }
664
- function B(a) {
665
- return Xe(u, h(a));
666
- }
667
- function Y(a, d = null) {
668
- if (!a.destroyed) {
669
- a.destroy(d);
670
- for (const v of a.subscriptions) {
671
- const C = v.event.traits || w.ACTIVE;
672
- a.hasTrait(C) || L(v);
673
- }
674
- if (a.destroyed) {
675
- for (const v of a.children)
676
- v.destroyed || Y(v, d);
677
- U("destroyScope", {
678
- element: a.element,
679
- scope: a
680
- }), u.delete(a), R("destroyScope", {
681
- scope: a
682
- });
683
- }
684
- P(a.element), a.parent && P(a.parent.element);
685
- }
686
- }
687
- function U(a, d) {
688
- R("trace", {
689
- ...d,
690
- action: a
691
- });
692
- }
693
- function P(a) {
694
- c.add(a), m.length || R("tick");
695
- }
696
- function Z(a) {
697
- R("scopeChanged", {
698
- scope: a
699
- });
700
- }
701
- function R(a, d = {}) {
702
- return e.fire(`tokenSimulation.simulator.${a}`, d);
703
- }
704
- function $t(a, d) {
705
- e.on("tokenSimulation.simulator." + a, d);
706
- }
707
- function ze(a, d) {
708
- e.off("tokenSimulation.simulator." + a, d);
709
- }
710
- function qe(a, d) {
711
- const v = Ue(a);
712
- o[a.id || a] = {
713
- ...v,
714
- ...d
715
- }, P(a);
716
- }
717
- function Yn() {
718
- const a = [];
719
- return n.forEach((d) => {
720
- if (!Vt(d, ["bpmn:Process", "bpmn:Participant"]))
721
- return;
722
- const v = Rt({
723
- element: d
724
- }, !1);
725
- a.push(v);
726
- const C = d.children.filter(dt), _ = d.children.filter(Re);
727
- for (const b of C) {
728
- const x = {
729
- ...wt(b),
730
- interrupting: !1
731
- };
732
- M(v, x, ($) => G({
733
- element: d,
734
- startEvent: b,
735
- initiator: $
736
- }));
737
- }
738
- if (!C.length)
739
- for (const b of _) {
740
- const x = Pt(b);
741
- M(v, x, ($) => G({
742
- element: d,
743
- initiator: $
744
- }));
745
- }
746
- }), a;
747
- }
748
- function Ye(a) {
749
- const {
750
- element: d
751
- } = a, v = Rt(a), {
752
- attachers: C = []
753
- } = d, _ = Ft(d, n);
754
- for (const b of _)
755
- if (ot(b)) {
756
- const x = Ft(b, n).filter(
757
- ($) => dt($) && !ne($)
758
- );
759
- for (const $ of x)
760
- M(v, $, (Ot) => G({
761
- element: b,
762
- parentScope: v,
763
- startEvent: $,
764
- initiator: Ot
765
- }));
766
- }
767
- for (const b of C)
768
- ee(b) && !ne(b) && M(v, b, (x) => G({
769
- element: b,
770
- parentScope: v.parent,
771
- hostScope: v,
772
- initiator: x
773
- }));
774
- return v;
775
- }
776
- function Ue(a) {
777
- return o[a.id || a] || {};
778
- }
779
- function Un(a, d) {
780
- if (!d.length)
781
- return;
782
- const v = {
783
- type: "all-completed",
784
- persistent: !1
785
- }, C = new Set(d), _ = (b) => {
786
- C.delete(b.scope), C.size === 0 && (ze("destroyScope", _), I({
787
- scope: a,
788
- event: v
789
- }));
790
- };
791
- return $t("destroyScope", _), v;
792
- }
793
- function Wn(a, d = !0) {
794
- qe(a, {
795
- wait: d
796
- });
797
- }
798
- function Jn() {
799
- for (const a of u)
800
- Y(a);
801
- for (const a of Yn())
802
- u.add(a);
803
- R("tick"), R("reset");
804
- }
805
- this.createScope = Rt, this.destroyScope = Y, this.findScope = B, this.findScopes = F, this.findSubscription = y, this.findSubscriptions = g, this.waitAtElement = Wn, this.waitForScopes = Un, this.setConfig = qe, this.getConfig = Ue, this.signal = G, this.enter = j, this.exit = k, this.subscribe = M, this.trigger = I, this.reset = Jn, this.on = $t, this.off = ze, this.registerBehavior = function(a, d) {
806
- s[a] = d;
807
- };
808
- }
809
- kn.$inject = [
810
- "injector",
811
- "eventBus",
812
- "elementRegistry"
813
- ];
814
- function Vi() {
815
- this.signal = function(t) {
816
- console.log("ignored #exit", t.element);
817
- }, this.exit = function(t) {
818
- console.log("ignored #exit", t.element);
819
- }, this.enter = function(t) {
820
- console.log("ignored #enter", t.element);
821
- };
822
- }
823
- function zi(t, e) {
824
- return t.boundary && !e.boundary;
825
- }
826
- function qi(t) {
827
- return p(t, "bpmn:ReceiveTask") || t.incoming.some((e) => p(e, "bpmn:MessageFlow"));
828
- }
829
- function Yi(t) {
830
- if (!ee(t))
831
- return !1;
832
- const e = An(t);
833
- return !e[0] || Vt(e[0], [
834
- "bpmn:ConditionalEventDefinition",
835
- "bpmn:TimerEventDefinition"
836
- ]);
837
- }
838
- function An(t) {
839
- return t.businessObject.get("eventDefinitions") || [];
840
- }
841
- function ce(t, e) {
842
- this._simulator = t, this._activityBehavior = e, t.registerBehavior("bpmn:StartEvent", this);
843
- }
844
- ce.prototype.signal = function(t) {
845
- this._simulator.exit(t);
846
- };
847
- ce.prototype.exit = function(t) {
848
- this._activityBehavior.exit(t);
849
- };
850
- ce.$inject = [
851
- "simulator",
852
- "activityBehavior"
853
- ];
854
- function zt(t, e, n) {
855
- this._intermediateThrowEventBehavior = n, this._scopeBehavior = e, t.registerBehavior("bpmn:EndEvent", this);
856
- }
857
- zt.$inject = [
858
- "simulator",
859
- "scopeBehavior",
860
- "intermediateThrowEventBehavior"
861
- ];
862
- zt.prototype.enter = function(t) {
863
- this._intermediateThrowEventBehavior.enter(t);
864
- };
865
- zt.prototype.signal = function(t) {
866
- this._intermediateThrowEventBehavior.signal(t);
867
- };
868
- zt.prototype.exit = function(t) {
869
- const {
870
- scope: e
871
- } = t;
872
- this._scopeBehavior.tryExit(e.parent, e);
873
- };
874
- function le(t, e, n) {
875
- this._simulator = t, this._activityBehavior = e, this._scopeBehavior = n, t.registerBehavior("bpmn:BoundaryEvent", this);
876
- }
877
- le.prototype.signal = function(t) {
878
- const {
879
- element: e,
880
- scope: n,
881
- hostScope: i = this._simulator.findScope({
882
- parent: n.parent,
883
- element: e.host
884
- })
885
- } = t;
886
- if (!i)
887
- throw new Error("host scope not found");
888
- if (H(e).cancelActivity) {
889
- this._scopeBehavior.interrupt(i, n);
890
- const s = this._scopeBehavior.tryExit(i, n);
891
- if (s) {
892
- const r = this._simulator.subscribe(i, s, (c) => (r.remove(), this._simulator.exit(t)));
893
- return;
894
- }
895
- }
896
- this._simulator.exit(t);
897
- };
898
- le.prototype.exit = function(t) {
899
- this._activityBehavior.exit(t);
900
- };
901
- le.$inject = [
902
- "simulator",
903
- "activityBehavior",
904
- "scopeBehavior"
905
- ];
906
- function qt(t, e) {
907
- this._activityBehavior = e, this._simulator = t, t.registerBehavior("bpmn:IntermediateCatchEvent", this), t.registerBehavior("bpmn:ReceiveTask", this);
908
- }
909
- qt.$inject = [
910
- "simulator",
911
- "activityBehavior"
912
- ];
913
- qt.prototype.signal = function(t) {
914
- return this._simulator.exit(t);
915
- };
916
- qt.prototype.enter = function(t) {
917
- const {
918
- element: e
919
- } = t;
920
- return this._activityBehavior.signalOnEvent(t, e);
921
- };
922
- qt.prototype.exit = function(t) {
923
- this._activityBehavior.exit(t);
924
- };
925
- function Yt(t, e, n) {
926
- this._simulator = t, this._activityBehavior = e, this._eventBehaviors = n, t.registerBehavior("bpmn:IntermediateThrowEvent", this), t.registerBehavior("bpmn:SendTask", this);
927
- }
928
- Yt.prototype.enter = function(t) {
929
- const {
930
- element: e
931
- } = t, n = this._eventBehaviors.get(e);
932
- if (n) {
933
- const i = n(t);
934
- if (i)
935
- return this._activityBehavior.signalOnEvent(t, i);
936
- }
937
- this._activityBehavior.enter(t);
938
- };
939
- Yt.prototype.signal = function(t) {
940
- this._activityBehavior.signal(t);
941
- };
942
- Yt.prototype.exit = function(t) {
943
- this._activityBehavior.exit(t);
944
- };
945
- Yt.$inject = [
946
- "simulator",
947
- "activityBehavior",
948
- "eventBehaviors"
949
- ];
950
- function ue(t, e) {
951
- this._scopeBehavior = e, this._simulator = t, t.registerBehavior("bpmn:ExclusiveGateway", this);
952
- }
953
- ue.prototype.enter = function(t) {
954
- this._simulator.exit(t);
955
- };
956
- ue.prototype.exit = function(t) {
957
- const {
958
- element: e,
959
- scope: n
960
- } = t, i = Ht(e.outgoing);
961
- if (i.length === 1)
962
- return this._simulator.enter({
963
- element: i[0],
964
- scope: n.parent
965
- });
966
- const {
967
- activeOutgoing: o
968
- } = this._simulator.getConfig(e), s = i.find((r) => r === o);
969
- return s ? this._simulator.enter({
970
- element: s,
971
- scope: n.parent
972
- }) : this._scopeBehavior.tryExit(n.parent, n);
973
- };
974
- ue.$inject = [
975
- "simulator",
976
- "scopeBehavior"
977
- ];
978
- function Ut(t, e) {
979
- this._simulator = t, this._activityBehavior = e, t.registerBehavior("bpmn:ParallelGateway", this);
980
- }
981
- Ut.prototype.enter = function(t) {
982
- const {
983
- scope: e
984
- } = t, n = this._findJoiningScopes(t);
985
- if (n.length) {
986
- for (const i of n)
987
- i !== e && this._simulator.destroyScope(i.complete(), e);
988
- this._simulator.exit(t);
989
- }
990
- };
991
- Ut.prototype._findJoiningScopes = function(t) {
992
- const {
993
- scope: e,
994
- element: n
995
- } = t, i = Ht(n.incoming), {
996
- parent: o
997
- } = e, s = this._simulator.findScopes({
998
- parent: o,
999
- element: n
1000
- }), r = i.map(
1001
- (c) => s.find((m) => m.initiator.element === c)
1002
- ).filter((c) => c);
1003
- return r.length === i.length ? r : [];
1004
- };
1005
- Ut.prototype.exit = function(t) {
1006
- this._activityBehavior.exit(t);
1007
- };
1008
- Ut.$inject = [
1009
- "simulator",
1010
- "activityBehavior"
1011
- ];
1012
- function $e(t) {
1013
- this._simulator = t, t.registerBehavior("bpmn:EventBasedGateway", this);
1014
- }
1015
- $e.$inject = [
1016
- "simulator"
1017
- ];
1018
- $e.prototype.enter = function(t) {
1019
- const {
1020
- element: e,
1021
- scope: n
1022
- } = t, i = n.parent, s = Ui(e).map(
1023
- (r) => this._simulator.subscribe(i, r, (c) => (s.forEach((m) => m.remove()), this._simulator.destroyScope(n, c), this._simulator.signal({
1024
- element: r,
1025
- parentScope: i,
1026
- initiator: c
1027
- })))
1028
- );
1029
- };
1030
- function Ui(t) {
1031
- return t.outgoing.map(
1032
- (e) => e.target
1033
- ).filter((e) => Vt(e, [
1034
- "bpmn:IntermediateCatchEvent",
1035
- "bpmn:ReceiveTask"
1036
- ]));
1037
- }
1038
- function Mn(t, e) {
1039
- return Qn(H(t).eventDefinitions, (n) => p(n, e));
1040
- }
1041
- function Wi(t, e) {
1042
- return on(H(t).eventDefinitions, (n) => p(n, e));
1043
- }
1044
- function at(t, e) {
1045
- this._simulator = t, this._activityBehavior = e, t.registerBehavior("bpmn:InclusiveGateway", this);
1046
- }
1047
- at.prototype.enter = function(t) {
1048
- this._tryJoin(t);
1049
- };
1050
- at.prototype.exit = function(t) {
1051
- const {
1052
- element: e,
1053
- scope: n
1054
- } = t;
1055
- if (Ht(e.outgoing).length > 1) {
1056
- const {
1057
- activeOutgoing: o = []
1058
- } = this._simulator.getConfig(e);
1059
- if (!o.length)
1060
- throw new Error("no outgoing configured");
1061
- for (const s of o)
1062
- this._simulator.enter({
1063
- element: s,
1064
- scope: n.parent
1065
- });
1066
- } else
1067
- this._activityBehavior.exit(t);
1068
- };
1069
- at.prototype._tryJoin = function(t) {
1070
- var e = t.exclude || [];
1071
- const {
1072
- scope: n,
1073
- element: i
1074
- } = t, {
1075
- parent: o
1076
- } = n, s = Ht(i.incoming), r = this._simulator.findScopes({
1077
- parent: o,
1078
- element: i
1079
- }).filter((k) => !e.includes(k)), c = s.filter(
1080
- (k) => !r.find((I) => I.initiator.element === k)
1081
- ), m = s.filter(
1082
- (k) => r.find((I) => I.initiator.element === k)
1083
- ), S = this._getRemainingScopes(t).filter(
1084
- (k) => c.some(
1085
- (I) => this._canReachElement(t, k.element, I)
1086
- )
1087
- ).filter(
1088
- (k) => !m.some(
1089
- (I) => this._canReachElement(t, k.element, I)
1090
- )
1091
- );
1092
- if (S.length || this._join(t, m, r, e), this._simulator.findScopes({
1093
- parent: o,
1094
- element: i
1095
- }).filter((k) => !e.includes(k))[0] !== n)
1096
- return;
1097
- const G = this._simulator.waitForScopes(n, S), j = this._simulator.subscribe(n, G, () => {
1098
- j.remove(), this._tryJoin(t);
1099
- });
1100
- };
1101
- at.prototype._getRemainingScopes = function(t) {
1102
- const {
1103
- scope: e,
1104
- element: n
1105
- } = t, {
1106
- parent: i
1107
- } = e;
1108
- return this._simulator.findScopes(
1109
- (o) => o.parent === i && o.element !== n
1110
- );
1111
- };
1112
- at.prototype._join = function(t, e, n, i) {
1113
- const {
1114
- scope: o
1115
- } = t, s = e.map(
1116
- (c) => n.find((m) => m.initiator.element === c)
1117
- );
1118
- for (const c of s)
1119
- c !== o && this._simulator.destroyScope(c.complete(), o);
1120
- this._simulator.exit(t), i.push(o);
1121
- const r = n.filter(
1122
- (c) => !s.includes(c)
1123
- );
1124
- r.length && this._tryJoin({
1125
- initiator: r[0].initiator,
1126
- element: r[0].element,
1127
- scope: r[0],
1128
- exclude: i
1129
- });
1130
- };
1131
- at.prototype._canReachElement = function(t, e, n, i = /* @__PURE__ */ new Set()) {
1132
- return t.element === n || i.has(n) ? !1 : (i.add(n), e === n ? !0 : rt(n) ? this._canReachElement(t, e, n.source, i) : Le(n) ? Ji(
1133
- n.parent.children,
1134
- Ln(n)
1135
- ).some(
1136
- (r) => this._canReachElement(t, e, r, i)
1137
- ) : Ht(n.incoming).some(
1138
- (s) => this._canReachElement(t, e, s, i)
1139
- ));
1140
- };
1141
- function Ln(t) {
1142
- return Mn(t, "bpmn:LinkEventDefinition").name;
1143
- }
1144
- function Ji(t, e) {
1145
- return t.filter(
1146
- (n) => Hi(n) && Ln(n) === e
1147
- );
1148
- }
1149
- at.$inject = [
1150
- "simulator",
1151
- "activityBehavior"
1152
- ];
1153
- function et(t, e, n) {
1154
- this._simulator = t, this._scopeBehavior = e, this._transactionBehavior = n;
1155
- const i = [
1156
- "bpmn:BusinessRuleTask",
1157
- "bpmn:CallActivity",
1158
- "bpmn:ManualTask",
1159
- "bpmn:ScriptTask",
1160
- "bpmn:ServiceTask",
1161
- "bpmn:Task",
1162
- "bpmn:UserTask"
1163
- ];
1164
- for (const o of i)
1165
- t.registerBehavior(o, this);
1166
- }
1167
- et.$inject = [
1168
- "simulator",
1169
- "scopeBehavior",
1170
- "transactionBehavior"
1171
- ];
1172
- et.prototype.signal = function(t) {
1173
- const e = this._triggerMessages(t);
1174
- if (e)
1175
- return this.signalOnEvent(t, e);
1176
- this._simulator.exit(t);
1177
- };
1178
- et.prototype.enter = function(t) {
1179
- const {
1180
- element: e
1181
- } = t, n = this.waitAtElement(e);
1182
- if (n)
1183
- return this.signalOnEvent(t, n);
1184
- const i = this._triggerMessages(t);
1185
- if (i)
1186
- return this.signalOnEvent(t, i);
1187
- this._simulator.exit(t);
1188
- };
1189
- et.prototype.exit = function(t) {
1190
- const {
1191
- element: e,
1192
- scope: n
1193
- } = t, i = n.parent, o = n.active && !n.failed;
1194
- o && !ot(e) && this._transactionBehavior.registerCompensation(n);
1195
- const s = o ? e.outgoing.filter(rt) : [];
1196
- s.forEach(
1197
- (r) => this._simulator.enter({
1198
- element: r,
1199
- scope: i
1200
- })
1201
- ), s.length === 0 && this._scopeBehavior.tryExit(i, n);
1202
- };
1203
- et.prototype.signalOnEvent = function(t, e) {
1204
- const {
1205
- scope: n,
1206
- element: i
1207
- } = t, o = this._simulator.subscribe(n, e, (s) => (o.remove(), this._simulator.signal({
1208
- scope: n,
1209
- element: i,
1210
- initiator: s
1211
- })));
1212
- };
1213
- et.prototype.waitAtElement = function(t) {
1214
- return this._simulator.getConfig(t).wait && {
1215
- element: t,
1216
- type: "continue",
1217
- interrupting: !1,
1218
- boundary: !1
1219
- };
1220
- };
1221
- et.prototype._getMessageContexts = function(t, e = null) {
1222
- const n = e ? (o) => o.referencePoint.x > e.x : () => !0, i = (o, s) => o.referencePoint.x - s.referencePoint.x;
1223
- return [
1224
- ...t.incoming.filter(we).map((o) => ({
1225
- incoming: o,
1226
- referencePoint: Ki(o.waypoints)
1227
- })),
1228
- ...t.outgoing.filter(we).map((o) => ({
1229
- outgoing: o,
1230
- referencePoint: Xi(o.waypoints)
1231
- }))
1232
- ].sort(i).filter(n);
1233
- };
1234
- et.prototype._triggerMessages = function(t) {
1235
- const {
1236
- element: e,
1237
- initiator: n,
1238
- scope: i
1239
- } = t;
1240
- let o = i.messageContexts;
1241
- o || (o = i.messageContexts = this._getMessageContexts(e));
1242
- const s = n && n.element;
1243
- if (we(s) && i.expectedIncoming !== s) {
1244
- console.debug("Simulator :: ActivityBehavior :: ignoring out-of-bounds message");
1245
- return;
1246
- }
1247
- for (; o.length; ) {
1248
- const {
1249
- incoming: r,
1250
- outgoing: c
1251
- } = o.shift();
1252
- if (r) {
1253
- if (!n)
1254
- continue;
1255
- return i.expectedIncoming = r, {
1256
- element: e,
1257
- type: "message",
1258
- name: r.id,
1259
- interrupting: !1,
1260
- boundary: !1
1261
- };
1262
- }
1263
- this._simulator.signal({
1264
- element: c
1265
- });
1266
- }
1267
- };
1268
- function Xi(t) {
1269
- return t && t[0];
1270
- }
1271
- function Ki(t) {
1272
- return t && t[t.length - 1];
1273
- }
1274
- function _t(t, e, n, i, o) {
1275
- this._simulator = t, this._activityBehavior = e, this._scopeBehavior = n, this._transactionBehavior = i, this._elementRegistry = o, t.registerBehavior("bpmn:SubProcess", this), t.registerBehavior("bpmn:Transaction", this), t.registerBehavior("bpmn:AdHocSubProcess", this);
1276
- }
1277
- _t.$inject = [
1278
- "simulator",
1279
- "activityBehavior",
1280
- "scopeBehavior",
1281
- "transactionBehavior",
1282
- "elementRegistry"
1283
- ];
1284
- _t.prototype.signal = function(t) {
1285
- this._start(t);
1286
- };
1287
- _t.prototype.enter = function(t) {
1288
- const {
1289
- element: e
1290
- } = t, n = this._activityBehavior.waitAtElement(e);
1291
- if (n)
1292
- return this._activityBehavior.signalOnEvent(t, n);
1293
- this._start(t);
1294
- };
1295
- _t.prototype.exit = function(t) {
1296
- const {
1297
- scope: e
1298
- } = t, n = e.parent;
1299
- n.failInitiator === e && n.complete(), this._activityBehavior.exit(t);
1300
- };
1301
- _t.prototype._start = function(t) {
1302
- const {
1303
- element: e,
1304
- startEvent: n,
1305
- scope: i
1306
- } = t, o = i.parent;
1307
- if (ot(e)) {
1308
- if (!n)
1309
- throw new Error("missing <startEvent>: required for event sub-process");
1310
- } else if (n)
1311
- throw new Error("unexpected <startEvent>: not allowed for sub-process");
1312
- if (o.destroyed)
1313
- throw new Error(`target scope <${o.id}> destroyed`);
1314
- Zi(e) && this._transactionBehavior.setup(t), n && xn(n) && this._scopeBehavior.interrupt(o, i);
1315
- const s = this._findStarts(e, n);
1316
- for (const r of s)
1317
- dt(r) ? this._simulator.signal({
1318
- element: r,
1319
- parentScope: i,
1320
- initiator: i
1321
- }) : this._simulator.enter({
1322
- element: r,
1323
- scope: i,
1324
- initiator: i
1325
- });
1326
- s.length || this._simulator.exit(t);
1327
- };
1328
- _t.prototype._findStarts = function(t, e) {
1329
- const n = e ? (i) => e === i : (i) => Bn(i);
1330
- return Ft(t, this._elementRegistry).filter(
1331
- (i) => n(i) || Re(i)
1332
- );
1333
- };
1334
- function Zi(t) {
1335
- return p(t, "bpmn:Transaction");
1336
- }
1337
- const Ce = {
1338
- type: "cancel",
1339
- interrupting: !0,
1340
- boundary: !1,
1341
- persistent: !0
1342
- };
1343
- function ct(t, e, n) {
1344
- this._simulator = t, this._scopeBehavior = e, this._elementRegistry = n;
1345
- }
1346
- ct.$inject = [
1347
- "simulator",
1348
- "scopeBehavior",
1349
- "elementRegistry"
1350
- ];
1351
- ct.prototype.setup = function(t) {
1352
- const {
1353
- scope: e
1354
- } = t, n = this._simulator.subscribe(e, Ce, (s) => (n.remove(), this.cancel({
1355
- scope: e,
1356
- initiator: s
1357
- }))), i = {
1358
- type: "compensate",
1359
- ref: e.element,
1360
- persistent: !0,
1361
- traits: w.NOT_DEAD
1362
- }, o = this._simulator.subscribe(e, i, (s) => e.canceled ? (o.remove(), this.compensate({
1363
- scope: e,
1364
- element: e.element,
1365
- initiator: s
1366
- })) : this._simulator.trigger({
1367
- event: Ce,
1368
- scope: e
1369
- }));
1370
- };
1371
- ct.prototype.cancel = function(t) {
1372
- const {
1373
- scope: e,
1374
- initiator: n
1375
- } = t;
1376
- if (!e.destroyed)
1377
- return e.cancel(n), this._simulator.trigger({
1378
- event: {
1379
- type: "compensate",
1380
- ref: e.element
1381
- },
1382
- initiator: n,
1383
- scope: e
1384
- }), this._simulator.trigger({
1385
- scope: e,
1386
- initiator: n,
1387
- event: Ce
1388
- });
1389
- };
1390
- ct.prototype.registerCompensation = function(t) {
1391
- const {
1392
- element: e
1393
- } = t, i = Ft(e, this._elementRegistry).filter(
1394
- ot
1395
- ).map(
1396
- (r) => Ft(r, this._elementRegistry).find(
1397
- (c) => dt(c) && ne(c)
1398
- )
1399
- ).filter((r) => r), o = e.attachers.filter(ne);
1400
- if (!i.length && !o.length)
1401
- return;
1402
- const s = this.findTransactionScope(t);
1403
- p(s.element, "bpmn:Transaction") || this.makeCompensable(s);
1404
- for (const r of i) {
1405
- const c = {
1406
- element: r,
1407
- type: "compensate",
1408
- persistent: !0,
1409
- interrupting: !0,
1410
- ref: e,
1411
- traits: w.NOT_DEAD
1412
- }, m = r.parent, u = this._simulator.subscribe(t, c, (E) => (u.remove(), this._simulator.signal({
1413
- initiator: E,
1414
- element: m,
1415
- startEvent: r,
1416
- parentScope: t
1417
- })));
1418
- }
1419
- for (const r of o) {
1420
- const c = {
1421
- element: r,
1422
- type: "compensate",
1423
- persistent: !0,
1424
- ref: e,
1425
- traits: w.NOT_DEAD
1426
- }, m = r.outgoing.map(
1427
- (E) => E.target
1428
- ).find(
1429
- Fn
1430
- );
1431
- if (!m)
1432
- continue;
1433
- const u = this._simulator.subscribe(s, c, (E) => (u.remove(), this._simulator.enter({
1434
- initiator: E,
1435
- element: m,
1436
- scope: s
1437
- })));
1438
- }
1439
- };
1440
- ct.prototype.makeCompensable = function(t) {
1441
- if (t.hasTrait(w.COMPENSABLE) || !t.parent)
1442
- return;
1443
- const e = {
1444
- type: "compensate",
1445
- ref: t.element,
1446
- interrupting: !0,
1447
- persistent: !0,
1448
- traits: w.NOT_DEAD
1449
- };
1450
- t.compensable();
1451
- const n = this._simulator.subscribe(t, e, (s) => (n.remove(), t.fail(s), this.compensate({
1452
- scope: t,
1453
- element: t.element,
1454
- initiator: s
1455
- }), this._scopeBehavior.tryExit(t, s), t)), i = t.parent;
1456
- if (!i)
1457
- return;
1458
- const o = this._simulator.subscribe(i, e, (s) => (o.remove(), this._simulator.trigger({
1459
- scope: t,
1460
- event: e,
1461
- initiator: s
1462
- })));
1463
- this.makeCompensable(i);
1464
- };
1465
- ct.prototype.findTransactionScope = function(t) {
1466
- let e = t;
1467
- for (; e; ) {
1468
- const n = e.element;
1469
- if (p(n, "bpmn:SubProcess") && !ot(n) || Vt(n, [
1470
- "bpmn:Transaction",
1471
- "bpmn:Process",
1472
- "bpmn:Participant"
1473
- ]))
1474
- return e;
1475
- e = e.parent;
1476
- }
1477
- throw Qi(t);
1478
- };
1479
- ct.prototype.compensate = function(t) {
1480
- const {
1481
- scope: e,
1482
- element: n
1483
- } = t, i = Ct(
1484
- e.subscriptions,
1485
- (r) => Se({ type: "compensate" }, r.event)
1486
- ), o = i.filter((r) => r.event.ref === n), s = i.filter((r) => r.event.ref !== n);
1487
- for (const r of o)
1488
- this._scopeBehavior.preExit(e, (c) => this._simulator.trigger(r));
1489
- for (const r of s.reverse())
1490
- this._scopeBehavior.preExit(e, (c) => this._simulator.trigger(r));
1491
- };
1492
- function Qi(t) {
1493
- throw new Error(`no transaction context for <${t.id}>`);
1494
- }
1495
- function yt(t, e) {
1496
- this._simulator = t, this._scopeBehavior = e, t.registerBehavior("bpmn:SequenceFlow", this);
1497
- }
1498
- yt.prototype.enter = function(t) {
1499
- this._simulator.exit(t);
1500
- };
1501
- yt.prototype.exit = function(t) {
1502
- const {
1503
- element: e,
1504
- scope: n
1505
- } = t;
1506
- this._simulator.enter({
1507
- initiator: n,
1508
- element: e.target,
1509
- scope: n.parent
1510
- });
1511
- };
1512
- yt.$inject = [
1513
- "simulator",
1514
- "scopeBehavior"
1515
- ];
1516
- function bt(t) {
1517
- this._simulator = t, t.registerBehavior("bpmn:MessageFlow", this);
1518
- }
1519
- bt.$inject = ["simulator"];
1520
- bt.prototype.signal = function(t) {
1521
- this._simulator.exit(t);
1522
- };
1523
- bt.prototype.exit = function(t) {
1524
- const {
1525
- element: e,
1526
- scope: n
1527
- } = t, i = e.target, o = Pe(i) ? i : {
1528
- type: "message",
1529
- element: e,
1530
- name: e.id
1531
- }, s = this._simulator.findSubscription({
1532
- event: o,
1533
- elements: [i, i.parent]
1534
- });
1535
- s && this._simulator.trigger({
1536
- event: o,
1537
- initiator: n,
1538
- scope: s.scope
1539
- });
1540
- };
1541
- function Oe(t, e, n) {
1542
- this._simulator = t, this._elementRegistry = e, this._scopeBehavior = n;
1543
- }
1544
- Oe.$inject = [
1545
- "simulator",
1546
- "elementRegistry",
1547
- "scopeBehavior"
1548
- ];
1549
- Oe.prototype.get = function(t) {
1550
- const n = Object.entries({
1551
- "bpmn:LinkEventDefinition": (i) => {
1552
- const {
1553
- element: o,
1554
- scope: s
1555
- } = i, r = Ke(o), c = s.parent, m = c.element, E = Ft(m, this._elementRegistry).filter(
1556
- (S) => Le(S) && Ke(S).name === r.name
1557
- );
1558
- for (const S of E)
1559
- this._simulator.signal({
1560
- element: S,
1561
- parentScope: c,
1562
- initiator: s
1563
- });
1564
- },
1565
- "bpmn:SignalEventDefinition": (i) => {
1566
- const {
1567
- element: o,
1568
- scope: s
1569
- } = i, r = this._simulator.findSubscriptions({
1570
- event: o
1571
- }), c = /* @__PURE__ */ new Set();
1572
- for (const m of r) {
1573
- const u = m.scope;
1574
- c.has(u) || (c.add(u), this._simulator.trigger({
1575
- event: o,
1576
- scope: u,
1577
- initiator: s
1578
- }));
1579
- }
1580
- },
1581
- "bpmn:EscalationEventDefinition": (i) => {
1582
- const {
1583
- element: o,
1584
- scope: s
1585
- } = i, r = this._simulator.findScopes({
1586
- subscribedTo: {
1587
- event: o
1588
- },
1589
- trait: w.ACTIVE
1590
- });
1591
- let c = s;
1592
- for (; c = c.parent; )
1593
- if (r.includes(c)) {
1594
- this._simulator.trigger({
1595
- event: o,
1596
- scope: c,
1597
- initiator: s
1598
- });
1599
- break;
1600
- }
1601
- },
1602
- "bpmn:ErrorEventDefinition": (i) => {
1603
- const {
1604
- element: o,
1605
- scope: s
1606
- } = i, r = this._simulator.findScopes({
1607
- subscribedTo: {
1608
- event: o
1609
- },
1610
- trait: w.ACTIVE
1611
- });
1612
- let c = s;
1613
- for (; c = c.parent; )
1614
- if (r.includes(c)) {
1615
- this._simulator.trigger({
1616
- event: o,
1617
- scope: c,
1618
- initiator: s
1619
- });
1620
- break;
1621
- }
1622
- },
1623
- "bpmn:TerminateEventDefinition": (i) => {
1624
- const {
1625
- scope: o
1626
- } = i;
1627
- this._scopeBehavior.terminate(o.parent, o);
1628
- },
1629
- "bpmn:CancelEventDefinition": (i) => {
1630
- const {
1631
- scope: o,
1632
- element: s
1633
- } = i;
1634
- this._simulator.trigger({
1635
- event: s,
1636
- initiator: o,
1637
- scope: Ze(o)
1638
- });
1639
- },
1640
- "bpmn:CompensateEventDefinition": (i) => {
1641
- const {
1642
- scope: o,
1643
- element: s
1644
- } = i;
1645
- return this._simulator.waitForScopes(
1646
- o,
1647
- this._simulator.trigger({
1648
- event: s,
1649
- scope: Ze(o)
1650
- })
1651
- );
1652
- }
1653
- }).find(
1654
- (i) => Wi(t, i[0])
1655
- );
1656
- return n && n[1];
1657
- };
1658
- function Ke(t) {
1659
- return Mn(t, "bpmn:LinkEventDefinition");
1660
- }
1661
- function Ze(t) {
1662
- for (; ot(t.parent.element); )
1663
- t = t.parent;
1664
- return t.parent;
1665
- }
1666
- const Pn = {
1667
- type: "pre-exit",
1668
- persistent: !0,
1669
- interrupting: !0,
1670
- boundary: !1
1671
- }, ve = {
1672
- type: "exit",
1673
- interrupting: !0,
1674
- boundary: !1,
1675
- persistent: !0
1676
- };
1677
- function nt(t) {
1678
- this._simulator = t;
1679
- }
1680
- nt.$inject = [
1681
- "simulator"
1682
- ];
1683
- nt.prototype.isFinished = function(t, e = null) {
1684
- return e = Rn(e), t.children.every((n) => n.destroyed || n.completed || e(n));
1685
- };
1686
- nt.prototype.destroyChildren = function(t, e, n = null) {
1687
- n = Rn(n), t.children.filter((i) => !i.destroyed && !n(i)).map((i) => {
1688
- this._simulator.destroyScope(i, e);
1689
- });
1690
- };
1691
- nt.prototype.terminate = function(t, e) {
1692
- this.destroyChildren(t, e), t.terminate(e), this.tryExit(t, e);
1693
- };
1694
- nt.prototype.interrupt = function(t, e) {
1695
- this.destroyChildren(t, e, e), t.fail(e);
1696
- };
1697
- nt.prototype.tryExit = function(t, e) {
1698
- if (!t)
1699
- throw new Error("missing <scope>");
1700
- if (e || (e = t), !this.isFinished(t, e))
1701
- return ve;
1702
- const n = this._simulator.findSubscriptions({
1703
- event: Pn,
1704
- scope: t
1705
- });
1706
- for (const i of n) {
1707
- const {
1708
- event: o,
1709
- scope: s
1710
- } = i;
1711
- if (this._simulator.trigger({
1712
- event: o,
1713
- scope: s,
1714
- initiator: e
1715
- }).length)
1716
- return ve;
1717
- }
1718
- this._simulator.trigger({
1719
- event: ve,
1720
- scope: t,
1721
- initiator: e
1722
- }), this.exit({
1723
- scope: t,
1724
- initiator: e
1725
- });
1726
- };
1727
- nt.prototype.exit = function(t) {
1728
- const {
1729
- scope: e,
1730
- initiator: n
1731
- } = t;
1732
- if (!n)
1733
- throw new Error("missing <initiator>");
1734
- this._simulator.exit({
1735
- element: e.element,
1736
- scope: e,
1737
- initiator: n
1738
- });
1739
- };
1740
- nt.prototype.preExit = function(t, e) {
1741
- const n = this._simulator.subscribe(t, Pn, (i) => (n.remove(), e(i)));
1742
- return n;
1743
- };
1744
- function Rn(t) {
1745
- return typeof t == "function" ? t : (e) => e === t;
1746
- }
1747
- function Wt(t, e) {
1748
- this._simulator = t, this._scopeBehavior = e, t.registerBehavior("bpmn:Process", this), t.registerBehavior("bpmn:Participant", this);
1749
- }
1750
- Wt.prototype.signal = function(t) {
1751
- const {
1752
- element: e,
1753
- startEvent: n,
1754
- startNodes: i = this._findStarts(e, n),
1755
- scope: o
1756
- } = t;
1757
- if (!i.length)
1758
- throw new Error("missing <startNodes> or <startEvent>");
1759
- for (const s of i)
1760
- dt(s) ? this._simulator.signal({
1761
- element: s,
1762
- parentScope: o
1763
- }) : this._simulator.enter({
1764
- element: s,
1765
- scope: o
1766
- });
1767
- };
1768
- Wt.prototype.exit = function(t) {
1769
- const {
1770
- scope: e,
1771
- initiator: n
1772
- } = t;
1773
- this._scopeBehavior.destroyChildren(e, n);
1774
- };
1775
- Wt.prototype._findStarts = function(t, e) {
1776
- const n = e ? (i) => e === i : (i) => Bn(i);
1777
- return t.children.filter(
1778
- (i) => n(i) || Re(i)
1779
- );
1780
- };
1781
- Wt.$inject = [
1782
- "simulator",
1783
- "scopeBehavior"
1784
- ];
1785
- const to = {
1786
- __init__: [
1787
- "startEventBehavior",
1788
- "endEventBehavior",
1789
- "boundaryEventBehavior",
1790
- "intermediateCatchEventBehavior",
1791
- "intermediateThrowEventBehavior",
1792
- "exclusiveGatewayBehavior",
1793
- "parallelGatewayBehavior",
1794
- "eventBasedGatewayBehavior",
1795
- "inclusiveGatewayBehavior",
1796
- "subProcessBehavior",
1797
- "sequenceFlowBehavior",
1798
- "messageFlowBehavior",
1799
- "processBehavior"
1800
- ],
1801
- startEventBehavior: ["type", ce],
1802
- endEventBehavior: ["type", zt],
1803
- boundaryEventBehavior: ["type", le],
1804
- intermediateCatchEventBehavior: ["type", qt],
1805
- intermediateThrowEventBehavior: ["type", Yt],
1806
- exclusiveGatewayBehavior: ["type", ue],
1807
- parallelGatewayBehavior: ["type", Ut],
1808
- eventBasedGatewayBehavior: ["type", $e],
1809
- inclusiveGatewayBehavior: ["type", at],
1810
- activityBehavior: ["type", et],
1811
- subProcessBehavior: ["type", _t],
1812
- sequenceFlowBehavior: ["type", yt],
1813
- messageFlowBehavior: ["type", bt],
1814
- eventBehaviors: ["type", Oe],
1815
- scopeBehavior: ["type", nt],
1816
- processBehavior: ["type", Wt],
1817
- transactionBehavior: ["type", ct]
1818
- }, eo = 5e3, $n = {
1819
- __depends__: [
1820
- to
1821
- ],
1822
- __init__: [
1823
- ["eventBus", "simulator", function(t, e) {
1824
- t.on([
1825
- "tokenSimulation.toggleMode",
1826
- "tokenSimulation.resetSimulation"
1827
- ], eo, (n) => {
1828
- e.reset();
1829
- });
1830
- }]
1831
- ],
1832
- simulator: ["type", kn]
1833
- };
1834
- function he(t, e) {
1835
- t.invoke(bt, this), this._animation = e;
1836
- }
1837
- sn(he, bt);
1838
- he.$inject = [
1839
- "injector",
1840
- "animation"
1841
- ];
1842
- he.prototype.signal = function(t) {
1843
- const {
1844
- element: e,
1845
- scope: n
1846
- } = t;
1847
- this._animation.animate(e, n, () => {
1848
- bt.prototype.signal.call(this, t);
1849
- });
1850
- };
1851
- function pe(t, e) {
1852
- t.invoke(yt, this), this._animation = e;
1853
- }
1854
- sn(pe, yt);
1855
- pe.$inject = [
1856
- "injector",
1857
- "animation"
1858
- ];
1859
- pe.prototype.enter = function(t) {
1860
- const {
1861
- element: e,
1862
- scope: n
1863
- } = t;
1864
- this._animation.animate(e, n, () => {
1865
- yt.prototype.enter.call(this, t);
1866
- });
1867
- };
1868
- const no = {
1869
- sequenceFlowBehavior: ["type", pe],
1870
- messageFlowBehavior: ["type", he]
1871
- }, Qe = (t) => !0;
1872
- function kt(t, e) {
1873
- this._eventBus = t, this._simulator = e, this._filter = Qe, t.on([
1874
- N,
1875
- tt
1876
- ], () => {
1877
- this._filter = Qe;
1878
- }), t.on(Gt, (n) => {
1879
- const {
1880
- scope: i
1881
- } = n;
1882
- this._scope === i && i.parent && this.toggle(i.parent);
1883
- }), t.on(vt, (n) => {
1884
- const {
1885
- scope: i
1886
- } = n;
1887
- !i.parent && this._scope && !On(this._scope, i) && this.toggle(null);
1888
- });
1889
- }
1890
- kt.prototype.toggle = function(t) {
1891
- const e = this._scope !== t;
1892
- this._scope = e ? t : null, this._filter = this._scope ? (n) => On(this._scope, n) : (n) => !0, this._eventBus.fire(Bt, {
1893
- filter: this._filter,
1894
- scope: this._scope
1895
- });
1896
- };
1897
- kt.prototype.isShown = function(t) {
1898
- return typeof t == "string" && (t = this._simulator.findScope((e) => e.id === t)), t && this._filter(t);
1899
- };
1900
- kt.prototype.isFocused = function(t) {
1901
- const e = t.id || t;
1902
- return this._scope?.id === e;
1903
- };
1904
- kt.prototype.findScope = function(t) {
1905
- return this._simulator.findScopes(t).filter((e) => this.isShown(e))[0];
1906
- };
1907
- kt.$inject = [
1908
- "eventBus",
1909
- "simulator"
1910
- ];
1911
- function On(t, e) {
1912
- do
1913
- if (t === e)
1914
- return !0;
1915
- while (e = e.parent);
1916
- return !1;
1917
- }
1918
- const At = {
1919
- scopeFilter: ["type", kt]
1920
- }, Nn = getComputedStyle(document.documentElement), io = Nn.getPropertyValue("--token-simulation-green-base-44"), oo = Nn.getPropertyValue("--token-simulation-white");
1921
- function so() {
1922
- }
1923
- function ro(t, e) {
1924
- return e.length === 2 ? uo : t === 1 ? co : t === e.length - 1 ? lo : ao;
1925
- }
1926
- const ao = function(t) {
1927
- return t;
1928
- }, co = function(t) {
1929
- return -Math.cos(t * Math.PI / 2) + 1;
1930
- }, lo = function(t) {
1931
- return Math.sin(t * Math.PI / 2);
1932
- }, uo = function(t) {
1933
- return -Math.cos(t * Math.PI) / 2 + 0.5;
1934
- }, Dt = 20;
1935
- function z(t, e, n, i) {
1936
- this._eventBus = n, this._scopeFilter = i, this._canvas = e, this._randomize = t && t.randomize !== !1, this._animations = /* @__PURE__ */ new Set(), this._speed = 1, n.on([
1937
- "diagram.destroy",
1938
- tt
1939
- ], () => {
1940
- this.clearAnimations();
1941
- }), n.on(un, () => {
1942
- this.pause();
1943
- }), n.on(ln, () => {
1944
- this.play();
1945
- }), n.on(Bt, (o) => {
1946
- this.each((s) => {
1947
- this._scopeFilter.isShown(s.scope) ? s.show() : s.hide();
1948
- });
1949
- }), n.on(Gt, (o) => {
1950
- const {
1951
- scope: s
1952
- } = o;
1953
- this.clearAnimations(s);
1954
- });
1955
- }
1956
- z.prototype.animate = function(t, e, n) {
1957
- this.createAnimation(t, e, n);
1958
- };
1959
- z.prototype.pause = function() {
1960
- this.each((t) => t.pause());
1961
- };
1962
- z.prototype.play = function() {
1963
- this.each((t) => t.play());
1964
- };
1965
- z.prototype.each = function(t) {
1966
- this._animations.forEach(t);
1967
- };
1968
- z.prototype.createAnimation = function(t, e, n = so) {
1969
- const i = this._getGroup(e);
1970
- if (!i)
1971
- return;
1972
- const o = this._createTokenGfx(i, e), s = new J(o, t.waypoints, this._randomize, () => {
1973
- this._clearAnimation(s), n();
1974
- });
1975
- return s.setSpeed(this.getAnimationSpeed()), this._scopeFilter.isShown(e) || s.hide(), s.scope = e, s.element = t, this._animations.add(s), this._eventBus.fire(si, {
1976
- animation: s
1977
- }), s.play(), s;
1978
- };
1979
- z.prototype.setAnimationSpeed = function(t) {
1980
- this._speed = t, this.each((e) => e.setSpeed(t)), this._eventBus.fire(hn, {
1981
- speed: t
1982
- });
1983
- };
1984
- z.prototype.getAnimationSpeed = function() {
1985
- return this._speed;
1986
- };
1987
- z.prototype.clearAnimations = function(t) {
1988
- this.each((e) => {
1989
- (!t || e.scope === t) && this._clearAnimation(e);
1990
- });
1991
- };
1992
- z.prototype._clearAnimation = function(t) {
1993
- t.remove(), this._animations.delete(t);
1994
- };
1995
- z.prototype._createTokenGfx = function(t, e) {
1996
- const n = Fe(this._getTokenSVG(e).trim());
1997
- return rn(n, t);
1998
- };
1999
- z.prototype._getTokenSVG = function(t) {
2000
- const e = t.colors || {
2001
- primary: io,
2002
- auxiliary: oo
2003
- };
2004
- return `
2005
- <g class="bts-token">
2006
- <circle
2007
- class="bts-circle"
2008
- r="${Dt / 2}"
2009
- cx="${Dt / 2}"
2010
- cy="${Dt / 2}"
2011
- fill="${e.primary}"
2012
- />
2013
- <text
2014
- class="bts-text"
2015
- transform="translate(10, 14)"
2016
- text-anchor="middle"
2017
- fill="${e.auxiliary}"
2018
- >1</text>
2019
- </g>
2020
- `;
2021
- };
2022
- z.prototype._getGroup = function(t) {
2023
- var e = this._canvas, n, i;
2024
- "findRoot" in e ? (i = e.findRoot(t.element), n = e._findPlaneForRoot(i).layer) : n = mt(".viewport", e._svg);
2025
- var o = mt(".bts-animation-tokens", n);
2026
- return o || (o = Fe('<g class="bts-animation-tokens" />'), rn(
2027
- o,
2028
- n
2029
- )), o;
2030
- };
2031
- z.$inject = [
2032
- "config.animation",
2033
- "canvas",
2034
- "eventBus",
2035
- "scopeFilter"
2036
- ];
2037
- function J(t, e, n, i) {
2038
- this.gfx = t, this.waypoints = e, this.done = i, this.randomize = n, this._paused = !0, this._t = 0, this._parts = [], this.create();
2039
- }
2040
- J.prototype.pause = function() {
2041
- this._paused = !0;
2042
- };
2043
- J.prototype.play = function() {
2044
- this._paused && (this._paused = !1, this.tick(0)), this.schedule();
2045
- };
2046
- J.prototype.schedule = function() {
2047
- if (this._paused || this._scheduled)
2048
- return;
2049
- const t = Date.now();
2050
- this._scheduled = !0, requestAnimationFrame(() => {
2051
- this._scheduled = !1, !this._paused && (this.tick((Date.now() - t) * this._speed), this.schedule());
2052
- });
2053
- };
2054
- J.prototype.tick = function(t) {
2055
- const e = this._t = this._t + t, n = this._parts.find(
2056
- (c) => c.startTime <= e && c.endTime > e
2057
- );
2058
- if (!n)
2059
- return this.completed();
2060
- const i = e - n.startTime, o = n.length * n.easing(i / n.duration), s = n.startLength + o, r = this._path.getPointAtLength(s);
2061
- this.move(r.x, r.y);
2062
- };
2063
- J.prototype.move = function(t, e) {
2064
- Be(this.gfx, "transform", `translate(${t}, ${e})`);
2065
- };
2066
- J.prototype.create = function() {
2067
- const t = this.waypoints, e = t.reduce((s, r, c) => {
2068
- const m = t[c - 1];
2069
- if (m) {
2070
- const u = s[s.length - 1], E = u && u.endLength || 0, S = fo(m, r);
2071
- s.push({
2072
- startLength: E,
2073
- endLength: E + S,
2074
- length: S,
2075
- easing: ro(c, t)
2076
- });
2077
- }
2078
- return s;
2079
- }, []), n = e.reduce(function(s, r) {
2080
- return s + r.length;
2081
- }, 0), i = t.reduce((s, r, c) => {
2082
- const m = r.x - Dt / 2, u = r.y - Dt / 2;
2083
- return s.push([c > 0 ? "L" : "M", m, u]), s;
2084
- }, []).flat().join(" "), o = ho(n, this._randomize);
2085
- this._parts = e.reduce((s, r, c) => {
2086
- const m = o / n * r.length, u = c > 0 ? s[c - 1].endTime : 0, E = u + m;
2087
- return [
2088
- ...s,
2089
- {
2090
- ...r,
2091
- startTime: u,
2092
- endTime: E,
2093
- duration: m
2094
- }
2095
- ];
2096
- }, []), this._path = Fe(`<path d="${i}" />`), this._t = 0;
2097
- };
2098
- J.prototype.show = function() {
2099
- Be(this.gfx, "display", "");
2100
- };
2101
- J.prototype.hide = function() {
2102
- Be(this.gfx, "display", "none");
2103
- };
2104
- J.prototype.completed = function() {
2105
- this.done();
2106
- };
2107
- J.prototype.remove = function() {
2108
- this.pause(), ti(this.gfx);
2109
- };
2110
- J.prototype.setSpeed = function(t) {
2111
- this._speed = t;
2112
- };
2113
- function ho(t, e = !1) {
2114
- return Math.log(t) * (e ? po(250, 300) : 250);
2115
- }
2116
- function po(t, e) {
2117
- return t + Math.floor(Math.random() * (e - t));
2118
- }
2119
- function fo(t, e) {
2120
- return Math.sqrt(Math.pow(t.x - e.x, 2) + Math.pow(t.y - e.y, 2));
2121
- }
2122
- const mo = {
2123
- __depends__: [
2124
- $n,
2125
- no,
2126
- At
2127
- ],
2128
- animation: ["type", z]
2129
- };
2130
- var Nt = { exports: {} }, go = Nt.exports, tn;
2131
- function vo() {
2132
- return tn || (tn = 1, (function(t, e) {
2133
- (function(n, i) {
2134
- {
2135
- var o = i();
2136
- t && t.exports && (e = t.exports = o), e.randomColor = o;
2137
- }
2138
- })(go, function() {
2139
- var n = null, i = {};
2140
- M();
2141
- var o = [], s = function(l) {
2142
- if (l = l || {}, l.seed !== void 0 && l.seed !== null && l.seed === parseInt(l.seed, 10))
2143
- n = l.seed;
2144
- else if (typeof l.seed == "string")
2145
- n = wt(l.seed);
2146
- else {
2147
- if (l.seed !== void 0 && l.seed !== null)
2148
- throw new TypeError("The seed value must be an integer or string");
2149
- n = null;
2150
- }
2151
- var f, h, g;
2152
- if (l.count !== null && l.count !== void 0) {
2153
- for (var y = l.count, F = [], B = 0; B < l.count; B++)
2154
- o.push(!1);
2155
- for (l.count = null; y > F.length; ) {
2156
- var Y = s(l);
2157
- n !== null && (l.seed = n), F.push(Y);
2158
- }
2159
- return l.count = y, F;
2160
- }
2161
- return f = r(l), h = c(f, l), g = m(f, h, l), u([f, h, g], l);
2162
- };
2163
- function r(l) {
2164
- if (o.length > 0) {
2165
- var f = Rt(l.hue), h = j(f), g = (f[1] - f[0]) / o.length, y = parseInt((h - f[0]) / g);
2166
- o[y] === !0 ? y = (y + 2) % o.length : o[y] = !0;
2167
- var F = (f[0] + y * g) % 359, B = (f[0] + (y + 1) * g) % 359;
2168
- return f = [F, B], h = j(f), h < 0 && (h = 360 + h), h;
2169
- } else {
2170
- var f = S(l.hue);
2171
- return h = j(f), h < 0 && (h = 360 + h), h;
2172
- }
2173
- }
2174
- function c(l, f) {
2175
- if (f.hue === "monochrome")
2176
- return 0;
2177
- if (f.luminosity === "random")
2178
- return j([0, 100]);
2179
- var h = D(l), g = h[0], y = h[1];
2180
- switch (f.luminosity) {
2181
- case "bright":
2182
- g = 55;
2183
- break;
2184
- case "dark":
2185
- g = y - 10;
2186
- break;
2187
- case "light":
2188
- y = 55;
2189
- break;
2190
- }
2191
- return j([g, y]);
2192
- }
2193
- function m(l, f, h) {
2194
- var g = E(l, f), y = 100;
2195
- switch (h.luminosity) {
2196
- case "dark":
2197
- y = g + 20;
2198
- break;
2199
- case "light":
2200
- g = (y + g) / 2;
2201
- break;
2202
- case "random":
2203
- g = 0, y = 100;
2204
- break;
2205
- }
2206
- return j([g, y]);
2207
- }
2208
- function u(l, f) {
2209
- switch (f.format) {
2210
- case "hsvArray":
2211
- return l;
2212
- case "hslArray":
2213
- return Pt(l);
2214
- case "hsl":
2215
- var h = Pt(l);
2216
- return "hsl(" + h[0] + ", " + h[1] + "%, " + h[2] + "%)";
2217
- case "hsla":
2218
- var g = Pt(l), B = f.alpha || Math.random();
2219
- return "hsla(" + g[0] + ", " + g[1] + "%, " + g[2] + "%, " + B + ")";
2220
- case "rgbArray":
2221
- return L(l);
2222
- case "rgb":
2223
- var y = L(l);
2224
- return "rgb(" + y.join(", ") + ")";
2225
- case "rgba":
2226
- var F = L(l), B = f.alpha || Math.random();
2227
- return "rgba(" + F.join(", ") + ", " + B + ")";
2228
- default:
2229
- return k(l);
2230
- }
2231
- }
2232
- function E(l, f) {
2233
- for (var h = G(l).lowerBounds, g = 0; g < h.length - 1; g++) {
2234
- var y = h[g][0], F = h[g][1], B = h[g + 1][0], Y = h[g + 1][1];
2235
- if (f >= y && f <= B) {
2236
- var U = (Y - F) / (B - y), P = F - U * y;
2237
- return U * f + P;
2238
- }
2239
- }
2240
- return 0;
2241
- }
2242
- function S(l) {
2243
- if (typeof parseInt(l) == "number") {
2244
- var f = parseInt(l);
2245
- if (f < 360 && f > 0)
2246
- return [f, f];
2247
- }
2248
- if (typeof l == "string") {
2249
- if (i[l]) {
2250
- var h = i[l];
2251
- if (h.hueRange)
2252
- return h.hueRange;
2253
- } else if (l.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i)) {
2254
- var g = Qt(l)[0];
2255
- return [g, g];
2256
- }
2257
- }
2258
- return [0, 360];
2259
- }
2260
- function D(l) {
2261
- return G(l).saturationRange;
2262
- }
2263
- function G(l) {
2264
- l >= 334 && l <= 360 && (l -= 360);
2265
- for (var f in i) {
2266
- var h = i[f];
2267
- if (h.hueRange && l >= h.hueRange[0] && l <= h.hueRange[1])
2268
- return i[f];
2269
- }
2270
- return "Color not found";
2271
- }
2272
- function j(l) {
2273
- if (n === null) {
2274
- var f = 0.618033988749895, h = Math.random();
2275
- return h += f, h %= 1, Math.floor(l[0] + h * (l[1] + 1 - l[0]));
2276
- } else {
2277
- var g = l[1] || 1, y = l[0] || 0;
2278
- n = (n * 9301 + 49297) % 233280;
2279
- var F = n / 233280;
2280
- return Math.floor(y + F * (g - y));
2281
- }
2282
- }
2283
- function k(l) {
2284
- var f = L(l);
2285
- function h(y) {
2286
- var F = y.toString(16);
2287
- return F.length == 1 ? "0" + F : F;
2288
- }
2289
- var g = "#" + h(f[0]) + h(f[1]) + h(f[2]);
2290
- return g;
2291
- }
2292
- function I(l, f, h) {
2293
- var g = h[0][0], y = h[h.length - 1][0], F = h[h.length - 1][1], B = h[0][1];
2294
- i[l] = {
2295
- hueRange: f,
2296
- lowerBounds: h,
2297
- saturationRange: [g, y],
2298
- brightnessRange: [F, B]
2299
- };
2300
- }
2301
- function M() {
2302
- I(
2303
- "monochrome",
2304
- null,
2305
- [[0, 0], [100, 0]]
2306
- ), I(
2307
- "red",
2308
- [-26, 18],
2309
- [[20, 100], [30, 92], [40, 89], [50, 85], [60, 78], [70, 70], [80, 60], [90, 55], [100, 50]]
2310
- ), I(
2311
- "orange",
2312
- [18, 46],
2313
- [[20, 100], [30, 93], [40, 88], [50, 86], [60, 85], [70, 70], [100, 70]]
2314
- ), I(
2315
- "yellow",
2316
- [46, 62],
2317
- [[25, 100], [40, 94], [50, 89], [60, 86], [70, 84], [80, 82], [90, 80], [100, 75]]
2318
- ), I(
2319
- "green",
2320
- [62, 178],
2321
- [[30, 100], [40, 90], [50, 85], [60, 81], [70, 74], [80, 64], [90, 50], [100, 40]]
2322
- ), I(
2323
- "blue",
2324
- [178, 257],
2325
- [[20, 100], [30, 86], [40, 80], [50, 74], [60, 60], [70, 52], [80, 44], [90, 39], [100, 35]]
2326
- ), I(
2327
- "purple",
2328
- [257, 282],
2329
- [[20, 100], [30, 87], [40, 79], [50, 70], [60, 65], [70, 59], [80, 52], [90, 45], [100, 42]]
2330
- ), I(
2331
- "pink",
2332
- [282, 334],
2333
- [[20, 100], [30, 90], [40, 86], [60, 84], [80, 80], [90, 75], [100, 73]]
2334
- );
2335
- }
2336
- function L(l) {
2337
- var f = l[0];
2338
- f === 0 && (f = 1), f === 360 && (f = 359), f = f / 360;
2339
- var h = l[1] / 100, g = l[2] / 100, y = Math.floor(f * 6), F = f * 6 - y, B = g * (1 - h), Y = g * (1 - F * h), U = g * (1 - (1 - F) * h), P = 256, Z = 256, R = 256;
2340
- switch (y) {
2341
- case 0:
2342
- P = g, Z = U, R = B;
2343
- break;
2344
- case 1:
2345
- P = Y, Z = g, R = B;
2346
- break;
2347
- case 2:
2348
- P = B, Z = g, R = U;
2349
- break;
2350
- case 3:
2351
- P = B, Z = Y, R = g;
2352
- break;
2353
- case 4:
2354
- P = U, Z = B, R = g;
2355
- break;
2356
- case 5:
2357
- P = g, Z = B, R = Y;
2358
- break;
2359
- }
2360
- var $t = [Math.floor(P * 255), Math.floor(Z * 255), Math.floor(R * 255)];
2361
- return $t;
2362
- }
2363
- function Qt(l) {
2364
- l = l.replace(/^#/, ""), l = l.length === 3 ? l.replace(/(.)/g, "$1$1") : l;
2365
- var f = parseInt(l.substr(0, 2), 16) / 255, h = parseInt(l.substr(2, 2), 16) / 255, g = parseInt(l.substr(4, 2), 16) / 255, y = Math.max(f, h, g), F = y - Math.min(f, h, g), B = y ? F / y : 0;
2366
- switch (y) {
2367
- case f:
2368
- return [60 * ((h - g) / F % 6) || 0, B, y];
2369
- case h:
2370
- return [60 * ((g - f) / F + 2) || 0, B, y];
2371
- case g:
2372
- return [60 * ((f - h) / F + 4) || 0, B, y];
2373
- }
2374
- }
2375
- function Pt(l) {
2376
- var f = l[0], h = l[1] / 100, g = l[2] / 100, y = (2 - h) * g;
2377
- return [
2378
- f,
2379
- Math.round(h * g / (y < 1 ? y : 2 - y) * 1e4) / 100,
2380
- y / 2 * 100
2381
- ];
2382
- }
2383
- function wt(l) {
2384
- for (var f = 0, h = 0; h !== l.length && !(f >= Number.MAX_SAFE_INTEGER); h++)
2385
- f += l.charCodeAt(h);
2386
- return f;
2387
- }
2388
- function Rt(l) {
2389
- if (isNaN(l)) {
2390
- if (typeof l == "string") {
2391
- if (i[l]) {
2392
- var h = i[l];
2393
- if (h.hueRange)
2394
- return h.hueRange;
2395
- } else if (l.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i)) {
2396
- var g = Qt(l)[0];
2397
- return G(g).hueRange;
2398
- }
2399
- }
2400
- } else {
2401
- var f = parseInt(l);
2402
- if (f < 360 && f > 0)
2403
- return G(l).hueRange;
2404
- }
2405
- return [0, 360];
2406
- }
2407
- return s;
2408
- });
2409
- })(Nt, Nt.exports)), Nt.exports;
2410
- }
2411
- var _o = vo();
2412
- const yo = /* @__PURE__ */ oi(_o), bo = 1500;
2413
- function Dn(t) {
2414
- const e = yo({
2415
- count: 60
2416
- }).filter((s) => n(s.substring(1)) < 200);
2417
- function n(s) {
2418
- var r = parseInt(s.substr(0, 2), 16), c = parseInt(s.substr(2, 2), 16), m = parseInt(s.substr(4, 2), 16), u = (r * 299 + c * 587 + m * 114) / 1e3;
2419
- return u;
2420
- }
2421
- let i = 0;
2422
- function o(s) {
2423
- const {
2424
- element: r
2425
- } = s;
2426
- if (r && r.type === "bpmn:MessageFlow")
2427
- return {
2428
- primary: "#999",
2429
- auxiliary: "#FFF"
2430
- };
2431
- if (s.parent)
2432
- return s.parent.colors;
2433
- const c = e[i++ % e.length];
2434
- return {
2435
- primary: c,
2436
- auxiliary: n(c) >= 128 ? "#111" : "#fff"
2437
- };
2438
- }
2439
- t.on(vt, bo, (s) => {
2440
- const {
2441
- scope: r
2442
- } = s;
2443
- r.colors = o(r);
2444
- });
2445
- }
2446
- Dn.$inject = [
2447
- "eventBus"
2448
- ];
2449
- const Eo = {
2450
- __init__: [
2451
- "coloredScopes"
2452
- ],
2453
- coloredScopes: ["type", Dn]
2454
- };
2455
- function Ne(t) {
2456
- this._exclusiveGatewaySettings = t;
2457
- }
2458
- Ne.prototype.createContextPads = function(t) {
2459
- if (t.outgoing.filter(function(o) {
2460
- return p(o, "bpmn:SequenceFlow");
2461
- }).length < 2)
2462
- return;
2463
- const n = `
2464
- <button class="bts-context-pad" title="Set Sequence Flow">
2465
- ${mn()}
2466
- </button>
2467
- `;
2468
- return [
2469
- {
2470
- action: () => {
2471
- this._exclusiveGatewaySettings.setSequenceFlow(t);
2472
- },
2473
- element: t,
2474
- html: n
2475
- }
2476
- ];
2477
- };
2478
- Ne.$inject = [
2479
- "exclusiveGatewaySettings"
2480
- ];
2481
- function De(t) {
2482
- this._inclusiveGatewaySettings = t;
2483
- }
2484
- De.prototype.createContextPads = function(t) {
2485
- const e = t.outgoing.filter(rt);
2486
- if (e.length < 2)
2487
- return;
2488
- const n = e.filter((o) => {
2489
- const s = H(o);
2490
- return H(t).default !== s;
2491
- }), i = `
2492
- <button class="bts-context-pad" title="Set Sequence Flow">
2493
- ${mn()}
2494
- </button>
2495
- `;
2496
- return n.map((o) => ({
2497
- action: () => {
2498
- this._inclusiveGatewaySettings.toggleSequenceFlow(t, o);
2499
- },
2500
- element: o,
2501
- html: i
2502
- }));
2503
- };
2504
- De.$inject = [
2505
- "inclusiveGatewaySettings"
2506
- ];
2507
- function Et(t) {
2508
- this._simulator = t;
2509
- }
2510
- Et.prototype.createContextPads = function(t) {
2511
- return p(t, "bpmn:ReceiveTask") || p(t, "bpmn:SubProcess") && H(t).triggeredByEvent ? [] : [
2512
- this.createPauseContextPad(t)
2513
- ];
2514
- };
2515
- Et.prototype.createPauseContextPad = function(t) {
2516
- const e = () => this._findSubscriptions({
2517
- element: t
2518
- }), n = this._isPaused(t), i = `
2519
- <button class="bts-context-pad ${n ? "" : "show-hover"}" title="${n ? "Remove" : "Add"} pause point">
2520
- ${(n ? wi : Ee)("show-hover")}
2521
- ${Ee("hide-hover")}
2522
- </button>
2523
- `;
2524
- return {
2525
- action: () => {
2526
- this._togglePaused(t);
2527
- },
2528
- element: t,
2529
- hideContexts: e,
2530
- html: i
2531
- };
2532
- };
2533
- Et.prototype._isPaused = function(t) {
2534
- const {
2535
- wait: e
2536
- } = this._simulator.getConfig(t);
2537
- return e;
2538
- };
2539
- Et.prototype._togglePaused = function(t) {
2540
- const e = !this._isPaused(t);
2541
- this._simulator.waitAtElement(t, e);
2542
- };
2543
- Et.prototype._findSubscriptions = function(t) {
2544
- return this._simulator.findSubscriptions(t);
2545
- };
2546
- Et.$inject = [
2547
- "simulator"
2548
- ];
2549
- function gt(t) {
2550
- this._simulator = t;
2551
- }
2552
- gt.$inject = [
2553
- "simulator"
2554
- ];
2555
- gt.prototype.createContextPads = function(t) {
2556
- return [
2557
- this.createTriggerContextPad(t)
2558
- ];
2559
- };
2560
- gt.prototype.createTriggerContextPad = function(t) {
2561
- const e = () => this._findSubscriptions({
2562
- element: t
2563
- }).slice().sort((r, c) => r.event.type === "none" ? 1 : -1), n = `
2564
- <button class="bts-context-pad" title="Trigger Event">
2565
- ${vn()}
2566
- </button>
2567
- `;
2568
- return {
2569
- action: (o) => {
2570
- const {
2571
- event: s,
2572
- scope: r
2573
- } = o[0];
2574
- return this._simulator.trigger({
2575
- event: s,
2576
- scope: r
2577
- });
2578
- },
2579
- element: t,
2580
- html: n,
2581
- contexts: e
2582
- };
2583
- };
2584
- gt.prototype._findSubscriptions = function(t) {
2585
- return this._simulator.findSubscriptions(t);
2586
- };
2587
- const te = 500, So = -15, wo = -15;
2588
- function X(t, e, n, i, o, s) {
2589
- this._elementRegistry = e, this._overlays = n, this._injector = i, this._canvas = o, this._scopeFilter = s, this._active = !1, this._overlayCache = /* @__PURE__ */ new Map(), this._handlerIdx = 0, this._handlers = [], this.registerHandler("bpmn:ExclusiveGateway", Ne), this.registerHandler("bpmn:InclusiveGateway", De), this.registerHandler("bpmn:Activity", Et), this.registerHandler("bpmn:Event", gt), this.registerHandler("bpmn:Gateway", gt), this.registerHandler("bpmn:Activity", gt), t.on(N, te, (r) => {
2590
- this._active = r.active, this._active ? this.openContextPads() : this.closeContextPads();
2591
- }), t.on(tt, te, () => {
2592
- this.closeContextPads(), this.openContextPads();
2593
- }), t.on("root.set", te, () => {
2594
- this._active ? this.openContextPads() : this.closeContextPads();
2595
- }), t.on(Bt, (r) => {
2596
- const c = Tt(
2597
- ".djs-overlay-bts-context-menu [data-scope-ids]",
2598
- n._overlayRoot
2599
- );
2600
- for (const u of c) {
2601
- const S = u.dataset.scopeIds.split(",").some((D) => s.isShown(D));
2602
- T(u).toggle("hidden", !S);
2603
- }
2604
- const m = Tt(
2605
- ".djs-overlay-bts-context-menu [data-hide-scope-ids]",
2606
- n._overlayRoot
2607
- );
2608
- for (const u of m) {
2609
- const S = u.dataset.hideScopeIds.split(",").some((D) => s.isShown(D));
2610
- T(u).toggle("hidden", S);
2611
- }
2612
- }), t.on(pn, te, (r) => {
2613
- const {
2614
- element: c
2615
- } = r;
2616
- this.updateElementContextPads(c);
2617
- });
2618
- }
2619
- X.prototype.registerHandler = function(t, e) {
2620
- const n = this._injector.instantiate(e);
2621
- n.hash = String(this._handlerIdx++), this._handlers.push({ handler: n, type: t });
2622
- };
2623
- X.prototype.getHandlers = function(t) {
2624
- return this._handlers.filter(
2625
- ({ type: e }) => p(t, e)
2626
- ).map(
2627
- ({ handler: e }) => e
2628
- );
2629
- };
2630
- X.prototype.openContextPads = function(t) {
2631
- t || (t = this._canvas.getRootElement()), this._elementRegistry.forEach((e) => {
2632
- Co(t, e) && !ei(e) && this.updateElementContextPads(e);
2633
- });
2634
- };
2635
- X.prototype._getOverlays = function(t) {
2636
- return this._overlayCache.get(t) || [];
2637
- };
2638
- X.prototype._addOverlay = function(t, e) {
2639
- const {
2640
- handlerHash: n
2641
- } = e;
2642
- if (!n)
2643
- throw new Error("<handlerHash> required");
2644
- const i = this._overlays.add(t, "bts-context-menu", {
2645
- ...e,
2646
- position: {
2647
- top: So,
2648
- left: wo
2649
- },
2650
- show: {
2651
- minZoom: 0.5
2652
- }
2653
- }), o = this._overlays.get(i), s = this._overlayCache;
2654
- s.has(n) || s.set(n, []), s.get(n).push(o);
2655
- };
2656
- X.prototype._removeOverlay = function(t) {
2657
- const {
2658
- id: e,
2659
- handlerHash: n
2660
- } = t;
2661
- this._overlays.remove(e);
2662
- const i = this._overlayCache.get(n) || [], o = i.indexOf(t);
2663
- o !== -1 && i.splice(o, 1);
2664
- };
2665
- X.prototype.updateElementContextPads = function(t) {
2666
- for (const e of this.getHandlers(t))
2667
- this._updateElementContextPads(t, e);
2668
- };
2669
- X.prototype._updateElementContextPads = function(t, e) {
2670
- const n = this._canvas, i = (e.createContextPads(t) || []).filter((c) => c), o = `${t.id}------${e.hash}`, s = this._getOverlays(o), r = [];
2671
- for (const c of i) {
2672
- const {
2673
- element: m,
2674
- contexts: u,
2675
- hideContexts: E,
2676
- action: S,
2677
- html: D
2678
- } = c, G = `${c.element.id}-------${D}`;
2679
- let j = s.find(
2680
- (I) => I.hash === G
2681
- );
2682
- const k = j && j.html || O(D);
2683
- if (u) {
2684
- const I = u();
2685
- k.dataset.scopeIds = I.map((L) => L.scope.id).join(",");
2686
- const M = I.filter((L) => this._scopeFilter.isShown(L.scope));
2687
- T(k).toggle("hidden", M.length === 0);
2688
- }
2689
- if (E) {
2690
- const I = E();
2691
- k.dataset.hideScopeIds = I.map((L) => L.scope.id).join(",");
2692
- const M = I.filter((L) => this._scopeFilter.isShown(L.scope));
2693
- T(k).toggle("hidden", M.length > 0);
2694
- }
2695
- if (j) {
2696
- r.push(j);
2697
- continue;
2698
- }
2699
- if (S) {
2700
- const I = () => {
2701
- const M = u ? u().filter((L) => this._scopeFilter.isShown(L.scope)) : null;
2702
- S(M);
2703
- };
2704
- W.bind(k, "click", (M) => {
2705
- M.preventDefault(), I(), "focus" in n && n.focus();
2706
- }), W.bind(k, "keydown", (M) => {
2707
- To(M) && (M.preventDefault(), I());
2708
- });
2709
- }
2710
- this._addOverlay(m, {
2711
- hash: G,
2712
- handlerHash: o,
2713
- html: k
2714
- });
2715
- }
2716
- for (const c of s)
2717
- r.includes(c) || this._removeOverlay(c);
2718
- };
2719
- X.prototype.closeContextPads = function() {
2720
- for (const t of this._overlayCache.values())
2721
- for (const e of t)
2722
- this._closeOverlay(e);
2723
- this._overlayCache.clear();
2724
- };
2725
- X.prototype._closeOverlay = function(t) {
2726
- this._overlays.remove(t.id);
2727
- };
2728
- X.$inject = [
2729
- "eventBus",
2730
- "elementRegistry",
2731
- "overlays",
2732
- "injector",
2733
- "canvas",
2734
- "scopeFilter"
2735
- ];
2736
- function Co(t, e) {
2737
- do {
2738
- if (t === e)
2739
- return !0;
2740
- e = e.parent;
2741
- } while (e);
2742
- return !1;
2743
- }
2744
- function To(t) {
2745
- return ["Enter", " ", "Spacebar"].includes(t.key);
2746
- }
2747
- const Io = {
2748
- __depends__: [
2749
- At
2750
- ],
2751
- __init__: [
2752
- "contextPads"
2753
- ],
2754
- contextPads: ["type", X]
2755
- };
2756
- function Gn(t, e, n) {
2757
- t.on(Gt, (i) => {
2758
- const {
2759
- scope: o
2760
- } = i, {
2761
- destroyInitiator: s,
2762
- element: r
2763
- } = o;
2764
- !o.completed || !s || ![
2765
- "bpmn:Process",
2766
- "bpmn:Participant"
2767
- ].includes(r.type) || n.addElementNotification(s.element, {
2768
- type: "success",
2769
- icon: be(),
2770
- text: "Finished",
2771
- scope: o
2772
- });
2773
- });
2774
- }
2775
- Gn.$inject = [
2776
- "eventBus",
2777
- "simulator",
2778
- "elementNotifications"
2779
- ];
2780
- const Fo = -15, Bo = 15;
2781
- function Jt(t, e) {
2782
- this._overlays = t, e.on([
2783
- tt,
2784
- vt,
2785
- N
2786
- ], () => {
2787
- this.clear();
2788
- });
2789
- }
2790
- Jt.prototype.addElementNotification = function(t, e) {
2791
- const n = {
2792
- top: Fo,
2793
- right: Bo
2794
- }, {
2795
- type: i,
2796
- icon: o,
2797
- text: s,
2798
- scope: r = {}
2799
- } = e, c = r.colors, m = c ? `style="color: ${c.auxiliary}; background: ${c.primary}"` : "", u = O(`
2800
- <div class="bts-element-notification ${i || ""}" ${m}>
2801
- ${o || ""}
2802
- <span class="bts-text">${s}</span>
2803
- </div>
2804
- `);
2805
- this._overlays.add(t, "bts-element-notification", {
2806
- position: n,
2807
- html: u,
2808
- show: {
2809
- minZoom: 0.5
2810
- }
2811
- });
2812
- };
2813
- Jt.prototype.clear = function() {
2814
- this._overlays.remove({ type: "bts-element-notification" });
2815
- };
2816
- Jt.prototype.removeElementNotification = function(t) {
2817
- this._overlays.remove({ element: t });
2818
- };
2819
- Jt.$inject = ["overlays", "eventBus"];
2820
- const jn = {
2821
- elementNotifications: ["type", Jt]
2822
- }, xo = 2e3, ko = gn();
2823
- function Xt(t, e, n) {
2824
- this._eventBus = t, this._canvas = e, this._scopeFilter = n, this._init(), t.on([
2825
- N,
2826
- tt
2827
- ], (i) => {
2828
- this.clear();
2829
- });
2830
- }
2831
- Xt.prototype._init = function() {
2832
- this.container = O('<div class="bts-notifications"></div>'), this._canvas.getContainer().appendChild(this.container);
2833
- };
2834
- Xt.prototype.showNotification = function(t) {
2835
- const {
2836
- text: e,
2837
- type: n = "info",
2838
- icon: i = ko,
2839
- scope: o,
2840
- ttl: s = xo
2841
- } = t;
2842
- if (o && !this._scopeFilter.isShown(o))
2843
- return;
2844
- const r = i.startsWith("<") ? i : `<i class="${i}"></i>`, c = o && o.colors, m = c ? `style="color: ${c.auxiliary}; background: ${c.primary}"` : "", u = O(`
2845
- <div class="bts-notification ${n}">
2846
- <span class="bts-icon">${r}</span>
2847
- <span class="bts-text" title="${e}">${e}</span>
2848
- ${o ? `<span class="bts-scope" ${m}>${o.id}</span>` : ""}
2849
- </div>
2850
- `);
2851
- for (this.container.appendChild(u); this.container.children.length > 5; )
2852
- this.container.children[0].remove();
2853
- setTimeout(function() {
2854
- u.remove();
2855
- }, s);
2856
- };
2857
- Xt.prototype.clear = function() {
2858
- for (; this.container.children.length; )
2859
- this.container.children[0].remove();
2860
- };
2861
- Xt.$inject = [
2862
- "eventBus",
2863
- "canvas",
2864
- "scopeFilter"
2865
- ];
2866
- const Kt = {
2867
- __depends__: [
2868
- At
2869
- ],
2870
- notifications: ["type", Xt]
2871
- }, Ao = {
2872
- __depends__: [
2873
- jn,
2874
- Kt
2875
- ],
2876
- __init__: [
2877
- "simulationState"
2878
- ],
2879
- simulationState: ["type", Gn]
2880
- }, Mo = "--token-simulation-silver-base-97", Lo = "--token-simulation-green-base-44", Hn = "show-scopes", Po = 3e3;
2881
- function K(t, e, n, i, o) {
2882
- this._eventBus = t, this._canvas = e, this._scopeFilter = n, this._elementColors = i, this._simulationStyles = o, this._highlight = null, this._init(), t.on(N, (s) => {
2883
- s.active ? T(this._container).remove("hidden") : (T(this._container).add("hidden"), ni(this._container), this.unhighlightScope());
2884
- }), t.on(Bt, (s) => {
2885
- const r = this.getScopeElements();
2886
- for (const c of r) {
2887
- const m = c.dataset.scopeId;
2888
- T(c).toggle("inactive", !this._scopeFilter.isShown(m)), T(c).toggle("focussed", this._scopeFilter.isFocused(m)), c.setAttribute("aria-pressed", String(this._scopeFilter.isFocused(m)));
2889
- }
2890
- }), t.on(vt, (s) => {
2891
- this.addScope(s.scope);
2892
- }), t.on(Gt, (s) => {
2893
- this.removeScope(s.scope);
2894
- }), t.on(ri, (s) => {
2895
- this.updateScope(s.scope);
2896
- }), t.on(tt, () => {
2897
- this.removeAllInstances();
2898
- });
2899
- }
2900
- K.prototype._init = function() {
2901
- this._container = O('<div class="bts-scopes hidden"></div>'), this._canvas.getContainer().appendChild(this._container);
2902
- };
2903
- K.prototype.addScope = function(t) {
2904
- const e = [
2905
- "bpmn:Process",
2906
- "bpmn:SubProcess",
2907
- "bpmn:Participant"
2908
- ], {
2909
- element: n
2910
- } = t;
2911
- if (!It(n, e))
2912
- return;
2913
- const i = t.colors, o = i ? `style="color: ${i.auxiliary}; background: ${i.primary}; --scope-color: ${i.primary}"` : "", s = O(`
2914
- <button data-scope-id="${t.id}" class="bts-scope"
2915
- aria-pressed="false"
2916
- title="Focus process instance ${t.id}" ${o}>
2917
- ${t.getTokens()}
2918
- </button>
2919
- `);
2920
- W.bind(s, "click", () => {
2921
- this._scopeFilter.toggle(t);
2922
- }), W.bind(s, "mouseenter", () => {
2923
- this.highlightScope(n);
2924
- }), W.bind(s, "mouseleave", () => {
2925
- this.unhighlightScope();
2926
- }), this._scopeFilter.isShown(t) || T(s).add("inactive"), T(s).toggle("focussed", this._scopeFilter.isFocused(t)), s.setAttribute("aria-pressed", String(this._scopeFilter.isFocused(t))), this._container.appendChild(s);
2927
- };
2928
- K.prototype.getScopeElements = function() {
2929
- return Tt("[data-scope-id]", this._container);
2930
- };
2931
- K.prototype.getScopeElement = function(t) {
2932
- return mt(`[data-scope-id="${t.id}"]`, this._container);
2933
- };
2934
- K.prototype.updateScope = function(t) {
2935
- const e = this.getScopeElement(t);
2936
- e && (e.textContent = t.getTokens());
2937
- };
2938
- K.prototype.removeScope = function(t) {
2939
- const e = this.getScopeElement(t);
2940
- e && e.remove();
2941
- };
2942
- K.prototype.removeAllInstances = function() {
2943
- this._container.innerHTML = "";
2944
- };
2945
- K.prototype.highlightScope = function(t) {
2946
- this.unhighlightScope(), this._highlight = t, this._elementColors.add(t, Hn, this._getHighlightColors(), Po), t.parent || T(this._canvas.getContainer()).add("highlight");
2947
- };
2948
- K.prototype.unhighlightScope = function() {
2949
- if (!this._highlight)
2950
- return;
2951
- const t = this._highlight;
2952
- this._elementColors.remove(t, Hn), t.parent || T(this._canvas.getContainer()).remove("highlight"), this._highlight = null;
2953
- };
2954
- K.prototype._getHighlightColors = function() {
2955
- return {
2956
- fill: this._simulationStyles.get(Mo),
2957
- stroke: this._simulationStyles.get(Lo)
2958
- };
2959
- };
2960
- K.$inject = [
2961
- "eventBus",
2962
- "canvas",
2963
- "scopeFilter",
2964
- "elementColors",
2965
- "simulationStyles"
2966
- ];
2967
- function fe() {
2968
- this._cache = {};
2969
- }
2970
- fe.$inject = [];
2971
- fe.prototype.get = function(t) {
2972
- const e = this._cache[t];
2973
- return e || (this._computedStyle || (this._computedStyle = this._getComputedStyle()), this._cache[t] = this._computedStyle.getPropertyValue(t).trim());
2974
- };
2975
- fe.prototype._getComputedStyle = function() {
2976
- const t = typeof getComputedStyle == "function" ? getComputedStyle : Ro, e = typeof document < "u" ? document.documentElement : {};
2977
- return t(e);
2978
- };
2979
- function Ro() {
2980
- return {
2981
- getPropertyValue() {
2982
- return "";
2983
- }
2984
- };
2985
- }
2986
- const me = {
2987
- simulationStyles: ["type", fe]
2988
- }, $o = {
2989
- __depends__: [
2990
- At,
2991
- me
2992
- ],
2993
- __init__: [
2994
- "showScopes"
2995
- ],
2996
- showScopes: ["type", K]
2997
- }, Oo = gn();
2998
- function _e(t) {
2999
- const e = t && t.businessObject.name;
3000
- return e && ii(e);
3001
- }
3002
- function ye(t, e) {
3003
- const n = Te(t);
3004
- return n === "none" ? "bpmn-icon-intermediate-event-none" : `bpmn-icon-intermediate-event-${e}-${n}`;
3005
- }
3006
- function Te(t) {
3007
- const e = H(t);
3008
- if (e.get("eventDefinitions").length === 0)
3009
- return "none";
3010
- const n = e.eventDefinitions[0];
3011
- return p(n, "bpmn:MessageEventDefinition") ? "message" : p(n, "bpmn:TimerEventDefinition") ? "timer" : p(n, "bpmn:SignalEventDefinition") ? "signal" : p(n, "bpmn:ErrorEventDefinition") ? "error" : p(n, "bpmn:EscalationEventDefinition") ? "escalation" : p(n, "bpmn:CompensateEventDefinition") ? "compensation" : p(n, "bpmn:ConditionalEventDefinition") ? "condition" : p(n, "bpmn:LinkEventDefinition") ? "link" : p(n, "bpmn:CancelEventDefinition") ? "cancel" : p(n, "bpmn:TerminateEventDefinition") ? "terminate" : "none";
3012
- }
3013
- function St(t, e, n, i, o, s) {
3014
- this._notifications = e, this._tokenSimulationPalette = n, this._canvas = i, this._scopeFilter = o, this._init(), t.on(Bt, (r) => {
3015
- const c = Tt(".bts-entry[data-scope-id]", this._container);
3016
- for (const m of c) {
3017
- const u = m.dataset.scopeId;
3018
- T(m).toggle("inactive", !this._scopeFilter.isShown(u));
3019
- }
3020
- }), t.on(Gt, (r) => {
3021
- const {
3022
- scope: c
3023
- } = r, {
3024
- element: m
3025
- } = c, u = c.completed;
3026
- if (!It(m, [
3027
- "bpmn:Process",
3028
- "bpmn:Participant",
3029
- "bpmn:SubProcess"
3030
- ]))
3031
- return;
3032
- const D = `${p(m, "bpmn:SubProcess") ? _e(m) || "SubProcess" : "Process"} ${u ? "finished" : "canceled"}`;
3033
- this.log({
3034
- text: D,
3035
- icon: u ? be() : Ii(),
3036
- scope: c
3037
- });
3038
- }), t.on(vt, (r) => {
3039
- const {
3040
- scope: c
3041
- } = r, {
3042
- element: m
3043
- } = c;
3044
- if (!It(m, [
3045
- "bpmn:Process",
3046
- "bpmn:Participant",
3047
- "bpmn:SubProcess"
3048
- ]))
3049
- return;
3050
- const S = `${p(m, "bpmn:SubProcess") ? _e(m) || "SubProcess" : "Process"} started`;
3051
- this.log({
3052
- text: S,
3053
- icon: be(),
3054
- scope: c
3055
- });
3056
- }), t.on(fn, (r) => {
3057
- const {
3058
- action: c,
3059
- scope: m,
3060
- element: u
3061
- } = r;
3062
- if (c !== "exit")
3063
- return;
3064
- const E = m.parent, S = _e(u);
3065
- if (p(u, "bpmn:ServiceTask"))
3066
- return this.log({
3067
- text: S || "Service Task",
3068
- icon: "bpmn-icon-service",
3069
- scope: E
3070
- });
3071
- if (p(u, "bpmn:UserTask"))
3072
- return this.log({
3073
- text: S || "User Task",
3074
- icon: "bpmn-icon-user",
3075
- scope: E
3076
- });
3077
- if (p(u, "bpmn:CallActivity"))
3078
- return this.log({
3079
- text: S || "Call Activity",
3080
- icon: "bpmn-icon-call-activity",
3081
- scope: E
3082
- });
3083
- if (p(u, "bpmn:ScriptTask"))
3084
- return this.log({
3085
- text: S || "Script Task",
3086
- icon: "bpmn-icon-script",
3087
- scope: E
3088
- });
3089
- if (p(u, "bpmn:BusinessRuleTask"))
3090
- return this.log({
3091
- text: S || "Business Rule Task",
3092
- icon: "bpmn-icon-business-rule",
3093
- scope: E
3094
- });
3095
- if (p(u, "bpmn:ManualTask"))
3096
- return this.log({
3097
- text: S || "Manual Task",
3098
- icon: "bpmn-icon-manual-task",
3099
- scope: E
3100
- });
3101
- if (p(u, "bpmn:ReceiveTask"))
3102
- return this.log({
3103
- text: S || "Receive Task",
3104
- icon: "bpmn-icon-receive",
3105
- scope: E
3106
- });
3107
- if (p(u, "bpmn:SendTask"))
3108
- return this.log({
3109
- text: S || "Send Task",
3110
- icon: "bpmn-icon-send",
3111
- scope: E
3112
- });
3113
- if (p(u, "bpmn:Task"))
3114
- return this.log({
3115
- text: S || "Task",
3116
- icon: "bpmn-icon-task",
3117
- scope: E
3118
- });
3119
- if (p(u, "bpmn:ExclusiveGateway"))
3120
- return this.log({
3121
- text: S || "Exclusive Gateway",
3122
- icon: "bpmn-icon-gateway-xor",
3123
- scope: E
3124
- });
3125
- if (p(u, "bpmn:ParallelGateway"))
3126
- return this.log({
3127
- text: S || "Parallel Gateway",
3128
- icon: "bpmn-icon-gateway-parallel",
3129
- scope: E
3130
- });
3131
- if (p(u, "bpmn:InclusiveGateway"))
3132
- return this.log({
3133
- text: S || "Inclusive Gateway",
3134
- icon: "bpmn-icon-gateway-or",
3135
- scope: E
3136
- });
3137
- if (p(u, "bpmn:StartEvent"))
3138
- return this.log({
3139
- text: S || "Start Event",
3140
- icon: `bpmn-icon-start-event-${Te(u)}`,
3141
- scope: E
3142
- });
3143
- if (p(u, "bpmn:IntermediateCatchEvent"))
3144
- return this.log({
3145
- text: S || "Intermediate Event",
3146
- icon: ye(u, "catch"),
3147
- scope: E
3148
- });
3149
- if (p(u, "bpmn:IntermediateThrowEvent"))
3150
- return this.log({
3151
- text: S || "Intermediate Event",
3152
- icon: ye(u, "throw"),
3153
- scope: E
3154
- });
3155
- if (p(u, "bpmn:BoundaryEvent"))
3156
- return this.log({
3157
- text: S || "Boundary Event",
3158
- icon: ye(u, "catch"),
3159
- scope: E
3160
- });
3161
- if (p(u, "bpmn:EndEvent"))
3162
- return this.log({
3163
- text: S || "End Event",
3164
- icon: `bpmn-icon-end-event-${Te(u)}`,
3165
- scope: E
3166
- });
3167
- }), t.on([
3168
- N,
3169
- tt
3170
- ], (r) => {
3171
- this.clear(), this.toggle(!1);
3172
- });
3173
- }
3174
- St.prototype._init = function() {
3175
- this._container = O(`
3176
- <div class="bts-log hidden djs-scrollable">
3177
- <div class="bts-header">
3178
- ${Je("bts-log-icon")}
3179
- Simulation Log
3180
- <button class="bts-close" aria-label="Close">
3181
- ${Fi()}
3182
- </button>
3183
- </div>
3184
- <div class="bts-content">
3185
- <p class="bts-entry placeholder">No Entries</p>
3186
- </div>
3187
- </div>
3188
- `), this._placeholder = mt(".bts-placeholder", this._container), this._content = mt(".bts-content", this._container), W.bind(this._content, "mousedown", (t) => {
3189
- t.stopPropagation();
3190
- }), this._close = mt(".bts-close", this._container), W.bind(this._close, "click", () => {
3191
- this.toggle(!1);
3192
- }), this._icon = mt(".bts-log-icon", this._container), W.bind(this._icon, "click", () => {
3193
- this.toggle();
3194
- }), this._canvas.getContainer().appendChild(this._container), this.paletteEntry = O(`
3195
- <button class="bts-entry" title="Toggle Simulation Log">
3196
- ${Je()}
3197
- </button>
3198
- `), W.bind(this.paletteEntry, "click", () => {
3199
- this.toggle();
3200
- }), this._tokenSimulationPalette.addEntry(this.paletteEntry, 3);
3201
- };
3202
- St.prototype.isShown = function() {
3203
- const t = this._container;
3204
- return !T(t).has("hidden");
3205
- };
3206
- St.prototype.toggle = function(t = !this.isShown()) {
3207
- const e = this._container;
3208
- t ? T(e).remove("hidden") : T(e).add("hidden");
3209
- };
3210
- St.prototype.log = function(t) {
3211
- const {
3212
- text: e,
3213
- type: n = "info",
3214
- icon: i = Oo,
3215
- scope: o
3216
- } = t, s = this._content;
3217
- T(this._placeholder).add("hidden"), this.isShown() || this._notifications.showNotification(t);
3218
- const r = i.startsWith("<") ? i : `<i class="${i}"></i>`, c = o && o.colors, m = c ? `style="background: ${c.primary}; color: ${c.auxiliary}"` : "", u = O(`
3219
- <p class="bts-entry ${n} ${o && this._scopeFilter.isShown(o) ? "" : "inactive"}" ${o ? `data-scope-id="${o.id}"` : ""}>
3220
- <span class="bts-icon">${r}</span>
3221
- <span class="bts-text" title="${e}">${e}</span>
3222
- ${o ? `<span class="bts-scope" data-scope-id="${o.id}" ${m}>${o.id}</span>` : ""}
3223
- </p>
3224
- `);
3225
- an.bind(u, ".bts-scope[data-scope-id]", "click", (S) => {
3226
- this._scopeFilter.toggle(o);
3227
- });
3228
- const E = Math.abs(s.clientHeight + s.scrollTop - s.scrollHeight) < 2;
3229
- s.appendChild(u), E && (s.scrollTop = s.scrollHeight);
3230
- };
3231
- St.prototype.clear = function() {
3232
- for (; this._content.firstChild; )
3233
- this._content.removeChild(this._content.firstChild);
3234
- this._placeholder = O('<p class="bts-entry placeholder">No Entries</p>'), this._content.appendChild(this._placeholder);
3235
- };
3236
- St.$inject = [
3237
- "eventBus",
3238
- "notifications",
3239
- "tokenSimulationPalette",
3240
- "canvas",
3241
- "scopeFilter",
3242
- "simulator"
3243
- ];
3244
- const No = {
3245
- __depends__: [
3246
- Kt,
3247
- At
3248
- ],
3249
- __init__: [
3250
- "log"
3251
- ],
3252
- log: ["type", St]
3253
- }, Do = [
3254
- "bpmn:ComplexGateway"
3255
- ];
3256
- function Go(t) {
3257
- return t.labelTarget;
3258
- }
3259
- function Mt(t, e, n, i, o) {
3260
- this._eventBus = t, this._elementRegistry = e, this._elementNotifications = o, this._notifications = i, this._canvasParent = n.getContainer().parentNode, t.on(N, (s) => {
3261
- s.active ? this.enable() : this.clear();
3262
- });
3263
- }
3264
- Mt.prototype.getUnsupportedElements = function() {
3265
- return this._unsupportedElements;
3266
- };
3267
- Mt.prototype.enable = function() {
3268
- const t = [];
3269
- this._elementRegistry.forEach((e) => {
3270
- Go(e) || It(e, Do) && (this.showWarning(e), t.push(e));
3271
- }), t.length && this._notifications.showNotification({
3272
- text: "Found unsupported elements",
3273
- icon: dn(),
3274
- type: "warning",
3275
- ttl: 5e3
3276
- }), this._unsupportedElements = t;
3277
- };
3278
- Mt.prototype.clear = function() {
3279
- T(this._canvasParent).remove("warning");
3280
- };
3281
- Mt.prototype.showWarning = function(t) {
3282
- this._elementNotifications.addElementNotification(t, {
3283
- type: "warning",
3284
- icon: dn(),
3285
- text: "Not supported"
3286
- });
3287
- };
3288
- Mt.$inject = [
3289
- "eventBus",
3290
- "elementRegistry",
3291
- "canvas",
3292
- "notifications",
3293
- "elementNotifications"
3294
- ];
3295
- const jo = {
3296
- __depends__: [
3297
- jn,
3298
- Kt
3299
- ],
3300
- __init__: ["elementSupport"],
3301
- elementSupport: ["type", Mt]
3302
- }, Vn = vn(), Ho = Ee(), en = 1500;
3303
- function lt(t, e, n, i) {
3304
- this._eventBus = t, this._tokenSimulationPalette = e, this._notifications = n, this.canvasParent = i.getContainer().parentNode, this.isActive = !1, this.isPaused = !0, this._init(), t.on(vt, en, (o) => {
3305
- this.activate(), this.unpause();
3306
- }), t.on([
3307
- tt,
3308
- N
3309
- ], () => {
3310
- this.deactivate(), this.pause();
3311
- }), t.on(fn, en, (o) => {
3312
- this.unpause();
3313
- });
3314
- }
3315
- lt.prototype._init = function() {
3316
- this.paletteEntry = O(`
3317
- <button class="bts-entry disabled" title="Play/Pause Simulation" disabled>
3318
- ${Vn}
3319
- </button>
3320
- `), W.bind(this.paletteEntry, "click", this.toggle.bind(this)), this._tokenSimulationPalette.addEntry(this.paletteEntry, 1);
3321
- };
3322
- lt.prototype.toggle = function() {
3323
- this.isPaused ? this.unpause() : this.pause();
3324
- };
3325
- lt.prototype.pause = function() {
3326
- this.isActive && (T(this.paletteEntry).remove("active"), T(this.canvasParent).add("paused"), this.paletteEntry.innerHTML = Vn, this._eventBus.fire(un), this._notifications.showNotification({
3327
- text: "Pause Simulation"
3328
- }), this.isPaused = !0);
3329
- };
3330
- lt.prototype.unpause = function() {
3331
- !this.isActive || !this.isPaused || (T(this.paletteEntry).add("active"), T(this.canvasParent).remove("paused"), this.paletteEntry.innerHTML = Ho, this._eventBus.fire(ln), this._notifications.showNotification({
3332
- text: "Play Simulation"
3333
- }), this.isPaused = !1);
3334
- };
3335
- lt.prototype.activate = function() {
3336
- this.isActive = !0, T(this.paletteEntry).remove("disabled"), this.paletteEntry.removeAttribute("disabled");
3337
- };
3338
- lt.prototype.deactivate = function() {
3339
- this.isActive = !1, T(this.paletteEntry).remove("active"), T(this.paletteEntry).add("disabled"), this.paletteEntry.setAttribute("disabled", "");
3340
- };
3341
- lt.$inject = [
3342
- "eventBus",
3343
- "tokenSimulationPalette",
3344
- "notifications",
3345
- "canvas"
3346
- ];
3347
- const Vo = {
3348
- __depends__: [
3349
- Kt
3350
- ],
3351
- __init__: [
3352
- "pauseSimulation"
3353
- ],
3354
- pauseSimulation: ["type", lt]
3355
- };
3356
- function de(t, e, n) {
3357
- this._eventBus = t, this._tokenSimulationPalette = e, this._notifications = n, this._init(), t.on(vt, () => {
3358
- T(this._paletteEntry).remove("disabled"), this._paletteEntry.removeAttribute("disabled");
3359
- }), t.on(N, (i) => {
3360
- (this._active = i.active) || this.resetSimulation();
3361
- });
3362
- }
3363
- de.prototype._init = function() {
3364
- this._paletteEntry = O(`
3365
- <button class="bts-entry disabled" title="Reset Simulation" disabled>
3366
- ${Ci()}
3367
- </button>
3368
- `), W.bind(this._paletteEntry, "click", () => {
3369
- this.resetSimulation(), this._notifications.showNotification({
3370
- text: "Reset Simulation",
3371
- type: "info"
3372
- });
3373
- }), this._tokenSimulationPalette.addEntry(this._paletteEntry, 2);
3374
- };
3375
- de.prototype.resetSimulation = function() {
3376
- T(this._paletteEntry).add("disabled"), this._paletteEntry.setAttribute("disabled", ""), this._eventBus.fire(tt);
3377
- };
3378
- de.$inject = [
3379
- "eventBus",
3380
- "tokenSimulationPalette",
3381
- "notifications"
3382
- ];
3383
- const zo = {
3384
- __depends__: [
3385
- Kt
3386
- ],
3387
- __init__: [
3388
- "resetSimulation"
3389
- ],
3390
- resetSimulation: ["type", de]
3391
- }, qo = 10, Yo = -15, Uo = 500, Wo = "--token-simulation-green-base-44", Jo = "--token-simulation-white";
3392
- function ut(t, e, n, i, o) {
3393
- this._overlays = e, this._scopeFilter = i, this._simulator = n, this._simulationStyles = o, this.overlayIds = {}, t.on(pn, Uo, (s) => {
3394
- const {
3395
- element: r
3396
- } = s;
3397
- this.removeTokenCounts(r), this.addTokenCounts(r);
3398
- }), t.on(Bt, (s) => {
3399
- const r = Tt(".bts-token-count[data-scope-id]", e._overlayRoot);
3400
- for (const c of r) {
3401
- const m = c.dataset.scopeId;
3402
- T(c).toggle("inactive", !this._scopeFilter.isShown(m));
3403
- }
3404
- });
3405
- }
3406
- ut.prototype.addTokenCounts = function(t) {
3407
- if (p(t, "bpmn:MessageFlow") || p(t, "bpmn:SequenceFlow"))
3408
- return;
3409
- const e = this._simulator.findScopes((n) => !n.destroyed && n.children.some((i) => !i.destroyed && i.element === t));
3410
- this.addTokenCount(t, e);
3411
- };
3412
- ut.prototype.addTokenCount = function(t, e) {
3413
- if (!e.length)
3414
- return;
3415
- const n = e.map((r) => this._getTokenHTML(t, r)).join(""), i = O(`
3416
- <div class="bts-token-count-parent">
3417
- ${n}
3418
- </div>
3419
- `), o = { bottom: qo, left: Yo }, s = this._overlays.add(t, "bts-token-count", {
3420
- position: o,
3421
- html: i,
3422
- show: {
3423
- minZoom: 0.5
3424
- }
3425
- });
3426
- this.overlayIds[t.id] = s;
3427
- };
3428
- ut.prototype.removeTokenCounts = function(t) {
3429
- this.removeTokenCount(t);
3430
- };
3431
- ut.prototype.removeTokenCount = function(t) {
3432
- const e = this.overlayIds[t.id];
3433
- e && (this._overlays.remove(e), delete this.overlayIds[t.id]);
3434
- };
3435
- ut.prototype._getTokenHTML = function(t, e) {
3436
- const n = e.colors || this._getDefaultColors();
3437
- return `
3438
- <div data-scope-id="${e.id}" class="bts-token-count waiting ${this._scopeFilter.isShown(e) ? "" : "inactive"}"
3439
- style="color: ${n.auxiliary}; background: ${n.primary}">
3440
- ${e.getTokensByElement(t)}
3441
- </div>
3442
- `;
3443
- };
3444
- ut.prototype._getDefaultColors = function() {
3445
- return {
3446
- primary: this._simulationStyles.get(Wo),
3447
- auxiliary: this._simuationStyles.get(Jo)
3448
- };
3449
- };
3450
- ut.$inject = [
3451
- "eventBus",
3452
- "overlays",
3453
- "simulator",
3454
- "scopeFilter",
3455
- "simulationStyles"
3456
- ];
3457
- const Xo = {
3458
- __depends__: [
3459
- At,
3460
- me
3461
- ],
3462
- __init__: [
3463
- "tokenCount"
3464
- ],
3465
- tokenCount: ["type", ut]
3466
- }, Ko = [
3467
- ["Slow", 0.5],
3468
- ["Normal", 1],
3469
- ["Fast", 2]
3470
- ];
3471
- function Zt(t, e, n) {
3472
- this._canvas = t, this._animation = e, this._eventBus = n, this._init(e.getAnimationSpeed()), n.on(N, (i) => {
3473
- i.active ? T(this._container).remove("hidden") : T(this._container).add("hidden");
3474
- }), n.on(hn, (i) => {
3475
- this.setActive(i.speed);
3476
- });
3477
- }
3478
- Zt.prototype.getToggleSpeed = function(t) {
3479
- return parseFloat(t.dataset.speed);
3480
- };
3481
- Zt.prototype._init = function(t) {
3482
- this._container = O(`
3483
- <div class="bts-set-animation-speed hidden">
3484
- ${Ti()}
3485
- <div class="bts-animation-speed-buttons">
3486
- ${Ko.map(([e, n], i) => `
3487
- <button title="Set animation speed = ${e}" data-speed="${n}" class="bts-animation-speed-button ${n === t ? "active" : ""}">
3488
- ${Array.from({ length: i + 1 }).map(
3489
- () => Si()
3490
- ).join("")}
3491
- </button>
3492
- `).join("")}
3493
- </div>
3494
- </div>
3495
- `), an.bind(this._container, "[data-speed]", "click", (e) => {
3496
- const n = e.delegateTarget, i = this.getToggleSpeed(n);
3497
- this._animation.setAnimationSpeed(i);
3498
- }), this._canvas.getContainer().appendChild(this._container);
3499
- };
3500
- Zt.prototype.setActive = function(t) {
3501
- Tt("[data-speed]", this._container).forEach((e) => {
3502
- const n = this.getToggleSpeed(e) === t;
3503
- T(e)[n ? "add" : "remove"]("active");
3504
- });
3505
- };
3506
- Zt.$inject = [
3507
- "canvas",
3508
- "animation",
3509
- "eventBus"
3510
- ];
3511
- const Zo = {
3512
- __init__: [
3513
- "setAnimationSpeed"
3514
- ],
3515
- setAnimationSpeed: ["type", Zt]
3516
- }, Qo = "--token-simulation-grey-darken-30", ts = "--token-simulation-grey-lighten-56";
3517
- function es(t, e) {
3518
- var n = t.outgoing.filter(Ge), i = n.indexOf(e || t.sequenceFlow);
3519
- return n[i + 1] ? n[i + 1] : n[0];
3520
- }
3521
- function Ge(t) {
3522
- return p(t, "bpmn:SequenceFlow");
3523
- }
3524
- const ns = "exclusive-gateway-settings", is = 2e3;
3525
- function Lt(t, e, n, i, o) {
3526
- this._elementRegistry = e, this._elementColors = n, this._simulator = i, this._simulationStyles = o, t.on(N, (s) => {
3527
- s.active ? this.setSequenceFlowsDefault() : this.resetSequenceFlows();
3528
- });
3529
- }
3530
- Lt.prototype.setSequenceFlowsDefault = function() {
3531
- const t = this._elementRegistry.filter((e) => p(e, "bpmn:ExclusiveGateway"));
3532
- for (const e of t)
3533
- this.setSequenceFlow(e);
3534
- };
3535
- Lt.prototype.resetSequenceFlows = function() {
3536
- this._elementRegistry.filter((e) => p(e, "bpmn:ExclusiveGateway")).forEach((e) => {
3537
- e.outgoing.filter(Ge).length && this.resetSequenceFlow(e);
3538
- });
3539
- };
3540
- Lt.prototype.resetSequenceFlow = function(t) {
3541
- this._simulator.setConfig(t, { activeOutgoing: void 0 });
3542
- };
3543
- Lt.prototype.setSequenceFlow = function(t) {
3544
- const e = t.outgoing.filter(Ge);
3545
- if (e.length < 2)
3546
- return;
3547
- const {
3548
- activeOutgoing: n
3549
- } = this._simulator.getConfig(t);
3550
- let i;
3551
- n ? i = es(t, n) : i = e[0], this._simulator.setConfig(t, { activeOutgoing: i }), t.outgoing.forEach((o) => {
3552
- const s = o === i ? Qo : ts, r = this._simulationStyles.get(s);
3553
- this._elementColors.add(o, ns, {
3554
- stroke: r
3555
- }, is);
3556
- });
3557
- };
3558
- Lt.$inject = [
3559
- "eventBus",
3560
- "elementRegistry",
3561
- "elementColors",
3562
- "simulator",
3563
- "simulationStyles"
3564
- ];
3565
- const nn = 5e4;
3566
- function Q(t, e, n) {
3567
- this._elementRegistry = t, this._eventBus = e, this._graphicsFactory = n, this._originalColors = {}, this._customColors = {}, e.on(N, nn, (i) => {
3568
- i.active ? this._saveOriginalColors() : (this._applyOriginalColors(), this._originalColors = {}, this._customColors = {});
3569
- }), e.on("saveXML.start", nn, () => {
3570
- this._applyOriginalColors(), e.once("saveXML.done", () => this._applyCustomColors());
3571
- });
3572
- }
3573
- Q.$inject = [
3574
- "elementRegistry",
3575
- "eventBus",
3576
- "graphicsFactory"
3577
- ];
3578
- Q.prototype.add = function(t, e, n, i = 1e3) {
3579
- let o = this._customColors[t.id];
3580
- o || (o = this._customColors[t.id] = {}), o[e] = {
3581
- ...n,
3582
- priority: i
3583
- }, this._applyHighestPriorityColor(t);
3584
- };
3585
- Q.prototype.remove = function(t, e) {
3586
- const n = this._customColors[t.id];
3587
- n && (delete n[e], Object.keys(n) || delete this._customColors[t.id]), this._applyHighestPriorityColor(t);
3588
- };
3589
- Q.prototype._get = function(t) {
3590
- const e = cn(t);
3591
- if (e) {
3592
- if (zn(t))
3593
- return {
3594
- stroke: e.label && e.label.get("color")
3595
- };
3596
- if (It(e, ["bpmndi:BPMNEdge", "bpmndi:BPMNShape"]))
3597
- return {
3598
- fill: e.get("background-color"),
3599
- stroke: e.get("border-color")
3600
- };
3601
- }
3602
- };
3603
- Q.prototype._set = function(t, e = {}) {
3604
- const {
3605
- fill: n,
3606
- stroke: i
3607
- } = e, o = cn(t);
3608
- o && (zn(t) ? o.label && o.label.set("color", i) : It(o, ["bpmndi:BPMNEdge", "bpmndi:BPMNShape"]) && (o.set("background-color", n), o.set("border-color", i)), this._forceRedraw(t));
3609
- };
3610
- Q.prototype._saveOriginalColors = function() {
3611
- this._originalColors = {}, this._elementRegistry.forEach((t) => {
3612
- this._originalColors[t.id] = this._get(t);
3613
- });
3614
- };
3615
- Q.prototype._applyOriginalColors = function() {
3616
- this._elementRegistry.forEach((t) => {
3617
- const e = this._originalColors[t.id];
3618
- e && this._set(t, e);
3619
- });
3620
- };
3621
- Q.prototype._applyCustomColors = function() {
3622
- this._elementRegistry.forEach((t) => {
3623
- const e = this._customColors[t.id];
3624
- e && this._set(t, qn(e));
3625
- });
3626
- };
3627
- Q.prototype._applyHighestPriorityColor = function(t) {
3628
- const e = this._customColors[t.id];
3629
- if (!e) {
3630
- this._set(t, this._originalColors[t.id]);
3631
- return;
3632
- }
3633
- this._set(t, qn(e));
3634
- };
3635
- Q.prototype._forceRedraw = function(t) {
3636
- const e = this._elementRegistry.getGraphics(t), n = t.waypoints ? "connection" : "shape";
3637
- this._graphicsFactory.update(n, t, e);
3638
- };
3639
- function zn(t) {
3640
- return "labelTarget" in t;
3641
- }
3642
- function qn(t = {}) {
3643
- const e = Object.values(t).reduce((n, i) => {
3644
- const { priority: o = 1e3 } = i;
3645
- return !n || o > n.priority ? i : n;
3646
- }, void 0);
3647
- if (e) {
3648
- const { priority: n, ...i } = e;
3649
- return i;
3650
- }
3651
- }
3652
- const je = {
3653
- elementColors: ["type", Q]
3654
- }, os = {
3655
- __depends__: [
3656
- je,
3657
- me
3658
- ],
3659
- exclusiveGatewaySettings: ["type", Lt]
3660
- }, ss = "neutral-element-colors";
3661
- function He(t, e, n) {
3662
- this._elementRegistry = e, this._elementColors = n, t.on(N, (i) => {
3663
- const { active: o } = i;
3664
- o && this._setNeutralColors();
3665
- });
3666
- }
3667
- He.prototype._setNeutralColors = function() {
3668
- this._elementRegistry.forEach((t) => {
3669
- this._elementColors.add(t, ss, {
3670
- stroke: "#212121",
3671
- fill: "#fff"
3672
- });
3673
- });
3674
- };
3675
- He.$inject = [
3676
- "eventBus",
3677
- "elementRegistry",
3678
- "elementColors"
3679
- ];
3680
- const rs = {
3681
- __depends__: [je],
3682
- __init__: [
3683
- "neutralElementColors"
3684
- ],
3685
- neutralElementColors: ["type", He]
3686
- }, as = "--token-simulation-grey-darken-30", cs = "--token-simulation-grey-lighten-56", ls = "inclusive-gateway-settings";
3687
- function it(t, e, n, i, o) {
3688
- this._elementRegistry = e, this._elementColors = n, this._simulator = i, this._simulationStyles = o, t.on(N, (s) => {
3689
- s.active ? this.setDefaults() : this.reset();
3690
- });
3691
- }
3692
- it.prototype.setDefaults = function() {
3693
- this._elementRegistry.filter((e) => p(e, "bpmn:InclusiveGateway")).forEach((e) => {
3694
- e.outgoing.filter(rt).length > 1 && this._setGatewayDefaults(e);
3695
- });
3696
- };
3697
- it.prototype.reset = function() {
3698
- this._elementRegistry.filter((e) => p(e, "bpmn:InclusiveGateway")).forEach((e) => {
3699
- e.outgoing.filter(rt).length > 1 && this._resetGateway(e);
3700
- });
3701
- };
3702
- it.prototype.toggleSequenceFlow = function(t, e) {
3703
- const n = this._getActiveOutgoing(t), i = Ve(t), o = us(t);
3704
- let s;
3705
- n.includes(e) ? s = Ie(n, e) : s = Ie(n, i).concat(e), s.length || (i ? s = [i] : s = [o.find((r) => r !== e)]), this._setActiveOutgoing(t, s);
3706
- };
3707
- it.prototype._getActiveOutgoing = function(t) {
3708
- const {
3709
- activeOutgoing: e
3710
- } = this._simulator.getConfig(t);
3711
- return e;
3712
- };
3713
- it.prototype._setActiveOutgoing = function(t, e) {
3714
- this._simulator.setConfig(t, { activeOutgoing: e }), t.outgoing.filter(rt).forEach((i) => {
3715
- const o = !e || e.includes(i) ? as : cs, s = this._simulationStyles.get(o);
3716
- this._elementColors.add(i, ls, {
3717
- stroke: s
3718
- });
3719
- });
3720
- };
3721
- it.prototype._setGatewayDefaults = function(t) {
3722
- const e = t.outgoing.filter(rt), n = Ve(t), i = Ie(e, n);
3723
- this._setActiveOutgoing(t, i);
3724
- };
3725
- it.prototype._resetGateway = function(t) {
3726
- this._simulator.setConfig(t, { activeOutgoing: void 0 });
3727
- };
3728
- it.$inject = [
3729
- "eventBus",
3730
- "elementRegistry",
3731
- "elementColors",
3732
- "simulator",
3733
- "simulationStyles"
3734
- ];
3735
- function Ve(t) {
3736
- const e = H(t).default;
3737
- if (e)
3738
- return t.outgoing.find((n) => H(n) === e);
3739
- }
3740
- function us(t) {
3741
- const e = Ve(t);
3742
- return t.outgoing.filter((n) => H(n) !== e);
3743
- }
3744
- function Ie(t, e) {
3745
- return t.filter((n) => n !== e);
3746
- }
3747
- const hs = {
3748
- __depends__: [
3749
- je,
3750
- me
3751
- ],
3752
- inclusiveGatewaySettings: ["type", it]
3753
- };
3754
- function ge(t, e) {
3755
- var n = this;
3756
- this._canvas = e, this.entries = [], this._init(), t.on(N, function(i) {
3757
- var o = i.active;
3758
- o ? T(n.container).remove("hidden") : T(n.container).add("hidden");
3759
- });
3760
- }
3761
- ge.prototype._init = function() {
3762
- this.container = O('<div class="bts-palette hidden"></div>'), this._canvas.getContainer().appendChild(this.container);
3763
- };
3764
- ge.prototype.addEntry = function(t, e) {
3765
- var n = 0;
3766
- this.entries.forEach(function(i) {
3767
- e >= i.index && n++;
3768
- }), this.container.insertBefore(t, this.container.childNodes[n]), this.entries.push({
3769
- entry: t,
3770
- index: e
3771
- });
3772
- };
3773
- ge.$inject = ["eventBus", "canvas"];
3774
- const ps = {
3775
- __init__: [
3776
- "tokenSimulationPalette"
3777
- ],
3778
- tokenSimulationPalette: ["type", ge]
3779
- }, fs = {
3780
- __depends__: [
3781
- $n,
3782
- mo,
3783
- Eo,
3784
- Io,
3785
- Ao,
3786
- $o,
3787
- No,
3788
- jo,
3789
- Vo,
3790
- zo,
3791
- Xo,
3792
- Zo,
3793
- os,
3794
- rs,
3795
- hs,
3796
- ps
3797
- ]
3798
- }, gs = {
3799
- __depends__: [
3800
- fs,
3801
- xi
3802
- ]
3803
- };
3804
- export {
3805
- gs as default
3806
- };