@aranzatech/diagrams-bpmn 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/chunk-23B2IGK5.js +24 -0
  2. package/dist/chunk-23B2IGK5.js.map +1 -0
  3. package/dist/chunk-3AFZDIMQ.js +286 -0
  4. package/dist/chunk-3AFZDIMQ.js.map +1 -0
  5. package/dist/chunk-4OAEWYYU.js +579 -0
  6. package/dist/chunk-4OAEWYYU.js.map +1 -0
  7. package/dist/chunk-57LA2WSJ.js +476 -0
  8. package/dist/chunk-57LA2WSJ.js.map +1 -0
  9. package/dist/chunk-6TUC5QX5.js +491 -0
  10. package/dist/chunk-6TUC5QX5.js.map +1 -0
  11. package/dist/chunk-MLUJKUTG.js +86 -0
  12. package/dist/chunk-MLUJKUTG.js.map +1 -0
  13. package/dist/chunk-NXMUX67A.js +1443 -0
  14. package/dist/chunk-NXMUX67A.js.map +1 -0
  15. package/dist/edges/index.cjs +300 -0
  16. package/dist/edges/index.cjs.map +1 -0
  17. package/dist/edges/index.d.cts +17 -0
  18. package/dist/edges/index.d.ts +17 -0
  19. package/dist/edges/index.js +4 -0
  20. package/dist/edges/index.js.map +1 -0
  21. package/dist/elements/index.cjs +587 -0
  22. package/dist/elements/index.cjs.map +1 -0
  23. package/dist/elements/index.d.cts +20 -0
  24. package/dist/elements/index.d.ts +20 -0
  25. package/dist/elements/index.js +4 -0
  26. package/dist/elements/index.js.map +1 -0
  27. package/dist/index.cjs +3442 -0
  28. package/dist/index.cjs.map +1 -0
  29. package/dist/index.d.cts +67 -0
  30. package/dist/index.d.ts +67 -0
  31. package/dist/index.js +45 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/nodes/index.cjs +1487 -0
  34. package/dist/nodes/index.cjs.map +1 -0
  35. package/dist/nodes/index.d.cts +45 -0
  36. package/dist/nodes/index.d.ts +45 -0
  37. package/dist/nodes/index.js +4 -0
  38. package/dist/nodes/index.js.map +1 -0
  39. package/dist/simulation/index.cjs +483 -0
  40. package/dist/simulation/index.cjs.map +1 -0
  41. package/dist/simulation/index.d.cts +62 -0
  42. package/dist/simulation/index.d.ts +62 -0
  43. package/dist/simulation/index.js +3 -0
  44. package/dist/simulation/index.js.map +1 -0
  45. package/dist/types-CxzazgBX.d.cts +111 -0
  46. package/dist/types-CxzazgBX.d.ts +111 -0
  47. package/dist/xml/index.cjs +1068 -0
  48. package/dist/xml/index.cjs.map +1 -0
  49. package/dist/xml/index.d.cts +24 -0
  50. package/dist/xml/index.d.ts +24 -0
  51. package/dist/xml/index.js +4 -0
  52. package/dist/xml/index.js.map +1 -0
  53. package/package.json +84 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/xml/mapper.ts","../src/xml/importer.ts","../src/xml/exporter.ts"],"names":["laneSet","BpmnModdle"],"mappings":";;;;AAIO,IAAM,sBAAA,GAAsE;AAAA,EACjF,iBAAA,EAA6B,YAAA;AAAA,EAC7B,eAAA,EAA6B,UAAA;AAAA,EAC7B,6BAAA,EAA+B,wBAAA;AAAA,EAC/B,6BAAA,EAA+B,wBAAA;AAAA,EAC/B,oBAAA,EAA6B,eAAA;AAAA,EAC7B,WAAA,EAA6B,MAAA;AAAA,EAC7B,eAAA,EAA6B,UAAA;AAAA,EAC7B,kBAAA,EAA6B,aAAA;AAAA,EAC7B,iBAAA,EAA6B,YAAA;AAAA,EAC7B,iBAAA,EAA6B,YAAA;AAAA,EAC7B,uBAAA,EAA6B,kBAAA;AAAA,EAC7B,kBAAA,EAA6B,aAAA;AAAA,EAC7B,eAAA,EAA6B,UAAA;AAAA,EAC7B,mBAAA,EAA6B,cAAA;AAAA,EAC7B,uBAAA,EAA6B,kBAAA;AAAA,EAC7B,uBAAA,EAA6B,kBAAA;AAAA,EAC7B,sBAAA,EAA6B,iBAAA;AAAA,EAC7B,wBAAA,EAA6B,mBAAA;AAAA,EAC7B,qBAAA,EAA6B,gBAAA;AAAA,EAC7B,iBAAA,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CAAK,EAAA,EAAG;AAAA,QAC3B,QAAA,EAAU;AAAA,OACX;AAAA,KACH;AAAA,EACF;AAGA,EAAA,MAAM,UAAW,WAAA,CAAwC,YAAA;AACzD,EAAA,MAAM,YAAA,GAAe,UAAU,CAAC,CAAA;AAEhC,EAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,MAAA,CAAO,kBAAA,EAAoB;AAAA,IAC9C,EAAA,EAAI,aAAA;AAAA,IACJ,WAAA,EAAa,YAAA,IAAgB,EAAE,EAAA,EAAI,SAAA,EAAU;AAAA,IAC7C,YAAA,EAAc,CAAC,GAAG,MAAA,EAAQ,GAAG,UAAU;AAAA,GACxC,CAAA;AAED,EAAA,MAAM,OAAA,GAAU,MAAA,CAAO,MAAA,CAAO,oBAAA,EAAsB;AAAA,IAClD,EAAA,EAAI,eAAA;AAAA,IACJ;AAAA,GACD,CAAA;AAED,EAAC,WAAA,CAAwC,QAAA,GAAW,CAAC,OAAO,CAAA;AAC9D;AAIA,eAAsB,gBAAA,CACpB,KAAA,EACA,KAAA,EACA,IAAA,GAA0B,EAAC,EACV;AACjB,EAAA,MAAM,MAAA,GAAS,IAAIC,UAAAA,EAAW;AAE9B,EAAA,MAAM,WAAA,GAAc,kBAAA,CAAmB,MAAA,EAAQ,KAAA,EAAO,OAAO,IAAI,CAAA;AACjE,EAAA,WAAA,CAAY,MAAA,EAAQ,WAAA,EAAa,KAAA,EAAO,KAAK,CAAA;AAE7C,EAAA,MAAM,EAAE,GAAA,EAAI,GAAI,MAAM,MAAA,CAAO,MAAM,WAAA,EAAa;AAAA,IAC9C,MAAA,EAAQ,KAAK,MAAA,IAAU;AAAA,GACxB,CAAA;AAED,EAAA,OAAO,GAAA;AACT","file":"chunk-4OAEWYYU.js","sourcesContent":["import type { BpmnElementType, BpmnEdgeType, EventTrigger } from \"../elements/types\";\n\n// ─── BPMN moddle $type → our BpmnElementType ─────────────────────────────────\n\nexport const MODDLE_TO_ELEMENT_TYPE: Record<string, BpmnElementType | undefined> = {\n \"bpmn:StartEvent\": \"StartEvent\",\n \"bpmn:EndEvent\": \"EndEvent\",\n \"bpmn:IntermediateCatchEvent\": \"IntermediateCatchEvent\",\n \"bpmn:IntermediateThrowEvent\": \"IntermediateThrowEvent\",\n \"bpmn:BoundaryEvent\": \"BoundaryEvent\",\n \"bpmn:Task\": \"Task\",\n \"bpmn:UserTask\": \"UserTask\",\n \"bpmn:ServiceTask\": \"ServiceTask\",\n \"bpmn:ScriptTask\": \"ScriptTask\",\n \"bpmn:ManualTask\": \"ManualTask\",\n \"bpmn:BusinessRuleTask\": \"BusinessRuleTask\",\n \"bpmn:ReceiveTask\": \"ReceiveTask\",\n \"bpmn:SendTask\": \"SendTask\",\n \"bpmn:CallActivity\": \"CallActivity\",\n \"bpmn:ExclusiveGateway\": \"ExclusiveGateway\",\n \"bpmn:InclusiveGateway\": \"InclusiveGateway\",\n \"bpmn:ParallelGateway\": \"ParallelGateway\",\n \"bpmn:EventBasedGateway\": \"EventBasedGateway\",\n \"bpmn:ComplexGateway\": \"ComplexGateway\",\n \"bpmn:SubProcess\": \"SubProcess\",\n \"bpmn:AdHocSubProcess\": \"SubProcess\",\n \"bpmn:Transaction\": \"SubProcess\",\n \"bpmn:TextAnnotation\": \"Annotation\",\n \"bpmn:Group\": \"Group\",\n \"bpmn:DataObject\": \"DataObject\",\n \"bpmn:DataObjectReference\": \"DataObjectReference\",\n \"bpmn:DataInput\": \"DataInput\",\n \"bpmn:DataOutput\": \"DataOutput\",\n \"bpmn:DataStore\": \"DataStore\",\n \"bpmn:DataStoreReference\": \"DataStoreReference\",\n \"bpmn:Conversation\": \"Conversation\",\n \"bpmn:SubConversation\": \"SubConversation\",\n \"bpmn:CallConversation\": \"CallConversation\",\n \"bpmn:ChoreographyTask\": \"ChoreographyTask\",\n \"bpmn:SubChoreography\": \"SubChoreography\",\n \"bpmn:CallChoreography\": \"CallChoreography\",\n \"bpmn:Lane\": \"Lane\",\n};\n\n// ─── Our BpmnElementType → canonical bpmn: type ──────────────────────────────\n\nexport const ELEMENT_TYPE_TO_MODDLE: Partial<Record<BpmnElementType, string>> = {\n StartEvent: \"bpmn:StartEvent\",\n EndEvent: \"bpmn:EndEvent\",\n IntermediateCatchEvent: \"bpmn:IntermediateCatchEvent\",\n IntermediateThrowEvent: \"bpmn:IntermediateThrowEvent\",\n BoundaryEvent: \"bpmn:BoundaryEvent\",\n Task: \"bpmn:Task\",\n UserTask: \"bpmn:UserTask\",\n ServiceTask: \"bpmn:ServiceTask\",\n ScriptTask: \"bpmn:ScriptTask\",\n ManualTask: \"bpmn:ManualTask\",\n BusinessRuleTask: \"bpmn:BusinessRuleTask\",\n ReceiveTask: \"bpmn:ReceiveTask\",\n SendTask: \"bpmn:SendTask\",\n CallActivity: \"bpmn:CallActivity\",\n ExclusiveGateway: \"bpmn:ExclusiveGateway\",\n InclusiveGateway: \"bpmn:InclusiveGateway\",\n ParallelGateway: \"bpmn:ParallelGateway\",\n EventBasedGateway: \"bpmn:EventBasedGateway\",\n ComplexGateway: \"bpmn:ComplexGateway\",\n SubProcess: \"bpmn:SubProcess\",\n Pool: \"bpmn:Participant\",\n Lane: \"bpmn:Lane\",\n Annotation: \"bpmn:TextAnnotation\",\n Group: \"bpmn:Group\",\n DataObject: \"bpmn:DataObject\",\n DataObjectReference: \"bpmn:DataObjectReference\",\n DataInput: \"bpmn:DataInput\",\n DataOutput: \"bpmn:DataOutput\",\n DataStore: \"bpmn:DataStore\",\n DataStoreReference: \"bpmn:DataStoreReference\",\n Conversation: \"bpmn:Conversation\",\n SubConversation: \"bpmn:SubConversation\",\n CallConversation: \"bpmn:CallConversation\",\n ChoreographyTask: \"bpmn:ChoreographyTask\",\n SubChoreography: \"bpmn:SubChoreography\",\n CallChoreography: \"bpmn:CallChoreography\",\n};\n\n// ─── Edge type mappings ───────────────────────────────────────────────────────\n\nexport const MODDLE_TO_EDGE_TYPE: Record<string, BpmnEdgeType | undefined> = {\n \"bpmn:SequenceFlow\": \"sequenceFlow\",\n \"bpmn:MessageFlow\": \"messageFlow\",\n \"bpmn:Association\": \"association\",\n \"bpmn:DataInputAssociation\": \"dataAssociation\",\n \"bpmn:DataOutputAssociation\": \"dataAssociation\",\n \"bpmn:ConversationLink\": \"conversationLink\",\n};\n\nexport const EDGE_TYPE_TO_MODDLE: Record<BpmnEdgeType, string> = {\n sequenceFlow: \"bpmn:SequenceFlow\",\n messageFlow: \"bpmn:MessageFlow\",\n association: \"bpmn:Association\",\n dataAssociation: \"bpmn:DataInputAssociation\",\n conversationLink:\"bpmn:ConversationLink\",\n};\n\n// ─── Event definition type → trigger ─────────────────────────────────────────\n\nexport const EVENT_DEF_TO_TRIGGER: Record<string, EventTrigger> = {\n \"bpmn:MessageEventDefinition\": \"message\",\n \"bpmn:TimerEventDefinition\": \"timer\",\n \"bpmn:EscalationEventDefinition\": \"escalation\",\n \"bpmn:ConditionalEventDefinition\": \"conditional\",\n \"bpmn:ErrorEventDefinition\": \"error\",\n \"bpmn:CancelEventDefinition\": \"cancel\",\n \"bpmn:CompensateEventDefinition\": \"compensation\",\n \"bpmn:SignalEventDefinition\": \"signal\",\n \"bpmn:LinkEventDefinition\": \"link\",\n \"bpmn:TerminateEventDefinition\": \"terminate\",\n};\n\nexport const TRIGGER_TO_EVENT_DEF: Partial<Record<EventTrigger, string>> = {\n message: \"bpmn:MessageEventDefinition\",\n timer: \"bpmn:TimerEventDefinition\",\n escalation: \"bpmn:EscalationEventDefinition\",\n conditional: \"bpmn:ConditionalEventDefinition\",\n error: \"bpmn:ErrorEventDefinition\",\n cancel: \"bpmn:CancelEventDefinition\",\n compensation: \"bpmn:CompensateEventDefinition\",\n signal: \"bpmn:SignalEventDefinition\",\n link: \"bpmn:LinkEventDefinition\",\n terminate: \"bpmn:TerminateEventDefinition\",\n};\n","import { BpmnModdle, type ModdleElement } from \"bpmn-moddle\";\nimport { BPMN_ELEMENT_CATALOG } from \"../elements/catalog\";\nimport type { BpmnElementType, BpmnEdgeType, BpmnNodeData, BpmnEdgeData, EventTrigger, SubProcessVariant } from \"../elements/types\";\nimport type { BpmnRFNode, BpmnRFEdge, BpmnImportResult } from \"./types\";\nimport {\n MODDLE_TO_ELEMENT_TYPE,\n MODDLE_TO_EDGE_TYPE,\n EVENT_DEF_TO_TRIGGER,\n} from \"./mapper\";\n\n// ─── Internal helpers ─────────────────────────────────────────────────────────\n\ninterface ShapeInfo {\n x: number;\n y: number;\n width: number;\n height: number;\n isExpanded?: boolean;\n}\n\ntype ShapeMap = Map<string, ShapeInfo>;\ntype WaypointMap = Map<string, Array<{ x: number; y: number }>>;\n\nfunction asElements(v: unknown): ModdleElement[] {\n return Array.isArray(v) ? (v as ModdleElement[]) : [];\n}\n\nfunction asString(v: unknown): string | undefined {\n return typeof v === \"string\" && v.trim() ? v.trim() : undefined;\n}\n\n// ─── Extract BPMNDI shape/edge positions ─────────────────────────────────────\n\nfunction extractDiagramInfo(definitions: ModdleElement): {\n shapes: ShapeMap;\n waypoints: WaypointMap;\n} {\n const shapes: ShapeMap = new Map();\n const waypoints: WaypointMap = new Map();\n\n for (const diagram of asElements(definitions.diagrams)) {\n const plane = diagram.plane as ModdleElement | undefined;\n if (!plane) continue;\n\n for (const el of asElements(plane.planeElement)) {\n const bpmnEl = el.bpmnElement as ModdleElement | undefined;\n if (!bpmnEl?.id) continue;\n const id = bpmnEl.id as string;\n\n if (el.$type === \"bpmndi:BPMNShape\") {\n const b = el.bounds as { x: number; y: number; width: number; height: number } | undefined;\n if (b) {\n shapes.set(id, {\n x: b.x,\n y: b.y,\n width: b.width,\n height: b.height,\n ...(typeof el.isExpanded === \"boolean\" ? { isExpanded: el.isExpanded as boolean } : {}),\n });\n }\n } else if (el.$type === \"bpmndi:BPMNEdge\") {\n const pts = (el.waypoint ?? []) as Array<{ x: number; y: number }>;\n if (pts.length) waypoints.set(id, pts);\n }\n }\n }\n\n return { shapes, waypoints };\n}\n\n// ─── Lane membership (flowNodeId → laneId) ───────────────────────────────────\n\nfunction extractLaneMembership(process: ModdleElement): Map<string, string> {\n const map = new Map<string, string>();\n\n function walkLaneSet(laneSet: ModdleElement) {\n for (const lane of asElements(laneSet.lanes)) {\n const laneId = lane.id as string | undefined;\n if (!laneId) continue;\n for (const ref of asElements(lane.flowNodeRef)) {\n if (ref.id) map.set(ref.id as string, laneId);\n }\n const child = lane.childLaneSet as ModdleElement | undefined;\n if (child) walkLaneSet(child);\n }\n }\n\n const laneSet = process.laneSet as ModdleElement | undefined;\n if (laneSet) walkLaneSet(laneSet);\n return map;\n}\n\n// ─── Event trigger from eventDefinitions ─────────────────────────────────────\n\nfunction extractTrigger(el: ModdleElement): EventTrigger | undefined {\n const defs = asElements(el.eventDefinitions);\n if (defs.length === 0) return undefined;\n if (defs.length > 1) return el.$type.includes(\"Parallel\") ? \"parallelMultiple\" : \"multiple\";\n return EVENT_DEF_TO_TRIGGER[defs[0].$type];\n}\n\n// ─── SubProcessVariant from moddle type / properties ─────────────────────────\n\nfunction extractSubProcessVariant(el: ModdleElement): SubProcessVariant | undefined {\n if (el.$type === \"bpmn:Transaction\") return \"transaction\";\n if (el.$type === \"bpmn:AdHocSubProcess\") return \"adhoc\";\n if (el.triggeredByEvent === true) return \"event\";\n return \"embedded\";\n}\n\n// ─── Walk a flowElements list, producing nodes and edges ─────────────────────\n\ninterface WalkContext {\n shapes: ShapeMap;\n waypoints: WaypointMap;\n laneMembership: Map<string, string>;\n warnings: string[];\n autoX: { value: number };\n}\n\nfunction walkFlowElements(\n elements: ModdleElement[],\n parentId: string | undefined,\n ctx: WalkContext,\n nodes: BpmnRFNode[],\n edges: BpmnRFEdge[],\n) {\n for (const el of elements) {\n const { $type, id } = el;\n if (!id) continue;\n\n const edgeType = MODDLE_TO_EDGE_TYPE[$type];\n if (edgeType !== undefined) {\n buildEdge(el, edgeType, ctx, edges);\n continue;\n }\n\n // Lane nodes are handled separately via laneMembership\n if ($type === \"bpmn:LaneSet\") continue;\n\n const elementType = MODDLE_TO_ELEMENT_TYPE[$type];\n if (!elementType) {\n ctx.warnings.push(`Unknown element type \"${$type}\" (id=${id as string}) — skipped.`);\n continue;\n }\n\n buildNode(el, elementType, parentId, ctx, nodes);\n\n // Recurse into subprocess children\n if ($type === \"bpmn:SubProcess\" || $type === \"bpmn:Transaction\" || $type === \"bpmn:AdHocSubProcess\") {\n const children = asElements(el.flowElements);\n const laneMembership = extractLaneMembership(el);\n walkFlowElements(children, id as string, { ...ctx, laneMembership }, nodes, edges);\n }\n }\n}\n\nfunction buildNode(\n el: ModdleElement,\n elementType: BpmnElementType,\n parentId: string | undefined,\n ctx: WalkContext,\n nodes: BpmnRFNode[],\n) {\n const id = el.id as string;\n const meta = BPMN_ELEMENT_CATALOG[elementType];\n const shape = ctx.shapes.get(id);\n\n // Position: use BPMNDI if available, otherwise auto-grid\n const x = shape?.x ?? ctx.autoX.value;\n const y = shape?.y ?? 100;\n if (!shape) ctx.autoX.value += (meta?.defaultWidth ?? 120) + 20;\n\n const label = asString(el.name);\n const trigger = extractTrigger(el);\n const isNonInterrupting = el.cancelActivity === false;\n\n const data: BpmnNodeData = {\n elementType,\n ...(label ? { label } : {}),\n ...(trigger ? { trigger } : {}),\n ...(isNonInterrupting ? { isNonInterrupting: true } : {}),\n };\n\n // SubProcess variant\n if (elementType === \"SubProcess\") {\n const variant = extractSubProcessVariant(el);\n if (variant) data.subProcessVariant = variant;\n const isExpanded = shape?.isExpanded ?? true;\n data.isExpanded = isExpanded;\n }\n\n // Determine effective parentId: lane membership overrides process-level parent\n const laneId = ctx.laneMembership.get(id);\n const effectiveParentId = laneId ?? parentId;\n\n const node: BpmnRFNode = {\n id,\n type: elementType,\n position: { x, y },\n data,\n width: shape?.width ?? meta?.defaultWidth,\n height: shape?.height ?? meta?.defaultHeight,\n ...(effectiveParentId ? { parentId: effectiveParentId } : {}),\n };\n\n nodes.push(node);\n}\n\nfunction buildEdge(\n el: ModdleElement,\n edgeType: BpmnEdgeType,\n ctx: WalkContext,\n edges: BpmnRFEdge[],\n) {\n const id = el.id as string;\n const source = (el.sourceRef as ModdleElement | undefined)?.id as string | undefined;\n const target = (el.targetRef as ModdleElement | undefined)?.id as string | undefined;\n\n if (!source || !target) {\n ctx.warnings.push(`Edge \"${id}\" missing source or target — skipped.`);\n return;\n }\n\n const label = asString(el.name);\n const condExpr = el.conditionExpression as { body?: string } | undefined;\n\n const data: BpmnEdgeData = {\n edgeType,\n ...(label ? { label } : {}),\n ...(condExpr?.body ? { conditionExpression: condExpr.body } : {}),\n };\n\n const waypoints = ctx.waypoints.get(id);\n if (waypoints?.length) data.routingPoints = waypoints;\n\n edges.push({ id, type: edgeType, source, target, data });\n}\n\n// ─── Handle Collaboration: Participants → Pool nodes ──────────────────────────\n\nfunction handleCollaboration(\n collaboration: ModdleElement,\n ctx: WalkContext,\n nodes: BpmnRFNode[],\n edges: BpmnRFEdge[],\n) {\n // Participants become Pool nodes\n for (const participant of asElements(collaboration.participants)) {\n const id = participant.id as string | undefined;\n if (!id) continue;\n const label = asString(participant.name);\n const shape = ctx.shapes.get(id);\n\n const poolNode: BpmnRFNode = {\n id,\n type: \"Pool\",\n position: { x: shape?.x ?? 0, y: shape?.y ?? 0 },\n data: { elementType: \"Pool\", ...(label ? { label } : {}) },\n width: shape?.width ?? 600,\n height: shape?.height ?? 200,\n };\n nodes.push(poolNode);\n\n // Walk the referenced process, assigning pool as parent\n const processRef = participant.processRef as ModdleElement | undefined;\n if (processRef) {\n const laneMembership = extractLaneMembership(processRef);\n walkFlowElements(\n asElements(processRef.flowElements),\n id,\n { ...ctx, laneMembership },\n nodes,\n edges,\n );\n\n // Add Lane nodes\n const laneSet = processRef.laneSet as ModdleElement | undefined;\n if (laneSet) {\n addLaneNodes(laneSet, id, ctx, nodes);\n }\n }\n }\n\n // Message flows\n for (const mf of asElements(collaboration.messageFlows)) {\n buildEdge(mf, \"messageFlow\", ctx, edges);\n }\n\n // Conversation links\n for (const cl of asElements(collaboration.conversationLinks)) {\n buildEdge(cl, \"conversationLink\", ctx, edges);\n }\n}\n\nfunction addLaneNodes(\n laneSet: ModdleElement,\n poolId: string,\n ctx: WalkContext,\n nodes: BpmnRFNode[],\n) {\n for (const lane of asElements(laneSet.lanes)) {\n const id = lane.id as string | undefined;\n if (!id) continue;\n const label = asString(lane.name);\n const shape = ctx.shapes.get(id);\n\n nodes.push({\n id,\n type: \"Lane\",\n position: { x: shape?.x ?? 30, y: shape?.y ?? 0 },\n data: { elementType: \"Lane\", ...(label ? { label } : {}) },\n width: shape?.width ?? 570,\n height: shape?.height ?? 120,\n parentId: poolId,\n });\n\n const child = lane.childLaneSet as ModdleElement | undefined;\n if (child) addLaneNodes(child, poolId, ctx, nodes);\n }\n}\n\n// ─── Public: parseBpmnXml ─────────────────────────────────────────────────────\n\nexport async function parseBpmnXml(xml: string): Promise<BpmnImportResult> {\n const moddle = new BpmnModdle();\n const warnings: string[] = [];\n\n let rootElement: ModdleElement;\n try {\n const result = await moddle.fromXML(xml);\n rootElement = result.rootElement;\n for (const w of result.warnings) warnings.push(w.message);\n } catch (err) {\n throw new Error(`Failed to parse BPMN XML: ${String(err)}`);\n }\n\n const nodes: BpmnRFNode[] = [];\n const edges: BpmnRFEdge[] = [];\n\n const { shapes, waypoints } = extractDiagramInfo(rootElement);\n const ctx: WalkContext = {\n shapes,\n waypoints,\n laneMembership: new Map(),\n warnings,\n autoX: { value: 50 },\n };\n\n for (const rootEl of asElements(rootElement.rootElements)) {\n if (rootEl.$type === \"bpmn:Collaboration\") {\n handleCollaboration(rootEl, ctx, nodes, edges);\n } else if (rootEl.$type === \"bpmn:Process\") {\n const laneMembership = extractLaneMembership(rootEl);\n const laneSet = rootEl.laneSet as ModdleElement | undefined;\n if (laneSet) addLaneNodes(laneSet, \"\", ctx, nodes);\n walkFlowElements(\n asElements(rootEl.flowElements),\n undefined,\n { ...ctx, laneMembership },\n nodes,\n edges,\n );\n }\n }\n\n return { nodes, edges, warnings };\n}\n","import { BpmnModdle, type ModdleElement } from \"bpmn-moddle\";\nimport { BPMN_ELEMENT_CATALOG } from \"../elements/catalog\";\nimport type { BpmnRFNode, BpmnRFEdge, BpmnExportOptions } from \"./types\";\nimport {\n ELEMENT_TYPE_TO_MODDLE,\n EDGE_TYPE_TO_MODDLE,\n TRIGGER_TO_EVENT_DEF,\n} from \"./mapper\";\n\n// ─── Helpers ──────────────────────────────────────────────────────────────────\n\nfunction uid(prefix: string, id: string): string {\n return `${prefix}_${id}`;\n}\n\nfunction asNodes(nodes: BpmnRFNode[], types: string[]): BpmnRFNode[] {\n return nodes.filter((n) => types.includes(n.data.elementType));\n}\n\n// ─── Flowable extension attributes ───────────────────────────────────────────\n\nfunction buildFlowableAttrs(data: BpmnRFNode[\"data\"]): Record<string, string> {\n const attrs: Record<string, string> = {};\n if (data.flowableAssignee) attrs[\"flowable:assignee\"] = data.flowableAssignee;\n if (data.flowableCandidateGroups) attrs[\"flowable:candidateGroups\"] = data.flowableCandidateGroups;\n if (data.flowableCandidateUsers) attrs[\"flowable:candidateUsers\"] = data.flowableCandidateUsers;\n if (data.flowableFormKey) attrs[\"flowable:formKey\"] = data.flowableFormKey;\n if (data.flowableDueDate) attrs[\"flowable:dueDate\"] = data.flowableDueDate;\n if (data.flowableType) attrs[\"flowable:type\"] = data.flowableType;\n if (data.flowableExpression) attrs[\"flowable:expression\"] = data.flowableExpression;\n if (data.flowableClass) attrs[\"flowable:class\"] = data.flowableClass;\n if (data.flowableDelegateExpression) attrs[\"flowable:delegateExpression\"] = data.flowableDelegateExpression;\n return attrs;\n}\n\n// ─── Build BPMN semantic model ────────────────────────────────────────────────\n\nfunction buildSemanticModel(\n moddle: BpmnModdle,\n nodes: BpmnRFNode[],\n edges: BpmnRFEdge[],\n opts: BpmnExportOptions,\n): ModdleElement {\n const defId = opts.id ?? \"Definitions_1\";\n const defName = opts.name;\n\n // Collect pool nodes → Collaboration + Participants\n const poolNodes = asNodes(nodes, [\"Pool\"]);\n const laneNodes = asNodes(nodes, [\"Lane\"]);\n const isCollaboration = poolNodes.length > 0;\n\n const definitions = moddle.create(\"bpmn:Definitions\", {\n id: defId,\n targetNamespace: \"http://bpmn.io/schema/bpmn\",\n ...(defName ? { name: defName } : {}),\n });\n // Flowable namespace: bpmn-moddle serializes xmlns:* from the element's own namespace map.\n // Injected via the moddle descriptor when a full Flowable extension is loaded.\n // For now, individual elements declare their own flowable:* attributes via $attrs.\n\n const rootElements: ModdleElement[] = [];\n\n if (isCollaboration) {\n const participants: ModdleElement[] = [];\n const processes: ModdleElement[] = [];\n\n for (const pool of poolNodes) {\n const processId = `Process_${pool.id}`;\n const process = buildProcess(moddle, nodes, edges, pool.id, laneNodes, processId);\n processes.push(process);\n\n const participant = moddle.create(\"bpmn:Participant\", {\n id: pool.id,\n name: pool.data.label ?? \"\",\n processRef: process,\n });\n participants.push(participant);\n }\n\n // Message flows and conversation links belong to collaboration\n const messageFlowEdges = edges.filter((e) => e.data?.edgeType === \"messageFlow\");\n const conversationLinkEdges = edges.filter((e) => e.data?.edgeType === \"conversationLink\");\n\n const messageFlows = messageFlowEdges.map((e) =>\n moddle.create(\"bpmn:MessageFlow\", {\n id: e.id,\n name: e.data?.label ?? \"\",\n sourceRef: { id: e.source },\n targetRef: { id: e.target },\n }),\n );\n\n const conversationLinks = conversationLinkEdges.map((e) =>\n moddle.create(\"bpmn:ConversationLink\", {\n id: e.id,\n sourceRef: { id: e.source },\n targetRef: { id: e.target },\n }),\n );\n\n const collaboration = moddle.create(\"bpmn:Collaboration\", {\n id: `Collaboration_${defId}`,\n participants,\n messageFlows,\n conversationLinks,\n });\n\n rootElements.push(collaboration, ...processes);\n } else {\n // Single process — no collaboration\n const process = buildProcess(moddle, nodes, edges, undefined, laneNodes, \"Process_1\");\n rootElements.push(process);\n }\n\n (definitions as Record<string, unknown>).rootElements = rootElements;\n return definitions;\n}\n\n// Build a bpmn:Process element containing flow nodes and sequence flows\nfunction buildProcess(\n moddle: BpmnModdle,\n allNodes: BpmnRFNode[],\n allEdges: BpmnRFEdge[],\n poolId: string | undefined,\n laneNodes: BpmnRFNode[],\n processId: string,\n): ModdleElement {\n // Collect flow nodes that belong to this pool (or all if no pools)\n const myNodes = poolId\n ? allNodes.filter(\n (n) =>\n n.parentId === poolId ||\n laneNodes.some((l) => l.id === n.parentId && l.parentId === poolId),\n )\n : allNodes.filter((n) => n.data.elementType !== \"Pool\" && n.data.elementType !== \"Lane\");\n\n const myLanes = laneNodes.filter((l) => (poolId ? l.parentId === poolId : true));\n\n // Build flow elements\n const flowElements: ModdleElement[] = [];\n\n for (const node of myNodes) {\n const el = buildFlowElement(moddle, node, allNodes, allEdges);\n if (el) flowElements.push(el);\n }\n\n // Sequence flows and associations\n const myNodeIds = new Set(myNodes.map((n) => n.id));\n const myEdges = allEdges.filter(\n (e) =>\n (e.data?.edgeType === \"sequenceFlow\" ||\n e.data?.edgeType === \"association\" ||\n e.data?.edgeType === \"dataAssociation\") &&\n myNodeIds.has(e.source) &&\n myNodeIds.has(e.target),\n );\n\n for (const edge of myEdges) {\n const edgeMeta = buildEdgeElement(moddle, edge);\n if (edgeMeta) flowElements.push(edgeMeta);\n }\n\n const process = moddle.create(\"bpmn:Process\", {\n id: processId,\n isExecutable: true,\n flowElements,\n });\n\n // Lane set\n if (myLanes.length > 0) {\n const laneElements = myLanes.map((l) =>\n moddle.create(\"bpmn:Lane\", {\n id: l.id,\n name: l.data.label ?? \"\",\n flowNodeRef: myNodes\n .filter((n) => n.parentId === l.id)\n .map((n) => ({ id: n.id })),\n }),\n );\n (process as Record<string, unknown>).laneSet = moddle.create(\"bpmn:LaneSet\", {\n id: `LaneSet_${processId}`,\n lanes: laneElements,\n });\n }\n\n return process;\n}\n\nfunction buildFlowElement(\n moddle: BpmnModdle,\n node: BpmnRFNode,\n _allNodes: BpmnRFNode[],\n _allEdges: BpmnRFEdge[],\n): ModdleElement | null {\n const { elementType, label, trigger } = node.data;\n\n // Pools and Lanes are handled in buildProcess / collaboration\n if (elementType === \"Pool\" || elementType === \"Lane\") return null;\n\n const moddleType = ELEMENT_TYPE_TO_MODDLE[elementType];\n if (!moddleType) return null;\n\n const attrs: Record<string, unknown> = {\n id: node.id,\n name: label ?? \"\",\n };\n\n // Event definitions\n if (trigger && trigger !== \"none\") {\n const defType = TRIGGER_TO_EVENT_DEF[trigger];\n if (defType) {\n attrs.eventDefinitions = [moddle.create(defType, { id: uid(\"EventDef\", node.id) })];\n }\n }\n\n // SubProcess variant\n if (elementType === \"SubProcess\" && node.data.subProcessVariant === \"transaction\") {\n return moddle.create(\"bpmn:Transaction\", attrs);\n }\n if (elementType === \"SubProcess\" && node.data.subProcessVariant === \"adhoc\") {\n return moddle.create(\"bpmn:AdHocSubProcess\", attrs);\n }\n\n const element = moddle.create(moddleType, attrs);\n\n // Flowable extension attributes\n const flowableAttrs = buildFlowableAttrs(node.data);\n if (Object.keys(flowableAttrs).length > 0) {\n (element as Record<string, unknown>).$attrs = flowableAttrs;\n }\n\n return element;\n}\n\nfunction buildEdgeElement(moddle: BpmnModdle, edge: BpmnRFEdge): ModdleElement | null {\n if (!edge.data) return null;\n const moddleType = EDGE_TYPE_TO_MODDLE[edge.data.edgeType];\n if (!moddleType) return null;\n\n const attrs: Record<string, unknown> = {\n id: edge.id,\n name: edge.data.label ?? \"\",\n sourceRef: { id: edge.source },\n targetRef: { id: edge.target },\n };\n\n if (edge.data.conditionExpression) {\n attrs.conditionExpression = moddle.create(\"bpmn:FormalExpression\", {\n body: edge.data.conditionExpression,\n });\n }\n\n return moddle.create(moddleType, attrs);\n}\n\n// ─── Build BPMNDI (diagram interchange / layout) ─────────────────────────────\n\nfunction buildBpmnDI(\n moddle: BpmnModdle,\n definitions: ModdleElement,\n nodes: BpmnRFNode[],\n edges: BpmnRFEdge[],\n): void {\n const shapes: ModdleElement[] = [];\n const edgeShapes: ModdleElement[] = [];\n\n for (const node of nodes) {\n const meta = BPMN_ELEMENT_CATALOG[node.data.elementType];\n const w = node.width ?? meta?.defaultWidth ?? 120;\n const h = node.height ?? meta?.defaultHeight ?? 60;\n\n const bounds = moddle.create(\"dc:Bounds\", {\n x: node.position.x,\n y: node.position.y,\n width: w,\n height: h,\n });\n\n const shape = moddle.create(\"bpmndi:BPMNShape\", {\n id: uid(\"BPMNShape\", node.id),\n bpmnElement: { id: node.id },\n bounds,\n });\n\n if (node.data.isExpanded !== undefined) {\n (shape as Record<string, unknown>).isExpanded = node.data.isExpanded;\n }\n\n shapes.push(shape);\n }\n\n for (const edge of edges) {\n const waypoints =\n edge.data?.routingPoints?.map((p) =>\n moddle.create(\"dc:Point\", { x: p.x, y: p.y }),\n ) ?? [];\n\n edgeShapes.push(\n moddle.create(\"bpmndi:BPMNEdge\", {\n id: uid(\"BPMNEdge\", edge.id),\n bpmnElement: { id: edge.id },\n waypoint: waypoints,\n }),\n );\n }\n\n // Find the main process / collaboration element\n const rootEls = (definitions as Record<string, unknown>).rootElements as ModdleElement[] | undefined;\n const planeElement = rootEls?.[0];\n\n const plane = moddle.create(\"bpmndi:BPMNPlane\", {\n id: \"BPMNPlane_1\",\n bpmnElement: planeElement ?? { id: \"unknown\" },\n planeElement: [...shapes, ...edgeShapes],\n });\n\n const diagram = moddle.create(\"bpmndi:BPMNDiagram\", {\n id: \"BPMNDiagram_1\",\n plane,\n });\n\n (definitions as Record<string, unknown>).diagrams = [diagram];\n}\n\n// ─── Public: serializeBpmnXml ─────────────────────────────────────────────────\n\nexport async function serializeBpmnXml(\n nodes: BpmnRFNode[],\n edges: BpmnRFEdge[],\n opts: BpmnExportOptions = {},\n): Promise<string> {\n const moddle = new BpmnModdle();\n\n const definitions = buildSemanticModel(moddle, nodes, edges, opts);\n buildBpmnDI(moddle, definitions, nodes, edges);\n\n const { xml } = await moddle.toXML(definitions, {\n format: opts.format ?? true,\n });\n\n return xml;\n}\n"]}
@@ -0,0 +1,476 @@
1
+ // src/simulation/evaluator.ts
2
+ function parseValue(raw) {
3
+ if (raw === "true") return true;
4
+ if (raw === "false") return false;
5
+ if (raw.startsWith("'") && raw.endsWith("'") || raw.startsWith('"') && raw.endsWith('"'))
6
+ return raw.slice(1, -1);
7
+ const n = Number(raw);
8
+ return isNaN(n) ? raw : n;
9
+ }
10
+ function evalCondition(expr, variables) {
11
+ const body = expr.trim().replace(/^\$\{|\}$/g, "").trim();
12
+ if (!body) return false;
13
+ if (body.startsWith("!")) {
14
+ const inner = body.slice(1).trim();
15
+ return !Boolean(variables[inner]);
16
+ }
17
+ const neq = body.match(/^(\w+)\s*!=\s*(.+)$/);
18
+ if (neq) return String(variables[neq[1].trim()]) !== String(parseValue(neq[2].trim()));
19
+ const eq = body.match(/^(\w+)\s*==\s*(.+)$/);
20
+ if (eq) {
21
+ const lhs = variables[eq[1].trim()];
22
+ const rhs = parseValue(eq[2].trim());
23
+ return lhs == rhs;
24
+ }
25
+ const gte = body.match(/^(\w+)\s*>=\s*(-?\d+\.?\d*)$/);
26
+ if (gte) return Number(variables[gte[1].trim()]) >= Number(gte[2]);
27
+ const lte = body.match(/^(\w+)\s*<=\s*(-?\d+\.?\d*)$/);
28
+ if (lte) return Number(variables[lte[1].trim()]) <= Number(lte[2]);
29
+ const gt = body.match(/^(\w+)\s*>\s*(-?\d+\.?\d*)$/);
30
+ if (gt) return Number(variables[gt[1].trim()]) > Number(gt[2]);
31
+ const lt = body.match(/^(\w+)\s*<\s*(-?\d+\.?\d*)$/);
32
+ if (lt) return Number(variables[lt[1].trim()]) < Number(lt[2]);
33
+ return Boolean(variables[body]);
34
+ }
35
+
36
+ // src/simulation/index.ts
37
+ function seqOut(diagram, nodeId) {
38
+ return diagram.edges.filter((e) => e.type === "sequenceFlow" && e.source === nodeId);
39
+ }
40
+ function seqIn(diagram, nodeId) {
41
+ return diagram.edges.filter((e) => e.type === "sequenceFlow" && e.target === nodeId);
42
+ }
43
+ function nodeById(diagram, id) {
44
+ return diagram.nodes.find((n) => n.id === id);
45
+ }
46
+ function boundaryEventsOf(diagram, hostId) {
47
+ return diagram.nodes.filter((n) => n.type === "BoundaryEvent" && n.attachedToRef === hostId);
48
+ }
49
+ var _tokenCounter = 0;
50
+ function nextTokenId() {
51
+ return `tok_${++_tokenCounter}`;
52
+ }
53
+ var GATEWAY_TYPES = /* @__PURE__ */ new Set([
54
+ "ExclusiveGateway",
55
+ "InclusiveGateway",
56
+ "ParallelGateway",
57
+ "ComplexGateway",
58
+ "EventBasedGateway"
59
+ ]);
60
+ var TASK_TYPES = /* @__PURE__ */ new Set([
61
+ "Task",
62
+ "UserTask",
63
+ "ServiceTask",
64
+ "ScriptTask",
65
+ "ManualTask",
66
+ "BusinessRuleTask",
67
+ "ReceiveTask",
68
+ "SendTask",
69
+ "CallActivity"
70
+ ]);
71
+ function isAutomatic(nodeType) {
72
+ return nodeType === "StartEvent" || nodeType === "EndEvent" || nodeType === "IntermediateThrowEvent" || GATEWAY_TYPES.has(nodeType);
73
+ }
74
+ function isManual(nodeType) {
75
+ return TASK_TYPES.has(nodeType) || nodeType === "IntermediateCatchEvent" || nodeType === "BoundaryEvent";
76
+ }
77
+ function isSubProcess(nodeType) {
78
+ return nodeType === "SubProcess" || nodeType === "Transaction" || nodeType === "AdHocSubProcess";
79
+ }
80
+ function getScopeId(diagram, nodeId) {
81
+ const node = nodeById(diagram, nodeId);
82
+ if (!node?.parentId) return "root";
83
+ const parent = nodeById(diagram, node.parentId);
84
+ return parent && isSubProcess(parent.type) ? node.parentId : "root";
85
+ }
86
+ function withLog(state, entry) {
87
+ return { ...state, log: [...state.log, { ...entry, step: state.step }] };
88
+ }
89
+ function disperseToTargets(diagram, state, sourceId, consumedTokenId) {
90
+ const outEdges = seqOut(diagram, sourceId);
91
+ if (outEdges.length === 0) return state;
92
+ let next = {
93
+ ...state,
94
+ tokens: consumedTokenId !== null ? state.tokens.filter((t) => t.id !== consumedTokenId) : state.tokens
95
+ };
96
+ for (const edge of outEdges) {
97
+ const target = nodeById(diagram, edge.target);
98
+ if (!target) continue;
99
+ const newToken = {
100
+ id: nextTokenId(),
101
+ elementId: edge.target,
102
+ scopeId: getScopeId(diagram, edge.target)
103
+ };
104
+ next = {
105
+ ...next,
106
+ tokens: [...next.tokens, newToken]
107
+ };
108
+ next = withLog(next, {
109
+ type: "created",
110
+ elementId: edge.target,
111
+ tokenId: newToken.id,
112
+ message: `Token created at "${target.name ?? edge.target}".`
113
+ });
114
+ }
115
+ return next;
116
+ }
117
+ function enterSubProcess(diagram, state, subProcNode) {
118
+ const childStarts = diagram.nodes.filter(
119
+ (n) => n.type === "StartEvent" && n.parentId === subProcNode.id
120
+ );
121
+ let next = {
122
+ ...state,
123
+ enteredScopes: [...state.enteredScopes, subProcNode.id]
124
+ };
125
+ for (const startNode of childStarts) {
126
+ const newToken = {
127
+ id: nextTokenId(),
128
+ elementId: startNode.id,
129
+ scopeId: subProcNode.id
130
+ };
131
+ next = {
132
+ ...next,
133
+ tokens: [...next.tokens, newToken]
134
+ };
135
+ next = withLog(next, {
136
+ type: "created",
137
+ elementId: startNode.id,
138
+ tokenId: newToken.id,
139
+ message: `SubProcess "${subProcNode.name ?? subProcNode.id}" entered \u2014 token at "${startNode.name ?? startNode.id}".`
140
+ });
141
+ }
142
+ return next;
143
+ }
144
+ function fireAutomatic(diagram, state, token) {
145
+ const node = nodeById(diagram, token.elementId);
146
+ if (!node) return state;
147
+ const { type } = node;
148
+ const vars = state.variables;
149
+ if (type === "EndEvent") {
150
+ let next = {
151
+ ...state,
152
+ tokens: state.tokens.filter((t) => t.id !== token.id)
153
+ };
154
+ next = withLog(next, {
155
+ type: "consumed",
156
+ elementId: node.id,
157
+ tokenId: token.id,
158
+ message: `Token consumed at end event "${node.name ?? node.id}".`
159
+ });
160
+ return next;
161
+ }
162
+ if (type === "StartEvent" || type === "IntermediateThrowEvent") {
163
+ let next = withLog(state, {
164
+ type: "fired",
165
+ elementId: node.id,
166
+ tokenId: token.id,
167
+ message: `"${node.name ?? node.id}" (${type}) fired.`
168
+ });
169
+ return disperseToTargets(diagram, next, node.id, token.id);
170
+ }
171
+ if (type === "ExclusiveGateway") {
172
+ const incoming = seqIn(diagram, node.id);
173
+ if (incoming.length >= 2) {
174
+ let next2 = withLog(state, {
175
+ type: "joined",
176
+ elementId: node.id,
177
+ tokenId: token.id,
178
+ message: `ExclusiveGateway "${node.name ?? node.id}" join \u2014 token passes through.`
179
+ });
180
+ return disperseToTargets(diagram, next2, node.id, token.id);
181
+ }
182
+ const outEdges = seqOut(diagram, node.id);
183
+ const chosen = outEdges.find(
184
+ (e) => e.conditionExpression && !e.isDefault && evalCondition(e.conditionExpression, vars)
185
+ ) ?? outEdges.find((e) => e.isDefault) ?? outEdges[0];
186
+ if (!chosen) return state;
187
+ const target = nodeById(diagram, chosen.target);
188
+ if (!target) return state;
189
+ const newToken = {
190
+ id: nextTokenId(),
191
+ elementId: chosen.target,
192
+ scopeId: getScopeId(diagram, chosen.target)
193
+ };
194
+ let next = {
195
+ ...state,
196
+ tokens: [...state.tokens.filter((t) => t.id !== token.id), newToken]
197
+ };
198
+ next = withLog(next, {
199
+ type: "fired",
200
+ elementId: node.id,
201
+ tokenId: token.id,
202
+ message: `ExclusiveGateway "${node.name ?? node.id}" split \u2192 "${target.name ?? chosen.target}".`
203
+ });
204
+ return next;
205
+ }
206
+ if (type === "InclusiveGateway") {
207
+ const incoming = seqIn(diagram, node.id);
208
+ if (incoming.length >= 2) {
209
+ let next2 = withLog(state, {
210
+ type: "joined",
211
+ elementId: node.id,
212
+ tokenId: token.id,
213
+ message: `InclusiveGateway "${node.name ?? node.id}" join.`
214
+ });
215
+ return disperseToTargets(diagram, next2, node.id, token.id);
216
+ }
217
+ const outEdges = seqOut(diagram, node.id);
218
+ const matching = outEdges.filter(
219
+ (e) => e.conditionExpression && !e.isDefault && evalCondition(e.conditionExpression, vars)
220
+ );
221
+ const activePaths = matching.length > 0 ? matching : outEdges.filter((e) => e.isDefault);
222
+ const paths = activePaths.length > 0 ? activePaths : outEdges;
223
+ let next = withLog(state, {
224
+ type: "split",
225
+ elementId: node.id,
226
+ tokenId: token.id,
227
+ message: `InclusiveGateway "${node.name ?? node.id}" split \u2192 ${paths.length} path(s).`
228
+ });
229
+ next = { ...next, tokens: next.tokens.filter((t) => t.id !== token.id) };
230
+ for (const edge of paths) {
231
+ const tgt = nodeById(diagram, edge.target);
232
+ if (!tgt) continue;
233
+ const newToken = {
234
+ id: nextTokenId(),
235
+ elementId: edge.target,
236
+ scopeId: getScopeId(diagram, edge.target)
237
+ };
238
+ next = { ...next, tokens: [...next.tokens, newToken] };
239
+ next = withLog(next, {
240
+ type: "created",
241
+ elementId: edge.target,
242
+ tokenId: newToken.id,
243
+ message: `Token created at "${tgt.name ?? edge.target}".`
244
+ });
245
+ }
246
+ return next;
247
+ }
248
+ if (type === "ParallelGateway") {
249
+ const incoming = seqIn(diagram, node.id);
250
+ if (incoming.length >= 2) {
251
+ const atGateway = state.tokens.filter((t) => t.elementId === node.id);
252
+ if (atGateway.length < incoming.length) {
253
+ return withLog(state, {
254
+ type: "blocked",
255
+ elementId: node.id,
256
+ tokenId: token.id,
257
+ message: `ParallelGateway "${node.name ?? node.id}" waiting for ${incoming.length - atGateway.length} more token(s).`
258
+ });
259
+ }
260
+ const consumeIds = new Set(atGateway.map((t) => t.id));
261
+ let next2 = {
262
+ ...state,
263
+ tokens: state.tokens.filter((t) => !consumeIds.has(t.id))
264
+ };
265
+ next2 = withLog(next2, {
266
+ type: "joined",
267
+ elementId: node.id,
268
+ message: `ParallelGateway "${node.name ?? node.id}" join fired \u2014 all paths synchronized.`
269
+ });
270
+ return disperseToTargets(diagram, next2, node.id, null);
271
+ }
272
+ let next = withLog(state, {
273
+ type: "split",
274
+ elementId: node.id,
275
+ tokenId: token.id,
276
+ message: `ParallelGateway "${node.name ?? node.id}" split \u2192 ${seqOut(diagram, node.id).length} paths.`
277
+ });
278
+ return disperseToTargets(diagram, next, node.id, token.id);
279
+ }
280
+ if (type === "EventBasedGateway") {
281
+ let next = withLog(state, {
282
+ type: "split",
283
+ elementId: node.id,
284
+ tokenId: token.id,
285
+ message: `EventBasedGateway "${node.name ?? node.id}" waiting \u2014 ${seqOut(diagram, node.id).length} competing event(s).`
286
+ });
287
+ return disperseToTargets(diagram, next, node.id, token.id);
288
+ }
289
+ if (type === "ComplexGateway") {
290
+ const outEdges = seqOut(diagram, node.id);
291
+ const chosen = outEdges[0];
292
+ if (!chosen) return state;
293
+ const newToken = {
294
+ id: nextTokenId(),
295
+ elementId: chosen.target,
296
+ scopeId: getScopeId(diagram, chosen.target)
297
+ };
298
+ let next = {
299
+ ...state,
300
+ tokens: [...state.tokens.filter((t) => t.id !== token.id), newToken]
301
+ };
302
+ next = withLog(next, {
303
+ type: "fired",
304
+ elementId: node.id,
305
+ tokenId: token.id,
306
+ message: `ComplexGateway "${node.name ?? node.id}" fired \u2192 "${chosen.target}".`
307
+ });
308
+ return next;
309
+ }
310
+ return state;
311
+ }
312
+ function createSimulation(diagram, initialVariables = {}) {
313
+ _tokenCounter = 0;
314
+ const startEvents = diagram.nodes.filter(
315
+ (n) => n.type === "StartEvent" && !n.parentId
316
+ );
317
+ const tokens = startEvents.map((n) => ({
318
+ id: nextTokenId(),
319
+ elementId: n.id,
320
+ scopeId: "root"
321
+ }));
322
+ const log = startEvents.map((n, i) => ({
323
+ step: 0,
324
+ type: "created",
325
+ elementId: n.id,
326
+ tokenId: tokens[i]?.id,
327
+ message: `Simulation started \u2014 token placed at "${n.name ?? n.id}".`
328
+ }));
329
+ return {
330
+ tokens,
331
+ step: 0,
332
+ status: startEvents.length > 0 ? "running" : "idle",
333
+ log,
334
+ variables: initialVariables,
335
+ enteredScopes: []
336
+ };
337
+ }
338
+ function tick(diagram, state) {
339
+ if (state.status !== "running") return state;
340
+ let current = { ...state, step: state.step + 1 };
341
+ let changed = true;
342
+ let guard = 0;
343
+ while (changed && guard < 1e3) {
344
+ guard++;
345
+ changed = false;
346
+ for (const token of current.tokens) {
347
+ const node = nodeById(diagram, token.elementId);
348
+ if (!node) continue;
349
+ if (isSubProcess(node.type)) {
350
+ if (!current.enteredScopes.includes(node.id)) {
351
+ const childStarts = diagram.nodes.filter(
352
+ (n) => n.type === "StartEvent" && n.parentId === node.id
353
+ );
354
+ if (childStarts.length > 0) {
355
+ current = enterSubProcess(diagram, current, node);
356
+ changed = true;
357
+ break;
358
+ }
359
+ } else {
360
+ const scopeTokens = current.tokens.filter((t) => t.scopeId === node.id);
361
+ if (scopeTokens.length === 0) {
362
+ let next = withLog(current, {
363
+ type: "fired",
364
+ elementId: node.id,
365
+ tokenId: token.id,
366
+ message: `SubProcess "${node.name ?? node.id}" completed.`
367
+ });
368
+ current = disperseToTargets(diagram, next, node.id, token.id);
369
+ changed = true;
370
+ break;
371
+ }
372
+ }
373
+ continue;
374
+ }
375
+ if (node.type === "ParallelGateway") {
376
+ const incoming = seqIn(diagram, node.id);
377
+ const atGateway = current.tokens.filter((t) => t.elementId === node.id);
378
+ if (incoming.length >= 2 && atGateway.length < incoming.length) continue;
379
+ }
380
+ if (!isAutomatic(node.type)) continue;
381
+ const prevLen = current.tokens.length;
382
+ const prevIds = new Set(current.tokens.map((t) => t.id));
383
+ current = fireAutomatic(diagram, current, token);
384
+ const same = current.tokens.length === prevLen && [...prevIds].every((id) => current.tokens.some((t) => t.id === id));
385
+ if (!same) {
386
+ changed = true;
387
+ break;
388
+ }
389
+ }
390
+ }
391
+ if (current.tokens.length === 0) {
392
+ current = { ...current, status: "completed" };
393
+ }
394
+ return current;
395
+ }
396
+ function fire(diagram, state, elementId, variables) {
397
+ if (state.status !== "running") return state;
398
+ const node = nodeById(diagram, elementId);
399
+ if (!node) return state;
400
+ const mergedVars = variables ? { ...state.variables, ...variables } : state.variables;
401
+ if (node.type === "BoundaryEvent") {
402
+ const hostId = node.attachedToRef;
403
+ if (!hostId) return state;
404
+ const hostToken = state.tokens.find((t) => t.elementId === hostId);
405
+ if (!hostToken) return state;
406
+ const isInterrupting = node.isInterrupting !== false;
407
+ let next2 = { ...state, variables: mergedVars, step: state.step + 1 };
408
+ next2 = withLog(next2, {
409
+ type: isInterrupting ? "interrupted" : "fired",
410
+ elementId,
411
+ tokenId: hostToken.id,
412
+ message: `BoundaryEvent "${node.name ?? elementId}" fired (${isInterrupting ? "interrupting" : "non-interrupting"}).`
413
+ });
414
+ if (isInterrupting) {
415
+ next2 = { ...next2, tokens: next2.tokens.filter((t) => t.id !== hostToken.id) };
416
+ }
417
+ next2 = disperseToTargets(diagram, next2, elementId, null);
418
+ return tick(diagram, { ...next2, step: next2.step - 1 });
419
+ }
420
+ const token = state.tokens.find((t) => t.elementId === elementId);
421
+ if (!token) return state;
422
+ if (node.type === "IntermediateCatchEvent") {
423
+ const gwEdge = seqIn(diagram, elementId).find((e) => {
424
+ const src = nodeById(diagram, e.source);
425
+ return src?.type === "EventBasedGateway";
426
+ });
427
+ if (gwEdge) {
428
+ const gw = nodeById(diagram, gwEdge.source);
429
+ if (gw) {
430
+ const siblingTargets = new Set(
431
+ seqOut(diagram, gw.id).map((e) => e.target).filter((id) => id !== elementId)
432
+ );
433
+ state = {
434
+ ...state,
435
+ tokens: state.tokens.filter((t) => !siblingTargets.has(t.elementId))
436
+ };
437
+ }
438
+ }
439
+ }
440
+ let next = { ...state, variables: mergedVars, step: state.step + 1 };
441
+ next = withLog(next, {
442
+ type: "fired",
443
+ elementId,
444
+ tokenId: token.id,
445
+ message: `"${node.name ?? elementId}" (${node.type}) manually fired.`
446
+ });
447
+ next = disperseToTargets(diagram, next, elementId, token.id);
448
+ return tick(diagram, { ...next, step: next.step - 1 });
449
+ }
450
+ function getFireable(diagram, state) {
451
+ if (state.status !== "running") return [];
452
+ const fireable = /* @__PURE__ */ new Set();
453
+ for (const token of state.tokens) {
454
+ const node = nodeById(diagram, token.elementId);
455
+ if (!node) continue;
456
+ if (isManual(node.type)) {
457
+ fireable.add(node.id);
458
+ }
459
+ if (TASK_TYPES.has(node.type)) {
460
+ for (const be of boundaryEventsOf(diagram, node.id)) {
461
+ fireable.add(be.id);
462
+ }
463
+ }
464
+ }
465
+ return [...fireable];
466
+ }
467
+ function isCompleted(state) {
468
+ return state.status === "completed";
469
+ }
470
+ function setVariable(state, key, value) {
471
+ return { ...state, variables: { ...state.variables, [key]: value } };
472
+ }
473
+
474
+ export { createSimulation, fire, getFireable, isCompleted, setVariable, tick };
475
+ //# sourceMappingURL=chunk-57LA2WSJ.js.map
476
+ //# sourceMappingURL=chunk-57LA2WSJ.js.map