@miragon/value-chain-renderer 0.0.0-stage → 0.1.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 (107) hide show
  1. package/README.md +66 -2
  2. package/dist/Modeler.d.ts +11 -0
  3. package/dist/Modeler.d.ts.map +1 -0
  4. package/dist/NavigatedViewer.d.ts +7 -0
  5. package/dist/NavigatedViewer.d.ts.map +1 -0
  6. package/dist/VcBaseViewer.d.ts +45 -0
  7. package/dist/VcBaseViewer.d.ts.map +1 -0
  8. package/dist/Viewer.d.ts +7 -0
  9. package/dist/Viewer.d.ts.map +1 -0
  10. package/dist/append/VcAppend.d.ts +25 -0
  11. package/dist/append/VcAppend.d.ts.map +1 -0
  12. package/dist/append/VcAutoPlaceBehavior.d.ts +24 -0
  13. package/dist/append/VcAutoPlaceBehavior.d.ts.map +1 -0
  14. package/dist/append/VcCreatePreviewBehavior.d.ts +9 -0
  15. package/dist/append/VcCreatePreviewBehavior.d.ts.map +1 -0
  16. package/dist/append/index.d.ts +4 -0
  17. package/dist/append/index.d.ts.map +1 -0
  18. package/dist/connect/VcConnect.d.ts +17 -0
  19. package/dist/connect/VcConnect.d.ts.map +1 -0
  20. package/dist/connect/index.d.ts +4 -0
  21. package/dist/connect/index.d.ts.map +1 -0
  22. package/dist/context-pad/VcContextPadProvider.d.ts +28 -0
  23. package/dist/context-pad/VcContextPadProvider.d.ts.map +1 -0
  24. package/dist/context-pad/index.d.ts +4 -0
  25. package/dist/context-pad/index.d.ts.map +1 -0
  26. package/dist/copy-paste/VcCopyPasteBehavior.d.ts +10 -0
  27. package/dist/copy-paste/VcCopyPasteBehavior.d.ts.map +1 -0
  28. package/dist/copy-paste/index.d.ts +4 -0
  29. package/dist/copy-paste/index.d.ts.map +1 -0
  30. package/dist/draw/VcRenderer.d.ts +17 -0
  31. package/dist/draw/VcRenderer.d.ts.map +1 -0
  32. package/dist/draw/geometry.d.ts +18 -0
  33. package/dist/draw/geometry.d.ts.map +1 -0
  34. package/dist/draw/icons.d.ts +24 -0
  35. package/dist/draw/icons.d.ts.map +1 -0
  36. package/dist/draw/index.d.ts +7 -0
  37. package/dist/draw/index.d.ts.map +1 -0
  38. package/dist/draw/styles.d.ts +21 -0
  39. package/dist/draw/styles.d.ts.map +1 -0
  40. package/dist/index.d.ts +23 -0
  41. package/dist/index.d.ts.map +1 -0
  42. package/dist/index.js +1432 -0
  43. package/dist/index.js.map +1 -0
  44. package/dist/io/VcExporter.d.ts +16 -0
  45. package/dist/io/VcExporter.d.ts.map +1 -0
  46. package/dist/io/VcImporter.d.ts +25 -0
  47. package/dist/io/VcImporter.d.ts.map +1 -0
  48. package/dist/io/index.d.ts +8 -0
  49. package/dist/io/index.d.ts.map +1 -0
  50. package/dist/io/saveSvg.d.ts +11 -0
  51. package/dist/io/saveSvg.d.ts.map +1 -0
  52. package/dist/io/types.d.ts +10 -0
  53. package/dist/io/types.d.ts.map +1 -0
  54. package/dist/keyboard/VcEditorActions.d.ts +8 -0
  55. package/dist/keyboard/VcEditorActions.d.ts.map +1 -0
  56. package/dist/keyboard/VcKeyboardBindings.d.ts +11 -0
  57. package/dist/keyboard/VcKeyboardBindings.d.ts.map +1 -0
  58. package/dist/keyboard/index.d.ts +6 -0
  59. package/dist/keyboard/index.d.ts.map +1 -0
  60. package/dist/label-editing/VcLabelEditingProvider.d.ts +38 -0
  61. package/dist/label-editing/VcLabelEditingProvider.d.ts.map +1 -0
  62. package/dist/label-editing/index.d.ts +4 -0
  63. package/dist/label-editing/index.d.ts.map +1 -0
  64. package/dist/model/VcDiagramElementFactory.d.ts +20 -0
  65. package/dist/model/VcDiagramElementFactory.d.ts.map +1 -0
  66. package/dist/model/VcElementFactory.d.ts +23 -0
  67. package/dist/model/VcElementFactory.d.ts.map +1 -0
  68. package/dist/model/di-types.d.ts +29 -0
  69. package/dist/model/di-types.d.ts.map +1 -0
  70. package/dist/model/index.d.ts +10 -0
  71. package/dist/model/index.d.ts.map +1 -0
  72. package/dist/modeling/VcConnectionTypeBehavior.d.ts +13 -0
  73. package/dist/modeling/VcConnectionTypeBehavior.d.ts.map +1 -0
  74. package/dist/modeling/VcHierarchyRelayoutBehavior.d.ts +18 -0
  75. package/dist/modeling/VcHierarchyRelayoutBehavior.d.ts.map +1 -0
  76. package/dist/modeling/VcLayouter.d.ts +66 -0
  77. package/dist/modeling/VcLayouter.d.ts.map +1 -0
  78. package/dist/modeling/VcModeling.d.ts +16 -0
  79. package/dist/modeling/VcModeling.d.ts.map +1 -0
  80. package/dist/modeling/cmd/UpdatePropertiesHandler.d.ts +15 -0
  81. package/dist/modeling/cmd/UpdatePropertiesHandler.d.ts.map +1 -0
  82. package/dist/modeling/index.d.ts +11 -0
  83. package/dist/modeling/index.d.ts.map +1 -0
  84. package/dist/ordering/VcOrderingProvider.d.ts +13 -0
  85. package/dist/ordering/VcOrderingProvider.d.ts.map +1 -0
  86. package/dist/ordering/index.d.ts +4 -0
  87. package/dist/ordering/index.d.ts.map +1 -0
  88. package/dist/palette/VcPaletteProvider.d.ts +32 -0
  89. package/dist/palette/VcPaletteProvider.d.ts.map +1 -0
  90. package/dist/palette/index.d.ts +4 -0
  91. package/dist/palette/index.d.ts.map +1 -0
  92. package/dist/popup/VcAlignMenuProvider.d.ts +21 -0
  93. package/dist/popup/VcAlignMenuProvider.d.ts.map +1 -0
  94. package/dist/popup/VcColorPickerProvider.d.ts +18 -0
  95. package/dist/popup/VcColorPickerProvider.d.ts.map +1 -0
  96. package/dist/popup/index.d.ts +6 -0
  97. package/dist/popup/index.d.ts.map +1 -0
  98. package/dist/resize/VcResizeBehavior.d.ts +7 -0
  99. package/dist/resize/VcResizeBehavior.d.ts.map +1 -0
  100. package/dist/resize/index.d.ts +4 -0
  101. package/dist/resize/index.d.ts.map +1 -0
  102. package/dist/rules/VcRules.d.ts +15 -0
  103. package/dist/rules/VcRules.d.ts.map +1 -0
  104. package/dist/rules/index.d.ts +4 -0
  105. package/dist/rules/index.d.ts.map +1 -0
  106. package/dist/value-chain.css +2 -0
  107. package/package.json +60 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["svgCreate","ICONS","Diagram","ElementFactory","BaseRenderer","TextUtil","SelectionModule","ZoomScrollModule","MoveCanvasModule","ModelingModule","MoveModule","OutlineModule","BendpointsModule","AutoScrollModule","GridSnappingModule","SnappingModule","KeyboardMoveSelectionModule","KeyboardMoveModule","CroppingConnectionDocking","BaseLayouter","CommandInterceptor","RulesModule","RuleProvider","ConnectModule","AutoPlaceModule","CreateModule","ConnectionPreviewModule","PaletteModule","HandToolModule","LassoToolModule","SpaceToolModule","GlobalConnectModule","ContextPadModule","PopupMenuModule","DirectEditingModule","AlignElementsModule","DistributeElementsModule","KeyboardModule","EditorActionsModule","KeyboardBindings","OrderingProvider","CopyPasteModule","ResizeModule","isObject","value","isVcShape","element","\"vcType\"","isStep","isOrgUnit","isVcConnection","isVcElement","EXPORT_PADDING","saveSVG","source","canvas","elements","elementRegistry","contents","getBBox","box","clone","viewport","VcBaseViewer","options","name","event","priority","callback","importer","warnings","document","target","container","sizeToCss","modules","VcElementFactory","elementFactory","connection","point","DEFAULT_STEP_SIZE","label","DEFAULT_ORG_UNIT_SIZE","VcDiagramElementFactory","withId","attrs","type","next","id","vcModelModule","notchDepth","height","width","chevronPath","chevronPathAt","labelInset","depth","d","my","y","x","ellipsePathAt","rx","ry","cx","COLORS","FONT","COLOR_OPTIONS","VC_RENDER_PRIORITY","ARROW_PATH","rendererInstances","VcRenderer","eventBus","shape","stroke","orgUnit","path","create","attr","append","visuals","inset","svg","line","createLine","first","rest","color","defs","marker","arrow","vcDrawModule","ROOT_ID","VcImporter","vcElementFactory","root","shapeById","connectionIndex","existing","VcExporter","connections","bounds","businessObject","link","rootMeta","validateDocument","CURRENT_SCHEMA_VERSION","ioModule","Viewer","NavigatedViewer","UpdatePropertiesHandler","context","old","key","properties","setOrDelete","oldProperties","UPDATE_PROPERTIES","VcModeling","commandStack","TRUNK_MARGIN","BUS_MIN_STUB","EXIT_MARGIN","VcLayouter","connectionDocking","hints","waypoints","isHierarchy","stub","result","allFinite","fallback","getMid","interior","sourceMid","targetMid","children","hierarchyChildren","group","isRowArrangement","withoutRedundantPoints","connectPoints","bottom","topmost","child","busY","minChildX","trunkX","connectRectangles","hierarchyDropSpan","tops","ROW_TOLERANCE_Y","centerX","span","points","VcConnectionTypeBehavior","modeling","VcHierarchyRelayoutBehavior","layouter","shapes","parents","hierarchyEdges","incoming","parent","edge","sameWaypoints","a","b","index","vcModelingModule","VcRules","vcConnect","hasConnection","endpointsAllowed","isRoot","pending","ignore","vcRulesModule","VcConnect","connect","vcConnectModule","VcAppend","autoPlace","factory","newShape","BEFORE_DEFAULT","SEQUENCE_GAP_X","HIERARCHY_GAP_Y","SIBLING_GAP_Y","SIBLING_GAP_X","DECONFLICT_STEP_Y","DECONFLICT_MARGIN","VcAutoPlaceBehavior","desired","anchor","rightmost","bottommost","steps","candidate","position","attempt","step","best","vcAppendModule","connectionPreview","injector","canConnect","icon","viewBox","content","ICONS","paletteEntryHtml","draggable","title","iconSvg","contextPadEntryHtml","VcPaletteProvider","handTool","lassoTool","spaceTool","globalConnect","palette","startCreateStep","startCreateOrgUnit","vcPaletteModule","COLOR_PICKER_PROVIDER_ID","swatch","VcColorPickerProvider","vcModeling","popupMenu","entries","option","ALIGN_MENU_PROVIDER_ID","alignIcon","ICONS$1","VcAlignMenuProvider","alignElements","distributeElements","align","VcContextPadProvider","vcAppend","contextPad","startConnect","mouse","other","\"delete\"","\"align\"","appendDrag","vcContextPadModule","VcLabelEditingProvider","directEditing","canExecute","bbox","zoom","sanitizeLabel","newText","text","vcLabelEditingModule","vcColorPickerModule","vcAlignMenuModule","VcKeyboardBindings","keyboard","editorActions","addListener","action","listener","bindTool","isKey","keys","hasModifier","HIGH_PRIORITY","VcEditorActions","register","service","serviceName","run","tool","selection","selected","vcKeyboardModule","VcOrderingProvider","newParent","vcOrderingModule","VcCopyPasteBehavior","\"vcLabel\"","\"color\"","\"link\"","vcCopyPasteModule","VcResizeBehavior","MIN_STEP_SIZE","minDimensions","vcResizeModule","Modeler"],"sources":["../src/model/di-types.ts","../src/io/saveSvg.ts","../src/VcBaseViewer.ts","../src/model/VcElementFactory.ts","../src/model/VcDiagramElementFactory.ts","../src/model/index.ts","../src/draw/geometry.ts","../src/draw/styles.ts","../src/draw/VcRenderer.ts","../src/draw/index.ts","../src/io/types.ts","../src/io/VcImporter.ts","../src/io/VcExporter.ts","../src/io/index.ts","../src/Viewer.ts","../src/NavigatedViewer.ts","../src/modeling/cmd/UpdatePropertiesHandler.ts","../src/modeling/VcModeling.ts","../src/modeling/VcLayouter.ts","../src/modeling/VcConnectionTypeBehavior.ts","../src/modeling/VcHierarchyRelayoutBehavior.ts","../src/modeling/index.ts","../src/rules/VcRules.ts","../src/rules/index.ts","../src/connect/VcConnect.ts","../src/connect/index.ts","../src/append/VcAppend.ts","../src/append/VcAutoPlaceBehavior.ts","../src/append/VcCreatePreviewBehavior.ts","../src/append/index.ts","../src/draw/icons.ts","../src/palette/VcPaletteProvider.ts","../src/palette/index.ts","../src/popup/VcColorPickerProvider.ts","../src/popup/VcAlignMenuProvider.ts","../src/context-pad/VcContextPadProvider.ts","../src/context-pad/index.ts","../src/label-editing/VcLabelEditingProvider.ts","../src/label-editing/index.ts","../src/popup/index.ts","../src/keyboard/VcKeyboardBindings.ts","../src/keyboard/VcEditorActions.ts","../src/keyboard/index.ts","../src/ordering/VcOrderingProvider.ts","../src/ordering/index.ts","../src/copy-paste/VcCopyPasteBehavior.ts","../src/copy-paste/index.ts","../src/resize/VcResizeBehavior.ts","../src/resize/index.ts","../src/Modeler.ts"],"sourcesContent":["import type { Connection, Shape } from 'diagram-js/lib/model/Types';\nimport type {\n ChainConnection,\n ConnectionType,\n DiagramElement,\n} from '@miragon/value-chain-schema-model';\n\nexport type VcShapeType = 'step' | 'orgUnit';\n\n/**\n * Runtime model: diagram-js elements carry the editable domain truth as flat properties\n * (`vcType`, `vcLabel`, `color`, `link`). The `businessObject` is only an import-time\n * snapshot used as fallback for fields the UI cannot edit.\n */\nexport interface VcShape extends Shape {\n vcType: VcShapeType;\n vcLabel: string;\n color?: string;\n link?: string;\n businessObject?: DiagramElement;\n}\n\nexport interface VcConnection extends Connection {\n vcType: ConnectionType;\n businessObject?: ChainConnection;\n}\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\nexport function isVcShape(element: unknown): element is VcShape {\n return isObject(element) && (element['vcType'] === 'step' || element['vcType'] === 'orgUnit');\n}\n\nexport function isStep(element: unknown): element is VcShape & { vcType: 'step' } {\n return isObject(element) && element['vcType'] === 'step';\n}\n\nexport function isOrgUnit(element: unknown): element is VcShape & { vcType: 'orgUnit' } {\n return isObject(element) && element['vcType'] === 'orgUnit';\n}\n\nexport function isVcConnection(element: unknown): element is VcConnection {\n return (\n isObject(element) &&\n (element['vcType'] === 'sequence' ||\n element['vcType'] === 'hierarchy' ||\n element['vcType'] === 'assignment') &&\n 'waypoints' in element\n );\n}\n\nexport function isVcElement(element: unknown): element is VcShape | VcConnection {\n return isVcShape(element) || isVcConnection(element);\n}\n","import type Canvas from 'diagram-js/lib/core/Canvas';\nimport type ElementRegistry from 'diagram-js/lib/core/ElementRegistry';\nimport type { Element } from 'diagram-js/lib/model/Types';\nimport { getBBox } from 'diagram-js/lib/util/Elements';\nimport { isVcElement } from '../model/di-types.js';\n\nconst EXPORT_PADDING = 20;\n\n/**\n * Standalone SVG export: clones the live SVG, sets a viewBox around the diagram\n * contents and strips the pan/zoom transform. Fonts are SVG presentation attributes,\n * so the result renders identically outside the editor.\n */\nexport function saveSVG(canvas: Canvas, elementRegistry: ElementRegistry): { svg: string } {\n const container = canvas.getContainer();\n const source = container.querySelector('svg');\n if (!source) {\n throw new Error('No SVG found in the canvas container.');\n }\n\n const elements = elementRegistry.getAll().filter(isVcElement) as Element[];\n const contents = elements.length ? getBBox(elements) : { x: 0, y: 0, width: 800, height: 600 };\n\n const box = {\n x: contents.x - EXPORT_PADDING,\n y: contents.y - EXPORT_PADDING,\n width: contents.width + EXPORT_PADDING * 2,\n height: contents.height + EXPORT_PADDING * 2,\n };\n\n const clone = source.cloneNode(true) as SVGSVGElement;\n clone.setAttribute('xmlns', 'http://www.w3.org/2000/svg');\n clone.setAttribute('viewBox', `${box.x} ${box.y} ${box.width} ${box.height}`);\n clone.setAttribute('width', String(box.width));\n clone.setAttribute('height', String(box.height));\n\n const viewport = clone.querySelector<SVGGElement>('.viewport');\n if (viewport) {\n viewport.removeAttribute('transform');\n }\n\n const svg = new XMLSerializer().serializeToString(clone);\n return { svg: `<?xml version=\"1.0\" encoding=\"utf-8\"?>\\n${svg}` };\n}\n","import Diagram from 'diagram-js/lib/Diagram';\nimport type { ModuleDeclaration } from 'didi';\nimport type Canvas from 'diagram-js/lib/core/Canvas';\nimport type ElementRegistry from 'diagram-js/lib/core/ElementRegistry';\nimport type EventBus from 'diagram-js/lib/core/EventBus';\nimport type { EventBusEventCallback } from 'diagram-js/lib/core/EventBus';\nimport type { ValueChainDocument } from '@miragon/value-chain-schema-model';\nimport type VcImporter from './io/VcImporter.js';\nimport type VcExporter from './io/VcExporter.js';\nimport { saveSVG } from './io/saveSvg.js';\nimport type { ImportWarning } from './io/types.js';\nimport { isVcElement } from './model/di-types.js';\n\nexport interface VcViewerOptions {\n /** Host element. If missing, a detached <div> is created (attach later via attachTo). */\n container?: HTMLElement;\n width?: number | string;\n height?: number | string;\n /** Concatenated to the end of the module list (extension point). */\n additionalModules?: ModuleDeclaration[];\n}\n\ninterface CommandStackLike {\n clear(): void;\n}\n\n/**\n * DI bootstrap and lifecycle shared by Viewer/NavigatedViewer/Modeler. The diagram is\n * created lazily on first access; `_getModules()` is a method (not a class field) to\n * avoid subclass field-initialization-order problems.\n */\nexport abstract class VcBaseViewer {\n protected abstract _getModules(): ModuleDeclaration[];\n\n private _diagram: Diagram | undefined;\n private readonly _container: HTMLElement;\n private readonly _options: VcViewerOptions;\n\n constructor(options: VcViewerOptions = {}) {\n this._options = options;\n this._container = this._createContainer(options);\n }\n\n get container(): HTMLElement {\n return this._container;\n }\n\n get<T>(name: string): T {\n return this._ensureDiagram().get<T>(name);\n }\n\n /** Like get(), but returns null instead of throwing when the service is absent. */\n getOptional<T>(name: string): T | null {\n return (this._ensureDiagram().get<T>(name, false) as T | null) ?? null;\n }\n\n on<T = unknown>(event: string, callback: EventBusEventCallback<T>, priority = 1000): void {\n this.get<EventBus>('eventBus').on(event, priority, callback as EventBusEventCallback<unknown>);\n }\n\n off<T = unknown>(event: string, callback: EventBusEventCallback<T>): void {\n this.get<EventBus>('eventBus').off(event, callback as EventBusEventCallback<unknown>);\n }\n\n /** Replaces the current diagram contents; clears the undo history. */\n importDocument(document: ValueChainDocument): ImportWarning[] {\n const importer = this.get<VcImporter>('vcImporter');\n importer.clear();\n const warnings = importer.import(document);\n this.getOptional<CommandStackLike>('commandStack')?.clear();\n this.fitViewport();\n this.get<EventBus>('eventBus').fire('import.done', { warnings });\n return warnings;\n }\n\n exportDocument(): ValueChainDocument {\n return this.get<VcExporter>('vcExporter').export();\n }\n\n saveSVG(): { svg: string } {\n return saveSVG(this.get<Canvas>('canvas'), this.get<ElementRegistry>('elementRegistry'));\n }\n\n /** Zooms to fit the diagram, never above 100%. */\n fitViewport(): void {\n const canvas = this.get<Canvas>('canvas');\n const hasContent = this.get<ElementRegistry>('elementRegistry').getAll().some(isVcElement);\n if (!hasContent) {\n return;\n }\n canvas.zoom('fit-viewport');\n if (canvas.zoom() > 1) {\n canvas.zoom(1);\n }\n }\n\n clear(): void {\n this.get<VcImporter>('vcImporter').clear();\n this.getOptional<CommandStackLike>('commandStack')?.clear();\n }\n\n attachTo(target: HTMLElement): void {\n this.detach();\n target.appendChild(this._container);\n this.get<Canvas>('canvas').resized();\n }\n\n detach(): void {\n this._container.parentNode?.removeChild(this._container);\n }\n\n destroy(): void {\n this._diagram?.destroy();\n this._diagram = undefined;\n this.detach();\n }\n\n private _createContainer(options: VcViewerOptions): HTMLElement {\n const container = options.container ?? document.createElement('div');\n container.classList.add('vc-container');\n container.style.width = sizeToCss(options.width ?? '100%');\n container.style.height = sizeToCss(options.height ?? (options.container ? '100%' : '600px'));\n return container;\n }\n\n private _ensureDiagram(): Diagram {\n if (!this._diagram) {\n const modules = [...this._getModules(), ...(this._options.additionalModules ?? [])];\n this._diagram = new Diagram({ canvas: { container: this._container }, modules });\n }\n return this._diagram;\n }\n}\n\nfunction sizeToCss(value: number | string): string {\n return typeof value === 'number' ? `${value}px` : value;\n}\n","import type ElementFactory from 'diagram-js/lib/core/ElementFactory';\nimport type { Shape } from 'diagram-js/lib/model/Types';\nimport {\n DEFAULT_ORG_UNIT_SIZE,\n DEFAULT_STEP_SIZE,\n type ChainConnection,\n type DiagramElement,\n} from '@miragon/value-chain-schema-model';\nimport type { VcConnection, VcShape } from './di-types.js';\n\n/**\n * Domain-aware factory: builds diagram-js shapes/connections from schema-model elements\n * (import) and blank ones for palette/context-pad creation.\n */\nexport default class VcElementFactory {\n static $inject = ['elementFactory'];\n\n constructor(private readonly elementFactory: ElementFactory) {}\n\n createElement(element: DiagramElement): VcShape {\n return this.elementFactory.createShape({\n id: element.id,\n x: element.bounds.x,\n y: element.bounds.y,\n width: element.bounds.width,\n height: element.bounds.height,\n vcType: element.elementType,\n vcLabel: element.name,\n ...(element.color !== undefined ? { color: element.color } : {}),\n ...(element.elementType === 'step' && element.link !== undefined\n ? { link: element.link }\n : {}),\n businessObject: element,\n }) as VcShape;\n }\n\n createConnection(connection: ChainConnection, source: Shape, target: Shape): VcConnection {\n return this.elementFactory.createConnection({\n id: connection.id,\n source,\n target,\n waypoints: connection.waypoints.map((point) => ({ x: point.x, y: point.y })),\n vcType: connection.connectionType,\n businessObject: connection,\n }) as VcConnection;\n }\n\n /**\n * A blank step for interactive creation: no id/position — diagram-js assigns the id,\n * the create/auto-place interaction assigns the position.\n */\n createNewStep(label = ''): VcShape {\n return this.elementFactory.createShape({\n width: DEFAULT_STEP_SIZE.width,\n height: DEFAULT_STEP_SIZE.height,\n vcType: 'step',\n vcLabel: label,\n }) as VcShape;\n }\n\n /** A blank organizational unit for interactive creation. */\n createNewOrgUnit(label = ''): VcShape {\n return this.elementFactory.createShape({\n width: DEFAULT_ORG_UNIT_SIZE.width,\n height: DEFAULT_ORG_UNIT_SIZE.height,\n vcType: 'orgUnit',\n vcLabel: label,\n }) as VcShape;\n }\n}\n","import ElementFactory from 'diagram-js/lib/core/ElementFactory';\nimport type ElementRegistry from 'diagram-js/lib/core/ElementRegistry';\nimport type { Connection, Label, Root, Shape } from 'diagram-js/lib/model/Types';\n\n/**\n * Replaces the stock elementFactory: generated ids are probed against the element\n * registry, so interactively created elements never collide with ids that came in\n * through document import (the stock factory's counter restarts at 0 per instance).\n */\nexport default class VcDiagramElementFactory extends ElementFactory {\n static $inject = ['elementRegistry'];\n\n private readonly counters = new Map<string, number>();\n\n constructor(private readonly elementRegistry: ElementRegistry) {\n super();\n }\n\n override create(type: 'root', attrs?: Partial<Root>): Root;\n override create(type: 'shape', attrs?: Partial<Shape>): Shape;\n override create(type: 'connection', attrs?: Partial<Connection>): Connection;\n override create(type: 'label', attrs?: Partial<Label>): Label;\n override create(\n type: 'root' | 'shape' | 'connection' | 'label',\n attrs?: Partial<Root & Shape & Connection & Label>,\n ): Root | Shape | Connection | Label {\n const withId = attrs?.id ? attrs : { ...attrs, id: this.unusedId(type) };\n switch (type) {\n case 'root':\n return super.create(type, withId);\n case 'shape':\n return super.create(type, withId);\n case 'connection':\n return super.create(type, withId);\n case 'label':\n return super.create(type, withId);\n }\n }\n\n private unusedId(type: string): string {\n let next = this.counters.get(type) ?? 0;\n let id: string;\n do {\n next += 1;\n id = `${type}_${next}`;\n } while (this.elementRegistry.get(id));\n this.counters.set(type, next);\n return id;\n }\n}\n","import type { ModuleDeclaration } from 'didi';\nimport VcElementFactory from './VcElementFactory.js';\nimport VcDiagramElementFactory from './VcDiagramElementFactory.js';\n\n/**\n * Domain-aware element creation (schema-model element → diagram-js element) plus an\n * elementFactory override with registry-probed id generation.\n */\nexport const vcModelModule: ModuleDeclaration = {\n elementFactory: ['type', VcDiagramElementFactory],\n vcElementFactory: ['type', VcElementFactory],\n};\n\nexport { default as VcElementFactory } from './VcElementFactory.js';\nexport { default as VcDiagramElementFactory } from './VcDiagramElementFactory.js';\nexport * from './di-types.js';\n","/**\n * Chevron (\"Blockpfeil\") geometry of a value chain step: flat top/bottom, a point on the\n * right and a matching notch cut into the left edge. Point/notch depth is half the height\n * (45° edges, the canonical ARIS/PowerPoint look), clamped so narrow steps don't degenerate.\n */\nexport function notchDepth(width: number, height: number): number {\n return Math.min(height / 2, 0.4 * width);\n}\n\n/** Shape-local chevron path for a step of the given size. */\nexport function chevronPath(width: number, height: number): string {\n return chevronPathAt(0, 0, width, height);\n}\n\n/**\n * Horizontal label inset. Less than the full notch depth: lines sit around the vertical\n * middle where the 45° notch/point edges leave `fontSize`-dependent extra room.\n */\nexport function labelInset(width: number, height: number): number {\n const depth = notchDepth(width, height);\n return Math.max(7, depth - 5);\n}\n\n/** Absolute chevron path, as consumed by diagram-js outline/cropping via getShapePath. */\nexport function chevronPathAt(x: number, y: number, width: number, height: number): string {\n const d = notchDepth(width, height);\n const my = y + height / 2;\n return [\n `M${x},${y}`,\n `L${x + width - d},${y}`,\n `L${x + width},${my}`,\n `L${x + width - d},${y + height}`,\n `L${x},${y + height}`,\n `L${x + d},${my}`,\n 'Z',\n ].join('');\n}\n\n/** Ellipse path (organizational unit), arc-based so cropping intersects exactly. */\nexport function ellipsePathAt(x: number, y: number, width: number, height: number): string {\n const rx = width / 2;\n const ry = height / 2;\n const cx = x + rx;\n return [\n `M${cx},${y}`,\n `A${rx},${ry} 0 0 1 ${cx},${y + height}`,\n `A${rx},${ry} 0 0 1 ${cx},${y}`,\n 'Z',\n ].join('');\n}\n","/**\n * Single source of visual constants, matching the bpmn.io design language:\n * near-black ink strokes (2px, round joins) on white fills, Arial 12px labels.\n */\nexport const COLORS = {\n ink: 'hsl(225, 10%, 15%)',\n fill: 'white',\n} as const;\n\nexport const FONT = {\n family: 'Arial, sans-serif',\n size: 12,\n lineHeight: 1.2,\n} as const;\n\nexport const STROKE_WIDTH = 2;\n\nexport const LABEL_PADDING = 7;\n\n/** Accent colors offered by the color picker (stroke + label tint; fill stays white). */\nexport const COLOR_OPTIONS: ReadonlyArray<{ label: string; color?: string }> = [\n { label: 'Default' },\n { label: 'Blue', color: 'hsl(205, 100%, 45%)' },\n { label: 'Green', color: 'hsl(150, 86%, 34%)' },\n { label: 'Orange', color: 'hsl(29, 89%, 44%)' },\n { label: 'Red', color: 'hsl(360, 100%, 45%)' },\n { label: 'Purple', color: 'hsl(287, 65%, 44%)' },\n];\n","import BaseRenderer from 'diagram-js/lib/draw/BaseRenderer';\nimport TextUtil from 'diagram-js/lib/util/Text';\nimport { createLine } from 'diagram-js/lib/util/RenderUtil';\nimport type EventBus from 'diagram-js/lib/core/EventBus';\nimport type { Connection, Element, Shape } from 'diagram-js/lib/model/Types';\nimport { append as svgAppend, attr as svgAttr, create as svgCreate } from 'tiny-svg';\nimport { chevronPath, chevronPathAt, ellipsePathAt, labelInset } from './geometry.js';\nimport { COLORS, FONT, LABEL_PADDING, STROKE_WIDTH } from './styles.js';\nimport {\n isOrgUnit,\n isVcConnection,\n isVcShape,\n type VcConnection,\n type VcShape,\n} from '../model/di-types.js';\n\n/** BaseRenderer default is 1000; 1500 wins the render.shape/render.connection event. */\nconst VC_RENDER_PRIORITY = 1500;\n\n/** Arrowhead geometry mirrors the bpmn-js sequence flow marker. */\nconst ARROW_PATH = 'M 1 5 L 11 10 L 1 15 Z';\n\nlet rendererInstances = 0;\n\nexport default class VcRenderer extends BaseRenderer {\n static $inject = ['eventBus'];\n\n private readonly textUtil = new TextUtil({\n style: {\n fontFamily: FONT.family,\n fontSize: FONT.size,\n fontWeight: 'normal',\n lineHeight: FONT.lineHeight,\n },\n });\n\n /** Unique per instance so marker ids never collide across diagrams on one page. */\n private readonly markerSuffix = `${(rendererInstances += 1)}`;\n\n constructor(eventBus: EventBus) {\n super(eventBus, VC_RENDER_PRIORITY);\n }\n\n override canRender(element: Element): boolean {\n return isVcShape(element) || isVcConnection(element);\n }\n\n override drawShape(visuals: SVGElement, element: Shape): SVGElement {\n const shape = element as VcShape;\n const stroke = shape.color ?? COLORS.ink;\n const orgUnit = isOrgUnit(shape);\n\n const path = svgCreate('path');\n svgAttr(path, {\n d: orgUnit\n ? ellipsePathAt(0, 0, shape.width, shape.height)\n : chevronPath(shape.width, shape.height),\n fill: COLORS.fill,\n stroke,\n 'stroke-width': STROKE_WIDTH,\n 'stroke-linecap': 'round',\n 'stroke-linejoin': 'round',\n });\n svgAppend(visuals, path);\n\n if (shape.vcLabel) {\n const inset = orgUnit ? LABEL_PADDING + 5 : labelInset(shape.width, shape.height);\n const label = this.textUtil.createText(shape.vcLabel, {\n box: { width: shape.width, height: shape.height },\n align: 'center-middle',\n padding: {\n top: LABEL_PADDING,\n bottom: LABEL_PADDING,\n left: inset,\n right: inset,\n },\n style: { fill: stroke },\n });\n svgAppend(visuals, label);\n }\n\n return path;\n }\n\n override drawConnection(visuals: SVGElement, element: Connection): SVGElement {\n const connection = element as VcConnection;\n const stroke = COLORS.ink;\n\n const attrs: Record<string, string | number> = {\n stroke,\n 'stroke-width': STROKE_WIDTH,\n 'stroke-linecap': 'round',\n 'stroke-linejoin': 'round',\n fill: 'none',\n };\n if (connection.vcType === 'sequence') {\n attrs['stroke-dasharray'] = '8, 5';\n }\n // assignments (org unit ↔ step) are plain lines without an arrowhead\n if (connection.vcType !== 'assignment') {\n const svg = visuals.ownerSVGElement;\n if (svg) {\n attrs['marker-end'] = this.arrowMarker(svg, stroke);\n }\n }\n\n const line = createLine(connection.waypoints, attrs);\n svgAppend(visuals, line);\n return line;\n }\n\n override getShapePath(shape: Shape): string {\n if (isOrgUnit(shape)) {\n return ellipsePathAt(shape.x, shape.y, shape.width, shape.height);\n }\n return chevronPathAt(shape.x, shape.y, shape.width, shape.height);\n }\n\n override getConnectionPath(connection: Connection): string {\n const [first, ...rest] = connection.waypoints;\n if (!first) {\n return '';\n }\n return `M${first.x},${first.y}${rest.map((point) => `L${point.x},${point.y}`).join('')}`;\n }\n\n private arrowMarker(svg: SVGSVGElement, color: string): string {\n const id = `vc-arrow-${this.markerSuffix}-${color.replace(/[^a-zA-Z0-9]/g, '')}`;\n if (!svg.querySelector(`marker[id=\"${id}\"]`)) {\n let defs = svg.querySelector('defs');\n if (!defs) {\n defs = svgCreate('defs') as SVGDefsElement;\n svgAppend(svg, defs);\n }\n const marker = svgCreate('marker');\n svgAttr(marker, {\n id,\n viewBox: '0 0 20 20',\n refX: 11,\n refY: 10,\n markerWidth: 10,\n markerHeight: 10,\n orient: 'auto',\n });\n const arrow = svgCreate('path');\n svgAttr(arrow, {\n d: ARROW_PATH,\n fill: color,\n stroke: color,\n 'stroke-width': 1,\n 'stroke-linejoin': 'round',\n });\n svgAppend(marker, arrow);\n svgAppend(defs, marker);\n }\n return `url(#${id})`;\n }\n}\n","import type { ModuleDeclaration } from 'didi';\nimport VcRenderer from './VcRenderer.js';\n\n/** SVG rendering of value chain steps and connections (BaseRenderer subclass). */\nexport const vcDrawModule: ModuleDeclaration = {\n __init__: ['vcRenderer'],\n vcRenderer: ['type', VcRenderer],\n};\n\nexport { default as VcRenderer } from './VcRenderer.js';\nexport { chevronPath, chevronPathAt, ellipsePathAt, notchDepth } from './geometry.js';\nexport { COLORS, COLOR_OPTIONS, FONT } from './styles.js';\n","export const ROOT_ID = 'vc-root';\n\nexport interface ImportWarning {\n message: string;\n connectionId?: string;\n}\n\n/** Document-level metadata kept on the root element while editing. */\nexport interface RootBusinessObject {\n name: string;\n}\n","import type Canvas from 'diagram-js/lib/core/Canvas';\nimport type ElementFactory from 'diagram-js/lib/core/ElementFactory';\nimport type ElementRegistry from 'diagram-js/lib/core/ElementRegistry';\nimport type EventBus from 'diagram-js/lib/core/EventBus';\nimport type { Shape } from 'diagram-js/lib/model/Types';\nimport type { ValueChainDocument } from '@miragon/value-chain-schema-model';\nimport type VcElementFactory from '../model/VcElementFactory.js';\nimport { isVcConnection, isVcShape } from '../model/di-types.js';\nimport { ROOT_ID, type ImportWarning, type RootBusinessObject } from './types.js';\n\n/**\n * Renders a value chain document onto the canvas. Deliberately bypasses the command\n * stack — importing must not create undo entries.\n */\nexport default class VcImporter {\n static $inject = ['canvas', 'elementFactory', 'vcElementFactory', 'elementRegistry', 'eventBus'];\n\n constructor(\n private readonly canvas: Canvas,\n private readonly elementFactory: ElementFactory,\n private readonly vcElementFactory: VcElementFactory,\n private readonly elementRegistry: ElementRegistry,\n private readonly eventBus: EventBus,\n ) {}\n\n import(document: ValueChainDocument): ImportWarning[] {\n const warnings: ImportWarning[] = [];\n this.eventBus.fire('import.render.start', { document });\n\n const root = this.ensureRoot();\n (root.businessObject as RootBusinessObject) = { name: document.meta.name };\n\n const shapeById = new Map<string, Shape>();\n for (const element of document.elements) {\n if (element.id === ROOT_ID) {\n warnings.push({ message: `Skipped element \"${element.id}\": reserved id.` });\n continue;\n }\n const shape = this.vcElementFactory.createElement(element);\n this.canvas.addShape(shape, root);\n shapeById.set(element.id, shape);\n }\n\n let connectionIndex = 0;\n for (const connection of document.connections) {\n const source = shapeById.get(connection.source);\n const target = shapeById.get(connection.target);\n if (!source || !target) {\n warnings.push({\n message: `Skipped connection \"${connection.id}\": unresolved endpoint.`,\n connectionId: connection.id,\n });\n continue;\n }\n const element = this.vcElementFactory.createConnection(connection, source, target);\n // Insert connections at the front of the children so they paint behind the steps.\n this.canvas.addConnection(element, root, connectionIndex);\n connectionIndex += 1;\n }\n\n this.eventBus.fire('import.render.done', { document, warnings });\n return warnings;\n }\n\n /** Removes all imported elements and document meta, tolerating elements already gone. */\n clear(): void {\n const elements = this.elementRegistry.getAll();\n for (const element of elements) {\n if (element.id === ROOT_ID) {\n element.businessObject = undefined;\n continue;\n }\n try {\n if (isVcConnection(element)) {\n this.canvas.removeConnection(element);\n } else if (isVcShape(element)) {\n this.canvas.removeShape(element);\n }\n } catch {\n // already removed along with a previous element\n }\n }\n }\n\n private ensureRoot(): ReturnType<Canvas['getRootElement']> {\n const existing = this.canvas.getRootElement();\n if (existing.id === ROOT_ID) {\n return existing;\n }\n const root = this.elementFactory.createRoot({ id: ROOT_ID });\n this.canvas.setRootElement(root);\n return root;\n }\n}\n","import type ElementRegistry from 'diagram-js/lib/core/ElementRegistry';\nimport type Canvas from 'diagram-js/lib/core/Canvas';\nimport {\n CURRENT_SCHEMA_VERSION,\n validateDocument,\n type ChainConnection,\n type DiagramElement,\n type ValueChainDocument,\n} from '@miragon/value-chain-schema-model';\nimport { isVcConnection, isVcShape } from '../model/di-types.js';\nimport { ROOT_ID, type RootBusinessObject } from './types.js';\n\n/**\n * Rebuilds a schema-model document from the live diagram. The diagram-js element\n * properties are the source of truth; businessObject only backfills fields the UI\n * cannot edit (currently: `link`).\n */\nexport default class VcExporter {\n static $inject = ['elementRegistry', 'canvas'];\n\n constructor(\n private readonly elementRegistry: ElementRegistry,\n private readonly canvas: Canvas,\n ) {}\n\n export(): ValueChainDocument {\n const elements: DiagramElement[] = [];\n const connections: ChainConnection[] = [];\n\n for (const element of this.elementRegistry.getAll()) {\n if (element.id === ROOT_ID) {\n continue;\n }\n if (isVcConnection(element)) {\n if (!element.source || !element.target) {\n continue;\n }\n connections.push({\n id: element.id,\n connectionType: element.vcType,\n source: element.source.id,\n target: element.target.id,\n waypoints: element.waypoints.map((point) => ({ x: point.x, y: point.y })),\n });\n } else if (isVcShape(element)) {\n const bounds = {\n x: element.x,\n y: element.y,\n width: element.width,\n height: element.height,\n };\n const color = element.color !== undefined ? { color: element.color } : {};\n if (element.vcType === 'orgUnit') {\n elements.push({\n id: element.id,\n elementType: 'orgUnit',\n name: element.vcLabel,\n bounds,\n ...color,\n });\n } else {\n const businessObject = element.businessObject;\n const link =\n element.link ??\n (businessObject?.elementType === 'step' ? businessObject.link : undefined);\n elements.push({\n id: element.id,\n elementType: 'step',\n name: element.vcLabel,\n bounds,\n ...color,\n ...(link !== undefined ? { link } : {}),\n });\n }\n }\n }\n\n const rootMeta = this.canvas.getRootElement().businessObject as RootBusinessObject | undefined;\n\n return validateDocument({\n schemaVersion: CURRENT_SCHEMA_VERSION,\n meta: { name: rootMeta?.name ?? 'Untitled value chain' },\n elements,\n connections,\n });\n }\n}\n","import type { ModuleDeclaration } from 'didi';\nimport VcImporter from './VcImporter.js';\nimport VcExporter from './VcExporter.js';\n\n/** Document import/export between schema-model and the canvas. */\nexport const ioModule: ModuleDeclaration = {\n vcImporter: ['type', VcImporter],\n vcExporter: ['type', VcExporter],\n};\n\nexport { default as VcImporter } from './VcImporter.js';\nexport { default as VcExporter } from './VcExporter.js';\nexport { saveSVG } from './saveSvg.js';\nexport { ROOT_ID, type ImportWarning, type RootBusinessObject } from './types.js';\n","import type { ModuleDeclaration } from 'didi';\nimport { VcBaseViewer } from './VcBaseViewer.js';\nimport { vcModelModule } from './model/index.js';\nimport { vcDrawModule } from './draw/index.js';\nimport { ioModule } from './io/index.js';\n\n/** Read-only rendering of value chain documents. */\nexport class Viewer extends VcBaseViewer {\n protected _getModules(): ModuleDeclaration[] {\n return [vcModelModule, vcDrawModule, ioModule];\n }\n}\n","import type { ModuleDeclaration } from 'didi';\nimport SelectionModule from 'diagram-js/lib/features/selection';\nimport ZoomScrollModule from 'diagram-js/lib/navigation/zoomscroll';\nimport MoveCanvasModule from 'diagram-js/lib/navigation/movecanvas';\nimport { Viewer } from './Viewer.js';\n\n/** Viewer plus canvas navigation (zoom, pan, selection). */\nexport class NavigatedViewer extends Viewer {\n protected override _getModules(): ModuleDeclaration[] {\n return [...super._getModules(), SelectionModule, ZoomScrollModule, MoveCanvasModule];\n }\n}\n","import type { Element } from 'diagram-js/lib/model/Types';\n\nexport interface UpdatePropertiesContext {\n element: Element;\n properties: Record<string, unknown>;\n oldProperties?: Record<string, unknown>;\n}\n\n/**\n * Generic undoable property update: `execute` remembers the previous values,\n * `revert` restores them. Returned elements trigger `elements.changed` → re-render.\n */\nexport default class UpdatePropertiesHandler {\n execute(context: UpdatePropertiesContext): Element[] {\n const { element, properties } = context;\n const target = element as unknown as Record<string, unknown>;\n const old: Record<string, unknown> = {};\n for (const key of Object.keys(properties)) {\n old[key] = target[key];\n setOrDelete(target, key, properties[key]);\n }\n context.oldProperties = old;\n return [element];\n }\n\n revert(context: UpdatePropertiesContext): Element[] {\n const { element, oldProperties } = context;\n const target = element as unknown as Record<string, unknown>;\n if (oldProperties) {\n for (const key of Object.keys(oldProperties)) {\n setOrDelete(target, key, oldProperties[key]);\n }\n }\n return [element];\n }\n}\n\nfunction setOrDelete(target: Record<string, unknown>, key: string, value: unknown): void {\n if (value === undefined) {\n delete target[key];\n } else {\n target[key] = value;\n }\n}\n","import type CommandStack from 'diagram-js/lib/command/CommandStack';\nimport type { Element } from 'diagram-js/lib/model/Types';\nimport type { ConnectionType } from '@miragon/value-chain-schema-model';\nimport UpdatePropertiesHandler from './cmd/UpdatePropertiesHandler.js';\nimport type { VcConnection, VcShape } from '../model/di-types.js';\n\nconst UPDATE_PROPERTIES = 'element.updateProperties';\n\n/** High-level undoable domain mutations; everything funnels through one command. */\nexport default class VcModeling {\n static $inject = ['commandStack'];\n\n constructor(private readonly commandStack: CommandStack) {\n commandStack.registerHandler(UPDATE_PROPERTIES, UpdatePropertiesHandler);\n }\n\n updateProperties(element: Element, properties: Record<string, unknown>): void {\n this.commandStack.execute(UPDATE_PROPERTIES, { element, properties });\n }\n\n updateLabel(element: VcShape, label: string): void {\n if (label === element.vcLabel) {\n return;\n }\n this.updateProperties(element, { vcLabel: label });\n }\n\n setColor(element: VcShape, color: string | undefined): void {\n if (color === element.color) {\n return;\n }\n this.updateProperties(element, { color });\n }\n\n /** Re-routing happens in the same undo step via VcConnectionTypeBehavior. */\n setConnectionType(connection: VcConnection, type: ConnectionType): void {\n if (type === connection.vcType) {\n return;\n }\n this.updateProperties(connection, { vcType: type });\n }\n}\n","import BaseLayouter from 'diagram-js/lib/layout/BaseLayouter';\nimport type CroppingConnectionDocking from 'diagram-js/lib/layout/CroppingConnectionDocking';\nimport { getMid } from 'diagram-js/lib/layout/LayoutUtil';\nimport {\n connectPoints,\n connectRectangles,\n withoutRedundantPoints,\n} from 'diagram-js/lib/layout/ManhattanLayout';\nimport type { Connection, Shape } from 'diagram-js/lib/model/Types';\nimport type { Point } from 'diagram-js/lib/util/Types';\nimport { notchDepth } from '../draw/geometry.js';\n\n/** Horizontal distance of the column trunk from the leftmost sub-step. */\nconst TRUNK_MARGIN = 25;\n\n/**\n * Minimum gap between the center exit and the leftmost sub-step for the trunk to run\n * straight down under the exit (kink-free column).\n */\nexport const TRUNK_CLEARANCE = 10;\n\n/** Minimum stub length below the parent before the bus/trunk elbow. */\nconst BUS_MIN_STUB = 10;\n\n/** Keeps the drop-span boundary away from the parent's corners/point. */\nconst EXIT_MARGIN = 10;\n\nexport interface VcLayoutHints {\n source?: Shape;\n target?: Shape;\n connectionStart?: Point;\n connectionEnd?: Point;\n waypoints?: Point[];\n}\n\n/**\n * Connection routing:\n * - sequence (\"ist Vorgänger von\"): straight line, user bendpoints survive re-layouts;\n * - hierarchy (\"ist prozessorientiert übergeordnet\"): always re-routed orthogonally\n * (ARIS cascade look — down from the parent, across, down into the sub-step).\n * Both are cropped at the chevron contour via the renderer's getShapePath.\n */\nexport default class VcLayouter extends BaseLayouter {\n static $inject = ['connectionDocking'];\n\n constructor(private readonly connectionDocking: CroppingConnectionDocking) {\n super();\n }\n\n override layoutConnection(connection: Connection, hints: VcLayoutHints = {}): Point[] {\n const source = hints.source ?? (connection.source as Shape | undefined);\n const target = hints.target ?? (connection.target as Shape | undefined);\n if (!source || !target) {\n return connection.waypoints?.map((point) => ({ x: point.x, y: point.y })) ?? [];\n }\n\n const waypoints = isHierarchy(connection)\n ? this.hierarchyWaypoints(source, target, hints)\n : this.sequenceWaypoints(connection, source, target, hints);\n\n const stub = { ...connection, source, target, waypoints } as Connection;\n let result = waypoints;\n try {\n result = this.connectionDocking.getCroppedWaypoints(stub, source, target);\n } catch {\n // fall through to the uncropped waypoints\n }\n\n // Non-finite coordinates (e.g. anchors adjusted against degenerate zero-size old\n // bounds, see diagram-js AttachUtil.getNewAttachPoint) must never reach the model:\n // once a waypoint is NaN, every handle/bendpoint render throws. Fall back to a\n // plain mid-to-mid line in that case.\n if (!allFinite(result)) {\n const fallback = [getMid(source), getMid(target)];\n return allFinite(fallback) ? fallback : [];\n }\n return result;\n }\n\n /**\n * Straight line between the shape mids, cropped to the contours afterwards.\n * The connectionStart/End anchor hints diagram-js passes on move (old cropped\n * waypoint + delta) are ignored on purpose: such a point can land in the chevron's\n * notch cutout where cropping finds no intersection, leaving the arrowhead hidden\n * behind the shape. Mid-to-mid always crops reliably; user bendpoints survive.\n */\n private sequenceWaypoints(\n connection: Connection,\n source: Shape,\n target: Shape,\n hints: VcLayoutHints,\n ): Point[] {\n const interior = (hints.waypoints ?? connection.waypoints ?? [])\n .slice(1, -1)\n .map((point) => ({ x: point.x, y: point.y }));\n return [getMid(source), ...interior, getMid(target)];\n }\n\n /**\n * Adaptive hierarchy routing. Every edge exits the parent at its BOTTOM CENTER;\n * the sub-steps' arrangement picks how it continues:\n * - horizontal row (aligned tops / single child under the parent's span): down to a\n * shared bus halfway to the children, across, and down into each sub-step's top;\n * - vertical column (ARIS rake, the default): straight down under the exit whenever\n * all children sit right of the center (no kink), otherwise via a bus to a shared\n * trunk left of all children; then a horizontal arm into each left notch.\n * Anchor hints are ignored on purpose: hierarchy edges always re-route from the\n * current geometry.\n */\n private hierarchyWaypoints(source: Shape, target: Shape, _hints: VcLayoutHints): Point[] {\n const sourceMid = getMid(source);\n const targetMid = getMid(target);\n\n if (target.y >= source.y + source.height) {\n const children = hierarchyChildren(source);\n const group = children.length ? children : [target];\n\n if (isRowArrangement(group, source)) {\n return withoutRedundantPoints(connectPoints(sourceMid, targetMid, 'v:v'));\n }\n\n const bottom = source.y + source.height;\n const topmost = Math.min(...group.map((child) => child.y));\n const busY = Math.max(bottom + BUS_MIN_STUB, (bottom + topmost) / 2);\n const minChildX = Math.min(...group.map((child) => child.x));\n const trunkX =\n sourceMid.x <= minChildX - TRUNK_CLEARANCE ? sourceMid.x : minChildX - TRUNK_MARGIN;\n return withoutRedundantPoints([\n sourceMid,\n { x: sourceMid.x, y: busY },\n { x: trunkX, y: busY },\n { x: trunkX, y: targetMid.y },\n targetMid,\n ]);\n }\n\n return withoutRedundantPoints(\n connectRectangles(source, target, sourceMid, targetMid, { preferredLayouts: ['v:v'] }),\n );\n }\n}\n\n/**\n * The x range of the parent's bottom edge in which a sub-step's hierarchy edge is\n * drawn as a straight vertical drop (row notation) instead of the rake.\n */\nexport function hierarchyDropSpan(source: Shape): { min: number; max: number } {\n return {\n min: source.x + EXIT_MARGIN,\n max: source.x + source.width - notchDepth(source.width, source.height) - EXIT_MARGIN,\n };\n}\n\n/** All sub-steps connected to the given step via hierarchy edges. */\nexport function hierarchyChildren(source: Shape): Shape[] {\n return (source.outgoing ?? [])\n .filter((connection) => isHierarchy(connection))\n .map((connection) => connection.target as Shape)\n .filter((target): target is Shape => !!target);\n}\n\n/**\n * A horizontal row: several children with aligned tops, or a single child sitting\n * inside the parent's drop span. Shared by routing and auto-placement so both always\n * agree on the arrangement.\n */\nexport function isRowArrangement(children: Shape[], source: Shape): boolean {\n if (!children.length) {\n return false;\n }\n if (children.length >= 2) {\n const tops = children.map((child) => child.y);\n return Math.max(...tops) - Math.min(...tops) <= ROW_TOLERANCE_Y;\n }\n const child = children[0]!;\n const centerX = child.x + child.width / 2;\n const span = hierarchyDropSpan(source);\n return centerX >= span.min && centerX <= span.max;\n}\n\n/** Row detection tolerance for \"aligned tops\". */\nconst ROW_TOLERANCE_Y = 10;\n\nfunction isHierarchy(connection: Connection): boolean {\n return (connection as { vcType?: string }).vcType === 'hierarchy';\n}\n\nfunction allFinite(points: Point[]): boolean {\n return points.every((point) => Number.isFinite(point.x) && Number.isFinite(point.y));\n}\n","import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';\nimport type EventBus from 'diagram-js/lib/core/EventBus';\nimport type Modeling from 'diagram-js/lib/features/modeling/Modeling';\nimport type { Connection } from 'diagram-js/lib/model/Types';\nimport { isVcConnection } from '../model/di-types.js';\n\ninterface UpdatePropertiesContext {\n element?: unknown;\n properties?: Record<string, unknown>;\n}\n\n/**\n * Switching a connection's type changes its routing (straight/dashed vs rake).\n * Re-layout nested inside the updateProperties command, so type change and new\n * route form a single undo step.\n */\nexport default class VcConnectionTypeBehavior extends CommandInterceptor {\n static override $inject = ['eventBus', 'modeling'];\n\n constructor(eventBus: EventBus, modeling: Modeling) {\n super(eventBus);\n\n this.postExecute(\n ['element.updateProperties'],\n (context: UpdatePropertiesContext) => {\n const { element, properties } = context;\n if (properties && 'vcType' in properties && isVcConnection(element)) {\n modeling.layoutConnection(element as Connection);\n }\n },\n true,\n );\n }\n}\n","import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';\nimport type EventBus from 'diagram-js/lib/core/EventBus';\nimport type Modeling from 'diagram-js/lib/features/modeling/Modeling';\nimport type { Connection, Shape } from 'diagram-js/lib/model/Types';\nimport type { Point } from 'diagram-js/lib/util/Types';\nimport type VcLayouter from './VcLayouter.js';\nimport { isVcConnection, isVcShape } from '../model/di-types.js';\n\ninterface CommandContext {\n shape?: unknown;\n shapes?: unknown[];\n elements?: unknown[];\n connection?: unknown;\n}\n\n/**\n * Hierarchy routing depends on the whole sibling group (row vs column), but diagram-js\n * only re-layouts the edges of the shape that moved. This behavior re-layouts ALL\n * hierarchy edges of every affected parent — nested into the triggering command, so\n * arrangement flips stay one undo step and no sibling keeps a stale route.\n */\nexport default class VcHierarchyRelayoutBehavior extends CommandInterceptor {\n static override $inject = ['eventBus', 'modeling', 'layouter'];\n\n constructor(\n eventBus: EventBus,\n private readonly modeling: Modeling,\n private readonly layouter: VcLayouter,\n ) {\n super(eventBus);\n\n this.postExecuted(\n ['shape.move', 'elements.move', 'shape.resize', 'connection.create', 'connection.delete'],\n (context: CommandContext) => this.relayoutAffected(context),\n true,\n );\n }\n\n private relayoutAffected(context: CommandContext): void {\n const shapes = [context.shape, ...(context.shapes ?? []), ...(context.elements ?? [])].filter(\n isVcShape,\n );\n\n const connection = context.connection;\n const parents = new Set<Shape>();\n\n if (isVcConnection(connection) && connection.vcType === 'hierarchy' && connection.source) {\n parents.add(connection.source as Shape);\n }\n\n for (const shape of shapes) {\n if (hierarchyEdges(shape as Shape).length) {\n parents.add(shape as Shape);\n }\n for (const incoming of (shape as Shape).incoming ?? []) {\n if (isVcConnection(incoming) && incoming.vcType === 'hierarchy' && incoming.source) {\n parents.add(incoming.source as Shape);\n }\n }\n }\n\n for (const parent of parents) {\n for (const edge of hierarchyEdges(parent)) {\n const fresh = this.layouter.layoutConnection(edge);\n if (!sameWaypoints(fresh, edge.waypoints ?? [])) {\n this.modeling.layoutConnection(edge);\n }\n }\n }\n }\n}\n\nfunction hierarchyEdges(shape: Shape): Connection[] {\n return ((shape.outgoing ?? []) as Connection[]).filter(\n (connection) => isVcConnection(connection) && connection.vcType === 'hierarchy',\n );\n}\n\nfunction sameWaypoints(a: Point[], b: Point[]): boolean {\n return (\n a.length === b.length &&\n a.every((point, index) => point.x === b[index]!.x && point.y === b[index]!.y)\n );\n}\n","import type { ModuleDeclaration } from 'didi';\nimport CroppingConnectionDocking from 'diagram-js/lib/layout/CroppingConnectionDocking';\nimport VcModeling from './VcModeling.js';\nimport VcLayouter from './VcLayouter.js';\nimport VcConnectionTypeBehavior from './VcConnectionTypeBehavior.js';\nimport VcHierarchyRelayoutBehavior from './VcHierarchyRelayoutBehavior.js';\n\n/**\n * Domain mutations + connection layout. Overrides the stock `layouter` and registers\n * `connectionDocking` (also consumed by bendpoints and connection previews).\n */\nexport const vcModelingModule: ModuleDeclaration = {\n __init__: ['vcModeling', 'vcConnectionTypeBehavior', 'vcHierarchyRelayoutBehavior'],\n vcModeling: ['type', VcModeling],\n vcConnectionTypeBehavior: ['type', VcConnectionTypeBehavior],\n vcHierarchyRelayoutBehavior: ['type', VcHierarchyRelayoutBehavior],\n layouter: ['type', VcLayouter],\n connectionDocking: ['type', CroppingConnectionDocking],\n};\n\nexport { default as VcModeling } from './VcModeling.js';\nexport {\n default as VcLayouter,\n hierarchyDropSpan,\n hierarchyChildren,\n isRowArrangement,\n} from './VcLayouter.js';\nexport { default as VcConnectionTypeBehavior } from './VcConnectionTypeBehavior.js';\nexport { default as VcHierarchyRelayoutBehavior } from './VcHierarchyRelayoutBehavior.js';\n","import RuleProvider from 'diagram-js/lib/features/rules/RuleProvider';\nimport type EventBus from 'diagram-js/lib/core/EventBus';\nimport type { Element } from 'diagram-js/lib/model/Types';\nimport type { ConnectionType } from '@miragon/value-chain-schema-model';\nimport {\n isOrgUnit,\n isStep,\n isVcConnection,\n isVcShape,\n type VcConnection,\n type VcShape,\n} from '../model/di-types.js';\nimport type VcConnect from '../connect/VcConnect.js';\n\ninterface ConnectContext {\n source?: Element;\n target?: Element;\n connection?: Element;\n}\n\nexport default class VcRules extends RuleProvider {\n static override $inject = ['eventBus', 'vcConnect'];\n\n constructor(\n eventBus: EventBus,\n private readonly vcConnect: VcConnect,\n ) {\n super(eventBus);\n }\n\n override init(): void {\n this.addRule('connection.start', (context: ConnectContext) => isVcShape(context.source));\n\n this.addRule('connection.create', (context: ConnectContext) => {\n const { source, target } = context;\n const type = this.resolveType(source, target);\n if (!type || hasConnection(source as VcShape, target as VcShape, type)) {\n return false;\n }\n return { vcType: type };\n });\n\n this.addRule('connection.reconnect', (context: ConnectContext) => {\n const { source, target, connection } = context;\n if (!isVcConnection(connection) || !isVcShape(source) || !isVcShape(target)) {\n return false;\n }\n if (source === target || !endpointsAllowed(connection.vcType, source, target)) {\n return false;\n }\n return !hasConnection(source, target, connection.vcType, connection);\n });\n\n this.addRule('connection.updateWaypoints', (context: ConnectContext) =>\n isVcConnection(context.connection),\n );\n\n // Elements live directly on the root — no containment.\n this.addRule('shape.create', (context: { target?: Element }) => isRoot(context.target));\n this.addRule('elements.create', (context: { target?: Element }) => isRoot(context.target));\n\n this.addRule(['shape.move', 'elements.move'], () => true);\n this.addRule('shape.resize', (context: { shape?: Element }) => isVcShape(context.shape));\n\n this.addRule(['elements.align', 'elements.distribute'], (context: { elements?: Element[] }) =>\n (context.elements ?? []).filter(isVcShape),\n );\n }\n\n /**\n * The relation type follows from the endpoint kinds: step→step uses the pending\n * connect type, an org unit on either end always yields an assignment.\n */\n private resolveType(\n source: Element | undefined,\n target: Element | undefined,\n ): ConnectionType | null {\n if (!isVcShape(source) || !isVcShape(target) || source === target) {\n return null;\n }\n if (isStep(source) && isStep(target)) {\n const pending = this.vcConnect.pendingType;\n return pending === 'assignment' ? null : pending;\n }\n if ((isStep(source) && isOrgUnit(target)) || (isOrgUnit(source) && isStep(target))) {\n return 'assignment';\n }\n return null;\n }\n}\n\nfunction isRoot(element: Element | undefined): boolean {\n return !!element && !isVcShape(element) && !isVcConnection(element) && !element.parent;\n}\n\nfunction endpointsAllowed(type: ConnectionType, source: VcShape, target: VcShape): boolean {\n if (type === 'assignment') {\n return (isStep(source) && isOrgUnit(target)) || (isOrgUnit(source) && isStep(target));\n }\n return isStep(source) && isStep(target);\n}\n\nfunction hasConnection(\n source: VcShape,\n target: VcShape,\n type: ConnectionType,\n ignore?: VcConnection,\n): boolean {\n const links = [\n ...(source.outgoing ?? []),\n ...(type === 'assignment' ? (source.incoming ?? []) : []),\n ];\n return links.some(\n (connection) =>\n connection !== ignore &&\n isVcConnection(connection) &&\n connection.vcType === type &&\n (connection.target === target || connection.source === target),\n );\n}\n","import type { ModuleDeclaration } from 'didi';\nimport RulesModule from 'diagram-js/lib/features/rules';\nimport VcRules from './VcRules.js';\n\nexport const vcRulesModule: ModuleDeclaration = {\n __depends__: [RulesModule],\n __init__: ['vcRules'],\n vcRules: ['type', VcRules],\n};\n\nexport { default as VcRules } from './VcRules.js';\n","import type Connect from 'diagram-js/lib/features/connect/Connect';\nimport type EventBus from 'diagram-js/lib/core/EventBus';\nimport type { ConnectionType } from '@miragon/value-chain-schema-model';\nimport type { VcShape } from '../model/di-types.js';\n\n/**\n * Typed wrapper around the diagram-js connect interaction. The rule provider reads\n * `pendingType` while a connect/create drag is running to stamp the right connection\n * type; it resets to the default once the interaction is over.\n */\nexport default class VcConnect {\n static $inject = ['connect', 'eventBus'];\n\n pendingType: ConnectionType = 'sequence';\n\n constructor(\n private readonly connect: Connect,\n eventBus: EventBus,\n ) {\n eventBus.on(['connect.cleanup', 'create.cleanup', 'global-connect.cleanup'], () => {\n this.pendingType = 'sequence';\n });\n }\n\n start(event: MouseEvent | Event, source: VcShape, type: ConnectionType): void {\n this.pendingType = type;\n this.connect.start(event as MouseEvent, source);\n }\n}\n","import type { ModuleDeclaration } from 'didi';\nimport ConnectModule from 'diagram-js/lib/features/connect';\nimport VcConnect from './VcConnect.js';\n\nexport const vcConnectModule: ModuleDeclaration = {\n __depends__: [ConnectModule],\n __init__: ['vcConnect'],\n vcConnect: ['type', VcConnect],\n};\n\nexport { default as VcConnect } from './VcConnect.js';\n","import type AutoPlace from 'diagram-js/lib/features/auto-place/AutoPlace';\nimport type Create from 'diagram-js/lib/features/create/Create';\nimport type { Shape } from 'diagram-js/lib/model/Types';\nimport type { ConnectionType } from '@miragon/value-chain-schema-model';\nimport type VcElementFactory from '../model/VcElementFactory.js';\nimport type VcConnect from '../connect/VcConnect.js';\nimport type { VcShape } from '../model/di-types.js';\n\n/**\n * Append interactions à la bpmn.io: click places the new element automatically\n * (auto-place, label editing opens via the label-editing provider); dragging places\n * it manually with a live connection preview. `assignment` appends an organizational\n * unit; the other types append a step.\n */\nexport default class VcAppend {\n static $inject = ['autoPlace', 'create', 'vcElementFactory', 'vcConnect'];\n\n constructor(\n private readonly autoPlace: AutoPlace,\n private readonly create: Create,\n private readonly factory: VcElementFactory,\n private readonly vcConnect: VcConnect,\n ) {}\n\n append(source: VcShape, type: ConnectionType): Shape {\n this.vcConnect.pendingType = type;\n const newShape = this.autoPlace.append(source as Shape, this.createShape(type) as Shape, {\n connection: { vcType: type },\n }) as Shape;\n this.vcConnect.pendingType = 'sequence';\n return newShape;\n }\n\n startAppendDrag(event: Event, source: VcShape, type: ConnectionType): void {\n this.vcConnect.pendingType = type;\n this.create.start(event as MouseEvent, this.createShape(type) as Shape, {\n source: source as Shape,\n });\n }\n\n private createShape(type: ConnectionType): VcShape {\n return type === 'assignment' ? this.factory.createNewOrgUnit() : this.factory.createNewStep();\n }\n}\n","import type ElementRegistry from 'diagram-js/lib/core/ElementRegistry';\nimport type EventBus from 'diagram-js/lib/core/EventBus';\nimport type { Shape } from 'diagram-js/lib/model/Types';\nimport type { Point } from 'diagram-js/lib/util/Types';\nimport { isVcShape, type VcShape } from '../model/di-types.js';\nimport { hierarchyChildren, isRowArrangement, TRUNK_CLEARANCE } from '../modeling/VcLayouter.js';\nimport type VcConnect from '../connect/VcConnect.js';\n\n/** Runs before the diagram-js default (priority 100). */\nconst BEFORE_DEFAULT = 200;\n\nconst SEQUENCE_GAP_X = 45;\nconst HIERARCHY_GAP_Y = 45;\n\nconst SIBLING_GAP_Y = 30;\nconst SIBLING_GAP_X = 20;\nconst DECONFLICT_STEP_Y = 30;\nconst DECONFLICT_MARGIN = 10;\n\n/**\n * Placement of appended steps:\n * - sequence: to the right of the source (reading direction),\n * - hierarchy: follows the existing arrangement of the parent's sub-steps — a\n * horizontal row keeps growing to the right, a vertical column (ARIS rake,\n * the default) keeps growing downwards.\n * All placements nudge downwards until the spot is free of other steps.\n */\nexport default class VcAutoPlaceBehavior {\n static $inject = ['eventBus', 'vcConnect', 'elementRegistry'];\n\n constructor(eventBus: EventBus, vcConnect: VcConnect, elementRegistry: ElementRegistry) {\n eventBus.on(\n 'autoPlace',\n BEFORE_DEFAULT,\n (context: { source: Shape; shape: Shape }): Point | undefined => {\n const { source, shape } = context;\n if (!isVcShape(source)) {\n return undefined;\n }\n\n const desired = this.desiredPosition(vcConnect.pendingType, source, shape);\n return this.deconflict(desired, shape);\n },\n );\n\n this.elementRegistry = elementRegistry;\n }\n\n private readonly elementRegistry: ElementRegistry;\n\n private desiredPosition(type: string, source: VcShape, shape: Shape): Point {\n if (type === 'hierarchy') {\n return this.hierarchyPosition(source, shape);\n }\n if (type === 'assignment') {\n return this.assignmentPosition(source, shape);\n }\n return this.sequencePosition(source, shape);\n }\n\n private sequencePosition(source: VcShape, shape: Shape): Point {\n return {\n x: source.x + source.width + SEQUENCE_GAP_X + shape.width / 2,\n y: source.y + source.height / 2,\n };\n }\n\n /** Organizational units sit centered below their step (Wikipedia notation). */\n private assignmentPosition(source: VcShape, shape: Shape): Point {\n return {\n x: source.x + source.width / 2,\n y: source.y + source.height + HIERARCHY_GAP_Y + shape.height / 2,\n };\n }\n\n private hierarchyPosition(source: VcShape, shape: Shape): Point {\n const children = hierarchyChildren(source);\n if (!children.length) {\n return {\n x: source.x + source.width / 2 + TRUNK_CLEARANCE + shape.width / 2,\n y: source.y + source.height + HIERARCHY_GAP_Y + shape.height / 2,\n };\n }\n\n if (isRowArrangement(children, source)) {\n const anchor = rightmost(children)!;\n return {\n x: anchor.x + anchor.width + SIBLING_GAP_X + shape.width / 2,\n y: anchor.y + shape.height / 2,\n };\n }\n\n const anchor = bottommost(children)!;\n return {\n x: anchor.x + shape.width / 2,\n y: anchor.y + anchor.height + SIBLING_GAP_Y + shape.height / 2,\n };\n }\n\n /** Nudges the position downwards until the new shape overlaps no existing step. */\n private deconflict(position: Point, shape: Shape): Point {\n const steps = this.elementRegistry.getAll().filter(isVcShape);\n const candidate = { ...position };\n for (let attempt = 0; attempt < 50; attempt += 1) {\n const bounds = {\n x: candidate.x - shape.width / 2 - DECONFLICT_MARGIN,\n y: candidate.y - shape.height / 2 - DECONFLICT_MARGIN,\n width: shape.width + DECONFLICT_MARGIN * 2,\n height: shape.height + DECONFLICT_MARGIN * 2,\n };\n const conflict = steps.some(\n (step) =>\n step.x < bounds.x + bounds.width &&\n step.x + step.width > bounds.x &&\n step.y < bounds.y + bounds.height &&\n step.y + step.height > bounds.y,\n );\n if (!conflict) {\n break;\n }\n candidate.y += DECONFLICT_STEP_Y;\n }\n return candidate;\n }\n}\n\nfunction rightmost(shapes: Shape[]): Shape | undefined {\n return shapes.reduce<Shape | undefined>(\n (best, shape) => (!best || shape.x + shape.width > best.x + best.width ? shape : best),\n undefined,\n );\n}\n\nfunction bottommost(shapes: Shape[]): Shape | undefined {\n return shapes.reduce<Shape | undefined>(\n (best, shape) => (!best || shape.y + shape.height > best.y + best.height ? shape : best),\n undefined,\n );\n}\n","import type EventBus from 'diagram-js/lib/core/EventBus';\nimport type { Shape } from 'diagram-js/lib/model/Types';\nimport { getMid } from 'diagram-js/lib/layout/LayoutUtil';\n\ninterface ConnectionPreviewLike {\n drawPreview(context: object, canConnect: unknown, hints: object): void;\n cleanUp(context: object): void;\n}\n\ninterface CreateEvent {\n x: number;\n y: number;\n context: {\n source?: Shape;\n shape?: Shape;\n canExecute?: boolean | { connect?: unknown };\n };\n}\n\n/** Drag-append UX: live connection preview from the source while dragging a new step. */\nexport default class VcCreatePreviewBehavior {\n static $inject = ['injector', 'eventBus'];\n\n constructor(injector: { get<T>(name: string, strict: boolean): T | null }, eventBus: EventBus) {\n const connectionPreview = injector.get<ConnectionPreviewLike>('connectionPreview', false);\n if (!connectionPreview) {\n return;\n }\n\n eventBus.on('create.move', (event: CreateEvent) => {\n const { context } = event;\n const source = context.source;\n if (!source) {\n return;\n }\n const canConnect =\n typeof context.canExecute === 'object' ? context.canExecute?.connect : false;\n // noCropping: there is no positioned target shape yet, and cropping against an\n // undefined target would throw inside CroppingConnectionDocking.\n connectionPreview.drawPreview(context, canConnect ?? false, {\n source,\n connectionStart: getMid(source),\n connectionEnd: { x: event.x, y: event.y },\n noCropping: true,\n });\n });\n\n eventBus.on(['create.end', 'create.cancel', 'create.cleanup'], (event: CreateEvent) => {\n connectionPreview.cleanUp(event.context);\n });\n }\n}\n","import type { ModuleDeclaration } from 'didi';\nimport AutoPlaceModule from 'diagram-js/lib/features/auto-place';\nimport CreateModule from 'diagram-js/lib/features/create';\nimport ConnectionPreviewModule from 'diagram-js/lib/features/connection-preview';\nimport VcAppend from './VcAppend.js';\nimport VcAutoPlaceBehavior from './VcAutoPlaceBehavior.js';\nimport VcCreatePreviewBehavior from './VcCreatePreviewBehavior.js';\n\nexport const vcAppendModule: ModuleDeclaration = {\n __depends__: [AutoPlaceModule, CreateModule, ConnectionPreviewModule],\n __init__: ['vcAutoPlaceBehavior', 'vcCreatePreviewBehavior'],\n vcAppend: ['type', VcAppend],\n vcAutoPlaceBehavior: ['type', VcAutoPlaceBehavior],\n vcCreatePreviewBehavior: ['type', VcCreatePreviewBehavior],\n};\n\nexport { default as VcAppend } from './VcAppend.js';\n","/**\n * Inline SVG icons for palette (28px) and context pad (24px) entries. All icons use\n * `currentColor`, so the diagram-js palette/context-pad hover colors apply.\n */\n\nfunction icon(content: string, viewBox = '0 0 24 24'): string {\n return (\n `<svg viewBox=\"${viewBox}\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" ` +\n `stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\">${content}</svg>`\n );\n}\n\n/** Chevron used wherever a step is depicted (matches the canvas shape). */\nconst CHEVRON = 'M3 7 h12 l6 5 -6 5 H3 l4.5 -5 Z';\n\nexport const ICONS = {\n handTool: icon(\n '<path d=\"M18 11V7.5a1.5 1.5 0 0 0-3 0\"/>' +\n '<path d=\"M15 10.5V6a1.5 1.5 0 0 0-3 0v4\"/>' +\n '<path d=\"M12 10V7a1.5 1.5 0 0 0-3 0v6\"/>' +\n '<path d=\"M18 10a1.5 1.5 0 0 1 3 0v4.5a6.5 6.5 0 0 1-6.5 6.5h-1.6c-2.1 0-3.4-.7-4.5-1.8' +\n 'l-3-3a1.5 1.5 0 0 1 2.1-2.1L9 15.5\"/>',\n ),\n lassoTool: icon(\n '<rect x=\"3.5\" y=\"5.5\" width=\"14\" height=\"11\" rx=\"1\" stroke-dasharray=\"3.2 2.4\"/>' +\n '<path d=\"M17.5 16.5 l3.5 3.5 M21 17.5 v2.5 h-2.5\"/>',\n ),\n spaceTool: icon(\n '<path d=\"M12 3.5 v17\" stroke-dasharray=\"3.2 2.4\"/>' +\n '<path d=\"M15 12 h5.5 m-2.5 -2.5 2.5 2.5 -2.5 2.5\"/>' +\n '<path d=\"M9 12 H3.5 m2.5 -2.5 L3.5 12 l2.5 2.5\"/>',\n ),\n globalConnect: icon(\n '<rect x=\"3\" y=\"3.5\" width=\"6\" height=\"5\" rx=\"0.5\"/>' +\n '<rect x=\"15\" y=\"15.5\" width=\"6\" height=\"5\" rx=\"0.5\"/>' +\n '<path d=\"M9.5 9.5 L14.5 14.5 m-4.2 -1 4.2 1 -1 -4.2\" stroke-dasharray=\"2.6 2\"/>',\n ),\n createStep: icon(`<path d=\"${CHEVRON}\"/>`),\n appendStep: icon(\n '<path d=\"M2.5 12 h4.5 m-2 -2 2 2 -2 2\" stroke-dasharray=\"2.6 2\"/>' +\n '<path d=\"M9 7 h8 l4 5 -4 5 H9 l3 -5 Z\"/>',\n ),\n appendSubStep: icon(\n '<path d=\"M7 3 v8.5 h2.5\" />' +\n '<path d=\"M11 7 h7.5 l3 4.5 -3 4.5 H11 l2.5 -4.5 Z\" transform=\"translate(-1.5 0.5)\"/>',\n '0 0 22 22',\n ),\n connectSequence: icon(\n '<path d=\"M4 19 L17.5 5.5\" stroke-dasharray=\"3 2.6\"/><path d=\"M13 5 h5.5 v5.5\" />',\n ),\n connectHierarchy: icon('<path d=\"M6 4 v14 h11.5 m-3.5 -3.5 3.5 3.5 -3.5 3.5\"/>'),\n createOrgUnit: icon('<ellipse cx=\"12\" cy=\"12\" rx=\"9.5\" ry=\"6.5\"/>'),\n appendOrgUnit: icon('<path d=\"M12 3.5 v5\"/><ellipse cx=\"12\" cy=\"15\" rx=\"8.5\" ry=\"5.5\"/>'),\n toggleType: icon(\n '<path d=\"M4.5 9 h13 m-3.2 -3.2 3.2 3.2 -3.2 3.2\"/>' +\n '<path d=\"M19.5 15.5 h-13 m3.2 3.2 -3.2 -3.2 3.2 -3.2\" stroke-dasharray=\"2.8 2.2\"/>',\n ),\n align: icon(\n '<path d=\"M4 3.5 v17\"/><rect x=\"7\" y=\"6\" width=\"12\" height=\"4\" rx=\"0.5\"/>' +\n '<rect x=\"7\" y=\"13.5\" width=\"7.5\" height=\"4\" rx=\"0.5\"/>',\n ),\n color: icon('<path d=\"M12 3.5 c3 4 6 7 6 10.5 a6 6 0 1 1 -12 0 c0 -3.5 3 -6.5 6 -10.5 Z\"/>'),\n trash: icon(\n '<path d=\"M4.5 6.5 h15 M9.5 6 V4.5 h5 V6 M6.5 6.5 l1 13 h9 l1 -13 M10 10 v6 M14 10 v6\"/>',\n ),\n} as const;\n\nexport function paletteEntryHtml(iconSvg: string, title: string, draggable = false): string {\n return (\n `<div class=\"entry vc-palette-entry\"${draggable ? ' draggable=\"true\"' : ''} ` +\n `title=\"${title}\">${iconSvg}</div>`\n );\n}\n\nexport function contextPadEntryHtml(iconSvg: string, title: string, draggable = false): string {\n return (\n `<div class=\"entry vc-cp-entry\"${draggable ? ' draggable=\"true\"' : ''} ` +\n `title=\"${title}\">${iconSvg}</div>`\n );\n}\n","import type Palette from 'diagram-js/lib/features/palette/Palette';\nimport type PaletteProvider from 'diagram-js/lib/features/palette/PaletteProvider';\nimport type Create from 'diagram-js/lib/features/create/Create';\nimport type HandTool from 'diagram-js/lib/features/hand-tool/HandTool';\nimport type LassoTool from 'diagram-js/lib/features/lasso-tool/LassoTool';\nimport type SpaceTool from 'diagram-js/lib/features/space-tool/SpaceTool';\nimport type GlobalConnect from 'diagram-js/lib/features/global-connect/GlobalConnect';\nimport type { Shape } from 'diagram-js/lib/model/Types';\nimport type VcElementFactory from '../model/VcElementFactory.js';\nimport { ICONS, paletteEntryHtml } from '../draw/icons.js';\n\ninterface PaletteEntry {\n group: string;\n html?: string;\n separator?: boolean;\n title?: string;\n action?: Record<string, (event: Event) => void>;\n}\n\n/**\n * bpmn.io-style palette: tools on top (hand, lasso, space, global connect),\n * then the create entries. Tool entry keys must end in `-tool` and use the\n * group `tools` so the active tool gets highlighted.\n */\nexport default class VcPaletteProvider {\n static $inject = [\n 'palette',\n 'create',\n 'vcElementFactory',\n 'handTool',\n 'lassoTool',\n 'spaceTool',\n 'globalConnect',\n ];\n\n constructor(\n palette: Palette,\n private readonly create: Create,\n private readonly factory: VcElementFactory,\n private readonly handTool: HandTool,\n private readonly lassoTool: LassoTool,\n private readonly spaceTool: SpaceTool,\n private readonly globalConnect: GlobalConnect,\n ) {\n palette.registerProvider(this as unknown as PaletteProvider);\n }\n\n getPaletteEntries(): Record<string, PaletteEntry> {\n const startCreateStep = (event: Event): void => {\n this.create.start(event as MouseEvent, this.factory.createNewStep() as Shape);\n };\n const startCreateOrgUnit = (event: Event): void => {\n this.create.start(event as MouseEvent, this.factory.createNewOrgUnit() as Shape);\n };\n\n return {\n 'hand-tool': {\n group: 'tools',\n title: 'Activate hand tool — H',\n html: paletteEntryHtml(ICONS.handTool, 'Activate hand tool'),\n action: { click: (event) => this.handTool.activateHand(event as MouseEvent, false, false) },\n },\n 'lasso-tool': {\n group: 'tools',\n title: 'Activate lasso tool — L',\n html: paletteEntryHtml(ICONS.lassoTool, 'Activate lasso tool'),\n action: { click: (event) => this.lassoTool.activateSelection(event as MouseEvent, false) },\n },\n 'space-tool': {\n group: 'tools',\n title: 'Activate create/remove space tool — S',\n html: paletteEntryHtml(ICONS.spaceTool, 'Activate create/remove space tool'),\n action: {\n click: (event) => this.spaceTool.activateSelection(event as MouseEvent, false, false),\n },\n },\n 'global-connect-tool': {\n group: 'tools',\n title: 'Activate connect tool — C',\n html: paletteEntryHtml(ICONS.globalConnect, 'Activate connect tool'),\n action: { click: (event) => this.globalConnect.start(event as MouseEvent, false) },\n },\n 'tool-separator': {\n group: 'tools',\n separator: true,\n },\n 'create.step': {\n group: 'value-chain',\n title: 'Create step',\n html: paletteEntryHtml(ICONS.createStep, 'Create step', true),\n action: { click: startCreateStep, dragstart: startCreateStep },\n },\n 'create.org-unit': {\n group: 'value-chain',\n title: 'Create organizational unit',\n html: paletteEntryHtml(ICONS.createOrgUnit, 'Create organizational unit', true),\n action: { click: startCreateOrgUnit, dragstart: startCreateOrgUnit },\n },\n };\n }\n}\n","import type { ModuleDeclaration } from 'didi';\nimport PaletteModule from 'diagram-js/lib/features/palette';\nimport CreateModule from 'diagram-js/lib/features/create';\nimport HandToolModule from 'diagram-js/lib/features/hand-tool';\nimport LassoToolModule from 'diagram-js/lib/features/lasso-tool';\nimport SpaceToolModule from 'diagram-js/lib/features/space-tool';\nimport GlobalConnectModule from 'diagram-js/lib/features/global-connect';\nimport VcPaletteProvider from './VcPaletteProvider.js';\n\nexport const vcPaletteModule: ModuleDeclaration = {\n __depends__: [\n PaletteModule,\n CreateModule,\n HandToolModule,\n LassoToolModule,\n SpaceToolModule,\n GlobalConnectModule,\n ],\n __init__: ['vcPaletteProvider'],\n vcPaletteProvider: ['type', VcPaletteProvider],\n};\n\nexport { default as VcPaletteProvider } from './VcPaletteProvider.js';\n","import type PopupMenu from 'diagram-js/lib/features/popup-menu/PopupMenu';\nimport type { Element } from 'diagram-js/lib/model/Types';\nimport { COLOR_OPTIONS, COLORS } from '../draw/styles.js';\nimport { isVcShape } from '../model/di-types.js';\nimport type VcModeling from '../modeling/VcModeling.js';\n\nexport const COLOR_PICKER_PROVIDER_ID = 'vc-color-picker';\n\ninterface PopupMenuEntry {\n label: string;\n group?: string;\n imageHtml?: string;\n action: () => void;\n}\n\nfunction swatch(color: string): string {\n return (\n `<svg viewBox=\"0 0 16 16\" width=\"16\" height=\"16\" aria-hidden=\"true\">` +\n `<rect x=\"1\" y=\"1\" width=\"14\" height=\"14\" rx=\"2\" fill=\"white\" ` +\n `stroke=\"${color}\" stroke-width=\"2\"/></svg>`\n );\n}\n\nexport default class VcColorPickerProvider {\n static $inject = ['popupMenu', 'vcModeling'];\n\n constructor(\n popupMenu: PopupMenu,\n private readonly vcModeling: VcModeling,\n ) {\n popupMenu.registerProvider(COLOR_PICKER_PROVIDER_ID, this);\n }\n\n getPopupMenuEntries(target: Element | Element[]): Record<string, PopupMenuEntry> {\n const element = Array.isArray(target) ? target[0] : target;\n if (!isVcShape(element)) {\n return {};\n }\n\n const entries: Record<string, PopupMenuEntry> = {};\n for (const option of COLOR_OPTIONS) {\n entries[`color-${option.label.toLowerCase()}`] = {\n label: option.label,\n imageHtml: swatch(option.color ?? COLORS.ink),\n action: () => this.vcModeling.setColor(element, option.color),\n };\n }\n return entries;\n }\n}\n","import type PopupMenu from 'diagram-js/lib/features/popup-menu/PopupMenu';\nimport type AlignElements from 'diagram-js/lib/features/align-elements/AlignElements';\nimport type DistributeElements from 'diagram-js/lib/features/distribute-elements/DistributeElements';\nimport type { Element } from 'diagram-js/lib/model/Types';\nimport { isVcShape } from '../model/di-types.js';\n\nexport const ALIGN_MENU_PROVIDER_ID = 'vc-align-elements';\n\ninterface PopupMenuEntry {\n label: string;\n group?: string;\n imageHtml?: string;\n action: () => void;\n}\n\nfunction alignIcon(content: string): string {\n return (\n '<svg viewBox=\"0 0 16 16\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" ' +\n `stroke-width=\"1.3\" stroke-linecap=\"round\" aria-hidden=\"true\">${content}</svg>`\n );\n}\n\nconst ICONS = {\n left: alignIcon(\n '<path d=\"M3 2v12\"/><rect x=\"5\" y=\"4\" width=\"8\" height=\"3\"/><rect x=\"5\" y=\"9\" width=\"5\" height=\"3\"/>',\n ),\n center: alignIcon(\n '<path d=\"M8 2v12\"/><rect x=\"4\" y=\"4\" width=\"8\" height=\"3\"/><rect x=\"5.5\" y=\"9\" width=\"5\" height=\"3\"/>',\n ),\n right: alignIcon(\n '<path d=\"M13 2v12\"/><rect x=\"3\" y=\"4\" width=\"8\" height=\"3\"/><rect x=\"6\" y=\"9\" width=\"5\" height=\"3\"/>',\n ),\n top: alignIcon(\n '<path d=\"M2 3h12\"/><rect x=\"4\" y=\"5\" width=\"3\" height=\"8\"/><rect x=\"9\" y=\"5\" width=\"3\" height=\"5\"/>',\n ),\n middle: alignIcon(\n '<path d=\"M2 8h12\"/><rect x=\"4\" y=\"4\" width=\"3\" height=\"8\"/><rect x=\"9\" y=\"5.5\" width=\"3\" height=\"5\"/>',\n ),\n bottom: alignIcon(\n '<path d=\"M2 13h12\"/><rect x=\"4\" y=\"3\" width=\"3\" height=\"8\"/><rect x=\"9\" y=\"6\" width=\"3\" height=\"5\"/>',\n ),\n horizontal: alignIcon(\n '<rect x=\"2\" y=\"5\" width=\"3\" height=\"6\"/><rect x=\"6.5\" y=\"5\" width=\"3\" height=\"6\"/><rect x=\"11\" y=\"5\" width=\"3\" height=\"6\"/>',\n ),\n vertical: alignIcon(\n '<rect x=\"5\" y=\"2\" width=\"6\" height=\"3\"/><rect x=\"5\" y=\"6.5\" width=\"6\" height=\"3\"/><rect x=\"5\" y=\"11\" width=\"6\" height=\"3\"/>',\n ),\n} as const;\n\n/** Align/distribute menu for multi-selections, opened from the context pad. */\nexport default class VcAlignMenuProvider {\n static $inject = ['popupMenu', 'alignElements', 'distributeElements'];\n\n constructor(\n popupMenu: PopupMenu,\n private readonly alignElements: AlignElements,\n private readonly distributeElements: DistributeElements,\n ) {\n popupMenu.registerProvider(ALIGN_MENU_PROVIDER_ID, this);\n }\n\n getPopupMenuEntries(target: Element | Element[]): Record<string, PopupMenuEntry> {\n const elements = (Array.isArray(target) ? target : [target]).filter(isVcShape) as Element[];\n if (elements.length < 2) {\n return {};\n }\n\n const align = (type: string, label: string, icon: string): PopupMenuEntry => ({\n label,\n group: 'align',\n imageHtml: icon,\n action: () => this.alignElements.trigger(elements, type as never),\n });\n\n const entries: Record<string, PopupMenuEntry> = {\n 'align-left': align('left', 'Align left', ICONS.left),\n 'align-center': align('center', 'Align center', ICONS.center),\n 'align-right': align('right', 'Align right', ICONS.right),\n 'align-top': align('top', 'Align top', ICONS.top),\n 'align-middle': align('middle', 'Align middle', ICONS.middle),\n 'align-bottom': align('bottom', 'Align bottom', ICONS.bottom),\n };\n\n if (elements.length >= 3) {\n entries['distribute-horizontally'] = {\n label: 'Distribute horizontally',\n group: 'distribute',\n imageHtml: ICONS.horizontal,\n action: () => this.distributeElements.trigger(elements, 'horizontal'),\n };\n entries['distribute-vertically'] = {\n label: 'Distribute vertically',\n group: 'distribute',\n imageHtml: ICONS.vertical,\n action: () => this.distributeElements.trigger(elements, 'vertical'),\n };\n }\n\n return entries;\n }\n}\n","import type ContextPad from 'diagram-js/lib/features/context-pad/ContextPad';\nimport type ContextPadProvider from 'diagram-js/lib/features/context-pad/ContextPadProvider';\nimport type Modeling from 'diagram-js/lib/features/modeling/Modeling';\nimport type PopupMenu from 'diagram-js/lib/features/popup-menu/PopupMenu';\nimport type { Element } from 'diagram-js/lib/model/Types';\nimport type { ConnectionType } from '@miragon/value-chain-schema-model';\nimport {\n isOrgUnit,\n isStep,\n isVcConnection,\n isVcShape,\n type VcConnection,\n type VcShape,\n} from '../model/di-types.js';\nimport { contextPadEntryHtml, ICONS } from '../draw/icons.js';\nimport { COLOR_PICKER_PROVIDER_ID } from '../popup/VcColorPickerProvider.js';\nimport { ALIGN_MENU_PROVIDER_ID } from '../popup/VcAlignMenuProvider.js';\nimport type VcAppend from '../append/VcAppend.js';\nimport type VcConnect from '../connect/VcConnect.js';\nimport type VcModeling from '../modeling/VcModeling.js';\n\ninterface ContextPadEntry {\n group: string;\n html?: string;\n title?: string;\n action: Record<string, (event: Event, element?: Element) => void>;\n}\n\ntype Entries = Record<string, ContextPadEntry>;\n\nexport default class VcContextPadProvider {\n static $inject = ['contextPad', 'modeling', 'popupMenu', 'vcAppend', 'vcConnect', 'vcModeling'];\n\n constructor(\n contextPad: ContextPad,\n private readonly modeling: Modeling,\n private readonly popupMenu: PopupMenu,\n private readonly vcAppend: VcAppend,\n private readonly vcConnect: VcConnect,\n private readonly vcModeling: VcModeling,\n ) {\n contextPad.registerProvider(this as unknown as ContextPadProvider);\n }\n\n getContextPadEntries(element: Element): Entries {\n const entries: Entries = {};\n\n if (isStep(element)) {\n this.addStepEntries(entries, element);\n }\n\n if (isOrgUnit(element)) {\n const startConnect = (event: Event): void => {\n this.vcConnect.start(event, element, 'assignment');\n };\n entries['connect.assignment'] = {\n group: 'connect',\n title: 'Connect to step',\n html: contextPadEntryHtml(ICONS.connectHierarchy, 'Connect to step', true),\n action: { click: startConnect, dragstart: startConnect },\n };\n }\n\n if (isVcShape(element)) {\n entries['set-color'] = {\n group: 'edit',\n title: 'Set color',\n html: contextPadEntryHtml(ICONS.color, 'Set color'),\n action: {\n click: (event: Event) => {\n const mouse = event as MouseEvent;\n this.popupMenu.open(element, COLOR_PICKER_PROVIDER_ID, {\n x: mouse.clientX,\n y: mouse.clientY,\n });\n },\n },\n };\n }\n\n if (isVcConnection(element) && element.vcType !== 'assignment') {\n const connection = element as VcConnection;\n const other: ConnectionType = connection.vcType === 'sequence' ? 'hierarchy' : 'sequence';\n entries['toggle-type'] = {\n group: 'edit',\n title: `Switch to \"${other === 'sequence' ? 'is predecessor of' : 'is process-oriented superior'}\"`,\n html: contextPadEntryHtml(ICONS.toggleType, 'Switch relation type'),\n action: { click: () => this.vcModeling.setConnectionType(connection, other) },\n };\n }\n\n if (isVcShape(element) || isVcConnection(element)) {\n entries['delete'] = {\n group: 'edit',\n title: 'Delete',\n html: contextPadEntryHtml(ICONS.trash, 'Delete'),\n action: { click: () => this.modeling.removeElements([element]) },\n };\n }\n\n return entries;\n }\n\n getMultiElementContextPadEntries(elements: Element[]): Entries {\n const entries: Entries = {};\n\n if (elements.filter(isVcShape).length >= 2) {\n entries['align'] = {\n group: 'edit',\n title: 'Align / distribute',\n html: contextPadEntryHtml(ICONS.align, 'Align / distribute'),\n action: {\n click: (event: Event) => {\n const mouse = event as MouseEvent;\n this.popupMenu.open(elements, ALIGN_MENU_PROVIDER_ID, {\n x: mouse.clientX,\n y: mouse.clientY,\n });\n },\n },\n };\n }\n\n entries['delete'] = {\n group: 'edit',\n title: 'Delete',\n html: contextPadEntryHtml(ICONS.trash, 'Delete'),\n action: { click: () => this.modeling.removeElements([...elements]) },\n };\n\n return entries;\n }\n\n private addStepEntries(entries: Entries, shape: VcShape): void {\n const append = (type: ConnectionType) => () => {\n this.vcAppend.append(shape, type);\n };\n const appendDrag = (type: ConnectionType) => (event: Event) => {\n this.vcAppend.startAppendDrag(event, shape, type);\n };\n const connect = (type: ConnectionType) => (event: Event) => {\n this.vcConnect.start(event, shape, type);\n };\n\n entries['append.step'] = {\n group: 'model',\n title: 'Append step (is predecessor of)',\n html: contextPadEntryHtml(ICONS.appendStep, 'Append step (is predecessor of)', true),\n action: { click: append('sequence'), dragstart: appendDrag('sequence') },\n };\n\n entries['append.sub-step'] = {\n group: 'model',\n title: 'Append sub-step (is process-oriented superior)',\n html: contextPadEntryHtml(\n ICONS.appendSubStep,\n 'Append sub-step (is process-oriented superior)',\n true,\n ),\n action: { click: append('hierarchy'), dragstart: appendDrag('hierarchy') },\n };\n\n entries['append.org-unit'] = {\n group: 'model',\n title: 'Append organizational unit',\n html: contextPadEntryHtml(ICONS.appendOrgUnit, 'Append organizational unit', true),\n action: { click: append('assignment'), dragstart: appendDrag('assignment') },\n };\n\n entries['connect.sequence'] = {\n group: 'connect',\n title: 'Connect (is predecessor of)',\n html: contextPadEntryHtml(ICONS.connectSequence, 'Connect (is predecessor of)', true),\n action: { click: connect('sequence'), dragstart: connect('sequence') },\n };\n\n entries['connect.hierarchy'] = {\n group: 'connect',\n title: 'Connect (is process-oriented superior)',\n html: contextPadEntryHtml(\n ICONS.connectHierarchy,\n 'Connect (is process-oriented superior)',\n true,\n ),\n action: { click: connect('hierarchy'), dragstart: connect('hierarchy') },\n };\n }\n}\n","import type { ModuleDeclaration } from 'didi';\nimport ContextPadModule from 'diagram-js/lib/features/context-pad';\nimport PopupMenuModule from 'diagram-js/lib/features/popup-menu';\nimport VcContextPadProvider from './VcContextPadProvider.js';\n\nexport const vcContextPadModule: ModuleDeclaration = {\n __depends__: [ContextPadModule, PopupMenuModule],\n __init__: ['vcContextPadProvider'],\n vcContextPadProvider: ['type', VcContextPadProvider],\n};\n\nexport { default as VcContextPadProvider } from './VcContextPadProvider.js';\n","import type Canvas from 'diagram-js/lib/core/Canvas';\nimport type EventBus from 'diagram-js/lib/core/EventBus';\nimport type { Element } from 'diagram-js/lib/model/Types';\nimport { labelInset } from '../draw/geometry.js';\nimport { FONT, LABEL_PADDING } from '../draw/styles.js';\nimport { isOrgUnit, isVcShape, type VcShape } from '../model/di-types.js';\nimport type VcModeling from '../modeling/VcModeling.js';\n\ninterface DirectEditingLike {\n registerProvider(provider: unknown): void;\n activate(element: Element): void;\n isActive(element?: Element): boolean;\n complete(): void;\n cancel(): void;\n}\n\ninterface EditingContext {\n bounds: { x: number; y: number; width: number; height: number };\n text: string;\n style?: Record<string, string>;\n options?: Record<string, unknown>;\n}\n\n/**\n * In-place label editing via diagram-js-direct-editing, bpmn.io style: double click\n * (or E) opens a centered text box over the chevron's label area; editing commits\n * through the command stack (undoable).\n */\nexport default class VcLabelEditingProvider {\n static $inject = ['directEditing', 'canvas', 'eventBus', 'vcModeling'];\n\n constructor(\n private readonly directEditing: DirectEditingLike,\n private readonly canvas: Canvas,\n eventBus: EventBus,\n private readonly vcModeling: VcModeling,\n ) {\n directEditing.registerProvider(this);\n\n eventBus.on('element.dblclick', (event: { element?: Element }) => {\n if (event.element && isVcShape(event.element)) {\n directEditing.activate(event.element);\n }\n });\n\n // Open editing on freshly appended/created-with-source steps (after the default\n // handlers at priority 1000 have created the shape).\n eventBus.on('autoPlace.end', 500, (event: { shape?: Element }) => {\n if (event.shape && isVcShape(event.shape)) {\n directEditing.activate(event.shape);\n }\n });\n eventBus.on(\n 'create.end',\n 500,\n (event: { context: { source?: Element; shape?: Element; canExecute?: unknown } }) => {\n const { source, shape, canExecute } = event.context;\n if (source && canExecute && shape && isVcShape(shape)) {\n directEditing.activate(shape);\n }\n },\n );\n\n // Interacting elsewhere commits (does not discard) the pending edit.\n eventBus.on(\n [\n 'element.mousedown',\n 'drag.init',\n 'canvas.viewbox.changing',\n 'autoPlace.start',\n 'popupMenu.open',\n ],\n () => {\n if (directEditing.isActive()) {\n directEditing.complete();\n }\n },\n );\n\n // Model changed underneath the editor (undo/redo via chrome or API) — discard the\n // pending edit instead of committing against a possibly removed element.\n eventBus.on(['commandStack.changed', 'diagram.destroy'], () => {\n if (directEditing.isActive()) {\n directEditing.cancel();\n }\n });\n }\n\n activate(element: Element): EditingContext | undefined {\n if (!isVcShape(element)) {\n return undefined;\n }\n const shape = element;\n const bbox = this.canvas.getAbsoluteBBox(shape);\n const zoom = this.canvas.zoom();\n const rawInset = isOrgUnit(shape) ? LABEL_PADDING + 5 : labelInset(shape.width, shape.height);\n const inset = rawInset * zoom;\n\n const bounds = {\n x: bbox.x + inset,\n y: bbox.y,\n width: bbox.width - inset * 2,\n height: bbox.height,\n };\n\n const style = {\n fontFamily: FONT.family,\n fontSize: `${FONT.size * zoom}px`,\n fontWeight: 'normal',\n lineHeight: String(FONT.lineHeight),\n textAlign: 'center',\n };\n\n return {\n bounds,\n style,\n options: { centerVertically: true },\n text: shape.vcLabel || '',\n };\n }\n\n update(element: Element, newText: string): void {\n this.vcModeling.updateLabel(element as VcShape, sanitizeLabel(newText));\n }\n}\n\nfunction sanitizeLabel(text: string): string {\n return text.replace(/\\r\\n?/g, '\\n').trim();\n}\n","import type { ModuleDeclaration } from 'didi';\nimport DirectEditingModule from 'diagram-js-direct-editing';\nimport VcLabelEditingProvider from './VcLabelEditingProvider.js';\n\nexport const vcLabelEditingModule: ModuleDeclaration = {\n __depends__: [DirectEditingModule],\n __init__: ['vcLabelEditingProvider'],\n vcLabelEditingProvider: ['type', VcLabelEditingProvider],\n};\n\nexport { default as VcLabelEditingProvider } from './VcLabelEditingProvider.js';\n","import type { ModuleDeclaration } from 'didi';\nimport PopupMenuModule from 'diagram-js/lib/features/popup-menu';\nimport AlignElementsModule from 'diagram-js/lib/features/align-elements';\nimport DistributeElementsModule from 'diagram-js/lib/features/distribute-elements';\nimport VcColorPickerProvider from './VcColorPickerProvider.js';\nimport VcAlignMenuProvider from './VcAlignMenuProvider.js';\n\nexport const vcColorPickerModule: ModuleDeclaration = {\n __depends__: [PopupMenuModule],\n __init__: ['vcColorPickerProvider'],\n vcColorPickerProvider: ['type', VcColorPickerProvider],\n};\n\nexport const vcAlignMenuModule: ModuleDeclaration = {\n __depends__: [PopupMenuModule, AlignElementsModule, DistributeElementsModule],\n __init__: ['vcAlignMenuProvider'],\n vcAlignMenuProvider: ['type', VcAlignMenuProvider],\n};\n\nexport {\n default as VcColorPickerProvider,\n COLOR_PICKER_PROVIDER_ID,\n} from './VcColorPickerProvider.js';\nexport { default as VcAlignMenuProvider, ALIGN_MENU_PROVIDER_ID } from './VcAlignMenuProvider.js';\n","import KeyboardBindings from 'diagram-js/lib/features/keyboard/KeyboardBindings';\nimport { hasModifier, isKey } from 'diagram-js/lib/features/keyboard/KeyboardUtil';\nimport type Keyboard from 'diagram-js/lib/features/keyboard/Keyboard';\nimport type EditorActions from 'diagram-js/lib/features/editor-actions/EditorActions';\n\ninterface KeyContext {\n keyEvent: KeyboardEvent;\n}\n\n/**\n * Default diagram-js bindings (undo/redo/copy/paste/zoom/delete) plus the bpmn.io\n * single-key tool shortcuts: H hand, L lasso, S space, C connect, E direct editing.\n */\nexport default class VcKeyboardBindings extends KeyboardBindings {\n override registerBindings(keyboard: Keyboard, editorActions: EditorActions): void {\n super.registerBindings(keyboard, editorActions);\n\n const addListener = (action: string, listener: (context: KeyContext) => boolean | void) => {\n if (editorActions.isRegistered(action)) {\n keyboard.addListener(listener as never);\n }\n };\n\n const bindTool = (action: string, keys: string[]): void => {\n addListener(action, (context) => {\n const event = context.keyEvent;\n if (isKey(keys, event) && !hasModifier(event)) {\n editorActions.trigger(action, {});\n return true;\n }\n return undefined as unknown as boolean;\n });\n };\n\n bindTool('handTool', ['h', 'H']);\n bindTool('lassoTool', ['l', 'L']);\n bindTool('spaceTool', ['s', 'S']);\n bindTool('globalConnectTool', ['c', 'C']);\n bindTool('directEditing', ['e', 'E']);\n }\n}\n","import type EventBus from 'diagram-js/lib/core/EventBus';\nimport type EditorActions from 'diagram-js/lib/features/editor-actions/EditorActions';\nimport type { Injector } from 'didi';\nimport type { Element } from 'diagram-js/lib/model/Types';\n\n/** Runs before KeyboardBindings' listener (priority 500) checks registered actions. */\nconst HIGH_PRIORITY = 1500;\n\ninterface ToggleTool {\n toggle(): void;\n}\n\n/** Registers the tool/editing actions the keyboard bindings and app chrome rely on. */\nexport default class VcEditorActions {\n static $inject = ['eventBus', 'injector'];\n\n constructor(eventBus: EventBus, injector: Injector) {\n eventBus.on('editorActions.init', HIGH_PRIORITY, (event: { editorActions: EditorActions }) => {\n const { editorActions } = event;\n\n const register = (name: string, serviceName: string, run: (service: never) => void) => {\n const service = injector.get(serviceName, false);\n if (service) {\n editorActions.register({ [name]: () => run(service as never) });\n }\n };\n\n register('handTool', 'handTool', (tool: ToggleTool) => tool.toggle());\n register('lassoTool', 'lassoTool', (tool: ToggleTool) => tool.toggle());\n register('spaceTool', 'spaceTool', (tool: ToggleTool) => tool.toggle());\n register('globalConnectTool', 'globalConnect', (tool: ToggleTool) => tool.toggle());\n\n const directEditing = injector.get('directEditing', false) as {\n activate(element: Element): void;\n } | null;\n const selection = injector.get('selection', false) as { get(): Element[] } | null;\n if (directEditing && selection) {\n editorActions.register({\n directEditing: () => {\n const selected = selection.get();\n if (selected.length === 1 && selected[0]) {\n directEditing.activate(selected[0]);\n }\n },\n });\n }\n });\n }\n}\n","import type { ModuleDeclaration } from 'didi';\nimport KeyboardModule from 'diagram-js/lib/features/keyboard';\nimport EditorActionsModule from 'diagram-js/lib/features/editor-actions';\nimport VcKeyboardBindings from './VcKeyboardBindings.js';\nimport VcEditorActions from './VcEditorActions.js';\n\n/** Overrides the stock `keyboardBindings` with the bpmn.io-style tool shortcuts. */\nexport const vcKeyboardModule: ModuleDeclaration = {\n __depends__: [KeyboardModule, EditorActionsModule],\n __init__: ['vcEditorActions'],\n keyboardBindings: ['type', VcKeyboardBindings],\n vcEditorActions: ['type', VcEditorActions],\n};\n\nexport { default as VcKeyboardBindings } from './VcKeyboardBindings.js';\nexport { default as VcEditorActions } from './VcEditorActions.js';\n","import OrderingProvider from 'diagram-js/lib/features/ordering/OrderingProvider';\nimport type EventBus from 'diagram-js/lib/core/EventBus';\nimport type { Element, Shape } from 'diagram-js/lib/model/Types';\nimport { isVcConnection } from '../model/di-types.js';\n\n/** Keeps connections behind steps during interactive edits (mirrors the import order). */\nexport default class VcOrderingProvider extends OrderingProvider {\n static override $inject = ['eventBus'];\n\n constructor(eventBus: EventBus) {\n super(eventBus);\n }\n\n override getOrdering(element: Element, newParent: Shape): { parent: Shape; index?: number } {\n if (isVcConnection(element)) {\n const siblings = (newParent.children ?? []) as Element[];\n const index = siblings.filter((child) => child !== element && isVcConnection(child)).length;\n return { parent: newParent, index };\n }\n return { parent: newParent };\n }\n}\n","import type { ModuleDeclaration } from 'didi';\nimport VcOrderingProvider from './VcOrderingProvider.js';\n\nexport const vcOrderingModule: ModuleDeclaration = {\n __init__: ['vcOrderingProvider'],\n vcOrderingProvider: ['type', VcOrderingProvider],\n};\n\nexport { default as VcOrderingProvider } from './VcOrderingProvider.js';\n","import type EventBus from 'diagram-js/lib/core/EventBus';\nimport { isVcConnection, isVcShape } from '../model/di-types.js';\n\ninterface CopyContext {\n descriptor: Record<string, unknown>;\n element: unknown;\n}\n\n/**\n * Copy/paste support: diagram-js turns copy descriptors into element attrs on paste,\n * so carrying the flat domain properties across is all that is needed.\n */\nexport default class VcCopyPasteBehavior {\n static $inject = ['eventBus'];\n\n constructor(eventBus: EventBus) {\n eventBus.on('copyPaste.copyElement', (context: CopyContext) => {\n const { descriptor, element } = context;\n if (isVcShape(element)) {\n descriptor['vcType'] = element.vcType;\n descriptor['vcLabel'] = element.vcLabel;\n if (element.color !== undefined) {\n descriptor['color'] = element.color;\n }\n if (element.link !== undefined) {\n descriptor['link'] = element.link;\n }\n } else if (isVcConnection(element)) {\n descriptor['vcType'] = element.vcType;\n }\n });\n }\n}\n","import type { ModuleDeclaration } from 'didi';\nimport CopyPasteModule from 'diagram-js/lib/features/copy-paste';\nimport VcCopyPasteBehavior from './VcCopyPasteBehavior.js';\n\nexport const vcCopyPasteModule: ModuleDeclaration = {\n __depends__: [CopyPasteModule],\n __init__: ['vcCopyPasteBehavior'],\n vcCopyPasteBehavior: ['type', VcCopyPasteBehavior],\n};\n\nexport { default as VcCopyPasteBehavior } from './VcCopyPasteBehavior.js';\n","import type EventBus from 'diagram-js/lib/core/EventBus';\nimport type { Shape } from 'diagram-js/lib/model/Types';\nimport { MIN_STEP_SIZE } from '@miragon/value-chain-schema-model';\nimport { isVcShape } from '../model/di-types.js';\n\ninterface ResizeStartEvent {\n context: {\n shape?: unknown;\n minDimensions?: { width: number; height: number };\n };\n}\n\n/** Enforces the minimum step size while resizing and while using the space tool. */\nexport default class VcResizeBehavior {\n static $inject = ['eventBus'];\n\n constructor(eventBus: EventBus) {\n eventBus.on('resize.start', (event: ResizeStartEvent) => {\n if (isVcShape(event.context.shape)) {\n event.context.minDimensions = { ...MIN_STEP_SIZE };\n }\n });\n\n eventBus.on(\n 'spaceTool.getMinDimensions',\n (event: { shapes: Shape[] }): Record<string, { width: number; height: number }> => {\n const minDimensions: Record<string, { width: number; height: number }> = {};\n for (const shape of event.shapes) {\n if (isVcShape(shape)) {\n minDimensions[shape.id] = { ...MIN_STEP_SIZE };\n }\n }\n return minDimensions;\n },\n );\n }\n}\n","import type { ModuleDeclaration } from 'didi';\nimport ResizeModule from 'diagram-js/lib/features/resize';\nimport VcResizeBehavior from './VcResizeBehavior.js';\n\nexport const vcResizeModule: ModuleDeclaration = {\n __depends__: [ResizeModule],\n __init__: ['vcResizeBehavior'],\n vcResizeBehavior: ['type', VcResizeBehavior],\n};\n\nexport { default as VcResizeBehavior } from './VcResizeBehavior.js';\n","import type { ModuleDeclaration } from 'didi';\nimport type CommandStack from 'diagram-js/lib/command/CommandStack';\nimport ModelingModule from 'diagram-js/lib/features/modeling';\nimport MoveModule from 'diagram-js/lib/features/move';\nimport OutlineModule from 'diagram-js/lib/features/outline';\nimport BendpointsModule from 'diagram-js/lib/features/bendpoints';\nimport AutoScrollModule from 'diagram-js/lib/features/auto-scroll';\nimport GridSnappingModule from 'diagram-js/lib/features/grid-snapping';\nimport SnappingModule from 'diagram-js/lib/features/snapping';\nimport KeyboardMoveSelectionModule from 'diagram-js/lib/features/keyboard-move-selection';\nimport KeyboardMoveModule from 'diagram-js/lib/navigation/keyboard-move';\nimport { NavigatedViewer } from './NavigatedViewer.js';\nimport { vcModelingModule } from './modeling/index.js';\nimport { vcRulesModule } from './rules/index.js';\nimport { vcConnectModule } from './connect/index.js';\nimport { vcAppendModule } from './append/index.js';\nimport { vcPaletteModule } from './palette/index.js';\nimport { vcContextPadModule } from './context-pad/index.js';\nimport { vcLabelEditingModule } from './label-editing/index.js';\nimport { vcAlignMenuModule, vcColorPickerModule } from './popup/index.js';\nimport { vcKeyboardModule } from './keyboard/index.js';\nimport { vcOrderingModule } from './ordering/index.js';\nimport { vcCopyPasteModule } from './copy-paste/index.js';\nimport { vcResizeModule } from './resize/index.js';\n\n/** The full value chain editor. */\nexport class Modeler extends NavigatedViewer {\n protected override _getModules(): ModuleDeclaration[] {\n return [\n ...super._getModules(),\n // stock diagram-js editing features\n ModelingModule,\n MoveModule,\n OutlineModule,\n BendpointsModule,\n AutoScrollModule,\n GridSnappingModule,\n SnappingModule,\n KeyboardMoveSelectionModule,\n KeyboardMoveModule,\n // value chain specific modules\n vcModelingModule,\n vcRulesModule,\n vcConnectModule,\n vcAppendModule,\n vcPaletteModule,\n vcContextPadModule,\n vcLabelEditingModule,\n vcColorPickerModule,\n vcAlignMenuModule,\n vcKeyboardModule,\n vcOrderingModule,\n vcCopyPasteModule,\n vcResizeModule,\n ];\n }\n\n undo(): void {\n this.get<CommandStack>('commandStack').undo();\n }\n\n redo(): void {\n this.get<CommandStack>('commandStack').redo();\n }\n\n canUndo(): boolean {\n return this.get<CommandStack>('commandStack').canUndo();\n }\n\n canRedo(): boolean {\n return this.get<CommandStack>('commandStack').canRedo();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAS2C,EAAS,GAAkD;CAClE,OAAO,OAAOC,KAAU,cAAYA;AACtC;AAEA,SAAgBC,EAAU,GAAsC;CAC9D,OAAOF,EAASG,CAAO,MAAMA,EAAQC,WAAc,UAAUD,EAAQC,WAAc;AACrF;AAEA,SAAgBC,EAAO,GAA2D;CAChF,OAAOL,EAASG,CAAO,KAAKA,EAAQC,WAAc;AACpD;AAEA,SAAgBE,EAAU,GAA8D;CACtF,OAAON,EAASG,CAAO,KAAKA,EAAQC,WAAc;AACpD;AAEA,SAAgBG,EAAe,GAA2C;CACxE,OACEP,EAASG,CAAO,MACfA,EAAQC,WAAc,cACrBD,EAAQC,WAAc,eACtBD,EAAQC,WAAc,iBACxB,eAAeD;AAEnB;AAEA,SAAgBK,EAAY,GAAqD;CAC/E,OAAON,EAAUC,CAAO,KAAKI,EAAeJ,CAAO;AACrD;;;ACjDA,IAAMM,IAAiB;AAOvB,SAAgBC,EAAQ,GAAgB,GAAmD;CAEzF,IAAMC,IADYC,EAAO,aACV,CAAA,CAAU,cAAc,KAAK;CAC5C,IAAI,CAACD,GACH,MAAU,MAAM,uCAAuC;CAGzD,IAAME,IAAWC,EAAgB,OAAO,CAAC,CAAC,OAAON,CAAW,GACtDO,IAAWF,EAAS,SAASG,EAAQH,CAAQ,IAAI;EAAE,GAAG;EAAG,GAAG;EAAG,OAAO;EAAK,QAAQ;CAAI,GAEvFI,IAAM;EACV,GAAGF,EAAS,IAAIN;EAChB,GAAGM,EAAS,IAAIN;EAChB,OAAOM,EAAS,QAAQ;EACxB,QAAQA,EAAS,SAAS;CAC5B,GAEMG,IAAQP,EAAO,UAAU,EAAI;CAInC,AAHAO,EAAM,aAAa,SAAS,4BAA4B,G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jB,OAAO,KAAK,IAAkB,cAAc,CAAC,CAAC,QAAQ;CACxD;AACF"}
@@ -0,0 +1,16 @@
1
+ import { default as ElementRegistry } from 'diagram-js/lib/core/ElementRegistry';
2
+ import { default as Canvas } from 'diagram-js/lib/core/Canvas';
3
+ import { ValueChainDocument } from '@miragon/value-chain-schema-model';
4
+ /**
5
+ * Rebuilds a schema-model document from the live diagram. The diagram-js element
6
+ * properties are the source of truth; businessObject only backfills fields the UI
7
+ * cannot edit (currently: `link`).
8
+ */
9
+ export default class VcExporter {
10
+ private readonly elementRegistry;
11
+ private readonly canvas;
12
+ static $inject: string[];
13
+ constructor(elementRegistry: ElementRegistry, canvas: Canvas);
14
+ export(): ValueChainDocument;
15
+ }
16
+ //# sourceMappingURL=VcExporter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VcExporter.d.ts","sourceRoot":"","sources":["../../src/io/VcExporter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,eAAe,MAAM,qCAAqC,CAAC;AACvE,OAAO,KAAK,MAAM,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,mCAAmC,CAAC;AAI3C;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IAI3B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAJzB,MAAM,CAAC,OAAO,WAAiC;gBAG5B,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,MAAM;IAGjC,MAAM,IAAI,kBAAkB;CA6D7B"}
@@ -0,0 +1,25 @@
1
+ import { default as Canvas } from 'diagram-js/lib/core/Canvas';
2
+ import { default as ElementFactory } from 'diagram-js/lib/core/ElementFactory';
3
+ import { default as ElementRegistry } from 'diagram-js/lib/core/ElementRegistry';
4
+ import { default as EventBus } from 'diagram-js/lib/core/EventBus';
5
+ import { ValueChainDocument } from '@miragon/value-chain-schema-model';
6
+ import { default as VcElementFactory } from '../model/VcElementFactory.js';
7
+ import { ImportWarning } from './types.js';
8
+ /**
9
+ * Renders a value chain document onto the canvas. Deliberately bypasses the command
10
+ * stack — importing must not create undo entries.
11
+ */
12
+ export default class VcImporter {
13
+ private readonly canvas;
14
+ private readonly elementFactory;
15
+ private readonly vcElementFactory;
16
+ private readonly elementRegistry;
17
+ private readonly eventBus;
18
+ static $inject: string[];
19
+ constructor(canvas: Canvas, elementFactory: ElementFactory, vcElementFactory: VcElementFactory, elementRegistry: ElementRegistry, eventBus: EventBus);
20
+ import(document: ValueChainDocument): ImportWarning[];
21
+ /** Removes all imported elements and document meta, tolerating elements already gone. */
22
+ clear(): void;
23
+ private ensureRoot;
24
+ }
25
+ //# sourceMappingURL=VcImporter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VcImporter.d.ts","sourceRoot":"","sources":["../../src/io/VcImporter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,4BAA4B,CAAC;AACrD,OAAO,KAAK,cAAc,MAAM,oCAAoC,CAAC;AACrE,OAAO,KAAK,eAAe,MAAM,qCAAqC,CAAC;AACvE,OAAO,KAAK,QAAQ,MAAM,8BAA8B,CAAC;AAEzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,KAAK,gBAAgB,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAW,KAAK,aAAa,EAA2B,MAAM,YAAY,CAAC;AAElF;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IAI3B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAP3B,MAAM,CAAC,OAAO,WAAmF;gBAG9E,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,cAAc,EAC9B,gBAAgB,EAAE,gBAAgB,EAClC,eAAe,EAAE,eAAe,EAChC,QAAQ,EAAE,QAAQ;IAGrC,MAAM,CAAC,QAAQ,EAAE,kBAAkB,GAAG,aAAa,EAAE;IAuCrD,yFAAyF;IACzF,KAAK,IAAI,IAAI;IAmBb,OAAO,CAAC,UAAU;CASnB"}
@@ -0,0 +1,8 @@
1
+ import { ModuleDeclaration } from 'didi';
2
+ /** Document import/export between schema-model and the canvas. */
3
+ export declare const ioModule: ModuleDeclaration;
4
+ export { default as VcImporter } from './VcImporter.js';
5
+ export { default as VcExporter } from './VcExporter.js';
6
+ export { saveSVG } from './saveSvg.js';
7
+ export { ROOT_ID, type ImportWarning, type RootBusinessObject } from './types.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/io/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAI9C,kEAAkE;AAClE,eAAO,MAAM,QAAQ,EAAE,iBAGtB,CAAC;AAEF,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { default as Canvas } from 'diagram-js/lib/core/Canvas';
2
+ import { default as ElementRegistry } from 'diagram-js/lib/core/ElementRegistry';
3
+ /**
4
+ * Standalone SVG export: clones the live SVG, sets a viewBox around the diagram
5
+ * contents and strips the pan/zoom transform. Fonts are SVG presentation attributes,
6
+ * so the result renders identically outside the editor.
7
+ */
8
+ export declare function saveSVG(canvas: Canvas, elementRegistry: ElementRegistry): {
9
+ svg: string;
10
+ };
11
+ //# sourceMappingURL=saveSvg.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"saveSvg.d.ts","sourceRoot":"","sources":["../../src/io/saveSvg.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,4BAA4B,CAAC;AACrD,OAAO,KAAK,eAAe,MAAM,qCAAqC,CAAC;AAOvE;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CA8BzF"}
@@ -0,0 +1,10 @@
1
+ export declare const ROOT_ID = "vc-root";
2
+ export interface ImportWarning {
3
+ message: string;
4
+ connectionId?: string;
5
+ }
6
+ /** Document-level metadata kept on the root element while editing. */
7
+ export interface RootBusinessObject {
8
+ name: string;
9
+ }
10
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/io/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,YAAY,CAAC;AAEjC,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,sEAAsE;AACtE,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;CACd"}
@@ -0,0 +1,8 @@
1
+ import { default as EventBus } from 'diagram-js/lib/core/EventBus';
2
+ import { Injector } from 'didi';
3
+ /** Registers the tool/editing actions the keyboard bindings and app chrome rely on. */
4
+ export default class VcEditorActions {
5
+ static $inject: string[];
6
+ constructor(eventBus: EventBus, injector: Injector);
7
+ }
8
+ //# sourceMappingURL=VcEditorActions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VcEditorActions.d.ts","sourceRoot":"","sources":["../../src/keyboard/VcEditorActions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,8BAA8B,CAAC;AAEzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAUrC,uFAAuF;AACvF,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,MAAM,CAAC,OAAO,WAA4B;gBAE9B,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ;CAgCnD"}
@@ -0,0 +1,11 @@
1
+ import { default as KeyboardBindings } from 'diagram-js/lib/features/keyboard/KeyboardBindings';
2
+ import { default as Keyboard } from 'diagram-js/lib/features/keyboard/Keyboard';
3
+ import { default as EditorActions } from 'diagram-js/lib/features/editor-actions/EditorActions';
4
+ /**
5
+ * Default diagram-js bindings (undo/redo/copy/paste/zoom/delete) plus the bpmn.io
6
+ * single-key tool shortcuts: H hand, L lasso, S space, C connect, E direct editing.
7
+ */
8
+ export default class VcKeyboardBindings extends KeyboardBindings {
9
+ registerBindings(keyboard: Keyboard, editorActions: EditorActions): void;
10
+ }
11
+ //# sourceMappingURL=VcKeyboardBindings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VcKeyboardBindings.d.ts","sourceRoot":"","sources":["../../src/keyboard/VcKeyboardBindings.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,mDAAmD,CAAC;AAEjF,OAAO,KAAK,QAAQ,MAAM,2CAA2C,CAAC;AACtE,OAAO,KAAK,aAAa,MAAM,sDAAsD,CAAC;AAMtF;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,gBAAgB;IACrD,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,GAAG,IAAI;CA0BlF"}
@@ -0,0 +1,6 @@
1
+ import { ModuleDeclaration } from 'didi';
2
+ /** Overrides the stock `keyboardBindings` with the bpmn.io-style tool shortcuts. */
3
+ export declare const vcKeyboardModule: ModuleDeclaration;
4
+ export { default as VcKeyboardBindings } from './VcKeyboardBindings.js';
5
+ export { default as VcEditorActions } from './VcEditorActions.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/keyboard/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAM9C,oFAAoF;AACpF,eAAO,MAAM,gBAAgB,EAAE,iBAK9B,CAAC;AAEF,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { default as Canvas } from 'diagram-js/lib/core/Canvas';
2
+ import { default as EventBus } from 'diagram-js/lib/core/EventBus';
3
+ import { Element } from 'diagram-js/lib/model/Types';
4
+ import { default as VcModeling } from '../modeling/VcModeling.js';
5
+ interface DirectEditingLike {
6
+ registerProvider(provider: unknown): void;
7
+ activate(element: Element): void;
8
+ isActive(element?: Element): boolean;
9
+ complete(): void;
10
+ cancel(): void;
11
+ }
12
+ interface EditingContext {
13
+ bounds: {
14
+ x: number;
15
+ y: number;
16
+ width: number;
17
+ height: number;
18
+ };
19
+ text: string;
20
+ style?: Record<string, string>;
21
+ options?: Record<string, unknown>;
22
+ }
23
+ /**
24
+ * In-place label editing via diagram-js-direct-editing, bpmn.io style: double click
25
+ * (or E) opens a centered text box over the chevron's label area; editing commits
26
+ * through the command stack (undoable).
27
+ */
28
+ export default class VcLabelEditingProvider {
29
+ private readonly directEditing;
30
+ private readonly canvas;
31
+ private readonly vcModeling;
32
+ static $inject: string[];
33
+ constructor(directEditing: DirectEditingLike, canvas: Canvas, eventBus: EventBus, vcModeling: VcModeling);
34
+ activate(element: Element): EditingContext | undefined;
35
+ update(element: Element, newText: string): void;
36
+ }
37
+ export {};
38
+ //# sourceMappingURL=VcLabelEditingProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VcLabelEditingProvider.d.ts","sourceRoot":"","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,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;CAGhD"}
@@ -0,0 +1,4 @@
1
+ import { ModuleDeclaration } from 'didi';
2
+ export declare const vcLabelEditingModule: ModuleDeclaration;
3
+ export { default as VcLabelEditingProvider } from './VcLabelEditingProvider.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/label-editing/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAI9C,eAAO,MAAM,oBAAoB,EAAE,iBAIlC,CAAC;AAEF,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,6BAA6B,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { default as ElementFactory } from 'diagram-js/lib/core/ElementFactory';
2
+ import { default as ElementRegistry } from 'diagram-js/lib/core/ElementRegistry';
3
+ import { Connection, Label, Root, Shape } from 'diagram-js/lib/model/Types';
4
+ /**
5
+ * Replaces the stock elementFactory: generated ids are probed against the element
6
+ * registry, so interactively created elements never collide with ids that came in
7
+ * through document import (the stock factory's counter restarts at 0 per instance).
8
+ */
9
+ export default class VcDiagramElementFactory extends ElementFactory {
10
+ private readonly elementRegistry;
11
+ static $inject: string[];
12
+ private readonly counters;
13
+ constructor(elementRegistry: ElementRegistry);
14
+ create(type: 'root', attrs?: Partial<Root>): Root;
15
+ create(type: 'shape', attrs?: Partial<Shape>): Shape;
16
+ create(type: 'connection', attrs?: Partial<Connection>): Connection;
17
+ create(type: 'label', attrs?: Partial<Label>): Label;
18
+ private unusedId;
19
+ }
20
+ //# sourceMappingURL=VcDiagramElementFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VcDiagramElementFactory.d.ts","sourceRoot":"","sources":["../../src/model/VcDiagramElementFactory.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,oCAAoC,CAAC;AAChE,OAAO,KAAK,eAAe,MAAM,qCAAqC,CAAC;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAEjF;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,cAAc;IAKrD,OAAO,CAAC,QAAQ,CAAC,eAAe;IAJ5C,MAAM,CAAC,OAAO,WAAuB;IAErC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6B;gBAEzB,eAAe,EAAE,eAAe;IAIpD,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IACjD,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK;IACpD,MAAM,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU;IACnE,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK;IAkB7D,OAAO,CAAC,QAAQ;CAUjB"}