@miragon/wardley-renderer 0.0.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.
- package/dist/Modeler.d.ts +14 -0
- package/dist/Modeler.d.ts.map +1 -0
- package/dist/NavigatedViewer.d.ts +10 -0
- package/dist/NavigatedViewer.d.ts.map +1 -0
- package/dist/Viewer.d.ts +6 -0
- package/dist/Viewer.d.ts.map +1 -0
- package/dist/WardleyBaseViewer.d.ts +66 -0
- package/dist/WardleyBaseViewer.d.ts.map +1 -0
- package/dist/append/WardleyAppendBehavior.d.ts +15 -0
- package/dist/append/WardleyAppendBehavior.d.ts.map +1 -0
- package/dist/append/index.d.ts +9 -0
- package/dist/append/index.d.ts.map +1 -0
- package/dist/color-picker/WardleyColorPicker.d.ts +23 -0
- package/dist/color-picker/WardleyColorPicker.d.ts.map +1 -0
- package/dist/color-picker/index.d.ts +5 -0
- package/dist/color-picker/index.d.ts.map +1 -0
- package/dist/context-pad/WardleyContextPadProvider.d.ts +28 -0
- package/dist/context-pad/WardleyContextPadProvider.d.ts.map +1 -0
- package/dist/context-pad/index.d.ts +5 -0
- package/dist/context-pad/index.d.ts.map +1 -0
- package/dist/draw/WardleyRenderer.d.ts +23 -0
- package/dist/draw/WardleyRenderer.d.ts.map +1 -0
- package/dist/draw/icons.d.ts +70 -0
- package/dist/draw/icons.d.ts.map +1 -0
- package/dist/draw/index.d.ts +5 -0
- package/dist/draw/index.d.ts.map +1 -0
- package/dist/draw/palette-icons.d.ts +3 -0
- package/dist/draw/palette-icons.d.ts.map +1 -0
- package/dist/draw/styles.d.ts +108 -0
- package/dist/draw/styles.d.ts.map +1 -0
- package/dist/evolution-grid/EvolutionConstraintBehavior.d.ts +16 -0
- package/dist/evolution-grid/EvolutionConstraintBehavior.d.ts.map +1 -0
- package/dist/evolution-grid/EvolutionGrid.d.ts +39 -0
- package/dist/evolution-grid/EvolutionGrid.d.ts.map +1 -0
- package/dist/evolution-grid/index.d.ts +8 -0
- package/dist/evolution-grid/index.d.ts.map +1 -0
- package/dist/evolve/WardleyEvolveDragging.d.ts +21 -0
- package/dist/evolve/WardleyEvolveDragging.d.ts.map +1 -0
- package/dist/evolve/index.d.ts +4 -0
- package/dist/evolve/index.d.ts.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1985 -0
- package/dist/index.js.map +1 -0
- package/dist/io/WardleyExporter.d.ts +19 -0
- package/dist/io/WardleyExporter.d.ts.map +1 -0
- package/dist/io/WardleyImporter.d.ts +27 -0
- package/dist/io/WardleyImporter.d.ts.map +1 -0
- package/dist/io/index.d.ts +8 -0
- package/dist/io/index.d.ts.map +1 -0
- package/dist/io/saveSvg.d.ts +10 -0
- package/dist/io/saveSvg.d.ts.map +1 -0
- package/dist/io/types.d.ts +13 -0
- package/dist/io/types.d.ts.map +1 -0
- package/dist/keyboard/WardleyKeyboard.d.ts +13 -0
- package/dist/keyboard/WardleyKeyboard.d.ts.map +1 -0
- package/dist/keyboard/index.d.ts +5 -0
- package/dist/keyboard/index.d.ts.map +1 -0
- package/dist/label-editing/WardleyLabelEditing.d.ts +22 -0
- package/dist/label-editing/WardleyLabelEditing.d.ts.map +1 -0
- package/dist/label-editing/index.d.ts +5 -0
- package/dist/label-editing/index.d.ts.map +1 -0
- package/dist/model/WardleyElementFactory.d.ts +46 -0
- package/dist/model/WardleyElementFactory.d.ts.map +1 -0
- package/dist/model/di-types.d.ts +47 -0
- package/dist/model/di-types.d.ts.map +1 -0
- package/dist/model/index.d.ts +6 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/modeling/WardleyModeling.d.ts +27 -0
- package/dist/modeling/WardleyModeling.d.ts.map +1 -0
- package/dist/modeling/cmd/UpdatePropertiesHandler.d.ts +18 -0
- package/dist/modeling/cmd/UpdatePropertiesHandler.d.ts.map +1 -0
- package/dist/modeling/index.d.ts +6 -0
- package/dist/modeling/index.d.ts.map +1 -0
- package/dist/palette/WardleyPaletteProvider.d.ts +12 -0
- package/dist/palette/WardleyPaletteProvider.d.ts.map +1 -0
- package/dist/palette/index.d.ts +5 -0
- package/dist/palette/index.d.ts.map +1 -0
- package/dist/pan-constraint/PanConstraint.d.ts +18 -0
- package/dist/pan-constraint/PanConstraint.d.ts.map +1 -0
- package/dist/pan-constraint/index.d.ts +4 -0
- package/dist/pan-constraint/index.d.ts.map +1 -0
- package/dist/popup/WardleyElementSettingsProvider.d.ts +17 -0
- package/dist/popup/WardleyElementSettingsProvider.d.ts.map +1 -0
- package/dist/popup/index.d.ts +5 -0
- package/dist/popup/index.d.ts.map +1 -0
- package/dist/rules/WardleyRules.d.ts +13 -0
- package/dist/rules/WardleyRules.d.ts.map +1 -0
- package/dist/rules/index.d.ts +5 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/snapping/StageSnapping.d.ts +12 -0
- package/dist/snapping/StageSnapping.d.ts.map +1 -0
- package/dist/snapping/index.d.ts +5 -0
- package/dist/snapping/index.d.ts.map +1 -0
- package/dist/wardley.css +2 -0
- package/package.json +43 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/draw/styles.ts","../src/io/saveSvg.ts","../src/io/types.ts","../src/WardleyBaseViewer.ts","../src/model/WardleyElementFactory.ts","../src/model/di-types.ts","../src/model/index.ts","../src/evolution-grid/EvolutionGrid.ts","../src/evolution-grid/EvolutionConstraintBehavior.ts","../src/evolution-grid/index.ts","../src/draw/icons.ts","../src/draw/WardleyRenderer.ts","../src/draw/index.ts","../src/io/WardleyImporter.ts","../src/io/WardleyExporter.ts","../src/io/index.ts","../src/Viewer.ts","../src/pan-constraint/PanConstraint.ts","../src/pan-constraint/index.ts","../src/NavigatedViewer.ts","../src/modeling/cmd/UpdatePropertiesHandler.ts","../src/modeling/WardleyModeling.ts","../src/modeling/index.ts","../src/rules/WardleyRules.ts","../src/rules/index.ts","../src/snapping/StageSnapping.ts","../src/snapping/index.ts","../src/draw/palette-icons.ts","../src/palette/WardleyPaletteProvider.ts","../src/palette/index.ts","../src/popup/WardleyElementSettingsProvider.ts","../src/popup/index.ts","../src/context-pad/WardleyContextPadProvider.ts","../src/context-pad/index.ts","../src/label-editing/WardleyLabelEditing.ts","../src/label-editing/index.ts","../src/keyboard/WardleyKeyboard.ts","../src/keyboard/index.ts","../src/evolve/WardleyEvolveDragging.ts","../src/evolve/index.ts","../src/append/WardleyAppendBehavior.ts","../src/append/index.ts","../src/color-picker/WardleyColorPicker.ts","../src/color-picker/index.ts","../src/Modeler.ts"],"sourcesContent":["/** Default plot area in diagram px (interior without axis margins). Changeable at runtime via config.size. */\nexport const PLOT = {\n width: 1080,\n height: 680,\n marginLeft: 66,\n marginTop: 38,\n marginRight: 44,\n marginBottom: 58,\n} as const;\n\nexport const PLOT_MIN = { width: 480, height: 320 } as const;\n\nexport const NODE_SIZE = 34;\nexport const COMPONENT_RADIUS = 15;\n/** Inner ring for \"evolving\" (intermediate-event look). */\nexport const COMPONENT_INNER_RADIUS = 12;\nexport const ANCHOR_ICON_SIZE = 26;\nexport const PIPELINE_HEIGHT = 30;\n\nexport const NOTE_LINE_HEIGHT = 17;\nconst NOTE_PAD_X = 8;\nconst NOTE_PAD_Y = 6;\n// Rough, deliberately slightly generous character width (13px Spline Sans) — the hitbox should cover\n// the text reliably (better a bit too wide than too narrow). No DOM measurement -> deterministic\n// (holds for import/export/headless too).\nconst NOTE_CHAR_W = 7.5;\n\n/**\n * Box dimensions of a note from its (possibly multi-line) text. The note shape grows as large as\n * its text -> the move/click hitbox grows with it (instead of a fixed 34px). Minimum = NODE_SIZE.\n */\nexport function noteMetrics(label: string): { lines: string[]; width: number; height: number } {\n const lines = (label && label.length ? label : 'note').split('\\n');\n const maxLen = Math.max(1, ...lines.map((l) => l.length));\n return {\n lines,\n width: Math.max(NODE_SIZE, Math.round(maxLen * NOTE_CHAR_W) + NOTE_PAD_X * 2),\n height: Math.max(NODE_SIZE, lines.length * NOTE_LINE_HEIGHT + NOTE_PAD_Y * 2),\n };\n}\n\nexport const COLORS = {\n paper: '#fbfaf7',\n ink: '#1b1b1a',\n inkSoft: '#3a3a37',\n axis: '#cdc7bb',\n axisText: '#8c8475',\n grid: '#ebe7de',\n band: 'rgba(27,27,26,0.022)',\n stroke: '#1b1b1a',\n componentFill: '#ffffff',\n anchorFill: '#1b1b1a',\n dependency: '#a9a296',\n accent: '#0e7c74',\n accentSoft: 'rgba(14,124,116,0.12)',\n flow: '#0e7c74',\n movement: '#bf2f2a',\n inertia: '#1b1b1a',\n noteText: '#4a4640',\n pipeline: '#1b1b1a',\n} as const;\n\n/**\n * Note color palette (bpmn.io-style mini picker; deliberately NOT a full color picker). Values are\n * hex and are rendered 1:1 as CSS color, or serialized in the DSL as `(color …)`.\n * Convention (also used in the Wardley-mapping skill): green = good, red = problem/risk,\n * amber = watch, blue = info, purple = idea, slate = neutral.\n */\nexport const NOTE_COLORS = [\n { id: 'green', name: 'Green · good', value: '#15803d' },\n { id: 'amber', name: 'Amber · watch', value: '#b45309' },\n { id: 'red', name: 'Red · problem', value: '#b91c1c' },\n { id: 'blue', name: 'Blue · info', value: '#1d4ed8' },\n { id: 'teal', name: 'Teal', value: '#0e7c74' },\n { id: 'purple', name: 'Purple · idea', value: '#7e22ce' },\n { id: 'pink', name: 'Pink', value: '#be185d' },\n { id: 'slate', name: 'Slate · neutral', value: '#475569' },\n] as const;\n\n/** Colors of the attitude regions per kind (shared by renderer + palette icons). */\nexport const ATTITUDE_COLORS: Record<string, { fill: string; stroke: string }> = {\n pioneers: { fill: 'rgba(14,124,116,0.07)', stroke: '#0e7c74' },\n settlers: { fill: 'rgba(180,131,30,0.08)', stroke: '#b4831e' },\n townplanners: { fill: 'rgba(120,53,170,0.07)', stroke: '#7835aa' },\n};\n\nexport const FONT = {\n /**\n * Set as the `font-family` attribute DIRECTLY on all SVG text elements (canvas labels,\n * axis/stage text and consequently the SVG export too) – not inherited from a CSS container.\n * In EVERY context it reaches for the self-hosted 'Spline Sans Variable' if the consumer provides\n * it; otherwise (e.g. an export SVG opened standalone) it falls back safely to a system sans.\n * The library does NOT ship the font – consumers must include it themselves\n * (e.g. via @fontsource-variable/spline-sans), see README.\n */\n family:\n \"'Spline Sans Variable', 'Spline Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif\",\n label: 13,\n axis: 12,\n stage: 12,\n} as const;\n","import type Canvas from 'diagram-js/lib/core/Canvas';\nimport { PLOT } from '../draw/styles.js';\n\n/**\n * Serializes the current canvas into standalone SVG (snapshot/export).\n * Sets a fixed viewBox to the outer plot bounds so the result is independent of the\n * current zoom/scroll.\n */\nexport function saveSVG(canvas: Canvas): { svg: string } {\n const container = canvas.getContainer();\n const source = container.querySelector('svg');\n if (!source) throw new Error('No SVG found in the canvas container.');\n\n const clone = source.cloneNode(true) as SVGSVGElement;\n\n const width = PLOT.marginLeft + PLOT.width + PLOT.marginRight;\n const height = PLOT.marginTop + PLOT.height + PLOT.marginBottom;\n clone.setAttribute('xmlns', 'http://www.w3.org/2000/svg');\n clone.setAttribute('viewBox', `0 0 ${width} ${height}`);\n clone.setAttribute('width', String(width));\n clone.setAttribute('height', String(height));\n\n // diagram-js sets a viewbox transform on the outermost layer; for the static export we\n // neutralize pan/zoom by letting the viewBox (above) determine the geometry.\n const viewport = clone.querySelector<SVGGElement>('.viewport');\n if (viewport) viewport.removeAttribute('transform');\n\n const svg = new XMLSerializer().serializeToString(clone);\n return { svg: '<?xml version=\"1.0\" encoding=\"utf-8\"?>\\n' + svg };\n}\n","import type { MapConfig } from '@miragon/wardley-schema-model';\n\n/** ID of the diagram-js root element of the Wardley map. */\nexport const ROOT_ID = 'wardley-root';\n\nexport interface ImportWarning {\n readonly message: string;\n readonly elementId?: string;\n}\n\n/** Map metadata stored on the root element (config + lossless passthrough). */\nexport interface RootBusinessObject {\n readonly config: MapConfig;\n readonly rawPassthrough?: readonly string[];\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 EventBus from 'diagram-js/lib/core/EventBus';\nimport type { Root } from 'diagram-js/lib/model/Types';\nimport type { MapConfig, WardleyMap } from '@miragon/wardley-schema-model';\nimport { parseDSL, serializeDSL } from '@miragon/wardley-dsl';\nimport { saveSVG } from './io/saveSvg.js';\nimport type WardleyImporter from './io/WardleyImporter.js';\nimport type WardleyExporter from './io/WardleyExporter.js';\nimport type EvolutionGrid from './evolution-grid/EvolutionGrid.js';\nimport { ROOT_ID, type ImportWarning, type RootBusinessObject } from './io/types.js';\n\nexport interface WardleyViewerOptions {\n /** Host element. If missing, a detached <div> is created (can be attached 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, §12). */\n additionalModules?: ModuleDeclaration[];\n}\n\nexport type EventCallback<T = unknown> = (event: T) => void;\n\nfunction sizeToCss(value: number | string): string {\n return typeof value === 'number' ? `${value}px` : value;\n}\n\n/**\n * Shared lifecycle & DI bootstrap for all Wardley viewers (analogous to bpmn-js BaseViewer, but OUR\n * OWN code — no bpmn-js as a dependency, §3.3). Subclasses only override `_getModules()` (a method\n * rather than a field, to sidestep the constructor/field initialization order). `attachTo`/`detach`\n * are own implementations (not a diagram-js primitive, §6.1).\n */\nexport abstract class WardleyBaseViewer {\n protected abstract _getModules(): ModuleDeclaration[];\n\n private _diagram: Diagram | undefined;\n private readonly _container: HTMLElement;\n private readonly _options: WardleyViewerOptions;\n\n constructor(options: WardleyViewerOptions = {}) {\n this._options = options;\n this._container = this._createContainer(options);\n }\n\n private _createContainer(options: WardleyViewerOptions): HTMLElement {\n const container = options.container ?? document.createElement('div');\n container.classList.add('wardley-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 get<T>(name: string): T {\n return this._ensureDiagram().get<T>(name);\n }\n\n on<T = unknown>(event: string, callback: EventCallback<T>, priority = 1000): void {\n this.get<EventBus>('eventBus').on(event, priority, callback as EventCallback);\n }\n\n off(event: string, callback: EventCallback): void {\n this.get<EventBus>('eventBus').off(event, callback);\n }\n\n /** Load a model into the canvas (replaces existing content). */\n async importMap(map: WardleyMap): Promise<{ warnings: ImportWarning[] }> {\n const diagram = this._ensureDiagram();\n const eventBus = diagram.get<EventBus>('eventBus');\n const importer = diagram.get<WardleyImporter>('wardleyImporter');\n importer.clear();\n const warnings = importer.import(map);\n eventBus.fire('import.done', { warnings });\n return { warnings };\n }\n\n async importDSL(text: string): Promise<{ warnings: ImportWarning[] }> {\n const eventBus = this._ensureDiagram().get<EventBus>('eventBus');\n eventBus.fire('import.parse.start', { text });\n const map = parseDSL(text);\n eventBus.fire('import.parse.done', { map });\n return this.importMap(map);\n }\n\n /** Current state as the canonical model (from the DI properties). */\n exportMap(): WardleyMap {\n return this.get<WardleyExporter>('wardleyExporter').export();\n }\n\n /**\n * Changes the map's logical plot size (in diagram-px) and re-projects all elements.\n * Sets `config.size` and re-imports the current state (normalized coordinates stay the truth).\n */\n async setMapSize(width: number, height: number): Promise<{ warnings: ImportWarning[] }> {\n const map = this.exportMap();\n return this.importMap({ ...map, config: { ...map.config, size: { width, height } } });\n }\n\n /**\n * Sets the four X-axis stage labels (`undefined` = default Genesis/Custom/Product/Commodity).\n * Changes only the labeling, not the geometry: updates the map config in-place and re-renders only\n * the axis background (no re-import -> no view jump, no selection loss). Fires\n * `wardley.config.changed` for consumers' URL/persistence sync.\n */\n setEvolutionLabels(labels: readonly [string, string, string, string] | undefined): void {\n const canvas = this.get<Canvas>('canvas');\n let root: (Root & { businessObject?: RootBusinessObject }) | undefined;\n try {\n root = canvas.getRootElement() as Root & { businessObject?: RootBusinessObject };\n } catch {\n return; // nothing imported yet -> nothing to configure\n }\n if (!root || root.id !== ROOT_ID) return;\n\n const current = root.businessObject?.config ?? { title: 'Untitled Map' };\n const { evolutionLabels: _drop, ...rest } = current;\n const config: MapConfig = labels ? { ...rest, evolutionLabels: labels } : rest;\n root.businessObject = { ...root.businessObject, config };\n\n const grid = this.get<EvolutionGrid>('evolutionGrid');\n grid.configure(config);\n grid.render();\n this.get<EventBus>('eventBus').fire('wardley.config.changed', { config });\n }\n\n exportDSL(): string {\n return serializeDSL(this.exportMap());\n }\n\n /** Static, standalone SVG. */\n async saveSVG(): Promise<{ svg: string }> {\n return saveSVG(this.get<Canvas>('canvas'));\n }\n\n /** Own implementation (not a diagram-js primitive): attach the container to `target`. */\n attachTo(target: HTMLElement): void {\n target.appendChild(this._container);\n this.get<Canvas>('canvas').resized();\n }\n\n /** Own implementation: detach the container from the DOM, keeping state. */\n detach(): void {\n this._container.remove();\n }\n\n clear(): void {\n this._ensureDiagram().clear();\n }\n\n destroy(): void {\n if (this._diagram) {\n this._diagram.destroy();\n this._diagram = undefined;\n }\n this._container.remove();\n }\n\n get container(): HTMLElement {\n return this._container;\n }\n}\n","import type ElementFactory from 'diagram-js/lib/core/ElementFactory';\nimport type ElementRegistry from 'diagram-js/lib/core/ElementRegistry';\nimport type {\n AcceleratorDirection,\n AcceleratorElement,\n AnchorElement,\n AnnotationElement,\n AttitudeElement,\n AttitudeKind,\n ComponentElement,\n MapEdge,\n NoteElement,\n PipelineElement,\n SubmapElement,\n} from '@miragon/wardley-schema-model';\nimport type EvolutionGrid from '../evolution-grid/EvolutionGrid.js';\nimport { NODE_SIZE, PIPELINE_HEIGHT, noteMetrics } from '../draw/styles.js';\nimport type { WardleyConnection, WardleyShape } from './di-types.js';\n\nexport interface CreateNewExtra {\n attitudeKind?: AttitudeKind;\n acceleratorDirection?: AcceleratorDirection;\n annotationNumber?: number;\n market?: boolean;\n ecosystem?: boolean;\n}\n\n/**\n * Creates diagram-js runtime elements with Wardley markers. Projects normalized coordinates to\n * pixels via the SINGLE math source (EvolutionGrid, P7).\n */\nexport default class WardleyElementFactory {\n static $inject = ['elementFactory', 'evolutionGrid', 'elementRegistry'];\n\n constructor(\n private readonly elementFactory: ElementFactory,\n private readonly grid: EvolutionGrid,\n private readonly elementRegistry: ElementRegistry,\n ) {}\n\n /**\n * Returns a unique label: `base`, otherwise `base 2`, `base 3`, … Unique labels are mandatory\n * because the OWM DSL references elements BY THEIR NAME — duplicate names would cause ID\n * collisions on serialize/re-import and lose edges (lines).\n *\n * @param excludeId optional ID of the element currently being renamed (does NOT count its own\n * current name as a collision — otherwise every rename would add a suffix).\n */\n uniqueLabel(base: string, excludeId?: string): string {\n const taken = new Set<string>();\n for (const el of this.elementRegistry.getAll()) {\n if (excludeId && el.id === excludeId) continue;\n const lbl = (el as { wardleyLabel?: unknown }).wardleyLabel;\n if (typeof lbl === 'string') taken.add(lbl);\n }\n if (!taken.has(base)) return base;\n let i = 2;\n while (taken.has(`${base} ${i}`)) i++;\n return `${base} ${i}`;\n }\n\n createComponent(el: ComponentElement): WardleyShape {\n return this.node(\n 'component',\n el.id,\n el.label,\n el.position.visibility,\n el.position.evolution,\n el,\n {\n ...(el.decorators ? { decorators: el.decorators } : {}),\n ...(el.movement ? { movement: el.movement } : {}),\n },\n );\n }\n\n createAnchor(el: AnchorElement): WardleyShape {\n return this.node('anchor', el.id, el.label, el.position.visibility, el.position.evolution, el);\n }\n\n createNote(el: NoteElement): WardleyShape {\n // Note box grows with the (possibly multiline) text -> move/click hitbox covers the text.\n // Centered on the position (consistent with the center back-calculation on move).\n const { width, height } = noteMetrics(el.label);\n const center = this.grid.toCanvas(el.position);\n const shape = this.elementFactory.createShape({\n id: el.id,\n x: center.x - width / 2,\n y: center.y - height / 2,\n width,\n height,\n wardleyType: 'note',\n wardleyLabel: el.label,\n evolution: el.position.evolution,\n visibility: el.position.visibility,\n businessObject: el,\n ...(el.color ? { color: el.color } : {}),\n });\n return shape as unknown as WardleyShape;\n }\n\n createPipeline(el: PipelineElement): WardleyShape {\n const start = this.grid.toCanvas({\n visibility: el.position.visibility,\n evolution: el.evolutionStart,\n });\n const end = this.grid.toCanvas({\n visibility: el.position.visibility,\n evolution: el.evolutionEnd,\n });\n const width = Math.max(end.x - start.x, 2);\n const shape = this.elementFactory.createShape({\n id: el.id,\n x: start.x,\n y: start.y - PIPELINE_HEIGHT / 2,\n width,\n height: PIPELINE_HEIGHT,\n wardleyType: 'pipeline',\n wardleyLabel: el.label,\n evolution: el.position.evolution,\n visibility: el.position.visibility,\n evolutionStart: el.evolutionStart,\n evolutionEnd: el.evolutionEnd,\n // Frame: only the border is clickable -> inner clicks reach the nodes (diagram-js isFrame).\n isFrame: true,\n businessObject: el,\n });\n return shape as unknown as WardleyShape;\n }\n\n createAnnotation(el: AnnotationElement): WardleyShape {\n const pos = el.positions[0] ?? el.position;\n return this.node('annotation', el.id, el.text, pos.visibility, pos.evolution, el, {\n annotationNumber: el.number,\n });\n }\n\n createAccelerator(el: AcceleratorElement): WardleyShape {\n return this.node(\n 'accelerator',\n el.id,\n el.label,\n el.position.visibility,\n el.position.evolution,\n el,\n {\n acceleratorDirection: el.direction,\n },\n );\n }\n\n createAttitude(el: AttitudeElement): WardleyShape {\n // OWM: position = anchor point (top left), width/height in px.\n const anchor = this.grid.toCanvas(el.position);\n const shape = this.elementFactory.createShape({\n id: el.id,\n x: anchor.x,\n y: anchor.y,\n width: Math.max(el.width, 4),\n height: Math.max(el.height, 4),\n wardleyType: 'attitude',\n wardleyLabel: el.label || el.kind,\n attitudeKind: el.kind,\n evolution: el.position.evolution,\n visibility: el.position.visibility,\n isFrame: true,\n businessObject: el,\n });\n return shape as unknown as WardleyShape;\n }\n\n createSubmap(el: SubmapElement): WardleyShape {\n return this.node('submap', el.id, el.label, el.position.visibility, el.position.evolution, el);\n }\n\n createNew(\n type: WardleyShape['wardleyType'],\n rawLabel: string,\n extra: CreateNewExtra = {},\n ): WardleyShape {\n // Enforce a unique label -> lossless DSL round-trip (see uniqueLabel).\n const label = this.uniqueLabel(rawLabel);\n if (type === 'pipeline') {\n const shape = this.elementFactory.createShape({\n width: 200,\n height: PIPELINE_HEIGHT,\n wardleyType: 'pipeline',\n wardleyLabel: label,\n evolution: 0.5,\n visibility: 0.5,\n evolutionStart: 0.4,\n evolutionEnd: 0.6,\n isFrame: true,\n });\n return shape as unknown as WardleyShape;\n }\n if (type === 'attitude') {\n const shape = this.elementFactory.createShape({\n width: 180,\n height: 48,\n wardleyType: 'attitude',\n wardleyLabel: label,\n attitudeKind: extra.attitudeKind ?? 'pioneers',\n evolution: 0.5,\n visibility: 0.5,\n isFrame: true,\n });\n return shape as unknown as WardleyShape;\n }\n if (type === 'note') {\n const { width, height } = noteMetrics(label);\n const shape = this.elementFactory.createShape({\n width,\n height,\n wardleyType: 'note',\n wardleyLabel: label,\n evolution: 0.5,\n visibility: 0.5,\n });\n return shape as unknown as WardleyShape;\n }\n const decorators = extra.market\n ? { market: true }\n : extra.ecosystem\n ? { ecosystem: true }\n : undefined;\n const shape = this.elementFactory.createShape({\n width: NODE_SIZE,\n height: NODE_SIZE,\n wardleyType: type,\n wardleyLabel: label,\n evolution: 0.5,\n visibility: 0.5,\n ...(extra.acceleratorDirection ? { acceleratorDirection: extra.acceleratorDirection } : {}),\n ...(extra.annotationNumber !== undefined ? { annotationNumber: extra.annotationNumber } : {}),\n ...(decorators ? { decorators } : {}),\n });\n return shape as unknown as WardleyShape;\n }\n\n createDependency(edge: MapEdge, source: WardleyShape, target: WardleyShape): WardleyConnection {\n return this.connection('dependency', edge, source, target);\n }\n\n createFlow(edge: MapEdge, source: WardleyShape, target: WardleyShape): WardleyConnection {\n const bidirectional = edge.edgeType === 'flow' && edge.bidirectional === true;\n return this.connection('flow', edge, source, target, bidirectional);\n }\n\n private node(\n type: WardleyShape['wardleyType'],\n id: string,\n label: string,\n visibility: number,\n evolution: number,\n businessObject: WardleyShape['businessObject'],\n extra: Partial<WardleyShape> = {},\n ): WardleyShape {\n const center = this.grid.toCanvas({ visibility, evolution });\n const shape = this.elementFactory.createShape({\n id,\n x: center.x - NODE_SIZE / 2,\n y: center.y - NODE_SIZE / 2,\n width: NODE_SIZE,\n height: NODE_SIZE,\n wardleyType: type,\n wardleyLabel: label,\n evolution,\n visibility,\n businessObject,\n ...extra,\n });\n return shape as unknown as WardleyShape;\n }\n\n private connection(\n type: WardleyConnection['wardleyType'],\n edge: MapEdge,\n source: WardleyShape,\n target: WardleyShape,\n bidirectional = false,\n ): WardleyConnection {\n const flowValue = edge.edgeType === 'flow' ? edge.flowValue : undefined;\n const conn = this.elementFactory.createConnection({\n id: edge.id,\n source,\n target,\n waypoints: [centerOf(source), centerOf(target)],\n wardleyType: type,\n bidirectional,\n ...(flowValue ? { flowValue } : {}),\n ...(edge.label ? { linkLabel: edge.label } : {}),\n businessObject: edge,\n });\n return conn as unknown as WardleyConnection;\n }\n}\n\nfunction centerOf(shape: WardleyShape): { x: number; y: number } {\n return { x: shape.x + shape.width / 2, y: shape.y + shape.height / 2 };\n}\n","import type { Shape, Connection } from 'diagram-js/lib/model/Types';\nimport type {\n AcceleratorDirection,\n AttitudeKind,\n ComponentDecorators,\n MapEdge,\n MapElement,\n Movement,\n} from '@miragon/wardley-schema-model';\n\n/**\n * diagram-js runtime model with Wardley extensions.\n *\n * The positional truth while editing is `evolution`/`visibility` (normalized), NOT `x`/`y` (pixels)\n * and NOT the `businessObject` (concept doc §2.2, §5.6).\n * `businessObject` is the identity/metadata backref to the original model element.\n */\n\nexport type WardleyShapeType =\n | 'component'\n | 'anchor'\n | 'pipeline'\n | 'note'\n | 'annotation'\n | 'attitude'\n | 'submap'\n | 'accelerator';\n\nexport type WardleyConnectionType = 'dependency' | 'flow';\n\nexport interface WardleyShape extends Shape {\n wardleyType: WardleyShapeType;\n /** normalized [0,1] — runtime truth of the X position. */\n evolution: number;\n /** normalized [0,1] — runtime truth of the Y position. */\n visibility: number;\n /** Display text (separate from diagram-js `label`, which references a label element). */\n wardleyLabel: string;\n decorators?: ComponentDecorators;\n movement?: Movement;\n /** pipeline only: evolution range. */\n evolutionStart?: number;\n evolutionEnd?: number;\n /** annotation only. */\n annotationNumber?: number;\n /** attitude region only. */\n attitudeKind?: AttitudeKind;\n /** accelerator only. */\n acceleratorDirection?: AcceleratorDirection;\n /** note only: optional color (CSS color/hex from NOTE_COLORS). */\n color?: string;\n businessObject?: MapElement;\n}\n\nexport interface WardleyConnection extends Connection {\n wardleyType: WardleyConnectionType;\n bidirectional?: boolean;\n flowValue?: string;\n /** annotation text after `;` (e.g. \"limited by\"). */\n linkLabel?: string;\n businessObject?: MapEdge;\n}\n\nfunction isObject(el: unknown): el is Record<string, unknown> {\n return typeof el === 'object' && el !== null;\n}\n\nexport function isWardleyShape(el: unknown): el is WardleyShape {\n return isObject(el) && typeof el['wardleyType'] === 'string' && 'evolution' in el;\n}\n\nexport function isWardleyConnection(el: unknown): el is WardleyConnection {\n return isObject(el) && typeof el['wardleyType'] === 'string' && 'waypoints' in el;\n}\n\nexport function isComponent(el: unknown): el is WardleyShape {\n return isWardleyShape(el) && el.wardleyType === 'component';\n}\n\nexport function isPipeline(el: unknown): el is WardleyShape {\n return isWardleyShape(el) && el.wardleyType === 'pipeline';\n}\n","import type { ModuleDeclaration } from 'didi';\nimport WardleyElementFactory from './WardleyElementFactory.js';\n\n/** Custom ElementFactory with Wardley defaults and pixel projection. */\nexport const wardleyModelModule: ModuleDeclaration = {\n wardleyElementFactory: ['type', WardleyElementFactory],\n};\n\nexport { default as WardleyElementFactory } from './WardleyElementFactory.js';\nexport * from './di-types.js';\n","import {\n append as svgAppend,\n create as svgCreate,\n attr as svgAttr,\n clear as svgClear,\n} from 'tiny-svg';\nimport {\n evolutionStage,\n DEFAULT_STAGE_BOUNDARIES,\n DEFAULT_EVOLUTION_LABELS,\n type Coordinate,\n type EvolutionStage,\n type MapConfig,\n} from '@miragon/wardley-schema-model';\nimport type Canvas from 'diagram-js/lib/core/Canvas';\nimport type { Point } from 'diagram-js/lib/util/Types';\nimport { PLOT, PLOT_MIN, COLORS, FONT } from '../draw/styles.js';\n\nconst AXES_LAYER = 'wardley-axes';\n\nfunction clamp01(n: number): number {\n return n < 0 ? 0 : n > 1 ? 1 : n;\n}\n\n/**\n * Holds the SINGLE pixel<->normalized transform (guiding principle P7) and renders the\n * non-interactive axis/grid background into its own diagram-js layer (z below the\n * elements). The plot size is changeable at runtime via `config.size` (\"scale map\").\n */\nexport default class EvolutionGrid {\n static $inject = ['canvas'];\n\n private boundaries: readonly [number, number, number] = DEFAULT_STAGE_BOUNDARIES;\n private labels: readonly [string, string, string, string] = DEFAULT_EVOLUTION_LABELS;\n private yAxisLabel = 'Value Chain';\n private plotWidth: number = PLOT.width;\n private plotHeight: number = PLOT.height;\n\n constructor(private readonly canvas: Canvas) {}\n\n configure(config: MapConfig): void {\n this.boundaries = config.stageBoundaries ?? DEFAULT_STAGE_BOUNDARIES;\n this.labels = config.evolutionLabels ?? DEFAULT_EVOLUTION_LABELS;\n this.yAxisLabel = config.yAxisLabel ?? 'Value Chain';\n this.plotWidth = Math.max(config.size?.width ?? PLOT.width, PLOT_MIN.width);\n this.plotHeight = Math.max(config.size?.height ?? PLOT.height, PLOT_MIN.height);\n }\n\n /** Normalized -> diagram px (center of the node). */\n toCanvas(coord: Coordinate): Point {\n return {\n x: PLOT.marginLeft + coord.evolution * this.plotWidth,\n y: PLOT.marginTop + (1 - coord.visibility) * this.plotHeight,\n };\n }\n\n /** diagram px -> normalized, clamped to [0,1]. */\n fromCanvas(point: Point): Coordinate {\n return {\n evolution: clamp01((point.x - PLOT.marginLeft) / this.plotWidth),\n visibility: clamp01(1 - (point.y - PLOT.marginTop) / this.plotHeight),\n };\n }\n\n stageOf(evolution: number): EvolutionStage {\n return evolutionStage(evolution, this.boundaries);\n }\n\n /** The three stage boundaries (evolution values) — for snapping. */\n getBoundaries(): readonly [number, number, number] {\n return this.boundaries;\n }\n\n getPlotSize(): { width: number; height: number } {\n return { width: this.plotWidth, height: this.plotHeight };\n }\n\n /** Outer bounds including margins (for the initial viewbox). */\n outerBounds(): { x: number; y: number; width: number; height: number } {\n return {\n x: 0,\n y: 0,\n width: PLOT.marginLeft + this.plotWidth + PLOT.marginRight,\n height: PLOT.marginTop + this.plotHeight + PLOT.marginBottom,\n };\n }\n\n render(): void {\n const layer = this.canvas.getLayer(AXES_LAYER, -1);\n svgClear(layer);\n\n const left = PLOT.marginLeft;\n const top = PLOT.marginTop;\n const right = left + this.plotWidth;\n const bottom = top + this.plotHeight;\n\n svgAppend(\n layer,\n rect(left, top, this.plotWidth, this.plotHeight, { fill: '#ffffff', stroke: COLORS.grid }),\n );\n\n const edges = [0, ...this.boundaries, 1];\n for (let i = 0; i < 4; i++) {\n const x0 = left + edges[i]! * this.plotWidth;\n const x1 = left + edges[i + 1]! * this.plotWidth;\n if (i % 2 === 1) {\n svgAppend(\n layer,\n rect(x0, top, x1 - x0, this.plotHeight, { fill: COLORS.band, stroke: 'none' }),\n );\n }\n if (i > 0) {\n svgAppend(\n layer,\n line(x0, top, x0, bottom, { stroke: COLORS.grid, 'stroke-dasharray': '3 5' }),\n );\n }\n const midX = (x0 + x1) / 2;\n svgAppend(\n layer,\n text(this.labels[i]!.toUpperCase(), midX, bottom + 18, {\n 'text-anchor': 'middle',\n 'font-size': FONT.stage,\n 'letter-spacing': '0.08em',\n fill: COLORS.axisText,\n }),\n );\n }\n\n svgAppend(layer, line(left, bottom, right + 10, bottom, { stroke: COLORS.axis }));\n svgAppend(layer, arrowHead(right + 10, bottom, 'right'));\n svgAppend(\n layer,\n text('Evolution', right + 6, bottom + 38, {\n 'text-anchor': 'end',\n 'font-size': FONT.axis,\n fill: COLORS.axisText,\n 'font-style': 'italic',\n }),\n );\n\n svgAppend(layer, line(left, bottom, left, top - 10, { stroke: COLORS.axis }));\n svgAppend(layer, arrowHead(left, top - 10, 'up'));\n const yLabel = text(this.yAxisLabel, 0, 0, {\n 'text-anchor': 'middle',\n 'font-size': FONT.axis,\n fill: COLORS.axisText,\n 'font-style': 'italic',\n });\n svgAttr(yLabel, { transform: `translate(${left - 46}, ${(top + bottom) / 2}) rotate(-90)` });\n svgAppend(layer, yLabel);\n\n svgAppend(\n layer,\n text('visible', left - 10, top + 11, {\n 'text-anchor': 'end',\n 'font-size': FONT.stage,\n fill: COLORS.axisText,\n }),\n );\n svgAppend(\n layer,\n text('invisible', left - 10, bottom - 2, {\n 'text-anchor': 'end',\n 'font-size': FONT.stage,\n fill: COLORS.axisText,\n }),\n );\n }\n}\n\ntype Attrs = Record<string, string | number>;\n\nfunction rect(x: number, y: number, w: number, h: number, attrs: Attrs): SVGElement {\n return svgAttr(svgCreate('rect'), { x, y, width: w, height: h, 'stroke-width': 1, ...attrs });\n}\n\nfunction line(x1: number, y1: number, x2: number, y2: number, attrs: Attrs): SVGElement {\n return svgAttr(svgCreate('line'), { x1, y1, x2, y2, 'stroke-width': 1, ...attrs });\n}\n\nfunction text(content: string, x: number, y: number, attrs: Attrs): SVGElement {\n const el = svgAttr(svgCreate('text'), { x, y, 'font-family': FONT.family, ...attrs });\n el.textContent = content;\n return el;\n}\n\nfunction arrowHead(x: number, y: number, dir: 'right' | 'up'): SVGElement {\n const s = 5;\n const points =\n dir === 'right'\n ? `${x - s},${y - s} ${x + 2},${y} ${x - s},${y + s}`\n : `${x - s},${y + s} ${x},${y - 2} ${x + s},${y + s}`;\n return svgAttr(svgCreate('polygon'), { points, fill: COLORS.axis });\n}\n","import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';\nimport type EventBus from 'diagram-js/lib/core/EventBus';\nimport { isWardleyShape, type WardleyShape } from '../model/di-types.js';\nimport type EvolutionGrid from './EvolutionGrid.js';\n\nconst MOVE_COMMANDS = [\n 'shape.move',\n 'shape.create',\n 'shape.resize',\n 'elements.move',\n 'elements.create',\n];\n\ninterface CommandContextLike {\n shape?: unknown;\n shapes?: unknown[];\n elements?: unknown[];\n}\n\n/**\n * After every geometry change (move/create/resize), keeps the normalized Wardley coordinates\n * in sync with the pixel geometry — in BOTH directions (postExecuted AND reverted), so that undo/redo\n * stays consistent (concept doc §5.3). `EvolutionGrid` is the single source of math (P7).\n */\nexport default class EvolutionConstraintBehavior extends CommandInterceptor {\n static override $inject = ['eventBus', 'evolutionGrid'];\n\n constructor(\n eventBus: EventBus,\n private readonly grid: EvolutionGrid,\n ) {\n super(eventBus);\n const sync = (event: { context?: CommandContextLike }) => this.syncAll(event.context);\n this.postExecuted(MOVE_COMMANDS, sync);\n this.reverted(MOVE_COMMANDS, sync);\n }\n\n private syncAll(context: CommandContextLike | undefined): void {\n if (!context) return;\n const candidates: unknown[] = [\n ...(context.shape ? [context.shape] : []),\n ...(context.shapes ?? []),\n ...(context.elements ?? []),\n ];\n for (const c of candidates) {\n if (isWardleyShape(c)) this.syncFromGeometry(c);\n }\n }\n\n private syncFromGeometry(shape: WardleyShape): void {\n const cy = shape.y + shape.height / 2;\n if (shape.wardleyType === 'pipeline') {\n const start = this.grid.fromCanvas({ x: shape.x, y: cy });\n const end = this.grid.fromCanvas({ x: shape.x + shape.width, y: cy });\n shape.evolutionStart = start.evolution;\n shape.evolutionEnd = Math.max(end.evolution, start.evolution + 0.001);\n shape.evolution = (shape.evolutionStart + shape.evolutionEnd) / 2;\n shape.visibility = start.visibility;\n return;\n }\n if (shape.wardleyType === 'attitude') {\n // Attitude position = anchor point (top left), matching the OWM semantics.\n const tl = this.grid.fromCanvas({ x: shape.x, y: shape.y });\n shape.evolution = tl.evolution;\n shape.visibility = tl.visibility;\n return;\n }\n const coord = this.grid.fromCanvas({ x: shape.x + shape.width / 2, y: cy });\n shape.evolution = coord.evolution;\n shape.visibility = coord.visibility;\n }\n}\n","import type { ModuleDeclaration } from 'didi';\nimport EvolutionGrid from './EvolutionGrid.js';\nimport EvolutionConstraintBehavior from './EvolutionConstraintBehavior.js';\n\n/** Axis background + single pixel<->normalized math (P7). */\nexport const evolutionGridModule: ModuleDeclaration = {\n evolutionGrid: ['type', EvolutionGrid],\n};\n\n/** Keeps normalized coordinates in sync with the geometry (editor-only). */\nexport const evolutionConstraintModule: ModuleDeclaration = {\n __init__: ['evolutionConstraintBehavior'],\n __depends__: [evolutionGridModule],\n evolutionConstraintBehavior: ['type', EvolutionConstraintBehavior],\n};\n\nexport { default as EvolutionGrid } from './EvolutionGrid.js';\nexport { default as EvolutionConstraintBehavior } from './EvolutionConstraintBehavior.js';\n","import { append as svgAppend, attr as svgAttr, create as svgCreate } from 'tiny-svg';\n\n/**\n * Embedded icon paths from Google Material Icons (Apache-2.0, © Google).\n * 24x24-viewBox paths. `drawIcon` renders them as SVG (renderer), `iconMarkup` as an HTML string\n * (palette/context pad/buttons) with `fill: currentColor` (color controllable via CSS).\n * Source: https://github.com/google/material-design-icons (Apache License 2.0).\n */\n\nexport const ICON_PERSON =\n 'M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z';\nexport const ICON_GROUP =\n 'M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z';\n\n/** radio_button_unchecked — ring (component / event). */\nexport const ICON_CIRCLE =\n 'M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z';\nexport const ICON_ARROW_FORWARD = 'M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z';\n/** double_arrow — evolve. */\nexport const ICON_DOUBLE_ARROW = 'M15.5 5H11l5 7-5 7h4.5l5-7zM8.5 5H4l5 7-5 7h4.5l5-7z';\n/** block — inertia (resistance to change). */\nexport const ICON_BLOCK =\n 'M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8 0-1.85.63-3.55 1.69-4.9L16.9 18.31C15.55 19.37 13.85 20 12 20zm6.31-3.1L7.1 5.69C8.45 4.63 10.15 4 12 4c4.42 0 8 3.58 8 8 0 1.85-.63 3.55-1.69 4.9z';\nexport const ICON_EDIT =\n 'M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z';\nexport const ICON_DELETE =\n 'M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z';\n/** close — remove evolve. */\nexport const ICON_CLOSE =\n 'M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z';\n/** description — note. */\nexport const ICON_NOTE =\n 'M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z';\nexport const ICON_UNDO =\n 'M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z';\nexport const ICON_REDO =\n 'M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z';\n/** data_object — JSON. */\nexport const ICON_DATA_OBJECT =\n 'M4 7v2c0 .55-.45 1-1 1H2v2h1c.55 0 1 .45 1 1v2c0 1.65 1.35 3 3 3h1v-2H7c-.55 0-1-.45-1-1v-2c0-.84-.35-1.61-.92-2.18L4.85 12l.23-.82C5.65 10.61 6 9.84 6 9V7c0-.55.45-1 1-1h1V4H7C5.35 4 4 5.35 4 7zm16 3c-.55 0-1-.45-1-1V7c0-1.65-1.35-3-3-3h-1v2h1c.55 0 1 .45 1 1v2c0 .84.35 1.61.92 2.18l.23.82-.23.82c-.57.57-.92 1.34-.92 2.18v2c0 .55-.45 1-1 1h-1v2h1c1.65 0 3-1.35 3-3v-2c0-.55.45-1 1-1h1v-2h-1z';\n/** code — DSL. */\nexport const ICON_CODE =\n 'M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z';\n/** download — Export. */\nexport const ICON_DOWNLOAD = 'M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z';\n/** share — share link. */\nexport const ICON_SHARE =\n 'M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81 1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9c-1.66 0-3 1.34-3 3s1.34 3 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.16c-.05.21-.08.43-.08.65 0 1.61 1.31 2.92 2.92 2.92s2.92-1.31 2.92-2.92-1.31-2.92-2.92-2.92z';\n/** storefront — market decorator. */\nexport const ICON_STOREFRONT =\n 'M21.9 8.89l-1.05-4.37c-.22-.9-1-1.52-1.91-1.52H5.05c-.9 0-1.69.63-1.9 1.52L2.1 8.89c-.24 1.02-.02 2.06.62 2.88.08.11.19.19.28.29V19c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-6.94c.09-.09.2-.18.28-.28.64-.82.87-1.87.62-2.89zM13 5h1.96l.54 3.52c.09.62-.39 1.18-.99 1.18-.65 0-1.18-.55-1.18-1.18V5zm-5.5 0h1.5v3.52C9 9.32 8.45 10 7.7 10c-.62 0-1.13-.49-1.21-1.13L7.5 5zm-3 .49C5.42 5.36 5.53 5 5.89 5H7.5l-.5 3.69c-.08.6-.59 1.06-1.19 1.06-.66 0-1.18-.56-1.18-1.18l.07-.6L4.5 5.49zM19 19H5v-6.03c.08.01.15.03.23.03.85 0 1.62-.35 2.19-.91.58.57 1.36.91 2.24.91.85 0 1.61-.35 2.18-.89.58.55 1.36.89 2.24.89.81 0 1.59-.34 2.17-.9.58.56 1.35.9 2.2.9.08 0 .15-.02.23-.03V19z';\n/** public — ecosystem decorator. */\nexport const ICON_PUBLIC =\n 'M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.94-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z';\n/** folder_open — open file. */\nexport const ICON_FOLDER_OPEN =\n 'M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z';\n/** image — PNG/image. */\nexport const ICON_IMAGE =\n 'M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z';\n/** note_add — new / clear. */\nexport const ICON_NEW =\n 'M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 14h-3v3h-2v-3H8v-2h3v-3h2v3h3v2zm-3-7V3.5L18.5 9H13z';\n/** settings — gear (element settings / popup). */\nexport const ICON_SETTINGS =\n 'M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z';\n/** palette — note color. */\nexport const ICON_PALETTE =\n 'M12 2C6.49 2 2 6.49 2 12s4.49 10 10 10c1.38 0 2.5-1.12 2.5-2.5 0-.61-.23-1.2-.64-1.67-.08-.1-.13-.21-.13-.33 0-.28.22-.5.5-.5H16c3.31 0 6-2.69 6-6 0-4.96-4.49-9-10-9zm-5.5 9c-.83 0-1.5-.67-1.5-1.5S5.67 8 6.5 8 8 8.67 8 9.5 7.33 11 6.5 11zm3-4C8.67 7 8 6.33 8 5.5S8.67 4 9.5 4s1.5.67 1.5 1.5S10.33 7 9.5 7zm5 0c-.83 0-1.5-.67-1.5-1.5S13.67 4 14.5 4s1.5.67 1.5 1.5S15.33 7 14.5 7zm3 4c-.83 0-1.5-.67-1.5-1.5S16.67 8 17.5 8s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z';\n/** place — annotation (marker). */\nexport const ICON_PLACE =\n 'M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z';\n/** fast_forward — Accelerator. */\nexport const ICON_FAST_FORWARD = 'M4 18l8.5-6L4 6v12zm9-12v12l8.5-6L13 6z';\n/** fast_rewind — Deaccelerator. */\nexport const ICON_FAST_REWIND = 'M11 18V6l-8.5 6 8.5 6zm.5-6l8.5 6V6l-8.5 6z';\n/** crop_landscape — attitude band (PST). */\nexport const ICON_CROP_LANDSCAPE =\n 'M19 5H5c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 12H5V7h14v10z';\n/** layers — submap (nested map). */\nexport const ICON_LAYERS =\n 'M11.99 18.54l-7.37-5.73L3 14.07l9 7 9-7-1.63-1.27-7.38 5.74zM12 16l7.36-5.73L21 9l-9-7-9 7 1.63 1.27L12 16z';\n/** autorenew — cycle procurement method (build/buy/outsource). */\nexport const ICON_AUTORENEW =\n 'M12 6v3l4-4-4-4v3c-4.42 0-8 3.58-8 8 0 1.57.46 3.03 1.24 4.26L6.7 14.8c-.45-.83-.7-1.79-.7-2.8 0-3.31 2.69-6 6-6zm6.76 1.74L17.3 9.2c.44.84.7 1.79.7 2.8 0 3.31-2.69 6-6 6v-3l-4 4 4 4v-3c4.42 0 8-3.58 8-8 0-1.57-.46-3.03-1.24-4.26z';\n/** aspect_ratio — map size. */\nexport const ICON_ASPECT_RATIO =\n 'M19 12h-2v3h-3v2h5v-5zM7 9h3V7H5v5h2V9zm14-6H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16.01H3V4.99h18v14.02z';\n/** menu — hamburger (main menu). */\nexport const ICON_MENU = 'M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z';\n/** add — append component. */\nexport const ICON_ADD = 'M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z';\n/** visibility — eye (show example). */\nexport const ICON_VISIBILITY =\n 'M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z';\n\n/** Draws a 24x24 icon as an SVG group centered on (cx, cy), scaled to `size`. */\nexport function drawIcon(\n path: string,\n cx: number,\n cy: number,\n size: number,\n fill: string,\n): SVGElement {\n const g = svgCreate('g');\n const s = size / 24;\n svgAttr(g, {\n transform: `translate(${cx - size / 2}, ${cy - size / 2}) scale(${s})`,\n fill,\n stroke: 'none',\n });\n svgAppend(g, svgAttr(svgCreate('path'), { d: path }));\n return g;\n}\n\n/** Returns an icon as an HTML SVG string (for palette/context pad/buttons), color = currentColor. */\nexport function iconMarkup(path: string, size = 18): string {\n return `<svg viewBox=\"0 0 24 24\" width=\"${size}\" height=\"${size}\" fill=\"currentColor\" aria-hidden=\"true\"><path d=\"${path}\"/></svg>`;\n}\n","import BaseRenderer from 'diagram-js/lib/draw/BaseRenderer';\nimport { append as svgAppend, create as svgCreate, attr as svgAttr } from 'tiny-svg';\nimport type EventBus from 'diagram-js/lib/core/EventBus';\nimport type { ElementLike, ShapeLike, ConnectionLike } from 'diagram-js/lib/model/Types';\nimport type { Point } from 'diagram-js/lib/util/Types';\nimport {\n COLORS,\n FONT,\n COMPONENT_RADIUS,\n COMPONENT_INNER_RADIUS,\n ANCHOR_ICON_SIZE,\n ATTITUDE_COLORS,\n NOTE_LINE_HEIGHT,\n} from './styles.js';\nimport { drawIcon, ICON_PERSON } from './icons.js';\nimport {\n isWardleyConnection,\n isWardleyShape,\n type WardleyConnection,\n type WardleyShape,\n} from '../model/di-types.js';\nimport type EvolutionGrid from '../evolution-grid/EvolutionGrid.js';\n\n/** BaseRenderer default is 1000; 1500 wins the render.shape/render.connection event. */\nconst WARDLEY_RENDER_PRIORITY = 1500;\n\ntype Attrs = Record<string, string | number>;\n\nexport default class WardleyRenderer extends BaseRenderer {\n static $inject = ['eventBus', 'evolutionGrid'];\n\n constructor(\n eventBus: EventBus,\n private readonly grid: EvolutionGrid,\n ) {\n super(eventBus, WARDLEY_RENDER_PRIORITY);\n }\n\n override canRender(element: ElementLike): boolean {\n return isWardleyShape(element) || isWardleyConnection(element);\n }\n\n override drawShape(visuals: SVGElement, element: ShapeLike): SVGElement {\n const shape = element as unknown as WardleyShape;\n switch (shape.wardleyType) {\n case 'pipeline':\n return this.drawPipeline(visuals, shape);\n case 'anchor':\n return this.drawAnchor(visuals, shape);\n case 'note':\n return this.drawNote(visuals, shape);\n case 'attitude':\n return this.drawAttitude(visuals, shape);\n case 'annotation':\n return this.drawAnnotation(visuals, shape);\n case 'accelerator':\n return this.drawAccelerator(visuals, shape);\n case 'submap':\n return this.drawSubmap(visuals, shape);\n case 'component':\n default:\n return this.drawComponent(visuals, shape);\n }\n }\n\n override drawConnection(visuals: SVGElement, element: ConnectionLike): SVGElement {\n const conn = element as unknown as WardleyConnection;\n const isFlow = conn.wardleyType === 'flow';\n const color = isFlow ? COLORS.flow : COLORS.dependency;\n const [start, end] = endpoints(conn);\n\n const path = svgAttr(svgCreate('polyline'), {\n points: `${start.x},${start.y} ${end.x},${end.y}`,\n fill: 'none',\n stroke: color,\n 'stroke-width': isFlow ? 2.5 : 1.5,\n 'stroke-linecap': 'round',\n });\n svgAppend(visuals, path);\n\n // BPMN-style arrowhead at the target (both line types); for bidirectional flow also at the source.\n svgAppend(visuals, connectionArrow(start, end, color, isFlow ? 11 : 9, isFlow ? 5 : 4));\n if (isFlow && conn.bidirectional) {\n svgAppend(visuals, connectionArrow(end, start, color, 11, 5));\n }\n const mx = (start.x + end.x) / 2;\n const my = (start.y + end.y) / 2;\n if (isFlow && conn.flowValue) {\n svgAppend(\n visuals,\n label(conn.flowValue, mx, my - 5, {\n 'text-anchor': 'middle',\n 'font-size': 11,\n fill: COLORS.flow,\n }),\n );\n }\n // Link annotation (`; …`) at the midpoint (a bit lower if a flow value is also present).\n if (conn.linkLabel) {\n svgAppend(\n visuals,\n label(conn.linkLabel, mx, my + (conn.flowValue ? 12 : -4), {\n 'text-anchor': 'middle',\n 'font-size': 11,\n 'font-style': 'italic',\n fill: COLORS.axisText,\n }),\n );\n }\n return path;\n }\n\n override getShapePath(shape: ShapeLike): string {\n const { x, y, width, height } = shape;\n return `M${x},${y}l${width},0l0,${height}l${-width},0z`;\n }\n\n override getConnectionPath(connection: ConnectionLike): string {\n const [first, ...rest] = connection.waypoints;\n if (!first) return '';\n return `M${first.x},${first.y}` + rest.map((p: Point) => `L${p.x},${p.y}`).join('');\n }\n\n private drawComponent(visuals: SVGElement, shape: WardleyShape): SVGElement {\n const cx = shape.width / 2;\n const cy = shape.height / 2;\n const evolving = !!shape.movement;\n const dec = shape.decorators;\n\n // Planned evolution: red arrow to the target event circle (pixel delta via the single source of math).\n if (shape.movement) {\n const here = this.grid.toCanvas({ visibility: shape.visibility, evolution: shape.evolution });\n const there = this.grid.toCanvas({\n visibility: shape.visibility,\n evolution: shape.movement.targetEvolution,\n });\n const dx = there.x - here.x;\n svgAppend(\n visuals,\n line(cx, cy, cx + dx, cy, { stroke: COLORS.movement, 'stroke-width': 1.5 }),\n );\n svgAppend(visuals, connectionArrow({ x: cx, y: cy }, { x: cx + dx, y: cy }, COLORS.movement));\n // Target circle = direct drag handle: marked by class so the evolve module can intercept a\n // mousedown on it and let the target be moved by dragging (see WardleyEvolveDragging).\n svgAppend(\n visuals,\n circle(cx + dx, cy, COMPONENT_RADIUS, {\n fill: COLORS.paper,\n stroke: COLORS.movement,\n 'stroke-width': 2,\n class: 'wardley-evolve-handle',\n }),\n );\n }\n\n if (dec?.inertia) {\n const bx = cx + COMPONENT_RADIUS + 3;\n svgAppend(\n visuals,\n line(bx, cy - 13, bx, cy + 13, {\n stroke: COLORS.inertia,\n 'stroke-width': 3,\n 'stroke-linecap': 'round',\n }),\n );\n }\n\n const ring = circle(cx, cy, COMPONENT_RADIUS, {\n fill: COLORS.componentFill,\n stroke: COLORS.stroke,\n 'stroke-width': 2,\n });\n svgAppend(visuals, ring);\n\n // \"evolving\" = double ring (echoing the BPMN intermediate event).\n if (evolving) {\n svgAppend(\n visuals,\n circle(cx, cy, COMPONENT_INNER_RADIUS, {\n fill: 'none',\n stroke: COLORS.stroke,\n 'stroke-width': 1.5,\n }),\n );\n }\n\n // Market/ecosystem as an inner symbol (event-icon idiom).\n if (dec?.ecosystem) {\n svgAppend(\n visuals,\n circle(cx, cy, 4.5, { fill: 'none', stroke: COLORS.stroke, 'stroke-width': 1.5 }),\n );\n } else if (dec?.market) {\n svgAppend(visuals, circle(cx, cy, 3, { fill: COLORS.stroke }));\n }\n\n svgAppend(\n visuals,\n label(shape.wardleyLabel, cx + COMPONENT_RADIUS + 7, cy - 4, { 'font-weight': '500' }),\n );\n if (dec?.method) {\n svgAppend(\n visuals,\n label(dec.method, cx + COMPONENT_RADIUS + 7, cy + 11, {\n 'font-size': 10.5,\n fill: COLORS.axisText,\n }),\n );\n }\n return ring;\n }\n\n private drawAnchor(visuals: SVGElement, shape: WardleyShape): SVGElement {\n const cx = shape.width / 2;\n const cy = shape.height / 2;\n const icon = drawIcon(ICON_PERSON, cx, cy, ANCHOR_ICON_SIZE, COLORS.ink);\n svgAppend(visuals, icon);\n svgAppend(\n visuals,\n label(shape.wardleyLabel, cx, cy - ANCHOR_ICON_SIZE / 2 - 4, {\n 'text-anchor': 'middle',\n 'font-weight': '700',\n }),\n );\n return icon;\n }\n\n private drawPipeline(visuals: SVGElement, shape: WardleyShape): SVGElement {\n const box = svgAttr(svgCreate('rect'), {\n x: 0,\n y: 0,\n width: Math.max(shape.width, 1),\n height: Math.max(shape.height, 1),\n rx: 4,\n fill: COLORS.accentSoft,\n stroke: COLORS.pipeline,\n 'stroke-width': 1.25,\n 'stroke-dasharray': '6 3',\n });\n svgAppend(visuals, box);\n svgAppend(visuals, label(shape.wardleyLabel, 4, -6, { 'font-weight': '500' }));\n return box;\n }\n\n private drawNote(visuals: SVGElement, shape: WardleyShape): SVGElement {\n const color = shape.color;\n const lines = (shape.wardleyLabel ?? '').split('\\n');\n const cx = shape.width / 2;\n // Center the block of lines vertically in the box (+4 ~ baseline offset for 13px).\n const y0 = shape.height / 2 - ((lines.length - 1) * NOTE_LINE_HEIGHT) / 2 + 4;\n const attrs = {\n 'text-anchor': 'middle',\n fill: color ?? COLORS.noteText,\n 'font-style': 'italic',\n // Colored notes are slightly bolder -> feedback (good/bad) stands out.\n ...(color ? { 'font-weight': '600' } : {}),\n };\n let first: SVGElement | undefined;\n lines.forEach((line, i) => {\n const el = label(line, cx, y0 + i * NOTE_LINE_HEIGHT, attrs);\n svgAppend(visuals, el);\n if (!first) first = el;\n });\n return first ?? svgCreate('text');\n }\n\n private drawAttitude(visuals: SVGElement, shape: WardleyShape): SVGElement {\n const c = ATTITUDE_COLORS[shape.attitudeKind ?? 'pioneers'] ?? {\n fill: 'rgba(0,0,0,0.05)',\n stroke: '#666666',\n };\n const box = svgAttr(svgCreate('rect'), {\n x: 0,\n y: 0,\n width: Math.max(shape.width, 1),\n height: Math.max(shape.height, 1),\n rx: 10,\n fill: c.fill,\n stroke: c.stroke,\n 'stroke-width': 1.25,\n 'stroke-dasharray': '5 4',\n });\n svgAppend(visuals, box);\n svgAppend(\n visuals,\n label(capitalize(shape.attitudeKind ?? shape.wardleyLabel), 10, 18, {\n fill: c.stroke,\n 'font-weight': '700',\n 'letter-spacing': '0.04em',\n }),\n );\n return box;\n }\n\n private drawAnnotation(visuals: SVGElement, shape: WardleyShape): SVGElement {\n const cx = shape.width / 2;\n const cy = shape.height / 2;\n const marker = circle(cx, cy, 10, {\n fill: '#fff8e6',\n stroke: COLORS.stroke,\n 'stroke-width': 1.25,\n });\n svgAppend(visuals, marker);\n svgAppend(\n visuals,\n label(\n String(shape.annotationNumber ?? ''),\n cx,\n cy + 4,\n { 'text-anchor': 'middle', 'font-size': 11, 'font-weight': '700' },\n false,\n ),\n );\n if (shape.wardleyLabel) {\n svgAppend(\n visuals,\n label(shape.wardleyLabel, cx + 15, cy + 4, { 'font-size': 12, fill: COLORS.noteText }),\n );\n }\n return marker;\n }\n\n private drawAccelerator(visuals: SVGElement, shape: WardleyShape): SVGElement {\n const cx = shape.width / 2;\n const cy = shape.height / 2;\n const accelerate = shape.acceleratorDirection !== 'deaccelerate';\n const sym = label(accelerate ? '»' : '«', cx, cy + 6, {\n 'text-anchor': 'middle',\n 'font-size': 19,\n 'font-weight': '700',\n fill: accelerate ? COLORS.flow : COLORS.movement,\n });\n svgAppend(visuals, sym);\n if (shape.wardleyLabel) {\n svgAppend(visuals, label(shape.wardleyLabel, cx + 11, cy + 6, { 'font-size': 12 }));\n }\n return sym;\n }\n\n private drawSubmap(visuals: SVGElement, shape: WardleyShape): SVGElement {\n const cx = shape.width / 2;\n const cy = shape.height / 2;\n const r = COMPONENT_RADIUS + 1;\n const outer = svgAttr(svgCreate('rect'), {\n x: cx - r,\n y: cy - r,\n width: r * 2,\n height: r * 2,\n rx: 3,\n fill: COLORS.componentFill,\n stroke: COLORS.stroke,\n 'stroke-width': 2,\n });\n svgAppend(visuals, outer);\n svgAppend(\n visuals,\n svgAttr(svgCreate('rect'), {\n x: cx - r + 3,\n y: cy - r + 3,\n width: r * 2 - 6,\n height: r * 2 - 6,\n rx: 1.5,\n fill: 'none',\n stroke: COLORS.stroke,\n 'stroke-width': 1,\n }),\n );\n svgAppend(visuals, label(shape.wardleyLabel, cx + r + 6, cy - 6, { 'font-weight': '500' }));\n return outer;\n }\n}\n\nfunction circle(cx: number, cy: number, r: number, attrs: Attrs): SVGElement {\n return svgAttr(svgCreate('circle'), { cx, cy, r, 'stroke-width': 1, ...attrs });\n}\n\nfunction line(x1: number, y1: number, x2: number, y2: number, attrs: Attrs): SVGElement {\n return svgAttr(svgCreate('line'), { x1, y1, x2, y2, ...attrs });\n}\n\n/**\n * Text label with a paper halo (paint-order: stroke) for legibility over lines/bands.\n * `halo=false` disables the halo (e.g. for annotation numbers on a filled marker).\n */\nfunction label(content: string, x: number, y: number, attrs: Attrs = {}, halo = true): SVGElement {\n const haloAttrs: Attrs = halo\n ? {\n stroke: COLORS.paper,\n 'stroke-width': 3.5,\n 'paint-order': 'stroke',\n 'stroke-linejoin': 'round',\n }\n : {};\n const el = svgAttr(svgCreate('text'), {\n x,\n y,\n 'font-family': FONT.family,\n 'font-size': FONT.label,\n fill: COLORS.ink,\n ...haloAttrs,\n ...attrs,\n });\n el.textContent = content;\n return el;\n}\n\nfunction connectionArrow(from: Point, to: Point, color: string, len = 10, w = 5): SVGElement {\n const angle = Math.atan2(to.y - from.y, to.x - from.x);\n const bx = to.x - len * Math.cos(angle);\n const by = to.y - len * Math.sin(angle);\n const points =\n `${to.x},${to.y} ` +\n `${bx - w * Math.sin(angle)},${by + w * Math.cos(angle)} ` +\n `${bx + w * Math.sin(angle)},${by - w * Math.cos(angle)}`;\n return svgAttr(svgCreate('polygon'), { points, fill: color });\n}\n\n/** Effective radius of a node for cropping the connection at its boundary. */\nfunction radiusOf(s: WardleyShape): number {\n if (s.wardleyType === 'component') return COMPONENT_RADIUS + 2;\n if (s.wardleyType === 'anchor') return ANCHOR_ICON_SIZE / 2 + 1;\n return Math.min(s.width, s.height) / 2;\n}\n\n/**\n * Connection endpoints from the CURRENT node centers, cropped at their boundary\n * (BPMN look: line ends at the edge, arrowhead visible — independent of z-order, and\n * correct after moving, since recomputed on every render).\n */\nfunction endpoints(conn: WardleyConnection): [Point, Point] {\n const s = conn.source as unknown as WardleyShape | undefined;\n const t = conn.target as unknown as WardleyShape | undefined;\n const wp = conn.waypoints;\n if (!s || !t) {\n const a = wp[0] ?? { x: 0, y: 0 };\n return [a, wp[wp.length - 1] ?? a];\n }\n const sc = { x: s.x + s.width / 2, y: s.y + s.height / 2 };\n const tc = { x: t.x + t.width / 2, y: t.y + t.height / 2 };\n const dx = tc.x - sc.x;\n const dy = tc.y - sc.y;\n const dist = Math.hypot(dx, dy) || 1;\n const ux = dx / dist;\n const uy = dy / dist;\n const sr = radiusOf(s);\n const tr = radiusOf(t);\n if (dist <= sr + tr + 2) return [sc, tc];\n return [\n { x: sc.x + ux * sr, y: sc.y + uy * sr },\n { x: tc.x - ux * tr, y: tc.y - uy * tr },\n ];\n}\n\nfunction capitalize(s: string): string {\n return s ? s.charAt(0).toUpperCase() + s.slice(1) : s;\n}\n","import type { ModuleDeclaration } from 'didi';\nimport WardleyRenderer from './WardleyRenderer.js';\n\n/** SVG rendering of all Wardley types (BaseRenderer subclass, priority 1500). */\nexport const wardleyDrawModule: ModuleDeclaration = {\n __init__: ['wardleyRenderer'],\n wardleyRenderer: ['type', WardleyRenderer],\n};\n\nexport { default as WardleyRenderer } from './WardleyRenderer.js';\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 { Root } from 'diagram-js/lib/model/Types';\nimport type { MapElement, WardleyMap } from '@miragon/wardley-schema-model';\nimport type EvolutionGrid from '../evolution-grid/EvolutionGrid.js';\nimport type WardleyElementFactory from '../model/WardleyElementFactory.js';\nimport type { WardleyShape } from '../model/di-types.js';\nimport { ROOT_ID, type ImportWarning, type RootBusinessObject } from './types.js';\n\n/** \"Frame\" types sit behind the connections (concept doc requirement: frames at the very back). */\nconst FRAME_TYPES: ReadonlySet<string> = new Set(['attitude', 'pipeline']);\n\n/** Z-order of the nodes among themselves: smaller number = further back. */\nconst TYPE_ORDER: Record<string, number> = {\n attitude: 0,\n pipeline: 1,\n note: 2,\n component: 3,\n anchor: 4,\n annotation: 5,\n submap: 3,\n accelerator: 3,\n};\n\n/**\n * Bridges the WardleyMap model into the diagram-js canvas.\n * Uses `evolutionGrid` exclusively for the pixel projection (P7). Deliberately bypasses the\n * commandStack (import path, P4 exception): no undo, no dirty (concept doc §5.6).\n */\nexport default class WardleyImporter {\n static $inject = [\n 'canvas',\n 'elementFactory',\n 'wardleyElementFactory',\n 'evolutionGrid',\n 'eventBus',\n 'elementRegistry',\n ];\n\n constructor(\n private readonly canvas: Canvas,\n private readonly elementFactory: ElementFactory,\n private readonly factory: WardleyElementFactory,\n private readonly grid: EvolutionGrid,\n private readonly eventBus: EventBus,\n private readonly elementRegistry: ElementRegistry,\n ) {}\n\n import(map: WardleyMap): ImportWarning[] {\n const warnings: ImportWarning[] = [];\n this.eventBus.fire('import.render.start', { map });\n\n this.grid.configure(map.config);\n\n const meta: RootBusinessObject = {\n config: map.config,\n ...(map.rawPassthrough ? { rawPassthrough: map.rawPassthrough } : {}),\n };\n\n // Reuse the existing root (re-import), otherwise create a new one.\n let existing: (Root & { businessObject?: RootBusinessObject }) | undefined;\n try {\n existing = this.canvas.getRootElement() as Root & { businessObject?: RootBusinessObject };\n } catch {\n existing = undefined;\n }\n let root: Root & { businessObject?: RootBusinessObject };\n if (existing && existing.id === ROOT_ID) {\n root = existing;\n } else {\n root = this.elementFactory.createRoot({ id: ROOT_ID }) as Root & {\n businessObject?: RootBusinessObject;\n };\n this.canvas.setRootElement(root);\n }\n root.businessObject = meta;\n\n this.grid.render();\n\n const shapeById = new Map<string, WardleyShape>();\n const ordered = [...map.elements].sort(\n (a, b) => (TYPE_ORDER[a.elementType] ?? 9) - (TYPE_ORDER[b.elementType] ?? 9),\n );\n\n // Z-order (back -> front): frames (attitude/pipeline) -> connections -> nodes.\n // Frames + nodes must be registered before the connections; the connections are then\n // inserted via parentIndex BEHIND the nodes (but before them in the DOM).\n const frames = ordered.filter((el) => FRAME_TYPES.has(el.elementType));\n const nodes = ordered.filter((el) => !FRAME_TYPES.has(el.elementType));\n\n let frameCount = 0;\n for (const el of frames) {\n const shape = this.createShape(el);\n if (!shape) continue;\n this.canvas.addShape(shape, root);\n shapeById.set(el.id, shape);\n frameCount++;\n }\n for (const el of nodes) {\n const shape = this.createShape(el);\n if (!shape) continue;\n this.canvas.addShape(shape, root);\n shapeById.set(el.id, shape);\n }\n\n for (const edge of map.edges) {\n const source = shapeById.get(edge.from);\n const target = shapeById.get(edge.to);\n if (!source || !target) {\n warnings.push({ message: `Edge ${edge.id}: endpoint missing.`, elementId: edge.id });\n continue;\n }\n const conn =\n edge.edgeType === 'flow'\n ? this.factory.createFlow(edge, source, target)\n : this.factory.createDependency(edge, source, target);\n // Insert directly behind the frames, before all nodes.\n this.canvas.addConnection(conn, root, frameCount);\n }\n\n this.canvas.viewbox(this.grid.outerBounds());\n this.eventBus.fire('import.render.done', { warnings });\n return warnings;\n }\n\n private createShape(el: MapElement): WardleyShape | undefined {\n switch (el.elementType) {\n case 'component':\n return this.factory.createComponent(el);\n case 'anchor':\n return this.factory.createAnchor(el);\n case 'note':\n return this.factory.createNote(el);\n case 'pipeline':\n return this.factory.createPipeline(el);\n case 'annotation':\n return this.factory.createAnnotation(el);\n case 'attitude':\n return this.factory.createAttitude(el);\n case 'accelerator':\n return this.factory.createAccelerator(el);\n case 'submap':\n return this.factory.createSubmap(el);\n default: {\n const exhaustive: never = el;\n void exhaustive;\n return undefined;\n }\n }\n }\n\n clear(): void {\n for (const el of [...this.elementRegistry.getAll()]) {\n const e = el as { waypoints?: unknown; id: string };\n if (e.id === ROOT_ID) continue;\n try {\n if (e.waypoints) this.canvas.removeConnection(e.id);\n else this.canvas.removeShape(e.id);\n } catch {\n // already removed (e.g. edge on a removed shape) — ignore\n }\n }\n }\n}\n","import type Canvas from 'diagram-js/lib/core/Canvas';\nimport type ElementRegistry from 'diagram-js/lib/core/ElementRegistry';\nimport type { Root } from 'diagram-js/lib/model/Types';\nimport {\n validateMap,\n CURRENT_SCHEMA_VERSION,\n type ComponentElement,\n type MapConfig,\n type MapEdge,\n type MapElement,\n type NoteElement,\n type PipelineElement,\n type SubmapElement,\n type WardleyMap,\n} from '@miragon/wardley-schema-model';\nimport { isWardleyConnection, isWardleyShape, type WardleyShape } from '../model/di-types.js';\nimport { ROOT_ID, type RootBusinessObject } from './types.js';\n\nfunction compact<T extends Record<string, unknown>>(obj: T): T {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(obj)) if (v !== undefined) out[k] = v;\n return out as T;\n}\n\n/**\n * Reconstructs a WardleyMap from the diagram-js runtime model. The source of truth for positions are\n * the DI properties `evolution`/`visibility`; editable fields (label, decorators, movement,\n * pipeline range) are likewise read from the DI properties (concept doc §5.6). The\n * `businessObject` serves only as a fallback for type-specific fields that are not (yet) editable.\n */\nexport default class WardleyExporter {\n static $inject = ['elementRegistry', 'canvas'];\n\n constructor(\n private readonly elementRegistry: ElementRegistry,\n private readonly canvas: Canvas,\n ) {}\n\n export(): WardleyMap {\n const root = this.canvas.getRootElement() as Root & { businessObject?: RootBusinessObject };\n const meta = root.businessObject;\n const config: MapConfig = meta?.config ?? { title: 'Untitled Map' };\n\n const elements: MapElement[] = [];\n const edges: MapEdge[] = [];\n\n for (const el of this.elementRegistry.getAll()) {\n if (el.id === ROOT_ID) continue;\n if (isWardleyConnection(el)) {\n if (el.businessObject) {\n edges.push(el.businessObject);\n } else {\n const base = { id: el.id, from: el.source?.id ?? '', to: el.target?.id ?? '' };\n edges.push(\n el.wardleyType === 'flow'\n ? { ...base, edgeType: 'flow', ...(el.bidirectional ? { bidirectional: true } : {}) }\n : { ...base, edgeType: 'dependency' },\n );\n }\n } else if (isWardleyShape(el)) {\n const built = this.buildElement(el);\n if (built) elements.push(built);\n }\n }\n\n const map: WardleyMap = {\n schemaVersion: CURRENT_SCHEMA_VERSION,\n config,\n elements,\n edges,\n ...(meta?.rawPassthrough ? { rawPassthrough: meta.rawPassthrough } : {}),\n };\n\n return validateMap(map);\n }\n\n /** Builds a MapElement from the DI properties (common types) or the businessObject (the rest). */\n private buildElement(el: WardleyShape): MapElement | undefined {\n const position = { visibility: el.visibility, evolution: el.evolution };\n const bo = el.businessObject;\n\n switch (el.wardleyType) {\n case 'component':\n return compact({\n id: el.id,\n elementType: 'component',\n label: el.wardleyLabel,\n position,\n decorators: el.decorators,\n movement: el.movement,\n pipelineId: (bo as ComponentElement | undefined)?.pipelineId,\n }) as ComponentElement;\n case 'anchor':\n return { id: el.id, elementType: 'anchor', label: el.wardleyLabel, position };\n case 'note':\n return compact({\n id: el.id,\n elementType: 'note',\n label: el.wardleyLabel,\n position,\n patternType: (bo as NoteElement | undefined)?.patternType,\n color: el.color,\n }) as NoteElement;\n case 'pipeline':\n return {\n id: el.id,\n elementType: 'pipeline',\n label: el.wardleyLabel,\n position,\n evolutionStart: el.evolutionStart ?? 0,\n evolutionEnd: el.evolutionEnd ?? 1,\n childIds: (bo as PipelineElement | undefined)?.childIds ?? [],\n };\n case 'attitude':\n return {\n id: el.id,\n elementType: 'attitude',\n kind: el.attitudeKind ?? 'pioneers',\n label: el.wardleyLabel,\n position,\n width: el.width,\n height: el.height,\n };\n case 'accelerator':\n return {\n id: el.id,\n elementType: 'accelerator',\n direction: el.acceleratorDirection ?? 'accelerate',\n label: el.wardleyLabel,\n position,\n };\n case 'annotation':\n return {\n id: el.id,\n elementType: 'annotation',\n label: el.wardleyLabel,\n position,\n number: el.annotationNumber ?? 0,\n positions: [position],\n text: el.wardleyLabel,\n };\n case 'submap':\n return compact({\n id: el.id,\n elementType: 'submap',\n label: el.wardleyLabel,\n position,\n urlRef: (bo as SubmapElement | undefined)?.urlRef,\n }) as SubmapElement;\n default: {\n const exhaustive: never = el.wardleyType;\n void exhaustive;\n return bo ? ({ ...bo, position } as MapElement) : undefined;\n }\n }\n }\n}\n","import type { ModuleDeclaration } from 'didi';\nimport WardleyImporter from './WardleyImporter.js';\nimport WardleyExporter from './WardleyExporter.js';\n\nexport const ioModule: ModuleDeclaration = {\n wardleyImporter: ['type', WardleyImporter],\n wardleyExporter: ['type', WardleyExporter],\n};\n\nexport { default as WardleyImporter } from './WardleyImporter.js';\nexport { default as WardleyExporter } from './WardleyExporter.js';\nexport { saveSVG } from './saveSvg.js';\nexport { ROOT_ID } from './types.js';\nexport type { ImportWarning, RootBusinessObject } from './types.js';\n","import type { ModuleDeclaration } from 'didi';\nimport { WardleyBaseViewer } from './WardleyBaseViewer.js';\nimport { wardleyModelModule } from './model/index.js';\nimport { evolutionGridModule } from './evolution-grid/index.js';\nimport { wardleyDrawModule } from './draw/index.js';\nimport { ioModule } from './io/index.js';\n\nexport class Viewer extends WardleyBaseViewer {\n protected _getModules(): ModuleDeclaration[] {\n return [wardleyModelModule, evolutionGridModule, wardleyDrawModule, ioModule];\n }\n}\n","import type EventBus from 'diagram-js/lib/core/EventBus';\nimport type Canvas from 'diagram-js/lib/core/Canvas';\nimport type EvolutionGrid from '../evolution-grid/EvolutionGrid.js';\n\nconst PAD_TOP = 180;\nconst PAD_BOTTOM = 80;\nconst PAD_SIDE = 120;\nconst EPSILON = 0.5;\n\ntype ViewBox = { x: number; y: number; width: number; height: number };\n\nconst clamp = (value: number, lo: number, hi: number): number =>\n value < lo ? lo : value > hi ? hi : value;\n\nfunction constrainAxis(\n position: number,\n viewSize: number,\n boundMin: number,\n boundSize: number,\n): number {\n if (viewSize <= boundSize) return clamp(position, boundMin, boundMin + boundSize - viewSize);\n return boundMin + boundSize / 2 - viewSize / 2;\n}\n\n/**\n * Keeps the map in view while scrolling and zooming.\n * Without this the user could scroll the map completely off-screen into empty space.\n * After every move we pull the visible area back so it stays close to the map,\n * leaving only a small margin of empty space around it.\n */\nexport default class PanConstraint {\n static $inject = ['eventBus', 'canvas', 'evolutionGrid'];\n\n private applying = false;\n\n constructor(\n eventBus: EventBus,\n private readonly canvas: Canvas,\n private readonly grid: EvolutionGrid,\n ) {\n eventBus.on('canvas.viewbox.changed', (event: { viewbox?: ViewBox }) => {\n if (this.applying) return;\n this.constrain(event?.viewbox);\n });\n }\n\n private constrain(viewbox?: ViewBox): void {\n const current = viewbox ?? (this.canvas.viewbox() as unknown as ViewBox);\n const bounds = this.grid.outerBounds();\n if (\n !(bounds.width > 0) ||\n !(bounds.height > 0) ||\n !(current.width > 0) ||\n !(current.height > 0)\n )\n return;\n\n const clampedX = constrainAxis(\n current.x,\n current.width,\n bounds.x - PAD_SIDE,\n bounds.width + 2 * PAD_SIDE,\n );\n const clampedY = constrainAxis(\n current.y,\n current.height,\n bounds.y - PAD_TOP,\n bounds.height + PAD_TOP + PAD_BOTTOM,\n );\n\n if (Math.abs(clampedX - current.x) < EPSILON && Math.abs(clampedY - current.y) < EPSILON)\n return;\n\n this.applying = true;\n try {\n this.canvas.viewbox({\n x: clampedX,\n y: clampedY,\n width: current.width,\n height: current.height,\n });\n } finally {\n this.applying = false;\n }\n }\n}\n","import type { ModuleDeclaration } from 'didi';\nimport PanConstraint from './PanConstraint.js';\n\nexport const PanConstraintModule: ModuleDeclaration = {\n __init__: ['panConstraint'],\n panConstraint: ['type', PanConstraint],\n};\n\nexport { default as PanConstraint } from './PanConstraint.js';\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 KeyboardModule from 'diagram-js/lib/features/keyboard';\nimport { Viewer } from './Viewer.js';\nimport { PanConstraintModule } from './pan-constraint/index.js';\n\n/**\n * `keyboard-move-selection` depends on `modeling` and therefore belongs in the (later) Modeler,\n * not in the read-only NavigatedViewer.\n */\nexport class NavigatedViewer extends Viewer {\n protected override _getModules(): ModuleDeclaration[] {\n return [\n ...super._getModules(),\n SelectionModule,\n ZoomScrollModule,\n MoveCanvasModule,\n KeyboardModule,\n PanConstraintModule,\n ];\n }\n}\n","import type { ElementLike } from 'diagram-js/lib/core/Types';\nimport type CommandHandler from 'diagram-js/lib/command/CommandHandler';\n\nexport interface UpdatePropertiesContext {\n element: ElementLike & Record<string, unknown>;\n properties: Record<string, unknown>;\n /** set internally by the handler (for revert). */\n oldProperties?: Record<string, unknown>;\n}\n\nfunction setOrDelete(obj: Record<string, unknown>, key: string, value: unknown): void {\n if (value === undefined) delete obj[key];\n else obj[key] = value;\n}\n\n/**\n * Generic, undoable command handler for setting arbitrary Wardley properties\n * (wardleyLabel, decorators, movement, evolutionStart/End, ...). Returns the changed element\n * -> CommandStack fires `elements.changed` -> re-render.\n */\nexport default class UpdatePropertiesHandler implements CommandHandler {\n execute(context: UpdatePropertiesContext): ElementLike[] {\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): ElementLike[] {\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)) setOrDelete(target, key, oldProperties[key]);\n }\n return [element];\n }\n}\n","import type CommandStack from 'diagram-js/lib/command/CommandStack';\nimport type { Method } from '@miragon/wardley-schema-model';\nimport type { WardleyShape } from '../model/di-types.js';\nimport { noteMetrics } from '../draw/styles.js';\nimport UpdatePropertiesHandler from './cmd/UpdatePropertiesHandler.js';\n\nconst UPDATE_PROPERTIES = 'element.updateProperties';\n\nfunction compact<T extends Record<string, unknown>>(obj: T): T {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(obj)) if (v !== undefined) out[k] = v;\n return out as T;\n}\n\nexport interface EvolveOptions {\n newLabel?: string;\n method?: Method;\n}\n\n/**\n * High-level mutations on Wardley shapes that run through the commandStack (undo/redo, P4).\n * Registers the generic UpdatePropertiesHandler at bootstrap.\n */\nexport default class WardleyModeling {\n static $inject = ['commandStack'];\n\n constructor(private readonly commandStack: CommandStack) {\n commandStack.registerHandler(UPDATE_PROPERTIES, UpdatePropertiesHandler);\n }\n\n updateProperties(element: WardleyShape, properties: Record<string, unknown>): void {\n this.commandStack.execute(UPDATE_PROPERTIES, { element, properties });\n }\n\n updateLabel(element: WardleyShape, label: string): void {\n // Notes: resize the box (and thus the move/click hitbox) to the new text, keeping the center.\n if (element.wardleyType === 'note') {\n const { width, height } = noteMetrics(label);\n const cx = element.x + element.width / 2;\n const cy = element.y + element.height / 2;\n this.updateProperties(element, {\n wardleyLabel: label,\n width,\n height,\n x: cx - width / 2,\n y: cy - height / 2,\n });\n return;\n }\n this.updateProperties(element, { wardleyLabel: label });\n }\n\n evolveComponent(element: WardleyShape, targetEvolution: number, opts: EvolveOptions = {}): void {\n this.updateProperties(element, {\n movement: compact({\n targetEvolution: clamp01(targetEvolution),\n newLabel: opts.newLabel,\n method: opts.method,\n }),\n });\n }\n\n clearMovement(element: WardleyShape): void {\n this.updateProperties(element, { movement: undefined });\n }\n\n toggleInertia(element: WardleyShape): void {\n const dec: Record<string, unknown> = { ...(element.decorators ?? {}) };\n if (dec['inertia']) delete dec['inertia'];\n else dec['inertia'] = true;\n this.updateProperties(element, { decorators: Object.keys(dec).length ? dec : undefined });\n }\n\n setMethod(element: WardleyShape, method: Method | undefined): void {\n const dec: Record<string, unknown> = { ...(element.decorators ?? {}) };\n if (method) dec['method'] = method;\n else delete dec['method'];\n this.updateProperties(element, { decorators: Object.keys(dec).length ? dec : undefined });\n }\n\n /** Sets market/ecosystem (mutually exclusive) or removes both (`undefined`). */\n setMarketEcosystem(element: WardleyShape, kind: 'market' | 'ecosystem' | undefined): void {\n const dec: Record<string, unknown> = { ...(element.decorators ?? {}) };\n delete dec['market'];\n delete dec['ecosystem'];\n if (kind) dec[kind] = true;\n this.updateProperties(element, { decorators: Object.keys(dec).length ? dec : undefined });\n }\n\n /** Sets the note color (CSS color/hex) or removes it (`undefined` = default color). */\n setColor(element: WardleyShape, color: string | undefined): void {\n this.updateProperties(element, { color });\n }\n}\n\nfunction clamp01(n: number): number {\n return n < 0 ? 0 : n > 1 ? 1 : n;\n}\n","import type { ModuleDeclaration } from 'didi';\nimport WardleyModeling from './WardleyModeling.js';\n\n/** High-level Wardley mutations + registration of the custom command handlers. */\nexport const wardleyModelingModule: ModuleDeclaration = {\n __init__: ['wardleyModeling'],\n wardleyModeling: ['type', WardleyModeling],\n};\n\nexport { default as WardleyModeling } from './WardleyModeling.js';\nexport type { EvolveOptions } from './WardleyModeling.js';\n","import RuleProvider from 'diagram-js/lib/features/rules/RuleProvider';\nimport type EventBus from 'diagram-js/lib/core/EventBus';\nimport { isWardleyShape, isPipeline, type WardleyShape } from '../model/di-types.js';\n\nconst CONNECTABLE: ReadonlySet<string> = new Set(['component', 'anchor']);\n\nfunction isConnectable(el: unknown): el is WardleyShape {\n return isWardleyShape(el) && CONNECTABLE.has(el.wardleyType);\n}\n\n/**\n * Allowed editing operations (concept doc §5.4). On success the `connection.create` rule returns\n * the new connection's attributes (`{ wardleyType: 'dependency' }`) — diagram-js Connect adopts\n * them as connection attributes.\n */\nexport default class WardleyRules extends RuleProvider {\n static override $inject = ['eventBus'];\n\n constructor(eventBus: EventBus) {\n super(eventBus);\n }\n\n override init(): void {\n this.addRule('connection.start', (context: { source?: unknown }) =>\n isConnectable(context.source),\n );\n\n this.addRule('connection.create', (context: { source?: unknown; target?: unknown }) => {\n const { source, target } = context;\n if (!isConnectable(source) || !isConnectable(target)) return false;\n if (source === target) return false;\n return { wardleyType: 'dependency' };\n });\n\n this.addRule(['shape.move', 'elements.move'], () => true);\n this.addRule('shape.create', () => true);\n this.addRule('shape.resize', (context: { shape?: unknown }) => isPipeline(context.shape));\n }\n}\n","import type { ModuleDeclaration } from 'didi';\nimport WardleyRules from './WardleyRules.js';\n\n/** Allowed Wardley operations (RuleProvider). */\nexport const wardleyRulesModule: ModuleDeclaration = {\n __init__: ['wardleyRules'],\n wardleyRules: ['type', WardleyRules],\n};\n\nexport { default as WardleyRules } from './WardleyRules.js';\n","import type EventBus from 'diagram-js/lib/core/EventBus';\nimport type EvolutionGrid from '../evolution-grid/EvolutionGrid.js';\n\nconst SNAP_TOLERANCE = 8;\n\ninterface DragMoveEvent {\n x?: number;\n y?: number;\n originalEvent?: { shiftKey?: boolean };\n}\n\n/**\n * Snaps the X position (evolution) during move/create/resize to the stage boundaries.\n * Disabled while the Shift key is held. Deliberately lightweight (no replacement for the full\n * diagram-js snapping); it adds the Wardley-specific band boundaries to the snapping.\n */\nexport default class StageSnapping {\n static $inject = ['eventBus', 'evolutionGrid'];\n\n constructor(eventBus: EventBus, grid: EvolutionGrid) {\n const events = [\n 'shape.move.move',\n 'shape.move.end',\n 'create.move',\n 'create.end',\n 'shape.resize.move',\n 'shape.resize.end',\n ];\n\n eventBus.on(events, 1500, (event: DragMoveEvent) => {\n if (event.originalEvent?.shiftKey) return;\n if (typeof event.x !== 'number') return;\n const xs = grid\n .getBoundaries()\n .map((b) => grid.toCanvas({ visibility: 0.5, evolution: b }).x);\n for (const sx of xs) {\n if (Math.abs(event.x - sx) <= SNAP_TOLERANCE) {\n event.x = sx;\n break;\n }\n }\n });\n }\n}\n","import type { ModuleDeclaration } from 'didi';\nimport StageSnapping from './StageSnapping.js';\n\n/** Snapping to the evolution stage boundaries (editor-only). */\nexport const stageSnappingModule: ModuleDeclaration = {\n __init__: ['stageSnapping'],\n stageSnapping: ['type', StageSnapping],\n};\n\nexport { default as StageSnapping } from './StageSnapping.js';\n","import { COLORS, ATTITUDE_COLORS, FONT } from './styles.js';\nimport { ICON_PERSON } from './icons.js';\n\n/**\n * Palette icons as a mini preview of the ACTUAL canvas rendering (WYSIWYG) — same colors\n * and shapes as the WardleyRenderer, so the palette shows what will be created.\n */\n\nconst wrap = (inner: string): string =>\n `<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" class=\"wardley-palette-svg\">${inner}</svg>`;\n\nconst eventCircle = (extra = ''): string =>\n `<circle cx=\"12\" cy=\"12\" r=\"7\" fill=\"${COLORS.componentFill}\" stroke=\"${COLORS.stroke}\" stroke-width=\"2\"/>${extra}`;\n\nconst text = (content: string, attrs: string): string =>\n `<text x=\"12\" text-anchor=\"middle\" font-family=\"${FONT.family}\" ${attrs}>${content}</text>`;\n\nexport const PALETTE_ICONS: Record<string, string> = {\n component: wrap(eventCircle()),\n market: wrap(eventCircle(`<circle cx=\"12\" cy=\"12\" r=\"2.6\" fill=\"${COLORS.stroke}\"/>`)),\n ecosystem: wrap(\n eventCircle(\n `<circle cx=\"12\" cy=\"12\" r=\"4\" fill=\"none\" stroke=\"${COLORS.stroke}\" stroke-width=\"1.5\"/>`,\n ),\n ),\n anchor: wrap(`<path d=\"${ICON_PERSON}\" fill=\"${COLORS.ink}\"/>`),\n pipeline: wrap(\n `<rect x=\"2\" y=\"8\" width=\"20\" height=\"8\" rx=\"3\" fill=\"${COLORS.accentSoft}\" stroke=\"${COLORS.pipeline}\" stroke-width=\"1.5\" stroke-dasharray=\"3 2\"/>`,\n ),\n note: wrap(\n `<g stroke=\"${COLORS.noteText}\" stroke-width=\"1.5\" stroke-linecap=\"round\"><line x1=\"5\" y1=\"8\" x2=\"19\" y2=\"8\"/><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"/><line x1=\"5\" y1=\"16\" x2=\"13\" y2=\"16\"/></g>`,\n ),\n annotation: wrap(\n `<circle cx=\"12\" cy=\"12\" r=\"8\" fill=\"#fff8e6\" stroke=\"${COLORS.stroke}\" stroke-width=\"1.25\"/>` +\n text('1', `y=\"16\" font-size=\"11\" font-weight=\"700\" fill=\"${COLORS.stroke}\"`),\n ),\n accelerator: wrap(text('»', `y=\"17.5\" font-size=\"19\" font-weight=\"700\" fill=\"${COLORS.flow}\"`)),\n deaccelerator: wrap(\n text('«', `y=\"17.5\" font-size=\"19\" font-weight=\"700\" fill=\"${COLORS.movement}\"`),\n ),\n submap: wrap(\n `<rect x=\"4\" y=\"4\" width=\"16\" height=\"16\" rx=\"3\" fill=\"${COLORS.componentFill}\" stroke=\"${COLORS.stroke}\" stroke-width=\"2\"/>` +\n `<rect x=\"7.5\" y=\"7.5\" width=\"9\" height=\"9\" rx=\"1.5\" fill=\"none\" stroke=\"${COLORS.stroke}\" stroke-width=\"1\"/>`,\n ),\n};\n\nexport function attitudeIcon(kind: string): string {\n const c = ATTITUDE_COLORS[kind] ?? { fill: 'rgba(0,0,0,0.05)', stroke: '#666666' };\n return wrap(\n `<rect x=\"2\" y=\"6\" width=\"20\" height=\"12\" rx=\"3\" fill=\"${c.fill}\" stroke=\"${c.stroke}\" stroke-width=\"1.5\" stroke-dasharray=\"3 2\"/>`,\n );\n}\n","import type Palette from 'diagram-js/lib/features/palette/Palette';\nimport type Create from 'diagram-js/lib/features/create/Create';\nimport type {\n PaletteEntries,\n PaletteEntry,\n default as PaletteProvider,\n} from 'diagram-js/lib/features/palette/PaletteProvider';\nimport type WardleyElementFactory from '../model/WardleyElementFactory.js';\nimport type { CreateNewExtra } from '../model/WardleyElementFactory.js';\nimport type { WardleyShapeType } from '../model/di-types.js';\nimport { PALETTE_ICONS, attitudeIcon } from '../draw/palette-icons.js';\n\ninterface PaletteSpec {\n key: string;\n type: WardleyShapeType;\n label: string;\n title: string;\n icon: string;\n group: string;\n extra?: CreateNewExtra;\n}\n\n// Group IDs with a prefix number -> stable, visible ordering of the palette groups.\nconst GROUP_BLOCKS = 'wardley-1-blocks';\nconst GROUP_STRATEGY = 'wardley-2-strategy';\nconst GROUP_NOTES = 'wardley-3-notes';\n\nconst SPECS: readonly PaletteSpec[] = [\n {\n key: 'component',\n type: 'component',\n label: 'Component',\n title: 'Component',\n icon: PALETTE_ICONS.component!,\n group: GROUP_BLOCKS,\n },\n {\n key: 'market',\n type: 'component',\n label: 'Market',\n title: 'Market component',\n icon: PALETTE_ICONS.market!,\n group: GROUP_BLOCKS,\n extra: { market: true },\n },\n {\n key: 'ecosystem',\n type: 'component',\n label: 'Ecosystem',\n title: 'Ecosystem component',\n icon: PALETTE_ICONS.ecosystem!,\n group: GROUP_BLOCKS,\n extra: { ecosystem: true },\n },\n {\n key: 'anchor',\n type: 'anchor',\n label: 'User',\n title: 'Anchor / User',\n icon: PALETTE_ICONS.anchor!,\n group: GROUP_BLOCKS,\n },\n {\n key: 'pipeline',\n type: 'pipeline',\n label: 'Pipeline',\n title: 'Pipeline',\n icon: PALETTE_ICONS.pipeline!,\n group: GROUP_BLOCKS,\n },\n {\n key: 'submap',\n type: 'submap',\n label: 'Submap',\n title: 'Submap',\n icon: PALETTE_ICONS.submap!,\n group: GROUP_BLOCKS,\n },\n\n {\n key: 'pioneers',\n type: 'attitude',\n label: 'Pioneers',\n title: 'Pioneers region',\n icon: attitudeIcon('pioneers'),\n group: GROUP_STRATEGY,\n extra: { attitudeKind: 'pioneers' },\n },\n {\n key: 'settlers',\n type: 'attitude',\n label: 'Settlers',\n title: 'Settlers region',\n icon: attitudeIcon('settlers'),\n group: GROUP_STRATEGY,\n extra: { attitudeKind: 'settlers' },\n },\n {\n key: 'townplanners',\n type: 'attitude',\n label: 'Town Planners',\n title: 'Town Planners region',\n icon: attitudeIcon('townplanners'),\n group: GROUP_STRATEGY,\n extra: { attitudeKind: 'townplanners' },\n },\n {\n key: 'accelerator',\n type: 'accelerator',\n label: 'Accelerate',\n title: 'Accelerator',\n icon: PALETTE_ICONS.accelerator!,\n group: GROUP_STRATEGY,\n extra: { acceleratorDirection: 'accelerate' },\n },\n {\n key: 'deaccelerator',\n type: 'accelerator',\n label: 'Deaccelerate',\n title: 'Deaccelerator',\n icon: PALETTE_ICONS.deaccelerator!,\n group: GROUP_STRATEGY,\n extra: { acceleratorDirection: 'deaccelerate' },\n },\n\n {\n key: 'note',\n type: 'note',\n label: 'Note',\n title: 'Note',\n icon: PALETTE_ICONS.note!,\n group: GROUP_NOTES,\n },\n {\n key: 'annotation',\n type: 'annotation',\n label: 'Annotation',\n title: 'Annotation (numbered marker)',\n icon: PALETTE_ICONS.annotation!,\n group: GROUP_NOTES,\n extra: { annotationNumber: 1 },\n },\n];\n\nexport default class WardleyPaletteProvider implements PaletteProvider {\n static $inject = ['palette', 'create', 'wardleyElementFactory'];\n\n constructor(\n palette: Palette,\n private readonly create: Create,\n private readonly factory: WardleyElementFactory,\n ) {\n palette.registerProvider(this);\n }\n\n getPaletteEntries(): PaletteEntries {\n const entries: Record<string, PaletteEntry> = {};\n for (const spec of SPECS) {\n const start = (event: Event) => {\n const shape = this.factory.createNew(spec.type, spec.label, spec.extra ?? {});\n this.create.start(event, shape);\n };\n entries[`create.${spec.key}`] = {\n group: spec.group,\n title: spec.title,\n html: `<div class=\"entry wardley-palette-entry\" draggable=\"true\" title=\"${spec.title}\">${spec.icon}</div>`,\n action: { dragstart: start, click: start },\n };\n }\n return entries;\n }\n}\n","import type { ModuleDeclaration } from 'didi';\nimport WardleyPaletteProvider from './WardleyPaletteProvider.js';\n\n/** Tool palette (drag-to-create). */\nexport const wardleyPaletteModule: ModuleDeclaration = {\n __init__: ['wardleyPaletteProvider'],\n wardleyPaletteProvider: ['type', WardleyPaletteProvider],\n};\n\nexport { default as WardleyPaletteProvider } from './WardleyPaletteProvider.js';\n","import type PopupMenu from 'diagram-js/lib/features/popup-menu/PopupMenu';\nimport type { PopupMenuTarget } from 'diagram-js/lib/features/popup-menu/PopupMenu';\nimport type {\n PopupMenuEntries,\n default as PopupMenuProvider,\n} from 'diagram-js/lib/features/popup-menu/PopupMenuProvider';\nimport { isComponent, type WardleyShape } from '../model/di-types.js';\nimport type WardleyModeling from '../modeling/WardleyModeling.js';\n\nexport const POPUP_PROVIDER_ID = 'wardley-element-settings';\n\nconst TYPE_GROUP = { id: 'type', name: 'Type' };\nconst METHOD_GROUP = { id: 'method', name: 'Sourcing' };\nconst PROP_GROUP = { id: 'props', name: 'Properties' };\n\nfunction mark(active: boolean, label: string): string {\n return active ? `✓ ${label}` : label;\n}\n\n/**\n * Popup submenu (opened via the context pad gear) for directly setting type (normal/market/\n * ecosystem), sourcing (build/buy/outsource) and inertia — instead of cycle buttons.\n * All actions go through `wardleyModeling` (undo/redo).\n */\nexport default class WardleyElementSettingsProvider implements PopupMenuProvider {\n static $inject = ['popupMenu', 'wardleyModeling'];\n\n constructor(\n popupMenu: PopupMenu,\n private readonly modeling: WardleyModeling,\n ) {\n popupMenu.registerProvider(POPUP_PROVIDER_ID, this);\n }\n\n getPopupMenuEntries(target: PopupMenuTarget): PopupMenuEntries {\n const shape = (Array.isArray(target) ? target[0] : target) as WardleyShape | undefined;\n if (!isComponent(shape)) return {};\n return this.componentEntries(shape);\n }\n\n private componentEntries(shape: WardleyShape): PopupMenuEntries {\n const dec = shape.decorators ?? {};\n const kind = dec.ecosystem ? 'ecosystem' : dec.market ? 'market' : 'normal';\n const method = dec.method;\n\n return {\n 'type-normal': {\n label: mark(kind === 'normal', 'Normal'),\n group: TYPE_GROUP,\n action: () => this.modeling.setMarketEcosystem(shape, undefined),\n },\n 'type-market': {\n label: mark(kind === 'market', 'Market'),\n group: TYPE_GROUP,\n action: () => this.modeling.setMarketEcosystem(shape, 'market'),\n },\n 'type-ecosystem': {\n label: mark(kind === 'ecosystem', 'Ecosystem'),\n group: TYPE_GROUP,\n action: () => this.modeling.setMarketEcosystem(shape, 'ecosystem'),\n },\n 'method-none': {\n label: mark(!method, 'None'),\n group: METHOD_GROUP,\n action: () => this.modeling.setMethod(shape, undefined),\n },\n 'method-build': {\n label: mark(method === 'build', 'Build'),\n group: METHOD_GROUP,\n action: () => this.modeling.setMethod(shape, 'build'),\n },\n 'method-buy': {\n label: mark(method === 'buy', 'Buy'),\n group: METHOD_GROUP,\n action: () => this.modeling.setMethod(shape, 'buy'),\n },\n 'method-outsource': {\n label: mark(method === 'outsource', 'Outsource'),\n group: METHOD_GROUP,\n action: () => this.modeling.setMethod(shape, 'outsource'),\n },\n 'prop-inertia': {\n label: mark(!!dec.inertia, 'Inertia'),\n group: PROP_GROUP,\n action: () => this.modeling.toggleInertia(shape),\n },\n };\n }\n}\n","import type { ModuleDeclaration } from 'didi';\nimport WardleyElementSettingsProvider from './WardleyElementSettingsProvider.js';\n\n/** Popup submenu for element settings (type/sourcing/inertia). */\nexport const wardleyPopupModule: ModuleDeclaration = {\n __init__: ['wardleyElementSettings'],\n wardleyElementSettings: ['type', WardleyElementSettingsProvider],\n};\n\nexport {\n default as WardleyElementSettingsProvider,\n POPUP_PROVIDER_ID,\n} from './WardleyElementSettingsProvider.js';\n","import type ContextPad from 'diagram-js/lib/features/context-pad/ContextPad';\nimport type Modeling from 'diagram-js/lib/features/modeling/Modeling';\nimport type Connect from 'diagram-js/lib/features/connect/Connect';\nimport type Create from 'diagram-js/lib/features/create/Create';\nimport type PopupMenu from 'diagram-js/lib/features/popup-menu/PopupMenu';\nimport type {\n ContextPadEntries,\n default as ContextPadProvider,\n} from 'diagram-js/lib/features/context-pad/ContextPadProvider';\nimport type { Element } from 'diagram-js/lib/model/Types';\nimport { isWardleyShape, isWardleyConnection, type WardleyShape } from '../model/di-types.js';\nimport type WardleyModeling from '../modeling/WardleyModeling.js';\nimport type WardleyLabelEditing from '../label-editing/WardleyLabelEditing.js';\nimport type WardleyEvolveDragging from '../evolve/WardleyEvolveDragging.js';\nimport type WardleyElementFactory from '../model/WardleyElementFactory.js';\nimport type WardleyColorPicker from '../color-picker/WardleyColorPicker.js';\nimport { POPUP_PROVIDER_ID } from '../popup/index.js';\nimport {\n iconMarkup,\n ICON_CIRCLE,\n ICON_ARROW_FORWARD,\n ICON_CLOSE,\n ICON_DELETE,\n ICON_DOUBLE_ARROW,\n ICON_EDIT,\n ICON_PALETTE,\n ICON_SETTINGS,\n} from '../draw/icons.js';\n\n/**\n * ContextPad entry as HTML with a Material icon. `draggable=true` is mandatory for entries with a\n * `dragstart` action — otherwise diagram-js does not fire the drag.\n */\nfunction cpHtml(icon: string, title: string, draggable = false): string {\n return `<div class=\"entry wardley-cp-entry\"${draggable ? ' draggable=\"true\"' : ''} title=\"${title}\">${iconMarkup(icon)}</div>`;\n}\n\n/** Context actions per element (concept doc §5.5). */\nexport default class WardleyContextPadProvider implements ContextPadProvider {\n static $inject = [\n 'contextPad',\n 'modeling',\n 'connect',\n 'create',\n 'popupMenu',\n 'wardleyModeling',\n 'wardleyLabelEditing',\n 'wardleyEvolveDragging',\n 'wardleyElementFactory',\n 'wardleyColorPicker',\n ];\n\n constructor(\n contextPad: ContextPad,\n private readonly modeling: Modeling,\n private readonly connect: Connect,\n private readonly create: Create,\n private readonly popupMenu: PopupMenu,\n private readonly wardleyModeling: WardleyModeling,\n private readonly labelEditing: WardleyLabelEditing,\n private readonly evolveDragging: WardleyEvolveDragging,\n private readonly factory: WardleyElementFactory,\n private readonly colorPicker: WardleyColorPicker,\n ) {\n contextPad.registerProvider(this);\n }\n\n getContextPadEntries(element: Element): ContextPadEntries {\n // Connections (dependency/flow): own pad with delete only — otherwise there would be no way to\n // remove a line again (shapes get their full pad further below).\n if (isWardleyConnection(element)) {\n return {\n delete: {\n group: 'edit',\n title: 'Delete connection',\n html: cpHtml(ICON_DELETE, 'Delete connection'),\n action: { click: () => this.modeling.removeElements([element]) },\n },\n };\n }\n if (!isWardleyShape(element)) return {};\n const shape = element as WardleyShape;\n const entries: ContextPadEntries = {};\n\n const connectable = shape.wardleyType === 'component' || shape.wardleyType === 'anchor';\n if (connectable) {\n // Append component: drags out a new (blank) component and creates the arrow automatically\n // (diagram-js Create with `source` -> modeling.appendShape). Configurable via ⚙.\n const startAppend = (event: Event) => {\n const next = this.factory.createNew('component', 'Component');\n this.create.start(event as MouseEvent, next as unknown as Element, {\n source: shape as unknown as Element,\n });\n };\n entries['append'] = {\n group: 'edit',\n title: 'Append component (auto-connect)',\n html: cpHtml(ICON_CIRCLE, 'Append component', true),\n action: { click: startAppend, dragstart: startAppend },\n };\n\n const startConnect = (event: Event) => {\n this.connect.start(event as MouseEvent, shape as unknown as Element);\n };\n entries['connect'] = {\n group: 'edit',\n title: 'Connect to existing element',\n html: cpHtml(ICON_ARROW_FORWARD, 'Connect to existing element', true),\n action: { click: startConnect, dragstart: startConnect },\n };\n }\n\n if (shape.wardleyType === 'component') {\n if (shape.movement) {\n // Target is set -> drag the red target circle directly to MOVE it\n // (see WardleyEvolveDragging). Here we only offer removal.\n entries['evolve-clear'] = {\n group: 'wardley',\n title: 'Remove evolve',\n html: cpHtml(ICON_CLOSE, 'Remove evolve'),\n action: { click: () => this.wardleyModeling.clearMovement(shape) },\n };\n } else {\n // Drag the target out along the axis (live preview). The click does NOT model immediately\n // (no automatic +0.2 anymore) — it only starts the placement.\n const startEvolve = (event: Event) => this.evolveDragging.start(event, shape);\n entries['evolve'] = {\n group: 'wardley',\n title: 'Evolve: drag to set the target maturity',\n html: cpHtml(ICON_DOUBLE_ARROW, 'Evolve: drag to set the target maturity', true),\n action: { click: startEvolve, dragstart: startEvolve },\n };\n }\n\n entries['settings'] = {\n group: 'wardley',\n title: 'Settings (type, sourcing, inertia)',\n html: cpHtml(ICON_SETTINGS, 'Settings'),\n action: {\n click: (event: Event) => {\n const e = event as MouseEvent;\n this.popupMenu.open(shape as unknown as Element, POPUP_PROVIDER_ID, {\n x: e.clientX,\n y: e.clientY,\n });\n },\n },\n };\n }\n\n if (shape.wardleyType === 'note') {\n entries['color'] = {\n group: 'wardley',\n title: 'Note color',\n html: cpHtml(ICON_PALETTE, 'Note color'),\n action: {\n click: (event: Event) => {\n const e = event as MouseEvent;\n this.colorPicker.open(shape, e.clientX, e.clientY);\n },\n },\n };\n }\n\n entries['edit-label'] = {\n group: 'edit',\n title: 'Edit label',\n html: cpHtml(ICON_EDIT, 'Edit label'),\n action: { click: () => this.labelEditing.activate(shape) },\n };\n\n entries['delete'] = {\n group: 'edit',\n title: 'Delete',\n html: cpHtml(ICON_DELETE, 'Delete'),\n action: { click: () => this.modeling.removeElements([shape as unknown as Element]) },\n };\n\n return entries;\n }\n}\n","import type { ModuleDeclaration } from 'didi';\nimport WardleyContextPadProvider from './WardleyContextPadProvider.js';\n\n/** Context actions per element. */\nexport const wardleyContextPadModule: ModuleDeclaration = {\n __init__: ['wardleyContextPadProvider'],\n wardleyContextPadProvider: ['type', WardleyContextPadProvider],\n};\n\nexport { default as WardleyContextPadProvider } from './WardleyContextPadProvider.js';\n","import type Canvas from 'diagram-js/lib/core/Canvas';\nimport type EventBus from 'diagram-js/lib/core/EventBus';\nimport { isWardleyShape, type WardleyShape } from '../model/di-types.js';\nimport type WardleyModeling from '../modeling/WardleyModeling.js';\nimport type WardleyElementFactory from '../model/WardleyElementFactory.js';\n\ninterface ActiveEdit {\n field: HTMLInputElement | HTMLTextAreaElement;\n /** Saves the current value and closes (for Enter, blur, click outside). */\n commit: () => void;\n /** Discards and closes (only for Escape). */\n cleanup: () => void;\n}\n\n/**\n * Custom inline label editing as an HTML overlay (deliberately not diagram-js direct-editing, §8.5).\n * Commit goes through `wardleyModeling.updateLabel` -> commandStack (undo, P4).\n * Notes are edited in a `<textarea>` (multiline: Enter = line break, Cmd/Ctrl+Enter or click outside\n * = save); everything else in an `<input>` (Enter = save).\n */\nexport default class WardleyLabelEditing {\n static $inject = ['eventBus', 'canvas', 'wardleyModeling', 'wardleyElementFactory'];\n\n private active: ActiveEdit | null = null;\n\n constructor(\n eventBus: EventBus,\n private readonly canvas: Canvas,\n private readonly modeling: WardleyModeling,\n private readonly factory: WardleyElementFactory,\n ) {\n eventBus.on('element.dblclick', (event: { element?: unknown }) => {\n if (isWardleyShape(event.element)) this.activate(event.element);\n });\n // Click/drag/pan outside the field = SAVE (not discard). Only Escape discards.\n eventBus.on(['element.mousedown', 'drag.init', 'canvas.viewbox.changing'], () =>\n this.active?.commit(),\n );\n }\n\n activate(element: WardleyShape): void {\n this.active?.commit();\n\n const container = this.canvas.getContainer();\n const scale = this.canvas.zoom();\n const vb = this.canvas.viewbox();\n const isNote = element.wardleyType === 'note';\n const left = (element.x + element.width + 6 - vb.x) * scale;\n const top = (element.y + element.height / 2 - 11 - vb.y) * scale;\n\n const field = document.createElement(isNote ? 'textarea' : 'input') as\n | HTMLInputElement\n | HTMLTextAreaElement;\n field.className = isNote ? 'wardley-label-input wardley-label-textarea' : 'wardley-label-input';\n field.value = element.wardleyLabel ?? '';\n if (isNote) {\n const ta = field as HTMLTextAreaElement;\n ta.rows = Math.max(2, field.value.split('\\n').length);\n ta.wrap = 'off';\n } else {\n (field as HTMLInputElement).type = 'text';\n }\n field.style.position = 'absolute';\n field.style.left = `${left}px`;\n field.style.top = `${top}px`;\n container.appendChild(field);\n field.focus();\n field.select();\n\n let done = false;\n const cleanup = () => {\n if (done) return;\n done = true;\n field.removeEventListener('keydown', onKey as EventListener);\n field.removeEventListener('blur', onBlur);\n field.remove();\n this.active = null;\n };\n const commit = () => {\n if (done) return;\n const value = field.value.trim();\n const changed = value && value !== element.wardleyLabel;\n cleanup();\n if (!changed) return;\n // Enforce uniqueness only for linkable nodes (duplicate names would collapse nodes on the\n // DSL round-trip -> arrows disappear). Notes are never edge endpoints and may therefore\n // repeat (e.g. several \"Risk\" hints).\n const finalLabel = isNote ? value : this.factory.uniqueLabel(value, element.id);\n this.modeling.updateLabel(element, finalLabel);\n };\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n e.preventDefault();\n cleanup();\n return;\n }\n if (e.key === 'Enter') {\n // Note: save only with Cmd/Ctrl -> otherwise line break. Others: Enter saves.\n if (isNote && !(e.metaKey || e.ctrlKey)) return;\n e.preventDefault();\n commit();\n }\n };\n const onBlur = () => commit();\n field.addEventListener('keydown', onKey as EventListener);\n field.addEventListener('blur', onBlur);\n\n this.active = { field, commit, cleanup };\n }\n\n cancel(): void {\n this.active?.cleanup();\n }\n}\n","import type { ModuleDeclaration } from 'didi';\nimport WardleyLabelEditing from './WardleyLabelEditing.js';\n\n/** Custom inline label editing (HTML overlay). */\nexport const labelEditingModule: ModuleDeclaration = {\n __init__: ['wardleyLabelEditing'],\n wardleyLabelEditing: ['type', WardleyLabelEditing],\n};\n\nexport { default as WardleyLabelEditing } from './WardleyLabelEditing.js';\n","import type Canvas from 'diagram-js/lib/core/Canvas';\nimport type CommandStack from 'diagram-js/lib/command/CommandStack';\nimport type Selection from 'diagram-js/lib/features/selection/Selection';\nimport type Modeling from 'diagram-js/lib/features/modeling/Modeling';\nimport type { Element } from 'diagram-js/lib/model/Types';\n\n/**\n * Minimal keyboard binding on the canvas container: undo/redo and deleting the selection.\n * Deliberately a DOM listener (no diagram-js keyboard-service binding needed).\n */\nexport default class WardleyKeyboard {\n static $inject = ['canvas', 'commandStack', 'selection', 'modeling'];\n\n constructor(\n canvas: Canvas,\n commandStack: CommandStack,\n selection: Selection,\n modeling: Modeling,\n ) {\n const container = canvas.getContainer();\n if (!container.hasAttribute('tabindex')) container.setAttribute('tabindex', '0');\n\n container.addEventListener('keydown', (e: KeyboardEvent) => {\n // If the user is currently typing in an input field, do NOT intercept: inline label editing\n // (WardleyLabelEditing) attaches its <input>/<textarea> to THIS container, so keydown bubbles\n // up to here. Without the guard, Backspace/Delete would delete the selected element (instead\n // of a character) and Cmd+Z would reset the diagram instead of the text.\n if (isEditableTarget(e.target)) return;\n\n const cmd = e.ctrlKey || e.metaKey;\n const key = e.key.toLowerCase();\n\n if (cmd && key === 'z' && !e.shiftKey) {\n e.preventDefault();\n commandStack.undo();\n } else if ((cmd && key === 'z' && e.shiftKey) || (cmd && key === 'y')) {\n e.preventDefault();\n commandStack.redo();\n } else if (key === 'delete' || key === 'backspace') {\n const sel = selection.get() as Element[];\n if (sel.length) {\n e.preventDefault();\n modeling.removeElements(sel);\n }\n }\n });\n }\n}\n\nfunction isEditableTarget(target: EventTarget | null): boolean {\n if (!(target instanceof HTMLElement)) return false;\n const tag = target.tagName;\n return tag === 'INPUT' || tag === 'TEXTAREA' || target.isContentEditable;\n}\n","import type { ModuleDeclaration } from 'didi';\nimport WardleyKeyboard from './WardleyKeyboard.js';\n\n/** Undo/redo/delete via keyboard on the canvas container. */\nexport const wardleyKeyboardModule: ModuleDeclaration = {\n __init__: ['wardleyKeyboard'],\n wardleyKeyboard: ['type', WardleyKeyboard],\n};\n\nexport { default as WardleyKeyboard } from './WardleyKeyboard.js';\n","import type EventBus from 'diagram-js/lib/core/EventBus';\nimport type Dragging from 'diagram-js/lib/features/dragging/Dragging';\nimport type Canvas from 'diagram-js/lib/core/Canvas';\nimport type ElementRegistry from 'diagram-js/lib/core/ElementRegistry';\nimport type { Movement } from '@miragon/wardley-schema-model';\nimport type EvolutionGrid from '../evolution-grid/EvolutionGrid.js';\nimport type WardleyModeling from '../modeling/WardleyModeling.js';\nimport type { WardleyShape } from '../model/di-types.js';\n\nconst PREFIX = 'wardley.evolve';\nconst MIN_DELTA = 0.005;\n/** CSS class of the red target circle (set by the renderer) — direct drag handle. */\nconst HANDLE_CLASS = 'wardley-evolve-handle';\n\ninterface EvolveContext {\n shape: WardleyShape;\n originalMovement?: Movement;\n target?: number;\n committed?: boolean;\n}\n\nfunction clamp01(n: number): number {\n return n < 0 ? 0 : n > 1 ? 1 : n;\n}\n\n/**\n * Sets a component's evolve target by dragging along the evolution axis (instead of a text field).\n * During the drag a live preview (direct mutation + re-render); on release exactly ONE\n * undoable commit via the commandStack (P4). ESC cancels and restores the original state.\n */\nexport default class WardleyEvolveDragging {\n static $inject = [\n 'eventBus',\n 'dragging',\n 'evolutionGrid',\n 'wardleyModeling',\n 'canvas',\n 'elementRegistry',\n ];\n\n constructor(\n eventBus: EventBus,\n private readonly dragging: Dragging,\n grid: EvolutionGrid,\n modeling: WardleyModeling,\n canvas: Canvas,\n elementRegistry: ElementRegistry,\n ) {\n const preview = (shape: WardleyShape, movement: Movement | undefined) => {\n if (movement === undefined) delete shape.movement;\n else shape.movement = movement;\n eventBus.fire('element.changed', { element: shape });\n };\n\n // Screen pixels -> normalized evolution (via the single source of math, P7).\n const evolutionAtClientX = (clientX: number, cy: number): number => {\n const rect = canvas.getContainer().getBoundingClientRect();\n const vb = canvas.viewbox();\n const canvasX = vb.x + (clientX - rect.left) * (vb.width / rect.width);\n return clamp01(grid.fromCanvas({ x: canvasX, y: cy }).evolution);\n };\n\n // Direct handle: mousedown on the red target circle moves the evolve target by dragging.\n // Capture phase + stopPropagation so that diagram-js does NOT move the node instead.\n // Own document listeners (instead of dragging.init) — reliable, testable mousedown dragging.\n // Delegated on the container -> survives the re-rendering of the circle during the preview.\n canvas.getContainer().addEventListener(\n 'mousedown',\n (event: MouseEvent) => {\n const dom = event.target as Element | null;\n if (!dom?.closest(`.${HANDLE_CLASS}`)) return;\n const id = dom.closest('[data-element-id]')?.getAttribute('data-element-id');\n const shape = id ? (elementRegistry.get(id) as WardleyShape | undefined) : undefined;\n if (!shape || shape.wardleyType !== 'component') return;\n event.stopPropagation();\n event.preventDefault();\n\n const original = shape.movement;\n const cy = shape.y + shape.height / 2;\n let target: number | undefined;\n const onMove = (e: MouseEvent) => {\n target = evolutionAtClientX(e.clientX, cy);\n preview(shape, { targetEvolution: target });\n };\n const onUp = () => {\n document.removeEventListener('mousemove', onMove);\n document.removeEventListener('mouseup', onUp);\n preview(shape, original); // reset preview, then ONE undoable commit (P4)\n if (target !== undefined && Math.abs(target - shape.evolution) > MIN_DELTA) {\n modeling.evolveComponent(shape, target);\n }\n };\n document.addEventListener('mousemove', onMove);\n document.addEventListener('mouseup', onUp);\n },\n true,\n );\n\n eventBus.on(`${PREFIX}.move`, (event: { context: EvolveContext; x: number }) => {\n const { shape } = event.context;\n const cy = shape.y + shape.height / 2;\n const target = clamp01(grid.fromCanvas({ x: event.x, y: cy }).evolution);\n event.context.target = target;\n preview(shape, { targetEvolution: target });\n });\n\n eventBus.on(`${PREFIX}.end`, (event: { context: EvolveContext }) => {\n const ctx = event.context;\n const { shape, target } = ctx;\n // Reset the preview, then execute as ONE command (clean undo).\n preview(shape, ctx.originalMovement);\n if (target !== undefined && Math.abs(target - shape.evolution) > MIN_DELTA) {\n modeling.evolveComponent(shape, target);\n }\n ctx.committed = true;\n });\n\n eventBus.on(`${PREFIX}.cleanup`, (event: { context?: EvolveContext }) => {\n const ctx = event.context;\n if (ctx && !ctx.committed) preview(ctx.shape, ctx.originalMovement);\n });\n }\n\n /** Starts the evolve drag for `shape` (from the context pad): set the target by dragging along\n * the axis, or move it afterwards, with live preview; commit on release. */\n start(event: Event, shape: WardleyShape): void {\n const context: EvolveContext = {\n shape,\n ...(shape.movement ? { originalMovement: shape.movement } : {}),\n };\n this.dragging.init(event as MouseEvent, PREFIX, { cursor: 'ew-resize', data: { context } });\n }\n}\n","import type { ModuleDeclaration } from 'didi';\nimport WardleyEvolveDragging from './WardleyEvolveDragging.js';\n\nexport const wardleyEvolveModule: ModuleDeclaration = {\n __init__: ['wardleyEvolveDragging'],\n wardleyEvolveDragging: ['type', WardleyEvolveDragging],\n};\n\nexport { default as WardleyEvolveDragging } from './WardleyEvolveDragging.js';\n","import type EventBus from 'diagram-js/lib/core/EventBus';\nimport type { Injector } from 'didi';\n\ninterface ConnectionPreviewLike {\n drawPreview(context: object, canConnect: unknown, hints: object): void;\n cleanUp(context: object): void;\n}\n\ninterface LabelEditingLike {\n activate(element: object): void;\n}\n\ninterface SourceShape {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\ninterface CreateEvent {\n x: number;\n y: number;\n context: {\n source?: SourceShape;\n shape?: object;\n canExecute?: { connect?: unknown } | false | null;\n };\n}\n\n// diagram-js runs listeners in descending priority order; the default create.end handler (creation)\n// sits at 1000 -> with < 1000 we run AFTERWARDS, once the shape already exists.\nconst AFTER_CREATE = 500;\n\n/**\n * Behavior for \"append component\" (`create.start` with `context.source`):\n * 1. LIVE arrow preview from the source to the cursor (analogous to diagram-js ConnectPreview, but\n * in the create flow) — requires the `connectionPreview` service (ConnectionPreviewModule).\n * 2. After creation, automatically opens the new component's label editor so it can be named\n * (uniquely) right away.\n * Both only when `context.source` is set; ordinary palette-create stays untouched.\n */\nexport default class WardleyAppendBehavior {\n static $inject = ['injector', 'eventBus'];\n\n constructor(injector: Injector, eventBus: EventBus) {\n const connectionPreview = injector.get(\n 'connectionPreview',\n false,\n ) as ConnectionPreviewLike | null;\n const labelEditing = injector.get('wardleyLabelEditing', false) as LabelEditingLike | null;\n\n // (1) arrow preview\n if (connectionPreview) {\n eventBus.on('create.move', (event: CreateEvent) => {\n const { context } = event;\n const source = context.source;\n if (!source) return;\n const canConnect =\n context.canExecute && (context.canExecute as { connect?: unknown }).connect;\n connectionPreview.drawPreview(context, canConnect ?? false, {\n source,\n connectionStart: { x: source.x + source.width / 2, y: source.y + source.height / 2 },\n connectionEnd: { x: event.x, y: event.y },\n });\n });\n\n eventBus.on(\n ['create.end', 'create.cancel', 'create.cleanup'],\n (event: { context: object }) => {\n connectionPreview.cleanUp(event.context);\n },\n );\n }\n\n // (2) automatically open the label editor after appending\n if (labelEditing) {\n eventBus.on('create.end', AFTER_CREATE, (event: CreateEvent) => {\n const { context } = event;\n if (!context.source || !context.canExecute || !context.shape) return;\n const shape = context.shape;\n // Activate only after render/cleanup so the editor is positioned correctly.\n setTimeout(() => labelEditing.activate(shape), 0);\n });\n }\n }\n}\n","import type { ModuleDeclaration } from 'didi';\nimport ConnectionPreviewModule from 'diagram-js/lib/features/connection-preview';\nimport WardleyAppendBehavior from './WardleyAppendBehavior.js';\n\n/**\n * \"Append component\": pulls in the `connectionPreview` service (thereby also enabling the connect\n * tool's arrow preview) and registers the append behavior (live arrow preview + automatically\n * opening the label editor after creation).\n */\nexport const wardleyAppendModule: ModuleDeclaration = {\n __depends__: [ConnectionPreviewModule],\n __init__: ['wardleyAppendBehavior'],\n wardleyAppendBehavior: ['type', WardleyAppendBehavior],\n};\n\nexport { default as WardleyAppendBehavior } from './WardleyAppendBehavior.js';\n","import type Canvas from 'diagram-js/lib/core/Canvas';\nimport type EventBus from 'diagram-js/lib/core/EventBus';\nimport type WardleyModeling from '../modeling/WardleyModeling.js';\nimport type { WardleyShape } from '../model/di-types.js';\nimport { NOTE_COLORS } from '../draw/styles.js';\n\n/**\n * Compact color picker (bpmn.io-style): a 3x3 grid of small color squares (no text), opened from a\n * note's context pad. Uses its own popover (instead of diagram-js PopupMenu) so the swatch grid can\n * be rendered exactly and without text. Sets the color via `wardleyModeling` (undo/redo). First\n * cell = \"no color\".\n */\nexport default class WardleyColorPicker {\n static $inject = ['canvas', 'eventBus', 'wardleyModeling'];\n\n private popover: HTMLElement | undefined;\n\n private readonly onDocPointer = (e: MouseEvent): void => {\n if (this.popover && !this.popover.contains(e.target as Node)) this.close();\n };\n private readonly onKey = (e: KeyboardEvent): void => {\n if (e.key === 'Escape') this.close();\n };\n\n constructor(\n private readonly canvas: Canvas,\n eventBus: EventBus,\n private readonly modeling: WardleyModeling,\n ) {\n // Close on pan/zoom, drag or re-import (otherwise the popover ends up misplaced).\n eventBus.on(['canvas.viewbox.changing', 'drag.init', 'diagram.clear'], () => this.close());\n }\n\n /** Opens the swatch grid for `shape` at the click position (viewport coordinates). */\n open(shape: WardleyShape, clientX: number, clientY: number): void {\n this.close();\n const container = this.canvas.getContainer();\n const rect = container.getBoundingClientRect();\n\n const pop = document.createElement('div');\n pop.className = 'wardley-color-picker';\n\n const swatches: ReadonlyArray<{ value: string | undefined; title: string; cls: string }> = [\n { value: undefined, title: 'No color', cls: 'wardley-cp-none' },\n ...NOTE_COLORS.map((c) => ({ value: c.value as string, title: c.name, cls: '' })),\n ];\n for (const s of swatches) {\n const btn = document.createElement('button');\n btn.type = 'button';\n btn.className = `wardley-cp-swatch ${s.cls}`.trim();\n btn.title = s.title;\n if (s.value) btn.style.background = s.value;\n if ((shape.color ?? undefined) === s.value) btn.classList.add('wardley-cp-active');\n btn.addEventListener('click', (ev) => {\n ev.stopPropagation();\n this.modeling.setColor(shape, s.value);\n this.close();\n });\n pop.append(btn);\n }\n\n container.appendChild(pop);\n\n // Keep it within the (overflow:hidden) container.\n const cw = container.clientWidth;\n const ch = container.clientHeight;\n const pw = pop.offsetWidth;\n const ph = pop.offsetHeight;\n const left = Math.max(4, Math.min(clientX - rect.left, cw - pw - 4));\n const top = Math.max(4, Math.min(clientY - rect.top, ch - ph - 4));\n pop.style.left = `${left}px`;\n pop.style.top = `${top}px`;\n\n this.popover = pop;\n // Attach listeners with a delay so the opening click does not immediately close the popover.\n setTimeout(() => {\n document.addEventListener('click', this.onDocPointer, true);\n document.addEventListener('keydown', this.onKey, true);\n }, 0);\n }\n\n close(): void {\n if (!this.popover) return;\n this.popover.remove();\n this.popover = undefined;\n document.removeEventListener('click', this.onDocPointer, true);\n document.removeEventListener('keydown', this.onKey, true);\n }\n}\n","import type { ModuleDeclaration } from 'didi';\nimport WardleyColorPicker from './WardleyColorPicker.js';\n\n/** Note color picker (3x3 swatch popover). */\nexport const wardleyColorPickerModule: ModuleDeclaration = {\n __init__: ['wardleyColorPicker'],\n wardleyColorPicker: ['type', WardleyColorPicker],\n};\n\nexport { default as WardleyColorPicker } from './WardleyColorPicker.js';\n","import type { ModuleDeclaration } from 'didi';\nimport type CommandStack from 'diagram-js/lib/command/CommandStack';\n\nimport ModelingModule from 'diagram-js/lib/features/modeling';\nimport MoveModule from 'diagram-js/lib/features/move';\nimport CreateModule from 'diagram-js/lib/features/create';\nimport ConnectModule from 'diagram-js/lib/features/connect';\nimport ContextPadModule from 'diagram-js/lib/features/context-pad';\nimport PaletteModule from 'diagram-js/lib/features/palette';\nimport RulesModule from 'diagram-js/lib/features/rules';\nimport OutlineModule from 'diagram-js/lib/features/outline';\nimport ResizeModule from 'diagram-js/lib/features/resize';\nimport PopupMenuModule from 'diagram-js/lib/features/popup-menu';\n\nimport { NavigatedViewer } from './NavigatedViewer.js';\nimport { wardleyModelingModule } from './modeling/index.js';\nimport { wardleyRulesModule } from './rules/index.js';\nimport { evolutionConstraintModule } from './evolution-grid/index.js';\nimport { stageSnappingModule } from './snapping/index.js';\nimport { wardleyPaletteModule } from './palette/index.js';\nimport { wardleyContextPadModule } from './context-pad/index.js';\nimport { labelEditingModule } from './label-editing/index.js';\nimport { wardleyKeyboardModule } from './keyboard/index.js';\nimport { wardleyEvolveModule } from './evolve/index.js';\nimport { wardleyPopupModule } from './popup/index.js';\nimport { wardleyAppendModule } from './append/index.js';\nimport { wardleyColorPickerModule } from './color-picker/index.js';\n\n/**\n * Full Wardley editor: palette/create, move with EvolutionConstraint + stage snapping, connect with\n * rules, context pad, inline label editing, undo/redo (concept doc §6.1, roadmap M3).\n */\nexport class Modeler extends NavigatedViewer {\n protected override _getModules(): ModuleDeclaration[] {\n return [\n ...super._getModules(),\n ModelingModule,\n RulesModule,\n MoveModule,\n CreateModule,\n ConnectModule,\n ContextPadModule,\n PaletteModule,\n OutlineModule,\n ResizeModule,\n PopupMenuModule,\n wardleyModelingModule,\n wardleyRulesModule,\n evolutionConstraintModule,\n stageSnappingModule,\n wardleyPaletteModule,\n wardleyContextPadModule,\n labelEditingModule,\n wardleyKeyboardModule,\n wardleyEvolveModule,\n wardleyPopupModule,\n wardleyAppendModule,\n wardleyColorPickerModule,\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":";;;;;;;;;;;;;;;;;;;;;;;AACA,IAAa,IAAO;CAClB,OAAO;CACP,QAAQ;CACR,YAAY;CACZ,WAAW;CACX,aAAa;CACb,cAAc;AAChB,GAEa,KAAW;CAAE,OAAO;CAAK,QAAQ;AAAI,GAU5C,KAAa,GACb,KAAa,GAIb,KAAc;AAMpB,SAAgB,EAAY,GAAmE;CAC7F,IAAM,KAAS,KAAS,EAAM,SAAS,IAAQ,QAAQ,MAAM,IAAI,GAC3D,IAAS,KAAK,IAAI,GAAG,GAAG,EAAM,KAAK,MAAM,EAAE,MAAM,CAAC;CACxD,OAAO;EACL;EACA,OAAO,KAAK,IAAA,IAAe,KAAK,MAAM,IAAS,EAAW,IAAI,KAAa,CAAC;EAC5E,QAAQ,KAAK,IAAA,IAAe,EAAM,SAAA,KAA4B,KAAa,CAAC;CAC9E;AACF;AAEA,IAAa,IAAS;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F;CACF;CAEA,OAAa;EACX,KAAK,IAAkB,cAAc,EAAE,KAAK;CAC9C;CAEA,OAAa;EACX,KAAK,IAAkB,cAAc,EAAE,KAAK;CAC9C;CAEA,UAAmB;EACjB,OAAO,KAAK,IAAkB,cAAc,EAAE,QAAQ;CACxD;CAEA,UAAmB;EACjB,OAAO,KAAK,IAAkB,cAAc,EAAE,QAAQ;CACxD;AACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { default as Canvas } from 'diagram-js/lib/core/Canvas';
|
|
2
|
+
import { default as ElementRegistry } from 'diagram-js/lib/core/ElementRegistry';
|
|
3
|
+
import { WardleyMap } from '@miragon/wardley-schema-model';
|
|
4
|
+
/**
|
|
5
|
+
* Reconstructs a WardleyMap from the diagram-js runtime model. The source of truth for positions are
|
|
6
|
+
* the DI properties `evolution`/`visibility`; editable fields (label, decorators, movement,
|
|
7
|
+
* pipeline range) are likewise read from the DI properties (concept doc §5.6). The
|
|
8
|
+
* `businessObject` serves only as a fallback for type-specific fields that are not (yet) editable.
|
|
9
|
+
*/
|
|
10
|
+
export default class WardleyExporter {
|
|
11
|
+
private readonly elementRegistry;
|
|
12
|
+
private readonly canvas;
|
|
13
|
+
static $inject: string[];
|
|
14
|
+
constructor(elementRegistry: ElementRegistry, canvas: Canvas);
|
|
15
|
+
export(): WardleyMap;
|
|
16
|
+
/** Builds a MapElement from the DI properties (common types) or the businessObject (the rest). */
|
|
17
|
+
private buildElement;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=WardleyExporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WardleyExporter.d.ts","sourceRoot":"","sources":["../../src/io/WardleyExporter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,4BAA4B,CAAC;AACrD,OAAO,KAAK,eAAe,MAAM,qCAAqC,CAAC;AAEvE,OAAO,EAUL,KAAK,UAAU,EAChB,MAAM,+BAA+B,CAAC;AAUvC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe;IAIhC,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,UAAU;IAsCpB,kGAAkG;IAClG,OAAO,CAAC,YAAY;CA+ErB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { WardleyMap } from '@miragon/wardley-schema-model';
|
|
6
|
+
import { default as EvolutionGrid } from '../evolution-grid/EvolutionGrid.js';
|
|
7
|
+
import { default as WardleyElementFactory } from '../model/WardleyElementFactory.js';
|
|
8
|
+
import { ImportWarning } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Bridges the WardleyMap model into the diagram-js canvas.
|
|
11
|
+
* Uses `evolutionGrid` exclusively for the pixel projection (P7). Deliberately bypasses the
|
|
12
|
+
* commandStack (import path, P4 exception): no undo, no dirty (concept doc §5.6).
|
|
13
|
+
*/
|
|
14
|
+
export default class WardleyImporter {
|
|
15
|
+
private readonly canvas;
|
|
16
|
+
private readonly elementFactory;
|
|
17
|
+
private readonly factory;
|
|
18
|
+
private readonly grid;
|
|
19
|
+
private readonly eventBus;
|
|
20
|
+
private readonly elementRegistry;
|
|
21
|
+
static $inject: string[];
|
|
22
|
+
constructor(canvas: Canvas, elementFactory: ElementFactory, factory: WardleyElementFactory, grid: EvolutionGrid, eventBus: EventBus, elementRegistry: ElementRegistry);
|
|
23
|
+
import(map: WardleyMap): ImportWarning[];
|
|
24
|
+
private createShape;
|
|
25
|
+
clear(): void;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=WardleyImporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WardleyImporter.d.ts","sourceRoot":"","sources":["../../src/io/WardleyImporter.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,EAAc,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,KAAK,aAAa,MAAM,oCAAoC,CAAC;AACpE,OAAO,KAAK,qBAAqB,MAAM,mCAAmC,CAAC;AAE3E,OAAO,EAAW,KAAK,aAAa,EAA2B,MAAM,YAAY,CAAC;AAiBlF;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe;IAWhC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAflC,MAAM,CAAC,OAAO,WAOZ;gBAGiB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,qBAAqB,EAC9B,IAAI,EAAE,aAAa,EACnB,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,eAAe;IAGnD,MAAM,CAAC,GAAG,EAAE,UAAU,GAAG,aAAa,EAAE;IA6ExC,OAAO,CAAC,WAAW;IA0BnB,KAAK,IAAI,IAAI;CAYd"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ModuleDeclaration } from 'didi';
|
|
2
|
+
export declare const ioModule: ModuleDeclaration;
|
|
3
|
+
export { default as WardleyImporter } from './WardleyImporter.js';
|
|
4
|
+
export { default as WardleyExporter } from './WardleyExporter.js';
|
|
5
|
+
export { saveSVG } from './saveSvg.js';
|
|
6
|
+
export { ROOT_ID } from './types.js';
|
|
7
|
+
export type { ImportWarning, 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,eAAO,MAAM,QAAQ,EAAE,iBAGtB,CAAC;AAEF,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { default as Canvas } from 'diagram-js/lib/core/Canvas';
|
|
2
|
+
/**
|
|
3
|
+
* Serializes the current canvas into standalone SVG (snapshot/export).
|
|
4
|
+
* Sets a fixed viewBox to the outer plot bounds so the result is independent of the
|
|
5
|
+
* current zoom/scroll.
|
|
6
|
+
*/
|
|
7
|
+
export declare function saveSVG(canvas: Canvas): {
|
|
8
|
+
svg: string;
|
|
9
|
+
};
|
|
10
|
+
//# 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;AAGrD;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAqBvD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MapConfig } from '@miragon/wardley-schema-model';
|
|
2
|
+
/** ID of the diagram-js root element of the Wardley map. */
|
|
3
|
+
export declare const ROOT_ID = "wardley-root";
|
|
4
|
+
export interface ImportWarning {
|
|
5
|
+
readonly message: string;
|
|
6
|
+
readonly elementId?: string;
|
|
7
|
+
}
|
|
8
|
+
/** Map metadata stored on the root element (config + lossless passthrough). */
|
|
9
|
+
export interface RootBusinessObject {
|
|
10
|
+
readonly config: MapConfig;
|
|
11
|
+
readonly rawPassthrough?: readonly string[];
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/io/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE/D,4DAA4D;AAC5D,eAAO,MAAM,OAAO,iBAAiB,CAAC;AAEtC,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,+EAA+E;AAC/E,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7C"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default as Canvas } from 'diagram-js/lib/core/Canvas';
|
|
2
|
+
import { default as CommandStack } from 'diagram-js/lib/command/CommandStack';
|
|
3
|
+
import { default as Selection } from 'diagram-js/lib/features/selection/Selection';
|
|
4
|
+
import { default as Modeling } from 'diagram-js/lib/features/modeling/Modeling';
|
|
5
|
+
/**
|
|
6
|
+
* Minimal keyboard binding on the canvas container: undo/redo and deleting the selection.
|
|
7
|
+
* Deliberately a DOM listener (no diagram-js keyboard-service binding needed).
|
|
8
|
+
*/
|
|
9
|
+
export default class WardleyKeyboard {
|
|
10
|
+
static $inject: string[];
|
|
11
|
+
constructor(canvas: Canvas, commandStack: CommandStack, selection: Selection, modeling: Modeling);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=WardleyKeyboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WardleyKeyboard.d.ts","sourceRoot":"","sources":["../../src/keyboard/WardleyKeyboard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,4BAA4B,CAAC;AACrD,OAAO,KAAK,YAAY,MAAM,qCAAqC,CAAC;AACpE,OAAO,KAAK,SAAS,MAAM,6CAA6C,CAAC;AACzE,OAAO,KAAK,QAAQ,MAAM,2CAA2C,CAAC;AAGtE;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,MAAM,CAAC,OAAO,WAAuD;gBAGnE,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ;CA8BrB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ModuleDeclaration } from 'didi';
|
|
2
|
+
/** Undo/redo/delete via keyboard on the canvas container. */
|
|
3
|
+
export declare const wardleyKeyboardModule: ModuleDeclaration;
|
|
4
|
+
export { default as WardleyKeyboard } from './WardleyKeyboard.js';
|
|
5
|
+
//# 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;AAG9C,6DAA6D;AAC7D,eAAO,MAAM,qBAAqB,EAAE,iBAGnC,CAAC;AAEF,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { default as Canvas } from 'diagram-js/lib/core/Canvas';
|
|
2
|
+
import { default as EventBus } from 'diagram-js/lib/core/EventBus';
|
|
3
|
+
import { WardleyShape } from '../model/di-types.js';
|
|
4
|
+
import { default as WardleyModeling } from '../modeling/WardleyModeling.js';
|
|
5
|
+
import { default as WardleyElementFactory } from '../model/WardleyElementFactory.js';
|
|
6
|
+
/**
|
|
7
|
+
* Custom inline label editing as an HTML overlay (deliberately not diagram-js direct-editing, §8.5).
|
|
8
|
+
* Commit goes through `wardleyModeling.updateLabel` -> commandStack (undo, P4).
|
|
9
|
+
* Notes are edited in a `<textarea>` (multiline: Enter = line break, Cmd/Ctrl+Enter or click outside
|
|
10
|
+
* = save); everything else in an `<input>` (Enter = save).
|
|
11
|
+
*/
|
|
12
|
+
export default class WardleyLabelEditing {
|
|
13
|
+
private readonly canvas;
|
|
14
|
+
private readonly modeling;
|
|
15
|
+
private readonly factory;
|
|
16
|
+
static $inject: string[];
|
|
17
|
+
private active;
|
|
18
|
+
constructor(eventBus: EventBus, canvas: Canvas, modeling: WardleyModeling, factory: WardleyElementFactory);
|
|
19
|
+
activate(element: WardleyShape): void;
|
|
20
|
+
cancel(): void;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=WardleyLabelEditing.d.ts.map
|