n8n-editor-ui 1.81.2 → 1.82.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/biome.jsonc +2 -2
  2. package/dist/assets/{AnnotationTagsDropdown.ee.vue_vue_type_script_setup_true_lang-C9QSjwx2.js → AnnotationTagsDropdown.ee.vue_vue_type_script_setup_true_lang-S6sC2rqC.js} +1 -1
  3. package/dist/assets/{AuthView-Ckt8JqkO.js → AuthView-DhLPVf9-.js} +2 -2
  4. package/dist/assets/{CanvasChat-oFfeuF_m.css → CanvasChat-CSLR5tKe.css} +67 -67
  5. package/dist/assets/{CanvasChat-Cy1m21Qr.js → CanvasChat-DjKTx2jN.js} +7 -7
  6. package/dist/assets/{ChangePasswordView-AoOsRhn6.js → ChangePasswordView-CcEYn8N_.js} +3 -3
  7. package/dist/assets/CollectionParameter-BzV9DuAR.js +4 -0
  8. package/dist/assets/{ConcurrentExecutionsHeader-Ov5gmvZv.js → ConcurrentExecutionsHeader-DEuxxBOa.js} +2 -2
  9. package/dist/assets/{CredentialsView-CtrYJkBd.js → CredentialsView-CyBNC9MS.js} +6 -6
  10. package/dist/assets/{ErrorView-DQ6IxeMW.js → ErrorView-k2iqIjfF.js} +1 -1
  11. package/dist/assets/{ExecutionsView-CjAi5MPS.js → ExecutionsView-B3G-SDHi.js} +6 -6
  12. package/dist/assets/{FileSaver.min-BCizZpyV.js → FileSaver.min-C3y-t-w8.js} +1 -1
  13. package/dist/assets/{FixedCollectionParameter-BReT5syB.css → FixedCollectionParameter-BATXrzXI.css} +18 -18
  14. package/dist/assets/{FixedCollectionParameter-hSKWl3Cr.js → FixedCollectionParameter-_Y9rxAqw.js} +2 -2
  15. package/dist/assets/{ForgotMyPasswordView-bgCElxPF.js → ForgotMyPasswordView-DphAOWHQ.js} +3 -3
  16. package/dist/assets/{Logo-SggscMOj.js → Logo-DUrZye2i.js} +1 -1
  17. package/dist/assets/{MainHeader-ByRLGpW_.css → MainHeader-CX-ZfeKE.css} +34 -40
  18. package/dist/assets/{MainHeader-C9IgyjLi.js → MainHeader-PG8BBJpt.js} +112 -97
  19. package/dist/assets/{MainSidebar-BAfxFkJz.js → MainSidebar-9NvHWe8s.js} +3 -3
  20. package/dist/assets/{MainSidebar-BQVC8zBU.css → MainSidebar-DULRx8tG.css} +2 -2
  21. package/dist/assets/{NodeCreation-CGPBWOsp.js → NodeCreation-B5IA4OSp.js} +4 -4
  22. package/dist/assets/{NodeCreator-CfRdwsEP.js → NodeCreator-Do-c2_pi.js} +4 -4
  23. package/dist/assets/{NodeDetailsView-BaeRsNfe.js → NodeDetailsView-B4RWpeXL.js} +43 -26
  24. package/dist/assets/{NodeDetailsView-C2CtoATD.css → NodeDetailsView-mr-1IzdH.css} +22 -22
  25. package/dist/assets/{NodeView-BIkAV11y.js → NodeView-DLAZbogk.js} +28 -18
  26. package/dist/assets/{ProjectCardBadge-DbDv6sZf.js → ProjectCardBadge-Cd22Jp5H.js} +1 -1
  27. package/dist/assets/{ProjectCreateResource-B7vjvB0g.js → ProjectCreateResource-CNZoR3aH.js} +1 -1
  28. package/dist/assets/{ProjectHeader--DY7lR41.js → ProjectHeader-jjyjO9Sn.js} +31 -12
  29. package/dist/assets/{ProjectSettings-DBkXXbnf.js → ProjectSettings-CNPBR8Py.js} +3 -3
  30. package/dist/assets/{PushConnectionTracker.vue_vue_type_script_setup_true_lang-BmDVjPzU.js → PushConnectionTracker.vue_vue_type_script_setup_true_lang-DBLwE_Te.js} +2 -2
  31. package/dist/assets/{ResourcesListLayout-BvDRT_NT.js → ResourcesListLayout-7x3qhzgO.js} +31 -27
  32. package/dist/assets/{ResourcesListLayout-GXGxZsS7.css → ResourcesListLayout-CrglsyJJ.css} +28 -25
  33. package/dist/assets/{RunDataAi-CTqCC4qP.js → RunDataAi-NsV225aR.js} +95 -81
  34. package/dist/assets/{RunDataJson-Da828ryU.js → RunDataJson-Cz0pyx-c.js} +12 -12
  35. package/dist/assets/{RunDataJsonActions-BJTF9rnw.js → RunDataJsonActions-pi0-gz1O.js} +2 -2
  36. package/dist/assets/{RunDataSearch-BnOB6pq1.js → RunDataSearch-CdoVJUy2.js} +1 -1
  37. package/dist/assets/{RunDataTable-O4pMxSL3.js → RunDataTable-BlfFPz_o.js} +2 -2
  38. package/dist/assets/{SamlOnboarding-_ryt8W2b.js → SamlOnboarding-DrHEUeao.js} +3 -3
  39. package/dist/assets/{SettingsApiView-BB3Lm3bi.css → SettingsApiView-BF29ifnH.css} +17 -7
  40. package/dist/assets/{SettingsApiView-DscvMUm4.js → SettingsApiView-xOx9zvK8.js} +96 -12
  41. package/dist/assets/{SettingsCommunityNodesView-BwQqFFul.js → SettingsCommunityNodesView-DJdg3rwD.js} +5 -5
  42. package/dist/assets/{SettingsExternalSecrets-Bns3YFMo.js → SettingsExternalSecrets-BawxcYEz.js} +1 -1
  43. package/dist/assets/{SettingsLdapView-C4z8TThS.js → SettingsLdapView-UP-yLJR0.js} +1 -1
  44. package/dist/assets/{SettingsLogStreamingView-CeddPL5W.js → SettingsLogStreamingView-BI6cv-3k.js} +1 -1
  45. package/dist/assets/{SettingsPersonalView-T66EcUl1.js → SettingsPersonalView-T_Gv_CP4.js} +1 -1
  46. package/dist/assets/{SettingsSourceControl-B2g48mBg.js → SettingsSourceControl-b35BPriM.js} +1 -1
  47. package/dist/assets/{SettingsSso-DtJRjXuJ.js → SettingsSso-Cv560JhN.js} +1 -1
  48. package/dist/assets/{SettingsUsageAndPlan-B5DEUrT3.css → SettingsUsageAndPlan-Cul4YcIk.css} +3 -3
  49. package/dist/assets/{SettingsUsageAndPlan-DcEfsK15.js → SettingsUsageAndPlan-vdhHrfLx.js} +2 -2
  50. package/dist/assets/{SettingsUsersView-CiRUNOx8.js → SettingsUsersView-fOw0vUke.js} +1 -1
  51. package/dist/assets/{SettingsView-CMGmeLhf.js → SettingsView-DP7tEJ5g.js} +1 -1
  52. package/dist/assets/{SetupView-pCvp7JLT.js → SetupView-A_5QHzjg.js} +3 -3
  53. package/dist/assets/{SetupWorkflowCredentialsButton-B_Xu8nk4.js → SetupWorkflowCredentialsButton-BxKYo82D.js} +1 -1
  54. package/dist/assets/{SetupWorkflowFromTemplateView-wSwqXRvb.js → SetupWorkflowFromTemplateView-lItls2qU.js} +3 -3
  55. package/dist/assets/{SigninView-CcdkQAYx.js → SigninView-DCSGKzQW.js} +3 -3
  56. package/dist/assets/{SignoutView-BRcA6k7Y.js → SignoutView-DjLzc_dB.js} +1 -1
  57. package/dist/assets/{SignupView-B7mxGyr_.js → SignupView-Bmc7voE4.js} +3 -3
  58. package/dist/assets/{TemplateDetails-CrV-sqws.js → TemplateDetails-CNDlIU68.js} +1 -1
  59. package/dist/assets/{TemplateList-DeoFPe1T.js → TemplateList-Bd2BANIh.js} +1 -1
  60. package/dist/assets/{TemplatesCollectionView-Ds6Reoqk.js → TemplatesCollectionView-BtCb9-G2.js} +5 -5
  61. package/dist/assets/{TemplatesSearchView-DKRqKDsz.js → TemplatesSearchView-uzkWuDz-.js} +3 -3
  62. package/dist/assets/{TemplatesView-CvANPrac.js → TemplatesView-zaUOfZH6.js} +1 -1
  63. package/dist/assets/{TemplatesWorkflowView-DqLpZX3Y.js → TemplatesWorkflowView-C-9rF9ZV.js} +5 -5
  64. package/dist/assets/{TestDefinitionEditView-n-k2EViv.js → TestDefinitionEditView-Dwc43mWu.js} +316 -446
  65. package/dist/assets/{TestDefinitionEditView-B-ShDvcb.css → TestDefinitionEditView-P_NZr18p.css} +54 -237
  66. package/dist/assets/{TestDefinitionListView-2dTaUcPb.js → TestDefinitionListView-CerTQbEg.js} +29 -35
  67. package/dist/assets/{TestDefinitionListView-DQQJ8Oqf.css → TestDefinitionListView-Di-Edppe.css} +5 -5
  68. package/dist/assets/{TestDefinitionNewView-D9TlngIG.js → TestDefinitionNewView-B6G7zC8e.js} +2 -2
  69. package/dist/assets/{TestDefinitionRootView-DyYcRvES.js → TestDefinitionRootView-BtnW_v0S.js} +1 -1
  70. package/dist/assets/{VariablesView-u3Zaa4Dx.js → VariablesView-BwOp_rAK.js} +6 -6
  71. package/dist/assets/{VariablesView-0Eu4NnUq.css → VariablesView-CbTLdNwU.css} +10 -10
  72. package/dist/assets/{WorkerView-CjhMC5C9.js → WorkerView-zJQ3m1UQ.js} +7 -7
  73. package/dist/assets/{WorkflowActivator-CDtN9xyL.js → WorkflowActivator-ByyZSmam.js} +2 -2
  74. package/dist/assets/{WorkflowExecutionsInfoAccordion-dNND3XQ1.js → WorkflowExecutionsInfoAccordion-By2qBGv3.js} +1 -1
  75. package/dist/assets/{WorkflowExecutionsLandingPage-C5QEDyTb.js → WorkflowExecutionsLandingPage-Dv9pB-gw.js} +2 -2
  76. package/dist/assets/{WorkflowExecutionsPreview-CXwWU4Da.js → WorkflowExecutionsPreview-B95KC_nD.js} +6 -6
  77. package/dist/assets/{WorkflowExecutionsView-YzQhE6BJ.js → WorkflowExecutionsView-BlrNNbyH.js} +7 -7
  78. package/dist/assets/{WorkflowHistory-DwNBPKKC.js → WorkflowHistory-BAWH5OhJ.js} +3 -3
  79. package/dist/assets/{WorkflowOnboardingView-B-ZvDAJm.js → WorkflowOnboardingView-C7H4P9fv.js} +1 -1
  80. package/dist/assets/{WorkflowPreview-q-thWWZZ.js → WorkflowPreview-B4gIeMU5.js} +1 -1
  81. package/dist/assets/{WorkflowsView-Dc4DNgGT.css → WorkflowsView-JN0Hvhvt.css} +323 -26
  82. package/dist/assets/{WorkflowsView-PSsz5TRG.js → WorkflowsView-WiMvvjrZ.js} +633 -272
  83. package/dist/assets/{easyAiWorkflowUtils-KW1Ht6j8.js → easyAiWorkflowUtils-K9DVRQP8.js} +1 -1
  84. package/dist/assets/{global-link-actions-DRfLF4y6.js → global-link-actions-B95GMIG5.js} +1 -1
  85. package/dist/assets/{import-curl-pNf9q0qQ.js → import-curl-DUxX-cV3.js} +1 -1
  86. package/dist/assets/{index-C06tkpld.js → index-BGYw7Tle.js} +3390 -3351
  87. package/dist/assets/{index-CV2sFqhR.js → index-CZL3Jl0P.js} +1 -1
  88. package/dist/assets/{index-CKK_xS1q.css → index-DvUG3hgI.css} +355 -148
  89. package/dist/assets/{pickBy-CMtHkGeG.js → pickBy-e-2Qz7NU.js} +1 -1
  90. package/dist/assets/{pushConnection.store-BqZhZ7-T.js → pushConnection.store-BGGIKcjm.js} +1 -1
  91. package/dist/assets/{templateActions-D6RFtMCF.js → templateActions-DV-GKWdP.js} +1 -1
  92. package/dist/assets/{useBeforeUnload-BuZ-l9nI.js → useBeforeUnload-C-AtZLTg.js} +1 -1
  93. package/dist/assets/{useCanvasMapping-Bb0rYy8s.css → useCanvasMapping-CkNBF2SE.css} +184 -45
  94. package/dist/assets/{useCanvasMapping-B2Rx4tNy.js → useCanvasMapping-Hz5gCELZ.js} +4252 -279
  95. package/dist/assets/{useCanvasOperations-C-zV2Jxd.js → useCanvasOperations-DvuQ2UqW.js} +219 -21
  96. package/dist/assets/{useExecutionDebugging-CLBfRoGl.js → useExecutionDebugging-rI6MFxnv.js} +1 -1
  97. package/dist/assets/{useExecutionHelpers-7L4-5LnP.js → useExecutionHelpers-DQskduD9.js} +1 -1
  98. package/dist/assets/{useImportCurlCommand-Cbk6CGT_.js → useImportCurlCommand-CBugVIsK.js} +2 -2
  99. package/dist/assets/{usePinnedData-Hq06xPoo.js → usePinnedData-DEotvVuQ.js} +1 -1
  100. package/dist/assets/{usePushConnection-QnDVQ8As.js → usePushConnection-XtMvldec.js} +4 -4
  101. package/dist/assets/{useRunWorkflow-BJon34Vp.js → useRunWorkflow-CPV3na7d.js} +193 -18
  102. package/dist/assets/{useTestDefinitionForm-C0uFCVbQ.js → useTestDefinitionForm-ClopiqsS.js} +1 -1
  103. package/dist/assets/{useWorkflowActivate-1kRXyIJ4.js → useWorkflowActivate-Dlae1S8s.js} +1 -1
  104. package/dist/index.html +2 -2
  105. package/package.json +1 -1
  106. package/tsconfig.json +8 -12
  107. package/vite.config.mts +17 -16
  108. package/dist/assets/CollectionParameter-CgyeAR1l.js +0 -4
  109. /package/dist/{public/tree-sitter-bash.wasm → tree-sitter-bash.wasm} +0 -0
  110. /package/dist/{public/tree-sitter.wasm → tree-sitter.wasm} +0 -0
@@ -1,7 +1,7 @@
1
- import { f4 as effectScope, I as watch, d as defineComponent, br as toRef, c as openBlock, h as createElementBlock, e as createBlock, v as renderSlot, f5 as Teleport, f6 as useSlots, b4 as onUnmounted, i as createVNode, w as withCtx, l as unref, r as ref, z as nextTick, q as computed, aw as onBeforeMount, cs as getCurrentInstance, bt as reactive, o as onMounted, n as normalizeClass, j as createBaseVNode, t as toDisplayString, f as createCommentVNode, F as Fragment, B as renderList, C as normalizeStyle, y as onBeforeUnmount, f7 as isMemoSame, bq as provide, aX as isRef, aY as toRefs$1, f8 as customRef, f9 as toValue$1, fa as useAttrs, a$ as mergeProps, aW as inject, fb as getCurrentScope, fc as onScopeDispose, fd as createPropsRestProxy, b0 as resolveDynamicComponent, k as createTextVNode, m as resolveComponent, ap as h, fe as readonly, ff as markRaw, bs as KeyboardShortcutTooltip, g as useI18n, bh as NodeConnectionType, fg as CanvasKey, ab as useCssModule, _ as _export_sfc$1, bn as watchEffect, aZ as normalizeProps, fh as refThrottled, fi as CanvasNodeKey, bK as CanvasConnectionMode, bN as CanvasNodeRenderType, fj as mergeModels, fk as useModel, bp as useNodeHelpers, fl as TitledList, ad as nodeViewEventBus, J as withModifiers, bJ as NODE_CREATOR_OPEN_SOURCES, fm as CanvasNodeHandleKey, ax as withDirectives, ay as vShow, fn as Transition$2, L as useUIStore, bo as useNodeTypesStore, U as useWorkflowsStore, a1 as useSourceControlStore, am as getResourcePermissions, f3 as isPresent, fo as getMousePosition$1, aB as STICKY_NODE_TYPE, fp as NOT_DUPLICATABLE_NODE_TYPES, b as useRouter, b7 as CHAT_TRIGGER_NODE_TYPE, cB as _sfc_main$y, D as createEventBus, fq as isEqual, bL as isValidNodeConnectionType, fr as onKeyDown, fs as onKeyUp, ft as useActiveElement, fu as useDeviceSupport, fv as useEventListener$1, G as onClickOutside, fw as N8nActionDropdown, aS as createSlots, eU as GRID_SIZE, fx as useThrottleFn, a_ as guardReactiveProps, bD as Suspense, eO as CUSTOM_API_CALL_KEY, be as getNodeInputs, bg as getNodeOutputs, dd as getTriggerNodeServiceName, bY as sanitizeHtml, fy as nodeIssuesToString, fz as WAIT_NODE_TYPE, dY as SEND_AND_WAIT_OPERATION, fA as FORM_NODE_TYPE, fB as WAIT_INDEFINITELY } from "./index-C06tkpld.js";
2
- import { p as parseCanvasConnectionHandleString, u as useNodeCreatorStore, a as useCanvasOperations, c as createCanvasConnectionHandleString, i as insertSpacersBetweenEndpoints, m as mapLegacyEndpointsToCanvasConnectionPort, b as checkOverlap, d as mapLegacyConnectionsToCanvasConnections } from "./useCanvasOperations-C-zV2Jxd.js";
3
- import { u as usePinnedData } from "./usePinnedData-Hq06xPoo.js";
4
- import { u as useRunWorkflow } from "./useRunWorkflow-BJon34Vp.js";
1
+ import { f8 as effectScope, I as watch, d as defineComponent, bs as toRef, c as openBlock, h as createElementBlock, e as createBlock, v as renderSlot, f9 as Teleport, fa as useSlots, b5 as onUnmounted, i as createVNode, w as withCtx, l as unref, r as ref, z as nextTick, q as computed, aw as onBeforeMount, cu as getCurrentInstance, bu as reactive, o as onMounted, n as normalizeClass, j as createBaseVNode, t as toDisplayString, f as createCommentVNode, F as Fragment, B as renderList, C as normalizeStyle, y as onBeforeUnmount, fb as isMemoSame, br as provide, aY as isRef, aZ as toRefs$1, fc as customRef, fd as toValue$1, fe as useAttrs, b0 as mergeProps, aX as inject, ff as getCurrentScope, fg as onScopeDispose, fh as createPropsRestProxy, b1 as resolveDynamicComponent, k as createTextVNode, m as resolveComponent, ap as h, fi as readonly, fj as markRaw, _ as _export_sfc$1, bt as KeyboardShortcutTooltip, g as useI18n, bi as NodeConnectionType, fk as CanvasKey, ab as useCssModule, bo as watchEffect, a_ as normalizeProps, fl as refThrottled, fm as CanvasNodeKey, bL as CanvasConnectionMode, bO as CanvasNodeRenderType, fn as mergeModels, fo as useModel, bq as useNodeHelpers, fp as TitledList, aQ as N8nTooltip, dq as CanvasNodeDirtiness, J as withModifiers, ad as nodeViewEventBus, bK as NODE_CREATOR_OPEN_SOURCES, fq as CanvasNodeHandleKey, ax as withDirectives, ay as vShow, fr as Transition$2, L as useUIStore, bp as useNodeTypesStore, U as useWorkflowsStore, a1 as useSourceControlStore, am as getResourcePermissions, f7 as isPresent, fs as getMousePosition$1, aC as STICKY_NODE_TYPE, ft as NOT_DUPLICATABLE_NODE_TYPES, b as useRouter, b8 as CHAT_TRIGGER_NODE_TYPE, cD as _sfc_main$z, D as createEventBus, fu as isEqual, bM as isValidNodeConnectionType, fv as onKeyDown, fw as onKeyUp, fx as useActiveElement, fy as useDeviceSupport, fz as useEventListener$1, G as onClickOutside, fA as N8nActionDropdown, aT as createSlots, e_ as GRID_SIZE, fB as useThrottleFn, c1 as getDefaultExportFromCjs, eZ as NODE_SIZE, a$ as guardReactiveProps, bE as Suspense, eW as CUSTOM_API_CALL_KEY, bf as getNodeInputs, bh as getNodeOutputs, df as getTriggerNodeServiceName, bZ as sanitizeHtml, fC as nodeIssuesToString, fD as WAIT_NODE_TYPE, e4 as SEND_AND_WAIT_OPERATION, fE as FORM_NODE_TYPE, fF as WAIT_INDEFINITELY } from "./index-BGYw7Tle.js";
2
+ import { p as parseCanvasConnectionHandleString, u as useNodeCreatorStore, a as useCanvasOperations, c as createCanvasConnectionHandleString, i as insertSpacersBetweenEndpoints, m as mapLegacyEndpointsToCanvasConnectionPort, b as checkOverlap, d as mapLegacyConnectionsToCanvasConnections } from "./useCanvasOperations-DvuQ2UqW.js";
3
+ import { u as usePinnedData } from "./usePinnedData-DEotvVuQ.js";
4
+ import { u as useRunWorkflow, a as useNodeDirtiness } from "./useRunWorkflow-CPV3na7d.js";
5
5
  function tryOnScopeDispose(fn) {
6
6
  if (getCurrentScope()) {
7
7
  onScopeDispose(fn);
@@ -14,8 +14,8 @@ function toValue(r) {
14
14
  }
15
15
  const isClient = typeof window !== "undefined" && typeof document !== "undefined";
16
16
  const isDef$1 = (val) => typeof val !== "undefined";
17
- const toString = Object.prototype.toString;
18
- const isObject = (val) => toString.call(val) === "[object Object]";
17
+ const toString$1 = Object.prototype.toString;
18
+ const isObject = (val) => toString$1.call(val) === "[object Object]";
19
19
  const noop$2 = () => {
20
20
  };
21
21
  function createFilterWrapper(filter2, fn) {
@@ -943,14 +943,14 @@ ClassList$2.prototype = {
943
943
  }
944
944
  };
945
945
  function classedAdd$2(node2, names) {
946
- var list = classList$2(node2), i = -1, n = names.length;
946
+ var list2 = classList$2(node2), i = -1, n = names.length;
947
947
  while (++i < n)
948
- list.add(names[i]);
948
+ list2.add(names[i]);
949
949
  }
950
950
  function classedRemove$2(node2, names) {
951
- var list = classList$2(node2), i = -1, n = names.length;
951
+ var list2 = classList$2(node2), i = -1, n = names.length;
952
952
  while (++i < n)
953
- list.remove(names[i]);
953
+ list2.remove(names[i]);
954
954
  }
955
955
  function classedTrue$2(names) {
956
956
  return function() {
@@ -970,9 +970,9 @@ function classedFunction$2(names, value) {
970
970
  function selection_classed$2(name, value) {
971
971
  var names = classArray$2(name + "");
972
972
  if (arguments.length < 2) {
973
- var list = classList$2(this.node()), i = -1, n = names.length;
973
+ var list2 = classList$2(this.node()), i = -1, n = names.length;
974
974
  while (++i < n)
975
- if (!list.contains(names[i]))
975
+ if (!list2.contains(names[i]))
976
976
  return false;
977
977
  return true;
978
978
  }
@@ -4320,15 +4320,15 @@ function isValidHandle(event, {
4320
4320
  fromHandleId,
4321
4321
  fromType,
4322
4322
  doc,
4323
- lib,
4323
+ lib: lib2,
4324
4324
  flowId,
4325
4325
  isValidConnection = alwaysValid$1
4326
4326
  }, edges, nodes, findNode) {
4327
4327
  const isTarget = fromType === "target";
4328
- const handleDomNode = handle2 ? doc.querySelector(`.${lib}-flow__handle[data-id="${flowId}-${handle2 == null ? void 0 : handle2.nodeId}-${handle2 == null ? void 0 : handle2.id}-${handle2 == null ? void 0 : handle2.type}"]`) : null;
4328
+ const handleDomNode = handle2 ? doc.querySelector(`.${lib2}-flow__handle[data-id="${flowId}-${handle2 == null ? void 0 : handle2.nodeId}-${handle2 == null ? void 0 : handle2.id}-${handle2 == null ? void 0 : handle2.type}"]`) : null;
4329
4329
  const { x, y } = getEventPosition(event);
4330
4330
  const handleBelow = doc.elementFromPoint(x, y);
4331
- const handleToCheck = (handleBelow == null ? void 0 : handleBelow.classList.contains(`${lib}-flow__handle`)) ? handleBelow : handleDomNode;
4331
+ const handleToCheck = (handleBelow == null ? void 0 : handleBelow.classList.contains(`${lib2}-flow__handle`)) ? handleBelow : handleDomNode;
4332
4332
  const result = {
4333
4333
  handleDomNode: handleToCheck,
4334
4334
  isValid: false,
@@ -9456,7 +9456,7 @@ function useStylesLoadedWarning() {
9456
9456
  }
9457
9457
  });
9458
9458
  }
9459
- const _hoisted_1$c = /* @__PURE__ */ createBaseVNode("div", { class: "vue-flow__edge-labels" }, null, -1);
9459
+ const _hoisted_1$d = /* @__PURE__ */ createBaseVNode("div", { class: "vue-flow__edge-labels" }, null, -1);
9460
9460
  const __default__$1$2 = {
9461
9461
  name: "VueFlow",
9462
9462
  compatConfig: { MODE: 3 }
@@ -9549,7 +9549,7 @@ const _sfc_main$1$4 = /* @__PURE__ */ defineComponent({
9549
9549
  createVNode(_sfc_main$8$1, null, {
9550
9550
  default: withCtx(() => [
9551
9551
  createVNode(_sfc_main$4$1),
9552
- _hoisted_1$c,
9552
+ _hoisted_1$d,
9553
9553
  createVNode(_sfc_main$2$1),
9554
9554
  renderSlot(_ctx.$slots, "zoom-pane")
9555
9555
  ]),
@@ -9565,7 +9565,7 @@ const __default__$g = {
9565
9565
  name: "Panel",
9566
9566
  compatConfig: { MODE: 3 }
9567
9567
  };
9568
- const _sfc_main$x = /* @__PURE__ */ defineComponent({
9568
+ const _sfc_main$y = /* @__PURE__ */ defineComponent({
9569
9569
  ...__default__$g,
9570
9570
  props: {
9571
9571
  position: {}
@@ -9596,12 +9596,12 @@ const _export_sfc = (sfc, props) => {
9596
9596
  return target2;
9597
9597
  };
9598
9598
  const _hoisted_1$5$1 = { class: "vue-flow__controls-button" };
9599
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
9599
+ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
9600
9600
  return openBlock(), createElementBlock("button", _hoisted_1$5$1, [
9601
9601
  renderSlot(_ctx.$slots, "default")
9602
9602
  ]);
9603
9603
  }
9604
- const ControlButton = /* @__PURE__ */ _export_sfc(_sfc_main$1$3, [["render", _sfc_render]]);
9604
+ const ControlButton = /* @__PURE__ */ _export_sfc(_sfc_main$1$3, [["render", _sfc_render$1]]);
9605
9605
  const _hoisted_1$4$1 = {
9606
9606
  xmlns: "http://www.w3.org/2000/svg",
9607
9607
  viewBox: "0 0 32 32"
@@ -9650,7 +9650,7 @@ function render$1(_ctx, _cache) {
9650
9650
  return openBlock(), createElementBlock("svg", _hoisted_1$1$2, _hoisted_3$1$1);
9651
9651
  }
9652
9652
  const Lock = { render: render$1 };
9653
- const _hoisted_1$b = {
9653
+ const _hoisted_1$c = {
9654
9654
  xmlns: "http://www.w3.org/2000/svg",
9655
9655
  viewBox: "0 0 25 32"
9656
9656
  };
@@ -9659,14 +9659,14 @@ const _hoisted_3$5 = [
9659
9659
  _hoisted_2$7
9660
9660
  ];
9661
9661
  function render(_ctx, _cache) {
9662
- return openBlock(), createElementBlock("svg", _hoisted_1$b, _hoisted_3$5);
9662
+ return openBlock(), createElementBlock("svg", _hoisted_1$c, _hoisted_3$5);
9663
9663
  }
9664
9664
  const Unlock = { render };
9665
9665
  const __default__$4 = {
9666
9666
  name: "Controls",
9667
9667
  compatConfig: { MODE: 3 }
9668
9668
  };
9669
- const _sfc_main$w = /* @__PURE__ */ defineComponent({
9669
+ const _sfc_main$x = /* @__PURE__ */ defineComponent({
9670
9670
  ...__default__$4,
9671
9671
  props: {
9672
9672
  showZoom: { type: Boolean, default: true },
@@ -9709,7 +9709,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
9709
9709
  emit("interactionChange", !isInteractive.value);
9710
9710
  }
9711
9711
  return (_ctx, _cache) => {
9712
- return openBlock(), createBlock(unref(_sfc_main$x), {
9712
+ return openBlock(), createBlock(unref(_sfc_main$y), {
9713
9713
  class: "vue-flow__controls",
9714
9714
  position: _ctx.position
9715
9715
  }, {
@@ -9782,12 +9782,26 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
9782
9782
  };
9783
9783
  }
9784
9784
  });
9785
+ const _sfc_main$w = {};
9786
+ const _hoisted_1$b = {
9787
+ xmlns: "http://www.w3.org/2000/svg",
9788
+ viewBox: "0 0 16 16"
9789
+ };
9790
+ function _sfc_render(_ctx, _cache) {
9791
+ return openBlock(), createElementBlock("svg", _hoisted_1$b, _cache[0] || (_cache[0] = [
9792
+ createBaseVNode("path", {
9793
+ fill: "currentColor",
9794
+ d: "M1.6.13c-.18-.17-.47-.18-.62 0L.56.57.14.98c-.2.15-.18.44 0 .62l3.63 3.6c.1.1.1.27 0 .37-.2.2-.53.52-.93.94-.56.57-.12 1.62.22 2.11.05.07.12.1.2.1.05-.01.1-.04.15-.08l5.23-5.22c.1-.1.1-.26-.02-.34-.5-.34-1.55-.78-2.12-.22-.42.4-.75.73-.94.93-.1.1-.27.1-.37 0L1.6.13ZM9.5 3.9c.07-.09.2-.1.3-.04l6.07 3.44c.15.08.18.29.05.4l-1.21 1.22a.26.26 0 0 1-.26.07l-2.18-.64a.26.26 0 0 0-.32.33l.76 2.02c.04.1.01.2-.06.27L7.7 15.92a.26.26 0 0 1-.41-.05L3.83 9.8a.26.26 0 0 1 .04-.3l5.62-5.6Z"
9795
+ }, null, -1)
9796
+ ]));
9797
+ }
9798
+ const TidyUpIcon = /* @__PURE__ */ _export_sfc$1(_sfc_main$w, [["render", _sfc_render]]);
9785
9799
  const _sfc_main$v = /* @__PURE__ */ defineComponent({
9786
9800
  __name: "CanvasControlButtons",
9787
9801
  props: {
9788
9802
  zoom: { default: 1 }
9789
9803
  },
9790
- emits: ["reset-zoom", "zoom-in", "zoom-out", "zoom-to-fit"],
9804
+ emits: ["reset-zoom", "zoom-in", "zoom-out", "zoom-to-fit", "tidy-up"],
9791
9805
  setup(__props, { emit: __emit }) {
9792
9806
  const props = __props;
9793
9807
  const emit = __emit;
@@ -9805,9 +9819,13 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
9805
9819
  function onZoomToFit() {
9806
9820
  emit("zoom-to-fit");
9807
9821
  }
9822
+ function onTidyUp() {
9823
+ emit("tidy-up");
9824
+ }
9808
9825
  return (_ctx, _cache) => {
9809
9826
  const _component_N8nIconButton = resolveComponent("N8nIconButton");
9810
- return openBlock(), createBlock(unref(_sfc_main$w), {
9827
+ const _component_N8nButton = resolveComponent("N8nButton");
9828
+ return openBlock(), createBlock(unref(_sfc_main$x), {
9811
9829
  "show-zoom": false,
9812
9830
  "show-fit-view": false
9813
9831
  }, {
@@ -9872,13 +9890,42 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
9872
9890
  })
9873
9891
  ]),
9874
9892
  _: 1
9875
- }, 8, ["label"])) : createCommentVNode("", true)
9893
+ }, 8, ["label"])) : createCommentVNode("", true),
9894
+ createVNode(KeyboardShortcutTooltip, {
9895
+ label: unref(i18n).baseText("nodeView.tidyUp"),
9896
+ shortcut: { shiftKey: true, altKey: true, keys: ["T"] }
9897
+ }, {
9898
+ default: withCtx(() => [
9899
+ createVNode(_component_N8nButton, {
9900
+ square: "",
9901
+ type: "tertiary",
9902
+ size: "large",
9903
+ "data-test-id": "tidy-up-button",
9904
+ class: normalizeClass(_ctx.$style.iconButton),
9905
+ onClick: onTidyUp
9906
+ }, {
9907
+ default: withCtx(() => [
9908
+ createVNode(TidyUpIcon)
9909
+ ]),
9910
+ _: 1
9911
+ }, 8, ["class"])
9912
+ ]),
9913
+ _: 1
9914
+ }, 8, ["label"])
9876
9915
  ]),
9877
9916
  _: 1
9878
9917
  });
9879
9918
  };
9880
9919
  }
9881
9920
  });
9921
+ const iconButton = "_iconButton_kehsi_123";
9922
+ const style0$o = {
9923
+ iconButton
9924
+ };
9925
+ const cssModules$o = {
9926
+ "$style": style0$o
9927
+ };
9928
+ const __unplugin_components_1$1 = /* @__PURE__ */ _export_sfc$1(_sfc_main$v, [["__cssModules", cssModules$o]]);
9882
9929
  const EDGE_PADDING_BOTTOM = 130;
9883
9930
  const EDGE_PADDING_X = 40;
9884
9931
  const EDGE_BORDER_RADIUS = 16;
@@ -10515,12 +10562,12 @@ ClassList$1.prototype = {
10515
10562
  }
10516
10563
  };
10517
10564
  function classedAdd$1(node2, names) {
10518
- var list = classList$1(node2), i = -1, n = names.length;
10519
- while (++i < n) list.add(names[i]);
10565
+ var list2 = classList$1(node2), i = -1, n = names.length;
10566
+ while (++i < n) list2.add(names[i]);
10520
10567
  }
10521
10568
  function classedRemove$1(node2, names) {
10522
- var list = classList$1(node2), i = -1, n = names.length;
10523
- while (++i < n) list.remove(names[i]);
10569
+ var list2 = classList$1(node2), i = -1, n = names.length;
10570
+ while (++i < n) list2.remove(names[i]);
10524
10571
  }
10525
10572
  function classedTrue$1(names) {
10526
10573
  return function() {
@@ -10540,8 +10587,8 @@ function classedFunction$1(names, value) {
10540
10587
  function selection_classed$1(name, value) {
10541
10588
  var names = classArray$1(name + "");
10542
10589
  if (arguments.length < 2) {
10543
- var list = classList$1(this.node()), i = -1, n = names.length;
10544
- while (++i < n) if (!list.contains(names[i])) return false;
10590
+ var list2 = classList$1(this.node()), i = -1, n = names.length;
10591
+ while (++i < n) if (!list2.contains(names[i])) return false;
10545
10592
  return true;
10546
10593
  }
10547
10594
  return this.each((typeof value === "function" ? classedFunction$1 : value ? classedTrue$1 : classedFalse$1)(names, value));
@@ -12721,7 +12768,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
12721
12768
  emit("nodeMouseleave", param);
12722
12769
  }
12723
12770
  return (_ctx, _cache) => {
12724
- return openBlock(), createBlock(unref(_sfc_main$x), {
12771
+ return openBlock(), createBlock(unref(_sfc_main$y), {
12725
12772
  position: _ctx.position,
12726
12773
  class: normalizeClass(["vue-flow__minimap", { pannable: _ctx.pannable, zoomable: _ctx.zoomable }])
12727
12774
  }, {
@@ -13102,11 +13149,12 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
13102
13149
  __name: "CanvasNodeDisabledStrikeThrough",
13103
13150
  setup(__props) {
13104
13151
  const $style = useCssModule();
13105
- const { hasRunData } = useCanvasNode();
13152
+ const { hasRunData, render: render2 } = useCanvasNode();
13106
13153
  const classes = computed(() => {
13107
13154
  return {
13108
13155
  [$style.disabledStrikeThrough]: true,
13109
- [$style.success]: hasRunData.value
13156
+ [$style.success]: hasRunData.value,
13157
+ [$style.warning]: render2.value.type === CanvasNodeRenderType.Default && render2.value.options.dirtiness !== void 0
13110
13158
  };
13111
13159
  });
13112
13160
  return (_ctx, _cache) => {
@@ -13116,11 +13164,13 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
13116
13164
  };
13117
13165
  }
13118
13166
  });
13119
- const disabledStrikeThrough = "_disabledStrikeThrough_nt80z_123";
13120
- const success$2 = "_success_nt80z_132";
13167
+ const disabledStrikeThrough = "_disabledStrikeThrough_nl2g7_123";
13168
+ const success$2 = "_success_nl2g7_132";
13169
+ const warning$2 = "_warning_nl2g7_136";
13121
13170
  const style0$k = {
13122
13171
  disabledStrikeThrough,
13123
- success: success$2
13172
+ success: success$2,
13173
+ warning: warning$2
13124
13174
  };
13125
13175
  const cssModules$k = {
13126
13176
  "$style": style0$k
@@ -13129,6 +13179,7 @@ const __unplugin_components_2 = /* @__PURE__ */ _export_sfc$1(_sfc_main$q, [["__
13129
13179
  const _hoisted_1$8 = { key: 1 };
13130
13180
  const _hoisted_2$4 = ["textContent"];
13131
13181
  const _hoisted_3$2 = { key: 3 };
13182
+ const _hoisted_4$1 = { key: 5 };
13132
13183
  const _sfc_main$p = /* @__PURE__ */ defineComponent({
13133
13184
  __name: "CanvasNodeStatusIcons",
13134
13185
  setup(__props) {
@@ -13143,18 +13194,21 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
13143
13194
  executionRunningThrottled,
13144
13195
  hasRunData,
13145
13196
  runDataIterations,
13146
- isDisabled
13197
+ isDisabled,
13198
+ render: render2
13147
13199
  } = useCanvasNode();
13148
13200
  const hideNodeIssues = computed(() => false);
13201
+ const dirtiness = computed(
13202
+ () => render2.value.type === CanvasNodeRenderType.Default ? render2.value.options.dirtiness : void 0
13203
+ );
13149
13204
  return (_ctx, _cache) => {
13150
13205
  const _component_FontAwesomeIcon = resolveComponent("FontAwesomeIcon");
13151
- const _component_N8nTooltip = resolveComponent("N8nTooltip");
13152
13206
  return unref(hasIssues) && !hideNodeIssues.value ? (openBlock(), createElementBlock("div", {
13153
13207
  key: 0,
13154
13208
  class: normalizeClass([_ctx.$style.status, _ctx.$style.issues]),
13155
13209
  "data-test-id": "node-issues"
13156
13210
  }, [
13157
- createVNode(_component_N8nTooltip, {
13211
+ createVNode(unref(N8nTooltip), {
13158
13212
  "show-after": 500,
13159
13213
  placement: "bottom"
13160
13214
  }, {
@@ -13173,7 +13227,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
13173
13227
  createBaseVNode("div", {
13174
13228
  class: normalizeClass([_ctx.$style.status, _ctx.$style.waiting])
13175
13229
  }, [
13176
- createVNode(_component_N8nTooltip, { placement: "bottom" }, {
13230
+ createVNode(unref(N8nTooltip), { placement: "bottom" }, {
13177
13231
  content: withCtx(() => [
13178
13232
  createBaseVNode("div", {
13179
13233
  textContent: toDisplayString(unref(executionWaiting))
@@ -13208,8 +13262,32 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
13208
13262
  icon: "sync-alt",
13209
13263
  spin: ""
13210
13264
  })
13211
- ], 2)) : unref(hasRunData) ? (openBlock(), createElementBlock("div", {
13212
- key: 5,
13265
+ ], 2)) : dirtiness.value !== void 0 ? (openBlock(), createElementBlock("div", _hoisted_4$1, [
13266
+ createVNode(unref(N8nTooltip), {
13267
+ "show-after": 500,
13268
+ placement: "bottom"
13269
+ }, {
13270
+ content: withCtx(() => [
13271
+ createTextVNode(toDisplayString(unref(i18n).baseText(
13272
+ dirtiness.value === unref(CanvasNodeDirtiness).PARAMETERS_UPDATED ? "node.dirty" : "node.subjectToChange"
13273
+ )), 1)
13274
+ ]),
13275
+ default: withCtx(() => [
13276
+ createBaseVNode("div", {
13277
+ "data-test-id": "canvas-node-status-warning",
13278
+ class: normalizeClass([_ctx.$style.status, _ctx.$style.warning])
13279
+ }, [
13280
+ createVNode(_component_FontAwesomeIcon, { icon: "triangle" }),
13281
+ unref(runDataIterations) > 1 ? (openBlock(), createElementBlock("span", {
13282
+ key: 0,
13283
+ class: normalizeClass(_ctx.$style.count)
13284
+ }, toDisplayString(unref(runDataIterations)), 3)) : createCommentVNode("", true)
13285
+ ], 2)
13286
+ ]),
13287
+ _: 1
13288
+ })
13289
+ ])) : unref(hasRunData) ? (openBlock(), createElementBlock("div", {
13290
+ key: 6,
13213
13291
  "data-test-id": "canvas-node-status-success",
13214
13292
  class: normalizeClass([_ctx.$style.status, _ctx.$style.runData])
13215
13293
  }, [
@@ -13222,22 +13300,24 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
13222
13300
  };
13223
13301
  }
13224
13302
  });
13225
- const status = "_status_f7q46_123";
13226
- const runData = "_runData_f7q46_129";
13227
- const waiting$1 = "_waiting_f7q46_134";
13228
- const pinnedData = "_pinnedData_f7q46_138";
13229
- const running$1 = "_running_f7q46_142";
13230
- const issues = "_issues_f7q46_165";
13231
- const count = "_count_f7q46_170";
13303
+ const status = "_status_1slg1_123";
13304
+ const runData = "_runData_1slg1_130";
13305
+ const waiting$1 = "_waiting_1slg1_134";
13306
+ const pinnedData = "_pinnedData_1slg1_138";
13307
+ const running$1 = "_running_1slg1_142";
13308
+ const issues = "_issues_1slg1_165";
13309
+ const count = "_count_1slg1_170";
13310
+ const warning$1 = "_warning_1slg1_174";
13232
13311
  const style0$j = {
13233
13312
  status,
13234
13313
  runData,
13235
13314
  waiting: waiting$1,
13236
13315
  pinnedData,
13237
13316
  running: running$1,
13238
- "node-waiting-spinner": "_node-waiting-spinner_f7q46_152",
13317
+ "node-waiting-spinner": "_node-waiting-spinner_1slg1_152",
13239
13318
  issues,
13240
- count
13319
+ count,
13320
+ warning: warning$1
13241
13321
  };
13242
13322
  const cssModules$j = {
13243
13323
  "$style": style0$j
@@ -13341,13 +13421,14 @@ function useNodeConnections({
13341
13421
  const _hoisted_1$7 = ["data-test-id"];
13342
13422
  const _sfc_main$n = /* @__PURE__ */ defineComponent({
13343
13423
  __name: "CanvasNodeDefault",
13344
- emits: ["open:contextmenu"],
13424
+ emits: ["open:contextmenu", "activate"],
13345
13425
  setup(__props, { emit: __emit }) {
13346
13426
  const $style = useCssModule();
13347
13427
  const i18n = useI18n();
13348
13428
  const emit = __emit;
13349
13429
  const { initialized, viewport } = useCanvas();
13350
13430
  const {
13431
+ id: id2,
13351
13432
  label: label2,
13352
13433
  subtitle: subtitle2,
13353
13434
  inputs: inputs2,
@@ -13388,7 +13469,8 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
13388
13469
  [$style.running]: executionRunning.value,
13389
13470
  [$style.configurable]: renderOptions.value.configurable,
13390
13471
  [$style.configuration]: renderOptions.value.configuration,
13391
- [$style.trigger]: renderOptions.value.trigger
13472
+ [$style.trigger]: renderOptions.value.trigger,
13473
+ [$style.warning]: renderOptions.value.dirtiness !== void 0
13392
13474
  };
13393
13475
  });
13394
13476
  const styles = computed(() => {
@@ -13432,6 +13514,9 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
13432
13514
  function openContextMenu(event) {
13433
13515
  emit("open:contextmenu", event);
13434
13516
  }
13517
+ function onActivate() {
13518
+ emit("activate", id2.value);
13519
+ }
13435
13520
  return (_ctx, _cache) => {
13436
13521
  const _component_CanvasNodeTooltip = __unplugin_components_0$4;
13437
13522
  const _component_CanvasNodeStatusIcons = __unplugin_components_1;
@@ -13440,7 +13525,8 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
13440
13525
  class: normalizeClass(classes.value),
13441
13526
  style: normalizeStyle(styles.value),
13442
13527
  "data-test-id": dataTestId.value,
13443
- onContextmenu: openContextMenu
13528
+ onContextmenu: openContextMenu,
13529
+ onDblclick: withModifiers(onActivate, ["stop"])
13444
13530
  }, [
13445
13531
  renderOptions.value.tooltip ? (openBlock(), createBlock(_component_CanvasNodeTooltip, {
13446
13532
  key: 0,
@@ -13472,22 +13558,23 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
13472
13558
  };
13473
13559
  }
13474
13560
  });
13475
- const node = "_node_uhfie_123";
13476
- const trigger$1 = "_trigger_uhfie_155";
13477
- const configuration = "_configuration_uhfie_158";
13478
- const statusIcons = "_statusIcons_uhfie_165";
13479
- const configurable = "_configurable_uhfie_168";
13480
- const description = "_description_uhfie_179";
13481
- const label$5 = "_label_uhfie_189";
13482
- const subtitle = "_subtitle_uhfie_192";
13483
- const selected$1 = "_selected_uhfie_202";
13484
- const success$1 = "_success_uhfie_205";
13485
- const error = "_error_uhfie_208";
13486
- const pinned = "_pinned_uhfie_211";
13487
- const disabled = "_disabled_uhfie_214";
13488
- const running = "_running_uhfie_217";
13489
- const waiting = "_waiting_uhfie_221";
13490
- const disabledLabel = "_disabledLabel_uhfie_238";
13561
+ const node = "_node_1ektz_123";
13562
+ const trigger$1 = "_trigger_1ektz_155";
13563
+ const configuration = "_configuration_1ektz_158";
13564
+ const statusIcons = "_statusIcons_1ektz_165";
13565
+ const configurable = "_configurable_1ektz_168";
13566
+ const description = "_description_1ektz_179";
13567
+ const label$5 = "_label_1ektz_189";
13568
+ const subtitle = "_subtitle_1ektz_192";
13569
+ const selected$1 = "_selected_1ektz_202";
13570
+ const success$1 = "_success_1ektz_205";
13571
+ const warning = "_warning_1ektz_208";
13572
+ const error = "_error_1ektz_211";
13573
+ const pinned = "_pinned_1ektz_214";
13574
+ const disabled = "_disabled_1ektz_217";
13575
+ const running = "_running_1ektz_220";
13576
+ const waiting = "_waiting_1ektz_224";
13577
+ const disabledLabel = "_disabledLabel_1ektz_241";
13491
13578
  const style0$h = {
13492
13579
  node,
13493
13580
  trigger: trigger$1,
@@ -13499,6 +13586,7 @@ const style0$h = {
13499
13586
  subtitle,
13500
13587
  selected: selected$1,
13501
13588
  success: success$1,
13589
+ warning,
13502
13590
  error,
13503
13591
  pinned,
13504
13592
  disabled,
@@ -13975,14 +14063,14 @@ ClassList.prototype = {
13975
14063
  }
13976
14064
  };
13977
14065
  function classedAdd(node2, names) {
13978
- var list = classList(node2), i = -1, n = names.length;
14066
+ var list2 = classList(node2), i = -1, n = names.length;
13979
14067
  while (++i < n)
13980
- list.add(names[i]);
14068
+ list2.add(names[i]);
13981
14069
  }
13982
14070
  function classedRemove(node2, names) {
13983
- var list = classList(node2), i = -1, n = names.length;
14071
+ var list2 = classList(node2), i = -1, n = names.length;
13984
14072
  while (++i < n)
13985
- list.remove(names[i]);
14073
+ list2.remove(names[i]);
13986
14074
  }
13987
14075
  function classedTrue(names) {
13988
14076
  return function() {
@@ -14002,9 +14090,9 @@ function classedFunction(names, value) {
14002
14090
  function selection_classed(name, value) {
14003
14091
  var names = classArray(name + "");
14004
14092
  if (arguments.length < 2) {
14005
- var list = classList(this.node()), i = -1, n = names.length;
14093
+ var list2 = classList(this.node()), i = -1, n = names.length;
14006
14094
  while (++i < n)
14007
- if (!list.contains(names[i]))
14095
+ if (!list2.contains(names[i]))
14008
14096
  return false;
14009
14097
  return true;
14010
14098
  }
@@ -14907,7 +14995,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
14907
14995
  inheritAttrs: false
14908
14996
  },
14909
14997
  __name: "CanvasNodeStickyNote",
14910
- emits: ["update", "move", "dblclick", "open:contextmenu"],
14998
+ emits: ["update", "move", "activate", "deactivate", "open:contextmenu"],
14911
14999
  setup(__props, { emit: __emit }) {
14912
15000
  const emit = __emit;
14913
15001
  const $style = useCssModule();
@@ -14935,23 +15023,26 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
14935
15023
  content: value
14936
15024
  });
14937
15025
  }
14938
- function onEdit(edit) {
14939
- isActive.value = edit;
14940
- }
14941
- function onDoubleClick(event) {
14942
- emit("dblclick", event);
15026
+ function onSetActive(value) {
15027
+ if (isActive.value === value) return;
15028
+ isActive.value = value;
15029
+ if (value) {
15030
+ emit("activate", id2.value);
15031
+ } else {
15032
+ emit("deactivate", id2.value);
15033
+ }
14943
15034
  }
14944
15035
  function onActivate() {
14945
- onEdit(true);
15036
+ onSetActive(true);
14946
15037
  }
14947
15038
  function openContextMenu(event) {
14948
15039
  emit("open:contextmenu", event);
14949
15040
  }
14950
15041
  onMounted(() => {
14951
- eventBus.value?.on("update:node:active", onActivate);
15042
+ eventBus.value?.on("update:node:activated", onActivate);
14952
15043
  });
14953
15044
  onBeforeUnmount(() => {
14954
- eventBus.value?.off("update:node:active", onActivate);
15045
+ eventBus.value?.off("update:node:activated", onActivate);
14955
15046
  });
14956
15047
  return (_ctx, _cache) => {
14957
15048
  const _component_N8nSticky = resolveComponent("N8nSticky");
@@ -14974,8 +15065,8 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
14974
15065
  "background-color": renderOptions.value.color,
14975
15066
  "edit-mode": isActive.value,
14976
15067
  "read-only": unref(isReadOnly),
14977
- onEdit,
14978
- onDblclick: onDoubleClick,
15068
+ onEdit: onSetActive,
15069
+ onDblclick: withModifiers(onActivate, ["stop"]),
14979
15070
  "onUpdate:modelValue": onInputChange,
14980
15071
  onContextmenu: openContextMenu
14981
15072
  }), null, 16, ["id", "class", "height", "width", "model-value", "background-color", "edit-mode", "read-only"])
@@ -15432,12 +15523,12 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
15432
15523
  };
15433
15524
  }
15434
15525
  });
15435
- const handle$3 = "_handle_19arw_123";
15436
- const connected = "_connected_19arw_129";
15437
- const label$2 = "_label_19arw_129";
15438
- const required$2 = "_required_19arw_143";
15439
- const outputLabel = "_outputLabel_19arw_148";
15440
- const runDataLabel = "_runDataLabel_19arw_156";
15526
+ const handle$3 = "_handle_1u904_123";
15527
+ const connected = "_connected_1u904_129";
15528
+ const label$2 = "_label_1u904_129";
15529
+ const required$2 = "_required_1u904_143";
15530
+ const outputLabel = "_outputLabel_1u904_148";
15531
+ const runDataLabel = "_runDataLabel_1u904_156";
15441
15532
  const style0$a = {
15442
15533
  handle: handle$3,
15443
15534
  connected,
@@ -15793,6 +15884,16 @@ const useContextMenu = (onAction = () => {
15793
15884
  disabled: nodes.length === 0
15794
15885
  }
15795
15886
  ];
15887
+ const layoutActions = [
15888
+ {
15889
+ id: "tidy_up",
15890
+ divided: true,
15891
+ label: i18n.baseText(
15892
+ nodes.length < 2 ? "contextMenu.tidyUpWorkflow" : "contextMenu.tidyUpSelection"
15893
+ ),
15894
+ shortcut: { shiftKey: true, altKey: true, keys: ["T"] }
15895
+ }
15896
+ ];
15796
15897
  if (nodes.length === 0) {
15797
15898
  actions.value = [
15798
15899
  {
@@ -15807,6 +15908,7 @@ const useContextMenu = (onAction = () => {
15807
15908
  label: i18n.baseText("contextMenu.addSticky"),
15808
15909
  disabled: isReadOnly.value
15809
15910
  },
15911
+ ...layoutActions,
15810
15912
  ...selectionActions
15811
15913
  ];
15812
15914
  } else {
@@ -15834,6 +15936,7 @@ const useContextMenu = (onAction = () => {
15834
15936
  shortcut: { metaKey: true, keys: ["D"] },
15835
15937
  disabled: isReadOnly.value || !nodes.every(canDuplicateNode)
15836
15938
  },
15939
+ ...layoutActions,
15837
15940
  ...selectionActions,
15838
15941
  {
15839
15942
  id: "delete",
@@ -16011,7 +16114,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
16011
16114
  hovered: { type: Boolean },
16012
16115
  nearbyHovered: { type: Boolean }
16013
16116
  },
16014
- emits: ["add", "delete", "run", "select", "toggle", "activate", "open:contextmenu", "update", "update:inputs", "update:outputs", "move"],
16117
+ emits: ["add", "delete", "run", "select", "toggle", "activate", "deactivate", "open:contextmenu", "update", "update:inputs", "update:outputs", "move"],
16015
16118
  setup(__props, { emit: __emit }) {
16016
16119
  const slots = useSlots();
16017
16120
  const emit = __emit;
@@ -16137,6 +16240,9 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
16137
16240
  function onActivate() {
16138
16241
  emit("activate", props.id);
16139
16242
  }
16243
+ function onDeactivate() {
16244
+ emit("deactivate", props.id);
16245
+ }
16140
16246
  function onOpenContextMenuFromToolbar(event) {
16141
16247
  emit("open:contextmenu", props.id, event, "node-button");
16142
16248
  }
@@ -16247,13 +16353,14 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
16247
16353
  "onOpen:contextmenu": onOpenContextMenuFromToolbar
16248
16354
  }, null, 8, ["read-only", "class"])) : createCommentVNode("", true),
16249
16355
  createVNode(_sfc_main$j, {
16250
- onDblclick: withModifiers(onActivate, ["stop"]),
16356
+ onActivate,
16357
+ onDeactivate,
16251
16358
  onMove,
16252
16359
  onUpdate,
16253
16360
  "onOpen:contextmenu": onOpenContextMenuFromNode
16254
16361
  }, {
16255
16362
  default: withCtx(() => [
16256
- createVNode(_sfc_main$y, {
16363
+ createVNode(_sfc_main$z, {
16257
16364
  "node-type": nodeTypeDescription.value,
16258
16365
  size: nodeIconSize.value,
16259
16366
  shrink: false,
@@ -16441,7 +16548,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
16441
16548
  }));
16442
16549
  const edgeLabelStyle = computed(() => ({
16443
16550
  transform: `translate(0, ${isConnectorStraight.value ? "-100%" : "0%"})`,
16444
- color: edgeColor.value
16551
+ color: "var(--color-text-base)"
16445
16552
  }));
16446
16553
  const isConnectorStraight = computed(() => renderData.value.isConnectorStraight);
16447
16554
  const edgeToolbarStyle = computed(() => ({
@@ -17043,194 +17150,4042 @@ function useCanvasNodeHover(nodesRef, store, getHitBox) {
17043
17150
  });
17044
17151
  return { id: id2 };
17045
17152
  }
17046
- const renameKeyCode = " ";
17047
- const defaultZoom = 1;
17048
- const minimapVisibilityDelay = 1e3;
17049
- const _sfc_main = /* @__PURE__ */ defineComponent({
17050
- __name: "Canvas",
17051
- props: {
17052
- id: { default: "canvas" },
17053
- nodes: { default: () => [] },
17054
- connections: { default: () => [] },
17055
- controlsPosition: { default: PanelPosition.BottomLeft },
17056
- eventBus: { default: () => createEventBus() },
17057
- readOnly: { type: Boolean, default: false },
17058
- executing: { type: Boolean, default: false },
17059
- keyBindings: { type: Boolean, default: true },
17060
- loading: { type: Boolean, default: false }
17061
- },
17062
- emits: ["update:modelValue", "update:node:position", "update:nodes:position", "update:node:active", "update:node:enabled", "update:node:selected", "update:node:name", "update:node:parameters", "update:node:inputs", "update:node:outputs", "click:node", "click:node:add", "run:node", "delete:node", "create:node", "create:sticky", "delete:nodes", "update:nodes:enabled", "copy:nodes", "duplicate:nodes", "update:nodes:pin", "cut:nodes", "delete:connection", "create:connection:start", "create:connection", "create:connection:end", "create:connection:cancelled", "click:connection:add", "click:pane", "run:workflow", "save:workflow", "create:workflow", "drag-and-drop"],
17063
- setup(__props, { emit: __emit }) {
17064
- const $style = useCssModule();
17065
- const emit = __emit;
17066
- const props = __props;
17067
- const { isMobileDevice, controlKeyCode } = useDeviceSupport();
17068
- const vueFlow = useVueFlow({ id: props.id, deleteKeyCode: null });
17069
- const {
17070
- getSelectedNodes: selectedNodes,
17071
- addSelectedNodes,
17072
- removeSelectedNodes,
17073
- viewportRef,
17074
- fitView,
17075
- zoomIn,
17076
- zoomOut,
17077
- zoomTo,
17078
- setInteractive,
17079
- elementsSelectable,
17080
- project,
17081
- nodes: graphNodes,
17082
- onPaneReady,
17083
- onNodesInitialized,
17084
- findNode,
17085
- viewport,
17086
- onEdgeMouseLeave,
17087
- onEdgeMouseEnter,
17088
- onEdgeMouseMove,
17089
- onNodeMouseEnter,
17090
- onNodeMouseLeave
17091
- } = vueFlow;
17092
- const {
17093
- getIncomingNodes,
17094
- getOutgoingNodes,
17095
- getSiblingNodes,
17096
- getDownstreamNodes,
17097
- getUpstreamNodes
17098
- } = useCanvasTraversal(vueFlow);
17099
- const isPaneReady = ref(false);
17100
- const classes = computed(() => ({
17101
- [$style.canvas]: true,
17102
- [$style.ready]: !props.loading && isPaneReady.value
17103
- }));
17104
- const panningKeyCode = ref(isMobileDevice ? true : [" ", controlKeyCode]);
17105
- const panningMouseButton = ref(isMobileDevice ? true : [1]);
17106
- const selectionKeyCode = ref(isMobileDevice ? "Shift" : true);
17107
- function switchToPanningMode() {
17108
- selectionKeyCode.value = null;
17109
- panningMouseButton.value = [0, 1];
17153
+ var graph;
17154
+ var hasRequiredGraph;
17155
+ function requireGraph() {
17156
+ if (hasRequiredGraph) return graph;
17157
+ hasRequiredGraph = 1;
17158
+ var DEFAULT_EDGE_NAME = "\0";
17159
+ var GRAPH_NODE = "\0";
17160
+ var EDGE_KEY_DELIM = "";
17161
+ class Graph {
17162
+ _isDirected = true;
17163
+ _isMultigraph = false;
17164
+ _isCompound = false;
17165
+ // Label for the graph itself
17166
+ _label;
17167
+ // Defaults to be set when creating a new node
17168
+ _defaultNodeLabelFn = () => void 0;
17169
+ // Defaults to be set when creating a new edge
17170
+ _defaultEdgeLabelFn = () => void 0;
17171
+ // v -> label
17172
+ _nodes = {};
17173
+ // v -> edgeObj
17174
+ _in = {};
17175
+ // u -> v -> Number
17176
+ _preds = {};
17177
+ // v -> edgeObj
17178
+ _out = {};
17179
+ // v -> w -> Number
17180
+ _sucs = {};
17181
+ // e -> edgeObj
17182
+ _edgeObjs = {};
17183
+ // e -> label
17184
+ _edgeLabels = {};
17185
+ /* Number of nodes in the graph. Should only be changed by the implementation. */
17186
+ _nodeCount = 0;
17187
+ /* Number of edges in the graph. Should only be changed by the implementation. */
17188
+ _edgeCount = 0;
17189
+ _parent;
17190
+ _children;
17191
+ constructor(opts) {
17192
+ if (opts) {
17193
+ this._isDirected = Object.hasOwn(opts, "directed") ? opts.directed : true;
17194
+ this._isMultigraph = Object.hasOwn(opts, "multigraph") ? opts.multigraph : false;
17195
+ this._isCompound = Object.hasOwn(opts, "compound") ? opts.compound : false;
17196
+ }
17197
+ if (this._isCompound) {
17198
+ this._parent = {};
17199
+ this._children = {};
17200
+ this._children[GRAPH_NODE] = {};
17201
+ }
17202
+ }
17203
+ /* === Graph functions ========= */
17204
+ /**
17205
+ * Whether graph was created with 'directed' flag set to true or not.
17206
+ */
17207
+ isDirected() {
17208
+ return this._isDirected;
17209
+ }
17210
+ /**
17211
+ * Whether graph was created with 'multigraph' flag set to true or not.
17212
+ */
17213
+ isMultigraph() {
17214
+ return this._isMultigraph;
17215
+ }
17216
+ /**
17217
+ * Whether graph was created with 'compound' flag set to true or not.
17218
+ */
17219
+ isCompound() {
17220
+ return this._isCompound;
17221
+ }
17222
+ /**
17223
+ * Sets the label of the graph.
17224
+ */
17225
+ setGraph(label2) {
17226
+ this._label = label2;
17227
+ return this;
17110
17228
  }
17111
- function switchToSelectionMode() {
17112
- selectionKeyCode.value = true;
17113
- panningMouseButton.value = [1];
17229
+ /**
17230
+ * Gets the graph label.
17231
+ */
17232
+ graph() {
17233
+ return this._label;
17234
+ }
17235
+ /* === Node functions ========== */
17236
+ /**
17237
+ * Sets the default node label. If newDefault is a function, it will be
17238
+ * invoked ach time when setting a label for a node. Otherwise, this label
17239
+ * will be assigned as default label in case if no label was specified while
17240
+ * setting a node.
17241
+ * Complexity: O(1).
17242
+ */
17243
+ setDefaultNodeLabel(newDefault) {
17244
+ this._defaultNodeLabelFn = newDefault;
17245
+ if (typeof newDefault !== "function") {
17246
+ this._defaultNodeLabelFn = () => newDefault;
17247
+ }
17248
+ return this;
17114
17249
  }
17115
- onKeyDown(panningKeyCode.value, switchToPanningMode, {
17116
- dedupe: true
17117
- });
17118
- onKeyUp(panningKeyCode.value, switchToSelectionMode);
17119
- useShortKeyPress(
17120
- renameKeyCode,
17121
- () => {
17122
- if (lastSelectedNode.value) {
17123
- emit("update:node:name", lastSelectedNode.value.id);
17250
+ /**
17251
+ * Gets the number of nodes in the graph.
17252
+ * Complexity: O(1).
17253
+ */
17254
+ nodeCount() {
17255
+ return this._nodeCount;
17256
+ }
17257
+ /**
17258
+ * Gets all nodes of the graph. Note, the in case of compound graph subnodes are
17259
+ * not included in list.
17260
+ * Complexity: O(1).
17261
+ */
17262
+ nodes() {
17263
+ return Object.keys(this._nodes);
17264
+ }
17265
+ /**
17266
+ * Gets list of nodes without in-edges.
17267
+ * Complexity: O(|V|).
17268
+ */
17269
+ sources() {
17270
+ var self = this;
17271
+ return this.nodes().filter((v) => Object.keys(self._in[v]).length === 0);
17272
+ }
17273
+ /**
17274
+ * Gets list of nodes without out-edges.
17275
+ * Complexity: O(|V|).
17276
+ */
17277
+ sinks() {
17278
+ var self = this;
17279
+ return this.nodes().filter((v) => Object.keys(self._out[v]).length === 0);
17280
+ }
17281
+ /**
17282
+ * Invokes setNode method for each node in names list.
17283
+ * Complexity: O(|names|).
17284
+ */
17285
+ setNodes(vs, value) {
17286
+ var args = arguments;
17287
+ var self = this;
17288
+ vs.forEach(function(v) {
17289
+ if (args.length > 1) {
17290
+ self.setNode(v, value);
17291
+ } else {
17292
+ self.setNode(v);
17124
17293
  }
17125
- },
17126
- {
17127
- disabled: toRef(props, "readOnly")
17294
+ });
17295
+ return this;
17296
+ }
17297
+ /**
17298
+ * Creates or updates the value for the node v in the graph. If label is supplied
17299
+ * it is set as the value for the node. If label is not supplied and the node was
17300
+ * created by this call then the default node label will be assigned.
17301
+ * Complexity: O(1).
17302
+ */
17303
+ setNode(v, value) {
17304
+ if (Object.hasOwn(this._nodes, v)) {
17305
+ if (arguments.length > 1) {
17306
+ this._nodes[v] = value;
17307
+ }
17308
+ return this;
17309
+ }
17310
+ this._nodes[v] = arguments.length > 1 ? value : this._defaultNodeLabelFn(v);
17311
+ if (this._isCompound) {
17312
+ this._parent[v] = GRAPH_NODE;
17313
+ this._children[v] = {};
17314
+ this._children[GRAPH_NODE][v] = true;
17315
+ }
17316
+ this._in[v] = {};
17317
+ this._preds[v] = {};
17318
+ this._out[v] = {};
17319
+ this._sucs[v] = {};
17320
+ ++this._nodeCount;
17321
+ return this;
17322
+ }
17323
+ /**
17324
+ * Gets the label of node with specified name.
17325
+ * Complexity: O(|V|).
17326
+ */
17327
+ node(v) {
17328
+ return this._nodes[v];
17329
+ }
17330
+ /**
17331
+ * Detects whether graph has a node with specified name or not.
17332
+ */
17333
+ hasNode(v) {
17334
+ return Object.hasOwn(this._nodes, v);
17335
+ }
17336
+ /**
17337
+ * Remove the node with the name from the graph or do nothing if the node is not in
17338
+ * the graph. If the node was removed this function also removes any incident
17339
+ * edges.
17340
+ * Complexity: O(1).
17341
+ */
17342
+ removeNode(v) {
17343
+ var self = this;
17344
+ if (Object.hasOwn(this._nodes, v)) {
17345
+ var removeEdge = (e) => self.removeEdge(self._edgeObjs[e]);
17346
+ delete this._nodes[v];
17347
+ if (this._isCompound) {
17348
+ this._removeFromParentsChildList(v);
17349
+ delete this._parent[v];
17350
+ this.children(v).forEach(function(child) {
17351
+ self.setParent(child);
17352
+ });
17353
+ delete this._children[v];
17354
+ }
17355
+ Object.keys(this._in[v]).forEach(removeEdge);
17356
+ delete this._in[v];
17357
+ delete this._preds[v];
17358
+ Object.keys(this._out[v]).forEach(removeEdge);
17359
+ delete this._out[v];
17360
+ delete this._sucs[v];
17361
+ --this._nodeCount;
17128
17362
  }
17129
- );
17130
- const disableKeyBindings = computed(() => !props.keyBindings);
17131
- function selectLeftNode(id2) {
17132
- const incomingNodes = getIncomingNodes(id2);
17133
- const previousNode = incomingNodes[0];
17134
- if (previousNode) {
17135
- onSelectNodes({ ids: [previousNode.id] });
17363
+ return this;
17364
+ }
17365
+ /**
17366
+ * Sets node p as a parent for node v if it is defined, or removes the
17367
+ * parent for v if p is undefined. Method throws an exception in case of
17368
+ * invoking it in context of noncompound graph.
17369
+ * Average-case complexity: O(1).
17370
+ */
17371
+ setParent(v, parent) {
17372
+ if (!this._isCompound) {
17373
+ throw new Error("Cannot set parent in a non-compound graph");
17374
+ }
17375
+ if (parent === void 0) {
17376
+ parent = GRAPH_NODE;
17377
+ } else {
17378
+ parent += "";
17379
+ for (var ancestor = parent; ancestor !== void 0; ancestor = this.parent(ancestor)) {
17380
+ if (ancestor === v) {
17381
+ throw new Error("Setting " + parent + " as parent of " + v + " would create a cycle");
17382
+ }
17383
+ }
17384
+ this.setNode(parent);
17136
17385
  }
17386
+ this.setNode(v);
17387
+ this._removeFromParentsChildList(v);
17388
+ this._parent[v] = parent;
17389
+ this._children[parent][v] = true;
17390
+ return this;
17137
17391
  }
17138
- function selectRightNode(id2) {
17139
- const outgoingNodes = getOutgoingNodes(id2);
17140
- const nextNode = outgoingNodes[0];
17141
- if (nextNode) {
17142
- onSelectNodes({ ids: [nextNode.id] });
17392
+ _removeFromParentsChildList(v) {
17393
+ delete this._children[this._parent[v]][v];
17394
+ }
17395
+ /**
17396
+ * Gets parent node for node v.
17397
+ * Complexity: O(1).
17398
+ */
17399
+ parent(v) {
17400
+ if (this._isCompound) {
17401
+ var parent = this._parent[v];
17402
+ if (parent !== GRAPH_NODE) {
17403
+ return parent;
17404
+ }
17143
17405
  }
17144
17406
  }
17145
- function selectLowerSiblingNode(id2) {
17146
- const siblingNodes = getSiblingNodes(id2);
17147
- const index = siblingNodes.findIndex((n) => n.id === id2);
17148
- const nextNode = siblingNodes[index + 1] ?? siblingNodes[0];
17149
- if (nextNode) {
17150
- onSelectNodes({
17151
- ids: [nextNode.id]
17152
- });
17407
+ /**
17408
+ * Gets list of direct children of node v.
17409
+ * Complexity: O(1).
17410
+ */
17411
+ children(v = GRAPH_NODE) {
17412
+ if (this._isCompound) {
17413
+ var children2 = this._children[v];
17414
+ if (children2) {
17415
+ return Object.keys(children2);
17416
+ }
17417
+ } else if (v === GRAPH_NODE) {
17418
+ return this.nodes();
17419
+ } else if (this.hasNode(v)) {
17420
+ return [];
17421
+ }
17422
+ }
17423
+ /**
17424
+ * Return all nodes that are predecessors of the specified node or undefined if node v is not in
17425
+ * the graph. Behavior is undefined for undirected graphs - use neighbors instead.
17426
+ * Complexity: O(|V|).
17427
+ */
17428
+ predecessors(v) {
17429
+ var predsV = this._preds[v];
17430
+ if (predsV) {
17431
+ return Object.keys(predsV);
17432
+ }
17433
+ }
17434
+ /**
17435
+ * Return all nodes that are successors of the specified node or undefined if node v is not in
17436
+ * the graph. Behavior is undefined for undirected graphs - use neighbors instead.
17437
+ * Complexity: O(|V|).
17438
+ */
17439
+ successors(v) {
17440
+ var sucsV = this._sucs[v];
17441
+ if (sucsV) {
17442
+ return Object.keys(sucsV);
17443
+ }
17444
+ }
17445
+ /**
17446
+ * Return all nodes that are predecessors or successors of the specified node or undefined if
17447
+ * node v is not in the graph.
17448
+ * Complexity: O(|V|).
17449
+ */
17450
+ neighbors(v) {
17451
+ var preds = this.predecessors(v);
17452
+ if (preds) {
17453
+ const union = new Set(preds);
17454
+ for (var succ of this.successors(v)) {
17455
+ union.add(succ);
17456
+ }
17457
+ return Array.from(union.values());
17153
17458
  }
17154
17459
  }
17155
- function selectUpperSiblingNode(id2) {
17156
- const siblingNodes = getSiblingNodes(id2);
17157
- const index = siblingNodes.findIndex((n) => n.id === id2);
17158
- const previousNode = siblingNodes[index - 1] ?? siblingNodes[siblingNodes.length - 1];
17159
- if (previousNode) {
17160
- onSelectNodes({
17161
- ids: [previousNode.id]
17162
- });
17460
+ isLeaf(v) {
17461
+ var neighbors;
17462
+ if (this.isDirected()) {
17463
+ neighbors = this.successors(v);
17464
+ } else {
17465
+ neighbors = this.neighbors(v);
17466
+ }
17467
+ return neighbors.length === 0;
17468
+ }
17469
+ /**
17470
+ * Creates new graph with nodes filtered via filter. Edges incident to rejected node
17471
+ * are also removed. In case of compound graph, if parent is rejected by filter,
17472
+ * than all its children are rejected too.
17473
+ * Average-case complexity: O(|E|+|V|).
17474
+ */
17475
+ filterNodes(filter2) {
17476
+ var copy = new this.constructor({
17477
+ directed: this._isDirected,
17478
+ multigraph: this._isMultigraph,
17479
+ compound: this._isCompound
17480
+ });
17481
+ copy.setGraph(this.graph());
17482
+ var self = this;
17483
+ Object.entries(this._nodes).forEach(function([v, value]) {
17484
+ if (filter2(v)) {
17485
+ copy.setNode(v, value);
17486
+ }
17487
+ });
17488
+ Object.values(this._edgeObjs).forEach(function(e) {
17489
+ if (copy.hasNode(e.v) && copy.hasNode(e.w)) {
17490
+ copy.setEdge(e, self.edge(e));
17491
+ }
17492
+ });
17493
+ var parents = {};
17494
+ function findParent(v) {
17495
+ var parent = self.parent(v);
17496
+ if (parent === void 0 || copy.hasNode(parent)) {
17497
+ parents[v] = parent;
17498
+ return parent;
17499
+ } else if (parent in parents) {
17500
+ return parents[parent];
17501
+ } else {
17502
+ return findParent(parent);
17503
+ }
17504
+ }
17505
+ if (this._isCompound) {
17506
+ copy.nodes().forEach((v) => copy.setParent(v, findParent(v)));
17163
17507
  }
17508
+ return copy;
17164
17509
  }
17165
- function selectDownstreamNodes(id2) {
17166
- const downstreamNodes = getDownstreamNodes(id2);
17167
- onSelectNodes({ ids: [...downstreamNodes.map((node2) => node2.id), id2] });
17510
+ /* === Edge functions ========== */
17511
+ /**
17512
+ * Sets the default edge label or factory function. This label will be
17513
+ * assigned as default label in case if no label was specified while setting
17514
+ * an edge or this function will be invoked each time when setting an edge
17515
+ * with no label specified and returned value * will be used as a label for edge.
17516
+ * Complexity: O(1).
17517
+ */
17518
+ setDefaultEdgeLabel(newDefault) {
17519
+ this._defaultEdgeLabelFn = newDefault;
17520
+ if (typeof newDefault !== "function") {
17521
+ this._defaultEdgeLabelFn = () => newDefault;
17522
+ }
17523
+ return this;
17168
17524
  }
17169
- function selectUpstreamNodes(id2) {
17170
- const upstreamNodes = getUpstreamNodes(id2);
17171
- onSelectNodes({ ids: [...upstreamNodes.map((node2) => node2.id), id2] });
17525
+ /**
17526
+ * Gets the number of edges in the graph.
17527
+ * Complexity: O(1).
17528
+ */
17529
+ edgeCount() {
17530
+ return this._edgeCount;
17531
+ }
17532
+ /**
17533
+ * Gets edges of the graph. In case of compound graph subgraphs are not considered.
17534
+ * Complexity: O(|E|).
17535
+ */
17536
+ edges() {
17537
+ return Object.values(this._edgeObjs);
17538
+ }
17539
+ /**
17540
+ * Establish an edges path over the nodes in nodes list. If some edge is already
17541
+ * exists, it will update its label, otherwise it will create an edge between pair
17542
+ * of nodes with label provided or default label if no label provided.
17543
+ * Complexity: O(|nodes|).
17544
+ */
17545
+ setPath(vs, value) {
17546
+ var self = this;
17547
+ var args = arguments;
17548
+ vs.reduce(function(v, w) {
17549
+ if (args.length > 1) {
17550
+ self.setEdge(v, w, value);
17551
+ } else {
17552
+ self.setEdge(v, w);
17553
+ }
17554
+ return w;
17555
+ });
17556
+ return this;
17172
17557
  }
17173
- const keyMap = computed(() => ({
17174
- ctrl_c: emitWithSelectedNodes((ids) => emit("copy:nodes", ids)),
17175
- enter: emitWithLastSelectedNode((id2) => onSetNodeActive(id2)),
17176
- ctrl_a: () => addSelectedNodes(graphNodes.value),
17177
- // Support both key and code for zooming in and out
17178
- "shift_+|+|=|shift_Equal|Equal": async () => await onZoomIn(),
17179
- "shift+_|-|_|shift_Minus|Minus": async () => await onZoomOut(),
17180
- 0: async () => await onResetZoom(),
17181
- 1: async () => await onFitView(),
17182
- ArrowUp: emitWithLastSelectedNode(selectUpperSiblingNode),
17183
- ArrowDown: emitWithLastSelectedNode(selectLowerSiblingNode),
17184
- ArrowLeft: emitWithLastSelectedNode(selectLeftNode),
17185
- ArrowRight: emitWithLastSelectedNode(selectRightNode),
17186
- shift_ArrowLeft: emitWithLastSelectedNode(selectUpstreamNodes),
17187
- shift_ArrowRight: emitWithLastSelectedNode(selectDownstreamNodes),
17188
- ...props.readOnly ? {} : {
17189
- ctrl_x: emitWithSelectedNodes((ids) => emit("cut:nodes", ids)),
17190
- "delete|backspace": emitWithSelectedNodes((ids) => emit("delete:nodes", ids)),
17191
- ctrl_d: emitWithSelectedNodes((ids) => emit("duplicate:nodes", ids)),
17192
- d: emitWithSelectedNodes((ids) => emit("update:nodes:enabled", ids)),
17193
- p: emitWithSelectedNodes((ids) => emit("update:nodes:pin", ids, "keyboard-shortcut")),
17194
- f2: emitWithLastSelectedNode((id2) => emit("update:node:name", id2)),
17195
- tab: () => emit("create:node", "tab"),
17196
- shift_s: () => emit("create:sticky"),
17197
- ctrl_alt_n: () => emit("create:workflow"),
17198
- ctrl_enter: () => emit("run:workflow"),
17199
- ctrl_s: () => emit("save:workflow")
17558
+ /**
17559
+ * Creates or updates the label for the edge (v, w) with the optionally supplied
17560
+ * name. If label is supplied it is set as the value for the edge. If label is not
17561
+ * supplied and the edge was created by this call then the default edge label will
17562
+ * be assigned. The name parameter is only useful with multigraphs.
17563
+ */
17564
+ setEdge() {
17565
+ var v, w, name, value;
17566
+ var valueSpecified = false;
17567
+ var arg0 = arguments[0];
17568
+ if (typeof arg0 === "object" && arg0 !== null && "v" in arg0) {
17569
+ v = arg0.v;
17570
+ w = arg0.w;
17571
+ name = arg0.name;
17572
+ if (arguments.length === 2) {
17573
+ value = arguments[1];
17574
+ valueSpecified = true;
17575
+ }
17576
+ } else {
17577
+ v = arg0;
17578
+ w = arguments[1];
17579
+ name = arguments[3];
17580
+ if (arguments.length > 2) {
17581
+ value = arguments[2];
17582
+ valueSpecified = true;
17583
+ }
17200
17584
  }
17201
- }));
17202
- useKeybindings(keyMap, { disabled: disableKeyBindings });
17203
- const hasSelection = computed(() => selectedNodes.value.length > 0);
17204
- const selectedNodeIds = computed(() => selectedNodes.value.map((node2) => node2.id));
17205
- const lastSelectedNode = ref();
17206
- const triggerNodes = computed(
17207
- () => props.nodes.filter(
17208
- (node2) => node2.data?.render.type === CanvasNodeRenderType.Default && node2.data.render.options.trigger
17209
- )
17210
- );
17211
- const hoveredTriggerNode = useCanvasNodeHover(triggerNodes, vueFlow, (nodeRect) => ({
17212
- x: nodeRect.x - nodeRect.width * 2,
17213
- // should cover the width of trigger button
17214
- y: nodeRect.y - nodeRect.height,
17215
- width: nodeRect.width * 4,
17216
- height: nodeRect.height * 3
17217
- }));
17218
- watch(selectedNodes, (nodes) => {
17219
- if (!lastSelectedNode.value || !nodes.find((node2) => node2.id === lastSelectedNode.value?.id)) {
17220
- lastSelectedNode.value = nodes[nodes.length - 1];
17585
+ v = "" + v;
17586
+ w = "" + w;
17587
+ if (name !== void 0) {
17588
+ name = "" + name;
17221
17589
  }
17222
- });
17223
- function onClickNodeAdd(id2, handle2) {
17224
- emit("click:node:add", id2, handle2);
17590
+ var e = edgeArgsToId(this._isDirected, v, w, name);
17591
+ if (Object.hasOwn(this._edgeLabels, e)) {
17592
+ if (valueSpecified) {
17593
+ this._edgeLabels[e] = value;
17594
+ }
17595
+ return this;
17596
+ }
17597
+ if (name !== void 0 && !this._isMultigraph) {
17598
+ throw new Error("Cannot set a named edge when isMultigraph = false");
17599
+ }
17600
+ this.setNode(v);
17601
+ this.setNode(w);
17602
+ this._edgeLabels[e] = valueSpecified ? value : this._defaultEdgeLabelFn(v, w, name);
17603
+ var edgeObj = edgeArgsToObj(this._isDirected, v, w, name);
17604
+ v = edgeObj.v;
17605
+ w = edgeObj.w;
17606
+ Object.freeze(edgeObj);
17607
+ this._edgeObjs[e] = edgeObj;
17608
+ incrementOrInitEntry(this._preds[w], v);
17609
+ incrementOrInitEntry(this._sucs[v], w);
17610
+ this._in[w][e] = edgeObj;
17611
+ this._out[v][e] = edgeObj;
17612
+ this._edgeCount++;
17613
+ return this;
17225
17614
  }
17226
- function onUpdateNodesPosition(events) {
17227
- emit("update:nodes:position", events);
17615
+ /**
17616
+ * Gets the label for the specified edge.
17617
+ * Complexity: O(1).
17618
+ */
17619
+ edge(v, w, name) {
17620
+ var e = arguments.length === 1 ? edgeObjToId(this._isDirected, arguments[0]) : edgeArgsToId(this._isDirected, v, w, name);
17621
+ return this._edgeLabels[e];
17622
+ }
17623
+ /**
17624
+ * Gets the label for the specified edge and converts it to an object.
17625
+ * Complexity: O(1)
17626
+ */
17627
+ edgeAsObj() {
17628
+ const edge2 = this.edge(...arguments);
17629
+ if (typeof edge2 !== "object") {
17630
+ return { label: edge2 };
17631
+ }
17632
+ return edge2;
17633
+ }
17634
+ /**
17635
+ * Detects whether the graph contains specified edge or not. No subgraphs are considered.
17636
+ * Complexity: O(1).
17637
+ */
17638
+ hasEdge(v, w, name) {
17639
+ var e = arguments.length === 1 ? edgeObjToId(this._isDirected, arguments[0]) : edgeArgsToId(this._isDirected, v, w, name);
17640
+ return Object.hasOwn(this._edgeLabels, e);
17641
+ }
17642
+ /**
17643
+ * Removes the specified edge from the graph. No subgraphs are considered.
17644
+ * Complexity: O(1).
17645
+ */
17646
+ removeEdge(v, w, name) {
17647
+ var e = arguments.length === 1 ? edgeObjToId(this._isDirected, arguments[0]) : edgeArgsToId(this._isDirected, v, w, name);
17648
+ var edge2 = this._edgeObjs[e];
17649
+ if (edge2) {
17650
+ v = edge2.v;
17651
+ w = edge2.w;
17652
+ delete this._edgeLabels[e];
17653
+ delete this._edgeObjs[e];
17654
+ decrementOrRemoveEntry(this._preds[w], v);
17655
+ decrementOrRemoveEntry(this._sucs[v], w);
17656
+ delete this._in[w][e];
17657
+ delete this._out[v][e];
17658
+ this._edgeCount--;
17659
+ }
17660
+ return this;
17228
17661
  }
17229
- function onUpdateNodePosition(id2, position2) {
17230
- emit("update:node:position", id2, position2);
17662
+ /**
17663
+ * Return all edges that point to the node v. Optionally filters those edges down to just those
17664
+ * coming from node u. Behavior is undefined for undirected graphs - use nodeEdges instead.
17665
+ * Complexity: O(|E|).
17666
+ */
17667
+ inEdges(v, u) {
17668
+ var inV = this._in[v];
17669
+ if (inV) {
17670
+ var edges = Object.values(inV);
17671
+ if (!u) {
17672
+ return edges;
17673
+ }
17674
+ return edges.filter((edge2) => edge2.v === u);
17675
+ }
17676
+ }
17677
+ /**
17678
+ * Return all edges that are pointed at by node v. Optionally filters those edges down to just
17679
+ * those point to w. Behavior is undefined for undirected graphs - use nodeEdges instead.
17680
+ * Complexity: O(|E|).
17681
+ */
17682
+ outEdges(v, w) {
17683
+ var outV = this._out[v];
17684
+ if (outV) {
17685
+ var edges = Object.values(outV);
17686
+ if (!w) {
17687
+ return edges;
17688
+ }
17689
+ return edges.filter((edge2) => edge2.w === w);
17690
+ }
17231
17691
  }
17232
- function onNodeDragStop(event) {
17233
- onUpdateNodesPosition(event.nodes.map(({ id: id2, position: position2 }) => ({ id: id2, position: position2 })));
17692
+ /**
17693
+ * Returns all edges to or from node v regardless of direction. Optionally filters those edges
17694
+ * down to just those between nodes v and w regardless of direction.
17695
+ * Complexity: O(|E|).
17696
+ */
17697
+ nodeEdges(v, w) {
17698
+ var inEdges = this.inEdges(v, w);
17699
+ if (inEdges) {
17700
+ return inEdges.concat(this.outEdges(v, w));
17701
+ }
17702
+ }
17703
+ }
17704
+ function incrementOrInitEntry(map, k) {
17705
+ if (map[k]) {
17706
+ map[k]++;
17707
+ } else {
17708
+ map[k] = 1;
17709
+ }
17710
+ }
17711
+ function decrementOrRemoveEntry(map, k) {
17712
+ if (!--map[k]) {
17713
+ delete map[k];
17714
+ }
17715
+ }
17716
+ function edgeArgsToId(isDirected, v_, w_, name) {
17717
+ var v = "" + v_;
17718
+ var w = "" + w_;
17719
+ if (!isDirected && v > w) {
17720
+ var tmp = v;
17721
+ v = w;
17722
+ w = tmp;
17723
+ }
17724
+ return v + EDGE_KEY_DELIM + w + EDGE_KEY_DELIM + (name === void 0 ? DEFAULT_EDGE_NAME : name);
17725
+ }
17726
+ function edgeArgsToObj(isDirected, v_, w_, name) {
17727
+ var v = "" + v_;
17728
+ var w = "" + w_;
17729
+ if (!isDirected && v > w) {
17730
+ var tmp = v;
17731
+ v = w;
17732
+ w = tmp;
17733
+ }
17734
+ var edgeObj = { v, w };
17735
+ if (name) {
17736
+ edgeObj.name = name;
17737
+ }
17738
+ return edgeObj;
17739
+ }
17740
+ function edgeObjToId(isDirected, edgeObj) {
17741
+ return edgeArgsToId(isDirected, edgeObj.v, edgeObj.w, edgeObj.name);
17742
+ }
17743
+ graph = Graph;
17744
+ return graph;
17745
+ }
17746
+ var version$1;
17747
+ var hasRequiredVersion$1;
17748
+ function requireVersion$1() {
17749
+ if (hasRequiredVersion$1) return version$1;
17750
+ hasRequiredVersion$1 = 1;
17751
+ version$1 = "2.2.4";
17752
+ return version$1;
17753
+ }
17754
+ var lib;
17755
+ var hasRequiredLib;
17756
+ function requireLib() {
17757
+ if (hasRequiredLib) return lib;
17758
+ hasRequiredLib = 1;
17759
+ lib = {
17760
+ Graph: requireGraph(),
17761
+ version: requireVersion$1()
17762
+ };
17763
+ return lib;
17764
+ }
17765
+ var json;
17766
+ var hasRequiredJson;
17767
+ function requireJson() {
17768
+ if (hasRequiredJson) return json;
17769
+ hasRequiredJson = 1;
17770
+ var Graph = requireGraph();
17771
+ json = {
17772
+ write,
17773
+ read
17774
+ };
17775
+ function write(g) {
17776
+ var json2 = {
17777
+ options: {
17778
+ directed: g.isDirected(),
17779
+ multigraph: g.isMultigraph(),
17780
+ compound: g.isCompound()
17781
+ },
17782
+ nodes: writeNodes(g),
17783
+ edges: writeEdges(g)
17784
+ };
17785
+ if (g.graph() !== void 0) {
17786
+ json2.value = structuredClone(g.graph());
17787
+ }
17788
+ return json2;
17789
+ }
17790
+ function writeNodes(g) {
17791
+ return g.nodes().map(function(v) {
17792
+ var nodeValue = g.node(v);
17793
+ var parent = g.parent(v);
17794
+ var node2 = { v };
17795
+ if (nodeValue !== void 0) {
17796
+ node2.value = nodeValue;
17797
+ }
17798
+ if (parent !== void 0) {
17799
+ node2.parent = parent;
17800
+ }
17801
+ return node2;
17802
+ });
17803
+ }
17804
+ function writeEdges(g) {
17805
+ return g.edges().map(function(e) {
17806
+ var edgeValue = g.edge(e);
17807
+ var edge2 = { v: e.v, w: e.w };
17808
+ if (e.name !== void 0) {
17809
+ edge2.name = e.name;
17810
+ }
17811
+ if (edgeValue !== void 0) {
17812
+ edge2.value = edgeValue;
17813
+ }
17814
+ return edge2;
17815
+ });
17816
+ }
17817
+ function read(json2) {
17818
+ var g = new Graph(json2.options).setGraph(json2.value);
17819
+ json2.nodes.forEach(function(entry) {
17820
+ g.setNode(entry.v, entry.value);
17821
+ if (entry.parent) {
17822
+ g.setParent(entry.v, entry.parent);
17823
+ }
17824
+ });
17825
+ json2.edges.forEach(function(entry) {
17826
+ g.setEdge({ v: entry.v, w: entry.w, name: entry.name }, entry.value);
17827
+ });
17828
+ return g;
17829
+ }
17830
+ return json;
17831
+ }
17832
+ var components_1;
17833
+ var hasRequiredComponents;
17834
+ function requireComponents() {
17835
+ if (hasRequiredComponents) return components_1;
17836
+ hasRequiredComponents = 1;
17837
+ components_1 = components;
17838
+ function components(g) {
17839
+ var visited = {};
17840
+ var cmpts = [];
17841
+ var cmpt;
17842
+ function dfs(v) {
17843
+ if (Object.hasOwn(visited, v)) return;
17844
+ visited[v] = true;
17845
+ cmpt.push(v);
17846
+ g.successors(v).forEach(dfs);
17847
+ g.predecessors(v).forEach(dfs);
17848
+ }
17849
+ g.nodes().forEach(function(v) {
17850
+ cmpt = [];
17851
+ dfs(v);
17852
+ if (cmpt.length) {
17853
+ cmpts.push(cmpt);
17854
+ }
17855
+ });
17856
+ return cmpts;
17857
+ }
17858
+ return components_1;
17859
+ }
17860
+ var priorityQueue;
17861
+ var hasRequiredPriorityQueue;
17862
+ function requirePriorityQueue() {
17863
+ if (hasRequiredPriorityQueue) return priorityQueue;
17864
+ hasRequiredPriorityQueue = 1;
17865
+ class PriorityQueue {
17866
+ _arr = [];
17867
+ _keyIndices = {};
17868
+ /**
17869
+ * Returns the number of elements in the queue. Takes `O(1)` time.
17870
+ */
17871
+ size() {
17872
+ return this._arr.length;
17873
+ }
17874
+ /**
17875
+ * Returns the keys that are in the queue. Takes `O(n)` time.
17876
+ */
17877
+ keys() {
17878
+ return this._arr.map(function(x) {
17879
+ return x.key;
17880
+ });
17881
+ }
17882
+ /**
17883
+ * Returns `true` if **key** is in the queue and `false` if not.
17884
+ */
17885
+ has(key) {
17886
+ return Object.hasOwn(this._keyIndices, key);
17887
+ }
17888
+ /**
17889
+ * Returns the priority for **key**. If **key** is not present in the queue
17890
+ * then this function returns `undefined`. Takes `O(1)` time.
17891
+ *
17892
+ * @param {Object} key
17893
+ */
17894
+ priority(key) {
17895
+ var index = this._keyIndices[key];
17896
+ if (index !== void 0) {
17897
+ return this._arr[index].priority;
17898
+ }
17899
+ }
17900
+ /**
17901
+ * Returns the key for the minimum element in this queue. If the queue is
17902
+ * empty this function throws an Error. Takes `O(1)` time.
17903
+ */
17904
+ min() {
17905
+ if (this.size() === 0) {
17906
+ throw new Error("Queue underflow");
17907
+ }
17908
+ return this._arr[0].key;
17909
+ }
17910
+ /**
17911
+ * Inserts a new key into the priority queue. If the key already exists in
17912
+ * the queue this function returns `false`; otherwise it will return `true`.
17913
+ * Takes `O(n)` time.
17914
+ *
17915
+ * @param {Object} key the key to add
17916
+ * @param {Number} priority the initial priority for the key
17917
+ */
17918
+ add(key, priority) {
17919
+ var keyIndices = this._keyIndices;
17920
+ key = String(key);
17921
+ if (!Object.hasOwn(keyIndices, key)) {
17922
+ var arr = this._arr;
17923
+ var index = arr.length;
17924
+ keyIndices[key] = index;
17925
+ arr.push({ key, priority });
17926
+ this._decrease(index);
17927
+ return true;
17928
+ }
17929
+ return false;
17930
+ }
17931
+ /**
17932
+ * Removes and returns the smallest key in the queue. Takes `O(log n)` time.
17933
+ */
17934
+ removeMin() {
17935
+ this._swap(0, this._arr.length - 1);
17936
+ var min = this._arr.pop();
17937
+ delete this._keyIndices[min.key];
17938
+ this._heapify(0);
17939
+ return min.key;
17940
+ }
17941
+ /**
17942
+ * Decreases the priority for **key** to **priority**. If the new priority is
17943
+ * greater than the previous priority, this function will throw an Error.
17944
+ *
17945
+ * @param {Object} key the key for which to raise priority
17946
+ * @param {Number} priority the new priority for the key
17947
+ */
17948
+ decrease(key, priority) {
17949
+ var index = this._keyIndices[key];
17950
+ if (priority > this._arr[index].priority) {
17951
+ throw new Error("New priority is greater than current priority. Key: " + key + " Old: " + this._arr[index].priority + " New: " + priority);
17952
+ }
17953
+ this._arr[index].priority = priority;
17954
+ this._decrease(index);
17955
+ }
17956
+ _heapify(i) {
17957
+ var arr = this._arr;
17958
+ var l = 2 * i;
17959
+ var r = l + 1;
17960
+ var largest = i;
17961
+ if (l < arr.length) {
17962
+ largest = arr[l].priority < arr[largest].priority ? l : largest;
17963
+ if (r < arr.length) {
17964
+ largest = arr[r].priority < arr[largest].priority ? r : largest;
17965
+ }
17966
+ if (largest !== i) {
17967
+ this._swap(i, largest);
17968
+ this._heapify(largest);
17969
+ }
17970
+ }
17971
+ }
17972
+ _decrease(index) {
17973
+ var arr = this._arr;
17974
+ var priority = arr[index].priority;
17975
+ var parent;
17976
+ while (index !== 0) {
17977
+ parent = index >> 1;
17978
+ if (arr[parent].priority < priority) {
17979
+ break;
17980
+ }
17981
+ this._swap(index, parent);
17982
+ index = parent;
17983
+ }
17984
+ }
17985
+ _swap(i, j) {
17986
+ var arr = this._arr;
17987
+ var keyIndices = this._keyIndices;
17988
+ var origArrI = arr[i];
17989
+ var origArrJ = arr[j];
17990
+ arr[i] = origArrJ;
17991
+ arr[j] = origArrI;
17992
+ keyIndices[origArrJ.key] = i;
17993
+ keyIndices[origArrI.key] = j;
17994
+ }
17995
+ }
17996
+ priorityQueue = PriorityQueue;
17997
+ return priorityQueue;
17998
+ }
17999
+ var dijkstra_1;
18000
+ var hasRequiredDijkstra;
18001
+ function requireDijkstra() {
18002
+ if (hasRequiredDijkstra) return dijkstra_1;
18003
+ hasRequiredDijkstra = 1;
18004
+ var PriorityQueue = requirePriorityQueue();
18005
+ dijkstra_1 = dijkstra;
18006
+ var DEFAULT_WEIGHT_FUNC = () => 1;
18007
+ function dijkstra(g, source, weightFn, edgeFn) {
18008
+ return runDijkstra(
18009
+ g,
18010
+ String(source),
18011
+ weightFn || DEFAULT_WEIGHT_FUNC,
18012
+ edgeFn || function(v) {
18013
+ return g.outEdges(v);
18014
+ }
18015
+ );
18016
+ }
18017
+ function runDijkstra(g, source, weightFn, edgeFn) {
18018
+ var results = {};
18019
+ var pq = new PriorityQueue();
18020
+ var v, vEntry;
18021
+ var updateNeighbors = function(edge2) {
18022
+ var w = edge2.v !== v ? edge2.v : edge2.w;
18023
+ var wEntry = results[w];
18024
+ var weight = weightFn(edge2);
18025
+ var distance2 = vEntry.distance + weight;
18026
+ if (weight < 0) {
18027
+ throw new Error("dijkstra does not allow negative edge weights. Bad edge: " + edge2 + " Weight: " + weight);
18028
+ }
18029
+ if (distance2 < wEntry.distance) {
18030
+ wEntry.distance = distance2;
18031
+ wEntry.predecessor = v;
18032
+ pq.decrease(w, distance2);
18033
+ }
18034
+ };
18035
+ g.nodes().forEach(function(v2) {
18036
+ var distance2 = v2 === source ? 0 : Number.POSITIVE_INFINITY;
18037
+ results[v2] = { distance: distance2 };
18038
+ pq.add(v2, distance2);
18039
+ });
18040
+ while (pq.size() > 0) {
18041
+ v = pq.removeMin();
18042
+ vEntry = results[v];
18043
+ if (vEntry.distance === Number.POSITIVE_INFINITY) {
18044
+ break;
18045
+ }
18046
+ edgeFn(v).forEach(updateNeighbors);
18047
+ }
18048
+ return results;
18049
+ }
18050
+ return dijkstra_1;
18051
+ }
18052
+ var dijkstraAll_1;
18053
+ var hasRequiredDijkstraAll;
18054
+ function requireDijkstraAll() {
18055
+ if (hasRequiredDijkstraAll) return dijkstraAll_1;
18056
+ hasRequiredDijkstraAll = 1;
18057
+ var dijkstra = requireDijkstra();
18058
+ dijkstraAll_1 = dijkstraAll;
18059
+ function dijkstraAll(g, weightFunc, edgeFunc) {
18060
+ return g.nodes().reduce(function(acc, v) {
18061
+ acc[v] = dijkstra(g, v, weightFunc, edgeFunc);
18062
+ return acc;
18063
+ }, {});
18064
+ }
18065
+ return dijkstraAll_1;
18066
+ }
18067
+ var tarjan_1;
18068
+ var hasRequiredTarjan;
18069
+ function requireTarjan() {
18070
+ if (hasRequiredTarjan) return tarjan_1;
18071
+ hasRequiredTarjan = 1;
18072
+ tarjan_1 = tarjan;
18073
+ function tarjan(g) {
18074
+ var index = 0;
18075
+ var stack = [];
18076
+ var visited = {};
18077
+ var results = [];
18078
+ function dfs(v) {
18079
+ var entry = visited[v] = {
18080
+ onStack: true,
18081
+ lowlink: index,
18082
+ index: index++
18083
+ };
18084
+ stack.push(v);
18085
+ g.successors(v).forEach(function(w2) {
18086
+ if (!Object.hasOwn(visited, w2)) {
18087
+ dfs(w2);
18088
+ entry.lowlink = Math.min(entry.lowlink, visited[w2].lowlink);
18089
+ } else if (visited[w2].onStack) {
18090
+ entry.lowlink = Math.min(entry.lowlink, visited[w2].index);
18091
+ }
18092
+ });
18093
+ if (entry.lowlink === entry.index) {
18094
+ var cmpt = [];
18095
+ var w;
18096
+ do {
18097
+ w = stack.pop();
18098
+ visited[w].onStack = false;
18099
+ cmpt.push(w);
18100
+ } while (v !== w);
18101
+ results.push(cmpt);
18102
+ }
18103
+ }
18104
+ g.nodes().forEach(function(v) {
18105
+ if (!Object.hasOwn(visited, v)) {
18106
+ dfs(v);
18107
+ }
18108
+ });
18109
+ return results;
18110
+ }
18111
+ return tarjan_1;
18112
+ }
18113
+ var findCycles_1;
18114
+ var hasRequiredFindCycles;
18115
+ function requireFindCycles() {
18116
+ if (hasRequiredFindCycles) return findCycles_1;
18117
+ hasRequiredFindCycles = 1;
18118
+ var tarjan = requireTarjan();
18119
+ findCycles_1 = findCycles;
18120
+ function findCycles(g) {
18121
+ return tarjan(g).filter(function(cmpt) {
18122
+ return cmpt.length > 1 || cmpt.length === 1 && g.hasEdge(cmpt[0], cmpt[0]);
18123
+ });
18124
+ }
18125
+ return findCycles_1;
18126
+ }
18127
+ var floydWarshall_1;
18128
+ var hasRequiredFloydWarshall;
18129
+ function requireFloydWarshall() {
18130
+ if (hasRequiredFloydWarshall) return floydWarshall_1;
18131
+ hasRequiredFloydWarshall = 1;
18132
+ floydWarshall_1 = floydWarshall;
18133
+ var DEFAULT_WEIGHT_FUNC = () => 1;
18134
+ function floydWarshall(g, weightFn, edgeFn) {
18135
+ return runFloydWarshall(
18136
+ g,
18137
+ weightFn || DEFAULT_WEIGHT_FUNC,
18138
+ edgeFn || function(v) {
18139
+ return g.outEdges(v);
18140
+ }
18141
+ );
18142
+ }
18143
+ function runFloydWarshall(g, weightFn, edgeFn) {
18144
+ var results = {};
18145
+ var nodes = g.nodes();
18146
+ nodes.forEach(function(v) {
18147
+ results[v] = {};
18148
+ results[v][v] = { distance: 0 };
18149
+ nodes.forEach(function(w) {
18150
+ if (v !== w) {
18151
+ results[v][w] = { distance: Number.POSITIVE_INFINITY };
18152
+ }
18153
+ });
18154
+ edgeFn(v).forEach(function(edge2) {
18155
+ var w = edge2.v === v ? edge2.w : edge2.v;
18156
+ var d = weightFn(edge2);
18157
+ results[v][w] = { distance: d, predecessor: v };
18158
+ });
18159
+ });
18160
+ nodes.forEach(function(k) {
18161
+ var rowK = results[k];
18162
+ nodes.forEach(function(i) {
18163
+ var rowI = results[i];
18164
+ nodes.forEach(function(j) {
18165
+ var ik = rowI[k];
18166
+ var kj = rowK[j];
18167
+ var ij = rowI[j];
18168
+ var altDistance = ik.distance + kj.distance;
18169
+ if (altDistance < ij.distance) {
18170
+ ij.distance = altDistance;
18171
+ ij.predecessor = kj.predecessor;
18172
+ }
18173
+ });
18174
+ });
18175
+ });
18176
+ return results;
18177
+ }
18178
+ return floydWarshall_1;
18179
+ }
18180
+ var topsort_1;
18181
+ var hasRequiredTopsort;
18182
+ function requireTopsort() {
18183
+ if (hasRequiredTopsort) return topsort_1;
18184
+ hasRequiredTopsort = 1;
18185
+ function topsort(g) {
18186
+ var visited = {};
18187
+ var stack = {};
18188
+ var results = [];
18189
+ function visit(node2) {
18190
+ if (Object.hasOwn(stack, node2)) {
18191
+ throw new CycleException();
18192
+ }
18193
+ if (!Object.hasOwn(visited, node2)) {
18194
+ stack[node2] = true;
18195
+ visited[node2] = true;
18196
+ g.predecessors(node2).forEach(visit);
18197
+ delete stack[node2];
18198
+ results.push(node2);
18199
+ }
18200
+ }
18201
+ g.sinks().forEach(visit);
18202
+ if (Object.keys(visited).length !== g.nodeCount()) {
18203
+ throw new CycleException();
18204
+ }
18205
+ return results;
18206
+ }
18207
+ class CycleException extends Error {
18208
+ constructor() {
18209
+ super(...arguments);
18210
+ }
18211
+ }
18212
+ topsort_1 = topsort;
18213
+ topsort.CycleException = CycleException;
18214
+ return topsort_1;
18215
+ }
18216
+ var isAcyclic_1;
18217
+ var hasRequiredIsAcyclic;
18218
+ function requireIsAcyclic() {
18219
+ if (hasRequiredIsAcyclic) return isAcyclic_1;
18220
+ hasRequiredIsAcyclic = 1;
18221
+ var topsort = requireTopsort();
18222
+ isAcyclic_1 = isAcyclic;
18223
+ function isAcyclic(g) {
18224
+ try {
18225
+ topsort(g);
18226
+ } catch (e) {
18227
+ if (e instanceof topsort.CycleException) {
18228
+ return false;
18229
+ }
18230
+ throw e;
18231
+ }
18232
+ return true;
18233
+ }
18234
+ return isAcyclic_1;
18235
+ }
18236
+ var dfs_1;
18237
+ var hasRequiredDfs;
18238
+ function requireDfs() {
18239
+ if (hasRequiredDfs) return dfs_1;
18240
+ hasRequiredDfs = 1;
18241
+ dfs_1 = dfs;
18242
+ function dfs(g, vs, order) {
18243
+ if (!Array.isArray(vs)) {
18244
+ vs = [vs];
18245
+ }
18246
+ var navigation = g.isDirected() ? (v) => g.successors(v) : (v) => g.neighbors(v);
18247
+ var orderFunc = order === "post" ? postOrderDfs : preOrderDfs;
18248
+ var acc = [];
18249
+ var visited = {};
18250
+ vs.forEach((v) => {
18251
+ if (!g.hasNode(v)) {
18252
+ throw new Error("Graph does not have node: " + v);
18253
+ }
18254
+ orderFunc(v, navigation, visited, acc);
18255
+ });
18256
+ return acc;
18257
+ }
18258
+ function postOrderDfs(v, navigation, visited, acc) {
18259
+ var stack = [[v, false]];
18260
+ while (stack.length > 0) {
18261
+ var curr = stack.pop();
18262
+ if (curr[1]) {
18263
+ acc.push(curr[0]);
18264
+ } else {
18265
+ if (!Object.hasOwn(visited, curr[0])) {
18266
+ visited[curr[0]] = true;
18267
+ stack.push([curr[0], true]);
18268
+ forEachRight(navigation(curr[0]), (w) => stack.push([w, false]));
18269
+ }
18270
+ }
18271
+ }
18272
+ }
18273
+ function preOrderDfs(v, navigation, visited, acc) {
18274
+ var stack = [v];
18275
+ while (stack.length > 0) {
18276
+ var curr = stack.pop();
18277
+ if (!Object.hasOwn(visited, curr)) {
18278
+ visited[curr] = true;
18279
+ acc.push(curr);
18280
+ forEachRight(navigation(curr), (w) => stack.push(w));
18281
+ }
18282
+ }
18283
+ }
18284
+ function forEachRight(array2, iteratee) {
18285
+ var length = array2.length;
18286
+ while (length--) {
18287
+ iteratee(array2[length], length, array2);
18288
+ }
18289
+ return array2;
18290
+ }
18291
+ return dfs_1;
18292
+ }
18293
+ var postorder_1;
18294
+ var hasRequiredPostorder;
18295
+ function requirePostorder() {
18296
+ if (hasRequiredPostorder) return postorder_1;
18297
+ hasRequiredPostorder = 1;
18298
+ var dfs = requireDfs();
18299
+ postorder_1 = postorder;
18300
+ function postorder(g, vs) {
18301
+ return dfs(g, vs, "post");
18302
+ }
18303
+ return postorder_1;
18304
+ }
18305
+ var preorder_1;
18306
+ var hasRequiredPreorder;
18307
+ function requirePreorder() {
18308
+ if (hasRequiredPreorder) return preorder_1;
18309
+ hasRequiredPreorder = 1;
18310
+ var dfs = requireDfs();
18311
+ preorder_1 = preorder;
18312
+ function preorder(g, vs) {
18313
+ return dfs(g, vs, "pre");
18314
+ }
18315
+ return preorder_1;
18316
+ }
18317
+ var prim_1;
18318
+ var hasRequiredPrim;
18319
+ function requirePrim() {
18320
+ if (hasRequiredPrim) return prim_1;
18321
+ hasRequiredPrim = 1;
18322
+ var Graph = requireGraph();
18323
+ var PriorityQueue = requirePriorityQueue();
18324
+ prim_1 = prim;
18325
+ function prim(g, weightFunc) {
18326
+ var result = new Graph();
18327
+ var parents = {};
18328
+ var pq = new PriorityQueue();
18329
+ var v;
18330
+ function updateNeighbors(edge2) {
18331
+ var w = edge2.v === v ? edge2.w : edge2.v;
18332
+ var pri = pq.priority(w);
18333
+ if (pri !== void 0) {
18334
+ var edgeWeight = weightFunc(edge2);
18335
+ if (edgeWeight < pri) {
18336
+ parents[w] = v;
18337
+ pq.decrease(w, edgeWeight);
18338
+ }
18339
+ }
18340
+ }
18341
+ if (g.nodeCount() === 0) {
18342
+ return result;
18343
+ }
18344
+ g.nodes().forEach(function(v2) {
18345
+ pq.add(v2, Number.POSITIVE_INFINITY);
18346
+ result.setNode(v2);
18347
+ });
18348
+ pq.decrease(g.nodes()[0], 0);
18349
+ var init2 = false;
18350
+ while (pq.size() > 0) {
18351
+ v = pq.removeMin();
18352
+ if (Object.hasOwn(parents, v)) {
18353
+ result.setEdge(v, parents[v]);
18354
+ } else if (init2) {
18355
+ throw new Error("Input graph is not connected: " + g);
18356
+ } else {
18357
+ init2 = true;
18358
+ }
18359
+ g.nodeEdges(v).forEach(updateNeighbors);
18360
+ }
18361
+ return result;
18362
+ }
18363
+ return prim_1;
18364
+ }
18365
+ var alg;
18366
+ var hasRequiredAlg;
18367
+ function requireAlg() {
18368
+ if (hasRequiredAlg) return alg;
18369
+ hasRequiredAlg = 1;
18370
+ alg = {
18371
+ components: requireComponents(),
18372
+ dijkstra: requireDijkstra(),
18373
+ dijkstraAll: requireDijkstraAll(),
18374
+ findCycles: requireFindCycles(),
18375
+ floydWarshall: requireFloydWarshall(),
18376
+ isAcyclic: requireIsAcyclic(),
18377
+ postorder: requirePostorder(),
18378
+ preorder: requirePreorder(),
18379
+ prim: requirePrim(),
18380
+ tarjan: requireTarjan(),
18381
+ topsort: requireTopsort()
18382
+ };
18383
+ return alg;
18384
+ }
18385
+ var graphlib;
18386
+ var hasRequiredGraphlib;
18387
+ function requireGraphlib() {
18388
+ if (hasRequiredGraphlib) return graphlib;
18389
+ hasRequiredGraphlib = 1;
18390
+ var lib2 = requireLib();
18391
+ graphlib = {
18392
+ Graph: lib2.Graph,
18393
+ json: requireJson(),
18394
+ alg: requireAlg(),
18395
+ version: lib2.version
18396
+ };
18397
+ return graphlib;
18398
+ }
18399
+ var list;
18400
+ var hasRequiredList;
18401
+ function requireList() {
18402
+ if (hasRequiredList) return list;
18403
+ hasRequiredList = 1;
18404
+ class List {
18405
+ constructor() {
18406
+ let sentinel = {};
18407
+ sentinel._next = sentinel._prev = sentinel;
18408
+ this._sentinel = sentinel;
18409
+ }
18410
+ dequeue() {
18411
+ let sentinel = this._sentinel;
18412
+ let entry = sentinel._prev;
18413
+ if (entry !== sentinel) {
18414
+ unlink(entry);
18415
+ return entry;
18416
+ }
18417
+ }
18418
+ enqueue(entry) {
18419
+ let sentinel = this._sentinel;
18420
+ if (entry._prev && entry._next) {
18421
+ unlink(entry);
18422
+ }
18423
+ entry._next = sentinel._next;
18424
+ sentinel._next._prev = entry;
18425
+ sentinel._next = entry;
18426
+ entry._prev = sentinel;
18427
+ }
18428
+ toString() {
18429
+ let strs = [];
18430
+ let sentinel = this._sentinel;
18431
+ let curr = sentinel._prev;
18432
+ while (curr !== sentinel) {
18433
+ strs.push(JSON.stringify(curr, filterOutLinks));
18434
+ curr = curr._prev;
18435
+ }
18436
+ return "[" + strs.join(", ") + "]";
18437
+ }
18438
+ }
18439
+ function unlink(entry) {
18440
+ entry._prev._next = entry._next;
18441
+ entry._next._prev = entry._prev;
18442
+ delete entry._next;
18443
+ delete entry._prev;
18444
+ }
18445
+ function filterOutLinks(k, v) {
18446
+ if (k !== "_next" && k !== "_prev") {
18447
+ return v;
18448
+ }
18449
+ }
18450
+ list = List;
18451
+ return list;
18452
+ }
18453
+ var greedyFas;
18454
+ var hasRequiredGreedyFas;
18455
+ function requireGreedyFas() {
18456
+ if (hasRequiredGreedyFas) return greedyFas;
18457
+ hasRequiredGreedyFas = 1;
18458
+ let Graph = requireGraphlib().Graph;
18459
+ let List = requireList();
18460
+ greedyFas = greedyFAS;
18461
+ let DEFAULT_WEIGHT_FN = () => 1;
18462
+ function greedyFAS(g, weightFn) {
18463
+ if (g.nodeCount() <= 1) {
18464
+ return [];
18465
+ }
18466
+ let state = buildState(g, weightFn || DEFAULT_WEIGHT_FN);
18467
+ let results = doGreedyFAS(state.graph, state.buckets, state.zeroIdx);
18468
+ return results.flatMap((e) => g.outEdges(e.v, e.w));
18469
+ }
18470
+ function doGreedyFAS(g, buckets, zeroIdx) {
18471
+ let results = [];
18472
+ let sources = buckets[buckets.length - 1];
18473
+ let sinks = buckets[0];
18474
+ let entry;
18475
+ while (g.nodeCount()) {
18476
+ while (entry = sinks.dequeue()) {
18477
+ removeNode(g, buckets, zeroIdx, entry);
18478
+ }
18479
+ while (entry = sources.dequeue()) {
18480
+ removeNode(g, buckets, zeroIdx, entry);
18481
+ }
18482
+ if (g.nodeCount()) {
18483
+ for (let i = buckets.length - 2; i > 0; --i) {
18484
+ entry = buckets[i].dequeue();
18485
+ if (entry) {
18486
+ results = results.concat(removeNode(g, buckets, zeroIdx, entry, true));
18487
+ break;
18488
+ }
18489
+ }
18490
+ }
18491
+ }
18492
+ return results;
18493
+ }
18494
+ function removeNode(g, buckets, zeroIdx, entry, collectPredecessors) {
18495
+ let results = collectPredecessors ? [] : void 0;
18496
+ g.inEdges(entry.v).forEach((edge2) => {
18497
+ let weight = g.edge(edge2);
18498
+ let uEntry = g.node(edge2.v);
18499
+ if (collectPredecessors) {
18500
+ results.push({ v: edge2.v, w: edge2.w });
18501
+ }
18502
+ uEntry.out -= weight;
18503
+ assignBucket(buckets, zeroIdx, uEntry);
18504
+ });
18505
+ g.outEdges(entry.v).forEach((edge2) => {
18506
+ let weight = g.edge(edge2);
18507
+ let w = edge2.w;
18508
+ let wEntry = g.node(w);
18509
+ wEntry["in"] -= weight;
18510
+ assignBucket(buckets, zeroIdx, wEntry);
18511
+ });
18512
+ g.removeNode(entry.v);
18513
+ return results;
18514
+ }
18515
+ function buildState(g, weightFn) {
18516
+ let fasGraph = new Graph();
18517
+ let maxIn = 0;
18518
+ let maxOut = 0;
18519
+ g.nodes().forEach((v) => {
18520
+ fasGraph.setNode(v, { v, "in": 0, out: 0 });
18521
+ });
18522
+ g.edges().forEach((e) => {
18523
+ let prevWeight = fasGraph.edge(e.v, e.w) || 0;
18524
+ let weight = weightFn(e);
18525
+ let edgeWeight = prevWeight + weight;
18526
+ fasGraph.setEdge(e.v, e.w, edgeWeight);
18527
+ maxOut = Math.max(maxOut, fasGraph.node(e.v).out += weight);
18528
+ maxIn = Math.max(maxIn, fasGraph.node(e.w)["in"] += weight);
18529
+ });
18530
+ let buckets = range(maxOut + maxIn + 3).map(() => new List());
18531
+ let zeroIdx = maxIn + 1;
18532
+ fasGraph.nodes().forEach((v) => {
18533
+ assignBucket(buckets, zeroIdx, fasGraph.node(v));
18534
+ });
18535
+ return { graph: fasGraph, buckets, zeroIdx };
18536
+ }
18537
+ function assignBucket(buckets, zeroIdx, entry) {
18538
+ if (!entry.out) {
18539
+ buckets[0].enqueue(entry);
18540
+ } else if (!entry["in"]) {
18541
+ buckets[buckets.length - 1].enqueue(entry);
18542
+ } else {
18543
+ buckets[entry.out - entry["in"] + zeroIdx].enqueue(entry);
18544
+ }
18545
+ }
18546
+ function range(limit) {
18547
+ const range2 = [];
18548
+ for (let i = 0; i < limit; i++) {
18549
+ range2.push(i);
18550
+ }
18551
+ return range2;
18552
+ }
18553
+ return greedyFas;
18554
+ }
18555
+ var util$1;
18556
+ var hasRequiredUtil$1;
18557
+ function requireUtil$1() {
18558
+ if (hasRequiredUtil$1) return util$1;
18559
+ hasRequiredUtil$1 = 1;
18560
+ let Graph = requireGraphlib().Graph;
18561
+ util$1 = {
18562
+ addBorderNode,
18563
+ addDummyNode,
18564
+ applyWithChunking,
18565
+ asNonCompoundGraph,
18566
+ buildLayerMatrix,
18567
+ intersectRect,
18568
+ mapValues,
18569
+ maxRank,
18570
+ normalizeRanks,
18571
+ notime,
18572
+ partition,
18573
+ pick,
18574
+ predecessorWeights,
18575
+ range,
18576
+ removeEmptyRanks,
18577
+ simplify,
18578
+ successorWeights,
18579
+ time,
18580
+ uniqueId,
18581
+ zipObject
18582
+ };
18583
+ function addDummyNode(g, type, attrs, name) {
18584
+ let v;
18585
+ do {
18586
+ v = uniqueId(name);
18587
+ } while (g.hasNode(v));
18588
+ attrs.dummy = type;
18589
+ g.setNode(v, attrs);
18590
+ return v;
18591
+ }
18592
+ function simplify(g) {
18593
+ let simplified = new Graph().setGraph(g.graph());
18594
+ g.nodes().forEach((v) => simplified.setNode(v, g.node(v)));
18595
+ g.edges().forEach((e) => {
18596
+ let simpleLabel = simplified.edge(e.v, e.w) || { weight: 0, minlen: 1 };
18597
+ let label2 = g.edge(e);
18598
+ simplified.setEdge(e.v, e.w, {
18599
+ weight: simpleLabel.weight + label2.weight,
18600
+ minlen: Math.max(simpleLabel.minlen, label2.minlen)
18601
+ });
18602
+ });
18603
+ return simplified;
18604
+ }
18605
+ function asNonCompoundGraph(g) {
18606
+ let simplified = new Graph({ multigraph: g.isMultigraph() }).setGraph(g.graph());
18607
+ g.nodes().forEach((v) => {
18608
+ if (!g.children(v).length) {
18609
+ simplified.setNode(v, g.node(v));
18610
+ }
18611
+ });
18612
+ g.edges().forEach((e) => {
18613
+ simplified.setEdge(e, g.edge(e));
18614
+ });
18615
+ return simplified;
18616
+ }
18617
+ function successorWeights(g) {
18618
+ let weightMap = g.nodes().map((v) => {
18619
+ let sucs = {};
18620
+ g.outEdges(v).forEach((e) => {
18621
+ sucs[e.w] = (sucs[e.w] || 0) + g.edge(e).weight;
18622
+ });
18623
+ return sucs;
18624
+ });
18625
+ return zipObject(g.nodes(), weightMap);
18626
+ }
18627
+ function predecessorWeights(g) {
18628
+ let weightMap = g.nodes().map((v) => {
18629
+ let preds = {};
18630
+ g.inEdges(v).forEach((e) => {
18631
+ preds[e.v] = (preds[e.v] || 0) + g.edge(e).weight;
18632
+ });
18633
+ return preds;
18634
+ });
18635
+ return zipObject(g.nodes(), weightMap);
18636
+ }
18637
+ function intersectRect(rect, point) {
18638
+ let x = rect.x;
18639
+ let y = rect.y;
18640
+ let dx = point.x - x;
18641
+ let dy = point.y - y;
18642
+ let w = rect.width / 2;
18643
+ let h2 = rect.height / 2;
18644
+ if (!dx && !dy) {
18645
+ throw new Error("Not possible to find intersection inside of the rectangle");
18646
+ }
18647
+ let sx, sy;
18648
+ if (Math.abs(dy) * w > Math.abs(dx) * h2) {
18649
+ if (dy < 0) {
18650
+ h2 = -h2;
18651
+ }
18652
+ sx = h2 * dx / dy;
18653
+ sy = h2;
18654
+ } else {
18655
+ if (dx < 0) {
18656
+ w = -w;
18657
+ }
18658
+ sx = w;
18659
+ sy = w * dy / dx;
18660
+ }
18661
+ return { x: x + sx, y: y + sy };
18662
+ }
18663
+ function buildLayerMatrix(g) {
18664
+ let layering = range(maxRank(g) + 1).map(() => []);
18665
+ g.nodes().forEach((v) => {
18666
+ let node2 = g.node(v);
18667
+ let rank = node2.rank;
18668
+ if (rank !== void 0) {
18669
+ layering[rank][node2.order] = v;
18670
+ }
18671
+ });
18672
+ return layering;
18673
+ }
18674
+ function normalizeRanks(g) {
18675
+ let nodeRanks = g.nodes().map((v) => {
18676
+ let rank = g.node(v).rank;
18677
+ if (rank === void 0) {
18678
+ return Number.MAX_VALUE;
18679
+ }
18680
+ return rank;
18681
+ });
18682
+ let min = applyWithChunking(Math.min, nodeRanks);
18683
+ g.nodes().forEach((v) => {
18684
+ let node2 = g.node(v);
18685
+ if (Object.hasOwn(node2, "rank")) {
18686
+ node2.rank -= min;
18687
+ }
18688
+ });
18689
+ }
18690
+ function removeEmptyRanks(g) {
18691
+ let nodeRanks = g.nodes().map((v) => g.node(v).rank);
18692
+ let offset = applyWithChunking(Math.min, nodeRanks);
18693
+ let layers = [];
18694
+ g.nodes().forEach((v) => {
18695
+ let rank = g.node(v).rank - offset;
18696
+ if (!layers[rank]) {
18697
+ layers[rank] = [];
18698
+ }
18699
+ layers[rank].push(v);
18700
+ });
18701
+ let delta = 0;
18702
+ let nodeRankFactor = g.graph().nodeRankFactor;
18703
+ Array.from(layers).forEach((vs, i) => {
18704
+ if (vs === void 0 && i % nodeRankFactor !== 0) {
18705
+ --delta;
18706
+ } else if (vs !== void 0 && delta) {
18707
+ vs.forEach((v) => g.node(v).rank += delta);
18708
+ }
18709
+ });
18710
+ }
18711
+ function addBorderNode(g, prefix, rank, order) {
18712
+ let node2 = {
18713
+ width: 0,
18714
+ height: 0
18715
+ };
18716
+ if (arguments.length >= 4) {
18717
+ node2.rank = rank;
18718
+ node2.order = order;
18719
+ }
18720
+ return addDummyNode(g, "border", node2, prefix);
18721
+ }
18722
+ function splitToChunks(array2, chunkSize = CHUNKING_THRESHOLD) {
18723
+ const chunks = [];
18724
+ for (let i = 0; i < array2.length; i += chunkSize) {
18725
+ const chunk = array2.slice(i, i + chunkSize);
18726
+ chunks.push(chunk);
18727
+ }
18728
+ return chunks;
18729
+ }
18730
+ const CHUNKING_THRESHOLD = 65535;
18731
+ function applyWithChunking(fn, argsArray) {
18732
+ if (argsArray.length > CHUNKING_THRESHOLD) {
18733
+ const chunks = splitToChunks(argsArray);
18734
+ return fn.apply(null, chunks.map((chunk) => fn.apply(null, chunk)));
18735
+ } else {
18736
+ return fn.apply(null, argsArray);
18737
+ }
18738
+ }
18739
+ function maxRank(g) {
18740
+ const nodes = g.nodes();
18741
+ const nodeRanks = nodes.map((v) => {
18742
+ let rank = g.node(v).rank;
18743
+ if (rank === void 0) {
18744
+ return Number.MIN_VALUE;
18745
+ }
18746
+ return rank;
18747
+ });
18748
+ return applyWithChunking(Math.max, nodeRanks);
18749
+ }
18750
+ function partition(collection, fn) {
18751
+ let result = { lhs: [], rhs: [] };
18752
+ collection.forEach((value) => {
18753
+ if (fn(value)) {
18754
+ result.lhs.push(value);
18755
+ } else {
18756
+ result.rhs.push(value);
18757
+ }
18758
+ });
18759
+ return result;
18760
+ }
18761
+ function time(name, fn) {
18762
+ let start2 = Date.now();
18763
+ try {
18764
+ return fn();
18765
+ } finally {
18766
+ console.log(name + " time: " + (Date.now() - start2) + "ms");
18767
+ }
18768
+ }
18769
+ function notime(name, fn) {
18770
+ return fn();
18771
+ }
18772
+ let idCounter = 0;
18773
+ function uniqueId(prefix) {
18774
+ var id2 = ++idCounter;
18775
+ return toString(prefix) + id2;
18776
+ }
18777
+ function range(start2, limit, step = 1) {
18778
+ if (limit == null) {
18779
+ limit = start2;
18780
+ start2 = 0;
18781
+ }
18782
+ let endCon = (i) => i < limit;
18783
+ if (step < 0) {
18784
+ endCon = (i) => limit < i;
18785
+ }
18786
+ const range2 = [];
18787
+ for (let i = start2; endCon(i); i += step) {
18788
+ range2.push(i);
18789
+ }
18790
+ return range2;
18791
+ }
18792
+ function pick(source, keys) {
18793
+ const dest = {};
18794
+ for (const key of keys) {
18795
+ if (source[key] !== void 0) {
18796
+ dest[key] = source[key];
18797
+ }
18798
+ }
18799
+ return dest;
18800
+ }
18801
+ function mapValues(obj, funcOrProp) {
18802
+ let func = funcOrProp;
18803
+ if (typeof funcOrProp === "string") {
18804
+ func = (val) => val[funcOrProp];
18805
+ }
18806
+ return Object.entries(obj).reduce((acc, [k, v]) => {
18807
+ acc[k] = func(v, k);
18808
+ return acc;
18809
+ }, {});
18810
+ }
18811
+ function zipObject(props, values) {
18812
+ return props.reduce((acc, key, i) => {
18813
+ acc[key] = values[i];
18814
+ return acc;
18815
+ }, {});
18816
+ }
18817
+ return util$1;
18818
+ }
18819
+ var acyclic;
18820
+ var hasRequiredAcyclic;
18821
+ function requireAcyclic() {
18822
+ if (hasRequiredAcyclic) return acyclic;
18823
+ hasRequiredAcyclic = 1;
18824
+ let greedyFAS = requireGreedyFas();
18825
+ let uniqueId = requireUtil$1().uniqueId;
18826
+ acyclic = {
18827
+ run,
18828
+ undo
18829
+ };
18830
+ function run(g) {
18831
+ let fas = g.graph().acyclicer === "greedy" ? greedyFAS(g, weightFn(g)) : dfsFAS(g);
18832
+ fas.forEach((e) => {
18833
+ let label2 = g.edge(e);
18834
+ g.removeEdge(e);
18835
+ label2.forwardName = e.name;
18836
+ label2.reversed = true;
18837
+ g.setEdge(e.w, e.v, label2, uniqueId("rev"));
18838
+ });
18839
+ function weightFn(g2) {
18840
+ return (e) => {
18841
+ return g2.edge(e).weight;
18842
+ };
18843
+ }
18844
+ }
18845
+ function dfsFAS(g) {
18846
+ let fas = [];
18847
+ let stack = {};
18848
+ let visited = {};
18849
+ function dfs(v) {
18850
+ if (Object.hasOwn(visited, v)) {
18851
+ return;
18852
+ }
18853
+ visited[v] = true;
18854
+ stack[v] = true;
18855
+ g.outEdges(v).forEach((e) => {
18856
+ if (Object.hasOwn(stack, e.w)) {
18857
+ fas.push(e);
18858
+ } else {
18859
+ dfs(e.w);
18860
+ }
18861
+ });
18862
+ delete stack[v];
18863
+ }
18864
+ g.nodes().forEach(dfs);
18865
+ return fas;
18866
+ }
18867
+ function undo(g) {
18868
+ g.edges().forEach((e) => {
18869
+ let label2 = g.edge(e);
18870
+ if (label2.reversed) {
18871
+ g.removeEdge(e);
18872
+ let forwardName = label2.forwardName;
18873
+ delete label2.reversed;
18874
+ delete label2.forwardName;
18875
+ g.setEdge(e.w, e.v, label2, forwardName);
18876
+ }
18877
+ });
18878
+ }
18879
+ return acyclic;
18880
+ }
18881
+ var normalize;
18882
+ var hasRequiredNormalize;
18883
+ function requireNormalize() {
18884
+ if (hasRequiredNormalize) return normalize;
18885
+ hasRequiredNormalize = 1;
18886
+ let util2 = requireUtil$1();
18887
+ normalize = {
18888
+ run,
18889
+ undo
18890
+ };
18891
+ function run(g) {
18892
+ g.graph().dummyChains = [];
18893
+ g.edges().forEach((edge2) => normalizeEdge(g, edge2));
18894
+ }
18895
+ function normalizeEdge(g, e) {
18896
+ let v = e.v;
18897
+ let vRank = g.node(v).rank;
18898
+ let w = e.w;
18899
+ let wRank = g.node(w).rank;
18900
+ let name = e.name;
18901
+ let edgeLabel2 = g.edge(e);
18902
+ let labelRank = edgeLabel2.labelRank;
18903
+ if (wRank === vRank + 1) return;
18904
+ g.removeEdge(e);
18905
+ let dummy, attrs, i;
18906
+ for (i = 0, ++vRank; vRank < wRank; ++i, ++vRank) {
18907
+ edgeLabel2.points = [];
18908
+ attrs = {
18909
+ width: 0,
18910
+ height: 0,
18911
+ edgeLabel: edgeLabel2,
18912
+ edgeObj: e,
18913
+ rank: vRank
18914
+ };
18915
+ dummy = util2.addDummyNode(g, "edge", attrs, "_d");
18916
+ if (vRank === labelRank) {
18917
+ attrs.width = edgeLabel2.width;
18918
+ attrs.height = edgeLabel2.height;
18919
+ attrs.dummy = "edge-label";
18920
+ attrs.labelpos = edgeLabel2.labelpos;
18921
+ }
18922
+ g.setEdge(v, dummy, { weight: edgeLabel2.weight }, name);
18923
+ if (i === 0) {
18924
+ g.graph().dummyChains.push(dummy);
18925
+ }
18926
+ v = dummy;
18927
+ }
18928
+ g.setEdge(v, w, { weight: edgeLabel2.weight }, name);
18929
+ }
18930
+ function undo(g) {
18931
+ g.graph().dummyChains.forEach((v) => {
18932
+ let node2 = g.node(v);
18933
+ let origLabel = node2.edgeLabel;
18934
+ let w;
18935
+ g.setEdge(node2.edgeObj, origLabel);
18936
+ while (node2.dummy) {
18937
+ w = g.successors(v)[0];
18938
+ g.removeNode(v);
18939
+ origLabel.points.push({ x: node2.x, y: node2.y });
18940
+ if (node2.dummy === "edge-label") {
18941
+ origLabel.x = node2.x;
18942
+ origLabel.y = node2.y;
18943
+ origLabel.width = node2.width;
18944
+ origLabel.height = node2.height;
18945
+ }
18946
+ v = w;
18947
+ node2 = g.node(v);
18948
+ }
18949
+ });
18950
+ }
18951
+ return normalize;
18952
+ }
18953
+ var util;
18954
+ var hasRequiredUtil;
18955
+ function requireUtil() {
18956
+ if (hasRequiredUtil) return util;
18957
+ hasRequiredUtil = 1;
18958
+ const { applyWithChunking } = requireUtil$1();
18959
+ util = {
18960
+ longestPath,
18961
+ slack
18962
+ };
18963
+ function longestPath(g) {
18964
+ var visited = {};
18965
+ function dfs(v) {
18966
+ var label2 = g.node(v);
18967
+ if (Object.hasOwn(visited, v)) {
18968
+ return label2.rank;
18969
+ }
18970
+ visited[v] = true;
18971
+ let outEdgesMinLens = g.outEdges(v).map((e) => {
18972
+ if (e == null) {
18973
+ return Number.POSITIVE_INFINITY;
18974
+ }
18975
+ return dfs(e.w) - g.edge(e).minlen;
18976
+ });
18977
+ var rank = applyWithChunking(Math.min, outEdgesMinLens);
18978
+ if (rank === Number.POSITIVE_INFINITY) {
18979
+ rank = 0;
18980
+ }
18981
+ return label2.rank = rank;
18982
+ }
18983
+ g.sources().forEach(dfs);
18984
+ }
18985
+ function slack(g, e) {
18986
+ return g.node(e.w).rank - g.node(e.v).rank - g.edge(e).minlen;
18987
+ }
18988
+ return util;
18989
+ }
18990
+ var feasibleTree_1;
18991
+ var hasRequiredFeasibleTree;
18992
+ function requireFeasibleTree() {
18993
+ if (hasRequiredFeasibleTree) return feasibleTree_1;
18994
+ hasRequiredFeasibleTree = 1;
18995
+ var Graph = requireGraphlib().Graph;
18996
+ var slack = requireUtil().slack;
18997
+ feasibleTree_1 = feasibleTree;
18998
+ function feasibleTree(g) {
18999
+ var t = new Graph({ directed: false });
19000
+ var start2 = g.nodes()[0];
19001
+ var size = g.nodeCount();
19002
+ t.setNode(start2, {});
19003
+ var edge2, delta;
19004
+ while (tightTree(t, g) < size) {
19005
+ edge2 = findMinSlackEdge(t, g);
19006
+ delta = t.hasNode(edge2.v) ? slack(g, edge2) : -slack(g, edge2);
19007
+ shiftRanks(t, g, delta);
19008
+ }
19009
+ return t;
19010
+ }
19011
+ function tightTree(t, g) {
19012
+ function dfs(v) {
19013
+ g.nodeEdges(v).forEach((e) => {
19014
+ var edgeV = e.v, w = v === edgeV ? e.w : edgeV;
19015
+ if (!t.hasNode(w) && !slack(g, e)) {
19016
+ t.setNode(w, {});
19017
+ t.setEdge(v, w, {});
19018
+ dfs(w);
19019
+ }
19020
+ });
19021
+ }
19022
+ t.nodes().forEach(dfs);
19023
+ return t.nodeCount();
19024
+ }
19025
+ function findMinSlackEdge(t, g) {
19026
+ const edges = g.edges();
19027
+ return edges.reduce((acc, edge2) => {
19028
+ let edgeSlack = Number.POSITIVE_INFINITY;
19029
+ if (t.hasNode(edge2.v) !== t.hasNode(edge2.w)) {
19030
+ edgeSlack = slack(g, edge2);
19031
+ }
19032
+ if (edgeSlack < acc[0]) {
19033
+ return [edgeSlack, edge2];
19034
+ }
19035
+ return acc;
19036
+ }, [Number.POSITIVE_INFINITY, null])[1];
19037
+ }
19038
+ function shiftRanks(t, g, delta) {
19039
+ t.nodes().forEach((v) => g.node(v).rank += delta);
19040
+ }
19041
+ return feasibleTree_1;
19042
+ }
19043
+ var networkSimplex_1;
19044
+ var hasRequiredNetworkSimplex;
19045
+ function requireNetworkSimplex() {
19046
+ if (hasRequiredNetworkSimplex) return networkSimplex_1;
19047
+ hasRequiredNetworkSimplex = 1;
19048
+ var feasibleTree = requireFeasibleTree();
19049
+ var slack = requireUtil().slack;
19050
+ var initRank = requireUtil().longestPath;
19051
+ var preorder = requireGraphlib().alg.preorder;
19052
+ var postorder = requireGraphlib().alg.postorder;
19053
+ var simplify = requireUtil$1().simplify;
19054
+ networkSimplex_1 = networkSimplex;
19055
+ networkSimplex.initLowLimValues = initLowLimValues;
19056
+ networkSimplex.initCutValues = initCutValues;
19057
+ networkSimplex.calcCutValue = calcCutValue;
19058
+ networkSimplex.leaveEdge = leaveEdge;
19059
+ networkSimplex.enterEdge = enterEdge;
19060
+ networkSimplex.exchangeEdges = exchangeEdges;
19061
+ function networkSimplex(g) {
19062
+ g = simplify(g);
19063
+ initRank(g);
19064
+ var t = feasibleTree(g);
19065
+ initLowLimValues(t);
19066
+ initCutValues(t, g);
19067
+ var e, f;
19068
+ while (e = leaveEdge(t)) {
19069
+ f = enterEdge(t, g, e);
19070
+ exchangeEdges(t, g, e, f);
19071
+ }
19072
+ }
19073
+ function initCutValues(t, g) {
19074
+ var vs = postorder(t, t.nodes());
19075
+ vs = vs.slice(0, vs.length - 1);
19076
+ vs.forEach((v) => assignCutValue(t, g, v));
19077
+ }
19078
+ function assignCutValue(t, g, child) {
19079
+ var childLab = t.node(child);
19080
+ var parent = childLab.parent;
19081
+ t.edge(child, parent).cutvalue = calcCutValue(t, g, child);
19082
+ }
19083
+ function calcCutValue(t, g, child) {
19084
+ var childLab = t.node(child);
19085
+ var parent = childLab.parent;
19086
+ var childIsTail = true;
19087
+ var graphEdge = g.edge(child, parent);
19088
+ var cutValue = 0;
19089
+ if (!graphEdge) {
19090
+ childIsTail = false;
19091
+ graphEdge = g.edge(parent, child);
19092
+ }
19093
+ cutValue = graphEdge.weight;
19094
+ g.nodeEdges(child).forEach((e) => {
19095
+ var isOutEdge = e.v === child, other = isOutEdge ? e.w : e.v;
19096
+ if (other !== parent) {
19097
+ var pointsToHead = isOutEdge === childIsTail, otherWeight = g.edge(e).weight;
19098
+ cutValue += pointsToHead ? otherWeight : -otherWeight;
19099
+ if (isTreeEdge(t, child, other)) {
19100
+ var otherCutValue = t.edge(child, other).cutvalue;
19101
+ cutValue += pointsToHead ? -otherCutValue : otherCutValue;
19102
+ }
19103
+ }
19104
+ });
19105
+ return cutValue;
19106
+ }
19107
+ function initLowLimValues(tree, root2) {
19108
+ if (arguments.length < 2) {
19109
+ root2 = tree.nodes()[0];
19110
+ }
19111
+ dfsAssignLowLim(tree, {}, 1, root2);
19112
+ }
19113
+ function dfsAssignLowLim(tree, visited, nextLim, v, parent) {
19114
+ var low = nextLim;
19115
+ var label2 = tree.node(v);
19116
+ visited[v] = true;
19117
+ tree.neighbors(v).forEach((w) => {
19118
+ if (!Object.hasOwn(visited, w)) {
19119
+ nextLim = dfsAssignLowLim(tree, visited, nextLim, w, v);
19120
+ }
19121
+ });
19122
+ label2.low = low;
19123
+ label2.lim = nextLim++;
19124
+ if (parent) {
19125
+ label2.parent = parent;
19126
+ } else {
19127
+ delete label2.parent;
19128
+ }
19129
+ return nextLim;
19130
+ }
19131
+ function leaveEdge(tree) {
19132
+ return tree.edges().find((e) => tree.edge(e).cutvalue < 0);
19133
+ }
19134
+ function enterEdge(t, g, edge2) {
19135
+ var v = edge2.v;
19136
+ var w = edge2.w;
19137
+ if (!g.hasEdge(v, w)) {
19138
+ v = edge2.w;
19139
+ w = edge2.v;
19140
+ }
19141
+ var vLabel = t.node(v);
19142
+ var wLabel = t.node(w);
19143
+ var tailLabel = vLabel;
19144
+ var flip = false;
19145
+ if (vLabel.lim > wLabel.lim) {
19146
+ tailLabel = wLabel;
19147
+ flip = true;
19148
+ }
19149
+ var candidates = g.edges().filter((edge3) => {
19150
+ return flip === isDescendant(t, t.node(edge3.v), tailLabel) && flip !== isDescendant(t, t.node(edge3.w), tailLabel);
19151
+ });
19152
+ return candidates.reduce((acc, edge3) => {
19153
+ if (slack(g, edge3) < slack(g, acc)) {
19154
+ return edge3;
19155
+ }
19156
+ return acc;
19157
+ });
19158
+ }
19159
+ function exchangeEdges(t, g, e, f) {
19160
+ var v = e.v;
19161
+ var w = e.w;
19162
+ t.removeEdge(v, w);
19163
+ t.setEdge(f.v, f.w, {});
19164
+ initLowLimValues(t);
19165
+ initCutValues(t, g);
19166
+ updateRanks(t, g);
19167
+ }
19168
+ function updateRanks(t, g) {
19169
+ var root2 = t.nodes().find((v) => !g.node(v).parent);
19170
+ var vs = preorder(t, root2);
19171
+ vs = vs.slice(1);
19172
+ vs.forEach((v) => {
19173
+ var parent = t.node(v).parent, edge2 = g.edge(v, parent), flipped = false;
19174
+ if (!edge2) {
19175
+ edge2 = g.edge(parent, v);
19176
+ flipped = true;
19177
+ }
19178
+ g.node(v).rank = g.node(parent).rank + (flipped ? edge2.minlen : -edge2.minlen);
19179
+ });
19180
+ }
19181
+ function isTreeEdge(tree, u, v) {
19182
+ return tree.hasEdge(u, v);
19183
+ }
19184
+ function isDescendant(tree, vLabel, rootLabel) {
19185
+ return rootLabel.low <= vLabel.lim && vLabel.lim <= rootLabel.lim;
19186
+ }
19187
+ return networkSimplex_1;
19188
+ }
19189
+ var rank_1;
19190
+ var hasRequiredRank;
19191
+ function requireRank() {
19192
+ if (hasRequiredRank) return rank_1;
19193
+ hasRequiredRank = 1;
19194
+ var rankUtil = requireUtil();
19195
+ var longestPath = rankUtil.longestPath;
19196
+ var feasibleTree = requireFeasibleTree();
19197
+ var networkSimplex = requireNetworkSimplex();
19198
+ rank_1 = rank;
19199
+ function rank(g) {
19200
+ switch (g.graph().ranker) {
19201
+ case "network-simplex":
19202
+ networkSimplexRanker(g);
19203
+ break;
19204
+ case "tight-tree":
19205
+ tightTreeRanker(g);
19206
+ break;
19207
+ case "longest-path":
19208
+ longestPathRanker(g);
19209
+ break;
19210
+ default:
19211
+ networkSimplexRanker(g);
19212
+ }
19213
+ }
19214
+ var longestPathRanker = longestPath;
19215
+ function tightTreeRanker(g) {
19216
+ longestPath(g);
19217
+ feasibleTree(g);
19218
+ }
19219
+ function networkSimplexRanker(g) {
19220
+ networkSimplex(g);
19221
+ }
19222
+ return rank_1;
19223
+ }
19224
+ var parentDummyChains_1;
19225
+ var hasRequiredParentDummyChains;
19226
+ function requireParentDummyChains() {
19227
+ if (hasRequiredParentDummyChains) return parentDummyChains_1;
19228
+ hasRequiredParentDummyChains = 1;
19229
+ parentDummyChains_1 = parentDummyChains;
19230
+ function parentDummyChains(g) {
19231
+ let postorderNums = postorder(g);
19232
+ g.graph().dummyChains.forEach((v) => {
19233
+ let node2 = g.node(v);
19234
+ let edgeObj = node2.edgeObj;
19235
+ let pathData = findPath(g, postorderNums, edgeObj.v, edgeObj.w);
19236
+ let path = pathData.path;
19237
+ let lca = pathData.lca;
19238
+ let pathIdx = 0;
19239
+ let pathV = path[pathIdx];
19240
+ let ascending2 = true;
19241
+ while (v !== edgeObj.w) {
19242
+ node2 = g.node(v);
19243
+ if (ascending2) {
19244
+ while ((pathV = path[pathIdx]) !== lca && g.node(pathV).maxRank < node2.rank) {
19245
+ pathIdx++;
19246
+ }
19247
+ if (pathV === lca) {
19248
+ ascending2 = false;
19249
+ }
19250
+ }
19251
+ if (!ascending2) {
19252
+ while (pathIdx < path.length - 1 && g.node(pathV = path[pathIdx + 1]).minRank <= node2.rank) {
19253
+ pathIdx++;
19254
+ }
19255
+ pathV = path[pathIdx];
19256
+ }
19257
+ g.setParent(v, pathV);
19258
+ v = g.successors(v)[0];
19259
+ }
19260
+ });
19261
+ }
19262
+ function findPath(g, postorderNums, v, w) {
19263
+ let vPath = [];
19264
+ let wPath = [];
19265
+ let low = Math.min(postorderNums[v].low, postorderNums[w].low);
19266
+ let lim = Math.max(postorderNums[v].lim, postorderNums[w].lim);
19267
+ let parent;
19268
+ let lca;
19269
+ parent = v;
19270
+ do {
19271
+ parent = g.parent(parent);
19272
+ vPath.push(parent);
19273
+ } while (parent && (postorderNums[parent].low > low || lim > postorderNums[parent].lim));
19274
+ lca = parent;
19275
+ parent = w;
19276
+ while ((parent = g.parent(parent)) !== lca) {
19277
+ wPath.push(parent);
19278
+ }
19279
+ return { path: vPath.concat(wPath.reverse()), lca };
19280
+ }
19281
+ function postorder(g) {
19282
+ let result = {};
19283
+ let lim = 0;
19284
+ function dfs(v) {
19285
+ let low = lim;
19286
+ g.children(v).forEach(dfs);
19287
+ result[v] = { low, lim: lim++ };
19288
+ }
19289
+ g.children().forEach(dfs);
19290
+ return result;
19291
+ }
19292
+ return parentDummyChains_1;
19293
+ }
19294
+ var nestingGraph;
19295
+ var hasRequiredNestingGraph;
19296
+ function requireNestingGraph() {
19297
+ if (hasRequiredNestingGraph) return nestingGraph;
19298
+ hasRequiredNestingGraph = 1;
19299
+ let util2 = requireUtil$1();
19300
+ nestingGraph = {
19301
+ run,
19302
+ cleanup
19303
+ };
19304
+ function run(g) {
19305
+ let root2 = util2.addDummyNode(g, "root", {}, "_root");
19306
+ let depths = treeDepths(g);
19307
+ let depthsArr = Object.values(depths);
19308
+ let height = util2.applyWithChunking(Math.max, depthsArr) - 1;
19309
+ let nodeSep = 2 * height + 1;
19310
+ g.graph().nestingRoot = root2;
19311
+ g.edges().forEach((e) => g.edge(e).minlen *= nodeSep);
19312
+ let weight = sumWeights(g) + 1;
19313
+ g.children().forEach((child) => dfs(g, root2, nodeSep, weight, height, depths, child));
19314
+ g.graph().nodeRankFactor = nodeSep;
19315
+ }
19316
+ function dfs(g, root2, nodeSep, weight, height, depths, v) {
19317
+ let children2 = g.children(v);
19318
+ if (!children2.length) {
19319
+ if (v !== root2) {
19320
+ g.setEdge(root2, v, { weight: 0, minlen: nodeSep });
19321
+ }
19322
+ return;
19323
+ }
19324
+ let top2 = util2.addBorderNode(g, "_bt");
19325
+ let bottom2 = util2.addBorderNode(g, "_bb");
19326
+ let label2 = g.node(v);
19327
+ g.setParent(top2, v);
19328
+ label2.borderTop = top2;
19329
+ g.setParent(bottom2, v);
19330
+ label2.borderBottom = bottom2;
19331
+ children2.forEach((child) => {
19332
+ dfs(g, root2, nodeSep, weight, height, depths, child);
19333
+ let childNode = g.node(child);
19334
+ let childTop = childNode.borderTop ? childNode.borderTop : child;
19335
+ let childBottom = childNode.borderBottom ? childNode.borderBottom : child;
19336
+ let thisWeight = childNode.borderTop ? weight : 2 * weight;
19337
+ let minlen = childTop !== childBottom ? 1 : height - depths[v] + 1;
19338
+ g.setEdge(top2, childTop, {
19339
+ weight: thisWeight,
19340
+ minlen,
19341
+ nestingEdge: true
19342
+ });
19343
+ g.setEdge(childBottom, bottom2, {
19344
+ weight: thisWeight,
19345
+ minlen,
19346
+ nestingEdge: true
19347
+ });
19348
+ });
19349
+ if (!g.parent(v)) {
19350
+ g.setEdge(root2, top2, { weight: 0, minlen: height + depths[v] });
19351
+ }
19352
+ }
19353
+ function treeDepths(g) {
19354
+ var depths = {};
19355
+ function dfs2(v, depth) {
19356
+ var children2 = g.children(v);
19357
+ if (children2 && children2.length) {
19358
+ children2.forEach((child) => dfs2(child, depth + 1));
19359
+ }
19360
+ depths[v] = depth;
19361
+ }
19362
+ g.children().forEach((v) => dfs2(v, 1));
19363
+ return depths;
19364
+ }
19365
+ function sumWeights(g) {
19366
+ return g.edges().reduce((acc, e) => acc + g.edge(e).weight, 0);
19367
+ }
19368
+ function cleanup(g) {
19369
+ var graphLabel = g.graph();
19370
+ g.removeNode(graphLabel.nestingRoot);
19371
+ delete graphLabel.nestingRoot;
19372
+ g.edges().forEach((e) => {
19373
+ var edge2 = g.edge(e);
19374
+ if (edge2.nestingEdge) {
19375
+ g.removeEdge(e);
19376
+ }
19377
+ });
19378
+ }
19379
+ return nestingGraph;
19380
+ }
19381
+ var addBorderSegments_1;
19382
+ var hasRequiredAddBorderSegments;
19383
+ function requireAddBorderSegments() {
19384
+ if (hasRequiredAddBorderSegments) return addBorderSegments_1;
19385
+ hasRequiredAddBorderSegments = 1;
19386
+ let util2 = requireUtil$1();
19387
+ addBorderSegments_1 = addBorderSegments;
19388
+ function addBorderSegments(g) {
19389
+ function dfs(v) {
19390
+ let children2 = g.children(v);
19391
+ let node2 = g.node(v);
19392
+ if (children2.length) {
19393
+ children2.forEach(dfs);
19394
+ }
19395
+ if (Object.hasOwn(node2, "minRank")) {
19396
+ node2.borderLeft = [];
19397
+ node2.borderRight = [];
19398
+ for (let rank = node2.minRank, maxRank = node2.maxRank + 1; rank < maxRank; ++rank) {
19399
+ addBorderNode(g, "borderLeft", "_bl", v, node2, rank);
19400
+ addBorderNode(g, "borderRight", "_br", v, node2, rank);
19401
+ }
19402
+ }
19403
+ }
19404
+ g.children().forEach(dfs);
19405
+ }
19406
+ function addBorderNode(g, prop, prefix, sg, sgNode, rank) {
19407
+ let label2 = { width: 0, height: 0, rank, borderType: prop };
19408
+ let prev = sgNode[prop][rank - 1];
19409
+ let curr = util2.addDummyNode(g, "border", label2, prefix);
19410
+ sgNode[prop][rank] = curr;
19411
+ g.setParent(curr, sg);
19412
+ if (prev) {
19413
+ g.setEdge(prev, curr, { weight: 1 });
19414
+ }
19415
+ }
19416
+ return addBorderSegments_1;
19417
+ }
19418
+ var coordinateSystem;
19419
+ var hasRequiredCoordinateSystem;
19420
+ function requireCoordinateSystem() {
19421
+ if (hasRequiredCoordinateSystem) return coordinateSystem;
19422
+ hasRequiredCoordinateSystem = 1;
19423
+ coordinateSystem = {
19424
+ adjust,
19425
+ undo
19426
+ };
19427
+ function adjust(g) {
19428
+ let rankDir = g.graph().rankdir.toLowerCase();
19429
+ if (rankDir === "lr" || rankDir === "rl") {
19430
+ swapWidthHeight(g);
19431
+ }
19432
+ }
19433
+ function undo(g) {
19434
+ let rankDir = g.graph().rankdir.toLowerCase();
19435
+ if (rankDir === "bt" || rankDir === "rl") {
19436
+ reverseY(g);
19437
+ }
19438
+ if (rankDir === "lr" || rankDir === "rl") {
19439
+ swapXY(g);
19440
+ swapWidthHeight(g);
19441
+ }
19442
+ }
19443
+ function swapWidthHeight(g) {
19444
+ g.nodes().forEach((v) => swapWidthHeightOne(g.node(v)));
19445
+ g.edges().forEach((e) => swapWidthHeightOne(g.edge(e)));
19446
+ }
19447
+ function swapWidthHeightOne(attrs) {
19448
+ let w = attrs.width;
19449
+ attrs.width = attrs.height;
19450
+ attrs.height = w;
19451
+ }
19452
+ function reverseY(g) {
19453
+ g.nodes().forEach((v) => reverseYOne(g.node(v)));
19454
+ g.edges().forEach((e) => {
19455
+ let edge2 = g.edge(e);
19456
+ edge2.points.forEach(reverseYOne);
19457
+ if (Object.hasOwn(edge2, "y")) {
19458
+ reverseYOne(edge2);
19459
+ }
19460
+ });
19461
+ }
19462
+ function reverseYOne(attrs) {
19463
+ attrs.y = -attrs.y;
19464
+ }
19465
+ function swapXY(g) {
19466
+ g.nodes().forEach((v) => swapXYOne(g.node(v)));
19467
+ g.edges().forEach((e) => {
19468
+ let edge2 = g.edge(e);
19469
+ edge2.points.forEach(swapXYOne);
19470
+ if (Object.hasOwn(edge2, "x")) {
19471
+ swapXYOne(edge2);
19472
+ }
19473
+ });
19474
+ }
19475
+ function swapXYOne(attrs) {
19476
+ let x = attrs.x;
19477
+ attrs.x = attrs.y;
19478
+ attrs.y = x;
19479
+ }
19480
+ return coordinateSystem;
19481
+ }
19482
+ var initOrder_1;
19483
+ var hasRequiredInitOrder;
19484
+ function requireInitOrder() {
19485
+ if (hasRequiredInitOrder) return initOrder_1;
19486
+ hasRequiredInitOrder = 1;
19487
+ let util2 = requireUtil$1();
19488
+ initOrder_1 = initOrder;
19489
+ function initOrder(g) {
19490
+ let visited = {};
19491
+ let simpleNodes = g.nodes().filter((v) => !g.children(v).length);
19492
+ let simpleNodesRanks = simpleNodes.map((v) => g.node(v).rank);
19493
+ let maxRank = util2.applyWithChunking(Math.max, simpleNodesRanks);
19494
+ let layers = util2.range(maxRank + 1).map(() => []);
19495
+ function dfs(v) {
19496
+ if (visited[v]) return;
19497
+ visited[v] = true;
19498
+ let node2 = g.node(v);
19499
+ layers[node2.rank].push(v);
19500
+ g.successors(v).forEach(dfs);
19501
+ }
19502
+ let orderedVs = simpleNodes.sort((a, b) => g.node(a).rank - g.node(b).rank);
19503
+ orderedVs.forEach(dfs);
19504
+ return layers;
19505
+ }
19506
+ return initOrder_1;
19507
+ }
19508
+ var crossCount_1;
19509
+ var hasRequiredCrossCount;
19510
+ function requireCrossCount() {
19511
+ if (hasRequiredCrossCount) return crossCount_1;
19512
+ hasRequiredCrossCount = 1;
19513
+ let zipObject = requireUtil$1().zipObject;
19514
+ crossCount_1 = crossCount;
19515
+ function crossCount(g, layering) {
19516
+ let cc = 0;
19517
+ for (let i = 1; i < layering.length; ++i) {
19518
+ cc += twoLayerCrossCount(g, layering[i - 1], layering[i]);
19519
+ }
19520
+ return cc;
19521
+ }
19522
+ function twoLayerCrossCount(g, northLayer, southLayer) {
19523
+ let southPos = zipObject(southLayer, southLayer.map((v, i) => i));
19524
+ let southEntries = northLayer.flatMap((v) => {
19525
+ return g.outEdges(v).map((e) => {
19526
+ return { pos: southPos[e.w], weight: g.edge(e).weight };
19527
+ }).sort((a, b) => a.pos - b.pos);
19528
+ });
19529
+ let firstIndex = 1;
19530
+ while (firstIndex < southLayer.length) firstIndex <<= 1;
19531
+ let treeSize = 2 * firstIndex - 1;
19532
+ firstIndex -= 1;
19533
+ let tree = new Array(treeSize).fill(0);
19534
+ let cc = 0;
19535
+ southEntries.forEach((entry) => {
19536
+ let index = entry.pos + firstIndex;
19537
+ tree[index] += entry.weight;
19538
+ let weightSum = 0;
19539
+ while (index > 0) {
19540
+ if (index % 2) {
19541
+ weightSum += tree[index + 1];
19542
+ }
19543
+ index = index - 1 >> 1;
19544
+ tree[index] += entry.weight;
19545
+ }
19546
+ cc += entry.weight * weightSum;
19547
+ });
19548
+ return cc;
19549
+ }
19550
+ return crossCount_1;
19551
+ }
19552
+ var barycenter_1;
19553
+ var hasRequiredBarycenter;
19554
+ function requireBarycenter() {
19555
+ if (hasRequiredBarycenter) return barycenter_1;
19556
+ hasRequiredBarycenter = 1;
19557
+ barycenter_1 = barycenter;
19558
+ function barycenter(g, movable = []) {
19559
+ return movable.map((v) => {
19560
+ let inV = g.inEdges(v);
19561
+ if (!inV.length) {
19562
+ return { v };
19563
+ } else {
19564
+ let result = inV.reduce((acc, e) => {
19565
+ let edge2 = g.edge(e), nodeU = g.node(e.v);
19566
+ return {
19567
+ sum: acc.sum + edge2.weight * nodeU.order,
19568
+ weight: acc.weight + edge2.weight
19569
+ };
19570
+ }, { sum: 0, weight: 0 });
19571
+ return {
19572
+ v,
19573
+ barycenter: result.sum / result.weight,
19574
+ weight: result.weight
19575
+ };
19576
+ }
19577
+ });
19578
+ }
19579
+ return barycenter_1;
19580
+ }
19581
+ var resolveConflicts_1;
19582
+ var hasRequiredResolveConflicts;
19583
+ function requireResolveConflicts() {
19584
+ if (hasRequiredResolveConflicts) return resolveConflicts_1;
19585
+ hasRequiredResolveConflicts = 1;
19586
+ let util2 = requireUtil$1();
19587
+ resolveConflicts_1 = resolveConflicts;
19588
+ function resolveConflicts(entries, cg) {
19589
+ let mappedEntries = {};
19590
+ entries.forEach((entry, i) => {
19591
+ let tmp = mappedEntries[entry.v] = {
19592
+ indegree: 0,
19593
+ "in": [],
19594
+ out: [],
19595
+ vs: [entry.v],
19596
+ i
19597
+ };
19598
+ if (entry.barycenter !== void 0) {
19599
+ tmp.barycenter = entry.barycenter;
19600
+ tmp.weight = entry.weight;
19601
+ }
19602
+ });
19603
+ cg.edges().forEach((e) => {
19604
+ let entryV = mappedEntries[e.v];
19605
+ let entryW = mappedEntries[e.w];
19606
+ if (entryV !== void 0 && entryW !== void 0) {
19607
+ entryW.indegree++;
19608
+ entryV.out.push(mappedEntries[e.w]);
19609
+ }
19610
+ });
19611
+ let sourceSet = Object.values(mappedEntries).filter((entry) => !entry.indegree);
19612
+ return doResolveConflicts(sourceSet);
19613
+ }
19614
+ function doResolveConflicts(sourceSet) {
19615
+ let entries = [];
19616
+ function handleIn(vEntry) {
19617
+ return (uEntry) => {
19618
+ if (uEntry.merged) {
19619
+ return;
19620
+ }
19621
+ if (uEntry.barycenter === void 0 || vEntry.barycenter === void 0 || uEntry.barycenter >= vEntry.barycenter) {
19622
+ mergeEntries(vEntry, uEntry);
19623
+ }
19624
+ };
19625
+ }
19626
+ function handleOut(vEntry) {
19627
+ return (wEntry) => {
19628
+ wEntry["in"].push(vEntry);
19629
+ if (--wEntry.indegree === 0) {
19630
+ sourceSet.push(wEntry);
19631
+ }
19632
+ };
19633
+ }
19634
+ while (sourceSet.length) {
19635
+ let entry = sourceSet.pop();
19636
+ entries.push(entry);
19637
+ entry["in"].reverse().forEach(handleIn(entry));
19638
+ entry.out.forEach(handleOut(entry));
19639
+ }
19640
+ return entries.filter((entry) => !entry.merged).map((entry) => {
19641
+ return util2.pick(entry, ["vs", "i", "barycenter", "weight"]);
19642
+ });
19643
+ }
19644
+ function mergeEntries(target2, source) {
19645
+ let sum = 0;
19646
+ let weight = 0;
19647
+ if (target2.weight) {
19648
+ sum += target2.barycenter * target2.weight;
19649
+ weight += target2.weight;
19650
+ }
19651
+ if (source.weight) {
19652
+ sum += source.barycenter * source.weight;
19653
+ weight += source.weight;
19654
+ }
19655
+ target2.vs = source.vs.concat(target2.vs);
19656
+ target2.barycenter = sum / weight;
19657
+ target2.weight = weight;
19658
+ target2.i = Math.min(source.i, target2.i);
19659
+ source.merged = true;
19660
+ }
19661
+ return resolveConflicts_1;
19662
+ }
19663
+ var sort_1;
19664
+ var hasRequiredSort;
19665
+ function requireSort() {
19666
+ if (hasRequiredSort) return sort_1;
19667
+ hasRequiredSort = 1;
19668
+ let util2 = requireUtil$1();
19669
+ sort_1 = sort;
19670
+ function sort(entries, biasRight) {
19671
+ let parts = util2.partition(entries, (entry) => {
19672
+ return Object.hasOwn(entry, "barycenter");
19673
+ });
19674
+ let sortable = parts.lhs, unsortable = parts.rhs.sort((a, b) => b.i - a.i), vs = [], sum = 0, weight = 0, vsIndex = 0;
19675
+ sortable.sort(compareWithBias(!!biasRight));
19676
+ vsIndex = consumeUnsortable(vs, unsortable, vsIndex);
19677
+ sortable.forEach((entry) => {
19678
+ vsIndex += entry.vs.length;
19679
+ vs.push(entry.vs);
19680
+ sum += entry.barycenter * entry.weight;
19681
+ weight += entry.weight;
19682
+ vsIndex = consumeUnsortable(vs, unsortable, vsIndex);
19683
+ });
19684
+ let result = { vs: vs.flat(true) };
19685
+ if (weight) {
19686
+ result.barycenter = sum / weight;
19687
+ result.weight = weight;
19688
+ }
19689
+ return result;
19690
+ }
19691
+ function consumeUnsortable(vs, unsortable, index) {
19692
+ let last;
19693
+ while (unsortable.length && (last = unsortable[unsortable.length - 1]).i <= index) {
19694
+ unsortable.pop();
19695
+ vs.push(last.vs);
19696
+ index++;
19697
+ }
19698
+ return index;
19699
+ }
19700
+ function compareWithBias(bias) {
19701
+ return (entryV, entryW) => {
19702
+ if (entryV.barycenter < entryW.barycenter) {
19703
+ return -1;
19704
+ } else if (entryV.barycenter > entryW.barycenter) {
19705
+ return 1;
19706
+ }
19707
+ return !bias ? entryV.i - entryW.i : entryW.i - entryV.i;
19708
+ };
19709
+ }
19710
+ return sort_1;
19711
+ }
19712
+ var sortSubgraph_1;
19713
+ var hasRequiredSortSubgraph;
19714
+ function requireSortSubgraph() {
19715
+ if (hasRequiredSortSubgraph) return sortSubgraph_1;
19716
+ hasRequiredSortSubgraph = 1;
19717
+ let barycenter = requireBarycenter();
19718
+ let resolveConflicts = requireResolveConflicts();
19719
+ let sort = requireSort();
19720
+ sortSubgraph_1 = sortSubgraph;
19721
+ function sortSubgraph(g, v, cg, biasRight) {
19722
+ let movable = g.children(v);
19723
+ let node2 = g.node(v);
19724
+ let bl = node2 ? node2.borderLeft : void 0;
19725
+ let br = node2 ? node2.borderRight : void 0;
19726
+ let subgraphs = {};
19727
+ if (bl) {
19728
+ movable = movable.filter((w) => w !== bl && w !== br);
19729
+ }
19730
+ let barycenters = barycenter(g, movable);
19731
+ barycenters.forEach((entry) => {
19732
+ if (g.children(entry.v).length) {
19733
+ let subgraphResult = sortSubgraph(g, entry.v, cg, biasRight);
19734
+ subgraphs[entry.v] = subgraphResult;
19735
+ if (Object.hasOwn(subgraphResult, "barycenter")) {
19736
+ mergeBarycenters(entry, subgraphResult);
19737
+ }
19738
+ }
19739
+ });
19740
+ let entries = resolveConflicts(barycenters, cg);
19741
+ expandSubgraphs(entries, subgraphs);
19742
+ let result = sort(entries, biasRight);
19743
+ if (bl) {
19744
+ result.vs = [bl, result.vs, br].flat(true);
19745
+ if (g.predecessors(bl).length) {
19746
+ let blPred = g.node(g.predecessors(bl)[0]), brPred = g.node(g.predecessors(br)[0]);
19747
+ if (!Object.hasOwn(result, "barycenter")) {
19748
+ result.barycenter = 0;
19749
+ result.weight = 0;
19750
+ }
19751
+ result.barycenter = (result.barycenter * result.weight + blPred.order + brPred.order) / (result.weight + 2);
19752
+ result.weight += 2;
19753
+ }
19754
+ }
19755
+ return result;
19756
+ }
19757
+ function expandSubgraphs(entries, subgraphs) {
19758
+ entries.forEach((entry) => {
19759
+ entry.vs = entry.vs.flatMap((v) => {
19760
+ if (subgraphs[v]) {
19761
+ return subgraphs[v].vs;
19762
+ }
19763
+ return v;
19764
+ });
19765
+ });
19766
+ }
19767
+ function mergeBarycenters(target2, other) {
19768
+ if (target2.barycenter !== void 0) {
19769
+ target2.barycenter = (target2.barycenter * target2.weight + other.barycenter * other.weight) / (target2.weight + other.weight);
19770
+ target2.weight += other.weight;
19771
+ } else {
19772
+ target2.barycenter = other.barycenter;
19773
+ target2.weight = other.weight;
19774
+ }
19775
+ }
19776
+ return sortSubgraph_1;
19777
+ }
19778
+ var buildLayerGraph_1;
19779
+ var hasRequiredBuildLayerGraph;
19780
+ function requireBuildLayerGraph() {
19781
+ if (hasRequiredBuildLayerGraph) return buildLayerGraph_1;
19782
+ hasRequiredBuildLayerGraph = 1;
19783
+ let Graph = requireGraphlib().Graph;
19784
+ let util2 = requireUtil$1();
19785
+ buildLayerGraph_1 = buildLayerGraph;
19786
+ function buildLayerGraph(g, rank, relationship) {
19787
+ let root2 = createRootNode(g), result = new Graph({ compound: true }).setGraph({ root: root2 }).setDefaultNodeLabel((v) => g.node(v));
19788
+ g.nodes().forEach((v) => {
19789
+ let node2 = g.node(v), parent = g.parent(v);
19790
+ if (node2.rank === rank || node2.minRank <= rank && rank <= node2.maxRank) {
19791
+ result.setNode(v);
19792
+ result.setParent(v, parent || root2);
19793
+ g[relationship](v).forEach((e) => {
19794
+ let u = e.v === v ? e.w : e.v, edge2 = result.edge(u, v), weight = edge2 !== void 0 ? edge2.weight : 0;
19795
+ result.setEdge(u, v, { weight: g.edge(e).weight + weight });
19796
+ });
19797
+ if (Object.hasOwn(node2, "minRank")) {
19798
+ result.setNode(v, {
19799
+ borderLeft: node2.borderLeft[rank],
19800
+ borderRight: node2.borderRight[rank]
19801
+ });
19802
+ }
19803
+ }
19804
+ });
19805
+ return result;
19806
+ }
19807
+ function createRootNode(g) {
19808
+ var v;
19809
+ while (g.hasNode(v = util2.uniqueId("_root"))) ;
19810
+ return v;
19811
+ }
19812
+ return buildLayerGraph_1;
19813
+ }
19814
+ var addSubgraphConstraints_1;
19815
+ var hasRequiredAddSubgraphConstraints;
19816
+ function requireAddSubgraphConstraints() {
19817
+ if (hasRequiredAddSubgraphConstraints) return addSubgraphConstraints_1;
19818
+ hasRequiredAddSubgraphConstraints = 1;
19819
+ addSubgraphConstraints_1 = addSubgraphConstraints;
19820
+ function addSubgraphConstraints(g, cg, vs) {
19821
+ let prev = {}, rootPrev;
19822
+ vs.forEach((v) => {
19823
+ let child = g.parent(v), parent, prevChild;
19824
+ while (child) {
19825
+ parent = g.parent(child);
19826
+ if (parent) {
19827
+ prevChild = prev[parent];
19828
+ prev[parent] = child;
19829
+ } else {
19830
+ prevChild = rootPrev;
19831
+ rootPrev = child;
19832
+ }
19833
+ if (prevChild && prevChild !== child) {
19834
+ cg.setEdge(prevChild, child);
19835
+ return;
19836
+ }
19837
+ child = parent;
19838
+ }
19839
+ });
19840
+ }
19841
+ return addSubgraphConstraints_1;
19842
+ }
19843
+ var order_1;
19844
+ var hasRequiredOrder;
19845
+ function requireOrder() {
19846
+ if (hasRequiredOrder) return order_1;
19847
+ hasRequiredOrder = 1;
19848
+ let initOrder = requireInitOrder();
19849
+ let crossCount = requireCrossCount();
19850
+ let sortSubgraph = requireSortSubgraph();
19851
+ let buildLayerGraph = requireBuildLayerGraph();
19852
+ let addSubgraphConstraints = requireAddSubgraphConstraints();
19853
+ let Graph = requireGraphlib().Graph;
19854
+ let util2 = requireUtil$1();
19855
+ order_1 = order;
19856
+ function order(g, opts) {
19857
+ if (opts && typeof opts.customOrder === "function") {
19858
+ opts.customOrder(g, order);
19859
+ return;
19860
+ }
19861
+ let maxRank = util2.maxRank(g), downLayerGraphs = buildLayerGraphs(g, util2.range(1, maxRank + 1), "inEdges"), upLayerGraphs = buildLayerGraphs(g, util2.range(maxRank - 1, -1, -1), "outEdges");
19862
+ let layering = initOrder(g);
19863
+ assignOrder(g, layering);
19864
+ if (opts && opts.disableOptimalOrderHeuristic) {
19865
+ return;
19866
+ }
19867
+ let bestCC = Number.POSITIVE_INFINITY, best;
19868
+ for (let i = 0, lastBest = 0; lastBest < 4; ++i, ++lastBest) {
19869
+ sweepLayerGraphs(i % 2 ? downLayerGraphs : upLayerGraphs, i % 4 >= 2);
19870
+ layering = util2.buildLayerMatrix(g);
19871
+ let cc = crossCount(g, layering);
19872
+ if (cc < bestCC) {
19873
+ lastBest = 0;
19874
+ best = Object.assign({}, layering);
19875
+ bestCC = cc;
19876
+ }
19877
+ }
19878
+ assignOrder(g, best);
19879
+ }
19880
+ function buildLayerGraphs(g, ranks, relationship) {
19881
+ return ranks.map(function(rank) {
19882
+ return buildLayerGraph(g, rank, relationship);
19883
+ });
19884
+ }
19885
+ function sweepLayerGraphs(layerGraphs, biasRight) {
19886
+ let cg = new Graph();
19887
+ layerGraphs.forEach(function(lg) {
19888
+ let root2 = lg.graph().root;
19889
+ let sorted = sortSubgraph(lg, root2, cg, biasRight);
19890
+ sorted.vs.forEach((v, i) => lg.node(v).order = i);
19891
+ addSubgraphConstraints(lg, cg, sorted.vs);
19892
+ });
19893
+ }
19894
+ function assignOrder(g, layering) {
19895
+ Object.values(layering).forEach((layer) => layer.forEach((v, i) => g.node(v).order = i));
19896
+ }
19897
+ return order_1;
19898
+ }
19899
+ var bk;
19900
+ var hasRequiredBk;
19901
+ function requireBk() {
19902
+ if (hasRequiredBk) return bk;
19903
+ hasRequiredBk = 1;
19904
+ let Graph = requireGraphlib().Graph;
19905
+ let util2 = requireUtil$1();
19906
+ bk = {
19907
+ positionX,
19908
+ findType1Conflicts,
19909
+ findType2Conflicts,
19910
+ addConflict,
19911
+ hasConflict,
19912
+ verticalAlignment,
19913
+ horizontalCompaction,
19914
+ alignCoordinates,
19915
+ findSmallestWidthAlignment,
19916
+ balance
19917
+ };
19918
+ function findType1Conflicts(g, layering) {
19919
+ let conflicts = {};
19920
+ function visitLayer(prevLayer, layer) {
19921
+ let k0 = 0, scanPos = 0, prevLayerLength = prevLayer.length, lastNode = layer[layer.length - 1];
19922
+ layer.forEach((v, i) => {
19923
+ let w = findOtherInnerSegmentNode(g, v), k1 = w ? g.node(w).order : prevLayerLength;
19924
+ if (w || v === lastNode) {
19925
+ layer.slice(scanPos, i + 1).forEach((scanNode) => {
19926
+ g.predecessors(scanNode).forEach((u) => {
19927
+ let uLabel = g.node(u), uPos = uLabel.order;
19928
+ if ((uPos < k0 || k1 < uPos) && !(uLabel.dummy && g.node(scanNode).dummy)) {
19929
+ addConflict(conflicts, u, scanNode);
19930
+ }
19931
+ });
19932
+ });
19933
+ scanPos = i + 1;
19934
+ k0 = k1;
19935
+ }
19936
+ });
19937
+ return layer;
19938
+ }
19939
+ layering.length && layering.reduce(visitLayer);
19940
+ return conflicts;
19941
+ }
19942
+ function findType2Conflicts(g, layering) {
19943
+ let conflicts = {};
19944
+ function scan(south, southPos, southEnd, prevNorthBorder, nextNorthBorder) {
19945
+ let v;
19946
+ util2.range(southPos, southEnd).forEach((i) => {
19947
+ v = south[i];
19948
+ if (g.node(v).dummy) {
19949
+ g.predecessors(v).forEach((u) => {
19950
+ let uNode = g.node(u);
19951
+ if (uNode.dummy && (uNode.order < prevNorthBorder || uNode.order > nextNorthBorder)) {
19952
+ addConflict(conflicts, u, v);
19953
+ }
19954
+ });
19955
+ }
19956
+ });
19957
+ }
19958
+ function visitLayer(north, south) {
19959
+ let prevNorthPos = -1, nextNorthPos, southPos = 0;
19960
+ south.forEach((v, southLookahead) => {
19961
+ if (g.node(v).dummy === "border") {
19962
+ let predecessors = g.predecessors(v);
19963
+ if (predecessors.length) {
19964
+ nextNorthPos = g.node(predecessors[0]).order;
19965
+ scan(south, southPos, southLookahead, prevNorthPos, nextNorthPos);
19966
+ southPos = southLookahead;
19967
+ prevNorthPos = nextNorthPos;
19968
+ }
19969
+ }
19970
+ scan(south, southPos, south.length, nextNorthPos, north.length);
19971
+ });
19972
+ return south;
19973
+ }
19974
+ layering.length && layering.reduce(visitLayer);
19975
+ return conflicts;
19976
+ }
19977
+ function findOtherInnerSegmentNode(g, v) {
19978
+ if (g.node(v).dummy) {
19979
+ return g.predecessors(v).find((u) => g.node(u).dummy);
19980
+ }
19981
+ }
19982
+ function addConflict(conflicts, v, w) {
19983
+ if (v > w) {
19984
+ let tmp = v;
19985
+ v = w;
19986
+ w = tmp;
19987
+ }
19988
+ let conflictsV = conflicts[v];
19989
+ if (!conflictsV) {
19990
+ conflicts[v] = conflictsV = {};
19991
+ }
19992
+ conflictsV[w] = true;
19993
+ }
19994
+ function hasConflict(conflicts, v, w) {
19995
+ if (v > w) {
19996
+ let tmp = v;
19997
+ v = w;
19998
+ w = tmp;
19999
+ }
20000
+ return !!conflicts[v] && Object.hasOwn(conflicts[v], w);
20001
+ }
20002
+ function verticalAlignment(g, layering, conflicts, neighborFn) {
20003
+ let root2 = {}, align = {}, pos = {};
20004
+ layering.forEach((layer) => {
20005
+ layer.forEach((v, order) => {
20006
+ root2[v] = v;
20007
+ align[v] = v;
20008
+ pos[v] = order;
20009
+ });
20010
+ });
20011
+ layering.forEach((layer) => {
20012
+ let prevIdx = -1;
20013
+ layer.forEach((v) => {
20014
+ let ws = neighborFn(v);
20015
+ if (ws.length) {
20016
+ ws = ws.sort((a, b) => pos[a] - pos[b]);
20017
+ let mp = (ws.length - 1) / 2;
20018
+ for (let i = Math.floor(mp), il = Math.ceil(mp); i <= il; ++i) {
20019
+ let w = ws[i];
20020
+ if (align[v] === v && prevIdx < pos[w] && !hasConflict(conflicts, v, w)) {
20021
+ align[w] = v;
20022
+ align[v] = root2[v] = root2[w];
20023
+ prevIdx = pos[w];
20024
+ }
20025
+ }
20026
+ }
20027
+ });
20028
+ });
20029
+ return { root: root2, align };
20030
+ }
20031
+ function horizontalCompaction(g, layering, root2, align, reverseSep) {
20032
+ let xs = {}, blockG = buildBlockGraph(g, layering, root2, reverseSep), borderType = reverseSep ? "borderLeft" : "borderRight";
20033
+ function iterate(setXsFunc, nextNodesFunc) {
20034
+ let stack = blockG.nodes();
20035
+ let elem = stack.pop();
20036
+ let visited = {};
20037
+ while (elem) {
20038
+ if (visited[elem]) {
20039
+ setXsFunc(elem);
20040
+ } else {
20041
+ visited[elem] = true;
20042
+ stack.push(elem);
20043
+ stack = stack.concat(nextNodesFunc(elem));
20044
+ }
20045
+ elem = stack.pop();
20046
+ }
20047
+ }
20048
+ function pass1(elem) {
20049
+ xs[elem] = blockG.inEdges(elem).reduce((acc, e) => {
20050
+ return Math.max(acc, xs[e.v] + blockG.edge(e));
20051
+ }, 0);
20052
+ }
20053
+ function pass2(elem) {
20054
+ let min = blockG.outEdges(elem).reduce((acc, e) => {
20055
+ return Math.min(acc, xs[e.w] - blockG.edge(e));
20056
+ }, Number.POSITIVE_INFINITY);
20057
+ let node2 = g.node(elem);
20058
+ if (min !== Number.POSITIVE_INFINITY && node2.borderType !== borderType) {
20059
+ xs[elem] = Math.max(xs[elem], min);
20060
+ }
20061
+ }
20062
+ iterate(pass1, blockG.predecessors.bind(blockG));
20063
+ iterate(pass2, blockG.successors.bind(blockG));
20064
+ Object.keys(align).forEach((v) => xs[v] = xs[root2[v]]);
20065
+ return xs;
20066
+ }
20067
+ function buildBlockGraph(g, layering, root2, reverseSep) {
20068
+ let blockGraph = new Graph(), graphLabel = g.graph(), sepFn = sep(graphLabel.nodesep, graphLabel.edgesep, reverseSep);
20069
+ layering.forEach((layer) => {
20070
+ let u;
20071
+ layer.forEach((v) => {
20072
+ let vRoot = root2[v];
20073
+ blockGraph.setNode(vRoot);
20074
+ if (u) {
20075
+ var uRoot = root2[u], prevMax = blockGraph.edge(uRoot, vRoot);
20076
+ blockGraph.setEdge(uRoot, vRoot, Math.max(sepFn(g, v, u), prevMax || 0));
20077
+ }
20078
+ u = v;
20079
+ });
20080
+ });
20081
+ return blockGraph;
20082
+ }
20083
+ function findSmallestWidthAlignment(g, xss) {
20084
+ return Object.values(xss).reduce((currentMinAndXs, xs) => {
20085
+ let max = Number.NEGATIVE_INFINITY;
20086
+ let min = Number.POSITIVE_INFINITY;
20087
+ Object.entries(xs).forEach(([v, x]) => {
20088
+ let halfWidth = width(g, v) / 2;
20089
+ max = Math.max(x + halfWidth, max);
20090
+ min = Math.min(x - halfWidth, min);
20091
+ });
20092
+ const newMin = max - min;
20093
+ if (newMin < currentMinAndXs[0]) {
20094
+ currentMinAndXs = [newMin, xs];
20095
+ }
20096
+ return currentMinAndXs;
20097
+ }, [Number.POSITIVE_INFINITY, null])[1];
20098
+ }
20099
+ function alignCoordinates(xss, alignTo) {
20100
+ let alignToVals = Object.values(alignTo), alignToMin = util2.applyWithChunking(Math.min, alignToVals), alignToMax = util2.applyWithChunking(Math.max, alignToVals);
20101
+ ["u", "d"].forEach((vert) => {
20102
+ ["l", "r"].forEach((horiz) => {
20103
+ let alignment = vert + horiz, xs = xss[alignment];
20104
+ if (xs === alignTo) return;
20105
+ let xsVals = Object.values(xs);
20106
+ let delta = alignToMin - util2.applyWithChunking(Math.min, xsVals);
20107
+ if (horiz !== "l") {
20108
+ delta = alignToMax - util2.applyWithChunking(Math.max, xsVals);
20109
+ }
20110
+ if (delta) {
20111
+ xss[alignment] = util2.mapValues(xs, (x) => x + delta);
20112
+ }
20113
+ });
20114
+ });
20115
+ }
20116
+ function balance(xss, align) {
20117
+ return util2.mapValues(xss.ul, (num, v) => {
20118
+ if (align) {
20119
+ return xss[align.toLowerCase()][v];
20120
+ } else {
20121
+ let xs = Object.values(xss).map((xs2) => xs2[v]).sort((a, b) => a - b);
20122
+ return (xs[1] + xs[2]) / 2;
20123
+ }
20124
+ });
20125
+ }
20126
+ function positionX(g) {
20127
+ let layering = util2.buildLayerMatrix(g);
20128
+ let conflicts = Object.assign(
20129
+ findType1Conflicts(g, layering),
20130
+ findType2Conflicts(g, layering)
20131
+ );
20132
+ let xss = {};
20133
+ let adjustedLayering;
20134
+ ["u", "d"].forEach((vert) => {
20135
+ adjustedLayering = vert === "u" ? layering : Object.values(layering).reverse();
20136
+ ["l", "r"].forEach((horiz) => {
20137
+ if (horiz === "r") {
20138
+ adjustedLayering = adjustedLayering.map((inner) => {
20139
+ return Object.values(inner).reverse();
20140
+ });
20141
+ }
20142
+ let neighborFn = (vert === "u" ? g.predecessors : g.successors).bind(g);
20143
+ let align = verticalAlignment(g, adjustedLayering, conflicts, neighborFn);
20144
+ let xs = horizontalCompaction(
20145
+ g,
20146
+ adjustedLayering,
20147
+ align.root,
20148
+ align.align,
20149
+ horiz === "r"
20150
+ );
20151
+ if (horiz === "r") {
20152
+ xs = util2.mapValues(xs, (x) => -x);
20153
+ }
20154
+ xss[vert + horiz] = xs;
20155
+ });
20156
+ });
20157
+ let smallestWidth = findSmallestWidthAlignment(g, xss);
20158
+ alignCoordinates(xss, smallestWidth);
20159
+ return balance(xss, g.graph().align);
20160
+ }
20161
+ function sep(nodeSep, edgeSep, reverseSep) {
20162
+ return (g, v, w) => {
20163
+ let vLabel = g.node(v);
20164
+ let wLabel = g.node(w);
20165
+ let sum = 0;
20166
+ let delta;
20167
+ sum += vLabel.width / 2;
20168
+ if (Object.hasOwn(vLabel, "labelpos")) {
20169
+ switch (vLabel.labelpos.toLowerCase()) {
20170
+ case "l":
20171
+ delta = -vLabel.width / 2;
20172
+ break;
20173
+ case "r":
20174
+ delta = vLabel.width / 2;
20175
+ break;
20176
+ }
20177
+ }
20178
+ if (delta) {
20179
+ sum += reverseSep ? delta : -delta;
20180
+ }
20181
+ delta = 0;
20182
+ sum += (vLabel.dummy ? edgeSep : nodeSep) / 2;
20183
+ sum += (wLabel.dummy ? edgeSep : nodeSep) / 2;
20184
+ sum += wLabel.width / 2;
20185
+ if (Object.hasOwn(wLabel, "labelpos")) {
20186
+ switch (wLabel.labelpos.toLowerCase()) {
20187
+ case "l":
20188
+ delta = wLabel.width / 2;
20189
+ break;
20190
+ case "r":
20191
+ delta = -wLabel.width / 2;
20192
+ break;
20193
+ }
20194
+ }
20195
+ if (delta) {
20196
+ sum += reverseSep ? delta : -delta;
20197
+ }
20198
+ delta = 0;
20199
+ return sum;
20200
+ };
20201
+ }
20202
+ function width(g, v) {
20203
+ return g.node(v).width;
20204
+ }
20205
+ return bk;
20206
+ }
20207
+ var position_1;
20208
+ var hasRequiredPosition;
20209
+ function requirePosition() {
20210
+ if (hasRequiredPosition) return position_1;
20211
+ hasRequiredPosition = 1;
20212
+ let util2 = requireUtil$1();
20213
+ let positionX = requireBk().positionX;
20214
+ position_1 = position2;
20215
+ function position2(g) {
20216
+ g = util2.asNonCompoundGraph(g);
20217
+ positionY(g);
20218
+ Object.entries(positionX(g)).forEach(([v, x]) => g.node(v).x = x);
20219
+ }
20220
+ function positionY(g) {
20221
+ let layering = util2.buildLayerMatrix(g);
20222
+ let rankSep = g.graph().ranksep;
20223
+ let prevY = 0;
20224
+ layering.forEach((layer) => {
20225
+ const maxHeight = layer.reduce((acc, v) => {
20226
+ const height = g.node(v).height;
20227
+ if (acc > height) {
20228
+ return acc;
20229
+ } else {
20230
+ return height;
20231
+ }
20232
+ }, 0);
20233
+ layer.forEach((v) => g.node(v).y = prevY + maxHeight / 2);
20234
+ prevY += maxHeight + rankSep;
20235
+ });
20236
+ }
20237
+ return position_1;
20238
+ }
20239
+ var layout_1;
20240
+ var hasRequiredLayout;
20241
+ function requireLayout() {
20242
+ if (hasRequiredLayout) return layout_1;
20243
+ hasRequiredLayout = 1;
20244
+ let acyclic2 = requireAcyclic();
20245
+ let normalize2 = requireNormalize();
20246
+ let rank = requireRank();
20247
+ let normalizeRanks = requireUtil$1().normalizeRanks;
20248
+ let parentDummyChains = requireParentDummyChains();
20249
+ let removeEmptyRanks = requireUtil$1().removeEmptyRanks;
20250
+ let nestingGraph2 = requireNestingGraph();
20251
+ let addBorderSegments = requireAddBorderSegments();
20252
+ let coordinateSystem2 = requireCoordinateSystem();
20253
+ let order = requireOrder();
20254
+ let position2 = requirePosition();
20255
+ let util2 = requireUtil$1();
20256
+ let Graph = requireGraphlib().Graph;
20257
+ layout_1 = layout;
20258
+ function layout(g, opts) {
20259
+ let time = opts && opts.debugTiming ? util2.time : util2.notime;
20260
+ time("layout", () => {
20261
+ let layoutGraph = time(" buildLayoutGraph", () => buildLayoutGraph(g));
20262
+ time(" runLayout", () => runLayout(layoutGraph, time, opts));
20263
+ time(" updateInputGraph", () => updateInputGraph(g, layoutGraph));
20264
+ });
20265
+ }
20266
+ function runLayout(g, time, opts) {
20267
+ time(" makeSpaceForEdgeLabels", () => makeSpaceForEdgeLabels(g));
20268
+ time(" removeSelfEdges", () => removeSelfEdges(g));
20269
+ time(" acyclic", () => acyclic2.run(g));
20270
+ time(" nestingGraph.run", () => nestingGraph2.run(g));
20271
+ time(" rank", () => rank(util2.asNonCompoundGraph(g)));
20272
+ time(" injectEdgeLabelProxies", () => injectEdgeLabelProxies(g));
20273
+ time(" removeEmptyRanks", () => removeEmptyRanks(g));
20274
+ time(" nestingGraph.cleanup", () => nestingGraph2.cleanup(g));
20275
+ time(" normalizeRanks", () => normalizeRanks(g));
20276
+ time(" assignRankMinMax", () => assignRankMinMax(g));
20277
+ time(" removeEdgeLabelProxies", () => removeEdgeLabelProxies(g));
20278
+ time(" normalize.run", () => normalize2.run(g));
20279
+ time(" parentDummyChains", () => parentDummyChains(g));
20280
+ time(" addBorderSegments", () => addBorderSegments(g));
20281
+ time(" order", () => order(g, opts));
20282
+ time(" insertSelfEdges", () => insertSelfEdges(g));
20283
+ time(" adjustCoordinateSystem", () => coordinateSystem2.adjust(g));
20284
+ time(" position", () => position2(g));
20285
+ time(" positionSelfEdges", () => positionSelfEdges(g));
20286
+ time(" removeBorderNodes", () => removeBorderNodes(g));
20287
+ time(" normalize.undo", () => normalize2.undo(g));
20288
+ time(" fixupEdgeLabelCoords", () => fixupEdgeLabelCoords(g));
20289
+ time(" undoCoordinateSystem", () => coordinateSystem2.undo(g));
20290
+ time(" translateGraph", () => translateGraph(g));
20291
+ time(" assignNodeIntersects", () => assignNodeIntersects(g));
20292
+ time(" reversePoints", () => reversePointsForReversedEdges(g));
20293
+ time(" acyclic.undo", () => acyclic2.undo(g));
20294
+ }
20295
+ function updateInputGraph(inputGraph, layoutGraph) {
20296
+ inputGraph.nodes().forEach((v) => {
20297
+ let inputLabel = inputGraph.node(v);
20298
+ let layoutLabel = layoutGraph.node(v);
20299
+ if (inputLabel) {
20300
+ inputLabel.x = layoutLabel.x;
20301
+ inputLabel.y = layoutLabel.y;
20302
+ inputLabel.rank = layoutLabel.rank;
20303
+ if (layoutGraph.children(v).length) {
20304
+ inputLabel.width = layoutLabel.width;
20305
+ inputLabel.height = layoutLabel.height;
20306
+ }
20307
+ }
20308
+ });
20309
+ inputGraph.edges().forEach((e) => {
20310
+ let inputLabel = inputGraph.edge(e);
20311
+ let layoutLabel = layoutGraph.edge(e);
20312
+ inputLabel.points = layoutLabel.points;
20313
+ if (Object.hasOwn(layoutLabel, "x")) {
20314
+ inputLabel.x = layoutLabel.x;
20315
+ inputLabel.y = layoutLabel.y;
20316
+ }
20317
+ });
20318
+ inputGraph.graph().width = layoutGraph.graph().width;
20319
+ inputGraph.graph().height = layoutGraph.graph().height;
20320
+ }
20321
+ let graphNumAttrs = ["nodesep", "edgesep", "ranksep", "marginx", "marginy"];
20322
+ let graphDefaults = { ranksep: 50, edgesep: 20, nodesep: 50, rankdir: "tb" };
20323
+ let graphAttrs = ["acyclicer", "ranker", "rankdir", "align"];
20324
+ let nodeNumAttrs = ["width", "height"];
20325
+ let nodeDefaults = { width: 0, height: 0 };
20326
+ let edgeNumAttrs = ["minlen", "weight", "width", "height", "labeloffset"];
20327
+ let edgeDefaults = {
20328
+ minlen: 1,
20329
+ weight: 1,
20330
+ width: 0,
20331
+ height: 0,
20332
+ labeloffset: 10,
20333
+ labelpos: "r"
20334
+ };
20335
+ let edgeAttrs = ["labelpos"];
20336
+ function buildLayoutGraph(inputGraph) {
20337
+ let g = new Graph({ multigraph: true, compound: true });
20338
+ let graph2 = canonicalize(inputGraph.graph());
20339
+ g.setGraph(Object.assign(
20340
+ {},
20341
+ graphDefaults,
20342
+ selectNumberAttrs(graph2, graphNumAttrs),
20343
+ util2.pick(graph2, graphAttrs)
20344
+ ));
20345
+ inputGraph.nodes().forEach((v) => {
20346
+ let node2 = canonicalize(inputGraph.node(v));
20347
+ const newNode = selectNumberAttrs(node2, nodeNumAttrs);
20348
+ Object.keys(nodeDefaults).forEach((k) => {
20349
+ if (newNode[k] === void 0) {
20350
+ newNode[k] = nodeDefaults[k];
20351
+ }
20352
+ });
20353
+ g.setNode(v, newNode);
20354
+ g.setParent(v, inputGraph.parent(v));
20355
+ });
20356
+ inputGraph.edges().forEach((e) => {
20357
+ let edge2 = canonicalize(inputGraph.edge(e));
20358
+ g.setEdge(e, Object.assign(
20359
+ {},
20360
+ edgeDefaults,
20361
+ selectNumberAttrs(edge2, edgeNumAttrs),
20362
+ util2.pick(edge2, edgeAttrs)
20363
+ ));
20364
+ });
20365
+ return g;
20366
+ }
20367
+ function makeSpaceForEdgeLabels(g) {
20368
+ let graph2 = g.graph();
20369
+ graph2.ranksep /= 2;
20370
+ g.edges().forEach((e) => {
20371
+ let edge2 = g.edge(e);
20372
+ edge2.minlen *= 2;
20373
+ if (edge2.labelpos.toLowerCase() !== "c") {
20374
+ if (graph2.rankdir === "TB" || graph2.rankdir === "BT") {
20375
+ edge2.width += edge2.labeloffset;
20376
+ } else {
20377
+ edge2.height += edge2.labeloffset;
20378
+ }
20379
+ }
20380
+ });
20381
+ }
20382
+ function injectEdgeLabelProxies(g) {
20383
+ g.edges().forEach((e) => {
20384
+ let edge2 = g.edge(e);
20385
+ if (edge2.width && edge2.height) {
20386
+ let v = g.node(e.v);
20387
+ let w = g.node(e.w);
20388
+ let label2 = { rank: (w.rank - v.rank) / 2 + v.rank, e };
20389
+ util2.addDummyNode(g, "edge-proxy", label2, "_ep");
20390
+ }
20391
+ });
20392
+ }
20393
+ function assignRankMinMax(g) {
20394
+ let maxRank = 0;
20395
+ g.nodes().forEach((v) => {
20396
+ let node2 = g.node(v);
20397
+ if (node2.borderTop) {
20398
+ node2.minRank = g.node(node2.borderTop).rank;
20399
+ node2.maxRank = g.node(node2.borderBottom).rank;
20400
+ maxRank = Math.max(maxRank, node2.maxRank);
20401
+ }
20402
+ });
20403
+ g.graph().maxRank = maxRank;
20404
+ }
20405
+ function removeEdgeLabelProxies(g) {
20406
+ g.nodes().forEach((v) => {
20407
+ let node2 = g.node(v);
20408
+ if (node2.dummy === "edge-proxy") {
20409
+ g.edge(node2.e).labelRank = node2.rank;
20410
+ g.removeNode(v);
20411
+ }
20412
+ });
20413
+ }
20414
+ function translateGraph(g) {
20415
+ let minX = Number.POSITIVE_INFINITY;
20416
+ let maxX = 0;
20417
+ let minY = Number.POSITIVE_INFINITY;
20418
+ let maxY = 0;
20419
+ let graphLabel = g.graph();
20420
+ let marginX = graphLabel.marginx || 0;
20421
+ let marginY = graphLabel.marginy || 0;
20422
+ function getExtremes(attrs) {
20423
+ let x = attrs.x;
20424
+ let y = attrs.y;
20425
+ let w = attrs.width;
20426
+ let h2 = attrs.height;
20427
+ minX = Math.min(minX, x - w / 2);
20428
+ maxX = Math.max(maxX, x + w / 2);
20429
+ minY = Math.min(minY, y - h2 / 2);
20430
+ maxY = Math.max(maxY, y + h2 / 2);
20431
+ }
20432
+ g.nodes().forEach((v) => getExtremes(g.node(v)));
20433
+ g.edges().forEach((e) => {
20434
+ let edge2 = g.edge(e);
20435
+ if (Object.hasOwn(edge2, "x")) {
20436
+ getExtremes(edge2);
20437
+ }
20438
+ });
20439
+ minX -= marginX;
20440
+ minY -= marginY;
20441
+ g.nodes().forEach((v) => {
20442
+ let node2 = g.node(v);
20443
+ node2.x -= minX;
20444
+ node2.y -= minY;
20445
+ });
20446
+ g.edges().forEach((e) => {
20447
+ let edge2 = g.edge(e);
20448
+ edge2.points.forEach((p) => {
20449
+ p.x -= minX;
20450
+ p.y -= minY;
20451
+ });
20452
+ if (Object.hasOwn(edge2, "x")) {
20453
+ edge2.x -= minX;
20454
+ }
20455
+ if (Object.hasOwn(edge2, "y")) {
20456
+ edge2.y -= minY;
20457
+ }
20458
+ });
20459
+ graphLabel.width = maxX - minX + marginX;
20460
+ graphLabel.height = maxY - minY + marginY;
20461
+ }
20462
+ function assignNodeIntersects(g) {
20463
+ g.edges().forEach((e) => {
20464
+ let edge2 = g.edge(e);
20465
+ let nodeV = g.node(e.v);
20466
+ let nodeW = g.node(e.w);
20467
+ let p1, p2;
20468
+ if (!edge2.points) {
20469
+ edge2.points = [];
20470
+ p1 = nodeW;
20471
+ p2 = nodeV;
20472
+ } else {
20473
+ p1 = edge2.points[0];
20474
+ p2 = edge2.points[edge2.points.length - 1];
20475
+ }
20476
+ edge2.points.unshift(util2.intersectRect(nodeV, p1));
20477
+ edge2.points.push(util2.intersectRect(nodeW, p2));
20478
+ });
20479
+ }
20480
+ function fixupEdgeLabelCoords(g) {
20481
+ g.edges().forEach((e) => {
20482
+ let edge2 = g.edge(e);
20483
+ if (Object.hasOwn(edge2, "x")) {
20484
+ if (edge2.labelpos === "l" || edge2.labelpos === "r") {
20485
+ edge2.width -= edge2.labeloffset;
20486
+ }
20487
+ switch (edge2.labelpos) {
20488
+ case "l":
20489
+ edge2.x -= edge2.width / 2 + edge2.labeloffset;
20490
+ break;
20491
+ case "r":
20492
+ edge2.x += edge2.width / 2 + edge2.labeloffset;
20493
+ break;
20494
+ }
20495
+ }
20496
+ });
20497
+ }
20498
+ function reversePointsForReversedEdges(g) {
20499
+ g.edges().forEach((e) => {
20500
+ let edge2 = g.edge(e);
20501
+ if (edge2.reversed) {
20502
+ edge2.points.reverse();
20503
+ }
20504
+ });
20505
+ }
20506
+ function removeBorderNodes(g) {
20507
+ g.nodes().forEach((v) => {
20508
+ if (g.children(v).length) {
20509
+ let node2 = g.node(v);
20510
+ let t = g.node(node2.borderTop);
20511
+ let b = g.node(node2.borderBottom);
20512
+ let l = g.node(node2.borderLeft[node2.borderLeft.length - 1]);
20513
+ let r = g.node(node2.borderRight[node2.borderRight.length - 1]);
20514
+ node2.width = Math.abs(r.x - l.x);
20515
+ node2.height = Math.abs(b.y - t.y);
20516
+ node2.x = l.x + node2.width / 2;
20517
+ node2.y = t.y + node2.height / 2;
20518
+ }
20519
+ });
20520
+ g.nodes().forEach((v) => {
20521
+ if (g.node(v).dummy === "border") {
20522
+ g.removeNode(v);
20523
+ }
20524
+ });
20525
+ }
20526
+ function removeSelfEdges(g) {
20527
+ g.edges().forEach((e) => {
20528
+ if (e.v === e.w) {
20529
+ var node2 = g.node(e.v);
20530
+ if (!node2.selfEdges) {
20531
+ node2.selfEdges = [];
20532
+ }
20533
+ node2.selfEdges.push({ e, label: g.edge(e) });
20534
+ g.removeEdge(e);
20535
+ }
20536
+ });
20537
+ }
20538
+ function insertSelfEdges(g) {
20539
+ var layers = util2.buildLayerMatrix(g);
20540
+ layers.forEach((layer) => {
20541
+ var orderShift = 0;
20542
+ layer.forEach((v, i) => {
20543
+ var node2 = g.node(v);
20544
+ node2.order = i + orderShift;
20545
+ (node2.selfEdges || []).forEach((selfEdge) => {
20546
+ util2.addDummyNode(g, "selfedge", {
20547
+ width: selfEdge.label.width,
20548
+ height: selfEdge.label.height,
20549
+ rank: node2.rank,
20550
+ order: i + ++orderShift,
20551
+ e: selfEdge.e,
20552
+ label: selfEdge.label
20553
+ }, "_se");
20554
+ });
20555
+ delete node2.selfEdges;
20556
+ });
20557
+ });
20558
+ }
20559
+ function positionSelfEdges(g) {
20560
+ g.nodes().forEach((v) => {
20561
+ var node2 = g.node(v);
20562
+ if (node2.dummy === "selfedge") {
20563
+ var selfNode = g.node(node2.e.v);
20564
+ var x = selfNode.x + selfNode.width / 2;
20565
+ var y = selfNode.y;
20566
+ var dx = node2.x - x;
20567
+ var dy = selfNode.height / 2;
20568
+ g.setEdge(node2.e, node2.label);
20569
+ g.removeNode(v);
20570
+ node2.label.points = [
20571
+ { x: x + 2 * dx / 3, y: y - dy },
20572
+ { x: x + 5 * dx / 6, y: y - dy },
20573
+ { x: x + dx, y },
20574
+ { x: x + 5 * dx / 6, y: y + dy },
20575
+ { x: x + 2 * dx / 3, y: y + dy }
20576
+ ];
20577
+ node2.label.x = node2.x;
20578
+ node2.label.y = node2.y;
20579
+ }
20580
+ });
20581
+ }
20582
+ function selectNumberAttrs(obj, attrs) {
20583
+ return util2.mapValues(util2.pick(obj, attrs), Number);
20584
+ }
20585
+ function canonicalize(attrs) {
20586
+ var newAttrs = {};
20587
+ if (attrs) {
20588
+ Object.entries(attrs).forEach(([k, v]) => {
20589
+ if (typeof k === "string") {
20590
+ k = k.toLowerCase();
20591
+ }
20592
+ newAttrs[k] = v;
20593
+ });
20594
+ }
20595
+ return newAttrs;
20596
+ }
20597
+ return layout_1;
20598
+ }
20599
+ var debug;
20600
+ var hasRequiredDebug;
20601
+ function requireDebug() {
20602
+ if (hasRequiredDebug) return debug;
20603
+ hasRequiredDebug = 1;
20604
+ let util2 = requireUtil$1();
20605
+ let Graph = requireGraphlib().Graph;
20606
+ debug = {
20607
+ debugOrdering
20608
+ };
20609
+ function debugOrdering(g) {
20610
+ let layerMatrix = util2.buildLayerMatrix(g);
20611
+ let h2 = new Graph({ compound: true, multigraph: true }).setGraph({});
20612
+ g.nodes().forEach((v) => {
20613
+ h2.setNode(v, { label: v });
20614
+ h2.setParent(v, "layer" + g.node(v).rank);
20615
+ });
20616
+ g.edges().forEach((e) => h2.setEdge(e.v, e.w, {}, e.name));
20617
+ layerMatrix.forEach((layer, i) => {
20618
+ let layerV = "layer" + i;
20619
+ h2.setNode(layerV, { rank: "same" });
20620
+ layer.reduce((u, v) => {
20621
+ h2.setEdge(u, v, { style: "invis" });
20622
+ return v;
20623
+ });
20624
+ });
20625
+ return h2;
20626
+ }
20627
+ return debug;
20628
+ }
20629
+ var version;
20630
+ var hasRequiredVersion;
20631
+ function requireVersion() {
20632
+ if (hasRequiredVersion) return version;
20633
+ hasRequiredVersion = 1;
20634
+ version = "1.1.4";
20635
+ return version;
20636
+ }
20637
+ var dagre$1;
20638
+ var hasRequiredDagre;
20639
+ function requireDagre() {
20640
+ if (hasRequiredDagre) return dagre$1;
20641
+ hasRequiredDagre = 1;
20642
+ dagre$1 = {
20643
+ graphlib: requireGraphlib(),
20644
+ layout: requireLayout(),
20645
+ debug: requireDebug(),
20646
+ util: {
20647
+ time: requireUtil$1().time,
20648
+ notime: requireUtil$1().notime
20649
+ },
20650
+ version: requireVersion()
20651
+ };
20652
+ return dagre$1;
20653
+ }
20654
+ var dagreExports = requireDagre();
20655
+ const dagre = /* @__PURE__ */ getDefaultExportFromCjs(dagreExports);
20656
+ const NODE_X_SPACING = GRID_SIZE * 6;
20657
+ const NODE_Y_SPACING = GRID_SIZE * 5;
20658
+ const SUBGRAPH_SPACING = GRID_SIZE * 8;
20659
+ const AI_X_SPACING = GRID_SIZE * 2;
20660
+ const AI_Y_SPACING = GRID_SIZE * 6;
20661
+ const STICKY_BOTTOM_PADDING = GRID_SIZE * 3;
20662
+ function useCanvasLayout({ id: canvasId } = {}) {
20663
+ const {
20664
+ findNode,
20665
+ findEdge,
20666
+ getSelectedNodes,
20667
+ edges: allEdges,
20668
+ nodes: allNodes
20669
+ } = useVueFlow({ id: canvasId });
20670
+ function getTargetData(target2) {
20671
+ if (target2 === "selection") {
20672
+ return { nodes: getSelectedNodes.value, edges: allEdges.value };
20673
+ }
20674
+ return { nodes: allNodes.value, edges: allEdges.value };
20675
+ }
20676
+ function sortByPosition(posA, posB) {
20677
+ const yDiff = posA.y - posB.y;
20678
+ return yDiff === 0 ? posA.x - posB.x : yDiff;
20679
+ }
20680
+ function sortNodesByPosition(nodeA, nodeB) {
20681
+ const hasEdgesA = allEdges.value.some((edge2) => edge2.target === nodeA.id);
20682
+ const hasEdgesB = allEdges.value.some((edge2) => edge2.target === nodeB.id);
20683
+ if (!hasEdgesA && hasEdgesB) return -1;
20684
+ if (hasEdgesA && !hasEdgesB) return 1;
20685
+ return sortByPosition(nodeA.position, nodeB.position);
20686
+ }
20687
+ function sortEdgesByPosition(edgeA, edgeB) {
20688
+ return sortByPosition(positionFromEdge(edgeA), positionFromEdge(edgeB));
20689
+ }
20690
+ function positionFromEdge(edge2) {
20691
+ return { x: edge2.targetX, y: edge2.targetY };
20692
+ }
20693
+ function createDagreGraph({ nodes, edges }) {
20694
+ const graph2 = new dagre.graphlib.Graph();
20695
+ graph2.setDefaultEdgeLabel(() => ({}));
20696
+ const graphNodes = nodes.map((node2) => findNode(node2.id)).filter(isPresent).sort(sortNodesByPosition);
20697
+ const nodeIdSet = new Set(nodes.map((node2) => node2.id));
20698
+ graphNodes.forEach(({ id: nodeId, position: { x, y }, dimensions: { width, height } }) => {
20699
+ graph2.setNode(nodeId, { width, height, x, y });
20700
+ });
20701
+ edges.map((node2) => findEdge(node2.id)).filter(isPresent).filter((edge2) => nodeIdSet.has(edge2.source) && nodeIdSet.has(edge2.target)).sort(sortEdgesByPosition).forEach((edge2) => graph2.setEdge(edge2.source, edge2.target));
20702
+ return graph2;
20703
+ }
20704
+ function createDagreSubGraph({
20705
+ nodeIds,
20706
+ parent
20707
+ }) {
20708
+ const subGraph = new dagre.graphlib.Graph();
20709
+ subGraph.setGraph({
20710
+ rankdir: "LR",
20711
+ edgesep: NODE_Y_SPACING,
20712
+ nodesep: NODE_Y_SPACING,
20713
+ ranksep: NODE_X_SPACING
20714
+ });
20715
+ subGraph.setDefaultEdgeLabel(() => ({}));
20716
+ const nodeIdSet = new Set(nodeIds);
20717
+ parent.nodes().filter((nodeId) => nodeIdSet.has(nodeId)).forEach((nodeId) => {
20718
+ subGraph.setNode(nodeId, parent.node(nodeId));
20719
+ });
20720
+ parent.edges().filter((edge2) => nodeIdSet.has(edge2.v) && nodeIdSet.has(edge2.w)).forEach((edge2) => subGraph.setEdge(edge2.v, edge2.w, parent.edge(edge2)));
20721
+ return subGraph;
20722
+ }
20723
+ function createDagreVerticalGraph({ nodes }) {
20724
+ const subGraph = new dagre.graphlib.Graph();
20725
+ subGraph.setGraph({
20726
+ rankdir: "TB",
20727
+ align: "UL",
20728
+ edgesep: SUBGRAPH_SPACING,
20729
+ nodesep: SUBGRAPH_SPACING,
20730
+ ranksep: SUBGRAPH_SPACING
20731
+ });
20732
+ subGraph.setDefaultEdgeLabel(() => ({}));
20733
+ nodes.forEach(
20734
+ ({ id: id2, box: { x, y, width, height } }) => subGraph.setNode(id2, { x, y, width, height })
20735
+ );
20736
+ nodes.forEach((node2, index) => {
20737
+ if (!nodes[index + 1]) return;
20738
+ subGraph.setEdge(node2.id, nodes[index + 1].id);
20739
+ });
20740
+ return subGraph;
20741
+ }
20742
+ function createAiSubGraph({
20743
+ parent,
20744
+ nodeIds
20745
+ }) {
20746
+ const subGraph = new dagre.graphlib.Graph();
20747
+ subGraph.setGraph({
20748
+ rankdir: "TB",
20749
+ edgesep: AI_X_SPACING,
20750
+ nodesep: AI_X_SPACING,
20751
+ ranksep: AI_Y_SPACING
20752
+ });
20753
+ subGraph.setDefaultEdgeLabel(() => ({}));
20754
+ const nodeIdSet = new Set(nodeIds);
20755
+ parent.nodes().filter((nodeId) => nodeIdSet.has(nodeId)).forEach((nodeId) => {
20756
+ subGraph.setNode(nodeId, parent.node(nodeId));
20757
+ });
20758
+ parent.edges().filter((edge2) => nodeIdSet.has(edge2.v) && nodeIdSet.has(edge2.w)).forEach((edge2) => subGraph.setEdge(edge2.w, edge2.v));
20759
+ return subGraph;
20760
+ }
20761
+ function compositeBoundingBox(boxes) {
20762
+ const { minX, minY, maxX, maxY } = boxes.reduce(
20763
+ (bbox, node2) => {
20764
+ const { x, y, width, height } = node2;
20765
+ return {
20766
+ minX: Math.min(bbox.minX, x),
20767
+ maxX: Math.max(bbox.maxX, x + width),
20768
+ minY: Math.min(bbox.minY, y),
20769
+ maxY: Math.max(bbox.maxY, y + height)
20770
+ };
20771
+ },
20772
+ { minX: Infinity, minY: Infinity, maxX: -Infinity, maxY: -Infinity }
20773
+ );
20774
+ return {
20775
+ x: minX,
20776
+ y: minY,
20777
+ width: maxX - minX,
20778
+ height: maxY - minY
20779
+ };
20780
+ }
20781
+ function boundingBoxFromCanvasNode(node2) {
20782
+ return {
20783
+ x: node2.position.x,
20784
+ y: node2.position.y,
20785
+ width: node2.dimensions.width,
20786
+ height: node2.dimensions.height
20787
+ };
20788
+ }
20789
+ function boundingBoxFromDagreNode(node2) {
20790
+ return {
20791
+ x: node2.x - node2.width / 2,
20792
+ y: node2.y - node2.height / 2,
20793
+ width: node2.width,
20794
+ height: node2.height
20795
+ };
20796
+ }
20797
+ function boundingBoxFromGraph(graph2) {
20798
+ return compositeBoundingBox(
20799
+ graph2.nodes().map((nodeId) => boundingBoxFromDagreNode(graph2.node(nodeId)))
20800
+ );
20801
+ }
20802
+ function boundingBoxFromCanvasNodes(nodes) {
20803
+ return compositeBoundingBox(nodes.map(boundingBoxFromCanvasNode));
20804
+ }
20805
+ function isCoveredBy(parent, child) {
20806
+ const childRight = child.x + child.width;
20807
+ const childBottom = child.y + child.height;
20808
+ const parentRight = parent.x + parent.width;
20809
+ const parentBottom = parent.y + parent.height;
20810
+ return child.x >= parent.x && child.y >= parent.y && childRight <= parentRight && childBottom <= parentBottom;
20811
+ }
20812
+ function centerHorizontally(container2, target2) {
20813
+ const containerCenter = container2.x + container2.width / 2;
20814
+ const newX = containerCenter - target2.width / 2;
20815
+ return newX;
20816
+ }
20817
+ function intersects(container2, target2, padding = 0) {
20818
+ const targetWithPadding = {
20819
+ x: target2.x - padding,
20820
+ y: target2.y - padding,
20821
+ width: target2.width + padding * 2,
20822
+ height: target2.height + padding * 2
20823
+ };
20824
+ const noIntersection = targetWithPadding.x + targetWithPadding.width < container2.x || targetWithPadding.x > container2.x + container2.width || targetWithPadding.y + targetWithPadding.height < container2.y || targetWithPadding.y > container2.y + container2.height;
20825
+ return !noIntersection;
20826
+ }
20827
+ function isAiParentNode(node2) {
20828
+ return node2.render.type === CanvasNodeRenderType.Default && node2.render.options.configurable && !node2.render.options.configuration;
20829
+ }
20830
+ function isAiConfigNode(node2) {
20831
+ return node2.render.type === CanvasNodeRenderType.Default && node2.render.options.configuration;
20832
+ }
20833
+ function getAllConnectedAiConfigNodes({
20834
+ graph: graph2,
20835
+ root: root2,
20836
+ nodeById
20837
+ }) {
20838
+ return graph2.predecessors(root2.id).map((successor) => nodeById[successor]).filter((node2) => isAiConfigNode(node2.data)).flatMap((node2) => [
20839
+ node2.id,
20840
+ ...getAllConnectedAiConfigNodes({ graph: graph2, root: node2.data, nodeById })
20841
+ ]);
20842
+ }
20843
+ function layout(target2) {
20844
+ const { nodes, edges } = getTargetData(target2);
20845
+ const nonStickyNodes = nodes.filter((node2) => node2.data.type !== STICKY_NODE_TYPE).map((node2) => findNode(node2.id)).filter(isPresent);
20846
+ const boundingBoxBefore = boundingBoxFromCanvasNodes(nonStickyNodes);
20847
+ const parentGraph = createDagreGraph({ nodes: nonStickyNodes, edges });
20848
+ const nodeById = nonStickyNodes.reduce((acc, node2) => {
20849
+ acc[node2.id] = node2;
20850
+ return acc;
20851
+ }, {});
20852
+ const subgraphs = dagre.graphlib.alg.components(parentGraph).map((nodeIds) => {
20853
+ const subgraph = createDagreSubGraph({ nodeIds, parent: parentGraph });
20854
+ const aiParentNodes = subgraph.nodes().map((nodeId) => nodeById[nodeId].data).filter(isAiParentNode);
20855
+ const aiGraphs = aiParentNodes.map((aiParentNode) => {
20856
+ const configNodeIds = getAllConnectedAiConfigNodes({
20857
+ graph: subgraph,
20858
+ nodeById,
20859
+ root: aiParentNode
20860
+ });
20861
+ const allAiNodeIds = configNodeIds.concat(aiParentNode.id);
20862
+ const aiGraph = createAiSubGraph({
20863
+ parent: subgraph,
20864
+ nodeIds: allAiNodeIds
20865
+ });
20866
+ configNodeIds.forEach((nodeId) => subgraph.removeNode(nodeId));
20867
+ const rootEdges = subgraph.edges().filter((edge2) => edge2.v === aiParentNode.id || edge2.w === aiParentNode.id);
20868
+ dagre.layout(aiGraph, { disableOptimalOrderHeuristic: true });
20869
+ const aiBoundingBox = boundingBoxFromGraph(aiGraph);
20870
+ subgraph.setNode(aiParentNode.id, {
20871
+ width: aiBoundingBox.width,
20872
+ height: aiBoundingBox.height
20873
+ });
20874
+ rootEdges.forEach((edge2) => subgraph.setEdge(edge2));
20875
+ return { graph: aiGraph, boundingBox: aiBoundingBox, aiParentNode };
20876
+ });
20877
+ dagre.layout(subgraph, { disableOptimalOrderHeuristic: true });
20878
+ return { graph: subgraph, aiGraphs, boundingBox: boundingBoxFromGraph(subgraph) };
20879
+ });
20880
+ const compositeGraph = createDagreVerticalGraph({
20881
+ nodes: subgraphs.map(({ boundingBox }, index) => ({
20882
+ box: boundingBox,
20883
+ id: index.toString()
20884
+ }))
20885
+ });
20886
+ dagre.layout(compositeGraph, { disableOptimalOrderHeuristic: true });
20887
+ const boundingBoxByNodeId = subgraphs.flatMap(({ graph: graph2, aiGraphs }, index) => {
20888
+ const subgraphPosition = compositeGraph.node(index.toString());
20889
+ const aiParentNodes = new Set(aiGraphs.map(({ aiParentNode }) => aiParentNode.id));
20890
+ const offset = {
20891
+ x: 0,
20892
+ y: subgraphPosition.y - subgraphPosition.height / 2
20893
+ };
20894
+ return graph2.nodes().flatMap((nodeId) => {
20895
+ const { x, y, width, height } = graph2.node(nodeId);
20896
+ const positionedNode = {
20897
+ id: nodeId,
20898
+ boundingBox: {
20899
+ x: x + offset.x - width / 2,
20900
+ y: y + offset.y - height / 2,
20901
+ width,
20902
+ height
20903
+ }
20904
+ };
20905
+ if (aiParentNodes.has(nodeId)) {
20906
+ const aiGraph = aiGraphs.find(({ aiParentNode }) => aiParentNode.id === nodeId);
20907
+ if (!aiGraph) return [];
20908
+ const aiParentNodeBox = positionedNode.boundingBox;
20909
+ const parentOffset = {
20910
+ x: aiParentNodeBox.x,
20911
+ y: aiParentNodeBox.y
20912
+ };
20913
+ return aiGraph.graph.nodes().map((aiNodeId) => {
20914
+ const aiNode = aiGraph.graph.node(aiNodeId);
20915
+ const aiBoundingBox = {
20916
+ x: aiNode.x + parentOffset.x - aiNode.width / 2,
20917
+ y: aiNode.y + parentOffset.y - aiNode.height / 2,
20918
+ width: aiNode.width,
20919
+ height: aiNode.height
20920
+ };
20921
+ return {
20922
+ id: aiNodeId,
20923
+ boundingBox: aiBoundingBox
20924
+ };
20925
+ });
20926
+ }
20927
+ return positionedNode;
20928
+ });
20929
+ }).reduce(
20930
+ (acc, node2) => {
20931
+ acc[node2.id] = node2.boundingBox;
20932
+ return acc;
20933
+ },
20934
+ {}
20935
+ );
20936
+ subgraphs.flatMap(({ aiGraphs }) => aiGraphs).forEach(({ graph: graph2 }) => {
20937
+ const aiNodes = graph2.nodes();
20938
+ const aiGraphBoundingBox = compositeBoundingBox(
20939
+ aiNodes.map((nodeId) => boundingBoxByNodeId[nodeId]).filter(isPresent)
20940
+ );
20941
+ const aiNodeVerticalCorrection = aiGraphBoundingBox.height / 2 - NODE_SIZE / 2;
20942
+ aiGraphBoundingBox.y += aiNodeVerticalCorrection;
20943
+ const hasConflictingNodes = Object.entries(boundingBoxByNodeId).filter(([id2]) => !graph2.hasNode(id2)).some(
20944
+ ([, nodeBoundingBox]) => intersects(aiGraphBoundingBox, nodeBoundingBox, NODE_Y_SPACING)
20945
+ );
20946
+ if (!hasConflictingNodes) {
20947
+ for (const aiNode of aiNodes) {
20948
+ boundingBoxByNodeId[aiNode].y += aiNodeVerticalCorrection;
20949
+ }
20950
+ }
20951
+ });
20952
+ const positionedNodes = Object.entries(boundingBoxByNodeId).map(([id2, boundingBox]) => ({
20953
+ id: id2,
20954
+ boundingBox
20955
+ }));
20956
+ const boundingBoxAfter = compositeBoundingBox(positionedNodes.map((node2) => node2.boundingBox));
20957
+ const anchor = {
20958
+ x: boundingBoxAfter.x - boundingBoxBefore.x,
20959
+ y: boundingBoxAfter.y - boundingBoxBefore.y
20960
+ };
20961
+ const stickies = nodes.filter((node2) => node2.data.type === STICKY_NODE_TYPE).map((node2) => findNode(node2.id)).filter(isPresent);
20962
+ const positionedStickies = stickies.map((sticky2) => {
20963
+ const stickyBox = boundingBoxFromCanvasNode(sticky2);
20964
+ const coveredNodes = nonStickyNodes.filter(
20965
+ (node2) => isCoveredBy(boundingBoxFromCanvasNode(sticky2), boundingBoxFromCanvasNode(node2))
20966
+ );
20967
+ if (coveredNodes.length === 0) return null;
20968
+ const coveredNodesBoxAfter = compositeBoundingBox(
20969
+ positionedNodes.filter((node2) => coveredNodes.some((covered) => covered.id === node2.id)).map(({ boundingBox }) => boundingBox)
20970
+ );
20971
+ return {
20972
+ id: sticky2.id,
20973
+ boundingBox: {
20974
+ x: centerHorizontally(coveredNodesBoxAfter, stickyBox),
20975
+ y: coveredNodesBoxAfter.y + coveredNodesBoxAfter.height - stickyBox.height + STICKY_BOTTOM_PADDING,
20976
+ height: stickyBox.height,
20977
+ width: stickyBox.width
20978
+ }
20979
+ };
20980
+ }).filter(isPresent);
20981
+ return {
20982
+ boundingBox: boundingBoxAfter,
20983
+ nodes: positionedNodes.concat(positionedStickies).map(({ id: id2, boundingBox }) => {
20984
+ return {
20985
+ id: id2,
20986
+ x: boundingBox.x - anchor.x,
20987
+ y: boundingBox.y - anchor.y
20988
+ };
20989
+ })
20990
+ };
20991
+ }
20992
+ return { layout };
20993
+ }
20994
+ const renameKeyCode = " ";
20995
+ const defaultZoom = 1;
20996
+ const minimapVisibilityDelay = 1e3;
20997
+ const _sfc_main = /* @__PURE__ */ defineComponent({
20998
+ __name: "Canvas",
20999
+ props: {
21000
+ id: { default: "canvas" },
21001
+ nodes: { default: () => [] },
21002
+ connections: { default: () => [] },
21003
+ controlsPosition: { default: PanelPosition.BottomLeft },
21004
+ eventBus: { default: () => createEventBus() },
21005
+ readOnly: { type: Boolean, default: false },
21006
+ executing: { type: Boolean, default: false },
21007
+ keyBindings: { type: Boolean, default: true },
21008
+ loading: { type: Boolean, default: false }
21009
+ },
21010
+ emits: ["update:modelValue", "update:node:position", "update:nodes:position", "update:node:activated", "update:node:deactivated", "update:node:enabled", "update:node:selected", "update:node:name", "update:node:parameters", "update:node:inputs", "update:node:outputs", "click:node", "click:node:add", "run:node", "delete:node", "create:node", "create:sticky", "delete:nodes", "update:nodes:enabled", "copy:nodes", "duplicate:nodes", "update:nodes:pin", "cut:nodes", "delete:connection", "create:connection:start", "create:connection", "create:connection:end", "create:connection:cancelled", "click:connection:add", "click:pane", "run:workflow", "save:workflow", "create:workflow", "drag-and-drop"],
21011
+ setup(__props, { emit: __emit }) {
21012
+ const $style = useCssModule();
21013
+ const emit = __emit;
21014
+ const props = __props;
21015
+ const { isMobileDevice, controlKeyCode } = useDeviceSupport();
21016
+ const vueFlow = useVueFlow({ id: props.id, deleteKeyCode: null });
21017
+ const {
21018
+ getSelectedNodes: selectedNodes,
21019
+ addSelectedNodes,
21020
+ removeSelectedNodes,
21021
+ viewportRef,
21022
+ fitView,
21023
+ zoomIn,
21024
+ zoomOut,
21025
+ zoomTo,
21026
+ setInteractive,
21027
+ elementsSelectable,
21028
+ project,
21029
+ nodes: graphNodes,
21030
+ onPaneReady,
21031
+ onNodesInitialized,
21032
+ findNode,
21033
+ viewport,
21034
+ onEdgeMouseLeave,
21035
+ onEdgeMouseEnter,
21036
+ onEdgeMouseMove,
21037
+ onNodeMouseEnter,
21038
+ onNodeMouseLeave
21039
+ } = vueFlow;
21040
+ const {
21041
+ getIncomingNodes,
21042
+ getOutgoingNodes,
21043
+ getSiblingNodes,
21044
+ getDownstreamNodes,
21045
+ getUpstreamNodes
21046
+ } = useCanvasTraversal(vueFlow);
21047
+ const { layout } = useCanvasLayout({ id: props.id });
21048
+ const isPaneReady = ref(false);
21049
+ const classes = computed(() => ({
21050
+ [$style.canvas]: true,
21051
+ [$style.ready]: !props.loading && isPaneReady.value
21052
+ }));
21053
+ const panningKeyCode = ref(isMobileDevice ? true : [" ", controlKeyCode]);
21054
+ const panningMouseButton = ref(isMobileDevice ? true : [1]);
21055
+ const selectionKeyCode = ref(isMobileDevice ? "Shift" : true);
21056
+ function switchToPanningMode() {
21057
+ selectionKeyCode.value = null;
21058
+ panningMouseButton.value = [0, 1];
21059
+ }
21060
+ function switchToSelectionMode() {
21061
+ selectionKeyCode.value = true;
21062
+ panningMouseButton.value = [1];
21063
+ }
21064
+ onKeyDown(panningKeyCode.value, switchToPanningMode, {
21065
+ dedupe: true
21066
+ });
21067
+ onKeyUp(panningKeyCode.value, switchToSelectionMode);
21068
+ useShortKeyPress(
21069
+ renameKeyCode,
21070
+ () => {
21071
+ if (lastSelectedNode.value) {
21072
+ emit("update:node:name", lastSelectedNode.value.id);
21073
+ }
21074
+ },
21075
+ {
21076
+ disabled: toRef(props, "readOnly")
21077
+ }
21078
+ );
21079
+ const disableKeyBindings = computed(() => !props.keyBindings);
21080
+ function selectLeftNode(id2) {
21081
+ const incomingNodes = getIncomingNodes(id2);
21082
+ const previousNode = incomingNodes[0];
21083
+ if (previousNode) {
21084
+ onSelectNodes({ ids: [previousNode.id] });
21085
+ }
21086
+ }
21087
+ function selectRightNode(id2) {
21088
+ const outgoingNodes = getOutgoingNodes(id2);
21089
+ const nextNode = outgoingNodes[0];
21090
+ if (nextNode) {
21091
+ onSelectNodes({ ids: [nextNode.id] });
21092
+ }
21093
+ }
21094
+ function selectLowerSiblingNode(id2) {
21095
+ const siblingNodes = getSiblingNodes(id2);
21096
+ const index = siblingNodes.findIndex((n) => n.id === id2);
21097
+ const nextNode = siblingNodes[index + 1] ?? siblingNodes[0];
21098
+ if (nextNode) {
21099
+ onSelectNodes({
21100
+ ids: [nextNode.id]
21101
+ });
21102
+ }
21103
+ }
21104
+ function selectUpperSiblingNode(id2) {
21105
+ const siblingNodes = getSiblingNodes(id2);
21106
+ const index = siblingNodes.findIndex((n) => n.id === id2);
21107
+ const previousNode = siblingNodes[index - 1] ?? siblingNodes[siblingNodes.length - 1];
21108
+ if (previousNode) {
21109
+ onSelectNodes({
21110
+ ids: [previousNode.id]
21111
+ });
21112
+ }
21113
+ }
21114
+ function selectDownstreamNodes(id2) {
21115
+ const downstreamNodes = getDownstreamNodes(id2);
21116
+ onSelectNodes({ ids: [...downstreamNodes.map((node2) => node2.id), id2] });
21117
+ }
21118
+ function selectUpstreamNodes(id2) {
21119
+ const upstreamNodes = getUpstreamNodes(id2);
21120
+ onSelectNodes({ ids: [...upstreamNodes.map((node2) => node2.id), id2] });
21121
+ }
21122
+ const keyMap = computed(() => {
21123
+ const readOnlyKeymap = {
21124
+ ctrl_c: emitWithSelectedNodes((ids) => emit("copy:nodes", ids)),
21125
+ enter: emitWithLastSelectedNode((id2) => onSetNodeActivated(id2)),
21126
+ ctrl_a: () => addSelectedNodes(graphNodes.value),
21127
+ // Support both key and code for zooming in and out
21128
+ "shift_+|+|=|shift_Equal|Equal": async () => await onZoomIn(),
21129
+ "shift+_|-|_|shift_Minus|Minus": async () => await onZoomOut(),
21130
+ 0: async () => await onResetZoom(),
21131
+ 1: async () => await onFitView(),
21132
+ ArrowUp: emitWithLastSelectedNode(selectUpperSiblingNode),
21133
+ ArrowDown: emitWithLastSelectedNode(selectLowerSiblingNode),
21134
+ ArrowLeft: emitWithLastSelectedNode(selectLeftNode),
21135
+ ArrowRight: emitWithLastSelectedNode(selectRightNode),
21136
+ shift_ArrowLeft: emitWithLastSelectedNode(selectUpstreamNodes),
21137
+ shift_ArrowRight: emitWithLastSelectedNode(selectDownstreamNodes)
21138
+ };
21139
+ if (props.readOnly) return readOnlyKeymap;
21140
+ const fullKeymap = {
21141
+ ...readOnlyKeymap,
21142
+ ctrl_x: emitWithSelectedNodes((ids) => emit("cut:nodes", ids)),
21143
+ "delete|backspace": emitWithSelectedNodes((ids) => emit("delete:nodes", ids)),
21144
+ ctrl_d: emitWithSelectedNodes((ids) => emit("duplicate:nodes", ids)),
21145
+ d: emitWithSelectedNodes((ids) => emit("update:nodes:enabled", ids)),
21146
+ p: emitWithSelectedNodes((ids) => emit("update:nodes:pin", ids, "keyboard-shortcut")),
21147
+ f2: emitWithLastSelectedNode((id2) => emit("update:node:name", id2)),
21148
+ tab: () => emit("create:node", "tab"),
21149
+ shift_s: () => emit("create:sticky"),
21150
+ ctrl_alt_n: () => emit("create:workflow"),
21151
+ ctrl_enter: () => emit("run:workflow"),
21152
+ ctrl_s: () => emit("save:workflow"),
21153
+ shift_alt_t: onTidyUp
21154
+ };
21155
+ return fullKeymap;
21156
+ });
21157
+ useKeybindings(keyMap, { disabled: disableKeyBindings });
21158
+ const hasSelection = computed(() => selectedNodes.value.length > 0);
21159
+ const selectedNodeIds = computed(() => selectedNodes.value.map((node2) => node2.id));
21160
+ const lastSelectedNode = ref();
21161
+ const triggerNodes = computed(
21162
+ () => props.nodes.filter(
21163
+ (node2) => node2.data?.render.type === CanvasNodeRenderType.Default && node2.data.render.options.trigger
21164
+ )
21165
+ );
21166
+ const hoveredTriggerNode = useCanvasNodeHover(triggerNodes, vueFlow, (nodeRect) => ({
21167
+ x: nodeRect.x - nodeRect.width * 2,
21168
+ // should cover the width of trigger button
21169
+ y: nodeRect.y - nodeRect.height,
21170
+ width: nodeRect.width * 4,
21171
+ height: nodeRect.height * 3
21172
+ }));
21173
+ watch(selectedNodes, (nodes) => {
21174
+ if (!lastSelectedNode.value || !nodes.find((node2) => node2.id === lastSelectedNode.value?.id)) {
21175
+ lastSelectedNode.value = nodes[nodes.length - 1];
21176
+ }
21177
+ });
21178
+ function onClickNodeAdd(id2, handle2) {
21179
+ emit("click:node:add", id2, handle2);
21180
+ }
21181
+ function onUpdateNodesPosition(events) {
21182
+ emit("update:nodes:position", events);
21183
+ }
21184
+ function onUpdateNodePosition(id2, position2) {
21185
+ emit("update:node:position", id2, position2);
21186
+ }
21187
+ function onNodeDragStop(event) {
21188
+ onUpdateNodesPosition(event.nodes.map(({ id: id2, position: position2 }) => ({ id: id2, position: position2 })));
17234
21189
  }
17235
21190
  function onNodeClick({ event, node: node2 }) {
17236
21191
  emit("click:node", node2.id);
@@ -17242,9 +21197,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
17242
21197
  function onSelectionDragStop(event) {
17243
21198
  onUpdateNodesPosition(event.nodes.map(({ id: id2, position: position2 }) => ({ id: id2, position: position2 })));
17244
21199
  }
17245
- function onSetNodeActive(id2) {
17246
- props.eventBus.emit("nodes:action", { ids: [id2], action: "update:node:active" });
17247
- emit("update:node:active", id2);
21200
+ function onSetNodeActivated(id2) {
21201
+ props.eventBus.emit("nodes:action", { ids: [id2], action: "update:node:activated" });
21202
+ emit("update:node:activated", id2);
21203
+ }
21204
+ function onSetNodeDeactivated(id2) {
21205
+ emit("update:node:deactivated", id2);
17248
21206
  }
17249
21207
  function clearSelectedNodes() {
17250
21208
  removeSelectedNodes(selectedNodes.value);
@@ -17412,7 +21370,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
17412
21370
  }
17413
21371
  contextMenu2.open(event, { source, nodeId: id2 });
17414
21372
  }
17415
- function onContextMenuAction(action, nodeIds) {
21373
+ async function onContextMenuAction(action, nodeIds) {
17416
21374
  switch (action) {
17417
21375
  case "add_node":
17418
21376
  return emit("create:node", "context_menu");
@@ -17435,11 +21393,22 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
17435
21393
  case "toggle_activation":
17436
21394
  return emit("update:nodes:enabled", nodeIds);
17437
21395
  case "open":
17438
- return onSetNodeActive(nodeIds[0]);
21396
+ return onSetNodeActivated(nodeIds[0]);
17439
21397
  case "rename":
17440
21398
  return emit("update:node:name", nodeIds[0]);
17441
21399
  case "change_color":
17442
21400
  return props.eventBus.emit("nodes:action", { ids: nodeIds, action: "update:sticky:color" });
21401
+ case "tidy_up":
21402
+ return await onTidyUp();
21403
+ }
21404
+ }
21405
+ async function onTidyUp() {
21406
+ const applyOnSelection = selectedNodes.value.length > 1;
21407
+ const { nodes } = layout(applyOnSelection ? "selection" : "all");
21408
+ onUpdateNodesPosition(nodes.map((node2) => ({ id: node2.id, position: { x: node2.x, y: node2.y } })));
21409
+ if (!applyOnSelection) {
21410
+ await nextTick();
21411
+ await onFitView();
17443
21412
  }
17444
21413
  }
17445
21414
  function onDragOver(event) {
@@ -17512,7 +21481,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
17512
21481
  });
17513
21482
  return (_ctx, _cache) => {
17514
21483
  const _component_CanvasConnectionLine = __unplugin_components_0$6;
17515
- const _component_CanvasControlButtons = _sfc_main$v;
21484
+ const _component_CanvasControlButtons = __unplugin_components_1$1;
17516
21485
  return openBlock(), createBlock(unref(_sfc_main$1$4), {
17517
21486
  id: _ctx.id,
17518
21487
  nodes: _ctx.nodes,
@@ -17556,7 +21525,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
17556
21525
  onRun: onRunNode,
17557
21526
  onSelect: onSelectNode,
17558
21527
  onToggle: onToggleNodeEnabled,
17559
- onActivate: onSetNodeActive,
21528
+ onActivate: onSetNodeActivated,
21529
+ onDeactivate: onSetNodeDeactivated,
17560
21530
  "onOpen:contextmenu": onOpenNodeContextMenu,
17561
21531
  onUpdate: onUpdateNodeParameters,
17562
21532
  "onUpdate:inputs": onUpdateNodeInputs,
@@ -17622,7 +21592,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
17622
21592
  onZoomToFit: onFitView,
17623
21593
  onZoomIn,
17624
21594
  onZoomOut,
17625
- onResetZoom
21595
+ onResetZoom,
21596
+ onTidyUp
17626
21597
  }, null, 8, ["class", "position", "zoom"]),
17627
21598
  (openBlock(), createBlock(Suspense, null, {
17628
21599
  default: withCtx(() => [
@@ -17645,7 +21616,7 @@ const style0 = {
17645
21616
  const cssModules = {
17646
21617
  "$style": style0
17647
21618
  };
17648
- const __unplugin_components_0 = /* @__PURE__ */ _export_sfc$1(_sfc_main, [["__cssModules", cssModules], ["__scopeId", "data-v-24a2ded6"]]);
21619
+ const __unplugin_components_0 = /* @__PURE__ */ _export_sfc$1(_sfc_main, [["__cssModules", cssModules], ["__scopeId", "data-v-ef2140b6"]]);
17649
21620
  function useCanvasMapping({
17650
21621
  nodes,
17651
21622
  connections,
@@ -17655,6 +21626,7 @@ function useCanvasMapping({
17655
21626
  const workflowsStore = useWorkflowsStore();
17656
21627
  const nodeTypesStore = useNodeTypesStore();
17657
21628
  const nodeHelpers = useNodeHelpers();
21629
+ const { dirtinessByName } = useNodeDirtiness();
17658
21630
  function createStickyNoteRenderType(node2) {
17659
21631
  return {
17660
21632
  type: CanvasNodeRenderType.StickyNote,
@@ -17685,7 +21657,8 @@ function useCanvasMapping({
17685
21657
  outputs: {
17686
21658
  labelSize: nodeOutputLabelSizeById.value[node2.id]
17687
21659
  },
17688
- tooltip: nodeTooltipById.value[node2.id]
21660
+ tooltip: nodeTooltipById.value[node2.id],
21661
+ dirtiness: dirtinessByName.value[node2.name]
17689
21662
  }
17690
21663
  };
17691
21664
  }