chunk-4XFIHP3G.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. import {
  2. e
  3. } from "./chunk-6C2KFJ7V.js";
  4. import {
  5. DEFAULT_LABEL_SIZE
  6. } from "./chunk-PSXVIVF4.js";
  7. import {
  8. isExpanded
  9. } from "./chunk-ZH5JUQV2.js";
  10. import {
  11. getBusinessObject,
  12. getDi,
  13. is,
  14. isAny
  15. } from "./chunk-L5SG54UC.js";
  16. import {
  17. assign,
  18. forEach,
  19. has,
  20. isDefined,
  21. isObject,
  22. omit
  23. } from "./chunk-4AK4GF4H.js";
  24. // node_modules/.pnpm/object-refs@0.4.0/node_modules/object-refs/dist/index.js
  25. function extend(collection, refs, property, target) {
  26. var inverseProperty = property.inverse;
  27. Object.defineProperty(collection, "remove", {
  28. value: function(element) {
  29. var idx = this.indexOf(element);
  30. if (idx !== -1) {
  31. this.splice(idx, 1);
  32. refs.unset(element, inverseProperty, target);
  33. }
  34. return element;
  35. }
  36. });
  37. Object.defineProperty(collection, "contains", {
  38. value: function(element) {
  39. return this.indexOf(element) !== -1;
  40. }
  41. });
  42. Object.defineProperty(collection, "add", {
  43. value: function(element, idx) {
  44. var currentIdx = this.indexOf(element);
  45. if (typeof idx === "undefined") {
  46. if (currentIdx !== -1) {
  47. return;
  48. }
  49. idx = this.length;
  50. }
  51. if (currentIdx !== -1) {
  52. this.splice(currentIdx, 1);
  53. }
  54. this.splice(idx, 0, element);
  55. if (currentIdx === -1) {
  56. refs.set(element, inverseProperty, target);
  57. }
  58. }
  59. });
  60. Object.defineProperty(collection, "__refs_collection", {
  61. value: true
  62. });
  63. return collection;
  64. }
  65. function isExtended(collection) {
  66. return collection.__refs_collection === true;
  67. }
  68. function hasOwnProperty(e2, property) {
  69. return Object.prototype.hasOwnProperty.call(e2, property.name || property);
  70. }
  71. function defineCollectionProperty(ref, property, target) {
  72. var collection = extend(target[property.name] || [], ref, property, target);
  73. Object.defineProperty(target, property.name, {
  74. enumerable: property.enumerable,
  75. value: collection
  76. });
  77. if (collection.length) {
  78. collection.forEach(function(o) {
  79. ref.set(o, property.inverse, target);
  80. });
  81. }
  82. }
  83. function defineProperty(ref, property, target) {
  84. var inverseProperty = property.inverse;
  85. var _value = target[property.name];
  86. Object.defineProperty(target, property.name, {
  87. configurable: property.configurable,
  88. enumerable: property.enumerable,
  89. get: function() {
  90. return _value;
  91. },
  92. set: function(value) {
  93. if (value === _value) {
  94. return;
  95. }
  96. var old = _value;
  97. _value = null;
  98. if (old) {
  99. ref.unset(old, inverseProperty, target);
  100. }
  101. _value = value;
  102. ref.set(_value, inverseProperty, target);
  103. }
  104. });
  105. }
  106. function Refs(a, b) {
  107. if (!(this instanceof Refs)) {
  108. return new Refs(a, b);
  109. }
  110. a.inverse = b;
  111. b.inverse = a;
  112. this.props = {};
  113. this.props[a.name] = a;
  114. this.props[b.name] = b;
  115. }
  116. Refs.prototype.bind = function(target, property) {
  117. if (typeof property === "string") {
  118. if (!this.props[property]) {
  119. throw new Error("no property <" + property + "> in ref");
  120. }
  121. property = this.props[property];
  122. }
  123. if (property.collection) {
  124. defineCollectionProperty(this, property, target);
  125. } else {
  126. defineProperty(this, property, target);
  127. }
  128. };
  129. Refs.prototype.ensureRefsCollection = function(target, property) {
  130. var collection = target[property.name];
  131. if (!isExtended(collection)) {
  132. defineCollectionProperty(this, property, target);
  133. }
  134. return collection;
  135. };
  136. Refs.prototype.ensureBound = function(target, property) {
  137. if (!hasOwnProperty(target, property)) {
  138. this.bind(target, property);
  139. }
  140. };
  141. Refs.prototype.unset = function(target, property, value) {
  142. if (target) {
  143. this.ensureBound(target, property);
  144. if (property.collection) {
  145. this.ensureRefsCollection(target, property).remove(value);
  146. } else {
  147. target[property.name] = void 0;
  148. }
  149. }
  150. };
  151. Refs.prototype.set = function(target, property, value) {
  152. if (target) {
  153. this.ensureBound(target, property);
  154. if (property.collection) {
  155. this.ensureRefsCollection(target, property).add(value);
  156. } else {
  157. target[property.name] = value;
  158. }
  159. }
  160. };
  161. // node_modules/.pnpm/diagram-js@13.4.0/node_modules/diagram-js/lib/model/index.js
  162. var parentRefs = new Refs({ name: "children", enumerable: true, collection: true }, { name: "parent" });
  163. var labelRefs = new Refs({ name: "labels", enumerable: true, collection: true }, { name: "labelTarget" });
  164. var attacherRefs = new Refs({ name: "attachers", collection: true }, { name: "host" });
  165. var outgoingRefs = new Refs({ name: "outgoing", collection: true }, { name: "source" });
  166. var incomingRefs = new Refs({ name: "incoming", collection: true }, { name: "target" });
  167. function ElementImpl() {
  168. Object.defineProperty(this, "businessObject", {
  169. writable: true
  170. });
  171. Object.defineProperty(this, "label", {
  172. get: function() {
  173. return this.labels[0];
  174. },
  175. set: function(newLabel) {
  176. var label = this.label, labels = this.labels;
  177. if (!newLabel && label) {
  178. labels.remove(label);
  179. } else {
  180. labels.add(newLabel, 0);
  181. }
  182. }
  183. });
  184. parentRefs.bind(this, "parent");
  185. labelRefs.bind(this, "labels");
  186. outgoingRefs.bind(this, "outgoing");
  187. incomingRefs.bind(this, "incoming");
  188. }
  189. function ShapeImpl() {
  190. ElementImpl.call(this);
  191. parentRefs.bind(this, "children");
  192. attacherRefs.bind(this, "host");
  193. attacherRefs.bind(this, "attachers");
  194. }
  195. e(ShapeImpl, ElementImpl);
  196. function RootImpl() {
  197. ElementImpl.call(this);
  198. parentRefs.bind(this, "children");
  199. }
  200. e(RootImpl, ShapeImpl);
  201. function LabelImpl() {
  202. ShapeImpl.call(this);
  203. labelRefs.bind(this, "labelTarget");
  204. }
  205. e(LabelImpl, ShapeImpl);
  206. function ConnectionImpl() {
  207. ElementImpl.call(this);
  208. outgoingRefs.bind(this, "source");
  209. incomingRefs.bind(this, "target");
  210. }
  211. e(ConnectionImpl, ElementImpl);
  212. var types = {
  213. connection: ConnectionImpl,
  214. shape: ShapeImpl,
  215. label: LabelImpl,
  216. root: RootImpl
  217. };
  218. function create(type, attrs) {
  219. var Type = types[type];
  220. if (!Type) {
  221. throw new Error("unknown type: <" + type + ">");
  222. }
  223. return assign(new Type(), attrs);
  224. }
  225. function isModelElement(obj) {
  226. return obj instanceof ElementImpl;
  227. }
  228. // node_modules/.pnpm/diagram-js@13.4.0/node_modules/diagram-js/lib/core/ElementFactory.js
  229. function ElementFactory() {
  230. this._uid = 12;
  231. }
  232. ElementFactory.prototype.createRoot = function(attrs) {
  233. return this.create("root", attrs);
  234. };
  235. ElementFactory.prototype.createLabel = function(attrs) {
  236. return this.create("label", attrs);
  237. };
  238. ElementFactory.prototype.createShape = function(attrs) {
  239. return this.create("shape", attrs);
  240. };
  241. ElementFactory.prototype.createConnection = function(attrs) {
  242. return this.create("connection", attrs);
  243. };
  244. ElementFactory.prototype.create = function(type, attrs) {
  245. attrs = assign({}, attrs || {});
  246. if (!attrs.id) {
  247. attrs.id = type + "_" + this._uid++;
  248. }
  249. return create(type, attrs);
  250. };
  251. // node_modules/.pnpm/bpmn-js@16.3.2/node_modules/bpmn-js/lib/util/CompatibilityUtil.js
  252. var DI_ERROR_MESSAGE = "Tried to access di from the businessObject. The di is available through the diagram element only. For more information, see https://github.com/bpmn-io/bpmn-js/issues/1472";
  253. function ensureCompatDiRef(businessObject) {
  254. if (!has(businessObject, "di")) {
  255. Object.defineProperty(businessObject, "di", {
  256. enumerable: false,
  257. get: function() {
  258. throw new Error(DI_ERROR_MESSAGE);
  259. }
  260. });
  261. }
  262. }
  263. // node_modules/.pnpm/bpmn-js@16.3.2/node_modules/bpmn-js/lib/features/modeling/ElementFactory.js
  264. function ElementFactory2(bpmnFactory, moddle, translate) {
  265. ElementFactory.call(this);
  266. this._bpmnFactory = bpmnFactory;
  267. this._moddle = moddle;
  268. this._translate = translate;
  269. }
  270. e(ElementFactory2, ElementFactory);
  271. ElementFactory2.$inject = [
  272. "bpmnFactory",
  273. "moddle",
  274. "translate"
  275. ];
  276. ElementFactory2.prototype._baseCreate = ElementFactory.prototype.create;
  277. ElementFactory2.prototype.create = function(elementType, attrs) {
  278. if (elementType === "label") {
  279. var di = attrs.di || this._bpmnFactory.createDiLabel();
  280. return this._baseCreate(elementType, assign({ type: "label", di }, DEFAULT_LABEL_SIZE, attrs));
  281. }
  282. return this.createElement(elementType, attrs);
  283. };
  284. ElementFactory2.prototype.createElement = function(elementType, attrs) {
  285. var size, translate = this._translate;
  286. attrs = assign({}, attrs || {});
  287. var businessObject = attrs.businessObject, di = attrs.di;
  288. if (!businessObject) {
  289. if (!attrs.type) {
  290. throw new Error(translate("no shape type specified"));
  291. }
  292. businessObject = this._bpmnFactory.create(attrs.type);
  293. ensureCompatDiRef(businessObject);
  294. }
  295. if (!isModdleDi(di)) {
  296. var diAttrs = assign(
  297. {},
  298. di || {},
  299. { id: businessObject.id + "_di" }
  300. );
  301. if (elementType === "root") {
  302. di = this._bpmnFactory.createDiPlane(businessObject, diAttrs);
  303. } else if (elementType === "connection") {
  304. di = this._bpmnFactory.createDiEdge(businessObject, diAttrs);
  305. } else {
  306. di = this._bpmnFactory.createDiShape(businessObject, diAttrs);
  307. }
  308. }
  309. if (is(businessObject, "bpmn:Group")) {
  310. attrs = assign({
  311. isFrame: true
  312. }, attrs);
  313. }
  314. attrs = applyAttributes(businessObject, attrs, [
  315. "processRef",
  316. "isInterrupting",
  317. "associationDirection",
  318. "isForCompensation"
  319. ]);
  320. if (attrs.isExpanded) {
  321. attrs = applyAttribute(di, attrs, "isExpanded");
  322. }
  323. if (is(businessObject, "bpmn:SubProcess")) {
  324. attrs.collapsed = !isExpanded(businessObject, di);
  325. }
  326. if (is(businessObject, "bpmn:ExclusiveGateway")) {
  327. di.isMarkerVisible = true;
  328. }
  329. if (isDefined(attrs.triggeredByEvent)) {
  330. businessObject.triggeredByEvent = attrs.triggeredByEvent;
  331. delete attrs.triggeredByEvent;
  332. }
  333. if (isDefined(attrs.cancelActivity)) {
  334. businessObject.cancelActivity = attrs.cancelActivity;
  335. delete attrs.cancelActivity;
  336. }
  337. var eventDefinitions, newEventDefinition;
  338. if (attrs.eventDefinitionType) {
  339. eventDefinitions = businessObject.get("eventDefinitions") || [];
  340. newEventDefinition = this._bpmnFactory.create(attrs.eventDefinitionType, attrs.eventDefinitionAttrs);
  341. if (attrs.eventDefinitionType === "bpmn:ConditionalEventDefinition") {
  342. newEventDefinition.condition = this._bpmnFactory.create("bpmn:FormalExpression");
  343. }
  344. eventDefinitions.push(newEventDefinition);
  345. newEventDefinition.$parent = businessObject;
  346. businessObject.eventDefinitions = eventDefinitions;
  347. delete attrs.eventDefinitionType;
  348. }
  349. size = this.getDefaultSize(businessObject, di);
  350. attrs = assign({
  351. id: businessObject.id
  352. }, size, attrs, {
  353. businessObject,
  354. di
  355. });
  356. return this._baseCreate(elementType, attrs);
  357. };
  358. ElementFactory2.prototype.getDefaultSize = function(element, di) {
  359. var bo = getBusinessObject(element);
  360. di = di || getDi(element);
  361. if (is(bo, "bpmn:SubProcess")) {
  362. if (isExpanded(bo, di)) {
  363. return { width: 350, height: 200 };
  364. } else {
  365. return { width: 100, height: 80 };
  366. }
  367. }
  368. if (is(bo, "bpmn:Task")) {
  369. return { width: 100, height: 80 };
  370. }
  371. if (is(bo, "bpmn:Gateway")) {
  372. return { width: 50, height: 50 };
  373. }
  374. if (is(bo, "bpmn:Event")) {
  375. return { width: 36, height: 36 };
  376. }
  377. if (is(bo, "bpmn:Participant")) {
  378. if (isExpanded(bo, di)) {
  379. return { width: 600, height: 250 };
  380. } else {
  381. return { width: 400, height: 60 };
  382. }
  383. }
  384. if (is(bo, "bpmn:Lane")) {
  385. return { width: 400, height: 100 };
  386. }
  387. if (is(bo, "bpmn:DataObjectReference")) {
  388. return { width: 36, height: 50 };
  389. }
  390. if (is(bo, "bpmn:DataStoreReference")) {
  391. return { width: 50, height: 50 };
  392. }
  393. if (is(bo, "bpmn:TextAnnotation")) {
  394. return { width: 100, height: 30 };
  395. }
  396. if (is(bo, "bpmn:Group")) {
  397. return { width: 300, height: 300 };
  398. }
  399. return { width: 100, height: 80 };
  400. };
  401. ElementFactory2.prototype.createParticipantShape = function(attrs) {
  402. if (!isObject(attrs)) {
  403. attrs = { isExpanded: attrs };
  404. }
  405. attrs = assign({ type: "bpmn:Participant" }, attrs || {});
  406. if (attrs.isExpanded !== false) {
  407. attrs.processRef = this._bpmnFactory.create("bpmn:Process");
  408. }
  409. return this.createShape(attrs);
  410. };
  411. function applyAttributes(element, attrs, attributeNames) {
  412. forEach(attributeNames, function(property) {
  413. attrs = applyAttribute(element, attrs, property);
  414. });
  415. return attrs;
  416. }
  417. function applyAttribute(element, attrs, attributeName) {
  418. if (attrs[attributeName] === void 0) {
  419. return attrs;
  420. }
  421. element[attributeName] = attrs[attributeName];
  422. return omit(attrs, [attributeName]);
  423. }
  424. function isModdleDi(element) {
  425. return isAny(element, [
  426. "bpmndi:BPMNShape",
  427. "bpmndi:BPMNEdge",
  428. "bpmndi:BPMNDiagram",
  429. "bpmndi:BPMNPlane"
  430. ]);
  431. }
  432. export {
  433. isModelElement,
  434. ElementFactory,
  435. ensureCompatDiRef,
  436. ElementFactory2
  437. };
  438. //# sourceMappingURL=chunk-4XFIHP3G.js.map