{
  "$schema": "https://ai.syncfusion.com/schema/registry-item.json",
  "name": "diagram-bpmn-editor",
  "framework": "javascript",
  "type": "registry:component",
  "component": "Diagram",
  "variant": "bpmn-editor",
  "dependencies": [
    "@syncfusion/ej2-diagrams"
  ],
  "description": "Business process modeling diagram with swimlanes, lane swapping, and BPMN task connectors.",
  "meta": {
    "essentialStudioRelease": "2026 Volume 3 (v35.1.37)",
    "license": "commercial-or-community",
    "licenseNote": "The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md",
    "requiresLicenseKey": true,
    "requiresServerEndpoint": false,
    "platformIndex": "https://ai.syncfusion.com/javascript/llms.txt",
    "skillPack": "syncfusion/javascript-ui-components-skills",
    "docs": "https://ai.syncfusion.com/gallery/javascript/diagram-bpmn-editor.md"
  },
  "files": [
    {
      "target": "src/components/diagram-bpmn-editor/diagram.html",
      "content": "<div class=\"control-section\">\n    <link href=\"https://ej2.syncfusion.com/javascript/demos/src/diagram/styles/diagram-common.css\" rel=\"stylesheet\">\n    <script src=\"https://ej2.syncfusion.com/javascript/demos/src/diagram/script/diagram-common.js\"></script>\n\n    <style>\n        /* Context-menu items CSS */\n        @font-face {\n            font-family: 'e-bpmn-icons';\n            font-weight: normal;\n            font-style: normal;\n        }\n\n\n        .e-bpmn-icons {\n            font-family: 'e-bpmn-icons' !important;\n            font-size: 55px;\n            font-style: normal;\n            font-weight: normal;\n            font-variant: normal;\n            text-transform: none;\n            line-height: 1;\n            -webkit-font-smoothing: antialiased;\n            -moz-osx-font-smoothing: grayscale;\n        }\n\n        .e-Order:before {\n            content: \"\\e700\";\n        }\n\n        .e-InBOCatchMessage:before {\n            content: \"\\e701\";\n        }\n\n        .e-NoneEnd:before {\n            content: \"\\e723\";\n        }\n\n        .e-DataObjectCollection:before {\n            content: \"\\e703\";\n        }\n\n        .e-DataOutput:before {\n            content: \"\\e704\";\n        }\n\n        .e-EscalationEnd:before {\n            content: \"\\e705\";\n        }\n\n        .e-Activity:before {\n            content: \"\\e706\";\n        }\n\n        .e-EventBasedGateway:before {\n            content: \"\\e721\";\n        }\n\n        .e-CatchParallelMultiple:before {\n            content: \"\\e708\";\n        }\n\n        .e-CatchMultipleIn:before {\n            content: \"\\e709\";\n        }\n\n        .e-BoCatchCompensation:before {\n            content: \"\\e70a\";\n        }\n\n        .e-TimerIntermediate:before {\n            content: \"\\e70b\";\n        }\n\n        .e-NonInBoCatchParallelMultiple:before {\n            content: \"\\e70d\";\n        }\n\n        .e-NonInBoTimerIntermediate:before {\n            content: \"\\e70e\";\n        }\n\n        .e-ParallelEventBasedGatewaytostart:before {\n            content: \"\\e718\";\n        }\n\n        .e-NonInMultiple:before {\n            content: \"\\e710\";\n        }\n\n        .e-CompensationEnd:before {\n            content: \"\\e711\";\n        }\n\n        .e-InError:before {\n            content: \"\\e70f\";\n        }\n\n        .e-NonCatchMultipleIn:before {\n            content: \"\\e713\";\n        }\n\n        .e-InCompensation:before {\n            content: \"\\e722\";\n        }\n\n        .e-NonInEscalation:before {\n            content: \"\\e716\";\n        }\n\n        .e-ThrowMultipleIn:before {\n            content: \"\\e717\";\n        }\n\n        .e-InMessage:before {\n            content: \"\\e715\";\n        }\n\n        .e-OutMessage:before {\n            content: \"\\e702\";\n        }\n\n        .e-ScriptCall:before {\n            content: \"\\e703\";\n        }\n\n        .e-UserCall:before {\n            content: \"\\e713\";\n        }\n\n        .e-NonInThrowMessage:before {\n            content: \"\\e719\";\n        }\n\n        .e-EvBaseGateTostartProcess:before {\n            content: \"\\e71a\";\n        }\n\n        .e-InterruptingNone:before {\n            content: \"\\e71e\";\n        }\n\n        .e-ThrowingIntermediate:before {\n            content: \"\\e711\";\n        }\n\n        .e-DataOutputCollection:before {\n            content: \"\\e71c\";\n        }\n\n        .e-ThrowEscalationIn:before {\n            content: \"\\e71d\";\n        }\n\n        .e-ExclusiveGatewayWithMarker:before {\n            content: \"\\e70d\";\n        }\n\n        .e-ErrorEnd:before {\n            content: \"\\e71f\";\n        }\n\n        .e-ComplexGateway:before {\n            content: \"\\e707\";\n        }\n\n        .e-NonInParallelMultiple:before {\n            content: \"\\e721\";\n        }\n\n        .e-InSignal:before {\n            content: \"\\e705\";\n        }\n\n        .e-NonInBoCatchEscalation:before {\n            content: \"\\e723\";\n        }\n\n        .e-InclusiveGateway:before {\n            content: \"\\e71e\";\n        }\n\n        .e-MultipleEnd:before {\n            content: \"\\e725\";\n        }\n\n        .e-ThrowLinkin:before {\n            content: \"\\e70c\";\n        }\n\n        .e-ParallelGateway:before {\n            content: \"\\e729\";\n        }\n\n        .e-SignalEnd:before {\n            content: \"\\e728\";\n        }\n\n        .e-TerminateEnd:before {\n            content: \"\\e714\";\n        }\n\n        .e-BoCatchCompensationIn:before {\n            content: \"\\e72a\";\n        }\n\n        .e-InTimer:before {\n            content: \"\\e720\";\n        }\n\n        .e-ThrowCompensationIn:before {\n            content: \"\\e72c\";\n        }\n\n        .e-InConditional:before {\n            content: \"\\e728\";\n        }\n\n        .e-BoCatchCancelIn:before {\n            content: \"\\e72f\";\n        }\n\n        .e-ThrowMessage:before {\n            content: \"\\e730\";\n        }\n\n        .e-CatchLinkIn:before {\n            content: \"\\e731\";\n        }\n\n        .e-Gateway:before {\n            content: \"\\e732\";\n        }\n\n        .e-DataInputCollection:before {\n            content: \"\\e733\";\n        }\n\n        .e-NonInSignal:before {\n            content: \"\\e734\";\n        }\n\n        .e-DataInput:before {\n            content: \"\\e70c\";\n        }\n\n        .e-InMultiple:before {\n            content: \"\\e710\";\n        }\n\n        .e-InEscalation:before {\n            content: \"\\e71a\";\n        }\n\n        .e-CancelEnd:before {\n            content: \"\\e717\";\n        }\n\n        .e-DataObject:before {\n            content: \"\\e739\";\n        }\n\n        .e-NonInBOCatchMessage:before {\n            content: \"\\e73a\";\n        }\n\n        .e-ManualCall:before {\n            content: \"\\e725\";\n        }\n\n        .e-InParallelMultiple:before {\n            content: \"\\e727\";\n        }\n\n        .e-Flow:before {\n            content: \"\\e73d\";\n        }\n\n        .e-DataStore:before {\n            content: \"\\e73e\";\n        }\n\n        .e-NoneStart:before {\n            content: \"\\e71f\";\n        }\n\n        .e-ServiceTask:before {\n            content: \"\\e719\";\n        }\n\n        .e-InBoCatchEscalation:before {\n            content: \"\\e741\";\n        }\n\n        .e-NonInConditional:before {\n            content: \"\\e742\";\n        }\n\n        .e-BusinessRule:before {\n            content: \"\\e712\";\n        }\n\n        .e-NonInTimer:before {\n            content: \"\\e744\";\n        }\n\n        .e-MessageEnd:before {\n            content: \"\\e745\";\n        }\n\n        .e-None:before {\n            content: \"\\e726\";\n        }\n\n        .e-SequentialMI:before {\n            content: \"\\e71d\";\n        }\n\n        .e-ParallelMI:before {\n            content: \"\\e70a\";\n        }\n\n        .e-Loop:before {\n            content: \"\\e70e\";\n        }\n\n        .e-Compensation:before {\n            content: \"\\e722\";\n        }\n\n        .e-SubProcess:before {\n            content: \"\\e700\";\n        }\n\n        .e-Task:before {\n            content: \"\\e71b\";\n        }\n\n        .e-Call:before {\n            content: \"\\e70b\";\n        }\n\n        .e-adhoc:before {\n            content: \"\\e709\";\n        }\n\n        .e-Default:before {\n            content: \"\\e71b\";\n        }\n\n        .e-Event:before {\n            content: \"\\e708\";\n        }\n\n        .e-CallActivity:before {\n            content: \"\\e701\";\n        }\n\n        .e-ExclusiveEventBased:before {\n            content: \"\\e71c\";\n        }\n\n        .e-Noninterruptingstart:before {\n            content: \"\\e72b\";\n        }\n\n        .e-NoninterruptingIntermediate:before {\n            content: \"\\e72a\";\n        }\n\n        .e-InstantiatingReceive:before {\n            content: \"\\e72c\";\n        }\n\n        .container-fluid {\n            padding-bottom: 15px;\n        }\n\n        .sb-bpmn-editor {\n            border-color: rgba(0, 0, 0, 0.12);\n            border-width: 1px 1px 1px 0px;\n            border-style: solid;\n        }\n\n        @media (max-width: 550px) {\n            .sb-bpmn-editor {\n                border-width: 0px 1px 1px;\n            }\n        }\n    </style>\n    <div class=\"sb-mobile-palette-bar\">\n        <div id=\"palette-icon\" style=\"float: right;\" role=\"button\" class=\"e-ddb-icons1 e-toggle-palette\"></div>\n    </div>\n    <div id=\"palette-space\" class=\"sb-mobile-palette\">\n        <div id=\"symbolpalette\"></div>\n    </div>\n    <div id=\"diagram-space\" class=\"sb-mobile-diagram sb-bpmn-editor\">\n        <div id=\"container\"></div>\n    </div>\n</div>\n"
    },
    {
      "target": "src/components/diagram-bpmn-editor/diagram.ts",
      "content": "// tslint:disable:no-non-null-assertion\nimport type {\n    NodeModel, BpmnShapeModel, ConnectorModel, DiagramBeforeMenuOpenEventArgs, \n    ContextMenuSettingsModel, IDragEnterEventArgs, BpmnEvents,\n    BpmnGateways, BpmnDataObjects, BpmnTriggers, BpmnTasks, BpmnBoundary, BpmnLoops\n} from '@syncfusion/ej2-diagrams';\nimport {\n    Diagram, Node, BpmnDiagrams, UndoRedo,\n    SymbolPalette, DiagramContextMenu, NodeConstraints\n} from '@syncfusion/ej2-diagrams';\n\n// tslint:disable \nDiagram.Inject(BpmnDiagrams, UndoRedo, DiagramContextMenu);\nSymbolPalette.Inject(BpmnDiagrams);\n\n// Define a variable to hold an instance of the DiagramComponent\nlet diagram: Diagram;\n\n// Creates a BPMN event node with specified properties\nconst createBpmnEventNode = (id: string, offsetX: number, offsetY: number, eventType: BpmnEvents, annotationContent: string = '') => {\n    // Define the node model with basic properties and a BPMN event shape\n    const node: NodeModel = {\n        id,\n        width: 40,\n        height: 40,\n        offsetX,\n        offsetY,\n        shape: { type: 'Bpmn', shape: 'Event', event: { event: eventType } }\n    };\n    // If annotation content is provided, add an annotation to the node\n    if (annotationContent) {\n        node.annotations = [{\n            id: `${id}Label`,\n            content: annotationContent,\n            style: { fill: 'white', color: 'black' },\n            verticalAlignment: 'Top',\n            margin: { top: 20 }\n        }];\n    }\n    return node;\n};\n\n// Creates a BPMN event node with specified margins\nconst createBpmnEventNodeWithMargin = (id: string, marginX: number, marginY: number, eventType: BpmnEvents, trigger?: BpmnTriggers) => {\n    const node: NodeModel = {\n        id,\n        width: 30,\n        height: 30,\n        shape: { type: 'Bpmn', shape: 'Event', event: { event: eventType, trigger: trigger } },\n        margin: { left: marginX, top: marginY }\n    }\n    return node;\n};\n\n// Creates a BPMN activity node with task type and additional properties\nconst createBpmnActivity = (\n    id: string, fill: string, content: string, left: number, top: number, width: number, height: number,\n    taskType: BpmnTasks = 'Service', loop?: BpmnLoops, compensation?: boolean\n): NodeModel => ({\n    id: id,\n    style: { fill: fill },\n    width: width,\n    height: height,\n    shape: {\n        type: 'Bpmn', shape: 'Activity',\n        activity: { activity: 'Task', task: { type: taskType, loop: loop, compensation: compensation } },\n    },\n    annotations: [{\n        id: `${id}Label2`, content: content, offset: { x: 0.5, y: 0.6 },\n        style: { color: 'white' }\n    }],\n    margin: { left: left, top: top },\n});\n\n// Initializes nodes for key elements in a business process flow\nlet nodes: NodeModel[] = [\n    createBpmnEventNode('start', 35, 230, 'Start'),\n    createBpmnActivity('service', '#6FAAB0', 'Book hotel', 110, 20, 95, 70, 'Service', 'ParallelMultiInstance'),\n    createBpmnEventNodeWithMargin('subProcessesEnd', 440, 210, 'End'),\n    {\n        id: 'subProcess',\n        width: 520,\n        height: 250,\n        offsetX: 355,\n        offsetY: 230,\n        constraints: NodeConstraints.Default | NodeConstraints.AllowDrop,\n        shape: {\n            shape: 'Activity', type: 'Bpmn',\n            activity: {\n                activity: 'SubProcess', subProcess: {\n                    type: 'Transaction', collapsed: false,\n                    processes: ['processesStart', 'service', 'compensation', 'processesTask',\n                        'error', 'processesEnd', 'user', 'subProcessesEnd']\n                }\n            }\n        }\n    },\n];\n\n// Creates a connector between BPMN nodes with optional annotations and properties\nconst createConnector = (\n    id: string, sourceID: string, targetID: string,\n    annotationContent: string = \"\", sourcePortID: string = \"\", additionalProps: any = {}\n): ConnectorModel => ({\n    id,\n    sourceID,\n    targetID,\n    sourcePortID,\n    type: \"Orthogonal\",\n    // Conditionally add annotations if content is provided\n    ...(annotationContent && {\n        annotations: [{\n            id: `${id}Label`,\n            content: annotationContent,\n            offset: 0.50,\n            style: { fill: 'white' }\n        }]\n    }),\n    ...additionalProps // Spread additional properties for customization\n});\n\n// Initializes connectors to define flow and relationships between BPMN elements\nlet connectors: ConnectorModel[] = [\n    createConnector('connector1', 'start', 'subProcess'),\n    createConnector('connector2', 'subProcess', 'end', '', 'success'),\n    createConnector('connector3', 'subProcess', 'hazardEnd', 'Booking system failure', 'failure', {\n        segments: [{ type: 'Orthogonal', length: 50, direction: 'Bottom' }]\n    }),\n   \n];\n\n// Retrieves specific shape details for BPMN elements based on type and subtype\nconst getShapeDetails = (type: string, subType: string): any => {\n    switch (type) {\n        case 'Event':\n            // Returns BPMN event details\n            return { event: { event: subType } };\n        case 'Activity':\n            if (subType === 'Task') {\n                // Returns BPMN task details\n                return { activity: { activity: subType } };\n            } else if (subType === 'Transaction') {\n                // Returns BPMN transaction subprocess details\n                return {\n                    activity: {\n                        activity: 'SubProcess',\n                        subProcess: {\n                            type: subType,\n                            transaction: {\n                                cancel: { visible: false },\n                                failure: { visible: false },\n                                success: { visible: false }\n                            }\n                        }\n                    }\n                };\n            } else if (subType === 'Service') {\n                // Returns BPMN service task details\n                return { activity: { activity: 'Task', task: { type: subType } } };\n            }\n            break;\n        case 'Gateway':\n            // Returns BPMN gateway details\n            return { gateway: { type: 'Exclusive' } };\n        case 'DataObject':\n            // Returns BPMN data object details\n            return { dataObject: { collection: false, type: 'None' } };\n        default:\n            return {};\n    }\n};\n\n// Creates a BPMN shape node with specified dimensions, type, and subtype\nconst createBpmnShape = (id: string, width: number, height: number, type: string, subType: string): NodeModel => ({\n    id,\n    width,\n    height,\n    // Setting the BPMN shape based on type and subtype\n    shape: { type: 'Bpmn', shape: type, ...getShapeDetails(type, subType) }\n});\n\n// Initializes an array of BPMN shapes for the symbol palette\nlet bpmnShapes: NodeModel[] = [\n    createBpmnShape('Start', 35, 35, 'Event', 'Start'),\n    createBpmnShape('NonInterruptingIntermediate', 35, 35, 'Event', 'NonInterruptingIntermediate'),\n    createBpmnShape('End', 35, 35, 'Event', 'End'),\n];\n\n// Define a base connector symbol to reduce redundancy\nconst baseConnector: Partial<ConnectorModel> = {\n    sourcePoint: { x: 0, y: 0 },\n    targetPoint: { x: 40, y: 40 },\n    targetDecorator: { style: { strokeColor: '#757575', fill: '#757575' }, shape: \"Arrow\" },\n    style: { strokeColor: '#757575', strokeWidth: 2 }\n};\n\n// Initialize an array of connector symbols for the symbol palette\nlet connectorSymbols: ConnectorModel[] = [\n    { ...baseConnector, id: 'Link1', type: 'Orthogonal' },\n    { ...baseConnector, id: 'Link2', type: 'Orthogonal', style: { ...baseConnector.style, strokeDashArray: '4 4' } },\n    { ...baseConnector, id: 'Link3', type: 'Straight' },\n    {\n        id: 'link4',\n        sourcePoint: { x: 0, y: 0 },\n        targetPoint: { x: 40, y: 40 },\n        type: 'Orthogonal',\n        targetDecorator: { style: { strokeColor: '#757575', fill: '#757575' } },\n        shape: { type: 'Bpmn', flow: 'Association', association: 'Directional' },\n        style: { strokeDashArray: '2,2', strokeColor: '#757575' },\n    },\n];\n\n// Initializes the context menu for BPMN shapes with various options.\nlet contextMenu: ContextMenuSettingsModel = {\n    show: true,\n    items: [\n        {\n            text: 'Ad-Hoc',\n            id: 'Adhoc',\n            // Sub-menu for Ad-Hoc options\n            items: [\n                { text: 'None', iconCss: 'e-adhocs e-bpmn-event e-bpmn-icons e-None', id: 'AdhocNone' },\n                { iconCss: 'e-adhocs e-bpmn-icons e-adhoc', text: 'Ad-Hoc', id: 'AdhocAdhoc' }\n            ]\n        },\n        {\n            text: 'Loop',\n            id: 'Loop',\n            // Sub-menu for Loop options\n            items: [\n                { text: 'None', iconCss: 'e-loop e-bpmn-icons e-None', id: 'LoopNone' },\n                { text: 'Standard', iconCss: 'e-loop e-bpmn-icons e-Loop', id: 'Standard' },\n                { text: 'Parallel Multi-Instance', iconCss: 'e-loop e-bpmn-icons e-ParallelMI', id: 'ParallelMultiInstance' },\n                { text: 'Sequence Multi-Instance', iconCss: 'e-loop e-bpmn-icons e-SequentialMI', id: 'SequenceMultiInstance' }\n            ]\n        },\n        {\n            text: 'Compensation',\n            id: 'taskCompensation',\n            // Sub-menu for Compensation options\n            items: [\n                { text: 'None', iconCss: 'e-compensation e-bpmn-icons e-None', id: 'CompensationNone' },\n                { iconCss: 'e-compensation e-bpmn-icons e-Compensation', text: 'Compensation', id: 'CompensationCompensation' }\n            ]\n        },\n        {\n            text: 'Activity-Type',\n            id: 'Activity-Type',\n            // Sub-menu for Activity-Type options\n            items: [\n                { text: 'Collapsed sub-process', iconCss: 'e-bpmn-icons e-SubProcess', id: 'CollapsedSubProcess' },\n                { iconCss: 'e-bpmn-icons e-Task', text: 'Expanded sub-process', id: 'ExpandedSubProcess' }\n            ]\n        },\n        {\n            text: 'Boundry',\n            id: 'Boundry',\n            // Sub-menu for Boundary options\n            items: [\n                { text: 'Default', iconCss: 'e-boundry e-bpmn-icons e-Default', id: 'Default' },\n                { text: 'Call', iconCss: 'e-boundry e-bpmn-icons e-Call', id: 'BoundryCall' },\n                { text: 'Event', iconCss: 'e-boundry e-bpmn-icons e-Event', id: 'BoundryEvent' }\n            ]\n        },\n        {\n            text: 'Data Object',\n            id: 'DataObject',\n            // Sub-menu for Data Object options\n            items: [\n                { text: 'None', iconCss: 'e-data e-bpmn-icons e-None', id: 'DataObjectNone' },\n                { text: 'Input', iconCss: 'e-data e-bpmn-icons e-DataInput', id: 'Input' },\n                { text: 'Output', iconCss: 'e-data e-bpmn-icons e-DataOutput', id: 'Output' }\n            ]\n        },\n        {\n            text: 'Collection',\n            id: 'collection',\n            // Sub-menu for Collection options\n            items: [\n                { text: 'None', iconCss: 'e-collection e-bpmn-icons e-None', id: 'collectionNone' },\n                { text: 'Collection', iconCss: 'e-collection e-bpmn-icons e-ParallelMI', id: 'Collectioncollection' }\n            ]\n        },\n        {\n            text: 'Call',\n            id: 'DeftCall',\n            // Sub-menu for Call options\n            items: [\n                { text: 'None', iconCss: 'e-call e-bpmn-icons e-None', id: 'CallNone' },\n                { text: 'Call', iconCss: 'e-call e-bpmn-icons e-CallActivity', id: 'CallCall' }\n            ]\n        },\n        {\n            text: 'Trigger Result',\n            id: 'TriggerResult',\n            // Sub-menu for Trigger Result options\n            items: [\n                { text: 'None', id: 'TriggerNone', iconCss: 'e-trigger e-bpmn-icons e-None' },\n                { text: 'Message', id: 'Message', iconCss: 'e-trigger e-bpmn-icons e-InMessage' },\n                { text: 'Multiple', id: 'Multiple', iconCss: 'e-trigger e-bpmn-icons e-InMultiple' },\n                { text: 'Parallel', id: 'Parallel', iconCss: 'e-trigger e-bpmn-icons e-InParallelMultiple' },\n                { text: 'Signal', id: 'Signal', iconCss: 'e-trigger e-bpmn-icons e-InSignal' },\n                { text: 'Timer', id: 'Timer', iconCss: 'e-trigger e-bpmn-icons e-InTimer' },\n                { text: 'Cancel', id: 'Cancel', iconCss: 'e-trigger e-bpmn-icons e-CancelEnd' },\n                { text: 'Escalation', id: 'Escalation', iconCss: 'e-trigger e-bpmn-icons e-InEscalation' },\n                { text: 'Error', id: 'Error', iconCss: 'e-trigger e-bpmn-icons e-InError' },\n                { text: 'Compensation', id: 'triggerCompensation', iconCss: 'e-trigger e-bpmn-icons e-InCompensation' },\n                { text: 'Terminate', id: 'Terminate', iconCss: 'e-trigger e-bpmn-icons e-TerminateEnd' },\n                { text: 'Conditional', id: 'Conditional', iconCss: 'e-trigger e-bpmn-icons e-InConditional' },\n                { text: 'Link', id: 'Link', iconCss: 'e-trigger e-bpmn-icons e-ThrowLinkin' }\n            ]\n        },\n        {\n            text: 'Event Type',\n            id: 'EventType',\n            // Sub-menu for Event Type options\n            items: [\n                { text: 'Start', id: 'Start', iconCss: 'e-event e-bpmn-icons e-NoneStart' },\n                { text: 'Intermediate', id: 'Intermediate', iconCss: 'e-event e-bpmn-icons e-InterruptingNone' },\n                { text: 'NonInterruptingStart', id: 'NonInterruptingStart', iconCss: 'e-event e-bpmn-icons e-Noninterruptingstart' },\n                { text: 'ThrowingIntermediate', id: 'ThrowingIntermediate', iconCss: 'e-event e-bpmn-icons e-ThrowingIntermediate' },\n                { text: 'NonInterruptingIntermediate', id: 'NonInterruptingIntermediate', iconCss: 'e-event e-bpmn-icons e-NoninterruptingIntermediate' },\n                { text: 'End', id: 'End', iconCss: 'e-event e-bpmn-icons e-NoneEnd' }\n            ]\n        },\n        {\n            text: 'Task Type',\n            id: 'TaskType',\n            // Sub-menu for Task Type options\n            items: [\n                { text: 'None', id: 'TaskNone', iconCss: 'e-task e-bpmn-icons e-None' },\n                { text: 'Service', id: 'Service', iconCss: 'e-task e-bpmn-icons e-ServiceTask' },\n                { text: 'BusinessRule', id: 'BusinessRule', iconCss: 'e-task e-bpmn-icons e-BusinessRule' },\n                { text: 'InstantiatingReceive', id: 'InstantiatingReceive', iconCss: 'e-task e-bpmn-icons e-InstantiatingReceive' },\n                { text: 'Manual', id: 'Manual', iconCss: 'e-task e-bpmn-icons e-ManualCall' },\n                { text: 'Receive', id: 'Receive', iconCss: 'e-task e-bpmn-icons e-InMessage' },\n                { text: 'Script', id: 'Script', iconCss: 'e-task e-bpmn-icons e-ScriptCall' },\n                { text: 'Send', id: 'Send', iconCss: 'e-task e-bpmn-icons e-OutMessage' },\n                { text: 'User', id: 'User', iconCss: 'e-task e-bpmn-icons e-UserCall' },\n            ]\n        },\n        {\n            text: 'GateWay',\n            id: 'GateWay',\n            iconCss: 'e-bpmn-icons e-Gateway',\n            // Sub-menu for Gateway options\n            items: [\n                { text: 'None', id: 'GatewayNone', iconCss: 'e-gate e-bpmn-icons e-None' },\n                { text: 'Exclusive', iconCss: 'e-gate e-bpmn-icons e-ExclusiveGatewayWithMarker', id: 'Exclusive' },\n                { text: 'Inclusive', iconCss: 'e-gate e-bpmn-icons e-InclusiveGateway', id: 'Inclusive' },\n                { text: 'Parallel', iconCss: 'e-gate e-bpmn-icons e-ParallelGateway', id: 'GatewayParallel' },\n                { text: 'Complex', iconCss: 'e-gate e-bpmn-icons e-ComplexGateway', id: 'Complex' },\n                { text: 'EventBased', iconCss: 'e-gate e-bpmn-icons e-EventBasedGateway', id: 'EventBased' },\n                { text: 'ExclusiveEventBased', iconCss: 'e-gate e-bpmn-icons e-ExclusiveEventBased', id: 'ExclusiveEventBased' },\n                { text: 'ParallelEventBased', iconCss: 'e-gate e-bpmn-icons e-ParallelEventBasedGatewaytostart', id: 'ParallelEventBased' }\n            ]\n        }\n    ],\n    showCustomMenuOnly: true,\n};\n\n// Configures drag-and-drop behavior for nodes\nfunction dragEnter(args: IDragEnterEventArgs): void {\n    let node: NodeModel = args.element as NodeModel;\n    if (node instanceof Node) {\n        let bpmnShape: BpmnShapeModel = node.shape as BpmnShapeModel;\n        if (!bpmnShape.activity!.subProcess!.collapsed) {\n            const transaction = bpmnShape.activity!.subProcess!.transaction;\n            transaction!.cancel!.visible = true;\n            transaction!.failure!.visible = true;\n            transaction!.success!.visible = true;\n        } else {\n            let ratio: number = 100 / node.width;\n            let oldWidth: number = node.width;\n            let oldHeight: number = node.height;\n            node.width = 100;\n            node.height *= ratio;\n            node.offsetX += (node.width - oldWidth) / 2;\n            node.offsetY += (node.height - oldHeight) / 2;\n        }\n    }\n}\n\n// Handles context menu click events within the BPMN editor.\nfunction contextMenuClick(args: any): void {\n// Check if any node is selected\n    if (diagram.selectedItems.nodes!.length > 0) {\n        let bpmnShape: BpmnShapeModel = diagram.selectedItems.nodes![0].shape as BpmnShapeModel;\n        if (args.item.iconCss) {\n            if (args.item.iconCss.indexOf('e-adhocs') > -1) {\n                bpmnShape.activity!.subProcess!.adhoc = args.item.id === 'AdhocNone' ? false : true;\n            }\n            if (args.item.iconCss.indexOf('e-event') > -1) {\n                bpmnShape.event!.event = (args.item.id as BpmnEvents);\n            }\n            if (args.item.iconCss.indexOf('e-trigger') > -1) {\n                bpmnShape.event!.trigger = (args.item.text as BpmnTriggers);\n            }\n            if (args.item.iconCss.indexOf('e-loop') > -1) {\n                let loop: string = (args.item.id === 'LoopNone' as BpmnLoops) ? 'None' : args.item.id;\n                if (bpmnShape.activity!.activity === 'Task') {\n                    bpmnShape.activity!.task!.loop = loop as BpmnLoops;\n                }\n                if (bpmnShape.activity!.activity === 'SubProcess') {\n                    bpmnShape.activity!.subProcess!.loop = loop as BpmnLoops;\n                }\n            }\n            if (args.item.iconCss.indexOf('e-compensation') > -1) {\n                let compensation: boolean = (args.item.id === 'CompensationNone') ? false : true;\n                if (bpmnShape.activity!.activity === 'Task') {\n                    bpmnShape.activity!.task!.compensation = compensation;\n                }\n                if (bpmnShape.activity!.activity === 'SubProcess') {\n                    bpmnShape.activity!.subProcess!.compensation = compensation;\n                }\n            }\n            if (args.item.iconCss.indexOf('e-call') > -1) {\n                let compensation: boolean = (args.item.id === 'CallNone') ? false : true;\n                if (bpmnShape.activity!.activity === 'Task') {\n                    bpmnShape.activity!.task!.call = compensation;\n                }\n            }\n\n            if (args.item.iconCss.indexOf('e-boundry') > -1) {\n                let call: string = args.item.id;\n                if (args.item.id !== 'Default') {\n                    call = (args.item.id === 'BoundryEvent') ? 'Event' : 'Call';\n                }\n                bpmnShape.activity!.subProcess!.boundary = call as BpmnBoundary;\n            }\n            if (args.item.iconCss.indexOf('e-data') > -1) {\n                let call: string = args.item.id === 'DataObjectNone' ? 'None' : args.item.id;\n                bpmnShape.dataObject!.type = call as BpmnDataObjects;\n            }\n            if (args.item.iconCss.indexOf('e-collection') > -1) {\n                let call: boolean = (args.item.id === 'Collectioncollection') ? true : false;\n                bpmnShape.dataObject!.collection = call;\n            }\n            if (args.item.iconCss.indexOf('e-task') > -1) {\n                let task: string = args.item.id === 'TaskNone' ? 'None' : args.item.id;\n                if (bpmnShape.activity!.activity === 'Task') {\n                    bpmnShape.activity!.task!.type = task as BpmnTasks;\n                }\n            }\n            if (args.item.iconCss.indexOf('e-gate') > -1) {\n                let task: string = args.item.id.replace('Gateway', '');\n                if (bpmnShape.shape === 'Gateway') {\n                    bpmnShape.gateway!.type = task as BpmnGateways;\n                }\n            }\n        }\n        if (args.item.id === 'CollapsedSubProcess' || args.item.id === 'ExpandedSubProcess') {\n            if (args.item.id === 'ExpandedSubProcess') {\n                bpmnShape.activity!.activity = 'SubProcess';\n                bpmnShape.activity!.subProcess!.collapsed = false;\n            } else {\n                bpmnShape.activity!.activity = 'SubProcess';\n                bpmnShape.activity!.subProcess!.collapsed = true;\n            }\n        }\n        diagram.dataBind();\n    }\n\n}\n\n// Initializes the default symbol style symbol palette\nfunction getSymbolDefaults(symbol: NodeModel): void {\n    symbol.style!.strokeColor = '#757575'\n}\n\n// Prepares the context menu before it is opened by determining which items should be visible based on the current selection.\nfunction contextMenuOpen(args: DiagramBeforeMenuOpenEventArgs): void {\n    let hiddenId: string[] = [];\n    if (args.element.className !== 'e-menu-parent e-ul ') {\n        hiddenId = ['Adhoc', 'Loop', 'taskCompensation', 'Activity-Type', 'Boundry', 'DataObject',\n            'collection', 'DeftCall', 'TriggerResult', 'EventType', 'TaskType', 'GateWay'];\n    }\n    if (diagram.selectedItems.nodes!.length) {\n        for (let item of args.items) {\n            let bpmnShape: BpmnShapeModel = diagram.selectedItems.nodes![0].shape as BpmnShapeModel;\n            if (bpmnShape.shape !== 'DataObject' && bpmnShape.shape !== 'Gateway') {\n                if (item.text === 'Ad-Hoc') {\n                    if (bpmnShape.activity!.activity === 'SubProcess') {\n                        hiddenId.splice(hiddenId.indexOf(item.id!), 1);\n                    }\n                }\n                if (item.text === 'Loop' || item.text === 'Compensation' || item.text === 'Activity-Type') {\n                    if (bpmnShape.shape === 'Activity') {\n                        hiddenId.splice(hiddenId.indexOf(item.id!), 1);\n                    }\n                }\n                if (item.text === 'Boundry') {\n                    if (bpmnShape.activity!.activity === 'SubProcess') {\n                        hiddenId.splice(hiddenId.indexOf(item.id!), 1);\n                    }\n                }\n            }\n            if (item.text === 'Data Object') {\n                if (bpmnShape.shape === 'DataObject') {\n                    hiddenId.splice(hiddenId.indexOf(item.id!), 1);\n                }\n            }\n            if (item.text === 'Collection') {\n                if (bpmnShape.shape === 'DataObject') {\n                    hiddenId.splice(hiddenId.indexOf(item.id!), 1);\n                }\n            }\n            if (item.text === 'Call') {\n                if (bpmnShape.shape === 'Activity' && bpmnShape.activity!.activity === 'Task') {\n                    hiddenId.splice(hiddenId.indexOf(item.id!), 1);\n                }\n            }\n            if (item.text === 'Trigger Result') {\n                if ((bpmnShape.shape === 'Event')) {\n                    hiddenId.splice(hiddenId.indexOf(item.id!), 1);\n                }\n            }\n            if (item.text === 'Event Type') {\n                if ((bpmnShape.shape === 'Event')) {\n                    hiddenId.splice(hiddenId.indexOf(item.id!), 1);\n                }\n            }\n            if (item.text === 'Task Type') {\n                if ((bpmnShape.shape === 'Activity')\n                    && (bpmnShape.activity!.activity === 'Task')) {\n                    hiddenId.splice(hiddenId.indexOf(item.id!), 1);\n                }\n            }\n            if (item.text === 'GateWay') {\n                if ((bpmnShape.shape === 'Gateway')) {\n                    hiddenId.splice(hiddenId.indexOf(item.id!), 1);\n                }\n            }\n            if (args.parentItem && args.parentItem.id === 'TriggerResult' && bpmnShape.shape === 'Event') {\n\n                if (item.text !== 'None' && (item.text === bpmnShape.event!.event || item.text === bpmnShape.event!.trigger)) {\n                    hiddenId.push(item.id!);\n                }\n                if (bpmnShape.event!.event === 'Start') {\n                    if (item.text === 'Cancel' || item.text === 'Terminate' || item.text === 'Link') {\n                        hiddenId.push(item.id!);\n                    }\n                }\n                if (bpmnShape.event!.event === 'NonInterruptingStart' || item.text === 'Link') {\n                    if (item.text === 'Cancel' || item.text === 'Terminate' || item.text === 'Compensation' ||\n                        item.text === 'Error' || item.text === 'None') {\n                        hiddenId.push(item.id!);\n                    }\n                }\n                if (bpmnShape.event!.event === 'Intermediate') {\n                    if (item.text === 'Terminate') {\n                        hiddenId.push(item.id!);\n                    }\n                }\n                if (bpmnShape.event!.event === 'NonInterruptingIntermediate') {\n                    if (item.text === 'Cancel' || item.text === 'Terminate' || item.text === 'Compensation' ||\n                        item.text === 'Error' || item.text === 'None' || item.text === 'Link') {\n                        hiddenId.push(item.id!);\n                    }\n                }\n                if (bpmnShape.event!.event === 'ThrowingIntermediate') {\n                    if (item.text === 'Cancel' || item.text === 'Terminate' || item.text === 'Timer' || item.text === 'Error' ||\n                        item.text === 'None' || item.text === 'Pareller' || item.text === 'Conditional') {\n                        hiddenId.push(item.id!);\n                    }\n                }\n                if (bpmnShape.event!.event === 'End') {\n                    if (item.text === 'Parallel' || item.text === 'Timer' || item.text === 'Conditional' || item.text === 'Link') {\n                        hiddenId.push(item.id!);\n                    }\n                }\n            }\n            if (args.parentItem && args.parentItem.id === 'EventType' && bpmnShape.shape === 'Event') {\n                if (item.text === bpmnShape.event!.event) {\n                    hiddenId.push(item.id!);\n                }\n            }\n        }\n    }\n    args.hiddenItems = hiddenId; // Set the hidden menu items based on the logic above\n}\n\n// Initialization function for the diagram and symbol palette\nexport function initBpmnEditor(): void {\n    //Initializtion of the diagram.\n    diagram = new Diagram({\n        width: '100%', height: '445px', nodes: nodes, connectors: connectors,\n        contextMenuSettings: contextMenu,\n        contextMenuOpen: contextMenuOpen,\n        contextMenuClick: contextMenuClick,\n        snapSettings: { constraints: 0 },\n        dragEnter: dragEnter\n    });\n    diagram.appendTo('#container');\n    diagram.fitToPage();\n\n    //Initializes the symbol palette\n    let palette: SymbolPalette = new SymbolPalette({\n        expandMode: 'Multiple', symbolMargin: { left: 15, right: 15, top: 15, bottom: 15 }, symbolHeight: 60, symbolWidth: 60,\n        palettes: [\n            { id: 'Bpmn', expanded: true, symbols: bpmnShapes, iconCss: 'shapes', title: 'BPMN Shapes' },\n            { id: 'Connector', expanded: true, symbols: connectorSymbols, iconCss: 'shapes', title: 'Connectors' },\n        ],\n        width: '100%', height: '471px', getNodeDefaults: getSymbolDefaults\n    });\n    palette.appendTo('#symbolpalette');\n\n    // Function to add event listeners for Symbol palette to Mobile device\n    // addEvents();\n}"
    }
  ]
}